Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVeronika Irvine2003-03-05 15:00:14 +0000
committerVeronika Irvine2003-03-05 15:00:14 +0000
commit281dc95420976f0ffb0cbab0dc7e5e4a8f3ac547 (patch)
tree7682936f0fef30a163a6b92d96ef435e09c564c1
parent4d0b24a27232ff40c8169511178d0b60b9efdcc2 (diff)
downloadeclipse.platform.swt-281dc95420976f0ffb0cbab0dc7e5e4a8f3ac547.tar.gz
eclipse.platform.swt-281dc95420976f0ffb0cbab0dc7e5e4a8f3ac547.tar.xz
eclipse.platform.swt-281dc95420976f0ffb0cbab0dc7e5e4a8f3ac547.zip
Converting Binary files to ASCII
-rw-r--r--bundles/org.eclipse.swt/.classpath_motif_j2me44
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT AWT/win32/org/eclipse/swt/internal/awt/win32/SWT_AWT.java302
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT Accessibility/common/org/eclipse/swt/accessibility/ACC.java120
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT Accessibility/common/org/eclipse/swt/accessibility/AccessibleAdapter.java242
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT Accessibility/common/org/eclipse/swt/accessibility/AccessibleControlAdapter.java488
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT Accessibility/common/org/eclipse/swt/accessibility/AccessibleControlEvent.java96
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT Accessibility/common/org/eclipse/swt/accessibility/AccessibleControlListener.java452
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT Accessibility/common/org/eclipse/swt/accessibility/AccessibleEvent.java92
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT Accessibility/common/org/eclipse/swt/accessibility/AccessibleListener.java238
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT Accessibility/emulated/org/eclipse/swt/accessibility/Accessible.java362
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT Accessibility/win32/org/eclipse/swt/accessibility/Accessible.java2320
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/AnimatedProgress.java424
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/BidiSegmentEvent.java132
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/BidiSegmentListener.java58
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/BusyIndicator.java152
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/CCombo.java2352
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/CLabel.java1216
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/CTabFolder.java4198
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/CTabFolderAdapter.java16
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/CTabFolderEvent.java32
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/CTabFolderListener.java16
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/CTabItem.java1028
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/ControlEditor.java476
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/DefaultContent.java1750
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/DefaultLineStyler.java1354
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/ExtendedModifyEvent.java42
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/ExtendedModifyListener.java40
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/LineBackgroundEvent.java48
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/LineBackgroundListener.java38
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/LineStyleEvent.java42
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/LineStyleListener.java36
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/PopupList.java494
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/ST.java118
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/SashForm.java892
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/ScrolledComposite.java1160
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/StackLayout.java222
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/StyleRange.java302
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/StyledText.java16526
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/StyledTextBidi.java2106
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/StyledTextContent.java396
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/StyledTextEvent.java62
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/StyledTextListener.java140
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/TableCursor.java1022
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/TableEditor.java380
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/TableTree.java1478
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/TableTreeEditor.java454
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/TableTreeItem.java1600
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/TextChangeListener.java108
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/TextChangedEvent.java44
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/TextChangingEvent.java118
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/TreeEditor.java318
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/VerifyKeyListener.java32
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/ViewForm.java1222
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/WrappedContent.java1326
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT Drag and Drop/common/org/eclipse/swt/dnd/DND.java452
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT Drag and Drop/common/org/eclipse/swt/dnd/DNDEvent.java30
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT Drag and Drop/common/org/eclipse/swt/dnd/DNDListener.java154
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT Drag and Drop/common/org/eclipse/swt/dnd/DragSourceAdapter.java66
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT Drag and Drop/common/org/eclipse/swt/dnd/DragSourceEvent.java126
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT Drag and Drop/common/org/eclipse/swt/dnd/DragSourceListener.java146
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT Drag and Drop/common/org/eclipse/swt/dnd/DragUnderEffect.java20
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT Drag and Drop/common/org/eclipse/swt/dnd/DropTargetAdapter.java118
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT Drag and Drop/common/org/eclipse/swt/dnd/DropTargetEvent.java210
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT Drag and Drop/common/org/eclipse/swt/dnd/DropTargetListener.java486
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT Drag and Drop/common/org/eclipse/swt/dnd/NoDragUnderEffect.java24
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT Drag and Drop/motif/org/eclipse/swt/dnd/ByteArrayTransfer.java348
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT Drag and Drop/motif/org/eclipse/swt/dnd/Clipboard.java652
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT Drag and Drop/motif/org/eclipse/swt/dnd/DragSource.java1044
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT Drag and Drop/motif/org/eclipse/swt/dnd/DropTarget.java1610
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT Drag and Drop/motif/org/eclipse/swt/dnd/FileTransfer.java216
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT Drag and Drop/motif/org/eclipse/swt/dnd/RTFTransfer.java156
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT Drag and Drop/motif/org/eclipse/swt/dnd/TableDragUnderEffect.java200
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT Drag and Drop/motif/org/eclipse/swt/dnd/TextTransfer.java254
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT Drag and Drop/motif/org/eclipse/swt/dnd/Transfer.java248
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT Drag and Drop/motif/org/eclipse/swt/dnd/TransferData.java114
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT Drag and Drop/motif/org/eclipse/swt/dnd/TreeDragUnderEffect.java426
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT Drag and Drop/photon/org/eclipse/swt/dnd/ByteArrayTransfer.java352
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT Drag and Drop/photon/org/eclipse/swt/dnd/Clipboard.java566
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT Drag and Drop/photon/org/eclipse/swt/dnd/DragSource.java516
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT Drag and Drop/photon/org/eclipse/swt/dnd/DropTarget.java514
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT Drag and Drop/photon/org/eclipse/swt/dnd/FileTransfer.java216
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT Drag and Drop/photon/org/eclipse/swt/dnd/RTFTransfer.java154
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT Drag and Drop/photon/org/eclipse/swt/dnd/TableDragUnderEffect.java122
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT Drag and Drop/photon/org/eclipse/swt/dnd/TextTransfer.java154
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT Drag and Drop/photon/org/eclipse/swt/dnd/Transfer.java236
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT Drag and Drop/photon/org/eclipse/swt/dnd/TransferData.java94
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT Drag and Drop/photon/org/eclipse/swt/dnd/TreeDragUnderEffect.java200
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT Drag and Drop/win32/org/eclipse/swt/dnd/ByteArrayTransfer.java448
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT Drag and Drop/win32/org/eclipse/swt/dnd/Clipboard.java1000
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT Drag and Drop/win32/org/eclipse/swt/dnd/DragSource.java1038
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT Drag and Drop/win32/org/eclipse/swt/dnd/DropTarget.java1320
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT Drag and Drop/win32/org/eclipse/swt/dnd/FileTransfer.java314
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT Drag and Drop/win32/org/eclipse/swt/dnd/OleEnumFORMATETC.java306
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT Drag and Drop/win32/org/eclipse/swt/dnd/RTFTransfer.java256
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT Drag and Drop/win32/org/eclipse/swt/dnd/TableDragUnderEffect.java230
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT Drag and Drop/win32/org/eclipse/swt/dnd/TextTransfer.java240
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT Drag and Drop/win32/org/eclipse/swt/dnd/Transfer.java254
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT Drag and Drop/win32/org/eclipse/swt/dnd/TransferData.java116
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT Drag and Drop/win32/org/eclipse/swt/dnd/TreeDragUnderEffect.java422
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/internal/ole/win32/COMObject.java2046
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/ole/win32/OLE.java854
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/ole/win32/OleAutomation.java1192
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/ole/win32/OleClientSite.java2672
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/ole/win32/OleControlSite.java1616
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/ole/win32/OleEvent.java30
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/ole/win32/OleEventSink.java348
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/ole/win32/OleEventTable.java136
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/ole/win32/OleFile.java250
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/ole/win32/OleFrame.java1372
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/ole/win32/OleFunctionDescription.java40
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/ole/win32/OleListener.java30
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/ole/win32/OleParameterDescription.java20
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/ole/win32/OlePropertyChangeSink.java368
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/ole/win32/OlePropertyDescription.java28
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/ole/win32/Variant.java1476
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/common_j2me/org/eclipse/swt/internal/Library.java124
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/common_j2se/org/eclipse/swt/internal/Library.java224
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/GdkColor.java42
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/GdkEventExpose.java52
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/GdkGCValues.java82
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/GdkImage.java56
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/GdkRectangle.java42
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/GdkVisual.java60
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/GtkAdjustment.java44
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/GtkAllocation.java42
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/GtkRequisition.java38
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/gtk1x/org/eclipse/swt/internal/gtk/GdkColor.java46
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/gtk1x/org/eclipse/swt/internal/gtk/GdkEvent.java44
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/gtk1x/org/eclipse/swt/internal/gtk/GdkEventButton.java60
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/gtk1x/org/eclipse/swt/internal/gtk/GdkEventExpose.java46
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/gtk1x/org/eclipse/swt/internal/gtk/GdkEventKey.java46
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/gtk1x/org/eclipse/swt/internal/gtk/GdkEventMotion.java60
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/gtk1x/org/eclipse/swt/internal/gtk/GdkFont.java44
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/gtk1x/org/eclipse/swt/internal/gtk/GdkGCValues.java86
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/gtk1x/org/eclipse/swt/internal/gtk/GdkRectangle.java46
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/gtk1x/org/eclipse/swt/internal/gtk/GdkVisual.java66
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/gtk1x/org/eclipse/swt/internal/gtk/GtkAdjustment.java50
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/gtk1x/org/eclipse/swt/internal/gtk/GtkAllocation.java46
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/gtk1x/org/eclipse/swt/internal/gtk/GtkBox.java44
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/gtk1x/org/eclipse/swt/internal/gtk/GtkCListColumn.java68
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/gtk1x/org/eclipse/swt/internal/gtk/GtkCListRow.java70
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/gtk1x/org/eclipse/swt/internal/gtk/GtkCTreeRow.java58
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/gtk1x/org/eclipse/swt/internal/gtk/GtkCheckMenuItem.java42
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/gtk1x/org/eclipse/swt/internal/gtk/GtkColorSelectionDialog.java50
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/gtk1x/org/eclipse/swt/internal/gtk/GtkFileSelection.java78
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/gtk1x/org/eclipse/swt/internal/gtk/GtkFontSelectionDialog.java54
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/gtk1x/org/eclipse/swt/internal/gtk/GtkHBox.java38
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/gtk1x/org/eclipse/swt/internal/gtk/GtkItem.java38
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/gtk1x/org/eclipse/swt/internal/gtk/GtkMenuItem.java58
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/gtk1x/org/eclipse/swt/internal/gtk/GtkRequisition.java42
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/gtk1x/org/eclipse/swt/internal/gtk/GtkStyleClass.java40
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/gtk1x/org/eclipse/swt/internal/gtk/GtkText.java50
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/motif/org/eclipse/swt/internal/motif/GNOME.java32
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/motif/org/eclipse/swt/internal/motif/KDE.java112
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/motif/org/eclipse/swt/internal/motif/OS.java2878
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/motif/org/eclipse/swt/internal/motif/Visual.java30
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/motif/org/eclipse/swt/internal/motif/XAnyEvent.java20
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/motif/org/eclipse/swt/internal/motif/XButtonEvent.java22
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/motif/org/eclipse/swt/internal/motif/XCharStruct.java30
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/motif/org/eclipse/swt/internal/motif/XColor.java26
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/motif/org/eclipse/swt/internal/motif/XConfigureEvent.java30
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/motif/org/eclipse/swt/internal/motif/XCrossingEvent.java36
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/motif/org/eclipse/swt/internal/motif/XEvent.java28
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/motif/org/eclipse/swt/internal/motif/XExposeEvent.java26
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/motif/org/eclipse/swt/internal/motif/XFocusChangeEvent.java34
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/motif/org/eclipse/swt/internal/motif/XFontStruct.java70
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/motif/org/eclipse/swt/internal/motif/XGCValues.java64
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/motif/org/eclipse/swt/internal/motif/XImage.java48
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/motif/org/eclipse/swt/internal/motif/XInputEvent.java18
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/motif/org/eclipse/swt/internal/motif/XKeyEvent.java22
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/motif/org/eclipse/swt/internal/motif/XMotionEvent.java22
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/motif/org/eclipse/swt/internal/motif/XRectangle.java26
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/motif/org/eclipse/swt/internal/motif/XSetWindowAttributes.java48
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/motif/org/eclipse/swt/internal/motif/XWindowAttributes.java60
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/motif/org/eclipse/swt/internal/motif/XWindowChanges.java28
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/motif/org/eclipse/swt/internal/motif/XWindowEvent.java26
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/motif/org/eclipse/swt/internal/motif/XmAnyCallbackStruct.java22
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/motif/org/eclipse/swt/internal/motif/XmDragProcCallback.java40
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/motif/org/eclipse/swt/internal/motif/XmDropFinishCallback.java36
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/motif/org/eclipse/swt/internal/motif/XmDropProcCallback.java40
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/motif/org/eclipse/swt/internal/motif/XmTextBlockRec.java24
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/motif/org/eclipse/swt/internal/motif/XmTextVerifyCallbackStruct.java30
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/motif/org/eclipse/swt/internal/motif/XtWidgetGeometry.java28
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/photon/library/swt.c268
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/photon/org/eclipse/swt/internal/photon/FontDetails.java28
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/photon/org/eclipse/swt/internal/photon/FontQueryInfo.java36
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/photon/org/eclipse/swt/internal/photon/OS.java5956
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/photon/org/eclipse/swt/internal/photon/PgAlpha_t.java44
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/photon/org/eclipse/swt/internal/photon/PgDisplaySettings_t.java28
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/photon/org/eclipse/swt/internal/photon/PgMap_t.java28
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/photon/org/eclipse/swt/internal/photon/PgVideoModeInfo_t.java40
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/photon/org/eclipse/swt/internal/photon/PhArea_t.java24
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/photon/org/eclipse/swt/internal/photon/PhClipHeader.java48
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/photon/org/eclipse/swt/internal/photon/PhCursorDef_t.java70
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/photon/org/eclipse/swt/internal/photon/PhCursorInfo_t.java72
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/photon/org/eclipse/swt/internal/photon/PhDim_t.java20
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/photon/org/eclipse/swt/internal/photon/PhEvent_t.java50
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/photon/org/eclipse/swt/internal/photon/PhImage_t.java52
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/photon/org/eclipse/swt/internal/photon/PhKeyEvent_t.java36
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/photon/org/eclipse/swt/internal/photon/PhPoint_t.java20
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/photon/org/eclipse/swt/internal/photon/PhPointerEvent_t.java36
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/photon/org/eclipse/swt/internal/photon/PhRect_t.java24
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/photon/org/eclipse/swt/internal/photon/PhRegion_t.java60
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/photon/org/eclipse/swt/internal/photon/PhTile_t.java28
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/photon/org/eclipse/swt/internal/photon/PhWindowEvent_t.java40
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/photon/org/eclipse/swt/internal/photon/PtCallbackInfo_t.java24
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/photon/org/eclipse/swt/internal/photon/PtColorSelectInfo_t.java50
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/photon/org/eclipse/swt/internal/photon/PtContainerCallback_t.java40
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/photon/org/eclipse/swt/internal/photon/PtFileSelectionInfo_t.java46
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/photon/org/eclipse/swt/internal/photon/PtScrollbarCallback_t.java20
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/photon/org/eclipse/swt/internal/photon/PtTextCallback_t.java32
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/build-ce.bat122
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/build.bat52
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/defines.h42
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/make_win32.mak112
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/make_wince.mak214
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/structs.c10026
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/structs.h1634
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/swt.c14640
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/ole/win32/CAUUID.java24
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/ole/win32/COM.java1334
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/ole/win32/CONTROLINFO.java28
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/ole/win32/COSERVERINFO.java26
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/ole/win32/DISPPARAMS.java30
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/ole/win32/DVTARGETDEVICE.java32
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/ole/win32/EXCEPINFO.java38
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/ole/win32/FORMATETC.java30
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/ole/win32/FUNCDESC1.java56
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/ole/win32/FUNCDESC2.java56
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/ole/win32/GUID.java42
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/ole/win32/IAccessible.java154
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/ole/win32/IClassFactory2.java40
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/ole/win32/IConnectionPoint.java34
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/ole/win32/IConnectionPointContainer.java28
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/ole/win32/IDataObject.java72
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/ole/win32/IDispatch.java118
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/ole/win32/IEnum.java46
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/ole/win32/IEnumFORMATETC.java20
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/ole/win32/IEnumSTATSTG.java20
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/ole/win32/IFont.java26
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/ole/win32/IMoniker.java22
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/ole/win32/IOleCommandTarget.java58
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/ole/win32/IOleControl.java28
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/ole/win32/IOleInPlaceActiveObject.java40
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/ole/win32/IOleInPlaceObject.java50
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/ole/win32/IOleLink.java34
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/ole/win32/IOleObject.java106
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/ole/win32/IOleWindow.java26
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/ole/win32/IPersist.java28
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/ole/win32/IPersistStorage.java58
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/ole/win32/IProvideClassInfo.java28
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/ole/win32/IProvideClassInfo2.java28
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/ole/win32/ISpecifyPropertyPages.java28
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/ole/win32/IStorage.java284
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/ole/win32/IStream.java56
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/ole/win32/ITypeInfo.java306
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/ole/win32/IUnknown.java48
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/ole/win32/IViewObject2.java38
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/ole/win32/LICINFO.java26
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/ole/win32/OLECMD.java22
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/ole/win32/OLECMDTEXT.java30
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/ole/win32/OLEINPLACEFRAMEINFO.java34
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/ole/win32/STATSTG.java74
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/ole/win32/STGMEDIUM.java26
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/ole/win32/TYPEATTR.java92
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/ole/win32/VARDESC1.java42
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/ole/win32/VARDESC2.java42
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/ACCEL.java22
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/BITMAP.java30
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/BROWSEINFO.java32
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/CHOOSECOLOR.java34
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/CHOOSEFONT.java46
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/COMPOSITIONFORM.java26
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/CREATESTRUCT.java40
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/DIBSECTION.java48
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/DLLVERSIONINFO.java26
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/DOCINFO.java24
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/DRAWITEMSTRUCT.java36
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/DROPFILES.java38
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/FILETIME.java22
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/GCP_RESULTS.java36
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/GRADIENT_RECT.java22
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/HDITEM.java34
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/HELPINFO.java32
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/ICONINFO.java26
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/INITCOMMONCONTROLSEX.java20
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/LOGBRUSH.java22
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/LOGFONT.java62
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/LOGPEN.java26
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/LRESULT.java26
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/LVCOLUMN.java32
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/LVHITTESTINFO.java28
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/LVITEM.java36
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/MEASUREITEMSTRUCT.java28
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/MENUINFO.java30
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/MENUITEMINFO.java62
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/MSG.java30
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/NMHDR.java22
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/NMHEADER.java22
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/NMLISTVIEW.java32
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/NMTOOLBAR.java42
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/NMTTDISPINFO.java32
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/NONCLIENTMETRICS.java60
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/OPENFILENAME.java56
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/OS.java4856
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/OSVERSIONINFO.java36
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/PAINTSTRUCT.java32
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/POINT.java20
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/PRINTDLG.java52
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/REBARBANDINFO.java58
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/RECT.java24
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/SCROLLINFO.java30
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/SHELLEXECUTEINFO.java64
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/SHMENUBARINFO.java30
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/SIZE.java20
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/TBBUTTON.java28
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/TBBUTTONINFO.java36
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/TCHAR.java216
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/TCITEM.java30
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/TEXTMETRIC.java64
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/TOOLINFO.java34
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/TRACKMOUSEEVENT.java26
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/TRIVERTEX.java30
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/TVHITTESTINFO.java26
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/TVINSERTSTRUCT.java42
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/TVITEM.java36
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/WINDOWPLACEMENT.java44
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/WINDOWPOS.java30
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/WNDCLASS.java36
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT Printing/common/org/eclipse/swt/printing/PrinterData.java316
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT Printing/gtk/org/eclipse/swt/printing/PrintDialog.java358
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT Printing/gtk/org/eclipse/swt/printing/Printer.java176
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT Printing/gtk1x/org/eclipse/swt/printing/PrintDialog.java112
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT Printing/gtk1x/org/eclipse/swt/printing/Printer.java182
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT Printing/motif/org/eclipse/swt/printing/PrintDialog.java358
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT Printing/photon/org/eclipse/swt/printing/PrintDialog.java358
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT Printing/photon/org/eclipse/swt/printing/Printer.java178
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT Printing/win32/org/eclipse/swt/printing/PrintDialog.java586
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT Printing/win32/org/eclipse/swt/printing/Printer.java1020
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT Program/photon/org/eclipse/swt/program/Program.java614
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT Program/win32/org/eclipse/swt/program/Program.java648
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/common/library/swt.h24
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/SWT.java4756
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/SWTError.java220
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/SWTException.java206
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/events/ArmEvent.java56
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/events/ArmListener.java62
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/events/ControlAdapter.java78
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/events/ControlEvent.java60
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/events/ControlListener.java82
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/events/DisposeEvent.java58
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/events/DisposeListener.java64
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/events/FocusAdapter.java76
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/events/FocusEvent.java58
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/events/FocusListener.java82
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/events/HelpEvent.java58
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/events/HelpListener.java66
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/events/KeyAdapter.java76
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/events/KeyEvent.java118
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/events/KeyListener.java80
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/events/MenuAdapter.java76
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/events/MenuEvent.java58
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/events/MenuListener.java78
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/events/ModifyEvent.java58
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/events/ModifyListener.java62
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/events/MouseAdapter.java102
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/events/MouseEvent.java134
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/events/MouseListener.java100
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/events/MouseMoveListener.java62
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/events/MouseTrackAdapter.java104
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/events/MouseTrackListener.java102
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/events/PaintEvent.java150
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/events/PaintListener.java64
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/events/SelectionAdapter.java76
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/events/SelectionEvent.java192
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/events/SelectionListener.java98
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/events/ShellAdapter.java130
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/events/ShellEvent.java58
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/events/ShellListener.java120
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/events/TraverseEvent.java238
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/events/TraverseListener.java76
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/events/TreeAdapter.java76
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/events/TreeEvent.java58
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/events/TreeListener.java80
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/events/TypedEvent.java136
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/events/VerifyEvent.java108
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/events/VerifyListener.java76
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/graphics/Drawable.java86
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/graphics/ImageData.java7094
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/graphics/ImageLoader.java580
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/graphics/ImageLoaderEvent.java152
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/graphics/ImageLoaderListener.java74
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/graphics/PaletteData.java408
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/graphics/Point.java184
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/graphics/RGB.java214
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/graphics/Rectangle.java544
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal/Callback.java372
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal/image/FileFormat.java214
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal/image/GIFFileFormat.java1048
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal/image/JPEGAppn.java42
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal/image/JPEGArithmeticConditioningTable.java32
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal/image/JPEGComment.java40
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal/image/JPEGEndOfImage.java48
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal/image/JPEGFileFormat.java3778
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal/image/JPEGFixedSizeSegment.java74
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal/image/JPEGFrameHeader.java414
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal/image/JPEGHuffmanTable.java522
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal/image/JPEGQuantizationTable.java316
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal/image/JPEGRestartInterval.java48
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal/image/JPEGScanHeader.java232
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal/image/JPEGSegment.java102
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal/image/JPEGStartOfImage.java56
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal/image/JPEGVariableSizeSegment.java62
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal/image/LEDataInputStream.java354
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal/image/LEDataOutputStream.java100
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal/image/LZWCodec.java950
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal/image/LZWNode.java20
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal/image/PNGFileFormat.java1060
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal/image/PngChunk.java664
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal/image/PngChunkReader.java124
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal/image/PngDecodingDataStream.java256
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal/image/PngFileReadState.java36
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal/image/PngHuffmanTable.java240
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal/image/PngHuffmanTables.java308
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal/image/PngIdatChunk.java68
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal/image/PngIendChunk.java74
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal/image/PngIhdrChunk.java742
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal/image/PngLzBlockReader.java330
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal/image/PngPlteChunk.java172
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal/image/PngTrnsChunk.java262
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal/image/WinBMPFileFormat.java1324
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal/image/WinICOFileFormat.java562
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/layout/FillLayout.java216
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/layout/FormAttachment.java516
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/layout/FormLayout.java10
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/layout/GridData.java384
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/layout/GridLayout.java1376
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/layout/RowData.java100
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/layout/RowLayout.java588
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/widgets/Dialog.java500
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/widgets/Event.java410
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/widgets/EventTable.java254
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/widgets/Item.java348
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/widgets/Layout.java160
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/widgets/Listener.java88
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/widgets/RunnableLock.java64
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/widgets/Synchronizer.java310
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/widgets/TypedListener.java442
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/common/version.txt2
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/common_j2me/org/eclipse/swt/internal/CloneableCompatibility.java46
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/common_j2me/org/eclipse/swt/internal/Compatibility.java778
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/common_j2me/org/eclipse/swt/internal/SWTEventListener.java38
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/common_j2me/org/eclipse/swt/internal/SWTEventObject.java106
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/common_j2me/org/eclipse/swt/internal/SerializableCompatibility.java48
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/common_j2se/org/eclipse/swt/internal/CloneableCompatibility.java38
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/common_j2se/org/eclipse/swt/internal/Compatibility.java600
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/common_j2se/org/eclipse/swt/internal/SWTEventListener.java42
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/common_j2se/org/eclipse/swt/internal/SWTEventObject.java60
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/common_j2se/org/eclipse/swt/internal/SWTMessages.properties82
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/common_j2se/org/eclipse/swt/internal/SerializableCompatibility.java44
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/emulated/bidi/org/eclipse/swt/internal/BidiUtil.java164
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/emulated/coolbar/org/eclipse/swt/widgets/CoolBar.java2104
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/emulated/coolbar/org/eclipse/swt/widgets/CoolItem.java1234
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/emulated/tabfolder/org/eclipse/swt/widgets/TabFolder.java2222
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/emulated/tabfolder/org/eclipse/swt/widgets/TabItem.java772
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/emulated/treetable/org/eclipse/swt/widgets/AbstractTreeItem.java620
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/emulated/treetable/org/eclipse/swt/widgets/SelectableItem.java630
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/emulated/treetable/org/eclipse/swt/widgets/SelectableItemWidget.java4126
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/emulated/treetable/org/eclipse/swt/widgets/Table.java5396
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/emulated/treetable/org/eclipse/swt/widgets/TableColumn.java1012
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/emulated/treetable/org/eclipse/swt/widgets/TableItem.java2400
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/emulated/treetable/org/eclipse/swt/widgets/Tree.java3308
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/emulated/treetable/org/eclipse/swt/widgets/TreeItem.java2710
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/emulated/treetable/org/eclipse/swt/widgets/TreeRoots.java312
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/Color.java250
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/Cursor.java266
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/Device.java366
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/Font.java200
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/FontData.java488
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/FontMetrics.java92
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/GC.java1712
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/GCData.java62
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/Image.java744
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/Region.java528
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/internal/Converter.java100
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Button.java410
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Canvas.java204
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Caret.java456
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ColorDialog.java276
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Combo.java1046
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Composite.java288
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Control.java2136
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Decorations.java1074
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/DirectoryDialog.java350
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Display.java1074
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/FileDialog.java582
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/FontDialog.java336
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Group.java150
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Label.java264
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/List.java1212
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Menu.java790
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/MenuItem.java866
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TabFolder.java940
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TabItem.java258
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ToolBar.java4
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Tracker.java710
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TreeItem.java544
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/WidgetTable.java200
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk1x/org/eclipse/swt/graphics/DefaultGtkStyle.java230
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk1x/org/eclipse/swt/graphics/FontData.java868
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk1x/org/eclipse/swt/graphics/FontMetrics.java104
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk1x/org/eclipse/swt/graphics/GCData.java28
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk1x/org/eclipse/swt/graphics/Region.java210
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk1x/org/eclipse/swt/internal/Converter.java112
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk1x/org/eclipse/swt/widgets/ColorDialog.java164
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk1x/org/eclipse/swt/widgets/Decorations.java322
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk1x/org/eclipse/swt/widgets/DirectoryDialog.java100
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk1x/org/eclipse/swt/widgets/FileDialog.java136
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk1x/org/eclipse/swt/widgets/FontDialog.java162
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk1x/org/eclipse/swt/widgets/Menu.java522
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk1x/org/eclipse/swt/widgets/MenuItem.java702
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk1x/org/eclipse/swt/widgets/TabFolder.java870
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk1x/org/eclipse/swt/widgets/TabItem.java184
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk1x/org/eclipse/swt/widgets/TableColumn.java408
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk1x/org/eclipse/swt/widgets/TableItem.java740
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk1x/org/eclipse/swt/widgets/ToolBar.java4
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk1x/org/eclipse/swt/widgets/Tracker.java778
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk1x/org/eclipse/swt/widgets/TreeItem.java824
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk1x/org/eclipse/swt/widgets/WidgetTable.java176
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/graphics/Color.java386
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/graphics/Cursor.java320
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/graphics/Device.java922
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/graphics/DeviceData.java44
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/graphics/Font.java734
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/graphics/FontData.java668
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/graphics/FontMetrics.java108
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/graphics/GC.java3320
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/graphics/GCData.java42
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/graphics/Image.java1930
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/graphics/Region.java180
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/internal/Converter.java610
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Button.java1260
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Canvas.java432
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Caret.java868
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/ColorDialog.java822
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Combo.java2746
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Composite.java1294
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Control.java5450
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Decorations.java1122
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/DirectoryDialog.java556
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Display.java4454
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/FileDialog.java886
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/FontDialog.java1852
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Group.java540
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Label.java818
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/List.java2862
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Menu.java1380
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/MenuItem.java1524
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/MessageBox.java750
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/ProgressBar.java702
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Sash.java718
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Scale.java586
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/ScrollBar.java1184
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Scrollable.java580
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Shell.java2504
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Slider.java976
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Text.java2612
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/ToolBar.java768
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/ToolDrawable.java72
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/ToolItem.java1976
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Tracker.java1134
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Widget.java2120
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/WidgetTable.java240
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/graphics/Color.java202
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/graphics/Cursor.java372
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/graphics/Device.java568
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/graphics/DeviceData.java30
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/graphics/Font.java308
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/graphics/FontData.java422
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/graphics/FontMetrics.java152
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/graphics/GC.java3430
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/graphics/GCData.java42
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/graphics/Image.java1326
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/graphics/Region.java298
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/internal/Converter.java92
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Button.java884
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Canvas.java220
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Caret.java526
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/ColorDialog.java106
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Combo.java1348
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Composite.java1248
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Control.java2988
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Decorations.java440
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/DirectoryDialog.java122
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Display.java2778
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/FileDialog.java258
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/FontDialog.java168
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Group.java252
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Label.java610
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/List.java1180
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Menu.java768
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/MenuItem.java1046
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/MessageBox.java222
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/ProgressBar.java242
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Sash.java632
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Scale.java328
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/ScrollBar.java654
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Scrollable.java248
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Shell.java1678
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Slider.java444
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/TabFolder.java890
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/TabItem.java264
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Text.java1460
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/ToolBar.java606
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/ToolItem.java1106
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Tracker.java1210
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Widget.java1580
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/WidgetTable.java212
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/Color.java654
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/Cursor.java802
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/Device.java1420
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/DeviceData.java30
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/Font.java506
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/FontData.java1380
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/FontMetrics.java340
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/GC.java4604
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/GCData.java60
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/Image.java3798
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/Region.java608
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/BidiUtil.java1056
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/Converter.java366
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Button.java1418
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Canvas.java426
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Caret.java1104
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/ColorDialog.java390
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Combo.java2916
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Composite.java1654
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Control.java8440
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/CoolBar.java1996
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/CoolItem.java1324
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Decorations.java2722
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/DirectoryDialog.java478
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Display.java4660
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/FileDialog.java816
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/FontDialog.java468
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Group.java740
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/ImageList.java502
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Label.java1160
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/List.java3074
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Menu.java2394
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/MenuItem.java1946
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/MessageBox.java498
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/ProgressBar.java552
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Sash.java802
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Scale.java826
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/ScrollBar.java2002
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Scrollable.java752
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Shell.java2718
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Slider.java1592
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/TabFolder.java1578
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/TabItem.java628
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Table.java5018
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/TableColumn.java952
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/TableItem.java1416
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Text.java3504
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/ToolBar.java1850
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/ToolItem.java1656
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Tracker.java1446
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Tree.java3808
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/TreeItem.java1362
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Widget.java2108
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/WidgetTable.java224
-rw-r--r--bundles/org.eclipse.swt/build.properties2
-rw-r--r--bundles/org.eclipse.swt/build.xml74
-rwxr-xr-xbundles/org.eclipse.swt/buildnotes_swt.html4544
-rw-r--r--bundles/org.eclipse.swt/plugin.properties2
-rwxr-xr-xbundles/org.eclipse.swt/plugin.xml32
-rwxr-xr-xbundles/org.eclipse.swt/readme_swt.html232
678 files changed, 205790 insertions, 205790 deletions
diff --git a/bundles/org.eclipse.swt/.classpath_motif_j2me b/bundles/org.eclipse.swt/.classpath_motif_j2me
index 2baed49c5d..5da30731c7 100644
--- a/bundles/org.eclipse.swt/.classpath_motif_j2me
+++ b/bundles/org.eclipse.swt/.classpath_motif_j2me
@@ -1,23 +1,23 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<classpath>
- <classpathentry kind="var" path="JRE_LIB"/>
- <classpathentry kind="src" path="Eclipse SWT/motif"/>
- <classpathentry kind="src" path="Eclipse SWT/emulated/bidi"/>
- <classpathentry kind="src" path="Eclipse SWT/emulated/coolbar"/>
- <classpathentry kind="src" path="Eclipse SWT/emulated/tabfolder"/>
- <classpathentry kind="src" path="Eclipse SWT/emulated/treetable"/>
- <classpathentry kind="src" path="Eclipse SWT/common"/>
- <classpathentry kind="src" path="Eclipse SWT/common_j2me"/>
- <classpathentry kind="src" path="Eclipse SWT PI/motif"/>
- <classpathentry kind="src" path="Eclipse SWT PI/common_j2me"/>
- <classpathentry kind="src" path="Eclipse SWT Accessibility/emulated"/>
- <classpathentry kind="src" path="Eclipse SWT Accessibility/common"/>
- <classpathentry kind="src" path="Eclipse SWT Drag and Drop/motif"/>
- <classpathentry kind="src" path="Eclipse SWT Drag and Drop/common"/>
- <classpathentry kind="src" path="Eclipse SWT Printing/motif"/>
- <classpathentry kind="src" path="Eclipse SWT Printing/common"/>
- <classpathentry kind="src" path="Eclipse SWT Program/motif"/>
- <classpathentry kind="src" path="Eclipse SWT Program/common"/>
- <classpathentry kind="src" path="Eclipse SWT Custom Widgets/common"/>
- <classpathentry kind="output" path="bin"/>
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="var" path="JRE_LIB"/>
+ <classpathentry kind="src" path="Eclipse SWT/motif"/>
+ <classpathentry kind="src" path="Eclipse SWT/emulated/bidi"/>
+ <classpathentry kind="src" path="Eclipse SWT/emulated/coolbar"/>
+ <classpathentry kind="src" path="Eclipse SWT/emulated/tabfolder"/>
+ <classpathentry kind="src" path="Eclipse SWT/emulated/treetable"/>
+ <classpathentry kind="src" path="Eclipse SWT/common"/>
+ <classpathentry kind="src" path="Eclipse SWT/common_j2me"/>
+ <classpathentry kind="src" path="Eclipse SWT PI/motif"/>
+ <classpathentry kind="src" path="Eclipse SWT PI/common_j2me"/>
+ <classpathentry kind="src" path="Eclipse SWT Accessibility/emulated"/>
+ <classpathentry kind="src" path="Eclipse SWT Accessibility/common"/>
+ <classpathentry kind="src" path="Eclipse SWT Drag and Drop/motif"/>
+ <classpathentry kind="src" path="Eclipse SWT Drag and Drop/common"/>
+ <classpathentry kind="src" path="Eclipse SWT Printing/motif"/>
+ <classpathentry kind="src" path="Eclipse SWT Printing/common"/>
+ <classpathentry kind="src" path="Eclipse SWT Program/motif"/>
+ <classpathentry kind="src" path="Eclipse SWT Program/common"/>
+ <classpathentry kind="src" path="Eclipse SWT Custom Widgets/common"/>
+ <classpathentry kind="output" path="bin"/>
</classpath> \ No newline at end of file
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
index d46ee966f4..47a962cca6 100755
--- 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
@@ -1,155 +1,155 @@
-package org.eclipse.swt.internal.awt.win32;
-
-/*
+package org.eclipse.swt.internal.awt.win32;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-import java.lang.reflect.Method;
-import java.lang.reflect.Constructor;
-
-/* Win32, SUN AWT */
-import sun.awt.windows.WEmbeddedFrame;
-//import sun.awt.DrawingSurface;
-//import sun.awt.windows.WDrawingSurfaceInfo;
-
-/* 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;
-import java.awt.event.WindowEvent;
-import java.awt.event.FocusEvent;
-
-public class SWT_AWT {
-
-public static Panel new_Panel (final Composite parent) {
- int handle = parent.handle;
- /*
- * Some JREs have implemented the WEmbeddedFrame constructor to take an integer
- * value for the HWND parameter and other JREs take a long for the HWND parameter.
- * To handle this binary incompatability, we use reflection to perform the equivalent of
- * the following line of code:
- *
- * final WEmbeddedFrame frame = new WEmbeddedFrame(handle);
- */
- Constructor constructor = null;
- try {
- constructor = WEmbeddedFrame.class.getConstructor (new Class [] {int.class});
- } catch (Exception e1) {
- try {
- constructor = WEmbeddedFrame.class.getConstructor (new Class [] {long.class});
- } catch (Exception e2) {
- SWT.error (SWT.ERROR_NOT_IMPLEMENTED, e2);
- }
- }
- WEmbeddedFrame value = null;
- try {
- value = (WEmbeddedFrame) constructor.newInstance (new Object [] {new Integer (handle)});
- } catch (Exception e) {
- SWT.error (SWT.ERROR_NOT_IMPLEMENTED, e);
- }
- final WEmbeddedFrame frame = value;
-
- Panel panel = new Panel ();
- frame.add (panel);
- parent.addListener (SWT.Activate, new Listener () {
- public void handleEvent (Event e) {
- frame.dispatchEvent (new WindowEvent (frame, WindowEvent.WINDOW_ACTIVATED));
- frame.dispatchEvent (new FocusEvent (frame, FocusEvent.FOCUS_GAINED));
- }
- });
- parent.addListener (SWT.Deactivate, new Listener () {
- public void handleEvent (Event e) {
- frame.dispatchEvent (new WindowEvent (frame, WindowEvent.WINDOW_DEACTIVATED));
- frame.dispatchEvent (new FocusEvent (frame, FocusEvent.FOCUS_LOST));
- }
- });
- parent.getShell ().addListener (SWT.Move, new Listener () {
- public void handleEvent (Event e) {
- final Rectangle rect = parent.getClientArea ();
- frame.getToolkit ().getSystemEventQueue ().invokeLater(new Runnable () {
- public void run () {
- frame.dispatchEvent (new ComponentEvent (frame, ComponentEvent.COMPONENT_MOVED));
- }
- });
- }
- });
- parent.addListener (SWT.Resize, new Listener () {
- public void handleEvent (Event e) {
- final Rectangle rect = parent.getClientArea ();
- frame.getToolkit ().getSystemEventQueue ().invokeLater(new Runnable () {
- public void run () {
- frame.setSize (rect.width, rect.height);
- frame.validate ();
- }
- });
- }
- });
- parent.addListener (SWT.Dispose, new Listener () {
- public void handleEvent (Event event) {
- parent.setVisible(false);
- frame.dispose ();
- }
- });
- return panel;
-}
-
-public static Shell new_Shell (Display display, final Canvas parent) {
- /*
- * As of JDK 1.4, the DrawingSurface and WDrawingSurfaceInfo no longer exist
- * so that code that references these classes no longer compiles. The fix is
- * to use refection to invoke equivalent code that is commented below. There
- * is no fix at this time for the missing WDrawingSurfaceInfo functionality.
- */
-// DrawingSurface ds = (DrawingSurface)parent.getPeer();
-// WDrawingSurfaceInfo wds = (WDrawingSurfaceInfo)ds.getDrawingSurfaceInfo();
-// wds.lock ();
-// int handle = (int) wds.getHWnd ();
-// wds.unlock ();
- Integer hwnd = null;
- try {
- Object ds = parent.getPeer ();
- Class drawingSurfaceClass = Class.forName ("sun.awt.DrawingSurface"); //$NON-NLS-1$
- Method method = drawingSurfaceClass.getDeclaredMethod ("getDrawingSurfaceInfo", null); //$NON-NLS-1$
- Object wds = method.invoke (ds, null);
- Class wDrawingSurfaceClass = Class.forName ("sun.awt.windows.WDrawingSurfaceInfo"); //$NON-NLS-1$
- method = wDrawingSurfaceClass.getMethod ("lock", null); //$NON-NLS-1$
- method.invoke (wds, null);
- method = wDrawingSurfaceClass.getMethod ("getHWnd", null); //$NON-NLS-1$
- hwnd = (Integer) method.invoke (wds, null);
- method = wDrawingSurfaceClass.getMethod ("unlock", null); //$NON-NLS-1$
- method.invoke (wds, null);
- } catch (Exception e) {
- SWT.error (SWT.ERROR_NOT_IMPLEMENTED, e);
- }
- int handle = hwnd.intValue();
-
- 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;
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+import java.lang.reflect.Method;
+import java.lang.reflect.Constructor;
+
+/* Win32, SUN AWT */
+import sun.awt.windows.WEmbeddedFrame;
+//import sun.awt.DrawingSurface;
+//import sun.awt.windows.WDrawingSurfaceInfo;
+
+/* 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;
+import java.awt.event.WindowEvent;
+import java.awt.event.FocusEvent;
+
+public class SWT_AWT {
+
+public static Panel new_Panel (final Composite parent) {
+ int handle = parent.handle;
+ /*
+ * Some JREs have implemented the WEmbeddedFrame constructor to take an integer
+ * value for the HWND parameter and other JREs take a long for the HWND parameter.
+ * To handle this binary incompatability, we use reflection to perform the equivalent of
+ * the following line of code:
+ *
+ * final WEmbeddedFrame frame = new WEmbeddedFrame(handle);
+ */
+ Constructor constructor = null;
+ try {
+ constructor = WEmbeddedFrame.class.getConstructor (new Class [] {int.class});
+ } catch (Exception e1) {
+ try {
+ constructor = WEmbeddedFrame.class.getConstructor (new Class [] {long.class});
+ } catch (Exception e2) {
+ SWT.error (SWT.ERROR_NOT_IMPLEMENTED, e2);
+ }
+ }
+ WEmbeddedFrame value = null;
+ try {
+ value = (WEmbeddedFrame) constructor.newInstance (new Object [] {new Integer (handle)});
+ } catch (Exception e) {
+ SWT.error (SWT.ERROR_NOT_IMPLEMENTED, e);
+ }
+ final WEmbeddedFrame frame = value;
+
+ Panel panel = new Panel ();
+ frame.add (panel);
+ parent.addListener (SWT.Activate, new Listener () {
+ public void handleEvent (Event e) {
+ frame.dispatchEvent (new WindowEvent (frame, WindowEvent.WINDOW_ACTIVATED));
+ frame.dispatchEvent (new FocusEvent (frame, FocusEvent.FOCUS_GAINED));
+ }
+ });
+ parent.addListener (SWT.Deactivate, new Listener () {
+ public void handleEvent (Event e) {
+ frame.dispatchEvent (new WindowEvent (frame, WindowEvent.WINDOW_DEACTIVATED));
+ frame.dispatchEvent (new FocusEvent (frame, FocusEvent.FOCUS_LOST));
+ }
+ });
+ parent.getShell ().addListener (SWT.Move, new Listener () {
+ public void handleEvent (Event e) {
+ final Rectangle rect = parent.getClientArea ();
+ frame.getToolkit ().getSystemEventQueue ().invokeLater(new Runnable () {
+ public void run () {
+ frame.dispatchEvent (new ComponentEvent (frame, ComponentEvent.COMPONENT_MOVED));
+ }
+ });
+ }
+ });
+ parent.addListener (SWT.Resize, new Listener () {
+ public void handleEvent (Event e) {
+ final Rectangle rect = parent.getClientArea ();
+ frame.getToolkit ().getSystemEventQueue ().invokeLater(new Runnable () {
+ public void run () {
+ frame.setSize (rect.width, rect.height);
+ frame.validate ();
+ }
+ });
+ }
+ });
+ parent.addListener (SWT.Dispose, new Listener () {
+ public void handleEvent (Event event) {
+ parent.setVisible(false);
+ frame.dispose ();
+ }
+ });
+ return panel;
+}
+
+public static Shell new_Shell (Display display, final Canvas parent) {
+ /*
+ * As of JDK 1.4, the DrawingSurface and WDrawingSurfaceInfo no longer exist
+ * so that code that references these classes no longer compiles. The fix is
+ * to use refection to invoke equivalent code that is commented below. There
+ * is no fix at this time for the missing WDrawingSurfaceInfo functionality.
+ */
+// DrawingSurface ds = (DrawingSurface)parent.getPeer();
+// WDrawingSurfaceInfo wds = (WDrawingSurfaceInfo)ds.getDrawingSurfaceInfo();
+// wds.lock ();
+// int handle = (int) wds.getHWnd ();
+// wds.unlock ();
+ Integer hwnd = null;
+ try {
+ Object ds = parent.getPeer ();
+ Class drawingSurfaceClass = Class.forName ("sun.awt.DrawingSurface"); //$NON-NLS-1$
+ Method method = drawingSurfaceClass.getDeclaredMethod ("getDrawingSurfaceInfo", null); //$NON-NLS-1$
+ Object wds = method.invoke (ds, null);
+ Class wDrawingSurfaceClass = Class.forName ("sun.awt.windows.WDrawingSurfaceInfo"); //$NON-NLS-1$
+ method = wDrawingSurfaceClass.getMethod ("lock", null); //$NON-NLS-1$
+ method.invoke (wds, null);
+ method = wDrawingSurfaceClass.getMethod ("getHWnd", null); //$NON-NLS-1$
+ hwnd = (Integer) method.invoke (wds, null);
+ method = wDrawingSurfaceClass.getMethod ("unlock", null); //$NON-NLS-1$
+ method.invoke (wds, null);
+ } catch (Exception e) {
+ SWT.error (SWT.ERROR_NOT_IMPLEMENTED, e);
+ }
+ int handle = hwnd.intValue();
+
+ 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;
+}
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Accessibility/common/org/eclipse/swt/accessibility/ACC.java b/bundles/org.eclipse.swt/Eclipse SWT Accessibility/common/org/eclipse/swt/accessibility/ACC.java
index f63b03f18f..b6009a9e14 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT Accessibility/common/org/eclipse/swt/accessibility/ACC.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT Accessibility/common/org/eclipse/swt/accessibility/ACC.java
@@ -1,63 +1,63 @@
-package org.eclipse.swt.accessibility;
-
-/*
+package org.eclipse.swt.accessibility;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-/**
- * Class ACC contains all the constants used in defining an
- * Accessible object.
- *
- * @since 2.0
- */
-public class ACC {
- public static final int STATE_NORMAL = 0x00000000;
- public static final int STATE_SELECTED = 0x00000002;
- public static final int STATE_SELECTABLE = 0x00200000;
- public static final int STATE_MULTISELECTABLE = 0x1000000;
- public static final int STATE_FOCUSED = 0x00000004;
- public static final int STATE_FOCUSABLE = 0x00100000;
- public static final int STATE_PRESSED = 0x8;
- public static final int STATE_CHECKED = 0x10;
- public static final int STATE_EXPANDED = 0x200;
- public static final int STATE_COLLAPSED = 0x400;
- public static final int STATE_HOTTRACKED = 0x80;
- public static final int STATE_BUSY = 0x800;
- public static final int STATE_READONLY = 0x40;
- public static final int STATE_INVISIBLE = 0x8000;
- public static final int STATE_OFFSCREEN = 0x10000;
- public static final int STATE_SIZEABLE = 0x20000;
-
- public static final int ROLE_CLIENT_AREA = 0xa;
- public static final int ROLE_WINDOW = 0x9;
- public static final int ROLE_MENUBAR = 0x2;
- public static final int ROLE_MENU = 0xb;
- public static final int ROLE_MENUITEM = 0xc;
- public static final int ROLE_SEPARATOR = 0x15;
- public static final int ROLE_TOOLTIP = 0xd;
- public static final int ROLE_SCROLLBAR = 0x3;
- public static final int ROLE_DIALOG = 0x12;
- public static final int ROLE_LABEL = 0x29;
- public static final int ROLE_PUSHBUTTON = 0x2b;
- public static final int ROLE_CHECKBUTTON = 0x2c;
- public static final int ROLE_RADIOBUTTON = 0x2d;
- public static final int ROLE_COMBOBOX = 0x2e;
- public static final int ROLE_TEXT = 0x2a;
- public static final int ROLE_TOOLBAR = 0x16;
- public static final int ROLE_LIST = 0x21;
- public static final int ROLE_LISTITEM = 0x22;
- public static final int ROLE_TABLE = 0x18;
- public static final int ROLE_TABLECOLUMN = 0x19;
- public static final int ROLE_TREE = 0x23;
- public static final int ROLE_TABFOLDER = 0x3c;
- public static final int ROLE_TABITEM = 0x25;
- public static final int ROLE_PROGRESSBAR = 0x30;
- public static final int ROLE_SLIDER = 0x33;
-
- public static final int CHILDID_SELF = -1;
- public static final int CHILDID_NONE = -2;
- public static final int CHILDID_MULTIPLE = -3;
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+/**
+ * Class ACC contains all the constants used in defining an
+ * Accessible object.
+ *
+ * @since 2.0
+ */
+public class ACC {
+ public static final int STATE_NORMAL = 0x00000000;
+ public static final int STATE_SELECTED = 0x00000002;
+ public static final int STATE_SELECTABLE = 0x00200000;
+ public static final int STATE_MULTISELECTABLE = 0x1000000;
+ public static final int STATE_FOCUSED = 0x00000004;
+ public static final int STATE_FOCUSABLE = 0x00100000;
+ public static final int STATE_PRESSED = 0x8;
+ public static final int STATE_CHECKED = 0x10;
+ public static final int STATE_EXPANDED = 0x200;
+ public static final int STATE_COLLAPSED = 0x400;
+ public static final int STATE_HOTTRACKED = 0x80;
+ public static final int STATE_BUSY = 0x800;
+ public static final int STATE_READONLY = 0x40;
+ public static final int STATE_INVISIBLE = 0x8000;
+ public static final int STATE_OFFSCREEN = 0x10000;
+ public static final int STATE_SIZEABLE = 0x20000;
+
+ public static final int ROLE_CLIENT_AREA = 0xa;
+ public static final int ROLE_WINDOW = 0x9;
+ public static final int ROLE_MENUBAR = 0x2;
+ public static final int ROLE_MENU = 0xb;
+ public static final int ROLE_MENUITEM = 0xc;
+ public static final int ROLE_SEPARATOR = 0x15;
+ public static final int ROLE_TOOLTIP = 0xd;
+ public static final int ROLE_SCROLLBAR = 0x3;
+ public static final int ROLE_DIALOG = 0x12;
+ public static final int ROLE_LABEL = 0x29;
+ public static final int ROLE_PUSHBUTTON = 0x2b;
+ public static final int ROLE_CHECKBUTTON = 0x2c;
+ public static final int ROLE_RADIOBUTTON = 0x2d;
+ public static final int ROLE_COMBOBOX = 0x2e;
+ public static final int ROLE_TEXT = 0x2a;
+ public static final int ROLE_TOOLBAR = 0x16;
+ public static final int ROLE_LIST = 0x21;
+ public static final int ROLE_LISTITEM = 0x22;
+ public static final int ROLE_TABLE = 0x18;
+ public static final int ROLE_TABLECOLUMN = 0x19;
+ public static final int ROLE_TREE = 0x23;
+ public static final int ROLE_TABFOLDER = 0x3c;
+ public static final int ROLE_TABITEM = 0x25;
+ public static final int ROLE_PROGRESSBAR = 0x30;
+ public static final int ROLE_SLIDER = 0x33;
+
+ public static final int CHILDID_SELF = -1;
+ public static final int CHILDID_NONE = -2;
+ public static final int CHILDID_MULTIPLE = -3;
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Accessibility/common/org/eclipse/swt/accessibility/AccessibleAdapter.java b/bundles/org.eclipse.swt/Eclipse SWT Accessibility/common/org/eclipse/swt/accessibility/AccessibleAdapter.java
index a0fcfd51c7..25682d5ce7 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT Accessibility/common/org/eclipse/swt/accessibility/AccessibleAdapter.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT Accessibility/common/org/eclipse/swt/accessibility/AccessibleAdapter.java
@@ -1,124 +1,124 @@
-package org.eclipse.swt.accessibility;
-
-/*
+package org.eclipse.swt.accessibility;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-/**
- * This adapter class provides default implementations for the
- * methods described by the <code>AccessibleListener</code> interface.
- * <p>
- * Classes that wish to deal with <code>AccessibleEvent</code>s can
- * extend this class and override only the methods that they are
- * interested in.
- * </p><p>
- * Note: Accessibility clients use child identifiers to specify
- * whether they want information about a control or one of its children.
- * Child identifiers are increasing integers beginning with 0.
- * The identifier CHILDID_SELF represents the control itself.
- * </p>
- *
- * @see AccessibleListener
- * @see AccessibleEvent
- *
- * @since 2.0
- */
-public abstract class AccessibleAdapter implements AccessibleListener {
-
- /**
- * Sent when an accessibility client requests the name
- * of the control, or the name of a child of the control.
- * The default behavior is to do nothing.
- * <p>
- * Return the name of the control or specified child in the
- * <code>result</code> field of the event object. Returning
- * an empty string tells the client that the control or child
- * does not have a name, and returning null tells the client
- * to use the platform name.
- * </p>
- *
- * @param e an event object containing the following fields:<ul>
- * <li>childID [IN] - an identifier specifying the control or one of its children</li>
- * <li>result [OUT] - the requested name string, or null</li>
- * </ul>
- */
- public void getName(AccessibleEvent e) {
- }
-
- /**
- * Sent when an accessibility client requests the help string
- * of the control, or the help string of a child of the control.
- * The default behavior is to do nothing.
- * <p>
- * The information in this property should be similar to the help
- * provided by toolTipText. It describes what the control or child
- * does or how to use it, as opposed to getDescription, which
- * describes appearance.
- * </p><p>
- * Return the help string of the control or specified child in
- * the <code>result</code> field of the event object. Returning
- * an empty string tells the client that the control or child
- * does not have a help string, and returning null tells the
- * client to use the platform help string.
- * </p>
- *
- * @param e an event object containing the following fields:<ul>
- * <li>childID [IN] - an identifier specifying the control or one of its children</li>
- * <li>result [OUT] - the requested help string, or null</li>
- * </ul>
- */
- public void getHelp(AccessibleEvent e) {
- }
-
- /**
- * Sent when an accessibility client requests the keyboard shortcut
- * of the control, or the keyboard shortcut of a child of the control.
- * The default behavior is to do nothing.
- * <p>
- * A keyboard shortcut can either be a mnemonic, or an accelerator.
- * As a general rule, if the control or child can receive keyboard focus,
- * then you should expose its mnemonic, and if it cannot receive keyboard
- * focus, then you should expose its accelerator.
- * </p><p>
- * Return the keyboard shortcut string of the control or specified child
- * in the <code>result</code> field of the event object. Returning an
- * empty string tells the client that the control or child does not
- * have a keyboard shortcut string, and returning null tells the client
- * to use the platform keyboard shortcut string.
- * </p>
- *
- * @param e an event object containing the following fields:<ul>
- * <li>childID [IN] - an identifier specifying the control or one of its children</li>
- * <li>result [OUT] - the requested keyboard shortcut string (example: "ALT+N"), or null</li>
- * </ul>
- */
- public void getKeyboardShortcut(AccessibleEvent e) {
- }
-
- /**
- * Sent when an accessibility client requests a description
- * of the control, or a description of a child of the control.
- * The default behavior is to do nothing.
- * <p>
- * This is a textual description of the control or child's visual
- * appearance, which is typically only necessary if it cannot be
- * determined from other properties such as role.
- * </p><p>
- * Return the description of the control or specified child in
- * the <code>result</code> field of the event object. Returning
- * an empty string tells the client that the control or child
- * does not have a description, and returning null tells the
- * client to use the platform description.
- * </p>
- *
- * @param e an event object containing the following fields:<ul>
- * <li>childID [IN] - an identifier specifying the control or one of its children</li>
- * <li>result [OUT] - the requested description string, or null</li>
- * </ul>
- */
- public void getDescription(AccessibleEvent e) {
- }
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+/**
+ * This adapter class provides default implementations for the
+ * methods described by the <code>AccessibleListener</code> interface.
+ * <p>
+ * Classes that wish to deal with <code>AccessibleEvent</code>s can
+ * extend this class and override only the methods that they are
+ * interested in.
+ * </p><p>
+ * Note: Accessibility clients use child identifiers to specify
+ * whether they want information about a control or one of its children.
+ * Child identifiers are increasing integers beginning with 0.
+ * The identifier CHILDID_SELF represents the control itself.
+ * </p>
+ *
+ * @see AccessibleListener
+ * @see AccessibleEvent
+ *
+ * @since 2.0
+ */
+public abstract class AccessibleAdapter implements AccessibleListener {
+
+ /**
+ * Sent when an accessibility client requests the name
+ * of the control, or the name of a child of the control.
+ * The default behavior is to do nothing.
+ * <p>
+ * Return the name of the control or specified child in the
+ * <code>result</code> field of the event object. Returning
+ * an empty string tells the client that the control or child
+ * does not have a name, and returning null tells the client
+ * to use the platform name.
+ * </p>
+ *
+ * @param e an event object containing the following fields:<ul>
+ * <li>childID [IN] - an identifier specifying the control or one of its children</li>
+ * <li>result [OUT] - the requested name string, or null</li>
+ * </ul>
+ */
+ public void getName(AccessibleEvent e) {
+ }
+
+ /**
+ * Sent when an accessibility client requests the help string
+ * of the control, or the help string of a child of the control.
+ * The default behavior is to do nothing.
+ * <p>
+ * The information in this property should be similar to the help
+ * provided by toolTipText. It describes what the control or child
+ * does or how to use it, as opposed to getDescription, which
+ * describes appearance.
+ * </p><p>
+ * Return the help string of the control or specified child in
+ * the <code>result</code> field of the event object. Returning
+ * an empty string tells the client that the control or child
+ * does not have a help string, and returning null tells the
+ * client to use the platform help string.
+ * </p>
+ *
+ * @param e an event object containing the following fields:<ul>
+ * <li>childID [IN] - an identifier specifying the control or one of its children</li>
+ * <li>result [OUT] - the requested help string, or null</li>
+ * </ul>
+ */
+ public void getHelp(AccessibleEvent e) {
+ }
+
+ /**
+ * Sent when an accessibility client requests the keyboard shortcut
+ * of the control, or the keyboard shortcut of a child of the control.
+ * The default behavior is to do nothing.
+ * <p>
+ * A keyboard shortcut can either be a mnemonic, or an accelerator.
+ * As a general rule, if the control or child can receive keyboard focus,
+ * then you should expose its mnemonic, and if it cannot receive keyboard
+ * focus, then you should expose its accelerator.
+ * </p><p>
+ * Return the keyboard shortcut string of the control or specified child
+ * in the <code>result</code> field of the event object. Returning an
+ * empty string tells the client that the control or child does not
+ * have a keyboard shortcut string, and returning null tells the client
+ * to use the platform keyboard shortcut string.
+ * </p>
+ *
+ * @param e an event object containing the following fields:<ul>
+ * <li>childID [IN] - an identifier specifying the control or one of its children</li>
+ * <li>result [OUT] - the requested keyboard shortcut string (example: "ALT+N"), or null</li>
+ * </ul>
+ */
+ public void getKeyboardShortcut(AccessibleEvent e) {
+ }
+
+ /**
+ * Sent when an accessibility client requests a description
+ * of the control, or a description of a child of the control.
+ * The default behavior is to do nothing.
+ * <p>
+ * This is a textual description of the control or child's visual
+ * appearance, which is typically only necessary if it cannot be
+ * determined from other properties such as role.
+ * </p><p>
+ * Return the description of the control or specified child in
+ * the <code>result</code> field of the event object. Returning
+ * an empty string tells the client that the control or child
+ * does not have a description, and returning null tells the
+ * client to use the platform description.
+ * </p>
+ *
+ * @param e an event object containing the following fields:<ul>
+ * <li>childID [IN] - an identifier specifying the control or one of its children</li>
+ * <li>result [OUT] - the requested description string, or null</li>
+ * </ul>
+ */
+ public void getDescription(AccessibleEvent e) {
+ }
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Accessibility/common/org/eclipse/swt/accessibility/AccessibleControlAdapter.java b/bundles/org.eclipse.swt/Eclipse SWT Accessibility/common/org/eclipse/swt/accessibility/AccessibleControlAdapter.java
index 1eeb7e07b0..91db3109b7 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT Accessibility/common/org/eclipse/swt/accessibility/AccessibleControlAdapter.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT Accessibility/common/org/eclipse/swt/accessibility/AccessibleControlAdapter.java
@@ -1,247 +1,247 @@
-package org.eclipse.swt.accessibility;
-
-/*
+package org.eclipse.swt.accessibility;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-/**
- * This adapter class provides default implementations for the
- * methods described by the <code>AccessibleControlListener</code> interface.
- * <p>
- * Classes that wish to deal with <code>AccessibleControlEvent</code>s can
- * extend this class and override only the methods that they are
- * interested in.
- * </p><p>
- * Note: Accessibility clients use child identifiers to specify
- * whether they want information about a control or one of its children.
- * Child identifiers are increasing integers beginning with 0.
- * The identifier CHILDID_SELF represents the control itself.
- * When returning a child identifier to a client, you may use CHILDID_NONE
- * to indicate that no child or control has the required information.
- * </p><p>
- * Note: This adapter is typically used by implementors of
- * a custom control to provide very detailed information about
- * the control instance to accessibility clients.
- * </p>
- *
- * @see AccessibleControlListener
- * @see AccessibleControlEvent
- *
- * @since 2.0
- */
-public abstract class AccessibleControlAdapter implements AccessibleControlListener {
-
- /**
- * Sent when an accessibility client requests the identifier
- * of the control child at the specified display coordinates.
- * The default behavior is to do nothing.
- * <p>
- * Return the identifier of the child at display point (x, y)
- * in the <code>childID</code> field of the event object.
- * Return CHILDID_SELF if point (x, y) is in the control itself
- * and not in any child. Return CHILDID_NONE if point (x, y)
- * is not contained in either the control or any of its children.
- * </p>
- *
- * @param e an event object containing the following fields:<ul>
- * <li>x, y [IN] - the specified point in display coordinates</li>
- * <li>childID [Typical OUT] - the ID of the child at point, or CHILDID_SELF, or CHILDID_NONE</li>
- * <li>accessible [Optional OUT] - the accessible object for the control or child may be returned instead of the childID</li>
- * </ul>
- */
- public void getChildAtPoint(AccessibleControlEvent e) {
- }
-
- /**
- * Sent when an accessibility client requests the location
- * of the control, or the location of a child of the control.
- * The default behavior is to do nothing.
- * <p>
- * Return a rectangle describing the location of the specified
- * control or child in the <code>x, y, width, and height</code>
- * fields of the event object.
- * </p>
- *
- * @param e an event object containing the following fields:<ul>
- * <li>childID [IN] - an identifier specifying the control or one of its children</li>
- * <li>x, y, width, height [OUT] - the control or child location in display coordinates</li>
- * </ul>
- */
- public void getLocation(AccessibleControlEvent e) {
- }
-
- /**
- * Sent when an accessibility client requests the accessible object
- * for a child of the control.
- * The default behavior is to do nothing.
- * <p>
- * Return an <code>Accessible</code> for the specified control or
- * child in the <code>accessible</code> field of the event object.
- * Return null if the specified child does not have its own
- * <code>Accessible</code>.
- * </p>
- *
- * @param e an event object containing the following fields:<ul>
- * <li>childID [IN] - an identifier specifying a child of the control</li>
- * <li>accessible [OUT] - an Accessible for the specified childID, or null if one does not exist</li>
- * </ul>
- */
- public void getChild(AccessibleControlEvent e) {
- }
-
- /**
- * Sent when an accessibility client requests the number of
- * children in the control.
- * The default behavior is to do nothing.
- * <p>
- * Return the number of child items in the <code>detail</code>
- * field of the event object.
- * </p>
- *
- * @param e an event object containing the following fields:<ul>
- * <li>detail [OUT] - the number of child items in this control</li>
- * </ul>
- */
- public void getChildCount(AccessibleControlEvent e) {
- }
-
- /**
- * Sent when an accessibility client requests the default action
- * of the control, or the default action of a child of the control.
- * The default behavior is to do nothing.
- * <p>
- * This string is typically a verb describing what the user does to it.
- * For example, a Push Button's default action is "Press", a Check Button's
- * is "Check" or "UnCheck", and List items have the default action "Double Click".
- * </p><p>
- * Return a string describing the default action of the specified
- * control or child in the <code>result</code> field of the event object.
- * Returning null tells the client to use the platform default action string.
- * </p>
- *
- * @param e an event object containing the following fields:<ul>
- * <li>childID [IN] - an identifier specifying the control or one of its children</li>
- * <li>result [OUT] - the requested default action string, or null</li>
- * </ul>
- */
- public void getDefaultAction(AccessibleControlEvent e) {
- }
-
- /**
- * Sent when an accessibility client requests the identity of
- * the child or control that has keyboard focus.
- * The default behavior is to do nothing.
- * <p>
- * Return the identifier of the child that has focus in the
- * <code>childID</code> field of the event object.
- * Return CHILDID_SELF if the control itself has keyboard focus.
- * Return CHILDID_NONE if neither the control nor any of its children has focus.
- * </p>
- *
- * @param e an event object containing the following fields:<ul>
- * <li>childID [Typical OUT] - the ID of the child with focus, or CHILDID_SELF, or CHILDID_NONE</li>
- * <li>accessible [Optional OUT] - the accessible object for a child may be returned instead of its childID</li>
- * </ul>
- */
- public void getFocus(AccessibleControlEvent e) {
- }
-
- /**
- * Sent when an accessibility client requests the role
- * of the control, or the role of a child of the control.
- * The default behavior is to do nothing.
- * <p>
- * Return a role constant (constant defined in ACC beginning with ROLE_)
- * that describes the role of the specified control or child in the
- * <code>detail</code> field of the event object.
- * </p>
- *
- * @param e an event object containing the following fields:<ul>
- * <li>childID [IN] - an identifier specifying the control or one of its children</li>
- * <li>detail [OUT] - a role constant describing the role of the control or child</li>
- * </ul>
- */
- public void getRole(AccessibleControlEvent e) {
- }
-
- /**
- * Sent when an accessibility client requests the identity of
- * the child or control that is currently selected.
- * The default behavior is to do nothing.
- * <p>
- * Return the identifier of the selected child in the
- * <code>childID</code> field of the event object.
- * Return CHILDID_SELF if the control itself is selected.
- * Return CHILDID_MULTIPLE if multiple children are selected, and return an array of childIDs in the <code>children</code> field.
- * Return CHILDID_NONE if neither the control nor any of its children are selected.
- * </p>
- *
- * @param e an event object containing the following fields:<ul>
- * <li>childID [Typical OUT] - the ID of the selected child, or CHILDID_SELF, or CHILDID_MULTIPLE, or CHILDID_NONE</li>
- * <li>accessible [Optional OUT] - the accessible object for the control or child may be returned instead of the childID</li>
- * </ul>
- */
- public void getSelection(AccessibleControlEvent e) {
- }
-
- /**
- * Sent when an accessibility client requests the state
- * of the control, or the state of a child of the control.
- * The default behavior is to do nothing.
- * <p>
- * Return a state constant (constant defined in ACC beginning with STATE_)
- * that describes the current state of the specified control or child in the
- * <code>detail</code> field of the event object.
- * </p>
- *
- * @param e an event object containing the following fields:<ul>
- * <li>childID [IN] - an identifier specifying the control or one of its children</li>
- * <li>detail [OUT] - a state constant describing the current state of the control or child</li>
- * </ul>
- */
- public void getState(AccessibleControlEvent e) {
- }
-
- /**
- * Sent when an accessibility client requests the value
- * of the control, or the value of a child of the control.
- * The default behavior is to do nothing.
- * <p>
- * Many controls do not return a value. Examples of controls
- * that do are: Combo returns the text string, Text returns
- * its contents, ProgressBar returns a string representing a
- * percentage, and Tree items return a string representing
- * their level in the tree.
- * </p><p>
- * Return a string describing the value of the specified control
- * or child in the <code>result</code> field of the event object.
- * Returning null tells the client to use the platform value string.
- * </p>
- *
- * @param e an event object containing the following fields:<ul>
- * <li>childID [IN] - an identifier specifying the control or one of its children</li>
- * <li>result [OUT] - the requested value string, or null</li>
- * </ul>
- */
- public void getValue(AccessibleControlEvent e) {
- }
-
- /**
- * Sent when an accessibility client requests the children of the control.
- * The default behavior is to do nothing.
- * <p>
- * Return the children as an array of childIDs in the <code>children</code>
- * field of the event object.
- * </p>
- *
- * @param e an event object containing the following fields:<ul>
- * <li>children [Typical OUT] - an array of childIDs</li>
- * <li>accessible [Optional OUT] - an array of accessible objects for the children may be returned instead of the childIDs</li>
- * </ul>
- */
- public void getChildren(AccessibleControlEvent e) {
- }
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+/**
+ * This adapter class provides default implementations for the
+ * methods described by the <code>AccessibleControlListener</code> interface.
+ * <p>
+ * Classes that wish to deal with <code>AccessibleControlEvent</code>s can
+ * extend this class and override only the methods that they are
+ * interested in.
+ * </p><p>
+ * Note: Accessibility clients use child identifiers to specify
+ * whether they want information about a control or one of its children.
+ * Child identifiers are increasing integers beginning with 0.
+ * The identifier CHILDID_SELF represents the control itself.
+ * When returning a child identifier to a client, you may use CHILDID_NONE
+ * to indicate that no child or control has the required information.
+ * </p><p>
+ * Note: This adapter is typically used by implementors of
+ * a custom control to provide very detailed information about
+ * the control instance to accessibility clients.
+ * </p>
+ *
+ * @see AccessibleControlListener
+ * @see AccessibleControlEvent
+ *
+ * @since 2.0
+ */
+public abstract class AccessibleControlAdapter implements AccessibleControlListener {
+
+ /**
+ * Sent when an accessibility client requests the identifier
+ * of the control child at the specified display coordinates.
+ * The default behavior is to do nothing.
+ * <p>
+ * Return the identifier of the child at display point (x, y)
+ * in the <code>childID</code> field of the event object.
+ * Return CHILDID_SELF if point (x, y) is in the control itself
+ * and not in any child. Return CHILDID_NONE if point (x, y)
+ * is not contained in either the control or any of its children.
+ * </p>
+ *
+ * @param e an event object containing the following fields:<ul>
+ * <li>x, y [IN] - the specified point in display coordinates</li>
+ * <li>childID [Typical OUT] - the ID of the child at point, or CHILDID_SELF, or CHILDID_NONE</li>
+ * <li>accessible [Optional OUT] - the accessible object for the control or child may be returned instead of the childID</li>
+ * </ul>
+ */
+ public void getChildAtPoint(AccessibleControlEvent e) {
+ }
+
+ /**
+ * Sent when an accessibility client requests the location
+ * of the control, or the location of a child of the control.
+ * The default behavior is to do nothing.
+ * <p>
+ * Return a rectangle describing the location of the specified
+ * control or child in the <code>x, y, width, and height</code>
+ * fields of the event object.
+ * </p>
+ *
+ * @param e an event object containing the following fields:<ul>
+ * <li>childID [IN] - an identifier specifying the control or one of its children</li>
+ * <li>x, y, width, height [OUT] - the control or child location in display coordinates</li>
+ * </ul>
+ */
+ public void getLocation(AccessibleControlEvent e) {
+ }
+
+ /**
+ * Sent when an accessibility client requests the accessible object
+ * for a child of the control.
+ * The default behavior is to do nothing.
+ * <p>
+ * Return an <code>Accessible</code> for the specified control or
+ * child in the <code>accessible</code> field of the event object.
+ * Return null if the specified child does not have its own
+ * <code>Accessible</code>.
+ * </p>
+ *
+ * @param e an event object containing the following fields:<ul>
+ * <li>childID [IN] - an identifier specifying a child of the control</li>
+ * <li>accessible [OUT] - an Accessible for the specified childID, or null if one does not exist</li>
+ * </ul>
+ */
+ public void getChild(AccessibleControlEvent e) {
+ }
+
+ /**
+ * Sent when an accessibility client requests the number of
+ * children in the control.
+ * The default behavior is to do nothing.
+ * <p>
+ * Return the number of child items in the <code>detail</code>
+ * field of the event object.
+ * </p>
+ *
+ * @param e an event object containing the following fields:<ul>
+ * <li>detail [OUT] - the number of child items in this control</li>
+ * </ul>
+ */
+ public void getChildCount(AccessibleControlEvent e) {
+ }
+
+ /**
+ * Sent when an accessibility client requests the default action
+ * of the control, or the default action of a child of the control.
+ * The default behavior is to do nothing.
+ * <p>
+ * This string is typically a verb describing what the user does to it.
+ * For example, a Push Button's default action is "Press", a Check Button's
+ * is "Check" or "UnCheck", and List items have the default action "Double Click".
+ * </p><p>
+ * Return a string describing the default action of the specified
+ * control or child in the <code>result</code> field of the event object.
+ * Returning null tells the client to use the platform default action string.
+ * </p>
+ *
+ * @param e an event object containing the following fields:<ul>
+ * <li>childID [IN] - an identifier specifying the control or one of its children</li>
+ * <li>result [OUT] - the requested default action string, or null</li>
+ * </ul>
+ */
+ public void getDefaultAction(AccessibleControlEvent e) {
+ }
+
+ /**
+ * Sent when an accessibility client requests the identity of
+ * the child or control that has keyboard focus.
+ * The default behavior is to do nothing.
+ * <p>
+ * Return the identifier of the child that has focus in the
+ * <code>childID</code> field of the event object.
+ * Return CHILDID_SELF if the control itself has keyboard focus.
+ * Return CHILDID_NONE if neither the control nor any of its children has focus.
+ * </p>
+ *
+ * @param e an event object containing the following fields:<ul>
+ * <li>childID [Typical OUT] - the ID of the child with focus, or CHILDID_SELF, or CHILDID_NONE</li>
+ * <li>accessible [Optional OUT] - the accessible object for a child may be returned instead of its childID</li>
+ * </ul>
+ */
+ public void getFocus(AccessibleControlEvent e) {
+ }
+
+ /**
+ * Sent when an accessibility client requests the role
+ * of the control, or the role of a child of the control.
+ * The default behavior is to do nothing.
+ * <p>
+ * Return a role constant (constant defined in ACC beginning with ROLE_)
+ * that describes the role of the specified control or child in the
+ * <code>detail</code> field of the event object.
+ * </p>
+ *
+ * @param e an event object containing the following fields:<ul>
+ * <li>childID [IN] - an identifier specifying the control or one of its children</li>
+ * <li>detail [OUT] - a role constant describing the role of the control or child</li>
+ * </ul>
+ */
+ public void getRole(AccessibleControlEvent e) {
+ }
+
+ /**
+ * Sent when an accessibility client requests the identity of
+ * the child or control that is currently selected.
+ * The default behavior is to do nothing.
+ * <p>
+ * Return the identifier of the selected child in the
+ * <code>childID</code> field of the event object.
+ * Return CHILDID_SELF if the control itself is selected.
+ * Return CHILDID_MULTIPLE if multiple children are selected, and return an array of childIDs in the <code>children</code> field.
+ * Return CHILDID_NONE if neither the control nor any of its children are selected.
+ * </p>
+ *
+ * @param e an event object containing the following fields:<ul>
+ * <li>childID [Typical OUT] - the ID of the selected child, or CHILDID_SELF, or CHILDID_MULTIPLE, or CHILDID_NONE</li>
+ * <li>accessible [Optional OUT] - the accessible object for the control or child may be returned instead of the childID</li>
+ * </ul>
+ */
+ public void getSelection(AccessibleControlEvent e) {
+ }
+
+ /**
+ * Sent when an accessibility client requests the state
+ * of the control, or the state of a child of the control.
+ * The default behavior is to do nothing.
+ * <p>
+ * Return a state constant (constant defined in ACC beginning with STATE_)
+ * that describes the current state of the specified control or child in the
+ * <code>detail</code> field of the event object.
+ * </p>
+ *
+ * @param e an event object containing the following fields:<ul>
+ * <li>childID [IN] - an identifier specifying the control or one of its children</li>
+ * <li>detail [OUT] - a state constant describing the current state of the control or child</li>
+ * </ul>
+ */
+ public void getState(AccessibleControlEvent e) {
+ }
+
+ /**
+ * Sent when an accessibility client requests the value
+ * of the control, or the value of a child of the control.
+ * The default behavior is to do nothing.
+ * <p>
+ * Many controls do not return a value. Examples of controls
+ * that do are: Combo returns the text string, Text returns
+ * its contents, ProgressBar returns a string representing a
+ * percentage, and Tree items return a string representing
+ * their level in the tree.
+ * </p><p>
+ * Return a string describing the value of the specified control
+ * or child in the <code>result</code> field of the event object.
+ * Returning null tells the client to use the platform value string.
+ * </p>
+ *
+ * @param e an event object containing the following fields:<ul>
+ * <li>childID [IN] - an identifier specifying the control or one of its children</li>
+ * <li>result [OUT] - the requested value string, or null</li>
+ * </ul>
+ */
+ public void getValue(AccessibleControlEvent e) {
+ }
+
+ /**
+ * Sent when an accessibility client requests the children of the control.
+ * The default behavior is to do nothing.
+ * <p>
+ * Return the children as an array of childIDs in the <code>children</code>
+ * field of the event object.
+ * </p>
+ *
+ * @param e an event object containing the following fields:<ul>
+ * <li>children [Typical OUT] - an array of childIDs</li>
+ * <li>accessible [Optional OUT] - an array of accessible objects for the children may be returned instead of the childIDs</li>
+ * </ul>
+ */
+ public void getChildren(AccessibleControlEvent e) {
+ }
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Accessibility/common/org/eclipse/swt/accessibility/AccessibleControlEvent.java b/bundles/org.eclipse.swt/Eclipse SWT Accessibility/common/org/eclipse/swt/accessibility/AccessibleControlEvent.java
index 634a46db69..b6260bf23e 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT Accessibility/common/org/eclipse/swt/accessibility/AccessibleControlEvent.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT Accessibility/common/org/eclipse/swt/accessibility/AccessibleControlEvent.java
@@ -1,52 +1,52 @@
-package org.eclipse.swt.accessibility;
-
-/*
+package org.eclipse.swt.accessibility;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-import org.eclipse.swt.internal.SWTEventObject;
-
-/**
- * Instances of this class are sent as a result of
- * accessibility clients sending messages to controls
- * asking for detailed information about the implementation
- * of the control instance. Typically, only implementors
- * of custom controls need to listen for this event.
- * <p>
- * Note: The meaning of each field depends on the
- * message that was sent.
- * </p>
- *
- * @see AccessibleControlListener
- * @see AccessibleControlAdapter
- *
- * @since 2.0
- */
-public class AccessibleControlEvent extends SWTEventObject {
- public int childID; // IN/OUT
- public Accessible accessible; // OUT
- public int x, y; // IN/OUT
- public int width, height; // OUT
- public int detail; // IN/OUT
- public String result; // OUT
- public Object children[]; // [OUT]
-
-public AccessibleControlEvent(Object source) {
- super(source);
-}
-
-public String toString () {
- return "AccessibleControlEvent {childID=" + childID +
- " accessible=" + accessible +
- " x=" + x +
- " y=" + y +
- " width=" + width +
- " height=" + height +
- " detail=" + detail +
- " result=" + result +
- "}";
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+import org.eclipse.swt.internal.SWTEventObject;
+
+/**
+ * Instances of this class are sent as a result of
+ * accessibility clients sending messages to controls
+ * asking for detailed information about the implementation
+ * of the control instance. Typically, only implementors
+ * of custom controls need to listen for this event.
+ * <p>
+ * Note: The meaning of each field depends on the
+ * message that was sent.
+ * </p>
+ *
+ * @see AccessibleControlListener
+ * @see AccessibleControlAdapter
+ *
+ * @since 2.0
+ */
+public class AccessibleControlEvent extends SWTEventObject {
+ public int childID; // IN/OUT
+ public Accessible accessible; // OUT
+ public int x, y; // IN/OUT
+ public int width, height; // OUT
+ public int detail; // IN/OUT
+ public String result; // OUT
+ public Object children[]; // [OUT]
+
+public AccessibleControlEvent(Object source) {
+ super(source);
+}
+
+public String toString () {
+ return "AccessibleControlEvent {childID=" + childID +
+ " accessible=" + accessible +
+ " x=" + x +
+ " y=" + y +
+ " width=" + width +
+ " height=" + height +
+ " detail=" + detail +
+ " result=" + result +
+ "}";
+}
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Accessibility/common/org/eclipse/swt/accessibility/AccessibleControlListener.java b/bundles/org.eclipse.swt/Eclipse SWT Accessibility/common/org/eclipse/swt/accessibility/AccessibleControlListener.java
index 1e44fbe4bb..07d187a717 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT Accessibility/common/org/eclipse/swt/accessibility/AccessibleControlListener.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT Accessibility/common/org/eclipse/swt/accessibility/AccessibleControlListener.java
@@ -1,229 +1,229 @@
-package org.eclipse.swt.accessibility;
-
-/*
+package org.eclipse.swt.accessibility;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-import org.eclipse.swt.internal.SWTEventListener;
-
-/**
- * Classes that implement this interface provide methods
- * that deal with the events that are generated when an
- * accessibility client sends a message to a control.
- * <p>
- * After creating an instance of a class that implements
- * this interface it can be added to a control using the
- * <code>addAccessibleControlListener</code> method and removed
- * using the <code>removeAccessibleControlListener</code> method.
- * When a client requests information the appropriate method
- * will be invoked.
- * </p><p>
- * Note: Accessibility clients use child identifiers to specify
- * whether they want information about a control or one of its children.
- * Child identifiers are increasing integers beginning with 0.
- * The identifier CHILDID_SELF represents the control itself.
- * </p><p>
- * Note: This interface is typically used by implementors of
- * a custom control to provide very detailed information about
- * the control instance to accessibility clients.
- * </p>
- *
- * @see AccessibleControlAdapter
- * @see AccessibleControlEvent
- *
- * @since 2.0
- */
-public interface AccessibleControlListener extends SWTEventListener {
-
- /**
- * Sent when an accessibility client requests the identifier
- * of the control child at the specified display coordinates.
- * <p>
- * Return the identifier of the child at display point (x, y)
- * in the <code>childID</code> field of the event object.
- * Return CHILDID_SELF if point (x, y) is in the control itself
- * and not in any child. Return CHILDID_NONE if point (x, y)
- * is not contained in either the control or any of its children.
- * </p>
- *
- * @param e an event object containing the following fields:<ul>
- * <li>x, y [IN] - the specified point in display coordinates</li>
- * <li>childID [Typical OUT] - the ID of the child at point, or CHILDID_SELF, or CHILDID_NONE</li>
- * <li>accessible [Optional OUT] - the accessible object for the control or child may be returned instead of the childID</li>
- * </ul>
- */
- public void getChildAtPoint(AccessibleControlEvent e);
-
- /**
- * Sent when an accessibility client requests the location
- * of the control, or the location of a child of the control.
- * <p>
- * Return a rectangle describing the location of the specified
- * control or child in the <code>x, y, width, and height</code>
- * fields of the event object.
- * </p>
- *
- * @param e an event object containing the following fields:<ul>
- * <li>childID [IN] - an identifier specifying the control or one of its children</li>
- * <li>x, y, width, height [OUT] - the control or child location in display coordinates</li>
- * </ul>
- */
- public void getLocation(AccessibleControlEvent e);
-
- /**
- * Sent when an accessibility client requests the accessible object
- * for a child of the control.
- * <p>
- * Return an <code>Accessible</code> for the specified control or
- * child in the <code>accessible</code> field of the event object.
- * Return null if the specified child does not have its own
- * <code>Accessible</code>.
- * </p>
- *
- * @param e an event object containing the following fields:<ul>
- * <li>childID [IN] - an identifier specifying a child of the control</li>
- * <li>accessible [OUT] - an Accessible for the specified childID, or null if one does not exist</li>
- * </ul>
- */
- public void getChild(AccessibleControlEvent e);
-
- /**
- * Sent when an accessibility client requests the number of
- * children in the control.
- * <p>
- * Return the number of child items in the <code>detail</code>
- * field of the event object.
- * </p>
- *
- * @param e an event object containing the following fields:<ul>
- * <li>detail [OUT] - the number of child items in this control</li>
- * </ul>
- */
- public void getChildCount(AccessibleControlEvent e);
-
- /**
- * Sent when an accessibility client requests the default action
- * of the control, or the default action of a child of the control.
- * <p>
- * This string is typically a verb describing what the user does to it.
- * For example, a Push Button's default action is "Press", a Check Button's
- * is "Check" or "UnCheck", and List items have the default action "Double Click".
- * </p><p>
- * Return a string describing the default action of the specified
- * control or child in the <code>result</code> field of the event object.
- * Returning null tells the client to use the platform default action string.
- * </p>
- *
- * @param e an event object containing the following fields:<ul>
- * <li>childID [IN] - an identifier specifying the control or one of its children</li>
- * <li>result [OUT] - the requested default action string, or null</li>
- * </ul>
- */
- public void getDefaultAction(AccessibleControlEvent e);
-
- /**
- * Sent when an accessibility client requests the identity of
- * the child or control that has keyboard focus.
- * <p>
- * Return the identifier of the child that has focus in the
- * <code>childID</code> field of the event object.
- * Return CHILDID_SELF if the control itself has keyboard focus.
- * Return CHILDID_NONE if neither the control nor any of its children has focus.
- * </p>
- *
- * @param e an event object containing the following fields:<ul>
- * <li>childID [Typical OUT] - the ID of the child with focus, or CHILDID_SELF, or CHILDID_NONE</li>
- * <li>accessible [Optional OUT] - the accessible object for a child may be returned instead of its childID</li>
- * </ul>
- */
- public void getFocus(AccessibleControlEvent e);
-
- /**
- * Sent when an accessibility client requests the role
- * of the control, or the role of a child of the control.
- * <p>
- * Return a role constant (constant defined in ACC beginning with ROLE_)
- * that describes the role of the specified control or child in the
- * <code>detail</code> field of the event object.
- * </p>
- *
- * @param e an event object containing the following fields:<ul>
- * <li>childID [IN] - an identifier specifying the control or one of its children</li>
- * <li>detail [OUT] - a role constant describing the role of the control or child</li>
- * </ul>
- */
- public void getRole(AccessibleControlEvent e);
-
- /**
- * Sent when an accessibility client requests the identity of
- * the child or control that is currently selected.
- * <p>
- * Return the identifier of the selected child in the
- * <code>childID</code> field of the event object.
- * Return CHILDID_SELF if the control itself is selected.
- * Return CHILDID_MULTIPLE if multiple children are selected, and return an array of childIDs in the <code>children</code> field.
- * Return CHILDID_NONE if neither the control nor any of its children are selected.
- * </p>
- *
- * @param e an event object containing the following fields:<ul>
- * <li>childID [Typical OUT] - the ID of the selected child, or CHILDID_SELF, or CHILDID_MULTIPLE, or CHILDID_NONE</li>
- * <li>accessible [Optional OUT] - the accessible object for the control or child may be returned instead of the childID</li>
- * </ul>
- */
- public void getSelection(AccessibleControlEvent e);
-
- /**
- * Sent when an accessibility client requests the state
- * of the control, or the state of a child of the control.
- * <p>
- * Return a state constant (constant defined in ACC beginning with STATE_)
- * that describes the current state of the specified control or child in the
- * <code>detail</code> field of the event object.
- * </p>
- *
- * @param e an event object containing the following fields:<ul>
- * <li>childID [IN] - an identifier specifying the control or one of its children</li>
- * <li>detail [OUT] - a state constant describing the current state of the control or child</li>
- * </ul>
- */
- public void getState(AccessibleControlEvent e);
-
- /**
- * Sent when an accessibility client requests the value
- * of the control, or the value of a child of the control.
- * <p>
- * Many controls do not return a value. Examples of controls
- * that do are: Combo returns the text string, Text returns
- * its contents, ProgressBar returns a string representing a
- * percentage, and Tree items return a string representing
- * their level in the tree.
- * </p><p>
- * Return a string describing the value of the specified control
- * or child in the <code>result</code> field of the event object.
- * Returning null tells the client to use the platform value string.
- * </p>
- *
- * @param e an event object containing the following fields:<ul>
- * <li>childID [IN] - an identifier specifying the control or one of its children</li>
- * <li>result [OUT] - the requested value string, or null</li>
- * </ul>
- */
- public void getValue(AccessibleControlEvent e);
-
- /**
- * Sent when an accessibility client requests the children of the control.
- * <p>
- * Return the children as an array of childIDs in the <code>children</code>
- * field of the event object.
- * </p>
- *
- * @param e an event object containing the following fields:<ul>
- * <li>children [Typical OUT] - an array of childIDs</li>
- * <li>accessible [Optional OUT] - an array of accessible objects for the children may be returned instead of the childIDs</li>
- * </ul>
- */
- public void getChildren(AccessibleControlEvent e);
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+import org.eclipse.swt.internal.SWTEventListener;
+
+/**
+ * Classes that implement this interface provide methods
+ * that deal with the events that are generated when an
+ * accessibility client sends a message to a control.
+ * <p>
+ * After creating an instance of a class that implements
+ * this interface it can be added to a control using the
+ * <code>addAccessibleControlListener</code> method and removed
+ * using the <code>removeAccessibleControlListener</code> method.
+ * When a client requests information the appropriate method
+ * will be invoked.
+ * </p><p>
+ * Note: Accessibility clients use child identifiers to specify
+ * whether they want information about a control or one of its children.
+ * Child identifiers are increasing integers beginning with 0.
+ * The identifier CHILDID_SELF represents the control itself.
+ * </p><p>
+ * Note: This interface is typically used by implementors of
+ * a custom control to provide very detailed information about
+ * the control instance to accessibility clients.
+ * </p>
+ *
+ * @see AccessibleControlAdapter
+ * @see AccessibleControlEvent
+ *
+ * @since 2.0
+ */
+public interface AccessibleControlListener extends SWTEventListener {
+
+ /**
+ * Sent when an accessibility client requests the identifier
+ * of the control child at the specified display coordinates.
+ * <p>
+ * Return the identifier of the child at display point (x, y)
+ * in the <code>childID</code> field of the event object.
+ * Return CHILDID_SELF if point (x, y) is in the control itself
+ * and not in any child. Return CHILDID_NONE if point (x, y)
+ * is not contained in either the control or any of its children.
+ * </p>
+ *
+ * @param e an event object containing the following fields:<ul>
+ * <li>x, y [IN] - the specified point in display coordinates</li>
+ * <li>childID [Typical OUT] - the ID of the child at point, or CHILDID_SELF, or CHILDID_NONE</li>
+ * <li>accessible [Optional OUT] - the accessible object for the control or child may be returned instead of the childID</li>
+ * </ul>
+ */
+ public void getChildAtPoint(AccessibleControlEvent e);
+
+ /**
+ * Sent when an accessibility client requests the location
+ * of the control, or the location of a child of the control.
+ * <p>
+ * Return a rectangle describing the location of the specified
+ * control or child in the <code>x, y, width, and height</code>
+ * fields of the event object.
+ * </p>
+ *
+ * @param e an event object containing the following fields:<ul>
+ * <li>childID [IN] - an identifier specifying the control or one of its children</li>
+ * <li>x, y, width, height [OUT] - the control or child location in display coordinates</li>
+ * </ul>
+ */
+ public void getLocation(AccessibleControlEvent e);
+
+ /**
+ * Sent when an accessibility client requests the accessible object
+ * for a child of the control.
+ * <p>
+ * Return an <code>Accessible</code> for the specified control or
+ * child in the <code>accessible</code> field of the event object.
+ * Return null if the specified child does not have its own
+ * <code>Accessible</code>.
+ * </p>
+ *
+ * @param e an event object containing the following fields:<ul>
+ * <li>childID [IN] - an identifier specifying a child of the control</li>
+ * <li>accessible [OUT] - an Accessible for the specified childID, or null if one does not exist</li>
+ * </ul>
+ */
+ public void getChild(AccessibleControlEvent e);
+
+ /**
+ * Sent when an accessibility client requests the number of
+ * children in the control.
+ * <p>
+ * Return the number of child items in the <code>detail</code>
+ * field of the event object.
+ * </p>
+ *
+ * @param e an event object containing the following fields:<ul>
+ * <li>detail [OUT] - the number of child items in this control</li>
+ * </ul>
+ */
+ public void getChildCount(AccessibleControlEvent e);
+
+ /**
+ * Sent when an accessibility client requests the default action
+ * of the control, or the default action of a child of the control.
+ * <p>
+ * This string is typically a verb describing what the user does to it.
+ * For example, a Push Button's default action is "Press", a Check Button's
+ * is "Check" or "UnCheck", and List items have the default action "Double Click".
+ * </p><p>
+ * Return a string describing the default action of the specified
+ * control or child in the <code>result</code> field of the event object.
+ * Returning null tells the client to use the platform default action string.
+ * </p>
+ *
+ * @param e an event object containing the following fields:<ul>
+ * <li>childID [IN] - an identifier specifying the control or one of its children</li>
+ * <li>result [OUT] - the requested default action string, or null</li>
+ * </ul>
+ */
+ public void getDefaultAction(AccessibleControlEvent e);
+
+ /**
+ * Sent when an accessibility client requests the identity of
+ * the child or control that has keyboard focus.
+ * <p>
+ * Return the identifier of the child that has focus in the
+ * <code>childID</code> field of the event object.
+ * Return CHILDID_SELF if the control itself has keyboard focus.
+ * Return CHILDID_NONE if neither the control nor any of its children has focus.
+ * </p>
+ *
+ * @param e an event object containing the following fields:<ul>
+ * <li>childID [Typical OUT] - the ID of the child with focus, or CHILDID_SELF, or CHILDID_NONE</li>
+ * <li>accessible [Optional OUT] - the accessible object for a child may be returned instead of its childID</li>
+ * </ul>
+ */
+ public void getFocus(AccessibleControlEvent e);
+
+ /**
+ * Sent when an accessibility client requests the role
+ * of the control, or the role of a child of the control.
+ * <p>
+ * Return a role constant (constant defined in ACC beginning with ROLE_)
+ * that describes the role of the specified control or child in the
+ * <code>detail</code> field of the event object.
+ * </p>
+ *
+ * @param e an event object containing the following fields:<ul>
+ * <li>childID [IN] - an identifier specifying the control or one of its children</li>
+ * <li>detail [OUT] - a role constant describing the role of the control or child</li>
+ * </ul>
+ */
+ public void getRole(AccessibleControlEvent e);
+
+ /**
+ * Sent when an accessibility client requests the identity of
+ * the child or control that is currently selected.
+ * <p>
+ * Return the identifier of the selected child in the
+ * <code>childID</code> field of the event object.
+ * Return CHILDID_SELF if the control itself is selected.
+ * Return CHILDID_MULTIPLE if multiple children are selected, and return an array of childIDs in the <code>children</code> field.
+ * Return CHILDID_NONE if neither the control nor any of its children are selected.
+ * </p>
+ *
+ * @param e an event object containing the following fields:<ul>
+ * <li>childID [Typical OUT] - the ID of the selected child, or CHILDID_SELF, or CHILDID_MULTIPLE, or CHILDID_NONE</li>
+ * <li>accessible [Optional OUT] - the accessible object for the control or child may be returned instead of the childID</li>
+ * </ul>
+ */
+ public void getSelection(AccessibleControlEvent e);
+
+ /**
+ * Sent when an accessibility client requests the state
+ * of the control, or the state of a child of the control.
+ * <p>
+ * Return a state constant (constant defined in ACC beginning with STATE_)
+ * that describes the current state of the specified control or child in the
+ * <code>detail</code> field of the event object.
+ * </p>
+ *
+ * @param e an event object containing the following fields:<ul>
+ * <li>childID [IN] - an identifier specifying the control or one of its children</li>
+ * <li>detail [OUT] - a state constant describing the current state of the control or child</li>
+ * </ul>
+ */
+ public void getState(AccessibleControlEvent e);
+
+ /**
+ * Sent when an accessibility client requests the value
+ * of the control, or the value of a child of the control.
+ * <p>
+ * Many controls do not return a value. Examples of controls
+ * that do are: Combo returns the text string, Text returns
+ * its contents, ProgressBar returns a string representing a
+ * percentage, and Tree items return a string representing
+ * their level in the tree.
+ * </p><p>
+ * Return a string describing the value of the specified control
+ * or child in the <code>result</code> field of the event object.
+ * Returning null tells the client to use the platform value string.
+ * </p>
+ *
+ * @param e an event object containing the following fields:<ul>
+ * <li>childID [IN] - an identifier specifying the control or one of its children</li>
+ * <li>result [OUT] - the requested value string, or null</li>
+ * </ul>
+ */
+ public void getValue(AccessibleControlEvent e);
+
+ /**
+ * Sent when an accessibility client requests the children of the control.
+ * <p>
+ * Return the children as an array of childIDs in the <code>children</code>
+ * field of the event object.
+ * </p>
+ *
+ * @param e an event object containing the following fields:<ul>
+ * <li>children [Typical OUT] - an array of childIDs</li>
+ * <li>accessible [Optional OUT] - an array of accessible objects for the children may be returned instead of the childIDs</li>
+ * </ul>
+ */
+ public void getChildren(AccessibleControlEvent e);
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Accessibility/common/org/eclipse/swt/accessibility/AccessibleEvent.java b/bundles/org.eclipse.swt/Eclipse SWT Accessibility/common/org/eclipse/swt/accessibility/AccessibleEvent.java
index 5220b8c99f..3c909bc9d2 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT Accessibility/common/org/eclipse/swt/accessibility/AccessibleEvent.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT Accessibility/common/org/eclipse/swt/accessibility/AccessibleEvent.java
@@ -1,50 +1,50 @@
-package org.eclipse.swt.accessibility;
-
-/*
+package org.eclipse.swt.accessibility;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-import org.eclipse.swt.internal.SWTEventObject;
-
-/**
- * Instances of this class are sent as a result of
- * accessibility clients sending messages to controls
- * asking for information about the control instance.
- * <p>
- * Note: The meaning of the result field depends
- * on the message that was sent.
- * </p>
- *
- * @see AccessibleListener
- * @see AccessibleAdapter
- *
- * @since 2.0
- */
-public class AccessibleEvent extends SWTEventObject {
- /**
- * The value of this field is set by an accessibility client
- * before the accessible listener method is called.
- * ChildID can be CHILDID_SELF, representing the control itself,
- * or a 0-based integer representing a specific child of the control.
- */
- public int childID;
-
- /**
- * The value of this field must be set in the accessible listener
- * method before returning.
- * What to set it to depends on the listener method called, and
- * the childID specified by the client.
- */
- public String result;
-
-public AccessibleEvent(Object source) {
- super(source);
-}
-
-public String toString () {
- return "AccessibleEvent {childID=" + childID + " result=" + result + "}";
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+import org.eclipse.swt.internal.SWTEventObject;
+
+/**
+ * Instances of this class are sent as a result of
+ * accessibility clients sending messages to controls
+ * asking for information about the control instance.
+ * <p>
+ * Note: The meaning of the result field depends
+ * on the message that was sent.
+ * </p>
+ *
+ * @see AccessibleListener
+ * @see AccessibleAdapter
+ *
+ * @since 2.0
+ */
+public class AccessibleEvent extends SWTEventObject {
+ /**
+ * The value of this field is set by an accessibility client
+ * before the accessible listener method is called.
+ * ChildID can be CHILDID_SELF, representing the control itself,
+ * or a 0-based integer representing a specific child of the control.
+ */
+ public int childID;
+
+ /**
+ * The value of this field must be set in the accessible listener
+ * method before returning.
+ * What to set it to depends on the listener method called, and
+ * the childID specified by the client.
+ */
+ public String result;
+
+public AccessibleEvent(Object source) {
+ super(source);
+}
+
+public String toString () {
+ return "AccessibleEvent {childID=" + childID + " result=" + result + "}";
+}
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Accessibility/common/org/eclipse/swt/accessibility/AccessibleListener.java b/bundles/org.eclipse.swt/Eclipse SWT Accessibility/common/org/eclipse/swt/accessibility/AccessibleListener.java
index 903bfca01d..ee6396f753 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT Accessibility/common/org/eclipse/swt/accessibility/AccessibleListener.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT Accessibility/common/org/eclipse/swt/accessibility/AccessibleListener.java
@@ -1,122 +1,122 @@
-package org.eclipse.swt.accessibility;
-
-/*
+package org.eclipse.swt.accessibility;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-import org.eclipse.swt.internal.SWTEventListener;
-
-/**
- * Classes that implement this interface provide methods
- * that deal with the events that are generated when an
- * accessibility client sends a message to a control.
- * <p>
- * After creating an instance of a class that implements
- * this interface it can be added to a control using the
- * <code>addAccessibleListener</code> method and removed
- * using the <code>removeAccessibleListener</code> method.
- * When a client requests information, the appropriate method
- * will be invoked.
- * </p><p>
- * Note: Accessibility clients use child identifiers to specify
- * whether they want information about a control or one of its children.
- * Child identifiers are increasing integers beginning with 0.
- * The identifier CHILDID_SELF represents the control itself.
- * </p>
- *
- * @see AccessibleAdapter
- * @see AccessibleEvent
- *
- * @since 2.0
- */
-public interface AccessibleListener extends SWTEventListener {
-
- /**
- * Sent when an accessibility client requests the name
- * of the control, or the name of a child of the control.
- * <p>
- * Return the name of the control or specified child in the
- * <code>result</code> field of the event object. Returning
- * an empty string tells the client that the control or child
- * does not have a name, and returning null tells the client
- * to use the platform name.
- * </p>
- *
- * @param e an event object containing the following fields:<ul>
- * <li>childID [IN] - an identifier specifying the control or one of its children</li>
- * <li>result [OUT] - the requested name string, or null</li>
- * </ul>
- */
- public void getName(AccessibleEvent e);
-
- /**
- * Sent when an accessibility client requests the help string
- * of the control, or the help string of a child of the control.
- * <p>
- * The information in this property should be similar to the help
- * provided by toolTipText. It describes what the control or child
- * does or how to use it, as opposed to getDescription, which
- * describes appearance.
- * </p><p>
- * Return the help string of the control or specified child in
- * the <code>result</code> field of the event object. Returning
- * an empty string tells the client that the control or child
- * does not have a help string, and returning null tells the
- * client to use the platform help string.
- * </p>
- *
- * @param e an event object containing the following fields:<ul>
- * <li>childID [IN] - an identifier specifying the control or one of its children</li>
- * <li>result [OUT] - the requested help string, or null</li>
- * </ul>
- */
- public void getHelp(AccessibleEvent e);
-
- /**
- * Sent when an accessibility client requests the keyboard shortcut
- * of the control, or the keyboard shortcut of a child of the control.
- * <p>
- * A keyboard shortcut can either be a mnemonic, or an accelerator.
- * As a general rule, if the control or child can receive keyboard focus,
- * then you should expose its mnemonic, and if it cannot receive keyboard
- * focus, then you should expose its accelerator.
- * </p><p>
- * Return the keyboard shortcut string of the control or specified child
- * in the <code>result</code> field of the event object. Returning an
- * empty string tells the client that the control or child does not
- * have a keyboard shortcut string, and returning null tells the client
- * to use the platform keyboard shortcut string.
- * </p>
- *
- * @param e an event object containing the following fields:<ul>
- * <li>childID [IN] - an identifier specifying the control or one of its children</li>
- * <li>result [OUT] - the requested keyboard shortcut string (example: "ALT+N"), or null</li>
- * </ul>
- */
- public void getKeyboardShortcut(AccessibleEvent e);
-
- /**
- * Sent when an accessibility client requests a description
- * of the control, or a description of a child of the control.
- * <p>
- * This is a textual description of the control or child's visual
- * appearance, which is typically only necessary if it cannot be
- * determined from other properties such as role.
- * </p><p>
- * Return the description of the control or specified child in
- * the <code>result</code> field of the event object. Returning
- * an empty string tells the client that the control or child
- * does not have a description, and returning null tells the
- * client to use the platform description.
- * </p>
- *
- * @param e an event object containing the following fields:<ul>
- * <li>childID [IN] - an identifier specifying the control or one of its children</li>
- * <li>result [OUT] - the requested description string, or null</li>
- * </ul>
- */
- public void getDescription(AccessibleEvent e);
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+import org.eclipse.swt.internal.SWTEventListener;
+
+/**
+ * Classes that implement this interface provide methods
+ * that deal with the events that are generated when an
+ * accessibility client sends a message to a control.
+ * <p>
+ * After creating an instance of a class that implements
+ * this interface it can be added to a control using the
+ * <code>addAccessibleListener</code> method and removed
+ * using the <code>removeAccessibleListener</code> method.
+ * When a client requests information, the appropriate method
+ * will be invoked.
+ * </p><p>
+ * Note: Accessibility clients use child identifiers to specify
+ * whether they want information about a control or one of its children.
+ * Child identifiers are increasing integers beginning with 0.
+ * The identifier CHILDID_SELF represents the control itself.
+ * </p>
+ *
+ * @see AccessibleAdapter
+ * @see AccessibleEvent
+ *
+ * @since 2.0
+ */
+public interface AccessibleListener extends SWTEventListener {
+
+ /**
+ * Sent when an accessibility client requests the name
+ * of the control, or the name of a child of the control.
+ * <p>
+ * Return the name of the control or specified child in the
+ * <code>result</code> field of the event object. Returning
+ * an empty string tells the client that the control or child
+ * does not have a name, and returning null tells the client
+ * to use the platform name.
+ * </p>
+ *
+ * @param e an event object containing the following fields:<ul>
+ * <li>childID [IN] - an identifier specifying the control or one of its children</li>
+ * <li>result [OUT] - the requested name string, or null</li>
+ * </ul>
+ */
+ public void getName(AccessibleEvent e);
+
+ /**
+ * Sent when an accessibility client requests the help string
+ * of the control, or the help string of a child of the control.
+ * <p>
+ * The information in this property should be similar to the help
+ * provided by toolTipText. It describes what the control or child
+ * does or how to use it, as opposed to getDescription, which
+ * describes appearance.
+ * </p><p>
+ * Return the help string of the control or specified child in
+ * the <code>result</code> field of the event object. Returning
+ * an empty string tells the client that the control or child
+ * does not have a help string, and returning null tells the
+ * client to use the platform help string.
+ * </p>
+ *
+ * @param e an event object containing the following fields:<ul>
+ * <li>childID [IN] - an identifier specifying the control or one of its children</li>
+ * <li>result [OUT] - the requested help string, or null</li>
+ * </ul>
+ */
+ public void getHelp(AccessibleEvent e);
+
+ /**
+ * Sent when an accessibility client requests the keyboard shortcut
+ * of the control, or the keyboard shortcut of a child of the control.
+ * <p>
+ * A keyboard shortcut can either be a mnemonic, or an accelerator.
+ * As a general rule, if the control or child can receive keyboard focus,
+ * then you should expose its mnemonic, and if it cannot receive keyboard
+ * focus, then you should expose its accelerator.
+ * </p><p>
+ * Return the keyboard shortcut string of the control or specified child
+ * in the <code>result</code> field of the event object. Returning an
+ * empty string tells the client that the control or child does not
+ * have a keyboard shortcut string, and returning null tells the client
+ * to use the platform keyboard shortcut string.
+ * </p>
+ *
+ * @param e an event object containing the following fields:<ul>
+ * <li>childID [IN] - an identifier specifying the control or one of its children</li>
+ * <li>result [OUT] - the requested keyboard shortcut string (example: "ALT+N"), or null</li>
+ * </ul>
+ */
+ public void getKeyboardShortcut(AccessibleEvent e);
+
+ /**
+ * Sent when an accessibility client requests a description
+ * of the control, or a description of a child of the control.
+ * <p>
+ * This is a textual description of the control or child's visual
+ * appearance, which is typically only necessary if it cannot be
+ * determined from other properties such as role.
+ * </p><p>
+ * Return the description of the control or specified child in
+ * the <code>result</code> field of the event object. Returning
+ * an empty string tells the client that the control or child
+ * does not have a description, and returning null tells the
+ * client to use the platform description.
+ * </p>
+ *
+ * @param e an event object containing the following fields:<ul>
+ * <li>childID [IN] - an identifier specifying the control or one of its children</li>
+ * <li>result [OUT] - the requested description string, or null</li>
+ * </ul>
+ */
+ public void getDescription(AccessibleEvent e);
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Accessibility/emulated/org/eclipse/swt/accessibility/Accessible.java b/bundles/org.eclipse.swt/Eclipse SWT Accessibility/emulated/org/eclipse/swt/accessibility/Accessible.java
index 2c22be84fb..2e2fc877e8 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT Accessibility/emulated/org/eclipse/swt/accessibility/Accessible.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT Accessibility/emulated/org/eclipse/swt/accessibility/Accessible.java
@@ -1,193 +1,193 @@
-package org.eclipse.swt.accessibility;
-
-/*
+package org.eclipse.swt.accessibility;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-import org.eclipse.swt.widgets.Control;
-
-/**
- * Instances of this class provide a bridge between application
- * code and assistive technology clients. Many platforms provide
- * default accessible behavior for most widgets, and this class
- * allows that default behavior to be overridden. Applications
- * can get the default Accessible object for a control by sending
- * it <code>getAccessible</code>, and then add an accessible listener
- * to override simple items like the name and help string, or they
- * can add an accessible control listener to override complex items.
- * As a rule of thumb, an application would only want to use the
- * accessible control listener to implement accessibility for a
- * custom control.
- *
- * @see Control#getAccessible
- * @see AccessibleListener
- * @see AccessibleEvent
- * @see AccessibleControlListener
- * @see AccessibleControlEvent
- *
- * @since 2.0
+ * http://www.eclipse.org/legal/cpl-v10.html
*/
-public class Accessible {
-
- Accessible(Control control) {
- }
-
- /**
- * Invokes platform specific functionality to allocate a new accessible object.
- * <p>
- * <b>IMPORTANT:</b> This method is <em>not</em> part of the public
- * API for <code>Accessible</code>. It is marked public only so that it
- * can be shared within the packages provided by SWT. It is not
- * available on all platforms, and should never be called from
- * application code.
- * </p>
- *
- * @param control the control to get the accessible object for
- * @return the platform specific accessible object
- *
- * @private
+
+import org.eclipse.swt.widgets.Control;
+
+/**
+ * Instances of this class provide a bridge between application
+ * code and assistive technology clients. Many platforms provide
+ * default accessible behavior for most widgets, and this class
+ * allows that default behavior to be overridden. Applications
+ * can get the default Accessible object for a control by sending
+ * it <code>getAccessible</code>, and then add an accessible listener
+ * to override simple items like the name and help string, or they
+ * can add an accessible control listener to override complex items.
+ * As a rule of thumb, an application would only want to use the
+ * accessible control listener to implement accessibility for a
+ * custom control.
+ *
+ * @see Control#getAccessible
+ * @see AccessibleListener
+ * @see AccessibleEvent
+ * @see AccessibleControlListener
+ * @see AccessibleControlEvent
+ *
+ * @since 2.0
+ */
+public class Accessible {
+
+ Accessible(Control control) {
+ }
+
+ /**
+ * Invokes platform specific functionality to allocate a new accessible object.
+ * <p>
+ * <b>IMPORTANT:</b> This method is <em>not</em> part of the public
+ * API for <code>Accessible</code>. It is marked public only so that it
+ * can be shared within the packages provided by SWT. It is not
+ * available on all platforms, and should never be called from
+ * application code.
+ * </p>
+ *
+ * @param control the control to get the accessible object for
+ * @return the platform specific accessible object
+ *
+ * @private
*/
- public static Accessible internal_new_Accessible(Control control) {
- return new Accessible(control);
- }
-
- /**
- * Adds the listener to the collection of listeners who will
- * be notifed when an accessible client asks for certain strings,
- * such as name, description, help, or keyboard shortcut. The
- * listener is notified by sending it one of the messages defined
- * in the <code>AccessibleListener</code> interface.
- *
- * @param listener the listener that should be notified when the receiver
- * is asked for a name, description, help, or keyboard shortcut string
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver's control has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver's control</li>
- * </ul>
- *
- * @see AccessibleListener
- * @see #removeAccessibleListener
+ public static Accessible internal_new_Accessible(Control control) {
+ return new Accessible(control);
+ }
+
+ /**
+ * Adds the listener to the collection of listeners who will
+ * be notifed when an accessible client asks for certain strings,
+ * such as name, description, help, or keyboard shortcut. The
+ * listener is notified by sending it one of the messages defined
+ * in the <code>AccessibleListener</code> interface.
+ *
+ * @param listener the listener that should be notified when the receiver
+ * is asked for a name, description, help, or keyboard shortcut string
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver's control has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver's control</li>
+ * </ul>
+ *
+ * @see AccessibleListener
+ * @see #removeAccessibleListener
*/
- public void addAccessibleListener(AccessibleListener listener) {
- }
-
- /**
- * Removes the listener from the collection of listeners who will
- * be notifed when an accessible client asks for certain strings,
- * such as name, description, help, or keyboard shortcut.
- *
- * @param listener the listener that should no longer be notified when the receiver
- * is asked for a name, description, help, or keyboard shortcut string
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver's control has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver's control</li>
- * </ul>
- *
- * @see AccessibleListener
- * @see #addDisposeListener
+ public void addAccessibleListener(AccessibleListener listener) {
+ }
+
+ /**
+ * Removes the listener from the collection of listeners who will
+ * be notifed when an accessible client asks for certain strings,
+ * such as name, description, help, or keyboard shortcut.
+ *
+ * @param listener the listener that should no longer be notified when the receiver
+ * is asked for a name, description, help, or keyboard shortcut string
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver's control has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver's control</li>
+ * </ul>
+ *
+ * @see AccessibleListener
+ * @see #addDisposeListener
*/
- public void removeAccessibleListener(AccessibleListener listener) {
- }
-
- /**
- * Adds the listener to the collection of listeners who will
- * be notifed when an accessible client asks for custom control
- * specific information. The listener is notified by sending it
- * one of the messages defined in the <code>AccessibleControlListener</code>
- * interface.
- *
- * @param listener the listener that should be notified when the receiver
- * is asked for custom control specific information
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver's control has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver's control</li>
- * </ul>
- *
- * @see AccessibleControlListener
- * @see #removeAccessibleControlListener
+ public void removeAccessibleListener(AccessibleListener listener) {
+ }
+
+ /**
+ * Adds the listener to the collection of listeners who will
+ * be notifed when an accessible client asks for custom control
+ * specific information. The listener is notified by sending it
+ * one of the messages defined in the <code>AccessibleControlListener</code>
+ * interface.
+ *
+ * @param listener the listener that should be notified when the receiver
+ * is asked for custom control specific information
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver's control has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver's control</li>
+ * </ul>
+ *
+ * @see AccessibleControlListener
+ * @see #removeAccessibleControlListener
*/
- public void addAccessibleControlListener(AccessibleControlListener listener) {
- }
-
- /**
- * Removes the listener from the collection of listeners who will
- * be notifed when an accessible client asks for custom control
- * specific information.
- *
- * @param listener the listener that should no longer be notified when the receiver
- * is asked for custom control specific information
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver's control has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver's control</li>
- * </ul>
- *
- * @see AccessibleControlListener
- * @see #addAccessibleControlListener
+ public void addAccessibleControlListener(AccessibleControlListener listener) {
+ }
+
+ /**
+ * Removes the listener from the collection of listeners who will
+ * be notifed when an accessible client asks for custom control
+ * specific information.
+ *
+ * @param listener the listener that should no longer be notified when the receiver
+ * is asked for custom control specific information
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver's control has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver's control</li>
+ * </ul>
+ *
+ * @see AccessibleControlListener
+ * @see #addAccessibleControlListener
*/
- public void removeAccessibleControlListener(AccessibleControlListener listener) {
- }
-
- /**
- * Sends a message to accessible clients indicating that the focus
- * has changed within a custom control.
- *
- * @param childID an identifier specifying a child of the control
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver's control has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver's control</li>
- * </ul>
+ public void removeAccessibleControlListener(AccessibleControlListener listener) {
+ }
+
+ /**
+ * Sends a message to accessible clients indicating that the focus
+ * has changed within a custom control.
+ *
+ * @param childID an identifier specifying a child of the control
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver's control has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver's control</li>
+ * </ul>
*/
- public void setFocus(int childID) {
- }
-
- /**
- * Invokes platform specific functionality to dispose an accessible object.
- * <p>
- * <b>IMPORTANT:</b> This method is <em>not</em> part of the public
- * API for <code>Accessible</code>. It is marked public only so that it
- * can be shared within the packages provided by SWT. It is not
- * available on all platforms, and should never be called from
- * application code.
- * </p>
- *
- * @private
+ public void setFocus(int childID) {
+ }
+
+ /**
+ * Invokes platform specific functionality to dispose an accessible object.
+ * <p>
+ * <b>IMPORTANT:</b> This method is <em>not</em> part of the public
+ * API for <code>Accessible</code>. It is marked public only so that it
+ * can be shared within the packages provided by SWT. It is not
+ * available on all platforms, and should never be called from
+ * application code.
+ * </p>
+ *
+ * @private
*/
- public void internal_dispose_Accessible() {
- }
-
- /**
- * Invokes platform specific functionality to handle a window message.
- * <p>
- * <b>IMPORTANT:</b> This method is <em>not</em> part of the public
- * API for <code>Accessible</code>. It is marked public only so that it
- * can be shared within the packages provided by SWT. It is not
- * available on all platforms, and should never be called from
- * application code.
- * </p>
- *
- * @private
+ public void internal_dispose_Accessible() {
+ }
+
+ /**
+ * Invokes platform specific functionality to handle a window message.
+ * <p>
+ * <b>IMPORTANT:</b> This method is <em>not</em> part of the public
+ * API for <code>Accessible</code>. It is marked public only so that it
+ * can be shared within the packages provided by SWT. It is not
+ * available on all platforms, and should never be called from
+ * application code.
+ * </p>
+ *
+ * @private
*/
- public int internal_WM_GETOBJECT (int wParam, int lParam) {
- return 0;
- }
-}
+ public int internal_WM_GETOBJECT (int wParam, int lParam) {
+ return 0;
+ }
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Accessibility/win32/org/eclipse/swt/accessibility/Accessible.java b/bundles/org.eclipse.swt/Eclipse SWT Accessibility/win32/org/eclipse/swt/accessibility/Accessible.java
index c1d1ba01b0..d90789220d 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT Accessibility/win32/org/eclipse/swt/accessibility/Accessible.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT Accessibility/win32/org/eclipse/swt/accessibility/Accessible.java
@@ -1,1163 +1,1163 @@
-package org.eclipse.swt.accessibility;
-
-/*
+package org.eclipse.swt.accessibility;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-import java.util.Vector;
-import org.eclipse.swt.*;
-import org.eclipse.swt.widgets.*;
-import org.eclipse.swt.internal.win32.*;
-import org.eclipse.swt.ole.win32.*;
-import org.eclipse.swt.internal.ole.win32.*;
-
-/**
- * Instances of this class provide a bridge between application
- * code and assistive technology clients. Many platforms provide
- * default accessible behavior for most widgets, and this class
- * allows that default behavior to be overridden. Applications
- * can get the default Accessible object for a control by sending
- * it <code>getAccessible</code>, and then add an accessible listener
- * to override simple items like the name and help string, or they
- * can add an accessible control listener to override complex items.
- * As a rule of thumb, an application would only want to use the
- * accessible control listener to implement accessibility for a
- * custom control.
- *
- * @see Control#getAccessible
- * @see AccessibleListener
- * @see AccessibleEvent
- * @see AccessibleControlListener
- * @see AccessibleControlEvent
- *
- * @since 2.0
- */
-public class Accessible {
- int refCount = 0, enumIndex = 0;
- COMObject objIAccessible, objIEnumVARIANT;
- IAccessible iaccessible;
- Vector accessibleListeners = new Vector(), accessibleControlListeners = new Vector();
- Object[] variants;
- Control control;
-
- Accessible(Control control) {
- this.control = control;
- int[] ppvObject = new int[1];
- int result = COM.CreateStdAccessibleObject(control.handle, COM.OBJID_CLIENT, COM.IIDIAccessible, ppvObject);
- if (result == COM.E_NOTIMPL) return;
- if (result != COM.S_OK) OLE.error(OLE.ERROR_CANNOT_CREATE_OBJECT, result);
- iaccessible = new IAccessible(ppvObject[0]);
- iaccessible.AddRef();
-
- objIAccessible = new COMObject(new int[] {2,0,0,1,3,5,8,1,1,5,5,5,5,5,5,5,6,5,1,1,5,5,8,6,3,4,5,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();}
- // method3 GetTypeInfoCount - not implemented
- // method4 GetTypeInfo - not implemented
- // method5 GetIDsOfNames - not implemented
- // method6 Invoke - not implemented
- public int method7(int[] args) {return get_accParent(args[0]);}
- public int method8(int[] args) {return get_accChildCount(args[0]);}
- public int method9(int[] args) {return get_accChild(args[0], args[1], args[2], args[3], args[4]);}
- public int method10(int[] args) {return get_accName(args[0], args[1], args[2], args[3], args[4]);}
- public int method11(int[] args) {return get_accValue(args[0], args[1], args[2], args[3], args[4]);}
- public int method12(int[] args) {return get_accDescription(args[0], args[1], args[2], args[3], args[4]);}
- public int method13(int[] args) {return get_accRole(args[0], args[1], args[2], args[3], args[4]);}
- public int method14(int[] args) {return get_accState(args[0], args[1], args[2], args[3], args[4]);}
- public int method15(int[] args) {return get_accHelp(args[0], args[1], args[2], args[3], args[4]);}
- public int method16(int[] args) {return get_accHelpTopic(args[0], args[1], args[2], args[3], args[4], args[5]);}
- public int method17(int[] args) {return get_accKeyboardShortcut(args[0], args[1], args[2], args[3], args[4]);}
- public int method18(int[] args) {return get_accFocus(args[0]);}
- public int method19(int[] args) {return get_accSelection(args[0]);}
- public int method20(int[] args) {return get_accDefaultAction(args[0], args[1], args[2], args[3], args[4]);}
- public int method21(int[] args) {return accSelect(args[0], args[1], args[2], args[3], args[4]);}
- public int method22(int[] args) {return accLocation(args[0], args[1], args[2], args[3], args[4], args[5], args[6], args[7]);}
- public int method23(int[] args) {return accNavigate(args[0], args[1], args[2], args[3], args[4], args[5]);}
- public int method24(int[] args) {return accHitTest(args[0], args[1], args[2]);}
- public int method25(int[] args) {return accDoDefaultAction(args[0], args[1], args[2], args[3]);}
- public int method26(int[] args) {return put_accName(args[0], args[1], args[2], args[3], args[4]);}
- public int method27(int[] args) {return put_accValue(args[0], args[1], args[2], args[3], args[4]);}
- };
-
- objIEnumVARIANT = 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
- };
- AddRef();
- }
-
- /**
- * Invokes platform specific functionality to allocate a new accessible object.
- * <p>
- * <b>IMPORTANT:</b> This method is <em>not</em> part of the public
- * API for <code>Accessible</code>. It is marked public only so that it
- * can be shared within the packages provided by SWT. It is not
- * available on all platforms, and should never be called from
- * application code.
- * </p>
- *
- * @param control the control to get the accessible object for
- * @return the platform specific accessible object
- *
- * @private
- */
- public static Accessible internal_new_Accessible(Control control) {
- return new Accessible(control);
- }
-
- /**
- * Adds the listener to the collection of listeners who will
- * be notifed when an accessible client asks for certain strings,
- * such as name, description, help, or keyboard shortcut. The
- * listener is notified by sending it one of the messages defined
- * in the <code>AccessibleListener</code> interface.
- *
- * @param listener the listener that should be notified when the receiver
- * is asked for a name, description, help, or keyboard shortcut string
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver's control has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver's control</li>
- * </ul>
- *
- * @see AccessibleListener
- * @see #removeAccessibleListener
- */
- public void addAccessibleListener(AccessibleListener listener) {
- checkWidget();
- if (listener == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
- accessibleListeners.addElement(listener);
- }
-
- /**
- * Removes the listener from the collection of listeners who will
- * be notifed when an accessible client asks for certain strings,
- * such as name, description, help, or keyboard shortcut.
- *
- * @param listener the listener that should no longer be notified when the receiver
- * is asked for a name, description, help, or keyboard shortcut string
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver's control has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver's control</li>
- * </ul>
- *
- * @see AccessibleListener
- * @see #addDisposeListener
- */
- public void removeAccessibleListener(AccessibleListener listener) {
- checkWidget();
- if (listener == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
- accessibleListeners.removeElement(listener);
- }
-
- /**
- * Adds the listener to the collection of listeners who will
- * be notifed when an accessible client asks for custom control
- * specific information. The listener is notified by sending it
- * one of the messages defined in the <code>AccessibleControlListener</code>
- * interface.
- *
- * @param listener the listener that should be notified when the receiver
- * is asked for custom control specific information
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver's control has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver's control</li>
- * </ul>
- *
- * @see AccessibleControlListener
- * @see #removeAccessibleControlListener
- */
- public void addAccessibleControlListener(AccessibleControlListener listener) {
- checkWidget();
- if (listener == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
- accessibleControlListeners.addElement(listener);
- }
-
- /**
- * Removes the listener from the collection of listeners who will
- * be notifed when an accessible client asks for custom control
- * specific information.
- *
- * @param listener the listener that should no longer be notified when the receiver
- * is asked for custom control specific information
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver's control has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver's control</li>
- * </ul>
- *
- * @see AccessibleControlListener
- * @see #addAccessibleControlListener
- */
- public void removeAccessibleControlListener(AccessibleControlListener listener) {
- checkWidget();
- if (listener == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
- accessibleControlListeners.removeElement(listener);
- }
-
- /**
- * Sends a message to accessible clients indicating that the focus
- * has changed within a custom control.
- *
- * @param childID an identifier specifying a child of the control
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver's control has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver's control</li>
- * </ul>
- */
- public void setFocus(int childID) {
- checkWidget();
- int id;
- if (childID == ACC.CHILDID_SELF) id = COM.CHILDID_SELF;
- else if (control instanceof Tree) id = childID; // Tree item childIDs are pointers
- else id = childID + 1; // All other childIDs are 1-based indices
- COM.NotifyWinEvent (COM.EVENT_OBJECT_FOCUS, control.handle, COM.OBJID_CLIENT, id);
- }
-
- /**
- * Invokes platform specific functionality to dispose an accessible object.
- * <p>
- * <b>IMPORTANT:</b> This method is <em>not</em> part of the public
- * API for <code>Accessible</code>. It is marked public only so that it
- * can be shared within the packages provided by SWT. It is not
- * available on all platforms, and should never be called from
- * application code.
- * </p>
- *
- * @private
- */
- public void internal_dispose_Accessible() {
- if (iaccessible != null)
- iaccessible.Release();
- iaccessible = null;
- Release();
- }
-
- /**
- * Invokes platform specific functionality to handle a window message.
- * <p>
- * <b>IMPORTANT:</b> This method is <em>not</em> part of the public
- * API for <code>Accessible</code>. It is marked public only so that it
- * can be shared within the packages provided by SWT. It is not
- * available on all platforms, and should never be called from
- * application code.
- * </p>
- *
- * @private
- */
- public int internal_WM_GETOBJECT (int wParam, int lParam) {
- if (objIAccessible == null) return 0;
- if (lParam == COM.OBJID_CLIENT) {
- return COM.LresultFromObject(COM.IIDIAccessible, wParam, objIAccessible.getAddress());
- }
- return 0;
- }
-
- int QueryInterface(int arg1, int arg2) {
- if (iaccessible == null) return COM.CO_E_OBJNOTCONNECTED;
- GUID guid = new GUID();
- COM.MoveMemory(guid, arg1, GUID.sizeof);
-
- if (COM.IsEqualGUID(guid, COM.IIDIUnknown)) {
- COM.MoveMemory(arg2, new int[] { objIAccessible.getAddress()}, 4);
- AddRef();
- return COM.S_OK;
- }
-
- if (COM.IsEqualGUID(guid, COM.IIDIDispatch)) {
- COM.MoveMemory(arg2, new int[] { objIAccessible.getAddress()}, 4);
- AddRef();
- return COM.S_OK;
- }
-
- if (COM.IsEqualGUID(guid, COM.IIDIAccessible)) {
- COM.MoveMemory(arg2, new int[] { objIAccessible.getAddress()}, 4);
- AddRef();
- return COM.S_OK;
- }
-
- if (COM.IsEqualGUID(guid, COM.IIDIEnumVARIANT)) {
- COM.MoveMemory(arg2, new int[] { objIEnumVARIANT.getAddress()}, 4);
- AddRef();
- enumIndex = 0;
- return COM.S_OK;
- }
-
- int[] ppvObject = new int[1];
- int result = iaccessible.QueryInterface(guid, ppvObject);
- COM.MoveMemory(arg2, ppvObject, 4);
- return result;
- }
-
- int AddRef() {
- refCount++;
- return refCount;
- }
-
- int Release() {
- refCount--;
-
- if (refCount == 0) {
- if (objIAccessible != null)
- objIAccessible.dispose();
- objIAccessible = null;
-
- if (objIEnumVARIANT != null)
- objIEnumVARIANT.dispose();
- objIEnumVARIANT = null;
- }
- return refCount;
- }
-
- int accDoDefaultAction(int varChild_vt, int varChild_reserved1, int varChild_lVal, int varChild_reserved2) {
- if (iaccessible == null) return COM.CO_E_OBJNOTCONNECTED;
- // Currently, we don't let the application override this. Forward to the proxy.
- int code = iaccessible.accDoDefaultAction(varChild_vt, varChild_reserved1, varChild_lVal, varChild_reserved2);
- if (code == COM.E_INVALIDARG) code = COM.S_FALSE; // proxy doesn't know about app childID
- return code;
- }
-
- int accHitTest(int xLeft, int yTop, int pvarChild) {
- if (iaccessible == null) return COM.CO_E_OBJNOTCONNECTED;
- if (accessibleControlListeners.size() == 0) {
- return iaccessible.accHitTest(xLeft, yTop, pvarChild);
- }
-
- AccessibleControlEvent event = new AccessibleControlEvent(this);
- event.childID = ACC.CHILDID_NONE;
- event.x = xLeft;
- event.y = yTop;
- for (int i = 0; i < accessibleControlListeners.size(); i++) {
- AccessibleControlListener listener = (AccessibleControlListener) accessibleControlListeners.elementAt(i);
- listener.getChildAtPoint(event);
- }
- int childID = event.childID;
- if (childID == ACC.CHILDID_NONE) {
- return iaccessible.accHitTest(xLeft, yTop, pvarChild);
- }
- if (childID == ACC.CHILDID_SELF) childID = COM.CHILDID_SELF;
- else if (!(control instanceof Tree)) childID++; // Tree item childIDs are pointers (not 1-based indices)
- COM.MoveMemory(pvarChild, new short[] { COM.VT_I4 }, 2);
- COM.MoveMemory(pvarChild + 8, new int[] { childID }, 4);
- return COM.S_OK;
- }
-
- int accLocation(int pxLeft, int pyTop, int pcxWidth, int pcyHeight, int varChild_vt, int varChild_reserved1, int varChild_lVal, int varChild_reserved2) {
- if (iaccessible == null) return COM.CO_E_OBJNOTCONNECTED;
- if ((varChild_vt & 0xFFFF) != COM.VT_I4) return COM.E_INVALIDARG;
-
- /* Get the default location from the OS. */
- int osLeft = 0, osTop = 0, osWidth = 0, osHeight = 0;
- int code = iaccessible.accLocation(pxLeft, pyTop, pcxWidth, pcyHeight, varChild_vt, varChild_reserved1, varChild_lVal, varChild_reserved2);
- if (code == COM.E_INVALIDARG) code = COM.S_FALSE; // proxy doesn't know about app childID
- if (accessibleControlListeners.size() == 0) return code;
- if (code == COM.S_OK) {
- int[] pLeft = new int[1], pTop = new int[1], pWidth = new int[1], pHeight = new int[1];
- COM.MoveMemory(pLeft, pxLeft, 4);
- COM.MoveMemory(pTop, pyTop, 4);
- COM.MoveMemory(pWidth, pcxWidth, 4);
- COM.MoveMemory(pHeight, pcyHeight, 4);
- osLeft = pLeft[0]; osTop = pTop[0]; osWidth = pWidth[0]; osHeight = pHeight[0];
- }
-
- AccessibleControlEvent event = new AccessibleControlEvent(this);
- if (varChild_lVal == COM.CHILDID_SELF) event.childID = ACC.CHILDID_SELF;
- else if (control instanceof Tree) event.childID = varChild_lVal; // Tree item childIDs are pointers
- else event.childID = varChild_lVal - 1; // All other childIDs are 1-based indices
- event.x = osLeft;
- event.y = osTop;
- event.width = osWidth;
- event.height = osHeight;
- for (int i = 0; i < accessibleControlListeners.size(); i++) {
- AccessibleControlListener listener = (AccessibleControlListener) accessibleControlListeners.elementAt(i);
- listener.getLocation(event);
- }
- OS.MoveMemory(pxLeft, new int[] { event.x }, 4);
- OS.MoveMemory(pyTop, new int[] { event.y }, 4);
- OS.MoveMemory(pcxWidth, new int[] { event.width }, 4);
- OS.MoveMemory(pcyHeight, new int[] { event.height }, 4);
- return COM.S_OK;
- }
-
- int accNavigate(int navDir, int varStart_vt, int varStart_reserved1, int varStart_lVal, int varStart_reserved2, int pvarEndUpAt) {
- if (iaccessible == null) return COM.CO_E_OBJNOTCONNECTED;
- // Currently, we don't let the application override this. Forward to the proxy.
- int code = iaccessible.accNavigate(navDir, varStart_vt, varStart_reserved1, varStart_lVal, varStart_reserved2, pvarEndUpAt);
- if (code == COM.E_INVALIDARG) code = COM.S_FALSE; // proxy doesn't know about app childID
- return code;
- }
-
- int accSelect(int flagsSelect, int varChild_vt, int varChild_reserved1, int varChild_lVal, int varChild_reserved2) {
- if (iaccessible == null) return COM.CO_E_OBJNOTCONNECTED;
- // Currently, we don't let the application override this. Forward to the proxy.
- int code = iaccessible.accSelect(flagsSelect, varChild_vt, varChild_reserved1, varChild_lVal, varChild_reserved2);
- if (code == COM.E_INVALIDARG) code = COM.S_FALSE; // proxy doesn't know about app childID
- return code;
- }
-
- int get_accChild(int varChild_vt, int varChild_reserved1, int varChild_lVal, int varChild_reserved2, int ppdispChild) {
- if (iaccessible == null) return COM.CO_E_OBJNOTCONNECTED;
- if ((varChild_vt & 0xFFFF) != COM.VT_I4) return COM.E_INVALIDARG;
- if (accessibleControlListeners.size() == 0) {
- int code = iaccessible.get_accChild(varChild_vt, varChild_reserved1, varChild_lVal, varChild_reserved2, ppdispChild);
- if (code == COM.E_INVALIDARG) code = COM.S_FALSE; // proxy doesn't know about app childID
- return code;
- }
-
- AccessibleControlEvent event = new AccessibleControlEvent(this);
- if (varChild_lVal == COM.CHILDID_SELF) event.childID = ACC.CHILDID_SELF;
- else if (control instanceof Tree) event.childID = varChild_lVal; // Tree item childIDs are pointers
- else event.childID = varChild_lVal - 1; // All other childIDs are 1-based indices
- for (int i = 0; i < accessibleControlListeners.size(); i++) {
- AccessibleControlListener listener = (AccessibleControlListener) accessibleControlListeners.elementAt(i);
- listener.getChild(event);
- }
- Accessible accessible = event.accessible;
- if (accessible != null) {
- COM.MoveMemory(ppdispChild, new int[] { accessible.objIAccessible.getAddress() }, 4);
- return COM.S_OK;
- }
- return COM.S_FALSE;
- }
-
- int get_accChildCount(int pcountChildren) {
- if (iaccessible == null) return COM.CO_E_OBJNOTCONNECTED;
-
- /* Get the default child count from the OS. */
- int osChildCount = 0;
- int code = iaccessible.get_accChildCount(pcountChildren);
- if (accessibleControlListeners.size() == 0) return code;
- if (code == COM.S_OK) {
- int[] pChildCount = new int[1];
- COM.MoveMemory(pChildCount, pcountChildren, 4);
- osChildCount = pChildCount[0];
- }
-
- AccessibleControlEvent event = new AccessibleControlEvent(this);
- event.childID = ACC.CHILDID_SELF;
- event.detail = osChildCount;
- for (int i = 0; i < accessibleControlListeners.size(); i++) {
- AccessibleControlListener listener = (AccessibleControlListener) accessibleControlListeners.elementAt(i);
- listener.getChildCount(event);
- }
-
- COM.MoveMemory(pcountChildren, new int[] { event.detail }, 4);
- return COM.S_OK;
- }
-
- int get_accDefaultAction(int varChild_vt, int varChild_reserved1, int varChild_lVal, int varChild_reserved2, int pszDefaultAction) {
- if (iaccessible == null) return COM.CO_E_OBJNOTCONNECTED;
- if ((varChild_vt & 0xFFFF) != COM.VT_I4) return COM.E_INVALIDARG;
-
- /* Get the default defaultAction from the OS. */
- String osDefaultAction = null;
- int code = iaccessible.get_accDefaultAction(varChild_vt, varChild_reserved1, varChild_lVal, varChild_reserved2, pszDefaultAction);
- if (code == COM.E_INVALIDARG) code = COM.S_FALSE; // proxy doesn't know about app childID
- if (accessibleControlListeners.size() == 0) return code;
- if (code == COM.S_OK) {
- int[] pDefaultAction = new int[1];
- COM.MoveMemory(pDefaultAction, pszDefaultAction, 4);
- int size = COM.SysStringByteLen(pDefaultAction[0]);
- if (size > 0) {
- char[] buffer = new char[(size + 1) /2];
- COM.MoveMemory(buffer, pDefaultAction[0], size);
- osDefaultAction = new String(buffer);
- }
- }
-
- AccessibleControlEvent event = new AccessibleControlEvent(this);
- if (varChild_lVal == COM.CHILDID_SELF) event.childID = ACC.CHILDID_SELF;
- else if (control instanceof Tree) event.childID = varChild_lVal; // Tree item childIDs are pointers
- else event.childID = varChild_lVal - 1; // All other childIDs are 1-based indices
- event.result = osDefaultAction;
- for (int i = 0; i < accessibleControlListeners.size(); i++) {
- AccessibleControlListener listener = (AccessibleControlListener) accessibleControlListeners.elementAt(i);
- listener.getDefaultAction(event);
- }
- if (event.result == null) return code;
- char[] data = (event.result + "\0").toCharArray();
- int ptr = COM.SysAllocString(data);
- COM.MoveMemory(pszDefaultAction, new int[] { ptr }, 4);
- return COM.S_OK;
- }
-
- int get_accDescription(int varChild_vt, int varChild_reserved1, int varChild_lVal, int varChild_reserved2, int pszDescription) {
- if (iaccessible == null) return COM.CO_E_OBJNOTCONNECTED;
- if ((varChild_vt & 0xFFFF) != COM.VT_I4) return COM.E_INVALIDARG;
-
- /* Get the default description from the OS. */
- String osDescription = null;
- int code = iaccessible.get_accDescription(varChild_vt, varChild_reserved1, varChild_lVal, varChild_reserved2, pszDescription);
- if (code == COM.E_INVALIDARG) code = COM.S_FALSE; // proxy doesn't know about app childID
- if (accessibleListeners.size() == 0) return code;
- if (code == COM.S_OK) {
- int[] pDescription = new int[1];
- COM.MoveMemory(pDescription, pszDescription, 4);
- int size = COM.SysStringByteLen(pDescription[0]);
- if (size > 0) {
- char[] buffer = new char[(size + 1) /2];
- COM.MoveMemory(buffer, pDescription[0], size);
- osDescription = new String(buffer);
- }
- }
-
- AccessibleEvent event = new AccessibleEvent(this);
- if (varChild_lVal == COM.CHILDID_SELF) event.childID = ACC.CHILDID_SELF;
- else if (control instanceof Tree) event.childID = varChild_lVal; // Tree item childIDs are pointers
- else event.childID = varChild_lVal - 1; // All other childIDs are 1-based indices
- event.result = osDescription;
- for (int i = 0; i < accessibleListeners.size(); i++) {
- AccessibleListener listener = (AccessibleListener) accessibleListeners.elementAt(i);
- listener.getDescription(event);
- }
- if (event.result == null) return code;
- char[] data = (event.result + "\0").toCharArray();
- int ptr = COM.SysAllocString(data);
- COM.MoveMemory(pszDescription, new int[] { ptr }, 4);
- return COM.S_OK;
- }
-
- int get_accFocus(int pvarChild) {
- if (iaccessible == null) return COM.CO_E_OBJNOTCONNECTED;
-
- /* Get the default focus child from the OS. */
- int osChild = ACC.CHILDID_NONE;
- int code = iaccessible.get_accFocus(pvarChild);
- if (accessibleControlListeners.size() == 0) return code;
- if (code == COM.S_OK) {
- short[] pvt = new short[1];
- COM.MoveMemory(pvt, pvarChild, 2);
- if (pvt[0] == COM.VT_I4) {
- int[] pChild = new int[1];
- COM.MoveMemory(pChild, pvarChild + 8, 4);
- osChild = (pChild[0] == COM.CHILDID_SELF) ? ACC.CHILDID_SELF : pChild[0] - 1;
- }
- }
-
- AccessibleControlEvent event = new AccessibleControlEvent(this);
- event.childID = osChild;
- for (int i = 0; i < accessibleControlListeners.size(); i++) {
- AccessibleControlListener listener = (AccessibleControlListener) accessibleControlListeners.elementAt(i);
- listener.getFocus(event);
- }
- Accessible accessible = event.accessible;
- if (accessible != null) {
- COM.MoveMemory(pvarChild, new short[] { COM.VT_DISPATCH }, 2);
- COM.MoveMemory(pvarChild + 8, new int[] { accessible.objIAccessible.getAddress() }, 4);
- return COM.S_OK;
- }
- int childID = event.childID;
- if (childID == ACC.CHILDID_NONE) {
- COM.MoveMemory(pvarChild, new short[] { COM.VT_EMPTY }, 2);
- return COM.S_FALSE;
- }
- if (childID == ACC.CHILDID_SELF) {
- COM.MoveMemory(pvarChild, new short[] { COM.VT_DISPATCH }, 2);
- COM.MoveMemory(pvarChild + 8, new int[] { objIAccessible.getAddress() }, 4);
- return COM.S_OK;
- }
- COM.MoveMemory(pvarChild, new short[] { COM.VT_I4 }, 2);
- COM.MoveMemory(pvarChild + 8, new int[] { childID + 1 }, 4);
- return COM.S_OK;
- }
-
- int get_accHelp(int varChild_vt, int varChild_reserved1, int varChild_lVal, int varChild_reserved2, int pszHelp) {
- if (iaccessible == null) return COM.CO_E_OBJNOTCONNECTED;
- if ((varChild_vt & 0xFFFF) != COM.VT_I4) return COM.E_INVALIDARG;
-
- /* Get the default help string from the OS. */
- String osHelp = null;
- int code = iaccessible.get_accHelp(varChild_vt, varChild_reserved1, varChild_lVal, varChild_reserved2, pszHelp);
- if (code == COM.E_INVALIDARG) code = COM.S_FALSE; // proxy doesn't know about app childID
- if (accessibleListeners.size() == 0) return code;
- if (code == COM.S_OK) {
- int[] pHelp = new int[1];
- COM.MoveMemory(pHelp, pszHelp, 4);
- int size = COM.SysStringByteLen(pHelp[0]);
- if (size > 0) {
- char[] buffer = new char[(size + 1) /2];
- COM.MoveMemory(buffer, pHelp[0], size);
- osHelp = new String(buffer);
- }
- }
-
- AccessibleEvent event = new AccessibleEvent(this);
- if (varChild_lVal == COM.CHILDID_SELF) event.childID = ACC.CHILDID_SELF;
- else if (control instanceof Tree) event.childID = varChild_lVal; // Tree item childIDs are pointers
- else event.childID = varChild_lVal - 1; // All other childIDs are 1-based indices
- event.result = osHelp;
- for (int i = 0; i < accessibleListeners.size(); i++) {
- AccessibleListener listener = (AccessibleListener) accessibleListeners.elementAt(i);
- listener.getHelp(event);
- }
- if (event.result == null) return code;
- char[] data = (event.result + "\0").toCharArray();
- int ptr = COM.SysAllocString(data);
- COM.MoveMemory(pszHelp, new int[] { ptr }, 4);
- return COM.S_OK;
- }
-
- int get_accHelpTopic(int pszHelpFile, int varChild_vt, int varChild_reserved1, int varChild_lVal, int varChild_reserved2, int pidTopic) {
- if (iaccessible == null) return COM.CO_E_OBJNOTCONNECTED;
- // Currently, we don't let the application override this. Forward to the proxy.
- int code = iaccessible.get_accHelpTopic(pszHelpFile, varChild_vt, varChild_reserved1, varChild_lVal, varChild_reserved2, pidTopic);
- if (code == COM.E_INVALIDARG) code = COM.S_FALSE; // proxy doesn't know about app childID
- return code;
- }
-
- int get_accKeyboardShortcut(int varChild_vt, int varChild_reserved1, int varChild_lVal, int varChild_reserved2, int pszKeyboardShortcut) {
- if (iaccessible == null) return COM.CO_E_OBJNOTCONNECTED;
- if ((varChild_vt & 0xFFFF) != COM.VT_I4) return COM.E_INVALIDARG;
-
- /* Get the default keyboard shortcut from the OS. */
- String osKeyboardShortcut = null;
- int code = iaccessible.get_accKeyboardShortcut(varChild_vt, varChild_reserved1, varChild_lVal, varChild_reserved2, pszKeyboardShortcut);
- if (code == COM.E_INVALIDARG) code = COM.S_FALSE; // proxy doesn't know about app childID
- if (accessibleListeners.size() == 0) return code;
- if (code == COM.S_OK) {
- int[] pKeyboardShortcut = new int[1];
- COM.MoveMemory(pKeyboardShortcut, pszKeyboardShortcut, 4);
- int size = COM.SysStringByteLen(pKeyboardShortcut[0]);
- if (size > 0) {
- char[] buffer = new char[(size + 1) /2];
- COM.MoveMemory(buffer, pKeyboardShortcut[0], size);
- osKeyboardShortcut = new String(buffer);
- }
- }
-
- AccessibleEvent event = new AccessibleEvent(this);
- if (varChild_lVal == COM.CHILDID_SELF) event.childID = ACC.CHILDID_SELF;
- else if (control instanceof Tree) event.childID = varChild_lVal; // Tree item childIDs are pointers
- else event.childID = varChild_lVal - 1; // All other childIDs are 1-based indices
- event.result = osKeyboardShortcut;
- for (int i = 0; i < accessibleListeners.size(); i++) {
- AccessibleListener listener = (AccessibleListener) accessibleListeners.elementAt(i);
- listener.getKeyboardShortcut(event);
- }
- if (event.result == null) return code;
- char[] data = (event.result + "\0").toCharArray();
- int ptr = COM.SysAllocString(data);
- COM.MoveMemory(pszKeyboardShortcut, new int[] { ptr }, 4);
- return COM.S_OK;
- }
-
- int get_accName(int varChild_vt, int varChild_reserved1, int varChild_lVal, int varChild_reserved2, int pszName) {
- if (iaccessible == null) return COM.CO_E_OBJNOTCONNECTED;
- if ((varChild_vt & 0xFFFF) != COM.VT_I4) return COM.E_INVALIDARG;
-
- /* Get the default name from the OS. */
- String osName = null;
- int code = iaccessible.get_accName(varChild_vt, varChild_reserved1, varChild_lVal, varChild_reserved2, pszName);
- if (code == COM.E_INVALIDARG) code = COM.S_FALSE; // proxy doesn't know about app childID
- if (accessibleListeners.size() == 0) return code;
- if (code == COM.S_OK) {
- int[] pName = new int[1];
- COM.MoveMemory(pName, pszName, 4);
- int size = COM.SysStringByteLen(pName[0]);
- if (size > 0) {
- char[] buffer = new char[(size + 1) /2];
- COM.MoveMemory(buffer, pName[0], size);
- osName = new String(buffer);
- }
- }
-
- AccessibleEvent event = new AccessibleEvent(this);
- if (varChild_lVal == COM.CHILDID_SELF) event.childID = ACC.CHILDID_SELF;
- else if (control instanceof Tree) event.childID = varChild_lVal; // Tree item childIDs are pointers
- else event.childID = varChild_lVal - 1; // All other childIDs are 1-based indices
- event.result = osName;
- for (int i = 0; i < accessibleListeners.size(); i++) {
- AccessibleListener listener = (AccessibleListener) accessibleListeners.elementAt(i);
- listener.getName(event);
- }
- if (event.result == null) return code;
- char[] data = (event.result + "\0").toCharArray();
- int ptr = COM.SysAllocString(data);
- COM.MoveMemory(pszName, new int[] { ptr }, 4);
- return COM.S_OK;
- }
-
- int get_accParent(int ppdispParent) {
- if (iaccessible == null) return COM.CO_E_OBJNOTCONNECTED;
- // Currently, we don't let the application override this. Forward to the proxy.
- return iaccessible.get_accParent(ppdispParent);
- }
-
- int get_accRole(int varChild_vt, int varChild_reserved1, int varChild_lVal, int varChild_reserved2, int pvarRole) {
- if (iaccessible == null) return COM.CO_E_OBJNOTCONNECTED;
- if ((varChild_vt & 0xFFFF) != COM.VT_I4) return COM.E_INVALIDARG;
-
- /* Get the default role from the OS. */
- int osRole = COM.ROLE_SYSTEM_CLIENT;
- int code = iaccessible.get_accRole(varChild_vt, varChild_reserved1, varChild_lVal, varChild_reserved2, pvarRole);
- if (code == COM.E_INVALIDARG) code = COM.S_FALSE; // proxy doesn't know about app childID
- // TEMPORARY CODE - process tree and table even if there are no apps listening
- if (accessibleControlListeners.size() == 0 && !(control instanceof Tree || control instanceof Table)) return code;
- if (code == COM.S_OK) {
- short[] pvt = new short[1];
- COM.MoveMemory(pvt, pvarRole, 2);
- if (pvt[0] == COM.VT_I4) {
- int[] pRole = new int[1];
- COM.MoveMemory(pRole, pvarRole + 8, 4);
- osRole = pRole[0];
- }
- }
-
- AccessibleControlEvent event = new AccessibleControlEvent(this);
- event.detail = osToRole(osRole);
- if (varChild_lVal == COM.CHILDID_SELF) {
- event.childID = ACC.CHILDID_SELF;
- } else {
- if (control instanceof Tree) {
- /* Tree item childIDs are pointers (not 1-based indices). */
- event.childID = varChild_lVal;
-
- // TEMPORARY CODE
- /* Currently our checkbox tree is emulated using state mask images,
- * so we need to specify 'checkbox' role for the items here. */
- if ((control.getStyle() & SWT.CHECK) != 0) event.detail = ACC.ROLE_CHECKBUTTON;
- } else if (control instanceof Table) {
- event.childID = varChild_lVal - 1;
-
- // TEMPORARY CODE
- /* Currently our checkbox table is emulated using state mask images,
- * so we need to specify 'checkbox' role for the items here. */
- if ((control.getStyle() & SWT.CHECK) != 0) event.detail = ACC.ROLE_CHECKBUTTON;
- } else {
- event.childID = varChild_lVal - 1;
- }
- }
- for (int i = 0; i < accessibleControlListeners.size(); i++) {
- AccessibleControlListener listener = (AccessibleControlListener) accessibleControlListeners.elementAt(i);
- listener.getRole(event);
- }
- int role = roleToOs(event.detail);
- COM.MoveMemory(pvarRole, new short[] { COM.VT_I4 }, 2);
- COM.MoveMemory(pvarRole + 8, new int[] { role }, 4);
- return COM.S_OK;
- }
-
- int get_accSelection(int pvarChildren) {
- if (iaccessible == null) return COM.CO_E_OBJNOTCONNECTED;
-
- /* Get the default selection from the OS. */
- int osChild = ACC.CHILDID_NONE;
- int code = iaccessible.get_accSelection(pvarChildren);
- if (accessibleControlListeners.size() == 0) return code;
- if (code == COM.S_OK) {
- short[] pvt = new short[1];
- COM.MoveMemory(pvt, pvarChildren, 2);
- if (pvt[0] == COM.VT_I4) {
- int[] pChild = new int[1];
- COM.MoveMemory(pChild, pvarChildren + 8, 4);
- osChild = (pChild[0] == COM.CHILDID_SELF) ? ACC.CHILDID_SELF : pChild[0] - 1;
- } else if (pvt[0] == COM.VT_UNKNOWN) {
- osChild = ACC.CHILDID_MULTIPLE;
- /* Should get IEnumVARIANT from punkVal field... need better API here... */
- }
- }
-
- AccessibleControlEvent event = new AccessibleControlEvent(this);
- event.childID = osChild;
- for (int i = 0; i < accessibleControlListeners.size(); i++) {
- AccessibleControlListener listener = (AccessibleControlListener) accessibleControlListeners.elementAt(i);
- listener.getSelection(event);
- }
- Accessible accessible = event.accessible;
- if (accessible != null) {
- COM.MoveMemory(pvarChildren, new short[] { COM.VT_DISPATCH }, 2);
- COM.MoveMemory(pvarChildren + 8, new int[] { accessible.objIAccessible.getAddress() }, 4);
- return COM.S_OK;
- }
- int childID = event.childID;
- if (childID == ACC.CHILDID_NONE) {
- COM.MoveMemory(pvarChildren, new short[] { COM.VT_EMPTY }, 2);
- return COM.S_FALSE;
- }
- if (childID == ACC.CHILDID_MULTIPLE) {
- COM.MoveMemory(pvarChildren, new short[] { COM.VT_UNKNOWN }, 2);
- /* Should return an IEnumVARIANT for this... so the next line is wrong... need better API here... */
- COM.MoveMemory(pvarChildren + 8, new int[] { objIAccessible.getAddress() }, 4);
- return COM.S_OK;
- }
- if (childID == ACC.CHILDID_SELF) {
- COM.MoveMemory(pvarChildren, new short[] { COM.VT_DISPATCH }, 2);
- COM.MoveMemory(pvarChildren + 8, new int[] { objIAccessible.getAddress() }, 4);
- return COM.S_OK;
- }
- COM.MoveMemory(pvarChildren, new short[] { COM.VT_I4 }, 2);
- COM.MoveMemory(pvarChildren + 8, new int[] { childID + 1 }, 4);
- return COM.S_OK;
- }
-
- int get_accState(int varChild_vt, int varChild_reserved1, int varChild_lVal, int varChild_reserved2, int pvarState) {
- if (iaccessible == null) return COM.CO_E_OBJNOTCONNECTED;
- if ((varChild_vt & 0xFFFF) != COM.VT_I4) return COM.E_INVALIDARG;
-
- /* Get the default state from the OS. */
- int osState = 0;
- int code = iaccessible.get_accState(varChild_vt, varChild_reserved1, varChild_lVal, varChild_reserved2, pvarState);
- if (code == COM.E_INVALIDARG) code = COM.S_FALSE; // proxy doesn't know about app childID
- // TEMPORARY CODE - process tree and table even if there are no apps listening
- if (accessibleControlListeners.size() == 0 && !(control instanceof Tree || control instanceof Table)) return code;
- if (code == COM.S_OK) {
- short[] pvt = new short[1];
- COM.MoveMemory(pvt, pvarState, 2);
- if (pvt[0] == COM.VT_I4) {
- int[] pState = new int[1];
- COM.MoveMemory(pState, pvarState + 8, 4);
- osState = pState[0];
- }
- }
-
- AccessibleControlEvent event = new AccessibleControlEvent(this);
- event.detail = osToState(osState);
- if (varChild_lVal == COM.CHILDID_SELF) {
- event.childID = ACC.CHILDID_SELF;
- } else {
- if (control instanceof Tree) {
- /* Tree item childIDs are pointers (not 1-based indices). */
- event.childID = varChild_lVal;
-
- // TEMPORARY CODE
- /* Currently our checkbox tree is emulated using state mask images,
- * so we need to determine if the item is 'checked' here. */
- int hwnd = control.handle;
- TVITEM tvItem = new TVITEM ();
- tvItem.mask = OS.TVIF_HANDLE | OS.TVIF_STATE;
- tvItem.hItem = varChild_lVal;
- tvItem.stateMask = OS.TVIS_STATEIMAGEMASK;
- int result = OS.SendMessage (hwnd, OS.TVM_GETITEM, 0, tvItem);
- boolean checked = (result != 0) && (((tvItem.state >> 12) & 1) == 0);
- if (checked) event.detail |= ACC.STATE_CHECKED;
- } else if (control instanceof Table) {
- event.childID = varChild_lVal - 1;
-
- // TEMPORARY CODE
- /* Currently our checkbox table is emulated using state mask images,
- * so we need to determine if the item is 'checked' here. */
- Table table = (Table) control;
- TableItem item = table.getItem(event.childID);
- if (item != null) {
- if (item.getChecked()) event.detail |= ACC.STATE_CHECKED;
- }
- } else {
- event.childID = varChild_lVal - 1;
- }
- }
- for (int i = 0; i < accessibleControlListeners.size(); i++) {
- AccessibleControlListener listener = (AccessibleControlListener) accessibleControlListeners.elementAt(i);
- listener.getState(event);
- }
- int state = stateToOs(event.detail);
- COM.MoveMemory(pvarState, new short[] { COM.VT_I4 }, 2);
- COM.MoveMemory(pvarState + 8, new int[] { state }, 4);
- return COM.S_OK;
- }
-
- int get_accValue(int varChild_vt, int varChild_reserved1, int varChild_lVal, int varChild_reserved2, int pszValue) {
- if (iaccessible == null) return COM.CO_E_OBJNOTCONNECTED;
- if ((varChild_vt & 0xFFFF) != COM.VT_I4) return COM.E_INVALIDARG;
-
- /* Get the default value string from the OS. */
- String osValue = null;
- int code = iaccessible.get_accValue(varChild_vt, varChild_reserved1, varChild_lVal, varChild_reserved2, pszValue);
- if (code == COM.E_INVALIDARG) code = COM.S_FALSE; // proxy doesn't know about app childID
- if (accessibleControlListeners.size() == 0) return code;
- if (code == COM.S_OK) {
- int[] pValue = new int[1];
- COM.MoveMemory(pValue, pszValue, 4);
- int size = COM.SysStringByteLen(pValue[0]);
- if (size > 0) {
- char[] buffer = new char[(size + 1) /2];
- COM.MoveMemory(buffer, pValue[0], size);
- osValue = new String(buffer);
- }
- }
-
- AccessibleControlEvent event = new AccessibleControlEvent(this);
- if (varChild_lVal == COM.CHILDID_SELF) event.childID = ACC.CHILDID_SELF;
- else if (control instanceof Tree) event.childID = varChild_lVal; // Tree item childIDs are pointers
- else event.childID = varChild_lVal - 1; // All other childIDs are 1-based indices
- event.result = osValue;
- for (int i = 0; i < accessibleControlListeners.size(); i++) {
- AccessibleControlListener listener = (AccessibleControlListener) accessibleControlListeners.elementAt(i);
- listener.getValue(event);
- }
- if (event.result == null) return code;
- char[] data = (event.result + "\0").toCharArray();
- int ptr = COM.SysAllocString(data);
- COM.MoveMemory(pszValue, new int[] { ptr }, 4);
- return COM.S_OK;
- }
-
- int put_accName(int varChild_vt, int varChild_reserved1, int varChild_lVal, int varChild_reserved2, int szName) {
- // MSAA: this method is no longer supported
- if (iaccessible == null) return COM.CO_E_OBJNOTCONNECTED;
- // We don't implement this. Forward to the proxy.
- int code = iaccessible.put_accName(varChild_vt, varChild_reserved1, varChild_lVal, varChild_reserved2, szName);
- if (code == COM.E_INVALIDARG) code = COM.S_FALSE; // proxy doesn't know about app childID
- return code;
- }
-
- int put_accValue(int varChild_vt, int varChild_reserved1, int varChild_lVal, int varChild_reserved2, int szValue) {
- // MSAA: this method is typically only used for edit controls
- if (iaccessible == null) return COM.CO_E_OBJNOTCONNECTED;
- // We don't implement this. Forward to the proxy.
- int code = iaccessible.put_accValue(varChild_vt, varChild_reserved1, varChild_lVal, varChild_reserved2, szValue);
- if (code == COM.E_INVALIDARG) code = COM.S_FALSE; // proxy doesn't know about app childID
- return code;
- }
-
- /* IEnumVARIANT methods: Next, Skip, Reset */
- /* Retrieve the next celt items in the enumeration sequence.
- * If there are fewer than the requested number of elements left
- * in the sequence, retrieve the remaining elements.
- * The number of elements actually retrieved is returned in pceltFetched
- * (unless the caller passed in NULL for that parameter).
- */
- int Next(int celt, int rgvar, int pceltFetched) {
- /* If there are no listeners, query the proxy for
- * its IEnumVariant, and get the Next items from it.
- */
- if (accessibleControlListeners.size() == 0) {
- int[] ppvObject = new int[1];
- int code = iaccessible.QueryInterface(COM.IIDIEnumVARIANT, ppvObject);
- if (code != COM.S_OK) return code;
- IEnumVARIANT ienumvariant = new IEnumVARIANT(ppvObject[0]);
- int[] celtFetched = new int[1];
- code = ienumvariant.Next(celt, rgvar, celtFetched);
- COM.MoveMemory(pceltFetched, celtFetched, 4);
- return code;
- }
-
- if (rgvar == 0) return COM.E_INVALIDARG;
- if (pceltFetched == 0 && celt != 1) return COM.E_INVALIDARG;
- if (enumIndex == 0) {
- AccessibleControlEvent event = new AccessibleControlEvent(this);
- event.childID = ACC.CHILDID_SELF;
- for (int i = 0; i < accessibleControlListeners.size(); i++) {
- AccessibleControlListener listener = (AccessibleControlListener) accessibleControlListeners.elementAt(i);
- listener.getChildren(event);
- }
- variants = event.children;
- }
- Object[] nextItems = null;
- if (variants != null && celt >= 1) {
- int endIndex = enumIndex + celt - 1;
- if (endIndex > (variants.length - 1)) endIndex = variants.length - 1;
- if (enumIndex <= endIndex) {
- nextItems = new Object[endIndex - enumIndex + 1];
- for (int i = 0; i < nextItems.length; i++) {
- Object child = variants[enumIndex];
- if (child instanceof Integer) {
- nextItems[i] = new Integer(((Integer)child).intValue() + 1);
- } else {
- nextItems[i] = child;
- }
- enumIndex++;
- }
- }
- }
- if (nextItems != null) {
- for (int i = 0; i < nextItems.length; i++) {
- Object nextItem = nextItems[i];
- if (nextItem instanceof Integer) {
- int item = ((Integer) nextItem).intValue();
- COM.MoveMemory(rgvar + i * 16, new short[] { COM.VT_I4 }, 2);
- COM.MoveMemory(rgvar + i * 16 + 8, new int[] { item }, 4);
- } else {
- int address = ((Accessible) nextItem).objIAccessible.getAddress();
- COM.MoveMemory(rgvar + i * 16, new short[] { COM.VT_DISPATCH }, 2);
- COM.MoveMemory(rgvar + i * 16 + 8, new int[] { address }, 4);
- }
- }
- 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);
- }
- return COM.S_FALSE;
- }
-
- /* Skip over the specified number of elements in the enumeration sequence. */
- int Skip(int celt) {
- /* If there are no listeners, query the proxy
- * for its IEnumVariant, and tell it to Skip.
- */
- if (accessibleControlListeners.size() == 0) {
- int[] ppvObject = new int[1];
- int code = iaccessible.QueryInterface(COM.IIDIEnumVARIANT, ppvObject);
- if (code != COM.S_OK) return code;
- IEnumVARIANT ienumvariant = new IEnumVARIANT(ppvObject[0]);
- code = ienumvariant.Skip(celt);
- return code;
- }
-
- if (celt < 1 ) return COM.E_INVALIDARG;
- enumIndex += celt;
- if (enumIndex > (variants.length - 1)) {
- enumIndex = variants.length - 1;
- return COM.S_FALSE;
- }
- return COM.S_OK;
- }
-
- /* Reset the enumeration sequence to the beginning. */
- int Reset() {
- /* If there are no listeners, query the proxy
- * for its IEnumVariant, and tell it to Reset.
- */
- if (accessibleControlListeners.size() == 0) {
- int[] ppvObject = new int[1];
- int code = iaccessible.QueryInterface(COM.IIDIEnumVARIANT, ppvObject);
- if (code != COM.S_OK) return code;
- IEnumVARIANT ienumvariant = new IEnumVARIANT(ppvObject[0]);
- code = ienumvariant.Reset();
- return code;
- }
-
- enumIndex = 0;
- return COM.S_OK;
- }
-
- int stateToOs(int state) {
- int osState = 0;
- if ((state & ACC.STATE_SELECTED) != 0) osState |= COM.STATE_SYSTEM_SELECTED;
- if ((state & ACC.STATE_SELECTABLE) != 0) osState |= COM.STATE_SYSTEM_SELECTABLE;
- if ((state & ACC.STATE_MULTISELECTABLE) != 0) osState |= COM.STATE_SYSTEM_MULTISELECTABLE;
- if ((state & ACC.STATE_FOCUSED) != 0) osState |= COM.STATE_SYSTEM_FOCUSED;
- if ((state & ACC.STATE_FOCUSABLE) != 0) osState |= COM.STATE_SYSTEM_FOCUSABLE;
- if ((state & ACC.STATE_PRESSED) != 0) osState |= COM.STATE_SYSTEM_PRESSED;
- if ((state & ACC.STATE_CHECKED) != 0) osState |= COM.STATE_SYSTEM_CHECKED;
- if ((state & ACC.STATE_EXPANDED) != 0) osState |= COM.STATE_SYSTEM_EXPANDED;
- if ((state & ACC.STATE_COLLAPSED) != 0) osState |= COM.STATE_SYSTEM_COLLAPSED;
- if ((state & ACC.STATE_HOTTRACKED) != 0) osState |= COM.STATE_SYSTEM_HOTTRACKED;
- if ((state & ACC.STATE_BUSY) != 0) osState |= COM.STATE_SYSTEM_BUSY;
- if ((state & ACC.STATE_READONLY) != 0) osState |= COM.STATE_SYSTEM_READONLY;
- if ((state & ACC.STATE_INVISIBLE) != 0) osState |= COM.STATE_SYSTEM_INVISIBLE;
- if ((state & ACC.STATE_OFFSCREEN) != 0) osState |= COM.STATE_SYSTEM_OFFSCREEN;
- if ((state & ACC.STATE_SIZEABLE) != 0) osState |= COM.STATE_SYSTEM_SIZEABLE;
- return osState;
- }
-
- int osToState(int osState) {
- int state = ACC.STATE_NORMAL;
- if ((osState & COM.STATE_SYSTEM_SELECTED) != 0) state |= ACC.STATE_SELECTED;
- if ((osState & COM.STATE_SYSTEM_SELECTABLE) != 0) state |= ACC.STATE_SELECTABLE;
- if ((osState & COM.STATE_SYSTEM_MULTISELECTABLE) != 0) state |= ACC.STATE_MULTISELECTABLE;
- if ((osState & COM.STATE_SYSTEM_FOCUSED) != 0) state |= ACC.STATE_FOCUSED;
- if ((osState & COM.STATE_SYSTEM_FOCUSABLE) != 0) state |= ACC.STATE_FOCUSABLE;
- if ((osState & COM.STATE_SYSTEM_PRESSED) != 0) state |= ACC.STATE_PRESSED;
- if ((osState & COM.STATE_SYSTEM_CHECKED) != 0) state |= ACC.STATE_CHECKED;
- if ((osState & COM.STATE_SYSTEM_EXPANDED) != 0) state |= ACC.STATE_EXPANDED;
- if ((osState & COM.STATE_SYSTEM_COLLAPSED) != 0) state |= ACC.STATE_COLLAPSED;
- if ((osState & COM.STATE_SYSTEM_HOTTRACKED) != 0) state |= ACC.STATE_HOTTRACKED;
- if ((osState & COM.STATE_SYSTEM_BUSY) != 0) state |= ACC.STATE_BUSY;
- if ((osState & COM.STATE_SYSTEM_READONLY) != 0) state |= ACC.STATE_READONLY;
- if ((osState & COM.STATE_SYSTEM_INVISIBLE) != 0) state |= ACC.STATE_INVISIBLE;
- if ((osState & COM.STATE_SYSTEM_OFFSCREEN) != 0) state |= ACC.STATE_OFFSCREEN;
- if ((osState & COM.STATE_SYSTEM_SIZEABLE) != 0) state |= ACC.STATE_SIZEABLE;
- return state;
- }
-
- int roleToOs(int role) {
- switch (role) {
- case ACC.ROLE_CLIENT_AREA: return COM.ROLE_SYSTEM_CLIENT;
- case ACC.ROLE_WINDOW: return COM.ROLE_SYSTEM_WINDOW;
- case ACC.ROLE_MENUBAR: return COM.ROLE_SYSTEM_MENUBAR;
- case ACC.ROLE_MENU: return COM.ROLE_SYSTEM_MENUPOPUP;
- case ACC.ROLE_MENUITEM: return COM.ROLE_SYSTEM_MENUITEM;
- case ACC.ROLE_SEPARATOR: return COM.ROLE_SYSTEM_SEPARATOR;
- case ACC.ROLE_TOOLTIP: return COM.ROLE_SYSTEM_TOOLTIP;
- case ACC.ROLE_SCROLLBAR: return COM.ROLE_SYSTEM_SCROLLBAR;
- case ACC.ROLE_DIALOG: return COM.ROLE_SYSTEM_DIALOG;
- case ACC.ROLE_LABEL: return COM.ROLE_SYSTEM_STATICTEXT;
- case ACC.ROLE_PUSHBUTTON: return COM.ROLE_SYSTEM_PUSHBUTTON;
- case ACC.ROLE_CHECKBUTTON: return COM.ROLE_SYSTEM_CHECKBUTTON;
- case ACC.ROLE_RADIOBUTTON: return COM.ROLE_SYSTEM_RADIOBUTTON;
- case ACC.ROLE_COMBOBOX: return COM.ROLE_SYSTEM_COMBOBOX;
- case ACC.ROLE_TEXT: return COM.ROLE_SYSTEM_TEXT;
- case ACC.ROLE_TOOLBAR: return COM.ROLE_SYSTEM_TOOLBAR;
- case ACC.ROLE_LIST: return COM.ROLE_SYSTEM_LIST;
- case ACC.ROLE_LISTITEM: return COM.ROLE_SYSTEM_LISTITEM;
- case ACC.ROLE_TABLE: return COM.ROLE_SYSTEM_TABLE;
- case ACC.ROLE_TABLECOLUMN: return COM.ROLE_SYSTEM_COLUMNHEADER;
- case ACC.ROLE_TREE: return COM.ROLE_SYSTEM_OUTLINE;
- case ACC.ROLE_TABFOLDER: return COM.ROLE_SYSTEM_PAGETABLIST;
- case ACC.ROLE_TABITEM: return COM.ROLE_SYSTEM_PAGETAB;
- case ACC.ROLE_PROGRESSBAR: return COM.ROLE_SYSTEM_PROGRESSBAR;
- case ACC.ROLE_SLIDER: return COM.ROLE_SYSTEM_SLIDER;
- }
- return COM.ROLE_SYSTEM_CLIENT;
- }
-
- int osToRole(int osRole) {
- int role = COM.ROLE_SYSTEM_CLIENT;
- switch (osRole) {
- case COM.ROLE_SYSTEM_CLIENT: return ACC.ROLE_CLIENT_AREA;
- case COM.ROLE_SYSTEM_WINDOW: return ACC.ROLE_WINDOW;
- case COM.ROLE_SYSTEM_MENUBAR: return ACC.ROLE_MENUBAR;
- case COM.ROLE_SYSTEM_MENUPOPUP: return ACC.ROLE_MENU;
- case COM.ROLE_SYSTEM_MENUITEM: return ACC.ROLE_MENUITEM;
- case COM.ROLE_SYSTEM_SEPARATOR: return ACC.ROLE_SEPARATOR;
- case COM.ROLE_SYSTEM_TOOLTIP: return ACC.ROLE_TOOLTIP;
- case COM.ROLE_SYSTEM_SCROLLBAR: return ACC.ROLE_SCROLLBAR;
- case COM.ROLE_SYSTEM_DIALOG: return ACC.ROLE_DIALOG;
- case COM.ROLE_SYSTEM_STATICTEXT: return ACC.ROLE_LABEL;
- case COM.ROLE_SYSTEM_PUSHBUTTON: return ACC.ROLE_PUSHBUTTON;
- case COM.ROLE_SYSTEM_CHECKBUTTON: return ACC.ROLE_CHECKBUTTON;
- case COM.ROLE_SYSTEM_RADIOBUTTON: return ACC.ROLE_RADIOBUTTON;
- case COM.ROLE_SYSTEM_COMBOBOX: return ACC.ROLE_COMBOBOX;
- case COM.ROLE_SYSTEM_TEXT: return ACC.ROLE_TEXT;
- case COM.ROLE_SYSTEM_TOOLBAR: return ACC.ROLE_TOOLBAR;
- case COM.ROLE_SYSTEM_LIST: return ACC.ROLE_LIST;
- case COM.ROLE_SYSTEM_LISTITEM: return ACC.ROLE_LISTITEM;
- case COM.ROLE_SYSTEM_TABLE: return ACC.ROLE_TABLE;
- case COM.ROLE_SYSTEM_COLUMNHEADER: return ACC.ROLE_TABLECOLUMN;
- case COM.ROLE_SYSTEM_OUTLINE: return ACC.ROLE_TREE;
- case COM.ROLE_SYSTEM_PAGETABLIST: return ACC.ROLE_TABFOLDER;
- case COM.ROLE_SYSTEM_PAGETAB: return ACC.ROLE_TABITEM;
- case COM.ROLE_SYSTEM_PROGRESSBAR: return ACC.ROLE_PROGRESSBAR;
- case COM.ROLE_SYSTEM_SLIDER: return ACC.ROLE_SLIDER;
- }
- return role;
- }
-
- /* checkWidget was copied from Widget, and rewritten to work in this package */
- void checkWidget () {
- if (!isValidThread ()) SWT.error (SWT.ERROR_THREAD_INVALID_ACCESS);
- if (control.isDisposed ()) SWT.error (SWT.ERROR_WIDGET_DISPOSED);
- }
-
- /* isValidThread was copied from Widget, and rewritten to work in this package */
- boolean isValidThread () {
- return control.getDisplay ().getThread () == Thread.currentThread ();
- }
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+import java.util.Vector;
+import org.eclipse.swt.*;
+import org.eclipse.swt.widgets.*;
+import org.eclipse.swt.internal.win32.*;
+import org.eclipse.swt.ole.win32.*;
+import org.eclipse.swt.internal.ole.win32.*;
+
+/**
+ * Instances of this class provide a bridge between application
+ * code and assistive technology clients. Many platforms provide
+ * default accessible behavior for most widgets, and this class
+ * allows that default behavior to be overridden. Applications
+ * can get the default Accessible object for a control by sending
+ * it <code>getAccessible</code>, and then add an accessible listener
+ * to override simple items like the name and help string, or they
+ * can add an accessible control listener to override complex items.
+ * As a rule of thumb, an application would only want to use the
+ * accessible control listener to implement accessibility for a
+ * custom control.
+ *
+ * @see Control#getAccessible
+ * @see AccessibleListener
+ * @see AccessibleEvent
+ * @see AccessibleControlListener
+ * @see AccessibleControlEvent
+ *
+ * @since 2.0
+ */
+public class Accessible {
+ int refCount = 0, enumIndex = 0;
+ COMObject objIAccessible, objIEnumVARIANT;
+ IAccessible iaccessible;
+ Vector accessibleListeners = new Vector(), accessibleControlListeners = new Vector();
+ Object[] variants;
+ Control control;
+
+ Accessible(Control control) {
+ this.control = control;
+ int[] ppvObject = new int[1];
+ int result = COM.CreateStdAccessibleObject(control.handle, COM.OBJID_CLIENT, COM.IIDIAccessible, ppvObject);
+ if (result == COM.E_NOTIMPL) return;
+ if (result != COM.S_OK) OLE.error(OLE.ERROR_CANNOT_CREATE_OBJECT, result);
+ iaccessible = new IAccessible(ppvObject[0]);
+ iaccessible.AddRef();
+
+ objIAccessible = new COMObject(new int[] {2,0,0,1,3,5,8,1,1,5,5,5,5,5,5,5,6,5,1,1,5,5,8,6,3,4,5,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();}
+ // method3 GetTypeInfoCount - not implemented
+ // method4 GetTypeInfo - not implemented
+ // method5 GetIDsOfNames - not implemented
+ // method6 Invoke - not implemented
+ public int method7(int[] args) {return get_accParent(args[0]);}
+ public int method8(int[] args) {return get_accChildCount(args[0]);}
+ public int method9(int[] args) {return get_accChild(args[0], args[1], args[2], args[3], args[4]);}
+ public int method10(int[] args) {return get_accName(args[0], args[1], args[2], args[3], args[4]);}
+ public int method11(int[] args) {return get_accValue(args[0], args[1], args[2], args[3], args[4]);}
+ public int method12(int[] args) {return get_accDescription(args[0], args[1], args[2], args[3], args[4]);}
+ public int method13(int[] args) {return get_accRole(args[0], args[1], args[2], args[3], args[4]);}
+ public int method14(int[] args) {return get_accState(args[0], args[1], args[2], args[3], args[4]);}
+ public int method15(int[] args) {return get_accHelp(args[0], args[1], args[2], args[3], args[4]);}
+ public int method16(int[] args) {return get_accHelpTopic(args[0], args[1], args[2], args[3], args[4], args[5]);}
+ public int method17(int[] args) {return get_accKeyboardShortcut(args[0], args[1], args[2], args[3], args[4]);}
+ public int method18(int[] args) {return get_accFocus(args[0]);}
+ public int method19(int[] args) {return get_accSelection(args[0]);}
+ public int method20(int[] args) {return get_accDefaultAction(args[0], args[1], args[2], args[3], args[4]);}
+ public int method21(int[] args) {return accSelect(args[0], args[1], args[2], args[3], args[4]);}
+ public int method22(int[] args) {return accLocation(args[0], args[1], args[2], args[3], args[4], args[5], args[6], args[7]);}
+ public int method23(int[] args) {return accNavigate(args[0], args[1], args[2], args[3], args[4], args[5]);}
+ public int method24(int[] args) {return accHitTest(args[0], args[1], args[2]);}
+ public int method25(int[] args) {return accDoDefaultAction(args[0], args[1], args[2], args[3]);}
+ public int method26(int[] args) {return put_accName(args[0], args[1], args[2], args[3], args[4]);}
+ public int method27(int[] args) {return put_accValue(args[0], args[1], args[2], args[3], args[4]);}
+ };
+
+ objIEnumVARIANT = 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
+ };
+ AddRef();
+ }
+
+ /**
+ * Invokes platform specific functionality to allocate a new accessible object.
+ * <p>
+ * <b>IMPORTANT:</b> This method is <em>not</em> part of the public
+ * API for <code>Accessible</code>. It is marked public only so that it
+ * can be shared within the packages provided by SWT. It is not
+ * available on all platforms, and should never be called from
+ * application code.
+ * </p>
+ *
+ * @param control the control to get the accessible object for
+ * @return the platform specific accessible object
+ *
+ * @private
+ */
+ public static Accessible internal_new_Accessible(Control control) {
+ return new Accessible(control);
+ }
+
+ /**
+ * Adds the listener to the collection of listeners who will
+ * be notifed when an accessible client asks for certain strings,
+ * such as name, description, help, or keyboard shortcut. The
+ * listener is notified by sending it one of the messages defined
+ * in the <code>AccessibleListener</code> interface.
+ *
+ * @param listener the listener that should be notified when the receiver
+ * is asked for a name, description, help, or keyboard shortcut string
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver's control has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver's control</li>
+ * </ul>
+ *
+ * @see AccessibleListener
+ * @see #removeAccessibleListener
+ */
+ public void addAccessibleListener(AccessibleListener listener) {
+ checkWidget();
+ if (listener == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ accessibleListeners.addElement(listener);
+ }
+
+ /**
+ * Removes the listener from the collection of listeners who will
+ * be notifed when an accessible client asks for certain strings,
+ * such as name, description, help, or keyboard shortcut.
+ *
+ * @param listener the listener that should no longer be notified when the receiver
+ * is asked for a name, description, help, or keyboard shortcut string
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver's control has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver's control</li>
+ * </ul>
+ *
+ * @see AccessibleListener
+ * @see #addDisposeListener
+ */
+ public void removeAccessibleListener(AccessibleListener listener) {
+ checkWidget();
+ if (listener == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ accessibleListeners.removeElement(listener);
+ }
+
+ /**
+ * Adds the listener to the collection of listeners who will
+ * be notifed when an accessible client asks for custom control
+ * specific information. The listener is notified by sending it
+ * one of the messages defined in the <code>AccessibleControlListener</code>
+ * interface.
+ *
+ * @param listener the listener that should be notified when the receiver
+ * is asked for custom control specific information
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver's control has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver's control</li>
+ * </ul>
+ *
+ * @see AccessibleControlListener
+ * @see #removeAccessibleControlListener
+ */
+ public void addAccessibleControlListener(AccessibleControlListener listener) {
+ checkWidget();
+ if (listener == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ accessibleControlListeners.addElement(listener);
+ }
+
+ /**
+ * Removes the listener from the collection of listeners who will
+ * be notifed when an accessible client asks for custom control
+ * specific information.
+ *
+ * @param listener the listener that should no longer be notified when the receiver
+ * is asked for custom control specific information
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver's control has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver's control</li>
+ * </ul>
+ *
+ * @see AccessibleControlListener
+ * @see #addAccessibleControlListener
+ */
+ public void removeAccessibleControlListener(AccessibleControlListener listener) {
+ checkWidget();
+ if (listener == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ accessibleControlListeners.removeElement(listener);
+ }
+
+ /**
+ * Sends a message to accessible clients indicating that the focus
+ * has changed within a custom control.
+ *
+ * @param childID an identifier specifying a child of the control
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver's control has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver's control</li>
+ * </ul>
+ */
+ public void setFocus(int childID) {
+ checkWidget();
+ int id;
+ if (childID == ACC.CHILDID_SELF) id = COM.CHILDID_SELF;
+ else if (control instanceof Tree) id = childID; // Tree item childIDs are pointers
+ else id = childID + 1; // All other childIDs are 1-based indices
+ COM.NotifyWinEvent (COM.EVENT_OBJECT_FOCUS, control.handle, COM.OBJID_CLIENT, id);
+ }
+
+ /**
+ * Invokes platform specific functionality to dispose an accessible object.
+ * <p>
+ * <b>IMPORTANT:</b> This method is <em>not</em> part of the public
+ * API for <code>Accessible</code>. It is marked public only so that it
+ * can be shared within the packages provided by SWT. It is not
+ * available on all platforms, and should never be called from
+ * application code.
+ * </p>
+ *
+ * @private
+ */
+ public void internal_dispose_Accessible() {
+ if (iaccessible != null)
+ iaccessible.Release();
+ iaccessible = null;
+ Release();
+ }
+
+ /**
+ * Invokes platform specific functionality to handle a window message.
+ * <p>
+ * <b>IMPORTANT:</b> This method is <em>not</em> part of the public
+ * API for <code>Accessible</code>. It is marked public only so that it
+ * can be shared within the packages provided by SWT. It is not
+ * available on all platforms, and should never be called from
+ * application code.
+ * </p>
+ *
+ * @private
+ */
+ public int internal_WM_GETOBJECT (int wParam, int lParam) {
+ if (objIAccessible == null) return 0;
+ if (lParam == COM.OBJID_CLIENT) {
+ return COM.LresultFromObject(COM.IIDIAccessible, wParam, objIAccessible.getAddress());
+ }
+ return 0;
+ }
+
+ int QueryInterface(int arg1, int arg2) {
+ if (iaccessible == null) return COM.CO_E_OBJNOTCONNECTED;
+ GUID guid = new GUID();
+ COM.MoveMemory(guid, arg1, GUID.sizeof);
+
+ if (COM.IsEqualGUID(guid, COM.IIDIUnknown)) {
+ COM.MoveMemory(arg2, new int[] { objIAccessible.getAddress()}, 4);
+ AddRef();
+ return COM.S_OK;
+ }
+
+ if (COM.IsEqualGUID(guid, COM.IIDIDispatch)) {
+ COM.MoveMemory(arg2, new int[] { objIAccessible.getAddress()}, 4);
+ AddRef();
+ return COM.S_OK;
+ }
+
+ if (COM.IsEqualGUID(guid, COM.IIDIAccessible)) {
+ COM.MoveMemory(arg2, new int[] { objIAccessible.getAddress()}, 4);
+ AddRef();
+ return COM.S_OK;
+ }
+
+ if (COM.IsEqualGUID(guid, COM.IIDIEnumVARIANT)) {
+ COM.MoveMemory(arg2, new int[] { objIEnumVARIANT.getAddress()}, 4);
+ AddRef();
+ enumIndex = 0;
+ return COM.S_OK;
+ }
+
+ int[] ppvObject = new int[1];
+ int result = iaccessible.QueryInterface(guid, ppvObject);
+ COM.MoveMemory(arg2, ppvObject, 4);
+ return result;
+ }
+
+ int AddRef() {
+ refCount++;
+ return refCount;
+ }
+
+ int Release() {
+ refCount--;
+
+ if (refCount == 0) {
+ if (objIAccessible != null)
+ objIAccessible.dispose();
+ objIAccessible = null;
+
+ if (objIEnumVARIANT != null)
+ objIEnumVARIANT.dispose();
+ objIEnumVARIANT = null;
+ }
+ return refCount;
+ }
+
+ int accDoDefaultAction(int varChild_vt, int varChild_reserved1, int varChild_lVal, int varChild_reserved2) {
+ if (iaccessible == null) return COM.CO_E_OBJNOTCONNECTED;
+ // Currently, we don't let the application override this. Forward to the proxy.
+ int code = iaccessible.accDoDefaultAction(varChild_vt, varChild_reserved1, varChild_lVal, varChild_reserved2);
+ if (code == COM.E_INVALIDARG) code = COM.S_FALSE; // proxy doesn't know about app childID
+ return code;
+ }
+
+ int accHitTest(int xLeft, int yTop, int pvarChild) {
+ if (iaccessible == null) return COM.CO_E_OBJNOTCONNECTED;
+ if (accessibleControlListeners.size() == 0) {
+ return iaccessible.accHitTest(xLeft, yTop, pvarChild);
+ }
+
+ AccessibleControlEvent event = new AccessibleControlEvent(this);
+ event.childID = ACC.CHILDID_NONE;
+ event.x = xLeft;
+ event.y = yTop;
+ for (int i = 0; i < accessibleControlListeners.size(); i++) {
+ AccessibleControlListener listener = (AccessibleControlListener) accessibleControlListeners.elementAt(i);
+ listener.getChildAtPoint(event);
+ }
+ int childID = event.childID;
+ if (childID == ACC.CHILDID_NONE) {
+ return iaccessible.accHitTest(xLeft, yTop, pvarChild);
+ }
+ if (childID == ACC.CHILDID_SELF) childID = COM.CHILDID_SELF;
+ else if (!(control instanceof Tree)) childID++; // Tree item childIDs are pointers (not 1-based indices)
+ COM.MoveMemory(pvarChild, new short[] { COM.VT_I4 }, 2);
+ COM.MoveMemory(pvarChild + 8, new int[] { childID }, 4);
+ return COM.S_OK;
+ }
+
+ int accLocation(int pxLeft, int pyTop, int pcxWidth, int pcyHeight, int varChild_vt, int varChild_reserved1, int varChild_lVal, int varChild_reserved2) {
+ if (iaccessible == null) return COM.CO_E_OBJNOTCONNECTED;
+ if ((varChild_vt & 0xFFFF) != COM.VT_I4) return COM.E_INVALIDARG;
+
+ /* Get the default location from the OS. */
+ int osLeft = 0, osTop = 0, osWidth = 0, osHeight = 0;
+ int code = iaccessible.accLocation(pxLeft, pyTop, pcxWidth, pcyHeight, varChild_vt, varChild_reserved1, varChild_lVal, varChild_reserved2);
+ if (code == COM.E_INVALIDARG) code = COM.S_FALSE; // proxy doesn't know about app childID
+ if (accessibleControlListeners.size() == 0) return code;
+ if (code == COM.S_OK) {
+ int[] pLeft = new int[1], pTop = new int[1], pWidth = new int[1], pHeight = new int[1];
+ COM.MoveMemory(pLeft, pxLeft, 4);
+ COM.MoveMemory(pTop, pyTop, 4);
+ COM.MoveMemory(pWidth, pcxWidth, 4);
+ COM.MoveMemory(pHeight, pcyHeight, 4);
+ osLeft = pLeft[0]; osTop = pTop[0]; osWidth = pWidth[0]; osHeight = pHeight[0];
+ }
+
+ AccessibleControlEvent event = new AccessibleControlEvent(this);
+ if (varChild_lVal == COM.CHILDID_SELF) event.childID = ACC.CHILDID_SELF;
+ else if (control instanceof Tree) event.childID = varChild_lVal; // Tree item childIDs are pointers
+ else event.childID = varChild_lVal - 1; // All other childIDs are 1-based indices
+ event.x = osLeft;
+ event.y = osTop;
+ event.width = osWidth;
+ event.height = osHeight;
+ for (int i = 0; i < accessibleControlListeners.size(); i++) {
+ AccessibleControlListener listener = (AccessibleControlListener) accessibleControlListeners.elementAt(i);
+ listener.getLocation(event);
+ }
+ OS.MoveMemory(pxLeft, new int[] { event.x }, 4);
+ OS.MoveMemory(pyTop, new int[] { event.y }, 4);
+ OS.MoveMemory(pcxWidth, new int[] { event.width }, 4);
+ OS.MoveMemory(pcyHeight, new int[] { event.height }, 4);
+ return COM.S_OK;
+ }
+
+ int accNavigate(int navDir, int varStart_vt, int varStart_reserved1, int varStart_lVal, int varStart_reserved2, int pvarEndUpAt) {
+ if (iaccessible == null) return COM.CO_E_OBJNOTCONNECTED;
+ // Currently, we don't let the application override this. Forward to the proxy.
+ int code = iaccessible.accNavigate(navDir, varStart_vt, varStart_reserved1, varStart_lVal, varStart_reserved2, pvarEndUpAt);
+ if (code == COM.E_INVALIDARG) code = COM.S_FALSE; // proxy doesn't know about app childID
+ return code;
+ }
+
+ int accSelect(int flagsSelect, int varChild_vt, int varChild_reserved1, int varChild_lVal, int varChild_reserved2) {
+ if (iaccessible == null) return COM.CO_E_OBJNOTCONNECTED;
+ // Currently, we don't let the application override this. Forward to the proxy.
+ int code = iaccessible.accSelect(flagsSelect, varChild_vt, varChild_reserved1, varChild_lVal, varChild_reserved2);
+ if (code == COM.E_INVALIDARG) code = COM.S_FALSE; // proxy doesn't know about app childID
+ return code;
+ }
+
+ int get_accChild(int varChild_vt, int varChild_reserved1, int varChild_lVal, int varChild_reserved2, int ppdispChild) {
+ if (iaccessible == null) return COM.CO_E_OBJNOTCONNECTED;
+ if ((varChild_vt & 0xFFFF) != COM.VT_I4) return COM.E_INVALIDARG;
+ if (accessibleControlListeners.size() == 0) {
+ int code = iaccessible.get_accChild(varChild_vt, varChild_reserved1, varChild_lVal, varChild_reserved2, ppdispChild);
+ if (code == COM.E_INVALIDARG) code = COM.S_FALSE; // proxy doesn't know about app childID
+ return code;
+ }
+
+ AccessibleControlEvent event = new AccessibleControlEvent(this);
+ if (varChild_lVal == COM.CHILDID_SELF) event.childID = ACC.CHILDID_SELF;
+ else if (control instanceof Tree) event.childID = varChild_lVal; // Tree item childIDs are pointers
+ else event.childID = varChild_lVal - 1; // All other childIDs are 1-based indices
+ for (int i = 0; i < accessibleControlListeners.size(); i++) {
+ AccessibleControlListener listener = (AccessibleControlListener) accessibleControlListeners.elementAt(i);
+ listener.getChild(event);
+ }
+ Accessible accessible = event.accessible;
+ if (accessible != null) {
+ COM.MoveMemory(ppdispChild, new int[] { accessible.objIAccessible.getAddress() }, 4);
+ return COM.S_OK;
+ }
+ return COM.S_FALSE;
+ }
+
+ int get_accChildCount(int pcountChildren) {
+ if (iaccessible == null) return COM.CO_E_OBJNOTCONNECTED;
+
+ /* Get the default child count from the OS. */
+ int osChildCount = 0;
+ int code = iaccessible.get_accChildCount(pcountChildren);
+ if (accessibleControlListeners.size() == 0) return code;
+ if (code == COM.S_OK) {
+ int[] pChildCount = new int[1];
+ COM.MoveMemory(pChildCount, pcountChildren, 4);
+ osChildCount = pChildCount[0];
+ }
+
+ AccessibleControlEvent event = new AccessibleControlEvent(this);
+ event.childID = ACC.CHILDID_SELF;
+ event.detail = osChildCount;
+ for (int i = 0; i < accessibleControlListeners.size(); i++) {
+ AccessibleControlListener listener = (AccessibleControlListener) accessibleControlListeners.elementAt(i);
+ listener.getChildCount(event);
+ }
+
+ COM.MoveMemory(pcountChildren, new int[] { event.detail }, 4);
+ return COM.S_OK;
+ }
+
+ int get_accDefaultAction(int varChild_vt, int varChild_reserved1, int varChild_lVal, int varChild_reserved2, int pszDefaultAction) {
+ if (iaccessible == null) return COM.CO_E_OBJNOTCONNECTED;
+ if ((varChild_vt & 0xFFFF) != COM.VT_I4) return COM.E_INVALIDARG;
+
+ /* Get the default defaultAction from the OS. */
+ String osDefaultAction = null;
+ int code = iaccessible.get_accDefaultAction(varChild_vt, varChild_reserved1, varChild_lVal, varChild_reserved2, pszDefaultAction);
+ if (code == COM.E_INVALIDARG) code = COM.S_FALSE; // proxy doesn't know about app childID
+ if (accessibleControlListeners.size() == 0) return code;
+ if (code == COM.S_OK) {
+ int[] pDefaultAction = new int[1];
+ COM.MoveMemory(pDefaultAction, pszDefaultAction, 4);
+ int size = COM.SysStringByteLen(pDefaultAction[0]);
+ if (size > 0) {
+ char[] buffer = new char[(size + 1) /2];
+ COM.MoveMemory(buffer, pDefaultAction[0], size);
+ osDefaultAction = new String(buffer);
+ }
+ }
+
+ AccessibleControlEvent event = new AccessibleControlEvent(this);
+ if (varChild_lVal == COM.CHILDID_SELF) event.childID = ACC.CHILDID_SELF;
+ else if (control instanceof Tree) event.childID = varChild_lVal; // Tree item childIDs are pointers
+ else event.childID = varChild_lVal - 1; // All other childIDs are 1-based indices
+ event.result = osDefaultAction;
+ for (int i = 0; i < accessibleControlListeners.size(); i++) {
+ AccessibleControlListener listener = (AccessibleControlListener) accessibleControlListeners.elementAt(i);
+ listener.getDefaultAction(event);
+ }
+ if (event.result == null) return code;
+ char[] data = (event.result + "\0").toCharArray();
+ int ptr = COM.SysAllocString(data);
+ COM.MoveMemory(pszDefaultAction, new int[] { ptr }, 4);
+ return COM.S_OK;
+ }
+
+ int get_accDescription(int varChild_vt, int varChild_reserved1, int varChild_lVal, int varChild_reserved2, int pszDescription) {
+ if (iaccessible == null) return COM.CO_E_OBJNOTCONNECTED;
+ if ((varChild_vt & 0xFFFF) != COM.VT_I4) return COM.E_INVALIDARG;
+
+ /* Get the default description from the OS. */
+ String osDescription = null;
+ int code = iaccessible.get_accDescription(varChild_vt, varChild_reserved1, varChild_lVal, varChild_reserved2, pszDescription);
+ if (code == COM.E_INVALIDARG) code = COM.S_FALSE; // proxy doesn't know about app childID
+ if (accessibleListeners.size() == 0) return code;
+ if (code == COM.S_OK) {
+ int[] pDescription = new int[1];
+ COM.MoveMemory(pDescription, pszDescription, 4);
+ int size = COM.SysStringByteLen(pDescription[0]);
+ if (size > 0) {
+ char[] buffer = new char[(size + 1) /2];
+ COM.MoveMemory(buffer, pDescription[0], size);
+ osDescription = new String(buffer);
+ }
+ }
+
+ AccessibleEvent event = new AccessibleEvent(this);
+ if (varChild_lVal == COM.CHILDID_SELF) event.childID = ACC.CHILDID_SELF;
+ else if (control instanceof Tree) event.childID = varChild_lVal; // Tree item childIDs are pointers
+ else event.childID = varChild_lVal - 1; // All other childIDs are 1-based indices
+ event.result = osDescription;
+ for (int i = 0; i < accessibleListeners.size(); i++) {
+ AccessibleListener listener = (AccessibleListener) accessibleListeners.elementAt(i);
+ listener.getDescription(event);
+ }
+ if (event.result == null) return code;
+ char[] data = (event.result + "\0").toCharArray();
+ int ptr = COM.SysAllocString(data);
+ COM.MoveMemory(pszDescription, new int[] { ptr }, 4);
+ return COM.S_OK;
+ }
+
+ int get_accFocus(int pvarChild) {
+ if (iaccessible == null) return COM.CO_E_OBJNOTCONNECTED;
+
+ /* Get the default focus child from the OS. */
+ int osChild = ACC.CHILDID_NONE;
+ int code = iaccessible.get_accFocus(pvarChild);
+ if (accessibleControlListeners.size() == 0) return code;
+ if (code == COM.S_OK) {
+ short[] pvt = new short[1];
+ COM.MoveMemory(pvt, pvarChild, 2);
+ if (pvt[0] == COM.VT_I4) {
+ int[] pChild = new int[1];
+ COM.MoveMemory(pChild, pvarChild + 8, 4);
+ osChild = (pChild[0] == COM.CHILDID_SELF) ? ACC.CHILDID_SELF : pChild[0] - 1;
+ }
+ }
+
+ AccessibleControlEvent event = new AccessibleControlEvent(this);
+ event.childID = osChild;
+ for (int i = 0; i < accessibleControlListeners.size(); i++) {
+ AccessibleControlListener listener = (AccessibleControlListener) accessibleControlListeners.elementAt(i);
+ listener.getFocus(event);
+ }
+ Accessible accessible = event.accessible;
+ if (accessible != null) {
+ COM.MoveMemory(pvarChild, new short[] { COM.VT_DISPATCH }, 2);
+ COM.MoveMemory(pvarChild + 8, new int[] { accessible.objIAccessible.getAddress() }, 4);
+ return COM.S_OK;
+ }
+ int childID = event.childID;
+ if (childID == ACC.CHILDID_NONE) {
+ COM.MoveMemory(pvarChild, new short[] { COM.VT_EMPTY }, 2);
+ return COM.S_FALSE;
+ }
+ if (childID == ACC.CHILDID_SELF) {
+ COM.MoveMemory(pvarChild, new short[] { COM.VT_DISPATCH }, 2);
+ COM.MoveMemory(pvarChild + 8, new int[] { objIAccessible.getAddress() }, 4);
+ return COM.S_OK;
+ }
+ COM.MoveMemory(pvarChild, new short[] { COM.VT_I4 }, 2);
+ COM.MoveMemory(pvarChild + 8, new int[] { childID + 1 }, 4);
+ return COM.S_OK;
+ }
+
+ int get_accHelp(int varChild_vt, int varChild_reserved1, int varChild_lVal, int varChild_reserved2, int pszHelp) {
+ if (iaccessible == null) return COM.CO_E_OBJNOTCONNECTED;
+ if ((varChild_vt & 0xFFFF) != COM.VT_I4) return COM.E_INVALIDARG;
+
+ /* Get the default help string from the OS. */
+ String osHelp = null;
+ int code = iaccessible.get_accHelp(varChild_vt, varChild_reserved1, varChild_lVal, varChild_reserved2, pszHelp);
+ if (code == COM.E_INVALIDARG) code = COM.S_FALSE; // proxy doesn't know about app childID
+ if (accessibleListeners.size() == 0) return code;
+ if (code == COM.S_OK) {
+ int[] pHelp = new int[1];
+ COM.MoveMemory(pHelp, pszHelp, 4);
+ int size = COM.SysStringByteLen(pHelp[0]);
+ if (size > 0) {
+ char[] buffer = new char[(size + 1) /2];
+ COM.MoveMemory(buffer, pHelp[0], size);
+ osHelp = new String(buffer);
+ }
+ }
+
+ AccessibleEvent event = new AccessibleEvent(this);
+ if (varChild_lVal == COM.CHILDID_SELF) event.childID = ACC.CHILDID_SELF;
+ else if (control instanceof Tree) event.childID = varChild_lVal; // Tree item childIDs are pointers
+ else event.childID = varChild_lVal - 1; // All other childIDs are 1-based indices
+ event.result = osHelp;
+ for (int i = 0; i < accessibleListeners.size(); i++) {
+ AccessibleListener listener = (AccessibleListener) accessibleListeners.elementAt(i);
+ listener.getHelp(event);
+ }
+ if (event.result == null) return code;
+ char[] data = (event.result + "\0").toCharArray();
+ int ptr = COM.SysAllocString(data);
+ COM.MoveMemory(pszHelp, new int[] { ptr }, 4);
+ return COM.S_OK;
+ }
+
+ int get_accHelpTopic(int pszHelpFile, int varChild_vt, int varChild_reserved1, int varChild_lVal, int varChild_reserved2, int pidTopic) {
+ if (iaccessible == null) return COM.CO_E_OBJNOTCONNECTED;
+ // Currently, we don't let the application override this. Forward to the proxy.
+ int code = iaccessible.get_accHelpTopic(pszHelpFile, varChild_vt, varChild_reserved1, varChild_lVal, varChild_reserved2, pidTopic);
+ if (code == COM.E_INVALIDARG) code = COM.S_FALSE; // proxy doesn't know about app childID
+ return code;
+ }
+
+ int get_accKeyboardShortcut(int varChild_vt, int varChild_reserved1, int varChild_lVal, int varChild_reserved2, int pszKeyboardShortcut) {
+ if (iaccessible == null) return COM.CO_E_OBJNOTCONNECTED;
+ if ((varChild_vt & 0xFFFF) != COM.VT_I4) return COM.E_INVALIDARG;
+
+ /* Get the default keyboard shortcut from the OS. */
+ String osKeyboardShortcut = null;
+ int code = iaccessible.get_accKeyboardShortcut(varChild_vt, varChild_reserved1, varChild_lVal, varChild_reserved2, pszKeyboardShortcut);
+ if (code == COM.E_INVALIDARG) code = COM.S_FALSE; // proxy doesn't know about app childID
+ if (accessibleListeners.size() == 0) return code;
+ if (code == COM.S_OK) {
+ int[] pKeyboardShortcut = new int[1];
+ COM.MoveMemory(pKeyboardShortcut, pszKeyboardShortcut, 4);
+ int size = COM.SysStringByteLen(pKeyboardShortcut[0]);
+ if (size > 0) {
+ char[] buffer = new char[(size + 1) /2];
+ COM.MoveMemory(buffer, pKeyboardShortcut[0], size);
+ osKeyboardShortcut = new String(buffer);
+ }
+ }
+
+ AccessibleEvent event = new AccessibleEvent(this);
+ if (varChild_lVal == COM.CHILDID_SELF) event.childID = ACC.CHILDID_SELF;
+ else if (control instanceof Tree) event.childID = varChild_lVal; // Tree item childIDs are pointers
+ else event.childID = varChild_lVal - 1; // All other childIDs are 1-based indices
+ event.result = osKeyboardShortcut;
+ for (int i = 0; i < accessibleListeners.size(); i++) {
+ AccessibleListener listener = (AccessibleListener) accessibleListeners.elementAt(i);
+ listener.getKeyboardShortcut(event);
+ }
+ if (event.result == null) return code;
+ char[] data = (event.result + "\0").toCharArray();
+ int ptr = COM.SysAllocString(data);
+ COM.MoveMemory(pszKeyboardShortcut, new int[] { ptr }, 4);
+ return COM.S_OK;
+ }
+
+ int get_accName(int varChild_vt, int varChild_reserved1, int varChild_lVal, int varChild_reserved2, int pszName) {
+ if (iaccessible == null) return COM.CO_E_OBJNOTCONNECTED;
+ if ((varChild_vt & 0xFFFF) != COM.VT_I4) return COM.E_INVALIDARG;
+
+ /* Get the default name from the OS. */
+ String osName = null;
+ int code = iaccessible.get_accName(varChild_vt, varChild_reserved1, varChild_lVal, varChild_reserved2, pszName);
+ if (code == COM.E_INVALIDARG) code = COM.S_FALSE; // proxy doesn't know about app childID
+ if (accessibleListeners.size() == 0) return code;
+ if (code == COM.S_OK) {
+ int[] pName = new int[1];
+ COM.MoveMemory(pName, pszName, 4);
+ int size = COM.SysStringByteLen(pName[0]);
+ if (size > 0) {
+ char[] buffer = new char[(size + 1) /2];
+ COM.MoveMemory(buffer, pName[0], size);
+ osName = new String(buffer);
+ }
+ }
+
+ AccessibleEvent event = new AccessibleEvent(this);
+ if (varChild_lVal == COM.CHILDID_SELF) event.childID = ACC.CHILDID_SELF;
+ else if (control instanceof Tree) event.childID = varChild_lVal; // Tree item childIDs are pointers
+ else event.childID = varChild_lVal - 1; // All other childIDs are 1-based indices
+ event.result = osName;
+ for (int i = 0; i < accessibleListeners.size(); i++) {
+ AccessibleListener listener = (AccessibleListener) accessibleListeners.elementAt(i);
+ listener.getName(event);
+ }
+ if (event.result == null) return code;
+ char[] data = (event.result + "\0").toCharArray();
+ int ptr = COM.SysAllocString(data);
+ COM.MoveMemory(pszName, new int[] { ptr }, 4);
+ return COM.S_OK;
+ }
+
+ int get_accParent(int ppdispParent) {
+ if (iaccessible == null) return COM.CO_E_OBJNOTCONNECTED;
+ // Currently, we don't let the application override this. Forward to the proxy.
+ return iaccessible.get_accParent(ppdispParent);
+ }
+
+ int get_accRole(int varChild_vt, int varChild_reserved1, int varChild_lVal, int varChild_reserved2, int pvarRole) {
+ if (iaccessible == null) return COM.CO_E_OBJNOTCONNECTED;
+ if ((varChild_vt & 0xFFFF) != COM.VT_I4) return COM.E_INVALIDARG;
+
+ /* Get the default role from the OS. */
+ int osRole = COM.ROLE_SYSTEM_CLIENT;
+ int code = iaccessible.get_accRole(varChild_vt, varChild_reserved1, varChild_lVal, varChild_reserved2, pvarRole);
+ if (code == COM.E_INVALIDARG) code = COM.S_FALSE; // proxy doesn't know about app childID
+ // TEMPORARY CODE - process tree and table even if there are no apps listening
+ if (accessibleControlListeners.size() == 0 && !(control instanceof Tree || control instanceof Table)) return code;
+ if (code == COM.S_OK) {
+ short[] pvt = new short[1];
+ COM.MoveMemory(pvt, pvarRole, 2);
+ if (pvt[0] == COM.VT_I4) {
+ int[] pRole = new int[1];
+ COM.MoveMemory(pRole, pvarRole + 8, 4);
+ osRole = pRole[0];
+ }
+ }
+
+ AccessibleControlEvent event = new AccessibleControlEvent(this);
+ event.detail = osToRole(osRole);
+ if (varChild_lVal == COM.CHILDID_SELF) {
+ event.childID = ACC.CHILDID_SELF;
+ } else {
+ if (control instanceof Tree) {
+ /* Tree item childIDs are pointers (not 1-based indices). */
+ event.childID = varChild_lVal;
+
+ // TEMPORARY CODE
+ /* Currently our checkbox tree is emulated using state mask images,
+ * so we need to specify 'checkbox' role for the items here. */
+ if ((control.getStyle() & SWT.CHECK) != 0) event.detail = ACC.ROLE_CHECKBUTTON;
+ } else if (control instanceof Table) {
+ event.childID = varChild_lVal - 1;
+
+ // TEMPORARY CODE
+ /* Currently our checkbox table is emulated using state mask images,
+ * so we need to specify 'checkbox' role for the items here. */
+ if ((control.getStyle() & SWT.CHECK) != 0) event.detail = ACC.ROLE_CHECKBUTTON;
+ } else {
+ event.childID = varChild_lVal - 1;
+ }
+ }
+ for (int i = 0; i < accessibleControlListeners.size(); i++) {
+ AccessibleControlListener listener = (AccessibleControlListener) accessibleControlListeners.elementAt(i);
+ listener.getRole(event);
+ }
+ int role = roleToOs(event.detail);
+ COM.MoveMemory(pvarRole, new short[] { COM.VT_I4 }, 2);
+ COM.MoveMemory(pvarRole + 8, new int[] { role }, 4);
+ return COM.S_OK;
+ }
+
+ int get_accSelection(int pvarChildren) {
+ if (iaccessible == null) return COM.CO_E_OBJNOTCONNECTED;
+
+ /* Get the default selection from the OS. */
+ int osChild = ACC.CHILDID_NONE;
+ int code = iaccessible.get_accSelection(pvarChildren);
+ if (accessibleControlListeners.size() == 0) return code;
+ if (code == COM.S_OK) {
+ short[] pvt = new short[1];
+ COM.MoveMemory(pvt, pvarChildren, 2);
+ if (pvt[0] == COM.VT_I4) {
+ int[] pChild = new int[1];
+ COM.MoveMemory(pChild, pvarChildren + 8, 4);
+ osChild = (pChild[0] == COM.CHILDID_SELF) ? ACC.CHILDID_SELF : pChild[0] - 1;
+ } else if (pvt[0] == COM.VT_UNKNOWN) {
+ osChild = ACC.CHILDID_MULTIPLE;
+ /* Should get IEnumVARIANT from punkVal field... need better API here... */
+ }
+ }
+
+ AccessibleControlEvent event = new AccessibleControlEvent(this);
+ event.childID = osChild;
+ for (int i = 0; i < accessibleControlListeners.size(); i++) {
+ AccessibleControlListener listener = (AccessibleControlListener) accessibleControlListeners.elementAt(i);
+ listener.getSelection(event);
+ }
+ Accessible accessible = event.accessible;
+ if (accessible != null) {
+ COM.MoveMemory(pvarChildren, new short[] { COM.VT_DISPATCH }, 2);
+ COM.MoveMemory(pvarChildren + 8, new int[] { accessible.objIAccessible.getAddress() }, 4);
+ return COM.S_OK;
+ }
+ int childID = event.childID;
+ if (childID == ACC.CHILDID_NONE) {
+ COM.MoveMemory(pvarChildren, new short[] { COM.VT_EMPTY }, 2);
+ return COM.S_FALSE;
+ }
+ if (childID == ACC.CHILDID_MULTIPLE) {
+ COM.MoveMemory(pvarChildren, new short[] { COM.VT_UNKNOWN }, 2);
+ /* Should return an IEnumVARIANT for this... so the next line is wrong... need better API here... */
+ COM.MoveMemory(pvarChildren + 8, new int[] { objIAccessible.getAddress() }, 4);
+ return COM.S_OK;
+ }
+ if (childID == ACC.CHILDID_SELF) {
+ COM.MoveMemory(pvarChildren, new short[] { COM.VT_DISPATCH }, 2);
+ COM.MoveMemory(pvarChildren + 8, new int[] { objIAccessible.getAddress() }, 4);
+ return COM.S_OK;
+ }
+ COM.MoveMemory(pvarChildren, new short[] { COM.VT_I4 }, 2);
+ COM.MoveMemory(pvarChildren + 8, new int[] { childID + 1 }, 4);
+ return COM.S_OK;
+ }
+
+ int get_accState(int varChild_vt, int varChild_reserved1, int varChild_lVal, int varChild_reserved2, int pvarState) {
+ if (iaccessible == null) return COM.CO_E_OBJNOTCONNECTED;
+ if ((varChild_vt & 0xFFFF) != COM.VT_I4) return COM.E_INVALIDARG;
+
+ /* Get the default state from the OS. */
+ int osState = 0;
+ int code = iaccessible.get_accState(varChild_vt, varChild_reserved1, varChild_lVal, varChild_reserved2, pvarState);
+ if (code == COM.E_INVALIDARG) code = COM.S_FALSE; // proxy doesn't know about app childID
+ // TEMPORARY CODE - process tree and table even if there are no apps listening
+ if (accessibleControlListeners.size() == 0 && !(control instanceof Tree || control instanceof Table)) return code;
+ if (code == COM.S_OK) {
+ short[] pvt = new short[1];
+ COM.MoveMemory(pvt, pvarState, 2);
+ if (pvt[0] == COM.VT_I4) {
+ int[] pState = new int[1];
+ COM.MoveMemory(pState, pvarState + 8, 4);
+ osState = pState[0];
+ }
+ }
+
+ AccessibleControlEvent event = new AccessibleControlEvent(this);
+ event.detail = osToState(osState);
+ if (varChild_lVal == COM.CHILDID_SELF) {
+ event.childID = ACC.CHILDID_SELF;
+ } else {
+ if (control instanceof Tree) {
+ /* Tree item childIDs are pointers (not 1-based indices). */
+ event.childID = varChild_lVal;
+
+ // TEMPORARY CODE
+ /* Currently our checkbox tree is emulated using state mask images,
+ * so we need to determine if the item is 'checked' here. */
+ int hwnd = control.handle;
+ TVITEM tvItem = new TVITEM ();
+ tvItem.mask = OS.TVIF_HANDLE | OS.TVIF_STATE;
+ tvItem.hItem = varChild_lVal;
+ tvItem.stateMask = OS.TVIS_STATEIMAGEMASK;
+ int result = OS.SendMessage (hwnd, OS.TVM_GETITEM, 0, tvItem);
+ boolean checked = (result != 0) && (((tvItem.state >> 12) & 1) == 0);
+ if (checked) event.detail |= ACC.STATE_CHECKED;
+ } else if (control instanceof Table) {
+ event.childID = varChild_lVal - 1;
+
+ // TEMPORARY CODE
+ /* Currently our checkbox table is emulated using state mask images,
+ * so we need to determine if the item is 'checked' here. */
+ Table table = (Table) control;
+ TableItem item = table.getItem(event.childID);
+ if (item != null) {
+ if (item.getChecked()) event.detail |= ACC.STATE_CHECKED;
+ }
+ } else {
+ event.childID = varChild_lVal - 1;
+ }
+ }
+ for (int i = 0; i < accessibleControlListeners.size(); i++) {
+ AccessibleControlListener listener = (AccessibleControlListener) accessibleControlListeners.elementAt(i);
+ listener.getState(event);
+ }
+ int state = stateToOs(event.detail);
+ COM.MoveMemory(pvarState, new short[] { COM.VT_I4 }, 2);
+ COM.MoveMemory(pvarState + 8, new int[] { state }, 4);
+ return COM.S_OK;
+ }
+
+ int get_accValue(int varChild_vt, int varChild_reserved1, int varChild_lVal, int varChild_reserved2, int pszValue) {
+ if (iaccessible == null) return COM.CO_E_OBJNOTCONNECTED;
+ if ((varChild_vt & 0xFFFF) != COM.VT_I4) return COM.E_INVALIDARG;
+
+ /* Get the default value string from the OS. */
+ String osValue = null;
+ int code = iaccessible.get_accValue(varChild_vt, varChild_reserved1, varChild_lVal, varChild_reserved2, pszValue);
+ if (code == COM.E_INVALIDARG) code = COM.S_FALSE; // proxy doesn't know about app childID
+ if (accessibleControlListeners.size() == 0) return code;
+ if (code == COM.S_OK) {
+ int[] pValue = new int[1];
+ COM.MoveMemory(pValue, pszValue, 4);
+ int size = COM.SysStringByteLen(pValue[0]);
+ if (size > 0) {
+ char[] buffer = new char[(size + 1) /2];
+ COM.MoveMemory(buffer, pValue[0], size);
+ osValue = new String(buffer);
+ }
+ }
+
+ AccessibleControlEvent event = new AccessibleControlEvent(this);
+ if (varChild_lVal == COM.CHILDID_SELF) event.childID = ACC.CHILDID_SELF;
+ else if (control instanceof Tree) event.childID = varChild_lVal; // Tree item childIDs are pointers
+ else event.childID = varChild_lVal - 1; // All other childIDs are 1-based indices
+ event.result = osValue;
+ for (int i = 0; i < accessibleControlListeners.size(); i++) {
+ AccessibleControlListener listener = (AccessibleControlListener) accessibleControlListeners.elementAt(i);
+ listener.getValue(event);
+ }
+ if (event.result == null) return code;
+ char[] data = (event.result + "\0").toCharArray();
+ int ptr = COM.SysAllocString(data);
+ COM.MoveMemory(pszValue, new int[] { ptr }, 4);
+ return COM.S_OK;
+ }
+
+ int put_accName(int varChild_vt, int varChild_reserved1, int varChild_lVal, int varChild_reserved2, int szName) {
+ // MSAA: this method is no longer supported
+ if (iaccessible == null) return COM.CO_E_OBJNOTCONNECTED;
+ // We don't implement this. Forward to the proxy.
+ int code = iaccessible.put_accName(varChild_vt, varChild_reserved1, varChild_lVal, varChild_reserved2, szName);
+ if (code == COM.E_INVALIDARG) code = COM.S_FALSE; // proxy doesn't know about app childID
+ return code;
+ }
+
+ int put_accValue(int varChild_vt, int varChild_reserved1, int varChild_lVal, int varChild_reserved2, int szValue) {
+ // MSAA: this method is typically only used for edit controls
+ if (iaccessible == null) return COM.CO_E_OBJNOTCONNECTED;
+ // We don't implement this. Forward to the proxy.
+ int code = iaccessible.put_accValue(varChild_vt, varChild_reserved1, varChild_lVal, varChild_reserved2, szValue);
+ if (code == COM.E_INVALIDARG) code = COM.S_FALSE; // proxy doesn't know about app childID
+ return code;
+ }
+
+ /* IEnumVARIANT methods: Next, Skip, Reset */
+ /* Retrieve the next celt items in the enumeration sequence.
+ * If there are fewer than the requested number of elements left
+ * in the sequence, retrieve the remaining elements.
+ * The number of elements actually retrieved is returned in pceltFetched
+ * (unless the caller passed in NULL for that parameter).
+ */
+ int Next(int celt, int rgvar, int pceltFetched) {
+ /* If there are no listeners, query the proxy for
+ * its IEnumVariant, and get the Next items from it.
+ */
+ if (accessibleControlListeners.size() == 0) {
+ int[] ppvObject = new int[1];
+ int code = iaccessible.QueryInterface(COM.IIDIEnumVARIANT, ppvObject);
+ if (code != COM.S_OK) return code;
+ IEnumVARIANT ienumvariant = new IEnumVARIANT(ppvObject[0]);
+ int[] celtFetched = new int[1];
+ code = ienumvariant.Next(celt, rgvar, celtFetched);
+ COM.MoveMemory(pceltFetched, celtFetched, 4);
+ return code;
+ }
+
+ if (rgvar == 0) return COM.E_INVALIDARG;
+ if (pceltFetched == 0 && celt != 1) return COM.E_INVALIDARG;
+ if (enumIndex == 0) {
+ AccessibleControlEvent event = new AccessibleControlEvent(this);
+ event.childID = ACC.CHILDID_SELF;
+ for (int i = 0; i < accessibleControlListeners.size(); i++) {
+ AccessibleControlListener listener = (AccessibleControlListener) accessibleControlListeners.elementAt(i);
+ listener.getChildren(event);
+ }
+ variants = event.children;
+ }
+ Object[] nextItems = null;
+ if (variants != null && celt >= 1) {
+ int endIndex = enumIndex + celt - 1;
+ if (endIndex > (variants.length - 1)) endIndex = variants.length - 1;
+ if (enumIndex <= endIndex) {
+ nextItems = new Object[endIndex - enumIndex + 1];
+ for (int i = 0; i < nextItems.length; i++) {
+ Object child = variants[enumIndex];
+ if (child instanceof Integer) {
+ nextItems[i] = new Integer(((Integer)child).intValue() + 1);
+ } else {
+ nextItems[i] = child;
+ }
+ enumIndex++;
+ }
+ }
+ }
+ if (nextItems != null) {
+ for (int i = 0; i < nextItems.length; i++) {
+ Object nextItem = nextItems[i];
+ if (nextItem instanceof Integer) {
+ int item = ((Integer) nextItem).intValue();
+ COM.MoveMemory(rgvar + i * 16, new short[] { COM.VT_I4 }, 2);
+ COM.MoveMemory(rgvar + i * 16 + 8, new int[] { item }, 4);
+ } else {
+ int address = ((Accessible) nextItem).objIAccessible.getAddress();
+ COM.MoveMemory(rgvar + i * 16, new short[] { COM.VT_DISPATCH }, 2);
+ COM.MoveMemory(rgvar + i * 16 + 8, new int[] { address }, 4);
+ }
+ }
+ 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);
+ }
+ return COM.S_FALSE;
+ }
+
+ /* Skip over the specified number of elements in the enumeration sequence. */
+ int Skip(int celt) {
+ /* If there are no listeners, query the proxy
+ * for its IEnumVariant, and tell it to Skip.
+ */
+ if (accessibleControlListeners.size() == 0) {
+ int[] ppvObject = new int[1];
+ int code = iaccessible.QueryInterface(COM.IIDIEnumVARIANT, ppvObject);
+ if (code != COM.S_OK) return code;
+ IEnumVARIANT ienumvariant = new IEnumVARIANT(ppvObject[0]);
+ code = ienumvariant.Skip(celt);
+ return code;
+ }
+
+ if (celt < 1 ) return COM.E_INVALIDARG;
+ enumIndex += celt;
+ if (enumIndex > (variants.length - 1)) {
+ enumIndex = variants.length - 1;
+ return COM.S_FALSE;
+ }
+ return COM.S_OK;
+ }
+
+ /* Reset the enumeration sequence to the beginning. */
+ int Reset() {
+ /* If there are no listeners, query the proxy
+ * for its IEnumVariant, and tell it to Reset.
+ */
+ if (accessibleControlListeners.size() == 0) {
+ int[] ppvObject = new int[1];
+ int code = iaccessible.QueryInterface(COM.IIDIEnumVARIANT, ppvObject);
+ if (code != COM.S_OK) return code;
+ IEnumVARIANT ienumvariant = new IEnumVARIANT(ppvObject[0]);
+ code = ienumvariant.Reset();
+ return code;
+ }
+
+ enumIndex = 0;
+ return COM.S_OK;
+ }
+
+ int stateToOs(int state) {
+ int osState = 0;
+ if ((state & ACC.STATE_SELECTED) != 0) osState |= COM.STATE_SYSTEM_SELECTED;
+ if ((state & ACC.STATE_SELECTABLE) != 0) osState |= COM.STATE_SYSTEM_SELECTABLE;
+ if ((state & ACC.STATE_MULTISELECTABLE) != 0) osState |= COM.STATE_SYSTEM_MULTISELECTABLE;
+ if ((state & ACC.STATE_FOCUSED) != 0) osState |= COM.STATE_SYSTEM_FOCUSED;
+ if ((state & ACC.STATE_FOCUSABLE) != 0) osState |= COM.STATE_SYSTEM_FOCUSABLE;
+ if ((state & ACC.STATE_PRESSED) != 0) osState |= COM.STATE_SYSTEM_PRESSED;
+ if ((state & ACC.STATE_CHECKED) != 0) osState |= COM.STATE_SYSTEM_CHECKED;
+ if ((state & ACC.STATE_EXPANDED) != 0) osState |= COM.STATE_SYSTEM_EXPANDED;
+ if ((state & ACC.STATE_COLLAPSED) != 0) osState |= COM.STATE_SYSTEM_COLLAPSED;
+ if ((state & ACC.STATE_HOTTRACKED) != 0) osState |= COM.STATE_SYSTEM_HOTTRACKED;
+ if ((state & ACC.STATE_BUSY) != 0) osState |= COM.STATE_SYSTEM_BUSY;
+ if ((state & ACC.STATE_READONLY) != 0) osState |= COM.STATE_SYSTEM_READONLY;
+ if ((state & ACC.STATE_INVISIBLE) != 0) osState |= COM.STATE_SYSTEM_INVISIBLE;
+ if ((state & ACC.STATE_OFFSCREEN) != 0) osState |= COM.STATE_SYSTEM_OFFSCREEN;
+ if ((state & ACC.STATE_SIZEABLE) != 0) osState |= COM.STATE_SYSTEM_SIZEABLE;
+ return osState;
+ }
+
+ int osToState(int osState) {
+ int state = ACC.STATE_NORMAL;
+ if ((osState & COM.STATE_SYSTEM_SELECTED) != 0) state |= ACC.STATE_SELECTED;
+ if ((osState & COM.STATE_SYSTEM_SELECTABLE) != 0) state |= ACC.STATE_SELECTABLE;
+ if ((osState & COM.STATE_SYSTEM_MULTISELECTABLE) != 0) state |= ACC.STATE_MULTISELECTABLE;
+ if ((osState & COM.STATE_SYSTEM_FOCUSED) != 0) state |= ACC.STATE_FOCUSED;
+ if ((osState & COM.STATE_SYSTEM_FOCUSABLE) != 0) state |= ACC.STATE_FOCUSABLE;
+ if ((osState & COM.STATE_SYSTEM_PRESSED) != 0) state |= ACC.STATE_PRESSED;
+ if ((osState & COM.STATE_SYSTEM_CHECKED) != 0) state |= ACC.STATE_CHECKED;
+ if ((osState & COM.STATE_SYSTEM_EXPANDED) != 0) state |= ACC.STATE_EXPANDED;
+ if ((osState & COM.STATE_SYSTEM_COLLAPSED) != 0) state |= ACC.STATE_COLLAPSED;
+ if ((osState & COM.STATE_SYSTEM_HOTTRACKED) != 0) state |= ACC.STATE_HOTTRACKED;
+ if ((osState & COM.STATE_SYSTEM_BUSY) != 0) state |= ACC.STATE_BUSY;
+ if ((osState & COM.STATE_SYSTEM_READONLY) != 0) state |= ACC.STATE_READONLY;
+ if ((osState & COM.STATE_SYSTEM_INVISIBLE) != 0) state |= ACC.STATE_INVISIBLE;
+ if ((osState & COM.STATE_SYSTEM_OFFSCREEN) != 0) state |= ACC.STATE_OFFSCREEN;
+ if ((osState & COM.STATE_SYSTEM_SIZEABLE) != 0) state |= ACC.STATE_SIZEABLE;
+ return state;
+ }
+
+ int roleToOs(int role) {
+ switch (role) {
+ case ACC.ROLE_CLIENT_AREA: return COM.ROLE_SYSTEM_CLIENT;
+ case ACC.ROLE_WINDOW: return COM.ROLE_SYSTEM_WINDOW;
+ case ACC.ROLE_MENUBAR: return COM.ROLE_SYSTEM_MENUBAR;
+ case ACC.ROLE_MENU: return COM.ROLE_SYSTEM_MENUPOPUP;
+ case ACC.ROLE_MENUITEM: return COM.ROLE_SYSTEM_MENUITEM;
+ case ACC.ROLE_SEPARATOR: return COM.ROLE_SYSTEM_SEPARATOR;
+ case ACC.ROLE_TOOLTIP: return COM.ROLE_SYSTEM_TOOLTIP;
+ case ACC.ROLE_SCROLLBAR: return COM.ROLE_SYSTEM_SCROLLBAR;
+ case ACC.ROLE_DIALOG: return COM.ROLE_SYSTEM_DIALOG;
+ case ACC.ROLE_LABEL: return COM.ROLE_SYSTEM_STATICTEXT;
+ case ACC.ROLE_PUSHBUTTON: return COM.ROLE_SYSTEM_PUSHBUTTON;
+ case ACC.ROLE_CHECKBUTTON: return COM.ROLE_SYSTEM_CHECKBUTTON;
+ case ACC.ROLE_RADIOBUTTON: return COM.ROLE_SYSTEM_RADIOBUTTON;
+ case ACC.ROLE_COMBOBOX: return COM.ROLE_SYSTEM_COMBOBOX;
+ case ACC.ROLE_TEXT: return COM.ROLE_SYSTEM_TEXT;
+ case ACC.ROLE_TOOLBAR: return COM.ROLE_SYSTEM_TOOLBAR;
+ case ACC.ROLE_LIST: return COM.ROLE_SYSTEM_LIST;
+ case ACC.ROLE_LISTITEM: return COM.ROLE_SYSTEM_LISTITEM;
+ case ACC.ROLE_TABLE: return COM.ROLE_SYSTEM_TABLE;
+ case ACC.ROLE_TABLECOLUMN: return COM.ROLE_SYSTEM_COLUMNHEADER;
+ case ACC.ROLE_TREE: return COM.ROLE_SYSTEM_OUTLINE;
+ case ACC.ROLE_TABFOLDER: return COM.ROLE_SYSTEM_PAGETABLIST;
+ case ACC.ROLE_TABITEM: return COM.ROLE_SYSTEM_PAGETAB;
+ case ACC.ROLE_PROGRESSBAR: return COM.ROLE_SYSTEM_PROGRESSBAR;
+ case ACC.ROLE_SLIDER: return COM.ROLE_SYSTEM_SLIDER;
+ }
+ return COM.ROLE_SYSTEM_CLIENT;
+ }
+
+ int osToRole(int osRole) {
+ int role = COM.ROLE_SYSTEM_CLIENT;
+ switch (osRole) {
+ case COM.ROLE_SYSTEM_CLIENT: return ACC.ROLE_CLIENT_AREA;
+ case COM.ROLE_SYSTEM_WINDOW: return ACC.ROLE_WINDOW;
+ case COM.ROLE_SYSTEM_MENUBAR: return ACC.ROLE_MENUBAR;
+ case COM.ROLE_SYSTEM_MENUPOPUP: return ACC.ROLE_MENU;
+ case COM.ROLE_SYSTEM_MENUITEM: return ACC.ROLE_MENUITEM;
+ case COM.ROLE_SYSTEM_SEPARATOR: return ACC.ROLE_SEPARATOR;
+ case COM.ROLE_SYSTEM_TOOLTIP: return ACC.ROLE_TOOLTIP;
+ case COM.ROLE_SYSTEM_SCROLLBAR: return ACC.ROLE_SCROLLBAR;
+ case COM.ROLE_SYSTEM_DIALOG: return ACC.ROLE_DIALOG;
+ case COM.ROLE_SYSTEM_STATICTEXT: return ACC.ROLE_LABEL;
+ case COM.ROLE_SYSTEM_PUSHBUTTON: return ACC.ROLE_PUSHBUTTON;
+ case COM.ROLE_SYSTEM_CHECKBUTTON: return ACC.ROLE_CHECKBUTTON;
+ case COM.ROLE_SYSTEM_RADIOBUTTON: return ACC.ROLE_RADIOBUTTON;
+ case COM.ROLE_SYSTEM_COMBOBOX: return ACC.ROLE_COMBOBOX;
+ case COM.ROLE_SYSTEM_TEXT: return ACC.ROLE_TEXT;
+ case COM.ROLE_SYSTEM_TOOLBAR: return ACC.ROLE_TOOLBAR;
+ case COM.ROLE_SYSTEM_LIST: return ACC.ROLE_LIST;
+ case COM.ROLE_SYSTEM_LISTITEM: return ACC.ROLE_LISTITEM;
+ case COM.ROLE_SYSTEM_TABLE: return ACC.ROLE_TABLE;
+ case COM.ROLE_SYSTEM_COLUMNHEADER: return ACC.ROLE_TABLECOLUMN;
+ case COM.ROLE_SYSTEM_OUTLINE: return ACC.ROLE_TREE;
+ case COM.ROLE_SYSTEM_PAGETABLIST: return ACC.ROLE_TABFOLDER;
+ case COM.ROLE_SYSTEM_PAGETAB: return ACC.ROLE_TABITEM;
+ case COM.ROLE_SYSTEM_PROGRESSBAR: return ACC.ROLE_PROGRESSBAR;
+ case COM.ROLE_SYSTEM_SLIDER: return ACC.ROLE_SLIDER;
+ }
+ return role;
+ }
+
+ /* checkWidget was copied from Widget, and rewritten to work in this package */
+ void checkWidget () {
+ if (!isValidThread ()) SWT.error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (control.isDisposed ()) SWT.error (SWT.ERROR_WIDGET_DISPOSED);
+ }
+
+ /* isValidThread was copied from Widget, and rewritten to work in this package */
+ boolean isValidThread () {
+ return control.getDisplay ().getThread () == Thread.currentThread ();
+ }
+}
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
index c21d07ab14..475f4e2e4d 100755
--- 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
@@ -1,215 +1,215 @@
-package org.eclipse.swt.custom;
-
-/*
+package org.eclipse.swt.custom;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-import org.eclipse.swt.*;
-import org.eclipse.swt.graphics.*;
-import org.eclipse.swt.widgets.*;
-import org.eclipse.swt.events.*;
-
-/**
- * A control for showing progress feedback for a long running operation.
- *
- * @deprecated As of Eclipse 2.1, use ProgressBar with the style SWT.INDETERMINATE
- *
- * <dl>
- * <dt><b>Styles:</b><dd>VERTICAL, HORIZONTAL, BORDER
- * </dl>
- */
-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;
-
-/**
- * Constructs a new instance of this class given its parent
- * and a style value describing its behavior and appearance.
- * <p>
- * The style value is either one of the style constants defined in
- * class <code>SWT</code> which is applicable to instances of this
- * class, or must be built by <em>bitwise OR</em>'ing together
- * (that is, using the <code>int</code> "|" operator) two or more
- * of those <code>SWT</code> style constants. The class description
- * lists the style constants that are applicable to the class.
- * Style bits are also inherited from superclasses.
- * </p>
- *
- * @param parent a widget which will be the parent of the new instance (cannot be null)
- * @param style the style of widget to construct
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
- * </ul>
- *
- * @see SWT#VERTICAL
- * @see SWT#HORIZONTAL
- * @see SWT#BORDER
- * @see #getStyle
- */
-public AnimatedProgress(Composite parent, int style) {
- super(parent, checkStyle(style));
-
- if ((style & SWT.VERTICAL) != 0) {
- orientation = SWT.VERTICAL;
- }
- showBorder = (style & SWT.BORDER) != 0;
-
- addControlListener(new ControlAdapter() {
- public void controlResized(ControlEvent e) {
- redraw();
- }
- });
- addPaintListener(new PaintListener() {
- public void paintControl(PaintEvent e) {
- paint(e);
- }
- });
- addDisposeListener(new DisposeListener() {
- public void widgetDisposed(DisposeEvent e){
- stop();
- }
- });
-}
-private static int checkStyle (int style) {
- int mask = SWT.NONE;
- return style & mask;
-}
-/**
- * Stop the animation if it is not already stopped and
- * reset the presentation to a blank appearance.
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public synchronized void clear(){
- checkWidget();
- if (active) stop();
- showStripes = false;
- redraw();
-}
-public Point computeSize(int wHint, int hHint, boolean changed) {
- checkWidget();
- Point size = null;
- if (orientation == SWT.HORIZONTAL) {
- size = new Point(DEFAULT_WIDTH, DEFAULT_HEIGHT);
- } else {
- size = new Point(DEFAULT_HEIGHT, DEFAULT_WIDTH);
- }
- if (wHint != SWT.DEFAULT) size.x = wHint;
- if (hHint != SWT.DEFAULT) size.y = hHint;
-
- return size;
-}
-private void drawBevelRect(GC gc, int x, int y, int w, int h, Color topleft, Color bottomright) {
- gc.setForeground(topleft);
- gc.drawLine(x, y, x+w-1, y);
- gc.drawLine(x, y, x, y+h-1);
-
- gc.setForeground(bottomright);
- gc.drawLine(x+w, y, x+w, y+h);
- gc.drawLine(x, y+h, x+w, y+h);
-}
-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.
-*
-* @exception SWTException <ul>
-* <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
-* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
-* </ul>
-*/
-public synchronized void start() {
- checkWidget();
- if (active) return;
-
- active = true;
- showStripes = true;
-
- final Display display = getDisplay();
- final Runnable [] timer = new Runnable [1];
- timer [0] = new Runnable () {
- public void run () {
- if (!active) return;
- GC gc = new GC(AnimatedProgress.this);
- paintStripes(gc);
- gc.dispose();
- display.timerExec (SLEEP, timer [0]);
- }
- };
- display.timerExec (SLEEP, timer [0]);
-}
-/**
-* Stop the animation. Freeze the presentation at its current appearance.
-*/
-public synchronized void stop() {
- //checkWidget();
- active = false;
-}
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+import org.eclipse.swt.*;
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.widgets.*;
+import org.eclipse.swt.events.*;
+
+/**
+ * A control for showing progress feedback for a long running operation.
+ *
+ * @deprecated As of Eclipse 2.1, use ProgressBar with the style SWT.INDETERMINATE
+ *
+ * <dl>
+ * <dt><b>Styles:</b><dd>VERTICAL, HORIZONTAL, BORDER
+ * </dl>
+ */
+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;
+
+/**
+ * Constructs a new instance of this class given its parent
+ * and a style value describing its behavior and appearance.
+ * <p>
+ * The style value is either one of the style constants defined in
+ * class <code>SWT</code> which is applicable to instances of this
+ * class, or must be built by <em>bitwise OR</em>'ing together
+ * (that is, using the <code>int</code> "|" operator) two or more
+ * of those <code>SWT</code> style constants. The class description
+ * lists the style constants that are applicable to the class.
+ * Style bits are also inherited from superclasses.
+ * </p>
+ *
+ * @param parent a widget which will be the parent of the new instance (cannot be null)
+ * @param style the style of widget to construct
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
+ * </ul>
+ *
+ * @see SWT#VERTICAL
+ * @see SWT#HORIZONTAL
+ * @see SWT#BORDER
+ * @see #getStyle
+ */
+public AnimatedProgress(Composite parent, int style) {
+ super(parent, checkStyle(style));
+
+ if ((style & SWT.VERTICAL) != 0) {
+ orientation = SWT.VERTICAL;
+ }
+ showBorder = (style & SWT.BORDER) != 0;
+
+ addControlListener(new ControlAdapter() {
+ public void controlResized(ControlEvent e) {
+ redraw();
+ }
+ });
+ addPaintListener(new PaintListener() {
+ public void paintControl(PaintEvent e) {
+ paint(e);
+ }
+ });
+ addDisposeListener(new DisposeListener() {
+ public void widgetDisposed(DisposeEvent e){
+ stop();
+ }
+ });
+}
+private static int checkStyle (int style) {
+ int mask = SWT.NONE;
+ return style & mask;
+}
+/**
+ * Stop the animation if it is not already stopped and
+ * reset the presentation to a blank appearance.
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public synchronized void clear(){
+ checkWidget();
+ if (active) stop();
+ showStripes = false;
+ redraw();
+}
+public Point computeSize(int wHint, int hHint, boolean changed) {
+ checkWidget();
+ Point size = null;
+ if (orientation == SWT.HORIZONTAL) {
+ size = new Point(DEFAULT_WIDTH, DEFAULT_HEIGHT);
+ } else {
+ size = new Point(DEFAULT_HEIGHT, DEFAULT_WIDTH);
+ }
+ if (wHint != SWT.DEFAULT) size.x = wHint;
+ if (hHint != SWT.DEFAULT) size.y = hHint;
+
+ return size;
+}
+private void drawBevelRect(GC gc, int x, int y, int w, int h, Color topleft, Color bottomright) {
+ gc.setForeground(topleft);
+ gc.drawLine(x, y, x+w-1, y);
+ gc.drawLine(x, y, x, y+h-1);
+
+ gc.setForeground(bottomright);
+ gc.drawLine(x+w, y, x+w, y+h);
+ gc.drawLine(x, y+h, x+w, y+h);
+}
+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.
+*
+* @exception SWTException <ul>
+* <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+* </ul>
+*/
+public synchronized void start() {
+ checkWidget();
+ if (active) return;
+
+ active = true;
+ showStripes = true;
+
+ final Display display = getDisplay();
+ final Runnable [] timer = new Runnable [1];
+ timer [0] = new Runnable () {
+ public void run () {
+ if (!active) return;
+ GC gc = new GC(AnimatedProgress.this);
+ paintStripes(gc);
+ gc.dispose();
+ display.timerExec (SLEEP, timer [0]);
+ }
+ };
+ display.timerExec (SLEEP, timer [0]);
+}
+/**
+* Stop the animation. Freeze the presentation at its current appearance.
+*/
+public synchronized void stop() {
+ //checkWidget();
+ active = false;
+}
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/BidiSegmentEvent.java b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/BidiSegmentEvent.java
index 45125d77b8..dd13c1aa72 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/BidiSegmentEvent.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/BidiSegmentEvent.java
@@ -1,69 +1,69 @@
-package org.eclipse.swt.custom;
-
-/*
+package org.eclipse.swt.custom;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-import org.eclipse.swt.events.*;
-
-/**
- * This event is sent to BidiSegmentListeners when a line is to
- * be measured or rendered in a bidi locale. The segments field is
- * used to specify text ranges in the line that should be treated as
- * separate segments for bidi reordering. Each segment will be reordered
- * and rendered separately.
- * <p>
- * The elements in the segments field specify the start offset of
- * a segment relative to the start of the line. They must follow
- * the following rules:
- * <ul>
- * <li>first element must be 0
- * <li>elements must be in ascending order and must not have duplicates
- * <li>elements must not exceed the line length
- * </ul>
- * In addition, the last element may be set to the end of the line
- * but this is not required.
- *
- * The segments field may be left null if the entire line should
- * be reordered as is.
- * </p>
- * A BidiSegmentListener may be used when adjacent segments of
- * right-to-left text should not be reordered relative to each other.
- * For example, within a Java editor, you may wish multiple
- * right-to-left string literals to be reordered differently than the
- * bidi algorithm specifies.
- *
- * Example:
- * <pre>
- * stored line = "R1R2R3" + "R4R5R6"
- * R1 to R6 are right-to-left characters. The quotation marks
- * are part of the line text. The line is 13 characters long.
- *
- * segments = null:
- * entire line will be reordered and thus the two R2L segments
- * swapped (as per the bidi algorithm).
- * visual line (rendered on screen) = "R6R5R4" + "R3R2R1"
- *
- * segments = [0, 5, 8]
- * "R1R2R3" will be reordered, followed by [blank]+[blank] and
- * "R4R5R6".
- * visual line = "R3R2R1" + "R6R5R4"
- * </pre>
- */
-public class BidiSegmentEvent extends TypedEvent {
- /** line start offset */
- public int lineOffset;
- /** line text */
- public String lineText;
- /** bidi segments, see above */
- public int[] segments;
-
-BidiSegmentEvent(StyledTextEvent e) {
- super(e);
- lineOffset = e.detail;
- lineText = e.text;
-}
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+import org.eclipse.swt.events.*;
+
+/**
+ * This event is sent to BidiSegmentListeners when a line is to
+ * be measured or rendered in a bidi locale. The segments field is
+ * used to specify text ranges in the line that should be treated as
+ * separate segments for bidi reordering. Each segment will be reordered
+ * and rendered separately.
+ * <p>
+ * The elements in the segments field specify the start offset of
+ * a segment relative to the start of the line. They must follow
+ * the following rules:
+ * <ul>
+ * <li>first element must be 0
+ * <li>elements must be in ascending order and must not have duplicates
+ * <li>elements must not exceed the line length
+ * </ul>
+ * In addition, the last element may be set to the end of the line
+ * but this is not required.
+ *
+ * The segments field may be left null if the entire line should
+ * be reordered as is.
+ * </p>
+ * A BidiSegmentListener may be used when adjacent segments of
+ * right-to-left text should not be reordered relative to each other.
+ * For example, within a Java editor, you may wish multiple
+ * right-to-left string literals to be reordered differently than the
+ * bidi algorithm specifies.
+ *
+ * Example:
+ * <pre>
+ * stored line = "R1R2R3" + "R4R5R6"
+ * R1 to R6 are right-to-left characters. The quotation marks
+ * are part of the line text. The line is 13 characters long.
+ *
+ * segments = null:
+ * entire line will be reordered and thus the two R2L segments
+ * swapped (as per the bidi algorithm).
+ * visual line (rendered on screen) = "R6R5R4" + "R3R2R1"
+ *
+ * segments = [0, 5, 8]
+ * "R1R2R3" will be reordered, followed by [blank]+[blank] and
+ * "R4R5R6".
+ * visual line = "R3R2R1" + "R6R5R4"
+ * </pre>
+ */
+public class BidiSegmentEvent extends TypedEvent {
+ /** line start offset */
+ public int lineOffset;
+ /** line text */
+ public String lineText;
+ /** bidi segments, see above */
+ public int[] segments;
+
+BidiSegmentEvent(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/BidiSegmentListener.java b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/BidiSegmentListener.java
index 551551afe3..267f5dbe2b 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/BidiSegmentListener.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/BidiSegmentListener.java
@@ -1,32 +1,32 @@
-package org.eclipse.swt.custom;
-
-/*
+package org.eclipse.swt.custom;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-import org.eclipse.swt.internal.SWTEventListener;
-
-/**
- * This listener interface may be implemented in order to receive
- * BidiSegmentEvents.
- * @see BidiSegmentEvent
- */
-public interface BidiSegmentListener extends SWTEventListener {
-
-/**
- * This method is called when a line needs to be reordered for
- * measuring or rendering in a bidi locale.
- * <p>
- *
- * @param event.lineOffset line start offset (input)
- * @param event.lineText line text (input)
- * @param event.segments text segments that should be reordered
- * separately. (output)
- * @see BidiSegmentEvent
- */
-public void lineGetSegments(BidiSegmentEvent event);
-
-}
-
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+import org.eclipse.swt.internal.SWTEventListener;
+
+/**
+ * This listener interface may be implemented in order to receive
+ * BidiSegmentEvents.
+ * @see BidiSegmentEvent
+ */
+public interface BidiSegmentListener extends SWTEventListener {
+
+/**
+ * This method is called when a line needs to be reordered for
+ * measuring or rendering in a bidi locale.
+ * <p>
+ *
+ * @param event.lineOffset line start offset (input)
+ * @param event.lineText line text (input)
+ * @param event.segments text segments that should be reordered
+ * separately. (output)
+ * @see BidiSegmentEvent
+ */
+public void lineGetSegments(BidiSegmentEvent event);
+
+}
+
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
index b9268db080..5e4df66c07 100755
--- 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
@@ -1,80 +1,80 @@
-package org.eclipse.swt.custom;
-
-/*
+package org.eclipse.swt.custom;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-import org.eclipse.swt.*;
-import org.eclipse.swt.graphics.*;
-import org.eclipse.swt.widgets.*;
-
-/**
- * Support for showing a Busy Cursor during a long running process.
- */
-public class BusyIndicator {
-
- static int nextBusyId = 1;
- static final String BUSYID_NAME = "SWT BusyIndicator"; //$NON-NLS-1$
-
-/**
- * Runs the given <code>Runnable</code> while providing
- * busy feedback using this busy indicator.
- *
- * @param display the display on which the busy feedback should be
- * displayed. If the display is null, the Display for the current
- * thread will be used. If there is no Display for the current thread,
- * the runnable code will be executed and no busy feedback will be displayed.
- * @param runnable the runnable for which busy feedback is to be shown.
- * Must not be null.
- *
-* @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the runnable is null</li>
- * </ul>
- *
- * @see #showWhile
- */
-
-public static void showWhile(Display display, Runnable runnable) {
- if (runnable == null)
- SWT.error(SWT.ERROR_NULL_ARGUMENT);
- if (display == null) {
- display = Display.getCurrent();
- if (display == null) {
- runnable.run();
- return;
- }
- }
-
- Integer busyId = new Integer(nextBusyId);
- nextBusyId++;
- Cursor cursor = new Cursor(display, SWT.CURSOR_WAIT);
-
- Shell[] shells = display.getShells();
- for (int i = 0; i < shells.length; i++) {
- Integer id = (Integer)shells[i].getData(BUSYID_NAME);
- if (id == null) {
- shells[i].setCursor(cursor);
- shells[i].setData(BUSYID_NAME, busyId);
- }
- }
-
- try {
- runnable.run();
- } finally {
- shells = display.getShells();
- for (int i = 0; i < shells.length; i++) {
- Integer id = (Integer)shells[i].getData(BUSYID_NAME);
- if (id == busyId) {
- shells[i].setCursor(null);
- shells[i].setData(BUSYID_NAME, null);
- }
- }
- if (cursor != null && !cursor.isDisposed()) {
- cursor.dispose();
- }
- }
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+import org.eclipse.swt.*;
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.widgets.*;
+
+/**
+ * Support for showing a Busy Cursor during a long running process.
+ */
+public class BusyIndicator {
+
+ static int nextBusyId = 1;
+ static final String BUSYID_NAME = "SWT BusyIndicator"; //$NON-NLS-1$
+
+/**
+ * Runs the given <code>Runnable</code> while providing
+ * busy feedback using this busy indicator.
+ *
+ * @param display the display on which the busy feedback should be
+ * displayed. If the display is null, the Display for the current
+ * thread will be used. If there is no Display for the current thread,
+ * the runnable code will be executed and no busy feedback will be displayed.
+ * @param runnable the runnable for which busy feedback is to be shown.
+ * Must not be null.
+ *
+* @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if the runnable is null</li>
+ * </ul>
+ *
+ * @see #showWhile
+ */
+
+public static void showWhile(Display display, Runnable runnable) {
+ if (runnable == null)
+ SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ if (display == null) {
+ display = Display.getCurrent();
+ if (display == null) {
+ runnable.run();
+ return;
+ }
+ }
+
+ Integer busyId = new Integer(nextBusyId);
+ nextBusyId++;
+ Cursor cursor = new Cursor(display, SWT.CURSOR_WAIT);
+
+ Shell[] shells = display.getShells();
+ for (int i = 0; i < shells.length; i++) {
+ Integer id = (Integer)shells[i].getData(BUSYID_NAME);
+ if (id == null) {
+ shells[i].setCursor(cursor);
+ shells[i].setData(BUSYID_NAME, busyId);
+ }
+ }
+
+ try {
+ runnable.run();
+ } finally {
+ shells = display.getShells();
+ for (int i = 0; i < shells.length; i++) {
+ Integer id = (Integer)shells[i].getData(BUSYID_NAME);
+ if (id == busyId) {
+ shells[i].setCursor(null);
+ shells[i].setData(BUSYID_NAME, null);
+ }
+ }
+ if (cursor != null && !cursor.isDisposed()) {
+ cursor.dispose();
+ }
+ }
+}
}
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
index e484e9fc94..76031ae785 100755
--- 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
@@ -1,1180 +1,1180 @@
-package org.eclipse.swt.custom;
-
-/*
+package org.eclipse.swt.custom;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-import org.eclipse.swt.*;
-import org.eclipse.swt.graphics.*;
-import org.eclipse.swt.events.*;
-import org.eclipse.swt.widgets.*;
-import org.eclipse.swt.accessibility.*;
-
-/**
- * The CCombo class represents a selectable user interface object
- * that combines a text field and a list and issues notificiation
- * when an item is selected from the list.
- * <p>
- * Note that although this class is a subclass of <code>Composite</code>,
- * it does not make sense to add children to it, or set a layout on it.
- * </p>
- * <dl>
- * <dt><b>Styles:</b>
- * <dd>BORDER, READ_ONLY, FLAT</dd>
- * <dt><b>Events:</b>
- * <dd>Selection</dd>
- * </dl>
- */
-public final class CCombo extends Composite {
-
- static final int ITEMS_SHOWING = 5;
-
- Text text;
- List list;
- Shell popup;
- Button arrow;
- boolean hasFocus;
-
-/**
- * Constructs a new instance of this class given its parent
- * and a style value describing its behavior and appearance.
- * <p>
- * The style value is either one of the style constants defined in
- * class <code>SWT</code> which is applicable to instances of this
- * class, or must be built by <em>bitwise OR</em>'ing together
- * (that is, using the <code>int</code> "|" operator) two or more
- * of those <code>SWT</code> style constants. The class description
- * lists the style constants that are applicable to the class.
- * Style bits are also inherited from superclasses.
- * </p>
- *
- * @param parent a widget which will be the parent of the new instance (cannot be null)
- * @param style the style of widget to construct
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
- * </ul>
- *
- * @see SWT#BORDER
- * @see SWT#READ_ONLY
- * @see SWT#FLAT
- * @see Widget#getStyle
- */
-public CCombo (Composite parent, int style) {
- super (parent, 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.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 [] comboEvents = {SWT.Dispose, SWT.Move, SWT.Resize};
- for (int i=0; i<comboEvents.length; i++) this.addListener (comboEvents [i], listener);
-
- 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.Traverse, SWT.FocusIn, SWT.FocusOut};
- for (int i=0; i<textEvents.length; i++) text.addListener (textEvents [i], listener);
-
- int [] listEvents = {SWT.MouseUp, SWT.Selection, SWT.Traverse, SWT.KeyDown, SWT.KeyUp, SWT.FocusIn, SWT.FocusOut};
- for (int i=0; i<listEvents.length; i++) list.addListener (listEvents [i], listener);
-
- int [] arrowEvents = {SWT.Selection, SWT.FocusIn, SWT.FocusOut};
- for (int i=0; i<arrowEvents.length; i++) arrow.addListener (arrowEvents [i], listener);
-
- initAccessible();
-}
-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) {
- checkWidget();
- 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) {
- checkWidget();
- 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) {;
- checkWidget();
- 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) {
- checkWidget();
- 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) {
- switch (event.type) {
- case SWT.FocusIn: {
- if (hasFocus) return;
- hasFocus = true;
- if (getEditable ()) text.selectAll ();
- Event e = new Event();
- e.time = event.time;
- notifyListeners(SWT.FocusIn, e);
- break;
- }
- case SWT.FocusOut: {
- event.display.asyncExec(new Runnable() {
- public void run() {
- if (CCombo.this.isDisposed()) return;
- Control focusControl = getDisplay().getFocusControl();
- if (focusControl == list || focusControl == text) return;
- hasFocus = false;
- Event e = new Event();
- notifyListeners(SWT.FocusOut, e);
- }
- });
- break;
- }
- case SWT.Selection: {
- dropDown (!isDropped ());
- break;
- }
- }
-}
-/**
-* 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 () {
- checkWidget();
- 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) {
- checkWidget();
- 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);
- 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) {
- checkWidget();
- 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 () {
- checkWidget();
- list.deselectAll ();
-}
-void dropDown (boolean drop) {
- if (drop == isDropped ()) return;
- if (!drop) {
- popup.setVisible (false);
- text.setFocus();
- return;
- }
- int index = list.getSelectionIndex ();
- if (index != -1) list.setTopIndex (index);
- Rectangle listRect = list.getBounds ();
- Point point = getParent().toDisplay (getLocation ());
- Point comboSize = getSize();
- int width = Math.max (comboSize.x, listRect.width + 2);
- popup.setBounds (point.x, point.y + comboSize.y, width, listRect.height + 2);
- popup.setVisible (true);
- list.setFocus();
-}
-public Control [] getChildren () {
- checkWidget();
- 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) {
- checkWidget();
- 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 () {
- checkWidget();
- 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 () {
- checkWidget();
- 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 () {
- checkWidget();
- 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 () {
- checkWidget();
- 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 () {
- checkWidget();
- 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 () {
- checkWidget();
- 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 () {
- checkWidget();
- 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 () {
- checkWidget();
- 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) {
- checkWidget();
- 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) {
- checkWidget();
- if (string == null) SWT.error (SWT.ERROR_NULL_ARGUMENT);
- return list.indexOf (string, start);
-}
-
-void initAccessible() {
- getAccessible().addAccessibleListener(new AccessibleAdapter() {
- public void getHelp(AccessibleEvent e) {
- e.result = getToolTipText();
- }
- });
-
- getAccessible().addAccessibleControlListener(new AccessibleControlAdapter() {
- public void getChildAtPoint(AccessibleControlEvent e) {
- Point testPoint = toControl(new Point(e.x, e.y));
- if (getBounds().contains(testPoint)) {
- e.childID = ACC.CHILDID_SELF;
- }
- }
-
- public void getLocation(AccessibleControlEvent e) {
- Rectangle location = getBounds();
- Point pt = toDisplay(new Point(location.x, location.y));
- e.x = pt.x;
- e.y = pt.y;
- e.width = location.width;
- e.height = location.height;
- }
-
- public void getChildCount(AccessibleControlEvent e) {
- e.detail = 0;
- }
-
- public void getRole(AccessibleControlEvent e) {
- e.detail = ACC.ROLE_COMBOBOX;
- }
-
- public void getState(AccessibleControlEvent e) {
- e.detail = ACC.STATE_NORMAL;
- }
-
- public void getValue(AccessibleControlEvent e) {
- e.result = getText();
- }
- });
-}
-boolean isDropped () {
- return popup.getVisible ();
-}
-public boolean isFocusControl () {
- checkWidget();
- if (text.isFocusControl() || arrow.isFocusControl() || list.isFocusControl() || popup.isFocusControl()) {
- return true;
- } else {
- return super.isFocusControl();
- }
-}
-void internalLayout () {
- if (isDropped ()) dropDown (false);
-
- Rectangle rect = getClientArea();
- int width = rect.width;
- int height = rect.height;
- 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 itemHeight = list.getItemHeight () * ITEMS_SHOWING;
- Point listSize = list.computeSize (SWT.DEFAULT, itemHeight);
- list.setBounds (1, 1, Math.max (size.x - 2, listSize.x), listSize.y);
-}
-void listEvent (Event event) {
- switch (event.type) {
- case SWT.FocusIn: {
- if (hasFocus) return;
- hasFocus = true;
- if (getEditable ()) text.selectAll ();
- Event e = new Event();
- e.time = event.time;
- notifyListeners(SWT.FocusIn, e);
- break;
- }
- case SWT.FocusOut: {
- event.display.asyncExec(new Runnable() {
- public void run() {
- if (CCombo.this.isDisposed()) return;
- Control focusControl = getDisplay().getFocusControl();
- if (focusControl == text || focusControl == arrow) return;
- hasFocus = false;
- Event e = new Event();
- notifyListeners(SWT.FocusOut, e);
- }
- });
- break;
- }
- case SWT.MouseUp: {
- if (event.button != 1) return;
- dropDown (false);
- Event e = new Event();
- e.time = event.time;
- notifyListeners(SWT.DefaultSelection, e);
- break;
- }
- case SWT.Selection: {
- int index = list.getSelectionIndex ();
- if (index == -1) return;
- text.setText (list.getItem (index));
- text.selectAll ();
- list.setSelection(index);
- Event e = new Event();
- e.time = event.time;
- e.stateMask = event.stateMask;
- e.doit = event.doit;
- notifyListeners(SWT.Selection, e);
- event.doit = e.doit;
- break;
- }
- case SWT.Traverse: {
- switch (event.detail) {
- case SWT.TRAVERSE_TAB_NEXT:
- case SWT.TRAVERSE_RETURN:
- case SWT.TRAVERSE_ESCAPE:
- case SWT.TRAVERSE_ARROW_PREVIOUS:
- case SWT.TRAVERSE_ARROW_NEXT:
- event.doit = false;
- break;
- }
- 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;
- }
- case SWT.KeyUp: {
- Event e = new Event();
- e.time = event.time;
- e.character = event.character;
- e.keyCode = event.keyCode;
- e.stateMask = event.stateMask;
- notifyListeners(SWT.KeyUp, e);
- break;
- }
- case SWT.KeyDown: {
- if (event.character == SWT.ESC) {
- // escape key cancels popup list
- dropDown (false);
- }
- if (event.character == SWT.CR || event.character == '\t') {
- // Enter and Tab cause default selection
- dropDown (false);
- Event e = new Event();
- e.time = event.time;
- e.stateMask = event.stateMask;
- notifyListeners(SWT.DefaultSelection, e);
- }
- //At this point the widget may have been disposed.
- // If so, do not continue.
- if (isDisposed()) break;
- Event e = new Event();
- e.time = event.time;
- e.character = event.character;
- e.keyCode = event.keyCode;
- e.stateMask = event.stateMask;
- notifyListeners(SWT.KeyDown, e);
- break;
-
- }
- }
-}
-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) {
- checkWidget();
- 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) {
- checkWidget();
- 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) {
- checkWidget();
- 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) {
- checkWidget();
- 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 () {
- checkWidget();
- text.setText (""); //$NON-NLS-1$
- 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) {
- checkWidget();
- 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) {
- checkWidget();
- 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) {
- checkWidget();
- if (index == -1) {
- list.deselectAll ();
- text.setText (""); //$NON-NLS-1$
- return;
- }
- if (0 <= index && index < list.getItemCount()) {
- if (index != getSelectionIndex()) {
- text.setText (list.getItem (index));
- text.selectAll ();
- list.select (index);
- list.showSelection ();
- }
- }
-}
-public void setBackground (Color color) {
- super.setBackground(color);
- if (text != null) text.setBackground(color);
- if (list != null) list.setBackground(color);
- if (arrow != null) arrow.setBackground(color);
-}
-public boolean setFocus () {
- checkWidget();
- return text.setFocus ();
-}
-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) {
- checkWidget();
- 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) {
- checkWidget();
- if (items == null) SWT.error (SWT.ERROR_NULL_ARGUMENT);
- int style = getStyle();
- if ((style & SWT.READ_ONLY) != 0) text.setText (""); //$NON-NLS-1$
- 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) {
- checkWidget();
- 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) {
- checkWidget();
- if (string == null) SWT.error (SWT.ERROR_NULL_ARGUMENT);
- int index = list.indexOf (string);
- if (index == -1) {
- list.deselectAll ();
- text.setText (string);
- return;
- }
- text.setText (string);
- text.selectAll ();
- list.setSelection (index);
- list.showSelection ();
-}
-/**
-* Sets the 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) {
- checkWidget();
- text.setTextLimit (limit);
-}
-
-public void setToolTipText (String string) {
- checkWidget();
- super.setToolTipText(string);
- arrow.setToolTipText (string);
- text.setToolTipText (string);
-}
-
-public void setVisible (boolean visible) {
- super.setVisible(visible);
- if (!visible) popup.setVisible(false);
-}
-
-void textEvent (Event event) {
- switch (event.type) {
- case SWT.FocusIn: {
- if (hasFocus) return;
- hasFocus = true;
- if (getEditable ()) text.selectAll ();
- Event e = new Event();
- e.time = event.time;
- notifyListeners(SWT.FocusIn, e);
- break;
- }
- case SWT.FocusOut: {
- event.display.asyncExec(new Runnable() {
- public void run() {
- if (CCombo.this.isDisposed()) return;
- Control focusControl = getDisplay().getFocusControl();
- if (focusControl == list || focusControl == arrow) return;
- hasFocus = false;
- Event e = new Event();
- notifyListeners(SWT.FocusOut, e);
- }
- });
- break;
- }
- case SWT.KeyDown: {
-
- if (event.character == SWT.ESC) { // escape key cancels popup list
- dropDown (false);
- }
- if (event.character == SWT.CR) {
- dropDown (false);
- Event e = new Event();
- e.time = event.time;
- e.stateMask = event.stateMask;
- notifyListeners(SWT.DefaultSelection, e);
- }
- //At this point the widget may have been disposed.
- // If so, do not continue.
- if (isDisposed()) break;
-
- 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;
- e.stateMask = event.stateMask;
- notifyListeners(SWT.Selection, e);
- }
- //At this point the widget may have been disposed.
- // If so, do not continue.
- if (isDisposed()) break;
- }
-
- // 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.Traverse: {
- switch (event.detail) {
- case SWT.TRAVERSE_RETURN:
- case SWT.TRAVERSE_ARROW_PREVIOUS:
- case SWT.TRAVERSE_ARROW_NEXT:
- // The enter causes default selection and
- // the arrow keys are used to manipulate the list contents so
- // do not use them for traversal.
- event.doit = false;
- break;
- }
-
- 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;
- }
- }
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+import org.eclipse.swt.*;
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.events.*;
+import org.eclipse.swt.widgets.*;
+import org.eclipse.swt.accessibility.*;
+
+/**
+ * The CCombo class represents a selectable user interface object
+ * that combines a text field and a list and issues notificiation
+ * when an item is selected from the list.
+ * <p>
+ * Note that although this class is a subclass of <code>Composite</code>,
+ * it does not make sense to add children to it, or set a layout on it.
+ * </p>
+ * <dl>
+ * <dt><b>Styles:</b>
+ * <dd>BORDER, READ_ONLY, FLAT</dd>
+ * <dt><b>Events:</b>
+ * <dd>Selection</dd>
+ * </dl>
+ */
+public final class CCombo extends Composite {
+
+ static final int ITEMS_SHOWING = 5;
+
+ Text text;
+ List list;
+ Shell popup;
+ Button arrow;
+ boolean hasFocus;
+
+/**
+ * Constructs a new instance of this class given its parent
+ * and a style value describing its behavior and appearance.
+ * <p>
+ * The style value is either one of the style constants defined in
+ * class <code>SWT</code> which is applicable to instances of this
+ * class, or must be built by <em>bitwise OR</em>'ing together
+ * (that is, using the <code>int</code> "|" operator) two or more
+ * of those <code>SWT</code> style constants. The class description
+ * lists the style constants that are applicable to the class.
+ * Style bits are also inherited from superclasses.
+ * </p>
+ *
+ * @param parent a widget which will be the parent of the new instance (cannot be null)
+ * @param style the style of widget to construct
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
+ * </ul>
+ *
+ * @see SWT#BORDER
+ * @see SWT#READ_ONLY
+ * @see SWT#FLAT
+ * @see Widget#getStyle
+ */
+public CCombo (Composite parent, int style) {
+ super (parent, 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.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 [] comboEvents = {SWT.Dispose, SWT.Move, SWT.Resize};
+ for (int i=0; i<comboEvents.length; i++) this.addListener (comboEvents [i], listener);
+
+ 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.Traverse, SWT.FocusIn, SWT.FocusOut};
+ for (int i=0; i<textEvents.length; i++) text.addListener (textEvents [i], listener);
+
+ int [] listEvents = {SWT.MouseUp, SWT.Selection, SWT.Traverse, SWT.KeyDown, SWT.KeyUp, SWT.FocusIn, SWT.FocusOut};
+ for (int i=0; i<listEvents.length; i++) list.addListener (listEvents [i], listener);
+
+ int [] arrowEvents = {SWT.Selection, SWT.FocusIn, SWT.FocusOut};
+ for (int i=0; i<arrowEvents.length; i++) arrow.addListener (arrowEvents [i], listener);
+
+ initAccessible();
+}
+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) {
+ checkWidget();
+ 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) {
+ checkWidget();
+ 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) {;
+ checkWidget();
+ 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) {
+ checkWidget();
+ 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) {
+ switch (event.type) {
+ case SWT.FocusIn: {
+ if (hasFocus) return;
+ hasFocus = true;
+ if (getEditable ()) text.selectAll ();
+ Event e = new Event();
+ e.time = event.time;
+ notifyListeners(SWT.FocusIn, e);
+ break;
+ }
+ case SWT.FocusOut: {
+ event.display.asyncExec(new Runnable() {
+ public void run() {
+ if (CCombo.this.isDisposed()) return;
+ Control focusControl = getDisplay().getFocusControl();
+ if (focusControl == list || focusControl == text) return;
+ hasFocus = false;
+ Event e = new Event();
+ notifyListeners(SWT.FocusOut, e);
+ }
+ });
+ break;
+ }
+ case SWT.Selection: {
+ dropDown (!isDropped ());
+ break;
+ }
+ }
+}
+/**
+* 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 () {
+ checkWidget();
+ 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) {
+ checkWidget();
+ 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);
+ 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) {
+ checkWidget();
+ 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 () {
+ checkWidget();
+ list.deselectAll ();
+}
+void dropDown (boolean drop) {
+ if (drop == isDropped ()) return;
+ if (!drop) {
+ popup.setVisible (false);
+ text.setFocus();
+ return;
+ }
+ int index = list.getSelectionIndex ();
+ if (index != -1) list.setTopIndex (index);
+ Rectangle listRect = list.getBounds ();
+ Point point = getParent().toDisplay (getLocation ());
+ Point comboSize = getSize();
+ int width = Math.max (comboSize.x, listRect.width + 2);
+ popup.setBounds (point.x, point.y + comboSize.y, width, listRect.height + 2);
+ popup.setVisible (true);
+ list.setFocus();
+}
+public Control [] getChildren () {
+ checkWidget();
+ 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) {
+ checkWidget();
+ 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 () {
+ checkWidget();
+ 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 () {
+ checkWidget();
+ 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 () {
+ checkWidget();
+ 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 () {
+ checkWidget();
+ 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 () {
+ checkWidget();
+ 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 () {
+ checkWidget();
+ 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 () {
+ checkWidget();
+ 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 () {
+ checkWidget();
+ 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) {
+ checkWidget();
+ 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) {
+ checkWidget();
+ if (string == null) SWT.error (SWT.ERROR_NULL_ARGUMENT);
+ return list.indexOf (string, start);
+}
+
+void initAccessible() {
+ getAccessible().addAccessibleListener(new AccessibleAdapter() {
+ public void getHelp(AccessibleEvent e) {
+ e.result = getToolTipText();
+ }
+ });
+
+ getAccessible().addAccessibleControlListener(new AccessibleControlAdapter() {
+ public void getChildAtPoint(AccessibleControlEvent e) {
+ Point testPoint = toControl(new Point(e.x, e.y));
+ if (getBounds().contains(testPoint)) {
+ e.childID = ACC.CHILDID_SELF;
+ }
+ }
+
+ public void getLocation(AccessibleControlEvent e) {
+ Rectangle location = getBounds();
+ Point pt = toDisplay(new Point(location.x, location.y));
+ e.x = pt.x;
+ e.y = pt.y;
+ e.width = location.width;
+ e.height = location.height;
+ }
+
+ public void getChildCount(AccessibleControlEvent e) {
+ e.detail = 0;
+ }
+
+ public void getRole(AccessibleControlEvent e) {
+ e.detail = ACC.ROLE_COMBOBOX;
+ }
+
+ public void getState(AccessibleControlEvent e) {
+ e.detail = ACC.STATE_NORMAL;
+ }
+
+ public void getValue(AccessibleControlEvent e) {
+ e.result = getText();
+ }
+ });
+}
+boolean isDropped () {
+ return popup.getVisible ();
+}
+public boolean isFocusControl () {
+ checkWidget();
+ if (text.isFocusControl() || arrow.isFocusControl() || list.isFocusControl() || popup.isFocusControl()) {
+ return true;
+ } else {
+ return super.isFocusControl();
+ }
+}
+void internalLayout () {
+ if (isDropped ()) dropDown (false);
+
+ Rectangle rect = getClientArea();
+ int width = rect.width;
+ int height = rect.height;
+ 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 itemHeight = list.getItemHeight () * ITEMS_SHOWING;
+ Point listSize = list.computeSize (SWT.DEFAULT, itemHeight);
+ list.setBounds (1, 1, Math.max (size.x - 2, listSize.x), listSize.y);
+}
+void listEvent (Event event) {
+ switch (event.type) {
+ case SWT.FocusIn: {
+ if (hasFocus) return;
+ hasFocus = true;
+ if (getEditable ()) text.selectAll ();
+ Event e = new Event();
+ e.time = event.time;
+ notifyListeners(SWT.FocusIn, e);
+ break;
+ }
+ case SWT.FocusOut: {
+ event.display.asyncExec(new Runnable() {
+ public void run() {
+ if (CCombo.this.isDisposed()) return;
+ Control focusControl = getDisplay().getFocusControl();
+ if (focusControl == text || focusControl == arrow) return;
+ hasFocus = false;
+ Event e = new Event();
+ notifyListeners(SWT.FocusOut, e);
+ }
+ });
+ break;
+ }
+ case SWT.MouseUp: {
+ if (event.button != 1) return;
+ dropDown (false);
+ Event e = new Event();
+ e.time = event.time;
+ notifyListeners(SWT.DefaultSelection, e);
+ break;
+ }
+ case SWT.Selection: {
+ int index = list.getSelectionIndex ();
+ if (index == -1) return;
+ text.setText (list.getItem (index));
+ text.selectAll ();
+ list.setSelection(index);
+ Event e = new Event();
+ e.time = event.time;
+ e.stateMask = event.stateMask;
+ e.doit = event.doit;
+ notifyListeners(SWT.Selection, e);
+ event.doit = e.doit;
+ break;
+ }
+ case SWT.Traverse: {
+ switch (event.detail) {
+ case SWT.TRAVERSE_TAB_NEXT:
+ case SWT.TRAVERSE_RETURN:
+ case SWT.TRAVERSE_ESCAPE:
+ case SWT.TRAVERSE_ARROW_PREVIOUS:
+ case SWT.TRAVERSE_ARROW_NEXT:
+ event.doit = false;
+ break;
+ }
+ 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;
+ }
+ case SWT.KeyUp: {
+ Event e = new Event();
+ e.time = event.time;
+ e.character = event.character;
+ e.keyCode = event.keyCode;
+ e.stateMask = event.stateMask;
+ notifyListeners(SWT.KeyUp, e);
+ break;
+ }
+ case SWT.KeyDown: {
+ if (event.character == SWT.ESC) {
+ // escape key cancels popup list
+ dropDown (false);
+ }
+ if (event.character == SWT.CR || event.character == '\t') {
+ // Enter and Tab cause default selection
+ dropDown (false);
+ Event e = new Event();
+ e.time = event.time;
+ e.stateMask = event.stateMask;
+ notifyListeners(SWT.DefaultSelection, e);
+ }
+ //At this point the widget may have been disposed.
+ // If so, do not continue.
+ if (isDisposed()) break;
+ Event e = new Event();
+ e.time = event.time;
+ e.character = event.character;
+ e.keyCode = event.keyCode;
+ e.stateMask = event.stateMask;
+ notifyListeners(SWT.KeyDown, e);
+ break;
+
+ }
+ }
+}
+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) {
+ checkWidget();
+ 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) {
+ checkWidget();
+ 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) {
+ checkWidget();
+ 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) {
+ checkWidget();
+ 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 () {
+ checkWidget();
+ text.setText (""); //$NON-NLS-1$
+ 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) {
+ checkWidget();
+ 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) {
+ checkWidget();
+ 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) {
+ checkWidget();
+ if (index == -1) {
+ list.deselectAll ();
+ text.setText (""); //$NON-NLS-1$
+ return;
+ }
+ if (0 <= index && index < list.getItemCount()) {
+ if (index != getSelectionIndex()) {
+ text.setText (list.getItem (index));
+ text.selectAll ();
+ list.select (index);
+ list.showSelection ();
+ }
+ }
+}
+public void setBackground (Color color) {
+ super.setBackground(color);
+ if (text != null) text.setBackground(color);
+ if (list != null) list.setBackground(color);
+ if (arrow != null) arrow.setBackground(color);
+}
+public boolean setFocus () {
+ checkWidget();
+ return text.setFocus ();
+}
+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) {
+ checkWidget();
+ 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) {
+ checkWidget();
+ if (items == null) SWT.error (SWT.ERROR_NULL_ARGUMENT);
+ int style = getStyle();
+ if ((style & SWT.READ_ONLY) != 0) text.setText (""); //$NON-NLS-1$
+ 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) {
+ checkWidget();
+ 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) {
+ checkWidget();
+ if (string == null) SWT.error (SWT.ERROR_NULL_ARGUMENT);
+ int index = list.indexOf (string);
+ if (index == -1) {
+ list.deselectAll ();
+ text.setText (string);
+ return;
+ }
+ text.setText (string);
+ text.selectAll ();
+ list.setSelection (index);
+ list.showSelection ();
+}
+/**
+* Sets the 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) {
+ checkWidget();
+ text.setTextLimit (limit);
+}
+
+public void setToolTipText (String string) {
+ checkWidget();
+ super.setToolTipText(string);
+ arrow.setToolTipText (string);
+ text.setToolTipText (string);
+}
+
+public void setVisible (boolean visible) {
+ super.setVisible(visible);
+ if (!visible) popup.setVisible(false);
+}
+
+void textEvent (Event event) {
+ switch (event.type) {
+ case SWT.FocusIn: {
+ if (hasFocus) return;
+ hasFocus = true;
+ if (getEditable ()) text.selectAll ();
+ Event e = new Event();
+ e.time = event.time;
+ notifyListeners(SWT.FocusIn, e);
+ break;
+ }
+ case SWT.FocusOut: {
+ event.display.asyncExec(new Runnable() {
+ public void run() {
+ if (CCombo.this.isDisposed()) return;
+ Control focusControl = getDisplay().getFocusControl();
+ if (focusControl == list || focusControl == arrow) return;
+ hasFocus = false;
+ Event e = new Event();
+ notifyListeners(SWT.FocusOut, e);
+ }
+ });
+ break;
+ }
+ case SWT.KeyDown: {
+
+ if (event.character == SWT.ESC) { // escape key cancels popup list
+ dropDown (false);
+ }
+ if (event.character == SWT.CR) {
+ dropDown (false);
+ Event e = new Event();
+ e.time = event.time;
+ e.stateMask = event.stateMask;
+ notifyListeners(SWT.DefaultSelection, e);
+ }
+ //At this point the widget may have been disposed.
+ // If so, do not continue.
+ if (isDisposed()) break;
+
+ 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;
+ e.stateMask = event.stateMask;
+ notifyListeners(SWT.Selection, e);
+ }
+ //At this point the widget may have been disposed.
+ // If so, do not continue.
+ if (isDisposed()) break;
+ }
+
+ // 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.Traverse: {
+ switch (event.detail) {
+ case SWT.TRAVERSE_RETURN:
+ case SWT.TRAVERSE_ARROW_PREVIOUS:
+ case SWT.TRAVERSE_ARROW_NEXT:
+ // The enter causes default selection and
+ // the arrow keys are used to manipulate the list contents so
+ // do not use them for traversal.
+ event.doit = false;
+ break;
+ }
+
+ 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;
+ }
+ }
+}
}
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
index eba4c43e10..62576ceb0a 100755
--- 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
@@ -1,611 +1,611 @@
-package org.eclipse.swt.custom;
-
-/*
+package org.eclipse.swt.custom;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-import org.eclipse.swt.*;
-import org.eclipse.swt.widgets.*;
-import org.eclipse.swt.graphics.*;
-import org.eclipse.swt.events.*;
-import org.eclipse.swt.accessibility.*;
-
-/**
- * A Label which supports aligned text and/or an image and different border styles.
- * <p>
- * If there is not enough space a CLabel uses the following strategy to fit the
- * information into the available space:
- * <pre>
- * ignores the indent in left align mode
- * ignores the image and the gap
- * shortens the text by replacing the center portion of the label with an ellipsis
- * shortens the text by removing the center portion of the label
- * </pre>
- * <p>
- * <dl>
- * <dt><b>Styles:</b>
- * <dd>LEFT, RIGHT, CENTER, SHADOW_IN, SHADOW_OUT, SHADOW_NONE</dd>
- * <dt><b>Events:</b>
- * <dd></dd>
- * </dl>
- */
-public class CLabel extends Canvas {
-
- /** Gap between icon and text */
- private static final int GAP = 5;
- /** Left and right margins */
- private static final int INDENT = 3;
- /** a string inserted in the middle of text that has been shortened */
- private static final String ellipsis = "..."; //$NON-NLS-1$
- /** the alignment. Either CENTER, RIGHT, LEFT. Default is LEFT*/
- private int align = SWT.LEFT;
- private int hIndent = INDENT;
- private int vIndent = INDENT;
- /** the current text */
- private String text;
- /** the current icon */
- private Image image;
- // The tooltip is used for two purposes - the application can set
- // a tooltip or the tooltip can be used to display the full text when the
- // the text has been truncated due to the label being too short.
- // The appToolTip stores the tooltip set by the application. Control.tooltiptext
- // contains whatever tooltip is currently being displayed.
- private String appToolTipText;
-
- private Image backgroundImage;
- private Color[] gradientColors;
- private int[] gradientPercents;
-
-/**
- * Constructs a new instance of this class given its parent
- * and a style value describing its behavior and appearance.
- * <p>
- * The style value is either one of the style constants defined in
- * class <code>SWT</code> which is applicable to instances of this
- * class, or must be built by <em>bitwise OR</em>'ing together
- * (that is, using the <code>int</code> "|" operator) two or more
- * of those <code>SWT</code> style constants. The class description
- * lists the style constants that are applicable to the class.
- * Style bits are also inherited from superclasses.
- * </p>
- *
- * @param parent a widget which will be the parent of the new instance (cannot be null)
- * @param style the style of widget to construct
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
- * </ul>
- *
- * @see SWT#LEFT
- * @see SWT#RIGHT
- * @see SWT#CENTER
- * @see SWT#SHADOW_IN
- * @see SWT#SHADOW_OUT
- * @see SWT#SHADOW_NONE
- * @see #getStyle
- */
-public CLabel(Composite parent, int style) {
- super(parent, checkStyle(style));
-
- if ((style & SWT.CENTER) != 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);
- }
- });
-
- initAccessible();
-
-}
-/**
- * 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;
- //TEMPORARY CODE
- /*
- * The default background on carbon and some GTK themes is not a solid color
- * but a texture. To show the correct default background, we must allow
- * the operating system to draw it and therefore, we can not use the
- * NO_BACKGROUND style. The NO_BACKGROUND style is not required on platforms
- * that use double buffering which is true in both of these cases.
- */
- String platform = SWT.getPlatform();
- if ("carbon".equals(platform) || "gtk".equals(platform)) return style; //$NON-NLS-1$ //$NON-NLS-2$
- return style | SWT.NO_BACKGROUND;
-}
-public Point computeSize(int wHint, int hHint, boolean changed) {
- checkWidget();
- Point e = getTotalSize(image, text);
- if (wHint == SWT.DEFAULT){
- e.x += 2*hIndent;
- } else {
- e.x = wHint;
- }
- if (hHint == SWT.DEFAULT) {
- e.y += 2*vIndent;
- } else {
- e.y = hHint;
- }
- return e;
-}
-/**
- * Draw a rectangle in the given colors.
- */
-private void drawBevelRect(GC gc, int x, int y, int w, int h, Color topleft, Color bottomright) {
- gc.setForeground(bottomright);
- gc.drawLine(x+w, y, x+w, y+h);
- gc.drawLine(x, y+h, x+w, y+h);
-
- gc.setForeground(topleft);
- gc.drawLine(x, y, x+w-1, y);
- gc.drawLine(x, y, x, y+h-1);
-}
-/**
- * Returns the alignment.
- * The alignment style (LEFT, CENTER or RIGHT) is returned.
- *
- * @return SWT.LEFT, SWT.RIGHT or SWT.CENTER
- */
-public int getAlignment() {
- //checkWidget();
- return align;
-}
-/**
- * Return the CLabel's image or <code>null</code>.
- *
- * @return the image of the label or null
- */
-public Image getImage() {
- //checkWidget();
- return image;
-}
-/**
- * Compute the minimum size.
- */
-private Point getTotalSize(Image image, String text) {
- Point size = new Point(0, 0);
-
- if (image != null) {
- Rectangle r = image.getBounds();
- size.x += r.width;
- size.y += r.height;
- }
-
- GC gc = new GC(this);
- if (text != null && text.length() > 0) {
- Point e = gc.textExtent(text);
- 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.
- *
- * @return the text of the label or null
- */
-public String getText() {
- //checkWidget();
- return text;
-}
-public String getToolTipText () {
- checkWidget();
- 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 initAccessible() {
- Accessible accessible = getAccessible();
- accessible.addAccessibleListener(new AccessibleAdapter() {
- public void getName(AccessibleEvent e) {
- e.result = getText();
- }
-
- public void getHelp(AccessibleEvent e) {
- e.result = getToolTipText();
- }
- });
-
- accessible.addAccessibleControlListener(new AccessibleControlAdapter() {
- public void getChildAtPoint(AccessibleControlEvent e) {
- Point pt = toControl(new Point(e.x, e.y));
- e.childID = (getBounds().contains(pt)) ? ACC.CHILDID_SELF : ACC.CHILDID_NONE;
- }
-
- public void getLocation(AccessibleControlEvent e) {
- Rectangle location = getBounds();
- Point pt = toDisplay(new Point(location.x, location.y));
- e.x = pt.x;
- e.y = pt.y;
- e.width = location.width;
- e.height = location.height;
- }
-
- public void getChildCount(AccessibleControlEvent e) {
- e.detail = 0;
- }
-
- public void getRole(AccessibleControlEvent e) {
- e.detail = ACC.ROLE_LABEL;
- }
-
- public void getState(AccessibleControlEvent e) {
- e.detail = ACC.STATE_READONLY;
- }
- });
-}
-private void onDispose(DisposeEvent event) {
- gradientColors = null;
- gradientPercents = null;
- backgroundImage = null;
- text = null;
- image = null;
- appToolTipText = 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 img = image;
- int availableWidth = rect.width - 2*hIndent;
- Point extent = getTotalSize(img, t);
- if (extent.x > availableWidth) {
- img = null;
- extent = getTotalSize(img, t);
- if (extent.x > availableWidth) {
- shortenText = true;
- }
- }
-
- GC gc = event.gc;
-
- // shorten the text
- if (shortenText) {
- t = shortenText(gc, text, availableWidth);
- extent = getTotalSize(img, 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
- try {
- if (backgroundImage != null) {
- // draw a background image behind the text
- Rectangle imageRect = backgroundImage.getBounds();
- gc.drawImage(backgroundImage, 0, 0, imageRect.width, imageRect.height,
- 0, 0, rect.width, rect.height);
- } else if (gradientColors != null) {
- // draw a gradient behind the text
- final Color oldBackground = gc.getBackground();
- if (gradientColors.length == 1) {
- if (gradientColors[0] != null) gc.setBackground(gradientColors[0]);
- gc.fillRectangle(0, 0, rect.width, rect.height);
- } else {
- final Color oldForeground = gc.getForeground();
- Color lastColor = gradientColors[0];
- if (lastColor == null) lastColor = oldBackground;
- for (int i = 0, pos = 0; i < gradientPercents.length; ++i) {
- gc.setForeground(lastColor);
- lastColor = gradientColors[i + 1];
- if (lastColor == null) lastColor = oldBackground;
- gc.setBackground(lastColor);
- final int gradientWidth = (gradientPercents[i] * rect.width / 100) - pos;
- gc.fillGradientRectangle(pos, 0, gradientWidth, rect.height, false);
- pos += gradientWidth;
- }
- gc.setForeground(oldForeground);
- }
- gc.setBackground(oldBackground);
- } else {
- if ((getStyle() & SWT.NO_BACKGROUND) != 0) {
- gc.setBackground(getBackground());
- gc.fillRectangle(rect);
- }
- }
- } catch (SWTException e) {
- if ((getStyle() & SWT.NO_BACKGROUND) != 0) {
- gc.setBackground(getBackground());
- gc.fillRectangle(rect);
- }
- }
-
- // draw border
- int style = getStyle();
- if ((style & SWT.SHADOW_IN) != 0 || (style & SWT.SHADOW_OUT) != 0) {
- paintBorder(gc, rect);
- }
- // draw the image
- if (img != null) {
- Rectangle imageRect = img.getBounds();
- gc.drawImage(img, 0, 0, imageRect.width, imageRect.height,
- x, (rect.height-imageRect.height)/2, imageRect.width, imageRect.height);
- x += imageRect.width + GAP;
- }
- // 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.
- *
- * @param align the alignment style of LEFT, RIGHT or CENTER
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * <li>ERROR_INVALID_ARGUMENT - if the value of align is not one of SWT.LEFT, SWT.RIGHT or SWT.CENTER</li>
- * </ul>
- */
-public void setAlignment(int align) {
- checkWidget();
- if (align != SWT.LEFT && align != SWT.RIGHT && align != SWT.CENTER) {
- SWT.error(SWT.ERROR_INVALID_ARGUMENT);
- }
- if (this.align != align) {
- this.align = align;
- redraw();
- }
-}
-
-public void setBackground (Color color) {
- super.setBackground (color);
- // Are these settings the same as before?
- if (color != null && backgroundImage == null &&
- gradientColors == null && gradientPercents == null) {
- Color background = getBackground();
- if (color.equals(background)) {
- return;
- }
- }
- backgroundImage = null;
- gradientColors = null;
- gradientPercents = null;
- redraw ();
-}
-
-/**
- * Specify a gradient of colours to be drawn in the background of the CLabel.
- * <p>For example, to draw a gradient that varies from dark blue to blue and then to
- * white and stays white for the right hald of the label, use the following call
- * to setBackground:</p>
- * <pre>
- * clabel.setBackground(new Color[]{display.getSystemColor(SWT.COLOR_DARK_BLUE),
- * display.getSystemColor(SWT.COLOR_BLUE),
- * display.getSystemColor(SWT.COLOR_WHITE),
- * display.getSystemColor(SWT.COLOR_WHITE)},
- * new int[] {25, 50, 100});
- * </pre>
- *
- * @param colors an array of Color that specifies the colors to appear in the gradient
- * in order of appearance from left to right; The value <code>null</code>
- * clears the background gradient; the value <code>null</code> can be used
- * inside the array of Color to specify the background color.
- * @param percents an array of integers between 0 and 100 specifying the percent of the width
- * of the widget at which the color should change; the size of the percents
- * array must be one less than the size of the colors array.
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * <li>ERROR_INVALID_ARGUMENT - if the values of colors and percents are not consistant</li>
- * </ul>
- */
-public void setBackground(Color[] colors, int[] percents) {
- checkWidget();
- if (colors != null) {
- if (percents == null || percents.length != colors.length - 1) {
- SWT.error(SWT.ERROR_INVALID_ARGUMENT);
- }
- if (getDisplay().getDepth() < 15) {
- // Don't use gradients on low color displays
- colors = new Color[] { colors[0] };
- percents = new int[] { };
- }
- for (int i = 0; i < percents.length; i++) {
- if (percents[i] < 0 || percents[i] > 100) {
- SWT.error(SWT.ERROR_INVALID_ARGUMENT);
- }
- if (i > 0 && percents[i] < percents[i-1]) {
- SWT.error(SWT.ERROR_INVALID_ARGUMENT);
- }
- }
- }
-
- // Are these settings the same as before?
- final Color background = getBackground();
- if (backgroundImage == null) {
- if ((gradientColors != null) && (colors != null) &&
- (gradientColors.length == colors.length)) {
- boolean same = false;
- for (int i = 0; i < gradientColors.length; i++) {
- same = (gradientColors[i] == colors[i]) ||
- ((gradientColors[i] == null) && (colors[i] == background)) ||
- ((gradientColors[i] == background) && (colors[i] == null));
- if (!same) break;
- }
- if (same) {
- for (int i = 0; i < gradientPercents.length; i++) {
- same = gradientPercents[i] == percents[i];
- if (!same) break;
- }
- }
- if (same) return;
- }
- } else {
- backgroundImage = null;
- }
- // Store the new settings
- if (colors == null) {
- gradientColors = null;
- gradientPercents = null;
- } else {
- gradientColors = new Color[colors.length];
- for (int i = 0; i < colors.length; ++i)
- gradientColors[i] = (colors[i] != null) ? colors[i] : background;
- gradientPercents = new int[percents.length];
- for (int i = 0; i < percents.length; ++i)
- gradientPercents[i] = percents[i];
- }
- // Refresh with the new settings
- redraw();
-}
-/**
- * Set the image to be drawn in the background of the label.
- *
- * @param image the image to be drawn in the background
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public void setBackground(Image image) {
- checkWidget();
- if (image == backgroundImage) return;
- if (image != null) {
- gradientColors = null;
- gradientPercents = null;
- }
- backgroundImage = image;
- redraw();
-
-}
-public void setFont(Font font) {
- super.setFont(font);
- redraw();
-}
-/**
- * Set the label's Image.
- * The value <code>null</code> clears it.
- *
- * @param image the image to be displayed in the label or null
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public void setImage(Image image) {
- checkWidget();
- if (image != this.image) {
- this.image = image;
- redraw();
- }
-}
-/**
- * Set the label's text.
- * The value <code>null</code> clears it.
- *
- * @param text the text to be displayed in the label or null
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public void setText(String text) {
- checkWidget();
- if (text == null) text = ""; //$NON-NLS-1$
- if (! text.equals(this.text)) {
- this.text = text;
- redraw();
- }
-}
-/**
- * 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) {
- if (t == null) return null;
- 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;
-}
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+import org.eclipse.swt.*;
+import org.eclipse.swt.widgets.*;
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.events.*;
+import org.eclipse.swt.accessibility.*;
+
+/**
+ * A Label which supports aligned text and/or an image and different border styles.
+ * <p>
+ * If there is not enough space a CLabel uses the following strategy to fit the
+ * information into the available space:
+ * <pre>
+ * ignores the indent in left align mode
+ * ignores the image and the gap
+ * shortens the text by replacing the center portion of the label with an ellipsis
+ * shortens the text by removing the center portion of the label
+ * </pre>
+ * <p>
+ * <dl>
+ * <dt><b>Styles:</b>
+ * <dd>LEFT, RIGHT, CENTER, SHADOW_IN, SHADOW_OUT, SHADOW_NONE</dd>
+ * <dt><b>Events:</b>
+ * <dd></dd>
+ * </dl>
+ */
+public class CLabel extends Canvas {
+
+ /** Gap between icon and text */
+ private static final int GAP = 5;
+ /** Left and right margins */
+ private static final int INDENT = 3;
+ /** a string inserted in the middle of text that has been shortened */
+ private static final String ellipsis = "..."; //$NON-NLS-1$
+ /** the alignment. Either CENTER, RIGHT, LEFT. Default is LEFT*/
+ private int align = SWT.LEFT;
+ private int hIndent = INDENT;
+ private int vIndent = INDENT;
+ /** the current text */
+ private String text;
+ /** the current icon */
+ private Image image;
+ // The tooltip is used for two purposes - the application can set
+ // a tooltip or the tooltip can be used to display the full text when the
+ // the text has been truncated due to the label being too short.
+ // The appToolTip stores the tooltip set by the application. Control.tooltiptext
+ // contains whatever tooltip is currently being displayed.
+ private String appToolTipText;
+
+ private Image backgroundImage;
+ private Color[] gradientColors;
+ private int[] gradientPercents;
+
+/**
+ * Constructs a new instance of this class given its parent
+ * and a style value describing its behavior and appearance.
+ * <p>
+ * The style value is either one of the style constants defined in
+ * class <code>SWT</code> which is applicable to instances of this
+ * class, or must be built by <em>bitwise OR</em>'ing together
+ * (that is, using the <code>int</code> "|" operator) two or more
+ * of those <code>SWT</code> style constants. The class description
+ * lists the style constants that are applicable to the class.
+ * Style bits are also inherited from superclasses.
+ * </p>
+ *
+ * @param parent a widget which will be the parent of the new instance (cannot be null)
+ * @param style the style of widget to construct
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
+ * </ul>
+ *
+ * @see SWT#LEFT
+ * @see SWT#RIGHT
+ * @see SWT#CENTER
+ * @see SWT#SHADOW_IN
+ * @see SWT#SHADOW_OUT
+ * @see SWT#SHADOW_NONE
+ * @see #getStyle
+ */
+public CLabel(Composite parent, int style) {
+ super(parent, checkStyle(style));
+
+ if ((style & SWT.CENTER) != 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);
+ }
+ });
+
+ initAccessible();
+
+}
+/**
+ * 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;
+ //TEMPORARY CODE
+ /*
+ * The default background on carbon and some GTK themes is not a solid color
+ * but a texture. To show the correct default background, we must allow
+ * the operating system to draw it and therefore, we can not use the
+ * NO_BACKGROUND style. The NO_BACKGROUND style is not required on platforms
+ * that use double buffering which is true in both of these cases.
+ */
+ String platform = SWT.getPlatform();
+ if ("carbon".equals(platform) || "gtk".equals(platform)) return style; //$NON-NLS-1$ //$NON-NLS-2$
+ return style | SWT.NO_BACKGROUND;
+}
+public Point computeSize(int wHint, int hHint, boolean changed) {
+ checkWidget();
+ Point e = getTotalSize(image, text);
+ if (wHint == SWT.DEFAULT){
+ e.x += 2*hIndent;
+ } else {
+ e.x = wHint;
+ }
+ if (hHint == SWT.DEFAULT) {
+ e.y += 2*vIndent;
+ } else {
+ e.y = hHint;
+ }
+ return e;
+}
+/**
+ * Draw a rectangle in the given colors.
+ */
+private void drawBevelRect(GC gc, int x, int y, int w, int h, Color topleft, Color bottomright) {
+ gc.setForeground(bottomright);
+ gc.drawLine(x+w, y, x+w, y+h);
+ gc.drawLine(x, y+h, x+w, y+h);
+
+ gc.setForeground(topleft);
+ gc.drawLine(x, y, x+w-1, y);
+ gc.drawLine(x, y, x, y+h-1);
+}
+/**
+ * Returns the alignment.
+ * The alignment style (LEFT, CENTER or RIGHT) is returned.
+ *
+ * @return SWT.LEFT, SWT.RIGHT or SWT.CENTER
+ */
+public int getAlignment() {
+ //checkWidget();
+ return align;
+}
+/**
+ * Return the CLabel's image or <code>null</code>.
+ *
+ * @return the image of the label or null
+ */
+public Image getImage() {
+ //checkWidget();
+ return image;
+}
+/**
+ * Compute the minimum size.
+ */
+private Point getTotalSize(Image image, String text) {
+ Point size = new Point(0, 0);
+
+ if (image != null) {
+ Rectangle r = image.getBounds();
+ size.x += r.width;
+ size.y += r.height;
+ }
+
+ GC gc = new GC(this);
+ if (text != null && text.length() > 0) {
+ Point e = gc.textExtent(text);
+ 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.
+ *
+ * @return the text of the label or null
+ */
+public String getText() {
+ //checkWidget();
+ return text;
+}
+public String getToolTipText () {
+ checkWidget();
+ 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 initAccessible() {
+ Accessible accessible = getAccessible();
+ accessible.addAccessibleListener(new AccessibleAdapter() {
+ public void getName(AccessibleEvent e) {
+ e.result = getText();
+ }
+
+ public void getHelp(AccessibleEvent e) {
+ e.result = getToolTipText();
+ }
+ });
+
+ accessible.addAccessibleControlListener(new AccessibleControlAdapter() {
+ public void getChildAtPoint(AccessibleControlEvent e) {
+ Point pt = toControl(new Point(e.x, e.y));
+ e.childID = (getBounds().contains(pt)) ? ACC.CHILDID_SELF : ACC.CHILDID_NONE;
+ }
+
+ public void getLocation(AccessibleControlEvent e) {
+ Rectangle location = getBounds();
+ Point pt = toDisplay(new Point(location.x, location.y));
+ e.x = pt.x;
+ e.y = pt.y;
+ e.width = location.width;
+ e.height = location.height;
+ }
+
+ public void getChildCount(AccessibleControlEvent e) {
+ e.detail = 0;
+ }
+
+ public void getRole(AccessibleControlEvent e) {
+ e.detail = ACC.ROLE_LABEL;
+ }
+
+ public void getState(AccessibleControlEvent e) {
+ e.detail = ACC.STATE_READONLY;
+ }
+ });
+}
+private void onDispose(DisposeEvent event) {
+ gradientColors = null;
+ gradientPercents = null;
+ backgroundImage = null;
+ text = null;
+ image = null;
+ appToolTipText = 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 img = image;
+ int availableWidth = rect.width - 2*hIndent;
+ Point extent = getTotalSize(img, t);
+ if (extent.x > availableWidth) {
+ img = null;
+ extent = getTotalSize(img, t);
+ if (extent.x > availableWidth) {
+ shortenText = true;
+ }
+ }
+
+ GC gc = event.gc;
+
+ // shorten the text
+ if (shortenText) {
+ t = shortenText(gc, text, availableWidth);
+ extent = getTotalSize(img, 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
+ try {
+ if (backgroundImage != null) {
+ // draw a background image behind the text
+ Rectangle imageRect = backgroundImage.getBounds();
+ gc.drawImage(backgroundImage, 0, 0, imageRect.width, imageRect.height,
+ 0, 0, rect.width, rect.height);
+ } else if (gradientColors != null) {
+ // draw a gradient behind the text
+ final Color oldBackground = gc.getBackground();
+ if (gradientColors.length == 1) {
+ if (gradientColors[0] != null) gc.setBackground(gradientColors[0]);
+ gc.fillRectangle(0, 0, rect.width, rect.height);
+ } else {
+ final Color oldForeground = gc.getForeground();
+ Color lastColor = gradientColors[0];
+ if (lastColor == null) lastColor = oldBackground;
+ for (int i = 0, pos = 0; i < gradientPercents.length; ++i) {
+ gc.setForeground(lastColor);
+ lastColor = gradientColors[i + 1];
+ if (lastColor == null) lastColor = oldBackground;
+ gc.setBackground(lastColor);
+ final int gradientWidth = (gradientPercents[i] * rect.width / 100) - pos;
+ gc.fillGradientRectangle(pos, 0, gradientWidth, rect.height, false);
+ pos += gradientWidth;
+ }
+ gc.setForeground(oldForeground);
+ }
+ gc.setBackground(oldBackground);
+ } else {
+ if ((getStyle() & SWT.NO_BACKGROUND) != 0) {
+ gc.setBackground(getBackground());
+ gc.fillRectangle(rect);
+ }
+ }
+ } catch (SWTException e) {
+ if ((getStyle() & SWT.NO_BACKGROUND) != 0) {
+ gc.setBackground(getBackground());
+ gc.fillRectangle(rect);
+ }
+ }
+
+ // draw border
+ int style = getStyle();
+ if ((style & SWT.SHADOW_IN) != 0 || (style & SWT.SHADOW_OUT) != 0) {
+ paintBorder(gc, rect);
+ }
+ // draw the image
+ if (img != null) {
+ Rectangle imageRect = img.getBounds();
+ gc.drawImage(img, 0, 0, imageRect.width, imageRect.height,
+ x, (rect.height-imageRect.height)/2, imageRect.width, imageRect.height);
+ x += imageRect.width + GAP;
+ }
+ // 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.
+ *
+ * @param align the alignment style of LEFT, RIGHT or CENTER
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * <li>ERROR_INVALID_ARGUMENT - if the value of align is not one of SWT.LEFT, SWT.RIGHT or SWT.CENTER</li>
+ * </ul>
+ */
+public void setAlignment(int align) {
+ checkWidget();
+ if (align != SWT.LEFT && align != SWT.RIGHT && align != SWT.CENTER) {
+ SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+ }
+ if (this.align != align) {
+ this.align = align;
+ redraw();
+ }
+}
+
+public void setBackground (Color color) {
+ super.setBackground (color);
+ // Are these settings the same as before?
+ if (color != null && backgroundImage == null &&
+ gradientColors == null && gradientPercents == null) {
+ Color background = getBackground();
+ if (color.equals(background)) {
+ return;
+ }
+ }
+ backgroundImage = null;
+ gradientColors = null;
+ gradientPercents = null;
+ redraw ();
+}
+
+/**
+ * Specify a gradient of colours to be drawn in the background of the CLabel.
+ * <p>For example, to draw a gradient that varies from dark blue to blue and then to
+ * white and stays white for the right hald of the label, use the following call
+ * to setBackground:</p>
+ * <pre>
+ * clabel.setBackground(new Color[]{display.getSystemColor(SWT.COLOR_DARK_BLUE),
+ * display.getSystemColor(SWT.COLOR_BLUE),
+ * display.getSystemColor(SWT.COLOR_WHITE),
+ * display.getSystemColor(SWT.COLOR_WHITE)},
+ * new int[] {25, 50, 100});
+ * </pre>
+ *
+ * @param colors an array of Color that specifies the colors to appear in the gradient
+ * in order of appearance from left to right; The value <code>null</code>
+ * clears the background gradient; the value <code>null</code> can be used
+ * inside the array of Color to specify the background color.
+ * @param percents an array of integers between 0 and 100 specifying the percent of the width
+ * of the widget at which the color should change; the size of the percents
+ * array must be one less than the size of the colors array.
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * <li>ERROR_INVALID_ARGUMENT - if the values of colors and percents are not consistant</li>
+ * </ul>
+ */
+public void setBackground(Color[] colors, int[] percents) {
+ checkWidget();
+ if (colors != null) {
+ if (percents == null || percents.length != colors.length - 1) {
+ SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+ }
+ if (getDisplay().getDepth() < 15) {
+ // Don't use gradients on low color displays
+ colors = new Color[] { colors[0] };
+ percents = new int[] { };
+ }
+ for (int i = 0; i < percents.length; i++) {
+ if (percents[i] < 0 || percents[i] > 100) {
+ SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+ }
+ if (i > 0 && percents[i] < percents[i-1]) {
+ SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+ }
+ }
+ }
+
+ // Are these settings the same as before?
+ final Color background = getBackground();
+ if (backgroundImage == null) {
+ if ((gradientColors != null) && (colors != null) &&
+ (gradientColors.length == colors.length)) {
+ boolean same = false;
+ for (int i = 0; i < gradientColors.length; i++) {
+ same = (gradientColors[i] == colors[i]) ||
+ ((gradientColors[i] == null) && (colors[i] == background)) ||
+ ((gradientColors[i] == background) && (colors[i] == null));
+ if (!same) break;
+ }
+ if (same) {
+ for (int i = 0; i < gradientPercents.length; i++) {
+ same = gradientPercents[i] == percents[i];
+ if (!same) break;
+ }
+ }
+ if (same) return;
+ }
+ } else {
+ backgroundImage = null;
+ }
+ // Store the new settings
+ if (colors == null) {
+ gradientColors = null;
+ gradientPercents = null;
+ } else {
+ gradientColors = new Color[colors.length];
+ for (int i = 0; i < colors.length; ++i)
+ gradientColors[i] = (colors[i] != null) ? colors[i] : background;
+ gradientPercents = new int[percents.length];
+ for (int i = 0; i < percents.length; ++i)
+ gradientPercents[i] = percents[i];
+ }
+ // Refresh with the new settings
+ redraw();
+}
+/**
+ * Set the image to be drawn in the background of the label.
+ *
+ * @param image the image to be drawn in the background
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setBackground(Image image) {
+ checkWidget();
+ if (image == backgroundImage) return;
+ if (image != null) {
+ gradientColors = null;
+ gradientPercents = null;
+ }
+ backgroundImage = image;
+ redraw();
+
+}
+public void setFont(Font font) {
+ super.setFont(font);
+ redraw();
+}
+/**
+ * Set the label's Image.
+ * The value <code>null</code> clears it.
+ *
+ * @param image the image to be displayed in the label or null
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setImage(Image image) {
+ checkWidget();
+ if (image != this.image) {
+ this.image = image;
+ redraw();
+ }
+}
+/**
+ * Set the label's text.
+ * The value <code>null</code> clears it.
+ *
+ * @param text the text to be displayed in the label or null
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setText(String text) {
+ checkWidget();
+ if (text == null) text = ""; //$NON-NLS-1$
+ if (! text.equals(this.text)) {
+ this.text = text;
+ redraw();
+ }
+}
+/**
+ * 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) {
+ if (t == null) return null;
+ 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
index 7406e5a0f1..029413724f 100755
--- 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
@@ -1,2102 +1,2102 @@
-package org.eclipse.swt.custom;
-
-/*
+package org.eclipse.swt.custom;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-import org.eclipse.swt.*;
-import org.eclipse.swt.events.*;
-import org.eclipse.swt.graphics.*;
-import org.eclipse.swt.widgets.*;
-import org.eclipse.swt.accessibility.*;
-
-/**
- * Instances of this class implement the notebook user interface
- * metaphor. It allows the user to select a notebook page from
- * set of pages.
- * <p>
- * The item children that may be added to instances of this class
- * must be of type <code>CTabItem</code>.
- * <code>Control</code> children are created and then set into a
- * tab item using <code>CTabItem#setControl</code>.
- * </p><p>
- * Note that although this class is a subclass of <code>Composite</code>,
- * it does not make sense to set a layout on it.
- * </p><p>
- * <dl>
- * <dt><b>Styles:</b></dt>
- * <dd>TOP, BOTTOM, FLAT</dd>
- * <dt><b>Events:</b></dt>
- * <dd>Selection</dd>
- * <dd>"CTabFolder"</dd>
- * </dl>
- * <p>
- * Note: Only one of the styles TOP and BOTTOM
- * may be specified.
- * </p><p>
- * IMPORTANT: This class is <em>not</em> intended to be subclassed.
- * </p>
- */
-
-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 int MIN_TAB_WIDTH = 3;
-
- /* sizing, positioning */
- int xClient, yClient;
- boolean onBottom = false;
- boolean fixedTabHeight;
- int tabHeight;
-
- /* 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;
- Color[] gradientColors;
- int[] gradientPercents;
- Color selectionForeground;
- Color background;
-
- // internal constants
- private static final int DEFAULT_WIDTH = 64;
- private static final int DEFAULT_HEIGHT = 64;
-
- // scrolling arrows
- private ToolBar arrowBar;
- private Image arrowLeftImage;
- private Image arrowRightImage;
-
- private Control topRight;
-
- // close button
- boolean showClose = false;
- private Image closeImage;
- ToolBar closeBar;
- private ToolBar inactiveCloseBar;
- private CTabItem inactiveItem;
-
- // borders
- boolean showBorders = false;
- private int borderBottom = 0;
- private int borderLeft = 0;
- private int borderRight = 0;
- private int borderTop = 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 Point oldSize;
- private Font oldFont;
-
- // insertion marker
- int insertionIndex = -2; // Index of insert marker. Marker always shown after index.
- // -2 means no insert marker
-
- // tool tip
- private Shell tip;
- private Label label;
- private boolean showToolTip = false;
- private CTabItem toolTipItem;
-
-/**
- * Constructs a new instance of this class given its parent
- * and a style value describing its behavior and appearance.
- * <p>
- * The style value is either one of the style constants defined in
- * class <code>SWT</code> which is applicable to instances of this
- * class, or must be built by <em>bitwise OR</em>'ing together
- * (that is, using the <code>int</code> "|" operator) two or more
- * of those <code>SWT</code> style constants. The class description
- * lists the style constants that are applicable to the class.
- * Style bits are also inherited from superclasses.
- * </p>
- *
- * @param parent a widget which will be the parent of the new instance (cannot be null)
- * @param style the style of widget to construct
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
- * </ul>
- *
- * @see SWT#TOP
- * @see SWT#BOTTOM
- * @see SWT#FLAT
- * @see #getStyle
- */
-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);
-
- // tool tip support
- tip = new Shell (getShell(), SWT.ON_TOP);
- label = new Label (tip, SWT.CENTER);
-
- // Add all listeners
- Listener listener = new Listener() {
- public void handleEvent(Event event) {
- switch (event.type) {
- case SWT.Dispose: onDispose(); break;
- case SWT.Paint: onPaint(event); break;
- case SWT.Resize: onResize(); break;
- case SWT.MouseDoubleClick: onMouseDoubleClick(event); break;
- case SWT.MouseDown: onMouseDown(event); break;
- case SWT.MouseExit: onMouseExit(event); break;
- case SWT.MouseHover: onMouseHover(event); break;
- case SWT.MouseMove: onMouseMove(event); break;
- case SWT.FocusIn: onFocus(event); break;
- case SWT.FocusOut: onFocus(event); break;
- case SWT.KeyDown: onKeyDown(event); break;
- case SWT.Traverse: onTraverse(event); break;
- }
- }
- };
-
- int[] folderEvents = new int[]{
- SWT.Dispose,
- SWT.Paint,
- SWT.Resize,
- SWT.MouseDoubleClick,
- SWT.MouseDown,
- SWT.MouseExit,
- SWT.MouseHover,
- SWT.MouseMove,
- SWT.FocusIn,
- SWT.FocusOut,
- SWT.KeyDown,
- SWT.Traverse,
- };
- for (int i = 0; i < folderEvents.length; i++) {
- addListener(folderEvents[i], listener);
- }
-
- createArrowBar();
- createCloseBar();
-
- setBorderVisible((style & SWT.BORDER) != 0);
-
- initAccessible();
-
-}
-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) {
- checkWidget();
- if (listener == null) {
- SWT.error(SWT.ERROR_NULL_ARGUMENT);
- }
- TypedListener typedListener = new TypedListener(listener);
- addListener(SWT.Selection, typedListener);
- addListener(SWT.DefaultSelection, typedListener);
-}
-/**
- * Adds the listener to the collection of listeners who will
- * be notified when a tab item is closed.
- *
- * @param listener the listener which should be notified
- *
- * @exception IllegalArgumentException <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 - if the listener is null</li>
- * </ul>
- *
- * @see CTabFolderListener
- * @see #removeCTabFolderListener
- */
-public void addCTabFolderListener(CTabFolderListener listener) {
- checkWidget();
- if (listener == null) SWT.error (SWT.ERROR_NULL_ARGUMENT);
- // add to array
- CTabFolderListener[] newTabListeners = new CTabFolderListener[tabListeners.length + 1];
- System.arraycopy(tabListeners, 0, newTabListeners, 0, tabListeners.length);
- tabListeners = newTabListeners;
- tabListeners[tabListeners.length - 1] = listener;
- showClose = true;
- setButtonBounds();
-}
-private void closeNotify(CTabItem item, int time) {
- if (item == null) return;
-
- 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) {
- checkWidget();
- int minWidth = 0;
- int minHeight = 0;
-
- // preferred width of tab area to show all tabs
- GC gc = new GC(this);
- for (int i = 0; i < items.length; i++) {
- minWidth += items[i].preferredWidth(gc);
- }
- gc.dispose();
-
- // preferred size of controls in tab items
- for (int i = 0; i < items.length; i++) {
- Control control = items[i].getControl();
- if (control != null && !control.isDisposed()){
- Point size = control.computeSize (wHint, hHint);
- 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) {
- checkWidget();
- if (items.length == 0) {
- if (!showBorders) return new Rectangle(x, y, width, height);
- int trimX = x - borderRight - 1;
- int trimY = y - borderBottom - 1;
- int trimWidth = width + borderRight + 2;
- int trimHeight = height + borderBottom + 2;
- return new Rectangle (trimX, trimY, trimWidth, trimHeight);
- } else {
- int trimX = x - marginWidth - borderLeft;
- int trimY = y - marginHeight - tabHeight - borderTop - 1;
- // -1 is for the line at the bottom of the tabs
- if (onBottom) {
- trimY = y - marginHeight - borderTop;
- }
- int trimWidth = width + borderLeft + borderRight + 2*marginWidth;
- int trimHeight = height + borderTop + borderBottom + 2*marginHeight + tabHeight + 1;
- 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;
- resetTabSize(true);
- } else {
- setItemBounds();
- showItem(item);
- }
-
- if (items.length == 1) {
- redraw();
- } else {
- redrawTabArea(-1);
- }
-}
-
-private void createArrowBar() {
- // create arrow buttons for scrolling
- arrowBar = new ToolBar(this, SWT.FLAT);
- arrowBar.setVisible(false);
- arrowBar.setBackground(background);
- ToolItem scrollLeft = new ToolItem(arrowBar, SWT.PUSH);
- scrollLeft.setEnabled(false);
- ToolItem scrollRight = new ToolItem(arrowBar, SWT.PUSH);
- scrollRight.setEnabled(false);
-
- scrollLeft.addListener(SWT.Selection, new Listener() {
- public void handleEvent(Event event) {
- scroll_scrollLeft();
- }
- });
- scrollRight.addListener(SWT.Selection, new Listener() {
- public void handleEvent(Event event) {
- scroll_scrollRight();
- }
- });
-
-}
-private void createCloseBar() {
- closeBar = new ToolBar(this, SWT.FLAT);
- closeBar.setVisible(false);
- if (gradientColors != null && gradientColors.length > 0) {
- closeBar.setBackground(gradientColors[gradientColors.length - 1]);
- } else {
- closeBar.setBackground(background);
- }
- ToolItem closeItem = new ToolItem(closeBar, SWT.PUSH);
-
- inactiveCloseBar = new ToolBar(this, SWT.FLAT);
- inactiveCloseBar.setVisible(false);
- inactiveCloseBar.setBackground(background);
- ToolItem inactiveCloseItem = new ToolItem(inactiveCloseBar, SWT.PUSH);
-
- closeItem.addListener(SWT.Selection, new Listener() {
- public void handleEvent(Event event) {
- closeNotify(getSelection(), event.time);
- }
- });
- inactiveCloseItem.addListener(SWT.Selection, new Listener() {
- public void handleEvent(Event event) {
- closeNotify(inactiveItem, event.time);
- inactiveCloseBar.setVisible(false);
- inactiveItem = null;
- }
- });
- inactiveCloseBar.addListener (SWT.MouseExit, new Listener() {
- public void handleEvent(Event event) {
- if (inactiveItem != null) {
- Rectangle itemBounds = inactiveItem.getBounds();
- if (itemBounds.contains(event.x, event.y)) return;
- }
- inactiveCloseBar.setVisible(false);
- inactiveItem = null;
- }
- });
-
-}
-/**
- * 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);
- if (!fixedTabHeight) tabHeight = 0;
- 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;
- setSelection(Math.max(0, index - 1), true);
- } else if (selectedIndex > index) {
- selectedIndex --;
- }
-
- setItemBounds();
- redrawTabArea(-1);
-}
-private void onKeyDown(Event e) {
- if (e.keyCode == SWT.ARROW_LEFT) {
- if (selectedIndex > 0) {
- setSelection(selectedIndex - 1, true);
- }
- }
- if (e.keyCode == SWT.ARROW_RIGHT) {
- if (selectedIndex < items.length - 1) {
- setSelection(selectedIndex + 1, true);
- }
- }
-}
-/**
- * Dispose the items of the receiver
- */
-private void onDispose() {
- /*
- * Usually when an item is disposed, destroyItem will change the size of the items array,
- * reset the bounds of all the tabs and manage the widget associated with the tab.
- * Since the whole folder is being disposed, this is not necessary. For speed
- * the inDispose flag is used to skip over this part of the item dispose.
- */
- inDispose = true;
-
- 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;
- label = null;
- }
-
- if (arrowLeftImage != null) arrowLeftImage.dispose();
- arrowLeftImage = null;
- if (arrowRightImage != null) arrowRightImage.dispose();
- arrowRightImage = null;
- if (closeImage != null) closeImage.dispose();
- closeImage = null;
-
- gradientColors = null;
- gradientPercents = null;
- backgroundImage = null;
-
- if (borderColor1 != null) borderColor1.dispose();
- borderColor1 = null;
-
- if (borderColor2 != null) borderColor2.dispose();
- borderColor2 = null;
-
- if (borderColor3 != null) borderColor3.dispose();
- borderColor3 = null;
-}
-private void onFocus(Event e) {
- checkWidget();
- if (selectedIndex >= 0) {
- redrawTabArea(selectedIndex);
- } else {
- setSelection(0, true);
- }
-}
-/**
- * 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 lineY = d.y + borderTop + tabHeight;
- if (onBottom) {
- lineY = d.y + d.height - borderBottom - tabHeight - 1;
- }
- gc.setForeground(borderColor1);
- gc.drawLine(d.x + borderLeft, lineY, d.x + d.width - borderRight, lineY);
- }
-
- gc.setForeground(getForeground());
-}
-public Rectangle getClientArea() {
- checkWidget();
- Point size = getSize();
- if (items.length == 0) {
- if (!showBorders) return super.getClientArea();
- int width = size.x - borderRight - 2;
- int height = size.y - borderBottom - 2;
- return new Rectangle(borderRight + 1, borderBottom + 1, width, height);
- } else {
- int width = size.x - 2*marginWidth - borderLeft - borderRight;
- int height = size.y - 2*marginHeight - borderTop - borderBottom - tabHeight - 1;
- return new Rectangle(xClient, yClient, width, height);
- }
-}
-/**
- * Returns the height of the tab
- *
- * @return the height of the tab
- *
- * @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 getTabHeight(){
- checkWidget();
- return tabHeight;
-}
-
-/**
- * Return the tab that is located at the specified index.
- *
- * @return the item at the specified index
- */
-public CTabItem getItem (int index) {
- //checkWidget();
- if (index < 0 || index >= items.length)
- SWT.error(SWT.ERROR_INVALID_RANGE);
- return items [index];
-}
-/**
-* Gets the item at a point in the widget.
-* <p>
-*
-* @return the item at a point
-*/
-public CTabItem getItem (Point pt) {
- //checkWidget();
- if (items.length == 0) return null;
- int lastItem = getLastItem();
- lastItem = Math.min(items.length - 1, lastItem + 1);
- for (int i = topTabIndex; i <= lastItem; i++) {
- Rectangle bounds = items[i].getBounds();
- if (bounds.contains(pt)) return items[i];
- }
- return null;
-}
-/**
- * Return the number of tabs in the folder.
- *
- * @return the number of tabs in the folder
- */
-public int getItemCount(){
- //checkWidget();
- return items.length;
-}
-/**
- * Return the tab items.
- *
- * @return the tab items
- */
-public CTabItem [] getItems() {
- //checkWidget();
- CTabItem[] tabItems = new CTabItem [items.length];
- System.arraycopy(items, 0, tabItems, 0, items.length);
- return tabItems;
-}
-
-private int getLastItem(){
- if (items.length == 0) return -1;
- Rectangle area = getClientArea();
- if (area.width <= 0) return 0;
- Rectangle toolspace = getToolSpace();
- if (toolspace.width == 0) return items.length -1;
- int width = area.width - toolspace.width;
- int index = topTabIndex;
- int tabWidth = items[index].width;
- while (index < items.length - 1) {
- tabWidth += items[index + 1].width;
- if (tabWidth > width) break;
- index++;
- }
- return index;
-}
-/**
- * Return the selected tab item, or an empty array if there
- * is no selection.
- *
- * @return the selected tab item
- */
-public CTabItem getSelection() {
- //checkWidget();
- if (selectedIndex == -1) return null;
- return items[selectedIndex];
-}
-/**
- * Return the index of the selected tab item, or -1 if there
- * is no selection.
- *
- * @return the index of the selected tab item or -1
- */
-public int getSelectionIndex() {
- //checkWidget();
- return selectedIndex;
-}
-private Rectangle getToolSpace() {
- boolean showArrows = scroll_leftVisible() || scroll_rightVisible();
- if (!showArrows && topRight == null) return new Rectangle(0, 0, 0, 0);
- Rectangle toolspace;
- if (showArrows) {
- toolspace = arrowBar.getBounds();
- toolspace.width += borderRight;
- if (topRight != null) toolspace.width += topRight.getSize().x;
- } else {
- toolspace = topRight.getBounds();
- toolspace.width += borderRight;
- }
- return toolspace;
-}
-/**
- * Returns the control in the top right corner of the tab folder.
- * Typically this is a close button or a composite with a menu and close button.
- *
- * @since 2.1
- *
- * @return the control in the top right corner of the tab folder 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 Control getTopRight() {
- checkWidget();
- return topRight;
-}
-
-/**
- * Return the index of the specified tab or -1 if the tab is not
- * in the receiver.
- *
- * @return the index of the specified tab item or -1
- *
- * @exception SWTError <ul>
- * <li>ERROR_NULL_ARGUMENT when the item is null</li>
- * </ul>
- */
-public int indexOf(CTabItem item) {
- //checkWidget();
- if (item == null) {
- SWT.error(SWT.ERROR_NULL_ARGUMENT);
- }
- for (int i = 0; i < items.length; i++) {
- if (items[i] == item) return i;
- }
- return -1;
-}
-
-private void initAccessible() {
- final Accessible accessible = getAccessible();
- accessible.addAccessibleListener(new AccessibleAdapter() {
- public void getName(AccessibleEvent e) {
- String name = null;
- int childID = e.childID;
- if (childID >= 0 && childID < items.length) {
- name = items[childID].getText();
- int index = name.indexOf('&');
- if (index > 0) {
- name = name.substring(0, index) + name.substring(index + 1);
- }
- }
- e.result = name;
- }
-
- public void getHelp(AccessibleEvent e) {
- String help = null;
- int childID = e.childID;
- if (childID == ACC.CHILDID_SELF) {
- help = getToolTipText();
- } else if (childID >= 0 && childID < items.length) {
- help = items[childID].getToolTipText();
- }
- e.result = help;
- }
-
- public void getKeyboardShortcut(AccessibleEvent e) {
- String shortcut = null;
- int childID = e.childID;
- if (childID >= 0 && childID < items.length) {
- String text = items[childID].getText();
- if (text != null) {
- char mnemonic = getMnemonic(text);
- if (mnemonic != '\0') {
- shortcut = "Alt+"+mnemonic; //$NON-NLS-1$
- }
- }
- }
- e.result = shortcut;
- }
- });
-
- accessible.addAccessibleControlListener(new AccessibleControlAdapter() {
- public void getChildAtPoint(AccessibleControlEvent e) {
- Point testPoint = toControl(new Point(e.x, e.y));
- int childID = ACC.CHILDID_NONE;
- for (int i = 0; i < items.length; i++) {
- if (items[i].getBounds().contains(testPoint)) {
- childID = i;
- break;
- }
- }
- if (childID == ACC.CHILDID_NONE) {
- Rectangle location = getBounds();
- location.height = location.height - getClientArea().height;
- if (location.contains(testPoint)) {
- childID = ACC.CHILDID_SELF;
- }
- }
- e.childID = childID;
- }
-
-
- public void getLocation(AccessibleControlEvent e) {
- Rectangle location = null;
- int childID = e.childID;
- if (childID == ACC.CHILDID_SELF) {
- location = getBounds();
- }
- if (childID >= 0 && childID < items.length) {
- location = items[childID].getBounds();
- }
- if (location != null) {
- Point pt = toDisplay(new Point(location.x, location.y));
- e.x = pt.x;
- e.y = pt.y;
- e.width = location.width;
- e.height = location.height;
- }
- }
-
- public void getChildCount(AccessibleControlEvent e) {
- e.detail = items.length;
- }
-
- public void getDefaultAction(AccessibleControlEvent e) {
- String action = null;
- int childID = e.childID;
- if (childID >= 0 && childID < items.length) {
- action = "Switch"; //$NON-NLS-1$
- }
- e.result = action;
- }
-
- public void getFocus(AccessibleControlEvent e) {
- int childID = ACC.CHILDID_NONE;
- if (isFocusControl()) {
- if (selectedIndex == -1) {
- childID = ACC.CHILDID_SELF;
- } else {
- childID = selectedIndex;
- }
- }
- e.childID = childID;
- }
-
- public void getRole(AccessibleControlEvent e) {
- int role = 0;
- int childID = e.childID;
- if (childID == ACC.CHILDID_SELF) {
- role = ACC.ROLE_TABFOLDER;
- } else if (childID >= 0 && childID < items.length) {
- role = ACC.ROLE_TABITEM;
- }
- e.detail = role;
- }
-
- public void getSelection(AccessibleControlEvent e) {
- e.childID = (selectedIndex == -1) ? ACC.CHILDID_NONE : selectedIndex;
- }
-
- public void getState(AccessibleControlEvent e) {
- int state = 0;
- int childID = e.childID;
- if (childID == ACC.CHILDID_SELF) {
- state = ACC.STATE_NORMAL;
- } else if (childID >= 0 && childID < items.length) {
- state = ACC.STATE_SELECTABLE;
- if (isFocusControl()) {
- state |= ACC.STATE_FOCUSABLE;
- }
- if (selectedIndex == childID) {
- state |= ACC.STATE_SELECTED;
- if (isFocusControl()) {
- state |= ACC.STATE_FOCUSED;
- }
- }
- }
- e.detail = state;
- }
-
- public void getChildren(AccessibleControlEvent e) {
- Object[] children = new Object[items.length];
- for (int i = 0; i < items.length; i++) {
- children[i] = new Integer(i);
- }
- e.children = children;
- }
- });
-
- addListener(SWT.Selection, new Listener() {
- public void handleEvent(Event event) {
- if (isFocusControl()) {
- if (selectedIndex == -1) {
- accessible.setFocus(ACC.CHILDID_SELF);
- } else {
- accessible.setFocus(selectedIndex);
- }
- }
- }
- });
-
- addListener(SWT.FocusIn, new Listener() {
- public void handleEvent(Event event) {
- if (selectedIndex == -1) {
- accessible.setFocus(ACC.CHILDID_SELF);
- } else {
- accessible.setFocus(selectedIndex);
- }
- }
- });
-}
-
-private void setButtonBounds() {
-
- updateArrowBar();
- updateCloseBar();
-
- Rectangle area = super.getClientArea();
-
- int offset = 0;
- if (topRight != null) {
- Point size = topRight.computeSize(SWT.DEFAULT, tabHeight);
- int x = area.x + area.width - borderRight - size.x;
- int y = onBottom ? area.y + area.height - borderBottom - size.y : area.y + borderTop;
- topRight.setBounds(x, y, size.x, size.y);
- offset = size.x;
- }
- boolean leftVisible = scroll_leftVisible();
- boolean rightVisible = scroll_rightVisible();
- if (leftVisible || rightVisible) {
- Point size = arrowBar.computeSize(SWT.DEFAULT, tabHeight);
- int x = area.x + area.width - borderRight - size.x - offset;
- int y = (onBottom) ? area.y + area.height - borderBottom - size.y : area.y + borderTop;
-
- arrowBar.setBounds(x, y, size.x, size.y);
- ToolItem[] items = arrowBar.getItems();
- items[0].setEnabled(leftVisible);
- items[1].setEnabled(rightVisible);
- arrowBar.setVisible(true);
- } else {
- arrowBar.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) {
- inactiveCloseBar.setVisible(false);
- CTabItem item = getSelection();
- if (item == null) {
- closeBar.setVisible(false);
- } else {
- int toolbarHeight = tabHeight - CTabItem.TOP_MARGIN - CTabItem.BOTTOM_MARGIN + 2; // +2 to ignore gap between focus rectangle
- Point size = closeBar.computeSize(SWT.DEFAULT, toolbarHeight);
- int x = item.x + item.width - size.x - 2; // -2 to not overlap focus rectangle and trim
- int y = item.y + Math.max(0, (item.height - toolbarHeight)/2);
- closeBar.setBounds(x, y, size.x, toolbarHeight);
- Rectangle toolspace = getToolSpace();
- Point folderSize = getSize();
- boolean visible = (toolspace.width == 0 || x < toolspace.x) && x + size.x < folderSize.x - borderRight;
- closeBar.setVisible(visible);
- }
- }
-}
-private boolean setItemLocation() {
- if (items.length == 0) return false;
- Rectangle area = super.getClientArea();
- int x = area.x;
- int y = area.y + borderTop;
- if (onBottom) y = Math.max(0, area.y + area.height - borderBottom - tabHeight);
-
- boolean changed = false;
- for (int i = topTabIndex - 1; i>=0; i--) {
- // if the first visible tab is not the first tab
- CTabItem tab = items[i];
- x -= tab.width;
- if (!changed && (tab.x != x || tab.y != y) ) changed = true;
- // layout tab items from right to left thus making them invisible
- tab.x = x;
- tab.y = y;
- }
-
- x = area.x + borderLeft;
- 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;
- x = x + tab.width;
- }
- setButtonBounds();
- return changed;
-}
-private void setLastItem(int index) {
- if (index < 0 || index > items.length - 1) return;
- Rectangle area = getClientArea();
- if (area.width <= 0) return;
- int maxWidth = area.width;
- Rectangle toolspace = getToolSpace();
- if (toolspace.width > 0){
- maxWidth -= toolspace.width;
- }
- int tabWidth = items[index].width;
- while (index > 0) {
- tabWidth += items[index - 1].width;
- if (tabWidth > maxWidth) break;
- index--;
- }
- topTabIndex = index;
- setItemLocation();
- redrawTabArea(-1);
-}
-/**
- * Layout the items and store the client area size.
- */
-boolean setItemBounds() {
- boolean changed = false;
- if (isDisposed()) return changed;
- Rectangle area = super.getClientArea();
-
- xClient = area.x + borderLeft + marginWidth;
- if (onBottom) {
- yClient = area.y + borderTop + marginHeight;
- } else {
- yClient = area.y + borderTop + tabHeight + 1 + marginHeight;
- // +1 is for the line at the bottom of the tabs
- }
-
- if (area.width <= 0 || area.height <= 0 || items.length == 0) return changed;
-
- int[] widths = new int[items.length];
- GC gc = new GC(this);
- for (int i = 0; i < items.length; i++) {
- widths[i] = items[i].preferredWidth(gc);
- }
- gc.dispose();
-
- int oldAverageWidth = 0;
- int averageWidth = (area.width - borderLeft - borderRight) / items.length;
- while (averageWidth > oldAverageWidth) {
- int width = area.width - borderLeft - borderRight;
- 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;
- }
- }
- averageWidth = Math.max(averageWidth, MIN_TAB_WIDTH * tabHeight);
- for (int i = 0; i < items.length; i++) {
- if (widths[i] > averageWidth) {
- widths[i] = averageWidth;
- }
- }
-
- int totalWidth = 0;
- for (int i = 0; i < items.length; i++) {
- CTabItem tab = items[i];
- if (tab.height != tabHeight || tab.width != widths[i]) changed = true;
- tab.height = tabHeight;
- tab.width = widths[i];
- totalWidth += widths[i];
- }
-
- int areaWidth = area.x + area.width - borderRight;
- if (totalWidth <= areaWidth) {
- topTabIndex = 0;
- }
- if (setItemLocation()) changed = true;
-
- // Is there a gap after last item showing
- if (correctLastItem()) changed = true;
- return changed;
-}
-private boolean onMnemonic (Event event) {
- char key = event.character;
- for (int i = 0; i < items.length; i++) {
- if (items[i] != null) {
- char mnemonic = getMnemonic (items[i].getText ());
- if (mnemonic != '\0') {
- if (Character.toUpperCase (key) == Character.toUpperCase (mnemonic)) {
- setSelection(i, true);
- return true;
- }
- }
- }
- }
- return false;
-}
-/**
- * Paint the receiver.
- */
-private void onPaint(Event event) {
- Font font = getFont();
- if (oldFont == null || !oldFont.equals(font)) {
- oldFont = font;
- resetTabSize(true);
- }
- GC gc = event.gc;
- Rectangle rect = super.getClientArea();
- if (items.length == 0) {
- if (showBorders) {
- if ((getStyle() & SWT.FLAT) != 0) {
- gc.setForeground(borderColor1);
- gc.drawRectangle(rect.x, rect.y, rect.x + rect.width - 1, rect.y + rect.height - 1);
- } else {
- gc.setForeground(borderColor1);
- gc.drawRectangle(rect.x, rect.y, rect.x + rect.width - 3, rect.y + rect.height - 3);
-
- // fill in right and bottom edges with parent's background
- gc.setBackground(getParent().getBackground());
- gc.fillRectangle(rect.x + rect.width - 2, rect.y, 2, rect.height);
- gc.fillRectangle(rect.x, rect.y + rect.height - 2, rect.width, 2);
- }
- gc.setForeground(getForeground());
- }
- return;
- }
-
- // redraw the Border
- drawBorder(gc);
-
- rect.x += borderLeft;
- rect.y += borderTop;
- rect.width -= borderLeft + borderRight;
- rect.height -= borderTop + borderBottom;
- Rectangle clip = gc.getClipping ();
- gc.setClipping(clip.intersection(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 - borderLeft - borderRight;
- height = tabHeight + 1; // +1 causes top line between content and tabs to be redrawn
- x = area.x + borderLeft;
- y = area.y + borderTop;
- if (onBottom) {
- y = Math.max(0, area.y + area.height - borderBottom - height);
- }
- } else {
- CTabItem item = items[index];
- x = item.x;
- y = item.y;
- Rectangle area = super.getClientArea();
- width = area.x + area.width - x;
- 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) {
- checkWidget();
- 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) {
- checkWidget();
- if (listener == null) SWT.error (SWT.ERROR_NULL_ARGUMENT);
- if (tabListeners.length == 0) return;
- int index = -1;
- for (int i = 0; i < tabListeners.length; i++) {
- if (listener == tabListeners[i]){
- index = i;
- break;
- }
- }
- if (index == -1) return;
- if (tabListeners.length == 1) {
- tabListeners = new CTabFolderListener[0];
- showClose = false;
- setButtonBounds();
- 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;
- }
-
- if (setItemBounds()) {
- redrawTabArea(-1);
- }
-
- Point size = getSize();
- if (oldSize == null) {
- redraw();
- } else {
- if (onBottom && size.y != oldSize.y) {
- redraw();
- } else {
- int x1 = Math.min(size.x, oldSize.x);
- if (size.x != oldSize.x) x1 -= 10;
- int y1 = Math.min(size.y, oldSize.y);
- if (size.y != oldSize.y) y1 -= 10;
- int x2 = Math.max(size.x, oldSize.x);
- int y2 = Math.max(size.y, oldSize.y);
- redraw(0, y1, x2 + 10, y2 - y1, false);
- redraw(x1, 0, x2 - x1, y2, false);
- }
- }
- oldSize = size;
-
- // 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);
- background = color;
- // init inactive close button
- inactiveCloseBar.setBackground(color);
-
- // init scroll buttons
- arrowBar.setBackground(color);
-
- //init topRight control
- if (topRight != null)
- topRight.setBackground(color);
-
- // init close button
- if (gradientColors == null) {
- closeBar.setBackground(color);
- }
-}
-/**
- * Specify a gradient of colours to be draw in the background of the selected tab.
- * For example to draw a gradient that varies from dark blue to blue and then to
- * white, use the following call to setBackground:
- * <pre>
- * cfolder.setBackground(new Color[]{display.getSystemColor(SWT.COLOR_DARK_BLUE),
- * display.getSystemColor(SWT.COLOR_BLUE),
- * display.getSystemColor(SWT.COLOR_WHITE),
- * display.getSystemColor(SWT.COLOR_WHITE)},
- * new int[] {25, 50, 100});
- * </pre>
- *
- * @param colors an array of Color that specifies the colors to appear in the gradient
- * in order of appearance left to right. The value <code>null</code> clears the
- * background gradient. The value <code>null</code> can be used inside the array of
- * Color to specify the background color.
- * @param percents an array of integers between 0 and 100 specifying the percent of the width
- * of the widget at which the color should change. The size of the percents array must be one
- * less than the size of the colors array.
- *
- * @exception 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 setSelectionBackground(Color[] colors, int[] percents) {
- checkWidget();
- if (colors != null) {
- if (percents == null || percents.length != colors.length - 1) {
- SWT.error(SWT.ERROR_INVALID_ARGUMENT);
- }
- if (getDisplay().getDepth() < 15) {
- // Don't use gradients on low color displays
- colors = new Color[] { colors[0] };
- percents = new int[] { };
- }
- for (int i = 0; i < percents.length; i++) {
- if (percents[i] < 0 || percents[i] > 100) {
- SWT.error(SWT.ERROR_INVALID_ARGUMENT);
- }
- if (i > 0 && percents[i] < percents[i-1]) {
- SWT.error(SWT.ERROR_INVALID_ARGUMENT);
- }
- }
- }
-
- // Are these settings the same as before?
- if (backgroundImage == null) {
- if ((gradientColors != null) && (colors != null) &&
- (gradientColors.length == colors.length)) {
- boolean same = false;
- for (int i = 0; i < gradientColors.length; i++) {
- if (gradientColors[i] == null) {
- same = colors[i] == null;
- } else {
- same = gradientColors[i].equals(colors[i]);
- }
- if (!same) break;
- }
- if (same) {
- for (int i = 0; i < gradientPercents.length; i++) {
- same = gradientPercents[i] == percents[i];
- if (!same) break;
- }
- }
- if (same) return;
- }
- } else {
- backgroundImage = null;
- }
- // Store the new settings
- if (colors == null) {
- gradientColors = null;
- gradientPercents = null;
- closeBar.setBackground(background);
- } else {
- gradientColors = new Color[colors.length];
- for (int i = 0; i < colors.length; ++i)
- gradientColors[i] = colors[i];
- gradientPercents = new int[percents.length];
- for (int i = 0; i < percents.length; ++i)
- gradientPercents[i] = percents[i];
- if (getDisplay().getDepth() < 15) closeBar.setBackground(background);
- else closeBar.setBackground(gradientColors[gradientColors.length - 1]);
- }
-
- // Refresh with the new settings
- if (selectedIndex > -1) redrawTabArea(selectedIndex);
-}
-
-/**
- * Set the image to be drawn in the background of the selected tab.
- *
- * @param image the image to be drawn in the background
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public void setSelectionBackground(Image image) {
- checkWidget();
- if (image == backgroundImage) return;
- if (image != null) {
- gradientColors = null;
- gradientPercents = null;
- }
- backgroundImage = image;
- redrawTabArea(selectedIndex);
-}
-/**
- * Toggle the visibility of the border
- *
- * @param show true if the border should be displayed
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public void setBorderVisible(boolean show) {
- checkWidget();
- if (showBorders == show) return;
-
- showBorders = show;
- if (showBorders) {
- if ((getStyle() & SWT.FLAT) != 0) {
- borderBottom = borderTop = borderLeft = borderRight = 1;
- } else {
- borderLeft = borderTop = 1;
- borderRight = borderBottom = 3;
- }
- } else {
- borderBottom = borderTop = borderLeft = borderRight = 0;
- }
- oldSize = null;
- notifyListeners(SWT.Resize, new Event());
-}
-public void setFont(Font font) {
- checkWidget();
- if (font != null && font.equals(getFont())) return;
- super.setFont(font);
- oldFont = getFont();
- resetTabSize(true);
-}
-/**
- * Set the foreground color of the selected tab.
- *
- * @param color the color of the text displayed in the selected tab
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public void setSelectionForeground (Color color) {
- checkWidget();
- if (selectionForeground == color) return;
- if (color == null) color = getForeground();
- selectionForeground = color;
- if (selectedIndex > -1) {
- redrawTabArea(selectedIndex);
- }
-}
-/**
- * Display an insert marker before or after the specified tab item.
- * Null will clear the mark.
- *
- * @param item the item with which the mark is associated or null
- *
- * @param after true if the mark should be displayed after the specified item
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public void setInsertMark(CTabItem item, boolean after) {
- checkWidget();
- int index = -1;
- if (item != null) {
- index = indexOf(item);
- }
- setInsertMark(index, after);
-}
-/**
- * Display an insert marker before or after the specified tab item.
- * -1 will clear the mark.
- *
- * @param item the index of the item with which the mark is associated or null
- *
- * @param after true if the mark should be displayed after the specified item
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public void setInsertMark(int index, boolean after) {
- checkWidget();
- if (index < -1 || index >= getItemCount()) {
- SWT.error(SWT.ERROR_INVALID_ARGUMENT);
- }
-
- 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.
- *
- * @param index the index of the tab item to be selected
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public void setSelection(int index) {
- checkWidget();
- if (index < 0 || index >= items.length) return;
- if (selectedIndex == index) return;
-
- 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);
- }
- }
- showItem(items[selectedIndex]);
- setButtonBounds();
- redrawTabArea(-1);
-}
-/**
- * Set the control that appears in the top right corner of the tab folder.
- * Typically this is a close button or a composite with a Menu and close button.
- * The topRight control is optional. Setting the top right control to null will remove it from the tab folder.
- *
- * @since 2.1
- *
- * @param control the control to be displayed in the top right corner or null
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * <li>ERROR_INVALID_ARGUMENT - if the control is not a child of this CTabFolder</li>
- * </ul>
- */
-public void setTopRight(Control control) {
- checkWidget();
- if (control != null && control.getParent() != this) {
- SWT.error(SWT.ERROR_INVALID_ARGUMENT);
- }
- topRight = control;
- resetTabSize(true);
-}
-
-/**
- * Shows the item. If the item is already showing in the receiver,
- * this method simply returns. Otherwise, the items are scrolled until
- * the item is visible.
- *
- * @param item the item to be shown
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the item is null</li>
- * <li>ERROR_INVALID_ARGUMENT - if the item has been disposed</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see CTabFolder#showSelection()
- *
- * @since 2.0
- */
-public void showItem (CTabItem item) {
- checkWidget();
- if (item == null) SWT.error (SWT.ERROR_NULL_ARGUMENT);
- if (item.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
-
- int index = indexOf(item);
- if (index < topTabIndex) {
- topTabIndex = index;
- setItemLocation();
- redrawTabArea(-1);
- return;
- }
- Rectangle area = getClientArea();
- if (area.width <= 0) {
- topTabIndex = index;
- return;
- }
- int rightEdge = area.x + area.width;
- Rectangle rect = getToolSpace();
- if (rect.width > 0) {
- rightEdge -= rect.width;
- }
- if (item.x + item.width < rightEdge) return;
- setLastItem(index);
-}
-/**
- * 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 CTabFolder#showItem(CTabItem)
- *
- * @since 2.0
- *
- */
-public void showSelection () {
- checkWidget ();
- if (selectedIndex != -1) {
- showItem(getSelection());
- }
-}
-
-char getMnemonic (String string) {
- int index = 0;
- int length = string.length ();
- do {
- while ((index < length) && (string.charAt (index) != '&')) index++;
- if (++index >= length) return '\0';
- if (string.charAt (index) != '&') return string.charAt (index);
- index++;
- } while (index < length);
- return '\0';
-}
-/**
- * Set the selection to the tab at the specified item.
- *
- * @param index the tab item to be selected
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * <li>ERROR_NULL_ARGUMENT - if argument is null</li>
- * </ul>
- */
-public void setSelection(CTabItem item) {
- checkWidget();
- if (item == null)
- SWT.error(SWT.ERROR_NULL_ARGUMENT);
- int index = indexOf(item);
- setSelection(index);
-}
-/**
- * Set the selection to the tab at the specified index.
- */
-private void setSelection(int index, boolean notify) {
- int oldSelectedIndex = selectedIndex;
- setSelection(index);
- if (notify && selectedIndex != oldSelectedIndex && selectedIndex != -1) {
- Event event = new Event();
- event.item = getItem(selectedIndex);
- notifyListeners(SWT.Selection, event);
- }
-}
-
-private void updateCloseBar() {
- int imageHeight = tabHeight - CTabItem.TOP_MARGIN - CTabItem.BOTTOM_MARGIN - 4;
- if (imageHeight < 8) return;
-
- if (closeImage != null && closeImage.getBounds().height == imageHeight) return;
-
- if (closeBar != null) closeBar.dispose();
- closeBar = null;
- if (inactiveCloseBar != null) inactiveCloseBar.dispose();
- inactiveCloseBar = null;
- createCloseBar();
-
- ToolItem closeItem = closeBar.getItems()[0];
- ToolItem inactiveCloseItem = inactiveCloseBar.getItems()[0];
-
- if (closeImage != null) closeImage.dispose();
-
- Display display = getDisplay();
- Color foreground = getForeground();
- Color black = display.getSystemColor(SWT.COLOR_BLACK);
- Color background = getBackground();
-
- PaletteData palette = new PaletteData(new RGB[]{foreground.getRGB(), background.getRGB(), black.getRGB()});
- ImageData imageData = new ImageData(imageHeight, imageHeight, 4, palette);
- imageData.transparentPixel = 1;
- closeImage = new Image(display, imageData);
- GC gc = new GC(closeImage);
- gc.setBackground(background);
- gc.fillRectangle(0, 0, imageHeight, imageHeight);
- gc.setForeground(black);
-
- //draw an 8x7 'x' centered in image
- int h = (imageHeight / 2 )* 2;
- int inset = (h - 8) / 2;
- gc.drawLine( inset, inset, h - inset - 1, h - inset - 1);
- gc.drawLine( inset + 1, inset, h - inset, h - inset - 1);
- gc.drawLine( inset, h - inset - 1, h - inset - 1, inset);
- gc.drawLine( inset + 1, h - inset - 1, h - inset, inset);
-
- gc.dispose();
-
- closeItem.setImage(closeImage);
- inactiveCloseItem.setImage(closeImage);
-}
-private void updateArrowBar() {
-
- int imageHeight = tabHeight - 6;
- if (imageHeight < 10) return;
-
- if (arrowLeftImage != null && arrowLeftImage.getBounds().height == imageHeight) return;
-
- if (arrowBar != null) arrowBar.dispose();
- arrowBar = null;
- if (arrowLeftImage != null) arrowLeftImage.dispose();
- if (arrowRightImage != null) arrowRightImage.dispose();
-
- createArrowBar();
- ToolItem[] items = arrowBar.getItems();
- ToolItem left = items[0];
- ToolItem right = items[1];
-
- Display display = getDisplay();
- Color foreground = getForeground();
- Color black = display.getSystemColor(SWT.COLOR_BLACK);
- Color background = getBackground();
-
- PaletteData palette = new PaletteData(new RGB[]{foreground.getRGB(), background.getRGB(), black.getRGB()});
- ImageData imageData = new ImageData(7, imageHeight, 4, palette);
- imageData.transparentPixel = 1;
- arrowLeftImage = new Image(display, imageData);
- GC gc = new GC(arrowLeftImage);
- gc.setBackground(background);
- gc.fillRectangle(0, 0, 7, imageHeight);
- gc.setBackground(black);
- //draw a 10x5 '<' centered vertically in image
- int h = (imageHeight / 2 )* 2;
- int midpoint = h / 2 - 1;
- int[] pointArr = new int[] {6, midpoint - 5,
- 1, midpoint,
- 6, midpoint + 5,};
- gc.fillPolygon(pointArr);
- gc.dispose();
-
- palette = new PaletteData(new RGB[]{foreground.getRGB(), background.getRGB(), black.getRGB()});
- imageData = new ImageData(7, imageHeight, 4, palette);
- imageData.transparentPixel = 1;
- arrowRightImage = new Image(display, imageData);
- gc = new GC(arrowRightImage);
- gc.setBackground(background);
- gc.fillRectangle(0, 0, 7, imageHeight);
- gc.setBackground(black);
- //draw a 10x5 '>' centered vertically in image
- pointArr = new int[] {1, midpoint - 5,
- 6, midpoint,
- 1, midpoint + 5,};
- gc.fillPolygon(pointArr);
- gc.dispose();
-
- left.setImage(arrowLeftImage);
- right.setImage(arrowRightImage);
-}
-
-private void onMouseDoubleClick(Event event) {
- Event e = new Event();
- e.item = getItem(new Point(event.x, event.y));
- notifyListeners(SWT.DefaultSelection, e);
-}
-/**
- * A mouse button was pressed down.
- * If a tab was hit select the tab.
- */
-private void onMouseDown(Event event) {
- for (int i=0; i<items.length; i++) {
- if (items[i].getBounds().contains(new Point(event.x, event.y))) {
- if (i == selectedIndex) {
- showSelection();
- return;
- }
- forceFocus();
- setSelection(i, true);
- if (isFocusControl()) setFocus();
- return;
- }
- }
-}
-
-private void onMouseExit(Event event) {
- Rectangle inactiveBounds = inactiveCloseBar.getBounds();
- if (inactiveBounds.contains(event.x, event.y)) return;
- inactiveCloseBar.setVisible(false);
- inactiveItem = null;
-
- showToolTip = false;
- toolTipItem = null;
- if (tip != null && !tip.isDisposed() && tip.isVisible()) tip.setVisible(false);
-}
-
-private void onMouseHover(Event event) {
- if (tip == null || tip.isDisposed()) return;
- showToolTip = true;
- showToolTip(event.x, event.y);
-}
-private void showToolTip (int x, int y) {
- CTabItem item = getItem(new Point (x, y));
- if (item != null) {
- if (item == toolTipItem) return;
- toolTipItem = item;
- String tooltip = item.getToolTipText();
- if (tooltip != null) {
- Display display = tip.getDisplay();
- label.setForeground (display.getSystemColor (SWT.COLOR_INFO_FOREGROUND));
- label.setBackground (display.getSystemColor (SWT.COLOR_INFO_BACKGROUND));
- label.setText(tooltip);
- Point labelSize = label.computeSize(SWT.DEFAULT, SWT.DEFAULT);
- labelSize.x += 2; labelSize.y += 2;
- label.setSize(labelSize);
- tip.pack();
- /*
- * On some platforms, there is a minimum size for a shell
- * which may be greater than the label size.
- * To avoid having the background of the tip shell showing
- * around the label, force the label to fill the entire client area.
- */
- Rectangle area = tip.getClientArea();
- label.setSize(area.width, area.height);
- /*
- * Position the tooltip and ensure that it is not located off
- * the screen.
- */
- Point pt = new Point(item.x + item.width / 4, item.y + item.height + 2);
- pt = toDisplay(pt);
- Rectangle rect = display.getBounds();
- Point tipSize = tip.getSize();
- pt.x = Math.max (0, Math.min (pt.x, rect.width - tipSize.x));
- pt.y = Math.max (0, Math.min (pt.y, rect.height - tipSize.y));
- tip.setLocation(pt);
- tip.setVisible(true);
- return;
- }
- }
-
- toolTipItem = null;
- if (tip != null && !tip.isDisposed() && tip.isVisible()) tip.setVisible(false);
-}
-private void onMouseMove(Event event) {
- if (showToolTip) {
- showToolTip(event.x, event.y);
- }
-
- if (!showClose) return;
-
- CTabItem item = null;
- for (int i=0; i<items.length; i++) {
- Rectangle rect = items[i].getBounds();
- if (rect.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;
-
- int toolbarHeight = tabHeight - CTabItem.TOP_MARGIN - CTabItem.BOTTOM_MARGIN + 2; // +2 to ignore gap between focus rectangle
- Point size = inactiveCloseBar.computeSize(SWT.DEFAULT, toolbarHeight);
- int x = item.x + item.width - size.x - 2; // -2 to not overlap focus rectangle and trim
- int y = item.y + Math.max(0, (item.height - toolbarHeight)/2);
- Rectangle toolspace = getToolSpace();
- Point folderSize = getSize();
- if ((toolspace.width == 0 || x < toolspace.x) && x + size.x < folderSize.x - borderRight) {
- inactiveCloseBar.setBounds(x, y, size.x, toolbarHeight);
- inactiveCloseBar.setVisible(true);
- inactiveItem = item;
- }
-}
-private void onTraverse (Event event) {
- switch (event.detail) {
- case SWT.TRAVERSE_ESCAPE:
-// TEMPORARY CODE See bug report 17372
-// case SWT.TRAVERSE_RETURN:
- case SWT.TRAVERSE_TAB_NEXT:
- case SWT.TRAVERSE_TAB_PREVIOUS:
- event.doit = true;
- break;
- case SWT.TRAVERSE_MNEMONIC:
- event.doit = onMnemonic(event);
- if (event.doit) event.detail = SWT.TRAVERSE_NONE;
- break;
- case SWT.TRAVERSE_PAGE_NEXT:
- case SWT.TRAVERSE_PAGE_PREVIOUS:
- event.doit = onPageTraversal(event);
- if (event.doit) event.detail = SWT.TRAVERSE_NONE;
- break;
- }
-}
-
-private boolean onPageTraversal(Event event) {
- int count = getItemCount ();
- if (count == 0) return false;
- int index = getSelectionIndex ();
- if (index == -1) {
- index = 0;
- } else {
- int offset = (event.detail == SWT.TRAVERSE_PAGE_NEXT) ? 1 : -1;
- index = (index + offset + count) % count;
- }
- setSelection (index, true);
- return true;
-}
-
-/**
- * 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() {
- // only show Scroll buttons if there is more than one item
- // and if we are not already at the last item
- if (items.length < 2) return false;
- Rectangle area = getClientArea();
- int rightEdge = area.x + area.width;
- if (rightEdge <= 0) return false;
- if (topTabIndex > 0) {
- rightEdge -= arrowBar.getSize().x;
- }
- if (topRight != null) {
- rightEdge -= topRight.getSize().x;
- }
- CTabItem item = items[items.length-1];
- return (item.x + item.width > rightEdge);
-}
-
-/**
- * Scroll the tab items to the left.
- */
-private void scroll_scrollLeft() {
- if (items.length == 0) return;
- setLastItem(topTabIndex - 1);
-}
-
-/**
- * Scroll the tab items to the right.
- */
-private void scroll_scrollRight() {
- int lastIndex = getLastItem();
- topTabIndex = lastIndex + 1;
- setItemLocation();
- correctLastItem();
- redrawTabArea(-1);
-}
-private boolean correctLastItem() {
- Rectangle area = getClientArea();
- int rightEdge = area.x + area.width;
- if (rightEdge <= 0) return false;
- Rectangle toolspace = getToolSpace();
- if (toolspace.width > 0) {
- rightEdge -= toolspace.width;
- }
- CTabItem item = items[items.length - 1];
- if (item.x + item.width < rightEdge) {
- setLastItem(items.length - 1);
- return true;
- }
- return false;
-}
-/**
- * Specify a fixed height for the tab items. If no height is specified,
- * the default height is the height of the text or the image, whichever
- * is greater. Specifying a height of 0 will revert to the default height.
- *
- * @param height the pixel value of the height or 0
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * <li>ERROR_INVALID_ARGUMENT - if called with a height of less than 0</li>
- * </ul>
- */
-public void setTabHeight(int height) {
- checkWidget();
- if (height < 0) {
- SWT.error(SWT.ERROR_INVALID_ARGUMENT);
- }
- fixedTabHeight = true;
- if (tabHeight == height) return;
- tabHeight = height;
- oldSize = null;
- notifyListeners(SWT.Resize, new Event());
-}
-void resetTabSize(boolean checkHeight){
- int oldHeight = tabHeight;
- if (!fixedTabHeight && checkHeight) {
- int tempHeight = 0;
- GC gc = new GC(this);
- for (int i=0; i < items.length; i++) {
- tempHeight = Math.max(tempHeight, items[i].preferredHeight(gc));
- }
- gc.dispose();
- if (topRight != null) tempHeight = Math.max(tempHeight, topRight.computeSize(SWT.DEFAULT, SWT.DEFAULT).y);
- tabHeight = tempHeight;
- }
-
- if (tabHeight != oldHeight){
- oldSize = null;
- notifyListeners(SWT.Resize, new Event());
- } else {
- setItemBounds();
- redraw();
- }
-}
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+import org.eclipse.swt.*;
+import org.eclipse.swt.events.*;
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.widgets.*;
+import org.eclipse.swt.accessibility.*;
+
+/**
+ * Instances of this class implement the notebook user interface
+ * metaphor. It allows the user to select a notebook page from
+ * set of pages.
+ * <p>
+ * The item children that may be added to instances of this class
+ * must be of type <code>CTabItem</code>.
+ * <code>Control</code> children are created and then set into a
+ * tab item using <code>CTabItem#setControl</code>.
+ * </p><p>
+ * Note that although this class is a subclass of <code>Composite</code>,
+ * it does not make sense to set a layout on it.
+ * </p><p>
+ * <dl>
+ * <dt><b>Styles:</b></dt>
+ * <dd>TOP, BOTTOM, FLAT</dd>
+ * <dt><b>Events:</b></dt>
+ * <dd>Selection</dd>
+ * <dd>"CTabFolder"</dd>
+ * </dl>
+ * <p>
+ * Note: Only one of the styles TOP and BOTTOM
+ * may be specified.
+ * </p><p>
+ * IMPORTANT: This class is <em>not</em> intended to be subclassed.
+ * </p>
+ */
+
+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 int MIN_TAB_WIDTH = 3;
+
+ /* sizing, positioning */
+ int xClient, yClient;
+ boolean onBottom = false;
+ boolean fixedTabHeight;
+ int tabHeight;
+
+ /* 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;
+ Color[] gradientColors;
+ int[] gradientPercents;
+ Color selectionForeground;
+ Color background;
+
+ // internal constants
+ private static final int DEFAULT_WIDTH = 64;
+ private static final int DEFAULT_HEIGHT = 64;
+
+ // scrolling arrows
+ private ToolBar arrowBar;
+ private Image arrowLeftImage;
+ private Image arrowRightImage;
+
+ private Control topRight;
+
+ // close button
+ boolean showClose = false;
+ private Image closeImage;
+ ToolBar closeBar;
+ private ToolBar inactiveCloseBar;
+ private CTabItem inactiveItem;
+
+ // borders
+ boolean showBorders = false;
+ private int borderBottom = 0;
+ private int borderLeft = 0;
+ private int borderRight = 0;
+ private int borderTop = 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 Point oldSize;
+ private Font oldFont;
+
+ // insertion marker
+ int insertionIndex = -2; // Index of insert marker. Marker always shown after index.
+ // -2 means no insert marker
+
+ // tool tip
+ private Shell tip;
+ private Label label;
+ private boolean showToolTip = false;
+ private CTabItem toolTipItem;
+
+/**
+ * Constructs a new instance of this class given its parent
+ * and a style value describing its behavior and appearance.
+ * <p>
+ * The style value is either one of the style constants defined in
+ * class <code>SWT</code> which is applicable to instances of this
+ * class, or must be built by <em>bitwise OR</em>'ing together
+ * (that is, using the <code>int</code> "|" operator) two or more
+ * of those <code>SWT</code> style constants. The class description
+ * lists the style constants that are applicable to the class.
+ * Style bits are also inherited from superclasses.
+ * </p>
+ *
+ * @param parent a widget which will be the parent of the new instance (cannot be null)
+ * @param style the style of widget to construct
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
+ * </ul>
+ *
+ * @see SWT#TOP
+ * @see SWT#BOTTOM
+ * @see SWT#FLAT
+ * @see #getStyle
+ */
+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);
+
+ // tool tip support
+ tip = new Shell (getShell(), SWT.ON_TOP);
+ label = new Label (tip, SWT.CENTER);
+
+ // Add all listeners
+ Listener listener = new Listener() {
+ public void handleEvent(Event event) {
+ switch (event.type) {
+ case SWT.Dispose: onDispose(); break;
+ case SWT.Paint: onPaint(event); break;
+ case SWT.Resize: onResize(); break;
+ case SWT.MouseDoubleClick: onMouseDoubleClick(event); break;
+ case SWT.MouseDown: onMouseDown(event); break;
+ case SWT.MouseExit: onMouseExit(event); break;
+ case SWT.MouseHover: onMouseHover(event); break;
+ case SWT.MouseMove: onMouseMove(event); break;
+ case SWT.FocusIn: onFocus(event); break;
+ case SWT.FocusOut: onFocus(event); break;
+ case SWT.KeyDown: onKeyDown(event); break;
+ case SWT.Traverse: onTraverse(event); break;
+ }
+ }
+ };
+
+ int[] folderEvents = new int[]{
+ SWT.Dispose,
+ SWT.Paint,
+ SWT.Resize,
+ SWT.MouseDoubleClick,
+ SWT.MouseDown,
+ SWT.MouseExit,
+ SWT.MouseHover,
+ SWT.MouseMove,
+ SWT.FocusIn,
+ SWT.FocusOut,
+ SWT.KeyDown,
+ SWT.Traverse,
+ };
+ for (int i = 0; i < folderEvents.length; i++) {
+ addListener(folderEvents[i], listener);
+ }
+
+ createArrowBar();
+ createCloseBar();
+
+ setBorderVisible((style & SWT.BORDER) != 0);
+
+ initAccessible();
+
+}
+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) {
+ checkWidget();
+ if (listener == null) {
+ SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ }
+ TypedListener typedListener = new TypedListener(listener);
+ addListener(SWT.Selection, typedListener);
+ addListener(SWT.DefaultSelection, typedListener);
+}
+/**
+ * Adds the listener to the collection of listeners who will
+ * be notified when a tab item is closed.
+ *
+ * @param listener the listener which should be notified
+ *
+ * @exception IllegalArgumentException <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 - if the listener is null</li>
+ * </ul>
+ *
+ * @see CTabFolderListener
+ * @see #removeCTabFolderListener
+ */
+public void addCTabFolderListener(CTabFolderListener listener) {
+ checkWidget();
+ if (listener == null) SWT.error (SWT.ERROR_NULL_ARGUMENT);
+ // add to array
+ CTabFolderListener[] newTabListeners = new CTabFolderListener[tabListeners.length + 1];
+ System.arraycopy(tabListeners, 0, newTabListeners, 0, tabListeners.length);
+ tabListeners = newTabListeners;
+ tabListeners[tabListeners.length - 1] = listener;
+ showClose = true;
+ setButtonBounds();
+}
+private void closeNotify(CTabItem item, int time) {
+ if (item == null) return;
+
+ 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) {
+ checkWidget();
+ int minWidth = 0;
+ int minHeight = 0;
+
+ // preferred width of tab area to show all tabs
+ GC gc = new GC(this);
+ for (int i = 0; i < items.length; i++) {
+ minWidth += items[i].preferredWidth(gc);
+ }
+ gc.dispose();
+
+ // preferred size of controls in tab items
+ for (int i = 0; i < items.length; i++) {
+ Control control = items[i].getControl();
+ if (control != null && !control.isDisposed()){
+ Point size = control.computeSize (wHint, hHint);
+ 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) {
+ checkWidget();
+ if (items.length == 0) {
+ if (!showBorders) return new Rectangle(x, y, width, height);
+ int trimX = x - borderRight - 1;
+ int trimY = y - borderBottom - 1;
+ int trimWidth = width + borderRight + 2;
+ int trimHeight = height + borderBottom + 2;
+ return new Rectangle (trimX, trimY, trimWidth, trimHeight);
+ } else {
+ int trimX = x - marginWidth - borderLeft;
+ int trimY = y - marginHeight - tabHeight - borderTop - 1;
+ // -1 is for the line at the bottom of the tabs
+ if (onBottom) {
+ trimY = y - marginHeight - borderTop;
+ }
+ int trimWidth = width + borderLeft + borderRight + 2*marginWidth;
+ int trimHeight = height + borderTop + borderBottom + 2*marginHeight + tabHeight + 1;
+ 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;
+ resetTabSize(true);
+ } else {
+ setItemBounds();
+ showItem(item);
+ }
+
+ if (items.length == 1) {
+ redraw();
+ } else {
+ redrawTabArea(-1);
+ }
+}
+
+private void createArrowBar() {
+ // create arrow buttons for scrolling
+ arrowBar = new ToolBar(this, SWT.FLAT);
+ arrowBar.setVisible(false);
+ arrowBar.setBackground(background);
+ ToolItem scrollLeft = new ToolItem(arrowBar, SWT.PUSH);
+ scrollLeft.setEnabled(false);
+ ToolItem scrollRight = new ToolItem(arrowBar, SWT.PUSH);
+ scrollRight.setEnabled(false);
+
+ scrollLeft.addListener(SWT.Selection, new Listener() {
+ public void handleEvent(Event event) {
+ scroll_scrollLeft();
+ }
+ });
+ scrollRight.addListener(SWT.Selection, new Listener() {
+ public void handleEvent(Event event) {
+ scroll_scrollRight();
+ }
+ });
+
+}
+private void createCloseBar() {
+ closeBar = new ToolBar(this, SWT.FLAT);
+ closeBar.setVisible(false);
+ if (gradientColors != null && gradientColors.length > 0) {
+ closeBar.setBackground(gradientColors[gradientColors.length - 1]);
+ } else {
+ closeBar.setBackground(background);
+ }
+ ToolItem closeItem = new ToolItem(closeBar, SWT.PUSH);
+
+ inactiveCloseBar = new ToolBar(this, SWT.FLAT);
+ inactiveCloseBar.setVisible(false);
+ inactiveCloseBar.setBackground(background);
+ ToolItem inactiveCloseItem = new ToolItem(inactiveCloseBar, SWT.PUSH);
+
+ closeItem.addListener(SWT.Selection, new Listener() {
+ public void handleEvent(Event event) {
+ closeNotify(getSelection(), event.time);
+ }
+ });
+ inactiveCloseItem.addListener(SWT.Selection, new Listener() {
+ public void handleEvent(Event event) {
+ closeNotify(inactiveItem, event.time);
+ inactiveCloseBar.setVisible(false);
+ inactiveItem = null;
+ }
+ });
+ inactiveCloseBar.addListener (SWT.MouseExit, new Listener() {
+ public void handleEvent(Event event) {
+ if (inactiveItem != null) {
+ Rectangle itemBounds = inactiveItem.getBounds();
+ if (itemBounds.contains(event.x, event.y)) return;
+ }
+ inactiveCloseBar.setVisible(false);
+ inactiveItem = null;
+ }
+ });
+
+}
+/**
+ * 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);
+ if (!fixedTabHeight) tabHeight = 0;
+ 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;
+ setSelection(Math.max(0, index - 1), true);
+ } else if (selectedIndex > index) {
+ selectedIndex --;
+ }
+
+ setItemBounds();
+ redrawTabArea(-1);
+}
+private void onKeyDown(Event e) {
+ if (e.keyCode == SWT.ARROW_LEFT) {
+ if (selectedIndex > 0) {
+ setSelection(selectedIndex - 1, true);
+ }
+ }
+ if (e.keyCode == SWT.ARROW_RIGHT) {
+ if (selectedIndex < items.length - 1) {
+ setSelection(selectedIndex + 1, true);
+ }
+ }
+}
+/**
+ * Dispose the items of the receiver
+ */
+private void onDispose() {
+ /*
+ * Usually when an item is disposed, destroyItem will change the size of the items array,
+ * reset the bounds of all the tabs and manage the widget associated with the tab.
+ * Since the whole folder is being disposed, this is not necessary. For speed
+ * the inDispose flag is used to skip over this part of the item dispose.
+ */
+ inDispose = true;
+
+ 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;
+ label = null;
+ }
+
+ if (arrowLeftImage != null) arrowLeftImage.dispose();
+ arrowLeftImage = null;
+ if (arrowRightImage != null) arrowRightImage.dispose();
+ arrowRightImage = null;
+ if (closeImage != null) closeImage.dispose();
+ closeImage = null;
+
+ gradientColors = null;
+ gradientPercents = null;
+ backgroundImage = null;
+
+ if (borderColor1 != null) borderColor1.dispose();
+ borderColor1 = null;
+
+ if (borderColor2 != null) borderColor2.dispose();
+ borderColor2 = null;
+
+ if (borderColor3 != null) borderColor3.dispose();
+ borderColor3 = null;
+}
+private void onFocus(Event e) {
+ checkWidget();
+ if (selectedIndex >= 0) {
+ redrawTabArea(selectedIndex);
+ } else {
+ setSelection(0, true);
+ }
+}
+/**
+ * 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 lineY = d.y + borderTop + tabHeight;
+ if (onBottom) {
+ lineY = d.y + d.height - borderBottom - tabHeight - 1;
+ }
+ gc.setForeground(borderColor1);
+ gc.drawLine(d.x + borderLeft, lineY, d.x + d.width - borderRight, lineY);
+ }
+
+ gc.setForeground(getForeground());
+}
+public Rectangle getClientArea() {
+ checkWidget();
+ Point size = getSize();
+ if (items.length == 0) {
+ if (!showBorders) return super.getClientArea();
+ int width = size.x - borderRight - 2;
+ int height = size.y - borderBottom - 2;
+ return new Rectangle(borderRight + 1, borderBottom + 1, width, height);
+ } else {
+ int width = size.x - 2*marginWidth - borderLeft - borderRight;
+ int height = size.y - 2*marginHeight - borderTop - borderBottom - tabHeight - 1;
+ return new Rectangle(xClient, yClient, width, height);
+ }
+}
+/**
+ * Returns the height of the tab
+ *
+ * @return the height of the tab
+ *
+ * @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 getTabHeight(){
+ checkWidget();
+ return tabHeight;
+}
+
+/**
+ * Return the tab that is located at the specified index.
+ *
+ * @return the item at the specified index
+ */
+public CTabItem getItem (int index) {
+ //checkWidget();
+ if (index < 0 || index >= items.length)
+ SWT.error(SWT.ERROR_INVALID_RANGE);
+ return items [index];
+}
+/**
+* Gets the item at a point in the widget.
+* <p>
+*
+* @return the item at a point
+*/
+public CTabItem getItem (Point pt) {
+ //checkWidget();
+ if (items.length == 0) return null;
+ int lastItem = getLastItem();
+ lastItem = Math.min(items.length - 1, lastItem + 1);
+ for (int i = topTabIndex; i <= lastItem; i++) {
+ Rectangle bounds = items[i].getBounds();
+ if (bounds.contains(pt)) return items[i];
+ }
+ return null;
+}
+/**
+ * Return the number of tabs in the folder.
+ *
+ * @return the number of tabs in the folder
+ */
+public int getItemCount(){
+ //checkWidget();
+ return items.length;
+}
+/**
+ * Return the tab items.
+ *
+ * @return the tab items
+ */
+public CTabItem [] getItems() {
+ //checkWidget();
+ CTabItem[] tabItems = new CTabItem [items.length];
+ System.arraycopy(items, 0, tabItems, 0, items.length);
+ return tabItems;
+}
+
+private int getLastItem(){
+ if (items.length == 0) return -1;
+ Rectangle area = getClientArea();
+ if (area.width <= 0) return 0;
+ Rectangle toolspace = getToolSpace();
+ if (toolspace.width == 0) return items.length -1;
+ int width = area.width - toolspace.width;
+ int index = topTabIndex;
+ int tabWidth = items[index].width;
+ while (index < items.length - 1) {
+ tabWidth += items[index + 1].width;
+ if (tabWidth > width) break;
+ index++;
+ }
+ return index;
+}
+/**
+ * Return the selected tab item, or an empty array if there
+ * is no selection.
+ *
+ * @return the selected tab item
+ */
+public CTabItem getSelection() {
+ //checkWidget();
+ if (selectedIndex == -1) return null;
+ return items[selectedIndex];
+}
+/**
+ * Return the index of the selected tab item, or -1 if there
+ * is no selection.
+ *
+ * @return the index of the selected tab item or -1
+ */
+public int getSelectionIndex() {
+ //checkWidget();
+ return selectedIndex;
+}
+private Rectangle getToolSpace() {
+ boolean showArrows = scroll_leftVisible() || scroll_rightVisible();
+ if (!showArrows && topRight == null) return new Rectangle(0, 0, 0, 0);
+ Rectangle toolspace;
+ if (showArrows) {
+ toolspace = arrowBar.getBounds();
+ toolspace.width += borderRight;
+ if (topRight != null) toolspace.width += topRight.getSize().x;
+ } else {
+ toolspace = topRight.getBounds();
+ toolspace.width += borderRight;
+ }
+ return toolspace;
+}
+/**
+ * Returns the control in the top right corner of the tab folder.
+ * Typically this is a close button or a composite with a menu and close button.
+ *
+ * @since 2.1
+ *
+ * @return the control in the top right corner of the tab folder 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 Control getTopRight() {
+ checkWidget();
+ return topRight;
+}
+
+/**
+ * Return the index of the specified tab or -1 if the tab is not
+ * in the receiver.
+ *
+ * @return the index of the specified tab item or -1
+ *
+ * @exception SWTError <ul>
+ * <li>ERROR_NULL_ARGUMENT when the item is null</li>
+ * </ul>
+ */
+public int indexOf(CTabItem item) {
+ //checkWidget();
+ if (item == null) {
+ SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ }
+ for (int i = 0; i < items.length; i++) {
+ if (items[i] == item) return i;
+ }
+ return -1;
+}
+
+private void initAccessible() {
+ final Accessible accessible = getAccessible();
+ accessible.addAccessibleListener(new AccessibleAdapter() {
+ public void getName(AccessibleEvent e) {
+ String name = null;
+ int childID = e.childID;
+ if (childID >= 0 && childID < items.length) {
+ name = items[childID].getText();
+ int index = name.indexOf('&');
+ if (index > 0) {
+ name = name.substring(0, index) + name.substring(index + 1);
+ }
+ }
+ e.result = name;
+ }
+
+ public void getHelp(AccessibleEvent e) {
+ String help = null;
+ int childID = e.childID;
+ if (childID == ACC.CHILDID_SELF) {
+ help = getToolTipText();
+ } else if (childID >= 0 && childID < items.length) {
+ help = items[childID].getToolTipText();
+ }
+ e.result = help;
+ }
+
+ public void getKeyboardShortcut(AccessibleEvent e) {
+ String shortcut = null;
+ int childID = e.childID;
+ if (childID >= 0 && childID < items.length) {
+ String text = items[childID].getText();
+ if (text != null) {
+ char mnemonic = getMnemonic(text);
+ if (mnemonic != '\0') {
+ shortcut = "Alt+"+mnemonic; //$NON-NLS-1$
+ }
+ }
+ }
+ e.result = shortcut;
+ }
+ });
+
+ accessible.addAccessibleControlListener(new AccessibleControlAdapter() {
+ public void getChildAtPoint(AccessibleControlEvent e) {
+ Point testPoint = toControl(new Point(e.x, e.y));
+ int childID = ACC.CHILDID_NONE;
+ for (int i = 0; i < items.length; i++) {
+ if (items[i].getBounds().contains(testPoint)) {
+ childID = i;
+ break;
+ }
+ }
+ if (childID == ACC.CHILDID_NONE) {
+ Rectangle location = getBounds();
+ location.height = location.height - getClientArea().height;
+ if (location.contains(testPoint)) {
+ childID = ACC.CHILDID_SELF;
+ }
+ }
+ e.childID = childID;
+ }
+
+
+ public void getLocation(AccessibleControlEvent e) {
+ Rectangle location = null;
+ int childID = e.childID;
+ if (childID == ACC.CHILDID_SELF) {
+ location = getBounds();
+ }
+ if (childID >= 0 && childID < items.length) {
+ location = items[childID].getBounds();
+ }
+ if (location != null) {
+ Point pt = toDisplay(new Point(location.x, location.y));
+ e.x = pt.x;
+ e.y = pt.y;
+ e.width = location.width;
+ e.height = location.height;
+ }
+ }
+
+ public void getChildCount(AccessibleControlEvent e) {
+ e.detail = items.length;
+ }
+
+ public void getDefaultAction(AccessibleControlEvent e) {
+ String action = null;
+ int childID = e.childID;
+ if (childID >= 0 && childID < items.length) {
+ action = "Switch"; //$NON-NLS-1$
+ }
+ e.result = action;
+ }
+
+ public void getFocus(AccessibleControlEvent e) {
+ int childID = ACC.CHILDID_NONE;
+ if (isFocusControl()) {
+ if (selectedIndex == -1) {
+ childID = ACC.CHILDID_SELF;
+ } else {
+ childID = selectedIndex;
+ }
+ }
+ e.childID = childID;
+ }
+
+ public void getRole(AccessibleControlEvent e) {
+ int role = 0;
+ int childID = e.childID;
+ if (childID == ACC.CHILDID_SELF) {
+ role = ACC.ROLE_TABFOLDER;
+ } else if (childID >= 0 && childID < items.length) {
+ role = ACC.ROLE_TABITEM;
+ }
+ e.detail = role;
+ }
+
+ public void getSelection(AccessibleControlEvent e) {
+ e.childID = (selectedIndex == -1) ? ACC.CHILDID_NONE : selectedIndex;
+ }
+
+ public void getState(AccessibleControlEvent e) {
+ int state = 0;
+ int childID = e.childID;
+ if (childID == ACC.CHILDID_SELF) {
+ state = ACC.STATE_NORMAL;
+ } else if (childID >= 0 && childID < items.length) {
+ state = ACC.STATE_SELECTABLE;
+ if (isFocusControl()) {
+ state |= ACC.STATE_FOCUSABLE;
+ }
+ if (selectedIndex == childID) {
+ state |= ACC.STATE_SELECTED;
+ if (isFocusControl()) {
+ state |= ACC.STATE_FOCUSED;
+ }
+ }
+ }
+ e.detail = state;
+ }
+
+ public void getChildren(AccessibleControlEvent e) {
+ Object[] children = new Object[items.length];
+ for (int i = 0; i < items.length; i++) {
+ children[i] = new Integer(i);
+ }
+ e.children = children;
+ }
+ });
+
+ addListener(SWT.Selection, new Listener() {
+ public void handleEvent(Event event) {
+ if (isFocusControl()) {
+ if (selectedIndex == -1) {
+ accessible.setFocus(ACC.CHILDID_SELF);
+ } else {
+ accessible.setFocus(selectedIndex);
+ }
+ }
+ }
+ });
+
+ addListener(SWT.FocusIn, new Listener() {
+ public void handleEvent(Event event) {
+ if (selectedIndex == -1) {
+ accessible.setFocus(ACC.CHILDID_SELF);
+ } else {
+ accessible.setFocus(selectedIndex);
+ }
+ }
+ });
+}
+
+private void setButtonBounds() {
+
+ updateArrowBar();
+ updateCloseBar();
+
+ Rectangle area = super.getClientArea();
+
+ int offset = 0;
+ if (topRight != null) {
+ Point size = topRight.computeSize(SWT.DEFAULT, tabHeight);
+ int x = area.x + area.width - borderRight - size.x;
+ int y = onBottom ? area.y + area.height - borderBottom - size.y : area.y + borderTop;
+ topRight.setBounds(x, y, size.x, size.y);
+ offset = size.x;
+ }
+ boolean leftVisible = scroll_leftVisible();
+ boolean rightVisible = scroll_rightVisible();
+ if (leftVisible || rightVisible) {
+ Point size = arrowBar.computeSize(SWT.DEFAULT, tabHeight);
+ int x = area.x + area.width - borderRight - size.x - offset;
+ int y = (onBottom) ? area.y + area.height - borderBottom - size.y : area.y + borderTop;
+
+ arrowBar.setBounds(x, y, size.x, size.y);
+ ToolItem[] items = arrowBar.getItems();
+ items[0].setEnabled(leftVisible);
+ items[1].setEnabled(rightVisible);
+ arrowBar.setVisible(true);
+ } else {
+ arrowBar.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) {
+ inactiveCloseBar.setVisible(false);
+ CTabItem item = getSelection();
+ if (item == null) {
+ closeBar.setVisible(false);
+ } else {
+ int toolbarHeight = tabHeight - CTabItem.TOP_MARGIN - CTabItem.BOTTOM_MARGIN + 2; // +2 to ignore gap between focus rectangle
+ Point size = closeBar.computeSize(SWT.DEFAULT, toolbarHeight);
+ int x = item.x + item.width - size.x - 2; // -2 to not overlap focus rectangle and trim
+ int y = item.y + Math.max(0, (item.height - toolbarHeight)/2);
+ closeBar.setBounds(x, y, size.x, toolbarHeight);
+ Rectangle toolspace = getToolSpace();
+ Point folderSize = getSize();
+ boolean visible = (toolspace.width == 0 || x < toolspace.x) && x + size.x < folderSize.x - borderRight;
+ closeBar.setVisible(visible);
+ }
+ }
+}
+private boolean setItemLocation() {
+ if (items.length == 0) return false;
+ Rectangle area = super.getClientArea();
+ int x = area.x;
+ int y = area.y + borderTop;
+ if (onBottom) y = Math.max(0, area.y + area.height - borderBottom - tabHeight);
+
+ boolean changed = false;
+ for (int i = topTabIndex - 1; i>=0; i--) {
+ // if the first visible tab is not the first tab
+ CTabItem tab = items[i];
+ x -= tab.width;
+ if (!changed && (tab.x != x || tab.y != y) ) changed = true;
+ // layout tab items from right to left thus making them invisible
+ tab.x = x;
+ tab.y = y;
+ }
+
+ x = area.x + borderLeft;
+ 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;
+ x = x + tab.width;
+ }
+ setButtonBounds();
+ return changed;
+}
+private void setLastItem(int index) {
+ if (index < 0 || index > items.length - 1) return;
+ Rectangle area = getClientArea();
+ if (area.width <= 0) return;
+ int maxWidth = area.width;
+ Rectangle toolspace = getToolSpace();
+ if (toolspace.width > 0){
+ maxWidth -= toolspace.width;
+ }
+ int tabWidth = items[index].width;
+ while (index > 0) {
+ tabWidth += items[index - 1].width;
+ if (tabWidth > maxWidth) break;
+ index--;
+ }
+ topTabIndex = index;
+ setItemLocation();
+ redrawTabArea(-1);
+}
+/**
+ * Layout the items and store the client area size.
+ */
+boolean setItemBounds() {
+ boolean changed = false;
+ if (isDisposed()) return changed;
+ Rectangle area = super.getClientArea();
+
+ xClient = area.x + borderLeft + marginWidth;
+ if (onBottom) {
+ yClient = area.y + borderTop + marginHeight;
+ } else {
+ yClient = area.y + borderTop + tabHeight + 1 + marginHeight;
+ // +1 is for the line at the bottom of the tabs
+ }
+
+ if (area.width <= 0 || area.height <= 0 || items.length == 0) return changed;
+
+ int[] widths = new int[items.length];
+ GC gc = new GC(this);
+ for (int i = 0; i < items.length; i++) {
+ widths[i] = items[i].preferredWidth(gc);
+ }
+ gc.dispose();
+
+ int oldAverageWidth = 0;
+ int averageWidth = (area.width - borderLeft - borderRight) / items.length;
+ while (averageWidth > oldAverageWidth) {
+ int width = area.width - borderLeft - borderRight;
+ 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;
+ }
+ }
+ averageWidth = Math.max(averageWidth, MIN_TAB_WIDTH * tabHeight);
+ for (int i = 0; i < items.length; i++) {
+ if (widths[i] > averageWidth) {
+ widths[i] = averageWidth;
+ }
+ }
+
+ int totalWidth = 0;
+ for (int i = 0; i < items.length; i++) {
+ CTabItem tab = items[i];
+ if (tab.height != tabHeight || tab.width != widths[i]) changed = true;
+ tab.height = tabHeight;
+ tab.width = widths[i];
+ totalWidth += widths[i];
+ }
+
+ int areaWidth = area.x + area.width - borderRight;
+ if (totalWidth <= areaWidth) {
+ topTabIndex = 0;
+ }
+ if (setItemLocation()) changed = true;
+
+ // Is there a gap after last item showing
+ if (correctLastItem()) changed = true;
+ return changed;
+}
+private boolean onMnemonic (Event event) {
+ char key = event.character;
+ for (int i = 0; i < items.length; i++) {
+ if (items[i] != null) {
+ char mnemonic = getMnemonic (items[i].getText ());
+ if (mnemonic != '\0') {
+ if (Character.toUpperCase (key) == Character.toUpperCase (mnemonic)) {
+ setSelection(i, true);
+ return true;
+ }
+ }
+ }
+ }
+ return false;
+}
+/**
+ * Paint the receiver.
+ */
+private void onPaint(Event event) {
+ Font font = getFont();
+ if (oldFont == null || !oldFont.equals(font)) {
+ oldFont = font;
+ resetTabSize(true);
+ }
+ GC gc = event.gc;
+ Rectangle rect = super.getClientArea();
+ if (items.length == 0) {
+ if (showBorders) {
+ if ((getStyle() & SWT.FLAT) != 0) {
+ gc.setForeground(borderColor1);
+ gc.drawRectangle(rect.x, rect.y, rect.x + rect.width - 1, rect.y + rect.height - 1);
+ } else {
+ gc.setForeground(borderColor1);
+ gc.drawRectangle(rect.x, rect.y, rect.x + rect.width - 3, rect.y + rect.height - 3);
+
+ // fill in right and bottom edges with parent's background
+ gc.setBackground(getParent().getBackground());
+ gc.fillRectangle(rect.x + rect.width - 2, rect.y, 2, rect.height);
+ gc.fillRectangle(rect.x, rect.y + rect.height - 2, rect.width, 2);
+ }
+ gc.setForeground(getForeground());
+ }
+ return;
+ }
+
+ // redraw the Border
+ drawBorder(gc);
+
+ rect.x += borderLeft;
+ rect.y += borderTop;
+ rect.width -= borderLeft + borderRight;
+ rect.height -= borderTop + borderBottom;
+ Rectangle clip = gc.getClipping ();
+ gc.setClipping(clip.intersection(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 - borderLeft - borderRight;
+ height = tabHeight + 1; // +1 causes top line between content and tabs to be redrawn
+ x = area.x + borderLeft;
+ y = area.y + borderTop;
+ if (onBottom) {
+ y = Math.max(0, area.y + area.height - borderBottom - height);
+ }
+ } else {
+ CTabItem item = items[index];
+ x = item.x;
+ y = item.y;
+ Rectangle area = super.getClientArea();
+ width = area.x + area.width - x;
+ 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) {
+ checkWidget();
+ 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) {
+ checkWidget();
+ if (listener == null) SWT.error (SWT.ERROR_NULL_ARGUMENT);
+ if (tabListeners.length == 0) return;
+ int index = -1;
+ for (int i = 0; i < tabListeners.length; i++) {
+ if (listener == tabListeners[i]){
+ index = i;
+ break;
+ }
+ }
+ if (index == -1) return;
+ if (tabListeners.length == 1) {
+ tabListeners = new CTabFolderListener[0];
+ showClose = false;
+ setButtonBounds();
+ 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;
+ }
+
+ if (setItemBounds()) {
+ redrawTabArea(-1);
+ }
+
+ Point size = getSize();
+ if (oldSize == null) {
+ redraw();
+ } else {
+ if (onBottom && size.y != oldSize.y) {
+ redraw();
+ } else {
+ int x1 = Math.min(size.x, oldSize.x);
+ if (size.x != oldSize.x) x1 -= 10;
+ int y1 = Math.min(size.y, oldSize.y);
+ if (size.y != oldSize.y) y1 -= 10;
+ int x2 = Math.max(size.x, oldSize.x);
+ int y2 = Math.max(size.y, oldSize.y);
+ redraw(0, y1, x2 + 10, y2 - y1, false);
+ redraw(x1, 0, x2 - x1, y2, false);
+ }
+ }
+ oldSize = size;
+
+ // 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);
+ background = color;
+ // init inactive close button
+ inactiveCloseBar.setBackground(color);
+
+ // init scroll buttons
+ arrowBar.setBackground(color);
+
+ //init topRight control
+ if (topRight != null)
+ topRight.setBackground(color);
+
+ // init close button
+ if (gradientColors == null) {
+ closeBar.setBackground(color);
+ }
+}
+/**
+ * Specify a gradient of colours to be draw in the background of the selected tab.
+ * For example to draw a gradient that varies from dark blue to blue and then to
+ * white, use the following call to setBackground:
+ * <pre>
+ * cfolder.setBackground(new Color[]{display.getSystemColor(SWT.COLOR_DARK_BLUE),
+ * display.getSystemColor(SWT.COLOR_BLUE),
+ * display.getSystemColor(SWT.COLOR_WHITE),
+ * display.getSystemColor(SWT.COLOR_WHITE)},
+ * new int[] {25, 50, 100});
+ * </pre>
+ *
+ * @param colors an array of Color that specifies the colors to appear in the gradient
+ * in order of appearance left to right. The value <code>null</code> clears the
+ * background gradient. The value <code>null</code> can be used inside the array of
+ * Color to specify the background color.
+ * @param percents an array of integers between 0 and 100 specifying the percent of the width
+ * of the widget at which the color should change. The size of the percents array must be one
+ * less than the size of the colors array.
+ *
+ * @exception 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 setSelectionBackground(Color[] colors, int[] percents) {
+ checkWidget();
+ if (colors != null) {
+ if (percents == null || percents.length != colors.length - 1) {
+ SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+ }
+ if (getDisplay().getDepth() < 15) {
+ // Don't use gradients on low color displays
+ colors = new Color[] { colors[0] };
+ percents = new int[] { };
+ }
+ for (int i = 0; i < percents.length; i++) {
+ if (percents[i] < 0 || percents[i] > 100) {
+ SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+ }
+ if (i > 0 && percents[i] < percents[i-1]) {
+ SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+ }
+ }
+ }
+
+ // Are these settings the same as before?
+ if (backgroundImage == null) {
+ if ((gradientColors != null) && (colors != null) &&
+ (gradientColors.length == colors.length)) {
+ boolean same = false;
+ for (int i = 0; i < gradientColors.length; i++) {
+ if (gradientColors[i] == null) {
+ same = colors[i] == null;
+ } else {
+ same = gradientColors[i].equals(colors[i]);
+ }
+ if (!same) break;
+ }
+ if (same) {
+ for (int i = 0; i < gradientPercents.length; i++) {
+ same = gradientPercents[i] == percents[i];
+ if (!same) break;
+ }
+ }
+ if (same) return;
+ }
+ } else {
+ backgroundImage = null;
+ }
+ // Store the new settings
+ if (colors == null) {
+ gradientColors = null;
+ gradientPercents = null;
+ closeBar.setBackground(background);
+ } else {
+ gradientColors = new Color[colors.length];
+ for (int i = 0; i < colors.length; ++i)
+ gradientColors[i] = colors[i];
+ gradientPercents = new int[percents.length];
+ for (int i = 0; i < percents.length; ++i)
+ gradientPercents[i] = percents[i];
+ if (getDisplay().getDepth() < 15) closeBar.setBackground(background);
+ else closeBar.setBackground(gradientColors[gradientColors.length - 1]);
+ }
+
+ // Refresh with the new settings
+ if (selectedIndex > -1) redrawTabArea(selectedIndex);
+}
+
+/**
+ * Set the image to be drawn in the background of the selected tab.
+ *
+ * @param image the image to be drawn in the background
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setSelectionBackground(Image image) {
+ checkWidget();
+ if (image == backgroundImage) return;
+ if (image != null) {
+ gradientColors = null;
+ gradientPercents = null;
+ }
+ backgroundImage = image;
+ redrawTabArea(selectedIndex);
+}
+/**
+ * Toggle the visibility of the border
+ *
+ * @param show true if the border should be displayed
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setBorderVisible(boolean show) {
+ checkWidget();
+ if (showBorders == show) return;
+
+ showBorders = show;
+ if (showBorders) {
+ if ((getStyle() & SWT.FLAT) != 0) {
+ borderBottom = borderTop = borderLeft = borderRight = 1;
+ } else {
+ borderLeft = borderTop = 1;
+ borderRight = borderBottom = 3;
+ }
+ } else {
+ borderBottom = borderTop = borderLeft = borderRight = 0;
+ }
+ oldSize = null;
+ notifyListeners(SWT.Resize, new Event());
+}
+public void setFont(Font font) {
+ checkWidget();
+ if (font != null && font.equals(getFont())) return;
+ super.setFont(font);
+ oldFont = getFont();
+ resetTabSize(true);
+}
+/**
+ * Set the foreground color of the selected tab.
+ *
+ * @param color the color of the text displayed in the selected tab
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setSelectionForeground (Color color) {
+ checkWidget();
+ if (selectionForeground == color) return;
+ if (color == null) color = getForeground();
+ selectionForeground = color;
+ if (selectedIndex > -1) {
+ redrawTabArea(selectedIndex);
+ }
+}
+/**
+ * Display an insert marker before or after the specified tab item.
+ * Null will clear the mark.
+ *
+ * @param item the item with which the mark is associated or null
+ *
+ * @param after true if the mark should be displayed after the specified item
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setInsertMark(CTabItem item, boolean after) {
+ checkWidget();
+ int index = -1;
+ if (item != null) {
+ index = indexOf(item);
+ }
+ setInsertMark(index, after);
+}
+/**
+ * Display an insert marker before or after the specified tab item.
+ * -1 will clear the mark.
+ *
+ * @param item the index of the item with which the mark is associated or null
+ *
+ * @param after true if the mark should be displayed after the specified item
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setInsertMark(int index, boolean after) {
+ checkWidget();
+ if (index < -1 || index >= getItemCount()) {
+ SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+ }
+
+ 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.
+ *
+ * @param index the index of the tab item to be selected
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setSelection(int index) {
+ checkWidget();
+ if (index < 0 || index >= items.length) return;
+ if (selectedIndex == index) return;
+
+ 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);
+ }
+ }
+ showItem(items[selectedIndex]);
+ setButtonBounds();
+ redrawTabArea(-1);
+}
+/**
+ * Set the control that appears in the top right corner of the tab folder.
+ * Typically this is a close button or a composite with a Menu and close button.
+ * The topRight control is optional. Setting the top right control to null will remove it from the tab folder.
+ *
+ * @since 2.1
+ *
+ * @param control the control to be displayed in the top right corner or null
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * <li>ERROR_INVALID_ARGUMENT - if the control is not a child of this CTabFolder</li>
+ * </ul>
+ */
+public void setTopRight(Control control) {
+ checkWidget();
+ if (control != null && control.getParent() != this) {
+ SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+ }
+ topRight = control;
+ resetTabSize(true);
+}
+
+/**
+ * Shows the item. If the item is already showing in the receiver,
+ * this method simply returns. Otherwise, the items are scrolled until
+ * the item is visible.
+ *
+ * @param item the item to be shown
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if the item is null</li>
+ * <li>ERROR_INVALID_ARGUMENT - if the item has been disposed</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see CTabFolder#showSelection()
+ *
+ * @since 2.0
+ */
+public void showItem (CTabItem item) {
+ checkWidget();
+ if (item == null) SWT.error (SWT.ERROR_NULL_ARGUMENT);
+ if (item.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+
+ int index = indexOf(item);
+ if (index < topTabIndex) {
+ topTabIndex = index;
+ setItemLocation();
+ redrawTabArea(-1);
+ return;
+ }
+ Rectangle area = getClientArea();
+ if (area.width <= 0) {
+ topTabIndex = index;
+ return;
+ }
+ int rightEdge = area.x + area.width;
+ Rectangle rect = getToolSpace();
+ if (rect.width > 0) {
+ rightEdge -= rect.width;
+ }
+ if (item.x + item.width < rightEdge) return;
+ setLastItem(index);
+}
+/**
+ * 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 CTabFolder#showItem(CTabItem)
+ *
+ * @since 2.0
+ *
+ */
+public void showSelection () {
+ checkWidget ();
+ if (selectedIndex != -1) {
+ showItem(getSelection());
+ }
+}
+
+char getMnemonic (String string) {
+ int index = 0;
+ int length = string.length ();
+ do {
+ while ((index < length) && (string.charAt (index) != '&')) index++;
+ if (++index >= length) return '\0';
+ if (string.charAt (index) != '&') return string.charAt (index);
+ index++;
+ } while (index < length);
+ return '\0';
+}
+/**
+ * Set the selection to the tab at the specified item.
+ *
+ * @param index the tab item to be selected
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * <li>ERROR_NULL_ARGUMENT - if argument is null</li>
+ * </ul>
+ */
+public void setSelection(CTabItem item) {
+ checkWidget();
+ if (item == null)
+ SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ int index = indexOf(item);
+ setSelection(index);
+}
+/**
+ * Set the selection to the tab at the specified index.
+ */
+private void setSelection(int index, boolean notify) {
+ int oldSelectedIndex = selectedIndex;
+ setSelection(index);
+ if (notify && selectedIndex != oldSelectedIndex && selectedIndex != -1) {
+ Event event = new Event();
+ event.item = getItem(selectedIndex);
+ notifyListeners(SWT.Selection, event);
+ }
+}
+
+private void updateCloseBar() {
+ int imageHeight = tabHeight - CTabItem.TOP_MARGIN - CTabItem.BOTTOM_MARGIN - 4;
+ if (imageHeight < 8) return;
+
+ if (closeImage != null && closeImage.getBounds().height == imageHeight) return;
+
+ if (closeBar != null) closeBar.dispose();
+ closeBar = null;
+ if (inactiveCloseBar != null) inactiveCloseBar.dispose();
+ inactiveCloseBar = null;
+ createCloseBar();
+
+ ToolItem closeItem = closeBar.getItems()[0];
+ ToolItem inactiveCloseItem = inactiveCloseBar.getItems()[0];
+
+ if (closeImage != null) closeImage.dispose();
+
+ Display display = getDisplay();
+ Color foreground = getForeground();
+ Color black = display.getSystemColor(SWT.COLOR_BLACK);
+ Color background = getBackground();
+
+ PaletteData palette = new PaletteData(new RGB[]{foreground.getRGB(), background.getRGB(), black.getRGB()});
+ ImageData imageData = new ImageData(imageHeight, imageHeight, 4, palette);
+ imageData.transparentPixel = 1;
+ closeImage = new Image(display, imageData);
+ GC gc = new GC(closeImage);
+ gc.setBackground(background);
+ gc.fillRectangle(0, 0, imageHeight, imageHeight);
+ gc.setForeground(black);
+
+ //draw an 8x7 'x' centered in image
+ int h = (imageHeight / 2 )* 2;
+ int inset = (h - 8) / 2;
+ gc.drawLine( inset, inset, h - inset - 1, h - inset - 1);
+ gc.drawLine( inset + 1, inset, h - inset, h - inset - 1);
+ gc.drawLine( inset, h - inset - 1, h - inset - 1, inset);
+ gc.drawLine( inset + 1, h - inset - 1, h - inset, inset);
+
+ gc.dispose();
+
+ closeItem.setImage(closeImage);
+ inactiveCloseItem.setImage(closeImage);
+}
+private void updateArrowBar() {
+
+ int imageHeight = tabHeight - 6;
+ if (imageHeight < 10) return;
+
+ if (arrowLeftImage != null && arrowLeftImage.getBounds().height == imageHeight) return;
+
+ if (arrowBar != null) arrowBar.dispose();
+ arrowBar = null;
+ if (arrowLeftImage != null) arrowLeftImage.dispose();
+ if (arrowRightImage != null) arrowRightImage.dispose();
+
+ createArrowBar();
+ ToolItem[] items = arrowBar.getItems();
+ ToolItem left = items[0];
+ ToolItem right = items[1];
+
+ Display display = getDisplay();
+ Color foreground = getForeground();
+ Color black = display.getSystemColor(SWT.COLOR_BLACK);
+ Color background = getBackground();
+
+ PaletteData palette = new PaletteData(new RGB[]{foreground.getRGB(), background.getRGB(), black.getRGB()});
+ ImageData imageData = new ImageData(7, imageHeight, 4, palette);
+ imageData.transparentPixel = 1;
+ arrowLeftImage = new Image(display, imageData);
+ GC gc = new GC(arrowLeftImage);
+ gc.setBackground(background);
+ gc.fillRectangle(0, 0, 7, imageHeight);
+ gc.setBackground(black);
+ //draw a 10x5 '<' centered vertically in image
+ int h = (imageHeight / 2 )* 2;
+ int midpoint = h / 2 - 1;
+ int[] pointArr = new int[] {6, midpoint - 5,
+ 1, midpoint,
+ 6, midpoint + 5,};
+ gc.fillPolygon(pointArr);
+ gc.dispose();
+
+ palette = new PaletteData(new RGB[]{foreground.getRGB(), background.getRGB(), black.getRGB()});
+ imageData = new ImageData(7, imageHeight, 4, palette);
+ imageData.transparentPixel = 1;
+ arrowRightImage = new Image(display, imageData);
+ gc = new GC(arrowRightImage);
+ gc.setBackground(background);
+ gc.fillRectangle(0, 0, 7, imageHeight);
+ gc.setBackground(black);
+ //draw a 10x5 '>' centered vertically in image
+ pointArr = new int[] {1, midpoint - 5,
+ 6, midpoint,
+ 1, midpoint + 5,};
+ gc.fillPolygon(pointArr);
+ gc.dispose();
+
+ left.setImage(arrowLeftImage);
+ right.setImage(arrowRightImage);
+}
+
+private void onMouseDoubleClick(Event event) {
+ Event e = new Event();
+ e.item = getItem(new Point(event.x, event.y));
+ notifyListeners(SWT.DefaultSelection, e);
+}
+/**
+ * A mouse button was pressed down.
+ * If a tab was hit select the tab.
+ */
+private void onMouseDown(Event event) {
+ for (int i=0; i<items.length; i++) {
+ if (items[i].getBounds().contains(new Point(event.x, event.y))) {
+ if (i == selectedIndex) {
+ showSelection();
+ return;
+ }
+ forceFocus();
+ setSelection(i, true);
+ if (isFocusControl()) setFocus();
+ return;
+ }
+ }
+}
+
+private void onMouseExit(Event event) {
+ Rectangle inactiveBounds = inactiveCloseBar.getBounds();
+ if (inactiveBounds.contains(event.x, event.y)) return;
+ inactiveCloseBar.setVisible(false);
+ inactiveItem = null;
+
+ showToolTip = false;
+ toolTipItem = null;
+ if (tip != null && !tip.isDisposed() && tip.isVisible()) tip.setVisible(false);
+}
+
+private void onMouseHover(Event event) {
+ if (tip == null || tip.isDisposed()) return;
+ showToolTip = true;
+ showToolTip(event.x, event.y);
+}
+private void showToolTip (int x, int y) {
+ CTabItem item = getItem(new Point (x, y));
+ if (item != null) {
+ if (item == toolTipItem) return;
+ toolTipItem = item;
+ String tooltip = item.getToolTipText();
+ if (tooltip != null) {
+ Display display = tip.getDisplay();
+ label.setForeground (display.getSystemColor (SWT.COLOR_INFO_FOREGROUND));
+ label.setBackground (display.getSystemColor (SWT.COLOR_INFO_BACKGROUND));
+ label.setText(tooltip);
+ Point labelSize = label.computeSize(SWT.DEFAULT, SWT.DEFAULT);
+ labelSize.x += 2; labelSize.y += 2;
+ label.setSize(labelSize);
+ tip.pack();
+ /*
+ * On some platforms, there is a minimum size for a shell
+ * which may be greater than the label size.
+ * To avoid having the background of the tip shell showing
+ * around the label, force the label to fill the entire client area.
+ */
+ Rectangle area = tip.getClientArea();
+ label.setSize(area.width, area.height);
+ /*
+ * Position the tooltip and ensure that it is not located off
+ * the screen.
+ */
+ Point pt = new Point(item.x + item.width / 4, item.y + item.height + 2);
+ pt = toDisplay(pt);
+ Rectangle rect = display.getBounds();
+ Point tipSize = tip.getSize();
+ pt.x = Math.max (0, Math.min (pt.x, rect.width - tipSize.x));
+ pt.y = Math.max (0, Math.min (pt.y, rect.height - tipSize.y));
+ tip.setLocation(pt);
+ tip.setVisible(true);
+ return;
+ }
+ }
+
+ toolTipItem = null;
+ if (tip != null && !tip.isDisposed() && tip.isVisible()) tip.setVisible(false);
+}
+private void onMouseMove(Event event) {
+ if (showToolTip) {
+ showToolTip(event.x, event.y);
+ }
+
+ if (!showClose) return;
+
+ CTabItem item = null;
+ for (int i=0; i<items.length; i++) {
+ Rectangle rect = items[i].getBounds();
+ if (rect.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;
+
+ int toolbarHeight = tabHeight - CTabItem.TOP_MARGIN - CTabItem.BOTTOM_MARGIN + 2; // +2 to ignore gap between focus rectangle
+ Point size = inactiveCloseBar.computeSize(SWT.DEFAULT, toolbarHeight);
+ int x = item.x + item.width - size.x - 2; // -2 to not overlap focus rectangle and trim
+ int y = item.y + Math.max(0, (item.height - toolbarHeight)/2);
+ Rectangle toolspace = getToolSpace();
+ Point folderSize = getSize();
+ if ((toolspace.width == 0 || x < toolspace.x) && x + size.x < folderSize.x - borderRight) {
+ inactiveCloseBar.setBounds(x, y, size.x, toolbarHeight);
+ inactiveCloseBar.setVisible(true);
+ inactiveItem = item;
+ }
+}
+private void onTraverse (Event event) {
+ switch (event.detail) {
+ case SWT.TRAVERSE_ESCAPE:
+// TEMPORARY CODE See bug report 17372
+// case SWT.TRAVERSE_RETURN:
+ case SWT.TRAVERSE_TAB_NEXT:
+ case SWT.TRAVERSE_TAB_PREVIOUS:
+ event.doit = true;
+ break;
+ case SWT.TRAVERSE_MNEMONIC:
+ event.doit = onMnemonic(event);
+ if (event.doit) event.detail = SWT.TRAVERSE_NONE;
+ break;
+ case SWT.TRAVERSE_PAGE_NEXT:
+ case SWT.TRAVERSE_PAGE_PREVIOUS:
+ event.doit = onPageTraversal(event);
+ if (event.doit) event.detail = SWT.TRAVERSE_NONE;
+ break;
+ }
+}
+
+private boolean onPageTraversal(Event event) {
+ int count = getItemCount ();
+ if (count == 0) return false;
+ int index = getSelectionIndex ();
+ if (index == -1) {
+ index = 0;
+ } else {
+ int offset = (event.detail == SWT.TRAVERSE_PAGE_NEXT) ? 1 : -1;
+ index = (index + offset + count) % count;
+ }
+ setSelection (index, true);
+ return true;
+}
+
+/**
+ * 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() {
+ // only show Scroll buttons if there is more than one item
+ // and if we are not already at the last item
+ if (items.length < 2) return false;
+ Rectangle area = getClientArea();
+ int rightEdge = area.x + area.width;
+ if (rightEdge <= 0) return false;
+ if (topTabIndex > 0) {
+ rightEdge -= arrowBar.getSize().x;
+ }
+ if (topRight != null) {
+ rightEdge -= topRight.getSize().x;
+ }
+ CTabItem item = items[items.length-1];
+ return (item.x + item.width > rightEdge);
+}
+
+/**
+ * Scroll the tab items to the left.
+ */
+private void scroll_scrollLeft() {
+ if (items.length == 0) return;
+ setLastItem(topTabIndex - 1);
+}
+
+/**
+ * Scroll the tab items to the right.
+ */
+private void scroll_scrollRight() {
+ int lastIndex = getLastItem();
+ topTabIndex = lastIndex + 1;
+ setItemLocation();
+ correctLastItem();
+ redrawTabArea(-1);
+}
+private boolean correctLastItem() {
+ Rectangle area = getClientArea();
+ int rightEdge = area.x + area.width;
+ if (rightEdge <= 0) return false;
+ Rectangle toolspace = getToolSpace();
+ if (toolspace.width > 0) {
+ rightEdge -= toolspace.width;
+ }
+ CTabItem item = items[items.length - 1];
+ if (item.x + item.width < rightEdge) {
+ setLastItem(items.length - 1);
+ return true;
+ }
+ return false;
+}
+/**
+ * Specify a fixed height for the tab items. If no height is specified,
+ * the default height is the height of the text or the image, whichever
+ * is greater. Specifying a height of 0 will revert to the default height.
+ *
+ * @param height the pixel value of the height or 0
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * <li>ERROR_INVALID_ARGUMENT - if called with a height of less than 0</li>
+ * </ul>
+ */
+public void setTabHeight(int height) {
+ checkWidget();
+ if (height < 0) {
+ SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+ }
+ fixedTabHeight = true;
+ if (tabHeight == height) return;
+ tabHeight = height;
+ oldSize = null;
+ notifyListeners(SWT.Resize, new Event());
+}
+void resetTabSize(boolean checkHeight){
+ int oldHeight = tabHeight;
+ if (!fixedTabHeight && checkHeight) {
+ int tempHeight = 0;
+ GC gc = new GC(this);
+ for (int i=0; i < items.length; i++) {
+ tempHeight = Math.max(tempHeight, items[i].preferredHeight(gc));
+ }
+ gc.dispose();
+ if (topRight != null) tempHeight = Math.max(tempHeight, topRight.computeSize(SWT.DEFAULT, SWT.DEFAULT).y);
+ tabHeight = tempHeight;
+ }
+
+ if (tabHeight != oldHeight){
+ oldSize = null;
+ notifyListeners(SWT.Resize, new Event());
+ } else {
+ setItemBounds();
+ redraw();
+ }
+}
+}
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
index 0bb5acae8f..d3324b4523 100755
--- 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
@@ -1,12 +1,12 @@
-package org.eclipse.swt.custom;
-
-/*
+package org.eclipse.swt.custom;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-public class CTabFolderAdapter implements CTabFolderListener {
- public void itemClosed(CTabFolderEvent event){};
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+public class CTabFolderAdapter implements CTabFolderListener {
+ public void itemClosed(CTabFolderEvent event){};
}
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
index 3cc4757e41..d36dd58508 100755
--- 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
@@ -1,20 +1,20 @@
-package org.eclipse.swt.custom;
-
-/*
+package org.eclipse.swt.custom;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-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);
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+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);
+}
}
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
index bb1b33890b..fd19b332cc 100755
--- 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
@@ -1,12 +1,12 @@
-package org.eclipse.swt.custom;
-
-/*
+package org.eclipse.swt.custom;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-public interface CTabFolderListener {
- public void itemClosed(CTabFolderEvent event);
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+public interface CTabFolderListener {
+ public void itemClosed(CTabFolderEvent event);
}
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
index d2136a3625..ded51fcee7 100755
--- 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
@@ -1,518 +1,518 @@
-package org.eclipse.swt.custom;
-
-/*
+package org.eclipse.swt.custom;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-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
- static final int LEFT_MARGIN = 4;
- static final int RIGHT_MARGIN = 4;
- static final int TOP_MARGIN = 3;
- static final int BOTTOM_MARGIN = 3;
- private static final int INTERNAL_SPACING = 2;
-
- private static final String ellipsis = "..."; //$NON-NLS-1$
-
- String shortenedText;
- int shortenedTextWidth;
-
-/**
- * Constructs a new instance of this class given its parent
- * (which must be a <code>CTabFolder</code>) and a style value
- * describing its behavior and appearance. The item is added
- * to the end of the items maintained by its parent.
- * <p>
- * The style value is either one of the style constants defined in
- * class <code>SWT</code> which is applicable to instances of this
- * class, or must be built by <em>bitwise OR</em>'ing together
- * (that is, using the <code>int</code> "|" operator) two or more
- * of those <code>SWT</code> style constants. The class description
- * lists the style constants that are applicable to the class.
- * Style bits are also inherited from superclasses.
- * </p>
- *
- * @param parent a CTabFolder which will be the parent of the new instance (cannot be null)
- * @param style the style of control to construct
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
- * </ul>
- *
- * @see SWT
- * @see Widget#getStyle
- */
-public CTabItem (CTabFolder parent, int style) {
- this(parent, style, parent.getItemCount());
-}
-/**
- * Constructs a new instance of this class given its parent
- * (which must be a <code>CTabFolder</code>), a style value
- * describing its behavior and appearance, and the index
- * at which to place it in the items maintained by its parent.
- * <p>
- * The style value is either one of the style constants defined in
- * class <code>SWT</code> which is applicable to instances of this
- * class, or must be built by <em>bitwise OR</em>'ing together
- * (that is, using the <code>int</code> "|" operator) two or more
- * of those <code>SWT</code> style constants. The class description
- * lists the style constants that are applicable to the class.
- * Style bits are also inherited from superclasses.
- * </p>
- *
- * @param parent a CTabFolder which will be the parent of the new instance (cannot be null)
- * @param style the style of control to construct
- * @param index the index to store the receiver in its parent
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
- * </ul>
- *
- * @see SWT
- * @see Widget#getStyle
- */
-public CTabItem (CTabFolder parent, int style, int index) {
- super (parent, checkStyle(style));
- parent.createItem (this, index);
-}
-private static int checkStyle(int style) {
- return SWT.NONE;
-}
-
-public void dispose () {
- if (isDisposed()) return;
- parent.destroyItem(this);
- super.dispose();
- parent = null;
- control = null;
- toolTipText = null;
-}
-
-/**
- * Returns a rectangle describing the receiver's size and location
- * relative to its parent.
- *
- * @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 () {
- //checkWidget();
- return new Rectangle(x, y, width, height);
-}
-/**
-* Gets the control that is displayed in the content are of the tab item.
-*
-* @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 () {
- checkWidget();
- return control;
-}
-public Display getDisplay() {
- if (parent == null) SWT.error(SWT.ERROR_WIDGET_DISPOSED);
- return parent.getDisplay();
-}
-/**
- * Get the image displayed in the tab if the tab is disabled.
- *
- * @return the disabled image or null
- */
-public Image getDisabledImage(){
- //checkWidget();
- return disabledImage;
-}
-/**
- * Returns the receiver's parent, which must be a <code>CTabFolder</code>.
- *
- * @return the receiver's parent
- */
-public CTabFolder 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;
-}
-/**
- * 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) {
-
- Rectangle bounds = null;
- if (!parent.onBottom) {
- if (index == parent.topTabIndex) {
- bounds = new Rectangle(x + 1, y + 1, width - 2, height - 1);
- } else {
- bounds = new Rectangle(x + 2, y + 1, width - 3, height - 1);
- }
- } else {
- if (index == parent.topTabIndex) {
- bounds = new Rectangle(x + 1, y + 1, width - 2, height - 2);
- } else {
- bounds = new Rectangle(x + 2, y + 1, width - 3, height - 2);
- }
- }
- if (parent.backgroundImage != null) {
- // draw a background image behind the text
- Rectangle imageRect = parent.backgroundImage.getBounds();
- gc.drawImage(parent.backgroundImage, 0, 0, imageRect.width, imageRect.height,
- bounds.x, bounds.y, bounds.width, bounds.height);
- } else if (parent.gradientColors != null) {
- // draw a gradient behind the text
- Color oldBackground = gc.getBackground();
- if (parent.gradientColors.length == 1) {
- if (parent.gradientColors[0] != null) gc.setBackground(parent.gradientColors[0]);
- gc.fillRectangle(bounds.x, bounds.y, bounds.width, bounds.height);
- } else {
- Color oldForeground = gc.getForeground();
- Color lastColor = parent.gradientColors[0];
- if (lastColor == null) lastColor = oldBackground;
- for (int i = 0, pos = 0; i < parent.gradientPercents.length; ++i) {
- gc.setForeground(lastColor);
- lastColor = parent.gradientColors[i + 1];
- if (lastColor == null) lastColor = oldBackground;
- gc.setBackground(lastColor);
- int gradientWidth = (parent.gradientPercents[i] * bounds.width / 100) - pos;
- gc.fillGradientRectangle(bounds.x + pos, bounds.y, gradientWidth, bounds.height, false);
- pos += gradientWidth;
- }
- gc.setForeground(oldForeground);
- }
- gc.setBackground(oldBackground);
- }
-
- // 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 - 1, y, x + width - 1, y);
- gc.drawLine(x + width, y + 1, x + width, y + height - 2);
- gc.drawLine(x + width, y + height - 1, x + width, 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 - 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);
-
- // light line across top
- if (index != parent.topTabIndex) {
- gc.drawLine(x + 3, y, x + width - 3, y);
- } else {
- gc.drawLine(x + 1, y, x + width - 3, 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, y, x + width, y);
- gc.drawLine(x + width, y + 1, x + width, 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 + 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 - 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);
-
- // 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 - 3, y + height - 1);
- } else {
- gc.drawLine(x + 1, y, x + width - 2, y);
- gc.drawLine(x + 1, y + height - 1, x + width - 3, y + height - 1);
- }
- }
- if (parent.isFocusControl()) {
- // draw a focus rectangle
- int x1, y1, width1, height1;
- if (!parent.onBottom) {
- if (index == parent.topTabIndex) {
- x1 = x + 1; y1 = y + 1; width1 = width - 2; height1 = height - 1;
- } else {
- x1 = x + 2; y1 = y + 1; width1 = width - 3; height1 = height - 1;
- }
- } else {
- if (index == parent.topTabIndex) {
- x1 = x + 1; y1 = y + 1; width1 = width - 2; height1 = height - 2;
- } else {
- x1 = x + 2; y1 = y + 1; width1 = width - 3; height1 = height - 2;
- }
- }
- gc.setBackground(display.getSystemColor(SWT.COLOR_BLACK));
- gc.setForeground(display.getSystemColor(SWT.COLOR_WHITE));
- gc.drawFocus(x1, y1, width1, height1);
- }
- } else {
- // draw tab lines for unselected items
- gc.setForeground(normalShadow);
- if (!parent.onBottom) {
- if (index != parent.topTabIndex && index != parent.getSelectionIndex() + 1) {
- gc.drawLine(x, y, x, y + (height / 2));
- }
- } else {
- if (index != parent.topTabIndex && index != parent.getSelectionIndex() + 1) {
- gc.drawLine(x, y + (height / 2), x, 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 imageX = xDraw;
- int imageHeight = Math.min(height - BOTTOM_MARGIN - TOP_MARGIN, imageBounds.height);
- int imageY = y + (height - imageHeight) / 2;
- int imageWidth = imageBounds.width * imageHeight / imageBounds.height;
- gc.drawImage(image,
- imageBounds.x, imageBounds.y, imageBounds.width, imageBounds.height,
- imageX, imageY, imageWidth, imageHeight);
- xDraw += imageWidth + INTERNAL_SPACING;
- }
-
- // draw Text
- int textWidth = x + width - xDraw - RIGHT_MARGIN;
- if (isSelected && parent.showClose) {
- textWidth = x + width - xDraw - parent.closeBar.getSize().x - RIGHT_MARGIN;
- }
- if (shortenedText == null || shortenedTextWidth != textWidth) {
- shortenedText = shortenText(gc, getText(), textWidth);
- shortenedTextWidth = textWidth;
- }
- String text = shortenedText;
-
- if (isSelected && parent.selectionForeground != null) {
- gc.setForeground(parent.selectionForeground);
- } else {
- gc.setForeground(parent.getForeground());
- }
- int textY = y + (height - gc.textExtent(text, SWT.DRAW_MNEMONIC).y) / 2;
- gc.drawText(text, xDraw, textY, SWT.DRAW_TRANSPARENT | SWT.DRAW_MNEMONIC);
-
- gc.setForeground(parent.getForeground());
-}
-private static String shortenText(GC gc, String text, int width) {
- if (gc.textExtent(text, SWT.DRAW_MNEMONIC).x <= width) return text;
-
- int ellipseWidth = gc.textExtent(ellipsis, SWT.DRAW_MNEMONIC).x;
- int length = text.length();
- int end = length - 1;
- while (end > 0) {
- text = text.substring(0, end);
- int l1 = gc.textExtent(text, SWT.DRAW_MNEMONIC).x;
- if (l1 + ellipseWidth <= width) {
- return text + ellipsis;
- }
- end--;
- }
- return text + ellipsis;
-}
-/**
- * Answer the preferred height of the receiver for the GC.
- */
-int preferredHeight(GC gc) {
- Image image = getImage();
- int height = 0;
- if (image != null) height = image.getBounds().height;
- String text = getText();
- height = Math.max(height, gc.textExtent(text, SWT.DRAW_MNEMONIC).y);
- return height + TOP_MARGIN + BOTTOM_MARGIN;
-}
-/**
- * Answer the preferred width of the receiver for the GC.
- */
-int preferredWidth(GC gc) {
- int width = 0;
- Image image = getImage();
- if (image != null) width += image.getBounds().width;
- String text = getText();
- if (text != null) {
- if (image != null) width += INTERNAL_SPACING;
- width += gc.textExtent(text, SWT.DRAW_MNEMONIC).x;
- }
- if (parent.showClose) width += INTERNAL_SPACING + preferredHeight(gc); // closebar will be square and will fill preferred height
- return width + LEFT_MARGIN + RIGHT_MARGIN;
-}
-/**
- * Sets the control that is used to fill the client area of
- * the tab folder when the user selects the tab item.
- * <p>
- * @param control the new control (or null)
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_INVALID_ARGUMENT - if the control has been disposed</li>
- * <li>ERROR_INVALID_PARENT - if the control is not in the same widget tree</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public void setControl (Control control) {
- checkWidget();
- if (control != null) {
- if (control.isDisposed()) SWT.error (SWT.ERROR_INVALID_ARGUMENT);
- if (control.getParent() != parent) SWT.error (SWT.ERROR_INVALID_PARENT);
- }
- if (this.control != null && !this.control.isDisposed()) {
- this.control.setVisible(false);
- }
- this.control = control;
- if (this.control != null) {
- int index = parent.indexOf (this);
- if (index == parent.getSelectionIndex ()){
- this.control.setBounds(parent.getClientArea ());
- this.control.setVisible(true);
- } else {
- this.control.setVisible(false);
- }
- }
-}
-public void setImage (Image image) {
- checkWidget();
- if (image != null && image.equals(getImage())) return;
- super.setImage(image);
- parent.resetTabSize(true);
-}
-/**
- * Sets the image that is displayed if the tab item is disabled.
- * Null will clear the image.
- *
- * @param image the image to be displayed when the item is disabled or null
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public void setDisabledImage (Image image) {
- checkWidget();
- if (image != null && image.equals(getDisabledImage())) return;
- disabledImage = image;
- parent.redraw();
-}
-
-/**
- * Set the widget text.
- * <p>
- * This method sets the widget label. The label may include
- * mnemonic characters but must not contain line delimiters.
- *
- * @param string the new label for the widget
- *
- * @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.equals(getText())) return;
- super.setText(string);
- shortenedText = null;
- shortenedTextWidth = 0;
- parent.resetTabSize(false);
-}
-/**
- * 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;
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+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
+ static final int LEFT_MARGIN = 4;
+ static final int RIGHT_MARGIN = 4;
+ static final int TOP_MARGIN = 3;
+ static final int BOTTOM_MARGIN = 3;
+ private static final int INTERNAL_SPACING = 2;
+
+ private static final String ellipsis = "..."; //$NON-NLS-1$
+
+ String shortenedText;
+ int shortenedTextWidth;
+
+/**
+ * Constructs a new instance of this class given its parent
+ * (which must be a <code>CTabFolder</code>) and a style value
+ * describing its behavior and appearance. The item is added
+ * to the end of the items maintained by its parent.
+ * <p>
+ * The style value is either one of the style constants defined in
+ * class <code>SWT</code> which is applicable to instances of this
+ * class, or must be built by <em>bitwise OR</em>'ing together
+ * (that is, using the <code>int</code> "|" operator) two or more
+ * of those <code>SWT</code> style constants. The class description
+ * lists the style constants that are applicable to the class.
+ * Style bits are also inherited from superclasses.
+ * </p>
+ *
+ * @param parent a CTabFolder which will be the parent of the new instance (cannot be null)
+ * @param style the style of control to construct
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
+ * </ul>
+ *
+ * @see SWT
+ * @see Widget#getStyle
+ */
+public CTabItem (CTabFolder parent, int style) {
+ this(parent, style, parent.getItemCount());
+}
+/**
+ * Constructs a new instance of this class given its parent
+ * (which must be a <code>CTabFolder</code>), a style value
+ * describing its behavior and appearance, and the index
+ * at which to place it in the items maintained by its parent.
+ * <p>
+ * The style value is either one of the style constants defined in
+ * class <code>SWT</code> which is applicable to instances of this
+ * class, or must be built by <em>bitwise OR</em>'ing together
+ * (that is, using the <code>int</code> "|" operator) two or more
+ * of those <code>SWT</code> style constants. The class description
+ * lists the style constants that are applicable to the class.
+ * Style bits are also inherited from superclasses.
+ * </p>
+ *
+ * @param parent a CTabFolder which will be the parent of the new instance (cannot be null)
+ * @param style the style of control to construct
+ * @param index the index to store the receiver in its parent
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
+ * </ul>
+ *
+ * @see SWT
+ * @see Widget#getStyle
+ */
+public CTabItem (CTabFolder parent, int style, int index) {
+ super (parent, checkStyle(style));
+ parent.createItem (this, index);
+}
+private static int checkStyle(int style) {
+ return SWT.NONE;
+}
+
+public void dispose () {
+ if (isDisposed()) return;
+ parent.destroyItem(this);
+ super.dispose();
+ parent = null;
+ control = null;
+ toolTipText = null;
+}
+
+/**
+ * Returns a rectangle describing the receiver's size and location
+ * relative to its parent.
+ *
+ * @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 () {
+ //checkWidget();
+ return new Rectangle(x, y, width, height);
+}
+/**
+* Gets the control that is displayed in the content are of the tab item.
+*
+* @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 () {
+ checkWidget();
+ return control;
+}
+public Display getDisplay() {
+ if (parent == null) SWT.error(SWT.ERROR_WIDGET_DISPOSED);
+ return parent.getDisplay();
+}
+/**
+ * Get the image displayed in the tab if the tab is disabled.
+ *
+ * @return the disabled image or null
+ */
+public Image getDisabledImage(){
+ //checkWidget();
+ return disabledImage;
+}
+/**
+ * Returns the receiver's parent, which must be a <code>CTabFolder</code>.
+ *
+ * @return the receiver's parent
+ */
+public CTabFolder 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;
+}
+/**
+ * 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) {
+
+ Rectangle bounds = null;
+ if (!parent.onBottom) {
+ if (index == parent.topTabIndex) {
+ bounds = new Rectangle(x + 1, y + 1, width - 2, height - 1);
+ } else {
+ bounds = new Rectangle(x + 2, y + 1, width - 3, height - 1);
+ }
+ } else {
+ if (index == parent.topTabIndex) {
+ bounds = new Rectangle(x + 1, y + 1, width - 2, height - 2);
+ } else {
+ bounds = new Rectangle(x + 2, y + 1, width - 3, height - 2);
+ }
+ }
+ if (parent.backgroundImage != null) {
+ // draw a background image behind the text
+ Rectangle imageRect = parent.backgroundImage.getBounds();
+ gc.drawImage(parent.backgroundImage, 0, 0, imageRect.width, imageRect.height,
+ bounds.x, bounds.y, bounds.width, bounds.height);
+ } else if (parent.gradientColors != null) {
+ // draw a gradient behind the text
+ Color oldBackground = gc.getBackground();
+ if (parent.gradientColors.length == 1) {
+ if (parent.gradientColors[0] != null) gc.setBackground(parent.gradientColors[0]);
+ gc.fillRectangle(bounds.x, bounds.y, bounds.width, bounds.height);
+ } else {
+ Color oldForeground = gc.getForeground();
+ Color lastColor = parent.gradientColors[0];
+ if (lastColor == null) lastColor = oldBackground;
+ for (int i = 0, pos = 0; i < parent.gradientPercents.length; ++i) {
+ gc.setForeground(lastColor);
+ lastColor = parent.gradientColors[i + 1];
+ if (lastColor == null) lastColor = oldBackground;
+ gc.setBackground(lastColor);
+ int gradientWidth = (parent.gradientPercents[i] * bounds.width / 100) - pos;
+ gc.fillGradientRectangle(bounds.x + pos, bounds.y, gradientWidth, bounds.height, false);
+ pos += gradientWidth;
+ }
+ gc.setForeground(oldForeground);
+ }
+ gc.setBackground(oldBackground);
+ }
+
+ // 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 - 1, y, x + width - 1, y);
+ gc.drawLine(x + width, y + 1, x + width, y + height - 2);
+ gc.drawLine(x + width, y + height - 1, x + width, 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 - 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);
+
+ // light line across top
+ if (index != parent.topTabIndex) {
+ gc.drawLine(x + 3, y, x + width - 3, y);
+ } else {
+ gc.drawLine(x + 1, y, x + width - 3, 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, y, x + width, y);
+ gc.drawLine(x + width, y + 1, x + width, 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 + 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 - 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);
+
+ // 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 - 3, y + height - 1);
+ } else {
+ gc.drawLine(x + 1, y, x + width - 2, y);
+ gc.drawLine(x + 1, y + height - 1, x + width - 3, y + height - 1);
+ }
+ }
+ if (parent.isFocusControl()) {
+ // draw a focus rectangle
+ int x1, y1, width1, height1;
+ if (!parent.onBottom) {
+ if (index == parent.topTabIndex) {
+ x1 = x + 1; y1 = y + 1; width1 = width - 2; height1 = height - 1;
+ } else {
+ x1 = x + 2; y1 = y + 1; width1 = width - 3; height1 = height - 1;
+ }
+ } else {
+ if (index == parent.topTabIndex) {
+ x1 = x + 1; y1 = y + 1; width1 = width - 2; height1 = height - 2;
+ } else {
+ x1 = x + 2; y1 = y + 1; width1 = width - 3; height1 = height - 2;
+ }
+ }
+ gc.setBackground(display.getSystemColor(SWT.COLOR_BLACK));
+ gc.setForeground(display.getSystemColor(SWT.COLOR_WHITE));
+ gc.drawFocus(x1, y1, width1, height1);
+ }
+ } else {
+ // draw tab lines for unselected items
+ gc.setForeground(normalShadow);
+ if (!parent.onBottom) {
+ if (index != parent.topTabIndex && index != parent.getSelectionIndex() + 1) {
+ gc.drawLine(x, y, x, y + (height / 2));
+ }
+ } else {
+ if (index != parent.topTabIndex && index != parent.getSelectionIndex() + 1) {
+ gc.drawLine(x, y + (height / 2), x, 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 imageX = xDraw;
+ int imageHeight = Math.min(height - BOTTOM_MARGIN - TOP_MARGIN, imageBounds.height);
+ int imageY = y + (height - imageHeight) / 2;
+ int imageWidth = imageBounds.width * imageHeight / imageBounds.height;
+ gc.drawImage(image,
+ imageBounds.x, imageBounds.y, imageBounds.width, imageBounds.height,
+ imageX, imageY, imageWidth, imageHeight);
+ xDraw += imageWidth + INTERNAL_SPACING;
+ }
+
+ // draw Text
+ int textWidth = x + width - xDraw - RIGHT_MARGIN;
+ if (isSelected && parent.showClose) {
+ textWidth = x + width - xDraw - parent.closeBar.getSize().x - RIGHT_MARGIN;
+ }
+ if (shortenedText == null || shortenedTextWidth != textWidth) {
+ shortenedText = shortenText(gc, getText(), textWidth);
+ shortenedTextWidth = textWidth;
+ }
+ String text = shortenedText;
+
+ if (isSelected && parent.selectionForeground != null) {
+ gc.setForeground(parent.selectionForeground);
+ } else {
+ gc.setForeground(parent.getForeground());
+ }
+ int textY = y + (height - gc.textExtent(text, SWT.DRAW_MNEMONIC).y) / 2;
+ gc.drawText(text, xDraw, textY, SWT.DRAW_TRANSPARENT | SWT.DRAW_MNEMONIC);
+
+ gc.setForeground(parent.getForeground());
+}
+private static String shortenText(GC gc, String text, int width) {
+ if (gc.textExtent(text, SWT.DRAW_MNEMONIC).x <= width) return text;
+
+ int ellipseWidth = gc.textExtent(ellipsis, SWT.DRAW_MNEMONIC).x;
+ int length = text.length();
+ int end = length - 1;
+ while (end > 0) {
+ text = text.substring(0, end);
+ int l1 = gc.textExtent(text, SWT.DRAW_MNEMONIC).x;
+ if (l1 + ellipseWidth <= width) {
+ return text + ellipsis;
+ }
+ end--;
+ }
+ return text + ellipsis;
+}
+/**
+ * Answer the preferred height of the receiver for the GC.
+ */
+int preferredHeight(GC gc) {
+ Image image = getImage();
+ int height = 0;
+ if (image != null) height = image.getBounds().height;
+ String text = getText();
+ height = Math.max(height, gc.textExtent(text, SWT.DRAW_MNEMONIC).y);
+ return height + TOP_MARGIN + BOTTOM_MARGIN;
+}
+/**
+ * Answer the preferred width of the receiver for the GC.
+ */
+int preferredWidth(GC gc) {
+ int width = 0;
+ Image image = getImage();
+ if (image != null) width += image.getBounds().width;
+ String text = getText();
+ if (text != null) {
+ if (image != null) width += INTERNAL_SPACING;
+ width += gc.textExtent(text, SWT.DRAW_MNEMONIC).x;
+ }
+ if (parent.showClose) width += INTERNAL_SPACING + preferredHeight(gc); // closebar will be square and will fill preferred height
+ return width + LEFT_MARGIN + RIGHT_MARGIN;
+}
+/**
+ * Sets the control that is used to fill the client area of
+ * the tab folder when the user selects the tab item.
+ * <p>
+ * @param control the new control (or null)
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_INVALID_ARGUMENT - if the control has been disposed</li>
+ * <li>ERROR_INVALID_PARENT - if the control is not in the same widget tree</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setControl (Control control) {
+ checkWidget();
+ if (control != null) {
+ if (control.isDisposed()) SWT.error (SWT.ERROR_INVALID_ARGUMENT);
+ if (control.getParent() != parent) SWT.error (SWT.ERROR_INVALID_PARENT);
+ }
+ if (this.control != null && !this.control.isDisposed()) {
+ this.control.setVisible(false);
+ }
+ this.control = control;
+ if (this.control != null) {
+ int index = parent.indexOf (this);
+ if (index == parent.getSelectionIndex ()){
+ this.control.setBounds(parent.getClientArea ());
+ this.control.setVisible(true);
+ } else {
+ this.control.setVisible(false);
+ }
+ }
+}
+public void setImage (Image image) {
+ checkWidget();
+ if (image != null && image.equals(getImage())) return;
+ super.setImage(image);
+ parent.resetTabSize(true);
+}
+/**
+ * Sets the image that is displayed if the tab item is disabled.
+ * Null will clear the image.
+ *
+ * @param image the image to be displayed when the item is disabled or null
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setDisabledImage (Image image) {
+ checkWidget();
+ if (image != null && image.equals(getDisabledImage())) return;
+ disabledImage = image;
+ parent.redraw();
+}
+
+/**
+ * Set the widget text.
+ * <p>
+ * This method sets the widget label. The label may include
+ * mnemonic characters but must not contain line delimiters.
+ *
+ * @param string the new label for the widget
+ *
+ * @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.equals(getText())) return;
+ super.setText(string);
+ shortenedText = null;
+ shortenedTextWidth = 0;
+ parent.resetTabSize(false);
+}
+/**
+ * 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 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
index 679db4762f..d681ce5d13 100755
--- 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
@@ -1,242 +1,242 @@
-package org.eclipse.swt.custom;
-
-/*
+package org.eclipse.swt.custom;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-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 tableListener;
- private Listener scrollbarListener;
-/**
-* 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;
-
- tableListener = new Listener() {
- public void handleEvent(Event e) {
- resize ();
- }
- };
- parent.addListener (SWT.Resize, tableListener);
-
- scrollbarListener = new Listener() {
- public void handleEvent(Event e) {
- scroll (e);
- }
- };
- ScrollBar hBar = parent.getHorizontalBar ();
- if (hBar != null) hBar.addListener (SWT.Selection, scrollbarListener);
- ScrollBar vBar = parent.getVerticalBar ();
- if (vBar != null) vBar.addListener (SWT.Selection, scrollbarListener);
-}
-Rectangle computeBounds () {
- Rectangle clientArea = parent.getClientArea();
- Rectangle editorRect = new Rectangle(clientArea.x, clientArea.y, minimumWidth, minimumHeight);
-
- if (grabHorizontal)
- editorRect.width = Math.max(clientArea.width, minimumWidth);
-
- if (grabVertical)
- editorRect.height = Math.max(clientArea.height, minimumHeight);
-
- switch (horizontalAlignment) {
- case SWT.RIGHT:
- editorRect.x += clientArea.width - editorRect.width;
- break;
- case SWT.LEFT:
- // do nothing - clientArea.x is the right answer
- break;
- default:
- // default is CENTER
- editorRect.x += (clientArea.width - editorRect.width)/2;
- }
-
- switch (verticalAlignment) {
- case SWT.BOTTOM:
- editorRect.y += clientArea.height - editorRect.height;
- break;
- case SWT.TOP:
- // do nothing - clientArea.y is the right answer
- break;
- default :
- // default is CENTER
- editorRect.y += (clientArea.height - editorRect.height)/2;
- }
-
-
- return editorRect;
-
-}
-/**
- * Removes all associations between the Editor and the underlying composite. The
- * composite and the editor Control are <b>not</b> disposed.
- */
-public void dispose () {
- if (!parent.isDisposed()) {
- parent.removeListener (SWT.Resize, tableListener);
- ScrollBar hBar = parent.getHorizontalBar ();
- if (hBar != null) hBar.removeListener (SWT.Selection, scrollbarListener);
- ScrollBar vBar = parent.getVerticalBar ();
- if (vBar != null) vBar.removeListener (SWT.Selection, scrollbarListener);
- }
-
- parent = null;
- editor = null;
- hadFocus = false;
- tableListener = null;
- scrollbarListener = null;
-}
-/**
-* Returns the Control that is displayed above the composite being edited.
-*
-* @return the Control that is displayed above the composite being edited
-*/
-public Control getEditor () {
- return editor;
-}
-/**
- * Lays out the control within the underlying composite. This
- * method should be called after changing one or more fields to
- * force the Editor to resize.
- *
- * @since 2.1
- */
-public void layout () {
- resize();
-}
-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;
- editor.setBounds (computeBounds ());
-}
-/**
-* 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;
- resize();
- editor.setVisible(true);
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+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 tableListener;
+ private Listener scrollbarListener;
+/**
+* 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;
+
+ tableListener = new Listener() {
+ public void handleEvent(Event e) {
+ resize ();
+ }
+ };
+ parent.addListener (SWT.Resize, tableListener);
+
+ scrollbarListener = new Listener() {
+ public void handleEvent(Event e) {
+ scroll (e);
+ }
+ };
+ ScrollBar hBar = parent.getHorizontalBar ();
+ if (hBar != null) hBar.addListener (SWT.Selection, scrollbarListener);
+ ScrollBar vBar = parent.getVerticalBar ();
+ if (vBar != null) vBar.addListener (SWT.Selection, scrollbarListener);
+}
+Rectangle computeBounds () {
+ Rectangle clientArea = parent.getClientArea();
+ Rectangle editorRect = new Rectangle(clientArea.x, clientArea.y, minimumWidth, minimumHeight);
+
+ if (grabHorizontal)
+ editorRect.width = Math.max(clientArea.width, minimumWidth);
+
+ if (grabVertical)
+ editorRect.height = Math.max(clientArea.height, minimumHeight);
+
+ switch (horizontalAlignment) {
+ case SWT.RIGHT:
+ editorRect.x += clientArea.width - editorRect.width;
+ break;
+ case SWT.LEFT:
+ // do nothing - clientArea.x is the right answer
+ break;
+ default:
+ // default is CENTER
+ editorRect.x += (clientArea.width - editorRect.width)/2;
+ }
+
+ switch (verticalAlignment) {
+ case SWT.BOTTOM:
+ editorRect.y += clientArea.height - editorRect.height;
+ break;
+ case SWT.TOP:
+ // do nothing - clientArea.y is the right answer
+ break;
+ default :
+ // default is CENTER
+ editorRect.y += (clientArea.height - editorRect.height)/2;
+ }
+
+
+ return editorRect;
+
+}
+/**
+ * Removes all associations between the Editor and the underlying composite. The
+ * composite and the editor Control are <b>not</b> disposed.
+ */
+public void dispose () {
+ if (!parent.isDisposed()) {
+ parent.removeListener (SWT.Resize, tableListener);
+ ScrollBar hBar = parent.getHorizontalBar ();
+ if (hBar != null) hBar.removeListener (SWT.Selection, scrollbarListener);
+ ScrollBar vBar = parent.getVerticalBar ();
+ if (vBar != null) vBar.removeListener (SWT.Selection, scrollbarListener);
+ }
+
+ parent = null;
+ editor = null;
+ hadFocus = false;
+ tableListener = null;
+ scrollbarListener = null;
+}
+/**
+* Returns the Control that is displayed above the composite being edited.
+*
+* @return the Control that is displayed above the composite being edited
+*/
+public Control getEditor () {
+ return editor;
+}
+/**
+ * Lays out the control within the underlying composite. This
+ * method should be called after changing one or more fields to
+ * force the Editor to resize.
+ *
+ * @since 2.1
+ */
+public void layout () {
+ resize();
+}
+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;
+ editor.setBounds (computeBounds ());
+}
+/**
+* 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;
+ resize();
+ editor.setVisible(true);
+}
}
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
index d14aefd0da..b9de862635 100755
--- 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
@@ -1,879 +1,879 @@
-package org.eclipse.swt.custom;
-/*
+package org.eclipse.swt.custom;
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-import org.eclipse.swt.*;
-import org.eclipse.swt.internal.Compatibility;
-import org.eclipse.swt.widgets.*;
-import java.util.Vector;
-
-class DefaultContent implements StyledTextContent {
- private final static String LineDelimiter = System.getProperty("line.separator");
-
- Vector textListeners = new Vector(); // stores text listeners for event sending
- char[] textStore = new char[0]; // stores the actual text
- int gapStart = -1; // the character position start of the gap
- int gapEnd = -1; // the character position after the end of the gap
- int gapLine = -1; // the line on which the gap exists, the gap will always be associated
- // with one line
- int highWatermark = 300;
- int lowWatermark = 50;
-
- int[][] lines = new int[50][2]; // array of character positions and lengths representing
- // the lines of text
- int lineCount = 0; // the number of lines of text
- int expandExp = 1; // the expansion exponent, used to increase the lines array exponentially
- int replaceExpandExp = 1; // the expansion exponent, used to increase the lines array exponentially
-
-/**
- * Creates a new DefaultContent and initializes it. A <code>StyledTextContent</> will always have
- * at least one empty line.
- */
-DefaultContent() {
- super();
- setText("");
-}
-/**
- * Adds a line to the end of the line indexes array. Increases the size of the array if necessary.
- * <code>lineCount</code> is updated to reflect the new entry.
- * <p>
- *
- * @param start the start of the line
- * @param length the length of the line
- */
-void addLineIndex(int start, int length) {
- int size = lines.length;
- if (lineCount == size) {
- // expand the lines by powers of 2
- int[][] newLines = new int[size+Compatibility.pow2(expandExp)][2];
- System.arraycopy(lines, 0, newLines, 0, size);
- lines = newLines;
- expandExp++;
- }
- int[] range = new int[] {start, length};
- lines[lineCount] = range;
- lineCount++;
-}
-/**
- * Adds a line index to the end of <code>linesArray</code>. Increases the
- * size of the array if necessary and returns a new array.
- * <p>
- *
- * @param start the start of the line
- * @param length the length of the line
- * @param linesArray the array to which to add the line index
- * @param count the position at which to add the line
- * @return a new array of line indexes
- */
-int[][] addLineIndex(int start, int length, int[][] linesArray, int count) {
- int size = linesArray.length;
- int[][] newLines = linesArray;
- if (count == size) {
- newLines = new int[size+Compatibility.pow2(replaceExpandExp)][2];
- replaceExpandExp++;
- System.arraycopy(linesArray, 0, newLines, 0, size);
- }
- int[] range = new int[] {start, length};
- newLines[count] = range;
- return newLines;
-}
-/**
- * Adds a <code>TextChangeListener</code> listening for
- * <code>TextChangingEvent</code> and <code>TextChangedEvent</code>. A
- * <code>TextChangingEvent</code> is sent before changes to the text occur.
- * A <code>TextChangedEvent</code> is sent after changes to the text
- * occured.
- * <p>
- *
- * @param listener the listener
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT when listener is null</li>
- * </ul>
- */
-public void addTextChangeListener(TextChangeListener listener) {
- if (listener == null) error(SWT.ERROR_NULL_ARGUMENT);
- StyledTextListener typedListener = new StyledTextListener(listener);
- textListeners.addElement(typedListener);
-}
-/**
- * Adjusts the gap to 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;
-}
-/**
- * Determine whether or not the replace operation is valid. DefaultContent will not allow
- * the /r/n line delimiter to be split or partially deleted.
- * <p>
- *
- * @param start start offset of text to replace
- * @param replaceLength start offset of text to replace
- * @param newText start offset of text to replace
- */
-protected boolean isValidReplace(int start, int replaceLength, String newText){
- if (replaceLength == 0) {
- // inserting text, see if the \r\n line delimiter is being split
- if (start == 0) return true;
- if (start == getCharCount()) return true;
- char before = getTextRange(start - 1, 1).charAt(0);
- if (before == '\r') {
- char after = getTextRange(start, 1).charAt(0);
- if (after == '\n') return false;
- }
- } else {
- // deleting text, see if part of a \r\n line delimiter is being deleted
- char startChar = getTextRange(start, 1).charAt(0);
- if (startChar == '\n') {
- // see if char before delete position is \r
- if (start != 0) {
- char before = getTextRange(start - 1, 1).charAt(0);
- if (before == '\r') return false;
- }
- }
- char endChar = getTextRange(start + replaceLength - 1, 1).charAt(0);
- if (endChar == '\r') {
- // see if char after delete position is \n
- if (start + replaceLength != getCharCount()) {
- char after = getTextRange(start + replaceLength, 1).charAt(0);
- if (after == '\n') return false;
- }
- }
- }
- return true;
-}
-/**
- * Calculates the indexes of each line of text in the given range.
- * <p>
- *
- * @param offset the logical start offset of the text lineate
- * @param length the length of the text to lineate, includes gap
- * @param numLines the number of lines to initially allocate for the line index array,
- * passed in for efficiency (the exact number of lines may be known)
- * @return a line indexes array where each line is identified by a start offset and
- * a length
- */
-int[][] indexLines(int offset, int length, int numLines){
- int[][] indexedLines = new int[numLines][2];
- int start = 0;
- int 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;
-}
-/**
- * Returns the number of lines that are in the specified text.
- * <p>
- *
- * @param text the text to lineate
- * @return number of lines in the text
- */
-int lineCount(String text){
- int lineCount = 0;
- int length = text.length();
- for (int i = 0; i < length; i++) {
- char ch = text.charAt(i);
- if (ch == SWT.CR) {
- if (i + 1 < length && text.charAt(i + 1) == SWT.LF) {
- i++;
- }
- lineCount++;
- }
- else
- if (ch == SWT.LF) {
- lineCount++;
- }
- }
- return lineCount;
-}
-/**
- * @return the logical length of the text store
- */
-public int getCharCount() {
- int length = gapEnd - gapStart;
- return (textStore.length - length);
-}
-/**
- * Returns the line at <code>index</code> without delimiters.
- * <p>
- *
- * @param index the index of the line to return
- * @return the logical line text (i.e., without the gap)
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_INVALID_ARGUMENT when index is out of range</li>
- * </ul>
- */
-public String getLine(int index) {
- if ((index >= lineCount) || (index < 0)) error(SWT.ERROR_INVALID_ARGUMENT);
- int start = lines[index][0];
- int length = lines[index][1];
- int end = start + length - 1;
- if (!gapExists() || (end < gapStart) || (start >= gapEnd)) {
- // line is before or after the gap
- while ((length - 1 >= 0) && isDelimiter(textStore[start+length-1])) {
- length--;
- }
- return new String(textStore, start, length);
- } else {
- // gap is in the specified range, strip out the gap
- StringBuffer buf = new StringBuffer();
- int gapLength = gapEnd - gapStart;
- buf.append(textStore, start, gapStart - start);
- buf.append(textStore, gapEnd, length - gapLength - (gapStart - start));
- length = buf.length();
- while ((length - 1 >=0) && isDelimiter(buf.charAt(length-1))) {
- length--;
- }
- return Compatibility.substring(buf, 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 <code>TextChangeListener</code>.
- * <p>
- *
- * @param listener the listener
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT when listener is null</li>
- * </ul>
- */
-public void removeTextChangeListener(TextChangeListener listener){
- if (listener == null) error(SWT.ERROR_NULL_ARGUMENT);
- for (int i=0; i<textListeners.size(); i++) {
- TypedListener typedListener = (TypedListener) textListeners.elementAt(i);
- if (typedListener.getEventListener () == listener) {
- textListeners.removeElementAt(i);
- break;
- }
- }
-}
-/**
- * Replaces the text with <code>newText</code> starting at position <code>start</code>
- * for a length of <code>replaceLength</code>. Notifies the appropriate listeners.
- * <p>
- *
- * When sending the TextChangingEvent, <code>newLineCount</code> is the number of
- * lines that are going to be inserted and <code>replaceLineCount</code> is
- * the number of lines that are going to be deleted, based on the change
- * that occurs visually. For example:
- * <ul>
- * <li>(replaceText,newText) ==> (replaceLineCount,newLineCount)
- * <li>("","\n") ==> (0,1)
- * <li>("\n\n","a") ==> (2,0)
- * </ul>
- * </p>
- *
- * @param start start offset of text to replace
- * @param replaceLength start offset of text to replace
- * @param newText start offset of text to replace
- *
- * @exception SWTException <ul>
- * <li>ERROR_INVALID_ARGUMENT when the text change results in a multi byte
- * line delimiter being split or partially deleted. Splitting a line
- * delimiter by inserting text between the CR and LF characters of the
- * \r\n delimiter or deleting part of this line delimiter is not supported</li>
- * </ul>
- */
-public void replaceTextRange(int start, int replaceLength, String newText){
- // check for invalid replace operations
- if (!isValidReplace(start, replaceLength, newText)) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
-
- // inform listeners
- StyledTextEvent event = new StyledTextEvent(this);
- event.type = StyledText.TextChanging;
- event.start = start;
- event.replaceLineCount = lineCount(start, replaceLength);
- event.text = newText;
- event.newLineCount = lineCount(newText);
- event.replaceCharCount = replaceLength;
- event.newCharCount = newText.length();
- sendTextEvent(event);
-
- // first delete the text to be replaced
- delete(start, replaceLength, event.replaceLineCount + 1);
- // then insert the new text
- insert(start, newText);
- // inform listeners
- event = new StyledTextEvent(this);
- event.type = StyledText.TextChanged;
- sendTextEvent(event);
- // 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);
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+import org.eclipse.swt.*;
+import org.eclipse.swt.internal.Compatibility;
+import org.eclipse.swt.widgets.*;
+import java.util.Vector;
+
+class DefaultContent implements StyledTextContent {
+ private final static String LineDelimiter = System.getProperty("line.separator");
+
+ Vector textListeners = new Vector(); // stores text listeners for event sending
+ char[] textStore = new char[0]; // stores the actual text
+ int gapStart = -1; // the character position start of the gap
+ int gapEnd = -1; // the character position after the end of the gap
+ int gapLine = -1; // the line on which the gap exists, the gap will always be associated
+ // with one line
+ int highWatermark = 300;
+ int lowWatermark = 50;
+
+ int[][] lines = new int[50][2]; // array of character positions and lengths representing
+ // the lines of text
+ int lineCount = 0; // the number of lines of text
+ int expandExp = 1; // the expansion exponent, used to increase the lines array exponentially
+ int replaceExpandExp = 1; // the expansion exponent, used to increase the lines array exponentially
+
+/**
+ * Creates a new DefaultContent and initializes it. A <code>StyledTextContent</> will always have
+ * at least one empty line.
+ */
+DefaultContent() {
+ super();
+ setText("");
+}
+/**
+ * Adds a line to the end of the line indexes array. Increases the size of the array if necessary.
+ * <code>lineCount</code> is updated to reflect the new entry.
+ * <p>
+ *
+ * @param start the start of the line
+ * @param length the length of the line
+ */
+void addLineIndex(int start, int length) {
+ int size = lines.length;
+ if (lineCount == size) {
+ // expand the lines by powers of 2
+ int[][] newLines = new int[size+Compatibility.pow2(expandExp)][2];
+ System.arraycopy(lines, 0, newLines, 0, size);
+ lines = newLines;
+ expandExp++;
+ }
+ int[] range = new int[] {start, length};
+ lines[lineCount] = range;
+ lineCount++;
+}
+/**
+ * Adds a line index to the end of <code>linesArray</code>. Increases the
+ * size of the array if necessary and returns a new array.
+ * <p>
+ *
+ * @param start the start of the line
+ * @param length the length of the line
+ * @param linesArray the array to which to add the line index
+ * @param count the position at which to add the line
+ * @return a new array of line indexes
+ */
+int[][] addLineIndex(int start, int length, int[][] linesArray, int count) {
+ int size = linesArray.length;
+ int[][] newLines = linesArray;
+ if (count == size) {
+ newLines = new int[size+Compatibility.pow2(replaceExpandExp)][2];
+ replaceExpandExp++;
+ System.arraycopy(linesArray, 0, newLines, 0, size);
+ }
+ int[] range = new int[] {start, length};
+ newLines[count] = range;
+ return newLines;
+}
+/**
+ * Adds a <code>TextChangeListener</code> listening for
+ * <code>TextChangingEvent</code> and <code>TextChangedEvent</code>. A
+ * <code>TextChangingEvent</code> is sent before changes to the text occur.
+ * A <code>TextChangedEvent</code> is sent after changes to the text
+ * occured.
+ * <p>
+ *
+ * @param listener the listener
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT when listener is null</li>
+ * </ul>
+ */
+public void addTextChangeListener(TextChangeListener listener) {
+ if (listener == null) error(SWT.ERROR_NULL_ARGUMENT);
+ StyledTextListener typedListener = new StyledTextListener(listener);
+ textListeners.addElement(typedListener);
+}
+/**
+ * Adjusts the gap to 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;
+}
+/**
+ * Determine whether or not the replace operation is valid. DefaultContent will not allow
+ * the /r/n line delimiter to be split or partially deleted.
+ * <p>
+ *
+ * @param start start offset of text to replace
+ * @param replaceLength start offset of text to replace
+ * @param newText start offset of text to replace
+ */
+protected boolean isValidReplace(int start, int replaceLength, String newText){
+ if (replaceLength == 0) {
+ // inserting text, see if the \r\n line delimiter is being split
+ if (start == 0) return true;
+ if (start == getCharCount()) return true;
+ char before = getTextRange(start - 1, 1).charAt(0);
+ if (before == '\r') {
+ char after = getTextRange(start, 1).charAt(0);
+ if (after == '\n') return false;
+ }
+ } else {
+ // deleting text, see if part of a \r\n line delimiter is being deleted
+ char startChar = getTextRange(start, 1).charAt(0);
+ if (startChar == '\n') {
+ // see if char before delete position is \r
+ if (start != 0) {
+ char before = getTextRange(start - 1, 1).charAt(0);
+ if (before == '\r') return false;
+ }
+ }
+ char endChar = getTextRange(start + replaceLength - 1, 1).charAt(0);
+ if (endChar == '\r') {
+ // see if char after delete position is \n
+ if (start + replaceLength != getCharCount()) {
+ char after = getTextRange(start + replaceLength, 1).charAt(0);
+ if (after == '\n') return false;
+ }
+ }
+ }
+ return true;
+}
+/**
+ * Calculates the indexes of each line of text in the given range.
+ * <p>
+ *
+ * @param offset the logical start offset of the text lineate
+ * @param length the length of the text to lineate, includes gap
+ * @param numLines the number of lines to initially allocate for the line index array,
+ * passed in for efficiency (the exact number of lines may be known)
+ * @return a line indexes array where each line is identified by a start offset and
+ * a length
+ */
+int[][] indexLines(int offset, int length, int numLines){
+ int[][] indexedLines = new int[numLines][2];
+ int start = 0;
+ int 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;
+}
+/**
+ * Returns the number of lines that are in the specified text.
+ * <p>
+ *
+ * @param text the text to lineate
+ * @return number of lines in the text
+ */
+int lineCount(String text){
+ int lineCount = 0;
+ int length = text.length();
+ for (int i = 0; i < length; i++) {
+ char ch = text.charAt(i);
+ if (ch == SWT.CR) {
+ if (i + 1 < length && text.charAt(i + 1) == SWT.LF) {
+ i++;
+ }
+ lineCount++;
+ }
+ else
+ if (ch == SWT.LF) {
+ lineCount++;
+ }
+ }
+ return lineCount;
+}
+/**
+ * @return the logical length of the text store
+ */
+public int getCharCount() {
+ int length = gapEnd - gapStart;
+ return (textStore.length - length);
+}
+/**
+ * Returns the line at <code>index</code> without delimiters.
+ * <p>
+ *
+ * @param index the index of the line to return
+ * @return the logical line text (i.e., without the gap)
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_INVALID_ARGUMENT when index is out of range</li>
+ * </ul>
+ */
+public String getLine(int index) {
+ if ((index >= lineCount) || (index < 0)) error(SWT.ERROR_INVALID_ARGUMENT);
+ int start = lines[index][0];
+ int length = lines[index][1];
+ int end = start + length - 1;
+ if (!gapExists() || (end < gapStart) || (start >= gapEnd)) {
+ // line is before or after the gap
+ while ((length - 1 >= 0) && isDelimiter(textStore[start+length-1])) {
+ length--;
+ }
+ return new String(textStore, start, length);
+ } else {
+ // gap is in the specified range, strip out the gap
+ StringBuffer buf = new StringBuffer();
+ int gapLength = gapEnd - gapStart;
+ buf.append(textStore, start, gapStart - start);
+ buf.append(textStore, gapEnd, length - gapLength - (gapStart - start));
+ length = buf.length();
+ while ((length - 1 >=0) && isDelimiter(buf.charAt(length-1))) {
+ length--;
+ }
+ return Compatibility.substring(buf, 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 <code>TextChangeListener</code>.
+ * <p>
+ *
+ * @param listener the listener
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT when listener is null</li>
+ * </ul>
+ */
+public void removeTextChangeListener(TextChangeListener listener){
+ if (listener == null) error(SWT.ERROR_NULL_ARGUMENT);
+ for (int i=0; i<textListeners.size(); i++) {
+ TypedListener typedListener = (TypedListener) textListeners.elementAt(i);
+ if (typedListener.getEventListener () == listener) {
+ textListeners.removeElementAt(i);
+ break;
+ }
+ }
+}
+/**
+ * Replaces the text with <code>newText</code> starting at position <code>start</code>
+ * for a length of <code>replaceLength</code>. Notifies the appropriate listeners.
+ * <p>
+ *
+ * When sending the TextChangingEvent, <code>newLineCount</code> is the number of
+ * lines that are going to be inserted and <code>replaceLineCount</code> is
+ * the number of lines that are going to be deleted, based on the change
+ * that occurs visually. For example:
+ * <ul>
+ * <li>(replaceText,newText) ==> (replaceLineCount,newLineCount)
+ * <li>("","\n") ==> (0,1)
+ * <li>("\n\n","a") ==> (2,0)
+ * </ul>
+ * </p>
+ *
+ * @param start start offset of text to replace
+ * @param replaceLength start offset of text to replace
+ * @param newText start offset of text to replace
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_INVALID_ARGUMENT when the text change results in a multi byte
+ * line delimiter being split or partially deleted. Splitting a line
+ * delimiter by inserting text between the CR and LF characters of the
+ * \r\n delimiter or deleting part of this line delimiter is not supported</li>
+ * </ul>
+ */
+public void replaceTextRange(int start, int replaceLength, String newText){
+ // check for invalid replace operations
+ if (!isValidReplace(start, replaceLength, newText)) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+
+ // inform listeners
+ StyledTextEvent event = new StyledTextEvent(this);
+ event.type = StyledText.TextChanging;
+ event.start = start;
+ event.replaceLineCount = lineCount(start, replaceLength);
+ event.text = newText;
+ event.newLineCount = lineCount(newText);
+ event.replaceCharCount = replaceLength;
+ event.newCharCount = newText.length();
+ sendTextEvent(event);
+
+ // first delete the text to be replaced
+ delete(start, replaceLength, event.replaceLineCount + 1);
+ // then insert the new text
+ insert(start, newText);
+ // inform listeners
+ event = new StyledTextEvent(this);
+ event.type = StyledText.TextChanged;
+ sendTextEvent(event);
+ // 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);
+}
}
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
index 19224bd3cf..962386b47f 100755
--- 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
@@ -1,681 +1,681 @@
-package org.eclipse.swt.custom;
-/*
+package org.eclipse.swt.custom;
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-import org.eclipse.swt.graphics.*;
-import org.eclipse.swt.internal.Compatibility;
-import java.util.Vector;
-
-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) {
- insertStyles(new StyleRange[] {style}, index);
-}
-/**
- * Insert the styles at the given location.
- * <p>
- *
- * @param insertStyles the new styles
- * @param index the index at which to insert the styles (the first new style
- * will reside at this index)
- *
- */
-void insertStyles(StyleRange[] insertStyles, int index) {
- int size = styles.length;
- int insertCount = insertStyles.length;
- int spaceNeeded = styleCount + insertCount - size;
- if (spaceNeeded > 0) {
- StyleRange[] newStyles = new StyleRange[size+spaceNeeded];
- System.arraycopy(styles, 0, newStyles, 0, size);
- styles = newStyles;
- }
- // shift the styles down to make room for the new styles
- System.arraycopy(styles, index, styles, index + insertCount, styleCount - index);
- // add the new styles
- System.arraycopy(insertStyles, 0, styles, index, insertCount);
- styleCount = styleCount + insertCount;
-}
-/**
- * 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;
- int deleteStyle = -1;
- int deleteCount = 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
- if (deleteStyle == -1) {
- deleteStyle = i;
- }
- deleteCount++;
- } else {
- // beginning of overlap needs to be cleared
- overlap.start=clearStyleEnd + 1;
- overlap.length=overlapEnd - overlap.start + 1;
- break;
- }
- }
- count++;
- }
- deleteStyles(deleteStyle, deleteCount);
-}
-/**
- * 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(Compatibility.pow2(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) {
- deleteStyles(index, 1);
-}
-/**
- * Delete count styles starting at <code>index</code>.
- * <p>
- *
- * @param index the index of the style to be deleted
- * @param count the number of styles to be deleted
- */
-void deleteStyles(int index, int count) {
- if ((count == 0) || (index < 0)) return;
- // shift the styles up
- System.arraycopy(styles, index + count, styles, index, styleCount - (index + count));
- for (int i=0; i<count; i++) {
- styles[styleCount - i - 1] = null;
- }
- styleCount = styleCount - count;
-}
-/**
- * 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) {
- int lineIndex = content.getLineAtOffset(event.lineOffset);
- event.lineBackground = lineBackgrounds[lineIndex];
-}
-/**
- * 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.addElement(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++;
- }
-}
-/**
- * Replace the styles for the given range.
- * <p>
- *
- * @param styles the new styles, must be in order and non-overlapping
- */
-void replaceStyleRanges(int start, int length, StyleRange[] ranges) {
- clearStyle(new StyleRange(start, length, null, null));
- // find insert point
- int high = styleCount;
- int low = -1;
- int index = high;
- while (high - low > 1) {
- index = (high + low) / 2;
- StyleRange style = styles[index];
- if (start <= style.start) {
- high = index;
- }
- else {
- low = index;
- }
- }
- insertStyles(ranges, high);
-}
-/**
- * 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 pending text
- * change.
- * Called by StyledText when a TextChangingEvent is received.
- * <p>
- *
- * @param event the event with the text change information
- */
-public void textChanging(TextChangingEvent event) {
- int startLine = content.getLineAtOffset(event.start);
- int startLineOffset = content.getOffsetAtLine(startLine);
-
- textChanging(event.start, -event.replaceCharCount);
- textChanging(event.start, event.newCharCount);
-
- if (event.replaceCharCount == content.getCharCount()) {
- // all text is going to be replaced, clear line backgrounds
- linesChanging(0, -lineCount);
- linesChanging(0, content.getLineCount() - event.replaceLineCount + event.newLineCount);
- return;
- }
-
- if (event.start != startLineOffset) {
- startLine = startLine + 1;
- }
-
- linesChanging(startLine, -event.replaceLineCount);
- linesChanging(startLine, event.newLineCount);
-}
-/*
- * Updates the line backgrounds to reflect a pending text change.
- * <p>
- *
- * @param start the starting line of the change that is about to take place
- * @param delta the number of lines in the change, > 0 indicates lines inserted,
- * < 0 indicates lines deleted
- */
-void linesChanging(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 is about to
- * take place
- * @param delta the length of the change, > 0 indicates text inserted,
- * < 0 indicates text deleted
- */
-void textChanging(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;
- int deleteStart = -1;
- int deleteCount = 0;
- 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
- if (deleteStart == -1) {
- deleteStart = index;
- }
- deleteCount++;
- } else {
- // style starts in change range, ends after change range
- style.start = start;
- style.length = styleEnd - end;
- index++;
- break;
- }
- }
- }
- }
- deleteStyles(deleteStart, deleteCount);
- // change the offsets of the styles after the affected styles
- for (int i = index - deleteCount; 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;
-}
-/**
- * Returns the styles for the given range. Returns the existing styles,
- * so be careful not to modify the return value. Styles are not cloned
- * in order to make this method as efficient as possible.
- * <p>
- *
- * @param offset the start position of the text range
- * @param length the length of the text range
- * @return a StyleRange array or null if no styles are specified for the text
- * range
- */
-StyleRange[] getStyleRangesFor(int offset, int length) {
- if (styleCount == 0) return null;
- Point pt = getOverlappingStyles(offset, length);
- if (pt == null || pt.y == 0) return null;
- StyleRange[] ranges = new StyleRange[pt.y];
- for (int i=0; i<pt.y; i++) {
- StyleRange newStyle = styles[pt.x + i];
- ranges[i]=newStyle;
- }
- return ranges;
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.internal.Compatibility;
+import java.util.Vector;
+
+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) {
+ insertStyles(new StyleRange[] {style}, index);
+}
+/**
+ * Insert the styles at the given location.
+ * <p>
+ *
+ * @param insertStyles the new styles
+ * @param index the index at which to insert the styles (the first new style
+ * will reside at this index)
+ *
+ */
+void insertStyles(StyleRange[] insertStyles, int index) {
+ int size = styles.length;
+ int insertCount = insertStyles.length;
+ int spaceNeeded = styleCount + insertCount - size;
+ if (spaceNeeded > 0) {
+ StyleRange[] newStyles = new StyleRange[size+spaceNeeded];
+ System.arraycopy(styles, 0, newStyles, 0, size);
+ styles = newStyles;
+ }
+ // shift the styles down to make room for the new styles
+ System.arraycopy(styles, index, styles, index + insertCount, styleCount - index);
+ // add the new styles
+ System.arraycopy(insertStyles, 0, styles, index, insertCount);
+ styleCount = styleCount + insertCount;
+}
+/**
+ * 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;
+ int deleteStyle = -1;
+ int deleteCount = 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
+ if (deleteStyle == -1) {
+ deleteStyle = i;
+ }
+ deleteCount++;
+ } else {
+ // beginning of overlap needs to be cleared
+ overlap.start=clearStyleEnd + 1;
+ overlap.length=overlapEnd - overlap.start + 1;
+ break;
+ }
+ }
+ count++;
+ }
+ deleteStyles(deleteStyle, deleteCount);
+}
+/**
+ * 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(Compatibility.pow2(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) {
+ deleteStyles(index, 1);
+}
+/**
+ * Delete count styles starting at <code>index</code>.
+ * <p>
+ *
+ * @param index the index of the style to be deleted
+ * @param count the number of styles to be deleted
+ */
+void deleteStyles(int index, int count) {
+ if ((count == 0) || (index < 0)) return;
+ // shift the styles up
+ System.arraycopy(styles, index + count, styles, index, styleCount - (index + count));
+ for (int i=0; i<count; i++) {
+ styles[styleCount - i - 1] = null;
+ }
+ styleCount = styleCount - count;
+}
+/**
+ * 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) {
+ int lineIndex = content.getLineAtOffset(event.lineOffset);
+ event.lineBackground = lineBackgrounds[lineIndex];
+}
+/**
+ * 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.addElement(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++;
+ }
+}
+/**
+ * Replace the styles for the given range.
+ * <p>
+ *
+ * @param styles the new styles, must be in order and non-overlapping
+ */
+void replaceStyleRanges(int start, int length, StyleRange[] ranges) {
+ clearStyle(new StyleRange(start, length, null, null));
+ // find insert point
+ int high = styleCount;
+ int low = -1;
+ int index = high;
+ while (high - low > 1) {
+ index = (high + low) / 2;
+ StyleRange style = styles[index];
+ if (start <= style.start) {
+ high = index;
+ }
+ else {
+ low = index;
+ }
+ }
+ insertStyles(ranges, high);
+}
+/**
+ * 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 pending text
+ * change.
+ * Called by StyledText when a TextChangingEvent is received.
+ * <p>
+ *
+ * @param event the event with the text change information
+ */
+public void textChanging(TextChangingEvent event) {
+ int startLine = content.getLineAtOffset(event.start);
+ int startLineOffset = content.getOffsetAtLine(startLine);
+
+ textChanging(event.start, -event.replaceCharCount);
+ textChanging(event.start, event.newCharCount);
+
+ if (event.replaceCharCount == content.getCharCount()) {
+ // all text is going to be replaced, clear line backgrounds
+ linesChanging(0, -lineCount);
+ linesChanging(0, content.getLineCount() - event.replaceLineCount + event.newLineCount);
+ return;
+ }
+
+ if (event.start != startLineOffset) {
+ startLine = startLine + 1;
+ }
+
+ linesChanging(startLine, -event.replaceLineCount);
+ linesChanging(startLine, event.newLineCount);
+}
+/*
+ * Updates the line backgrounds to reflect a pending text change.
+ * <p>
+ *
+ * @param start the starting line of the change that is about to take place
+ * @param delta the number of lines in the change, > 0 indicates lines inserted,
+ * < 0 indicates lines deleted
+ */
+void linesChanging(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 is about to
+ * take place
+ * @param delta the length of the change, > 0 indicates text inserted,
+ * < 0 indicates text deleted
+ */
+void textChanging(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;
+ int deleteStart = -1;
+ int deleteCount = 0;
+ 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
+ if (deleteStart == -1) {
+ deleteStart = index;
+ }
+ deleteCount++;
+ } else {
+ // style starts in change range, ends after change range
+ style.start = start;
+ style.length = styleEnd - end;
+ index++;
+ break;
+ }
+ }
+ }
+ }
+ deleteStyles(deleteStart, deleteCount);
+ // change the offsets of the styles after the affected styles
+ for (int i = index - deleteCount; 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;
+}
+/**
+ * Returns the styles for the given range. Returns the existing styles,
+ * so be careful not to modify the return value. Styles are not cloned
+ * in order to make this method as efficient as possible.
+ * <p>
+ *
+ * @param offset the start position of the text range
+ * @param length the length of the text range
+ * @return a StyleRange array or null if no styles are specified for the text
+ * range
+ */
+StyleRange[] getStyleRangesFor(int offset, int length) {
+ if (styleCount == 0) return null;
+ Point pt = getOverlappingStyles(offset, length);
+ if (pt == null || pt.y == 0) return null;
+ StyleRange[] ranges = new StyleRange[pt.y];
+ for (int i=0; i<pt.y; i++) {
+ StyleRange newStyle = styles[pt.x + i];
+ ranges[i]=newStyle;
+ }
+ return ranges;
+}
}
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
index 6a0b40c2dd..8bda363356 100755
--- 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
@@ -1,25 +1,25 @@
-package org.eclipse.swt.custom;
-/*
+package org.eclipse.swt.custom;
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-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;
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+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;
+}
}
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
index a365c831ff..1c15e0c4b3 100755
--- 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
@@ -1,23 +1,23 @@
-package org.eclipse.swt.custom;
-/*
+package org.eclipse.swt.custom;
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-import org.eclipse.swt.internal.SWTEventListener;
-
-public interface ExtendedModifyListener extends SWTEventListener {
-/**
- * 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);
-}
-
-
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+import org.eclipse.swt.internal.SWTEventListener;
+
+public interface ExtendedModifyListener extends SWTEventListener {
+/**
+ * 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
index 916f265a81..5c050eeb4f 100755
--- 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
@@ -1,27 +1,27 @@
-package org.eclipse.swt.custom;
-/*
+package org.eclipse.swt.custom;
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-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;
-}
-}
-
-
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+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
index 14103cf4c2..bb00d05b1a 100755
--- 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
@@ -1,23 +1,23 @@
-package org.eclipse.swt.custom;
-/*
+package org.eclipse.swt.custom;
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-import org.eclipse.swt.internal.SWTEventListener;
-
-public interface LineBackgroundListener extends SWTEventListener {
-
-/**
- * This method is called when a line is about to be drawn in order to get its
- * background color.
- * <p>
- *
- * @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);
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+import org.eclipse.swt.internal.SWTEventListener;
+
+public interface LineBackgroundListener extends SWTEventListener {
+
+/**
+ * This method is called when a line is about to be drawn in order to get its
+ * background color.
+ * <p>
+ *
+ * @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);
}
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
index 74d7fa5bf0..cf65387bb0 100755
--- 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
@@ -1,25 +1,25 @@
-package org.eclipse.swt.custom;
-/*
+package org.eclipse.swt.custom;
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-import org.eclipse.swt.events.*;
-
-/**
- * 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;
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+import org.eclipse.swt.events.*;
+
+/**
+ * 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;
+}
}
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
index 9ade47d9f0..0d172e7b6e 100755
--- 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
@@ -1,22 +1,22 @@
-package org.eclipse.swt.custom;
-/*
+package org.eclipse.swt.custom;
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-import org.eclipse.swt.internal.SWTEventListener;
-
-public interface LineStyleListener extends SWTEventListener {
-/**
- * This method is called when a line is about to be drawn in order to get the
- * line's style information.
- * <p>
- *
- * @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);
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+import org.eclipse.swt.internal.SWTEventListener;
+
+public interface LineStyleListener extends SWTEventListener {
+/**
+ * This method is called when a line is about to be drawn in order to get the
+ * line's style information.
+ * <p>
+ *
+ * @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);
}
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
index 43ab4c30ec..9a22421a9f 100755
--- 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
@@ -1,250 +1,250 @@
-package org.eclipse.swt.custom;
-
-/*
+package org.eclipse.swt.custom;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-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;
-}
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+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
index e445f0e40e..8ec93cc273 100755
--- 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
@@ -1,62 +1,62 @@
-package org.eclipse.swt.custom;
-/*
+package org.eclipse.swt.custom;
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-
-/**
- * This class provides access to the public constants provided by <code>StyledText</code>.
- */
-public class ST {
-
- /* StyledText key action constants. Key bindings for the actions are set
- * by the StyledText widget. @see StyledText#createKeyBindings()
- */
-
- /* Navigation Key Actions */
- public static final int LINE_UP = 16777217; // binding = SWT.ARROW_UP
- public static final int LINE_DOWN = 16777218; // binding = SWT.ARROW_DOWN
- public static final int LINE_START = 16777223; // binding = SWT.HOME
- public static final int LINE_END = 16777224; // binding = SWT.END
- public static final int COLUMN_PREVIOUS = 16777219; // binding = SWT.ARROW_LEFT
- public static final int COLUMN_NEXT = 16777220; // binding = SWT.ARROW_RIGHT
- public static final int PAGE_UP = 16777221; // binding = SWT.PAGE_UP
- public static final int PAGE_DOWN = 16777222; // binding = SWT.PAGE_DOWN
- public static final int WORD_PREVIOUS = 17039363; // binding = SWT.MOD1 + SWT.ARROW_LEFT
- public static final int WORD_NEXT = 17039364; // binding = SWT.MOD1 + SWT.ARROW_RIGHT
- public static final int TEXT_START = 17039367; // binding = SWT.MOD1 + SWT.HOME
- public static final int TEXT_END = 17039368; // binding = SWT.MOD1 + SWT.END
- public static final int WINDOW_START = 17039365; // binding = SWT.MOD1 + SWT.PAGE_UP
- public static final int WINDOW_END = 17039366; // binding = SWT.MOD1 + SWT.PAGE_DOWN
-
- /* Selection Key Actions */
- public static final int SELECT_LINE_UP = 16908289; // binding = SWT.MOD2 + SWT.ARROW_UP
- public static final int SELECT_LINE_DOWN = 16908290; // binding = SWT.MOD2 + SWT.ARROW_DOWN
- public static final int SELECT_LINE_START = 16908295; // binding = SWT.MOD2 + SWT.HOME
- public static final int SELECT_LINE_END = 16908296; // binding = SWT.MOD2 + SWT.END
- public static final int SELECT_COLUMN_PREVIOUS = 16908291; // binding = SWT.MOD2 + SWT.ARROW_LEFT
- public static final int SELECT_COLUMN_NEXT = 16908292; // binding = SWT.MOD2 + SWT.ARROW_RIGHT
- public static final int SELECT_PAGE_UP = 16908293; // binding = SWT.MOD2 + SWT.PAGE_UP
- public static final int SELECT_PAGE_DOWN = 16908294; // binding = SWT.MOD2 + SWT.PAGE_DOWN
- public static final int SELECT_WORD_PREVIOUS = 17170435; // binding = SWT.MOD1 + SWT.MOD2 + SWT.ARROW_LEFT
- public static final int SELECT_WORD_NEXT = 17170436; // binding = SWT.MOD1 + SWT.MOD2 + SWT.ARROW_RIGHT
- public static final int SELECT_TEXT_START = 17170439; // binding = SWT.MOD1 + SWT.MOD2 + SWT.HOME
- public static final int SELECT_TEXT_END = 17170440; // binding = SWT.MOD1 + SWT.MOD2 + SWT.END
- public static final int SELECT_WINDOW_START = 17170437; // binding = SWT.MOD1 + SWT.MOD2 + SWT.PAGE_UP
- public static final int SELECT_WINDOW_END = 17170438; // binding = SWT.MOD1 + SWT.MOD2 + SWT.PAGE_DOWN
-
- /* Modification Key Actions */
- public static final int CUT = 131199; // binding = SWT.MOD2 + SWT.DEL
- public static final int COPY = 17039369; // binding = SWT.MOD1 + SWT.INSERT;
- public static final int PASTE = 16908297; // binding = SWT.MOD2 + SWT.INSERT ;
- public static final int DELETE_PREVIOUS = '\b'; // binding = SWT.BS;
- public static final int DELETE_NEXT = 0x7F; // binding = SWT.DEL;
- public static final int DELETE_WORD_PREVIOUS = 262152; // binding = SWT.BS | SWT.MOD1;
- public static final int DELETE_WORD_NEXT = 262271; // binding = SWT.DEL | SWT.MOD1;
-
- /* Miscellaneous Key Actions */
- public static final int TOGGLE_OVERWRITE = 16777225; // binding = SWT.INSERT;
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+
+/**
+ * This class provides access to the public constants provided by <code>StyledText</code>.
+ */
+public class ST {
+
+ /* StyledText key action constants. Key bindings for the actions are set
+ * by the StyledText widget. @see StyledText#createKeyBindings()
+ */
+
+ /* Navigation Key Actions */
+ public static final int LINE_UP = 16777217; // binding = SWT.ARROW_UP
+ public static final int LINE_DOWN = 16777218; // binding = SWT.ARROW_DOWN
+ public static final int LINE_START = 16777223; // binding = SWT.HOME
+ public static final int LINE_END = 16777224; // binding = SWT.END
+ public static final int COLUMN_PREVIOUS = 16777219; // binding = SWT.ARROW_LEFT
+ public static final int COLUMN_NEXT = 16777220; // binding = SWT.ARROW_RIGHT
+ public static final int PAGE_UP = 16777221; // binding = SWT.PAGE_UP
+ public static final int PAGE_DOWN = 16777222; // binding = SWT.PAGE_DOWN
+ public static final int WORD_PREVIOUS = 17039363; // binding = SWT.MOD1 + SWT.ARROW_LEFT
+ public static final int WORD_NEXT = 17039364; // binding = SWT.MOD1 + SWT.ARROW_RIGHT
+ public static final int TEXT_START = 17039367; // binding = SWT.MOD1 + SWT.HOME
+ public static final int TEXT_END = 17039368; // binding = SWT.MOD1 + SWT.END
+ public static final int WINDOW_START = 17039365; // binding = SWT.MOD1 + SWT.PAGE_UP
+ public static final int WINDOW_END = 17039366; // binding = SWT.MOD1 + SWT.PAGE_DOWN
+
+ /* Selection Key Actions */
+ public static final int SELECT_LINE_UP = 16908289; // binding = SWT.MOD2 + SWT.ARROW_UP
+ public static final int SELECT_LINE_DOWN = 16908290; // binding = SWT.MOD2 + SWT.ARROW_DOWN
+ public static final int SELECT_LINE_START = 16908295; // binding = SWT.MOD2 + SWT.HOME
+ public static final int SELECT_LINE_END = 16908296; // binding = SWT.MOD2 + SWT.END
+ public static final int SELECT_COLUMN_PREVIOUS = 16908291; // binding = SWT.MOD2 + SWT.ARROW_LEFT
+ public static final int SELECT_COLUMN_NEXT = 16908292; // binding = SWT.MOD2 + SWT.ARROW_RIGHT
+ public static final int SELECT_PAGE_UP = 16908293; // binding = SWT.MOD2 + SWT.PAGE_UP
+ public static final int SELECT_PAGE_DOWN = 16908294; // binding = SWT.MOD2 + SWT.PAGE_DOWN
+ public static final int SELECT_WORD_PREVIOUS = 17170435; // binding = SWT.MOD1 + SWT.MOD2 + SWT.ARROW_LEFT
+ public static final int SELECT_WORD_NEXT = 17170436; // binding = SWT.MOD1 + SWT.MOD2 + SWT.ARROW_RIGHT
+ public static final int SELECT_TEXT_START = 17170439; // binding = SWT.MOD1 + SWT.MOD2 + SWT.HOME
+ public static final int SELECT_TEXT_END = 17170440; // binding = SWT.MOD1 + SWT.MOD2 + SWT.END
+ public static final int SELECT_WINDOW_START = 17170437; // binding = SWT.MOD1 + SWT.MOD2 + SWT.PAGE_UP
+ public static final int SELECT_WINDOW_END = 17170438; // binding = SWT.MOD1 + SWT.MOD2 + SWT.PAGE_DOWN
+
+ /* Modification Key Actions */
+ public static final int CUT = 131199; // binding = SWT.MOD2 + SWT.DEL
+ public static final int COPY = 17039369; // binding = SWT.MOD1 + SWT.INSERT;
+ public static final int PASTE = 16908297; // binding = SWT.MOD2 + SWT.INSERT ;
+ public static final int DELETE_PREVIOUS = '\b'; // binding = SWT.BS;
+ public static final int DELETE_NEXT = 0x7F; // binding = SWT.DEL;
+ public static final int DELETE_WORD_PREVIOUS = 262152; // binding = SWT.BS | SWT.MOD1;
+ public static final int DELETE_WORD_NEXT = 262271; // binding = SWT.DEL | SWT.MOD1;
+
+ /* Miscellaneous Key Actions */
+ public static final int TOGGLE_OVERWRITE = 16777225; // binding = SWT.INSERT;
+}
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
index f39fec4d10..e9df0ca766 100755
--- 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
@@ -1,450 +1,450 @@
-package org.eclipse.swt.custom;
-
-/*
+package org.eclipse.swt.custom;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-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;
- private final static String LAYOUT_RATIO = "layout ratio"; //$NON-NLS-1$
-
-/**
- * Constructs a new instance of this class given its parent
- * and a style value describing its behavior and appearance.
- * <p>
- * The style value is either one of the style constants defined in
- * class <code>SWT</code> which is applicable to instances of this
- * class, or must be built by <em>bitwise OR</em>'ing together
- * (that is, using the <code>int</code> "|" operator) two or more
- * of those <code>SWT</code> style constants. The class description
- * lists the style constants that are applicable to the class.
- * Style bits are also inherited from superclasses.
- * </p>
- *
- * @param parent a widget which will be the parent of the new instance (cannot be null)
- * @param style the style of widget to construct
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
- * </ul>
- *
- * @see SWT#HORIZONTAL
- * @see SWT#VERTICAL
- * @see #getStyle
- */
-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) {
- checkWidget();
- Control[] controls = getControls(true);
- if (controls.length == 0) return new Point(wHint, hHint);
-
- int width = 0;
- int height = 0;
- boolean vertical = (orientation == SWT.VERTICAL);
- if (vertical) {
- height += (controls.length - 1) * SASH_WIDTH;
- } else {
- width += (controls.length - 1) * SASH_WIDTH;
- }
- for (int i = 0; i < controls.length; i++) {
- if (vertical) {
- Point size = controls[i].computeSize(wHint, SWT.DEFAULT);
- height += size.y;
- width = Math.max(width, size.x);
- } else {
- Point size = controls[i].computeSize(SWT.DEFAULT, hHint);
- width += size.x;
- height = Math.max(height, size.y);
- }
- }
- if (wHint != SWT.DEFAULT) width = wHint;
- if (hHint != SWT.DEFAULT) height = hHint;
-
- return new Point(width, height);
-}
-/**
- * Returns SWT.HORIZONTAL if the controls in the SashForm are laid out side by side
- * or SWT.VERTICAL if the controls in the SashForm are laid out top to bottom.
- *
- * @return SWT.HORIZONTAL or SWT.VERTICAL
- */
-public int getOrientation() {
- //checkWidget();
- return orientation;
-}
-/**
- * Answer the control that currently is maximized in the SashForm.
- * This value may be null.
- *
- * @return the control that currently is maximized or null
- */
-public Control getMaximizedControl(){
- //checkWidget();
- return this.maxControl;
-}
-/**
- * Answer the relative weight of each child in the SashForm. The weight represents the
- * percent of the total width (if SashForm has Horizontal orientation) or
- * total height (if SashForm has Vertical orientation) each control occupies.
- * The weights are returned in order of the creation of the widgets (weight[0]
- * corresponds to the weight of the first child created).
- *
- * @return the relative weight of each child
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-
-public int[] getWeights() {
- checkWidget();
- Control[] cArray = getControls(false);
- 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) {
- checkWidget();
- 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.
- *
- * @param orientation SWT.HORIZONTAL or SWT.VERTICAL
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * <li>ERROR_INVALID_ARGUMENT - if the value of orientation is not SWT.HORIZONTAL or SWT.VERTICAL
- * </ul>
- */
-public void setOrientation(int orientation) {
- checkWidget();
- if (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) {
- checkWidget();
-}
-/**
- * Specify the control that should take up the entire client area of the SashForm.
- * If one control has been maximized, and this method is called with a different control,
- * the previous control will be minimized and the new control will be maximized..
- * if the value of control is null, the SashForm will minimize all controls and return to
- * the default layout where all controls are laid out separated by sashes.
- *
- * @param control the control to be maximized or null
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public void setMaximizedControl(Control control){
- checkWidget();
- if (control == null) {
- if (maxControl != null) {
- this.maxControl = null;
- layout();
- 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();
-}
-
-/**
- * Specify the relative weight of each child in the SashForm. This will determine
- * what percent of the total width (if SashForm has Horizontal orientation) or
- * total height (if SashForm has Vertical orientation) each control will occupy.
- * The weights must be positive values and there must be an entry for each
- * non-sash child of the SashForm.
- *
- * @param weights the relative weight of each child
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * <li>ERROR_INVALID_ARGUMENT - if the weights value is null or of incorrect length (must match the number of children)</li>
- * </ul>
- */
-public void setWeights(int[] weights) {
- checkWidget();
- Control[] cArray = getControls(false);
- if (weights == null || weights.length != cArray.length) {
- SWT.error(SWT.ERROR_INVALID_ARGUMENT);
- }
-
- int total = 0;
- for (int i = 0; i < weights.length; i++) {
- if (weights[i] < 0) {
- SWT.error(SWT.ERROR_INVALID_ARGUMENT);
- }
- total += weights[i];
- }
- if (total == 0) {
- SWT.error(SWT.ERROR_INVALID_ARGUMENT);
- }
- for (int i = 0; i < cArray.length; i++) {
- cArray[i].setData(LAYOUT_RATIO, new Float((float)weights[i] / (float)total));
- }
-
- layout();
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+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;
+ private final static String LAYOUT_RATIO = "layout ratio"; //$NON-NLS-1$
+
+/**
+ * Constructs a new instance of this class given its parent
+ * and a style value describing its behavior and appearance.
+ * <p>
+ * The style value is either one of the style constants defined in
+ * class <code>SWT</code> which is applicable to instances of this
+ * class, or must be built by <em>bitwise OR</em>'ing together
+ * (that is, using the <code>int</code> "|" operator) two or more
+ * of those <code>SWT</code> style constants. The class description
+ * lists the style constants that are applicable to the class.
+ * Style bits are also inherited from superclasses.
+ * </p>
+ *
+ * @param parent a widget which will be the parent of the new instance (cannot be null)
+ * @param style the style of widget to construct
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
+ * </ul>
+ *
+ * @see SWT#HORIZONTAL
+ * @see SWT#VERTICAL
+ * @see #getStyle
+ */
+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) {
+ checkWidget();
+ Control[] controls = getControls(true);
+ if (controls.length == 0) return new Point(wHint, hHint);
+
+ int width = 0;
+ int height = 0;
+ boolean vertical = (orientation == SWT.VERTICAL);
+ if (vertical) {
+ height += (controls.length - 1) * SASH_WIDTH;
+ } else {
+ width += (controls.length - 1) * SASH_WIDTH;
+ }
+ for (int i = 0; i < controls.length; i++) {
+ if (vertical) {
+ Point size = controls[i].computeSize(wHint, SWT.DEFAULT);
+ height += size.y;
+ width = Math.max(width, size.x);
+ } else {
+ Point size = controls[i].computeSize(SWT.DEFAULT, hHint);
+ width += size.x;
+ height = Math.max(height, size.y);
+ }
+ }
+ if (wHint != SWT.DEFAULT) width = wHint;
+ if (hHint != SWT.DEFAULT) height = hHint;
+
+ return new Point(width, height);
+}
+/**
+ * Returns SWT.HORIZONTAL if the controls in the SashForm are laid out side by side
+ * or SWT.VERTICAL if the controls in the SashForm are laid out top to bottom.
+ *
+ * @return SWT.HORIZONTAL or SWT.VERTICAL
+ */
+public int getOrientation() {
+ //checkWidget();
+ return orientation;
+}
+/**
+ * Answer the control that currently is maximized in the SashForm.
+ * This value may be null.
+ *
+ * @return the control that currently is maximized or null
+ */
+public Control getMaximizedControl(){
+ //checkWidget();
+ return this.maxControl;
+}
+/**
+ * Answer the relative weight of each child in the SashForm. The weight represents the
+ * percent of the total width (if SashForm has Horizontal orientation) or
+ * total height (if SashForm has Vertical orientation) each control occupies.
+ * The weights are returned in order of the creation of the widgets (weight[0]
+ * corresponds to the weight of the first child created).
+ *
+ * @return the relative weight of each child
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+
+public int[] getWeights() {
+ checkWidget();
+ Control[] cArray = getControls(false);
+ 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) {
+ checkWidget();
+ 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.
+ *
+ * @param orientation SWT.HORIZONTAL or SWT.VERTICAL
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * <li>ERROR_INVALID_ARGUMENT - if the value of orientation is not SWT.HORIZONTAL or SWT.VERTICAL
+ * </ul>
+ */
+public void setOrientation(int orientation) {
+ checkWidget();
+ if (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) {
+ checkWidget();
+}
+/**
+ * Specify the control that should take up the entire client area of the SashForm.
+ * If one control has been maximized, and this method is called with a different control,
+ * the previous control will be minimized and the new control will be maximized..
+ * if the value of control is null, the SashForm will minimize all controls and return to
+ * the default layout where all controls are laid out separated by sashes.
+ *
+ * @param control the control to be maximized or null
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setMaximizedControl(Control control){
+ checkWidget();
+ if (control == null) {
+ if (maxControl != null) {
+ this.maxControl = null;
+ layout();
+ 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();
+}
+
+/**
+ * Specify the relative weight of each child in the SashForm. This will determine
+ * what percent of the total width (if SashForm has Horizontal orientation) or
+ * total height (if SashForm has Vertical orientation) each control will occupy.
+ * The weights must be positive values and there must be an entry for each
+ * non-sash child of the SashForm.
+ *
+ * @param weights the relative weight of each child
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * <li>ERROR_INVALID_ARGUMENT - if the weights value is null or of incorrect length (must match the number of children)</li>
+ * </ul>
+ */
+public void setWeights(int[] weights) {
+ checkWidget();
+ Control[] cArray = getControls(false);
+ if (weights == null || weights.length != cArray.length) {
+ SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+ }
+
+ int total = 0;
+ for (int i = 0; i < weights.length; i++) {
+ if (weights[i] < 0) {
+ SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+ }
+ total += weights[i];
+ }
+ if (total == 0) {
+ SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+ }
+ for (int i = 0; i < cArray.length; i++) {
+ cArray[i].setData(LAYOUT_RATIO, new Float((float)weights[i] / (float)total));
+ }
+
+ layout();
+}
}
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
index f8c53bde76..09476a36ef 100755
--- 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
@@ -1,583 +1,583 @@
-package org.eclipse.swt.custom;
-
-/*
+package org.eclipse.swt.custom;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-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>There are two ways to use the ScrolledComposite:
- *
- * <p>
- * 1) Set the size of the control that is being scrolled and the ScrolledComposite
- * will show scrollbars when the contained control can not be fully seen.
- *
- * 2) The second way imitates the way a browser would work. Set the minimum size of
- * the control and the ScrolledComposite will show scroll bars if the visible area is
- * less than the minimum size of the control and it will expand the size of the control
- * if the visible area is greater than the minimum size. This requires invoking
- * both setMinWidth(), setMinHeight() and setExpandHorizontal(), setExpandVertical().
- *
- * <code><pre>
- * public static void main (String [] args) {
- * Display display = new Display ();
- * Color red = display.getSystemColor(SWT.COLOR_RED);
- * Color blue = display.getSystemColor(SWT.COLOR_BLUE);
- * Shell shell = new Shell (display);
- * shell.setLayout(new FillLayout());
- *
- * // set the size of the scrolled content - method 1
- * final ScrolledComposite sc1 = new ScrolledComposite(shell, SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER);
- * final Composite c1 = new Composite(sc1, SWT.NONE);
- * sc1.setContent(c1);
- * c1.setBackground(red);
- * GridLayout layout = new GridLayout();
- * layout.numColumns = 4;
- * c1.setLayout(layout);
- * Button b1 = new Button (c1, SWT.PUSH);
- * b1.setText("first button");
- * c1.setSize(c1.computeSize(SWT.DEFAULT, SWT.DEFAULT));
- *
- * // set the minimum width and height of the scrolled content - method 2
- * final ScrolledComposite sc2 = new ScrolledComposite(shell, SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER);
- * sc2.setExpandHorizontal(true);
- * sc2.setExpandVertical(true);
- * final Composite c2 = new Composite(sc2, SWT.NONE);
- * sc2.setContent(c2);
- * c2.setBackground(blue);
- * layout = new GridLayout();
- * layout.numColumns = 4;
- * c2.setLayout(layout);
- * Button b2 = new Button (c2, SWT.PUSH);
- * b2.setText("first button");
- * sc2.setMinSize(c2.computeSize(SWT.DEFAULT, SWT.DEFAULT));
- *
- * Button add = new Button (shell, SWT.PUSH);
- * add.setText("add children");
- * final int[] index = new int[]{0};
- * add.addListener(SWT.Selection, new Listener() {
- * public void handleEvent(Event e) {
- * index[0]++;
- * Button button = new Button(c1, SWT.PUSH);
- * button.setText("button "+index[0]);
- * // reset size of content so children can be seen - method 1
- * c1.setSize(c1.computeSize(SWT.DEFAULT, SWT.DEFAULT));
- * c1.layout();
- *
- * button = new Button(c2, SWT.PUSH);
- * button.setText("button "+index[0]);
- * // reset the minimum width and height so children can be seen - method 2
- * sc2.setMinSize(c2.computeSize(SWT.DEFAULT, SWT.DEFAULT));
- * c2.layout();
- * }
- * });
- *
- * shell.open ();
- * while (!shell.isDisposed ()) {
- * if (!display.readAndDispatch ()) display.sleep ();
- * }
- * display.dispose ();
- * }
- * </pre></code>
- *
- * <dl>
- * <dt><b>Styles:</b><dd>H_SCROLL, V_SCROLL
- * </dl>
- */
-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;
- private boolean alwaysShowScroll = false;
- private boolean inResize = false;
-
-/**
- * Constructs a new instance of this class given its parent
- * and a style value describing its behavior and appearance.
- * <p>
- * The style value is either one of the style constants defined in
- * class <code>SWT</code> which is applicable to instances of this
- * class, or must be built by <em>bitwise OR</em>'ing together
- * (that is, using the <code>int</code> "|" operator) two or more
- * of those <code>SWT</code> style constants. The class description
- * lists the style constants that are applicable to the class.
- * Style bits are also inherited from superclasses.
- * </p>
- *
- * @param parent a widget which will be the parent of the new instance (cannot be null)
- * @param style the style of widget to construct
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
- * </ul>
- *
- * @see SWT#H_SCROLL
- * @see SWT#V_SCROLL
- * @see #getStyle
- */
-public ScrolledComposite(Composite parent, int style) {
- super(parent, checkStyle(style));
-
- 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;
-}
-
-public Point computeSize (int wHint, int hHint, boolean changed) {
- checkWidget ();
- /*
- * When a composite does layout without using a layout
- * manager, it must take into account the preferred size
- * of it's children when computing it's preferred size in
- * the same way that a layout manager would. In particular,
- * when a scrolled composite hides the scroll bars and
- * places a child to fill the client area, then repeated
- * calls to compute the preferred size of the scrolled
- * composite should not keep adding in the space used by
- * the scroll bars.
- */
- if (content == null) {
- return super.computeSize (wHint, hHint, changed);
- }
- Point size = content.computeSize (wHint, hHint, changed);
- Rectangle trim = computeTrim (0, 0, size.x, size.y);
- return new Point (trim.width, trim.height);
-}
-
-/**
- * Returns the Always Show Scrollbars flag. True if the scrollbars are
- * always shown even if they are not required. False if the scrollbars are only
- * visible when some part of the composite needs to be scrolled to be seen.
- * The H_SCROLL and V_SCROLL style bits are also required to enable scrollbars in the
- * horizontal and vertical directions.
- *
- * @return the Always Show Scrollbars flag value
- */
-public boolean getAlwaysShowScrollBars() {
- //checkWidget();
- return alwaysShowScroll;
-}
-
-/**
- * Get the content that is being scrolled.
- *
- * @return the control displayed in the content area
- */
-public Control getContent() {
- //checkWidget();
- 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);
-}
-
-public void layout(boolean changed) {
- checkWidget();
- if (content == null) return;
- Rectangle contentRect = content.getBounds();
- ScrollBar hBar = getHorizontalBar ();
- ScrollBar vBar = getVerticalBar ();
- if (!alwaysShowScroll) {
- boolean hVisible = needHScroll(contentRect, false);
- boolean vVisible = needVScroll(contentRect, hVisible);
- if (!hVisible && vVisible) hVisible = needHScroll(contentRect, vVisible);
- if (hBar != null) hBar.setVisible(hVisible);
- if (vBar != null) vBar.setVisible(vVisible);
- }
-
- Rectangle hostRect = getClientArea();
- if (expandHorizontal) {
- contentRect.width = Math.max(minWidth, hostRect.width);
- }
- if (expandVertical) {
- contentRect.height = Math.max(minHeight, hostRect.height);
- }
-
- if (hBar != null) {
- hBar.setMaximum (contentRect.width);
- hBar.setThumb (Math.min (contentRect.width, hostRect.width));
- int hPage = contentRect.width - hostRect.width;
- int hSelection = hBar.getSelection ();
- if (hSelection >= hPage) {
- if (hPage <= 0) {
- hSelection = 0;
- hBar.setSelection(0);
- }
- contentRect.x = -hSelection;
- }
- }
-
- if (vBar != null) {
- vBar.setMaximum (contentRect.height);
- vBar.setThumb (Math.min (contentRect.height, hostRect.height));
- int vPage = contentRect.height - hostRect.height;
- int vSelection = vBar.getSelection ();
- if (vSelection >= vPage) {
- if (vPage <= 0) {
- vSelection = 0;
- vBar.setSelection(0);
- }
- contentRect.y = -vSelection;
- }
- }
-
- content.setBounds (contentRect);
-}
-
-private boolean needHScroll(Rectangle contentRect, boolean vVisible) {
- ScrollBar hBar = getHorizontalBar();
- if (hBar == null) return false;
-
- Rectangle hostRect = getBounds();
- int border = getBorderWidth();
- hostRect.width -= 2*border;
- ScrollBar vBar = getVerticalBar();
- if (vVisible && vBar != null) hostRect.width -= vBar.getSize().x;
-
- if (!expandHorizontal && contentRect.width > hostRect.width) return true;
- if (expandHorizontal && minWidth > hostRect.width) return true;
- return false;
-}
-
-private boolean needVScroll(Rectangle contentRect, boolean hVisible) {
- ScrollBar vBar = getVerticalBar();
- if (vBar == null) return false;
-
- Rectangle hostRect = getBounds();
- int border = getBorderWidth();
- hostRect.height -= 2*border;
- ScrollBar hBar = getHorizontalBar();
- if (hVisible && hBar != null) hostRect.height -= hBar.getSize().y;
-
- if (!expandHorizontal && contentRect.height > hostRect.height) return true;
- if (expandHorizontal && minHeight > hostRect.height) return true;
- return false;
-}
-
-private void resize() {
- if (inResize) return;
- inResize = true;
- layout();
- inResize = false;
-}
-/**
- * Return the point in the content that currenly appears in the top left
- * corner of the scrolled composite.
- *
- * @return the point in the content that currenly appears in the top left
- * corner of the scrolled composite. If no content has been set, this returns
- * (0, 0).
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @since 2.0
- */
-public Point getOrigin() {
- checkWidget();
- if (content == null) return new Point(0, 0);
- Point location = content.getLocation();
- return new Point(-location.x, -location.y);
-}
-/**
- * Scrolls the content so that the specified point in the content is in the top
- * left corner. If no content has been set, nothing will occur.
- *
- * Negative values will be ignored. Values greater than the maximum scroll
- * distance will result in scrolling to the end of the scrollbar.
- *
- * @param origin the point on the content to appear in the top left corner
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * <li>ERROR_INVALID_ARGUMENT - value of origin is outside of content
- * </ul>
- * @since 2.0
- */
-public void setOrigin(Point origin) {
- setOrigin(origin.x, origin.y);
-}
-/**
- * Scrolls the content so that the specified point in the content is in the top
- * left corner. If no content has been set, nothing will occur.
- *
- * Negative values will be ignored. Values greater than the maximum scroll
- * distance will result in scrolling to the end of the scrollbar.
- *
- * @param x the x coordinate of the content to appear in the top left corner
- *
- * @param y the y coordinate of the content to appear in the top left corner
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @since 2.0
- */
-public void setOrigin(int x, int y) {
- checkWidget();
- if (content == null) return;
- ScrollBar hBar = getHorizontalBar ();
- if (hBar != null) {
- hBar.setSelection(x);
- x = -hBar.getSelection ();
- } else {
- x = 0;
- }
- ScrollBar vBar = getVerticalBar ();
- if (vBar != null) {
- vBar.setSelection(y);
- y = -vBar.getSelection ();
- } else {
- y = 0;
- }
- content.setLocation(x, y);
-}
-/**
- * Set the Always Show Scrollbars flag. True if the scrollbars are
- * always shown even if they are not required. False if the scrollbars are only
- * visible when some part of the composite needs to be scrolled to be seen.
- * The H_SCROLL and V_SCROLL style bits are also required to enable scrollbars in the
- * horizontal and vertical directions.
- *
- * @param show true to show the scrollbars even when not required, false to show scrollbars only when required
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public void setAlwaysShowScrollBars(boolean show) {
- checkWidget();
- if (show == alwaysShowScroll) return;
- alwaysShowScroll = show;
- ScrollBar hBar = getHorizontalBar ();
- if (hBar != null && alwaysShowScroll) hBar.setVisible(true);
- ScrollBar vBar = getVerticalBar ();
- if (vBar != null && alwaysShowScroll) vBar.setVisible(true);
- layout();
-}
-
-/**
- * Set the content that will be scrolled.
- *
- * @param content the control to be displayed in the content area
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public void setContent(Control content) {
- checkWidget();
- if (this.content != null && !this.content.isDisposed()) {
- this.content.removeListener(SWT.Resize, contentListener);
- this.content.setBounds(new Rectangle(-200, -200, 0, 0));
- }
-
- this.content = content;
- ScrollBar vBar = getVerticalBar ();
- ScrollBar hBar = getHorizontalBar ();
- if (this.content != null) {
- if (vBar != null) {
- vBar.setMaximum (0);
- vBar.setThumb (0);
- vBar.setSelection(0);
- }
- if (hBar != null) {
- hBar.setMaximum (0);
- hBar.setThumb (0);
- hBar.setSelection(0);
- }
- content.setLocation(0, 0);
- layout();
- this.content.addListener(SWT.Resize, contentListener);
- } else {
- if (hBar != null) hBar.setVisible(alwaysShowScroll);
- if (vBar != null) vBar.setVisible(alwaysShowScroll);
- }
-}
-/**
- * Configure the ScrolledComposite to resize the content object to be as wide as the
- * ScrolledComposite when the width of the ScrolledComposite is greater than the
- * minimum width specified in setMinWidth. If the ScrolledComposite is less than the
- * minimum width, the content will not resized and instead the horizontal scroll bar will be
- * used to view the entire width.
- * If expand is false, this behaviour is turned off. By default, this behaviour is turned off.
- *
- * @param expand true to expand the content control to fill available horizontal space
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public void setExpandHorizontal(boolean expand) {
- checkWidget();
- if (expand == expandHorizontal) return;
- expandHorizontal = expand;
- layout();
-}
-/**
- * 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.
- *
- * @param expand true to expand the content control to fill available vertical space
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public void setExpandVertical(boolean expand) {
- checkWidget();
- if (expand == expandVertical) return;
- expandVertical = expand;
- layout();
-}
-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
- checkWidget();
- return;
-}
-/**
- * Specify the minimum height at which the ScrolledComposite will begin scrolling the
- * content with the vertical scroll bar. This value is only relevant if
- * setExpandVertical(true) has been set.
- *
- * @param height the minimum height or 0 for default height
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public void setMinHeight(int height) {
- setMinSize(minWidth, height);
-}
-/**
- * Specify the minimum width and height at which the ScrolledComposite will begin scrolling the
- * content with the horizontal scroll bar. This value is only relevant if
- * setExpandHorizontal(true) and setExpandVertical(true) have been set.
- *
- * @param size the minimum size or null for the default size
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public void setMinSize(Point size) {
- if (size == null) {
- setMinSize(0, 0);
- } else {
- setMinSize(size.x, size.y);
- }
-}
-/**
- * Specify the minimum width and height at which the ScrolledComposite will begin scrolling the
- * content with the horizontal scroll bar. This value is only relevant if
- * setExpandHorizontal(true) and setExpandVertical(true) have been set.
- *
- * @param width the minimum width or 0 for default width
- * @param height the minimum height or 0 for default height
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public void setMinSize(int width, int height) {
- checkWidget();
- if (width == minWidth && height == minHeight) return;
- minWidth = Math.max(0, width);
- minHeight = Math.max(0, height);
- layout();
-}
-/**
- * Specify the minimum width at which the ScrolledComposite will begin scrolling the
- * content with the horizontal scroll bar. This value is only relevant if
- * setExpandHorizontal(true) has been set.
- *
- * @param width the minimum width or 0 for default width
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public void setMinWidth(int width) {
- setMinSize(width, minHeight);
-}
-
-private void vScroll() {
- if (content == null) return;
- Point location = content.getLocation ();
- ScrollBar vBar = getVerticalBar ();
- int vSelection = vBar.getSelection ();
- content.setLocation (location.x, -vSelection);
-}
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+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>There are two ways to use the ScrolledComposite:
+ *
+ * <p>
+ * 1) Set the size of the control that is being scrolled and the ScrolledComposite
+ * will show scrollbars when the contained control can not be fully seen.
+ *
+ * 2) The second way imitates the way a browser would work. Set the minimum size of
+ * the control and the ScrolledComposite will show scroll bars if the visible area is
+ * less than the minimum size of the control and it will expand the size of the control
+ * if the visible area is greater than the minimum size. This requires invoking
+ * both setMinWidth(), setMinHeight() and setExpandHorizontal(), setExpandVertical().
+ *
+ * <code><pre>
+ * public static void main (String [] args) {
+ * Display display = new Display ();
+ * Color red = display.getSystemColor(SWT.COLOR_RED);
+ * Color blue = display.getSystemColor(SWT.COLOR_BLUE);
+ * Shell shell = new Shell (display);
+ * shell.setLayout(new FillLayout());
+ *
+ * // set the size of the scrolled content - method 1
+ * final ScrolledComposite sc1 = new ScrolledComposite(shell, SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER);
+ * final Composite c1 = new Composite(sc1, SWT.NONE);
+ * sc1.setContent(c1);
+ * c1.setBackground(red);
+ * GridLayout layout = new GridLayout();
+ * layout.numColumns = 4;
+ * c1.setLayout(layout);
+ * Button b1 = new Button (c1, SWT.PUSH);
+ * b1.setText("first button");
+ * c1.setSize(c1.computeSize(SWT.DEFAULT, SWT.DEFAULT));
+ *
+ * // set the minimum width and height of the scrolled content - method 2
+ * final ScrolledComposite sc2 = new ScrolledComposite(shell, SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER);
+ * sc2.setExpandHorizontal(true);
+ * sc2.setExpandVertical(true);
+ * final Composite c2 = new Composite(sc2, SWT.NONE);
+ * sc2.setContent(c2);
+ * c2.setBackground(blue);
+ * layout = new GridLayout();
+ * layout.numColumns = 4;
+ * c2.setLayout(layout);
+ * Button b2 = new Button (c2, SWT.PUSH);
+ * b2.setText("first button");
+ * sc2.setMinSize(c2.computeSize(SWT.DEFAULT, SWT.DEFAULT));
+ *
+ * Button add = new Button (shell, SWT.PUSH);
+ * add.setText("add children");
+ * final int[] index = new int[]{0};
+ * add.addListener(SWT.Selection, new Listener() {
+ * public void handleEvent(Event e) {
+ * index[0]++;
+ * Button button = new Button(c1, SWT.PUSH);
+ * button.setText("button "+index[0]);
+ * // reset size of content so children can be seen - method 1
+ * c1.setSize(c1.computeSize(SWT.DEFAULT, SWT.DEFAULT));
+ * c1.layout();
+ *
+ * button = new Button(c2, SWT.PUSH);
+ * button.setText("button "+index[0]);
+ * // reset the minimum width and height so children can be seen - method 2
+ * sc2.setMinSize(c2.computeSize(SWT.DEFAULT, SWT.DEFAULT));
+ * c2.layout();
+ * }
+ * });
+ *
+ * shell.open ();
+ * while (!shell.isDisposed ()) {
+ * if (!display.readAndDispatch ()) display.sleep ();
+ * }
+ * display.dispose ();
+ * }
+ * </pre></code>
+ *
+ * <dl>
+ * <dt><b>Styles:</b><dd>H_SCROLL, V_SCROLL
+ * </dl>
+ */
+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;
+ private boolean alwaysShowScroll = false;
+ private boolean inResize = false;
+
+/**
+ * Constructs a new instance of this class given its parent
+ * and a style value describing its behavior and appearance.
+ * <p>
+ * The style value is either one of the style constants defined in
+ * class <code>SWT</code> which is applicable to instances of this
+ * class, or must be built by <em>bitwise OR</em>'ing together
+ * (that is, using the <code>int</code> "|" operator) two or more
+ * of those <code>SWT</code> style constants. The class description
+ * lists the style constants that are applicable to the class.
+ * Style bits are also inherited from superclasses.
+ * </p>
+ *
+ * @param parent a widget which will be the parent of the new instance (cannot be null)
+ * @param style the style of widget to construct
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
+ * </ul>
+ *
+ * @see SWT#H_SCROLL
+ * @see SWT#V_SCROLL
+ * @see #getStyle
+ */
+public ScrolledComposite(Composite parent, int style) {
+ super(parent, checkStyle(style));
+
+ 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;
+}
+
+public Point computeSize (int wHint, int hHint, boolean changed) {
+ checkWidget ();
+ /*
+ * When a composite does layout without using a layout
+ * manager, it must take into account the preferred size
+ * of it's children when computing it's preferred size in
+ * the same way that a layout manager would. In particular,
+ * when a scrolled composite hides the scroll bars and
+ * places a child to fill the client area, then repeated
+ * calls to compute the preferred size of the scrolled
+ * composite should not keep adding in the space used by
+ * the scroll bars.
+ */
+ if (content == null) {
+ return super.computeSize (wHint, hHint, changed);
+ }
+ Point size = content.computeSize (wHint, hHint, changed);
+ Rectangle trim = computeTrim (0, 0, size.x, size.y);
+ return new Point (trim.width, trim.height);
+}
+
+/**
+ * Returns the Always Show Scrollbars flag. True if the scrollbars are
+ * always shown even if they are not required. False if the scrollbars are only
+ * visible when some part of the composite needs to be scrolled to be seen.
+ * The H_SCROLL and V_SCROLL style bits are also required to enable scrollbars in the
+ * horizontal and vertical directions.
+ *
+ * @return the Always Show Scrollbars flag value
+ */
+public boolean getAlwaysShowScrollBars() {
+ //checkWidget();
+ return alwaysShowScroll;
+}
+
+/**
+ * Get the content that is being scrolled.
+ *
+ * @return the control displayed in the content area
+ */
+public Control getContent() {
+ //checkWidget();
+ 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);
+}
+
+public void layout(boolean changed) {
+ checkWidget();
+ if (content == null) return;
+ Rectangle contentRect = content.getBounds();
+ ScrollBar hBar = getHorizontalBar ();
+ ScrollBar vBar = getVerticalBar ();
+ if (!alwaysShowScroll) {
+ boolean hVisible = needHScroll(contentRect, false);
+ boolean vVisible = needVScroll(contentRect, hVisible);
+ if (!hVisible && vVisible) hVisible = needHScroll(contentRect, vVisible);
+ if (hBar != null) hBar.setVisible(hVisible);
+ if (vBar != null) vBar.setVisible(vVisible);
+ }
+
+ Rectangle hostRect = getClientArea();
+ if (expandHorizontal) {
+ contentRect.width = Math.max(minWidth, hostRect.width);
+ }
+ if (expandVertical) {
+ contentRect.height = Math.max(minHeight, hostRect.height);
+ }
+
+ if (hBar != null) {
+ hBar.setMaximum (contentRect.width);
+ hBar.setThumb (Math.min (contentRect.width, hostRect.width));
+ int hPage = contentRect.width - hostRect.width;
+ int hSelection = hBar.getSelection ();
+ if (hSelection >= hPage) {
+ if (hPage <= 0) {
+ hSelection = 0;
+ hBar.setSelection(0);
+ }
+ contentRect.x = -hSelection;
+ }
+ }
+
+ if (vBar != null) {
+ vBar.setMaximum (contentRect.height);
+ vBar.setThumb (Math.min (contentRect.height, hostRect.height));
+ int vPage = contentRect.height - hostRect.height;
+ int vSelection = vBar.getSelection ();
+ if (vSelection >= vPage) {
+ if (vPage <= 0) {
+ vSelection = 0;
+ vBar.setSelection(0);
+ }
+ contentRect.y = -vSelection;
+ }
+ }
+
+ content.setBounds (contentRect);
+}
+
+private boolean needHScroll(Rectangle contentRect, boolean vVisible) {
+ ScrollBar hBar = getHorizontalBar();
+ if (hBar == null) return false;
+
+ Rectangle hostRect = getBounds();
+ int border = getBorderWidth();
+ hostRect.width -= 2*border;
+ ScrollBar vBar = getVerticalBar();
+ if (vVisible && vBar != null) hostRect.width -= vBar.getSize().x;
+
+ if (!expandHorizontal && contentRect.width > hostRect.width) return true;
+ if (expandHorizontal && minWidth > hostRect.width) return true;
+ return false;
+}
+
+private boolean needVScroll(Rectangle contentRect, boolean hVisible) {
+ ScrollBar vBar = getVerticalBar();
+ if (vBar == null) return false;
+
+ Rectangle hostRect = getBounds();
+ int border = getBorderWidth();
+ hostRect.height -= 2*border;
+ ScrollBar hBar = getHorizontalBar();
+ if (hVisible && hBar != null) hostRect.height -= hBar.getSize().y;
+
+ if (!expandHorizontal && contentRect.height > hostRect.height) return true;
+ if (expandHorizontal && minHeight > hostRect.height) return true;
+ return false;
+}
+
+private void resize() {
+ if (inResize) return;
+ inResize = true;
+ layout();
+ inResize = false;
+}
+/**
+ * Return the point in the content that currenly appears in the top left
+ * corner of the scrolled composite.
+ *
+ * @return the point in the content that currenly appears in the top left
+ * corner of the scrolled composite. If no content has been set, this returns
+ * (0, 0).
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @since 2.0
+ */
+public Point getOrigin() {
+ checkWidget();
+ if (content == null) return new Point(0, 0);
+ Point location = content.getLocation();
+ return new Point(-location.x, -location.y);
+}
+/**
+ * Scrolls the content so that the specified point in the content is in the top
+ * left corner. If no content has been set, nothing will occur.
+ *
+ * Negative values will be ignored. Values greater than the maximum scroll
+ * distance will result in scrolling to the end of the scrollbar.
+ *
+ * @param origin the point on the content to appear in the top left corner
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * <li>ERROR_INVALID_ARGUMENT - value of origin is outside of content
+ * </ul>
+ * @since 2.0
+ */
+public void setOrigin(Point origin) {
+ setOrigin(origin.x, origin.y);
+}
+/**
+ * Scrolls the content so that the specified point in the content is in the top
+ * left corner. If no content has been set, nothing will occur.
+ *
+ * Negative values will be ignored. Values greater than the maximum scroll
+ * distance will result in scrolling to the end of the scrollbar.
+ *
+ * @param x the x coordinate of the content to appear in the top left corner
+ *
+ * @param y the y coordinate of the content to appear in the top left corner
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @since 2.0
+ */
+public void setOrigin(int x, int y) {
+ checkWidget();
+ if (content == null) return;
+ ScrollBar hBar = getHorizontalBar ();
+ if (hBar != null) {
+ hBar.setSelection(x);
+ x = -hBar.getSelection ();
+ } else {
+ x = 0;
+ }
+ ScrollBar vBar = getVerticalBar ();
+ if (vBar != null) {
+ vBar.setSelection(y);
+ y = -vBar.getSelection ();
+ } else {
+ y = 0;
+ }
+ content.setLocation(x, y);
+}
+/**
+ * Set the Always Show Scrollbars flag. True if the scrollbars are
+ * always shown even if they are not required. False if the scrollbars are only
+ * visible when some part of the composite needs to be scrolled to be seen.
+ * The H_SCROLL and V_SCROLL style bits are also required to enable scrollbars in the
+ * horizontal and vertical directions.
+ *
+ * @param show true to show the scrollbars even when not required, false to show scrollbars only when required
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setAlwaysShowScrollBars(boolean show) {
+ checkWidget();
+ if (show == alwaysShowScroll) return;
+ alwaysShowScroll = show;
+ ScrollBar hBar = getHorizontalBar ();
+ if (hBar != null && alwaysShowScroll) hBar.setVisible(true);
+ ScrollBar vBar = getVerticalBar ();
+ if (vBar != null && alwaysShowScroll) vBar.setVisible(true);
+ layout();
+}
+
+/**
+ * Set the content that will be scrolled.
+ *
+ * @param content the control to be displayed in the content area
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setContent(Control content) {
+ checkWidget();
+ if (this.content != null && !this.content.isDisposed()) {
+ this.content.removeListener(SWT.Resize, contentListener);
+ this.content.setBounds(new Rectangle(-200, -200, 0, 0));
+ }
+
+ this.content = content;
+ ScrollBar vBar = getVerticalBar ();
+ ScrollBar hBar = getHorizontalBar ();
+ if (this.content != null) {
+ if (vBar != null) {
+ vBar.setMaximum (0);
+ vBar.setThumb (0);
+ vBar.setSelection(0);
+ }
+ if (hBar != null) {
+ hBar.setMaximum (0);
+ hBar.setThumb (0);
+ hBar.setSelection(0);
+ }
+ content.setLocation(0, 0);
+ layout();
+ this.content.addListener(SWT.Resize, contentListener);
+ } else {
+ if (hBar != null) hBar.setVisible(alwaysShowScroll);
+ if (vBar != null) vBar.setVisible(alwaysShowScroll);
+ }
+}
+/**
+ * Configure the ScrolledComposite to resize the content object to be as wide as the
+ * ScrolledComposite when the width of the ScrolledComposite is greater than the
+ * minimum width specified in setMinWidth. If the ScrolledComposite is less than the
+ * minimum width, the content will not resized and instead the horizontal scroll bar will be
+ * used to view the entire width.
+ * If expand is false, this behaviour is turned off. By default, this behaviour is turned off.
+ *
+ * @param expand true to expand the content control to fill available horizontal space
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setExpandHorizontal(boolean expand) {
+ checkWidget();
+ if (expand == expandHorizontal) return;
+ expandHorizontal = expand;
+ layout();
+}
+/**
+ * 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.
+ *
+ * @param expand true to expand the content control to fill available vertical space
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setExpandVertical(boolean expand) {
+ checkWidget();
+ if (expand == expandVertical) return;
+ expandVertical = expand;
+ layout();
+}
+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
+ checkWidget();
+ return;
+}
+/**
+ * Specify the minimum height at which the ScrolledComposite will begin scrolling the
+ * content with the vertical scroll bar. This value is only relevant if
+ * setExpandVertical(true) has been set.
+ *
+ * @param height the minimum height or 0 for default height
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setMinHeight(int height) {
+ setMinSize(minWidth, height);
+}
+/**
+ * Specify the minimum width and height at which the ScrolledComposite will begin scrolling the
+ * content with the horizontal scroll bar. This value is only relevant if
+ * setExpandHorizontal(true) and setExpandVertical(true) have been set.
+ *
+ * @param size the minimum size or null for the default size
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setMinSize(Point size) {
+ if (size == null) {
+ setMinSize(0, 0);
+ } else {
+ setMinSize(size.x, size.y);
+ }
+}
+/**
+ * Specify the minimum width and height at which the ScrolledComposite will begin scrolling the
+ * content with the horizontal scroll bar. This value is only relevant if
+ * setExpandHorizontal(true) and setExpandVertical(true) have been set.
+ *
+ * @param width the minimum width or 0 for default width
+ * @param height the minimum height or 0 for default height
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setMinSize(int width, int height) {
+ checkWidget();
+ if (width == minWidth && height == minHeight) return;
+ minWidth = Math.max(0, width);
+ minHeight = Math.max(0, height);
+ layout();
+}
+/**
+ * Specify the minimum width at which the ScrolledComposite will begin scrolling the
+ * content with the horizontal scroll bar. This value is only relevant if
+ * setExpandHorizontal(true) has been set.
+ *
+ * @param width the minimum width or 0 for default width
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setMinWidth(int width) {
+ setMinSize(width, minHeight);
+}
+
+private void vScroll() {
+ if (content == null) return;
+ Point location = content.getLocation ();
+ ScrollBar vBar = getVerticalBar ();
+ int vSelection = vBar.getSelection ();
+ content.setLocation (location.x, -vSelection);
+}
+}
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
index 9a0be76824..4ad2155a2e 100755
--- 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
@@ -1,114 +1,114 @@
-package org.eclipse.swt.custom;
-
-/*
+package org.eclipse.swt.custom;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-import org.eclipse.swt.*;
-import org.eclipse.swt.graphics.*;
-import org.eclipse.swt.widgets.*;
-
-/**
- * This Layout stacks all the controls one on top of the other and resizes all controls
- * to have the same size and location.
- * The control specified in topControl is visible and all other controls are not visible.
- * Users must set the topControl value to flip between the visible items and the call
- * layout() on the composite which has the StackLayout.
- *
- * <p> Here is an example which places ten buttons in a stack layout and
- * flips between them:
- *
- * <pre><code>
- * public static void main(String[] args) {
- * Display display = new Display();
- * Shell shell = new Shell(display);
- * shell.setLayout(new GridLayout());
- *
- * final Composite parent = new Composite(shell, SWT.NONE);
- * parent.setLayoutData(new GridData(GridData.FILL_BOTH));
- * final StackLayout layout = new StackLayout();
- * parent.setLayout(layout);
- * final Button[] bArray = new Button[10];
- * for (int i = 0; i < 10; i++) {
- * bArray[i] = new Button(parent, SWT.PUSH);
- * bArray[i].setText("Button "+i);
- * }
- * layout.topControl = bArray[0];
- *
- * Button b = new Button(shell, SWT.PUSH);
- * b.setText("Show Next Button");
- * final int[] index = new int[1];
- * b.addListener(SWT.Selection, new Listener(){
- * public void handleEvent(Event e) {
- * index[0] = (index[0] + 1) % 10;
- * layout.topControl = bArray[index[0]];
- * parent.layout();
- * }
- * });
- *
- * shell.open();
- * while (shell != null && !shell.isDisposed()) {
- * if (!display.readAndDispatch())
- * display.sleep();
- * }
- * }
- * </code></pre>
- */
-
-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);
-
- }
-}
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+import org.eclipse.swt.*;
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.widgets.*;
+
+/**
+ * This Layout stacks all the controls one on top of the other and resizes all controls
+ * to have the same size and location.
+ * The control specified in topControl is visible and all other controls are not visible.
+ * Users must set the topControl value to flip between the visible items and the call
+ * layout() on the composite which has the StackLayout.
+ *
+ * <p> Here is an example which places ten buttons in a stack layout and
+ * flips between them:
+ *
+ * <pre><code>
+ * public static void main(String[] args) {
+ * Display display = new Display();
+ * Shell shell = new Shell(display);
+ * shell.setLayout(new GridLayout());
+ *
+ * final Composite parent = new Composite(shell, SWT.NONE);
+ * parent.setLayoutData(new GridData(GridData.FILL_BOTH));
+ * final StackLayout layout = new StackLayout();
+ * parent.setLayout(layout);
+ * final Button[] bArray = new Button[10];
+ * for (int i = 0; i < 10; i++) {
+ * bArray[i] = new Button(parent, SWT.PUSH);
+ * bArray[i].setText("Button "+i);
+ * }
+ * layout.topControl = bArray[0];
+ *
+ * Button b = new Button(shell, SWT.PUSH);
+ * b.setText("Show Next Button");
+ * final int[] index = new int[1];
+ * b.addListener(SWT.Selection, new Listener(){
+ * public void handleEvent(Event e) {
+ * index[0] = (index[0] + 1) % 10;
+ * layout.topControl = bArray[index[0]];
+ * parent.layout();
+ * }
+ * });
+ *
+ * shell.open();
+ * while (shell != null && !shell.isDisposed()) {
+ * if (!display.readAndDispatch())
+ * display.sleep();
+ * }
+ * }
+ * </code></pre>
+ */
+
+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
index 7d9643cd3b..887573c8ee 100755
--- 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
@@ -1,155 +1,155 @@
-package org.eclipse.swt.custom;
-/*
+package org.eclipse.swt.custom;
+/*
* Copyright (c) 2000, 2003 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-import org.eclipse.swt.*;
-import org.eclipse.swt.graphics.*;
-import org.eclipse.swt.internal.CloneableCompatibility;
-
-public class StyleRange implements CloneableCompatibility {
- 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() {
- int code = start + length;
-
- if (foreground != null)
- code += foreground.hashCode();
- if (background != null)
- code += background.hashCode();
- return code + 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();
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+import org.eclipse.swt.*;
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.internal.CloneableCompatibility;
+
+public class StyleRange implements CloneableCompatibility {
+ 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() {
+ int code = start + length;
+
+ if (foreground != null)
+ code += foreground.hashCode();
+ if (background != null)
+ code += background.hashCode();
+ return code + 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();
+}
}
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
index c629ce1054..31dd608a06 100755
--- 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
@@ -1,8267 +1,8267 @@
-package org.eclipse.swt.custom;
-
-/*
+package org.eclipse.swt.custom;
+
+/*
* Copyright (c) 2000, 2003 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-import java.util.*;
-
-import org.eclipse.swt.*;
-import org.eclipse.swt.dnd.*;
-import org.eclipse.swt.events.*;
-import org.eclipse.swt.graphics.*;
-import org.eclipse.swt.internal.*;
-import org.eclipse.swt.printing.*;
-import org.eclipse.swt.widgets.*;
-
-/**
- * A StyledText is an editable user interface object that displays lines
- * of text. The following style attributes can be defined for the text:
- * <ul>
- * <li>foreground color
- * <li>background color
- * <li>font style (bold, 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>replaceStyleRanges(int,int,StyleRange[])
- * <li>setStyleRange(StyleRange)
- * <li>setStyleRanges(StyleRange[])
- * </ul>
- * </p>
- * <p>
- * There are two ways to use this widget when specifying line background colors.
- * You may use the API that is defined for StyledText or you may define your own
- * LineBackgroundListener. If you define your own listener, you will be responsible
- * for maintaining the line background color information for the widget.
- * IMPORTANT: You may not define your own listener and use the StyledText API.
- * The following StyledText API is not supported if you have defined a
- * LineBackgroundListener:
- * <ul>
- * <li>getLineBackground(int)
- * <li>setLineBackground(int,int,Color)
- * </ul>
- * </p>
- * <p>
- * The content implementation for this widget may also be user-defined. To do so,
- * you must implement the StyledTextContent interface and use the StyledText API
- * setContent(StyledTextContent) to initialize the widget.
- * </p>
- * <p>
- * IMPORTANT: This class is <em>not</em> intended to be subclassed.
- * </p>
- * <dl>
- * <dt><b>Styles:</b><dd>FULL_SELECTION, MULTI, READ_ONLY, SINGLE, WRAP
- * <dt><b>Events:</b><dd>ExtendedModify, LineGetBackground, LineGetSegments, LineGetStyle, Modify, Selection, Verify, VerifyKey
- * </dl>
- */
-public class StyledText extends Canvas {
- static final char TAB = '\t';
- static final String PlatformLineDelimiter = System.getProperty("line.separator");
- static final int BIDI_CARET_WIDTH = 4;
- static final int XINSET = BIDI_CARET_WIDTH - 1;
- static final int DEFAULT_WIDTH = 64;
- static final int DEFAULT_HEIGHT = 64;
-
- static final int ExtendedModify = 3000;
- static final int LineGetBackground = 3001;
- static final int LineGetStyle = 3002;
- static final int TextChanging = 3003;
- static final int TextSet = 3004;
- static final int VerifyKey = 3005;
- static final int TextChanged = 3006;
- static final int LineGetSegments = 3007;
-
- Color selectionBackground; // selection background color
- Color selectionForeground; // selection foreground color
- StyledTextContent logicalContent; // native content (default or user specified)
- StyledTextContent content; // line wrapping content, same as logicalContent if word wrap is off
- DisplayRenderer renderer;
- TextChangeListener textChangeListener; // listener for TextChanging, TextChanged and TextSet events from StyledTextContent
- DefaultLineStyler defaultLineStyler;// used for setStyles API when no LineStyleListener is registered
- LineCache lineCache;
- 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 topOffset = 0; // offset of first character in top line
- int clientAreaHeight = 0; // the client area height. Needed to calculate content width for new
- // visible lines during Resize callback
- int clientAreaWidth = 0; // the client area width. Needed during Resize callback to determine
- // if line wrap needs to be recalculated
- int lineHeight; // line height=font height
- int tabLength = 4; // number of characters in a tab
- int lineEndSpaceWidth; // space, in pixel, used to indicated a selected line break
- int leftMargin = 1;
- int topMargin = 1;
- int rightMargin = 2;
- int bottomMargin = 2;
- Cursor ibeamCursor;
- int columnX; // keep track of the horizontal caret position
- // when changing lines/pages. Fixes bug 5935
- 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
- Point doubleClickSelection; // selection after last mouse double click
- boolean editable = true;
- boolean wordWrap = false;
- boolean doubleClickEnabled = true; // see getDoubleClickEnabled
- boolean overwrite = false; // insert/overwrite edit mode
- int textLimit = -1; // limits the number of characters the user can type in the widget. Unlimited by default.
- Hashtable keyActionMap = new Hashtable();
- Color background = null; // workaround for bug 4791
- Color foreground = null; //
- Clipboard clipboard;
- 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)
- int lastTextChangeStart; // cache data of the
- int lastTextChangeNewLineCount; // last text changing
- int lastTextChangeNewCharCount; // event for use in the
- int lastTextChangeReplaceLineCount; // text changed handler
- int lastTextChangeReplaceCharCount;
- boolean isBidi;
- boolean bidiColoring = false; // apply the BIDI algorithm on text segments of the same color
- Image leftCaretBitmap = null;
- Image rightCaretBitmap = null;
- int caretDirection = SWT.NULL;
- PaletteData caretPalette = null;
- int lastCaretDirection = SWT.NULL;
- boolean isCarbon; // flag set to true on Mac OSX
-
- /**
- * The Printing class implements printing of a range of text.
- * An instance of <class>Printing </class> is returned in the
- * StyledText#print(Printer) API. The run() method may be
- * invoked from any thread.
- */
- class Printing implements Runnable {
- final static int LEFT = 0; // left aligned header/footer segment
- final static int CENTER = 1; // centered header/footer segment
- final static int RIGHT = 2; // right aligned header/footer segment
-
- Printer printer;
- PrintRenderer renderer;
- StyledTextPrintOptions printOptions;
- StyledTextContent printerContent; // copy of the widget content
- Rectangle clientArea; // client area to print on
- Font printerFont;
- FontData displayFontData;
- Hashtable printerColors; // printer color cache for line backgrounds and style
- Hashtable lineBackgrounds = new Hashtable(); // cached line backgrounds
- Hashtable lineStyles = new Hashtable(); // cached line styles
- Hashtable bidiSegments = new Hashtable(); // cached bidi segments when running on a bidi platform
- GC gc; // printer GC
- int pageWidth; // width of a printer page in pixels
- int startPage; // first page to print
- int endPage; // last page to print
- int pageSize; // number of lines on a page
- int startLine; // first (wrapped) line to print
- int endLine; // last (wrapped) line to print
- boolean singleLine; // widget single line mode
- Point selection = null; // selected text
-
- /**
- * Creates an instance of <class>Printing</class>.
- * Copies the widget content and rendering data that needs
- * to be requested from listeners.
- * </p>
- * @param parent StyledText widget to print.
- * @param printer printer device to print on.
- * @param printOptions print options
- */
- Printing(StyledText parent, Printer printer, StyledTextPrintOptions printOptions) {
- PrinterData data = printer.getPrinterData();
-
- this.printer = printer;
- this.printOptions = printOptions;
- singleLine = parent.isSingleLine();
- startPage = 1;
- endPage = Integer.MAX_VALUE;
- if (data.scope == PrinterData.PAGE_RANGE) {
- startPage = data.startPage;
- endPage = data.endPage;
- if (endPage < startPage) {
- int temp = endPage;
- endPage = startPage;
- startPage = temp;
- }
- } if (data.scope == PrinterData.SELECTION) {
- selection = parent.getSelectionRange();
- }
-
- displayFontData = getFont().getFontData()[0];
- copyContent(parent.getContent());
- cacheLineData(printerContent);
- }
- /**
- * Caches the bidi segments of the given line.
- * </p>
- * @param lineOffset offset of the line to cache bidi segments for.
- * Relative to the start of the document.
- * @param line line to cache bidi segments for.
- */
- void cacheBidiSegments(int lineOffset, String line) {
- int[] segments = getBidiSegments(lineOffset, line);
-
- if (segments != null) {
- bidiSegments.put(new Integer(lineOffset), segments);
- }
- }
- /**
- * Caches the line background color of the given line.
- * </p>
- * @param lineOffset offset of the line to cache the background
- * color for. Relative to the start of the document.
- * @param line line to cache the background color for
- */
- void cacheLineBackground(int lineOffset, String line) {
- StyledTextEvent event = getLineBackgroundData(lineOffset, line);
-
- if (event != null) {
- lineBackgrounds.put(new Integer(lineOffset), event);
- }
- }
- /**
- * Caches all line data that needs to be requested from a listener.
- * </p>
- * @param printerContent <class>StyledTextContent</class> to request
- * line data for.
- */
- void cacheLineData(StyledTextContent printerContent) {
- for (int i = 0; i < printerContent.getLineCount(); i++) {
- int lineOffset = printerContent.getOffsetAtLine(i);
- String line = printerContent.getLine(i);
-
- if (printOptions.printLineBackground) {
- cacheLineBackground(lineOffset, line);
- }
- if (printOptions.printTextBackground ||
- printOptions.printTextForeground ||
- printOptions.printTextFontStyle) {
- cacheLineStyle(lineOffset, line);
- }
- if (isBidi()) {
- cacheBidiSegments(lineOffset, line);
- }
- }
- }
- /**
- * Caches all line styles of the given line.
- * </p>
- * @param lineOffset offset of the line to cache the styles for.
- * Relative to the start of the document.
- * @param line line to cache the styles for.
- */
- void cacheLineStyle(int lineOffset, String line) {
- StyledTextEvent event = getLineStyleData(lineOffset, line);
-
- if (event != null) {
- StyleRange[] styles = event.styles;
- for (int i = 0; i < styles.length; i++) {
- StyleRange styleCopy = null;
- if (printOptions.printTextBackground == false && styles[i].background != null) {
- styleCopy = (StyleRange) styles[i].clone();
- styleCopy.background = null;
- }
- if (printOptions.printTextForeground == false && styles[i].foreground != null) {
- if (styleCopy == null) {
- styleCopy = (StyleRange) styles[i].clone();
- }
- styleCopy.foreground = null;
- }
- if (printOptions.printTextFontStyle == false && styles[i].fontStyle != SWT.NORMAL) {
- if (styleCopy == null) {
- styleCopy = (StyleRange) styles[i].clone();
- }
- styleCopy.fontStyle = SWT.NORMAL;
- }
- if (styleCopy != null) {
- styles[i] = styleCopy;
- }
- }
- lineStyles.put(new Integer(lineOffset), event);
- }
- }
- /**
- * Copies the text of the specified <class>StyledTextContent</class>.
- * </p>
- * @param original the <class>StyledTextContent</class> to copy.
- */
- void copyContent(StyledTextContent original) {
- int insertOffset = 0;
-
- printerContent = new DefaultContent();
- for (int i = 0; i < original.getLineCount(); i++) {
- int insertEndOffset;
- if (i < original.getLineCount() - 1) {
- insertEndOffset = original.getOffsetAtLine(i + 1);
- }
- else {
- insertEndOffset = original.getCharCount();
- }
- printerContent.replaceTextRange(insertOffset, 0, original.getTextRange(insertOffset, insertEndOffset - insertOffset));
- insertOffset = insertEndOffset;
- }
- }
- /**
- * Replaces all display colors in the cached line backgrounds and
- * line styles with printer colors.
- */
- void createPrinterColors() {
- Enumeration values = lineBackgrounds.elements();
- printerColors = new Hashtable();
- while (values.hasMoreElements()) {
- StyledTextEvent event = (StyledTextEvent) values.nextElement();
- event.lineBackground = getPrinterColor(event.lineBackground);
- }
-
- values = lineStyles.elements();
- while (values.hasMoreElements()) {
- StyledTextEvent event = (StyledTextEvent) values.nextElement();
- for (int i = 0; i < event.styles.length; i++) {
- StyleRange style = event.styles[i];
- Color printerBackground = getPrinterColor(style.background);
- Color printerForeground = getPrinterColor(style.foreground);
-
- if (printerBackground != style.background ||
- printerForeground != style.foreground) {
- style = (StyleRange) style.clone();
- style.background = printerBackground;
- style.foreground = printerForeground;
- event.styles[i] = style;
- }
- }
- }
- }
- /**
- * Disposes of the resources and the <class>PrintRenderer</class>.
- */
- void dispose() {
- if (printerColors != null) {
- Enumeration colors = printerColors.elements();
-
- while (colors.hasMoreElements()) {
- Color color = (Color) colors.nextElement();
- color.dispose();
- }
- printerColors = null;
- }
- if (gc != null) {
- gc.dispose();
- gc = null;
- }
- if (printerFont != null) {
- printerFont.dispose();
- printerFont = null;
- }
- if (renderer != null) {
- renderer.dispose();
- renderer = null;
- }
- }
- /**
- * Finish printing the indicated page.
- *
- * @param page page that was printed
- */
- void endPage(int page) {
- printDecoration(page, false);
- printer.endPage();
- }
- /**
- * Creates a <class>PrintRenderer</class> and calculate the line range
- * to print.
- */
- void initializeRenderer() {
- Rectangle trim = printer.computeTrim(0, 0, 0, 0);
- Point dpi = printer.getDPI();
-
- printerFont = new Font(printer, displayFontData.getName(), displayFontData.getHeight(), SWT.NORMAL);
- clientArea = printer.getClientArea();
- pageWidth = clientArea.width;
- // one inch margin around text
- clientArea.x = dpi.x + trim.x;
- clientArea.y = dpi.y + trim.y;
- clientArea.width -= (clientArea.x + trim.width);
- clientArea.height -= (clientArea.y + trim.height);
-
- gc = new GC(printer);
- gc.setFont(printerFont);
- renderer = new PrintRenderer(
- printer, printerFont, isBidi(), gc, printerContent,
- lineBackgrounds, lineStyles, bidiSegments,
- tabLength, clientArea);
- if (printOptions.header != null) {
- int lineHeight = renderer.getLineHeight();
- clientArea.y += lineHeight * 2;
- clientArea.height -= lineHeight * 2;
- }
- if (printOptions.footer != null) {
- clientArea.height -= renderer.getLineHeight() * 2;
- }
- pageSize = clientArea.height / renderer.getLineHeight();
- StyledTextContent content = renderer.getContent();
- startLine = 0;
- endLine = content.getLineCount() - 1;
- PrinterData data = printer.getPrinterData();
- if (data.scope == PrinterData.PAGE_RANGE) {
- startLine = (startPage - 1) * pageSize;
- } else if (data.scope == PrinterData.SELECTION) {
- startLine = content.getLineAtOffset(selection.x);
- if (selection.y > 0) {
- endLine = content.getLineAtOffset(selection.x + selection.y - 1);
- } else {
- endLine = startLine - 1;
- }
- }
- }
- /**
- * Returns the printer color for the given display color.
- * </p>
- * @param color display color
- * @return color create on the printer with the same RGB values
- * as the display color.
- */
- Color getPrinterColor(Color color) {
- Color printerColor = null;
-
- if (color != null) {
- printerColor = (Color) printerColors.get(color);
- if (printerColor == null) {
- printerColor = new Color(printer, color.getRGB());
- printerColors.put(color, printerColor);
- }
- }
- return printerColor;
- }
- /**
- * Prints the lines in the specified page range.
- */
- void print() {
- StyledTextContent content = renderer.getContent();
- Color background = gc.getBackground();
- Color foreground = gc.getForeground();
- int lineHeight = renderer.getLineHeight();
- int lineCount = content.getLineCount();
- int paintY = clientArea.y;
- int page = startPage;
-
- if (singleLine) {
- lineCount = 1;
- }
- for (int i = startLine; i <= endLine && page <= endPage; i++, paintY += lineHeight) {
- String line = content.getLine(i);
-
- if (paintY == clientArea.y) {
- startPage(page);
- }
- renderer.drawLine(
- line, i, paintY, gc, background, foreground, true);
- if (paintY + lineHeight * 2 > clientArea.y + clientArea.height) {
- endPage(page);
- paintY = clientArea.y;
- page++;
- if (page > endPage || i == lineCount - 1) {
- break;
- }
- }
- }
- if (paintY > clientArea.y && paintY <= clientArea.y + clientArea.height) {
- endPage(page);
- }
- }
- /**
- * Print header or footer decorations.
- * * @param page page number to print, if specified in the StyledTextPrintOptions header or footer. * @param header true = print the header, false = print the footer */
- void printDecoration(int page, boolean header) {
- int lastSegmentIndex = 0;
- final int SegmentCount = 3;
- String text;
-
- if (header) {
- text = printOptions.header;
- }
- else {
- text = printOptions.footer;
- }
- if (text == null) {
- return;
- }
- for (int i = 0; i < SegmentCount; i++) {
- int segmentIndex = text.indexOf(StyledTextPrintOptions.SEPARATOR, lastSegmentIndex);
- String segment;
-
- if (segmentIndex == -1) {
- segment = text.substring(lastSegmentIndex);
- printDecorationSegment(segment, i, page, header);
- break;
- }
- else {
- segment = text.substring(lastSegmentIndex, segmentIndex);
- printDecorationSegment(segment, i, page, header);
- lastSegmentIndex = segmentIndex + StyledTextPrintOptions.SEPARATOR.length();
- }
- }
- }
- /**
- * Print one segment of a header or footer decoration.
- * Headers and footers have three different segments.
- * One each for left aligned, centered, and right aligned text.
- *
- * @param segment decoration segment to print
- * @param alignment alignment of the segment. 0=left, 1=center, 2=right
- * @param page page number to print, if specified in the decoration segment.
- * @param header true = print the header, false = print the footer
- */
- void printDecorationSegment(String segment, int alignment, int page, boolean header) {
- int pageIndex = segment.indexOf(StyledTextPrintOptions.PAGE_TAG);
-
- if (pageIndex != -1) {
- final int PageTagLength = StyledTextPrintOptions.PAGE_TAG.length();
- StringBuffer buffer = new StringBuffer(segment);
- buffer.replace(pageIndex, pageIndex + PageTagLength, new Integer(page).toString());
- segment = buffer.toString();
- }
- if (segment.length() > 0) {
- int segmentWidth;
- int drawX = 0;
- int drawY;
- StyledTextBidi bidi = null;
-
- if (isBidi()) {
- bidi = new StyledTextBidi(gc, tabLength, segment, null, null, new int[] {0, segment.length()});
- segmentWidth = bidi.getTextWidth();
- }
- else {
- segmentWidth = gc.textExtent(segment).x;
- }
- if (header) {
- drawY = clientArea.y - renderer.getLineHeight() * 2;
- }
- else {
- drawY = clientArea.y + clientArea.height + renderer.getLineHeight();
- }
- if (alignment == LEFT) {
- drawX = clientArea.x;
- }
- else
- if (alignment == CENTER) {
- drawX = (pageWidth - segmentWidth) / 2;
- }
- else
- if (alignment == RIGHT) {
- drawX = clientArea.x + clientArea.width - segmentWidth;
- }
- if (bidi != null) {
- bidi.drawBidiText(0, segment.length(), drawX, drawY);
- }
- else {
- gc.drawString(segment, drawX, drawY, true);
- }
- }
- }
- /**
- * Starts a print job and prints the pages specified in the constructor.
- */
- public void run() {
- String jobName = printOptions.jobName;
-
- if (jobName == null) {
- jobName = "Printing";
- }
- if (printer.startJob(jobName)) {
- createPrinterColors();
- initializeRenderer();
- print();
- dispose();
- printer.endJob();
- }
- }
- /**
- * Start printing a new page.
- *
- * @param page page number to be started
- */
- void startPage(int page) {
- printer.startPage();
- printDecoration(page, true);
- }
- }
- /**
- * 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();
- boolean WriteUnicode;
-
- /**
- * Creates a RTF writer that writes content starting at offset "start"
- * in the document. <code>start</code> and <code>length</code>can be set to specify partial
- * lines.
- * <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());
- setUnicode();
- }
- /**
- * Closes the RTF writer. Once closed no more content can be written.
- * <b>NOTE:</b> <code>toString()</code> does not return a valid RTF string until
- * <code>close()</code> has been called.
- */
- public void close() {
- if (isClosed() == 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;
- }
- /**
- * Determines if Unicode RTF should be written.
- * Don't write Unicode RTF on Windows 95/98/ME or NT.
- */
- void setUnicode() {
- final String Win95 = "windows 95";
- final String Win98 = "windows 98";
- final String WinME = "windows me";
- final String WinNT = "windows nt";
- String osName = System.getProperty("os.name").toLowerCase();
- String osVersion = System.getProperty("os.version");
- int majorVersion = 0;
-
- if (osName.startsWith(WinNT) && osVersion != null) {
- int majorIndex = osVersion.indexOf('.');
- if (majorIndex != -1) {
- osVersion = osVersion.substring(0, majorIndex);
- try {
- majorVersion = Integer.parseInt(osVersion);
- }
- catch (NumberFormatException exception) {
- // ignore exception. version number remains unknown.
- // will write without Unicode
- }
- }
- }
- if (osName != null &&
- osName.startsWith(Win95) == false &&
- osName.startsWith(Win98) == false &&
- osName.startsWith(WinME) == false &&
- (osName.startsWith(WinNT) == false || majorVersion > 4)) {
- WriteUnicode = true;
- }
- else {
- WriteUnicode = false;
- }
- }
- /**
- * 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) {
- for (int index = start; index < end; index++) {
- char ch = string.charAt(index);
- if (ch > 0xFF && WriteUnicode) {
- // write the sub string from the last escaped character
- // to the current one. Fixes bug 21698.
- if (index > start) {
- write(string.substring(start, index));
- }
- write("\\u");
- write(Integer.toString((short) ch));
- write(' '); // control word delimiter
- start = index + 1;
- }
- else
- if (ch == '}' || ch == '{' || ch == '\\') {
- // write the sub string from the last escaped character
- // to the current one. Fixes bug 21698.
- if (index > start) {
- write(string.substring(start, index));
- }
- write('\\');
- write(ch);
- start = index + 1;
- }
- }
- // write from the last escaped character to the end.
- // Fixes bug 21698.
- if (start < end) {
- write(string.substring(start, end));
- }
- }
- /**
- * Writes the RTF header including font table and color table.
- */
- void writeHeader() {
- StringBuffer header = new StringBuffer();
- FontData fontData = getFont().getFontData()[0];
- header.append("{\\rtf1\\ansi");
- // specify code page, necessary for copy to work in bidi
- // systems that don't support Unicode RTF.
- String cpg = System.getProperty("file.encoding").toLowerCase();
- if (cpg.startsWith("cp") || cpg.startsWith("ms")) {
- cpg = cpg.substring(2, cpg.length());
- header.append("\\ansicpg");
- header.append(cpg);
- }
- header.append("\\uc0\\deff0{\\fonttbl{\\f0\\fnil ");
- header.append(fontData.getName());
- header.append(";}}\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.</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 = renderer.getLineStyleData(lineOffset, line);
- if (event != null) {
- styles = event.styles;
- }
- event = renderer.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.</li>
- * </ul>
- */
- public void writeLineDelimiter(String lineDelimiter) {
- if (isClosed()) {
- SWT.error(SWT.ERROR_IO);
- }
- write(lineDelimiter, 0, lineDelimiter.length());
- write("\\par ");
- }
- /**
- * Appends the specified line text to the RTF data.
- * 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 lineEndOffset = Math.min(lineLength, endOffset - lineOffset);
- 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;
- }
- // style starts beyond line end or RTF write end
- if (start >= lineEndOffset) {
- break;
- }
- // write any unstyled text
- if (lineIndex < start) {
- // copy to start of style
- // style starting betond end of write range or end of line
- // is guarded against above.
- write(line, lineIndex, start);
- lineIndex = start;
- }
- // 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 or end of line
- copyEnd = Math.min(end, lineEndOffset);
- // guard against invalid styles and let style processing continue
- copyEnd = Math.max(copyEnd, lineIndex);
- write(line, lineIndex, copyEnd);
- if (style.fontStyle == SWT.BOLD) {
- write("\\b0");
- }
- write("}");
- lineIndex = copyEnd;
- }
- // write unstyled text at the end of the line
- if (lineIndex < lineEndOffset) {
- write(line, lineIndex, lineEndOffset);
- }
- if (lineBackground != null) {
- write("}");
- }
- }
- }
- /**
- * The <code>TextWriter</code> class is used to write widget content to
- * a string. Whole and partial lines and line breaks can be written. To write
- * partial lines, specify the start and length of the desired segment
- * during object creation.
- * <p>
- * </b>NOTE:</b> <code>toString()</code> is guaranteed to return a valid string only after close()
- * has been called.
- */
- 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.</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.</li>
- * </ul>
- */
- public void writeLineDelimiter(String lineDelimiter) {
- if (isClosed) {
- SWT.error(SWT.ERROR_IO);
- }
- write(lineDelimiter);
- }
- }
- /**
- * LineCache provides an interface to calculate and invalidate
- * line based data.
- * Implementors need to return a line width in <code>getWidth</code>.
- */
- interface LineCache {
- /**
- * Calculates the lines in the specified range.
- * <p>
- *
- * @param startLine first line to calculate
- * @param lineCount number of lines to calculate
- */
- public void calculate(int startLine, int lineCount);
- /**
- * Returns a width that will be used by the <code>StyledText</code>
- * widget to size a horizontal scroll bar.
- * <p>
- *
- * @return the line width
- */
- public int getWidth();
- /**
- * Resets the lines in the specified range.
- * This method is called in <code>StyledText.redraw()</code>
- * and allows implementors to call redraw themselves during reset.
- * <p>
- *
- * @param startLine the first line to reset
- * @param lineCount the number of lines to reset
- * @param calculateMaxWidth true=implementors should retain a
- * valid width even if it is affected by the reset operation.
- * false=the width may be set to 0
- */
- public void redrawReset(int startLine, int lineCount, boolean calculateMaxWidth);
- /**
- * Resets the lines in the specified range.
- * <p>
- *
- * @param startLine the first line to reset
- * @param lineCount the number of lines to reset
- * @param calculateMaxWidth true=implementors should retain a
- * valid width even if it is affected by the reset operation.
- * false=the width may be set to 0
- */
- public void reset(int startLine, int lineCount, boolean calculateMaxWidth);
- /**
- * Called when a text change occurred.
- * <p>
- *
- * @param startOffset the start offset of the text change
- * @param newLineCount the number of inserted lines
- * @param replaceLineCount the number of deleted lines
- * @param newCharCount the number of new characters
- * @param replaceCharCount the number of deleted characters
- */
- public void textChanged(int startOffset, int newLineCount, int replaceLineCount, int newCharCount, int replaceCharCount);
- }
- /**
- * Keeps track of line widths and the longest line in the
- * StyledText document.
- * Line widths are calculated when requested by a call to
- * <code>calculate</code> and cached until reset by a call
- * to <code>redrawReset</code> or <code>reset</code>.
- */
- class ContentWidthCache implements LineCache {
- StyledText parent; // parent widget, used to create a GC for line measuring
- int[] lineWidth; // width in pixel of each line in the document, -1 for unknown width
- int lineCount; // number of lines in lineWidth array
- int maxWidth; // maximum line width of all measured lines
- int maxWidthLineIndex; // index of the widest line
-
- /**
- * Creates a new <code>ContentWidthCache</code> and allocates space
- * for the given number of lines.
- * <p>
- *
- * @param parent the StyledText widget used to create a GC for
- * line measuring
- * @param lineCount initial number of lines to allocate space for
- */
- public ContentWidthCache(StyledText parent, int lineCount) {
- this.lineCount = lineCount;
- this.parent = parent;
- lineWidth = new int[lineCount];
- reset(0, lineCount, false);
- }
- /**
- * Calculates the width of each line in the given range if it has
- * not been calculated yet.
- * If any line in the given range is wider than the currently widest
- * line, the maximum line width is updated,
- * <p>
- *
- * @param startLine first line to calculate the line width of
- * @param lineCount number of lines to calculate the line width for
- */
- public void calculate(int startLine, int lineCount) {
- GC gc = null;
- int caretWidth = 0;
- int stopLine = startLine + lineCount;
-
- for (int i = startLine; i < stopLine; i++) {
- if (lineWidth[i] == -1) {
- String line = content.getLine(i);
- int lineOffset = content.getOffsetAtLine(i);
-
- if (gc == null) {
- gc = parent.getGC();
- caretWidth = getCaretWidth();
- }
- lineWidth[i] = contentWidth(line, lineOffset, gc) + caretWidth;
- }
- if (lineWidth[i] > maxWidth) {
- maxWidth = lineWidth[i];
- maxWidthLineIndex = i;
- }
- }
- if (gc != null) {
- gc.dispose();
- }
- }
- /**
- * Calculates the width of the visible lines in the specified
- * range.
- * <p>
- *
- * @param startLine the first changed line
- * @param newLineCount the number of inserted lines
- */
- void calculateVisible(int startLine, int newLineCount) {
- int topIndex = parent.getTopIndex();
- int bottomLine = Math.min(getPartialBottomIndex(), startLine + newLineCount);
-
- startLine = Math.max(startLine, topIndex);
- calculate(startLine, bottomLine - startLine + 1);
- }
- /**
- * Measures the width of the given line.
- * <p>
- *
- * @param line the line to measure
- * @param lineOffset start offset of the line to measure, relative
- * to the start of the document
- * @param gc the GC to use for measuring the line
- * @param currentFont the font currently set in gc. Cached for better
- * performance. Null when running in a bidi locale.
- * @return the width of the given line
- */
- int contentWidth(String line, int lineOffset, GC gc) {
- int width;
-
- if (isBidi()) {
- StyledTextBidi bidi = getStyledTextBidi(line, lineOffset, gc);
- width = bidi.getTextWidth();
- }
- else {
- StyledTextEvent event = renderer.getLineStyleData(lineOffset, line);
- StyleRange[] styles = null;
- if (event != null) {
- styles = renderer.filterLineStyles(event.styles);
- }
- width = renderer.getTextWidth(line, lineOffset, 0, line.length(), styles, 0, gc);
- }
- return width + leftMargin;
- }
- /**
- * Grows the <code>lineWidth</code> array to accomodate new line width
- * information.
- * <p>
- *
- * @param numLines the number of elements to increase the array by
- */
- void expandLines(int numLines) {
- int size = lineWidth.length;
- if (size - lineCount >= numLines) {
- return;
- }
- int[] newLines = new int[Math.max(size * 2, size + numLines)];
- System.arraycopy(lineWidth, 0, newLines, 0, size);
- lineWidth = newLines;
- reset(size, lineWidth.length - size, false);
- }
- /**
- * Returns the width of the longest measured line.
- * <p>
- *
- * @return the width of the longest measured line.
- */
- public int getWidth() {
- return maxWidth;
- }
- /**
- * Updates the line width array to reflect inserted or deleted lines.
- * <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 startLine, int delta) {
- boolean inserting = delta > 0;
-
- if (delta == 0) {
- return;
- }
- if (inserting) {
- // shift the lines down to make room for new lines
- expandLines(delta);
- for (int i = lineCount - 1; i >= startLine; i--) {
- lineWidth[i + delta] = lineWidth[i];
- }
- // reset the new lines
- for (int i = startLine + 1; i <= startLine + delta && i < lineWidth.length; i++) {
- lineWidth[i] = -1;
- }
- // have new lines been inserted above the longest line?
- if (maxWidthLineIndex >= startLine) {
- maxWidthLineIndex += delta;
- }
- }
- else {
- // shift up the lines
- for (int i = startLine - delta; i < lineCount; i++) {
- lineWidth[i+delta] = lineWidth[i];
- }
- // has the longest line been removed?
- if (maxWidthLineIndex > startLine && maxWidthLineIndex <= startLine - delta) {
- maxWidth = 0;
- maxWidthLineIndex = -1;
- }
- else
- if (maxWidthLineIndex >= startLine - delta) {
- maxWidthLineIndex += delta;
- }
- }
- lineCount += delta;
- }
- /**
- * Resets the line width of the lines in the specified range.
- * <p>
- *
- * @param startLine the first line to reset
- * @param lineCount the number of lines to reset
- * @param calculateMaxWidth true=if the widest line is being
- * reset the maximum width of all remaining cached lines is
- * calculated. false=the maximum width is set to 0 if the
- * widest line is being reset.
- */
- public void redrawReset(int startLine, int lineCount, boolean calculateMaxWidth) {
- reset(startLine, lineCount, calculateMaxWidth);
- }
- /**
- * Resets the line width of the lines in the specified range.
- * <p>
- *
- * @param startLine the first line to reset
- * @param lineCount the number of lines to reset
- * @param calculateMaxWidth true=if the widest line is being
- * reset the maximum width of all remaining cached lines is
- * calculated. false=the maximum width is set to 0 if the
- * widest line is being reset.
- */
- public void reset(int startLine, int lineCount, boolean calculateMaxWidth) {
- int endLine = startLine + lineCount;
-
- if (startLine < 0 || endLine > lineWidth.length) {
- return;
- }
- for (int i = startLine; i < endLine; i++) {
- lineWidth[i] = -1;
- }
- // if the longest line is one of the reset lines, the maximum line
- // width is no longer valid
- if (maxWidthLineIndex >= startLine && maxWidthLineIndex < endLine) {
- maxWidth = 0;
- maxWidthLineIndex = -1;
- if (calculateMaxWidth) {
- for (int i = 0; i < lineCount; i++) {
- if (lineWidth[i] > maxWidth) {
- maxWidth = lineWidth[i];
- maxWidthLineIndex = i;
- }
- }
- }
- }
- }
- /**
- * Updates the line width array to reflect a text change.
- * Lines affected by the text change will be reset.
- * <p>
- *
- * @param startOffset the start offset of the text change
- * @param newLineCount the number of inserted lines
- * @param replaceLineCount the number of deleted lines
- * @param newCharCount the number of new characters
- * @param replaceCharCount the number of deleted characters
- */
- public void textChanged(int startOffset, int newLineCount, int replaceLineCount, int newCharCount, int replaceCharCount) {
- int startLine = parent.getLineAtOffset(startOffset);
- boolean removedMaxLine = (maxWidthLineIndex > startLine && maxWidthLineIndex <= startLine + replaceLineCount);
- // entire text deleted?
- if (startLine == 0 && replaceLineCount == lineCount) {
- lineCount = newLineCount;
- lineWidth = new int[lineCount];
- reset(0, lineCount, false);
- maxWidth = 0;
- }
- else {
- linesChanged(startLine, -replaceLineCount);
- linesChanged(startLine, newLineCount);
- lineWidth[startLine] = -1;
- }
- // only calculate the visible lines. otherwise measurements of changed lines
- // outside the visible area may subsequently change again without the
- // lines ever being visible.
- calculateVisible(startLine, newLineCount);
- // maxWidthLineIndex will be -1 (i.e., unknown line width) if the widget has
- // not been visible yet and the changed lines have therefore not been
- // calculated above.
- if (removedMaxLine ||
- (maxWidthLineIndex != -1 && lineWidth[maxWidthLineIndex] < maxWidth)) {
- // longest line has been removed or changed and is now shorter.
- // need to recalculate maximum content width for all lines
- maxWidth = 0;
- for (int i = 0; i < lineCount; i++) {
- if (lineWidth[i] > maxWidth) {
- maxWidth = lineWidth[i];
- maxWidthLineIndex = i;
- }
- }
- }
- }
- }
- /**
- * Updates the line wrapping of the content.
- * The line wrapping must always be in a consistent state.
- * Therefore, when <code>reset</code> or <code>redrawReset</code>
- * is called, the line wrapping is recalculated immediately
- * instead of in <code>calculate</code>.
- */
- class WordWrapCache implements LineCache {
- StyledText parent;
- WrappedContent visualContent;
-
- /**
- * Creates a new <code>WordWrapCache</code> and calculates an initial
- * line wrapping.
- * <p>
- *
- * @param parent the StyledText widget to wrap content in.
- * @param content the content provider that does the actual line wrapping.
- */
- public WordWrapCache(StyledText parent, WrappedContent content) {
- this.parent = parent;
- visualContent = content;
- visualContent.wrapLines();
- }
- /**
- * Do nothing. Lines are wrapped immediately after reset.
- * <p>
- *
- * @param startLine first line to calculate
- * @param lineCount number of lines to calculate
- */
- public void calculate(int startLine, int lineCount) {
- }
- /**
- * Returns the client area width. Lines are wrapped so there
- * is no horizontal scroll bar.
- * <p>
- *
- * @return the line width
- */
- public int getWidth() {
- return parent.getClientArea().width;
- }
- /**
- * Wraps the lines in the specified range.
- * This method is called in <code>StyledText.redraw()</code>.
- * A redraw is therefore not necessary.
- * <p>
- *
- * @param startLine the first line to reset
- * @param lineCount the number of lines to reset
- * @param calculateMaxWidth true=implementors should retain a
- * valid width even if it is affected by the reset operation.
- * false=the width may be set to 0
- */
- public void redrawReset(int startLine, int lineCount, boolean calculateMaxWidth) {
- if (lineCount == visualContent.getLineCount()) {
- // do a full rewrap if all lines are reset
- visualContent.wrapLines();
- }
- else {
- visualContent.reset(startLine, lineCount);
- }
- }
- /**
- * Rewraps the lines in the specified range and redraws
- * the widget if the line wrapping has changed.
- * <p>
- *
- * @param startLine the first line to reset
- * @param lineCount the number of lines to reset
- * @param calculateMaxWidth true=implementors should retain a
- * valid width even if it is affected by the reset operation.
- * false=the width may be set to 0
- */
- public void reset(int startLine, int lineCount, boolean calculateMaxWidth) {
- int itemCount = getPartialBottomIndex() - topIndex + 1;
- int[] oldLineOffsets = new int[itemCount];
-
- for (int i = 0; i < itemCount; i++) {
- oldLineOffsets[i] = visualContent.getOffsetAtLine(i + topIndex);
- }
- redrawReset(startLine, lineCount, calculateMaxWidth);
- // check for cases which will require a full redraw
- if (getPartialBottomIndex() - topIndex + 1 != itemCount) {
- // number of visible lines has changed
- parent.internalRedraw();
- }
- else {
- for (int i = 0; i < itemCount; i++) {
- if (visualContent.getOffsetAtLine(i + topIndex) != oldLineOffsets[i]) {
- // wrapping of one of the visible lines has changed
- parent.internalRedraw();
- break;
- }
- }
- }
- }
- /**
- * Passes the text change notification to the line wrap content.
- * <p>
- *
- * @param startOffset the start offset of the text change
- * @param newLineCount the number of inserted lines
- * @param replaceLineCount the number of deleted lines
- * @param newCharCount the number of new characters
- * @param replaceCharCount the number of deleted characters
- */
- public void textChanged(int startOffset, int newLineCount, int replaceLineCount, int newCharCount, int replaceCharCount) {
- int startLine = visualContent.getLineAtOffset(startOffset);
-
- visualContent.textChanged(startOffset, newLineCount, replaceLineCount, newCharCount, replaceCharCount);
- if (startLine <= getPartialBottomIndex()) {
- // only redraw if the text change is inside or above the
- // visible lines. if it is below the visible lines it will
- // not affect the word wrapping. fixes bug 14047.
- parent.internalRedraw();
- }
- }
- }
-
-/**
- * Constructs a new instance of this class given its parent
- * and a style value describing its behavior and appearance.
- * <p>
- * The style value is either one of the style constants defined in
- * class <code>SWT</code> which is applicable to instances of this
- * class, or must be built by <em>bitwise OR</em>'ing together
- * (that is, using the <code>int</code> "|" operator) two or more
- * of those <code>SWT</code> style constants. The class description
- * lists the style constants that are applicable to the class.
- * Style bits are also inherited from superclasses.
- * </p>
- *
- * @param parent a widget which will be the parent of the new instance (cannot be null)
- * @param style the style of widget to construct
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
- * </ul>
- *
- * @see SWT#FULL_SELECTION
- * @see SWT#MULTI
- * @see SWT#READ_ONLY
- * @see SWT#SINGLE
- * @see SWT#WRAP
- * @see #getStyle
- */
-public StyledText(Composite parent, int style) {
- super(parent, checkStyle(style | SWT.NO_REDRAW_RESIZE | SWT.NO_BACKGROUND));
- // set the bg/fg in the OS to ensure that these are the same as StyledText, necessary
- // for ensuring that the bg/fg the IME box uses is the same as what StyledText uses
- super.setForeground(getForeground());
- super.setBackground(getBackground());
- Display display = getDisplay();
- isBidi = StyledTextBidi.isBidiPlatform();
- if ((style & SWT.READ_ONLY) != 0) {
- setEditable(false);
- }
- if ((style & SWT.BORDER) == 0 || (style & SWT.SINGLE) == 0) {
- leftMargin = topMargin = rightMargin = bottomMargin = 0;
- }
- clipboard = new Clipboard(display);
- installDefaultContent();
- initializeRenderer();
- if ((style & SWT.WRAP) != 0) {
- setWordWrap(true);
- }
- else {
- lineCache = new ContentWidthCache(this, content.getLineCount());
- }
- if (isBidi() == false) {
- Caret caret = new Caret(this, SWT.NULL);
- caret.setSize(1, caret.getSize().y);
- }
- else {
- createCaretBitmaps();
- new Caret(this, SWT.NULL);
- setBidiCaretDirection();
- Runnable runnable = new Runnable() {
- public void run() {
- // setBidiCaretLocation calculates caret location like during
- // cursor movement and takes keyboard language into account.
- // Fixes 1GKPYMK
- setBidiCaretLocation(null);
- }
- };
- StyledTextBidi.addLanguageListener(this, runnable);
- }
-
- String platform= SWT.getPlatform();
- isCarbon = "carbon".equals(platform);
-
- // set the caret width, the height of the caret will default to the line height
- calculateScrollBars();
- createKeyBindings();
- ibeamCursor = new Cursor(display, SWT.CURSOR_IBEAM);
- setCursor(ibeamCursor);
- 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. Preferred state masks are one or more of
- * SWT.MOD1, SWT.MOD2, SWT.MOD3, since these masks account for modifier platform
- * differences. However, there may be cases where using the specific state masks
- * (i.e., SWT.CTRL, SWT.SHIFT, SWT.ALT, SWT.COMMAND) makes sense.
- * @param action one of the predefined actions defined in ST.java.
- * Use SWT.NULL to remove a key binding.
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public void setKeyBinding(int key, int action) {
- checkWidget();
-
- int keyValue = key & SWT.KEY_MASK;
- int modifierValue = key & SWT.MODIFIER_MASK;
- char keyChar = (char)keyValue;
-
- if (Character.isLetter(keyChar)) {
- // make the keybinding case insensitive by adding it
- // in its upper and lower case form
- char ch = Character.toUpperCase(keyChar);
- int newKey = ch | modifierValue;
- if (action == SWT.NULL) {
- keyActionMap.remove(new Integer(newKey));
- }
- else {
- keyActionMap.put(new Integer(newKey), new Integer(action));
- }
- ch = Character.toLowerCase(keyChar);
- newKey = ch | modifierValue;
- if (action == SWT.NULL) {
- keyActionMap.remove(new Integer(newKey));
- }
- else {
- keyActionMap.put(new Integer(newKey), new Integer(action));
- }
- } else {
- if (action == SWT.NULL) {
- keyActionMap.remove(new Integer(key));
- }
- else {
- keyActionMap.put(new Integer(key), new Integer(action));
- }
- }
-
-}
-/**
- * Adds a bidirectional segment listener. A BidiSegmentEvent is sent
- * whenever a line of text is measured or rendered. The user can
- * specify text ranges in the line that should be treated as if they
- * had a different direction than the surrounding text.
- * This may be used when adjacent segments of right-to-left text should
- * not be reordered relative to each other.
- * E.g., Multiple Java string literals in a right-to-left language
- * should generally remain in logical order to each other, that is, the
- * way they are stored.
- * <p>
- *
- * @param listener the listener
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT when listener is null</li>
- * </ul>
- * @see BidiSegmentEvent
- * @since 2.0
- */
-public void addBidiSegmentListener(BidiSegmentListener listener) {
- checkWidget();
- if (listener == null) {
- SWT.error(SWT.ERROR_NULL_ARGUMENT);
- }
- StyledTextListener typedListener = new StyledTextListener(listener);
- addListener(LineGetSegments, typedListener);
-}
-/**
- * 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, logicalContent.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) {
- lineCache = getLineCache(content);
- lineCache.calculate(topIndex, getPartialBottomIndex() - topIndex + 1);
- }
-}
-/**
- * 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());
- }
-}
-/**
- * Calculates the top index based on the current vertical scroll offset.
- * The top index is the index of the topmost fully visible line or the
- * topmost partially visible line if no line is fully visible.
- * The top index starts at 0.
- */
-void calculateTopIndex() {
- int oldTopIndex = topIndex;
- int verticalIncrement = getVerticalIncrement();
- int clientAreaHeight = getClientArea().height;
-
- if (verticalIncrement == 0) {
- return;
- }
- topIndex = Compatibility.ceil(verticalScrollOffset, verticalIncrement);
- // Set top index to partially visible top line if no line is fully
- // visible but at least some of the widget client area is visible.
- // Fixes bug 15088.
- if (topIndex > 0) {
- if (clientAreaHeight > 0) {
- int bottomPixel = verticalScrollOffset + clientAreaHeight;
- int fullLineTopPixel = topIndex * verticalIncrement;
- int fullLineVisibleHeight = bottomPixel - fullLineTopPixel;
- // set top index to partially visible line if no line fully fits in
- // client area or if space is available but not used (the latter should
- // never happen because we use claimBottomFreeSpace)
- if (fullLineVisibleHeight < verticalIncrement) {
- topIndex--;
- }
- }
- else
- if (topIndex >= content.getLineCount()) {
- topIndex = content.getLineCount() - 1;
- }
- }
- if (topIndex != oldTopIndex) {
- topOffset = content.getOffsetAtLine(topIndex);
- lineCache.calculate(topIndex, getPartialBottomIndex() - topIndex + 1);
- setHorizontalScrollBar();
- }
-}
-/**
- * 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 newVerticalOffset = Math.max(0, content.getLineCount() * lineHeight - getClientArea().height);
-
- if (newVerticalOffset < verticalScrollOffset) {
- // Scroll up so that empty lines below last text line are used.
- // Fixes 1GEYJM0
- setVerticalScrollOffset(newVerticalOffset, true);
- }
-}
-/**
- * Scrolls text to the right to use new space made available by a resize.
- */
-void claimRightFreeSpace() {
- int newHorizontalOffset = Math.max(0, lineCache.getWidth() - (getClientArea().width - leftMargin - rightMargin));
-
- if (newHorizontalOffset < horizontalScrollOffset) {
- // item is no longer drawn past the right border of the client area
- // align the right end of the item with the right border of the
- // client area (window is scrolled right).
- scrollHorizontalBar(newHorizontalOffset - horizontalScrollOffset);
- }
-}
-/**
- * Clears the widget margin.
- *
- * @param gc GC to render on
- * @param background background color to use for clearing the margin
- * @param clientArea widget client area dimensions
- * @param renderHeight height in pixel of the rendered lines
- */
-void clearMargin(GC gc, Color background, Rectangle clientArea, int renderHeight) {
- if (renderHeight + topMargin <= 0) {
- return;
- }
- // clear the margin background
- gc.setBackground(background);
- gc.fillRectangle(0, 0, clientArea.width, topMargin);
- gc.fillRectangle(0, 0, leftMargin, renderHeight + topMargin);
- gc.fillRectangle(
- 0, clientArea.height - bottomMargin,
- clientArea.width, bottomMargin);
- gc.fillRectangle(
- clientArea.width - rightMargin, 0,
- rightMargin, renderHeight + topMargin);
-}
-/**
- * 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) {
- internalRedrawRange(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;
- boolean singleLine = (getStyle() & SWT.SINGLE) != 0;
-
- if (singleLine) {
- count = 1;
- } else {
- count = content.getLineCount();
- }
- if (wHint != SWT.DEFAULT) {
- width = wHint;
- }
- else {
- width = DEFAULT_WIDTH;
- }
-
- if (wordWrap) {
- if (((WrappedContent) content).getVisualLineCount() != 0) {
- // lines have already been wrapped to a specific width.
- // use existing line count. fixes bug 9191
- if (wHint == SWT.DEFAULT) {
- width = lineCache.getWidth();
- } else {
- ((WrappedContent) content).wrapLines(width);
- // caret may be on a different line after a rewrap
- setCaretLocation();
- }
- if (singleLine == false) {
- count = content.getLineCount();
- }
- }
- else {
- if (singleLine == false) {
- ((WrappedContent) content).wrapLines(width);
- // caret may be on a different line after a rewrap
- setCaretLocation();
- count = content.getLineCount();
- }
- }
- }
- else if (wHint == SWT.DEFAULT) {
- // 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().height / lineHeight);
- lineCache.calculate(0, visibleCount);
- width = lineCache.getWidth() + leftMargin + rightMargin;
- }
- if (hHint != SWT.DEFAULT) {
- height = hHint;
- }
- else {
- height = count * lineHeight + topMargin + bottomMargin;
- }
- // Use default values if no text is defined.
- if (width == 0) {
- width = DEFAULT_WIDTH;
- }
- if (height == 0) {
- if (singleLine) {
- height = lineHeight;
- }
- else {
- height = DEFAULT_HEIGHT;
- }
- }
- Rectangle rect = computeTrim(0, 0, width, height);
- return new Point (rect.width, rect.height);
-}
-/**
- * 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) {
- try {
- setClipboardContent(selection.x, length);
- }
- catch (SWTError error) {
- // Copy to clipboard failed. This happens when another application
- // is accessing the clipboard while we copy. Ignore the error.
- // Fixes 1GDQAVN
- // Rethrow all other errors. Fixes bug 17578.
- if (error.code != DND.ERROR_CANNOT_SET_CLIPBOARD) {
- throw error;
- }
- }
- }
-}
-/**
- * Returns 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.MOD1, ST.WORD_PREVIOUS);
- setKeyBinding(SWT.ARROW_RIGHT | SWT.MOD1, ST.WORD_NEXT);
- setKeyBinding(SWT.HOME | SWT.MOD1, ST.TEXT_START);
- setKeyBinding(SWT.END | SWT.MOD1, ST.TEXT_END);
- setKeyBinding(SWT.PAGE_UP | SWT.MOD1, ST.WINDOW_START);
- setKeyBinding(SWT.PAGE_DOWN | SWT.MOD1, ST.WINDOW_END);
- // Selection
- setKeyBinding(SWT.ARROW_UP | SWT.MOD2, ST.SELECT_LINE_UP);
- setKeyBinding(SWT.ARROW_DOWN | SWT.MOD2, ST.SELECT_LINE_DOWN);
- setKeyBinding(SWT.HOME | SWT.MOD2, ST.SELECT_LINE_START);
- setKeyBinding(SWT.END | SWT.MOD2, ST.SELECT_LINE_END);
- setKeyBinding(SWT.ARROW_LEFT | SWT.MOD2, ST.SELECT_COLUMN_PREVIOUS);
- setKeyBinding(SWT.ARROW_RIGHT | SWT.MOD2, ST.SELECT_COLUMN_NEXT);
- setKeyBinding(SWT.PAGE_UP | SWT.MOD2, ST.SELECT_PAGE_UP);
- setKeyBinding(SWT.PAGE_DOWN | SWT.MOD2, ST.SELECT_PAGE_DOWN);
- setKeyBinding(SWT.ARROW_LEFT | SWT.MOD1 | SWT.MOD2, ST.SELECT_WORD_PREVIOUS);
- setKeyBinding(SWT.ARROW_RIGHT | SWT.MOD1 | SWT.MOD2, ST.SELECT_WORD_NEXT);
- setKeyBinding(SWT.HOME | SWT.MOD1 | SWT.MOD2, ST.SELECT_TEXT_START);
- setKeyBinding(SWT.END | SWT.MOD1 | SWT.MOD2, ST.SELECT_TEXT_END);
- setKeyBinding(SWT.PAGE_UP | SWT.MOD1 | SWT.MOD2, ST.SELECT_WINDOW_START);
- setKeyBinding(SWT.PAGE_DOWN | SWT.MOD1 | SWT.MOD2, ST.SELECT_WINDOW_END);
-
- // Modification
- // Cut, Copy, Paste
- setKeyBinding('X' | SWT.MOD1, ST.CUT);
- setKeyBinding('C' | SWT.MOD1, ST.COPY);
- setKeyBinding('V' | SWT.MOD1, ST.PASTE);
- // Cut, Copy, Paste Wordstar style
- setKeyBinding(SWT.DEL | SWT.MOD2, ST.CUT);
- setKeyBinding(SWT.INSERT | SWT.MOD1, ST.COPY);
- setKeyBinding(SWT.INSERT | SWT.MOD2, ST.PASTE);
- setKeyBinding(SWT.BS | SWT.MOD2, ST.DELETE_PREVIOUS);
-
- setKeyBinding(SWT.BS, ST.DELETE_PREVIOUS);
- setKeyBinding(SWT.DEL, ST.DELETE_NEXT);
- setKeyBinding(SWT.BS | SWT.MOD1, ST.DELETE_WORD_PREVIOUS);
- setKeyBinding(SWT.DEL | SWT.MOD1, ST.DELETE_WORD_NEXT);
-
- // Miscellaneous
- setKeyBinding(SWT.INSERT, ST.TOGGLE_OVERWRITE);
-}
-/**
- * Create the bitmaps to use for the caret in bidi mode. This
- * method only needs to be called upon widget creation and when the
- * font changes (the caret bitmap height needs to match font height).
- */
-void createCaretBitmaps() {
- int caretWidth = BIDI_CARET_WIDTH;
-
- Display display = getDisplay();
- if (caretPalette == null) {
- caretPalette = new PaletteData(new RGB[] {new RGB (0,0,0), new RGB (255,255,255)});
- }
- if (leftCaretBitmap != null) {
- leftCaretBitmap.dispose();
- }
- ImageData imageData = new ImageData(caretWidth, lineHeight, 1, caretPalette);
- leftCaretBitmap = new Image(display, imageData);
- GC gc = new GC (leftCaretBitmap);
- gc.setForeground(display.getSystemColor(SWT.COLOR_WHITE));
- gc.drawLine(0,0,0,lineHeight);
- gc.drawLine(0,0,caretWidth-1,0);
- gc.drawLine(0,1,1,1);
- gc.dispose();
-
- if (rightCaretBitmap != null) {
- rightCaretBitmap.dispose();
- }
- rightCaretBitmap = new Image(display, imageData);
- gc = new GC (rightCaretBitmap);
- gc.setForeground(display.getSystemColor(SWT.COLOR_WHITE));
- gc.drawLine(caretWidth-1,0,caretWidth-1,lineHeight);
- gc.drawLine(0,0,caretWidth-1,0);
- gc.drawLine(caretWidth-1,1,1,1);
- gc.dispose();
-}
-/**
- * Moves the selected text to the clipboard. The text will be put in the
- * clipboard in plain text format and RTF format.
- * <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();
- int length = selection.y - selection.x;
-
- if (length > 0) {
- try {
- setClipboardContent(selection.x, length);
- }
- catch (SWTError error) {
- // Copy to clipboard failed. This happens when another application
- // is accessing the clipboard while we copy. Ignore the error.
- // Fixes 1GDQAVN
- // Rethrow all other errors. Fixes bug 17578.
- if (error.code != DND.ERROR_CANNOT_SET_CLIPBOARD) {
- throw error;
- }
- // Abort cut operation if copy to clipboard fails.
- // Fixes bug 21030.
- return;
- }
- doDelete();
- }
-}
-/**
- * A mouse move event has occurred. See if we should start autoscrolling. If
- * the move position is outside of the client area, initiate autoscrolling.
- * Otherwise, we've moved back into the widget so end autoscrolling.
- */
-void doAutoScroll(Event event) {
- Rectangle area = getClientArea();
-
- if (event.y > area.height) {
- doAutoScroll(SWT.DOWN);
- }
- else
- if (event.y < 0) {
- doAutoScroll(SWT.UP);
- }
- else
- if (event.x < leftMargin && wordWrap == false) {
- doAutoScroll(SWT.LEFT);
- }
- else
- if (event.x > area.width - leftMargin - rightMargin && wordWrap == false) {
- 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) {
- doSelectionLineUp();
- display.timerExec(TIMER_INTERVAL, this);
- }
- }
- };
- } else if (direction == SWT.DOWN) {
- timer = new Runnable() {
- public void run() {
- if (autoScrollDirection == SWT.DOWN) {
- doSelectionLineDown();
- display.timerExec(TIMER_INTERVAL, this);
- }
- }
- };
- } else if (direction == SWT.RIGHT) {
- timer = new Runnable() {
- public void run() {
- if (autoScrollDirection == SWT.RIGHT) {
- doColumnRight();
- setMouseWordSelectionAnchor();
- doSelection(SWT.RIGHT);
- display.timerExec(TIMER_INTERVAL, this);
- }
- }
- };
- } else if (direction == SWT.LEFT) {
- timer = new Runnable() {
- public void run() {
- if (autoScrollDirection == SWT.LEFT) {
- doColumnLeft();
- setMouseWordSelectionAnchor();
- doSelection(SWT.LEFT);
- display.timerExec(TIMER_INTERVAL, this);
- }
- }
- };
- }
- if (timer != null) {
- autoScrollDirection = direction;
- display.timerExec(TIMER_INTERVAL, timer);
- }
-}
-/**
- * Deletes the previous character. Delete the selected text if any.
- * Move the caret in front of the deleted text.
- */
-void doBackspace() {
- Event event = new Event();
- event.text = "";
- if (selection.x != selection.y) {
- event.start = selection.x;
- event.end = selection.y;
- sendKeyEvent(event);
- }
- else
- if (caretOffset > 0) {
- int 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);
- }
-}
-/**
- * Moves the caret one character to the left. Do not go to the previous line.
- * When in a bidi locale and at a R2L character the caret is moved to the
- * beginning of the R2L segment (visually right) and then one character to the
- * left (visually left because it's now in a L2R segment).
- */
-void doColumnLeft() {
- int line = content.getLineAtOffset(caretOffset);
- int lineOffset = content.getOffsetAtLine(line);
- int offsetInLine = caretOffset - lineOffset;
-
- if (isBidi()) {
- String lineText = content.getLine(line);
- int lineLength = lineText.length();
- GC gc = getGC();
- StyledTextBidi bidi = getStyledTextBidi(lineText, lineOffset, gc);
-
- if (horizontalScrollOffset > 0 || offsetInLine > 0) {
- if (offsetInLine < lineLength && bidi.isRightToLeft(offsetInLine)) {
- // advance caret logically if in R2L segment (move visually left)
- caretOffset++;
- doSelection(SWT.RIGHT);
- if (caretOffset - lineOffset == lineLength) {
- // if the line end is reached in a R2L segment, make the
- // caret position (visual left border) visible before
- // jumping to segment start
- showCaret();
- }
- // end of R2L segment reached (visual left side)?
- if (bidi.isRightToLeft(caretOffset - lineOffset) == false) {
- if (bidi.getTextPosition(caretOffset - lineOffset) < horizontalScrollOffset) {
- // make beginning of R2L segment visible before going
- // left, to L2R segment important if R2L segment ends
- // at visual left in order to scroll all the way to the
- // left. Fixes 1GKM3XS
- showCaret();
- }
- // go to beginning of R2L segment (visually end of next L2R
- // segment)/beginning of line
- caretOffset--;
- while (caretOffset - lineOffset > 0 &&
- bidi.isRightToLeft(caretOffset - lineOffset)) {
- caretOffset--;
- }
- }
- }
- else
- if (offsetInLine == lineLength &&
- bidi.getTextPosition(lineLength) != XINSET) {
- // at logical line end in R2L segment but there's more text (a
- // L2R segment) go to end of R2L segment (visually left of next
- // L2R segment)/end of line
- caretOffset--;
- while (caretOffset - lineOffset > 0 &&
- bidi.isRightToLeft(caretOffset - lineOffset)) {
- caretOffset--;
- }
- }
- else
- if (offsetInLine > 0 && bidi.isRightToLeft(offsetInLine) == false) {
- // decrease caret logically if in L2R segment (move visually left)
- caretOffset--;
- doSelection(SWT.LEFT);
- // end of L2R segment reached (visual left side of preceeding R2L
- // segment)?
- if (caretOffset - lineOffset > 0 &&
- bidi.isRightToLeft(caretOffset - lineOffset - 1)) {
- // go to beginning of R2L segment (visually start of next L2R
- // segment)/beginning of line
- caretOffset--;
- while (caretOffset - lineOffset > 0 &&
- bidi.isRightToLeft(caretOffset - lineOffset - 1)) {
- caretOffset--;
- }
- }
- }
- // if new caret position is to the left of the client area
- if (bidi.getTextPosition(caretOffset - lineOffset) < horizontalScrollOffset) {
- // scroll to the caret position
- showCaret();
- }
- else {
- // otherwise just update caret position without scrolling it into view
- setBidiCaretLocation(null);
- setBidiKeyboardLanguage();
- }
- // Beginning of line reached (auto scroll finished) but not scrolled
- // completely to the left? Fixes 1GKM193
- if (caretOffset - lineOffset == 0 && horizontalScrollOffset > 0 &&
- horizontalScrollOffset <= XINSET) {
- scrollHorizontalBar(-horizontalScrollOffset);
- }
- }
- gc.dispose();
- }
- else
- if (offsetInLine > 0) {
- caretOffset--;
- showCaret();
- }
-}
-/**
- * Moves the caret one character to the right. Do not go to the next line.
- * When in a bidi locale and at a R2L character the caret is moved to the
- * end of the R2L segment (visually left) and then one character to the
- * right (visually right because it's now in a L2R segment).
- */
-void doColumnRight() {
- int line = content.getLineAtOffset(caretOffset);
- int lineOffset = content.getOffsetAtLine(line);
- int offsetInLine = caretOffset - lineOffset;
- String lineText = content.getLine(line);
- int lineLength = lineText.length();
-
- if (isBidi()) {
- GC gc = getGC();
- StyledTextBidi bidi = getStyledTextBidi(lineText, lineOffset, gc);
- if (bidi.getTextWidth() + leftMargin > horizontalScrollOffset + getClientArea().width ||
- offsetInLine < lineLength) {
- if (bidi.isRightToLeft(offsetInLine) == false &&
- offsetInLine < lineLength) {
- // advance caret logically if in L2R segment (move visually right)
- caretOffset++;
- doSelection(SWT.RIGHT);
- // end of L2R segment reached (visual right side)?
- if (bidi.isRightToLeft(caretOffset - lineOffset)) {
- // go to end of R2L segment (visually left of next R2L segment)/
- // end of line
- caretOffset++;
- while (caretOffset < lineOffset + lineLength &&
- bidi.isRightToLeft(caretOffset - lineOffset)) {
- caretOffset++;
- }
- }
- }
- else
- if (offsetInLine > 0 &&
- (bidi.isRightToLeft(offsetInLine) ||
- bidi.getTextWidth() + leftMargin > horizontalScrollOffset + getClientArea().width ||
- offsetInLine < lineLength)) {
- // advance caret visually if in R2L segment or logically at line end
- // but right end of line is not fully visible yet
- caretOffset--;
- doSelection(SWT.LEFT);
- offsetInLine = caretOffset - lineOffset;
- // end of R2L segment reached (visual right side)?
- if (offsetInLine > 0 && bidi.isRightToLeft(offsetInLine) == false) {
- // go to end of R2L segment (visually left of next L2R segment)/
- // end of line
- caretOffset++;
- while (caretOffset < lineOffset + lineLength &&
- bidi.isRightToLeft(caretOffset - lineOffset)) {
- caretOffset++;
- }
- }
- }
- else
- if (offsetInLine == 0 && bidi.getTextPosition(0) != bidi.getTextWidth()) {
- // at logical line start in R2L segment but there's more text (a L2R
- // segment) go to end of R2L segment (visually left of next L2R
- // segment)/end of line
- caretOffset++;
- while (caretOffset < lineOffset + lineLength &&
- bidi.isRightToLeft(caretOffset - lineOffset - 1)) {
- caretOffset++;
- }
- }
- offsetInLine = caretOffset - lineOffset;
- // if new caret position is to the right of the client area
- if (bidi.getTextPosition(offsetInLine) >= horizontalScrollOffset) {
- // scroll to the caret position
- showCaret();
- }
- else {
- // otherwise just update caret position without scrolling it into view
- setBidiCaretLocation(null);
- setBidiKeyboardLanguage();
- }
- if (offsetInLine > 0 && offsetInLine < lineLength - 1) {
- int clientAreaEnd = horizontalScrollOffset + getClientArea().width;
- boolean directionChange = bidi.isRightToLeft(offsetInLine - 1) == false && bidi.isRightToLeft(offsetInLine);
- int textWidth = bidi.getTextWidth() + leftMargin;
- // between L2R and R2L segment and second character of R2L segment is
- // left of right border and logical line end is left of right border
- // but visual line end is not left of right border
- if (directionChange &&
- bidi.isRightToLeft(offsetInLine + 1) &&
- bidi.getTextPosition(offsetInLine + 1) + leftMargin < clientAreaEnd &&
- bidi.getTextPosition(lineLength) + leftMargin < clientAreaEnd && textWidth > clientAreaEnd) {
- // make visual line end visible
- scrollHorizontalBar(textWidth - clientAreaEnd);
- }
- }
- }
- gc.dispose();
- }
- else
- if (offsetInLine < lineLength) {
- 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() {
- // place caret at end of first line if receiver is in single
- // line mode. fixes 4820.
- if (isSingleLine()) {
- doLineEnd();
- }
- else {
- int length = content.getCharCount();
- if (caretOffset < length) {
- caretOffset = length;
- showCaret();
- }
- }
-}
-/**
- * Moves the caret in front of the first character of the widget content.
- */
-void doContentStart() {
- if (caretOffset > 0) {
- caretOffset = 0;
- showCaret();
- }
-}
-/**
- * Moves the caret to the start of the selection if a selection exists.
- * Otherwise, if no selection exists move the cursor according to the
- * cursor selection rules.
- * <p>
- *
- * @see #doSelectionCursorPrevious
- */
-void doCursorPrevious() {
- if (selection.y - selection.x > 0) {
- int caretLine;
-
- caretOffset = selection.x;
- caretLine = getCaretLine();
- showCaret(caretLine);
- }
- else {
- doSelectionCursorPrevious();
- }
-}
-/**
- * Moves the caret to the end of the selection if a selection exists.
- * Otherwise, if no selection exists move the cursor according to the
- * cursor selection rules.
- * <p>
- *
- * @see #doSelectionCursorNext
- */
-void doCursorNext() {
- if (selection.y - selection.x > 0) {
- int caretLine;
-
- caretOffset = selection.y;
- caretLine = getCaretLine();
- showCaret(caretLine);
- }
- else {
- doSelectionCursorNext();
- }
-}
-/**
- * Deletes the next character. Delete the selected text if any.
- */
-void doDelete() {
- Event event = new Event();
-
- event.text = "";
- if (selection.x != selection.y) {
- event.start = selection.x;
- event.end = selection.y;
- sendKeyEvent(event);
- }
- else
- if (caretOffset < content.getCharCount()) {
- int line = content.getLineAtOffset(caretOffset);
- int lineOffset = content.getOffsetAtLine(line);
- int lineLength = content.getLine(line).length();
-
- if (caretOffset == lineOffset + lineLength) {
- event.start = caretOffset;
- event.end = content.getOffsetAtLine(line + 1);
- }
- else {
- event.start = caretOffset;
- event.end = caretOffset + 1;
- }
- sendKeyEvent(event);
- }
-}
-/**
- * Deletes the next word.
- */
-void doDeleteWordNext() {
- if (selection.x != selection.y) {
- // if a selection exists, treat the as if
- // only the delete key was pressed
- doDelete();
- } else {
- Event event = new Event();
- event.text = "";
- event.start = caretOffset;
- event.end = getWordEnd(caretOffset);
- sendKeyEvent(event);
- }
-}
-/**
- * Deletes the previous word.
- */
-void doDeleteWordPrevious() {
- if (selection.x != selection.y) {
- // if a selection exists, treat as if
- // only the backspace key was pressed
- doBackspace();
- } else {
- Event event = new Event();
- event.text = "";
- event.start = getWordStart(caretOffset);
- event.end = caretOffset;
- sendKeyEvent(event);
- }
-}
-/**
- * Moves the caret one line down and to the same character offset relative
- * to the beginning of the line. Move the caret to the end of the new line
- * if the new line is shorter than the character offset.
- *
- * @return index of the new line relative to the first line in the document
- */
-int doLineDown() {
- if (isSingleLine()) {
- return 0;
- }
- // allow line down action only if receiver is not in single line mode.
- // fixes 4820.
- int caretLine = getCaretLine();
- if (caretLine < content.getLineCount() - 1) {
- caretLine++;
- if (isBidi()) {
- caretOffset = getBidiOffsetAtMouseLocation(columnX, caretLine);
- }
- else {
- caretOffset = getOffsetAtMouseLocation(columnX, caretLine);
- }
- }
- return caretLine;
-}
-/**
- * Moves the caret to the end of the line.
- */
-void doLineEnd() {
- int caretLine = getCaretLine();
- int lineOffset = content.getOffsetAtLine(caretLine);
- int lineLength = content.getLine(caretLine).length();
- int lineEndOffset = lineOffset + lineLength;
-
- if (caretOffset < lineEndOffset) {
- caretOffset = lineEndOffset;
- showCaret();
- }
-}
-/**
- * Moves the caret to the beginning of the line.
- */
-void doLineStart() {
- int caretLine = getCaretLine();
- int lineOffset = content.getOffsetAtLine(caretLine);
-
- if (caretOffset > lineOffset) {
- caretOffset = lineOffset;
- showCaret(caretLine);
- }
-}
-/**
- * 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.
- *
- * @return index of the new line relative to the first line in the document
- */
-int doLineUp() {
- int caretLine = getCaretLine();
-
- if (caretLine > 0) {
- caretLine--;
- if (isBidi()) {
- caretOffset = getBidiOffsetAtMouseLocation(columnX, caretLine);
- }
- else {
- caretOffset = getOffsetAtMouseLocation(columnX, caretLine);
- }
- }
- return caretLine;
-}
-/**
- * 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) / lineHeight;
- int lineCount = content.getLineCount();
- int newCaretOffset;
- int newCaretLine;
-
- if (line > lineCount - 1) {
- line = lineCount - 1;
- }
- // allow caret to be placed below first line only if receiver is
- // not in single line mode. fixes 4820.
- if (line < 0 || (isSingleLine() && line > 0)) {
- return;
- }
- if (isBidi()) {
- newCaretOffset = getBidiOffsetAtMouseLocation(x, line);
- }
- else {
- newCaretOffset = getOffsetAtMouseLocation(x, line);
- }
- if (mouseDoubleClick) {
- // double click word select the previous/next word. fixes bug 15610
- newCaretOffset = doMouseWordSelect(x, newCaretOffset, line);
- }
- newCaretLine = content.getLineAtOffset(newCaretOffset);
- // Is the mouse within the left client area border or on
- // a different line? If not the autoscroll selection
- // could be incorrectly reset. Fixes 1GKM3XS
- if (y >= 0 && y < getClientArea().height &&
- (x >= 0 || newCaretLine != content.getLineAtOffset(caretOffset))) {
- 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);
- }
-}
-/**
- * Returns the offset of the word at the specified offset.
- * If the current selection extends from high index to low index
- * (i.e., right to left, or caret is at left border of selecton on
- * non-bidi platforms) the start offset of the word preceeding the
- * selection is returned. If the current selection extends from
- * low index to high index the end offset of the word following
- * the selection is returned.
- *
- * @param x mouse x location
- * @param newCaretOffset caret offset of the mouse cursor location
- * @param line line index of the mouse cursor location
- */
-int doMouseWordSelect(int x, int newCaretOffset, int line) {
- int wordOffset;
-
- // flip selection anchor based on word selection direction from
- // base double click. Always do this here (and don't rely on doAutoScroll)
- // because auto scroll only does not cover all possible mouse selections
- // (e.g., mouse x < 0 && mouse y > caret line y)
- if (newCaretOffset < selectionAnchor && selectionAnchor == selection.x) {
- selectionAnchor = doubleClickSelection.y;
- }
- else
- if (newCaretOffset > selectionAnchor && selectionAnchor == selection.y) {
- selectionAnchor = doubleClickSelection.x;
- }
- if (x >= 0 && x < getClientArea().width) {
- // find the previous/next word
- if (caretOffset == selection.x) {
- wordOffset = getWordStart(newCaretOffset);
- }
- else {
- wordOffset = getWordEndNoSpaces(newCaretOffset);
- }
- // mouse word select only on same line mouse cursor is on
- if (content.getLineAtOffset(wordOffset) == line) {
- newCaretOffset = wordOffset;
- }
- }
- return newCaretOffset;
-}
-/**
- * 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 lineCount = content.getLineCount();
- int oldColumnX = columnX;
- int caretLine;
-
- // do nothing if in single line mode. fixes 5673
- if (isSingleLine()) {
- return;
- }
- caretLine = getCaretLine();
- if (caretLine < lineCount - 1) {
- int verticalMaximum = lineCount * getVerticalIncrement();
- int pageSize = getClientArea().height;
- int scrollLines = Math.min(lineCount - caretLine - 1, getLineCountWhole());
- int scrollOffset;
-
- // ensure that scrollLines never gets negative and at leat one
- // line is scrolled. fixes bug 5602.
- scrollLines = Math.max(1, scrollLines);
- caretLine += scrollLines;
- if (isBidi()) {
- caretOffset = getBidiOffsetAtMouseLocation(columnX, caretLine);
- }
- else {
- caretOffset = getOffsetAtMouseLocation(columnX, caretLine);
- }
- 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);
- }
- }
- // explicitly go to the calculated caret line. may be different
- // from content.getLineAtOffset(caretOffset) when in word wrap mode
- showCaret(caretLine);
- // save the original horizontal caret position
- columnX = oldColumnX;
-}
-/**
- * Moves the cursor to the end of the last fully visible line.
- */
-void doPageEnd() {
- // go to end of line if in single line mode. fixes 5673
- if (isSingleLine()) {
- doLineEnd();
- }
- else {
- int line = getBottomIndex();
- int bottomCaretOffset = content.getOffsetAtLine(line) + content.getLine(line).length();
-
- if (caretOffset < bottomCaretOffset) {
- caretOffset = bottomCaretOffset;
- showCaret();
- }
- }
-}
-/**
- * Moves the cursor to the beginning of the first fully visible line.
- */
-void doPageStart() {
- int topCaretOffset = content.getOffsetAtLine(topIndex);
-
- if (caretOffset > topCaretOffset) {
- caretOffset = topCaretOffset;
- // explicitly go to the calculated caret line. may be different
- // from content.getLineAtOffset(caretOffset) when in word wrap mode
- showCaret(topIndex);
- }
-}
-/**
- * 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 oldColumnX = columnX;
- int caretLine = getCaretLine();
-
- if (caretLine > 0) {
- int scrollLines = Math.max(1, Math.min(caretLine, getLineCountWhole()));
- int scrollOffset;
-
- caretLine -= scrollLines;
- if (isBidi()) {
- caretOffset = getBidiOffsetAtMouseLocation(columnX, caretLine);
- }
- else {
- caretOffset = getOffsetAtMouseLocation(columnX, caretLine);
- }
- // scroll one page up or to the top
- scrollOffset = Math.max(0, verticalScrollOffset - scrollLines * getVerticalIncrement());
- if (scrollOffset < verticalScrollOffset) {
- setVerticalScrollOffset(scrollOffset, true);
- }
- }
- // explicitly go to the calculated caret line. may be different
- // from content.getLineAtOffset(caretOffset) when in word wrap mode
- showCaret(caretLine);
- // save the original horizontal caret position
- columnX = oldColumnX;
-}
-/**
- * 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) {
- internalRedrawRange(redrawStart, redrawEnd - redrawStart, true);
- sendSelectionEvent();
- }
-}
-/**
- * Moves the caret to the next character or to the beginning of the
- * next line if the cursor is at the end of a line.
- */
-void doSelectionCursorNext() {
- int caretLine = getCaretLine();
- int lineOffset = content.getOffsetAtLine(caretLine);
- int offsetInLine = caretOffset - lineOffset;
-
- if (offsetInLine < content.getLine(caretLine).length()) {
- // Remember the last direction. Always update lastCaretDirection,
- // even though it's not used in non-bidi mode in order to avoid
- // extra methods.
- lastCaretDirection = ST.COLUMN_NEXT;
- caretOffset++;
- showCaret();
- }
- else
- if (caretLine < content.getLineCount() - 1 && isSingleLine() == false) {
- // only go to next line if not in single line mode. fixes 5673
- caretLine++;
- caretOffset = content.getOffsetAtLine(caretLine);
- // explicitly go to the calculated caret line. may be different
- // from content.getLineAtOffset(caretOffset) when in word wrap mode
- showCaret(caretLine);
- }
-}
-/**
- * Moves the caret to the previous character or to the end of the previous
- * line if the cursor is at the beginning of a line.
- */
-void doSelectionCursorPrevious() {
- int caretLine = getCaretLine();
- int lineOffset = content.getOffsetAtLine(caretLine);
- int offsetInLine = caretOffset - lineOffset;
-
- if (offsetInLine > 0) {
- // Remember the last direction. Always update lastCaretDirection,
- // even though it's not used in non-bidi mode in order to avoid
- // extra methods.
- lastCaretDirection = ST.COLUMN_PREVIOUS;
- caretOffset--;
- // explicitly go to the calculated caret line. may be different
- // from content.getLineAtOffset(caretOffset) when in word wrap mode
- showCaret(caretLine);
- }
- else
- if (caretLine > 0) {
- caretLine--;
- lineOffset = content.getOffsetAtLine(caretLine);
- caretOffset = lineOffset + content.getLine(caretLine).length();
- showCaret();
- }
-}
-/**
- * Moves the caret one line down and to the same character offset relative
- * to the beginning of the line. Moves the caret to the end of the new line
- * if the new line is shorter than the character offset.
- * Moves the caret to the end of the text if the caret already is on the
- * last line.
- * Adjusts the selection according to the caret change. This can either add
- * to or subtract from the old selection, depending on the previous selection
- * direction.
- */
-void doSelectionLineDown() {
- int oldColumnX;
- int caretLine;
- int lineStartOffset;
-
- if (isSingleLine()) {
- return;
- }
- caretLine = getCaretLine();
- lineStartOffset = content.getOffsetAtLine(caretLine);
- // reset columnX on selection
- oldColumnX = columnX = getXAtOffset(
- content.getLine(caretLine), caretLine, caretOffset - lineStartOffset);
- if (caretLine == content.getLineCount() - 1) {
- caretOffset = content.getCharCount();
- }
- else {
- caretLine = doLineDown();
- }
- setMouseWordSelectionAnchor();
- // select first and then scroll to reduce flash when key
- // repeat scrolls lots of lines
- doSelection(SWT.RIGHT);
- // explicitly go to the calculated caret line. may be different
- // from content.getLineAtOffset(caretOffset) when in word wrap mode
- showCaret(caretLine);
- // save the original horizontal caret position
- columnX = oldColumnX;
-}
-/**
- * Moves the caret one line up and to the same character offset relative
- * to the beginning of the line. Moves the caret to the end of the new line
- * if the new line is shorter than the character offset.
- * Moves the caret to the beginning of the document if it is already on the
- * first line.
- * Adjusts the selection according to the caret change. This can either add
- * to or subtract from the old selection, depending on the previous selection
- * direction.
- */
-void doSelectionLineUp() {
- int oldColumnX;
- int caretLine = getCaretLine();
- int lineStartOffset = content.getOffsetAtLine(caretLine);
-
- // reset columnX on selection
- oldColumnX = columnX = getXAtOffset(
- content.getLine(caretLine), caretLine, caretOffset - lineStartOffset);
- if (caretLine == 0) {
- caretOffset = 0;
- }
- else {
- caretLine = doLineUp();
- }
- setMouseWordSelectionAnchor();
- // explicitly go to the calculated caret line. may be different
- // from content.getLineAtOffset(caretOffset) when in word wrap mode
- showCaret(caretLine);
- doSelection(SWT.LEFT);
- // save the original horizontal caret position
- columnX = oldColumnX;
-}
-/**
- * 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>
- * Adjusts the selection according to the caret change. This can either add
- * to or subtract from the old selection, depending on the previous selection
- * direction.
- * </p>
- */
-void doSelectionPageDown() {
- int oldColumnX;
- int caretLine = getCaretLine();
- int lineStartOffset = content.getOffsetAtLine(caretLine);
-
- // reset columnX on selection
- oldColumnX = columnX = getXAtOffset(
- content.getLine(caretLine), caretLine, caretOffset - lineStartOffset);
- doPageDown(true);
- columnX = oldColumnX;
-}
-/**
- * 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.
- * <p>
- * Adjusts the selection according to the caret change. This can either add
- * to or subtract from the old selection, depending on the previous selection
- * direction.
- * </p>
- */
-void doSelectionPageUp() {
- int oldColumnX;
- int caretLine = getCaretLine();
- int lineStartOffset = content.getOffsetAtLine(caretLine);
-
- // reset columnX on selection
- oldColumnX = columnX = getXAtOffset(
- content.getLine(caretLine), caretLine, caretOffset - lineStartOffset);
- doPageUp();
- columnX = oldColumnX;
-}
-/**
- * Moves the caret to the end of the next word .
- */
-void doSelectionWordNext() {
- int newCaretOffset = getWordEnd(caretOffset);
-
- // don't change caret position if in single line mode and the cursor
- // would be on a different line. fixes 5673
- if (isSingleLine() == false ||
- content.getLineAtOffset(caretOffset) == content.getLineAtOffset(newCaretOffset)) {
- lastCaretDirection = ST.COLUMN_NEXT;
- caretOffset = newCaretOffset;
- showCaret();
- }
-}
-/**
- * Moves the caret to the start of the previous word.
- */
-void doSelectionWordPrevious() {
- int caretLine;
-
- lastCaretDirection = ST.COLUMN_PREVIOUS;
- caretOffset = getWordStart(caretOffset);
- caretLine = content.getLineAtOffset(caretOffset);
- // word previous always comes from bottom line. when
- // wrapping lines, stay on bottom line when on line boundary
- if (wordWrap && caretLine < content.getLineCount() - 1 &&
- caretOffset == content.getOffsetAtLine(caretLine + 1)) {
- caretLine++;
- }
- showCaret(caretLine);
-}
-/**
- * Moves the caret to the end of the next word.
- * If a selection exists, move the caret to the end of the selection
- * and remove the selection.
- */
-void doWordNext() {
- if (selection.y - selection.x > 0) {
- int caretLine;
-
- caretOffset = selection.y;
- caretLine = getCaretLine();
- showCaret(caretLine);
- }
- else {
- doSelectionWordNext();
- }
-}
-/**
- * Moves the caret to the start of the previous word.
- * If a selection exists, move the caret to the start of the selection
- * and remove the selection.
- */
-void doWordPrevious() {
- if (selection.y - selection.x > 0) {
- int caretLine;
-
- caretOffset = selection.x;
- caretLine = getCaretLine();
- showCaret(caretLine);
- }
- else {
- doSelectionWordPrevious();
- }
-}
-/**
- * Draws the specified rectangle.
- * Draw directly without invalidating the affected area when clearBackground is
- * false.
- * <p>
- *
- * @param x the x position
- * @param y the y position
- * @param width the width
- * @param height the height
- * @param clearBackground true=clear the background by invalidating the requested
- * redraw area, false=draw the foreground directly without invalidating the
- * redraw area.
- */
-void draw(int x, int y, int width, int height, boolean clearBackground) {
- if (clearBackground) {
- redraw(x + leftMargin, y + topMargin, width, height, true);
- }
- else {
- int startLine = (y + verticalScrollOffset) / lineHeight;
- int endY = y + height;
- int paintYFromTopLine = (startLine - topIndex) * lineHeight;
- int topLineOffset = (topIndex * lineHeight - verticalScrollOffset);
- int paintY = paintYFromTopLine + topLineOffset + topMargin; // adjust y position for pixel based scrolling
- int lineCount = content.getLineCount();
- Color background = getBackground();
- Color foreground = getForeground();
- GC gc = getGC();
-
- 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);
- renderer.drawLine(line, i, paintY, gc, background, foreground, clearBackground);
- }
- gc.dispose();
- }
-}
-/**
- * Ends the autoscroll process.
- */
-void endAutoScroll() {
- autoScrollDirection = SWT.NULL;
-}
-/**
- * @see org.eclipse.swt.widgets.Control#getBackground
- */
-public Color getBackground() {
- checkWidget();
- if (background == null) {
- return getDisplay().getSystemColor(SWT.COLOR_LIST_BACKGROUND);
- }
- return background;
-}
-/**
- * Gets the BIDI coloring mode. When true the BIDI text display
- * algorithm is applied to segments of text that are the same
- * color.
- *
- * @return the current coloring mode
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- * <p>
- * @deprecated use BidiSegmentListener instead.
- * </p>
- */
-public boolean getBidiColoring() {
- checkWidget();
- return bidiColoring;
-}
-/**
- * Returns the offset at the specified x location in the specified line.
- * Also sets the caret direction so that the caret is placed correctly
- * depending on whether the mouse location is in a R2L or L2R segment.
- * <p>
- *
- * @param x x location of the mouse location
- * @param line line the mouse location is in
- * @return the offset at the specified x location in the specified line,
- * relative to the beginning of the document
- */
-int getBidiOffsetAtMouseLocation(int x, int line) {
- String lineText = content.getLine(line);
- int lineOffset = content.getOffsetAtLine(line);
- GC gc = getGC();
- StyledTextBidi bidi = getStyledTextBidi(lineText, lineOffset, gc);
- int[] values;
- int offsetInLine;
- x += horizontalScrollOffset;
- values = bidi.getCaretOffsetAndDirectionAtX(x - leftMargin);
- offsetInLine = values[0];
- lastCaretDirection = values[1];
- gc.dispose();
-
- return lineOffset + offsetInLine;
-}
-/**
- * Returns the x position of the character at the specified offset
- * relative to the first character in the line.
- * </p>
- *
- * @param text text to be measured.
- * @param endOffset offset of the character
- * @param bidi the bidi object to use for measuring text in bidi
- * locales.
- * @return x position of the character at the specified offset.
- * 0 if the length is outside the specified text.
- */
-int getBidiTextPosition(String text, int endOffset, StyledTextBidi bidi) {
- if (endOffset > text.length()) {
- return 0;
- }
- // Use lastCaretDirection in order to get same results as during
- // caret positioning (setBidiCaretLocation). Fixes 1GKU4C5.
- return bidi.getTextPosition(endOffset, lastCaretDirection);
-}
-/**
- * Returns the index of the last fully visible line.
- * <p>
- *
- * @return index of the last fully visible line.
- */
-int getBottomIndex() {
- int lineCount = 1;
-
- if (lineHeight != 0) {
- // calculate the number of lines that are fully visible
- int partialTopLineHeight = topIndex * lineHeight - verticalScrollOffset;
- lineCount = (getClientArea().height - partialTopLineHeight) / lineHeight;
- }
- return Math.min(content.getLineCount() - 1, topIndex + Math.max(0, lineCount - 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 caret offset at the given x location in the line.
- * The caret offset is the offset of the character where the caret will be
- * placed when a mouse click occurs. The caret offset will be the offset of
- * the character after the clicked one if the mouse click occurs at the second
- * half of a character.
- * Doesn't properly handle ligatures and other context dependent characters
- * unless the current locale is a bidi locale.
- * 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 caret offset at the x location relative to the start of the line.
- */
-int getCaretOffsetAtX(String line, int lineOffset, int lineXOffset) {
- int offset = 0;
- GC gc = getGC();
- StyleRange[] styles = null;
- StyledTextEvent event = renderer.getLineStyleData(lineOffset, line);
-
- lineXOffset += horizontalScrollOffset;
- if (event != null) {
- styles = renderer.filterLineStyles(event.styles);
- }
- int low = -1;
- int high = line.length();
- while (high - low > 1) {
- offset = (high + low) / 2;
- int x = renderer.getTextPosition(line, lineOffset, offset, styles, gc) + leftMargin;
- int charWidth = renderer.getTextPosition(line, lineOffset, offset + 1, styles, gc) + leftMargin - x;
- if (lineXOffset <= x + charWidth / 2) {
- high = offset;
- }
- else {
- low = offset;
- }
- }
- offset = high;
- gc.dispose();
- return offset;
-}
-/**
- * Returns the caret width.
- * <p>
- *
- * @return the caret width, 0 if caret is null.
- */
-int getCaretWidth() {
- Caret caret = getCaret();
- if (caret == null) return 0;
- return caret.getSize().x;
-}
-/**
- * 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 logicalContent;
-}
-/**
- * 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;
-}
-/**
- * @see org.eclipse.swt.widgets.Control#getForeground
- */
-public Color getForeground() {
- checkWidget();
- if (foreground == null) {
- return getDisplay().getSystemColor(SWT.COLOR_LIST_FOREGROUND);
- }
- return foreground;
-}
-/**
- * Return a GC to use for rendering and update the cached font style to
- * represent the current style.
- * <p>
- *
- * @return GC.
- */
-GC getGC() {
- renderer.setCurrentFontStyle(SWT.NORMAL);
- return new GC(this);
-}
-/**
- * Returns the horizontal scroll increment.
- * <p>
- *
- * @return horizontal scroll increment.
- */
-int getHorizontalIncrement() {
- GC gc = getGC();
- 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. Preferred state masks are one or more of
- * SWT.MOD1, SWT.MOD2, SWT.MOD3, since these masks account for modifier platform
- * differences. However, there may be cases where using the specific state masks
- * (i.e., SWT.CTRL, SWT.SHIFT, SWT.ALT, SWT.COMMAND) makes sense.
- * @return one of the predefined actions defined in ST.java or SWT.NULL
- * if there is no action associated with the key.
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public int getKeyBinding(int key) {
- checkWidget();
- Integer action = (Integer) keyActionMap.get(new Integer(key));
- 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 > logicalContent.getLineCount()) {
- SWT.error(SWT.ERROR_INVALID_ARGUMENT);
- }
- if (userLineBackground == false) {
- lineBackground = defaultLineStyler.getLineBackground(index);
- }
- return lineBackground;
-}
-/**
- * Returns the line background data for the given line or null if
- * there is none.
- * <p>
- * @param lineOffset offset of the line start relative to the start
- * of the content.
- * @param line line to get line background data for
- * @return line background data for the given line.
- */
-StyledTextEvent getLineBackgroundData(int lineOffset, String line) {
- return sendLineEvent(LineGetBackground, lineOffset, line);
-}
-/**
- * Gets the number of text lines.
- * <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 can be completely displayed in the
- * widget client area.
- * <p>
- *
- * @return number of lines that can be completely displayed in the widget
- * client area.
- */
-int getLineCountWhole() {
- int lineCount;
-
- 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 logicalContent.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 a StyledTextEvent that can be used to request data such
- * as styles and background color for a line.
- * The specified line may be a visual (wrapped) line if in word
- * wrap mode. The returned object will always be for a logical
- * (unwrapped) line.
- * <p>
- *
- * @param lineOffset offset of the line. This may be the offset of
- * a visual line if the widget is in word wrap mode.
- * @param line line text. This may be the text of a visualline if
- * the widget is in word wrap mode.
- * @return StyledTextEvent that can be used to request line data
- * for the given line.
- */
-StyledTextEvent sendLineEvent(int eventType, int lineOffset, String line) {
- StyledTextEvent event = null;
-
- if (isListening(eventType)) {
- event = new StyledTextEvent(logicalContent);
- if (wordWrap) {
- // if word wrap is on, the line offset and text may be visual (wrapped)
- int lineIndex = logicalContent.getLineAtOffset(lineOffset);
-
- event.detail = logicalContent.getOffsetAtLine(lineIndex);
- event.text = logicalContent.getLine(lineIndex);
- }
- else {
- event.detail = lineOffset;
- event.text = line;
- }
- notifyListeners(eventType, event);
- }
- return event;
-}
-/**
- * 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();
- return lineHeight;
-}
-/**
- * Returns a LineCache implementation. Depending on whether or not
- * word wrap is on this may be a line wrapping or line width
- * calculating implementaiton.
- * <p>
- *
- * @param content StyledTextContent to create the LineCache on.
- * @return a LineCache implementation
- */
-LineCache getLineCache(StyledTextContent content) {
- LineCache lineCache;
-
- if (wordWrap) {
- lineCache = new WordWrapCache(this, (WrappedContent) content);
- }
- else {
- lineCache = new ContentWidthCache(this, content.getLineCount());
- }
- return lineCache;
-}
-/**
- * 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.
- * <p>
- *
- * @param lineOffset offset of the line start relative to the start of
- * the content.
- * @param line line to get line styles for
- * @return line style data for the given line. Styles may start before
- * line start and end after line end
- */
-StyledTextEvent getLineStyleData(int lineOffset, String line) {
- return sendLineEvent(LineGetStyle, lineOffset, line);
-}
-/**
- * Returns the 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 = content.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 character offset of the first character of the given line.
- * <p>
- *
- * @param lineIndex index of the line, 0 based relative to the first
- * line in the content. 0 <= lineIndex < getLineCount(), except
- * lineIndex may always be 0
- * @return offset offset of the first character of the line, relative to
- * the beginning of the document. The first character of the document is
- * at offset 0.
- * When there are not any lines, getOffsetAtLine(0) is a valid call that
- * answers 0.
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_INVALID_RANGE when the offset is outside the valid range (< 0 or > getCharCount())</li>
- * </ul>
- * @since 2.0
- */
-public int getOffsetAtLine(int lineIndex) {
- checkWidget();
-
- if (lineIndex < 0 ||
- (lineIndex > 0 && lineIndex >= logicalContent.getLineCount())) {
- SWT.error(SWT.ERROR_INVALID_RANGE);
- }
- return logicalContent.getOffsetAtLine(lineIndex);
-}
-/**
- * Returns the offset of the character at the given location relative
- * to the first character in the document.
- * The return value reflects the character offset that the caret will
- * be placed at if a mouse click occurred at the specified location.
- * If the x coordinate of the location is beyond the center of a character
- * the returned offset will be behind the character.
- * <p>
- *
- * @param point the origin of character bounding box relative to
- * the origin of the widget client area.
- * @return offset of the character at the given location relative
- * to the first character in the document.
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT when point is null</li>
- * <li>ERROR_INVALID_ARGUMENT when there is no character at the specified location</li>
- * </ul>
- */
-public int getOffsetAtLocation(Point point) {
- checkWidget();
- int line;
- int lineOffset;
- int offsetInLine;
- String lineText;
-
- if (point == null) {
- SWT.error(SWT.ERROR_NULL_ARGUMENT);
- }
- // is y above first line or is x before first column?
- if (point.y + verticalScrollOffset < 0 || point.x + horizontalScrollOffset < 0) {
- SWT.error(SWT.ERROR_INVALID_ARGUMENT);
- }
- line = (getTopPixel() + point.y) / lineHeight;
- // does the referenced line exist?
- if (line >= content.getLineCount()) {
- SWT.error(SWT.ERROR_INVALID_ARGUMENT);
- }
- lineText = content.getLine(line);
- lineOffset = content.getOffsetAtLine(line);
- offsetInLine = getOffsetAtX(lineText, lineOffset, point.x);
- // is the x position within the line?
- if (offsetInLine == -1) {
- SWT.error(SWT.ERROR_INVALID_ARGUMENT);
- }
- return lineOffset + offsetInLine;
-}
-/**
- * Returns the offset at the specified x location in the specified line.
- * <p>
- *
- * @param x x location of the mouse location
- * @param line line the mouse location is in
- * @return the offset at the specified x location in the specified line,
- * relative to the beginning of the document
- */
-int getOffsetAtMouseLocation(int x, int line) {
- String lineText = content.getLine(line);
- int lineOffset = content.getOffsetAtLine(line);
- int offsetInLine = getCaretOffsetAtX(lineText, lineOffset, x);
- return lineOffset + offsetInLine;
-}
-/**
- * Returns the offset of the character at the given x location in the line.
- * <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. -1 if the x location is past the end if the line.
- */
-int getOffsetAtX(String line, int lineOffset, int lineXOffset) {
- GC gc = getGC();
- int offset;
-
- lineXOffset += (horizontalScrollOffset - leftMargin);
- if (isBidi()) {
- StyledTextBidi bidi = getStyledTextBidi(line, lineOffset, gc);
- offset = bidi.getOffsetAtX(lineXOffset);
- }
- else {
- StyleRange[] styles = null;
- StyledTextEvent event = renderer.getLineStyleData(lineOffset, line);
-
- if (event != null) {
- styles = renderer.filterLineStyles(event.styles);
- }
- int low = -1;
- int high = line.length();
- while (high - low > 1) {
- offset = (high + low) / 2;
- // Restrict right/high search boundary only if x is within searched text segment.
- // Fixes 1GL4ZVE.
- if (lineXOffset < renderer.getTextPosition(line, lineOffset, offset + 1, styles, gc)) {
- high = offset;
- }
- else
- if (high == line.length() && high - offset == 1) {
- // requested x location is past end of line
- high = -1;
- }
- 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 = Compatibility.ceil(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 = logicalContent.getLineAtOffset(writer.getStart());
- int endLine = logicalContent.getLineAtOffset(end);
- String endLineText = logicalContent.getLine(endLine);
- int endLineOffset = logicalContent.getOffsetAtLine(endLine);
-
- for (int i = startLine; i <= endLine; i++) {
- writer.writeLine(logicalContent.getLine(i), logicalContent.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.
- * The selection values returned are visual (i.e., x will always always be
- * <= y). To determine if a selection is right-to-left (RtoL) vs. left-to-right
- * (LtoR), compare the caretOffset to the start and end of the selection
- * (e.g., caretOffset == start of selection implies that the selection is RtoL).
- * @see #getSelectionRange
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public Point getSelection() {
- checkWidget();
- return new Point(selection.x, selection.y);
-}
-/**
- * Returns the selection.
- * <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.
- * The selection values returned are visual (i.e., length will always always be
- * positive). To determine if a selection is right-to-left (RtoL) vs. left-to-right
- * (LtoR), compare the caretOffset to the start and end of the selection
- * (e.g., caretOffset == start of selection implies that the selection is RtoL).
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public Point getSelectionRange() {
- checkWidget();
- return new Point(selection.x, selection.y - selection.x);
-}
-/**
- * Returns the receiver's selection background color.
- *
- * @return the selection background color
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- * @since 2.1
- */
-public Color getSelectionBackground() {
- checkWidget();
- if (selectionBackground == null) {
- return getDisplay().getSystemColor(SWT.COLOR_LIST_SELECTION);
- }
- return selectionBackground;
-}
-/**
- * Gets the number of selected characters.
- * <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 receiver's selection foreground color.
- *
- * @return the selection foreground color
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- * @since 2.1
- */
-public Color getSelectionForeground() {
- checkWidget();
- if (selectionForeground == null) {
- return getDisplay().getSystemColor(SWT.COLOR_LIST_SELECTION_TEXT);
- }
- return selectionForeground;
-}
-/**
- * Returns the selected text.
- * <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 text segments that should be treated as if they
- * had a different direction than the surrounding text.
- * <p>
- *
- * @param lineOffset offset of the first character in the line.
- * 0 based from the beginning of the document.
- * @param line text of the line to specify bidi segments for
- * @return text segments that should be treated as if they had a
- * different direction than the surrounding text. Only the start
- * index of a segment is specified, relative to the start of the
- * line. Always starts with 0 and ends with the line length.
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_INVALID_ARGUMENT - if the segment indices returned
- * by the listener do not start with 0, are not in ascending order,
- * exceed the line length or have duplicates</li>
- * </ul>
- */
-int [] getBidiSegments(int lineOffset, String line) {
- if (isListening(LineGetSegments) == false) {
- return getBidiSegmentsCompatibility(line, lineOffset);
- }
- StyledTextEvent event = sendLineEvent(LineGetSegments, lineOffset, line);
- int lineLength = line.length();
- int[] segments;
- if (event == null || event.segments == null || event.segments.length == 0) {
- segments = new int[] {0, lineLength};
- }
- else {
- int segmentCount = event.segments.length;
-
- // test segment index consistency
- if (event.segments[0] != 0) {
- SWT.error(SWT.ERROR_INVALID_ARGUMENT);
- }
- for (int i = 1; i < segmentCount; i++) {
- if (event.segments[i] <= event.segments[i - 1] || event.segments[i] > lineLength) {
- SWT.error(SWT.ERROR_INVALID_ARGUMENT);
- }
- }
- // ensure that last segment index is line end offset
- if (event.segments[segmentCount - 1] != lineLength) {
- segments = new int[segmentCount + 1];
- System.arraycopy(event.segments, 0, segments, 0, segmentCount);
- segments[segmentCount] = lineLength;
- }
- else {
- segments = event.segments;
- }
- }
- return segments;
-}
-/**
- * @see getBidiSegments
- * Supports deprecated setBidiColoring API. Remove when API is removed.
- */
-int [] getBidiSegmentsCompatibility(String line, int lineOffset) {
- StyledTextEvent event;
- StyleRange [] styles = new StyleRange [0];
- int lineLength = line.length();
- if (bidiColoring == false) {
- return new int[] {0, lineLength};
- }
- event = renderer.getLineStyleData(lineOffset, line);
- if (event != null) {
- styles = event.styles;
- }
- if (styles.length == 0) {
- return new int[] {0, lineLength};
- }
- int k=0, count = 1;
- while (k < styles.length && styles[k].start == 0 && styles[k].length == lineLength) {
- k++;
- }
- int[] offsets = new int[(styles.length - k) * 2 + 2];
- for (int i = k; i < styles.length; i++) {
- StyleRange style = styles[i];
- int styleLineStart = Math.max(style.start - lineOffset, 0);
- int styleLineEnd = Math.max(style.start + style.length - lineOffset, styleLineStart);
- styleLineEnd = Math.min (styleLineEnd, line.length ());
- if (i > 0 && count > 1 &&
- ((styleLineStart >= offsets[count-2] && styleLineStart <= offsets[count-1]) ||
- (styleLineEnd >= offsets[count-2] && styleLineEnd <= offsets[count-1])) &&
- style.similarTo(styles[i-1])) {
- offsets[count-2] = Math.min(offsets[count-2], styleLineStart);
- offsets[count-1] = Math.max(offsets[count-1], styleLineEnd);
- } else {
- if (styleLineStart > offsets[count - 1]) {
- offsets[count] = styleLineStart;
- count++;
- }
- offsets[count] = styleLineEnd;
- count++;
- }
- }
- // add offset for last non-colored segment in line, if any
- if (lineLength > offsets[count-1]) {
- offsets [count] = lineLength;
- count++;
- }
- if (count == offsets.length) {
- return offsets;
- }
- int [] result = new int [count];
- System.arraycopy (offsets, 0, result, 0, count);
- return result;
-}
-/**
- * Returns the style range at the given offset.
- * Returns null if a LineStyleListener has been set or if a style is not set
- * for the offset.
- * Should not be called if a LineStyleListener has been set since the
- * listener maintains the styles.
- * <p>
- *
- * @param offset the offset to return the style for.
- * 0 <= offset < getCharCount() must be true.
- * @return a StyleRange with start == offset and length == 1, indicating
- * the style at the given offset. null if a LineStyleListener has been set
- * or if a style is not set for the given offset.
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_INVALID_ARGUMENT when the offset is invalid</li>
- * </ul>
- */
-public StyleRange getStyleRangeAtOffset(int offset) {
- checkWidget();
- if (offset < 0 || offset >= getCharCount()) {
- SWT.error(SWT.ERROR_INVALID_ARGUMENT);
- }
- if (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 a StyledTextBidi object for the specified line.
- * <p>
- *
- * @param lineText the line that the StyledTextBidi object should
- * work on.
- * @param lineOffset offset of the beginning of the line, relative
- * to the beginning of the document
- * @param gc GC to use when creating a new StyledTextBidi object.
- * @return a StyledTextBidi object for the specified line.
- */
-StyledTextBidi getStyledTextBidi(String lineText, int lineOffset, GC gc) {
- return getStyledTextBidi(lineText, lineOffset, gc, null);
-}
-/**
- * Returns a StyledTextBidi object for the specified line.
- * <p>
- *
- * @param lineText the line that the StyledTextBidi object should
- * work on.
- * @param lineOffset offset of the beginning of the line, relative
- * to the beginning of the document
- * @param gc GC to use when creating a new StyledTextBidi object.
- * @param styles StyleRanges to use when creating a new StyledTextBidi
- * object.
- * @return a StyledTextBidi object for the specified line.
- */
-StyledTextBidi getStyledTextBidi(String lineText, int lineOffset, GC gc, StyleRange[] styles) {
- return renderer.getStyledTextBidi(lineText, lineOffset, gc, 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 > end || start < 0 || end > contentLength) {
- 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;
-}
-/**
- * Returns the x position of the character at the specified offset
- * relative to the first character in the line.
- * Expands 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 x position of the character at the specified offset
- * with tabs expanded to tab stops. 0 if the length is outside the
- * specified text.
- */
-int getTextPosition(String line, int lineIndex, int length, GC gc) {
- int lineOffset = content.getOffsetAtLine(lineIndex);
- int lineLength = line.length();
- int width;
- if (lineLength == 0 || length > lineLength) {
- return 0;
- }
- if (isBidi()) {
- StyledTextBidi bidi = getStyledTextBidi(line, lineOffset, gc, null);
- width = getBidiTextPosition(line, length, bidi);
- }
- else {
- StyledTextEvent event = renderer.getLineStyleData(lineOffset, line);
- StyleRange[] styles = null;
- if (event != null) {
- styles = renderer.filterLineStyles(event.styles);
- }
- width = renderer.getTextPosition(line, lineOffset, length, styles, gc);
- }
- return width;
-}
-/**
- * Gets the top index. The top index is the index of the fully visible line that
- * is currently at the top of the widget or the topmost partially visible line if
- * no line is fully visible.
- * The top index changes when the widget is scrolled. Indexing is zero based.
- * <p>
- *
- * @return the index of the top line
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public int getTopIndex() {
- checkWidget();
- int logicalTopIndex = topIndex;
-
- if (wordWrap) {
- int visualLineOffset = content.getOffsetAtLine(topIndex);
- logicalTopIndex = logicalContent.getLineAtOffset(visualLineOffset);
- }
- return logicalTopIndex;
-}
-/**
- * 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 lineHeight;
-}
-/**
- * Returns the index of the line the caret is on.
- * When in word wrap mode and at the end of one wrapped line/
- * beginning of the continuing wrapped line the caret offset
- * is not sufficient to determine the caret line.
- *
- * @return the index of the line the caret is on.
- */
-int getCaretLine() {
- int caretLine = content.getLineAtOffset(caretOffset);
- int leftColumnX = 0;
-
- if (isBidi()) {
- leftColumnX = XINSET;
- }
- if (wordWrap && columnX <= leftColumnX &&
- caretLine < content.getLineCount() - 1 &&
- caretOffset == content.getOffsetAtLine(caretLine + 1)) {
- caretLine++;
- }
- return caretLine;
-}
-/**
- * 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 = logicalContent.getLineAtOffset(offset);
- int lineOffset = logicalContent.getOffsetAtLine(line);
- String lineText = logicalContent.getLine(line);
- int lineLength = lineText.length();
-
- if (offset >= getCharCount()) {
- return offset;
- }
- if (offset == lineOffset + lineLength) {
- line++;
- offset = logicalContent.getOffsetAtLine(line);
- }
- else {
- offset -= lineOffset;
- char ch = lineText.charAt(offset);
- boolean letterOrDigit = Compatibility.isLetterOrDigit(ch);
- while (offset < lineLength - 1 && Compatibility.isLetterOrDigit(ch) == letterOrDigit) {
- offset++;
- ch = lineText.charAt(offset);
- }
- // skip over trailing whitespace
- while (offset < lineLength - 1 && Compatibility.isSpaceChar(ch)) {
- offset++;
- ch = lineText.charAt(offset);
- }
- if (offset == lineLength - 1 && (Compatibility.isLetterOrDigit(ch) == letterOrDigit || Compatibility.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 = logicalContent.getLineAtOffset(offset);
- int lineOffset = logicalContent.getOffsetAtLine(line);
- String lineText = logicalContent.getLine(line);
- int lineLength = lineText.length();
-
- if (offset >= getCharCount()) {
- return offset;
- }
- if (offset == lineOffset + lineLength) {
- line++;
- offset = logicalContent.getOffsetAtLine(line);
- }
- else {
- offset -= lineOffset;
- char ch = lineText.charAt(offset);
- boolean letterOrDigit = Compatibility.isLetterOrDigit(ch);
-
- while (offset < lineLength - 1 && Compatibility.isLetterOrDigit(ch) == letterOrDigit && Compatibility.isSpaceChar(ch) == false) {
- offset++;
- ch = lineText.charAt(offset);
- }
- if (offset == lineLength - 1 && Compatibility.isLetterOrDigit(ch) == letterOrDigit && Compatibility.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 = logicalContent.getLineAtOffset(offset);
- int lineOffset = logicalContent.getOffsetAtLine(line);
- String lineText = logicalContent.getLine(line);
-
- if (offset <= 0) {
- return offset;
- }
- if (offset == lineOffset) {
- line--;
- lineText = logicalContent.getLine(line);
- offset = logicalContent.getOffsetAtLine(line) + lineText.length();
- }
- else {
- char ch;
- boolean letterOrDigit;
-
- offset -= lineOffset;
- // skip over trailing whitespace
- do {
- offset--;
- ch = lineText.charAt(offset);
- } while (offset > 0 && Compatibility.isSpaceChar(ch));
- letterOrDigit = Compatibility.isLetterOrDigit(ch);
- while (offset > 0 && Compatibility.isLetterOrDigit(ch) == letterOrDigit && Compatibility.isSpaceChar(ch) == false) {
- offset--;
- ch = lineText.charAt(offset);
- }
- if (offset > 0 || Compatibility.isLetterOrDigit(ch) != letterOrDigit) {
- offset++;
- }
- offset += lineOffset;
- }
- return offset;
-}
-/**
- * Returns whether the widget wraps lines.
- * <p>
- *
- * @return true if widget wraps lines, false otherwise
- * @since 2.0
- */
-public boolean getWordWrap() {
- checkWidget();
- return wordWrap;
-}
-/**
- * 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 given offset in the line.
- */
-int getXAtOffset(String line, int lineIndex, int lineOffset) {
- int x;
- if (lineOffset == 0 && isBidi() == false) {
- x = leftMargin;
- }
- else {
- GC gc = getGC();
- x = getTextPosition(line, lineIndex, Math.min(line.length(), lineOffset), gc) + leftMargin;
- gc.dispose();
- if (lineOffset > line.length()) {
- // offset is not on the line. return an x location one character
- // after the line to indicate the line delimiter.
- x += lineEndSpaceWidth;
- }
- }
- 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 string is null</li>
- * </ul>
- */
-public void insert(String string) {
- checkWidget();
- if (string == null) {
- SWT.error(SWT.ERROR_NULL_ARGUMENT);
- }
- Point sel = getSelectionRange();
- replaceTextRange(sel.x, sel.y, string);
-}
-/**
- * Creates content change listeners and set the default content model.
- */
-void installDefaultContent() {
- textChangeListener = new TextChangeListener() {
- public void textChanging(TextChangingEvent event) {
- handleTextChanging(event);
- }
- public void textChanged(TextChangedEvent event) {
- handleTextChanged(event);
- }
- public void textSet(TextChangedEvent event) {
- handleTextSet(event);
- }
- };
- logicalContent = content = new DefaultContent();
- content.addTextChangeListener(textChangeListener);
-}
-/**
- * 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(logicalContent);
- 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) {
- handleTraverse(event);
- }
- });
- 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);
- }
- });
- }
-}
-StyledTextContent internalGetContent() {
- return content;
-}
-int internalGetHorizontalPixel() {
- return horizontalScrollOffset;
-}
-LineCache internalGetLineCache() {
- return lineCache;
-}
-Point internalGetSelection() {
- return selection;
-}
-boolean internalGetWordWrap() {
- return wordWrap;
-}
-/**
- * Used by WordWrapCache to bypass StyledText.redraw which does
- * an unwanted cache reset.
- */
-void internalRedraw() {
- super.redraw();
-}
-/**
- * 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 range will
- * be cleared before anything is redrawn. If the redraw range includes
- * the last character of a line (i.e., the entire line is redrawn) the
- * line is cleared all the way to the right border of the widget.
- * The redraw operation will be faster and smoother if clearBackground is
- * set to false. Whether or not the flag can be set to false depends on
- * the type of change that has taken place. If font styles or background
- * colors for the redraw range have changed, clearBackground should be
- * set to true. If only foreground colors have changed for the redraw
- * range, clearBackground can be set to false.
- */
-void internalRedrawRange(int start, int length, boolean clearBackground) {
- int end = start + length;
- int firstLine = content.getLineAtOffset(start);
- int lastLine = content.getLineAtOffset(end);
- int offsetInFirstLine;
- int partialBottomIndex = getPartialBottomIndex();
- int partialTopIndex = verticalScrollOffset / lineHeight;
- // do nothing if redraw range is completely invisible
- if (firstLine > partialBottomIndex || lastLine < partialTopIndex) {
- return;
- }
- // only redraw visible lines
- if (partialTopIndex > firstLine) {
- firstLine = partialTopIndex;
- offsetInFirstLine = 0;
- }
- else {
- offsetInFirstLine = start - content.getOffsetAtLine(firstLine);
- }
- if (partialBottomIndex + 1 < lastLine) {
- lastLine = partialBottomIndex + 1; // + 1 to redraw whole bottom line, including line break
- end = content.getOffsetAtLine(lastLine);
- }
- // redraw first and last lines
- if (isBidi()) {
- redrawBidiLines(firstLine, offsetInFirstLine, lastLine, end, clearBackground);
- }
- else {
- redrawLines(firstLine, offsetInFirstLine, lastLine, end, clearBackground);
- }
- // redraw entire center lines if redraw range includes more than two lines
- if (lastLine - firstLine > 1) {
- Rectangle clientArea = getClientArea();
- int redrawStopY = lastLine * lineHeight - verticalScrollOffset;
- int redrawY = (firstLine + 1) * lineHeight - verticalScrollOffset;
- draw(0, redrawY, clientArea.width, redrawStopY - redrawY, clearBackground);
- }
-}
-/**
- * Returns the widget text with style information encoded using RTF format
- * specification version 1.5.
- *
- * @return the widget text with style information encoded using RTF format
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-String getRtf(){
- checkWidget();
- RTFWriter rtfWriter = new RTFWriter(0, getCharCount());
- return getPlatformDelimitedText(rtfWriter);
-}
-/**
- * Frees resources.
- */
-void handleDispose() {
- clipboard.dispose();
- ibeamCursor.dispose();
- if (renderer != null) {
- renderer.dispose();
- renderer = null;
- }
- if (content != null) {
- content.removeTextChangeListener(textChangeListener);
- }
- if (leftCaretBitmap != null) {
- leftCaretBitmap.dispose();
- leftCaretBitmap = null;
- }
- if (rightCaretBitmap != null) {
- rightCaretBitmap.dispose();
- rightCaretBitmap = null;
- }
- if (isBidi()) {
- StyledTextBidi.removeLanguageListener(this);
- }
-}
-/**
- * Scrolls the widget horizontally.
- */
-void handleHorizontalScroll(Event event) {
- int scrollPixel = getHorizontalBar().getSelection() - horizontalScrollOffset;
- scrollHorizontal(scrollPixel);
-}
-/**
- * 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) {
- // special key pressed (e.g., F1)
- action = getKeyBinding(event.keyCode | event.stateMask);
- }
- else {
- // character key pressed
- action = getKeyBinding(event.character | event.stateMask);
- if (action == SWT.NULL) {
- // see if we have a control character
- if ((event.stateMask & SWT.CTRL) != 0 && (event.character >= 0) && event.character <= 31) {
- // get the character from the CTRL+char sequence, the control
- // key subtracts 64 from the value of the key that it modifies
- int c = event.character + 64;
- action = getKeyBinding(c | event.stateMask);
- }
- }
- }
- if (action == SWT.NULL) {
- boolean ignore = false;
-
- if (isCarbon) {
- // Ignore acclerator key combinations (we do not want to
- // insert a character in the text in this instance). Do not
- // ignore COMMAND+ALT combinations since that key sequence
- // produces characters on the mac.
- ignore = (event.stateMask ^ SWT.COMMAND) == 0 ||
- (event.stateMask ^ (SWT.COMMAND | SWT.SHIFT)) == 0;
- } else {
- // Ignore acclerator key combinations (we do not want to
- // insert a character in the text in this instance). Don't
- // ignore CTRL+ALT combinations since that is the Alt Gr
- // key on some keyboards. See bug 20953.
- ignore = (event.stateMask ^ SWT.ALT) == 0 ||
- (event.stateMask ^ SWT.CTRL) == 0 ||
- (event.stateMask ^ (SWT.ALT | SWT.SHIFT)) == 0 ||
- (event.stateMask ^ (SWT.CTRL | SWT.SHIFT)) == 0;
- }
- // -ignore anything below SPACE except for line delimiter keys and tab.
- // -ignore DEL
- if (!ignore && event.character > 31 && event.character != SWT.DEL ||
- event.character == SWT.CR || event.character == SWT.LF ||
- event.character == TAB) {
- doContent(event.character);
- }
- }
- else {
- invokeAction(action);
- }
-}
-/**
- * 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);
- }
-}
-/**
- * Updates the caret location and selection if mouse button 1 has been
- * pressed.
- */
-void handleMouseDoubleClick(Event event) {
- if (event.button != 1 || doubleClickEnabled == false) {
- return;
- }
- event.y -= topMargin;
- mouseDoubleClick = true;
- caretOffset = getWordStart(caretOffset);
- resetSelection();
- caretOffset = getWordEndNoSpaces(caretOffset);
- showCaret();
- doMouseSelection();
- doubleClickSelection = new Point(selection.x, selection.y);
-}
-/**
- * Updates the caret location and selection if mouse button 1 has been
- * pressed.
- */
-void handleMouseDown(Event event) {
- boolean select = (event.stateMask & SWT.MOD2) != 0;
-
- if (event.button != 1) {
- return;
- }
- mouseDoubleClick = false;
- event.y -= topMargin;
- doMouseLocationChange(event.x, event.y, select);
-}
-/**
- * Updates the caret location and selection if mouse button 1 is pressed
- * during the mouse move.
- */
-void handleMouseMove(Event event) {
- if ((event.stateMask & SWT.BUTTON1) == 0) {
- return;
- }
- event.y -= topMargin;
- doMouseLocationChange(event.x, event.y, true);
- doAutoScroll(event);
-}
-/**
- * Autoscrolling ends when the mouse button is released.
- */
-void handleMouseUp(Event event) {
- event.y -= topMargin;
- endAutoScroll();
-}
-/**
- * Renders the invalidated area specified in the paint event.
- * <p>
- *
- * @param event paint event
- */
-void handlePaint(Event event) {
- int startLine = Math.max(0, (event.y - topMargin + verticalScrollOffset) / lineHeight);
- int paintYFromTopLine = (startLine - topIndex) * lineHeight;
- int topLineOffset = topIndex * lineHeight - verticalScrollOffset;
- int startY = paintYFromTopLine + topLineOffset + topMargin; // adjust y position for pixel based scrolling and top margin
- int renderHeight = event.y + event.height - startY;
- Rectangle clientArea = getClientArea();
-
- // Check if there is work to do. clientArea.width should never be 0
- // if we receive a paint event but we never want to try and create
- // an Image with 0 width.
- if (clientArea.width == 0 || event.height == 0) {
- return;
- }
- performPaint(event.gc, startLine, startY, renderHeight);
-}
-/**
- * Recalculates the scroll bars. Rewraps all lines when in word
- * wrap mode.
- * <p>
- *
- * @param event resize event
- */
-void handleResize(Event event) {
- int oldHeight = clientAreaHeight;
- int oldWidth = clientAreaWidth;
-
- clientAreaHeight = getClientArea().height;
- clientAreaWidth = getClientArea().width;
- if (wordWrap) {
- if (oldWidth != clientAreaWidth) {
- wordWrapResize(oldWidth);
- }
- }
- else
- if (clientAreaHeight > oldHeight) {
- int lineCount = content.getLineCount();
- int oldBottomIndex = topIndex + oldHeight / lineHeight;
- int newItemCount = Compatibility.ceil(clientAreaHeight - oldHeight, lineHeight);
-
- oldBottomIndex = Math.min(oldBottomIndex, lineCount);
- newItemCount = Math.min(newItemCount, lineCount - oldBottomIndex);
- lineCache.calculate(oldBottomIndex, newItemCount);
- }
- setScrollBars();
- claimBottomFreeSpace();
- claimRightFreeSpace();
- if (oldHeight != clientAreaHeight) {
- calculateTopIndex();
- }
-}
-/**
- * Updates the caret position and selection and the scroll bars to reflect
- * the content change.
- * <p>
- */
-void handleTextChanged(TextChangedEvent event) {
- lineCache.textChanged(lastTextChangeStart,
- lastTextChangeNewLineCount,
- lastTextChangeReplaceLineCount,
- lastTextChangeNewCharCount,
- lastTextChangeReplaceCharCount);
- setScrollBars();
- // 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(
- lastTextChangeStart,
- lastTextChangeReplaceCharCount,
- lastTextChangeNewCharCount);
-
- if (lastTextChangeReplaceLineCount > 0) {
- // Only check for unused space when lines are deleted.
- // Fixes 1GFL4LY
- // Scroll up so that empty lines below last text line are used.
- // Fixes 1GEYJM0
- claimBottomFreeSpace();
- }
- if (lastTextChangeReplaceCharCount > 0) {
- // fixes bug 8273
- claimRightFreeSpace();
- }
- // do direct drawing if the text change is confined to a single line.
- // optimization and fixes bug 13999. see also handleTextChanging.
- if (lastTextChangeNewLineCount == 0 && lastTextChangeReplaceLineCount == 0) {
- int startLine = content.getLineAtOffset(lastTextChangeStart);
- int startY = startLine * lineHeight - verticalScrollOffset + topMargin;
-
- GC gc = getGC();
- Caret caret = getCaret();
- boolean caretVisible = false;
-
- if (caret != null) {
- caretVisible = caret.getVisible();
- caret.setVisible(false);
- }
- performPaint(gc, startLine, startY, lineHeight);
- if (caret != null) {
- caret.setVisible(caretVisible);
- }
- gc.dispose();
- }
-}
-/**
- * Updates the screen to reflect a pending content change.
- * <p>
- *
- * @param event.start the start offset of the change
- * @param event.newText text that is going to be inserted or empty String
- * if no text will be inserted
- * @param event.replaceCharCount length of text that is going to be replaced
- * @param event.newCharCount length of text that is going to be inserted
- * @param event.replaceLineCount number of lines that are going to be replaced
- * @param event.newLineCount number of new lines that are going to be inserted
- */
-void handleTextChanging(TextChangingEvent event) {
- int firstLine;
- int textChangeY;
- boolean isMultiLineChange = event.replaceLineCount > 0 || event.newLineCount > 0;
-
- if (event.replaceCharCount < 0) {
- event.start += event.replaceCharCount;
- event.replaceCharCount *= -1;
- }
- lastTextChangeStart = event.start;
- lastTextChangeNewLineCount = event.newLineCount;
- lastTextChangeNewCharCount = event.newCharCount;
- lastTextChangeReplaceLineCount = event.replaceLineCount;
- lastTextChangeReplaceCharCount = event.replaceCharCount;
- firstLine = content.getLineAtOffset(event.start);
- textChangeY = firstLine * lineHeight - verticalScrollOffset + topMargin;
- if (isMultiLineChange) {
- redrawMultiLineChange(textChangeY, event.newLineCount, event.replaceLineCount);
- }
- // notify default line styler about text change
- if (defaultLineStyler != null) {
- defaultLineStyler.textChanging(event);
- }
-
- // Update the caret offset if it is greater than the length of the content.
- // This is necessary since style range API may be called between the
- // handleTextChanging and handleTextChanged events and this API sets the
- // caretOffset.
- int newEndOfText = content.getCharCount() - event.replaceCharCount + event.newCharCount;
- if (caretOffset > newEndOfText) caretOffset = newEndOfText;
-}
-/**
- * Called when the widget content is set 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();
-}
-/**
- * Called when a traversal key is pressed.
- * Allow tab next traversal to occur when the widget is in single
- * line mode or in multi line and non-editable mode .
- * When in editable multi line mode we want to prevent the tab
- * traversal and receive the tab key event instead.
- * <p>
- *
- * @param event the event
- */
-void handleTraverse(Event event) {
- int style = getStyle();
- boolean ignoreTab = (style & SWT.MULTI) != 0 && !editable || isSingleLine();
-
- if ((event.detail == SWT.TRAVERSE_TAB_NEXT ||
- event.detail == SWT.TRAVERSE_RETURN) && ignoreTab) {
- event.doit = true;
- }
-}
-/**
- * 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 initializeRenderer() {
- if (renderer != null) {
- renderer.dispose();
- }
- renderer = new DisplayRenderer(
- getDisplay(), getFont(), isBidi(), leftMargin, this, tabLength);
- lineHeight = renderer.getLineHeight();
- lineEndSpaceWidth = renderer.getLineEndSpaceWidth();
-}
-/**
- * Executes the action.
- * <p>
- *
- * @param action one of the actions defined in ST.java
- */
-public void invokeAction(int action) {
- int oldColumnX;
- int caretLine;
-
- checkWidget();
- switch (action) {
- // Navigation
- case ST.LINE_UP:
- caretLine = doLineUp();
- oldColumnX = columnX;
- // explicitly go to the calculated caret line. may be different
- // from content.getLineAtOffset(caretOffset) when in word wrap mode
- showCaret(caretLine);
- // save the original horizontal caret position
- columnX = oldColumnX;
- clearSelection(true);
- break;
- case ST.LINE_DOWN:
- caretLine = doLineDown();
- oldColumnX = columnX;
- // explicitly go to the calculated caret line. may be different
- // from content.getLineAtOffset(caretOffset) when in word wrap mode
- showCaret(caretLine);
- // save the original horizontal caret position
- columnX = oldColumnX;
- clearSelection(true);
- break;
- case ST.LINE_START:
- doLineStart();
- clearSelection(true);
- break;
- case ST.LINE_END:
- doLineEnd();
- clearSelection(true);
- break;
- case ST.COLUMN_PREVIOUS:
- doCursorPrevious();
- clearSelection(true);
- break;
- case ST.COLUMN_NEXT:
- doCursorNext();
- clearSelection(true);
- break;
- case ST.PAGE_UP:
- doPageUp();
- clearSelection(true);
- break;
- case ST.PAGE_DOWN:
- doPageDown(false);
- clearSelection(true);
- break;
- case ST.WORD_PREVIOUS:
- doWordPrevious();
- clearSelection(true);
- break;
- case ST.WORD_NEXT:
- doWordNext();
- clearSelection(true);
- break;
- case ST.TEXT_START:
- doContentStart();
- clearSelection(true);
- break;
- case ST.TEXT_END:
- doContentEnd();
- clearSelection(true);
- break;
- case ST.WINDOW_START:
- doPageStart();
- clearSelection(true);
- break;
- case ST.WINDOW_END:
- doPageEnd();
- clearSelection(true);
- break;
- // Selection
- case ST.SELECT_LINE_UP:
- doSelectionLineUp();
- break;
- case ST.SELECT_LINE_DOWN:
- doSelectionLineDown();
- break;
- case ST.SELECT_LINE_START:
- doLineStart();
- doSelection(SWT.LEFT);
- break;
- case ST.SELECT_LINE_END:
- doLineEnd();
- doSelection(SWT.RIGHT);
- break;
- case ST.SELECT_COLUMN_PREVIOUS:
- doSelectionCursorPrevious();
- doSelection(SWT.LEFT);
- break;
- case ST.SELECT_COLUMN_NEXT:
- doSelectionCursorNext();
- doSelection(SWT.RIGHT);
- break;
- case ST.SELECT_PAGE_UP:
- doSelectionPageUp();
- doSelection(SWT.LEFT);
- break;
- case ST.SELECT_PAGE_DOWN:
- doSelectionPageDown();
- break;
- case ST.SELECT_WORD_PREVIOUS:
- doSelectionWordPrevious();
- doSelection(SWT.LEFT);
- break;
- case ST.SELECT_WORD_NEXT:
- doSelectionWordNext();
- 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();
- break;
- case ST.DELETE_NEXT:
- doDelete();
- break;
- case ST.DELETE_WORD_PREVIOUS:
- doDeleteWordPrevious();
- break;
- case ST.DELETE_WORD_NEXT:
- doDeleteWordNext();
- break;
- // Miscellaneous
- case ST.TOGGLE_OVERWRITE:
- overwrite = !overwrite; // toggle insert/overwrite mode
- break;
- }
-}
-/**
- * Temporary until SWT provides this
- */
-boolean isBidi() {
- return isBidi;
-}
-/**
- * Returns whether the given offset is inside a multi byte line delimiter.
- * Example:
- * "Line1\r\n" isLineDelimiter(5) == false but isLineDelimiter(6) == true
- *
- * @return true if the given offset is inside a multi byte line delimiter.
- * false if the given offset is before or after a line delimiter.
- */
-boolean isLineDelimiter(int offset) {
- int line = content.getLineAtOffset(offset);
- int lineOffset = content.getOffsetAtLine(line);
- int offsetInLine = offset - lineOffset;
- // offsetInLine will be greater than line length if the line
- // delimiter is longer than one character and the offset is set
- // in between parts of the line delimiter.
- return offsetInLine > content.getLine(line).length();
-}
-/**
- * Returns whether or not the given lines are visible.
- * <p>
- *
- * @return true if any of the lines is visible
- * false if none of the lines is visible
- */
-boolean isAreaVisible(int firstLine, int lastLine) {
- int partialBottomIndex = getPartialBottomIndex();
- int partialTopIndex = verticalScrollOffset / lineHeight;
- boolean notVisible = firstLine > partialBottomIndex || lastLine < partialTopIndex;
- return !notVisible;
-}
-/**
- * Returns whether or not the given styles will necessitate a redraw for the given start line.
- * A redraw is necessary when font style changes after the start of a style will take place.
- * This method assumes ranges is in order and non-overlapping.
- * <p>
- *
- * @return true if a redraw of the given line is necessary, false otherwise
- */
-boolean isRedrawFirstLine(StyleRange[] ranges, int firstLine, int firstLineOffset) {
- int lineEnd = firstLineOffset + content.getLine(firstLine).length();
- for (int i=0; i<ranges.length; i++) {
- StyleRange range = ranges[i];
- // does the style start on the first line?
- if (range.start < lineEnd) {
- int rangeEnd = range.start + range.length;
- if (isStyleChanging(range, range.start, Math.min(rangeEnd, lineEnd))) return true;
- } else {
- return false;
- }
- }
- return false;
-}
-/**
- * Returns whether or not the given styles will necessitate a redraw for the given end line.
- * A redraw is necessary when font style changes after the start of a style will take place.
- * This method assumes ranges is in order and non-overlapping.
- * <p>
- *
- * @return true if a redraw of the last line is necessary, false otherwise
- */
-boolean isRedrawLastLine(StyleRange[] ranges, int lastLine, int lastLineOffset) {
- for (int i = ranges.length - 1; i >= 0; i--) {
- StyleRange range = ranges[i];
- int rangeEnd = range.start + range.length;
- // does style range end on the last line?
- if (rangeEnd >= lastLineOffset) {
- if (isStyleChanging(range, Math.max(range.start, lastLineOffset), rangeEnd)) return true;
- } else {
- break;
- }
- }
- return false;
-}
-/**
- * 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;
-}
-/**
- * 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();
- StyleRange[] styles = defaultLineStyler.getStyleRangesFor(start, end - start);
-
- if (styles == null) {
- return (range.fontStyle != SWT.NORMAL);
- }
- for (int i = 0; i < styles.length; i++) {
- StyleRange newStyle = styles[i];
- if (newStyle.fontStyle != range.fontStyle) {
- 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;
- boolean isCharacterRemove = replacedLength == 1 && event.text.length() == 0;
- boolean isBackspace = event.start < caretOffset;
- boolean isDirectionBoundary = false;
-
- if (updateCaret && isBidi() && isCharacterRemove) {
- // set the keyboard language to the language of the deleted character.
- // determine direction boundary so that caret location can be updated
- // properly.
- int line = content.getLineAtOffset(caretOffset);
- int lineStartOffset = content.getOffsetAtLine(line);
- int offsetInLine = caretOffset - lineStartOffset;
- String lineText = content.getLine(line);
- GC gc = getGC();
- StyledTextBidi bidi = new StyledTextBidi(gc, lineText, getBidiSegments(lineStartOffset, lineText));
- if (isBackspace) {
- if (offsetInLine > 0) {
- // the line start/end does not represent a direction boundary
- // even if the previous/next line has a different direction.
- isDirectionBoundary =
- offsetInLine < lineText.length() &&
- (bidi.isRightToLeft(offsetInLine) != bidi.isRightToLeft(offsetInLine - 1) ||
- bidi.isLocalNumber(offsetInLine) != bidi.isLocalNumber(offsetInLine - 1));
- bidi.setKeyboardLanguage(offsetInLine - 1);
- }
- }
- else {
- if (offsetInLine < lineText.length()) {
- // the line start/end does not represent a direction boundary
- // even if the previous/next line has a different direction.
- isDirectionBoundary =
- offsetInLine > 0 &&
- (bidi.isRightToLeft(offsetInLine) != bidi.isRightToLeft(offsetInLine - 1) ||
- bidi.isLocalNumber(offsetInLine) != bidi.isLocalNumber(offsetInLine - 1));
- bidi.setKeyboardLanguage(offsetInLine);
- }
- }
- gc.dispose();
- }
- if (isListening(ExtendedModify)) {
- styledTextEvent = new StyledTextEvent(logicalContent);
- 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) {
- // always update the caret location. fixes 1G8FODP
- internalSetSelection(event.start + event.text.length(), 0, true);
- if (isBidi()) {
- // Update the caret direction so that the caret moves to the
- // typed/deleted character. Fixes 1GJLQ16.
- if (isCharacterRemove) {
- updateBidiDirection(isBackspace, isDirectionBoundary);
- }
- else {
- lastCaretDirection = ST.COLUMN_NEXT;
- }
- showBidiCaret();
- }
- else {
- showCaret();
- }
- }
- notifyListeners(SWT.Modify, event);
- if (isListening(ExtendedModify)) {
- notifyListeners(ExtendedModify, styledTextEvent);
- }
- }
-}
-/**
- * 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);
- }
-}
-/**
- * Render the specified area. Broken out as its own method to support
- * direct drawing.
- * <p>
- *
- * @param gc GC to render on
- * @param startLine first line to render
- * @param startY y pixel location to start rendering at
- * @param renderHeight renderHeight widget area that needs to be filled with lines
- */
-void performPaint(GC gc,int startLine,int startY, int renderHeight) {
- Rectangle clientArea = getClientArea();
- Color background = getBackground();
-
- // Check if there is work to do. We never want to try and create
- // an Image with 0 width or 0 height.
- if (clientArea.width == 0) {
- return;
- }
- if (renderHeight > 0) {
- // renderHeight will be negative when only top margin needs redrawing
- Color foreground = getForeground();
- int lineCount = content.getLineCount();
- int paintY = 0;
-
- if (isSingleLine()) {
- lineCount = 1;
- if (startLine > 1) {
- startLine = 1;
- }
- }
- Image lineBuffer = new Image(getDisplay(), clientArea.width, renderHeight);
- GC lineGC = new GC(lineBuffer);
-
- lineGC.setFont(getFont());
- renderer.setCurrentFontStyle(SWT.NORMAL);
- lineGC.setForeground(foreground);
- lineGC.setBackground(background);
-
- for (int i = startLine; paintY < renderHeight && i < lineCount; i++, paintY += lineHeight) {
- String line = content.getLine(i);
- renderer.drawLine(line, i, paintY, lineGC, background, foreground, true);
- }
- if (paintY < renderHeight) {
- lineGC.setBackground(background);
- lineGC.setForeground(background);
- lineGC.fillRectangle(0, paintY, clientArea.width, renderHeight - paintY);
- }
- gc.drawImage(lineBuffer, 0, startY);
- lineGC.dispose();
- lineBuffer.dispose();
- }
- clearMargin(gc, background, clientArea, renderHeight);
-}
-/**
- * Prints the widget's text to the default printer.
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public void print() {
- checkWidget();
- Printer printer = new Printer();
- StyledTextPrintOptions options = new StyledTextPrintOptions();
-
- options.printTextForeground = true;
- options.printTextBackground = true;
- options.printTextFontStyle = true;
- options.printLineBackground = true;
- new Printing(this, printer, options).run();
- printer.dispose();
-}
-/**
- * Returns a runnable that will print the widget's text
- * to the specified printer.
- * <p>
- * The runnable may be run in a non-UI thread.
- * </p>
- *
- * @param printer the printer to print to
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT when printer is null</li>
- * </ul>
- */
-public Runnable print(Printer printer) {
- StyledTextPrintOptions options = new StyledTextPrintOptions();
-
- checkWidget();
- options.printTextForeground = true;
- options.printTextBackground = true;
- options.printTextFontStyle = true;
- options.printLineBackground = true;
- if (printer == null) {
- SWT.error(SWT.ERROR_NULL_ARGUMENT);
- }
- return print(printer, options);
-}
-/**
- * Returns a runnable that will print the widget's text
- * to the specified printer.
- * <p>
- * The runnable may be run in a non-UI thread.
- * </p>
- *
- * @param printer the printer to print to
- * @param options print options to use during printing
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT when printer or options is null</li>
- * </ul>
- * @since 2.1
- */
-public Runnable print(Printer printer, StyledTextPrintOptions options) {
- checkWidget();
- if (printer == null || options == null) {
- SWT.error(SWT.ERROR_NULL_ARGUMENT);
- }
- return new Printing(this, printer, options);
-}
-/**
- * Causes the entire bounds of the receiver to be marked
- * as needing to be redrawn. The next time a paint request
- * is processed, the control will be completely painted.
- * <p>
- * Recalculates the content width for all lines in the bounds.
- * When a <code>LineStyleListener</code> is used a redraw call
- * is the only notification to the widget that styles have changed
- * and that the content width may have changed.
- * </p>
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see Control#update
- */
-public void redraw() {
- int itemCount;
-
- super.redraw();
- itemCount = getPartialBottomIndex() - topIndex + 1;
- lineCache.redrawReset(topIndex, itemCount, true);
- lineCache.calculate(topIndex, itemCount);
- setHorizontalScrollBar();
-}
-/**
- * Causes the rectangular area of the receiver specified by
- * the arguments to be marked as needing to be redrawn.
- * The next time a paint request is processed, that area of
- * the receiver will be painted. If the <code>all</code> flag
- * is <code>true</code>, any children of the receiver which
- * intersect with the specified area will also paint their
- * intersecting areas. If the <code>all</code> flag is
- * <code>false</code>, the children will not be painted.
- * <p>
- * Marks the content width of all lines in the specified rectangle
- * as unknown. Recalculates the content width of all visible lines.
- * When a <code>LineStyleListener</code> is used a redraw call
- * is the only notification to the widget that styles have changed
- * and that the content width may have changed.
- * </p>
- *
- * @param x the x coordinate of the area to draw
- * @param y the y coordinate of the area to draw
- * @param width the width of the area to draw
- * @param height the height of the area to draw
- * @param all <code>true</code> if children should redraw, and <code>false</code> otherwise
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see Control#update
- */
-public void redraw(int x, int y, int width, int height, boolean all) {
- super.redraw(x, y, width, height, all);
- if (height > 0) {
- int lineCount = content.getLineCount();
- int startLine = (getTopPixel() + y) / lineHeight;
- int endLine = startLine + Compatibility.ceil(height, lineHeight);
- int itemCount;
-
- // reset all lines in the redraw rectangle
- startLine = Math.min(startLine, lineCount);
- itemCount = Math.min(endLine, lineCount) - startLine;
- lineCache.reset(startLine, itemCount, true);
- // only calculate the visible lines
- itemCount = getPartialBottomIndex() - topIndex + 1;
- lineCache.calculate(topIndex, itemCount);
- setHorizontalScrollBar();
- }
-}
-/**
- * Redraws a text range in the specified lines
- * <p>
- *
- * @param firstLine first line to redraw at the specified offset
- * @param offsetInFirstLine offset in firstLine to start redrawing
- * @param lastLine last line to redraw
- * @param endOffset offset in the last where redrawing should stop
- * @param clearBackground true=clear the background by invalidating
- * the requested redraw range, false=draw the foreground directly
- * without invalidating the redraw range.
- */
-void redrawBidiLines(int firstLine, int offsetInFirstLine, int lastLine, int endOffset, boolean clearBackground) {
- int lineCount = lastLine - firstLine + 1;
- int redrawY = firstLine * lineHeight - verticalScrollOffset;
- int firstLineOffset = content.getOffsetAtLine(firstLine);
- String line = content.getLine(firstLine);
- GC gc = getGC();
- StyledTextBidi bidi = getStyledTextBidi(line, firstLineOffset, gc);
-
- bidi.redrawRange(
- this, offsetInFirstLine,
- Math.min(line.length(), endOffset) - offsetInFirstLine,
- leftMargin - horizontalScrollOffset, redrawY + topMargin, lineHeight);
- // redraw line break marker (either space or full client area width)
- // if redraw range extends over more than one line and background should be redrawn
- if (lastLine > firstLine && clearBackground) {
- int lineBreakWidth;
- int lineBreakStartX = bidi.getTextWidth();
- // handle empty line case
- if (lineBreakStartX == leftMargin) {
- lineBreakStartX += XINSET;
- }
- lineBreakStartX = lineBreakStartX - horizontalScrollOffset;
- if ((getStyle() & SWT.FULL_SELECTION) != 0) {
- lineBreakWidth = getClientArea().width - lineBreakStartX;
- }
- else {
- lineBreakWidth = lineEndSpaceWidth;
- }
- draw(lineBreakStartX, redrawY, lineBreakWidth, lineHeight, clearBackground);
- }
- // redraw last line if more than one line needs redrawing
- if (lineCount > 1) {
- int lastLineOffset = content.getOffsetAtLine(lastLine);
- int offsetInLastLine = endOffset - lastLineOffset;
- // no redraw necessary if redraw offset is 0
- if (offsetInLastLine > 0) {
- line = content.getLine(lastLine);
- redrawY = lastLine * lineHeight - verticalScrollOffset;
- bidi = getStyledTextBidi(line, lastLineOffset, gc);
- bidi.redrawRange(
- this, 0, offsetInLastLine,
- leftMargin - horizontalScrollOffset,
- redrawY + topMargin, lineHeight);
- }
- }
- gc.dispose();
-}
-/**
- * Redraw the given line.
- * <p>
- *
- * @param line index of the line to redraw
- * @param offset offset in line to start redrawing
- */
-void redrawLine(int line, int offset) {
- int redrawX = 0;
- if (offset > 0) {
- String lineText = content.getLine(line);
- redrawX = getXAtOffset(lineText, line, offset);
- }
- int redrawY = line * lineHeight - verticalScrollOffset;
- super.redraw(
- redrawX + leftMargin, redrawY + topMargin,
- getClientArea().width, lineHeight, true);
-}
-/**
- * Redraws a text range in the specified lines
- * <p>
- *
- * @param firstLine first line to redraw at the specified offset
- * @param offsetInFirstLine offset in firstLine to start redrawing
- * @param lastLine last line to redraw
- * @param endOffset offset in the last where redrawing should stop
- * @param clearBackground true=clear the background by invalidating
- * the requested redraw range. If the redraw range includes the
- * last character of a line (i.e., the entire line is redrawn) the
- * line is cleared all the way to the right border of the widget.
- * false=draw the foreground directly without invalidating the
- * redraw range.
- */
-void redrawLines(int firstLine, int offsetInFirstLine, int lastLine, int endOffset, boolean clearBackground) {
- String line = content.getLine(firstLine);
- int lineCount = lastLine - firstLine + 1;
- int redrawX = getXAtOffset(line, firstLine, offsetInFirstLine) - leftMargin;
- int redrawStopX;
- int redrawY = firstLine * lineHeight - verticalScrollOffset;
- int firstLineOffset = content.getOffsetAtLine(firstLine);
- boolean fullLineRedraw = ((getStyle() & SWT.FULL_SELECTION) != 0 && lastLine > firstLine);
-
- // if redraw range includes last character on the first line,
- // clear background to right widget border. fixes bug 19595.
- if (clearBackground && endOffset - firstLineOffset >= line.length()) {
- fullLineRedraw = true;
- }
- // calculate redraw stop location
- if (fullLineRedraw) {
- redrawStopX = getClientArea().width - leftMargin;
- }
- else {
- redrawStopX = getXAtOffset(line, firstLine, endOffset - firstLineOffset) - leftMargin;
- }
- draw(redrawX, redrawY, redrawStopX - redrawX, lineHeight, clearBackground);
- // redraw last line if more than one line needs redrawing
- if (lineCount > 1) {
- int offsetInLastLine = endOffset - content.getOffsetAtLine(lastLine);
- // no redraw necessary if redraw offset is 0
- if (offsetInLastLine > 0) {
- line = content.getLine(lastLine);
- // if redraw range includes last character on the last line,
- // clear background to right widget border. fixes bug 19595.
- if (clearBackground && offsetInLastLine >= line.length()) {
- fullLineRedraw = true;
- }
- if (fullLineRedraw) {
- redrawStopX = getClientArea().width - leftMargin;
- }
- else {
- redrawStopX = getXAtOffset(line, lastLine, offsetInLastLine) - leftMargin;
- }
- redrawY = lastLine * lineHeight - verticalScrollOffset;
- draw(0, redrawY, redrawStopX, lineHeight, clearBackground);
- }
- }
-}
-/**
- * Fixes the widget to display a text change.
- * Bit blitting and redrawing is done as necessary.
- * <p>
- *
- * @param y y location of the text change
- * @param newLineCount number of new lines.
- * @param replacedLineCount number of replaced lines.
- */
-void redrawMultiLineChange(int y, int newLineCount, int replacedLineCount) {
- Rectangle clientArea = getClientArea();
- int lineCount = newLineCount - replacedLineCount;
- int sourceY;
- int destinationY;
-
- if (lineCount > 0) {
- sourceY = Math.max(0, y + lineHeight);
- destinationY = sourceY + lineCount * lineHeight;
- }
- else {
- destinationY = Math.max(0, y + lineHeight);
- sourceY = destinationY - lineCount * 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.
- if (y + lineHeight > 0 && y <= clientArea.height) {
- // redraw first changed line in case a line was split/joined
- super.redraw(0, y, clientArea.width, lineHeight, true);
- }
- if (newLineCount > 0) {
- int redrawStartY = y + lineHeight;
- int redrawHeight = newLineCount * lineHeight;
-
- if (redrawStartY + redrawHeight > 0 && redrawStartY <= clientArea.height) {
- // display new text
- super.redraw(0, redrawStartY, clientArea.width, redrawHeight, true);
- }
- }
-}
-/**
- * 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 range will
- * be cleared before anything is redrawn. If the redraw range includes
- * the last character of a line (i.e., the entire line is redrawn) the
- * line is cleared all the way to the right border of the widget.
- * The redraw operation will be faster and smoother if clearBackground
- * is set to false. Whether or not the flag can be set to false depends
- * on the type of change that has taken place. If font styles or
- * background colors for the redraw range have changed, clearBackground
- * should be set to true. If only foreground colors have changed for
- * the redraw range, clearBackground can be set to false.
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_INVALID_RANGE when start and/or end are outside the widget content</li>
- * </ul>
- */
-public void redrawRange(int start, int length, boolean clearBackground) {
- checkWidget();
- int end = start + length;
- int contentLength = content.getCharCount();
- int firstLine;
- int lastLine;
-
- if (start > end || start < 0 || end > contentLength) {
- SWT.error(SWT.ERROR_INVALID_RANGE);
- }
- firstLine = content.getLineAtOffset(start);
- lastLine = content.getLineAtOffset(end);
- // reset all affected lines but let the redraw recalculate only
- // those that are visible.
- lineCache.reset(firstLine, lastLine - firstLine + 1, true);
- internalRedrawRange(start, length, clearBackground);
-}
-/**
- * Removes the specified bidirectional segment 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>
- * @since 2.0
- */
-public void removeBidiSegmentListener(BidiSegmentListener listener) {
- checkWidget();
- if (listener == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
- removeListener(LineGetSegments, listener);
-}
-/**
- * Removes the specified extended modify listener.
- * <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 styles in the given range with new styles. This method
- * effectively deletes the styles in the given range and then adds the
- * the new styles.
- * <p>
- * Should not be called if a LineStyleListener has been set since the
- * listener maintains the styles.
- * </p>
- *
- * @param start offset of first character where styles will be deleted
- * @param length length of the range to delete styles in
- * @param ranges StyleRange objects containing the new style information.
- * The ranges should not overlap and should be within the specified start
- * and length. The style rendering is undefined if the ranges do overlap
- * or are ill-defined. Must not be null.
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_INVALID_RANGE when either start or end is outside the valid range (0 <= offset <= getCharCount())</li>
- * <li>ERROR_NULL_ARGUMENT when string is null</li>
- * </ul>
- * @since 2.0
- */
-public void replaceStyleRanges(int start, int length, StyleRange[] ranges) {
- checkWidget();
- if (userLineStyle) {
- return;
- }
- if (ranges == null) {
- SWT.error(SWT.ERROR_NULL_ARGUMENT);
- }
- if (ranges.length == 0) {
- setStyleRange(new StyleRange(start, length, null, null));
- return;
- }
- int end = start + length;
- if (start > end || start < 0 || end > getCharCount()) {
- SWT.error(SWT.ERROR_INVALID_RANGE);
- }
-
- int firstLine = content.getLineAtOffset(start);
- int lastLine = content.getLineAtOffset(end);
-
- // if the area is not visible, there is no need to redraw
- boolean redrawLines = isAreaVisible(firstLine, lastLine);
-
- if (!redrawLines) {
- defaultLineStyler.replaceStyleRanges(start, length, ranges);
- lineCache.reset(firstLine, lastLine - firstLine + 1, true);
- } else {
- boolean redrawFirstLine = false;
- boolean redrawLastLine = false;
- // 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 firstLineOffset = content.getOffsetAtLine(firstLine);
- if (isBidi()) {
- redrawFirstLine = true;
- redrawLastLine = true;
- } else {
- int firstLineEnd = firstLineOffset + content.getLine(firstLine).length();
- redrawFirstLine = isRedrawFirstLine(ranges, firstLine, firstLineOffset);
- // check if any bold styles will be cleared
- StyleRange clearRange = new StyleRange(firstLineOffset, firstLineEnd - firstLineOffset, null, null);
- redrawFirstLine = redrawFirstLine || isRedrawFirstLine(new StyleRange[] {clearRange}, firstLine, firstLineOffset);
- if (lastLine != firstLine) {
- int lastLineOffset = content.getOffsetAtLine(lastLine);
- int lastLineEnd = lastLineOffset + content.getLine(lastLine).length();
- redrawLastLine = isRedrawLastLine(ranges, lastLine, lastLineOffset);
- // check if any bold styles will be cleared
- clearRange = new StyleRange(lastLineOffset, lastLineEnd - lastLineOffset, null, null);
- redrawLastLine = redrawLastLine || isRedrawLastLine(new StyleRange[] {clearRange}, lastLine, lastLineOffset);
- }
- }
- defaultLineStyler.replaceStyleRanges(start, length, ranges);
- // reset all lines affected by the style change but let the redraw
- // recalculate only those that are visible.
- lineCache.reset(firstLine, lastLine - firstLine + 1, true);
- internalRedrawRange(start, length, true);
- if (redrawFirstLine) {
- redrawLine(firstLine, start - firstLineOffset);
- }
- if (redrawLastLine) {
- redrawLine(lastLine, 0);
- }
- }
-
- // make sure that the caret is positioned correctly.
- // caret location may change if font style changes.
- // fixes 1G8FODP
- setCaretLocation();
-}
-/**
- * Replaces the given text range with new text.
- * If the widget has the SWT.SINGLE style and "text" contains more than
- * one line, only the first line is rendered but the text is stored
- * unchanged. A subsequent call to getText will return the same text
- * that was set. Note that only a single line of text should be set when
- * the SWT.SINGLE style is used.
- * <p>
- * <b>NOTE:</b> During the replace operation the current selection is
- * changed as follows:
- * <ul>
- * <li>selection before replaced text: selection unchanged
- * <li>selection after replaced text: adjust the selection so that same text
- * remains selected
- * <li>selection intersects replaced text: selection is cleared and caret
- * is placed after inserted text
- * </ul>
- * </p>
- *
- * @param start offset of first character to replace
- * @param length number of characters to replace. Use 0 to insert text
- * @param text new text. May be empty to delete text.
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_INVALID_RANGE when either start or end is outside the valid range (0 <= offset <= getCharCount())</li>
- * <li>ERROR_INVALID_ARGUMENT when either start or end is inside a multi byte line delimiter.
- * Splitting a line delimiter for example by inserting text in between the CR and LF and deleting part of a line delimiter is not supported</li>
- * <li>ERROR_NULL_ARGUMENT when string is null</li>
- * </ul>
- */
-public void replaceTextRange(int start, int length, String text) {
- checkWidget();
- int contentLength = getCharCount();
- int end = start + length;
- Event event = new Event();
-
- if (start > end || start < 0 || end > contentLength) {
- SWT.error(SWT.ERROR_INVALID_RANGE);
- }
- if (text == null) {
- SWT.error(SWT.ERROR_NULL_ARGUMENT);
- }
- 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;
- topOffset = 0;
- verticalScrollOffset = 0;
- horizontalScrollOffset = 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();
- super.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();
- if (pixels > 0) {
- int sourceX = leftMargin + pixels;
- int scrollWidth = clientArea.width - sourceX - rightMargin;
- int scrollHeight = clientArea.height - topMargin - bottomMargin;
- scroll(
- leftMargin, topMargin, // destination x, y
- sourceX, topMargin, // source x, y
- scrollWidth, scrollHeight, true);
- if (sourceX > scrollWidth) {
- // redraw from end of scrolled area to beginning of scroll
- // invalidated area
- super.redraw(
- leftMargin + scrollWidth, topMargin,
- pixels - scrollWidth, scrollHeight, true);
- }
- }
- else {
- int destinationX = leftMargin - pixels;
- int scrollWidth = clientArea.width - destinationX - rightMargin;
- int scrollHeight = clientArea.height - topMargin - bottomMargin;
- scroll(
- destinationX, topMargin, // destination x, y
- leftMargin, topMargin, // source x, y
- scrollWidth, scrollHeight, true);
- if (destinationX > scrollWidth) {
- // redraw from end of scroll invalidated area to scroll
- // destination
- super.redraw(
- leftMargin + scrollWidth, topMargin,
- -pixels - scrollWidth, scrollHeight, 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
- * @return
- * true=the widget was scrolled
- * false=the widget was not scrolled, the given offset is not valid.
- */
-boolean scrollHorizontalBar(int pixels) {
- if (pixels == 0) {
- return false;
- }
- ScrollBar horizontalBar = getHorizontalBar();
- if (horizontalBar != null) {
- horizontalBar.setSelection(horizontalScrollOffset + pixels);
- }
- scrollHorizontal(pixels);
- return true;
-}
-/**
- * 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);
-}
-/**
- * Sets whether the widget wraps lines.
- * This overrides the creation style bit SWT.WRAP.
- * <p>
- *
- * @param wrap true=widget wraps lines, false=widget does not wrap lines
- * @since 2.0
- */
-public void setWordWrap(boolean wrap) {
- checkWidget();
-
- if (wrap != wordWrap) {
- ScrollBar horizontalBar = getHorizontalBar();
-
- wordWrap = wrap;
- if (wordWrap) {
- logicalContent = content;
- content = new WrappedContent(renderer, logicalContent);
- }
- else {
- content = logicalContent;
- }
- calculateContentWidth();
- horizontalScrollOffset = 0;
- if (horizontalBar != null) {
- horizontalBar.setVisible(!wordWrap);
- }
- setScrollBars();
- setCaretLocation();
- super.redraw();
- }
-}
-/**
- * Sets the caret location and scrolls the caret offset into view.
- */
-void showBidiCaret() {
- int line = content.getLineAtOffset(caretOffset);
- int lineOffset = content.getOffsetAtLine(line);
- int offsetInLine = caretOffset - lineOffset;
- String lineText = content.getLine(line);
- int xAtOffset = 0;
- boolean scrolled = false;
- GC gc = getGC();
- StyledTextBidi bidi = getStyledTextBidi(lineText, lineOffset, gc);
- // getXAtOffset, inlined for better performance
- xAtOffset = getBidiTextPosition(lineText, offsetInLine, bidi) + leftMargin;
- if (offsetInLine > lineText.length()) {
- // offset is not on the line. return an x location one character
- // after the line to indicate the line delimiter.
- xAtOffset += lineEndSpaceWidth;
- }
- xAtOffset -= horizontalScrollOffset;
- //
- scrolled = showLocation(xAtOffset, line);
- if (scrolled == false) {
- setBidiCaretLocation(bidi);
- }
- gc.dispose();
-}
-/**
- * Sets the receiver's caret. Set the caret's height and location.
- *
- * </p>
- * @param caret the new caret for the receiver
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public void setCaret(Caret caret) {
- checkWidget ();
- super.setCaret(caret);
- if (caret != null) {
- if (isBidi() == false) {
- caret.setSize(caret.getSize().x, lineHeight);
- }
- setCaretLocation();
- if (isBidi()) {
- setBidiKeyboardLanguage();
- }
- }
-}
-/**
- * @see org.eclipse.swt.widgets.Control#setBackground
- */
-public void setBackground(Color color) {
- checkWidget();
- super.setBackground(color);
- background = color;
- redraw();
-}
-/**
- * Set the caret to indicate the current typing direction.
- */
-void setBidiCaretDirection() {
- Caret caret = getCaret();
- int direction = StyledTextBidi.getKeyboardLanguageDirection();
-
- if (caret == null || direction == caretDirection) {
- return;
- }
- caretDirection = direction;
- if (direction == SWT.DEFAULT) {
- caret.setImage(null);
- caret.setSize(caret.getSize().x, lineHeight);
- }
- else
- if (caretDirection == SWT.LEFT) {
- caret.setImage(leftCaretBitmap);
- }
- else
- if (caretDirection == SWT.RIGHT) {
- caret.setImage(rightCaretBitmap);
- }
-}
-/**
- * Moves the Caret to the current caret offset.
- * <p>
- *
- * @param bidi StyledTextBidi object to use for measuring.
- * May be left null in which case a new object will be created.
- */
-void setBidiCaretLocation(StyledTextBidi bidi) {
- int caretLine = getCaretLine();
-
- setBidiCaretLocation(bidi, caretLine);
-}
-/**
- * Moves the Caret to the current caret offset.
- * <p>
- *
- * @param bidi StyledTextBidi object to use for measuring.
- * May be left null in which case a new object will be created.
- * @param caretLine line the caret should be placed on. Relative to
- * first line in document
- */
-void setBidiCaretLocation(StyledTextBidi bidi, int caretLine) {
- Caret caret = getCaret();
- String lineText = content.getLine(caretLine);
- int lineStartOffset = content.getOffsetAtLine(caretLine);
- int offsetInLine = caretOffset - lineStartOffset;
- GC gc = null;
-
- if (bidi == null) {
- gc = getGC();
- bidi = getStyledTextBidi(lineText, lineStartOffset, gc);
- }
- if (lastCaretDirection == SWT.NULL) {
- columnX = bidi.getTextPosition(offsetInLine) + leftMargin - horizontalScrollOffset;
- } else {
- columnX = bidi.getTextPosition(offsetInLine, lastCaretDirection) + leftMargin - horizontalScrollOffset;
- }
- if (StyledTextBidi.getKeyboardLanguageDirection() == SWT.RIGHT) {
- columnX -= (getCaretWidth() - 1);
- }
- if (caret != null) {
- setBidiCaretDirection();
- caret.setLocation(
- columnX,
- caretLine * lineHeight - verticalScrollOffset + topMargin);
- }
- if (gc != null) {
- gc.dispose();
- }
-}
-/**
- * Sets the BIDI coloring mode. When true the BIDI text display
- * algorithm is applied to segments of text that are the same
- * color.
- *
- * @param mode the new coloring mode
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- * <p>
- * @deprecated use BidiSegmentListener instead.
- * </p>
- */
-public void setBidiColoring(boolean mode) {
- checkWidget();
- bidiColoring = mode;
-}
-/**
- * Switches the keyboard language according to the current editing
- * position and cursor direction.
- */
-void setBidiKeyboardLanguage() {
- int caretLine = getCaretLine();
- int lineStartOffset = content.getOffsetAtLine(caretLine);
- int offsetInLine = caretOffset - lineStartOffset;
- String lineText = content.getLine(caretLine);
- GC gc = getGC();
- StyledTextBidi bidi;
- int lineLength = lineText.length();
-
- // Don't supply the bold styles/font since we don't want to measure anything
- bidi = new StyledTextBidi(gc, lineText, getBidiSegments(lineStartOffset, lineText));
- if (offsetInLine == 0) {
- bidi.setKeyboardLanguage(offsetInLine);
- }
- else
- if (offsetInLine >= lineLength) {
- offsetInLine = Math.min(offsetInLine, lineLength - 1);
- bidi.setKeyboardLanguage(offsetInLine);
- }
- else
- if (lastCaretDirection == ST.COLUMN_NEXT) {
- // continue with previous character type
- bidi.setKeyboardLanguage(offsetInLine - 1);
- }
- else {
- bidi.setKeyboardLanguage(offsetInLine);
- }
- gc.dispose();
-}
-/**
- * Moves the Caret to the current caret offset.
- * <p>
- *
- * @param newCaretX the new x location of the caret.
- * passed in for better performance when it has already been
- * calculated outside this method.
- * @param line index of the line the caret is on. Relative to
- * the first line in the document.
- */
-void setCaretLocation(int newCaretX, int line) {
- if (isBidi()) {
- setBidiCaretLocation(null, line);
- }
- else {
- Caret caret = getCaret();
-
- columnX = newCaretX;
- if (caret != null) {
- caret.setLocation(
- newCaretX,
- line * lineHeight - verticalScrollOffset + topMargin);
- }
- }
-}
-/**
- * Moves the Caret to the current caret offset.
- */
-void setCaretLocation() {
- if (isBidi()) {
- setBidiCaretLocation(null);
- }
- else {
- Caret caret = getCaret();
- int caretLine = getCaretLine();
- int lineStartOffset = content.getOffsetAtLine(caretLine);
-
- columnX = getXAtOffset(
- content.getLine(caretLine), caretLine, caretOffset - lineStartOffset);
- if (caret != null) {
- caret.setLocation(
- columnX,
- caretLine * lineHeight - verticalScrollOffset + topMargin);
- }
- }
-}
-/**
- * Sets the caret offset.
- *
- * @param offset caret offset, relative to the first character in the text.
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_INVALID_ARGUMENT when either the start or the end of the selection range is inside a
- * multi byte line delimiter (and thus neither clearly in front of or after the line delimiter)
- * </ul>
- */
-public void setCaretOffset(int offset) {
- checkWidget();
- int length = getCharCount();
-
- if (length > 0 && offset != caretOffset) {
- if (offset < 0) {
- caretOffset = 0;
- }
- else
- if (offset > length) {
- caretOffset = length;
- }
- else {
- if (isLineDelimiter(offset)) {
- // offset is inside a multi byte line delimiter. This is an
- // illegal operation and an exception is thrown. Fixes 1GDKK3R
- SWT.error(SWT.ERROR_INVALID_ARGUMENT);
- }
- caretOffset = offset;
- }
- // 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();
- if (isBidi()) {
- setBidiKeyboardLanguage();
- }
-}
-/**
- * Copies the specified text range to the clipboard. The text will be placed
- * in the clipboard in plain text format and RTF format.
- * <p>
- *
- * @param start start index of the text
- * @param length length of text to place in clipboard
- *
- * @exception SWTError, see Clipboard.setContents
- * @see org.eclipse.swt.dnd.Clipboard.setContents
- */
-void setClipboardContent(int start, int length) throws SWTError {
- RTFTransfer rtfTransfer = RTFTransfer.getInstance();
- TextTransfer plainTextTransfer = TextTransfer.getInstance();
- RTFWriter rtfWriter = new RTFWriter(start, length);
- TextWriter plainTextWriter = new TextWriter(start, length);
- String rtfText = getPlatformDelimitedText(rtfWriter);
- String plainText = getPlatformDelimitedText(plainTextWriter);
-
- clipboard.setContents(
- new String[]{rtfText, plainText},
- new Transfer[]{rtfTransfer, plainTextTransfer});
-}
-/**
- * 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 newContent) {
- checkWidget();
- if (newContent == null) {
- SWT.error(SWT.ERROR_NULL_ARGUMENT);
- }
- if (content != null) {
- content.removeTextChangeListener(textChangeListener);
- }
- logicalContent = newContent;
- if (wordWrap) {
- content = new WrappedContent(renderer, logicalContent);
- }
- else {
- content = logicalContent;
- }
- content.addTextChangeListener(textChangeListener);
- reset();
-}
-/**
- * Sets the receiver's cursor to the cursor specified by the
- * argument. Overridden to handle the null case since the
- * StyledText widget uses an ibeam as its default cursor.
- *
- * @see org.eclipse.swt.widgets.Control#setCursor
- */
-public void setCursor (Cursor cursor) {
- if (cursor == null) {
- super.setCursor(ibeamCursor);
- } else {
- super.setCursor(cursor);
- }
-}
-/**
- * Sets whether the widget implements double click mouse behavior.
- * </p>
- *
- * @param enable if true double clicking a word selects the word, if false
- * double clicks have the same effect as regular mouse clicks.
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public void setDoubleClickEnabled(boolean enable) {
- checkWidget();
- doubleClickEnabled = enable;
-}
-/**
- * Sets whether the widget content can be edited.
- * </p>
- *
- * @param editable if true content can be edited, if false content can not be
- * edited
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public void setEditable(boolean editable) {
- checkWidget();
- this.editable = editable;
-}
-/**
- * Sets a new font to render text with.
- * <p>
- * <b>NOTE:</b> Italic fonts are not supported unless they have no overhang
- * and the same baseline as regular fonts.
- * </p>
- *
- * @param font new font
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public void setFont(Font font) {
- checkWidget();
- int oldLineHeight = lineHeight;
-
- super.setFont(font);
- initializeRenderer();
- // keep the same top line visible. fixes 5815
- if (lineHeight != oldLineHeight) {
- setVerticalScrollOffset(verticalScrollOffset * lineHeight / oldLineHeight, true);
- claimBottomFreeSpace();
- }
- calculateContentWidth();
- calculateScrollBars();
- if (isBidi()) {
- caretDirection = SWT.NULL;
- createCaretBitmaps();
- setBidiCaretDirection();
- }
- else {
- Caret caret = getCaret();
- if (caret != null) {
- caret.setSize(caret.getSize().x, lineHeight);
- }
- }
- // always set the caret location. Fixes 6685
- setCaretLocation();
- super.redraw();
-}
-/**
- * @see org.eclipse.swt.widgets.Control#setForeground
- */
-public void setForeground(Color color) {
- checkWidget();
- super.setForeground(color);
- foreground = color;
- 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) {
- int width = lineCache.getWidth();
- // prevent scrolling if the content fits in the client area.
- // align end of longest line with right border of client area
- // if offset is out of range.
- if (offset > width - clientAreaWidth) {
- offset = Math.max(0, width - clientAreaWidth);
- }
- }
- scrollHorizontalBar(offset - horizontalScrollOffset);
-}
-/**
- * Sets the horizontal pixel offset relative to the start of the line.
- * Do nothing if there is no text set.
- * <p>
- * <b>NOTE:</b> The horizontal pixel offset is reset to 0 when new text
- * is set in the widget.
- * </p>
- *
- * @param pixel horizontal pixel offset relative to the start
- * of the line.
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- * @since 2.0
- */
-public void setHorizontalPixel(int pixel) {
- checkWidget();
- int clientAreaWidth = getClientArea().width;
- if (getCharCount() == 0) {
- return;
- }
- if (pixel < 0) {
- pixel = 0;
- }
- // allow any value if client area width is unknown or 0.
- // offset will be checked in resize handler.
- // don't use isVisible since width is known even if widget
- // is temporarily invisible
- if (clientAreaWidth > 0) {
- int width = lineCache.getWidth();
- // prevent scrolling if the content fits in the client area.
- // align end of longest line with right border of client area
- // if offset is out of range.
- if (pixel > width - clientAreaWidth) {
- pixel = Math.max(0, width - clientAreaWidth);
- }
- }
- scrollHorizontalBar(pixel - horizontalScrollOffset);
-}
-/**
- * Adjusts the maximum and the page size of the horizontal scroll bar
- * to reflect content width changes.
- */
-void setHorizontalScrollBar() {
- ScrollBar horizontalBar = getHorizontalBar();
-
- if (horizontalBar != null && horizontalBar.getVisible()) {
- final int INACTIVE = 1;
- Rectangle clientArea = getClientArea();
- // 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 < lineCache.getWidth()) {
- horizontalBar.setValues(
- horizontalBar.getSelection(),
- horizontalBar.getMinimum(),
- lineCache.getWidth(), // maximum
- clientArea.width - leftMargin - rightMargin, // thumb size
- horizontalBar.getIncrement(),
- clientArea.width - leftMargin - rightMargin); // page size
- }
- else
- if (horizontalBar.getThumb() != INACTIVE || horizontalBar.getMaximum() != INACTIVE) {
- horizontalBar.setValues(
- horizontalBar.getSelection(),
- horizontalBar.getMinimum(),
- INACTIVE,
- INACTIVE,
- horizontalBar.getIncrement(),
- INACTIVE);
- }
- }
-}
-/**
- * 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>
- * Line background colors are maintained relative to the line text, not the
- * line index that is specified in this method call.
- * During text changes, when entire lines are inserted or removed, the line
- * background colors that are associated with the lines after the change
- * will "move" with their respective text. An entire line is defined as
- * extending from the first character on a line to the last and including the
- * line delimiter.
- * </p>
- * <p>
- * When two lines are joined by deleting a line delimiter, the top line
- * background takes precedence and the color of the bottom line is deleted.
- * 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();
-
- // this API can not be used if the client is providing the line background
- if (userLineBackground) {
- return;
- }
- if (startLine < 0 || startLine + lineCount > logicalContent.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;
- super.redraw(
- leftMargin, startLine * lineHeight + topMargin,
- getClientArea().width - leftMargin - rightMargin, lineCount * lineHeight, true);
-}
-/**
- * Flips selection anchor based on word selection direction.
- */
-void setMouseWordSelectionAnchor() {
- if (mouseDoubleClick == false) {
- return;
- }
- if (caretOffset < doubleClickSelection.x) {
- selectionAnchor = doubleClickSelection.y;
- }
- else
- if (caretOffset > doubleClickSelection.y) {
- selectionAnchor = doubleClickSelection.x;
- }
-}
-/**
- * Adjusts the maximum and the page size of the scroll bars to
- * reflect content width/length changes.
- */
-void setScrollBars() {
- ScrollBar verticalBar = getVerticalBar();
-
- if (verticalBar != null) {
- Rectangle clientArea = getClientArea();
- final int INACTIVE = 1;
- 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);
- }
- }
- setHorizontalScrollBar();
-}
-/**
- * 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
- * <li>ERROR_INVALID_ARGUMENT when either the start or the end of the selection range is inside a
- * multi byte line delimiter (and thus neither clearly in front of or after the line delimiter)
- * </ul>
- */
-public void setSelection(int start) {
- // checkWidget test done in setSelectionRange
- setSelection(start, start);
-}
-/**
- * Sets the selection and scrolls it into view.
- * <p>
- * Indexing is zero based. Text selections are specified in terms of
- * caret positions. In a text widget that contains N characters, there are
- * N+1 caret positions, ranging from 0..N
- * </p>
- *
- * @param point x=selection start offset, y=selection end offset
- * The caret will be placed at the selection start when x > y.
- * @see #setSelection(int,int)
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT when point is null</li>
- * <li>ERROR_INVALID_RANGE when start or end is outside the widget content
- * <li>ERROR_INVALID_ARGUMENT when either the start or the end of the selection range is inside a
- * multi byte line delimiter (and thus neither clearly in front of or after the line delimiter)
- * </ul>
- */
-public void setSelection(Point point) {
- checkWidget();
- if (point == null) SWT.error (SWT.ERROR_NULL_ARGUMENT);
- setSelection(point.x, point.y);
-}
-/**
- * Sets the receiver's selection background color to the color specified
- * by the argument, or to the default system color for the control
- * if the argument is null.
- *
- * @param color the new color (or null)
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_INVALID_ARGUMENT - if the argument has been disposed</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- * @since 2.1
- */
-public void setSelectionBackground (Color color) {
- checkWidget ();
- if (color != null) {
- if (color.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
- }
- selectionBackground = color;
- redraw();
-}
-/**
- * Sets the receiver's selection foreground color to the color specified
- * by the argument, or to the default system color for the control
- * if the argument is null.
- *
- * @param color the new color (or null)
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_INVALID_ARGUMENT - if the argument has been disposed</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- * @since 2.1
- */
-public void setSelectionForeground (Color color) {
- checkWidget ();
- if (color != null) {
- if (color.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
- }
- selectionForeground = color;
- redraw();
-}
-/**
- * Sets the selection and scrolls it into view.
- * <p>
- * Indexing is zero based. Text selections are specified in terms of
- * caret positions. In a text widget that contains N characters, there are
- * N+1 caret positions, ranging from 0..N
- * </p>
- *
- * @param start selection start offset. The caret will be placed at the
- * selection start when start > end.
- * @param end selection end offset
- * @see #setSelectionRange(int,int)
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_INVALID_RANGE when start or end is outside the widget content
- * <li>ERROR_INVALID_ARGUMENT when either the start or the end of the selection range is inside a
- * multi byte line delimiter (and thus neither clearly in front of or after the line delimiter)
- * </ul>
- */
-public void setSelection(int start, int end) {
- // checkWidget test done in setSelectionRange
- setSelectionRange(start, end - start);
- 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, 0 <= start + length <= getCharCount()
- * must be true.
- * A negative length places the caret at the visual start 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>
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_INVALID_RANGE when the range specified by start and length is outside the widget content
- * <li>ERROR_INVALID_ARGUMENT when either the start or the end of the selection range is inside a
- * multi byte line delimiter (and thus neither clearly in front of or after the line delimiter)
- * </ul>
- */
-public void setSelectionRange(int start, int length) {
- checkWidget();
- int contentLength = getCharCount();
- int end = start + length;
-
- if (start < 0 || end < 0 || start > contentLength || end > contentLength) {
- SWT.error(SWT.ERROR_INVALID_RANGE);
- }
- if (isLineDelimiter(start) || isLineDelimiter(end)) {
- // the start offset or end offset of the selection range is inside a
- // multi byte line delimiter. This is an illegal operation and an exception
- // is thrown. Fixes 1GDKK3R
- SWT.error(SWT.ERROR_INVALID_ARGUMENT);
- }
- internalSetSelection(start, length, false);
- // always update the caret location. fixes 1G8FODP
- setCaretLocation();
- if (isBidi()) {
- setBidiKeyboardLanguage();
- }
-}
-/**
- * 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, 0 <= start + length
- * <= getCharCount() must be true.
- * A negative length places the caret at the selection start.
- * @param sendEvent a Selection event is sent when set to true and when
- * the selection is reset.
- */
-void internalSetSelection(int start, int length, boolean sendEvent) {
- int end = start + length;
-
- if (start > end) {
- int temp = end;
- end = start;
- start = temp;
- }
- // is the selection range different or is the selection direction
- // different?
- if (selection.x != start || selection.y != end ||
- (length > 0 && selectionAnchor != selection.x) ||
- (length < 0 && selectionAnchor != selection.y)) {
- clearSelection(sendEvent);
- if (length < 0) {
- selectionAnchor = selection.y = end;
- caretOffset = selection.x = start;
- }
- else {
- selectionAnchor = selection.x = start;
- caretOffset = selection.y = end;
- }
- internalRedrawRange(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();
-
- // 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) {
- boolean redrawFirstLine = false;
- boolean redrawLastLine = false;
- int firstLine = content.getLineAtOffset(range.start);
- int lastLine = content.getLineAtOffset(range.start + range.length);
-
- // if the style is not visible, there is no need to redraw
- boolean redrawLines = isAreaVisible(firstLine, lastLine);
-
- if (!redrawLines) {
- defaultLineStyler.setStyleRange(range);
- lineCache.reset(firstLine, lastLine - firstLine + 1, true);
- } else {
- // 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 firstLineOffset = content.getOffsetAtLine(firstLine);
- int lastLineOffset = content.getOffsetAtLine(lastLine);
- if (isBidi()) {
- if (firstLine != lastLine) {
- redrawFirstLine = true;
- }
- redrawLastLine = true;
- } else {
- redrawFirstLine = isRedrawFirstLine(new StyleRange[] {range}, firstLine, firstLineOffset);
- if (lastLine != firstLine) {
- redrawLastLine = isRedrawLastLine(new StyleRange[] {range}, lastLine, lastLineOffset);
- }
- }
- defaultLineStyler.setStyleRange(range);
- // reset all lines affected by the style change but let the redraw
- // recalculate only those that are visible.
- lineCache.reset(firstLine, lastLine - firstLine + 1, true);
- internalRedrawRange(range.start, range.length, true);
- if (redrawFirstLine) {
- redrawLine(firstLine, range.start - firstLineOffset);
- }
- if (redrawLastLine) {
- redrawLine(lastLine, 0);
- }
- }
- } else {
- // clearing all styles
- defaultLineStyler.setStyleRange(range);
- lineCache.reset(0, content.getLineCount(), false);
- 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
- * in the widget 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];
- int lastEnd = last.start + last.length;
- int firstLine = content.getLineAtOffset(ranges[0].start);
- int lastLine;
- if (lastEnd > content.getCharCount()) {
- SWT.error(SWT.ERROR_INVALID_RANGE);
- }
- lastLine = content.getLineAtOffset(lastEnd);
- // reset all lines affected by the style change
- lineCache.reset(firstLine, lastLine - firstLine + 1, true);
- }
- else {
- // reset all lines
- lineCache.reset(0, content.getLineCount(), false);
- }
- defaultLineStyler.setStyleRanges(ranges);
- redraw(); // should 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;
- renderer.setTabLength(tabLength);
- if (caretOffset > 0) {
- caretOffset = 0;
- if (isBidi()) {
- showBidiCaret();
- }
- else {
- showCaret();
- }
- clearSelection(false);
- }
- // reset all line widths when the tab width changes
- lineCache.reset(0, content.getLineCount(), 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>
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT when string is null</li>
- * </ul>
- */
-public void setText(String text) {
- checkWidget();
- Event event = new Event();
-
- if (text == null) {
- SWT.error(SWT.ERROR_NULL_ARGUMENT);
- }
- event.start = 0;
- event.end = getCharCount();
- event.text = text;
- event.doit = true;
- notifyListeners(SWT.Verify, event);
- if (event.doit) {
- StyledTextEvent styledTextEvent = null;
-
- if (isListening(ExtendedModify)) {
- styledTextEvent = new StyledTextEvent(logicalContent);
- styledTextEvent.start = event.start;
- styledTextEvent.end = event.start + event.text.length();
- styledTextEvent.text = content.getTextRange(event.start, event.end - event.start);
- }
- content.setText(event.text);
- notifyListeners(SWT.Modify, event);
- if (styledTextEvent != null) {
- notifyListeners(ExtendedModify, styledTextEvent);
- }
- }
-}
-/**
- * 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() - fully visible lines per page. If no lines are fully
- * visible the maximum value is getLineCount() - 1. An out of range
- * index will be adjusted accordingly.
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public void setTopIndex(int topIndex) {
- checkWidget();
- int lineCount = logicalContent.getLineCount();
- int pageSize = Math.max(1, Math.min(lineCount, getLineCountWhole()));
-
- if (getCharCount() == 0) {
- return;
- }
- if (topIndex < 0) {
- topIndex = 0;
- }
- else
- if (topIndex > lineCount - pageSize) {
- topIndex = lineCount - pageSize;
- }
- if (wordWrap) {
- int logicalLineOffset = logicalContent.getOffsetAtLine(topIndex);
- topIndex = content.getLineAtOffset(logicalLineOffset);
- }
- setVerticalScrollOffset(topIndex * getVerticalIncrement(), true);
-}
-/**
- * Sets the top pixel offset. Do nothing if there is no text set.
- * <p>
- * The top pixel offset is the vertical pixel offset of the widget. The
- * widget is scrolled so that the given pixel position is at the top.
- * The top index is adjusted to the corresponding top line.
- * Note: The top pixel is reset to 0 when new text is set in the widget.
- * </p>
- *
- * @param pixel new top pixel offset. Must be between 0 and
- * (getLineCount() - visible lines per page) / getLineHeight()). An out
- * of range offset will be adjusted accordingly.
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- * @since 2.0
- */
-public void setTopPixel(int pixel) {
- checkWidget();
- int lineCount =content.getLineCount();
- int height = getClientArea().height;
- int maxTopPixel = Math.max(0, lineCount * getVerticalIncrement() - height);
-
- if (getCharCount() == 0) {
- return;
- }
- if (pixel < 0) {
- pixel = 0;
- }
- else
- if (pixel > maxTopPixel) {
- pixel = maxTopPixel;
- }
- setVerticalScrollOffset(pixel, true);
-}
-/**
- * Scrolls the widget vertically.
- * <p>
- *
- * @param pixelOffset the new vertical scroll offset
- * @param adjustScrollBar
- * true= the scroll thumb will be moved to reflect the new scroll offset.
- * false = the scroll thumb will not be moved
- * @return
- * true=the widget was scrolled
- * false=the widget was not scrolled, the given offset is not valid.
- */
-boolean setVerticalScrollOffset(int pixelOffset, boolean adjustScrollBar) {
- Rectangle clientArea;
- ScrollBar verticalBar = getVerticalBar();
-
- if (pixelOffset == verticalScrollOffset) {
- return false;
- }
- 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);
-
- verticalScrollOffset = pixelOffset;
- calculateTopIndex();
- setCaretLocation();
- return true;
-}
-/**
- * Scrolls the specified location into view.
- * <p>
- *
- * @param x the x coordinate that should be made visible.
- * @param line the line that should be made visible. Relative to the
- * first line in the document.
- * @return
- * true=the widget was scrolled to make the specified location visible.
- * false=the specified location is already visible, the widget was
- * not scrolled.
- */
-boolean showLocation(int x, int line) {
- int clientAreaWidth = getClientArea().width - leftMargin - rightMargin;
- int verticalIncrement = getVerticalIncrement();
- int horizontalIncrement = clientAreaWidth / 4;
- boolean scrolled = false;
-
- if (x < leftMargin) {
- // always make 1/4 of a page visible
- x = Math.max(horizontalScrollOffset * -1, x - horizontalIncrement);
- scrolled = scrollHorizontalBar(x);
- }
- else
- if (x >= clientAreaWidth) {
- // always make 1/4 of a page visible
- x = Math.min(lineCache.getWidth() - horizontalScrollOffset, x + horizontalIncrement);
- scrolled = scrollHorizontalBar(x - clientAreaWidth);
- }
- if (line < topIndex) {
- scrolled = setVerticalScrollOffset(line * verticalIncrement, true);
- }
- else
- if (line > getBottomIndex()) {
- scrolled = setVerticalScrollOffset((line + 1) * verticalIncrement - getClientArea().height, true);
- }
- return scrolled;
-}
-/**
- * Sets the caret location and scrolls the caret offset into view.
- */
-void showCaret() {
- int caretLine = content.getLineAtOffset(caretOffset);
-
- showCaret(caretLine);
-}
-/**
- * Sets the caret location and scrolls the caret offset into view.
- */
-void showCaret(int caretLine) {
- int lineOffset = content.getOffsetAtLine(caretLine);
- String lineText = content.getLine(caretLine);
- int offsetInLine = caretOffset - lineOffset;
- int xAtOffset = getXAtOffset(lineText, caretLine, offsetInLine);
- boolean scrolled = showLocation(xAtOffset, caretLine);
- boolean setWrapCaretLocation = false;
- Caret caret = getCaret();
-
- if (wordWrap && caret != null) {
- int caretY = caret.getLocation().y;
- if ((caretY + verticalScrollOffset) / getVerticalIncrement() - 1 != caretLine) {
- setWrapCaretLocation = true;
- }
- }
- if (scrolled == false || setWrapCaretLocation) {
- // set the caret location if a scroll operation did not set it (as a
- // sideeffect of scrolling) or when in word wrap mode and the caret
- // line was explicitly specified (i.e., because getWrapCaretLine does
- // not return the desired line causing scrolling to not set it correctly)
- setCaretLocation(xAtOffset, caretLine);
- }
- if (isBidi()) {
- setBidiKeyboardLanguage();
- }
-}
-/**
- * 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);
-
- showLocation(xAtOffset, line);
-}
-/**
-/**
- * Scrolls the selection into view. The end of the selection will be scrolled into
- * view. Note that if a right-to-left selection exists, the end of the selection is the
- * visual beginning of the selection (i.e., where the caret is located).
- * <p>
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public void showSelection() {
- checkWidget();
- boolean selectionFits;
- int startOffset, startLine, startX, endOffset, endLine, endX, offsetInLine;
-
- // is selection from right-to-left?
- boolean rightToLeft = caretOffset == selection.x;
-
- if (rightToLeft) {
- startOffset = selection.y;
- endOffset = selection.x;
- } else {
- startOffset = selection.x;
- endOffset = selection.y;
- }
-
- // calculate the logical start and end values for the selection
- startLine = content.getLineAtOffset(startOffset);
- offsetInLine = startOffset - content.getOffsetAtLine(startLine);
- startX = getXAtOffset(content.getLine(startLine), startLine, offsetInLine);
- endLine = content.getLineAtOffset(endOffset);
- offsetInLine = endOffset - content.getOffsetAtLine(endLine);
- endX = getXAtOffset(content.getLine(endLine), endLine, offsetInLine);
-
- // can the selection be fully displayed within the widget's visible width?
- int w = getClientArea().width;
- if (rightToLeft) {
- selectionFits = startX - endX <= w;
- } else {
- selectionFits = endX - startX <= w;
- }
-
- if (selectionFits) {
- // show as much of the selection as possible by first showing
- // the start of the selection
- showLocation(startX, startLine);
- // endX value could change if showing startX caused a scroll to occur
- endX = getXAtOffset(content.getLine(endLine), endLine, offsetInLine);
- showLocation(endX, endLine);
- } else {
- // just show the end of the selection since the selection start
- // will not be visible
- showLocation(endX, endLine);
- }
-}
-/**
- * Updates the caret direction when a delete operation occured based on
- * the type of the delete operation (next/previous character) and the
- * caret location (at a direction boundary or inside a direction segment).
- * The intent is to place the caret at the visual location where a
- * character was deleted.
- * <p>
- *
- * @param isBackspace true=the previous character was deleted, false=the
- * character next to the caret location was deleted
- * @param isDirectionBoundary true=the caret is between a R2L and L2R segment,
- * false=the caret is within a direction segment
- */
-void updateBidiDirection(boolean isBackspace, boolean isDirectionBoundary) {
- if (isDirectionBoundary) {
- if (isBackspace) {
- // Deleted previous character (backspace) at a direction boundary
- // Go to direction segment of deleted character
- lastCaretDirection = ST.COLUMN_NEXT;
- }
- else {
- // Deleted next character. Go to direction segment of deleted character
- lastCaretDirection = ST.COLUMN_PREVIOUS;
- }
- }
- else {
- if (isBackspace) {
- // Delete previous character inside direction segment (i.e., not at a direction boundary)
- lastCaretDirection = ST.COLUMN_PREVIOUS;
- }
- else {
- // Deleted next character.
- lastCaretDirection = ST.COLUMN_NEXT;
- }
- }
-}
-/**
- * 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
- internalRedrawRange(selection.x, startOffset - selection.x, true);
- }
- if (selection.y > startOffset + replacedLength && selection.x < startOffset + replacedLength) {
- // clear selection fragment after text change.
- // do this only when the selection is actually affected by the
- // change. Selection is only affected if it intersects the change (1GDY217).
- int netNewLength = newLength - replacedLength;
- int redrawStart = startOffset + newLength;
- internalRedrawRange(redrawStart, selection.y + netNewLength - redrawStart, true);
- }
- if (selection.y > startOffset && selection.x < startOffset + replacedLength) {
- // selection intersects replaced text. set caret behind text change
- internalSetSelection(startOffset + newLength, 0, true);
- // 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, true);
- // always update the caret location. fixes 1G8FODP
- setCaretLocation();
- }
-}
-/**
- * Rewraps all lines
- * <p>
- *
- * @param oldClientAreaWidth client area width before resize
- * occurred
- */
-void wordWrapResize(int oldClientAreaWidth) {
- WrappedContent wrappedContent = (WrappedContent) content;
- int newTopIndex;
-
- // all lines are wrapped and no rewrap required if widget has already
- // been visible, client area is now wider and visual (wrapped) line
- // count equals logical line count.
- if (oldClientAreaWidth != 0 && clientAreaWidth > oldClientAreaWidth &&
- wrappedContent.getLineCount() == logicalContent.getLineCount()) {
- return;
- }
- wrappedContent.wrapLines();
-
- // adjust the top index so that top line remains the same
- newTopIndex = content.getLineAtOffset(topOffset);
- // topOffset is the beginning of the top line. therefore it
- // needs to be adjusted because in a wrapped line this is also
- // the end of the preceeding line.
- if (newTopIndex < content.getLineCount() - 1 &&
- topOffset == content.getOffsetAtLine(newTopIndex + 1)) {
- newTopIndex++;
- }
- if (newTopIndex != topIndex) {
- ScrollBar verticalBar = getVerticalBar();
- // adjust index and pixel offset manually instead of calling
- // setVerticalScrollOffset because the widget does not actually need
- // to be scrolled. causes flash otherwise.
- verticalScrollOffset += (newTopIndex - topIndex) * getVerticalIncrement();
- // verticalScrollOffset may become negative if first line was
- // partially visible and second line was top line. prevent this from
- // happening to fix 8503.
- if (verticalScrollOffset < 0) {
- verticalScrollOffset = 0;
- }
- topIndex = newTopIndex;
- topOffset = content.getOffsetAtLine(topIndex);
- if (verticalBar != null) {
- verticalBar.setSelection(verticalScrollOffset);
- }
- }
- // caret may be on a different line after a rewrap.
- // call setCaretLocation after fixing vertical scroll offset.
- setCaretLocation();
- // word wrap may have changed on one of the visible lines
- super.redraw();
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+import java.util.*;
+
+import org.eclipse.swt.*;
+import org.eclipse.swt.dnd.*;
+import org.eclipse.swt.events.*;
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.internal.*;
+import org.eclipse.swt.printing.*;
+import org.eclipse.swt.widgets.*;
+
+/**
+ * A StyledText is an editable user interface object that displays lines
+ * of text. The following style attributes can be defined for the text:
+ * <ul>
+ * <li>foreground color
+ * <li>background color
+ * <li>font style (bold, 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>replaceStyleRanges(int,int,StyleRange[])
+ * <li>setStyleRange(StyleRange)
+ * <li>setStyleRanges(StyleRange[])
+ * </ul>
+ * </p>
+ * <p>
+ * There are two ways to use this widget when specifying line background colors.
+ * You may use the API that is defined for StyledText or you may define your own
+ * LineBackgroundListener. If you define your own listener, you will be responsible
+ * for maintaining the line background color information for the widget.
+ * IMPORTANT: You may not define your own listener and use the StyledText API.
+ * The following StyledText API is not supported if you have defined a
+ * LineBackgroundListener:
+ * <ul>
+ * <li>getLineBackground(int)
+ * <li>setLineBackground(int,int,Color)
+ * </ul>
+ * </p>
+ * <p>
+ * The content implementation for this widget may also be user-defined. To do so,
+ * you must implement the StyledTextContent interface and use the StyledText API
+ * setContent(StyledTextContent) to initialize the widget.
+ * </p>
+ * <p>
+ * IMPORTANT: This class is <em>not</em> intended to be subclassed.
+ * </p>
+ * <dl>
+ * <dt><b>Styles:</b><dd>FULL_SELECTION, MULTI, READ_ONLY, SINGLE, WRAP
+ * <dt><b>Events:</b><dd>ExtendedModify, LineGetBackground, LineGetSegments, LineGetStyle, Modify, Selection, Verify, VerifyKey
+ * </dl>
+ */
+public class StyledText extends Canvas {
+ static final char TAB = '\t';
+ static final String PlatformLineDelimiter = System.getProperty("line.separator");
+ static final int BIDI_CARET_WIDTH = 4;
+ static final int XINSET = BIDI_CARET_WIDTH - 1;
+ static final int DEFAULT_WIDTH = 64;
+ static final int DEFAULT_HEIGHT = 64;
+
+ static final int ExtendedModify = 3000;
+ static final int LineGetBackground = 3001;
+ static final int LineGetStyle = 3002;
+ static final int TextChanging = 3003;
+ static final int TextSet = 3004;
+ static final int VerifyKey = 3005;
+ static final int TextChanged = 3006;
+ static final int LineGetSegments = 3007;
+
+ Color selectionBackground; // selection background color
+ Color selectionForeground; // selection foreground color
+ StyledTextContent logicalContent; // native content (default or user specified)
+ StyledTextContent content; // line wrapping content, same as logicalContent if word wrap is off
+ DisplayRenderer renderer;
+ TextChangeListener textChangeListener; // listener for TextChanging, TextChanged and TextSet events from StyledTextContent
+ DefaultLineStyler defaultLineStyler;// used for setStyles API when no LineStyleListener is registered
+ LineCache lineCache;
+ 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 topOffset = 0; // offset of first character in top line
+ int clientAreaHeight = 0; // the client area height. Needed to calculate content width for new
+ // visible lines during Resize callback
+ int clientAreaWidth = 0; // the client area width. Needed during Resize callback to determine
+ // if line wrap needs to be recalculated
+ int lineHeight; // line height=font height
+ int tabLength = 4; // number of characters in a tab
+ int lineEndSpaceWidth; // space, in pixel, used to indicated a selected line break
+ int leftMargin = 1;
+ int topMargin = 1;
+ int rightMargin = 2;
+ int bottomMargin = 2;
+ Cursor ibeamCursor;
+ int columnX; // keep track of the horizontal caret position
+ // when changing lines/pages. Fixes bug 5935
+ 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
+ Point doubleClickSelection; // selection after last mouse double click
+ boolean editable = true;
+ boolean wordWrap = false;
+ boolean doubleClickEnabled = true; // see getDoubleClickEnabled
+ boolean overwrite = false; // insert/overwrite edit mode
+ int textLimit = -1; // limits the number of characters the user can type in the widget. Unlimited by default.
+ Hashtable keyActionMap = new Hashtable();
+ Color background = null; // workaround for bug 4791
+ Color foreground = null; //
+ Clipboard clipboard;
+ 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)
+ int lastTextChangeStart; // cache data of the
+ int lastTextChangeNewLineCount; // last text changing
+ int lastTextChangeNewCharCount; // event for use in the
+ int lastTextChangeReplaceLineCount; // text changed handler
+ int lastTextChangeReplaceCharCount;
+ boolean isBidi;
+ boolean bidiColoring = false; // apply the BIDI algorithm on text segments of the same color
+ Image leftCaretBitmap = null;
+ Image rightCaretBitmap = null;
+ int caretDirection = SWT.NULL;
+ PaletteData caretPalette = null;
+ int lastCaretDirection = SWT.NULL;
+ boolean isCarbon; // flag set to true on Mac OSX
+
+ /**
+ * The Printing class implements printing of a range of text.
+ * An instance of <class>Printing </class> is returned in the
+ * StyledText#print(Printer) API. The run() method may be
+ * invoked from any thread.
+ */
+ class Printing implements Runnable {
+ final static int LEFT = 0; // left aligned header/footer segment
+ final static int CENTER = 1; // centered header/footer segment
+ final static int RIGHT = 2; // right aligned header/footer segment
+
+ Printer printer;
+ PrintRenderer renderer;
+ StyledTextPrintOptions printOptions;
+ StyledTextContent printerContent; // copy of the widget content
+ Rectangle clientArea; // client area to print on
+ Font printerFont;
+ FontData displayFontData;
+ Hashtable printerColors; // printer color cache for line backgrounds and style
+ Hashtable lineBackgrounds = new Hashtable(); // cached line backgrounds
+ Hashtable lineStyles = new Hashtable(); // cached line styles
+ Hashtable bidiSegments = new Hashtable(); // cached bidi segments when running on a bidi platform
+ GC gc; // printer GC
+ int pageWidth; // width of a printer page in pixels
+ int startPage; // first page to print
+ int endPage; // last page to print
+ int pageSize; // number of lines on a page
+ int startLine; // first (wrapped) line to print
+ int endLine; // last (wrapped) line to print
+ boolean singleLine; // widget single line mode
+ Point selection = null; // selected text
+
+ /**
+ * Creates an instance of <class>Printing</class>.
+ * Copies the widget content and rendering data that needs
+ * to be requested from listeners.
+ * </p>
+ * @param parent StyledText widget to print.
+ * @param printer printer device to print on.
+ * @param printOptions print options
+ */
+ Printing(StyledText parent, Printer printer, StyledTextPrintOptions printOptions) {
+ PrinterData data = printer.getPrinterData();
+
+ this.printer = printer;
+ this.printOptions = printOptions;
+ singleLine = parent.isSingleLine();
+ startPage = 1;
+ endPage = Integer.MAX_VALUE;
+ if (data.scope == PrinterData.PAGE_RANGE) {
+ startPage = data.startPage;
+ endPage = data.endPage;
+ if (endPage < startPage) {
+ int temp = endPage;
+ endPage = startPage;
+ startPage = temp;
+ }
+ } if (data.scope == PrinterData.SELECTION) {
+ selection = parent.getSelectionRange();
+ }
+
+ displayFontData = getFont().getFontData()[0];
+ copyContent(parent.getContent());
+ cacheLineData(printerContent);
+ }
+ /**
+ * Caches the bidi segments of the given line.
+ * </p>
+ * @param lineOffset offset of the line to cache bidi segments for.
+ * Relative to the start of the document.
+ * @param line line to cache bidi segments for.
+ */
+ void cacheBidiSegments(int lineOffset, String line) {
+ int[] segments = getBidiSegments(lineOffset, line);
+
+ if (segments != null) {
+ bidiSegments.put(new Integer(lineOffset), segments);
+ }
+ }
+ /**
+ * Caches the line background color of the given line.
+ * </p>
+ * @param lineOffset offset of the line to cache the background
+ * color for. Relative to the start of the document.
+ * @param line line to cache the background color for
+ */
+ void cacheLineBackground(int lineOffset, String line) {
+ StyledTextEvent event = getLineBackgroundData(lineOffset, line);
+
+ if (event != null) {
+ lineBackgrounds.put(new Integer(lineOffset), event);
+ }
+ }
+ /**
+ * Caches all line data that needs to be requested from a listener.
+ * </p>
+ * @param printerContent <class>StyledTextContent</class> to request
+ * line data for.
+ */
+ void cacheLineData(StyledTextContent printerContent) {
+ for (int i = 0; i < printerContent.getLineCount(); i++) {
+ int lineOffset = printerContent.getOffsetAtLine(i);
+ String line = printerContent.getLine(i);
+
+ if (printOptions.printLineBackground) {
+ cacheLineBackground(lineOffset, line);
+ }
+ if (printOptions.printTextBackground ||
+ printOptions.printTextForeground ||
+ printOptions.printTextFontStyle) {
+ cacheLineStyle(lineOffset, line);
+ }
+ if (isBidi()) {
+ cacheBidiSegments(lineOffset, line);
+ }
+ }
+ }
+ /**
+ * Caches all line styles of the given line.
+ * </p>
+ * @param lineOffset offset of the line to cache the styles for.
+ * Relative to the start of the document.
+ * @param line line to cache the styles for.
+ */
+ void cacheLineStyle(int lineOffset, String line) {
+ StyledTextEvent event = getLineStyleData(lineOffset, line);
+
+ if (event != null) {
+ StyleRange[] styles = event.styles;
+ for (int i = 0; i < styles.length; i++) {
+ StyleRange styleCopy = null;
+ if (printOptions.printTextBackground == false && styles[i].background != null) {
+ styleCopy = (StyleRange) styles[i].clone();
+ styleCopy.background = null;
+ }
+ if (printOptions.printTextForeground == false && styles[i].foreground != null) {
+ if (styleCopy == null) {
+ styleCopy = (StyleRange) styles[i].clone();
+ }
+ styleCopy.foreground = null;
+ }
+ if (printOptions.printTextFontStyle == false && styles[i].fontStyle != SWT.NORMAL) {
+ if (styleCopy == null) {
+ styleCopy = (StyleRange) styles[i].clone();
+ }
+ styleCopy.fontStyle = SWT.NORMAL;
+ }
+ if (styleCopy != null) {
+ styles[i] = styleCopy;
+ }
+ }
+ lineStyles.put(new Integer(lineOffset), event);
+ }
+ }
+ /**
+ * Copies the text of the specified <class>StyledTextContent</class>.
+ * </p>
+ * @param original the <class>StyledTextContent</class> to copy.
+ */
+ void copyContent(StyledTextContent original) {
+ int insertOffset = 0;
+
+ printerContent = new DefaultContent();
+ for (int i = 0; i < original.getLineCount(); i++) {
+ int insertEndOffset;
+ if (i < original.getLineCount() - 1) {
+ insertEndOffset = original.getOffsetAtLine(i + 1);
+ }
+ else {
+ insertEndOffset = original.getCharCount();
+ }
+ printerContent.replaceTextRange(insertOffset, 0, original.getTextRange(insertOffset, insertEndOffset - insertOffset));
+ insertOffset = insertEndOffset;
+ }
+ }
+ /**
+ * Replaces all display colors in the cached line backgrounds and
+ * line styles with printer colors.
+ */
+ void createPrinterColors() {
+ Enumeration values = lineBackgrounds.elements();
+ printerColors = new Hashtable();
+ while (values.hasMoreElements()) {
+ StyledTextEvent event = (StyledTextEvent) values.nextElement();
+ event.lineBackground = getPrinterColor(event.lineBackground);
+ }
+
+ values = lineStyles.elements();
+ while (values.hasMoreElements()) {
+ StyledTextEvent event = (StyledTextEvent) values.nextElement();
+ for (int i = 0; i < event.styles.length; i++) {
+ StyleRange style = event.styles[i];
+ Color printerBackground = getPrinterColor(style.background);
+ Color printerForeground = getPrinterColor(style.foreground);
+
+ if (printerBackground != style.background ||
+ printerForeground != style.foreground) {
+ style = (StyleRange) style.clone();
+ style.background = printerBackground;
+ style.foreground = printerForeground;
+ event.styles[i] = style;
+ }
+ }
+ }
+ }
+ /**
+ * Disposes of the resources and the <class>PrintRenderer</class>.
+ */
+ void dispose() {
+ if (printerColors != null) {
+ Enumeration colors = printerColors.elements();
+
+ while (colors.hasMoreElements()) {
+ Color color = (Color) colors.nextElement();
+ color.dispose();
+ }
+ printerColors = null;
+ }
+ if (gc != null) {
+ gc.dispose();
+ gc = null;
+ }
+ if (printerFont != null) {
+ printerFont.dispose();
+ printerFont = null;
+ }
+ if (renderer != null) {
+ renderer.dispose();
+ renderer = null;
+ }
+ }
+ /**
+ * Finish printing the indicated page.
+ *
+ * @param page page that was printed
+ */
+ void endPage(int page) {
+ printDecoration(page, false);
+ printer.endPage();
+ }
+ /**
+ * Creates a <class>PrintRenderer</class> and calculate the line range
+ * to print.
+ */
+ void initializeRenderer() {
+ Rectangle trim = printer.computeTrim(0, 0, 0, 0);
+ Point dpi = printer.getDPI();
+
+ printerFont = new Font(printer, displayFontData.getName(), displayFontData.getHeight(), SWT.NORMAL);
+ clientArea = printer.getClientArea();
+ pageWidth = clientArea.width;
+ // one inch margin around text
+ clientArea.x = dpi.x + trim.x;
+ clientArea.y = dpi.y + trim.y;
+ clientArea.width -= (clientArea.x + trim.width);
+ clientArea.height -= (clientArea.y + trim.height);
+
+ gc = new GC(printer);
+ gc.setFont(printerFont);
+ renderer = new PrintRenderer(
+ printer, printerFont, isBidi(), gc, printerContent,
+ lineBackgrounds, lineStyles, bidiSegments,
+ tabLength, clientArea);
+ if (printOptions.header != null) {
+ int lineHeight = renderer.getLineHeight();
+ clientArea.y += lineHeight * 2;
+ clientArea.height -= lineHeight * 2;
+ }
+ if (printOptions.footer != null) {
+ clientArea.height -= renderer.getLineHeight() * 2;
+ }
+ pageSize = clientArea.height / renderer.getLineHeight();
+ StyledTextContent content = renderer.getContent();
+ startLine = 0;
+ endLine = content.getLineCount() - 1;
+ PrinterData data = printer.getPrinterData();
+ if (data.scope == PrinterData.PAGE_RANGE) {
+ startLine = (startPage - 1) * pageSize;
+ } else if (data.scope == PrinterData.SELECTION) {
+ startLine = content.getLineAtOffset(selection.x);
+ if (selection.y > 0) {
+ endLine = content.getLineAtOffset(selection.x + selection.y - 1);
+ } else {
+ endLine = startLine - 1;
+ }
+ }
+ }
+ /**
+ * Returns the printer color for the given display color.
+ * </p>
+ * @param color display color
+ * @return color create on the printer with the same RGB values
+ * as the display color.
+ */
+ Color getPrinterColor(Color color) {
+ Color printerColor = null;
+
+ if (color != null) {
+ printerColor = (Color) printerColors.get(color);
+ if (printerColor == null) {
+ printerColor = new Color(printer, color.getRGB());
+ printerColors.put(color, printerColor);
+ }
+ }
+ return printerColor;
+ }
+ /**
+ * Prints the lines in the specified page range.
+ */
+ void print() {
+ StyledTextContent content = renderer.getContent();
+ Color background = gc.getBackground();
+ Color foreground = gc.getForeground();
+ int lineHeight = renderer.getLineHeight();
+ int lineCount = content.getLineCount();
+ int paintY = clientArea.y;
+ int page = startPage;
+
+ if (singleLine) {
+ lineCount = 1;
+ }
+ for (int i = startLine; i <= endLine && page <= endPage; i++, paintY += lineHeight) {
+ String line = content.getLine(i);
+
+ if (paintY == clientArea.y) {
+ startPage(page);
+ }
+ renderer.drawLine(
+ line, i, paintY, gc, background, foreground, true);
+ if (paintY + lineHeight * 2 > clientArea.y + clientArea.height) {
+ endPage(page);
+ paintY = clientArea.y;
+ page++;
+ if (page > endPage || i == lineCount - 1) {
+ break;
+ }
+ }
+ }
+ if (paintY > clientArea.y && paintY <= clientArea.y + clientArea.height) {
+ endPage(page);
+ }
+ }
+ /**
+ * Print header or footer decorations.
+ * * @param page page number to print, if specified in the StyledTextPrintOptions header or footer. * @param header true = print the header, false = print the footer */
+ void printDecoration(int page, boolean header) {
+ int lastSegmentIndex = 0;
+ final int SegmentCount = 3;
+ String text;
+
+ if (header) {
+ text = printOptions.header;
+ }
+ else {
+ text = printOptions.footer;
+ }
+ if (text == null) {
+ return;
+ }
+ for (int i = 0; i < SegmentCount; i++) {
+ int segmentIndex = text.indexOf(StyledTextPrintOptions.SEPARATOR, lastSegmentIndex);
+ String segment;
+
+ if (segmentIndex == -1) {
+ segment = text.substring(lastSegmentIndex);
+ printDecorationSegment(segment, i, page, header);
+ break;
+ }
+ else {
+ segment = text.substring(lastSegmentIndex, segmentIndex);
+ printDecorationSegment(segment, i, page, header);
+ lastSegmentIndex = segmentIndex + StyledTextPrintOptions.SEPARATOR.length();
+ }
+ }
+ }
+ /**
+ * Print one segment of a header or footer decoration.
+ * Headers and footers have three different segments.
+ * One each for left aligned, centered, and right aligned text.
+ *
+ * @param segment decoration segment to print
+ * @param alignment alignment of the segment. 0=left, 1=center, 2=right
+ * @param page page number to print, if specified in the decoration segment.
+ * @param header true = print the header, false = print the footer
+ */
+ void printDecorationSegment(String segment, int alignment, int page, boolean header) {
+ int pageIndex = segment.indexOf(StyledTextPrintOptions.PAGE_TAG);
+
+ if (pageIndex != -1) {
+ final int PageTagLength = StyledTextPrintOptions.PAGE_TAG.length();
+ StringBuffer buffer = new StringBuffer(segment);
+ buffer.replace(pageIndex, pageIndex + PageTagLength, new Integer(page).toString());
+ segment = buffer.toString();
+ }
+ if (segment.length() > 0) {
+ int segmentWidth;
+ int drawX = 0;
+ int drawY;
+ StyledTextBidi bidi = null;
+
+ if (isBidi()) {
+ bidi = new StyledTextBidi(gc, tabLength, segment, null, null, new int[] {0, segment.length()});
+ segmentWidth = bidi.getTextWidth();
+ }
+ else {
+ segmentWidth = gc.textExtent(segment).x;
+ }
+ if (header) {
+ drawY = clientArea.y - renderer.getLineHeight() * 2;
+ }
+ else {
+ drawY = clientArea.y + clientArea.height + renderer.getLineHeight();
+ }
+ if (alignment == LEFT) {
+ drawX = clientArea.x;
+ }
+ else
+ if (alignment == CENTER) {
+ drawX = (pageWidth - segmentWidth) / 2;
+ }
+ else
+ if (alignment == RIGHT) {
+ drawX = clientArea.x + clientArea.width - segmentWidth;
+ }
+ if (bidi != null) {
+ bidi.drawBidiText(0, segment.length(), drawX, drawY);
+ }
+ else {
+ gc.drawString(segment, drawX, drawY, true);
+ }
+ }
+ }
+ /**
+ * Starts a print job and prints the pages specified in the constructor.
+ */
+ public void run() {
+ String jobName = printOptions.jobName;
+
+ if (jobName == null) {
+ jobName = "Printing";
+ }
+ if (printer.startJob(jobName)) {
+ createPrinterColors();
+ initializeRenderer();
+ print();
+ dispose();
+ printer.endJob();
+ }
+ }
+ /**
+ * Start printing a new page.
+ *
+ * @param page page number to be started
+ */
+ void startPage(int page) {
+ printer.startPage();
+ printDecoration(page, true);
+ }
+ }
+ /**
+ * 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();
+ boolean WriteUnicode;
+
+ /**
+ * Creates a RTF writer that writes content starting at offset "start"
+ * in the document. <code>start</code> and <code>length</code>can be set to specify partial
+ * lines.
+ * <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());
+ setUnicode();
+ }
+ /**
+ * Closes the RTF writer. Once closed no more content can be written.
+ * <b>NOTE:</b> <code>toString()</code> does not return a valid RTF string until
+ * <code>close()</code> has been called.
+ */
+ public void close() {
+ if (isClosed() == 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;
+ }
+ /**
+ * Determines if Unicode RTF should be written.
+ * Don't write Unicode RTF on Windows 95/98/ME or NT.
+ */
+ void setUnicode() {
+ final String Win95 = "windows 95";
+ final String Win98 = "windows 98";
+ final String WinME = "windows me";
+ final String WinNT = "windows nt";
+ String osName = System.getProperty("os.name").toLowerCase();
+ String osVersion = System.getProperty("os.version");
+ int majorVersion = 0;
+
+ if (osName.startsWith(WinNT) && osVersion != null) {
+ int majorIndex = osVersion.indexOf('.');
+ if (majorIndex != -1) {
+ osVersion = osVersion.substring(0, majorIndex);
+ try {
+ majorVersion = Integer.parseInt(osVersion);
+ }
+ catch (NumberFormatException exception) {
+ // ignore exception. version number remains unknown.
+ // will write without Unicode
+ }
+ }
+ }
+ if (osName != null &&
+ osName.startsWith(Win95) == false &&
+ osName.startsWith(Win98) == false &&
+ osName.startsWith(WinME) == false &&
+ (osName.startsWith(WinNT) == false || majorVersion > 4)) {
+ WriteUnicode = true;
+ }
+ else {
+ WriteUnicode = false;
+ }
+ }
+ /**
+ * 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) {
+ for (int index = start; index < end; index++) {
+ char ch = string.charAt(index);
+ if (ch > 0xFF && WriteUnicode) {
+ // write the sub string from the last escaped character
+ // to the current one. Fixes bug 21698.
+ if (index > start) {
+ write(string.substring(start, index));
+ }
+ write("\\u");
+ write(Integer.toString((short) ch));
+ write(' '); // control word delimiter
+ start = index + 1;
+ }
+ else
+ if (ch == '}' || ch == '{' || ch == '\\') {
+ // write the sub string from the last escaped character
+ // to the current one. Fixes bug 21698.
+ if (index > start) {
+ write(string.substring(start, index));
+ }
+ write('\\');
+ write(ch);
+ start = index + 1;
+ }
+ }
+ // write from the last escaped character to the end.
+ // Fixes bug 21698.
+ if (start < end) {
+ write(string.substring(start, end));
+ }
+ }
+ /**
+ * Writes the RTF header including font table and color table.
+ */
+ void writeHeader() {
+ StringBuffer header = new StringBuffer();
+ FontData fontData = getFont().getFontData()[0];
+ header.append("{\\rtf1\\ansi");
+ // specify code page, necessary for copy to work in bidi
+ // systems that don't support Unicode RTF.
+ String cpg = System.getProperty("file.encoding").toLowerCase();
+ if (cpg.startsWith("cp") || cpg.startsWith("ms")) {
+ cpg = cpg.substring(2, cpg.length());
+ header.append("\\ansicpg");
+ header.append(cpg);
+ }
+ header.append("\\uc0\\deff0{\\fonttbl{\\f0\\fnil ");
+ header.append(fontData.getName());
+ header.append(";}}\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.</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 = renderer.getLineStyleData(lineOffset, line);
+ if (event != null) {
+ styles = event.styles;
+ }
+ event = renderer.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.</li>
+ * </ul>
+ */
+ public void writeLineDelimiter(String lineDelimiter) {
+ if (isClosed()) {
+ SWT.error(SWT.ERROR_IO);
+ }
+ write(lineDelimiter, 0, lineDelimiter.length());
+ write("\\par ");
+ }
+ /**
+ * Appends the specified line text to the RTF data.
+ * 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 lineEndOffset = Math.min(lineLength, endOffset - lineOffset);
+ 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;
+ }
+ // style starts beyond line end or RTF write end
+ if (start >= lineEndOffset) {
+ break;
+ }
+ // write any unstyled text
+ if (lineIndex < start) {
+ // copy to start of style
+ // style starting betond end of write range or end of line
+ // is guarded against above.
+ write(line, lineIndex, start);
+ lineIndex = start;
+ }
+ // 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 or end of line
+ copyEnd = Math.min(end, lineEndOffset);
+ // guard against invalid styles and let style processing continue
+ copyEnd = Math.max(copyEnd, lineIndex);
+ write(line, lineIndex, copyEnd);
+ if (style.fontStyle == SWT.BOLD) {
+ write("\\b0");
+ }
+ write("}");
+ lineIndex = copyEnd;
+ }
+ // write unstyled text at the end of the line
+ if (lineIndex < lineEndOffset) {
+ write(line, lineIndex, lineEndOffset);
+ }
+ if (lineBackground != null) {
+ write("}");
+ }
+ }
+ }
+ /**
+ * The <code>TextWriter</code> class is used to write widget content to
+ * a string. Whole and partial lines and line breaks can be written. To write
+ * partial lines, specify the start and length of the desired segment
+ * during object creation.
+ * <p>
+ * </b>NOTE:</b> <code>toString()</code> is guaranteed to return a valid string only after close()
+ * has been called.
+ */
+ 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.</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.</li>
+ * </ul>
+ */
+ public void writeLineDelimiter(String lineDelimiter) {
+ if (isClosed) {
+ SWT.error(SWT.ERROR_IO);
+ }
+ write(lineDelimiter);
+ }
+ }
+ /**
+ * LineCache provides an interface to calculate and invalidate
+ * line based data.
+ * Implementors need to return a line width in <code>getWidth</code>.
+ */
+ interface LineCache {
+ /**
+ * Calculates the lines in the specified range.
+ * <p>
+ *
+ * @param startLine first line to calculate
+ * @param lineCount number of lines to calculate
+ */
+ public void calculate(int startLine, int lineCount);
+ /**
+ * Returns a width that will be used by the <code>StyledText</code>
+ * widget to size a horizontal scroll bar.
+ * <p>
+ *
+ * @return the line width
+ */
+ public int getWidth();
+ /**
+ * Resets the lines in the specified range.
+ * This method is called in <code>StyledText.redraw()</code>
+ * and allows implementors to call redraw themselves during reset.
+ * <p>
+ *
+ * @param startLine the first line to reset
+ * @param lineCount the number of lines to reset
+ * @param calculateMaxWidth true=implementors should retain a
+ * valid width even if it is affected by the reset operation.
+ * false=the width may be set to 0
+ */
+ public void redrawReset(int startLine, int lineCount, boolean calculateMaxWidth);
+ /**
+ * Resets the lines in the specified range.
+ * <p>
+ *
+ * @param startLine the first line to reset
+ * @param lineCount the number of lines to reset
+ * @param calculateMaxWidth true=implementors should retain a
+ * valid width even if it is affected by the reset operation.
+ * false=the width may be set to 0
+ */
+ public void reset(int startLine, int lineCount, boolean calculateMaxWidth);
+ /**
+ * Called when a text change occurred.
+ * <p>
+ *
+ * @param startOffset the start offset of the text change
+ * @param newLineCount the number of inserted lines
+ * @param replaceLineCount the number of deleted lines
+ * @param newCharCount the number of new characters
+ * @param replaceCharCount the number of deleted characters
+ */
+ public void textChanged(int startOffset, int newLineCount, int replaceLineCount, int newCharCount, int replaceCharCount);
+ }
+ /**
+ * Keeps track of line widths and the longest line in the
+ * StyledText document.
+ * Line widths are calculated when requested by a call to
+ * <code>calculate</code> and cached until reset by a call
+ * to <code>redrawReset</code> or <code>reset</code>.
+ */
+ class ContentWidthCache implements LineCache {
+ StyledText parent; // parent widget, used to create a GC for line measuring
+ int[] lineWidth; // width in pixel of each line in the document, -1 for unknown width
+ int lineCount; // number of lines in lineWidth array
+ int maxWidth; // maximum line width of all measured lines
+ int maxWidthLineIndex; // index of the widest line
+
+ /**
+ * Creates a new <code>ContentWidthCache</code> and allocates space
+ * for the given number of lines.
+ * <p>
+ *
+ * @param parent the StyledText widget used to create a GC for
+ * line measuring
+ * @param lineCount initial number of lines to allocate space for
+ */
+ public ContentWidthCache(StyledText parent, int lineCount) {
+ this.lineCount = lineCount;
+ this.parent = parent;
+ lineWidth = new int[lineCount];
+ reset(0, lineCount, false);
+ }
+ /**
+ * Calculates the width of each line in the given range if it has
+ * not been calculated yet.
+ * If any line in the given range is wider than the currently widest
+ * line, the maximum line width is updated,
+ * <p>
+ *
+ * @param startLine first line to calculate the line width of
+ * @param lineCount number of lines to calculate the line width for
+ */
+ public void calculate(int startLine, int lineCount) {
+ GC gc = null;
+ int caretWidth = 0;
+ int stopLine = startLine + lineCount;
+
+ for (int i = startLine; i < stopLine; i++) {
+ if (lineWidth[i] == -1) {
+ String line = content.getLine(i);
+ int lineOffset = content.getOffsetAtLine(i);
+
+ if (gc == null) {
+ gc = parent.getGC();
+ caretWidth = getCaretWidth();
+ }
+ lineWidth[i] = contentWidth(line, lineOffset, gc) + caretWidth;
+ }
+ if (lineWidth[i] > maxWidth) {
+ maxWidth = lineWidth[i];
+ maxWidthLineIndex = i;
+ }
+ }
+ if (gc != null) {
+ gc.dispose();
+ }
+ }
+ /**
+ * Calculates the width of the visible lines in the specified
+ * range.
+ * <p>
+ *
+ * @param startLine the first changed line
+ * @param newLineCount the number of inserted lines
+ */
+ void calculateVisible(int startLine, int newLineCount) {
+ int topIndex = parent.getTopIndex();
+ int bottomLine = Math.min(getPartialBottomIndex(), startLine + newLineCount);
+
+ startLine = Math.max(startLine, topIndex);
+ calculate(startLine, bottomLine - startLine + 1);
+ }
+ /**
+ * Measures the width of the given line.
+ * <p>
+ *
+ * @param line the line to measure
+ * @param lineOffset start offset of the line to measure, relative
+ * to the start of the document
+ * @param gc the GC to use for measuring the line
+ * @param currentFont the font currently set in gc. Cached for better
+ * performance. Null when running in a bidi locale.
+ * @return the width of the given line
+ */
+ int contentWidth(String line, int lineOffset, GC gc) {
+ int width;
+
+ if (isBidi()) {
+ StyledTextBidi bidi = getStyledTextBidi(line, lineOffset, gc);
+ width = bidi.getTextWidth();
+ }
+ else {
+ StyledTextEvent event = renderer.getLineStyleData(lineOffset, line);
+ StyleRange[] styles = null;
+ if (event != null) {
+ styles = renderer.filterLineStyles(event.styles);
+ }
+ width = renderer.getTextWidth(line, lineOffset, 0, line.length(), styles, 0, gc);
+ }
+ return width + leftMargin;
+ }
+ /**
+ * Grows the <code>lineWidth</code> array to accomodate new line width
+ * information.
+ * <p>
+ *
+ * @param numLines the number of elements to increase the array by
+ */
+ void expandLines(int numLines) {
+ int size = lineWidth.length;
+ if (size - lineCount >= numLines) {
+ return;
+ }
+ int[] newLines = new int[Math.max(size * 2, size + numLines)];
+ System.arraycopy(lineWidth, 0, newLines, 0, size);
+ lineWidth = newLines;
+ reset(size, lineWidth.length - size, false);
+ }
+ /**
+ * Returns the width of the longest measured line.
+ * <p>
+ *
+ * @return the width of the longest measured line.
+ */
+ public int getWidth() {
+ return maxWidth;
+ }
+ /**
+ * Updates the line width array to reflect inserted or deleted lines.
+ * <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 startLine, int delta) {
+ boolean inserting = delta > 0;
+
+ if (delta == 0) {
+ return;
+ }
+ if (inserting) {
+ // shift the lines down to make room for new lines
+ expandLines(delta);
+ for (int i = lineCount - 1; i >= startLine; i--) {
+ lineWidth[i + delta] = lineWidth[i];
+ }
+ // reset the new lines
+ for (int i = startLine + 1; i <= startLine + delta && i < lineWidth.length; i++) {
+ lineWidth[i] = -1;
+ }
+ // have new lines been inserted above the longest line?
+ if (maxWidthLineIndex >= startLine) {
+ maxWidthLineIndex += delta;
+ }
+ }
+ else {
+ // shift up the lines
+ for (int i = startLine - delta; i < lineCount; i++) {
+ lineWidth[i+delta] = lineWidth[i];
+ }
+ // has the longest line been removed?
+ if (maxWidthLineIndex > startLine && maxWidthLineIndex <= startLine - delta) {
+ maxWidth = 0;
+ maxWidthLineIndex = -1;
+ }
+ else
+ if (maxWidthLineIndex >= startLine - delta) {
+ maxWidthLineIndex += delta;
+ }
+ }
+ lineCount += delta;
+ }
+ /**
+ * Resets the line width of the lines in the specified range.
+ * <p>
+ *
+ * @param startLine the first line to reset
+ * @param lineCount the number of lines to reset
+ * @param calculateMaxWidth true=if the widest line is being
+ * reset the maximum width of all remaining cached lines is
+ * calculated. false=the maximum width is set to 0 if the
+ * widest line is being reset.
+ */
+ public void redrawReset(int startLine, int lineCount, boolean calculateMaxWidth) {
+ reset(startLine, lineCount, calculateMaxWidth);
+ }
+ /**
+ * Resets the line width of the lines in the specified range.
+ * <p>
+ *
+ * @param startLine the first line to reset
+ * @param lineCount the number of lines to reset
+ * @param calculateMaxWidth true=if the widest line is being
+ * reset the maximum width of all remaining cached lines is
+ * calculated. false=the maximum width is set to 0 if the
+ * widest line is being reset.
+ */
+ public void reset(int startLine, int lineCount, boolean calculateMaxWidth) {
+ int endLine = startLine + lineCount;
+
+ if (startLine < 0 || endLine > lineWidth.length) {
+ return;
+ }
+ for (int i = startLine; i < endLine; i++) {
+ lineWidth[i] = -1;
+ }
+ // if the longest line is one of the reset lines, the maximum line
+ // width is no longer valid
+ if (maxWidthLineIndex >= startLine && maxWidthLineIndex < endLine) {
+ maxWidth = 0;
+ maxWidthLineIndex = -1;
+ if (calculateMaxWidth) {
+ for (int i = 0; i < lineCount; i++) {
+ if (lineWidth[i] > maxWidth) {
+ maxWidth = lineWidth[i];
+ maxWidthLineIndex = i;
+ }
+ }
+ }
+ }
+ }
+ /**
+ * Updates the line width array to reflect a text change.
+ * Lines affected by the text change will be reset.
+ * <p>
+ *
+ * @param startOffset the start offset of the text change
+ * @param newLineCount the number of inserted lines
+ * @param replaceLineCount the number of deleted lines
+ * @param newCharCount the number of new characters
+ * @param replaceCharCount the number of deleted characters
+ */
+ public void textChanged(int startOffset, int newLineCount, int replaceLineCount, int newCharCount, int replaceCharCount) {
+ int startLine = parent.getLineAtOffset(startOffset);
+ boolean removedMaxLine = (maxWidthLineIndex > startLine && maxWidthLineIndex <= startLine + replaceLineCount);
+ // entire text deleted?
+ if (startLine == 0 && replaceLineCount == lineCount) {
+ lineCount = newLineCount;
+ lineWidth = new int[lineCount];
+ reset(0, lineCount, false);
+ maxWidth = 0;
+ }
+ else {
+ linesChanged(startLine, -replaceLineCount);
+ linesChanged(startLine, newLineCount);
+ lineWidth[startLine] = -1;
+ }
+ // only calculate the visible lines. otherwise measurements of changed lines
+ // outside the visible area may subsequently change again without the
+ // lines ever being visible.
+ calculateVisible(startLine, newLineCount);
+ // maxWidthLineIndex will be -1 (i.e., unknown line width) if the widget has
+ // not been visible yet and the changed lines have therefore not been
+ // calculated above.
+ if (removedMaxLine ||
+ (maxWidthLineIndex != -1 && lineWidth[maxWidthLineIndex] < maxWidth)) {
+ // longest line has been removed or changed and is now shorter.
+ // need to recalculate maximum content width for all lines
+ maxWidth = 0;
+ for (int i = 0; i < lineCount; i++) {
+ if (lineWidth[i] > maxWidth) {
+ maxWidth = lineWidth[i];
+ maxWidthLineIndex = i;
+ }
+ }
+ }
+ }
+ }
+ /**
+ * Updates the line wrapping of the content.
+ * The line wrapping must always be in a consistent state.
+ * Therefore, when <code>reset</code> or <code>redrawReset</code>
+ * is called, the line wrapping is recalculated immediately
+ * instead of in <code>calculate</code>.
+ */
+ class WordWrapCache implements LineCache {
+ StyledText parent;
+ WrappedContent visualContent;
+
+ /**
+ * Creates a new <code>WordWrapCache</code> and calculates an initial
+ * line wrapping.
+ * <p>
+ *
+ * @param parent the StyledText widget to wrap content in.
+ * @param content the content provider that does the actual line wrapping.
+ */
+ public WordWrapCache(StyledText parent, WrappedContent content) {
+ this.parent = parent;
+ visualContent = content;
+ visualContent.wrapLines();
+ }
+ /**
+ * Do nothing. Lines are wrapped immediately after reset.
+ * <p>
+ *
+ * @param startLine first line to calculate
+ * @param lineCount number of lines to calculate
+ */
+ public void calculate(int startLine, int lineCount) {
+ }
+ /**
+ * Returns the client area width. Lines are wrapped so there
+ * is no horizontal scroll bar.
+ * <p>
+ *
+ * @return the line width
+ */
+ public int getWidth() {
+ return parent.getClientArea().width;
+ }
+ /**
+ * Wraps the lines in the specified range.
+ * This method is called in <code>StyledText.redraw()</code>.
+ * A redraw is therefore not necessary.
+ * <p>
+ *
+ * @param startLine the first line to reset
+ * @param lineCount the number of lines to reset
+ * @param calculateMaxWidth true=implementors should retain a
+ * valid width even if it is affected by the reset operation.
+ * false=the width may be set to 0
+ */
+ public void redrawReset(int startLine, int lineCount, boolean calculateMaxWidth) {
+ if (lineCount == visualContent.getLineCount()) {
+ // do a full rewrap if all lines are reset
+ visualContent.wrapLines();
+ }
+ else {
+ visualContent.reset(startLine, lineCount);
+ }
+ }
+ /**
+ * Rewraps the lines in the specified range and redraws
+ * the widget if the line wrapping has changed.
+ * <p>
+ *
+ * @param startLine the first line to reset
+ * @param lineCount the number of lines to reset
+ * @param calculateMaxWidth true=implementors should retain a
+ * valid width even if it is affected by the reset operation.
+ * false=the width may be set to 0
+ */
+ public void reset(int startLine, int lineCount, boolean calculateMaxWidth) {
+ int itemCount = getPartialBottomIndex() - topIndex + 1;
+ int[] oldLineOffsets = new int[itemCount];
+
+ for (int i = 0; i < itemCount; i++) {
+ oldLineOffsets[i] = visualContent.getOffsetAtLine(i + topIndex);
+ }
+ redrawReset(startLine, lineCount, calculateMaxWidth);
+ // check for cases which will require a full redraw
+ if (getPartialBottomIndex() - topIndex + 1 != itemCount) {
+ // number of visible lines has changed
+ parent.internalRedraw();
+ }
+ else {
+ for (int i = 0; i < itemCount; i++) {
+ if (visualContent.getOffsetAtLine(i + topIndex) != oldLineOffsets[i]) {
+ // wrapping of one of the visible lines has changed
+ parent.internalRedraw();
+ break;
+ }
+ }
+ }
+ }
+ /**
+ * Passes the text change notification to the line wrap content.
+ * <p>
+ *
+ * @param startOffset the start offset of the text change
+ * @param newLineCount the number of inserted lines
+ * @param replaceLineCount the number of deleted lines
+ * @param newCharCount the number of new characters
+ * @param replaceCharCount the number of deleted characters
+ */
+ public void textChanged(int startOffset, int newLineCount, int replaceLineCount, int newCharCount, int replaceCharCount) {
+ int startLine = visualContent.getLineAtOffset(startOffset);
+
+ visualContent.textChanged(startOffset, newLineCount, replaceLineCount, newCharCount, replaceCharCount);
+ if (startLine <= getPartialBottomIndex()) {
+ // only redraw if the text change is inside or above the
+ // visible lines. if it is below the visible lines it will
+ // not affect the word wrapping. fixes bug 14047.
+ parent.internalRedraw();
+ }
+ }
+ }
+
+/**
+ * Constructs a new instance of this class given its parent
+ * and a style value describing its behavior and appearance.
+ * <p>
+ * The style value is either one of the style constants defined in
+ * class <code>SWT</code> which is applicable to instances of this
+ * class, or must be built by <em>bitwise OR</em>'ing together
+ * (that is, using the <code>int</code> "|" operator) two or more
+ * of those <code>SWT</code> style constants. The class description
+ * lists the style constants that are applicable to the class.
+ * Style bits are also inherited from superclasses.
+ * </p>
+ *
+ * @param parent a widget which will be the parent of the new instance (cannot be null)
+ * @param style the style of widget to construct
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
+ * </ul>
+ *
+ * @see SWT#FULL_SELECTION
+ * @see SWT#MULTI
+ * @see SWT#READ_ONLY
+ * @see SWT#SINGLE
+ * @see SWT#WRAP
+ * @see #getStyle
+ */
+public StyledText(Composite parent, int style) {
+ super(parent, checkStyle(style | SWT.NO_REDRAW_RESIZE | SWT.NO_BACKGROUND));
+ // set the bg/fg in the OS to ensure that these are the same as StyledText, necessary
+ // for ensuring that the bg/fg the IME box uses is the same as what StyledText uses
+ super.setForeground(getForeground());
+ super.setBackground(getBackground());
+ Display display = getDisplay();
+ isBidi = StyledTextBidi.isBidiPlatform();
+ if ((style & SWT.READ_ONLY) != 0) {
+ setEditable(false);
+ }
+ if ((style & SWT.BORDER) == 0 || (style & SWT.SINGLE) == 0) {
+ leftMargin = topMargin = rightMargin = bottomMargin = 0;
+ }
+ clipboard = new Clipboard(display);
+ installDefaultContent();
+ initializeRenderer();
+ if ((style & SWT.WRAP) != 0) {
+ setWordWrap(true);
+ }
+ else {
+ lineCache = new ContentWidthCache(this, content.getLineCount());
+ }
+ if (isBidi() == false) {
+ Caret caret = new Caret(this, SWT.NULL);
+ caret.setSize(1, caret.getSize().y);
+ }
+ else {
+ createCaretBitmaps();
+ new Caret(this, SWT.NULL);
+ setBidiCaretDirection();
+ Runnable runnable = new Runnable() {
+ public void run() {
+ // setBidiCaretLocation calculates caret location like during
+ // cursor movement and takes keyboard language into account.
+ // Fixes 1GKPYMK
+ setBidiCaretLocation(null);
+ }
+ };
+ StyledTextBidi.addLanguageListener(this, runnable);
+ }
+
+ String platform= SWT.getPlatform();
+ isCarbon = "carbon".equals(platform);
+
+ // set the caret width, the height of the caret will default to the line height
+ calculateScrollBars();
+ createKeyBindings();
+ ibeamCursor = new Cursor(display, SWT.CURSOR_IBEAM);
+ setCursor(ibeamCursor);
+ 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. Preferred state masks are one or more of
+ * SWT.MOD1, SWT.MOD2, SWT.MOD3, since these masks account for modifier platform
+ * differences. However, there may be cases where using the specific state masks
+ * (i.e., SWT.CTRL, SWT.SHIFT, SWT.ALT, SWT.COMMAND) makes sense.
+ * @param action one of the predefined actions defined in ST.java.
+ * Use SWT.NULL to remove a key binding.
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setKeyBinding(int key, int action) {
+ checkWidget();
+
+ int keyValue = key & SWT.KEY_MASK;
+ int modifierValue = key & SWT.MODIFIER_MASK;
+ char keyChar = (char)keyValue;
+
+ if (Character.isLetter(keyChar)) {
+ // make the keybinding case insensitive by adding it
+ // in its upper and lower case form
+ char ch = Character.toUpperCase(keyChar);
+ int newKey = ch | modifierValue;
+ if (action == SWT.NULL) {
+ keyActionMap.remove(new Integer(newKey));
+ }
+ else {
+ keyActionMap.put(new Integer(newKey), new Integer(action));
+ }
+ ch = Character.toLowerCase(keyChar);
+ newKey = ch | modifierValue;
+ if (action == SWT.NULL) {
+ keyActionMap.remove(new Integer(newKey));
+ }
+ else {
+ keyActionMap.put(new Integer(newKey), new Integer(action));
+ }
+ } else {
+ if (action == SWT.NULL) {
+ keyActionMap.remove(new Integer(key));
+ }
+ else {
+ keyActionMap.put(new Integer(key), new Integer(action));
+ }
+ }
+
+}
+/**
+ * Adds a bidirectional segment listener. A BidiSegmentEvent is sent
+ * whenever a line of text is measured or rendered. The user can
+ * specify text ranges in the line that should be treated as if they
+ * had a different direction than the surrounding text.
+ * This may be used when adjacent segments of right-to-left text should
+ * not be reordered relative to each other.
+ * E.g., Multiple Java string literals in a right-to-left language
+ * should generally remain in logical order to each other, that is, the
+ * way they are stored.
+ * <p>
+ *
+ * @param listener the listener
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT when listener is null</li>
+ * </ul>
+ * @see BidiSegmentEvent
+ * @since 2.0
+ */
+public void addBidiSegmentListener(BidiSegmentListener listener) {
+ checkWidget();
+ if (listener == null) {
+ SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ }
+ StyledTextListener typedListener = new StyledTextListener(listener);
+ addListener(LineGetSegments, typedListener);
+}
+/**
+ * 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, logicalContent.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) {
+ lineCache = getLineCache(content);
+ lineCache.calculate(topIndex, getPartialBottomIndex() - topIndex + 1);
+ }
+}
+/**
+ * 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());
+ }
+}
+/**
+ * Calculates the top index based on the current vertical scroll offset.
+ * The top index is the index of the topmost fully visible line or the
+ * topmost partially visible line if no line is fully visible.
+ * The top index starts at 0.
+ */
+void calculateTopIndex() {
+ int oldTopIndex = topIndex;
+ int verticalIncrement = getVerticalIncrement();
+ int clientAreaHeight = getClientArea().height;
+
+ if (verticalIncrement == 0) {
+ return;
+ }
+ topIndex = Compatibility.ceil(verticalScrollOffset, verticalIncrement);
+ // Set top index to partially visible top line if no line is fully
+ // visible but at least some of the widget client area is visible.
+ // Fixes bug 15088.
+ if (topIndex > 0) {
+ if (clientAreaHeight > 0) {
+ int bottomPixel = verticalScrollOffset + clientAreaHeight;
+ int fullLineTopPixel = topIndex * verticalIncrement;
+ int fullLineVisibleHeight = bottomPixel - fullLineTopPixel;
+ // set top index to partially visible line if no line fully fits in
+ // client area or if space is available but not used (the latter should
+ // never happen because we use claimBottomFreeSpace)
+ if (fullLineVisibleHeight < verticalIncrement) {
+ topIndex--;
+ }
+ }
+ else
+ if (topIndex >= content.getLineCount()) {
+ topIndex = content.getLineCount() - 1;
+ }
+ }
+ if (topIndex != oldTopIndex) {
+ topOffset = content.getOffsetAtLine(topIndex);
+ lineCache.calculate(topIndex, getPartialBottomIndex() - topIndex + 1);
+ setHorizontalScrollBar();
+ }
+}
+/**
+ * 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 newVerticalOffset = Math.max(0, content.getLineCount() * lineHeight - getClientArea().height);
+
+ if (newVerticalOffset < verticalScrollOffset) {
+ // Scroll up so that empty lines below last text line are used.
+ // Fixes 1GEYJM0
+ setVerticalScrollOffset(newVerticalOffset, true);
+ }
+}
+/**
+ * Scrolls text to the right to use new space made available by a resize.
+ */
+void claimRightFreeSpace() {
+ int newHorizontalOffset = Math.max(0, lineCache.getWidth() - (getClientArea().width - leftMargin - rightMargin));
+
+ if (newHorizontalOffset < horizontalScrollOffset) {
+ // item is no longer drawn past the right border of the client area
+ // align the right end of the item with the right border of the
+ // client area (window is scrolled right).
+ scrollHorizontalBar(newHorizontalOffset - horizontalScrollOffset);
+ }
+}
+/**
+ * Clears the widget margin.
+ *
+ * @param gc GC to render on
+ * @param background background color to use for clearing the margin
+ * @param clientArea widget client area dimensions
+ * @param renderHeight height in pixel of the rendered lines
+ */
+void clearMargin(GC gc, Color background, Rectangle clientArea, int renderHeight) {
+ if (renderHeight + topMargin <= 0) {
+ return;
+ }
+ // clear the margin background
+ gc.setBackground(background);
+ gc.fillRectangle(0, 0, clientArea.width, topMargin);
+ gc.fillRectangle(0, 0, leftMargin, renderHeight + topMargin);
+ gc.fillRectangle(
+ 0, clientArea.height - bottomMargin,
+ clientArea.width, bottomMargin);
+ gc.fillRectangle(
+ clientArea.width - rightMargin, 0,
+ rightMargin, renderHeight + topMargin);
+}
+/**
+ * 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) {
+ internalRedrawRange(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;
+ boolean singleLine = (getStyle() & SWT.SINGLE) != 0;
+
+ if (singleLine) {
+ count = 1;
+ } else {
+ count = content.getLineCount();
+ }
+ if (wHint != SWT.DEFAULT) {
+ width = wHint;
+ }
+ else {
+ width = DEFAULT_WIDTH;
+ }
+
+ if (wordWrap) {
+ if (((WrappedContent) content).getVisualLineCount() != 0) {
+ // lines have already been wrapped to a specific width.
+ // use existing line count. fixes bug 9191
+ if (wHint == SWT.DEFAULT) {
+ width = lineCache.getWidth();
+ } else {
+ ((WrappedContent) content).wrapLines(width);
+ // caret may be on a different line after a rewrap
+ setCaretLocation();
+ }
+ if (singleLine == false) {
+ count = content.getLineCount();
+ }
+ }
+ else {
+ if (singleLine == false) {
+ ((WrappedContent) content).wrapLines(width);
+ // caret may be on a different line after a rewrap
+ setCaretLocation();
+ count = content.getLineCount();
+ }
+ }
+ }
+ else if (wHint == SWT.DEFAULT) {
+ // 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().height / lineHeight);
+ lineCache.calculate(0, visibleCount);
+ width = lineCache.getWidth() + leftMargin + rightMargin;
+ }
+ if (hHint != SWT.DEFAULT) {
+ height = hHint;
+ }
+ else {
+ height = count * lineHeight + topMargin + bottomMargin;
+ }
+ // Use default values if no text is defined.
+ if (width == 0) {
+ width = DEFAULT_WIDTH;
+ }
+ if (height == 0) {
+ if (singleLine) {
+ height = lineHeight;
+ }
+ else {
+ height = DEFAULT_HEIGHT;
+ }
+ }
+ Rectangle rect = computeTrim(0, 0, width, height);
+ return new Point (rect.width, rect.height);
+}
+/**
+ * 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) {
+ try {
+ setClipboardContent(selection.x, length);
+ }
+ catch (SWTError error) {
+ // Copy to clipboard failed. This happens when another application
+ // is accessing the clipboard while we copy. Ignore the error.
+ // Fixes 1GDQAVN
+ // Rethrow all other errors. Fixes bug 17578.
+ if (error.code != DND.ERROR_CANNOT_SET_CLIPBOARD) {
+ throw error;
+ }
+ }
+ }
+}
+/**
+ * Returns 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.MOD1, ST.WORD_PREVIOUS);
+ setKeyBinding(SWT.ARROW_RIGHT | SWT.MOD1, ST.WORD_NEXT);
+ setKeyBinding(SWT.HOME | SWT.MOD1, ST.TEXT_START);
+ setKeyBinding(SWT.END | SWT.MOD1, ST.TEXT_END);
+ setKeyBinding(SWT.PAGE_UP | SWT.MOD1, ST.WINDOW_START);
+ setKeyBinding(SWT.PAGE_DOWN | SWT.MOD1, ST.WINDOW_END);
+ // Selection
+ setKeyBinding(SWT.ARROW_UP | SWT.MOD2, ST.SELECT_LINE_UP);
+ setKeyBinding(SWT.ARROW_DOWN | SWT.MOD2, ST.SELECT_LINE_DOWN);
+ setKeyBinding(SWT.HOME | SWT.MOD2, ST.SELECT_LINE_START);
+ setKeyBinding(SWT.END | SWT.MOD2, ST.SELECT_LINE_END);
+ setKeyBinding(SWT.ARROW_LEFT | SWT.MOD2, ST.SELECT_COLUMN_PREVIOUS);
+ setKeyBinding(SWT.ARROW_RIGHT | SWT.MOD2, ST.SELECT_COLUMN_NEXT);
+ setKeyBinding(SWT.PAGE_UP | SWT.MOD2, ST.SELECT_PAGE_UP);
+ setKeyBinding(SWT.PAGE_DOWN | SWT.MOD2, ST.SELECT_PAGE_DOWN);
+ setKeyBinding(SWT.ARROW_LEFT | SWT.MOD1 | SWT.MOD2, ST.SELECT_WORD_PREVIOUS);
+ setKeyBinding(SWT.ARROW_RIGHT | SWT.MOD1 | SWT.MOD2, ST.SELECT_WORD_NEXT);
+ setKeyBinding(SWT.HOME | SWT.MOD1 | SWT.MOD2, ST.SELECT_TEXT_START);
+ setKeyBinding(SWT.END | SWT.MOD1 | SWT.MOD2, ST.SELECT_TEXT_END);
+ setKeyBinding(SWT.PAGE_UP | SWT.MOD1 | SWT.MOD2, ST.SELECT_WINDOW_START);
+ setKeyBinding(SWT.PAGE_DOWN | SWT.MOD1 | SWT.MOD2, ST.SELECT_WINDOW_END);
+
+ // Modification
+ // Cut, Copy, Paste
+ setKeyBinding('X' | SWT.MOD1, ST.CUT);
+ setKeyBinding('C' | SWT.MOD1, ST.COPY);
+ setKeyBinding('V' | SWT.MOD1, ST.PASTE);
+ // Cut, Copy, Paste Wordstar style
+ setKeyBinding(SWT.DEL | SWT.MOD2, ST.CUT);
+ setKeyBinding(SWT.INSERT | SWT.MOD1, ST.COPY);
+ setKeyBinding(SWT.INSERT | SWT.MOD2, ST.PASTE);
+ setKeyBinding(SWT.BS | SWT.MOD2, ST.DELETE_PREVIOUS);
+
+ setKeyBinding(SWT.BS, ST.DELETE_PREVIOUS);
+ setKeyBinding(SWT.DEL, ST.DELETE_NEXT);
+ setKeyBinding(SWT.BS | SWT.MOD1, ST.DELETE_WORD_PREVIOUS);
+ setKeyBinding(SWT.DEL | SWT.MOD1, ST.DELETE_WORD_NEXT);
+
+ // Miscellaneous
+ setKeyBinding(SWT.INSERT, ST.TOGGLE_OVERWRITE);
+}
+/**
+ * Create the bitmaps to use for the caret in bidi mode. This
+ * method only needs to be called upon widget creation and when the
+ * font changes (the caret bitmap height needs to match font height).
+ */
+void createCaretBitmaps() {
+ int caretWidth = BIDI_CARET_WIDTH;
+
+ Display display = getDisplay();
+ if (caretPalette == null) {
+ caretPalette = new PaletteData(new RGB[] {new RGB (0,0,0), new RGB (255,255,255)});
+ }
+ if (leftCaretBitmap != null) {
+ leftCaretBitmap.dispose();
+ }
+ ImageData imageData = new ImageData(caretWidth, lineHeight, 1, caretPalette);
+ leftCaretBitmap = new Image(display, imageData);
+ GC gc = new GC (leftCaretBitmap);
+ gc.setForeground(display.getSystemColor(SWT.COLOR_WHITE));
+ gc.drawLine(0,0,0,lineHeight);
+ gc.drawLine(0,0,caretWidth-1,0);
+ gc.drawLine(0,1,1,1);
+ gc.dispose();
+
+ if (rightCaretBitmap != null) {
+ rightCaretBitmap.dispose();
+ }
+ rightCaretBitmap = new Image(display, imageData);
+ gc = new GC (rightCaretBitmap);
+ gc.setForeground(display.getSystemColor(SWT.COLOR_WHITE));
+ gc.drawLine(caretWidth-1,0,caretWidth-1,lineHeight);
+ gc.drawLine(0,0,caretWidth-1,0);
+ gc.drawLine(caretWidth-1,1,1,1);
+ gc.dispose();
+}
+/**
+ * Moves the selected text to the clipboard. The text will be put in the
+ * clipboard in plain text format and RTF format.
+ * <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();
+ int length = selection.y - selection.x;
+
+ if (length > 0) {
+ try {
+ setClipboardContent(selection.x, length);
+ }
+ catch (SWTError error) {
+ // Copy to clipboard failed. This happens when another application
+ // is accessing the clipboard while we copy. Ignore the error.
+ // Fixes 1GDQAVN
+ // Rethrow all other errors. Fixes bug 17578.
+ if (error.code != DND.ERROR_CANNOT_SET_CLIPBOARD) {
+ throw error;
+ }
+ // Abort cut operation if copy to clipboard fails.
+ // Fixes bug 21030.
+ return;
+ }
+ doDelete();
+ }
+}
+/**
+ * A mouse move event has occurred. See if we should start autoscrolling. If
+ * the move position is outside of the client area, initiate autoscrolling.
+ * Otherwise, we've moved back into the widget so end autoscrolling.
+ */
+void doAutoScroll(Event event) {
+ Rectangle area = getClientArea();
+
+ if (event.y > area.height) {
+ doAutoScroll(SWT.DOWN);
+ }
+ else
+ if (event.y < 0) {
+ doAutoScroll(SWT.UP);
+ }
+ else
+ if (event.x < leftMargin && wordWrap == false) {
+ doAutoScroll(SWT.LEFT);
+ }
+ else
+ if (event.x > area.width - leftMargin - rightMargin && wordWrap == false) {
+ 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) {
+ doSelectionLineUp();
+ display.timerExec(TIMER_INTERVAL, this);
+ }
+ }
+ };
+ } else if (direction == SWT.DOWN) {
+ timer = new Runnable() {
+ public void run() {
+ if (autoScrollDirection == SWT.DOWN) {
+ doSelectionLineDown();
+ display.timerExec(TIMER_INTERVAL, this);
+ }
+ }
+ };
+ } else if (direction == SWT.RIGHT) {
+ timer = new Runnable() {
+ public void run() {
+ if (autoScrollDirection == SWT.RIGHT) {
+ doColumnRight();
+ setMouseWordSelectionAnchor();
+ doSelection(SWT.RIGHT);
+ display.timerExec(TIMER_INTERVAL, this);
+ }
+ }
+ };
+ } else if (direction == SWT.LEFT) {
+ timer = new Runnable() {
+ public void run() {
+ if (autoScrollDirection == SWT.LEFT) {
+ doColumnLeft();
+ setMouseWordSelectionAnchor();
+ doSelection(SWT.LEFT);
+ display.timerExec(TIMER_INTERVAL, this);
+ }
+ }
+ };
+ }
+ if (timer != null) {
+ autoScrollDirection = direction;
+ display.timerExec(TIMER_INTERVAL, timer);
+ }
+}
+/**
+ * Deletes the previous character. Delete the selected text if any.
+ * Move the caret in front of the deleted text.
+ */
+void doBackspace() {
+ Event event = new Event();
+ event.text = "";
+ if (selection.x != selection.y) {
+ event.start = selection.x;
+ event.end = selection.y;
+ sendKeyEvent(event);
+ }
+ else
+ if (caretOffset > 0) {
+ int 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);
+ }
+}
+/**
+ * Moves the caret one character to the left. Do not go to the previous line.
+ * When in a bidi locale and at a R2L character the caret is moved to the
+ * beginning of the R2L segment (visually right) and then one character to the
+ * left (visually left because it's now in a L2R segment).
+ */
+void doColumnLeft() {
+ int line = content.getLineAtOffset(caretOffset);
+ int lineOffset = content.getOffsetAtLine(line);
+ int offsetInLine = caretOffset - lineOffset;
+
+ if (isBidi()) {
+ String lineText = content.getLine(line);
+ int lineLength = lineText.length();
+ GC gc = getGC();
+ StyledTextBidi bidi = getStyledTextBidi(lineText, lineOffset, gc);
+
+ if (horizontalScrollOffset > 0 || offsetInLine > 0) {
+ if (offsetInLine < lineLength && bidi.isRightToLeft(offsetInLine)) {
+ // advance caret logically if in R2L segment (move visually left)
+ caretOffset++;
+ doSelection(SWT.RIGHT);
+ if (caretOffset - lineOffset == lineLength) {
+ // if the line end is reached in a R2L segment, make the
+ // caret position (visual left border) visible before
+ // jumping to segment start
+ showCaret();
+ }
+ // end of R2L segment reached (visual left side)?
+ if (bidi.isRightToLeft(caretOffset - lineOffset) == false) {
+ if (bidi.getTextPosition(caretOffset - lineOffset) < horizontalScrollOffset) {
+ // make beginning of R2L segment visible before going
+ // left, to L2R segment important if R2L segment ends
+ // at visual left in order to scroll all the way to the
+ // left. Fixes 1GKM3XS
+ showCaret();
+ }
+ // go to beginning of R2L segment (visually end of next L2R
+ // segment)/beginning of line
+ caretOffset--;
+ while (caretOffset - lineOffset > 0 &&
+ bidi.isRightToLeft(caretOffset - lineOffset)) {
+ caretOffset--;
+ }
+ }
+ }
+ else
+ if (offsetInLine == lineLength &&
+ bidi.getTextPosition(lineLength) != XINSET) {
+ // at logical line end in R2L segment but there's more text (a
+ // L2R segment) go to end of R2L segment (visually left of next
+ // L2R segment)/end of line
+ caretOffset--;
+ while (caretOffset - lineOffset > 0 &&
+ bidi.isRightToLeft(caretOffset - lineOffset)) {
+ caretOffset--;
+ }
+ }
+ else
+ if (offsetInLine > 0 && bidi.isRightToLeft(offsetInLine) == false) {
+ // decrease caret logically if in L2R segment (move visually left)
+ caretOffset--;
+ doSelection(SWT.LEFT);
+ // end of L2R segment reached (visual left side of preceeding R2L
+ // segment)?
+ if (caretOffset - lineOffset > 0 &&
+ bidi.isRightToLeft(caretOffset - lineOffset - 1)) {
+ // go to beginning of R2L segment (visually start of next L2R
+ // segment)/beginning of line
+ caretOffset--;
+ while (caretOffset - lineOffset > 0 &&
+ bidi.isRightToLeft(caretOffset - lineOffset - 1)) {
+ caretOffset--;
+ }
+ }
+ }
+ // if new caret position is to the left of the client area
+ if (bidi.getTextPosition(caretOffset - lineOffset) < horizontalScrollOffset) {
+ // scroll to the caret position
+ showCaret();
+ }
+ else {
+ // otherwise just update caret position without scrolling it into view
+ setBidiCaretLocation(null);
+ setBidiKeyboardLanguage();
+ }
+ // Beginning of line reached (auto scroll finished) but not scrolled
+ // completely to the left? Fixes 1GKM193
+ if (caretOffset - lineOffset == 0 && horizontalScrollOffset > 0 &&
+ horizontalScrollOffset <= XINSET) {
+ scrollHorizontalBar(-horizontalScrollOffset);
+ }
+ }
+ gc.dispose();
+ }
+ else
+ if (offsetInLine > 0) {
+ caretOffset--;
+ showCaret();
+ }
+}
+/**
+ * Moves the caret one character to the right. Do not go to the next line.
+ * When in a bidi locale and at a R2L character the caret is moved to the
+ * end of the R2L segment (visually left) and then one character to the
+ * right (visually right because it's now in a L2R segment).
+ */
+void doColumnRight() {
+ int line = content.getLineAtOffset(caretOffset);
+ int lineOffset = content.getOffsetAtLine(line);
+ int offsetInLine = caretOffset - lineOffset;
+ String lineText = content.getLine(line);
+ int lineLength = lineText.length();
+
+ if (isBidi()) {
+ GC gc = getGC();
+ StyledTextBidi bidi = getStyledTextBidi(lineText, lineOffset, gc);
+ if (bidi.getTextWidth() + leftMargin > horizontalScrollOffset + getClientArea().width ||
+ offsetInLine < lineLength) {
+ if (bidi.isRightToLeft(offsetInLine) == false &&
+ offsetInLine < lineLength) {
+ // advance caret logically if in L2R segment (move visually right)
+ caretOffset++;
+ doSelection(SWT.RIGHT);
+ // end of L2R segment reached (visual right side)?
+ if (bidi.isRightToLeft(caretOffset - lineOffset)) {
+ // go to end of R2L segment (visually left of next R2L segment)/
+ // end of line
+ caretOffset++;
+ while (caretOffset < lineOffset + lineLength &&
+ bidi.isRightToLeft(caretOffset - lineOffset)) {
+ caretOffset++;
+ }
+ }
+ }
+ else
+ if (offsetInLine > 0 &&
+ (bidi.isRightToLeft(offsetInLine) ||
+ bidi.getTextWidth() + leftMargin > horizontalScrollOffset + getClientArea().width ||
+ offsetInLine < lineLength)) {
+ // advance caret visually if in R2L segment or logically at line end
+ // but right end of line is not fully visible yet
+ caretOffset--;
+ doSelection(SWT.LEFT);
+ offsetInLine = caretOffset - lineOffset;
+ // end of R2L segment reached (visual right side)?
+ if (offsetInLine > 0 && bidi.isRightToLeft(offsetInLine) == false) {
+ // go to end of R2L segment (visually left of next L2R segment)/
+ // end of line
+ caretOffset++;
+ while (caretOffset < lineOffset + lineLength &&
+ bidi.isRightToLeft(caretOffset - lineOffset)) {
+ caretOffset++;
+ }
+ }
+ }
+ else
+ if (offsetInLine == 0 && bidi.getTextPosition(0) != bidi.getTextWidth()) {
+ // at logical line start in R2L segment but there's more text (a L2R
+ // segment) go to end of R2L segment (visually left of next L2R
+ // segment)/end of line
+ caretOffset++;
+ while (caretOffset < lineOffset + lineLength &&
+ bidi.isRightToLeft(caretOffset - lineOffset - 1)) {
+ caretOffset++;
+ }
+ }
+ offsetInLine = caretOffset - lineOffset;
+ // if new caret position is to the right of the client area
+ if (bidi.getTextPosition(offsetInLine) >= horizontalScrollOffset) {
+ // scroll to the caret position
+ showCaret();
+ }
+ else {
+ // otherwise just update caret position without scrolling it into view
+ setBidiCaretLocation(null);
+ setBidiKeyboardLanguage();
+ }
+ if (offsetInLine > 0 && offsetInLine < lineLength - 1) {
+ int clientAreaEnd = horizontalScrollOffset + getClientArea().width;
+ boolean directionChange = bidi.isRightToLeft(offsetInLine - 1) == false && bidi.isRightToLeft(offsetInLine);
+ int textWidth = bidi.getTextWidth() + leftMargin;
+ // between L2R and R2L segment and second character of R2L segment is
+ // left of right border and logical line end is left of right border
+ // but visual line end is not left of right border
+ if (directionChange &&
+ bidi.isRightToLeft(offsetInLine + 1) &&
+ bidi.getTextPosition(offsetInLine + 1) + leftMargin < clientAreaEnd &&
+ bidi.getTextPosition(lineLength) + leftMargin < clientAreaEnd && textWidth > clientAreaEnd) {
+ // make visual line end visible
+ scrollHorizontalBar(textWidth - clientAreaEnd);
+ }
+ }
+ }
+ gc.dispose();
+ }
+ else
+ if (offsetInLine < lineLength) {
+ 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() {
+ // place caret at end of first line if receiver is in single
+ // line mode. fixes 4820.
+ if (isSingleLine()) {
+ doLineEnd();
+ }
+ else {
+ int length = content.getCharCount();
+ if (caretOffset < length) {
+ caretOffset = length;
+ showCaret();
+ }
+ }
+}
+/**
+ * Moves the caret in front of the first character of the widget content.
+ */
+void doContentStart() {
+ if (caretOffset > 0) {
+ caretOffset = 0;
+ showCaret();
+ }
+}
+/**
+ * Moves the caret to the start of the selection if a selection exists.
+ * Otherwise, if no selection exists move the cursor according to the
+ * cursor selection rules.
+ * <p>
+ *
+ * @see #doSelectionCursorPrevious
+ */
+void doCursorPrevious() {
+ if (selection.y - selection.x > 0) {
+ int caretLine;
+
+ caretOffset = selection.x;
+ caretLine = getCaretLine();
+ showCaret(caretLine);
+ }
+ else {
+ doSelectionCursorPrevious();
+ }
+}
+/**
+ * Moves the caret to the end of the selection if a selection exists.
+ * Otherwise, if no selection exists move the cursor according to the
+ * cursor selection rules.
+ * <p>
+ *
+ * @see #doSelectionCursorNext
+ */
+void doCursorNext() {
+ if (selection.y - selection.x > 0) {
+ int caretLine;
+
+ caretOffset = selection.y;
+ caretLine = getCaretLine();
+ showCaret(caretLine);
+ }
+ else {
+ doSelectionCursorNext();
+ }
+}
+/**
+ * Deletes the next character. Delete the selected text if any.
+ */
+void doDelete() {
+ Event event = new Event();
+
+ event.text = "";
+ if (selection.x != selection.y) {
+ event.start = selection.x;
+ event.end = selection.y;
+ sendKeyEvent(event);
+ }
+ else
+ if (caretOffset < content.getCharCount()) {
+ int line = content.getLineAtOffset(caretOffset);
+ int lineOffset = content.getOffsetAtLine(line);
+ int lineLength = content.getLine(line).length();
+
+ if (caretOffset == lineOffset + lineLength) {
+ event.start = caretOffset;
+ event.end = content.getOffsetAtLine(line + 1);
+ }
+ else {
+ event.start = caretOffset;
+ event.end = caretOffset + 1;
+ }
+ sendKeyEvent(event);
+ }
+}
+/**
+ * Deletes the next word.
+ */
+void doDeleteWordNext() {
+ if (selection.x != selection.y) {
+ // if a selection exists, treat the as if
+ // only the delete key was pressed
+ doDelete();
+ } else {
+ Event event = new Event();
+ event.text = "";
+ event.start = caretOffset;
+ event.end = getWordEnd(caretOffset);
+ sendKeyEvent(event);
+ }
+}
+/**
+ * Deletes the previous word.
+ */
+void doDeleteWordPrevious() {
+ if (selection.x != selection.y) {
+ // if a selection exists, treat as if
+ // only the backspace key was pressed
+ doBackspace();
+ } else {
+ Event event = new Event();
+ event.text = "";
+ event.start = getWordStart(caretOffset);
+ event.end = caretOffset;
+ sendKeyEvent(event);
+ }
+}
+/**
+ * Moves the caret one line down and to the same character offset relative
+ * to the beginning of the line. Move the caret to the end of the new line
+ * if the new line is shorter than the character offset.
+ *
+ * @return index of the new line relative to the first line in the document
+ */
+int doLineDown() {
+ if (isSingleLine()) {
+ return 0;
+ }
+ // allow line down action only if receiver is not in single line mode.
+ // fixes 4820.
+ int caretLine = getCaretLine();
+ if (caretLine < content.getLineCount() - 1) {
+ caretLine++;
+ if (isBidi()) {
+ caretOffset = getBidiOffsetAtMouseLocation(columnX, caretLine);
+ }
+ else {
+ caretOffset = getOffsetAtMouseLocation(columnX, caretLine);
+ }
+ }
+ return caretLine;
+}
+/**
+ * Moves the caret to the end of the line.
+ */
+void doLineEnd() {
+ int caretLine = getCaretLine();
+ int lineOffset = content.getOffsetAtLine(caretLine);
+ int lineLength = content.getLine(caretLine).length();
+ int lineEndOffset = lineOffset + lineLength;
+
+ if (caretOffset < lineEndOffset) {
+ caretOffset = lineEndOffset;
+ showCaret();
+ }
+}
+/**
+ * Moves the caret to the beginning of the line.
+ */
+void doLineStart() {
+ int caretLine = getCaretLine();
+ int lineOffset = content.getOffsetAtLine(caretLine);
+
+ if (caretOffset > lineOffset) {
+ caretOffset = lineOffset;
+ showCaret(caretLine);
+ }
+}
+/**
+ * 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.
+ *
+ * @return index of the new line relative to the first line in the document
+ */
+int doLineUp() {
+ int caretLine = getCaretLine();
+
+ if (caretLine > 0) {
+ caretLine--;
+ if (isBidi()) {
+ caretOffset = getBidiOffsetAtMouseLocation(columnX, caretLine);
+ }
+ else {
+ caretOffset = getOffsetAtMouseLocation(columnX, caretLine);
+ }
+ }
+ return caretLine;
+}
+/**
+ * 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) / lineHeight;
+ int lineCount = content.getLineCount();
+ int newCaretOffset;
+ int newCaretLine;
+
+ if (line > lineCount - 1) {
+ line = lineCount - 1;
+ }
+ // allow caret to be placed below first line only if receiver is
+ // not in single line mode. fixes 4820.
+ if (line < 0 || (isSingleLine() && line > 0)) {
+ return;
+ }
+ if (isBidi()) {
+ newCaretOffset = getBidiOffsetAtMouseLocation(x, line);
+ }
+ else {
+ newCaretOffset = getOffsetAtMouseLocation(x, line);
+ }
+ if (mouseDoubleClick) {
+ // double click word select the previous/next word. fixes bug 15610
+ newCaretOffset = doMouseWordSelect(x, newCaretOffset, line);
+ }
+ newCaretLine = content.getLineAtOffset(newCaretOffset);
+ // Is the mouse within the left client area border or on
+ // a different line? If not the autoscroll selection
+ // could be incorrectly reset. Fixes 1GKM3XS
+ if (y >= 0 && y < getClientArea().height &&
+ (x >= 0 || newCaretLine != content.getLineAtOffset(caretOffset))) {
+ 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);
+ }
+}
+/**
+ * Returns the offset of the word at the specified offset.
+ * If the current selection extends from high index to low index
+ * (i.e., right to left, or caret is at left border of selecton on
+ * non-bidi platforms) the start offset of the word preceeding the
+ * selection is returned. If the current selection extends from
+ * low index to high index the end offset of the word following
+ * the selection is returned.
+ *
+ * @param x mouse x location
+ * @param newCaretOffset caret offset of the mouse cursor location
+ * @param line line index of the mouse cursor location
+ */
+int doMouseWordSelect(int x, int newCaretOffset, int line) {
+ int wordOffset;
+
+ // flip selection anchor based on word selection direction from
+ // base double click. Always do this here (and don't rely on doAutoScroll)
+ // because auto scroll only does not cover all possible mouse selections
+ // (e.g., mouse x < 0 && mouse y > caret line y)
+ if (newCaretOffset < selectionAnchor && selectionAnchor == selection.x) {
+ selectionAnchor = doubleClickSelection.y;
+ }
+ else
+ if (newCaretOffset > selectionAnchor && selectionAnchor == selection.y) {
+ selectionAnchor = doubleClickSelection.x;
+ }
+ if (x >= 0 && x < getClientArea().width) {
+ // find the previous/next word
+ if (caretOffset == selection.x) {
+ wordOffset = getWordStart(newCaretOffset);
+ }
+ else {
+ wordOffset = getWordEndNoSpaces(newCaretOffset);
+ }
+ // mouse word select only on same line mouse cursor is on
+ if (content.getLineAtOffset(wordOffset) == line) {
+ newCaretOffset = wordOffset;
+ }
+ }
+ return newCaretOffset;
+}
+/**
+ * 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 lineCount = content.getLineCount();
+ int oldColumnX = columnX;
+ int caretLine;
+
+ // do nothing if in single line mode. fixes 5673
+ if (isSingleLine()) {
+ return;
+ }
+ caretLine = getCaretLine();
+ if (caretLine < lineCount - 1) {
+ int verticalMaximum = lineCount * getVerticalIncrement();
+ int pageSize = getClientArea().height;
+ int scrollLines = Math.min(lineCount - caretLine - 1, getLineCountWhole());
+ int scrollOffset;
+
+ // ensure that scrollLines never gets negative and at leat one
+ // line is scrolled. fixes bug 5602.
+ scrollLines = Math.max(1, scrollLines);
+ caretLine += scrollLines;
+ if (isBidi()) {
+ caretOffset = getBidiOffsetAtMouseLocation(columnX, caretLine);
+ }
+ else {
+ caretOffset = getOffsetAtMouseLocation(columnX, caretLine);
+ }
+ 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);
+ }
+ }
+ // explicitly go to the calculated caret line. may be different
+ // from content.getLineAtOffset(caretOffset) when in word wrap mode
+ showCaret(caretLine);
+ // save the original horizontal caret position
+ columnX = oldColumnX;
+}
+/**
+ * Moves the cursor to the end of the last fully visible line.
+ */
+void doPageEnd() {
+ // go to end of line if in single line mode. fixes 5673
+ if (isSingleLine()) {
+ doLineEnd();
+ }
+ else {
+ int line = getBottomIndex();
+ int bottomCaretOffset = content.getOffsetAtLine(line) + content.getLine(line).length();
+
+ if (caretOffset < bottomCaretOffset) {
+ caretOffset = bottomCaretOffset;
+ showCaret();
+ }
+ }
+}
+/**
+ * Moves the cursor to the beginning of the first fully visible line.
+ */
+void doPageStart() {
+ int topCaretOffset = content.getOffsetAtLine(topIndex);
+
+ if (caretOffset > topCaretOffset) {
+ caretOffset = topCaretOffset;
+ // explicitly go to the calculated caret line. may be different
+ // from content.getLineAtOffset(caretOffset) when in word wrap mode
+ showCaret(topIndex);
+ }
+}
+/**
+ * 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 oldColumnX = columnX;
+ int caretLine = getCaretLine();
+
+ if (caretLine > 0) {
+ int scrollLines = Math.max(1, Math.min(caretLine, getLineCountWhole()));
+ int scrollOffset;
+
+ caretLine -= scrollLines;
+ if (isBidi()) {
+ caretOffset = getBidiOffsetAtMouseLocation(columnX, caretLine);
+ }
+ else {
+ caretOffset = getOffsetAtMouseLocation(columnX, caretLine);
+ }
+ // scroll one page up or to the top
+ scrollOffset = Math.max(0, verticalScrollOffset - scrollLines * getVerticalIncrement());
+ if (scrollOffset < verticalScrollOffset) {
+ setVerticalScrollOffset(scrollOffset, true);
+ }
+ }
+ // explicitly go to the calculated caret line. may be different
+ // from content.getLineAtOffset(caretOffset) when in word wrap mode
+ showCaret(caretLine);
+ // save the original horizontal caret position
+ columnX = oldColumnX;
+}
+/**
+ * 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) {
+ internalRedrawRange(redrawStart, redrawEnd - redrawStart, true);
+ sendSelectionEvent();
+ }
+}
+/**
+ * Moves the caret to the next character or to the beginning of the
+ * next line if the cursor is at the end of a line.
+ */
+void doSelectionCursorNext() {
+ int caretLine = getCaretLine();
+ int lineOffset = content.getOffsetAtLine(caretLine);
+ int offsetInLine = caretOffset - lineOffset;
+
+ if (offsetInLine < content.getLine(caretLine).length()) {
+ // Remember the last direction. Always update lastCaretDirection,
+ // even though it's not used in non-bidi mode in order to avoid
+ // extra methods.
+ lastCaretDirection = ST.COLUMN_NEXT;
+ caretOffset++;
+ showCaret();
+ }
+ else
+ if (caretLine < content.getLineCount() - 1 && isSingleLine() == false) {
+ // only go to next line if not in single line mode. fixes 5673
+ caretLine++;
+ caretOffset = content.getOffsetAtLine(caretLine);
+ // explicitly go to the calculated caret line. may be different
+ // from content.getLineAtOffset(caretOffset) when in word wrap mode
+ showCaret(caretLine);
+ }
+}
+/**
+ * Moves the caret to the previous character or to the end of the previous
+ * line if the cursor is at the beginning of a line.
+ */
+void doSelectionCursorPrevious() {
+ int caretLine = getCaretLine();
+ int lineOffset = content.getOffsetAtLine(caretLine);
+ int offsetInLine = caretOffset - lineOffset;
+
+ if (offsetInLine > 0) {
+ // Remember the last direction. Always update lastCaretDirection,
+ // even though it's not used in non-bidi mode in order to avoid
+ // extra methods.
+ lastCaretDirection = ST.COLUMN_PREVIOUS;
+ caretOffset--;
+ // explicitly go to the calculated caret line. may be different
+ // from content.getLineAtOffset(caretOffset) when in word wrap mode
+ showCaret(caretLine);
+ }
+ else
+ if (caretLine > 0) {
+ caretLine--;
+ lineOffset = content.getOffsetAtLine(caretLine);
+ caretOffset = lineOffset + content.getLine(caretLine).length();
+ showCaret();
+ }
+}
+/**
+ * Moves the caret one line down and to the same character offset relative
+ * to the beginning of the line. Moves the caret to the end of the new line
+ * if the new line is shorter than the character offset.
+ * Moves the caret to the end of the text if the caret already is on the
+ * last line.
+ * Adjusts the selection according to the caret change. This can either add
+ * to or subtract from the old selection, depending on the previous selection
+ * direction.
+ */
+void doSelectionLineDown() {
+ int oldColumnX;
+ int caretLine;
+ int lineStartOffset;
+
+ if (isSingleLine()) {
+ return;
+ }
+ caretLine = getCaretLine();
+ lineStartOffset = content.getOffsetAtLine(caretLine);
+ // reset columnX on selection
+ oldColumnX = columnX = getXAtOffset(
+ content.getLine(caretLine), caretLine, caretOffset - lineStartOffset);
+ if (caretLine == content.getLineCount() - 1) {
+ caretOffset = content.getCharCount();
+ }
+ else {
+ caretLine = doLineDown();
+ }
+ setMouseWordSelectionAnchor();
+ // select first and then scroll to reduce flash when key
+ // repeat scrolls lots of lines
+ doSelection(SWT.RIGHT);
+ // explicitly go to the calculated caret line. may be different
+ // from content.getLineAtOffset(caretOffset) when in word wrap mode
+ showCaret(caretLine);
+ // save the original horizontal caret position
+ columnX = oldColumnX;
+}
+/**
+ * Moves the caret one line up and to the same character offset relative
+ * to the beginning of the line. Moves the caret to the end of the new line
+ * if the new line is shorter than the character offset.
+ * Moves the caret to the beginning of the document if it is already on the
+ * first line.
+ * Adjusts the selection according to the caret change. This can either add
+ * to or subtract from the old selection, depending on the previous selection
+ * direction.
+ */
+void doSelectionLineUp() {
+ int oldColumnX;
+ int caretLine = getCaretLine();
+ int lineStartOffset = content.getOffsetAtLine(caretLine);
+
+ // reset columnX on selection
+ oldColumnX = columnX = getXAtOffset(
+ content.getLine(caretLine), caretLine, caretOffset - lineStartOffset);
+ if (caretLine == 0) {
+ caretOffset = 0;
+ }
+ else {
+ caretLine = doLineUp();
+ }
+ setMouseWordSelectionAnchor();
+ // explicitly go to the calculated caret line. may be different
+ // from content.getLineAtOffset(caretOffset) when in word wrap mode
+ showCaret(caretLine);
+ doSelection(SWT.LEFT);
+ // save the original horizontal caret position
+ columnX = oldColumnX;
+}
+/**
+ * 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>
+ * Adjusts the selection according to the caret change. This can either add
+ * to or subtract from the old selection, depending on the previous selection
+ * direction.
+ * </p>
+ */
+void doSelectionPageDown() {
+ int oldColumnX;
+ int caretLine = getCaretLine();
+ int lineStartOffset = content.getOffsetAtLine(caretLine);
+
+ // reset columnX on selection
+ oldColumnX = columnX = getXAtOffset(
+ content.getLine(caretLine), caretLine, caretOffset - lineStartOffset);
+ doPageDown(true);
+ columnX = oldColumnX;
+}
+/**
+ * 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.
+ * <p>
+ * Adjusts the selection according to the caret change. This can either add
+ * to or subtract from the old selection, depending on the previous selection
+ * direction.
+ * </p>
+ */
+void doSelectionPageUp() {
+ int oldColumnX;
+ int caretLine = getCaretLine();
+ int lineStartOffset = content.getOffsetAtLine(caretLine);
+
+ // reset columnX on selection
+ oldColumnX = columnX = getXAtOffset(
+ content.getLine(caretLine), caretLine, caretOffset - lineStartOffset);
+ doPageUp();
+ columnX = oldColumnX;
+}
+/**
+ * Moves the caret to the end of the next word .
+ */
+void doSelectionWordNext() {
+ int newCaretOffset = getWordEnd(caretOffset);
+
+ // don't change caret position if in single line mode and the cursor
+ // would be on a different line. fixes 5673
+ if (isSingleLine() == false ||
+ content.getLineAtOffset(caretOffset) == content.getLineAtOffset(newCaretOffset)) {
+ lastCaretDirection = ST.COLUMN_NEXT;
+ caretOffset = newCaretOffset;
+ showCaret();
+ }
+}
+/**
+ * Moves the caret to the start of the previous word.
+ */
+void doSelectionWordPrevious() {
+ int caretLine;
+
+ lastCaretDirection = ST.COLUMN_PREVIOUS;
+ caretOffset = getWordStart(caretOffset);
+ caretLine = content.getLineAtOffset(caretOffset);
+ // word previous always comes from bottom line. when
+ // wrapping lines, stay on bottom line when on line boundary
+ if (wordWrap && caretLine < content.getLineCount() - 1 &&
+ caretOffset == content.getOffsetAtLine(caretLine + 1)) {
+ caretLine++;
+ }
+ showCaret(caretLine);
+}
+/**
+ * Moves the caret to the end of the next word.
+ * If a selection exists, move the caret to the end of the selection
+ * and remove the selection.
+ */
+void doWordNext() {
+ if (selection.y - selection.x > 0) {
+ int caretLine;
+
+ caretOffset = selection.y;
+ caretLine = getCaretLine();
+ showCaret(caretLine);
+ }
+ else {
+ doSelectionWordNext();
+ }
+}
+/**
+ * Moves the caret to the start of the previous word.
+ * If a selection exists, move the caret to the start of the selection
+ * and remove the selection.
+ */
+void doWordPrevious() {
+ if (selection.y - selection.x > 0) {
+ int caretLine;
+
+ caretOffset = selection.x;
+ caretLine = getCaretLine();
+ showCaret(caretLine);
+ }
+ else {
+ doSelectionWordPrevious();
+ }
+}
+/**
+ * Draws the specified rectangle.
+ * Draw directly without invalidating the affected area when clearBackground is
+ * false.
+ * <p>
+ *
+ * @param x the x position
+ * @param y the y position
+ * @param width the width
+ * @param height the height
+ * @param clearBackground true=clear the background by invalidating the requested
+ * redraw area, false=draw the foreground directly without invalidating the
+ * redraw area.
+ */
+void draw(int x, int y, int width, int height, boolean clearBackground) {
+ if (clearBackground) {
+ redraw(x + leftMargin, y + topMargin, width, height, true);
+ }
+ else {
+ int startLine = (y + verticalScrollOffset) / lineHeight;
+ int endY = y + height;
+ int paintYFromTopLine = (startLine - topIndex) * lineHeight;
+ int topLineOffset = (topIndex * lineHeight - verticalScrollOffset);
+ int paintY = paintYFromTopLine + topLineOffset + topMargin; // adjust y position for pixel based scrolling
+ int lineCount = content.getLineCount();
+ Color background = getBackground();
+ Color foreground = getForeground();
+ GC gc = getGC();
+
+ 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);
+ renderer.drawLine(line, i, paintY, gc, background, foreground, clearBackground);
+ }
+ gc.dispose();
+ }
+}
+/**
+ * Ends the autoscroll process.
+ */
+void endAutoScroll() {
+ autoScrollDirection = SWT.NULL;
+}
+/**
+ * @see org.eclipse.swt.widgets.Control#getBackground
+ */
+public Color getBackground() {
+ checkWidget();
+ if (background == null) {
+ return getDisplay().getSystemColor(SWT.COLOR_LIST_BACKGROUND);
+ }
+ return background;
+}
+/**
+ * Gets the BIDI coloring mode. When true the BIDI text display
+ * algorithm is applied to segments of text that are the same
+ * color.
+ *
+ * @return the current coloring mode
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * <p>
+ * @deprecated use BidiSegmentListener instead.
+ * </p>
+ */
+public boolean getBidiColoring() {
+ checkWidget();
+ return bidiColoring;
+}
+/**
+ * Returns the offset at the specified x location in the specified line.
+ * Also sets the caret direction so that the caret is placed correctly
+ * depending on whether the mouse location is in a R2L or L2R segment.
+ * <p>
+ *
+ * @param x x location of the mouse location
+ * @param line line the mouse location is in
+ * @return the offset at the specified x location in the specified line,
+ * relative to the beginning of the document
+ */
+int getBidiOffsetAtMouseLocation(int x, int line) {
+ String lineText = content.getLine(line);
+ int lineOffset = content.getOffsetAtLine(line);
+ GC gc = getGC();
+ StyledTextBidi bidi = getStyledTextBidi(lineText, lineOffset, gc);
+ int[] values;
+ int offsetInLine;
+ x += horizontalScrollOffset;
+ values = bidi.getCaretOffsetAndDirectionAtX(x - leftMargin);
+ offsetInLine = values[0];
+ lastCaretDirection = values[1];
+ gc.dispose();
+
+ return lineOffset + offsetInLine;
+}
+/**
+ * Returns the x position of the character at the specified offset
+ * relative to the first character in the line.
+ * </p>
+ *
+ * @param text text to be measured.
+ * @param endOffset offset of the character
+ * @param bidi the bidi object to use for measuring text in bidi
+ * locales.
+ * @return x position of the character at the specified offset.
+ * 0 if the length is outside the specified text.
+ */
+int getBidiTextPosition(String text, int endOffset, StyledTextBidi bidi) {
+ if (endOffset > text.length()) {
+ return 0;
+ }
+ // Use lastCaretDirection in order to get same results as during
+ // caret positioning (setBidiCaretLocation). Fixes 1GKU4C5.
+ return bidi.getTextPosition(endOffset, lastCaretDirection);
+}
+/**
+ * Returns the index of the last fully visible line.
+ * <p>
+ *
+ * @return index of the last fully visible line.
+ */
+int getBottomIndex() {
+ int lineCount = 1;
+
+ if (lineHeight != 0) {
+ // calculate the number of lines that are fully visible
+ int partialTopLineHeight = topIndex * lineHeight - verticalScrollOffset;
+ lineCount = (getClientArea().height - partialTopLineHeight) / lineHeight;
+ }
+ return Math.min(content.getLineCount() - 1, topIndex + Math.max(0, lineCount - 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 caret offset at the given x location in the line.
+ * The caret offset is the offset of the character where the caret will be
+ * placed when a mouse click occurs. The caret offset will be the offset of
+ * the character after the clicked one if the mouse click occurs at the second
+ * half of a character.
+ * Doesn't properly handle ligatures and other context dependent characters
+ * unless the current locale is a bidi locale.
+ * 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 caret offset at the x location relative to the start of the line.
+ */
+int getCaretOffsetAtX(String line, int lineOffset, int lineXOffset) {
+ int offset = 0;
+ GC gc = getGC();
+ StyleRange[] styles = null;
+ StyledTextEvent event = renderer.getLineStyleData(lineOffset, line);
+
+ lineXOffset += horizontalScrollOffset;
+ if (event != null) {
+ styles = renderer.filterLineStyles(event.styles);
+ }
+ int low = -1;
+ int high = line.length();
+ while (high - low > 1) {
+ offset = (high + low) / 2;
+ int x = renderer.getTextPosition(line, lineOffset, offset, styles, gc) + leftMargin;
+ int charWidth = renderer.getTextPosition(line, lineOffset, offset + 1, styles, gc) + leftMargin - x;
+ if (lineXOffset <= x + charWidth / 2) {
+ high = offset;
+ }
+ else {
+ low = offset;
+ }
+ }
+ offset = high;
+ gc.dispose();
+ return offset;
+}
+/**
+ * Returns the caret width.
+ * <p>
+ *
+ * @return the caret width, 0 if caret is null.
+ */
+int getCaretWidth() {
+ Caret caret = getCaret();
+ if (caret == null) return 0;
+ return caret.getSize().x;
+}
+/**
+ * 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 logicalContent;
+}
+/**
+ * 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;
+}
+/**
+ * @see org.eclipse.swt.widgets.Control#getForeground
+ */
+public Color getForeground() {
+ checkWidget();
+ if (foreground == null) {
+ return getDisplay().getSystemColor(SWT.COLOR_LIST_FOREGROUND);
+ }
+ return foreground;
+}
+/**
+ * Return a GC to use for rendering and update the cached font style to
+ * represent the current style.
+ * <p>
+ *
+ * @return GC.
+ */
+GC getGC() {
+ renderer.setCurrentFontStyle(SWT.NORMAL);
+ return new GC(this);
+}
+/**
+ * Returns the horizontal scroll increment.
+ * <p>
+ *
+ * @return horizontal scroll increment.
+ */
+int getHorizontalIncrement() {
+ GC gc = getGC();
+ 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. Preferred state masks are one or more of
+ * SWT.MOD1, SWT.MOD2, SWT.MOD3, since these masks account for modifier platform
+ * differences. However, there may be cases where using the specific state masks
+ * (i.e., SWT.CTRL, SWT.SHIFT, SWT.ALT, SWT.COMMAND) makes sense.
+ * @return one of the predefined actions defined in ST.java or SWT.NULL
+ * if there is no action associated with the key.
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public int getKeyBinding(int key) {
+ checkWidget();
+ Integer action = (Integer) keyActionMap.get(new Integer(key));
+ 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 > logicalContent.getLineCount()) {
+ SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+ }
+ if (userLineBackground == false) {
+ lineBackground = defaultLineStyler.getLineBackground(index);
+ }
+ return lineBackground;
+}
+/**
+ * Returns the line background data for the given line or null if
+ * there is none.
+ * <p>
+ * @param lineOffset offset of the line start relative to the start
+ * of the content.
+ * @param line line to get line background data for
+ * @return line background data for the given line.
+ */
+StyledTextEvent getLineBackgroundData(int lineOffset, String line) {
+ return sendLineEvent(LineGetBackground, lineOffset, line);
+}
+/**
+ * Gets the number of text lines.
+ * <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 can be completely displayed in the
+ * widget client area.
+ * <p>
+ *
+ * @return number of lines that can be completely displayed in the widget
+ * client area.
+ */
+int getLineCountWhole() {
+ int lineCount;
+
+ 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 logicalContent.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 a StyledTextEvent that can be used to request data such
+ * as styles and background color for a line.
+ * The specified line may be a visual (wrapped) line if in word
+ * wrap mode. The returned object will always be for a logical
+ * (unwrapped) line.
+ * <p>
+ *
+ * @param lineOffset offset of the line. This may be the offset of
+ * a visual line if the widget is in word wrap mode.
+ * @param line line text. This may be the text of a visualline if
+ * the widget is in word wrap mode.
+ * @return StyledTextEvent that can be used to request line data
+ * for the given line.
+ */
+StyledTextEvent sendLineEvent(int eventType, int lineOffset, String line) {
+ StyledTextEvent event = null;
+
+ if (isListening(eventType)) {
+ event = new StyledTextEvent(logicalContent);
+ if (wordWrap) {
+ // if word wrap is on, the line offset and text may be visual (wrapped)
+ int lineIndex = logicalContent.getLineAtOffset(lineOffset);
+
+ event.detail = logicalContent.getOffsetAtLine(lineIndex);
+ event.text = logicalContent.getLine(lineIndex);
+ }
+ else {
+ event.detail = lineOffset;
+ event.text = line;
+ }
+ notifyListeners(eventType, event);
+ }
+ return event;
+}
+/**
+ * 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();
+ return lineHeight;
+}
+/**
+ * Returns a LineCache implementation. Depending on whether or not
+ * word wrap is on this may be a line wrapping or line width
+ * calculating implementaiton.
+ * <p>
+ *
+ * @param content StyledTextContent to create the LineCache on.
+ * @return a LineCache implementation
+ */
+LineCache getLineCache(StyledTextContent content) {
+ LineCache lineCache;
+
+ if (wordWrap) {
+ lineCache = new WordWrapCache(this, (WrappedContent) content);
+ }
+ else {
+ lineCache = new ContentWidthCache(this, content.getLineCount());
+ }
+ return lineCache;
+}
+/**
+ * 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.
+ * <p>
+ *
+ * @param lineOffset offset of the line start relative to the start of
+ * the content.
+ * @param line line to get line styles for
+ * @return line style data for the given line. Styles may start before
+ * line start and end after line end
+ */
+StyledTextEvent getLineStyleData(int lineOffset, String line) {
+ return sendLineEvent(LineGetStyle, lineOffset, line);
+}
+/**
+ * Returns the 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 = content.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 character offset of the first character of the given line.
+ * <p>
+ *
+ * @param lineIndex index of the line, 0 based relative to the first
+ * line in the content. 0 <= lineIndex < getLineCount(), except
+ * lineIndex may always be 0
+ * @return offset offset of the first character of the line, relative to
+ * the beginning of the document. The first character of the document is
+ * at offset 0.
+ * When there are not any lines, getOffsetAtLine(0) is a valid call that
+ * answers 0.
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_INVALID_RANGE when the offset is outside the valid range (< 0 or > getCharCount())</li>
+ * </ul>
+ * @since 2.0
+ */
+public int getOffsetAtLine(int lineIndex) {
+ checkWidget();
+
+ if (lineIndex < 0 ||
+ (lineIndex > 0 && lineIndex >= logicalContent.getLineCount())) {
+ SWT.error(SWT.ERROR_INVALID_RANGE);
+ }
+ return logicalContent.getOffsetAtLine(lineIndex);
+}
+/**
+ * Returns the offset of the character at the given location relative
+ * to the first character in the document.
+ * The return value reflects the character offset that the caret will
+ * be placed at if a mouse click occurred at the specified location.
+ * If the x coordinate of the location is beyond the center of a character
+ * the returned offset will be behind the character.
+ * <p>
+ *
+ * @param point the origin of character bounding box relative to
+ * the origin of the widget client area.
+ * @return offset of the character at the given location relative
+ * to the first character in the document.
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT when point is null</li>
+ * <li>ERROR_INVALID_ARGUMENT when there is no character at the specified location</li>
+ * </ul>
+ */
+public int getOffsetAtLocation(Point point) {
+ checkWidget();
+ int line;
+ int lineOffset;
+ int offsetInLine;
+ String lineText;
+
+ if (point == null) {
+ SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ }
+ // is y above first line or is x before first column?
+ if (point.y + verticalScrollOffset < 0 || point.x + horizontalScrollOffset < 0) {
+ SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+ }
+ line = (getTopPixel() + point.y) / lineHeight;
+ // does the referenced line exist?
+ if (line >= content.getLineCount()) {
+ SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+ }
+ lineText = content.getLine(line);
+ lineOffset = content.getOffsetAtLine(line);
+ offsetInLine = getOffsetAtX(lineText, lineOffset, point.x);
+ // is the x position within the line?
+ if (offsetInLine == -1) {
+ SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+ }
+ return lineOffset + offsetInLine;
+}
+/**
+ * Returns the offset at the specified x location in the specified line.
+ * <p>
+ *
+ * @param x x location of the mouse location
+ * @param line line the mouse location is in
+ * @return the offset at the specified x location in the specified line,
+ * relative to the beginning of the document
+ */
+int getOffsetAtMouseLocation(int x, int line) {
+ String lineText = content.getLine(line);
+ int lineOffset = content.getOffsetAtLine(line);
+ int offsetInLine = getCaretOffsetAtX(lineText, lineOffset, x);
+ return lineOffset + offsetInLine;
+}
+/**
+ * Returns the offset of the character at the given x location in the line.
+ * <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. -1 if the x location is past the end if the line.
+ */
+int getOffsetAtX(String line, int lineOffset, int lineXOffset) {
+ GC gc = getGC();
+ int offset;
+
+ lineXOffset += (horizontalScrollOffset - leftMargin);
+ if (isBidi()) {
+ StyledTextBidi bidi = getStyledTextBidi(line, lineOffset, gc);
+ offset = bidi.getOffsetAtX(lineXOffset);
+ }
+ else {
+ StyleRange[] styles = null;
+ StyledTextEvent event = renderer.getLineStyleData(lineOffset, line);
+
+ if (event != null) {
+ styles = renderer.filterLineStyles(event.styles);
+ }
+ int low = -1;
+ int high = line.length();
+ while (high - low > 1) {
+ offset = (high + low) / 2;
+ // Restrict right/high search boundary only if x is within searched text segment.
+ // Fixes 1GL4ZVE.
+ if (lineXOffset < renderer.getTextPosition(line, lineOffset, offset + 1, styles, gc)) {
+ high = offset;
+ }
+ else
+ if (high == line.length() && high - offset == 1) {
+ // requested x location is past end of line
+ high = -1;
+ }
+ 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 = Compatibility.ceil(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 = logicalContent.getLineAtOffset(writer.getStart());
+ int endLine = logicalContent.getLineAtOffset(end);
+ String endLineText = logicalContent.getLine(endLine);
+ int endLineOffset = logicalContent.getOffsetAtLine(endLine);
+
+ for (int i = startLine; i <= endLine; i++) {
+ writer.writeLine(logicalContent.getLine(i), logicalContent.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.
+ * The selection values returned are visual (i.e., x will always always be
+ * <= y). To determine if a selection is right-to-left (RtoL) vs. left-to-right
+ * (LtoR), compare the caretOffset to the start and end of the selection
+ * (e.g., caretOffset == start of selection implies that the selection is RtoL).
+ * @see #getSelectionRange
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public Point getSelection() {
+ checkWidget();
+ return new Point(selection.x, selection.y);
+}
+/**
+ * Returns the selection.
+ * <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.
+ * The selection values returned are visual (i.e., length will always always be
+ * positive). To determine if a selection is right-to-left (RtoL) vs. left-to-right
+ * (LtoR), compare the caretOffset to the start and end of the selection
+ * (e.g., caretOffset == start of selection implies that the selection is RtoL).
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public Point getSelectionRange() {
+ checkWidget();
+ return new Point(selection.x, selection.y - selection.x);
+}
+/**
+ * Returns the receiver's selection background color.
+ *
+ * @return the selection background color
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * @since 2.1
+ */
+public Color getSelectionBackground() {
+ checkWidget();
+ if (selectionBackground == null) {
+ return getDisplay().getSystemColor(SWT.COLOR_LIST_SELECTION);
+ }
+ return selectionBackground;
+}
+/**
+ * Gets the number of selected characters.
+ * <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 receiver's selection foreground color.
+ *
+ * @return the selection foreground color
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * @since 2.1
+ */
+public Color getSelectionForeground() {
+ checkWidget();
+ if (selectionForeground == null) {
+ return getDisplay().getSystemColor(SWT.COLOR_LIST_SELECTION_TEXT);
+ }
+ return selectionForeground;
+}
+/**
+ * Returns the selected text.
+ * <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 text segments that should be treated as if they
+ * had a different direction than the surrounding text.
+ * <p>
+ *
+ * @param lineOffset offset of the first character in the line.
+ * 0 based from the beginning of the document.
+ * @param line text of the line to specify bidi segments for
+ * @return text segments that should be treated as if they had a
+ * different direction than the surrounding text. Only the start
+ * index of a segment is specified, relative to the start of the
+ * line. Always starts with 0 and ends with the line length.
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_INVALID_ARGUMENT - if the segment indices returned
+ * by the listener do not start with 0, are not in ascending order,
+ * exceed the line length or have duplicates</li>
+ * </ul>
+ */
+int [] getBidiSegments(int lineOffset, String line) {
+ if (isListening(LineGetSegments) == false) {
+ return getBidiSegmentsCompatibility(line, lineOffset);
+ }
+ StyledTextEvent event = sendLineEvent(LineGetSegments, lineOffset, line);
+ int lineLength = line.length();
+ int[] segments;
+ if (event == null || event.segments == null || event.segments.length == 0) {
+ segments = new int[] {0, lineLength};
+ }
+ else {
+ int segmentCount = event.segments.length;
+
+ // test segment index consistency
+ if (event.segments[0] != 0) {
+ SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+ }
+ for (int i = 1; i < segmentCount; i++) {
+ if (event.segments[i] <= event.segments[i - 1] || event.segments[i] > lineLength) {
+ SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+ }
+ }
+ // ensure that last segment index is line end offset
+ if (event.segments[segmentCount - 1] != lineLength) {
+ segments = new int[segmentCount + 1];
+ System.arraycopy(event.segments, 0, segments, 0, segmentCount);
+ segments[segmentCount] = lineLength;
+ }
+ else {
+ segments = event.segments;
+ }
+ }
+ return segments;
+}
+/**
+ * @see getBidiSegments
+ * Supports deprecated setBidiColoring API. Remove when API is removed.
+ */
+int [] getBidiSegmentsCompatibility(String line, int lineOffset) {
+ StyledTextEvent event;
+ StyleRange [] styles = new StyleRange [0];
+ int lineLength = line.length();
+ if (bidiColoring == false) {
+ return new int[] {0, lineLength};
+ }
+ event = renderer.getLineStyleData(lineOffset, line);
+ if (event != null) {
+ styles = event.styles;
+ }
+ if (styles.length == 0) {
+ return new int[] {0, lineLength};
+ }
+ int k=0, count = 1;
+ while (k < styles.length && styles[k].start == 0 && styles[k].length == lineLength) {
+ k++;
+ }
+ int[] offsets = new int[(styles.length - k) * 2 + 2];
+ for (int i = k; i < styles.length; i++) {
+ StyleRange style = styles[i];
+ int styleLineStart = Math.max(style.start - lineOffset, 0);
+ int styleLineEnd = Math.max(style.start + style.length - lineOffset, styleLineStart);
+ styleLineEnd = Math.min (styleLineEnd, line.length ());
+ if (i > 0 && count > 1 &&
+ ((styleLineStart >= offsets[count-2] && styleLineStart <= offsets[count-1]) ||
+ (styleLineEnd >= offsets[count-2] && styleLineEnd <= offsets[count-1])) &&
+ style.similarTo(styles[i-1])) {
+ offsets[count-2] = Math.min(offsets[count-2], styleLineStart);
+ offsets[count-1] = Math.max(offsets[count-1], styleLineEnd);
+ } else {
+ if (styleLineStart > offsets[count - 1]) {
+ offsets[count] = styleLineStart;
+ count++;
+ }
+ offsets[count] = styleLineEnd;
+ count++;
+ }
+ }
+ // add offset for last non-colored segment in line, if any
+ if (lineLength > offsets[count-1]) {
+ offsets [count] = lineLength;
+ count++;
+ }
+ if (count == offsets.length) {
+ return offsets;
+ }
+ int [] result = new int [count];
+ System.arraycopy (offsets, 0, result, 0, count);
+ return result;
+}
+/**
+ * Returns the style range at the given offset.
+ * Returns null if a LineStyleListener has been set or if a style is not set
+ * for the offset.
+ * Should not be called if a LineStyleListener has been set since the
+ * listener maintains the styles.
+ * <p>
+ *
+ * @param offset the offset to return the style for.
+ * 0 <= offset < getCharCount() must be true.
+ * @return a StyleRange with start == offset and length == 1, indicating
+ * the style at the given offset. null if a LineStyleListener has been set
+ * or if a style is not set for the given offset.
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_INVALID_ARGUMENT when the offset is invalid</li>
+ * </ul>
+ */
+public StyleRange getStyleRangeAtOffset(int offset) {
+ checkWidget();
+ if (offset < 0 || offset >= getCharCount()) {
+ SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+ }
+ if (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 a StyledTextBidi object for the specified line.
+ * <p>
+ *
+ * @param lineText the line that the StyledTextBidi object should
+ * work on.
+ * @param lineOffset offset of the beginning of the line, relative
+ * to the beginning of the document
+ * @param gc GC to use when creating a new StyledTextBidi object.
+ * @return a StyledTextBidi object for the specified line.
+ */
+StyledTextBidi getStyledTextBidi(String lineText, int lineOffset, GC gc) {
+ return getStyledTextBidi(lineText, lineOffset, gc, null);
+}
+/**
+ * Returns a StyledTextBidi object for the specified line.
+ * <p>
+ *
+ * @param lineText the line that the StyledTextBidi object should
+ * work on.
+ * @param lineOffset offset of the beginning of the line, relative
+ * to the beginning of the document
+ * @param gc GC to use when creating a new StyledTextBidi object.
+ * @param styles StyleRanges to use when creating a new StyledTextBidi
+ * object.
+ * @return a StyledTextBidi object for the specified line.
+ */
+StyledTextBidi getStyledTextBidi(String lineText, int lineOffset, GC gc, StyleRange[] styles) {
+ return renderer.getStyledTextBidi(lineText, lineOffset, gc, 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 > end || start < 0 || end > contentLength) {
+ 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;
+}
+/**
+ * Returns the x position of the character at the specified offset
+ * relative to the first character in the line.
+ * Expands 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 x position of the character at the specified offset
+ * with tabs expanded to tab stops. 0 if the length is outside the
+ * specified text.
+ */
+int getTextPosition(String line, int lineIndex, int length, GC gc) {
+ int lineOffset = content.getOffsetAtLine(lineIndex);
+ int lineLength = line.length();
+ int width;
+ if (lineLength == 0 || length > lineLength) {
+ return 0;
+ }
+ if (isBidi()) {
+ StyledTextBidi bidi = getStyledTextBidi(line, lineOffset, gc, null);
+ width = getBidiTextPosition(line, length, bidi);
+ }
+ else {
+ StyledTextEvent event = renderer.getLineStyleData(lineOffset, line);
+ StyleRange[] styles = null;
+ if (event != null) {
+ styles = renderer.filterLineStyles(event.styles);
+ }
+ width = renderer.getTextPosition(line, lineOffset, length, styles, gc);
+ }
+ return width;
+}
+/**
+ * Gets the top index. The top index is the index of the fully visible line that
+ * is currently at the top of the widget or the topmost partially visible line if
+ * no line is fully visible.
+ * The top index changes when the widget is scrolled. Indexing is zero based.
+ * <p>
+ *
+ * @return the index of the top line
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public int getTopIndex() {
+ checkWidget();
+ int logicalTopIndex = topIndex;
+
+ if (wordWrap) {
+ int visualLineOffset = content.getOffsetAtLine(topIndex);
+ logicalTopIndex = logicalContent.getLineAtOffset(visualLineOffset);
+ }
+ return logicalTopIndex;
+}
+/**
+ * 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 lineHeight;
+}
+/**
+ * Returns the index of the line the caret is on.
+ * When in word wrap mode and at the end of one wrapped line/
+ * beginning of the continuing wrapped line the caret offset
+ * is not sufficient to determine the caret line.
+ *
+ * @return the index of the line the caret is on.
+ */
+int getCaretLine() {
+ int caretLine = content.getLineAtOffset(caretOffset);
+ int leftColumnX = 0;
+
+ if (isBidi()) {
+ leftColumnX = XINSET;
+ }
+ if (wordWrap && columnX <= leftColumnX &&
+ caretLine < content.getLineCount() - 1 &&
+ caretOffset == content.getOffsetAtLine(caretLine + 1)) {
+ caretLine++;
+ }
+ return caretLine;
+}
+/**
+ * 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 = logicalContent.getLineAtOffset(offset);
+ int lineOffset = logicalContent.getOffsetAtLine(line);
+ String lineText = logicalContent.getLine(line);
+ int lineLength = lineText.length();
+
+ if (offset >= getCharCount()) {
+ return offset;
+ }
+ if (offset == lineOffset + lineLength) {
+ line++;
+ offset = logicalContent.getOffsetAtLine(line);
+ }
+ else {
+ offset -= lineOffset;
+ char ch = lineText.charAt(offset);
+ boolean letterOrDigit = Compatibility.isLetterOrDigit(ch);
+ while (offset < lineLength - 1 && Compatibility.isLetterOrDigit(ch) == letterOrDigit) {
+ offset++;
+ ch = lineText.charAt(offset);
+ }
+ // skip over trailing whitespace
+ while (offset < lineLength - 1 && Compatibility.isSpaceChar(ch)) {
+ offset++;
+ ch = lineText.charAt(offset);
+ }
+ if (offset == lineLength - 1 && (Compatibility.isLetterOrDigit(ch) == letterOrDigit || Compatibility.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 = logicalContent.getLineAtOffset(offset);
+ int lineOffset = logicalContent.getOffsetAtLine(line);
+ String lineText = logicalContent.getLine(line);
+ int lineLength = lineText.length();
+
+ if (offset >= getCharCount()) {
+ return offset;
+ }
+ if (offset == lineOffset + lineLength) {
+ line++;
+ offset = logicalContent.getOffsetAtLine(line);
+ }
+ else {
+ offset -= lineOffset;
+ char ch = lineText.charAt(offset);
+ boolean letterOrDigit = Compatibility.isLetterOrDigit(ch);
+
+ while (offset < lineLength - 1 && Compatibility.isLetterOrDigit(ch) == letterOrDigit && Compatibility.isSpaceChar(ch) == false) {
+ offset++;
+ ch = lineText.charAt(offset);
+ }
+ if (offset == lineLength - 1 && Compatibility.isLetterOrDigit(ch) == letterOrDigit && Compatibility.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 = logicalContent.getLineAtOffset(offset);
+ int lineOffset = logicalContent.getOffsetAtLine(line);
+ String lineText = logicalContent.getLine(line);
+
+ if (offset <= 0) {
+ return offset;
+ }
+ if (offset == lineOffset) {
+ line--;
+ lineText = logicalContent.getLine(line);
+ offset = logicalContent.getOffsetAtLine(line) + lineText.length();
+ }
+ else {
+ char ch;
+ boolean letterOrDigit;
+
+ offset -= lineOffset;
+ // skip over trailing whitespace
+ do {
+ offset--;
+ ch = lineText.charAt(offset);
+ } while (offset > 0 && Compatibility.isSpaceChar(ch));
+ letterOrDigit = Compatibility.isLetterOrDigit(ch);
+ while (offset > 0 && Compatibility.isLetterOrDigit(ch) == letterOrDigit && Compatibility.isSpaceChar(ch) == false) {
+ offset--;
+ ch = lineText.charAt(offset);
+ }
+ if (offset > 0 || Compatibility.isLetterOrDigit(ch) != letterOrDigit) {
+ offset++;
+ }
+ offset += lineOffset;
+ }
+ return offset;
+}
+/**
+ * Returns whether the widget wraps lines.
+ * <p>
+ *
+ * @return true if widget wraps lines, false otherwise
+ * @since 2.0
+ */
+public boolean getWordWrap() {
+ checkWidget();
+ return wordWrap;
+}
+/**
+ * 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 given offset in the line.
+ */
+int getXAtOffset(String line, int lineIndex, int lineOffset) {
+ int x;
+ if (lineOffset == 0 && isBidi() == false) {
+ x = leftMargin;
+ }
+ else {
+ GC gc = getGC();
+ x = getTextPosition(line, lineIndex, Math.min(line.length(), lineOffset), gc) + leftMargin;
+ gc.dispose();
+ if (lineOffset > line.length()) {
+ // offset is not on the line. return an x location one character
+ // after the line to indicate the line delimiter.
+ x += lineEndSpaceWidth;
+ }
+ }
+ 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 string is null</li>
+ * </ul>
+ */
+public void insert(String string) {
+ checkWidget();
+ if (string == null) {
+ SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ }
+ Point sel = getSelectionRange();
+ replaceTextRange(sel.x, sel.y, string);
+}
+/**
+ * Creates content change listeners and set the default content model.
+ */
+void installDefaultContent() {
+ textChangeListener = new TextChangeListener() {
+ public void textChanging(TextChangingEvent event) {
+ handleTextChanging(event);
+ }
+ public void textChanged(TextChangedEvent event) {
+ handleTextChanged(event);
+ }
+ public void textSet(TextChangedEvent event) {
+ handleTextSet(event);
+ }
+ };
+ logicalContent = content = new DefaultContent();
+ content.addTextChangeListener(textChangeListener);
+}
+/**
+ * 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(logicalContent);
+ 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) {
+ handleTraverse(event);
+ }
+ });
+ 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);
+ }
+ });
+ }
+}
+StyledTextContent internalGetContent() {
+ return content;
+}
+int internalGetHorizontalPixel() {
+ return horizontalScrollOffset;
+}
+LineCache internalGetLineCache() {
+ return lineCache;
+}
+Point internalGetSelection() {
+ return selection;
+}
+boolean internalGetWordWrap() {
+ return wordWrap;
+}
+/**
+ * Used by WordWrapCache to bypass StyledText.redraw which does
+ * an unwanted cache reset.
+ */
+void internalRedraw() {
+ super.redraw();
+}
+/**
+ * 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 range will
+ * be cleared before anything is redrawn. If the redraw range includes
+ * the last character of a line (i.e., the entire line is redrawn) the
+ * line is cleared all the way to the right border of the widget.
+ * The redraw operation will be faster and smoother if clearBackground is
+ * set to false. Whether or not the flag can be set to false depends on
+ * the type of change that has taken place. If font styles or background
+ * colors for the redraw range have changed, clearBackground should be
+ * set to true. If only foreground colors have changed for the redraw
+ * range, clearBackground can be set to false.
+ */
+void internalRedrawRange(int start, int length, boolean clearBackground) {
+ int end = start + length;
+ int firstLine = content.getLineAtOffset(start);
+ int lastLine = content.getLineAtOffset(end);
+ int offsetInFirstLine;
+ int partialBottomIndex = getPartialBottomIndex();
+ int partialTopIndex = verticalScrollOffset / lineHeight;
+ // do nothing if redraw range is completely invisible
+ if (firstLine > partialBottomIndex || lastLine < partialTopIndex) {
+ return;
+ }
+ // only redraw visible lines
+ if (partialTopIndex > firstLine) {
+ firstLine = partialTopIndex;
+ offsetInFirstLine = 0;
+ }
+ else {
+ offsetInFirstLine = start - content.getOffsetAtLine(firstLine);
+ }
+ if (partialBottomIndex + 1 < lastLine) {
+ lastLine = partialBottomIndex + 1; // + 1 to redraw whole bottom line, including line break
+ end = content.getOffsetAtLine(lastLine);
+ }
+ // redraw first and last lines
+ if (isBidi()) {
+ redrawBidiLines(firstLine, offsetInFirstLine, lastLine, end, clearBackground);
+ }
+ else {
+ redrawLines(firstLine, offsetInFirstLine, lastLine, end, clearBackground);
+ }
+ // redraw entire center lines if redraw range includes more than two lines
+ if (lastLine - firstLine > 1) {
+ Rectangle clientArea = getClientArea();
+ int redrawStopY = lastLine * lineHeight - verticalScrollOffset;
+ int redrawY = (firstLine + 1) * lineHeight - verticalScrollOffset;
+ draw(0, redrawY, clientArea.width, redrawStopY - redrawY, clearBackground);
+ }
+}
+/**
+ * Returns the widget text with style information encoded using RTF format
+ * specification version 1.5.
+ *
+ * @return the widget text with style information encoded using RTF format
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+String getRtf(){
+ checkWidget();
+ RTFWriter rtfWriter = new RTFWriter(0, getCharCount());
+ return getPlatformDelimitedText(rtfWriter);
+}
+/**
+ * Frees resources.
+ */
+void handleDispose() {
+ clipboard.dispose();
+ ibeamCursor.dispose();
+ if (renderer != null) {
+ renderer.dispose();
+ renderer = null;
+ }
+ if (content != null) {
+ content.removeTextChangeListener(textChangeListener);
+ }
+ if (leftCaretBitmap != null) {
+ leftCaretBitmap.dispose();
+ leftCaretBitmap = null;
+ }
+ if (rightCaretBitmap != null) {
+ rightCaretBitmap.dispose();
+ rightCaretBitmap = null;
+ }
+ if (isBidi()) {
+ StyledTextBidi.removeLanguageListener(this);
+ }
+}
+/**
+ * Scrolls the widget horizontally.
+ */
+void handleHorizontalScroll(Event event) {
+ int scrollPixel = getHorizontalBar().getSelection() - horizontalScrollOffset;
+ scrollHorizontal(scrollPixel);
+}
+/**
+ * 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) {
+ // special key pressed (e.g., F1)
+ action = getKeyBinding(event.keyCode | event.stateMask);
+ }
+ else {
+ // character key pressed
+ action = getKeyBinding(event.character | event.stateMask);
+ if (action == SWT.NULL) {
+ // see if we have a control character
+ if ((event.stateMask & SWT.CTRL) != 0 && (event.character >= 0) && event.character <= 31) {
+ // get the character from the CTRL+char sequence, the control
+ // key subtracts 64 from the value of the key that it modifies
+ int c = event.character + 64;
+ action = getKeyBinding(c | event.stateMask);
+ }
+ }
+ }
+ if (action == SWT.NULL) {
+ boolean ignore = false;
+
+ if (isCarbon) {
+ // Ignore acclerator key combinations (we do not want to
+ // insert a character in the text in this instance). Do not
+ // ignore COMMAND+ALT combinations since that key sequence
+ // produces characters on the mac.
+ ignore = (event.stateMask ^ SWT.COMMAND) == 0 ||
+ (event.stateMask ^ (SWT.COMMAND | SWT.SHIFT)) == 0;
+ } else {
+ // Ignore acclerator key combinations (we do not want to
+ // insert a character in the text in this instance). Don't
+ // ignore CTRL+ALT combinations since that is the Alt Gr
+ // key on some keyboards. See bug 20953.
+ ignore = (event.stateMask ^ SWT.ALT) == 0 ||
+ (event.stateMask ^ SWT.CTRL) == 0 ||
+ (event.stateMask ^ (SWT.ALT | SWT.SHIFT)) == 0 ||
+ (event.stateMask ^ (SWT.CTRL | SWT.SHIFT)) == 0;
+ }
+ // -ignore anything below SPACE except for line delimiter keys and tab.
+ // -ignore DEL
+ if (!ignore && event.character > 31 && event.character != SWT.DEL ||
+ event.character == SWT.CR || event.character == SWT.LF ||
+ event.character == TAB) {
+ doContent(event.character);
+ }
+ }
+ else {
+ invokeAction(action);
+ }
+}
+/**
+ * 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);
+ }
+}
+/**
+ * Updates the caret location and selection if mouse button 1 has been
+ * pressed.
+ */
+void handleMouseDoubleClick(Event event) {
+ if (event.button != 1 || doubleClickEnabled == false) {
+ return;
+ }
+ event.y -= topMargin;
+ mouseDoubleClick = true;
+ caretOffset = getWordStart(caretOffset);
+ resetSelection();
+ caretOffset = getWordEndNoSpaces(caretOffset);
+ showCaret();
+ doMouseSelection();
+ doubleClickSelection = new Point(selection.x, selection.y);
+}
+/**
+ * Updates the caret location and selection if mouse button 1 has been
+ * pressed.
+ */
+void handleMouseDown(Event event) {
+ boolean select = (event.stateMask & SWT.MOD2) != 0;
+
+ if (event.button != 1) {
+ return;
+ }
+ mouseDoubleClick = false;
+ event.y -= topMargin;
+ doMouseLocationChange(event.x, event.y, select);
+}
+/**
+ * Updates the caret location and selection if mouse button 1 is pressed
+ * during the mouse move.
+ */
+void handleMouseMove(Event event) {
+ if ((event.stateMask & SWT.BUTTON1) == 0) {
+ return;
+ }
+ event.y -= topMargin;
+ doMouseLocationChange(event.x, event.y, true);
+ doAutoScroll(event);
+}
+/**
+ * Autoscrolling ends when the mouse button is released.
+ */
+void handleMouseUp(Event event) {
+ event.y -= topMargin;
+ endAutoScroll();
+}
+/**
+ * Renders the invalidated area specified in the paint event.
+ * <p>
+ *
+ * @param event paint event
+ */
+void handlePaint(Event event) {
+ int startLine = Math.max(0, (event.y - topMargin + verticalScrollOffset) / lineHeight);
+ int paintYFromTopLine = (startLine - topIndex) * lineHeight;
+ int topLineOffset = topIndex * lineHeight - verticalScrollOffset;
+ int startY = paintYFromTopLine + topLineOffset + topMargin; // adjust y position for pixel based scrolling and top margin
+ int renderHeight = event.y + event.height - startY;
+ Rectangle clientArea = getClientArea();
+
+ // Check if there is work to do. clientArea.width should never be 0
+ // if we receive a paint event but we never want to try and create
+ // an Image with 0 width.
+ if (clientArea.width == 0 || event.height == 0) {
+ return;
+ }
+ performPaint(event.gc, startLine, startY, renderHeight);
+}
+/**
+ * Recalculates the scroll bars. Rewraps all lines when in word
+ * wrap mode.
+ * <p>
+ *
+ * @param event resize event
+ */
+void handleResize(Event event) {
+ int oldHeight = clientAreaHeight;
+ int oldWidth = clientAreaWidth;
+
+ clientAreaHeight = getClientArea().height;
+ clientAreaWidth = getClientArea().width;
+ if (wordWrap) {
+ if (oldWidth != clientAreaWidth) {
+ wordWrapResize(oldWidth);
+ }
+ }
+ else
+ if (clientAreaHeight > oldHeight) {
+ int lineCount = content.getLineCount();
+ int oldBottomIndex = topIndex + oldHeight / lineHeight;
+ int newItemCount = Compatibility.ceil(clientAreaHeight - oldHeight, lineHeight);
+
+ oldBottomIndex = Math.min(oldBottomIndex, lineCount);
+ newItemCount = Math.min(newItemCount, lineCount - oldBottomIndex);
+ lineCache.calculate(oldBottomIndex, newItemCount);
+ }
+ setScrollBars();
+ claimBottomFreeSpace();
+ claimRightFreeSpace();
+ if (oldHeight != clientAreaHeight) {
+ calculateTopIndex();
+ }
+}
+/**
+ * Updates the caret position and selection and the scroll bars to reflect
+ * the content change.
+ * <p>
+ */
+void handleTextChanged(TextChangedEvent event) {
+ lineCache.textChanged(lastTextChangeStart,
+ lastTextChangeNewLineCount,
+ lastTextChangeReplaceLineCount,
+ lastTextChangeNewCharCount,
+ lastTextChangeReplaceCharCount);
+ setScrollBars();
+ // 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(
+ lastTextChangeStart,
+ lastTextChangeReplaceCharCount,
+ lastTextChangeNewCharCount);
+
+ if (lastTextChangeReplaceLineCount > 0) {
+ // Only check for unused space when lines are deleted.
+ // Fixes 1GFL4LY
+ // Scroll up so that empty lines below last text line are used.
+ // Fixes 1GEYJM0
+ claimBottomFreeSpace();
+ }
+ if (lastTextChangeReplaceCharCount > 0) {
+ // fixes bug 8273
+ claimRightFreeSpace();
+ }
+ // do direct drawing if the text change is confined to a single line.
+ // optimization and fixes bug 13999. see also handleTextChanging.
+ if (lastTextChangeNewLineCount == 0 && lastTextChangeReplaceLineCount == 0) {
+ int startLine = content.getLineAtOffset(lastTextChangeStart);
+ int startY = startLine * lineHeight - verticalScrollOffset + topMargin;
+
+ GC gc = getGC();
+ Caret caret = getCaret();
+ boolean caretVisible = false;
+
+ if (caret != null) {
+ caretVisible = caret.getVisible();
+ caret.setVisible(false);
+ }
+ performPaint(gc, startLine, startY, lineHeight);
+ if (caret != null) {
+ caret.setVisible(caretVisible);
+ }
+ gc.dispose();
+ }
+}
+/**
+ * Updates the screen to reflect a pending content change.
+ * <p>
+ *
+ * @param event.start the start offset of the change
+ * @param event.newText text that is going to be inserted or empty String
+ * if no text will be inserted
+ * @param event.replaceCharCount length of text that is going to be replaced
+ * @param event.newCharCount length of text that is going to be inserted
+ * @param event.replaceLineCount number of lines that are going to be replaced
+ * @param event.newLineCount number of new lines that are going to be inserted
+ */
+void handleTextChanging(TextChangingEvent event) {
+ int firstLine;
+ int textChangeY;
+ boolean isMultiLineChange = event.replaceLineCount > 0 || event.newLineCount > 0;
+
+ if (event.replaceCharCount < 0) {
+ event.start += event.replaceCharCount;
+ event.replaceCharCount *= -1;
+ }
+ lastTextChangeStart = event.start;
+ lastTextChangeNewLineCount = event.newLineCount;
+ lastTextChangeNewCharCount = event.newCharCount;
+ lastTextChangeReplaceLineCount = event.replaceLineCount;
+ lastTextChangeReplaceCharCount = event.replaceCharCount;
+ firstLine = content.getLineAtOffset(event.start);
+ textChangeY = firstLine * lineHeight - verticalScrollOffset + topMargin;
+ if (isMultiLineChange) {
+ redrawMultiLineChange(textChangeY, event.newLineCount, event.replaceLineCount);
+ }
+ // notify default line styler about text change
+ if (defaultLineStyler != null) {
+ defaultLineStyler.textChanging(event);
+ }
+
+ // Update the caret offset if it is greater than the length of the content.
+ // This is necessary since style range API may be called between the
+ // handleTextChanging and handleTextChanged events and this API sets the
+ // caretOffset.
+ int newEndOfText = content.getCharCount() - event.replaceCharCount + event.newCharCount;
+ if (caretOffset > newEndOfText) caretOffset = newEndOfText;
+}
+/**
+ * Called when the widget content is set 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();
+}
+/**
+ * Called when a traversal key is pressed.
+ * Allow tab next traversal to occur when the widget is in single
+ * line mode or in multi line and non-editable mode .
+ * When in editable multi line mode we want to prevent the tab
+ * traversal and receive the tab key event instead.
+ * <p>
+ *
+ * @param event the event
+ */
+void handleTraverse(Event event) {
+ int style = getStyle();
+ boolean ignoreTab = (style & SWT.MULTI) != 0 && !editable || isSingleLine();
+
+ if ((event.detail == SWT.TRAVERSE_TAB_NEXT ||
+ event.detail == SWT.TRAVERSE_RETURN) && ignoreTab) {
+ event.doit = true;
+ }
+}
+/**
+ * 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 initializeRenderer() {
+ if (renderer != null) {
+ renderer.dispose();
+ }
+ renderer = new DisplayRenderer(
+ getDisplay(), getFont(), isBidi(), leftMargin, this, tabLength);
+ lineHeight = renderer.getLineHeight();
+ lineEndSpaceWidth = renderer.getLineEndSpaceWidth();
+}
+/**
+ * Executes the action.
+ * <p>
+ *
+ * @param action one of the actions defined in ST.java
+ */
+public void invokeAction(int action) {
+ int oldColumnX;
+ int caretLine;
+
+ checkWidget();
+ switch (action) {
+ // Navigation
+ case ST.LINE_UP:
+ caretLine = doLineUp();
+ oldColumnX = columnX;
+ // explicitly go to the calculated caret line. may be different
+ // from content.getLineAtOffset(caretOffset) when in word wrap mode
+ showCaret(caretLine);
+ // save the original horizontal caret position
+ columnX = oldColumnX;
+ clearSelection(true);
+ break;
+ case ST.LINE_DOWN:
+ caretLine = doLineDown();
+ oldColumnX = columnX;
+ // explicitly go to the calculated caret line. may be different
+ // from content.getLineAtOffset(caretOffset) when in word wrap mode
+ showCaret(caretLine);
+ // save the original horizontal caret position
+ columnX = oldColumnX;
+ clearSelection(true);
+ break;
+ case ST.LINE_START:
+ doLineStart();
+ clearSelection(true);
+ break;
+ case ST.LINE_END:
+ doLineEnd();
+ clearSelection(true);
+ break;
+ case ST.COLUMN_PREVIOUS:
+ doCursorPrevious();
+ clearSelection(true);
+ break;
+ case ST.COLUMN_NEXT:
+ doCursorNext();
+ clearSelection(true);
+ break;
+ case ST.PAGE_UP:
+ doPageUp();
+ clearSelection(true);
+ break;
+ case ST.PAGE_DOWN:
+ doPageDown(false);
+ clearSelection(true);
+ break;
+ case ST.WORD_PREVIOUS:
+ doWordPrevious();
+ clearSelection(true);
+ break;
+ case ST.WORD_NEXT:
+ doWordNext();
+ clearSelection(true);
+ break;
+ case ST.TEXT_START:
+ doContentStart();
+ clearSelection(true);
+ break;
+ case ST.TEXT_END:
+ doContentEnd();
+ clearSelection(true);
+ break;
+ case ST.WINDOW_START:
+ doPageStart();
+ clearSelection(true);
+ break;
+ case ST.WINDOW_END:
+ doPageEnd();
+ clearSelection(true);
+ break;
+ // Selection
+ case ST.SELECT_LINE_UP:
+ doSelectionLineUp();
+ break;
+ case ST.SELECT_LINE_DOWN:
+ doSelectionLineDown();
+ break;
+ case ST.SELECT_LINE_START:
+ doLineStart();
+ doSelection(SWT.LEFT);
+ break;
+ case ST.SELECT_LINE_END:
+ doLineEnd();
+ doSelection(SWT.RIGHT);
+ break;
+ case ST.SELECT_COLUMN_PREVIOUS:
+ doSelectionCursorPrevious();
+ doSelection(SWT.LEFT);
+ break;
+ case ST.SELECT_COLUMN_NEXT:
+ doSelectionCursorNext();
+ doSelection(SWT.RIGHT);
+ break;
+ case ST.SELECT_PAGE_UP:
+ doSelectionPageUp();
+ doSelection(SWT.LEFT);
+ break;
+ case ST.SELECT_PAGE_DOWN:
+ doSelectionPageDown();
+ break;
+ case ST.SELECT_WORD_PREVIOUS:
+ doSelectionWordPrevious();
+ doSelection(SWT.LEFT);
+ break;
+ case ST.SELECT_WORD_NEXT:
+ doSelectionWordNext();
+ 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();
+ break;
+ case ST.DELETE_NEXT:
+ doDelete();
+ break;
+ case ST.DELETE_WORD_PREVIOUS:
+ doDeleteWordPrevious();
+ break;
+ case ST.DELETE_WORD_NEXT:
+ doDeleteWordNext();
+ break;
+ // Miscellaneous
+ case ST.TOGGLE_OVERWRITE:
+ overwrite = !overwrite; // toggle insert/overwrite mode
+ break;
+ }
+}
+/**
+ * Temporary until SWT provides this
+ */
+boolean isBidi() {
+ return isBidi;
+}
+/**
+ * Returns whether the given offset is inside a multi byte line delimiter.
+ * Example:
+ * "Line1\r\n" isLineDelimiter(5) == false but isLineDelimiter(6) == true
+ *
+ * @return true if the given offset is inside a multi byte line delimiter.
+ * false if the given offset is before or after a line delimiter.
+ */
+boolean isLineDelimiter(int offset) {
+ int line = content.getLineAtOffset(offset);
+ int lineOffset = content.getOffsetAtLine(line);
+ int offsetInLine = offset - lineOffset;
+ // offsetInLine will be greater than line length if the line
+ // delimiter is longer than one character and the offset is set
+ // in between parts of the line delimiter.
+ return offsetInLine > content.getLine(line).length();
+}
+/**
+ * Returns whether or not the given lines are visible.
+ * <p>
+ *
+ * @return true if any of the lines is visible
+ * false if none of the lines is visible
+ */
+boolean isAreaVisible(int firstLine, int lastLine) {
+ int partialBottomIndex = getPartialBottomIndex();
+ int partialTopIndex = verticalScrollOffset / lineHeight;
+ boolean notVisible = firstLine > partialBottomIndex || lastLine < partialTopIndex;
+ return !notVisible;
+}
+/**
+ * Returns whether or not the given styles will necessitate a redraw for the given start line.
+ * A redraw is necessary when font style changes after the start of a style will take place.
+ * This method assumes ranges is in order and non-overlapping.
+ * <p>
+ *
+ * @return true if a redraw of the given line is necessary, false otherwise
+ */
+boolean isRedrawFirstLine(StyleRange[] ranges, int firstLine, int firstLineOffset) {
+ int lineEnd = firstLineOffset + content.getLine(firstLine).length();
+ for (int i=0; i<ranges.length; i++) {
+ StyleRange range = ranges[i];
+ // does the style start on the first line?
+ if (range.start < lineEnd) {
+ int rangeEnd = range.start + range.length;
+ if (isStyleChanging(range, range.start, Math.min(rangeEnd, lineEnd))) return true;
+ } else {
+ return false;
+ }
+ }
+ return false;
+}
+/**
+ * Returns whether or not the given styles will necessitate a redraw for the given end line.
+ * A redraw is necessary when font style changes after the start of a style will take place.
+ * This method assumes ranges is in order and non-overlapping.
+ * <p>
+ *
+ * @return true if a redraw of the last line is necessary, false otherwise
+ */
+boolean isRedrawLastLine(StyleRange[] ranges, int lastLine, int lastLineOffset) {
+ for (int i = ranges.length - 1; i >= 0; i--) {
+ StyleRange range = ranges[i];
+ int rangeEnd = range.start + range.length;
+ // does style range end on the last line?
+ if (rangeEnd >= lastLineOffset) {
+ if (isStyleChanging(range, Math.max(range.start, lastLineOffset), rangeEnd)) return true;
+ } else {
+ break;
+ }
+ }
+ return false;
+}
+/**
+ * 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;
+}
+/**
+ * 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();
+ StyleRange[] styles = defaultLineStyler.getStyleRangesFor(start, end - start);
+
+ if (styles == null) {
+ return (range.fontStyle != SWT.NORMAL);
+ }
+ for (int i = 0; i < styles.length; i++) {
+ StyleRange newStyle = styles[i];
+ if (newStyle.fontStyle != range.fontStyle) {
+ 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;
+ boolean isCharacterRemove = replacedLength == 1 && event.text.length() == 0;
+ boolean isBackspace = event.start < caretOffset;
+ boolean isDirectionBoundary = false;
+
+ if (updateCaret && isBidi() && isCharacterRemove) {
+ // set the keyboard language to the language of the deleted character.
+ // determine direction boundary so that caret location can be updated
+ // properly.
+ int line = content.getLineAtOffset(caretOffset);
+ int lineStartOffset = content.getOffsetAtLine(line);
+ int offsetInLine = caretOffset - lineStartOffset;
+ String lineText = content.getLine(line);
+ GC gc = getGC();
+ StyledTextBidi bidi = new StyledTextBidi(gc, lineText, getBidiSegments(lineStartOffset, lineText));
+ if (isBackspace) {
+ if (offsetInLine > 0) {
+ // the line start/end does not represent a direction boundary
+ // even if the previous/next line has a different direction.
+ isDirectionBoundary =
+ offsetInLine < lineText.length() &&
+ (bidi.isRightToLeft(offsetInLine) != bidi.isRightToLeft(offsetInLine - 1) ||
+ bidi.isLocalNumber(offsetInLine) != bidi.isLocalNumber(offsetInLine - 1));
+ bidi.setKeyboardLanguage(offsetInLine - 1);
+ }
+ }
+ else {
+ if (offsetInLine < lineText.length()) {
+ // the line start/end does not represent a direction boundary
+ // even if the previous/next line has a different direction.
+ isDirectionBoundary =
+ offsetInLine > 0 &&
+ (bidi.isRightToLeft(offsetInLine) != bidi.isRightToLeft(offsetInLine - 1) ||
+ bidi.isLocalNumber(offsetInLine) != bidi.isLocalNumber(offsetInLine - 1));
+ bidi.setKeyboardLanguage(offsetInLine);
+ }
+ }
+ gc.dispose();
+ }
+ if (isListening(ExtendedModify)) {
+ styledTextEvent = new StyledTextEvent(logicalContent);
+ 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) {
+ // always update the caret location. fixes 1G8FODP
+ internalSetSelection(event.start + event.text.length(), 0, true);
+ if (isBidi()) {
+ // Update the caret direction so that the caret moves to the
+ // typed/deleted character. Fixes 1GJLQ16.
+ if (isCharacterRemove) {
+ updateBidiDirection(isBackspace, isDirectionBoundary);
+ }
+ else {
+ lastCaretDirection = ST.COLUMN_NEXT;
+ }
+ showBidiCaret();
+ }
+ else {
+ showCaret();
+ }
+ }
+ notifyListeners(SWT.Modify, event);
+ if (isListening(ExtendedModify)) {
+ notifyListeners(ExtendedModify, styledTextEvent);
+ }
+ }
+}
+/**
+ * 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);
+ }
+}
+/**
+ * Render the specified area. Broken out as its own method to support
+ * direct drawing.
+ * <p>
+ *
+ * @param gc GC to render on
+ * @param startLine first line to render
+ * @param startY y pixel location to start rendering at
+ * @param renderHeight renderHeight widget area that needs to be filled with lines
+ */
+void performPaint(GC gc,int startLine,int startY, int renderHeight) {
+ Rectangle clientArea = getClientArea();
+ Color background = getBackground();
+
+ // Check if there is work to do. We never want to try and create
+ // an Image with 0 width or 0 height.
+ if (clientArea.width == 0) {
+ return;
+ }
+ if (renderHeight > 0) {
+ // renderHeight will be negative when only top margin needs redrawing
+ Color foreground = getForeground();
+ int lineCount = content.getLineCount();
+ int paintY = 0;
+
+ if (isSingleLine()) {
+ lineCount = 1;
+ if (startLine > 1) {
+ startLine = 1;
+ }
+ }
+ Image lineBuffer = new Image(getDisplay(), clientArea.width, renderHeight);
+ GC lineGC = new GC(lineBuffer);
+
+ lineGC.setFont(getFont());
+ renderer.setCurrentFontStyle(SWT.NORMAL);
+ lineGC.setForeground(foreground);
+ lineGC.setBackground(background);
+
+ for (int i = startLine; paintY < renderHeight && i < lineCount; i++, paintY += lineHeight) {
+ String line = content.getLine(i);
+ renderer.drawLine(line, i, paintY, lineGC, background, foreground, true);
+ }
+ if (paintY < renderHeight) {
+ lineGC.setBackground(background);
+ lineGC.setForeground(background);
+ lineGC.fillRectangle(0, paintY, clientArea.width, renderHeight - paintY);
+ }
+ gc.drawImage(lineBuffer, 0, startY);
+ lineGC.dispose();
+ lineBuffer.dispose();
+ }
+ clearMargin(gc, background, clientArea, renderHeight);
+}
+/**
+ * Prints the widget's text to the default printer.
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void print() {
+ checkWidget();
+ Printer printer = new Printer();
+ StyledTextPrintOptions options = new StyledTextPrintOptions();
+
+ options.printTextForeground = true;
+ options.printTextBackground = true;
+ options.printTextFontStyle = true;
+ options.printLineBackground = true;
+ new Printing(this, printer, options).run();
+ printer.dispose();
+}
+/**
+ * Returns a runnable that will print the widget's text
+ * to the specified printer.
+ * <p>
+ * The runnable may be run in a non-UI thread.
+ * </p>
+ *
+ * @param printer the printer to print to
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT when printer is null</li>
+ * </ul>
+ */
+public Runnable print(Printer printer) {
+ StyledTextPrintOptions options = new StyledTextPrintOptions();
+
+ checkWidget();
+ options.printTextForeground = true;
+ options.printTextBackground = true;
+ options.printTextFontStyle = true;
+ options.printLineBackground = true;
+ if (printer == null) {
+ SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ }
+ return print(printer, options);
+}
+/**
+ * Returns a runnable that will print the widget's text
+ * to the specified printer.
+ * <p>
+ * The runnable may be run in a non-UI thread.
+ * </p>
+ *
+ * @param printer the printer to print to
+ * @param options print options to use during printing
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT when printer or options is null</li>
+ * </ul>
+ * @since 2.1
+ */
+public Runnable print(Printer printer, StyledTextPrintOptions options) {
+ checkWidget();
+ if (printer == null || options == null) {
+ SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ }
+ return new Printing(this, printer, options);
+}
+/**
+ * Causes the entire bounds of the receiver to be marked
+ * as needing to be redrawn. The next time a paint request
+ * is processed, the control will be completely painted.
+ * <p>
+ * Recalculates the content width for all lines in the bounds.
+ * When a <code>LineStyleListener</code> is used a redraw call
+ * is the only notification to the widget that styles have changed
+ * and that the content width may have changed.
+ * </p>
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see Control#update
+ */
+public void redraw() {
+ int itemCount;
+
+ super.redraw();
+ itemCount = getPartialBottomIndex() - topIndex + 1;
+ lineCache.redrawReset(topIndex, itemCount, true);
+ lineCache.calculate(topIndex, itemCount);
+ setHorizontalScrollBar();
+}
+/**
+ * Causes the rectangular area of the receiver specified by
+ * the arguments to be marked as needing to be redrawn.
+ * The next time a paint request is processed, that area of
+ * the receiver will be painted. If the <code>all</code> flag
+ * is <code>true</code>, any children of the receiver which
+ * intersect with the specified area will also paint their
+ * intersecting areas. If the <code>all</code> flag is
+ * <code>false</code>, the children will not be painted.
+ * <p>
+ * Marks the content width of all lines in the specified rectangle
+ * as unknown. Recalculates the content width of all visible lines.
+ * When a <code>LineStyleListener</code> is used a redraw call
+ * is the only notification to the widget that styles have changed
+ * and that the content width may have changed.
+ * </p>
+ *
+ * @param x the x coordinate of the area to draw
+ * @param y the y coordinate of the area to draw
+ * @param width the width of the area to draw
+ * @param height the height of the area to draw
+ * @param all <code>true</code> if children should redraw, and <code>false</code> otherwise
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see Control#update
+ */
+public void redraw(int x, int y, int width, int height, boolean all) {
+ super.redraw(x, y, width, height, all);
+ if (height > 0) {
+ int lineCount = content.getLineCount();
+ int startLine = (getTopPixel() + y) / lineHeight;
+ int endLine = startLine + Compatibility.ceil(height, lineHeight);
+ int itemCount;
+
+ // reset all lines in the redraw rectangle
+ startLine = Math.min(startLine, lineCount);
+ itemCount = Math.min(endLine, lineCount) - startLine;
+ lineCache.reset(startLine, itemCount, true);
+ // only calculate the visible lines
+ itemCount = getPartialBottomIndex() - topIndex + 1;
+ lineCache.calculate(topIndex, itemCount);
+ setHorizontalScrollBar();
+ }
+}
+/**
+ * Redraws a text range in the specified lines
+ * <p>
+ *
+ * @param firstLine first line to redraw at the specified offset
+ * @param offsetInFirstLine offset in firstLine to start redrawing
+ * @param lastLine last line to redraw
+ * @param endOffset offset in the last where redrawing should stop
+ * @param clearBackground true=clear the background by invalidating
+ * the requested redraw range, false=draw the foreground directly
+ * without invalidating the redraw range.
+ */
+void redrawBidiLines(int firstLine, int offsetInFirstLine, int lastLine, int endOffset, boolean clearBackground) {
+ int lineCount = lastLine - firstLine + 1;
+ int redrawY = firstLine * lineHeight - verticalScrollOffset;
+ int firstLineOffset = content.getOffsetAtLine(firstLine);
+ String line = content.getLine(firstLine);
+ GC gc = getGC();
+ StyledTextBidi bidi = getStyledTextBidi(line, firstLineOffset, gc);
+
+ bidi.redrawRange(
+ this, offsetInFirstLine,
+ Math.min(line.length(), endOffset) - offsetInFirstLine,
+ leftMargin - horizontalScrollOffset, redrawY + topMargin, lineHeight);
+ // redraw line break marker (either space or full client area width)
+ // if redraw range extends over more than one line and background should be redrawn
+ if (lastLine > firstLine && clearBackground) {
+ int lineBreakWidth;
+ int lineBreakStartX = bidi.getTextWidth();
+ // handle empty line case
+ if (lineBreakStartX == leftMargin) {
+ lineBreakStartX += XINSET;
+ }
+ lineBreakStartX = lineBreakStartX - horizontalScrollOffset;
+ if ((getStyle() & SWT.FULL_SELECTION) != 0) {
+ lineBreakWidth = getClientArea().width - lineBreakStartX;
+ }
+ else {
+ lineBreakWidth = lineEndSpaceWidth;
+ }
+ draw(lineBreakStartX, redrawY, lineBreakWidth, lineHeight, clearBackground);
+ }
+ // redraw last line if more than one line needs redrawing
+ if (lineCount > 1) {
+ int lastLineOffset = content.getOffsetAtLine(lastLine);
+ int offsetInLastLine = endOffset - lastLineOffset;
+ // no redraw necessary if redraw offset is 0
+ if (offsetInLastLine > 0) {
+ line = content.getLine(lastLine);
+ redrawY = lastLine * lineHeight - verticalScrollOffset;
+ bidi = getStyledTextBidi(line, lastLineOffset, gc);
+ bidi.redrawRange(
+ this, 0, offsetInLastLine,
+ leftMargin - horizontalScrollOffset,
+ redrawY + topMargin, lineHeight);
+ }
+ }
+ gc.dispose();
+}
+/**
+ * Redraw the given line.
+ * <p>
+ *
+ * @param line index of the line to redraw
+ * @param offset offset in line to start redrawing
+ */
+void redrawLine(int line, int offset) {
+ int redrawX = 0;
+ if (offset > 0) {
+ String lineText = content.getLine(line);
+ redrawX = getXAtOffset(lineText, line, offset);
+ }
+ int redrawY = line * lineHeight - verticalScrollOffset;
+ super.redraw(
+ redrawX + leftMargin, redrawY + topMargin,
+ getClientArea().width, lineHeight, true);
+}
+/**
+ * Redraws a text range in the specified lines
+ * <p>
+ *
+ * @param firstLine first line to redraw at the specified offset
+ * @param offsetInFirstLine offset in firstLine to start redrawing
+ * @param lastLine last line to redraw
+ * @param endOffset offset in the last where redrawing should stop
+ * @param clearBackground true=clear the background by invalidating
+ * the requested redraw range. If the redraw range includes the
+ * last character of a line (i.e., the entire line is redrawn) the
+ * line is cleared all the way to the right border of the widget.
+ * false=draw the foreground directly without invalidating the
+ * redraw range.
+ */
+void redrawLines(int firstLine, int offsetInFirstLine, int lastLine, int endOffset, boolean clearBackground) {
+ String line = content.getLine(firstLine);
+ int lineCount = lastLine - firstLine + 1;
+ int redrawX = getXAtOffset(line, firstLine, offsetInFirstLine) - leftMargin;
+ int redrawStopX;
+ int redrawY = firstLine * lineHeight - verticalScrollOffset;
+ int firstLineOffset = content.getOffsetAtLine(firstLine);
+ boolean fullLineRedraw = ((getStyle() & SWT.FULL_SELECTION) != 0 && lastLine > firstLine);
+
+ // if redraw range includes last character on the first line,
+ // clear background to right widget border. fixes bug 19595.
+ if (clearBackground && endOffset - firstLineOffset >= line.length()) {
+ fullLineRedraw = true;
+ }
+ // calculate redraw stop location
+ if (fullLineRedraw) {
+ redrawStopX = getClientArea().width - leftMargin;
+ }
+ else {
+ redrawStopX = getXAtOffset(line, firstLine, endOffset - firstLineOffset) - leftMargin;
+ }
+ draw(redrawX, redrawY, redrawStopX - redrawX, lineHeight, clearBackground);
+ // redraw last line if more than one line needs redrawing
+ if (lineCount > 1) {
+ int offsetInLastLine = endOffset - content.getOffsetAtLine(lastLine);
+ // no redraw necessary if redraw offset is 0
+ if (offsetInLastLine > 0) {
+ line = content.getLine(lastLine);
+ // if redraw range includes last character on the last line,
+ // clear background to right widget border. fixes bug 19595.
+ if (clearBackground && offsetInLastLine >= line.length()) {
+ fullLineRedraw = true;
+ }
+ if (fullLineRedraw) {
+ redrawStopX = getClientArea().width - leftMargin;
+ }
+ else {
+ redrawStopX = getXAtOffset(line, lastLine, offsetInLastLine) - leftMargin;
+ }
+ redrawY = lastLine * lineHeight - verticalScrollOffset;
+ draw(0, redrawY, redrawStopX, lineHeight, clearBackground);
+ }
+ }
+}
+/**
+ * Fixes the widget to display a text change.
+ * Bit blitting and redrawing is done as necessary.
+ * <p>
+ *
+ * @param y y location of the text change
+ * @param newLineCount number of new lines.
+ * @param replacedLineCount number of replaced lines.
+ */
+void redrawMultiLineChange(int y, int newLineCount, int replacedLineCount) {
+ Rectangle clientArea = getClientArea();
+ int lineCount = newLineCount - replacedLineCount;
+ int sourceY;
+ int destinationY;
+
+ if (lineCount > 0) {
+ sourceY = Math.max(0, y + lineHeight);
+ destinationY = sourceY + lineCount * lineHeight;
+ }
+ else {
+ destinationY = Math.max(0, y + lineHeight);
+ sourceY = destinationY - lineCount * 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.
+ if (y + lineHeight > 0 && y <= clientArea.height) {
+ // redraw first changed line in case a line was split/joined
+ super.redraw(0, y, clientArea.width, lineHeight, true);
+ }
+ if (newLineCount > 0) {
+ int redrawStartY = y + lineHeight;
+ int redrawHeight = newLineCount * lineHeight;
+
+ if (redrawStartY + redrawHeight > 0 && redrawStartY <= clientArea.height) {
+ // display new text
+ super.redraw(0, redrawStartY, clientArea.width, redrawHeight, true);
+ }
+ }
+}
+/**
+ * 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 range will
+ * be cleared before anything is redrawn. If the redraw range includes
+ * the last character of a line (i.e., the entire line is redrawn) the
+ * line is cleared all the way to the right border of the widget.
+ * The redraw operation will be faster and smoother if clearBackground
+ * is set to false. Whether or not the flag can be set to false depends
+ * on the type of change that has taken place. If font styles or
+ * background colors for the redraw range have changed, clearBackground
+ * should be set to true. If only foreground colors have changed for
+ * the redraw range, clearBackground can be set to false.
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_INVALID_RANGE when start and/or end are outside the widget content</li>
+ * </ul>
+ */
+public void redrawRange(int start, int length, boolean clearBackground) {
+ checkWidget();
+ int end = start + length;
+ int contentLength = content.getCharCount();
+ int firstLine;
+ int lastLine;
+
+ if (start > end || start < 0 || end > contentLength) {
+ SWT.error(SWT.ERROR_INVALID_RANGE);
+ }
+ firstLine = content.getLineAtOffset(start);
+ lastLine = content.getLineAtOffset(end);
+ // reset all affected lines but let the redraw recalculate only
+ // those that are visible.
+ lineCache.reset(firstLine, lastLine - firstLine + 1, true);
+ internalRedrawRange(start, length, clearBackground);
+}
+/**
+ * Removes the specified bidirectional segment 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>
+ * @since 2.0
+ */
+public void removeBidiSegmentListener(BidiSegmentListener listener) {
+ checkWidget();
+ if (listener == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ removeListener(LineGetSegments, listener);
+}
+/**
+ * Removes the specified extended modify listener.
+ * <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 styles in the given range with new styles. This method
+ * effectively deletes the styles in the given range and then adds the
+ * the new styles.
+ * <p>
+ * Should not be called if a LineStyleListener has been set since the
+ * listener maintains the styles.
+ * </p>
+ *
+ * @param start offset of first character where styles will be deleted
+ * @param length length of the range to delete styles in
+ * @param ranges StyleRange objects containing the new style information.
+ * The ranges should not overlap and should be within the specified start
+ * and length. The style rendering is undefined if the ranges do overlap
+ * or are ill-defined. Must not be null.
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_INVALID_RANGE when either start or end is outside the valid range (0 <= offset <= getCharCount())</li>
+ * <li>ERROR_NULL_ARGUMENT when string is null</li>
+ * </ul>
+ * @since 2.0
+ */
+public void replaceStyleRanges(int start, int length, StyleRange[] ranges) {
+ checkWidget();
+ if (userLineStyle) {
+ return;
+ }
+ if (ranges == null) {
+ SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ }
+ if (ranges.length == 0) {
+ setStyleRange(new StyleRange(start, length, null, null));
+ return;
+ }
+ int end = start + length;
+ if (start > end || start < 0 || end > getCharCount()) {
+ SWT.error(SWT.ERROR_INVALID_RANGE);
+ }
+
+ int firstLine = content.getLineAtOffset(start);
+ int lastLine = content.getLineAtOffset(end);
+
+ // if the area is not visible, there is no need to redraw
+ boolean redrawLines = isAreaVisible(firstLine, lastLine);
+
+ if (!redrawLines) {
+ defaultLineStyler.replaceStyleRanges(start, length, ranges);
+ lineCache.reset(firstLine, lastLine - firstLine + 1, true);
+ } else {
+ boolean redrawFirstLine = false;
+ boolean redrawLastLine = false;
+ // 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 firstLineOffset = content.getOffsetAtLine(firstLine);
+ if (isBidi()) {
+ redrawFirstLine = true;
+ redrawLastLine = true;
+ } else {
+ int firstLineEnd = firstLineOffset + content.getLine(firstLine).length();
+ redrawFirstLine = isRedrawFirstLine(ranges, firstLine, firstLineOffset);
+ // check if any bold styles will be cleared
+ StyleRange clearRange = new StyleRange(firstLineOffset, firstLineEnd - firstLineOffset, null, null);
+ redrawFirstLine = redrawFirstLine || isRedrawFirstLine(new StyleRange[] {clearRange}, firstLine, firstLineOffset);
+ if (lastLine != firstLine) {
+ int lastLineOffset = content.getOffsetAtLine(lastLine);
+ int lastLineEnd = lastLineOffset + content.getLine(lastLine).length();
+ redrawLastLine = isRedrawLastLine(ranges, lastLine, lastLineOffset);
+ // check if any bold styles will be cleared
+ clearRange = new StyleRange(lastLineOffset, lastLineEnd - lastLineOffset, null, null);
+ redrawLastLine = redrawLastLine || isRedrawLastLine(new StyleRange[] {clearRange}, lastLine, lastLineOffset);
+ }
+ }
+ defaultLineStyler.replaceStyleRanges(start, length, ranges);
+ // reset all lines affected by the style change but let the redraw
+ // recalculate only those that are visible.
+ lineCache.reset(firstLine, lastLine - firstLine + 1, true);
+ internalRedrawRange(start, length, true);
+ if (redrawFirstLine) {
+ redrawLine(firstLine, start - firstLineOffset);
+ }
+ if (redrawLastLine) {
+ redrawLine(lastLine, 0);
+ }
+ }
+
+ // make sure that the caret is positioned correctly.
+ // caret location may change if font style changes.
+ // fixes 1G8FODP
+ setCaretLocation();
+}
+/**
+ * Replaces the given text range with new text.
+ * If the widget has the SWT.SINGLE style and "text" contains more than
+ * one line, only the first line is rendered but the text is stored
+ * unchanged. A subsequent call to getText will return the same text
+ * that was set. Note that only a single line of text should be set when
+ * the SWT.SINGLE style is used.
+ * <p>
+ * <b>NOTE:</b> During the replace operation the current selection is
+ * changed as follows:
+ * <ul>
+ * <li>selection before replaced text: selection unchanged
+ * <li>selection after replaced text: adjust the selection so that same text
+ * remains selected
+ * <li>selection intersects replaced text: selection is cleared and caret
+ * is placed after inserted text
+ * </ul>
+ * </p>
+ *
+ * @param start offset of first character to replace
+ * @param length number of characters to replace. Use 0 to insert text
+ * @param text new text. May be empty to delete text.
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_INVALID_RANGE when either start or end is outside the valid range (0 <= offset <= getCharCount())</li>
+ * <li>ERROR_INVALID_ARGUMENT when either start or end is inside a multi byte line delimiter.
+ * Splitting a line delimiter for example by inserting text in between the CR and LF and deleting part of a line delimiter is not supported</li>
+ * <li>ERROR_NULL_ARGUMENT when string is null</li>
+ * </ul>
+ */
+public void replaceTextRange(int start, int length, String text) {
+ checkWidget();
+ int contentLength = getCharCount();
+ int end = start + length;
+ Event event = new Event();
+
+ if (start > end || start < 0 || end > contentLength) {
+ SWT.error(SWT.ERROR_INVALID_RANGE);
+ }
+ if (text == null) {
+ SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ }
+ 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;
+ topOffset = 0;
+ verticalScrollOffset = 0;
+ horizontalScrollOffset = 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();
+ super.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();
+ if (pixels > 0) {
+ int sourceX = leftMargin + pixels;
+ int scrollWidth = clientArea.width - sourceX - rightMargin;
+ int scrollHeight = clientArea.height - topMargin - bottomMargin;
+ scroll(
+ leftMargin, topMargin, // destination x, y
+ sourceX, topMargin, // source x, y
+ scrollWidth, scrollHeight, true);
+ if (sourceX > scrollWidth) {
+ // redraw from end of scrolled area to beginning of scroll
+ // invalidated area
+ super.redraw(
+ leftMargin + scrollWidth, topMargin,
+ pixels - scrollWidth, scrollHeight, true);
+ }
+ }
+ else {
+ int destinationX = leftMargin - pixels;
+ int scrollWidth = clientArea.width - destinationX - rightMargin;
+ int scrollHeight = clientArea.height - topMargin - bottomMargin;
+ scroll(
+ destinationX, topMargin, // destination x, y
+ leftMargin, topMargin, // source x, y
+ scrollWidth, scrollHeight, true);
+ if (destinationX > scrollWidth) {
+ // redraw from end of scroll invalidated area to scroll
+ // destination
+ super.redraw(
+ leftMargin + scrollWidth, topMargin,
+ -pixels - scrollWidth, scrollHeight, 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
+ * @return
+ * true=the widget was scrolled
+ * false=the widget was not scrolled, the given offset is not valid.
+ */
+boolean scrollHorizontalBar(int pixels) {
+ if (pixels == 0) {
+ return false;
+ }
+ ScrollBar horizontalBar = getHorizontalBar();
+ if (horizontalBar != null) {
+ horizontalBar.setSelection(horizontalScrollOffset + pixels);
+ }
+ scrollHorizontal(pixels);
+ return true;
+}
+/**
+ * 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);
+}
+/**
+ * Sets whether the widget wraps lines.
+ * This overrides the creation style bit SWT.WRAP.
+ * <p>
+ *
+ * @param wrap true=widget wraps lines, false=widget does not wrap lines
+ * @since 2.0
+ */
+public void setWordWrap(boolean wrap) {
+ checkWidget();
+
+ if (wrap != wordWrap) {
+ ScrollBar horizontalBar = getHorizontalBar();
+
+ wordWrap = wrap;
+ if (wordWrap) {
+ logicalContent = content;
+ content = new WrappedContent(renderer, logicalContent);
+ }
+ else {
+ content = logicalContent;
+ }
+ calculateContentWidth();
+ horizontalScrollOffset = 0;
+ if (horizontalBar != null) {
+ horizontalBar.setVisible(!wordWrap);
+ }
+ setScrollBars();
+ setCaretLocation();
+ super.redraw();
+ }
+}
+/**
+ * Sets the caret location and scrolls the caret offset into view.
+ */
+void showBidiCaret() {
+ int line = content.getLineAtOffset(caretOffset);
+ int lineOffset = content.getOffsetAtLine(line);
+ int offsetInLine = caretOffset - lineOffset;
+ String lineText = content.getLine(line);
+ int xAtOffset = 0;
+ boolean scrolled = false;
+ GC gc = getGC();
+ StyledTextBidi bidi = getStyledTextBidi(lineText, lineOffset, gc);
+ // getXAtOffset, inlined for better performance
+ xAtOffset = getBidiTextPosition(lineText, offsetInLine, bidi) + leftMargin;
+ if (offsetInLine > lineText.length()) {
+ // offset is not on the line. return an x location one character
+ // after the line to indicate the line delimiter.
+ xAtOffset += lineEndSpaceWidth;
+ }
+ xAtOffset -= horizontalScrollOffset;
+ //
+ scrolled = showLocation(xAtOffset, line);
+ if (scrolled == false) {
+ setBidiCaretLocation(bidi);
+ }
+ gc.dispose();
+}
+/**
+ * Sets the receiver's caret. Set the caret's height and location.
+ *
+ * </p>
+ * @param caret the new caret for the receiver
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setCaret(Caret caret) {
+ checkWidget ();
+ super.setCaret(caret);
+ if (caret != null) {
+ if (isBidi() == false) {
+ caret.setSize(caret.getSize().x, lineHeight);
+ }
+ setCaretLocation();
+ if (isBidi()) {
+ setBidiKeyboardLanguage();
+ }
+ }
+}
+/**
+ * @see org.eclipse.swt.widgets.Control#setBackground
+ */
+public void setBackground(Color color) {
+ checkWidget();
+ super.setBackground(color);
+ background = color;
+ redraw();
+}
+/**
+ * Set the caret to indicate the current typing direction.
+ */
+void setBidiCaretDirection() {
+ Caret caret = getCaret();
+ int direction = StyledTextBidi.getKeyboardLanguageDirection();
+
+ if (caret == null || direction == caretDirection) {
+ return;
+ }
+ caretDirection = direction;
+ if (direction == SWT.DEFAULT) {
+ caret.setImage(null);
+ caret.setSize(caret.getSize().x, lineHeight);
+ }
+ else
+ if (caretDirection == SWT.LEFT) {
+ caret.setImage(leftCaretBitmap);
+ }
+ else
+ if (caretDirection == SWT.RIGHT) {
+ caret.setImage(rightCaretBitmap);
+ }
+}
+/**
+ * Moves the Caret to the current caret offset.
+ * <p>
+ *
+ * @param bidi StyledTextBidi object to use for measuring.
+ * May be left null in which case a new object will be created.
+ */
+void setBidiCaretLocation(StyledTextBidi bidi) {
+ int caretLine = getCaretLine();
+
+ setBidiCaretLocation(bidi, caretLine);
+}
+/**
+ * Moves the Caret to the current caret offset.
+ * <p>
+ *
+ * @param bidi StyledTextBidi object to use for measuring.
+ * May be left null in which case a new object will be created.
+ * @param caretLine line the caret should be placed on. Relative to
+ * first line in document
+ */
+void setBidiCaretLocation(StyledTextBidi bidi, int caretLine) {
+ Caret caret = getCaret();
+ String lineText = content.getLine(caretLine);
+ int lineStartOffset = content.getOffsetAtLine(caretLine);
+ int offsetInLine = caretOffset - lineStartOffset;
+ GC gc = null;
+
+ if (bidi == null) {
+ gc = getGC();
+ bidi = getStyledTextBidi(lineText, lineStartOffset, gc);
+ }
+ if (lastCaretDirection == SWT.NULL) {
+ columnX = bidi.getTextPosition(offsetInLine) + leftMargin - horizontalScrollOffset;
+ } else {
+ columnX = bidi.getTextPosition(offsetInLine, lastCaretDirection) + leftMargin - horizontalScrollOffset;
+ }
+ if (StyledTextBidi.getKeyboardLanguageDirection() == SWT.RIGHT) {
+ columnX -= (getCaretWidth() - 1);
+ }
+ if (caret != null) {
+ setBidiCaretDirection();
+ caret.setLocation(
+ columnX,
+ caretLine * lineHeight - verticalScrollOffset + topMargin);
+ }
+ if (gc != null) {
+ gc.dispose();
+ }
+}
+/**
+ * Sets the BIDI coloring mode. When true the BIDI text display
+ * algorithm is applied to segments of text that are the same
+ * color.
+ *
+ * @param mode the new coloring mode
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * <p>
+ * @deprecated use BidiSegmentListener instead.
+ * </p>
+ */
+public void setBidiColoring(boolean mode) {
+ checkWidget();
+ bidiColoring = mode;
+}
+/**
+ * Switches the keyboard language according to the current editing
+ * position and cursor direction.
+ */
+void setBidiKeyboardLanguage() {
+ int caretLine = getCaretLine();
+ int lineStartOffset = content.getOffsetAtLine(caretLine);
+ int offsetInLine = caretOffset - lineStartOffset;
+ String lineText = content.getLine(caretLine);
+ GC gc = getGC();
+ StyledTextBidi bidi;
+ int lineLength = lineText.length();
+
+ // Don't supply the bold styles/font since we don't want to measure anything
+ bidi = new StyledTextBidi(gc, lineText, getBidiSegments(lineStartOffset, lineText));
+ if (offsetInLine == 0) {
+ bidi.setKeyboardLanguage(offsetInLine);
+ }
+ else
+ if (offsetInLine >= lineLength) {
+ offsetInLine = Math.min(offsetInLine, lineLength - 1);
+ bidi.setKeyboardLanguage(offsetInLine);
+ }
+ else
+ if (lastCaretDirection == ST.COLUMN_NEXT) {
+ // continue with previous character type
+ bidi.setKeyboardLanguage(offsetInLine - 1);
+ }
+ else {
+ bidi.setKeyboardLanguage(offsetInLine);
+ }
+ gc.dispose();
+}
+/**
+ * Moves the Caret to the current caret offset.
+ * <p>
+ *
+ * @param newCaretX the new x location of the caret.
+ * passed in for better performance when it has already been
+ * calculated outside this method.
+ * @param line index of the line the caret is on. Relative to
+ * the first line in the document.
+ */
+void setCaretLocation(int newCaretX, int line) {
+ if (isBidi()) {
+ setBidiCaretLocation(null, line);
+ }
+ else {
+ Caret caret = getCaret();
+
+ columnX = newCaretX;
+ if (caret != null) {
+ caret.setLocation(
+ newCaretX,
+ line * lineHeight - verticalScrollOffset + topMargin);
+ }
+ }
+}
+/**
+ * Moves the Caret to the current caret offset.
+ */
+void setCaretLocation() {
+ if (isBidi()) {
+ setBidiCaretLocation(null);
+ }
+ else {
+ Caret caret = getCaret();
+ int caretLine = getCaretLine();
+ int lineStartOffset = content.getOffsetAtLine(caretLine);
+
+ columnX = getXAtOffset(
+ content.getLine(caretLine), caretLine, caretOffset - lineStartOffset);
+ if (caret != null) {
+ caret.setLocation(
+ columnX,
+ caretLine * lineHeight - verticalScrollOffset + topMargin);
+ }
+ }
+}
+/**
+ * Sets the caret offset.
+ *
+ * @param offset caret offset, relative to the first character in the text.
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_INVALID_ARGUMENT when either the start or the end of the selection range is inside a
+ * multi byte line delimiter (and thus neither clearly in front of or after the line delimiter)
+ * </ul>
+ */
+public void setCaretOffset(int offset) {
+ checkWidget();
+ int length = getCharCount();
+
+ if (length > 0 && offset != caretOffset) {
+ if (offset < 0) {
+ caretOffset = 0;
+ }
+ else
+ if (offset > length) {
+ caretOffset = length;
+ }
+ else {
+ if (isLineDelimiter(offset)) {
+ // offset is inside a multi byte line delimiter. This is an
+ // illegal operation and an exception is thrown. Fixes 1GDKK3R
+ SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+ }
+ caretOffset = offset;
+ }
+ // 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();
+ if (isBidi()) {
+ setBidiKeyboardLanguage();
+ }
+}
+/**
+ * Copies the specified text range to the clipboard. The text will be placed
+ * in the clipboard in plain text format and RTF format.
+ * <p>
+ *
+ * @param start start index of the text
+ * @param length length of text to place in clipboard
+ *
+ * @exception SWTError, see Clipboard.setContents
+ * @see org.eclipse.swt.dnd.Clipboard.setContents
+ */
+void setClipboardContent(int start, int length) throws SWTError {
+ RTFTransfer rtfTransfer = RTFTransfer.getInstance();
+ TextTransfer plainTextTransfer = TextTransfer.getInstance();
+ RTFWriter rtfWriter = new RTFWriter(start, length);
+ TextWriter plainTextWriter = new TextWriter(start, length);
+ String rtfText = getPlatformDelimitedText(rtfWriter);
+ String plainText = getPlatformDelimitedText(plainTextWriter);
+
+ clipboard.setContents(
+ new String[]{rtfText, plainText},
+ new Transfer[]{rtfTransfer, plainTextTransfer});
+}
+/**
+ * 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 newContent) {
+ checkWidget();
+ if (newContent == null) {
+ SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ }
+ if (content != null) {
+ content.removeTextChangeListener(textChangeListener);
+ }
+ logicalContent = newContent;
+ if (wordWrap) {
+ content = new WrappedContent(renderer, logicalContent);
+ }
+ else {
+ content = logicalContent;
+ }
+ content.addTextChangeListener(textChangeListener);
+ reset();
+}
+/**
+ * Sets the receiver's cursor to the cursor specified by the
+ * argument. Overridden to handle the null case since the
+ * StyledText widget uses an ibeam as its default cursor.
+ *
+ * @see org.eclipse.swt.widgets.Control#setCursor
+ */
+public void setCursor (Cursor cursor) {
+ if (cursor == null) {
+ super.setCursor(ibeamCursor);
+ } else {
+ super.setCursor(cursor);
+ }
+}
+/**
+ * Sets whether the widget implements double click mouse behavior.
+ * </p>
+ *
+ * @param enable if true double clicking a word selects the word, if false
+ * double clicks have the same effect as regular mouse clicks.
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setDoubleClickEnabled(boolean enable) {
+ checkWidget();
+ doubleClickEnabled = enable;
+}
+/**
+ * Sets whether the widget content can be edited.
+ * </p>
+ *
+ * @param editable if true content can be edited, if false content can not be
+ * edited
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setEditable(boolean editable) {
+ checkWidget();
+ this.editable = editable;
+}
+/**
+ * Sets a new font to render text with.
+ * <p>
+ * <b>NOTE:</b> Italic fonts are not supported unless they have no overhang
+ * and the same baseline as regular fonts.
+ * </p>
+ *
+ * @param font new font
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setFont(Font font) {
+ checkWidget();
+ int oldLineHeight = lineHeight;
+
+ super.setFont(font);
+ initializeRenderer();
+ // keep the same top line visible. fixes 5815
+ if (lineHeight != oldLineHeight) {
+ setVerticalScrollOffset(verticalScrollOffset * lineHeight / oldLineHeight, true);
+ claimBottomFreeSpace();
+ }
+ calculateContentWidth();
+ calculateScrollBars();
+ if (isBidi()) {
+ caretDirection = SWT.NULL;
+ createCaretBitmaps();
+ setBidiCaretDirection();
+ }
+ else {
+ Caret caret = getCaret();
+ if (caret != null) {
+ caret.setSize(caret.getSize().x, lineHeight);
+ }
+ }
+ // always set the caret location. Fixes 6685
+ setCaretLocation();
+ super.redraw();
+}
+/**
+ * @see org.eclipse.swt.widgets.Control#setForeground
+ */
+public void setForeground(Color color) {
+ checkWidget();
+ super.setForeground(color);
+ foreground = color;
+ 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) {
+ int width = lineCache.getWidth();
+ // prevent scrolling if the content fits in the client area.
+ // align end of longest line with right border of client area
+ // if offset is out of range.
+ if (offset > width - clientAreaWidth) {
+ offset = Math.max(0, width - clientAreaWidth);
+ }
+ }
+ scrollHorizontalBar(offset - horizontalScrollOffset);
+}
+/**
+ * Sets the horizontal pixel offset relative to the start of the line.
+ * Do nothing if there is no text set.
+ * <p>
+ * <b>NOTE:</b> The horizontal pixel offset is reset to 0 when new text
+ * is set in the widget.
+ * </p>
+ *
+ * @param pixel horizontal pixel offset relative to the start
+ * of the line.
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * @since 2.0
+ */
+public void setHorizontalPixel(int pixel) {
+ checkWidget();
+ int clientAreaWidth = getClientArea().width;
+ if (getCharCount() == 0) {
+ return;
+ }
+ if (pixel < 0) {
+ pixel = 0;
+ }
+ // allow any value if client area width is unknown or 0.
+ // offset will be checked in resize handler.
+ // don't use isVisible since width is known even if widget
+ // is temporarily invisible
+ if (clientAreaWidth > 0) {
+ int width = lineCache.getWidth();
+ // prevent scrolling if the content fits in the client area.
+ // align end of longest line with right border of client area
+ // if offset is out of range.
+ if (pixel > width - clientAreaWidth) {
+ pixel = Math.max(0, width - clientAreaWidth);
+ }
+ }
+ scrollHorizontalBar(pixel - horizontalScrollOffset);
+}
+/**
+ * Adjusts the maximum and the page size of the horizontal scroll bar
+ * to reflect content width changes.
+ */
+void setHorizontalScrollBar() {
+ ScrollBar horizontalBar = getHorizontalBar();
+
+ if (horizontalBar != null && horizontalBar.getVisible()) {
+ final int INACTIVE = 1;
+ Rectangle clientArea = getClientArea();
+ // 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 < lineCache.getWidth()) {
+ horizontalBar.setValues(
+ horizontalBar.getSelection(),
+ horizontalBar.getMinimum(),
+ lineCache.getWidth(), // maximum
+ clientArea.width - leftMargin - rightMargin, // thumb size
+ horizontalBar.getIncrement(),
+ clientArea.width - leftMargin - rightMargin); // page size
+ }
+ else
+ if (horizontalBar.getThumb() != INACTIVE || horizontalBar.getMaximum() != INACTIVE) {
+ horizontalBar.setValues(
+ horizontalBar.getSelection(),
+ horizontalBar.getMinimum(),
+ INACTIVE,
+ INACTIVE,
+ horizontalBar.getIncrement(),
+ INACTIVE);
+ }
+ }
+}
+/**
+ * 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>
+ * Line background colors are maintained relative to the line text, not the
+ * line index that is specified in this method call.
+ * During text changes, when entire lines are inserted or removed, the line
+ * background colors that are associated with the lines after the change
+ * will "move" with their respective text. An entire line is defined as
+ * extending from the first character on a line to the last and including the
+ * line delimiter.
+ * </p>
+ * <p>
+ * When two lines are joined by deleting a line delimiter, the top line
+ * background takes precedence and the color of the bottom line is deleted.
+ * 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();
+
+ // this API can not be used if the client is providing the line background
+ if (userLineBackground) {
+ return;
+ }
+ if (startLine < 0 || startLine + lineCount > logicalContent.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;
+ super.redraw(
+ leftMargin, startLine * lineHeight + topMargin,
+ getClientArea().width - leftMargin - rightMargin, lineCount * lineHeight, true);
+}
+/**
+ * Flips selection anchor based on word selection direction.
+ */
+void setMouseWordSelectionAnchor() {
+ if (mouseDoubleClick == false) {
+ return;
+ }
+ if (caretOffset < doubleClickSelection.x) {
+ selectionAnchor = doubleClickSelection.y;
+ }
+ else
+ if (caretOffset > doubleClickSelection.y) {
+ selectionAnchor = doubleClickSelection.x;
+ }
+}
+/**
+ * Adjusts the maximum and the page size of the scroll bars to
+ * reflect content width/length changes.
+ */
+void setScrollBars() {
+ ScrollBar verticalBar = getVerticalBar();
+
+ if (verticalBar != null) {
+ Rectangle clientArea = getClientArea();
+ final int INACTIVE = 1;
+ 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);
+ }
+ }
+ setHorizontalScrollBar();
+}
+/**
+ * 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
+ * <li>ERROR_INVALID_ARGUMENT when either the start or the end of the selection range is inside a
+ * multi byte line delimiter (and thus neither clearly in front of or after the line delimiter)
+ * </ul>
+ */
+public void setSelection(int start) {
+ // checkWidget test done in setSelectionRange
+ setSelection(start, start);
+}
+/**
+ * Sets the selection and scrolls it into view.
+ * <p>
+ * Indexing is zero based. Text selections are specified in terms of
+ * caret positions. In a text widget that contains N characters, there are
+ * N+1 caret positions, ranging from 0..N
+ * </p>
+ *
+ * @param point x=selection start offset, y=selection end offset
+ * The caret will be placed at the selection start when x > y.
+ * @see #setSelection(int,int)
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT when point is null</li>
+ * <li>ERROR_INVALID_RANGE when start or end is outside the widget content
+ * <li>ERROR_INVALID_ARGUMENT when either the start or the end of the selection range is inside a
+ * multi byte line delimiter (and thus neither clearly in front of or after the line delimiter)
+ * </ul>
+ */
+public void setSelection(Point point) {
+ checkWidget();
+ if (point == null) SWT.error (SWT.ERROR_NULL_ARGUMENT);
+ setSelection(point.x, point.y);
+}
+/**
+ * Sets the receiver's selection background color to the color specified
+ * by the argument, or to the default system color for the control
+ * if the argument is null.
+ *
+ * @param color the new color (or null)
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_INVALID_ARGUMENT - if the argument has been disposed</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * @since 2.1
+ */
+public void setSelectionBackground (Color color) {
+ checkWidget ();
+ if (color != null) {
+ if (color.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+ }
+ selectionBackground = color;
+ redraw();
+}
+/**
+ * Sets the receiver's selection foreground color to the color specified
+ * by the argument, or to the default system color for the control
+ * if the argument is null.
+ *
+ * @param color the new color (or null)
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_INVALID_ARGUMENT - if the argument has been disposed</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * @since 2.1
+ */
+public void setSelectionForeground (Color color) {
+ checkWidget ();
+ if (color != null) {
+ if (color.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+ }
+ selectionForeground = color;
+ redraw();
+}
+/**
+ * Sets the selection and scrolls it into view.
+ * <p>
+ * Indexing is zero based. Text selections are specified in terms of
+ * caret positions. In a text widget that contains N characters, there are
+ * N+1 caret positions, ranging from 0..N
+ * </p>
+ *
+ * @param start selection start offset. The caret will be placed at the
+ * selection start when start > end.
+ * @param end selection end offset
+ * @see #setSelectionRange(int,int)
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_INVALID_RANGE when start or end is outside the widget content
+ * <li>ERROR_INVALID_ARGUMENT when either the start or the end of the selection range is inside a
+ * multi byte line delimiter (and thus neither clearly in front of or after the line delimiter)
+ * </ul>
+ */
+public void setSelection(int start, int end) {
+ // checkWidget test done in setSelectionRange
+ setSelectionRange(start, end - start);
+ 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, 0 <= start + length <= getCharCount()
+ * must be true.
+ * A negative length places the caret at the visual start 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>
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_INVALID_RANGE when the range specified by start and length is outside the widget content
+ * <li>ERROR_INVALID_ARGUMENT when either the start or the end of the selection range is inside a
+ * multi byte line delimiter (and thus neither clearly in front of or after the line delimiter)
+ * </ul>
+ */
+public void setSelectionRange(int start, int length) {
+ checkWidget();
+ int contentLength = getCharCount();
+ int end = start + length;
+
+ if (start < 0 || end < 0 || start > contentLength || end > contentLength) {
+ SWT.error(SWT.ERROR_INVALID_RANGE);
+ }
+ if (isLineDelimiter(start) || isLineDelimiter(end)) {
+ // the start offset or end offset of the selection range is inside a
+ // multi byte line delimiter. This is an illegal operation and an exception
+ // is thrown. Fixes 1GDKK3R
+ SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+ }
+ internalSetSelection(start, length, false);
+ // always update the caret location. fixes 1G8FODP
+ setCaretLocation();
+ if (isBidi()) {
+ setBidiKeyboardLanguage();
+ }
+}
+/**
+ * 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, 0 <= start + length
+ * <= getCharCount() must be true.
+ * A negative length places the caret at the selection start.
+ * @param sendEvent a Selection event is sent when set to true and when
+ * the selection is reset.
+ */
+void internalSetSelection(int start, int length, boolean sendEvent) {
+ int end = start + length;
+
+ if (start > end) {
+ int temp = end;
+ end = start;
+ start = temp;
+ }
+ // is the selection range different or is the selection direction
+ // different?
+ if (selection.x != start || selection.y != end ||
+ (length > 0 && selectionAnchor != selection.x) ||
+ (length < 0 && selectionAnchor != selection.y)) {
+ clearSelection(sendEvent);
+ if (length < 0) {
+ selectionAnchor = selection.y = end;
+ caretOffset = selection.x = start;
+ }
+ else {
+ selectionAnchor = selection.x = start;
+ caretOffset = selection.y = end;
+ }
+ internalRedrawRange(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();
+
+ // 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) {
+ boolean redrawFirstLine = false;
+ boolean redrawLastLine = false;
+ int firstLine = content.getLineAtOffset(range.start);
+ int lastLine = content.getLineAtOffset(range.start + range.length);
+
+ // if the style is not visible, there is no need to redraw
+ boolean redrawLines = isAreaVisible(firstLine, lastLine);
+
+ if (!redrawLines) {
+ defaultLineStyler.setStyleRange(range);
+ lineCache.reset(firstLine, lastLine - firstLine + 1, true);
+ } else {
+ // 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 firstLineOffset = content.getOffsetAtLine(firstLine);
+ int lastLineOffset = content.getOffsetAtLine(lastLine);
+ if (isBidi()) {
+ if (firstLine != lastLine) {
+ redrawFirstLine = true;
+ }
+ redrawLastLine = true;
+ } else {
+ redrawFirstLine = isRedrawFirstLine(new StyleRange[] {range}, firstLine, firstLineOffset);
+ if (lastLine != firstLine) {
+ redrawLastLine = isRedrawLastLine(new StyleRange[] {range}, lastLine, lastLineOffset);
+ }
+ }
+ defaultLineStyler.setStyleRange(range);
+ // reset all lines affected by the style change but let the redraw
+ // recalculate only those that are visible.
+ lineCache.reset(firstLine, lastLine - firstLine + 1, true);
+ internalRedrawRange(range.start, range.length, true);
+ if (redrawFirstLine) {
+ redrawLine(firstLine, range.start - firstLineOffset);
+ }
+ if (redrawLastLine) {
+ redrawLine(lastLine, 0);
+ }
+ }
+ } else {
+ // clearing all styles
+ defaultLineStyler.setStyleRange(range);
+ lineCache.reset(0, content.getLineCount(), false);
+ 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
+ * in the widget 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];
+ int lastEnd = last.start + last.length;
+ int firstLine = content.getLineAtOffset(ranges[0].start);
+ int lastLine;
+ if (lastEnd > content.getCharCount()) {
+ SWT.error(SWT.ERROR_INVALID_RANGE);
+ }
+ lastLine = content.getLineAtOffset(lastEnd);
+ // reset all lines affected by the style change
+ lineCache.reset(firstLine, lastLine - firstLine + 1, true);
+ }
+ else {
+ // reset all lines
+ lineCache.reset(0, content.getLineCount(), false);
+ }
+ defaultLineStyler.setStyleRanges(ranges);
+ redraw(); // should 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;
+ renderer.setTabLength(tabLength);
+ if (caretOffset > 0) {
+ caretOffset = 0;
+ if (isBidi()) {
+ showBidiCaret();
+ }
+ else {
+ showCaret();
+ }
+ clearSelection(false);
+ }
+ // reset all line widths when the tab width changes
+ lineCache.reset(0, content.getLineCount(), 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>
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT when string is null</li>
+ * </ul>
+ */
+public void setText(String text) {
+ checkWidget();
+ Event event = new Event();
+
+ if (text == null) {
+ SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ }
+ event.start = 0;
+ event.end = getCharCount();
+ event.text = text;
+ event.doit = true;
+ notifyListeners(SWT.Verify, event);
+ if (event.doit) {
+ StyledTextEvent styledTextEvent = null;
+
+ if (isListening(ExtendedModify)) {
+ styledTextEvent = new StyledTextEvent(logicalContent);
+ styledTextEvent.start = event.start;
+ styledTextEvent.end = event.start + event.text.length();
+ styledTextEvent.text = content.getTextRange(event.start, event.end - event.start);
+ }
+ content.setText(event.text);
+ notifyListeners(SWT.Modify, event);
+ if (styledTextEvent != null) {
+ notifyListeners(ExtendedModify, styledTextEvent);
+ }
+ }
+}
+/**
+ * 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() - fully visible lines per page. If no lines are fully
+ * visible the maximum value is getLineCount() - 1. An out of range
+ * index will be adjusted accordingly.
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setTopIndex(int topIndex) {
+ checkWidget();
+ int lineCount = logicalContent.getLineCount();
+ int pageSize = Math.max(1, Math.min(lineCount, getLineCountWhole()));
+
+ if (getCharCount() == 0) {
+ return;
+ }
+ if (topIndex < 0) {
+ topIndex = 0;
+ }
+ else
+ if (topIndex > lineCount - pageSize) {
+ topIndex = lineCount - pageSize;
+ }
+ if (wordWrap) {
+ int logicalLineOffset = logicalContent.getOffsetAtLine(topIndex);
+ topIndex = content.getLineAtOffset(logicalLineOffset);
+ }
+ setVerticalScrollOffset(topIndex * getVerticalIncrement(), true);
+}
+/**
+ * Sets the top pixel offset. Do nothing if there is no text set.
+ * <p>
+ * The top pixel offset is the vertical pixel offset of the widget. The
+ * widget is scrolled so that the given pixel position is at the top.
+ * The top index is adjusted to the corresponding top line.
+ * Note: The top pixel is reset to 0 when new text is set in the widget.
+ * </p>
+ *
+ * @param pixel new top pixel offset. Must be between 0 and
+ * (getLineCount() - visible lines per page) / getLineHeight()). An out
+ * of range offset will be adjusted accordingly.
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * @since 2.0
+ */
+public void setTopPixel(int pixel) {
+ checkWidget();
+ int lineCount =content.getLineCount();
+ int height = getClientArea().height;
+ int maxTopPixel = Math.max(0, lineCount * getVerticalIncrement() - height);
+
+ if (getCharCount() == 0) {
+ return;
+ }
+ if (pixel < 0) {
+ pixel = 0;
+ }
+ else
+ if (pixel > maxTopPixel) {
+ pixel = maxTopPixel;
+ }
+ setVerticalScrollOffset(pixel, true);
+}
+/**
+ * Scrolls the widget vertically.
+ * <p>
+ *
+ * @param pixelOffset the new vertical scroll offset
+ * @param adjustScrollBar
+ * true= the scroll thumb will be moved to reflect the new scroll offset.
+ * false = the scroll thumb will not be moved
+ * @return
+ * true=the widget was scrolled
+ * false=the widget was not scrolled, the given offset is not valid.
+ */
+boolean setVerticalScrollOffset(int pixelOffset, boolean adjustScrollBar) {
+ Rectangle clientArea;
+ ScrollBar verticalBar = getVerticalBar();
+
+ if (pixelOffset == verticalScrollOffset) {
+ return false;
+ }
+ 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);
+
+ verticalScrollOffset = pixelOffset;
+ calculateTopIndex();
+ setCaretLocation();
+ return true;
+}
+/**
+ * Scrolls the specified location into view.
+ * <p>
+ *
+ * @param x the x coordinate that should be made visible.
+ * @param line the line that should be made visible. Relative to the
+ * first line in the document.
+ * @return
+ * true=the widget was scrolled to make the specified location visible.
+ * false=the specified location is already visible, the widget was
+ * not scrolled.
+ */
+boolean showLocation(int x, int line) {
+ int clientAreaWidth = getClientArea().width - leftMargin - rightMargin;
+ int verticalIncrement = getVerticalIncrement();
+ int horizontalIncrement = clientAreaWidth / 4;
+ boolean scrolled = false;
+
+ if (x < leftMargin) {
+ // always make 1/4 of a page visible
+ x = Math.max(horizontalScrollOffset * -1, x - horizontalIncrement);
+ scrolled = scrollHorizontalBar(x);
+ }
+ else
+ if (x >= clientAreaWidth) {
+ // always make 1/4 of a page visible
+ x = Math.min(lineCache.getWidth() - horizontalScrollOffset, x + horizontalIncrement);
+ scrolled = scrollHorizontalBar(x - clientAreaWidth);
+ }
+ if (line < topIndex) {
+ scrolled = setVerticalScrollOffset(line * verticalIncrement, true);
+ }
+ else
+ if (line > getBottomIndex()) {
+ scrolled = setVerticalScrollOffset((line + 1) * verticalIncrement - getClientArea().height, true);
+ }
+ return scrolled;
+}
+/**
+ * Sets the caret location and scrolls the caret offset into view.
+ */
+void showCaret() {
+ int caretLine = content.getLineAtOffset(caretOffset);
+
+ showCaret(caretLine);
+}
+/**
+ * Sets the caret location and scrolls the caret offset into view.
+ */
+void showCaret(int caretLine) {
+ int lineOffset = content.getOffsetAtLine(caretLine);
+ String lineText = content.getLine(caretLine);
+ int offsetInLine = caretOffset - lineOffset;
+ int xAtOffset = getXAtOffset(lineText, caretLine, offsetInLine);
+ boolean scrolled = showLocation(xAtOffset, caretLine);
+ boolean setWrapCaretLocation = false;
+ Caret caret = getCaret();
+
+ if (wordWrap && caret != null) {
+ int caretY = caret.getLocation().y;
+ if ((caretY + verticalScrollOffset) / getVerticalIncrement() - 1 != caretLine) {
+ setWrapCaretLocation = true;
+ }
+ }
+ if (scrolled == false || setWrapCaretLocation) {
+ // set the caret location if a scroll operation did not set it (as a
+ // sideeffect of scrolling) or when in word wrap mode and the caret
+ // line was explicitly specified (i.e., because getWrapCaretLine does
+ // not return the desired line causing scrolling to not set it correctly)
+ setCaretLocation(xAtOffset, caretLine);
+ }
+ if (isBidi()) {
+ setBidiKeyboardLanguage();
+ }
+}
+/**
+ * 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);
+
+ showLocation(xAtOffset, line);
+}
+/**
+/**
+ * Scrolls the selection into view. The end of the selection will be scrolled into
+ * view. Note that if a right-to-left selection exists, the end of the selection is the
+ * visual beginning of the selection (i.e., where the caret is located).
+ * <p>
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void showSelection() {
+ checkWidget();
+ boolean selectionFits;
+ int startOffset, startLine, startX, endOffset, endLine, endX, offsetInLine;
+
+ // is selection from right-to-left?
+ boolean rightToLeft = caretOffset == selection.x;
+
+ if (rightToLeft) {
+ startOffset = selection.y;
+ endOffset = selection.x;
+ } else {
+ startOffset = selection.x;
+ endOffset = selection.y;
+ }
+
+ // calculate the logical start and end values for the selection
+ startLine = content.getLineAtOffset(startOffset);
+ offsetInLine = startOffset - content.getOffsetAtLine(startLine);
+ startX = getXAtOffset(content.getLine(startLine), startLine, offsetInLine);
+ endLine = content.getLineAtOffset(endOffset);
+ offsetInLine = endOffset - content.getOffsetAtLine(endLine);
+ endX = getXAtOffset(content.getLine(endLine), endLine, offsetInLine);
+
+ // can the selection be fully displayed within the widget's visible width?
+ int w = getClientArea().width;
+ if (rightToLeft) {
+ selectionFits = startX - endX <= w;
+ } else {
+ selectionFits = endX - startX <= w;
+ }
+
+ if (selectionFits) {
+ // show as much of the selection as possible by first showing
+ // the start of the selection
+ showLocation(startX, startLine);
+ // endX value could change if showing startX caused a scroll to occur
+ endX = getXAtOffset(content.getLine(endLine), endLine, offsetInLine);
+ showLocation(endX, endLine);
+ } else {
+ // just show the end of the selection since the selection start
+ // will not be visible
+ showLocation(endX, endLine);
+ }
+}
+/**
+ * Updates the caret direction when a delete operation occured based on
+ * the type of the delete operation (next/previous character) and the
+ * caret location (at a direction boundary or inside a direction segment).
+ * The intent is to place the caret at the visual location where a
+ * character was deleted.
+ * <p>
+ *
+ * @param isBackspace true=the previous character was deleted, false=the
+ * character next to the caret location was deleted
+ * @param isDirectionBoundary true=the caret is between a R2L and L2R segment,
+ * false=the caret is within a direction segment
+ */
+void updateBidiDirection(boolean isBackspace, boolean isDirectionBoundary) {
+ if (isDirectionBoundary) {
+ if (isBackspace) {
+ // Deleted previous character (backspace) at a direction boundary
+ // Go to direction segment of deleted character
+ lastCaretDirection = ST.COLUMN_NEXT;
+ }
+ else {
+ // Deleted next character. Go to direction segment of deleted character
+ lastCaretDirection = ST.COLUMN_PREVIOUS;
+ }
+ }
+ else {
+ if (isBackspace) {
+ // Delete previous character inside direction segment (i.e., not at a direction boundary)
+ lastCaretDirection = ST.COLUMN_PREVIOUS;
+ }
+ else {
+ // Deleted next character.
+ lastCaretDirection = ST.COLUMN_NEXT;
+ }
+ }
+}
+/**
+ * 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
+ internalRedrawRange(selection.x, startOffset - selection.x, true);
+ }
+ if (selection.y > startOffset + replacedLength && selection.x < startOffset + replacedLength) {
+ // clear selection fragment after text change.
+ // do this only when the selection is actually affected by the
+ // change. Selection is only affected if it intersects the change (1GDY217).
+ int netNewLength = newLength - replacedLength;
+ int redrawStart = startOffset + newLength;
+ internalRedrawRange(redrawStart, selection.y + netNewLength - redrawStart, true);
+ }
+ if (selection.y > startOffset && selection.x < startOffset + replacedLength) {
+ // selection intersects replaced text. set caret behind text change
+ internalSetSelection(startOffset + newLength, 0, true);
+ // 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, true);
+ // always update the caret location. fixes 1G8FODP
+ setCaretLocation();
+ }
+}
+/**
+ * Rewraps all lines
+ * <p>
+ *
+ * @param oldClientAreaWidth client area width before resize
+ * occurred
+ */
+void wordWrapResize(int oldClientAreaWidth) {
+ WrappedContent wrappedContent = (WrappedContent) content;
+ int newTopIndex;
+
+ // all lines are wrapped and no rewrap required if widget has already
+ // been visible, client area is now wider and visual (wrapped) line
+ // count equals logical line count.
+ if (oldClientAreaWidth != 0 && clientAreaWidth > oldClientAreaWidth &&
+ wrappedContent.getLineCount() == logicalContent.getLineCount()) {
+ return;
+ }
+ wrappedContent.wrapLines();
+
+ // adjust the top index so that top line remains the same
+ newTopIndex = content.getLineAtOffset(topOffset);
+ // topOffset is the beginning of the top line. therefore it
+ // needs to be adjusted because in a wrapped line this is also
+ // the end of the preceeding line.
+ if (newTopIndex < content.getLineCount() - 1 &&
+ topOffset == content.getOffsetAtLine(newTopIndex + 1)) {
+ newTopIndex++;
+ }
+ if (newTopIndex != topIndex) {
+ ScrollBar verticalBar = getVerticalBar();
+ // adjust index and pixel offset manually instead of calling
+ // setVerticalScrollOffset because the widget does not actually need
+ // to be scrolled. causes flash otherwise.
+ verticalScrollOffset += (newTopIndex - topIndex) * getVerticalIncrement();
+ // verticalScrollOffset may become negative if first line was
+ // partially visible and second line was top line. prevent this from
+ // happening to fix 8503.
+ if (verticalScrollOffset < 0) {
+ verticalScrollOffset = 0;
+ }
+ topIndex = newTopIndex;
+ topOffset = content.getOffsetAtLine(topIndex);
+ if (verticalBar != null) {
+ verticalBar.setSelection(verticalScrollOffset);
+ }
+ }
+ // caret may be on a different line after a rewrap.
+ // call setCaretLocation after fixing vertical scroll offset.
+ setCaretLocation();
+ // word wrap may have changed on one of the visible lines
+ super.redraw();
+}
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/StyledTextBidi.java b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/StyledTextBidi.java
index fb98cb65cc..982517ff2a 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/StyledTextBidi.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/StyledTextBidi.java
@@ -1,1056 +1,1056 @@
-package org.eclipse.swt.custom;
-
-/*
+package org.eclipse.swt.custom;
+
+/*
* Copyright (c) 2001, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-import java.util.*;
-import org.eclipse.swt.*;
-import org.eclipse.swt.graphics.*;
-import org.eclipse.swt.internal.*;
-import org.eclipse.swt.widgets.*;
-
-/**
- * This class provides API for StyledText to implement bidirectional text
- * functions.
- * Objects of this class are created for a single line of text.
- */
-class StyledTextBidi {
- private GC gc;
- private int[] bidiSegments; // bidi text segments, each segment will be rendered separately
- private int[] renderPositions; // x position at which characters of the line are rendered, in visual order
- private int[] order; // reordering indices in logical order, iV=order[iL] (iV=visual index, iL=logical index),
- // if no character in a line needs reordering all iV and iL are the same.
- private int[] dx; // distance between character cells. in visual order. renderPositions[iV + 1] = renderPositions[iV] + dx[iV]
- private byte[] classBuffer; // the character types in logical order, see BidiUtil for the possible types
- private char[] glyphBuffer; // the glyphs in visual order as they will be rendered on screen.
-
- /**
- * This class describes a text segment of a single direction, either
- * left-to-right (L2R) or right-to-left (R2L).
- * Objects of this class are used by StyledTextBidi rendering methods
- * to render logically contiguous text segments that may be visually
- * discontiguous if they consist of different directions.
- */
- class DirectionRun {
- int logicalStart;
- int logicalEnd;
-
- DirectionRun(int logicalStart, int logicalEnd) {
- this.logicalStart = logicalStart;
- this.logicalEnd = logicalEnd;
- }
- int getVisualStart() {
- int visualStart = order[logicalStart];
- int visualEnd = order[logicalEnd];
- // the visualStart of a R2L direction run is actually
- // at the run's logicalEnd, answered as such since rendering
- // always occurs from L2R regardless of the text run's
- // direction
- if (visualEnd < visualStart) {
- visualStart = visualEnd;
- }
- return visualStart;
- }
- int getVisualEnd() {
- int visualStart = order[logicalStart];
- int visualEnd = order[logicalEnd];
- // the visualEnd of a R2L direction run is actually
- // at the run's logicalStart, answered as such since rendering
- // always occurs from L2R regardless of the text run's
- // direction
- if (visualEnd < visualStart) {
- visualEnd = visualStart;
- }
- return visualEnd;
- }
- int getRenderStartX() {
- return renderPositions[getVisualStart()];
- }
- int getRenderStopX() {
- int visualEnd = getVisualEnd();
-
- return renderPositions[visualEnd] + dx[visualEnd];
- }
- public String toString() {
- StringBuffer buf = new StringBuffer();
- buf.append("vStart,Stop:" + getVisualStart() + "," + getVisualEnd() + " lStart,Stop:" + logicalStart + "," + logicalEnd + " renderStart,Stop: " + getRenderStartX() + "," + getRenderStopX());
- return buf.toString();
- }
- }
-
-/**
- * Constructs an instance of this class for a line of text. The text
- * is reordered to reflect how it will be displayed.
- * <p>
- *
- * @param gc the GC to use for rendering and measuring of this line.
- * @param tabWidth tab width in number of spaces, used to calculate
- * tab stops
- * @param text line that bidi data should be calculated for
- * @param boldRanges bold text segments in the line, specified as
- * i=bold start,i+1=bold length
- * @param boldFont font that bold text will be rendered in, needed for
- * proper measuring of bold text segments.
- * @param offset text segments that should be measured and reordered
- * separately, may be needed to preserve the order of separate R2L
- * segments to each other. Must have at least two elements, 0 and the text
- * length.
- */
-public StyledTextBidi(GC gc, int tabWidth, String text, StyleRange[] ranges, Font boldFont, int[] offsets) {
- int length = text.length();
-
- this.gc = gc;
- bidiSegments = offsets;
- renderPositions = new int[length];
- order = new int[length];
- dx = new int[length];
- classBuffer = new byte[length];
- if (length == 0) {
- glyphBuffer = new char[0];
- }
- else {
- glyphBuffer = BidiUtil.getRenderInfo(gc, text, order, classBuffer, dx, 0, offsets);
- if (ranges != null) {
- // If the font supports characters shaping, break up the font style ranges based on
- // the specified bidi segments. Each bidi segment will be treated separately
- // for font style purposes.
- StyleRange[] segmentedRanges;
- if (isCharacterShaped(gc)) segmentedRanges = getSegmentedRangesFor(ranges);
- else segmentedRanges = ranges;
- Font normalFont = gc.getFont();
- gc.setFont(boldFont);
- for (int i = 0; i < segmentedRanges.length; i++) {
- StyleRange segmentedRange = segmentedRanges[i];
- int rangeStart = segmentedRange.start;
- int rangeLength = segmentedRange.length;
- // Font styled text needs to be processed so that the dx array reflects the styled
- // font.
- prepareFontStyledText(text, rangeStart, rangeLength);
- }
- gc.setFont(normalFont);
- }
- calculateTabStops(text, tabWidth);
- calculateRenderPositions();
- }
-}
-/**
- * Constructs an instance of this class for a line of text. This constructor
- * should be used when only ordering (not rendering) information is needed.
- * Only the class and order arrays will be filled during this call.
- * <p>
- *
- * @param gc the GC to use for rendering and measuring of this line.
- * @param text line that bidi data should be calculated for
- * @param offset text segments that should be measured and reordered
- * separately, may be needed to preserve the order of separate R2L
- * segments to each other
- */
-public StyledTextBidi(GC gc, String text, int[] offsets) {
- int length = text.length();
- this.gc = gc;
- bidiSegments = offsets;
- order = new int[length];
- classBuffer = new byte[length];
- BidiUtil.getOrderInfo(gc, text, order, classBuffer, 0, offsets);
- // initialize the unused arrays
- dx = new int[0];
- renderPositions = new int[0];
- glyphBuffer = new char[0];
-
-}
-/**
- * Adds a listener that should be called when the user changes the
- * keyboard layout for the specified window.
- * <p>
- *
- * @param control Control to add the keyboard language listener for.
- * Each window has its own keyboard language setting.
- * @param runnable the listener that should be called when the user
- * changes the keyboard layout.
- */
-static void addLanguageListener(Control control, Runnable runnable) {
- BidiUtil.addLanguageListener(control.handle, runnable);
-}
-/**
- * Answers the direction of the active keyboard language - either
- * L2R or R2L. The active keyboard language determines the direction
- * of the caret and can be changed by the user (e.g., via Alt-Shift on
- * Win32 platforms).
- * <p>
- *
- * @return the direction of the active keyboard language. SWT.LEFT (for L2R
- * language) or SWT.RIGHT (for R2L language) or SWT.DEFAULT if no R2L languages
- * are installed.
- */
-static int getKeyboardLanguageDirection() {
- int language = BidiUtil.getKeyboardLanguage();
- if (language == BidiUtil.KEYBOARD_BIDI) {
- return SWT.RIGHT;
- }
- if (BidiUtil.isKeyboardBidi()) {
- return SWT.LEFT;
- }
- return SWT.DEFAULT;
-}
-/**
- * Returns whether the current platform supports a bidi language.
- * <p>
- *
- * @return true=bidi is supported, false otherwise.
- */
-static boolean isBidiPlatform() {
- return BidiUtil.isBidiPlatform();
-}
-/**
- * Returns whether the font set in the specified gc supports
- * character shaping.
- * <p>
- *
- * @param gc the GC that should be tested for character shaping.
- * @return
- * true=the font set in the specified gc supports character shaped glyphs
- * false=the font set in the specified gc doesn't support character shaped glyphs
- */
-static boolean isCharacterShaped(GC gc) {
- return (BidiUtil.getFontBidiAttributes(gc) & BidiUtil.GLYPHSHAPE) != 0;
-}
-/**
- * Returns whether the font set in the specified gc contains
- * ligatured glyphs.
- * <p>
- *
- * @param gc the GC that should be tested for ligatures.
- * @return
- * true=the font set in the specified gc contains ligatured glyphs.
- * false=the font set in the specified gc doesn't contain ligatured
- * glyphs.
- */
-static boolean isLigated(GC gc) {
- return (BidiUtil.getFontBidiAttributes(gc) & BidiUtil.LIGATE) != 0;
-}
-/**
- * Removes the keyboard language listener for the specified window.
- * <p>
- *
- * @param control window to remove the keyboard language listener from.
- */
-static void removeLanguageListener(Control control) {
- BidiUtil.removeLanguageListener(control.handle);
-}
-/**
- * Calculates render positions using the glyph distance values in the dx array.
- */
-private void calculateRenderPositions() {
- renderPositions = new int[dx.length];
- renderPositions[0] = StyledText.XINSET;
- for (int i = 0; i < dx.length - 1; i++) {
- renderPositions[i + 1] = renderPositions[i] + dx[i];
- }
-}
-/**
- * Calculate the line's tab stops and adjust the dx array to
- * reflect the width of tab characters.
- * <p>
- *
- * @param text the original line text (not reordered) containing
- * tab characters.
- * @param tabWidth number of pixels that one tab character represents
- */
-private void calculateTabStops(String text, int tabWidth) {
- int tabIndex = text.indexOf('\t', 0);
- int logicalIndex = 0;
- int x = 0;
- int spaceWidth = gc.stringExtent(" ").x;
-
- while (tabIndex != -1) {
- for (; logicalIndex < tabIndex; logicalIndex++) {
- x += dx[order[logicalIndex]];
- }
- int tabStop = x + tabWidth;
- // make sure tab stop is at least one space width apart
- // from the last character. fixes 4844.
- if (tabWidth - tabStop % tabWidth < spaceWidth) {
- tabStop += tabWidth;
- }
- tabStop -= tabStop % tabWidth;
- dx[order[tabIndex]] = tabStop - x;
- tabIndex = text.indexOf('\t', tabIndex + 1);
- }
-}
-/**
- * Renders the specified text segment. All text is rendered L2R
- * regardless of the direction of the text. The rendered text may
- * be visually discontiguous if the text segment is bidirectional.
- * <p>
- *
- * @param logicalStart start offset in the logical text
- * @param length number of logical characters to render
- * @param xOffset x location of the line start
- * @param yOffset y location of the line start
- */
-void drawBidiText(int logicalStart, int length, int xOffset, int yOffset) {
- Enumeration directionRuns;
- int endOffset = logicalStart + length;
-
- if (logicalStart < 0 || endOffset > getTextLength()) {
- return;
- }
- directionRuns = getDirectionRuns(logicalStart, length).elements();
- while (directionRuns.hasMoreElements()) {
- DirectionRun run = (DirectionRun) directionRuns.nextElement();
- int visualStart = run.getVisualStart();
- int visualEnd = run.getVisualEnd();
- int x = xOffset + run.getRenderStartX();
- drawGlyphs(visualStart, visualEnd - visualStart + 1, x, yOffset);
- }
-}
-/**
- * Renders a segment of glyphs. Glyphs are visual objects so the
- * start and length are visual as well. Glyphs are always rendered L2R.
- * <p>
- *
- * @param visualStart start offset of the glyphs to render relative to the
- * line start.
- * @param length number of glyphs to render
- * @param x x location to render at
- * @param y y location to render at
- */
-private void drawGlyphs(int visualStart, int length, int x, int y) {
- char[] renderBuffer = new char[length];
- int[] renderDx = new int[length];
- if (length == 0) {
- return;
- }
- System.arraycopy(glyphBuffer, visualStart, renderBuffer, 0, length);
- // copy the distance values for the desired rendering range
- System.arraycopy(dx, visualStart, renderDx, 0, length);
- BidiUtil.drawGlyphs(gc, renderBuffer, renderDx, x, y);
-}
-/**
- * Fills a rectangle spanning the given logical range.
- * The rectangle may be visually discontiguous if the text segment
- * is bidirectional.
- * <p>
- *
- * @param logicalStart logcial start offset of the rectangle
- * @param length number of logical characters the rectangle should span
- * @param xOffset x location of the line start
- * @param yOffset y location of the line start
- * @param height height of the rectangle
- */
-void fillBackground(int logicalStart, int length, int xOffset, int yOffset, int height) {
- Enumeration directionRuns = getDirectionRuns(logicalStart, length).elements();
-
- if (logicalStart < 0 || logicalStart + length > getTextLength()) {
- return;
- }
- while (directionRuns.hasMoreElements()) {
- DirectionRun run = (DirectionRun) directionRuns.nextElement();
- int startX = run.getRenderStartX();
- gc.fillRectangle(xOffset + startX, yOffset, run.getRenderStopX() - startX, height);
- }
-}
-/**
- * Returns the offset and direction that will be used to position the caret for
- * the given x location. The caret will be placed in front of or behind the
- * character at location x depending on what type of character (i.e., R2L or L2R)
- * is at location x. This method is used for positioning the caret when a mouse
- * click occurs within the widget.
- * <p>
- *
- * @param x the x location of the character in the line.
- * @return array containing the caret offset and direction for the x location.
- * index 0: offset relative to the start of the line
- * index 1: direction, either ST.COLUMN_NEXT or ST.COLUMN_PREVIOUS.
- * The direction is used to control the caret position at direction
- * boundaries. The semantics follow the behavior for keyboard cursor
- * navigation.
- * Example: RRRLLL
- * Pressing cursor left (COLUMN_PREVIOUS) in the L2R segment places the cursor
- * in front of the first character of the L2R segment. Pressing cursor right
- * (COLUMN_NEXT) in a R2L segment places the cursor behind the last character
- * of the R2L segment. However, both are the same logical offset.
- */
-int[] getCaretOffsetAndDirectionAtX(int x) {
- int lineLength = getTextLength();
- int offset;
- int direction;
-
- if (lineLength == 0) {
- return new int[] {0, 0};
- }
- int eol = renderPositions[renderPositions.length - 1] + dx[dx.length - 1];
- if (x >= eol) {
- return new int[] {lineLength, ST.COLUMN_NEXT};
- }
- // get the visual offset of the clicked character
- int visualOffset = getVisualOffsetAtX(x);
- // figure out if the character was clicked on the right or left
- int halfway = renderPositions[visualOffset] + dx[visualOffset] / 2;
- boolean visualLeft = (x <= halfway);
- offset = getLogicalOffset(visualOffset);
-
- if (isRightToLeft(offset)) {
- if (visualLeft) {
- if (isLigated(gc)) {
- // the caret should be positioned after the last
- // character of the ligature
- offset = getLigatureEndOffset(offset);
- }
- offset++;
- // position the caret as if the caret is to the right
- // of the character at location x and the NEXT key is
- // pressed
- direction = ST.COLUMN_NEXT;
- }
- else {
- // position the caret as if the caret is to the left
- // of the character at location x and the PREVIOUS key is
- // pressed
- direction = ST.COLUMN_PREVIOUS;
- }
- }
- else {
- if (visualLeft) {
- // position the caret as if the caret is to the right
- // of the character at location x and the PREVIOUS key is
- // pressed
- direction = ST.COLUMN_PREVIOUS;
- }
- else {
- // position the caret as if the caret is to the left
- // of the character at location x and the NEXT key is
- // pressed
- offset++;
- direction = ST.COLUMN_NEXT;
- }
- }
- return new int[] {offset, direction};
-}
-/**
- * Returns the direction segments that are in the specified text
- * range. The text range may be visually discontiguous if the
- * text is bidirectional. Each returned direction run has a single
- * direction and the runs all go from left to right, regardless of
- * the direction of the text in the segment. User specified segments
- * (via BidiSegmentListener) are taken into account and result in
- * separate direction runs.
- * <p>
- *
- * @param logicalStart offset of the logcial start of the first
- * direction segment
- * @param length length of the text included in the direction
- * segments
- * @return the direction segments that are in the specified
- * text range, each segment has a single direction.
- */
-private Vector getDirectionRuns(int logicalStart, int length) {
- Vector directionRuns = new Vector();
- int logicalEnd = logicalStart + length - 1;
- int segmentLogicalStart = logicalStart;
- int segmentLogicalEnd = segmentLogicalStart;
-
- if (logicalEnd < getTextLength()) {
- int bidiSegmentIndex = 0;
- int bidiSegmentEnd = bidiSegments[bidiSegmentIndex + 1];
-
- // Find the bidi segment that the direction runs start in.
- // There will always be at least on bidi segment (for the entire line).
- while (bidiSegmentIndex < bidiSegments.length - 2 && bidiSegmentEnd <= logicalStart) {
- bidiSegmentIndex++;
- bidiSegmentEnd = bidiSegments[bidiSegmentIndex + 1];
- }
- while (segmentLogicalEnd <= logicalEnd) {
- boolean isRightToLeftSegment = isRightToLeft(segmentLogicalStart);
- // Search for the end of the direction segment. Each segment needs to
- // be rendered separately.
- // E.g., 11211 (1=R2L, 2=L2R), rendering from logical index 0 to 5
- // would be visual 1 to 4 and would thus miss visual 0. Rendering the
- // segments separately would render from visual 1 to 0, then 2, then
- // 4 to 3.
- while (segmentLogicalEnd < logicalEnd &&
- // If our segment type is RtoL, the order index for the next character should be one less, if there
- // is no direction change.
- // If our segment type is LtoR, the order index for the next character will be one more if there is
- // no direction change.
- ((isRightToLeftSegment && (order[segmentLogicalEnd + 1]+ 1 == order[segmentLogicalEnd])) ||
- (isRightToLeftSegment == false && (order[segmentLogicalEnd + 1]- 1 == order[segmentLogicalEnd]))) &&
- segmentLogicalEnd + 1 < bidiSegmentEnd) {
- segmentLogicalEnd++;
- }
- directionRuns.addElement(new DirectionRun(segmentLogicalStart, segmentLogicalEnd));
- segmentLogicalStart = ++segmentLogicalEnd;
- // The current direction run ends at a bidi segment end. Get the next bidi segment.
- if (segmentLogicalEnd == bidiSegmentEnd && bidiSegmentIndex < bidiSegments.length - 2) {
- bidiSegmentIndex++;
- bidiSegmentEnd = bidiSegments[bidiSegmentIndex + 1];
- }
- }
- }
- return directionRuns;
-}
-/**
- * Returns the offset of the last character comprising a ligature.
- * <p>
- *
- * @param offset the logical offset of a character that may be a
- * ligature.
- * @return the offset of the last character comprising a ligature.
- */
-int getLigatureEndOffset(int offset) {
- int newOffset = offset;
- int i = offset + 1;
-
- // assume only bidi languages support ligatures
- if (offset < 0 || offset >= order.length || isRightToLeft(offset) == false) {
- return offset;
- }
- // a ligature is a visual character that is comprised of
- // multiple logical characters, thus each logical part of
- // a ligature will have the same order value
- while (i < order.length && (order[i] == order[offset])) {
- newOffset = i;
- i++;
- }
- return newOffset;
-}
-/**
- * Returns the offset of the first character comprising a ligature.
- * <p>
- *
- * @param offset the logical offset of a character that may be a
- * ligature.
- * @return the offset of the first character comprising a ligature.
- */
-int getLigatureStartOffset(int offset) {
- int newOffset = offset;
- int i = offset - 1;
-
- // assume only bidi languages support ligatures
- if (offset < 0 || offset >= order.length || isRightToLeft(offset) == false) {
- return offset;
- }
- // a ligature is a visual character that is comprised of
- // multiple logical characters, thus each logical part of
- // a ligature will have the same order value
- while (i >= 0 && (order[i] == order[offset])) {
- newOffset = i;
- i--;
- }
- return newOffset;
-}
-/**
- * Returns the logical offset of the character at the specified
- * visual offset.
- * <p>
- *
- * @param visualOffset the visual offset
- * @return the logical offset of the character at <code>visualOffset</code>.
- */
-private int getLogicalOffset(int visualOffset) {
- int logicalOffset = 0;
-
- while (logicalOffset < order.length && order[logicalOffset] != visualOffset) {
- logicalOffset++;
- }
- return logicalOffset;
-}
-/**
- * Returns the offset of the character at the specified x location.
- * <p>
- *
- * @param x the location of the character
- * @return the logical offset of the character at the specified x
- * location.
- */
-int getOffsetAtX(int x) {
- int visualOffset;
-
- if (getTextLength() == 0) {
- return 0;
- }
- if (x >= renderPositions[renderPositions.length - 1] + dx[dx.length - 1]) {
- // Return when x is past the end of the line. Fixes 1GLADBK.
- return -1;
- }
- visualOffset = getVisualOffsetAtX(x);
- return getLogicalOffset(visualOffset);
-}
-/**
- * Returns the reordering indices that map between logical and
- * visual index of characters in the specified range.
- * <p>
- *
- * @param start start offset of the reordering indices
- * @param length number of reordering indices to return
- * @return the reordering indices that map between logical and
- * visual index of characters in the specified range. Relative
- * to the start of the range.
- */
-private int[] getRenderIndexesFor(int start, int length) {
- int[] positions = new int[length];
- int end = start + length;
-
- for (int i = start; i < end; i++) {
- positions[i-start] = order[i];
- }
- return positions;
-}
-/**
- * Break up the given ranges such that each range is fully contained within a bidi
- * segment.
- */
-private StyleRange[] getSegmentedRangesFor(StyleRange[] ranges) {
- if ((bidiSegments == null) || (bidiSegments.length == 0)) return ranges;
- Vector newRanges = new Vector();
- int j=0;
- int startSegment;
- int endSegment;
- for (int i=0; i<ranges.length; i++) {
- int start = ranges[i].start;
- int end = start+ranges[i].length;
- startSegment=-1;
- endSegment=-1;
- boolean done = false;
- while (j<bidiSegments.length && !done) {
- if (bidiSegments[j]<=start) {
- startSegment=j;
- }
- if (bidiSegments[j]>=end) {
- endSegment=j-1;
- j--;
- }
- done = (startSegment != -1) && (endSegment != -1);
- if (!done) j++;
- }
- if (startSegment == endSegment) {
- // range is within one segment
- StyleRange newStyle = new StyleRange(start, end-start, null, null);
- newRanges.addElement(newStyle);
- } else if (startSegment > endSegment) {
- // range is within no segment (i.e., it's empty)
- } else {
- // range spans multiple segments
- StyleRange newStyle = new StyleRange(start, bidiSegments[startSegment+1]-start, null, null);
- newRanges.addElement(newStyle);
- startSegment++;
- for (int k=startSegment; k<endSegment; k++) {
- newStyle = new StyleRange(bidiSegments[k], bidiSegments[k+1]-bidiSegments[k], null, null);
- newRanges.addElement(newStyle);
- }
- newStyle = new StyleRange(bidiSegments[endSegment], end-bidiSegments[endSegment], null, null);
- newRanges.addElement(newStyle);
- }
- }
- StyleRange[] rangeArray = new StyleRange[newRanges.size()];
- for (int i=0; i<newRanges.size(); i++) {
- rangeArray[i]=(StyleRange)newRanges.elementAt(i);
- }
- return rangeArray;
-}
-/**
- * Returns the number of characters in the line.
- * <p>
- *
- * @return the number of characters in the line.
- */
-private int getTextLength() {
- return dx.length;
-}
-/**
- * Returns the x position at the specified offset in the line.
- * <p>
- * @param logicalOffset offset of the character in the line.
- * @return the x position at the specified offset in the line.
- */
-int getTextPosition(int logicalOffset) {
- return getTextPosition(logicalOffset, ST.COLUMN_NEXT);
-}
-/**
- * Returns the x position at the specified offset in the line.
- * The direction parameter is used to determine the position
- * at direction boundaries. If the logical offset is between a R2L
- * and a L2R segment, pressing cursor left in the L2R segment places
- * the position in front of the first character of the L2R segment; whereas
- * pressing cursor right in the R2L segment places the position behind
- * the last character of the R2L segment. However, both x positions
- * are at the same logical offset.
- * <p>
- *
- * @param logicalOffset offset of the character in the line
- * @param direction direction the caret moved to the specified location.
- * either ST.COLUMN_NEXT (right cursor key) or ST.COLUMN_PREVIOUS (left cursor key) .
- * @return the x position at the specified offset in the line,
- * taking the direction into account as described above.
- */
-int getTextPosition(int logicalOffset, int direction) {
- int caretX;
-
- if (getTextLength() == 0 || logicalOffset < 0) {
- return StyledText.XINSET;
- }
- // at or past end of line?
- if (logicalOffset >= order.length) {
- logicalOffset = Math.min(logicalOffset, order.length - 1);
- int visualOffset = order[logicalOffset];
- if (isRightToLeft(logicalOffset)) {
- caretX = renderPositions[visualOffset];
- }
- else {
- caretX = renderPositions[visualOffset] + dx[visualOffset];
- }
- }
- else
- // at beginning of line?
- if (logicalOffset == 0) {
- int visualOffset = order[logicalOffset];
- if (isRightToLeft(logicalOffset)) {
- caretX = renderPositions[visualOffset] + dx[visualOffset];
- }
- else {
- caretX = renderPositions[visualOffset];
- }
- }
- else
- // always consider local numbers as a direction boundary
- // because they represent a discontiguous text segment coming from
- // a R2L segment.
- // treat user specified direction segments like real direction changes.
- if (direction == ST.COLUMN_NEXT &&
- (isRightToLeft(logicalOffset) != isRightToLeft(logicalOffset - 1) ||
- isLocalNumber(logicalOffset) != isLocalNumber(logicalOffset - 1) ||
- isStartOfBidiSegment(logicalOffset))) {
- int visualOffset = order[logicalOffset-1];
- // moving between segments.
- // do not consider local numbers as R2L here, to determine position,
- // because local numbers are navigated L2R and we want the caret to
- // be to the right of the number. see 1GK9API
- if (isRightToLeft(logicalOffset - 1)) {
- // moving from RtoL to LtoR
- caretX = renderPositions[visualOffset];
- }
- else {
- // moving from LtoR to RtoL
- caretX = renderPositions[visualOffset] + dx[visualOffset];
- }
- }
- else
- // consider local numbers as R2L in determining direction boundaries.
- // fixes 1GK9API.
- if (direction == ST.COLUMN_PREVIOUS &&
- isRightToLeftInput(logicalOffset) != isRightToLeftInput(logicalOffset - 1)) {
- int visualOffset = order[logicalOffset];
- // moving between segments.
- // consider local numbers as R2L here, to determine position, because
- // we want to stay in L2R segment and place the cursor to the left of
- // first L2R character. see 1GK9API
- if (isRightToLeftInput(logicalOffset - 1)) {
- // moving from LtoR to RtoL
- caretX = renderPositions[visualOffset];
- }
- else {
- // moving from RtoL to LtoR
- caretX = renderPositions[visualOffset] + dx[visualOffset];
- }
- }
- else
- if (isRightToLeft(logicalOffset)) {
- int visualOffset = order[logicalOffset];
- caretX = renderPositions[visualOffset] + dx[visualOffset];
- }
- else {
- caretX = renderPositions[order[logicalOffset]];
- }
- return caretX;
-}
-/**
- * Returns the width in pixels of the line.
- * <p>
- *
- * @return the width in pixels of the line.
- */
-int getTextWidth() {
- int width = 0;
-
- if (getTextLength() > 0) {
- width = renderPositions[renderPositions.length - 1] + dx[dx.length - 1];
- }
- return width;
-}
-/**
- * Returns the visual offset of the character at the specified x
- * location.
- * <p>
- *
- * @param x the location of the character
- * @return the visual offset of the character at the specified x
- * location.
- */
-private int getVisualOffsetAtX(int x) {
- int lineLength = getTextLength();
- int low = -1;
- int high = lineLength;
-
- while (high - low > 1) {
- int offset = (high + low) / 2;
- int visualX = renderPositions[offset];
-
- // visualX + dx is the start of the next character. Restrict right/high
- // search boundary only if x is before next character. Fixes 1GL4ZVE.
- if (x < visualX + dx[offset]) {
- high = offset;
- }
- else
- if (high == lineLength && high - offset == 1) {
- // requested x location is past end of line
- high = -1;
- }
- else {
- low = offset;
- }
- }
- return high;
-}
-/**
- * Returns if the character at the given offset is a local number.
- * <p>
- *
- * @param logicalIndex the index of the character
- * @return
- * true=the character at the specified index is a local number
- * false=the character at the specified index is not a local number
- */
-boolean isLocalNumber(int logicalIndex) {
- boolean isLocalNumber = false;
-
- if (logicalIndex >= 0 && logicalIndex < classBuffer.length) {
- isLocalNumber = classBuffer[logicalIndex] == BidiUtil.CLASS_LOCALNUMBER;
- }
- return isLocalNumber;
-}
-/**
- * Returns the direction of the character at the specified index.
- * Used for rendering and caret positioning where local numbers (e.g.,
- * national Arabic, or Hindi, numbers) are considered left-to-right.
- * <p>
- *
- * @param logicalIndex the index of the character
- * @return
- * true=the character at the specified index is in a right-to-left
- * codepage (e.g., Hebrew, Arabic).
- * false=the character at the specified index is in a left-to-right/latin
- * codepage.
- */
-boolean isRightToLeft(int logicalIndex) {
- boolean isRightToLeft = false;
-
- if (logicalIndex >= 0 && logicalIndex < classBuffer.length) {
- isRightToLeft = (classBuffer[logicalIndex] == BidiUtil.CLASS_ARABIC) ||
- (classBuffer[logicalIndex] == BidiUtil.CLASS_HEBREW);
- }
- return isRightToLeft;
-}
-/**
- * Returns the direction of the character at the specified index.
- * Used for setting the keyboard language where local numbers (e.g.,
- * national Arabic, or Hindi, numbers) are considered right-to-left.
- * <p>
- *
- * @param logicalIndex the index of the character
- * @return
- * true=the character at the specified index is in a right-to-left
- * codepage (e.g., Hebrew, Arabic).
- * false=the character at the specified index is in a left-to-right/latin
- * codepage.
- */
-boolean isRightToLeftInput(int logicalIndex) {
- boolean isRightToLeft = false;
-
- if (logicalIndex >= 0 && logicalIndex < classBuffer.length) {
- isRightToLeft = (classBuffer[logicalIndex] == BidiUtil.CLASS_ARABIC) ||
- (classBuffer[logicalIndex] == BidiUtil.CLASS_HEBREW) ||
- (classBuffer[logicalIndex] == BidiUtil.CLASS_LOCALNUMBER);
- }
- return isRightToLeft;
-}
-/**
- * Returns whether the specified index is the start of a user
- * specified direction segment.
- * <p>
- *
- * @param logicalIndex the index to test
- * @return true=the specified index is the start of a user specified
- * direction segment, false otherwise
- */
-private boolean isStartOfBidiSegment(int logicalIndex) {
- for (int i = 0; i < bidiSegments.length; i++) {
- if (bidiSegments[i] == logicalIndex) return true;
- }
- return false;
-}
-/**
- * Reorders and calculates render positions for the specified sub-line
- * of text. The results will be merged with the data for the rest of
- * the line .
- * <p>
- *
- * @param textline the entire line of text that this object represents.
- * @param logicalStart the start offset of the first character to
- * reorder.
- * @param length the number of characters to reorder
- */
-private void prepareFontStyledText(String textline, int logicalStart, int length) {
- int byteCount = length;
- int flags = 0;
- String text = textline.substring(logicalStart, logicalStart + length);
-
- // Figure out what is before and after the substring so that the proper character
- // shaping will occur. Character shaping will not occur across bidi segments, so
- // if the styled text starts or ends on a bidi segment, do not process the text
- // for character shaping.
- if (logicalStart != 0
- && isCharacterShaped(gc)
- && !isStartOfBidiSegment(logicalStart)
- && !Compatibility.isWhitespace(textline.charAt(logicalStart - 1))
- && isRightToLeft(logicalStart - 1)) {
- // if the start of the substring is not the beginning of the
- // text line, check to see what is before the string
- flags |= BidiUtil.LINKBEFORE;
- }
- if ((logicalStart + byteCount) != dx.length
- && isCharacterShaped(gc)
- && !isStartOfBidiSegment(logicalStart + length)
- && !Compatibility.isWhitespace(textline.charAt(logicalStart + byteCount))
- && isRightToLeft(logicalStart + byteCount)) {
- // if the end of the substring is not the end of the text line,
- // check to see what is after the substring
- flags |= BidiUtil.LINKAFTER;
- }
- // set classification values for the substring
- flags |= BidiUtil.CLASSIN;
- byte[] classArray = new byte[byteCount];
- int[] renderIndexes = getRenderIndexesFor(logicalStart, byteCount);
- for (int i = 0; i < byteCount; i++) {
- classArray[i] = classBuffer[renderIndexes[i]];
- }
- int[] dxArray = new int[byteCount];
- int[] orderArray = new int[byteCount];
- BidiUtil.getRenderInfo(gc, text, orderArray, classArray, dxArray, flags, new int[] {0, text.length()});
- // update the existing dx array with the new dx values based on the bold font
- for (int i = 0; i < dxArray.length; i++) {
- int dxValue = dxArray[orderArray[i]];
- int visualIndex = renderIndexes[i];
- dx[visualIndex] = dxValue;
- }
-}
-/**
- * Redraws a rectangle spanning the given logical range.
- * The rectangle may be visually discontiguous if the text segment
- * is bidirectional.
- * <p>
- *
- * @param parent window that should be invalidated
- * @param logicalStart logcial start offset of the rectangle
- * @param length number of logical characters the rectangle should span
- * @param xOffset x location of the line start
- * @param yOffset y location of the line start
- * @param height height of the invalidated rectangle
- */
-void redrawRange(Control parent, int logicalStart, int length, int xOffset, int yOffset, int height) {
- Enumeration directionRuns;
-
- if (logicalStart < 0 || logicalStart + length > getTextLength()) {
- return;
- }
- directionRuns = getDirectionRuns(logicalStart, length).elements();
- while (directionRuns.hasMoreElements()) {
- DirectionRun run = (DirectionRun) directionRuns.nextElement();
- int startX = run.getRenderStartX();
-
- parent.redraw(xOffset + startX, yOffset, run.getRenderStopX() - startX, height, true);
- }
-}
-/**
- * Sets the keyboard language to match the codepage of the character
- * at the specified offset.
- * Only distinguishes between left-to-right and right-to-left characters and
- * sets the keyboard language to a bidi or non-bidi language.
- * <p>
- *
- * @param logicalIndex logical offset of the character to use for
- * determining the new keyboard language.
- */
-void setKeyboardLanguage(int logicalIndex) {
- int language;
- int current = BidiUtil.getKeyboardLanguage();
-
- if (logicalIndex < 0 || logicalIndex >= classBuffer.length) {
- return;
- }
- if (isRightToLeftInput(logicalIndex)) {
- // keyboard already in bidi mode, since we cannot distinguish between
- // multiple bidi languages, just return
- if (current == BidiUtil.KEYBOARD_BIDI) return;
- language = BidiUtil.KEYBOARD_BIDI;
- } else {
- // keyboard already in non-bidi mode, since we cannot distinguish between
- // multiple non-bidi languages, just return
- if (current == BidiUtil.KEYBOARD_NON_BIDI) return;
- language = BidiUtil.KEYBOARD_NON_BIDI;
- }
- BidiUtil.setKeyboardLanguage(language);
-}
-/**
- * Returns a string representation of the receiver.
- * <p>
- *
- * @return a string representation of the receiver for
- * debugging purposes. The output order of the StyledTextbidi values
- * is as follows: order, render position, dx, character class, glyphs.
- */
-public String toString() {
- StringBuffer buf = new StringBuffer();
-
- buf.append("StyledTextBidi {{");
- // order
- for (int i = 0; i < order.length; i++) {
- if (i != 0) {
- buf.append(",");
- }
- buf.append(order[i]);
- }
- buf.append("}, {");
- // render positions
- for (int i = 0; i < renderPositions.length; i++) {
- if (i != 0) {
- buf.append(",");
- }
- buf.append(renderPositions[i]);
- }
- buf.append("}, {");
- // dx
- for (int i = 0; i < dx.length; i++) {
- if (i != 0) {
- buf.append(",");
- }
- buf.append(dx[i]);
- }
- buf.append("}, {");
- // character class
- for (int i = 0; i < classBuffer.length; i++) {
- if (i != 0) {
- buf.append(",");
- }
- buf.append(classBuffer[i]);
- }
- buf.append("}, {");
- // glyphs
- buf.append(glyphBuffer);
- buf.append("}}");
- return buf.toString();
-}
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+import java.util.*;
+import org.eclipse.swt.*;
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.internal.*;
+import org.eclipse.swt.widgets.*;
+
+/**
+ * This class provides API for StyledText to implement bidirectional text
+ * functions.
+ * Objects of this class are created for a single line of text.
+ */
+class StyledTextBidi {
+ private GC gc;
+ private int[] bidiSegments; // bidi text segments, each segment will be rendered separately
+ private int[] renderPositions; // x position at which characters of the line are rendered, in visual order
+ private int[] order; // reordering indices in logical order, iV=order[iL] (iV=visual index, iL=logical index),
+ // if no character in a line needs reordering all iV and iL are the same.
+ private int[] dx; // distance between character cells. in visual order. renderPositions[iV + 1] = renderPositions[iV] + dx[iV]
+ private byte[] classBuffer; // the character types in logical order, see BidiUtil for the possible types
+ private char[] glyphBuffer; // the glyphs in visual order as they will be rendered on screen.
+
+ /**
+ * This class describes a text segment of a single direction, either
+ * left-to-right (L2R) or right-to-left (R2L).
+ * Objects of this class are used by StyledTextBidi rendering methods
+ * to render logically contiguous text segments that may be visually
+ * discontiguous if they consist of different directions.
+ */
+ class DirectionRun {
+ int logicalStart;
+ int logicalEnd;
+
+ DirectionRun(int logicalStart, int logicalEnd) {
+ this.logicalStart = logicalStart;
+ this.logicalEnd = logicalEnd;
+ }
+ int getVisualStart() {
+ int visualStart = order[logicalStart];
+ int visualEnd = order[logicalEnd];
+ // the visualStart of a R2L direction run is actually
+ // at the run's logicalEnd, answered as such since rendering
+ // always occurs from L2R regardless of the text run's
+ // direction
+ if (visualEnd < visualStart) {
+ visualStart = visualEnd;
+ }
+ return visualStart;
+ }
+ int getVisualEnd() {
+ int visualStart = order[logicalStart];
+ int visualEnd = order[logicalEnd];
+ // the visualEnd of a R2L direction run is actually
+ // at the run's logicalStart, answered as such since rendering
+ // always occurs from L2R regardless of the text run's
+ // direction
+ if (visualEnd < visualStart) {
+ visualEnd = visualStart;
+ }
+ return visualEnd;
+ }
+ int getRenderStartX() {
+ return renderPositions[getVisualStart()];
+ }
+ int getRenderStopX() {
+ int visualEnd = getVisualEnd();
+
+ return renderPositions[visualEnd] + dx[visualEnd];
+ }
+ public String toString() {
+ StringBuffer buf = new StringBuffer();
+ buf.append("vStart,Stop:" + getVisualStart() + "," + getVisualEnd() + " lStart,Stop:" + logicalStart + "," + logicalEnd + " renderStart,Stop: " + getRenderStartX() + "," + getRenderStopX());
+ return buf.toString();
+ }
+ }
+
+/**
+ * Constructs an instance of this class for a line of text. The text
+ * is reordered to reflect how it will be displayed.
+ * <p>
+ *
+ * @param gc the GC to use for rendering and measuring of this line.
+ * @param tabWidth tab width in number of spaces, used to calculate
+ * tab stops
+ * @param text line that bidi data should be calculated for
+ * @param boldRanges bold text segments in the line, specified as
+ * i=bold start,i+1=bold length
+ * @param boldFont font that bold text will be rendered in, needed for
+ * proper measuring of bold text segments.
+ * @param offset text segments that should be measured and reordered
+ * separately, may be needed to preserve the order of separate R2L
+ * segments to each other. Must have at least two elements, 0 and the text
+ * length.
+ */
+public StyledTextBidi(GC gc, int tabWidth, String text, StyleRange[] ranges, Font boldFont, int[] offsets) {
+ int length = text.length();
+
+ this.gc = gc;
+ bidiSegments = offsets;
+ renderPositions = new int[length];
+ order = new int[length];
+ dx = new int[length];
+ classBuffer = new byte[length];
+ if (length == 0) {
+ glyphBuffer = new char[0];
+ }
+ else {
+ glyphBuffer = BidiUtil.getRenderInfo(gc, text, order, classBuffer, dx, 0, offsets);
+ if (ranges != null) {
+ // If the font supports characters shaping, break up the font style ranges based on
+ // the specified bidi segments. Each bidi segment will be treated separately
+ // for font style purposes.
+ StyleRange[] segmentedRanges;
+ if (isCharacterShaped(gc)) segmentedRanges = getSegmentedRangesFor(ranges);
+ else segmentedRanges = ranges;
+ Font normalFont = gc.getFont();
+ gc.setFont(boldFont);
+ for (int i = 0; i < segmentedRanges.length; i++) {
+ StyleRange segmentedRange = segmentedRanges[i];
+ int rangeStart = segmentedRange.start;
+ int rangeLength = segmentedRange.length;
+ // Font styled text needs to be processed so that the dx array reflects the styled
+ // font.
+ prepareFontStyledText(text, rangeStart, rangeLength);
+ }
+ gc.setFont(normalFont);
+ }
+ calculateTabStops(text, tabWidth);
+ calculateRenderPositions();
+ }
+}
+/**
+ * Constructs an instance of this class for a line of text. This constructor
+ * should be used when only ordering (not rendering) information is needed.
+ * Only the class and order arrays will be filled during this call.
+ * <p>
+ *
+ * @param gc the GC to use for rendering and measuring of this line.
+ * @param text line that bidi data should be calculated for
+ * @param offset text segments that should be measured and reordered
+ * separately, may be needed to preserve the order of separate R2L
+ * segments to each other
+ */
+public StyledTextBidi(GC gc, String text, int[] offsets) {
+ int length = text.length();
+ this.gc = gc;
+ bidiSegments = offsets;
+ order = new int[length];
+ classBuffer = new byte[length];
+ BidiUtil.getOrderInfo(gc, text, order, classBuffer, 0, offsets);
+ // initialize the unused arrays
+ dx = new int[0];
+ renderPositions = new int[0];
+ glyphBuffer = new char[0];
+
+}
+/**
+ * Adds a listener that should be called when the user changes the
+ * keyboard layout for the specified window.
+ * <p>
+ *
+ * @param control Control to add the keyboard language listener for.
+ * Each window has its own keyboard language setting.
+ * @param runnable the listener that should be called when the user
+ * changes the keyboard layout.
+ */
+static void addLanguageListener(Control control, Runnable runnable) {
+ BidiUtil.addLanguageListener(control.handle, runnable);
+}
+/**
+ * Answers the direction of the active keyboard language - either
+ * L2R or R2L. The active keyboard language determines the direction
+ * of the caret and can be changed by the user (e.g., via Alt-Shift on
+ * Win32 platforms).
+ * <p>
+ *
+ * @return the direction of the active keyboard language. SWT.LEFT (for L2R
+ * language) or SWT.RIGHT (for R2L language) or SWT.DEFAULT if no R2L languages
+ * are installed.
+ */
+static int getKeyboardLanguageDirection() {
+ int language = BidiUtil.getKeyboardLanguage();
+ if (language == BidiUtil.KEYBOARD_BIDI) {
+ return SWT.RIGHT;
+ }
+ if (BidiUtil.isKeyboardBidi()) {
+ return SWT.LEFT;
+ }
+ return SWT.DEFAULT;
+}
+/**
+ * Returns whether the current platform supports a bidi language.
+ * <p>
+ *
+ * @return true=bidi is supported, false otherwise.
+ */
+static boolean isBidiPlatform() {
+ return BidiUtil.isBidiPlatform();
+}
+/**
+ * Returns whether the font set in the specified gc supports
+ * character shaping.
+ * <p>
+ *
+ * @param gc the GC that should be tested for character shaping.
+ * @return
+ * true=the font set in the specified gc supports character shaped glyphs
+ * false=the font set in the specified gc doesn't support character shaped glyphs
+ */
+static boolean isCharacterShaped(GC gc) {
+ return (BidiUtil.getFontBidiAttributes(gc) & BidiUtil.GLYPHSHAPE) != 0;
+}
+/**
+ * Returns whether the font set in the specified gc contains
+ * ligatured glyphs.
+ * <p>
+ *
+ * @param gc the GC that should be tested for ligatures.
+ * @return
+ * true=the font set in the specified gc contains ligatured glyphs.
+ * false=the font set in the specified gc doesn't contain ligatured
+ * glyphs.
+ */
+static boolean isLigated(GC gc) {
+ return (BidiUtil.getFontBidiAttributes(gc) & BidiUtil.LIGATE) != 0;
+}
+/**
+ * Removes the keyboard language listener for the specified window.
+ * <p>
+ *
+ * @param control window to remove the keyboard language listener from.
+ */
+static void removeLanguageListener(Control control) {
+ BidiUtil.removeLanguageListener(control.handle);
+}
+/**
+ * Calculates render positions using the glyph distance values in the dx array.
+ */
+private void calculateRenderPositions() {
+ renderPositions = new int[dx.length];
+ renderPositions[0] = StyledText.XINSET;
+ for (int i = 0; i < dx.length - 1; i++) {
+ renderPositions[i + 1] = renderPositions[i] + dx[i];
+ }
+}
+/**
+ * Calculate the line's tab stops and adjust the dx array to
+ * reflect the width of tab characters.
+ * <p>
+ *
+ * @param text the original line text (not reordered) containing
+ * tab characters.
+ * @param tabWidth number of pixels that one tab character represents
+ */
+private void calculateTabStops(String text, int tabWidth) {
+ int tabIndex = text.indexOf('\t', 0);
+ int logicalIndex = 0;
+ int x = 0;
+ int spaceWidth = gc.stringExtent(" ").x;
+
+ while (tabIndex != -1) {
+ for (; logicalIndex < tabIndex; logicalIndex++) {
+ x += dx[order[logicalIndex]];
+ }
+ int tabStop = x + tabWidth;
+ // make sure tab stop is at least one space width apart
+ // from the last character. fixes 4844.
+ if (tabWidth - tabStop % tabWidth < spaceWidth) {
+ tabStop += tabWidth;
+ }
+ tabStop -= tabStop % tabWidth;
+ dx[order[tabIndex]] = tabStop - x;
+ tabIndex = text.indexOf('\t', tabIndex + 1);
+ }
+}
+/**
+ * Renders the specified text segment. All text is rendered L2R
+ * regardless of the direction of the text. The rendered text may
+ * be visually discontiguous if the text segment is bidirectional.
+ * <p>
+ *
+ * @param logicalStart start offset in the logical text
+ * @param length number of logical characters to render
+ * @param xOffset x location of the line start
+ * @param yOffset y location of the line start
+ */
+void drawBidiText(int logicalStart, int length, int xOffset, int yOffset) {
+ Enumeration directionRuns;
+ int endOffset = logicalStart + length;
+
+ if (logicalStart < 0 || endOffset > getTextLength()) {
+ return;
+ }
+ directionRuns = getDirectionRuns(logicalStart, length).elements();
+ while (directionRuns.hasMoreElements()) {
+ DirectionRun run = (DirectionRun) directionRuns.nextElement();
+ int visualStart = run.getVisualStart();
+ int visualEnd = run.getVisualEnd();
+ int x = xOffset + run.getRenderStartX();
+ drawGlyphs(visualStart, visualEnd - visualStart + 1, x, yOffset);
+ }
+}
+/**
+ * Renders a segment of glyphs. Glyphs are visual objects so the
+ * start and length are visual as well. Glyphs are always rendered L2R.
+ * <p>
+ *
+ * @param visualStart start offset of the glyphs to render relative to the
+ * line start.
+ * @param length number of glyphs to render
+ * @param x x location to render at
+ * @param y y location to render at
+ */
+private void drawGlyphs(int visualStart, int length, int x, int y) {
+ char[] renderBuffer = new char[length];
+ int[] renderDx = new int[length];
+ if (length == 0) {
+ return;
+ }
+ System.arraycopy(glyphBuffer, visualStart, renderBuffer, 0, length);
+ // copy the distance values for the desired rendering range
+ System.arraycopy(dx, visualStart, renderDx, 0, length);
+ BidiUtil.drawGlyphs(gc, renderBuffer, renderDx, x, y);
+}
+/**
+ * Fills a rectangle spanning the given logical range.
+ * The rectangle may be visually discontiguous if the text segment
+ * is bidirectional.
+ * <p>
+ *
+ * @param logicalStart logcial start offset of the rectangle
+ * @param length number of logical characters the rectangle should span
+ * @param xOffset x location of the line start
+ * @param yOffset y location of the line start
+ * @param height height of the rectangle
+ */
+void fillBackground(int logicalStart, int length, int xOffset, int yOffset, int height) {
+ Enumeration directionRuns = getDirectionRuns(logicalStart, length).elements();
+
+ if (logicalStart < 0 || logicalStart + length > getTextLength()) {
+ return;
+ }
+ while (directionRuns.hasMoreElements()) {
+ DirectionRun run = (DirectionRun) directionRuns.nextElement();
+ int startX = run.getRenderStartX();
+ gc.fillRectangle(xOffset + startX, yOffset, run.getRenderStopX() - startX, height);
+ }
+}
+/**
+ * Returns the offset and direction that will be used to position the caret for
+ * the given x location. The caret will be placed in front of or behind the
+ * character at location x depending on what type of character (i.e., R2L or L2R)
+ * is at location x. This method is used for positioning the caret when a mouse
+ * click occurs within the widget.
+ * <p>
+ *
+ * @param x the x location of the character in the line.
+ * @return array containing the caret offset and direction for the x location.
+ * index 0: offset relative to the start of the line
+ * index 1: direction, either ST.COLUMN_NEXT or ST.COLUMN_PREVIOUS.
+ * The direction is used to control the caret position at direction
+ * boundaries. The semantics follow the behavior for keyboard cursor
+ * navigation.
+ * Example: RRRLLL
+ * Pressing cursor left (COLUMN_PREVIOUS) in the L2R segment places the cursor
+ * in front of the first character of the L2R segment. Pressing cursor right
+ * (COLUMN_NEXT) in a R2L segment places the cursor behind the last character
+ * of the R2L segment. However, both are the same logical offset.
+ */
+int[] getCaretOffsetAndDirectionAtX(int x) {
+ int lineLength = getTextLength();
+ int offset;
+ int direction;
+
+ if (lineLength == 0) {
+ return new int[] {0, 0};
+ }
+ int eol = renderPositions[renderPositions.length - 1] + dx[dx.length - 1];
+ if (x >= eol) {
+ return new int[] {lineLength, ST.COLUMN_NEXT};
+ }
+ // get the visual offset of the clicked character
+ int visualOffset = getVisualOffsetAtX(x);
+ // figure out if the character was clicked on the right or left
+ int halfway = renderPositions[visualOffset] + dx[visualOffset] / 2;
+ boolean visualLeft = (x <= halfway);
+ offset = getLogicalOffset(visualOffset);
+
+ if (isRightToLeft(offset)) {
+ if (visualLeft) {
+ if (isLigated(gc)) {
+ // the caret should be positioned after the last
+ // character of the ligature
+ offset = getLigatureEndOffset(offset);
+ }
+ offset++;
+ // position the caret as if the caret is to the right
+ // of the character at location x and the NEXT key is
+ // pressed
+ direction = ST.COLUMN_NEXT;
+ }
+ else {
+ // position the caret as if the caret is to the left
+ // of the character at location x and the PREVIOUS key is
+ // pressed
+ direction = ST.COLUMN_PREVIOUS;
+ }
+ }
+ else {
+ if (visualLeft) {
+ // position the caret as if the caret is to the right
+ // of the character at location x and the PREVIOUS key is
+ // pressed
+ direction = ST.COLUMN_PREVIOUS;
+ }
+ else {
+ // position the caret as if the caret is to the left
+ // of the character at location x and the NEXT key is
+ // pressed
+ offset++;
+ direction = ST.COLUMN_NEXT;
+ }
+ }
+ return new int[] {offset, direction};
+}
+/**
+ * Returns the direction segments that are in the specified text
+ * range. The text range may be visually discontiguous if the
+ * text is bidirectional. Each returned direction run has a single
+ * direction and the runs all go from left to right, regardless of
+ * the direction of the text in the segment. User specified segments
+ * (via BidiSegmentListener) are taken into account and result in
+ * separate direction runs.
+ * <p>
+ *
+ * @param logicalStart offset of the logcial start of the first
+ * direction segment
+ * @param length length of the text included in the direction
+ * segments
+ * @return the direction segments that are in the specified
+ * text range, each segment has a single direction.
+ */
+private Vector getDirectionRuns(int logicalStart, int length) {
+ Vector directionRuns = new Vector();
+ int logicalEnd = logicalStart + length - 1;
+ int segmentLogicalStart = logicalStart;
+ int segmentLogicalEnd = segmentLogicalStart;
+
+ if (logicalEnd < getTextLength()) {
+ int bidiSegmentIndex = 0;
+ int bidiSegmentEnd = bidiSegments[bidiSegmentIndex + 1];
+
+ // Find the bidi segment that the direction runs start in.
+ // There will always be at least on bidi segment (for the entire line).
+ while (bidiSegmentIndex < bidiSegments.length - 2 && bidiSegmentEnd <= logicalStart) {
+ bidiSegmentIndex++;
+ bidiSegmentEnd = bidiSegments[bidiSegmentIndex + 1];
+ }
+ while (segmentLogicalEnd <= logicalEnd) {
+ boolean isRightToLeftSegment = isRightToLeft(segmentLogicalStart);
+ // Search for the end of the direction segment. Each segment needs to
+ // be rendered separately.
+ // E.g., 11211 (1=R2L, 2=L2R), rendering from logical index 0 to 5
+ // would be visual 1 to 4 and would thus miss visual 0. Rendering the
+ // segments separately would render from visual 1 to 0, then 2, then
+ // 4 to 3.
+ while (segmentLogicalEnd < logicalEnd &&
+ // If our segment type is RtoL, the order index for the next character should be one less, if there
+ // is no direction change.
+ // If our segment type is LtoR, the order index for the next character will be one more if there is
+ // no direction change.
+ ((isRightToLeftSegment && (order[segmentLogicalEnd + 1]+ 1 == order[segmentLogicalEnd])) ||
+ (isRightToLeftSegment == false && (order[segmentLogicalEnd + 1]- 1 == order[segmentLogicalEnd]))) &&
+ segmentLogicalEnd + 1 < bidiSegmentEnd) {
+ segmentLogicalEnd++;
+ }
+ directionRuns.addElement(new DirectionRun(segmentLogicalStart, segmentLogicalEnd));
+ segmentLogicalStart = ++segmentLogicalEnd;
+ // The current direction run ends at a bidi segment end. Get the next bidi segment.
+ if (segmentLogicalEnd == bidiSegmentEnd && bidiSegmentIndex < bidiSegments.length - 2) {
+ bidiSegmentIndex++;
+ bidiSegmentEnd = bidiSegments[bidiSegmentIndex + 1];
+ }
+ }
+ }
+ return directionRuns;
+}
+/**
+ * Returns the offset of the last character comprising a ligature.
+ * <p>
+ *
+ * @param offset the logical offset of a character that may be a
+ * ligature.
+ * @return the offset of the last character comprising a ligature.
+ */
+int getLigatureEndOffset(int offset) {
+ int newOffset = offset;
+ int i = offset + 1;
+
+ // assume only bidi languages support ligatures
+ if (offset < 0 || offset >= order.length || isRightToLeft(offset) == false) {
+ return offset;
+ }
+ // a ligature is a visual character that is comprised of
+ // multiple logical characters, thus each logical part of
+ // a ligature will have the same order value
+ while (i < order.length && (order[i] == order[offset])) {
+ newOffset = i;
+ i++;
+ }
+ return newOffset;
+}
+/**
+ * Returns the offset of the first character comprising a ligature.
+ * <p>
+ *
+ * @param offset the logical offset of a character that may be a
+ * ligature.
+ * @return the offset of the first character comprising a ligature.
+ */
+int getLigatureStartOffset(int offset) {
+ int newOffset = offset;
+ int i = offset - 1;
+
+ // assume only bidi languages support ligatures
+ if (offset < 0 || offset >= order.length || isRightToLeft(offset) == false) {
+ return offset;
+ }
+ // a ligature is a visual character that is comprised of
+ // multiple logical characters, thus each logical part of
+ // a ligature will have the same order value
+ while (i >= 0 && (order[i] == order[offset])) {
+ newOffset = i;
+ i--;
+ }
+ return newOffset;
+}
+/**
+ * Returns the logical offset of the character at the specified
+ * visual offset.
+ * <p>
+ *
+ * @param visualOffset the visual offset
+ * @return the logical offset of the character at <code>visualOffset</code>.
+ */
+private int getLogicalOffset(int visualOffset) {
+ int logicalOffset = 0;
+
+ while (logicalOffset < order.length && order[logicalOffset] != visualOffset) {
+ logicalOffset++;
+ }
+ return logicalOffset;
+}
+/**
+ * Returns the offset of the character at the specified x location.
+ * <p>
+ *
+ * @param x the location of the character
+ * @return the logical offset of the character at the specified x
+ * location.
+ */
+int getOffsetAtX(int x) {
+ int visualOffset;
+
+ if (getTextLength() == 0) {
+ return 0;
+ }
+ if (x >= renderPositions[renderPositions.length - 1] + dx[dx.length - 1]) {
+ // Return when x is past the end of the line. Fixes 1GLADBK.
+ return -1;
+ }
+ visualOffset = getVisualOffsetAtX(x);
+ return getLogicalOffset(visualOffset);
+}
+/**
+ * Returns the reordering indices that map between logical and
+ * visual index of characters in the specified range.
+ * <p>
+ *
+ * @param start start offset of the reordering indices
+ * @param length number of reordering indices to return
+ * @return the reordering indices that map between logical and
+ * visual index of characters in the specified range. Relative
+ * to the start of the range.
+ */
+private int[] getRenderIndexesFor(int start, int length) {
+ int[] positions = new int[length];
+ int end = start + length;
+
+ for (int i = start; i < end; i++) {
+ positions[i-start] = order[i];
+ }
+ return positions;
+}
+/**
+ * Break up the given ranges such that each range is fully contained within a bidi
+ * segment.
+ */
+private StyleRange[] getSegmentedRangesFor(StyleRange[] ranges) {
+ if ((bidiSegments == null) || (bidiSegments.length == 0)) return ranges;
+ Vector newRanges = new Vector();
+ int j=0;
+ int startSegment;
+ int endSegment;
+ for (int i=0; i<ranges.length; i++) {
+ int start = ranges[i].start;
+ int end = start+ranges[i].length;
+ startSegment=-1;
+ endSegment=-1;
+ boolean done = false;
+ while (j<bidiSegments.length && !done) {
+ if (bidiSegments[j]<=start) {
+ startSegment=j;
+ }
+ if (bidiSegments[j]>=end) {
+ endSegment=j-1;
+ j--;
+ }
+ done = (startSegment != -1) && (endSegment != -1);
+ if (!done) j++;
+ }
+ if (startSegment == endSegment) {
+ // range is within one segment
+ StyleRange newStyle = new StyleRange(start, end-start, null, null);
+ newRanges.addElement(newStyle);
+ } else if (startSegment > endSegment) {
+ // range is within no segment (i.e., it's empty)
+ } else {
+ // range spans multiple segments
+ StyleRange newStyle = new StyleRange(start, bidiSegments[startSegment+1]-start, null, null);
+ newRanges.addElement(newStyle);
+ startSegment++;
+ for (int k=startSegment; k<endSegment; k++) {
+ newStyle = new StyleRange(bidiSegments[k], bidiSegments[k+1]-bidiSegments[k], null, null);
+ newRanges.addElement(newStyle);
+ }
+ newStyle = new StyleRange(bidiSegments[endSegment], end-bidiSegments[endSegment], null, null);
+ newRanges.addElement(newStyle);
+ }
+ }
+ StyleRange[] rangeArray = new StyleRange[newRanges.size()];
+ for (int i=0; i<newRanges.size(); i++) {
+ rangeArray[i]=(StyleRange)newRanges.elementAt(i);
+ }
+ return rangeArray;
+}
+/**
+ * Returns the number of characters in the line.
+ * <p>
+ *
+ * @return the number of characters in the line.
+ */
+private int getTextLength() {
+ return dx.length;
+}
+/**
+ * Returns the x position at the specified offset in the line.
+ * <p>
+ * @param logicalOffset offset of the character in the line.
+ * @return the x position at the specified offset in the line.
+ */
+int getTextPosition(int logicalOffset) {
+ return getTextPosition(logicalOffset, ST.COLUMN_NEXT);
+}
+/**
+ * Returns the x position at the specified offset in the line.
+ * The direction parameter is used to determine the position
+ * at direction boundaries. If the logical offset is between a R2L
+ * and a L2R segment, pressing cursor left in the L2R segment places
+ * the position in front of the first character of the L2R segment; whereas
+ * pressing cursor right in the R2L segment places the position behind
+ * the last character of the R2L segment. However, both x positions
+ * are at the same logical offset.
+ * <p>
+ *
+ * @param logicalOffset offset of the character in the line
+ * @param direction direction the caret moved to the specified location.
+ * either ST.COLUMN_NEXT (right cursor key) or ST.COLUMN_PREVIOUS (left cursor key) .
+ * @return the x position at the specified offset in the line,
+ * taking the direction into account as described above.
+ */
+int getTextPosition(int logicalOffset, int direction) {
+ int caretX;
+
+ if (getTextLength() == 0 || logicalOffset < 0) {
+ return StyledText.XINSET;
+ }
+ // at or past end of line?
+ if (logicalOffset >= order.length) {
+ logicalOffset = Math.min(logicalOffset, order.length - 1);
+ int visualOffset = order[logicalOffset];
+ if (isRightToLeft(logicalOffset)) {
+ caretX = renderPositions[visualOffset];
+ }
+ else {
+ caretX = renderPositions[visualOffset] + dx[visualOffset];
+ }
+ }
+ else
+ // at beginning of line?
+ if (logicalOffset == 0) {
+ int visualOffset = order[logicalOffset];
+ if (isRightToLeft(logicalOffset)) {
+ caretX = renderPositions[visualOffset] + dx[visualOffset];
+ }
+ else {
+ caretX = renderPositions[visualOffset];
+ }
+ }
+ else
+ // always consider local numbers as a direction boundary
+ // because they represent a discontiguous text segment coming from
+ // a R2L segment.
+ // treat user specified direction segments like real direction changes.
+ if (direction == ST.COLUMN_NEXT &&
+ (isRightToLeft(logicalOffset) != isRightToLeft(logicalOffset - 1) ||
+ isLocalNumber(logicalOffset) != isLocalNumber(logicalOffset - 1) ||
+ isStartOfBidiSegment(logicalOffset))) {
+ int visualOffset = order[logicalOffset-1];
+ // moving between segments.
+ // do not consider local numbers as R2L here, to determine position,
+ // because local numbers are navigated L2R and we want the caret to
+ // be to the right of the number. see 1GK9API
+ if (isRightToLeft(logicalOffset - 1)) {
+ // moving from RtoL to LtoR
+ caretX = renderPositions[visualOffset];
+ }
+ else {
+ // moving from LtoR to RtoL
+ caretX = renderPositions[visualOffset] + dx[visualOffset];
+ }
+ }
+ else
+ // consider local numbers as R2L in determining direction boundaries.
+ // fixes 1GK9API.
+ if (direction == ST.COLUMN_PREVIOUS &&
+ isRightToLeftInput(logicalOffset) != isRightToLeftInput(logicalOffset - 1)) {
+ int visualOffset = order[logicalOffset];
+ // moving between segments.
+ // consider local numbers as R2L here, to determine position, because
+ // we want to stay in L2R segment and place the cursor to the left of
+ // first L2R character. see 1GK9API
+ if (isRightToLeftInput(logicalOffset - 1)) {
+ // moving from LtoR to RtoL
+ caretX = renderPositions[visualOffset];
+ }
+ else {
+ // moving from RtoL to LtoR
+ caretX = renderPositions[visualOffset] + dx[visualOffset];
+ }
+ }
+ else
+ if (isRightToLeft(logicalOffset)) {
+ int visualOffset = order[logicalOffset];
+ caretX = renderPositions[visualOffset] + dx[visualOffset];
+ }
+ else {
+ caretX = renderPositions[order[logicalOffset]];
+ }
+ return caretX;
+}
+/**
+ * Returns the width in pixels of the line.
+ * <p>
+ *
+ * @return the width in pixels of the line.
+ */
+int getTextWidth() {
+ int width = 0;
+
+ if (getTextLength() > 0) {
+ width = renderPositions[renderPositions.length - 1] + dx[dx.length - 1];
+ }
+ return width;
+}
+/**
+ * Returns the visual offset of the character at the specified x
+ * location.
+ * <p>
+ *
+ * @param x the location of the character
+ * @return the visual offset of the character at the specified x
+ * location.
+ */
+private int getVisualOffsetAtX(int x) {
+ int lineLength = getTextLength();
+ int low = -1;
+ int high = lineLength;
+
+ while (high - low > 1) {
+ int offset = (high + low) / 2;
+ int visualX = renderPositions[offset];
+
+ // visualX + dx is the start of the next character. Restrict right/high
+ // search boundary only if x is before next character. Fixes 1GL4ZVE.
+ if (x < visualX + dx[offset]) {
+ high = offset;
+ }
+ else
+ if (high == lineLength && high - offset == 1) {
+ // requested x location is past end of line
+ high = -1;
+ }
+ else {
+ low = offset;
+ }
+ }
+ return high;
+}
+/**
+ * Returns if the character at the given offset is a local number.
+ * <p>
+ *
+ * @param logicalIndex the index of the character
+ * @return
+ * true=the character at the specified index is a local number
+ * false=the character at the specified index is not a local number
+ */
+boolean isLocalNumber(int logicalIndex) {
+ boolean isLocalNumber = false;
+
+ if (logicalIndex >= 0 && logicalIndex < classBuffer.length) {
+ isLocalNumber = classBuffer[logicalIndex] == BidiUtil.CLASS_LOCALNUMBER;
+ }
+ return isLocalNumber;
+}
+/**
+ * Returns the direction of the character at the specified index.
+ * Used for rendering and caret positioning where local numbers (e.g.,
+ * national Arabic, or Hindi, numbers) are considered left-to-right.
+ * <p>
+ *
+ * @param logicalIndex the index of the character
+ * @return
+ * true=the character at the specified index is in a right-to-left
+ * codepage (e.g., Hebrew, Arabic).
+ * false=the character at the specified index is in a left-to-right/latin
+ * codepage.
+ */
+boolean isRightToLeft(int logicalIndex) {
+ boolean isRightToLeft = false;
+
+ if (logicalIndex >= 0 && logicalIndex < classBuffer.length) {
+ isRightToLeft = (classBuffer[logicalIndex] == BidiUtil.CLASS_ARABIC) ||
+ (classBuffer[logicalIndex] == BidiUtil.CLASS_HEBREW);
+ }
+ return isRightToLeft;
+}
+/**
+ * Returns the direction of the character at the specified index.
+ * Used for setting the keyboard language where local numbers (e.g.,
+ * national Arabic, or Hindi, numbers) are considered right-to-left.
+ * <p>
+ *
+ * @param logicalIndex the index of the character
+ * @return
+ * true=the character at the specified index is in a right-to-left
+ * codepage (e.g., Hebrew, Arabic).
+ * false=the character at the specified index is in a left-to-right/latin
+ * codepage.
+ */
+boolean isRightToLeftInput(int logicalIndex) {
+ boolean isRightToLeft = false;
+
+ if (logicalIndex >= 0 && logicalIndex < classBuffer.length) {
+ isRightToLeft = (classBuffer[logicalIndex] == BidiUtil.CLASS_ARABIC) ||
+ (classBuffer[logicalIndex] == BidiUtil.CLASS_HEBREW) ||
+ (classBuffer[logicalIndex] == BidiUtil.CLASS_LOCALNUMBER);
+ }
+ return isRightToLeft;
+}
+/**
+ * Returns whether the specified index is the start of a user
+ * specified direction segment.
+ * <p>
+ *
+ * @param logicalIndex the index to test
+ * @return true=the specified index is the start of a user specified
+ * direction segment, false otherwise
+ */
+private boolean isStartOfBidiSegment(int logicalIndex) {
+ for (int i = 0; i < bidiSegments.length; i++) {
+ if (bidiSegments[i] == logicalIndex) return true;
+ }
+ return false;
+}
+/**
+ * Reorders and calculates render positions for the specified sub-line
+ * of text. The results will be merged with the data for the rest of
+ * the line .
+ * <p>
+ *
+ * @param textline the entire line of text that this object represents.
+ * @param logicalStart the start offset of the first character to
+ * reorder.
+ * @param length the number of characters to reorder
+ */
+private void prepareFontStyledText(String textline, int logicalStart, int length) {
+ int byteCount = length;
+ int flags = 0;
+ String text = textline.substring(logicalStart, logicalStart + length);
+
+ // Figure out what is before and after the substring so that the proper character
+ // shaping will occur. Character shaping will not occur across bidi segments, so
+ // if the styled text starts or ends on a bidi segment, do not process the text
+ // for character shaping.
+ if (logicalStart != 0
+ && isCharacterShaped(gc)
+ && !isStartOfBidiSegment(logicalStart)
+ && !Compatibility.isWhitespace(textline.charAt(logicalStart - 1))
+ && isRightToLeft(logicalStart - 1)) {
+ // if the start of the substring is not the beginning of the
+ // text line, check to see what is before the string
+ flags |= BidiUtil.LINKBEFORE;
+ }
+ if ((logicalStart + byteCount) != dx.length
+ && isCharacterShaped(gc)
+ && !isStartOfBidiSegment(logicalStart + length)
+ && !Compatibility.isWhitespace(textline.charAt(logicalStart + byteCount))
+ && isRightToLeft(logicalStart + byteCount)) {
+ // if the end of the substring is not the end of the text line,
+ // check to see what is after the substring
+ flags |= BidiUtil.LINKAFTER;
+ }
+ // set classification values for the substring
+ flags |= BidiUtil.CLASSIN;
+ byte[] classArray = new byte[byteCount];
+ int[] renderIndexes = getRenderIndexesFor(logicalStart, byteCount);
+ for (int i = 0; i < byteCount; i++) {
+ classArray[i] = classBuffer[renderIndexes[i]];
+ }
+ int[] dxArray = new int[byteCount];
+ int[] orderArray = new int[byteCount];
+ BidiUtil.getRenderInfo(gc, text, orderArray, classArray, dxArray, flags, new int[] {0, text.length()});
+ // update the existing dx array with the new dx values based on the bold font
+ for (int i = 0; i < dxArray.length; i++) {
+ int dxValue = dxArray[orderArray[i]];
+ int visualIndex = renderIndexes[i];
+ dx[visualIndex] = dxValue;
+ }
+}
+/**
+ * Redraws a rectangle spanning the given logical range.
+ * The rectangle may be visually discontiguous if the text segment
+ * is bidirectional.
+ * <p>
+ *
+ * @param parent window that should be invalidated
+ * @param logicalStart logcial start offset of the rectangle
+ * @param length number of logical characters the rectangle should span
+ * @param xOffset x location of the line start
+ * @param yOffset y location of the line start
+ * @param height height of the invalidated rectangle
+ */
+void redrawRange(Control parent, int logicalStart, int length, int xOffset, int yOffset, int height) {
+ Enumeration directionRuns;
+
+ if (logicalStart < 0 || logicalStart + length > getTextLength()) {
+ return;
+ }
+ directionRuns = getDirectionRuns(logicalStart, length).elements();
+ while (directionRuns.hasMoreElements()) {
+ DirectionRun run = (DirectionRun) directionRuns.nextElement();
+ int startX = run.getRenderStartX();
+
+ parent.redraw(xOffset + startX, yOffset, run.getRenderStopX() - startX, height, true);
+ }
+}
+/**
+ * Sets the keyboard language to match the codepage of the character
+ * at the specified offset.
+ * Only distinguishes between left-to-right and right-to-left characters and
+ * sets the keyboard language to a bidi or non-bidi language.
+ * <p>
+ *
+ * @param logicalIndex logical offset of the character to use for
+ * determining the new keyboard language.
+ */
+void setKeyboardLanguage(int logicalIndex) {
+ int language;
+ int current = BidiUtil.getKeyboardLanguage();
+
+ if (logicalIndex < 0 || logicalIndex >= classBuffer.length) {
+ return;
+ }
+ if (isRightToLeftInput(logicalIndex)) {
+ // keyboard already in bidi mode, since we cannot distinguish between
+ // multiple bidi languages, just return
+ if (current == BidiUtil.KEYBOARD_BIDI) return;
+ language = BidiUtil.KEYBOARD_BIDI;
+ } else {
+ // keyboard already in non-bidi mode, since we cannot distinguish between
+ // multiple non-bidi languages, just return
+ if (current == BidiUtil.KEYBOARD_NON_BIDI) return;
+ language = BidiUtil.KEYBOARD_NON_BIDI;
+ }
+ BidiUtil.setKeyboardLanguage(language);
+}
+/**
+ * Returns a string representation of the receiver.
+ * <p>
+ *
+ * @return a string representation of the receiver for
+ * debugging purposes. The output order of the StyledTextbidi values
+ * is as follows: order, render position, dx, character class, glyphs.
+ */
+public String toString() {
+ StringBuffer buf = new StringBuffer();
+
+ buf.append("StyledTextBidi {{");
+ // order
+ for (int i = 0; i < order.length; i++) {
+ if (i != 0) {
+ buf.append(",");
+ }
+ buf.append(order[i]);
+ }
+ buf.append("}, {");
+ // render positions
+ for (int i = 0; i < renderPositions.length; i++) {
+ if (i != 0) {
+ buf.append(",");
+ }
+ buf.append(renderPositions[i]);
+ }
+ buf.append("}, {");
+ // dx
+ for (int i = 0; i < dx.length; i++) {
+ if (i != 0) {
+ buf.append(",");
+ }
+ buf.append(dx[i]);
+ }
+ buf.append("}, {");
+ // character class
+ for (int i = 0; i < classBuffer.length; i++) {
+ if (i != 0) {
+ buf.append(",");
+ }
+ buf.append(classBuffer[i]);
+ }
+ buf.append("}, {");
+ // glyphs
+ buf.append(glyphBuffer);
+ buf.append("}}");
+ return buf.toString();
+}
+}
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
index bb46fb4eb4..4a39db49b7 100755
--- 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
@@ -1,202 +1,202 @@
-package org.eclipse.swt.custom;
-
-/*
+package org.eclipse.swt.custom;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-/**
- * Clients may implement the StyledTextContent interface to provide a
- * custom store for the StyledText widget content. The StyledText widget
- * interacts with its StyledTextContent in order to access and update
- * the text that is being displayed and edited in the widget.
- * A custom content implementation can be set in the widget using the
- * StyledText.setContent API.
- */
-public interface StyledTextContent {
-
-/**
- * Called by StyledText to add itself as an Observer to content changes.
- * See TextChangeListener for a description of the listener methods that
- * are called when text changes occur.
- * <p>
- *
- * @param listener the listener
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT when listener is null</li>
- * </ul>
- */
-public void addTextChangeListener(TextChangeListener listener);
-
-/**
- * Return the number of characters in the content.
- * <p>
- *
- * @return the number of characters in the content.
- */
-public int getCharCount();
-
-/**
- * Return the line at the given line index without delimiters.
- * <p>
- *
- * @param lineIndex index of the line to return. Does not include
- * delimiters of preceeding lines. Index 0 is the first line of the
- * content.
- * @return the line text without delimiters
- */
-public String getLine(int lineIndex);
-
-/**
- * Return the line index at the given character offset.
- * <p>
- *
- * @param offset offset of the line to return. The first character of the
- * document is at offset 0. An offset of getLength() is valid and should
- * answer the number of lines.
- * @return the line index. The first line is at index 0. If the character
- * at offset is a delimiter character, answer the line index of the line
- * that is delimited.
- * For example, if text = "\r\n\r\n", and delimiter = "\r\n", then:
- * <ul>
- * <li>getLineAtOffset(0) == 0
- * <li>getLineAtOffset(1) == 0
- * <li>getLineAtOffset(2) == 1
- * <li>getLineAtOffset(3) == 1
- * <li>getLineAtOffset(4) == 2
- * </ul>
- */
-public int getLineAtOffset(int offset);
-
-/**
- * Return the number of lines. Should answer 1 when no text is specified.
- * The StyledText widget relies on this behavior for drawing the cursor.
- * <p>
- *
- * @return the number of lines. For example:
- * <ul>
- * <li> text value ==> getLineCount
- * <li> null ==> 1
- * <li> "" ==> 1
- * <li> "a\n" ==> 2
- * <li> "\n\n" ==> 3
- * </ul>
- */
-public int getLineCount();
-
-/**
- * Return the line delimiter that should be used by the StyledText
- * widget when inserting new lines. New lines entered using key strokes
- * and paste operations use this line delimiter.
- * Implementors may use System.getProperty("line.separator") to return
- * the platform line delimiter.
- * <p>
- *
- * @return the line delimiter that should be used by the StyledText widget
- * when inserting new lines.
- */
-public String getLineDelimiter();
-
-/**
- * Return the character offset of the first character of the given line.
- * <p>
- * <b>NOTE:</b> When there is no text (i.e., no lines), getOffsetAtLine(0)
- * is a valid call that should return 0.
- * </p>
- *
- * @param lineIndex index of the line. The first line is at index 0.
- * @return offset offset of the first character of the line. The first
- * character of the document is at offset 0. The return value should
- * include line delimiters.
- * For example, if text = "\r\ntest\r\n" and delimiter = "\r\n", then:
- * <ul>
- * <li>getOffsetAtLine(0) == 0
- * <li>getOffsetAtLine(1) == 2
- * <li>getOffsetAtLine(2) == 8
- * </ul>
- */
-public int getOffsetAtLine(int lineIndex);
-
-/**
- * Returns a string representing the content at the given range.
- * <p>
- *
- * @param start the start offset of the text to return. Offset 0 is the
- * first character of the document.
- * @param length the length of the text to return
- * @return the text at the given range
- */
-public String getTextRange(int start, int length);
-
-/**
- * Remove the specified text changed listener.
- * <p>
- *
- * @param listener the listener
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT when listener is null</li>
- * </ul>
- */
-public void removeTextChangeListener(TextChangeListener listener);
-
-/**
- * Replace the text with "newText" starting at position "start"
- * for a length of "replaceLength".
- * <p>
- * Implementors have to notify the TextChangeListeners that were added
- * using <code>addTextChangeListener</code> before and after the content
- * is changed. A <code>TextChangingEvent</code> has to be sent to the
- * textChanging method before the content is changed and a
- * <code>TextChangedEvent</code> has to be sent to the textChanged method
- * after the content has changed.
- * The text change that occurs after the <code>TextChangingEvent</code>
- * has been sent has to be consistent with the data provided in the
- * <code>TextChangingEvent</code>.
- * This data will be cached by the widget and will be used when the
- * <code>TextChangedEvent</code> is received.
- * <p>
- * The <code>TextChangingEvent</code> should be set as follows:
- * <ul>
- * <li>event.start = start of the replaced text
- * <li>event.newText = text that is going to be inserted or empty String
- * if no text will be inserted
- * <li>event.replaceCharCount = length of text that is going to be replaced
- * <li>event.newCharCount = length of text that is going to be inserted
- * <li>event.replaceLineCount = number of lines that are going to be replaced
- * <li>event.newLineCount = number of new lines that are going to be inserted
- * </ul>
- * <b>NOTE:</b> newLineCount is the number of inserted lines and replaceLineCount
- * is the number of deleted lines based on the change that occurs visually.
- * For example:
- * <ul>
- * <li>(replaceText, newText) ==> (replaceLineCount, newLineCount)
- * <li>("", "\n") ==> (0, 1)
- * <li>("\n\n", "a") ==> (2, 0)
- * <li>("a", "\n\n") ==> (0, 2)
- * <li>("\n", "") ==> (1, 0)
- * </ul>
- * </p>
- *
- * @param start start offset of text to replace, none of the offsets include
- * delimiters of 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
- * @see TextChangeListener
- */
-public void replaceTextRange(int start, int replaceLength, String text);
-
-/**
- * Set text to "text".
- * Implementors have to send a <code>TextChangedEvent</code> to the
- * textSet method of the TextChangeListeners that were added using
- * <code>addTextChangeListener</code>.
- * <p>
- *
- * @param text the new text
- * @see TextChangeListener
- */
-public void setText(String text);
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+/**
+ * Clients may implement the StyledTextContent interface to provide a
+ * custom store for the StyledText widget content. The StyledText widget
+ * interacts with its StyledTextContent in order to access and update
+ * the text that is being displayed and edited in the widget.
+ * A custom content implementation can be set in the widget using the
+ * StyledText.setContent API.
+ */
+public interface StyledTextContent {
+
+/**
+ * Called by StyledText to add itself as an Observer to content changes.
+ * See TextChangeListener for a description of the listener methods that
+ * are called when text changes occur.
+ * <p>
+ *
+ * @param listener the listener
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT when listener is null</li>
+ * </ul>
+ */
+public void addTextChangeListener(TextChangeListener listener);
+
+/**
+ * Return the number of characters in the content.
+ * <p>
+ *
+ * @return the number of characters in the content.
+ */
+public int getCharCount();
+
+/**
+ * Return the line at the given line index without delimiters.
+ * <p>
+ *
+ * @param lineIndex index of the line to return. Does not include
+ * delimiters of preceeding lines. Index 0 is the first line of the
+ * content.
+ * @return the line text without delimiters
+ */
+public String getLine(int lineIndex);
+
+/**
+ * Return the line index at the given character offset.
+ * <p>
+ *
+ * @param offset offset of the line to return. The first character of the
+ * document is at offset 0. An offset of getLength() is valid and should
+ * answer the number of lines.
+ * @return the line index. The first line is at index 0. If the character
+ * at offset is a delimiter character, answer the line index of the line
+ * that is delimited.
+ * For example, if text = "\r\n\r\n", and delimiter = "\r\n", then:
+ * <ul>
+ * <li>getLineAtOffset(0) == 0
+ * <li>getLineAtOffset(1) == 0
+ * <li>getLineAtOffset(2) == 1
+ * <li>getLineAtOffset(3) == 1
+ * <li>getLineAtOffset(4) == 2
+ * </ul>
+ */
+public int getLineAtOffset(int offset);
+
+/**
+ * Return the number of lines. Should answer 1 when no text is specified.
+ * The StyledText widget relies on this behavior for drawing the cursor.
+ * <p>
+ *
+ * @return the number of lines. For example:
+ * <ul>
+ * <li> text value ==> getLineCount
+ * <li> null ==> 1
+ * <li> "" ==> 1
+ * <li> "a\n" ==> 2
+ * <li> "\n\n" ==> 3
+ * </ul>
+ */
+public int getLineCount();
+
+/**
+ * Return the line delimiter that should be used by the StyledText
+ * widget when inserting new lines. New lines entered using key strokes
+ * and paste operations use this line delimiter.
+ * Implementors may use System.getProperty("line.separator") to return
+ * the platform line delimiter.
+ * <p>
+ *
+ * @return the line delimiter that should be used by the StyledText widget
+ * when inserting new lines.
+ */
+public String getLineDelimiter();
+
+/**
+ * Return the character offset of the first character of the given line.
+ * <p>
+ * <b>NOTE:</b> When there is no text (i.e., no lines), getOffsetAtLine(0)
+ * is a valid call that should return 0.
+ * </p>
+ *
+ * @param lineIndex index of the line. The first line is at index 0.
+ * @return offset offset of the first character of the line. The first
+ * character of the document is at offset 0. The return value should
+ * include line delimiters.
+ * For example, if text = "\r\ntest\r\n" and delimiter = "\r\n", then:
+ * <ul>
+ * <li>getOffsetAtLine(0) == 0
+ * <li>getOffsetAtLine(1) == 2
+ * <li>getOffsetAtLine(2) == 8
+ * </ul>
+ */
+public int getOffsetAtLine(int lineIndex);
+
+/**
+ * Returns a string representing the content at the given range.
+ * <p>
+ *
+ * @param start the start offset of the text to return. Offset 0 is the
+ * first character of the document.
+ * @param length the length of the text to return
+ * @return the text at the given range
+ */
+public String getTextRange(int start, int length);
+
+/**
+ * Remove the specified text changed listener.
+ * <p>
+ *
+ * @param listener the listener
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT when listener is null</li>
+ * </ul>
+ */
+public void removeTextChangeListener(TextChangeListener listener);
+
+/**
+ * Replace the text with "newText" starting at position "start"
+ * for a length of "replaceLength".
+ * <p>
+ * Implementors have to notify the TextChangeListeners that were added
+ * using <code>addTextChangeListener</code> before and after the content
+ * is changed. A <code>TextChangingEvent</code> has to be sent to the
+ * textChanging method before the content is changed and a
+ * <code>TextChangedEvent</code> has to be sent to the textChanged method
+ * after the content has changed.
+ * The text change that occurs after the <code>TextChangingEvent</code>
+ * has been sent has to be consistent with the data provided in the
+ * <code>TextChangingEvent</code>.
+ * This data will be cached by the widget and will be used when the
+ * <code>TextChangedEvent</code> is received.
+ * <p>
+ * The <code>TextChangingEvent</code> should be set as follows:
+ * <ul>
+ * <li>event.start = start of the replaced text
+ * <li>event.newText = text that is going to be inserted or empty String
+ * if no text will be inserted
+ * <li>event.replaceCharCount = length of text that is going to be replaced
+ * <li>event.newCharCount = length of text that is going to be inserted
+ * <li>event.replaceLineCount = number of lines that are going to be replaced
+ * <li>event.newLineCount = number of new lines that are going to be inserted
+ * </ul>
+ * <b>NOTE:</b> newLineCount is the number of inserted lines and replaceLineCount
+ * is the number of deleted lines based on the change that occurs visually.
+ * For example:
+ * <ul>
+ * <li>(replaceText, newText) ==> (replaceLineCount, newLineCount)
+ * <li>("", "\n") ==> (0, 1)
+ * <li>("\n\n", "a") ==> (2, 0)
+ * <li>("a", "\n\n") ==> (0, 2)
+ * <li>("\n", "") ==> (1, 0)
+ * </ul>
+ * </p>
+ *
+ * @param start start offset of text to replace, none of the offsets include
+ * delimiters of 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
+ * @see TextChangeListener
+ */
+public void replaceTextRange(int start, int replaceLength, String text);
+
+/**
+ * Set text to "text".
+ * Implementors have to send a <code>TextChangedEvent</code> to the
+ * textSet method of the TextChangeListeners that were added using
+ * <code>addTextChangeListener</code>.
+ * <p>
+ *
+ * @param text the new text
+ * @see TextChangeListener
+ */
+public void setText(String text);
}
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
index 8011bbfda8..8e4b598347 100755
--- 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
@@ -1,34 +1,34 @@
-package org.eclipse.swt.custom;
-/*
+package org.eclipse.swt.custom;
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-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 BidiSegmentEvent
- int[] segments;
- // used by TextChangedEvent
- int replaceCharCount;
- int newCharCount;
- int replaceLineCount;
- int newLineCount;
-
-StyledTextEvent (StyledTextContent content) {
- super();
- data = content;
-}
-}
-
-
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+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 BidiSegmentEvent
+ int[] segments;
+ // used by TextChangedEvent
+ int replaceCharCount;
+ int newCharCount;
+ int replaceLineCount;
+ 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
index 5f156af93a..825f546992 100755
--- 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
@@ -1,73 +1,73 @@
-package org.eclipse.swt.custom;
-/*
+package org.eclipse.swt.custom;
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-import org.eclipse.swt.events.*;
-import org.eclipse.swt.widgets.*;
-import org.eclipse.swt.internal.SWTEventListener;
-
-class StyledTextListener extends TypedListener {
-/**
- */
-StyledTextListener(SWTEventListener listener) {
- super(listener);
-}
-/**
- * Process StyledText events by invoking the event's handler.
- */
-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.LineGetBackground:
- LineBackgroundEvent lineBgEvent = new LineBackgroundEvent((StyledTextEvent) e);
- ((LineBackgroundListener) eventListener).lineGetBackground(lineBgEvent);
- ((StyledTextEvent) e).lineBackground = lineBgEvent.lineBackground;
- break;
-
- case StyledText.LineGetSegments:
- BidiSegmentEvent segmentEvent = new BidiSegmentEvent((StyledTextEvent) e);
- ((BidiSegmentListener) eventListener).lineGetSegments(segmentEvent);
- ((StyledTextEvent) e).segments = segmentEvent.segments;
- break;
-
- case StyledText.LineGetStyle:
- LineStyleEvent lineStyleEvent = new LineStyleEvent((StyledTextEvent) e);
- ((LineStyleListener) eventListener).lineGetStyle(lineStyleEvent);
- ((StyledTextEvent) e).styles = lineStyleEvent.styles;
- break;
-
- case StyledText.VerifyKey:
- VerifyEvent verifyEvent = new VerifyEvent(e);
- ((VerifyKeyListener) eventListener).verifyKey(verifyEvent);
- e.doit = verifyEvent.doit;
- break;
-
- case StyledText.TextChanged:
- textChangedEvent = new TextChangedEvent((StyledTextContent) e.data);
- ((TextChangeListener) eventListener).textChanged(textChangedEvent);
- break;
-
- case StyledText.TextChanging:
- TextChangingEvent textChangingEvent = new TextChangingEvent((StyledTextContent) e.data, (StyledTextEvent) e);
- ((TextChangeListener) eventListener).textChanging(textChangingEvent);
- break;
-
- case StyledText.TextSet:
- textChangedEvent = new TextChangedEvent((StyledTextContent) e.data);
- ((TextChangeListener) eventListener).textSet(textChangedEvent);
- break;
- }
-}
-}
-
-
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+import org.eclipse.swt.events.*;
+import org.eclipse.swt.widgets.*;
+import org.eclipse.swt.internal.SWTEventListener;
+
+class StyledTextListener extends TypedListener {
+/**
+ */
+StyledTextListener(SWTEventListener listener) {
+ super(listener);
+}
+/**
+ * Process StyledText events by invoking the event's handler.
+ */
+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.LineGetBackground:
+ LineBackgroundEvent lineBgEvent = new LineBackgroundEvent((StyledTextEvent) e);
+ ((LineBackgroundListener) eventListener).lineGetBackground(lineBgEvent);
+ ((StyledTextEvent) e).lineBackground = lineBgEvent.lineBackground;
+ break;
+
+ case StyledText.LineGetSegments:
+ BidiSegmentEvent segmentEvent = new BidiSegmentEvent((StyledTextEvent) e);
+ ((BidiSegmentListener) eventListener).lineGetSegments(segmentEvent);
+ ((StyledTextEvent) e).segments = segmentEvent.segments;
+ break;
+
+ case StyledText.LineGetStyle:
+ LineStyleEvent lineStyleEvent = new LineStyleEvent((StyledTextEvent) e);
+ ((LineStyleListener) eventListener).lineGetStyle(lineStyleEvent);
+ ((StyledTextEvent) e).styles = lineStyleEvent.styles;
+ break;
+
+ case StyledText.VerifyKey:
+ VerifyEvent verifyEvent = new VerifyEvent(e);
+ ((VerifyKeyListener) eventListener).verifyKey(verifyEvent);
+ e.doit = verifyEvent.doit;
+ break;
+
+ case StyledText.TextChanged:
+ textChangedEvent = new TextChangedEvent((StyledTextContent) e.data);
+ ((TextChangeListener) eventListener).textChanged(textChangedEvent);
+ break;
+
+ case StyledText.TextChanging:
+ TextChangingEvent textChangingEvent = new TextChangingEvent((StyledTextContent) e.data, (StyledTextEvent) e);
+ ((TextChangeListener) eventListener).textChanging(textChangingEvent);
+ break;
+
+ case StyledText.TextSet:
+ textChangedEvent = new TextChangedEvent((StyledTextContent) e.data);
+ ((TextChangeListener) eventListener).textSet(textChangedEvent);
+ break;
+ }
+}
+}
+
+
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/TableCursor.java b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/TableCursor.java
index 8cd05e8a1f..6727675f61 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/TableCursor.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/TableCursor.java
@@ -1,515 +1,515 @@
-package org.eclipse.swt.custom;
-
-/*
+package org.eclipse.swt.custom;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-import org.eclipse.swt.*;
-import org.eclipse.swt.graphics.*;
-import org.eclipse.swt.widgets.*;
-import org.eclipse.swt.events.*;
-
-/**
- * A TableCursor provides a way for the user to navigate around a Table
- * using the keyboard. It also provides a mechanism for selecting an
- * individual cell in a table.
- *
- * <p> Here is an example of using a TableCursor to navigate to a cell and then edit it.
- *
- * <code><pre>
- * public static void main(String[] args) {
- * Display display = new Display();
- * Shell shell = new Shell(display);
- * shell.setLayout(new GridLayout());
- *
- * // create a a table with 3 columns and fill with data
- * final Table table = new Table(shell, SWT.BORDER | SWT.MULTI | SWT.FULL_SELECTION);
- * table.setLayoutData(new GridData(GridData.FILL_BOTH));
- * TableColumn column1 = new TableColumn(table, SWT.NONE);
- * TableColumn column2 = new TableColumn(table, SWT.NONE);
- * TableColumn column3 = new TableColumn(table, SWT.NONE);
- * for (int i = 0; i < 100; i++) {
- * TableItem item = new TableItem(table, SWT.NONE);
- * item.setText(new String[] { "cell "+i+" 0", "cell "+i+" 1", "cell "+i+" 2"});
- * }
- * column1.pack();
- * column2.pack();
- * column3.pack();
- *
- * // create a TableCursor to navigate around the table
- * final TableCursor cursor = new TableCursor(table, SWT.NONE);
- * // create an editor to edit the cell when the user hits "ENTER"
- * // while over a cell in the table
- * final ControlEditor editor = new ControlEditor(cursor);
- * editor.grabHorizontal = true;
- * editor.grabVertical = true;
- *
- * cursor.addSelectionListener(new SelectionAdapter() {
- * // when the TableEditor is over a cell, select the corresponding row in
- * // the table
- * public void widgetSelected(SelectionEvent e) {
- * table.setSelection(new TableItem[] {cursor.getRow()});
- * }
- * // when the user hits "ENTER" in the TableCursor, pop up a text editor so that
- * // they can change the text of the cell
- * public void widgetDefaultSelected(SelectionEvent e){
- * final Text text = new Text(cursor, SWT.NONE);
- * TableItem row = cursor.getRow();
- * int column = cursor.getColumn();
- * text.setText(row.getText(column));
- * text.addKeyListener(new KeyAdapter() {
- * public void keyPressed(KeyEvent e) {
- * // close the text editor and copy the data over
- * // when the user hits "ENTER"
- * if (e.character == SWT.CR) {
- * TableItem row = cursor.getRow();
- * int column = cursor.getColumn();
- * row.setText(column, text.getText());
- * text.dispose();
- * }
- * // close the text editor when the user hits "ESC"
- * if (e.character == SWT.ESC) {
- * text.dispose();
- * }
- * }
- * });
- * editor.setEditor(text);
- * text.setFocus();
- * }
- * });
- * // Hide the TableCursor when the user hits the "CTRL" or "SHIFT" key.
- * // This alows the user to select multiple items in the table.
- * cursor.addKeyListener(new KeyAdapter() {
- * public void keyPressed(KeyEvent e) {
- * if (e.keyCode == SWT.CTRL ||
- * e.keyCode == SWT.SHIFT ||
- * (e.stateMask & SWT.CONTROL) != 0 ||
- * (e.stateMask & SWT.SHIFT) != 0) {
- * cursor.setVisible(false);
- * }
- * }
- * });
- * // Show the TableCursor when the user releases the "SHIFT" or "CTRL" key.
- * // This signals the end of the multiple selection task.
- * table.addKeyListener(new KeyAdapter() {
- * public void keyReleased(KeyEvent e) {
- * if (e.keyCode == SWT.CONTROL && (e.stateMask & SWT.SHIFT) != 0) return;
- * if (e.keyCode == SWT.SHIFT && (e.stateMask & SWT.CONTROL) != 0) return;
- * if (e.keyCode != SWT.CONTROL && (e.stateMask & SWT.CONTROL) != 0) return;
- * if (e.keyCode != SWT.SHIFT && (e.stateMask & SWT.SHIFT) != 0) return;
- *
- * TableItem[] selection = table.getSelection();
- * TableItem row = (selection.length == 0) ? table.getItem(table.getTopIndex()) : selection[0];
- * table.showItem(row);
- * cursor.setSelection(row, 0);
- * cursor.setVisible(true);
- * cursor.setFocus();
- * }
- * });
- *
- * shell.open();
- * while (!shell.isDisposed()) {
- * if (!display.readAndDispatch())
- * display.sleep();
- * }
- * display.dispose();
- * }
- * </pre></code>
- *
- * <dl>
- * <dt><b>Styles:</b></dt>
- * <dd>BORDER</dd>
- * <dt><b>Events:</b></dt>
- * <dd>Selection, DefaultSelection</dd>
- * </dl>
- *
- * @since 2.0
- *
- */
-public class TableCursor extends Canvas {
- Table table;
- int row, column;
- Listener tableListener, resizeListener;
-
-/**
- * Constructs a new instance of this class given its parent
- * table and a style value describing its behavior and appearance.
- * <p>
- * The style value is either one of the style constants defined in
- * class <code>SWT</code> which is applicable to instances of this
- * class, or must be built by <em>bitwise OR</em>'ing together
- * (that is, using the <code>int</code> "|" operator) two or more
- * of those <code>SWT</code> style constants. The class description
- * lists the style constants that are applicable to the class.
- * Style bits are also inherited from superclasses.
- * </p>
- *
- * @param parent a Table control which will be the parent of the new instance (cannot be null)
- * @param style the style of control to construct
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
- * <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
- * </ul>
- *
- * @see SWT#BORDER
- * @see Widget#checkSubclass
- * @see Widget#getStyle
- */
-public TableCursor(Table parent, int style) {
- super(parent, style);
- table = parent;
- Listener listener = new Listener() {
- public void handleEvent(Event event) {
- switch (event.type) {
- case SWT.Dispose :
- dispose(event);
- break;
- case SWT.KeyDown :
- keyDown(event);
- break;
- case SWT.Paint :
- paint(event);
- break;
- case SWT.Traverse :
- traverse(event);
- break;
- }
- }
- };
- addListener(SWT.Dispose, listener);
- addListener(SWT.KeyDown, listener);
- addListener(SWT.Paint, listener);
- addListener(SWT.Traverse, listener);
-
- tableListener = new Listener() {
- public void handleEvent(Event event) {
- switch (event.type) {
- case SWT.MouseDown :
- tableMouseDown(event);
- break;
- case SWT.FocusIn :
- tableFocusIn(event);
- break;
- }
- }
- };
- table.addListener(SWT.FocusIn, tableListener);
- table.addListener(SWT.MouseDown, tableListener);
-
- resizeListener = new Listener() {
- public void handleEvent(Event event) {
- resize();
- }
- };
- int columns = table.getColumnCount();
- for (int i = 0; i < columns; i++) {
- TableColumn column = table.getColumn(i);
- column.addListener(SWT.Resize, resizeListener);
- }
- ScrollBar hBar = table.getHorizontalBar();
- if (hBar != null) {
- hBar.addListener(SWT.Selection, resizeListener);
- }
- ScrollBar vBar = table.getVerticalBar();
- if (vBar != null) {
- vBar.addListener(SWT.Selection, resizeListener);
- }
-}
-
-/**
- * Adds the listener to the collection of listeners who will
- * be notified when the receiver's selection changes, by sending
- * it one of the messages defined in the <code>SelectionListener</code>
- * interface.
- * <p>
- * When <code>widgetSelected</code> is called, the item field of the event object is valid.
- * If the reciever has <code>SWT.CHECK</code> style set and the check selection changes,
- * the event object detail field contains the value <code>SWT.CHECK</code>.
- * <code>widgetDefaultSelected</code> is typically called when an item is double-clicked.
- * </p>
- *
- * @param listener the listener which should be notified
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see SelectionListener
- * @see #removeSelectionListener
- * @see SelectionEvent
- */
-public void addSelectionListener(SelectionListener listener) {
- checkWidget();
- if (listener == null)
- SWT.error(SWT.ERROR_NULL_ARGUMENT);
- TypedListener typedListener = new TypedListener(listener);
- addListener(SWT.Selection, typedListener);
- addListener(SWT.DefaultSelection, typedListener);
-}
-
-void dispose(Event event) {
- Display display = getDisplay();
- display.asyncExec(new Runnable() {
- public void run() {
- if (table.isDisposed())
- return;
- table.removeListener(SWT.FocusIn, tableListener);
- table.removeListener(SWT.MouseDown, tableListener);
- int columns = table.getColumnCount();
- for (int i = 0; i < columns; i++) {
- TableColumn column = table.getColumn(i);
- column.removeListener(SWT.Resize, resizeListener);
- }
- ScrollBar hBar = table.getHorizontalBar();
- if (hBar != null) {
- hBar.removeListener(SWT.Selection, resizeListener);
- }
- ScrollBar vBar = table.getVerticalBar();
- if (vBar != null) {
- vBar.removeListener(SWT.Selection, resizeListener);
- }
- }
- });
-}
-
-void keyDown(Event event) {
- switch (event.character) {
- case SWT.CR :
- notifyListeners(SWT.DefaultSelection, new Event());
- return;
- }
- switch (event.keyCode) {
- case SWT.ARROW_UP :
- setRowColumn(row - 1, column, true);
- break;
- case SWT.ARROW_DOWN :
- setRowColumn(row + 1, column, true);
- break;
- case SWT.ARROW_LEFT :
- setRowColumn(row, column - 1, true);
- break;
- case SWT.ARROW_RIGHT :
- setRowColumn(row, column + 1, true);
- break;
- case SWT.HOME :
- setRowColumn(0, column, true);
- break;
- case SWT.END :
- {
- int row = table.getItemCount() - 1;
- setRowColumn(row, column, true);
- break;
- }
- case SWT.PAGE_UP :
- {
- int index = table.getTopIndex();
- if (index == row) {
- Rectangle rect = table.getClientArea();
- TableItem item = table.getItem(index);
- Rectangle itemRect = item.getBounds(0);
- rect.height -= itemRect.y;
- int height = table.getItemHeight();
- int page = Math.max(1, rect.height / height);
- index = Math.max(0, index - page + 1);
- }
- setRowColumn(index, column, true);
- break;
- }
- case SWT.PAGE_DOWN :
- {
- int index = table.getTopIndex();
- Rectangle rect = table.getClientArea();
- TableItem item = table.getItem(index);
- Rectangle itemRect = item.getBounds(0);
- rect.height -= itemRect.y;
- int height = table.getItemHeight();
- int page = Math.max(1, rect.height / height);
- int end = table.getItemCount() - 1;
- index = Math.min(end, index + page - 1);
- if (index == row) {
- index = Math.min(end, index + page - 1);
- }
- setRowColumn(index, column, true);
- break;
- }
- }
-}
-
-void paint(Event event) {
- GC gc = event.gc;
- Display display = getDisplay();
- gc.setBackground(display.getSystemColor(SWT.COLOR_LIST_SELECTION_TEXT));
- gc.setForeground(display.getSystemColor(SWT.COLOR_LIST_SELECTION));
- gc.fillRectangle(event.x, event.y, event.width, event.height);
- TableItem item = table.getItem(row);
- int x = 0, y = 0;
- Point size = getSize();
- Image image = item.getImage(column);
- if (image != null) {
- Rectangle imageSize = image.getBounds();
- int imageY = y + (int) (((float) size.y - (float) imageSize.height) / 2.0);
- gc.drawImage(image, x, imageY);
- x += imageSize.width;
- }
- x += (column == 0) ? 2 : 6;
-
- int textY =
- y + (int) (((float) size.y - (float) gc.getFontMetrics().getHeight()) / 2.0);
- gc.drawString(item.getText(column), x, textY);
- if (isFocusControl()) {
- gc.setBackground(display.getSystemColor(SWT.COLOR_BLACK));
- gc.setForeground(display.getSystemColor(SWT.COLOR_WHITE));
- gc.drawFocus(0, 0, size.x, size.y);
- }
-
-}
-
-void tableFocusIn(Event event) {
- if (isDisposed())
- return;
- if (isVisible())
- setFocus();
-}
-
-void tableMouseDown(Event event) {
- if (isDisposed() || !isVisible())
- return;
- Point pt = new Point(event.x, event.y);
- Rectangle clientRect = table.getClientArea();
- int columns = table.getColumnCount();
- int start = table.getTopIndex();
- int end = table.getItemCount();
- for (int row = start; row < end; row++) {
- TableItem item = table.getItem(row);
- for (int column = 0; column < columns; column++) {
- Rectangle rect = item.getBounds(column);
- if (rect.y > clientRect.y + clientRect.height)
- return;
- if (rect.contains(pt)) {
- setRowColumn(row, column, true);
- setFocus();
- return;
- }
- }
- }
-}
-
-void traverse(Event event) {
- switch (event.detail) {
- case SWT.TRAVERSE_ARROW_NEXT :
- case SWT.TRAVERSE_ARROW_PREVIOUS :
- case SWT.TRAVERSE_RETURN :
- event.doit = false;
- return;
- }
- event.doit = true;
-}
-
-void setRowColumn(int row, int column, boolean notify) {
- if (0 <= row && row < table.getItemCount()) {
- if (0 <= column && column < table.getColumnCount()) {
- this.row = row;
- this.column = column;
- TableItem item = table.getItem(row);
- table.showItem(item);
- setBounds(item.getBounds(column));
- redraw();
- if (notify) {
- notifyListeners(SWT.Selection, new Event());
- }
- }
- }
-}
-
-public void setVisible(boolean visible) {
- checkWidget();
- if (visible)
- resize();
- super.setVisible(visible);
-}
-
-void resize() {
- TableItem item = table.getItem(row);
- setBounds(item.getBounds(column));
-}
-/**
- * Returns the column over which the TableCursor is positioned.
- *
- * @return the column for the current position
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public int getColumn() {
- checkWidget();
- return column;
-}
-/**
- * Returns the row over which the TableCursor is positioned.
- *
- * @return the item for the current position
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public TableItem getRow() {
- checkWidget();
- return table.getItem(row);
-}
-/**
- * Positions the TableCursor over the cell at the given row and column in the parent table.
- *
- * @param row the index of the row for the cell to select
- * @param column the index of column for the cell to select
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- */
-public void setSelection(int row, int column) {
- checkWidget();
- if (row < 0
- || row >= table.getItemCount()
- || column < 0
- || column >= table.getColumnCount())
- SWT.error(SWT.ERROR_INVALID_ARGUMENT);
- setRowColumn(row, column, false);
-}
-/**
- * Positions the TableCursor over the cell at the given row and column in the parent table.
- *
- * @param row the TableItem of the row for the cell to select
- * @param column the index of column for the cell to select
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- */
-public void setSelection(TableItem row, int column) {
- checkWidget();
- if (row == null
- || row.isDisposed()
- || column < 0
- || column >= table.getColumnCount())
- SWT.error(SWT.ERROR_INVALID_ARGUMENT);
- setRowColumn(table.indexOf(row), column, false);
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+import org.eclipse.swt.*;
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.widgets.*;
+import org.eclipse.swt.events.*;
+
+/**
+ * A TableCursor provides a way for the user to navigate around a Table
+ * using the keyboard. It also provides a mechanism for selecting an
+ * individual cell in a table.
+ *
+ * <p> Here is an example of using a TableCursor to navigate to a cell and then edit it.
+ *
+ * <code><pre>
+ * public static void main(String[] args) {
+ * Display display = new Display();
+ * Shell shell = new Shell(display);
+ * shell.setLayout(new GridLayout());
+ *
+ * // create a a table with 3 columns and fill with data
+ * final Table table = new Table(shell, SWT.BORDER | SWT.MULTI | SWT.FULL_SELECTION);
+ * table.setLayoutData(new GridData(GridData.FILL_BOTH));
+ * TableColumn column1 = new TableColumn(table, SWT.NONE);
+ * TableColumn column2 = new TableColumn(table, SWT.NONE);
+ * TableColumn column3 = new TableColumn(table, SWT.NONE);
+ * for (int i = 0; i < 100; i++) {
+ * TableItem item = new TableItem(table, SWT.NONE);
+ * item.setText(new String[] { "cell "+i+" 0", "cell "+i+" 1", "cell "+i+" 2"});
+ * }
+ * column1.pack();
+ * column2.pack();
+ * column3.pack();
+ *
+ * // create a TableCursor to navigate around the table
+ * final TableCursor cursor = new TableCursor(table, SWT.NONE);
+ * // create an editor to edit the cell when the user hits "ENTER"
+ * // while over a cell in the table
+ * final ControlEditor editor = new ControlEditor(cursor);
+ * editor.grabHorizontal = true;
+ * editor.grabVertical = true;
+ *
+ * cursor.addSelectionListener(new SelectionAdapter() {
+ * // when the TableEditor is over a cell, select the corresponding row in
+ * // the table
+ * public void widgetSelected(SelectionEvent e) {
+ * table.setSelection(new TableItem[] {cursor.getRow()});
+ * }
+ * // when the user hits "ENTER" in the TableCursor, pop up a text editor so that
+ * // they can change the text of the cell
+ * public void widgetDefaultSelected(SelectionEvent e){
+ * final Text text = new Text(cursor, SWT.NONE);
+ * TableItem row = cursor.getRow();
+ * int column = cursor.getColumn();
+ * text.setText(row.getText(column));
+ * text.addKeyListener(new KeyAdapter() {
+ * public void keyPressed(KeyEvent e) {
+ * // close the text editor and copy the data over
+ * // when the user hits "ENTER"
+ * if (e.character == SWT.CR) {
+ * TableItem row = cursor.getRow();
+ * int column = cursor.getColumn();
+ * row.setText(column, text.getText());
+ * text.dispose();
+ * }
+ * // close the text editor when the user hits "ESC"
+ * if (e.character == SWT.ESC) {
+ * text.dispose();
+ * }
+ * }
+ * });
+ * editor.setEditor(text);
+ * text.setFocus();
+ * }
+ * });
+ * // Hide the TableCursor when the user hits the "CTRL" or "SHIFT" key.
+ * // This alows the user to select multiple items in the table.
+ * cursor.addKeyListener(new KeyAdapter() {
+ * public void keyPressed(KeyEvent e) {
+ * if (e.keyCode == SWT.CTRL ||
+ * e.keyCode == SWT.SHIFT ||
+ * (e.stateMask & SWT.CONTROL) != 0 ||
+ * (e.stateMask & SWT.SHIFT) != 0) {
+ * cursor.setVisible(false);
+ * }
+ * }
+ * });
+ * // Show the TableCursor when the user releases the "SHIFT" or "CTRL" key.
+ * // This signals the end of the multiple selection task.
+ * table.addKeyListener(new KeyAdapter() {
+ * public void keyReleased(KeyEvent e) {
+ * if (e.keyCode == SWT.CONTROL && (e.stateMask & SWT.SHIFT) != 0) return;
+ * if (e.keyCode == SWT.SHIFT && (e.stateMask & SWT.CONTROL) != 0) return;
+ * if (e.keyCode != SWT.CONTROL && (e.stateMask & SWT.CONTROL) != 0) return;
+ * if (e.keyCode != SWT.SHIFT && (e.stateMask & SWT.SHIFT) != 0) return;
+ *
+ * TableItem[] selection = table.getSelection();
+ * TableItem row = (selection.length == 0) ? table.getItem(table.getTopIndex()) : selection[0];
+ * table.showItem(row);
+ * cursor.setSelection(row, 0);
+ * cursor.setVisible(true);
+ * cursor.setFocus();
+ * }
+ * });
+ *
+ * shell.open();
+ * while (!shell.isDisposed()) {
+ * if (!display.readAndDispatch())
+ * display.sleep();
+ * }
+ * display.dispose();
+ * }
+ * </pre></code>
+ *
+ * <dl>
+ * <dt><b>Styles:</b></dt>
+ * <dd>BORDER</dd>
+ * <dt><b>Events:</b></dt>
+ * <dd>Selection, DefaultSelection</dd>
+ * </dl>
+ *
+ * @since 2.0
+ *
+ */
+public class TableCursor extends Canvas {
+ Table table;
+ int row, column;
+ Listener tableListener, resizeListener;
+
+/**
+ * Constructs a new instance of this class given its parent
+ * table and a style value describing its behavior and appearance.
+ * <p>
+ * The style value is either one of the style constants defined in
+ * class <code>SWT</code> which is applicable to instances of this
+ * class, or must be built by <em>bitwise OR</em>'ing together
+ * (that is, using the <code>int</code> "|" operator) two or more
+ * of those <code>SWT</code> style constants. The class description
+ * lists the style constants that are applicable to the class.
+ * Style bits are also inherited from superclasses.
+ * </p>
+ *
+ * @param parent a Table control which will be the parent of the new instance (cannot be null)
+ * @param style the style of control to construct
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
+ * <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
+ * </ul>
+ *
+ * @see SWT#BORDER
+ * @see Widget#checkSubclass
+ * @see Widget#getStyle
+ */
+public TableCursor(Table parent, int style) {
+ super(parent, style);
+ table = parent;
+ Listener listener = new Listener() {
+ public void handleEvent(Event event) {
+ switch (event.type) {
+ case SWT.Dispose :
+ dispose(event);
+ break;
+ case SWT.KeyDown :
+ keyDown(event);
+ break;
+ case SWT.Paint :
+ paint(event);
+ break;
+ case SWT.Traverse :
+ traverse(event);
+ break;
+ }
+ }
+ };
+ addListener(SWT.Dispose, listener);
+ addListener(SWT.KeyDown, listener);
+ addListener(SWT.Paint, listener);
+ addListener(SWT.Traverse, listener);
+
+ tableListener = new Listener() {
+ public void handleEvent(Event event) {
+ switch (event.type) {
+ case SWT.MouseDown :
+ tableMouseDown(event);
+ break;
+ case SWT.FocusIn :
+ tableFocusIn(event);
+ break;
+ }
+ }
+ };
+ table.addListener(SWT.FocusIn, tableListener);
+ table.addListener(SWT.MouseDown, tableListener);
+
+ resizeListener = new Listener() {
+ public void handleEvent(Event event) {
+ resize();
+ }
+ };
+ int columns = table.getColumnCount();
+ for (int i = 0; i < columns; i++) {
+ TableColumn column = table.getColumn(i);
+ column.addListener(SWT.Resize, resizeListener);
+ }
+ ScrollBar hBar = table.getHorizontalBar();
+ if (hBar != null) {
+ hBar.addListener(SWT.Selection, resizeListener);
+ }
+ ScrollBar vBar = table.getVerticalBar();
+ if (vBar != null) {
+ vBar.addListener(SWT.Selection, resizeListener);
+ }
+}
+
+/**
+ * Adds the listener to the collection of listeners who will
+ * be notified when the receiver's selection changes, by sending
+ * it one of the messages defined in the <code>SelectionListener</code>
+ * interface.
+ * <p>
+ * When <code>widgetSelected</code> is called, the item field of the event object is valid.
+ * If the reciever has <code>SWT.CHECK</code> style set and the check selection changes,
+ * the event object detail field contains the value <code>SWT.CHECK</code>.
+ * <code>widgetDefaultSelected</code> is typically called when an item is double-clicked.
+ * </p>
+ *
+ * @param listener the listener which should be notified
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see SelectionListener
+ * @see #removeSelectionListener
+ * @see SelectionEvent
+ */
+public void addSelectionListener(SelectionListener listener) {
+ checkWidget();
+ if (listener == null)
+ SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ TypedListener typedListener = new TypedListener(listener);
+ addListener(SWT.Selection, typedListener);
+ addListener(SWT.DefaultSelection, typedListener);
+}
+
+void dispose(Event event) {
+ Display display = getDisplay();
+ display.asyncExec(new Runnable() {
+ public void run() {
+ if (table.isDisposed())
+ return;
+ table.removeListener(SWT.FocusIn, tableListener);
+ table.removeListener(SWT.MouseDown, tableListener);
+ int columns = table.getColumnCount();
+ for (int i = 0; i < columns; i++) {
+ TableColumn column = table.getColumn(i);
+ column.removeListener(SWT.Resize, resizeListener);
+ }
+ ScrollBar hBar = table.getHorizontalBar();
+ if (hBar != null) {
+ hBar.removeListener(SWT.Selection, resizeListener);
+ }
+ ScrollBar vBar = table.getVerticalBar();
+ if (vBar != null) {
+ vBar.removeListener(SWT.Selection, resizeListener);
+ }
+ }
+ });
+}
+
+void keyDown(Event event) {
+ switch (event.character) {
+ case SWT.CR :
+ notifyListeners(SWT.DefaultSelection, new Event());
+ return;
+ }
+ switch (event.keyCode) {
+ case SWT.ARROW_UP :
+ setRowColumn(row - 1, column, true);
+ break;
+ case SWT.ARROW_DOWN :
+ setRowColumn(row + 1, column, true);
+ break;
+ case SWT.ARROW_LEFT :
+ setRowColumn(row, column - 1, true);
+ break;
+ case SWT.ARROW_RIGHT :
+ setRowColumn(row, column + 1, true);
+ break;
+ case SWT.HOME :
+ setRowColumn(0, column, true);
+ break;
+ case SWT.END :
+ {
+ int row = table.getItemCount() - 1;
+ setRowColumn(row, column, true);
+ break;
+ }
+ case SWT.PAGE_UP :
+ {
+ int index = table.getTopIndex();
+ if (index == row) {
+ Rectangle rect = table.getClientArea();
+ TableItem item = table.getItem(index);
+ Rectangle itemRect = item.getBounds(0);
+ rect.height -= itemRect.y;
+ int height = table.getItemHeight();
+ int page = Math.max(1, rect.height / height);
+ index = Math.max(0, index - page + 1);
+ }
+ setRowColumn(index, column, true);
+ break;
+ }
+ case SWT.PAGE_DOWN :
+ {
+ int index = table.getTopIndex();
+ Rectangle rect = table.getClientArea();
+ TableItem item = table.getItem(index);
+ Rectangle itemRect = item.getBounds(0);
+ rect.height -= itemRect.y;
+ int height = table.getItemHeight();
+ int page = Math.max(1, rect.height / height);
+ int end = table.getItemCount() - 1;
+ index = Math.min(end, index + page - 1);
+ if (index == row) {
+ index = Math.min(end, index + page - 1);
+ }
+ setRowColumn(index, column, true);
+ break;
+ }
+ }
+}
+
+void paint(Event event) {
+ GC gc = event.gc;
+ Display display = getDisplay();
+ gc.setBackground(display.getSystemColor(SWT.COLOR_LIST_SELECTION_TEXT));
+ gc.setForeground(display.getSystemColor(SWT.COLOR_LIST_SELECTION));
+ gc.fillRectangle(event.x, event.y, event.width, event.height);
+ TableItem item = table.getItem(row);
+ int x = 0, y = 0;
+ Point size = getSize();
+ Image image = item.getImage(column);
+ if (image != null) {
+ Rectangle imageSize = image.getBounds();
+ int imageY = y + (int) (((float) size.y - (float) imageSize.height) / 2.0);
+ gc.drawImage(image, x, imageY);
+ x += imageSize.width;
+ }
+ x += (column == 0) ? 2 : 6;
+
+ int textY =
+ y + (int) (((float) size.y - (float) gc.getFontMetrics().getHeight()) / 2.0);
+ gc.drawString(item.getText(column), x, textY);
+ if (isFocusControl()) {
+ gc.setBackground(display.getSystemColor(SWT.COLOR_BLACK));
+ gc.setForeground(display.getSystemColor(SWT.COLOR_WHITE));
+ gc.drawFocus(0, 0, size.x, size.y);
+ }
+
+}
+
+void tableFocusIn(Event event) {
+ if (isDisposed())
+ return;
+ if (isVisible())
+ setFocus();
+}
+
+void tableMouseDown(Event event) {
+ if (isDisposed() || !isVisible())
+ return;
+ Point pt = new Point(event.x, event.y);
+ Rectangle clientRect = table.getClientArea();
+ int columns = table.getColumnCount();
+ int start = table.getTopIndex();
+ int end = table.getItemCount();
+ for (int row = start; row < end; row++) {
+ TableItem item = table.getItem(row);
+ for (int column = 0; column < columns; column++) {
+ Rectangle rect = item.getBounds(column);
+ if (rect.y > clientRect.y + clientRect.height)
+ return;
+ if (rect.contains(pt)) {
+ setRowColumn(row, column, true);
+ setFocus();
+ return;
+ }
+ }
+ }
+}
+
+void traverse(Event event) {
+ switch (event.detail) {
+ case SWT.TRAVERSE_ARROW_NEXT :
+ case SWT.TRAVERSE_ARROW_PREVIOUS :
+ case SWT.TRAVERSE_RETURN :
+ event.doit = false;
+ return;
+ }
+ event.doit = true;
+}
+
+void setRowColumn(int row, int column, boolean notify) {
+ if (0 <= row && row < table.getItemCount()) {
+ if (0 <= column && column < table.getColumnCount()) {
+ this.row = row;
+ this.column = column;
+ TableItem item = table.getItem(row);
+ table.showItem(item);
+ setBounds(item.getBounds(column));
+ redraw();
+ if (notify) {
+ notifyListeners(SWT.Selection, new Event());
+ }
+ }
+ }
+}
+
+public void setVisible(boolean visible) {
+ checkWidget();
+ if (visible)
+ resize();
+ super.setVisible(visible);
+}
+
+void resize() {
+ TableItem item = table.getItem(row);
+ setBounds(item.getBounds(column));
+}
+/**
+ * Returns the column over which the TableCursor is positioned.
+ *
+ * @return the column for the current position
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public int getColumn() {
+ checkWidget();
+ return column;
+}
+/**
+ * Returns the row over which the TableCursor is positioned.
+ *
+ * @return the item for the current position
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public TableItem getRow() {
+ checkWidget();
+ return table.getItem(row);
+}
+/**
+ * Positions the TableCursor over the cell at the given row and column in the parent table.
+ *
+ * @param row the index of the row for the cell to select
+ * @param column the index of column for the cell to select
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ */
+public void setSelection(int row, int column) {
+ checkWidget();
+ if (row < 0
+ || row >= table.getItemCount()
+ || column < 0
+ || column >= table.getColumnCount())
+ SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+ setRowColumn(row, column, false);
+}
+/**
+ * Positions the TableCursor over the cell at the given row and column in the parent table.
+ *
+ * @param row the TableItem of the row for the cell to select
+ * @param column the index of column for the cell to select
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ */
+public void setSelection(TableItem row, int column) {
+ checkWidget();
+ if (row == null
+ || row.isDisposed()
+ || column < 0
+ || column >= table.getColumnCount())
+ SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+ setRowColumn(table.indexOf(row), column, false);
+}
} \ No newline at end of file
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
index 4acff4524d..fd6a6c4eae 100755
--- 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
@@ -1,193 +1,193 @@
-package org.eclipse.swt.custom;
-
-/*
+package org.eclipse.swt.custom;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-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);
- }
- columnListener = null;
- 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;
-}
-/**
-* 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 setColumn(int column) {
-
- int columnCount = table.getColumnCount();
- // Separately handle the case where the table has no TableColumns.
- // In this situation, there is a single default column.
- if (columnCount == 0) {
- this.column = (column == 0) ? 0 : -1;
- resize();
- return;
- }
-
- if (this.column > -1 && this.column < columnCount){
- TableColumn tableColumn = table.getColumn(this.column);
- tableColumn.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);
- resize();
-}
-public void setItem (TableItem item) {
- this.item = item;
- resize();
-}
-
-/**
-* Specify the Control that is to be displayed and the cell in the table that it is to be positioned above.
-*
-* <p>Note: The Control provided as the editor <b>must</b> be created with its parent being the Table control
-* specified in the TableEditor constructor.
-*
-* @param editor the Control that is displayed above the cell being edited
-* @param item the TableItem for the row of the cell being tracked by this editor
-* @param column the zero based index of the column of the cell being tracked by this editor
-*/
-public void setEditor (Control editor, TableItem item, int column) {
- setItem(item);
- setColumn(column);
- setEditor(editor);
-}
-void resize () {
- if (table.isDisposed()) return;
- if (item == null || item.isDisposed()) return;
- int columnCount = table.getColumnCount();
- if (columnCount == 0 && column != 0) return;
- if (columnCount > 0 && (column < 0 || column >= columnCount)) return;
- super.resize();
-}
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+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);
+ }
+ columnListener = null;
+ 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;
+}
+/**
+* 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 setColumn(int column) {
+
+ int columnCount = table.getColumnCount();
+ // Separately handle the case where the table has no TableColumns.
+ // In this situation, there is a single default column.
+ if (columnCount == 0) {
+ this.column = (column == 0) ? 0 : -1;
+ resize();
+ return;
+ }
+
+ if (this.column > -1 && this.column < columnCount){
+ TableColumn tableColumn = table.getColumn(this.column);
+ tableColumn.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);
+ resize();
+}
+public void setItem (TableItem item) {
+ this.item = item;
+ resize();
+}
+
+/**
+* Specify the Control that is to be displayed and the cell in the table that it is to be positioned above.
+*
+* <p>Note: The Control provided as the editor <b>must</b> be created with its parent being the Table control
+* specified in the TableEditor constructor.
+*
+* @param editor the Control that is displayed above the cell being edited
+* @param item the TableItem for the row of the cell being tracked by this editor
+* @param column the zero based index of the column of the cell being tracked by this editor
+*/
+public void setEditor (Control editor, TableItem item, int column) {
+ setItem(item);
+ setColumn(column);
+ setEditor(editor);
+}
+void resize () {
+ if (table.isDisposed()) return;
+ if (item == null || item.isDisposed()) return;
+ int columnCount = table.getColumnCount();
+ if (columnCount == 0 && column != 0) return;
+ if (columnCount > 0 && (column < 0 || column >= columnCount)) return;
+ super.resize();
+}
+}
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
index b53097d7be..54244e3b1f 100755
--- 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
@@ -1,742 +1,742 @@
-package org.eclipse.swt.custom;
-
-/*
+package org.eclipse.swt.custom;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-import org.eclipse.swt.*;
-import org.eclipse.swt.events.*;
-import org.eclipse.swt.graphics.*;
-import org.eclipse.swt.widgets.*;
-
-/**
- * A TableTree is a selectable user interface object
- * that displays a hierarchy of items, and issues
- * notification when an item is selected.
- * A TableTree may be single or multi select.
- * <p>
- * The item children that may be added to instances of this class
- * must be of type <code>TableTreeItem</code>.
- * </p><p>
- * Note that although this class is a subclass of <code>Composite</code>,
- * it does not make sense to add <code>Control</code> children to it,
- * or set a layout on it.
- * </p><p>
- * <dl>
- * <dt><b>Styles:</b> <dd> SINGLE, MULTI, CHECK, FULL_SELECTION
- * <dt><b>Events:</b> <dd> Selection, DefaultSelection, Collapse, Expand
- * </dl>
- * <p>
- * Note: Only one of the styles SINGLE, and MULTI may be specified.
- * </p>
- */
-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];
- static final String ITEMID = "TableTreeItemID"; //$NON-NLS-1$
-
-/**
- * Constructs a new instance of this class given its parent
- * and a style value describing its behavior and appearance.
- * <p>
- * The style value is either one of the style constants defined in
- * class <code>SWT</code> which is applicable to instances of this
- * class, or must be built by <em>bitwise OR</em>'ing together
- * (that is, using the <code>int</code> "|" operator) two or more
- * of those <code>SWT</code> style constants. The class description
- * lists the style constants that are applicable to the class.
- * Style bits are also inherited from superclasses.
- * </p>
- *
- * @param parent a widget which will be the parent of the new instance (cannot be null)
- * @param style the style of widget to construct
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
- * </ul>
- *
- * @see SWT#SINGLE
- * @see SWT#MULTI
- * @see SWT#CHECK
- * @see SWT#FULL_SELECTION
- * @see #getStyle
- */
-public TableTree(Composite parent, int style) {
- super(parent, SWT.NONE);
- table = new Table(this, style);
- Listener tableListener = new Listener() {
- public void handleEvent(Event e) {
- switch (e.type) {
- case SWT.MouseDown: onMouseDown(e); break;
- case SWT.Selection: onSelection(e); break;
- case SWT.DefaultSelection: onSelection(e); break;
- case SWT.KeyDown: onKeyDown(e); break;
- }
- }
- };
- int[] tableEvents = new int[]{SWT.MouseDown,
- SWT.Selection,
- SWT.DefaultSelection,
- SWT.KeyDown};
- for (int i = 0; i < tableEvents.length; i++) {
- table.addListener(tableEvents[i], tableListener);
- }
-
- Listener listener = new Listener() {
- public void handleEvent(Event e) {
- switch (e.type) {
- case SWT.Dispose: onDispose(e); break;
- case SWT.Resize: onResize(e); break;
- case SWT.FocusIn: onFocusIn(e); break;
- }
- }
- };
- int[] events = new int[]{SWT.Dispose,
- SWT.Resize,
- SWT.FocusIn};
- for (int i = 0; i < events.length; i++) {
- addListener(events[i], listener);
- }
-}
-
-int addItem(TableTreeItem item, int index) {
- if (index < 0 || index > items.length) 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 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.
- * <p>
- * When <code>widgetSelected</code> is called, the item field of the event object is valid.
- * If the reciever has <code>SWT.CHECK</code> style set and the check selection changes,
- * the event object detail field contains the value <code>SWT.CHECK</code>.
- * <code>widgetDefaultSelected</code> is typically called when an item is double-clicked.
- * The item field of the event object is valid for default selection, but the detail field is not used.
- * </p>
- *
- * @param listener the listener which should be notified
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see SelectionListener
- * @see #removeSelectionListener
- * @see SelectionEvent
- */
-public void addSelectionListener(SelectionListener listener) {
- checkWidget();
- if (listener == null) 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) {
- checkWidget();
- if (listener == null) throw new SWTError (SWT.ERROR_NULL_ARGUMENT);
- TypedListener typedListener = new TypedListener (listener);
- addListener (SWT.Expand, typedListener);
- addListener (SWT.Collapse, typedListener);
-}
-public Point computeSize (int wHint, int hHint) {
- checkWidget();
- return table.computeSize (wHint, hHint, true);
-}
-public Rectangle computeTrim (int x, int y, int width, int height) {
- checkWidget();
- return table.computeTrim(x, y, width, height);
-}
-
-/**
- * Deselects all items.
- * <p>
- * If an item is selected, it is deselected.
- * If an item is not selected, it remains unselected.
- *
- * @exception 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 () {
- checkWidget();
- table.deselectAll();
-}
-
-/* Expand upward from the specified leaf item. */
-void expandItem (TableTreeItem item) {
- if (item == null) return;
- expandItem(item.parentItem);
- if (!item.getVisible()) item.setVisible(true);
- if ( !item.expanded && item.items.length > 0) {
- item.setExpanded(true);
- Event event = new Event();
- event.item = item;
- notifyListeners(SWT.Expand, event);
- }
-}
-public Color getBackground () {
- // This method must be overriden otherwise, in a TableTree in which the first
- // item has no sub items, a grey (Widget background colour) square will appear in
- // the first column of the first item.
- // It is not possible in the constructor to set the background of the TableTree
- // to be the same as the background of the Table because this interferes with
- // the TableTree adapting to changes in the System color settings.
- return table.getBackground();
-}
-public Rectangle getClientArea () {
- return table.getClientArea();
-}
-public Color getForeground () {
- return table.getForeground();
-}
-public Font getFont () {
- return table.getFont();
-}
-/**
- * Gets the number of items.
- * <p>
- * @return the number of items in the widget
- */
-public int getItemCount () {
- //checkWidget();
- return items.length;
-}
-
-/**
- * Gets the height of one item.
- * <p>
- * This operation will fail if the height of
- * one item could not be queried from the OS.
- *
- * @return the height of one item in the widget
- *
- * @exception 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 () {
- checkWidget();
- return table.getItemHeight();
-}
-
-/**
- * Gets the items.
- * <p>
- * @return the items in the widget
- */
-public TableTreeItem [] getItems () {
- //checkWidget();
- TableTreeItem[] newItems = new TableTreeItem[items.length];
- System.arraycopy(items, 0, newItems, 0, items.length);
- return newItems;
-}
-
-/**
- * Gets the selected items.
- * <p>
- * This operation will fail if the selected
- * items cannot be queried from the OS.
- *
- * @return the selected items in the widget
- *
- * @exception 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 () {
- checkWidget();
- TableItem[] selection = table.getSelection();
- TableTreeItem [] result = new TableTreeItem[selection.length];
- for (int i = 0; i < selection.length; i++){
- result[i] = (TableTreeItem) selection[i].getData(ITEMID);
- }
- return result;
-}
-
-/**
- * Gets the number of selected items.
- * <p>
- * This operation will fail if the number of selected
- * items cannot be queried from the OS.
- *
- * @return the number of selected items in the widget
- *
- * @exception 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 () {
- checkWidget();
- return table.getSelectionCount();
-}
-
-public int getStyle () {
- checkWidget();
- return table.getStyle();
-}
-
-/**
- * Returns the underlying Table control.
- *
- * @return the underlying Table control
- */
-public Table getTable () {
- //checkWidget();
- return table;
-}
-
-void createImages () {
-
- int itemHeight = sizeImage.getBounds().height;
- // Calculate border around image.
- // At least 9 pixels are needed to draw the image
- // Leave at least a 6 pixel border.
- int indent = Math.min(6, (itemHeight - 9) / 2);
- indent = Math.max(0, indent);
- int size = Math.max (10, itemHeight - 2 * indent);
- size = ((size + 1) / 2) * 2; // size must be an even number
- int midpoint = indent + size / 2;
-
- Color foreground = getForeground();
- Color plusMinus = getDisplay().getSystemColor(SWT.COLOR_WIDGET_NORMAL_SHADOW);
- Color background = getBackground();
-
- /* Plus image */
- PaletteData palette = new PaletteData(new RGB[]{foreground.getRGB(), background.getRGB(), plusMinus.getRGB()});
- ImageData imageData = new ImageData(itemHeight, itemHeight, 4, palette);
- imageData.transparentPixel = 1;
- plusImage = new Image(getDisplay(), imageData);
- GC gc = new GC(plusImage);
- gc.setBackground(background);
- gc.fillRectangle(0, 0, itemHeight, itemHeight);
- gc.setForeground(plusMinus);
- gc.drawRectangle(indent, indent, size, size);
- gc.setForeground(foreground);
- gc.drawLine(midpoint, indent + 2, midpoint, indent + size - 2);
- gc.drawLine(indent + 2, midpoint, indent + size - 2, midpoint);
- gc.dispose();
-
- /* Minus image */
- palette = new PaletteData(new RGB[]{foreground.getRGB(), background.getRGB(), plusMinus.getRGB()});
- imageData = new ImageData(itemHeight, itemHeight, 4, palette);
- imageData.transparentPixel = 1;
- minusImage = new Image(getDisplay(), imageData);
- gc = new GC(minusImage);
- gc.setBackground(background);
- gc.fillRectangle(0, 0, itemHeight, itemHeight);
- gc.setForeground(plusMinus);
- gc.drawRectangle(indent, indent, size, size);
- gc.setForeground(foreground);
- gc.drawLine(indent + 2, midpoint, indent + size - 2, midpoint);
- gc.dispose();
-}
-
-Image getPlusImage() {
- if (plusImage == null) createImages();
- return plusImage;
-}
-
-Image getMinusImage() {
- if (minusImage == null) createImages();
- return minusImage;
-}
-
-/**
- * Gets the index of an item.
- *
- * <p>The widget is searched starting at 0 until an
- * item is found that is equal to the search item.
- * If no item is found, -1 is returned. Indexing
- * is zero based. This index is relative to the parent only.
- *
- * @param item the search item
- * @return the index of the item or -1
- */
-public int indexOf (TableTreeItem item) {
- //checkWidget();
- for (int i = 0; i < items.length; i++) {
- if (item == items[i]) return i;
- }
- return -1;
-}
-
-void onDispose(Event e) {
- /*
- * Usually when an item is disposed, destroyItem will change the size of the items array
- * and dispose of the underlying table items.
- * Since the whole table tree is being disposed, this is not necessary. For speed
- * the inDispose flag is used to skip over this part of the item dispose.
- */
- inDispose = true;
- for (int i = 0; i < items.length; i++) {
- items[i].dispose();
- }
- inDispose = false;
- if (plusImage != null) plusImage.dispose();
- if (minusImage != null) minusImage.dispose();
- if (sizeImage != null) sizeImage.dispose();
- plusImage = minusImage = sizeImage = null;
-}
-
-void onResize(Event e) {
- Point size = getSize();
- table.setBounds(0, 0, size.x, size.y);
-}
-
-void onSelection(Event e) {
- Event event = new Event();
- TableItem tableItem = (TableItem)e.item;
- TableTreeItem item = getItem(tableItem);
- event.item = item;
-
- if (e.type == SWT.Selection && e.detail == SWT.CHECK && item != null) {
- event.detail = SWT.CHECK;
- item.checked = tableItem.getChecked();
- }
- notifyListeners(e.type, event);
-}
-/**
- * Returns the item at the given 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 TableTreeItem getItem(Point point) {
- checkWidget();
- TableItem item = table.getItem(point);
- if (item == null) return null;
- return getItem(item);
-
-}
-TableTreeItem getItem(TableItem tableItem) {
- if (tableItem == null) return null;
- for (int i = 0; i < items.length; i++) {
- TableTreeItem item = items[i].getItem(tableItem);
- if (item != null) return item;
- }
- return null;
-}
-void onFocusIn (Event e) {
- table.setFocus();
-}
-
-void onKeyDown (Event e) {
- TableTreeItem[] selection = getSelection();
- if (selection.length == 0) return;
- TableTreeItem item = selection[0];
- int type = 0;
- if (e.keyCode == SWT.ARROW_RIGHT || e.keyCode == SWT.ARROW_LEFT) {
- if (e.keyCode == SWT.ARROW_RIGHT) {
- if (item.getItemCount() == 0) return;
- if (item.getExpanded()) {
- TableTreeItem newSelection = item.getItems()[0];
- table.setSelection(new TableItem[]{newSelection.tableItem});
- showItem(newSelection);
- type = SWT.Selection;
- } else {
- item.setExpanded(true);
- type = SWT.Expand;
- }
- } else {
- if (item.getExpanded()) {
- item.setExpanded(false);
- type = SWT.Collapse;
- } else {
- TableTreeItem parent = item.getParentItem();
- if (parent != null) {
- int index = parent.indexOf(item);
- if (index != 0) return;
- table.setSelection(new TableItem[]{parent.tableItem});
- type = SWT.Selection;
- }
- }
- }
- }
- if (e.character == '*') {
- item.expandAll(true);
- }
- if (e.character == '-') {
- if (item.getExpanded()) {
- item.setExpanded(false);
- type = SWT.Collapse;
- }
- }
- if (e.character == '+') {
- if (item.getItemCount() > 0 && !item.getExpanded()) {
- item.setExpanded(true);
- type = SWT.Expand;
- }
- }
- if (type == 0) return;
- Event event = new Event();
- event.item = item;
- notifyListeners(type, event);
-}
-void onMouseDown(Event event) {
- /* If user clicked on the [+] or [-], expand or collapse the tree. */
- TableItem[] items = table.getItems();
- for (int i = 0; i < items.length; i++) {
- Rectangle rect = items[i].getImageBounds(0);
- if (rect.contains(event.x, event.y)) {
- TableTreeItem item = (TableTreeItem) items[i].getData(ITEMID);
- event = new Event();
- event.item = item;
- item.setExpanded(!item.getExpanded());
- if (item.getExpanded()) {
- notifyListeners(SWT.Expand, event);
- } else {
- notifyListeners(SWT.Collapse, event);
- }
- return;
- }
- }
-}
-
-/**
- * Removes all items.
- * <p>
- * This operation will fail when an item
- * could not be removed in the OS.
- *
- * @exception 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 () {
- checkWidget();
- setRedraw(false);
- for (int i = items.length - 1; i >= 0; i--) {
- items[i].dispose();
- }
- items = EMPTY_ITEMS;
- setRedraw(true);
-}
-
-void removeItem(TableTreeItem item) {
- int index = 0;
- while (index < items.length && items[index] != item) index++;
- if (index == items.length) return;
- TableTreeItem[] newItems = new TableTreeItem[items.length - 1];
- System.arraycopy(items, 0, newItems, 0, index);
- System.arraycopy(items, index + 1, newItems, index, items.length - index - 1);
- items = newItems;
-}
-
-/**
- * Removes the listener.
- * <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) {
- checkWidget();
- 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) {
- checkWidget();
- 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 () {
- checkWidget();
- table.selectAll();
-}
-public void setBackground (Color color) {
- super.setBackground(color);
- table.setBackground(color);
- if (sizeImage != null) {
- GC gc = new GC (sizeImage);
- gc.setBackground(getBackground());
- Rectangle size = sizeImage.getBounds();
- gc.fillRectangle(size);
- gc.dispose();
- }
-}
-public void setEnabled (boolean enabled) {
- super.setEnabled(enabled);
- table.setEnabled(enabled);
-}
-public void setFont (Font font) {
- super.setFont(font);
- table.setFont(font);
-}
-public void setForeground (Color color) {
- super.setForeground(color);
- table.setForeground(color);
-}
-public void setMenu (Menu menu) {
- super.setMenu(menu);
- table.setMenu(menu);
-}
-
-/**
- * Sets the 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) {
- checkWidget();
- 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);
-}
-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) {
- checkWidget();
- 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 () {
- checkWidget();
- table.showSelection();
-}
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+import org.eclipse.swt.*;
+import org.eclipse.swt.events.*;
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.widgets.*;
+
+/**
+ * A TableTree is a selectable user interface object
+ * that displays a hierarchy of items, and issues
+ * notification when an item is selected.
+ * A TableTree may be single or multi select.
+ * <p>
+ * The item children that may be added to instances of this class
+ * must be of type <code>TableTreeItem</code>.
+ * </p><p>
+ * Note that although this class is a subclass of <code>Composite</code>,
+ * it does not make sense to add <code>Control</code> children to it,
+ * or set a layout on it.
+ * </p><p>
+ * <dl>
+ * <dt><b>Styles:</b> <dd> SINGLE, MULTI, CHECK, FULL_SELECTION
+ * <dt><b>Events:</b> <dd> Selection, DefaultSelection, Collapse, Expand
+ * </dl>
+ * <p>
+ * Note: Only one of the styles SINGLE, and MULTI may be specified.
+ * </p>
+ */
+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];
+ static final String ITEMID = "TableTreeItemID"; //$NON-NLS-1$
+
+/**
+ * Constructs a new instance of this class given its parent
+ * and a style value describing its behavior and appearance.
+ * <p>
+ * The style value is either one of the style constants defined in
+ * class <code>SWT</code> which is applicable to instances of this
+ * class, or must be built by <em>bitwise OR</em>'ing together
+ * (that is, using the <code>int</code> "|" operator) two or more
+ * of those <code>SWT</code> style constants. The class description
+ * lists the style constants that are applicable to the class.
+ * Style bits are also inherited from superclasses.
+ * </p>
+ *
+ * @param parent a widget which will be the parent of the new instance (cannot be null)
+ * @param style the style of widget to construct
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
+ * </ul>
+ *
+ * @see SWT#SINGLE
+ * @see SWT#MULTI
+ * @see SWT#CHECK
+ * @see SWT#FULL_SELECTION
+ * @see #getStyle
+ */
+public TableTree(Composite parent, int style) {
+ super(parent, SWT.NONE);
+ table = new Table(this, style);
+ Listener tableListener = new Listener() {
+ public void handleEvent(Event e) {
+ switch (e.type) {
+ case SWT.MouseDown: onMouseDown(e); break;
+ case SWT.Selection: onSelection(e); break;
+ case SWT.DefaultSelection: onSelection(e); break;
+ case SWT.KeyDown: onKeyDown(e); break;
+ }
+ }
+ };
+ int[] tableEvents = new int[]{SWT.MouseDown,
+ SWT.Selection,
+ SWT.DefaultSelection,
+ SWT.KeyDown};
+ for (int i = 0; i < tableEvents.length; i++) {
+ table.addListener(tableEvents[i], tableListener);
+ }
+
+ Listener listener = new Listener() {
+ public void handleEvent(Event e) {
+ switch (e.type) {
+ case SWT.Dispose: onDispose(e); break;
+ case SWT.Resize: onResize(e); break;
+ case SWT.FocusIn: onFocusIn(e); break;
+ }
+ }
+ };
+ int[] events = new int[]{SWT.Dispose,
+ SWT.Resize,
+ SWT.FocusIn};
+ for (int i = 0; i < events.length; i++) {
+ addListener(events[i], listener);
+ }
+}
+
+int addItem(TableTreeItem item, int index) {
+ if (index < 0 || index > items.length) 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 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.
+ * <p>
+ * When <code>widgetSelected</code> is called, the item field of the event object is valid.
+ * If the reciever has <code>SWT.CHECK</code> style set and the check selection changes,
+ * the event object detail field contains the value <code>SWT.CHECK</code>.
+ * <code>widgetDefaultSelected</code> is typically called when an item is double-clicked.
+ * The item field of the event object is valid for default selection, but the detail field is not used.
+ * </p>
+ *
+ * @param listener the listener which should be notified
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see SelectionListener
+ * @see #removeSelectionListener
+ * @see SelectionEvent
+ */
+public void addSelectionListener(SelectionListener listener) {
+ checkWidget();
+ if (listener == null) 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) {
+ checkWidget();
+ if (listener == null) throw new SWTError (SWT.ERROR_NULL_ARGUMENT);
+ TypedListener typedListener = new TypedListener (listener);
+ addListener (SWT.Expand, typedListener);
+ addListener (SWT.Collapse, typedListener);
+}
+public Point computeSize (int wHint, int hHint) {
+ checkWidget();
+ return table.computeSize (wHint, hHint, true);
+}
+public Rectangle computeTrim (int x, int y, int width, int height) {
+ checkWidget();
+ return table.computeTrim(x, y, width, height);
+}
+
+/**
+ * Deselects all items.
+ * <p>
+ * If an item is selected, it is deselected.
+ * If an item is not selected, it remains unselected.
+ *
+ * @exception 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 () {
+ checkWidget();
+ table.deselectAll();
+}
+
+/* Expand upward from the specified leaf item. */
+void expandItem (TableTreeItem item) {
+ if (item == null) return;
+ expandItem(item.parentItem);
+ if (!item.getVisible()) item.setVisible(true);
+ if ( !item.expanded && item.items.length > 0) {
+ item.setExpanded(true);
+ Event event = new Event();
+ event.item = item;
+ notifyListeners(SWT.Expand, event);
+ }
+}
+public Color getBackground () {
+ // This method must be overriden otherwise, in a TableTree in which the first
+ // item has no sub items, a grey (Widget background colour) square will appear in
+ // the first column of the first item.
+ // It is not possible in the constructor to set the background of the TableTree
+ // to be the same as the background of the Table because this interferes with
+ // the TableTree adapting to changes in the System color settings.
+ return table.getBackground();
+}
+public Rectangle getClientArea () {
+ return table.getClientArea();
+}
+public Color getForeground () {
+ return table.getForeground();
+}
+public Font getFont () {
+ return table.getFont();
+}
+/**
+ * Gets the number of items.
+ * <p>
+ * @return the number of items in the widget
+ */
+public int getItemCount () {
+ //checkWidget();
+ return items.length;
+}
+
+/**
+ * Gets the height of one item.
+ * <p>
+ * This operation will fail if the height of
+ * one item could not be queried from the OS.
+ *
+ * @return the height of one item in the widget
+ *
+ * @exception 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 () {
+ checkWidget();
+ return table.getItemHeight();
+}
+
+/**
+ * Gets the items.
+ * <p>
+ * @return the items in the widget
+ */
+public TableTreeItem [] getItems () {
+ //checkWidget();
+ TableTreeItem[] newItems = new TableTreeItem[items.length];
+ System.arraycopy(items, 0, newItems, 0, items.length);
+ return newItems;
+}
+
+/**
+ * Gets the selected items.
+ * <p>
+ * This operation will fail if the selected
+ * items cannot be queried from the OS.
+ *
+ * @return the selected items in the widget
+ *
+ * @exception 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 () {
+ checkWidget();
+ TableItem[] selection = table.getSelection();
+ TableTreeItem [] result = new TableTreeItem[selection.length];
+ for (int i = 0; i < selection.length; i++){
+ result[i] = (TableTreeItem) selection[i].getData(ITEMID);
+ }
+ return result;
+}
+
+/**
+ * Gets the number of selected items.
+ * <p>
+ * This operation will fail if the number of selected
+ * items cannot be queried from the OS.
+ *
+ * @return the number of selected items in the widget
+ *
+ * @exception 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 () {
+ checkWidget();
+ return table.getSelectionCount();
+}
+
+public int getStyle () {
+ checkWidget();
+ return table.getStyle();
+}
+
+/**
+ * Returns the underlying Table control.
+ *
+ * @return the underlying Table control
+ */
+public Table getTable () {
+ //checkWidget();
+ return table;
+}
+
+void createImages () {
+
+ int itemHeight = sizeImage.getBounds().height;
+ // Calculate border around image.
+ // At least 9 pixels are needed to draw the image
+ // Leave at least a 6 pixel border.
+ int indent = Math.min(6, (itemHeight - 9) / 2);
+ indent = Math.max(0, indent);
+ int size = Math.max (10, itemHeight - 2 * indent);
+ size = ((size + 1) / 2) * 2; // size must be an even number
+ int midpoint = indent + size / 2;
+
+ Color foreground = getForeground();
+ Color plusMinus = getDisplay().getSystemColor(SWT.COLOR_WIDGET_NORMAL_SHADOW);
+ Color background = getBackground();
+
+ /* Plus image */
+ PaletteData palette = new PaletteData(new RGB[]{foreground.getRGB(), background.getRGB(), plusMinus.getRGB()});
+ ImageData imageData = new ImageData(itemHeight, itemHeight, 4, palette);
+ imageData.transparentPixel = 1;
+ plusImage = new Image(getDisplay(), imageData);
+ GC gc = new GC(plusImage);
+ gc.setBackground(background);
+ gc.fillRectangle(0, 0, itemHeight, itemHeight);
+ gc.setForeground(plusMinus);
+ gc.drawRectangle(indent, indent, size, size);
+ gc.setForeground(foreground);
+ gc.drawLine(midpoint, indent + 2, midpoint, indent + size - 2);
+ gc.drawLine(indent + 2, midpoint, indent + size - 2, midpoint);
+ gc.dispose();
+
+ /* Minus image */
+ palette = new PaletteData(new RGB[]{foreground.getRGB(), background.getRGB(), plusMinus.getRGB()});
+ imageData = new ImageData(itemHeight, itemHeight, 4, palette);
+ imageData.transparentPixel = 1;
+ minusImage = new Image(getDisplay(), imageData);
+ gc = new GC(minusImage);
+ gc.setBackground(background);
+ gc.fillRectangle(0, 0, itemHeight, itemHeight);
+ gc.setForeground(plusMinus);
+ gc.drawRectangle(indent, indent, size, size);
+ gc.setForeground(foreground);
+ gc.drawLine(indent + 2, midpoint, indent + size - 2, midpoint);
+ gc.dispose();
+}
+
+Image getPlusImage() {
+ if (plusImage == null) createImages();
+ return plusImage;
+}
+
+Image getMinusImage() {
+ if (minusImage == null) createImages();
+ return minusImage;
+}
+
+/**
+ * Gets the index of an item.
+ *
+ * <p>The widget is searched starting at 0 until an
+ * item is found that is equal to the search item.
+ * If no item is found, -1 is returned. Indexing
+ * is zero based. This index is relative to the parent only.
+ *
+ * @param item the search item
+ * @return the index of the item or -1
+ */
+public int indexOf (TableTreeItem item) {
+ //checkWidget();
+ for (int i = 0; i < items.length; i++) {
+ if (item == items[i]) return i;
+ }
+ return -1;
+}
+
+void onDispose(Event e) {
+ /*
+ * Usually when an item is disposed, destroyItem will change the size of the items array
+ * and dispose of the underlying table items.
+ * Since the whole table tree is being disposed, this is not necessary. For speed
+ * the inDispose flag is used to skip over this part of the item dispose.
+ */
+ inDispose = true;
+ for (int i = 0; i < items.length; i++) {
+ items[i].dispose();
+ }
+ inDispose = false;
+ if (plusImage != null) plusImage.dispose();
+ if (minusImage != null) minusImage.dispose();
+ if (sizeImage != null) sizeImage.dispose();
+ plusImage = minusImage = sizeImage = null;
+}
+
+void onResize(Event e) {
+ Point size = getSize();
+ table.setBounds(0, 0, size.x, size.y);
+}
+
+void onSelection(Event e) {
+ Event event = new Event();
+ TableItem tableItem = (TableItem)e.item;
+ TableTreeItem item = getItem(tableItem);
+ event.item = item;
+
+ if (e.type == SWT.Selection && e.detail == SWT.CHECK && item != null) {
+ event.detail = SWT.CHECK;
+ item.checked = tableItem.getChecked();
+ }
+ notifyListeners(e.type, event);
+}
+/**
+ * Returns the item at the given 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 TableTreeItem getItem(Point point) {
+ checkWidget();
+ TableItem item = table.getItem(point);
+ if (item == null) return null;
+ return getItem(item);
+
+}
+TableTreeItem getItem(TableItem tableItem) {
+ if (tableItem == null) return null;
+ for (int i = 0; i < items.length; i++) {
+ TableTreeItem item = items[i].getItem(tableItem);
+ if (item != null) return item;
+ }
+ return null;
+}
+void onFocusIn (Event e) {
+ table.setFocus();
+}
+
+void onKeyDown (Event e) {
+ TableTreeItem[] selection = getSelection();
+ if (selection.length == 0) return;
+ TableTreeItem item = selection[0];
+ int type = 0;
+ if (e.keyCode == SWT.ARROW_RIGHT || e.keyCode == SWT.ARROW_LEFT) {
+ if (e.keyCode == SWT.ARROW_RIGHT) {
+ if (item.getItemCount() == 0) return;
+ if (item.getExpanded()) {
+ TableTreeItem newSelection = item.getItems()[0];
+ table.setSelection(new TableItem[]{newSelection.tableItem});
+ showItem(newSelection);
+ type = SWT.Selection;
+ } else {
+ item.setExpanded(true);
+ type = SWT.Expand;
+ }
+ } else {
+ if (item.getExpanded()) {
+ item.setExpanded(false);
+ type = SWT.Collapse;
+ } else {
+ TableTreeItem parent = item.getParentItem();
+ if (parent != null) {
+ int index = parent.indexOf(item);
+ if (index != 0) return;
+ table.setSelection(new TableItem[]{parent.tableItem});
+ type = SWT.Selection;
+ }
+ }
+ }
+ }
+ if (e.character == '*') {
+ item.expandAll(true);
+ }
+ if (e.character == '-') {
+ if (item.getExpanded()) {
+ item.setExpanded(false);
+ type = SWT.Collapse;
+ }
+ }
+ if (e.character == '+') {
+ if (item.getItemCount() > 0 && !item.getExpanded()) {
+ item.setExpanded(true);
+ type = SWT.Expand;
+ }
+ }
+ if (type == 0) return;
+ Event event = new Event();
+ event.item = item;
+ notifyListeners(type, event);
+}
+void onMouseDown(Event event) {
+ /* If user clicked on the [+] or [-], expand or collapse the tree. */
+ TableItem[] items = table.getItems();
+ for (int i = 0; i < items.length; i++) {
+ Rectangle rect = items[i].getImageBounds(0);
+ if (rect.contains(event.x, event.y)) {
+ TableTreeItem item = (TableTreeItem) items[i].getData(ITEMID);
+ event = new Event();
+ event.item = item;
+ item.setExpanded(!item.getExpanded());
+ if (item.getExpanded()) {
+ notifyListeners(SWT.Expand, event);
+ } else {
+ notifyListeners(SWT.Collapse, event);
+ }
+ return;
+ }
+ }
+}
+
+/**
+ * Removes all items.
+ * <p>
+ * This operation will fail when an item
+ * could not be removed in the OS.
+ *
+ * @exception 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 () {
+ checkWidget();
+ setRedraw(false);
+ for (int i = items.length - 1; i >= 0; i--) {
+ items[i].dispose();
+ }
+ items = EMPTY_ITEMS;
+ setRedraw(true);
+}
+
+void removeItem(TableTreeItem item) {
+ int index = 0;
+ while (index < items.length && items[index] != item) index++;
+ if (index == items.length) return;
+ TableTreeItem[] newItems = new TableTreeItem[items.length - 1];
+ System.arraycopy(items, 0, newItems, 0, index);
+ System.arraycopy(items, index + 1, newItems, index, items.length - index - 1);
+ items = newItems;
+}
+
+/**
+ * Removes the listener.
+ * <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) {
+ checkWidget();
+ 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) {
+ checkWidget();
+ 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 () {
+ checkWidget();
+ table.selectAll();
+}
+public void setBackground (Color color) {
+ super.setBackground(color);
+ table.setBackground(color);
+ if (sizeImage != null) {
+ GC gc = new GC (sizeImage);
+ gc.setBackground(getBackground());
+ Rectangle size = sizeImage.getBounds();
+ gc.fillRectangle(size);
+ gc.dispose();
+ }
+}
+public void setEnabled (boolean enabled) {
+ super.setEnabled(enabled);
+ table.setEnabled(enabled);
+}
+public void setFont (Font font) {
+ super.setFont(font);
+ table.setFont(font);
+}
+public void setForeground (Color color) {
+ super.setForeground(color);
+ table.setForeground(color);
+}
+public void setMenu (Menu menu) {
+ super.setMenu(menu);
+ table.setMenu(menu);
+}
+
+/**
+ * Sets the 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) {
+ checkWidget();
+ 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);
+}
+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) {
+ checkWidget();
+ 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 () {
+ checkWidget();
+ 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
index b00f5a18f6..8a127d5a91 100755
--- 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
@@ -1,231 +1,231 @@
-package org.eclipse.swt.custom;
-
-/*
+package org.eclipse.swt.custom;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-import org.eclipse.swt.*;
-import org.eclipse.swt.graphics.*;
-import org.eclipse.swt.widgets.*;
-import org.eclipse.swt.events.*;
-/**
-*
-* A TableTreeEditor is a manager for a Control that appears above a cell in a TableTree
-* and tracks with the moving and resizing of that cell. It can be used to display a
-* text widget above a cell in a TableTree so that the user can edit the contents of
-* that cell. It can also be used to display a button that can launch a dialog for
-* modifying the contents of the associated cell.
-*
-* <p> Here is an example of using a TableTreeEditor:
-* <code><pre>
-* public static void main (String [] args) {
-* Display display = new Display ();
-* Shell shell = new Shell (display);
-* final TableTree tableTree = new TableTree(shell, SWT.FULL_SELECTION);
-* Table table = tableTree.getTable();
-* table.setLinesVisible(true);
-* TableColumn column1 = new TableColumn(table, SWT.NONE);
-* column1.setText("column 1");
-* TableColumn column2 = new TableColumn(table, SWT.NONE);
-* column2.setText("column 2");
-* for (int i = 0; i < 40; i++) {
-* TableTreeItem item = new TableTreeItem(tableTree, SWT.NONE);
-* item.setText(0, "table tree item"+i);
-* item.setText(1, "value "+i);
-* }
-* column1.pack();
-* column2.pack();
-* final TableTreeEditor editor = new TableTreeEditor (tableTree);
-* tableTree.addSelectionListener (new SelectionAdapter() {
-* public void widgetSelected(SelectionEvent e) {
-* // Clean up any previous editor control
-* Control oldEditor = editor.getEditor();
-* if (oldEditor != null)
-* oldEditor.dispose();
-* // Identify the selected row
-* TableTreeItem[] selection = tableTree.getSelection();
-* if (selection.length == 0) return;
-* TableTreeItem item = selection[0];
-* // The control that will be the editor must be a child of the Table
-* // that underlies the TableTree
-* Text text = new Text(tableTree.getTable(), SWT.NONE);
-* //text.moveAbove(tableTree);
-* //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 ();
-* }
-* });
-* tableTree.setBounds(10, 10, 200, 400);
-* shell.open ();
-* while (!shell.isDisposed ()) {
-* if (!display.readAndDispatch ()) display.sleep ();
-* }
-* display.dispose ();
-* }
-* </pre></code>
-*/
-public class TableTreeEditor extends ControlEditor {
-
- TableTree tableTree;
- TableTreeItem item;
- int column = -1;
- ControlListener columnListener;
- TreeListener treeListener;
-/**
-* Creates a TableEditor for the specified Table.
-*
-* @param table the Table Control above which this editor will be displayed
-*
-*/
-public TableTreeEditor (TableTree tableTree) {
- super(tableTree.getTable());
- this.tableTree = tableTree;
-
- treeListener = new TreeListener () {
- final Runnable runnable = new Runnable() {
- public void run() {
- if (TableTreeEditor.this.tableTree.isDisposed() || editor == null) return;
- resize();
- editor.setVisible(true);
- }
- };
- public void treeCollapsed(TreeEvent e) {
- if (editor == null) return;
- editor.setVisible(false);
- Display display = TableTreeEditor.this.tableTree.getDisplay();
- display.asyncExec(runnable);
- }
- public void treeExpanded(TreeEvent e) {
- if (editor == null) return;
- editor.setVisible(false);
- Display display = TableTreeEditor.this.tableTree.getDisplay();
- display.asyncExec(runnable);
- }
- };
- tableTree.addTreeListener(treeListener);
-
- columnListener = new ControlListener() {
- public void controlMoved(ControlEvent e){
- resize ();
- }
- public void controlResized(ControlEvent e){
- resize ();
- }
- };
-
-}
-Rectangle computeBounds () {
- if (item == null || column == -1 || item.isDisposed() || item.tableItem == null) return new Rectangle(0, 0, 0, 0);
- Rectangle cell = item.getBounds(column);
- Rectangle editorRect = new Rectangle(cell.x, cell.y, minimumWidth, cell.height);
- Rectangle area = tableTree.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 (treeListener != null)
- tableTree.removeTreeListener(treeListener);
- treeListener = null;
- Table table = tableTree.getTable();
- if (this.column > -1 && this.column < table.getColumnCount()){
- TableColumn tableColumn = table.getColumn(this.column);
- tableColumn.removeControlListener(columnListener);
- }
-
- tableTree = null;
- item = null;
- column = -1;
-
- super.dispose();
-}
-/**
-* Returns the zero based index of the column of the cell being tracked by this editor.
-*
-* @return the zero based index of the column of the cell being tracked by this editor
-*/
-public int getColumn () {
- return column;
-}
-public void setColumn(int column) {
- Table table = tableTree.getTable();
- if (this.column > -1 && this.column < table.getColumnCount()){
- TableColumn tableColumn = table.getColumn(this.column);
- tableColumn.removeControlListener(columnListener);
- this.column = -1;
- }
-
- if (column < 0 || column >= table.getColumnCount()) return;
-
- this.column = column;
- TableColumn tableColumn = table.getColumn(this.column);
- tableColumn.addControlListener(columnListener);
-
- resize();
-}
-/**
-* 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 TableTreeItem getItem () {
- return item;
-}
-public void setItem (TableTreeItem item) {
- this.item = item;
- resize();
-}
-
-/**
-* Specify the Control that is to be displayed and the cell in the table that it is to be positioned above.
-*
-* <p>Note: The Control provided as the editor <b>must</b> be created with its parent being the Table control
-* specified in the TableEditor constructor.
-*
-* @param editor the Control that is displayed above the cell being edited
-* @param item the TableItem for the row of the cell being tracked by this editor
-* @param column the zero based index of the column of the cell being tracked by this editor
-*/
-public void setEditor (Control editor, TableTreeItem item, int column) {
- setItem(item);
- setColumn(column);
- super.setEditor(editor);
-}
-void resize () {
- if (tableTree.isDisposed()) return;
- if (item == null || item.isDisposed()) return;
- Table table = tableTree.getTable();
- if (column < 0 || column >= table.getColumnCount()) return;
- super.resize();
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+import org.eclipse.swt.*;
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.widgets.*;
+import org.eclipse.swt.events.*;
+/**
+*
+* A TableTreeEditor is a manager for a Control that appears above a cell in a TableTree
+* and tracks with the moving and resizing of that cell. It can be used to display a
+* text widget above a cell in a TableTree so that the user can edit the contents of
+* that cell. It can also be used to display a button that can launch a dialog for
+* modifying the contents of the associated cell.
+*
+* <p> Here is an example of using a TableTreeEditor:
+* <code><pre>
+* public static void main (String [] args) {
+* Display display = new Display ();
+* Shell shell = new Shell (display);
+* final TableTree tableTree = new TableTree(shell, SWT.FULL_SELECTION);
+* Table table = tableTree.getTable();
+* table.setLinesVisible(true);
+* TableColumn column1 = new TableColumn(table, SWT.NONE);
+* column1.setText("column 1");
+* TableColumn column2 = new TableColumn(table, SWT.NONE);
+* column2.setText("column 2");
+* for (int i = 0; i < 40; i++) {
+* TableTreeItem item = new TableTreeItem(tableTree, SWT.NONE);
+* item.setText(0, "table tree item"+i);
+* item.setText(1, "value "+i);
+* }
+* column1.pack();
+* column2.pack();
+* final TableTreeEditor editor = new TableTreeEditor (tableTree);
+* tableTree.addSelectionListener (new SelectionAdapter() {
+* public void widgetSelected(SelectionEvent e) {
+* // Clean up any previous editor control
+* Control oldEditor = editor.getEditor();
+* if (oldEditor != null)
+* oldEditor.dispose();
+* // Identify the selected row
+* TableTreeItem[] selection = tableTree.getSelection();
+* if (selection.length == 0) return;
+* TableTreeItem item = selection[0];
+* // The control that will be the editor must be a child of the Table
+* // that underlies the TableTree
+* Text text = new Text(tableTree.getTable(), SWT.NONE);
+* //text.moveAbove(tableTree);
+* //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 ();
+* }
+* });
+* tableTree.setBounds(10, 10, 200, 400);
+* shell.open ();
+* while (!shell.isDisposed ()) {
+* if (!display.readAndDispatch ()) display.sleep ();
+* }
+* display.dispose ();
+* }
+* </pre></code>
+*/
+public class TableTreeEditor extends ControlEditor {
+
+ TableTree tableTree;
+ TableTreeItem item;
+ int column = -1;
+ ControlListener columnListener;
+ TreeListener treeListener;
+/**
+* Creates a TableEditor for the specified Table.
+*
+* @param table the Table Control above which this editor will be displayed
+*
+*/
+public TableTreeEditor (TableTree tableTree) {
+ super(tableTree.getTable());
+ this.tableTree = tableTree;
+
+ treeListener = new TreeListener () {
+ final Runnable runnable = new Runnable() {
+ public void run() {
+ if (TableTreeEditor.this.tableTree.isDisposed() || editor == null) return;
+ resize();
+ editor.setVisible(true);
+ }
+ };
+ public void treeCollapsed(TreeEvent e) {
+ if (editor == null) return;
+ editor.setVisible(false);
+ Display display = TableTreeEditor.this.tableTree.getDisplay();
+ display.asyncExec(runnable);
+ }
+ public void treeExpanded(TreeEvent e) {
+ if (editor == null) return;
+ editor.setVisible(false);
+ Display display = TableTreeEditor.this.tableTree.getDisplay();
+ display.asyncExec(runnable);
+ }
+ };
+ tableTree.addTreeListener(treeListener);
+
+ columnListener = new ControlListener() {
+ public void controlMoved(ControlEvent e){
+ resize ();
+ }
+ public void controlResized(ControlEvent e){
+ resize ();
+ }
+ };
+
+}
+Rectangle computeBounds () {
+ if (item == null || column == -1 || item.isDisposed() || item.tableItem == null) return new Rectangle(0, 0, 0, 0);
+ Rectangle cell = item.getBounds(column);
+ Rectangle editorRect = new Rectangle(cell.x, cell.y, minimumWidth, cell.height);
+ Rectangle area = tableTree.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 (treeListener != null)
+ tableTree.removeTreeListener(treeListener);
+ treeListener = null;
+ Table table = tableTree.getTable();
+ if (this.column > -1 && this.column < table.getColumnCount()){
+ TableColumn tableColumn = table.getColumn(this.column);
+ tableColumn.removeControlListener(columnListener);
+ }
+
+ tableTree = null;
+ item = null;
+ column = -1;
+
+ super.dispose();
+}
+/**
+* Returns the zero based index of the column of the cell being tracked by this editor.
+*
+* @return the zero based index of the column of the cell being tracked by this editor
+*/
+public int getColumn () {
+ return column;
+}
+public void setColumn(int column) {
+ Table table = tableTree.getTable();
+ if (this.column > -1 && this.column < table.getColumnCount()){
+ TableColumn tableColumn = table.getColumn(this.column);
+ tableColumn.removeControlListener(columnListener);
+ this.column = -1;
+ }
+
+ if (column < 0 || column >= table.getColumnCount()) return;
+
+ this.column = column;
+ TableColumn tableColumn = table.getColumn(this.column);
+ tableColumn.addControlListener(columnListener);
+
+ resize();
+}
+/**
+* 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 TableTreeItem getItem () {
+ return item;
+}
+public void setItem (TableTreeItem item) {
+ this.item = item;
+ resize();
+}
+
+/**
+* Specify the Control that is to be displayed and the cell in the table that it is to be positioned above.
+*
+* <p>Note: The Control provided as the editor <b>must</b> be created with its parent being the Table control
+* specified in the TableEditor constructor.
+*
+* @param editor the Control that is displayed above the cell being edited
+* @param item the TableItem for the row of the cell being tracked by this editor
+* @param column the zero based index of the column of the cell being tracked by this editor
+*/
+public void setEditor (Control editor, TableTreeItem item, int column) {
+ setItem(item);
+ setColumn(column);
+ super.setEditor(editor);
+}
+void resize () {
+ if (tableTree.isDisposed()) return;
+ if (item == null || item.isDisposed()) return;
+ Table table = tableTree.getTable();
+ if (column < 0 || column >= table.getColumnCount()) return;
+ super.resize();
+}
} \ No newline at end of file
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
index 4b6f0ca1b3..6bd93abf20 100755
--- 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
@@ -1,803 +1,803 @@
-package org.eclipse.swt.custom;
-
-/*
+package org.eclipse.swt.custom;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-import org.eclipse.swt.*;
-import org.eclipse.swt.graphics.*;
-import org.eclipse.swt.widgets.*;
-
-/**
- * A TableTreeItem is a selectable user interface object
- * that represents an item in a 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;
- Color background;
- Color foreground;
- boolean expanded;
- boolean checked;
- boolean grayed;
-
-/**
- * Constructs a new instance of this class given its parent
- * (which must be a <code>TableTree</code>)
- * and a style value describing its behavior and appearance.
- * The item is added to the end of the items maintained by its parent.
- * <p>
- * The style value is either one of the style constants defined in
- * class <code>SWT</code> which is applicable to instances of this
- * class, or must be built by <em>bitwise OR</em>'ing together
- * (that is, using the <code>int</code> "|" operator) two or more
- * of those <code>SWT</code> style constants. The class description
- * lists the style constants that are applicable to the class.
- * Style bits are also inherited from superclasses.
- * </p>
- *
- * @param parent a composite control which will be the parent of the new instance (cannot be null)
- * @param style the style of control to construct
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
- * </ul>
- *
- * @see SWT
- * @see Widget#getStyle
- */
-public TableTreeItem(TableTree parent, int style) {
- this (parent, style, parent.getItemCount());
-}
-
-/**
- * Constructs a new instance of this class given its parent
- * (which must be a <code>TableTree</code>,
- * a style value describing its behavior and appearance, and the index
- * at which to place it in the items maintained by its parent.
- * <p>
- * The style value is either one of the style constants defined in
- * class <code>SWT</code> which is applicable to instances of this
- * class, or must be built by <em>bitwise OR</em>'ing together
- * (that is, using the <code>int</code> "|" operator) two or more
- * of those <code>SWT</code> style constants. The class description
- * lists the style constants that are applicable to the class.
- * Style bits are also inherited from superclasses.
- * </p>
- *
- * @param parent a composite control which will be the parent of the new instance (cannot be null)
- * @param style the style of control to construct
- * @param index the index to store the receiver in its parent
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
- * </ul>
- *
- * @see SWT
- * @see Widget#getStyle
- */
-public TableTreeItem(TableTree parent, int style, int index) {
- this (parent, null, style, index);
-}
-
-/**
- * Constructs a new instance of this class given its parent
- * (which must be a <code>TableTreeItem</code>)
- * and a style value describing its behavior and appearance.
- * The item is added to the end of the items maintained by its parent.
- * <p>
- * The style value is either one of the style constants defined in
- * class <code>SWT</code> which is applicable to instances of this
- * class, or must be built by <em>bitwise OR</em>'ing together
- * (that is, using the <code>int</code> "|" operator) two or more
- * of those <code>SWT</code> style constants. The class description
- * lists the style constants that are applicable to the class.
- * Style bits are also inherited from superclasses.
- * </p>
- *
- * @param parentItem a composite control which will be the parent of the new instance (cannot be null)
- * @param style the style of control to construct
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
- * </ul>
- *
- * @see SWT
- * @see Widget#getStyle
- */
-public TableTreeItem(TableTreeItem parent, int style) {
- this (parent, style, parent.getItemCount());
-}
-
-/**
- * Constructs a new instance of this class given its parent
- * (which must be a <code>TableTreeItem</code>),
- * a style value describing its behavior and appearance, and the index
- * at which to place it in the items maintained by its parent.
- * <p>
- * The style value is either one of the style constants defined in
- * class <code>SWT</code> which is applicable to instances of this
- * class, or must be built by <em>bitwise OR</em>'ing together
- * (that is, using the <code>int</code> "|" operator) two or more
- * of those <code>SWT</code> style constants. The class description
- * lists the style constants that are applicable to the class.
- * Style bits are also inherited from superclasses.
- * </p>
- *
- * @param parentItem a composite control which will be the parent of the new instance (cannot be null)
- * @param style the style of control to construct
- * @param index the index to store the receiver in its parent
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
- * </ul>
- *
- * @see SWT
- * @see Widget#getStyle
- */
-public TableTreeItem(TableTreeItem parent, int style, int index) {
- this (parent.getParent(), parent, style, index);
-}
-
-TableTreeItem(TableTree parent, TableTreeItem parentItem, int style, int index) {
- super(parent, style);
- this.parent = parent;
- this.parentItem = parentItem;
- if (parentItem == null) {
-
- /* Root items are visible immediately */
- int tableIndex = parent.addItem(this, index);
- tableItem = new TableItem(parent.getTable(), style, tableIndex);
- tableItem.setData(TableTree.ITEMID, this);
- addCheck();
- /*
- * Feature in the Table. The table uses the first image that
- * is inserted into the table to size the table rows. If the
- * user is allowed to insert the first image, this will cause
- * the +/- images to be scaled. The fix is to insert a dummy
- * image to force the size.
- */
- if (parent.sizeImage == null) {
- int itemHeight = parent.getItemHeight();
- parent.sizeImage = new Image(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);
- }
-}
-void addCheck() {
- Table table = parent.getTable();
- if ((table.getStyle() & SWT.CHECK) == 0) return;
- tableItem.setChecked(checked);
- tableItem.setGrayed(grayed);
-}
-void addItem(TableTreeItem item, int index) {
- if (item == null) 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);
-}
-
-/**
- * Returns the receiver's background color.
- *
- * @return the background color
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @since 2.0
- *
- */
-public Color getBackground () {
- checkWidget ();
- return (background == null) ? parent.getBackground() : background;
-}
-
-/**
- * Returns a rectangle describing the receiver's size and location
- * relative to its parent.
- *
- * @return the receiver's bounding rectangle
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public Rectangle getBounds (int index) {
- checkWidget();
- if (tableItem != null) {
- return tableItem.getBounds(index);
- } else {
- return new Rectangle(0, 0, 0, 0);
- }
-}
-/**
- * Returns <code>true</code> if the receiver is checked,
- * and false otherwise. When the parent does not have
- * the <code>CHECK style, return false.
- *
- * @return the checked state of the checkbox
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public boolean getChecked () {
- checkWidget();
- if (tableItem == null) return checked;
- return tableItem.getChecked();
-}
-
-/**
- * Returns <code>true</code> if the receiver is grayed,
- * and false otherwise. When the parent does not have
- * the <code>CHECK</code> style, return false.
- *
- * @return the grayed state of the checkbox
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @since 2.1
- */
-public boolean getGrayed () {
- checkWidget();
- if (tableItem == null) return grayed;
- return tableItem.getGrayed();
-}
-
-public Display getDisplay () {
- TableTree parent = this.parent;
- if (parent == null) throw new SWTError (SWT.ERROR_WIDGET_DISPOSED);
- return parent.getDisplay ();
-}
-
-/**
- * Returns <code>true</code> if the receiver is expanded,
- * and false otherwise.
- * <p>
- *
- * @return the expanded state
- */
-public boolean getExpanded () {
- //checkWidget();
- return expanded;
-}
-
-/**
- * Returns the foreground color that the receiver will use to draw.
- *
- * @return the receiver's foreground color
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @since 2.0
- *
- */
-public Color getForeground () {
- checkWidget ();
- return (foreground == null) ? parent.getForeground() : foreground;
-}
-/**
- * Gets the first image.
- * <p>
- * The image in column 0 is reserved for the [+] and [-]
- * images of the tree, therefore getImage(0) will return null.
- *
- * @return the image at index 0
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public Image getImage () {
- checkWidget();
- return getImage(0);
-}
-
-/**
- * Gets the image at the specified index.
- * <p>
- * Indexing is zero based. The image can be null.
- * The image in column 0 is reserved for the [+] and [-]
- * images of the tree, therefore getImage(0) will return null.
- * Return null if the index is out of range.
- *
- * @param index the index of the image
- * @return the image at the specified index or null
- */
-public Image getImage (int index) {
- //checkWidget();
- if (0 < index && index < images.length) return images[index];
- return null;
-}
-
-int getIndent() {
- if (parentItem == null) return 0;
- return parentItem.getIndent() + 1;
-}
-
-/**
- * Returns the number of items contained in the receiver
- * that are direct item children of the receiver.
- *
- * @return the number of items
- */
-public int getItemCount () {
- //checkWidget();
- return items.length;
-}
-
-/**
- * Returns an array of <code>TableTreeItem</code>s which are the
- * direct item children of the receiver.
- * <p>
- * Note: This is not the actual structure used by the receiver
- * to maintain its list of items, so modifying the array will
- * not affect the receiver.
- * </p>
- *
- * @return the receiver's items
- */
-public TableTreeItem[] getItems () {
- //checkWidget();
- TableTreeItem[] newItems = new TableTreeItem[items.length];
- System.arraycopy(items, 0, newItems, 0, items.length);
- return newItems;
-}
-
-TableTreeItem getItem(TableItem tableItem) {
- if (tableItem == null) return null;
- if (this.tableItem == tableItem) return this;
- for (int i = 0; i < items.length; i++) {
- TableTreeItem item = items[i].getItem(tableItem);
- if (item != null) return item;
- }
- return null;
-}
-
-/**
- * Returns the receiver's parent, which must be a <code>TableTree</code>.
- *
- * @return the receiver's parent
- */
-public TableTree getParent () {
- //checkWidget();
- return parent;
-}
-
-/**
- * Returns the receiver's parent item, which must be a
- * <code>TableTreeItem</code> or null when the receiver is a
- * root.
- *
- * @return the receiver's parent item
- */
-public TableTreeItem getParentItem () {
- //checkWidget();
- return parentItem;
-}
-public String getText () {
- checkWidget();
- return getText(0);
-}
-
-/**
- * Gets the item text at the specified index.
- * <p>
- * Indexing is zero based.
- *
- * This operation will fail when the index is out
- * of range or an item could not be queried from
- * the OS.
- *
- * @param index the index of the item
- * @return the item text at the specified index, which can be null
- */
-public String getText(int index) {
- //checkWidget();
- if (0 <= index && index < texts.length) return texts[index];
- return null;
-}
-
-boolean getVisible () {
- return tableItem != null;
-}
-
-/**
- * Gets the index of the specified item.
- *
- * <p>The widget is searched starting at 0 until an
- * item is found that is equal to the search item.
- * If no item is found, -1 is returned. Indexing
- * is zero based. This index is relative to the parent only.
- *
- * @param item the search item
- * @return the index of the item or -1 if the item is not found
- *
- */
-public int indexOf (TableTreeItem item) {
- //checkWidget();
- for (int i = 0; i < items.length; i++) {
- if (items[i] == item) return i;
- }
- return -1;
-}
-
-void expandAll(boolean notify) {
- if (items.length == 0) return;
- if (!expanded) {
- setExpanded(true);
- if (notify) {
- Event event = new Event();
- event.item = this;
- parent.notifyListeners(SWT.Expand, event);
- }
- }
- for (int i = 0; i < items.length; i++) {
- items[i].expandAll(notify);
- }
-}
-int expandedIndexOf (TableTreeItem item) {
- int index = 0;
- for (int i = 0; i < items.length; i++) {
- if (items[i] == item) return index;
- if (items[i].expanded) index += items[i].visibleChildrenCount ();
- index++;
- }
- return -1;
-}
-
-int visibleChildrenCount () {
- int count = 0;
- for (int i = 0; i < items.length; i++) {
- if (items[i].getVisible ()) {
- count += 1 + items[i].visibleChildrenCount ();
- }
- }
- return count;
-}
-
-public void dispose () {
- if (isDisposed()) return;
- for (int i = items.length - 1; i >= 0; i--) {
- items[i].dispose();
- }
- super.dispose();
- if (!parent.inDispose) {
- if (parentItem != null) {
- parentItem.removeItem(this);
- } else {
- parent.removeItem(this);
- }
- if (tableItem != null) tableItem.dispose();
- }
- items = null;
- parentItem = null;
- parent = null;
- images = null;
- texts = null;
- tableItem = null;
- foreground = null;
- background = null;
-}
-
-void removeItem(TableTreeItem item) {
- int index = 0;
- while (index < items.length && items[index] != item) index++;
- if (index == items.length) return;
- TableTreeItem[] newItems = new TableTreeItem[items.length - 1];
- System.arraycopy(items, 0, newItems, 0, index);
- System.arraycopy(items, index + 1, newItems, index, items.length - index - 1);
- items = newItems;
- if (items.length == 0) {
- if (tableItem != null) tableItem.setImage(0, null);
- }
-}
-
-/**
- * Sets the receiver's background color to the color specified
- * by the argument, or to the default system color for the item
- * if the argument is null.
- *
- * @param color the new color (or null)
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_INVALID_ARGUMENT - if the argument has been disposed</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @since 2.0
- *
- */
-public void setBackground (Color color) {
- checkWidget ();
- if (color != null && color.isDisposed ()) {
- SWT.error (SWT.ERROR_INVALID_ARGUMENT);
- }
- if (tableItem != null) {
- tableItem.setBackground(color);
- }
- background = color;
-}
-
-/**
- * Sets the checked state of the checkbox for this item. This state change
- * only applies if the Table was created with the SWT.CHECK style.
- *
- * @param checked the new checked state of the checkbox
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public void setChecked (boolean checked) {
- checkWidget();
- Table table = parent.getTable();
- if ((table.getStyle() & SWT.CHECK) == 0) return;
- if (tableItem != null) {
- tableItem.setChecked(checked);
- }
- this.checked = checked;
-}
-
-/**
- * Sets the grayed state of the checkbox for this item. This state change
- * only applies if the Table was created with the SWT.CHECK style.
- *
- * @param grayed the new grayed state of the checkbox;
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @since 2.1
- */
-public void setGrayed (boolean grayed) {
- checkWidget();
- Table table = parent.getTable();
- if ((table.getStyle() & SWT.CHECK) == 0) return;
- if (tableItem != null) {
- tableItem.setGrayed(grayed);
- }
- this.grayed = grayed;
-}
-
-/**
- * Sets the expanded state.
- * <p>
- * @param expanded the new expanded state.
- *
- * @exception 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) {
- checkWidget();
- 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 receiver's foreground color to the color specified
- * by the argument, or to the default system color for the item
- * if the argument is null.
- *
- * @param color the new color (or null)
- *
- * @since 2.0
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_INVALID_ARGUMENT - if the argument has been disposed</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @since 2.0
- *
- */
-public void setForeground (Color color) {
- checkWidget ();
- if (color != null && color.isDisposed ()) {
- SWT.error (SWT.ERROR_INVALID_ARGUMENT);
- }
- if (tableItem != null) {
- tableItem.setForeground(color);
- }
- foreground = color;
-}
-
-/**
- * Sets the image at an index.
- * <p>
- * The image can be null.
- * The image in column 0 is reserved for the [+] and [-]
- * images of the tree, therefore do nothing if index is 0.
- *
- * @param image the new image or null
- *
- * @exception 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) {
- checkWidget();
- int columnCount = Math.max(parent.getTable().getColumnCount(), 1);
- if (index <= 0 || index >= columnCount) return;
- if (images.length < columnCount) {
- Image[] newImages = new Image[columnCount];
- System.arraycopy(images, 0, newImages, 0, images.length);
- images = newImages;
- }
- images[index] = image;
- if (tableItem != null) tableItem.setImage(index, image);
-}
-
-/**
- * Sets the first image.
- * <p>
- * The image can be null.
- * The image in column 0 is reserved for the [+] and [-]
- * images of the tree, therefore do nothing.
- *
- * @param image the new image or null
- *
- * @exception 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 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) {
- checkWidget();
- int columnCount = Math.max(parent.getTable().getColumnCount(), 1);
- if (index < 0 || index >= columnCount) return;
- if (texts.length < columnCount) {
- String[] newTexts = new String[columnCount];
- System.arraycopy(texts, 0, newTexts, 0, texts.length);
- texts = newTexts;
- }
- texts[index] = text;
- if (tableItem != null) tableItem.setText(index, text);
-}
-public void setText (String string) {
- setText(0, string);
-}
-
-void setVisible (boolean show) {
- if (parentItem == null) return; // this is a root and can not be toggled between visible and hidden
- if (getVisible() == show) return;
-
- if (show) {
- if (!parentItem.getVisible()) return; // parentItem must already be visible
- // create underlying table item and set data in table item to stored data
- Table table = parent.getTable();
- int parentIndex = table.indexOf(parentItem.tableItem);
- int index = parentItem.expandedIndexOf(this) + parentIndex + 1;
- if (index < 0) return;
- tableItem = new TableItem(table, getStyle(), index);
- tableItem.setData(TableTree.ITEMID, this);
- tableItem.setImageIndent(getIndent());
- if (background != null) tableItem.setBackground(background);
- if (foreground != null) tableItem.setForeground(foreground);
- 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;
- }
-}
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+import org.eclipse.swt.*;
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.widgets.*;
+
+/**
+ * A TableTreeItem is a selectable user interface object
+ * that represents an item in a 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;
+ Color background;
+ Color foreground;
+ boolean expanded;
+ boolean checked;
+ boolean grayed;
+
+/**
+ * Constructs a new instance of this class given its parent
+ * (which must be a <code>TableTree</code>)
+ * and a style value describing its behavior and appearance.
+ * The item is added to the end of the items maintained by its parent.
+ * <p>
+ * The style value is either one of the style constants defined in
+ * class <code>SWT</code> which is applicable to instances of this
+ * class, or must be built by <em>bitwise OR</em>'ing together
+ * (that is, using the <code>int</code> "|" operator) two or more
+ * of those <code>SWT</code> style constants. The class description
+ * lists the style constants that are applicable to the class.
+ * Style bits are also inherited from superclasses.
+ * </p>
+ *
+ * @param parent a composite control which will be the parent of the new instance (cannot be null)
+ * @param style the style of control to construct
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
+ * </ul>
+ *
+ * @see SWT
+ * @see Widget#getStyle
+ */
+public TableTreeItem(TableTree parent, int style) {
+ this (parent, style, parent.getItemCount());
+}
+
+/**
+ * Constructs a new instance of this class given its parent
+ * (which must be a <code>TableTree</code>,
+ * a style value describing its behavior and appearance, and the index
+ * at which to place it in the items maintained by its parent.
+ * <p>
+ * The style value is either one of the style constants defined in
+ * class <code>SWT</code> which is applicable to instances of this
+ * class, or must be built by <em>bitwise OR</em>'ing together
+ * (that is, using the <code>int</code> "|" operator) two or more
+ * of those <code>SWT</code> style constants. The class description
+ * lists the style constants that are applicable to the class.
+ * Style bits are also inherited from superclasses.
+ * </p>
+ *
+ * @param parent a composite control which will be the parent of the new instance (cannot be null)
+ * @param style the style of control to construct
+ * @param index the index to store the receiver in its parent
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
+ * </ul>
+ *
+ * @see SWT
+ * @see Widget#getStyle
+ */
+public TableTreeItem(TableTree parent, int style, int index) {
+ this (parent, null, style, index);
+}
+
+/**
+ * Constructs a new instance of this class given its parent
+ * (which must be a <code>TableTreeItem</code>)
+ * and a style value describing its behavior and appearance.
+ * The item is added to the end of the items maintained by its parent.
+ * <p>
+ * The style value is either one of the style constants defined in
+ * class <code>SWT</code> which is applicable to instances of this
+ * class, or must be built by <em>bitwise OR</em>'ing together
+ * (that is, using the <code>int</code> "|" operator) two or more
+ * of those <code>SWT</code> style constants. The class description
+ * lists the style constants that are applicable to the class.
+ * Style bits are also inherited from superclasses.
+ * </p>
+ *
+ * @param parentItem a composite control which will be the parent of the new instance (cannot be null)
+ * @param style the style of control to construct
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
+ * </ul>
+ *
+ * @see SWT
+ * @see Widget#getStyle
+ */
+public TableTreeItem(TableTreeItem parent, int style) {
+ this (parent, style, parent.getItemCount());
+}
+
+/**
+ * Constructs a new instance of this class given its parent
+ * (which must be a <code>TableTreeItem</code>),
+ * a style value describing its behavior and appearance, and the index
+ * at which to place it in the items maintained by its parent.
+ * <p>
+ * The style value is either one of the style constants defined in
+ * class <code>SWT</code> which is applicable to instances of this
+ * class, or must be built by <em>bitwise OR</em>'ing together
+ * (that is, using the <code>int</code> "|" operator) two or more
+ * of those <code>SWT</code> style constants. The class description
+ * lists the style constants that are applicable to the class.
+ * Style bits are also inherited from superclasses.
+ * </p>
+ *
+ * @param parentItem a composite control which will be the parent of the new instance (cannot be null)
+ * @param style the style of control to construct
+ * @param index the index to store the receiver in its parent
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
+ * </ul>
+ *
+ * @see SWT
+ * @see Widget#getStyle
+ */
+public TableTreeItem(TableTreeItem parent, int style, int index) {
+ this (parent.getParent(), parent, style, index);
+}
+
+TableTreeItem(TableTree parent, TableTreeItem parentItem, int style, int index) {
+ super(parent, style);
+ this.parent = parent;
+ this.parentItem = parentItem;
+ if (parentItem == null) {
+
+ /* Root items are visible immediately */
+ int tableIndex = parent.addItem(this, index);
+ tableItem = new TableItem(parent.getTable(), style, tableIndex);
+ tableItem.setData(TableTree.ITEMID, this);
+ addCheck();
+ /*
+ * Feature in the Table. The table uses the first image that
+ * is inserted into the table to size the table rows. If the
+ * user is allowed to insert the first image, this will cause
+ * the +/- images to be scaled. The fix is to insert a dummy
+ * image to force the size.
+ */
+ if (parent.sizeImage == null) {
+ int itemHeight = parent.getItemHeight();
+ parent.sizeImage = new Image(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);
+ }
+}
+void addCheck() {
+ Table table = parent.getTable();
+ if ((table.getStyle() & SWT.CHECK) == 0) return;
+ tableItem.setChecked(checked);
+ tableItem.setGrayed(grayed);
+}
+void addItem(TableTreeItem item, int index) {
+ if (item == null) 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);
+}
+
+/**
+ * Returns the receiver's background color.
+ *
+ * @return the background color
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @since 2.0
+ *
+ */
+public Color getBackground () {
+ checkWidget ();
+ return (background == null) ? parent.getBackground() : background;
+}
+
+/**
+ * Returns a rectangle describing the receiver's size and location
+ * relative to its parent.
+ *
+ * @return the receiver's bounding rectangle
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public Rectangle getBounds (int index) {
+ checkWidget();
+ if (tableItem != null) {
+ return tableItem.getBounds(index);
+ } else {
+ return new Rectangle(0, 0, 0, 0);
+ }
+}
+/**
+ * Returns <code>true</code> if the receiver is checked,
+ * and false otherwise. When the parent does not have
+ * the <code>CHECK style, return false.
+ *
+ * @return the checked state of the checkbox
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public boolean getChecked () {
+ checkWidget();
+ if (tableItem == null) return checked;
+ return tableItem.getChecked();
+}
+
+/**
+ * Returns <code>true</code> if the receiver is grayed,
+ * and false otherwise. When the parent does not have
+ * the <code>CHECK</code> style, return false.
+ *
+ * @return the grayed state of the checkbox
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @since 2.1
+ */
+public boolean getGrayed () {
+ checkWidget();
+ if (tableItem == null) return grayed;
+ return tableItem.getGrayed();
+}
+
+public Display getDisplay () {
+ TableTree parent = this.parent;
+ if (parent == null) throw new SWTError (SWT.ERROR_WIDGET_DISPOSED);
+ return parent.getDisplay ();
+}
+
+/**
+ * Returns <code>true</code> if the receiver is expanded,
+ * and false otherwise.
+ * <p>
+ *
+ * @return the expanded state
+ */
+public boolean getExpanded () {
+ //checkWidget();
+ return expanded;
+}
+
+/**
+ * Returns the foreground color that the receiver will use to draw.
+ *
+ * @return the receiver's foreground color
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @since 2.0
+ *
+ */
+public Color getForeground () {
+ checkWidget ();
+ return (foreground == null) ? parent.getForeground() : foreground;
+}
+/**
+ * Gets the first image.
+ * <p>
+ * The image in column 0 is reserved for the [+] and [-]
+ * images of the tree, therefore getImage(0) will return null.
+ *
+ * @return the image at index 0
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public Image getImage () {
+ checkWidget();
+ return getImage(0);
+}
+
+/**
+ * Gets the image at the specified index.
+ * <p>
+ * Indexing is zero based. The image can be null.
+ * The image in column 0 is reserved for the [+] and [-]
+ * images of the tree, therefore getImage(0) will return null.
+ * Return null if the index is out of range.
+ *
+ * @param index the index of the image
+ * @return the image at the specified index or null
+ */
+public Image getImage (int index) {
+ //checkWidget();
+ if (0 < index && index < images.length) return images[index];
+ return null;
+}
+
+int getIndent() {
+ if (parentItem == null) return 0;
+ return parentItem.getIndent() + 1;
+}
+
+/**
+ * Returns the number of items contained in the receiver
+ * that are direct item children of the receiver.
+ *
+ * @return the number of items
+ */
+public int getItemCount () {
+ //checkWidget();
+ return items.length;
+}
+
+/**
+ * Returns an array of <code>TableTreeItem</code>s which are the
+ * direct item children of the receiver.
+ * <p>
+ * Note: This is not the actual structure used by the receiver
+ * to maintain its list of items, so modifying the array will
+ * not affect the receiver.
+ * </p>
+ *
+ * @return the receiver's items
+ */
+public TableTreeItem[] getItems () {
+ //checkWidget();
+ TableTreeItem[] newItems = new TableTreeItem[items.length];
+ System.arraycopy(items, 0, newItems, 0, items.length);
+ return newItems;
+}
+
+TableTreeItem getItem(TableItem tableItem) {
+ if (tableItem == null) return null;
+ if (this.tableItem == tableItem) return this;
+ for (int i = 0; i < items.length; i++) {
+ TableTreeItem item = items[i].getItem(tableItem);
+ if (item != null) return item;
+ }
+ return null;
+}
+
+/**
+ * Returns the receiver's parent, which must be a <code>TableTree</code>.
+ *
+ * @return the receiver's parent
+ */
+public TableTree getParent () {
+ //checkWidget();
+ return parent;
+}
+
+/**
+ * Returns the receiver's parent item, which must be a
+ * <code>TableTreeItem</code> or null when the receiver is a
+ * root.
+ *
+ * @return the receiver's parent item
+ */
+public TableTreeItem getParentItem () {
+ //checkWidget();
+ return parentItem;
+}
+public String getText () {
+ checkWidget();
+ return getText(0);
+}
+
+/**
+ * Gets the item text at the specified index.
+ * <p>
+ * Indexing is zero based.
+ *
+ * This operation will fail when the index is out
+ * of range or an item could not be queried from
+ * the OS.
+ *
+ * @param index the index of the item
+ * @return the item text at the specified index, which can be null
+ */
+public String getText(int index) {
+ //checkWidget();
+ if (0 <= index && index < texts.length) return texts[index];
+ return null;
+}
+
+boolean getVisible () {
+ return tableItem != null;
+}
+
+/**
+ * Gets the index of the specified item.
+ *
+ * <p>The widget is searched starting at 0 until an
+ * item is found that is equal to the search item.
+ * If no item is found, -1 is returned. Indexing
+ * is zero based. This index is relative to the parent only.
+ *
+ * @param item the search item
+ * @return the index of the item or -1 if the item is not found
+ *
+ */
+public int indexOf (TableTreeItem item) {
+ //checkWidget();
+ for (int i = 0; i < items.length; i++) {
+ if (items[i] == item) return i;
+ }
+ return -1;
+}
+
+void expandAll(boolean notify) {
+ if (items.length == 0) return;
+ if (!expanded) {
+ setExpanded(true);
+ if (notify) {
+ Event event = new Event();
+ event.item = this;
+ parent.notifyListeners(SWT.Expand, event);
+ }
+ }
+ for (int i = 0; i < items.length; i++) {
+ items[i].expandAll(notify);
+ }
+}
+int expandedIndexOf (TableTreeItem item) {
+ int index = 0;
+ for (int i = 0; i < items.length; i++) {
+ if (items[i] == item) return index;
+ if (items[i].expanded) index += items[i].visibleChildrenCount ();
+ index++;
+ }
+ return -1;
+}
+
+int visibleChildrenCount () {
+ int count = 0;
+ for (int i = 0; i < items.length; i++) {
+ if (items[i].getVisible ()) {
+ count += 1 + items[i].visibleChildrenCount ();
+ }
+ }
+ return count;
+}
+
+public void dispose () {
+ if (isDisposed()) return;
+ for (int i = items.length - 1; i >= 0; i--) {
+ items[i].dispose();
+ }
+ super.dispose();
+ if (!parent.inDispose) {
+ if (parentItem != null) {
+ parentItem.removeItem(this);
+ } else {
+ parent.removeItem(this);
+ }
+ if (tableItem != null) tableItem.dispose();
+ }
+ items = null;
+ parentItem = null;
+ parent = null;
+ images = null;
+ texts = null;
+ tableItem = null;
+ foreground = null;
+ background = null;
+}
+
+void removeItem(TableTreeItem item) {
+ int index = 0;
+ while (index < items.length && items[index] != item) index++;
+ if (index == items.length) return;
+ TableTreeItem[] newItems = new TableTreeItem[items.length - 1];
+ System.arraycopy(items, 0, newItems, 0, index);
+ System.arraycopy(items, index + 1, newItems, index, items.length - index - 1);
+ items = newItems;
+ if (items.length == 0) {
+ if (tableItem != null) tableItem.setImage(0, null);
+ }
+}
+
+/**
+ * Sets the receiver's background color to the color specified
+ * by the argument, or to the default system color for the item
+ * if the argument is null.
+ *
+ * @param color the new color (or null)
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_INVALID_ARGUMENT - if the argument has been disposed</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @since 2.0
+ *
+ */
+public void setBackground (Color color) {
+ checkWidget ();
+ if (color != null && color.isDisposed ()) {
+ SWT.error (SWT.ERROR_INVALID_ARGUMENT);
+ }
+ if (tableItem != null) {
+ tableItem.setBackground(color);
+ }
+ background = color;
+}
+
+/**
+ * Sets the checked state of the checkbox for this item. This state change
+ * only applies if the Table was created with the SWT.CHECK style.
+ *
+ * @param checked the new checked state of the checkbox
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setChecked (boolean checked) {
+ checkWidget();
+ Table table = parent.getTable();
+ if ((table.getStyle() & SWT.CHECK) == 0) return;
+ if (tableItem != null) {
+ tableItem.setChecked(checked);
+ }
+ this.checked = checked;
+}
+
+/**
+ * Sets the grayed state of the checkbox for this item. This state change
+ * only applies if the Table was created with the SWT.CHECK style.
+ *
+ * @param grayed the new grayed state of the checkbox;
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @since 2.1
+ */
+public void setGrayed (boolean grayed) {
+ checkWidget();
+ Table table = parent.getTable();
+ if ((table.getStyle() & SWT.CHECK) == 0) return;
+ if (tableItem != null) {
+ tableItem.setGrayed(grayed);
+ }
+ this.grayed = grayed;
+}
+
+/**
+ * Sets the expanded state.
+ * <p>
+ * @param expanded the new expanded state.
+ *
+ * @exception 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) {
+ checkWidget();
+ 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 receiver's foreground color to the color specified
+ * by the argument, or to the default system color for the item
+ * if the argument is null.
+ *
+ * @param color the new color (or null)
+ *
+ * @since 2.0
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_INVALID_ARGUMENT - if the argument has been disposed</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @since 2.0
+ *
+ */
+public void setForeground (Color color) {
+ checkWidget ();
+ if (color != null && color.isDisposed ()) {
+ SWT.error (SWT.ERROR_INVALID_ARGUMENT);
+ }
+ if (tableItem != null) {
+ tableItem.setForeground(color);
+ }
+ foreground = color;
+}
+
+/**
+ * Sets the image at an index.
+ * <p>
+ * The image can be null.
+ * The image in column 0 is reserved for the [+] and [-]
+ * images of the tree, therefore do nothing if index is 0.
+ *
+ * @param image the new image or null
+ *
+ * @exception 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) {
+ checkWidget();
+ int columnCount = Math.max(parent.getTable().getColumnCount(), 1);
+ if (index <= 0 || index >= columnCount) return;
+ if (images.length < columnCount) {
+ Image[] newImages = new Image[columnCount];
+ System.arraycopy(images, 0, newImages, 0, images.length);
+ images = newImages;
+ }
+ images[index] = image;
+ if (tableItem != null) tableItem.setImage(index, image);
+}
+
+/**
+ * Sets the first image.
+ * <p>
+ * The image can be null.
+ * The image in column 0 is reserved for the [+] and [-]
+ * images of the tree, therefore do nothing.
+ *
+ * @param image the new image or null
+ *
+ * @exception 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 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) {
+ checkWidget();
+ int columnCount = Math.max(parent.getTable().getColumnCount(), 1);
+ if (index < 0 || index >= columnCount) return;
+ if (texts.length < columnCount) {
+ String[] newTexts = new String[columnCount];
+ System.arraycopy(texts, 0, newTexts, 0, texts.length);
+ texts = newTexts;
+ }
+ texts[index] = text;
+ if (tableItem != null) tableItem.setText(index, text);
+}
+public void setText (String string) {
+ setText(0, string);
+}
+
+void setVisible (boolean show) {
+ if (parentItem == null) return; // this is a root and can not be toggled between visible and hidden
+ if (getVisible() == show) return;
+
+ if (show) {
+ if (!parentItem.getVisible()) return; // parentItem must already be visible
+ // create underlying table item and set data in table item to stored data
+ Table table = parent.getTable();
+ int parentIndex = table.indexOf(parentItem.tableItem);
+ int index = parentItem.expandedIndexOf(this) + parentIndex + 1;
+ if (index < 0) return;
+ tableItem = new TableItem(table, getStyle(), index);
+ tableItem.setData(TableTree.ITEMID, this);
+ tableItem.setImageIndent(getIndent());
+ if (background != null) tableItem.setBackground(background);
+ if (foreground != null) tableItem.setForeground(foreground);
+ 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/TextChangeListener.java b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/TextChangeListener.java
index d3efd17bba..682da982db 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/TextChangeListener.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/TextChangeListener.java
@@ -1,57 +1,57 @@
-package org.eclipse.swt.custom;
-
-/*
+package org.eclipse.swt.custom;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-import org.eclipse.swt.internal.SWTEventListener;
-
-/**
- * The StyledText widget implements this listener to receive
- * notifications when changes to the model occur.
- * It is not intended to be implemented by clients or by
- * implementors of StyledTextContent.
- * Clients should listen to the ModifyEvent or ExtendedModifyEvent
- * that is sent by the StyledText widget to receive text change
- * notifications.
- * Implementors of StyledTextContent should call the textChanging
- * and textChanged methods when text changes occur as described
- * below. If the entire text is replaced the textSet method
- * should be called instead.
- */
-public interface TextChangeListener extends SWTEventListener {
-
-/**
- * This method is called when the content is about to be changed.
- * Callers also need to call the textChanged method after the
- * content change has been applied. The widget only updates the
- * screen properly when it receives both events.
- *
- * @param event the text changing event. All event fields need
- * to be set by the sender.
- * @see TextChangingEvent
- */
-public void textChanging(TextChangingEvent event);
-/**
- * This method is called when the content has changed.
- * Callers need to have called the textChanging method prior to
- * applying the content change and calling this method. The widget
- * only updates the screen properly when it receives both events.
- *
- * @param event the text changed event
- */
-public void textChanged(TextChangedEvent event);
-/**
- * This method is called instead of the textChanging/textChanged
- * combination when the entire old content has been replaced
- * (e.g., by a call to StyledTextContent.setText()).
- *
- * @param event the text changed event
- */
-public void textSet(TextChangedEvent event);
-}
-
-
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+import org.eclipse.swt.internal.SWTEventListener;
+
+/**
+ * The StyledText widget implements this listener to receive
+ * notifications when changes to the model occur.
+ * It is not intended to be implemented by clients or by
+ * implementors of StyledTextContent.
+ * Clients should listen to the ModifyEvent or ExtendedModifyEvent
+ * that is sent by the StyledText widget to receive text change
+ * notifications.
+ * Implementors of StyledTextContent should call the textChanging
+ * and textChanged methods when text changes occur as described
+ * below. If the entire text is replaced the textSet method
+ * should be called instead.
+ */
+public interface TextChangeListener extends SWTEventListener {
+
+/**
+ * This method is called when the content is about to be changed.
+ * Callers also need to call the textChanged method after the
+ * content change has been applied. The widget only updates the
+ * screen properly when it receives both events.
+ *
+ * @param event the text changing event. All event fields need
+ * to be set by the sender.
+ * @see TextChangingEvent
+ */
+public void textChanging(TextChangingEvent event);
+/**
+ * This method is called when the content has changed.
+ * Callers need to have called the textChanging method prior to
+ * applying the content change and calling this method. The widget
+ * only updates the screen properly when it receives both events.
+ *
+ * @param event the text changed event
+ */
+public void textChanged(TextChangedEvent event);
+/**
+ * This method is called instead of the textChanging/textChanged
+ * combination when the entire old content has been replaced
+ * (e.g., by a call to StyledTextContent.setText()).
+ *
+ * @param event the text changed event
+ */
+public void textSet(TextChangedEvent event);
+}
+
+
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
index b76b0cc42a..5c4749959c 100755
--- 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
@@ -1,26 +1,26 @@
-package org.eclipse.swt.custom;
-/*
+package org.eclipse.swt.custom;
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-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 {
-/**
- * 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);
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+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 {
+/**
+ * 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);
+}
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/TextChangingEvent.java b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/TextChangingEvent.java
index 19ac181426..0668a05f64 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/TextChangingEvent.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/TextChangingEvent.java
@@ -1,63 +1,63 @@
-package org.eclipse.swt.custom;
-
-/*
+package org.eclipse.swt.custom;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-import org.eclipse.swt.events.*;
-
-/**
- * This event is sent by the StyledTextContent implementor when a change
- * to the text is about to occur.
- */
-public class TextChangingEvent extends TypedEvent {
- /**
- * Start offset of the text that is going to be replaced
- */
- public int start;
- /**
- * Text that is going to be inserted or empty string
- * if no text will be inserted
- */
- public String newText;
- /**
- * Length of text that is going to be replaced
- */
- public int replaceCharCount;
- /**
- * Length of text that is going to be inserted
- */
- public int newCharCount;
- /**
- * Number of lines that are going to be replaced
- */
- public int replaceLineCount;
- /**
- * Number of new lines that are going to be inserted
- */
- public int newLineCount;
-
-/**
- * Create the TextChangedEvent to be used by the StyledTextContent implementor.
- * <p>
- *
- * @param source the object that will be sending the new TextChangingEvent,
- * cannot be null
- */
-public TextChangingEvent(StyledTextContent source) {
- super(source);
-}
-TextChangingEvent(StyledTextContent source, StyledTextEvent e) {
- super(source);
- start = e.start;
- replaceCharCount = e.replaceCharCount;
- newCharCount = e.newCharCount;
- replaceLineCount = e.replaceLineCount;
- newLineCount = e.newLineCount;
- newText = e.text;
-}
-
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+import org.eclipse.swt.events.*;
+
+/**
+ * This event is sent by the StyledTextContent implementor when a change
+ * to the text is about to occur.
+ */
+public class TextChangingEvent extends TypedEvent {
+ /**
+ * Start offset of the text that is going to be replaced
+ */
+ public int start;
+ /**
+ * Text that is going to be inserted or empty string
+ * if no text will be inserted
+ */
+ public String newText;
+ /**
+ * Length of text that is going to be replaced
+ */
+ public int replaceCharCount;
+ /**
+ * Length of text that is going to be inserted
+ */
+ public int newCharCount;
+ /**
+ * Number of lines that are going to be replaced
+ */
+ public int replaceLineCount;
+ /**
+ * Number of new lines that are going to be inserted
+ */
+ public int newLineCount;
+
+/**
+ * Create the TextChangedEvent to be used by the StyledTextContent implementor.
+ * <p>
+ *
+ * @param source the object that will be sending the new TextChangingEvent,
+ * cannot be null
+ */
+public TextChangingEvent(StyledTextContent source) {
+ super(source);
+}
+TextChangingEvent(StyledTextContent source, StyledTextEvent e) {
+ super(source);
+ start = e.start;
+ replaceCharCount = e.replaceCharCount;
+ newCharCount = e.newCharCount;
+ replaceLineCount = e.replaceLineCount;
+ newLineCount = e.newLineCount;
+ newText = e.text;
+}
+
}
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
index 09916eae1b..d3b80b447c 100755
--- 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
@@ -1,162 +1,162 @@
-package org.eclipse.swt.custom;
-
-/*
+package org.eclipse.swt.custom;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-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>
-* final Tree tree = new Tree(parent, SWT.FULL_SELECTION);
-* final 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
-* TreeItem item = (TreeItem)e.item;
-*
-* // 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;
- resize();
-}
-
-/**
-* Specify the Control that is to be displayed and the cell in the tree that it is to be positioned above.
-*
-* <p>Note: The Control provided as the editor <b>must</b> be created with its parent being the Tree control
-* specified in the TreeEditor constructor.
-*
-* @param editor the Control that is displayed above the cell being edited
-* @param item the TreeItem for the row of the cell being tracked by this editor
-* @param column the zero based index of the column of the cell being tracked by this editor
-*/
-public void setEditor (Control editor, TreeItem item) {
- setItem (item);
- super.setEditor (editor);
-}
-
-void resize () {
- if (tree.isDisposed()) return;
- if (item == null || item.isDisposed()) return;
- super.resize();
-}
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+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>
+* final Tree tree = new Tree(parent, SWT.FULL_SELECTION);
+* final 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
+* TreeItem item = (TreeItem)e.item;
+*
+* // 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;
+ resize();
+}
+
+/**
+* Specify the Control that is to be displayed and the cell in the tree that it is to be positioned above.
+*
+* <p>Note: The Control provided as the editor <b>must</b> be created with its parent being the Tree control
+* specified in the TreeEditor constructor.
+*
+* @param editor the Control that is displayed above the cell being edited
+* @param item the TreeItem for the row of the cell being tracked by this editor
+* @param column the zero based index of the column of the cell being tracked by this editor
+*/
+public void setEditor (Control editor, TreeItem item) {
+ setItem (item);
+ super.setEditor (editor);
+}
+
+void resize () {
+ if (tree.isDisposed()) return;
+ if (item == null || item.isDisposed()) return;
+ super.resize();
+}
+}
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
index 1af445df29..151861bbb3 100755
--- 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
@@ -1,20 +1,20 @@
-package org.eclipse.swt.custom;
-/*
+package org.eclipse.swt.custom;
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-import org.eclipse.swt.events.*;
-import org.eclipse.swt.internal.SWTEventListener;
-
-public interface VerifyKeyListener extends SWTEventListener {
-/**
- * @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);
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+import org.eclipse.swt.events.*;
+import org.eclipse.swt.internal.SWTEventListener;
+
+public interface VerifyKeyListener extends SWTEventListener {
+/**
+ * @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);
}
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
index 82da8294d5..675aa437dc 100755
--- 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
@@ -1,614 +1,614 @@
-package org.eclipse.swt.custom;
-
-/*
+package org.eclipse.swt.custom;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-import org.eclipse.swt.graphics.*;
-import org.eclipse.swt.widgets.*;
-import org.eclipse.swt.*;
-import org.eclipse.swt.events.*;
-
-/**
- * Instances of this class implement a Composite that lays out three
- * children horizontally and allows programmatic control of layout and
- * border parameters. ViewForm is used in the workbench to implement a
- * view's label/menu/toolbar local bar.
- * <p>
- * Note that although this class is a subclass of <code>Composite</code>,
- * it does not make sense to set a layout on it.
- * </p><p>
- * <dl>
- * <dt><b>Styles:</b></dt>
- * <dd>BORDER, FLAT</dd>
- * <dt><b>Events:</b></dt>
- * <dd>(None)</dd>
- * </dl>
- * <p>
- * IMPORTANT: This class is <em>not</em> intended to be subclassed.
- * </p>
- */
-
-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;
- private static final int OFFSCREEN = -200;
-/**
- * Constructs a new instance of this class given its parent
- * and a style value describing its behavior and appearance.
- * <p>
- * The style value is either one of the style constants defined in
- * class <code>SWT</code> which is applicable to instances of this
- * class, or must be built by <em>bitwise OR</em>'ing together
- * (that is, using the <code>int</code> "|" operator) two or more
- * of those <code>SWT</code> style constants. The class description
- * lists the style constants that are applicable to the class.
- * Style bits are also inherited from superclasses.
- * </p>
- *
- * @param parent a widget which will be the parent of the new instance (cannot be null)
- * @param style the style of widget to construct
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
- * </ul>
- *
- * @see SWT#BORDER
- * @see SWT#FLAT
- * @see #getStyle
- */
-public ViewForm(Composite parent, int style) {
- super(parent, checkStyle(style));
-
- 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) {
- checkWidget();
- // size of title bar area
- Point leftSize = new Point(0, 0);
- if (topLeft != null) {
- leftSize = topLeft.computeSize(SWT.DEFAULT, SWT.DEFAULT);
- leftSize.x += 1; // +1 for highlight line
- }
- 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 ||
- (wHint != SWT.DEFAULT && leftSize.x + centerSize.x + rightSize.x > wHint)) {
- size.x = leftSize.x + rightSize.x;
- size.x = Math.max(centerSize.x, size.x);
- size.y = Math.max(leftSize.y, rightSize.y) + 1; // +1 for highlight line
- 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)) + 1; // +1 for highlight line
- }
-
- 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 + 1; // +1 for line bewteen content and header
- }
-
- size.x += 2 * marginWidth;
- size.y += 2 * marginHeight;
-
- 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);
-}
-public Rectangle computeTrim (int x, int y, int width, int height) {
- checkWidget ();
- int trimX = x - BORDER_LEFT;
- int trimY = y - BORDER_TOP;
- int trimWidth = width + BORDER_LEFT + BORDER_RIGHT;
- int trimHeight = height + BORDER_TOP + BORDER_BOTTOM;
- return new Rectangle(trimX, trimY, trimWidth, trimHeight);
-}
-public Rectangle getClientArea() {
- checkWidget();
- 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.
-*
-* @return the control in the content area of the pane or null
-*/
-public Control getContent() {
- //checkWidget();
- return content;
-}
-/**
-* Returns Control that appears in the top center of the pane.
-* Typically this is a toolbar.
-*
-* @return the control in the top center of the pane or null
-*/
-public Control getTopCenter() {
- //checkWidget();
- return topCenter;
-}
-/**
-* Returns the Control that appears in the top left corner of the pane.
-* Typically this is a label such as CLabel.
-*
-* @return the control in the top left corner of the pane or null
-*/
-public Control getTopLeft() {
- //checkWidget();
- return topLeft;
-}
-/**
-* Returns the control in the top right corner of the pane.
-* Typically this is a Close button or a composite with a Menu and Close button.
-*
-* @return the control in the top right corner of the pane or null
-*/
-public Control getTopRight() {
- //checkWidget();
- return topRight;
-}
-public void layout (boolean changed) {
- checkWidget();
- 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;
-
- topLeft = null;
- topCenter = null;
- topRight = null;
- content = null;
- oldArea = 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.
-*
-* @param c the control to be displayed in the content area or null
-*
-* @exception SWTException <ul>
-* <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
-* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
-* </ul>
-*/
-public void setContent(Control content) {
- checkWidget();
- if (content != null && content.getParent() != this) {
- SWT.error(SWT.ERROR_INVALID_ARGUMENT);
- }
- if (this.content != null && !this.content.isDisposed()) {
- this.content.setBounds(OFFSCREEN, OFFSCREEN, 0, 0);
- }
- this.content = content;
- layout();
-}
-
-/**
-* 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();
-}
-/**
- * Sets the layout which is associated with the receiver to be
- * the argument which may be null.
- * <p>
- * Note : ViewForm does not use a layout class to size and position its children.
- * </p>
- *
- * @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();
- 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.
-*
-* @param c the control to be displayed in the top center or null
-*
-* @exception SWTException <ul>
-* <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
-* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
-* </ul>
-*/
-public void setTopCenter(Control topCenter) {
- checkWidget();
- if (topCenter != null && topCenter.getParent() != this) {
- SWT.error(SWT.ERROR_INVALID_ARGUMENT);
- }
- if (this.topCenter != null && !this.topCenter.isDisposed()) {
- this.topCenter.setBounds(OFFSCREEN, OFFSCREEN, 0, 0);
- }
- 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.
-*
-* @param c the control to be displayed in the top left corner or null
-*
-* @exception SWTException <ul>
-* <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
-* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
-* </ul>
-*/
-public void setTopLeft(Control c) {
- checkWidget();
- if (c != null && c.getParent() != this) {
- SWT.error(SWT.ERROR_INVALID_ARGUMENT);
- }
- if (this.topLeft != null && !this.topLeft.isDisposed()) {
- this.topLeft.setBounds(OFFSCREEN, OFFSCREEN, 0, 0);
- }
- 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.
-*
-* @param c the control to be displayed in the top right corner or null
-*
-* @exception SWTException <ul>
-* <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
-* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
-* <li>ERROR_INVALID_ARGUMENT - if the control is not a child of this ViewForm</li>
-* </ul>
-*/
-public void setTopRight(Control c) {
- checkWidget();
- if (c != null && c.getParent() != this) {
- SWT.error(SWT.ERROR_INVALID_ARGUMENT);
- }
- if (this.topRight != null && !this.topRight.isDisposed()) {
- this.topRight.setBounds(OFFSCREEN, OFFSCREEN, 0, 0);
- }
- this.topRight = c;
- layout();
-}
-/**
-* Specify whether the border should be displayed or not.
-*
-* @param show true if the border should be displayed
-*
-* @exception SWTException <ul>
-* <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
-* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
-* </ul>
-*/
-public void setBorderVisible(boolean show) {
- checkWidget();
- if (showBorder == show) return;
-
- showBorder = show;
- if (showBorder) {
- 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.
-*
-* @param show true if the topCenter will always appear on a separate line by itself
-*
-* @exception SWTException <ul>
-* <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
-* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
-* </ul>
-*/
-public void setTopCenterSeparate(boolean show) {
- checkWidget();
- separateTopCenter = show;
- layout();
-}
-
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.widgets.*;
+import org.eclipse.swt.*;
+import org.eclipse.swt.events.*;
+
+/**
+ * Instances of this class implement a Composite that lays out three
+ * children horizontally and allows programmatic control of layout and
+ * border parameters. ViewForm is used in the workbench to implement a
+ * view's label/menu/toolbar local bar.
+ * <p>
+ * Note that although this class is a subclass of <code>Composite</code>,
+ * it does not make sense to set a layout on it.
+ * </p><p>
+ * <dl>
+ * <dt><b>Styles:</b></dt>
+ * <dd>BORDER, FLAT</dd>
+ * <dt><b>Events:</b></dt>
+ * <dd>(None)</dd>
+ * </dl>
+ * <p>
+ * IMPORTANT: This class is <em>not</em> intended to be subclassed.
+ * </p>
+ */
+
+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;
+ private static final int OFFSCREEN = -200;
+/**
+ * Constructs a new instance of this class given its parent
+ * and a style value describing its behavior and appearance.
+ * <p>
+ * The style value is either one of the style constants defined in
+ * class <code>SWT</code> which is applicable to instances of this
+ * class, or must be built by <em>bitwise OR</em>'ing together
+ * (that is, using the <code>int</code> "|" operator) two or more
+ * of those <code>SWT</code> style constants. The class description
+ * lists the style constants that are applicable to the class.
+ * Style bits are also inherited from superclasses.
+ * </p>
+ *
+ * @param parent a widget which will be the parent of the new instance (cannot be null)
+ * @param style the style of widget to construct
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
+ * </ul>
+ *
+ * @see SWT#BORDER
+ * @see SWT#FLAT
+ * @see #getStyle
+ */
+public ViewForm(Composite parent, int style) {
+ super(parent, checkStyle(style));
+
+ 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) {
+ checkWidget();
+ // size of title bar area
+ Point leftSize = new Point(0, 0);
+ if (topLeft != null) {
+ leftSize = topLeft.computeSize(SWT.DEFAULT, SWT.DEFAULT);
+ leftSize.x += 1; // +1 for highlight line
+ }
+ 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 ||
+ (wHint != SWT.DEFAULT && leftSize.x + centerSize.x + rightSize.x > wHint)) {
+ size.x = leftSize.x + rightSize.x;
+ size.x = Math.max(centerSize.x, size.x);
+ size.y = Math.max(leftSize.y, rightSize.y) + 1; // +1 for highlight line
+ 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)) + 1; // +1 for highlight line
+ }
+
+ 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 + 1; // +1 for line bewteen content and header
+ }
+
+ size.x += 2 * marginWidth;
+ size.y += 2 * marginHeight;
+
+ 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);
+}
+public Rectangle computeTrim (int x, int y, int width, int height) {
+ checkWidget ();
+ int trimX = x - BORDER_LEFT;
+ int trimY = y - BORDER_TOP;
+ int trimWidth = width + BORDER_LEFT + BORDER_RIGHT;
+ int trimHeight = height + BORDER_TOP + BORDER_BOTTOM;
+ return new Rectangle(trimX, trimY, trimWidth, trimHeight);
+}
+public Rectangle getClientArea() {
+ checkWidget();
+ 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.
+*
+* @return the control in the content area of the pane or null
+*/
+public Control getContent() {
+ //checkWidget();
+ return content;
+}
+/**
+* Returns Control that appears in the top center of the pane.
+* Typically this is a toolbar.
+*
+* @return the control in the top center of the pane or null
+*/
+public Control getTopCenter() {
+ //checkWidget();
+ return topCenter;
+}
+/**
+* Returns the Control that appears in the top left corner of the pane.
+* Typically this is a label such as CLabel.
+*
+* @return the control in the top left corner of the pane or null
+*/
+public Control getTopLeft() {
+ //checkWidget();
+ return topLeft;
+}
+/**
+* Returns the control in the top right corner of the pane.
+* Typically this is a Close button or a composite with a Menu and Close button.
+*
+* @return the control in the top right corner of the pane or null
+*/
+public Control getTopRight() {
+ //checkWidget();
+ return topRight;
+}
+public void layout (boolean changed) {
+ checkWidget();
+ 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;
+
+ topLeft = null;
+ topCenter = null;
+ topRight = null;
+ content = null;
+ oldArea = 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.
+*
+* @param c the control to be displayed in the content area or null
+*
+* @exception SWTException <ul>
+* <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+* </ul>
+*/
+public void setContent(Control content) {
+ checkWidget();
+ if (content != null && content.getParent() != this) {
+ SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+ }
+ if (this.content != null && !this.content.isDisposed()) {
+ this.content.setBounds(OFFSCREEN, OFFSCREEN, 0, 0);
+ }
+ this.content = content;
+ layout();
+}
+
+/**
+* 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();
+}
+/**
+ * Sets the layout which is associated with the receiver to be
+ * the argument which may be null.
+ * <p>
+ * Note : ViewForm does not use a layout class to size and position its children.
+ * </p>
+ *
+ * @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();
+ 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.
+*
+* @param c the control to be displayed in the top center or null
+*
+* @exception SWTException <ul>
+* <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+* </ul>
+*/
+public void setTopCenter(Control topCenter) {
+ checkWidget();
+ if (topCenter != null && topCenter.getParent() != this) {
+ SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+ }
+ if (this.topCenter != null && !this.topCenter.isDisposed()) {
+ this.topCenter.setBounds(OFFSCREEN, OFFSCREEN, 0, 0);
+ }
+ 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.
+*
+* @param c the control to be displayed in the top left corner or null
+*
+* @exception SWTException <ul>
+* <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+* </ul>
+*/
+public void setTopLeft(Control c) {
+ checkWidget();
+ if (c != null && c.getParent() != this) {
+ SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+ }
+ if (this.topLeft != null && !this.topLeft.isDisposed()) {
+ this.topLeft.setBounds(OFFSCREEN, OFFSCREEN, 0, 0);
+ }
+ 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.
+*
+* @param c the control to be displayed in the top right corner or null
+*
+* @exception SWTException <ul>
+* <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+* <li>ERROR_INVALID_ARGUMENT - if the control is not a child of this ViewForm</li>
+* </ul>
+*/
+public void setTopRight(Control c) {
+ checkWidget();
+ if (c != null && c.getParent() != this) {
+ SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+ }
+ if (this.topRight != null && !this.topRight.isDisposed()) {
+ this.topRight.setBounds(OFFSCREEN, OFFSCREEN, 0, 0);
+ }
+ this.topRight = c;
+ layout();
+}
+/**
+* Specify whether the border should be displayed or not.
+*
+* @param show true if the border should be displayed
+*
+* @exception SWTException <ul>
+* <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+* </ul>
+*/
+public void setBorderVisible(boolean show) {
+ checkWidget();
+ if (showBorder == show) return;
+
+ showBorder = show;
+ if (showBorder) {
+ 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.
+*
+* @param show true if the topCenter will always appear on a separate line by itself
+*
+* @exception SWTException <ul>
+* <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+* </ul>
+*/
+public void setTopCenterSeparate(boolean show) {
+ checkWidget();
+ separateTopCenter = show;
+ layout();
+}
+
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/WrappedContent.java b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/WrappedContent.java
index b7fd249aed..7d73a3b941 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/WrappedContent.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/WrappedContent.java
@@ -1,667 +1,667 @@
-package org.eclipse.swt.custom;
-
-/*
+package org.eclipse.swt.custom;
+
+/*
* Copyright (c) 2001, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-import org.eclipse.swt.*;
-import org.eclipse.swt.graphics.*;
-import org.eclipse.swt.internal.*;
-
-/**
- * An instance of class <code>WrappedContent</code> is used by
- * StyledText to display wrapped lines. Lines are wrapped at word
- * breaks which are marked by a space character. Trailing space
- * behind words is kept on the current line.
- * If the last remaining word on a line can not be fully displayed
- * the line is wrapped character by character.
- * WrappedContent wraps a StyledTextContent which provides the line
- * data. The start offset and length of wrapped lines is calculated
- * and updated based on recalculation requests and text changes.
- * <p>
- * All public methods in this class implement the
- * <code>StyledTextContent</code> interface. Package visible
- * methods are internal API for use by <code>StyledText</code>.
- * </p>
- */
-class WrappedContent implements StyledTextContent {
- final static int LINE_OFFSET = 0; // index of line offset in visualLines array
- final static int LINE_LENGTH = 1; // index of line lenght in visualLines array
- final static int WRAP_LINE_LENGTH = 0;
- final static int WRAP_LINE_WIDTH = 1;
-
- StyledTextRenderer renderer;
- StyledTextContent logicalContent;
- int[][] visualLines; // start and length of each visual line
- int visualLineCount = 0;
-
-/**
- * Create a new instance.
- *
- * @param renderer <class>StyledTextRenderer</class> that renders
- * the lines wrapped by the new instance.
- * @param logicalContent StyledTextContent that provides the line
- * data.
- */
-WrappedContent(StyledTextRenderer renderer, StyledTextContent logicalContent) {
- this.renderer = renderer;
- this.logicalContent = logicalContent;
-}
-/**
- * @see StyledTextContent#addTextChangeListener(TextChangeListener)
- */
-public void addTextChangeListener(TextChangeListener listener) {
- logicalContent.addTextChangeListener(listener);
-}
-/**
- * Grow the lines array to at least the specified size.
- * <p>
- *
- * @param numLines number of elements that the array should have
- * at a minimum
- */
-private void ensureSize(int numLines) {
- int size = visualLines.length;
- if (size >= numLines) {
- return;
- }
- int[][] newLines = new int[Math.max(size * 2, numLines)][2];
- System.arraycopy(visualLines, 0, newLines, 0, size);
- visualLines = newLines;
- resetVisualLines(size, visualLines.length - size);
-}
-/**
- * @see StyledTextContent#getCharCount()
- */
-public int getCharCount() {
- return logicalContent.getCharCount();
-}
-/**
- * @return the visual (wrapped) line at the specified index
- * @see StyledTextContent#getLine(int)
- */
-public String getLine(int lineIndex) {
- String line;
-
- // redirect call to logical content if there are no wrapped lines
- if (visualLineCount == 0) {
- line = logicalContent.getLine(lineIndex);
- }
- else {
- if (lineIndex >= visualLineCount || lineIndex < 0) {
- SWT.error(SWT.ERROR_INVALID_ARGUMENT);
- }
- line = logicalContent.getTextRange(visualLines[lineIndex][LINE_OFFSET], visualLines[lineIndex][LINE_LENGTH]);
- }
- return line;
-}
-/**
- * Returns the visual (wrapped) line at given offset.
- * <p>
- * The offset is ambiguous if it identifies the end of a visual line and
- * there is another visual line below. In this case the end of the visual
- * line has the same offset as the beginning of the next visual line
- * since the visual line break is not represented by any character in the
- * logical line.
- * In this ambiguous case the offset is assumed to represent the end of a
- * visual line and the index of the first visual line is returned.
- * </p>
- *
- * @param offset offset of the desired line.
- * @return the index of the visual (wrapped) line at the specified offset
- * @see StyledTextContent#getLineAtOffset(int)
- */
-public int getLineAtOffset(int offset) {
- int lastLine = visualLineCount - 1;
- int lastChar;
-
- // redirect call to logical content if there are no wrapped lines
- if (visualLineCount == 0) {
- return logicalContent.getLineAtOffset(offset);
- }
- // can't use getCharCount to get the number of characters since this
- // method is called in textChanged, when the logicalContent used by
- // getCharCount has already changed. at that point the visual lines
- // have not been updated yet and we thus need to use the old character
- // count which is only available in the visual content.
- lastChar = visualLines[lastLine][LINE_OFFSET] + visualLines[lastLine][LINE_LENGTH];
- if (offset < 0 || (offset > 0 && offset > lastChar)) {
- SWT.error(SWT.ERROR_INVALID_ARGUMENT);
- }
- // 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 (offset == lastChar) {
- return lastLine;
- }
-
- int high = visualLineCount;
- int low = -1;
- int index = visualLineCount;
- while (high - low > 1) {
- index = (high + low) / 2;
- int lineStart = visualLines[index][LINE_OFFSET];
- if (offset >= lineStart) {
- int lineEnd = lineStart + visualLines[index][LINE_LENGTH];
- low = index;
- if (offset <= lineEnd) {
- break;
- }
- }
- else {
- high = index;
- }
- }
- if (low > 0 && offset == visualLines[low - 1][LINE_OFFSET] + visualLines[low - 1][LINE_LENGTH]) {
- // end of a visual line/beginning of next visual line is ambiguous
- // (they have the same offset). always return the first visual line
- low--;
- }
- return low;
-}
-/**
- * @return the number of visual (wrapped) lines
- * @see StyledTextContent#getLineCount()
- */
-public int getLineCount() {
- int lineCount = visualLineCount;
-
- // redirect call to logical content if there are no wrapped lines
- if (visualLineCount == 0) {
- lineCount = logicalContent.getLineCount();
- }
- return lineCount;
-}
-/**
- * @see StyledTextContent#getLineDelimiter()
- */
-public String getLineDelimiter() {
- return logicalContent.getLineDelimiter();
-}
-/**
- * @return the start offset of the visual (wrapped) line at the given
- * index
- * @see StyledTextContent#getOffsetAtLine(int)
- */
-public int getOffsetAtLine(int lineIndex) {
- int offset;
-
- // redirect call to logical content if there are no wrapped lines
- if (visualLineCount == 0) {
- offset = logicalContent.getOffsetAtLine(lineIndex);
- }
- else {
- if (lineIndex >= visualLineCount || lineIndex < 0) {
- SWT.error(SWT.ERROR_INVALID_ARGUMENT);
- }
- offset = visualLines[lineIndex][LINE_OFFSET];
- }
- return offset;
-}
-/**
- * @see StyledTextContent#getTextRange(int, int)
- */
-public String getTextRange(int start, int length) {
- return logicalContent.getTextRange(start, length);
-}
-/**
- * Returns the number of visual (wrapped) lines.
- *
- * @return the number of visual (wrapped) lines
- */
-int getVisualLineCount() {
- return visualLineCount;
-}
-/**
- * Returns the offset of the character after the word at the specified
- * offset.
- * <p>
- * Words are separated by spaces. Trailing spaces are considered part
- * of the word.
- * </p>
- *
- * @param line logical line the word is in
- * @param startOffset start offset of the line, relative to the start
- * of the logical line.
- * @param offset offset of the word to return the end of, relative to
- * the start of the visual line.
- * @return the offset of the character after the word at the specified
- * offset.
- */
-private int getWordEnd(String line, int startOffset, int offset) {
- int lineLength = line.length();
-
- offset += startOffset;
- if (offset >= lineLength) {
- return offset - startOffset;
- }
- // skip over leading whitespace
- do {
- offset++;
- } while (offset < lineLength && Compatibility.isSpaceChar(line.charAt(offset)));
- while (offset < lineLength && Compatibility.isSpaceChar(line.charAt(offset)) == false) {
- offset++;
- }
- // skip over trailing whitespace
- while (offset < lineLength && Compatibility.isSpaceChar(line.charAt(offset))) {
- offset++;
- }
- return offset - startOffset;
-}
-/**
- * Returns the start offset of the word at the specified offset.
- * There are two classes of words formed by a sequence of characters:
- * <p>
- * Words are separated by spaces. Trailing spaces are considered part
- * of the word.
- * </p>
- *
- * @param line logical line the word is in
- * @param startOffset start offset of the line, relative to the start
- * of the logical line.
- * @param offset offset of the word to return the start of, relative to
- * the start of the visual line.
- * @return the start offset of the word at the specified offset.
- */
-private int getWordStart(String line, int startOffset, int offset) {
- offset += startOffset;
- // skip over trailing whitespace
- do {
- offset--;
- } while (offset > startOffset && Compatibility.isSpaceChar(line.charAt(offset)));
- while (offset > startOffset && Compatibility.isSpaceChar(line.charAt(offset - 1)) == false) {
- offset--;
- }
- return offset - startOffset;
-}
-/**
- * @see StyledTextContent#removeTextChangeListener(TextChangeListener)
- */
-public void removeTextChangeListener(TextChangeListener listener) {
- logicalContent.removeTextChangeListener(listener);
-}
-/**
- * Reset the visual (wrapped) lines in the specified range.
- * If the range specifies partial logical lines (e.g., startLine is
- * the second of two visual lines) it is extended to reset all visual
- * lines of a logical line.
- * Following the reset the logical lines in the reset visual range are
- * rewrapped.
- * <p>
- *
- * @param startLine index of the first visual line
- * @param lineCount number of visual lines
- */
-void reset(int startLine, int lineCount) {
- if (lineCount <= 0 || visualLineCount == 0) {
- return;
- }
- reset(startLine, lineCount, true);
-}
-/**
- * Reset the visual (wrapped) lines in the specified range.
- * If the range specifies partial logical lines (e.g., startLine is
- * the second of two visual lines) it is extended to reset all visual
- * lines of a logical line.
- * <p>
- *
- * @param startLine index of the first visual line
- * @param lineCount number of visual lines
- * @param wrap true=rewrap the logical lines in the reset visual range
- * false=don't rewrap lines. Visual lines will be left in an inconsistent
- * state since there will be a range of unwrapped and unknown lines.
- * @return the first visual line that was reset
- */
-private int reset(int startLine, int lineCount, boolean wrap) {
- if (lineCount <= 0) {
- return startLine;
- }
- // make sure that all visual lines of the first logical line are
- // being reset. visualFirstLine is the first visual line of the
- // first logical line that has at least one visual line reset.
- int visualFirstLineOffset = getOffsetAtLine(startLine);
- int logicalFirstLine = logicalContent.getLineAtOffset(visualFirstLineOffset);
- int logicalFirstLineOffset = logicalContent.getOffsetAtLine(logicalFirstLine);
- int visualFirstLine = getLineAtOffset(logicalFirstLineOffset);
-
- lineCount += startLine - visualFirstLine;
- startLine = visualFirstLine;
-
- // make sure that all visual lines of the last logical line are
- // being reset.
- int lastLine = startLine + lineCount - 1;
- int lastLineEnd = visualLines[lastLine][LINE_OFFSET] + visualLines[lastLine][LINE_LENGTH];
- int logicalEndLine = 0;
-
- while (lastLine < visualLineCount - 1 && lastLineEnd == visualLines[lastLine + 1][LINE_OFFSET]) {
- lastLine++;
- lastLineEnd = visualLines[lastLine][LINE_OFFSET] + visualLines[lastLine][LINE_LENGTH];
- }
- if (wrap) {
- if (lastLine == visualLineCount - 1) {
- logicalEndLine = logicalContent.getLineCount();
- }
- else {
- logicalEndLine = logicalContent.getLineAtOffset(visualLines[lastLine + 1][LINE_OFFSET]);
- }
- }
- lineCount = lastLine - startLine + 1;
- resetVisualLines(startLine, lineCount);
- visualLineCount -= lineCount;
- if (wrap) {
- // always recalculate line wrap immediately after a reset
- // because the content always needs to be in a usable state.
- // i.e., there must not be any reset but unwrapped lines
- wrapLineRange(logicalFirstLine, logicalEndLine, startLine);
- }
- return startLine;
-}
-/**
- * Reset the visual (wrapped) lines in the specified range.
- * <p>
- *
- * @param startLine index of the first visual line
- * @param lineCount number of visual lines
- */
-private void resetVisualLines(int startLine, int lineCount) {
- int endLine = startLine + lineCount;
-
- for (int i = startLine; i < endLine; i++) {
- visualLines[i] = new int[] {-1, -1};
- }
-}
-/**
- * @see StyledTextContent#replaceTextRange(int, int, String)
- */
-public void replaceTextRange(int start, int replaceLength, String text) {
- logicalContent.replaceTextRange(start, replaceLength, text);
-}
-/**
- * @see StyledTextContent#setText(String)
- */
-public void setText(String text) {
- logicalContent.setText(text);
-}
-/**
- * Set the line wrap data for the specified visual (wrapped) line.
- * <p>
- *
- * @param visualLineIndex index of the visual line
- * @param visualLineOffset start offset of the visual line, relative
- * to the start of the document
- * @param visualLineLength length of the visual line
- */
-private void setVisualLine(int visualLineIndex, int visualLineOffset, int visualLineLength) {
- ensureSize(visualLineCount + 1);
- // is the space for the visual line already taken? can happen if
- // there are more visual lines for a given logical line than before
- if (visualLines[visualLineIndex][LINE_OFFSET] != -1) {
- System.arraycopy(visualLines, visualLineIndex, visualLines, visualLineIndex + 1, visualLineCount - visualLineIndex);
- visualLines[visualLineIndex] = new int[2];
- }
- visualLines[visualLineIndex][LINE_OFFSET] = visualLineOffset;
- visualLines[visualLineIndex][LINE_LENGTH] = visualLineLength;
- visualLineCount++;
-}
-/**
- * Recalculates the line wrap for the lines affected by the
- * text change.
- * <p>
- *
- * @param startOffset the start offset of the text change
- * @param newLineCount the number of inserted lines
- * @param replaceLineCount the number of deleted lines
- * @param newCharCount the number of new characters
- * @param replaceCharCount the number of deleted characters
- */
-void textChanged(int startOffset, int newLineCount, int replaceLineCount, int newCharCount, int replaceCharCount) {
- // do nothing if there are no wrapped lines
- if (visualLineCount == 0) {
- return;
- }
- int logicalStartLine = logicalContent.getLineAtOffset(startOffset);
- int visualStartLine = getLineAtOffset(startOffset);
- int visualReplaceLastLine = visualLineCount - 1;
- int textChangeDelta = newCharCount - replaceCharCount;
-
- if (replaceLineCount > 0) {
- visualReplaceLastLine = getLineAtOffset(startOffset + replaceCharCount);
- // at the start of a visual line/end of the previous visual line?
- if ((visualReplaceLastLine == 0 ||
- visualLines[visualReplaceLastLine][LINE_OFFSET] == visualLines[visualReplaceLastLine - 1][LINE_OFFSET] + visualLines[visualReplaceLastLine - 1][LINE_LENGTH]) &&
- visualReplaceLastLine != visualLineCount - 1) {
- visualReplaceLastLine++;
- }
- visualStartLine = reset(visualStartLine, visualReplaceLastLine - visualStartLine + 1, false);
- }
- else {
- visualStartLine = reset(visualStartLine, 1, false);
- }
- visualReplaceLastLine = wrapLineRange(logicalStartLine, logicalStartLine + 1 + newLineCount, visualStartLine);
- for (int i = visualReplaceLastLine; i < visualLineCount; i++) {
- visualLines[i][LINE_OFFSET] += textChangeDelta;
- }
-}
-/**
- * Measure the width of a segment in the specified logical line.
- * <p>
- *
- * @param line the logical line
- * @param logicalLineOffset start offset of the logical line, relative
- * to the start of the document
- * @param visualLineOffset offset to start measuring at/start offset
- * of the visual line
- * @param visualLineLength length of the segment to measure/the visual
- * line
- * @param styles StyleRanges to use during measuring
- * @param startX x position of the visual line relative to the start
- * of the logical line
- * @param gc GC to use for measuring
- */
-private int getTextWidth(String line, int logicalLineOffset, int visualLineOffset, int visualLineLength, StyleRange[] styles, int startX, GC gc) {
- int width;
-
- if (styles != null) {
- // while wrapping a line, the logcial line styles may contain
- // style ranges that don't apply (i.e., completely on the previous/next
- // visual line). Therefore we need to filter the logical lines.
- styles = renderer.getVisualLineStyleData(styles, logicalLineOffset + visualLineOffset, visualLineLength);
- }
- if (renderer.isBidi()) {
- String wrappedLine = line.substring(visualLineOffset, visualLineOffset + visualLineLength);
- StyledTextBidi bidi = renderer.getStyledTextBidi(wrappedLine, logicalLineOffset + visualLineOffset, gc, styles);
- width = bidi.getTextWidth();
- }
- else {
- width = renderer.getTextWidth(line, logicalLineOffset, visualLineOffset, visualLineLength, styles, startX, gc);
- }
- return width;
-}
-/**
- * Wrap the given logical line at the specified offset.
- * Called repeatedly until the entire logical lines has been split into
- * visual (wrapped) lines.
- * <p>
- *
- * @param line the logical line
- * @param logicalLineOffset offset of the logical line, relative to the
- * beginning of the content
- * @param visualLineOffset start offset of the new visual line, relative
- * to the start of the logical line.
- * @param startX x position of visualLineOffset, relative to the beginning
- * of the logical line
- * @param width width to wrap the line to
- * @param numChars average number of characters that fit into width
- * @param styles StyleRanges to use for measuring the wrapped line
- * @param gc GC to use for measuring
- * @return int[0]=length of the new visual line, int[1]=width in pixels of
- * the new visual line
- */
-private int[] wrapLine(String line, int logicalLineOffset, int visualLineOffset, int startX, int width, int numChars, StyleRange[] styles, GC gc) {
- int lineLength = line.length();
- int lineWidth = 0;
- int visualLineLength;
-
- numChars = Math.min(numChars, lineLength - visualLineOffset);
- visualLineLength = getWordStart(line, visualLineOffset, numChars);
- // find a word that is within the client area. make sure at least one
- // character is on each line so that line wrap algorithm terminates.
- if (visualLineLength > 0) {
- lineWidth = getTextWidth(line, logicalLineOffset, visualLineOffset, visualLineLength, styles, startX, gc);
- if (lineWidth >= width) {
- while (visualLineLength > 1 && lineWidth >= width) {
- visualLineLength = getWordStart(line, visualLineOffset, visualLineLength);
- lineWidth = getTextWidth(line, logicalLineOffset, visualLineOffset, visualLineLength, styles, startX, gc);
- }
- }
- else
- if (lineWidth < width) {
- while (visualLineOffset + visualLineLength < lineLength) {
- int newLineLength = getWordEnd(line, visualLineOffset, visualLineLength);
- int newLineWidth = getTextWidth(line, logicalLineOffset, visualLineOffset, newLineLength, styles, startX, gc);
- // would next word be beyond client area?
- if (newLineWidth >= width) {
- break;
- }
- else {
- visualLineLength = newLineLength;
- lineWidth = newLineWidth;
- }
- }
- }
- }
- if (visualLineLength <= 0) {
- // no complete word fits on the line. either first word was not within
- // estimated number of characters or it was beyond the line width even
- // though it was within numChars.
- visualLineLength = numChars;
- lineWidth = getTextWidth(line, logicalLineOffset, visualLineOffset, visualLineLength, styles, startX, gc);
- if (lineWidth >= width) {
- while (visualLineLength > 1 && lineWidth >= width) {
- visualLineLength--;
- lineWidth = getTextWidth(line, logicalLineOffset, visualLineOffset, visualLineLength, styles, startX, gc);
- }
- }
- else
- if (lineWidth < width) {
- while (visualLineOffset + visualLineLength < lineLength) {
- int newLineWidth = getTextWidth(line, logicalLineOffset, visualLineOffset, visualLineLength + 1, styles, startX, gc);
- if (newLineWidth >= width) {
- break;
- }
- else {
- visualLineLength++;
- lineWidth = newLineWidth;
- }
- }
- }
- }
- return new int[] {visualLineLength, lineWidth};
-}
-/**
- * Wrap the logical lines in the given range at the current client
- * area width of the StyledText widget
- * <p>
- *
- * @param startLine first logical line to wrap
- * @param endLine line after last logical line
- * @param visualLineIndex visual (wrapped) line index that startLine
- * corresponds to.
- * @return index of the line following the last wrapped line
- */
-private int wrapLineRange(int startLine, int endLine, int visualLineIndex) {
- int emptyLineCount = 0;
-
- visualLineIndex = wrapLineRange(startLine, endLine, visualLineIndex, renderer.getClientArea().width);
- // is there space left for more visual lines? can happen if there are fewer
- // visual lines for a given logical line than before
- for (int i = visualLineIndex; i < visualLines.length; i++, emptyLineCount++) {
- if (visualLines[i][LINE_OFFSET] != -1) {
- break;
- }
- }
- if (emptyLineCount > 0) {
- int copyLineCount = visualLineCount - visualLineIndex;
- System.arraycopy(visualLines, visualLineIndex + emptyLineCount, visualLines, visualLineIndex, copyLineCount);
- resetVisualLines(visualLineIndex + copyLineCount, emptyLineCount);
- }
- return visualLineIndex;
-}
-/**
- * Wrap the lines in the given range. Skip lines that have already
- * been wrapped.
- * <p>
- *
- * @param startLine first logical line to wrap
- * @param endLine line after last logical line
- * @param visualLineIndex visual (wrapped) line index that startLine
- * corresponds to.
- * @param width line width to wrap at
- * @return index of last wrapped line
- */
-private int wrapLineRange(int startLine, int endLine, int visualLineIndex, int width) {
- // if there are no wrapped lines and the width is 0 the widget has
- // not been made visible/sized yet. don't wrap until the widget size
- // is known.
- if (visualLineCount == 0 && width == 0) {
- return visualLineIndex;
- }
-
- GC gc = renderer.getGC();
- int numChars = Math.max(1, width / gc.getFontMetrics().getAverageCharWidth());
-
- for (int i = startLine; i < endLine; i++) {
- String line = logicalContent.getLine(i);
- int lineOffset = logicalContent.getOffsetAtLine(i);
- int lineLength = line.length();
-
- if (lineLength == 0) {
- setVisualLine(visualLineIndex, lineOffset, 0);
- visualLineIndex++;
- continue;
- }
- StyleRange[] styles = null;
- StyledTextEvent event = renderer.getLineStyleData(lineOffset, line);
- int startOffset = 0;
- int startX = 0;
-
- if (event != null) {
- styles = renderer.filterLineStyles(event.styles);
- }
- while (startOffset < lineLength) {
- int[] result = wrapLine(line, lineOffset, startOffset, startX, width, numChars, styles, gc);
-
- setVisualLine(visualLineIndex, lineOffset + startOffset, result[WRAP_LINE_LENGTH]);
- startOffset += result[WRAP_LINE_LENGTH];
- startX += result[WRAP_LINE_WIDTH];
- visualLineIndex++;
- }
- }
- renderer.disposeGC(gc);
- return visualLineIndex;
-}
-/**
- * Wrap all logical lines at the current client area width of the
- * StyledText widget
- */
-void wrapLines() {
- wrapLines(renderer.getClientArea().width);
-}
-/**
- * Wrap all logical lines at the given width.
- * <p>
- *
- * @param width width to wrap lines at
- */
-void wrapLines(int width) {
- int lineCount = logicalContent.getLineCount();
-
- visualLineCount = 0;
- visualLines = new int[lineCount][2];
- resetVisualLines(0, visualLines.length);
- wrapLineRange(0, lineCount, 0, width);
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+import org.eclipse.swt.*;
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.internal.*;
+
+/**
+ * An instance of class <code>WrappedContent</code> is used by
+ * StyledText to display wrapped lines. Lines are wrapped at word
+ * breaks which are marked by a space character. Trailing space
+ * behind words is kept on the current line.
+ * If the last remaining word on a line can not be fully displayed
+ * the line is wrapped character by character.
+ * WrappedContent wraps a StyledTextContent which provides the line
+ * data. The start offset and length of wrapped lines is calculated
+ * and updated based on recalculation requests and text changes.
+ * <p>
+ * All public methods in this class implement the
+ * <code>StyledTextContent</code> interface. Package visible
+ * methods are internal API for use by <code>StyledText</code>.
+ * </p>
+ */
+class WrappedContent implements StyledTextContent {
+ final static int LINE_OFFSET = 0; // index of line offset in visualLines array
+ final static int LINE_LENGTH = 1; // index of line lenght in visualLines array
+ final static int WRAP_LINE_LENGTH = 0;
+ final static int WRAP_LINE_WIDTH = 1;
+
+ StyledTextRenderer renderer;
+ StyledTextContent logicalContent;
+ int[][] visualLines; // start and length of each visual line
+ int visualLineCount = 0;
+
+/**
+ * Create a new instance.
+ *
+ * @param renderer <class>StyledTextRenderer</class> that renders
+ * the lines wrapped by the new instance.
+ * @param logicalContent StyledTextContent that provides the line
+ * data.
+ */
+WrappedContent(StyledTextRenderer renderer, StyledTextContent logicalContent) {
+ this.renderer = renderer;
+ this.logicalContent = logicalContent;
+}
+/**
+ * @see StyledTextContent#addTextChangeListener(TextChangeListener)
+ */
+public void addTextChangeListener(TextChangeListener listener) {
+ logicalContent.addTextChangeListener(listener);
+}
+/**
+ * Grow the lines array to at least the specified size.
+ * <p>
+ *
+ * @param numLines number of elements that the array should have
+ * at a minimum
+ */
+private void ensureSize(int numLines) {
+ int size = visualLines.length;
+ if (size >= numLines) {
+ return;
+ }
+ int[][] newLines = new int[Math.max(size * 2, numLines)][2];
+ System.arraycopy(visualLines, 0, newLines, 0, size);
+ visualLines = newLines;
+ resetVisualLines(size, visualLines.length - size);
+}
+/**
+ * @see StyledTextContent#getCharCount()
+ */
+public int getCharCount() {
+ return logicalContent.getCharCount();
+}
+/**
+ * @return the visual (wrapped) line at the specified index
+ * @see StyledTextContent#getLine(int)
+ */
+public String getLine(int lineIndex) {
+ String line;
+
+ // redirect call to logical content if there are no wrapped lines
+ if (visualLineCount == 0) {
+ line = logicalContent.getLine(lineIndex);
+ }
+ else {
+ if (lineIndex >= visualLineCount || lineIndex < 0) {
+ SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+ }
+ line = logicalContent.getTextRange(visualLines[lineIndex][LINE_OFFSET], visualLines[lineIndex][LINE_LENGTH]);
+ }
+ return line;
+}
+/**
+ * Returns the visual (wrapped) line at given offset.
+ * <p>
+ * The offset is ambiguous if it identifies the end of a visual line and
+ * there is another visual line below. In this case the end of the visual
+ * line has the same offset as the beginning of the next visual line
+ * since the visual line break is not represented by any character in the
+ * logical line.
+ * In this ambiguous case the offset is assumed to represent the end of a
+ * visual line and the index of the first visual line is returned.
+ * </p>
+ *
+ * @param offset offset of the desired line.
+ * @return the index of the visual (wrapped) line at the specified offset
+ * @see StyledTextContent#getLineAtOffset(int)
+ */
+public int getLineAtOffset(int offset) {
+ int lastLine = visualLineCount - 1;
+ int lastChar;
+
+ // redirect call to logical content if there are no wrapped lines
+ if (visualLineCount == 0) {
+ return logicalContent.getLineAtOffset(offset);
+ }
+ // can't use getCharCount to get the number of characters since this
+ // method is called in textChanged, when the logicalContent used by
+ // getCharCount has already changed. at that point the visual lines
+ // have not been updated yet and we thus need to use the old character
+ // count which is only available in the visual content.
+ lastChar = visualLines[lastLine][LINE_OFFSET] + visualLines[lastLine][LINE_LENGTH];
+ if (offset < 0 || (offset > 0 && offset > lastChar)) {
+ SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+ }
+ // 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 (offset == lastChar) {
+ return lastLine;
+ }
+
+ int high = visualLineCount;
+ int low = -1;
+ int index = visualLineCount;
+ while (high - low > 1) {
+ index = (high + low) / 2;
+ int lineStart = visualLines[index][LINE_OFFSET];
+ if (offset >= lineStart) {
+ int lineEnd = lineStart + visualLines[index][LINE_LENGTH];
+ low = index;
+ if (offset <= lineEnd) {
+ break;
+ }
+ }
+ else {
+ high = index;
+ }
+ }
+ if (low > 0 && offset == visualLines[low - 1][LINE_OFFSET] + visualLines[low - 1][LINE_LENGTH]) {
+ // end of a visual line/beginning of next visual line is ambiguous
+ // (they have the same offset). always return the first visual line
+ low--;
+ }
+ return low;
+}
+/**
+ * @return the number of visual (wrapped) lines
+ * @see StyledTextContent#getLineCount()
+ */
+public int getLineCount() {
+ int lineCount = visualLineCount;
+
+ // redirect call to logical content if there are no wrapped lines
+ if (visualLineCount == 0) {
+ lineCount = logicalContent.getLineCount();
+ }
+ return lineCount;
+}
+/**
+ * @see StyledTextContent#getLineDelimiter()
+ */
+public String getLineDelimiter() {
+ return logicalContent.getLineDelimiter();
+}
+/**
+ * @return the start offset of the visual (wrapped) line at the given
+ * index
+ * @see StyledTextContent#getOffsetAtLine(int)
+ */
+public int getOffsetAtLine(int lineIndex) {
+ int offset;
+
+ // redirect call to logical content if there are no wrapped lines
+ if (visualLineCount == 0) {
+ offset = logicalContent.getOffsetAtLine(lineIndex);
+ }
+ else {
+ if (lineIndex >= visualLineCount || lineIndex < 0) {
+ SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+ }
+ offset = visualLines[lineIndex][LINE_OFFSET];
+ }
+ return offset;
+}
+/**
+ * @see StyledTextContent#getTextRange(int, int)
+ */
+public String getTextRange(int start, int length) {
+ return logicalContent.getTextRange(start, length);
+}
+/**
+ * Returns the number of visual (wrapped) lines.
+ *
+ * @return the number of visual (wrapped) lines
+ */
+int getVisualLineCount() {
+ return visualLineCount;
+}
+/**
+ * Returns the offset of the character after the word at the specified
+ * offset.
+ * <p>
+ * Words are separated by spaces. Trailing spaces are considered part
+ * of the word.
+ * </p>
+ *
+ * @param line logical line the word is in
+ * @param startOffset start offset of the line, relative to the start
+ * of the logical line.
+ * @param offset offset of the word to return the end of, relative to
+ * the start of the visual line.
+ * @return the offset of the character after the word at the specified
+ * offset.
+ */
+private int getWordEnd(String line, int startOffset, int offset) {
+ int lineLength = line.length();
+
+ offset += startOffset;
+ if (offset >= lineLength) {
+ return offset - startOffset;
+ }
+ // skip over leading whitespace
+ do {
+ offset++;
+ } while (offset < lineLength && Compatibility.isSpaceChar(line.charAt(offset)));
+ while (offset < lineLength && Compatibility.isSpaceChar(line.charAt(offset)) == false) {
+ offset++;
+ }
+ // skip over trailing whitespace
+ while (offset < lineLength && Compatibility.isSpaceChar(line.charAt(offset))) {
+ offset++;
+ }
+ return offset - startOffset;
+}
+/**
+ * Returns the start offset of the word at the specified offset.
+ * There are two classes of words formed by a sequence of characters:
+ * <p>
+ * Words are separated by spaces. Trailing spaces are considered part
+ * of the word.
+ * </p>
+ *
+ * @param line logical line the word is in
+ * @param startOffset start offset of the line, relative to the start
+ * of the logical line.
+ * @param offset offset of the word to return the start of, relative to
+ * the start of the visual line.
+ * @return the start offset of the word at the specified offset.
+ */
+private int getWordStart(String line, int startOffset, int offset) {
+ offset += startOffset;
+ // skip over trailing whitespace
+ do {
+ offset--;
+ } while (offset > startOffset && Compatibility.isSpaceChar(line.charAt(offset)));
+ while (offset > startOffset && Compatibility.isSpaceChar(line.charAt(offset - 1)) == false) {
+ offset--;
+ }
+ return offset - startOffset;
+}
+/**
+ * @see StyledTextContent#removeTextChangeListener(TextChangeListener)
+ */
+public void removeTextChangeListener(TextChangeListener listener) {
+ logicalContent.removeTextChangeListener(listener);
+}
+/**
+ * Reset the visual (wrapped) lines in the specified range.
+ * If the range specifies partial logical lines (e.g., startLine is
+ * the second of two visual lines) it is extended to reset all visual
+ * lines of a logical line.
+ * Following the reset the logical lines in the reset visual range are
+ * rewrapped.
+ * <p>
+ *
+ * @param startLine index of the first visual line
+ * @param lineCount number of visual lines
+ */
+void reset(int startLine, int lineCount) {
+ if (lineCount <= 0 || visualLineCount == 0) {
+ return;
+ }
+ reset(startLine, lineCount, true);
+}
+/**
+ * Reset the visual (wrapped) lines in the specified range.
+ * If the range specifies partial logical lines (e.g., startLine is
+ * the second of two visual lines) it is extended to reset all visual
+ * lines of a logical line.
+ * <p>
+ *
+ * @param startLine index of the first visual line
+ * @param lineCount number of visual lines
+ * @param wrap true=rewrap the logical lines in the reset visual range
+ * false=don't rewrap lines. Visual lines will be left in an inconsistent
+ * state since there will be a range of unwrapped and unknown lines.
+ * @return the first visual line that was reset
+ */
+private int reset(int startLine, int lineCount, boolean wrap) {
+ if (lineCount <= 0) {
+ return startLine;
+ }
+ // make sure that all visual lines of the first logical line are
+ // being reset. visualFirstLine is the first visual line of the
+ // first logical line that has at least one visual line reset.
+ int visualFirstLineOffset = getOffsetAtLine(startLine);
+ int logicalFirstLine = logicalContent.getLineAtOffset(visualFirstLineOffset);
+ int logicalFirstLineOffset = logicalContent.getOffsetAtLine(logicalFirstLine);
+ int visualFirstLine = getLineAtOffset(logicalFirstLineOffset);
+
+ lineCount += startLine - visualFirstLine;
+ startLine = visualFirstLine;
+
+ // make sure that all visual lines of the last logical line are
+ // being reset.
+ int lastLine = startLine + lineCount - 1;
+ int lastLineEnd = visualLines[lastLine][LINE_OFFSET] + visualLines[lastLine][LINE_LENGTH];
+ int logicalEndLine = 0;
+
+ while (lastLine < visualLineCount - 1 && lastLineEnd == visualLines[lastLine + 1][LINE_OFFSET]) {
+ lastLine++;
+ lastLineEnd = visualLines[lastLine][LINE_OFFSET] + visualLines[lastLine][LINE_LENGTH];
+ }
+ if (wrap) {
+ if (lastLine == visualLineCount - 1) {
+ logicalEndLine = logicalContent.getLineCount();
+ }
+ else {
+ logicalEndLine = logicalContent.getLineAtOffset(visualLines[lastLine + 1][LINE_OFFSET]);
+ }
+ }
+ lineCount = lastLine - startLine + 1;
+ resetVisualLines(startLine, lineCount);
+ visualLineCount -= lineCount;
+ if (wrap) {
+ // always recalculate line wrap immediately after a reset
+ // because the content always needs to be in a usable state.
+ // i.e., there must not be any reset but unwrapped lines
+ wrapLineRange(logicalFirstLine, logicalEndLine, startLine);
+ }
+ return startLine;
+}
+/**
+ * Reset the visual (wrapped) lines in the specified range.
+ * <p>
+ *
+ * @param startLine index of the first visual line
+ * @param lineCount number of visual lines
+ */
+private void resetVisualLines(int startLine, int lineCount) {
+ int endLine = startLine + lineCount;
+
+ for (int i = startLine; i < endLine; i++) {
+ visualLines[i] = new int[] {-1, -1};
+ }
+}
+/**
+ * @see StyledTextContent#replaceTextRange(int, int, String)
+ */
+public void replaceTextRange(int start, int replaceLength, String text) {
+ logicalContent.replaceTextRange(start, replaceLength, text);
+}
+/**
+ * @see StyledTextContent#setText(String)
+ */
+public void setText(String text) {
+ logicalContent.setText(text);
+}
+/**
+ * Set the line wrap data for the specified visual (wrapped) line.
+ * <p>
+ *
+ * @param visualLineIndex index of the visual line
+ * @param visualLineOffset start offset of the visual line, relative
+ * to the start of the document
+ * @param visualLineLength length of the visual line
+ */
+private void setVisualLine(int visualLineIndex, int visualLineOffset, int visualLineLength) {
+ ensureSize(visualLineCount + 1);
+ // is the space for the visual line already taken? can happen if
+ // there are more visual lines for a given logical line than before
+ if (visualLines[visualLineIndex][LINE_OFFSET] != -1) {
+ System.arraycopy(visualLines, visualLineIndex, visualLines, visualLineIndex + 1, visualLineCount - visualLineIndex);
+ visualLines[visualLineIndex] = new int[2];
+ }
+ visualLines[visualLineIndex][LINE_OFFSET] = visualLineOffset;
+ visualLines[visualLineIndex][LINE_LENGTH] = visualLineLength;
+ visualLineCount++;
+}
+/**
+ * Recalculates the line wrap for the lines affected by the
+ * text change.
+ * <p>
+ *
+ * @param startOffset the start offset of the text change
+ * @param newLineCount the number of inserted lines
+ * @param replaceLineCount the number of deleted lines
+ * @param newCharCount the number of new characters
+ * @param replaceCharCount the number of deleted characters
+ */
+void textChanged(int startOffset, int newLineCount, int replaceLineCount, int newCharCount, int replaceCharCount) {
+ // do nothing if there are no wrapped lines
+ if (visualLineCount == 0) {
+ return;
+ }
+ int logicalStartLine = logicalContent.getLineAtOffset(startOffset);
+ int visualStartLine = getLineAtOffset(startOffset);
+ int visualReplaceLastLine = visualLineCount - 1;
+ int textChangeDelta = newCharCount - replaceCharCount;
+
+ if (replaceLineCount > 0) {
+ visualReplaceLastLine = getLineAtOffset(startOffset + replaceCharCount);
+ // at the start of a visual line/end of the previous visual line?
+ if ((visualReplaceLastLine == 0 ||
+ visualLines[visualReplaceLastLine][LINE_OFFSET] == visualLines[visualReplaceLastLine - 1][LINE_OFFSET] + visualLines[visualReplaceLastLine - 1][LINE_LENGTH]) &&
+ visualReplaceLastLine != visualLineCount - 1) {
+ visualReplaceLastLine++;
+ }
+ visualStartLine = reset(visualStartLine, visualReplaceLastLine - visualStartLine + 1, false);
+ }
+ else {
+ visualStartLine = reset(visualStartLine, 1, false);
+ }
+ visualReplaceLastLine = wrapLineRange(logicalStartLine, logicalStartLine + 1 + newLineCount, visualStartLine);
+ for (int i = visualReplaceLastLine; i < visualLineCount; i++) {
+ visualLines[i][LINE_OFFSET] += textChangeDelta;
+ }
+}
+/**
+ * Measure the width of a segment in the specified logical line.
+ * <p>
+ *
+ * @param line the logical line
+ * @param logicalLineOffset start offset of the logical line, relative
+ * to the start of the document
+ * @param visualLineOffset offset to start measuring at/start offset
+ * of the visual line
+ * @param visualLineLength length of the segment to measure/the visual
+ * line
+ * @param styles StyleRanges to use during measuring
+ * @param startX x position of the visual line relative to the start
+ * of the logical line
+ * @param gc GC to use for measuring
+ */
+private int getTextWidth(String line, int logicalLineOffset, int visualLineOffset, int visualLineLength, StyleRange[] styles, int startX, GC gc) {
+ int width;
+
+ if (styles != null) {
+ // while wrapping a line, the logcial line styles may contain
+ // style ranges that don't apply (i.e., completely on the previous/next
+ // visual line). Therefore we need to filter the logical lines.
+ styles = renderer.getVisualLineStyleData(styles, logicalLineOffset + visualLineOffset, visualLineLength);
+ }
+ if (renderer.isBidi()) {
+ String wrappedLine = line.substring(visualLineOffset, visualLineOffset + visualLineLength);
+ StyledTextBidi bidi = renderer.getStyledTextBidi(wrappedLine, logicalLineOffset + visualLineOffset, gc, styles);
+ width = bidi.getTextWidth();
+ }
+ else {
+ width = renderer.getTextWidth(line, logicalLineOffset, visualLineOffset, visualLineLength, styles, startX, gc);
+ }
+ return width;
+}
+/**
+ * Wrap the given logical line at the specified offset.
+ * Called repeatedly until the entire logical lines has been split into
+ * visual (wrapped) lines.
+ * <p>
+ *
+ * @param line the logical line
+ * @param logicalLineOffset offset of the logical line, relative to the
+ * beginning of the content
+ * @param visualLineOffset start offset of the new visual line, relative
+ * to the start of the logical line.
+ * @param startX x position of visualLineOffset, relative to the beginning
+ * of the logical line
+ * @param width width to wrap the line to
+ * @param numChars average number of characters that fit into width
+ * @param styles StyleRanges to use for measuring the wrapped line
+ * @param gc GC to use for measuring
+ * @return int[0]=length of the new visual line, int[1]=width in pixels of
+ * the new visual line
+ */
+private int[] wrapLine(String line, int logicalLineOffset, int visualLineOffset, int startX, int width, int numChars, StyleRange[] styles, GC gc) {
+ int lineLength = line.length();
+ int lineWidth = 0;
+ int visualLineLength;
+
+ numChars = Math.min(numChars, lineLength - visualLineOffset);
+ visualLineLength = getWordStart(line, visualLineOffset, numChars);
+ // find a word that is within the client area. make sure at least one
+ // character is on each line so that line wrap algorithm terminates.
+ if (visualLineLength > 0) {
+ lineWidth = getTextWidth(line, logicalLineOffset, visualLineOffset, visualLineLength, styles, startX, gc);
+ if (lineWidth >= width) {
+ while (visualLineLength > 1 && lineWidth >= width) {
+ visualLineLength = getWordStart(line, visualLineOffset, visualLineLength);
+ lineWidth = getTextWidth(line, logicalLineOffset, visualLineOffset, visualLineLength, styles, startX, gc);
+ }
+ }
+ else
+ if (lineWidth < width) {
+ while (visualLineOffset + visualLineLength < lineLength) {
+ int newLineLength = getWordEnd(line, visualLineOffset, visualLineLength);
+ int newLineWidth = getTextWidth(line, logicalLineOffset, visualLineOffset, newLineLength, styles, startX, gc);
+ // would next word be beyond client area?
+ if (newLineWidth >= width) {
+ break;
+ }
+ else {
+ visualLineLength = newLineLength;
+ lineWidth = newLineWidth;
+ }
+ }
+ }
+ }
+ if (visualLineLength <= 0) {
+ // no complete word fits on the line. either first word was not within
+ // estimated number of characters or it was beyond the line width even
+ // though it was within numChars.
+ visualLineLength = numChars;
+ lineWidth = getTextWidth(line, logicalLineOffset, visualLineOffset, visualLineLength, styles, startX, gc);
+ if (lineWidth >= width) {
+ while (visualLineLength > 1 && lineWidth >= width) {
+ visualLineLength--;
+ lineWidth = getTextWidth(line, logicalLineOffset, visualLineOffset, visualLineLength, styles, startX, gc);
+ }
+ }
+ else
+ if (lineWidth < width) {
+ while (visualLineOffset + visualLineLength < lineLength) {
+ int newLineWidth = getTextWidth(line, logicalLineOffset, visualLineOffset, visualLineLength + 1, styles, startX, gc);
+ if (newLineWidth >= width) {
+ break;
+ }
+ else {
+ visualLineLength++;
+ lineWidth = newLineWidth;
+ }
+ }
+ }
+ }
+ return new int[] {visualLineLength, lineWidth};
+}
+/**
+ * Wrap the logical lines in the given range at the current client
+ * area width of the StyledText widget
+ * <p>
+ *
+ * @param startLine first logical line to wrap
+ * @param endLine line after last logical line
+ * @param visualLineIndex visual (wrapped) line index that startLine
+ * corresponds to.
+ * @return index of the line following the last wrapped line
+ */
+private int wrapLineRange(int startLine, int endLine, int visualLineIndex) {
+ int emptyLineCount = 0;
+
+ visualLineIndex = wrapLineRange(startLine, endLine, visualLineIndex, renderer.getClientArea().width);
+ // is there space left for more visual lines? can happen if there are fewer
+ // visual lines for a given logical line than before
+ for (int i = visualLineIndex; i < visualLines.length; i++, emptyLineCount++) {
+ if (visualLines[i][LINE_OFFSET] != -1) {
+ break;
+ }
+ }
+ if (emptyLineCount > 0) {
+ int copyLineCount = visualLineCount - visualLineIndex;
+ System.arraycopy(visualLines, visualLineIndex + emptyLineCount, visualLines, visualLineIndex, copyLineCount);
+ resetVisualLines(visualLineIndex + copyLineCount, emptyLineCount);
+ }
+ return visualLineIndex;
+}
+/**
+ * Wrap the lines in the given range. Skip lines that have already
+ * been wrapped.
+ * <p>
+ *
+ * @param startLine first logical line to wrap
+ * @param endLine line after last logical line
+ * @param visualLineIndex visual (wrapped) line index that startLine
+ * corresponds to.
+ * @param width line width to wrap at
+ * @return index of last wrapped line
+ */
+private int wrapLineRange(int startLine, int endLine, int visualLineIndex, int width) {
+ // if there are no wrapped lines and the width is 0 the widget has
+ // not been made visible/sized yet. don't wrap until the widget size
+ // is known.
+ if (visualLineCount == 0 && width == 0) {
+ return visualLineIndex;
+ }
+
+ GC gc = renderer.getGC();
+ int numChars = Math.max(1, width / gc.getFontMetrics().getAverageCharWidth());
+
+ for (int i = startLine; i < endLine; i++) {
+ String line = logicalContent.getLine(i);
+ int lineOffset = logicalContent.getOffsetAtLine(i);
+ int lineLength = line.length();
+
+ if (lineLength == 0) {
+ setVisualLine(visualLineIndex, lineOffset, 0);
+ visualLineIndex++;
+ continue;
+ }
+ StyleRange[] styles = null;
+ StyledTextEvent event = renderer.getLineStyleData(lineOffset, line);
+ int startOffset = 0;
+ int startX = 0;
+
+ if (event != null) {
+ styles = renderer.filterLineStyles(event.styles);
+ }
+ while (startOffset < lineLength) {
+ int[] result = wrapLine(line, lineOffset, startOffset, startX, width, numChars, styles, gc);
+
+ setVisualLine(visualLineIndex, lineOffset + startOffset, result[WRAP_LINE_LENGTH]);
+ startOffset += result[WRAP_LINE_LENGTH];
+ startX += result[WRAP_LINE_WIDTH];
+ visualLineIndex++;
+ }
+ }
+ renderer.disposeGC(gc);
+ return visualLineIndex;
+}
+/**
+ * Wrap all logical lines at the current client area width of the
+ * StyledText widget
+ */
+void wrapLines() {
+ wrapLines(renderer.getClientArea().width);
+}
+/**
+ * Wrap all logical lines at the given width.
+ * <p>
+ *
+ * @param width width to wrap lines at
+ */
+void wrapLines(int width) {
+ int lineCount = logicalContent.getLineCount();
+
+ visualLineCount = 0;
+ visualLines = new int[lineCount][2];
+ resetVisualLines(0, visualLines.length);
+ wrapLineRange(0, lineCount, 0, width);
+}
} \ No newline at end of file
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
index a96f55eb6b..14f1e04929 100755
--- 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
@@ -1,229 +1,229 @@
-package org.eclipse.swt.dnd;
-
-/*
+package org.eclipse.swt.dnd;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-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 performed
- * (value is 0).
- */
- public final static int DROP_NONE = 0;
-
- /**
- * Drag and Drop Operation: a copy of the data in the drag source is
- * added to the drop target (value is 1 &lt;&lt; 0).
- */
- public final static int DROP_COPY = 1 << 0;
-
- /**
- * Drag and Drop Operation: a copy of the data is added to the drop target and
- * the original data is removed from the drag source (value is 1 &lt;&lt; 1).
- */
- public final static int DROP_MOVE = 1 << 1;
-
- /**
- * Drag and Drop Operation: the drop target makes a link to the data in
- * the drag source (value is 1 &lt;&lt; 2).
- */
- public final static int DROP_LINK = 1 << 2;
-
- /**
- * Drag and Drop Operation: the drop target moves the data and the drag source removes
- * any references to the data and updates its display. This is not available on all platforms
- * and is only used when a non-SWT application is the drop target. In this case, the SWT
- * drag source is informed in the dragFinished event that the drop target has moved the data.
- * (value is 1 &lt;&lt; 3).
- *
- * @see DragSourceListener#dragFinished
- */
- public final static int DROP_TARGET_MOVE = 1 << 3;
-
- /**
- * Drag and Drop Operation: During a dragEnter event or a dragOperationChanged, if no modifier keys
- * are pressed, the operation is set to DROP_DEFAULT. The application can choose what the default
- * operation should be by setting a new value in the operation field. If no value is choosen, the
- * default operation for the platform will be selected (value is 1 &lt;&lt; 4).
- *
- * @see DropTargetListener#dragEnter
- * @see DropTargetListener#dragOperationChanged
- * @since 2.0
- */
- public final static int DROP_DEFAULT = 1 << 4;
-
- /**
- * DragSource Event: the drop has successfully completed or has been terminated (such as hitting
- * the ESC key); perform cleanup such as removing data on a move operation (value is 2000).
- */
- public static final int DragEnd = 2000;
-
- /**
- * DragSource Event: the data to be dropped is required from the drag source (value is 2001).
- */
- public static final int DragSetData = 2001;
-
- /**
- * DropTarget Event: the cursor has entered the drop target boundaries (value is 2002).
- */
- public static final int DragEnter = 2002;
-
- /**
- * DropTarget Event: the cursor has left the drop target boundaries OR the drop
- * operation has been cancelled (such as by hitting ECS) OR the drop is about to
- * happen (user has released the mous ebutotn over this target) (value is 2003).
- */
- public static final int DragLeave = 2003;
-
- /**
- * DropTarget Event: the cursor is over the drop target (value is 2004).
- */
- public static final int DragOver = 2004;
-
- /**
- * DropTarget Event: the operation being performed has changed usually due to the user
- * changing the selected modifier keys while dragging (value is 2005).
- */
- public static final int DragOperationChanged = 2005;
-
- /**
- * DropTarget Event: the data has been dropped (value is 2006).
- */
- public static final int Drop = 2006;
-
- /**
- * DropTarget Event: the drop target is given a last chance to modify the drop (value is 2007).
- */
- public static final int DropAccept = 2007;
-
- /**
- * DragSource Event: a drag is about to begin (value is 2008).
- */
- public static final int DragStart = 2008;
-
- /**
- * DropTarget drag under effect: No effect is shown (value is 0).
- */
- public static final int FEEDBACK_NONE = 0;
-
- /**
- * DropTarget drag under effect: The item under the cursor is selected; applies to tables
- * and trees (value is 1).
- */
- public static final int FEEDBACK_SELECT = 1;
-
- /**
- * DropTarget drag under effect: An insertion mark is shown before the item under the cursor; applies to
- * tables and trees (value is 2).
- */
- public static final int FEEDBACK_INSERT_BEFORE = 2;
-
- /**
- * DropTarget drag under effect:An insertion mark is shown after the item under the cursor; applies
- * to tables and trees (value is 4).
- */
- public static final int FEEDBACK_INSERT_AFTER = 4;
-
- /**
- * DropTarget drag under effect: The widget is scrolled up or down to allow the user to drop on items that
- * are not currently visible; applies to tables and trees (value is 8).
- */
- public static final int FEEDBACK_SCROLL = 8;
-
- /**
- * DropTarget drag under effect: The item currently under the cursor is expanded to allow the user to
- * select a drop target from a sub item; applies to trees (value is 16).
- */
- public static final int FEEDBACK_EXPAND = 16;
-
- /**
- * Error code: drag source can not be initialized (value is 2000).
- */
- public static final int ERROR_CANNOT_INIT_DRAG = 2000;
-
- /**
- * Error code: drop target cannot be initialized (value is 2001).
- */
- public static final int ERROR_CANNOT_INIT_DROP = 2001;
-
- /**
- * Error code: Data can not be set on system clipboard (value is 2002).
- */
- public static final int ERROR_CANNOT_SET_CLIPBOARD = 2002;
-
-
- static final String INIT_DRAG_MESSAGE = "Cannot initialize Drag"; //$NON-NLS-1$
- static final String INIT_DROP_MESSAGE = "Cannot initialize Drop"; //$NON-NLS-1$
- static final String CANNOT_SET_CLIPBOARD_MESSAGE = "Cannot set data in clipboard"; //$NON-NLS-1$
-
-/**
- * Throws an appropriate exception based on the passed in error code.
- *
- * @param code the DND error code
- */
-public static void error (int code) {
- error (code, 0);
-}
-
-/**
- * Throws an appropriate exception based on the passed in error code.
- * The <code>hresult</code> argument should be either 0, or the
- * platform specific error code.
- * <p>
- * In DND, errors are reported by throwing one of three exceptions:
- * <dl>
- * <dd>java.lang.IllegalArgumentException</dd>
- * <dt>thrown whenever one of the API methods is invoked with an illegal argument</dt>
- * <dd>org.eclipse.swt.SWTException (extends java.lang.RuntimeException)</dd>
- * <dt>thrown whenever a recoverable error happens internally in SWT</dt>
- * <dd>org.eclipse.swt.SWTError (extends java.lang.Error)</dd>
- * <dt>thrown whenever a <b>non-recoverable</b> error happens internally in SWT</dt>
- * </dl>
- * This method provides the logic which maps between error codes
- * and one of the above exceptions.
- * </p>
- *
- * @param code the DND error code.
- * @param hresult the platform specific error code.
- *
- * @see SWTError
- * @see SWTException
- * @see IllegalArgumentException
- */
-public static void error (int code, int hresult) {
- switch (code) {
- /* OS Failure/Limit (fatal, may occur only on some platforms) */
- case DND.ERROR_CANNOT_INIT_DRAG:{
- String msg = DND.INIT_DRAG_MESSAGE;
- if (hresult != 0) msg += " result = "+hresult; //$NON-NLS-1$
- throw new SWTError (code, msg);
- }
- case DND.ERROR_CANNOT_INIT_DROP:{
- String msg = DND.INIT_DROP_MESSAGE;
- if (hresult != 0) msg += " result = "+hresult; //$NON-NLS-1$
- throw new SWTError (code, msg);
- }
- case DND.ERROR_CANNOT_SET_CLIPBOARD:{
- String msg = DND.CANNOT_SET_CLIPBOARD_MESSAGE;
- if (hresult != 0) msg += " result = "+hresult; //$NON-NLS-1$
- throw new SWTError (code, msg);
- }
- }
-
- /* Unknown/Undefined Error */
- SWT.error(code);
-}
-
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+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 performed
+ * (value is 0).
+ */
+ public final static int DROP_NONE = 0;
+
+ /**
+ * Drag and Drop Operation: a copy of the data in the drag source is
+ * added to the drop target (value is 1 &lt;&lt; 0).
+ */
+ public final static int DROP_COPY = 1 << 0;
+
+ /**
+ * Drag and Drop Operation: a copy of the data is added to the drop target and
+ * the original data is removed from the drag source (value is 1 &lt;&lt; 1).
+ */
+ public final static int DROP_MOVE = 1 << 1;
+
+ /**
+ * Drag and Drop Operation: the drop target makes a link to the data in
+ * the drag source (value is 1 &lt;&lt; 2).
+ */
+ public final static int DROP_LINK = 1 << 2;
+
+ /**
+ * Drag and Drop Operation: the drop target moves the data and the drag source removes
+ * any references to the data and updates its display. This is not available on all platforms
+ * and is only used when a non-SWT application is the drop target. In this case, the SWT
+ * drag source is informed in the dragFinished event that the drop target has moved the data.
+ * (value is 1 &lt;&lt; 3).
+ *
+ * @see DragSourceListener#dragFinished
+ */
+ public final static int DROP_TARGET_MOVE = 1 << 3;
+
+ /**
+ * Drag and Drop Operation: During a dragEnter event or a dragOperationChanged, if no modifier keys
+ * are pressed, the operation is set to DROP_DEFAULT. The application can choose what the default
+ * operation should be by setting a new value in the operation field. If no value is choosen, the
+ * default operation for the platform will be selected (value is 1 &lt;&lt; 4).
+ *
+ * @see DropTargetListener#dragEnter
+ * @see DropTargetListener#dragOperationChanged
+ * @since 2.0
+ */
+ public final static int DROP_DEFAULT = 1 << 4;
+
+ /**
+ * DragSource Event: the drop has successfully completed or has been terminated (such as hitting
+ * the ESC key); perform cleanup such as removing data on a move operation (value is 2000).
+ */
+ public static final int DragEnd = 2000;
+
+ /**
+ * DragSource Event: the data to be dropped is required from the drag source (value is 2001).
+ */
+ public static final int DragSetData = 2001;
+
+ /**
+ * DropTarget Event: the cursor has entered the drop target boundaries (value is 2002).
+ */
+ public static final int DragEnter = 2002;
+
+ /**
+ * DropTarget Event: the cursor has left the drop target boundaries OR the drop
+ * operation has been cancelled (such as by hitting ECS) OR the drop is about to
+ * happen (user has released the mous ebutotn over this target) (value is 2003).
+ */
+ public static final int DragLeave = 2003;
+
+ /**
+ * DropTarget Event: the cursor is over the drop target (value is 2004).
+ */
+ public static final int DragOver = 2004;
+
+ /**
+ * DropTarget Event: the operation being performed has changed usually due to the user
+ * changing the selected modifier keys while dragging (value is 2005).
+ */
+ public static final int DragOperationChanged = 2005;
+
+ /**
+ * DropTarget Event: the data has been dropped (value is 2006).
+ */
+ public static final int Drop = 2006;
+
+ /**
+ * DropTarget Event: the drop target is given a last chance to modify the drop (value is 2007).
+ */
+ public static final int DropAccept = 2007;
+
+ /**
+ * DragSource Event: a drag is about to begin (value is 2008).
+ */
+ public static final int DragStart = 2008;
+
+ /**
+ * DropTarget drag under effect: No effect is shown (value is 0).
+ */
+ public static final int FEEDBACK_NONE = 0;
+
+ /**
+ * DropTarget drag under effect: The item under the cursor is selected; applies to tables
+ * and trees (value is 1).
+ */
+ public static final int FEEDBACK_SELECT = 1;
+
+ /**
+ * DropTarget drag under effect: An insertion mark is shown before the item under the cursor; applies to
+ * tables and trees (value is 2).
+ */
+ public static final int FEEDBACK_INSERT_BEFORE = 2;
+
+ /**
+ * DropTarget drag under effect:An insertion mark is shown after the item under the cursor; applies
+ * to tables and trees (value is 4).
+ */
+ public static final int FEEDBACK_INSERT_AFTER = 4;
+
+ /**
+ * DropTarget drag under effect: The widget is scrolled up or down to allow the user to drop on items that
+ * are not currently visible; applies to tables and trees (value is 8).
+ */
+ public static final int FEEDBACK_SCROLL = 8;
+
+ /**
+ * DropTarget drag under effect: The item currently under the cursor is expanded to allow the user to
+ * select a drop target from a sub item; applies to trees (value is 16).
+ */
+ public static final int FEEDBACK_EXPAND = 16;
+
+ /**
+ * Error code: drag source can not be initialized (value is 2000).
+ */
+ public static final int ERROR_CANNOT_INIT_DRAG = 2000;
+
+ /**
+ * Error code: drop target cannot be initialized (value is 2001).
+ */
+ public static final int ERROR_CANNOT_INIT_DROP = 2001;
+
+ /**
+ * Error code: Data can not be set on system clipboard (value is 2002).
+ */
+ public static final int ERROR_CANNOT_SET_CLIPBOARD = 2002;
+
+
+ static final String INIT_DRAG_MESSAGE = "Cannot initialize Drag"; //$NON-NLS-1$
+ static final String INIT_DROP_MESSAGE = "Cannot initialize Drop"; //$NON-NLS-1$
+ static final String CANNOT_SET_CLIPBOARD_MESSAGE = "Cannot set data in clipboard"; //$NON-NLS-1$
+
+/**
+ * Throws an appropriate exception based on the passed in error code.
+ *
+ * @param code the DND error code
+ */
+public static void error (int code) {
+ error (code, 0);
+}
+
+/**
+ * Throws an appropriate exception based on the passed in error code.
+ * The <code>hresult</code> argument should be either 0, or the
+ * platform specific error code.
+ * <p>
+ * In DND, errors are reported by throwing one of three exceptions:
+ * <dl>
+ * <dd>java.lang.IllegalArgumentException</dd>
+ * <dt>thrown whenever one of the API methods is invoked with an illegal argument</dt>
+ * <dd>org.eclipse.swt.SWTException (extends java.lang.RuntimeException)</dd>
+ * <dt>thrown whenever a recoverable error happens internally in SWT</dt>
+ * <dd>org.eclipse.swt.SWTError (extends java.lang.Error)</dd>
+ * <dt>thrown whenever a <b>non-recoverable</b> error happens internally in SWT</dt>
+ * </dl>
+ * This method provides the logic which maps between error codes
+ * and one of the above exceptions.
+ * </p>
+ *
+ * @param code the DND error code.
+ * @param hresult the platform specific error code.
+ *
+ * @see SWTError
+ * @see SWTException
+ * @see IllegalArgumentException
+ */
+public static void error (int code, int hresult) {
+ switch (code) {
+ /* OS Failure/Limit (fatal, may occur only on some platforms) */
+ case DND.ERROR_CANNOT_INIT_DRAG:{
+ String msg = DND.INIT_DRAG_MESSAGE;
+ if (hresult != 0) msg += " result = "+hresult; //$NON-NLS-1$
+ throw new SWTError (code, msg);
+ }
+ case DND.ERROR_CANNOT_INIT_DROP:{
+ String msg = DND.INIT_DROP_MESSAGE;
+ if (hresult != 0) msg += " result = "+hresult; //$NON-NLS-1$
+ throw new SWTError (code, msg);
+ }
+ case DND.ERROR_CANNOT_SET_CLIPBOARD:{
+ String msg = DND.CANNOT_SET_CLIPBOARD_MESSAGE;
+ if (hresult != 0) msg += " result = "+hresult; //$NON-NLS-1$
+ throw new SWTError (code, msg);
+ }
+ }
+
+ /* 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
index c8b2956073..4f66e017ca 100755
--- 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
@@ -1,19 +1,19 @@
-package org.eclipse.swt.dnd;
-
-/*
+package org.eclipse.swt.dnd;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-import org.eclipse.swt.widgets.*;
-
-class DNDEvent extends Event {
-
- public TransferData dataType;
- public TransferData[] dataTypes;
- public int operations;
- public int feedback;
-
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+import org.eclipse.swt.widgets.*;
+
+class DNDEvent extends Event {
+
+ public TransferData dataType;
+ public TransferData[] dataTypes;
+ public int operations;
+ public int feedback;
+
}
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
index 5e0ec3c123..f3fb27a5b6 100755
--- 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
@@ -1,80 +1,80 @@
-package org.eclipse.swt.dnd;
-
-/*
+package org.eclipse.swt.dnd;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-import org.eclipse.swt.widgets.Event;
-import org.eclipse.swt.internal.SWTEventListener;
-
-
-class DNDListener extends org.eclipse.swt.widgets.TypedListener {
-/**
- * DNDListener constructor comment.
- * @param listener org.eclipse.swt.internal.SWTEventListener
- */
-DNDListener(SWTEventListener listener) {
- super(listener);
-}
-public void handleEvent (Event e) {
- switch (e.type) {
- case DND.DragStart: {
- DragSourceEvent event = new DragSourceEvent((DNDEvent)e);
- ((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;
- }
-
- }
-}
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+import org.eclipse.swt.widgets.Event;
+import org.eclipse.swt.internal.SWTEventListener;
+
+
+class DNDListener extends org.eclipse.swt.widgets.TypedListener {
+/**
+ * DNDListener constructor comment.
+ * @param listener org.eclipse.swt.internal.SWTEventListener
+ */
+DNDListener(SWTEventListener listener) {
+ super(listener);
+}
+public void handleEvent (Event e) {
+ switch (e.type) {
+ case DND.DragStart: {
+ DragSourceEvent event = new DragSourceEvent((DNDEvent)e);
+ ((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
index 9752b94fc6..30e3085f15 100755
--- 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
@@ -1,37 +1,37 @@
-package org.eclipse.swt.dnd;
-
-/*
+package org.eclipse.swt.dnd;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-/**
- * This adapter class provides default implementations for the
- * methods described by the <code>DragSourceListener</code> interface.
- *
- * <p>Classes that wish to deal with <code>DragSourceEvent</code>s can
- * extend this class and override only the methods which they are
- * interested in.</p>
- *
- * @see DragSourceListener
- * @see DragSourceEvent
- */
-public class DragSourceAdapter implements DragSourceListener {
- /**
- * This implementation of <code>dragStart</code> permits the drag operation to start.
- * For additional information see <code>DragSourceListener.dragStart</code>.
- */
- public void dragStart(DragSourceEvent event){};
- /**
- * This implementation of <code>dragFinished</code> does nothing.
- * For additional information see <code>DragSourceListener.dragFinished</code>.
- */
- public void dragFinished(DragSourceEvent event){};
- /**
- * This implementation of <code>dragSetData</code> does nothing.
- * For additional information see <code>DragSourceListener.dragSetData</code>.
- */
- public void dragSetData(DragSourceEvent event){};
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+/**
+ * This adapter class provides default implementations for the
+ * methods described by the <code>DragSourceListener</code> interface.
+ *
+ * <p>Classes that wish to deal with <code>DragSourceEvent</code>s can
+ * extend this class and override only the methods which they are
+ * interested in.</p>
+ *
+ * @see DragSourceListener
+ * @see DragSourceEvent
+ */
+public class DragSourceAdapter implements DragSourceListener {
+ /**
+ * This implementation of <code>dragStart</code> permits the drag operation to start.
+ * For additional information see <code>DragSourceListener.dragStart</code>.
+ */
+ public void dragStart(DragSourceEvent event){};
+ /**
+ * This implementation of <code>dragFinished</code> does nothing.
+ * For additional information see <code>DragSourceListener.dragFinished</code>.
+ */
+ public void dragFinished(DragSourceEvent event){};
+ /**
+ * This implementation of <code>dragSetData</code> does nothing.
+ * For additional information see <code>DragSourceListener.dragSetData</code>.
+ */
+ public void dragSetData(DragSourceEvent event){};
}
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
index 505ac1c6d7..52af045884 100755
--- 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
@@ -1,66 +1,66 @@
-package org.eclipse.swt.dnd;
-
-/*
+package org.eclipse.swt.dnd;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-import org.eclipse.swt.events.TypedEvent;
-
-/**
- * The DragSourceEvent contains the event information passed in the methods of the DragSourceListener.
- *
- * @see DragSourceListener
- */
-public class DragSourceEvent extends TypedEvent {
- /**
- * The operation that was performed.
- * @see DND.DROP_NONE
- * @see DND.DROP_MOVE
- * @see DND.DROP_COPY
- * @see DND.DROP_LINK
- * @see DND.DROP_TARGET_MOVE.
- */
- public int detail;
-
- /**
- * In dragStart:
- * <p>Flag to determine if the drag and drop operation should proceed.
- * The application can set this value to false to prevent the drag from starting.
- * Set to true by default.</p>
- *
- * <p>In dragFinished:</p>
- * <p>Flag to indicate if the operation was performed successfully.
- * True if the operation was performed successfully.</p>
- */
- public boolean doit;
-
- /**
- * The type of data requested.
- * Data provided in the data field must be of the same type.
- */
- public TransferData dataType;
-
-/**
- * Constructs a new instance of this class based on the
- * information in the given untyped event.
- *
- * @param e the untyped event containing the information
- */
-public DragSourceEvent(DNDEvent e) {
- super(e);
- this.data = e.data;
- this.detail = e.detail;
- this.doit = e.doit;
- this.dataType = e.dataType;
-}
-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;
-}
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+import org.eclipse.swt.events.TypedEvent;
+
+/**
+ * The DragSourceEvent contains the event information passed in the methods of the DragSourceListener.
+ *
+ * @see DragSourceListener
+ */
+public class DragSourceEvent extends TypedEvent {
+ /**
+ * The operation that was performed.
+ * @see DND.DROP_NONE
+ * @see DND.DROP_MOVE
+ * @see DND.DROP_COPY
+ * @see DND.DROP_LINK
+ * @see DND.DROP_TARGET_MOVE.
+ */
+ public int detail;
+
+ /**
+ * In dragStart:
+ * <p>Flag to determine if the drag and drop operation should proceed.
+ * The application can set this value to false to prevent the drag from starting.
+ * Set to true by default.</p>
+ *
+ * <p>In dragFinished:</p>
+ * <p>Flag to indicate if the operation was performed successfully.
+ * True if the operation was performed successfully.</p>
+ */
+ public boolean doit;
+
+ /**
+ * The type of data requested.
+ * Data provided in the data field must be of the same type.
+ */
+ public TransferData dataType;
+
+/**
+ * Constructs a new instance of this class based on the
+ * information in the given untyped event.
+ *
+ * @param e the untyped event containing the information
+ */
+public DragSourceEvent(DNDEvent e) {
+ super(e);
+ this.data = e.data;
+ this.detail = e.detail;
+ this.doit = e.doit;
+ this.dataType = e.dataType;
+}
+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
index 70022107f2..407d412f7f 100755
--- 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
@@ -1,76 +1,76 @@
-package org.eclipse.swt.dnd;
-
-/*
+package org.eclipse.swt.dnd;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-import org.eclipse.swt.internal.SWTEventListener;
-
-/**
- * The <code>DragSourceListener</code> class provides event notification to the application for DragSource events.
- *
- * <p>When the user drops data on a <code>DropTarget</code>, the application which defines the <code>DragSource</code>
- * must provide the dropped data by implementing <code>dragSetData</code>. In the dragSetData, the application
- * must support all the data types that were specified in the DragSource#setTransfer method.</p>
- *
- * <p>After the drop has completed successfully or has been aborted, the application which defines the
- * <code>DragSource</code> is required to take the appropriate cleanup action. In the case of a successful
- * <b>move</b> operation, the application must remove the data that was transferred.</p>
- *
- */
-public interface DragSourceListener extends SWTEventListener {
-
-/**
- * The user has begun the actions required to drag the widget. This event gives the application
- * the chance to decide if a drag should be started.
- *
- * <p>The following fields in the DragSourceEvent apply:
- * <ul>
- * <li>(in)widget
- * <li>(in)time
- * <li>(in,out)doit
- * </ul></p>
- *
- * @param event the information associated with the drag start event
- *
- * @see DragSourceEvent
- */
-public void dragStart(DragSourceEvent event);
-
-/**
- * The data is required from the drag source.
- *
- * <p>The following fields in the DragSourceEvent apply:
- * <ul>
- * <li>(in)widget
- * <li>(in)time
- * <li>(in)dataType - the type of data requested.
- * <li>(out)data - the application inserts the actual data here (must match the dataType)
- * </ul></p>
- *
- * @param event the information associated with the drag set data event
- *
- * @see DragSourceEvent
- */
-public void dragSetData(DragSourceEvent event);
-
-/**
- * The drop has successfully completed(mouse up over a valid target) or has been terminated (such as hitting
- * the ESC key). Perform cleanup such as removing data from the source side on a successful move operation.
- *
- * <p>The following fields in the DragSourceEvent apply:
- * <ul>
- * <li>(in)widget
- * <li>(in)time
- * <li>(in)doit
- * <li>(in)detail
- * </ul></p>
- *
- * @param event the information associated with the drag finished event
- *
- * @see DragSourceEvent
- */
-public void dragFinished(DragSourceEvent event);
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+import org.eclipse.swt.internal.SWTEventListener;
+
+/**
+ * The <code>DragSourceListener</code> class provides event notification to the application for DragSource events.
+ *
+ * <p>When the user drops data on a <code>DropTarget</code>, the application which defines the <code>DragSource</code>
+ * must provide the dropped data by implementing <code>dragSetData</code>. In the dragSetData, the application
+ * must support all the data types that were specified in the DragSource#setTransfer method.</p>
+ *
+ * <p>After the drop has completed successfully or has been aborted, the application which defines the
+ * <code>DragSource</code> is required to take the appropriate cleanup action. In the case of a successful
+ * <b>move</b> operation, the application must remove the data that was transferred.</p>
+ *
+ */
+public interface DragSourceListener extends SWTEventListener {
+
+/**
+ * The user has begun the actions required to drag the widget. This event gives the application
+ * the chance to decide if a drag should be started.
+ *
+ * <p>The following fields in the DragSourceEvent apply:
+ * <ul>
+ * <li>(in)widget
+ * <li>(in)time
+ * <li>(in,out)doit
+ * </ul></p>
+ *
+ * @param event the information associated with the drag start event
+ *
+ * @see DragSourceEvent
+ */
+public void dragStart(DragSourceEvent event);
+
+/**
+ * The data is required from the drag source.
+ *
+ * <p>The following fields in the DragSourceEvent apply:
+ * <ul>
+ * <li>(in)widget
+ * <li>(in)time
+ * <li>(in)dataType - the type of data requested.
+ * <li>(out)data - the application inserts the actual data here (must match the dataType)
+ * </ul></p>
+ *
+ * @param event the information associated with the drag set data event
+ *
+ * @see DragSourceEvent
+ */
+public void dragSetData(DragSourceEvent event);
+
+/**
+ * The drop has successfully completed(mouse up over a valid target) or has been terminated (such as hitting
+ * the ESC key). Perform cleanup such as removing data from the source side on a successful move operation.
+ *
+ * <p>The following fields in the DragSourceEvent apply:
+ * <ul>
+ * <li>(in)widget
+ * <li>(in)time
+ * <li>(in)doit
+ * <li>(in)detail
+ * </ul></p>
+ *
+ * @param event the information associated with the drag finished event
+ *
+ * @see DragSourceEvent
+ */
+public void dragFinished(DragSourceEvent event);
+}
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
index 509f99eae9..d148e20f52 100755
--- 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
@@ -1,14 +1,14 @@
-package org.eclipse.swt.dnd;
-
-/*
+package org.eclipse.swt.dnd;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-abstract class DragUnderEffect {
-
-abstract void show(int effect, int x, int y);
-
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+abstract class DragUnderEffect {
+
+abstract void show(int effect, int x, int y);
+
}
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
index 08e195d5a9..21b97afbb8 100755
--- 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
@@ -1,63 +1,63 @@
-package org.eclipse.swt.dnd;
-
-/*
+package org.eclipse.swt.dnd;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-/**
- * This adapter class provides default implementations for the
- * methods described by the <code>DropTargetListener</code> interface.
- * <p>
- * Classes that wish to deal with <code>DropTargetEvent</code>s can
- * extend this class and override only the methods which they are
- * interested in.
- * </p>
- *
- * @see DropTargetListener
- * @see DropTargetEvent
- */
-public class DropTargetAdapter implements DropTargetListener {
-
-/**
- * This implementation of <code>dragEnter</code> permits the default
- * operation defined in <code>event.detail</code>to be performed on the current data type
- * defined in <code>event.currentDataType</code>.
- * For additional information see <code>DropTargetListener.dragEnter</code>.
- */
-public void dragEnter(DropTargetEvent event){};
-/**
- * This implementation of <code>dragLeave</code> does nothing.
- * For additional information see <code>DropTargetListener.dragOperationChanged</code>.
- */
-public void dragLeave(DropTargetEvent event){};
-/**
- * This implementation of <code>dragOperationChanged</code> permits the default
- * operation defined in <code>event.detail</code>to be performed on the current data type
- * defined in <code>event.currentDataType</code>.
- * For additional information see <code>DropTargetListener.dragOperationChanged</code>.
- */
-public void dragOperationChanged(DropTargetEvent event){};
-/**
- * This implementation of <code>dragOver</code> permits the default
- * operation defined in <code>event.detail</code>to be performed on the current data type
- * defined in <code>event.currentDataType</code>.
- * For additional information see <code>DropTargetListener.dragOver</code>.
- */
-public void dragOver(DropTargetEvent event){};
-/**
- * This implementation of <code>drop</code> does nothing.
- * For additional information see <code>DropTargetListener.drop</code>.
- */
-public void drop(DropTargetEvent event){};
-/**
- * This implementation of <code>dropAccept</code> permits the default
- * operation defined in <code>event.detail</code>to be performed on the current data type
- * defined in <code>event.currentDataType</code>.
- * For additional information see <code>DropTargetListener.dropAccept</code>.
- */
-public void dropAccept(DropTargetEvent event){};
-
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+/**
+ * This adapter class provides default implementations for the
+ * methods described by the <code>DropTargetListener</code> interface.
+ * <p>
+ * Classes that wish to deal with <code>DropTargetEvent</code>s can
+ * extend this class and override only the methods which they are
+ * interested in.
+ * </p>
+ *
+ * @see DropTargetListener
+ * @see DropTargetEvent
+ */
+public class DropTargetAdapter implements DropTargetListener {
+
+/**
+ * This implementation of <code>dragEnter</code> permits the default
+ * operation defined in <code>event.detail</code>to be performed on the current data type
+ * defined in <code>event.currentDataType</code>.
+ * For additional information see <code>DropTargetListener.dragEnter</code>.
+ */
+public void dragEnter(DropTargetEvent event){};
+/**
+ * This implementation of <code>dragLeave</code> does nothing.
+ * For additional information see <code>DropTargetListener.dragOperationChanged</code>.
+ */
+public void dragLeave(DropTargetEvent event){};
+/**
+ * This implementation of <code>dragOperationChanged</code> permits the default
+ * operation defined in <code>event.detail</code>to be performed on the current data type
+ * defined in <code>event.currentDataType</code>.
+ * For additional information see <code>DropTargetListener.dragOperationChanged</code>.
+ */
+public void dragOperationChanged(DropTargetEvent event){};
+/**
+ * This implementation of <code>dragOver</code> permits the default
+ * operation defined in <code>event.detail</code>to be performed on the current data type
+ * defined in <code>event.currentDataType</code>.
+ * For additional information see <code>DropTargetListener.dragOver</code>.
+ */
+public void dragOver(DropTargetEvent event){};
+/**
+ * This implementation of <code>drop</code> does nothing.
+ * For additional information see <code>DropTargetListener.drop</code>.
+ */
+public void drop(DropTargetEvent event){};
+/**
+ * This implementation of <code>dropAccept</code> permits the default
+ * operation defined in <code>event.detail</code>to be performed on the current data type
+ * defined in <code>event.currentDataType</code>.
+ * For additional information see <code>DropTargetListener.dropAccept</code>.
+ */
+public void dropAccept(DropTargetEvent event){};
+
}
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
index 3fdd81bb8f..e3069cc6a6 100755
--- 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
@@ -1,108 +1,108 @@
-package org.eclipse.swt.dnd;
-
-/*
+package org.eclipse.swt.dnd;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-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.
- */
-public class DropTargetEvent extends TypedEvent {
- /**
- * The x-cordinate of the cursor relative to the <code>Display</code>
- */
- public int x;
-
- /**
- * The y-cordinate of the cursor relative to the <code>Display</code>
- */
- public int y;
-
- /**
- * The operation being performed.
- * @see DND.DROP_NONE
- * @see DND.DROP_MOVE
- * @see DND.DROP_COPY
- * @see DND.DROP_LINK
- */
- public int detail;
-
- /**
- * A bitwise OR'ing of the operations that the DragSource can support
- * (e.g. DND.DROP_MOVE | DND.DROP_COPY | DND.DROP_LINK).
- * The detail value must be a member of this list or DND.DROP_NONE.
- * @see DND.DROP_NONE
- * @see DND.DROP_MOVE
- * @see DND.DROP_COPY
- * @see DND.DROP_LINK
- */
- public int operations;
-
- /**
- * A bitwise OR'ing of the drag under effect feedback to be displayed to the user
- * (e.g. DND.FEEDBACK_SELECT | DND.FEEDBACK_SCROLL | DND.FEEDBACK_EXPAND).
- * <p>A value of DND.FEEDBACK_NONE indicates that no drag under effect will be displayed.</p>
- * <p>Feedback effects will only be applied if they are applicable.</p>
- * <p>The default value is DND.FEEDBACK_SELECT.</p>
- * @see DND.FEEDBACK_SELECT
- * @see DND.FEEDBACK_INSERT_BEFORE
- * @see DND.FEEDBACK_INSERT_AFTER
- * @see DND.FEEDBACK_SCROLL
- * @see DND.FEEDBACK_EXPAND
- */
- public int feedback;
-
- /**
- * If the associated control is a table or tree, this field contains the item located
- * at the cursor coordinates.
- */
- public Widget item;
-
- /**
- * The type of data that will be dropped.
- */
- public TransferData currentDataType;
-
- /**
- * A list of the types of data that the DragSource is capable of providing.
- * The currentDataType must be a member of this list.
- */
- public TransferData[] dataTypes;
-
-/**
- * Constructs a new instance of this class based on the
- * information in the given untyped event.
- *
- * @param e the untyped event containing the information
- */
-public DropTargetEvent(DNDEvent e) {
- super(e);
- this.data = e.data;
- this.x = e.x;
- this.y = e.y;
- this.detail = e.detail;
- this.currentDataType = e.dataType;
- this.dataTypes = e.dataTypes;
- this.operations = e.operations;
- this.feedback = e.feedback;
- this.item = e.item;
-}
-void updateEvent(DNDEvent e) {
- e.widget = this.widget;
- e.time = this.time;
- e.data = this.data;
- e.x = this.x;
- e.y = this.y;
- e.detail = this.detail;
- e.dataType = this.currentDataType;
- e.dataTypes = this.dataTypes;
- e.operations = this.operations;
- e.feedback = this.feedback;
- e.item = this.item;
-}
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+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.
+ */
+public class DropTargetEvent extends TypedEvent {
+ /**
+ * The x-cordinate of the cursor relative to the <code>Display</code>
+ */
+ public int x;
+
+ /**
+ * The y-cordinate of the cursor relative to the <code>Display</code>
+ */
+ public int y;
+
+ /**
+ * The operation being performed.
+ * @see DND.DROP_NONE
+ * @see DND.DROP_MOVE
+ * @see DND.DROP_COPY
+ * @see DND.DROP_LINK
+ */
+ public int detail;
+
+ /**
+ * A bitwise OR'ing of the operations that the DragSource can support
+ * (e.g. DND.DROP_MOVE | DND.DROP_COPY | DND.DROP_LINK).
+ * The detail value must be a member of this list or DND.DROP_NONE.
+ * @see DND.DROP_NONE
+ * @see DND.DROP_MOVE
+ * @see DND.DROP_COPY
+ * @see DND.DROP_LINK
+ */
+ public int operations;
+
+ /**
+ * A bitwise OR'ing of the drag under effect feedback to be displayed to the user
+ * (e.g. DND.FEEDBACK_SELECT | DND.FEEDBACK_SCROLL | DND.FEEDBACK_EXPAND).
+ * <p>A value of DND.FEEDBACK_NONE indicates that no drag under effect will be displayed.</p>
+ * <p>Feedback effects will only be applied if they are applicable.</p>
+ * <p>The default value is DND.FEEDBACK_SELECT.</p>
+ * @see DND.FEEDBACK_SELECT
+ * @see DND.FEEDBACK_INSERT_BEFORE
+ * @see DND.FEEDBACK_INSERT_AFTER
+ * @see DND.FEEDBACK_SCROLL
+ * @see DND.FEEDBACK_EXPAND
+ */
+ public int feedback;
+
+ /**
+ * If the associated control is a table or tree, this field contains the item located
+ * at the cursor coordinates.
+ */
+ public Widget item;
+
+ /**
+ * The type of data that will be dropped.
+ */
+ public TransferData currentDataType;
+
+ /**
+ * A list of the types of data that the DragSource is capable of providing.
+ * The currentDataType must be a member of this list.
+ */
+ public TransferData[] dataTypes;
+
+/**
+ * Constructs a new instance of this class based on the
+ * information in the given untyped event.
+ *
+ * @param e the untyped event containing the information
+ */
+public DropTargetEvent(DNDEvent e) {
+ super(e);
+ this.data = e.data;
+ this.x = e.x;
+ this.y = e.y;
+ this.detail = e.detail;
+ this.currentDataType = e.dataType;
+ this.dataTypes = e.dataTypes;
+ this.operations = e.operations;
+ this.feedback = e.feedback;
+ this.item = e.item;
+}
+void updateEvent(DNDEvent e) {
+ e.widget = this.widget;
+ e.time = this.time;
+ e.data = this.data;
+ e.x = this.x;
+ e.y = this.y;
+ e.detail = this.detail;
+ e.dataType = this.currentDataType;
+ e.dataTypes = this.dataTypes;
+ e.operations = this.operations;
+ e.feedback = this.feedback;
+ e.item = this.item;
+}
+}
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
index b17b8e9cbd..c73688083e 100755
--- 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
@@ -1,246 +1,246 @@
-package org.eclipse.swt.dnd;
-
-/*
+package org.eclipse.swt.dnd;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-import org.eclipse.swt.internal.SWTEventListener;
-
-/**
- * The <code>DropTargetListener</code> class provides event notification to the application
- * for DropTarget events.
- *
- * <p>As the user moves the cursor into, over and out of a Control that has been designated
- * as a DropTarget, events indicate what operation can be performed and what data can be
- * transferred if a drop where to occur at that point.
- * The application can respond to these events and change the type of data that will
- * be dropped by modifying event.currentDataType, or change the operation that will be performed
- * by modifying the event.detail field or stop any drop from happening on the current target
- * by setting the event.detail field to DND_DROP_NONE.</p>
- *
- * <p>When the user causes a drop to happen by releasing the mouse over a valid drop target,
- * the application has one last chance to change the data type of the drop through the
- * DropAccept event. If the drop is still allowed, the DropAccept event is immediately
- * followed by the Drop event. In the Drop event, the application can still change the
- * operation that is performed but the data type is fixed.</p>
- *
- * @see DropTargetEvent
- *
- */
-public interface DropTargetListener extends SWTEventListener {
-
-/**
- * The cursor has entered the drop target boundaries.
- *
- * <p>The following fields in the DropTargetEvent apply:
- * <ul>
- * <li>(in)widget
- * <li>(in)time
- * <li>(in)x
- * <li>(in)y
- * <li>(in)dataTypes
- * <li>(in,out)currentDataType
- * <li>(in)operations
- * <li>(in,out)detail
- * <li>(in,out)feedback
- * </ul></p>
- *
- * <p>The <code>operation</code> value is determined by the modifier keys pressed by the user.
- * If no keys are pressed the <code>event.detail</code> field is set to DND.DROP_DEFAULT.
- * If the application does not set the <code>event.detail</code> to something other
- * than <code>DND.DROP_DEFAULT</code> the operation will be set to the platform defined standard
- * default.</p>
- *
- * <p>The <code>currentDataType</code> is determined by the first transfer agent specified in
- * setTransfer() that matches a data type provided by the drag source.</p>
- *
- * <p>It is possible to get a DragEnter event when the drag source does not provide any matching data.
- * In this case, the default operation is DND.DROP_NONE and the currentDataType is null.</p>
- *
- * <p>The application can change the operation that will be performed by modifying the
- * <code>detail</code> field but the choice must be one of the values in the <code>operations</code>
- * field or DND.DROP_NONE.</p>
- *
- * <p>The application can also change the type of data being requested by
- * modifying the <code>currentDataTypes</code> field but the value must be one of the values
- * in the <code>dataTypes</code> list.</p>
- *
- * @param event the information associated with the drag enter event
- *
- * @see DropTargetEvent
- */
-public void dragEnter(DropTargetEvent event);
-
-/**
- * The cursor has left the drop target boundaries OR the drop has been cancelled OR the data
- * is about to be dropped.
- *
- * <p>The following fields in the DropTargetEvent apply:
- * <ul>
- * <li>(in)widget
- * <li>(in)time
- * <li>(in)x
- * <li>(in)y
- * <li>(in)dataTypes
- * <li>(in)currentDataType
- * <li>(in)operations
- * <li>(in)detail
- * </ul></p>
- *
- * @param event the information associated with the drag leave event
- *
- * @see DropTargetEvent
- */
-public void dragLeave(DropTargetEvent event);
-
-/**
- * The operation being performed has changed (usually due to the user changing the selected modifier key(s)
- * while dragging).
- *
- * <p>The following fields in the DropTargetEvent apply:
- * <ul>
- * <li>(in)widget
- * <li>(in)time
- * <li>(in)x
- * <li>(in)y
- * <li>(in)dataTypes
- * <li>(in,out)currentDataType
- * <li>(in)operations
- * <li>(in,out)detail
- * <li>(in,out)feedback
- * </ul></p>
- *
- * <p>The <code>operation</code> value is determined by the modifier keys pressed by the user.
- * If no keys are pressed the <code>event.detail</code> field is set to DND.DROP_DEFAULT.
- * If the application does not set the <code>event.detail</code> to something other than
- * <code>DND.DROP_DEFAULT</code> the operation will be set to the platform defined standard default.</p>
- *
- * <p>The <code>currentDataType</code> value is determined by the value assigned to
- * <code>currentDataType</code> in previous dragEnter and dragOver calls.</p>
- *
- * <p>The application can change the operation that will be performed by modifying the
- * <code>detail</code> field but the choice must be one of the values in the <code>operations</code>
- * field.</p>
- *
- * <p>The application can also change the type of data being requested by modifying
- * the <code>currentDataTypes</code> field but the value must be one of the values in the
- * <code>dataTypes</code> list.</p>
- *
- * @param event the information associated with the drag operation changed event
- *
- * @see DropTargetEvent
- */
-public void dragOperationChanged(DropTargetEvent event);
-
-/**
- * The cursor is moving over the drop target.
- *
- * <p>The following fields in the DropTargetEvent apply:
- * <ul>
- * <li>(in)widget
- * <li>(in)time
- * <li>(in)x
- * <li>(in)y
- * <li>(in)dataTypes
- * <li>(in,out)currentDataType
- * <li>(in)operations
- * <li>(in,out)detail
- * <li>(in,out)feedback
- * </ul></p>
- *
- * <p>The <code>operation</code> value is determined by the value assigned to
- * <code>currentDataType</code> in previous dragEnter and dragOver calls.</p>
- *
- * <p>The <code>currentDataType</code> value is determined by the value assigned to
- * <code>currentDataType</code> in previous dragEnter and dragOver calls.</p>
- *
- * <p>The application can change the operation that will be performed by modifying the
- * <code>detail</code> field but the choice must be one of the values in the <code>operations</code>
- * field.</p>
- *
- * <p>The application can also change the type of data being requested by modifying the
- * <code>currentDataTypes</code> field but the value must be one of the values in the
- * <code>dataTypes</code> list.</p>
- *
- * <p>NOTE: At this point the <code>data</code> field is null. On some platforms, it is possible
- * to obtain the data being transferred before the transfer occurs but in most platforms this is
- * not possible. On those platforms where the data is available, the application can access the
- * data as follows:</p>
- *
- * <pre><code>
- * public void dragOver(DropTargetEvent event) {
- * TextTransfer textTransfer = TextTransfer.getInstance();
- * String data = (String)textTransfer.nativeToJava(event.currentDataType);
- * if (data != null) {
- * System.out.println("Data to be dropped is (Text)"+data);
- * }
- * };
- * </code></pre>
- *
- * @param event the information associated with the drag over event
- *
- * @see DropTargetEvent
- */
-public void dragOver(DropTargetEvent event);
-
-/**
- * The data is being dropped. The data field contains java format of the data being dropped.
- * To determine the type of the data object, refer to the documentation for the Transfer subclass
- * specified in event.currentDataType.
- *
- * <p>The following fields in DropTargetEvent apply:
- * <ul>
- * <li>(in)widget
- * <li>(in)time
- * <li>(in)x
- * <li>(in)y
- * <li>(in,out)detail
- * <li>(in)currentDataType
- * <li>(in)data
- * </ul></p>
- *
- * <p>The application can refuse to perform the drop operation by setting the detail
- * field to DND.DROP_NONE.</p>
- *
- * @param event the information associated with the drop event
- *
- * @see DropTargetEvent
- */
-public void drop(DropTargetEvent event);
-
-/**
- * The drop is about to be performed.
- * The drop target is given a last chance to change the nature of the drop.
- *
- * <p>The following fields in the DropTargetEvent apply:
- * <ul>
- * <li>(in)widget
- * <li>(in)time
- * <li>(in)x
- * <li>(in)y
- * <li>(in)dataTypes
- * <li>(in,out)currentDataType
- * <li>(in)operations
- * <li>(in,out)detail
- * </ul></p>
- *
- * <p>The application can veto the drop by setting the <code>event.detail</code> field to
- * <code>DND.DROP_NONE</code>.</p>
- *
- * <p>The application can change the operation that will be performed by modifying the
- * <code>detail</code> field but the choice must be one of the values in the
- * <code>operations</code> field.</p>
- *
- * <p>The application can also change the type of data being requested by modifying the
- * <code>currentDataTypes</code> field but the value must be one of the values in the <
- * code>dataTypes</code> list.</p>
- *
- * @param event the information associated with the drop accept event
- *
- * @see DropTargetEvent
- */
-public void dropAccept(DropTargetEvent event);
-
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+import org.eclipse.swt.internal.SWTEventListener;
+
+/**
+ * The <code>DropTargetListener</code> class provides event notification to the application
+ * for DropTarget events.
+ *
+ * <p>As the user moves the cursor into, over and out of a Control that has been designated
+ * as a DropTarget, events indicate what operation can be performed and what data can be
+ * transferred if a drop where to occur at that point.
+ * The application can respond to these events and change the type of data that will
+ * be dropped by modifying event.currentDataType, or change the operation that will be performed
+ * by modifying the event.detail field or stop any drop from happening on the current target
+ * by setting the event.detail field to DND_DROP_NONE.</p>
+ *
+ * <p>When the user causes a drop to happen by releasing the mouse over a valid drop target,
+ * the application has one last chance to change the data type of the drop through the
+ * DropAccept event. If the drop is still allowed, the DropAccept event is immediately
+ * followed by the Drop event. In the Drop event, the application can still change the
+ * operation that is performed but the data type is fixed.</p>
+ *
+ * @see DropTargetEvent
+ *
+ */
+public interface DropTargetListener extends SWTEventListener {
+
+/**
+ * The cursor has entered the drop target boundaries.
+ *
+ * <p>The following fields in the DropTargetEvent apply:
+ * <ul>
+ * <li>(in)widget
+ * <li>(in)time
+ * <li>(in)x
+ * <li>(in)y
+ * <li>(in)dataTypes
+ * <li>(in,out)currentDataType
+ * <li>(in)operations
+ * <li>(in,out)detail
+ * <li>(in,out)feedback
+ * </ul></p>
+ *
+ * <p>The <code>operation</code> value is determined by the modifier keys pressed by the user.
+ * If no keys are pressed the <code>event.detail</code> field is set to DND.DROP_DEFAULT.
+ * If the application does not set the <code>event.detail</code> to something other
+ * than <code>DND.DROP_DEFAULT</code> the operation will be set to the platform defined standard
+ * default.</p>
+ *
+ * <p>The <code>currentDataType</code> is determined by the first transfer agent specified in
+ * setTransfer() that matches a data type provided by the drag source.</p>
+ *
+ * <p>It is possible to get a DragEnter event when the drag source does not provide any matching data.
+ * In this case, the default operation is DND.DROP_NONE and the currentDataType is null.</p>
+ *
+ * <p>The application can change the operation that will be performed by modifying the
+ * <code>detail</code> field but the choice must be one of the values in the <code>operations</code>
+ * field or DND.DROP_NONE.</p>
+ *
+ * <p>The application can also change the type of data being requested by
+ * modifying the <code>currentDataTypes</code> field but the value must be one of the values
+ * in the <code>dataTypes</code> list.</p>
+ *
+ * @param event the information associated with the drag enter event
+ *
+ * @see DropTargetEvent
+ */
+public void dragEnter(DropTargetEvent event);
+
+/**
+ * The cursor has left the drop target boundaries OR the drop has been cancelled OR the data
+ * is about to be dropped.
+ *
+ * <p>The following fields in the DropTargetEvent apply:
+ * <ul>
+ * <li>(in)widget
+ * <li>(in)time
+ * <li>(in)x
+ * <li>(in)y
+ * <li>(in)dataTypes
+ * <li>(in)currentDataType
+ * <li>(in)operations
+ * <li>(in)detail
+ * </ul></p>
+ *
+ * @param event the information associated with the drag leave event
+ *
+ * @see DropTargetEvent
+ */
+public void dragLeave(DropTargetEvent event);
+
+/**
+ * The operation being performed has changed (usually due to the user changing the selected modifier key(s)
+ * while dragging).
+ *
+ * <p>The following fields in the DropTargetEvent apply:
+ * <ul>
+ * <li>(in)widget
+ * <li>(in)time
+ * <li>(in)x
+ * <li>(in)y
+ * <li>(in)dataTypes
+ * <li>(in,out)currentDataType
+ * <li>(in)operations
+ * <li>(in,out)detail
+ * <li>(in,out)feedback
+ * </ul></p>
+ *
+ * <p>The <code>operation</code> value is determined by the modifier keys pressed by the user.
+ * If no keys are pressed the <code>event.detail</code> field is set to DND.DROP_DEFAULT.
+ * If the application does not set the <code>event.detail</code> to something other than
+ * <code>DND.DROP_DEFAULT</code> the operation will be set to the platform defined standard default.</p>
+ *
+ * <p>The <code>currentDataType</code> value is determined by the value assigned to
+ * <code>currentDataType</code> in previous dragEnter and dragOver calls.</p>
+ *
+ * <p>The application can change the operation that will be performed by modifying the
+ * <code>detail</code> field but the choice must be one of the values in the <code>operations</code>
+ * field.</p>
+ *
+ * <p>The application can also change the type of data being requested by modifying
+ * the <code>currentDataTypes</code> field but the value must be one of the values in the
+ * <code>dataTypes</code> list.</p>
+ *
+ * @param event the information associated with the drag operation changed event
+ *
+ * @see DropTargetEvent
+ */
+public void dragOperationChanged(DropTargetEvent event);
+
+/**
+ * The cursor is moving over the drop target.
+ *
+ * <p>The following fields in the DropTargetEvent apply:
+ * <ul>
+ * <li>(in)widget
+ * <li>(in)time
+ * <li>(in)x
+ * <li>(in)y
+ * <li>(in)dataTypes
+ * <li>(in,out)currentDataType
+ * <li>(in)operations
+ * <li>(in,out)detail
+ * <li>(in,out)feedback
+ * </ul></p>
+ *
+ * <p>The <code>operation</code> value is determined by the value assigned to
+ * <code>currentDataType</code> in previous dragEnter and dragOver calls.</p>
+ *
+ * <p>The <code>currentDataType</code> value is determined by the value assigned to
+ * <code>currentDataType</code> in previous dragEnter and dragOver calls.</p>
+ *
+ * <p>The application can change the operation that will be performed by modifying the
+ * <code>detail</code> field but the choice must be one of the values in the <code>operations</code>
+ * field.</p>
+ *
+ * <p>The application can also change the type of data being requested by modifying the
+ * <code>currentDataTypes</code> field but the value must be one of the values in the
+ * <code>dataTypes</code> list.</p>
+ *
+ * <p>NOTE: At this point the <code>data</code> field is null. On some platforms, it is possible
+ * to obtain the data being transferred before the transfer occurs but in most platforms this is
+ * not possible. On those platforms where the data is available, the application can access the
+ * data as follows:</p>
+ *
+ * <pre><code>
+ * public void dragOver(DropTargetEvent event) {
+ * TextTransfer textTransfer = TextTransfer.getInstance();
+ * String data = (String)textTransfer.nativeToJava(event.currentDataType);
+ * if (data != null) {
+ * System.out.println("Data to be dropped is (Text)"+data);
+ * }
+ * };
+ * </code></pre>
+ *
+ * @param event the information associated with the drag over event
+ *
+ * @see DropTargetEvent
+ */
+public void dragOver(DropTargetEvent event);
+
+/**
+ * The data is being dropped. The data field contains java format of the data being dropped.
+ * To determine the type of the data object, refer to the documentation for the Transfer subclass
+ * specified in event.currentDataType.
+ *
+ * <p>The following fields in DropTargetEvent apply:
+ * <ul>
+ * <li>(in)widget
+ * <li>(in)time
+ * <li>(in)x
+ * <li>(in)y
+ * <li>(in,out)detail
+ * <li>(in)currentDataType
+ * <li>(in)data
+ * </ul></p>
+ *
+ * <p>The application can refuse to perform the drop operation by setting the detail
+ * field to DND.DROP_NONE.</p>
+ *
+ * @param event the information associated with the drop event
+ *
+ * @see DropTargetEvent
+ */
+public void drop(DropTargetEvent event);
+
+/**
+ * The drop is about to be performed.
+ * The drop target is given a last chance to change the nature of the drop.
+ *
+ * <p>The following fields in the DropTargetEvent apply:
+ * <ul>
+ * <li>(in)widget
+ * <li>(in)time
+ * <li>(in)x
+ * <li>(in)y
+ * <li>(in)dataTypes
+ * <li>(in,out)currentDataType
+ * <li>(in)operations
+ * <li>(in,out)detail
+ * </ul></p>
+ *
+ * <p>The application can veto the drop by setting the <code>event.detail</code> field to
+ * <code>DND.DROP_NONE</code>.</p>
+ *
+ * <p>The application can change the operation that will be performed by modifying the
+ * <code>detail</code> field but the choice must be one of the values in the
+ * <code>operations</code> field.</p>
+ *
+ * <p>The application can also change the type of data being requested by modifying the
+ * <code>currentDataTypes</code> field but the value must be one of the values in the <
+ * code>dataTypes</code> list.</p>
+ *
+ * @param event the information associated with the drop accept event
+ *
+ * @see DropTargetEvent
+ */
+public void dropAccept(DropTargetEvent event);
+
+}
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
index 0d41868896..ba38f5f46c 100755
--- 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
@@ -1,16 +1,16 @@
-package org.eclipse.swt.dnd;
-
-/*
+package org.eclipse.swt.dnd;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-import org.eclipse.swt.widgets.*;
-
-class NoDragUnderEffect extends DragUnderEffect {
-
-NoDragUnderEffect(Control control) {}
-void show(int effect, int x, int y){}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+import org.eclipse.swt.widgets.*;
+
+class NoDragUnderEffect extends DragUnderEffect {
+
+NoDragUnderEffect(Control control) {}
+void show(int effect, int x, int y){}
}
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
index 737d94e20e..6a61c36aa6 100755
--- 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
@@ -1,178 +1,178 @@
-package org.eclipse.swt.dnd;
-
-/*
+package org.eclipse.swt.dnd;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-import org.eclipse.swt.internal.motif.OS;
-
-/**
- * The class <code>ByteArrayTransfer</code> provides a platform specific
- * mechanism for converting a java <code>byte[]</code> to a platform
- * specific representation of the byte array and vice versa. See
- * <code>Transfer</code> for additional information.
- *
- * <p><code>ByteArrayTransfer</code> is never used directly but is sub-classed
- * by transfer agents that convert between data in a java format such as a
- * <code>String</code> and a platform specific byte array.
- *
- * <p>If the data you are converting <b>does not</b> map to a
- * <code>byte[]</code>, you should sub-class <code>Transfer</code> directly
- * and do your own mapping to a platform data type.</p>
- *
- * <p>The following snippet shows a sublcass of ByteArrayTransfer that transfers
- * data defined by the class <code>MyType</code>.</p>
- *
- * <pre><code>
- * public class MyType {
- * public String fileName;
- * public long fileLength;
- * public long lastModified;
- * }
- * </code></pre>
- *
- * <code><pre>
- * public class MyTypeTransfer extends ByteArrayTransfer {
- *
- * private static final String MYTYPENAME = "my_type_name";
- * private static final int MYTYPEID = registerType(MYTYPENAME);
- * private static MyTypeTransfer _instance = new MyTypeTransfer();
- *
- * private MyTypeTransfer() {}
- *
- * public static MyTypeTransfer getInstance () {
- * return _instance;
- * }
- * public void javaToNative (Object object, TransferData transferData) {
- * if (object == null || !(object instanceof MyType[])) return;
- *
- * if (isSupportedType(transferData)) {
- * MyType[] myTypes = (MyType[]) object;
- * try {
- * // write data to a byte array and then ask super to convert to pMedium
- * ByteArrayOutputStream out = new ByteArrayOutputStream();
- * DataOutputStream writeOut = new DataOutputStream(out);
- * for (int i = 0, length = myTypes.length; i < length; i++){
- * byte[] buffer = myTypes[i].fileName.getBytes();
- * writeOut.writeInt(buffer.length);
- * writeOut.write(buffer);
- * writeOut.writeLong(myTypes[i].fileLength);
- * writeOut.writeLong(myTypes[i].lastModified);
- * }
- * byte[] buffer = out.toByteArray();
- * writeOut.close();
- *
- * super.javaToNative(buffer, transferData);
- *
- * } catch (IOException e) {
- * }
- * }
- * }
- * public Object nativeToJava(TransferData transferData){
- *
- * if (isSupportedType(transferData)) {
- *
- * byte[] buffer = (byte[])super.nativeToJava(transferData);
- * if (buffer == null) return null;
- *
- * MyType[] myData = new MyType[0];
- * try {
- * ByteArrayInputStream in = new ByteArrayInputStream(buffer);
- * DataInputStream readIn = new DataInputStream(in);
- * while(readIn.available() > 20) {
- * MyType datum = new MyType();
- * int size = readIn.readInt();
- * byte[] name = new byte[size];
- * readIn.read(name);
- * datum.fileName = new String(name);
- * datum.fileLength = readIn.readLong();
- * datum.lastModified = readIn.readLong();
- * MyType[] newMyData = new MyType[myData.length + 1];
- * System.arraycopy(myData, 0, newMyData, 0, myData.length);
- * newMyData[myData.length] = datum;
- * myData = newMyData;
- * }
- * readIn.close();
- * } catch (IOException ex) {
- * return null;
- * }
- * return myData;
- * }
- *
- * return null;
- * }
- * protected String[] getTypeNames(){
- * return new String[]{MYTYPENAME};
- * }
- * protected int[] getTypeIds(){
- * return new int[] {MYTYPEID};
- * }
- * }
+ * http://www.eclipse.org/legal/cpl-v10.html
*/
-public abstract class ByteArrayTransfer extends Transfer {
-
-public TransferData[] getSupportedTypes(){
- int[] types = getTypeIds();
- TransferData[] data = new TransferData[types.length];
- for (int i = 0; i < types.length; i++) {
- data[i] = new TransferData();
- data[i].type = types[i];
- }
- return data;
-}
-public boolean isSupportedType(TransferData transferData){
- if (transferData == null) return false;
- int[] types = getTypeIds();
- for (int i = 0; i < types.length; i++) {
- if (transferData.type == types[i]) return true;
- }
- return false;
-}
-
-/**
- * This implementation of <code>javaToNative</code> converts a java
- * <code>byte[]</code> to a platform specific representation. For additional
- * information see <code>Transfer#javaToNative</code>.
- *
- * @see Transfer#javaToNative
- *
- * @param object a java <code>byte[]</code> containing the data to be converted
- * @param transferData an empty <code>TransferData</code> object; this
- * object will be filled in on return with the platform specific format of the data
- */
-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);
- OS.memmove(transferData.pValue, buffer, buffer.length);
- transferData.length = buffer.length;
- transferData.format = 8;
- transferData.result = 1;
-}
-
-/**
- * This implementation of <code>nativeToJava</code> converts a platform specific
- * representation of a byte array to a java <code>byte[]</code>.
- * For additional information see <code>Transfer#nativeToJava</code>.
- *
- * @see Transfer#nativeToJava
- *
- * @param transferData the platform specific representation of the data to be
- * been converted
- * @return a java <code>byte[]</code> containing the converted data if the
- * conversion was successful; otherwise null
- */
-protected Object nativeToJava(TransferData transferData){
- if ( !(isSupportedType(transferData) || transferData.pValue == 0)) return null;
- int size = transferData.format * transferData.length / 8;
- byte[] buffer = new byte[size];
- OS.memmove(buffer, transferData.pValue, size);
- return buffer;
-}
-}
+
+import org.eclipse.swt.internal.motif.OS;
+
+/**
+ * The class <code>ByteArrayTransfer</code> provides a platform specific
+ * mechanism for converting a java <code>byte[]</code> to a platform
+ * specific representation of the byte array and vice versa. See
+ * <code>Transfer</code> for additional information.
+ *
+ * <p><code>ByteArrayTransfer</code> is never used directly but is sub-classed
+ * by transfer agents that convert between data in a java format such as a
+ * <code>String</code> and a platform specific byte array.
+ *
+ * <p>If the data you are converting <b>does not</b> map to a
+ * <code>byte[]</code>, you should sub-class <code>Transfer</code> directly
+ * and do your own mapping to a platform data type.</p>
+ *
+ * <p>The following snippet shows a sublcass of ByteArrayTransfer that transfers
+ * data defined by the class <code>MyType</code>.</p>
+ *
+ * <pre><code>
+ * public class MyType {
+ * public String fileName;
+ * public long fileLength;
+ * public long lastModified;
+ * }
+ * </code></pre>
+ *
+ * <code><pre>
+ * public class MyTypeTransfer extends ByteArrayTransfer {
+ *
+ * private static final String MYTYPENAME = "my_type_name";
+ * private static final int MYTYPEID = registerType(MYTYPENAME);
+ * private static MyTypeTransfer _instance = new MyTypeTransfer();
+ *
+ * private MyTypeTransfer() {}
+ *
+ * public static MyTypeTransfer getInstance () {
+ * return _instance;
+ * }
+ * public void javaToNative (Object object, TransferData transferData) {
+ * if (object == null || !(object instanceof MyType[])) return;
+ *
+ * if (isSupportedType(transferData)) {
+ * MyType[] myTypes = (MyType[]) object;
+ * try {
+ * // write data to a byte array and then ask super to convert to pMedium
+ * ByteArrayOutputStream out = new ByteArrayOutputStream();
+ * DataOutputStream writeOut = new DataOutputStream(out);
+ * for (int i = 0, length = myTypes.length; i < length; i++){
+ * byte[] buffer = myTypes[i].fileName.getBytes();
+ * writeOut.writeInt(buffer.length);
+ * writeOut.write(buffer);
+ * writeOut.writeLong(myTypes[i].fileLength);
+ * writeOut.writeLong(myTypes[i].lastModified);
+ * }
+ * byte[] buffer = out.toByteArray();
+ * writeOut.close();
+ *
+ * super.javaToNative(buffer, transferData);
+ *
+ * } catch (IOException e) {
+ * }
+ * }
+ * }
+ * public Object nativeToJava(TransferData transferData){
+ *
+ * if (isSupportedType(transferData)) {
+ *
+ * byte[] buffer = (byte[])super.nativeToJava(transferData);
+ * if (buffer == null) return null;
+ *
+ * MyType[] myData = new MyType[0];
+ * try {
+ * ByteArrayInputStream in = new ByteArrayInputStream(buffer);
+ * DataInputStream readIn = new DataInputStream(in);
+ * while(readIn.available() > 20) {
+ * MyType datum = new MyType();
+ * int size = readIn.readInt();
+ * byte[] name = new byte[size];
+ * readIn.read(name);
+ * datum.fileName = new String(name);
+ * datum.fileLength = readIn.readLong();
+ * datum.lastModified = readIn.readLong();
+ * MyType[] newMyData = new MyType[myData.length + 1];
+ * System.arraycopy(myData, 0, newMyData, 0, myData.length);
+ * newMyData[myData.length] = datum;
+ * myData = newMyData;
+ * }
+ * readIn.close();
+ * } catch (IOException ex) {
+ * return null;
+ * }
+ * return myData;
+ * }
+ *
+ * return null;
+ * }
+ * protected String[] getTypeNames(){
+ * return new String[]{MYTYPENAME};
+ * }
+ * protected int[] getTypeIds(){
+ * return new int[] {MYTYPEID};
+ * }
+ * }
+ */
+public abstract class ByteArrayTransfer extends Transfer {
+
+public TransferData[] getSupportedTypes(){
+ int[] types = getTypeIds();
+ TransferData[] data = new TransferData[types.length];
+ for (int i = 0; i < types.length; i++) {
+ data[i] = new TransferData();
+ data[i].type = types[i];
+ }
+ return data;
+}
+public boolean isSupportedType(TransferData transferData){
+ if (transferData == null) return false;
+ int[] types = getTypeIds();
+ for (int i = 0; i < types.length; i++) {
+ if (transferData.type == types[i]) return true;
+ }
+ return false;
+}
+
+/**
+ * This implementation of <code>javaToNative</code> converts a java
+ * <code>byte[]</code> to a platform specific representation. For additional
+ * information see <code>Transfer#javaToNative</code>.
+ *
+ * @see Transfer#javaToNative
+ *
+ * @param object a java <code>byte[]</code> containing the data to be converted
+ * @param transferData an empty <code>TransferData</code> object; this
+ * object will be filled in on return with the platform specific format of the data
+ */
+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);
+ OS.memmove(transferData.pValue, buffer, buffer.length);
+ transferData.length = buffer.length;
+ transferData.format = 8;
+ transferData.result = 1;
+}
+
+/**
+ * This implementation of <code>nativeToJava</code> converts a platform specific
+ * representation of a byte array to a java <code>byte[]</code>.
+ * For additional information see <code>Transfer#nativeToJava</code>.
+ *
+ * @see Transfer#nativeToJava
+ *
+ * @param transferData the platform specific representation of the data to be
+ * been converted
+ * @return a java <code>byte[]</code> containing the converted data if the
+ * conversion was successful; otherwise null
+ */
+protected Object nativeToJava(TransferData transferData){
+ if ( !(isSupportedType(transferData) || transferData.pValue == 0)) 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
index 9643ecdb0d..69a81d950f 100755
--- 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
@@ -1,332 +1,332 @@
-package org.eclipse.swt.dnd;
-
-/*
+package org.eclipse.swt.dnd;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-import org.eclipse.swt.*;
-import org.eclipse.swt.internal.*;
-import org.eclipse.swt.internal.motif.*;
-import org.eclipse.swt.widgets.*;
-
-/**
- * The <code>Clipboard</code> provides a mechanism for transferring data from one
- * application to another or within an application.
- *
- * <p>IMPORTANT: This class is <em>not</em> intended to be subclassed.</p>
- */
-public class Clipboard {
-
- private Display display;
- private final int MAX_RETRIES = 10;
- private int shellHandle;
-
-
-/**
- * Constructs a new instance of this class. Creating an instance of a Clipboard
- * may cause system resources to be allocated depending on the platform. It is therefore
- * mandatory that the Clipboard instance be disposed when no longer required.
- *
- * @param display the display on which to allocate the clipboard
- *
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
- * <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
- * </ul>
- *
- * @see Clipboard#dispose
- * @see Clipboard#checkSubclass
- */
-public Clipboard(Display display) {
- checkSubclass ();
- if (display == null) {
- display = Display.getCurrent();
- if (display == null) {
- display = Display.getDefault();
- }
- }
- if (display.getThread() != Thread.currentThread()) {
- 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);
-}
-
-/**
- * Checks that this class can be subclassed.
- * <p>
- * The SWT class library is intended to be subclassed
- * only at specific, controlled points. This method enforces this
- * rule unless it is overridden.
- * </p><p>
- * <em>IMPORTANT:</em> By providing an implementation of this
- * method that allows a subclass of a class which does not
- * normally allow subclassing to be created, the implementer
- * agrees to be fully responsible for the fact that any such
- * subclass will likely fail between SWT releases and will be
- * strongly platform specific. No support is provided for
- * user-written classes which are implemented in this fashion.
- * </p><p>
- * The ability to subclass outside of the allowed SWT classes
- * is intended purely to enable those not on the SWT development
- * team to implement patches in order to get around specific
- * limitations in advance of when those limitations can be
- * addressed by the team. Subclassing should not be attempted
- * without an intimate and detailed understanding of the hierarchy.
- * </p>
- *
- * @exception SWTException <ul>
- * <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
- * </ul>
- */
-protected void checkSubclass () {
- String name = getClass().getName ();
- String validName = Clipboard.class.getName();
- if (!validName.equals(name)) {
- DND.error (SWT.ERROR_INVALID_SUBCLASS);
- }
-}
-
-/**
- * Disposes of the operating system resources associated with the clipboard.
- * The data will still be available on the system clipboard after the dispose
- * method is called.
- *
- * <p>NOTE: On some platforms the data will not be available once the application
- * has exited or the display has been disposed.</p>
+ * http://www.eclipse.org/legal/cpl-v10.html
*/
-public void dispose () {
- if (shellHandle != 0) OS.XtDestroyWidget (shellHandle);
- shellHandle = 0;
- display = null;
-}
-
-/**
- * Retrieve the data of the specified type currently available on the system clipboard. Refer to the
- * specific subclass of <code>Tramsfer</code> to determine the type of object returned.
- *
- * <p>The following snippet shows text and RTF text being retrieved from the clipboard:</p>
- *
- * <code><pre>
- * Clipboard clipboard = new Clipboard(display);
- * TextTransfer textTransfer = TextTransfer.getInstance();
- * String textData = (String)clipboard.getContents(textTransfer);
- * if (textData != null) System.out.println("Text is "+textData);
- * RTFTransfer rtfTransfer = RTFTransfer.getInstance();
- * String rtfData = (String)clipboard.getContents(rtfTransfer);
- * if (rtfData != null) System.out.println("RTF Text is "+rtfData);
- * clipboard.dispose();
- * </code></pre>
- *
- * @see Transfer
- *
- * @param transfer the transfer agent for the type of data being requested
- *
- * @return the data obtained from the clipboard or null if no data of this type is available
+
+import org.eclipse.swt.*;
+import org.eclipse.swt.internal.*;
+import org.eclipse.swt.internal.motif.*;
+import org.eclipse.swt.widgets.*;
+
+/**
+ * The <code>Clipboard</code> provides a mechanism for transferring data from one
+ * application to another or within an application.
+ *
+ * <p>IMPORTANT: This class is <em>not</em> intended to be subclassed.</p>
*/
-public Object getContents(Transfer transfer) {
- if (display == null) SWT.error(SWT.ERROR_WIDGET_DISPOSED);
- if (display.isDisposed()) SWT.error(SWT.ERROR_DEVICE_DISPOSED);
- if (transfer == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
- 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?
- byte[] type = null;
- int[] length = new int[1];
- String[] supportedTypes = transfer.getTypeNames();
- for (int i = 0; i < supportedTypes.length; i++) {
- byte[] bName = Converter.wcsToMbcs(null, supportedTypes[i], true);
- if (OS.XmClipboardInquireLength(xDisplay, xWindow, bName, length) == 1 /*OS.XmClipboardSuccess*/ ) {
- type = bName;
- break;
- }
- }
-
- // Retrieve data from Clipboard
- byte[] data = null;
- if (type != null) {
- data = new byte[length[0]];
- status = OS.XmClipboardRetrieve(xDisplay, xWindow, type, 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();
- /* Use the character encoding for the default locale */
- transferData.type = OS.XmInternAtom (xDisplay, type, true);
- 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;
-}
-/**
- * Place data of the specified type on the system clipboard. More than one type of
- * data can be placed on the system clipboard at the same time. Setting the data
- * clears any previous data of the same type from the system clipboard and also
- * clears data of any other type currently on the system clipboard.
- *
- * <p>NOTE: On some platforms, the data is immediately copied to the system
- * clipboard but on other platforms it is provided upon request. As a result, if the
- * application modifes the data object it has set on the clipboard, that modification
- * may or may not be available when the data is subsequently requested.</p>
- *
- * <p>The following snippet shows text and RTF text being set on the clipboard:</p>
- *
- * <code><pre>
- * Clipboard clipboard = new Clipboard(display);
- * String textData = "Hello World";
- * String rtfData = "{\\rtf1\\b\\i Hello World}";
- * TextTransfer textTransfer = TextTransfer.getInstance();
- * RTFTransfer rtfTransfer = RTFTransfer.getInstance();
- * clipboard.setContents(new Object[]{textData, rtfData}, new Transfer[]{textTransfer, rtfTransfer});
- * clipboard.dispose();
- * </code></pre>
- *
- * @param data the data to be set in the clipboard
- * @param dataTypes the transfer agents that will convert the data to its platform
- * specific format; each entry in the data array must have a corresponding dataType
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if data is null or datatypes is null
- * or the length of data is not the same as the length of dataTypes</li>
- * </ul>
- * @exception SWTError <ul>
- * <li>ERROR_CANNOT_SET_CLIPBOARD - if the clipboard is locked or
- * otherwise unavailable</li>
- * </ul>
+public class Clipboard {
+
+ private Display display;
+ private final int MAX_RETRIES = 10;
+ private int shellHandle;
+
+
+/**
+ * Constructs a new instance of this class. Creating an instance of a Clipboard
+ * may cause system resources to be allocated depending on the platform. It is therefore
+ * mandatory that the Clipboard instance be disposed when no longer required.
+ *
+ * @param display the display on which to allocate the clipboard
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
+ * <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
+ * </ul>
+ *
+ * @see Clipboard#dispose
+ * @see Clipboard#checkSubclass
*/
-public void setContents(Object[] data, Transfer[] dataTypes){
- if (display == null) SWT.error(SWT.ERROR_WIDGET_DISPOSED);
- if (display.isDisposed()) SWT.error(SWT.ERROR_DEVICE_DISPOSED);
- if (data == null || dataTypes == null || data.length != dataTypes.length) {
- DND.error(SWT.ERROR_INVALID_ARGUMENT);
- }
-
- 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 < dataTypes.length; i++) {
- int[] ids = dataTypes[i].getTypeIds();
- String[] names = dataTypes[i].getTypeNames();
- for (int j = 0; j < names.length; j++) {
- TransferData transferData = new TransferData();
- /* Use the character encoding for the default locale */
- transferData.type = ids[j];
- dataTypes[i].javaToNative(data[i], transferData);
- status = OS.XmClipboardFail;
- if (transferData.result == 1) {
- if (transferData.format == 8){
- byte[] buffer = new byte[transferData.length];
- OS.memmove(buffer, transferData.pValue, transferData.length);
- byte[] bName = Converter.wcsToMbcs(null, names[j], true);
- 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);
-
-}
-/**
- * Returns a platform specific list of the data types currently available on the
- * system clipboard.
- *
- * <p>Note: <code>getAvailableTypeNames</code> is a utility for writing a Transfer
- * sub-class. It should NOT be used within an application because it provides
- * platform specific information.</p>
- *
- * @returns a platform specific list of the data types currently available on the
- * system clipboard
- */
-public String[] getAvailableTypeNames() {
- if (display == null) SWT.error(SWT.ERROR_WIDGET_DISPOSED);
- if (display.isDisposed()) SWT.error(SWT.ERROR_DEVICE_DISPOSED);
- 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]);
- char [] unicode = Converter.mbcsToWcs (null, buffer2);
- types[i] = new String (unicode);
- }
- return types;
-}
-}
+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);
+}
+
+/**
+ * Checks that this class can be subclassed.
+ * <p>
+ * The SWT class library is intended to be subclassed
+ * only at specific, controlled points. This method enforces this
+ * rule unless it is overridden.
+ * </p><p>
+ * <em>IMPORTANT:</em> By providing an implementation of this
+ * method that allows a subclass of a class which does not
+ * normally allow subclassing to be created, the implementer
+ * agrees to be fully responsible for the fact that any such
+ * subclass will likely fail between SWT releases and will be
+ * strongly platform specific. No support is provided for
+ * user-written classes which are implemented in this fashion.
+ * </p><p>
+ * The ability to subclass outside of the allowed SWT classes
+ * is intended purely to enable those not on the SWT development
+ * team to implement patches in order to get around specific
+ * limitations in advance of when those limitations can be
+ * addressed by the team. Subclassing should not be attempted
+ * without an intimate and detailed understanding of the hierarchy.
+ * </p>
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
+ * </ul>
+ */
+protected void checkSubclass () {
+ String name = getClass().getName ();
+ String validName = Clipboard.class.getName();
+ if (!validName.equals(name)) {
+ DND.error (SWT.ERROR_INVALID_SUBCLASS);
+ }
+}
+
+/**
+ * Disposes of the operating system resources associated with the clipboard.
+ * The data will still be available on the system clipboard after the dispose
+ * method is called.
+ *
+ * <p>NOTE: On some platforms the data will not be available once the application
+ * has exited or the display has been disposed.</p>
+ */
+public void dispose () {
+ if (shellHandle != 0) OS.XtDestroyWidget (shellHandle);
+ shellHandle = 0;
+ display = null;
+}
+
+/**
+ * Retrieve the data of the specified type currently available on the system clipboard. Refer to the
+ * specific subclass of <code>Tramsfer</code> to determine the type of object returned.
+ *
+ * <p>The following snippet shows text and RTF text being retrieved from the clipboard:</p>
+ *
+ * <code><pre>
+ * Clipboard clipboard = new Clipboard(display);
+ * TextTransfer textTransfer = TextTransfer.getInstance();
+ * String textData = (String)clipboard.getContents(textTransfer);
+ * if (textData != null) System.out.println("Text is "+textData);
+ * RTFTransfer rtfTransfer = RTFTransfer.getInstance();
+ * String rtfData = (String)clipboard.getContents(rtfTransfer);
+ * if (rtfData != null) System.out.println("RTF Text is "+rtfData);
+ * clipboard.dispose();
+ * </code></pre>
+ *
+ * @see Transfer
+ *
+ * @param transfer the transfer agent for the type of data being requested
+ *
+ * @return the data obtained from the clipboard or null if no data of this type is available
+ */
+public Object getContents(Transfer transfer) {
+ if (display == null) SWT.error(SWT.ERROR_WIDGET_DISPOSED);
+ if (display.isDisposed()) SWT.error(SWT.ERROR_DEVICE_DISPOSED);
+ if (transfer == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ 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?
+ byte[] type = null;
+ int[] length = new int[1];
+ String[] supportedTypes = transfer.getTypeNames();
+ for (int i = 0; i < supportedTypes.length; i++) {
+ byte[] bName = Converter.wcsToMbcs(null, supportedTypes[i], true);
+ if (OS.XmClipboardInquireLength(xDisplay, xWindow, bName, length) == 1 /*OS.XmClipboardSuccess*/ ) {
+ type = bName;
+ break;
+ }
+ }
+
+ // Retrieve data from Clipboard
+ byte[] data = null;
+ if (type != null) {
+ data = new byte[length[0]];
+ status = OS.XmClipboardRetrieve(xDisplay, xWindow, type, 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();
+ /* Use the character encoding for the default locale */
+ transferData.type = OS.XmInternAtom (xDisplay, type, true);
+ 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;
+}
+/**
+ * Place data of the specified type on the system clipboard. More than one type of
+ * data can be placed on the system clipboard at the same time. Setting the data
+ * clears any previous data of the same type from the system clipboard and also
+ * clears data of any other type currently on the system clipboard.
+ *
+ * <p>NOTE: On some platforms, the data is immediately copied to the system
+ * clipboard but on other platforms it is provided upon request. As a result, if the
+ * application modifes the data object it has set on the clipboard, that modification
+ * may or may not be available when the data is subsequently requested.</p>
+ *
+ * <p>The following snippet shows text and RTF text being set on the clipboard:</p>
+ *
+ * <code><pre>
+ * Clipboard clipboard = new Clipboard(display);
+ * String textData = "Hello World";
+ * String rtfData = "{\\rtf1\\b\\i Hello World}";
+ * TextTransfer textTransfer = TextTransfer.getInstance();
+ * RTFTransfer rtfTransfer = RTFTransfer.getInstance();
+ * clipboard.setContents(new Object[]{textData, rtfData}, new Transfer[]{textTransfer, rtfTransfer});
+ * clipboard.dispose();
+ * </code></pre>
+ *
+ * @param data the data to be set in the clipboard
+ * @param dataTypes the transfer agents that will convert the data to its platform
+ * specific format; each entry in the data array must have a corresponding dataType
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if data is null or datatypes is null
+ * or the length of data is not the same as the length of dataTypes</li>
+ * </ul>
+ * @exception SWTError <ul>
+ * <li>ERROR_CANNOT_SET_CLIPBOARD - if the clipboard is locked or
+ * otherwise unavailable</li>
+ * </ul>
+ */
+public void setContents(Object[] data, Transfer[] dataTypes){
+ if (display == null) SWT.error(SWT.ERROR_WIDGET_DISPOSED);
+ if (display.isDisposed()) SWT.error(SWT.ERROR_DEVICE_DISPOSED);
+ if (data == null || dataTypes == null || data.length != dataTypes.length) {
+ DND.error(SWT.ERROR_INVALID_ARGUMENT);
+ }
+
+ 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 < dataTypes.length; i++) {
+ int[] ids = dataTypes[i].getTypeIds();
+ String[] names = dataTypes[i].getTypeNames();
+ for (int j = 0; j < names.length; j++) {
+ TransferData transferData = new TransferData();
+ /* Use the character encoding for the default locale */
+ transferData.type = ids[j];
+ dataTypes[i].javaToNative(data[i], transferData);
+ status = OS.XmClipboardFail;
+ if (transferData.result == 1) {
+ if (transferData.format == 8){
+ byte[] buffer = new byte[transferData.length];
+ OS.memmove(buffer, transferData.pValue, transferData.length);
+ byte[] bName = Converter.wcsToMbcs(null, names[j], true);
+ 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);
+
+}
+/**
+ * Returns a platform specific list of the data types currently available on the
+ * system clipboard.
+ *
+ * <p>Note: <code>getAvailableTypeNames</code> is a utility for writing a Transfer
+ * sub-class. It should NOT be used within an application because it provides
+ * platform specific information.</p>
+ *
+ * @returns a platform specific list of the data types currently available on the
+ * system clipboard
+ */
+public String[] getAvailableTypeNames() {
+ if (display == null) SWT.error(SWT.ERROR_WIDGET_DISPOSED);
+ if (display.isDisposed()) SWT.error(SWT.ERROR_DEVICE_DISPOSED);
+ 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]);
+ char [] unicode = Converter.mbcsToWcs (null, buffer2);
+ types[i] = new String (unicode);
+ }
+ return types;
+}
+}
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
index 47d2ad9ba8..60aa38bef4 100755
--- 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
@@ -1,531 +1,531 @@
-package org.eclipse.swt.dnd;
-
-/*
+package org.eclipse.swt.dnd;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-import org.eclipse.swt.*;
-import org.eclipse.swt.widgets.*;
-import org.eclipse.swt.internal.*;
-import org.eclipse.swt.internal.motif.*;
-
-/**
- *
- * <code>DragSource</code> defines the source object for a drag and drop transfer.
- *
- * <p>IMPORTANT: This class is <em>not</em> intended to be subclassed.</p>
- *
- * <p>A drag source is the object which originates a drag and drop operation. For the specified widget,
- * it defines the type of data that is available for dragging and the set of operations that can
- * be performed on that data. The operations can be any bit-wise combination of DND.MOVE, DND.COPY or
- * DND.LINK. The type of data that can be transferred is specified by subclasses of Transfer such as
- * TextTransfer or FileTransfer. The type of data transferred can be a predefined system type or it
- * can be a type defined by the application. For instructions on how to define your own transfer type,
- * refer to <code>ByteArrayTransfer</code>.</p>
- *
- * <p>You may have several DragSources in an application but you can only have one DragSource
- * per Control. Data dragged from this DragSource can be dropped on a site within this application
- * or it can be dropped on another application such as an external Text editor.</p>
- *
- * <p>The application supplies the content of the data being transferred by implementing the
- * <code>DragSourceListener</code> and associating it with the DragSource via DragSource#addDragListener.</p>
- *
- * <p>When a successful move operation occurs, the application is required to take the appropriate
- * action to remove the data from its display and remove any associated operating system resources or
- * internal references. Typically in a move operation, the drop target makes a copy of the data
- * and the drag source deletes the original. However, sometimes copying the data can take a long
- * time (such as copying a large file). Therefore, on some platforms, the drop target may actually
- * move the data in the operating system rather than make a copy. This is usually only done in
- * file transfers. In this case, the drag source is informed in the DragEnd event that a
- * DROP_TARGET_MOVE was performed. It is the responsibility of the drag source at this point to clean
- * up its displayed information. No action needs to be taken on the operating system resources.</p>
- *
- * <p> The following example shows a Label widget that allows text to be dragged from it.</p>
- *
- * <code><pre>
- * // Enable a label as a Drag Source
- * Label label = new Label(shell, SWT.NONE);
- * // This example will allow text to be dragged
- * Transfer[] types = new Transfer[] {TextTransfer.getInstance()};
- * // This example will allow the text to be copied or moved to the drop target
- * int operations = DND.DROP_MOVE | DND.DROP_COPY;
- *
- * DragSource source = new DragSource (label, operations);
- * source.setTransfer(types);
- * source.addDragListener (new DragSourceListener() {
- * public void dragStart(DragSourceEvent e) {
- * // Only start the drag if there is actually text in the
- * // label - this text will be what is dropped on the target.
- * if (label.getText().length() == 0) {
- * event.doit = false;
- * }
- * };
- * public void dragSetData (DragSourceEvent event) {
- * // A drop has been performed, so provide the data of the
- * // requested type.
- * // (Checking the type of the requested data is only
- * // necessary if the drag source supports more than
- * // one data type but is shown here as an example).
- * if (TextTransfer.getInstance().isSupportedType(event.dataType)){
- * event.data = label.getText();
- * }
- * }
- * public void dragFinished(DragSourceEvent event) {
- * // A Move operation has been performed so remove the data
- * // from the source
- * if (event.detail == DND.DROP_MOVE)
- * label.setText("");
- * }
- * });
- * </pre></code>
- *
- *
- * <dl>
- * <dt><b>Styles</b></dt> <dd>DND.DROP_NONE, DND.DROP_COPY, DND.DROP_MOVE, DND.DROP_LINK</dd>
- * <dt><b>Events</b></dt> <dd>DND.DragStart, DND.DragSetData, DND.DragEnd</dd>
- * </dl>
- */
-public class DragSource extends Widget {
-
- static private Callback ConvertProc;
- static private Callback DragDropFinish;
- static private Callback DropFinish;
- static {
- ConvertProc = new Callback(DragSource.class, "ConvertProcCallback", 10);
- DragDropFinish = new Callback(DragSource.class, "DragDropFinishCallback", 3);
- DropFinish = new Callback(DragSource.class, "DropFinishCallback", 3);
- }
- static final String DRAGSOURCEID = "DragSource";
-
- // info for registering as a drag source
- private Control control;
- private Listener controlListener;
- private Transfer[] transferAgents = new Transfer[0];
-
- private boolean moveRequested;
-
- int dragContext;
-
-/**
- * Creates a new <code>DragSource</code> to handle dragging from the specified <code>Control</code>.
- * Creating an instance of a DragSource may cause system resources to be allocated depending on the platform.
- * It is therefore mandatory that the DragSource instance be disposed when no longer required.
- *
- * @param control the <code>Control</code> that the user clicks on to initiate the drag
- * @param style the bitwise OR'ing of allowed operations; this may be a combination of any of
- * DND.DROP_NONE, DND.DROP_COPY, DND.DROP_MOVE, DND.DROP_LINK
- *
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
- * <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
- * @exception SWTError <ul>
- * <li>ERROR_CANNOT_INIT_DRAG - unable to initiate drag source</li>
- * </ul>
- *
- * @see DragSource#dispose
- * @see DragSource#checkSubclass
- * @see DND#DROP_NONE
- * @see DND#DROP_COPY
- * @see DND#DROP_MOVE
- * @see DND#DROP_LINK
+ * http://www.eclipse.org/legal/cpl-v10.html
*/
-public DragSource(Control control, int style) {
- super (control, checkStyle(style));
- if (ConvertProc == null || DragDropFinish == null || DropFinish == null)
- DND.error(DND.ERROR_CANNOT_INIT_DRAG);
- if (control.getData(DRAGSOURCEID) != null)
- DND.error(DND.ERROR_CANNOT_INIT_DRAG);
- control.setData(DRAGSOURCEID, this);
- 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();
- }
- });
-}
-static DragSource FindDragSource(int handle) {
- Display display = Display.findDisplay(Thread.currentThread());
- if (display == null || display.isDisposed()) return null;
- return (DragSource)display.getData(Integer.toString(handle));
-}
-private static 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) {
- DragSource source = FindDragSource(widget);
- if (source == null) return 0;
- return source.convertProcCallback(widget, pSelection, pTarget, pType_return, ppValue_return, pLength_return, pFormat_return, max_length, client_data, request_id);
-}
-private static int DragDropFinishCallback(int widget, int client_data, int call_data) {
- DragSource source = FindDragSource(widget);
- if (source == null) return 0;
- return source.dragDropFinishCallback(widget, client_data, call_data);
-}
-private static int DropFinishCallback(int widget, int client_data, int call_data) {
- DragSource source = FindDragSource(widget);
- if (source == null) return 0;
- return source.dropFinishCallback(widget, client_data, call_data);
-}
-/**
- * Adds the listener to the collection of listeners who will
- * be notified when a drag and drop operation is in progress, by sending
- * it one of the messages defined in the <code>DragSourceListener</code>
- * interface.
- *
- * <p><ul>
- * <li><code>dragStart</code> is called when the user has begun the actions required to drag the widget.
- * This event gives the application the chance to decide if a drag should be started.
- * <li><code>dragSetData</code> is called when the data is required from the drag source.
- * <li><code>dragFinished</code> is called when the drop has successfully completed (mouse up
- * over a valid target) or has been terminated (such as hitting the ESC key). Perform cleanup
- * such as removing data from the source side on a successful move operation.
- * </ul></p>
- *
- * @param listener the listener which should be notified
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see DragSourceListener
- * @see #removeDragListener
- * @see DragSourceEvent
+
+import org.eclipse.swt.*;
+import org.eclipse.swt.widgets.*;
+import org.eclipse.swt.internal.*;
+import org.eclipse.swt.internal.motif.*;
+
+/**
+ *
+ * <code>DragSource</code> defines the source object for a drag and drop transfer.
+ *
+ * <p>IMPORTANT: This class is <em>not</em> intended to be subclassed.</p>
+ *
+ * <p>A drag source is the object which originates a drag and drop operation. For the specified widget,
+ * it defines the type of data that is available for dragging and the set of operations that can
+ * be performed on that data. The operations can be any bit-wise combination of DND.MOVE, DND.COPY or
+ * DND.LINK. The type of data that can be transferred is specified by subclasses of Transfer such as
+ * TextTransfer or FileTransfer. The type of data transferred can be a predefined system type or it
+ * can be a type defined by the application. For instructions on how to define your own transfer type,
+ * refer to <code>ByteArrayTransfer</code>.</p>
+ *
+ * <p>You may have several DragSources in an application but you can only have one DragSource
+ * per Control. Data dragged from this DragSource can be dropped on a site within this application
+ * or it can be dropped on another application such as an external Text editor.</p>
+ *
+ * <p>The application supplies the content of the data being transferred by implementing the
+ * <code>DragSourceListener</code> and associating it with the DragSource via DragSource#addDragListener.</p>
+ *
+ * <p>When a successful move operation occurs, the application is required to take the appropriate
+ * action to remove the data from its display and remove any associated operating system resources or
+ * internal references. Typically in a move operation, the drop target makes a copy of the data
+ * and the drag source deletes the original. However, sometimes copying the data can take a long
+ * time (such as copying a large file). Therefore, on some platforms, the drop target may actually
+ * move the data in the operating system rather than make a copy. This is usually only done in
+ * file transfers. In this case, the drag source is informed in the DragEnd event that a
+ * DROP_TARGET_MOVE was performed. It is the responsibility of the drag source at this point to clean
+ * up its displayed information. No action needs to be taken on the operating system resources.</p>
+ *
+ * <p> The following example shows a Label widget that allows text to be dragged from it.</p>
+ *
+ * <code><pre>
+ * // Enable a label as a Drag Source
+ * Label label = new Label(shell, SWT.NONE);
+ * // This example will allow text to be dragged
+ * Transfer[] types = new Transfer[] {TextTransfer.getInstance()};
+ * // This example will allow the text to be copied or moved to the drop target
+ * int operations = DND.DROP_MOVE | DND.DROP_COPY;
+ *
+ * DragSource source = new DragSource (label, operations);
+ * source.setTransfer(types);
+ * source.addDragListener (new DragSourceListener() {
+ * public void dragStart(DragSourceEvent e) {
+ * // Only start the drag if there is actually text in the
+ * // label - this text will be what is dropped on the target.
+ * if (label.getText().length() == 0) {
+ * event.doit = false;
+ * }
+ * };
+ * public void dragSetData (DragSourceEvent event) {
+ * // A drop has been performed, so provide the data of the
+ * // requested type.
+ * // (Checking the type of the requested data is only
+ * // necessary if the drag source supports more than
+ * // one data type but is shown here as an example).
+ * if (TextTransfer.getInstance().isSupportedType(event.dataType)){
+ * event.data = label.getText();
+ * }
+ * }
+ * public void dragFinished(DragSourceEvent event) {
+ * // A Move operation has been performed so remove the data
+ * // from the source
+ * if (event.detail == DND.DROP_MOVE)
+ * label.setText("");
+ * }
+ * });
+ * </pre></code>
+ *
+ *
+ * <dl>
+ * <dt><b>Styles</b></dt> <dd>DND.DROP_NONE, DND.DROP_COPY, DND.DROP_MOVE, DND.DROP_LINK</dd>
+ * <dt><b>Events</b></dt> <dd>DND.DragStart, DND.DragSetData, DND.DragEnd</dd>
+ * </dl>
*/
-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) {
- if (pSelection == 0 ) return 0;
-
- // is this a drop?
- int[] selection = new int[1];
- OS.memmove(selection, pSelection, 4);
- int xDisplay = getDisplay().xDisplay;
- byte[] bName = Converter.wcsToMbcs (null, "_MOTIF_DROP", true);
- int motifDropAtom = OS.XmInternAtom (xDisplay, bName, true);
- 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
- bName = Converter.wcsToMbcs (null, "DELETE", true); // DELETE corresponds to a Move request
- int deleteAtom = OS.XmInternAtom (xDisplay, bName, true);
- if (target[0] == deleteAtom) {
- moveRequested = true;
- bName = Converter.wcsToMbcs (null, "NULL", true);
- int nullAtom = OS.XmInternAtom (xDisplay, bName, true);
- OS.memmove(pType_return,new int[]{nullAtom}, 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 = false;
- 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 dc = OS.XmGetDragContext(control.handle, time);
- if (dc != 0){
- OS.XmDragCancel(dc);
- }
- 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);
-
- 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);
- }
- OS.XtFree(pExportTargets);
- if (dragContext == 0) return;
-
- // register a call back to clean up when drop is done (optional)
- OS.XtAddCallback(dragContext, OS.XmNdragDropFinishCallback, DragDropFinish.getAddress(), 0);
-
- // register a call back to tell user what happened (optional)
- OS.XtAddCallback(dragContext, OS.XmNdropFinishCallback, DropFinish.getAddress(), 0);
-
- display.setData(Integer.toString(dragContext), this);
- 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;
- getDisplay().setData(Integer.toString(dragContext), 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;
- if (moveRequested) {
- event.detail = DND.DROP_MOVE;
- } else {
- if (data.operation == OS.XmDROP_MOVE) {
- event.detail = DND.DROP_NONE;
- } else {
- event.detail = osOpToOp(data.operation);
- }
-
- }
- event.doit = (data.completionStatus != 0);
-
- try {
- notifyListeners(DND.DragEnd,event);
- } catch (Throwable err) {
- }
-
- moveRequested = false;
-
- return 0;
-}
-/**
- * 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 class DragSource extends Widget {
+
+ static private Callback ConvertProc;
+ static private Callback DragDropFinish;
+ static private Callback DropFinish;
+ static {
+ ConvertProc = new Callback(DragSource.class, "ConvertProcCallback", 10);
+ DragDropFinish = new Callback(DragSource.class, "DragDropFinishCallback", 3);
+ DropFinish = new Callback(DragSource.class, "DropFinishCallback", 3);
+ }
+ static final String DRAGSOURCEID = "DragSource";
+
+ // info for registering as a drag source
+ private Control control;
+ private Listener controlListener;
+ private Transfer[] transferAgents = new Transfer[0];
+
+ private boolean moveRequested;
+
+ int dragContext;
+
+/**
+ * Creates a new <code>DragSource</code> to handle dragging from the specified <code>Control</code>.
+ * Creating an instance of a DragSource may cause system resources to be allocated depending on the platform.
+ * It is therefore mandatory that the DragSource instance be disposed when no longer required.
+ *
+ * @param control the <code>Control</code> that the user clicks on to initiate the drag
+ * @param style the bitwise OR'ing of allowed operations; this may be a combination of any of
+ * DND.DROP_NONE, DND.DROP_COPY, DND.DROP_MOVE, DND.DROP_LINK
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
+ * <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
+ * @exception SWTError <ul>
+ * <li>ERROR_CANNOT_INIT_DRAG - unable to initiate drag source</li>
+ * </ul>
+ *
+ * @see DragSource#dispose
+ * @see DragSource#checkSubclass
+ * @see DND#DROP_NONE
+ * @see DND#DROP_COPY
+ * @see DND#DROP_MOVE
+ * @see DND#DROP_LINK
*/
-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 by this DragSource.
- *
- * @return the list of data types that can be transferred by this DragSource
+public DragSource(Control control, int style) {
+ super (control, checkStyle(style));
+ if (ConvertProc == null || DragDropFinish == null || DropFinish == null)
+ DND.error(DND.ERROR_CANNOT_INIT_DRAG);
+ if (control.getData(DRAGSOURCEID) != null)
+ DND.error(DND.ERROR_CANNOT_INIT_DRAG);
+ control.setData(DRAGSOURCEID, this);
+ 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();
+ }
+ });
+}
+static DragSource FindDragSource(int handle) {
+ Display display = Display.findDisplay(Thread.currentThread());
+ if (display == null || display.isDisposed()) return null;
+ return (DragSource)display.getData(Integer.toString(handle));
+}
+private static 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) {
+ DragSource source = FindDragSource(widget);
+ if (source == null) return 0;
+ return source.convertProcCallback(widget, pSelection, pTarget, pType_return, ppValue_return, pLength_return, pFormat_return, max_length, client_data, request_id);
+}
+private static int DragDropFinishCallback(int widget, int client_data, int call_data) {
+ DragSource source = FindDragSource(widget);
+ if (source == null) return 0;
+ return source.dragDropFinishCallback(widget, client_data, call_data);
+}
+private static int DropFinishCallback(int widget, int client_data, int call_data) {
+ DragSource source = FindDragSource(widget);
+ if (source == null) return 0;
+ return source.dropFinishCallback(widget, client_data, call_data);
+}
+/**
+ * Adds the listener to the collection of listeners who will
+ * be notified when a drag and drop operation is in progress, by sending
+ * it one of the messages defined in the <code>DragSourceListener</code>
+ * interface.
+ *
+ * <p><ul>
+ * <li><code>dragStart</code> is called when the user has begun the actions required to drag the widget.
+ * This event gives the application the chance to decide if a drag should be started.
+ * <li><code>dragSetData</code> is called when the data is required from the drag source.
+ * <li><code>dragFinished</code> is called when the drop has successfully completed (mouse up
+ * over a valid target) or has been terminated (such as hitting the ESC key). Perform cleanup
+ * such as removing data from the source side on a successful move operation.
+ * </ul></p>
+ *
+ * @param listener the listener which should be notified
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see DragSourceListener
+ * @see #removeDragListener
+ * @see DragSourceEvent
*/
-public Transfer[] getTransfer(){
- return transferAgents;
-}
-private void onDispose() {
- if (controlListener != null) {
- control.removeListener(SWT.Dispose, controlListener);
- control.removeListener(SWT.DragDetect, controlListener);
- }
- controlListener = null;
- control.setData(DRAGSOURCEID, 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;
-}
-/**
- * Removes the listener from the collection of listeners who will
- * be notified when a drag and drop operation is in progress.
- *
- * @param listener the listener which should be notified
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see DragSourceListener
- * @see #addDragListener
+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) {
+ if (pSelection == 0 ) return 0;
+
+ // is this a drop?
+ int[] selection = new int[1];
+ OS.memmove(selection, pSelection, 4);
+ int xDisplay = getDisplay().xDisplay;
+ byte[] bName = Converter.wcsToMbcs (null, "_MOTIF_DROP", true);
+ int motifDropAtom = OS.XmInternAtom (xDisplay, bName, true);
+ 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
+ bName = Converter.wcsToMbcs (null, "DELETE", true); // DELETE corresponds to a Move request
+ int deleteAtom = OS.XmInternAtom (xDisplay, bName, true);
+ if (target[0] == deleteAtom) {
+ moveRequested = true;
+ bName = Converter.wcsToMbcs (null, "NULL", true);
+ int nullAtom = OS.XmInternAtom (xDisplay, bName, true);
+ OS.memmove(pType_return,new int[]{nullAtom}, 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 = false;
+ 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 dc = OS.XmGetDragContext(control.handle, time);
+ if (dc != 0){
+ OS.XmDragCancel(dc);
+ }
+ 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);
+
+ 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);
+ }
+ OS.XtFree(pExportTargets);
+ if (dragContext == 0) return;
+
+ // register a call back to clean up when drop is done (optional)
+ OS.XtAddCallback(dragContext, OS.XmNdragDropFinishCallback, DragDropFinish.getAddress(), 0);
+
+ // register a call back to tell user what happened (optional)
+ OS.XtAddCallback(dragContext, OS.XmNdropFinishCallback, DropFinish.getAddress(), 0);
+
+ display.setData(Integer.toString(dragContext), this);
+ 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;
+ getDisplay().setData(Integer.toString(dragContext), 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;
+ if (moveRequested) {
+ event.detail = DND.DROP_MOVE;
+ } else {
+ if (data.operation == OS.XmDROP_MOVE) {
+ event.detail = DND.DROP_NONE;
+ } else {
+ event.detail = osOpToOp(data.operation);
+ }
+
+ }
+ event.doit = (data.completionStatus != 0);
+
+ try {
+ notifyListeners(DND.DragEnd,event);
+ } catch (Throwable err) {
+ }
+
+ moveRequested = false;
+
+ return 0;
+}
+/**
+ * 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 void removeDragListener(DragSourceListener listener) {
- if (listener == null) DND.error (SWT.ERROR_NULL_ARGUMENT);
- removeListener (DND.DragStart, listener);
- removeListener (DND.DragSetData, listener);
- removeListener (DND.DragEnd, listener);
-}
-
-/**
- * Specifies the list of data types that can be transferred by this DragSource.
- * The application must be able to provide data to match each of these types when
- * a successful drop has occurred.
- *
- * @param transferAgents a list of Transfer objects which define the types of data that can be
- * dragged from this source
+public 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 by this DragSource.
+ *
+ * @return the list of data types that can be transferred by this DragSource
*/
-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);
- }
-}
-}
+public Transfer[] getTransfer(){
+ return transferAgents;
+}
+private void onDispose() {
+ if (controlListener != null) {
+ control.removeListener(SWT.Dispose, controlListener);
+ control.removeListener(SWT.DragDetect, controlListener);
+ }
+ controlListener = null;
+ control.setData(DRAGSOURCEID, 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;
+}
+/**
+ * Removes the listener from the collection of listeners who will
+ * be notified when a drag and drop operation is in progress.
+ *
+ * @param listener the listener which should be notified
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see DragSourceListener
+ * @see #addDragListener
+ */
+public void removeDragListener(DragSourceListener listener) {
+ if (listener == null) DND.error (SWT.ERROR_NULL_ARGUMENT);
+ removeListener (DND.DragStart, listener);
+ removeListener (DND.DragSetData, listener);
+ removeListener (DND.DragEnd, listener);
+}
+
+/**
+ * Specifies the list of data types that can be transferred by this DragSource.
+ * The application must be able to provide data to match each of these types when
+ * a successful drop has occurred.
+ *
+ * @param transferAgents a list of Transfer objects which define the types of data that can be
+ * dragged from this source
+ */
+public void setTransfer(Transfer[] transferAgents){
+ 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
index e8fed290df..93fb50f5cb 100755
--- 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
@@ -1,815 +1,815 @@
-package org.eclipse.swt.dnd;
-
-/*
+package org.eclipse.swt.dnd;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.internal.Callback;
-import org.eclipse.swt.internal.motif.*;
-import org.eclipse.swt.widgets.*;
-
-/**
- *
- * Class <code>DropTarget</code> defines the target object for a drag and drop transfer.
- *
- * IMPORTANT: This class is <em>not</em> intended to be subclassed.
- *
- * <p>This class identifies the <code>Control</code> over which the user must position the cursor
- * in order to drop the data being transferred. It also specifies what data types can be dropped on
- * this control and what operations can be performed. You may have several DropTragets in an
- * application but there can only be a one to one mapping between a <code>Control</code> and a <code>DropTarget</code>.
- * The DropTarget can receive data from within the same application or from other applications
- * (such as text dragged from a text editor like Word).</p>
- *
- * <code><pre>
- * int operations = DND.DROP_MOVE | DND.DROP_COPY | DND.DROP_LINK;
- * Transfer[] types = new Transfer[] {TextTransfer.getInstance()};
- * DropTarget target = new DropTarget(label, operations);
- * target.setTransfer(types);
- * </code></pre>
- *
- * <p>The application is notified of data being dragged over this control and of when a drop occurs by
- * implementing the interface <code>DropTargetListener</code> which uses the class
- * <code>DropTargetEvent</code>. The application can modify the type of drag being performed
- * on this Control at any stage of the drag by modifying the <code>event.detail</code> field or the
- * <code>event.currentDataType</code> field. When the data is dropped, it is the responsibility of
- * the application to copy this data for its own purposes.
- *
- * <code><pre>
- * target.addDropListener (new DropTargetListener() {
- * public void dragEnter(DropTargetEvent event) {};
- * public void dragOver(DropTargetEvent event) {};
- * public void dragLeave(DropTargetEvent event) {};
- * public void dragOperationChanged(DropTargetEvent event) {};
- * public void dropAccept(DropTargetEvent event) {}
- * public void drop(DropTargetEvent event) {
- * // A drop has occurred, copy over the data
- * if (event.data == null) { // no data to copy, indicate failure in event.detail
- * event.detail = DND.DROP_NONE;
- * return;
- * }
- * label.setText ((String) event.data); // data copied to label text
- * }
- * });
- * </pre></code>
- *
- * <dl>
- * <dt><b>Styles</b></dt> <dd>DND.DROP_NONE, DND.DROP_COPY, DND.DROP_MOVE, DND.DROP_LINK</dd>
- * <dt><b>Events</b></dt> <dd>DND.DragEnter, DND.DragLeave, DND.DragOver, DND.DragOperationChanged,
- * DND.DropAccept, DND.Drop </dd>
- * </dl>
- */
-public class DropTarget extends Widget {
-
- static private Callback DropProc;
- static private Callback DragProc;
- static private Callback TransferProc;
- static {
- DropProc = new Callback(DropTarget.class, "DropProcCallback", 3);
- DragProc = new Callback(DropTarget.class, "DragProcCallback", 3);
- TransferProc = new Callback(DropTarget.class, "TransferProcCallback", 7);
- }
- static final String DROPTARGETID = "DropTarget";
- static int DELETE_TYPE = Transfer.registerType("DELETE\0");
-
- // 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;
-
- private static final int DRAGOVER_HYSTERESIS = 50;
- private long dragOverStart;
- private Runnable dragOverHeartbeat;
- private DNDEvent dragOverEvent;
-
- private int lastOperation;
- private int selectionTimeout;
-
- private boolean registered = false;
-
-/**
- * Creates a new <code>DropTarget</code> to allow data to be dropped on the specified
- * <code>Control</code>.
- * Creating an instance of a DropTarget may cause system resources to be allocated
- * depending on the platform. It is therefore mandatory that the DropTarget instance
- * be disposed when no longer required.
- *
- * @param control the <code>Control</code> over which the user positions the cursor to drop the data
- * @param style the bitwise OR'ing of allowed operations; this may be a combination of any of
- * DND.DROP_NONE, DND.DROP_COPY, DND.DROP_MOVE, DND.DROP_LINK
- *
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
- * <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
- * @exception SWTError <ul>
- * <li>ERROR_CANNOT_INIT_DROP - unable to initiate drop target</li>
- * </ul>
- *
- * @see DropTarget#dispose
- * @see DropTarget#checkSubclass
- * @see DND#DROP_NONE
- * @see DND#DROP_COPY
- * @see DND#DROP_MOVE
- * @see DND#DROP_LINK
+ * http://www.eclipse.org/legal/cpl-v10.html
*/
-public DropTarget(Control control, int style) {
- super (control, checkStyle(style));
- if (DropProc == null || DragProc == null || TransferProc == null)
- DND.error(DND.ERROR_CANNOT_INIT_DROP);
- if (control.getData(DROPTARGETID) != null)
- DND.error(DND.ERROR_CANNOT_INIT_DROP);
- control.setData(DROPTARGETID, this);
- this.control = control;
- controlListener = new Listener () {
- public void handleEvent (Event event) {
- switch (event.type) {
- case SWT.Dispose: {
- if (!DropTarget.this.isDisposed()){
- onDispose();
- }
- break;
- }
- case SWT.Show: {
- Display display = event.display;
- display.asyncExec(new Runnable() {
- public void run() {
- if (DropTarget.this.control == null ||
- DropTarget.this.control.isDisposed() ||
- !DropTarget.this.control.isVisible()) return;
-
- registerDropTarget();
- }
- });
- break;
- }
- case SWT.Hide: {
- Display display = event.display;
- display.asyncExec(new Runnable() {
- public void run() {
- if (DropTarget.this.control == null ||
- DropTarget.this.control.isDisposed() ||
- DropTarget.this.control.isVisible()) return;
-
- unregisterDropTarget();
- }
- });
- break;
- }
- }
- }
- };
- control.addListener (SWT.Dispose, controlListener);
- Control c = control;
- while (c != null) {
- c.addListener (SWT.Show, controlListener);
- c.addListener (SWT.Hide, controlListener);
- c = c.getParent();
- }
-
- this.addListener (SWT.Dispose, new Listener () {
- public void handleEvent (Event event) {
- if (DropTarget.this.control == null ||
- DropTarget.this.control.isDisposed()) return;
-
- unregisterDropTarget();
- 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);
- }
-
- if (control.isVisible()) registerDropTarget();
-}
-
-static DropTarget FindDropTarget(int handle) {
- Display display = Display.findDisplay(Thread.currentThread());
- if (display == null || display.isDisposed()) return null;
- Widget widget = display.findWidget(handle);
- if (widget == null) return null;
- return (DropTarget)widget.getData(DROPTARGETID);
-}
-private static int DragProcCallback(int widget, int client_data, int call_data) {
- DropTarget target = FindDropTarget(widget);
- if (target == null) return 0;
- return target.dragProcCallback(widget, client_data, call_data);
-}
-private static int DropProcCallback(int widget, int client_data, int call_data) {
- DropTarget target = FindDropTarget(widget);
- if (target == null) return 0;
- return target.dropProcCallback(widget, client_data, call_data);
-}
-private static int TransferProcCallback(int widget, int client_data, int pSelection, int pType, int pValue, int pLength, int pFormat) {
- DropTarget target = FindDropTarget(client_data);
- if (target == null) return 0;
- return target.transferProcCallback(widget, client_data, pSelection, pType, pValue, pLength, pFormat);
-}
-/**
- * Adds the listener to the collection of listeners who will
- * be notified when a drag and drop operation is in progress, by sending
- * it one of the messages defined in the <code>DropTargetListener</code>
- * interface.
- *
- * <p><ul>
- * <li><code>dragEnter</code> is called when the cursor has entered the drop target boundaries
- * <li><code>dragLeave</code> is called when the cursor has left the drop target boundaries and just before
- * the drop occurs or is cancelled.
- * <li><code>dragOperationChanged</code> is called when the operation being performed has changed
- * (usually due to the user changing the selected modifier key(s) while dragging)
- * <li><code>dragOver</code> is called when the cursor is moving over the drop target
- * <li><code>dropAccept</code> is called just before the drop is performed. The drop target is given
- * the chance to change the nature of the drop or veto the drop by setting the <code>event.detail</code> field
- * <li><code>drop</code> is called when the data is being dropped
- * </ul></p>
- *
- * @param listener the listener which should be notified
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see DropTargetListener
- * @see #removeDropListener
- * @see DropTargetEvent
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.internal.Callback;
+import org.eclipse.swt.internal.motif.*;
+import org.eclipse.swt.widgets.*;
+
+/**
+ *
+ * Class <code>DropTarget</code> defines the target object for a drag and drop transfer.
+ *
+ * IMPORTANT: This class is <em>not</em> intended to be subclassed.
+ *
+ * <p>This class identifies the <code>Control</code> over which the user must position the cursor
+ * in order to drop the data being transferred. It also specifies what data types can be dropped on
+ * this control and what operations can be performed. You may have several DropTragets in an
+ * application but there can only be a one to one mapping between a <code>Control</code> and a <code>DropTarget</code>.
+ * The DropTarget can receive data from within the same application or from other applications
+ * (such as text dragged from a text editor like Word).</p>
+ *
+ * <code><pre>
+ * int operations = DND.DROP_MOVE | DND.DROP_COPY | DND.DROP_LINK;
+ * Transfer[] types = new Transfer[] {TextTransfer.getInstance()};
+ * DropTarget target = new DropTarget(label, operations);
+ * target.setTransfer(types);
+ * </code></pre>
+ *
+ * <p>The application is notified of data being dragged over this control and of when a drop occurs by
+ * implementing the interface <code>DropTargetListener</code> which uses the class
+ * <code>DropTargetEvent</code>. The application can modify the type of drag being performed
+ * on this Control at any stage of the drag by modifying the <code>event.detail</code> field or the
+ * <code>event.currentDataType</code> field. When the data is dropped, it is the responsibility of
+ * the application to copy this data for its own purposes.
+ *
+ * <code><pre>
+ * target.addDropListener (new DropTargetListener() {
+ * public void dragEnter(DropTargetEvent event) {};
+ * public void dragOver(DropTargetEvent event) {};
+ * public void dragLeave(DropTargetEvent event) {};
+ * public void dragOperationChanged(DropTargetEvent event) {};
+ * public void dropAccept(DropTargetEvent event) {}
+ * public void drop(DropTargetEvent event) {
+ * // A drop has occurred, copy over the data
+ * if (event.data == null) { // no data to copy, indicate failure in event.detail
+ * event.detail = DND.DROP_NONE;
+ * return;
+ * }
+ * label.setText ((String) event.data); // data copied to label text
+ * }
+ * });
+ * </pre></code>
+ *
+ * <dl>
+ * <dt><b>Styles</b></dt> <dd>DND.DROP_NONE, DND.DROP_COPY, DND.DROP_MOVE, DND.DROP_LINK</dd>
+ * <dt><b>Events</b></dt> <dd>DND.DragEnter, DND.DragLeave, DND.DragOver, DND.DragOperationChanged,
+ * DND.DropAccept, DND.Drop </dd>
+ * </dl>
*/
-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 void updateDragOverHover(long delay, DNDEvent event) {
- if (delay == 0) {
- dragOverStart = 0;
- dragOverEvent = null;
- dragOverHeartbeat = null;
- return;
- }
- dragOverStart = System.currentTimeMillis() + delay;
- if (dragOverEvent == null) dragOverEvent = new DNDEvent();
- dragOverEvent.x = event.x;
- dragOverEvent.y = event.y;
- dragOverEvent.dataTypes = event.dataTypes;
- dragOverEvent.operations = event.operations;
- dragOverEvent.dataType = event.dataType;
- dragOverEvent.detail = event.detail;
-}
-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;
- }
- }
- }
- }
-
- if (dataTypes == null || dataTypes.length == 0) {
- callbackData.dropSiteStatus = OS.XmDROP_SITE_INVALID;
- callbackData.operation = opToOsOp(DND.DROP_NONE);
- OS.memmove(call_data, callbackData, XmDragProcCallback.sizeof);
- return 0;
- }
-
- if (selectedDataType == null) {
- selectedDataType = dataTypes[0];
- }
-
- 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;
- int allowedOperations = osOpToOp(callbackData.operations);
- event.operations = allowedOperations;
- event.dataType = selectedDataType;
-
- try {
- switch (callbackData.reason) {
- case OS.XmCR_DROP_SITE_ENTER_MESSAGE :
- event.detail = osOpToOp(callbackData.operation);
- if ((getStyle() & DND.DROP_DEFAULT) != 0) {
- int xDisplay = getDisplay().xDisplay;
- int xWindow = OS.XDefaultRootWindow (xDisplay);
- int [] unused = new int [1];
- int[] mask_return = new int[1];
- OS.XQueryPointer (xDisplay, xWindow, unused, unused, unused, unused, unused, unused, mask_return);
- int mask = mask_return[0];
- if ((mask & OS.ShiftMask) == 0 && (mask & OS.ControlMask) == 0) {
- event.detail = DND.DROP_DEFAULT;
- }
- }
- updateDragOverHover(DRAGOVER_HYSTERESIS, event);
- notifyListeners(DND.DragEnter, event);
- effect.show(event.feedback, event.x, event.y);
- break;
- case OS.XmCR_DROP_SITE_MOTION_MESSAGE :
- event.detail = lastOperation;
- updateDragOverHover(DRAGOVER_HYSTERESIS, event);
- notifyListeners(DND.DragOver, event);
- effect.show(event.feedback, event.x, event.y);
- break;
- case OS.XmCR_OPERATION_CHANGED :
- event.detail = osOpToOp(callbackData.operation);
- if ((getStyle() & DND.DROP_DEFAULT) != 0) {
- int xDisplay = getDisplay().xDisplay;
- int xWindow = OS.XDefaultRootWindow (xDisplay);
- int [] unused = new int [1];
- int[] mask_return = new int[1];
- OS.XQueryPointer (xDisplay, xWindow, unused, unused, unused, unused, unused, unused, mask_return);
- int mask = mask_return[0];
- if ((mask & OS.ShiftMask) == 0 && (mask & OS.ControlMask) == 0) {
- event.detail = DND.DROP_DEFAULT;
- }
- }
- updateDragOverHover(DRAGOVER_HYSTERESIS, event);
- 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;
- updateDragOverHover(0, null);
- 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;
- }
-
- if (event.detail == DND.DROP_DEFAULT) {
- event.detail = DND.DROP_MOVE;
- }
- 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 && (event.detail & allowedOperations) != 0) {
- lastOperation = event.detail;
- }
- callbackData.dropSiteStatus = OS.XmDROP_SITE_VALID;
- callbackData.operation = opToOsOp(lastOperation);
- OS.memmove(call_data, callbackData, XmDragProcCallback.sizeof);
-
- if (dragOverHeartbeat == null) {
- dragOverHeartbeat = new Runnable() {
- public void run() {
- if (control.isDisposed() || dragOverStart == 0) return;
- long time = System.currentTimeMillis();
- int delay = DRAGOVER_HYSTERESIS;
- if (time >= dragOverStart) {
- if (selectedDataType == null) {
- selectedDataType = dragOverEvent.dataTypes[0];
- }
- DNDEvent event = new DNDEvent();
- event.widget = control;
- event.time = (int)time;
- event.x = dragOverEvent.x;
- event.y = dragOverEvent.y;
- event.dataTypes = dragOverEvent.dataTypes;
- event.feedback = DND.FEEDBACK_SELECT;
- int allowedOperations = dragOverEvent.operations;
- event.operations = allowedOperations;
- event.dataType = selectedDataType;
- event.detail = lastOperation;
- notifyListeners(DND.DragOver, event);
- effect.show(event.feedback, event.x, event.y);
- 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 && ((event.detail & allowedOperations) == event.detail)) {
- lastOperation = event.detail;
- }
- } else {
- delay = (int)(dragOverStart - time);
- }
- control.getDisplay().timerExec(delay, dragOverHeartbeat);
- }
- };
- dragOverHeartbeat.run();
- }
-
- return 0;
-}
-private int dropProcCallback(int widget, int client_data, int call_data) {
- updateDragOverHover(0, null);
- 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;
- int allowedOperations = osOpToOp(droppedEventData.operations);
- event.operations = allowedOperations;
- event.dataType = selectedDataType;
- event.detail = lastOperation;
-
- 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;
- }
- }
- lastOperation = DND.DROP_NONE;
- if (selectedDataType != null && ((event.detail & allowedOperations) == 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] = control.handle; // pass control handle as data to locate drop target
- transferEntries[1] = selectedDataType.type;
-
- int pTransferEntries = OS.XtMalloc(transferEntries.length * 4);
- OS.memmove(pTransferEntries, transferEntries, transferEntries.length * 4);
-
- int xtContext = OS.XtDisplayToApplicationContext(getDisplay().xDisplay);
- selectionTimeout = OS.XtAppGetSelectionTimeout(xtContext);
- OS.XtAppSetSelectionTimeout(xtContext, 0x7fffffff);
-
- 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 class DropTarget extends Widget {
+
+ static private Callback DropProc;
+ static private Callback DragProc;
+ static private Callback TransferProc;
+ static {
+ DropProc = new Callback(DropTarget.class, "DropProcCallback", 3);
+ DragProc = new Callback(DropTarget.class, "DragProcCallback", 3);
+ TransferProc = new Callback(DropTarget.class, "TransferProcCallback", 7);
+ }
+ static final String DROPTARGETID = "DropTarget";
+ static int DELETE_TYPE = Transfer.registerType("DELETE\0");
+
+ // 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;
+
+ private static final int DRAGOVER_HYSTERESIS = 50;
+ private long dragOverStart;
+ private Runnable dragOverHeartbeat;
+ private DNDEvent dragOverEvent;
+
+ private int lastOperation;
+ private int selectionTimeout;
+
+ private boolean registered = false;
+
+/**
+ * Creates a new <code>DropTarget</code> to allow data to be dropped on the specified
+ * <code>Control</code>.
+ * Creating an instance of a DropTarget may cause system resources to be allocated
+ * depending on the platform. It is therefore mandatory that the DropTarget instance
+ * be disposed when no longer required.
+ *
+ * @param control the <code>Control</code> over which the user positions the cursor to drop the data
+ * @param style the bitwise OR'ing of allowed operations; this may be a combination of any of
+ * DND.DROP_NONE, DND.DROP_COPY, DND.DROP_MOVE, DND.DROP_LINK
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
+ * <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
+ * @exception SWTError <ul>
+ * <li>ERROR_CANNOT_INIT_DROP - unable to initiate drop target</li>
+ * </ul>
+ *
+ * @see DropTarget#dispose
+ * @see DropTarget#checkSubclass
+ * @see DND#DROP_NONE
+ * @see DND#DROP_COPY
+ * @see DND#DROP_MOVE
+ * @see DND#DROP_LINK
*/
-public Control getControl () {
- return control;
-}
-
-public Display getDisplay () {
-
- if (control == null) DND.error(SWT.ERROR_WIDGET_DISPOSED);
- return control.getDisplay ();
-}
-
-/**
- * Returns a list of the data types that can be transferred to this DropTarget.
- *
- * @return a list of the data types that can be transferred to this DropTarget
+public DropTarget(Control control, int style) {
+ super (control, checkStyle(style));
+ if (DropProc == null || DragProc == null || TransferProc == null)
+ DND.error(DND.ERROR_CANNOT_INIT_DROP);
+ if (control.getData(DROPTARGETID) != null)
+ DND.error(DND.ERROR_CANNOT_INIT_DROP);
+ control.setData(DROPTARGETID, this);
+ this.control = control;
+ controlListener = new Listener () {
+ public void handleEvent (Event event) {
+ switch (event.type) {
+ case SWT.Dispose: {
+ if (!DropTarget.this.isDisposed()){
+ onDispose();
+ }
+ break;
+ }
+ case SWT.Show: {
+ Display display = event.display;
+ display.asyncExec(new Runnable() {
+ public void run() {
+ if (DropTarget.this.control == null ||
+ DropTarget.this.control.isDisposed() ||
+ !DropTarget.this.control.isVisible()) return;
+
+ registerDropTarget();
+ }
+ });
+ break;
+ }
+ case SWT.Hide: {
+ Display display = event.display;
+ display.asyncExec(new Runnable() {
+ public void run() {
+ if (DropTarget.this.control == null ||
+ DropTarget.this.control.isDisposed() ||
+ DropTarget.this.control.isVisible()) return;
+
+ unregisterDropTarget();
+ }
+ });
+ break;
+ }
+ }
+ }
+ };
+ control.addListener (SWT.Dispose, controlListener);
+ Control c = control;
+ while (c != null) {
+ c.addListener (SWT.Show, controlListener);
+ c.addListener (SWT.Hide, controlListener);
+ c = c.getParent();
+ }
+
+ this.addListener (SWT.Dispose, new Listener () {
+ public void handleEvent (Event event) {
+ if (DropTarget.this.control == null ||
+ DropTarget.this.control.isDisposed()) return;
+
+ unregisterDropTarget();
+ 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);
+ }
+
+ if (control.isVisible()) registerDropTarget();
+}
+
+static DropTarget FindDropTarget(int handle) {
+ Display display = Display.findDisplay(Thread.currentThread());
+ if (display == null || display.isDisposed()) return null;
+ Widget widget = display.findWidget(handle);
+ if (widget == null) return null;
+ return (DropTarget)widget.getData(DROPTARGETID);
+}
+private static int DragProcCallback(int widget, int client_data, int call_data) {
+ DropTarget target = FindDropTarget(widget);
+ if (target == null) return 0;
+ return target.dragProcCallback(widget, client_data, call_data);
+}
+private static int DropProcCallback(int widget, int client_data, int call_data) {
+ DropTarget target = FindDropTarget(widget);
+ if (target == null) return 0;
+ return target.dropProcCallback(widget, client_data, call_data);
+}
+private static int TransferProcCallback(int widget, int client_data, int pSelection, int pType, int pValue, int pLength, int pFormat) {
+ DropTarget target = FindDropTarget(client_data);
+ if (target == null) return 0;
+ return target.transferProcCallback(widget, client_data, pSelection, pType, pValue, pLength, pFormat);
+}
+/**
+ * Adds the listener to the collection of listeners who will
+ * be notified when a drag and drop operation is in progress, by sending
+ * it one of the messages defined in the <code>DropTargetListener</code>
+ * interface.
+ *
+ * <p><ul>
+ * <li><code>dragEnter</code> is called when the cursor has entered the drop target boundaries
+ * <li><code>dragLeave</code> is called when the cursor has left the drop target boundaries and just before
+ * the drop occurs or is cancelled.
+ * <li><code>dragOperationChanged</code> is called when the operation being performed has changed
+ * (usually due to the user changing the selected modifier key(s) while dragging)
+ * <li><code>dragOver</code> is called when the cursor is moving over the drop target
+ * <li><code>dropAccept</code> is called just before the drop is performed. The drop target is given
+ * the chance to change the nature of the drop or veto the drop by setting the <code>event.detail</code> field
+ * <li><code>drop</code> is called when the data is being dropped
+ * </ul></p>
+ *
+ * @param listener the listener which should be notified
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see DropTargetListener
+ * @see #removeDropListener
+ * @see DropTargetEvent
*/
-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 (controlListener != null) {
- Control c = control;
- while (c != null) {
- c.removeListener (SWT.Show, controlListener);
- c.removeListener (SWT.Hide, controlListener);
- c = c.getParent();
- }
- control.removeListener(SWT.Dispose, controlListener);
- }
- controlListener = null;
- control.setData(DROPTARGETID, 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 registerDropTarget() {
- if (control == null || control.isDisposed() || registered) return;
-
- int[] args = new int[]{
- OS.XmNdropSiteOperations, opToOsOp(getStyle()),
- OS.XmNdropSiteActivity, OS.XmDROP_SITE_ACTIVE,
- OS.XmNdropProc, DropProc.getAddress(),
- OS.XmNdragProc, DragProc.getAddress(),
- OS.XmNanimationStyle, OS.XmDRAG_UNDER_NONE,
- OS.XmNdropSiteType, OS.XmDROP_SITE_COMPOSITE,
- };
-
- if (transferAgents.length != 0) {
- 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[] args2 = new int[]{
- OS.XmNimportTargets, pImportTargets,
- OS.XmNnumImportTargets, atoms.length
- };
-
- int[] newArgs = new int[args.length + args2.length];
- System.arraycopy(args, 0, newArgs, 0, args.length);
- System.arraycopy(args2, 0, newArgs, args.length, args2.length);
- args = newArgs;
- }
-
- OS.XmDropSiteRegister(control.handle, args, args.length / 2);
- registered = true;
-}
-
-private void unregisterDropTarget() {
- if (control == null || control.isDisposed() || !registered) return;
- OS.XmDropSiteUnregister(control.handle);
- registered = false;
-}
-private void releaseDropInfo(){
- selectedDataType = null;
- dataTypes = new TransferData[0];
- droppedEventData = null;
- dropTransferObject = 0;
-}
-/**
- * Removes the listener from the collection of listeners who will
- * be notified when a drag and drop operation is in progress.
- *
- * @param listener the listener which should be notified
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see DropTargetListener
- * @see #addDropListener
+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 void updateDragOverHover(long delay, DNDEvent event) {
+ if (delay == 0) {
+ dragOverStart = 0;
+ dragOverEvent = null;
+ dragOverHeartbeat = null;
+ return;
+ }
+ dragOverStart = System.currentTimeMillis() + delay;
+ if (dragOverEvent == null) dragOverEvent = new DNDEvent();
+ dragOverEvent.x = event.x;
+ dragOverEvent.y = event.y;
+ dragOverEvent.dataTypes = event.dataTypes;
+ dragOverEvent.operations = event.operations;
+ dragOverEvent.dataType = event.dataType;
+ dragOverEvent.detail = event.detail;
+}
+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;
+ }
+ }
+ }
+ }
+
+ if (dataTypes == null || dataTypes.length == 0) {
+ callbackData.dropSiteStatus = OS.XmDROP_SITE_INVALID;
+ callbackData.operation = opToOsOp(DND.DROP_NONE);
+ OS.memmove(call_data, callbackData, XmDragProcCallback.sizeof);
+ return 0;
+ }
+
+ if (selectedDataType == null) {
+ selectedDataType = dataTypes[0];
+ }
+
+ 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;
+ int allowedOperations = osOpToOp(callbackData.operations);
+ event.operations = allowedOperations;
+ event.dataType = selectedDataType;
+
+ try {
+ switch (callbackData.reason) {
+ case OS.XmCR_DROP_SITE_ENTER_MESSAGE :
+ event.detail = osOpToOp(callbackData.operation);
+ if ((getStyle() & DND.DROP_DEFAULT) != 0) {
+ int xDisplay = getDisplay().xDisplay;
+ int xWindow = OS.XDefaultRootWindow (xDisplay);
+ int [] unused = new int [1];
+ int[] mask_return = new int[1];
+ OS.XQueryPointer (xDisplay, xWindow, unused, unused, unused, unused, unused, unused, mask_return);
+ int mask = mask_return[0];
+ if ((mask & OS.ShiftMask) == 0 && (mask & OS.ControlMask) == 0) {
+ event.detail = DND.DROP_DEFAULT;
+ }
+ }
+ updateDragOverHover(DRAGOVER_HYSTERESIS, event);
+ notifyListeners(DND.DragEnter, event);
+ effect.show(event.feedback, event.x, event.y);
+ break;
+ case OS.XmCR_DROP_SITE_MOTION_MESSAGE :
+ event.detail = lastOperation;
+ updateDragOverHover(DRAGOVER_HYSTERESIS, event);
+ notifyListeners(DND.DragOver, event);
+ effect.show(event.feedback, event.x, event.y);
+ break;
+ case OS.XmCR_OPERATION_CHANGED :
+ event.detail = osOpToOp(callbackData.operation);
+ if ((getStyle() & DND.DROP_DEFAULT) != 0) {
+ int xDisplay = getDisplay().xDisplay;
+ int xWindow = OS.XDefaultRootWindow (xDisplay);
+ int [] unused = new int [1];
+ int[] mask_return = new int[1];
+ OS.XQueryPointer (xDisplay, xWindow, unused, unused, unused, unused, unused, unused, mask_return);
+ int mask = mask_return[0];
+ if ((mask & OS.ShiftMask) == 0 && (mask & OS.ControlMask) == 0) {
+ event.detail = DND.DROP_DEFAULT;
+ }
+ }
+ updateDragOverHover(DRAGOVER_HYSTERESIS, event);
+ 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;
+ updateDragOverHover(0, null);
+ 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;
+ }
+
+ if (event.detail == DND.DROP_DEFAULT) {
+ event.detail = DND.DROP_MOVE;
+ }
+ 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 && (event.detail & allowedOperations) != 0) {
+ lastOperation = event.detail;
+ }
+ callbackData.dropSiteStatus = OS.XmDROP_SITE_VALID;
+ callbackData.operation = opToOsOp(lastOperation);
+ OS.memmove(call_data, callbackData, XmDragProcCallback.sizeof);
+
+ if (dragOverHeartbeat == null) {
+ dragOverHeartbeat = new Runnable() {
+ public void run() {
+ if (control.isDisposed() || dragOverStart == 0) return;
+ long time = System.currentTimeMillis();
+ int delay = DRAGOVER_HYSTERESIS;
+ if (time >= dragOverStart) {
+ if (selectedDataType == null) {
+ selectedDataType = dragOverEvent.dataTypes[0];
+ }
+ DNDEvent event = new DNDEvent();
+ event.widget = control;
+ event.time = (int)time;
+ event.x = dragOverEvent.x;
+ event.y = dragOverEvent.y;
+ event.dataTypes = dragOverEvent.dataTypes;
+ event.feedback = DND.FEEDBACK_SELECT;
+ int allowedOperations = dragOverEvent.operations;
+ event.operations = allowedOperations;
+ event.dataType = selectedDataType;
+ event.detail = lastOperation;
+ notifyListeners(DND.DragOver, event);
+ effect.show(event.feedback, event.x, event.y);
+ 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 && ((event.detail & allowedOperations) == event.detail)) {
+ lastOperation = event.detail;
+ }
+ } else {
+ delay = (int)(dragOverStart - time);
+ }
+ control.getDisplay().timerExec(delay, dragOverHeartbeat);
+ }
+ };
+ dragOverHeartbeat.run();
+ }
+
+ return 0;
+}
+private int dropProcCallback(int widget, int client_data, int call_data) {
+ updateDragOverHover(0, null);
+ 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;
+ int allowedOperations = osOpToOp(droppedEventData.operations);
+ event.operations = allowedOperations;
+ event.dataType = selectedDataType;
+ event.detail = lastOperation;
+
+ 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;
+ }
+ }
+ lastOperation = DND.DROP_NONE;
+ if (selectedDataType != null && ((event.detail & allowedOperations) == 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] = control.handle; // pass control handle as data to locate drop target
+ transferEntries[1] = selectedDataType.type;
+
+ int pTransferEntries = OS.XtMalloc(transferEntries.length * 4);
+ OS.memmove(pTransferEntries, transferEntries, transferEntries.length * 4);
+
+ int xtContext = OS.XtDisplayToApplicationContext(getDisplay().xDisplay);
+ selectionTimeout = OS.XtAppGetSelectionTimeout(xtContext);
+ OS.XtAppSetSelectionTimeout(xtContext, 0x7fffffff);
+
+ 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 void removeDropListener(DropTargetListener listener) {
- if (listener == null) DND.error (SWT.ERROR_NULL_ARGUMENT);
- removeListener (DND.DragEnter, listener);
- removeListener (DND.DragLeave, listener);
- removeListener (DND.DragOver, listener);
- removeListener (DND.DragOperationChanged, listener);
- removeListener (DND.Drop, listener);
- removeListener (DND.DropAccept, listener);
-}
-
-/**
- * Specifies the data types that can be transferred to this DropTarget. If data is
- * being dragged that does not match one of these types, the drop target will be notified of
- * the drag and drop operation but the currentDataType will be null and the operation
- * will be DND.NONE.
- *
- * @param transferAgents a list of Transfer objects which define the types of data that can be
- * dropped on this target
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if transferAgents is null</li>
- * </ul>
+public Control getControl () {
+ return control;
+}
+
+public Display getDisplay () {
+
+ if (control == null) DND.error(SWT.ERROR_WIDGET_DISPOSED);
+ return control.getDisplay ();
+}
+
+/**
+ * Returns a list of the data types that can be transferred to this DropTarget.
+ *
+ * @return a list of the data types that can be transferred to this DropTarget
*/
-public void setTransfer(Transfer[] transferAgents){
- if (transferAgents == null) DND.error(SWT.ERROR_NULL_ARGUMENT);
- this.transferAgents = transferAgents;
-
- if (!control.isVisible()) return;
-
- // 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 = lastOperation;
- event.data = data;
-
- try {
- notifyListeners(DND.Drop,event);
- } catch (Throwable err) {
- event.detail = DND.DROP_NONE;
- }
-
- int xtContext = OS.XtDisplayToApplicationContext (getDisplay().xDisplay);
- OS.XtAppSetSelectionTimeout (xtContext, selectionTimeout);
-
- if ((event.detail & DND.DROP_MOVE) == DND.DROP_MOVE) {
- int[] args = new int[]{control.handle, DELETE_TYPE};
- OS.XmDropTransferAdd(dropTransferObject, args, args.length / 2);
- }
- }
- return 0;
-}
-
-protected void checkSubclass () {
- String name = getClass().getName ();
- String validName = DropTarget.class.getName();
- if (!validName.equals(name)) {
- DND.error (SWT.ERROR_INVALID_SUBCLASS);
- }
-}
+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 (controlListener != null) {
+ Control c = control;
+ while (c != null) {
+ c.removeListener (SWT.Show, controlListener);
+ c.removeListener (SWT.Hide, controlListener);
+ c = c.getParent();
+ }
+ control.removeListener(SWT.Dispose, controlListener);
+ }
+ controlListener = null;
+ control.setData(DROPTARGETID, 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 registerDropTarget() {
+ if (control == null || control.isDisposed() || registered) return;
+
+ int[] args = new int[]{
+ OS.XmNdropSiteOperations, opToOsOp(getStyle()),
+ OS.XmNdropSiteActivity, OS.XmDROP_SITE_ACTIVE,
+ OS.XmNdropProc, DropProc.getAddress(),
+ OS.XmNdragProc, DragProc.getAddress(),
+ OS.XmNanimationStyle, OS.XmDRAG_UNDER_NONE,
+ OS.XmNdropSiteType, OS.XmDROP_SITE_COMPOSITE,
+ };
+
+ if (transferAgents.length != 0) {
+ 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[] args2 = new int[]{
+ OS.XmNimportTargets, pImportTargets,
+ OS.XmNnumImportTargets, atoms.length
+ };
+
+ int[] newArgs = new int[args.length + args2.length];
+ System.arraycopy(args, 0, newArgs, 0, args.length);
+ System.arraycopy(args2, 0, newArgs, args.length, args2.length);
+ args = newArgs;
+ }
+
+ OS.XmDropSiteRegister(control.handle, args, args.length / 2);
+ registered = true;
+}
+
+private void unregisterDropTarget() {
+ if (control == null || control.isDisposed() || !registered) return;
+ OS.XmDropSiteUnregister(control.handle);
+ registered = false;
+}
+private void releaseDropInfo(){
+ selectedDataType = null;
+ dataTypes = new TransferData[0];
+ droppedEventData = null;
+ dropTransferObject = 0;
+}
+/**
+ * Removes the listener from the collection of listeners who will
+ * be notified when a drag and drop operation is in progress.
+ *
+ * @param listener the listener which should be notified
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see DropTargetListener
+ * @see #addDropListener
+ */
+public void removeDropListener(DropTargetListener listener) {
+ if (listener == null) DND.error (SWT.ERROR_NULL_ARGUMENT);
+ removeListener (DND.DragEnter, listener);
+ removeListener (DND.DragLeave, listener);
+ removeListener (DND.DragOver, listener);
+ removeListener (DND.DragOperationChanged, listener);
+ removeListener (DND.Drop, listener);
+ removeListener (DND.DropAccept, listener);
+}
+
+/**
+ * Specifies the data types that can be transferred to this DropTarget. If data is
+ * being dragged that does not match one of these types, the drop target will be notified of
+ * the drag and drop operation but the currentDataType will be null and the operation
+ * will be DND.NONE.
+ *
+ * @param transferAgents a list of Transfer objects which define the types of data that can be
+ * dropped on this target
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if transferAgents is null</li>
+ * </ul>
+ */
+public void setTransfer(Transfer[] transferAgents){
+ if (transferAgents == null) DND.error(SWT.ERROR_NULL_ARGUMENT);
+ this.transferAgents = transferAgents;
+
+ if (!control.isVisible()) return;
+
+ // 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 = lastOperation;
+ event.data = data;
+
+ try {
+ notifyListeners(DND.Drop,event);
+ } catch (Throwable err) {
+ event.detail = DND.DROP_NONE;
+ }
+
+ int xtContext = OS.XtDisplayToApplicationContext (getDisplay().xDisplay);
+ OS.XtAppSetSelectionTimeout (xtContext, selectionTimeout);
+
+ if ((event.detail & DND.DROP_MOVE) == DND.DROP_MOVE) {
+ int[] args = new int[]{control.handle, DELETE_TYPE};
+ OS.XmDropTransferAdd(dropTransferObject, args, args.length / 2);
+ }
+ }
+ return 0;
+}
+
+protected void checkSubclass () {
+ String name = getClass().getName ();
+ String validName = DropTarget.class.getName();
+ if (!validName.equals(name)) {
+ DND.error (SWT.ERROR_INVALID_SUBCLASS);
+ }
+}
} \ No newline at end of file
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
index 460b5097aa..a07fe8743b 100755
--- 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
@@ -1,115 +1,115 @@
-package org.eclipse.swt.dnd;
-
-/*
+package org.eclipse.swt.dnd;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-import org.eclipse.swt.internal.Converter;
-
-/**
- * The class <code>FileTransfer</code> provides a platform specific mechanism
- * for converting a list of files represented as a java <code>String[]</code> to a
- * platform specific representation of the data and vice versa.
- * Each <code>String</code> in the array contains the absolute path for a single
- * file or directory.
- * See <code>Transfer</code> for additional information.
- *
- * <p>An example of a java <code>String[]</code> containing a list of files is shown
- * below:</p>
- *
- * <code><pre>
- * File file1 = new File("C:\temp\file1");
- * File file2 = new File("C:\temp\file2");
- * String[] fileData = new String[2];
- * fileData[0] = file1.getAbsolutePath();
- * fileData[1] = file2.getAbsolutePath();
- * </code></pre>
+ * http://www.eclipse.org/legal/cpl-v10.html
*/
-public class FileTransfer extends ByteArrayTransfer {
-
- private static FileTransfer _instance = new FileTransfer();
- private static final String TYPENAME = "text/uri-list";
- private static final int TYPEID = registerType(TYPENAME);
-
-private FileTransfer() {}
-/**
- * Returns the singleton instance of the FileTransfer class.
- *
- * @return the singleton instance of the FileTransfer class
+import org.eclipse.swt.internal.Converter;
+
+/**
+ * The class <code>FileTransfer</code> provides a platform specific mechanism
+ * for converting a list of files represented as a java <code>String[]</code> to a
+ * platform specific representation of the data and vice versa.
+ * Each <code>String</code> in the array contains the absolute path for a single
+ * file or directory.
+ * See <code>Transfer</code> for additional information.
+ *
+ * <p>An example of a java <code>String[]</code> containing a list of files is shown
+ * below:</p>
+ *
+ * <code><pre>
+ * File file1 = new File("C:\temp\file1");
+ * File file2 = new File("C:\temp\file2");
+ * String[] fileData = new String[2];
+ * fileData[0] = file1.getAbsolutePath();
+ * fileData[1] = file2.getAbsolutePath();
+ * </code></pre>
*/
-public static FileTransfer getInstance () {
- return _instance;
-}
-/**
- * This implementation of <code>javaToNative</code> converts a list of file names
- * represented by a java <code>String[]</code> to a platform specific representation.
- * Each <code>String</code> in the array contains the absolute path for a single
- * file or directory. For additional information see
- * <code>Transfer#javaToNative</code>.
- *
- * @param object a java <code>String[]</code> containing the file names to be
- * converted
- * @param transferData an empty <code>TransferData</code> object; this
- * object will be filled in on return with the platform specific format of the data
+public class FileTransfer extends ByteArrayTransfer {
+
+ private static FileTransfer _instance = new FileTransfer();
+ private static final String TYPENAME = "text/uri-list";
+ private static final int TYPEID = registerType(TYPENAME);
+
+private FileTransfer() {}
+/**
+ * Returns the singleton instance of the FileTransfer class.
+ *
+ * @return the singleton instance of the FileTransfer class
*/
-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 = "";
- for (int i = 0, length = files.length; i < length; i++){
- nativeFormat += "file:"+files[i]+"\r";
- }
- byte[] buffer = Converter.wcsToMbcs(null, nativeFormat, true);
- // pass byte array on to super to convert to native
- super.javaToNative(buffer, transferData);
-}
-/**
- * This implementation of <code>nativeToJava</code> converts a platform specific
- * representation of a list of file names to a java <code>String[]</code>.
- * Each String in the array contains the absolute path for a single file or directory.
- * For additional information see <code>Transfer#nativeToJava</code>.
- *
- * @param transferData the platform specific representation of the data to be
- * been converted
- * @return a java <code>String[]</code> containing a list of file names if the
- * conversion was successful; otherwise null
+public static FileTransfer getInstance () {
+ return _instance;
+}
+/**
+ * This implementation of <code>javaToNative</code> converts a list of file names
+ * represented by a java <code>String[]</code> to a platform specific representation.
+ * Each <code>String</code> in the array contains the absolute path for a single
+ * file or directory. For additional information see
+ * <code>Transfer#javaToNative</code>.
+ *
+ * @param object a java <code>String[]</code> containing the file names to be
+ * converted
+ * @param transferData an empty <code>TransferData</code> object; this
+ * object will be filled in on return with the platform specific format of the data
*/
-public Object nativeToJava(TransferData transferData) {
-
- byte[] data = (byte[])super.nativeToJava(transferData);
- if (data == null) return null;
- char[] unicode = Converter.mbcsToWcs(null, data);
- String string = new String(unicode);
- // 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};
-}
-}
+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 = "";
+ for (int i = 0, length = files.length; i < length; i++){
+ nativeFormat += "file:"+files[i]+"\r";
+ }
+ byte[] buffer = Converter.wcsToMbcs(null, nativeFormat, true);
+ // pass byte array on to super to convert to native
+ super.javaToNative(buffer, transferData);
+}
+/**
+ * This implementation of <code>nativeToJava</code> converts a platform specific
+ * representation of a list of file names to a java <code>String[]</code>.
+ * Each String in the array contains the absolute path for a single file or directory.
+ * For additional information see <code>Transfer#nativeToJava</code>.
+ *
+ * @param transferData the platform specific representation of the data to be
+ * been converted
+ * @return a java <code>String[]</code> containing a list of file names if the
+ * conversion was successful; otherwise null
+ */
+public Object nativeToJava(TransferData transferData) {
+
+ byte[] data = (byte[])super.nativeToJava(transferData);
+ if (data == null) return null;
+ char[] unicode = Converter.mbcsToWcs(null, data);
+ String string = new String(unicode);
+ // 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
index 7a9effbace..731ae5347c 100755
--- 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
@@ -1,85 +1,85 @@
-package org.eclipse.swt.dnd;
-
-/*
+package org.eclipse.swt.dnd;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-import org.eclipse.swt.internal.Converter;
-
-/**
- * The class <code>RTFTransfer</code> provides a platform specific mechanism
- * for converting text in RTF format represented as a java <code>String</code>
- * to a platform specific representation of the data and vice versa. See
- * <code>Transfer</code> for additional information.
- *
- * <p>An example of a java <code>String</code> containing RTF text is shown
- * below:</p>
- *
- * <code><pre>
- * String rtfData = "{\\rtf1{\\colortbl;\\red255\\green0\\blue0;}\\uc1\\b\\i Hello World}";
- * </code></pre>
+ * http://www.eclipse.org/legal/cpl-v10.html
*/
-public class RTFTransfer extends ByteArrayTransfer {
-
- private static RTFTransfer _instance = new RTFTransfer();
- private static final String TYPENAME1 = "text/rtf";
- private static final int TYPEID1 = registerType(TYPENAME1);
- private static final String TYPENAME2 = "TEXT/RTF";
- private static final int TYPEID2 = registerType(TYPENAME2);
- private static final String TYPENAME3 = "application/rtf";
- private static final int TYPEID3 = registerType(TYPENAME3);
-
-private RTFTransfer() {
-}
-/**
- * Returns the singleton instance of the RTFTransfer class.
- *
- * @return the singleton instance of the RTFTransfer class
+
+import org.eclipse.swt.internal.Converter;
+
+/**
+ * The class <code>RTFTransfer</code> provides a platform specific mechanism
+ * for converting text in RTF format represented as a java <code>String</code>
+ * to a platform specific representation of the data and vice versa. See
+ * <code>Transfer</code> for additional information.
+ *
+ * <p>An example of a java <code>String</code> containing RTF text is shown
+ * below:</p>
+ *
+ * <code><pre>
+ * String rtfData = "{\\rtf1{\\colortbl;\\red255\\green0\\blue0;}\\uc1\\b\\i Hello World}";
+ * </code></pre>
*/
-public static RTFTransfer getInstance () {
- return _instance;
-}
-/**
- * This implementation of <code>javaToNative</code> converts RTF-formatted text
- * represented by a java <code>String</code> to a platform specific representation.
- * For additional information see <code>Transfer#javaToNative</code>.
- *
- * @param object a java <code>String</code> containing RTF text
- * @param transferData an empty <code>TransferData</code> object; this
- * object will be filled in on return with the platform specific format of the data
+public class RTFTransfer extends ByteArrayTransfer {
+
+ private static RTFTransfer _instance = new RTFTransfer();
+ private static final String TYPENAME1 = "text/rtf";
+ private static final int TYPEID1 = registerType(TYPENAME1);
+ private static final String TYPENAME2 = "TEXT/RTF";
+ private static final int TYPEID2 = registerType(TYPENAME2);
+ private static final String TYPENAME3 = "application/rtf";
+ private static final int TYPEID3 = registerType(TYPENAME3);
+
+private RTFTransfer() {
+}
+/**
+ * Returns the singleton instance of the RTFTransfer class.
+ *
+ * @return the singleton instance of the RTFTransfer class
*/
-public void javaToNative (Object object, TransferData transferData){
- if (object == null || !(object instanceof String)) return;
- byte [] buffer = Converter.wcsToMbcs (null, (String)object, true);
- super.javaToNative(buffer, transferData);
-}
-/**
- * This implementation of <code>nativeToJava</code> converts a platform specific
- * representation of RTF text to a java <code>String</code>.
- * For additional information see <code>Transfer#nativeToJava</code>.
- *
- * @param transferData the platform specific representation of the data to be
- * been converted
- * @return a java <code>String</code> containing RTF text if the
- * conversion was successful; otherwise null
+public static RTFTransfer getInstance () {
+ return _instance;
+}
+/**
+ * This implementation of <code>javaToNative</code> converts RTF-formatted text
+ * represented by a java <code>String</code> to a platform specific representation.
+ * For additional information see <code>Transfer#javaToNative</code>.
+ *
+ * @param object a java <code>String</code> containing RTF text
+ * @param transferData an empty <code>TransferData</code> object; this
+ * object will be filled in on return with the platform specific format of the data
*/
-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
- char [] unicode = Converter.mbcsToWcs (null, buffer);
- String string = new String (unicode);
- int end = string.indexOf('\0');
- return (end == -1) ? string : string.substring(0, end);
-}
-protected String[] getTypeNames(){
- return new String[]{TYPENAME1, TYPENAME2, TYPENAME3};
-}
-protected int[] getTypeIds(){
- return new int[]{TYPEID1, TYPEID2, TYPEID3};
-}
-}
+public void javaToNative (Object object, TransferData transferData){
+ if (object == null || !(object instanceof String)) return;
+ byte [] buffer = Converter.wcsToMbcs (null, (String)object, true);
+ super.javaToNative(buffer, transferData);
+}
+/**
+ * This implementation of <code>nativeToJava</code> converts a platform specific
+ * representation of RTF text to a java <code>String</code>.
+ * For additional information see <code>Transfer#nativeToJava</code>.
+ *
+ * @param transferData the platform specific representation of the data to be
+ * been converted
+ * @return a java <code>String</code> containing RTF text 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
+ char [] unicode = Converter.mbcsToWcs (null, buffer);
+ String string = new String (unicode);
+ int end = string.indexOf('\0');
+ return (end == -1) ? string : string.substring(0, end);
+}
+protected String[] getTypeNames(){
+ return new String[]{TYPENAME1, TYPENAME2, TYPENAME3};
+}
+protected int[] getTypeIds(){
+ return new int[]{TYPEID1, TYPEID2, TYPEID3};
+}
+}
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
index f716405435..02a26224b3 100755
--- 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
@@ -1,103 +1,103 @@
-package org.eclipse.swt.dnd;
-
-/*
+package org.eclipse.swt.dnd;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-import org.eclipse.swt.graphics.*;
-import org.eclipse.swt.widgets.*;
-
-class TableDragUnderEffect extends DragUnderEffect {
- private Table table;
- private TableItem[] selection = new TableItem[0];
- private int currentEffect = DND.FEEDBACK_NONE;
- private TableItem dropSelection;
- private TableItem scrollItem;
- private long scrollBeginTime;
- private static final int SCROLL_HYSTERESIS = 400; // milli seconds
- private static final int SCROLL_WIDTH = 100; // pixels
-
-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;
- if (currentEffect == DND.FEEDBACK_NONE && effect != DND.FEEDBACK_NONE) {
- selection = table.getSelection();
- table.deselectAll();
- }
- scrollHover(effect, item, x, y);
- setDragUnderEffect(effect, item);
- if (currentEffect != DND.FEEDBACK_NONE && effect == DND.FEEDBACK_NONE) {
- table.setSelection(selection);
- selection = new TableItem[0];
- }
- currentEffect = effect;
-}
-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 ((effect & DND.FEEDBACK_SELECT) != 0) {
- setDropSelection(item);
- return;
- }
- if ((currentEffect & DND.FEEDBACK_SELECT) != 0) setDropSelection(null);
-}
-private void setDropSelection (TableItem item) {
- if (item == dropSelection) return;
- if (dropSelection != null) table.deselectAll();
- dropSelection = item;
- if (dropSelection != null) table.setSelection(new TableItem[]{dropSelection});
-}
-private void scrollHover (int effect, TableItem item, int x, int y) {
- if ((effect & DND.FEEDBACK_SCROLL) == 0) {
- scrollBeginTime = 0;
- scrollItem = null;
- return;
- }
- if (scrollItem == item && scrollBeginTime != 0) {
- if (System.currentTimeMillis() >= scrollBeginTime) {
- scroll(item, x, y);
- scrollBeginTime = 0;
- scrollItem = null;
- }
- return;
- }
- scrollBeginTime = System.currentTimeMillis() + SCROLL_HYSTERESIS;
- scrollItem = item;
-}
-private void scroll(TableItem item, int x, int y) {
- if (item == null) return;
- Point coordinates = new Point(x, y);
- coordinates = table.toControl(coordinates);
- Rectangle area = table.getClientArea();
- TableItem showItem = null;
- int itemIndex = table.indexOf(item);
- if (coordinates.y - area.y < SCROLL_WIDTH) {
- showItem = table.getItem(Math.max(0, itemIndex - 1));
- } else if ((area.y + area.height - coordinates.y) < SCROLL_WIDTH) {
- showItem = table.getItem(Math.min(table.getItemCount() - 1, itemIndex + 1));
- }
- if (showItem != null) {
- table.showItem(showItem);
- }
-}
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.widgets.*;
+
+class TableDragUnderEffect extends DragUnderEffect {
+ private Table table;
+ private TableItem[] selection = new TableItem[0];
+ private int currentEffect = DND.FEEDBACK_NONE;
+ private TableItem dropSelection;
+ private TableItem scrollItem;
+ private long scrollBeginTime;
+ private static final int SCROLL_HYSTERESIS = 400; // milli seconds
+ private static final int SCROLL_WIDTH = 100; // pixels
+
+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;
+ if (currentEffect == DND.FEEDBACK_NONE && effect != DND.FEEDBACK_NONE) {
+ selection = table.getSelection();
+ table.deselectAll();
+ }
+ scrollHover(effect, item, x, y);
+ setDragUnderEffect(effect, item);
+ if (currentEffect != DND.FEEDBACK_NONE && effect == DND.FEEDBACK_NONE) {
+ table.setSelection(selection);
+ selection = new TableItem[0];
+ }
+ currentEffect = effect;
+}
+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 ((effect & DND.FEEDBACK_SELECT) != 0) {
+ setDropSelection(item);
+ return;
+ }
+ if ((currentEffect & DND.FEEDBACK_SELECT) != 0) setDropSelection(null);
+}
+private void setDropSelection (TableItem item) {
+ if (item == dropSelection) return;
+ if (dropSelection != null) table.deselectAll();
+ dropSelection = item;
+ if (dropSelection != null) table.setSelection(new TableItem[]{dropSelection});
+}
+private void scrollHover (int effect, TableItem item, int x, int y) {
+ if ((effect & DND.FEEDBACK_SCROLL) == 0) {
+ scrollBeginTime = 0;
+ scrollItem = null;
+ return;
+ }
+ if (scrollItem == item && scrollBeginTime != 0) {
+ if (System.currentTimeMillis() >= scrollBeginTime) {
+ scroll(item, x, y);
+ scrollBeginTime = 0;
+ scrollItem = null;
+ }
+ return;
+ }
+ scrollBeginTime = System.currentTimeMillis() + SCROLL_HYSTERESIS;
+ scrollItem = item;
+}
+private void scroll(TableItem item, int x, int y) {
+ if (item == null) return;
+ Point coordinates = new Point(x, y);
+ coordinates = table.toControl(coordinates);
+ Rectangle area = table.getClientArea();
+ TableItem showItem = null;
+ int itemIndex = table.indexOf(item);
+ if (coordinates.y - area.y < SCROLL_WIDTH) {
+ showItem = table.getItem(Math.max(0, itemIndex - 1));
+ } else if ((area.y + area.height - coordinates.y) < SCROLL_WIDTH) {
+ showItem = table.getItem(Math.min(table.getItemCount() - 1, itemIndex + 1));
+ }
+ if (showItem != null) {
+ table.showItem(showItem);
+ }
+}
+}
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
index 72d5beafa3..a0e3917e41 100755
--- 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
@@ -1,134 +1,134 @@
-package org.eclipse.swt.dnd;
-
-/*
+package org.eclipse.swt.dnd;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.internal.Converter;
-import org.eclipse.swt.internal.motif.OS;
-import org.eclipse.swt.internal.motif.XTextProperty;
-/**
- * The class <code>TextTransfer</code> provides a platform specific mechanism
- * for converting plain text represented as a java <code>String</code>
- * to a platform specific representation of the data and vice versa. See
- * <code>Transfer</code> for additional information.
- *
- * <p>An example of a java <code>String</code> containing plain text is shown
- * below:</p>
- *
- * <code><pre>
- * String textData = "Hello World";
- * </code></pre>
+ * http://www.eclipse.org/legal/cpl-v10.html
*/
-public class TextTransfer extends ByteArrayTransfer {
-
- private static TextTransfer _instance = new TextTransfer();
- private static final String TYPENAME1 = "COMPOUND_TEXT";
- private static final int TYPEID1 = registerType(TYPENAME1);
- private static final String TYPENAME2 = "STRING";
- private static final int TYPEID2 = registerType(TYPENAME2);
-
-private TextTransfer() {
-}
-/**
- * Returns the singleton instance of the TextTransfer class.
- *
- * @return the singleton instance of the TextTransfer class
+
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.internal.Converter;
+import org.eclipse.swt.internal.motif.OS;
+import org.eclipse.swt.internal.motif.XTextProperty;
+/**
+ * The class <code>TextTransfer</code> provides a platform specific mechanism
+ * for converting plain text represented as a java <code>String</code>
+ * to a platform specific representation of the data and vice versa. See
+ * <code>Transfer</code> for additional information.
+ *
+ * <p>An example of a java <code>String</code> containing plain text is shown
+ * below:</p>
+ *
+ * <code><pre>
+ * String textData = "Hello World";
+ * </code></pre>
*/
-public static TextTransfer getInstance () {
- return _instance;
-}
-/**
- * This implementation of <code>javaToNative</code> converts plain text
- * represented by a java <code>String</code> to a platform specific representation.
- * For additional information see <code>Transfer#javaToNative</code>.
- *
- * @param object a java <code>String</code> containing text
- * @param transferData an empty <code>TransferData</code> object; this
- * object will be filled in on return with the platform specific format of the data
+public class TextTransfer extends ByteArrayTransfer {
+
+ private static TextTransfer _instance = new TextTransfer();
+ private static final String TYPENAME1 = "COMPOUND_TEXT";
+ private static final int TYPEID1 = registerType(TYPENAME1);
+ private static final String TYPENAME2 = "STRING";
+ private static final int TYPEID2 = registerType(TYPENAME2);
+
+private TextTransfer() {
+}
+/**
+ * Returns the singleton instance of the TextTransfer class.
+ *
+ * @return the singleton instance of the TextTransfer class
*/
-public void javaToNative (Object object, TransferData transferData){
- if (object == null || !(object instanceof String)) return;
- byte[] buffer = Converter.wcsToMbcs (null, (String)object, true);
- if (transferData.type == TYPEID1) { // COMPOUND_TEXT
- Display display = Display.getCurrent();
- if (display == null) {
- transferData.result = 0;
- return;
- }
- int xDisplay = display.xDisplay;
- int pBuffer = OS.XtMalloc(buffer.length);
- OS.memmove(pBuffer, buffer, buffer.length);
- int list = OS.XtMalloc(4);
- OS.memmove(list, new int[] {pBuffer}, 4);
- XTextProperty text_prop_return = new XTextProperty();
- int result = OS.XmbTextListToTextProperty (xDisplay, list, 1, OS.XCompoundTextStyle, text_prop_return);
- OS.XtFree(pBuffer);
- OS.XtFree(list);
- if (result != 0){
- transferData.result = 0;
- } else {
- transferData.format = text_prop_return.format;
- transferData.length = text_prop_return.nitems;
- transferData.pValue = text_prop_return.value;
- transferData.type = text_prop_return.encoding;
- transferData.result = 1;
- }
- } else {
- super.javaToNative(buffer, transferData);
- }
-}
-/**
- * This implementation of <code>nativeToJava</code> converts a platform specific
- * representation of plain text to a java <code>String</code>.
- * For additional information see <code>Transfer#nativeToJava</code>.
- *
- * @param transferData the platform specific representation of the data to be
- * been converted
- * @return a java <code>String</code> containing text if the
- * conversion was successful; otherwise null
+public static TextTransfer getInstance () {
+ return _instance;
+}
+/**
+ * This implementation of <code>javaToNative</code> converts plain text
+ * represented by a java <code>String</code> to a platform specific representation.
+ * For additional information see <code>Transfer#javaToNative</code>.
+ *
+ * @param object a java <code>String</code> containing text
+ * @param transferData an empty <code>TransferData</code> object; this
+ * object will be filled in on return with the platform specific format of the data
*/
-public Object nativeToJava(TransferData transferData){
- // get byte array from super
- byte[] buffer = null;
- if (transferData.type == TYPEID1){ //COMPOUND_TEXT
- Display display = Display.getCurrent();
- if (display == null) return null;
- int xDisplay = display.xDisplay;
- XTextProperty text_prop = new XTextProperty();
- text_prop.encoding = transferData.type;
- text_prop.format = transferData.format;
- text_prop.nitems = transferData.length;
- text_prop.value = transferData.pValue;
- int[] list_return = new int[1];
- int[] count_return = new int[1];
- int result = OS.XmbTextPropertyToTextList (xDisplay, text_prop, list_return, count_return);
- if (result != 0) return null;
- //Note: only handling the first string in list
- int[] ptr = new int[1];
- OS.memmove(ptr, list_return[0], 4);
- int length = OS.strlen(ptr[0]);
- buffer = new byte[length];
- OS.memmove(buffer, ptr[0], buffer.length);
- OS.XFreeStringList(list_return[0]);
- } else {
- buffer = (byte[])super.nativeToJava(transferData);
- }
- if (buffer == null) return null;
- // convert byte array to a string
- char [] unicode = Converter.mbcsToWcs (null, buffer);
- String string = new String (unicode);
- int end = string.indexOf('\0');
- return (end == -1) ? string : string.substring(0, end);
-}
-protected String[] getTypeNames(){
- return new String[]{TYPENAME1, TYPENAME2,};
-}
-protected int[] getTypeIds(){
- return new int[]{TYPEID1, TYPEID2,};
-}
-}
+public void javaToNative (Object object, TransferData transferData){
+ if (object == null || !(object instanceof String)) return;
+ byte[] buffer = Converter.wcsToMbcs (null, (String)object, true);
+ if (transferData.type == TYPEID1) { // COMPOUND_TEXT
+ Display display = Display.getCurrent();
+ if (display == null) {
+ transferData.result = 0;
+ return;
+ }
+ int xDisplay = display.xDisplay;
+ int pBuffer = OS.XtMalloc(buffer.length);
+ OS.memmove(pBuffer, buffer, buffer.length);
+ int list = OS.XtMalloc(4);
+ OS.memmove(list, new int[] {pBuffer}, 4);
+ XTextProperty text_prop_return = new XTextProperty();
+ int result = OS.XmbTextListToTextProperty (xDisplay, list, 1, OS.XCompoundTextStyle, text_prop_return);
+ OS.XtFree(pBuffer);
+ OS.XtFree(list);
+ if (result != 0){
+ transferData.result = 0;
+ } else {
+ transferData.format = text_prop_return.format;
+ transferData.length = text_prop_return.nitems;
+ transferData.pValue = text_prop_return.value;
+ transferData.type = text_prop_return.encoding;
+ transferData.result = 1;
+ }
+ } else {
+ super.javaToNative(buffer, transferData);
+ }
+}
+/**
+ * This implementation of <code>nativeToJava</code> converts a platform specific
+ * representation of plain text to a java <code>String</code>.
+ * For additional information see <code>Transfer#nativeToJava</code>.
+ *
+ * @param transferData the platform specific representation of the data to be
+ * been converted
+ * @return a java <code>String</code> containing text if the
+ * conversion was successful; otherwise null
+ */
+public Object nativeToJava(TransferData transferData){
+ // get byte array from super
+ byte[] buffer = null;
+ if (transferData.type == TYPEID1){ //COMPOUND_TEXT
+ Display display = Display.getCurrent();
+ if (display == null) return null;
+ int xDisplay = display.xDisplay;
+ XTextProperty text_prop = new XTextProperty();
+ text_prop.encoding = transferData.type;
+ text_prop.format = transferData.format;
+ text_prop.nitems = transferData.length;
+ text_prop.value = transferData.pValue;
+ int[] list_return = new int[1];
+ int[] count_return = new int[1];
+ int result = OS.XmbTextPropertyToTextList (xDisplay, text_prop, list_return, count_return);
+ if (result != 0) return null;
+ //Note: only handling the first string in list
+ int[] ptr = new int[1];
+ OS.memmove(ptr, list_return[0], 4);
+ int length = OS.strlen(ptr[0]);
+ buffer = new byte[length];
+ OS.memmove(buffer, ptr[0], buffer.length);
+ OS.XFreeStringList(list_return[0]);
+ } else {
+ buffer = (byte[])super.nativeToJava(transferData);
+ }
+ if (buffer == null) return null;
+ // convert byte array to a string
+ char [] unicode = Converter.mbcsToWcs (null, buffer);
+ String string = new String (unicode);
+ int end = string.indexOf('\0');
+ return (end == -1) ? string : string.substring(0, end);
+}
+protected String[] getTypeNames(){
+ return new String[]{TYPENAME1, TYPENAME2,};
+}
+protected int[] getTypeIds(){
+ return new int[]{TYPEID1, TYPEID2,};
+}
+}
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
index 9a8bea504b..2353743ca8 100755
--- 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
@@ -1,131 +1,131 @@
-package org.eclipse.swt.dnd;
-
-/*
+package org.eclipse.swt.dnd;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-import org.eclipse.swt.internal.Converter;
-import org.eclipse.swt.internal.motif.OS;
-import org.eclipse.swt.widgets.Display;
-
-/**
- * <code>Transfer</code> provides a mechanism for converting between a java
- * representation of data and a platform specific representation of data and
- * vice versa. It is used in data transfer operations such as drag and drop and
- * clipboard copy/paste.
- *
- * <p>You should only need to become familiar with this class if you are
- * implementing a Transfer subclass and you are unable to subclass the
- * ByteArrayTransfer class.</p>
- *
- * @see ByteArrayTransfer
+ * http://www.eclipse.org/legal/cpl-v10.html
*/
-public abstract class Transfer {
-
-/**
- * Returns a list of the platform specific data types that can be converted using
- * this transfer agent.
- *
- * <p>Only the data type fields of the <code>TransferData</code> objects are filled
- * in.</p>
- *
- * @return a list of the data types that can be converted using this transfer agent
+
+import org.eclipse.swt.internal.Converter;
+import org.eclipse.swt.internal.motif.OS;
+import org.eclipse.swt.widgets.Display;
+
+/**
+ * <code>Transfer</code> provides a mechanism for converting between a java
+ * representation of data and a platform specific representation of data and
+ * vice versa. It is used in data transfer operations such as drag and drop and
+ * clipboard copy/paste.
+ *
+ * <p>You should only need to become familiar with this class if you are
+ * implementing a Transfer subclass and you are unable to subclass the
+ * ByteArrayTransfer class.</p>
+ *
+ * @see ByteArrayTransfer
*/
-abstract public TransferData[] getSupportedTypes();
-
-/**
- * Returns true if the <code>TransferData</code> data type can be converted
- * using this transfer agent.
- *
- * @param transferData a platform specific description of a data type; only the data
- * type fields of the <code>TransferData</code> object need to be filled in
- *
- * @return true if the transferData data type can be converted using this transfer
- * agent
+public abstract class Transfer {
+
+/**
+ * Returns a list of the platform specific data types that can be converted using
+ * this transfer agent.
+ *
+ * <p>Only the data type fields of the <code>TransferData</code> objects are filled
+ * in.</p>
+ *
+ * @return a list of the data types that can be converted using this transfer agent
*/
-abstract public boolean isSupportedType(TransferData transferData);
-
-/**
- * Returns the platform specfic names of the data types that can be converted
- * using this transfer agent.
- *
- * @return the platform specfic names of the data types that can be converted
- * using this transfer agent.
- */
-abstract protected String[] getTypeNames();
-
-/**
- * Returns the platform specfic ids of the data types that can be converted using
- * this transfer agent.
- *
- * @return the platform specfic ids of the data types that can be converted using
- * this transfer agent
- */
-abstract protected int[] getTypeIds();
-
-/**
- * Converts a java representation of data to a platform specific representation of
- * the data.
- *
- * <p>On a successful conversion, the transferData.result field will be set as follows:
- * <ul>
- * <li>Windows: COM.S_OK
- * <li>Motif: 1
- * <li>GTK: 1
- * <li>Photon: 1
- * </ul></p>
- *
- * <p>If this transfer agent is unable to perform the conversion, the transferData.result
- * field will be set to a failure value as follows:
- * <ul>
- * <li>Windows: COM.DV_E_TYMED or COM.E_FAIL
- * <li>Motif: 0
- * <li>GTK: 0
- * <li>Photon: 0
- * </ul></p>
- *
- * @param object a java representation of the data to be converted; the type of
- * Object that is passed in is dependant on the <code>Transfer</code> subclass.
- *
- * @param transferData an empty TransferData object; this object will be
- * filled in on return with the platform specific representation of the data
- */
-abstract protected void javaToNative (Object object, TransferData transferData);
-
-/**
- * Converts a platform specific representation of data to a java representation.
- *
- * @param transferData the platform specific representation of the data to be
- * converted
- *
- * @return a java representation of the converted data if the conversion was
- * successful; otherwise null. The type of Object that is returned is dependant
- * on the <code>Transfer</code> subclass
- */
-abstract protected Object nativeToJava(TransferData transferData);
-
-/**
- * Registers a name for a data type and returns the associated unique identifier.
- *
- * <p>You may register the same type more than once, the same unique identifier
- * will be returned if the type has been previously registered.</p>
- *
- * <p>Note: On windows, do <b>not</b> call this method with pre-defined
- * Clipboard Format types such as CF_TEXT or CF_BITMAP because the
- * pre-defined identifier will not be returned</p>
- *
- * @param formatName the name of a data type
- *
- * @return the unique identifier associated with htis data type
+abstract public TransferData[] getSupportedTypes();
+
+/**
+ * Returns true if the <code>TransferData</code> data type can be converted
+ * using this transfer agent.
+ *
+ * @param transferData a platform specific description of a data type; only the data
+ * type fields of the <code>TransferData</code> object need to be filled in
+ *
+ * @return true if the transferData data type can be converted using this transfer
+ * agent
*/
-public static int registerType(String formatName){
- // Use default display because we don't have a particular widget
- int xDisplay = Display.getDefault().xDisplay;
- // Use the character encoding for the default locale
- byte[] buffer = Converter.wcsToMbcs (null, formatName, true);
- return OS.XmInternAtom (xDisplay, buffer, false);
-}
-}
+abstract public boolean isSupportedType(TransferData transferData);
+
+/**
+ * Returns the platform specfic names of the data types that can be converted
+ * using this transfer agent.
+ *
+ * @return the platform specfic names of the data types that can be converted
+ * using this transfer agent.
+ */
+abstract protected String[] getTypeNames();
+
+/**
+ * Returns the platform specfic ids of the data types that can be converted using
+ * this transfer agent.
+ *
+ * @return the platform specfic ids of the data types that can be converted using
+ * this transfer agent
+ */
+abstract protected int[] getTypeIds();
+
+/**
+ * Converts a java representation of data to a platform specific representation of
+ * the data.
+ *
+ * <p>On a successful conversion, the transferData.result field will be set as follows:
+ * <ul>
+ * <li>Windows: COM.S_OK
+ * <li>Motif: 1
+ * <li>GTK: 1
+ * <li>Photon: 1
+ * </ul></p>
+ *
+ * <p>If this transfer agent is unable to perform the conversion, the transferData.result
+ * field will be set to a failure value as follows:
+ * <ul>
+ * <li>Windows: COM.DV_E_TYMED or COM.E_FAIL
+ * <li>Motif: 0
+ * <li>GTK: 0
+ * <li>Photon: 0
+ * </ul></p>
+ *
+ * @param object a java representation of the data to be converted; the type of
+ * Object that is passed in is dependant on the <code>Transfer</code> subclass.
+ *
+ * @param transferData an empty TransferData object; this object will be
+ * filled in on return with the platform specific representation of the data
+ */
+abstract protected void javaToNative (Object object, TransferData transferData);
+
+/**
+ * Converts a platform specific representation of data to a java representation.
+ *
+ * @param transferData the platform specific representation of the data to be
+ * converted
+ *
+ * @return a java representation of the converted data if the conversion was
+ * successful; otherwise null. The type of Object that is returned is dependant
+ * on the <code>Transfer</code> subclass
+ */
+abstract protected Object nativeToJava(TransferData transferData);
+
+/**
+ * Registers a name for a data type and returns the associated unique identifier.
+ *
+ * <p>You may register the same type more than once, the same unique identifier
+ * will be returned if the type has been previously registered.</p>
+ *
+ * <p>Note: On windows, do <b>not</b> call this method with pre-defined
+ * Clipboard Format types such as CF_TEXT or CF_BITMAP because the
+ * pre-defined identifier will not be returned</p>
+ *
+ * @param formatName the name of a data type
+ *
+ * @return the unique identifier associated with htis data type
+ */
+public static int registerType(String formatName){
+ // Use default display because we don't have a particular widget
+ int xDisplay = Display.getDefault().xDisplay;
+ // Use the character encoding for the default locale
+ byte[] buffer = Converter.wcsToMbcs (null, formatName, true);
+ return OS.XmInternAtom (xDisplay, buffer, false);
+}
+}
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
index 63cf330737..53a8ec2d88 100755
--- 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
@@ -1,63 +1,63 @@
-package org.eclipse.swt.dnd;
-
-/*
+package org.eclipse.swt.dnd;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-/**
- * The <code>TransferData</code> class is a platform specific data structure for
- * describing the type and the contents of data being converted by a transfer agent.
- *
- * <p>As an application writer, you do not need to know the specifics of
- * TransferData. TransferData instances are passed to a subclass of Transfer
- * and the Transfer object manages the platform specific issues.
- * You can ask a Transfer subclass if it can handle this data by calling
- * Transfer.isSupportedType(transferData).</p>
- *
- * <p>You should only need to become familiar with the fields in this class if you
- * are implementing a Transfer subclass and you are unable to subclass the
- * ByteArrayTransfer class.</p>
+ * http://www.eclipse.org/legal/cpl-v10.html
*/
-public class TransferData {
- /**
- * The type is a unique identifier of a system format or user defined format.
- * (Warning: This field is platform dependent)
+
+/**
+ * The <code>TransferData</code> class is a platform specific data structure for
+ * describing the type and the contents of data being converted by a transfer agent.
+ *
+ * <p>As an application writer, you do not need to know the specifics of
+ * TransferData. TransferData instances are passed to a subclass of Transfer
+ * and the Transfer object manages the platform specific issues.
+ * You can ask a Transfer subclass if it can handle this data by calling
+ * Transfer.isSupportedType(transferData).</p>
+ *
+ * <p>You should only need to become familiar with the fields in this class if you
+ * are implementing a Transfer subclass and you are unable to subclass the
+ * ByteArrayTransfer class.</p>
+ */
+public class TransferData {
+ /**
+ * The type is a unique identifier of a system format or user defined format.
+ * (Warning: This field is platform dependent)
+ */
+ public int type;
+
+ /**
+ * Specifies the number of units in pValue.
+ * (Warning: This field is platform dependent)
+ *
+ * @see TransferData#format for the size of one unit
+ */
+ public int length;
+
+ /**
+ * Specifies the size in bits of a single unit in pValue.
+ * (Warning: This field is platform dependent)
+ *
+ * This is most commonly 8 bits.
+ */
+ public int format;
+
+ /**
+ * Pointer to the data being transferred.
+ * (Warning: This field is platform dependent)
*/
- public int type;
-
- /**
- * Specifies the number of units in pValue.
- * (Warning: This field is platform dependent)
- *
- * @see TransferData#format for the size of one unit
- */
- public int length;
-
- /**
- * Specifies the size in bits of a single unit in pValue.
- * (Warning: This field is platform dependent)
- *
- * This is most commonly 8 bits.
- */
- public int format;
-
- /**
- * Pointer to the data being transferred.
- * (Warning: This field is platform dependent)
- */
- public int pValue;
-
- /**
- * The result field contains the result of converting a java data type
- * into a platform specific value.
- * (Warning: This field is platform dependent).
- *
- * <p>The value of result is 1 if the conversion was successfully. The value of
- * result is 0 if the conversion failed.</p>
+ public int pValue;
+
+ /**
+ * The result field contains the result of converting a java data type
+ * into a platform specific value.
+ * (Warning: This field is platform dependent).
+ *
+ * <p>The value of result is 1 if the conversion was successfully. The value of
+ * result is 0 if the conversion failed.</p>
*/
- public int result;
-
-}
+ public 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
index c4fd236893..3b7da8dffd 100755
--- 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
@@ -1,216 +1,216 @@
-package org.eclipse.swt.dnd;
-
-/*
+package org.eclipse.swt.dnd;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-import org.eclipse.swt.graphics.*;
-import org.eclipse.swt.widgets.*;
-import org.eclipse.swt.SWT;
-
-class TreeDragUnderEffect extends DragUnderEffect {
-
- private Tree tree;
- private int currentEffect = DND.FEEDBACK_NONE;
- private TreeItem[] selection = new TreeItem[0];
- private TreeItem dropSelection = null;
- private TreeItem insertMark = null;
- private boolean insertBefore = false;
-
- private TreeItem scrollItem;
- private long scrollBeginTime;
- private static final int SCROLL_HYSTERESIS = 400; // milli seconds
- private static final int SCROLL_WIDTH = 100; // pixels
-
- private TreeItem expandItem;
- private long expandBeginTime;
- private static final int EXPAND_HYSTERESIS = 1000; // milli seconds
-
-TreeDragUnderEffect(Tree tree) {
- this.tree = tree;
-}
-void show(int effect, int x, int y) {
- effect = checkEffect(effect);
- TreeItem item = findItem(x, y);
- if (item == null) effect = DND.FEEDBACK_NONE;
- if (currentEffect == DND.FEEDBACK_NONE && effect != DND.FEEDBACK_NONE) {
- selection = tree.getSelection();
- tree.deselectAll();
- }
- scrollHover(effect, item, x, y);
- expandHover(effect, item, x, y);
- setDragUnderEffect(effect, item);
- if (currentEffect != DND.FEEDBACK_NONE && effect == DND.FEEDBACK_NONE) {
- tree.setSelection(selection);
- selection = new TreeItem[0];
- }
- currentEffect = effect;
-}
-private int checkEffect(int effect) {
- // Some effects are mutually exclusive. Make sure that only one of the mutually exclusive effects has been specified.
- int mask = DND.FEEDBACK_INSERT_AFTER | DND.FEEDBACK_INSERT_BEFORE | DND.FEEDBACK_SELECT;
- int bits = effect & mask;
- if (bits == DND.FEEDBACK_INSERT_AFTER || bits == DND.FEEDBACK_INSERT_BEFORE || bits == DND.FEEDBACK_SELECT) return effect;
- return (effect & ~mask);
-}
-private TreeItem findItem(int x , int y){
- Point coordinates = new Point(x, y);
- coordinates = tree.toControl(coordinates);
- Rectangle area = tree.getClientArea();
- if (!area.contains(coordinates)) return null;
-
- TreeItem item = tree.getItem(coordinates);
- if (item != null) return item;
-
- // Scan across the width of the tree.
- for (int x1 = area.x; x1 < area.x + area.width; x1++) {
- coordinates = new Point(x1, coordinates.y);
- item = tree.getItem(coordinates);
- if (item != null) return item;
- }
- // Check if we are just below the last item of the tree
- coordinates = new Point(x, y);
- coordinates = tree.toControl(coordinates);
- if (coordinates.y > area.y + area.height - tree.getItemHeight()) {;
- int y1 = area.y + area.height - tree.getItemHeight();
- coordinates = new Point(coordinates.x, y1);
-
- item = tree.getItem(coordinates);
- if (item != null) return item;
-
- // Scan across the width of the tree just above the bottom..
- for (int x1 = area.x; x1 < area.x + area.width; x1++) {
- coordinates = new Point(x1, y1);
- item = tree.getItem(coordinates);
- if (item != null) return item;
- }
- }
- return null;
-}
-private void setDragUnderEffect(int effect, TreeItem item) {
- if ((effect & DND.FEEDBACK_SELECT) != 0) {
- if ((currentEffect & DND.FEEDBACK_INSERT_AFTER) != 0 ||
- (currentEffect & DND.FEEDBACK_INSERT_BEFORE) != 0) {
- tree.setInsertMark(null, false);
- }
- setDropSelection(item);
- return;
- }
- if ((effect & DND.FEEDBACK_INSERT_AFTER) != 0 ||
- (effect & DND.FEEDBACK_INSERT_BEFORE) != 0) {
- if ((currentEffect & DND.FEEDBACK_SELECT) != 0) {
- setDropSelection(null);
- }
- setInsertMark(item, (effect & DND.FEEDBACK_INSERT_BEFORE) != 0);
- return;
- }
-
- setInsertMark(null, false);
- setDropSelection(null);
-}
-private void setDropSelection (TreeItem item) {
- if (item == dropSelection) return;
- if (dropSelection != null) tree.deselectAll();
- dropSelection = item;
- if (dropSelection != null) tree.setSelection(new TreeItem[]{dropSelection});
-}
-private void setInsertMark(TreeItem item, boolean before) {
- if (item == insertMark && before == insertBefore) return;
- insertMark = item;
- insertBefore = before;
- tree.setInsertMark(item, before);
-}
-private void scrollHover (int effect, TreeItem item, int x, int y) {
- if ((effect & DND.FEEDBACK_SCROLL) == 0) {
- scrollBeginTime = 0;
- scrollItem = null;
- return;
- }
- if (scrollItem == item && scrollBeginTime != 0) {
- if (System.currentTimeMillis() >= scrollBeginTime) {
- scroll(item, x, y);
- scrollBeginTime = 0;
- scrollItem = null;
- }
- return;
- }
- scrollBeginTime = System.currentTimeMillis() + SCROLL_HYSTERESIS;
- scrollItem = item;
-}
-private void scroll(TreeItem item, int x, int y) {
- if (item == null) return;
- Point coordinates = new Point(x, y);
- coordinates = tree.toControl(coordinates);
- Rectangle area = tree.getClientArea();
- TreeItem showItem = null;
- if (coordinates.y - area.y < SCROLL_WIDTH) {
- showItem = getPreviousVisibleItem(item);
- } else if ((area.y + area.height - coordinates.y) < SCROLL_WIDTH) {
- showItem = getNextVisibleItem(item, true);
- }
- if (showItem != null) {
- tree.showItem(showItem);
- }
-}
-private void expandHover (int effect, TreeItem item, int x, int y) {
- if ((effect & DND.FEEDBACK_EXPAND) == 0) {
- expandBeginTime = 0;
- expandItem = null;
- return;
- }
- if (expandItem == item && expandBeginTime != 0) {
- if (System.currentTimeMillis() >= expandBeginTime) {
- expand(item, x, y);
- expandBeginTime = 0;
- expandItem = null;
- }
- return;
- }
- expandBeginTime = System.currentTimeMillis() + EXPAND_HYSTERESIS;
- expandItem = item;
-}
-private void expand(TreeItem item, int x, int y) {
- if (item == null || item.getExpanded()) return;
- Event event = new Event();
- event.x = x;
- event.y = y;
- event.item = item;
- event.time = (int) System.currentTimeMillis();
- tree.notifyListeners(SWT.Expand, event);
- if (item.isDisposed()) return;
- item.setExpanded(true);
-}
-private TreeItem getNextVisibleItem(TreeItem item, boolean includeChildren) {
- // look down
- // neccesary on the first pass only
- if (includeChildren && item.getItemCount() > 0 && item.getExpanded()) {
- return item.getItems()[0];
- }
- // look sideways
- TreeItem parent = item.getParentItem();
- TreeItem[] peers = (parent != null) ? parent.getItems() : tree.getItems();
- for (int i = 0; i < peers.length - 1; i++) {
- if (peers[i] == item) return peers[i + 1];
- }
- // look up
- if (parent != null) return getNextVisibleItem(parent, false);
- return null;
-}
-private TreeItem getPreviousVisibleItem(TreeItem item) {
- // look sideways
- TreeItem parent = item.getParentItem();
- TreeItem[] peers = (parent != null) ? parent.getItems() : tree.getItems();
- for (int i = peers.length - 1; i > 0; i--) {
- if (peers[i] == item) {
- TreeItem peer = peers[i-1];
- if (!peer.getExpanded() || peer.getItemCount() == 0) return peer;
- TreeItem[] peerItems = peer.getItems();
- return peerItems[peerItems.length - 1];
- }
- }
- // look up
- return parent;
-}
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.widgets.*;
+import org.eclipse.swt.SWT;
+
+class TreeDragUnderEffect extends DragUnderEffect {
+
+ private Tree tree;
+ private int currentEffect = DND.FEEDBACK_NONE;
+ private TreeItem[] selection = new TreeItem[0];
+ private TreeItem dropSelection = null;
+ private TreeItem insertMark = null;
+ private boolean insertBefore = false;
+
+ private TreeItem scrollItem;
+ private long scrollBeginTime;
+ private static final int SCROLL_HYSTERESIS = 400; // milli seconds
+ private static final int SCROLL_WIDTH = 100; // pixels
+
+ private TreeItem expandItem;
+ private long expandBeginTime;
+ private static final int EXPAND_HYSTERESIS = 1000; // milli seconds
+
+TreeDragUnderEffect(Tree tree) {
+ this.tree = tree;
+}
+void show(int effect, int x, int y) {
+ effect = checkEffect(effect);
+ TreeItem item = findItem(x, y);
+ if (item == null) effect = DND.FEEDBACK_NONE;
+ if (currentEffect == DND.FEEDBACK_NONE && effect != DND.FEEDBACK_NONE) {
+ selection = tree.getSelection();
+ tree.deselectAll();
+ }
+ scrollHover(effect, item, x, y);
+ expandHover(effect, item, x, y);
+ setDragUnderEffect(effect, item);
+ if (currentEffect != DND.FEEDBACK_NONE && effect == DND.FEEDBACK_NONE) {
+ tree.setSelection(selection);
+ selection = new TreeItem[0];
+ }
+ currentEffect = effect;
+}
+private int checkEffect(int effect) {
+ // Some effects are mutually exclusive. Make sure that only one of the mutually exclusive effects has been specified.
+ int mask = DND.FEEDBACK_INSERT_AFTER | DND.FEEDBACK_INSERT_BEFORE | DND.FEEDBACK_SELECT;
+ int bits = effect & mask;
+ if (bits == DND.FEEDBACK_INSERT_AFTER || bits == DND.FEEDBACK_INSERT_BEFORE || bits == DND.FEEDBACK_SELECT) return effect;
+ return (effect & ~mask);
+}
+private TreeItem findItem(int x , int y){
+ Point coordinates = new Point(x, y);
+ coordinates = tree.toControl(coordinates);
+ Rectangle area = tree.getClientArea();
+ if (!area.contains(coordinates)) return null;
+
+ TreeItem item = tree.getItem(coordinates);
+ if (item != null) return item;
+
+ // Scan across the width of the tree.
+ for (int x1 = area.x; x1 < area.x + area.width; x1++) {
+ coordinates = new Point(x1, coordinates.y);
+ item = tree.getItem(coordinates);
+ if (item != null) return item;
+ }
+ // Check if we are just below the last item of the tree
+ coordinates = new Point(x, y);
+ coordinates = tree.toControl(coordinates);
+ if (coordinates.y > area.y + area.height - tree.getItemHeight()) {;
+ int y1 = area.y + area.height - tree.getItemHeight();
+ coordinates = new Point(coordinates.x, y1);
+
+ item = tree.getItem(coordinates);
+ if (item != null) return item;
+
+ // Scan across the width of the tree just above the bottom..
+ for (int x1 = area.x; x1 < area.x + area.width; x1++) {
+ coordinates = new Point(x1, y1);
+ item = tree.getItem(coordinates);
+ if (item != null) return item;
+ }
+ }
+ return null;
+}
+private void setDragUnderEffect(int effect, TreeItem item) {
+ if ((effect & DND.FEEDBACK_SELECT) != 0) {
+ if ((currentEffect & DND.FEEDBACK_INSERT_AFTER) != 0 ||
+ (currentEffect & DND.FEEDBACK_INSERT_BEFORE) != 0) {
+ tree.setInsertMark(null, false);
+ }
+ setDropSelection(item);
+ return;
+ }
+ if ((effect & DND.FEEDBACK_INSERT_AFTER) != 0 ||
+ (effect & DND.FEEDBACK_INSERT_BEFORE) != 0) {
+ if ((currentEffect & DND.FEEDBACK_SELECT) != 0) {
+ setDropSelection(null);
+ }
+ setInsertMark(item, (effect & DND.FEEDBACK_INSERT_BEFORE) != 0);
+ return;
+ }
+
+ setInsertMark(null, false);
+ setDropSelection(null);
+}
+private void setDropSelection (TreeItem item) {
+ if (item == dropSelection) return;
+ if (dropSelection != null) tree.deselectAll();
+ dropSelection = item;
+ if (dropSelection != null) tree.setSelection(new TreeItem[]{dropSelection});
+}
+private void setInsertMark(TreeItem item, boolean before) {
+ if (item == insertMark && before == insertBefore) return;
+ insertMark = item;
+ insertBefore = before;
+ tree.setInsertMark(item, before);
+}
+private void scrollHover (int effect, TreeItem item, int x, int y) {
+ if ((effect & DND.FEEDBACK_SCROLL) == 0) {
+ scrollBeginTime = 0;
+ scrollItem = null;
+ return;
+ }
+ if (scrollItem == item && scrollBeginTime != 0) {
+ if (System.currentTimeMillis() >= scrollBeginTime) {
+ scroll(item, x, y);
+ scrollBeginTime = 0;
+ scrollItem = null;
+ }
+ return;
+ }
+ scrollBeginTime = System.currentTimeMillis() + SCROLL_HYSTERESIS;
+ scrollItem = item;
+}
+private void scroll(TreeItem item, int x, int y) {
+ if (item == null) return;
+ Point coordinates = new Point(x, y);
+ coordinates = tree.toControl(coordinates);
+ Rectangle area = tree.getClientArea();
+ TreeItem showItem = null;
+ if (coordinates.y - area.y < SCROLL_WIDTH) {
+ showItem = getPreviousVisibleItem(item);
+ } else if ((area.y + area.height - coordinates.y) < SCROLL_WIDTH) {
+ showItem = getNextVisibleItem(item, true);
+ }
+ if (showItem != null) {
+ tree.showItem(showItem);
+ }
+}
+private void expandHover (int effect, TreeItem item, int x, int y) {
+ if ((effect & DND.FEEDBACK_EXPAND) == 0) {
+ expandBeginTime = 0;
+ expandItem = null;
+ return;
+ }
+ if (expandItem == item && expandBeginTime != 0) {
+ if (System.currentTimeMillis() >= expandBeginTime) {
+ expand(item, x, y);
+ expandBeginTime = 0;
+ expandItem = null;
+ }
+ return;
+ }
+ expandBeginTime = System.currentTimeMillis() + EXPAND_HYSTERESIS;
+ expandItem = item;
+}
+private void expand(TreeItem item, int x, int y) {
+ if (item == null || item.getExpanded()) return;
+ Event event = new Event();
+ event.x = x;
+ event.y = y;
+ event.item = item;
+ event.time = (int) System.currentTimeMillis();
+ tree.notifyListeners(SWT.Expand, event);
+ if (item.isDisposed()) return;
+ item.setExpanded(true);
+}
+private TreeItem getNextVisibleItem(TreeItem item, boolean includeChildren) {
+ // look down
+ // neccesary on the first pass only
+ if (includeChildren && item.getItemCount() > 0 && item.getExpanded()) {
+ return item.getItems()[0];
+ }
+ // look sideways
+ TreeItem parent = item.getParentItem();
+ TreeItem[] peers = (parent != null) ? parent.getItems() : tree.getItems();
+ for (int i = 0; i < peers.length - 1; i++) {
+ if (peers[i] == item) return peers[i + 1];
+ }
+ // look up
+ if (parent != null) return getNextVisibleItem(parent, false);
+ return null;
+}
+private TreeItem getPreviousVisibleItem(TreeItem item) {
+ // look sideways
+ TreeItem parent = item.getParentItem();
+ TreeItem[] peers = (parent != null) ? parent.getItems() : tree.getItems();
+ for (int i = peers.length - 1; i > 0; i--) {
+ if (peers[i] == item) {
+ TreeItem peer = peers[i-1];
+ if (!peer.getExpanded() || peer.getItemCount() == 0) return peer;
+ TreeItem[] peerItems = peer.getItems();
+ return peerItems[peerItems.length - 1];
+ }
+ }
+ // look up
+ return parent;
+}
+}
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
index 9ef271c1e0..5b987c1e2e 100755
--- 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
@@ -1,180 +1,180 @@
-package org.eclipse.swt.dnd;
-
-/*
+package org.eclipse.swt.dnd;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-import org.eclipse.swt.internal.photon.*;
-
-/**
- * The class <code>ByteArrayTransfer</code> provides a platform specific
- * mechanism for converting a java <code>byte[]</code> to a platform
- * specific representation of the byte array and vice versa. See
- * <code>Transfer</code> for additional information.
- *
- * <p><code>ByteArrayTransfer</code> is never used directly but is sub-classed
- * by transfer agents that convert between data in a java format such as a
- * <code>String</code> and a platform specific byte array.
- *
- * <p>If the data you are converting <b>does not</b> map to a
- * <code>byte[]</code>, you should sub-class <code>Transfer</code> directly
- * and do your own mapping to a platform data type.</p>
- *
- * <p>The following snippet shows a sublcass of ByteArrayTransfer that transfers
- * data defined by the class <code>MyType</code>.</p>
- *
- * <pre><code>
- * public class MyType {
- * public String fileName;
- * public long fileLength;
- * public long lastModified;
- * }
- * </code></pre>
- *
- * <code><pre>
- * public class MyTypeTransfer extends ByteArrayTransfer {
- *
- * private static final String MYTYPENAME = "my_type_name";
- * private static final int MYTYPEID = registerType(MYTYPENAME);
- * private static MyTypeTransfer _instance = new MyTypeTransfer();
- *
- * private MyTypeTransfer() {}
- *
- * public static MyTypeTransfer getInstance () {
- * return _instance;
- * }
- * public void javaToNative (Object object, TransferData transferData) {
- * if (object == null || !(object instanceof MyType[])) return;
- *
- * if (isSupportedType(transferData)) {
- * MyType[] myTypes = (MyType[]) object;
- * try {
- * // write data to a byte array and then ask super to convert to pMedium
- * ByteArrayOutputStream out = new ByteArrayOutputStream();
- * DataOutputStream writeOut = new DataOutputStream(out);
- * for (int i = 0, length = myTypes.length; i < length; i++){
- * byte[] buffer = myTypes[i].fileName.getBytes();
- * writeOut.writeInt(buffer.length);
- * writeOut.write(buffer);
- * writeOut.writeLong(myTypes[i].fileLength);
- * writeOut.writeLong(myTypes[i].lastModified);
- * }
- * byte[] buffer = out.toByteArray();
- * writeOut.close();
- *
- * super.javaToNative(buffer, transferData);
- *
- * } catch (IOException e) {
- * }
- * }
- * }
- * public Object nativeToJava(TransferData transferData){
- *
- * if (isSupportedType(transferData)) {
- *
- * byte[] buffer = (byte[])super.nativeToJava(transferData);
- * if (buffer == null) return null;
- *
- * MyType[] myData = new MyType[0];
- * try {
- * ByteArrayInputStream in = new ByteArrayInputStream(buffer);
- * DataInputStream readIn = new DataInputStream(in);
- * while(readIn.available() > 20) {
- * MyType datum = new MyType();
- * int size = readIn.readInt();
- * byte[] name = new byte[size];
- * readIn.read(name);
- * datum.fileName = new String(name);
- * datum.fileLength = readIn.readLong();
- * datum.lastModified = readIn.readLong();
- * MyType[] newMyData = new MyType[myData.length + 1];
- * System.arraycopy(myData, 0, newMyData, 0, myData.length);
- * newMyData[myData.length] = datum;
- * myData = newMyData;
- * }
- * readIn.close();
- * } catch (IOException ex) {
- * return null;
- * }
- * return myData;
- * }
- *
- * return null;
- * }
- * protected String[] getTypeNames(){
- * return new String[]{MYTYPENAME};
- * }
- * protected int[] getTypeIds(){
- * return new int[] {MYTYPEID};
- * }
- * }
+ * http://www.eclipse.org/legal/cpl-v10.html
*/
-public abstract class ByteArrayTransfer extends Transfer {
-
-public TransferData[] getSupportedTypes(){
- int[] types = getTypeIds();
- TransferData[] data = new TransferData[types.length];
- for (int i = 0; i < types.length; i++) {
- data[i] = new TransferData();
- data[i].type = types[i];
- }
- return data;
-}
-public boolean isSupportedType(TransferData transferData){
- if (transferData == null) return false;
- int[] types = getTypeIds();
- for (int i = 0; i < types.length; i++) {
- if (transferData.type == types[i]) return true;
- }
- return false;
-}
-
-/**
- * This implementation of <code>javaToNative</code> converts a java
- * <code>byte[]</code> to a platform specific representation. For additional
- * information see <code>Transfer#javaToNative</code>.
- *
- * @see Transfer#javaToNative
- *
- * @param object a java <code>byte[]</code> containing the data to be converted
- * @param transferData an empty <code>TransferData</code> object; this
- * object will be filled in on return with the platform specific format of the data
- */
-protected void javaToNative (Object object, TransferData transferData){
- if ((object == null) || !(object instanceof byte[]) || !(isSupportedType(transferData))) {
- transferData.result = 0;
- return;
- }
- byte[] buffer = (byte[])object;
- transferData.pData = OS.malloc(buffer.length);
- OS.memmove(transferData.pData, buffer, buffer.length);
- transferData.length = buffer.length;
- transferData.result = 1;
-}
-
-/**
- * This implementation of <code>nativeToJava</code> converts a platform specific
- * representation of a byte array to a java <code>byte[]</code>.
- * For additional information see <code>Transfer#nativeToJava</code>.
- *
- * @see Transfer#nativeToJava
- *
- * @param transferData the platform specific representation of the data to be
- * been converted
- * @return a java <code>byte[]</code> containing the converted data if the
- * conversion was successful; otherwise null
- */
-protected Object nativeToJava(TransferData transferData){
-
- if (transferData.pData == 0 || !(isSupportedType(transferData))) return null;
-
- int size = transferData.length;
- if (size == 0) return null;
- byte[] buffer = new byte[size];
- OS.memmove(buffer, transferData.pData, size);
- return buffer;
-}
-}
+
+import org.eclipse.swt.internal.photon.*;
+
+/**
+ * The class <code>ByteArrayTransfer</code> provides a platform specific
+ * mechanism for converting a java <code>byte[]</code> to a platform
+ * specific representation of the byte array and vice versa. See
+ * <code>Transfer</code> for additional information.
+ *
+ * <p><code>ByteArrayTransfer</code> is never used directly but is sub-classed
+ * by transfer agents that convert between data in a java format such as a
+ * <code>String</code> and a platform specific byte array.
+ *
+ * <p>If the data you are converting <b>does not</b> map to a
+ * <code>byte[]</code>, you should sub-class <code>Transfer</code> directly
+ * and do your own mapping to a platform data type.</p>
+ *
+ * <p>The following snippet shows a sublcass of ByteArrayTransfer that transfers
+ * data defined by the class <code>MyType</code>.</p>
+ *
+ * <pre><code>
+ * public class MyType {
+ * public String fileName;
+ * public long fileLength;
+ * public long lastModified;
+ * }
+ * </code></pre>
+ *
+ * <code><pre>
+ * public class MyTypeTransfer extends ByteArrayTransfer {
+ *
+ * private static final String MYTYPENAME = "my_type_name";
+ * private static final int MYTYPEID = registerType(MYTYPENAME);
+ * private static MyTypeTransfer _instance = new MyTypeTransfer();
+ *
+ * private MyTypeTransfer() {}
+ *
+ * public static MyTypeTransfer getInstance () {
+ * return _instance;
+ * }
+ * public void javaToNative (Object object, TransferData transferData) {
+ * if (object == null || !(object instanceof MyType[])) return;
+ *
+ * if (isSupportedType(transferData)) {
+ * MyType[] myTypes = (MyType[]) object;
+ * try {
+ * // write data to a byte array and then ask super to convert to pMedium
+ * ByteArrayOutputStream out = new ByteArrayOutputStream();
+ * DataOutputStream writeOut = new DataOutputStream(out);
+ * for (int i = 0, length = myTypes.length; i < length; i++){
+ * byte[] buffer = myTypes[i].fileName.getBytes();
+ * writeOut.writeInt(buffer.length);
+ * writeOut.write(buffer);
+ * writeOut.writeLong(myTypes[i].fileLength);
+ * writeOut.writeLong(myTypes[i].lastModified);
+ * }
+ * byte[] buffer = out.toByteArray();
+ * writeOut.close();
+ *
+ * super.javaToNative(buffer, transferData);
+ *
+ * } catch (IOException e) {
+ * }
+ * }
+ * }
+ * public Object nativeToJava(TransferData transferData){
+ *
+ * if (isSupportedType(transferData)) {
+ *
+ * byte[] buffer = (byte[])super.nativeToJava(transferData);
+ * if (buffer == null) return null;
+ *
+ * MyType[] myData = new MyType[0];
+ * try {
+ * ByteArrayInputStream in = new ByteArrayInputStream(buffer);
+ * DataInputStream readIn = new DataInputStream(in);
+ * while(readIn.available() > 20) {
+ * MyType datum = new MyType();
+ * int size = readIn.readInt();
+ * byte[] name = new byte[size];
+ * readIn.read(name);
+ * datum.fileName = new String(name);
+ * datum.fileLength = readIn.readLong();
+ * datum.lastModified = readIn.readLong();
+ * MyType[] newMyData = new MyType[myData.length + 1];
+ * System.arraycopy(myData, 0, newMyData, 0, myData.length);
+ * newMyData[myData.length] = datum;
+ * myData = newMyData;
+ * }
+ * readIn.close();
+ * } catch (IOException ex) {
+ * return null;
+ * }
+ * return myData;
+ * }
+ *
+ * return null;
+ * }
+ * protected String[] getTypeNames(){
+ * return new String[]{MYTYPENAME};
+ * }
+ * protected int[] getTypeIds(){
+ * return new int[] {MYTYPEID};
+ * }
+ * }
+ */
+public abstract class ByteArrayTransfer extends Transfer {
+
+public TransferData[] getSupportedTypes(){
+ int[] types = getTypeIds();
+ TransferData[] data = new TransferData[types.length];
+ for (int i = 0; i < types.length; i++) {
+ data[i] = new TransferData();
+ data[i].type = types[i];
+ }
+ return data;
+}
+public boolean isSupportedType(TransferData transferData){
+ if (transferData == null) return false;
+ int[] types = getTypeIds();
+ for (int i = 0; i < types.length; i++) {
+ if (transferData.type == types[i]) return true;
+ }
+ return false;
+}
+
+/**
+ * This implementation of <code>javaToNative</code> converts a java
+ * <code>byte[]</code> to a platform specific representation. For additional
+ * information see <code>Transfer#javaToNative</code>.
+ *
+ * @see Transfer#javaToNative
+ *
+ * @param object a java <code>byte[]</code> containing the data to be converted
+ * @param transferData an empty <code>TransferData</code> object; this
+ * object will be filled in on return with the platform specific format of the data
+ */
+protected void javaToNative (Object object, TransferData transferData){
+ if ((object == null) || !(object instanceof byte[]) || !(isSupportedType(transferData))) {
+ transferData.result = 0;
+ return;
+ }
+ byte[] buffer = (byte[])object;
+ transferData.pData = OS.malloc(buffer.length);
+ OS.memmove(transferData.pData, buffer, buffer.length);
+ transferData.length = buffer.length;
+ transferData.result = 1;
+}
+
+/**
+ * This implementation of <code>nativeToJava</code> converts a platform specific
+ * representation of a byte array to a java <code>byte[]</code>.
+ * For additional information see <code>Transfer#nativeToJava</code>.
+ *
+ * @see Transfer#nativeToJava
+ *
+ * @param transferData the platform specific representation of the data to be
+ * been converted
+ * @return a java <code>byte[]</code> containing the converted data if the
+ * conversion was successful; otherwise null
+ */
+protected Object nativeToJava(TransferData transferData){
+
+ if (transferData.pData == 0 || !(isSupportedType(transferData))) return null;
+
+ int size = transferData.length;
+ if (size == 0) return null;
+ byte[] buffer = new byte[size];
+ OS.memmove(buffer, transferData.pData, 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
index b12651cef7..3e53e1de5e 100755
--- 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
@@ -1,291 +1,291 @@
-package org.eclipse.swt.dnd;
-
-/*
+package org.eclipse.swt.dnd;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-import org.eclipse.swt.*;
-import org.eclipse.swt.internal.*;
-import org.eclipse.swt.internal.photon.*;
-import org.eclipse.swt.widgets.*;
-
-/**
- * The <code>Clipboard</code> provides a mechanism for transferring data from one
- * application to another or within an application.
- *
- * <p>IMPORTANT: This class is <em>not</em> intended to be subclassed.</p>
+ * http://www.eclipse.org/legal/cpl-v10.html
*/
-public class Clipboard {
-
- private Display display;
- private final int MAX_RETRIES = 10;
-
-
-/**
- * Constructs a new instance of this class. Creating an instance of a Clipboard
- * may cause system resources to be allocated depending on the platform. It is therefore
- * mandatory that the Clipboard instance be disposed when no longer required.
- *
- * @param display the display on which to allocate the clipboard
- *
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
- * <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
- * </ul>
- *
- * @see Clipboard#dispose
- * @see Clipboard#checkSubclass
- */
-public Clipboard(Display display) {
- checkSubclass ();
- if (display == null) {
- display = Display.getCurrent();
- if (display == null) {
- display = Display.getDefault();
- }
- }
- if (display.getThread() != Thread.currentThread()) {
- SWT.error(SWT.ERROR_THREAD_INVALID_ACCESS);
- }
- this.display = display;
-}
-
-/**
- * Checks that this class can be subclassed.
- * <p>
- * The SWT class library is intended to be subclassed
- * only at specific, controlled points. This method enforces this
- * rule unless it is overridden.
- * </p><p>
- * <em>IMPORTANT:</em> By providing an implementation of this
- * method that allows a subclass of a class which does not
- * normally allow subclassing to be created, the implementer
- * agrees to be fully responsible for the fact that any such
- * subclass will likely fail between SWT releases and will be
- * strongly platform specific. No support is provided for
- * user-written classes which are implemented in this fashion.
- * </p><p>
- * The ability to subclass outside of the allowed SWT classes
- * is intended purely to enable those not on the SWT development
- * team to implement patches in order to get around specific
- * limitations in advance of when those limitations can be
- * addressed by the team. Subclassing should not be attempted
- * without an intimate and detailed understanding of the hierarchy.
- * </p>
- *
- * @exception SWTException <ul>
- * <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
- * </ul>
- */
-protected void checkSubclass () {
- String name = getClass().getName ();
- String validName = Clipboard.class.getName();
- if (!validName.equals(name)) {
- DND.error (SWT.ERROR_INVALID_SUBCLASS);
- }
-}
-/**
- * Disposes of the operating system resources associated with the clipboard.
- * The data will still be available on the system clipboard after the dispose
- * method is called.
- *
- * <p>NOTE: On some platforms the data will not be available once the application
- * has exited or the display has been disposed.</p>
+
+import org.eclipse.swt.*;
+import org.eclipse.swt.internal.*;
+import org.eclipse.swt.internal.photon.*;
+import org.eclipse.swt.widgets.*;
+
+/**
+ * The <code>Clipboard</code> provides a mechanism for transferring data from one
+ * application to another or within an application.
+ *
+ * <p>IMPORTANT: This class is <em>not</em> intended to be subclassed.</p>
*/
-public void dispose () {
- display = null;
-}
-/**
- * Retrieve the data of the specified type currently available on the system clipboard. Refer to the
- * specific subclass of <code>Tramsfer</code> to determine the type of object returned.
- *
- * <p>The following snippet shows text and RTF text being retrieved from the clipboard:</p>
- *
- * <code><pre>
- * Clipboard clipboard = new Clipboard(display);
- * TextTransfer textTransfer = TextTransfer.getInstance();
- * String textData = (String)clipboard.getContents(textTransfer);
- * if (textData != null) System.out.println("Text is "+textData);
- * RTFTransfer rtfTransfer = RTFTransfer.getInstance();
- * String rtfData = (String)clipboard.getContents(rtfTransfer);
- * if (rtfData != null) System.out.println("RTF Text is "+rtfData);
- * clipboard.dispose();
- * </code></pre>
- *
- * @see Transfer
- *
- * @param transfer the transfer agent for the type of data being requested
- *
- * @return the data obtained from the clipboard or null if no data of this type is available
+public class Clipboard {
+
+ private Display display;
+ private final int MAX_RETRIES = 10;
+
+
+/**
+ * Constructs a new instance of this class. Creating an instance of a Clipboard
+ * may cause system resources to be allocated depending on the platform. It is therefore
+ * mandatory that the Clipboard instance be disposed when no longer required.
+ *
+ * @param display the display on which to allocate the clipboard
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
+ * <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
+ * </ul>
+ *
+ * @see Clipboard#dispose
+ * @see Clipboard#checkSubclass
*/
-public Object getContents(Transfer transfer) {
- if (display.isDisposed() ) return null;
-
- Object result = null;
-
- int ig = OS.PhInputGroup(0);
- int cbdata = OS.PhClipboardPasteStart((short)ig);
- if (cbdata == 0) return result;
- try {
- String[] names = transfer.getTypeNames();
- int[] ids = transfer.getTypeIds();
- for (int i = 0; i < names.length; i++) {
- byte[] name = Converter.wcsToMbcs(null, names[i], true);
- name [Math.min(8, name.length) - 1] = (byte)0;
- int pClipHeader = OS.PhClipboardPasteType(cbdata, name);
- if (pClipHeader != 0) {
- PhClipHeader clipHeader = new PhClipHeader();
- OS.memmove(clipHeader, pClipHeader, PhClipHeader.sizeof);
- TransferData data = new TransferData();
- data.pData = clipHeader.data;
- data.length = clipHeader.length;
- data.type = ids[i];
- result = transfer.nativeToJava(data);
- break;
- }
- }
- } finally {
- OS.PhClipboardPasteFinish(cbdata);
- }
-
- return result;
-}
-/**
- * Place data of the specified type on the system clipboard. More than one type of
- * data can be placed on the system clipboard at the same time. Setting the data
- * clears any previous data of the same type from the system clipboard and also
- * clears data of any other type currently on the system clipboard.
- *
- * <p>NOTE: On some platforms, the data is immediately copied to the system
- * clipboard but on other platforms it is provided upon request. As a result, if the
- * application modifes the data object it has set on the clipboard, that modification
- * may or may not be available when the data is subsequently requested.</p>
- *
- * <p>The following snippet shows text and RTF text being set on the clipboard:</p>
- *
- * <code><pre>
- * Clipboard clipboard = new Clipboard(display);
- * String textData = "Hello World";
- * String rtfData = "{\\rtf1\\b\\i Hello World}";
- * TextTransfer textTransfer = TextTransfer.getInstance();
- * RTFTransfer rtfTransfer = RTFTransfer.getInstance();
- * clipboard.setContents(new Object[]{textData, rtfData}, new Transfer[]{textTransfer, rtfTransfer});
- * clipboard.dispose();
- * </code></pre>
- *
- * @param data the data to be set in the clipboard
- * @param dataTypes the transfer agents that will convert the data to its platform
- * specific format; each entry in the data array must have a corresponding dataType
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if data is null or datatypes is null
- * or the length of data is not the same as the length of dataTypes</li>
- * </ul>
- * @exception SWTError <ul>
- * <li>ERROR_CANNOT_SET_CLIPBOARD - if the clipboard is locked or
- * otherwise unavailable</li>
- * </ul>
+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;
+}
+
+/**
+ * Checks that this class can be subclassed.
+ * <p>
+ * The SWT class library is intended to be subclassed
+ * only at specific, controlled points. This method enforces this
+ * rule unless it is overridden.
+ * </p><p>
+ * <em>IMPORTANT:</em> By providing an implementation of this
+ * method that allows a subclass of a class which does not
+ * normally allow subclassing to be created, the implementer
+ * agrees to be fully responsible for the fact that any such
+ * subclass will likely fail between SWT releases and will be
+ * strongly platform specific. No support is provided for
+ * user-written classes which are implemented in this fashion.
+ * </p><p>
+ * The ability to subclass outside of the allowed SWT classes
+ * is intended purely to enable those not on the SWT development
+ * team to implement patches in order to get around specific
+ * limitations in advance of when those limitations can be
+ * addressed by the team. Subclassing should not be attempted
+ * without an intimate and detailed understanding of the hierarchy.
+ * </p>
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
+ * </ul>
+ */
+protected void checkSubclass () {
+ String name = getClass().getName ();
+ String validName = Clipboard.class.getName();
+ if (!validName.equals(name)) {
+ DND.error (SWT.ERROR_INVALID_SUBCLASS);
+ }
+}
+/**
+ * Disposes of the operating system resources associated with the clipboard.
+ * The data will still be available on the system clipboard after the dispose
+ * method is called.
+ *
+ * <p>NOTE: On some platforms the data will not be available once the application
+ * has exited or the display has been disposed.</p>
+ */
+public void dispose () {
+ display = null;
+}
+/**
+ * Retrieve the data of the specified type currently available on the system clipboard. Refer to the
+ * specific subclass of <code>Tramsfer</code> to determine the type of object returned.
+ *
+ * <p>The following snippet shows text and RTF text being retrieved from the clipboard:</p>
+ *
+ * <code><pre>
+ * Clipboard clipboard = new Clipboard(display);
+ * TextTransfer textTransfer = TextTransfer.getInstance();
+ * String textData = (String)clipboard.getContents(textTransfer);
+ * if (textData != null) System.out.println("Text is "+textData);
+ * RTFTransfer rtfTransfer = RTFTransfer.getInstance();
+ * String rtfData = (String)clipboard.getContents(rtfTransfer);
+ * if (rtfData != null) System.out.println("RTF Text is "+rtfData);
+ * clipboard.dispose();
+ * </code></pre>
+ *
+ * @see Transfer
+ *
+ * @param transfer the transfer agent for the type of data being requested
+ *
+ * @return the data obtained from the clipboard or null if no data of this type is available
*/
-public void setContents(Object[] data, Transfer[] transferAgents){
- if (display.isDisposed() ) return;
-
- if (data == null || transferAgents == null || data.length != transferAgents.length) {
- DND.error(SWT.ERROR_INVALID_ARGUMENT);
- }
-
- PhClipHeader[] clips = new PhClipHeader[0];
- int count = 0;
- for (int i = 0; i < transferAgents.length; i++) {
- String[] names = transferAgents[i].getTypeNames();
- int[] ids = transferAgents[i].getTypeIds();
- for (int j = 0; j < names.length; j++) {
- TransferData transferData = new TransferData();
- transferData.type = ids[j];
- transferAgents[i].javaToNative(data[i], transferData);
- PhClipHeader clip = new PhClipHeader();
- clip.data = transferData.pData;
- clip.length = (short)transferData.length;
- byte[] temp = Converter.wcsToMbcs(null, names[j], false);
- byte[] type = new byte[8];
- System.arraycopy(temp, 0, type, 0, Math.min(type.length - 1, temp.length));
- clip.type_0 = type[0];
- clip.type_1 = type[1];
- clip.type_2 = type[2];
- clip.type_3 = type[3];
- clip.type_4 = type[4];
- clip.type_5 = type[5];
- clip.type_6 = type[6];
- clip.type_7 = type[7];
- PhClipHeader[] newClips = new PhClipHeader[count + 1];
- System.arraycopy(clips, 0, newClips, 0, clips.length);
- clips = newClips;
- clips[count++] = clip;
- }
- }
-
- if (count == 0) return;
-
- // Copy data to clipboard
- byte[] buffer = new byte[count * PhClipHeader.sizeof];
- byte[] temp = new byte[PhClipHeader.sizeof];
- for (int i = 0; i < count; i++) {
- OS.memmove(temp, clips[i], PhClipHeader.sizeof);
- System.arraycopy(temp, 0, buffer, i * PhClipHeader.sizeof, temp.length);
- }
- int ig = OS.PhInputGroup(0);
- if (OS.PhClipboardCopy((short)ig, count, buffer) != 0) {
- DND.error(DND.ERROR_CANNOT_SET_CLIPBOARD);
- }
-
- // Free allocated data
- for (int i = 0; i < count; i++) {
- OS.free(clips[i].data);
- }
-}
-/**
- * Returns a platform specific list of the data types currently available on the
- * system clipboard.
- *
- * <p>Note: <code>getAvailableTypeNames</code> is a utility for writing a Transfer
- * sub-class. It should NOT be used within an application because it provides
- * platform specific information.</p>
- *
- * @returns a platform specific list of the data types currently available on the
- * system clipboard
- */
-public String[] getAvailableTypeNames() {
- String[] types = new String[0];
- int ig = OS.PhInputGroup(0);
- int cbdata = OS.PhClipboardPasteStart((short)ig);
- if (cbdata == 0) return types;
- try {
- int pClipHeader = 0;
- int n = 0;
- while ((pClipHeader = OS.PhClipboardPasteTypeN(cbdata, n++)) != 0) {
- PhClipHeader clipHeader = new PhClipHeader();
- OS.memmove(clipHeader, pClipHeader, PhClipHeader.sizeof);
- byte[] buffer = new byte[8];
- buffer[0] = clipHeader.type_0;
- buffer[1] = clipHeader.type_1;
- buffer[2] = clipHeader.type_2;
- buffer[3] = clipHeader.type_3;
- buffer[4] = clipHeader.type_4;
- buffer[5] = clipHeader.type_5;
- buffer[6] = clipHeader.type_6;
- buffer[7] = clipHeader.type_7;
- char [] unicode = Converter.mbcsToWcs (null, buffer);
-
- String[] newTypes = new String[types.length + 1];
- System.arraycopy(types, 0, newTypes, 0, types.length);
- newTypes[types.length] = new String (unicode).trim();
- types = newTypes;
- }
- } finally {
- OS.PhClipboardPasteFinish(cbdata);
- }
- return types;
-}
+public Object getContents(Transfer transfer) {
+ if (display.isDisposed() ) return null;
+
+ Object result = null;
+
+ int ig = OS.PhInputGroup(0);
+ int cbdata = OS.PhClipboardPasteStart((short)ig);
+ if (cbdata == 0) return result;
+ try {
+ String[] names = transfer.getTypeNames();
+ int[] ids = transfer.getTypeIds();
+ for (int i = 0; i < names.length; i++) {
+ byte[] name = Converter.wcsToMbcs(null, names[i], true);
+ name [Math.min(8, name.length) - 1] = (byte)0;
+ int pClipHeader = OS.PhClipboardPasteType(cbdata, name);
+ if (pClipHeader != 0) {
+ PhClipHeader clipHeader = new PhClipHeader();
+ OS.memmove(clipHeader, pClipHeader, PhClipHeader.sizeof);
+ TransferData data = new TransferData();
+ data.pData = clipHeader.data;
+ data.length = clipHeader.length;
+ data.type = ids[i];
+ result = transfer.nativeToJava(data);
+ break;
+ }
+ }
+ } finally {
+ OS.PhClipboardPasteFinish(cbdata);
+ }
+
+ return result;
+}
+/**
+ * Place data of the specified type on the system clipboard. More than one type of
+ * data can be placed on the system clipboard at the same time. Setting the data
+ * clears any previous data of the same type from the system clipboard and also
+ * clears data of any other type currently on the system clipboard.
+ *
+ * <p>NOTE: On some platforms, the data is immediately copied to the system
+ * clipboard but on other platforms it is provided upon request. As a result, if the
+ * application modifes the data object it has set on the clipboard, that modification
+ * may or may not be available when the data is subsequently requested.</p>
+ *
+ * <p>The following snippet shows text and RTF text being set on the clipboard:</p>
+ *
+ * <code><pre>
+ * Clipboard clipboard = new Clipboard(display);
+ * String textData = "Hello World";
+ * String rtfData = "{\\rtf1\\b\\i Hello World}";
+ * TextTransfer textTransfer = TextTransfer.getInstance();
+ * RTFTransfer rtfTransfer = RTFTransfer.getInstance();
+ * clipboard.setContents(new Object[]{textData, rtfData}, new Transfer[]{textTransfer, rtfTransfer});
+ * clipboard.dispose();
+ * </code></pre>
+ *
+ * @param data the data to be set in the clipboard
+ * @param dataTypes the transfer agents that will convert the data to its platform
+ * specific format; each entry in the data array must have a corresponding dataType
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if data is null or datatypes is null
+ * or the length of data is not the same as the length of dataTypes</li>
+ * </ul>
+ * @exception SWTError <ul>
+ * <li>ERROR_CANNOT_SET_CLIPBOARD - if the clipboard is locked or
+ * otherwise unavailable</li>
+ * </ul>
+ */
+public void setContents(Object[] data, Transfer[] transferAgents){
+ if (display.isDisposed() ) return;
+
+ if (data == null || transferAgents == null || data.length != transferAgents.length) {
+ DND.error(SWT.ERROR_INVALID_ARGUMENT);
+ }
+
+ PhClipHeader[] clips = new PhClipHeader[0];
+ int count = 0;
+ for (int i = 0; i < transferAgents.length; i++) {
+ String[] names = transferAgents[i].getTypeNames();
+ int[] ids = transferAgents[i].getTypeIds();
+ for (int j = 0; j < names.length; j++) {
+ TransferData transferData = new TransferData();
+ transferData.type = ids[j];
+ transferAgents[i].javaToNative(data[i], transferData);
+ PhClipHeader clip = new PhClipHeader();
+ clip.data = transferData.pData;
+ clip.length = (short)transferData.length;
+ byte[] temp = Converter.wcsToMbcs(null, names[j], false);
+ byte[] type = new byte[8];
+ System.arraycopy(temp, 0, type, 0, Math.min(type.length - 1, temp.length));
+ clip.type_0 = type[0];
+ clip.type_1 = type[1];
+ clip.type_2 = type[2];
+ clip.type_3 = type[3];
+ clip.type_4 = type[4];
+ clip.type_5 = type[5];
+ clip.type_6 = type[6];
+ clip.type_7 = type[7];
+ PhClipHeader[] newClips = new PhClipHeader[count + 1];
+ System.arraycopy(clips, 0, newClips, 0, clips.length);
+ clips = newClips;
+ clips[count++] = clip;
+ }
+ }
+
+ if (count == 0) return;
+
+ // Copy data to clipboard
+ byte[] buffer = new byte[count * PhClipHeader.sizeof];
+ byte[] temp = new byte[PhClipHeader.sizeof];
+ for (int i = 0; i < count; i++) {
+ OS.memmove(temp, clips[i], PhClipHeader.sizeof);
+ System.arraycopy(temp, 0, buffer, i * PhClipHeader.sizeof, temp.length);
+ }
+ int ig = OS.PhInputGroup(0);
+ if (OS.PhClipboardCopy((short)ig, count, buffer) != 0) {
+ DND.error(DND.ERROR_CANNOT_SET_CLIPBOARD);
+ }
+
+ // Free allocated data
+ for (int i = 0; i < count; i++) {
+ OS.free(clips[i].data);
+ }
+}
+/**
+ * Returns a platform specific list of the data types currently available on the
+ * system clipboard.
+ *
+ * <p>Note: <code>getAvailableTypeNames</code> is a utility for writing a Transfer
+ * sub-class. It should NOT be used within an application because it provides
+ * platform specific information.</p>
+ *
+ * @returns a platform specific list of the data types currently available on the
+ * system clipboard
+ */
+public String[] getAvailableTypeNames() {
+ String[] types = new String[0];
+ int ig = OS.PhInputGroup(0);
+ int cbdata = OS.PhClipboardPasteStart((short)ig);
+ if (cbdata == 0) return types;
+ try {
+ int pClipHeader = 0;
+ int n = 0;
+ while ((pClipHeader = OS.PhClipboardPasteTypeN(cbdata, n++)) != 0) {
+ PhClipHeader clipHeader = new PhClipHeader();
+ OS.memmove(clipHeader, pClipHeader, PhClipHeader.sizeof);
+ byte[] buffer = new byte[8];
+ buffer[0] = clipHeader.type_0;
+ buffer[1] = clipHeader.type_1;
+ buffer[2] = clipHeader.type_2;
+ buffer[3] = clipHeader.type_3;
+ buffer[4] = clipHeader.type_4;
+ buffer[5] = clipHeader.type_5;
+ buffer[6] = clipHeader.type_6;
+ buffer[7] = clipHeader.type_7;
+ char [] unicode = Converter.mbcsToWcs (null, buffer);
+
+ String[] newTypes = new String[types.length + 1];
+ System.arraycopy(types, 0, newTypes, 0, types.length);
+ newTypes[types.length] = new String (unicode).trim();
+ types = newTypes;
+ }
+ } finally {
+ OS.PhClipboardPasteFinish(cbdata);
+ }
+ return types;
+}
}
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
index a7643589c2..8d37c3559d 100755
--- 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
@@ -1,267 +1,267 @@
-package org.eclipse.swt.dnd;
-
-/*
+package org.eclipse.swt.dnd;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-import org.eclipse.swt.*;
-import org.eclipse.swt.widgets.*;
-import org.eclipse.swt.internal.*;
-
-/**
- *
- * <code>DragSource</code> defines the source object for a drag and drop transfer.
- *
- * <p>IMPORTANT: This class is <em>not</em> intended to be subclassed.</p>
- *
- * <p>A drag source is the object which originates a drag and drop operation. For the specified widget,
- * it defines the type of data that is available for dragging and the set of operations that can
- * be performed on that data. The operations can be any bit-wise combination of DND.MOVE, DND.COPY or
- * DND.LINK. The type of data that can be transferred is specified by subclasses of Transfer such as
- * TextTransfer or FileTransfer. The type of data transferred can be a predefined system type or it
- * can be a type defined by the application. For instructions on how to define your own transfer type,
- * refer to <code>ByteArrayTransfer</code>.</p>
- *
- * <p>You may have several DragSources in an application but you can only have one DragSource
- * per Control. Data dragged from this DragSource can be dropped on a site within this application
- * or it can be dropped on another application such as an external Text editor.</p>
- *
- * <p>The application supplies the content of the data being transferred by implementing the
- * <code>DragSourceListener</code> and associating it with the DragSource via DragSource#addDragListener.</p>
- *
- * <p>When a successful move operation occurs, the application is required to take the appropriate
- * action to remove the data from its display and remove any associated operating system resources or
- * internal references. Typically in a move operation, the drop target makes a copy of the data
- * and the drag source deletes the original. However, sometimes copying the data can take a long
- * time (such as copying a large file). Therefore, on some platforms, the drop target may actually
- * move the data in the operating system rather than make a copy. This is usually only done in
- * file transfers. In this case, the drag source is informed in the DragEnd event that a
- * DROP_TARGET_MOVE was performed. It is the responsibility of the drag source at this point to clean
- * up its displayed information. No action needs to be taken on the operating system resources.</p>
- *
- * <p> The following example shows a Label widget that allows text to be dragged from it.</p>
- *
- * <code><pre>
- * // Enable a label as a Drag Source
- * Label label = new Label(shell, SWT.NONE);
- * // This example will allow text to be dragged
- * Transfer[] types = new Transfer[] {TextTransfer.getInstance()};
- * // This example will allow the text to be copied or moved to the drop target
- * int operations = DND.DROP_MOVE | DND.DROP_COPY;
- *
- * DragSource source = new DragSource (label, operations);
- * source.setTransfer(types);
- * source.addDragListener (new DragSourceListener() {
- * public void dragStart(DragSourceEvent e) {
- * // Only start the drag if there is actually text in the
- * // label - this text will be what is dropped on the target.
- * if (label.getText().length() == 0) {
- * event.doit = false;
- * }
- * };
- * public void dragSetData (DragSourceEvent event) {
- * // A drop has been performed, so provide the data of the
- * // requested type.
- * // (Checking the type of the requested data is only
- * // necessary if the drag source supports more than
- * // one data type but is shown here as an example).
- * if (TextTransfer.getInstance().isSupportedType(event.dataType)){
- * event.data = label.getText();
- * }
- * }
- * public void dragFinished(DragSourceEvent event) {
- * // A Move operation has been performed so remove the data
- * // from the source
- * if (event.detail == DND.DROP_MOVE)
- * label.setText("");
- * }
- * });
- * </pre></code>
- *
- *
- * <dl>
- * <dt><b>Styles</b></dt> <dd>DND.DROP_NONE, DND.DROP_COPY, DND.DROP_MOVE, DND.DROP_LINK</dd>
- * <dt><b>Events</b></dt> <dd>DND.DragStart, DND.DragSetData, DND.DragEnd</dd>
- * </dl>
- */
-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;
-
-/**
- * Creates a new <code>DragSource</code> to handle dragging from the specified <code>Control</code>.
- * Creating an instance of a DragSource may cause system resources to be allocated depending on the platform.
- * It is therefore mandatory that the DragSource instance be disposed when no longer required.
- *
- * @param control the <code>Control</code> that the user clicks on to initiate the drag
- * @param style the bitwise OR'ing of allowed operations; this may be a combination of any of
- * DND.DROP_NONE, DND.DROP_COPY, DND.DROP_MOVE, DND.DROP_LINK
- *
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
- * <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
- * </ul>
- *
- * @see DragSource#dispose
- * @see DragSource#checkSubclass
- * @see DND#DROP_NONE
- * @see DND#DROP_COPY
- * @see DND#DROP_MOVE
- * @see DND#DROP_LINK
+ * http://www.eclipse.org/legal/cpl-v10.html
*/
-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 the collection of listeners who will
- * be notified when a drag and drop operation is in progress, by sending
- * it one of the messages defined in the <code>DragSourceListener</code>
- * interface.
- *
- * <p><ul>
- * <li><code>dragStart</code> is called when the user has begun the actions required to drag the widget.
- * This event gives the application the chance to decide if a drag should be started.
- * <li><code>dragSetData</code> is called when the data is required from the drag source.
- * <li><code>dragFinished</code> is called when the drop has successfully completed (mouse up
- * over a valid target) or has been terminated (such as hitting the ESC key). Perform cleanup
- * such as removing data from the source side on a successful move operation.
- * </ul></p>
- *
- * @param listener the listener which should be notified
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see DragSourceListener
- * @see #removeDragListener
- * @see DragSourceEvent
+
+import org.eclipse.swt.*;
+import org.eclipse.swt.widgets.*;
+import org.eclipse.swt.internal.*;
+
+/**
+ *
+ * <code>DragSource</code> defines the source object for a drag and drop transfer.
+ *
+ * <p>IMPORTANT: This class is <em>not</em> intended to be subclassed.</p>
+ *
+ * <p>A drag source is the object which originates a drag and drop operation. For the specified widget,
+ * it defines the type of data that is available for dragging and the set of operations that can
+ * be performed on that data. The operations can be any bit-wise combination of DND.MOVE, DND.COPY or
+ * DND.LINK. The type of data that can be transferred is specified by subclasses of Transfer such as
+ * TextTransfer or FileTransfer. The type of data transferred can be a predefined system type or it
+ * can be a type defined by the application. For instructions on how to define your own transfer type,
+ * refer to <code>ByteArrayTransfer</code>.</p>
+ *
+ * <p>You may have several DragSources in an application but you can only have one DragSource
+ * per Control. Data dragged from this DragSource can be dropped on a site within this application
+ * or it can be dropped on another application such as an external Text editor.</p>
+ *
+ * <p>The application supplies the content of the data being transferred by implementing the
+ * <code>DragSourceListener</code> and associating it with the DragSource via DragSource#addDragListener.</p>
+ *
+ * <p>When a successful move operation occurs, the application is required to take the appropriate
+ * action to remove the data from its display and remove any associated operating system resources or
+ * internal references. Typically in a move operation, the drop target makes a copy of the data
+ * and the drag source deletes the original. However, sometimes copying the data can take a long
+ * time (such as copying a large file). Therefore, on some platforms, the drop target may actually
+ * move the data in the operating system rather than make a copy. This is usually only done in
+ * file transfers. In this case, the drag source is informed in the DragEnd event that a
+ * DROP_TARGET_MOVE was performed. It is the responsibility of the drag source at this point to clean
+ * up its displayed information. No action needs to be taken on the operating system resources.</p>
+ *
+ * <p> The following example shows a Label widget that allows text to be dragged from it.</p>
+ *
+ * <code><pre>
+ * // Enable a label as a Drag Source
+ * Label label = new Label(shell, SWT.NONE);
+ * // This example will allow text to be dragged
+ * Transfer[] types = new Transfer[] {TextTransfer.getInstance()};
+ * // This example will allow the text to be copied or moved to the drop target
+ * int operations = DND.DROP_MOVE | DND.DROP_COPY;
+ *
+ * DragSource source = new DragSource (label, operations);
+ * source.setTransfer(types);
+ * source.addDragListener (new DragSourceListener() {
+ * public void dragStart(DragSourceEvent e) {
+ * // Only start the drag if there is actually text in the
+ * // label - this text will be what is dropped on the target.
+ * if (label.getText().length() == 0) {
+ * event.doit = false;
+ * }
+ * };
+ * public void dragSetData (DragSourceEvent event) {
+ * // A drop has been performed, so provide the data of the
+ * // requested type.
+ * // (Checking the type of the requested data is only
+ * // necessary if the drag source supports more than
+ * // one data type but is shown here as an example).
+ * if (TextTransfer.getInstance().isSupportedType(event.dataType)){
+ * event.data = label.getText();
+ * }
+ * }
+ * public void dragFinished(DragSourceEvent event) {
+ * // A Move operation has been performed so remove the data
+ * // from the source
+ * if (event.detail == DND.DROP_MOVE)
+ * label.setText("");
+ * }
+ * });
+ * </pre></code>
+ *
+ *
+ * <dl>
+ * <dt><b>Styles</b></dt> <dd>DND.DROP_NONE, DND.DROP_COPY, DND.DROP_MOVE, DND.DROP_LINK</dd>
+ * <dt><b>Events</b></dt> <dd>DND.DragStart, DND.DragSetData, DND.DragEnd</dd>
+ * </dl>
*/
-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;
-}
-
-
-
-
-
-/**
- * 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 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;
+
+/**
+ * Creates a new <code>DragSource</code> to handle dragging from the specified <code>Control</code>.
+ * Creating an instance of a DragSource may cause system resources to be allocated depending on the platform.
+ * It is therefore mandatory that the DragSource instance be disposed when no longer required.
+ *
+ * @param control the <code>Control</code> that the user clicks on to initiate the drag
+ * @param style the bitwise OR'ing of allowed operations; this may be a combination of any of
+ * DND.DROP_NONE, DND.DROP_COPY, DND.DROP_MOVE, DND.DROP_LINK
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
+ * <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
+ * </ul>
+ *
+ * @see DragSource#dispose
+ * @see DragSource#checkSubclass
+ * @see DND#DROP_NONE
+ * @see DND#DROP_COPY
+ * @see DND#DROP_MOVE
+ * @see DND#DROP_LINK
*/
-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 by this DragSource.
- *
- * @return the list of data types that can be transferred by this DragSource
+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 the collection of listeners who will
+ * be notified when a drag and drop operation is in progress, by sending
+ * it one of the messages defined in the <code>DragSourceListener</code>
+ * interface.
+ *
+ * <p><ul>
+ * <li><code>dragStart</code> is called when the user has begun the actions required to drag the widget.
+ * This event gives the application the chance to decide if a drag should be started.
+ * <li><code>dragSetData</code> is called when the data is required from the drag source.
+ * <li><code>dragFinished</code> is called when the drop has successfully completed (mouse up
+ * over a valid target) or has been terminated (such as hitting the ESC key). Perform cleanup
+ * such as removing data from the source side on a successful move operation.
+ * </ul></p>
+ *
+ * @param listener the listener which should be notified
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see DragSourceListener
+ * @see #removeDragListener
+ * @see DragSourceEvent
*/
-public Transfer[] getTransfer(){
- return transferAgents;
-}
-
-
-
-/**
- * Removes the listener from the collection of listeners who will
- * be notified when a drag and drop operation is in progress.
- *
- * @param listener the listener which should be notified
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see DragSourceListener
- * @see #addDragListener
+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;
+}
+
+
+
+
+
+/**
+ * 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 void removeDragListener(DragSourceListener listener) {
- if (listener == null) DND.error (SWT.ERROR_NULL_ARGUMENT);
- removeListener (DND.DragStart, listener);
- removeListener (DND.DragSetData, listener);
- removeListener (DND.DragEnd, listener);
-}
-/**
- * Specifies the list of data types that can be transferred by this DragSource.
- * The application must be able to provide data to match each of these types when
- * a successful drop has occurred.
- *
- * @param transferAgents a list of Transfer objects which define the types of data that can be
- * dragged from this source
+public 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 by this DragSource.
+ *
+ * @return the list of data types that can be transferred by this DragSource
*/
-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);
- }
-}
-}
+public Transfer[] getTransfer(){
+ return transferAgents;
+}
+
+
+
+/**
+ * Removes the listener from the collection of listeners who will
+ * be notified when a drag and drop operation is in progress.
+ *
+ * @param listener the listener which should be notified
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see DragSourceListener
+ * @see #addDragListener
+ */
+public void removeDragListener(DragSourceListener listener) {
+ if (listener == null) DND.error (SWT.ERROR_NULL_ARGUMENT);
+ removeListener (DND.DragStart, listener);
+ removeListener (DND.DragSetData, listener);
+ removeListener (DND.DragEnd, listener);
+}
+/**
+ * Specifies the list of data types that can be transferred by this DragSource.
+ * The application must be able to provide data to match each of these types when
+ * a successful drop has occurred.
+ *
+ * @param transferAgents a list of Transfer objects which define the types of data that can be
+ * dragged from this source
+ */
+public void setTransfer(Transfer[] transferAgents){
+ 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
index d5da8697f1..15b3df7dbd 100755
--- 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
@@ -1,264 +1,264 @@
-package org.eclipse.swt.dnd;
-
-/*
+package org.eclipse.swt.dnd;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-import org.eclipse.swt.*;
-import org.eclipse.swt.graphics.*;
-import org.eclipse.swt.widgets.*;
-import org.eclipse.swt.internal.*;
-
-/**
- *
- * Class <code>DropTarget</code> defines the target object for a drag and drop transfer.
- *
- * IMPORTANT: This class is <em>not</em> intended to be subclassed.
- *
- * <p>This class identifies the <code>Control</code> over which the user must position the cursor
- * in order to drop the data being transferred. It also specifies what data types can be dropped on
- * this control and what operations can be performed. You may have several DropTragets in an
- * application but there can only be a one to one mapping between a <code>Control</code> and a <code>DropTarget</code>.
- * The DropTarget can receive data from within the same application or from other applications
- * (such as text dragged from a text editor like Word).</p>
- *
- * <code><pre>
- * int operations = DND.DROP_MOVE | DND.DROP_COPY | DND.DROP_LINK;
- * Transfer[] types = new Transfer[] {TextTransfer.getInstance()};
- * DropTarget target = new DropTarget(label, operations);
- * target.setTransfer(types);
- * </code></pre>
- *
- * <p>The application is notified of data being dragged over this control and of when a drop occurs by
- * implementing the interface <code>DropTargetListener</code> which uses the class
- * <code>DropTargetEvent</code>. The application can modify the type of drag being performed
- * on this Control at any stage of the drag by modifying the <code>event.detail</code> field or the
- * <code>event.currentDataType</code> field. When the data is dropped, it is the responsibility of
- * the application to copy this data for its own purposes.
- *
- * <code><pre>
- * target.addDropListener (new DropTargetListener() {
- * public void dragEnter(DropTargetEvent event) {};
- * public void dragOver(DropTargetEvent event) {};
- * public void dragLeave(DropTargetEvent event) {};
- * public void dragOperationChanged(DropTargetEvent event) {};
- * public void dropAccept(DropTargetEvent event) {}
- * public void drop(DropTargetEvent event) {
- * // A drop has occurred, copy over the data
- * if (event.data == null) { // no data to copy, indicate failure in event.detail
- * event.detail = DND.DROP_NONE;
- * return;
- * }
- * label.setText ((String) event.data); // data copied to label text
- * }
- * });
- * </pre></code>
- *
- * <dl>
- * <dt><b>Styles</b></dt> <dd>DND.DROP_NONE, DND.DROP_COPY, DND.DROP_MOVE, DND.DROP_LINK</dd>
- * <dt><b>Events</b></dt> <dd>DND.DragEnter, DND.DragLeave, DND.DragOver, DND.DragOperationChanged,
- * DND.DropAccept, DND.Drop </dd>
- * </dl>
- */
-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;
-
-/**
- * Creates a new <code>DropTarget</code> to allow data to be dropped on the specified
- * <code>Control</code>.
- * Creating an instance of a DropTarget may cause system resources to be allocated
- * depending on the platform. It is therefore mandatory that the DropTarget instance
- * be disposed when no longer required.
- *
- * @param control the <code>Control</code> over which the user positions the cursor to drop the data
- * @param style the bitwise OR'ing of allowed operations; this may be a combination of any of
- * DND.DROP_NONE, DND.DROP_COPY, DND.DROP_MOVE, DND.DROP_LINK
- *
- * @see DropTarget#dispose
- * @see DropTarget#checkSubclass
- * @see DND#DROP_NONE
- * @see DND#DROP_COPY
- * @see DND#DROP_MOVE
- * @see DND#DROP_LINK
+ * http://www.eclipse.org/legal/cpl-v10.html
*/
-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 the collection of listeners who will
- * be notified when a drag and drop operation is in progress, by sending
- * it one of the messages defined in the <code>DropTargetListener</code>
- * interface.
- *
- * <p><ul>
- * <li><code>dragEnter</code> is called when the cursor has entered the drop target boundaries
- * <li><code>dragLeave</code> is called when the cursor has left the drop target boundaries and just before
- * the drop occurs or is cancelled.
- * <li><code>dragOperationChanged</code> is called when the operation being performed has changed
- * (usually due to the user changing the selected modifier key(s) while dragging)
- * <li><code>dragOver</code> is called when the cursor is moving over the drop target
- * <li><code>dropAccept</code> is called just before the drop is performed. The drop target is given
- * the chance to change the nature of the drop or veto the drop by setting the <code>event.detail</code> field
- * <li><code>drop</code> is called when the data is being dropped
- * </ul></p>
- *
- * @param listener the listener which should be notified
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see DropTargetListener
- * @see #removeDropListener
- * @see DropTargetEvent
+
+import org.eclipse.swt.*;
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.widgets.*;
+import org.eclipse.swt.internal.*;
+
+/**
+ *
+ * Class <code>DropTarget</code> defines the target object for a drag and drop transfer.
+ *
+ * IMPORTANT: This class is <em>not</em> intended to be subclassed.
+ *
+ * <p>This class identifies the <code>Control</code> over which the user must position the cursor
+ * in order to drop the data being transferred. It also specifies what data types can be dropped on
+ * this control and what operations can be performed. You may have several DropTragets in an
+ * application but there can only be a one to one mapping between a <code>Control</code> and a <code>DropTarget</code>.
+ * The DropTarget can receive data from within the same application or from other applications
+ * (such as text dragged from a text editor like Word).</p>
+ *
+ * <code><pre>
+ * int operations = DND.DROP_MOVE | DND.DROP_COPY | DND.DROP_LINK;
+ * Transfer[] types = new Transfer[] {TextTransfer.getInstance()};
+ * DropTarget target = new DropTarget(label, operations);
+ * target.setTransfer(types);
+ * </code></pre>
+ *
+ * <p>The application is notified of data being dragged over this control and of when a drop occurs by
+ * implementing the interface <code>DropTargetListener</code> which uses the class
+ * <code>DropTargetEvent</code>. The application can modify the type of drag being performed
+ * on this Control at any stage of the drag by modifying the <code>event.detail</code> field or the
+ * <code>event.currentDataType</code> field. When the data is dropped, it is the responsibility of
+ * the application to copy this data for its own purposes.
+ *
+ * <code><pre>
+ * target.addDropListener (new DropTargetListener() {
+ * public void dragEnter(DropTargetEvent event) {};
+ * public void dragOver(DropTargetEvent event) {};
+ * public void dragLeave(DropTargetEvent event) {};
+ * public void dragOperationChanged(DropTargetEvent event) {};
+ * public void dropAccept(DropTargetEvent event) {}
+ * public void drop(DropTargetEvent event) {
+ * // A drop has occurred, copy over the data
+ * if (event.data == null) { // no data to copy, indicate failure in event.detail
+ * event.detail = DND.DROP_NONE;
+ * return;
+ * }
+ * label.setText ((String) event.data); // data copied to label text
+ * }
+ * });
+ * </pre></code>
+ *
+ * <dl>
+ * <dt><b>Styles</b></dt> <dd>DND.DROP_NONE, DND.DROP_COPY, DND.DROP_MOVE, DND.DROP_LINK</dd>
+ * <dt><b>Events</b></dt> <dd>DND.DragEnter, DND.DragLeave, DND.DragOver, DND.DragOperationChanged,
+ * DND.DropAccept, DND.Drop </dd>
+ * </dl>
*/
-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 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;
+
+/**
+ * Creates a new <code>DropTarget</code> to allow data to be dropped on the specified
+ * <code>Control</code>.
+ * Creating an instance of a DropTarget may cause system resources to be allocated
+ * depending on the platform. It is therefore mandatory that the DropTarget instance
+ * be disposed when no longer required.
+ *
+ * @param control the <code>Control</code> over which the user positions the cursor to drop the data
+ * @param style the bitwise OR'ing of allowed operations; this may be a combination of any of
+ * DND.DROP_NONE, DND.DROP_COPY, DND.DROP_MOVE, DND.DROP_LINK
+ *
+ * @see DropTarget#dispose
+ * @see DropTarget#checkSubclass
+ * @see DND#DROP_NONE
+ * @see DND#DROP_COPY
+ * @see DND#DROP_MOVE
+ * @see DND#DROP_LINK
*/
-public Control getControl () {
- return control;
-}
-public Display getDisplay () {
-
- if (control == null) DND.error(SWT.ERROR_WIDGET_DISPOSED);
- return control.getDisplay ();
-}
-/**
- * Returns a list of the data types that can be transferred to this DropTarget.
- *
- * @return a list of the data types that can be transferred to this DropTarget
- */
-public Transfer[] getTransfer(){
- return transferAgents;
-}
-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);
-}
-
-/**
- * Removes the listener from the collection of listeners who will
- * be notified when a drag and drop operation is in progress.
- *
- * @param listener the listener which should be notified
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see DropTargetListener
- * @see #addDropListener
+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 the collection of listeners who will
+ * be notified when a drag and drop operation is in progress, by sending
+ * it one of the messages defined in the <code>DropTargetListener</code>
+ * interface.
+ *
+ * <p><ul>
+ * <li><code>dragEnter</code> is called when the cursor has entered the drop target boundaries
+ * <li><code>dragLeave</code> is called when the cursor has left the drop target boundaries and just before
+ * the drop occurs or is cancelled.
+ * <li><code>dragOperationChanged</code> is called when the operation being performed has changed
+ * (usually due to the user changing the selected modifier key(s) while dragging)
+ * <li><code>dragOver</code> is called when the cursor is moving over the drop target
+ * <li><code>dropAccept</code> is called just before the drop is performed. The drop target is given
+ * the chance to change the nature of the drop or veto the drop by setting the <code>event.detail</code> field
+ * <li><code>drop</code> is called when the data is being dropped
+ * </ul></p>
+ *
+ * @param listener the listener which should be notified
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see DropTargetListener
+ * @see #removeDropListener
+ * @see DropTargetEvent
*/
-public void removeDropListener(DropTargetListener listener) {
- if (listener == null) DND.error (SWT.ERROR_NULL_ARGUMENT);
- removeListener (DND.DragEnter, listener);
- removeListener (DND.DragLeave, listener);
- removeListener (DND.DragOver, listener);
- removeListener (DND.DragOperationChanged, listener);
- removeListener (DND.Drop, listener);
- removeListener (DND.DropAccept, listener);
-}
-/**
- * Specifies the data types that can be transferred to this DropTarget. If data is
- * being dragged that does not match one of these types, the drop target will be notified of
- * the drag and drop operation but the currentDataType will be null and the operation
- * will be DND.NONE.
- *
- * @param transferAgents a list of Transfer objects which define the types of data that can be
- * dropped on this target
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if transferAgents is null</li>
- * </ul>
- */
-public void setTransfer(Transfer[] transferAgents){
- if (transferAgents == null) DND.error(SWT.ERROR_NULL_ARGUMENT);
-}
-
-
-protected void checkSubclass () {
- String name = getClass().getName ();
- String validName = DropTarget.class.getName();
- if (!validName.equals(name)) {
- DND.error (SWT.ERROR_INVALID_SUBCLASS);
- }
-}
-}
+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 a list of the data types that can be transferred to this DropTarget.
+ *
+ * @return a list of the data types that can be transferred to this DropTarget
+ */
+public Transfer[] getTransfer(){
+ return transferAgents;
+}
+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);
+}
+
+/**
+ * Removes the listener from the collection of listeners who will
+ * be notified when a drag and drop operation is in progress.
+ *
+ * @param listener the listener which should be notified
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see DropTargetListener
+ * @see #addDropListener
+ */
+public void removeDropListener(DropTargetListener listener) {
+ if (listener == null) DND.error (SWT.ERROR_NULL_ARGUMENT);
+ removeListener (DND.DragEnter, listener);
+ removeListener (DND.DragLeave, listener);
+ removeListener (DND.DragOver, listener);
+ removeListener (DND.DragOperationChanged, listener);
+ removeListener (DND.Drop, listener);
+ removeListener (DND.DropAccept, listener);
+}
+/**
+ * Specifies the data types that can be transferred to this DropTarget. If data is
+ * being dragged that does not match one of these types, the drop target will be notified of
+ * the drag and drop operation but the currentDataType will be null and the operation
+ * will be DND.NONE.
+ *
+ * @param transferAgents a list of Transfer objects which define the types of data that can be
+ * dropped on this target
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if transferAgents is null</li>
+ * </ul>
+ */
+public void setTransfer(Transfer[] transferAgents){
+ if (transferAgents == null) DND.error(SWT.ERROR_NULL_ARGUMENT);
+}
+
+
+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
index 39e2304621..7814f55b7b 100755
--- 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
@@ -1,115 +1,115 @@
-package org.eclipse.swt.dnd;
-
-/*
+package org.eclipse.swt.dnd;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-import org.eclipse.swt.internal.Converter;
-
-/**
- * The class <code>FileTransfer</code> provides a platform specific mechanism
- * for converting a list of files represented as a java <code>String[]</code> to a
- * platform specific representation of the data and vice versa.
- * Each <code>String</code> in the array contains the absolute path for a single
- * file or directory.
- * See <code>Transfer</code> for additional information.
- *
- * <p>An example of a java <code>String[]</code> containing a list of files is shown
- * below:</p>
- *
- * <code><pre>
- * File file1 = new File("C:\temp\file1");
- * File file2 = new File("C:\temp\file2");
- * String[] fileData = new String[2];
- * fileData[0] = file1.getAbsolutePath();
- * fileData[1] = file2.getAbsolutePath();
- * </code></pre>
+ * http://www.eclipse.org/legal/cpl-v10.html
*/
-public class FileTransfer extends ByteArrayTransfer {
-
- private static FileTransfer _instance = new FileTransfer();
- private static final String TYPENAME = "files";
- private static final int TYPEID = registerType(TYPENAME);
-
-private FileTransfer() {}
-/**
- * Returns the singleton instance of the FileTransfer class.
- *
- * @return the singleton instance of the FileTransfer class
+import org.eclipse.swt.internal.Converter;
+
+/**
+ * The class <code>FileTransfer</code> provides a platform specific mechanism
+ * for converting a list of files represented as a java <code>String[]</code> to a
+ * platform specific representation of the data and vice versa.
+ * Each <code>String</code> in the array contains the absolute path for a single
+ * file or directory.
+ * See <code>Transfer</code> for additional information.
+ *
+ * <p>An example of a java <code>String[]</code> containing a list of files is shown
+ * below:</p>
+ *
+ * <code><pre>
+ * File file1 = new File("C:\temp\file1");
+ * File file2 = new File("C:\temp\file2");
+ * String[] fileData = new String[2];
+ * fileData[0] = file1.getAbsolutePath();
+ * fileData[1] = file2.getAbsolutePath();
+ * </code></pre>
*/
-public static FileTransfer getInstance () {
- return _instance;
-}
-/**
- * This implementation of <code>javaToNative</code> converts a list of file names
- * represented by a java <code>String[]</code> to a platform specific representation.
- * Each <code>String</code> in the array contains the absolute path for a single
- * file or directory. For additional information see
- * <code>Transfer#javaToNative</code>.
- *
- * @param object a java <code>String[]</code> containing the file names to be
- * converted
- * @param transferData an empty <code>TransferData</code> object; this
- * object will be filled in on return with the platform specific format of the data
+public class FileTransfer extends ByteArrayTransfer {
+
+ private static FileTransfer _instance = new FileTransfer();
+ private static final String TYPENAME = "files";
+ private static final int TYPEID = registerType(TYPENAME);
+
+private FileTransfer() {}
+/**
+ * Returns the singleton instance of the FileTransfer class.
+ *
+ * @return the singleton instance of the FileTransfer class
*/
-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 = "";
- for (int i = 0, length = files.length; i < length; i++){
- nativeFormat += "file:"+files[i]+"\r";
- }
- byte[] buffer = Converter.wcsToMbcs(null, nativeFormat, true);
- // pass byte array on to super to convert to native
- super.javaToNative(buffer, transferData);
-}
-/**
- * This implementation of <code>nativeToJava</code> converts a platform specific
- * representation of a list of file names to a java <code>String[]</code>.
- * Each String in the array contains the absolute path for a single file or directory.
- * For additional information see <code>Transfer#nativeToJava</code>.
- *
- * @param transferData the platform specific representation of the data to be
- * been converted
- * @return a java <code>String[]</code> containing a list of file names if the
- * conversion was successful; otherwise null
+public static FileTransfer getInstance () {
+ return _instance;
+}
+/**
+ * This implementation of <code>javaToNative</code> converts a list of file names
+ * represented by a java <code>String[]</code> to a platform specific representation.
+ * Each <code>String</code> in the array contains the absolute path for a single
+ * file or directory. For additional information see
+ * <code>Transfer#javaToNative</code>.
+ *
+ * @param object a java <code>String[]</code> containing the file names to be
+ * converted
+ * @param transferData an empty <code>TransferData</code> object; this
+ * object will be filled in on return with the platform specific format of the data
*/
-public Object nativeToJava(TransferData transferData) {
-
- byte[] data = (byte[])super.nativeToJava(transferData);
- if (data == null) return null;
- char[] unicode = Converter.mbcsToWcs(null, data);
- String string = new String(unicode);
- // 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};
-}
-}
+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 = "";
+ for (int i = 0, length = files.length; i < length; i++){
+ nativeFormat += "file:"+files[i]+"\r";
+ }
+ byte[] buffer = Converter.wcsToMbcs(null, nativeFormat, true);
+ // pass byte array on to super to convert to native
+ super.javaToNative(buffer, transferData);
+}
+/**
+ * This implementation of <code>nativeToJava</code> converts a platform specific
+ * representation of a list of file names to a java <code>String[]</code>.
+ * Each String in the array contains the absolute path for a single file or directory.
+ * For additional information see <code>Transfer#nativeToJava</code>.
+ *
+ * @param transferData the platform specific representation of the data to be
+ * been converted
+ * @return a java <code>String[]</code> containing a list of file names if the
+ * conversion was successful; otherwise null
+ */
+public Object nativeToJava(TransferData transferData) {
+
+ byte[] data = (byte[])super.nativeToJava(transferData);
+ if (data == null) return null;
+ char[] unicode = Converter.mbcsToWcs(null, data);
+ String string = new String(unicode);
+ // 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
index b80c5d0e01..c539cf5b70 100755
--- 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
@@ -1,85 +1,85 @@
-package org.eclipse.swt.dnd;
-
-/*
+package org.eclipse.swt.dnd;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-import org.eclipse.swt.internal.Converter;
-import org.eclipse.swt.internal.photon.OS;
-
-/**
- * The class <code>RTFTransfer</code> provides a platform specific mechanism
- * for converting text in RTF format represented as a java <code>String</code>
- * to a platform specific representation of the data and vice versa. See
- * <code>Transfer</code> for additional information.
- *
- * <p>An example of a java <code>String</code> containing RTF text is shown
- * below:</p>
- *
- * <code><pre>
- * String rtfData = "{\\rtf1{\\colortbl;\\red255\\green0\\blue0;}\\uc1\\b\\i Hello World}";
- * </code></pre>
+ * http://www.eclipse.org/legal/cpl-v10.html
*/
-public class RTFTransfer extends ByteArrayTransfer {
-
- private static RTFTransfer _instance = new RTFTransfer();
- private static final String TYPENAME = "RTF";
- private static final int TYPEID = registerType(TYPENAME);
-
-private RTFTransfer() {
-}
-/**
- * Returns the singleton instance of the RTFTransfer class.
- *
- * @return the singleton instance of the RTFTransfer class
+
+import org.eclipse.swt.internal.Converter;
+import org.eclipse.swt.internal.photon.OS;
+
+/**
+ * The class <code>RTFTransfer</code> provides a platform specific mechanism
+ * for converting text in RTF format represented as a java <code>String</code>
+ * to a platform specific representation of the data and vice versa. See
+ * <code>Transfer</code> for additional information.
+ *
+ * <p>An example of a java <code>String</code> containing RTF text is shown
+ * below:</p>
+ *
+ * <code><pre>
+ * String rtfData = "{\\rtf1{\\colortbl;\\red255\\green0\\blue0;}\\uc1\\b\\i Hello World}";
+ * </code></pre>
*/
-public static RTFTransfer getInstance () {
- return _instance;
-}
-/**
- * This implementation of <code>javaToNative</code> converts RTF-formatted text
- * represented by a java <code>String</code> to a platform specific representation.
- * For additional information see <code>Transfer#javaToNative</code>.
- *
- * @param object a java <code>String</code> containing RTF text
- * @param transferData an empty <code>TransferData</code> object; this
- * object will be filled in on return with the platform specific format of the data
+public class RTFTransfer extends ByteArrayTransfer {
+
+ private static RTFTransfer _instance = new RTFTransfer();
+ private static final String TYPENAME = "RTF";
+ private static final int TYPEID = registerType(TYPENAME);
+
+private RTFTransfer() {
+}
+/**
+ * Returns the singleton instance of the RTFTransfer class.
+ *
+ * @return the singleton instance of the RTFTransfer class
+ */
+public static RTFTransfer getInstance () {
+ return _instance;
+}
+/**
+ * This implementation of <code>javaToNative</code> converts RTF-formatted text
+ * represented by a java <code>String</code> to a platform specific representation.
+ * For additional information see <code>Transfer#javaToNative</code>.
+ *
+ * @param object a java <code>String</code> containing RTF text
+ * @param transferData an empty <code>TransferData</code> 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;
- byte [] buffer = Converter.wcsToMbcs (null, (String)object, true);
- super.javaToNative(buffer, transferData);
-}
-/**
- * This implementation of <code>nativeToJava</code> converts a platform specific
- * representation of RTF text to a java <code>String</code>.
- * For additional information see <code>Transfer#nativeToJava</code>.
- *
- * @param transferData the platform specific representation of the data to be
- * been converted
- * @return a java <code>String</code> containing RTF text if the
- * conversion was successful; otherwise null
+public void javaToNative (Object object, TransferData transferData){
+ if (object == null || !(object instanceof String)) return;
+ byte [] buffer = Converter.wcsToMbcs (null, (String)object, true);
+ super.javaToNative(buffer, transferData);
+}
+/**
+ * This implementation of <code>nativeToJava</code> converts a platform specific
+ * representation of RTF text to a java <code>String</code>.
+ * For additional information see <code>Transfer#nativeToJava</code>.
+ *
+ * @param transferData the platform specific representation of the data to be
+ * been converted
+ * @return a java <code>String</code> containing RTF text if the
+ * conversion was successful; otherwise null
*/
-public Object nativeToJava(TransferData transferData){
-
- if (transferData.pData == 0 || !(isSupportedType(transferData))) return null;
-
- int size = transferData.length;
- if (size == 0) return null;
- byte[] buffer = new byte[OS.strlen(transferData.pData)];
- OS.memmove(buffer, transferData.pData, buffer.length);
-
- // convert byte array to a string
- char [] unicode = Converter.mbcsToWcs (null, buffer);
- return new String (unicode);
-}
-protected String[] getTypeNames(){
- return new String[]{TYPENAME};
-}
-protected int[] getTypeIds(){
- return new int[]{TYPEID};
-}
+public Object nativeToJava(TransferData transferData){
+
+ if (transferData.pData == 0 || !(isSupportedType(transferData))) return null;
+
+ int size = transferData.length;
+ if (size == 0) return null;
+ byte[] buffer = new byte[OS.strlen(transferData.pData)];
+ OS.memmove(buffer, transferData.pData, buffer.length);
+
+ // convert byte array to a string
+ char [] unicode = Converter.mbcsToWcs (null, buffer);
+ return new String (unicode);
+}
+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/TableDragUnderEffect.java b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/photon/org/eclipse/swt/dnd/TableDragUnderEffect.java
index e155dc5b4f..ee4960f00f 100755
--- 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
@@ -1,65 +1,65 @@
-package org.eclipse.swt.dnd;
-
-/*
+package org.eclipse.swt.dnd;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-import org.eclipse.swt.graphics.*;
-import org.eclipse.swt.widgets.*;
-
-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;
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.widgets.*;
+
+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;
+}
}
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
index 45d75e6323..fbbd8ac12d 100755
--- 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
@@ -1,85 +1,85 @@
-package org.eclipse.swt.dnd;
-
-/*
+package org.eclipse.swt.dnd;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-import org.eclipse.swt.internal.Converter;
-import org.eclipse.swt.internal.photon.OS;
-
-/**
- * The class <code>TextTransfer</code> provides a platform specific mechanism
- * for converting plain text represented as a java <code>String</code>
- * to a platform specific representation of the data and vice versa. See
- * <code>Transfer</code> for additional information.
- *
- * <p>An example of a java <code>String</code> containing plain text is shown
- * below:</p>
- *
- * <code><pre>
- * String textData = "Hello World";
- * </code></pre>
+ * http://www.eclipse.org/legal/cpl-v10.html
*/
-public class TextTransfer extends ByteArrayTransfer {
-
- private static TextTransfer _instance = new TextTransfer();
- private static final String TYPENAME = "TEXT";
- private static final int TYPEID = registerType(TYPENAME);
-
-private TextTransfer() {
-}
-/**
- * Returns the singleton instance of the TextTransfer class.
- *
- * @return the singleton instance of the TextTransfer class
+
+import org.eclipse.swt.internal.Converter;
+import org.eclipse.swt.internal.photon.OS;
+
+/**
+ * The class <code>TextTransfer</code> provides a platform specific mechanism
+ * for converting plain text represented as a java <code>String</code>
+ * to a platform specific representation of the data and vice versa. See
+ * <code>Transfer</code> for additional information.
+ *
+ * <p>An example of a java <code>String</code> containing plain text is shown
+ * below:</p>
+ *
+ * <code><pre>
+ * String textData = "Hello World";
+ * </code></pre>
*/
-public static TextTransfer getInstance () {
- return _instance;
-}
-/**
- * This implementation of <code>javaToNative</code> converts plain text
- * represented by a java <code>String</code> to a platform specific representation.
- * For additional information see <code>Transfer#javaToNative</code>.
- *
- * @param object a java <code>String</code> containing text
- * @param transferData an empty <code>TransferData</code> object; this
- * object will be filled in on return with the platform specific format of the data
+public class TextTransfer extends ByteArrayTransfer {
+
+ private static TextTransfer _instance = new TextTransfer();
+ private static final String TYPENAME = "TEXT";
+ private static final int TYPEID = registerType(TYPENAME);
+
+private TextTransfer() {
+}
+/**
+ * Returns the singleton instance of the TextTransfer class.
+ *
+ * @return the singleton instance of the TextTransfer class
+ */
+public static TextTransfer getInstance () {
+ return _instance;
+}
+/**
+ * This implementation of <code>javaToNative</code> converts plain text
+ * represented by a java <code>String</code> to a platform specific representation.
+ * For additional information see <code>Transfer#javaToNative</code>.
+ *
+ * @param object a java <code>String</code> containing text
+ * @param transferData an empty <code>TransferData</code> 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;
- byte [] buffer = Converter.wcsToMbcs (null, (String)object, true);
- super.javaToNative(buffer, transferData);
-}
-/**
- * This implementation of <code>nativeToJava</code> converts a platform specific
- * representation of plain text to a java <code>String</code>.
- * For additional information see <code>Transfer#nativeToJava</code>.
- *
- * @param transferData the platform specific representation of the data to be
- * been converted
- * @return a java <code>String</code> containing text if the
- * conversion was successful; otherwise null
+public void javaToNative (Object object, TransferData transferData){
+ if (object == null || !(object instanceof String)) return;
+ byte [] buffer = Converter.wcsToMbcs (null, (String)object, true);
+ super.javaToNative(buffer, transferData);
+}
+/**
+ * This implementation of <code>nativeToJava</code> converts a platform specific
+ * representation of plain text to a java <code>String</code>.
+ * For additional information see <code>Transfer#nativeToJava</code>.
+ *
+ * @param transferData the platform specific representation of the data to be
+ * been converted
+ * @return a java <code>String</code> containing text if the
+ * conversion was successful; otherwise null
*/
-public Object nativeToJava(TransferData transferData){
-
- if (transferData.pData == 0 || !(isSupportedType(transferData))) return null;
-
- int size = transferData.length;
- if (size == 0) return null;
- byte[] buffer = new byte[OS.strlen(transferData.pData)];
- OS.memmove(buffer, transferData.pData, buffer.length);
-
- // convert byte array to a string
- char [] unicode = Converter.mbcsToWcs (null, buffer);
- return new String (unicode);
-}
-protected String[] getTypeNames(){
- return new String[]{TYPENAME};
-}
-protected int[] getTypeIds(){
- return new int[]{TYPEID};
-}
+public Object nativeToJava(TransferData transferData){
+
+ if (transferData.pData == 0 || !(isSupportedType(transferData))) return null;
+
+ int size = transferData.length;
+ if (size == 0) return null;
+ byte[] buffer = new byte[OS.strlen(transferData.pData)];
+ OS.memmove(buffer, transferData.pData, buffer.length);
+
+ // convert byte array to a string
+ char [] unicode = Converter.mbcsToWcs (null, buffer);
+ return new String (unicode);
+}
+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/Transfer.java b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/photon/org/eclipse/swt/dnd/Transfer.java
index c764524925..84de0744b7 100755
--- 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
@@ -1,125 +1,125 @@
-package org.eclipse.swt.dnd;
-
-/*
+package org.eclipse.swt.dnd;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-/**
- * <code>Transfer</code> provides a mechanism for converting between a java
- * representation of data and a platform specific representation of data and
- * vice versa. It is used in data transfer operations such as drag and drop and
- * clipboard copy/paste.
- *
- * <p>You should only need to become familiar with this class if you are
- * implementing a Transfer subclass and you are unable to subclass the
- * ByteArrayTransfer class.</p>
- *
- * @see ByteArrayTransfer
+ * http://www.eclipse.org/legal/cpl-v10.html
*/
-public abstract class Transfer {
-
-/**
- * Returns a list of the platform specific data types that can be converted using
- * this transfer agent.
- *
- * <p>Only the data type fields of the <code>TransferData</code> objects are filled
- * in.</p>
- *
- * @return a list of the data types that can be converted using this transfer agent
+
+/**
+ * <code>Transfer</code> provides a mechanism for converting between a java
+ * representation of data and a platform specific representation of data and
+ * vice versa. It is used in data transfer operations such as drag and drop and
+ * clipboard copy/paste.
+ *
+ * <p>You should only need to become familiar with this class if you are
+ * implementing a Transfer subclass and you are unable to subclass the
+ * ByteArrayTransfer class.</p>
+ *
+ * @see ByteArrayTransfer
*/
-abstract public TransferData[] getSupportedTypes();
-/**
- * Returns true if the <code>TransferData</code> data type can be converted
- * using this transfer agent.
- *
- * @param transferData a platform specific description of a data type; only the data
- * type fields of the <code>TransferData</code> object need to be filled in
- *
- * @return true if the transferData data type can be converted using this transfer
- * agent
+public abstract class Transfer {
+
+/**
+ * Returns a list of the platform specific data types that can be converted using
+ * this transfer agent.
+ *
+ * <p>Only the data type fields of the <code>TransferData</code> objects are filled
+ * in.</p>
+ *
+ * @return a list of the data types that can be converted using this transfer agent
*/
-abstract public boolean isSupportedType(TransferData transferData);
-
-/**
- * Returns the platform specfic names of the data types that can be converted
- * using this transfer agent.
- *
- * @return the platform specfic names of the data types that can be converted
- * using this transfer agent.
- */
-abstract protected String[] getTypeNames();
-
-/**
- * Returns the platform specfic ids of the data types that can be converted using
- * this transfer agent.
- *
- * @return the platform specfic ids of the data types that can be converted using
- * this transfer agent
- */
-abstract protected int[] getTypeIds();
-
-/**
- * Converts a java representation of data to a platform specific representation of
- * the data.
- *
- * <p>On a successful conversion, the transferData.result field will be set as follows:
- * <ul>
- * <li>Windows: COM.S_OK
- * <li>Motif: 1
- * <li>GTK: 1
- * <li>Photon: 1
- * </ul></p>
- *
- * <p>If this transfer agent is unable to perform the conversion, the transferData.result
- * field will be set to a failure value as follows:
- * <ul>
- * <li>Windows: COM.DV_E_TYMED or COM.E_FAIL
- * <li>Motif: 0
- * <li>GTK: 0
- * <li>Photon: 0
- * </ul></p>
- *
- * @param object a java representation of the data to be converted; the type of
- * Object that is passed in is dependant on the <code>Transfer</code> subclass.
- *
- * @param transferData an empty TransferData object; this object will be
- * filled in on return with the platform specific representation of the data
- */
-abstract protected void javaToNative (Object object, TransferData transferData);
-
-/**
- * Converts a platform specific representation of data to a java representation.
- *
- * @param transferData the platform specific representation of the data to be
- * converted
- *
- * @return a java representation of the converted data if the conversion was
- * successful; otherwise null. The type of Object that is returned is dependant
- * on the <code>Transfer</code> subclass
- */
-abstract protected Object nativeToJava(TransferData transferData);
-
-/**
- * Registers a name for a data type and returns the associated unique identifier.
- *
- * <p>You may register the same type more than once, the same unique identifier
- * will be returned if the type has been previously registered.</p>
- *
- * <p>Note: On windows, do <b>not</b> call this method with pre-defined
- * Clipboard Format types such as CF_TEXT or CF_BITMAP because the
- * pre-defined identifier will not be returned</p>
- *
- * @param formatName the name of a data type
- *
- * @return the unique identifier associated with htis data type
+abstract public TransferData[] getSupportedTypes();
+/**
+ * Returns true if the <code>TransferData</code> data type can be converted
+ * using this transfer agent.
+ *
+ * @param transferData a platform specific description of a data type; only the data
+ * type fields of the <code>TransferData</code> object need to be filled in
+ *
+ * @return true if the transferData data type can be converted using this transfer
+ * agent
*/
-public static int registerType(String formatName){
- if (formatName == "TEXT") return 10;
- if (formatName == "files") return 11;
- if (formatName == "RTF") return 12;
- return 0;
-}
-}
+abstract public boolean isSupportedType(TransferData transferData);
+
+/**
+ * Returns the platform specfic names of the data types that can be converted
+ * using this transfer agent.
+ *
+ * @return the platform specfic names of the data types that can be converted
+ * using this transfer agent.
+ */
+abstract protected String[] getTypeNames();
+
+/**
+ * Returns the platform specfic ids of the data types that can be converted using
+ * this transfer agent.
+ *
+ * @return the platform specfic ids of the data types that can be converted using
+ * this transfer agent
+ */
+abstract protected int[] getTypeIds();
+
+/**
+ * Converts a java representation of data to a platform specific representation of
+ * the data.
+ *
+ * <p>On a successful conversion, the transferData.result field will be set as follows:
+ * <ul>
+ * <li>Windows: COM.S_OK
+ * <li>Motif: 1
+ * <li>GTK: 1
+ * <li>Photon: 1
+ * </ul></p>
+ *
+ * <p>If this transfer agent is unable to perform the conversion, the transferData.result
+ * field will be set to a failure value as follows:
+ * <ul>
+ * <li>Windows: COM.DV_E_TYMED or COM.E_FAIL
+ * <li>Motif: 0
+ * <li>GTK: 0
+ * <li>Photon: 0
+ * </ul></p>
+ *
+ * @param object a java representation of the data to be converted; the type of
+ * Object that is passed in is dependant on the <code>Transfer</code> subclass.
+ *
+ * @param transferData an empty TransferData object; this object will be
+ * filled in on return with the platform specific representation of the data
+ */
+abstract protected void javaToNative (Object object, TransferData transferData);
+
+/**
+ * Converts a platform specific representation of data to a java representation.
+ *
+ * @param transferData the platform specific representation of the data to be
+ * converted
+ *
+ * @return a java representation of the converted data if the conversion was
+ * successful; otherwise null. The type of Object that is returned is dependant
+ * on the <code>Transfer</code> subclass
+ */
+abstract protected Object nativeToJava(TransferData transferData);
+
+/**
+ * Registers a name for a data type and returns the associated unique identifier.
+ *
+ * <p>You may register the same type more than once, the same unique identifier
+ * will be returned if the type has been previously registered.</p>
+ *
+ * <p>Note: On windows, do <b>not</b> call this method with pre-defined
+ * Clipboard Format types such as CF_TEXT or CF_BITMAP because the
+ * pre-defined identifier will not be returned</p>
+ *
+ * @param formatName the name of a data type
+ *
+ * @return the unique identifier associated with htis data type
+ */
+public static int registerType(String formatName){
+ if (formatName == "TEXT") return 10;
+ if (formatName == "files") return 11;
+ if (formatName == "RTF") return 12;
+ 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
index f3826fde7c..df9c032c54 100755
--- 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
@@ -1,53 +1,53 @@
-package org.eclipse.swt.dnd;
-
-/*
+package org.eclipse.swt.dnd;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-/**
- * The <code>TransferData</code> class is a platform specific data structure for
- * describing the type and the contents of data being converted by a transfer agent.
- *
- * <p>As an application writer, you do not need to know the specifics of
- * TransferData. TransferData instances are passed to a subclass of Transfer
- * and the Transfer object manages the platform specific issues.
- * You can ask a Transfer subclass if it can handle this data by calling
- * Transfer.isSupportedType(transferData).</p>
- *
- * <p>You should only need to become familiar with the fields in this class if you
- * are implementing a Transfer subclass and you are unable to subclass the
- * ByteArrayTransfer class.</p>
+ * http://www.eclipse.org/legal/cpl-v10.html
*/
-public class TransferData {
- /**
- * The type is a unique identifier of a system format or user defined format.
- * (Warning: This field is platform dependent)
+
+/**
+ * The <code>TransferData</code> class is a platform specific data structure for
+ * describing the type and the contents of data being converted by a transfer agent.
+ *
+ * <p>As an application writer, you do not need to know the specifics of
+ * TransferData. TransferData instances are passed to a subclass of Transfer
+ * and the Transfer object manages the platform specific issues.
+ * You can ask a Transfer subclass if it can handle this data by calling
+ * Transfer.isSupportedType(transferData).</p>
+ *
+ * <p>You should only need to become familiar with the fields in this class if you
+ * are implementing a Transfer subclass and you are unable to subclass the
+ * ByteArrayTransfer class.</p>
+ */
+public class TransferData {
+ /**
+ * The type is a unique identifier of a system format or user defined format.
+ * (Warning: This field is platform dependent)
+ */
+ public int type;
+
+ /**
+ * Pointer to the data being transferred. Data is of size
+ * <code>length</code> bytes.
+ * (Warning: This field is platform dependent)
+ */
+ public int pData;
+
+ /**
+ * Specifies the number of bytes in pValue.
+ * (Warning: This field is platform dependent)
*/
- public int type;
-
- /**
- * Pointer to the data being transferred. Data is of size
- * <code>length</code> bytes.
- * (Warning: This field is platform dependent)
- */
- public int pData;
-
- /**
- * Specifies the number of bytes in pValue.
- * (Warning: This field is platform dependent)
- */
- public int length;
-
- /**
- * The result field contains the result of converting a java data type
- * into a platform specific value.
- * (Warning: This field is platform dependent)
- *
- * <p>The value of result is 1 if the conversion was successfully. The value of
- * result is 0 if the conversion failed.</p>
+ public int length;
+
+ /**
+ * The result field contains the result of converting a java data type
+ * into a platform specific value.
+ * (Warning: This field is platform dependent)
+ *
+ * <p>The value of result is 1 if the conversion was successfully. The value of
+ * result is 0 if the conversion failed.</p>
*/
- public int result;
-}
+ public 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
index 36cd978bd7..40f41b3565 100755
--- 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
@@ -1,104 +1,104 @@
-package org.eclipse.swt.dnd;
-
-/*
+package org.eclipse.swt.dnd;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-import org.eclipse.swt.graphics.*;
-import org.eclipse.swt.widgets.*;
-
-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
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.widgets.*;
+
+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
+}
}
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
index 6a20fdcc01..3fe69a45d3 100755
--- 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
@@ -1,227 +1,227 @@
-package org.eclipse.swt.dnd;
-
-/*
+package org.eclipse.swt.dnd;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-import org.eclipse.swt.internal.ole.win32.*;
-import org.eclipse.swt.internal.win32.*;
-
-/**
- * The class <code>ByteArrayTransfer</code> provides a platform specific
- * mechanism for converting a java <code>byte[]</code> to a platform
- * specific representation of the byte array and vice versa. See
- * <code>Transfer</code> for additional information.
- *
- * <p><code>ByteArrayTransfer</code> is never used directly but is sub-classed
- * by transfer agents that convert between data in a java format such as a
- * <code>String</code> and a platform specific byte array.
- *
- * <p>If the data you are converting <b>does not</b> map to a
- * <code>byte[]</code>, you should sub-class <code>Transfer</code> directly
- * and do your own mapping to a platform data type.</p>
- *
- * <p>The following snippet shows a sublcass of ByteArrayTransfer that transfers
- * data defined by the class <code>MyType</code>.</p>
- *
- * <pre><code>
- * public class MyType {
- * public String fileName;
- * public long fileLength;
- * public long lastModified;
- * }
- * </code></pre>
- *
- * <code><pre>
- * public class MyTypeTransfer extends ByteArrayTransfer {
- *
- * private static final String MYTYPENAME = "my_type_name";
- * private static final int MYTYPEID = registerType(MYTYPENAME);
- * private static MyTypeTransfer _instance = new MyTypeTransfer();
- *
- * private MyTypeTransfer() {}
- *
- * public static MyTypeTransfer getInstance () {
- * return _instance;
- * }
- * public void javaToNative (Object object, TransferData transferData) {
- * if (object == null || !(object instanceof MyType[])) return;
- *
- * if (isSupportedType(transferData)) {
- * MyType[] myTypes = (MyType[]) object;
- * try {
- * // write data to a byte array and then ask super to convert to pMedium
- * ByteArrayOutputStream out = new ByteArrayOutputStream();
- * DataOutputStream writeOut = new DataOutputStream(out);
- * for (int i = 0, length = myTypes.length; i < length; i++){
- * byte[] buffer = myTypes[i].fileName.getBytes();
- * writeOut.writeInt(buffer.length);
- * writeOut.write(buffer);
- * writeOut.writeLong(myTypes[i].fileLength);
- * writeOut.writeLong(myTypes[i].lastModified);
- * }
- * byte[] buffer = out.toByteArray();
- * writeOut.close();
- *
- * super.javaToNative(buffer, transferData);
- *
- * } catch (IOException e) {
- * }
- * }
- * }
- * public Object nativeToJava(TransferData transferData){
- *
- * if (isSupportedType(transferData)) {
- *
- * byte[] buffer = (byte[])super.nativeToJava(transferData);
- * if (buffer == null) return null;
- *
- * MyType[] myData = new MyType[0];
- * try {
- * ByteArrayInputStream in = new ByteArrayInputStream(buffer);
- * DataInputStream readIn = new DataInputStream(in);
- * while(readIn.available() > 20) {
- * MyType datum = new MyType();
- * int size = readIn.readInt();
- * byte[] name = new byte[size];
- * readIn.read(name);
- * datum.fileName = new String(name);
- * datum.fileLength = readIn.readLong();
- * datum.lastModified = readIn.readLong();
- * MyType[] newMyData = new MyType[myData.length + 1];
- * System.arraycopy(myData, 0, newMyData, 0, myData.length);
- * newMyData[myData.length] = datum;
- * myData = newMyData;
- * }
- * readIn.close();
- * } catch (IOException ex) {
- * return null;
- * }
- * return myData;
- * }
- *
- * return null;
- * }
- * protected String[] getTypeNames(){
- * return new String[]{MYTYPENAME};
- * }
- * protected int[] getTypeIds(){
- * return new int[] {MYTYPEID};
- * }
- * }
- */
-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){
- if (transferData == null) return false;
- 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;
-}
-
-/**
- * This implementation of <code>javaToNative</code> converts a java
- * <code>byte[]</code> to a platform specific representation. For additional
- * information see <code>Transfer#javaToNative</code>.
- *
- * @see Transfer#javaToNative
- *
- * @param object a java <code>byte[]</code> containing the data to be converted
- * @param transferData an empty <code>TransferData</code> object; this
- * object will be filled in on return with the platform specific format of the data
- */
-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;
-}
-
-/**
- * This implementation of <code>nativeToJava</code> converts a platform specific
- * representation of a byte array to a java <code>byte[]</code>.
- * For additional information see <code>Transfer#nativeToJava</code>.
- *
- * @see Transfer#nativeToJava
- *
- * @param transferData the platform specific representation of the data to be
- * been converted
- * @return a java <code>byte[]</code> containing the converted 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 hMem = stgmedium.unionField;
- int size = OS.GlobalSize(hMem);
- byte[] buffer = new byte[size];
- int ptr = OS.GlobalLock(hMem);
- OS.MoveMemory(buffer, ptr, size);
- OS.GlobalUnlock(hMem);
- OS.GlobalFree(hMem);
-
- return buffer;
-}
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+import org.eclipse.swt.internal.ole.win32.*;
+import org.eclipse.swt.internal.win32.*;
+
+/**
+ * The class <code>ByteArrayTransfer</code> provides a platform specific
+ * mechanism for converting a java <code>byte[]</code> to a platform
+ * specific representation of the byte array and vice versa. See
+ * <code>Transfer</code> for additional information.
+ *
+ * <p><code>ByteArrayTransfer</code> is never used directly but is sub-classed
+ * by transfer agents that convert between data in a java format such as a
+ * <code>String</code> and a platform specific byte array.
+ *
+ * <p>If the data you are converting <b>does not</b> map to a
+ * <code>byte[]</code>, you should sub-class <code>Transfer</code> directly
+ * and do your own mapping to a platform data type.</p>
+ *
+ * <p>The following snippet shows a sublcass of ByteArrayTransfer that transfers
+ * data defined by the class <code>MyType</code>.</p>
+ *
+ * <pre><code>
+ * public class MyType {
+ * public String fileName;
+ * public long fileLength;
+ * public long lastModified;
+ * }
+ * </code></pre>
+ *
+ * <code><pre>
+ * public class MyTypeTransfer extends ByteArrayTransfer {
+ *
+ * private static final String MYTYPENAME = "my_type_name";
+ * private static final int MYTYPEID = registerType(MYTYPENAME);
+ * private static MyTypeTransfer _instance = new MyTypeTransfer();
+ *
+ * private MyTypeTransfer() {}
+ *
+ * public static MyTypeTransfer getInstance () {
+ * return _instance;
+ * }
+ * public void javaToNative (Object object, TransferData transferData) {
+ * if (object == null || !(object instanceof MyType[])) return;
+ *
+ * if (isSupportedType(transferData)) {
+ * MyType[] myTypes = (MyType[]) object;
+ * try {
+ * // write data to a byte array and then ask super to convert to pMedium
+ * ByteArrayOutputStream out = new ByteArrayOutputStream();
+ * DataOutputStream writeOut = new DataOutputStream(out);
+ * for (int i = 0, length = myTypes.length; i < length; i++){
+ * byte[] buffer = myTypes[i].fileName.getBytes();
+ * writeOut.writeInt(buffer.length);
+ * writeOut.write(buffer);
+ * writeOut.writeLong(myTypes[i].fileLength);
+ * writeOut.writeLong(myTypes[i].lastModified);
+ * }
+ * byte[] buffer = out.toByteArray();
+ * writeOut.close();
+ *
+ * super.javaToNative(buffer, transferData);
+ *
+ * } catch (IOException e) {
+ * }
+ * }
+ * }
+ * public Object nativeToJava(TransferData transferData){
+ *
+ * if (isSupportedType(transferData)) {
+ *
+ * byte[] buffer = (byte[])super.nativeToJava(transferData);
+ * if (buffer == null) return null;
+ *
+ * MyType[] myData = new MyType[0];
+ * try {
+ * ByteArrayInputStream in = new ByteArrayInputStream(buffer);
+ * DataInputStream readIn = new DataInputStream(in);
+ * while(readIn.available() > 20) {
+ * MyType datum = new MyType();
+ * int size = readIn.readInt();
+ * byte[] name = new byte[size];
+ * readIn.read(name);
+ * datum.fileName = new String(name);
+ * datum.fileLength = readIn.readLong();
+ * datum.lastModified = readIn.readLong();
+ * MyType[] newMyData = new MyType[myData.length + 1];
+ * System.arraycopy(myData, 0, newMyData, 0, myData.length);
+ * newMyData[myData.length] = datum;
+ * myData = newMyData;
+ * }
+ * readIn.close();
+ * } catch (IOException ex) {
+ * return null;
+ * }
+ * return myData;
+ * }
+ *
+ * return null;
+ * }
+ * protected String[] getTypeNames(){
+ * return new String[]{MYTYPENAME};
+ * }
+ * protected int[] getTypeIds(){
+ * return new int[] {MYTYPEID};
+ * }
+ * }
+ */
+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){
+ if (transferData == null) return false;
+ 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;
+}
+
+/**
+ * This implementation of <code>javaToNative</code> converts a java
+ * <code>byte[]</code> to a platform specific representation. For additional
+ * information see <code>Transfer#javaToNative</code>.
+ *
+ * @see Transfer#javaToNative
+ *
+ * @param object a java <code>byte[]</code> containing the data to be converted
+ * @param transferData an empty <code>TransferData</code> object; this
+ * object will be filled in on return with the platform specific format of the data
+ */
+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;
+}
+
+/**
+ * This implementation of <code>nativeToJava</code> converts a platform specific
+ * representation of a byte array to a java <code>byte[]</code>.
+ * For additional information see <code>Transfer#nativeToJava</code>.
+ *
+ * @see Transfer#nativeToJava
+ *
+ * @param transferData the platform specific representation of the data to be
+ * been converted
+ * @return a java <code>byte[]</code> containing the converted 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 hMem = stgmedium.unionField;
+ int size = OS.GlobalSize(hMem);
+ byte[] buffer = new byte[size];
+ int ptr = OS.GlobalLock(hMem);
+ OS.MoveMemory(buffer, ptr, size);
+ OS.GlobalUnlock(hMem);
+ OS.GlobalFree(hMem);
+
+ 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
index 55c8460140..168e04707b 100755
--- 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
@@ -1,504 +1,504 @@
-package org.eclipse.swt.dnd;
-
-/*
+package org.eclipse.swt.dnd;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-import org.eclipse.swt.*;
-import org.eclipse.swt.internal.win32.*;
-import org.eclipse.swt.internal.ole.win32.*;
-import org.eclipse.swt.widgets.*;
-
-/**
- * The <code>Clipboard</code> provides a mechanism for transferring data from one
- * application to another or within an application.
- *
- * <p>IMPORTANT: This class is <em>not</em> intended to be subclassed.</p>
- */
-public class Clipboard {
-
- // ole interfaces
- private COMObject iDataObject;
- private int refCount;
- private Display display;
-
- private final int MAX_RETRIES = 10;
- private Transfer[] transferAgents = new Transfer[0];
- private Object[] data = new Object[0];
- private int CFSTR_PREFERREDDROPEFFECT;
-
-/**
- * Constructs a new instance of this class. Creating an instance of a Clipboard
- * may cause system resources to be allocated depending on the platform. It is therefore
- * mandatory that the Clipboard instance be disposed when no longer required.
- *
- * @param display the display on which to allocate the clipboard
- *
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
- * <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
- * </ul>
- *
- * @see Clipboard#dispose
- * @see Clipboard#checkSubclass
- */
-public Clipboard(Display display) {
- checkSubclass ();
- if (display == null) {
- display = Display.getCurrent();
- if (display == null) {
- display = Display.getDefault();
- }
- }
- if (display.getThread() != Thread.currentThread()) {
- SWT.error(SWT.ERROR_THREAD_INVALID_ACCESS);
- }
- this.display = display;
-
- TCHAR chFormatName = new TCHAR(0, "Preferred DropEffect", true); //$NON-NLS-1$
- CFSTR_PREFERREDDROPEFFECT = COM.RegisterClipboardFormat(chFormatName);
- createCOMInterfaces();
- this.AddRef();
-}
-/**
- * Checks that this class can be subclassed.
- * <p>
- * The SWT class library is intended to be subclassed
- * only at specific, controlled points. This method enforces this
- * rule unless it is overridden.
- * </p><p>
- * <em>IMPORTANT:</em> By providing an implementation of this
- * method that allows a subclass of a class which does not
- * normally allow subclassing to be created, the implementer
- * agrees to be fully responsible for the fact that any such
- * subclass will likely fail between SWT releases and will be
- * strongly platform specific. No support is provided for
- * user-written classes which are implemented in this fashion.
- * </p><p>
- * The ability to subclass outside of the allowed SWT classes
- * is intended purely to enable those not on the SWT development
- * team to implement patches in order to get around specific
- * limitations in advance of when those limitations can be
- * addressed by the team. Subclassing should not be attempted
- * without an intimate and detailed understanding of the hierarchy.
- * </p>
- *
- * @exception SWTException <ul>
- * <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
- * </ul>
- */
-protected void checkSubclass () {
- String name = getClass().getName ();
- String validName = Clipboard.class.getName();
- if (!validName.equals(name)) {
- DND.error (SWT.ERROR_INVALID_SUBCLASS);
- }
-}
-
-/**
- * Disposes of the operating system resources associated with the clipboard.
- * The data will still be available on the system clipboard after the dispose
- * method is called.
- *
- * <p>NOTE: On some platforms the data will not be available once the application
- * has exited or the display has been disposed.</p>
- */
-public void dispose () {
- if (display == null) return;
- this.Release();
- display = null;
-}
-
-/**
- * Retrieve the data of the specified type currently available on the system clipboard. Refer to the
- * specific subclass of <code>Tramsfer</code> to determine the type of object returned.
- *
- * <p>The following snippet shows text and RTF text being retrieved from the clipboard:</p>
- *
- * <code><pre>
- * Clipboard clipboard = new Clipboard(display);
- * TextTransfer textTransfer = TextTransfer.getInstance();
- * String textData = (String)clipboard.getContents(textTransfer);
- * if (textData != null) System.out.println("Text is "+textData);
- * RTFTransfer rtfTransfer = RTFTransfer.getInstance();
- * String rtfData = (String)clipboard.getContents(rtfTransfer);
- * if (rtfData != null) System.out.println("RTF Text is "+rtfData);
- * clipboard.dispose();
- * </code></pre>
- *
- * @see Transfer
- *
- * @param transfer the transfer agent for the type of data being requested
- *
- * @return the data obtained from the clipboard or null if no data of this type is available
- */
-public Object getContents(Transfer transfer) {
- if (display == null) SWT.error(SWT.ERROR_WIDGET_DISPOSED);
- if (display.isDisposed()) SWT.error(SWT.ERROR_DEVICE_DISPOSED);
- if (transfer == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
- int[] ppv = new int[1];
- int retries = 0;
- while ((COM.OleGetClipboard(ppv) != COM.S_OK) && retries < MAX_RETRIES) {
- // Clipboard may be in use by some other application.
- // Wait for 10 milliseconds before trying again.
- try {Thread.sleep(10);} catch (InterruptedException e) {}
- retries++;
- }
- if (retries == 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);
-}
-/**
- * Place data of the specified type on the system clipboard. More than one type of
- * data can be placed on the system clipboard at the same time. Setting the data
- * clears any previous data of the same type from the system clipboard and also
- * clears data of any other type currently on the system clipboard.
- *
- * <p>NOTE: On some platforms, the data is immediately copied to the system
- * clipboard but on other platforms it is provided upon request. As a result, if the
- * application modifes the data object it has set on the clipboard, that modification
- * may or may not be available when the data is subsequently requested.</p>
- *
- * <p>The following snippet shows text and RTF text being set on the clipboard:</p>
- *
- * <code><pre>
- * Clipboard clipboard = new Clipboard(display);
- * String textData = "Hello World";
- * String rtfData = "{\\rtf1\\b\\i Hello World}";
- * TextTransfer textTransfer = TextTransfer.getInstance();
- * RTFTransfer rtfTransfer = RTFTransfer.getInstance();
- * clipboard.setContents(new Object[]{textData, rtfData}, new Transfer[]{textTransfer, rtfTransfer});
- * clipboard.dispose();
- * </code></pre>
- *
- * @param data the data to be set in the clipboard
- * @param dataTypes the transfer agents that will convert the data to its platform
- * specific format; each entry in the data array must have a corresponding dataType
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if data is null or datatypes is null
- * or the length of data is not the same as the length of dataTypes</li>
- * </ul>
- * @exception SWTError <ul>
- * <li>ERROR_CANNOT_SET_CLIPBOARD - if the clipboard is locked or
- * otherwise unavailable</li>
- * </ul>
- */
-public void setContents(Object[] data, Transfer[] dataTypes){
- if (display == null) SWT.error(SWT.ERROR_WIDGET_DISPOSED);
- if (display.isDisposed()) SWT.error(SWT.ERROR_DEVICE_DISPOSED);
- 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){
- // Clipboard may be in use by some other application.
- // Wait for 10 milliseconds before trying again.
- try {Thread.sleep(10);} catch (InterruptedException e) {}
- retries++;
- }
- if (retries == MAX_RETRIES) {
- DND.error(DND.ERROR_CANNOT_SET_CLIPBOARD, result);
- }
-
- result = COM.OleIsCurrentClipboard(this.iDataObject.getAddress());
- if (result != COM.S_OK) {
- DND.error(DND.ERROR_CANNOT_SET_CLIPBOARD, result);
- }
-
- retries = 0;
- while ((COM.OleFlushClipboard() != COM.S_OK) && (retries < MAX_RETRIES)) {
- try {Thread.sleep(10);} catch (InterruptedException e) {}
- retries++;
- }
- if (retries == MAX_RETRIES) {
- DND.error(DND.ERROR_CANNOT_SET_CLIPBOARD, result);
- }
-
- 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
- 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 (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 + 1];
- for (int i = 0; i < allowedDataTypes.length; i++){
- formats[i] = allowedDataTypes[i].formatetc;
- }
- // include the drop effect format to specify a copy operation
- FORMATETC dropeffect = new FORMATETC();
- dropeffect.cfFormat = CFSTR_PREFERREDDROPEFFECT;
- dropeffect.dwAspect = COM.DVASPECT_CONTENT;
- dropeffect.lindex = -1;
- dropeffect.tymed = COM.TYMED_HGLOBAL;
- formats[formats.length -1] = dropeffect;
-
- 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;
-
- if (transferData.type == CFSTR_PREFERREDDROPEFFECT) {
- // specify that a copy operation is to be performed
- STGMEDIUM stgmedium = new STGMEDIUM();
- stgmedium.tymed = COM.TYMED_HGLOBAL;
- stgmedium.unionField = COM.GlobalAlloc(COM.GMEM_FIXED | COM.GMEM_ZEROINIT, 4);
- COM.MoveMemory(stgmedium.unionField, new int[] {COM.DROPEFFECT_COPY}, 4);
- stgmedium.pUnkForRelease = 0;
- COM.MoveMemory(pmedium, stgmedium, STGMEDIUM.sizeof);
- return COM.S_OK;
- }
-
- // 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;
-
- if (transferData.type == CFSTR_PREFERREDDROPEFFECT) return COM.S_OK;
-
- // 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.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;
-}
-
-/**
- * Returns a platform specific list of the data types currently available on the
- * system clipboard.
- *
- * <p>Note: <code>getAvailableTypeNames</code> is a utility for writing a Transfer
- * sub-class. It should NOT be used within an application because it provides
- * platform specific information.</p>
- *
- * @returns a platform specific list of the data types currently available on the
- * system clipboard
- */
-public String[] getAvailableTypeNames() {
- if (display == null) SWT.error(SWT.ERROR_WIDGET_DISPOSED);
- if (display.isDisposed()) SWT.error(SWT.ERROR_DEVICE_DISPOSED);
- 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;
- TCHAR buffer = new TCHAR(0, maxSize);
- int size = COM.GetClipboardFormatName(formatetc.cfFormat, buffer, maxSize);
- String type = null;
- if (size != 0) {
- type = buffer.toString(0, size);
- } else {
- switch (formatetc.cfFormat) {
- case COM.CF_HDROP:
- type = "CF_HDROP"; //$NON-NLS-1$
- break;
- case COM.CF_TEXT:
- type = "CF_TEXT"; //$NON-NLS-1$
- break;
- case COM.CF_BITMAP:
- type = "CF_BITMAP"; //$NON-NLS-1$
- break;
- case COM.CF_METAFILEPICT:
- type = "CF_METAFILEPICT"; //$NON-NLS-1$
- break;
- case COM.CF_SYLK:
- type = "CF_SYLK"; //$NON-NLS-1$
- break;
- case COM.CF_DIF:
- type = "CF_DIF"; //$NON-NLS-1$
- break;
- case COM.CF_TIFF:
- type = "CF_TIFF"; //$NON-NLS-1$
- break;
- case COM.CF_OEMTEXT:
- type = "CF_OEMTEXT"; //$NON-NLS-1$
- break;
- case COM.CF_DIB:
- type = "CF_DIB"; //$NON-NLS-1$
- break;
- case COM.CF_PALETTE:
- type = "CF_PALETTE"; //$NON-NLS-1$
- break;
- case COM.CF_PENDATA:
- type = "CF_PENDATA"; //$NON-NLS-1$
- break;
- case COM.CF_RIFF:
- type = "CF_RIFF"; //$NON-NLS-1$
- break;
- case COM.CF_WAVE:
- type = "CF_WAVE"; //$NON-NLS-1$
- break;
- case COM.CF_UNICODETEXT:
- type = "CF_UNICODETEXT"; //$NON-NLS-1$
- break;
- case COM.CF_ENHMETAFILE:
- type = "CF_ENHMETAFILE"; //$NON-NLS-1$
- break;
- case COM.CF_LOCALE:
- type = "CF_LOCALE"; //$NON-NLS-1$
- break;
- case COM.CF_MAX:
- type = "CF_MAX"; //$NON-NLS-1$
- break;
- default:
- continue;
- }
- }
-
- 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;
-
-}
-
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+import org.eclipse.swt.*;
+import org.eclipse.swt.internal.win32.*;
+import org.eclipse.swt.internal.ole.win32.*;
+import org.eclipse.swt.widgets.*;
+
+/**
+ * The <code>Clipboard</code> provides a mechanism for transferring data from one
+ * application to another or within an application.
+ *
+ * <p>IMPORTANT: This class is <em>not</em> intended to be subclassed.</p>
+ */
+public class Clipboard {
+
+ // ole interfaces
+ private COMObject iDataObject;
+ private int refCount;
+ private Display display;
+
+ private final int MAX_RETRIES = 10;
+ private Transfer[] transferAgents = new Transfer[0];
+ private Object[] data = new Object[0];
+ private int CFSTR_PREFERREDDROPEFFECT;
+
+/**
+ * Constructs a new instance of this class. Creating an instance of a Clipboard
+ * may cause system resources to be allocated depending on the platform. It is therefore
+ * mandatory that the Clipboard instance be disposed when no longer required.
+ *
+ * @param display the display on which to allocate the clipboard
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
+ * <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
+ * </ul>
+ *
+ * @see Clipboard#dispose
+ * @see Clipboard#checkSubclass
+ */
+public Clipboard(Display display) {
+ checkSubclass ();
+ if (display == null) {
+ display = Display.getCurrent();
+ if (display == null) {
+ display = Display.getDefault();
+ }
+ }
+ if (display.getThread() != Thread.currentThread()) {
+ SWT.error(SWT.ERROR_THREAD_INVALID_ACCESS);
+ }
+ this.display = display;
+
+ TCHAR chFormatName = new TCHAR(0, "Preferred DropEffect", true); //$NON-NLS-1$
+ CFSTR_PREFERREDDROPEFFECT = COM.RegisterClipboardFormat(chFormatName);
+ createCOMInterfaces();
+ this.AddRef();
+}
+/**
+ * Checks that this class can be subclassed.
+ * <p>
+ * The SWT class library is intended to be subclassed
+ * only at specific, controlled points. This method enforces this
+ * rule unless it is overridden.
+ * </p><p>
+ * <em>IMPORTANT:</em> By providing an implementation of this
+ * method that allows a subclass of a class which does not
+ * normally allow subclassing to be created, the implementer
+ * agrees to be fully responsible for the fact that any such
+ * subclass will likely fail between SWT releases and will be
+ * strongly platform specific. No support is provided for
+ * user-written classes which are implemented in this fashion.
+ * </p><p>
+ * The ability to subclass outside of the allowed SWT classes
+ * is intended purely to enable those not on the SWT development
+ * team to implement patches in order to get around specific
+ * limitations in advance of when those limitations can be
+ * addressed by the team. Subclassing should not be attempted
+ * without an intimate and detailed understanding of the hierarchy.
+ * </p>
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
+ * </ul>
+ */
+protected void checkSubclass () {
+ String name = getClass().getName ();
+ String validName = Clipboard.class.getName();
+ if (!validName.equals(name)) {
+ DND.error (SWT.ERROR_INVALID_SUBCLASS);
+ }
+}
+
+/**
+ * Disposes of the operating system resources associated with the clipboard.
+ * The data will still be available on the system clipboard after the dispose
+ * method is called.
+ *
+ * <p>NOTE: On some platforms the data will not be available once the application
+ * has exited or the display has been disposed.</p>
+ */
+public void dispose () {
+ if (display == null) return;
+ this.Release();
+ display = null;
+}
+
+/**
+ * Retrieve the data of the specified type currently available on the system clipboard. Refer to the
+ * specific subclass of <code>Tramsfer</code> to determine the type of object returned.
+ *
+ * <p>The following snippet shows text and RTF text being retrieved from the clipboard:</p>
+ *
+ * <code><pre>
+ * Clipboard clipboard = new Clipboard(display);
+ * TextTransfer textTransfer = TextTransfer.getInstance();
+ * String textData = (String)clipboard.getContents(textTransfer);
+ * if (textData != null) System.out.println("Text is "+textData);
+ * RTFTransfer rtfTransfer = RTFTransfer.getInstance();
+ * String rtfData = (String)clipboard.getContents(rtfTransfer);
+ * if (rtfData != null) System.out.println("RTF Text is "+rtfData);
+ * clipboard.dispose();
+ * </code></pre>
+ *
+ * @see Transfer
+ *
+ * @param transfer the transfer agent for the type of data being requested
+ *
+ * @return the data obtained from the clipboard or null if no data of this type is available
+ */
+public Object getContents(Transfer transfer) {
+ if (display == null) SWT.error(SWT.ERROR_WIDGET_DISPOSED);
+ if (display.isDisposed()) SWT.error(SWT.ERROR_DEVICE_DISPOSED);
+ if (transfer == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ int[] ppv = new int[1];
+ int retries = 0;
+ while ((COM.OleGetClipboard(ppv) != COM.S_OK) && retries < MAX_RETRIES) {
+ // Clipboard may be in use by some other application.
+ // Wait for 10 milliseconds before trying again.
+ try {Thread.sleep(10);} catch (InterruptedException e) {}
+ retries++;
+ }
+ if (retries == 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);
+}
+/**
+ * Place data of the specified type on the system clipboard. More than one type of
+ * data can be placed on the system clipboard at the same time. Setting the data
+ * clears any previous data of the same type from the system clipboard and also
+ * clears data of any other type currently on the system clipboard.
+ *
+ * <p>NOTE: On some platforms, the data is immediately copied to the system
+ * clipboard but on other platforms it is provided upon request. As a result, if the
+ * application modifes the data object it has set on the clipboard, that modification
+ * may or may not be available when the data is subsequently requested.</p>
+ *
+ * <p>The following snippet shows text and RTF text being set on the clipboard:</p>
+ *
+ * <code><pre>
+ * Clipboard clipboard = new Clipboard(display);
+ * String textData = "Hello World";
+ * String rtfData = "{\\rtf1\\b\\i Hello World}";
+ * TextTransfer textTransfer = TextTransfer.getInstance();
+ * RTFTransfer rtfTransfer = RTFTransfer.getInstance();
+ * clipboard.setContents(new Object[]{textData, rtfData}, new Transfer[]{textTransfer, rtfTransfer});
+ * clipboard.dispose();
+ * </code></pre>
+ *
+ * @param data the data to be set in the clipboard
+ * @param dataTypes the transfer agents that will convert the data to its platform
+ * specific format; each entry in the data array must have a corresponding dataType
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if data is null or datatypes is null
+ * or the length of data is not the same as the length of dataTypes</li>
+ * </ul>
+ * @exception SWTError <ul>
+ * <li>ERROR_CANNOT_SET_CLIPBOARD - if the clipboard is locked or
+ * otherwise unavailable</li>
+ * </ul>
+ */
+public void setContents(Object[] data, Transfer[] dataTypes){
+ if (display == null) SWT.error(SWT.ERROR_WIDGET_DISPOSED);
+ if (display.isDisposed()) SWT.error(SWT.ERROR_DEVICE_DISPOSED);
+ 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){
+ // Clipboard may be in use by some other application.
+ // Wait for 10 milliseconds before trying again.
+ try {Thread.sleep(10);} catch (InterruptedException e) {}
+ retries++;
+ }
+ if (retries == MAX_RETRIES) {
+ DND.error(DND.ERROR_CANNOT_SET_CLIPBOARD, result);
+ }
+
+ result = COM.OleIsCurrentClipboard(this.iDataObject.getAddress());
+ if (result != COM.S_OK) {
+ DND.error(DND.ERROR_CANNOT_SET_CLIPBOARD, result);
+ }
+
+ retries = 0;
+ while ((COM.OleFlushClipboard() != COM.S_OK) && (retries < MAX_RETRIES)) {
+ try {Thread.sleep(10);} catch (InterruptedException e) {}
+ retries++;
+ }
+ if (retries == MAX_RETRIES) {
+ DND.error(DND.ERROR_CANNOT_SET_CLIPBOARD, result);
+ }
+
+ 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
+ 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 (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 + 1];
+ for (int i = 0; i < allowedDataTypes.length; i++){
+ formats[i] = allowedDataTypes[i].formatetc;
+ }
+ // include the drop effect format to specify a copy operation
+ FORMATETC dropeffect = new FORMATETC();
+ dropeffect.cfFormat = CFSTR_PREFERREDDROPEFFECT;
+ dropeffect.dwAspect = COM.DVASPECT_CONTENT;
+ dropeffect.lindex = -1;
+ dropeffect.tymed = COM.TYMED_HGLOBAL;
+ formats[formats.length -1] = dropeffect;
+
+ 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;
+
+ if (transferData.type == CFSTR_PREFERREDDROPEFFECT) {
+ // specify that a copy operation is to be performed
+ STGMEDIUM stgmedium = new STGMEDIUM();
+ stgmedium.tymed = COM.TYMED_HGLOBAL;
+ stgmedium.unionField = COM.GlobalAlloc(COM.GMEM_FIXED | COM.GMEM_ZEROINIT, 4);
+ COM.MoveMemory(stgmedium.unionField, new int[] {COM.DROPEFFECT_COPY}, 4);
+ stgmedium.pUnkForRelease = 0;
+ COM.MoveMemory(pmedium, stgmedium, STGMEDIUM.sizeof);
+ return COM.S_OK;
+ }
+
+ // 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;
+
+ if (transferData.type == CFSTR_PREFERREDDROPEFFECT) return COM.S_OK;
+
+ // 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.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;
+}
+
+/**
+ * Returns a platform specific list of the data types currently available on the
+ * system clipboard.
+ *
+ * <p>Note: <code>getAvailableTypeNames</code> is a utility for writing a Transfer
+ * sub-class. It should NOT be used within an application because it provides
+ * platform specific information.</p>
+ *
+ * @returns a platform specific list of the data types currently available on the
+ * system clipboard
+ */
+public String[] getAvailableTypeNames() {
+ if (display == null) SWT.error(SWT.ERROR_WIDGET_DISPOSED);
+ if (display.isDisposed()) SWT.error(SWT.ERROR_DEVICE_DISPOSED);
+ 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;
+ TCHAR buffer = new TCHAR(0, maxSize);
+ int size = COM.GetClipboardFormatName(formatetc.cfFormat, buffer, maxSize);
+ String type = null;
+ if (size != 0) {
+ type = buffer.toString(0, size);
+ } else {
+ switch (formatetc.cfFormat) {
+ case COM.CF_HDROP:
+ type = "CF_HDROP"; //$NON-NLS-1$
+ break;
+ case COM.CF_TEXT:
+ type = "CF_TEXT"; //$NON-NLS-1$
+ break;
+ case COM.CF_BITMAP:
+ type = "CF_BITMAP"; //$NON-NLS-1$
+ break;
+ case COM.CF_METAFILEPICT:
+ type = "CF_METAFILEPICT"; //$NON-NLS-1$
+ break;
+ case COM.CF_SYLK:
+ type = "CF_SYLK"; //$NON-NLS-1$
+ break;
+ case COM.CF_DIF:
+ type = "CF_DIF"; //$NON-NLS-1$
+ break;
+ case COM.CF_TIFF:
+ type = "CF_TIFF"; //$NON-NLS-1$
+ break;
+ case COM.CF_OEMTEXT:
+ type = "CF_OEMTEXT"; //$NON-NLS-1$
+ break;
+ case COM.CF_DIB:
+ type = "CF_DIB"; //$NON-NLS-1$
+ break;
+ case COM.CF_PALETTE:
+ type = "CF_PALETTE"; //$NON-NLS-1$
+ break;
+ case COM.CF_PENDATA:
+ type = "CF_PENDATA"; //$NON-NLS-1$
+ break;
+ case COM.CF_RIFF:
+ type = "CF_RIFF"; //$NON-NLS-1$
+ break;
+ case COM.CF_WAVE:
+ type = "CF_WAVE"; //$NON-NLS-1$
+ break;
+ case COM.CF_UNICODETEXT:
+ type = "CF_UNICODETEXT"; //$NON-NLS-1$
+ break;
+ case COM.CF_ENHMETAFILE:
+ type = "CF_ENHMETAFILE"; //$NON-NLS-1$
+ break;
+ case COM.CF_LOCALE:
+ type = "CF_LOCALE"; //$NON-NLS-1$
+ break;
+ case COM.CF_MAX:
+ type = "CF_MAX"; //$NON-NLS-1$
+ break;
+ default:
+ continue;
+ }
+ }
+
+ 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;
+
+}
+
}
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
index ad44ffa67a..06fb79d174 100755
--- 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
@@ -1,522 +1,522 @@
-package org.eclipse.swt.dnd;
-
-/*
+package org.eclipse.swt.dnd;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-import org.eclipse.swt.*;
-import org.eclipse.swt.internal.ole.win32.*;
-import org.eclipse.swt.widgets.*;
-import org.eclipse.swt.internal.win32.*;
-
-/**
- *
- * <code>DragSource</code> defines the source object for a drag and drop transfer.
- *
- * <p>IMPORTANT: This class is <em>not</em> intended to be subclassed.</p>
- *
- * <p>A drag source is the object which originates a drag and drop operation. For the specified widget,
- * it defines the type of data that is available for dragging and the set of operations that can
- * be performed on that data. The operations can be any bit-wise combination of DND.MOVE, DND.COPY or
- * DND.LINK. The type of data that can be transferred is specified by subclasses of Transfer such as
- * TextTransfer or FileTransfer. The type of data transferred can be a predefined system type or it
- * can be a type defined by the application. For instructions on how to define your own transfer type,
- * refer to <code>ByteArrayTransfer</code>.</p>
- *
- * <p>You may have several DragSources in an application but you can only have one DragSource
- * per Control. Data dragged from this DragSource can be dropped on a site within this application
- * or it can be dropped on another application such as an external Text editor.</p>
- *
- * <p>The application supplies the content of the data being transferred by implementing the
- * <code>DragSourceListener</code> and associating it with the DragSource via DragSource#addDragListener.</p>
- *
- * <p>When a successful move operation occurs, the application is required to take the appropriate
- * action to remove the data from its display and remove any associated operating system resources or
- * internal references. Typically in a move operation, the drop target makes a copy of the data
- * and the drag source deletes the original. However, sometimes copying the data can take a long
- * time (such as copying a large file). Therefore, on some platforms, the drop target may actually
- * move the data in the operating system rather than make a copy. This is usually only done in
- * file transfers. In this case, the drag source is informed in the DragEnd event that a
- * DROP_TARGET_MOVE was performed. It is the responsibility of the drag source at this point to clean
- * up its displayed information. No action needs to be taken on the operating system resources.</p>
- *
- * <p> The following example shows a Label widget that allows text to be dragged from it.</p>
- *
- * <code><pre>
- * // Enable a label as a Drag Source
- * Label label = new Label(shell, SWT.NONE);
- * // This example will allow text to be dragged
- * Transfer[] types = new Transfer[] {TextTransfer.getInstance()};
- * // This example will allow the text to be copied or moved to the drop target
- * int operations = DND.DROP_MOVE | DND.DROP_COPY;
- *
- * DragSource source = new DragSource (label, operations);
- * source.setTransfer(types);
- * source.addDragListener (new DragSourceListener() {
- * public void dragStart(DragSourceEvent e) {
- * // Only start the drag if there is actually text in the
- * // label - this text will be what is dropped on the target.
- * if (label.getText().length() == 0) {
- * event.doit = false;
- * }
- * };
- * public void dragSetData (DragSourceEvent event) {
- * // A drop has been performed, so provide the data of the
- * // requested type.
- * // (Checking the type of the requested data is only
- * // necessary if the drag source supports more than
- * // one data type but is shown here as an example).
- * if (TextTransfer.getInstance().isSupportedType(event.dataType)){
- * event.data = label.getText();
- * }
- * }
- * public void dragFinished(DragSourceEvent event) {
- * // A Move operation has been performed so remove the data
- * // from the source
- * if (event.detail == DND.DROP_MOVE)
- * label.setText("");
- * }
- * });
- * </pre></code>
- *
- *
- * <dl>
- * <dt><b>Styles</b></dt> <dd>DND.DROP_NONE, DND.DROP_COPY, DND.DROP_MOVE, DND.DROP_LINK</dd>
- * <dt><b>Events</b></dt> <dd>DND.DragStart, DND.DragSetData, DND.DragEnd</dd>
- * </dl>
- */
-public class DragSource extends Widget {
-
- // ole interfaces
- 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;
-
- private int dataEffect;
-
- private static final String DRAGSOURCEID = "DragSource"; //$NON-NLS-1$
-/**
- * Creates a new <code>DragSource</code> to handle dragging from the specified <code>Control</code>.
- * Creating an instance of a DragSource may cause system resources to be allocated depending on the platform.
- * It is therefore mandatory that the DragSource instance be disposed when no longer required.
- *
- * @param control the <code>Control</code> that the user clicks on to initiate the drag
- * @param style the bitwise OR'ing of allowed operations; this may be a combination of any of
- * DND.DROP_NONE, DND.DROP_COPY, DND.DROP_MOVE, DND.DROP_LINK
- *
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
- * <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
- * @exception SWTError <ul>
- * <li>ERROR_CANNOT_INIT_DRAG - unable to initiate drag source</li>
- * </ul>
- *
- * @see DragSource#dispose
- * @see DragSource#checkSubclass
- * @see DND#DROP_NONE
- * @see DND#DROP_COPY
- * @see DND#DROP_MOVE
- * @see DND#DROP_LINK
- */
-public DragSource(Control control, int style) {
-
- super (control, checkStyle (style));
- this.control = control;
- if (control.getData(DRAGSOURCEID) != null)
- DND.error(DND.ERROR_CANNOT_INIT_DRAG);
- control.setData(DRAGSOURCEID, this);
- 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 the collection of listeners who will
- * be notified when a drag and drop operation is in progress, by sending
- * it one of the messages defined in the <code>DragSourceListener</code>
- * interface.
- *
- * <p><ul>
- * <li><code>dragStart</code> is called when the user has begun the actions required to drag the widget.
- * This event gives the application the chance to decide if a drag should be started.
- * <li><code>dragSetData</code> is called when the data is required from the drag source.
- * <li><code>dragFinished</code> is called when the drop has successfully completed (mouse up
- * over a valid target) or has been terminated (such as hitting the ESC key). Perform cleanup
- * such as removing data from the source side on a successful move operation.
- * </ul></p>
- *
- * @param listener the listener which should be notified
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see DragSourceListener
- * @see #removeDragListener
- * @see DragSourceEvent
- */
-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
- 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
- public int method7(int[] args) {return SetData(args[0], args[1], args[2]);}
- 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.setData(DRAGSOURCEID, null);
- control = null;
-
- transferAgents = null;
-}
-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 void disposeCOMInterfaces() {
- 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;
-
- dataEffect = DND.DROP_NONE; //dataEffect will be updated in SetData callback
- int[] pdwEffect = new int[1];
- int operations = opToOs(getStyle());
- int result = COM.DoDragDrop(iDataObject.getAddress(), iDropSource.getAddress(), operations, pdwEffect);
- int operation = osToOp(pdwEffect[0]);
- event = new DNDEvent();
- event.widget = this;
- event.time = OS.GetMessageTime();
- if (dataEffect == DND.DROP_MOVE && (operation == DND.DROP_NONE || operation == DND.DROP_COPY)) {
- dataEffect = DND.DROP_TARGET_MOVE;
- }
- if (dataEffect == DND.DROP_NONE) {
- dataEffect = operation;
- }
- event.detail = dataEffect;
- 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.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 from the collection of listeners who will
- * be notified when a drag and drop operation is in progress.
- *
- * @param listener the listener which should be notified
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see DragSourceListener
- * @see #addDragListener
- */
-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);
-}
-private static int CFSTR_PERFORMEDDROPEFFECT = Transfer.registerType("Performed DropEffect"); //$NON-NLS-1$
-private int SetData(int pFormatetc, int pmedium, int fRelease) {
- if (pFormatetc == 0 || pmedium == 0) return COM.E_INVALIDARG;
- FORMATETC formatetc = new FORMATETC();
- COM.MoveMemory(formatetc, pFormatetc, FORMATETC.sizeof);
- if (formatetc.cfFormat == CFSTR_PERFORMEDDROPEFFECT && formatetc.tymed == COM.TYMED_HGLOBAL) {
- STGMEDIUM stgmedium = new STGMEDIUM();
- COM.MoveMemory(stgmedium, pmedium,STGMEDIUM.sizeof);
- int[] ptrEffect = new int[1];
- OS.MoveMemory(ptrEffect, stgmedium.unionField,4);
- int[] effect = new int[1];
- OS.MoveMemory(effect, ptrEffect[0],4);
- dataEffect = osToOp(effect[0]);
- }
- if (fRelease == 1) {
- COM.ReleaseStgMedium(pmedium);
- }
- return COM.S_OK;
-}
-/**
- * Specifies the list of data types that can be transferred by this DragSource.
- * The application must be able to provide data to match each of these types when
- * a successful drop has occurred.
- *
- * @param transferAgents a list of Transfer objects which define the types of data that can be
- * dragged from this source
- */
-public void setTransfer(Transfer[] transferAgents){
- 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);
- }
-}
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+import org.eclipse.swt.*;
+import org.eclipse.swt.internal.ole.win32.*;
+import org.eclipse.swt.widgets.*;
+import org.eclipse.swt.internal.win32.*;
+
+/**
+ *
+ * <code>DragSource</code> defines the source object for a drag and drop transfer.
+ *
+ * <p>IMPORTANT: This class is <em>not</em> intended to be subclassed.</p>
+ *
+ * <p>A drag source is the object which originates a drag and drop operation. For the specified widget,
+ * it defines the type of data that is available for dragging and the set of operations that can
+ * be performed on that data. The operations can be any bit-wise combination of DND.MOVE, DND.COPY or
+ * DND.LINK. The type of data that can be transferred is specified by subclasses of Transfer such as
+ * TextTransfer or FileTransfer. The type of data transferred can be a predefined system type or it
+ * can be a type defined by the application. For instructions on how to define your own transfer type,
+ * refer to <code>ByteArrayTransfer</code>.</p>
+ *
+ * <p>You may have several DragSources in an application but you can only have one DragSource
+ * per Control. Data dragged from this DragSource can be dropped on a site within this application
+ * or it can be dropped on another application such as an external Text editor.</p>
+ *
+ * <p>The application supplies the content of the data being transferred by implementing the
+ * <code>DragSourceListener</code> and associating it with the DragSource via DragSource#addDragListener.</p>
+ *
+ * <p>When a successful move operation occurs, the application is required to take the appropriate
+ * action to remove the data from its display and remove any associated operating system resources or
+ * internal references. Typically in a move operation, the drop target makes a copy of the data
+ * and the drag source deletes the original. However, sometimes copying the data can take a long
+ * time (such as copying a large file). Therefore, on some platforms, the drop target may actually
+ * move the data in the operating system rather than make a copy. This is usually only done in
+ * file transfers. In this case, the drag source is informed in the DragEnd event that a
+ * DROP_TARGET_MOVE was performed. It is the responsibility of the drag source at this point to clean
+ * up its displayed information. No action needs to be taken on the operating system resources.</p>
+ *
+ * <p> The following example shows a Label widget that allows text to be dragged from it.</p>
+ *
+ * <code><pre>
+ * // Enable a label as a Drag Source
+ * Label label = new Label(shell, SWT.NONE);
+ * // This example will allow text to be dragged
+ * Transfer[] types = new Transfer[] {TextTransfer.getInstance()};
+ * // This example will allow the text to be copied or moved to the drop target
+ * int operations = DND.DROP_MOVE | DND.DROP_COPY;
+ *
+ * DragSource source = new DragSource (label, operations);
+ * source.setTransfer(types);
+ * source.addDragListener (new DragSourceListener() {
+ * public void dragStart(DragSourceEvent e) {
+ * // Only start the drag if there is actually text in the
+ * // label - this text will be what is dropped on the target.
+ * if (label.getText().length() == 0) {
+ * event.doit = false;
+ * }
+ * };
+ * public void dragSetData (DragSourceEvent event) {
+ * // A drop has been performed, so provide the data of the
+ * // requested type.
+ * // (Checking the type of the requested data is only
+ * // necessary if the drag source supports more than
+ * // one data type but is shown here as an example).
+ * if (TextTransfer.getInstance().isSupportedType(event.dataType)){
+ * event.data = label.getText();
+ * }
+ * }
+ * public void dragFinished(DragSourceEvent event) {
+ * // A Move operation has been performed so remove the data
+ * // from the source
+ * if (event.detail == DND.DROP_MOVE)
+ * label.setText("");
+ * }
+ * });
+ * </pre></code>
+ *
+ *
+ * <dl>
+ * <dt><b>Styles</b></dt> <dd>DND.DROP_NONE, DND.DROP_COPY, DND.DROP_MOVE, DND.DROP_LINK</dd>
+ * <dt><b>Events</b></dt> <dd>DND.DragStart, DND.DragSetData, DND.DragEnd</dd>
+ * </dl>
+ */
+public class DragSource extends Widget {
+
+ // ole interfaces
+ 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;
+
+ private int dataEffect;
+
+ private static final String DRAGSOURCEID = "DragSource"; //$NON-NLS-1$
+/**
+ * Creates a new <code>DragSource</code> to handle dragging from the specified <code>Control</code>.
+ * Creating an instance of a DragSource may cause system resources to be allocated depending on the platform.
+ * It is therefore mandatory that the DragSource instance be disposed when no longer required.
+ *
+ * @param control the <code>Control</code> that the user clicks on to initiate the drag
+ * @param style the bitwise OR'ing of allowed operations; this may be a combination of any of
+ * DND.DROP_NONE, DND.DROP_COPY, DND.DROP_MOVE, DND.DROP_LINK
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
+ * <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
+ * @exception SWTError <ul>
+ * <li>ERROR_CANNOT_INIT_DRAG - unable to initiate drag source</li>
+ * </ul>
+ *
+ * @see DragSource#dispose
+ * @see DragSource#checkSubclass
+ * @see DND#DROP_NONE
+ * @see DND#DROP_COPY
+ * @see DND#DROP_MOVE
+ * @see DND#DROP_LINK
+ */
+public DragSource(Control control, int style) {
+
+ super (control, checkStyle (style));
+ this.control = control;
+ if (control.getData(DRAGSOURCEID) != null)
+ DND.error(DND.ERROR_CANNOT_INIT_DRAG);
+ control.setData(DRAGSOURCEID, this);
+ 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 the collection of listeners who will
+ * be notified when a drag and drop operation is in progress, by sending
+ * it one of the messages defined in the <code>DragSourceListener</code>
+ * interface.
+ *
+ * <p><ul>
+ * <li><code>dragStart</code> is called when the user has begun the actions required to drag the widget.
+ * This event gives the application the chance to decide if a drag should be started.
+ * <li><code>dragSetData</code> is called when the data is required from the drag source.
+ * <li><code>dragFinished</code> is called when the drop has successfully completed (mouse up
+ * over a valid target) or has been terminated (such as hitting the ESC key). Perform cleanup
+ * such as removing data from the source side on a successful move operation.
+ * </ul></p>
+ *
+ * @param listener the listener which should be notified
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see DragSourceListener
+ * @see #removeDragListener
+ * @see DragSourceEvent
+ */
+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
+ 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
+ public int method7(int[] args) {return SetData(args[0], args[1], args[2]);}
+ 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.setData(DRAGSOURCEID, null);
+ control = null;
+
+ transferAgents = null;
+}
+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 void disposeCOMInterfaces() {
+ 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;
+
+ dataEffect = DND.DROP_NONE; //dataEffect will be updated in SetData callback
+ int[] pdwEffect = new int[1];
+ int operations = opToOs(getStyle());
+ int result = COM.DoDragDrop(iDataObject.getAddress(), iDropSource.getAddress(), operations, pdwEffect);
+ int operation = osToOp(pdwEffect[0]);
+ event = new DNDEvent();
+ event.widget = this;
+ event.time = OS.GetMessageTime();
+ if (dataEffect == DND.DROP_MOVE && (operation == DND.DROP_NONE || operation == DND.DROP_COPY)) {
+ dataEffect = DND.DROP_TARGET_MOVE;
+ }
+ if (dataEffect == DND.DROP_NONE) {
+ dataEffect = operation;
+ }
+ event.detail = dataEffect;
+ 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.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 from the collection of listeners who will
+ * be notified when a drag and drop operation is in progress.
+ *
+ * @param listener the listener which should be notified
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see DragSourceListener
+ * @see #addDragListener
+ */
+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);
+}
+private static int CFSTR_PERFORMEDDROPEFFECT = Transfer.registerType("Performed DropEffect"); //$NON-NLS-1$
+private int SetData(int pFormatetc, int pmedium, int fRelease) {
+ if (pFormatetc == 0 || pmedium == 0) return COM.E_INVALIDARG;
+ FORMATETC formatetc = new FORMATETC();
+ COM.MoveMemory(formatetc, pFormatetc, FORMATETC.sizeof);
+ if (formatetc.cfFormat == CFSTR_PERFORMEDDROPEFFECT && formatetc.tymed == COM.TYMED_HGLOBAL) {
+ STGMEDIUM stgmedium = new STGMEDIUM();
+ COM.MoveMemory(stgmedium, pmedium,STGMEDIUM.sizeof);
+ int[] ptrEffect = new int[1];
+ OS.MoveMemory(ptrEffect, stgmedium.unionField,4);
+ int[] effect = new int[1];
+ OS.MoveMemory(effect, ptrEffect[0],4);
+ dataEffect = osToOp(effect[0]);
+ }
+ if (fRelease == 1) {
+ COM.ReleaseStgMedium(pmedium);
+ }
+ return COM.S_OK;
+}
+/**
+ * Specifies the list of data types that can be transferred by this DragSource.
+ * The application must be able to provide data to match each of these types when
+ * a successful drop has occurred.
+ *
+ * @param transferAgents a list of Transfer objects which define the types of data that can be
+ * dragged from this source
+ */
+public void setTransfer(Transfer[] transferAgents){
+ 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
index 52fb95e98e..b95d8403d7 100755
--- 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
@@ -1,663 +1,663 @@
-package org.eclipse.swt.dnd;
-
-/*
+package org.eclipse.swt.dnd;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-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.*;
-
-/**
- *
- * Class <code>DropTarget</code> defines the target object for a drag and drop transfer.
- *
- * IMPORTANT: This class is <em>not</em> intended to be subclassed.
- *
- * <p>This class identifies the <code>Control</code> over which the user must position the cursor
- * in order to drop the data being transferred. It also specifies what data types can be dropped on
- * this control and what operations can be performed. You may have several DropTragets in an
- * application but there can only be a one to one mapping between a <code>Control</code> and a <code>DropTarget</code>.
- * The DropTarget can receive data from within the same application or from other applications
- * (such as text dragged from a text editor like Word).</p>
- *
- * <code><pre>
- * int operations = DND.DROP_MOVE | DND.DROP_COPY | DND.DROP_LINK;
- * Transfer[] types = new Transfer[] {TextTransfer.getInstance()};
- * DropTarget target = new DropTarget(label, operations);
- * target.setTransfer(types);
- * </code></pre>
- *
- * <p>The application is notified of data being dragged over this control and of when a drop occurs by
- * implementing the interface <code>DropTargetListener</code> which uses the class
- * <code>DropTargetEvent</code>. The application can modify the type of drag being performed
- * on this Control at any stage of the drag by modifying the <code>event.detail</code> field or the
- * <code>event.currentDataType</code> field. When the data is dropped, it is the responsibility of
- * the application to copy this data for its own purposes.
- *
- * <code><pre>
- * target.addDropListener (new DropTargetListener() {
- * public void dragEnter(DropTargetEvent event) {};
- * public void dragOver(DropTargetEvent event) {};
- * public void dragLeave(DropTargetEvent event) {};
- * public void dragOperationChanged(DropTargetEvent event) {};
- * public void dropAccept(DropTargetEvent event) {}
- * public void drop(DropTargetEvent event) {
- * // A drop has occurred, copy over the data
- * if (event.data == null) { // no data to copy, indicate failure in event.detail
- * event.detail = DND.DROP_NONE;
- * return;
- * }
- * label.setText ((String) event.data); // data copied to label text
- * }
- * });
- * </pre></code>
- *
- * <dl>
- * <dt><b>Styles</b></dt> <dd>DND.DROP_NONE, DND.DROP_COPY, DND.DROP_MOVE, DND.DROP_LINK</dd>
- * <dt><b>Events</b></dt> <dd>DND.DragEnter, DND.DragLeave, DND.DragOver, DND.DragOperationChanged,
- * DND.DropAccept, DND.Drop </dd>
- * </dl>
- */
-public class DropTarget extends Widget {
-
-
- // interfaces
- 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;
-
- private static final String DROPTARGETID = "DropTarget"; //$NON-NLS-1$
-/**
- * Creates a new <code>DropTarget</code> to allow data to be dropped on the specified
- * <code>Control</code>.
- * Creating an instance of a DropTarget may cause system resources to be allocated
- * depending on the platform. It is therefore mandatory that the DropTarget instance
- * be disposed when no longer required.
- *
- * @param control the <code>Control</code> over which the user positions the cursor to drop the data
- * @param style the bitwise OR'ing of allowed operations; this may be a combination of any of
- * DND.DROP_NONE, DND.DROP_COPY, DND.DROP_MOVE, DND.DROP_LINK
- *
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
- * <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
- * @exception SWTError <ul>
- * <li>ERROR_CANNOT_INIT_DROP - unable to initiate drop target</li>
- * </ul>
- *
- * @see DropTarget#dispose
- * @see DropTarget#checkSubclass
- * @see DND#DROP_NONE
- * @see DND#DROP_COPY
- * @see DND#DROP_MOVE
- * @see DND#DROP_LINK
- */
-public DropTarget(Control control, int style) {
-
- super (control, checkStyle(style));
- this.control = control;
- if (control.getData(DROPTARGETID) != null)
- DND.error(DND.ERROR_CANNOT_INIT_DROP);
- control.setData(DROPTARGETID, this);
- createCOMInterfaces();
- this.AddRef();
-
- 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 the collection of listeners who will
- * be notified when a drag and drop operation is in progress, by sending
- * it one of the messages defined in the <code>DropTargetListener</code>
- * interface.
- *
- * <p><ul>
- * <li><code>dragEnter</code> is called when the cursor has entered the drop target boundaries
- * <li><code>dragLeave</code> is called when the cursor has left the drop target boundaries and just before
- * the drop occurs or is cancelled.
- * <li><code>dragOperationChanged</code> is called when the operation being performed has changed
- * (usually due to the user changing the selected modifier key(s) while dragging)
- * <li><code>dragOver</code> is called when the cursor is moving over the drop target
- * <li><code>dropAccept</code> is called just before the drop is performed. The drop target is given
- * the chance to change the nature of the drop or veto the drop by setting the <code>event.detail</code> field
- * <li><code>drop</code> is called when the data is being dropped
- * </ul></p>
- *
- * @param listener the listener which should be notified
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see DropTargetListener
- * @see #removeDropListener
- * @see DropTargetEvent
- */
-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
- 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;
- control.setData(DROPTARGETID, null);
- transferAgents = null;
- control = null;
-
- COM.CoLockObjectExternal(iDropTarget.getAddress(), false, true);
-
- this.Release();
-
- COM.CoFreeUnusedLibraries();
-}
-private void disposeCOMInterfaces() {
- 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;
-
- // 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;
- }
- // assign operation if it is allowed
- keyState = getOperationFromKeyState(grfKeyState);
- int style = getStyle();
- if (keyState == DND.DROP_DEFAULT && (style & DND.DROP_DEFAULT) == 0) {
- keyState = DND.DROP_MOVE;
- }
- event.detail = DND.DROP_NONE;
- if ((keyState & style) == 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;
- }
-
- if (event.detail == DND.DROP_DEFAULT) {
- event.detail = DND.DROP_MOVE;
- }
- 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 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;
- }
-
- int oldKeyState = keyState;
- keyState = getOperationFromKeyState(grfKeyState);
- int style = getStyle();
- if (keyState == DND.DROP_DEFAULT && (style & DND.DROP_DEFAULT) == 0) {
- keyState = DND.DROP_MOVE;
- }
- try {
- if (keyState == oldKeyState) {
- event.detail = lastOperation;
- notifyListeners(DND.DragOver,event);
- } else {
- event.detail = DND.DROP_NONE;
- if ((keyState & style) == keyState){
- event.detail = keyState;
- }
- notifyListeners(DND.DragOperationChanged, event);
- }
- } catch (Throwable e) {
- OS.MoveMemory(pdwEffect, new int[] {COM.DROPEFFECT_NONE}, 4);
- return COM.S_OK;
- }
- if (event.detail == DND.DROP_DEFAULT) {
- event.detail = DND.DROP_MOVE;
- }
-
- // 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[] {opToOs(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 DND.DROP_LINK;
- }
- if (ctrl){
- //CTRL == COPY
- return DND.DROP_COPY;
- }
- if (shift){
- //CTRL == MOVE
- return DND.DROP_MOVE;
- }
-
- return DND.DROP_DEFAULT; // default operation
-}
-/**
- * Returns a list of the data types that can be transferred to this DropTarget.
- *
- * @return a list of the data types that can be transferred to this DropTarget
- */
-public Transfer[] getTransfer(){
- return transferAgents;
-}
-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.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 from the collection of listeners who will
- * be notified when a drag and drop operation is in progress.
- *
- * @param listener the listener which should be notified
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see DropTargetListener
- * @see #addDropListener
- */
-public void removeDropListener(DropTargetListener listener) {
- if (listener == null) DND.error (SWT.ERROR_NULL_ARGUMENT);
- removeListener (DND.DragEnter, listener);
- removeListener (DND.DragLeave, listener);
- removeListener (DND.DragOver, listener);
- removeListener (DND.DragOperationChanged, listener);
- removeListener (DND.Drop, listener);
- removeListener (DND.DropAccept, listener);
-}
-/**
- * Specifies the data types that can be transferred to this DropTarget. If data is
- * being dragged that does not match one of these types, the drop target will be notified of
- * the drag and drop operation but the currentDataType will be null and the operation
- * will be DND.NONE.
- *
- * @param transferAgents a list of Transfer objects which define the types of data that can be
- * dropped on this target
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if transferAgents is null</li>
- * </ul>
- */
-public void setTransfer(Transfer[] transferAgents){
- if (transferAgents == null) DND.error(SWT.ERROR_NULL_ARGUMENT);
- 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);
- }
-}
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+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.*;
+
+/**
+ *
+ * Class <code>DropTarget</code> defines the target object for a drag and drop transfer.
+ *
+ * IMPORTANT: This class is <em>not</em> intended to be subclassed.
+ *
+ * <p>This class identifies the <code>Control</code> over which the user must position the cursor
+ * in order to drop the data being transferred. It also specifies what data types can be dropped on
+ * this control and what operations can be performed. You may have several DropTragets in an
+ * application but there can only be a one to one mapping between a <code>Control</code> and a <code>DropTarget</code>.
+ * The DropTarget can receive data from within the same application or from other applications
+ * (such as text dragged from a text editor like Word).</p>
+ *
+ * <code><pre>
+ * int operations = DND.DROP_MOVE | DND.DROP_COPY | DND.DROP_LINK;
+ * Transfer[] types = new Transfer[] {TextTransfer.getInstance()};
+ * DropTarget target = new DropTarget(label, operations);
+ * target.setTransfer(types);
+ * </code></pre>
+ *
+ * <p>The application is notified of data being dragged over this control and of when a drop occurs by
+ * implementing the interface <code>DropTargetListener</code> which uses the class
+ * <code>DropTargetEvent</code>. The application can modify the type of drag being performed
+ * on this Control at any stage of the drag by modifying the <code>event.detail</code> field or the
+ * <code>event.currentDataType</code> field. When the data is dropped, it is the responsibility of
+ * the application to copy this data for its own purposes.
+ *
+ * <code><pre>
+ * target.addDropListener (new DropTargetListener() {
+ * public void dragEnter(DropTargetEvent event) {};
+ * public void dragOver(DropTargetEvent event) {};
+ * public void dragLeave(DropTargetEvent event) {};
+ * public void dragOperationChanged(DropTargetEvent event) {};
+ * public void dropAccept(DropTargetEvent event) {}
+ * public void drop(DropTargetEvent event) {
+ * // A drop has occurred, copy over the data
+ * if (event.data == null) { // no data to copy, indicate failure in event.detail
+ * event.detail = DND.DROP_NONE;
+ * return;
+ * }
+ * label.setText ((String) event.data); // data copied to label text
+ * }
+ * });
+ * </pre></code>
+ *
+ * <dl>
+ * <dt><b>Styles</b></dt> <dd>DND.DROP_NONE, DND.DROP_COPY, DND.DROP_MOVE, DND.DROP_LINK</dd>
+ * <dt><b>Events</b></dt> <dd>DND.DragEnter, DND.DragLeave, DND.DragOver, DND.DragOperationChanged,
+ * DND.DropAccept, DND.Drop </dd>
+ * </dl>
+ */
+public class DropTarget extends Widget {
+
+
+ // interfaces
+ 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;
+
+ private static final String DROPTARGETID = "DropTarget"; //$NON-NLS-1$
+/**
+ * Creates a new <code>DropTarget</code> to allow data to be dropped on the specified
+ * <code>Control</code>.
+ * Creating an instance of a DropTarget may cause system resources to be allocated
+ * depending on the platform. It is therefore mandatory that the DropTarget instance
+ * be disposed when no longer required.
+ *
+ * @param control the <code>Control</code> over which the user positions the cursor to drop the data
+ * @param style the bitwise OR'ing of allowed operations; this may be a combination of any of
+ * DND.DROP_NONE, DND.DROP_COPY, DND.DROP_MOVE, DND.DROP_LINK
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
+ * <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
+ * @exception SWTError <ul>
+ * <li>ERROR_CANNOT_INIT_DROP - unable to initiate drop target</li>
+ * </ul>
+ *
+ * @see DropTarget#dispose
+ * @see DropTarget#checkSubclass
+ * @see DND#DROP_NONE
+ * @see DND#DROP_COPY
+ * @see DND#DROP_MOVE
+ * @see DND#DROP_LINK
+ */
+public DropTarget(Control control, int style) {
+
+ super (control, checkStyle(style));
+ this.control = control;
+ if (control.getData(DROPTARGETID) != null)
+ DND.error(DND.ERROR_CANNOT_INIT_DROP);
+ control.setData(DROPTARGETID, this);
+ createCOMInterfaces();
+ this.AddRef();
+
+ 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 the collection of listeners who will
+ * be notified when a drag and drop operation is in progress, by sending
+ * it one of the messages defined in the <code>DropTargetListener</code>
+ * interface.
+ *
+ * <p><ul>
+ * <li><code>dragEnter</code> is called when the cursor has entered the drop target boundaries
+ * <li><code>dragLeave</code> is called when the cursor has left the drop target boundaries and just before
+ * the drop occurs or is cancelled.
+ * <li><code>dragOperationChanged</code> is called when the operation being performed has changed
+ * (usually due to the user changing the selected modifier key(s) while dragging)
+ * <li><code>dragOver</code> is called when the cursor is moving over the drop target
+ * <li><code>dropAccept</code> is called just before the drop is performed. The drop target is given
+ * the chance to change the nature of the drop or veto the drop by setting the <code>event.detail</code> field
+ * <li><code>drop</code> is called when the data is being dropped
+ * </ul></p>
+ *
+ * @param listener the listener which should be notified
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see DropTargetListener
+ * @see #removeDropListener
+ * @see DropTargetEvent
+ */
+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
+ 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;
+ control.setData(DROPTARGETID, null);
+ transferAgents = null;
+ control = null;
+
+ COM.CoLockObjectExternal(iDropTarget.getAddress(), false, true);
+
+ this.Release();
+
+ COM.CoFreeUnusedLibraries();
+}
+private void disposeCOMInterfaces() {
+ 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;
+
+ // 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;
+ }
+ // assign operation if it is allowed
+ keyState = getOperationFromKeyState(grfKeyState);
+ int style = getStyle();
+ if (keyState == DND.DROP_DEFAULT && (style & DND.DROP_DEFAULT) == 0) {
+ keyState = DND.DROP_MOVE;
+ }
+ event.detail = DND.DROP_NONE;
+ if ((keyState & style) == 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;
+ }
+
+ if (event.detail == DND.DROP_DEFAULT) {
+ event.detail = DND.DROP_MOVE;
+ }
+ 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 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;
+ }
+
+ int oldKeyState = keyState;
+ keyState = getOperationFromKeyState(grfKeyState);
+ int style = getStyle();
+ if (keyState == DND.DROP_DEFAULT && (style & DND.DROP_DEFAULT) == 0) {
+ keyState = DND.DROP_MOVE;
+ }
+ try {
+ if (keyState == oldKeyState) {
+ event.detail = lastOperation;
+ notifyListeners(DND.DragOver,event);
+ } else {
+ event.detail = DND.DROP_NONE;
+ if ((keyState & style) == keyState){
+ event.detail = keyState;
+ }
+ notifyListeners(DND.DragOperationChanged, event);
+ }
+ } catch (Throwable e) {
+ OS.MoveMemory(pdwEffect, new int[] {COM.DROPEFFECT_NONE}, 4);
+ return COM.S_OK;
+ }
+ if (event.detail == DND.DROP_DEFAULT) {
+ event.detail = DND.DROP_MOVE;
+ }
+
+ // 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[] {opToOs(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 DND.DROP_LINK;
+ }
+ if (ctrl){
+ //CTRL == COPY
+ return DND.DROP_COPY;
+ }
+ if (shift){
+ //CTRL == MOVE
+ return DND.DROP_MOVE;
+ }
+
+ return DND.DROP_DEFAULT; // default operation
+}
+/**
+ * Returns a list of the data types that can be transferred to this DropTarget.
+ *
+ * @return a list of the data types that can be transferred to this DropTarget
+ */
+public Transfer[] getTransfer(){
+ return transferAgents;
+}
+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.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 from the collection of listeners who will
+ * be notified when a drag and drop operation is in progress.
+ *
+ * @param listener the listener which should be notified
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see DropTargetListener
+ * @see #addDropListener
+ */
+public void removeDropListener(DropTargetListener listener) {
+ if (listener == null) DND.error (SWT.ERROR_NULL_ARGUMENT);
+ removeListener (DND.DragEnter, listener);
+ removeListener (DND.DragLeave, listener);
+ removeListener (DND.DragOver, listener);
+ removeListener (DND.DragOperationChanged, listener);
+ removeListener (DND.Drop, listener);
+ removeListener (DND.DropAccept, listener);
+}
+/**
+ * Specifies the data types that can be transferred to this DropTarget. If data is
+ * being dragged that does not match one of these types, the drop target will be notified of
+ * the drag and drop operation but the currentDataType will be null and the operation
+ * will be DND.NONE.
+ *
+ * @param transferAgents a list of Transfer objects which define the types of data that can be
+ * dropped on this target
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if transferAgents is null</li>
+ * </ul>
+ */
+public void setTransfer(Transfer[] transferAgents){
+ if (transferAgents == null) DND.error(SWT.ERROR_NULL_ARGUMENT);
+ 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
index e0299bac70..94bd075f2b 100755
--- 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
@@ -1,160 +1,160 @@
-package org.eclipse.swt.dnd;
-
-/*
+package org.eclipse.swt.dnd;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-import org.eclipse.swt.internal.ole.win32.*;
-import org.eclipse.swt.internal.win32.TCHAR;
-import org.eclipse.swt.internal.win32.DROPFILES;
-
-/**
- * The class <code>FileTransfer</code> provides a platform specific mechanism
- * for converting a list of files represented as a java <code>String[]</code> to a
- * platform specific representation of the data and vice versa.
- * Each <code>String</code> in the array contains the absolute path for a single
- * file or directory.
- * See <code>Transfer</code> for additional information.
- *
- * <p>An example of a java <code>String[]</code> containing a list of files is shown
- * below:</p>
- *
- * <code><pre>
- * File file1 = new File("C:\temp\file1");
- * File file2 = new File("C:\temp\file2");
- * String[] fileData = new String[2];
- * fileData[0] = file1.getAbsolutePath();
- * fileData[1] = file2.getAbsolutePath();
- * </code></pre>
- */
-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;
-}
-
-/**
- * This implementation of <code>javaToNative</code> converts a list of file names
- * represented by a java <code>String[]</code> to a platform specific representation.
- * Each <code>String</code> in the array contains the absolute path for a single
- * file or directory. For additional information see
- * <code>Transfer#javaToNative</code>.
- *
- * @param object a java <code>String[]</code> containing the file names to be
- * converted
- * @param transferData an empty <code>TransferData</code> 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;
- }
-
- if (isSupportedType(transferData)) {
-
- String[] fileNames = (String[]) object;
- StringBuffer allFiles = new StringBuffer();
- for (int i = 0; i < fileNames.length; i++) {
- allFiles.append(fileNames[i]);
- allFiles.append('\0'); // each name is null terminated
- }
- TCHAR buffer = new TCHAR(0, allFiles.toString(), true); // 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 = COM.IsUnicode ? 1 : 0;
-
- // 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 byteCount = buffer.length() * TCHAR.sizeof;
- int newPtr = COM.GlobalAlloc(COM.GMEM_FIXED | COM.GMEM_ZEROINIT, DROPFILES.sizeof + byteCount);
- COM.MoveMemory(newPtr, dropfiles, DROPFILES.sizeof);
- COM.MoveMemory(newPtr + DROPFILES.sizeof, buffer, byteCount);
-
- 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;
-}
-
-/**
- * This implementation of <code>nativeToJava</code> converts a platform specific
- * representation of a list of file names to a java <code>String[]</code>.
- * Each String in the array contains the absolute path for a single file or directory.
- * For additional information see <code>Transfer#nativeToJava</code>.
- *
- * @param transferData the platform specific representation of the data to be
- * been converted
- * @return a java <code>String[]</code> 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;
- TCHAR lpszFile = new TCHAR(0, size);
- // Get file name and append it to string
- COM.DragQueryFile(stgmedium.unionField, i, lpszFile, size);
- fileNames[i] = lpszFile.toString(0, lpszFile.strlen());
- }
- 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"}; //$NON-NLS-1$
-}
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+import org.eclipse.swt.internal.ole.win32.*;
+import org.eclipse.swt.internal.win32.TCHAR;
+import org.eclipse.swt.internal.win32.DROPFILES;
+
+/**
+ * The class <code>FileTransfer</code> provides a platform specific mechanism
+ * for converting a list of files represented as a java <code>String[]</code> to a
+ * platform specific representation of the data and vice versa.
+ * Each <code>String</code> in the array contains the absolute path for a single
+ * file or directory.
+ * See <code>Transfer</code> for additional information.
+ *
+ * <p>An example of a java <code>String[]</code> containing a list of files is shown
+ * below:</p>
+ *
+ * <code><pre>
+ * File file1 = new File("C:\temp\file1");
+ * File file2 = new File("C:\temp\file2");
+ * String[] fileData = new String[2];
+ * fileData[0] = file1.getAbsolutePath();
+ * fileData[1] = file2.getAbsolutePath();
+ * </code></pre>
+ */
+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;
+}
+
+/**
+ * This implementation of <code>javaToNative</code> converts a list of file names
+ * represented by a java <code>String[]</code> to a platform specific representation.
+ * Each <code>String</code> in the array contains the absolute path for a single
+ * file or directory. For additional information see
+ * <code>Transfer#javaToNative</code>.
+ *
+ * @param object a java <code>String[]</code> containing the file names to be
+ * converted
+ * @param transferData an empty <code>TransferData</code> 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;
+ }
+
+ if (isSupportedType(transferData)) {
+
+ String[] fileNames = (String[]) object;
+ StringBuffer allFiles = new StringBuffer();
+ for (int i = 0; i < fileNames.length; i++) {
+ allFiles.append(fileNames[i]);
+ allFiles.append('\0'); // each name is null terminated
+ }
+ TCHAR buffer = new TCHAR(0, allFiles.toString(), true); // 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 = COM.IsUnicode ? 1 : 0;
+
+ // 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 byteCount = buffer.length() * TCHAR.sizeof;
+ int newPtr = COM.GlobalAlloc(COM.GMEM_FIXED | COM.GMEM_ZEROINIT, DROPFILES.sizeof + byteCount);
+ COM.MoveMemory(newPtr, dropfiles, DROPFILES.sizeof);
+ COM.MoveMemory(newPtr + DROPFILES.sizeof, buffer, byteCount);
+
+ 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;
+}
+
+/**
+ * This implementation of <code>nativeToJava</code> converts a platform specific
+ * representation of a list of file names to a java <code>String[]</code>.
+ * Each String in the array contains the absolute path for a single file or directory.
+ * For additional information see <code>Transfer#nativeToJava</code>.
+ *
+ * @param transferData the platform specific representation of the data to be
+ * been converted
+ * @return a java <code>String[]</code> 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;
+ TCHAR lpszFile = new TCHAR(0, size);
+ // Get file name and append it to string
+ COM.DragQueryFile(stgmedium.unionField, i, lpszFile, size);
+ fileNames[i] = lpszFile.toString(0, lpszFile.strlen());
+ }
+ 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"}; //$NON-NLS-1$
+}
+}
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
index 277510c06b..efd6d01c7b 100755
--- 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
@@ -1,156 +1,156 @@
-package org.eclipse.swt.dnd;
-
-/*
+package org.eclipse.swt.dnd;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-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;
-}
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+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
index 67cc4feb08..51fdb45fe5 100755
--- 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
@@ -1,131 +1,131 @@
-package org.eclipse.swt.dnd;
-
-/*
+package org.eclipse.swt.dnd;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-import org.eclipse.swt.internal.win32.OS;
-import org.eclipse.swt.internal.ole.win32.*;
-
-/**
- * The class <code>RTFTransfer</code> provides a platform specific mechanism
- * for converting text in RTF format represented as a java <code>String</code>
- * to a platform specific representation of the data and vice versa. See
- * <code>Transfer</code> for additional information.
- *
- * <p>An example of a java <code>String</code> containing RTF text is shown
- * below:</p>
- *
- * <code><pre>
- * String rtfData = "{\\rtf1{\\colortbl;\\red255\\green0\\blue0;}\\uc1\\b\\i Hello World}";
- * </code></pre>
- */
-public class RTFTransfer extends ByteArrayTransfer {
-
- private static final String CF_RTF_NAME = "Rich Text Format"; //$NON-NLS-1$
- private static final int CF_RTF = registerType(CF_RTF_NAME);
- private static RTFTransfer _instance = new RTFTransfer();
- private static int CodePage = OS.GetACP ();
-
-private RTFTransfer() {}
-/**
- * Returns the singleton instance of the RTFTransfer class.
- *
- * @return the singleton instance of the RTFTransfer class
- */
-public static RTFTransfer getInstance () {
- return _instance;
-}
-
-/**
- * This implementation of <code>javaToNative</code> converts RTF-formatted text
- * represented by a java <code>String</code> to a platform specific representation.
- * For additional information see <code>Transfer#javaToNative</code>.
- *
- * @param object a java <code>String</code> containing RTF text
- * @param transferData an empty <code>TransferData</code> 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;
- }
- // CF_RTF is stored as a null terminated byte array
- if (isSupportedType(transferData)) {
- String string = (String)object;
- int count = string.length ();
- char [] buffer = new char [count + 1];
- string.getChars (0, count, buffer, 0);
- int cchMultiByte = OS.WideCharToMultiByte (CodePage, 0, buffer, -1, null, 0, null, null);
- if (cchMultiByte == 0) {
- transferData.stgmedium = new STGMEDIUM();
- transferData.result = COM.DV_E_STGMEDIUM;
- return;
- }
- int lpMultiByteStr = COM.GlobalAlloc(COM.GMEM_FIXED | COM.GMEM_ZEROINIT, cchMultiByte);
- OS.WideCharToMultiByte (CodePage, 0, buffer, -1, lpMultiByteStr, cchMultiByte, null, null);
- transferData.stgmedium = new STGMEDIUM();
- transferData.stgmedium.tymed = COM.TYMED_HGLOBAL;
- transferData.stgmedium.unionField = lpMultiByteStr;
- 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;
-}
-
-/**
- * This implementation of <code>nativeToJava</code> converts a platform specific
- * representation of RTF text to a java <code>String</code>.
- * For additional information see <code>Transfer#nativeToJava</code>.
- *
- * @param transferData the platform specific representation of the data to be
- * been converted
- * @return a java <code>String</code> containing RTF text 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;
- }
-
- IDataObject data = new IDataObject(transferData.pIDataObject);
- data.AddRef();
- STGMEDIUM stgmedium = new STGMEDIUM();
- FORMATETC formatetc = transferData.formatetc;
- stgmedium.tymed = COM.TYMED_HGLOBAL;
- transferData.result = data.GetData(formatetc, stgmedium);
- data.Release();
- if (transferData.result != COM.S_OK) return null;
-
- int hMem = stgmedium.unionField;
- int lpMultiByteStr = COM.GlobalLock(hMem);
- if (lpMultiByteStr != 0) {
- try {
- int cchWideChar = OS.MultiByteToWideChar (CodePage, OS.MB_PRECOMPOSED, lpMultiByteStr, -1, null, 0);
- if (cchWideChar != 0) {
- char[] lpWideCharStr = new char [cchWideChar - 1];
- OS.MultiByteToWideChar (CodePage, OS.MB_PRECOMPOSED, lpMultiByteStr, -1, lpWideCharStr, lpWideCharStr.length);
- return new String(lpWideCharStr);
- }
- } finally {
- COM.GlobalUnlock(hMem);
- }
- }
- return null;
-}
-protected int[] getTypeIds(){
- return new int[] {CF_RTF};
-}
-protected String[] getTypeNames(){
- return new String[] {"CF_RTF"}; //$NON-NLS-1$
-}
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+import org.eclipse.swt.internal.win32.OS;
+import org.eclipse.swt.internal.ole.win32.*;
+
+/**
+ * The class <code>RTFTransfer</code> provides a platform specific mechanism
+ * for converting text in RTF format represented as a java <code>String</code>
+ * to a platform specific representation of the data and vice versa. See
+ * <code>Transfer</code> for additional information.
+ *
+ * <p>An example of a java <code>String</code> containing RTF text is shown
+ * below:</p>
+ *
+ * <code><pre>
+ * String rtfData = "{\\rtf1{\\colortbl;\\red255\\green0\\blue0;}\\uc1\\b\\i Hello World}";
+ * </code></pre>
+ */
+public class RTFTransfer extends ByteArrayTransfer {
+
+ private static final String CF_RTF_NAME = "Rich Text Format"; //$NON-NLS-1$
+ private static final int CF_RTF = registerType(CF_RTF_NAME);
+ private static RTFTransfer _instance = new RTFTransfer();
+ private static int CodePage = OS.GetACP ();
+
+private RTFTransfer() {}
+/**
+ * Returns the singleton instance of the RTFTransfer class.
+ *
+ * @return the singleton instance of the RTFTransfer class
+ */
+public static RTFTransfer getInstance () {
+ return _instance;
+}
+
+/**
+ * This implementation of <code>javaToNative</code> converts RTF-formatted text
+ * represented by a java <code>String</code> to a platform specific representation.
+ * For additional information see <code>Transfer#javaToNative</code>.
+ *
+ * @param object a java <code>String</code> containing RTF text
+ * @param transferData an empty <code>TransferData</code> 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;
+ }
+ // CF_RTF is stored as a null terminated byte array
+ if (isSupportedType(transferData)) {
+ String string = (String)object;
+ int count = string.length ();
+ char [] buffer = new char [count + 1];
+ string.getChars (0, count, buffer, 0);
+ int cchMultiByte = OS.WideCharToMultiByte (CodePage, 0, buffer, -1, null, 0, null, null);
+ if (cchMultiByte == 0) {
+ transferData.stgmedium = new STGMEDIUM();
+ transferData.result = COM.DV_E_STGMEDIUM;
+ return;
+ }
+ int lpMultiByteStr = COM.GlobalAlloc(COM.GMEM_FIXED | COM.GMEM_ZEROINIT, cchMultiByte);
+ OS.WideCharToMultiByte (CodePage, 0, buffer, -1, lpMultiByteStr, cchMultiByte, null, null);
+ transferData.stgmedium = new STGMEDIUM();
+ transferData.stgmedium.tymed = COM.TYMED_HGLOBAL;
+ transferData.stgmedium.unionField = lpMultiByteStr;
+ 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;
+}
+
+/**
+ * This implementation of <code>nativeToJava</code> converts a platform specific
+ * representation of RTF text to a java <code>String</code>.
+ * For additional information see <code>Transfer#nativeToJava</code>.
+ *
+ * @param transferData the platform specific representation of the data to be
+ * been converted
+ * @return a java <code>String</code> containing RTF text 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;
+ }
+
+ IDataObject data = new IDataObject(transferData.pIDataObject);
+ data.AddRef();
+ STGMEDIUM stgmedium = new STGMEDIUM();
+ FORMATETC formatetc = transferData.formatetc;
+ stgmedium.tymed = COM.TYMED_HGLOBAL;
+ transferData.result = data.GetData(formatetc, stgmedium);
+ data.Release();
+ if (transferData.result != COM.S_OK) return null;
+
+ int hMem = stgmedium.unionField;
+ int lpMultiByteStr = COM.GlobalLock(hMem);
+ if (lpMultiByteStr != 0) {
+ try {
+ int cchWideChar = OS.MultiByteToWideChar (CodePage, OS.MB_PRECOMPOSED, lpMultiByteStr, -1, null, 0);
+ if (cchWideChar != 0) {
+ char[] lpWideCharStr = new char [cchWideChar - 1];
+ OS.MultiByteToWideChar (CodePage, OS.MB_PRECOMPOSED, lpMultiByteStr, -1, lpWideCharStr, lpWideCharStr.length);
+ return new String(lpWideCharStr);
+ }
+ } finally {
+ COM.GlobalUnlock(hMem);
+ }
+ }
+ return null;
+}
+protected int[] getTypeIds(){
+ return new int[] {CF_RTF};
+}
+protected String[] getTypeNames(){
+ return new String[] {"CF_RTF"}; //$NON-NLS-1$
+}
+}
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
index 5cdccd4a44..d09c340c09 100755
--- 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
@@ -1,118 +1,118 @@
-package org.eclipse.swt.dnd;
-
-/*
+package org.eclipse.swt.dnd;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-import org.eclipse.swt.graphics.*;
-import org.eclipse.swt.widgets.*;
-import org.eclipse.swt.internal.win32.LVITEM;
-import org.eclipse.swt.internal.win32.OS;
-
-class TableDragUnderEffect extends DragUnderEffect {
- private Table table;
- private TableItem[] selection = new TableItem[0];
- int currentEffect = DND.FEEDBACK_NONE;
-// private TableItem dropSelection
- private TableItem scrollItem;
- private long scrollBeginTime;
- private static final int SCROLL_HYSTERESIS = 400; // milli seconds
- private static final int SCROLL_WIDTH = 100; // pixels
-
-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;
- if (currentEffect == DND.FEEDBACK_NONE && effect != DND.FEEDBACK_NONE) {
- selection = table.getSelection();
- table.deselectAll();
- }
- scrollHover(effect, item, x, y);
- setDragUnderEffect(effect, item);
- if (currentEffect != DND.FEEDBACK_NONE && effect == DND.FEEDBACK_NONE) {
- table.setSelection(selection);
- selection = new TableItem[0];
- }
- currentEffect = effect;
-}
-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 ((effect & DND.FEEDBACK_SELECT) != 0) {
- setDropSelection(item);
- } else {
- if ((currentEffect & DND.FEEDBACK_SELECT) != 0) {
- setDropSelection(null);
- }
- }
-}
-private void setDropSelection (TableItem item) {
-// if (item == dropSelection) return;
-// if (dropSelection != null) table.deselectAll();
-// dropSelection = item;
-// if (dropSelection != null) table.setSelection(new TableItem[]{dropSelection});
-
- 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);
- }
-}
-private void scrollHover (int effect, TableItem item, int x, int y) {
- if ((effect & DND.FEEDBACK_SCROLL) == 0) {
- scrollBeginTime = 0;
- scrollItem = null;
- return;
- }
- if (scrollItem == item && scrollBeginTime != 0) {
- if (System.currentTimeMillis() >= scrollBeginTime) {
- scroll(item, x, y);
- scrollBeginTime = 0;
- scrollItem = null;
- }
- return;
- }
- scrollBeginTime = System.currentTimeMillis() + SCROLL_HYSTERESIS;
- scrollItem = item;
-}
-private void scroll(TableItem item, int x, int y) {
- if (item == null) return;
- Point coordinates = new Point(x, y);
- coordinates = table.toControl(coordinates);
- Rectangle area = table.getClientArea();
- TableItem showItem = null;
- int itemIndex = table.indexOf(item);
- if (coordinates.y - area.y < SCROLL_WIDTH) {
- showItem = table.getItem(Math.max(0, itemIndex - 1));
- } else if ((area.y + area.height - coordinates.y) < SCROLL_WIDTH) {
- showItem = table.getItem(Math.min(table.getItemCount() - 1, itemIndex + 1));
- }
- if (showItem != null) {
- table.showItem(showItem);
- }
-}
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.widgets.*;
+import org.eclipse.swt.internal.win32.LVITEM;
+import org.eclipse.swt.internal.win32.OS;
+
+class TableDragUnderEffect extends DragUnderEffect {
+ private Table table;
+ private TableItem[] selection = new TableItem[0];
+ int currentEffect = DND.FEEDBACK_NONE;
+// private TableItem dropSelection
+ private TableItem scrollItem;
+ private long scrollBeginTime;
+ private static final int SCROLL_HYSTERESIS = 400; // milli seconds
+ private static final int SCROLL_WIDTH = 100; // pixels
+
+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;
+ if (currentEffect == DND.FEEDBACK_NONE && effect != DND.FEEDBACK_NONE) {
+ selection = table.getSelection();
+ table.deselectAll();
+ }
+ scrollHover(effect, item, x, y);
+ setDragUnderEffect(effect, item);
+ if (currentEffect != DND.FEEDBACK_NONE && effect == DND.FEEDBACK_NONE) {
+ table.setSelection(selection);
+ selection = new TableItem[0];
+ }
+ currentEffect = effect;
+}
+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 ((effect & DND.FEEDBACK_SELECT) != 0) {
+ setDropSelection(item);
+ } else {
+ if ((currentEffect & DND.FEEDBACK_SELECT) != 0) {
+ setDropSelection(null);
+ }
+ }
+}
+private void setDropSelection (TableItem item) {
+// if (item == dropSelection) return;
+// if (dropSelection != null) table.deselectAll();
+// dropSelection = item;
+// if (dropSelection != null) table.setSelection(new TableItem[]{dropSelection});
+
+ 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);
+ }
+}
+private void scrollHover (int effect, TableItem item, int x, int y) {
+ if ((effect & DND.FEEDBACK_SCROLL) == 0) {
+ scrollBeginTime = 0;
+ scrollItem = null;
+ return;
+ }
+ if (scrollItem == item && scrollBeginTime != 0) {
+ if (System.currentTimeMillis() >= scrollBeginTime) {
+ scroll(item, x, y);
+ scrollBeginTime = 0;
+ scrollItem = null;
+ }
+ return;
+ }
+ scrollBeginTime = System.currentTimeMillis() + SCROLL_HYSTERESIS;
+ scrollItem = item;
+}
+private void scroll(TableItem item, int x, int y) {
+ if (item == null) return;
+ Point coordinates = new Point(x, y);
+ coordinates = table.toControl(coordinates);
+ Rectangle area = table.getClientArea();
+ TableItem showItem = null;
+ int itemIndex = table.indexOf(item);
+ if (coordinates.y - area.y < SCROLL_WIDTH) {
+ showItem = table.getItem(Math.max(0, itemIndex - 1));
+ } else if ((area.y + area.height - coordinates.y) < SCROLL_WIDTH) {
+ showItem = table.getItem(Math.min(table.getItemCount() - 1, itemIndex + 1));
+ }
+ if (showItem != null) {
+ table.showItem(showItem);
+ }
+}
+}
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
index 4a369a0d92..36e0c900ab 100755
--- 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
@@ -1,123 +1,123 @@
-package org.eclipse.swt.dnd;
-
-/*
+package org.eclipse.swt.dnd;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-import org.eclipse.swt.internal.ole.win32.COM;
-import org.eclipse.swt.internal.win32.TCHAR;
-import org.eclipse.swt.internal.ole.win32.STGMEDIUM;
-import org.eclipse.swt.internal.ole.win32.FORMATETC;
-import org.eclipse.swt.internal.ole.win32.IDataObject;
-
-/**
- * The class <code>TextTransfer</code> provides a platform specific mechanism
- * for converting plain text represented as a java <code>String</code>
- * to a platform specific representation of the data and vice versa. See
- * <code>Transfer</code> for additional information.
- *
- * <p>An example of a java <code>String</code> containing plain text is shown
- * below:</p>
- *
- * <code><pre>
- * String textData = "Hello World";
- * </code></pre>
- */
-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;
-}
-
-/**
- * This implementation of <code>javaToNative</code> converts plain text
- * represented by a java <code>String</code> to a platform specific representation.
- * For additional information see <code>Transfer#javaToNative</code>.
- *
- * @param object a java <code>String</code> containing text
- * @param transferData an empty <code>TransferData</code> 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;
- }
-
- if (isSupportedType(transferData)) {
- TCHAR buffer = new TCHAR(0, (String)object, true);
- int byteCount = buffer.length() * TCHAR.sizeof;
- int newPtr = COM.GlobalAlloc(COM.GMEM_FIXED | COM.GMEM_ZEROINIT, byteCount);
- COM.MoveMemory(newPtr, buffer, byteCount);
-
- 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;
-
-}
-
-/**
- * This implementation of <code>nativeToJava</code> converts a platform specific
- * representation of plain text to a java <code>String</code>.
- * For additional information see <code>Transfer#nativeToJava</code>.
- *
- * @param transferData the platform specific representation of the data to be
- * been converted
- * @return a java <code>String</code> containing text 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;
- }
-
- 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 hMem = stgmedium.unionField;
- /* Ensure byteCount is a multiple of 2 bytes on UNICODE platforms */
- int size = COM.GlobalSize(hMem) / TCHAR.sizeof * TCHAR.sizeof;
- TCHAR buffer = new TCHAR(0, size / TCHAR.sizeof);
- int ptr = COM.GlobalLock(hMem);
- COM.MoveMemory(buffer, ptr, size);
- COM.GlobalUnlock(hMem);
- COM.GlobalFree(hMem);
- return buffer.toString(0, buffer.strlen());
-}
-protected int[] getTypeIds(){
- return new int[] {COM.IsUnicode ? COM.CF_UNICODETEXT : COM.CF_TEXT};
-}
-protected String[] getTypeNames(){
- return new String[] {COM.IsUnicode ? "CF_UNICODETEXT" : "CF_TEXT"}; //$NON-NLS-1$//$NON-NLS-2$
-}
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+import org.eclipse.swt.internal.ole.win32.COM;
+import org.eclipse.swt.internal.win32.TCHAR;
+import org.eclipse.swt.internal.ole.win32.STGMEDIUM;
+import org.eclipse.swt.internal.ole.win32.FORMATETC;
+import org.eclipse.swt.internal.ole.win32.IDataObject;
+
+/**
+ * The class <code>TextTransfer</code> provides a platform specific mechanism
+ * for converting plain text represented as a java <code>String</code>
+ * to a platform specific representation of the data and vice versa. See
+ * <code>Transfer</code> for additional information.
+ *
+ * <p>An example of a java <code>String</code> containing plain text is shown
+ * below:</p>
+ *
+ * <code><pre>
+ * String textData = "Hello World";
+ * </code></pre>
+ */
+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;
+}
+
+/**
+ * This implementation of <code>javaToNative</code> converts plain text
+ * represented by a java <code>String</code> to a platform specific representation.
+ * For additional information see <code>Transfer#javaToNative</code>.
+ *
+ * @param object a java <code>String</code> containing text
+ * @param transferData an empty <code>TransferData</code> 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;
+ }
+
+ if (isSupportedType(transferData)) {
+ TCHAR buffer = new TCHAR(0, (String)object, true);
+ int byteCount = buffer.length() * TCHAR.sizeof;
+ int newPtr = COM.GlobalAlloc(COM.GMEM_FIXED | COM.GMEM_ZEROINIT, byteCount);
+ COM.MoveMemory(newPtr, buffer, byteCount);
+
+ 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;
+
+}
+
+/**
+ * This implementation of <code>nativeToJava</code> converts a platform specific
+ * representation of plain text to a java <code>String</code>.
+ * For additional information see <code>Transfer#nativeToJava</code>.
+ *
+ * @param transferData the platform specific representation of the data to be
+ * been converted
+ * @return a java <code>String</code> containing text 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;
+ }
+
+ 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 hMem = stgmedium.unionField;
+ /* Ensure byteCount is a multiple of 2 bytes on UNICODE platforms */
+ int size = COM.GlobalSize(hMem) / TCHAR.sizeof * TCHAR.sizeof;
+ TCHAR buffer = new TCHAR(0, size / TCHAR.sizeof);
+ int ptr = COM.GlobalLock(hMem);
+ COM.MoveMemory(buffer, ptr, size);
+ COM.GlobalUnlock(hMem);
+ COM.GlobalFree(hMem);
+ return buffer.toString(0, buffer.strlen());
+}
+protected int[] getTypeIds(){
+ return new int[] {COM.IsUnicode ? COM.CF_UNICODETEXT : COM.CF_TEXT};
+}
+protected String[] getTypeNames(){
+ return new String[] {COM.IsUnicode ? "CF_UNICODETEXT" : "CF_TEXT"}; //$NON-NLS-1$//$NON-NLS-2$
+}
+}
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
index d13b5520b2..5fb5ab2323 100755
--- 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
@@ -1,130 +1,130 @@
-package org.eclipse.swt.dnd;
-
-/*
+package org.eclipse.swt.dnd;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-import org.eclipse.swt.internal.ole.win32.COM;
-import org.eclipse.swt.internal.win32.TCHAR;
-
-/**
- * <code>Transfer</code> provides a mechanism for converting between a java
- * representation of data and a platform specific representation of data and
- * vice versa. It is used in data transfer operations such as drag and drop and
- * clipboard copy/paste.
- *
- * <p>You should only need to become familiar with this class if you are
- * implementing a Transfer subclass and you are unable to subclass the
- * ByteArrayTransfer class.</p>
- *
- * @see ByteArrayTransfer
- */
-public abstract class Transfer {
-
-/**
- * Returns a list of the platform specific data types that can be converted using
- * this transfer agent.
- *
- * <p>Only the data type fields of the <code>TransferData</code> objects are filled
- * in.</p>
- *
- * @return a list of the data types that can be converted using this transfer agent
- */
-abstract public TransferData[] getSupportedTypes();
-
-/**
- * Returns true if the <code>TransferData</code> data type can be converted
- * using this transfer agent.
- *
- * @param transferData a platform specific description of a data type; only the data
- * type fields of the <code>TransferData</code> object need to be filled in
- *
- * @return true if the transferData data type can be converted using this transfer
- * agent
- */
-abstract public boolean isSupportedType(TransferData transferData);
-
-/**
- * Returns the platform specfic ids of the data types that can be converted using
- * this transfer agent.
- *
- * @return the platform specfic ids of the data types that can be converted using
- * this transfer agent
- */
-abstract protected int[] getTypeIds();
-
-/**
- * Returns the platform specfic names of the data types that can be converted
- * using this transfer agent.
- *
- * @return the platform specfic names of the data types that can be converted
- * using this transfer agent.
- */
-abstract protected String[] getTypeNames();
-
-/**
- * Converts a java representation of data to a platform specific representation of
- * the data.
- *
- * <p>On a successful conversion, the transferData.result field will be set as follows:
- * <ul>
- * <li>Windows: COM.S_OK
- * <li>Motif: 1
- * <li>GTK: 1
- * <li>Photon: 1
- * </ul></p>
- *
- * <p>If this transfer agent is unable to perform the conversion, the transferData.result
- * field will be set to a failure value as follows:
- * <ul>
- * <li>Windows: COM.DV_E_TYMED or COM.E_FAIL
- * <li>Motif: 0
- * <li>GTK: 0
- * <li>Photon: 0
- * </ul></p>
- *
- * @param object a java representation of the data to be converted; the type of
- * Object that is passed in is dependant on the <code>Transfer</code> subclass.
- *
- * @param transferData an empty TransferData object; this object will be
- * filled in on return with the platform specific representation of the data
- */
- abstract protected void javaToNative (Object object, TransferData transferData);
-
-/**
- * Converts a platform specific representation of data to a java representation.
- *
- * @param transferData the platform specific representation of the data to be
- * converted
- *
- * @return a java representation of the converted data if the conversion was
- * successful; otherwise null. The type of Object that is returned is dependant
- * on the <code>Transfer</code> subclass
- */
- abstract protected Object nativeToJava(TransferData transferData);
-
-/**
- * Registers a name for a data type and returns the associated unique identifier.
- *
- * <p>You may register the same type more than once, the same unique identifier
- * will be returned if the type has been previously registered.</p>
- *
- * <p>Note: On windows, do <b>not</b> call this method with pre-defined
- * Clipboard Format types such as CF_TEXT or CF_BITMAP because the
- * pre-defined identifier will not be returned</p>
- *
- * @param formatName the name of a data type
- *
- * @return the unique identifier associated with 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
- TCHAR chFormatName = new TCHAR(0, formatName, true);
- return COM.RegisterClipboardFormat(chFormatName);
-}
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+import org.eclipse.swt.internal.ole.win32.COM;
+import org.eclipse.swt.internal.win32.TCHAR;
+
+/**
+ * <code>Transfer</code> provides a mechanism for converting between a java
+ * representation of data and a platform specific representation of data and
+ * vice versa. It is used in data transfer operations such as drag and drop and
+ * clipboard copy/paste.
+ *
+ * <p>You should only need to become familiar with this class if you are
+ * implementing a Transfer subclass and you are unable to subclass the
+ * ByteArrayTransfer class.</p>
+ *
+ * @see ByteArrayTransfer
+ */
+public abstract class Transfer {
+
+/**
+ * Returns a list of the platform specific data types that can be converted using
+ * this transfer agent.
+ *
+ * <p>Only the data type fields of the <code>TransferData</code> objects are filled
+ * in.</p>
+ *
+ * @return a list of the data types that can be converted using this transfer agent
+ */
+abstract public TransferData[] getSupportedTypes();
+
+/**
+ * Returns true if the <code>TransferData</code> data type can be converted
+ * using this transfer agent.
+ *
+ * @param transferData a platform specific description of a data type; only the data
+ * type fields of the <code>TransferData</code> object need to be filled in
+ *
+ * @return true if the transferData data type can be converted using this transfer
+ * agent
+ */
+abstract public boolean isSupportedType(TransferData transferData);
+
+/**
+ * Returns the platform specfic ids of the data types that can be converted using
+ * this transfer agent.
+ *
+ * @return the platform specfic ids of the data types that can be converted using
+ * this transfer agent
+ */
+abstract protected int[] getTypeIds();
+
+/**
+ * Returns the platform specfic names of the data types that can be converted
+ * using this transfer agent.
+ *
+ * @return the platform specfic names of the data types that can be converted
+ * using this transfer agent.
+ */
+abstract protected String[] getTypeNames();
+
+/**
+ * Converts a java representation of data to a platform specific representation of
+ * the data.
+ *
+ * <p>On a successful conversion, the transferData.result field will be set as follows:
+ * <ul>
+ * <li>Windows: COM.S_OK
+ * <li>Motif: 1
+ * <li>GTK: 1
+ * <li>Photon: 1
+ * </ul></p>
+ *
+ * <p>If this transfer agent is unable to perform the conversion, the transferData.result
+ * field will be set to a failure value as follows:
+ * <ul>
+ * <li>Windows: COM.DV_E_TYMED or COM.E_FAIL
+ * <li>Motif: 0
+ * <li>GTK: 0
+ * <li>Photon: 0
+ * </ul></p>
+ *
+ * @param object a java representation of the data to be converted; the type of
+ * Object that is passed in is dependant on the <code>Transfer</code> subclass.
+ *
+ * @param transferData an empty TransferData object; this object will be
+ * filled in on return with the platform specific representation of the data
+ */
+ abstract protected void javaToNative (Object object, TransferData transferData);
+
+/**
+ * Converts a platform specific representation of data to a java representation.
+ *
+ * @param transferData the platform specific representation of the data to be
+ * converted
+ *
+ * @return a java representation of the converted data if the conversion was
+ * successful; otherwise null. The type of Object that is returned is dependant
+ * on the <code>Transfer</code> subclass
+ */
+ abstract protected Object nativeToJava(TransferData transferData);
+
+/**
+ * Registers a name for a data type and returns the associated unique identifier.
+ *
+ * <p>You may register the same type more than once, the same unique identifier
+ * will be returned if the type has been previously registered.</p>
+ *
+ * <p>Note: On windows, do <b>not</b> call this method with pre-defined
+ * Clipboard Format types such as CF_TEXT or CF_BITMAP because the
+ * pre-defined identifier will not be returned</p>
+ *
+ * @param formatName the name of a data type
+ *
+ * @return the unique identifier associated with 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
+ TCHAR chFormatName = new TCHAR(0, formatName, true);
+ 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
index f1db7a48e0..0bcc4aa3b0 100755
--- 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
@@ -1,61 +1,61 @@
-package org.eclipse.swt.dnd;
-
-/*
+package org.eclipse.swt.dnd;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-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 converted by a transfer agent.
- *
- * <p>As an application writer, you do not need to know the specifics of
- * TransferData. TransferData instances are passed to a subclass of Transfer
- * and the Transfer object manages the platform specific issues.
- * You can ask a Transfer subclass if it can handle this data by calling
- * Transfer.isSupportedType(transferData).</p>
- *
- * <p>You should only need to become familiar with the fields in this class if you
- * are implementing a Transfer subclass and you are unable to subclass the
- * ByteArrayTransfer class.</p>
- */
-public class TransferData {
- /**
- * The type is a unique identifier of a system format or user defined format.
- * (Warning: This field is platform dependent)
- */
- public int type;
-
- /**
- * The formatetc structure is a generalized data transfer format, enhanced to
- * encompass a target device, the aspect, or view of the data, and
- * a storage medium.
- * (Warning: This field is platform dependent)
- */
- public FORMATETC formatetc;
-
- /**
- * The stgmedium structure is a generalized global memory handle used for
- * data transfer operations.
- * (Warning: This field is platform dependent)
- */
- public STGMEDIUM stgmedium;
-
- /**
- * The result field contains the result of converting a java data type into a
- * stgmedium value.
- * (Warning: This field is platform dependent)
- */
- public int result = COM.E_FAIL;
-
- /**
- * The pIDataObject is the address of an IDataObject OLE Interface which
- * provides access to the data associated with the transfer.
- * (Warning: This field is platform dependent)
- */
- public int pIDataObject;
-
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+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 converted by a transfer agent.
+ *
+ * <p>As an application writer, you do not need to know the specifics of
+ * TransferData. TransferData instances are passed to a subclass of Transfer
+ * and the Transfer object manages the platform specific issues.
+ * You can ask a Transfer subclass if it can handle this data by calling
+ * Transfer.isSupportedType(transferData).</p>
+ *
+ * <p>You should only need to become familiar with the fields in this class if you
+ * are implementing a Transfer subclass and you are unable to subclass the
+ * ByteArrayTransfer class.</p>
+ */
+public class TransferData {
+ /**
+ * The type is a unique identifier of a system format or user defined format.
+ * (Warning: This field is platform dependent)
+ */
+ public int type;
+
+ /**
+ * The formatetc structure is a generalized data transfer format, enhanced to
+ * encompass a target device, the aspect, or view of the data, and
+ * a storage medium.
+ * (Warning: This field is platform dependent)
+ */
+ public FORMATETC formatetc;
+
+ /**
+ * The stgmedium structure is a generalized global memory handle used for
+ * data transfer operations.
+ * (Warning: This field is platform dependent)
+ */
+ public STGMEDIUM stgmedium;
+
+ /**
+ * The result field contains the result of converting a java data type into a
+ * stgmedium value.
+ * (Warning: This field is platform dependent)
+ */
+ public int result = COM.E_FAIL;
+
+ /**
+ * The pIDataObject is the address of an IDataObject OLE Interface which
+ * provides access to the data associated with the transfer.
+ * (Warning: This field is platform dependent)
+ */
+ 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
index 760aceca31..26188343d3 100755
--- 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
@@ -1,215 +1,215 @@
-package org.eclipse.swt.dnd;
-
-/*
+package org.eclipse.swt.dnd;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-import org.eclipse.swt.graphics.*;
-import org.eclipse.swt.widgets.*;
-import org.eclipse.swt.internal.win32.OS;
-import org.eclipse.swt.SWT;
-
-class TreeDragUnderEffect extends DragUnderEffect {
-
- private Tree tree;
- private int currentEffect = DND.FEEDBACK_NONE;
- private TreeItem[] selection = new TreeItem[0];
-// private TreeItem dropSelection = null;
- private TreeItem scrollItem;
- private long scrollBeginTime;
- private static final int SCROLL_HYSTERESIS = 400; // milli seconds
- private static final int SCROLL_WIDTH = 100; // pixels
- private TreeItem expandItem;
- private long expandBeginTime;
- private static final int EXPAND_HYSTERESIS = 1000; // milli seconds
-
-TreeDragUnderEffect(Tree tree) {
- this.tree = tree;
-}
-void show(int effect, int x, int y) {
- effect = checkEffect(effect);
- TreeItem item = findItem(x, y);
- if (item == null) effect = DND.FEEDBACK_NONE;
- if (currentEffect == DND.FEEDBACK_NONE && effect != DND.FEEDBACK_NONE) {
- selection = tree.getSelection();
- tree.deselectAll();
- }
- scrollHover(effect, item, x, y);
- expandHover(effect, item, x, y);
- setDragUnderEffect(effect, item);
- if (currentEffect != DND.FEEDBACK_NONE && effect == DND.FEEDBACK_NONE) {
- tree.setSelection(selection);
- selection = new TreeItem[0];
- }
- currentEffect = effect;
-
-}
-private int checkEffect(int effect) {
- // Some effects are mutually exclusive. Make sure that only one of the mutually exclusive effects has been specified.
- int mask = DND.FEEDBACK_INSERT_AFTER | DND.FEEDBACK_INSERT_BEFORE | DND.FEEDBACK_SELECT;
- int bits = effect & mask;
- if (bits == DND.FEEDBACK_INSERT_AFTER || bits == DND.FEEDBACK_INSERT_BEFORE || bits == DND.FEEDBACK_SELECT) return effect;
- return (effect & ~mask);
-}
-private TreeItem findItem(int x, int y){
- Point coordinates = new Point(x, y);
- coordinates = tree.toControl(coordinates);
- Rectangle area = tree.getClientArea();
- if (!area.contains(coordinates)) return null;
-
- TreeItem item = tree.getItem(coordinates);
- if (item != null) return item;
-
- // Scan across the width of the tree.
- for (int x1 = area.x; x1 < area.x + area.width; x1++) {
- Point pt = new Point(x1, coordinates.y);
- item = tree.getItem(pt);
- if (item != null) return item;
- }
- // Check if we are just below the last item of the tree
- if (coordinates.y > area.y + area.height - tree.getItemHeight()) {;
- int y1 = area.y + area.height - tree.getItemHeight();
- Point pt = new Point(coordinates.x, y1);
- item = tree.getItem(pt);
- if (item != null) return item;
-
- // Scan across the width of the tree just above the bottom..
- for (int x1 = area.x; x1 < area.x + area.width; x1++) {
- pt = new Point(x1, y1);
- item = tree.getItem(pt);
- if (item != null) return item;
- }
- }
- return null;
-}
-private void setDragUnderEffect(int effect, TreeItem item) {
- if ((effect & DND.FEEDBACK_SELECT) != 0) {
- if ((currentEffect & DND.FEEDBACK_INSERT_AFTER) != 0 ||
- (currentEffect & DND.FEEDBACK_INSERT_BEFORE) != 0) {
- tree.setInsertMark(null, false);
- }
- setDropSelection(item);
- return;
- }
- if ((effect & DND.FEEDBACK_INSERT_AFTER) != 0 ||
- (effect & DND.FEEDBACK_INSERT_BEFORE) != 0) {
- if ((currentEffect & DND.FEEDBACK_SELECT) != 0) {
- setDropSelection(null);
- }
- tree.setInsertMark(item, (effect & DND.FEEDBACK_INSERT_BEFORE) != 0);
- return;
- }
- if ((currentEffect & DND.FEEDBACK_INSERT_AFTER) != 0 ||
- (currentEffect & DND.FEEDBACK_INSERT_BEFORE) != 0) {
- tree.setInsertMark(null, false);
- }
- if ((currentEffect & DND.FEEDBACK_SELECT) != 0) {
- setDropSelection(null);
- }
-}
-private void setDropSelection (TreeItem item) {
-// if (item == dropSelection) return;
-// if (dropSelection != null) tree.deselectAll();
-// dropSelection = item;
-// if (dropSelection != null) tree.setSelection(new TreeItem[]{dropSelection});
-
- int hNewItem = 0;
- if (item != null) hNewItem = item.handle;
- OS.SendMessage (tree.handle, OS.TVM_SELECTITEM, OS.TVIS_DROPHILITED, hNewItem);
-}
-private void scrollHover (int effect, TreeItem item, int x, int y) {
- if ((effect & DND.FEEDBACK_SCROLL) == 0) {
- scrollBeginTime = 0;
- scrollItem = null;
- return;
- }
- if (scrollItem == item && scrollBeginTime != 0) {
- if (System.currentTimeMillis() >= scrollBeginTime) {
- scroll(item, x, y);
- scrollBeginTime = 0;
- scrollItem = null;
- }
- return;
- }
- scrollBeginTime = System.currentTimeMillis() + SCROLL_HYSTERESIS;
- scrollItem = item;
-}
-private void scroll(TreeItem item, int x, int y) {
- if (item == null) return;
- Point coordinates = new Point(x, y);
- coordinates = tree.toControl(coordinates);
- Rectangle area = tree.getClientArea();
- TreeItem showItem = null;
- if (coordinates.y - area.y < SCROLL_WIDTH) {
- showItem = getPreviousVisibleItem(item);
- } else if ((area.y + area.height - coordinates.y) < SCROLL_WIDTH) {
- showItem = getNextVisibleItem(item, true);
- }
- if (showItem != null) {
- tree.showItem(showItem);
- }
-}
-private void expandHover (int effect, TreeItem item, int x, int y) {
- if ((effect & DND.FEEDBACK_EXPAND) == 0) {
- expandBeginTime = 0;
- expandItem = null;
- return;
- }
- if (expandItem == item && expandBeginTime != 0) {
- if (System.currentTimeMillis() >= expandBeginTime) {
- expand(item, x, y);
- expandBeginTime = 0;
- expandItem = null;
- }
- return;
- }
- expandBeginTime = System.currentTimeMillis() + EXPAND_HYSTERESIS;
- expandItem = item;
-}
-private void expand(TreeItem item, int x, int y) {
- if (item == null) return;
- if (item.getExpanded()) return;
- Event event = new Event();
- event.x = x;
- event.y = y;
- event.item = item;
- event.time = (int) System.currentTimeMillis();
- tree.notifyListeners(SWT.Expand, event);
- if (item.isDisposed()) return;
- item.setExpanded(true);
-}
-private TreeItem getNextVisibleItem(TreeItem item, boolean includeChildren) {
- // look down
- // neccesary on the first pass only
- if (includeChildren && item.getItemCount() > 0 && item.getExpanded()) {
- return item.getItems()[0];
- }
- // look sideways
- TreeItem parent = item.getParentItem();
- TreeItem[] peers = (parent != null) ? parent.getItems() : tree.getItems();
- for (int i = 0; i < peers.length - 1; i++) {
- if (peers[i] == item) return peers[i + 1];
- }
- // look up
- if (parent != null) return getNextVisibleItem(parent, false);
- return null;
-}
-private TreeItem getPreviousVisibleItem(TreeItem item) {
- // look sideways
- TreeItem parent = item.getParentItem();
- TreeItem[] peers = (parent != null) ? parent.getItems() : tree.getItems();
- for (int i = peers.length - 1; i > 0; i--) {
- if (peers[i] == item) {
- TreeItem peer = peers[i-1];
- if (!peer.getExpanded() || peer.getItemCount() == 0) return peer;
- TreeItem[] peerItems = peer.getItems();
- return peerItems[peerItems.length - 1];
- }
- }
- // look up
- return parent;
-}
-
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.widgets.*;
+import org.eclipse.swt.internal.win32.OS;
+import org.eclipse.swt.SWT;
+
+class TreeDragUnderEffect extends DragUnderEffect {
+
+ private Tree tree;
+ private int currentEffect = DND.FEEDBACK_NONE;
+ private TreeItem[] selection = new TreeItem[0];
+// private TreeItem dropSelection = null;
+ private TreeItem scrollItem;
+ private long scrollBeginTime;
+ private static final int SCROLL_HYSTERESIS = 400; // milli seconds
+ private static final int SCROLL_WIDTH = 100; // pixels
+ private TreeItem expandItem;
+ private long expandBeginTime;
+ private static final int EXPAND_HYSTERESIS = 1000; // milli seconds
+
+TreeDragUnderEffect(Tree tree) {
+ this.tree = tree;
+}
+void show(int effect, int x, int y) {
+ effect = checkEffect(effect);
+ TreeItem item = findItem(x, y);
+ if (item == null) effect = DND.FEEDBACK_NONE;
+ if (currentEffect == DND.FEEDBACK_NONE && effect != DND.FEEDBACK_NONE) {
+ selection = tree.getSelection();
+ tree.deselectAll();
+ }
+ scrollHover(effect, item, x, y);
+ expandHover(effect, item, x, y);
+ setDragUnderEffect(effect, item);
+ if (currentEffect != DND.FEEDBACK_NONE && effect == DND.FEEDBACK_NONE) {
+ tree.setSelection(selection);
+ selection = new TreeItem[0];
+ }
+ currentEffect = effect;
+
+}
+private int checkEffect(int effect) {
+ // Some effects are mutually exclusive. Make sure that only one of the mutually exclusive effects has been specified.
+ int mask = DND.FEEDBACK_INSERT_AFTER | DND.FEEDBACK_INSERT_BEFORE | DND.FEEDBACK_SELECT;
+ int bits = effect & mask;
+ if (bits == DND.FEEDBACK_INSERT_AFTER || bits == DND.FEEDBACK_INSERT_BEFORE || bits == DND.FEEDBACK_SELECT) return effect;
+ return (effect & ~mask);
+}
+private TreeItem findItem(int x, int y){
+ Point coordinates = new Point(x, y);
+ coordinates = tree.toControl(coordinates);
+ Rectangle area = tree.getClientArea();
+ if (!area.contains(coordinates)) return null;
+
+ TreeItem item = tree.getItem(coordinates);
+ if (item != null) return item;
+
+ // Scan across the width of the tree.
+ for (int x1 = area.x; x1 < area.x + area.width; x1++) {
+ Point pt = new Point(x1, coordinates.y);
+ item = tree.getItem(pt);
+ if (item != null) return item;
+ }
+ // Check if we are just below the last item of the tree
+ if (coordinates.y > area.y + area.height - tree.getItemHeight()) {;
+ int y1 = area.y + area.height - tree.getItemHeight();
+ Point pt = new Point(coordinates.x, y1);
+ item = tree.getItem(pt);
+ if (item != null) return item;
+
+ // Scan across the width of the tree just above the bottom..
+ for (int x1 = area.x; x1 < area.x + area.width; x1++) {
+ pt = new Point(x1, y1);
+ item = tree.getItem(pt);
+ if (item != null) return item;
+ }
+ }
+ return null;
+}
+private void setDragUnderEffect(int effect, TreeItem item) {
+ if ((effect & DND.FEEDBACK_SELECT) != 0) {
+ if ((currentEffect & DND.FEEDBACK_INSERT_AFTER) != 0 ||
+ (currentEffect & DND.FEEDBACK_INSERT_BEFORE) != 0) {
+ tree.setInsertMark(null, false);
+ }
+ setDropSelection(item);
+ return;
+ }
+ if ((effect & DND.FEEDBACK_INSERT_AFTER) != 0 ||
+ (effect & DND.FEEDBACK_INSERT_BEFORE) != 0) {
+ if ((currentEffect & DND.FEEDBACK_SELECT) != 0) {
+ setDropSelection(null);
+ }
+ tree.setInsertMark(item, (effect & DND.FEEDBACK_INSERT_BEFORE) != 0);
+ return;
+ }
+ if ((currentEffect & DND.FEEDBACK_INSERT_AFTER) != 0 ||
+ (currentEffect & DND.FEEDBACK_INSERT_BEFORE) != 0) {
+ tree.setInsertMark(null, false);
+ }
+ if ((currentEffect & DND.FEEDBACK_SELECT) != 0) {
+ setDropSelection(null);
+ }
+}
+private void setDropSelection (TreeItem item) {
+// if (item == dropSelection) return;
+// if (dropSelection != null) tree.deselectAll();
+// dropSelection = item;
+// if (dropSelection != null) tree.setSelection(new TreeItem[]{dropSelection});
+
+ int hNewItem = 0;
+ if (item != null) hNewItem = item.handle;
+ OS.SendMessage (tree.handle, OS.TVM_SELECTITEM, OS.TVIS_DROPHILITED, hNewItem);
+}
+private void scrollHover (int effect, TreeItem item, int x, int y) {
+ if ((effect & DND.FEEDBACK_SCROLL) == 0) {
+ scrollBeginTime = 0;
+ scrollItem = null;
+ return;
+ }
+ if (scrollItem == item && scrollBeginTime != 0) {
+ if (System.currentTimeMillis() >= scrollBeginTime) {
+ scroll(item, x, y);
+ scrollBeginTime = 0;
+ scrollItem = null;
+ }
+ return;
+ }
+ scrollBeginTime = System.currentTimeMillis() + SCROLL_HYSTERESIS;
+ scrollItem = item;
+}
+private void scroll(TreeItem item, int x, int y) {
+ if (item == null) return;
+ Point coordinates = new Point(x, y);
+ coordinates = tree.toControl(coordinates);
+ Rectangle area = tree.getClientArea();
+ TreeItem showItem = null;
+ if (coordinates.y - area.y < SCROLL_WIDTH) {
+ showItem = getPreviousVisibleItem(item);
+ } else if ((area.y + area.height - coordinates.y) < SCROLL_WIDTH) {
+ showItem = getNextVisibleItem(item, true);
+ }
+ if (showItem != null) {
+ tree.showItem(showItem);
+ }
+}
+private void expandHover (int effect, TreeItem item, int x, int y) {
+ if ((effect & DND.FEEDBACK_EXPAND) == 0) {
+ expandBeginTime = 0;
+ expandItem = null;
+ return;
+ }
+ if (expandItem == item && expandBeginTime != 0) {
+ if (System.currentTimeMillis() >= expandBeginTime) {
+ expand(item, x, y);
+ expandBeginTime = 0;
+ expandItem = null;
+ }
+ return;
+ }
+ expandBeginTime = System.currentTimeMillis() + EXPAND_HYSTERESIS;
+ expandItem = item;
+}
+private void expand(TreeItem item, int x, int y) {
+ if (item == null) return;
+ if (item.getExpanded()) return;
+ Event event = new Event();
+ event.x = x;
+ event.y = y;
+ event.item = item;
+ event.time = (int) System.currentTimeMillis();
+ tree.notifyListeners(SWT.Expand, event);
+ if (item.isDisposed()) return;
+ item.setExpanded(true);
+}
+private TreeItem getNextVisibleItem(TreeItem item, boolean includeChildren) {
+ // look down
+ // neccesary on the first pass only
+ if (includeChildren && item.getItemCount() > 0 && item.getExpanded()) {
+ return item.getItems()[0];
+ }
+ // look sideways
+ TreeItem parent = item.getParentItem();
+ TreeItem[] peers = (parent != null) ? parent.getItems() : tree.getItems();
+ for (int i = 0; i < peers.length - 1; i++) {
+ if (peers[i] == item) return peers[i + 1];
+ }
+ // look up
+ if (parent != null) return getNextVisibleItem(parent, false);
+ return null;
+}
+private TreeItem getPreviousVisibleItem(TreeItem item) {
+ // look sideways
+ TreeItem parent = item.getParentItem();
+ TreeItem[] peers = (parent != null) ? parent.getItems() : tree.getItems();
+ for (int i = peers.length - 1; i > 0; i--) {
+ if (peers[i] == item) {
+ TreeItem peer = peers[i-1];
+ if (!peer.getExpanded() || peer.getItemCount() == 0) return peer;
+ TreeItem[] peerItems = peer.getItems();
+ return peerItems[peerItems.length - 1];
+ }
+ }
+ // look up
+ return parent;
+}
+
}
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
index e3d334ee97..f470f45a7a 100755
--- 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
@@ -1,1026 +1,1026 @@
-package org.eclipse.swt.internal.ole.win32;
-
-import java.util.Hashtable;
-import org.eclipse.swt.internal.*;
-import org.eclipse.swt.internal.win32.*;
-
-/*
+package org.eclipse.swt.internal.ole.win32;
+
+import java.util.Hashtable;
+import org.eclipse.swt.internal.*;
+import org.eclipse.swt.internal.win32.*;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-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); //$NON-NLS-1$
- }
- 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;
-}
-
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+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); //$NON-NLS-1$
+ }
+ 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/ole/win32/OLE.java b/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/ole/win32/OLE.java
index 37d84d235f..7948ff9dcb 100755
--- 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
@@ -1,430 +1,430 @@
-package org.eclipse.swt.ole.win32;
-
-/*
+package org.eclipse.swt.ole.win32;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-import org.eclipse.swt.*;
-import java.io.File;
-import org.eclipse.swt.internal.ole.win32.COM;
-import org.eclipse.swt.internal.win32.OS;
-import org.eclipse.swt.internal.win32.TCHAR;
-
-
-/**
- *
- * 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.
- public static final int E_FAIL = -2147467259; // Unspecified failure.
- public static final int E_INVALIDARG = -2147024809; // Invalid argument
- public static final int E_NOINTERFACE = -2147467262; // QueryInterface did not recognize the requested interface.
- public static final int E_NOTIMPL = -2147467263; // Not implemented
-
- public static final String IID_IUNKNOWN = "{00000000-0000-0000-C000-000000000046}";
- public static final String IID_IDISPATCH = "{00020400-0000-0000-C000-000000000046}";
-
- // 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.";//$NON-NLS-1$
- static final String ERROR_CANNOT_CREATE_FILE_MSG = "Failed to create file.";//$NON-NLS-1$
- static final String ERROR_CANNOT_CREATE_OBJECT_MSG = "Failed to create Ole Client.";//$NON-NLS-1$
- static final String ERROR_CANNOT_OPEN_FILE_MSG = "File does not exist, is not accessible to user or does not have the correct format.";//$NON-NLS-1$
- static final String ERROR_INTERFACE_NOT_FOUND_MSG = "Failed to find requested interface on OLE Object.";//$NON-NLS-1$
- static final String ERROR_INVALID_CLASSID_MSG = "Class ID not found in registry";//$NON-NLS-1$
- static final String ERROR_CANNOT_ACCESS_CLASSFACTORY_MSG = "Failed to get the class factory for the specified classID";//$NON-NLS-1$
- static final String ERROR_CANNOT_CREATE_LICENSED_OBJECT_MSG = "Failed to create Licensed instance";//$NON-NLS-1$
- static final String ERROR_OUT_OF_MEMORY_MSG = "Out of Memory";//$NON-NLS-1$
- static final String ERROR_CANNOT_CHANGE_VARIANT_TYPE_MSG = "Failed to change Variant type";//$NON-NLS-1$
- static final String ERROR_INVALID_INTERFACE_ADDRESS_MSG = "Invalid address received for Ole Interface.";//$NON-NLS-1$
- static final String ERROR_APPLICATION_NOT_FOUND_MSG = "Unable to find Application.";//$NON-NLS-1$
- static final String ERROR_ACTION_NOT_PERFORMED_MSG = "Action can not be performed.";//$NON-NLS-1$
-
-
-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;//$NON-NLS-1$
- throw new SWTException (code, msg);
- }
- case ERROR_CANNOT_CREATE_OBJECT : {
- String msg = ERROR_CANNOT_CREATE_OBJECT_MSG;
- if (hresult != 0) msg += " result = "+hresult;//$NON-NLS-1$
- throw new SWTException (code, msg);//$NON-NLS-1$
- }
- case ERROR_CANNOT_OPEN_FILE : {
- String msg = ERROR_CANNOT_OPEN_FILE_MSG;
- if (hresult != 0) msg += " result = "+hresult;//$NON-NLS-1$
- throw new SWTException (code, msg);
- }
- case ERROR_INTERFACE_NOT_FOUND : {
- String msg = ERROR_INTERFACE_NOT_FOUND_MSG;
- if (hresult != 0) msg += " result = "+hresult;//$NON-NLS-1$
- throw new SWTException (code, msg);
- }
- case ERROR_INVALID_CLASSID : {
- String msg = ERROR_INVALID_CLASSID_MSG;
- if (hresult != 0) msg += " result = "+hresult;//$NON-NLS-1$
- throw new SWTException (code, msg);
- }
- case ERROR_CANNOT_ACCESS_CLASSFACTORY : {
- String msg = ERROR_CANNOT_ACCESS_CLASSFACTORY_MSG;
- if (hresult != 0) msg += " result = "+hresult;//$NON-NLS-1$
- 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;//$NON-NLS-1$
- 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;//$NON-NLS-1$
- throw new SWTException (code, msg);
- }
- case ERROR_APPLICATION_NOT_FOUND : {
- String msg = ERROR_APPLICATION_NOT_FOUND_MSG;
- if (hresult != 0) msg += " result = "+hresult;//$NON-NLS-1$
- throw new SWTException (code, msg);
- }
- case ERROR_ACTION_NOT_PERFORMED : {
- String msg = ERROR_ACTION_NOT_PERFORMED_MSG;
- if (hresult != 0) msg += " result = "+hresult;//$NON-NLS-1$
- 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; //$NON-NLS-1$
- 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 ""; //$NON-NLS-1$
-
- if (extension.charAt (0) != '.') extension = "." + extension; //$NON-NLS-1$
-
- /* Use the character encoding for the default locale */
- TCHAR extensionKey = new TCHAR(0, extension, true);
- String result = getKeyValue(extensionKey);
- if (result != null) {
- // look for "<programID>\NotInsertable"
- TCHAR notInsertableKey = new TCHAR(0, result+"\\NotInsertable", true); //$NON-NLS-1$
- if (getKeyExists(notInsertableKey)) return ""; //$NON-NLS-1$
- // look for "<programID>\Insertable"
- TCHAR insertableKey = new TCHAR(0, result+"\\Insertable", true); //$NON-NLS-1$
- if (getKeyExists(insertableKey)) return result;
- // look for "<programID>\protocol\StdFileEditing\server"
- TCHAR serverKey = new TCHAR(0, result+"\\protocol\\StdFileEditing\\server", true); //$NON-NLS-1$
- if (getKeyExists(serverKey)) return result;
- }
-
- return ""; //$NON-NLS-1$
-}
-static String getKeyValue (TCHAR 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], (TCHAR) null, 0, null, null, lpcbData) == 0) {
- /* Use the character encoding for the default locale */
- TCHAR lpData = new TCHAR (0, lpcbData [0] / TCHAR.sizeof);
- if (OS.RegQueryValueEx (phkResult [0], null, 0, null, lpData, lpcbData) == 0) {
- int length = Math.max(0, lpData.length () - 1);
- result = lpData.toString (0, length);
- }
- }
- if (phkResult [0] != 0) OS.RegCloseKey (phkResult [0]);
- return result;
-}
-private static boolean getKeyExists (TCHAR 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);
-}
-
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+import org.eclipse.swt.*;
+import java.io.File;
+import org.eclipse.swt.internal.ole.win32.COM;
+import org.eclipse.swt.internal.win32.OS;
+import org.eclipse.swt.internal.win32.TCHAR;
+
+
+/**
+ *
+ * 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.
+ public static final int E_FAIL = -2147467259; // Unspecified failure.
+ public static final int E_INVALIDARG = -2147024809; // Invalid argument
+ public static final int E_NOINTERFACE = -2147467262; // QueryInterface did not recognize the requested interface.
+ public static final int E_NOTIMPL = -2147467263; // Not implemented
+
+ public static final String IID_IUNKNOWN = "{00000000-0000-0000-C000-000000000046}";
+ public static final String IID_IDISPATCH = "{00020400-0000-0000-C000-000000000046}";
+
+ // 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.";//$NON-NLS-1$
+ static final String ERROR_CANNOT_CREATE_FILE_MSG = "Failed to create file.";//$NON-NLS-1$
+ static final String ERROR_CANNOT_CREATE_OBJECT_MSG = "Failed to create Ole Client.";//$NON-NLS-1$
+ static final String ERROR_CANNOT_OPEN_FILE_MSG = "File does not exist, is not accessible to user or does not have the correct format.";//$NON-NLS-1$
+ static final String ERROR_INTERFACE_NOT_FOUND_MSG = "Failed to find requested interface on OLE Object.";//$NON-NLS-1$
+ static final String ERROR_INVALID_CLASSID_MSG = "Class ID not found in registry";//$NON-NLS-1$
+ static final String ERROR_CANNOT_ACCESS_CLASSFACTORY_MSG = "Failed to get the class factory for the specified classID";//$NON-NLS-1$
+ static final String ERROR_CANNOT_CREATE_LICENSED_OBJECT_MSG = "Failed to create Licensed instance";//$NON-NLS-1$
+ static final String ERROR_OUT_OF_MEMORY_MSG = "Out of Memory";//$NON-NLS-1$
+ static final String ERROR_CANNOT_CHANGE_VARIANT_TYPE_MSG = "Failed to change Variant type";//$NON-NLS-1$
+ static final String ERROR_INVALID_INTERFACE_ADDRESS_MSG = "Invalid address received for Ole Interface.";//$NON-NLS-1$
+ static final String ERROR_APPLICATION_NOT_FOUND_MSG = "Unable to find Application.";//$NON-NLS-1$
+ static final String ERROR_ACTION_NOT_PERFORMED_MSG = "Action can not be performed.";//$NON-NLS-1$
+
+
+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;//$NON-NLS-1$
+ throw new SWTException (code, msg);
+ }
+ case ERROR_CANNOT_CREATE_OBJECT : {
+ String msg = ERROR_CANNOT_CREATE_OBJECT_MSG;
+ if (hresult != 0) msg += " result = "+hresult;//$NON-NLS-1$
+ throw new SWTException (code, msg);//$NON-NLS-1$
+ }
+ case ERROR_CANNOT_OPEN_FILE : {
+ String msg = ERROR_CANNOT_OPEN_FILE_MSG;
+ if (hresult != 0) msg += " result = "+hresult;//$NON-NLS-1$
+ throw new SWTException (code, msg);
+ }
+ case ERROR_INTERFACE_NOT_FOUND : {
+ String msg = ERROR_INTERFACE_NOT_FOUND_MSG;
+ if (hresult != 0) msg += " result = "+hresult;//$NON-NLS-1$
+ throw new SWTException (code, msg);
+ }
+ case ERROR_INVALID_CLASSID : {
+ String msg = ERROR_INVALID_CLASSID_MSG;
+ if (hresult != 0) msg += " result = "+hresult;//$NON-NLS-1$
+ throw new SWTException (code, msg);
+ }
+ case ERROR_CANNOT_ACCESS_CLASSFACTORY : {
+ String msg = ERROR_CANNOT_ACCESS_CLASSFACTORY_MSG;
+ if (hresult != 0) msg += " result = "+hresult;//$NON-NLS-1$
+ 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;//$NON-NLS-1$
+ 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;//$NON-NLS-1$
+ throw new SWTException (code, msg);
+ }
+ case ERROR_APPLICATION_NOT_FOUND : {
+ String msg = ERROR_APPLICATION_NOT_FOUND_MSG;
+ if (hresult != 0) msg += " result = "+hresult;//$NON-NLS-1$
+ throw new SWTException (code, msg);
+ }
+ case ERROR_ACTION_NOT_PERFORMED : {
+ String msg = ERROR_ACTION_NOT_PERFORMED_MSG;
+ if (hresult != 0) msg += " result = "+hresult;//$NON-NLS-1$
+ 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; //$NON-NLS-1$
+ 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 ""; //$NON-NLS-1$
+
+ if (extension.charAt (0) != '.') extension = "." + extension; //$NON-NLS-1$
+
+ /* Use the character encoding for the default locale */
+ TCHAR extensionKey = new TCHAR(0, extension, true);
+ String result = getKeyValue(extensionKey);
+ if (result != null) {
+ // look for "<programID>\NotInsertable"
+ TCHAR notInsertableKey = new TCHAR(0, result+"\\NotInsertable", true); //$NON-NLS-1$
+ if (getKeyExists(notInsertableKey)) return ""; //$NON-NLS-1$
+ // look for "<programID>\Insertable"
+ TCHAR insertableKey = new TCHAR(0, result+"\\Insertable", true); //$NON-NLS-1$
+ if (getKeyExists(insertableKey)) return result;
+ // look for "<programID>\protocol\StdFileEditing\server"
+ TCHAR serverKey = new TCHAR(0, result+"\\protocol\\StdFileEditing\\server", true); //$NON-NLS-1$
+ if (getKeyExists(serverKey)) return result;
+ }
+
+ return ""; //$NON-NLS-1$
+}
+static String getKeyValue (TCHAR 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], (TCHAR) null, 0, null, null, lpcbData) == 0) {
+ /* Use the character encoding for the default locale */
+ TCHAR lpData = new TCHAR (0, lpcbData [0] / TCHAR.sizeof);
+ if (OS.RegQueryValueEx (phkResult [0], null, 0, null, lpData, lpcbData) == 0) {
+ int length = Math.max(0, lpData.length () - 1);
+ result = lpData.toString (0, length);
+ }
+ }
+ if (phkResult [0] != 0) OS.RegCloseKey (phkResult [0]);
+ return result;
+}
+private static boolean getKeyExists (TCHAR 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
index 02c9c035a2..e09542d0db 100755
--- 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
@@ -1,599 +1,599 @@
-package org.eclipse.swt.ole.win32;
-
-/*
+package org.eclipse.swt.ole.win32;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-import org.eclipse.swt.internal.ole.win32.*;
-import org.eclipse.swt.internal.win32.*;
-
-/**
- * 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(IDispatch idispatch) {
- if (idispatch == null) OLE.error(OLE.ERROR_INVALID_INTERFACE_ADDRESS);
- objIDispatch = idispatch;
- objIDispatch.AddRef();
-
- 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();
- }
-}
-/**
- * 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);
- if (names.length > 0) {
- data.name = names[0];
- }
- data.args = new OleParameterDescription[funcdesc.cParams];
- for (int i = 0; i < data.args.length; i++) {
- data.args[i] = new OleParameterDescription();
- if (names.length > i + 1) {
- 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 or null
- */
-public Variant getProperty(int dispIdMember) {
- Variant pVarResult = new Variant();
- int result = invoke(dispIdMember, COM.DISPATCH_PROPERTYGET, null, null, pVarResult);
- return (result == OLE.S_OK) ? pVarResult : null;
-}
-/**
- * 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
- *
- * @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 value of the property specified by the dispIdMember or null
- *
- * @since 2.0
- */
-public Variant getProperty(int dispIdMember, Variant[] rgvarg) {
- Variant pVarResult = new Variant();
- int result = invoke(dispIdMember, COM.DISPATCH_PROPERTYGET, rgvarg, null, pVarResult);
- return (result == OLE.S_OK) ? pVarResult : null;
-
-}
-/**
- * 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
- *
- * @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 value of the property specified by the dispIdMember or null
- *
- * @since 2.0
- */
-public Variant getProperty(int dispIdMember, Variant[] rgvarg, int[] rgdispidNamedArgs) {
- Variant pVarResult = new Variant();
- int result = invoke(dispIdMember, COM.DISPATCH_PROPERTYGET, rgvarg, rgdispidNamedArgs, pVarResult);
- return (result == OLE.S_OK) ? pVarResult : null;
-}
-
-/**
- * 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, COM.DISPATCH_METHOD, null, null, pVarResult);
- return (result == COM.S_OK) ? pVarResult : 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, COM.DISPATCH_METHOD, rgvarg, null, pVarResult);
- return (result == COM.S_OK) ? pVarResult : 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, COM.DISPATCH_METHOD, rgvarg, rgdispidNamedArgs, pVarResult);
- return (result == COM.S_OK) ? pVarResult : null;
-}
-private int invoke(int dispIdMember, int wFlags, 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, wFlags, 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, COM.DISPATCH_METHOD, 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, COM.DISPATCH_METHOD, 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, COM.DISPATCH_METHOD, 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) {
- Variant[] rgvarg2 = new Variant[] {rgvarg};
- int[] rgdispidNamedArgs = new int[] {COM.DISPID_PROPERTYPUT};
- int dwFlags = COM.DISPATCH_PROPERTYPUT;
- if ((rgvarg.getType() & COM.VT_BYREF) == COM.VT_BYREF)
- dwFlags = COM.DISPATCH_PROPERTYPUTREF;
- Variant pVarResult = new Variant();
- int result = invoke(dispIdMember, dwFlags, rgvarg2, rgdispidNamedArgs, pVarResult);
- return (result == COM.S_OK);
-}
-/**
- * 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 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 true if the operation was successful
- *
- * @since 2.0
- */
-public boolean setProperty(int dispIdMember, Variant[] rgvarg) {
- int[] rgdispidNamedArgs = new int[] {COM.DISPID_PROPERTYPUT};
- int dwFlags = COM.DISPATCH_PROPERTYPUT;
- for (int i = 0; i < rgvarg.length; i++) {
- if ((rgvarg[i].getType() & COM.VT_BYREF) == COM.VT_BYREF)
- dwFlags = COM.DISPATCH_PROPERTYPUTREF;
- }
- Variant pVarResult = new Variant();
- int result = invoke(dispIdMember, dwFlags, rgvarg, rgdispidNamedArgs, pVarResult);
- return (result == COM.S_OK);
-}
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+import org.eclipse.swt.internal.ole.win32.*;
+import org.eclipse.swt.internal.win32.*;
+
+/**
+ * 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(IDispatch idispatch) {
+ if (idispatch == null) OLE.error(OLE.ERROR_INVALID_INTERFACE_ADDRESS);
+ objIDispatch = idispatch;
+ objIDispatch.AddRef();
+
+ 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();
+ }
+}
+/**
+ * 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);
+ if (names.length > 0) {
+ data.name = names[0];
+ }
+ data.args = new OleParameterDescription[funcdesc.cParams];
+ for (int i = 0; i < data.args.length; i++) {
+ data.args[i] = new OleParameterDescription();
+ if (names.length > i + 1) {
+ 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 or null
+ */
+public Variant getProperty(int dispIdMember) {
+ Variant pVarResult = new Variant();
+ int result = invoke(dispIdMember, COM.DISPATCH_PROPERTYGET, null, null, pVarResult);
+ return (result == OLE.S_OK) ? pVarResult : null;
+}
+/**
+ * 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
+ *
+ * @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 value of the property specified by the dispIdMember or null
+ *
+ * @since 2.0
+ */
+public Variant getProperty(int dispIdMember, Variant[] rgvarg) {
+ Variant pVarResult = new Variant();
+ int result = invoke(dispIdMember, COM.DISPATCH_PROPERTYGET, rgvarg, null, pVarResult);
+ return (result == OLE.S_OK) ? pVarResult : null;
+
+}
+/**
+ * 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
+ *
+ * @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 value of the property specified by the dispIdMember or null
+ *
+ * @since 2.0
+ */
+public Variant getProperty(int dispIdMember, Variant[] rgvarg, int[] rgdispidNamedArgs) {
+ Variant pVarResult = new Variant();
+ int result = invoke(dispIdMember, COM.DISPATCH_PROPERTYGET, rgvarg, rgdispidNamedArgs, pVarResult);
+ return (result == OLE.S_OK) ? pVarResult : null;
+}
+
+/**
+ * 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, COM.DISPATCH_METHOD, null, null, pVarResult);
+ return (result == COM.S_OK) ? pVarResult : 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, COM.DISPATCH_METHOD, rgvarg, null, pVarResult);
+ return (result == COM.S_OK) ? pVarResult : 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, COM.DISPATCH_METHOD, rgvarg, rgdispidNamedArgs, pVarResult);
+ return (result == COM.S_OK) ? pVarResult : null;
+}
+private int invoke(int dispIdMember, int wFlags, 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, wFlags, 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, COM.DISPATCH_METHOD, 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, COM.DISPATCH_METHOD, 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, COM.DISPATCH_METHOD, 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) {
+ Variant[] rgvarg2 = new Variant[] {rgvarg};
+ int[] rgdispidNamedArgs = new int[] {COM.DISPID_PROPERTYPUT};
+ int dwFlags = COM.DISPATCH_PROPERTYPUT;
+ if ((rgvarg.getType() & COM.VT_BYREF) == COM.VT_BYREF)
+ dwFlags = COM.DISPATCH_PROPERTYPUTREF;
+ Variant pVarResult = new Variant();
+ int result = invoke(dispIdMember, dwFlags, rgvarg2, rgdispidNamedArgs, pVarResult);
+ return (result == COM.S_OK);
+}
+/**
+ * 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 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 true if the operation was successful
+ *
+ * @since 2.0
+ */
+public boolean setProperty(int dispIdMember, Variant[] rgvarg) {
+ int[] rgdispidNamedArgs = new int[] {COM.DISPID_PROPERTYPUT};
+ int dwFlags = COM.DISPATCH_PROPERTYPUT;
+ for (int i = 0; i < rgvarg.length; i++) {
+ if ((rgvarg[i].getType() & COM.VT_BYREF) == COM.VT_BYREF)
+ dwFlags = COM.DISPATCH_PROPERTYPUTREF;
+ }
+ Variant pVarResult = new Variant();
+ int result = invoke(dispIdMember, dwFlags, rgvarg, rgdispidNamedArgs, pVarResult);
+ return (result == 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
index 80b0cccb20..6ba3605a45 100755
--- 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
@@ -1,1339 +1,1339 @@
-package org.eclipse.swt.ole.win32;
-
-/*
+package org.eclipse.swt.ole.win32;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import org.eclipse.swt.*;
-import org.eclipse.swt.internal.Compatibility;
-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
- *
- * <p>Note that although this class is a subclass of <code>Composite</code>,
- * it does not make sense to add <code>Control</code> children to it,
- * or set a layout on it.
- * </p><p>
- * <dl>
- * <dt><b>Styles</b> <dd>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;
- private COMObject iOleDocumentSite;
-
- 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;
- protected IOleDocumentView objDocumentView;
-
- // Related storage information
- protected IStorage tempStorage; // IStorage interface of the receiver
-
- // Internal state and style information
- 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 boolean inDispose = false;
-
- private static final String WORDPROGID = "Word.Document"; //$NON-NLS-1$
-
- private Listener listener;
-
- static final int STATE_NONE = 0;
- static final int STATE_RUNNING = 1;
- static final int STATE_INPLACEACTIVE = 2;
- static final int STATE_UIACTIVE = 3;
- static final int STATE_ACTIVE = 4;
- int state = STATE_NONE;
-
-protected OleClientSite(Composite parent, int style) {
- /*
- * NOTE: 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 (parent != null) {
- if (parent instanceof OleFrame){
- frame = (OleFrame)parent;
- break;
- }
- parent = parent.getParent();
- }
- if (frame == null) OLE.error(SWT.ERROR_INVALID_ARGUMENT);
- frame.AddRef();
-
- 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(e); break;
- case SWT.FocusOut: onFocusOut(e); break;
- case SWT.Paint: onPaint(e); break;
- case SWT.Traverse: onTraverse(e); break;
- case SWT.KeyDown: /* required for traversal */ break;
- default :
- OLE.error(SWT.ERROR_NOT_IMPLEMENTED);
- }
- }
- };
-
- frame.addListener(SWT.Resize, listener);
- frame.addListener(SWT.Move, listener);
- addListener(SWT.Dispose, listener);
- addListener(SWT.FocusIn, listener);
- addListener(SWT.FocusOut, listener);
- addListener(SWT.Paint, listener);
- addListener(SWT.Traverse, listener);
- addListener(SWT.KeyDown, 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_INVALID_CLASSID, result);
- // associated CLSID may not be installed on this machine
- if (getProgramID() == null)
- OLE.error(OLE.ERROR_INVALID_CLASSID, 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();
-
- if (COM.OleRun(objIUnknown.getAddress()) == OLE.S_OK) state = STATE_RUNNING;
- } catch (SWTException e) {
- dispose();
- disposeCOMInterfaces();
- 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();
-
- if (COM.OleRun(objIUnknown.getAddress()) == OLE.S_OK) state = STATE_RUNNING;
-
- } catch (SWTException e) {
- dispose();
- disposeCOMInterfaces();
- 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"; //$NON-NLS-1$
- GUID wordGUID = getClassID(WORDPROGID);
- if (COM.IsEqualGUID(appClsid, wordGUID)) contentStream = "WordDocument"; //$NON-NLS-1$
-
- // 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();
-
- if (COM.OleRun(objIUnknown.getAddress()) == OLE.S_OK) state = STATE_RUNNING;
- } catch (SWTException e) {
- dispose();
- disposeCOMInterfaces();
- throw e;
- }
-}
-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"); //$NON-NLS-1$ //$NON-NLS-2$
-
- // 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]);}
- };
-
- iOleDocumentSite = new COMObject(new int[]{2, 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 ActivateMe(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 (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;
-
- if (iOleDocumentSite != null)
- iOleDocumentSite.dispose();
- iOleDocumentSite = 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) {
- // Not all OLE clients (for example PowerPoint) can be set into the running state in the constructor.
- // The fix is to ensure that the client is in the running state before invoking any verb on it.
- if (state == STATE_NONE) {
- if (COM.OleRun(objIUnknown.getAddress()) == OLE.S_OK) state = STATE_RUNNING;
- }
- if (state == STATE_NONE || isStatic)
- return COM.E_FAIL;
-
- // See PR: 1FV9RZW
- int result = objIOleObject.DoVerb(verb, null, iOleClientSite.getAddress(), 0, handle, null);
-
- if (state != STATE_RUNNING && 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 hMem = lplpszProgID[0];
- int length = OS.GlobalSize(hMem);
- int ptr = OS.GlobalLock(hMem);
- char[] buffer = new char[length];
- COM.MoveMemory(buffer, ptr, length);
- OS.GlobalUnlock(hMem);
- OS.GlobalFree(hMem);
-
- String result = new String(buffer);
- // remove null terminator
- int index = result.indexOf("\0");
- return result.substring(0, index);
- }
- }
- return null;
-}
-int ActivateMe(int pViewToActivate) {
- if (pViewToActivate == 0) {
- int[] ppvObject = new int[1];
- if (objIUnknown.QueryInterface(COM.IIDIOleDocument, ppvObject) != COM.S_OK) return COM.E_FAIL;
- IOleDocument objOleDocument = new IOleDocument(ppvObject[0]);
- if (objOleDocument.CreateView(iOleInPlaceSite.getAddress(), 0, 0, ppvObject) != COM.S_OK) return COM.E_FAIL;
- objOleDocument.Release();
- objDocumentView = new IOleDocumentView(ppvObject[0]);
- } else {
- objDocumentView = new IOleDocumentView(pViewToActivate);
- objDocumentView.AddRef();
- objDocumentView.SetInPlaceSite(iOleInPlaceSite.getAddress());
- }
- objDocumentView.UIActivate(1);//TRUE
- RECT rect = getRect();
- objDocumentView.SetRect(rect);
- objDocumentView.Show(1);//TRUE
- return COM.S_OK;
-}
-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;
-}
-RECT getRect() {
- Point location = this.getLocation();
- Rectangle area = frame.getClientArea();
- RECT rect = new RECT();
- rect.left = location.x;
- rect.top = location.y;
- rect.right = location.x + area.width - borderWidths.left - borderWidths.right;
- rect.bottom = location.y + area.height - borderWidths.top - borderWidths.bottom;
- return rect;
-}
-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
- RECT rect = getRect();
- if (lprcPosRect != 0) OS.MoveMemory(lprcPosRect, rect, RECT.sizeof);
- if (lprcClipRect != 0) OS.MoveMemory(lprcClipRect, rect, RECT.sizeof);
-
- // get frame info
- OLEINPLACEFRAMEINFO frameInfo = new OLEINPLACEFRAMEINFO();
- frameInfo.cb = OLEINPLACEFRAMEINFO.sizeof;
- frameInfo.fMDIApp = 0;
- frameInfo.hwndFrame = frame.handle;
- Shell shell = getShell();
- Menu menubar = shell.getMenuBar();
- if (menubar != null && !menubar.isDisposed()) {
- int hwnd = shell.handle;
- int cAccel = OS.SendMessage(hwnd, OS.WM_APP, 0, 0);
- if (cAccel != 0) {
- int hAccel = OS.SendMessage(hwnd, OS.WM_APP+1, 0, 0);
- if (hAccel != 0) {
- frameInfo.cAccelEntries = cAccel;
- frameInfo.haccel = hAccel;
- }
- }
- }
- COM.MoveMemory(lpFrameInfo, frameInfo, OLEINPLACEFRAMEINFO.sizeof);
-
- return COM.S_OK;
-}
-public boolean isDirty() {
- /*
- * Note: this method must return true unless it is absolutely clear that the
- * contents of the Ole Document do not differ from the contents in the file
- * on the file system.
- */
-
- // Get access to the persistant storage mechanism
- int[] address = new int[1];
- if (objIOleObject.QueryInterface(COM.IIDIPersistFile, address) != COM.S_OK)
- return true;
- IPersistStorage permStorage = new IPersistStorage(address[0]);
- // Are the contents of the permanent storage different from the file?
- int result = permStorage.IsDirty();
- permStorage.Release();
- if (result == COM.S_FALSE) return false;
- return true;
-}
-public boolean isFocusControl () {
- checkWidget ();
- int focusHwnd = OS.GetFocus();
- if (objIOleInPlaceObject == null) return (handle == focusHwnd);
- int[] phwnd = new int[1];
- objIOleInPlaceObject.GetWindow(phwnd);
- while (focusHwnd != 0) {
- if (phwnd[0] == focusHwnd) return true;
- focusHwnd = OS.GetParent(focusHwnd);
- }
- 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) {
- inDispose = true;
- if (state != STATE_NONE)
- doVerb(OLE.OLEIVERB_DISCARDUNDOSTATE);
- deactivateInPlaceClient();
- releaseObjectInterfaces(); // Note, must release object interfaces before releasing frame
- deleteTempStorage();
-
- // remove listeners
- removeListener(SWT.Dispose, listener);
- removeListener(SWT.FocusIn, listener);
- removeListener(SWT.Paint, listener);
- removeListener(SWT.Traverse, listener);
- removeListener(SWT.KeyDown, listener);
- frame.removeListener(SWT.Resize, listener);
- frame.removeListener(SWT.Move, listener);
-
- frame.Release();
- frame = null;
-}
-void onFocusIn(Event e) {
- if (inDispose) return;
- if (state != STATE_UIACTIVE) doVerb(OLE.OLEIVERB_SHOW);
- if (objIOleInPlaceObject == null) return;
- if (isFocusControl()) return;
- int[] phwnd = new int[1];
- objIOleInPlaceObject.GetWindow(phwnd);
- if (phwnd[0] == 0) return;
- OS.SetFocus(phwnd[0]);
-}
-void onFocusOut(Event e) {
-}
-private int OnInPlaceActivate() {
- state = STATE_INPLACEACTIVE;
- frame.setCurrentDocument(this);
- 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;
- state = STATE_RUNNING;
- redraw();
- if (getDisplay().getFocusControl() == null) {
- getShell().traverse(SWT.TRAVERSE_TAB_NEXT);
- }
- return COM.S_OK;
-}
-private int OnPosRectChange(int lprcPosRect) {
- Point size = getSize();
- setExtent(size.x, size.y);
- return COM.S_OK;
-}
-private void onPaint(Event e) {
- if (state == STATE_RUNNING || state == STATE_INPLACEACTIVE) {
- SIZE size = getExtent();
- Rectangle area = getClientArea();
- RECT rect = new RECT();
- if (getProgramID().startsWith("Excel.Sheet")) {
- rect.left = area.x; rect.right = area.x + (area.height * size.cx / size.cy);
- rect.top = area.y; rect.bottom = area.y + area.height;
- } else {
- rect.left = area.x; rect.right = area.x + size.cx;
- rect.top = area.y; rect.bottom = area.y + 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) {
- return COM.S_OK;
-}
-private int OnUIActivate() {
- if (objIOleInPlaceObject == null) return COM.E_FAIL;
- state = STATE_UIACTIVE;
- 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);
- }
- 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;
- state = STATE_INPLACEACTIVE;
- frame.SetActiveObject(0,0);
- redraw();
- if (getDisplay().getFocusControl() == frame) {
- getShell().traverse(SWT.TRAVERSE_TAB_NEXT);
- }
- Shell shell = getShell();
- Menu menubar = shell.getMenuBar();
- if (menubar == null || menubar.isDisposed())
- return COM.S_OK;
-
- int shellHandle = shell.handle;
- OS.SetMenu(shellHandle, menubar.handle);
- return COM.OleSetMenuDescriptor(0, shellHandle, 0, 0, 0);
-}
-private void onTraverse(Event event) {
- switch (event.detail) {
- case SWT.TRAVERSE_ESCAPE:
- case SWT.TRAVERSE_RETURN:
- case SWT.TRAVERSE_TAB_NEXT:
- case SWT.TRAVERSE_TAB_PREVIOUS:
- case SWT.TRAVERSE_PAGE_NEXT:
- case SWT.TRAVERSE_PAGE_PREVIOUS:
- case SWT.TRAVERSE_MNEMONIC:
- event.doit = true;
- break;
- }
-}
-private int OnViewChange(int dwAspect, int lindex) {
- 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;
- }
- if (COM.IsEqualGUID(guid, COM.IIDIOleDocumentSite )) {
- String progID = getProgramID();
- if (!progID.startsWith("PowerPoint")) {
- COM.MoveMemory(ppvObject, new int[] {iOleDocumentSite.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 (objDocumentView != null){
- objDocumentView.Release();
- }
- objDocumentView = 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) //$NON-NLS-1$
- 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) //$NON-NLS-1$
- 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 || 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 void setObjectRects() {
- if (objIOleInPlaceObject == null) return;
- // size the object to fill the available space
- // leave a border
- RECT rect = getRect();
- objIOleInPlaceObject.SetObjectRects(rect, rect);
-}
-
-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);
- int cx = Compatibility.round(aSize.cx * xppi, 2540); // 2540 HIMETRIC units per inch
- int cy = Compatibility.round(aSize.cy * yppi, 2540);
- 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);
- int cx = Compatibility.round(aSize.cx * 2540, xppi); // 2540 HIMETRIC units per inch
- int cy = Compatibility.round(aSize.cy * 2540, yppi);
- SIZE size = new SIZE();
- size.cx = cx;
- size.cy = cy;
- return size;
-}
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import org.eclipse.swt.*;
+import org.eclipse.swt.internal.Compatibility;
+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
+ *
+ * <p>Note that although this class is a subclass of <code>Composite</code>,
+ * it does not make sense to add <code>Control</code> children to it,
+ * or set a layout on it.
+ * </p><p>
+ * <dl>
+ * <dt><b>Styles</b> <dd>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;
+ private COMObject iOleDocumentSite;
+
+ 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;
+ protected IOleDocumentView objDocumentView;
+
+ // Related storage information
+ protected IStorage tempStorage; // IStorage interface of the receiver
+
+ // Internal state and style information
+ 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 boolean inDispose = false;
+
+ private static final String WORDPROGID = "Word.Document"; //$NON-NLS-1$
+
+ private Listener listener;
+
+ static final int STATE_NONE = 0;
+ static final int STATE_RUNNING = 1;
+ static final int STATE_INPLACEACTIVE = 2;
+ static final int STATE_UIACTIVE = 3;
+ static final int STATE_ACTIVE = 4;
+ int state = STATE_NONE;
+
+protected OleClientSite(Composite parent, int style) {
+ /*
+ * NOTE: 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 (parent != null) {
+ if (parent instanceof OleFrame){
+ frame = (OleFrame)parent;
+ break;
+ }
+ parent = parent.getParent();
+ }
+ if (frame == null) OLE.error(SWT.ERROR_INVALID_ARGUMENT);
+ frame.AddRef();
+
+ 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(e); break;
+ case SWT.FocusOut: onFocusOut(e); break;
+ case SWT.Paint: onPaint(e); break;
+ case SWT.Traverse: onTraverse(e); break;
+ case SWT.KeyDown: /* required for traversal */ break;
+ default :
+ OLE.error(SWT.ERROR_NOT_IMPLEMENTED);
+ }
+ }
+ };
+
+ frame.addListener(SWT.Resize, listener);
+ frame.addListener(SWT.Move, listener);
+ addListener(SWT.Dispose, listener);
+ addListener(SWT.FocusIn, listener);
+ addListener(SWT.FocusOut, listener);
+ addListener(SWT.Paint, listener);
+ addListener(SWT.Traverse, listener);
+ addListener(SWT.KeyDown, 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_INVALID_CLASSID, result);
+ // associated CLSID may not be installed on this machine
+ if (getProgramID() == null)
+ OLE.error(OLE.ERROR_INVALID_CLASSID, 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();
+
+ if (COM.OleRun(objIUnknown.getAddress()) == OLE.S_OK) state = STATE_RUNNING;
+ } catch (SWTException e) {
+ dispose();
+ disposeCOMInterfaces();
+ 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();
+
+ if (COM.OleRun(objIUnknown.getAddress()) == OLE.S_OK) state = STATE_RUNNING;
+
+ } catch (SWTException e) {
+ dispose();
+ disposeCOMInterfaces();
+ 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"; //$NON-NLS-1$
+ GUID wordGUID = getClassID(WORDPROGID);
+ if (COM.IsEqualGUID(appClsid, wordGUID)) contentStream = "WordDocument"; //$NON-NLS-1$
+
+ // 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();
+
+ if (COM.OleRun(objIUnknown.getAddress()) == OLE.S_OK) state = STATE_RUNNING;
+ } catch (SWTException e) {
+ dispose();
+ disposeCOMInterfaces();
+ throw e;
+ }
+}
+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"); //$NON-NLS-1$ //$NON-NLS-2$
+
+ // 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]);}
+ };
+
+ iOleDocumentSite = new COMObject(new int[]{2, 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 ActivateMe(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 (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;
+
+ if (iOleDocumentSite != null)
+ iOleDocumentSite.dispose();
+ iOleDocumentSite = 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) {
+ // Not all OLE clients (for example PowerPoint) can be set into the running state in the constructor.
+ // The fix is to ensure that the client is in the running state before invoking any verb on it.
+ if (state == STATE_NONE) {
+ if (COM.OleRun(objIUnknown.getAddress()) == OLE.S_OK) state = STATE_RUNNING;
+ }
+ if (state == STATE_NONE || isStatic)
+ return COM.E_FAIL;
+
+ // See PR: 1FV9RZW
+ int result = objIOleObject.DoVerb(verb, null, iOleClientSite.getAddress(), 0, handle, null);
+
+ if (state != STATE_RUNNING && 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 hMem = lplpszProgID[0];
+ int length = OS.GlobalSize(hMem);
+ int ptr = OS.GlobalLock(hMem);
+ char[] buffer = new char[length];
+ COM.MoveMemory(buffer, ptr, length);
+ OS.GlobalUnlock(hMem);
+ OS.GlobalFree(hMem);
+
+ String result = new String(buffer);
+ // remove null terminator
+ int index = result.indexOf("\0");
+ return result.substring(0, index);
+ }
+ }
+ return null;
+}
+int ActivateMe(int pViewToActivate) {
+ if (pViewToActivate == 0) {
+ int[] ppvObject = new int[1];
+ if (objIUnknown.QueryInterface(COM.IIDIOleDocument, ppvObject) != COM.S_OK) return COM.E_FAIL;
+ IOleDocument objOleDocument = new IOleDocument(ppvObject[0]);
+ if (objOleDocument.CreateView(iOleInPlaceSite.getAddress(), 0, 0, ppvObject) != COM.S_OK) return COM.E_FAIL;
+ objOleDocument.Release();
+ objDocumentView = new IOleDocumentView(ppvObject[0]);
+ } else {
+ objDocumentView = new IOleDocumentView(pViewToActivate);
+ objDocumentView.AddRef();
+ objDocumentView.SetInPlaceSite(iOleInPlaceSite.getAddress());
+ }
+ objDocumentView.UIActivate(1);//TRUE
+ RECT rect = getRect();
+ objDocumentView.SetRect(rect);
+ objDocumentView.Show(1);//TRUE
+ return COM.S_OK;
+}
+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;
+}
+RECT getRect() {
+ Point location = this.getLocation();
+ Rectangle area = frame.getClientArea();
+ RECT rect = new RECT();
+ rect.left = location.x;
+ rect.top = location.y;
+ rect.right = location.x + area.width - borderWidths.left - borderWidths.right;
+ rect.bottom = location.y + area.height - borderWidths.top - borderWidths.bottom;
+ return rect;
+}
+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
+ RECT rect = getRect();
+ if (lprcPosRect != 0) OS.MoveMemory(lprcPosRect, rect, RECT.sizeof);
+ if (lprcClipRect != 0) OS.MoveMemory(lprcClipRect, rect, RECT.sizeof);
+
+ // get frame info
+ OLEINPLACEFRAMEINFO frameInfo = new OLEINPLACEFRAMEINFO();
+ frameInfo.cb = OLEINPLACEFRAMEINFO.sizeof;
+ frameInfo.fMDIApp = 0;
+ frameInfo.hwndFrame = frame.handle;
+ Shell shell = getShell();
+ Menu menubar = shell.getMenuBar();
+ if (menubar != null && !menubar.isDisposed()) {
+ int hwnd = shell.handle;
+ int cAccel = OS.SendMessage(hwnd, OS.WM_APP, 0, 0);
+ if (cAccel != 0) {
+ int hAccel = OS.SendMessage(hwnd, OS.WM_APP+1, 0, 0);
+ if (hAccel != 0) {
+ frameInfo.cAccelEntries = cAccel;
+ frameInfo.haccel = hAccel;
+ }
+ }
+ }
+ COM.MoveMemory(lpFrameInfo, frameInfo, OLEINPLACEFRAMEINFO.sizeof);
+
+ return COM.S_OK;
+}
+public boolean isDirty() {
+ /*
+ * Note: this method must return true unless it is absolutely clear that the
+ * contents of the Ole Document do not differ from the contents in the file
+ * on the file system.
+ */
+
+ // Get access to the persistant storage mechanism
+ int[] address = new int[1];
+ if (objIOleObject.QueryInterface(COM.IIDIPersistFile, address) != COM.S_OK)
+ return true;
+ IPersistStorage permStorage = new IPersistStorage(address[0]);
+ // Are the contents of the permanent storage different from the file?
+ int result = permStorage.IsDirty();
+ permStorage.Release();
+ if (result == COM.S_FALSE) return false;
+ return true;
+}
+public boolean isFocusControl () {
+ checkWidget ();
+ int focusHwnd = OS.GetFocus();
+ if (objIOleInPlaceObject == null) return (handle == focusHwnd);
+ int[] phwnd = new int[1];
+ objIOleInPlaceObject.GetWindow(phwnd);
+ while (focusHwnd != 0) {
+ if (phwnd[0] == focusHwnd) return true;
+ focusHwnd = OS.GetParent(focusHwnd);
+ }
+ 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) {
+ inDispose = true;
+ if (state != STATE_NONE)
+ doVerb(OLE.OLEIVERB_DISCARDUNDOSTATE);
+ deactivateInPlaceClient();
+ releaseObjectInterfaces(); // Note, must release object interfaces before releasing frame
+ deleteTempStorage();
+
+ // remove listeners
+ removeListener(SWT.Dispose, listener);
+ removeListener(SWT.FocusIn, listener);
+ removeListener(SWT.Paint, listener);
+ removeListener(SWT.Traverse, listener);
+ removeListener(SWT.KeyDown, listener);
+ frame.removeListener(SWT.Resize, listener);
+ frame.removeListener(SWT.Move, listener);
+
+ frame.Release();
+ frame = null;
+}
+void onFocusIn(Event e) {
+ if (inDispose) return;
+ if (state != STATE_UIACTIVE) doVerb(OLE.OLEIVERB_SHOW);
+ if (objIOleInPlaceObject == null) return;
+ if (isFocusControl()) return;
+ int[] phwnd = new int[1];
+ objIOleInPlaceObject.GetWindow(phwnd);
+ if (phwnd[0] == 0) return;
+ OS.SetFocus(phwnd[0]);
+}
+void onFocusOut(Event e) {
+}
+private int OnInPlaceActivate() {
+ state = STATE_INPLACEACTIVE;
+ frame.setCurrentDocument(this);
+ 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;
+ state = STATE_RUNNING;
+ redraw();
+ if (getDisplay().getFocusControl() == null) {
+ getShell().traverse(SWT.TRAVERSE_TAB_NEXT);
+ }
+ return COM.S_OK;
+}
+private int OnPosRectChange(int lprcPosRect) {
+ Point size = getSize();
+ setExtent(size.x, size.y);
+ return COM.S_OK;
+}
+private void onPaint(Event e) {
+ if (state == STATE_RUNNING || state == STATE_INPLACEACTIVE) {
+ SIZE size = getExtent();
+ Rectangle area = getClientArea();
+ RECT rect = new RECT();
+ if (getProgramID().startsWith("Excel.Sheet")) {
+ rect.left = area.x; rect.right = area.x + (area.height * size.cx / size.cy);
+ rect.top = area.y; rect.bottom = area.y + area.height;
+ } else {
+ rect.left = area.x; rect.right = area.x + size.cx;
+ rect.top = area.y; rect.bottom = area.y + 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) {
+ return COM.S_OK;
+}
+private int OnUIActivate() {
+ if (objIOleInPlaceObject == null) return COM.E_FAIL;
+ state = STATE_UIACTIVE;
+ 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);
+ }
+ 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;
+ state = STATE_INPLACEACTIVE;
+ frame.SetActiveObject(0,0);
+ redraw();
+ if (getDisplay().getFocusControl() == frame) {
+ getShell().traverse(SWT.TRAVERSE_TAB_NEXT);
+ }
+ Shell shell = getShell();
+ Menu menubar = shell.getMenuBar();
+ if (menubar == null || menubar.isDisposed())
+ return COM.S_OK;
+
+ int shellHandle = shell.handle;
+ OS.SetMenu(shellHandle, menubar.handle);
+ return COM.OleSetMenuDescriptor(0, shellHandle, 0, 0, 0);
+}
+private void onTraverse(Event event) {
+ switch (event.detail) {
+ case SWT.TRAVERSE_ESCAPE:
+ case SWT.TRAVERSE_RETURN:
+ case SWT.TRAVERSE_TAB_NEXT:
+ case SWT.TRAVERSE_TAB_PREVIOUS:
+ case SWT.TRAVERSE_PAGE_NEXT:
+ case SWT.TRAVERSE_PAGE_PREVIOUS:
+ case SWT.TRAVERSE_MNEMONIC:
+ event.doit = true;
+ break;
+ }
+}
+private int OnViewChange(int dwAspect, int lindex) {
+ 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;
+ }
+ if (COM.IsEqualGUID(guid, COM.IIDIOleDocumentSite )) {
+ String progID = getProgramID();
+ if (!progID.startsWith("PowerPoint")) {
+ COM.MoveMemory(ppvObject, new int[] {iOleDocumentSite.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 (objDocumentView != null){
+ objDocumentView.Release();
+ }
+ objDocumentView = 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) //$NON-NLS-1$
+ 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) //$NON-NLS-1$
+ 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 || 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 void setObjectRects() {
+ if (objIOleInPlaceObject == null) return;
+ // size the object to fill the available space
+ // leave a border
+ RECT rect = getRect();
+ objIOleInPlaceObject.SetObjectRects(rect, rect);
+}
+
+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);
+ int cx = Compatibility.round(aSize.cx * xppi, 2540); // 2540 HIMETRIC units per inch
+ int cy = Compatibility.round(aSize.cy * yppi, 2540);
+ 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);
+ int cx = Compatibility.round(aSize.cx * 2540, xppi); // 2540 HIMETRIC units per inch
+ int cy = Compatibility.round(aSize.cy * 2540, yppi);
+ 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
index b9269941ad..9024137d29 100755
--- 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
@@ -1,812 +1,812 @@
-package org.eclipse.swt.ole.win32;
-
-/*
+package org.eclipse.swt.ole.win32;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-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.
- *
- * <p>Note that although this class is a subclass of <code>Composite</code>,
- * it does not make sense to add <code>Control</code> children to it,
- * or set a layout on it.
- * </p><p>
- * <dl>
- * <dt><b>Styles</b> <dd>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 = new OleEventSink[0];
- private GUID[] oleEventSinkGUID = new GUID[0];
- private int[] oleEventSinkIUnknown = new int[0];
-
- // supporting information for the Control COM object
- private CONTROLINFO currentControlInfo;
- private String licenseInfo;
- private int[] sitePropertyIds = new int[0];
- private Variant[] sitePropertyValues = new Variant[0];
-
-/**
- * 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);
- try {
-
- // 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
- addObjectReferences();
-
- // Init site properties
- setSiteProperty(COM.DISPID_AMBIENT_USERMODE, new Variant(true));
- setSiteProperty(COM.DISPID_AMBIENT_UIDEAD, new Variant(false));
-
- if (COM.OleRun(objIUnknown.getAddress()) == OLE.S_OK) state= STATE_RUNNING;
-
- } catch (SWTError e) {
- dispose();
- disposeCOMInterfaces();
- throw e;
- }
-}
-/**
- * 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);
- GUID riid = getDefaultEventSinkGUID(objIUnknown);
- if (riid != null) {
- addEventListener(objIUnknown.getAddress(), riid, eventID, listener);
- }
-
-}
-static GUID getDefaultEventSinkGUID(IUnknown unknown) {
- // get Event Sink I/F from IProvideClassInfo2
- int[] ppvObject = new int[1];
- if (unknown.QueryInterface(COM.IIDIProvideClassInfo2, ppvObject) == COM.S_OK) {
- IProvideClassInfo2 pci2 = new IProvideClassInfo2(ppvObject[0]);
- GUID riid = new GUID();
- int result = pci2.GetGUID(COM.GUIDKIND_DEFAULT_SOURCE_DISP_IID, riid);
- pci2.Release();
- if (result == COM.S_OK) return riid;
- }
-
- // get Event Sink I/F from IProvideClassInfo
- if (unknown.QueryInterface(COM.IIDIProvideClassInfo, ppvObject) == COM.S_OK) {
- IProvideClassInfo pci = new IProvideClassInfo(ppvObject[0]);
- int[] ppTI = new int[1];
- int[] ppEI = new int[1];
- int result = pci.GetClassInfo(ppTI);
- pci.Release();
-
- if (result == COM.S_OK && ppTI[0] != 0) {
- ITypeInfo classInfo = new ITypeInfo(ppTI[0]);
- int[] ppTypeAttr = new int[1];
- result = classInfo.GetTypeAttr(ppTypeAttr);
- if (result == COM.S_OK && ppTypeAttr[0] != 0) {
- TYPEATTR 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[0] != 0) {
- ITypeInfo eventInfo = new ITypeInfo(ppEI[0]);
- ppTypeAttr = new int[1];
- result = eventInfo.GetTypeAttr(ppTypeAttr);
- GUID riid = null;
- if (result == COM.S_OK && ppTypeAttr[0] != 0) {
- riid = new GUID();
- COM.MoveMemory(riid, ppTypeAttr[0], GUID.sizeof);
- eventInfo.ReleaseTypeAttr(ppTypeAttr[0]);
- }
- eventInfo.Release();
- return riid;
- }
- }
- }
- return null;
-}
-
-/**
- * Adds the listener to receive events.
- *
- * @since 2.0
- *
- * @param automation the automation object that provides the event notification
- *
- * @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(OleAutomation automation, int eventID, OleListener listener) {
- if (listener == null || automation == null) OLE.error (SWT.ERROR_NULL_ARGUMENT);
- int address = automation.getAddress();
- IUnknown unknown = new IUnknown(address);
- GUID riid = getDefaultEventSinkGUID(unknown);
- if (riid != null) {
- addEventListener(address, riid, eventID, listener);
- }
-
-}
-void addEventListener(int iunknown, GUID guid, int eventID, OleListener listener) {
- if (listener == null || iunknown == 0 || guid == null) OLE.error (SWT.ERROR_NULL_ARGUMENT);
- // have we connected to this kind of event sink before?
- int index = -1;
- for (int i = 0; i < oleEventSinkGUID.length; i++) {
- if (COM.IsEqualGUID(oleEventSinkGUID[i], guid)) {
- if (iunknown == oleEventSinkIUnknown[i]) {
- index = i;
- break;
- }
- }
- }
- if (index != -1) {
- oleEventSink[index].addListener(eventID, listener);
- } else {
- int oldLength = oleEventSink.length;
- OleEventSink[] newOleEventSink = new OleEventSink[oldLength + 1];
- GUID[] newOleEventSinkGUID = new GUID[oldLength + 1];
- int[] newOleEventSinkIUnknown = new int[oldLength + 1];
- System.arraycopy(oleEventSink, 0, newOleEventSink, 0, oldLength);
- System.arraycopy(oleEventSinkGUID, 0, newOleEventSinkGUID, 0, oldLength);
- System.arraycopy(oleEventSinkIUnknown, 0, newOleEventSinkIUnknown, 0, oldLength);
- oleEventSink = newOleEventSink;
- oleEventSinkGUID = newOleEventSinkGUID;
- oleEventSinkIUnknown = newOleEventSinkIUnknown;
-
- oleEventSink[oldLength] = new OleEventSink(this, iunknown, guid);
- oleEventSinkGUID[oldLength] = guid;
- oleEventSinkIUnknown[oldLength] = iunknown;
- oleEventSink[oldLength].AddRef();
- oleEventSink[oldLength].connect();
- oleEventSink[oldLength].addListener(eventID, listener);
-
- }
-}
-protected void addObjectReferences() {
-
- super.addObjectReferences();
-
- // 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 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, 5, 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 disconnectEventSinks() {
-
- for (int i = 0; i < oleEventSink.length; i++) {
- OleEventSink sink = oleEventSink[i];
- sink.disconnect();
- sink.Release();
- }
- oleEventSink = new OleEventSink[0];
- oleEventSinkGUID = new GUID[0];
- oleEventSinkIUnknown = new int[0];
-}
-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;
-}
-/**
- *
- * Get the control site property specified by the dispIdMember.
- *
- * @since 2.1
- *
- */
-public Variant getSiteProperty(int dispId){
- for (int i = 0; i < sitePropertyIds.length; i++) {
- if (sitePropertyIds[i] == dispId) {
- return sitePropertyValues[i];
- }
- }
- 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[] {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;
- }
- Variant result = getSiteProperty(dispIdMember);
- if (result != null) {
- if (pVarResult != 0) result.getData(pVarResult);
- return COM.S_OK;
- }
- switch (dispIdMember) {
- // 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;
- }
-}
-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;
-}
-void onFocusIn(Event e) {
- if (objIOleInPlaceObject == null) return;
- doVerb(OLE.OLEIVERB_UIACTIVATE);
- if (isFocusControl()) return;
- int[] phwnd = new int[1];
- objIOleInPlaceObject.GetWindow(phwnd);
- if (phwnd[0] == 0) return;
- OS.SetFocus(phwnd[0]);
-}
-void onFocusOut(Event e) {
- if (objIOleInPlaceObject != null) {
- objIOleInPlaceObject.UIDeactivate();
- }
-}
-private int OnFocus(int fGotFocus) {
- return COM.S_OK;
-}
-protected int OnUIDeactivate(int fUndoable) {
- // controls don't need to do anything for
- // border space or menubars
- state = STATE_INPLACEACTIVE;
- 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 int Release() {
- int result = super.Release();
- if (result == 0) {
- for (int i = 0; i < sitePropertyIds.length; i++) {
- sitePropertyValues[i].dispose();
- }
- sitePropertyIds = new int[0];
- sitePropertyValues = new Variant[0];
- }
- return result;
-}
-protected void releaseObjectInterfaces() {
-
- disconnectEventSinks();
-
- disconnectPropertyChangeSink();
-
- super.releaseObjectInterfaces();
-}
-/**
- * Removes the listener.
- *
- * @param eventID the event identifier
- *
- * @param listener the listener
- *
- * @exception SWTError
- * <ul><li>ERROR_NULL_ARGUMENT when listener is null</li></ul>
- */
-public void removeEventListener(int eventID, OleListener listener) {
- checkWidget();
- if (listener == null) throw new SWTError (SWT.ERROR_NULL_ARGUMENT);
-
- GUID riid = getDefaultEventSinkGUID(objIUnknown);
- if (riid != null) {
- removeEventListener(objIUnknown.getAddress(), riid, eventID, listener);
- }
-}
-/**
- * Removes the listener.
- *
- * @since 2.0
- * @deprecated - use OleControlSite.removeEventListener(OleAutomation, int, OleListener)
- *
- * @param automation the automation object that provides the event notification
- *
- * @param guid the identifier of the events COM interface
- *
- * @param eventID the event identifier
- *
- * @param listener the listener
- *
- * @exception SWTError
- * <ul><li>ERROR_NULL_ARGUMENT when listener is null</li></ul>
- */
-public void removeEventListener(OleAutomation automation, GUID guid, int eventID, OleListener listener) {
- checkWidget();
- if (automation == null || listener == null || guid == null) throw new SWTError (SWT.ERROR_NULL_ARGUMENT);
- removeEventListener(automation.getAddress(), guid, eventID, listener);
-}
-/**
- * Removes the listener.
- *
- * @since 2.0
- *
- * @param automation the automation object that provides the event notification
- *
- * @param eventID the event identifier
- *
- * @param listener the listener
- *
- * @exception SWTError
- * <ul><li>ERROR_NULL_ARGUMENT when listener is null</li></ul>
- */
-public void removeEventListener(OleAutomation automation, int eventID, OleListener listener) {
- checkWidget();
- if (automation == null || listener == null) throw new SWTError (SWT.ERROR_NULL_ARGUMENT);
- int address = automation.getAddress();
- IUnknown unknown = new IUnknown(address);
- GUID riid = getDefaultEventSinkGUID(unknown);
- if (riid != null) {
- removeEventListener(address, riid, eventID, listener);
- }
-}
-void removeEventListener(int iunknown, GUID guid, int eventID, OleListener listener) {
- if (listener == null || guid == null) throw new SWTError (SWT.ERROR_NULL_ARGUMENT);
- for (int i = 0; i < oleEventSink.length; i++) {
- if (COM.IsEqualGUID(oleEventSinkGUID[i], guid)) {
- if (iunknown == oleEventSinkIUnknown[i]) {
- oleEventSink[i].removeListener(eventID, listener);
- if (!oleEventSink[i].hasListeners()) {
- //free resources associated with event sink
- oleEventSink[i].disconnect();
- oleEventSink[i].Release();
- int oldLength = oleEventSink.length;
- if (oldLength == 1) {
- oleEventSink = new OleEventSink[0];
- oleEventSinkGUID = new GUID[0];
- oleEventSinkIUnknown = new int[0];
- } else {
- OleEventSink[] newOleEventSink = new OleEventSink[oldLength - 1];
- System.arraycopy(oleEventSink, 0, newOleEventSink, 0, i);
- System.arraycopy(oleEventSink, i + 1, newOleEventSink, i, oldLength - i - 1);
- oleEventSink = newOleEventSink;
-
- GUID[] newOleEventSinkGUID = new GUID[oldLength - 1];
- System.arraycopy(oleEventSinkGUID, 0, newOleEventSinkGUID, 0, i);
- System.arraycopy(oleEventSinkGUID, i + 1, newOleEventSinkGUID, i, oldLength - i - 1);
- oleEventSinkGUID = newOleEventSinkGUID;
-
- int[] newOleEventSinkIUnknown = new int[oldLength - 1];
- System.arraycopy(oleEventSinkIUnknown, 0, newOleEventSinkIUnknown, 0, i);
- System.arraycopy(oleEventSinkIUnknown, i + 1, newOleEventSinkIUnknown, i, oldLength - i - 1);
- oleEventSinkIUnknown = newOleEventSinkIUnknown;
- }
- }
- return;
- }
- }
- }
-}
-/**
- * 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();
- }
-}
-/**
- * Sets the control site property specified by the dispIdMember to a new value.
- * The value will be disposed by the control site when it is no longer required
- * using Variant.dispose. Passing a value of null will clear the dispId value.
- *
- * @param dispId the ID of the property as specified by the IDL of the ActiveX Control
- * @param value The new value for the property as expressed in a Variant.
- *
- * @since 2.1
- */
-public void setSiteProperty(int dispId, Variant value){
- for (int i = 0; i < sitePropertyIds.length; i++) {
- if (sitePropertyIds[i] == dispId) {
- if (sitePropertyValues[i] != null) {
- sitePropertyValues[i].dispose();
- }
- if (value != null) {
- sitePropertyValues[i] = value;
- } else {
- int oldLength = sitePropertyIds.length;
- int[] newSitePropertyIds = new int[oldLength - 1];
- Variant[] newSitePropertyValues = new Variant[oldLength - 1];
- System.arraycopy(sitePropertyIds, 0, newSitePropertyIds, 0, i);
- System.arraycopy(sitePropertyIds, i + 1, newSitePropertyIds, i, oldLength - i - 1);
- System.arraycopy(sitePropertyValues, 0, newSitePropertyValues, 0, i);
- System.arraycopy(sitePropertyValues, i + 1, newSitePropertyValues, i, oldLength - i - 1);
- sitePropertyIds = newSitePropertyIds;
- sitePropertyValues = newSitePropertyValues;
- }
- return;
- }
- }
- int oldLength = sitePropertyIds.length;
- int[] newSitePropertyIds = new int[oldLength + 1];
- Variant[] newSitePropertyValues = new Variant[oldLength + 1];
- System.arraycopy(sitePropertyIds, 0, newSitePropertyIds, 0, oldLength);
- System.arraycopy(sitePropertyValues, 0, newSitePropertyValues, 0, oldLength);
- newSitePropertyIds[oldLength] = dispId;
- newSitePropertyValues[oldLength] = value;
- sitePropertyIds = newSitePropertyIds;
- sitePropertyValues = newSitePropertyValues;
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+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.
+ *
+ * <p>Note that although this class is a subclass of <code>Composite</code>,
+ * it does not make sense to add <code>Control</code> children to it,
+ * or set a layout on it.
+ * </p><p>
+ * <dl>
+ * <dt><b>Styles</b> <dd>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 = new OleEventSink[0];
+ private GUID[] oleEventSinkGUID = new GUID[0];
+ private int[] oleEventSinkIUnknown = new int[0];
+
+ // supporting information for the Control COM object
+ private CONTROLINFO currentControlInfo;
+ private String licenseInfo;
+ private int[] sitePropertyIds = new int[0];
+ private Variant[] sitePropertyValues = new Variant[0];
+
+/**
+ * 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);
+ try {
+
+ // 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
+ addObjectReferences();
+
+ // Init site properties
+ setSiteProperty(COM.DISPID_AMBIENT_USERMODE, new Variant(true));
+ setSiteProperty(COM.DISPID_AMBIENT_UIDEAD, new Variant(false));
+
+ if (COM.OleRun(objIUnknown.getAddress()) == OLE.S_OK) state= STATE_RUNNING;
+
+ } catch (SWTError e) {
+ dispose();
+ disposeCOMInterfaces();
+ throw e;
+ }
+}
+/**
+ * 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);
+ GUID riid = getDefaultEventSinkGUID(objIUnknown);
+ if (riid != null) {
+ addEventListener(objIUnknown.getAddress(), riid, eventID, listener);
+ }
+
+}
+static GUID getDefaultEventSinkGUID(IUnknown unknown) {
+ // get Event Sink I/F from IProvideClassInfo2
+ int[] ppvObject = new int[1];
+ if (unknown.QueryInterface(COM.IIDIProvideClassInfo2, ppvObject) == COM.S_OK) {
+ IProvideClassInfo2 pci2 = new IProvideClassInfo2(ppvObject[0]);
+ GUID riid = new GUID();
+ int result = pci2.GetGUID(COM.GUIDKIND_DEFAULT_SOURCE_DISP_IID, riid);
+ pci2.Release();
+ if (result == COM.S_OK) return riid;
+ }
+
+ // get Event Sink I/F from IProvideClassInfo
+ if (unknown.QueryInterface(COM.IIDIProvideClassInfo, ppvObject) == COM.S_OK) {
+ IProvideClassInfo pci = new IProvideClassInfo(ppvObject[0]);
+ int[] ppTI = new int[1];
+ int[] ppEI = new int[1];
+ int result = pci.GetClassInfo(ppTI);
+ pci.Release();
+
+ if (result == COM.S_OK && ppTI[0] != 0) {
+ ITypeInfo classInfo = new ITypeInfo(ppTI[0]);
+ int[] ppTypeAttr = new int[1];
+ result = classInfo.GetTypeAttr(ppTypeAttr);
+ if (result == COM.S_OK && ppTypeAttr[0] != 0) {
+ TYPEATTR 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[0] != 0) {
+ ITypeInfo eventInfo = new ITypeInfo(ppEI[0]);
+ ppTypeAttr = new int[1];
+ result = eventInfo.GetTypeAttr(ppTypeAttr);
+ GUID riid = null;
+ if (result == COM.S_OK && ppTypeAttr[0] != 0) {
+ riid = new GUID();
+ COM.MoveMemory(riid, ppTypeAttr[0], GUID.sizeof);
+ eventInfo.ReleaseTypeAttr(ppTypeAttr[0]);
+ }
+ eventInfo.Release();
+ return riid;
+ }
+ }
+ }
+ return null;
+}
+
+/**
+ * Adds the listener to receive events.
+ *
+ * @since 2.0
+ *
+ * @param automation the automation object that provides the event notification
+ *
+ * @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(OleAutomation automation, int eventID, OleListener listener) {
+ if (listener == null || automation == null) OLE.error (SWT.ERROR_NULL_ARGUMENT);
+ int address = automation.getAddress();
+ IUnknown unknown = new IUnknown(address);
+ GUID riid = getDefaultEventSinkGUID(unknown);
+ if (riid != null) {
+ addEventListener(address, riid, eventID, listener);
+ }
+
+}
+void addEventListener(int iunknown, GUID guid, int eventID, OleListener listener) {
+ if (listener == null || iunknown == 0 || guid == null) OLE.error (SWT.ERROR_NULL_ARGUMENT);
+ // have we connected to this kind of event sink before?
+ int index = -1;
+ for (int i = 0; i < oleEventSinkGUID.length; i++) {
+ if (COM.IsEqualGUID(oleEventSinkGUID[i], guid)) {
+ if (iunknown == oleEventSinkIUnknown[i]) {
+ index = i;
+ break;
+ }
+ }
+ }
+ if (index != -1) {
+ oleEventSink[index].addListener(eventID, listener);
+ } else {
+ int oldLength = oleEventSink.length;
+ OleEventSink[] newOleEventSink = new OleEventSink[oldLength + 1];
+ GUID[] newOleEventSinkGUID = new GUID[oldLength + 1];
+ int[] newOleEventSinkIUnknown = new int[oldLength + 1];
+ System.arraycopy(oleEventSink, 0, newOleEventSink, 0, oldLength);
+ System.arraycopy(oleEventSinkGUID, 0, newOleEventSinkGUID, 0, oldLength);
+ System.arraycopy(oleEventSinkIUnknown, 0, newOleEventSinkIUnknown, 0, oldLength);
+ oleEventSink = newOleEventSink;
+ oleEventSinkGUID = newOleEventSinkGUID;
+ oleEventSinkIUnknown = newOleEventSinkIUnknown;
+
+ oleEventSink[oldLength] = new OleEventSink(this, iunknown, guid);
+ oleEventSinkGUID[oldLength] = guid;
+ oleEventSinkIUnknown[oldLength] = iunknown;
+ oleEventSink[oldLength].AddRef();
+ oleEventSink[oldLength].connect();
+ oleEventSink[oldLength].addListener(eventID, listener);
+
+ }
+}
+protected void addObjectReferences() {
+
+ super.addObjectReferences();
+
+ // 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 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, 5, 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 disconnectEventSinks() {
+
+ for (int i = 0; i < oleEventSink.length; i++) {
+ OleEventSink sink = oleEventSink[i];
+ sink.disconnect();
+ sink.Release();
+ }
+ oleEventSink = new OleEventSink[0];
+ oleEventSinkGUID = new GUID[0];
+ oleEventSinkIUnknown = new int[0];
+}
+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;
+}
+/**
+ *
+ * Get the control site property specified by the dispIdMember.
+ *
+ * @since 2.1
+ *
+ */
+public Variant getSiteProperty(int dispId){
+ for (int i = 0; i < sitePropertyIds.length; i++) {
+ if (sitePropertyIds[i] == dispId) {
+ return sitePropertyValues[i];
+ }
+ }
+ 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[] {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;
+ }
+ Variant result = getSiteProperty(dispIdMember);
+ if (result != null) {
+ if (pVarResult != 0) result.getData(pVarResult);
+ return COM.S_OK;
+ }
+ switch (dispIdMember) {
+ // 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;
+ }
+}
+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;
+}
+void onFocusIn(Event e) {
+ if (objIOleInPlaceObject == null) return;
+ doVerb(OLE.OLEIVERB_UIACTIVATE);
+ if (isFocusControl()) return;
+ int[] phwnd = new int[1];
+ objIOleInPlaceObject.GetWindow(phwnd);
+ if (phwnd[0] == 0) return;
+ OS.SetFocus(phwnd[0]);
+}
+void onFocusOut(Event e) {
+ if (objIOleInPlaceObject != null) {
+ objIOleInPlaceObject.UIDeactivate();
+ }
+}
+private int OnFocus(int fGotFocus) {
+ return COM.S_OK;
+}
+protected int OnUIDeactivate(int fUndoable) {
+ // controls don't need to do anything for
+ // border space or menubars
+ state = STATE_INPLACEACTIVE;
+ 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 int Release() {
+ int result = super.Release();
+ if (result == 0) {
+ for (int i = 0; i < sitePropertyIds.length; i++) {
+ sitePropertyValues[i].dispose();
+ }
+ sitePropertyIds = new int[0];
+ sitePropertyValues = new Variant[0];
+ }
+ return result;
+}
+protected void releaseObjectInterfaces() {
+
+ disconnectEventSinks();
+
+ disconnectPropertyChangeSink();
+
+ super.releaseObjectInterfaces();
+}
+/**
+ * Removes the listener.
+ *
+ * @param eventID the event identifier
+ *
+ * @param listener the listener
+ *
+ * @exception SWTError
+ * <ul><li>ERROR_NULL_ARGUMENT when listener is null</li></ul>
+ */
+public void removeEventListener(int eventID, OleListener listener) {
+ checkWidget();
+ if (listener == null) throw new SWTError (SWT.ERROR_NULL_ARGUMENT);
+
+ GUID riid = getDefaultEventSinkGUID(objIUnknown);
+ if (riid != null) {
+ removeEventListener(objIUnknown.getAddress(), riid, eventID, listener);
+ }
+}
+/**
+ * Removes the listener.
+ *
+ * @since 2.0
+ * @deprecated - use OleControlSite.removeEventListener(OleAutomation, int, OleListener)
+ *
+ * @param automation the automation object that provides the event notification
+ *
+ * @param guid the identifier of the events COM interface
+ *
+ * @param eventID the event identifier
+ *
+ * @param listener the listener
+ *
+ * @exception SWTError
+ * <ul><li>ERROR_NULL_ARGUMENT when listener is null</li></ul>
+ */
+public void removeEventListener(OleAutomation automation, GUID guid, int eventID, OleListener listener) {
+ checkWidget();
+ if (automation == null || listener == null || guid == null) throw new SWTError (SWT.ERROR_NULL_ARGUMENT);
+ removeEventListener(automation.getAddress(), guid, eventID, listener);
+}
+/**
+ * Removes the listener.
+ *
+ * @since 2.0
+ *
+ * @param automation the automation object that provides the event notification
+ *
+ * @param eventID the event identifier
+ *
+ * @param listener the listener
+ *
+ * @exception SWTError
+ * <ul><li>ERROR_NULL_ARGUMENT when listener is null</li></ul>
+ */
+public void removeEventListener(OleAutomation automation, int eventID, OleListener listener) {
+ checkWidget();
+ if (automation == null || listener == null) throw new SWTError (SWT.ERROR_NULL_ARGUMENT);
+ int address = automation.getAddress();
+ IUnknown unknown = new IUnknown(address);
+ GUID riid = getDefaultEventSinkGUID(unknown);
+ if (riid != null) {
+ removeEventListener(address, riid, eventID, listener);
+ }
+}
+void removeEventListener(int iunknown, GUID guid, int eventID, OleListener listener) {
+ if (listener == null || guid == null) throw new SWTError (SWT.ERROR_NULL_ARGUMENT);
+ for (int i = 0; i < oleEventSink.length; i++) {
+ if (COM.IsEqualGUID(oleEventSinkGUID[i], guid)) {
+ if (iunknown == oleEventSinkIUnknown[i]) {
+ oleEventSink[i].removeListener(eventID, listener);
+ if (!oleEventSink[i].hasListeners()) {
+ //free resources associated with event sink
+ oleEventSink[i].disconnect();
+ oleEventSink[i].Release();
+ int oldLength = oleEventSink.length;
+ if (oldLength == 1) {
+ oleEventSink = new OleEventSink[0];
+ oleEventSinkGUID = new GUID[0];
+ oleEventSinkIUnknown = new int[0];
+ } else {
+ OleEventSink[] newOleEventSink = new OleEventSink[oldLength - 1];
+ System.arraycopy(oleEventSink, 0, newOleEventSink, 0, i);
+ System.arraycopy(oleEventSink, i + 1, newOleEventSink, i, oldLength - i - 1);
+ oleEventSink = newOleEventSink;
+
+ GUID[] newOleEventSinkGUID = new GUID[oldLength - 1];
+ System.arraycopy(oleEventSinkGUID, 0, newOleEventSinkGUID, 0, i);
+ System.arraycopy(oleEventSinkGUID, i + 1, newOleEventSinkGUID, i, oldLength - i - 1);
+ oleEventSinkGUID = newOleEventSinkGUID;
+
+ int[] newOleEventSinkIUnknown = new int[oldLength - 1];
+ System.arraycopy(oleEventSinkIUnknown, 0, newOleEventSinkIUnknown, 0, i);
+ System.arraycopy(oleEventSinkIUnknown, i + 1, newOleEventSinkIUnknown, i, oldLength - i - 1);
+ oleEventSinkIUnknown = newOleEventSinkIUnknown;
+ }
+ }
+ return;
+ }
+ }
+ }
+}
+/**
+ * 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();
+ }
+}
+/**
+ * Sets the control site property specified by the dispIdMember to a new value.
+ * The value will be disposed by the control site when it is no longer required
+ * using Variant.dispose. Passing a value of null will clear the dispId value.
+ *
+ * @param dispId the ID of the property as specified by the IDL of the ActiveX Control
+ * @param value The new value for the property as expressed in a Variant.
+ *
+ * @since 2.1
+ */
+public void setSiteProperty(int dispId, Variant value){
+ for (int i = 0; i < sitePropertyIds.length; i++) {
+ if (sitePropertyIds[i] == dispId) {
+ if (sitePropertyValues[i] != null) {
+ sitePropertyValues[i].dispose();
+ }
+ if (value != null) {
+ sitePropertyValues[i] = value;
+ } else {
+ int oldLength = sitePropertyIds.length;
+ int[] newSitePropertyIds = new int[oldLength - 1];
+ Variant[] newSitePropertyValues = new Variant[oldLength - 1];
+ System.arraycopy(sitePropertyIds, 0, newSitePropertyIds, 0, i);
+ System.arraycopy(sitePropertyIds, i + 1, newSitePropertyIds, i, oldLength - i - 1);
+ System.arraycopy(sitePropertyValues, 0, newSitePropertyValues, 0, i);
+ System.arraycopy(sitePropertyValues, i + 1, newSitePropertyValues, i, oldLength - i - 1);
+ sitePropertyIds = newSitePropertyIds;
+ sitePropertyValues = newSitePropertyValues;
+ }
+ return;
+ }
+ }
+ int oldLength = sitePropertyIds.length;
+ int[] newSitePropertyIds = new int[oldLength + 1];
+ Variant[] newSitePropertyValues = new Variant[oldLength + 1];
+ System.arraycopy(sitePropertyIds, 0, newSitePropertyIds, 0, oldLength);
+ System.arraycopy(sitePropertyValues, 0, newSitePropertyValues, 0, oldLength);
+ newSitePropertyIds[oldLength] = dispId;
+ newSitePropertyValues[oldLength] = value;
+ sitePropertyIds = newSitePropertyIds;
+ sitePropertyValues = newSitePropertyValues;
+}
} \ No newline at end of file
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
index ca9e263d7e..8de2769798 100755
--- 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
@@ -1,18 +1,18 @@
-package org.eclipse.swt.ole.win32;
-
-/*
+package org.eclipse.swt.ole.win32;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-import org.eclipse.swt.widgets.Widget;
-
-public class OleEvent {
- public int type;
- public Widget widget;
- public int detail;
- public boolean doit = true;
- public Variant[] arguments;
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+import org.eclipse.swt.widgets.Widget;
+
+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
index 4405b58521..2481b06144 100755
--- 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
@@ -1,177 +1,177 @@
-package org.eclipse.swt.ole.win32;
-
-/*
+package org.eclipse.swt.ole.win32;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-import org.eclipse.swt.*;
-import org.eclipse.swt.internal.ole.win32.*;
-
-final class OleEventSink
-{
- private OleControlSite widget;
-
- private COMObject iDispatch;
- private int refCount;
-
- private IUnknown objIUnknown;
- private int eventCookie;
- private GUID eventGuid;
-
- private OleEventTable eventTable;
-
-OleEventSink(OleControlSite widget, int iUnknown, GUID riid) {
-
- this.widget = widget;
- this.eventGuid = riid;
- this.objIUnknown = new IUnknown(iUnknown);
-
- createCOMInterfaces();
-}
-
-void connect () {
- 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(eventGuid, ppCP) == COM.S_OK) {
- IConnectionPoint cp = new IConnectionPoint(ppCP[0]);
- int[] pCookie = new int[1];
- if (cp.Advise(iDispatch.getAddress(), pCookie) == COM.S_OK)
- eventCookie = pCookie[0];
- cp.Release();
- }
- cpc.Release();
- }
-}
-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;
-}
-private void createCOMInterfaces() {
- 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() {
- // 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(eventGuid, 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 (iDispatch != null)
- iDispatch.dispose();
- iDispatch = null;
-
-}
-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;
- try {
- notifyListener(dispIdMember,event);
- } catch (Throwable t) {
- }
-
- 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 = widget;
- 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, eventGuid)) {
- 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);
-}
-boolean hasListeners() {
- return eventTable.hasEntries();
-}
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+import org.eclipse.swt.*;
+import org.eclipse.swt.internal.ole.win32.*;
+
+final class OleEventSink
+{
+ private OleControlSite widget;
+
+ private COMObject iDispatch;
+ private int refCount;
+
+ private IUnknown objIUnknown;
+ private int eventCookie;
+ private GUID eventGuid;
+
+ private OleEventTable eventTable;
+
+OleEventSink(OleControlSite widget, int iUnknown, GUID riid) {
+
+ this.widget = widget;
+ this.eventGuid = riid;
+ this.objIUnknown = new IUnknown(iUnknown);
+
+ createCOMInterfaces();
+}
+
+void connect () {
+ 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(eventGuid, ppCP) == COM.S_OK) {
+ IConnectionPoint cp = new IConnectionPoint(ppCP[0]);
+ int[] pCookie = new int[1];
+ if (cp.Advise(iDispatch.getAddress(), pCookie) == COM.S_OK)
+ eventCookie = pCookie[0];
+ cp.Release();
+ }
+ cpc.Release();
+ }
+}
+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;
+}
+private void createCOMInterfaces() {
+ 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() {
+ // 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(eventGuid, 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 (iDispatch != null)
+ iDispatch.dispose();
+ iDispatch = null;
+
+}
+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;
+ try {
+ notifyListener(dispIdMember,event);
+ } catch (Throwable t) {
+ }
+
+ 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 = widget;
+ 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, eventGuid)) {
+ 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);
+}
+boolean hasListeners() {
+ return eventTable.hasEntries();
+}
+}
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
index 47bfd49841..f80bb28cca 100755
--- 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
@@ -1,71 +1,71 @@
-package org.eclipse.swt.ole.win32;
-
-/*
+package org.eclipse.swt.ole.win32;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-/**
-* 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 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;
- }
- }
-}
-boolean hasEntries() {
- for (int i=0; i<types.length; i++) {
- if (types[i] != 0) return true;
- }
- return false;
-}
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+/**
+* 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 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;
+ }
+ }
+}
+boolean hasEntries() {
+ for (int i=0; i<types.length; i++) {
+ if (types[i] != 0) return true;
+ }
+ return false;
+}
+}
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
index 71d7040da5..01132a16da 100755
--- 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
@@ -1,128 +1,128 @@
-package org.eclipse.swt.ole.win32;
-
-/*
+package org.eclipse.swt.ole.win32;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-import java.io.*;
-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();
-
-}
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+import java.io.*;
+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
index 71219cafc4..35c49530b7 100755
--- 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
@@ -1,689 +1,689 @@
-package org.eclipse.swt.ole.win32;
-
-/*
+package org.eclipse.swt.ole.win32;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-import org.eclipse.swt.*;
-import org.eclipse.swt.internal.ole.win32.*;
-import org.eclipse.swt.widgets.*;
-import org.eclipse.swt.internal.win32.*;
-import org.eclipse.swt.internal.*;
-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 Listener listener;
-
- private static String CHECK_FOCUS = "OLE_CHECK_FOCUS";
- private static String HHOOK = "OLE_HHOOK";
- private static String HHOOKMSG = "OLE_HHOOK_MSG";
-
-/**
- * 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 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);
- }
- }
- };
-
- addListener(SWT.Dispose, listener);
-
- // inform inplaceactiveobject whenever frame resizes
- addListener(SWT.Resize, listener);
-
- // inform inplaceactiveobject whenever frame moves
- addListener(SWT.Move, listener);
-
- // 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
- Display display = getDisplay();
- initCheckFocus(display);
- initMsgHook(display);
-}
-private static void initCheckFocus (final Display display) {
- if (display.getData(CHECK_FOCUS) != 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() {
- if (lastFocus[0] instanceof OleClientSite && !lastFocus[0].isDisposed()) {
- // ignore popup menus and dialogs
- int hwnd = OS.GetFocus();
- while (hwnd != 0) {
- int ownerHwnd = OS.GetWindow(hwnd, 4/*GW_OWNER*/);
- if (ownerHwnd != 0) {
- display.timerExec(time, timer[0]);
- return;
- }
- hwnd = OS.GetParent(hwnd);
- }
- }
- if (lastFocus[0] == null || lastFocus[0].isDisposed() || !lastFocus[0].isFocusControl()) {
- Control currentFocus = display.getFocusControl();
- if (currentFocus instanceof OleFrame) {
- OleFrame frame = (OleFrame) currentFocus;
- currentFocus = frame.getCurrentDocument();
- }
- if (lastFocus[0] != currentFocus) {
- Event event = new Event();
- if (lastFocus[0] instanceof OleClientSite && !lastFocus[0].isDisposed()) {
- lastFocus[0].notifyListeners (SWT.FocusOut, event);
- }
- if (currentFocus instanceof OleClientSite && !currentFocus.isDisposed()) {
- currentFocus.notifyListeners(SWT.FocusIn, event);
- }
- }
- lastFocus[0] = currentFocus;
- }
- display.timerExec(time, timer[0]);
- }
- };
- display.timerExec(time, timer[0]);
-}
-private static void initMsgHook(Display display) {
- if (display.getData(HHOOK) != null) return;
- final Callback callback = new Callback(OleFrame.class, "getMsgProc", 3);
- int address = callback.getAddress();
- int threadId = OS.GetCurrentThreadId();
- final int hHook = OS.SetWindowsHookEx(OS.WH_GETMESSAGE, address, 0, threadId);
- if (hHook == 0) {
- callback.dispose();
- return;
- }
- display.setData(HHOOK, new Integer(hHook));
- display.setData(HHOOKMSG, new MSG());
- display.disposeExec(new Runnable() {
- public void run() {
- if (hHook != 0) OS.UnhookWindowsHookEx(hHook);
- if (callback != null) callback.dispose();
- }
- });
-}
-static int getMsgProc(int code, int wParam, int lParam) {
- Display display = Display.getCurrent();
- if (display == null) return 0;
- Integer hHook = (Integer)display.getData(HHOOK);
- if (hHook == null) return 0;
- if (code < 0) {
- return OS.CallNextHookEx(hHook.intValue(), code, wParam, lParam);
- }
- MSG msg = (MSG)display.getData(HHOOKMSG);
- OS.MoveMemory(msg, lParam, MSG.sizeof);
- int message = msg.message;
- if (OS.WM_KEYFIRST <= message && message <= OS.WM_KEYLAST) {
- if (display != null) {
- Widget widget = null;
- int hwnd = msg.hwnd;
- while (hwnd != 0) {
- widget = display.findWidget (hwnd);
- if (widget != null) break;
- hwnd = OS.GetParent (hwnd);
- }
- if (widget != null && widget instanceof OleClientSite) {
- OleClientSite site = (OleClientSite)widget;
- if (site.handle == hwnd) {
- OleFrame frame = site.frame;
- if (frame.translateOleAccelerator(msg)) {
- // In order to prevent this message from also being processed
- // by the application, zero out message, wParam and lParam
- OS.MoveMemory(lParam + 4, new int[] {OS.WM_NULL, 0, 0}, 12);
- return 0;
- }
- }
- }
- }
- }
- return OS.CallNextHookEx(hHook.intValue(), code, wParam, lParam);
-}
-/**
- * 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();
-}
-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
- Menu menubar = getShell().getMenuBar();
- 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 cch = 128;
- int byteCount = cch * TCHAR.sizeof;
- int pszText = OS.HeapAlloc(hHeap, OS.HEAP_ZERO_MEMORY, byteCount);
- lpmii.cbSize = MENUITEMINFO.sizeof;
- lpmii.fMask = OS.MIIM_STATE | OS.MIIM_ID | OS.MIIM_TYPE | OS.MIIM_SUBMENU | OS.MIIM_DATA;
- lpmii.dwTypeData = pszText;
- lpmii.cch = cch;
-
- // 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 = cch; // lpmii.cch gets updated by GetMenuItemInfo to indicate the
- // exact number 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 = cch; // 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 = cch; // 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();
- removeListener(SWT.Dispose, listener);
- removeListener(SWT.Resize, listener);
- removeListener(SWT.Move, listener);
-}
-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) {
-
- Menu menubar = getShell().getMenuBar();
- 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.
- if (objIOleInPlaceActiveObject == null) return COM.S_OK;
- 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;
-}
-private int SetMenu(int hmenuShared, int holemenu, int hwndActiveObject) {
- int inPlaceActiveObject = 0;
- if (objIOleInPlaceActiveObject != null)
- inPlaceActiveObject = objIOleInPlaceActiveObject.getAddress();
-
- Menu menubar = getShell().getMenuBar();
- 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);
-}
-/**
- *
- * 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 boolean translateOleAccelerator(MSG msg) {
- if (objIOleInPlaceActiveObject == null) return false;
- int result = objIOleInPlaceActiveObject.TranslateAccelerator(msg);
- return (result != COM.S_FALSE && result != COM.E_NOTIMPL);
-}
-private int TranslateAccelerator(int lpmsg, int wID){
- Menu menubar = getShell().getMenuBar();
- if (menubar == null || menubar.isDisposed() || !menubar.isEnabled()) return COM.S_FALSE;
- if (wID < 0) return COM.S_FALSE;
-
- Shell shell = menubar.getShell();
- int hwnd = shell.handle;
- int hAccel = OS.SendMessage(hwnd, OS.WM_APP+1, 0, 0);
- if (hAccel == 0) return COM.S_FALSE;
-
- MSG msg = new MSG();
- OS.MoveMemory(msg, lpmsg, MSG.sizeof);
- int result = OS.TranslateAccelerator(hwnd, hAccel, msg);
- return result == 0 ? COM.S_FALSE : COM.S_OK;
-}
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+import org.eclipse.swt.*;
+import org.eclipse.swt.internal.ole.win32.*;
+import org.eclipse.swt.widgets.*;
+import org.eclipse.swt.internal.win32.*;
+import org.eclipse.swt.internal.*;
+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 Listener listener;
+
+ private static String CHECK_FOCUS = "OLE_CHECK_FOCUS";
+ private static String HHOOK = "OLE_HHOOK";
+ private static String HHOOKMSG = "OLE_HHOOK_MSG";
+
+/**
+ * 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 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);
+ }
+ }
+ };
+
+ addListener(SWT.Dispose, listener);
+
+ // inform inplaceactiveobject whenever frame resizes
+ addListener(SWT.Resize, listener);
+
+ // inform inplaceactiveobject whenever frame moves
+ addListener(SWT.Move, listener);
+
+ // 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
+ Display display = getDisplay();
+ initCheckFocus(display);
+ initMsgHook(display);
+}
+private static void initCheckFocus (final Display display) {
+ if (display.getData(CHECK_FOCUS) != 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() {
+ if (lastFocus[0] instanceof OleClientSite && !lastFocus[0].isDisposed()) {
+ // ignore popup menus and dialogs
+ int hwnd = OS.GetFocus();
+ while (hwnd != 0) {
+ int ownerHwnd = OS.GetWindow(hwnd, 4/*GW_OWNER*/);
+ if (ownerHwnd != 0) {
+ display.timerExec(time, timer[0]);
+ return;
+ }
+ hwnd = OS.GetParent(hwnd);
+ }
+ }
+ if (lastFocus[0] == null || lastFocus[0].isDisposed() || !lastFocus[0].isFocusControl()) {
+ Control currentFocus = display.getFocusControl();
+ if (currentFocus instanceof OleFrame) {
+ OleFrame frame = (OleFrame) currentFocus;
+ currentFocus = frame.getCurrentDocument();
+ }
+ if (lastFocus[0] != currentFocus) {
+ Event event = new Event();
+ if (lastFocus[0] instanceof OleClientSite && !lastFocus[0].isDisposed()) {
+ lastFocus[0].notifyListeners (SWT.FocusOut, event);
+ }
+ if (currentFocus instanceof OleClientSite && !currentFocus.isDisposed()) {
+ currentFocus.notifyListeners(SWT.FocusIn, event);
+ }
+ }
+ lastFocus[0] = currentFocus;
+ }
+ display.timerExec(time, timer[0]);
+ }
+ };
+ display.timerExec(time, timer[0]);
+}
+private static void initMsgHook(Display display) {
+ if (display.getData(HHOOK) != null) return;
+ final Callback callback = new Callback(OleFrame.class, "getMsgProc", 3);
+ int address = callback.getAddress();
+ int threadId = OS.GetCurrentThreadId();
+ final int hHook = OS.SetWindowsHookEx(OS.WH_GETMESSAGE, address, 0, threadId);
+ if (hHook == 0) {
+ callback.dispose();
+ return;
+ }
+ display.setData(HHOOK, new Integer(hHook));
+ display.setData(HHOOKMSG, new MSG());
+ display.disposeExec(new Runnable() {
+ public void run() {
+ if (hHook != 0) OS.UnhookWindowsHookEx(hHook);
+ if (callback != null) callback.dispose();
+ }
+ });
+}
+static int getMsgProc(int code, int wParam, int lParam) {
+ Display display = Display.getCurrent();
+ if (display == null) return 0;
+ Integer hHook = (Integer)display.getData(HHOOK);
+ if (hHook == null) return 0;
+ if (code < 0) {
+ return OS.CallNextHookEx(hHook.intValue(), code, wParam, lParam);
+ }
+ MSG msg = (MSG)display.getData(HHOOKMSG);
+ OS.MoveMemory(msg, lParam, MSG.sizeof);
+ int message = msg.message;
+ if (OS.WM_KEYFIRST <= message && message <= OS.WM_KEYLAST) {
+ if (display != null) {
+ Widget widget = null;
+ int hwnd = msg.hwnd;
+ while (hwnd != 0) {
+ widget = display.findWidget (hwnd);
+ if (widget != null) break;
+ hwnd = OS.GetParent (hwnd);
+ }
+ if (widget != null && widget instanceof OleClientSite) {
+ OleClientSite site = (OleClientSite)widget;
+ if (site.handle == hwnd) {
+ OleFrame frame = site.frame;
+ if (frame.translateOleAccelerator(msg)) {
+ // In order to prevent this message from also being processed
+ // by the application, zero out message, wParam and lParam
+ OS.MoveMemory(lParam + 4, new int[] {OS.WM_NULL, 0, 0}, 12);
+ return 0;
+ }
+ }
+ }
+ }
+ }
+ return OS.CallNextHookEx(hHook.intValue(), code, wParam, lParam);
+}
+/**
+ * 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();
+}
+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
+ Menu menubar = getShell().getMenuBar();
+ 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 cch = 128;
+ int byteCount = cch * TCHAR.sizeof;
+ int pszText = OS.HeapAlloc(hHeap, OS.HEAP_ZERO_MEMORY, byteCount);
+ lpmii.cbSize = MENUITEMINFO.sizeof;
+ lpmii.fMask = OS.MIIM_STATE | OS.MIIM_ID | OS.MIIM_TYPE | OS.MIIM_SUBMENU | OS.MIIM_DATA;
+ lpmii.dwTypeData = pszText;
+ lpmii.cch = cch;
+
+ // 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 = cch; // lpmii.cch gets updated by GetMenuItemInfo to indicate the
+ // exact number 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 = cch; // 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 = cch; // 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();
+ removeListener(SWT.Dispose, listener);
+ removeListener(SWT.Resize, listener);
+ removeListener(SWT.Move, listener);
+}
+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) {
+
+ Menu menubar = getShell().getMenuBar();
+ 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.
+ if (objIOleInPlaceActiveObject == null) return COM.S_OK;
+ 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;
+}
+private int SetMenu(int hmenuShared, int holemenu, int hwndActiveObject) {
+ int inPlaceActiveObject = 0;
+ if (objIOleInPlaceActiveObject != null)
+ inPlaceActiveObject = objIOleInPlaceActiveObject.getAddress();
+
+ Menu menubar = getShell().getMenuBar();
+ 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);
+}
+/**
+ *
+ * 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 boolean translateOleAccelerator(MSG msg) {
+ if (objIOleInPlaceActiveObject == null) return false;
+ int result = objIOleInPlaceActiveObject.TranslateAccelerator(msg);
+ return (result != COM.S_FALSE && result != COM.E_NOTIMPL);
+}
+private int TranslateAccelerator(int lpmsg, int wID){
+ Menu menubar = getShell().getMenuBar();
+ if (menubar == null || menubar.isDisposed() || !menubar.isEnabled()) return COM.S_FALSE;
+ if (wID < 0) return COM.S_FALSE;
+
+ Shell shell = menubar.getShell();
+ int hwnd = shell.handle;
+ int hAccel = OS.SendMessage(hwnd, OS.WM_APP+1, 0, 0);
+ if (hAccel == 0) return COM.S_FALSE;
+
+ MSG msg = new MSG();
+ OS.MoveMemory(msg, lpmsg, MSG.sizeof);
+ int result = OS.TranslateAccelerator(hwnd, hAccel, msg);
+ return result == 0 ? COM.S_FALSE : COM.S_OK;
+}
+}
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
index 7531274560..12f15e0d27 100755
--- 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
@@ -1,24 +1,24 @@
-package org.eclipse.swt.ole.win32;
-
-/*
+package org.eclipse.swt.ole.win32;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-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;
-
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+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;
+
}
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
index 91053ac323..0ea62cb004 100755
--- 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
@@ -1,18 +1,18 @@
-package org.eclipse.swt.ole.win32;
-
-/*
+package org.eclipse.swt.ole.win32;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-/**
- */
-public interface OleListener
-{
-/**
- *
- */
-public void handleEvent(OleEvent event);
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+/**
+ */
+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
index 1fdd097464..bce1389964 100755
--- 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
@@ -1,14 +1,14 @@
-package org.eclipse.swt.ole.win32;
-
-/*
+package org.eclipse.swt.ole.win32;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-public class OleParameterDescription {
- public String name;
- public short flags;
- public short type;
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+public class OleParameterDescription {
+ public String name;
+ public short flags;
+ public short type;
}
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
index 2dd70dd28e..c379e78a58 100755
--- 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
@@ -1,187 +1,187 @@
-package org.eclipse.swt.ole.win32;
-
-/*
+package org.eclipse.swt.ole.win32;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-import org.eclipse.swt.internal.ole.win32.*;
-import org.eclipse.swt.*;
-
-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;
- try {
- notifyListener(dispID,event);
- } catch (Throwable e) {
- }
-
- 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;
-
- try {
- notifyListener(dispID,event);
- } catch (Throwable e) {
- }
-
- 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);
-}
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+import org.eclipse.swt.internal.ole.win32.*;
+import org.eclipse.swt.*;
+
+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;
+ try {
+ notifyListener(dispID,event);
+ } catch (Throwable e) {
+ }
+
+ 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;
+
+ try {
+ notifyListener(dispID,event);
+ } catch (Throwable e) {
+ }
+
+ 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
index 9718db922a..dc3cf47a18 100755
--- 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
@@ -1,18 +1,18 @@
-package org.eclipse.swt.ole.win32;
-
-/*
+package org.eclipse.swt.ole.win32;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-public class OlePropertyDescription {
- public int id;
- public String name;
- public int type;
- public int flags;
- public int kind;
- public String description;
- public String helpFile;
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+public class OlePropertyDescription {
+ public int id;
+ public String name;
+ public int type;
+ public int flags;
+ public int kind;
+ public String description;
+ public String helpFile;
}
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
index a046946931..792fcf2f87 100755
--- 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
@@ -1,741 +1,741 @@
-package org.eclipse.swt.ole.win32;
-
-/*
+package org.eclipse.swt.ole.win32;
+
+/*
* Copyright (c) 2000, 2003 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-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 IDispatch dispatchData;
- private IUnknown unknownData;
-
-/**
- * Create an empty Variant object with type VT_EMPTY.
- *
- * @since 2.0
- */
-public 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
- *
- * <pre><code>short byRefType = OLE.VT_BSTR | OLE.VT_BYREF</code></pre>.
- *
- * @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 = new IDispatch(automation.getAddress());
-}
-/**
- * Create a Variant object which represents an IDispatch interface as a VT_Dispatch.
- * <p>The caller is expected to have appropriately invoked unknown.AddRef() before creating
- * this Variant.
- *
- * @since 2.0
- *
- * @param idispatch the IDispatch object that this Variant represents
- *
- */
-public Variant(IDispatch idispatch) {
- type = COM.VT_DISPATCH;
- dispatchData = idispatch;
-}
-/**
- * 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;
-}
-
-/**
- * Calling dispose will release resources associated with this Variant.
- * If the resource is an IDispatch or IUnknown interface, Release will be called.
- * If the resource is a ByRef pointer, nothing is released.
- *
- * @since 2.1
- */
-public void dispose() {
- if ((type & COM.VT_BYREF) == COM.VT_BYREF) {
- return;
- }
-
- switch (type) {
- case COM.VT_EMPTY :
- case COM.VT_BOOL :
- case COM.VT_R4 :
- case COM.VT_I4 :
- case COM.VT_I2 :
- case COM.VT_BSTR :
- break;
- case COM.VT_DISPATCH :
- dispatchData.Release();
- break;
- case COM.VT_UNKNOWN :
- unknownData.Release();
- break;
- }
-
-}
-/**
- * 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. Note that OleAutomation objects must be disposed when no longer
- * needed.
- *
- * @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_EMPTY) {
- OLE.error(OLE.ERROR_CANNOT_CHANGE_VARIANT_TYPE, -1);
- }
- if (type == COM.VT_DISPATCH) {
- return new OleAutomation(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 IDispatch object represented by this Variant.
- *
- * <p>If this Variant does not contain an IDispatch object, an attempt is made to
- * coerce the Variant type into an IDIspatch object. If this fails, an error is
- * thrown.
- *
- * @since 2.0
- *
- * @return the IDispatch object represented by this Variant
- *
- * @exception SWTError
- * ERROR_CANNOT_CHANGE_VARIANT_TYPE when type of Variant can not be coerced into an IDispatch object
- */
-public IDispatch getDispatch() {
- if (type == COM.VT_EMPTY) {
- OLE.error(OLE.ERROR_CANNOT_CHANGE_VARIANT_TYPE, -1);
- }
- 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.getDispatch();
- } 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_EMPTY) {
- OLE.error(OLE.ERROR_CANNOT_CHANGE_VARIANT_TYPE, -1);
- }
- 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_EMPTY) {
- OLE.error(OLE.ERROR_CANNOT_CHANGE_VARIANT_TYPE, -1);
- }
- 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 int[]{(booleanData) ? COM.VARIANT_TRUE : COM.VARIANT_FALSE}, 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 :
- dispatchData.AddRef();
- COM.MoveMemory(pData, new short[] {type}, 2);
- COM.MoveMemory(pData + 8, new int[]{dispatchData.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_EMPTY) {
- OLE.error(OLE.ERROR_CANNOT_CHANGE_VARIANT_TYPE, -1);
- }
- 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_EMPTY) {
- OLE.error(OLE.ERROR_CANNOT_CHANGE_VARIANT_TYPE, -1);
- }
- 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_EMPTY) {
- OLE.error(OLE.ERROR_CANNOT_CHANGE_VARIANT_TYPE, -1);
- }
- 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_EMPTY) {
- OLE.error(OLE.ERROR_CANNOT_CHANGE_VARIANT_TYPE, -1);
- }
- 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);
- }
-}
-/**
- * Returns the ytpe of the variant type. This will be an OLE.VT_* value or
- * a bitwise combination of OLE.VT_* values as in the case of
- * OLE.VT_BSTR | OLE.VT_BYREF.
- *
- * @return the type of the variant data
- *
- * @since 2.0
- */
-public 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_EMPTY) {
- OLE.error(OLE.ERROR_CANNOT_CHANGE_VARIANT_TYPE, -1);
- }
- 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);
- }
-}
-/**
- * Update the by reference value of this variant with a new boolean value.
- *
- * @param val the new boolean value
- *
- * @exception SWTError
- * <ul><li>ERROR_CANNOT_CHANGE_VARIANT_TYPE when type of Variant is not
- * a (VT_BYREF | VT_BOOL) object</ul>
- *
- * @since 2.1
- */
-public void setByRef(boolean val) {
- if ((type & COM.VT_BYREF) == 0 || (type & COM.VT_BOOL) == 0) {
- OLE.error(OLE.ERROR_CANNOT_CHANGE_VARIANT_TYPE);
- }
- COM.MoveMemory(byRefPtr, new short[]{val ? COM.VARIANT_TRUE : COM.VARIANT_FALSE}, 2);
-}
-/**
- * Update the by reference value of this variant with a new float value.
- *
- * @param val the new float value
- *
- * @exception SWTError
- * <ul><li>ERROR_CANNOT_CHANGE_VARIANT_TYPE when type of Variant is not
- * a (VT_BYREF | VT_R4) object</ul>
- *
- * @since 2.1
- */
-public void setByRef(float val) {
- if ((type & COM.VT_BYREF) == 0 || (type & COM.VT_R4) == 0) {
- OLE.error(OLE.ERROR_CANNOT_CHANGE_VARIANT_TYPE);
- }
- COM.MoveMemory(byRefPtr, new float[]{val}, 4);
-}
-/**
- * Update the by reference value of this variant with a new integer value.
- *
- * @param val the new integer value
- *
- * @exception SWTError
- * <ul><li>ERROR_CANNOT_CHANGE_VARIANT_TYPE when type of Variant is not
- * a (VT_BYREF | VT_I4) object</ul>
- *
- * @since 2.1
- */
-public void setByRef(int val) {
- if ((type & COM.VT_BYREF) == 0 || (type & COM.VT_I4) == 0) {
- OLE.error(OLE.ERROR_CANNOT_CHANGE_VARIANT_TYPE);
- }
- COM.MoveMemory(byRefPtr, new int[]{val}, 4);
-}
-/**
- * Update the by reference value of this variant with a new short value.
- *
- * @param val the new short value
- *
- * @exception SWTError
- * <ul><li>ERROR_CANNOT_CHANGE_VARIANT_TYPE when type of Variant is not
- * a (VT_BYREF | VT_I2) object</ul>
- *
- * @since 2.1
- */
-public void setByRef(short val) {
- if ((type & COM.VT_BYREF) == 0 || (type & COM.VT_I2) == 0) {
- OLE.error(OLE.ERROR_CANNOT_CHANGE_VARIANT_TYPE);
- }
- COM.MoveMemory(byRefPtr, new short[]{val}, 2);
-}
-
-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] != COM.VARIANT_FALSE);
- 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[] ppvObject = new int[1];
- OS.MoveMemory(ppvObject, pData + 8, 4);
- if (ppvObject[0] == 0) {
- type = COM.VT_EMPTY;
- break;
- }
- dispatchData = new IDispatch(ppvObject[0]);
- dispatchData.AddRef();
- break;
- }
- case COM.VT_UNKNOWN : {
- int[] ppvObject = new int[1];
- OS.MoveMemory(ppvObject, pData + 8, 4);
- if (ppvObject[0] == 0) {
- type = COM.VT_EMPTY;
- break;
- }
- unknownData = new IUnknown(ppvObject[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);
- if (hMem[0] == 0) {
- type = COM.VT_EMPTY;
- break;
- }
- // 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);
- } else {
- stringData = "";
- }
- 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;
- }
-}
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+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 IDispatch dispatchData;
+ private IUnknown unknownData;
+
+/**
+ * Create an empty Variant object with type VT_EMPTY.
+ *
+ * @since 2.0
+ */
+public 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
+ *
+ * <pre><code>short byRefType = OLE.VT_BSTR | OLE.VT_BYREF</code></pre>.
+ *
+ * @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 = new IDispatch(automation.getAddress());
+}
+/**
+ * Create a Variant object which represents an IDispatch interface as a VT_Dispatch.
+ * <p>The caller is expected to have appropriately invoked unknown.AddRef() before creating
+ * this Variant.
+ *
+ * @since 2.0
+ *
+ * @param idispatch the IDispatch object that this Variant represents
+ *
+ */
+public Variant(IDispatch idispatch) {
+ type = COM.VT_DISPATCH;
+ dispatchData = idispatch;
+}
+/**
+ * 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;
+}
+
+/**
+ * Calling dispose will release resources associated with this Variant.
+ * If the resource is an IDispatch or IUnknown interface, Release will be called.
+ * If the resource is a ByRef pointer, nothing is released.
+ *
+ * @since 2.1
+ */
+public void dispose() {
+ if ((type & COM.VT_BYREF) == COM.VT_BYREF) {
+ return;
+ }
+
+ switch (type) {
+ case COM.VT_EMPTY :
+ case COM.VT_BOOL :
+ case COM.VT_R4 :
+ case COM.VT_I4 :
+ case COM.VT_I2 :
+ case COM.VT_BSTR :
+ break;
+ case COM.VT_DISPATCH :
+ dispatchData.Release();
+ break;
+ case COM.VT_UNKNOWN :
+ unknownData.Release();
+ break;
+ }
+
+}
+/**
+ * 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. Note that OleAutomation objects must be disposed when no longer
+ * needed.
+ *
+ * @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_EMPTY) {
+ OLE.error(OLE.ERROR_CANNOT_CHANGE_VARIANT_TYPE, -1);
+ }
+ if (type == COM.VT_DISPATCH) {
+ return new OleAutomation(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 IDispatch object represented by this Variant.
+ *
+ * <p>If this Variant does not contain an IDispatch object, an attempt is made to
+ * coerce the Variant type into an IDIspatch object. If this fails, an error is
+ * thrown.
+ *
+ * @since 2.0
+ *
+ * @return the IDispatch object represented by this Variant
+ *
+ * @exception SWTError
+ * ERROR_CANNOT_CHANGE_VARIANT_TYPE when type of Variant can not be coerced into an IDispatch object
+ */
+public IDispatch getDispatch() {
+ if (type == COM.VT_EMPTY) {
+ OLE.error(OLE.ERROR_CANNOT_CHANGE_VARIANT_TYPE, -1);
+ }
+ 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.getDispatch();
+ } 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_EMPTY) {
+ OLE.error(OLE.ERROR_CANNOT_CHANGE_VARIANT_TYPE, -1);
+ }
+ 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_EMPTY) {
+ OLE.error(OLE.ERROR_CANNOT_CHANGE_VARIANT_TYPE, -1);
+ }
+ 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 int[]{(booleanData) ? COM.VARIANT_TRUE : COM.VARIANT_FALSE}, 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 :
+ dispatchData.AddRef();
+ COM.MoveMemory(pData, new short[] {type}, 2);
+ COM.MoveMemory(pData + 8, new int[]{dispatchData.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_EMPTY) {
+ OLE.error(OLE.ERROR_CANNOT_CHANGE_VARIANT_TYPE, -1);
+ }
+ 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_EMPTY) {
+ OLE.error(OLE.ERROR_CANNOT_CHANGE_VARIANT_TYPE, -1);
+ }
+ 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_EMPTY) {
+ OLE.error(OLE.ERROR_CANNOT_CHANGE_VARIANT_TYPE, -1);
+ }
+ 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_EMPTY) {
+ OLE.error(OLE.ERROR_CANNOT_CHANGE_VARIANT_TYPE, -1);
+ }
+ 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);
+ }
+}
+/**
+ * Returns the ytpe of the variant type. This will be an OLE.VT_* value or
+ * a bitwise combination of OLE.VT_* values as in the case of
+ * OLE.VT_BSTR | OLE.VT_BYREF.
+ *
+ * @return the type of the variant data
+ *
+ * @since 2.0
+ */
+public 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_EMPTY) {
+ OLE.error(OLE.ERROR_CANNOT_CHANGE_VARIANT_TYPE, -1);
+ }
+ 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);
+ }
+}
+/**
+ * Update the by reference value of this variant with a new boolean value.
+ *
+ * @param val the new boolean value
+ *
+ * @exception SWTError
+ * <ul><li>ERROR_CANNOT_CHANGE_VARIANT_TYPE when type of Variant is not
+ * a (VT_BYREF | VT_BOOL) object</ul>
+ *
+ * @since 2.1
+ */
+public void setByRef(boolean val) {
+ if ((type & COM.VT_BYREF) == 0 || (type & COM.VT_BOOL) == 0) {
+ OLE.error(OLE.ERROR_CANNOT_CHANGE_VARIANT_TYPE);
+ }
+ COM.MoveMemory(byRefPtr, new short[]{val ? COM.VARIANT_TRUE : COM.VARIANT_FALSE}, 2);
+}
+/**
+ * Update the by reference value of this variant with a new float value.
+ *
+ * @param val the new float value
+ *
+ * @exception SWTError
+ * <ul><li>ERROR_CANNOT_CHANGE_VARIANT_TYPE when type of Variant is not
+ * a (VT_BYREF | VT_R4) object</ul>
+ *
+ * @since 2.1
+ */
+public void setByRef(float val) {
+ if ((type & COM.VT_BYREF) == 0 || (type & COM.VT_R4) == 0) {
+ OLE.error(OLE.ERROR_CANNOT_CHANGE_VARIANT_TYPE);
+ }
+ COM.MoveMemory(byRefPtr, new float[]{val}, 4);
+}
+/**
+ * Update the by reference value of this variant with a new integer value.
+ *
+ * @param val the new integer value
+ *
+ * @exception SWTError
+ * <ul><li>ERROR_CANNOT_CHANGE_VARIANT_TYPE when type of Variant is not
+ * a (VT_BYREF | VT_I4) object</ul>
+ *
+ * @since 2.1
+ */
+public void setByRef(int val) {
+ if ((type & COM.VT_BYREF) == 0 || (type & COM.VT_I4) == 0) {
+ OLE.error(OLE.ERROR_CANNOT_CHANGE_VARIANT_TYPE);
+ }
+ COM.MoveMemory(byRefPtr, new int[]{val}, 4);
+}
+/**
+ * Update the by reference value of this variant with a new short value.
+ *
+ * @param val the new short value
+ *
+ * @exception SWTError
+ * <ul><li>ERROR_CANNOT_CHANGE_VARIANT_TYPE when type of Variant is not
+ * a (VT_BYREF | VT_I2) object</ul>
+ *
+ * @since 2.1
+ */
+public void setByRef(short val) {
+ if ((type & COM.VT_BYREF) == 0 || (type & COM.VT_I2) == 0) {
+ OLE.error(OLE.ERROR_CANNOT_CHANGE_VARIANT_TYPE);
+ }
+ COM.MoveMemory(byRefPtr, new short[]{val}, 2);
+}
+
+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] != COM.VARIANT_FALSE);
+ 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[] ppvObject = new int[1];
+ OS.MoveMemory(ppvObject, pData + 8, 4);
+ if (ppvObject[0] == 0) {
+ type = COM.VT_EMPTY;
+ break;
+ }
+ dispatchData = new IDispatch(ppvObject[0]);
+ dispatchData.AddRef();
+ break;
+ }
+ case COM.VT_UNKNOWN : {
+ int[] ppvObject = new int[1];
+ OS.MoveMemory(ppvObject, pData + 8, 4);
+ if (ppvObject[0] == 0) {
+ type = COM.VT_EMPTY;
+ break;
+ }
+ unknownData = new IUnknown(ppvObject[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);
+ if (hMem[0] == 0) {
+ type = COM.VT_EMPTY;
+ break;
+ }
+ // 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);
+ } else {
+ stringData = "";
+ }
+ 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 PI/common_j2me/org/eclipse/swt/internal/Library.java b/bundles/org.eclipse.swt/Eclipse SWT PI/common_j2me/org/eclipse/swt/internal/Library.java
index 561c78c51c..6b8f94e3be 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/common_j2me/org/eclipse/swt/internal/Library.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/common_j2me/org/eclipse/swt/internal/Library.java
@@ -1,65 +1,65 @@
-package org.eclipse.swt.internal;
-
-/*
+package org.eclipse.swt.internal;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-public class Library {
-
- /* SWT Version - Mmmm (M=major, mmm=minor) */
-
- /**
- * SWT Major version number (must be >= 0)
- */
- static int MAJOR_VERSION = 2;
-
- /**
- * SWT Minor version number (must be in the range 0..999)
- */
- static int MINOR_VERSION = 131;
-
- /**
- * SWT revision number (must be >= 0)
- */
- static int REVISION = 0;
-
-/**
- * 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 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;
-}
-
-/**
- * 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) {
-}
-
-}
-
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+public class Library {
+
+ /* SWT Version - Mmmm (M=major, mmm=minor) */
+
+ /**
+ * SWT Major version number (must be >= 0)
+ */
+ static int MAJOR_VERSION = 2;
+
+ /**
+ * SWT Minor version number (must be in the range 0..999)
+ */
+ static int MINOR_VERSION = 131;
+
+ /**
+ * SWT revision number (must be >= 0)
+ */
+ static int REVISION = 0;
+
+/**
+ * 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 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;
+}
+
+/**
+ * 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) {
+}
+
+}
+
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/common_j2se/org/eclipse/swt/internal/Library.java b/bundles/org.eclipse.swt/Eclipse SWT PI/common_j2se/org/eclipse/swt/internal/Library.java
index 32c970d37a..f3cc1eeca1 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/common_j2se/org/eclipse/swt/internal/Library.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/common_j2se/org/eclipse/swt/internal/Library.java
@@ -1,117 +1,117 @@
-package org.eclipse.swt.internal;
-
-/*
+package org.eclipse.swt.internal;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-public class Library {
-
- /* SWT Version - Mmmm (M=major, mmm=minor) */
-
- /**
- * SWT Major version number (must be >= 0)
- */
- static int MAJOR_VERSION = 2;
-
- /**
- * SWT Minor version number (must be in the range 0..999)
- */
- static int MINOR_VERSION = 131;
-
- /**
- * SWT revision number (must be >= 0)
- */
- static int REVISION = 0;
-
-/**
- * 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 platform name.
- *
- * @return the platform name of the currently running SWT
- */
-static String getPlatform () {
- String [] names = new String [] {"motif", "gtk", "win32", "photon", "carbon"};
- for (int i = 0; i < names.length; i++) {
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+public class Library {
+
+ /* SWT Version - Mmmm (M=major, mmm=minor) */
+
+ /**
+ * SWT Major version number (must be >= 0)
+ */
+ static int MAJOR_VERSION = 2;
+
+ /**
+ * SWT Minor version number (must be in the range 0..999)
+ */
+ static int MINOR_VERSION = 131;
+
+ /**
+ * SWT revision number (must be >= 0)
+ */
+ static int REVISION = 0;
+
+/**
+ * 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 platform name.
+ *
+ * @return the platform name of the currently running SWT
+ */
+static String getPlatform () {
+ String [] names = new String [] {"motif", "gtk", "win32", "photon", "carbon"};
+ for (int i = 0; i < names.length; i++) {
try {
- Class.forName("org.eclipse.swt.internal."+names[i]+".OS");
- return names[i];
- } catch (ClassNotFoundException e) {
+ Class.forName("org.eclipse.swt.internal."+names[i]+".OS");
+ return names[i];
+ } catch (ClassNotFoundException e) {
}
- }
- return "unknown";
-}
-
-/**
- * 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;
-}
-
-/**
- * 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) {
- /*
- * Include platform name to support different windowing systems
- * on same operating system.
- */
- String platform = getPlatform ();
-
- /*
- * Get version qualifier.
- */
- String version = System.getProperty ("swt.version");
- if (version == null) {
- version = "" + MAJOR_VERSION;
- /* Force 3 digits in minor version number */
- if (MINOR_VERSION < 10) {
- version += "00";
- } else {
- if (MINOR_VERSION < 100) version += "0";
- }
- version += MINOR_VERSION;
- /* No "r" until first revision */
- if (REVISION > 0) version += "r" + REVISION;
- }
-
- try {
- String newName = name + "-" + platform + "-" + version;
- System.loadLibrary (newName);
- return;
- } catch (UnsatisfiedLinkError e1) {
- try {
- String newName = name + "-" + platform;
- System.loadLibrary (newName);
- return;
- } catch (UnsatisfiedLinkError e2) {
- throw e1;
- }
- }
-}
-
-}
+ }
+ return "unknown";
+}
+
+/**
+ * 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;
+}
+
+/**
+ * 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) {
+ /*
+ * Include platform name to support different windowing systems
+ * on same operating system.
+ */
+ String platform = getPlatform ();
+
+ /*
+ * Get version qualifier.
+ */
+ String version = System.getProperty ("swt.version");
+ if (version == null) {
+ version = "" + MAJOR_VERSION;
+ /* Force 3 digits in minor version number */
+ if (MINOR_VERSION < 10) {
+ version += "00";
+ } else {
+ if (MINOR_VERSION < 100) version += "0";
+ }
+ version += MINOR_VERSION;
+ /* No "r" until first revision */
+ if (REVISION > 0) version += "r" + REVISION;
+ }
+
+ try {
+ String newName = name + "-" + platform + "-" + version;
+ System.loadLibrary (newName);
+ return;
+ } catch (UnsatisfiedLinkError e1) {
+ try {
+ String newName = name + "-" + platform;
+ System.loadLibrary (newName);
+ return;
+ } catch (UnsatisfiedLinkError e2) {
+ throw e1;
+ }
+ }
+}
+
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/GdkColor.java b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/GdkColor.java
index df5d77a1e6..ac6aa372dd 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/GdkColor.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/GdkColor.java
@@ -1,21 +1,21 @@
-package org.eclipse.swt.internal.gtk;
-
-/*
- * (c) Copyright 2000, 2002 IBM Corp. All rights reserved.
- * The contents of this file are made available under the terms
- * of the GNU Lesser General Public License (LGPL) Version 2.1 that
- * accompanies this distribution (lgpl-v21.txt). The LGPL is also
- * available at http://www.gnu.org/licenses/lgpl.html. If the version
- * of the LGPL at http://www.gnu.org is different to the version of
- * the LGPL accompanying this distribution and there is any conflict
- * between the two license versions, the terms of the LGPL accompanying
- * this distribution shall govern.
- */
-
-public class GdkColor {
- public int pixel;
- public short red;
- public short green;
- public short blue;
- public static final int sizeof = 12;
-}
+package org.eclipse.swt.internal.gtk;
+
+/*
+ * (c) Copyright 2000, 2002 IBM Corp. All rights reserved.
+ * The contents of this file are made available under the terms
+ * of the GNU Lesser General Public License (LGPL) Version 2.1 that
+ * accompanies this distribution (lgpl-v21.txt). The LGPL is also
+ * available at http://www.gnu.org/licenses/lgpl.html. If the version
+ * of the LGPL at http://www.gnu.org is different to the version of
+ * the LGPL accompanying this distribution and there is any conflict
+ * between the two license versions, the terms of the LGPL accompanying
+ * this distribution shall govern.
+ */
+
+public class GdkColor {
+ public int pixel;
+ public short red;
+ public short green;
+ public short blue;
+ public static final int sizeof = 12;
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/GdkEventExpose.java b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/GdkEventExpose.java
index 1168dc3a7f..d730046d90 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/GdkEventExpose.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/GdkEventExpose.java
@@ -1,26 +1,26 @@
-package org.eclipse.swt.internal.gtk;
-
-/*
- * (c) Copyright 2000, 2002 IBM Corp. All rights reserved.
- * The contents of this file are made available under the terms
- * of the GNU Lesser General Public License (LGPL) Version 2.1 that
- * accompanies this distribution (lgpl-v21.txt). The LGPL is also
- * available at http://www.gnu.org/licenses/lgpl.html. If the version
- * of the LGPL at http://www.gnu.org is different to the version of
- * the LGPL accompanying this distribution and there is any conflict
- * between the two license versions, the terms of the LGPL accompanying
- * this distribution shall govern.
- */
-
-public class GdkEventExpose extends GdkEvent {
- public int window;
- public byte send_event;
- public int area_x;
- public int area_y;
- public int area_width;
- public int area_height;
- public int region;
- public int count;
- public static final int sizeof = 36;
-}
-
+package org.eclipse.swt.internal.gtk;
+
+/*
+ * (c) Copyright 2000, 2002 IBM Corp. All rights reserved.
+ * The contents of this file are made available under the terms
+ * of the GNU Lesser General Public License (LGPL) Version 2.1 that
+ * accompanies this distribution (lgpl-v21.txt). The LGPL is also
+ * available at http://www.gnu.org/licenses/lgpl.html. If the version
+ * of the LGPL at http://www.gnu.org is different to the version of
+ * the LGPL accompanying this distribution and there is any conflict
+ * between the two license versions, the terms of the LGPL accompanying
+ * this distribution shall govern.
+ */
+
+public class GdkEventExpose extends GdkEvent {
+ public int window;
+ public byte send_event;
+ public int area_x;
+ public int area_y;
+ public int area_width;
+ public int area_height;
+ public int region;
+ public int count;
+ public static final int sizeof = 36;
+}
+
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/GdkGCValues.java b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/GdkGCValues.java
index 4a31ee7e55..d8dd299e2a 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/GdkGCValues.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/GdkGCValues.java
@@ -1,41 +1,41 @@
-package org.eclipse.swt.internal.gtk;
-
-/*
- * (c) Copyright 2000, 2002 IBM Corp. All rights reserved.
- * The contents of this file are made available under the terms
- * of the GNU Lesser General Public License (LGPL) Version 2.1 that
- * accompanies this distribution (lgpl-v21.txt). The LGPL is also
- * available at http://www.gnu.org/licenses/lgpl.html. If the version
- * of the LGPL at http://www.gnu.org is different to the version of
- * the LGPL accompanying this distribution and there is any conflict
- * between the two license versions, the terms of the LGPL accompanying
- * this distribution shall govern.
- */
-
-public class GdkGCValues {
- public int foreground_pixel;
- public short foreground_red;
- public short foreground_green;
- public short foreground_blue;
- public int background_pixel;
- public short background_red;
- public short background_green;
- public short background_blue;
- public int font;
- public int function;
- public int fill;
- public int tile;
- public int stipple;
- public int clip_mask;
- public int subwindow_mode;
- public int ts_x_origin;
- public int ts_y_origin;
- public int clip_x_origin;
- public int clip_y_origin;
- public int graphics_exposures;
- public int line_width;
- public int line_style;
- public int cap_style;
- public int join_style;
- public static final int sizeof = 88;
-}
+package org.eclipse.swt.internal.gtk;
+
+/*
+ * (c) Copyright 2000, 2002 IBM Corp. All rights reserved.
+ * The contents of this file are made available under the terms
+ * of the GNU Lesser General Public License (LGPL) Version 2.1 that
+ * accompanies this distribution (lgpl-v21.txt). The LGPL is also
+ * available at http://www.gnu.org/licenses/lgpl.html. If the version
+ * of the LGPL at http://www.gnu.org is different to the version of
+ * the LGPL accompanying this distribution and there is any conflict
+ * between the two license versions, the terms of the LGPL accompanying
+ * this distribution shall govern.
+ */
+
+public class GdkGCValues {
+ public int foreground_pixel;
+ public short foreground_red;
+ public short foreground_green;
+ public short foreground_blue;
+ public int background_pixel;
+ public short background_red;
+ public short background_green;
+ public short background_blue;
+ public int font;
+ public int function;
+ public int fill;
+ public int tile;
+ public int stipple;
+ public int clip_mask;
+ public int subwindow_mode;
+ public int ts_x_origin;
+ public int ts_y_origin;
+ public int clip_x_origin;
+ public int clip_y_origin;
+ public int graphics_exposures;
+ public int line_width;
+ public int line_style;
+ public int cap_style;
+ public int join_style;
+ public static final int sizeof = 88;
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/GdkImage.java b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/GdkImage.java
index 213bb3f390..bcb00e3711 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/GdkImage.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/GdkImage.java
@@ -1,28 +1,28 @@
-package org.eclipse.swt.internal.gtk;
-
-/*
- * (c) Copyright 2000, 2002 IBM Corp. All rights reserved.
- * The contents of this file are made available under the terms
- * of the GNU Lesser General Public License (LGPL) Version 2.1 that
- * accompanies this distribution (lgpl-v21.txt). The LGPL is also
- * available at http://www.gnu.org/licenses/lgpl.html. If the version
- * of the LGPL at http://www.gnu.org is different to the version of
- * the LGPL accompanying this distribution and there is any conflict
- * between the two license versions, the terms of the LGPL accompanying
- * this distribution shall govern.
- */
-
-public class GdkImage {
- public int type;
- public int visual;
- public int byte_order;
- public int width;
- public int height;
- public short depth;
- public short bpp;
- public short bpl;
- public short bits_per_pixel;
- public int mem;
- public int colormap;
- public int windowing_data;
-}
+package org.eclipse.swt.internal.gtk;
+
+/*
+ * (c) Copyright 2000, 2002 IBM Corp. All rights reserved.
+ * The contents of this file are made available under the terms
+ * of the GNU Lesser General Public License (LGPL) Version 2.1 that
+ * accompanies this distribution (lgpl-v21.txt). The LGPL is also
+ * available at http://www.gnu.org/licenses/lgpl.html. If the version
+ * of the LGPL at http://www.gnu.org is different to the version of
+ * the LGPL accompanying this distribution and there is any conflict
+ * between the two license versions, the terms of the LGPL accompanying
+ * this distribution shall govern.
+ */
+
+public class GdkImage {
+ public int type;
+ public int visual;
+ public int byte_order;
+ public int width;
+ public int height;
+ public short depth;
+ public short bpp;
+ public short bpl;
+ public short bits_per_pixel;
+ public int mem;
+ public int colormap;
+ public int windowing_data;
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/GdkRectangle.java b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/GdkRectangle.java
index 5f55e94d83..9bc530fe2e 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/GdkRectangle.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/GdkRectangle.java
@@ -1,21 +1,21 @@
-package org.eclipse.swt.internal.gtk;
-
-/*
- * (c) Copyright 2000, 2002 IBM Corp. All rights reserved.
- * The contents of this file are made available under the terms
- * of the GNU Lesser General Public License (LGPL) Version 2.1 that
- * accompanies this distribution (lgpl-v21.txt). The LGPL is also
- * available at http://www.gnu.org/licenses/lgpl.html. If the version
- * of the LGPL at http://www.gnu.org is different to the version of
- * the LGPL accompanying this distribution and there is any conflict
- * between the two license versions, the terms of the LGPL accompanying
- * this distribution shall govern.
- */
-
-public class GdkRectangle {
- public int x;
- public int y;
- public int width;
- public int height;
- public static final int sizeof = 16;
-}
+package org.eclipse.swt.internal.gtk;
+
+/*
+ * (c) Copyright 2000, 2002 IBM Corp. All rights reserved.
+ * The contents of this file are made available under the terms
+ * of the GNU Lesser General Public License (LGPL) Version 2.1 that
+ * accompanies this distribution (lgpl-v21.txt). The LGPL is also
+ * available at http://www.gnu.org/licenses/lgpl.html. If the version
+ * of the LGPL at http://www.gnu.org is different to the version of
+ * the LGPL accompanying this distribution and there is any conflict
+ * between the two license versions, the terms of the LGPL accompanying
+ * this distribution shall govern.
+ */
+
+public class GdkRectangle {
+ public int x;
+ public int y;
+ public int width;
+ public int height;
+ public static final int sizeof = 16;
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/GdkVisual.java b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/GdkVisual.java
index 10f8e02eaa..e97d33ac83 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/GdkVisual.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/GdkVisual.java
@@ -1,30 +1,30 @@
-package org.eclipse.swt.internal.gtk;
-
-/*
- * (c) Copyright 2000, 2002 IBM Corp. All rights reserved.
- * The contents of this file are made available under the terms
- * of the GNU Lesser General Public License (LGPL) Version 2.1 that
- * accompanies this distribution (lgpl-v21.txt). The LGPL is also
- * available at http://www.gnu.org/licenses/lgpl.html. If the version
- * of the LGPL at http://www.gnu.org is different to the version of
- * the LGPL accompanying this distribution and there is any conflict
- * between the two license versions, the terms of the LGPL accompanying
- * this distribution shall govern.
- */
-
-public class GdkVisual {
- public int type;
- public int depth;
- public int byte_order;
- public int colormap_size;
- public int bits_per_rgb;
- public int red_mask;
- public int red_shift;
- public int red_prec;
- public int green_mask;
- public int green_shift;
- public int green_prec;
- public int blue_mask;
- public int blue_shift;
- public int blue_prec;
-}
+package org.eclipse.swt.internal.gtk;
+
+/*
+ * (c) Copyright 2000, 2002 IBM Corp. All rights reserved.
+ * The contents of this file are made available under the terms
+ * of the GNU Lesser General Public License (LGPL) Version 2.1 that
+ * accompanies this distribution (lgpl-v21.txt). The LGPL is also
+ * available at http://www.gnu.org/licenses/lgpl.html. If the version
+ * of the LGPL at http://www.gnu.org is different to the version of
+ * the LGPL accompanying this distribution and there is any conflict
+ * between the two license versions, the terms of the LGPL accompanying
+ * this distribution shall govern.
+ */
+
+public class GdkVisual {
+ public int type;
+ public int depth;
+ public int byte_order;
+ public int colormap_size;
+ public int bits_per_rgb;
+ public int red_mask;
+ public int red_shift;
+ public int red_prec;
+ public int green_mask;
+ public int green_shift;
+ public int green_prec;
+ public int blue_mask;
+ public int blue_shift;
+ public int blue_prec;
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/GtkAdjustment.java b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/GtkAdjustment.java
index 699175c251..db109111e7 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/GtkAdjustment.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/GtkAdjustment.java
@@ -1,22 +1,22 @@
-package org.eclipse.swt.internal.gtk;
-
-/*
- * (c) Copyright 2000, 2002 IBM Corp. All rights reserved.
- * The contents of this file are made available under the terms
- * of the GNU Lesser General Public License (LGPL) Version 2.1 that
- * accompanies this distribution (lgpl-v21.txt). The LGPL is also
- * available at http://www.gnu.org/licenses/lgpl.html. If the version
- * of the LGPL at http://www.gnu.org is different to the version of
- * the LGPL accompanying this distribution and there is any conflict
- * between the two license versions, the terms of the LGPL accompanying
- * this distribution shall govern.
- */
-
-public class GtkAdjustment {
- public double lower;
- public double upper;
- public double value;
- public double step_increment;
- public double page_increment;
- public double page_size;
-}
+package org.eclipse.swt.internal.gtk;
+
+/*
+ * (c) Copyright 2000, 2002 IBM Corp. All rights reserved.
+ * The contents of this file are made available under the terms
+ * of the GNU Lesser General Public License (LGPL) Version 2.1 that
+ * accompanies this distribution (lgpl-v21.txt). The LGPL is also
+ * available at http://www.gnu.org/licenses/lgpl.html. If the version
+ * of the LGPL at http://www.gnu.org is different to the version of
+ * the LGPL accompanying this distribution and there is any conflict
+ * between the two license versions, the terms of the LGPL accompanying
+ * this distribution shall govern.
+ */
+
+public class GtkAdjustment {
+ public double lower;
+ public double upper;
+ public double value;
+ public double step_increment;
+ public double page_increment;
+ public double page_size;
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/GtkAllocation.java b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/GtkAllocation.java
index 0473706a2c..77629a7354 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/GtkAllocation.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/GtkAllocation.java
@@ -1,21 +1,21 @@
-package org.eclipse.swt.internal.gtk;
-
-/*
- * (c) Copyright 2000, 2002 IBM Corp. All rights reserved.
- * The contents of this file are made available under the terms
- * of the GNU Lesser General Public License (LGPL) Version 2.1 that
- * accompanies this distribution (lgpl-v21.txt). The LGPL is also
- * available at http://www.gnu.org/licenses/lgpl.html. If the version
- * of the LGPL at http://www.gnu.org is different to the version of
- * the LGPL accompanying this distribution and there is any conflict
- * between the two license versions, the terms of the LGPL accompanying
- * this distribution shall govern.
- */
-
-public class GtkAllocation {
- public int x;
- public int y;
- public int width;
- public int height;
- public static final int sizeof = 16;
-}
+package org.eclipse.swt.internal.gtk;
+
+/*
+ * (c) Copyright 2000, 2002 IBM Corp. All rights reserved.
+ * The contents of this file are made available under the terms
+ * of the GNU Lesser General Public License (LGPL) Version 2.1 that
+ * accompanies this distribution (lgpl-v21.txt). The LGPL is also
+ * available at http://www.gnu.org/licenses/lgpl.html. If the version
+ * of the LGPL at http://www.gnu.org is different to the version of
+ * the LGPL accompanying this distribution and there is any conflict
+ * between the two license versions, the terms of the LGPL accompanying
+ * this distribution shall govern.
+ */
+
+public class GtkAllocation {
+ public int x;
+ public int y;
+ public int width;
+ public int height;
+ public static final int sizeof = 16;
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/GtkRequisition.java b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/GtkRequisition.java
index e70014b02c..282281e1e9 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/GtkRequisition.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/GtkRequisition.java
@@ -1,19 +1,19 @@
-package org.eclipse.swt.internal.gtk;
-
-/*
- * (c) Copyright 2000, 2002 IBM Corp. All rights reserved.
- * The contents of this file are made available under the terms
- * of the GNU Lesser General Public License (LGPL) Version 2.1 that
- * accompanies this distribution (lgpl-v21.txt). The LGPL is also
- * available at http://www.gnu.org/licenses/lgpl.html. If the version
- * of the LGPL at http://www.gnu.org is different to the version of
- * the LGPL accompanying this distribution and there is any conflict
- * between the two license versions, the terms of the LGPL accompanying
- * this distribution shall govern.
- */
-
-public class GtkRequisition {
- public int width;
- public int height;
- public static final int sizeof = 8;
-}
+package org.eclipse.swt.internal.gtk;
+
+/*
+ * (c) Copyright 2000, 2002 IBM Corp. All rights reserved.
+ * The contents of this file are made available under the terms
+ * of the GNU Lesser General Public License (LGPL) Version 2.1 that
+ * accompanies this distribution (lgpl-v21.txt). The LGPL is also
+ * available at http://www.gnu.org/licenses/lgpl.html. If the version
+ * of the LGPL at http://www.gnu.org is different to the version of
+ * the LGPL accompanying this distribution and there is any conflict
+ * between the two license versions, the terms of the LGPL accompanying
+ * this distribution shall govern.
+ */
+
+public class GtkRequisition {
+ public int width;
+ public int height;
+ public static final int sizeof = 8;
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk1x/org/eclipse/swt/internal/gtk/GdkColor.java b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk1x/org/eclipse/swt/internal/gtk/GdkColor.java
index 4f788394c6..a8ca0e4a40 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk1x/org/eclipse/swt/internal/gtk/GdkColor.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk1x/org/eclipse/swt/internal/gtk/GdkColor.java
@@ -1,23 +1,23 @@
-package org.eclipse.swt.internal.gtk;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2001, 2002.
- * All rights reserved.
- *
- * The contents of this file are made available under the terms
- * of the GNU Lesser General Public License (LGPL) Version 2.1 that
- * accompanies this distribution (lgpl-v21.txt). The LGPL is also
- * available at http://www.gnu.org/licenses/lgpl.html. If the version
- * of the LGPL at http://www.gnu.org is different to the version of
- * the LGPL accompanying this distribution and there is any conflict
- * between the two license versions, the terms of the LGPL accompanying
- * this distribution shall govern.
- */
-
-public class GdkColor {
- public int pixel;
- public short red;
- public short green;
- public short blue;
- public static final int sizeof = 10;
-}
+package org.eclipse.swt.internal.gtk;
+
+/*
+ * (c) Copyright IBM Corp. 2000, 2001, 2002.
+ * All rights reserved.
+ *
+ * The contents of this file are made available under the terms
+ * of the GNU Lesser General Public License (LGPL) Version 2.1 that
+ * accompanies this distribution (lgpl-v21.txt). The LGPL is also
+ * available at http://www.gnu.org/licenses/lgpl.html. If the version
+ * of the LGPL at http://www.gnu.org is different to the version of
+ * the LGPL accompanying this distribution and there is any conflict
+ * between the two license versions, the terms of the LGPL accompanying
+ * this distribution shall govern.
+ */
+
+public class GdkColor {
+ public int pixel;
+ public short red;
+ public short green;
+ public short blue;
+ public static final int sizeof = 10;
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk1x/org/eclipse/swt/internal/gtk/GdkEvent.java b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk1x/org/eclipse/swt/internal/gtk/GdkEvent.java
index 22b2938d24..7453b45b44 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk1x/org/eclipse/swt/internal/gtk/GdkEvent.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk1x/org/eclipse/swt/internal/gtk/GdkEvent.java
@@ -1,22 +1,22 @@
-package org.eclipse.swt.internal.gtk;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2001, 2002.
- * All rights reserved.
- *
- * The contents of this file are made available under the terms
- * of the GNU Lesser General Public License (LGPL) Version 2.1 that
- * accompanies this distribution (lgpl-v21.txt). The LGPL is also
- * available at http://www.gnu.org/licenses/lgpl.html. If the version
- * of the LGPL at http://www.gnu.org is different to the version of
- * the LGPL accompanying this distribution and there is any conflict
- * between the two license versions, the terms of the LGPL accompanying
- * this distribution shall govern.
- */
-
-public class GdkEvent {
- public int type;
- public int window;
- public byte send_event;
- public static final int sizeof = 88;
-}
+package org.eclipse.swt.internal.gtk;
+
+/*
+ * (c) Copyright IBM Corp. 2000, 2001, 2002.
+ * All rights reserved.
+ *
+ * The contents of this file are made available under the terms
+ * of the GNU Lesser General Public License (LGPL) Version 2.1 that
+ * accompanies this distribution (lgpl-v21.txt). The LGPL is also
+ * available at http://www.gnu.org/licenses/lgpl.html. If the version
+ * of the LGPL at http://www.gnu.org is different to the version of
+ * the LGPL accompanying this distribution and there is any conflict
+ * between the two license versions, the terms of the LGPL accompanying
+ * this distribution shall govern.
+ */
+
+public class GdkEvent {
+ public int type;
+ public int window;
+ public byte send_event;
+ public static final int sizeof = 88;
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk1x/org/eclipse/swt/internal/gtk/GdkEventButton.java b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk1x/org/eclipse/swt/internal/gtk/GdkEventButton.java
index 4249e76a63..f83ff6c33c 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk1x/org/eclipse/swt/internal/gtk/GdkEventButton.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk1x/org/eclipse/swt/internal/gtk/GdkEventButton.java
@@ -1,30 +1,30 @@
-package org.eclipse.swt.internal.gtk;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2001, 2002.
- * All rights reserved.
- *
- * The contents of this file are made available under the terms
- * of the GNU Lesser General Public License (LGPL) Version 2.1 that
- * accompanies this distribution (lgpl-v21.txt). The LGPL is also
- * available at http://www.gnu.org/licenses/lgpl.html. If the version
- * of the LGPL at http://www.gnu.org is different to the version of
- * the LGPL accompanying this distribution and there is any conflict
- * between the two license versions, the terms of the LGPL accompanying
- * this distribution shall govern.
- */
-
-public class GdkEventButton extends GdkEvent {
- public int time;
- public long x;
- public long y;
- public long pressure;
- public long xtilt;
- public long ytilt;
- public int state;
- public int button;
- public int source;
- public int deviceid;
- public long x_root;
- public long y_root;
-}
+package org.eclipse.swt.internal.gtk;
+
+/*
+ * (c) Copyright IBM Corp. 2000, 2001, 2002.
+ * All rights reserved.
+ *
+ * The contents of this file are made available under the terms
+ * of the GNU Lesser General Public License (LGPL) Version 2.1 that
+ * accompanies this distribution (lgpl-v21.txt). The LGPL is also
+ * available at http://www.gnu.org/licenses/lgpl.html. If the version
+ * of the LGPL at http://www.gnu.org is different to the version of
+ * the LGPL accompanying this distribution and there is any conflict
+ * between the two license versions, the terms of the LGPL accompanying
+ * this distribution shall govern.
+ */
+
+public class GdkEventButton extends GdkEvent {
+ public int time;
+ public long x;
+ public long y;
+ public long pressure;
+ public long xtilt;
+ public long ytilt;
+ public int state;
+ public int button;
+ public int source;
+ public int deviceid;
+ public long x_root;
+ public long y_root;
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk1x/org/eclipse/swt/internal/gtk/GdkEventExpose.java b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk1x/org/eclipse/swt/internal/gtk/GdkEventExpose.java
index 441c439c97..e564dccf36 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk1x/org/eclipse/swt/internal/gtk/GdkEventExpose.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk1x/org/eclipse/swt/internal/gtk/GdkEventExpose.java
@@ -1,23 +1,23 @@
-package org.eclipse.swt.internal.gtk;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2001, 2002.
- * All rights reserved.
- *
- * The contents of this file are made available under the terms
- * of the GNU Lesser General Public License (LGPL) Version 2.1 that
- * accompanies this distribution (lgpl-v21.txt). The LGPL is also
- * available at http://www.gnu.org/licenses/lgpl.html. If the version
- * of the LGPL at http://www.gnu.org is different to the version of
- * the LGPL accompanying this distribution and there is any conflict
- * between the two license versions, the terms of the LGPL accompanying
- * this distribution shall govern.
- */
-
-public class GdkEventExpose extends GdkEvent {
- public short x;
- public short y;
- public short width;
- public short height;
- public int count;
-}
+package org.eclipse.swt.internal.gtk;
+
+/*
+ * (c) Copyright IBM Corp. 2000, 2001, 2002.
+ * All rights reserved.
+ *
+ * The contents of this file are made available under the terms
+ * of the GNU Lesser General Public License (LGPL) Version 2.1 that
+ * accompanies this distribution (lgpl-v21.txt). The LGPL is also
+ * available at http://www.gnu.org/licenses/lgpl.html. If the version
+ * of the LGPL at http://www.gnu.org is different to the version of
+ * the LGPL accompanying this distribution and there is any conflict
+ * between the two license versions, the terms of the LGPL accompanying
+ * this distribution shall govern.
+ */
+
+public class GdkEventExpose extends GdkEvent {
+ public short x;
+ public short y;
+ public short width;
+ public short height;
+ public int count;
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk1x/org/eclipse/swt/internal/gtk/GdkEventKey.java b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk1x/org/eclipse/swt/internal/gtk/GdkEventKey.java
index 1f2aa43fad..44603b67cf 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk1x/org/eclipse/swt/internal/gtk/GdkEventKey.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk1x/org/eclipse/swt/internal/gtk/GdkEventKey.java
@@ -1,23 +1,23 @@
-package org.eclipse.swt.internal.gtk;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2001, 2002.
- * All rights reserved.
- *
- * The contents of this file are made available under the terms
- * of the GNU Lesser General Public License (LGPL) Version 2.1 that
- * accompanies this distribution (lgpl-v21.txt). The LGPL is also
- * available at http://www.gnu.org/licenses/lgpl.html. If the version
- * of the LGPL at http://www.gnu.org is different to the version of
- * the LGPL accompanying this distribution and there is any conflict
- * between the two license versions, the terms of the LGPL accompanying
- * this distribution shall govern.
- */
-
-public class GdkEventKey extends GdkEvent {
- public int time;
- public int state;
- public int keyval;
- public int length;
- public int string;
-}
+package org.eclipse.swt.internal.gtk;
+
+/*
+ * (c) Copyright IBM Corp. 2000, 2001, 2002.
+ * All rights reserved.
+ *
+ * The contents of this file are made available under the terms
+ * of the GNU Lesser General Public License (LGPL) Version 2.1 that
+ * accompanies this distribution (lgpl-v21.txt). The LGPL is also
+ * available at http://www.gnu.org/licenses/lgpl.html. If the version
+ * of the LGPL at http://www.gnu.org is different to the version of
+ * the LGPL accompanying this distribution and there is any conflict
+ * between the two license versions, the terms of the LGPL accompanying
+ * this distribution shall govern.
+ */
+
+public class GdkEventKey extends GdkEvent {
+ public int time;
+ public int state;
+ public int keyval;
+ public int length;
+ public int string;
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk1x/org/eclipse/swt/internal/gtk/GdkEventMotion.java b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk1x/org/eclipse/swt/internal/gtk/GdkEventMotion.java
index 3b5b3d9c8b..9ec0e2bd5f 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk1x/org/eclipse/swt/internal/gtk/GdkEventMotion.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk1x/org/eclipse/swt/internal/gtk/GdkEventMotion.java
@@ -1,30 +1,30 @@
-package org.eclipse.swt.internal.gtk;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2001, 2002.
- * All rights reserved.
- *
- * The contents of this file are made available under the terms
- * of the GNU Lesser General Public License (LGPL) Version 2.1 that
- * accompanies this distribution (lgpl-v21.txt). The LGPL is also
- * available at http://www.gnu.org/licenses/lgpl.html. If the version
- * of the LGPL at http://www.gnu.org is different to the version of
- * the LGPL accompanying this distribution and there is any conflict
- * between the two license versions, the terms of the LGPL accompanying
- * this distribution shall govern.
- */
-
-public class GdkEventMotion extends GdkEvent {
- public int time;
- public long x;
- public long y;
- public long pressure;
- public long xtilt;
- public long ytilt;
- public int state;
- public int is_hint;
- public int source;
- public int deviceid;
- public long x_root;
- public long y_root;
-}
+package org.eclipse.swt.internal.gtk;
+
+/*
+ * (c) Copyright IBM Corp. 2000, 2001, 2002.
+ * All rights reserved.
+ *
+ * The contents of this file are made available under the terms
+ * of the GNU Lesser General Public License (LGPL) Version 2.1 that
+ * accompanies this distribution (lgpl-v21.txt). The LGPL is also
+ * available at http://www.gnu.org/licenses/lgpl.html. If the version
+ * of the LGPL at http://www.gnu.org is different to the version of
+ * the LGPL accompanying this distribution and there is any conflict
+ * between the two license versions, the terms of the LGPL accompanying
+ * this distribution shall govern.
+ */
+
+public class GdkEventMotion extends GdkEvent {
+ public int time;
+ public long x;
+ public long y;
+ public long pressure;
+ public long xtilt;
+ public long ytilt;
+ public int state;
+ public int is_hint;
+ public int source;
+ public int deviceid;
+ public long x_root;
+ public long y_root;
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk1x/org/eclipse/swt/internal/gtk/GdkFont.java b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk1x/org/eclipse/swt/internal/gtk/GdkFont.java
index a37adb5669..8549b0be6b 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk1x/org/eclipse/swt/internal/gtk/GdkFont.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk1x/org/eclipse/swt/internal/gtk/GdkFont.java
@@ -1,22 +1,22 @@
-package org.eclipse.swt.internal.gtk;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2001, 2002.
- * All rights reserved.
- *
- * The contents of this file are made available under the terms
- * of the GNU Lesser General Public License (LGPL) Version 2.1 that
- * accompanies this distribution (lgpl-v21.txt). The LGPL is also
- * available at http://www.gnu.org/licenses/lgpl.html. If the version
- * of the LGPL at http://www.gnu.org is different to the version of
- * the LGPL accompanying this distribution and there is any conflict
- * between the two license versions, the terms of the LGPL accompanying
- * this distribution shall govern.
- */
-
-public class GdkFont {
- public int type;
- public int ascent;
- public int descent;
- public static final int sizeof = 12;
-}
+package org.eclipse.swt.internal.gtk;
+
+/*
+ * (c) Copyright IBM Corp. 2000, 2001, 2002.
+ * All rights reserved.
+ *
+ * The contents of this file are made available under the terms
+ * of the GNU Lesser General Public License (LGPL) Version 2.1 that
+ * accompanies this distribution (lgpl-v21.txt). The LGPL is also
+ * available at http://www.gnu.org/licenses/lgpl.html. If the version
+ * of the LGPL at http://www.gnu.org is different to the version of
+ * the LGPL accompanying this distribution and there is any conflict
+ * between the two license versions, the terms of the LGPL accompanying
+ * this distribution shall govern.
+ */
+
+public class GdkFont {
+ public int type;
+ public int ascent;
+ public int descent;
+ public static final int sizeof = 12;
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk1x/org/eclipse/swt/internal/gtk/GdkGCValues.java b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk1x/org/eclipse/swt/internal/gtk/GdkGCValues.java
index e3ca371e8f..dc1dc6d99e 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk1x/org/eclipse/swt/internal/gtk/GdkGCValues.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk1x/org/eclipse/swt/internal/gtk/GdkGCValues.java
@@ -1,43 +1,43 @@
-package org.eclipse.swt.internal.gtk;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2001, 2002.
- * All rights reserved.
- *
- * The contents of this file are made available under the terms
- * of the GNU Lesser General Public License (LGPL) Version 2.1 that
- * accompanies this distribution (lgpl-v21.txt). The LGPL is also
- * available at http://www.gnu.org/licenses/lgpl.html. If the version
- * of the LGPL at http://www.gnu.org is different to the version of
- * the LGPL accompanying this distribution and there is any conflict
- * between the two license versions, the terms of the LGPL accompanying
- * this distribution shall govern.
- */
-
-public class GdkGCValues {
- public int foreground_pixel;
- public short foreground_red;
- public short foreground_green;
- public short foreground_blue;
- public int background_pixel;
- public short background_red;
- public short background_green;
- public short background_blue;
- public int font;
- public int function;
- public int fill;
- public int tile;
- public int stipple;
- public int clip_mask;
- public int subwindow_mode;
- public int ts_x_origin;
- public int ts_y_origin;
- public int clip_x_origin;
- public int clip_y_origin;
- public int graphics_exposures;
- public int line_width;
- public int line_style;
- public int cap_style;
- public int join_style;
- public static final int sizeof = 84;
-}
+package org.eclipse.swt.internal.gtk;
+
+/*
+ * (c) Copyright IBM Corp. 2000, 2001, 2002.
+ * All rights reserved.
+ *
+ * The contents of this file are made available under the terms
+ * of the GNU Lesser General Public License (LGPL) Version 2.1 that
+ * accompanies this distribution (lgpl-v21.txt). The LGPL is also
+ * available at http://www.gnu.org/licenses/lgpl.html. If the version
+ * of the LGPL at http://www.gnu.org is different to the version of
+ * the LGPL accompanying this distribution and there is any conflict
+ * between the two license versions, the terms of the LGPL accompanying
+ * this distribution shall govern.
+ */
+
+public class GdkGCValues {
+ public int foreground_pixel;
+ public short foreground_red;
+ public short foreground_green;
+ public short foreground_blue;
+ public int background_pixel;
+ public short background_red;
+ public short background_green;
+ public short background_blue;
+ public int font;
+ public int function;
+ public int fill;
+ public int tile;
+ public int stipple;
+ public int clip_mask;
+ public int subwindow_mode;
+ public int ts_x_origin;
+ public int ts_y_origin;
+ public int clip_x_origin;
+ public int clip_y_origin;
+ public int graphics_exposures;
+ public int line_width;
+ public int line_style;
+ public int cap_style;
+ public int join_style;
+ public static final int sizeof = 84;
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk1x/org/eclipse/swt/internal/gtk/GdkRectangle.java b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk1x/org/eclipse/swt/internal/gtk/GdkRectangle.java
index 6194af4fe2..352809b92d 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk1x/org/eclipse/swt/internal/gtk/GdkRectangle.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk1x/org/eclipse/swt/internal/gtk/GdkRectangle.java
@@ -1,23 +1,23 @@
-package org.eclipse.swt.internal.gtk;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2001, 2002.
- * All rights reserved.
- *
- * The contents of this file are made available under the terms
- * of the GNU Lesser General Public License (LGPL) Version 2.1 that
- * accompanies this distribution (lgpl-v21.txt). The LGPL is also
- * available at http://www.gnu.org/licenses/lgpl.html. If the version
- * of the LGPL at http://www.gnu.org is different to the version of
- * the LGPL accompanying this distribution and there is any conflict
- * between the two license versions, the terms of the LGPL accompanying
- * this distribution shall govern.
- */
-
-public class GdkRectangle {
- public short x;
- public short y;
- public short width;
- public short height;
- public static final int sizeof = 8;
-}
+package org.eclipse.swt.internal.gtk;
+
+/*
+ * (c) Copyright IBM Corp. 2000, 2001, 2002.
+ * All rights reserved.
+ *
+ * The contents of this file are made available under the terms
+ * of the GNU Lesser General Public License (LGPL) Version 2.1 that
+ * accompanies this distribution (lgpl-v21.txt). The LGPL is also
+ * available at http://www.gnu.org/licenses/lgpl.html. If the version
+ * of the LGPL at http://www.gnu.org is different to the version of
+ * the LGPL accompanying this distribution and there is any conflict
+ * between the two license versions, the terms of the LGPL accompanying
+ * this distribution shall govern.
+ */
+
+public class GdkRectangle {
+ public short x;
+ public short y;
+ public short width;
+ public short height;
+ public static final int sizeof = 8;
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk1x/org/eclipse/swt/internal/gtk/GdkVisual.java b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk1x/org/eclipse/swt/internal/gtk/GdkVisual.java
index b2c034d27a..1eab7fdfc7 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk1x/org/eclipse/swt/internal/gtk/GdkVisual.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk1x/org/eclipse/swt/internal/gtk/GdkVisual.java
@@ -1,33 +1,33 @@
-package org.eclipse.swt.internal.gtk;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2001, 2002.
- * All rights reserved.
- *
- * The contents of this file are made available under the terms
- * of the GNU Lesser General Public License (LGPL) Version 2.1 that
- * accompanies this distribution (lgpl-v21.txt). The LGPL is also
- * available at http://www.gnu.org/licenses/lgpl.html. If the version
- * of the LGPL at http://www.gnu.org is different to the version of
- * the LGPL accompanying this distribution and there is any conflict
- * between the two license versions, the terms of the LGPL accompanying
- * this distribution shall govern.
- */
-
-public class GdkVisual {
- public int type;
- public int depth;
- public int byte_order;
- public int colormap_size;
- public int bits_per_rgb;
- public int red_mask;
- public int red_shift;
- public int red_prec;
- public int green_mask;
- public int green_shift;
- public int green_prec;
- public int blue_mask;
- public int blue_shift;
- public int blue_prec;
- public static final int sizeof = 56;
-}
+package org.eclipse.swt.internal.gtk;
+
+/*
+ * (c) Copyright IBM Corp. 2000, 2001, 2002.
+ * All rights reserved.
+ *
+ * The contents of this file are made available under the terms
+ * of the GNU Lesser General Public License (LGPL) Version 2.1 that
+ * accompanies this distribution (lgpl-v21.txt). The LGPL is also
+ * available at http://www.gnu.org/licenses/lgpl.html. If the version
+ * of the LGPL at http://www.gnu.org is different to the version of
+ * the LGPL accompanying this distribution and there is any conflict
+ * between the two license versions, the terms of the LGPL accompanying
+ * this distribution shall govern.
+ */
+
+public class GdkVisual {
+ public int type;
+ public int depth;
+ public int byte_order;
+ public int colormap_size;
+ public int bits_per_rgb;
+ public int red_mask;
+ public int red_shift;
+ public int red_prec;
+ public int green_mask;
+ public int green_shift;
+ public int green_prec;
+ public int blue_mask;
+ public int blue_shift;
+ public int blue_prec;
+ public static final int sizeof = 56;
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk1x/org/eclipse/swt/internal/gtk/GtkAdjustment.java b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk1x/org/eclipse/swt/internal/gtk/GtkAdjustment.java
index e0d8e6eee2..5784a05360 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk1x/org/eclipse/swt/internal/gtk/GtkAdjustment.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk1x/org/eclipse/swt/internal/gtk/GtkAdjustment.java
@@ -1,25 +1,25 @@
-package org.eclipse.swt.internal.gtk;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2001, 2002.
- * All rights reserved.
- *
- * The contents of this file are made available under the terms
- * of the GNU Lesser General Public License (LGPL) Version 2.1 that
- * accompanies this distribution (lgpl-v21.txt). The LGPL is also
- * available at http://www.gnu.org/licenses/lgpl.html. If the version
- * of the LGPL at http://www.gnu.org is different to the version of
- * the LGPL accompanying this distribution and there is any conflict
- * between the two license versions, the terms of the LGPL accompanying
- * this distribution shall govern.
- */
-
-public class GtkAdjustment extends GtkObject {
- public float lower;
- public float upper;
- public float value;
- public float step_increment;
- public float page_increment;
- public float page_size;
- public static final int sizeof = 40;
-}
+package org.eclipse.swt.internal.gtk;
+
+/*
+ * (c) Copyright IBM Corp. 2000, 2001, 2002.
+ * All rights reserved.
+ *
+ * The contents of this file are made available under the terms
+ * of the GNU Lesser General Public License (LGPL) Version 2.1 that
+ * accompanies this distribution (lgpl-v21.txt). The LGPL is also
+ * available at http://www.gnu.org/licenses/lgpl.html. If the version
+ * of the LGPL at http://www.gnu.org is different to the version of
+ * the LGPL accompanying this distribution and there is any conflict
+ * between the two license versions, the terms of the LGPL accompanying
+ * this distribution shall govern.
+ */
+
+public class GtkAdjustment extends GtkObject {
+ public float lower;
+ public float upper;
+ public float value;
+ public float step_increment;
+ public float page_increment;
+ public float page_size;
+ public static final int sizeof = 40;
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk1x/org/eclipse/swt/internal/gtk/GtkAllocation.java b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk1x/org/eclipse/swt/internal/gtk/GtkAllocation.java
index ee8a0eede9..4db3f3d659 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk1x/org/eclipse/swt/internal/gtk/GtkAllocation.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk1x/org/eclipse/swt/internal/gtk/GtkAllocation.java
@@ -1,23 +1,23 @@
-package org.eclipse.swt.internal.gtk;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2001, 2002.
- * All rights reserved.
- *
- * The contents of this file are made available under the terms
- * of the GNU Lesser General Public License (LGPL) Version 2.1 that
- * accompanies this distribution (lgpl-v21.txt). The LGPL is also
- * available at http://www.gnu.org/licenses/lgpl.html. If the version
- * of the LGPL at http://www.gnu.org is different to the version of
- * the LGPL accompanying this distribution and there is any conflict
- * between the two license versions, the terms of the LGPL accompanying
- * this distribution shall govern.
- */
-
-public class GtkAllocation {
- public short x;
- public short y;
- public short width;
- public short height;
- public static final int sizeof = 8;
-}
+package org.eclipse.swt.internal.gtk;
+
+/*
+ * (c) Copyright IBM Corp. 2000, 2001, 2002.
+ * All rights reserved.
+ *
+ * The contents of this file are made available under the terms
+ * of the GNU Lesser General Public License (LGPL) Version 2.1 that
+ * accompanies this distribution (lgpl-v21.txt). The LGPL is also
+ * available at http://www.gnu.org/licenses/lgpl.html. If the version
+ * of the LGPL at http://www.gnu.org is different to the version of
+ * the LGPL accompanying this distribution and there is any conflict
+ * between the two license versions, the terms of the LGPL accompanying
+ * this distribution shall govern.
+ */
+
+public class GtkAllocation {
+ public short x;
+ public short y;
+ public short width;
+ public short height;
+ public static final int sizeof = 8;
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk1x/org/eclipse/swt/internal/gtk/GtkBox.java b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk1x/org/eclipse/swt/internal/gtk/GtkBox.java
index 8ebbe7d33f..35c9e2fb0f 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk1x/org/eclipse/swt/internal/gtk/GtkBox.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk1x/org/eclipse/swt/internal/gtk/GtkBox.java
@@ -1,22 +1,22 @@
-package org.eclipse.swt.internal.gtk;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2001, 2002.
- * All rights reserved.
- *
- * The contents of this file are made available under the terms
- * of the GNU Lesser General Public License (LGPL) Version 2.1 that
- * accompanies this distribution (lgpl-v21.txt). The LGPL is also
- * available at http://www.gnu.org/licenses/lgpl.html. If the version
- * of the LGPL at http://www.gnu.org is different to the version of
- * the LGPL accompanying this distribution and there is any conflict
- * between the two license versions, the terms of the LGPL accompanying
- * this distribution shall govern.
- */
-
-public class GtkBox extends GtkContainer {
- public int children;
- public short spacing;
- public int homogeneous;
- public static final int sizeof = 68;
-}
+package org.eclipse.swt.internal.gtk;
+
+/*
+ * (c) Copyright IBM Corp. 2000, 2001, 2002.
+ * All rights reserved.
+ *
+ * The contents of this file are made available under the terms
+ * of the GNU Lesser General Public License (LGPL) Version 2.1 that
+ * accompanies this distribution (lgpl-v21.txt). The LGPL is also
+ * available at http://www.gnu.org/licenses/lgpl.html. If the version
+ * of the LGPL at http://www.gnu.org is different to the version of
+ * the LGPL accompanying this distribution and there is any conflict
+ * between the two license versions, the terms of the LGPL accompanying
+ * this distribution shall govern.
+ */
+
+public class GtkBox extends GtkContainer {
+ public int children;
+ public short spacing;
+ public int homogeneous;
+ public static final int sizeof = 68;
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk1x/org/eclipse/swt/internal/gtk/GtkCListColumn.java b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk1x/org/eclipse/swt/internal/gtk/GtkCListColumn.java
index 07a78a77c3..38ee1ff10e 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk1x/org/eclipse/swt/internal/gtk/GtkCListColumn.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk1x/org/eclipse/swt/internal/gtk/GtkCListColumn.java
@@ -1,35 +1,35 @@
-package org.eclipse.swt.internal.gtk;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2001, 2002.
- * All rights reserved.
- *
- * The contents of this file are made available under the terms
- * of the GNU Lesser General Public License (LGPL) Version 2.1 that
- * accompanies this distribution (lgpl-v21.txt). The LGPL is also
- * available at http://www.gnu.org/licenses/lgpl.html. If the version
- * of the LGPL at http://www.gnu.org is different to the version of
- * the LGPL accompanying this distribution and there is any conflict
- * between the two license versions, the terms of the LGPL accompanying
- * this distribution shall govern.
- */
-
-public class GtkCListColumn {
- public int title;
- public short area_x;
- public short area_y;
- public short area_width;
- public short area_height;
- public int button;
- public int window;
- public int width;
- public int min_width;
- public int max_width;
- public int justification;
- public int visible;
- public int width_set;
- public int resizeable;
- public int auto_resize;
- public int button_passive;
- public static final int sizeof = 40;
+package org.eclipse.swt.internal.gtk;
+
+/*
+ * (c) Copyright IBM Corp. 2000, 2001, 2002.
+ * All rights reserved.
+ *
+ * The contents of this file are made available under the terms
+ * of the GNU Lesser General Public License (LGPL) Version 2.1 that
+ * accompanies this distribution (lgpl-v21.txt). The LGPL is also
+ * available at http://www.gnu.org/licenses/lgpl.html. If the version
+ * of the LGPL at http://www.gnu.org is different to the version of
+ * the LGPL accompanying this distribution and there is any conflict
+ * between the two license versions, the terms of the LGPL accompanying
+ * this distribution shall govern.
+ */
+
+public class GtkCListColumn {
+ public int title;
+ public short area_x;
+ public short area_y;
+ public short area_width;
+ public short area_height;
+ public int button;
+ public int window;
+ public int width;
+ public int min_width;
+ public int max_width;
+ public int justification;
+ public int visible;
+ public int width_set;
+ public int resizeable;
+ public int auto_resize;
+ public int button_passive;
+ public static final int sizeof = 40;
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk1x/org/eclipse/swt/internal/gtk/GtkCListRow.java b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk1x/org/eclipse/swt/internal/gtk/GtkCListRow.java
index 08f15543a1..08331ef023 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk1x/org/eclipse/swt/internal/gtk/GtkCListRow.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk1x/org/eclipse/swt/internal/gtk/GtkCListRow.java
@@ -1,35 +1,35 @@
-package org.eclipse.swt.internal.gtk;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2001, 2002.
- * All rights reserved.
- *
- * The contents of this file are made available under the terms
- * of the GNU Lesser General Public License (LGPL) Version 2.1 that
- * accompanies this distribution (lgpl-v21.txt). The LGPL is also
- * available at http://www.gnu.org/licenses/lgpl.html. If the version
- * of the LGPL at http://www.gnu.org is different to the version of
- * the LGPL accompanying this distribution and there is any conflict
- * between the two license versions, the terms of the LGPL accompanying
- * this distribution shall govern.
- */
-
-public class GtkCListRow {
- public int cell;
- public int state;
- public short foreground_red;
- public short foreground_green;
- public short foreground_blue;
- public int foreground_pixel;
- public short background_red;
- public short background_green;
- public short background_blue;
- public int background_pixel;
- public int style;
- public int data;
- public int destroy; // bitfield: 1
- public int fg_set; // bitfield: 1
- public int bg_set; // bitfield: 1
- public int selectable; // bitfield: 1
- public static final int sizeof = 48;
-}
+package org.eclipse.swt.internal.gtk;
+
+/*
+ * (c) Copyright IBM Corp. 2000, 2001, 2002.
+ * All rights reserved.
+ *
+ * The contents of this file are made available under the terms
+ * of the GNU Lesser General Public License (LGPL) Version 2.1 that
+ * accompanies this distribution (lgpl-v21.txt). The LGPL is also
+ * available at http://www.gnu.org/licenses/lgpl.html. If the version
+ * of the LGPL at http://www.gnu.org is different to the version of
+ * the LGPL accompanying this distribution and there is any conflict
+ * between the two license versions, the terms of the LGPL accompanying
+ * this distribution shall govern.
+ */
+
+public class GtkCListRow {
+ public int cell;
+ public int state;
+ public short foreground_red;
+ public short foreground_green;
+ public short foreground_blue;
+ public int foreground_pixel;
+ public short background_red;
+ public short background_green;
+ public short background_blue;
+ public int background_pixel;
+ public int style;
+ public int data;
+ public int destroy; // bitfield: 1
+ public int fg_set; // bitfield: 1
+ public int bg_set; // bitfield: 1
+ public int selectable; // bitfield: 1
+ public static final int sizeof = 48;
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk1x/org/eclipse/swt/internal/gtk/GtkCTreeRow.java b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk1x/org/eclipse/swt/internal/gtk/GtkCTreeRow.java
index 5f94d9c451..c34f8db9a7 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk1x/org/eclipse/swt/internal/gtk/GtkCTreeRow.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk1x/org/eclipse/swt/internal/gtk/GtkCTreeRow.java
@@ -1,29 +1,29 @@
-package org.eclipse.swt.internal.gtk;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2001, 2002.
- * All rights reserved.
- *
- * The contents of this file are made available under the terms
- * of the GNU Lesser General Public License (LGPL) Version 2.1 that
- * accompanies this distribution (lgpl-v21.txt). The LGPL is also
- * available at http://www.gnu.org/licenses/lgpl.html. If the version
- * of the LGPL at http://www.gnu.org is different to the version of
- * the LGPL accompanying this distribution and there is any conflict
- * between the two license versions, the terms of the LGPL accompanying
- * this distribution shall govern.
- */
-
-public class GtkCTreeRow extends GtkCListRow {
- public int parent;
- public int sibling;
- public int children;
- public int pixmap_closed;
- public int mask_closed;
- public int pixmap_opened;
- public int mask_opened;
- public short level;
- public int is_leaf; // bitfield: 1
- public int expanded; // bitfield: 1
- public static final int sizeof = 80;
-}
+package org.eclipse.swt.internal.gtk;
+
+/*
+ * (c) Copyright IBM Corp. 2000, 2001, 2002.
+ * All rights reserved.
+ *
+ * The contents of this file are made available under the terms
+ * of the GNU Lesser General Public License (LGPL) Version 2.1 that
+ * accompanies this distribution (lgpl-v21.txt). The LGPL is also
+ * available at http://www.gnu.org/licenses/lgpl.html. If the version
+ * of the LGPL at http://www.gnu.org is different to the version of
+ * the LGPL accompanying this distribution and there is any conflict
+ * between the two license versions, the terms of the LGPL accompanying
+ * this distribution shall govern.
+ */
+
+public class GtkCTreeRow extends GtkCListRow {
+ public int parent;
+ public int sibling;
+ public int children;
+ public int pixmap_closed;
+ public int mask_closed;
+ public int pixmap_opened;
+ public int mask_opened;
+ public short level;
+ public int is_leaf; // bitfield: 1
+ public int expanded; // bitfield: 1
+ public static final int sizeof = 80;
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk1x/org/eclipse/swt/internal/gtk/GtkCheckMenuItem.java b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk1x/org/eclipse/swt/internal/gtk/GtkCheckMenuItem.java
index 66a17164ab..3933d7d0f7 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk1x/org/eclipse/swt/internal/gtk/GtkCheckMenuItem.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk1x/org/eclipse/swt/internal/gtk/GtkCheckMenuItem.java
@@ -1,21 +1,21 @@
-package org.eclipse.swt.internal.gtk;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2001, 2002.
- * All rights reserved.
- *
- * The contents of this file are made available under the terms
- * of the GNU Lesser General Public License (LGPL) Version 2.1 that
- * accompanies this distribution (lgpl-v21.txt). The LGPL is also
- * available at http://www.gnu.org/licenses/lgpl.html. If the version
- * of the LGPL at http://www.gnu.org is different to the version of
- * the LGPL accompanying this distribution and there is any conflict
- * between the two license versions, the terms of the LGPL accompanying
- * this distribution shall govern.
- */
-
-public class GtkCheckMenuItem extends GtkMenuItem {
- public int active;
- public int always_show_toggle;
- public static final int sizeof = 88;
-}
+package org.eclipse.swt.internal.gtk;
+
+/*
+ * (c) Copyright IBM Corp. 2000, 2001, 2002.
+ * All rights reserved.
+ *
+ * The contents of this file are made available under the terms
+ * of the GNU Lesser General Public License (LGPL) Version 2.1 that
+ * accompanies this distribution (lgpl-v21.txt). The LGPL is also
+ * available at http://www.gnu.org/licenses/lgpl.html. If the version
+ * of the LGPL at http://www.gnu.org is different to the version of
+ * the LGPL accompanying this distribution and there is any conflict
+ * between the two license versions, the terms of the LGPL accompanying
+ * this distribution shall govern.
+ */
+
+public class GtkCheckMenuItem extends GtkMenuItem {
+ public int active;
+ public int always_show_toggle;
+ public static final int sizeof = 88;
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk1x/org/eclipse/swt/internal/gtk/GtkColorSelectionDialog.java b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk1x/org/eclipse/swt/internal/gtk/GtkColorSelectionDialog.java
index 873266393f..d9d4f846b4 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk1x/org/eclipse/swt/internal/gtk/GtkColorSelectionDialog.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk1x/org/eclipse/swt/internal/gtk/GtkColorSelectionDialog.java
@@ -1,25 +1,25 @@
-package org.eclipse.swt.internal.gtk;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2001, 2002.
- * All rights reserved.
- *
- * The contents of this file are made available under the terms
- * of the GNU Lesser General Public License (LGPL) Version 2.1 that
- * accompanies this distribution (lgpl-v21.txt). The LGPL is also
- * available at http://www.gnu.org/licenses/lgpl.html. If the version
- * of the LGPL at http://www.gnu.org is different to the version of
- * the LGPL accompanying this distribution and there is any conflict
- * between the two license versions, the terms of the LGPL accompanying
- * this distribution shall govern.
- */
-
-public class GtkColorSelectionDialog extends GtkWindow {
- public int colorsel;
- public int main_vbox;
- public int ok_button;
- public int reset_button;
- public int cancel_button;
- public int help_button;
- public static final int sizeof = 120;
-}
+package org.eclipse.swt.internal.gtk;
+
+/*
+ * (c) Copyright IBM Corp. 2000, 2001, 2002.
+ * All rights reserved.
+ *
+ * The contents of this file are made available under the terms
+ * of the GNU Lesser General Public License (LGPL) Version 2.1 that
+ * accompanies this distribution (lgpl-v21.txt). The LGPL is also
+ * available at http://www.gnu.org/licenses/lgpl.html. If the version
+ * of the LGPL at http://www.gnu.org is different to the version of
+ * the LGPL accompanying this distribution and there is any conflict
+ * between the two license versions, the terms of the LGPL accompanying
+ * this distribution shall govern.
+ */
+
+public class GtkColorSelectionDialog extends GtkWindow {
+ public int colorsel;
+ public int main_vbox;
+ public int ok_button;
+ public int reset_button;
+ public int cancel_button;
+ public int help_button;
+ public static final int sizeof = 120;
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk1x/org/eclipse/swt/internal/gtk/GtkFileSelection.java b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk1x/org/eclipse/swt/internal/gtk/GtkFileSelection.java
index cb61207371..741e7c3213 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk1x/org/eclipse/swt/internal/gtk/GtkFileSelection.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk1x/org/eclipse/swt/internal/gtk/GtkFileSelection.java
@@ -1,39 +1,39 @@
-package org.eclipse.swt.internal.gtk;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2001, 2002.
- * All rights reserved.
- *
- * The contents of this file are made available under the terms
- * of the GNU Lesser General Public License (LGPL) Version 2.1 that
- * accompanies this distribution (lgpl-v21.txt). The LGPL is also
- * available at http://www.gnu.org/licenses/lgpl.html. If the version
- * of the LGPL at http://www.gnu.org is different to the version of
- * the LGPL accompanying this distribution and there is any conflict
- * between the two license versions, the terms of the LGPL accompanying
- * this distribution shall govern.
- */
-
-public class GtkFileSelection extends GtkWindow {
- public int dir_list;
- public int file_list;
- public int selection_entry;
- public int selection_text;
- public int main_vbox;
- public int ok_button;
- public int cancel_button;
- public int help_button;
- public int history_pulldown;
- public int history_menu;
- public int history_list;
- public int fileop_dialog;
- public int fileop_entry;
- public int fileop_file;
- public int cmpl_state;
- public int fileop_c_dir;
- public int fileop_del_file;
- public int fileop_ren_file;
- public int button_area;
- public int action_area;
- public static final int sizeof = 176;
-}
+package org.eclipse.swt.internal.gtk;
+
+/*
+ * (c) Copyright IBM Corp. 2000, 2001, 2002.
+ * All rights reserved.
+ *
+ * The contents of this file are made available under the terms
+ * of the GNU Lesser General Public License (LGPL) Version 2.1 that
+ * accompanies this distribution (lgpl-v21.txt). The LGPL is also
+ * available at http://www.gnu.org/licenses/lgpl.html. If the version
+ * of the LGPL at http://www.gnu.org is different to the version of
+ * the LGPL accompanying this distribution and there is any conflict
+ * between the two license versions, the terms of the LGPL accompanying
+ * this distribution shall govern.
+ */
+
+public class GtkFileSelection extends GtkWindow {
+ public int dir_list;
+ public int file_list;
+ public int selection_entry;
+ public int selection_text;
+ public int main_vbox;
+ public int ok_button;
+ public int cancel_button;
+ public int help_button;
+ public int history_pulldown;
+ public int history_menu;
+ public int history_list;
+ public int fileop_dialog;
+ public int fileop_entry;
+ public int fileop_file;
+ public int cmpl_state;
+ public int fileop_c_dir;
+ public int fileop_del_file;
+ public int fileop_ren_file;
+ public int button_area;
+ public int action_area;
+ public static final int sizeof = 176;
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk1x/org/eclipse/swt/internal/gtk/GtkFontSelectionDialog.java b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk1x/org/eclipse/swt/internal/gtk/GtkFontSelectionDialog.java
index f0f466b22d..3edc262967 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk1x/org/eclipse/swt/internal/gtk/GtkFontSelectionDialog.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk1x/org/eclipse/swt/internal/gtk/GtkFontSelectionDialog.java
@@ -1,27 +1,27 @@
-package org.eclipse.swt.internal.gtk;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2001, 2002.
- * All rights reserved.
- *
- * The contents of this file are made available under the terms
- * of the GNU Lesser General Public License (LGPL) Version 2.1 that
- * accompanies this distribution (lgpl-v21.txt). The LGPL is also
- * available at http://www.gnu.org/licenses/lgpl.html. If the version
- * of the LGPL at http://www.gnu.org is different to the version of
- * the LGPL accompanying this distribution and there is any conflict
- * between the two license versions, the terms of the LGPL accompanying
- * this distribution shall govern.
- */
-
-public class GtkFontSelectionDialog extends GtkWindow {
- public int fontsel;
- public int main_vbox;
- public int action_area;
- public int ok_button;
- public int apply_button;
- public int cancel_button;
- public int dialog_width;
- public int auto_resize;
- public static final int sizeof = 132;
-}
+package org.eclipse.swt.internal.gtk;
+
+/*
+ * (c) Copyright IBM Corp. 2000, 2001, 2002.
+ * All rights reserved.
+ *
+ * The contents of this file are made available under the terms
+ * of the GNU Lesser General Public License (LGPL) Version 2.1 that
+ * accompanies this distribution (lgpl-v21.txt). The LGPL is also
+ * available at http://www.gnu.org/licenses/lgpl.html. If the version
+ * of the LGPL at http://www.gnu.org is different to the version of
+ * the LGPL accompanying this distribution and there is any conflict
+ * between the two license versions, the terms of the LGPL accompanying
+ * this distribution shall govern.
+ */
+
+public class GtkFontSelectionDialog extends GtkWindow {
+ public int fontsel;
+ public int main_vbox;
+ public int action_area;
+ public int ok_button;
+ public int apply_button;
+ public int cancel_button;
+ public int dialog_width;
+ public int auto_resize;
+ public static final int sizeof = 132;
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk1x/org/eclipse/swt/internal/gtk/GtkHBox.java b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk1x/org/eclipse/swt/internal/gtk/GtkHBox.java
index 3cf5df9936..305ae60c92 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk1x/org/eclipse/swt/internal/gtk/GtkHBox.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk1x/org/eclipse/swt/internal/gtk/GtkHBox.java
@@ -1,19 +1,19 @@
-package org.eclipse.swt.internal.gtk;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2001, 2002.
- * All rights reserved.
- *
- * The contents of this file are made available under the terms
- * of the GNU Lesser General Public License (LGPL) Version 2.1 that
- * accompanies this distribution (lgpl-v21.txt). The LGPL is also
- * available at http://www.gnu.org/licenses/lgpl.html. If the version
- * of the LGPL at http://www.gnu.org is different to the version of
- * the LGPL accompanying this distribution and there is any conflict
- * between the two license versions, the terms of the LGPL accompanying
- * this distribution shall govern.
- */
-
-public class GtkHBox extends GtkBox {
- public static final int sizeof = 68;
-}
+package org.eclipse.swt.internal.gtk;
+
+/*
+ * (c) Copyright IBM Corp. 2000, 2001, 2002.
+ * All rights reserved.
+ *
+ * The contents of this file are made available under the terms
+ * of the GNU Lesser General Public License (LGPL) Version 2.1 that
+ * accompanies this distribution (lgpl-v21.txt). The LGPL is also
+ * available at http://www.gnu.org/licenses/lgpl.html. If the version
+ * of the LGPL at http://www.gnu.org is different to the version of
+ * the LGPL accompanying this distribution and there is any conflict
+ * between the two license versions, the terms of the LGPL accompanying
+ * this distribution shall govern.
+ */
+
+public class GtkHBox extends GtkBox {
+ public static final int sizeof = 68;
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk1x/org/eclipse/swt/internal/gtk/GtkItem.java b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk1x/org/eclipse/swt/internal/gtk/GtkItem.java
index 2db78c39a9..74cc0cf0f1 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk1x/org/eclipse/swt/internal/gtk/GtkItem.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk1x/org/eclipse/swt/internal/gtk/GtkItem.java
@@ -1,19 +1,19 @@
-package org.eclipse.swt.internal.gtk;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2001, 2002.
- * All rights reserved.
- *
- * The contents of this file are made available under the terms
- * of the GNU Lesser General Public License (LGPL) Version 2.1 that
- * accompanies this distribution (lgpl-v21.txt). The LGPL is also
- * available at http://www.gnu.org/licenses/lgpl.html. If the version
- * of the LGPL at http://www.gnu.org is different to the version of
- * the LGPL accompanying this distribution and there is any conflict
- * between the two license versions, the terms of the LGPL accompanying
- * this distribution shall govern.
- */
-
-public class GtkItem extends GtkBin {
- public static final int sizeof = 64;
-}
+package org.eclipse.swt.internal.gtk;
+
+/*
+ * (c) Copyright IBM Corp. 2000, 2001, 2002.
+ * All rights reserved.
+ *
+ * The contents of this file are made available under the terms
+ * of the GNU Lesser General Public License (LGPL) Version 2.1 that
+ * accompanies this distribution (lgpl-v21.txt). The LGPL is also
+ * available at http://www.gnu.org/licenses/lgpl.html. If the version
+ * of the LGPL at http://www.gnu.org is different to the version of
+ * the LGPL accompanying this distribution and there is any conflict
+ * between the two license versions, the terms of the LGPL accompanying
+ * this distribution shall govern.
+ */
+
+public class GtkItem extends GtkBin {
+ public static final int sizeof = 64;
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk1x/org/eclipse/swt/internal/gtk/GtkMenuItem.java b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk1x/org/eclipse/swt/internal/gtk/GtkMenuItem.java
index e0330248af..f0d85ed199 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk1x/org/eclipse/swt/internal/gtk/GtkMenuItem.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk1x/org/eclipse/swt/internal/gtk/GtkMenuItem.java
@@ -1,29 +1,29 @@
-package org.eclipse.swt.internal.gtk;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2001, 2002.
- * All rights reserved.
- *
- * The contents of this file are made available under the terms
- * of the GNU Lesser General Public License (LGPL) Version 2.1 that
- * accompanies this distribution (lgpl-v21.txt). The LGPL is also
- * available at http://www.gnu.org/licenses/lgpl.html. If the version
- * of the LGPL at http://www.gnu.org is different to the version of
- * the LGPL accompanying this distribution and there is any conflict
- * between the two license versions, the terms of the LGPL accompanying
- * this distribution shall govern.
- */
-
-public class GtkMenuItem extends GtkItem {
- public int submenu;
- public int accelerator_signal;
- public int toggle_size;
- public int accelerator_width;
- public int show_toggle_indicator;
- public int show_submenu_indicator;
- public int submenu_placement;
- public int submenu_direction;
- public int right_justify;
- public int timer;
- public static final int sizeof = 84;
-}
+package org.eclipse.swt.internal.gtk;
+
+/*
+ * (c) Copyright IBM Corp. 2000, 2001, 2002.
+ * All rights reserved.
+ *
+ * The contents of this file are made available under the terms
+ * of the GNU Lesser General Public License (LGPL) Version 2.1 that
+ * accompanies this distribution (lgpl-v21.txt). The LGPL is also
+ * available at http://www.gnu.org/licenses/lgpl.html. If the version
+ * of the LGPL at http://www.gnu.org is different to the version of
+ * the LGPL accompanying this distribution and there is any conflict
+ * between the two license versions, the terms of the LGPL accompanying
+ * this distribution shall govern.
+ */
+
+public class GtkMenuItem extends GtkItem {
+ public int submenu;
+ public int accelerator_signal;
+ public int toggle_size;
+ public int accelerator_width;
+ public int show_toggle_indicator;
+ public int show_submenu_indicator;
+ public int submenu_placement;
+ public int submenu_direction;
+ public int right_justify;
+ public int timer;
+ public static final int sizeof = 84;
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk1x/org/eclipse/swt/internal/gtk/GtkRequisition.java b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk1x/org/eclipse/swt/internal/gtk/GtkRequisition.java
index 20bc949d5a..3bf3d1ad8a 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk1x/org/eclipse/swt/internal/gtk/GtkRequisition.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk1x/org/eclipse/swt/internal/gtk/GtkRequisition.java
@@ -1,21 +1,21 @@
-package org.eclipse.swt.internal.gtk;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2001, 2002.
- * All rights reserved.
- *
- * The contents of this file are made available under the terms
- * of the GNU Lesser General Public License (LGPL) Version 2.1 that
- * accompanies this distribution (lgpl-v21.txt). The LGPL is also
- * available at http://www.gnu.org/licenses/lgpl.html. If the version
- * of the LGPL at http://www.gnu.org is different to the version of
- * the LGPL accompanying this distribution and there is any conflict
- * between the two license versions, the terms of the LGPL accompanying
- * this distribution shall govern.
- */
-
-public class GtkRequisition {
- public short width;
- public short height;
- public static final int sizeof = 4;
-}
+package org.eclipse.swt.internal.gtk;
+
+/*
+ * (c) Copyright IBM Corp. 2000, 2001, 2002.
+ * All rights reserved.
+ *
+ * The contents of this file are made available under the terms
+ * of the GNU Lesser General Public License (LGPL) Version 2.1 that
+ * accompanies this distribution (lgpl-v21.txt). The LGPL is also
+ * available at http://www.gnu.org/licenses/lgpl.html. If the version
+ * of the LGPL at http://www.gnu.org is different to the version of
+ * the LGPL accompanying this distribution and there is any conflict
+ * between the two license versions, the terms of the LGPL accompanying
+ * this distribution shall govern.
+ */
+
+public class GtkRequisition {
+ public short width;
+ public short height;
+ public static final int sizeof = 4;
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk1x/org/eclipse/swt/internal/gtk/GtkStyleClass.java b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk1x/org/eclipse/swt/internal/gtk/GtkStyleClass.java
index e58402977c..ee239b6d8b 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk1x/org/eclipse/swt/internal/gtk/GtkStyleClass.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk1x/org/eclipse/swt/internal/gtk/GtkStyleClass.java
@@ -1,21 +1,21 @@
-package org.eclipse.swt.internal.gtk;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2001, 2002.
- * All rights reserved.
- *
- * The contents of this file are made available under the terms
- * of the GNU Lesser General Public License (LGPL) Version 2.1 that
- * accompanies this distribution (lgpl-v21.txt). The LGPL is also
- * available at http://www.gnu.org/licenses/lgpl.html. If the version
- * of the LGPL at http://www.gnu.org is different to the version of
- * the LGPL accompanying this distribution and there is any conflict
- * between the two license versions, the terms of the LGPL accompanying
- * this distribution shall govern.
- */
-
-public class GtkStyleClass {
- public int xthickness;
- public int ythickness;
- public static final int sizeof = 8;
+package org.eclipse.swt.internal.gtk;
+
+/*
+ * (c) Copyright IBM Corp. 2000, 2001, 2002.
+ * All rights reserved.
+ *
+ * The contents of this file are made available under the terms
+ * of the GNU Lesser General Public License (LGPL) Version 2.1 that
+ * accompanies this distribution (lgpl-v21.txt). The LGPL is also
+ * available at http://www.gnu.org/licenses/lgpl.html. If the version
+ * of the LGPL at http://www.gnu.org is different to the version of
+ * the LGPL accompanying this distribution and there is any conflict
+ * between the two license versions, the terms of the LGPL accompanying
+ * this distribution shall govern.
+ */
+
+public class GtkStyleClass {
+ public int xthickness;
+ public int ythickness;
+ public static final int sizeof = 8;
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk1x/org/eclipse/swt/internal/gtk/GtkText.java b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk1x/org/eclipse/swt/internal/gtk/GtkText.java
index c274a7a353..51e9e7d793 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk1x/org/eclipse/swt/internal/gtk/GtkText.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk1x/org/eclipse/swt/internal/gtk/GtkText.java
@@ -1,26 +1,26 @@
-package org.eclipse.swt.internal.gtk;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2001, 2002.
- * All rights reserved.
- *
- * The contents of this file are made available under the terms
- * of the GNU Lesser General Public License (LGPL) Version 2.1 that
- * accompanies this distribution (lgpl-v21.txt). The LGPL is also
- * available at http://www.gnu.org/licenses/lgpl.html. If the version
- * of the LGPL at http://www.gnu.org is different to the version of
- * the LGPL accompanying this distribution and there is any conflict
- * between the two license versions, the terms of the LGPL accompanying
- * this distribution shall govern.
- */
-
-public class GtkText extends GtkEditable {
- public int first_line_start_index;
- public int first_onscreen_hor_pixel;
- public int first_onscreen_ver_pixel;
- public int default_tab_width;
- public int cursor_pos_x;
- public int cursor_pos_y;
- public int cursor_virtual_x;
- public static final int sizeof = 244;
+package org.eclipse.swt.internal.gtk;
+
+/*
+ * (c) Copyright IBM Corp. 2000, 2001, 2002.
+ * All rights reserved.
+ *
+ * The contents of this file are made available under the terms
+ * of the GNU Lesser General Public License (LGPL) Version 2.1 that
+ * accompanies this distribution (lgpl-v21.txt). The LGPL is also
+ * available at http://www.gnu.org/licenses/lgpl.html. If the version
+ * of the LGPL at http://www.gnu.org is different to the version of
+ * the LGPL accompanying this distribution and there is any conflict
+ * between the two license versions, the terms of the LGPL accompanying
+ * this distribution shall govern.
+ */
+
+public class GtkText extends GtkEditable {
+ public int first_line_start_index;
+ public int first_onscreen_hor_pixel;
+ public int first_onscreen_ver_pixel;
+ public int default_tab_width;
+ public int cursor_pos_x;
+ public int cursor_pos_y;
+ public int cursor_virtual_x;
+ public static final int sizeof = 244;
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/motif/org/eclipse/swt/internal/motif/GNOME.java b/bundles/org.eclipse.swt/Eclipse SWT PI/motif/org/eclipse/swt/internal/motif/GNOME.java
index e7d344b40d..66db34ae8b 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/motif/org/eclipse/swt/internal/motif/GNOME.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/motif/org/eclipse/swt/internal/motif/GNOME.java
@@ -1,20 +1,20 @@
-package org.eclipse.swt.internal.motif;
-
-/*
+package org.eclipse.swt.internal.motif;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-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);
-
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+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);
+
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/motif/org/eclipse/swt/internal/motif/KDE.java b/bundles/org.eclipse.swt/Eclipse SWT PI/motif/org/eclipse/swt/internal/motif/KDE.java
index e607ab213f..a878719eb9 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/motif/org/eclipse/swt/internal/motif/KDE.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/motif/org/eclipse/swt/internal/motif/KDE.java
@@ -1,60 +1,60 @@
-package org.eclipse.swt.internal.motif;
-
-/*
+package org.eclipse.swt.internal.motif;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-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 loader, int iconQString, int iconType, int canReturnNull);
-
-public static final native int KMimeType_mimeType(int mimeTypeName);
-public static final native int KMimeType_icon(int mimeType, int unused1, int unused2);
-public static final native int KMimeType_name(int mimeType);
-public static final native int KMimeType_patterns(int mimeType);
-public static final native int KMimeType_offers(int mimeTypeName);
-public static final native int KMimeType_allMimeTypes();
-
-public static final native int KMimeTypeList_begin(int mimeTypeList);
-public static final native int KMimeTypeList_delete(int mimeTypeList);
-public static final native int KMimeTypeList_end(int mimeTypeList);
-
-public static final native int KMimeTypeListIterator_delete(int iterator);
-public static final native int KMimeTypeListIterator_dereference(int iterator);
-public static final native int KMimeTypeListIterator_equals(int iterator, int iterator2);
-public static final native void KMimeTypeListIterator_increment(int iterator);
-
-public static final native int QStringList_begin(int qstringList);
-public static final native int QStringList_delete(int qstringList);
-public static final native int QStringList_end(int qstringList);
-
-public static final native int QStringListIterator_delete(int iterator);
-public static final native int QStringListIterator_dereference(int iterator);
-public static final native int QStringListIterator_equals(int iterator, int iterator2);
-public static final native void QStringListIterator_increment(int iterator);
-
-public static final native int KURL_new( int qURLString );
-public static final native void KURL_delete( int url );
-public static final native int KRun_runURL( int url, int mimeTypeName );
-
-public static final native int KServiceList_delete(int serviceList);
-
-public static final native int QCString_data(int qcString);
-public static final native int QCString_delete(int qcString);
-public static final native int QCString_new(byte[] string);
-
-public static final native int QString_delete(int qString);
-public static final native int QString_equals(int qString, int qString2);
-public static final native int QString_new(byte[] string);
-public static final native int QString_utf8(int qString);
-
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+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 loader, int iconQString, int iconType, int canReturnNull);
+
+public static final native int KMimeType_mimeType(int mimeTypeName);
+public static final native int KMimeType_icon(int mimeType, int unused1, int unused2);
+public static final native int KMimeType_name(int mimeType);
+public static final native int KMimeType_patterns(int mimeType);
+public static final native int KMimeType_offers(int mimeTypeName);
+public static final native int KMimeType_allMimeTypes();
+
+public static final native int KMimeTypeList_begin(int mimeTypeList);
+public static final native int KMimeTypeList_delete(int mimeTypeList);
+public static final native int KMimeTypeList_end(int mimeTypeList);
+
+public static final native int KMimeTypeListIterator_delete(int iterator);
+public static final native int KMimeTypeListIterator_dereference(int iterator);
+public static final native int KMimeTypeListIterator_equals(int iterator, int iterator2);
+public static final native void KMimeTypeListIterator_increment(int iterator);
+
+public static final native int QStringList_begin(int qstringList);
+public static final native int QStringList_delete(int qstringList);
+public static final native int QStringList_end(int qstringList);
+
+public static final native int QStringListIterator_delete(int iterator);
+public static final native int QStringListIterator_dereference(int iterator);
+public static final native int QStringListIterator_equals(int iterator, int iterator2);
+public static final native void QStringListIterator_increment(int iterator);
+
+public static final native int KURL_new( int qURLString );
+public static final native void KURL_delete( int url );
+public static final native int KRun_runURL( int url, int mimeTypeName );
+
+public static final native int KServiceList_delete(int serviceList);
+
+public static final native int QCString_data(int qcString);
+public static final native int QCString_delete(int qcString);
+public static final native int QCString_new(byte[] string);
+
+public static final native int QString_delete(int qString);
+public static final native int QString_equals(int qString, int qString2);
+public static final native int QString_new(byte[] string);
+public static final native int QString_utf8(int qString);
+
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/motif/org/eclipse/swt/internal/motif/OS.java b/bundles/org.eclipse.swt/Eclipse SWT PI/motif/org/eclipse/swt/internal/motif/OS.java
index 0ec4f216b0..14558d9681 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/motif/org/eclipse/swt/internal/motif/OS.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/motif/org/eclipse/swt/internal/motif/OS.java
@@ -1,1439 +1,1439 @@
-package org.eclipse.swt.internal.motif;
-
-import org.eclipse.swt.internal.*;
-
-/*
- * Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
- * This file is made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-public class OS {
-
- /* Load the SWT library. */
- static {
- Library.loadLibrary ("swt");
- }
-
- /* OS and locale Constants*/
- public static final boolean IsAIX, IsSunOS, IsLinux, IsHPUX;
- public static final boolean IsDBLocale;
- static {
-
- /* Initialize the OS flags and locale constants */
- String osName = System.getProperty ("os.name");
- boolean isAIX = false, isSunOS = false, isLinux = false, isHPUX = false;
- if (osName.equals ("Linux")) isLinux = true;
- if (osName.equals ("AIX")) isAIX = true;
- if (osName.equals ("Solaris")) isSunOS = true;
- if (osName.equals ("SunOS")) isSunOS = true;
- if (osName.equals ("HP-UX")) isHPUX = true;
- IsAIX = isAIX; IsSunOS = isSunOS; IsLinux = isLinux; IsHPUX = isHPUX;
- IsDBLocale = OS.MB_CUR_MAX () != 1;
- }
- public static final int CODESET = OS.IsLinux ? 14 : 49;
- public static final int LC_CTYPE = OS.IsAIX ? 1 : 0;
-
- static final int RESOURCE_LENGTH = 1024 * 3;
- static final int RESOURCE_START = OS.XtMalloc (RESOURCE_LENGTH);
- static int NextResourceStart = RESOURCE_START;
- static {
- OS.setResourceMem (RESOURCE_START, RESOURCE_START + RESOURCE_LENGTH);
- }
-
- /*
- * Added for XEventsQueued.
- */
-// public static final int QueuedAlready = 0;
- public static final int QueuedAfterReading = 1;
-// public static final int QueuedAfterFlush = 2
-
- /*
- * Added for XmNpopupEnabled.
- */
-// public static final int XmPOPUP_DISABLED = 0;
-// public static final int XmPOPUP_KEYBBOARD = 1;
-// public static final int XmPOPUP_AUTOMATIC = 2;
-// public static final int XmPOPUP_AUTOMATIC_RECURSIVE = 3;
-
- /*
- * Added for XmNnavigationType.
- */
-// public static final int XmSTICKY_TAB_GROUP = 0x2;
-// public static final int XmEXCLUSIVE_TAB_GROUP = 0x3;
-
- /*
- * Added for XtInsertEventHandler.
- */
-// public static final int XtListHead = 0x0;
- public static final int XtListTail = 0x1;
-
- /* BEGIN Visual classes */
- //public static final int StaticGray = 0;
- //public static final int GrayScale = 1;
- //public static final int StaticColor = 2;
- //public static final int PseudoColor = 3;
- //public static final int TrueColor = 4;
- //public static final int DirectColor = 5;
- /* END Visual clases */
-
- /* 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 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 XCompoundTextStyle = 1;
-// 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_BackSpace = 0xFF08;
- 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_ISO_Left_Tab = 0xFE20;
-// 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_Linefeed = 0xFF0A;
- 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_space = 0x20;
- public static final int XK_Tab = 0xFF09;
- public static final int XK_Up = 0xFF52;
- public static final int XK_VoidSymbol = 0xFFFFFF;
-// 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 XStringStyle = 0;
- 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 XmDEFAULT_SELECT_COLOR = -1;
-// 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 int XmDRAG_UNDER_NONE = 0;
- 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 int XmDROP_SITE_COMPOSITE = 1;
- 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 XmFOREGROUND_COLOR = 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_COLOR = -3;
- 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;
- public static final int XmPATH_MODE_FULL = 0x0;
-// public static final int XmPATH_MODE_RELATIVE = 0x1;
-
- /* byte */
- public static final int XmNancestorSensitive = malloc ("ancestorSensitive", 1);
- public static final int XmNanimationStyle = malloc ("animationStyle", 1);
- public static final int XmNalignment = malloc ("alignment", 1);
- public static final int XmNallowShellResize = malloc ("allowShellResize", 1);
- public static final int XmNarrowDirection = malloc ("arrowDirection", 1);
- public static final int XmNblendModel = malloc ("blendModel", 1);
- public static final int XmNbottomAttachment = malloc ("bottomAttachment", 1);
- public static final int XmNcomboBoxType = malloc ("comboBoxType", 1);
- public static final int XmNdialogStyle = malloc ("dialogStyle", 1);
- public static final int XmNcursorPositionVisible = malloc ("cursorPositionVisible", 1);
- public static final int XmNdeleteResponse = malloc ("deleteResponse", 1);
- public static final int XmNdragInitiatorProtocolStyle = malloc ("dragInitiatorProtocolStyle", 1);
- public static final int XmNdragReceiverProtocolStyle = malloc ("dragReceiverProtocolStyle", 1);
- public static final int XmNdragOperations = malloc ("dragOperations", 1);
- public static final int XmNdropSiteActivity = malloc ("dropSiteActivity", 1);
- public static final int XmNdropSiteOperations = malloc ("dropSiteOperations", 1);
- public static final int XmNdropSiteType = malloc ("dropSiteType", 1);
- public static final int XmNeditable = malloc ("editable", 1);
- public static final int XmNenableThinThickness = malloc ("enableThinThickness", 1);
- public static final int XmNfillOnSelect = malloc ("fillOnSelect", 1);
- public static final int XmNframeChildType = malloc ("frameChildType", 1);
- public static final int XmNiconic = malloc ("iconic", 1);
- public static final int XmNlabelType = malloc ("labelType", 1);
- public static final int XmNleftAttachment = malloc ("leftAttachment", 1);
- public static final int XmNlistSizePolicy = malloc ("listSizePolicy", 1);
- public static final int XmNindicatorOn = malloc ("indicatorOn", 1);
- public static final int XmNindicatorType = malloc ("indicatorType", 1);
- public static final int XmNnoResize = malloc ("noResize", 1);
- public static final int XmNorientation = malloc ("orientation", 1);
- public static final int XmNoverrideRedirect = malloc ("overrideRedirect", 1);
- public static final int XmNprocessingDirection = malloc ("processingDirection", 1);
- public static final int XmNrecomputeSize = malloc ("recomputeSize", 1);
- public static final int XmNpushButtonEnabled = malloc ("pushButtonEnabled", 1);
- public static final int XmNresizable = malloc ("resizable", 1);
- public static final int XmNresizePolicy = malloc ("resizePolicy", 1);
- public static final int XmNrightAttachment = malloc ("rightAttachment", 1);
- public static final int XmNscrollHorizontal = malloc ("scrollHorizontal", 1);
- public static final int XmNscrollVertical = malloc ("scrollVertical", 1);
- public static final int XmNselectColor = malloc ("selectColor", 1);
- public static final int XmNselectionPolicy = malloc ("selectionPolicy", 1);
- public static final int XmNsensitive = malloc ("sensitive", 1);
- public static final int XmNseparatorType = malloc ("separatorType", 1);
- public static final int XmNset = malloc ("set", 1);
- public static final int XmNshadowType = malloc ("shadowType", 1);
- public static final int XmNtraversalOn = malloc ("traversalOn", 1);
- public static final int XmNtopAttachment = malloc ("topAttachment", 1);
- public static final int XmNverifyBell = malloc ("verifyBell", 1);
- public static final int XmNwordWrap = malloc ("wordWrap", 1);
- public static final int XmNnavigationType = malloc ("navigationType", 1);
-
- /* short */
- public static final int XmNarrowSize = malloc ("arrowSize", 2);
- public static final int XmNarrowSpacing = malloc ("arrowSpacing", 2);
- public static final int XmNborderWidth = malloc ("borderWidth", 2);
- public static final int XmNchildHorizontalSpacing = malloc ("childHorizontalSpacing", 2);
- public static final int XmNheight = malloc ("height", 2);
- public static final int XmNhighlightThickness = malloc ("highlightThickness", 2);
- public static final int XmNlistMarginHeight = malloc ("listMarginHeight", 2);
- public static final int XmNlistMarginWidth = malloc ("listMarginWidth", 2);
- public static final int XmNlistSpacing = malloc ("listSpacing", 2);
- public static final int XmNmarginBottom = malloc ("marginBottom", 2);
- public static final int XmNmarginHeight = malloc ("marginHeight", 2);
- public static final int XmNmarginLeft = malloc ("marginLeft", 2);
- public static final int XmNmarginRight = malloc ("marginRight", 2);
- public static final int XmNmarginTop = malloc ("marginTop", 2);
- public static final int XmNmarginWidth = malloc ("marginWidth", 2);
- public static final int XmNpositionIndex = malloc ("positionIndex", 2);
- public static final int XmNrows = malloc ("rows", 2);
- public static final int XmNshadowThickness = malloc ("shadowThickness", 2);
- public static final int XmNshowAsDefault = malloc ("showAsDefault", 2);
- public static final int XmNwidth = malloc ("width", 2);
- public static final int XmNx = malloc ("x", 2);
- public static final int XmNy = malloc ("y", 2);
-
- /* int */
- public static final int XmNaccelerator = malloc ("accelerator", 4);
- public static final int XmNacceleratorText = malloc ("acceleratorText", 4);
- public static final int XmNactivateCallback = malloc ("activateCallback", 4);
- public static final int XmNarmCallback = malloc ("armCallback", 4);
- public static final int XmNbackground = malloc ("background", 4);
- public static final int XmNborderColor = malloc ("borderColor", 4);
- public static final int XmNbottomShadowColor = malloc ("bottomShadowColor", 4);
- public static final int XmNbrowseSelectionCallback = malloc ("browseSelectionCallback", 4);
- public static final int XmNcancelCallback = malloc ("cancelCallback", 4);
- public static final int XmNcancelLabelString = malloc ("cancelLabelString", 4);
- public static final int XmNcascadingCallback = malloc ("cascadingCallback", 4);
- public static final int XmNchildren = malloc ("children", 4);
- public static final int XmNclientData = malloc ("clientData", 4);
- public static final int XmNcolormap = malloc ("colormap", 4);
- public static final int XmNconvertProc = malloc ("convertProc", 4);
- public static final int XmNdecrementCallback = malloc ("decrementCallback", 4);
- public static final int XmNdefaultActionCallback = malloc ("defaultActionCallback", 4);
- public static final int XmNdefaultButtonShadowThickness = malloc ("defaultButtonShadowThickness", 4);
- public static final int XmNdialogTitle = malloc ("dialogTitle", 4);
- public static final int XmNdirectory = malloc ("directory", 4);
- public static final int XmNdirMask = malloc ("dirMask", 4);
- public static final int XmNdirSpec = malloc ("dirSpec", 4);
- public static final int XmNdragCallback = malloc ("dragCallback", 4);
- public static final int XmNdragDropFinishCallback = malloc ("dragDropFinishCallback", 4);
- public static final int XmNdragProc = malloc ("dragProc", 4);
- public static final int XmNdropFinishCallback = malloc ("dropFinishCallback", 4);
- public static final int XmNdropProc = malloc("dropProc", 4);
- public static final int XmNeditMode = malloc ("editMode", 4);
- public static final int XmNexportTargets = malloc ("exportTargets", 4);
- public static final int XmNexposeCallback = malloc ("exposeCallback", 4);
- public static final int XmNextendedSelectionCallback = malloc ("extendedSelectionCallback", 4);
- public static final int XmNfilterLabelString = malloc ("filterLabelString", 4);
- public static final int XmNfont = malloc ("font", 4);
- public static final int XmNfontList = malloc ("fontList", 4);
- public static final int XmNfontType = malloc ("fontType", 4);
- public static final int XmNforeground = malloc ("foreground", 4);
- public static final int XmNhelpCallback = malloc ("helpCallback", 4);
- public static final int XmNhelpLabelString = malloc ("helpLabelString", 4);
- public static final int XmNhighlightColor = malloc ("highlightColor", 4);
- public static final int XmNhorizontalScrollBar = malloc ("horizontalScrollBar", 4);
- public static final int XmNiconMask = malloc ("iconMask", 4);
- public static final int XmNiconPixmap = malloc ("iconPixmap", 4);
- public static final int XmNincrement = malloc ("increment", 4);
- public static final int XmNincrementCallback = malloc ("incrementCallback", 4);
- public static final int XmNitemCount = malloc ("itemCount", 4);
- public static final int XmNitems = malloc ("items", 4);
- public static final int XmNlabelInsensitivePixmap = malloc ("labelInsensitivePixmap", 4);
- public static final int XmNlabelPixmap = malloc ("labelPixmap", 4);
- public static final int XmNlabelString = malloc ("labelString", 4);
- public static final int XmNlist = malloc ("list", 4);
- public static final int XmNmapCallback = malloc ("mapCallback", 4);
- public static final int XmNmappedWhenManaged = malloc ("mappedWhenManaged", 4);
- public static final int XmNmaximum = malloc ("maximum", 4);
- public static final int XmNmenuBar = malloc ("menuBar", 4);
- public static final int XmNmessageString = malloc ("messageString", 4);
- public static final int XmNminimum = malloc ("minimum", 4);
- public static final int XmNmodifyVerifyCallback = malloc ("modifyVerifyCallback", 4);
- public static final int XmNmwmDecorations = malloc ("mwmDecorations", 4);
- public static final int XmNmwmInputMode = malloc ("mwmInputMode", 4);
- public static final int XmNnumChildren = malloc ("numChildren", 4);
- public static final int XmNnumDropTransfers = malloc ("numDropTransfers", 4);
- public static final int XmNnumExportTargets = malloc ("numExportTargets", 4);
- public static final int XmNnumImportTargets = malloc("numImportTargets", 4);
- public static final int XmNmnemonic = malloc ("mnemonic", 4);
- public static final int XmNimportTargets = malloc("importTargets", 4);
- public static final int XmNokCallback = malloc ("okCallback", 4);
- public static final int XmNokLabelString = malloc ("okLabelString", 4);
- public static final int XmNoperationCursorIcon = malloc ("operationCursorIcon", 4);
- public static final int XmNselectionCallback = malloc ("selectionCallback", 4);
- public static final int XmNsourceCursorIcon = malloc ("sourceCursorIcon", 4);
- public static final int XmNstateCursorIcon = malloc ("stateCursorIcon", 4);
- public static final int XmNsubstitute = malloc ("substitute", 4);
- public static final int XmNpageDecrementCallback = malloc ("pageDecrementCallback", 4);
- public static final int XmNpageIncrement = malloc ("pageIncrement", 4);
- public static final int XmNpageIncrementCallback = malloc ("pageIncrementCallback", 4);
- public static final int XmNpathMode = malloc ("pathMode", 4);
- public static final int XmNpattern = malloc ("pattern", 4);
-// public static final int XmNpopupEnabled = malloc ("popupEnabled", 4);
-// public static final int XmNpopupHandlerCallback = malloc ("popupHandlerCallback", 4);
- public static final int XmNrenderTable = malloc ("renderTable", 4);
- public static final int XmNscaleMultiple = malloc ("scaleMultiple", 4);
- public static final int XmNselectedItemCount = malloc ("selectedItemCount", 4);
- public static final int XmNselectedItems = malloc ("selectedItems", 4);
- public static final int XmNselectedPosition = malloc ("selectedPosition", 4);
- public static final int XmNselectionArrayCount = malloc ("selectionArrayCount", 4);
- public static final int XmNsliderSize = malloc ("sliderSize", 4);
- public static final int XmNsliderVisual = malloc ("sliderVisual", 4);
- public static final int XmNsubMenuId = malloc ("subMenuId", 4);
- public static final int XmNtabList = malloc ("tabList", 4);
- public static final int XmNtextField = malloc ("textField", 4);
- public static final int XmNtitle = malloc ("title", 4);
- public static final int XmNtitleString = malloc ("titleString", 4);
- public static final int XmNtoBottomCallback = malloc ("toBottomCallback", 4);
- public static final int XmNtoTopCallback = malloc ("toTopCallback", 4);
-// public static final int XmNtopCharacter = malloc ("topCharacter", 4);
- public static final int XmNtopItemPosition = malloc ("topItemPosition", 4);
- public static final int XmNtopShadowColor = malloc ("topShadowColor", 4);
- public static final int XmNtransferProc = malloc ("transferProc", 4);
- public static final int XmNtransferStatus = malloc ("transferStatus", 4);
- public static final int XmNtroughColor = malloc ("troughColor", 4);
- public static final int XmNunmapCallback = malloc ("unmapCallback", 4);
- public static final int XmNuserData = malloc ("userData", 4);
- public static final int XmNvalue = malloc ("value", 4);
- public static final int XmNvalueChangedCallback = malloc ("valueChangedCallback", 4);
- public static final int XmNverticalScrollBar = malloc ("verticalScrollBar", 4);
- public static final int XmNvisibleItemCount = malloc ("visibleItemCount", 4);
- public static final int XmNdropTransfers = malloc ("dropTransfers", 4);
- public static final int XmNshowArrows = malloc ("showArrows", 4);
- public static final int XmNspotLocation = malloc ("spotLocation", 4);
-// public static final int XNFocusWindow = malloc ("focusWindow", 4);
-// public static final int XNInputStyle = malloc ("inputStyle", 4);
-// public static final int XNClientWindow = malloc ("clientWindow", 4);
-// public static final int XNQueryInputStyle = malloc ("queryInputStyle", 4);
-
- 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 XmREVERSED_GROUND_COLORS = -2;
- public static final int XmSET = 0x1;
- 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 XmUNSET = 0x0;
- 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 synchronized native int XBlackPixel (int display, int screenNum);
- public static final synchronized native void XChangeActivePointerGrab (int display, int eventMask, int cursor, int time);
- public static final synchronized native int XDefaultGC (int display, int screen_number);
- public static final synchronized native void XNoOp (int display);
- public static final synchronized native int XRootWindowOfScreen (int screen);
- public static final synchronized native int XSendEvent (int display, int w, boolean propagate, int event_mask, XAnyEvent event);
- public static final synchronized native int XmCreateCascadeButton (int parent, byte [] name, int [] arglist, int argcount);
- public static final synchronized native int XmCreateDrawnButton (int parent, byte [] name, int [] arglist, int argcount);
- public static final synchronized native int XmCreateRowColumn (int parent, byte [] name, int [] arglist, int argcount);
- public static final synchronized native int XmCreateScrolledWindow (int parent, byte [] name, int [] arglist, int argcount);
- public static final synchronized native int XmGetFocusWidget (int widget);
- public static final synchronized native void XmListAddItemsUnselected (int list, int xmStringTable, int item_count, int position);
- public static final synchronized native void XmListDeleteItem (int list, int item);
- public static final synchronized native void XmListDeselectItem (int list, int xmString);
- public static final synchronized native void XmListSelectItem (int list, int xmString, boolean notify);
- public static final synchronized native int XmPushButtonWidgetClass ();
- public static final synchronized native int XmStringLineCount (int xmString);
- public static final synchronized native boolean XmTextRemove (int widget);
- public static final synchronized native int XtAppSetErrorHandler (int app_context, int handler);
- public static final synchronized native int XtAppSetWarningHandler (int app_context, int handler);
- public static final synchronized native void XtCallActionProc (int widget, byte [] action, XAnyEvent event, byte [] params, int num_params);
- public static final synchronized native void XtCloseDisplay (int display);
- public static final synchronized native int XtCreateWidget (byte [] name, int widgetClass, int parent, int [] argList, int argCount);
- public static final synchronized native void XtRemoveCallback (int widget, int callback_name, int callback, int client_data);
- public static final synchronized native void XtRemoveEventHandler (int widget, int event_mask, boolean nonmaskable, int proc, int client_data);
- public static final synchronized native int XtScreen (int widget);
- */
-public static final synchronized native int OverrideShellWidgetClass ();
-public static final synchronized native int ShellWidgetClass ();
-public static final synchronized native int TopLevelShellWidgetClass ();
-public static final synchronized native int TransientShellWidgetClass ();
-public static final synchronized native int XAllocColor (int display, int colormap, XColor color);
-public static final synchronized native void XBell (int display, int ms);
-public static final synchronized native int XBitmapBitOrder (int display);
-public static final synchronized native int XBlackPixel (int display, int screenNum);
-public static final synchronized native int XChangeActivePointerGrab(int display, int event_mask, int cursor, int time);
-public static final synchronized native int XChangeGC (int display, int gc, int valuemask, XGCValues values);
-public static final synchronized native void XChangeWindowAttributes (int display, int window, int mask, XSetWindowAttributes attributes);
-public static final synchronized native boolean XCheckMaskEvent (int display, int mask, XAnyEvent event);
-public static final synchronized native boolean XCheckWindowEvent (int display, int window, int mask, XAnyEvent event);
-public static final synchronized native void XClearArea (int display, int window, int x, int y, int width, int height, boolean exposures);
-public static final synchronized native void XClipBox (int region, XRectangle rectangle);
-public static final synchronized 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 synchronized 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 synchronized native int XCreateBitmapFromData (int display, int drawable, byte [] data, int width, int height);
-public static final synchronized native int XCreateFontCursor (int display, int shape);
-public static final synchronized native int XCreateGC (int display, int window, int mask, XGCValues values);
-public static final synchronized 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 synchronized native int XCreatePixmap (int display, int drawable, int width, int height, int depth);
-public static final synchronized native int XCreatePixmapCursor (int display, int source, int mask, XColor foreground_color, XColor background_color, int x, int y);
-public static final synchronized native int XCreateRegion ();
-public static final synchronized native int XDefaultColormap (int display, int screen_number);
-public static final synchronized native int XDefaultDepthOfScreen (int screen);
-public static final synchronized native int XDefaultRootWindow (int display);
-public static final synchronized native int XDefaultScreen (int display);
-public static final synchronized native int XDefaultScreenOfDisplay (int display);
-public static final synchronized native int XDefaultVisual (int display, int screen_number);
-public static final synchronized native void XDefineCursor (int display, int window, int cursor);
-public static final synchronized native int XDestroyImage(int ximage);
-public static final synchronized native void XDestroyRegion (int region);
-public static final synchronized native int XDisplayHeight (int display, int screen);
-public static final synchronized native int XDisplayHeightMM (int display, int screen);
-public static final synchronized native int XDisplayWidth (int display, int screen);
-public static final synchronized native int XDisplayWidthMM (int display, int screen);
-public static final synchronized native void XDrawArc (int display, int drawable, int gc, int x1, int y1, int x2, int y2, int a1, int a2);
-public static final synchronized native void XDrawLine (int display, int drawable, int gc, int x1, int y1, int x2, int y2);
-public static final synchronized native void XDrawLines (int display, int drawable, int gc, short[] xPoints, int nPoints, int mode);
-public static final synchronized native void XDrawRectangle (int display, int drawable, int gc, int x, int y, int width, int height);
-public static final synchronized native boolean XEmptyRegion (int region);
-public static final synchronized native boolean XEqualRegion (int region1, int region2);
-public static final synchronized native void XFillArc (int display, int drawable, int gc, int x1, int y1, int x2, int y2, int a1, int a2);
-public static final synchronized native int XFillPolygon (int display, int drawable, int gc, short[] xPoints, int nPoints, int mode, int style);
-public static final synchronized native void XFillRectangle (int display, int drawable, int gc, int x, int y, int width, int height);
-public static final synchronized native boolean XFilterEvent (XAnyEvent event, int window);
-public static final synchronized native void XFlush (int display);
-public static final synchronized native int XFontsOfFontSet (int fontSet, int[] fontStructs, int[] fontNames);
-public static final synchronized native int XFree (int address);
-public static final synchronized native int XFreeColors (int display, int colormap, int [] pixels, int npixels, int planes);
-public static final synchronized native void XFreeCursor (int display, int pixmap);
-public static final synchronized native void XFreeFontNames(int list);
-public static final synchronized native void XFreeFont(int display, int font_struct);
-public static final synchronized native void XFreeFontSet(int display, int font_set);
-public static final synchronized native void XFreeGC (int display, int gc);
-public static final synchronized native void XFreePixmap (int display, int pixmap);
-public static final synchronized native int XGetGCValues (int display, int gc, int valuemask, XGCValues values);
-public static final synchronized 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 synchronized native int XGetImage (int display, int drawable, int x, int y, int width, int height, int plane_mask, int format);
-public static final synchronized native int XGetInputFocus (int display, int [] window, int [] revert);
-public static final synchronized native boolean XGetWindowAttributes (int display, int window, XWindowAttributes attributes);
-public static final synchronized native int XGrabKeyboard (
- int display,
- int grabWindow,
- int ownerEvents,
- int pointerMode,
- int keyboardMode,
- int time);
-public static final synchronized native int XGrabPointer (
- int display,
- int grabWindow,
- int ownerEvents,
- int eventMask,
- int pointerMode,
- int keyboardMode,
- int confineToWindow,
- int cursor,
- int time);
-public static final synchronized native int XInitThreads ();
-public static final synchronized native int XInternAtom( int display, byte [] name, boolean ifExists );
-public static final synchronized native int XKeysymToString (int keysym);
-public static final synchronized native int XListFonts(int display, byte[] pattern, int maxnames, int[] actual_count_return);
-public static final synchronized native int XListProperties(int display, int window, int[] num_prop_return);
-public static final synchronized native int XLookupString (XKeyEvent event, byte [] string, int size, int [] keysym, int [] status);
-public static final synchronized native int XLowerWindow (int display, int window);
-public static final synchronized native boolean XPointInRegion (int region, int x, int y);
-public static final synchronized 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 synchronized native int XQueryColor (int display, int colormap, XColor color);
-public static final synchronized native int XQueryPointer (
- int display,
- int window,
- int [] root,
- int [] child,
- int [] rootX,
- int [] rootY,
- int [] windowX,
- int [] windowY,
- int [] mask);
-public static final synchronized native int XQueryTree (int display, int window, int [] root_return, int [] parent_return, int [] children_return, int [] nChildren_return);
-public static final synchronized native int XRaiseWindow (int display, int window);
-public static final synchronized native int XReconfigureWMWindow (int display, int window, int screen, int valueMask, XWindowChanges values);
-public static final synchronized native int XRectInRegion (int region, int x, int y, int width, int height);
-public static final synchronized native void XSetBackground (int display, int gc, int background);
-public static final synchronized native void XSetClipMask (int display, int gc, int pixmap);
-public static final synchronized native void XSetClipRectangles (int display, int gc, int clip_x_origin, int clip_y_origin, XRectangle rectangles, int n, int ordering);
-public static final synchronized native int XSetDashes (int display, int gc, int dash_offset, byte[] dash_list, int n);
-public static final synchronized native int XSetErrorHandler (int handler);
-public static final synchronized native void XSetFillStyle (int display, int gc, int fill_style);
-public static final synchronized native int XSetFont (int display, int gc, int font);
-public static final synchronized native void XSetForeground (int display, int gc, int foreground);
-public static final synchronized native void XSetFunction (int display, int gc, int function);
-public static final synchronized native void XSetGraphicsExposures (int display, int gc, boolean graphics_exposures);
-public static final synchronized native int XSetInputFocus (int display, int window, int revert, int time);
-public static final synchronized native int XSetLineAttributes (int display, int gc, int lineWidth, int lineStyle, int capStyle, int joinStyle);
-public static final synchronized native void XSetRegion (int display, int gc, int region);
-public static final synchronized native void XSetStipple (int display, int gc, int pixmap);
-public static final synchronized native void XSetSubwindowMode (int display, int gc, int subwindow_mode);
-public static final synchronized native void XSetWindowBorderWidth (int display, int window, int width);
-public static final synchronized native void XSubtractRegion (int sra, int srb, int dr_return);
-public static final synchronized native void XSync (int display, boolean discard);
-public static final synchronized native int XSynchronize (int display, boolean onoff);
-public static final synchronized native void XUndefineCursor (int display, int window);
-public static final synchronized native int XUngrabKeyboard (int display, int time);
-public static final synchronized native int XUngrabPointer (int display, int time);
-public static final synchronized native void XUnionRectWithRegion (XRectangle rectangle, int src_region, int dest_region_return);
-public static final synchronized native void XUnionRegion (int sra, int srb, int dr_return);
-public static final synchronized native int XWarpPointer (int display, int sourceWindow, int destWindow, int sourceX, int sourceY, int sourceWidth, int sourceHeight, int destX, int destY);
-public static final synchronized native int XWhitePixel (int display, int screenNum);
-public static final synchronized native void XWithdrawWindow (int display, int window, int screen);
-public static final synchronized native void XmAddWMProtocolCallback (int shell, int protocol, int callback, int closure);
-public static final synchronized native void XmChangeColor (int widget, int pixel);
-public static final synchronized 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 synchronized native int XmClipboardEndCopy(int display, int window, int item_id);
-public static final synchronized native int XmClipboardStartCopy(int display, int window, int clip_label, int timestamp, int widget, int callback, int[] item_id);
-public static final synchronized native int XmClipboardInquireLength(int display, int widget, byte[] format_name, int[] length);
-public static final synchronized native int XmClipboardInquireFormat(int display, int window, int index, byte[] format_name_buf, int buffer_len, int[]copied_len);
-public static final synchronized native int XmClipboardInquireCount(int display, int window, int[] count, int[] max_format_name_length);
-public static final synchronized native int XmClipboardStartRetrieve(int display, int window, int timestamp);
-public static final synchronized native int XmClipboardRetrieve(int display, int window, byte[] format_name, byte[] buffer, int length, int[] num_bytes, int[] private_id);
-public static final synchronized native int XmClipboardEndRetrieve(int display, int window);
-public static final synchronized native void XmComboBoxAddItem(int widget, int xmString, int position, boolean unique);
-public static final synchronized native void XmComboBoxDeletePos(int widget, int position);
-public static final synchronized native void XmComboBoxSelectItem(int widget, int xmString);
-public static final synchronized native int XmCreateArrowButton (int parent, byte [] name, int [] arglist, int argcount);
-public static final synchronized native int XmCreateCascadeButtonGadget (int parent, byte [] name, int [] arglist, int argcount);
-public static final synchronized native int XmCreateComboBox(int parent, byte [] name, int [] arglist, int argcount);
-public static final synchronized native int XmCreateDialogShell (int parent, byte [] name, int [] arglist, int argcount);
-public static final synchronized native int XmCreateDrawingArea (int parent, byte [] name, int [] arglist, int argcount);
-//public static final synchronized native int XmCreateDrawnButton (int parent, byte [] name, int [] arglist, int argcount);
-public static final synchronized native int XmCreateErrorDialog (int parent, byte [] name, int [] arglist, int argcount);
-public static final synchronized native int XmCreateFileSelectionDialog (int parent, byte [] name, int [] arglist, int argcount);
-public static final synchronized native int XmCreateForm (int parent, byte [] name, int [] arglist, int argcount);
-public static final synchronized native int XmCreateFrame (int parent, byte [] name, int [] arglist, int argcount);
-public static final synchronized native int XmCreateInformationDialog (int parent, byte [] name, int [] arglist, int argcount);
-public static final synchronized native int XmCreateLabel (int parent, byte [] name, int [] arglist, int argcount);
-public static final synchronized native int XmCreateList (int parent, byte [] name, int [] arglist, int argcount);
-public static final synchronized native int XmCreateMainWindow (int parent, byte [] name, int [] arglist, int argcount);
-public static final synchronized native int XmCreateMenuBar (int parent, byte [] name, int [] arglist, int argcount);
-public static final synchronized native int XmCreateMessageDialog (int parent, byte [] name, int [] arglist, int argcount);
-public static final synchronized native int XmCreatePopupMenu (int parent, byte [] name, int [] arglist, int argcount);
-public static final synchronized native int XmCreatePulldownMenu (int parent, byte [] name, int [] arglist, int argcount);
-public static final synchronized native int XmCreatePushButton (int parent, byte [] name, int [] arglist, int argcount);
-public static final synchronized native int XmCreatePushButtonGadget (int parent, byte [] name, int [] arglist, int argcount);
-public static final synchronized native int XmCreateQuestionDialog (int parent, byte [] name, int [] arglist, int argcount);
-public static final synchronized native int XmCreateScale (int parent, byte [] name, int [] arglist, int argcount);
-public static final synchronized native int XmCreateScrollBar (int parent, byte [] name, int [] arglist, int argcount);
-public static final synchronized native int XmCreateScrolledList (int parent, byte [] name, int [] arglist, int argcount);
-public static final synchronized native int XmCreateScrolledText (int parent, byte [] name, int [] arglist, int argcount);
-public static final synchronized native int XmCreateSeparator (int parent, byte [] name, int [] arglist, int argcount);
-public static final synchronized native int XmCreateSeparatorGadget (int parent, byte [] name, int [] arglist, int argcount);
-//public static final synchronized native int XmCreateSimpleSpinBox (int parent, byte [] name, int [] arglist, int argcount);
-//public static final synchronized native int XmCreateSpinBox (int parent, byte [] name, int [] arglist, int argcount);
-public static final synchronized native int XmCreateTextField (int parent, byte [] name, int [] arglist, int argcount);
-public static final synchronized native int XmCreateToggleButton (int parent, byte [] name, int [] arglist, int argcount);
-public static final synchronized native int XmCreateToggleButtonGadget (int parent, byte [] name, int [] arglist, int argcount);
-public static final synchronized native int XmCreateWarningDialog (int parent, byte [] name, int [] arglist, int argcount);
-public static final synchronized native boolean XmDestroyPixmap (int screen, int pixmap);
-public static final synchronized native void XmDragCancel(int dragcontext);
-public static final synchronized native int XmDragStart(int widget, XAnyEvent event, int[] arglist, int argcount);
-public static final synchronized native void XmDropSiteRegister(int widget, int [] arglist, int argcount);
-public static final synchronized native void XmDropSiteUnregister(int widget);
-public static final synchronized native void XmDropSiteUpdate(int widget, int [] arglist, int argcount);
-public static final synchronized native void XmDropTransferAdd(int drop_transfer, int [] transfers, int num_transfers);
-public static final synchronized native int XmDropTransferStart(int widget, int [] arglist, int argcount);
-public static final synchronized native int XmFileSelectionBoxGetChild (int widget, int child);
-public static final synchronized native int XmFontListAppendEntry (int oldList, int entry);
-public static final synchronized native int XmFontListCopy (int fontlist);
-public static final synchronized native void XmFontListEntryFree (int[] entry);
-public static final synchronized native int XmFontListEntryGetFont (int entry, int[] type_return);
-public static final synchronized native int XmFontListEntryLoad (int display, byte [] fontName, int type, byte[] tag);
-public static final synchronized native void XmFontListFree (int list);
-public static final synchronized native void XmFontListFreeFontContext (int context);
-public static final synchronized native boolean XmFontListInitFontContext (int[] context,int fontList);
-public static final synchronized native int XmFontListNextEntry (int context);
-public static final synchronized native int XmGetAtomName (int display, int atom);
-public static final synchronized native int XmGetDragContext (int widget, int timestamp);
-public static final synchronized native int XmGetFocusWidget (int widget);
-public static final synchronized native int XmGetPixmap( int screen, byte [] name, int fgPixel, int bgPixel );
-public static final synchronized native int XmGetPixmapByDepth (int screen, byte [] image_name, int foreground, int background, int depth);
-public static final synchronized native int XmGetXmDisplay (int display);
-public static final synchronized native int XmImMbLookupString (int widget, XKeyEvent event, byte [] string, int size, int [] keysym, int [] status);
-public static final synchronized native int XmInternAtom (int display, byte [] name, boolean only_if_exists);
-public static final synchronized native void XmListAddItemUnselected (int list, int xmString, int position);
-public static final synchronized native void XmListDeleteAllItems (int list);
-public static final synchronized native void XmListDeleteItemsPos (int list, int item_count, int position);
-public static final synchronized native void XmListDeletePos (int list, int position);
-public static final synchronized native void XmListDeletePositions (int list, int [] position_list, int position_count);
-public static final synchronized native void XmListDeselectAllItems (int list);
-public static final synchronized native void XmListDeselectPos (int list, int position);
-public static final synchronized native int XmListGetKbdItemPos (int list);
-public static final synchronized native boolean XmListGetSelectedPos (int list, int [] positions, int [] count);
-public static final synchronized native int XmListItemPos (int list, int xmString);
-public static final synchronized native boolean XmListPosSelected (int list, int position);
-public static final synchronized native void XmListReplaceItemsPosUnselected (int list, int [] new_items, int item_count, int position);
-public static final synchronized native void XmListSelectPos (int list, int position, boolean notify);
-public static final synchronized native boolean XmListSetKbdItemPos (int list, int position);
-public static final synchronized native void XmListSetPos (int list, int position);
-public static final synchronized native void XmListUpdateSelectedList (int list);
-public static final synchronized native void XmMainWindowSetAreas (int widget, int menu, int command, int hscroll, int vscroll, int wregion);
-public static final synchronized native int XmMenuShellWidgetClass ();
-public static final synchronized native int XmMessageBoxGetChild (int widget, int child);
-public static final synchronized native int XmParseMappingCreate (int [] argList, int argCount);
-public static final synchronized native void XmParseMappingFree (int parseMapping);
-public static final synchronized native boolean XmProcessTraversal (int widget, int dir);
-public static final synchronized native int XmRenderTableAddRenditions(int oldTable, int[] renditions, int renditionCount, int mergeMode);
-public static final synchronized native void XmRenderTableFree(int renderTable);
-public static final synchronized native int XmRenditionCreate(int widget, byte[] tag, int[] argList, int argCount);
-public static final synchronized native void XmRenditionFree(int rendition);
-public static final synchronized native boolean XmStringCompare (int xmString1, int xmString2);
-public static final synchronized native int XmStringComponentCreate (int type, int length, byte[] value);
-public static final synchronized native int XmStringCreate (byte [] string, byte [] charset);
-public static final synchronized native int XmStringCreateLocalized (byte [] string);
-//public static final synchronized native int XmStringCreateLtoR (byte [] string, byte [] charset);
-public static final synchronized 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 synchronized 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 synchronized 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 synchronized native boolean XmStringEmpty (int s1);
-public static final synchronized native void XmStringFree (int xmString);
-//public static final synchronized native boolean XmStringGetLtoR (int xmString, byte [] charset, int [] text);
-public static final synchronized native int XmStringGenerate(byte[] text, byte[] tag, int type, byte[] rendition);
-public static final synchronized native int XmStringHeight (int fontList, int xmString);
-public static final synchronized native int XmStringParseText (byte[] text, int textEnd, byte [] tag, int tagType, int [] parseTable, int parseCount, int callData);
-public static final synchronized native int XmStringWidth (int fontList, int xmString);
-public static final synchronized native int XmStringUnparse (int xmString, byte [] tag, int tagType, int outputType, int [] parseTable, int parseCount, int parseModel);
-public static final synchronized native int XmTabCreate(int value, byte units, byte offsetModel, byte alignment, byte[] decimal);
-public static final synchronized native void XmTabFree(int tab);
-public static final synchronized native void XmTabListFree(int tabList);
-public static final synchronized native int XmTabListInsertTabs(int oldList, int[] tabs, int tab_count, int position);
-public static final synchronized native void XmTextClearSelection (int widget, int time);
-public static final synchronized native boolean XmTextCopy (int widget, int time);
-public static final synchronized native boolean XmTextCut (int widget, int time);
-public static final synchronized native void XmTextDisableRedisplay (int widget);
-public static final synchronized native void XmTextEnableRedisplay (int widget);
-public static final synchronized native int XmTextGetInsertionPosition (int widget);
-public static final synchronized native int XmTextGetLastPosition (int widget);
-public static final synchronized native int XmTextGetMaxLength (int widget);
-public static final synchronized native int XmTextGetSelection (int widget);
-public static final synchronized native boolean XmTextGetSelectionPosition (int widget, int [] left, int [] right);
-public static final synchronized native int XmTextGetString (int widget);
-public static final synchronized native int XmTextGetSubstring (int widget, int start, int num_chars, int buffer_size, byte [] buffer);
-public static final synchronized native int XmTextGetSubstringWcs (int widget, int start, int num_chars, int buffer_size, char [] buffer);
-public static final synchronized native void XmTextInsert (int widget, int position, byte [] value);
-public static final synchronized native boolean XmTextPaste (int widget);
-public static final synchronized native boolean XmTextPosToXY (int widget, int position, short [] x, short [] y);
-public static final synchronized native void XmTextReplace (int widget, int from_pos, int to_pos, byte [] value);
-public static final synchronized native void XmTextScroll (int widget, int lines);
-public static final synchronized native void XmTextSetEditable (int widget, boolean editable);
-public static final synchronized native void XmTextSetHighlight (int widget, int left, int right, int mode);
-public static final synchronized native void XmTextSetInsertionPosition (int widget, int position);
-public static final synchronized native void XmTextSetMaxLength (int widget, int max_length);
-public static final synchronized native void XmTextSetSelection (int widget, int first, int last, int time);
-public static final synchronized native void XmTextSetString (int widget, byte [] value);
-public static final synchronized native void XmTextShowPosition (int widget, int position);
-public static final synchronized native void XmUpdateDisplay (int widget);
-public static final synchronized native boolean XmWidgetGetDisplayRect (int region, XRectangle rectangle);
-//public static final synchronized native int XmbLookupString (int ic, XKeyEvent event, byte [] string, int size, int [] keysym, int [] status);
-public static final synchronized native int XmbTextListToTextProperty (int display, int list, int count, int style, XTextProperty text_prop_return);
-public static final synchronized native int XmbTextPropertyToTextList (int display, XTextProperty text_prop, int[] list_return, int[] count_return);
-
-public static final synchronized native void XtAddCallback (int widget, int callback_name, int callback, int client_data);
-public static final synchronized native void XtAddEventHandler (int widget, int event_mask, boolean nonmaskable, int proc, int client_data);
-public static final synchronized native void XtAddExposureToRegion (int event, int region);
-public static final synchronized native int XtAppAddTimeOut (int app_context, int interval, int proc, int client_data);
-public static final synchronized native int XtAppCreateShell (
- byte [] appName,
- byte [] appClass,
- int widgetClass,
- int display,
- int [] argList,
- int argCount);
-public static final synchronized native int XtAppGetSelectionTimeout (int appContext);
-public static final synchronized native void XtAppNextEvent (int appContext, XAnyEvent event);
-public static final synchronized native boolean XtAppPeekEvent (int appContext, XAnyEvent event);
-public static final synchronized native int XtAppPending (int appContext);
-public static final synchronized native void XtAppProcessEvent (int appContext, int inputMask);
-public static final synchronized native int XtAppSetErrorHandler (int app_context, int msg_handler);
-public static final synchronized native void XtAppSetSelectionTimeout (int appContext, int timeout);
-public static final synchronized native int XtAppSetWarningHandler (int app_context, int msg_handler);
-public static final synchronized native int XtBuildEventMask (int widget);
-public static final synchronized native void XtCallActionProc (int widget, byte [] action, XAnyEvent event, int [] params, int num_params);
-public static final synchronized native int XtClass (int widget);
-public static final synchronized native void XtConfigureWidget (int widget, int x, int y, int width, int height, int borderWidth);
-public static final synchronized native int XtCreateApplicationContext ();
-public static final synchronized native int XtCreatePopupShell (byte [] name, int widgetClass, int parent, int [] argList, int argCount);
-public static final synchronized native void XtDestroyApplicationContext (int appContext);
-public static final synchronized native void XtDestroyWidget (int widget);
-public static final synchronized native boolean XtDispatchEvent (XAnyEvent event);
-public static final synchronized native int XtDisplay (int widget);
-public static final synchronized native int XtDisplayToApplicationContext (int display);
-public static final synchronized native void XtFree (int ptr);
-public static final synchronized native int XtGetMultiClickTime (int display);
-public static final synchronized native void XtGetValues (int widget, int [] argList, int numArgs);
-public static final synchronized native boolean XtIsManaged (int widget);
-public static final synchronized native boolean XtIsRealized (int widget);
-public static final synchronized native boolean XtIsSubclass (int widget, int widgetClass);
-public static final synchronized native boolean XtIsTopLevelShell (int widget);
-public static final synchronized native boolean XtIsWidget (int widget);
-public static final synchronized native int XtLastTimestampProcessed (int display);
-public static final synchronized native int XtMalloc (int size);
-public static final synchronized native void XtManageChild (int widget);
-public static final synchronized native void XtMapWidget (int widget);
-public static final synchronized native void XtMoveWidget (int widget, int x, int y);
-public static final synchronized native int XtOpenDisplay (
- int xtAppContext,
- byte [] displayName,
- byte [] applicationName,
- byte [] applicationClass,
- int options,
- int numOptions,
- int [] argc,
- int argv);
-public static final synchronized native void XtOverrideTranslations (int w, int translations);
-public static final synchronized native int XtParent (int widget);
-public static final synchronized native int XtParseTranslationTable (byte [] string);
-public static final synchronized native void XtPopdown (int widget);
-public static final synchronized native void XtPopup (int widget, int flags);
-public static final synchronized native int XtQueryGeometry (int widget, XtWidgetGeometry intended, XtWidgetGeometry preferred_return);
-public static final synchronized native void XtRealizeWidget (int widget);
-public static final synchronized native void XtRemoveTimeOut (int id);
-public static final synchronized native void XtResizeWidget (int widget, int width, int height, int borderWidth);
-public static final synchronized native void XtResizeWindow (int widget);
-public static final synchronized native int XtSetLanguageProc (int appContext, int languageProc, int pointer);
-public static final synchronized native void XtSetMappedWhenManaged (int widget, boolean flag);
-public static final synchronized native void XtSetValues (int widget, int [] argList, int numArgs);
-public static final synchronized native void XtToolkitInitialize ();
-public static final synchronized native void XtTranslateCoords (int widget, short x, short y, short [] root_x, short [] root_y);
-public static final synchronized native void XtUnmanageChild (int widget);
-public static final synchronized native void XtUnmapWidget (int widget);
-public static final synchronized native int XtWindow (int widget);
-public static final synchronized native int XtWindowToWidget (int display, int widget);
-
-static int malloc (String name, int length) {
- int strLen = name.length ();
- if (NextResourceStart + strLen + 2 > RESOURCE_START + RESOURCE_LENGTH) {
- System.out.println ("*** Warning : SWT - Resource overrun. Increase OS.RESOURCE_LENGTH.");
- System.out.println ("*** Warning : Exiting ...");
- System.exit (0);
- }
- char [] unicode = new char [strLen];
- name.getChars (0, strLen, unicode, 0);
- byte[] buffer = new byte [strLen + 2];
- buffer [0] = (byte) length;
- for (int i = 0; i < strLen; i++) {
- buffer [i+1] = (byte) unicode[i];
- }
- OS.memmove (NextResourceStart, buffer, strLen + 2);
- int result = NextResourceStart + 1;
- NextResourceStart += strLen + 2;
- return result;
-}
-
-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, char [] 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 (int dest, XButtonEvent 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 (char [] 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 synchronized native int XmCreateDrawnButton (int parent, byte [] name, int [] arglist, int argcount);
-public static final synchronized native int XCheckIfEvent (int display, XAnyEvent event_return, int predicate, int arg);
-public static final synchronized native boolean XtToolkitThreadInitialize ();
-public static final synchronized native int Call (int proc, int arg1, int arg2);
-public static final synchronized native int XSetIOErrorHandler (int handler);
-public static final synchronized 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 synchronized native int XpCreateContext(int display, byte [] printer_name);
-public static final synchronized native int XpGetPrinterList(int display, byte [] printer_name, int [] list_count);
-public static final synchronized native void XpFreePrinterList(int printer_list);
-public static final synchronized native int XpGetAttributes(int display, int print_context, byte type);
-public static final synchronized native void XpSetAttributes(int display, int print_context, byte type, byte [] pool, byte replacement_rule);
-public static final synchronized native int XpGetOneAttribute(int display, int print_context, byte type, byte [] attribute_name);
-public static final synchronized native void XpSetContext(int display, int print_context);
-public static final synchronized native int XpGetScreenOfContext(int display, int print_context);
-public static final synchronized native void XpDestroyContext(int display, int print_context);
-public static final synchronized native int XpGetPageDimensions(int display, int print_context, short [] width, short [] height, XRectangle reproducible_area);
-public static final synchronized native void XpStartJob(int display, byte save_data);
-public static final synchronized native void XpStartPage(int display, int window);
-public static final synchronized native void XpEndPage(int display);
-public static final synchronized native void XpEndJob(int display);
-public static final synchronized native void XpCancelJob(int display, boolean discard);
-public static final synchronized native int XpQueryVersion(int display, short[] major_version, short[] minor_version);
-public static final synchronized native int XDefaultGCOfScreen(int screen);
-public static final synchronized native int XDefaultColormapOfScreen(int screen);
-public static final synchronized native int XRootWindowOfScreen(int screen);
-public static final synchronized native int XScreenNumberOfScreen(int screen);
-public static final synchronized 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 synchronized native void XDestroyWindow(int display, int w);
-public static final native int getenv(byte[] name);
-public static final synchronized native int XOpenDisplay(byte[] display_name);
-public static final synchronized native void XCloseDisplay(int display);
-
-/*
- * ======== End of printing constants and functions ========
- */
-
-public static final native int pipe (int [] filedes);
-public static final native int read (int filedes, byte [] buf, int nbyte);
-public static final native int write (int filedes, byte [] buf, int nbyte);
-public static final native int close (int filedes);
-public static final native int select (int n, byte [] readfds, byte [] writefds, byte [] exceptfds, int [] timeout);
-public static final native void FD_ZERO (byte [] fd_set);
-public static final native void FD_SET (int fd, byte [] fd_set);
-public static final native boolean FD_ISSET (int fd, byte [] fd_set);
-//public static final native int FD_SETSIZE ();
-//public static final native int NFDBITS ();
-public static final native int fd_set_sizeof ();
-public static final synchronized native int ConnectionNumber (int display);
-public static final synchronized native int XtAppAddInput (int app_context, int source, int condition, int proc, int client_data);
-public static final synchronized native void XtRemoveInput (int id);
-// public static final int XtInputNoneMask = 0;
- public static final int XtInputReadMask = 1;
-// public static final int XtInputWriteMask = 2;
-// public static final int XtInputExceptMask = 4;
-
-public static final synchronized native int XLoadQueryFont (int display, byte[] name);
-public static final synchronized native int XmFontListEntryCreate (byte[] tag, int type, int font);
-
-public static final synchronized native int XmImGetXIC (int widget, int input_policy, int[] args, int num_args);
-public static final synchronized native int XmImGetXIM (int widget);
-public static final synchronized native void XmImRegister (int widget, int reserved);
-public static final synchronized native int XmImSetFocusValues (int widget, int[] args, int num_args);
-//public static final synchronized native int XmImVaSetFocusValues(int widget, int arg1, int arg2, int arg3, int arg4, int arg5, int arg6, int arg7, int arg8, int arg9);
-public static final synchronized native int XmImSetValues (int widget, int[] args, int num_args);
-public static final synchronized native void XmImUnregister (int widget);
-public static final synchronized native void XmImUnsetFocus (int widget);
-//public static final synchronized native void XSetICFocus (int ic);
-//public static final synchronized native void XUnsetICFocus (int ic);
-//public static final synchronized native int XCreateIC (int im, int arg1, int arg2, int arg3, int arg4, int arg5, int arg6, int arg7);
-//public static final synchronized native int XSetICValues (int ic, int arg1, int arg2, int arg3);
-//public static final synchronized native int XGetICValues (int ic, int arg1, int arg2, int arg3);
-//public static final synchronized native int XGetIMValues (int im, int arg1, int arg2, int arg3);
-public static final native void memmove (int dest, short [] src, int count);
-//public static final native void memmove (char[] dest, int src, int count);
-//public static final native void memmove ( int dest, char[] src,int count);
-
-public static final native int nl_langinfo (int item);
-public static final native int iconv_open (byte[] tocode, byte[] fromcode);
-public static final native int iconv_close (int cd);
-public static final native int iconv (int cd, int[] inBuf, int[] inBytesLeft, int[] outBuf, int[] outBytesLeft);
-public static final native int MB_CUR_MAX ();
-public static final native int setlocale (int category, byte[] locale);
-static final native int setResourceMem (int start, int end);
-
-public static final synchronized native int XCreateFontSet (int display, byte [] base_font_name_list, int [] missing_charset_list_return, int [] missing_charset_count_return, int [] def_string_return);
-public static final synchronized native int XLocaleOfFontSet (int fontSet);
-public static final synchronized native void XFreeStringList (int list);
-
-public static final synchronized native void XtInsertEventHandler (int w, int event_mask, boolean nonmaskable, int proc, int client_data, int position);
-//public static final synchronized native void XmAddToPostFromList (int menu, int post_from_list);
-//public static final synchronized native void XmRemoveFromPostFromList (int menu, int post_from_list);
-//public static final synchronized native void XmMenuPosition (int menu, int event);
-public static final synchronized native void _XmSetMenuTraversal (int menu, boolean traversal);
-public static final synchronized native int XEventsQueued (int display, int mode);
-public static final native void memmove (int dest, XExposeEvent src, int count);
-public static final synchronized native void XtAppSetFallbackResources (int app_context, int specification_list);
-
-}
+package org.eclipse.swt.internal.motif;
+
+import org.eclipse.swt.internal.*;
+
+/*
+ * Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
+ * This file is made available under the terms of the Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+public class OS {
+
+ /* Load the SWT library. */
+ static {
+ Library.loadLibrary ("swt");
+ }
+
+ /* OS and locale Constants*/
+ public static final boolean IsAIX, IsSunOS, IsLinux, IsHPUX;
+ public static final boolean IsDBLocale;
+ static {
+
+ /* Initialize the OS flags and locale constants */
+ String osName = System.getProperty ("os.name");
+ boolean isAIX = false, isSunOS = false, isLinux = false, isHPUX = false;
+ if (osName.equals ("Linux")) isLinux = true;
+ if (osName.equals ("AIX")) isAIX = true;
+ if (osName.equals ("Solaris")) isSunOS = true;
+ if (osName.equals ("SunOS")) isSunOS = true;
+ if (osName.equals ("HP-UX")) isHPUX = true;
+ IsAIX = isAIX; IsSunOS = isSunOS; IsLinux = isLinux; IsHPUX = isHPUX;
+ IsDBLocale = OS.MB_CUR_MAX () != 1;
+ }
+ public static final int CODESET = OS.IsLinux ? 14 : 49;
+ public static final int LC_CTYPE = OS.IsAIX ? 1 : 0;
+
+ static final int RESOURCE_LENGTH = 1024 * 3;
+ static final int RESOURCE_START = OS.XtMalloc (RESOURCE_LENGTH);
+ static int NextResourceStart = RESOURCE_START;
+ static {
+ OS.setResourceMem (RESOURCE_START, RESOURCE_START + RESOURCE_LENGTH);
+ }
+
+ /*
+ * Added for XEventsQueued.
+ */
+// public static final int QueuedAlready = 0;
+ public static final int QueuedAfterReading = 1;
+// public static final int QueuedAfterFlush = 2
+
+ /*
+ * Added for XmNpopupEnabled.
+ */
+// public static final int XmPOPUP_DISABLED = 0;
+// public static final int XmPOPUP_KEYBBOARD = 1;
+// public static final int XmPOPUP_AUTOMATIC = 2;
+// public static final int XmPOPUP_AUTOMATIC_RECURSIVE = 3;
+
+ /*
+ * Added for XmNnavigationType.
+ */
+// public static final int XmSTICKY_TAB_GROUP = 0x2;
+// public static final int XmEXCLUSIVE_TAB_GROUP = 0x3;
+
+ /*
+ * Added for XtInsertEventHandler.
+ */
+// public static final int XtListHead = 0x0;
+ public static final int XtListTail = 0x1;
+
+ /* BEGIN Visual classes */
+ //public static final int StaticGray = 0;
+ //public static final int GrayScale = 1;
+ //public static final int StaticColor = 2;
+ //public static final int PseudoColor = 3;
+ //public static final int TrueColor = 4;
+ //public static final int DirectColor = 5;
+ /* END Visual clases */
+
+ /* 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 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 XCompoundTextStyle = 1;
+// 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_BackSpace = 0xFF08;
+ 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_ISO_Left_Tab = 0xFE20;
+// 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_Linefeed = 0xFF0A;
+ 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_space = 0x20;
+ public static final int XK_Tab = 0xFF09;
+ public static final int XK_Up = 0xFF52;
+ public static final int XK_VoidSymbol = 0xFFFFFF;
+// 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 XStringStyle = 0;
+ 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 XmDEFAULT_SELECT_COLOR = -1;
+// 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 int XmDRAG_UNDER_NONE = 0;
+ 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 int XmDROP_SITE_COMPOSITE = 1;
+ 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 XmFOREGROUND_COLOR = 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_COLOR = -3;
+ 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;
+ public static final int XmPATH_MODE_FULL = 0x0;
+// public static final int XmPATH_MODE_RELATIVE = 0x1;
+
+ /* byte */
+ public static final int XmNancestorSensitive = malloc ("ancestorSensitive", 1);
+ public static final int XmNanimationStyle = malloc ("animationStyle", 1);
+ public static final int XmNalignment = malloc ("alignment", 1);
+ public static final int XmNallowShellResize = malloc ("allowShellResize", 1);
+ public static final int XmNarrowDirection = malloc ("arrowDirection", 1);
+ public static final int XmNblendModel = malloc ("blendModel", 1);
+ public static final int XmNbottomAttachment = malloc ("bottomAttachment", 1);
+ public static final int XmNcomboBoxType = malloc ("comboBoxType", 1);
+ public static final int XmNdialogStyle = malloc ("dialogStyle", 1);
+ public static final int XmNcursorPositionVisible = malloc ("cursorPositionVisible", 1);
+ public static final int XmNdeleteResponse = malloc ("deleteResponse", 1);
+ public static final int XmNdragInitiatorProtocolStyle = malloc ("dragInitiatorProtocolStyle", 1);
+ public static final int XmNdragReceiverProtocolStyle = malloc ("dragReceiverProtocolStyle", 1);
+ public static final int XmNdragOperations = malloc ("dragOperations", 1);
+ public static final int XmNdropSiteActivity = malloc ("dropSiteActivity", 1);
+ public static final int XmNdropSiteOperations = malloc ("dropSiteOperations", 1);
+ public static final int XmNdropSiteType = malloc ("dropSiteType", 1);
+ public static final int XmNeditable = malloc ("editable", 1);
+ public static final int XmNenableThinThickness = malloc ("enableThinThickness", 1);
+ public static final int XmNfillOnSelect = malloc ("fillOnSelect", 1);
+ public static final int XmNframeChildType = malloc ("frameChildType", 1);
+ public static final int XmNiconic = malloc ("iconic", 1);
+ public static final int XmNlabelType = malloc ("labelType", 1);
+ public static final int XmNleftAttachment = malloc ("leftAttachment", 1);
+ public static final int XmNlistSizePolicy = malloc ("listSizePolicy", 1);
+ public static final int XmNindicatorOn = malloc ("indicatorOn", 1);
+ public static final int XmNindicatorType = malloc ("indicatorType", 1);
+ public static final int XmNnoResize = malloc ("noResize", 1);
+ public static final int XmNorientation = malloc ("orientation", 1);
+ public static final int XmNoverrideRedirect = malloc ("overrideRedirect", 1);
+ public static final int XmNprocessingDirection = malloc ("processingDirection", 1);
+ public static final int XmNrecomputeSize = malloc ("recomputeSize", 1);
+ public static final int XmNpushButtonEnabled = malloc ("pushButtonEnabled", 1);
+ public static final int XmNresizable = malloc ("resizable", 1);
+ public static final int XmNresizePolicy = malloc ("resizePolicy", 1);
+ public static final int XmNrightAttachment = malloc ("rightAttachment", 1);
+ public static final int XmNscrollHorizontal = malloc ("scrollHorizontal", 1);
+ public static final int XmNscrollVertical = malloc ("scrollVertical", 1);
+ public static final int XmNselectColor = malloc ("selectColor", 1);
+ public static final int XmNselectionPolicy = malloc ("selectionPolicy", 1);
+ public static final int XmNsensitive = malloc ("sensitive", 1);
+ public static final int XmNseparatorType = malloc ("separatorType", 1);
+ public static final int XmNset = malloc ("set", 1);
+ public static final int XmNshadowType = malloc ("shadowType", 1);
+ public static final int XmNtraversalOn = malloc ("traversalOn", 1);
+ public static final int XmNtopAttachment = malloc ("topAttachment", 1);
+ public static final int XmNverifyBell = malloc ("verifyBell", 1);
+ public static final int XmNwordWrap = malloc ("wordWrap", 1);
+ public static final int XmNnavigationType = malloc ("navigationType", 1);
+
+ /* short */
+ public static final int XmNarrowSize = malloc ("arrowSize", 2);
+ public static final int XmNarrowSpacing = malloc ("arrowSpacing", 2);
+ public static final int XmNborderWidth = malloc ("borderWidth", 2);
+ public static final int XmNchildHorizontalSpacing = malloc ("childHorizontalSpacing", 2);
+ public static final int XmNheight = malloc ("height", 2);
+ public static final int XmNhighlightThickness = malloc ("highlightThickness", 2);
+ public static final int XmNlistMarginHeight = malloc ("listMarginHeight", 2);
+ public static final int XmNlistMarginWidth = malloc ("listMarginWidth", 2);
+ public static final int XmNlistSpacing = malloc ("listSpacing", 2);
+ public static final int XmNmarginBottom = malloc ("marginBottom", 2);
+ public static final int XmNmarginHeight = malloc ("marginHeight", 2);
+ public static final int XmNmarginLeft = malloc ("marginLeft", 2);
+ public static final int XmNmarginRight = malloc ("marginRight", 2);
+ public static final int XmNmarginTop = malloc ("marginTop", 2);
+ public static final int XmNmarginWidth = malloc ("marginWidth", 2);
+ public static final int XmNpositionIndex = malloc ("positionIndex", 2);
+ public static final int XmNrows = malloc ("rows", 2);
+ public static final int XmNshadowThickness = malloc ("shadowThickness", 2);
+ public static final int XmNshowAsDefault = malloc ("showAsDefault", 2);
+ public static final int XmNwidth = malloc ("width", 2);
+ public static final int XmNx = malloc ("x", 2);
+ public static final int XmNy = malloc ("y", 2);
+
+ /* int */
+ public static final int XmNaccelerator = malloc ("accelerator", 4);
+ public static final int XmNacceleratorText = malloc ("acceleratorText", 4);
+ public static final int XmNactivateCallback = malloc ("activateCallback", 4);
+ public static final int XmNarmCallback = malloc ("armCallback", 4);
+ public static final int XmNbackground = malloc ("background", 4);
+ public static final int XmNborderColor = malloc ("borderColor", 4);
+ public static final int XmNbottomShadowColor = malloc ("bottomShadowColor", 4);
+ public static final int XmNbrowseSelectionCallback = malloc ("browseSelectionCallback", 4);
+ public static final int XmNcancelCallback = malloc ("cancelCallback", 4);
+ public static final int XmNcancelLabelString = malloc ("cancelLabelString", 4);
+ public static final int XmNcascadingCallback = malloc ("cascadingCallback", 4);
+ public static final int XmNchildren = malloc ("children", 4);
+ public static final int XmNclientData = malloc ("clientData", 4);
+ public static final int XmNcolormap = malloc ("colormap", 4);
+ public static final int XmNconvertProc = malloc ("convertProc", 4);
+ public static final int XmNdecrementCallback = malloc ("decrementCallback", 4);
+ public static final int XmNdefaultActionCallback = malloc ("defaultActionCallback", 4);
+ public static final int XmNdefaultButtonShadowThickness = malloc ("defaultButtonShadowThickness", 4);
+ public static final int XmNdialogTitle = malloc ("dialogTitle", 4);
+ public static final int XmNdirectory = malloc ("directory", 4);
+ public static final int XmNdirMask = malloc ("dirMask", 4);
+ public static final int XmNdirSpec = malloc ("dirSpec", 4);
+ public static final int XmNdragCallback = malloc ("dragCallback", 4);
+ public static final int XmNdragDropFinishCallback = malloc ("dragDropFinishCallback", 4);
+ public static final int XmNdragProc = malloc ("dragProc", 4);
+ public static final int XmNdropFinishCallback = malloc ("dropFinishCallback", 4);
+ public static final int XmNdropProc = malloc("dropProc", 4);
+ public static final int XmNeditMode = malloc ("editMode", 4);
+ public static final int XmNexportTargets = malloc ("exportTargets", 4);
+ public static final int XmNexposeCallback = malloc ("exposeCallback", 4);
+ public static final int XmNextendedSelectionCallback = malloc ("extendedSelectionCallback", 4);
+ public static final int XmNfilterLabelString = malloc ("filterLabelString", 4);
+ public static final int XmNfont = malloc ("font", 4);
+ public static final int XmNfontList = malloc ("fontList", 4);
+ public static final int XmNfontType = malloc ("fontType", 4);
+ public static final int XmNforeground = malloc ("foreground", 4);
+ public static final int XmNhelpCallback = malloc ("helpCallback", 4);
+ public static final int XmNhelpLabelString = malloc ("helpLabelString", 4);
+ public static final int XmNhighlightColor = malloc ("highlightColor", 4);
+ public static final int XmNhorizontalScrollBar = malloc ("horizontalScrollBar", 4);
+ public static final int XmNiconMask = malloc ("iconMask", 4);
+ public static final int XmNiconPixmap = malloc ("iconPixmap", 4);
+ public static final int XmNincrement = malloc ("increment", 4);
+ public static final int XmNincrementCallback = malloc ("incrementCallback", 4);
+ public static final int XmNitemCount = malloc ("itemCount", 4);
+ public static final int XmNitems = malloc ("items", 4);
+ public static final int XmNlabelInsensitivePixmap = malloc ("labelInsensitivePixmap", 4);
+ public static final int XmNlabelPixmap = malloc ("labelPixmap", 4);
+ public static final int XmNlabelString = malloc ("labelString", 4);
+ public static final int XmNlist = malloc ("list", 4);
+ public static final int XmNmapCallback = malloc ("mapCallback", 4);
+ public static final int XmNmappedWhenManaged = malloc ("mappedWhenManaged", 4);
+ public static final int XmNmaximum = malloc ("maximum", 4);
+ public static final int XmNmenuBar = malloc ("menuBar", 4);
+ public static final int XmNmessageString = malloc ("messageString", 4);
+ public static final int XmNminimum = malloc ("minimum", 4);
+ public static final int XmNmodifyVerifyCallback = malloc ("modifyVerifyCallback", 4);
+ public static final int XmNmwmDecorations = malloc ("mwmDecorations", 4);
+ public static final int XmNmwmInputMode = malloc ("mwmInputMode", 4);
+ public static final int XmNnumChildren = malloc ("numChildren", 4);
+ public static final int XmNnumDropTransfers = malloc ("numDropTransfers", 4);
+ public static final int XmNnumExportTargets = malloc ("numExportTargets", 4);
+ public static final int XmNnumImportTargets = malloc("numImportTargets", 4);
+ public static final int XmNmnemonic = malloc ("mnemonic", 4);
+ public static final int XmNimportTargets = malloc("importTargets", 4);
+ public static final int XmNokCallback = malloc ("okCallback", 4);
+ public static final int XmNokLabelString = malloc ("okLabelString", 4);
+ public static final int XmNoperationCursorIcon = malloc ("operationCursorIcon", 4);
+ public static final int XmNselectionCallback = malloc ("selectionCallback", 4);
+ public static final int XmNsourceCursorIcon = malloc ("sourceCursorIcon", 4);
+ public static final int XmNstateCursorIcon = malloc ("stateCursorIcon", 4);
+ public static final int XmNsubstitute = malloc ("substitute", 4);
+ public static final int XmNpageDecrementCallback = malloc ("pageDecrementCallback", 4);
+ public static final int XmNpageIncrement = malloc ("pageIncrement", 4);
+ public static final int XmNpageIncrementCallback = malloc ("pageIncrementCallback", 4);
+ public static final int XmNpathMode = malloc ("pathMode", 4);
+ public static final int XmNpattern = malloc ("pattern", 4);
+// public static final int XmNpopupEnabled = malloc ("popupEnabled", 4);
+// public static final int XmNpopupHandlerCallback = malloc ("popupHandlerCallback", 4);
+ public static final int XmNrenderTable = malloc ("renderTable", 4);
+ public static final int XmNscaleMultiple = malloc ("scaleMultiple", 4);
+ public static final int XmNselectedItemCount = malloc ("selectedItemCount", 4);
+ public static final int XmNselectedItems = malloc ("selectedItems", 4);
+ public static final int XmNselectedPosition = malloc ("selectedPosition", 4);
+ public static final int XmNselectionArrayCount = malloc ("selectionArrayCount", 4);
+ public static final int XmNsliderSize = malloc ("sliderSize", 4);
+ public static final int XmNsliderVisual = malloc ("sliderVisual", 4);
+ public static final int XmNsubMenuId = malloc ("subMenuId", 4);
+ public static final int XmNtabList = malloc ("tabList", 4);
+ public static final int XmNtextField = malloc ("textField", 4);
+ public static final int XmNtitle = malloc ("title", 4);
+ public static final int XmNtitleString = malloc ("titleString", 4);
+ public static final int XmNtoBottomCallback = malloc ("toBottomCallback", 4);
+ public static final int XmNtoTopCallback = malloc ("toTopCallback", 4);
+// public static final int XmNtopCharacter = malloc ("topCharacter", 4);
+ public static final int XmNtopItemPosition = malloc ("topItemPosition", 4);
+ public static final int XmNtopShadowColor = malloc ("topShadowColor", 4);
+ public static final int XmNtransferProc = malloc ("transferProc", 4);
+ public static final int XmNtransferStatus = malloc ("transferStatus", 4);
+ public static final int XmNtroughColor = malloc ("troughColor", 4);
+ public static final int XmNunmapCallback = malloc ("unmapCallback", 4);
+ public static final int XmNuserData = malloc ("userData", 4);
+ public static final int XmNvalue = malloc ("value", 4);
+ public static final int XmNvalueChangedCallback = malloc ("valueChangedCallback", 4);
+ public static final int XmNverticalScrollBar = malloc ("verticalScrollBar", 4);
+ public static final int XmNvisibleItemCount = malloc ("visibleItemCount", 4);
+ public static final int XmNdropTransfers = malloc ("dropTransfers", 4);
+ public static final int XmNshowArrows = malloc ("showArrows", 4);
+ public static final int XmNspotLocation = malloc ("spotLocation", 4);
+// public static final int XNFocusWindow = malloc ("focusWindow", 4);
+// public static final int XNInputStyle = malloc ("inputStyle", 4);
+// public static final int XNClientWindow = malloc ("clientWindow", 4);
+// public static final int XNQueryInputStyle = malloc ("queryInputStyle", 4);
+
+ 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 XmREVERSED_GROUND_COLORS = -2;
+ public static final int XmSET = 0x1;
+ 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 XmUNSET = 0x0;
+ 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 synchronized native int XBlackPixel (int display, int screenNum);
+ public static final synchronized native void XChangeActivePointerGrab (int display, int eventMask, int cursor, int time);
+ public static final synchronized native int XDefaultGC (int display, int screen_number);
+ public static final synchronized native void XNoOp (int display);
+ public static final synchronized native int XRootWindowOfScreen (int screen);
+ public static final synchronized native int XSendEvent (int display, int w, boolean propagate, int event_mask, XAnyEvent event);
+ public static final synchronized native int XmCreateCascadeButton (int parent, byte [] name, int [] arglist, int argcount);
+ public static final synchronized native int XmCreateDrawnButton (int parent, byte [] name, int [] arglist, int argcount);
+ public static final synchronized native int XmCreateRowColumn (int parent, byte [] name, int [] arglist, int argcount);
+ public static final synchronized native int XmCreateScrolledWindow (int parent, byte [] name, int [] arglist, int argcount);
+ public static final synchronized native int XmGetFocusWidget (int widget);
+ public static final synchronized native void XmListAddItemsUnselected (int list, int xmStringTable, int item_count, int position);
+ public static final synchronized native void XmListDeleteItem (int list, int item);
+ public static final synchronized native void XmListDeselectItem (int list, int xmString);
+ public static final synchronized native void XmListSelectItem (int list, int xmString, boolean notify);
+ public static final synchronized native int XmPushButtonWidgetClass ();
+ public static final synchronized native int XmStringLineCount (int xmString);
+ public static final synchronized native boolean XmTextRemove (int widget);
+ public static final synchronized native int XtAppSetErrorHandler (int app_context, int handler);
+ public static final synchronized native int XtAppSetWarningHandler (int app_context, int handler);
+ public static final synchronized native void XtCallActionProc (int widget, byte [] action, XAnyEvent event, byte [] params, int num_params);
+ public static final synchronized native void XtCloseDisplay (int display);
+ public static final synchronized native int XtCreateWidget (byte [] name, int widgetClass, int parent, int [] argList, int argCount);
+ public static final synchronized native void XtRemoveCallback (int widget, int callback_name, int callback, int client_data);
+ public static final synchronized native void XtRemoveEventHandler (int widget, int event_mask, boolean nonmaskable, int proc, int client_data);
+ public static final synchronized native int XtScreen (int widget);
+ */
+public static final synchronized native int OverrideShellWidgetClass ();
+public static final synchronized native int ShellWidgetClass ();
+public static final synchronized native int TopLevelShellWidgetClass ();
+public static final synchronized native int TransientShellWidgetClass ();
+public static final synchronized native int XAllocColor (int display, int colormap, XColor color);
+public static final synchronized native void XBell (int display, int ms);
+public static final synchronized native int XBitmapBitOrder (int display);
+public static final synchronized native int XBlackPixel (int display, int screenNum);
+public static final synchronized native int XChangeActivePointerGrab(int display, int event_mask, int cursor, int time);
+public static final synchronized native int XChangeGC (int display, int gc, int valuemask, XGCValues values);
+public static final synchronized native void XChangeWindowAttributes (int display, int window, int mask, XSetWindowAttributes attributes);
+public static final synchronized native boolean XCheckMaskEvent (int display, int mask, XAnyEvent event);
+public static final synchronized native boolean XCheckWindowEvent (int display, int window, int mask, XAnyEvent event);
+public static final synchronized native void XClearArea (int display, int window, int x, int y, int width, int height, boolean exposures);
+public static final synchronized native void XClipBox (int region, XRectangle rectangle);
+public static final synchronized 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 synchronized 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 synchronized native int XCreateBitmapFromData (int display, int drawable, byte [] data, int width, int height);
+public static final synchronized native int XCreateFontCursor (int display, int shape);
+public static final synchronized native int XCreateGC (int display, int window, int mask, XGCValues values);
+public static final synchronized 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 synchronized native int XCreatePixmap (int display, int drawable, int width, int height, int depth);
+public static final synchronized native int XCreatePixmapCursor (int display, int source, int mask, XColor foreground_color, XColor background_color, int x, int y);
+public static final synchronized native int XCreateRegion ();
+public static final synchronized native int XDefaultColormap (int display, int screen_number);
+public static final synchronized native int XDefaultDepthOfScreen (int screen);
+public static final synchronized native int XDefaultRootWindow (int display);
+public static final synchronized native int XDefaultScreen (int display);
+public static final synchronized native int XDefaultScreenOfDisplay (int display);
+public static final synchronized native int XDefaultVisual (int display, int screen_number);
+public static final synchronized native void XDefineCursor (int display, int window, int cursor);
+public static final synchronized native int XDestroyImage(int ximage);
+public static final synchronized native void XDestroyRegion (int region);
+public static final synchronized native int XDisplayHeight (int display, int screen);
+public static final synchronized native int XDisplayHeightMM (int display, int screen);
+public static final synchronized native int XDisplayWidth (int display, int screen);
+public static final synchronized native int XDisplayWidthMM (int display, int screen);
+public static final synchronized native void XDrawArc (int display, int drawable, int gc, int x1, int y1, int x2, int y2, int a1, int a2);
+public static final synchronized native void XDrawLine (int display, int drawable, int gc, int x1, int y1, int x2, int y2);
+public static final synchronized native void XDrawLines (int display, int drawable, int gc, short[] xPoints, int nPoints, int mode);
+public static final synchronized native void XDrawRectangle (int display, int drawable, int gc, int x, int y, int width, int height);
+public static final synchronized native boolean XEmptyRegion (int region);
+public static final synchronized native boolean XEqualRegion (int region1, int region2);
+public static final synchronized native void XFillArc (int display, int drawable, int gc, int x1, int y1, int x2, int y2, int a1, int a2);
+public static final synchronized native int XFillPolygon (int display, int drawable, int gc, short[] xPoints, int nPoints, int mode, int style);
+public static final synchronized native void XFillRectangle (int display, int drawable, int gc, int x, int y, int width, int height);
+public static final synchronized native boolean XFilterEvent (XAnyEvent event, int window);
+public static final synchronized native void XFlush (int display);
+public static final synchronized native int XFontsOfFontSet (int fontSet, int[] fontStructs, int[] fontNames);
+public static final synchronized native int XFree (int address);
+public static final synchronized native int XFreeColors (int display, int colormap, int [] pixels, int npixels, int planes);
+public static final synchronized native void XFreeCursor (int display, int pixmap);
+public static final synchronized native void XFreeFontNames(int list);
+public static final synchronized native void XFreeFont(int display, int font_struct);
+public static final synchronized native void XFreeFontSet(int display, int font_set);
+public static final synchronized native void XFreeGC (int display, int gc);
+public static final synchronized native void XFreePixmap (int display, int pixmap);
+public static final synchronized native int XGetGCValues (int display, int gc, int valuemask, XGCValues values);
+public static final synchronized 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 synchronized native int XGetImage (int display, int drawable, int x, int y, int width, int height, int plane_mask, int format);
+public static final synchronized native int XGetInputFocus (int display, int [] window, int [] revert);
+public static final synchronized native boolean XGetWindowAttributes (int display, int window, XWindowAttributes attributes);
+public static final synchronized native int XGrabKeyboard (
+ int display,
+ int grabWindow,
+ int ownerEvents,
+ int pointerMode,
+ int keyboardMode,
+ int time);
+public static final synchronized native int XGrabPointer (
+ int display,
+ int grabWindow,
+ int ownerEvents,
+ int eventMask,
+ int pointerMode,
+ int keyboardMode,
+ int confineToWindow,
+ int cursor,
+ int time);
+public static final synchronized native int XInitThreads ();
+public static final synchronized native int XInternAtom( int display, byte [] name, boolean ifExists );
+public static final synchronized native int XKeysymToString (int keysym);
+public static final synchronized native int XListFonts(int display, byte[] pattern, int maxnames, int[] actual_count_return);
+public static final synchronized native int XListProperties(int display, int window, int[] num_prop_return);
+public static final synchronized native int XLookupString (XKeyEvent event, byte [] string, int size, int [] keysym, int [] status);
+public static final synchronized native int XLowerWindow (int display, int window);
+public static final synchronized native boolean XPointInRegion (int region, int x, int y);
+public static final synchronized 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 synchronized native int XQueryColor (int display, int colormap, XColor color);
+public static final synchronized native int XQueryPointer (
+ int display,
+ int window,
+ int [] root,
+ int [] child,
+ int [] rootX,
+ int [] rootY,
+ int [] windowX,
+ int [] windowY,
+ int [] mask);
+public static final synchronized native int XQueryTree (int display, int window, int [] root_return, int [] parent_return, int [] children_return, int [] nChildren_return);
+public static final synchronized native int XRaiseWindow (int display, int window);
+public static final synchronized native int XReconfigureWMWindow (int display, int window, int screen, int valueMask, XWindowChanges values);
+public static final synchronized native int XRectInRegion (int region, int x, int y, int width, int height);
+public static final synchronized native void XSetBackground (int display, int gc, int background);
+public static final synchronized native void XSetClipMask (int display, int gc, int pixmap);
+public static final synchronized native void XSetClipRectangles (int display, int gc, int clip_x_origin, int clip_y_origin, XRectangle rectangles, int n, int ordering);
+public static final synchronized native int XSetDashes (int display, int gc, int dash_offset, byte[] dash_list, int n);
+public static final synchronized native int XSetErrorHandler (int handler);
+public static final synchronized native void XSetFillStyle (int display, int gc, int fill_style);
+public static final synchronized native int XSetFont (int display, int gc, int font);
+public static final synchronized native void XSetForeground (int display, int gc, int foreground);
+public static final synchronized native void XSetFunction (int display, int gc, int function);
+public static final synchronized native void XSetGraphicsExposures (int display, int gc, boolean graphics_exposures);
+public static final synchronized native int XSetInputFocus (int display, int window, int revert, int time);
+public static final synchronized native int XSetLineAttributes (int display, int gc, int lineWidth, int lineStyle, int capStyle, int joinStyle);
+public static final synchronized native void XSetRegion (int display, int gc, int region);
+public static final synchronized native void XSetStipple (int display, int gc, int pixmap);
+public static final synchronized native void XSetSubwindowMode (int display, int gc, int subwindow_mode);
+public static final synchronized native void XSetWindowBorderWidth (int display, int window, int width);
+public static final synchronized native void XSubtractRegion (int sra, int srb, int dr_return);
+public static final synchronized native void XSync (int display, boolean discard);
+public static final synchronized native int XSynchronize (int display, boolean onoff);
+public static final synchronized native void XUndefineCursor (int display, int window);
+public static final synchronized native int XUngrabKeyboard (int display, int time);
+public static final synchronized native int XUngrabPointer (int display, int time);
+public static final synchronized native void XUnionRectWithRegion (XRectangle rectangle, int src_region, int dest_region_return);
+public static final synchronized native void XUnionRegion (int sra, int srb, int dr_return);
+public static final synchronized native int XWarpPointer (int display, int sourceWindow, int destWindow, int sourceX, int sourceY, int sourceWidth, int sourceHeight, int destX, int destY);
+public static final synchronized native int XWhitePixel (int display, int screenNum);
+public static final synchronized native void XWithdrawWindow (int display, int window, int screen);
+public static final synchronized native void XmAddWMProtocolCallback (int shell, int protocol, int callback, int closure);
+public static final synchronized native void XmChangeColor (int widget, int pixel);
+public static final synchronized 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 synchronized native int XmClipboardEndCopy(int display, int window, int item_id);
+public static final synchronized native int XmClipboardStartCopy(int display, int window, int clip_label, int timestamp, int widget, int callback, int[] item_id);
+public static final synchronized native int XmClipboardInquireLength(int display, int widget, byte[] format_name, int[] length);
+public static final synchronized native int XmClipboardInquireFormat(int display, int window, int index, byte[] format_name_buf, int buffer_len, int[]copied_len);
+public static final synchronized native int XmClipboardInquireCount(int display, int window, int[] count, int[] max_format_name_length);
+public static final synchronized native int XmClipboardStartRetrieve(int display, int window, int timestamp);
+public static final synchronized native int XmClipboardRetrieve(int display, int window, byte[] format_name, byte[] buffer, int length, int[] num_bytes, int[] private_id);
+public static final synchronized native int XmClipboardEndRetrieve(int display, int window);
+public static final synchronized native void XmComboBoxAddItem(int widget, int xmString, int position, boolean unique);
+public static final synchronized native void XmComboBoxDeletePos(int widget, int position);
+public static final synchronized native void XmComboBoxSelectItem(int widget, int xmString);
+public static final synchronized native int XmCreateArrowButton (int parent, byte [] name, int [] arglist, int argcount);
+public static final synchronized native int XmCreateCascadeButtonGadget (int parent, byte [] name, int [] arglist, int argcount);
+public static final synchronized native int XmCreateComboBox(int parent, byte [] name, int [] arglist, int argcount);
+public static final synchronized native int XmCreateDialogShell (int parent, byte [] name, int [] arglist, int argcount);
+public static final synchronized native int XmCreateDrawingArea (int parent, byte [] name, int [] arglist, int argcount);
+//public static final synchronized native int XmCreateDrawnButton (int parent, byte [] name, int [] arglist, int argcount);
+public static final synchronized native int XmCreateErrorDialog (int parent, byte [] name, int [] arglist, int argcount);
+public static final synchronized native int XmCreateFileSelectionDialog (int parent, byte [] name, int [] arglist, int argcount);
+public static final synchronized native int XmCreateForm (int parent, byte [] name, int [] arglist, int argcount);
+public static final synchronized native int XmCreateFrame (int parent, byte [] name, int [] arglist, int argcount);
+public static final synchronized native int XmCreateInformationDialog (int parent, byte [] name, int [] arglist, int argcount);
+public static final synchronized native int XmCreateLabel (int parent, byte [] name, int [] arglist, int argcount);
+public static final synchronized native int XmCreateList (int parent, byte [] name, int [] arglist, int argcount);
+public static final synchronized native int XmCreateMainWindow (int parent, byte [] name, int [] arglist, int argcount);
+public static final synchronized native int XmCreateMenuBar (int parent, byte [] name, int [] arglist, int argcount);
+public static final synchronized native int XmCreateMessageDialog (int parent, byte [] name, int [] arglist, int argcount);
+public static final synchronized native int XmCreatePopupMenu (int parent, byte [] name, int [] arglist, int argcount);
+public static final synchronized native int XmCreatePulldownMenu (int parent, byte [] name, int [] arglist, int argcount);
+public static final synchronized native int XmCreatePushButton (int parent, byte [] name, int [] arglist, int argcount);
+public static final synchronized native int XmCreatePushButtonGadget (int parent, byte [] name, int [] arglist, int argcount);
+public static final synchronized native int XmCreateQuestionDialog (int parent, byte [] name, int [] arglist, int argcount);
+public static final synchronized native int XmCreateScale (int parent, byte [] name, int [] arglist, int argcount);
+public static final synchronized native int XmCreateScrollBar (int parent, byte [] name, int [] arglist, int argcount);
+public static final synchronized native int XmCreateScrolledList (int parent, byte [] name, int [] arglist, int argcount);
+public static final synchronized native int XmCreateScrolledText (int parent, byte [] name, int [] arglist, int argcount);
+public static final synchronized native int XmCreateSeparator (int parent, byte [] name, int [] arglist, int argcount);
+public static final synchronized native int XmCreateSeparatorGadget (int parent, byte [] name, int [] arglist, int argcount);
+//public static final synchronized native int XmCreateSimpleSpinBox (int parent, byte [] name, int [] arglist, int argcount);
+//public static final synchronized native int XmCreateSpinBox (int parent, byte [] name, int [] arglist, int argcount);
+public static final synchronized native int XmCreateTextField (int parent, byte [] name, int [] arglist, int argcount);
+public static final synchronized native int XmCreateToggleButton (int parent, byte [] name, int [] arglist, int argcount);
+public static final synchronized native int XmCreateToggleButtonGadget (int parent, byte [] name, int [] arglist, int argcount);
+public static final synchronized native int XmCreateWarningDialog (int parent, byte [] name, int [] arglist, int argcount);
+public static final synchronized native boolean XmDestroyPixmap (int screen, int pixmap);
+public static final synchronized native void XmDragCancel(int dragcontext);
+public static final synchronized native int XmDragStart(int widget, XAnyEvent event, int[] arglist, int argcount);
+public static final synchronized native void XmDropSiteRegister(int widget, int [] arglist, int argcount);
+public static final synchronized native void XmDropSiteUnregister(int widget);
+public static final synchronized native void XmDropSiteUpdate(int widget, int [] arglist, int argcount);
+public static final synchronized native void XmDropTransferAdd(int drop_transfer, int [] transfers, int num_transfers);
+public static final synchronized native int XmDropTransferStart(int widget, int [] arglist, int argcount);
+public static final synchronized native int XmFileSelectionBoxGetChild (int widget, int child);
+public static final synchronized native int XmFontListAppendEntry (int oldList, int entry);
+public static final synchronized native int XmFontListCopy (int fontlist);
+public static final synchronized native void XmFontListEntryFree (int[] entry);
+public static final synchronized native int XmFontListEntryGetFont (int entry, int[] type_return);
+public static final synchronized native int XmFontListEntryLoad (int display, byte [] fontName, int type, byte[] tag);
+public static final synchronized native void XmFontListFree (int list);
+public static final synchronized native void XmFontListFreeFontContext (int context);
+public static final synchronized native boolean XmFontListInitFontContext (int[] context,int fontList);
+public static final synchronized native int XmFontListNextEntry (int context);
+public static final synchronized native int XmGetAtomName (int display, int atom);
+public static final synchronized native int XmGetDragContext (int widget, int timestamp);
+public static final synchronized native int XmGetFocusWidget (int widget);
+public static final synchronized native int XmGetPixmap( int screen, byte [] name, int fgPixel, int bgPixel );
+public static final synchronized native int XmGetPixmapByDepth (int screen, byte [] image_name, int foreground, int background, int depth);
+public static final synchronized native int XmGetXmDisplay (int display);
+public static final synchronized native int XmImMbLookupString (int widget, XKeyEvent event, byte [] string, int size, int [] keysym, int [] status);
+public static final synchronized native int XmInternAtom (int display, byte [] name, boolean only_if_exists);
+public static final synchronized native void XmListAddItemUnselected (int list, int xmString, int position);
+public static final synchronized native void XmListDeleteAllItems (int list);
+public static final synchronized native void XmListDeleteItemsPos (int list, int item_count, int position);
+public static final synchronized native void XmListDeletePos (int list, int position);
+public static final synchronized native void XmListDeletePositions (int list, int [] position_list, int position_count);
+public static final synchronized native void XmListDeselectAllItems (int list);
+public static final synchronized native void XmListDeselectPos (int list, int position);
+public static final synchronized native int XmListGetKbdItemPos (int list);
+public static final synchronized native boolean XmListGetSelectedPos (int list, int [] positions, int [] count);
+public static final synchronized native int XmListItemPos (int list, int xmString);
+public static final synchronized native boolean XmListPosSelected (int list, int position);
+public static final synchronized native void XmListReplaceItemsPosUnselected (int list, int [] new_items, int item_count, int position);
+public static final synchronized native void XmListSelectPos (int list, int position, boolean notify);
+public static final synchronized native boolean XmListSetKbdItemPos (int list, int position);
+public static final synchronized native void XmListSetPos (int list, int position);
+public static final synchronized native void XmListUpdateSelectedList (int list);
+public static final synchronized native void XmMainWindowSetAreas (int widget, int menu, int command, int hscroll, int vscroll, int wregion);
+public static final synchronized native int XmMenuShellWidgetClass ();
+public static final synchronized native int XmMessageBoxGetChild (int widget, int child);
+public static final synchronized native int XmParseMappingCreate (int [] argList, int argCount);
+public static final synchronized native void XmParseMappingFree (int parseMapping);
+public static final synchronized native boolean XmProcessTraversal (int widget, int dir);
+public static final synchronized native int XmRenderTableAddRenditions(int oldTable, int[] renditions, int renditionCount, int mergeMode);
+public static final synchronized native void XmRenderTableFree(int renderTable);
+public static final synchronized native int XmRenditionCreate(int widget, byte[] tag, int[] argList, int argCount);
+public static final synchronized native void XmRenditionFree(int rendition);
+public static final synchronized native boolean XmStringCompare (int xmString1, int xmString2);
+public static final synchronized native int XmStringComponentCreate (int type, int length, byte[] value);
+public static final synchronized native int XmStringCreate (byte [] string, byte [] charset);
+public static final synchronized native int XmStringCreateLocalized (byte [] string);
+//public static final synchronized native int XmStringCreateLtoR (byte [] string, byte [] charset);
+public static final synchronized 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 synchronized 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 synchronized 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 synchronized native boolean XmStringEmpty (int s1);
+public static final synchronized native void XmStringFree (int xmString);
+//public static final synchronized native boolean XmStringGetLtoR (int xmString, byte [] charset, int [] text);
+public static final synchronized native int XmStringGenerate(byte[] text, byte[] tag, int type, byte[] rendition);
+public static final synchronized native int XmStringHeight (int fontList, int xmString);
+public static final synchronized native int XmStringParseText (byte[] text, int textEnd, byte [] tag, int tagType, int [] parseTable, int parseCount, int callData);
+public static final synchronized native int XmStringWidth (int fontList, int xmString);
+public static final synchronized native int XmStringUnparse (int xmString, byte [] tag, int tagType, int outputType, int [] parseTable, int parseCount, int parseModel);
+public static final synchronized native int XmTabCreate(int value, byte units, byte offsetModel, byte alignment, byte[] decimal);
+public static final synchronized native void XmTabFree(int tab);
+public static final synchronized native void XmTabListFree(int tabList);
+public static final synchronized native int XmTabListInsertTabs(int oldList, int[] tabs, int tab_count, int position);
+public static final synchronized native void XmTextClearSelection (int widget, int time);
+public static final synchronized native boolean XmTextCopy (int widget, int time);
+public static final synchronized native boolean XmTextCut (int widget, int time);
+public static final synchronized native void XmTextDisableRedisplay (int widget);
+public static final synchronized native void XmTextEnableRedisplay (int widget);
+public static final synchronized native int XmTextGetInsertionPosition (int widget);
+public static final synchronized native int XmTextGetLastPosition (int widget);
+public static final synchronized native int XmTextGetMaxLength (int widget);
+public static final synchronized native int XmTextGetSelection (int widget);
+public static final synchronized native boolean XmTextGetSelectionPosition (int widget, int [] left, int [] right);
+public static final synchronized native int XmTextGetString (int widget);
+public static final synchronized native int XmTextGetSubstring (int widget, int start, int num_chars, int buffer_size, byte [] buffer);
+public static final synchronized native int XmTextGetSubstringWcs (int widget, int start, int num_chars, int buffer_size, char [] buffer);
+public static final synchronized native void XmTextInsert (int widget, int position, byte [] value);
+public static final synchronized native boolean XmTextPaste (int widget);
+public static final synchronized native boolean XmTextPosToXY (int widget, int position, short [] x, short [] y);
+public static final synchronized native void XmTextReplace (int widget, int from_pos, int to_pos, byte [] value);
+public static final synchronized native void XmTextScroll (int widget, int lines);
+public static final synchronized native void XmTextSetEditable (int widget, boolean editable);
+public static final synchronized native void XmTextSetHighlight (int widget, int left, int right, int mode);
+public static final synchronized native void XmTextSetInsertionPosition (int widget, int position);
+public static final synchronized native void XmTextSetMaxLength (int widget, int max_length);
+public static final synchronized native void XmTextSetSelection (int widget, int first, int last, int time);
+public static final synchronized native void XmTextSetString (int widget, byte [] value);
+public static final synchronized native void XmTextShowPosition (int widget, int position);
+public static final synchronized native void XmUpdateDisplay (int widget);
+public static final synchronized native boolean XmWidgetGetDisplayRect (int region, XRectangle rectangle);
+//public static final synchronized native int XmbLookupString (int ic, XKeyEvent event, byte [] string, int size, int [] keysym, int [] status);
+public static final synchronized native int XmbTextListToTextProperty (int display, int list, int count, int style, XTextProperty text_prop_return);
+public static final synchronized native int XmbTextPropertyToTextList (int display, XTextProperty text_prop, int[] list_return, int[] count_return);
+
+public static final synchronized native void XtAddCallback (int widget, int callback_name, int callback, int client_data);
+public static final synchronized native void XtAddEventHandler (int widget, int event_mask, boolean nonmaskable, int proc, int client_data);
+public static final synchronized native void XtAddExposureToRegion (int event, int region);
+public static final synchronized native int XtAppAddTimeOut (int app_context, int interval, int proc, int client_data);
+public static final synchronized native int XtAppCreateShell (
+ byte [] appName,
+ byte [] appClass,
+ int widgetClass,
+ int display,
+ int [] argList,
+ int argCount);
+public static final synchronized native int XtAppGetSelectionTimeout (int appContext);
+public static final synchronized native void XtAppNextEvent (int appContext, XAnyEvent event);
+public static final synchronized native boolean XtAppPeekEvent (int appContext, XAnyEvent event);
+public static final synchronized native int XtAppPending (int appContext);
+public static final synchronized native void XtAppProcessEvent (int appContext, int inputMask);
+public static final synchronized native int XtAppSetErrorHandler (int app_context, int msg_handler);
+public static final synchronized native void XtAppSetSelectionTimeout (int appContext, int timeout);
+public static final synchronized native int XtAppSetWarningHandler (int app_context, int msg_handler);
+public static final synchronized native int XtBuildEventMask (int widget);
+public static final synchronized native void XtCallActionProc (int widget, byte [] action, XAnyEvent event, int [] params, int num_params);
+public static final synchronized native int XtClass (int widget);
+public static final synchronized native void XtConfigureWidget (int widget, int x, int y, int width, int height, int borderWidth);
+public static final synchronized native int XtCreateApplicationContext ();
+public static final synchronized native int XtCreatePopupShell (byte [] name, int widgetClass, int parent, int [] argList, int argCount);
+public static final synchronized native void XtDestroyApplicationContext (int appContext);
+public static final synchronized native void XtDestroyWidget (int widget);
+public static final synchronized native boolean XtDispatchEvent (XAnyEvent event);
+public static final synchronized native int XtDisplay (int widget);
+public static final synchronized native int XtDisplayToApplicationContext (int display);
+public static final synchronized native void XtFree (int ptr);
+public static final synchronized native int XtGetMultiClickTime (int display);
+public static final synchronized native void XtGetValues (int widget, int [] argList, int numArgs);
+public static final synchronized native boolean XtIsManaged (int widget);
+public static final synchronized native boolean XtIsRealized (int widget);
+public static final synchronized native boolean XtIsSubclass (int widget, int widgetClass);
+public static final synchronized native boolean XtIsTopLevelShell (int widget);
+public static final synchronized native boolean XtIsWidget (int widget);
+public static final synchronized native int XtLastTimestampProcessed (int display);
+public static final synchronized native int XtMalloc (int size);
+public static final synchronized native void XtManageChild (int widget);
+public static final synchronized native void XtMapWidget (int widget);
+public static final synchronized native void XtMoveWidget (int widget, int x, int y);
+public static final synchronized native int XtOpenDisplay (
+ int xtAppContext,
+ byte [] displayName,
+ byte [] applicationName,
+ byte [] applicationClass,
+ int options,
+ int numOptions,
+ int [] argc,
+ int argv);
+public static final synchronized native void XtOverrideTranslations (int w, int translations);
+public static final synchronized native int XtParent (int widget);
+public static final synchronized native int XtParseTranslationTable (byte [] string);
+public static final synchronized native void XtPopdown (int widget);
+public static final synchronized native void XtPopup (int widget, int flags);
+public static final synchronized native int XtQueryGeometry (int widget, XtWidgetGeometry intended, XtWidgetGeometry preferred_return);
+public static final synchronized native void XtRealizeWidget (int widget);
+public static final synchronized native void XtRemoveTimeOut (int id);
+public static final synchronized native void XtResizeWidget (int widget, int width, int height, int borderWidth);
+public static final synchronized native void XtResizeWindow (int widget);
+public static final synchronized native int XtSetLanguageProc (int appContext, int languageProc, int pointer);
+public static final synchronized native void XtSetMappedWhenManaged (int widget, boolean flag);
+public static final synchronized native void XtSetValues (int widget, int [] argList, int numArgs);
+public static final synchronized native void XtToolkitInitialize ();
+public static final synchronized native void XtTranslateCoords (int widget, short x, short y, short [] root_x, short [] root_y);
+public static final synchronized native void XtUnmanageChild (int widget);
+public static final synchronized native void XtUnmapWidget (int widget);
+public static final synchronized native int XtWindow (int widget);
+public static final synchronized native int XtWindowToWidget (int display, int widget);
+
+static int malloc (String name, int length) {
+ int strLen = name.length ();
+ if (NextResourceStart + strLen + 2 > RESOURCE_START + RESOURCE_LENGTH) {
+ System.out.println ("*** Warning : SWT - Resource overrun. Increase OS.RESOURCE_LENGTH.");
+ System.out.println ("*** Warning : Exiting ...");
+ System.exit (0);
+ }
+ char [] unicode = new char [strLen];
+ name.getChars (0, strLen, unicode, 0);
+ byte[] buffer = new byte [strLen + 2];
+ buffer [0] = (byte) length;
+ for (int i = 0; i < strLen; i++) {
+ buffer [i+1] = (byte) unicode[i];
+ }
+ OS.memmove (NextResourceStart, buffer, strLen + 2);
+ int result = NextResourceStart + 1;
+ NextResourceStart += strLen + 2;
+ return result;
+}
+
+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, char [] 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 (int dest, XButtonEvent 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 (char [] 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 synchronized native int XmCreateDrawnButton (int parent, byte [] name, int [] arglist, int argcount);
+public static final synchronized native int XCheckIfEvent (int display, XAnyEvent event_return, int predicate, int arg);
+public static final synchronized native boolean XtToolkitThreadInitialize ();
+public static final synchronized native int Call (int proc, int arg1, int arg2);
+public static final synchronized native int XSetIOErrorHandler (int handler);
+public static final synchronized 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 synchronized native int XpCreateContext(int display, byte [] printer_name);
+public static final synchronized native int XpGetPrinterList(int display, byte [] printer_name, int [] list_count);
+public static final synchronized native void XpFreePrinterList(int printer_list);
+public static final synchronized native int XpGetAttributes(int display, int print_context, byte type);
+public static final synchronized native void XpSetAttributes(int display, int print_context, byte type, byte [] pool, byte replacement_rule);
+public static final synchronized native int XpGetOneAttribute(int display, int print_context, byte type, byte [] attribute_name);
+public static final synchronized native void XpSetContext(int display, int print_context);
+public static final synchronized native int XpGetScreenOfContext(int display, int print_context);
+public static final synchronized native void XpDestroyContext(int display, int print_context);
+public static final synchronized native int XpGetPageDimensions(int display, int print_context, short [] width, short [] height, XRectangle reproducible_area);
+public static final synchronized native void XpStartJob(int display, byte save_data);
+public static final synchronized native void XpStartPage(int display, int window);
+public static final synchronized native void XpEndPage(int display);
+public static final synchronized native void XpEndJob(int display);
+public static final synchronized native void XpCancelJob(int display, boolean discard);
+public static final synchronized native int XpQueryVersion(int display, short[] major_version, short[] minor_version);
+public static final synchronized native int XDefaultGCOfScreen(int screen);
+public static final synchronized native int XDefaultColormapOfScreen(int screen);
+public static final synchronized native int XRootWindowOfScreen(int screen);
+public static final synchronized native int XScreenNumberOfScreen(int screen);
+public static final synchronized 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 synchronized native void XDestroyWindow(int display, int w);
+public static final native int getenv(byte[] name);
+public static final synchronized native int XOpenDisplay(byte[] display_name);
+public static final synchronized native void XCloseDisplay(int display);
+
+/*
+ * ======== End of printing constants and functions ========
+ */
+
+public static final native int pipe (int [] filedes);
+public static final native int read (int filedes, byte [] buf, int nbyte);
+public static final native int write (int filedes, byte [] buf, int nbyte);
+public static final native int close (int filedes);
+public static final native int select (int n, byte [] readfds, byte [] writefds, byte [] exceptfds, int [] timeout);
+public static final native void FD_ZERO (byte [] fd_set);
+public static final native void FD_SET (int fd, byte [] fd_set);
+public static final native boolean FD_ISSET (int fd, byte [] fd_set);
+//public static final native int FD_SETSIZE ();
+//public static final native int NFDBITS ();
+public static final native int fd_set_sizeof ();
+public static final synchronized native int ConnectionNumber (int display);
+public static final synchronized native int XtAppAddInput (int app_context, int source, int condition, int proc, int client_data);
+public static final synchronized native void XtRemoveInput (int id);
+// public static final int XtInputNoneMask = 0;
+ public static final int XtInputReadMask = 1;
+// public static final int XtInputWriteMask = 2;
+// public static final int XtInputExceptMask = 4;
+
+public static final synchronized native int XLoadQueryFont (int display, byte[] name);
+public static final synchronized native int XmFontListEntryCreate (byte[] tag, int type, int font);
+
+public static final synchronized native int XmImGetXIC (int widget, int input_policy, int[] args, int num_args);
+public static final synchronized native int XmImGetXIM (int widget);
+public static final synchronized native void XmImRegister (int widget, int reserved);
+public static final synchronized native int XmImSetFocusValues (int widget, int[] args, int num_args);
+//public static final synchronized native int XmImVaSetFocusValues(int widget, int arg1, int arg2, int arg3, int arg4, int arg5, int arg6, int arg7, int arg8, int arg9);
+public static final synchronized native int XmImSetValues (int widget, int[] args, int num_args);
+public static final synchronized native void XmImUnregister (int widget);
+public static final synchronized native void XmImUnsetFocus (int widget);
+//public static final synchronized native void XSetICFocus (int ic);
+//public static final synchronized native void XUnsetICFocus (int ic);
+//public static final synchronized native int XCreateIC (int im, int arg1, int arg2, int arg3, int arg4, int arg5, int arg6, int arg7);
+//public static final synchronized native int XSetICValues (int ic, int arg1, int arg2, int arg3);
+//public static final synchronized native int XGetICValues (int ic, int arg1, int arg2, int arg3);
+//public static final synchronized native int XGetIMValues (int im, int arg1, int arg2, int arg3);
+public static final native void memmove (int dest, short [] src, int count);
+//public static final native void memmove (char[] dest, int src, int count);
+//public static final native void memmove ( int dest, char[] src,int count);
+
+public static final native int nl_langinfo (int item);
+public static final native int iconv_open (byte[] tocode, byte[] fromcode);
+public static final native int iconv_close (int cd);
+public static final native int iconv (int cd, int[] inBuf, int[] inBytesLeft, int[] outBuf, int[] outBytesLeft);
+public static final native int MB_CUR_MAX ();
+public static final native int setlocale (int category, byte[] locale);
+static final native int setResourceMem (int start, int end);
+
+public static final synchronized native int XCreateFontSet (int display, byte [] base_font_name_list, int [] missing_charset_list_return, int [] missing_charset_count_return, int [] def_string_return);
+public static final synchronized native int XLocaleOfFontSet (int fontSet);
+public static final synchronized native void XFreeStringList (int list);
+
+public static final synchronized native void XtInsertEventHandler (int w, int event_mask, boolean nonmaskable, int proc, int client_data, int position);
+//public static final synchronized native void XmAddToPostFromList (int menu, int post_from_list);
+//public static final synchronized native void XmRemoveFromPostFromList (int menu, int post_from_list);
+//public static final synchronized native void XmMenuPosition (int menu, int event);
+public static final synchronized native void _XmSetMenuTraversal (int menu, boolean traversal);
+public static final synchronized native int XEventsQueued (int display, int mode);
+public static final native void memmove (int dest, XExposeEvent src, int count);
+public static final synchronized native void XtAppSetFallbackResources (int app_context, int specification_list);
+
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/motif/org/eclipse/swt/internal/motif/Visual.java b/bundles/org.eclipse.swt/Eclipse SWT PI/motif/org/eclipse/swt/internal/motif/Visual.java
index f0330dd6d2..47c0ef6f87 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/motif/org/eclipse/swt/internal/motif/Visual.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/motif/org/eclipse/swt/internal/motif/Visual.java
@@ -1,18 +1,18 @@
-package org.eclipse.swt.internal.motif;
-
-/*
+package org.eclipse.swt.internal.motif;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-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;
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+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 PI/motif/org/eclipse/swt/internal/motif/XAnyEvent.java b/bundles/org.eclipse.swt/Eclipse SWT PI/motif/org/eclipse/swt/internal/motif/XAnyEvent.java
index 95ba3b74ab..eea3470eb8 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/motif/org/eclipse/swt/internal/motif/XAnyEvent.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/motif/org/eclipse/swt/internal/motif/XAnyEvent.java
@@ -1,13 +1,13 @@
-package org.eclipse.swt.internal.motif;
-
-/*
+package org.eclipse.swt.internal.motif;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-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;
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+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 PI/motif/org/eclipse/swt/internal/motif/XButtonEvent.java b/bundles/org.eclipse.swt/Eclipse SWT PI/motif/org/eclipse/swt/internal/motif/XButtonEvent.java
index 8cd13c093a..1474d45388 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/motif/org/eclipse/swt/internal/motif/XButtonEvent.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/motif/org/eclipse/swt/internal/motif/XButtonEvent.java
@@ -1,14 +1,14 @@
-package org.eclipse.swt.internal.motif;
-
-/*
+package org.eclipse.swt.internal.motif;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-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;
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+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 PI/motif/org/eclipse/swt/internal/motif/XCharStruct.java b/bundles/org.eclipse.swt/Eclipse SWT PI/motif/org/eclipse/swt/internal/motif/XCharStruct.java
index 83297d8784..c383e9ae90 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/motif/org/eclipse/swt/internal/motif/XCharStruct.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/motif/org/eclipse/swt/internal/motif/XCharStruct.java
@@ -1,18 +1,18 @@
-package org.eclipse.swt.internal.motif;
-
-/*
+package org.eclipse.swt.internal.motif;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-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;
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+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 PI/motif/org/eclipse/swt/internal/motif/XColor.java b/bundles/org.eclipse.swt/Eclipse SWT PI/motif/org/eclipse/swt/internal/motif/XColor.java
index b1aa1015cb..094aac23e0 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/motif/org/eclipse/swt/internal/motif/XColor.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/motif/org/eclipse/swt/internal/motif/XColor.java
@@ -1,16 +1,16 @@
-package org.eclipse.swt.internal.motif;
-
-/*
+package org.eclipse.swt.internal.motif;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-public class XColor {
- public int pixel;
- public short red, green, blue;
- public byte flags;
- public byte pad;
- public static final int sizeof = 12;
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+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 PI/motif/org/eclipse/swt/internal/motif/XConfigureEvent.java b/bundles/org.eclipse.swt/Eclipse SWT PI/motif/org/eclipse/swt/internal/motif/XConfigureEvent.java
index 33300d0281..138eab8c35 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/motif/org/eclipse/swt/internal/motif/XConfigureEvent.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/motif/org/eclipse/swt/internal/motif/XConfigureEvent.java
@@ -1,18 +1,18 @@
-package org.eclipse.swt.internal.motif;
-
-/*
+package org.eclipse.swt.internal.motif;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-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;
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+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 PI/motif/org/eclipse/swt/internal/motif/XCrossingEvent.java b/bundles/org.eclipse.swt/Eclipse SWT PI/motif/org/eclipse/swt/internal/motif/XCrossingEvent.java
index 19d03dbbfc..24b5ace12c 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/motif/org/eclipse/swt/internal/motif/XCrossingEvent.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/motif/org/eclipse/swt/internal/motif/XCrossingEvent.java
@@ -1,21 +1,21 @@
-package org.eclipse.swt.internal.motif;
-
-/*
+package org.eclipse.swt.internal.motif;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-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;
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+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 PI/motif/org/eclipse/swt/internal/motif/XEvent.java b/bundles/org.eclipse.swt/Eclipse SWT PI/motif/org/eclipse/swt/internal/motif/XEvent.java
index 36ca27f291..4344f06b60 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/motif/org/eclipse/swt/internal/motif/XEvent.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/motif/org/eclipse/swt/internal/motif/XEvent.java
@@ -1,17 +1,17 @@
-package org.eclipse.swt.internal.motif;
-
-/*
+package org.eclipse.swt.internal.motif;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-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;
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+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 PI/motif/org/eclipse/swt/internal/motif/XExposeEvent.java b/bundles/org.eclipse.swt/Eclipse SWT PI/motif/org/eclipse/swt/internal/motif/XExposeEvent.java
index 4ed86fdd83..0066c3f798 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/motif/org/eclipse/swt/internal/motif/XExposeEvent.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/motif/org/eclipse/swt/internal/motif/XExposeEvent.java
@@ -1,16 +1,16 @@
-package org.eclipse.swt.internal.motif;
-
-/*
+package org.eclipse.swt.internal.motif;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-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;
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+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 PI/motif/org/eclipse/swt/internal/motif/XFocusChangeEvent.java b/bundles/org.eclipse.swt/Eclipse SWT PI/motif/org/eclipse/swt/internal/motif/XFocusChangeEvent.java
index 551b03460a..2554c25e71 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/motif/org/eclipse/swt/internal/motif/XFocusChangeEvent.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/motif/org/eclipse/swt/internal/motif/XFocusChangeEvent.java
@@ -1,20 +1,20 @@
-package org.eclipse.swt.internal.motif;
-
-/*
+package org.eclipse.swt.internal.motif;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-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;
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+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 PI/motif/org/eclipse/swt/internal/motif/XFontStruct.java b/bundles/org.eclipse.swt/Eclipse SWT PI/motif/org/eclipse/swt/internal/motif/XFontStruct.java
index e4615cfde4..72aa227182 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/motif/org/eclipse/swt/internal/motif/XFontStruct.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/motif/org/eclipse/swt/internal/motif/XFontStruct.java
@@ -1,38 +1,38 @@
-package org.eclipse.swt.internal.motif;
-
-/*
+package org.eclipse.swt.internal.motif;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-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;
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+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 PI/motif/org/eclipse/swt/internal/motif/XGCValues.java b/bundles/org.eclipse.swt/Eclipse SWT PI/motif/org/eclipse/swt/internal/motif/XGCValues.java
index e5d7ea7551..86439fc944 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/motif/org/eclipse/swt/internal/motif/XGCValues.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/motif/org/eclipse/swt/internal/motif/XGCValues.java
@@ -1,35 +1,35 @@
-package org.eclipse.swt.internal.motif;
-
-/*
+package org.eclipse.swt.internal.motif;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-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;
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+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 PI/motif/org/eclipse/swt/internal/motif/XImage.java b/bundles/org.eclipse.swt/Eclipse SWT PI/motif/org/eclipse/swt/internal/motif/XImage.java
index c1c9919d02..ca65db4094 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/motif/org/eclipse/swt/internal/motif/XImage.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/motif/org/eclipse/swt/internal/motif/XImage.java
@@ -1,27 +1,27 @@
-package org.eclipse.swt.internal.motif;
-
-/*
+package org.eclipse.swt.internal.motif;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-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;
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+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 PI/motif/org/eclipse/swt/internal/motif/XInputEvent.java b/bundles/org.eclipse.swt/Eclipse SWT PI/motif/org/eclipse/swt/internal/motif/XInputEvent.java
index 3176188329..07e72c9fb5 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/motif/org/eclipse/swt/internal/motif/XInputEvent.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/motif/org/eclipse/swt/internal/motif/XInputEvent.java
@@ -1,12 +1,12 @@
-package org.eclipse.swt.internal.motif;
-
-/*
+package org.eclipse.swt.internal.motif;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-public abstract class XInputEvent extends XWindowEvent {
- public int state; /* key or button mask */
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+public abstract class XInputEvent extends XWindowEvent {
+ public int state; /* key or button mask */
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/motif/org/eclipse/swt/internal/motif/XKeyEvent.java b/bundles/org.eclipse.swt/Eclipse SWT PI/motif/org/eclipse/swt/internal/motif/XKeyEvent.java
index f7adc0faf3..37ec17c353 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/motif/org/eclipse/swt/internal/motif/XKeyEvent.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/motif/org/eclipse/swt/internal/motif/XKeyEvent.java
@@ -1,14 +1,14 @@
-package org.eclipse.swt.internal.motif;
-
-/*
+package org.eclipse.swt.internal.motif;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-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;
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+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 PI/motif/org/eclipse/swt/internal/motif/XMotionEvent.java b/bundles/org.eclipse.swt/Eclipse SWT PI/motif/org/eclipse/swt/internal/motif/XMotionEvent.java
index 41e5c1d26f..1b4bebd493 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/motif/org/eclipse/swt/internal/motif/XMotionEvent.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/motif/org/eclipse/swt/internal/motif/XMotionEvent.java
@@ -1,14 +1,14 @@
-package org.eclipse.swt.internal.motif;
-
-/*
+package org.eclipse.swt.internal.motif;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-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;
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+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 PI/motif/org/eclipse/swt/internal/motif/XRectangle.java b/bundles/org.eclipse.swt/Eclipse SWT PI/motif/org/eclipse/swt/internal/motif/XRectangle.java
index c5beb4e3ec..152d300619 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/motif/org/eclipse/swt/internal/motif/XRectangle.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/motif/org/eclipse/swt/internal/motif/XRectangle.java
@@ -1,16 +1,16 @@
-package org.eclipse.swt.internal.motif;
-
-/*
+package org.eclipse.swt.internal.motif;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-public class XRectangle {
- public short x, y, width, height;
- public static final int sizeof = 8;
-public String toString () {
- return "XRectangle {" + x + ", " + y + ", " + width + ", " + height + "}";
-}
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+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 PI/motif/org/eclipse/swt/internal/motif/XSetWindowAttributes.java b/bundles/org.eclipse.swt/Eclipse SWT PI/motif/org/eclipse/swt/internal/motif/XSetWindowAttributes.java
index 29661cf806..a9a23f0ce6 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/motif/org/eclipse/swt/internal/motif/XSetWindowAttributes.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/motif/org/eclipse/swt/internal/motif/XSetWindowAttributes.java
@@ -1,27 +1,27 @@
-package org.eclipse.swt.internal.motif;
-
-/*
+package org.eclipse.swt.internal.motif;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-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;
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+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 PI/motif/org/eclipse/swt/internal/motif/XWindowAttributes.java b/bundles/org.eclipse.swt/Eclipse SWT PI/motif/org/eclipse/swt/internal/motif/XWindowAttributes.java
index 839298f6fb..778b99714b 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/motif/org/eclipse/swt/internal/motif/XWindowAttributes.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/motif/org/eclipse/swt/internal/motif/XWindowAttributes.java
@@ -1,33 +1,33 @@
-package org.eclipse.swt.internal.motif;
-
-/*
+package org.eclipse.swt.internal.motif;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-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;
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+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 PI/motif/org/eclipse/swt/internal/motif/XWindowChanges.java b/bundles/org.eclipse.swt/Eclipse SWT PI/motif/org/eclipse/swt/internal/motif/XWindowChanges.java
index 9802c04786..570e395637 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/motif/org/eclipse/swt/internal/motif/XWindowChanges.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/motif/org/eclipse/swt/internal/motif/XWindowChanges.java
@@ -1,17 +1,17 @@
-package org.eclipse.swt.internal.motif;
-
-/*
+package org.eclipse.swt.internal.motif;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-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;
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+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 PI/motif/org/eclipse/swt/internal/motif/XWindowEvent.java b/bundles/org.eclipse.swt/Eclipse SWT PI/motif/org/eclipse/swt/internal/motif/XWindowEvent.java
index 028aa4fffb..48c7bbd690 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/motif/org/eclipse/swt/internal/motif/XWindowEvent.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/motif/org/eclipse/swt/internal/motif/XWindowEvent.java
@@ -1,16 +1,16 @@
-package org.eclipse.swt.internal.motif;
-
-/*
+package org.eclipse.swt.internal.motif;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-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 */
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+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 PI/motif/org/eclipse/swt/internal/motif/XmAnyCallbackStruct.java b/bundles/org.eclipse.swt/Eclipse SWT PI/motif/org/eclipse/swt/internal/motif/XmAnyCallbackStruct.java
index 200145dbba..14cd5120a5 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/motif/org/eclipse/swt/internal/motif/XmAnyCallbackStruct.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/motif/org/eclipse/swt/internal/motif/XmAnyCallbackStruct.java
@@ -1,14 +1,14 @@
-package org.eclipse.swt.internal.motif;
-
-/*
+package org.eclipse.swt.internal.motif;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-public class XmAnyCallbackStruct {
- public int reason; // 0
- public int event; // 4
- public static final int sizeof = 8;
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+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 PI/motif/org/eclipse/swt/internal/motif/XmDragProcCallback.java b/bundles/org.eclipse.swt/Eclipse SWT PI/motif/org/eclipse/swt/internal/motif/XmDragProcCallback.java
index 9b4c8ee450..4301cbff59 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/motif/org/eclipse/swt/internal/motif/XmDragProcCallback.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/motif/org/eclipse/swt/internal/motif/XmDragProcCallback.java
@@ -1,23 +1,23 @@
-package org.eclipse.swt.internal.motif;
-
-/*
+package org.eclipse.swt.internal.motif;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-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;
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+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 PI/motif/org/eclipse/swt/internal/motif/XmDropFinishCallback.java b/bundles/org.eclipse.swt/Eclipse SWT PI/motif/org/eclipse/swt/internal/motif/XmDropFinishCallback.java
index 2c06ada8c3..d65beced5e 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/motif/org/eclipse/swt/internal/motif/XmDropFinishCallback.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/motif/org/eclipse/swt/internal/motif/XmDropFinishCallback.java
@@ -1,21 +1,21 @@
-package org.eclipse.swt.internal.motif;
-
-/*
+package org.eclipse.swt.internal.motif;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-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;
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+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 PI/motif/org/eclipse/swt/internal/motif/XmDropProcCallback.java b/bundles/org.eclipse.swt/Eclipse SWT PI/motif/org/eclipse/swt/internal/motif/XmDropProcCallback.java
index b683a617c1..a618355aa0 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/motif/org/eclipse/swt/internal/motif/XmDropProcCallback.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/motif/org/eclipse/swt/internal/motif/XmDropProcCallback.java
@@ -1,23 +1,23 @@
-package org.eclipse.swt.internal.motif;
-
-/*
+package org.eclipse.swt.internal.motif;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-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;
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+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 PI/motif/org/eclipse/swt/internal/motif/XmTextBlockRec.java b/bundles/org.eclipse.swt/Eclipse SWT PI/motif/org/eclipse/swt/internal/motif/XmTextBlockRec.java
index e44f1ff748..0432d1fa36 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/motif/org/eclipse/swt/internal/motif/XmTextBlockRec.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/motif/org/eclipse/swt/internal/motif/XmTextBlockRec.java
@@ -1,15 +1,15 @@
-package org.eclipse.swt.internal.motif;
-
-/*
+package org.eclipse.swt.internal.motif;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-public class XmTextBlockRec {
- public int ptr; // 0
- public int length; // 4
- public int format; // 8
- public static final int sizeof = 12;
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+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 PI/motif/org/eclipse/swt/internal/motif/XmTextVerifyCallbackStruct.java b/bundles/org.eclipse.swt/Eclipse SWT PI/motif/org/eclipse/swt/internal/motif/XmTextVerifyCallbackStruct.java
index ca5cb322ea..e0e2ba57ab 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/motif/org/eclipse/swt/internal/motif/XmTextVerifyCallbackStruct.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/motif/org/eclipse/swt/internal/motif/XmTextVerifyCallbackStruct.java
@@ -1,18 +1,18 @@
-package org.eclipse.swt.internal.motif;
-
-/*
+package org.eclipse.swt.internal.motif;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-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;
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+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 PI/motif/org/eclipse/swt/internal/motif/XtWidgetGeometry.java b/bundles/org.eclipse.swt/Eclipse SWT PI/motif/org/eclipse/swt/internal/motif/XtWidgetGeometry.java
index e9551e5f0b..65906d9e33 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/motif/org/eclipse/swt/internal/motif/XtWidgetGeometry.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/motif/org/eclipse/swt/internal/motif/XtWidgetGeometry.java
@@ -1,17 +1,17 @@
-package org.eclipse.swt.internal.motif;
-
-/*
+package org.eclipse.swt.internal.motif;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-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;
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+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 PI/photon/library/swt.c b/bundles/org.eclipse.swt/Eclipse SWT PI/photon/library/swt.c
index 8f5c028ebf..1817aaf945 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/photon/library/swt.c
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/photon/library/swt.c
@@ -6369,13 +6369,13 @@ JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_photon_OS_PgGetVideoModeInf
return result;
}
-/*
- * Class: org_eclipse_swt_internal_photon_OS
- * Method: PhClipboardCopy
- * Signature: (SI[B)I
+/*
+ * Class: org_eclipse_swt_internal_photon_OS
+ * Method: PhClipboardCopy
+ * Signature: (SI[B)I
*/
-JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_photon_OS_PhClipboardCopy
- (JNIEnv *env, jclass that, jshort ig, jint n, jbyteArray clip)
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_photon_OS_PhClipboardCopy
+ (JNIEnv *env, jclass that, jshort ig, jint n, jbyteArray clip)
{
jbyte *clip1;
jint result;
@@ -6396,134 +6396,134 @@ JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_photon_OS_PhClipboardCopy
return result;
}
-
-/*
- * Class: org_eclipse_swt_internal_photon_OS
- * Method: PhClipboardPasteStart
- * Signature: (S)I
- */
-JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_photon_OS_PhClipboardPasteStart
- (JNIEnv *env, jobject that, jshort ig)
-{
-#ifdef DEBUG_CALL_PRINTS
- fprintf(stderr, "PhClipboardPasteStart\n");
-#endif
-
- return (jint) PhClipboardPasteStart(ig);
-}
-
-/*
- * Class: org_eclipse_swt_internal_photon_OS
- * Method: PhClipboardPasteType
- * Signature: (I[B)I
- */
-JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_photon_OS_PhClipboardPasteType
- (JNIEnv *env, jobject that, jint cbdata, jbyteArray type)
-{
- char *type1=NULL;
- jint result;
-
-#ifdef DEBUG_CALL_PRINTS
- fprintf(stderr, "PhClipboardPasteType\n");
-#endif
-
- if (type)
- type1 = (char *)(*env)->GetByteArrayElements(env, type, NULL);
-
- result = (jint) PhClipboardPasteType((void *)cbdata, type1);
-
- if (type)
- (*env)->ReleaseByteArrayElements(env, type, (jbyte *)type1, 0);
-
- return result;
-}
-
-/*
- * Class: org_eclipse_swt_internal_photon_OS
- * Method: PhClipboardPasteTypeN
- * Signature: (II)I
- */
-JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_photon_OS_PhClipboardPasteTypeN
- (JNIEnv *env, jobject that, jint cbdata, jint n)
-{
-
-#ifdef DEBUG_CALL_PRINTS
- fprintf(stderr, "PhClipboardPasteTypeN\n");
-#endif
- return (jint) PhClipboardPasteTypeN((void *)cbdata, n);
-}
-
-/*
- * Class: org_eclipse_swt_internal_photon_OS
- * Method: PhClipboardPasteFinish
- * Signature: (I)V
- */
-JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_photon_OS_PhClipboardPasteFinish
- (JNIEnv *env, jobject that, jint cbdata)
-{
-#ifdef DEBUG_CALL_PRINTS
- fprintf(stderr, "PhClipboardPasteFinish\n");
-#endif
-
- PhClipboardPasteFinish((void *)cbdata);
-
- return;
-}
-
-/*
- * Class: org_eclipse_swt_internal_photon_OS
- * Method: memmove
- * Signature: (Lorg/eclipse/swt/internal/photon/PhClipHeader;II)V
- */
-JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_photon_OS_memmove__Lorg_eclipse_swt_internal_photon_PhClipHeader_2II
- (JNIEnv *env, jobject that, jobject dest, jint src, jint count)
-{
- DECL_GLOB(pGlob)
- PhClipHeader object, *dest1=NULL;
-#ifdef DEBUG_CALL_PRINTS
- fprintf(stderr, "memmove__Lorg_eclipse_swt_internal_photon_PhClipHeader_2II\n");
-#endif
-
- memmove((void *)&object, (void *)src, count);
- if (dest) {
- dest1=&object;
- cachePhClipHeaderFids(env, dest, &PGLOB(PhClipHeaderFc));
- setPhClipHeaderFields(env, dest, dest1, &PGLOB(PhClipHeaderFc));
- }
-
-}
-
-/*
- * Class: org_eclipse_swt_internal_photon_OS
- * Method: memmove
- * Signature: ([BLorg/eclipse/swt/internal/photon/PhClipHeader;I)V
- */
-JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_photon_OS_memmove___3BLorg_eclipse_swt_internal_photon_PhClipHeader_2I
- (JNIEnv *env, jobject that, jbyteArray dest, jobject src, jint count)
-{
- DECL_GLOB(pGlob)
- jbyte *dest1=NULL;
- PhClipHeader object, *src1= NULL;
-
-#ifdef DEBUG_CALL_PRINTS
- fprintf(stderr, "memmove___3BLorg_eclipse_swt_internal_photon_PhClipHeader_2I\n");
-#endif
-
- if (src) {
- src1=&object;
- cachePhClipHeaderFids(env, src, &PGLOB(PhClipHeaderFc));
- getPhClipHeaderFields(env, src, src1, &PGLOB(PhClipHeaderFc));
- }
-
- if (dest) {
- dest1 = (*env)->GetByteArrayElements(env, dest, NULL);
- }
-
- memmove((void *)dest1, (void *)src1, count);
-
- if (dest) {
- (*env)->ReleaseByteArrayElements(env, dest, (jbyte *)dest1, 0);
- }
+
+/*
+ * Class: org_eclipse_swt_internal_photon_OS
+ * Method: PhClipboardPasteStart
+ * Signature: (S)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_photon_OS_PhClipboardPasteStart
+ (JNIEnv *env, jobject that, jshort ig)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "PhClipboardPasteStart\n");
+#endif
+
+ return (jint) PhClipboardPasteStart(ig);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_photon_OS
+ * Method: PhClipboardPasteType
+ * Signature: (I[B)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_photon_OS_PhClipboardPasteType
+ (JNIEnv *env, jobject that, jint cbdata, jbyteArray type)
+{
+ char *type1=NULL;
+ jint result;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "PhClipboardPasteType\n");
+#endif
+
+ if (type)
+ type1 = (char *)(*env)->GetByteArrayElements(env, type, NULL);
+
+ result = (jint) PhClipboardPasteType((void *)cbdata, type1);
+
+ if (type)
+ (*env)->ReleaseByteArrayElements(env, type, (jbyte *)type1, 0);
+
+ return result;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_photon_OS
+ * Method: PhClipboardPasteTypeN
+ * Signature: (II)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_photon_OS_PhClipboardPasteTypeN
+ (JNIEnv *env, jobject that, jint cbdata, jint n)
+{
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "PhClipboardPasteTypeN\n");
+#endif
+ return (jint) PhClipboardPasteTypeN((void *)cbdata, n);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_photon_OS
+ * Method: PhClipboardPasteFinish
+ * Signature: (I)V
+ */
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_photon_OS_PhClipboardPasteFinish
+ (JNIEnv *env, jobject that, jint cbdata)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "PhClipboardPasteFinish\n");
+#endif
+
+ PhClipboardPasteFinish((void *)cbdata);
+
+ return;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_photon_OS
+ * Method: memmove
+ * Signature: (Lorg/eclipse/swt/internal/photon/PhClipHeader;II)V
+ */
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_photon_OS_memmove__Lorg_eclipse_swt_internal_photon_PhClipHeader_2II
+ (JNIEnv *env, jobject that, jobject dest, jint src, jint count)
+{
+ DECL_GLOB(pGlob)
+ PhClipHeader object, *dest1=NULL;
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "memmove__Lorg_eclipse_swt_internal_photon_PhClipHeader_2II\n");
+#endif
+
+ memmove((void *)&object, (void *)src, count);
+ if (dest) {
+ dest1=&object;
+ cachePhClipHeaderFids(env, dest, &PGLOB(PhClipHeaderFc));
+ setPhClipHeaderFields(env, dest, dest1, &PGLOB(PhClipHeaderFc));
+ }
+
+}
+
+/*
+ * Class: org_eclipse_swt_internal_photon_OS
+ * Method: memmove
+ * Signature: ([BLorg/eclipse/swt/internal/photon/PhClipHeader;I)V
+ */
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_photon_OS_memmove___3BLorg_eclipse_swt_internal_photon_PhClipHeader_2I
+ (JNIEnv *env, jobject that, jbyteArray dest, jobject src, jint count)
+{
+ DECL_GLOB(pGlob)
+ jbyte *dest1=NULL;
+ PhClipHeader object, *src1= NULL;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "memmove___3BLorg_eclipse_swt_internal_photon_PhClipHeader_2I\n");
+#endif
+
+ if (src) {
+ src1=&object;
+ cachePhClipHeaderFids(env, src, &PGLOB(PhClipHeaderFc));
+ getPhClipHeaderFields(env, src, src1, &PGLOB(PhClipHeaderFc));
+ }
+
+ if (dest) {
+ dest1 = (*env)->GetByteArrayElements(env, dest, NULL);
+ }
+
+ memmove((void *)dest1, (void *)src1, count);
+
+ if (dest) {
+ (*env)->ReleaseByteArrayElements(env, dest, (jbyte *)dest1, 0);
+ }
}
/*
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/photon/org/eclipse/swt/internal/photon/FontDetails.java b/bundles/org.eclipse.swt/Eclipse SWT PI/photon/org/eclipse/swt/internal/photon/FontDetails.java
index 6040c16cda..561bbccd06 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/photon/org/eclipse/swt/internal/photon/FontDetails.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/photon/org/eclipse/swt/internal/photon/FontDetails.java
@@ -1,17 +1,17 @@
-package org.eclipse.swt.internal.photon;
-
-/*
+package org.eclipse.swt.internal.photon;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-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;
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+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 PI/photon/org/eclipse/swt/internal/photon/FontQueryInfo.java b/bundles/org.eclipse.swt/Eclipse SWT PI/photon/org/eclipse/swt/internal/photon/FontQueryInfo.java
index fcdda64529..f99bf1cc38 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/photon/org/eclipse/swt/internal/photon/FontQueryInfo.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/photon/org/eclipse/swt/internal/photon/FontQueryInfo.java
@@ -1,21 +1,21 @@
-package org.eclipse.swt.internal.photon;
-
-/*
+package org.eclipse.swt.internal.photon;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-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;
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+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 PI/photon/org/eclipse/swt/internal/photon/OS.java b/bundles/org.eclipse.swt/Eclipse SWT PI/photon/org/eclipse/swt/internal/photon/OS.java
index 1e5fc36bb5..f113569a83 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/photon/org/eclipse/swt/internal/photon/OS.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/photon/org/eclipse/swt/internal/photon/OS.java
@@ -1,2981 +1,2981 @@
-package org.eclipse.swt.internal.photon;
-
-/*
+package org.eclipse.swt.internal.photon;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-import org.eclipse.swt.internal.*;
-
-public class OS {
-
- /* Load the SWT library. */
- static {
- Library.loadLibrary ("swt");
- }
-
-/**** 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_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 Pg_GRAD_BYTES_PER_PIXEL = 3;
-// public static final int Pg_GRAD_IMAGE_TYPE = Pg_IMAGE_DIRECT_888;
-// public static final int Pg_GRAD_BOXY = 0x80000000;
-// public static final int Pg_GRAD_NOGRADIENT = 0;
-// public static final int Pg_GRAD_VECTOR = 1;
-// public static final int Pg_GRAD_RADIAL = 2;
- public static final int Pg_GRAD_HORIZONTAL = 3;
- public static final int Pg_GRAD_VERTICAL = 4;
-// public static final int Pg_GRAD_FAST_VECTOR = 5;
-// public static final int Pg_GRAD_DIAGF = 6;
-// public static final int Pg_GRAD_DIAGB = 7;
-// public static final int Pg_GRAD_4POINT = 8;
-// public static final int Pg_GRAD_BOX_DIAGF = Pg_GRAD_DIAGF | Pg_GRAD_BOXY;
-// public static final int Pg_GRAD_BOX_DIAGB = Pg_GRAD_DIAGB | Pg_GRAD_BOXY;
-// public static final int Pg_GRAD_BOX_4POINT = Pg_GRAD_4POINT | Pg_GRAD_BOXY;
-// public static final int Pg_GRAD_TABLE = 100;
- public static final int Pg_GRAD_LINEAR = 0;
-// public static final int Pg_GRAD_HILL = 1;
-// public static final int Pg_GRAD_HILL2 = 2;
-// public static final int Pg_GRAD_EXP = 3;
-
-// 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 PHFONT_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_DRAGGABLE = 0x0001;
- public static final int Pt_TOOLBAR_ITEM_SEPARATORS = 0x0020;
- public static final int Pt_TOOLBAR_END_SEPARATOR = 0x0040;
-
- 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 );
-
- public static final int Pt_ALL_BUTTONS = 0x00800000;
- public static final int Pt_MENUABLE = 0x08000000;
-
- public static final int Ph_CONSUMED = 0x0004;
-
- public static final int Pt_ARG_MODIFIER_KEYS = ( 7 * 1000 + 4 );
-
- public static final byte [] Pg_PAT_HALF = {(byte)0xAA, (byte)0x55, (byte)0xAA, (byte)0x55, (byte)0xAA, (byte)0x55, (byte)0xAA, (byte)0x55};
-
- public static final int Pt_ARG_BEVEL_CONTRAST = ( 2 * 1000 + 20 );
-
- public static final int Pt_NO_PARENT = 1;
-
- public static final int Pt_CB_TREE_STATE = ( 23 * 1000 + 21 );
- public static final int Pt_CB_TREE_SELECTION = ( 23 * 1000 + 22 );
- public static final int Pt_TREE_COLLAPSING = 0;
- public static final int Pt_TREE_EXPANDING = 1;
- public static final int Pt_HOTKEYS_FIRST = 0x00000080;
-/*** 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_CONSOLE = 0x0000;
-//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_QUERY_WORKSPACE = 0x0002;
-//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_OUTBOUND = ( 1 * 1000 + 22 );
-//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_INDETERMINATE = 0x80;
-//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 PhRect_t PfExtentText(PhRect_t extent, PhPoint_t pos, byte[] font, byte[] 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 PfDecomposeStemToID(byte [] pkszStem);
-
-public static final native PhRect_t PgExtentMultiText(PhRect_t extent, PhPoint_t pos, byte[] font, byte[] str, int n, int linespacing);
-
-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 PgDrawGradient (PhPoint_t ul, PhPoint_t lr, int gradient_type, int transition_type, int num_color_pts, int color1, int color2, int color3, int color4, int table_size, byte[] transition_table);
-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 PgDrawMultiTextArea (byte[] text, int len, PhRect_t canvas, int text_flags, int canvas_flags, int linespacing);
-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 PhEventNext (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 PhSortTiles (int 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 PtSetResource (int widget, int type, int value, int length);
-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 PtWidgetFlags (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 PtContainerFocusNext (int widget, PhEvent_t event);
-public static final native int PtContainerFocusPrev (int widget, PhEvent_t event);
-public static final native int PtGlobalFocusNext (int widget, PhEvent_t event);
-public static final native int PtGlobalFocusPrev (int widget, PhEvent_t event);
-public static final native int PtGlobalFocusNextContainer (int widget, PhEvent_t event);
-public static final native int PtGlobalFocusPrevContainer (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 strdup (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 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, PhPointerEvent_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 void memmove (int address, PhEvent_t event, 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 PtFindGuardian( int widget, int superior_only );
-
-public static final native int PtBlockAllWindows(int skip, short cursor, int cursor_color);
-public static final native int PtBlockWindow(int window, 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 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);
-
-public static final native void memmove (PtContainerCallback_t dest, int src, int size);
-//public static final native void memmove (int dest, PtContainerCallback_t src, int size);
-
-public static final native void PtSendEventToWidget (int widget, int event);
-
-//public static final native void memmove (PhCursorDef_t dest, int src, int size);
-public static final native void memmove (int dest, PhCursorDef_t src, int size);
-
-public static final native void PgSetFillTransPat (byte [] pat);
-
-public static final native int PtInflateBalloon (int win, int me, int position, byte [] string, byte [] font, int fill, int text_color);
-
-//public static final native void memmove (PgDisplaySettings_t dest, int src, int size);
-//public static final native void memmove (int dest, PgDisplaySettings_t src, int size);
-
-//public static final native void memmove (PgVideoModeInfo_t dest, int src, int size);
-//public static final native void memmove (int dest, PgVideoModeInfo_t src, int size);
-
-public static final native int PgGetVideoMode (PgDisplaySettings_t settings);
-public static final native int PgGetVideoModeInfo (short mode_number, PgVideoModeInfo_t mode_info);
-
-public static final native void memmove (PhClipHeader dest, int src, int size);
-public static final native void memmove (int dest, PhClipHeader src, int size);
-public static final native void memmove (byte[] dest, PhClipHeader src, int size);
-
-public static final native int PhClipboardCopyString (short ig, byte [] string);
-public static final native int PhClipboardPasteString (short ig);
-public static final native int PhClipboardCopy (short ig, int n, byte[] clip);
-public static final native int PhClipboardPasteStart (short ig);
-public static final native int PhClipboardPasteType (int cbdata, byte[] type);
-public static final native int PhClipboardPasteTypeN (int cbdata, int n);
-public static final native void PhClipboardPasteFinish (int cbdata);
-public static final native int PtHold ();
-public static final native int PtRelease ();
-
-public static final native void PhMoveCursorAbs (int input_group, int x, int y );
-public static final native int getenv(byte[] name);
-public static final native int PhDCSetCurrent(int draw_context);
-public static final native int PfLoadMetrics(byte[] font);
-
-public static final native String NewStringUTF(byte[] buffer);
-public static final native int GetStringUTFLength(String string);
-public static final native void GetStringUTFRegion(String string, int start, int len, byte[] buffer);
-
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+import org.eclipse.swt.internal.*;
+
+public class OS {
+
+ /* Load the SWT library. */
+ static {
+ Library.loadLibrary ("swt");
+ }
+
+/**** 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_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 Pg_GRAD_BYTES_PER_PIXEL = 3;
+// public static final int Pg_GRAD_IMAGE_TYPE = Pg_IMAGE_DIRECT_888;
+// public static final int Pg_GRAD_BOXY = 0x80000000;
+// public static final int Pg_GRAD_NOGRADIENT = 0;
+// public static final int Pg_GRAD_VECTOR = 1;
+// public static final int Pg_GRAD_RADIAL = 2;
+ public static final int Pg_GRAD_HORIZONTAL = 3;
+ public static final int Pg_GRAD_VERTICAL = 4;
+// public static final int Pg_GRAD_FAST_VECTOR = 5;
+// public static final int Pg_GRAD_DIAGF = 6;
+// public static final int Pg_GRAD_DIAGB = 7;
+// public static final int Pg_GRAD_4POINT = 8;
+// public static final int Pg_GRAD_BOX_DIAGF = Pg_GRAD_DIAGF | Pg_GRAD_BOXY;
+// public static final int Pg_GRAD_BOX_DIAGB = Pg_GRAD_DIAGB | Pg_GRAD_BOXY;
+// public static final int Pg_GRAD_BOX_4POINT = Pg_GRAD_4POINT | Pg_GRAD_BOXY;
+// public static final int Pg_GRAD_TABLE = 100;
+ public static final int Pg_GRAD_LINEAR = 0;
+// public static final int Pg_GRAD_HILL = 1;
+// public static final int Pg_GRAD_HILL2 = 2;
+// public static final int Pg_GRAD_EXP = 3;
+
+// 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 PHFONT_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_DRAGGABLE = 0x0001;
+ public static final int Pt_TOOLBAR_ITEM_SEPARATORS = 0x0020;
+ public static final int Pt_TOOLBAR_END_SEPARATOR = 0x0040;
+
+ 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 );
+
+ public static final int Pt_ALL_BUTTONS = 0x00800000;
+ public static final int Pt_MENUABLE = 0x08000000;
+
+ public static final int Ph_CONSUMED = 0x0004;
+
+ public static final int Pt_ARG_MODIFIER_KEYS = ( 7 * 1000 + 4 );
+
+ public static final byte [] Pg_PAT_HALF = {(byte)0xAA, (byte)0x55, (byte)0xAA, (byte)0x55, (byte)0xAA, (byte)0x55, (byte)0xAA, (byte)0x55};
+
+ public static final int Pt_ARG_BEVEL_CONTRAST = ( 2 * 1000 + 20 );
+
+ public static final int Pt_NO_PARENT = 1;
+
+ public static final int Pt_CB_TREE_STATE = ( 23 * 1000 + 21 );
+ public static final int Pt_CB_TREE_SELECTION = ( 23 * 1000 + 22 );
+ public static final int Pt_TREE_COLLAPSING = 0;
+ public static final int Pt_TREE_EXPANDING = 1;
+ public static final int Pt_HOTKEYS_FIRST = 0x00000080;
+/*** 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_CONSOLE = 0x0000;
+//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_QUERY_WORKSPACE = 0x0002;
+//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_OUTBOUND = ( 1 * 1000 + 22 );
+//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_INDETERMINATE = 0x80;
+//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 PhRect_t PfExtentText(PhRect_t extent, PhPoint_t pos, byte[] font, byte[] 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 PfDecomposeStemToID(byte [] pkszStem);
+
+public static final native PhRect_t PgExtentMultiText(PhRect_t extent, PhPoint_t pos, byte[] font, byte[] str, int n, int linespacing);
+
+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 PgDrawGradient (PhPoint_t ul, PhPoint_t lr, int gradient_type, int transition_type, int num_color_pts, int color1, int color2, int color3, int color4, int table_size, byte[] transition_table);
+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 PgDrawMultiTextArea (byte[] text, int len, PhRect_t canvas, int text_flags, int canvas_flags, int linespacing);
+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 PhEventNext (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 PhSortTiles (int 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 PtSetResource (int widget, int type, int value, int length);
+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 PtWidgetFlags (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 PtContainerFocusNext (int widget, PhEvent_t event);
+public static final native int PtContainerFocusPrev (int widget, PhEvent_t event);
+public static final native int PtGlobalFocusNext (int widget, PhEvent_t event);
+public static final native int PtGlobalFocusPrev (int widget, PhEvent_t event);
+public static final native int PtGlobalFocusNextContainer (int widget, PhEvent_t event);
+public static final native int PtGlobalFocusPrevContainer (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 strdup (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 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, PhPointerEvent_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 void memmove (int address, PhEvent_t event, 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 PtFindGuardian( int widget, int superior_only );
+
+public static final native int PtBlockAllWindows(int skip, short cursor, int cursor_color);
+public static final native int PtBlockWindow(int window, 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 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);
+
+public static final native void memmove (PtContainerCallback_t dest, int src, int size);
+//public static final native void memmove (int dest, PtContainerCallback_t src, int size);
+
+public static final native void PtSendEventToWidget (int widget, int event);
+
+//public static final native void memmove (PhCursorDef_t dest, int src, int size);
+public static final native void memmove (int dest, PhCursorDef_t src, int size);
+
+public static final native void PgSetFillTransPat (byte [] pat);
+
+public static final native int PtInflateBalloon (int win, int me, int position, byte [] string, byte [] font, int fill, int text_color);
+
+//public static final native void memmove (PgDisplaySettings_t dest, int src, int size);
+//public static final native void memmove (int dest, PgDisplaySettings_t src, int size);
+
+//public static final native void memmove (PgVideoModeInfo_t dest, int src, int size);
+//public static final native void memmove (int dest, PgVideoModeInfo_t src, int size);
+
+public static final native int PgGetVideoMode (PgDisplaySettings_t settings);
+public static final native int PgGetVideoModeInfo (short mode_number, PgVideoModeInfo_t mode_info);
+
+public static final native void memmove (PhClipHeader dest, int src, int size);
+public static final native void memmove (int dest, PhClipHeader src, int size);
+public static final native void memmove (byte[] dest, PhClipHeader src, int size);
+
+public static final native int PhClipboardCopyString (short ig, byte [] string);
+public static final native int PhClipboardPasteString (short ig);
+public static final native int PhClipboardCopy (short ig, int n, byte[] clip);
+public static final native int PhClipboardPasteStart (short ig);
+public static final native int PhClipboardPasteType (int cbdata, byte[] type);
+public static final native int PhClipboardPasteTypeN (int cbdata, int n);
+public static final native void PhClipboardPasteFinish (int cbdata);
+public static final native int PtHold ();
+public static final native int PtRelease ();
+
+public static final native void PhMoveCursorAbs (int input_group, int x, int y );
+public static final native int getenv(byte[] name);
+public static final native int PhDCSetCurrent(int draw_context);
+public static final native int PfLoadMetrics(byte[] font);
+
+public static final native String NewStringUTF(byte[] buffer);
+public static final native int GetStringUTFLength(String string);
+public static final native void GetStringUTFRegion(String string, int start, int len, byte[] buffer);
+
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/photon/org/eclipse/swt/internal/photon/PgAlpha_t.java b/bundles/org.eclipse.swt/Eclipse SWT PI/photon/org/eclipse/swt/internal/photon/PgAlpha_t.java
index b787e575f8..dc38c417fc 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/photon/org/eclipse/swt/internal/photon/PgAlpha_t.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/photon/org/eclipse/swt/internal/photon/PgAlpha_t.java
@@ -1,26 +1,26 @@
-package org.eclipse.swt.internal.photon;
-
-/*
+package org.eclipse.swt.internal.photon;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-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;
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+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;
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/photon/org/eclipse/swt/internal/photon/PgDisplaySettings_t.java b/bundles/org.eclipse.swt/Eclipse SWT PI/photon/org/eclipse/swt/internal/photon/PgDisplaySettings_t.java
index a293754fef..eec85d355b 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/photon/org/eclipse/swt/internal/photon/PgDisplaySettings_t.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/photon/org/eclipse/swt/internal/photon/PgDisplaySettings_t.java
@@ -1,18 +1,18 @@
-package org.eclipse.swt.internal.photon;
-
-/*
+package org.eclipse.swt.internal.photon;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-public class PgDisplaySettings_t {
- public int mode;
- public int xres;
- public int yres;
- public int refresh;
- public int flags;
- public int [] reserved = new int [22];
- public static final int sizeof = 108;
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+public class PgDisplaySettings_t {
+ public int mode;
+ public int xres;
+ public int yres;
+ public int refresh;
+ public int flags;
+ public int [] reserved = new int [22];
+ public static final int sizeof = 108;
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/photon/org/eclipse/swt/internal/photon/PgMap_t.java b/bundles/org.eclipse.swt/Eclipse SWT PI/photon/org/eclipse/swt/internal/photon/PgMap_t.java
index 887e764a05..20d440f190 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/photon/org/eclipse/swt/internal/photon/PgMap_t.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/photon/org/eclipse/swt/internal/photon/PgMap_t.java
@@ -1,18 +1,18 @@
-package org.eclipse.swt.internal.photon;
-
-/*
+package org.eclipse.swt.internal.photon;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-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;
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+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;
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/photon/org/eclipse/swt/internal/photon/PgVideoModeInfo_t.java b/bundles/org.eclipse.swt/Eclipse SWT PI/photon/org/eclipse/swt/internal/photon/PgVideoModeInfo_t.java
index f576626545..72c9c74d4e 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/photon/org/eclipse/swt/internal/photon/PgVideoModeInfo_t.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/photon/org/eclipse/swt/internal/photon/PgVideoModeInfo_t.java
@@ -1,24 +1,24 @@
-package org.eclipse.swt.internal.photon;
-
-/*
+package org.eclipse.swt.internal.photon;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-public class PgVideoModeInfo_t {
- public short width;
- public short height;
- public short bits_per_pixel;
- public short bytes_per_scanline;
- public int type;
- public int mode_capabilities1;
- public int mode_capabilities2;
- public int mode_capabilities3;
- public int mode_capabilities4;
- public int mode_capabilities5;
- public int mode_capabilities6;
- public byte [] refresh_rates = new byte [20];
- public static final int sizeof = 56;
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+public class PgVideoModeInfo_t {
+ public short width;
+ public short height;
+ public short bits_per_pixel;
+ public short bytes_per_scanline;
+ public int type;
+ public int mode_capabilities1;
+ public int mode_capabilities2;
+ public int mode_capabilities3;
+ public int mode_capabilities4;
+ public int mode_capabilities5;
+ public int mode_capabilities6;
+ public byte [] refresh_rates = new byte [20];
+ public static final int sizeof = 56;
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/photon/org/eclipse/swt/internal/photon/PhArea_t.java b/bundles/org.eclipse.swt/Eclipse SWT PI/photon/org/eclipse/swt/internal/photon/PhArea_t.java
index 08d080b071..c7df2a4691 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/photon/org/eclipse/swt/internal/photon/PhArea_t.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/photon/org/eclipse/swt/internal/photon/PhArea_t.java
@@ -1,16 +1,16 @@
-package org.eclipse.swt.internal.photon;
-
-/*
+package org.eclipse.swt.internal.photon;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-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;
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+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;
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/photon/org/eclipse/swt/internal/photon/PhClipHeader.java b/bundles/org.eclipse.swt/Eclipse SWT PI/photon/org/eclipse/swt/internal/photon/PhClipHeader.java
index 3709569994..1fcfe90162 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/photon/org/eclipse/swt/internal/photon/PhClipHeader.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/photon/org/eclipse/swt/internal/photon/PhClipHeader.java
@@ -1,27 +1,27 @@
-package org.eclipse.swt.internal.photon;
-
-/*
+package org.eclipse.swt.internal.photon;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-public class PhClipHeader {
-
- public byte type_0;
- public byte type_1;
- public byte type_2;
- public byte type_3;
- public byte type_4;
- public byte type_5;
- public byte type_6;
- public byte type_7;
- public short length;
- public short zero;
- public int data;
-
- public static final int sizeof = 16;
-
-}
-
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+public class PhClipHeader {
+
+ public byte type_0;
+ public byte type_1;
+ public byte type_2;
+ public byte type_3;
+ public byte type_4;
+ public byte type_5;
+ public byte type_6;
+ public byte type_7;
+ public short length;
+ public short zero;
+ public int data;
+
+ public static final int sizeof = 16;
+
+}
+
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/photon/org/eclipse/swt/internal/photon/PhCursorDef_t.java b/bundles/org.eclipse.swt/Eclipse SWT PI/photon/org/eclipse/swt/internal/photon/PhCursorDef_t.java
index ed449ee992..47f47f395f 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/photon/org/eclipse/swt/internal/photon/PhCursorDef_t.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/photon/org/eclipse/swt/internal/photon/PhCursorDef_t.java
@@ -1,38 +1,38 @@
-package org.eclipse.swt.internal.photon;
- /*
+package org.eclipse.swt.internal.photon;
+ /*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
- public class PhCursorDef_t {
-// PhRegionDataHdr_t hdr;
- public short hdr_len;
- public short hdr_type;
-
-// PhPoint_t size1;
- public short size1_x;
- public short size1_y;
-// PhPoint_t offset1;
- public short offset1_x;
- public short offset1_y;
- public int color1;
- public byte bytesperline1;
-
-// byte zero1; // 3 bytes
-
-// PhPoint_t size2;
- public short size2_x;
- public short size2_y;
-// PhPoint_t offset2;
- public short offset2_x;
- public short offset2_y;
- public int color2;
- public byte bytesperline2;
-
-// byte Spare; // 14 bytes
-
-// byte images; // variable number of bytes
-
- public static final int sizeof = 47;
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+ public class PhCursorDef_t {
+// PhRegionDataHdr_t hdr;
+ public short hdr_len;
+ public short hdr_type;
+
+// PhPoint_t size1;
+ public short size1_x;
+ public short size1_y;
+// PhPoint_t offset1;
+ public short offset1_x;
+ public short offset1_y;
+ public int color1;
+ public byte bytesperline1;
+
+// byte zero1; // 3 bytes
+
+// PhPoint_t size2;
+ public short size2_x;
+ public short size2_y;
+// PhPoint_t offset2;
+ public short offset2_x;
+ public short offset2_y;
+ public int color2;
+ public byte bytesperline2;
+
+// byte Spare; // 14 bytes
+
+// byte images; // variable number of bytes
+
+ public static final int sizeof = 47;
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/photon/org/eclipse/swt/internal/photon/PhCursorInfo_t.java b/bundles/org.eclipse.swt/Eclipse SWT PI/photon/org/eclipse/swt/internal/photon/PhCursorInfo_t.java
index 3ec49167bf..e5fe5f1e91 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/photon/org/eclipse/swt/internal/photon/PhCursorInfo_t.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/photon/org/eclipse/swt/internal/photon/PhCursorInfo_t.java
@@ -1,40 +1,40 @@
-package org.eclipse.swt.internal.photon;
-
-/*
+package org.eclipse.swt.internal.photon;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-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;
-
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+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;
+
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/photon/org/eclipse/swt/internal/photon/PhDim_t.java b/bundles/org.eclipse.swt/Eclipse SWT PI/photon/org/eclipse/swt/internal/photon/PhDim_t.java
index 40503ff13e..73ee62c2c3 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/photon/org/eclipse/swt/internal/photon/PhDim_t.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/photon/org/eclipse/swt/internal/photon/PhDim_t.java
@@ -1,14 +1,14 @@
-package org.eclipse.swt.internal.photon;
-
-/*
+package org.eclipse.swt.internal.photon;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-public class PhDim_t {
- public short w;
- public short h;
- public static final int sizeof = 4;
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+public class PhDim_t {
+ public short w;
+ public short h;
+ public static final int sizeof = 4;
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/photon/org/eclipse/swt/internal/photon/PhEvent_t.java b/bundles/org.eclipse.swt/Eclipse SWT PI/photon/org/eclipse/swt/internal/photon/PhEvent_t.java
index 8bee397055..ef64304a59 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/photon/org/eclipse/swt/internal/photon/PhEvent_t.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/photon/org/eclipse/swt/internal/photon/PhEvent_t.java
@@ -1,29 +1,29 @@
-package org.eclipse.swt.internal.photon;
-
-/*
+package org.eclipse.swt.internal.photon;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-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;
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+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;
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/photon/org/eclipse/swt/internal/photon/PhImage_t.java b/bundles/org.eclipse.swt/Eclipse SWT PI/photon/org/eclipse/swt/internal/photon/PhImage_t.java
index 6f672081c3..a9d5e3250d 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/photon/org/eclipse/swt/internal/photon/PhImage_t.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/photon/org/eclipse/swt/internal/photon/PhImage_t.java
@@ -1,30 +1,30 @@
-package org.eclipse.swt.internal.photon;
-
-/*
+package org.eclipse.swt.internal.photon;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-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;
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+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;
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/photon/org/eclipse/swt/internal/photon/PhKeyEvent_t.java b/bundles/org.eclipse.swt/Eclipse SWT PI/photon/org/eclipse/swt/internal/photon/PhKeyEvent_t.java
index e0f3db50e0..a50a7a6fce 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/photon/org/eclipse/swt/internal/photon/PhKeyEvent_t.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/photon/org/eclipse/swt/internal/photon/PhKeyEvent_t.java
@@ -1,22 +1,22 @@
-package org.eclipse.swt.internal.photon;
-
-/*
+package org.eclipse.swt.internal.photon;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-public class PhKeyEvent_t {
- public int key_mods;
- public int key_flags;
- public int key_cap;
- public int key_sym;
- public short key_scan;
- public short key_zero;
-// PhPoint_t pos;
- public short pos_x;
- public short pos_y;
- public short button_state;
- public static final int sizeof = 26;
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+public class PhKeyEvent_t {
+ public int key_mods;
+ public int key_flags;
+ public int key_cap;
+ public int key_sym;
+ public short key_scan;
+ public short key_zero;
+// PhPoint_t pos;
+ public short pos_x;
+ public short pos_y;
+ public short button_state;
+ public static final int sizeof = 26;
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/photon/org/eclipse/swt/internal/photon/PhPoint_t.java b/bundles/org.eclipse.swt/Eclipse SWT PI/photon/org/eclipse/swt/internal/photon/PhPoint_t.java
index e5887f1d91..f27a60e5c5 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/photon/org/eclipse/swt/internal/photon/PhPoint_t.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/photon/org/eclipse/swt/internal/photon/PhPoint_t.java
@@ -1,14 +1,14 @@
-package org.eclipse.swt.internal.photon;
-
-/*
+package org.eclipse.swt.internal.photon;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-public class PhPoint_t {
- public short x;
- public short y;
- public static final int sizeof = 4;
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+public class PhPoint_t {
+ public short x;
+ public short y;
+ public static final int sizeof = 4;
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/photon/org/eclipse/swt/internal/photon/PhPointerEvent_t.java b/bundles/org.eclipse.swt/Eclipse SWT PI/photon/org/eclipse/swt/internal/photon/PhPointerEvent_t.java
index 083f24eaf5..27c4f0dafa 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/photon/org/eclipse/swt/internal/photon/PhPointerEvent_t.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/photon/org/eclipse/swt/internal/photon/PhPointerEvent_t.java
@@ -1,22 +1,22 @@
-package org.eclipse.swt.internal.photon;
-
-/*
+package org.eclipse.swt.internal.photon;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-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;
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+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;
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/photon/org/eclipse/swt/internal/photon/PhRect_t.java b/bundles/org.eclipse.swt/Eclipse SWT PI/photon/org/eclipse/swt/internal/photon/PhRect_t.java
index 9469633a37..132819d493 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/photon/org/eclipse/swt/internal/photon/PhRect_t.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/photon/org/eclipse/swt/internal/photon/PhRect_t.java
@@ -1,16 +1,16 @@
-package org.eclipse.swt.internal.photon;
-
-/*
+package org.eclipse.swt.internal.photon;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-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;
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+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;
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/photon/org/eclipse/swt/internal/photon/PhRegion_t.java b/bundles/org.eclipse.swt/Eclipse SWT PI/photon/org/eclipse/swt/internal/photon/PhRegion_t.java
index c86197d4d7..8bea7f43bc 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/photon/org/eclipse/swt/internal/photon/PhRegion_t.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/photon/org/eclipse/swt/internal/photon/PhRegion_t.java
@@ -1,34 +1,34 @@
-package org.eclipse.swt.internal.photon;
-
-/*
+package org.eclipse.swt.internal.photon;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-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;
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+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;
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/photon/org/eclipse/swt/internal/photon/PhTile_t.java b/bundles/org.eclipse.swt/Eclipse SWT PI/photon/org/eclipse/swt/internal/photon/PhTile_t.java
index e72318859b..aa902468a2 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/photon/org/eclipse/swt/internal/photon/PhTile_t.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/photon/org/eclipse/swt/internal/photon/PhTile_t.java
@@ -1,18 +1,18 @@
-package org.eclipse.swt.internal.photon;
-
-/*
+package org.eclipse.swt.internal.photon;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-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;
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+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;
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/photon/org/eclipse/swt/internal/photon/PhWindowEvent_t.java b/bundles/org.eclipse.swt/Eclipse SWT PI/photon/org/eclipse/swt/internal/photon/PhWindowEvent_t.java
index 015517f22f..2be134fedb 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/photon/org/eclipse/swt/internal/photon/PhWindowEvent_t.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/photon/org/eclipse/swt/internal/photon/PhWindowEvent_t.java
@@ -1,24 +1,24 @@
-package org.eclipse.swt.internal.photon;
-
-/*
+package org.eclipse.swt.internal.photon;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-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;
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+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;
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/photon/org/eclipse/swt/internal/photon/PtCallbackInfo_t.java b/bundles/org.eclipse.swt/Eclipse SWT PI/photon/org/eclipse/swt/internal/photon/PtCallbackInfo_t.java
index 056b9d4d91..c82c79c73d 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/photon/org/eclipse/swt/internal/photon/PtCallbackInfo_t.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/photon/org/eclipse/swt/internal/photon/PtCallbackInfo_t.java
@@ -1,16 +1,16 @@
-package org.eclipse.swt.internal.photon;
-
-/*
+package org.eclipse.swt.internal.photon;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-public class PtCallbackInfo_t {
- public int reason;
- public int reason_subtype;
- public int event;
- public int cbdata;
- public static final int sizeof = 16;
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+public class PtCallbackInfo_t {
+ public int reason;
+ public int reason_subtype;
+ public int event;
+ public int cbdata;
+ public static final int sizeof = 16;
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/photon/org/eclipse/swt/internal/photon/PtColorSelectInfo_t.java b/bundles/org.eclipse.swt/Eclipse SWT PI/photon/org/eclipse/swt/internal/photon/PtColorSelectInfo_t.java
index c416869248..c80620a66d 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/photon/org/eclipse/swt/internal/photon/PtColorSelectInfo_t.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/photon/org/eclipse/swt/internal/photon/PtColorSelectInfo_t.java
@@ -1,29 +1,29 @@
-package org.eclipse.swt.internal.photon;
-
-/*
+package org.eclipse.swt.internal.photon;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-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;
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+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;
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/photon/org/eclipse/swt/internal/photon/PtContainerCallback_t.java b/bundles/org.eclipse.swt/Eclipse SWT PI/photon/org/eclipse/swt/internal/photon/PtContainerCallback_t.java
index 66ae223943..9541cff89e 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/photon/org/eclipse/swt/internal/photon/PtContainerCallback_t.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/photon/org/eclipse/swt/internal/photon/PtContainerCallback_t.java
@@ -1,24 +1,24 @@
-package org.eclipse.swt.internal.photon;
-
-/*
+package org.eclipse.swt.internal.photon;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-public class PtContainerCallback_t {
- public short new_size_ul_x;
- public short new_size_ul_y;
- public short new_size_lr_x;
- public short new_size_lr_y;
- public short old_size_ul_x;
- public short old_size_ul_y;
- public short old_size_lr_x;
- public short old_size_lr_y;
- public short new_dim_w;
- public short new_dim_h;
- public short old_dim_w;
- public short old_dim_h;
- public static final int sizeof = 24;
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+public class PtContainerCallback_t {
+ public short new_size_ul_x;
+ public short new_size_ul_y;
+ public short new_size_lr_x;
+ public short new_size_lr_y;
+ public short old_size_ul_x;
+ public short old_size_ul_y;
+ public short old_size_lr_x;
+ public short old_size_lr_y;
+ public short new_dim_w;
+ public short new_dim_h;
+ public short old_dim_w;
+ public short old_dim_h;
+ public static final int sizeof = 24;
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/photon/org/eclipse/swt/internal/photon/PtFileSelectionInfo_t.java b/bundles/org.eclipse.swt/Eclipse SWT PI/photon/org/eclipse/swt/internal/photon/PtFileSelectionInfo_t.java
index d4de052f37..00d6ccd80d 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/photon/org/eclipse/swt/internal/photon/PtFileSelectionInfo_t.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/photon/org/eclipse/swt/internal/photon/PtFileSelectionInfo_t.java
@@ -1,27 +1,27 @@
-package org.eclipse.swt.internal.photon;
-
-/*
+package org.eclipse.swt.internal.photon;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-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;
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+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;
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/photon/org/eclipse/swt/internal/photon/PtScrollbarCallback_t.java b/bundles/org.eclipse.swt/Eclipse SWT PI/photon/org/eclipse/swt/internal/photon/PtScrollbarCallback_t.java
index 515777d441..f3de1c397b 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/photon/org/eclipse/swt/internal/photon/PtScrollbarCallback_t.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/photon/org/eclipse/swt/internal/photon/PtScrollbarCallback_t.java
@@ -1,14 +1,14 @@
-package org.eclipse.swt.internal.photon;
-
-/*
+package org.eclipse.swt.internal.photon;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-public class PtScrollbarCallback_t {
- public int action;
- public int position;
- public static final int sizeof = 8;
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+public class PtScrollbarCallback_t {
+ public int action;
+ public int position;
+ public static final int sizeof = 8;
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/photon/org/eclipse/swt/internal/photon/PtTextCallback_t.java b/bundles/org.eclipse.swt/Eclipse SWT PI/photon/org/eclipse/swt/internal/photon/PtTextCallback_t.java
index 399cbf5ad5..4576d0603c 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/photon/org/eclipse/swt/internal/photon/PtTextCallback_t.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/photon/org/eclipse/swt/internal/photon/PtTextCallback_t.java
@@ -1,20 +1,20 @@
-package org.eclipse.swt.internal.photon;
-
-/*
+package org.eclipse.swt.internal.photon;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-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;
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+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;
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/build-ce.bat b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/build-ce.bat
index 8483897742..9512eab15f 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/build-ce.bat
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/build-ce.bat
@@ -1,61 +1,61 @@
-@echo off
-
-rem Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
-rem This file is made available under the terms of the Common Public License v1.0
-rem which accompanies this distribution, and is available at
-rem http://www.eclipse.org/legal/cpl-v10.html
-
-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 WinCE
-rem *****************
-set WCEROOT=k:\dev\products\wince.sdk
-
-rem **********************************************************
-rem By default, build library for ARM Pocket PC
-rem 'Experiment' with other targets: an example is provided
-rem for ARM HPC 2000. Set the flag CFG to the value "hpc2000"
-rem to build for ARM HPC 2000.
-rem **********************************************************
-IF "%CFG%"=="hpc2000" GOTO HPC2000
-IF "%CFG%"=="SmartPhone 2002" GOTO SMARTPHONE
-
-:POCKETPC
-set OSVERSION=WCE300
-set PLATFORM=MS Pocket PC
-set PATH=%WCEROOT%\bin;%WCEROOT%\%OSVERSION%\bin;%path%
-set INCLUDE=%WCEROOT%\%OSVERSION%\%PLATFORM%\include;%WCEROOT%\%OSVERSION%\%PLATFORM%\MFC\include;%WCEROOT%\%OSVERSION%\%PLATFORM%\ATL\include;
-set LIB=%WCEROOT%\%OSVERSION%\%PLATFORM%\lib\arm;%WCEROOT%\%OSVERSION%\%PLATFORM%\MFC\lib\arm;%WCEROOT%\%OSVERSION%\%PLATFORM%\ATL\lib\arm;
-GOTO MAKE
-
-:HPC2000
-set OSVERSION=WCE300
-set PLATFORM=hpc2000
-set PATH=%WCEROOT%\bin;%WCEROOT%\%OSVERSION%\bin;%path%
-set INCLUDE=%WCEROOT%\%OSVERSION%\%PLATFORM%\include;%WCEROOT%\%OSVERSION%\%PLATFORM%\MFC\include;%WCEROOT%\%OSVERSION%\%PLATFORM%\ATL\include;
-set LIB=%WCEROOT%\%OSVERSION%\%PLATFORM%\lib\arm;%WCEROOT%\%OSVERSION%\%PLATFORM%\MFC\lib\arm;%WCEROOT%\%OSVERSION%\%PLATFORM%\ATL\lib\arm;
-GOTO MAKE
-
-:SMARTPHONE
-set OSVERSION=WCE300
-set PLATFORM=SmartPhone 2002
-set PATH=%WCEROOT%\bin;%WCEROOT%\%OSVERSION%\bin;%path%
-set INCLUDE=%WCEROOT%\%OSVERSION%\%PLATFORM%\include;%WCEROOT%\%OSVERSION%\%PLATFORM%\ATL\include;
-set LIB=%WCEROOT%\%OSVERSION%\%PLATFORM%\lib\arm;%WCEROOT%\%OSVERSION%\%PLATFORM%\ATL\lib\arm;
-GOTO MAKE
-
-:MAKE
-Title Environment %OSVERSION% %PLATFORM%
-nmake -f make_wince.mak %1 %2 %3 %4
+@echo off
+
+rem Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
+rem This file is made available under the terms of the Common Public License v1.0
+rem which accompanies this distribution, and is available at
+rem http://www.eclipse.org/legal/cpl-v10.html
+
+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 WinCE
+rem *****************
+set WCEROOT=k:\dev\products\wince.sdk
+
+rem **********************************************************
+rem By default, build library for ARM Pocket PC
+rem 'Experiment' with other targets: an example is provided
+rem for ARM HPC 2000. Set the flag CFG to the value "hpc2000"
+rem to build for ARM HPC 2000.
+rem **********************************************************
+IF "%CFG%"=="hpc2000" GOTO HPC2000
+IF "%CFG%"=="SmartPhone 2002" GOTO SMARTPHONE
+
+:POCKETPC
+set OSVERSION=WCE300
+set PLATFORM=MS Pocket PC
+set PATH=%WCEROOT%\bin;%WCEROOT%\%OSVERSION%\bin;%path%
+set INCLUDE=%WCEROOT%\%OSVERSION%\%PLATFORM%\include;%WCEROOT%\%OSVERSION%\%PLATFORM%\MFC\include;%WCEROOT%\%OSVERSION%\%PLATFORM%\ATL\include;
+set LIB=%WCEROOT%\%OSVERSION%\%PLATFORM%\lib\arm;%WCEROOT%\%OSVERSION%\%PLATFORM%\MFC\lib\arm;%WCEROOT%\%OSVERSION%\%PLATFORM%\ATL\lib\arm;
+GOTO MAKE
+
+:HPC2000
+set OSVERSION=WCE300
+set PLATFORM=hpc2000
+set PATH=%WCEROOT%\bin;%WCEROOT%\%OSVERSION%\bin;%path%
+set INCLUDE=%WCEROOT%\%OSVERSION%\%PLATFORM%\include;%WCEROOT%\%OSVERSION%\%PLATFORM%\MFC\include;%WCEROOT%\%OSVERSION%\%PLATFORM%\ATL\include;
+set LIB=%WCEROOT%\%OSVERSION%\%PLATFORM%\lib\arm;%WCEROOT%\%OSVERSION%\%PLATFORM%\MFC\lib\arm;%WCEROOT%\%OSVERSION%\%PLATFORM%\ATL\lib\arm;
+GOTO MAKE
+
+:SMARTPHONE
+set OSVERSION=WCE300
+set PLATFORM=SmartPhone 2002
+set PATH=%WCEROOT%\bin;%WCEROOT%\%OSVERSION%\bin;%path%
+set INCLUDE=%WCEROOT%\%OSVERSION%\%PLATFORM%\include;%WCEROOT%\%OSVERSION%\%PLATFORM%\ATL\include;
+set LIB=%WCEROOT%\%OSVERSION%\%PLATFORM%\lib\arm;%WCEROOT%\%OSVERSION%\%PLATFORM%\ATL\lib\arm;
+GOTO MAKE
+
+:MAKE
+Title Environment %OSVERSION% %PLATFORM%
+nmake -f make_wince.mak %1 %2 %3 %4
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/build.bat b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/build.bat
index 5fb465d3ea..eb24bad6cc 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/build.bat
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/build.bat
@@ -1,28 +1,28 @@
-@echo off
-
-rem Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
-rem This file is made available under the terms of the Common Public License v1.0
-rem which accompanies this distribution, and is available at
+@echo off
+
+rem Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
+rem This file is made available under the terms of the Common Public License v1.0
+rem which accompanies this distribution, and is available at
rem http://www.eclipse.org/legal/cpl-v10.html
-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
-rem ******
-set Mssdk=j:\teamswt\swt-builddir\mssdk
-call %mssdk%\setenv.bat
-
-:MAKE
-nmake -f make_win32.mak %1 %2 %3 %4
+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
+rem ******
+set Mssdk=j:\teamswt\swt-builddir\mssdk
+call %mssdk%\setenv.bat
+
+:MAKE
+nmake -f make_win32.mak %1 %2 %3 %4
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/defines.h b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/defines.h
index d650456116..ac64a20e0b 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/defines.h
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/defines.h
@@ -1,22 +1,22 @@
-/*
- * Copyright (c) 2002 IBM Corp. All rights reserved.
- * This file is made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-/*
- * - Size Optimization -
- * You can specify here which structs and SWT JNI calls
- * you want to exclude. This can be useful to create
- * a smaller library, based on your particular requirements.
- * For example, if your application does not use the type ACCEL
- * you can add:
- * #define NO_ACCEL
- * If your application does not require the function Arc,
- * you can add:
- * #define NO_Arc
- * By default, all types and JNI calls relevant to a
- * platform are included.
- *
+/*
+ * Copyright (c) 2002 IBM Corp. All rights reserved.
+ * This file is made available under the terms of the Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+/*
+ * - Size Optimization -
+ * You can specify here which structs and SWT JNI calls
+ * you want to exclude. This can be useful to create
+ * a smaller library, based on your particular requirements.
+ * For example, if your application does not use the type ACCEL
+ * you can add:
+ * #define NO_ACCEL
+ * If your application does not require the function Arc,
+ * you can add:
+ * #define NO_Arc
+ * By default, all types and JNI calls relevant to a
+ * platform are included.
+ *
*/ \ No newline at end of file
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/make_win32.mak b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/make_win32.mak
index f2ef4d831d..3c48d55645 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/make_win32.mak
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/make_win32.mak
@@ -1,56 +1,56 @@
-#**********************************************************************
-# Copyright (c) 1999, 2002 IBM Corp. All rights reserved.
-# This file is made available under the terms of the Common Public License v1.0
-# which accompanies this distribution, and is available at
-# http://www.eclipse.org/legal/cpl-v10.html
-#**********************************************************************
-#
-# Makefile for SWT libraries on Windows
-
-# assumes JAVA_HOME is set in the environment from which nmake is run
-
-APPVER=5.0
-!include <make_common.mak>
-!include <win32.mak>
-
-pgm_ver_str="SWT $(maj_ver).$(min_ver) for Windows"
-timestamp_str=__DATE__\" \"__TIME__\" (EST)\"
-copyright = "Copyright (C) 1999, 2002 IBM Corp. All rights reserved."
-
-SWT_PREFIX=swt
-WS_PREFIX=win32
-SWT_VERSION = $(maj_ver)$(min_ver)
-SWT_LIB = $(SWT_PREFIX)-$(WS_PREFIX)-$(SWT_VERSION).dll
-
-LINK_LIBS = ole32.lib comctl32.lib user32.lib gdi32.lib comdlg32.lib kernel32.lib shell32.lib oleaut32.lib advapi32.lib imm32.lib winspool.lib oleacc.lib
-
-# note: thoroughly test all examples after changing any optimization flags
-SWT_CDEBUG = #-Zi -Odi
-SWT_LDEBUG = #/DEBUG /DEBUGTYPE:both
-CFLAGS = -c -W3 -G6 -GD -O1 $(SWT_CDEBUG) -DSWT_VERSION=$(SWT_VERSION) -DSWT_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.
-RCFLAGS = -DSWT_FILE_VERSION=\"$(maj_ver).$(min_ver)\" -DSWT_COMMA_VERSION=$(comma_ver)
-LFLAGS = /INCREMENTAL:NO /PDB:NONE /RELEASE /NOLOGO $(SWT_LDEBUG) -entry:_DllMainCRTStartup@12 -dll /BASE:0x10000000 /comment:$(pgm_ver_str) /comment:$(copyright) /DLL
-
-SWT_OBJS = swt.obj structs.obj callback.obj swtole.obj
-
-all: $(SWT_LIB)
-
-.c.obj:
- cl $(CFLAGS) $*.c
-
-$(SWT_LIB): $(SWT_OBJS) swt.res
- echo $(LFLAGS) >templrf
- echo $(LINK_LIBS) >>templrf
- echo -machine:IX86 >>templrf
- echo -subsystem:windows >>templrf
- echo -out:$(SWT_LIB) >>templrf
- echo $(SWT_OBJS) >>templrf
- echo swt.res >>templrf
- link @templrf
- del templrf
-
-swt.res:
- rc $(RCFLAGS) -DSWT_ORG_FILENAME=\"$(SWT_LIB)\" -r -fo swt.res swt.rc
-
-clean:
- del *.obj *.res *.dll *.lib *.exp
+#**********************************************************************
+# Copyright (c) 1999, 2002 IBM Corp. All rights reserved.
+# This file is made available under the terms of the Common Public License v1.0
+# which accompanies this distribution, and is available at
+# http://www.eclipse.org/legal/cpl-v10.html
+#**********************************************************************
+#
+# Makefile for SWT libraries on Windows
+
+# assumes JAVA_HOME is set in the environment from which nmake is run
+
+APPVER=5.0
+!include <make_common.mak>
+!include <win32.mak>
+
+pgm_ver_str="SWT $(maj_ver).$(min_ver) for Windows"
+timestamp_str=__DATE__\" \"__TIME__\" (EST)\"
+copyright = "Copyright (C) 1999, 2002 IBM Corp. All rights reserved."
+
+SWT_PREFIX=swt
+WS_PREFIX=win32
+SWT_VERSION = $(maj_ver)$(min_ver)
+SWT_LIB = $(SWT_PREFIX)-$(WS_PREFIX)-$(SWT_VERSION).dll
+
+LINK_LIBS = ole32.lib comctl32.lib user32.lib gdi32.lib comdlg32.lib kernel32.lib shell32.lib oleaut32.lib advapi32.lib imm32.lib winspool.lib oleacc.lib
+
+# note: thoroughly test all examples after changing any optimization flags
+SWT_CDEBUG = #-Zi -Odi
+SWT_LDEBUG = #/DEBUG /DEBUGTYPE:both
+CFLAGS = -c -W3 -G6 -GD -O1 $(SWT_CDEBUG) -DSWT_VERSION=$(SWT_VERSION) -DSWT_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.
+RCFLAGS = -DSWT_FILE_VERSION=\"$(maj_ver).$(min_ver)\" -DSWT_COMMA_VERSION=$(comma_ver)
+LFLAGS = /INCREMENTAL:NO /PDB:NONE /RELEASE /NOLOGO $(SWT_LDEBUG) -entry:_DllMainCRTStartup@12 -dll /BASE:0x10000000 /comment:$(pgm_ver_str) /comment:$(copyright) /DLL
+
+SWT_OBJS = swt.obj structs.obj callback.obj swtole.obj
+
+all: $(SWT_LIB)
+
+.c.obj:
+ cl $(CFLAGS) $*.c
+
+$(SWT_LIB): $(SWT_OBJS) swt.res
+ echo $(LFLAGS) >templrf
+ echo $(LINK_LIBS) >>templrf
+ echo -machine:IX86 >>templrf
+ echo -subsystem:windows >>templrf
+ echo -out:$(SWT_LIB) >>templrf
+ echo $(SWT_OBJS) >>templrf
+ echo swt.res >>templrf
+ link @templrf
+ del templrf
+
+swt.res:
+ rc $(RCFLAGS) -DSWT_ORG_FILENAME=\"$(SWT_LIB)\" -r -fo swt.res swt.rc
+
+clean:
+ del *.obj *.res *.dll *.lib *.exp
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/make_wince.mak b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/make_wince.mak
index 85bc5674c8..def549e59a 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/make_wince.mak
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/make_wince.mak
@@ -1,108 +1,108 @@
-#**********************************************************************
-# Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
-# This file is made available under the terms of the Common Public License v1.0
-# which accompanies this distribution, and is available at
-# http://www.eclipse.org/legal/cpl-v10.html
-#**********************************************************************
-#
-# Makefile for SWT libraries on Windows CE
-
-# assumes JAVA_HOME is set in the environment from which nmake is run
-
-!include <make_common.mak>
-
-SWT_PREFIX = swt
-WS_PREFIX = win32
-SWT_VERSION = $(maj_ver)$(min_ver)
-SWT_LIB = $(SWT_PREFIX)-$(WS_PREFIX)-$(SWT_VERSION).dll
-
-!IF "$(PLATFORM)" == "MS Pocket PC"
-
-CPU=ARM
-
-LINK_LIBS = aygshell.lib corelibc.lib coredll.lib commdlg.lib commctrl.lib ceshell.lib
-
-CFLAGS = /nologo /c /W3 -O1 -DSWT_VERSION=$(SWT_VERSION) -DSWT_BUILD_NUM=$(bld_num) -DREDUCED_CALLBACKS -DJ9WINCE -D_WIN32_WCE=300 -D"WIN32_PLATFORM_PSPC" /DUNDER_CE=300 /D"UNICODE" /D"_MBCS" /Zm200 -DARM -D_ARM_ -DFIXUP_UNALIGNED /I. /I$(JAVA_HOME)\include $*.c
-RCFLAGS = -DSWT_FILE_VERSION=\"$(maj_ver).$(min_ver)\" -DSWT_COMMA_VERSION=$(comma_ver) -D"WIN32_PLATFORM_PSPC"
-LFLAGS = $(dlllflags) /dll /entry:"_DllMainCRTStartup" /NODEFAULTLIB:libc.lib /nodefaultlib:oldnames.lib
-
-SWT_OBJS = swt.obj structs.obj callback.obj
-
-all: $(SWT_LIB)
-
-.c.obj:
- clarm $(CFLAGS) $*.c
-
-$(SWT_LIB): $(SWT_OBJS) swt.res
- link $(LFLAGS) $(LINK_LIBS) \
- -machine:$(CPU) \
- -subsystem:windowsce,3.00 \
- -out:$(SWT_LIB) \
- $(SWT_OBJS) swt.res
-
-swt.res:
- rc $(RCFLAGS) -DSWT_ORG_FILENAME=\"$(SWT_LIB)\" -r -fo swt.res swt.rc
-
-clean:
- del *.obj *.res *.dll *.lib *.exp
-
-!ELSEIF "$(PLATFORM)" == "hpc2000"
-
-CPU=ARM
-
-LINK_LIBS = corelibc.lib coredll.lib commdlg.lib commctrl.lib ceshell.lib
-
-CFLAGS = /nologo /c /W3 -O1 -DSWT_VERSION=$(SWT_VERSION) -DSWT_BUILD_NUM=$(bld_num) -DREDUCED_CALLBACKS -DJ9WINCE -D_WIN32_WCE=300 -D"WIN32_PLATFORM_HPC2000" /DUNDER_CE=300 /D"UNICODE" /D"_MBCS" /Zm200 -DARM -D_ARM_ -DFIXUP_UNALIGNED /I. /I$(JAVA_HOME)\include $*.c
-RCFLAGS = -DSWT_FILE_VERSION=\"$(maj_ver).$(min_ver)\" -DSWT_COMMA_VERSION=$(comma_ver) -D"WIN32_PLATFORM_HPC2000"
-LFLAGS = $(dlllflags) /dll /entry:"_DllMainCRTStartup" /NODEFAULTLIB:libc.lib /nodefaultlib:oldnames.lib
-
-SWT_OBJS = swt.obj structs.obj callback.obj
-
-all: $(SWT_LIB)
-
-.c.obj:
- clarm $(CFLAGS) $*.c
-
-$(SWT_LIB): $(SWT_OBJS) swt.res
- link $(LFLAGS) $(LINK_LIBS) \
- -machine:$(CPU) \
- -subsystem:windowsce,3.00 \
- -out:$(SWT_LIB) \
- $(SWT_OBJS) swt.res
-
-swt.res:
- rc $(RCFLAGS) -DSWT_ORG_FILENAME=\"$(SWT_LIB)\" -r -fo swt.res swt.rc
-
-clean:
- del *.obj *.res *.dll *.lib *.exp
-
-!ELSEIF "$(PLATFORM)" == "SmartPhone 2002"
-
-CPU=ARM
-
-LINK_LIBS = aygshell.lib corelibc.lib coredll.lib commctrl.lib ceshell.lib
-CFLAGS = /nologo /c /W3 -O1 -DSWT_VERSION=$(SWT_VERSION) -DSWT_BUILD_NUM=$(bld_num) -DREDUCED_CALLBACKS -DJ9WINCE -D_WIN32_WCE=300 -D"WIN32_PLATFORM_WFSP=100" /DUNDER_CE=300 /D"UNICODE" /D"_MBCS" /Zm200 -DARM -D_ARM_ -DFIXUP_UNALIGNED /I. /I$(JAVA_HOME)\include $*.c
-RCFLAGS = -DSWT_FILE_VERSION=\"$(maj_ver).$(min_ver)\" -DSWT_COMMA_VERSION=$(comma_ver) -D"WIN32_PLATFORM_WFSP=100"
-LFLAGS = $(dlllflags) /dll /entry:"_DllMainCRTStartup" /NODEFAULTLIB:libc.lib /nodefaultlib:oldnames.lib
-
-SWT_OBJS = swt.obj structs.obj callback.obj
-
-all: $(SWT_LIB)
-
-.c.obj:
- clarm $(CFLAGS) $*.c
-
-$(SWT_LIB): $(SWT_OBJS) swt.res
- link $(LFLAGS) $(LINK_LIBS) \
- -machine:$(CPU) \
- -subsystem:windowsce,3.00 \
- -out:$(SWT_LIB) \
- $(SWT_OBJS) swt.res
-
-swt.res:
- rc $(RCFLAGS) -DSWT_ORG_FILENAME=\"$(SWT_LIB)\" -r -fo swt.res swt.rc
-
-clean:
- del *.obj *.res *.dll *.lib *.exp
-
+#**********************************************************************
+# Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
+# This file is made available under the terms of the Common Public License v1.0
+# which accompanies this distribution, and is available at
+# http://www.eclipse.org/legal/cpl-v10.html
+#**********************************************************************
+#
+# Makefile for SWT libraries on Windows CE
+
+# assumes JAVA_HOME is set in the environment from which nmake is run
+
+!include <make_common.mak>
+
+SWT_PREFIX = swt
+WS_PREFIX = win32
+SWT_VERSION = $(maj_ver)$(min_ver)
+SWT_LIB = $(SWT_PREFIX)-$(WS_PREFIX)-$(SWT_VERSION).dll
+
+!IF "$(PLATFORM)" == "MS Pocket PC"
+
+CPU=ARM
+
+LINK_LIBS = aygshell.lib corelibc.lib coredll.lib commdlg.lib commctrl.lib ceshell.lib
+
+CFLAGS = /nologo /c /W3 -O1 -DSWT_VERSION=$(SWT_VERSION) -DSWT_BUILD_NUM=$(bld_num) -DREDUCED_CALLBACKS -DJ9WINCE -D_WIN32_WCE=300 -D"WIN32_PLATFORM_PSPC" /DUNDER_CE=300 /D"UNICODE" /D"_MBCS" /Zm200 -DARM -D_ARM_ -DFIXUP_UNALIGNED /I. /I$(JAVA_HOME)\include $*.c
+RCFLAGS = -DSWT_FILE_VERSION=\"$(maj_ver).$(min_ver)\" -DSWT_COMMA_VERSION=$(comma_ver) -D"WIN32_PLATFORM_PSPC"
+LFLAGS = $(dlllflags) /dll /entry:"_DllMainCRTStartup" /NODEFAULTLIB:libc.lib /nodefaultlib:oldnames.lib
+
+SWT_OBJS = swt.obj structs.obj callback.obj
+
+all: $(SWT_LIB)
+
+.c.obj:
+ clarm $(CFLAGS) $*.c
+
+$(SWT_LIB): $(SWT_OBJS) swt.res
+ link $(LFLAGS) $(LINK_LIBS) \
+ -machine:$(CPU) \
+ -subsystem:windowsce,3.00 \
+ -out:$(SWT_LIB) \
+ $(SWT_OBJS) swt.res
+
+swt.res:
+ rc $(RCFLAGS) -DSWT_ORG_FILENAME=\"$(SWT_LIB)\" -r -fo swt.res swt.rc
+
+clean:
+ del *.obj *.res *.dll *.lib *.exp
+
+!ELSEIF "$(PLATFORM)" == "hpc2000"
+
+CPU=ARM
+
+LINK_LIBS = corelibc.lib coredll.lib commdlg.lib commctrl.lib ceshell.lib
+
+CFLAGS = /nologo /c /W3 -O1 -DSWT_VERSION=$(SWT_VERSION) -DSWT_BUILD_NUM=$(bld_num) -DREDUCED_CALLBACKS -DJ9WINCE -D_WIN32_WCE=300 -D"WIN32_PLATFORM_HPC2000" /DUNDER_CE=300 /D"UNICODE" /D"_MBCS" /Zm200 -DARM -D_ARM_ -DFIXUP_UNALIGNED /I. /I$(JAVA_HOME)\include $*.c
+RCFLAGS = -DSWT_FILE_VERSION=\"$(maj_ver).$(min_ver)\" -DSWT_COMMA_VERSION=$(comma_ver) -D"WIN32_PLATFORM_HPC2000"
+LFLAGS = $(dlllflags) /dll /entry:"_DllMainCRTStartup" /NODEFAULTLIB:libc.lib /nodefaultlib:oldnames.lib
+
+SWT_OBJS = swt.obj structs.obj callback.obj
+
+all: $(SWT_LIB)
+
+.c.obj:
+ clarm $(CFLAGS) $*.c
+
+$(SWT_LIB): $(SWT_OBJS) swt.res
+ link $(LFLAGS) $(LINK_LIBS) \
+ -machine:$(CPU) \
+ -subsystem:windowsce,3.00 \
+ -out:$(SWT_LIB) \
+ $(SWT_OBJS) swt.res
+
+swt.res:
+ rc $(RCFLAGS) -DSWT_ORG_FILENAME=\"$(SWT_LIB)\" -r -fo swt.res swt.rc
+
+clean:
+ del *.obj *.res *.dll *.lib *.exp
+
+!ELSEIF "$(PLATFORM)" == "SmartPhone 2002"
+
+CPU=ARM
+
+LINK_LIBS = aygshell.lib corelibc.lib coredll.lib commctrl.lib ceshell.lib
+CFLAGS = /nologo /c /W3 -O1 -DSWT_VERSION=$(SWT_VERSION) -DSWT_BUILD_NUM=$(bld_num) -DREDUCED_CALLBACKS -DJ9WINCE -D_WIN32_WCE=300 -D"WIN32_PLATFORM_WFSP=100" /DUNDER_CE=300 /D"UNICODE" /D"_MBCS" /Zm200 -DARM -D_ARM_ -DFIXUP_UNALIGNED /I. /I$(JAVA_HOME)\include $*.c
+RCFLAGS = -DSWT_FILE_VERSION=\"$(maj_ver).$(min_ver)\" -DSWT_COMMA_VERSION=$(comma_ver) -D"WIN32_PLATFORM_WFSP=100"
+LFLAGS = $(dlllflags) /dll /entry:"_DllMainCRTStartup" /NODEFAULTLIB:libc.lib /nodefaultlib:oldnames.lib
+
+SWT_OBJS = swt.obj structs.obj callback.obj
+
+all: $(SWT_LIB)
+
+.c.obj:
+ clarm $(CFLAGS) $*.c
+
+$(SWT_LIB): $(SWT_OBJS) swt.res
+ link $(LFLAGS) $(LINK_LIBS) \
+ -machine:$(CPU) \
+ -subsystem:windowsce,3.00 \
+ -out:$(SWT_LIB) \
+ $(SWT_OBJS) swt.res
+
+swt.res:
+ rc $(RCFLAGS) -DSWT_ORG_FILENAME=\"$(SWT_LIB)\" -r -fo swt.res swt.rc
+
+clean:
+ del *.obj *.res *.dll *.lib *.exp
+
!ENDIF \ No newline at end of file
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/structs.c b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/structs.c
index ec381a279a..2656726296 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/structs.c
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/structs.c
@@ -1,5014 +1,5014 @@
-/*
- * Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
- * This file is made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-/**
- * JNI SWT object field getters and setters declarations for Windows structs
- */
-
-#include "swt.h"
-#include "structs.h"
-
-#ifndef NO_ACCEL
-typedef struct ACCEL_FID_CACHE {
- int cached;
- jclass clazz;
- jfieldID fVirt, key, cmd;
-} ACCEL_FID_CACHE;
-
-ACCEL_FID_CACHE ACCELFc;
-
-void cacheACCELFids(JNIEnv *env, jobject lpObject)
-{
- if (ACCELFc.cached) return;
- ACCELFc.clazz = (*env)->GetObjectClass(env, lpObject);
- ACCELFc.fVirt = (*env)->GetFieldID(env, ACCELFc.clazz, "fVirt", "B");
- ACCELFc.key = (*env)->GetFieldID(env, ACCELFc.clazz, "key", "S");
- ACCELFc.cmd = (*env)->GetFieldID(env, ACCELFc.clazz, "cmd", "S");
- ACCELFc.cached = 1;
-}
-
-ACCEL *getACCELFields(JNIEnv *env, jobject lpObject, ACCEL *lpStruct)
-{
- if (!ACCELFc.cached) cacheACCELFids(env, lpObject);
- lpStruct->fVirt = (*env)->GetByteField(env, lpObject, ACCELFc.fVirt);
- lpStruct->key = (*env)->GetShortField(env, lpObject, ACCELFc.key);
- lpStruct->cmd = (*env)->GetShortField(env, lpObject, ACCELFc.cmd);
- return lpStruct;
-}
-
-void setACCELFields(JNIEnv *env, jobject lpObject, ACCEL *lpStruct)
-{
- if (!ACCELFc.cached) cacheACCELFids(env, lpObject);
- (*env)->SetByteField(env, lpObject, ACCELFc.fVirt, (jbyte)lpStruct->fVirt);
- (*env)->SetShortField(env, lpObject, ACCELFc.key, (jshort)lpStruct->key);
- (*env)->SetShortField(env, lpObject, ACCELFc.cmd, (jshort)lpStruct->cmd);
-}
-#endif /* NO_ACCEL */
-
-#ifndef NO_BITMAP
-typedef struct BITMAP_FID_CACHE {
- int cached;
- jclass clazz;
- jfieldID bmType, bmWidth, bmHeight, bmWidthBytes, bmPlanes, bmBitsPixel, bmBits;
-} BITMAP_FID_CACHE;
-
-BITMAP_FID_CACHE BITMAPFc;
-
-void cacheBITMAPFids(JNIEnv *env, jobject lpObject)
-{
- if (BITMAPFc.cached) return;
- BITMAPFc.clazz = (*env)->GetObjectClass(env, lpObject);
- BITMAPFc.bmType = (*env)->GetFieldID(env, BITMAPFc.clazz, "bmType", "I");
- BITMAPFc.bmWidth = (*env)->GetFieldID(env, BITMAPFc.clazz, "bmWidth", "I");
- BITMAPFc.bmHeight = (*env)->GetFieldID(env, BITMAPFc.clazz, "bmHeight", "I");
- BITMAPFc.bmWidthBytes = (*env)->GetFieldID(env, BITMAPFc.clazz, "bmWidthBytes", "I");
- BITMAPFc.bmPlanes = (*env)->GetFieldID(env, BITMAPFc.clazz, "bmPlanes", "S");
- BITMAPFc.bmBitsPixel = (*env)->GetFieldID(env, BITMAPFc.clazz, "bmBitsPixel", "S");
- BITMAPFc.bmBits = (*env)->GetFieldID(env, BITMAPFc.clazz, "bmBits", "I");
- BITMAPFc.cached = 1;
-}
-
-BITMAP *getBITMAPFields(JNIEnv *env, jobject lpObject, BITMAP *lpStruct)
-{
- if (!BITMAPFc.cached) cacheBITMAPFids(env, lpObject);
- lpStruct->bmType = (*env)->GetIntField(env, lpObject, BITMAPFc.bmType);
- lpStruct->bmWidth = (*env)->GetIntField(env, lpObject, BITMAPFc.bmWidth);
- lpStruct->bmHeight = (*env)->GetIntField(env, lpObject, BITMAPFc.bmHeight);
- lpStruct->bmWidthBytes = (*env)->GetIntField(env, lpObject, BITMAPFc.bmWidthBytes);
- lpStruct->bmPlanes = (*env)->GetShortField(env, lpObject, BITMAPFc.bmPlanes);
- lpStruct->bmBitsPixel = (*env)->GetShortField(env, lpObject, BITMAPFc.bmBitsPixel);
- lpStruct->bmBits = (LPVOID)(*env)->GetIntField(env, lpObject, BITMAPFc.bmBits);
- return lpStruct;
-}
-
-void setBITMAPFields(JNIEnv *env, jobject lpObject, BITMAP *lpStruct)
-{
- if (!BITMAPFc.cached) cacheBITMAPFids(env, lpObject);
- (*env)->SetIntField(env, lpObject, BITMAPFc.bmType, (jint)lpStruct->bmType);
- (*env)->SetIntField(env, lpObject, BITMAPFc.bmWidth, (jint)lpStruct->bmWidth);
- (*env)->SetIntField(env, lpObject, BITMAPFc.bmHeight, (jint)lpStruct->bmHeight);
- (*env)->SetIntField(env, lpObject, BITMAPFc.bmWidthBytes, (jint)lpStruct->bmWidthBytes);
- (*env)->SetShortField(env, lpObject, BITMAPFc.bmPlanes, (jshort)lpStruct->bmPlanes);
- (*env)->SetShortField(env, lpObject, BITMAPFc.bmBitsPixel, (jshort)lpStruct->bmBitsPixel);
- (*env)->SetIntField(env, lpObject, BITMAPFc.bmBits, (jint)lpStruct->bmBits);
-}
-#endif /* NO_BITMAP */
-
-#ifndef NO_BITMAPINFOHEADER
-typedef struct BITMAPINFOHEADER_FID_CACHE {
- int cached;
- jclass clazz;
- jfieldID biClrImportant, biClrUsed, biYPelsPerMeter, biXPelsPerMeter, biSizeImage, biCompression, biBitCount, biPlanes, biHeight, biWidth, biSize;
-} BITMAPINFOHEADER_FID_CACHE;
-
-BITMAPINFOHEADER_FID_CACHE BITMAPINFOHEADERFc;
-
-void cacheBITMAPINFOHEADERFids(JNIEnv *env, jobject lpObject)
-{
- if (BITMAPINFOHEADERFc.cached) return;
- BITMAPINFOHEADERFc.clazz = (*env)->GetObjectClass(env, lpObject);
- BITMAPINFOHEADERFc.biClrImportant = (*env)->GetFieldID(env, BITMAPINFOHEADERFc.clazz, "biClrImportant", "I");
- BITMAPINFOHEADERFc.biClrUsed = (*env)->GetFieldID(env, BITMAPINFOHEADERFc.clazz, "biClrUsed", "I");
- BITMAPINFOHEADERFc.biYPelsPerMeter = (*env)->GetFieldID(env, BITMAPINFOHEADERFc.clazz, "biYPelsPerMeter", "I");
- BITMAPINFOHEADERFc.biXPelsPerMeter = (*env)->GetFieldID(env, BITMAPINFOHEADERFc.clazz, "biXPelsPerMeter", "I");
- BITMAPINFOHEADERFc.biSizeImage = (*env)->GetFieldID(env, BITMAPINFOHEADERFc.clazz, "biSizeImage", "I");
- BITMAPINFOHEADERFc.biCompression = (*env)->GetFieldID(env, BITMAPINFOHEADERFc.clazz, "biCompression", "I");
- BITMAPINFOHEADERFc.biBitCount = (*env)->GetFieldID(env, BITMAPINFOHEADERFc.clazz, "biBitCount", "S");
- BITMAPINFOHEADERFc.biPlanes = (*env)->GetFieldID(env, BITMAPINFOHEADERFc.clazz, "biPlanes", "S");
- BITMAPINFOHEADERFc.biHeight = (*env)->GetFieldID(env, BITMAPINFOHEADERFc.clazz, "biHeight", "I");
- BITMAPINFOHEADERFc.biWidth = (*env)->GetFieldID(env, BITMAPINFOHEADERFc.clazz, "biWidth", "I");
- BITMAPINFOHEADERFc.biSize = (*env)->GetFieldID(env, BITMAPINFOHEADERFc.clazz, "biSize", "I");
- BITMAPINFOHEADERFc.cached = 1;
-}
-
-BITMAPINFOHEADER *getBITMAPINFOHEADERFields(JNIEnv *env, jobject lpObject, BITMAPINFOHEADER *lpStruct)
-{
- if (!BITMAPINFOHEADERFc.cached) cacheBITMAPINFOHEADERFids(env, lpObject);
- lpStruct->biClrImportant = (*env)->GetIntField(env, lpObject, BITMAPINFOHEADERFc.biClrImportant);
- lpStruct->biClrUsed = (*env)->GetIntField(env, lpObject, BITMAPINFOHEADERFc.biClrUsed);
- lpStruct->biYPelsPerMeter = (*env)->GetIntField(env, lpObject, BITMAPINFOHEADERFc.biYPelsPerMeter);
- lpStruct->biXPelsPerMeter = (*env)->GetIntField(env, lpObject, BITMAPINFOHEADERFc.biXPelsPerMeter);
- lpStruct->biSizeImage = (*env)->GetIntField(env, lpObject, BITMAPINFOHEADERFc.biSizeImage);
- lpStruct->biCompression = (*env)->GetIntField(env, lpObject, BITMAPINFOHEADERFc.biCompression);
- lpStruct->biBitCount = (*env)->GetShortField(env, lpObject, BITMAPINFOHEADERFc.biBitCount);
- lpStruct->biPlanes = (*env)->GetShortField(env, lpObject, BITMAPINFOHEADERFc.biPlanes);
- lpStruct->biHeight = (*env)->GetIntField(env, lpObject, BITMAPINFOHEADERFc.biHeight);
- lpStruct->biWidth = (*env)->GetIntField(env, lpObject, BITMAPINFOHEADERFc.biWidth);
- lpStruct->biSize = (*env)->GetIntField(env, lpObject, BITMAPINFOHEADERFc.biSize);
- return lpStruct;
-}
-
-void setBITMAPINFOHEADERFields(JNIEnv *env, jobject lpObject, BITMAPINFOHEADER *lpStruct)
-{
- if (!BITMAPINFOHEADERFc.cached) cacheBITMAPINFOHEADERFids(env, lpObject);
- (*env)->SetIntField(env, lpObject, BITMAPINFOHEADERFc.biClrImportant, (jint)lpStruct->biClrImportant);
- (*env)->SetIntField(env, lpObject, BITMAPINFOHEADERFc.biClrUsed, (jint)lpStruct->biClrUsed);
- (*env)->SetIntField(env, lpObject, BITMAPINFOHEADERFc.biYPelsPerMeter, (jint)lpStruct->biYPelsPerMeter);
- (*env)->SetIntField(env, lpObject, BITMAPINFOHEADERFc.biXPelsPerMeter, (jint)lpStruct->biXPelsPerMeter);
- (*env)->SetIntField(env, lpObject, BITMAPINFOHEADERFc.biSizeImage, (jint)lpStruct->biSizeImage);
- (*env)->SetIntField(env, lpObject, BITMAPINFOHEADERFc.biCompression, (jint)lpStruct->biCompression);
- (*env)->SetShortField(env, lpObject, BITMAPINFOHEADERFc.biBitCount, (jshort)lpStruct->biBitCount);
- (*env)->SetShortField(env, lpObject, BITMAPINFOHEADERFc.biPlanes, (jshort)lpStruct->biPlanes);
- (*env)->SetIntField(env, lpObject, BITMAPINFOHEADERFc.biHeight, (jint)lpStruct->biHeight);
- (*env)->SetIntField(env, lpObject, BITMAPINFOHEADERFc.biWidth, (jint)lpStruct->biWidth);
- (*env)->SetIntField(env, lpObject, BITMAPINFOHEADERFc.biSize, (jint)lpStruct->biSize);
-}
-#endif /* NO_BITMAPINFOHEADER */
-
-#ifndef NO_BROWSEINFO
-typedef struct BROWSEINFO_FID_CACHE {
- int cached;
- jclass clazz;
- jfieldID hwndOwner, pidlRoot, pszDisplayName, lpszTitle, ulFlags, lpfn, lParam, iImage;
-} BROWSEINFO_FID_CACHE;
-
-BROWSEINFO_FID_CACHE BROWSEINFOFc;
-
-void cacheBROWSEINFOFids(JNIEnv *env, jobject lpObject)
-{
- if (BROWSEINFOFc.cached) return;
- BROWSEINFOFc.clazz = (*env)->GetObjectClass(env, lpObject);
- BROWSEINFOFc.hwndOwner = (*env)->GetFieldID(env, BROWSEINFOFc.clazz, "hwndOwner", "I");
- BROWSEINFOFc.pidlRoot = (*env)->GetFieldID(env, BROWSEINFOFc.clazz, "pidlRoot", "I");
- BROWSEINFOFc.pszDisplayName = (*env)->GetFieldID(env, BROWSEINFOFc.clazz, "pszDisplayName", "I");
- BROWSEINFOFc.lpszTitle = (*env)->GetFieldID(env, BROWSEINFOFc.clazz, "lpszTitle", "I");
- BROWSEINFOFc.ulFlags = (*env)->GetFieldID(env, BROWSEINFOFc.clazz, "ulFlags", "I");
- BROWSEINFOFc.lpfn = (*env)->GetFieldID(env, BROWSEINFOFc.clazz, "lpfn", "I");
- BROWSEINFOFc.lParam = (*env)->GetFieldID(env, BROWSEINFOFc.clazz, "lParam", "I");
- BROWSEINFOFc.iImage = (*env)->GetFieldID(env, BROWSEINFOFc.clazz, "iImage", "I");
- BROWSEINFOFc.cached = 1;
-}
-
-BROWSEINFO *getBROWSEINFOFields(JNIEnv *env, jobject lpObject, BROWSEINFO *lpStruct)
-{
- if (!BROWSEINFOFc.cached) cacheBROWSEINFOFids(env, lpObject);
- lpStruct->hwndOwner = (HWND)(*env)->GetIntField(env, lpObject, BROWSEINFOFc.hwndOwner);
- lpStruct->pidlRoot = (LPCITEMIDLIST)(*env)->GetIntField(env, lpObject, BROWSEINFOFc.pidlRoot);
- lpStruct->pszDisplayName = (LPTSTR)(*env)->GetIntField(env, lpObject, BROWSEINFOFc.pszDisplayName);
- lpStruct->lpszTitle = (LPCTSTR)(*env)->GetIntField(env, lpObject, BROWSEINFOFc.lpszTitle);
- lpStruct->ulFlags = (*env)->GetIntField(env, lpObject, BROWSEINFOFc.ulFlags);
- lpStruct->lpfn = (BFFCALLBACK)(*env)->GetIntField(env, lpObject, BROWSEINFOFc.lpfn);
- lpStruct->lParam = (*env)->GetIntField(env, lpObject, BROWSEINFOFc.lParam);
- lpStruct->iImage = (*env)->GetIntField(env, lpObject, BROWSEINFOFc.iImage);
- return lpStruct;
-}
-
-void setBROWSEINFOFields(JNIEnv *env, jobject lpObject, BROWSEINFO *lpStruct)
-{
- if (!BROWSEINFOFc.cached) cacheBROWSEINFOFids(env, lpObject);
- (*env)->SetIntField(env, lpObject, BROWSEINFOFc.hwndOwner, (jint)lpStruct->hwndOwner);
- (*env)->SetIntField(env, lpObject, BROWSEINFOFc.pidlRoot, (jint)lpStruct->pidlRoot);
- (*env)->SetIntField(env, lpObject, BROWSEINFOFc.pszDisplayName, (jint)lpStruct->pszDisplayName);
- (*env)->SetIntField(env, lpObject, BROWSEINFOFc.lpszTitle, (jint)lpStruct->lpszTitle);
- (*env)->SetIntField(env, lpObject, BROWSEINFOFc.ulFlags, (jint)lpStruct->ulFlags);
- (*env)->SetIntField(env, lpObject, BROWSEINFOFc.lpfn, (jint)lpStruct->lpfn);
- (*env)->SetIntField(env, lpObject, BROWSEINFOFc.lParam, (jint)lpStruct->lParam);
- (*env)->SetIntField(env, lpObject, BROWSEINFOFc.iImage, (jint)lpStruct->iImage);
-}
-#endif /* NO_BROWSEINFO */
-
-#ifndef NO_CHOOSECOLOR
-typedef struct CHOOSECOLOR_FID_CACHE {
- int cached;
- jclass clazz;
- jfieldID lStructSize, hwndOwner, hInstance, rgbResult, lpCustColors, Flags, lCustData, lpfnHook, lpTemplateName;
-} CHOOSECOLOR_FID_CACHE;
-
-CHOOSECOLOR_FID_CACHE CHOOSECOLORFc;
-
-void cacheCHOOSECOLORFids(JNIEnv *env, jobject lpObject)
-{
- if (CHOOSECOLORFc.cached) return;
- CHOOSECOLORFc.clazz = (*env)->GetObjectClass(env, lpObject);
- CHOOSECOLORFc.lStructSize = (*env)->GetFieldID(env, CHOOSECOLORFc.clazz, "lStructSize", "I");
- CHOOSECOLORFc.hwndOwner = (*env)->GetFieldID(env, CHOOSECOLORFc.clazz, "hwndOwner", "I");
- CHOOSECOLORFc.hInstance = (*env)->GetFieldID(env, CHOOSECOLORFc.clazz, "hInstance", "I");
- CHOOSECOLORFc.rgbResult = (*env)->GetFieldID(env, CHOOSECOLORFc.clazz, "rgbResult", "I");
- CHOOSECOLORFc.lpCustColors = (*env)->GetFieldID(env, CHOOSECOLORFc.clazz, "lpCustColors", "I");
- CHOOSECOLORFc.Flags = (*env)->GetFieldID(env, CHOOSECOLORFc.clazz, "Flags", "I");
- CHOOSECOLORFc.lCustData = (*env)->GetFieldID(env, CHOOSECOLORFc.clazz, "lCustData", "I");
- CHOOSECOLORFc.lpfnHook = (*env)->GetFieldID(env, CHOOSECOLORFc.clazz, "lpfnHook", "I");
- CHOOSECOLORFc.lpTemplateName = (*env)->GetFieldID(env, CHOOSECOLORFc.clazz, "lpTemplateName", "I");
- CHOOSECOLORFc.cached = 1;
-}
-
-CHOOSECOLOR *getCHOOSECOLORFields(JNIEnv *env, jobject lpObject, CHOOSECOLOR *lpStruct)
-{
- if (!CHOOSECOLORFc.cached) cacheCHOOSECOLORFids(env, lpObject);
- lpStruct->lStructSize = (*env)->GetIntField(env, lpObject, CHOOSECOLORFc.lStructSize);
- lpStruct->hwndOwner = (HWND)(*env)->GetIntField(env, lpObject, CHOOSECOLORFc.hwndOwner);
- lpStruct->hInstance = (HANDLE)(*env)->GetIntField(env, lpObject, CHOOSECOLORFc.hInstance);
- lpStruct->rgbResult = (*env)->GetIntField(env, lpObject, CHOOSECOLORFc.rgbResult);
- lpStruct->lpCustColors = (COLORREF *)(*env)->GetIntField(env, lpObject, CHOOSECOLORFc.lpCustColors);
- lpStruct->Flags = (*env)->GetIntField(env, lpObject, CHOOSECOLORFc.Flags);
- lpStruct->lCustData = (*env)->GetIntField(env, lpObject, CHOOSECOLORFc.lCustData);
- lpStruct->lpfnHook = (LPCCHOOKPROC)(*env)->GetIntField(env, lpObject, CHOOSECOLORFc.lpfnHook);
- lpStruct->lpTemplateName = (LPCTSTR)(*env)->GetIntField(env, lpObject, CHOOSECOLORFc.lpTemplateName);
- return lpStruct;
-}
-
-void setCHOOSECOLORFields(JNIEnv *env, jobject lpObject, CHOOSECOLOR *lpStruct)
-{
- if (!CHOOSECOLORFc.cached) cacheCHOOSECOLORFids(env, lpObject);
- (*env)->SetIntField(env, lpObject, CHOOSECOLORFc.lStructSize, (jint)lpStruct->lStructSize);
- (*env)->SetIntField(env, lpObject, CHOOSECOLORFc.hwndOwner, (jint)lpStruct->hwndOwner);
- (*env)->SetIntField(env, lpObject, CHOOSECOLORFc.hInstance, (jint)lpStruct->hInstance);
- (*env)->SetIntField(env, lpObject, CHOOSECOLORFc.rgbResult, (jint)lpStruct->rgbResult);
- (*env)->SetIntField(env, lpObject, CHOOSECOLORFc.lpCustColors, (jint)lpStruct->lpCustColors);
- (*env)->SetIntField(env, lpObject, CHOOSECOLORFc.Flags, (jint)lpStruct->Flags);
- (*env)->SetIntField(env, lpObject, CHOOSECOLORFc.lCustData, (jint)lpStruct->lCustData);
- (*env)->SetIntField(env, lpObject, CHOOSECOLORFc.lpfnHook, (jint)lpStruct->lpfnHook);
- (*env)->SetIntField(env, lpObject, CHOOSECOLORFc.lpTemplateName, (jint)lpStruct->lpTemplateName);
-}
-#endif /* NO_CHOOSECOLOR */
-
-#ifndef NO_CHOOSEFONT
-typedef struct CHOOSEFONT_FID_CACHE {
- int cached;
- jclass clazz;
- jfieldID lStructSize, hwndOwner, hDC, lpLogFont, iPointSize, Flags, rgbColors, lCustData, lpfnHook, lpTemplateName, hInstance, lpszStyle, nFontType, nSizeMin, nSizeMax;
-} CHOOSEFONT_FID_CACHE;
-
-CHOOSEFONT_FID_CACHE CHOOSEFONTFc;
-
-void cacheCHOOSEFONTFids(JNIEnv *env, jobject lpObject)
-{
- if (CHOOSEFONTFc.cached) return;
- CHOOSEFONTFc.clazz = (*env)->GetObjectClass(env, lpObject);
- CHOOSEFONTFc.lStructSize = (*env)->GetFieldID(env, CHOOSEFONTFc.clazz, "lStructSize", "I");
- CHOOSEFONTFc.hwndOwner = (*env)->GetFieldID(env, CHOOSEFONTFc.clazz, "hwndOwner", "I");
- CHOOSEFONTFc.hDC = (*env)->GetFieldID(env, CHOOSEFONTFc.clazz, "hDC", "I");
- CHOOSEFONTFc.lpLogFont = (*env)->GetFieldID(env, CHOOSEFONTFc.clazz, "lpLogFont", "I");
- CHOOSEFONTFc.iPointSize = (*env)->GetFieldID(env, CHOOSEFONTFc.clazz, "iPointSize", "I");
- CHOOSEFONTFc.Flags = (*env)->GetFieldID(env, CHOOSEFONTFc.clazz, "Flags", "I");
- CHOOSEFONTFc.rgbColors = (*env)->GetFieldID(env, CHOOSEFONTFc.clazz, "rgbColors", "I");
- CHOOSEFONTFc.lCustData = (*env)->GetFieldID(env, CHOOSEFONTFc.clazz, "lCustData", "I");
- CHOOSEFONTFc.lpfnHook = (*env)->GetFieldID(env, CHOOSEFONTFc.clazz, "lpfnHook", "I");
- CHOOSEFONTFc.lpTemplateName = (*env)->GetFieldID(env, CHOOSEFONTFc.clazz, "lpTemplateName", "I");
- CHOOSEFONTFc.hInstance = (*env)->GetFieldID(env, CHOOSEFONTFc.clazz, "hInstance", "I");
- CHOOSEFONTFc.lpszStyle = (*env)->GetFieldID(env, CHOOSEFONTFc.clazz, "lpszStyle", "I");
- CHOOSEFONTFc.nFontType = (*env)->GetFieldID(env, CHOOSEFONTFc.clazz, "nFontType", "S");
- CHOOSEFONTFc.nSizeMin = (*env)->GetFieldID(env, CHOOSEFONTFc.clazz, "nSizeMin", "I");
- CHOOSEFONTFc.nSizeMax = (*env)->GetFieldID(env, CHOOSEFONTFc.clazz, "nSizeMax", "I");
- CHOOSEFONTFc.cached = 1;
-}
-
-CHOOSEFONT *getCHOOSEFONTFields(JNIEnv *env, jobject lpObject, CHOOSEFONT *lpStruct)
-{
- if (!CHOOSEFONTFc.cached) cacheCHOOSEFONTFids(env, lpObject);
- lpStruct->lStructSize = (*env)->GetIntField(env, lpObject, CHOOSEFONTFc.lStructSize);
- lpStruct->hwndOwner = (HWND)(*env)->GetIntField(env, lpObject, CHOOSEFONTFc.hwndOwner);
- lpStruct->hDC = (HDC)(*env)->GetIntField(env, lpObject, CHOOSEFONTFc.hDC);
- lpStruct->lpLogFont = (LPLOGFONT)(*env)->GetIntField(env, lpObject, CHOOSEFONTFc.lpLogFont);
- lpStruct->iPointSize = (*env)->GetIntField(env, lpObject, CHOOSEFONTFc.iPointSize);
- lpStruct->Flags = (*env)->GetIntField(env, lpObject, CHOOSEFONTFc.Flags);
- lpStruct->rgbColors = (*env)->GetIntField(env, lpObject, CHOOSEFONTFc.rgbColors);
- lpStruct->lCustData = (*env)->GetIntField(env, lpObject, CHOOSEFONTFc.lCustData);
- lpStruct->lpfnHook = (LPCFHOOKPROC)(*env)->GetIntField(env, lpObject, CHOOSEFONTFc.lpfnHook);
- lpStruct->lpTemplateName = (LPCTSTR)(*env)->GetIntField(env, lpObject, CHOOSEFONTFc.lpTemplateName);
- lpStruct->hInstance = (HINSTANCE)(*env)->GetIntField(env, lpObject, CHOOSEFONTFc.hInstance);
- lpStruct->lpszStyle = (LPTSTR)(*env)->GetIntField(env, lpObject, CHOOSEFONTFc.lpszStyle);
- lpStruct->nFontType = (*env)->GetShortField(env, lpObject, CHOOSEFONTFc.nFontType);
- lpStruct->nSizeMin = (*env)->GetIntField(env, lpObject, CHOOSEFONTFc.nSizeMin);
- lpStruct->nSizeMax = (*env)->GetIntField(env, lpObject, CHOOSEFONTFc.nSizeMax);
- return lpStruct;
-}
-
-void setCHOOSEFONTFields(JNIEnv *env, jobject lpObject, CHOOSEFONT *lpStruct)
-{
- if (!CHOOSEFONTFc.cached) cacheCHOOSEFONTFids(env, lpObject);
- (*env)->SetIntField(env, lpObject, CHOOSEFONTFc.lStructSize, (jint)lpStruct->lStructSize);
- (*env)->SetIntField(env, lpObject, CHOOSEFONTFc.hwndOwner, (jint)lpStruct->hwndOwner);
- (*env)->SetIntField(env, lpObject, CHOOSEFONTFc.hDC, (jint)lpStruct->hDC);
- (*env)->SetIntField(env, lpObject, CHOOSEFONTFc.lpLogFont, (jint)lpStruct->lpLogFont);
- (*env)->SetIntField(env, lpObject, CHOOSEFONTFc.iPointSize, (jint)lpStruct->iPointSize);
- (*env)->SetIntField(env, lpObject, CHOOSEFONTFc.Flags, (jint)lpStruct->Flags);
- (*env)->SetIntField(env, lpObject, CHOOSEFONTFc.rgbColors, (jint)lpStruct->rgbColors);
- (*env)->SetIntField(env, lpObject, CHOOSEFONTFc.lCustData, (jint)lpStruct->lCustData);
- (*env)->SetIntField(env, lpObject, CHOOSEFONTFc.lpfnHook, (jint)lpStruct->lpfnHook);
- (*env)->SetIntField(env, lpObject, CHOOSEFONTFc.lpTemplateName, (jint)lpStruct->lpTemplateName);
- (*env)->SetIntField(env, lpObject, CHOOSEFONTFc.hInstance, (jint)lpStruct->hInstance);
- (*env)->SetIntField(env, lpObject, CHOOSEFONTFc.lpszStyle, (jint)lpStruct->lpszStyle);
- (*env)->SetShortField(env, lpObject, CHOOSEFONTFc.nFontType, (jshort)lpStruct->nFontType);
- (*env)->SetIntField(env, lpObject, CHOOSEFONTFc.nSizeMin, (jint)lpStruct->nSizeMin);
- (*env)->SetIntField(env, lpObject, CHOOSEFONTFc.nSizeMax, (jint)lpStruct->nSizeMax);
-}
-#endif /* NO_CHOOSEFONT */
-
-#ifndef NO_COMPOSITIONFORM
-typedef struct COMPOSITIONFORM_FID_CACHE {
- int cached;
- jclass clazz;
- jfieldID dwStyle, x, y, left, top, right, bottom;
-} COMPOSITIONFORM_FID_CACHE;
-
-COMPOSITIONFORM_FID_CACHE COMPOSITIONFORMFc;
-
-void cacheCOMPOSITIONFORMFids(JNIEnv *env, jobject lpObject)
-{
- if (COMPOSITIONFORMFc.cached) return;
- COMPOSITIONFORMFc.clazz = (*env)->GetObjectClass(env, lpObject);
- COMPOSITIONFORMFc.dwStyle = (*env)->GetFieldID(env, COMPOSITIONFORMFc.clazz, "dwStyle", "I");
- COMPOSITIONFORMFc.x = (*env)->GetFieldID(env, COMPOSITIONFORMFc.clazz, "x", "I");
- COMPOSITIONFORMFc.y = (*env)->GetFieldID(env, COMPOSITIONFORMFc.clazz, "y", "I");
- COMPOSITIONFORMFc.left = (*env)->GetFieldID(env, COMPOSITIONFORMFc.clazz, "left", "I");
- COMPOSITIONFORMFc.top = (*env)->GetFieldID(env, COMPOSITIONFORMFc.clazz, "top", "I");
- COMPOSITIONFORMFc.right = (*env)->GetFieldID(env, COMPOSITIONFORMFc.clazz, "right", "I");
- COMPOSITIONFORMFc.bottom = (*env)->GetFieldID(env, COMPOSITIONFORMFc.clazz, "bottom", "I");
- COMPOSITIONFORMFc.cached = 1;
-}
-
-COMPOSITIONFORM *getCOMPOSITIONFORMFields(JNIEnv *env, jobject lpObject, COMPOSITIONFORM *lpStruct)
-{
- if (!COMPOSITIONFORMFc.cached) cacheCOMPOSITIONFORMFids(env, lpObject);
- lpStruct->dwStyle = (*env)->GetIntField(env, lpObject, COMPOSITIONFORMFc.dwStyle);
- lpStruct->ptCurrentPos.x = (*env)->GetIntField(env, lpObject, COMPOSITIONFORMFc.x);
- lpStruct->ptCurrentPos.y = (*env)->GetIntField(env, lpObject, COMPOSITIONFORMFc.y);
- lpStruct->rcArea.left = (*env)->GetIntField(env, lpObject, COMPOSITIONFORMFc.left);
- lpStruct->rcArea.top = (*env)->GetIntField(env, lpObject, COMPOSITIONFORMFc.top);
- lpStruct->rcArea.right = (*env)->GetIntField(env, lpObject, COMPOSITIONFORMFc.right);
- lpStruct->rcArea.bottom = (*env)->GetIntField(env, lpObject, COMPOSITIONFORMFc.bottom);
- return lpStruct;
-}
-
-void setCOMPOSITIONFORMFields(JNIEnv *env, jobject lpObject, COMPOSITIONFORM *lpStruct)
-{
- if (!COMPOSITIONFORMFc.cached) cacheCOMPOSITIONFORMFids(env, lpObject);
- (*env)->SetIntField(env, lpObject, COMPOSITIONFORMFc.dwStyle, (jint)lpStruct->dwStyle);
- (*env)->SetIntField(env, lpObject, COMPOSITIONFORMFc.x, (jint)lpStruct->ptCurrentPos.x);
- (*env)->SetIntField(env, lpObject, COMPOSITIONFORMFc.y, (jint)lpStruct->ptCurrentPos.y);
- (*env)->SetIntField(env, lpObject, COMPOSITIONFORMFc.left, (jint)lpStruct->rcArea.left);
- (*env)->SetIntField(env, lpObject, COMPOSITIONFORMFc.top, (jint)lpStruct->rcArea.top);
- (*env)->SetIntField(env, lpObject, COMPOSITIONFORMFc.right, (jint)lpStruct->rcArea.right);
- (*env)->SetIntField(env, lpObject, COMPOSITIONFORMFc.bottom, (jint)lpStruct->rcArea.bottom);
-}
-#endif /* NO_COMPOSITIONFORM */
-
-#ifndef NO_CREATESTRUCT
-typedef struct CREATESTRUCT_FID_CACHE {
- int cached;
- jclass clazz;
- jfieldID lpCreateParams, hInstance, hMenu, hwndParent, cy, cx, y, x, style, lpszName, lpszClass, dwExStyle;
-} CREATESTRUCT_FID_CACHE;
-
-CREATESTRUCT_FID_CACHE CREATESTRUCTFc;
-
-void cacheCREATESTRUCTFids(JNIEnv *env, jobject lpObject)
-{
- if (CREATESTRUCTFc.cached) return;
- CREATESTRUCTFc.clazz = (*env)->GetObjectClass(env, lpObject);
- CREATESTRUCTFc.lpCreateParams = (*env)->GetFieldID(env, CREATESTRUCTFc.clazz, "lpCreateParams", "I");
- CREATESTRUCTFc.hInstance = (*env)->GetFieldID(env, CREATESTRUCTFc.clazz, "hInstance", "I");
- CREATESTRUCTFc.hMenu = (*env)->GetFieldID(env, CREATESTRUCTFc.clazz, "hMenu", "I");
- CREATESTRUCTFc.hwndParent = (*env)->GetFieldID(env, CREATESTRUCTFc.clazz, "hwndParent", "I");
- CREATESTRUCTFc.cy = (*env)->GetFieldID(env, CREATESTRUCTFc.clazz, "cy", "I");
- CREATESTRUCTFc.cx = (*env)->GetFieldID(env, CREATESTRUCTFc.clazz, "cx", "I");
- CREATESTRUCTFc.y = (*env)->GetFieldID(env, CREATESTRUCTFc.clazz, "y", "I");
- CREATESTRUCTFc.x = (*env)->GetFieldID(env, CREATESTRUCTFc.clazz, "x", "I");
- CREATESTRUCTFc.style = (*env)->GetFieldID(env, CREATESTRUCTFc.clazz, "style", "I");
- CREATESTRUCTFc.lpszName = (*env)->GetFieldID(env, CREATESTRUCTFc.clazz, "lpszName", "I");
- CREATESTRUCTFc.lpszClass = (*env)->GetFieldID(env, CREATESTRUCTFc.clazz, "lpszClass", "I");
- CREATESTRUCTFc.dwExStyle = (*env)->GetFieldID(env, CREATESTRUCTFc.clazz, "dwExStyle", "I");
- CREATESTRUCTFc.cached = 1;
-}
-
-CREATESTRUCT *getCREATESTRUCTFields(JNIEnv *env, jobject lpObject, CREATESTRUCT *lpStruct)
-{
- if (!CREATESTRUCTFc.cached) cacheCREATESTRUCTFids(env, lpObject);
- lpStruct->lpCreateParams = (LPVOID)(*env)->GetIntField(env, lpObject, CREATESTRUCTFc.lpCreateParams);
- lpStruct->hInstance = (HINSTANCE)(*env)->GetIntField(env, lpObject, CREATESTRUCTFc.hInstance);
- lpStruct->hMenu = (HMENU)(*env)->GetIntField(env, lpObject, CREATESTRUCTFc.hMenu);
- lpStruct->hwndParent = (HWND)(*env)->GetIntField(env, lpObject, CREATESTRUCTFc.hwndParent);
- lpStruct->cy = (*env)->GetIntField(env, lpObject, CREATESTRUCTFc.cy);
- lpStruct->cx = (*env)->GetIntField(env, lpObject, CREATESTRUCTFc.cx);
- lpStruct->y = (*env)->GetIntField(env, lpObject, CREATESTRUCTFc.y);
- lpStruct->x = (*env)->GetIntField(env, lpObject, CREATESTRUCTFc.x);
- lpStruct->style = (*env)->GetIntField(env, lpObject, CREATESTRUCTFc.style);
- lpStruct->lpszName = (LPCTSTR)(*env)->GetIntField(env, lpObject, CREATESTRUCTFc.lpszName);
- lpStruct->lpszClass = (LPCTSTR)(*env)->GetIntField(env, lpObject, CREATESTRUCTFc.lpszClass);
- lpStruct->dwExStyle = (*env)->GetIntField(env, lpObject, CREATESTRUCTFc.dwExStyle);
- return lpStruct;
-}
-
-void setCREATESTRUCTFields(JNIEnv *env, jobject lpObject, CREATESTRUCT *lpStruct)
-{
- if (!CREATESTRUCTFc.cached) cacheCREATESTRUCTFids(env, lpObject);
- (*env)->SetIntField(env, lpObject, CREATESTRUCTFc.lpCreateParams, (jint)lpStruct->lpCreateParams);
- (*env)->SetIntField(env, lpObject, CREATESTRUCTFc.hInstance, (jint)lpStruct->hInstance);
- (*env)->SetIntField(env, lpObject, CREATESTRUCTFc.hMenu, (jint)lpStruct->hMenu);
- (*env)->SetIntField(env, lpObject, CREATESTRUCTFc.hwndParent, (jint)lpStruct->hwndParent);
- (*env)->SetIntField(env, lpObject, CREATESTRUCTFc.cy, (jint)lpStruct->cy);
- (*env)->SetIntField(env, lpObject, CREATESTRUCTFc.cx, (jint)lpStruct->cx);
- (*env)->SetIntField(env, lpObject, CREATESTRUCTFc.y, (jint)lpStruct->y);
- (*env)->SetIntField(env, lpObject, CREATESTRUCTFc.x, (jint)lpStruct->x);
- (*env)->SetIntField(env, lpObject, CREATESTRUCTFc.style, (jint)lpStruct->style);
- (*env)->SetIntField(env, lpObject, CREATESTRUCTFc.lpszName, (jint)lpStruct->lpszName);
- (*env)->SetIntField(env, lpObject, CREATESTRUCTFc.lpszClass, (jint)lpStruct->lpszClass);
- (*env)->SetIntField(env, lpObject, CREATESTRUCTFc.dwExStyle, (jint)lpStruct->dwExStyle);
-}
-#endif /* NO_CREATESTRUCT */
-
-#ifndef NO_DIBSECTION
-typedef struct DIBSECTION_FID_CACHE {
- int cached;
- jclass clazz;
- jfieldID biSize, biWidth, biHeight, biPlanes, biBitCount, biCompression, biSizeImage, biXPelsPerMeter, biYPelsPerMeter, biClrUsed, biClrImportant, dsBitfields0, dsBitfields1, dsBitfields2, dshSection, dsOffset;
-} DIBSECTION_FID_CACHE;
-
-DIBSECTION_FID_CACHE DIBSECTIONFc;
-
-void cacheDIBSECTIONFids(JNIEnv *env, jobject lpObject)
-{
- if (DIBSECTIONFc.cached) return;
- cacheBITMAPFids(env, lpObject);
- DIBSECTIONFc.clazz = (*env)->GetObjectClass(env, lpObject);
- DIBSECTIONFc.biSize = (*env)->GetFieldID(env, DIBSECTIONFc.clazz, "biSize", "I");
- DIBSECTIONFc.biWidth = (*env)->GetFieldID(env, DIBSECTIONFc.clazz, "biWidth", "I");
- DIBSECTIONFc.biHeight = (*env)->GetFieldID(env, DIBSECTIONFc.clazz, "biHeight", "I");
- DIBSECTIONFc.biPlanes = (*env)->GetFieldID(env, DIBSECTIONFc.clazz, "biPlanes", "S");
- DIBSECTIONFc.biBitCount = (*env)->GetFieldID(env, DIBSECTIONFc.clazz, "biBitCount", "S");
- DIBSECTIONFc.biCompression = (*env)->GetFieldID(env, DIBSECTIONFc.clazz, "biCompression", "I");
- DIBSECTIONFc.biSizeImage = (*env)->GetFieldID(env, DIBSECTIONFc.clazz, "biSizeImage", "I");
- DIBSECTIONFc.biXPelsPerMeter = (*env)->GetFieldID(env, DIBSECTIONFc.clazz, "biXPelsPerMeter", "I");
- DIBSECTIONFc.biYPelsPerMeter = (*env)->GetFieldID(env, DIBSECTIONFc.clazz, "biYPelsPerMeter", "I");
- DIBSECTIONFc.biClrUsed = (*env)->GetFieldID(env, DIBSECTIONFc.clazz, "biClrUsed", "I");
- DIBSECTIONFc.biClrImportant = (*env)->GetFieldID(env, DIBSECTIONFc.clazz, "biClrImportant", "I");
- DIBSECTIONFc.dsBitfields0 = (*env)->GetFieldID(env, DIBSECTIONFc.clazz, "dsBitfields0", "I");
- DIBSECTIONFc.dsBitfields1 = (*env)->GetFieldID(env, DIBSECTIONFc.clazz, "dsBitfields1", "I");
- DIBSECTIONFc.dsBitfields2 = (*env)->GetFieldID(env, DIBSECTIONFc.clazz, "dsBitfields2", "I");
- DIBSECTIONFc.dshSection = (*env)->GetFieldID(env, DIBSECTIONFc.clazz, "dshSection", "I");
- DIBSECTIONFc.dsOffset = (*env)->GetFieldID(env, DIBSECTIONFc.clazz, "dsOffset", "I");
- DIBSECTIONFc.cached = 1;
-}
-
-DIBSECTION *getDIBSECTIONFields(JNIEnv *env, jobject lpObject, DIBSECTION *lpStruct)
-{
- if (!DIBSECTIONFc.cached) cacheDIBSECTIONFids(env, lpObject);
- getBITMAPFields(env, lpObject, (BITMAP *)lpStruct);
- lpStruct->dsBmih.biSize = (*env)->GetIntField(env, lpObject, DIBSECTIONFc.biSize);
- lpStruct->dsBmih.biWidth = (*env)->GetIntField(env, lpObject, DIBSECTIONFc.biWidth);
- lpStruct->dsBmih.biHeight = (*env)->GetIntField(env, lpObject, DIBSECTIONFc.biHeight);
- lpStruct->dsBmih.biPlanes = (*env)->GetShortField(env, lpObject, DIBSECTIONFc.biPlanes);
- lpStruct->dsBmih.biBitCount = (*env)->GetShortField(env, lpObject, DIBSECTIONFc.biBitCount);
- lpStruct->dsBmih.biCompression = (*env)->GetIntField(env, lpObject, DIBSECTIONFc.biCompression);
- lpStruct->dsBmih.biSizeImage = (*env)->GetIntField(env, lpObject, DIBSECTIONFc.biSizeImage);
- lpStruct->dsBmih.biXPelsPerMeter = (*env)->GetIntField(env, lpObject, DIBSECTIONFc.biXPelsPerMeter);
- lpStruct->dsBmih.biYPelsPerMeter = (*env)->GetIntField(env, lpObject, DIBSECTIONFc.biYPelsPerMeter);
- lpStruct->dsBmih.biClrUsed = (*env)->GetIntField(env, lpObject, DIBSECTIONFc.biClrUsed);
- lpStruct->dsBmih.biClrImportant = (*env)->GetIntField(env, lpObject, DIBSECTIONFc.biClrImportant);
- lpStruct->dsBitfields[0] = (*env)->GetIntField(env, lpObject, DIBSECTIONFc.dsBitfields0);
- lpStruct->dsBitfields[1] = (*env)->GetIntField(env, lpObject, DIBSECTIONFc.dsBitfields1);
- lpStruct->dsBitfields[2] = (*env)->GetIntField(env, lpObject, DIBSECTIONFc.dsBitfields2);
- lpStruct->dshSection = (HANDLE)(*env)->GetIntField(env, lpObject, DIBSECTIONFc.dshSection);
- lpStruct->dsOffset = (*env)->GetIntField(env, lpObject, DIBSECTIONFc.dsOffset);
- return lpStruct;
-}
-
-void setDIBSECTIONFields(JNIEnv *env, jobject lpObject, DIBSECTION *lpStruct)
-{
- if (!DIBSECTIONFc.cached) cacheDIBSECTIONFids(env, lpObject);
- setBITMAPFields(env, lpObject, (BITMAP *)lpStruct);
- (*env)->SetIntField(env, lpObject, DIBSECTIONFc.biSize, (jint)lpStruct->dsBmih.biSize);
- (*env)->SetIntField(env, lpObject, DIBSECTIONFc.biWidth, (jint)lpStruct->dsBmih.biWidth);
- (*env)->SetIntField(env, lpObject, DIBSECTIONFc.biHeight, (jint)lpStruct->dsBmih.biHeight);
- (*env)->SetShortField(env, lpObject, DIBSECTIONFc.biPlanes, (jshort)lpStruct->dsBmih.biPlanes);
- (*env)->SetShortField(env, lpObject, DIBSECTIONFc.biBitCount, (jshort)lpStruct->dsBmih.biBitCount);
- (*env)->SetIntField(env, lpObject, DIBSECTIONFc.biCompression, (jint)lpStruct->dsBmih.biCompression);
- (*env)->SetIntField(env, lpObject, DIBSECTIONFc.biSizeImage, (jint)lpStruct->dsBmih.biSizeImage);
- (*env)->SetIntField(env, lpObject, DIBSECTIONFc.biXPelsPerMeter, (jint)lpStruct->dsBmih.biXPelsPerMeter);
- (*env)->SetIntField(env, lpObject, DIBSECTIONFc.biYPelsPerMeter, (jint)lpStruct->dsBmih.biYPelsPerMeter);
- (*env)->SetIntField(env, lpObject, DIBSECTIONFc.biClrUsed, (jint)lpStruct->dsBmih.biClrUsed);
- (*env)->SetIntField(env, lpObject, DIBSECTIONFc.biClrImportant, (jint)lpStruct->dsBmih.biClrImportant);
- (*env)->SetIntField(env, lpObject, DIBSECTIONFc.dsBitfields0, (jint)lpStruct->dsBitfields[0]);
- (*env)->SetIntField(env, lpObject, DIBSECTIONFc.dsBitfields1, (jint)lpStruct->dsBitfields[1]);
- (*env)->SetIntField(env, lpObject, DIBSECTIONFc.dsBitfields2, (jint)lpStruct->dsBitfields[2]);
- (*env)->SetIntField(env, lpObject, DIBSECTIONFc.dshSection, (jint)lpStruct->dshSection);
- (*env)->SetIntField(env, lpObject, DIBSECTIONFc.dsOffset, (jint)lpStruct->dsOffset);
-}
-#endif /* NO_DIBSECTION */
-
-#ifndef NO_DLLVERSIONINFO
-typedef struct DLLVERSIONINFO_FID_CACHE {
- int cached;
- jclass clazz;
- jfieldID cbSize, dwMajorVersion, dwMinorVersion, dwBuildNumber, dwPlatformID;
-} DLLVERSIONINFO_FID_CACHE;
-
-DLLVERSIONINFO_FID_CACHE DLLVERSIONINFOFc;
-
-void cacheDLLVERSIONINFOFids(JNIEnv *env, jobject lpObject)
-{
- if (DLLVERSIONINFOFc.cached) return;
- DLLVERSIONINFOFc.clazz = (*env)->GetObjectClass(env, lpObject);
- DLLVERSIONINFOFc.cbSize = (*env)->GetFieldID(env, DLLVERSIONINFOFc.clazz, "cbSize", "I");
- DLLVERSIONINFOFc.dwMajorVersion = (*env)->GetFieldID(env, DLLVERSIONINFOFc.clazz, "dwMajorVersion", "I");
- DLLVERSIONINFOFc.dwMinorVersion = (*env)->GetFieldID(env, DLLVERSIONINFOFc.clazz, "dwMinorVersion", "I");
- DLLVERSIONINFOFc.dwBuildNumber = (*env)->GetFieldID(env, DLLVERSIONINFOFc.clazz, "dwBuildNumber", "I");
- DLLVERSIONINFOFc.dwPlatformID = (*env)->GetFieldID(env, DLLVERSIONINFOFc.clazz, "dwPlatformID", "I");
- DLLVERSIONINFOFc.cached = 1;
-}
-
-DLLVERSIONINFO *getDLLVERSIONINFOFields(JNIEnv *env, jobject lpObject, DLLVERSIONINFO *lpStruct)
-{
- if (!DLLVERSIONINFOFc.cached) cacheDLLVERSIONINFOFids(env, lpObject);
- lpStruct->cbSize = (*env)->GetIntField(env, lpObject, DLLVERSIONINFOFc.cbSize);
- lpStruct->dwMajorVersion = (*env)->GetIntField(env, lpObject, DLLVERSIONINFOFc.dwMajorVersion);
- lpStruct->dwMinorVersion = (*env)->GetIntField(env, lpObject, DLLVERSIONINFOFc.dwMinorVersion);
- lpStruct->dwBuildNumber = (*env)->GetIntField(env, lpObject, DLLVERSIONINFOFc.dwBuildNumber);
- lpStruct->dwPlatformID = (*env)->GetIntField(env, lpObject, DLLVERSIONINFOFc.dwPlatformID);
- return lpStruct;
-}
-
-void setDLLVERSIONINFOFields(JNIEnv *env, jobject lpObject, DLLVERSIONINFO *lpStruct)
-{
- if (!DLLVERSIONINFOFc.cached) cacheDLLVERSIONINFOFids(env, lpObject);
- (*env)->SetIntField(env, lpObject, DLLVERSIONINFOFc.cbSize, (jint)lpStruct->cbSize);
- (*env)->SetIntField(env, lpObject, DLLVERSIONINFOFc.dwMajorVersion, (jint)lpStruct->dwMajorVersion);
- (*env)->SetIntField(env, lpObject, DLLVERSIONINFOFc.dwMinorVersion, (jint)lpStruct->dwMinorVersion);
- (*env)->SetIntField(env, lpObject, DLLVERSIONINFOFc.dwBuildNumber, (jint)lpStruct->dwBuildNumber);
- (*env)->SetIntField(env, lpObject, DLLVERSIONINFOFc.dwPlatformID, (jint)lpStruct->dwPlatformID);
-}
-#endif /* NO_DLLVERSIONINFO */
-
-#ifndef NO_DOCINFO
-typedef struct DOCINFO_FID_CACHE {
- int cached;
- jclass clazz;
- jfieldID cbSize, lpszDocName, lpszOutput, lpszDatatype, fwType;
-} DOCINFO_FID_CACHE;
-
-DOCINFO_FID_CACHE DOCINFOFc;
-
-void cacheDOCINFOFids(JNIEnv *env, jobject lpObject)
-{
- if (DOCINFOFc.cached) return;
- DOCINFOFc.clazz = (*env)->GetObjectClass(env, lpObject);
- DOCINFOFc.cbSize = (*env)->GetFieldID(env, DOCINFOFc.clazz, "cbSize", "I");
- DOCINFOFc.lpszDocName = (*env)->GetFieldID(env, DOCINFOFc.clazz, "lpszDocName", "I");
- DOCINFOFc.lpszOutput = (*env)->GetFieldID(env, DOCINFOFc.clazz, "lpszOutput", "I");
- DOCINFOFc.lpszDatatype = (*env)->GetFieldID(env, DOCINFOFc.clazz, "lpszDatatype", "I");
- DOCINFOFc.fwType = (*env)->GetFieldID(env, DOCINFOFc.clazz, "fwType", "I");
- DOCINFOFc.cached = 1;
-}
-
-DOCINFO *getDOCINFOFields(JNIEnv *env, jobject lpObject, DOCINFO *lpStruct)
-{
- if (!DOCINFOFc.cached) cacheDOCINFOFids(env, lpObject);
- lpStruct->cbSize = (*env)->GetIntField(env, lpObject, DOCINFOFc.cbSize);
- lpStruct->lpszDocName = (LPCTSTR)(*env)->GetIntField(env, lpObject, DOCINFOFc.lpszDocName);
- lpStruct->lpszOutput = (LPCTSTR)(*env)->GetIntField(env, lpObject, DOCINFOFc.lpszOutput);
- lpStruct->lpszDatatype = (LPCTSTR)(*env)->GetIntField(env, lpObject, DOCINFOFc.lpszDatatype);
- lpStruct->fwType = (*env)->GetIntField(env, lpObject, DOCINFOFc.fwType);
- return lpStruct;
-}
-
-void setDOCINFOFields(JNIEnv *env, jobject lpObject, DOCINFO *lpStruct)
-{
- if (!DOCINFOFc.cached) cacheDOCINFOFids(env, lpObject);
- (*env)->SetIntField(env, lpObject, DOCINFOFc.cbSize, (jint)lpStruct->cbSize);
- (*env)->SetIntField(env, lpObject, DOCINFOFc.lpszDocName, (jint)lpStruct->lpszDocName);
- (*env)->SetIntField(env, lpObject, DOCINFOFc.lpszOutput, (jint)lpStruct->lpszOutput);
- (*env)->SetIntField(env, lpObject, DOCINFOFc.lpszDatatype, (jint)lpStruct->lpszDatatype);
- (*env)->SetIntField(env, lpObject, DOCINFOFc.fwType, (jint)lpStruct->fwType);
-}
-#endif /* NO_DOCINFO */
-
-#ifndef NO_DRAWITEMSTRUCT
-typedef struct DRAWITEMSTRUCT_FID_CACHE {
- int cached;
- jclass clazz;
- jfieldID CtlType, CtlID, itemID, itemAction, itemState, hwndItem, hDC, left, top, bottom, right, itemData;
-} DRAWITEMSTRUCT_FID_CACHE;
-
-DRAWITEMSTRUCT_FID_CACHE DRAWITEMSTRUCTFc;
-
-void cacheDRAWITEMSTRUCTFids(JNIEnv *env, jobject lpObject)
-{
- if (DRAWITEMSTRUCTFc.cached) return;
- DRAWITEMSTRUCTFc.clazz = (*env)->GetObjectClass(env, lpObject);
- DRAWITEMSTRUCTFc.CtlType = (*env)->GetFieldID(env, DRAWITEMSTRUCTFc.clazz, "CtlType", "I");
- DRAWITEMSTRUCTFc.CtlID = (*env)->GetFieldID(env, DRAWITEMSTRUCTFc.clazz, "CtlID", "I");
- DRAWITEMSTRUCTFc.itemID = (*env)->GetFieldID(env, DRAWITEMSTRUCTFc.clazz, "itemID", "I");
- DRAWITEMSTRUCTFc.itemAction = (*env)->GetFieldID(env, DRAWITEMSTRUCTFc.clazz, "itemAction", "I");
- DRAWITEMSTRUCTFc.itemState = (*env)->GetFieldID(env, DRAWITEMSTRUCTFc.clazz, "itemState", "I");
- DRAWITEMSTRUCTFc.hwndItem = (*env)->GetFieldID(env, DRAWITEMSTRUCTFc.clazz, "hwndItem", "I");
- DRAWITEMSTRUCTFc.hDC = (*env)->GetFieldID(env, DRAWITEMSTRUCTFc.clazz, "hDC", "I");
- DRAWITEMSTRUCTFc.left = (*env)->GetFieldID(env, DRAWITEMSTRUCTFc.clazz, "left", "I");
- DRAWITEMSTRUCTFc.top = (*env)->GetFieldID(env, DRAWITEMSTRUCTFc.clazz, "top", "I");
- DRAWITEMSTRUCTFc.bottom = (*env)->GetFieldID(env, DRAWITEMSTRUCTFc.clazz, "bottom", "I");
- DRAWITEMSTRUCTFc.right = (*env)->GetFieldID(env, DRAWITEMSTRUCTFc.clazz, "right", "I");
- DRAWITEMSTRUCTFc.itemData = (*env)->GetFieldID(env, DRAWITEMSTRUCTFc.clazz, "itemData", "I");
- DRAWITEMSTRUCTFc.cached = 1;
-}
-
-DRAWITEMSTRUCT *getDRAWITEMSTRUCTFields(JNIEnv *env, jobject lpObject, DRAWITEMSTRUCT *lpStruct)
-{
- if (!DRAWITEMSTRUCTFc.cached) cacheDRAWITEMSTRUCTFids(env, lpObject);
- lpStruct->CtlType = (*env)->GetIntField(env, lpObject, DRAWITEMSTRUCTFc.CtlType);
- lpStruct->CtlID = (*env)->GetIntField(env, lpObject, DRAWITEMSTRUCTFc.CtlID);
- lpStruct->itemID = (*env)->GetIntField(env, lpObject, DRAWITEMSTRUCTFc.itemID);
- lpStruct->itemAction = (*env)->GetIntField(env, lpObject, DRAWITEMSTRUCTFc.itemAction);
- lpStruct->itemState = (*env)->GetIntField(env, lpObject, DRAWITEMSTRUCTFc.itemState);
- lpStruct->hwndItem = (HWND)(*env)->GetIntField(env, lpObject, DRAWITEMSTRUCTFc.hwndItem);
- lpStruct->hDC = (HDC)(*env)->GetIntField(env, lpObject, DRAWITEMSTRUCTFc.hDC);
- lpStruct->rcItem.left = (*env)->GetIntField(env, lpObject, DRAWITEMSTRUCTFc.left);
- lpStruct->rcItem.top = (*env)->GetIntField(env, lpObject, DRAWITEMSTRUCTFc.top);
- lpStruct->rcItem.bottom = (*env)->GetIntField(env, lpObject, DRAWITEMSTRUCTFc.bottom);
- lpStruct->rcItem.right = (*env)->GetIntField(env, lpObject, DRAWITEMSTRUCTFc.right);
- lpStruct->itemData = (*env)->GetIntField(env, lpObject, DRAWITEMSTRUCTFc.itemData);
- return lpStruct;
-}
-
-void setDRAWITEMSTRUCTFields(JNIEnv *env, jobject lpObject, DRAWITEMSTRUCT *lpStruct)
-{
- if (!DRAWITEMSTRUCTFc.cached) cacheDRAWITEMSTRUCTFids(env, lpObject);
- (*env)->SetIntField(env, lpObject, DRAWITEMSTRUCTFc.CtlType, (jint)lpStruct->CtlType);
- (*env)->SetIntField(env, lpObject, DRAWITEMSTRUCTFc.CtlID, (jint)lpStruct->CtlID);
- (*env)->SetIntField(env, lpObject, DRAWITEMSTRUCTFc.itemID, (jint)lpStruct->itemID);
- (*env)->SetIntField(env, lpObject, DRAWITEMSTRUCTFc.itemAction, (jint)lpStruct->itemAction);
- (*env)->SetIntField(env, lpObject, DRAWITEMSTRUCTFc.itemState, (jint)lpStruct->itemState);
- (*env)->SetIntField(env, lpObject, DRAWITEMSTRUCTFc.hwndItem, (jint)lpStruct->hwndItem);
- (*env)->SetIntField(env, lpObject, DRAWITEMSTRUCTFc.hDC, (jint)lpStruct->hDC);
- (*env)->SetIntField(env, lpObject, DRAWITEMSTRUCTFc.left, (jint)lpStruct->rcItem.left);
- (*env)->SetIntField(env, lpObject, DRAWITEMSTRUCTFc.top, (jint)lpStruct->rcItem.top);
- (*env)->SetIntField(env, lpObject, DRAWITEMSTRUCTFc.bottom, (jint)lpStruct->rcItem.bottom);
- (*env)->SetIntField(env, lpObject, DRAWITEMSTRUCTFc.right, (jint)lpStruct->rcItem.right);
- (*env)->SetIntField(env, lpObject, DRAWITEMSTRUCTFc.itemData, (jint)lpStruct->itemData);
-}
-#endif /* NO_DRAWITEMSTRUCT */
-
-#ifndef NO_DROPFILES
-typedef struct DROPFILES_FID_CACHE {
- int cached;
- jclass clazz;
- jfieldID pFiles, pt_x, pt_y, fNC, fWide;
-} DROPFILES_FID_CACHE;
-
-DROPFILES_FID_CACHE DROPFILESFc;
-
-void cacheDROPFILESFids(JNIEnv *env, jobject lpObject)
-{
- if (DROPFILESFc.cached) return;
- DROPFILESFc.clazz = (*env)->GetObjectClass(env, lpObject);
- DROPFILESFc.pFiles = (*env)->GetFieldID(env, DROPFILESFc.clazz, "pFiles", "I");
- DROPFILESFc.pt_x = (*env)->GetFieldID(env, DROPFILESFc.clazz, "pt_x", "I");
- DROPFILESFc.pt_y = (*env)->GetFieldID(env, DROPFILESFc.clazz, "pt_y", "I");
- DROPFILESFc.fNC = (*env)->GetFieldID(env, DROPFILESFc.clazz, "fNC", "I");
- DROPFILESFc.fWide = (*env)->GetFieldID(env, DROPFILESFc.clazz, "fWide", "I");
- DROPFILESFc.cached = 1;
-}
-
-DROPFILES *getDROPFILESFields(JNIEnv *env, jobject lpObject, DROPFILES *lpStruct)
-{
- if (!DROPFILESFc.cached) cacheDROPFILESFids(env, lpObject);
- lpStruct->pFiles = (*env)->GetIntField(env, lpObject, DROPFILESFc.pFiles);
- lpStruct->pt.x = (*env)->GetIntField(env, lpObject, DROPFILESFc.pt_x);
- lpStruct->pt.y = (*env)->GetIntField(env, lpObject, DROPFILESFc.pt_y);
- lpStruct->fNC = (*env)->GetIntField(env, lpObject, DROPFILESFc.fNC);
- lpStruct->fWide = (*env)->GetIntField(env, lpObject, DROPFILESFc.fWide);
- return lpStruct;
-}
-
-void setDROPFILESFields(JNIEnv *env, jobject lpObject, DROPFILES *lpStruct)
-{
- if (!DROPFILESFc.cached) cacheDROPFILESFids(env, lpObject);
- (*env)->SetIntField(env, lpObject, DROPFILESFc.pFiles, (jint)lpStruct->pFiles);
- (*env)->SetIntField(env, lpObject, DROPFILESFc.pt_x, (jint)lpStruct->pt.x);
- (*env)->SetIntField(env, lpObject, DROPFILESFc.pt_y, (jint)lpStruct->pt.y);
- (*env)->SetIntField(env, lpObject, DROPFILESFc.fNC, (jint)lpStruct->fNC);
- (*env)->SetIntField(env, lpObject, DROPFILESFc.fWide, (jint)lpStruct->fWide);
-}
-#endif /* NO_DROPFILES */
-
-#ifndef NO_FILETIME
-typedef struct FILETIME_FID_CACHE {
- int cached;
- jclass clazz;
- jfieldID dwLowDateTime, dwHighDateTime;
-} FILETIME_FID_CACHE;
-
-FILETIME_FID_CACHE FILETIMEFc;
-
-void cacheFILETIMEFids(JNIEnv *env, jobject lpObject)
-{
- if (FILETIMEFc.cached) return;
- FILETIMEFc.clazz = (*env)->GetObjectClass(env, lpObject);
- FILETIMEFc.dwLowDateTime = (*env)->GetFieldID(env, FILETIMEFc.clazz, "dwLowDateTime", "I");
- FILETIMEFc.dwHighDateTime = (*env)->GetFieldID(env, FILETIMEFc.clazz, "dwHighDateTime", "I");
- FILETIMEFc.cached = 1;
-}
-
-FILETIME *getFILETIMEFields(JNIEnv *env, jobject lpObject, FILETIME *lpStruct)
-{
- if (!FILETIMEFc.cached) cacheFILETIMEFids(env, lpObject);
- lpStruct->dwLowDateTime = (*env)->GetIntField(env, lpObject, FILETIMEFc.dwLowDateTime);
- lpStruct->dwHighDateTime = (*env)->GetIntField(env, lpObject, FILETIMEFc.dwHighDateTime);
- return lpStruct;
-}
-
-void setFILETIMEFields(JNIEnv *env, jobject lpObject, FILETIME *lpStruct)
-{
- if (!FILETIMEFc.cached) cacheFILETIMEFids(env, lpObject);
- (*env)->SetIntField(env, lpObject, FILETIMEFc.dwLowDateTime, (jint)lpStruct->dwLowDateTime);
- (*env)->SetIntField(env, lpObject, FILETIMEFc.dwHighDateTime, (jint)lpStruct->dwHighDateTime);
-}
-#endif /* NO_FILETIME */
-
-#ifndef NO_GCP_RESULTS
-typedef struct GCP_RESULTS_FID_CACHE {
- int cached;
- jclass clazz;
- jfieldID lStructSize, lpOutString, lpOrder, lpDx, lpCaretPos, lpClass, lpGlyphs, nGlyphs, nMaxFit;
-} GCP_RESULTS_FID_CACHE;
-
-GCP_RESULTS_FID_CACHE GCP_RESULTSFc;
-
-void cacheGCP_RESULTSFids(JNIEnv *env, jobject lpObject)
-{
- if (GCP_RESULTSFc.cached) return;
- GCP_RESULTSFc.clazz = (*env)->GetObjectClass(env, lpObject);
- GCP_RESULTSFc.lStructSize = (*env)->GetFieldID(env, GCP_RESULTSFc.clazz, "lStructSize", "I");
- GCP_RESULTSFc.lpOutString = (*env)->GetFieldID(env, GCP_RESULTSFc.clazz, "lpOutString", "I");
- GCP_RESULTSFc.lpOrder = (*env)->GetFieldID(env, GCP_RESULTSFc.clazz, "lpOrder", "I");
- GCP_RESULTSFc.lpDx = (*env)->GetFieldID(env, GCP_RESULTSFc.clazz, "lpDx", "I");
- GCP_RESULTSFc.lpCaretPos = (*env)->GetFieldID(env, GCP_RESULTSFc.clazz, "lpCaretPos", "I");
- GCP_RESULTSFc.lpClass = (*env)->GetFieldID(env, GCP_RESULTSFc.clazz, "lpClass", "I");
- GCP_RESULTSFc.lpGlyphs = (*env)->GetFieldID(env, GCP_RESULTSFc.clazz, "lpGlyphs", "I");
- GCP_RESULTSFc.nGlyphs = (*env)->GetFieldID(env, GCP_RESULTSFc.clazz, "nGlyphs", "I");
- GCP_RESULTSFc.nMaxFit = (*env)->GetFieldID(env, GCP_RESULTSFc.clazz, "nMaxFit", "I");
- GCP_RESULTSFc.cached = 1;
-}
-
-GCP_RESULTS *getGCP_RESULTSFields(JNIEnv *env, jobject lpObject, GCP_RESULTS *lpStruct)
-{
- if (!GCP_RESULTSFc.cached) cacheGCP_RESULTSFids(env, lpObject);
- lpStruct->lStructSize = (*env)->GetIntField(env, lpObject, GCP_RESULTSFc.lStructSize);
- lpStruct->lpOutString = (LPTSTR)(*env)->GetIntField(env, lpObject, GCP_RESULTSFc.lpOutString);
- lpStruct->lpOrder = (UINT *)(*env)->GetIntField(env, lpObject, GCP_RESULTSFc.lpOrder);
- lpStruct->lpDx = (int *)(*env)->GetIntField(env, lpObject, GCP_RESULTSFc.lpDx);
- lpStruct->lpCaretPos = (int *)(*env)->GetIntField(env, lpObject, GCP_RESULTSFc.lpCaretPos);
- lpStruct->lpClass = (LPSTR)(*env)->GetIntField(env, lpObject, GCP_RESULTSFc.lpClass);
- lpStruct->lpGlyphs = (LPWSTR)(*env)->GetIntField(env, lpObject, GCP_RESULTSFc.lpGlyphs);
- lpStruct->nGlyphs = (*env)->GetIntField(env, lpObject, GCP_RESULTSFc.nGlyphs);
- lpStruct->nMaxFit = (*env)->GetIntField(env, lpObject, GCP_RESULTSFc.nMaxFit);
- return lpStruct;
-}
-
-void setGCP_RESULTSFields(JNIEnv *env, jobject lpObject, GCP_RESULTS *lpStruct)
-{
- if (!GCP_RESULTSFc.cached) cacheGCP_RESULTSFids(env, lpObject);
- (*env)->SetIntField(env, lpObject, GCP_RESULTSFc.lStructSize, (jint)lpStruct->lStructSize);
- (*env)->SetIntField(env, lpObject, GCP_RESULTSFc.lpOutString, (jint)lpStruct->lpOutString);
- (*env)->SetIntField(env, lpObject, GCP_RESULTSFc.lpOrder, (jint)lpStruct->lpOrder);
- (*env)->SetIntField(env, lpObject, GCP_RESULTSFc.lpDx, (jint)lpStruct->lpDx);
- (*env)->SetIntField(env, lpObject, GCP_RESULTSFc.lpCaretPos, (jint)lpStruct->lpCaretPos);
- (*env)->SetIntField(env, lpObject, GCP_RESULTSFc.lpClass, (jint)lpStruct->lpClass);
- (*env)->SetIntField(env, lpObject, GCP_RESULTSFc.lpGlyphs, (jint)lpStruct->lpGlyphs);
- (*env)->SetIntField(env, lpObject, GCP_RESULTSFc.nGlyphs, (jint)lpStruct->nGlyphs);
- (*env)->SetIntField(env, lpObject, GCP_RESULTSFc.nMaxFit, (jint)lpStruct->nMaxFit);
-}
-#endif /* NO_GCP_RESULTS */
-
-#ifndef NO_GRADIENT_RECT
-typedef struct GRADIENT_RECT_FID_CACHE {
- int cached;
- jclass clazz;
- jfieldID UpperLeft, LowerRight;
-} GRADIENT_RECT_FID_CACHE;
-
-GRADIENT_RECT_FID_CACHE GRADIENT_RECTFc;
-
-void cacheGRADIENT_RECTFids(JNIEnv *env, jobject lpObject)
-{
- if (GRADIENT_RECTFc.cached) return;
- GRADIENT_RECTFc.clazz = (*env)->GetObjectClass(env, lpObject);
- GRADIENT_RECTFc.UpperLeft = (*env)->GetFieldID(env, GRADIENT_RECTFc.clazz, "UpperLeft", "I");
- GRADIENT_RECTFc.LowerRight = (*env)->GetFieldID(env, GRADIENT_RECTFc.clazz, "LowerRight", "I");
- GRADIENT_RECTFc.cached = 1;
-}
-
-GRADIENT_RECT *getGRADIENT_RECTFields(JNIEnv *env, jobject lpObject, GRADIENT_RECT *lpStruct)
-{
- if (!GRADIENT_RECTFc.cached) cacheGRADIENT_RECTFids(env, lpObject);
- lpStruct->UpperLeft = (*env)->GetIntField(env, lpObject, GRADIENT_RECTFc.UpperLeft);
- lpStruct->LowerRight = (*env)->GetIntField(env, lpObject, GRADIENT_RECTFc.LowerRight);
- return lpStruct;
-}
-
-void setGRADIENT_RECTFields(JNIEnv *env, jobject lpObject, GRADIENT_RECT *lpStruct)
-{
- if (!GRADIENT_RECTFc.cached) cacheGRADIENT_RECTFids(env, lpObject);
- (*env)->SetIntField(env, lpObject, GRADIENT_RECTFc.UpperLeft, (jint)lpStruct->UpperLeft);
- (*env)->SetIntField(env, lpObject, GRADIENT_RECTFc.LowerRight, (jint)lpStruct->LowerRight);
-}
-#endif /* NO_GRADIENT_RECT */
-
-#ifndef NO_HDITEM
-typedef struct HDITEM_FID_CACHE {
- int cached;
- jclass clazz;
- jfieldID mask, cxy, pszText, hbm, cchTextMax, fmt, lParam, iImage, iOrder;
-} HDITEM_FID_CACHE;
-
-HDITEM_FID_CACHE HDITEMFc;
-
-void cacheHDITEMFids(JNIEnv *env, jobject lpObject)
-{
- if (HDITEMFc.cached) return;
- HDITEMFc.clazz = (*env)->GetObjectClass(env, lpObject);
- HDITEMFc.mask = (*env)->GetFieldID(env, HDITEMFc.clazz, "mask", "I");
- HDITEMFc.cxy = (*env)->GetFieldID(env, HDITEMFc.clazz, "cxy", "I");
- HDITEMFc.pszText = (*env)->GetFieldID(env, HDITEMFc.clazz, "pszText", "I");
- HDITEMFc.hbm = (*env)->GetFieldID(env, HDITEMFc.clazz, "hbm", "I");
- HDITEMFc.cchTextMax = (*env)->GetFieldID(env, HDITEMFc.clazz, "cchTextMax", "I");
- HDITEMFc.fmt = (*env)->GetFieldID(env, HDITEMFc.clazz, "fmt", "I");
- HDITEMFc.lParam = (*env)->GetFieldID(env, HDITEMFc.clazz, "lParam", "I");
- HDITEMFc.iImage = (*env)->GetFieldID(env, HDITEMFc.clazz, "iImage", "I");
- HDITEMFc.iOrder = (*env)->GetFieldID(env, HDITEMFc.clazz, "iOrder", "I");
- HDITEMFc.cached = 1;
-}
-
-HDITEM *getHDITEMFields(JNIEnv *env, jobject lpObject, HDITEM *lpStruct)
-{
- if (!HDITEMFc.cached) cacheHDITEMFids(env, lpObject);
- lpStruct->mask = (*env)->GetIntField(env, lpObject, HDITEMFc.mask);
- lpStruct->cxy = (*env)->GetIntField(env, lpObject, HDITEMFc.cxy);
- lpStruct->pszText = (LPTSTR)(*env)->GetIntField(env, lpObject, HDITEMFc.pszText);
- lpStruct->hbm = (HBITMAP)(*env)->GetIntField(env, lpObject, HDITEMFc.hbm);
- lpStruct->cchTextMax = (*env)->GetIntField(env, lpObject, HDITEMFc.cchTextMax);
- lpStruct->fmt = (*env)->GetIntField(env, lpObject, HDITEMFc.fmt);
- lpStruct->lParam = (*env)->GetIntField(env, lpObject, HDITEMFc.lParam);
- lpStruct->iImage = (*env)->GetIntField(env, lpObject, HDITEMFc.iImage);
- lpStruct->iOrder = (*env)->GetIntField(env, lpObject, HDITEMFc.iOrder);
- return lpStruct;
-}
-
-void setHDITEMFields(JNIEnv *env, jobject lpObject, HDITEM *lpStruct)
-{
- if (!HDITEMFc.cached) cacheHDITEMFids(env, lpObject);
- (*env)->SetIntField(env, lpObject, HDITEMFc.mask, (jint)lpStruct->mask);
- (*env)->SetIntField(env, lpObject, HDITEMFc.cxy, (jint)lpStruct->cxy);
- (*env)->SetIntField(env, lpObject, HDITEMFc.pszText, (jint)lpStruct->pszText);
- (*env)->SetIntField(env, lpObject, HDITEMFc.hbm, (jint)lpStruct->hbm);
- (*env)->SetIntField(env, lpObject, HDITEMFc.cchTextMax, (jint)lpStruct->cchTextMax);
- (*env)->SetIntField(env, lpObject, HDITEMFc.fmt, (jint)lpStruct->fmt);
- (*env)->SetIntField(env, lpObject, HDITEMFc.lParam, (jint)lpStruct->lParam);
- (*env)->SetIntField(env, lpObject, HDITEMFc.iImage, (jint)lpStruct->iImage);
- (*env)->SetIntField(env, lpObject, HDITEMFc.iOrder, (jint)lpStruct->iOrder);
-}
-#endif /* NO_HDITEM */
-
-#ifndef NO_HELPINFO
-typedef struct HELPINFO_FID_CACHE {
- int cached;
- jclass clazz;
- jfieldID cbSize, iContextType, iCtrlId, hItemHandle, dwContextId, x, y;
-} HELPINFO_FID_CACHE;
-
-HELPINFO_FID_CACHE HELPINFOFc;
-
-void cacheHELPINFOFids(JNIEnv *env, jobject lpObject)
-{
- if (HELPINFOFc.cached) return;
- HELPINFOFc.clazz = (*env)->GetObjectClass(env, lpObject);
- HELPINFOFc.cbSize = (*env)->GetFieldID(env, HELPINFOFc.clazz, "cbSize", "I");
- HELPINFOFc.iContextType = (*env)->GetFieldID(env, HELPINFOFc.clazz, "iContextType", "I");
- HELPINFOFc.iCtrlId = (*env)->GetFieldID(env, HELPINFOFc.clazz, "iCtrlId", "I");
- HELPINFOFc.hItemHandle = (*env)->GetFieldID(env, HELPINFOFc.clazz, "hItemHandle", "I");
- HELPINFOFc.dwContextId = (*env)->GetFieldID(env, HELPINFOFc.clazz, "dwContextId", "I");
- HELPINFOFc.x = (*env)->GetFieldID(env, HELPINFOFc.clazz, "x", "I");
- HELPINFOFc.y = (*env)->GetFieldID(env, HELPINFOFc.clazz, "y", "I");
- HELPINFOFc.cached = 1;
-}
-
-HELPINFO *getHELPINFOFields(JNIEnv *env, jobject lpObject, HELPINFO *lpStruct)
-{
- if (!HELPINFOFc.cached) cacheHELPINFOFids(env, lpObject);
- lpStruct->cbSize = (*env)->GetIntField(env, lpObject, HELPINFOFc.cbSize);
- lpStruct->iContextType = (*env)->GetIntField(env, lpObject, HELPINFOFc.iContextType);
- lpStruct->iCtrlId = (*env)->GetIntField(env, lpObject, HELPINFOFc.iCtrlId);
- lpStruct->hItemHandle = (HANDLE)(*env)->GetIntField(env, lpObject, HELPINFOFc.hItemHandle);
- lpStruct->dwContextId = (*env)->GetIntField(env, lpObject, HELPINFOFc.dwContextId);
- lpStruct->MousePos.x = (*env)->GetIntField(env, lpObject, HELPINFOFc.x);
- lpStruct->MousePos.y = (*env)->GetIntField(env, lpObject, HELPINFOFc.y);
- return lpStruct;
-}
-
-void setHELPINFOFields(JNIEnv *env, jobject lpObject, HELPINFO *lpStruct)
-{
- if (!HELPINFOFc.cached) cacheHELPINFOFids(env, lpObject);
- (*env)->SetIntField(env, lpObject, HELPINFOFc.cbSize, (jint)lpStruct->cbSize);
- (*env)->SetIntField(env, lpObject, HELPINFOFc.iContextType, (jint)lpStruct->iContextType);
- (*env)->SetIntField(env, lpObject, HELPINFOFc.iCtrlId, (jint)lpStruct->iCtrlId);
- (*env)->SetIntField(env, lpObject, HELPINFOFc.hItemHandle, (jint)lpStruct->hItemHandle);
- (*env)->SetIntField(env, lpObject, HELPINFOFc.dwContextId, (jint)lpStruct->dwContextId);
- (*env)->SetIntField(env, lpObject, HELPINFOFc.x, (jint)lpStruct->MousePos.x);
- (*env)->SetIntField(env, lpObject, HELPINFOFc.y, (jint)lpStruct->MousePos.y);
-}
-#endif /* NO_HELPINFO */
-
-#ifndef NO_ICONINFO
-typedef struct ICONINFO_FID_CACHE {
- int cached;
- jclass clazz;
- jfieldID fIcon, xHotspot, yHotspot, hbmMask, hbmColor;
-} ICONINFO_FID_CACHE;
-
-ICONINFO_FID_CACHE ICONINFOFc;
-
-void cacheICONINFOFids(JNIEnv *env, jobject lpObject)
-{
- if (ICONINFOFc.cached) return;
- ICONINFOFc.clazz = (*env)->GetObjectClass(env, lpObject);
- ICONINFOFc.fIcon = (*env)->GetFieldID(env, ICONINFOFc.clazz, "fIcon", "Z");
- ICONINFOFc.xHotspot = (*env)->GetFieldID(env, ICONINFOFc.clazz, "xHotspot", "I");
- ICONINFOFc.yHotspot = (*env)->GetFieldID(env, ICONINFOFc.clazz, "yHotspot", "I");
- ICONINFOFc.hbmMask = (*env)->GetFieldID(env, ICONINFOFc.clazz, "hbmMask", "I");
- ICONINFOFc.hbmColor = (*env)->GetFieldID(env, ICONINFOFc.clazz, "hbmColor", "I");
- ICONINFOFc.cached = 1;
-}
-
-ICONINFO *getICONINFOFields(JNIEnv *env, jobject lpObject, ICONINFO *lpStruct)
-{
- if (!ICONINFOFc.cached) cacheICONINFOFids(env, lpObject);
- lpStruct->fIcon = (*env)->GetBooleanField(env, lpObject, ICONINFOFc.fIcon);
- lpStruct->xHotspot = (*env)->GetIntField(env, lpObject, ICONINFOFc.xHotspot);
- lpStruct->yHotspot = (*env)->GetIntField(env, lpObject, ICONINFOFc.yHotspot);
- lpStruct->hbmMask = (HBITMAP)(*env)->GetIntField(env, lpObject, ICONINFOFc.hbmMask);
- lpStruct->hbmColor = (HBITMAP)(*env)->GetIntField(env, lpObject, ICONINFOFc.hbmColor);
- return lpStruct;
-}
-
-void setICONINFOFields(JNIEnv *env, jobject lpObject, ICONINFO *lpStruct)
-{
- if (!ICONINFOFc.cached) cacheICONINFOFids(env, lpObject);
- (*env)->SetBooleanField(env, lpObject, ICONINFOFc.fIcon, (jboolean)lpStruct->fIcon);
- (*env)->SetIntField(env, lpObject, ICONINFOFc.xHotspot, (jint)lpStruct->xHotspot);
- (*env)->SetIntField(env, lpObject, ICONINFOFc.yHotspot, (jint)lpStruct->yHotspot);
- (*env)->SetIntField(env, lpObject, ICONINFOFc.hbmMask, (jint)lpStruct->hbmMask);
- (*env)->SetIntField(env, lpObject, ICONINFOFc.hbmColor, (jint)lpStruct->hbmColor);
-}
-#endif /* NO_ICONINFO */
-
-#ifndef NO_INITCOMMONCONTROLSEX
-typedef struct INITCOMMONCONTROLSEX_FID_CACHE {
- int cached;
- jclass clazz;
- jfieldID dwSize, dwICC;
-} INITCOMMONCONTROLSEX_FID_CACHE;
-
-INITCOMMONCONTROLSEX_FID_CACHE INITCOMMONCONTROLSEXFc;
-
-void cacheINITCOMMONCONTROLSEXFids(JNIEnv *env, jobject lpObject)
-{
- if (INITCOMMONCONTROLSEXFc.cached) return;
- INITCOMMONCONTROLSEXFc.clazz = (*env)->GetObjectClass(env, lpObject);
- INITCOMMONCONTROLSEXFc.dwSize = (*env)->GetFieldID(env, INITCOMMONCONTROLSEXFc.clazz, "dwSize", "I");
- INITCOMMONCONTROLSEXFc.dwICC = (*env)->GetFieldID(env, INITCOMMONCONTROLSEXFc.clazz, "dwICC", "I");
- INITCOMMONCONTROLSEXFc.cached = 1;
-}
-
-INITCOMMONCONTROLSEX *getINITCOMMONCONTROLSEXFields(JNIEnv *env, jobject lpObject, INITCOMMONCONTROLSEX *lpStruct)
-{
- if (!INITCOMMONCONTROLSEXFc.cached) cacheINITCOMMONCONTROLSEXFids(env, lpObject);
- lpStruct->dwSize = (*env)->GetIntField(env, lpObject, INITCOMMONCONTROLSEXFc.dwSize);
- lpStruct->dwICC = (*env)->GetIntField(env, lpObject, INITCOMMONCONTROLSEXFc.dwICC);
- return lpStruct;
-}
-
-void setINITCOMMONCONTROLSEXFields(JNIEnv *env, jobject lpObject, INITCOMMONCONTROLSEX *lpStruct)
-{
- if (!INITCOMMONCONTROLSEXFc.cached) cacheINITCOMMONCONTROLSEXFids(env, lpObject);
- (*env)->SetIntField(env, lpObject, INITCOMMONCONTROLSEXFc.dwSize, (jint)lpStruct->dwSize);
- (*env)->SetIntField(env, lpObject, INITCOMMONCONTROLSEXFc.dwICC, (jint)lpStruct->dwICC);
-}
-#endif /* NO_INITCOMMONCONTROLSEX */
-
-#ifndef NO_LOGBRUSH
-typedef struct LOGBRUSH_FID_CACHE {
- int cached;
- jclass clazz;
- jfieldID lbStyle, lbColor, lbHatch;
-} LOGBRUSH_FID_CACHE;
-
-LOGBRUSH_FID_CACHE LOGBRUSHFc;
-
-void cacheLOGBRUSHFids(JNIEnv *env, jobject lpObject)
-{
- if (LOGBRUSHFc.cached) return;
- LOGBRUSHFc.clazz = (*env)->GetObjectClass(env, lpObject);
- LOGBRUSHFc.lbStyle = (*env)->GetFieldID(env, LOGBRUSHFc.clazz, "lbStyle", "I");
- LOGBRUSHFc.lbColor = (*env)->GetFieldID(env, LOGBRUSHFc.clazz, "lbColor", "I");
- LOGBRUSHFc.lbHatch = (*env)->GetFieldID(env, LOGBRUSHFc.clazz, "lbHatch", "I");
- LOGBRUSHFc.cached = 1;
-}
-
-LOGBRUSH *getLOGBRUSHFields(JNIEnv *env, jobject lpObject, LOGBRUSH *lpStruct)
-{
- if (!LOGBRUSHFc.cached) cacheLOGBRUSHFids(env, lpObject);
- lpStruct->lbStyle = (*env)->GetIntField(env, lpObject, LOGBRUSHFc.lbStyle);
- lpStruct->lbColor = (*env)->GetIntField(env, lpObject, LOGBRUSHFc.lbColor);
- lpStruct->lbHatch = (*env)->GetIntField(env, lpObject, LOGBRUSHFc.lbHatch);
- return lpStruct;
-}
-
-void setLOGBRUSHFields(JNIEnv *env, jobject lpObject, LOGBRUSH *lpStruct)
-{
- if (!LOGBRUSHFc.cached) cacheLOGBRUSHFids(env, lpObject);
- (*env)->SetIntField(env, lpObject, LOGBRUSHFc.lbStyle, (jint)lpStruct->lbStyle);
- (*env)->SetIntField(env, lpObject, LOGBRUSHFc.lbColor, (jint)lpStruct->lbColor);
- (*env)->SetIntField(env, lpObject, LOGBRUSHFc.lbHatch, (jint)lpStruct->lbHatch);
-}
-#endif /* NO_LOGBRUSH */
-
-#ifndef NO_LOGFONT
-typedef struct LOGFONT_FID_CACHE {
- int cached;
- jclass clazz;
- 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;
-
-LOGFONT_FID_CACHE LOGFONTFc;
-
-void cacheLOGFONTFids(JNIEnv *env, jobject lpObject)
-{
- if (LOGFONTFc.cached) return;
- LOGFONTFc.clazz = (*env)->GetObjectClass(env, lpObject);
- LOGFONTFc.lfHeight = (*env)->GetFieldID(env, LOGFONTFc.clazz, "lfHeight", "I");
- LOGFONTFc.lfWidth = (*env)->GetFieldID(env, LOGFONTFc.clazz, "lfWidth", "I");
- LOGFONTFc.lfEscapement = (*env)->GetFieldID(env, LOGFONTFc.clazz, "lfEscapement", "I");
- LOGFONTFc.lfOrientation = (*env)->GetFieldID(env, LOGFONTFc.clazz, "lfOrientation", "I");
- LOGFONTFc.lfWeight = (*env)->GetFieldID(env, LOGFONTFc.clazz, "lfWeight", "I");
- LOGFONTFc.lfItalic = (*env)->GetFieldID(env, LOGFONTFc.clazz, "lfItalic", "B");
- LOGFONTFc.lfUnderline = (*env)->GetFieldID(env, LOGFONTFc.clazz, "lfUnderline", "B");
- LOGFONTFc.lfStrikeOut = (*env)->GetFieldID(env, LOGFONTFc.clazz, "lfStrikeOut", "B");
- LOGFONTFc.lfCharSet = (*env)->GetFieldID(env, LOGFONTFc.clazz, "lfCharSet", "B");
- LOGFONTFc.lfOutPrecision = (*env)->GetFieldID(env, LOGFONTFc.clazz, "lfOutPrecision", "B");
- LOGFONTFc.lfClipPrecision = (*env)->GetFieldID(env, LOGFONTFc.clazz, "lfClipPrecision", "B");
- LOGFONTFc.lfQuality = (*env)->GetFieldID(env, LOGFONTFc.clazz, "lfQuality", "B");
- LOGFONTFc.lfPitchAndFamily = (*env)->GetFieldID(env, LOGFONTFc.clazz, "lfPitchAndFamily", "B");
- LOGFONTFc.lfFaceName0 = (*env)->GetFieldID(env, LOGFONTFc.clazz, "lfFaceName0", "C");
- LOGFONTFc.lfFaceName1 = (*env)->GetFieldID(env, LOGFONTFc.clazz, "lfFaceName1", "C");
- LOGFONTFc.lfFaceName2 = (*env)->GetFieldID(env, LOGFONTFc.clazz, "lfFaceName2", "C");
- LOGFONTFc.lfFaceName3 = (*env)->GetFieldID(env, LOGFONTFc.clazz, "lfFaceName3", "C");
- LOGFONTFc.lfFaceName4 = (*env)->GetFieldID(env, LOGFONTFc.clazz, "lfFaceName4", "C");
- LOGFONTFc.lfFaceName5 = (*env)->GetFieldID(env, LOGFONTFc.clazz, "lfFaceName5", "C");
- LOGFONTFc.lfFaceName6 = (*env)->GetFieldID(env, LOGFONTFc.clazz, "lfFaceName6", "C");
- LOGFONTFc.lfFaceName7 = (*env)->GetFieldID(env, LOGFONTFc.clazz, "lfFaceName7", "C");
- LOGFONTFc.lfFaceName8 = (*env)->GetFieldID(env, LOGFONTFc.clazz, "lfFaceName8", "C");
- LOGFONTFc.lfFaceName9 = (*env)->GetFieldID(env, LOGFONTFc.clazz, "lfFaceName9", "C");
- LOGFONTFc.lfFaceName10 = (*env)->GetFieldID(env, LOGFONTFc.clazz, "lfFaceName10", "C");
- LOGFONTFc.lfFaceName11 = (*env)->GetFieldID(env, LOGFONTFc.clazz, "lfFaceName11", "C");
- LOGFONTFc.lfFaceName12 = (*env)->GetFieldID(env, LOGFONTFc.clazz, "lfFaceName12", "C");
- LOGFONTFc.lfFaceName13 = (*env)->GetFieldID(env, LOGFONTFc.clazz, "lfFaceName13", "C");
- LOGFONTFc.lfFaceName14 = (*env)->GetFieldID(env, LOGFONTFc.clazz, "lfFaceName14", "C");
- LOGFONTFc.lfFaceName15 = (*env)->GetFieldID(env, LOGFONTFc.clazz, "lfFaceName15", "C");
- LOGFONTFc.lfFaceName16 = (*env)->GetFieldID(env, LOGFONTFc.clazz, "lfFaceName16", "C");
- LOGFONTFc.lfFaceName17 = (*env)->GetFieldID(env, LOGFONTFc.clazz, "lfFaceName17", "C");
- LOGFONTFc.lfFaceName18 = (*env)->GetFieldID(env, LOGFONTFc.clazz, "lfFaceName18", "C");
- LOGFONTFc.lfFaceName19 = (*env)->GetFieldID(env, LOGFONTFc.clazz, "lfFaceName19", "C");
- LOGFONTFc.lfFaceName20 = (*env)->GetFieldID(env, LOGFONTFc.clazz, "lfFaceName20", "C");
- LOGFONTFc.lfFaceName21 = (*env)->GetFieldID(env, LOGFONTFc.clazz, "lfFaceName21", "C");
- LOGFONTFc.lfFaceName22 = (*env)->GetFieldID(env, LOGFONTFc.clazz, "lfFaceName22", "C");
- LOGFONTFc.lfFaceName23 = (*env)->GetFieldID(env, LOGFONTFc.clazz, "lfFaceName23", "C");
- LOGFONTFc.lfFaceName24 = (*env)->GetFieldID(env, LOGFONTFc.clazz, "lfFaceName24", "C");
- LOGFONTFc.lfFaceName25 = (*env)->GetFieldID(env, LOGFONTFc.clazz, "lfFaceName25", "C");
- LOGFONTFc.lfFaceName26 = (*env)->GetFieldID(env, LOGFONTFc.clazz, "lfFaceName26", "C");
- LOGFONTFc.lfFaceName27 = (*env)->GetFieldID(env, LOGFONTFc.clazz, "lfFaceName27", "C");
- LOGFONTFc.lfFaceName28 = (*env)->GetFieldID(env, LOGFONTFc.clazz, "lfFaceName28", "C");
- LOGFONTFc.lfFaceName29 = (*env)->GetFieldID(env, LOGFONTFc.clazz, "lfFaceName29", "C");
- LOGFONTFc.lfFaceName30 = (*env)->GetFieldID(env, LOGFONTFc.clazz, "lfFaceName30", "C");
- LOGFONTFc.lfFaceName31 = (*env)->GetFieldID(env, LOGFONTFc.clazz, "lfFaceName31", "C");
- LOGFONTFc.cached = 1;
-}
-
-#ifndef NO_LOGFONTA
-LOGFONTA* getLOGFONTAFields(JNIEnv *env, jobject lpObject, LOGFONTA *lpStruct)
-{
- if (!LOGFONTFc.cached) cacheLOGFONTFids(env, lpObject);
- lpStruct->lfHeight = (*env)->GetIntField(env,lpObject,LOGFONTFc.lfHeight);
- lpStruct->lfWidth = (*env)->GetIntField(env,lpObject,LOGFONTFc.lfWidth);
- lpStruct->lfEscapement = (*env)->GetIntField(env,lpObject,LOGFONTFc.lfEscapement);
- lpStruct->lfOrientation = (*env)->GetIntField(env,lpObject,LOGFONTFc.lfOrientation);
- lpStruct->lfWeight = (*env)->GetIntField(env,lpObject,LOGFONTFc.lfWeight);
- lpStruct->lfItalic = (*env)->GetByteField(env,lpObject,LOGFONTFc.lfItalic);
- lpStruct->lfUnderline = (*env)->GetByteField(env,lpObject,LOGFONTFc.lfUnderline);
- lpStruct->lfStrikeOut = (*env)->GetByteField(env,lpObject,LOGFONTFc.lfStrikeOut);
- lpStruct->lfCharSet = (*env)->GetByteField(env,lpObject,LOGFONTFc.lfCharSet);
- lpStruct->lfOutPrecision = (*env)->GetByteField(env,lpObject,LOGFONTFc.lfOutPrecision);
- lpStruct->lfClipPrecision = (*env)->GetByteField(env,lpObject,LOGFONTFc.lfClipPrecision);
- lpStruct->lfQuality = (*env)->GetByteField(env,lpObject,LOGFONTFc.lfQuality);
- lpStruct->lfPitchAndFamily = (*env)->GetByteField(env,lpObject,LOGFONTFc.lfPitchAndFamily);
- {
- WCHAR lfFaceName [32];
- lfFaceName[0] = (*env)->GetCharField(env,lpObject,LOGFONTFc.lfFaceName0);
- lfFaceName[1] = (*env)->GetCharField(env,lpObject,LOGFONTFc.lfFaceName1);
- lfFaceName[2] = (*env)->GetCharField(env,lpObject,LOGFONTFc.lfFaceName2);
- lfFaceName[3] = (*env)->GetCharField(env,lpObject,LOGFONTFc.lfFaceName3);
- lfFaceName[4] = (*env)->GetCharField(env,lpObject,LOGFONTFc.lfFaceName4);
- lfFaceName[5] = (*env)->GetCharField(env,lpObject,LOGFONTFc.lfFaceName5);
- lfFaceName[6] = (*env)->GetCharField(env,lpObject,LOGFONTFc.lfFaceName6);
- lfFaceName[7] = (*env)->GetCharField(env,lpObject,LOGFONTFc.lfFaceName7);
- lfFaceName[8] = (*env)->GetCharField(env,lpObject,LOGFONTFc.lfFaceName8);
- lfFaceName[9] = (*env)->GetCharField(env,lpObject,LOGFONTFc.lfFaceName9);
- lfFaceName[10] = (*env)->GetCharField(env,lpObject,LOGFONTFc.lfFaceName10);
- lfFaceName[11] = (*env)->GetCharField(env,lpObject,LOGFONTFc.lfFaceName11);
- lfFaceName[12] = (*env)->GetCharField(env,lpObject,LOGFONTFc.lfFaceName12);
- lfFaceName[13] = (*env)->GetCharField(env,lpObject,LOGFONTFc.lfFaceName13);
- lfFaceName[14] = (*env)->GetCharField(env,lpObject,LOGFONTFc.lfFaceName14);
- lfFaceName[15] = (*env)->GetCharField(env,lpObject,LOGFONTFc.lfFaceName15);
- lfFaceName[16] = (*env)->GetCharField(env,lpObject,LOGFONTFc.lfFaceName16);
- lfFaceName[17] = (*env)->GetCharField(env,lpObject,LOGFONTFc.lfFaceName17);
- lfFaceName[18] = (*env)->GetCharField(env,lpObject,LOGFONTFc.lfFaceName18);
- lfFaceName[19] = (*env)->GetCharField(env,lpObject,LOGFONTFc.lfFaceName19);
- lfFaceName[20] = (*env)->GetCharField(env,lpObject,LOGFONTFc.lfFaceName20);
- lfFaceName[21] = (*env)->GetCharField(env,lpObject,LOGFONTFc.lfFaceName21);
- lfFaceName[22] = (*env)->GetCharField(env,lpObject,LOGFONTFc.lfFaceName22);
- lfFaceName[23] = (*env)->GetCharField(env,lpObject,LOGFONTFc.lfFaceName23);
- lfFaceName[24] = (*env)->GetCharField(env,lpObject,LOGFONTFc.lfFaceName24);
- lfFaceName[25] = (*env)->GetCharField(env,lpObject,LOGFONTFc.lfFaceName25);
- lfFaceName[26] = (*env)->GetCharField(env,lpObject,LOGFONTFc.lfFaceName26);
- lfFaceName[27] = (*env)->GetCharField(env,lpObject,LOGFONTFc.lfFaceName27);
- lfFaceName[28] = (*env)->GetCharField(env,lpObject,LOGFONTFc.lfFaceName28);
- lfFaceName[29] = (*env)->GetCharField(env,lpObject,LOGFONTFc.lfFaceName29);
- lfFaceName[30] = (*env)->GetCharField(env,lpObject,LOGFONTFc.lfFaceName30);
- lfFaceName[31] = (*env)->GetCharField(env,lpObject,LOGFONTFc.lfFaceName31);
- WideCharToMultiByte (CP_ACP, 0, lfFaceName, 32, lpStruct->lfFaceName, 32, NULL, NULL);
- }
- return lpStruct;
-}
-
-void setLOGFONTAFields(JNIEnv *env, jobject lpObject, LOGFONTA *lpStruct)
-{
- if (!LOGFONTFc.cached) cacheLOGFONTFids(env, lpObject);
- (*env)->SetIntField(env,lpObject,LOGFONTFc.lfHeight, lpStruct->lfHeight);
- (*env)->SetIntField(env,lpObject,LOGFONTFc.lfWidth, lpStruct->lfWidth);
- (*env)->SetIntField(env,lpObject,LOGFONTFc.lfEscapement, lpStruct->lfEscapement);
- (*env)->SetIntField(env,lpObject,LOGFONTFc.lfOrientation, lpStruct->lfOrientation);
- (*env)->SetIntField(env,lpObject,LOGFONTFc.lfWeight, lpStruct->lfWeight);
- (*env)->SetByteField(env,lpObject,LOGFONTFc.lfItalic, lpStruct->lfItalic);
- (*env)->SetByteField(env,lpObject,LOGFONTFc.lfUnderline, lpStruct->lfUnderline);
- (*env)->SetByteField(env,lpObject,LOGFONTFc.lfStrikeOut, lpStruct->lfStrikeOut);
- (*env)->SetByteField(env,lpObject,LOGFONTFc.lfCharSet, lpStruct->lfCharSet);
- (*env)->SetByteField(env,lpObject,LOGFONTFc.lfOutPrecision, lpStruct->lfOutPrecision);
- (*env)->SetByteField(env,lpObject,LOGFONTFc.lfClipPrecision, lpStruct->lfClipPrecision);
- (*env)->SetByteField(env,lpObject,LOGFONTFc.lfQuality, lpStruct->lfQuality);
- (*env)->SetByteField(env,lpObject,LOGFONTFc.lfPitchAndFamily, lpStruct->lfPitchAndFamily);
- {
- WCHAR lfFaceName [32] = {0};
- MultiByteToWideChar (CP_ACP, MB_PRECOMPOSED, lpStruct->lfFaceName, -1, lfFaceName, 32);
- (*env)->SetCharField(env,lpObject,LOGFONTFc.lfFaceName0, lfFaceName[0]);
- (*env)->SetCharField(env,lpObject,LOGFONTFc.lfFaceName1, lfFaceName[1]);
- (*env)->SetCharField(env,lpObject,LOGFONTFc.lfFaceName2, lfFaceName[2]);
- (*env)->SetCharField(env,lpObject,LOGFONTFc.lfFaceName3, lfFaceName[3]);
- (*env)->SetCharField(env,lpObject,LOGFONTFc.lfFaceName4, lfFaceName[4]);
- (*env)->SetCharField(env,lpObject,LOGFONTFc.lfFaceName5, lfFaceName[5]);
- (*env)->SetCharField(env,lpObject,LOGFONTFc.lfFaceName6, lfFaceName[6]);
- (*env)->SetCharField(env,lpObject,LOGFONTFc.lfFaceName7, lfFaceName[7]);
- (*env)->SetCharField(env,lpObject,LOGFONTFc.lfFaceName8, lfFaceName[8]);
- (*env)->SetCharField(env,lpObject,LOGFONTFc.lfFaceName9, lfFaceName[9]);
- (*env)->SetCharField(env,lpObject,LOGFONTFc.lfFaceName10, lfFaceName[10]);
- (*env)->SetCharField(env,lpObject,LOGFONTFc.lfFaceName11, lfFaceName[11]);
- (*env)->SetCharField(env,lpObject,LOGFONTFc.lfFaceName12, lfFaceName[12]);
- (*env)->SetCharField(env,lpObject,LOGFONTFc.lfFaceName13, lfFaceName[13]);
- (*env)->SetCharField(env,lpObject,LOGFONTFc.lfFaceName14, lfFaceName[14]);
- (*env)->SetCharField(env,lpObject,LOGFONTFc.lfFaceName15, lfFaceName[15]);
- (*env)->SetCharField(env,lpObject,LOGFONTFc.lfFaceName16, lfFaceName[16]);
- (*env)->SetCharField(env,lpObject,LOGFONTFc.lfFaceName17, lfFaceName[17]);
- (*env)->SetCharField(env,lpObject,LOGFONTFc.lfFaceName18, lfFaceName[18]);
- (*env)->SetCharField(env,lpObject,LOGFONTFc.lfFaceName19, lfFaceName[19]);
- (*env)->SetCharField(env,lpObject,LOGFONTFc.lfFaceName20, lfFaceName[20]);
- (*env)->SetCharField(env,lpObject,LOGFONTFc.lfFaceName21, lfFaceName[21]);
- (*env)->SetCharField(env,lpObject,LOGFONTFc.lfFaceName22, lfFaceName[22]);
- (*env)->SetCharField(env,lpObject,LOGFONTFc.lfFaceName23, lfFaceName[23]);
- (*env)->SetCharField(env,lpObject,LOGFONTFc.lfFaceName24, lfFaceName[24]);
- (*env)->SetCharField(env,lpObject,LOGFONTFc.lfFaceName25, lfFaceName[25]);
- (*env)->SetCharField(env,lpObject,LOGFONTFc.lfFaceName26, lfFaceName[26]);
- (*env)->SetCharField(env,lpObject,LOGFONTFc.lfFaceName27, lfFaceName[27]);
- (*env)->SetCharField(env,lpObject,LOGFONTFc.lfFaceName28, lfFaceName[28]);
- (*env)->SetCharField(env,lpObject,LOGFONTFc.lfFaceName29, lfFaceName[29]);
- (*env)->SetCharField(env,lpObject,LOGFONTFc.lfFaceName30, lfFaceName[30]);
- (*env)->SetCharField(env,lpObject,LOGFONTFc.lfFaceName31, lfFaceName[31]);
- }
-}
-#endif /* NO_LOGFONTA */
-
-#ifndef NO_LOGFONTW
-LOGFONTW *getLOGFONTWFields(JNIEnv *env, jobject lpObject, LOGFONTW *lpStruct)
-{
- if (!LOGFONTFc.cached) cacheLOGFONTFids(env, lpObject);
- lpStruct->lfHeight = (*env)->GetIntField(env, lpObject, LOGFONTFc.lfHeight);
- lpStruct->lfWidth = (*env)->GetIntField(env, lpObject, LOGFONTFc.lfWidth);
- lpStruct->lfEscapement = (*env)->GetIntField(env, lpObject, LOGFONTFc.lfEscapement);
- lpStruct->lfOrientation = (*env)->GetIntField(env, lpObject, LOGFONTFc.lfOrientation);
- lpStruct->lfWeight = (*env)->GetIntField(env, lpObject, LOGFONTFc.lfWeight);
- lpStruct->lfItalic = (*env)->GetByteField(env, lpObject, LOGFONTFc.lfItalic);
- lpStruct->lfUnderline = (*env)->GetByteField(env, lpObject, LOGFONTFc.lfUnderline);
- lpStruct->lfStrikeOut = (*env)->GetByteField(env, lpObject, LOGFONTFc.lfStrikeOut);
- lpStruct->lfCharSet = (*env)->GetByteField(env, lpObject, LOGFONTFc.lfCharSet);
- lpStruct->lfOutPrecision = (*env)->GetByteField(env, lpObject, LOGFONTFc.lfOutPrecision);
- lpStruct->lfClipPrecision = (*env)->GetByteField(env, lpObject, LOGFONTFc.lfClipPrecision);
- lpStruct->lfQuality = (*env)->GetByteField(env, lpObject, LOGFONTFc.lfQuality);
- lpStruct->lfPitchAndFamily = (*env)->GetByteField(env, lpObject, LOGFONTFc.lfPitchAndFamily);
- lpStruct->lfFaceName[0] = (*env)->GetCharField(env, lpObject, LOGFONTFc.lfFaceName0);
- lpStruct->lfFaceName[1] = (*env)->GetCharField(env, lpObject, LOGFONTFc.lfFaceName1);
- lpStruct->lfFaceName[2] = (*env)->GetCharField(env, lpObject, LOGFONTFc.lfFaceName2);
- lpStruct->lfFaceName[3] = (*env)->GetCharField(env, lpObject, LOGFONTFc.lfFaceName3);
- lpStruct->lfFaceName[4] = (*env)->GetCharField(env, lpObject, LOGFONTFc.lfFaceName4);
- lpStruct->lfFaceName[5] = (*env)->GetCharField(env, lpObject, LOGFONTFc.lfFaceName5);
- lpStruct->lfFaceName[6] = (*env)->GetCharField(env, lpObject, LOGFONTFc.lfFaceName6);
- lpStruct->lfFaceName[7] = (*env)->GetCharField(env, lpObject, LOGFONTFc.lfFaceName7);
- lpStruct->lfFaceName[8] = (*env)->GetCharField(env, lpObject, LOGFONTFc.lfFaceName8);
- lpStruct->lfFaceName[9] = (*env)->GetCharField(env, lpObject, LOGFONTFc.lfFaceName9);
- lpStruct->lfFaceName[10] = (*env)->GetCharField(env, lpObject, LOGFONTFc.lfFaceName10);
- lpStruct->lfFaceName[11] = (*env)->GetCharField(env, lpObject, LOGFONTFc.lfFaceName11);
- lpStruct->lfFaceName[12] = (*env)->GetCharField(env, lpObject, LOGFONTFc.lfFaceName12);
- lpStruct->lfFaceName[13] = (*env)->GetCharField(env, lpObject, LOGFONTFc.lfFaceName13);
- lpStruct->lfFaceName[14] = (*env)->GetCharField(env, lpObject, LOGFONTFc.lfFaceName14);
- lpStruct->lfFaceName[15] = (*env)->GetCharField(env, lpObject, LOGFONTFc.lfFaceName15);
- lpStruct->lfFaceName[16] = (*env)->GetCharField(env, lpObject, LOGFONTFc.lfFaceName16);
- lpStruct->lfFaceName[17] = (*env)->GetCharField(env, lpObject, LOGFONTFc.lfFaceName17);
- lpStruct->lfFaceName[18] = (*env)->GetCharField(env, lpObject, LOGFONTFc.lfFaceName18);
- lpStruct->lfFaceName[19] = (*env)->GetCharField(env, lpObject, LOGFONTFc.lfFaceName19);
- lpStruct->lfFaceName[20] = (*env)->GetCharField(env, lpObject, LOGFONTFc.lfFaceName20);
- lpStruct->lfFaceName[21] = (*env)->GetCharField(env, lpObject, LOGFONTFc.lfFaceName21);
- lpStruct->lfFaceName[22] = (*env)->GetCharField(env, lpObject, LOGFONTFc.lfFaceName22);
- lpStruct->lfFaceName[23] = (*env)->GetCharField(env, lpObject, LOGFONTFc.lfFaceName23);
- lpStruct->lfFaceName[24] = (*env)->GetCharField(env, lpObject, LOGFONTFc.lfFaceName24);
- lpStruct->lfFaceName[25] = (*env)->GetCharField(env, lpObject, LOGFONTFc.lfFaceName25);
- lpStruct->lfFaceName[26] = (*env)->GetCharField(env, lpObject, LOGFONTFc.lfFaceName26);
- lpStruct->lfFaceName[27] = (*env)->GetCharField(env, lpObject, LOGFONTFc.lfFaceName27);
- lpStruct->lfFaceName[28] = (*env)->GetCharField(env, lpObject, LOGFONTFc.lfFaceName28);
- lpStruct->lfFaceName[29] = (*env)->GetCharField(env, lpObject, LOGFONTFc.lfFaceName29);
- lpStruct->lfFaceName[30] = (*env)->GetCharField(env, lpObject, LOGFONTFc.lfFaceName30);
- lpStruct->lfFaceName[31] = (*env)->GetCharField(env, lpObject, LOGFONTFc.lfFaceName31);
- return lpStruct;
-}
-
-void setLOGFONTWFields(JNIEnv *env, jobject lpObject, LOGFONTW *lpStruct)
-{
- if (!LOGFONTFc.cached) cacheLOGFONTFids(env, lpObject);
- (*env)->SetIntField(env, lpObject, LOGFONTFc.lfHeight, (jint)lpStruct->lfHeight);
- (*env)->SetIntField(env, lpObject, LOGFONTFc.lfWidth, (jint)lpStruct->lfWidth);
- (*env)->SetIntField(env, lpObject, LOGFONTFc.lfEscapement, (jint)lpStruct->lfEscapement);
- (*env)->SetIntField(env, lpObject, LOGFONTFc.lfOrientation, (jint)lpStruct->lfOrientation);
- (*env)->SetIntField(env, lpObject, LOGFONTFc.lfWeight, (jint)lpStruct->lfWeight);
- (*env)->SetByteField(env, lpObject, LOGFONTFc.lfItalic, (jbyte)lpStruct->lfItalic);
- (*env)->SetByteField(env, lpObject, LOGFONTFc.lfUnderline, (jbyte)lpStruct->lfUnderline);
- (*env)->SetByteField(env, lpObject, LOGFONTFc.lfStrikeOut, (jbyte)lpStruct->lfStrikeOut);
- (*env)->SetByteField(env, lpObject, LOGFONTFc.lfCharSet, (jbyte)lpStruct->lfCharSet);
- (*env)->SetByteField(env, lpObject, LOGFONTFc.lfOutPrecision, (jbyte)lpStruct->lfOutPrecision);
- (*env)->SetByteField(env, lpObject, LOGFONTFc.lfClipPrecision, (jbyte)lpStruct->lfClipPrecision);
- (*env)->SetByteField(env, lpObject, LOGFONTFc.lfQuality, (jbyte)lpStruct->lfQuality);
- (*env)->SetByteField(env, lpObject, LOGFONTFc.lfPitchAndFamily, (jbyte)lpStruct->lfPitchAndFamily);
- (*env)->SetCharField(env, lpObject, LOGFONTFc.lfFaceName0, (jchar)lpStruct->lfFaceName[0]);
- (*env)->SetCharField(env, lpObject, LOGFONTFc.lfFaceName1, (jchar)lpStruct->lfFaceName[1]);
- (*env)->SetCharField(env, lpObject, LOGFONTFc.lfFaceName2, (jchar)lpStruct->lfFaceName[2]);
- (*env)->SetCharField(env, lpObject, LOGFONTFc.lfFaceName3, (jchar)lpStruct->lfFaceName[3]);
- (*env)->SetCharField(env, lpObject, LOGFONTFc.lfFaceName4, (jchar)lpStruct->lfFaceName[4]);
- (*env)->SetCharField(env, lpObject, LOGFONTFc.lfFaceName5, (jchar)lpStruct->lfFaceName[5]);
- (*env)->SetCharField(env, lpObject, LOGFONTFc.lfFaceName6, (jchar)lpStruct->lfFaceName[6]);
- (*env)->SetCharField(env, lpObject, LOGFONTFc.lfFaceName7, (jchar)lpStruct->lfFaceName[7]);
- (*env)->SetCharField(env, lpObject, LOGFONTFc.lfFaceName8, (jchar)lpStruct->lfFaceName[8]);
- (*env)->SetCharField(env, lpObject, LOGFONTFc.lfFaceName9, (jchar)lpStruct->lfFaceName[9]);
- (*env)->SetCharField(env, lpObject, LOGFONTFc.lfFaceName10, (jchar)lpStruct->lfFaceName[10]);
- (*env)->SetCharField(env, lpObject, LOGFONTFc.lfFaceName11, (jchar)lpStruct->lfFaceName[11]);
- (*env)->SetCharField(env, lpObject, LOGFONTFc.lfFaceName12, (jchar)lpStruct->lfFaceName[12]);
- (*env)->SetCharField(env, lpObject, LOGFONTFc.lfFaceName13, (jchar)lpStruct->lfFaceName[13]);
- (*env)->SetCharField(env, lpObject, LOGFONTFc.lfFaceName14, (jchar)lpStruct->lfFaceName[14]);
- (*env)->SetCharField(env, lpObject, LOGFONTFc.lfFaceName15, (jchar)lpStruct->lfFaceName[15]);
- (*env)->SetCharField(env, lpObject, LOGFONTFc.lfFaceName16, (jchar)lpStruct->lfFaceName[16]);
- (*env)->SetCharField(env, lpObject, LOGFONTFc.lfFaceName17, (jchar)lpStruct->lfFaceName[17]);
- (*env)->SetCharField(env, lpObject, LOGFONTFc.lfFaceName18, (jchar)lpStruct->lfFaceName[18]);
- (*env)->SetCharField(env, lpObject, LOGFONTFc.lfFaceName19, (jchar)lpStruct->lfFaceName[19]);
- (*env)->SetCharField(env, lpObject, LOGFONTFc.lfFaceName20, (jchar)lpStruct->lfFaceName[20]);
- (*env)->SetCharField(env, lpObject, LOGFONTFc.lfFaceName21, (jchar)lpStruct->lfFaceName[21]);
- (*env)->SetCharField(env, lpObject, LOGFONTFc.lfFaceName22, (jchar)lpStruct->lfFaceName[22]);
- (*env)->SetCharField(env, lpObject, LOGFONTFc.lfFaceName23, (jchar)lpStruct->lfFaceName[23]);
- (*env)->SetCharField(env, lpObject, LOGFONTFc.lfFaceName24, (jchar)lpStruct->lfFaceName[24]);
- (*env)->SetCharField(env, lpObject, LOGFONTFc.lfFaceName25, (jchar)lpStruct->lfFaceName[25]);
- (*env)->SetCharField(env, lpObject, LOGFONTFc.lfFaceName26, (jchar)lpStruct->lfFaceName[26]);
- (*env)->SetCharField(env, lpObject, LOGFONTFc.lfFaceName27, (jchar)lpStruct->lfFaceName[27]);
- (*env)->SetCharField(env, lpObject, LOGFONTFc.lfFaceName28, (jchar)lpStruct->lfFaceName[28]);
- (*env)->SetCharField(env, lpObject, LOGFONTFc.lfFaceName29, (jchar)lpStruct->lfFaceName[29]);
- (*env)->SetCharField(env, lpObject, LOGFONTFc.lfFaceName30, (jchar)lpStruct->lfFaceName[30]);
- (*env)->SetCharField(env, lpObject, LOGFONTFc.lfFaceName31, (jchar)lpStruct->lfFaceName[31]);
-}
-#endif /* NO_LOGFONTW */
-#endif /* NO_LOGFONT */
-
-#ifndef NO_LOGPEN
-typedef struct LOGPEN_FID_CACHE {
- int cached;
- jclass clazz;
- jfieldID lopnStyle, x, y, lopnColor;
-} LOGPEN_FID_CACHE;
-
-LOGPEN_FID_CACHE LOGPENFc;
-
-void cacheLOGPENFids(JNIEnv *env, jobject lpObject)
-{
- if (LOGPENFc.cached) return;
- LOGPENFc.clazz = (*env)->GetObjectClass(env, lpObject);
- LOGPENFc.lopnStyle = (*env)->GetFieldID(env, LOGPENFc.clazz, "lopnStyle", "I");
- LOGPENFc.x = (*env)->GetFieldID(env, LOGPENFc.clazz, "x", "I");
- LOGPENFc.y = (*env)->GetFieldID(env, LOGPENFc.clazz, "y", "I");
- LOGPENFc.lopnColor = (*env)->GetFieldID(env, LOGPENFc.clazz, "lopnColor", "I");
- LOGPENFc.cached = 1;
-}
-
-LOGPEN *getLOGPENFields(JNIEnv *env, jobject lpObject, LOGPEN *lpStruct)
-{
- if (!LOGPENFc.cached) cacheLOGPENFids(env, lpObject);
- lpStruct->lopnStyle = (*env)->GetIntField(env, lpObject, LOGPENFc.lopnStyle);
- lpStruct->lopnWidth.x = (*env)->GetIntField(env, lpObject, LOGPENFc.x);
- lpStruct->lopnWidth.y = (*env)->GetIntField(env, lpObject, LOGPENFc.y);
- lpStruct->lopnColor = (*env)->GetIntField(env, lpObject, LOGPENFc.lopnColor);
- return lpStruct;
-}
-
-void setLOGPENFields(JNIEnv *env, jobject lpObject, LOGPEN *lpStruct)
-{
- if (!LOGPENFc.cached) cacheLOGPENFids(env, lpObject);
- (*env)->SetIntField(env, lpObject, LOGPENFc.lopnStyle, (jint)lpStruct->lopnStyle);
- (*env)->SetIntField(env, lpObject, LOGPENFc.x, (jint)lpStruct->lopnWidth.x);
- (*env)->SetIntField(env, lpObject, LOGPENFc.y, (jint)lpStruct->lopnWidth.y);
- (*env)->SetIntField(env, lpObject, LOGPENFc.lopnColor, (jint)lpStruct->lopnColor);
-}
-#endif /* NO_LOGPEN */
-
-#ifndef NO_LVCOLUMN
-typedef struct LVCOLUMN_FID_CACHE {
- int cached;
- jclass clazz;
- jfieldID mask, fmt, cx, pszText, cchTextMax, iSubItem, iImage, iOrder;
-} LVCOLUMN_FID_CACHE;
-
-LVCOLUMN_FID_CACHE LVCOLUMNFc;
-
-void cacheLVCOLUMNFids(JNIEnv *env, jobject lpObject)
-{
- if (LVCOLUMNFc.cached) return;
- LVCOLUMNFc.clazz = (*env)->GetObjectClass(env, lpObject);
- LVCOLUMNFc.mask = (*env)->GetFieldID(env, LVCOLUMNFc.clazz, "mask", "I");
- LVCOLUMNFc.fmt = (*env)->GetFieldID(env, LVCOLUMNFc.clazz, "fmt", "I");
- LVCOLUMNFc.cx = (*env)->GetFieldID(env, LVCOLUMNFc.clazz, "cx", "I");
- LVCOLUMNFc.pszText = (*env)->GetFieldID(env, LVCOLUMNFc.clazz, "pszText", "I");
- LVCOLUMNFc.cchTextMax = (*env)->GetFieldID(env, LVCOLUMNFc.clazz, "cchTextMax", "I");
- LVCOLUMNFc.iSubItem = (*env)->GetFieldID(env, LVCOLUMNFc.clazz, "iSubItem", "I");
- LVCOLUMNFc.iImage = (*env)->GetFieldID(env, LVCOLUMNFc.clazz, "iImage", "I");
- LVCOLUMNFc.iOrder = (*env)->GetFieldID(env, LVCOLUMNFc.clazz, "iOrder", "I");
- LVCOLUMNFc.cached = 1;
-}
-
-LVCOLUMN *getLVCOLUMNFields(JNIEnv *env, jobject lpObject, LVCOLUMN *lpStruct)
-{
- if (!LVCOLUMNFc.cached) cacheLVCOLUMNFids(env, lpObject);
- lpStruct->mask = (*env)->GetIntField(env, lpObject, LVCOLUMNFc.mask);
- lpStruct->fmt = (*env)->GetIntField(env, lpObject, LVCOLUMNFc.fmt);
- lpStruct->cx = (*env)->GetIntField(env, lpObject, LVCOLUMNFc.cx);
- lpStruct->pszText = (LPTSTR)(*env)->GetIntField(env, lpObject, LVCOLUMNFc.pszText);
- lpStruct->cchTextMax = (*env)->GetIntField(env, lpObject, LVCOLUMNFc.cchTextMax);
- lpStruct->iSubItem = (*env)->GetIntField(env, lpObject, LVCOLUMNFc.iSubItem);
- lpStruct->iImage = (*env)->GetIntField(env, lpObject, LVCOLUMNFc.iImage);
- lpStruct->iOrder = (*env)->GetIntField(env, lpObject, LVCOLUMNFc.iOrder);
- return lpStruct;
-}
-
-void setLVCOLUMNFields(JNIEnv *env, jobject lpObject, LVCOLUMN *lpStruct)
-{
- if (!LVCOLUMNFc.cached) cacheLVCOLUMNFids(env, lpObject);
- (*env)->SetIntField(env, lpObject, LVCOLUMNFc.mask, (jint)lpStruct->mask);
- (*env)->SetIntField(env, lpObject, LVCOLUMNFc.fmt, (jint)lpStruct->fmt);
- (*env)->SetIntField(env, lpObject, LVCOLUMNFc.cx, (jint)lpStruct->cx);
- (*env)->SetIntField(env, lpObject, LVCOLUMNFc.pszText, (jint)lpStruct->pszText);
- (*env)->SetIntField(env, lpObject, LVCOLUMNFc.cchTextMax, (jint)lpStruct->cchTextMax);
- (*env)->SetIntField(env, lpObject, LVCOLUMNFc.iSubItem, (jint)lpStruct->iSubItem);
- (*env)->SetIntField(env, lpObject, LVCOLUMNFc.iImage, (jint)lpStruct->iImage);
- (*env)->SetIntField(env, lpObject, LVCOLUMNFc.iOrder, (jint)lpStruct->iOrder);
-}
-#endif /* NO_LVCOLUMN */
-
-#ifndef NO_LVHITTESTINFO
-typedef struct LVHITTESTINFO_FID_CACHE {
- int cached;
- jclass clazz;
- jfieldID x, y, flags, iItem, iSubItem;
-} LVHITTESTINFO_FID_CACHE;
-
-LVHITTESTINFO_FID_CACHE LVHITTESTINFOFc;
-
-void cacheLVHITTESTINFOFids(JNIEnv *env, jobject lpObject)
-{
- if (LVHITTESTINFOFc.cached) return;
- LVHITTESTINFOFc.clazz = (*env)->GetObjectClass(env, lpObject);
- LVHITTESTINFOFc.x = (*env)->GetFieldID(env, LVHITTESTINFOFc.clazz, "x", "I");
- LVHITTESTINFOFc.y = (*env)->GetFieldID(env, LVHITTESTINFOFc.clazz, "y", "I");
- LVHITTESTINFOFc.flags = (*env)->GetFieldID(env, LVHITTESTINFOFc.clazz, "flags", "I");
- LVHITTESTINFOFc.iItem = (*env)->GetFieldID(env, LVHITTESTINFOFc.clazz, "iItem", "I");
- LVHITTESTINFOFc.iSubItem = (*env)->GetFieldID(env, LVHITTESTINFOFc.clazz, "iSubItem", "I");
- LVHITTESTINFOFc.cached = 1;
-}
-
-LVHITTESTINFO *getLVHITTESTINFOFields(JNIEnv *env, jobject lpObject, LVHITTESTINFO *lpStruct)
-{
- if (!LVHITTESTINFOFc.cached) cacheLVHITTESTINFOFids(env, lpObject);
- lpStruct->pt.x = (*env)->GetIntField(env, lpObject, LVHITTESTINFOFc.x);
- lpStruct->pt.y = (*env)->GetIntField(env, lpObject, LVHITTESTINFOFc.y);
- lpStruct->flags = (*env)->GetIntField(env, lpObject, LVHITTESTINFOFc.flags);
- lpStruct->iItem = (*env)->GetIntField(env, lpObject, LVHITTESTINFOFc.iItem);
- lpStruct->iSubItem = (*env)->GetIntField(env, lpObject, LVHITTESTINFOFc.iSubItem);
- return lpStruct;
-}
-
-void setLVHITTESTINFOFields(JNIEnv *env, jobject lpObject, LVHITTESTINFO *lpStruct)
-{
- if (!LVHITTESTINFOFc.cached) cacheLVHITTESTINFOFids(env, lpObject);
- (*env)->SetIntField(env, lpObject, LVHITTESTINFOFc.x, (jint)lpStruct->pt.x);
- (*env)->SetIntField(env, lpObject, LVHITTESTINFOFc.y, (jint)lpStruct->pt.y);
- (*env)->SetIntField(env, lpObject, LVHITTESTINFOFc.flags, (jint)lpStruct->flags);
- (*env)->SetIntField(env, lpObject, LVHITTESTINFOFc.iItem, (jint)lpStruct->iItem);
- (*env)->SetIntField(env, lpObject, LVHITTESTINFOFc.iSubItem, (jint)lpStruct->iSubItem);
-}
-#endif /* NO_LVHITTESTINFO */
-
-#ifndef NO_LVITEM
-typedef struct LVITEM_FID_CACHE {
- int cached;
- jclass clazz;
- jfieldID mask, iItem, iSubItem, state, stateMask, pszText, cchTextMax, iImage, lParam, iIndent;
-} LVITEM_FID_CACHE;
-
-LVITEM_FID_CACHE LVITEMFc;
-
-void cacheLVITEMFids(JNIEnv *env, jobject lpObject)
-{
- if (LVITEMFc.cached) return;
- LVITEMFc.clazz = (*env)->GetObjectClass(env, lpObject);
- LVITEMFc.mask = (*env)->GetFieldID(env, LVITEMFc.clazz, "mask", "I");
- LVITEMFc.iItem = (*env)->GetFieldID(env, LVITEMFc.clazz, "iItem", "I");
- LVITEMFc.iSubItem = (*env)->GetFieldID(env, LVITEMFc.clazz, "iSubItem", "I");
- LVITEMFc.state = (*env)->GetFieldID(env, LVITEMFc.clazz, "state", "I");
- LVITEMFc.stateMask = (*env)->GetFieldID(env, LVITEMFc.clazz, "stateMask", "I");
- LVITEMFc.pszText = (*env)->GetFieldID(env, LVITEMFc.clazz, "pszText", "I");
- LVITEMFc.cchTextMax = (*env)->GetFieldID(env, LVITEMFc.clazz, "cchTextMax", "I");
- LVITEMFc.iImage = (*env)->GetFieldID(env, LVITEMFc.clazz, "iImage", "I");
- LVITEMFc.lParam = (*env)->GetFieldID(env, LVITEMFc.clazz, "lParam", "I");
- LVITEMFc.iIndent = (*env)->GetFieldID(env, LVITEMFc.clazz, "iIndent", "I");
- LVITEMFc.cached = 1;
-}
-
-LVITEM *getLVITEMFields(JNIEnv *env, jobject lpObject, LVITEM *lpStruct)
-{
- if (!LVITEMFc.cached) cacheLVITEMFids(env, lpObject);
- lpStruct->mask = (*env)->GetIntField(env, lpObject, LVITEMFc.mask);
- lpStruct->iItem = (*env)->GetIntField(env, lpObject, LVITEMFc.iItem);
- lpStruct->iSubItem = (*env)->GetIntField(env, lpObject, LVITEMFc.iSubItem);
- lpStruct->state = (*env)->GetIntField(env, lpObject, LVITEMFc.state);
- lpStruct->stateMask = (*env)->GetIntField(env, lpObject, LVITEMFc.stateMask);
- lpStruct->pszText = (LPTSTR)(*env)->GetIntField(env, lpObject, LVITEMFc.pszText);
- lpStruct->cchTextMax = (*env)->GetIntField(env, lpObject, LVITEMFc.cchTextMax);
- lpStruct->iImage = (*env)->GetIntField(env, lpObject, LVITEMFc.iImage);
- lpStruct->lParam = (*env)->GetIntField(env, lpObject, LVITEMFc.lParam);
- lpStruct->iIndent = (*env)->GetIntField(env, lpObject, LVITEMFc.iIndent);
- return lpStruct;
-}
-
-void setLVITEMFields(JNIEnv *env, jobject lpObject, LVITEM *lpStruct)
-{
- if (!LVITEMFc.cached) cacheLVITEMFids(env, lpObject);
- (*env)->SetIntField(env, lpObject, LVITEMFc.mask, (jint)lpStruct->mask);
- (*env)->SetIntField(env, lpObject, LVITEMFc.iItem, (jint)lpStruct->iItem);
- (*env)->SetIntField(env, lpObject, LVITEMFc.iSubItem, (jint)lpStruct->iSubItem);
- (*env)->SetIntField(env, lpObject, LVITEMFc.state, (jint)lpStruct->state);
- (*env)->SetIntField(env, lpObject, LVITEMFc.stateMask, (jint)lpStruct->stateMask);
- (*env)->SetIntField(env, lpObject, LVITEMFc.pszText, (jint)lpStruct->pszText);
- (*env)->SetIntField(env, lpObject, LVITEMFc.cchTextMax, (jint)lpStruct->cchTextMax);
- (*env)->SetIntField(env, lpObject, LVITEMFc.iImage, (jint)lpStruct->iImage);
- (*env)->SetIntField(env, lpObject, LVITEMFc.lParam, (jint)lpStruct->lParam);
- (*env)->SetIntField(env, lpObject, LVITEMFc.iIndent, (jint)lpStruct->iIndent);
-}
-#endif /* NO_LVITEM */
-
-#ifndef NO_MEASUREITEMSTRUCT
-typedef struct MEASUREITEMSTRUCT_FID_CACHE {
- int cached;
- jclass clazz;
- jfieldID CtlType, CtlID, itemID, itemWidth, itemHeight, itemData;
-} MEASUREITEMSTRUCT_FID_CACHE;
-
-MEASUREITEMSTRUCT_FID_CACHE MEASUREITEMSTRUCTFc;
-
-void cacheMEASUREITEMSTRUCTFids(JNIEnv *env, jobject lpObject)
-{
- if (MEASUREITEMSTRUCTFc.cached) return;
- MEASUREITEMSTRUCTFc.clazz = (*env)->GetObjectClass(env, lpObject);
- MEASUREITEMSTRUCTFc.CtlType = (*env)->GetFieldID(env, MEASUREITEMSTRUCTFc.clazz, "CtlType", "I");
- MEASUREITEMSTRUCTFc.CtlID = (*env)->GetFieldID(env, MEASUREITEMSTRUCTFc.clazz, "CtlID", "I");
- MEASUREITEMSTRUCTFc.itemID = (*env)->GetFieldID(env, MEASUREITEMSTRUCTFc.clazz, "itemID", "I");
- MEASUREITEMSTRUCTFc.itemWidth = (*env)->GetFieldID(env, MEASUREITEMSTRUCTFc.clazz, "itemWidth", "I");
- MEASUREITEMSTRUCTFc.itemHeight = (*env)->GetFieldID(env, MEASUREITEMSTRUCTFc.clazz, "itemHeight", "I");
- MEASUREITEMSTRUCTFc.itemData = (*env)->GetFieldID(env, MEASUREITEMSTRUCTFc.clazz, "itemData", "I");
- MEASUREITEMSTRUCTFc.cached = 1;
-}
-
-MEASUREITEMSTRUCT *getMEASUREITEMSTRUCTFields(JNIEnv *env, jobject lpObject, MEASUREITEMSTRUCT *lpStruct)
-{
- if (!MEASUREITEMSTRUCTFc.cached) cacheMEASUREITEMSTRUCTFids(env, lpObject);
- lpStruct->CtlType = (*env)->GetIntField(env, lpObject, MEASUREITEMSTRUCTFc.CtlType);
- lpStruct->CtlID = (*env)->GetIntField(env, lpObject, MEASUREITEMSTRUCTFc.CtlID);
- lpStruct->itemID = (*env)->GetIntField(env, lpObject, MEASUREITEMSTRUCTFc.itemID);
- lpStruct->itemWidth = (*env)->GetIntField(env, lpObject, MEASUREITEMSTRUCTFc.itemWidth);
- lpStruct->itemHeight = (*env)->GetIntField(env, lpObject, MEASUREITEMSTRUCTFc.itemHeight);
- lpStruct->itemData = (*env)->GetIntField(env, lpObject, MEASUREITEMSTRUCTFc.itemData);
- return lpStruct;
-}
-
-void setMEASUREITEMSTRUCTFields(JNIEnv *env, jobject lpObject, MEASUREITEMSTRUCT *lpStruct)
-{
- if (!MEASUREITEMSTRUCTFc.cached) cacheMEASUREITEMSTRUCTFids(env, lpObject);
- (*env)->SetIntField(env, lpObject, MEASUREITEMSTRUCTFc.CtlType, (jint)lpStruct->CtlType);
- (*env)->SetIntField(env, lpObject, MEASUREITEMSTRUCTFc.CtlID, (jint)lpStruct->CtlID);
- (*env)->SetIntField(env, lpObject, MEASUREITEMSTRUCTFc.itemID, (jint)lpStruct->itemID);
- (*env)->SetIntField(env, lpObject, MEASUREITEMSTRUCTFc.itemWidth, (jint)lpStruct->itemWidth);
- (*env)->SetIntField(env, lpObject, MEASUREITEMSTRUCTFc.itemHeight, (jint)lpStruct->itemHeight);
- (*env)->SetIntField(env, lpObject, MEASUREITEMSTRUCTFc.itemData, (jint)lpStruct->itemData);
-}
-#endif /* NO_MEASUREITEMSTRUCT */
-
-#ifndef NO_MENUINFO
-typedef struct MENUINFO_FID_CACHE {
- int cached;
- jclass clazz;
- jfieldID cbSize, fMask, dwStyle, cyMax, hbrBack, dwContextHelpID, dwMenuData;
-} MENUINFO_FID_CACHE;
-
-MENUINFO_FID_CACHE MENUINFOFc;
-
-void cacheMENUINFOFids(JNIEnv *env, jobject lpObject)
-{
- if (MENUINFOFc.cached) return;
- MENUINFOFc.clazz = (*env)->GetObjectClass(env, lpObject);
- MENUINFOFc.cbSize = (*env)->GetFieldID(env, MENUINFOFc.clazz, "cbSize", "I");
- MENUINFOFc.fMask = (*env)->GetFieldID(env, MENUINFOFc.clazz, "fMask", "I");
- MENUINFOFc.dwStyle = (*env)->GetFieldID(env, MENUINFOFc.clazz, "dwStyle", "I");
- MENUINFOFc.cyMax = (*env)->GetFieldID(env, MENUINFOFc.clazz, "cyMax", "I");
- MENUINFOFc.hbrBack = (*env)->GetFieldID(env, MENUINFOFc.clazz, "hbrBack", "I");
- MENUINFOFc.dwContextHelpID = (*env)->GetFieldID(env, MENUINFOFc.clazz, "dwContextHelpID", "I");
- MENUINFOFc.dwMenuData = (*env)->GetFieldID(env, MENUINFOFc.clazz, "dwMenuData", "I");
- MENUINFOFc.cached = 1;
-}
-
-MENUINFO *getMENUINFOFields(JNIEnv *env, jobject lpObject, MENUINFO *lpStruct)
-{
- if (!MENUINFOFc.cached) cacheMENUINFOFids(env, lpObject);
- lpStruct->cbSize = (*env)->GetIntField(env, lpObject, MENUINFOFc.cbSize);
- lpStruct->fMask = (*env)->GetIntField(env, lpObject, MENUINFOFc.fMask);
- lpStruct->dwStyle = (*env)->GetIntField(env, lpObject, MENUINFOFc.dwStyle);
- lpStruct->cyMax = (*env)->GetIntField(env, lpObject, MENUINFOFc.cyMax);
- lpStruct->hbrBack = (HBRUSH)(*env)->GetIntField(env, lpObject, MENUINFOFc.hbrBack);
- lpStruct->dwContextHelpID = (*env)->GetIntField(env, lpObject, MENUINFOFc.dwContextHelpID);
- lpStruct->dwMenuData = (*env)->GetIntField(env, lpObject, MENUINFOFc.dwMenuData);
- return lpStruct;
-}
-
-void setMENUINFOFields(JNIEnv *env, jobject lpObject, MENUINFO *lpStruct)
-{
- if (!MENUINFOFc.cached) cacheMENUINFOFids(env, lpObject);
- (*env)->SetIntField(env, lpObject, MENUINFOFc.cbSize, (jint)lpStruct->cbSize);
- (*env)->SetIntField(env, lpObject, MENUINFOFc.fMask, (jint)lpStruct->fMask);
- (*env)->SetIntField(env, lpObject, MENUINFOFc.dwStyle, (jint)lpStruct->dwStyle);
- (*env)->SetIntField(env, lpObject, MENUINFOFc.cyMax, (jint)lpStruct->cyMax);
- (*env)->SetIntField(env, lpObject, MENUINFOFc.hbrBack, (jint)lpStruct->hbrBack);
- (*env)->SetIntField(env, lpObject, MENUINFOFc.dwContextHelpID, (jint)lpStruct->dwContextHelpID);
- (*env)->SetIntField(env, lpObject, MENUINFOFc.dwMenuData, (jint)lpStruct->dwMenuData);
-}
-#endif /* NO_MENUINFO */
-
-#ifndef NO_MENUITEMINFO
-typedef struct MENUITEMINFO_FID_CACHE {
- int cached;
- jclass clazz;
- jfieldID cbSize, fMask, fType, fState, wID, hSubMenu, hbmpChecked, hbmpUnchecked, dwItemData, dwTypeData, cch, hbmpItem;
-} MENUITEMINFO_FID_CACHE;
-
-MENUITEMINFO_FID_CACHE MENUITEMINFOFc;
-
-void cacheMENUITEMINFOFids(JNIEnv *env, jobject lpObject)
-{
- if (MENUITEMINFOFc.cached) return;
- MENUITEMINFOFc.clazz = (*env)->GetObjectClass(env, lpObject);
- MENUITEMINFOFc.cbSize = (*env)->GetFieldID(env, MENUITEMINFOFc.clazz, "cbSize", "I");
- MENUITEMINFOFc.fMask = (*env)->GetFieldID(env, MENUITEMINFOFc.clazz, "fMask", "I");
- MENUITEMINFOFc.fType = (*env)->GetFieldID(env, MENUITEMINFOFc.clazz, "fType", "I");
- MENUITEMINFOFc.fState = (*env)->GetFieldID(env, MENUITEMINFOFc.clazz, "fState", "I");
- MENUITEMINFOFc.wID = (*env)->GetFieldID(env, MENUITEMINFOFc.clazz, "wID", "I");
- MENUITEMINFOFc.hSubMenu = (*env)->GetFieldID(env, MENUITEMINFOFc.clazz, "hSubMenu", "I");
- MENUITEMINFOFc.hbmpChecked = (*env)->GetFieldID(env, MENUITEMINFOFc.clazz, "hbmpChecked", "I");
- MENUITEMINFOFc.hbmpUnchecked = (*env)->GetFieldID(env, MENUITEMINFOFc.clazz, "hbmpUnchecked", "I");
- MENUITEMINFOFc.dwItemData = (*env)->GetFieldID(env, MENUITEMINFOFc.clazz, "dwItemData", "I");
- MENUITEMINFOFc.dwTypeData = (*env)->GetFieldID(env, MENUITEMINFOFc.clazz, "dwTypeData", "I");
- MENUITEMINFOFc.cch = (*env)->GetFieldID(env, MENUITEMINFOFc.clazz, "cch", "I");
-#ifndef _WIN32_WCE
- MENUITEMINFOFc.hbmpItem = (*env)->GetFieldID(env, MENUITEMINFOFc.clazz, "hbmpItem", "I");
-#endif /* _WIN32_WCE */
- MENUITEMINFOFc.cached = 1;
-}
-
-MENUITEMINFO *getMENUITEMINFOFields(JNIEnv *env, jobject lpObject, MENUITEMINFO *lpStruct)
-{
- if (!MENUITEMINFOFc.cached) cacheMENUITEMINFOFids(env, lpObject);
- lpStruct->cbSize = (*env)->GetIntField(env, lpObject, MENUITEMINFOFc.cbSize);
- lpStruct->fMask = (*env)->GetIntField(env, lpObject, MENUITEMINFOFc.fMask);
- lpStruct->fType = (*env)->GetIntField(env, lpObject, MENUITEMINFOFc.fType);
- lpStruct->fState = (*env)->GetIntField(env, lpObject, MENUITEMINFOFc.fState);
- lpStruct->wID = (*env)->GetIntField(env, lpObject, MENUITEMINFOFc.wID);
- lpStruct->hSubMenu = (HMENU)(*env)->GetIntField(env, lpObject, MENUITEMINFOFc.hSubMenu);
- lpStruct->hbmpChecked = (HBITMAP)(*env)->GetIntField(env, lpObject, MENUITEMINFOFc.hbmpChecked);
- lpStruct->hbmpUnchecked = (HBITMAP)(*env)->GetIntField(env, lpObject, MENUITEMINFOFc.hbmpUnchecked);
- lpStruct->dwItemData = (*env)->GetIntField(env, lpObject, MENUITEMINFOFc.dwItemData);
- lpStruct->dwTypeData = (LPTSTR)(*env)->GetIntField(env, lpObject, MENUITEMINFOFc.dwTypeData);
- lpStruct->cch = (*env)->GetIntField(env, lpObject, MENUITEMINFOFc.cch);
-#ifndef _WIN32_WCE
- lpStruct->hbmpItem = (HBITMAP)(*env)->GetIntField(env, lpObject, MENUITEMINFOFc.hbmpItem);
-#endif /* _WIN32_WCE */
- return lpStruct;
-}
-
-void setMENUITEMINFOFields(JNIEnv *env, jobject lpObject, MENUITEMINFO *lpStruct)
-{
- if (!MENUITEMINFOFc.cached) cacheMENUITEMINFOFids(env, lpObject);
- (*env)->SetIntField(env, lpObject, MENUITEMINFOFc.cbSize, (jint)lpStruct->cbSize);
- (*env)->SetIntField(env, lpObject, MENUITEMINFOFc.fMask, (jint)lpStruct->fMask);
- (*env)->SetIntField(env, lpObject, MENUITEMINFOFc.fType, (jint)lpStruct->fType);
- (*env)->SetIntField(env, lpObject, MENUITEMINFOFc.fState, (jint)lpStruct->fState);
- (*env)->SetIntField(env, lpObject, MENUITEMINFOFc.wID, (jint)lpStruct->wID);
- (*env)->SetIntField(env, lpObject, MENUITEMINFOFc.hSubMenu, (jint)lpStruct->hSubMenu);
- (*env)->SetIntField(env, lpObject, MENUITEMINFOFc.hbmpChecked, (jint)lpStruct->hbmpChecked);
- (*env)->SetIntField(env, lpObject, MENUITEMINFOFc.hbmpUnchecked, (jint)lpStruct->hbmpUnchecked);
- (*env)->SetIntField(env, lpObject, MENUITEMINFOFc.dwItemData, (jint)lpStruct->dwItemData);
- (*env)->SetIntField(env, lpObject, MENUITEMINFOFc.dwTypeData, (jint)lpStruct->dwTypeData);
- (*env)->SetIntField(env, lpObject, MENUITEMINFOFc.cch, (jint)lpStruct->cch);
-#ifndef _WIN32_WCE
- (*env)->SetIntField(env, lpObject, MENUITEMINFOFc.hbmpItem, (jint)lpStruct->hbmpItem);
-#endif /* _WIN32_WCE */
-}
-#endif /* NO_MENUITEMINFO */
-
-#ifndef NO_MSG
-typedef struct MSG_FID_CACHE {
- int cached;
- jclass clazz;
- jfieldID hwnd, message, wParam, lParam, time, x, y;
-} MSG_FID_CACHE;
-
-MSG_FID_CACHE MSGFc;
-
-void cacheMSGFids(JNIEnv *env, jobject lpObject)
-{
- if (MSGFc.cached) return;
- MSGFc.clazz = (*env)->GetObjectClass(env, lpObject);
- MSGFc.hwnd = (*env)->GetFieldID(env, MSGFc.clazz, "hwnd", "I");
- MSGFc.message = (*env)->GetFieldID(env, MSGFc.clazz, "message", "I");
- MSGFc.wParam = (*env)->GetFieldID(env, MSGFc.clazz, "wParam", "I");
- MSGFc.lParam = (*env)->GetFieldID(env, MSGFc.clazz, "lParam", "I");
- MSGFc.time = (*env)->GetFieldID(env, MSGFc.clazz, "time", "I");
- MSGFc.x = (*env)->GetFieldID(env, MSGFc.clazz, "x", "I");
- MSGFc.y = (*env)->GetFieldID(env, MSGFc.clazz, "y", "I");
- MSGFc.cached = 1;
-}
-
-MSG *getMSGFields(JNIEnv *env, jobject lpObject, MSG *lpStruct)
-{
- if (!MSGFc.cached) cacheMSGFids(env, lpObject);
- lpStruct->hwnd = (HWND)(*env)->GetIntField(env, lpObject, MSGFc.hwnd);
- lpStruct->message = (*env)->GetIntField(env, lpObject, MSGFc.message);
- lpStruct->wParam = (*env)->GetIntField(env, lpObject, MSGFc.wParam);
- lpStruct->lParam = (*env)->GetIntField(env, lpObject, MSGFc.lParam);
- lpStruct->time = (*env)->GetIntField(env, lpObject, MSGFc.time);
- lpStruct->pt.x = (*env)->GetIntField(env, lpObject, MSGFc.x);
- lpStruct->pt.y = (*env)->GetIntField(env, lpObject, MSGFc.y);
- return lpStruct;
-}
-
-void setMSGFields(JNIEnv *env, jobject lpObject, MSG *lpStruct)
-{
- if (!MSGFc.cached) cacheMSGFids(env, lpObject);
- (*env)->SetIntField(env, lpObject, MSGFc.hwnd, (jint)lpStruct->hwnd);
- (*env)->SetIntField(env, lpObject, MSGFc.message, (jint)lpStruct->message);
- (*env)->SetIntField(env, lpObject, MSGFc.wParam, (jint)lpStruct->wParam);
- (*env)->SetIntField(env, lpObject, MSGFc.lParam, (jint)lpStruct->lParam);
- (*env)->SetIntField(env, lpObject, MSGFc.time, (jint)lpStruct->time);
- (*env)->SetIntField(env, lpObject, MSGFc.x, (jint)lpStruct->pt.x);
- (*env)->SetIntField(env, lpObject, MSGFc.y, (jint)lpStruct->pt.y);
-}
-#endif /* NO_MSG */
-
-#ifndef NO_NMHDR
-typedef struct NMHDR_FID_CACHE {
- int cached;
- jclass clazz;
- jfieldID hwndFrom, idFrom, code;
-} NMHDR_FID_CACHE;
-
-NMHDR_FID_CACHE NMHDRFc;
-
-void cacheNMHDRFids(JNIEnv *env, jobject lpObject)
-{
- if (NMHDRFc.cached) return;
- NMHDRFc.clazz = (*env)->GetObjectClass(env, lpObject);
- NMHDRFc.hwndFrom = (*env)->GetFieldID(env, NMHDRFc.clazz, "hwndFrom", "I");
- NMHDRFc.idFrom = (*env)->GetFieldID(env, NMHDRFc.clazz, "idFrom", "I");
- NMHDRFc.code = (*env)->GetFieldID(env, NMHDRFc.clazz, "code", "I");
- NMHDRFc.cached = 1;
-}
-
-NMHDR *getNMHDRFields(JNIEnv *env, jobject lpObject, NMHDR *lpStruct)
-{
- if (!NMHDRFc.cached) cacheNMHDRFids(env, lpObject);
- lpStruct->hwndFrom = (HWND)(*env)->GetIntField(env, lpObject, NMHDRFc.hwndFrom);
- lpStruct->idFrom = (*env)->GetIntField(env, lpObject, NMHDRFc.idFrom);
- lpStruct->code = (*env)->GetIntField(env, lpObject, NMHDRFc.code);
- return lpStruct;
-}
-
-void setNMHDRFields(JNIEnv *env, jobject lpObject, NMHDR *lpStruct)
-{
- if (!NMHDRFc.cached) cacheNMHDRFids(env, lpObject);
- (*env)->SetIntField(env, lpObject, NMHDRFc.hwndFrom, (jint)lpStruct->hwndFrom);
- (*env)->SetIntField(env, lpObject, NMHDRFc.idFrom, (jint)lpStruct->idFrom);
- (*env)->SetIntField(env, lpObject, NMHDRFc.code, (jint)lpStruct->code);
-}
-#endif /* NO_NMHDR */
-
-#ifndef NO_NMCUSTOMDRAW
-typedef struct NMCUSTOMDRAW_FID_CACHE {
- int cached;
- jclass clazz;
- jfieldID dwDrawStage, hdc, left, top, right, bottom, dwItemSpec, uItemState, lItemlParam;
-} NMCUSTOMDRAW_FID_CACHE;
-
-NMCUSTOMDRAW_FID_CACHE NMCUSTOMDRAWFc;
-
-void cacheNMCUSTOMDRAWFids(JNIEnv *env, jobject lpObject)
-{
- if (NMCUSTOMDRAWFc.cached) return;
- cacheNMHDRFids(env, lpObject);
- NMCUSTOMDRAWFc.clazz = (*env)->GetObjectClass(env, lpObject);
- NMCUSTOMDRAWFc.dwDrawStage = (*env)->GetFieldID(env, NMCUSTOMDRAWFc.clazz, "dwDrawStage", "I");
- NMCUSTOMDRAWFc.hdc = (*env)->GetFieldID(env, NMCUSTOMDRAWFc.clazz, "hdc", "I");
- NMCUSTOMDRAWFc.left = (*env)->GetFieldID(env, NMCUSTOMDRAWFc.clazz, "left", "I");
- NMCUSTOMDRAWFc.top = (*env)->GetFieldID(env, NMCUSTOMDRAWFc.clazz, "top", "I");
- NMCUSTOMDRAWFc.right = (*env)->GetFieldID(env, NMCUSTOMDRAWFc.clazz, "right", "I");
- NMCUSTOMDRAWFc.bottom = (*env)->GetFieldID(env, NMCUSTOMDRAWFc.clazz, "bottom", "I");
- NMCUSTOMDRAWFc.dwItemSpec = (*env)->GetFieldID(env, NMCUSTOMDRAWFc.clazz, "dwItemSpec", "I");
- NMCUSTOMDRAWFc.uItemState = (*env)->GetFieldID(env, NMCUSTOMDRAWFc.clazz, "uItemState", "I");
- NMCUSTOMDRAWFc.lItemlParam = (*env)->GetFieldID(env, NMCUSTOMDRAWFc.clazz, "lItemlParam", "I");
- NMCUSTOMDRAWFc.cached = 1;
-}
-
-NMCUSTOMDRAW *getNMCUSTOMDRAWFields(JNIEnv *env, jobject lpObject, NMCUSTOMDRAW *lpStruct)
-{
- if (!NMCUSTOMDRAWFc.cached) cacheNMCUSTOMDRAWFids(env, lpObject);
- getNMHDRFields(env, lpObject, (NMHDR *)lpStruct);
- lpStruct->dwDrawStage = (*env)->GetIntField(env, lpObject, NMCUSTOMDRAWFc.dwDrawStage);
- lpStruct->hdc = (HDC)(*env)->GetIntField(env, lpObject, NMCUSTOMDRAWFc.hdc);
- lpStruct->rc.left = (*env)->GetIntField(env, lpObject, NMCUSTOMDRAWFc.left);
- lpStruct->rc.top = (*env)->GetIntField(env, lpObject, NMCUSTOMDRAWFc.top);
- lpStruct->rc.right = (*env)->GetIntField(env, lpObject, NMCUSTOMDRAWFc.right);
- lpStruct->rc.bottom = (*env)->GetIntField(env, lpObject, NMCUSTOMDRAWFc.bottom);
- lpStruct->dwItemSpec = (*env)->GetIntField(env, lpObject, NMCUSTOMDRAWFc.dwItemSpec);
- lpStruct->uItemState = (*env)->GetIntField(env, lpObject, NMCUSTOMDRAWFc.uItemState);
- lpStruct->lItemlParam = (*env)->GetIntField(env, lpObject, NMCUSTOMDRAWFc.lItemlParam);
- return lpStruct;
-}
-
-void setNMCUSTOMDRAWFields(JNIEnv *env, jobject lpObject, NMCUSTOMDRAW *lpStruct)
-{
- if (!NMCUSTOMDRAWFc.cached) cacheNMCUSTOMDRAWFids(env, lpObject);
- setNMHDRFields(env, lpObject, (NMHDR *)lpStruct);
- (*env)->SetIntField(env, lpObject, NMCUSTOMDRAWFc.dwDrawStage, (jint)lpStruct->dwDrawStage);
- (*env)->SetIntField(env, lpObject, NMCUSTOMDRAWFc.hdc, (jint)lpStruct->hdc);
- (*env)->SetIntField(env, lpObject, NMCUSTOMDRAWFc.left, (jint)lpStruct->rc.left);
- (*env)->SetIntField(env, lpObject, NMCUSTOMDRAWFc.top, (jint)lpStruct->rc.top);
- (*env)->SetIntField(env, lpObject, NMCUSTOMDRAWFc.right, (jint)lpStruct->rc.right);
- (*env)->SetIntField(env, lpObject, NMCUSTOMDRAWFc.bottom, (jint)lpStruct->rc.bottom);
- (*env)->SetIntField(env, lpObject, NMCUSTOMDRAWFc.dwItemSpec, (jint)lpStruct->dwItemSpec);
- (*env)->SetIntField(env, lpObject, NMCUSTOMDRAWFc.uItemState, (jint)lpStruct->uItemState);
- (*env)->SetIntField(env, lpObject, NMCUSTOMDRAWFc.lItemlParam, (jint)lpStruct->lItemlParam);
-}
-#endif /* NO_NMCUSTOMDRAW */
-
-#ifndef NO_NMHEADER
-typedef struct NMHEADER_FID_CACHE {
- int cached;
- jclass clazz;
- jfieldID iItem, iButton, pitem;
-} NMHEADER_FID_CACHE;
-
-NMHEADER_FID_CACHE NMHEADERFc;
-
-void cacheNMHEADERFids(JNIEnv *env, jobject lpObject)
-{
- if (NMHEADERFc.cached) return;
- cacheNMHDRFids(env, lpObject);
- NMHEADERFc.clazz = (*env)->GetObjectClass(env, lpObject);
- NMHEADERFc.iItem = (*env)->GetFieldID(env, NMHEADERFc.clazz, "iItem", "I");
- NMHEADERFc.iButton = (*env)->GetFieldID(env, NMHEADERFc.clazz, "iButton", "I");
- NMHEADERFc.pitem = (*env)->GetFieldID(env, NMHEADERFc.clazz, "pitem", "I");
- NMHEADERFc.cached = 1;
-}
-
-NMHEADER *getNMHEADERFields(JNIEnv *env, jobject lpObject, NMHEADER *lpStruct)
-{
- if (!NMHEADERFc.cached) cacheNMHEADERFids(env, lpObject);
- getNMHDRFields(env, lpObject, (NMHDR *)lpStruct);
- lpStruct->iItem = (*env)->GetIntField(env, lpObject, NMHEADERFc.iItem);
- lpStruct->iButton = (*env)->GetIntField(env, lpObject, NMHEADERFc.iButton);
- lpStruct->pitem = (HDITEM FAR *)(*env)->GetIntField(env, lpObject, NMHEADERFc.pitem);
- return lpStruct;
-}
-
-void setNMHEADERFields(JNIEnv *env, jobject lpObject, NMHEADER *lpStruct)
-{
- if (!NMHEADERFc.cached) cacheNMHEADERFids(env, lpObject);
- setNMHDRFields(env, lpObject, (NMHDR *)lpStruct);
- (*env)->SetIntField(env, lpObject, NMHEADERFc.iItem, (jint)lpStruct->iItem);
- (*env)->SetIntField(env, lpObject, NMHEADERFc.iButton, (jint)lpStruct->iButton);
- (*env)->SetIntField(env, lpObject, NMHEADERFc.pitem, (jint)lpStruct->pitem);
-}
-#endif /* NO_NMHEADER */
-
-#ifndef NO_NMLISTVIEW
-typedef struct NMLISTVIEW_FID_CACHE {
- int cached;
- jclass clazz;
- jfieldID iItem, iSubItem, uNewState, uOldState, uChanged, x, y, lParam;
-} NMLISTVIEW_FID_CACHE;
-
-NMLISTVIEW_FID_CACHE NMLISTVIEWFc;
-
-void cacheNMLISTVIEWFids(JNIEnv *env, jobject lpObject)
-{
- if (NMLISTVIEWFc.cached) return;
- cacheNMHDRFids(env, lpObject);
- NMLISTVIEWFc.clazz = (*env)->GetObjectClass(env, lpObject);
- NMLISTVIEWFc.iItem = (*env)->GetFieldID(env, NMLISTVIEWFc.clazz, "iItem", "I");
- NMLISTVIEWFc.iSubItem = (*env)->GetFieldID(env, NMLISTVIEWFc.clazz, "iSubItem", "I");
- NMLISTVIEWFc.uNewState = (*env)->GetFieldID(env, NMLISTVIEWFc.clazz, "uNewState", "I");
- NMLISTVIEWFc.uOldState = (*env)->GetFieldID(env, NMLISTVIEWFc.clazz, "uOldState", "I");
- NMLISTVIEWFc.uChanged = (*env)->GetFieldID(env, NMLISTVIEWFc.clazz, "uChanged", "I");
- NMLISTVIEWFc.x = (*env)->GetFieldID(env, NMLISTVIEWFc.clazz, "x", "I");
- NMLISTVIEWFc.y = (*env)->GetFieldID(env, NMLISTVIEWFc.clazz, "y", "I");
- NMLISTVIEWFc.lParam = (*env)->GetFieldID(env, NMLISTVIEWFc.clazz, "lParam", "I");
- NMLISTVIEWFc.cached = 1;
-}
-
-NMLISTVIEW *getNMLISTVIEWFields(JNIEnv *env, jobject lpObject, NMLISTVIEW *lpStruct)
-{
- if (!NMLISTVIEWFc.cached) cacheNMLISTVIEWFids(env, lpObject);
- getNMHDRFields(env, lpObject, (NMHDR *)lpStruct);
- lpStruct->iItem = (*env)->GetIntField(env, lpObject, NMLISTVIEWFc.iItem);
- lpStruct->iSubItem = (*env)->GetIntField(env, lpObject, NMLISTVIEWFc.iSubItem);
- lpStruct->uNewState = (*env)->GetIntField(env, lpObject, NMLISTVIEWFc.uNewState);
- lpStruct->uOldState = (*env)->GetIntField(env, lpObject, NMLISTVIEWFc.uOldState);
- lpStruct->uChanged = (*env)->GetIntField(env, lpObject, NMLISTVIEWFc.uChanged);
- lpStruct->ptAction.x = (*env)->GetIntField(env, lpObject, NMLISTVIEWFc.x);
- lpStruct->ptAction.y = (*env)->GetIntField(env, lpObject, NMLISTVIEWFc.y);
- lpStruct->lParam = (*env)->GetIntField(env, lpObject, NMLISTVIEWFc.lParam);
- return lpStruct;
-}
-
-void setNMLISTVIEWFields(JNIEnv *env, jobject lpObject, NMLISTVIEW *lpStruct)
-{
- if (!NMLISTVIEWFc.cached) cacheNMLISTVIEWFids(env, lpObject);
- setNMHDRFields(env, lpObject, (NMHDR *)lpStruct);
- (*env)->SetIntField(env, lpObject, NMLISTVIEWFc.iItem, (jint)lpStruct->iItem);
- (*env)->SetIntField(env, lpObject, NMLISTVIEWFc.iSubItem, (jint)lpStruct->iSubItem);
- (*env)->SetIntField(env, lpObject, NMLISTVIEWFc.uNewState, (jint)lpStruct->uNewState);
- (*env)->SetIntField(env, lpObject, NMLISTVIEWFc.uOldState, (jint)lpStruct->uOldState);
- (*env)->SetIntField(env, lpObject, NMLISTVIEWFc.uChanged, (jint)lpStruct->uChanged);
- (*env)->SetIntField(env, lpObject, NMLISTVIEWFc.x, (jint)lpStruct->ptAction.x);
- (*env)->SetIntField(env, lpObject, NMLISTVIEWFc.y, (jint)lpStruct->ptAction.y);
- (*env)->SetIntField(env, lpObject, NMLISTVIEWFc.lParam, (jint)lpStruct->lParam);
-}
-#endif /* NO_NMLISTVIEW */
-
-#ifndef NO_NMLVCUSTOMDRAW
-typedef struct NMLVCUSTOMDRAW_FID_CACHE {
- int cached;
- jclass clazz;
- jfieldID clrText, clrTextBk, iSubItem;
-} NMLVCUSTOMDRAW_FID_CACHE;
-
-NMLVCUSTOMDRAW_FID_CACHE NMLVCUSTOMDRAWFc;
-
-void cacheNMLVCUSTOMDRAWFids(JNIEnv *env, jobject lpObject)
-{
- if (NMLVCUSTOMDRAWFc.cached) return;
- cacheNMCUSTOMDRAWFids(env, lpObject);
- NMLVCUSTOMDRAWFc.clazz = (*env)->GetObjectClass(env, lpObject);
- NMLVCUSTOMDRAWFc.clrText = (*env)->GetFieldID(env, NMLVCUSTOMDRAWFc.clazz, "clrText", "I");
- NMLVCUSTOMDRAWFc.clrTextBk = (*env)->GetFieldID(env, NMLVCUSTOMDRAWFc.clazz, "clrTextBk", "I");
- NMLVCUSTOMDRAWFc.iSubItem = (*env)->GetFieldID(env, NMLVCUSTOMDRAWFc.clazz, "iSubItem", "I");
- NMLVCUSTOMDRAWFc.cached = 1;
-}
-
-NMLVCUSTOMDRAW *getNMLVCUSTOMDRAWFields(JNIEnv *env, jobject lpObject, NMLVCUSTOMDRAW *lpStruct)
-{
- if (!NMLVCUSTOMDRAWFc.cached) cacheNMLVCUSTOMDRAWFids(env, lpObject);
- getNMCUSTOMDRAWFields(env, lpObject, (NMCUSTOMDRAW *)lpStruct);
- lpStruct->clrText = (*env)->GetIntField(env, lpObject, NMLVCUSTOMDRAWFc.clrText);
- lpStruct->clrTextBk = (*env)->GetIntField(env, lpObject, NMLVCUSTOMDRAWFc.clrTextBk);
- lpStruct->iSubItem = (*env)->GetIntField(env, lpObject, NMLVCUSTOMDRAWFc.iSubItem);
- return lpStruct;
-}
-
-void setNMLVCUSTOMDRAWFields(JNIEnv *env, jobject lpObject, NMLVCUSTOMDRAW *lpStruct)
-{
- if (!NMLVCUSTOMDRAWFc.cached) cacheNMLVCUSTOMDRAWFids(env, lpObject);
- setNMCUSTOMDRAWFields(env, lpObject, (NMCUSTOMDRAW *)lpStruct);
- (*env)->SetIntField(env, lpObject, NMLVCUSTOMDRAWFc.clrText, (jint)lpStruct->clrText);
- (*env)->SetIntField(env, lpObject, NMLVCUSTOMDRAWFc.clrTextBk, (jint)lpStruct->clrTextBk);
- (*env)->SetIntField(env, lpObject, NMLVCUSTOMDRAWFc.iSubItem, (jint)lpStruct->iSubItem);
-}
-#endif /* NO_NMLVCUSTOMDRAW */
-
-#ifndef NO_NMREBARCHEVRON
-typedef struct NMREBARCHEVRON_FID_CACHE {
- int cached;
- jclass clazz;
- jfieldID uBand, wID, lParam, left, top, right, bottom, lParamNM;
-} NMREBARCHEVRON_FID_CACHE;
-
-NMREBARCHEVRON_FID_CACHE NMREBARCHEVRONFc;
-
-void cacheNMREBARCHEVRONFids(JNIEnv *env, jobject lpObject)
-{
- if (NMREBARCHEVRONFc.cached) return;
- cacheNMHDRFids(env, lpObject);
- NMREBARCHEVRONFc.clazz = (*env)->GetObjectClass(env, lpObject);
- NMREBARCHEVRONFc.uBand = (*env)->GetFieldID(env, NMREBARCHEVRONFc.clazz, "uBand", "I");
- NMREBARCHEVRONFc.wID = (*env)->GetFieldID(env, NMREBARCHEVRONFc.clazz, "wID", "I");
- NMREBARCHEVRONFc.lParam = (*env)->GetFieldID(env, NMREBARCHEVRONFc.clazz, "lParam", "I");
- NMREBARCHEVRONFc.left = (*env)->GetFieldID(env, NMREBARCHEVRONFc.clazz, "left", "I");
- NMREBARCHEVRONFc.top = (*env)->GetFieldID(env, NMREBARCHEVRONFc.clazz, "top", "I");
- NMREBARCHEVRONFc.right = (*env)->GetFieldID(env, NMREBARCHEVRONFc.clazz, "right", "I");
- NMREBARCHEVRONFc.bottom = (*env)->GetFieldID(env, NMREBARCHEVRONFc.clazz, "bottom", "I");
- NMREBARCHEVRONFc.lParamNM = (*env)->GetFieldID(env, NMREBARCHEVRONFc.clazz, "lParamNM", "I");
- NMREBARCHEVRONFc.cached = 1;
-}
-
-NMREBARCHEVRON *getNMREBARCHEVRONFields(JNIEnv *env, jobject lpObject, NMREBARCHEVRON *lpStruct)
-{
- if (!NMREBARCHEVRONFc.cached) cacheNMREBARCHEVRONFids(env, lpObject);
- getNMHDRFields(env, lpObject, (NMHDR *)lpStruct);
- lpStruct->uBand = (*env)->GetIntField(env, lpObject, NMREBARCHEVRONFc.uBand);
- lpStruct->wID = (*env)->GetIntField(env, lpObject, NMREBARCHEVRONFc.wID);
- lpStruct->lParam = (*env)->GetIntField(env, lpObject, NMREBARCHEVRONFc.lParam);
- lpStruct->rc.left = (*env)->GetIntField(env, lpObject, NMREBARCHEVRONFc.left);
- lpStruct->rc.top = (*env)->GetIntField(env, lpObject, NMREBARCHEVRONFc.top);
- lpStruct->rc.right = (*env)->GetIntField(env, lpObject, NMREBARCHEVRONFc.right);
- lpStruct->rc.bottom = (*env)->GetIntField(env, lpObject, NMREBARCHEVRONFc.bottom);
- lpStruct->lParamNM = (*env)->GetIntField(env, lpObject, NMREBARCHEVRONFc.lParamNM);
- return lpStruct;
-}
-
-void setNMREBARCHEVRONFields(JNIEnv *env, jobject lpObject, NMREBARCHEVRON *lpStruct)
-{
- if (!NMREBARCHEVRONFc.cached) cacheNMREBARCHEVRONFids(env, lpObject);
- setNMHDRFields(env, lpObject, (NMHDR *)lpStruct);
- (*env)->SetIntField(env, lpObject, NMREBARCHEVRONFc.uBand, (jint)lpStruct->uBand);
- (*env)->SetIntField(env, lpObject, NMREBARCHEVRONFc.wID, (jint)lpStruct->wID);
- (*env)->SetIntField(env, lpObject, NMREBARCHEVRONFc.lParam, (jint)lpStruct->lParam);
- (*env)->SetIntField(env, lpObject, NMREBARCHEVRONFc.left, (jint)lpStruct->rc.left);
- (*env)->SetIntField(env, lpObject, NMREBARCHEVRONFc.top, (jint)lpStruct->rc.top);
- (*env)->SetIntField(env, lpObject, NMREBARCHEVRONFc.right, (jint)lpStruct->rc.right);
- (*env)->SetIntField(env, lpObject, NMREBARCHEVRONFc.bottom, (jint)lpStruct->rc.bottom);
- (*env)->SetIntField(env, lpObject, NMREBARCHEVRONFc.lParamNM, (jint)lpStruct->lParamNM);
-}
-#endif /* NO_NMREBARCHEVRON */
-
-#ifndef NO_NMTOOLBAR
-typedef struct NMTOOLBAR_FID_CACHE {
- int cached;
- jclass clazz;
- jfieldID iItem, iBitmap, idCommand, fsState, fsStyle, dwData, iString, cchText, pszText;
-#ifndef _WIN32_WCE
- jfieldID left, top, right, bottom;
-#endif /* _WIN32_WCE */
-} NMTOOLBAR_FID_CACHE;
-
-NMTOOLBAR_FID_CACHE NMTOOLBARFc;
-
-void cacheNMTOOLBARFids(JNIEnv *env, jobject lpObject)
-{
- if (NMTOOLBARFc.cached) return;
- cacheNMHDRFids(env, lpObject);
- NMTOOLBARFc.clazz = (*env)->GetObjectClass(env, lpObject);
- NMTOOLBARFc.iItem = (*env)->GetFieldID(env, NMTOOLBARFc.clazz, "iItem", "I");
- NMTOOLBARFc.iBitmap = (*env)->GetFieldID(env, NMTOOLBARFc.clazz, "iBitmap", "I");
- NMTOOLBARFc.idCommand = (*env)->GetFieldID(env, NMTOOLBARFc.clazz, "idCommand", "I");
- NMTOOLBARFc.fsState = (*env)->GetFieldID(env, NMTOOLBARFc.clazz, "fsState", "B");
- NMTOOLBARFc.fsStyle = (*env)->GetFieldID(env, NMTOOLBARFc.clazz, "fsStyle", "B");
- NMTOOLBARFc.dwData = (*env)->GetFieldID(env, NMTOOLBARFc.clazz, "dwData", "I");
- NMTOOLBARFc.iString = (*env)->GetFieldID(env, NMTOOLBARFc.clazz, "iString", "I");
- NMTOOLBARFc.cchText = (*env)->GetFieldID(env, NMTOOLBARFc.clazz, "cchText", "I");
- NMTOOLBARFc.pszText = (*env)->GetFieldID(env, NMTOOLBARFc.clazz, "pszText", "I");
-#ifndef _WIN32_WCE
- NMTOOLBARFc.left = (*env)->GetFieldID(env, NMTOOLBARFc.clazz, "left", "I");
- NMTOOLBARFc.top = (*env)->GetFieldID(env, NMTOOLBARFc.clazz, "top", "I");
- NMTOOLBARFc.right = (*env)->GetFieldID(env, NMTOOLBARFc.clazz, "right", "I");
- NMTOOLBARFc.bottom = (*env)->GetFieldID(env, NMTOOLBARFc.clazz, "bottom", "I");
-#endif /* _WIN32_WCE */
- NMTOOLBARFc.cached = 1;
-}
-
-NMTOOLBAR *getNMTOOLBARFields(JNIEnv *env, jobject lpObject, NMTOOLBAR *lpStruct)
-{
- if (!NMTOOLBARFc.cached) cacheNMTOOLBARFids(env, lpObject);
- getNMHDRFields(env, lpObject, (NMHDR *)lpStruct);
- lpStruct->iItem = (*env)->GetIntField(env, lpObject, NMTOOLBARFc.iItem);
- lpStruct->tbButton.iBitmap = (*env)->GetIntField(env, lpObject, NMTOOLBARFc.iBitmap);
- lpStruct->tbButton.idCommand = (*env)->GetIntField(env, lpObject, NMTOOLBARFc.idCommand);
- lpStruct->tbButton.fsState = (*env)->GetByteField(env, lpObject, NMTOOLBARFc.fsState);
- lpStruct->tbButton.fsStyle = (*env)->GetByteField(env, lpObject, NMTOOLBARFc.fsStyle);
- lpStruct->tbButton.dwData = (*env)->GetIntField(env, lpObject, NMTOOLBARFc.dwData);
- lpStruct->tbButton.iString = (*env)->GetIntField(env, lpObject, NMTOOLBARFc.iString);
- lpStruct->cchText = (*env)->GetIntField(env, lpObject, NMTOOLBARFc.cchText);
- lpStruct->pszText = (LPTSTR)(*env)->GetIntField(env, lpObject, NMTOOLBARFc.pszText);
-#ifndef _WIN32_WCE
- lpStruct->rcButton.left = (*env)->GetIntField(env, lpObject, NMTOOLBARFc.left);
- lpStruct->rcButton.top = (*env)->GetIntField(env, lpObject, NMTOOLBARFc.top);
- lpStruct->rcButton.right = (*env)->GetIntField(env, lpObject, NMTOOLBARFc.right);
- lpStruct->rcButton.bottom = (*env)->GetIntField(env, lpObject, NMTOOLBARFc.bottom);
-#endif /* _WIN32_WCE */
- return lpStruct;
-}
-
-void setNMTOOLBARFields(JNIEnv *env, jobject lpObject, NMTOOLBAR *lpStruct)
-{
- if (!NMTOOLBARFc.cached) cacheNMTOOLBARFids(env, lpObject);
- setNMHDRFields(env, lpObject, (NMHDR *)lpStruct);
- (*env)->SetIntField(env, lpObject, NMTOOLBARFc.iItem, (jint)lpStruct->iItem);
- (*env)->SetIntField(env, lpObject, NMTOOLBARFc.iBitmap, (jint)lpStruct->tbButton.iBitmap);
- (*env)->SetIntField(env, lpObject, NMTOOLBARFc.idCommand, (jint)lpStruct->tbButton.idCommand);
- (*env)->SetByteField(env, lpObject, NMTOOLBARFc.fsState, (jbyte)lpStruct->tbButton.fsState);
- (*env)->SetByteField(env, lpObject, NMTOOLBARFc.fsStyle, (jbyte)lpStruct->tbButton.fsStyle);
- (*env)->SetIntField(env, lpObject, NMTOOLBARFc.dwData, (jint)lpStruct->tbButton.dwData);
- (*env)->SetIntField(env, lpObject, NMTOOLBARFc.iString, (jint)lpStruct->tbButton.iString);
- (*env)->SetIntField(env, lpObject, NMTOOLBARFc.cchText, (jint)lpStruct->cchText);
- (*env)->SetIntField(env, lpObject, NMTOOLBARFc.pszText, (jint)lpStruct->pszText);
-#ifndef _WIN32_WCE
- (*env)->SetIntField(env, lpObject, NMTOOLBARFc.left, (jint)lpStruct->rcButton.left);
- (*env)->SetIntField(env, lpObject, NMTOOLBARFc.top, (jint)lpStruct->rcButton.top);
- (*env)->SetIntField(env, lpObject, NMTOOLBARFc.right, (jint)lpStruct->rcButton.right);
- (*env)->SetIntField(env, lpObject, NMTOOLBARFc.bottom, (jint)lpStruct->rcButton.bottom);
-#endif /* _WIN32_WCE */
-}
-#endif /* NO_NMTOOLBAR */
-
-#ifndef NO_NMTTDISPINFO
-typedef struct NMTTDISPINFO_FID_CACHE {
- int cached;
- jclass clazz;
- jfieldID lpszText, hinst, uFlags, lParam;
-} NMTTDISPINFO_FID_CACHE;
-
-NMTTDISPINFO_FID_CACHE NMTTDISPINFOFc;
-
-void cacheNMTTDISPINFOFids(JNIEnv *env, jobject lpObject)
-{
- if (NMTTDISPINFOFc.cached) return;
- cacheNMHDRFids(env, lpObject);
- NMTTDISPINFOFc.clazz = (*env)->GetObjectClass(env, lpObject);
- NMTTDISPINFOFc.lpszText = (*env)->GetFieldID(env, NMTTDISPINFOFc.clazz, "lpszText", "I");
- NMTTDISPINFOFc.hinst = (*env)->GetFieldID(env, NMTTDISPINFOFc.clazz, "hinst", "I");
- NMTTDISPINFOFc.uFlags = (*env)->GetFieldID(env, NMTTDISPINFOFc.clazz, "uFlags", "I");
- NMTTDISPINFOFc.lParam = (*env)->GetFieldID(env, NMTTDISPINFOFc.clazz, "lParam", "I");
- NMTTDISPINFOFc.cached = 1;
-}
-
-#ifndef NO_NMTTDISPINFOA
-NMTTDISPINFOA* getNMTTDISPINFOAFields(JNIEnv *env, jobject lpObject, NMTTDISPINFOA *lpStruct)
-{
- if (!NMTTDISPINFOFc.cached) cacheNMTTDISPINFOFids(env, lpObject);
- getNMHDRFields(env, lpObject, (NMHDR *)lpStruct);
- lpStruct->lpszText = (LPTSTR)(*env)->GetIntField(env, lpObject, NMTTDISPINFOFc.lpszText);
- lpStruct->hinst = (HINSTANCE)(*env)->GetIntField(env, lpObject, NMTTDISPINFOFc.hinst);
- lpStruct->uFlags = (*env)->GetIntField(env, lpObject, NMTTDISPINFOFc.uFlags);
- lpStruct->lParam = (*env)->GetIntField(env, lpObject, NMTTDISPINFOFc.lParam);
- return lpStruct;
-}
-
-void setNMTTDISPINFOAFields(JNIEnv *env, jobject lpObject, NMTTDISPINFOA *lpStruct)
-{
- if (!NMTTDISPINFOFc.cached) cacheNMTTDISPINFOFids(env, lpObject);
- setNMHDRFields(env, lpObject, (NMHDR *)lpStruct);
- (*env)->SetIntField(env, lpObject, NMTTDISPINFOFc.lpszText, (jint)lpStruct->lpszText);
- (*env)->SetIntField(env, lpObject, NMTTDISPINFOFc.hinst, (jint)lpStruct->hinst);
- (*env)->SetIntField(env, lpObject, NMTTDISPINFOFc.uFlags, lpStruct->uFlags);
- (*env)->SetIntField(env, lpObject, NMTTDISPINFOFc.lParam, lpStruct->lParam);
-}
-#endif /* NO_NMTTDISPINFOA */
-
-#ifndef NO_NMTTDISPINFOW
-NMTTDISPINFOW *getNMTTDISPINFOWFields(JNIEnv *env, jobject lpObject, NMTTDISPINFOW *lpStruct)
-{
- if (!NMTTDISPINFOFc.cached) cacheNMTTDISPINFOFids(env, lpObject);
- getNMHDRFields(env, lpObject, (NMHDR *)lpStruct);
- lpStruct->lpszText = (LPWSTR)(*env)->GetIntField(env, lpObject, NMTTDISPINFOFc.lpszText);
- lpStruct->hinst = (HINSTANCE)(*env)->GetIntField(env, lpObject, NMTTDISPINFOFc.hinst);
- lpStruct->uFlags = (*env)->GetIntField(env, lpObject, NMTTDISPINFOFc.uFlags);
- lpStruct->lParam = (*env)->GetIntField(env, lpObject, NMTTDISPINFOFc.lParam);
- return lpStruct;
-}
-
-void setNMTTDISPINFOWFields(JNIEnv *env, jobject lpObject, NMTTDISPINFOW *lpStruct)
-{
- if (!NMTTDISPINFOFc.cached) cacheNMTTDISPINFOFids(env, lpObject);
- setNMHDRFields(env, lpObject, (NMHDR *)lpStruct);
- (*env)->SetIntField(env, lpObject, NMTTDISPINFOFc.lpszText, (jint)lpStruct->lpszText);
- (*env)->SetIntField(env, lpObject, NMTTDISPINFOFc.hinst, (jint)lpStruct->hinst);
- (*env)->SetIntField(env, lpObject, NMTTDISPINFOFc.uFlags, (jint)lpStruct->uFlags);
- (*env)->SetIntField(env, lpObject, NMTTDISPINFOFc.lParam, (jint)lpStruct->lParam);
-}
-#endif /* NO_NMTTDISPINFOW */
-#endif /* NO_NMTTDISPINFO */
-
-#ifndef NO_NMTVCUSTOMDRAW
-typedef struct NMTVCUSTOMDRAW_FID_CACHE {
- int cached;
- jclass clazz;
- jfieldID clrText, clrTextBk;
-#ifndef _WIN32_WCE
- jfieldID iLevel;
-#endif /* _WIN32_WCE */
-} NMTVCUSTOMDRAW_FID_CACHE;
-
-NMTVCUSTOMDRAW_FID_CACHE NMTVCUSTOMDRAWFc;
-
-void cacheNMTVCUSTOMDRAWFids(JNIEnv *env, jobject lpObject)
-{
- if (NMTVCUSTOMDRAWFc.cached) return;
- cacheNMCUSTOMDRAWFids(env, lpObject);
- NMTVCUSTOMDRAWFc.clazz = (*env)->GetObjectClass(env, lpObject);
- NMTVCUSTOMDRAWFc.clrText = (*env)->GetFieldID(env, NMTVCUSTOMDRAWFc.clazz, "clrText", "I");
- NMTVCUSTOMDRAWFc.clrTextBk = (*env)->GetFieldID(env, NMTVCUSTOMDRAWFc.clazz, "clrTextBk", "I");
-#ifndef _WIN32_WCE
- NMTVCUSTOMDRAWFc.iLevel = (*env)->GetFieldID(env, NMTVCUSTOMDRAWFc.clazz, "iLevel", "I");
-#endif /* _WIN32_WCE */
- NMTVCUSTOMDRAWFc.cached = 1;
-}
-
-NMTVCUSTOMDRAW *getNMTVCUSTOMDRAWFields(JNIEnv *env, jobject lpObject, NMTVCUSTOMDRAW *lpStruct)
-{
- if (!NMTVCUSTOMDRAWFc.cached) cacheNMTVCUSTOMDRAWFids(env, lpObject);
- getNMCUSTOMDRAWFields(env, lpObject, (NMCUSTOMDRAW *)lpStruct);
- lpStruct->clrText = (*env)->GetIntField(env, lpObject, NMTVCUSTOMDRAWFc.clrText);
- lpStruct->clrTextBk = (*env)->GetIntField(env, lpObject, NMTVCUSTOMDRAWFc.clrTextBk);
-#ifndef _WIN32_WCE
- lpStruct->iLevel = (*env)->GetIntField(env, lpObject, NMTVCUSTOMDRAWFc.iLevel);
-#endif /* _WIN32_WCE */
- return lpStruct;
-}
-
-void setNMTVCUSTOMDRAWFields(JNIEnv *env, jobject lpObject, NMTVCUSTOMDRAW *lpStruct)
-{
- if (!NMTVCUSTOMDRAWFc.cached) cacheNMTVCUSTOMDRAWFids(env, lpObject);
- setNMCUSTOMDRAWFields(env, lpObject, (NMCUSTOMDRAW *)lpStruct);
- (*env)->SetIntField(env, lpObject, NMTVCUSTOMDRAWFc.clrText, (jint)lpStruct->clrText);
- (*env)->SetIntField(env, lpObject, NMTVCUSTOMDRAWFc.clrTextBk, (jint)lpStruct->clrTextBk);
-#ifndef _WIN32_WCE
- (*env)->SetIntField(env, lpObject, NMTVCUSTOMDRAWFc.iLevel, (jint)lpStruct->iLevel);
-#endif /* _WIN32_WCE */
-}
-#endif /* NO_NMTVCUSTOMDRAW */
-
-#ifndef NO_NONCLIENTMETRICS
-typedef struct NONCLIENTMETRICS_FID_CACHE {
- int cached;
- jclass clazz;
- jfieldID cbSize, iBorderWidth, iScrollWidth, iScrollHeight, iCaptionWidth, iCaptionHeight, lfCaptionFont, iSmCaptionWidth, iSmCaptionHeight, lfSmCaptionFont, iMenuWidth, iMenuHeight, lfMenuFont, lfStatusFont, lfMessageFont;
-} NONCLIENTMETRICS_FID_CACHE;
-
-NONCLIENTMETRICS_FID_CACHE NONCLIENTMETRICSFc;
-
-void cacheNONCLIENTMETRICSFids(JNIEnv *env, jobject lpObject)
-{
- if (NONCLIENTMETRICSFc.cached) return;
- NONCLIENTMETRICSFc.clazz = (*env)->GetObjectClass(env, lpObject);
- NONCLIENTMETRICSFc.cbSize = (*env)->GetFieldID(env, NONCLIENTMETRICSFc.clazz, "cbSize", "I");
- NONCLIENTMETRICSFc.iBorderWidth = (*env)->GetFieldID(env, NONCLIENTMETRICSFc.clazz, "iBorderWidth", "I");
- NONCLIENTMETRICSFc.iScrollWidth = (*env)->GetFieldID(env, NONCLIENTMETRICSFc.clazz, "iScrollWidth", "I");
- NONCLIENTMETRICSFc.iScrollHeight = (*env)->GetFieldID(env, NONCLIENTMETRICSFc.clazz, "iScrollHeight", "I");
- NONCLIENTMETRICSFc.iCaptionWidth = (*env)->GetFieldID(env, NONCLIENTMETRICSFc.clazz, "iCaptionWidth", "I");
- NONCLIENTMETRICSFc.iCaptionHeight = (*env)->GetFieldID(env, NONCLIENTMETRICSFc.clazz, "iCaptionHeight", "I");
- NONCLIENTMETRICSFc.lfCaptionFont = (*env)->GetFieldID(env, NONCLIENTMETRICSFc.clazz, "lfCaptionFont", "Lorg/eclipse/swt/internal/win32/LOGFONT;");
- NONCLIENTMETRICSFc.iSmCaptionWidth = (*env)->GetFieldID(env, NONCLIENTMETRICSFc.clazz, "iSmCaptionWidth", "I");
- NONCLIENTMETRICSFc.iSmCaptionHeight = (*env)->GetFieldID(env, NONCLIENTMETRICSFc.clazz, "iSmCaptionHeight", "I");
- NONCLIENTMETRICSFc.lfSmCaptionFont = (*env)->GetFieldID(env, NONCLIENTMETRICSFc.clazz, "lfSmCaptionFont", "Lorg/eclipse/swt/internal/win32/LOGFONT;");
- NONCLIENTMETRICSFc.iMenuWidth = (*env)->GetFieldID(env, NONCLIENTMETRICSFc.clazz, "iMenuWidth", "I");
- NONCLIENTMETRICSFc.iMenuHeight = (*env)->GetFieldID(env, NONCLIENTMETRICSFc.clazz, "iMenuHeight", "I");
- NONCLIENTMETRICSFc.lfMenuFont = (*env)->GetFieldID(env, NONCLIENTMETRICSFc.clazz, "lfMenuFont", "Lorg/eclipse/swt/internal/win32/LOGFONT;");
- NONCLIENTMETRICSFc.lfStatusFont = (*env)->GetFieldID(env, NONCLIENTMETRICSFc.clazz, "lfStatusFont", "Lorg/eclipse/swt/internal/win32/LOGFONT;");
- NONCLIENTMETRICSFc.lfMessageFont = (*env)->GetFieldID(env, NONCLIENTMETRICSFc.clazz, "lfMessageFont", "Lorg/eclipse/swt/internal/win32/LOGFONT;");
- NONCLIENTMETRICSFc.cached = 1;
-}
-
-#ifndef NONCLIENTMETRICSA
-NONCLIENTMETRICSA* getNONCLIENTMETRICSAFields(JNIEnv *env, jobject lpObject, NONCLIENTMETRICSA *lpStruct)
-{
- if (!NONCLIENTMETRICSFc.cached) cacheNONCLIENTMETRICSFids(env, lpObject);
- lpStruct->cbSize = (*env)->GetIntField(env, lpObject, NONCLIENTMETRICSFc.cbSize);
- lpStruct->iBorderWidth = (*env)->GetIntField(env, lpObject, NONCLIENTMETRICSFc.iBorderWidth);
- lpStruct->iScrollWidth = (*env)->GetIntField(env, lpObject, NONCLIENTMETRICSFc.iScrollWidth);
- lpStruct->iScrollHeight = (*env)->GetIntField(env, lpObject, NONCLIENTMETRICSFc.iScrollHeight);
- lpStruct->iCaptionWidth = (*env)->GetIntField(env, lpObject, NONCLIENTMETRICSFc.iCaptionWidth);
- lpStruct->iCaptionHeight = (*env)->GetIntField(env, lpObject, NONCLIENTMETRICSFc.iCaptionHeight);
- {
- jobject lpLogfont = (*env)->GetObjectField(env, lpObject, NONCLIENTMETRICSFc.lfCaptionFont);
- getLOGFONTAFields(env, lpLogfont, &lpStruct->lfCaptionFont);
- }
- lpStruct->iSmCaptionWidth = (*env)->GetIntField(env, lpObject, NONCLIENTMETRICSFc.iSmCaptionWidth);
- lpStruct->iSmCaptionHeight = (*env)->GetIntField(env, lpObject, NONCLIENTMETRICSFc.iSmCaptionHeight);
- {
- jobject lpLogfont = (*env)->GetObjectField(env, lpObject, NONCLIENTMETRICSFc.lfSmCaptionFont);
- getLOGFONTAFields(env, lpLogfont, &lpStruct->lfSmCaptionFont);
- }
- lpStruct->iMenuWidth = (*env)->GetIntField(env, lpObject, NONCLIENTMETRICSFc.iMenuWidth);
- lpStruct->iMenuHeight = (*env)->GetIntField(env, lpObject, NONCLIENTMETRICSFc.iMenuHeight);
- {
- jobject lpLogfont = (*env)->GetObjectField(env, lpObject, NONCLIENTMETRICSFc.lfMenuFont);
- getLOGFONTAFields(env, lpLogfont, &lpStruct->lfMenuFont);
- }
- {
- jobject lpLogfont = (*env)->GetObjectField(env, lpObject, NONCLIENTMETRICSFc.lfStatusFont);
- getLOGFONTAFields(env, lpLogfont, &lpStruct->lfStatusFont);
- }
- {
- jobject lpLogfont = (*env)->GetObjectField(env, lpObject, NONCLIENTMETRICSFc.lfMessageFont);
- getLOGFONTAFields(env, lpLogfont, &lpStruct->lfMessageFont);
- }
- return lpStruct;
-}
-
-void setNONCLIENTMETRICSAFields(JNIEnv *env, jobject lpObject, NONCLIENTMETRICSA *lpStruct)
-{
- if (!NONCLIENTMETRICSFc.cached) cacheNONCLIENTMETRICSFids(env, lpObject);
- (*env)->SetIntField(env, lpObject, NONCLIENTMETRICSFc.cbSize, lpStruct->cbSize);
- (*env)->SetIntField(env, lpObject, NONCLIENTMETRICSFc.iBorderWidth, lpStruct->iBorderWidth);
- (*env)->SetIntField(env, lpObject, NONCLIENTMETRICSFc.iScrollWidth, lpStruct->iScrollWidth);
- (*env)->SetIntField(env, lpObject, NONCLIENTMETRICSFc.iScrollHeight, lpStruct->iScrollHeight);
- (*env)->SetIntField(env, lpObject, NONCLIENTMETRICSFc.iCaptionWidth, lpStruct->iCaptionWidth);
- (*env)->SetIntField(env, lpObject, NONCLIENTMETRICSFc.iCaptionHeight, lpStruct->iCaptionHeight);
- {
- jobject lpLogfont = (*env)->GetObjectField(env, lpObject, NONCLIENTMETRICSFc.lfCaptionFont);
- setLOGFONTAFields(env, lpLogfont, &lpStruct->lfCaptionFont);
- }
- (*env)->SetIntField(env, lpObject, NONCLIENTMETRICSFc.iSmCaptionWidth, lpStruct->iSmCaptionWidth);
- (*env)->SetIntField(env, lpObject, NONCLIENTMETRICSFc.iSmCaptionHeight, lpStruct->iSmCaptionHeight);
- {
- jobject lpLogfont = (*env)->GetObjectField(env, lpObject, NONCLIENTMETRICSFc.lfSmCaptionFont);
- setLOGFONTAFields(env, lpLogfont, &lpStruct->lfSmCaptionFont);
- }
- (*env)->SetIntField(env, lpObject, NONCLIENTMETRICSFc.iMenuWidth, lpStruct->iMenuWidth);
- (*env)->SetIntField(env, lpObject, NONCLIENTMETRICSFc.iMenuHeight, lpStruct->iMenuHeight);
- {
- jobject lpLogfont = (*env)->GetObjectField(env, lpObject, NONCLIENTMETRICSFc.lfMenuFont);
- setLOGFONTAFields(env, lpLogfont, &lpStruct->lfMenuFont);
- }
- {
- jobject lpLogfont = (*env)->GetObjectField(env, lpObject, NONCLIENTMETRICSFc.lfStatusFont);
- setLOGFONTAFields(env, lpLogfont, &lpStruct->lfStatusFont);
- }
- {
- jobject lpLogfont = (*env)->GetObjectField(env, lpObject, NONCLIENTMETRICSFc.lfMessageFont);
- setLOGFONTAFields(env, lpLogfont, &lpStruct->lfMessageFont);
- }
-}
-#endif /* NONCLIENTMETRICSA */
-
-#ifndef NONCLIENTMETRICSW
-NONCLIENTMETRICSW *getNONCLIENTMETRICSWFields(JNIEnv *env, jobject lpObject, NONCLIENTMETRICSW *lpStruct)
-{
- if (!NONCLIENTMETRICSFc.cached) cacheNONCLIENTMETRICSFids(env, lpObject);
- lpStruct->cbSize = (*env)->GetIntField(env, lpObject, NONCLIENTMETRICSFc.cbSize);
- lpStruct->iBorderWidth = (*env)->GetIntField(env, lpObject, NONCLIENTMETRICSFc.iBorderWidth);
- lpStruct->iScrollWidth = (*env)->GetIntField(env, lpObject, NONCLIENTMETRICSFc.iScrollWidth);
- lpStruct->iScrollHeight = (*env)->GetIntField(env, lpObject, NONCLIENTMETRICSFc.iScrollHeight);
- lpStruct->iCaptionWidth = (*env)->GetIntField(env, lpObject, NONCLIENTMETRICSFc.iCaptionWidth);
- lpStruct->iCaptionHeight = (*env)->GetIntField(env, lpObject, NONCLIENTMETRICSFc.iCaptionHeight);
- {
- jobject lpObject1 = (*env)->GetObjectField(env, lpObject, NONCLIENTMETRICSFc.lfCaptionFont);
- getLOGFONTWFields(env, lpObject1, &lpStruct->lfCaptionFont);
- }
- lpStruct->iSmCaptionWidth = (*env)->GetIntField(env, lpObject, NONCLIENTMETRICSFc.iSmCaptionWidth);
- lpStruct->iSmCaptionHeight = (*env)->GetIntField(env, lpObject, NONCLIENTMETRICSFc.iSmCaptionHeight);
- {
- jobject lpObject1 = (*env)->GetObjectField(env, lpObject, NONCLIENTMETRICSFc.lfSmCaptionFont);
- getLOGFONTWFields(env, lpObject1, &lpStruct->lfSmCaptionFont);
- }
- lpStruct->iMenuWidth = (*env)->GetIntField(env, lpObject, NONCLIENTMETRICSFc.iMenuWidth);
- lpStruct->iMenuHeight = (*env)->GetIntField(env, lpObject, NONCLIENTMETRICSFc.iMenuHeight);
- {
- jobject lpObject1 = (*env)->GetObjectField(env, lpObject, NONCLIENTMETRICSFc.lfMenuFont);
- getLOGFONTWFields(env, lpObject1, &lpStruct->lfMenuFont);
- }
- {
- jobject lpObject1 = (*env)->GetObjectField(env, lpObject, NONCLIENTMETRICSFc.lfStatusFont);
- getLOGFONTWFields(env, lpObject1, &lpStruct->lfStatusFont);
- }
- {
- jobject lpObject1 = (*env)->GetObjectField(env, lpObject, NONCLIENTMETRICSFc.lfMessageFont);
- getLOGFONTWFields(env, lpObject1, &lpStruct->lfMessageFont);
- }
- return lpStruct;
-}
-
-void setNONCLIENTMETRICSWFields(JNIEnv *env, jobject lpObject, NONCLIENTMETRICSW *lpStruct)
-{
- if (!NONCLIENTMETRICSFc.cached) cacheNONCLIENTMETRICSFids(env, lpObject);
- (*env)->SetIntField(env, lpObject, NONCLIENTMETRICSFc.cbSize, (jint)lpStruct->cbSize);
- (*env)->SetIntField(env, lpObject, NONCLIENTMETRICSFc.iBorderWidth, (jint)lpStruct->iBorderWidth);
- (*env)->SetIntField(env, lpObject, NONCLIENTMETRICSFc.iScrollWidth, (jint)lpStruct->iScrollWidth);
- (*env)->SetIntField(env, lpObject, NONCLIENTMETRICSFc.iScrollHeight, (jint)lpStruct->iScrollHeight);
- (*env)->SetIntField(env, lpObject, NONCLIENTMETRICSFc.iCaptionWidth, (jint)lpStruct->iCaptionWidth);
- (*env)->SetIntField(env, lpObject, NONCLIENTMETRICSFc.iCaptionHeight, (jint)lpStruct->iCaptionHeight);
- {
- jobject lpObject1 = (*env)->GetObjectField(env, lpObject, NONCLIENTMETRICSFc.lfCaptionFont);
- setLOGFONTWFields(env, lpObject1, &lpStruct->lfCaptionFont);
- }
- (*env)->SetIntField(env, lpObject, NONCLIENTMETRICSFc.iSmCaptionWidth, (jint)lpStruct->iSmCaptionWidth);
- (*env)->SetIntField(env, lpObject, NONCLIENTMETRICSFc.iSmCaptionHeight, (jint)lpStruct->iSmCaptionHeight);
- {
- jobject lpObject1 = (*env)->GetObjectField(env, lpObject, NONCLIENTMETRICSFc.lfSmCaptionFont);
- setLOGFONTWFields(env, lpObject1, &lpStruct->lfSmCaptionFont);
- }
- (*env)->SetIntField(env, lpObject, NONCLIENTMETRICSFc.iMenuWidth, (jint)lpStruct->iMenuWidth);
- (*env)->SetIntField(env, lpObject, NONCLIENTMETRICSFc.iMenuHeight, (jint)lpStruct->iMenuHeight);
- {
- jobject lpObject1 = (*env)->GetObjectField(env, lpObject, NONCLIENTMETRICSFc.lfMenuFont);
- setLOGFONTWFields(env, lpObject1, &lpStruct->lfMenuFont);
- }
- {
- jobject lpObject1 = (*env)->GetObjectField(env, lpObject, NONCLIENTMETRICSFc.lfStatusFont);
- setLOGFONTWFields(env, lpObject1, &lpStruct->lfStatusFont);
- }
- {
- jobject lpObject1 = (*env)->GetObjectField(env, lpObject, NONCLIENTMETRICSFc.lfMessageFont);
- setLOGFONTWFields(env, lpObject1, &lpStruct->lfMessageFont);
- }
-}
-#endif /* NONCLIENTMETRICSW */
-#endif /* NO_NONCLIENTMETRICS */
-
-#ifndef NO_OPENFILENAME
-typedef struct OPENFILENAME_FID_CACHE {
- int cached;
- jclass clazz;
- jfieldID lStructSize, hwndOwner, hInstance, lpstrFilter, lpstrCustomFilter, nMaxCustFilter, nFilterIndex, lpstrFile, nMaxFile, lpstrFileTitle, nMaxFileTitle, lpstrInitialDir, lpstrTitle, Flags, nFileOffset, nFileExtension, lpstrDefExt, lCustData, lpfnHook, lpTemplateName;
-} OPENFILENAME_FID_CACHE;
-
-OPENFILENAME_FID_CACHE OPENFILENAMEFc;
-
-void cacheOPENFILENAMEFids(JNIEnv *env, jobject lpObject)
-{
- if (OPENFILENAMEFc.cached) return;
- OPENFILENAMEFc.clazz = (*env)->GetObjectClass(env, lpObject);
- OPENFILENAMEFc.lStructSize = (*env)->GetFieldID(env, OPENFILENAMEFc.clazz, "lStructSize", "I");
- OPENFILENAMEFc.hwndOwner = (*env)->GetFieldID(env, OPENFILENAMEFc.clazz, "hwndOwner", "I");
- OPENFILENAMEFc.hInstance = (*env)->GetFieldID(env, OPENFILENAMEFc.clazz, "hInstance", "I");
- OPENFILENAMEFc.lpstrFilter = (*env)->GetFieldID(env, OPENFILENAMEFc.clazz, "lpstrFilter", "I");
- OPENFILENAMEFc.lpstrCustomFilter = (*env)->GetFieldID(env, OPENFILENAMEFc.clazz, "lpstrCustomFilter", "I");
- OPENFILENAMEFc.nMaxCustFilter = (*env)->GetFieldID(env, OPENFILENAMEFc.clazz, "nMaxCustFilter", "I");
- OPENFILENAMEFc.nFilterIndex = (*env)->GetFieldID(env, OPENFILENAMEFc.clazz, "nFilterIndex", "I");
- OPENFILENAMEFc.lpstrFile = (*env)->GetFieldID(env, OPENFILENAMEFc.clazz, "lpstrFile", "I");
- OPENFILENAMEFc.nMaxFile = (*env)->GetFieldID(env, OPENFILENAMEFc.clazz, "nMaxFile", "I");
- OPENFILENAMEFc.lpstrFileTitle = (*env)->GetFieldID(env, OPENFILENAMEFc.clazz, "lpstrFileTitle", "I");
- OPENFILENAMEFc.nMaxFileTitle = (*env)->GetFieldID(env, OPENFILENAMEFc.clazz, "nMaxFileTitle", "I");
- OPENFILENAMEFc.lpstrInitialDir = (*env)->GetFieldID(env, OPENFILENAMEFc.clazz, "lpstrInitialDir", "I");
- OPENFILENAMEFc.lpstrTitle = (*env)->GetFieldID(env, OPENFILENAMEFc.clazz, "lpstrTitle", "I");
- OPENFILENAMEFc.Flags = (*env)->GetFieldID(env, OPENFILENAMEFc.clazz, "Flags", "I");
- OPENFILENAMEFc.nFileOffset = (*env)->GetFieldID(env, OPENFILENAMEFc.clazz, "nFileOffset", "S");
- OPENFILENAMEFc.nFileExtension = (*env)->GetFieldID(env, OPENFILENAMEFc.clazz, "nFileExtension", "S");
- OPENFILENAMEFc.lpstrDefExt = (*env)->GetFieldID(env, OPENFILENAMEFc.clazz, "lpstrDefExt", "I");
- OPENFILENAMEFc.lCustData = (*env)->GetFieldID(env, OPENFILENAMEFc.clazz, "lCustData", "I");
- OPENFILENAMEFc.lpfnHook = (*env)->GetFieldID(env, OPENFILENAMEFc.clazz, "lpfnHook", "I");
- OPENFILENAMEFc.lpTemplateName = (*env)->GetFieldID(env, OPENFILENAMEFc.clazz, "lpTemplateName", "I");
- OPENFILENAMEFc.cached = 1;
-}
-
-OPENFILENAME *getOPENFILENAMEFields(JNIEnv *env, jobject lpObject, OPENFILENAME *lpStruct)
-{
- if (!OPENFILENAMEFc.cached) cacheOPENFILENAMEFids(env, lpObject);
- lpStruct->lStructSize = (*env)->GetIntField(env, lpObject, OPENFILENAMEFc.lStructSize);
- lpStruct->hwndOwner = (HWND)(*env)->GetIntField(env, lpObject, OPENFILENAMEFc.hwndOwner);
- lpStruct->hInstance = (HINSTANCE)(*env)->GetIntField(env, lpObject, OPENFILENAMEFc.hInstance);
- lpStruct->lpstrFilter = (LPCTSTR)(*env)->GetIntField(env, lpObject, OPENFILENAMEFc.lpstrFilter);
- lpStruct->lpstrCustomFilter = (LPTSTR)(*env)->GetIntField(env, lpObject, OPENFILENAMEFc.lpstrCustomFilter);
- lpStruct->nMaxCustFilter = (*env)->GetIntField(env, lpObject, OPENFILENAMEFc.nMaxCustFilter);
- lpStruct->nFilterIndex = (*env)->GetIntField(env, lpObject, OPENFILENAMEFc.nFilterIndex);
- lpStruct->lpstrFile = (LPTSTR)(*env)->GetIntField(env, lpObject, OPENFILENAMEFc.lpstrFile);
- lpStruct->nMaxFile = (*env)->GetIntField(env, lpObject, OPENFILENAMEFc.nMaxFile);
- lpStruct->lpstrFileTitle = (LPTSTR)(*env)->GetIntField(env, lpObject, OPENFILENAMEFc.lpstrFileTitle);
- lpStruct->nMaxFileTitle = (*env)->GetIntField(env, lpObject, OPENFILENAMEFc.nMaxFileTitle);
- lpStruct->lpstrInitialDir = (LPCTSTR)(*env)->GetIntField(env, lpObject, OPENFILENAMEFc.lpstrInitialDir);
- lpStruct->lpstrTitle = (LPCTSTR)(*env)->GetIntField(env, lpObject, OPENFILENAMEFc.lpstrTitle);
- lpStruct->Flags = (*env)->GetIntField(env, lpObject, OPENFILENAMEFc.Flags);
- lpStruct->nFileOffset = (*env)->GetShortField(env, lpObject, OPENFILENAMEFc.nFileOffset);
- lpStruct->nFileExtension = (*env)->GetShortField(env, lpObject, OPENFILENAMEFc.nFileExtension);
- lpStruct->lpstrDefExt = (LPCTSTR)(*env)->GetIntField(env, lpObject, OPENFILENAMEFc.lpstrDefExt);
- lpStruct->lCustData = (*env)->GetIntField(env, lpObject, OPENFILENAMEFc.lCustData);
- lpStruct->lpfnHook = (LPOFNHOOKPROC)(*env)->GetIntField(env, lpObject, OPENFILENAMEFc.lpfnHook);
- lpStruct->lpTemplateName = (LPCTSTR)(*env)->GetIntField(env, lpObject, OPENFILENAMEFc.lpTemplateName);
- return lpStruct;
-}
-
-void setOPENFILENAMEFields(JNIEnv *env, jobject lpObject, OPENFILENAME *lpStruct)
-{
- if (!OPENFILENAMEFc.cached) cacheOPENFILENAMEFids(env, lpObject);
- (*env)->SetIntField(env, lpObject, OPENFILENAMEFc.lStructSize, (jint)lpStruct->lStructSize);
- (*env)->SetIntField(env, lpObject, OPENFILENAMEFc.hwndOwner, (jint)lpStruct->hwndOwner);
- (*env)->SetIntField(env, lpObject, OPENFILENAMEFc.hInstance, (jint)lpStruct->hInstance);
- (*env)->SetIntField(env, lpObject, OPENFILENAMEFc.lpstrFilter, (jint)lpStruct->lpstrFilter);
- (*env)->SetIntField(env, lpObject, OPENFILENAMEFc.lpstrCustomFilter, (jint)lpStruct->lpstrCustomFilter);
- (*env)->SetIntField(env, lpObject, OPENFILENAMEFc.nMaxCustFilter, (jint)lpStruct->nMaxCustFilter);
- (*env)->SetIntField(env, lpObject, OPENFILENAMEFc.nFilterIndex, (jint)lpStruct->nFilterIndex);
- (*env)->SetIntField(env, lpObject, OPENFILENAMEFc.lpstrFile, (jint)lpStruct->lpstrFile);
- (*env)->SetIntField(env, lpObject, OPENFILENAMEFc.nMaxFile, (jint)lpStruct->nMaxFile);
- (*env)->SetIntField(env, lpObject, OPENFILENAMEFc.lpstrFileTitle, (jint)lpStruct->lpstrFileTitle);
- (*env)->SetIntField(env, lpObject, OPENFILENAMEFc.nMaxFileTitle, (jint)lpStruct->nMaxFileTitle);
- (*env)->SetIntField(env, lpObject, OPENFILENAMEFc.lpstrInitialDir, (jint)lpStruct->lpstrInitialDir);
- (*env)->SetIntField(env, lpObject, OPENFILENAMEFc.lpstrTitle, (jint)lpStruct->lpstrTitle);
- (*env)->SetIntField(env, lpObject, OPENFILENAMEFc.Flags, (jint)lpStruct->Flags);
- (*env)->SetShortField(env, lpObject, OPENFILENAMEFc.nFileOffset, (jshort)lpStruct->nFileOffset);
- (*env)->SetShortField(env, lpObject, OPENFILENAMEFc.nFileExtension, (jshort)lpStruct->nFileExtension);
- (*env)->SetIntField(env, lpObject, OPENFILENAMEFc.lpstrDefExt, (jint)lpStruct->lpstrDefExt);
- (*env)->SetIntField(env, lpObject, OPENFILENAMEFc.lCustData, (jint)lpStruct->lCustData);
- (*env)->SetIntField(env, lpObject, OPENFILENAMEFc.lpfnHook, (jint)lpStruct->lpfnHook);
- (*env)->SetIntField(env, lpObject, OPENFILENAMEFc.lpTemplateName, (jint)lpStruct->lpTemplateName);
-}
-#endif /* NO_OPENFILENAME */
-
-#ifndef NO_OSVERSIONINFO
-typedef struct OSVERSIONINFO_FID_CACHE {
- int cached;
- jclass clazz;
- jfieldID dwOSVersionInfoSize, dwMajorVersion, dwMinorVersion, dwBuildNumber, dwPlatformId;
-} OSVERSIONINFO_FID_CACHE;
-
-OSVERSIONINFO_FID_CACHE OSVERSIONINFOFc;
-
-void cacheOSVERSIONINFOFids(JNIEnv *env, jobject lpObject)
-{
- if (OSVERSIONINFOFc.cached) return;
- OSVERSIONINFOFc.clazz = (*env)->GetObjectClass(env, lpObject);
- OSVERSIONINFOFc.dwOSVersionInfoSize = (*env)->GetFieldID(env, OSVERSIONINFOFc.clazz, "dwOSVersionInfoSize", "I");
- OSVERSIONINFOFc.dwMajorVersion = (*env)->GetFieldID(env, OSVERSIONINFOFc.clazz, "dwMajorVersion", "I");
- OSVERSIONINFOFc.dwMinorVersion = (*env)->GetFieldID(env, OSVERSIONINFOFc.clazz, "dwMinorVersion", "I");
- OSVERSIONINFOFc.dwBuildNumber = (*env)->GetFieldID(env, OSVERSIONINFOFc.clazz, "dwBuildNumber", "I");
- OSVERSIONINFOFc.dwPlatformId = (*env)->GetFieldID(env, OSVERSIONINFOFc.clazz, "dwPlatformId", "I");
- OSVERSIONINFOFc.cached = 1;
-}
-
-#ifndef OSVERSIONINFOA
-OSVERSIONINFOA* getOSVERSIONINFOAFields(JNIEnv *env, jobject lpObject, OSVERSIONINFOA *lpStruct)
-{
- if (!OSVERSIONINFOFc.cached) cacheOSVERSIONINFOFids(env, lpObject);
- lpStruct->dwOSVersionInfoSize = (*env)->GetIntField(env, lpObject, OSVERSIONINFOFc.dwOSVersionInfoSize);
- lpStruct->dwMajorVersion = (*env)->GetIntField(env, lpObject, OSVERSIONINFOFc.dwMajorVersion);
- lpStruct->dwMinorVersion = (*env)->GetIntField(env, lpObject, OSVERSIONINFOFc.dwMinorVersion);
- lpStruct->dwBuildNumber = (*env)->GetIntField(env, lpObject, OSVERSIONINFOFc.dwBuildNumber);
- lpStruct->dwPlatformId = (*env)->GetIntField(env, lpObject, OSVERSIONINFOFc.dwPlatformId);
- return lpStruct;
-}
-
-void setOSVERSIONINFOAFields(JNIEnv *env, jobject lpObject, OSVERSIONINFOA *lpStruct)
-{
- if (!OSVERSIONINFOFc.cached) cacheOSVERSIONINFOFids(env, lpObject);
- (*env)->SetIntField(env, lpObject, OSVERSIONINFOFc.dwOSVersionInfoSize, lpStruct->dwOSVersionInfoSize);
- (*env)->SetIntField(env, lpObject, OSVERSIONINFOFc.dwMajorVersion, lpStruct->dwMajorVersion);
- (*env)->SetIntField(env, lpObject, OSVERSIONINFOFc.dwMinorVersion, lpStruct->dwMinorVersion);
- (*env)->SetIntField(env, lpObject, OSVERSIONINFOFc.dwBuildNumber, lpStruct->dwBuildNumber);
- (*env)->SetIntField(env, lpObject, OSVERSIONINFOFc.dwPlatformId, lpStruct->dwPlatformId);
-}
-#endif /* OSVERSIONINFOA */
-
-#ifndef OSVERSIONINFOW
-OSVERSIONINFOW *getOSVERSIONINFOWFields(JNIEnv *env, jobject lpObject, OSVERSIONINFOW *lpStruct)
-{
- if (!OSVERSIONINFOFc.cached) cacheOSVERSIONINFOFids(env, lpObject);
- lpStruct->dwOSVersionInfoSize = (*env)->GetIntField(env, lpObject, OSVERSIONINFOFc.dwOSVersionInfoSize);
- lpStruct->dwMajorVersion = (*env)->GetIntField(env, lpObject, OSVERSIONINFOFc.dwMajorVersion);
- lpStruct->dwMinorVersion = (*env)->GetIntField(env, lpObject, OSVERSIONINFOFc.dwMinorVersion);
- lpStruct->dwBuildNumber = (*env)->GetIntField(env, lpObject, OSVERSIONINFOFc.dwBuildNumber);
- lpStruct->dwPlatformId = (*env)->GetIntField(env, lpObject, OSVERSIONINFOFc.dwPlatformId);
- return lpStruct;
-}
-
-void setOSVERSIONINFOWFields(JNIEnv *env, jobject lpObject, OSVERSIONINFOW *lpStruct)
-{
- if (!OSVERSIONINFOFc.cached) cacheOSVERSIONINFOFids(env, lpObject);
- (*env)->SetIntField(env, lpObject, OSVERSIONINFOFc.dwOSVersionInfoSize, (jint)lpStruct->dwOSVersionInfoSize);
- (*env)->SetIntField(env, lpObject, OSVERSIONINFOFc.dwMajorVersion, (jint)lpStruct->dwMajorVersion);
- (*env)->SetIntField(env, lpObject, OSVERSIONINFOFc.dwMinorVersion, (jint)lpStruct->dwMinorVersion);
- (*env)->SetIntField(env, lpObject, OSVERSIONINFOFc.dwBuildNumber, (jint)lpStruct->dwBuildNumber);
- (*env)->SetIntField(env, lpObject, OSVERSIONINFOFc.dwPlatformId, (jint)lpStruct->dwPlatformId);
-}
-#endif /* OSVERSIONINFOW */
-#endif /* NO_OSVERSIONINFO */
-
-#ifndef NO_PAINTSTRUCT
-typedef struct PAINTSTRUCT_FID_CACHE {
- int cached;
- jclass clazz;
- jfieldID hdc, fErase, left, top, right, bottom, fRestore, fIncUpdate /*, pad0, pad1, pad2, pad3, pad4, pad5, pad6, pad7 */;
-} PAINTSTRUCT_FID_CACHE;
-
-PAINTSTRUCT_FID_CACHE PAINTSTRUCTFc;
-
-void cachePAINTSTRUCTFids(JNIEnv *env, jobject lpObject)
-{
- if (PAINTSTRUCTFc.cached) return;
- PAINTSTRUCTFc.clazz = (*env)->GetObjectClass(env, lpObject);
- PAINTSTRUCTFc.hdc = (*env)->GetFieldID(env, PAINTSTRUCTFc.clazz, "hdc", "I");
- PAINTSTRUCTFc.fErase = (*env)->GetFieldID(env, PAINTSTRUCTFc.clazz, "fErase", "Z");
- PAINTSTRUCTFc.left = (*env)->GetFieldID(env, PAINTSTRUCTFc.clazz, "left", "I");
- PAINTSTRUCTFc.top = (*env)->GetFieldID(env, PAINTSTRUCTFc.clazz, "top", "I");
- PAINTSTRUCTFc.right = (*env)->GetFieldID(env, PAINTSTRUCTFc.clazz, "right", "I");
- PAINTSTRUCTFc.bottom = (*env)->GetFieldID(env, PAINTSTRUCTFc.clazz, "bottom", "I");
- PAINTSTRUCTFc.fRestore = (*env)->GetFieldID(env, PAINTSTRUCTFc.clazz, "fRestore", "Z");
- PAINTSTRUCTFc.fIncUpdate = (*env)->GetFieldID(env, PAINTSTRUCTFc.clazz, "fIncUpdate", "Z");
- PAINTSTRUCTFc.cached = 1;
-}
-
-PAINTSTRUCT *getPAINTSTRUCTFields(JNIEnv *env, jobject lpObject, PAINTSTRUCT *lpStruct)
-{
- if (!PAINTSTRUCTFc.cached) cachePAINTSTRUCTFids(env, lpObject);
- lpStruct->hdc = (HDC)(*env)->GetIntField(env, lpObject, PAINTSTRUCTFc.hdc);
- lpStruct->fErase = (*env)->GetBooleanField(env, lpObject, PAINTSTRUCTFc.fErase);
- lpStruct->rcPaint.left = (*env)->GetIntField(env, lpObject, PAINTSTRUCTFc.left);
- lpStruct->rcPaint.top = (*env)->GetIntField(env, lpObject, PAINTSTRUCTFc.top);
- lpStruct->rcPaint.right = (*env)->GetIntField(env, lpObject, PAINTSTRUCTFc.right);
- lpStruct->rcPaint.bottom = (*env)->GetIntField(env, lpObject, PAINTSTRUCTFc.bottom);
- lpStruct->fRestore = (*env)->GetBooleanField(env, lpObject, PAINTSTRUCTFc.fRestore);
- lpStruct->fIncUpdate = (*env)->GetBooleanField(env, lpObject, PAINTSTRUCTFc.fIncUpdate);
- return lpStruct;
-}
-
-void setPAINTSTRUCTFields(JNIEnv *env, jobject lpObject, PAINTSTRUCT *lpStruct)
-{
- if (!PAINTSTRUCTFc.cached) cachePAINTSTRUCTFids(env, lpObject);
- (*env)->SetIntField(env, lpObject, PAINTSTRUCTFc.hdc, (jint)lpStruct->hdc);
- (*env)->SetBooleanField(env, lpObject, PAINTSTRUCTFc.fErase, (jboolean)lpStruct->fErase);
- (*env)->SetIntField(env, lpObject, PAINTSTRUCTFc.left, (jint)lpStruct->rcPaint.left);
- (*env)->SetIntField(env, lpObject, PAINTSTRUCTFc.top, (jint)lpStruct->rcPaint.top);
- (*env)->SetIntField(env, lpObject, PAINTSTRUCTFc.right, (jint)lpStruct->rcPaint.right);
- (*env)->SetIntField(env, lpObject, PAINTSTRUCTFc.bottom, (jint)lpStruct->rcPaint.bottom);
- (*env)->SetBooleanField(env, lpObject, PAINTSTRUCTFc.fRestore, (jboolean)lpStruct->fRestore);
- (*env)->SetBooleanField(env, lpObject, PAINTSTRUCTFc.fIncUpdate, (jboolean)lpStruct->fIncUpdate);
-}
-#endif /* NO_PAINTSTRUCT */
-
-#ifndef NO_POINT
-typedef struct POINT_FID_CACHE {
- int cached;
- jclass clazz;
- jfieldID x, y;
-} POINT_FID_CACHE;
-
-POINT_FID_CACHE POINTFc;
-
-void cachePOINTFids(JNIEnv *env, jobject lpObject)
-{
- if (POINTFc.cached) return;
- POINTFc.clazz = (*env)->GetObjectClass(env, lpObject);
- POINTFc.x = (*env)->GetFieldID(env, POINTFc.clazz, "x", "I");
- POINTFc.y = (*env)->GetFieldID(env, POINTFc.clazz, "y", "I");
- POINTFc.cached = 1;
-}
-
-POINT *getPOINTFields(JNIEnv *env, jobject lpObject, POINT *lpStruct)
-{
- if (!POINTFc.cached) cachePOINTFids(env, lpObject);
- lpStruct->x = (*env)->GetIntField(env, lpObject, POINTFc.x);
- lpStruct->y = (*env)->GetIntField(env, lpObject, POINTFc.y);
- return lpStruct;
-}
-
-void setPOINTFields(JNIEnv *env, jobject lpObject, POINT *lpStruct)
-{
- if (!POINTFc.cached) cachePOINTFids(env, lpObject);
- (*env)->SetIntField(env, lpObject, POINTFc.x, (jint)lpStruct->x);
- (*env)->SetIntField(env, lpObject, POINTFc.y, (jint)lpStruct->y);
-}
-#endif /* NO_POINT */
-
-#ifndef NO_PRINTDLG
-typedef struct PRINTDLG_FID_CACHE {
- int cached;
- jclass clazz;
- jfieldID lStructSize, hwndOwner, hDevMode, hDevNames, hDC, Flags, nFromPage, nToPage, nMinPage, nMaxPage, nCopies, hInstance, lCustData, lpfnPrintHook, lpfnSetupHook, lpPrintTemplateName, lpSetupTemplateName, hPrintTemplate, hSetupTemplate;
-} PRINTDLG_FID_CACHE;
-
-PRINTDLG_FID_CACHE PRINTDLGFc;
-
-void cachePRINTDLGFids(JNIEnv *env, jobject lpObject)
-{
- if (PRINTDLGFc.cached) return;
- PRINTDLGFc.clazz = (*env)->GetObjectClass(env, lpObject);
- PRINTDLGFc.lStructSize = (*env)->GetFieldID(env, PRINTDLGFc.clazz, "lStructSize", "I");
- PRINTDLGFc.hwndOwner = (*env)->GetFieldID(env, PRINTDLGFc.clazz, "hwndOwner", "I");
- PRINTDLGFc.hDevMode = (*env)->GetFieldID(env, PRINTDLGFc.clazz, "hDevMode", "I");
- PRINTDLGFc.hDevNames = (*env)->GetFieldID(env, PRINTDLGFc.clazz, "hDevNames", "I");
- PRINTDLGFc.hDC = (*env)->GetFieldID(env, PRINTDLGFc.clazz, "hDC", "I");
- PRINTDLGFc.Flags = (*env)->GetFieldID(env, PRINTDLGFc.clazz, "Flags", "I");
- PRINTDLGFc.nFromPage = (*env)->GetFieldID(env, PRINTDLGFc.clazz, "nFromPage", "S");
- PRINTDLGFc.nToPage = (*env)->GetFieldID(env, PRINTDLGFc.clazz, "nToPage", "S");
- PRINTDLGFc.nMinPage = (*env)->GetFieldID(env, PRINTDLGFc.clazz, "nMinPage", "S");
- PRINTDLGFc.nMaxPage = (*env)->GetFieldID(env, PRINTDLGFc.clazz, "nMaxPage", "S");
- PRINTDLGFc.nCopies = (*env)->GetFieldID(env, PRINTDLGFc.clazz, "nCopies", "S");
- PRINTDLGFc.hInstance = (*env)->GetFieldID(env, PRINTDLGFc.clazz, "hInstance", "I");
- PRINTDLGFc.lCustData = (*env)->GetFieldID(env, PRINTDLGFc.clazz, "lCustData", "I");
- PRINTDLGFc.lpfnPrintHook = (*env)->GetFieldID(env, PRINTDLGFc.clazz, "lpfnPrintHook", "I");
- PRINTDLGFc.lpfnSetupHook = (*env)->GetFieldID(env, PRINTDLGFc.clazz, "lpfnSetupHook", "I");
- PRINTDLGFc.lpPrintTemplateName = (*env)->GetFieldID(env, PRINTDLGFc.clazz, "lpPrintTemplateName", "I");
- PRINTDLGFc.lpSetupTemplateName = (*env)->GetFieldID(env, PRINTDLGFc.clazz, "lpSetupTemplateName", "I");
- PRINTDLGFc.hPrintTemplate = (*env)->GetFieldID(env, PRINTDLGFc.clazz, "hPrintTemplate", "I");
- PRINTDLGFc.hSetupTemplate = (*env)->GetFieldID(env, PRINTDLGFc.clazz, "hSetupTemplate", "I");
- PRINTDLGFc.cached = 1;
-}
-
-PRINTDLG *getPRINTDLGFields(JNIEnv *env, jobject lpObject, PRINTDLG *lpStruct)
-{
- if (!PRINTDLGFc.cached) cachePRINTDLGFids(env, lpObject);
- lpStruct->lStructSize = (*env)->GetIntField(env, lpObject, PRINTDLGFc.lStructSize);
- lpStruct->hwndOwner = (HWND)(*env)->GetIntField(env, lpObject, PRINTDLGFc.hwndOwner);
- lpStruct->hDevMode = (HGLOBAL)(*env)->GetIntField(env, lpObject, PRINTDLGFc.hDevMode);
- lpStruct->hDevNames = (HGLOBAL)(*env)->GetIntField(env, lpObject, PRINTDLGFc.hDevNames);
- lpStruct->hDC = (HDC)(*env)->GetIntField(env, lpObject, PRINTDLGFc.hDC);
- lpStruct->Flags = (*env)->GetIntField(env, lpObject, PRINTDLGFc.Flags);
- lpStruct->nFromPage = (*env)->GetShortField(env, lpObject, PRINTDLGFc.nFromPage);
- lpStruct->nToPage = (*env)->GetShortField(env, lpObject, PRINTDLGFc.nToPage);
- lpStruct->nMinPage = (*env)->GetShortField(env, lpObject, PRINTDLGFc.nMinPage);
- lpStruct->nMaxPage = (*env)->GetShortField(env, lpObject, PRINTDLGFc.nMaxPage);
- lpStruct->nCopies = (*env)->GetShortField(env, lpObject, PRINTDLGFc.nCopies);
- lpStruct->hInstance = (HINSTANCE)(*env)->GetIntField(env, lpObject, PRINTDLGFc.hInstance);
- lpStruct->lCustData = (*env)->GetIntField(env, lpObject, PRINTDLGFc.lCustData);
- lpStruct->lpfnPrintHook = (LPPRINTHOOKPROC)(*env)->GetIntField(env, lpObject, PRINTDLGFc.lpfnPrintHook);
- lpStruct->lpfnSetupHook = (LPPRINTHOOKPROC)(*env)->GetIntField(env, lpObject, PRINTDLGFc.lpfnSetupHook);
- lpStruct->lpPrintTemplateName = (LPCTSTR)(*env)->GetIntField(env, lpObject, PRINTDLGFc.lpPrintTemplateName);
- lpStruct->lpSetupTemplateName = (LPCTSTR)(*env)->GetIntField(env, lpObject, PRINTDLGFc.lpSetupTemplateName);
- lpStruct->hPrintTemplate = (HGLOBAL)(*env)->GetIntField(env, lpObject, PRINTDLGFc.hPrintTemplate);
- lpStruct->hSetupTemplate = (HGLOBAL)(*env)->GetIntField(env, lpObject, PRINTDLGFc.hSetupTemplate);
- return lpStruct;
-}
-
-void setPRINTDLGFields(JNIEnv *env, jobject lpObject, PRINTDLG *lpStruct)
-{
- if (!PRINTDLGFc.cached) cachePRINTDLGFids(env, lpObject);
- (*env)->SetIntField(env, lpObject, PRINTDLGFc.lStructSize, (jint)lpStruct->lStructSize);
- (*env)->SetIntField(env, lpObject, PRINTDLGFc.hwndOwner, (jint)lpStruct->hwndOwner);
- (*env)->SetIntField(env, lpObject, PRINTDLGFc.hDevMode, (jint)lpStruct->hDevMode);
- (*env)->SetIntField(env, lpObject, PRINTDLGFc.hDevNames, (jint)lpStruct->hDevNames);
- (*env)->SetIntField(env, lpObject, PRINTDLGFc.hDC, (jint)lpStruct->hDC);
- (*env)->SetIntField(env, lpObject, PRINTDLGFc.Flags, (jint)lpStruct->Flags);
- (*env)->SetShortField(env, lpObject, PRINTDLGFc.nFromPage, (jshort)lpStruct->nFromPage);
- (*env)->SetShortField(env, lpObject, PRINTDLGFc.nToPage, (jshort)lpStruct->nToPage);
- (*env)->SetShortField(env, lpObject, PRINTDLGFc.nMinPage, (jshort)lpStruct->nMinPage);
- (*env)->SetShortField(env, lpObject, PRINTDLGFc.nMaxPage, (jshort)lpStruct->nMaxPage);
- (*env)->SetShortField(env, lpObject, PRINTDLGFc.nCopies, (jshort)lpStruct->nCopies);
- (*env)->SetIntField(env, lpObject, PRINTDLGFc.hInstance, (jint)lpStruct->hInstance);
- (*env)->SetIntField(env, lpObject, PRINTDLGFc.lCustData, (jint)lpStruct->lCustData);
- (*env)->SetIntField(env, lpObject, PRINTDLGFc.lpfnPrintHook, (jint)lpStruct->lpfnPrintHook);
- (*env)->SetIntField(env, lpObject, PRINTDLGFc.lpfnSetupHook, (jint)lpStruct->lpfnSetupHook);
- (*env)->SetIntField(env, lpObject, PRINTDLGFc.lpPrintTemplateName, (jint)lpStruct->lpPrintTemplateName);
- (*env)->SetIntField(env, lpObject, PRINTDLGFc.lpSetupTemplateName, (jint)lpStruct->lpSetupTemplateName);
- (*env)->SetIntField(env, lpObject, PRINTDLGFc.hPrintTemplate, (jint)lpStruct->hPrintTemplate);
- (*env)->SetIntField(env, lpObject, PRINTDLGFc.hSetupTemplate, (jint)lpStruct->hSetupTemplate);
-}
-#endif /* NO_PRINTDLG */
-
-#ifndef NO_REBARBANDINFO
-typedef struct REBARBANDINFO_FID_CACHE {
- int cached;
- jclass clazz;
- jfieldID cbSize, fMask, fStyle, clrFore, clrBack, lpText, cch, iImage, hwndChild, cxMinChild, cyMinChild, cx, hbmBack, wID, cyChild, cyMaxChild, cyIntegral, cxIdeal, lParam;
-#ifndef _WIN32_WCE
- jfieldID cxHeader;
-#endif /* _WIN32_WCE */
-} REBARBANDINFO_FID_CACHE;
-
-REBARBANDINFO_FID_CACHE REBARBANDINFOFc;
-
-void cacheREBARBANDINFOFids(JNIEnv *env, jobject lpObject)
-{
- if (REBARBANDINFOFc.cached) return;
- REBARBANDINFOFc.clazz = (*env)->GetObjectClass(env, lpObject);
- REBARBANDINFOFc.cbSize = (*env)->GetFieldID(env, REBARBANDINFOFc.clazz, "cbSize", "I");
- REBARBANDINFOFc.fMask = (*env)->GetFieldID(env, REBARBANDINFOFc.clazz, "fMask", "I");
- REBARBANDINFOFc.fStyle = (*env)->GetFieldID(env, REBARBANDINFOFc.clazz, "fStyle", "I");
- REBARBANDINFOFc.clrFore = (*env)->GetFieldID(env, REBARBANDINFOFc.clazz, "clrFore", "I");
- REBARBANDINFOFc.clrBack = (*env)->GetFieldID(env, REBARBANDINFOFc.clazz, "clrBack", "I");
- REBARBANDINFOFc.lpText = (*env)->GetFieldID(env, REBARBANDINFOFc.clazz, "lpText", "I");
- REBARBANDINFOFc.cch = (*env)->GetFieldID(env, REBARBANDINFOFc.clazz, "cch", "I");
- REBARBANDINFOFc.iImage = (*env)->GetFieldID(env, REBARBANDINFOFc.clazz, "iImage", "I");
- REBARBANDINFOFc.hwndChild = (*env)->GetFieldID(env, REBARBANDINFOFc.clazz, "hwndChild", "I");
- REBARBANDINFOFc.cxMinChild = (*env)->GetFieldID(env, REBARBANDINFOFc.clazz, "cxMinChild", "I");
- REBARBANDINFOFc.cyMinChild = (*env)->GetFieldID(env, REBARBANDINFOFc.clazz, "cyMinChild", "I");
- REBARBANDINFOFc.cx = (*env)->GetFieldID(env, REBARBANDINFOFc.clazz, "cx", "I");
- REBARBANDINFOFc.hbmBack = (*env)->GetFieldID(env, REBARBANDINFOFc.clazz, "hbmBack", "I");
- REBARBANDINFOFc.wID = (*env)->GetFieldID(env, REBARBANDINFOFc.clazz, "wID", "I");
- REBARBANDINFOFc.cyChild = (*env)->GetFieldID(env, REBARBANDINFOFc.clazz, "cyChild", "I");
- REBARBANDINFOFc.cyMaxChild = (*env)->GetFieldID(env, REBARBANDINFOFc.clazz, "cyMaxChild", "I");
- REBARBANDINFOFc.cyIntegral = (*env)->GetFieldID(env, REBARBANDINFOFc.clazz, "cyIntegral", "I");
- REBARBANDINFOFc.cxIdeal = (*env)->GetFieldID(env, REBARBANDINFOFc.clazz, "cxIdeal", "I");
- REBARBANDINFOFc.lParam = (*env)->GetFieldID(env, REBARBANDINFOFc.clazz, "lParam", "I");
-#ifndef _WIN32_WCE
- REBARBANDINFOFc.cxHeader = (*env)->GetFieldID(env, REBARBANDINFOFc.clazz, "cxHeader", "I");
-#endif /* _WIN32_WCE */
- REBARBANDINFOFc.cached = 1;
-}
-
-REBARBANDINFO *getREBARBANDINFOFields(JNIEnv *env, jobject lpObject, REBARBANDINFO *lpStruct)
-{
- if (!REBARBANDINFOFc.cached) cacheREBARBANDINFOFids(env, lpObject);
- lpStruct->cbSize = (*env)->GetIntField(env, lpObject, REBARBANDINFOFc.cbSize);
- lpStruct->fMask = (*env)->GetIntField(env, lpObject, REBARBANDINFOFc.fMask);
- lpStruct->fStyle = (*env)->GetIntField(env, lpObject, REBARBANDINFOFc.fStyle);
- lpStruct->clrFore = (*env)->GetIntField(env, lpObject, REBARBANDINFOFc.clrFore);
- lpStruct->clrBack = (*env)->GetIntField(env, lpObject, REBARBANDINFOFc.clrBack);
- lpStruct->lpText = (LPTSTR)(*env)->GetIntField(env, lpObject, REBARBANDINFOFc.lpText);
- lpStruct->cch = (*env)->GetIntField(env, lpObject, REBARBANDINFOFc.cch);
- lpStruct->iImage = (*env)->GetIntField(env, lpObject, REBARBANDINFOFc.iImage);
- lpStruct->hwndChild = (HWND)(*env)->GetIntField(env, lpObject, REBARBANDINFOFc.hwndChild);
- lpStruct->cxMinChild = (*env)->GetIntField(env, lpObject, REBARBANDINFOFc.cxMinChild);
- lpStruct->cyMinChild = (*env)->GetIntField(env, lpObject, REBARBANDINFOFc.cyMinChild);
- lpStruct->cx = (*env)->GetIntField(env, lpObject, REBARBANDINFOFc.cx);
- lpStruct->hbmBack = (HBITMAP)(*env)->GetIntField(env, lpObject, REBARBANDINFOFc.hbmBack);
- lpStruct->wID = (*env)->GetIntField(env, lpObject, REBARBANDINFOFc.wID);
- lpStruct->cyChild = (*env)->GetIntField(env, lpObject, REBARBANDINFOFc.cyChild);
- lpStruct->cyMaxChild = (*env)->GetIntField(env, lpObject, REBARBANDINFOFc.cyMaxChild);
- lpStruct->cyIntegral = (*env)->GetIntField(env, lpObject, REBARBANDINFOFc.cyIntegral);
- lpStruct->cxIdeal = (*env)->GetIntField(env, lpObject, REBARBANDINFOFc.cxIdeal);
- lpStruct->lParam = (*env)->GetIntField(env, lpObject, REBARBANDINFOFc.lParam);
-#ifndef _WIN32_WCE
- lpStruct->cxHeader = (*env)->GetIntField(env, lpObject, REBARBANDINFOFc.cxHeader);
-#endif /* _WIN32_WCE */
- return lpStruct;
-}
-
-void setREBARBANDINFOFields(JNIEnv *env, jobject lpObject, REBARBANDINFO *lpStruct)
-{
- if (!REBARBANDINFOFc.cached) cacheREBARBANDINFOFids(env, lpObject);
- (*env)->SetIntField(env, lpObject, REBARBANDINFOFc.cbSize, (jint)lpStruct->cbSize);
- (*env)->SetIntField(env, lpObject, REBARBANDINFOFc.fMask, (jint)lpStruct->fMask);
- (*env)->SetIntField(env, lpObject, REBARBANDINFOFc.fStyle, (jint)lpStruct->fStyle);
- (*env)->SetIntField(env, lpObject, REBARBANDINFOFc.clrFore, (jint)lpStruct->clrFore);
- (*env)->SetIntField(env, lpObject, REBARBANDINFOFc.clrBack, (jint)lpStruct->clrBack);
- (*env)->SetIntField(env, lpObject, REBARBANDINFOFc.lpText, (jint)lpStruct->lpText);
- (*env)->SetIntField(env, lpObject, REBARBANDINFOFc.cch, (jint)lpStruct->cch);
- (*env)->SetIntField(env, lpObject, REBARBANDINFOFc.iImage, (jint)lpStruct->iImage);
- (*env)->SetIntField(env, lpObject, REBARBANDINFOFc.hwndChild, (jint)lpStruct->hwndChild);
- (*env)->SetIntField(env, lpObject, REBARBANDINFOFc.cxMinChild, (jint)lpStruct->cxMinChild);
- (*env)->SetIntField(env, lpObject, REBARBANDINFOFc.cyMinChild, (jint)lpStruct->cyMinChild);
- (*env)->SetIntField(env, lpObject, REBARBANDINFOFc.cx, (jint)lpStruct->cx);
- (*env)->SetIntField(env, lpObject, REBARBANDINFOFc.hbmBack, (jint)lpStruct->hbmBack);
- (*env)->SetIntField(env, lpObject, REBARBANDINFOFc.wID, (jint)lpStruct->wID);
- (*env)->SetIntField(env, lpObject, REBARBANDINFOFc.cyChild, (jint)lpStruct->cyChild);
- (*env)->SetIntField(env, lpObject, REBARBANDINFOFc.cyMaxChild, (jint)lpStruct->cyMaxChild);
- (*env)->SetIntField(env, lpObject, REBARBANDINFOFc.cyIntegral, (jint)lpStruct->cyIntegral);
- (*env)->SetIntField(env, lpObject, REBARBANDINFOFc.cxIdeal, (jint)lpStruct->cxIdeal);
- (*env)->SetIntField(env, lpObject, REBARBANDINFOFc.lParam, (jint)lpStruct->lParam);
-#ifndef _WIN32_WCE
- (*env)->SetIntField(env, lpObject, REBARBANDINFOFc.cxHeader, (jint)lpStruct->cxHeader);
-#endif /* _WIN32_WCE */
-}
-#endif /* NO_REBARBANDINFO */
-
-#ifndef NO_RECT
-typedef struct RECT_FID_CACHE {
- int cached;
- jclass clazz;
- jfieldID left, top, right, bottom;
-} RECT_FID_CACHE;
-
-RECT_FID_CACHE RECTFc;
-
-void cacheRECTFids(JNIEnv *env, jobject lpObject)
-{
- if (RECTFc.cached) return;
- RECTFc.clazz = (*env)->GetObjectClass(env, lpObject);
- RECTFc.left = (*env)->GetFieldID(env, RECTFc.clazz, "left", "I");
- RECTFc.top = (*env)->GetFieldID(env, RECTFc.clazz, "top", "I");
- RECTFc.right = (*env)->GetFieldID(env, RECTFc.clazz, "right", "I");
- RECTFc.bottom = (*env)->GetFieldID(env, RECTFc.clazz, "bottom", "I");
- RECTFc.cached = 1;
-}
-
-RECT *getRECTFields(JNIEnv *env, jobject lpObject, RECT *lpStruct)
-{
- if (!RECTFc.cached) cacheRECTFids(env, lpObject);
- lpStruct->left = (*env)->GetIntField(env, lpObject, RECTFc.left);
- lpStruct->top = (*env)->GetIntField(env, lpObject, RECTFc.top);
- lpStruct->right = (*env)->GetIntField(env, lpObject, RECTFc.right);
- lpStruct->bottom = (*env)->GetIntField(env, lpObject, RECTFc.bottom);
- return lpStruct;
-}
-
-void setRECTFields(JNIEnv *env, jobject lpObject, RECT *lpStruct)
-{
- if (!RECTFc.cached) cacheRECTFids(env, lpObject);
- (*env)->SetIntField(env, lpObject, RECTFc.left, (jint)lpStruct->left);
- (*env)->SetIntField(env, lpObject, RECTFc.top, (jint)lpStruct->top);
- (*env)->SetIntField(env, lpObject, RECTFc.right, (jint)lpStruct->right);
- (*env)->SetIntField(env, lpObject, RECTFc.bottom, (jint)lpStruct->bottom);
-}
-#endif /* NO_RECT */
-
-#ifndef NO_SCROLLINFO
-typedef struct SCROLLINFO_FID_CACHE {
- int cached;
- jclass clazz;
- jfieldID cbSize, fMask, nMin, nMax, nPage, nPos, nTrackPos;
-} SCROLLINFO_FID_CACHE;
-
-SCROLLINFO_FID_CACHE SCROLLINFOFc;
-
-void cacheSCROLLINFOFids(JNIEnv *env, jobject lpObject)
-{
- if (SCROLLINFOFc.cached) return;
- SCROLLINFOFc.clazz = (*env)->GetObjectClass(env, lpObject);
- SCROLLINFOFc.cbSize = (*env)->GetFieldID(env, SCROLLINFOFc.clazz, "cbSize", "I");
- SCROLLINFOFc.fMask = (*env)->GetFieldID(env, SCROLLINFOFc.clazz, "fMask", "I");
- SCROLLINFOFc.nMin = (*env)->GetFieldID(env, SCROLLINFOFc.clazz, "nMin", "I");
- SCROLLINFOFc.nMax = (*env)->GetFieldID(env, SCROLLINFOFc.clazz, "nMax", "I");
- SCROLLINFOFc.nPage = (*env)->GetFieldID(env, SCROLLINFOFc.clazz, "nPage", "I");
- SCROLLINFOFc.nPos = (*env)->GetFieldID(env, SCROLLINFOFc.clazz, "nPos", "I");
- SCROLLINFOFc.nTrackPos = (*env)->GetFieldID(env, SCROLLINFOFc.clazz, "nTrackPos", "I");
- SCROLLINFOFc.cached = 1;
-}
-
-SCROLLINFO *getSCROLLINFOFields(JNIEnv *env, jobject lpObject, SCROLLINFO *lpStruct)
-{
- if (!SCROLLINFOFc.cached) cacheSCROLLINFOFids(env, lpObject);
- lpStruct->cbSize = (*env)->GetIntField(env, lpObject, SCROLLINFOFc.cbSize);
- lpStruct->fMask = (*env)->GetIntField(env, lpObject, SCROLLINFOFc.fMask);
- lpStruct->nMin = (*env)->GetIntField(env, lpObject, SCROLLINFOFc.nMin);
- lpStruct->nMax = (*env)->GetIntField(env, lpObject, SCROLLINFOFc.nMax);
- lpStruct->nPage = (*env)->GetIntField(env, lpObject, SCROLLINFOFc.nPage);
- lpStruct->nPos = (*env)->GetIntField(env, lpObject, SCROLLINFOFc.nPos);
- lpStruct->nTrackPos = (*env)->GetIntField(env, lpObject, SCROLLINFOFc.nTrackPos);
- return lpStruct;
-}
-
-void setSCROLLINFOFields(JNIEnv *env, jobject lpObject, SCROLLINFO *lpStruct)
-{
- if (!SCROLLINFOFc.cached) cacheSCROLLINFOFids(env, lpObject);
- (*env)->SetIntField(env, lpObject, SCROLLINFOFc.cbSize, (jint)lpStruct->cbSize);
- (*env)->SetIntField(env, lpObject, SCROLLINFOFc.fMask, (jint)lpStruct->fMask);
- (*env)->SetIntField(env, lpObject, SCROLLINFOFc.nMin, (jint)lpStruct->nMin);
- (*env)->SetIntField(env, lpObject, SCROLLINFOFc.nMax, (jint)lpStruct->nMax);
- (*env)->SetIntField(env, lpObject, SCROLLINFOFc.nPage, (jint)lpStruct->nPage);
- (*env)->SetIntField(env, lpObject, SCROLLINFOFc.nPos, (jint)lpStruct->nPos);
- (*env)->SetIntField(env, lpObject, SCROLLINFOFc.nTrackPos, (jint)lpStruct->nTrackPos);
-}
-#endif /* NO_SCROLLINFO */
-
-#ifndef NO_SHACTIVATEINFO
-typedef struct SHACTIVATEINFO_FID_CACHE {
- int cached;
- jclass clazz;
- jfieldID cbSize, hwndLastFocus, fSipUp, fSipOnDeactivation, fActive, fReserved;
-} SHACTIVATEINFO_FID_CACHE;
-
-SHACTIVATEINFO_FID_CACHE SHACTIVATEINFOFc;
-
-void cacheSHACTIVATEINFOFids(JNIEnv *env, jobject lpObject)
-{
- if (SHACTIVATEINFOFc.cached) return;
- SHACTIVATEINFOFc.clazz = (*env)->GetObjectClass(env, lpObject);
- SHACTIVATEINFOFc.cbSize = (*env)->GetFieldID(env, SHACTIVATEINFOFc.clazz, "cbSize", "I");
- SHACTIVATEINFOFc.hwndLastFocus = (*env)->GetFieldID(env, SHACTIVATEINFOFc.clazz, "hwndLastFocus", "I");
- SHACTIVATEINFOFc.fSipUp = (*env)->GetFieldID(env, SHACTIVATEINFOFc.clazz, "fSipUp", "I");
- SHACTIVATEINFOFc.fSipOnDeactivation = (*env)->GetFieldID(env, SHACTIVATEINFOFc.clazz, "fSipOnDeactivation", "I");
- SHACTIVATEINFOFc.fActive = (*env)->GetFieldID(env, SHACTIVATEINFOFc.clazz, "fActive", "I");
- SHACTIVATEINFOFc.fReserved = (*env)->GetFieldID(env, SHACTIVATEINFOFc.clazz, "fReserved", "I");
- SHACTIVATEINFOFc.cached = 1;
-}
-
-SHACTIVATEINFO *getSHACTIVATEINFOFields(JNIEnv *env, jobject lpObject, SHACTIVATEINFO *lpStruct)
-{
- if (!SHACTIVATEINFOFc.cached) cacheSHACTIVATEINFOFids(env, lpObject);
- lpStruct->cbSize = (*env)->GetIntField(env, lpObject, SHACTIVATEINFOFc.cbSize);
- lpStruct->hwndLastFocus = (HWND)(*env)->GetIntField(env, lpObject, SHACTIVATEINFOFc.hwndLastFocus);
- lpStruct->fSipUp = (*env)->GetIntField(env, lpObject, SHACTIVATEINFOFc.fSipUp);
- lpStruct->fSipOnDeactivation = (*env)->GetIntField(env, lpObject, SHACTIVATEINFOFc.fSipOnDeactivation);
- lpStruct->fActive = (*env)->GetIntField(env, lpObject, SHACTIVATEINFOFc.fActive);
- lpStruct->fReserved = (*env)->GetIntField(env, lpObject, SHACTIVATEINFOFc.fReserved);
- return lpStruct;
-}
-
-void setSHACTIVATEINFOFields(JNIEnv *env, jobject lpObject, SHACTIVATEINFO *lpStruct)
-{
- if (!SHACTIVATEINFOFc.cached) cacheSHACTIVATEINFOFids(env, lpObject);
- (*env)->SetIntField(env, lpObject, SHACTIVATEINFOFc.cbSize, (jint)lpStruct->cbSize);
- (*env)->SetIntField(env, lpObject, SHACTIVATEINFOFc.hwndLastFocus, (jint)lpStruct->hwndLastFocus);
- (*env)->SetIntField(env, lpObject, SHACTIVATEINFOFc.fSipUp, (jint)lpStruct->fSipUp);
- (*env)->SetIntField(env, lpObject, SHACTIVATEINFOFc.fSipOnDeactivation, (jint)lpStruct->fSipOnDeactivation);
- (*env)->SetIntField(env, lpObject, SHACTIVATEINFOFc.fActive, (jint)lpStruct->fActive);
- (*env)->SetIntField(env, lpObject, SHACTIVATEINFOFc.fReserved, (jint)lpStruct->fReserved);
-}
-#endif /* NO_SHACTIVATEINFO */
-
-#ifndef NO_SHELLEXECUTEINFO
-typedef struct SHELLEXECUTEINFO_FID_CACHE {
- int cached;
- jclass clazz;
- jfieldID cbSize, fMask, hwnd, lpVerb, lpFile, lpParameters, lpDirectory, nShow, hInstApp, lpIDList, lpClass, hkeyClass, dwHotKey, hIcon, hProcess;
-} SHELLEXECUTEINFO_FID_CACHE;
-
-SHELLEXECUTEINFO_FID_CACHE SHELLEXECUTEINFOFc;
-
-void cacheSHELLEXECUTEINFOFids(JNIEnv *env, jobject lpObject)
-{
- if (SHELLEXECUTEINFOFc.cached) return;
- SHELLEXECUTEINFOFc.clazz = (*env)->GetObjectClass(env, lpObject);
- SHELLEXECUTEINFOFc.cbSize = (*env)->GetFieldID(env, SHELLEXECUTEINFOFc.clazz, "cbSize", "I");
- SHELLEXECUTEINFOFc.fMask = (*env)->GetFieldID(env, SHELLEXECUTEINFOFc.clazz, "fMask", "I");
- SHELLEXECUTEINFOFc.hwnd = (*env)->GetFieldID(env, SHELLEXECUTEINFOFc.clazz, "hwnd", "I");
- SHELLEXECUTEINFOFc.lpVerb = (*env)->GetFieldID(env, SHELLEXECUTEINFOFc.clazz, "lpVerb", "I");
- SHELLEXECUTEINFOFc.lpFile = (*env)->GetFieldID(env, SHELLEXECUTEINFOFc.clazz, "lpFile", "I");
- SHELLEXECUTEINFOFc.lpParameters = (*env)->GetFieldID(env, SHELLEXECUTEINFOFc.clazz, "lpParameters", "I");
- SHELLEXECUTEINFOFc.lpDirectory = (*env)->GetFieldID(env, SHELLEXECUTEINFOFc.clazz, "lpDirectory", "I");
- SHELLEXECUTEINFOFc.nShow = (*env)->GetFieldID(env, SHELLEXECUTEINFOFc.clazz, "nShow", "I");
- SHELLEXECUTEINFOFc.hInstApp = (*env)->GetFieldID(env, SHELLEXECUTEINFOFc.clazz, "hInstApp", "I");
- SHELLEXECUTEINFOFc.lpIDList = (*env)->GetFieldID(env, SHELLEXECUTEINFOFc.clazz, "lpIDList", "I");
- SHELLEXECUTEINFOFc.lpClass = (*env)->GetFieldID(env, SHELLEXECUTEINFOFc.clazz, "lpClass", "I");
- SHELLEXECUTEINFOFc.hkeyClass = (*env)->GetFieldID(env, SHELLEXECUTEINFOFc.clazz, "hkeyClass", "I");
- SHELLEXECUTEINFOFc.dwHotKey = (*env)->GetFieldID(env, SHELLEXECUTEINFOFc.clazz, "dwHotKey", "I");
- SHELLEXECUTEINFOFc.hIcon = (*env)->GetFieldID(env, SHELLEXECUTEINFOFc.clazz, "hIcon", "I");
- SHELLEXECUTEINFOFc.hProcess = (*env)->GetFieldID(env, SHELLEXECUTEINFOFc.clazz, "hProcess", "I");
- SHELLEXECUTEINFOFc.cached = 1;
-}
-
-SHELLEXECUTEINFO *getSHELLEXECUTEINFOFields(JNIEnv *env, jobject lpObject, SHELLEXECUTEINFO *lpStruct)
-{
- if (!SHELLEXECUTEINFOFc.cached) cacheSHELLEXECUTEINFOFids(env, lpObject);
- lpStruct->cbSize = (*env)->GetIntField(env, lpObject, SHELLEXECUTEINFOFc.cbSize);
- lpStruct->fMask = (*env)->GetIntField(env, lpObject, SHELLEXECUTEINFOFc.fMask);
- lpStruct->hwnd = (HWND)(*env)->GetIntField(env, lpObject, SHELLEXECUTEINFOFc.hwnd);
- lpStruct->lpVerb = (LPCTSTR)(*env)->GetIntField(env, lpObject, SHELLEXECUTEINFOFc.lpVerb);
- lpStruct->lpFile = (LPCTSTR)(*env)->GetIntField(env, lpObject, SHELLEXECUTEINFOFc.lpFile);
- lpStruct->lpParameters = (LPCTSTR)(*env)->GetIntField(env, lpObject, SHELLEXECUTEINFOFc.lpParameters);
- lpStruct->lpDirectory = (LPCTSTR)(*env)->GetIntField(env, lpObject, SHELLEXECUTEINFOFc.lpDirectory);
- lpStruct->nShow = (*env)->GetIntField(env, lpObject, SHELLEXECUTEINFOFc.nShow);
- lpStruct->hInstApp = (HINSTANCE)(*env)->GetIntField(env, lpObject, SHELLEXECUTEINFOFc.hInstApp);
- lpStruct->lpIDList = (LPVOID)(*env)->GetIntField(env, lpObject, SHELLEXECUTEINFOFc.lpIDList);
- lpStruct->lpClass = (LPCTSTR)(*env)->GetIntField(env, lpObject, SHELLEXECUTEINFOFc.lpClass);
- lpStruct->hkeyClass = (HKEY)(*env)->GetIntField(env, lpObject, SHELLEXECUTEINFOFc.hkeyClass);
- lpStruct->dwHotKey = (*env)->GetIntField(env, lpObject, SHELLEXECUTEINFOFc.dwHotKey);
- lpStruct->hIcon = (HANDLE)(*env)->GetIntField(env, lpObject, SHELLEXECUTEINFOFc.hIcon);
- lpStruct->hProcess = (HANDLE)(*env)->GetIntField(env, lpObject, SHELLEXECUTEINFOFc.hProcess);
- return lpStruct;
-}
-
-void setSHELLEXECUTEINFOFields(JNIEnv *env, jobject lpObject, SHELLEXECUTEINFO *lpStruct)
-{
- if (!SHELLEXECUTEINFOFc.cached) cacheSHELLEXECUTEINFOFids(env, lpObject);
- (*env)->SetIntField(env, lpObject, SHELLEXECUTEINFOFc.cbSize, (jint)lpStruct->cbSize);
- (*env)->SetIntField(env, lpObject, SHELLEXECUTEINFOFc.fMask, (jint)lpStruct->fMask);
- (*env)->SetIntField(env, lpObject, SHELLEXECUTEINFOFc.hwnd, (jint)lpStruct->hwnd);
- (*env)->SetIntField(env, lpObject, SHELLEXECUTEINFOFc.lpVerb, (jint)lpStruct->lpVerb);
- (*env)->SetIntField(env, lpObject, SHELLEXECUTEINFOFc.lpFile, (jint)lpStruct->lpFile);
- (*env)->SetIntField(env, lpObject, SHELLEXECUTEINFOFc.lpParameters, (jint)lpStruct->lpParameters);
- (*env)->SetIntField(env, lpObject, SHELLEXECUTEINFOFc.lpDirectory, (jint)lpStruct->lpDirectory);
- (*env)->SetIntField(env, lpObject, SHELLEXECUTEINFOFc.nShow, (jint)lpStruct->nShow);
- (*env)->SetIntField(env, lpObject, SHELLEXECUTEINFOFc.hInstApp, (jint)lpStruct->hInstApp);
- (*env)->SetIntField(env, lpObject, SHELLEXECUTEINFOFc.lpIDList, (jint)lpStruct->lpIDList);
- (*env)->SetIntField(env, lpObject, SHELLEXECUTEINFOFc.lpClass, (jint)lpStruct->lpClass);
- (*env)->SetIntField(env, lpObject, SHELLEXECUTEINFOFc.hkeyClass, (jint)lpStruct->hkeyClass);
- (*env)->SetIntField(env, lpObject, SHELLEXECUTEINFOFc.dwHotKey, (jint)lpStruct->dwHotKey);
- (*env)->SetIntField(env, lpObject, SHELLEXECUTEINFOFc.hIcon, (jint)lpStruct->hIcon);
- (*env)->SetIntField(env, lpObject, SHELLEXECUTEINFOFc.hProcess, (jint)lpStruct->hProcess);
-}
-#endif /* NO_SHELLEXECUTEINFO */
-
-#ifndef NO_SHMENUBARINFO
-typedef struct SHMENUBARINFO_FID_CACHE {
- int cached;
- jclass clazz;
- jfieldID cbSize, hwndParent, dwFlags, nToolBarId, hInstRes, nBmpId, cBmpImages, hwndMB;
-} SHMENUBARINFO_FID_CACHE;
-
-SHMENUBARINFO_FID_CACHE SHMENUBARINFOFc;
-
-void cacheSHMENUBARINFOFids(JNIEnv *env, jobject lpObject)
-{
- if (SHMENUBARINFOFc.cached) return;
- SHMENUBARINFOFc.clazz = (*env)->GetObjectClass(env, lpObject);
- SHMENUBARINFOFc.cbSize = (*env)->GetFieldID(env, SHMENUBARINFOFc.clazz, "cbSize", "I");
- SHMENUBARINFOFc.hwndParent = (*env)->GetFieldID(env, SHMENUBARINFOFc.clazz, "hwndParent", "I");
- SHMENUBARINFOFc.dwFlags = (*env)->GetFieldID(env, SHMENUBARINFOFc.clazz, "dwFlags", "I");
- SHMENUBARINFOFc.nToolBarId = (*env)->GetFieldID(env, SHMENUBARINFOFc.clazz, "nToolBarId", "I");
- SHMENUBARINFOFc.hInstRes = (*env)->GetFieldID(env, SHMENUBARINFOFc.clazz, "hInstRes", "I");
- SHMENUBARINFOFc.nBmpId = (*env)->GetFieldID(env, SHMENUBARINFOFc.clazz, "nBmpId", "I");
- SHMENUBARINFOFc.cBmpImages = (*env)->GetFieldID(env, SHMENUBARINFOFc.clazz, "cBmpImages", "I");
- SHMENUBARINFOFc.hwndMB = (*env)->GetFieldID(env, SHMENUBARINFOFc.clazz, "hwndMB", "I");
- SHMENUBARINFOFc.cached = 1;
-}
-
-SHMENUBARINFO *getSHMENUBARINFOFields(JNIEnv *env, jobject lpObject, SHMENUBARINFO *lpStruct)
-{
- if (!SHMENUBARINFOFc.cached) cacheSHMENUBARINFOFids(env, lpObject);
- lpStruct->cbSize = (DWORD)(*env)->GetIntField(env, lpObject, SHMENUBARINFOFc.cbSize);
- lpStruct->hwndParent = (HWND)(*env)->GetIntField(env, lpObject, SHMENUBARINFOFc.hwndParent);
- lpStruct->dwFlags = (DWORD)(*env)->GetIntField(env, lpObject, SHMENUBARINFOFc.dwFlags);
- lpStruct->nToolBarId = (UINT)(*env)->GetIntField(env, lpObject, SHMENUBARINFOFc.nToolBarId);
- lpStruct->hInstRes = (HINSTANCE)(*env)->GetIntField(env, lpObject, SHMENUBARINFOFc.hInstRes);
- lpStruct->nBmpId = (*env)->GetIntField(env, lpObject, SHMENUBARINFOFc.nBmpId);
- lpStruct->cBmpImages = (*env)->GetIntField(env, lpObject, SHMENUBARINFOFc.cBmpImages);
- lpStruct->hwndMB = (HWND)(*env)->GetIntField(env, lpObject, SHMENUBARINFOFc.hwndMB);
- return lpStruct;
-}
-
-void setSHMENUBARINFOFields(JNIEnv *env, jobject lpObject, SHMENUBARINFO *lpStruct)
-{
- if (!SHMENUBARINFOFc.cached) cacheSHMENUBARINFOFids(env, lpObject);
- (*env)->SetIntField(env, lpObject, SHMENUBARINFOFc.cbSize, (jint)lpStruct->cbSize);
- (*env)->SetIntField(env, lpObject, SHMENUBARINFOFc.hwndParent, (jint)lpStruct->hwndParent);
- (*env)->SetIntField(env, lpObject, SHMENUBARINFOFc.dwFlags, (jint)lpStruct->dwFlags);
- (*env)->SetIntField(env, lpObject, SHMENUBARINFOFc.nToolBarId, (jint)lpStruct->nToolBarId);
- (*env)->SetIntField(env, lpObject, SHMENUBARINFOFc.hInstRes, (jint)lpStruct->hInstRes);
- (*env)->SetIntField(env, lpObject, SHMENUBARINFOFc.nBmpId, (jint)lpStruct->nBmpId);
- (*env)->SetIntField(env, lpObject, SHMENUBARINFOFc.cBmpImages, (jint)lpStruct->cBmpImages);
- (*env)->SetIntField(env, lpObject, SHMENUBARINFOFc.hwndMB, (jint)lpStruct->hwndMB);
-}
-#endif /* NO_SHMENUBARINFO */
-
-#ifndef NO_SHRGINFO
-typedef struct SHRGINFO_FID_CACHE {
- int cached;
- jclass clazz;
- jfieldID dwFlags, ptDown_y, ptDown_x, hwndClient, cbSize;
-} SHRGINFO_FID_CACHE;
-
-SHRGINFO_FID_CACHE SHRGINFOFc;
-
-void cacheSHRGINFOFids(JNIEnv *env, jobject lpObject)
-{
- if (SHRGINFOFc.cached) return;
- SHRGINFOFc.clazz = (*env)->GetObjectClass(env, lpObject);
- SHRGINFOFc.dwFlags = (*env)->GetFieldID(env, SHRGINFOFc.clazz, "dwFlags", "I");
- SHRGINFOFc.ptDown_y = (*env)->GetFieldID(env, SHRGINFOFc.clazz, "ptDown_y", "I");
- SHRGINFOFc.ptDown_x = (*env)->GetFieldID(env, SHRGINFOFc.clazz, "ptDown_x", "I");
- SHRGINFOFc.hwndClient = (*env)->GetFieldID(env, SHRGINFOFc.clazz, "hwndClient", "I");
- SHRGINFOFc.cbSize = (*env)->GetFieldID(env, SHRGINFOFc.clazz, "cbSize", "I");
- SHRGINFOFc.cached = 1;
-}
-
-SHRGINFO *getSHRGINFOFields(JNIEnv *env, jobject lpObject, SHRGINFO *lpStruct)
-{
- if (!SHRGINFOFc.cached) cacheSHRGINFOFids(env, lpObject);
- lpStruct->dwFlags = (*env)->GetIntField(env, lpObject, SHRGINFOFc.dwFlags);
- lpStruct->ptDown.y = (*env)->GetIntField(env, lpObject, SHRGINFOFc.ptDown_y);
- lpStruct->ptDown.x = (*env)->GetIntField(env, lpObject, SHRGINFOFc.ptDown_x);
- lpStruct->hwndClient = (HWND)(*env)->GetIntField(env, lpObject, SHRGINFOFc.hwndClient);
- lpStruct->cbSize = (*env)->GetIntField(env, lpObject, SHRGINFOFc.cbSize);
- return lpStruct;
-}
-
-void setSHRGINFOFields(JNIEnv *env, jobject lpObject, SHRGINFO *lpStruct)
-{
- if (!SHRGINFOFc.cached) cacheSHRGINFOFids(env, lpObject);
- (*env)->SetIntField(env, lpObject, SHRGINFOFc.dwFlags, (jint)lpStruct->dwFlags);
- (*env)->SetIntField(env, lpObject, SHRGINFOFc.ptDown_y, (jint)lpStruct->ptDown.y);
- (*env)->SetIntField(env, lpObject, SHRGINFOFc.ptDown_x, (jint)lpStruct->ptDown.x);
- (*env)->SetIntField(env, lpObject, SHRGINFOFc.hwndClient, (jint)lpStruct->hwndClient);
- (*env)->SetIntField(env, lpObject, SHRGINFOFc.cbSize, (jint)lpStruct->cbSize);
-}
-#endif /* NO_SHRGINFO */
-
-#ifndef NO_SIPINFO
-typedef struct SIPINFO_FID_CACHE {
- int cached;
- jclass clazz;
- jfieldID cbSize, fdwFlags, rcVisibleDesktop_left, rcVisibleDesktop_top, rcVisibleDesktop_right, rcVisibleDesktop_bottom, rcSipRect_left, rcSipRect_top, rcSipRect_right, rcSipRect_bottom, dwImDataSize, pvImData;
-} SIPINFO_FID_CACHE;
-
-SIPINFO_FID_CACHE SIPINFOFc;
-
-void cacheSIPINFOFids(JNIEnv *env, jobject lpObject)
-{
- if (SIPINFOFc.cached) return;
- SIPINFOFc.clazz = (*env)->GetObjectClass(env, lpObject);
- SIPINFOFc.cbSize = (*env)->GetFieldID(env, SIPINFOFc.clazz, "cbSize", "I");
- SIPINFOFc.fdwFlags = (*env)->GetFieldID(env, SIPINFOFc.clazz, "fdwFlags", "I");
- SIPINFOFc.rcVisibleDesktop_left = (*env)->GetFieldID(env, SIPINFOFc.clazz, "rcVisibleDesktop_left", "I");
- SIPINFOFc.rcVisibleDesktop_top = (*env)->GetFieldID(env, SIPINFOFc.clazz, "rcVisibleDesktop_top", "I");
- SIPINFOFc.rcVisibleDesktop_right = (*env)->GetFieldID(env, SIPINFOFc.clazz, "rcVisibleDesktop_right", "I");
- SIPINFOFc.rcVisibleDesktop_bottom = (*env)->GetFieldID(env, SIPINFOFc.clazz, "rcVisibleDesktop_bottom", "I");
- SIPINFOFc.rcSipRect_left = (*env)->GetFieldID(env, SIPINFOFc.clazz, "rcSipRect_left", "I");
- SIPINFOFc.rcSipRect_top = (*env)->GetFieldID(env, SIPINFOFc.clazz, "rcSipRect_top", "I");
- SIPINFOFc.rcSipRect_right = (*env)->GetFieldID(env, SIPINFOFc.clazz, "rcSipRect_right", "I");
- SIPINFOFc.rcSipRect_bottom = (*env)->GetFieldID(env, SIPINFOFc.clazz, "rcSipRect_bottom", "I");
- SIPINFOFc.dwImDataSize = (*env)->GetFieldID(env, SIPINFOFc.clazz, "dwImDataSize", "I");
- SIPINFOFc.pvImData = (*env)->GetFieldID(env, SIPINFOFc.clazz, "pvImData", "I");
- SIPINFOFc.cached = 1;
-}
-
-SIPINFO *getSIPINFOFields(JNIEnv *env, jobject lpObject, SIPINFO *lpStruct)
-{
- if (!SIPINFOFc.cached) cacheSIPINFOFids(env, lpObject);
- lpStruct->cbSize = (*env)->GetIntField(env, lpObject, SIPINFOFc.cbSize);
- lpStruct->fdwFlags = (*env)->GetIntField(env, lpObject, SIPINFOFc.fdwFlags);
- lpStruct->rcVisibleDesktop.left = (*env)->GetIntField(env, lpObject, SIPINFOFc.rcVisibleDesktop_left);
- lpStruct->rcVisibleDesktop.top = (*env)->GetIntField(env, lpObject, SIPINFOFc.rcVisibleDesktop_top);
- lpStruct->rcVisibleDesktop.right = (*env)->GetIntField(env, lpObject, SIPINFOFc.rcVisibleDesktop_right);
- lpStruct->rcVisibleDesktop.bottom = (*env)->GetIntField(env, lpObject, SIPINFOFc.rcVisibleDesktop_bottom);
- lpStruct->rcSipRect.left = (*env)->GetIntField(env, lpObject, SIPINFOFc.rcSipRect_left);
- lpStruct->rcSipRect.top = (*env)->GetIntField(env, lpObject, SIPINFOFc.rcSipRect_top);
- lpStruct->rcSipRect.right = (*env)->GetIntField(env, lpObject, SIPINFOFc.rcSipRect_right);
- lpStruct->rcSipRect.bottom = (*env)->GetIntField(env, lpObject, SIPINFOFc.rcSipRect_bottom);
- lpStruct->dwImDataSize = (*env)->GetIntField(env, lpObject, SIPINFOFc.dwImDataSize);
- lpStruct->pvImData = (void*)(*env)->GetIntField(env, lpObject, SIPINFOFc.pvImData);
- return lpStruct;
-}
-
-void setSIPINFOFields(JNIEnv *env, jobject lpObject, SIPINFO *lpStruct)
-{
- if (!SIPINFOFc.cached) cacheSIPINFOFids(env, lpObject);
- (*env)->SetIntField(env, lpObject, SIPINFOFc.cbSize, (jint)lpStruct->cbSize);
- (*env)->SetIntField(env, lpObject, SIPINFOFc.fdwFlags, (jint)lpStruct->fdwFlags);
- (*env)->SetIntField(env, lpObject, SIPINFOFc.rcVisibleDesktop_left, (jint)lpStruct->rcVisibleDesktop.left);
- (*env)->SetIntField(env, lpObject, SIPINFOFc.rcVisibleDesktop_top, (jint)lpStruct->rcVisibleDesktop.top);
- (*env)->SetIntField(env, lpObject, SIPINFOFc.rcVisibleDesktop_right, (jint)lpStruct->rcVisibleDesktop.right);
- (*env)->SetIntField(env, lpObject, SIPINFOFc.rcVisibleDesktop_bottom, (jint)lpStruct->rcVisibleDesktop.bottom);
- (*env)->SetIntField(env, lpObject, SIPINFOFc.rcSipRect_left, (jint)lpStruct->rcSipRect.left);
- (*env)->SetIntField(env, lpObject, SIPINFOFc.rcSipRect_top, (jint)lpStruct->rcSipRect.top);
- (*env)->SetIntField(env, lpObject, SIPINFOFc.rcSipRect_right, (jint)lpStruct->rcSipRect.right);
- (*env)->SetIntField(env, lpObject, SIPINFOFc.rcSipRect_bottom, (jint)lpStruct->rcSipRect.bottom);
- (*env)->SetIntField(env, lpObject, SIPINFOFc.dwImDataSize, (jint)lpStruct->dwImDataSize);
- (*env)->SetIntField(env, lpObject, SIPINFOFc.pvImData, (jint)lpStruct->pvImData);
-}
-#endif /* NO_SIPINFO */
-
-#ifndef NO_SIZE
-typedef struct SIZE_FID_CACHE {
- int cached;
- jclass clazz;
- jfieldID cx, cy;
-} SIZE_FID_CACHE;
-
-SIZE_FID_CACHE SIZEFc;
-
-void cacheSIZEFids(JNIEnv *env, jobject lpObject)
-{
- if (SIZEFc.cached) return;
- SIZEFc.clazz = (*env)->GetObjectClass(env, lpObject);
- SIZEFc.cx = (*env)->GetFieldID(env, SIZEFc.clazz, "cx", "I");
- SIZEFc.cy = (*env)->GetFieldID(env, SIZEFc.clazz, "cy", "I");
- SIZEFc.cached = 1;
-}
-
-SIZE *getSIZEFields(JNIEnv *env, jobject lpObject, SIZE *lpStruct)
-{
- if (!SIZEFc.cached) cacheSIZEFids(env, lpObject);
- lpStruct->cx = (*env)->GetIntField(env, lpObject, SIZEFc.cx);
- lpStruct->cy = (*env)->GetIntField(env, lpObject, SIZEFc.cy);
- return lpStruct;
-}
-
-void setSIZEFields(JNIEnv *env, jobject lpObject, SIZE *lpStruct)
-{
- if (!SIZEFc.cached) cacheSIZEFids(env, lpObject);
- (*env)->SetIntField(env, lpObject, SIZEFc.cx, (jint)lpStruct->cx);
- (*env)->SetIntField(env, lpObject, SIZEFc.cy, (jint)lpStruct->cy);
-}
-#endif /* NO_SIZE */
-
-#ifndef NO_TBBUTTON
-typedef struct TBBUTTON_FID_CACHE {
- int cached;
- jclass clazz;
- jfieldID iBitmap, idCommand, fsState, fsStyle, dwData, iString;
-} TBBUTTON_FID_CACHE;
-
-TBBUTTON_FID_CACHE TBBUTTONFc;
-
-void cacheTBBUTTONFids(JNIEnv *env, jobject lpObject)
-{
- if (TBBUTTONFc.cached) return;
- TBBUTTONFc.clazz = (*env)->GetObjectClass(env, lpObject);
- TBBUTTONFc.iBitmap = (*env)->GetFieldID(env, TBBUTTONFc.clazz, "iBitmap", "I");
- TBBUTTONFc.idCommand = (*env)->GetFieldID(env, TBBUTTONFc.clazz, "idCommand", "I");
- TBBUTTONFc.fsState = (*env)->GetFieldID(env, TBBUTTONFc.clazz, "fsState", "B");
- TBBUTTONFc.fsStyle = (*env)->GetFieldID(env, TBBUTTONFc.clazz, "fsStyle", "B");
- TBBUTTONFc.dwData = (*env)->GetFieldID(env, TBBUTTONFc.clazz, "dwData", "I");
- TBBUTTONFc.iString = (*env)->GetFieldID(env, TBBUTTONFc.clazz, "iString", "I");
- TBBUTTONFc.cached = 1;
-}
-
-TBBUTTON *getTBBUTTONFields(JNIEnv *env, jobject lpObject, TBBUTTON *lpStruct)
-{
- if (!TBBUTTONFc.cached) cacheTBBUTTONFids(env, lpObject);
- lpStruct->iBitmap = (*env)->GetIntField(env, lpObject, TBBUTTONFc.iBitmap);
- lpStruct->idCommand = (*env)->GetIntField(env, lpObject, TBBUTTONFc.idCommand);
- lpStruct->fsState = (*env)->GetByteField(env, lpObject, TBBUTTONFc.fsState);
- lpStruct->fsStyle = (*env)->GetByteField(env, lpObject, TBBUTTONFc.fsStyle);
- lpStruct->dwData = (*env)->GetIntField(env, lpObject, TBBUTTONFc.dwData);
- lpStruct->iString = (*env)->GetIntField(env, lpObject, TBBUTTONFc.iString);
- return lpStruct;
-}
-
-void setTBBUTTONFields(JNIEnv *env, jobject lpObject, TBBUTTON *lpStruct)
-{
- if (!TBBUTTONFc.cached) cacheTBBUTTONFids(env, lpObject);
- (*env)->SetIntField(env, lpObject, TBBUTTONFc.iBitmap, (jint)lpStruct->iBitmap);
- (*env)->SetIntField(env, lpObject, TBBUTTONFc.idCommand, (jint)lpStruct->idCommand);
- (*env)->SetByteField(env, lpObject, TBBUTTONFc.fsState, (jbyte)lpStruct->fsState);
- (*env)->SetByteField(env, lpObject, TBBUTTONFc.fsStyle, (jbyte)lpStruct->fsStyle);
- (*env)->SetIntField(env, lpObject, TBBUTTONFc.dwData, (jint)lpStruct->dwData);
- (*env)->SetIntField(env, lpObject, TBBUTTONFc.iString, (jint)lpStruct->iString);
-}
-#endif /* NO_TBBUTTON */
-
-#ifndef NO_TBBUTTONINFO
-typedef struct TBBUTTONINFO_FID_CACHE {
- int cached;
- jclass clazz;
- jfieldID cbSize, dwMask, idCommand, iImage, fsState, fsStyle, cx, lParam, pszText, cchText;
-} TBBUTTONINFO_FID_CACHE;
-
-TBBUTTONINFO_FID_CACHE TBBUTTONINFOFc;
-
-void cacheTBBUTTONINFOFids(JNIEnv *env, jobject lpObject)
-{
- if (TBBUTTONINFOFc.cached) return;
- TBBUTTONINFOFc.clazz = (*env)->GetObjectClass(env, lpObject);
- TBBUTTONINFOFc.cbSize = (*env)->GetFieldID(env, TBBUTTONINFOFc.clazz, "cbSize", "I");
- TBBUTTONINFOFc.dwMask = (*env)->GetFieldID(env, TBBUTTONINFOFc.clazz, "dwMask", "I");
- TBBUTTONINFOFc.idCommand = (*env)->GetFieldID(env, TBBUTTONINFOFc.clazz, "idCommand", "I");
- TBBUTTONINFOFc.iImage = (*env)->GetFieldID(env, TBBUTTONINFOFc.clazz, "iImage", "I");
- TBBUTTONINFOFc.fsState = (*env)->GetFieldID(env, TBBUTTONINFOFc.clazz, "fsState", "B");
- TBBUTTONINFOFc.fsStyle = (*env)->GetFieldID(env, TBBUTTONINFOFc.clazz, "fsStyle", "B");
- TBBUTTONINFOFc.cx = (*env)->GetFieldID(env, TBBUTTONINFOFc.clazz, "cx", "S");
- TBBUTTONINFOFc.lParam = (*env)->GetFieldID(env, TBBUTTONINFOFc.clazz, "lParam", "I");
- TBBUTTONINFOFc.pszText = (*env)->GetFieldID(env, TBBUTTONINFOFc.clazz, "pszText", "I");
- TBBUTTONINFOFc.cchText = (*env)->GetFieldID(env, TBBUTTONINFOFc.clazz, "cchText", "I");
- TBBUTTONINFOFc.cached = 1;
-}
-
-TBBUTTONINFO *getTBBUTTONINFOFields(JNIEnv *env, jobject lpObject, TBBUTTONINFO *lpStruct)
-{
- if (!TBBUTTONINFOFc.cached) cacheTBBUTTONINFOFids(env, lpObject);
- lpStruct->cbSize = (*env)->GetIntField(env, lpObject, TBBUTTONINFOFc.cbSize);
- lpStruct->dwMask = (*env)->GetIntField(env, lpObject, TBBUTTONINFOFc.dwMask);
- lpStruct->idCommand = (*env)->GetIntField(env, lpObject, TBBUTTONINFOFc.idCommand);
- lpStruct->iImage = (*env)->GetIntField(env, lpObject, TBBUTTONINFOFc.iImage);
- lpStruct->fsState = (*env)->GetByteField(env, lpObject, TBBUTTONINFOFc.fsState);
- lpStruct->fsStyle = (*env)->GetByteField(env, lpObject, TBBUTTONINFOFc.fsStyle);
- lpStruct->cx = (*env)->GetShortField(env, lpObject, TBBUTTONINFOFc.cx);
- lpStruct->lParam = (*env)->GetIntField(env, lpObject, TBBUTTONINFOFc.lParam);
- lpStruct->pszText = (LPTSTR)(*env)->GetIntField(env, lpObject, TBBUTTONINFOFc.pszText);
- lpStruct->cchText = (*env)->GetIntField(env, lpObject, TBBUTTONINFOFc.cchText);
- return lpStruct;
-}
-
-void setTBBUTTONINFOFields(JNIEnv *env, jobject lpObject, TBBUTTONINFO *lpStruct)
-{
- if (!TBBUTTONINFOFc.cached) cacheTBBUTTONINFOFids(env, lpObject);
- (*env)->SetIntField(env, lpObject, TBBUTTONINFOFc.cbSize, (jint)lpStruct->cbSize);
- (*env)->SetIntField(env, lpObject, TBBUTTONINFOFc.dwMask, (jint)lpStruct->dwMask);
- (*env)->SetIntField(env, lpObject, TBBUTTONINFOFc.idCommand, (jint)lpStruct->idCommand);
- (*env)->SetIntField(env, lpObject, TBBUTTONINFOFc.iImage, (jint)lpStruct->iImage);
- (*env)->SetByteField(env, lpObject, TBBUTTONINFOFc.fsState, (jbyte)lpStruct->fsState);
- (*env)->SetByteField(env, lpObject, TBBUTTONINFOFc.fsStyle, (jbyte)lpStruct->fsStyle);
- (*env)->SetShortField(env, lpObject, TBBUTTONINFOFc.cx, (jshort)lpStruct->cx);
- (*env)->SetIntField(env, lpObject, TBBUTTONINFOFc.lParam, (jint)lpStruct->lParam);
- (*env)->SetIntField(env, lpObject, TBBUTTONINFOFc.pszText, (jint)lpStruct->pszText);
- (*env)->SetIntField(env, lpObject, TBBUTTONINFOFc.cchText, (jint)lpStruct->cchText);
-}
-#endif /* NO_TBBUTTONINFO */
-
-#ifndef NO_TCITEM
-typedef struct TCITEM_FID_CACHE {
- int cached;
- jclass clazz;
- jfieldID mask, dwState, dwStateMask, pszText, cchTextMax, iImage, lParam;
-} TCITEM_FID_CACHE;
-
-TCITEM_FID_CACHE TCITEMFc;
-
-void cacheTCITEMFids(JNIEnv *env, jobject lpObject)
-{
- if (TCITEMFc.cached) return;
- TCITEMFc.clazz = (*env)->GetObjectClass(env, lpObject);
- TCITEMFc.mask = (*env)->GetFieldID(env, TCITEMFc.clazz, "mask", "I");
- TCITEMFc.dwState = (*env)->GetFieldID(env, TCITEMFc.clazz, "dwState", "I");
- TCITEMFc.dwStateMask = (*env)->GetFieldID(env, TCITEMFc.clazz, "dwStateMask", "I");
- TCITEMFc.pszText = (*env)->GetFieldID(env, TCITEMFc.clazz, "pszText", "I");
- TCITEMFc.cchTextMax = (*env)->GetFieldID(env, TCITEMFc.clazz, "cchTextMax", "I");
- TCITEMFc.iImage = (*env)->GetFieldID(env, TCITEMFc.clazz, "iImage", "I");
- TCITEMFc.lParam = (*env)->GetFieldID(env, TCITEMFc.clazz, "lParam", "I");
- TCITEMFc.cached = 1;
-}
-
-TCITEM *getTCITEMFields(JNIEnv *env, jobject lpObject, TCITEM *lpStruct)
-{
- if (!TCITEMFc.cached) cacheTCITEMFids(env, lpObject);
- lpStruct->mask = (*env)->GetIntField(env, lpObject, TCITEMFc.mask);
- lpStruct->dwState = (*env)->GetIntField(env, lpObject, TCITEMFc.dwState);
- lpStruct->dwStateMask = (*env)->GetIntField(env, lpObject, TCITEMFc.dwStateMask);
- lpStruct->pszText = (LPTSTR)(*env)->GetIntField(env, lpObject, TCITEMFc.pszText);
- lpStruct->cchTextMax = (*env)->GetIntField(env, lpObject, TCITEMFc.cchTextMax);
- lpStruct->iImage = (*env)->GetIntField(env, lpObject, TCITEMFc.iImage);
- lpStruct->lParam = (*env)->GetIntField(env, lpObject, TCITEMFc.lParam);
- return lpStruct;
-}
-
-void setTCITEMFields(JNIEnv *env, jobject lpObject, TCITEM *lpStruct)
-{
- if (!TCITEMFc.cached) cacheTCITEMFids(env, lpObject);
- (*env)->SetIntField(env, lpObject, TCITEMFc.mask, (jint)lpStruct->mask);
- (*env)->SetIntField(env, lpObject, TCITEMFc.dwState, (jint)lpStruct->dwState);
- (*env)->SetIntField(env, lpObject, TCITEMFc.dwStateMask, (jint)lpStruct->dwStateMask);
- (*env)->SetIntField(env, lpObject, TCITEMFc.pszText, (jint)lpStruct->pszText);
- (*env)->SetIntField(env, lpObject, TCITEMFc.cchTextMax, (jint)lpStruct->cchTextMax);
- (*env)->SetIntField(env, lpObject, TCITEMFc.iImage, (jint)lpStruct->iImage);
- (*env)->SetIntField(env, lpObject, TCITEMFc.lParam, (jint)lpStruct->lParam);
-}
-#endif /* NO_TCITEM */
-
-#ifndef NO_TEXTMETRIC
-typedef struct TEXTMETRIC_FID_CACHE {
- int cached;
- jclass clazz;
- jfieldID tmHeight, tmAscent, tmDescent, tmInternalLeading, tmExternalLeading, tmAveCharWidth, tmMaxCharWidth, tmWeight, tmOverhang, tmDigitizedAspectX, tmDigitizedAspectY, tmItalic, tmUnderlined, tmStruckOut, tmPitchAndFamily, tmCharSet;
-} TEXTMETRIC_FID_CACHE;
-
-TEXTMETRIC_FID_CACHE TEXTMETRICFc;
-
-void cacheTEXTMETRICFids(JNIEnv *env, jobject lpObject)
-{
- if (TEXTMETRICFc.cached) return;
- TEXTMETRICFc.clazz = (*env)->GetObjectClass(env, lpObject);
- TEXTMETRICFc.tmHeight = (*env)->GetFieldID(env, TEXTMETRICFc.clazz, "tmHeight", "I");
- TEXTMETRICFc.tmAscent = (*env)->GetFieldID(env, TEXTMETRICFc.clazz, "tmAscent", "I");
- TEXTMETRICFc.tmDescent = (*env)->GetFieldID(env, TEXTMETRICFc.clazz, "tmDescent", "I");
- TEXTMETRICFc.tmInternalLeading = (*env)->GetFieldID(env, TEXTMETRICFc.clazz, "tmInternalLeading", "I");
- TEXTMETRICFc.tmExternalLeading = (*env)->GetFieldID(env, TEXTMETRICFc.clazz, "tmExternalLeading", "I");
- TEXTMETRICFc.tmAveCharWidth = (*env)->GetFieldID(env, TEXTMETRICFc.clazz, "tmAveCharWidth", "I");
- TEXTMETRICFc.tmMaxCharWidth = (*env)->GetFieldID(env, TEXTMETRICFc.clazz, "tmMaxCharWidth", "I");
- TEXTMETRICFc.tmWeight = (*env)->GetFieldID(env, TEXTMETRICFc.clazz, "tmWeight", "I");
- TEXTMETRICFc.tmOverhang = (*env)->GetFieldID(env, TEXTMETRICFc.clazz, "tmOverhang", "I");
- TEXTMETRICFc.tmDigitizedAspectX = (*env)->GetFieldID(env, TEXTMETRICFc.clazz, "tmDigitizedAspectX", "I");
- TEXTMETRICFc.tmDigitizedAspectY = (*env)->GetFieldID(env, TEXTMETRICFc.clazz, "tmDigitizedAspectY", "I");
- TEXTMETRICFc.tmItalic = (*env)->GetFieldID(env, TEXTMETRICFc.clazz, "tmItalic", "B");
- TEXTMETRICFc.tmUnderlined = (*env)->GetFieldID(env, TEXTMETRICFc.clazz, "tmUnderlined", "B");
- TEXTMETRICFc.tmStruckOut = (*env)->GetFieldID(env, TEXTMETRICFc.clazz, "tmStruckOut", "B");
- TEXTMETRICFc.tmPitchAndFamily = (*env)->GetFieldID(env, TEXTMETRICFc.clazz, "tmPitchAndFamily", "B");
- TEXTMETRICFc.tmCharSet = (*env)->GetFieldID(env, TEXTMETRICFc.clazz, "tmCharSet", "B");
- TEXTMETRICFc.cached = 1;
-}
-#ifndef NO_TEXTMETRICA
-TEXTMETRICA* getTEXTMETRICAFields(JNIEnv *env, jobject lpObject, TEXTMETRICA *lpStruct)
-{
- if (!TEXTMETRICFc.cached) cacheTEXTMETRICFids(env, lpObject);
- lpStruct->tmHeight = (*env)->GetIntField(env, lpObject, TEXTMETRICFc.tmHeight);
- lpStruct->tmAscent = (*env)->GetIntField(env, lpObject, TEXTMETRICFc.tmAscent);
- lpStruct->tmDescent = (*env)->GetIntField(env, lpObject, TEXTMETRICFc.tmDescent);
- lpStruct->tmInternalLeading = (*env)->GetIntField(env, lpObject, TEXTMETRICFc.tmInternalLeading);
- lpStruct->tmExternalLeading = (*env)->GetIntField(env, lpObject, TEXTMETRICFc.tmExternalLeading);
- lpStruct->tmAveCharWidth = (*env)->GetIntField(env, lpObject, TEXTMETRICFc.tmAveCharWidth);
- lpStruct->tmMaxCharWidth = (*env)->GetIntField(env, lpObject, TEXTMETRICFc.tmMaxCharWidth);
- lpStruct->tmWeight = (*env)->GetIntField(env, lpObject, TEXTMETRICFc.tmWeight);
- lpStruct->tmOverhang = (*env)->GetIntField(env, lpObject, TEXTMETRICFc.tmOverhang);
- lpStruct->tmDigitizedAspectX = (*env)->GetIntField(env, lpObject, TEXTMETRICFc.tmDigitizedAspectX);
- lpStruct->tmDigitizedAspectY = (*env)->GetIntField(env, lpObject, TEXTMETRICFc.tmDigitizedAspectY);
- lpStruct->tmItalic = (*env)->GetByteField(env, lpObject, TEXTMETRICFc.tmItalic);
- lpStruct->tmUnderlined = (*env)->GetByteField(env, lpObject, TEXTMETRICFc.tmUnderlined);
- lpStruct->tmStruckOut = (*env)->GetByteField(env, lpObject, TEXTMETRICFc.tmStruckOut);
- lpStruct->tmPitchAndFamily = (*env)->GetByteField(env, lpObject, TEXTMETRICFc.tmPitchAndFamily);
- lpStruct->tmCharSet = (*env)->GetByteField(env, lpObject, TEXTMETRICFc.tmCharSet);
- return lpStruct;
-}
-
-void setTEXTMETRICAFields(JNIEnv *env, jobject lpObject, TEXTMETRICA *lpStruct)
-{
- if (!TEXTMETRICFc.cached) cacheTEXTMETRICFids(env, lpObject);
- (*env)->SetIntField(env, lpObject, TEXTMETRICFc.tmHeight, lpStruct->tmHeight);
- (*env)->SetIntField(env, lpObject, TEXTMETRICFc.tmAscent, lpStruct->tmAscent);
- (*env)->SetIntField(env, lpObject, TEXTMETRICFc.tmDescent, lpStruct->tmDescent);
- (*env)->SetIntField(env, lpObject, TEXTMETRICFc.tmInternalLeading, lpStruct->tmInternalLeading);
- (*env)->SetIntField(env, lpObject, TEXTMETRICFc.tmExternalLeading, lpStruct->tmExternalLeading);
- (*env)->SetIntField(env, lpObject, TEXTMETRICFc.tmAveCharWidth, lpStruct->tmAveCharWidth);
- (*env)->SetIntField(env, lpObject, TEXTMETRICFc.tmMaxCharWidth, lpStruct->tmMaxCharWidth);
- (*env)->SetIntField(env, lpObject, TEXTMETRICFc.tmWeight, lpStruct->tmWeight);
- (*env)->SetIntField(env, lpObject, TEXTMETRICFc.tmOverhang, lpStruct->tmOverhang);
- (*env)->SetIntField(env, lpObject, TEXTMETRICFc.tmDigitizedAspectX, lpStruct->tmDigitizedAspectX);
- (*env)->SetIntField(env, lpObject, TEXTMETRICFc.tmDigitizedAspectY, lpStruct->tmDigitizedAspectY);
- (*env)->SetByteField(env, lpObject, TEXTMETRICFc.tmItalic, lpStruct->tmItalic);
- (*env)->SetByteField(env, lpObject, TEXTMETRICFc.tmUnderlined, lpStruct->tmUnderlined);
- (*env)->SetByteField(env, lpObject, TEXTMETRICFc.tmStruckOut, lpStruct->tmStruckOut);
- (*env)->SetByteField(env, lpObject, TEXTMETRICFc.tmPitchAndFamily, lpStruct->tmPitchAndFamily);
- (*env)->SetByteField(env, lpObject, TEXTMETRICFc.tmCharSet, lpStruct->tmCharSet);
-}
-#endif /* NO_TEXTMETRICA */
-
-#ifndef NO_TEXTMETRICW
-TEXTMETRICW *getTEXTMETRICWFields(JNIEnv *env, jobject lpObject, TEXTMETRICW *lpStruct)
-{
- if (!TEXTMETRICFc.cached) cacheTEXTMETRICFids(env, lpObject);
- lpStruct->tmHeight = (*env)->GetIntField(env, lpObject, TEXTMETRICFc.tmHeight);
- lpStruct->tmAscent = (*env)->GetIntField(env, lpObject, TEXTMETRICFc.tmAscent);
- lpStruct->tmDescent = (*env)->GetIntField(env, lpObject, TEXTMETRICFc.tmDescent);
- lpStruct->tmInternalLeading = (*env)->GetIntField(env, lpObject, TEXTMETRICFc.tmInternalLeading);
- lpStruct->tmExternalLeading = (*env)->GetIntField(env, lpObject, TEXTMETRICFc.tmExternalLeading);
- lpStruct->tmAveCharWidth = (*env)->GetIntField(env, lpObject, TEXTMETRICFc.tmAveCharWidth);
- lpStruct->tmMaxCharWidth = (*env)->GetIntField(env, lpObject, TEXTMETRICFc.tmMaxCharWidth);
- lpStruct->tmWeight = (*env)->GetIntField(env, lpObject, TEXTMETRICFc.tmWeight);
- lpStruct->tmOverhang = (*env)->GetIntField(env, lpObject, TEXTMETRICFc.tmOverhang);
- lpStruct->tmDigitizedAspectX = (*env)->GetIntField(env, lpObject, TEXTMETRICFc.tmDigitizedAspectX);
- lpStruct->tmDigitizedAspectY = (*env)->GetIntField(env, lpObject, TEXTMETRICFc.tmDigitizedAspectY);
- lpStruct->tmItalic = (*env)->GetByteField(env, lpObject, TEXTMETRICFc.tmItalic);
- lpStruct->tmUnderlined = (*env)->GetByteField(env, lpObject, TEXTMETRICFc.tmUnderlined);
- lpStruct->tmStruckOut = (*env)->GetByteField(env, lpObject, TEXTMETRICFc.tmStruckOut);
- lpStruct->tmPitchAndFamily = (*env)->GetByteField(env, lpObject, TEXTMETRICFc.tmPitchAndFamily);
- lpStruct->tmCharSet = (*env)->GetByteField(env, lpObject, TEXTMETRICFc.tmCharSet);
- return lpStruct;
-}
-
-void setTEXTMETRICWFields(JNIEnv *env, jobject lpObject, TEXTMETRICW *lpStruct)
-{
- if (!TEXTMETRICFc.cached) cacheTEXTMETRICFids(env, lpObject);
- (*env)->SetIntField(env, lpObject, TEXTMETRICFc.tmHeight, (jint)lpStruct->tmHeight);
- (*env)->SetIntField(env, lpObject, TEXTMETRICFc.tmAscent, (jint)lpStruct->tmAscent);
- (*env)->SetIntField(env, lpObject, TEXTMETRICFc.tmDescent, (jint)lpStruct->tmDescent);
- (*env)->SetIntField(env, lpObject, TEXTMETRICFc.tmInternalLeading, (jint)lpStruct->tmInternalLeading);
- (*env)->SetIntField(env, lpObject, TEXTMETRICFc.tmExternalLeading, (jint)lpStruct->tmExternalLeading);
- (*env)->SetIntField(env, lpObject, TEXTMETRICFc.tmAveCharWidth, (jint)lpStruct->tmAveCharWidth);
- (*env)->SetIntField(env, lpObject, TEXTMETRICFc.tmMaxCharWidth, (jint)lpStruct->tmMaxCharWidth);
- (*env)->SetIntField(env, lpObject, TEXTMETRICFc.tmWeight, (jint)lpStruct->tmWeight);
- (*env)->SetIntField(env, lpObject, TEXTMETRICFc.tmOverhang, (jint)lpStruct->tmOverhang);
- (*env)->SetIntField(env, lpObject, TEXTMETRICFc.tmDigitizedAspectX, (jint)lpStruct->tmDigitizedAspectX);
- (*env)->SetIntField(env, lpObject, TEXTMETRICFc.tmDigitizedAspectY, (jint)lpStruct->tmDigitizedAspectY);
- (*env)->SetByteField(env, lpObject, TEXTMETRICFc.tmItalic, (jbyte)lpStruct->tmItalic);
- (*env)->SetByteField(env, lpObject, TEXTMETRICFc.tmUnderlined, (jbyte)lpStruct->tmUnderlined);
- (*env)->SetByteField(env, lpObject, TEXTMETRICFc.tmStruckOut, (jbyte)lpStruct->tmStruckOut);
- (*env)->SetByteField(env, lpObject, TEXTMETRICFc.tmPitchAndFamily, (jbyte)lpStruct->tmPitchAndFamily);
- (*env)->SetByteField(env, lpObject, TEXTMETRICFc.tmCharSet, (jbyte)lpStruct->tmCharSet);
-}
-#endif /* NO_TEXTMETRICW */
-#endif /* NO_TEXTMETRIC */
-
-#ifndef NO_TOOLINFO
-typedef struct TOOLINFO_FID_CACHE {
- int cached;
- jclass clazz;
- jfieldID cbSize, uFlags, hwnd, uId, left, top, right, bottom, hinst, lpszText, lParam;
-} TOOLINFO_FID_CACHE;
-
-TOOLINFO_FID_CACHE TOOLINFOFc;
-
-void cacheTOOLINFOFids(JNIEnv *env, jobject lpObject)
-{
- if (TOOLINFOFc.cached) return;
- TOOLINFOFc.clazz = (*env)->GetObjectClass(env, lpObject);
- TOOLINFOFc.cbSize = (*env)->GetFieldID(env, TOOLINFOFc.clazz, "cbSize", "I");
- TOOLINFOFc.uFlags = (*env)->GetFieldID(env, TOOLINFOFc.clazz, "uFlags", "I");
- TOOLINFOFc.hwnd = (*env)->GetFieldID(env, TOOLINFOFc.clazz, "hwnd", "I");
- TOOLINFOFc.uId = (*env)->GetFieldID(env, TOOLINFOFc.clazz, "uId", "I");
- TOOLINFOFc.left = (*env)->GetFieldID(env, TOOLINFOFc.clazz, "left", "I");
- TOOLINFOFc.top = (*env)->GetFieldID(env, TOOLINFOFc.clazz, "top", "I");
- TOOLINFOFc.right = (*env)->GetFieldID(env, TOOLINFOFc.clazz, "right", "I");
- TOOLINFOFc.bottom = (*env)->GetFieldID(env, TOOLINFOFc.clazz, "bottom", "I");
- TOOLINFOFc.hinst = (*env)->GetFieldID(env, TOOLINFOFc.clazz, "hinst", "I");
- TOOLINFOFc.lpszText = (*env)->GetFieldID(env, TOOLINFOFc.clazz, "lpszText", "I");
- TOOLINFOFc.lParam = (*env)->GetFieldID(env, TOOLINFOFc.clazz, "lParam", "I");
- TOOLINFOFc.cached = 1;
-}
-
-TOOLINFO *getTOOLINFOFields(JNIEnv *env, jobject lpObject, TOOLINFO *lpStruct)
-{
- if (!TOOLINFOFc.cached) cacheTOOLINFOFids(env, lpObject);
- lpStruct->cbSize = (*env)->GetIntField(env, lpObject, TOOLINFOFc.cbSize);
- lpStruct->uFlags = (*env)->GetIntField(env, lpObject, TOOLINFOFc.uFlags);
- lpStruct->hwnd = (HWND)(*env)->GetIntField(env, lpObject, TOOLINFOFc.hwnd);
- lpStruct->uId = (*env)->GetIntField(env, lpObject, TOOLINFOFc.uId);
- lpStruct->rect.left = (*env)->GetIntField(env, lpObject, TOOLINFOFc.left);
- lpStruct->rect.top = (*env)->GetIntField(env, lpObject, TOOLINFOFc.top);
- lpStruct->rect.right = (*env)->GetIntField(env, lpObject, TOOLINFOFc.right);
- lpStruct->rect.bottom = (*env)->GetIntField(env, lpObject, TOOLINFOFc.bottom);
- lpStruct->hinst = (HINSTANCE)(*env)->GetIntField(env, lpObject, TOOLINFOFc.hinst);
- lpStruct->lpszText = (LPTSTR)(*env)->GetIntField(env, lpObject, TOOLINFOFc.lpszText);
- lpStruct->lParam = (*env)->GetIntField(env, lpObject, TOOLINFOFc.lParam);
- return lpStruct;
-}
-
-void setTOOLINFOFields(JNIEnv *env, jobject lpObject, TOOLINFO *lpStruct)
-{
- if (!TOOLINFOFc.cached) cacheTOOLINFOFids(env, lpObject);
- (*env)->SetIntField(env, lpObject, TOOLINFOFc.cbSize, (jint)lpStruct->cbSize);
- (*env)->SetIntField(env, lpObject, TOOLINFOFc.uFlags, (jint)lpStruct->uFlags);
- (*env)->SetIntField(env, lpObject, TOOLINFOFc.hwnd, (jint)lpStruct->hwnd);
- (*env)->SetIntField(env, lpObject, TOOLINFOFc.uId, (jint)lpStruct->uId);
- (*env)->SetIntField(env, lpObject, TOOLINFOFc.left, (jint)lpStruct->rect.left);
- (*env)->SetIntField(env, lpObject, TOOLINFOFc.top, (jint)lpStruct->rect.top);
- (*env)->SetIntField(env, lpObject, TOOLINFOFc.right, (jint)lpStruct->rect.right);
- (*env)->SetIntField(env, lpObject, TOOLINFOFc.bottom, (jint)lpStruct->rect.bottom);
- (*env)->SetIntField(env, lpObject, TOOLINFOFc.hinst, (jint)lpStruct->hinst);
- (*env)->SetIntField(env, lpObject, TOOLINFOFc.lpszText, (jint)lpStruct->lpszText);
- (*env)->SetIntField(env, lpObject, TOOLINFOFc.lParam, (jint)lpStruct->lParam);
-}
-#endif /* NO_TOOLINFO */
-
-#ifndef NO_TRACKMOUSEEVENT
-typedef struct TRACKMOUSEEVENT_FID_CACHE {
- int cached;
- jclass clazz;
- jfieldID cbSize, dwFlags, hwndTrack, dwHoverTime;
-} TRACKMOUSEEVENT_FID_CACHE;
-
-TRACKMOUSEEVENT_FID_CACHE TRACKMOUSEEVENTFc;
-
-void cacheTRACKMOUSEEVENTFids(JNIEnv *env, jobject lpObject)
-{
- if (TRACKMOUSEEVENTFc.cached) return;
- TRACKMOUSEEVENTFc.clazz = (*env)->GetObjectClass(env, lpObject);
- TRACKMOUSEEVENTFc.cbSize = (*env)->GetFieldID(env, TRACKMOUSEEVENTFc.clazz, "cbSize", "I");
- TRACKMOUSEEVENTFc.dwFlags = (*env)->GetFieldID(env, TRACKMOUSEEVENTFc.clazz, "dwFlags", "I");
- TRACKMOUSEEVENTFc.hwndTrack = (*env)->GetFieldID(env, TRACKMOUSEEVENTFc.clazz, "hwndTrack", "I");
- TRACKMOUSEEVENTFc.dwHoverTime = (*env)->GetFieldID(env, TRACKMOUSEEVENTFc.clazz, "dwHoverTime", "I");
- TRACKMOUSEEVENTFc.cached = 1;
-}
-
-TRACKMOUSEEVENT *getTRACKMOUSEEVENTFields(JNIEnv *env, jobject lpObject, TRACKMOUSEEVENT *lpStruct)
-{
- if (!TRACKMOUSEEVENTFc.cached) cacheTRACKMOUSEEVENTFids(env, lpObject);
- lpStruct->cbSize = (*env)->GetIntField(env, lpObject, TRACKMOUSEEVENTFc.cbSize);
- lpStruct->dwFlags = (*env)->GetIntField(env, lpObject, TRACKMOUSEEVENTFc.dwFlags);
- lpStruct->hwndTrack = (HWND)(*env)->GetIntField(env, lpObject, TRACKMOUSEEVENTFc.hwndTrack);
- lpStruct->dwHoverTime = (*env)->GetIntField(env, lpObject, TRACKMOUSEEVENTFc.dwHoverTime);
- return lpStruct;
-}
-
-void setTRACKMOUSEEVENTFields(JNIEnv *env, jobject lpObject, TRACKMOUSEEVENT *lpStruct)
-{
- if (!TRACKMOUSEEVENTFc.cached) cacheTRACKMOUSEEVENTFids(env, lpObject);
- (*env)->SetIntField(env, lpObject, TRACKMOUSEEVENTFc.cbSize, (jint)lpStruct->cbSize);
- (*env)->SetIntField(env, lpObject, TRACKMOUSEEVENTFc.dwFlags, (jint)lpStruct->dwFlags);
- (*env)->SetIntField(env, lpObject, TRACKMOUSEEVENTFc.hwndTrack, (jint)lpStruct->hwndTrack);
- (*env)->SetIntField(env, lpObject, TRACKMOUSEEVENTFc.dwHoverTime, (jint)lpStruct->dwHoverTime);
-}
-#endif /* NO_TRACKMOUSEEVENT */
-
-#ifndef NO_TRIVERTEX
-typedef struct TRIVERTEX_FID_CACHE {
- int cached;
- jclass clazz;
- jfieldID x, y, Red, Green, Blue, Alpha;
-} TRIVERTEX_FID_CACHE;
-
-TRIVERTEX_FID_CACHE TRIVERTEXFc;
-
-void cacheTRIVERTEXFids(JNIEnv *env, jobject lpObject)
-{
- if (TRIVERTEXFc.cached) return;
- TRIVERTEXFc.clazz = (*env)->GetObjectClass(env, lpObject);
- TRIVERTEXFc.x = (*env)->GetFieldID(env, TRIVERTEXFc.clazz, "x", "I");
- TRIVERTEXFc.y = (*env)->GetFieldID(env, TRIVERTEXFc.clazz, "y", "I");
- TRIVERTEXFc.Red = (*env)->GetFieldID(env, TRIVERTEXFc.clazz, "Red", "S");
- TRIVERTEXFc.Green = (*env)->GetFieldID(env, TRIVERTEXFc.clazz, "Green", "S");
- TRIVERTEXFc.Blue = (*env)->GetFieldID(env, TRIVERTEXFc.clazz, "Blue", "S");
- TRIVERTEXFc.Alpha = (*env)->GetFieldID(env, TRIVERTEXFc.clazz, "Alpha", "S");
- TRIVERTEXFc.cached = 1;
-}
-
-TRIVERTEX *getTRIVERTEXFields(JNIEnv *env, jobject lpObject, TRIVERTEX *lpStruct)
-{
- if (!TRIVERTEXFc.cached) cacheTRIVERTEXFids(env, lpObject);
- lpStruct->x = (*env)->GetIntField(env, lpObject, TRIVERTEXFc.x);
- lpStruct->y = (*env)->GetIntField(env, lpObject, TRIVERTEXFc.y);
- lpStruct->Red = (*env)->GetShortField(env, lpObject, TRIVERTEXFc.Red);
- lpStruct->Green = (*env)->GetShortField(env, lpObject, TRIVERTEXFc.Green);
- lpStruct->Blue = (*env)->GetShortField(env, lpObject, TRIVERTEXFc.Blue);
- lpStruct->Alpha = (*env)->GetShortField(env, lpObject, TRIVERTEXFc.Alpha);
- return lpStruct;
-}
-
-void setTRIVERTEXFields(JNIEnv *env, jobject lpObject, TRIVERTEX *lpStruct)
-{
- if (!TRIVERTEXFc.cached) cacheTRIVERTEXFids(env, lpObject);
- (*env)->SetIntField(env, lpObject, TRIVERTEXFc.x, (jint)lpStruct->x);
- (*env)->SetIntField(env, lpObject, TRIVERTEXFc.y, (jint)lpStruct->y);
- (*env)->SetShortField(env, lpObject, TRIVERTEXFc.Red, (jshort)lpStruct->Red);
- (*env)->SetShortField(env, lpObject, TRIVERTEXFc.Green, (jshort)lpStruct->Green);
- (*env)->SetShortField(env, lpObject, TRIVERTEXFc.Blue, (jshort)lpStruct->Blue);
- (*env)->SetShortField(env, lpObject, TRIVERTEXFc.Alpha, (jshort)lpStruct->Alpha);
-}
-#endif /* NO_TRIVERTEX */
-
-#ifndef NO_TVHITTESTINFO
-typedef struct TVHITTESTINFO_FID_CACHE {
- int cached;
- jclass clazz;
- jfieldID x, y, flags, hItem;
-} TVHITTESTINFO_FID_CACHE;
-
-TVHITTESTINFO_FID_CACHE TVHITTESTINFOFc;
-
-void cacheTVHITTESTINFOFids(JNIEnv *env, jobject lpObject)
-{
- if (TVHITTESTINFOFc.cached) return;
- TVHITTESTINFOFc.clazz = (*env)->GetObjectClass(env, lpObject);
- TVHITTESTINFOFc.x = (*env)->GetFieldID(env, TVHITTESTINFOFc.clazz, "x", "I");
- TVHITTESTINFOFc.y = (*env)->GetFieldID(env, TVHITTESTINFOFc.clazz, "y", "I");
- TVHITTESTINFOFc.flags = (*env)->GetFieldID(env, TVHITTESTINFOFc.clazz, "flags", "I");
- TVHITTESTINFOFc.hItem = (*env)->GetFieldID(env, TVHITTESTINFOFc.clazz, "hItem", "I");
- TVHITTESTINFOFc.cached = 1;
-}
-
-TVHITTESTINFO *getTVHITTESTINFOFields(JNIEnv *env, jobject lpObject, TVHITTESTINFO *lpStruct)
-{
- if (!TVHITTESTINFOFc.cached) cacheTVHITTESTINFOFids(env, lpObject);
- lpStruct->pt.x = (*env)->GetIntField(env, lpObject, TVHITTESTINFOFc.x);
- lpStruct->pt.y = (*env)->GetIntField(env, lpObject, TVHITTESTINFOFc.y);
- lpStruct->flags = (*env)->GetIntField(env, lpObject, TVHITTESTINFOFc.flags);
- lpStruct->hItem = (HTREEITEM)(*env)->GetIntField(env, lpObject, TVHITTESTINFOFc.hItem);
- return lpStruct;
-}
-
-void setTVHITTESTINFOFields(JNIEnv *env, jobject lpObject, TVHITTESTINFO *lpStruct)
-{
- if (!TVHITTESTINFOFc.cached) cacheTVHITTESTINFOFids(env, lpObject);
- (*env)->SetIntField(env, lpObject, TVHITTESTINFOFc.x, (jint)lpStruct->pt.x);
- (*env)->SetIntField(env, lpObject, TVHITTESTINFOFc.y, (jint)lpStruct->pt.y);
- (*env)->SetIntField(env, lpObject, TVHITTESTINFOFc.flags, (jint)lpStruct->flags);
- (*env)->SetIntField(env, lpObject, TVHITTESTINFOFc.hItem, (jint)lpStruct->hItem);
-}
-#endif /* NO_TVHITTESTINFO */
-
-#ifndef NO_TVINSERTSTRUCT
-typedef struct TVINSERTSTRUCT_FID_CACHE {
- int cached;
- jclass clazz;
- jfieldID hParent, hInsertAfter, mask, hItem, state, stateMask, pszText, cchTextMax, iImage, iSelectedImage, cChildren, lParam;
-} TVINSERTSTRUCT_FID_CACHE;
-
-TVINSERTSTRUCT_FID_CACHE TVINSERTSTRUCTFc;
-
-void cacheTVINSERTSTRUCTFids(JNIEnv *env, jobject lpObject)
-{
- if (TVINSERTSTRUCTFc.cached) return;
- TVINSERTSTRUCTFc.clazz = (*env)->GetObjectClass(env, lpObject);
- TVINSERTSTRUCTFc.hParent = (*env)->GetFieldID(env, TVINSERTSTRUCTFc.clazz, "hParent", "I");
- TVINSERTSTRUCTFc.hInsertAfter = (*env)->GetFieldID(env, TVINSERTSTRUCTFc.clazz, "hInsertAfter", "I");
- TVINSERTSTRUCTFc.mask = (*env)->GetFieldID(env, TVINSERTSTRUCTFc.clazz, "mask", "I");
- TVINSERTSTRUCTFc.hItem = (*env)->GetFieldID(env, TVINSERTSTRUCTFc.clazz, "hItem", "I");
- TVINSERTSTRUCTFc.state = (*env)->GetFieldID(env, TVINSERTSTRUCTFc.clazz, "state", "I");
- TVINSERTSTRUCTFc.stateMask = (*env)->GetFieldID(env, TVINSERTSTRUCTFc.clazz, "stateMask", "I");
- TVINSERTSTRUCTFc.pszText = (*env)->GetFieldID(env, TVINSERTSTRUCTFc.clazz, "pszText", "I");
- TVINSERTSTRUCTFc.cchTextMax = (*env)->GetFieldID(env, TVINSERTSTRUCTFc.clazz, "cchTextMax", "I");
- TVINSERTSTRUCTFc.iImage = (*env)->GetFieldID(env, TVINSERTSTRUCTFc.clazz, "iImage", "I");
- TVINSERTSTRUCTFc.iSelectedImage = (*env)->GetFieldID(env, TVINSERTSTRUCTFc.clazz, "iSelectedImage", "I");
- TVINSERTSTRUCTFc.cChildren = (*env)->GetFieldID(env, TVINSERTSTRUCTFc.clazz, "cChildren", "I");
- TVINSERTSTRUCTFc.lParam = (*env)->GetFieldID(env, TVINSERTSTRUCTFc.clazz, "lParam", "I");
- TVINSERTSTRUCTFc.cached = 1;
-}
-
-TVINSERTSTRUCT *getTVINSERTSTRUCTFields(JNIEnv *env, jobject lpObject, TVINSERTSTRUCT *lpStruct)
-{
- if (!TVINSERTSTRUCTFc.cached) cacheTVINSERTSTRUCTFids(env, lpObject);
- lpStruct->hParent = (HTREEITEM)(*env)->GetIntField(env, lpObject, TVINSERTSTRUCTFc.hParent);
- lpStruct->hInsertAfter = (HTREEITEM)(*env)->GetIntField(env, lpObject, TVINSERTSTRUCTFc.hInsertAfter);
- lpStruct->item.mask = (*env)->GetIntField(env, lpObject, TVINSERTSTRUCTFc.mask);
- lpStruct->item.hItem = (HTREEITEM)(*env)->GetIntField(env, lpObject, TVINSERTSTRUCTFc.hItem);
- lpStruct->item.state = (*env)->GetIntField(env, lpObject, TVINSERTSTRUCTFc.state);
- lpStruct->item.stateMask = (*env)->GetIntField(env, lpObject, TVINSERTSTRUCTFc.stateMask);
- lpStruct->item.pszText = (LPTSTR)(*env)->GetIntField(env, lpObject, TVINSERTSTRUCTFc.pszText);
- lpStruct->item.cchTextMax = (*env)->GetIntField(env, lpObject, TVINSERTSTRUCTFc.cchTextMax);
- lpStruct->item.iImage = (*env)->GetIntField(env, lpObject, TVINSERTSTRUCTFc.iImage);
- lpStruct->item.iSelectedImage = (*env)->GetIntField(env, lpObject, TVINSERTSTRUCTFc.iSelectedImage);
- lpStruct->item.cChildren = (*env)->GetIntField(env, lpObject, TVINSERTSTRUCTFc.cChildren);
- lpStruct->item.lParam = (*env)->GetIntField(env, lpObject, TVINSERTSTRUCTFc.lParam);
- return lpStruct;
-}
-
-void setTVINSERTSTRUCTFields(JNIEnv *env, jobject lpObject, TVINSERTSTRUCT *lpStruct)
-{
- if (!TVINSERTSTRUCTFc.cached) cacheTVINSERTSTRUCTFids(env, lpObject);
- (*env)->SetIntField(env, lpObject, TVINSERTSTRUCTFc.hParent, (jint)lpStruct->hParent);
- (*env)->SetIntField(env, lpObject, TVINSERTSTRUCTFc.hInsertAfter, (jint)lpStruct->hInsertAfter);
- (*env)->SetIntField(env, lpObject, TVINSERTSTRUCTFc.mask, (jint)lpStruct->item.mask);
- (*env)->SetIntField(env, lpObject, TVINSERTSTRUCTFc.hItem, (jint)lpStruct->item.hItem);
- (*env)->SetIntField(env, lpObject, TVINSERTSTRUCTFc.state, (jint)lpStruct->item.state);
- (*env)->SetIntField(env, lpObject, TVINSERTSTRUCTFc.stateMask, (jint)lpStruct->item.stateMask);
- (*env)->SetIntField(env, lpObject, TVINSERTSTRUCTFc.pszText, (jint)lpStruct->item.pszText);
- (*env)->SetIntField(env, lpObject, TVINSERTSTRUCTFc.cchTextMax, (jint)lpStruct->item.cchTextMax);
- (*env)->SetIntField(env, lpObject, TVINSERTSTRUCTFc.iImage, (jint)lpStruct->item.iImage);
- (*env)->SetIntField(env, lpObject, TVINSERTSTRUCTFc.iSelectedImage, (jint)lpStruct->item.iSelectedImage);
- (*env)->SetIntField(env, lpObject, TVINSERTSTRUCTFc.cChildren, (jint)lpStruct->item.cChildren);
- (*env)->SetIntField(env, lpObject, TVINSERTSTRUCTFc.lParam, (jint)lpStruct->item.lParam);
-}
-#endif /* NO_TVINSERTSTRUCT */
-
-#ifndef NO_TVITEM
-typedef struct TVITEM_FID_CACHE {
- int cached;
- jclass clazz;
- jfieldID mask, hItem, state, stateMask, pszText, cchTextMax, iImage, iSelectedImage, cChildren, lParam;
-} TVITEM_FID_CACHE;
-
-TVITEM_FID_CACHE TVITEMFc;
-
-void cacheTVITEMFids(JNIEnv *env, jobject lpObject)
-{
- if (TVITEMFc.cached) return;
- TVITEMFc.clazz = (*env)->GetObjectClass(env, lpObject);
- TVITEMFc.mask = (*env)->GetFieldID(env, TVITEMFc.clazz, "mask", "I");
- TVITEMFc.hItem = (*env)->GetFieldID(env, TVITEMFc.clazz, "hItem", "I");
- TVITEMFc.state = (*env)->GetFieldID(env, TVITEMFc.clazz, "state", "I");
- TVITEMFc.stateMask = (*env)->GetFieldID(env, TVITEMFc.clazz, "stateMask", "I");
- TVITEMFc.pszText = (*env)->GetFieldID(env, TVITEMFc.clazz, "pszText", "I");
- TVITEMFc.cchTextMax = (*env)->GetFieldID(env, TVITEMFc.clazz, "cchTextMax", "I");
- TVITEMFc.iImage = (*env)->GetFieldID(env, TVITEMFc.clazz, "iImage", "I");
- TVITEMFc.iSelectedImage = (*env)->GetFieldID(env, TVITEMFc.clazz, "iSelectedImage", "I");
- TVITEMFc.cChildren = (*env)->GetFieldID(env, TVITEMFc.clazz, "cChildren", "I");
- TVITEMFc.lParam = (*env)->GetFieldID(env, TVITEMFc.clazz, "lParam", "I");
- TVITEMFc.cached = 1;
-}
-
-TVITEM *getTVITEMFields(JNIEnv *env, jobject lpObject, TVITEM *lpStruct)
-{
- if (!TVITEMFc.cached) cacheTVITEMFids(env, lpObject);
- lpStruct->mask = (*env)->GetIntField(env, lpObject, TVITEMFc.mask);
- lpStruct->hItem = (HTREEITEM)(*env)->GetIntField(env, lpObject, TVITEMFc.hItem);
- lpStruct->state = (*env)->GetIntField(env, lpObject, TVITEMFc.state);
- lpStruct->stateMask = (*env)->GetIntField(env, lpObject, TVITEMFc.stateMask);
- lpStruct->pszText = (LPTSTR)(*env)->GetIntField(env, lpObject, TVITEMFc.pszText);
- lpStruct->cchTextMax = (*env)->GetIntField(env, lpObject, TVITEMFc.cchTextMax);
- lpStruct->iImage = (*env)->GetIntField(env, lpObject, TVITEMFc.iImage);
- lpStruct->iSelectedImage = (*env)->GetIntField(env, lpObject, TVITEMFc.iSelectedImage);
- lpStruct->cChildren = (*env)->GetIntField(env, lpObject, TVITEMFc.cChildren);
- lpStruct->lParam = (*env)->GetIntField(env, lpObject, TVITEMFc.lParam);
- return lpStruct;
-}
-
-void setTVITEMFields(JNIEnv *env, jobject lpObject, TVITEM *lpStruct)
-{
- if (!TVITEMFc.cached) cacheTVITEMFids(env, lpObject);
- (*env)->SetIntField(env, lpObject, TVITEMFc.mask, (jint)lpStruct->mask);
- (*env)->SetIntField(env, lpObject, TVITEMFc.hItem, (jint)lpStruct->hItem);
- (*env)->SetIntField(env, lpObject, TVITEMFc.state, (jint)lpStruct->state);
- (*env)->SetIntField(env, lpObject, TVITEMFc.stateMask, (jint)lpStruct->stateMask);
- (*env)->SetIntField(env, lpObject, TVITEMFc.pszText, (jint)lpStruct->pszText);
- (*env)->SetIntField(env, lpObject, TVITEMFc.cchTextMax, (jint)lpStruct->cchTextMax);
- (*env)->SetIntField(env, lpObject, TVITEMFc.iImage, (jint)lpStruct->iImage);
- (*env)->SetIntField(env, lpObject, TVITEMFc.iSelectedImage, (jint)lpStruct->iSelectedImage);
- (*env)->SetIntField(env, lpObject, TVITEMFc.cChildren, (jint)lpStruct->cChildren);
- (*env)->SetIntField(env, lpObject, TVITEMFc.lParam, (jint)lpStruct->lParam);
-}
-#endif /* NO_TVITEM */
-
-#ifndef NO_WINDOWPLACEMENT
-typedef struct WINDOWPLACEMENT_FID_CACHE {
- int cached;
- jclass clazz;
- jfieldID length, flags, showCmd, ptMinPosition_x, ptMinPosition_y, ptMaxPosition_x, ptMaxPosition_y, left, top, right, bottom;
-} WINDOWPLACEMENT_FID_CACHE;
-
-WINDOWPLACEMENT_FID_CACHE WINDOWPLACEMENTFc;
-
-void cacheWINDOWPLACEMENTFids(JNIEnv *env, jobject lpObject)
-{
- if (WINDOWPLACEMENTFc.cached) return;
- WINDOWPLACEMENTFc.clazz = (*env)->GetObjectClass(env, lpObject);
- WINDOWPLACEMENTFc.length = (*env)->GetFieldID(env, WINDOWPLACEMENTFc.clazz, "length", "I");
- WINDOWPLACEMENTFc.flags = (*env)->GetFieldID(env, WINDOWPLACEMENTFc.clazz, "flags", "I");
- WINDOWPLACEMENTFc.showCmd = (*env)->GetFieldID(env, WINDOWPLACEMENTFc.clazz, "showCmd", "I");
- WINDOWPLACEMENTFc.ptMinPosition_x = (*env)->GetFieldID(env, WINDOWPLACEMENTFc.clazz, "ptMinPosition_x", "I");
- WINDOWPLACEMENTFc.ptMinPosition_y = (*env)->GetFieldID(env, WINDOWPLACEMENTFc.clazz, "ptMinPosition_y", "I");
- WINDOWPLACEMENTFc.ptMaxPosition_x = (*env)->GetFieldID(env, WINDOWPLACEMENTFc.clazz, "ptMaxPosition_x", "I");
- WINDOWPLACEMENTFc.ptMaxPosition_y = (*env)->GetFieldID(env, WINDOWPLACEMENTFc.clazz, "ptMaxPosition_y", "I");
- WINDOWPLACEMENTFc.left = (*env)->GetFieldID(env, WINDOWPLACEMENTFc.clazz, "left", "I");
- WINDOWPLACEMENTFc.top = (*env)->GetFieldID(env, WINDOWPLACEMENTFc.clazz, "top", "I");
- WINDOWPLACEMENTFc.right = (*env)->GetFieldID(env, WINDOWPLACEMENTFc.clazz, "right", "I");
- WINDOWPLACEMENTFc.bottom = (*env)->GetFieldID(env, WINDOWPLACEMENTFc.clazz, "bottom", "I");
- WINDOWPLACEMENTFc.cached = 1;
-}
-
-WINDOWPLACEMENT *getWINDOWPLACEMENTFields(JNIEnv *env, jobject lpObject, WINDOWPLACEMENT *lpStruct)
-{
- if (!WINDOWPLACEMENTFc.cached) cacheWINDOWPLACEMENTFids(env, lpObject);
- lpStruct->length = (*env)->GetIntField(env, lpObject, WINDOWPLACEMENTFc.length);
- lpStruct->flags = (*env)->GetIntField(env, lpObject, WINDOWPLACEMENTFc.flags);
- lpStruct->showCmd = (*env)->GetIntField(env, lpObject, WINDOWPLACEMENTFc.showCmd);
- lpStruct->ptMinPosition.x = (*env)->GetIntField(env, lpObject, WINDOWPLACEMENTFc.ptMinPosition_x);
- lpStruct->ptMinPosition.y = (*env)->GetIntField(env, lpObject, WINDOWPLACEMENTFc.ptMinPosition_y);
- lpStruct->ptMaxPosition.x = (*env)->GetIntField(env, lpObject, WINDOWPLACEMENTFc.ptMaxPosition_x);
- lpStruct->ptMaxPosition.y = (*env)->GetIntField(env, lpObject, WINDOWPLACEMENTFc.ptMaxPosition_y);
- lpStruct->rcNormalPosition.left = (*env)->GetIntField(env, lpObject, WINDOWPLACEMENTFc.left);
- lpStruct->rcNormalPosition.top = (*env)->GetIntField(env, lpObject, WINDOWPLACEMENTFc.top);
- lpStruct->rcNormalPosition.right = (*env)->GetIntField(env, lpObject, WINDOWPLACEMENTFc.right);
- lpStruct->rcNormalPosition.bottom = (*env)->GetIntField(env, lpObject, WINDOWPLACEMENTFc.bottom);
- return lpStruct;
-}
-
-void setWINDOWPLACEMENTFields(JNIEnv *env, jobject lpObject, WINDOWPLACEMENT *lpStruct)
-{
- if (!WINDOWPLACEMENTFc.cached) cacheWINDOWPLACEMENTFids(env, lpObject);
- (*env)->SetIntField(env, lpObject, WINDOWPLACEMENTFc.length, (jint)lpStruct->length);
- (*env)->SetIntField(env, lpObject, WINDOWPLACEMENTFc.flags, (jint)lpStruct->flags);
- (*env)->SetIntField(env, lpObject, WINDOWPLACEMENTFc.showCmd, (jint)lpStruct->showCmd);
- (*env)->SetIntField(env, lpObject, WINDOWPLACEMENTFc.ptMinPosition_x, (jint)lpStruct->ptMinPosition.x);
- (*env)->SetIntField(env, lpObject, WINDOWPLACEMENTFc.ptMinPosition_y, (jint)lpStruct->ptMinPosition.y);
- (*env)->SetIntField(env, lpObject, WINDOWPLACEMENTFc.ptMaxPosition_x, (jint)lpStruct->ptMaxPosition.x);
- (*env)->SetIntField(env, lpObject, WINDOWPLACEMENTFc.ptMaxPosition_y, (jint)lpStruct->ptMaxPosition.y);
- (*env)->SetIntField(env, lpObject, WINDOWPLACEMENTFc.left, (jint)lpStruct->rcNormalPosition.left);
- (*env)->SetIntField(env, lpObject, WINDOWPLACEMENTFc.top, (jint)lpStruct->rcNormalPosition.top);
- (*env)->SetIntField(env, lpObject, WINDOWPLACEMENTFc.right, (jint)lpStruct->rcNormalPosition.right);
- (*env)->SetIntField(env, lpObject, WINDOWPLACEMENTFc.bottom, (jint)lpStruct->rcNormalPosition.bottom);
-}
-#endif /* NO_WINDOWPLACEMENT */
-
-#ifndef NO_WINDOWPOS
-typedef struct WINDOWPOS_FID_CACHE {
- int cached;
- jclass clazz;
- jfieldID hwnd, hwndInsertAfter, x, y, cx, cy, flags;
-} WINDOWPOS_FID_CACHE;
-
-WINDOWPOS_FID_CACHE WINDOWPOSFc;
-
-void cacheWINDOWPOSFids(JNIEnv *env, jobject lpObject)
-{
- if (WINDOWPOSFc.cached) return;
- WINDOWPOSFc.clazz = (*env)->GetObjectClass(env, lpObject);
- WINDOWPOSFc.hwnd = (*env)->GetFieldID(env, WINDOWPOSFc.clazz, "hwnd", "I");
- WINDOWPOSFc.hwndInsertAfter = (*env)->GetFieldID(env, WINDOWPOSFc.clazz, "hwndInsertAfter", "I");
- WINDOWPOSFc.x = (*env)->GetFieldID(env, WINDOWPOSFc.clazz, "x", "I");
- WINDOWPOSFc.y = (*env)->GetFieldID(env, WINDOWPOSFc.clazz, "y", "I");
- WINDOWPOSFc.cx = (*env)->GetFieldID(env, WINDOWPOSFc.clazz, "cx", "I");
- WINDOWPOSFc.cy = (*env)->GetFieldID(env, WINDOWPOSFc.clazz, "cy", "I");
- WINDOWPOSFc.flags = (*env)->GetFieldID(env, WINDOWPOSFc.clazz, "flags", "I");
- WINDOWPOSFc.cached = 1;
-}
-
-WINDOWPOS *getWINDOWPOSFields(JNIEnv *env, jobject lpObject, WINDOWPOS *lpStruct)
-{
- if (!WINDOWPOSFc.cached) cacheWINDOWPOSFids(env, lpObject);
- lpStruct->hwnd = (HWND)(*env)->GetIntField(env, lpObject, WINDOWPOSFc.hwnd);
- lpStruct->hwndInsertAfter = (HWND)(*env)->GetIntField(env, lpObject, WINDOWPOSFc.hwndInsertAfter);
- lpStruct->x = (*env)->GetIntField(env, lpObject, WINDOWPOSFc.x);
- lpStruct->y = (*env)->GetIntField(env, lpObject, WINDOWPOSFc.y);
- lpStruct->cx = (*env)->GetIntField(env, lpObject, WINDOWPOSFc.cx);
- lpStruct->cy = (*env)->GetIntField(env, lpObject, WINDOWPOSFc.cy);
- lpStruct->flags = (*env)->GetIntField(env, lpObject, WINDOWPOSFc.flags);
- return lpStruct;
-}
-
-void setWINDOWPOSFields(JNIEnv *env, jobject lpObject, WINDOWPOS *lpStruct)
-{
- if (!WINDOWPOSFc.cached) cacheWINDOWPOSFids(env, lpObject);
- (*env)->SetIntField(env, lpObject, WINDOWPOSFc.hwnd, (jint)lpStruct->hwnd);
- (*env)->SetIntField(env, lpObject, WINDOWPOSFc.hwndInsertAfter, (jint)lpStruct->hwndInsertAfter);
- (*env)->SetIntField(env, lpObject, WINDOWPOSFc.x, (jint)lpStruct->x);
- (*env)->SetIntField(env, lpObject, WINDOWPOSFc.y, (jint)lpStruct->y);
- (*env)->SetIntField(env, lpObject, WINDOWPOSFc.cx, (jint)lpStruct->cx);
- (*env)->SetIntField(env, lpObject, WINDOWPOSFc.cy, (jint)lpStruct->cy);
- (*env)->SetIntField(env, lpObject, WINDOWPOSFc.flags, (jint)lpStruct->flags);
-}
-#endif /* NO_WINDOWPOS */
-
-#ifndef NO_WNDCLASS
-typedef struct WNDCLASS_FID_CACHE {
- int cached;
- jclass clazz;
- jfieldID style, lpfnWndProc, cbClsExtra, cbWndExtra, hInstance, hIcon, hCursor, hbrBackground, lpszMenuName, lpszClassName;
-} WNDCLASS_FID_CACHE;
-
-WNDCLASS_FID_CACHE WNDCLASSFc;
-
-void cacheWNDCLASSFids(JNIEnv *env, jobject lpObject)
-{
- if (WNDCLASSFc.cached) return;
- WNDCLASSFc.clazz = (*env)->GetObjectClass(env, lpObject);
- WNDCLASSFc.style = (*env)->GetFieldID(env, WNDCLASSFc.clazz, "style", "I");
- WNDCLASSFc.lpfnWndProc = (*env)->GetFieldID(env, WNDCLASSFc.clazz, "lpfnWndProc", "I");
- WNDCLASSFc.cbClsExtra = (*env)->GetFieldID(env, WNDCLASSFc.clazz, "cbClsExtra", "I");
- WNDCLASSFc.cbWndExtra = (*env)->GetFieldID(env, WNDCLASSFc.clazz, "cbWndExtra", "I");
- WNDCLASSFc.hInstance = (*env)->GetFieldID(env, WNDCLASSFc.clazz, "hInstance", "I");
- WNDCLASSFc.hIcon = (*env)->GetFieldID(env, WNDCLASSFc.clazz, "hIcon", "I");
- WNDCLASSFc.hCursor = (*env)->GetFieldID(env, WNDCLASSFc.clazz, "hCursor", "I");
- WNDCLASSFc.hbrBackground = (*env)->GetFieldID(env, WNDCLASSFc.clazz, "hbrBackground", "I");
- WNDCLASSFc.lpszMenuName = (*env)->GetFieldID(env, WNDCLASSFc.clazz, "lpszMenuName", "I");
- WNDCLASSFc.lpszClassName = (*env)->GetFieldID(env, WNDCLASSFc.clazz, "lpszClassName", "I");
- WNDCLASSFc.cached = 1;
-}
-
-WNDCLASS *getWNDCLASSFields(JNIEnv *env, jobject lpObject, WNDCLASS *lpStruct)
-{
- if (!WNDCLASSFc.cached) cacheWNDCLASSFids(env, lpObject);
- lpStruct->style = (*env)->GetIntField(env, lpObject, WNDCLASSFc.style);
- lpStruct->lpfnWndProc = (WNDPROC)(*env)->GetIntField(env, lpObject, WNDCLASSFc.lpfnWndProc);
- lpStruct->cbClsExtra = (*env)->GetIntField(env, lpObject, WNDCLASSFc.cbClsExtra);
- lpStruct->cbWndExtra = (*env)->GetIntField(env, lpObject, WNDCLASSFc.cbWndExtra);
- lpStruct->hInstance = (HINSTANCE)(*env)->GetIntField(env, lpObject, WNDCLASSFc.hInstance);
- lpStruct->hIcon = (HICON)(*env)->GetIntField(env, lpObject, WNDCLASSFc.hIcon);
- lpStruct->hCursor = (HCURSOR)(*env)->GetIntField(env, lpObject, WNDCLASSFc.hCursor);
- lpStruct->hbrBackground = (HBRUSH)(*env)->GetIntField(env, lpObject, WNDCLASSFc.hbrBackground);
- lpStruct->lpszMenuName = (LPCTSTR)(*env)->GetIntField(env, lpObject, WNDCLASSFc.lpszMenuName);
- lpStruct->lpszClassName = (LPCTSTR)(*env)->GetIntField(env, lpObject, WNDCLASSFc.lpszClassName);
- return lpStruct;
-}
-
-void setWNDCLASSFields(JNIEnv *env, jobject lpObject, WNDCLASS *lpStruct)
-{
- if (!WNDCLASSFc.cached) cacheWNDCLASSFids(env, lpObject);
- (*env)->SetIntField(env, lpObject, WNDCLASSFc.style, (jint)lpStruct->style);
- (*env)->SetIntField(env, lpObject, WNDCLASSFc.lpfnWndProc, (jint)lpStruct->lpfnWndProc);
- (*env)->SetIntField(env, lpObject, WNDCLASSFc.cbClsExtra, (jint)lpStruct->cbClsExtra);
- (*env)->SetIntField(env, lpObject, WNDCLASSFc.cbWndExtra, (jint)lpStruct->cbWndExtra);
- (*env)->SetIntField(env, lpObject, WNDCLASSFc.hInstance, (jint)lpStruct->hInstance);
- (*env)->SetIntField(env, lpObject, WNDCLASSFc.hIcon, (jint)lpStruct->hIcon);
- (*env)->SetIntField(env, lpObject, WNDCLASSFc.hCursor, (jint)lpStruct->hCursor);
- (*env)->SetIntField(env, lpObject, WNDCLASSFc.hbrBackground, (jint)lpStruct->hbrBackground);
- (*env)->SetIntField(env, lpObject, WNDCLASSFc.lpszMenuName, (jint)lpStruct->lpszMenuName);
- (*env)->SetIntField(env, lpObject, WNDCLASSFc.lpszClassName, (jint)lpStruct->lpszClassName);
-}
-#endif /* NO_WNDCLASS */
-
-/************************ OLE ***************************/
-
-#ifndef NO_CAUUID
-typedef struct CAUUID_FID_CACHE {
- int cached;
- jclass clazz;
- jfieldID cElems, pElems;
-} CAUUID_FID_CACHE;
-
-CAUUID_FID_CACHE CAUUIDFc;
-
-void cacheCAUUIDFids(JNIEnv *env, jobject lpObject)
-{
- if (CAUUIDFc.cached) return;
- CAUUIDFc.clazz = (*env)->GetObjectClass(env, lpObject);
- CAUUIDFc.cElems = (*env)->GetFieldID(env, CAUUIDFc.clazz, "cElems", "I");
- CAUUIDFc.pElems = (*env)->GetFieldID(env, CAUUIDFc.clazz, "pElems", "I");
- CAUUIDFc.cached = 1;
-}
-
-CAUUID *getCAUUIDFields(JNIEnv *env, jobject lpObject, CAUUID *lpStruct)
-{
- if (!CAUUIDFc.cached) cacheCAUUIDFids(env, lpObject);
- lpStruct->cElems = (*env)->GetIntField(env, lpObject, CAUUIDFc.cElems);
- lpStruct->pElems = (GUID FAR *)(*env)->GetIntField(env, lpObject, CAUUIDFc.pElems);
- return lpStruct;
-}
-
-void setCAUUIDFields(JNIEnv *env, jobject lpObject, CAUUID *lpStruct)
-{
- if (!CAUUIDFc.cached) cacheCAUUIDFids(env, lpObject);
- (*env)->SetIntField(env, lpObject, CAUUIDFc.cElems, (jint)lpStruct->cElems);
- (*env)->SetIntField(env, lpObject, CAUUIDFc.pElems, (jint)lpStruct->pElems);
-}
-#endif /* NO_CAUUID */
-
-#ifndef NO_CONTROLINFO
-typedef struct CONTROLINFO_FID_CACHE {
- int cached;
- jclass clazz;
- jfieldID cb, hAccel, cAccel, dwFlags;
-} CONTROLINFO_FID_CACHE;
-
-CONTROLINFO_FID_CACHE CONTROLINFOFc;
-
-void cacheCONTROLINFOFids(JNIEnv *env, jobject lpObject)
-{
- if (CONTROLINFOFc.cached) return;
- CONTROLINFOFc.clazz = (*env)->GetObjectClass(env, lpObject);
- CONTROLINFOFc.cb = (*env)->GetFieldID(env, CONTROLINFOFc.clazz, "cb", "I");
- CONTROLINFOFc.hAccel = (*env)->GetFieldID(env, CONTROLINFOFc.clazz, "hAccel", "I");
- CONTROLINFOFc.cAccel = (*env)->GetFieldID(env, CONTROLINFOFc.clazz, "cAccel", "S");
- CONTROLINFOFc.dwFlags = (*env)->GetFieldID(env, CONTROLINFOFc.clazz, "dwFlags", "I");
- CONTROLINFOFc.cached = 1;
-}
-
-CONTROLINFO *getCONTROLINFOFields(JNIEnv *env, jobject lpObject, CONTROLINFO *lpStruct)
-{
- if (!CONTROLINFOFc.cached) cacheCONTROLINFOFids(env, lpObject);
- lpStruct->cb = (*env)->GetIntField(env, lpObject, CONTROLINFOFc.cb);
- lpStruct->hAccel = (HACCEL)(*env)->GetIntField(env, lpObject, CONTROLINFOFc.hAccel);
- lpStruct->cAccel = (*env)->GetShortField(env, lpObject, CONTROLINFOFc.cAccel);
- lpStruct->dwFlags = (*env)->GetIntField(env, lpObject, CONTROLINFOFc.dwFlags);
- return lpStruct;
-}
-
-void setCONTROLINFOFields(JNIEnv *env, jobject lpObject, CONTROLINFO *lpStruct)
-{
- if (!CONTROLINFOFc.cached) cacheCONTROLINFOFids(env, lpObject);
- (*env)->SetIntField(env, lpObject, CONTROLINFOFc.cb, (jint)lpStruct->cb);
- (*env)->SetIntField(env, lpObject, CONTROLINFOFc.hAccel, (jint)lpStruct->hAccel);
- (*env)->SetShortField(env, lpObject, CONTROLINFOFc.cAccel, (jshort)lpStruct->cAccel);
- (*env)->SetIntField(env, lpObject, CONTROLINFOFc.dwFlags, (jint)lpStruct->dwFlags);
-}
-#endif /* NO_CONTROLINFO */
-
-#ifndef NO_COSERVERINFO
-typedef struct COSERVERINFO_FID_CACHE {
- int cached;
- jclass clazz;
- jfieldID dwReserved1, pwszName, pAuthInfo, dwReserved2;
-} COSERVERINFO_FID_CACHE;
-
-COSERVERINFO_FID_CACHE COSERVERINFOFc;
-
-void cacheCOSERVERINFOFids(JNIEnv *env, jobject lpObject)
-{
- if (COSERVERINFOFc.cached) return;
- COSERVERINFOFc.clazz = (*env)->GetObjectClass(env, lpObject);
- COSERVERINFOFc.dwReserved1 = (*env)->GetFieldID(env, COSERVERINFOFc.clazz, "dwReserved1", "I");
- COSERVERINFOFc.pwszName = (*env)->GetFieldID(env, COSERVERINFOFc.clazz, "pwszName", "I");
- COSERVERINFOFc.pAuthInfo = (*env)->GetFieldID(env, COSERVERINFOFc.clazz, "pAuthInfo", "I");
- COSERVERINFOFc.dwReserved2 = (*env)->GetFieldID(env, COSERVERINFOFc.clazz, "dwReserved2", "I");
- COSERVERINFOFc.cached = 1;
-}
-
-COSERVERINFO *getCOSERVERINFOFields(JNIEnv *env, jobject lpObject, COSERVERINFO *lpStruct)
-{
- if (!COSERVERINFOFc.cached) cacheCOSERVERINFOFids(env, lpObject);
- lpStruct->dwReserved1 = (*env)->GetIntField(env, lpObject, COSERVERINFOFc.dwReserved1);
- lpStruct->pwszName = (LPWSTR)(*env)->GetIntField(env, lpObject, COSERVERINFOFc.pwszName);
- lpStruct->pAuthInfo = (COAUTHINFO *)(*env)->GetIntField(env, lpObject, COSERVERINFOFc.pAuthInfo);
- lpStruct->dwReserved2 = (*env)->GetIntField(env, lpObject, COSERVERINFOFc.dwReserved2);
- return lpStruct;
-}
-
-void setCOSERVERINFOFields(JNIEnv *env, jobject lpObject, COSERVERINFO *lpStruct)
-{
- if (!COSERVERINFOFc.cached) cacheCOSERVERINFOFids(env, lpObject);
- (*env)->SetIntField(env, lpObject, COSERVERINFOFc.dwReserved1, (jint)lpStruct->dwReserved1);
- (*env)->SetIntField(env, lpObject, COSERVERINFOFc.pwszName, (jint)lpStruct->pwszName);
- (*env)->SetIntField(env, lpObject, COSERVERINFOFc.pAuthInfo, (jint)lpStruct->pAuthInfo);
- (*env)->SetIntField(env, lpObject, COSERVERINFOFc.dwReserved2, (jint)lpStruct->dwReserved2);
-}
-#endif /* NO_COSERVERINFO */
-
-#ifndef NO_DISPPARAMS
-typedef struct DISPPARAMS_FID_CACHE {
- int cached;
- jclass clazz;
- jfieldID rgvarg, rgdispidNamedArgs, cArgs, cNamedArgs;
-} DISPPARAMS_FID_CACHE;
-
-DISPPARAMS_FID_CACHE DISPPARAMSFc;
-
-void cacheDISPPARAMSFids(JNIEnv *env, jobject lpObject)
-{
- if (DISPPARAMSFc.cached) return;
- DISPPARAMSFc.clazz = (*env)->GetObjectClass(env, lpObject);
- DISPPARAMSFc.rgvarg = (*env)->GetFieldID(env, DISPPARAMSFc.clazz, "rgvarg", "I");
- DISPPARAMSFc.rgdispidNamedArgs = (*env)->GetFieldID(env, DISPPARAMSFc.clazz, "rgdispidNamedArgs", "I");
- DISPPARAMSFc.cArgs = (*env)->GetFieldID(env, DISPPARAMSFc.clazz, "cArgs", "I");
- DISPPARAMSFc.cNamedArgs = (*env)->GetFieldID(env, DISPPARAMSFc.clazz, "cNamedArgs", "I");
- DISPPARAMSFc.cached = 1;
-}
-
-DISPPARAMS *getDISPPARAMSFields(JNIEnv *env, jobject lpObject, DISPPARAMS *lpStruct)
-{
- if (!DISPPARAMSFc.cached) cacheDISPPARAMSFids(env, lpObject);
- lpStruct->rgvarg = (VARIANTARG FAR *)(*env)->GetIntField(env, lpObject, DISPPARAMSFc.rgvarg);
- lpStruct->rgdispidNamedArgs = (DISPID FAR *)(*env)->GetIntField(env, lpObject, DISPPARAMSFc.rgdispidNamedArgs);
- lpStruct->cArgs = (*env)->GetIntField(env, lpObject, DISPPARAMSFc.cArgs);
- lpStruct->cNamedArgs = (*env)->GetIntField(env, lpObject, DISPPARAMSFc.cNamedArgs);
- return lpStruct;
-}
-
-void setDISPPARAMSFields(JNIEnv *env, jobject lpObject, DISPPARAMS *lpStruct)
-{
- if (!DISPPARAMSFc.cached) cacheDISPPARAMSFids(env, lpObject);
- (*env)->SetIntField(env, lpObject, DISPPARAMSFc.rgvarg, (jint)lpStruct->rgvarg);
- (*env)->SetIntField(env, lpObject, DISPPARAMSFc.rgdispidNamedArgs, (jint)lpStruct->rgdispidNamedArgs);
- (*env)->SetIntField(env, lpObject, DISPPARAMSFc.cArgs, (jint)lpStruct->cArgs);
- (*env)->SetIntField(env, lpObject, DISPPARAMSFc.cNamedArgs, (jint)lpStruct->cNamedArgs);
-}
-#endif /* NO_DISPPARAMS */
-
-#ifndef NO_DVTARGETDEVICE
-typedef struct DVTARGETDEVICE_FID_CACHE {
- int cached;
- jclass clazz;
- jfieldID tdSize, tdDriverNameOffset, tdDeviceNameOffset, tdPortNameOffset, tdExtDevmodeOffset, tdData;
-} DVTARGETDEVICE_FID_CACHE;
-
-DVTARGETDEVICE_FID_CACHE DVTARGETDEVICEFc;
-
-void cacheDVTARGETDEVICEFids(JNIEnv *env, jobject lpObject)
-{
- if (DVTARGETDEVICEFc.cached) return;
- DVTARGETDEVICEFc.clazz = (*env)->GetObjectClass(env, lpObject);
- DVTARGETDEVICEFc.tdSize = (*env)->GetFieldID(env, DVTARGETDEVICEFc.clazz, "tdSize", "I");
- DVTARGETDEVICEFc.tdDriverNameOffset = (*env)->GetFieldID(env, DVTARGETDEVICEFc.clazz, "tdDriverNameOffset", "S");
- DVTARGETDEVICEFc.tdDeviceNameOffset = (*env)->GetFieldID(env, DVTARGETDEVICEFc.clazz, "tdDeviceNameOffset", "S");
- DVTARGETDEVICEFc.tdPortNameOffset = (*env)->GetFieldID(env, DVTARGETDEVICEFc.clazz, "tdPortNameOffset", "S");
- DVTARGETDEVICEFc.tdExtDevmodeOffset = (*env)->GetFieldID(env, DVTARGETDEVICEFc.clazz, "tdExtDevmodeOffset", "S");
- DVTARGETDEVICEFc.tdData = (*env)->GetFieldID(env, DVTARGETDEVICEFc.clazz, "tdData", "B");
- DVTARGETDEVICEFc.cached = 1;
-}
-
-DVTARGETDEVICE *getDVTARGETDEVICEFields(JNIEnv *env, jobject lpObject, DVTARGETDEVICE *lpStruct)
-{
- if (!DVTARGETDEVICEFc.cached) cacheDVTARGETDEVICEFids(env, lpObject);
- lpStruct->tdSize = (*env)->GetIntField(env, lpObject, DVTARGETDEVICEFc.tdSize);
- lpStruct->tdDriverNameOffset = (*env)->GetShortField(env, lpObject, DVTARGETDEVICEFc.tdDriverNameOffset);
- lpStruct->tdDeviceNameOffset = (*env)->GetShortField(env, lpObject, DVTARGETDEVICEFc.tdDeviceNameOffset);
- lpStruct->tdPortNameOffset = (*env)->GetShortField(env, lpObject, DVTARGETDEVICEFc.tdPortNameOffset);
- lpStruct->tdExtDevmodeOffset = (*env)->GetShortField(env, lpObject, DVTARGETDEVICEFc.tdExtDevmodeOffset);
- *lpStruct->tdData = (*env)->GetByteField(env, lpObject, DVTARGETDEVICEFc.tdData);
- return lpStruct;
-}
-
-void setDVTARGETDEVICEFields(JNIEnv *env, jobject lpObject, DVTARGETDEVICE *lpStruct)
-{
- if (!DVTARGETDEVICEFc.cached) cacheDVTARGETDEVICEFids(env, lpObject);
- (*env)->SetIntField(env, lpObject, DVTARGETDEVICEFc.tdSize, (jint)lpStruct->tdSize);
- (*env)->SetShortField(env, lpObject, DVTARGETDEVICEFc.tdDriverNameOffset, (jshort)lpStruct->tdDriverNameOffset);
- (*env)->SetShortField(env, lpObject, DVTARGETDEVICEFc.tdDeviceNameOffset, (jshort)lpStruct->tdDeviceNameOffset);
- (*env)->SetShortField(env, lpObject, DVTARGETDEVICEFc.tdPortNameOffset, (jshort)lpStruct->tdPortNameOffset);
- (*env)->SetShortField(env, lpObject, DVTARGETDEVICEFc.tdExtDevmodeOffset, (jshort)lpStruct->tdExtDevmodeOffset);
- (*env)->SetByteField(env, lpObject, DVTARGETDEVICEFc.tdData, (jbyte)*lpStruct->tdData);
-}
-#endif /* NO_DVTARGETDEVICE */
-
-#ifndef NO_EXCEPINFO
-typedef struct EXCEPINFO_FID_CACHE {
- int cached;
- jclass clazz;
- jfieldID wCode, wReserved, bstrSource, bstrDescription, bstrHelpFile, dwHelpContext, pvReserved, pfnDeferredFillIn, scode;
-} EXCEPINFO_FID_CACHE;
-
-EXCEPINFO_FID_CACHE EXCEPINFOFc;
-
-void cacheEXCEPINFOFids(JNIEnv *env, jobject lpObject)
-{
- if (EXCEPINFOFc.cached) return;
- EXCEPINFOFc.clazz = (*env)->GetObjectClass(env, lpObject);
- EXCEPINFOFc.wCode = (*env)->GetFieldID(env, EXCEPINFOFc.clazz, "wCode", "S");
- EXCEPINFOFc.wReserved = (*env)->GetFieldID(env, EXCEPINFOFc.clazz, "wReserved", "S");
- EXCEPINFOFc.bstrSource = (*env)->GetFieldID(env, EXCEPINFOFc.clazz, "bstrSource", "I");
- EXCEPINFOFc.bstrDescription = (*env)->GetFieldID(env, EXCEPINFOFc.clazz, "bstrDescription", "I");
- EXCEPINFOFc.bstrHelpFile = (*env)->GetFieldID(env, EXCEPINFOFc.clazz, "bstrHelpFile", "I");
- EXCEPINFOFc.dwHelpContext = (*env)->GetFieldID(env, EXCEPINFOFc.clazz, "dwHelpContext", "I");
- EXCEPINFOFc.pvReserved = (*env)->GetFieldID(env, EXCEPINFOFc.clazz, "pvReserved", "I");
- EXCEPINFOFc.pfnDeferredFillIn = (*env)->GetFieldID(env, EXCEPINFOFc.clazz, "pfnDeferredFillIn", "I");
- EXCEPINFOFc.scode = (*env)->GetFieldID(env, EXCEPINFOFc.clazz, "scode", "I");
- EXCEPINFOFc.cached = 1;
-}
-
-EXCEPINFO *getEXCEPINFOFields(JNIEnv *env, jobject lpObject, EXCEPINFO *lpStruct)
-{
- if (!EXCEPINFOFc.cached) cacheEXCEPINFOFids(env, lpObject);
- lpStruct->wCode = (*env)->GetShortField(env, lpObject, EXCEPINFOFc.wCode);
- lpStruct->wReserved = (*env)->GetShortField(env, lpObject, EXCEPINFOFc.wReserved);
- lpStruct->bstrSource = (BSTR)(*env)->GetIntField(env, lpObject, EXCEPINFOFc.bstrSource);
- lpStruct->bstrDescription = (BSTR)(*env)->GetIntField(env, lpObject, EXCEPINFOFc.bstrDescription);
- lpStruct->bstrHelpFile = (BSTR)(*env)->GetIntField(env, lpObject, EXCEPINFOFc.bstrHelpFile);
- lpStruct->dwHelpContext = (*env)->GetIntField(env, lpObject, EXCEPINFOFc.dwHelpContext);
- lpStruct->pvReserved = (void FAR *)(*env)->GetIntField(env, lpObject, EXCEPINFOFc.pvReserved);
- lpStruct->pfnDeferredFillIn = (HRESULT (STDAPICALLTYPE FAR* )(struct tagEXCEPINFO FAR*))(*env)->GetIntField(env, lpObject, EXCEPINFOFc.pfnDeferredFillIn);
- lpStruct->scode = (*env)->GetIntField(env, lpObject, EXCEPINFOFc.scode);
- return lpStruct;
-}
-
-void setEXCEPINFOFields(JNIEnv *env, jobject lpObject, EXCEPINFO *lpStruct)
-{
- if (!EXCEPINFOFc.cached) cacheEXCEPINFOFids(env, lpObject);
- (*env)->SetShortField(env, lpObject, EXCEPINFOFc.wCode, (jshort)lpStruct->wCode);
- (*env)->SetShortField(env, lpObject, EXCEPINFOFc.wReserved, (jshort)lpStruct->wReserved);
- (*env)->SetIntField(env, lpObject, EXCEPINFOFc.bstrSource, (jint)lpStruct->bstrSource);
- (*env)->SetIntField(env, lpObject, EXCEPINFOFc.bstrDescription, (jint)lpStruct->bstrDescription);
- (*env)->SetIntField(env, lpObject, EXCEPINFOFc.bstrHelpFile, (jint)lpStruct->bstrHelpFile);
- (*env)->SetIntField(env, lpObject, EXCEPINFOFc.dwHelpContext, (jint)lpStruct->dwHelpContext);
- (*env)->SetIntField(env, lpObject, EXCEPINFOFc.pvReserved, (jint)lpStruct->pvReserved);
- (*env)->SetIntField(env, lpObject, EXCEPINFOFc.pfnDeferredFillIn, (jint)lpStruct->pfnDeferredFillIn);
- (*env)->SetIntField(env, lpObject, EXCEPINFOFc.scode, (jint)lpStruct->scode);
-}
-#endif /* NO_EXCEPINFO */
-
-#ifndef NO_FORMATETC
-typedef struct FORMATETC_FID_CACHE {
- int cached;
- jclass clazz;
- jfieldID cfFormat, ptd, dwAspect, lindex, tymed;
-} FORMATETC_FID_CACHE;
-
-FORMATETC_FID_CACHE FORMATETCFc;
-
-void cacheFORMATETCFids(JNIEnv *env, jobject lpObject)
-{
- if (FORMATETCFc.cached) return;
- FORMATETCFc.clazz = (*env)->GetObjectClass(env, lpObject);
- FORMATETCFc.cfFormat = (*env)->GetFieldID(env, FORMATETCFc.clazz, "cfFormat", "I");
- FORMATETCFc.ptd = (*env)->GetFieldID(env, FORMATETCFc.clazz, "ptd", "I");
- FORMATETCFc.dwAspect = (*env)->GetFieldID(env, FORMATETCFc.clazz, "dwAspect", "I");
- FORMATETCFc.lindex = (*env)->GetFieldID(env, FORMATETCFc.clazz, "lindex", "I");
- FORMATETCFc.tymed = (*env)->GetFieldID(env, FORMATETCFc.clazz, "tymed", "I");
- FORMATETCFc.cached = 1;
-}
-
-FORMATETC *getFORMATETCFields(JNIEnv *env, jobject lpObject, FORMATETC *lpStruct)
-{
- if (!FORMATETCFc.cached) cacheFORMATETCFids(env, lpObject);
- lpStruct->cfFormat = (CLIPFORMAT)(*env)->GetIntField(env, lpObject, FORMATETCFc.cfFormat);
- lpStruct->ptd = (DVTARGETDEVICE *)(*env)->GetIntField(env, lpObject, FORMATETCFc.ptd);
- lpStruct->dwAspect = (*env)->GetIntField(env, lpObject, FORMATETCFc.dwAspect);
- lpStruct->lindex = (*env)->GetIntField(env, lpObject, FORMATETCFc.lindex);
- lpStruct->tymed = (*env)->GetIntField(env, lpObject, FORMATETCFc.tymed);
- return lpStruct;
-}
-
-void setFORMATETCFields(JNIEnv *env, jobject lpObject, FORMATETC *lpStruct)
-{
- if (!FORMATETCFc.cached) cacheFORMATETCFids(env, lpObject);
- (*env)->SetIntField(env, lpObject, FORMATETCFc.cfFormat, (jint)lpStruct->cfFormat);
- (*env)->SetIntField(env, lpObject, FORMATETCFc.ptd, (jint)lpStruct->ptd);
- (*env)->SetIntField(env, lpObject, FORMATETCFc.dwAspect, (jint)lpStruct->dwAspect);
- (*env)->SetIntField(env, lpObject, FORMATETCFc.lindex, (jint)lpStruct->lindex);
- (*env)->SetIntField(env, lpObject, FORMATETCFc.tymed, (jint)lpStruct->tymed);
-}
-#endif /* NO_FORMATETC */
-
-#ifndef NO_FUNCDESC1
-typedef struct FUNCDESC1_FID_CACHE {
- int cached;
- jclass clazz;
- jfieldID memid, lprgscode, lprgelemdescParam, funckind, invkind, callconv, cParams, cParamsOpt, oVft, cScodes, elemdescFunc_tdesc_union, elemdescFunc_tdesc_vt, elemdescFunc_paramdesc_pparamdescex, elemdescFunc_paramdesc_wParamFlags, wFuncFlags;
-} FUNCDESC1_FID_CACHE;
-
-FUNCDESC1_FID_CACHE FUNCDESC1Fc;
-
-void cacheFUNCDESC1Fids(JNIEnv *env, jobject lpObject)
-{
- if (FUNCDESC1Fc.cached) return;
- FUNCDESC1Fc.clazz = (*env)->GetObjectClass(env, lpObject);
- FUNCDESC1Fc.memid = (*env)->GetFieldID(env, FUNCDESC1Fc.clazz, "memid", "I");
- FUNCDESC1Fc.lprgscode = (*env)->GetFieldID(env, FUNCDESC1Fc.clazz, "lprgscode", "I");
- FUNCDESC1Fc.lprgelemdescParam = (*env)->GetFieldID(env, FUNCDESC1Fc.clazz, "lprgelemdescParam", "I");
- FUNCDESC1Fc.funckind = (*env)->GetFieldID(env, FUNCDESC1Fc.clazz, "funckind", "I");
- FUNCDESC1Fc.invkind = (*env)->GetFieldID(env, FUNCDESC1Fc.clazz, "invkind", "I");
- FUNCDESC1Fc.callconv = (*env)->GetFieldID(env, FUNCDESC1Fc.clazz, "callconv", "I");
- FUNCDESC1Fc.cParams = (*env)->GetFieldID(env, FUNCDESC1Fc.clazz, "cParams", "S");
- FUNCDESC1Fc.cParamsOpt = (*env)->GetFieldID(env, FUNCDESC1Fc.clazz, "cParamsOpt", "S");
- FUNCDESC1Fc.oVft = (*env)->GetFieldID(env, FUNCDESC1Fc.clazz, "oVft", "S");
- FUNCDESC1Fc.cScodes = (*env)->GetFieldID(env, FUNCDESC1Fc.clazz, "cScodes", "S");
- FUNCDESC1Fc.elemdescFunc_tdesc_union = (*env)->GetFieldID(env, FUNCDESC1Fc.clazz, "elemdescFunc_tdesc_union", "I");
- FUNCDESC1Fc.elemdescFunc_tdesc_vt = (*env)->GetFieldID(env, FUNCDESC1Fc.clazz, "elemdescFunc_tdesc_vt", "S");
- FUNCDESC1Fc.elemdescFunc_paramdesc_pparamdescex = (*env)->GetFieldID(env, FUNCDESC1Fc.clazz, "elemdescFunc_paramdesc_pparamdescex", "I");
- FUNCDESC1Fc.elemdescFunc_paramdesc_wParamFlags = (*env)->GetFieldID(env, FUNCDESC1Fc.clazz, "elemdescFunc_paramdesc_wParamFlags", "S");
- FUNCDESC1Fc.wFuncFlags = (*env)->GetFieldID(env, FUNCDESC1Fc.clazz, "wFuncFlags", "S");
- FUNCDESC1Fc.cached = 1;
-}
-
-FUNCDESC *getFUNCDESC1Fields(JNIEnv *env, jobject lpObject, FUNCDESC *lpStruct)
-{
- if (!FUNCDESC1Fc.cached) cacheFUNCDESC1Fids(env, lpObject);
- lpStruct->memid = (*env)->GetIntField(env, lpObject, FUNCDESC1Fc.memid);
- lpStruct->lprgscode = (SCODE FAR *)(*env)->GetIntField(env, lpObject, FUNCDESC1Fc.lprgscode);
- lpStruct->lprgelemdescParam = (ELEMDESC FAR *)(*env)->GetIntField(env, lpObject, FUNCDESC1Fc.lprgelemdescParam);
- lpStruct->funckind = (*env)->GetIntField(env, lpObject, FUNCDESC1Fc.funckind);
- lpStruct->invkind = (*env)->GetIntField(env, lpObject, FUNCDESC1Fc.invkind);
- lpStruct->callconv = (*env)->GetIntField(env, lpObject, FUNCDESC1Fc.callconv);
- lpStruct->cParams = (*env)->GetShortField(env, lpObject, FUNCDESC1Fc.cParams);
- lpStruct->cParamsOpt = (*env)->GetShortField(env, lpObject, FUNCDESC1Fc.cParamsOpt);
- lpStruct->oVft = (*env)->GetShortField(env, lpObject, FUNCDESC1Fc.oVft);
- lpStruct->cScodes = (*env)->GetShortField(env, lpObject, FUNCDESC1Fc.cScodes);
- lpStruct->elemdescFunc.tdesc.lptdesc = (struct FARSTRUCT tagTYPEDESC FAR* )(*env)->GetIntField(env, lpObject, FUNCDESC1Fc.elemdescFunc_tdesc_union);
- lpStruct->elemdescFunc.tdesc.vt = (*env)->GetShortField(env, lpObject, FUNCDESC1Fc.elemdescFunc_tdesc_vt);
- lpStruct->elemdescFunc.paramdesc.pparamdescex = (LPPARAMDESCEX)(*env)->GetIntField(env, lpObject, FUNCDESC1Fc.elemdescFunc_paramdesc_pparamdescex);
- lpStruct->elemdescFunc.paramdesc.wParamFlags = (*env)->GetShortField(env, lpObject, FUNCDESC1Fc.elemdescFunc_paramdesc_wParamFlags);
- lpStruct->wFuncFlags = (*env)->GetShortField(env, lpObject, FUNCDESC1Fc.wFuncFlags);
- return lpStruct;
-}
-
-void setFUNCDESC1Fields(JNIEnv *env, jobject lpObject, FUNCDESC *lpStruct)
-{
- if (!FUNCDESC1Fc.cached) cacheFUNCDESC1Fids(env, lpObject);
- (*env)->SetIntField(env, lpObject, FUNCDESC1Fc.memid, (jint)lpStruct->memid);
- (*env)->SetIntField(env, lpObject, FUNCDESC1Fc.lprgscode, (jint)lpStruct->lprgscode);
- (*env)->SetIntField(env, lpObject, FUNCDESC1Fc.lprgelemdescParam, (jint)lpStruct->lprgelemdescParam);
- (*env)->SetIntField(env, lpObject, FUNCDESC1Fc.funckind, (jint)lpStruct->funckind);
- (*env)->SetIntField(env, lpObject, FUNCDESC1Fc.invkind, (jint)lpStruct->invkind);
- (*env)->SetIntField(env, lpObject, FUNCDESC1Fc.callconv, (jint)lpStruct->callconv);
- (*env)->SetShortField(env, lpObject, FUNCDESC1Fc.cParams, (jshort)lpStruct->cParams);
- (*env)->SetShortField(env, lpObject, FUNCDESC1Fc.cParamsOpt, (jshort)lpStruct->cParamsOpt);
- (*env)->SetShortField(env, lpObject, FUNCDESC1Fc.oVft, (jshort)lpStruct->oVft);
- (*env)->SetShortField(env, lpObject, FUNCDESC1Fc.cScodes, (jshort)lpStruct->cScodes);
- (*env)->SetIntField(env, lpObject, FUNCDESC1Fc.elemdescFunc_tdesc_union, (jint)lpStruct->elemdescFunc.tdesc.lptdesc);
- (*env)->SetShortField(env, lpObject, FUNCDESC1Fc.elemdescFunc_tdesc_vt, (jshort)lpStruct->elemdescFunc.tdesc.vt);
- (*env)->SetIntField(env, lpObject, FUNCDESC1Fc.elemdescFunc_paramdesc_pparamdescex, (jint)lpStruct->elemdescFunc.paramdesc.pparamdescex);
- (*env)->SetShortField(env, lpObject, FUNCDESC1Fc.elemdescFunc_paramdesc_wParamFlags, (jshort)lpStruct->elemdescFunc.paramdesc.wParamFlags);
- (*env)->SetShortField(env, lpObject, FUNCDESC1Fc.wFuncFlags, (jshort)lpStruct->wFuncFlags);
-}
-#endif /* NO_FUNCDESC1 */
-
-#ifndef NO_FUNCDESC2
-typedef struct FUNCDESC2_FID_CACHE {
- int cached;
- jclass clazz;
- jfieldID memid, lprgscode, lprgelemdescParam, funckind, invkind, callconv, cParams, cParamsOpt, oVft, cScodes, elemdescFunc_tdesc_union, elemdescFunc_tdesc_vt, elemdescFunc_idldesc_dwReserved, elemdescFunc_idldesc_wIDLFlags, wFuncFlags;
-} FUNCDESC2_FID_CACHE;
-
-FUNCDESC2_FID_CACHE FUNCDESC2Fc;
-
-void cacheFUNCDESC2Fids(JNIEnv *env, jobject lpObject)
-{
- if (FUNCDESC2Fc.cached) return;
- FUNCDESC2Fc.clazz = (*env)->GetObjectClass(env, lpObject);
- FUNCDESC2Fc.memid = (*env)->GetFieldID(env, FUNCDESC2Fc.clazz, "memid", "I");
- FUNCDESC2Fc.lprgscode = (*env)->GetFieldID(env, FUNCDESC2Fc.clazz, "lprgscode", "I");
- FUNCDESC2Fc.lprgelemdescParam = (*env)->GetFieldID(env, FUNCDESC2Fc.clazz, "lprgelemdescParam", "I");
- FUNCDESC2Fc.funckind = (*env)->GetFieldID(env, FUNCDESC2Fc.clazz, "funckind", "I");
- FUNCDESC2Fc.invkind = (*env)->GetFieldID(env, FUNCDESC2Fc.clazz, "invkind", "I");
- FUNCDESC2Fc.callconv = (*env)->GetFieldID(env, FUNCDESC2Fc.clazz, "callconv", "I");
- FUNCDESC2Fc.cParams = (*env)->GetFieldID(env, FUNCDESC2Fc.clazz, "cParams", "S");
- FUNCDESC2Fc.cParamsOpt = (*env)->GetFieldID(env, FUNCDESC2Fc.clazz, "cParamsOpt", "S");
- FUNCDESC2Fc.oVft = (*env)->GetFieldID(env, FUNCDESC2Fc.clazz, "oVft", "S");
- FUNCDESC2Fc.cScodes = (*env)->GetFieldID(env, FUNCDESC2Fc.clazz, "cScodes", "S");
- FUNCDESC2Fc.elemdescFunc_tdesc_union = (*env)->GetFieldID(env, FUNCDESC2Fc.clazz, "elemdescFunc_tdesc_union", "I");
- FUNCDESC2Fc.elemdescFunc_tdesc_vt = (*env)->GetFieldID(env, FUNCDESC2Fc.clazz, "elemdescFunc_tdesc_vt", "S");
- FUNCDESC2Fc.elemdescFunc_idldesc_dwReserved = (*env)->GetFieldID(env, FUNCDESC2Fc.clazz, "elemdescFunc_idldesc_dwReserved", "I");
- FUNCDESC2Fc.elemdescFunc_idldesc_wIDLFlags = (*env)->GetFieldID(env, FUNCDESC2Fc.clazz, "elemdescFunc_idldesc_wIDLFlags", "S");
- FUNCDESC2Fc.wFuncFlags = (*env)->GetFieldID(env, FUNCDESC2Fc.clazz, "wFuncFlags", "S");
- FUNCDESC2Fc.cached = 1;
-}
-
-FUNCDESC *getFUNCDESC2Fields(JNIEnv *env, jobject lpObject, FUNCDESC *lpStruct)
-{
- if (!FUNCDESC2Fc.cached) cacheFUNCDESC2Fids(env, lpObject);
- lpStruct->memid = (*env)->GetIntField(env, lpObject, FUNCDESC2Fc.memid);
- lpStruct->lprgscode = (SCODE FAR *)(*env)->GetIntField(env, lpObject, FUNCDESC2Fc.lprgscode);
- lpStruct->lprgelemdescParam = (ELEMDESC FAR *)(*env)->GetIntField(env, lpObject, FUNCDESC2Fc.lprgelemdescParam);
- lpStruct->funckind = (*env)->GetIntField(env, lpObject, FUNCDESC2Fc.funckind);
- lpStruct->invkind = (*env)->GetIntField(env, lpObject, FUNCDESC2Fc.invkind);
- lpStruct->callconv = (*env)->GetIntField(env, lpObject, FUNCDESC2Fc.callconv);
- lpStruct->cParams = (*env)->GetShortField(env, lpObject, FUNCDESC2Fc.cParams);
- lpStruct->cParamsOpt = (*env)->GetShortField(env, lpObject, FUNCDESC2Fc.cParamsOpt);
- lpStruct->oVft = (*env)->GetShortField(env, lpObject, FUNCDESC2Fc.oVft);
- lpStruct->cScodes = (*env)->GetShortField(env, lpObject, FUNCDESC2Fc.cScodes);
- lpStruct->elemdescFunc.tdesc.lptdesc = (struct FARSTRUCT tagTYPEDESC FAR* )(*env)->GetIntField(env, lpObject, FUNCDESC2Fc.elemdescFunc_tdesc_union);
- lpStruct->elemdescFunc.tdesc.vt = (*env)->GetShortField(env, lpObject, FUNCDESC2Fc.elemdescFunc_tdesc_vt);
- lpStruct->elemdescFunc.idldesc.dwReserved = (*env)->GetIntField(env, lpObject, FUNCDESC2Fc.elemdescFunc_idldesc_dwReserved);
- lpStruct->elemdescFunc.idldesc.wIDLFlags = (*env)->GetShortField(env, lpObject, FUNCDESC2Fc.elemdescFunc_idldesc_wIDLFlags);
- lpStruct->wFuncFlags = (*env)->GetShortField(env, lpObject, FUNCDESC2Fc.wFuncFlags);
- return lpStruct;
-}
-
-void setFUNCDESC2Fields(JNIEnv *env, jobject lpObject, FUNCDESC *lpStruct)
-{
- if (!FUNCDESC2Fc.cached) cacheFUNCDESC2Fids(env, lpObject);
- (*env)->SetIntField(env, lpObject, FUNCDESC2Fc.memid, (jint)lpStruct->memid);
- (*env)->SetIntField(env, lpObject, FUNCDESC2Fc.lprgscode, (jint)lpStruct->lprgscode);
- (*env)->SetIntField(env, lpObject, FUNCDESC2Fc.lprgelemdescParam, (jint)lpStruct->lprgelemdescParam);
- (*env)->SetIntField(env, lpObject, FUNCDESC2Fc.funckind, (jint)lpStruct->funckind);
- (*env)->SetIntField(env, lpObject, FUNCDESC2Fc.invkind, (jint)lpStruct->invkind);
- (*env)->SetIntField(env, lpObject, FUNCDESC2Fc.callconv, (jint)lpStruct->callconv);
- (*env)->SetShortField(env, lpObject, FUNCDESC2Fc.cParams, (jshort)lpStruct->cParams);
- (*env)->SetShortField(env, lpObject, FUNCDESC2Fc.cParamsOpt, (jshort)lpStruct->cParamsOpt);
- (*env)->SetShortField(env, lpObject, FUNCDESC2Fc.oVft, (jshort)lpStruct->oVft);
- (*env)->SetShortField(env, lpObject, FUNCDESC2Fc.cScodes, (jshort)lpStruct->cScodes);
- (*env)->SetIntField(env, lpObject, FUNCDESC2Fc.elemdescFunc_tdesc_union, (jint)lpStruct->elemdescFunc.tdesc.lptdesc);
- (*env)->SetShortField(env, lpObject, FUNCDESC2Fc.elemdescFunc_tdesc_vt, (jshort)lpStruct->elemdescFunc.tdesc.vt);
- (*env)->SetIntField(env, lpObject, FUNCDESC2Fc.elemdescFunc_idldesc_dwReserved, (jint)lpStruct->elemdescFunc.idldesc.dwReserved);
- (*env)->SetShortField(env, lpObject, FUNCDESC2Fc.elemdescFunc_idldesc_wIDLFlags, (jshort)lpStruct->elemdescFunc.idldesc.wIDLFlags);
- (*env)->SetShortField(env, lpObject, FUNCDESC2Fc.wFuncFlags, (jshort)lpStruct->wFuncFlags);
-}
-#endif /* NO_FUNCDESC2 */
-
-#ifndef NO_GUID
-typedef struct GUID_FID_CACHE {
- int cached;
- jclass clazz;
- jfieldID data1, data2, data3, b0, b1, b2, b3, b4, b5, b6, b7;
-} GUID_FID_CACHE;
-
-GUID_FID_CACHE GUIDFc;
-
-void cacheGUIDFids(JNIEnv *env, jobject lpObject)
-{
- if (GUIDFc.cached) return;
- GUIDFc.clazz = (*env)->GetObjectClass(env, lpObject);
- GUIDFc.data1 = (*env)->GetFieldID(env, GUIDFc.clazz, "data1", "I");
- GUIDFc.data2 = (*env)->GetFieldID(env, GUIDFc.clazz, "data2", "S");
- GUIDFc.data3 = (*env)->GetFieldID(env, GUIDFc.clazz, "data3", "S");
- GUIDFc.b0 = (*env)->GetFieldID(env, GUIDFc.clazz, "b0", "B");
- GUIDFc.b1 = (*env)->GetFieldID(env, GUIDFc.clazz, "b1", "B");
- GUIDFc.b2 = (*env)->GetFieldID(env, GUIDFc.clazz, "b2", "B");
- GUIDFc.b3 = (*env)->GetFieldID(env, GUIDFc.clazz, "b3", "B");
- GUIDFc.b4 = (*env)->GetFieldID(env, GUIDFc.clazz, "b4", "B");
- GUIDFc.b5 = (*env)->GetFieldID(env, GUIDFc.clazz, "b5", "B");
- GUIDFc.b6 = (*env)->GetFieldID(env, GUIDFc.clazz, "b6", "B");
- GUIDFc.b7 = (*env)->GetFieldID(env, GUIDFc.clazz, "b7", "B");
- GUIDFc.cached = 1;
-}
-
-GUID *getGUIDFields(JNIEnv *env, jobject lpObject, GUID *lpStruct)
-{
- if (!GUIDFc.cached) cacheGUIDFids(env, lpObject);
- lpStruct->Data4[7] = (*env)->GetByteField(env, lpObject, GUIDFc.b7);
- lpStruct->Data4[6] = (*env)->GetByteField(env, lpObject, GUIDFc.b6);
- lpStruct->Data4[5] = (*env)->GetByteField(env, lpObject, GUIDFc.b5);
- lpStruct->Data4[4] = (*env)->GetByteField(env, lpObject, GUIDFc.b4);
- lpStruct->Data4[3] = (*env)->GetByteField(env, lpObject, GUIDFc.b3);
- lpStruct->Data4[2] = (*env)->GetByteField(env, lpObject, GUIDFc.b2);
- lpStruct->Data4[1] = (*env)->GetByteField(env, lpObject, GUIDFc.b1);
- lpStruct->Data4[0] = (*env)->GetByteField(env, lpObject, GUIDFc.b0);
- lpStruct->Data3 = (*env)->GetShortField(env, lpObject, GUIDFc.data3);
- lpStruct->Data2 = (*env)->GetShortField(env, lpObject, GUIDFc.data2);
- lpStruct->Data1 = (*env)->GetIntField(env, lpObject, GUIDFc.data1);
- return lpStruct;
-}
-
-void setGUIDFields(JNIEnv *env, jobject lpObject, GUID *lpStruct)
-{
- if (!GUIDFc.cached) cacheGUIDFids(env, lpObject);
- (*env)->SetByteField(env, lpObject, GUIDFc.b7, lpStruct->Data4[7]);
- (*env)->SetByteField(env, lpObject, GUIDFc.b6, lpStruct->Data4[6]);
- (*env)->SetByteField(env, lpObject, GUIDFc.b5, lpStruct->Data4[5]);
- (*env)->SetByteField(env, lpObject, GUIDFc.b4, lpStruct->Data4[4]);
- (*env)->SetByteField(env, lpObject, GUIDFc.b3, lpStruct->Data4[3]);
- (*env)->SetByteField(env, lpObject, GUIDFc.b2, lpStruct->Data4[2]);
- (*env)->SetByteField(env, lpObject, GUIDFc.b1, lpStruct->Data4[1]);
- (*env)->SetByteField(env, lpObject, GUIDFc.b0, lpStruct->Data4[0]);
- (*env)->SetShortField(env, lpObject, GUIDFc.data3, lpStruct->Data3);
- (*env)->SetShortField(env, lpObject, GUIDFc.data2, lpStruct->Data2);
- (*env)->SetIntField(env, lpObject, GUIDFc.data1, lpStruct->Data1);
-}
-
-#endif /* NO_GUID */
-
-#ifndef NO_LICINFO
-typedef struct LICINFO_FID_CACHE {
- int cached;
- jclass clazz;
- jfieldID cbLicInfo, fRuntimeKeyAvail, fLicVerified;
-} LICINFO_FID_CACHE;
-
-LICINFO_FID_CACHE LICINFOFc;
-
-void cacheLICINFOFids(JNIEnv *env, jobject lpObject)
-{
- if (LICINFOFc.cached) return;
- LICINFOFc.clazz = (*env)->GetObjectClass(env, lpObject);
- LICINFOFc.cbLicInfo = (*env)->GetFieldID(env, LICINFOFc.clazz, "cbLicInfo", "I");
- LICINFOFc.fRuntimeKeyAvail = (*env)->GetFieldID(env, LICINFOFc.clazz, "fRuntimeKeyAvail", "I");
- LICINFOFc.fLicVerified = (*env)->GetFieldID(env, LICINFOFc.clazz, "fLicVerified", "I");
- LICINFOFc.cached = 1;
-}
-
-LICINFO *getLICINFOFields(JNIEnv *env, jobject lpObject, LICINFO *lpStruct)
-{
- if (!LICINFOFc.cached) cacheLICINFOFids(env, lpObject);
- lpStruct->cbLicInfo = (*env)->GetIntField(env, lpObject, LICINFOFc.cbLicInfo);
- lpStruct->fRuntimeKeyAvail = (*env)->GetIntField(env, lpObject, LICINFOFc.fRuntimeKeyAvail);
- lpStruct->fLicVerified = (*env)->GetIntField(env, lpObject, LICINFOFc.fLicVerified);
- return lpStruct;
-}
-
-void setLICINFOFields(JNIEnv *env, jobject lpObject, LICINFO *lpStruct)
-{
- if (!LICINFOFc.cached) cacheLICINFOFids(env, lpObject);
- (*env)->SetIntField(env, lpObject, LICINFOFc.cbLicInfo, (jint)lpStruct->cbLicInfo);
- (*env)->SetIntField(env, lpObject, LICINFOFc.fRuntimeKeyAvail, (jint)lpStruct->fRuntimeKeyAvail);
- (*env)->SetIntField(env, lpObject, LICINFOFc.fLicVerified, (jint)lpStruct->fLicVerified);
-}
-#endif /* NO_LICINFO */
-
-#ifndef NO_OLECMD
-typedef struct OLECMD_FID_CACHE {
- int cached;
- jclass clazz;
- jfieldID cmdID, cmdf;
-} OLECMD_FID_CACHE;
-
-OLECMD_FID_CACHE OLECMDFc;
-
-void cacheOLECMDFids(JNIEnv *env, jobject lpObject)
-{
- if (OLECMDFc.cached) return;
- OLECMDFc.clazz = (*env)->GetObjectClass(env, lpObject);
- OLECMDFc.cmdID = (*env)->GetFieldID(env, OLECMDFc.clazz, "cmdID", "I");
- OLECMDFc.cmdf = (*env)->GetFieldID(env, OLECMDFc.clazz, "cmdf", "I");
- OLECMDFc.cached = 1;
-}
-
-OLECMD *getOLECMDFields(JNIEnv *env, jobject lpObject, OLECMD *lpStruct)
-{
- if (!OLECMDFc.cached) cacheOLECMDFids(env, lpObject);
- lpStruct->cmdID = (*env)->GetIntField(env, lpObject, OLECMDFc.cmdID);
- lpStruct->cmdf = (*env)->GetIntField(env, lpObject, OLECMDFc.cmdf);
- return lpStruct;
-}
-
-void setOLECMDFields(JNIEnv *env, jobject lpObject, OLECMD *lpStruct)
-{
- if (!OLECMDFc.cached) cacheOLECMDFids(env, lpObject);
- (*env)->SetIntField(env, lpObject, OLECMDFc.cmdID, (jint)lpStruct->cmdID);
- (*env)->SetIntField(env, lpObject, OLECMDFc.cmdf, (jint)lpStruct->cmdf);
-}
-#endif /* NO_OLECMD */
-
-#ifndef NO_OLECMDTEXT
-typedef struct OLECMDTEXT_FID_CACHE {
- int cached;
- jclass clazz;
- jfieldID cmdtextf, cwActual, cwBuf, rgwz;
-} OLECMDTEXT_FID_CACHE;
-
-OLECMDTEXT_FID_CACHE OLECMDTEXTFc;
-
-void cacheOLECMDTEXTFids(JNIEnv *env, jobject lpObject)
-{
- if (OLECMDTEXTFc.cached) return;
- OLECMDTEXTFc.clazz = (*env)->GetObjectClass(env, lpObject);
- OLECMDTEXTFc.cmdtextf = (*env)->GetFieldID(env, OLECMDTEXTFc.clazz, "cmdtextf", "I");
- OLECMDTEXTFc.cwActual = (*env)->GetFieldID(env, OLECMDTEXTFc.clazz, "cwActual", "I");
- OLECMDTEXTFc.cwBuf = (*env)->GetFieldID(env, OLECMDTEXTFc.clazz, "cwBuf", "I");
- OLECMDTEXTFc.rgwz = (*env)->GetFieldID(env, OLECMDTEXTFc.clazz, "rgwz", "S");
- OLECMDTEXTFc.cached = 1;
-}
-
-OLECMDTEXT *getOLECMDTEXTFields(JNIEnv *env, jobject lpObject, OLECMDTEXT *lpStruct)
-{
- if (!OLECMDTEXTFc.cached) cacheOLECMDTEXTFids(env, lpObject);
- lpStruct->cmdtextf = (*env)->GetIntField(env, lpObject, OLECMDTEXTFc.cmdtextf);
- lpStruct->cwActual = (*env)->GetIntField(env, lpObject, OLECMDTEXTFc.cwActual);
- lpStruct->cwBuf = (*env)->GetIntField(env, lpObject, OLECMDTEXTFc.cwBuf);
- lpStruct->rgwz[0] = (*env)->GetShortField(env, lpObject, OLECMDTEXTFc.rgwz); /* SPECIAL */
- return lpStruct;
-}
-
-void setOLECMDTEXTFields(JNIEnv *env, jobject lpObject, OLECMDTEXT *lpStruct)
-{
- if (!OLECMDTEXTFc.cached) cacheOLECMDTEXTFids(env, lpObject);
- (*env)->SetIntField(env, lpObject, OLECMDTEXTFc.cmdtextf, (jint)lpStruct->cmdtextf);
- (*env)->SetIntField(env, lpObject, OLECMDTEXTFc.cwActual, (jint)lpStruct->cwActual);
- (*env)->SetIntField(env, lpObject, OLECMDTEXTFc.cwBuf, (jint)lpStruct->cwBuf);
- (*env)->SetShortField(env, lpObject, OLECMDTEXTFc.rgwz, (jshort)lpStruct->rgwz[0]); /* SPECIAL */
-}
-#endif /* NO_OLECMDTEXT */
-
-#ifndef NO_OLEINPLACEFRAMEINFO
-typedef struct OLEINPLACEFRAMEINFO_FID_CACHE {
- int cached;
- jclass clazz;
- jfieldID cb, fMDIApp, hwndFrame, haccel, cAccelEntries;
-} OLEINPLACEFRAMEINFO_FID_CACHE;
-
-OLEINPLACEFRAMEINFO_FID_CACHE OLEINPLACEFRAMEINFOFc;
-
-void cacheOLEINPLACEFRAMEINFOFids(JNIEnv *env, jobject lpObject)
-{
- if (OLEINPLACEFRAMEINFOFc.cached) return;
- OLEINPLACEFRAMEINFOFc.clazz = (*env)->GetObjectClass(env, lpObject);
- OLEINPLACEFRAMEINFOFc.cb = (*env)->GetFieldID(env, OLEINPLACEFRAMEINFOFc.clazz, "cb", "I");
- OLEINPLACEFRAMEINFOFc.fMDIApp = (*env)->GetFieldID(env, OLEINPLACEFRAMEINFOFc.clazz, "fMDIApp", "I");
- OLEINPLACEFRAMEINFOFc.hwndFrame = (*env)->GetFieldID(env, OLEINPLACEFRAMEINFOFc.clazz, "hwndFrame", "I");
- OLEINPLACEFRAMEINFOFc.haccel = (*env)->GetFieldID(env, OLEINPLACEFRAMEINFOFc.clazz, "haccel", "I");
- OLEINPLACEFRAMEINFOFc.cAccelEntries = (*env)->GetFieldID(env, OLEINPLACEFRAMEINFOFc.clazz, "cAccelEntries", "I");
- OLEINPLACEFRAMEINFOFc.cached = 1;
-}
-
-OLEINPLACEFRAMEINFO *getOLEINPLACEFRAMEINFOFields(JNIEnv *env, jobject lpObject, OLEINPLACEFRAMEINFO *lpStruct)
-{
- if (!OLEINPLACEFRAMEINFOFc.cached) cacheOLEINPLACEFRAMEINFOFids(env, lpObject);
- lpStruct->cb = (*env)->GetIntField(env, lpObject, OLEINPLACEFRAMEINFOFc.cb);
- lpStruct->fMDIApp = (*env)->GetIntField(env, lpObject, OLEINPLACEFRAMEINFOFc.fMDIApp);
- lpStruct->hwndFrame = (HWND)(*env)->GetIntField(env, lpObject, OLEINPLACEFRAMEINFOFc.hwndFrame);
- lpStruct->haccel = (HACCEL)(*env)->GetIntField(env, lpObject, OLEINPLACEFRAMEINFOFc.haccel);
- lpStruct->cAccelEntries = (*env)->GetIntField(env, lpObject, OLEINPLACEFRAMEINFOFc.cAccelEntries);
- return lpStruct;
-}
-
-void setOLEINPLACEFRAMEINFOFields(JNIEnv *env, jobject lpObject, OLEINPLACEFRAMEINFO *lpStruct)
-{
- if (!OLEINPLACEFRAMEINFOFc.cached) cacheOLEINPLACEFRAMEINFOFids(env, lpObject);
- (*env)->SetIntField(env, lpObject, OLEINPLACEFRAMEINFOFc.cb, (jint)lpStruct->cb);
- (*env)->SetIntField(env, lpObject, OLEINPLACEFRAMEINFOFc.fMDIApp, (jint)lpStruct->fMDIApp);
- (*env)->SetIntField(env, lpObject, OLEINPLACEFRAMEINFOFc.hwndFrame, (jint)lpStruct->hwndFrame);
- (*env)->SetIntField(env, lpObject, OLEINPLACEFRAMEINFOFc.haccel, (jint)lpStruct->haccel);
- (*env)->SetIntField(env, lpObject, OLEINPLACEFRAMEINFOFc.cAccelEntries, (jint)lpStruct->cAccelEntries);
-}
-#endif /* NO_OLEINPLACEFRAMEINFO */
-
-#ifndef NO_STATSTG
-typedef struct STATSTG_FID_CACHE {
- int cached;
- jclass clazz;
- 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;
-
-STATSTG_FID_CACHE STATSTGFc;
-
-void cacheSTATSTGFids(JNIEnv *env, jobject lpObject)
-{
- if (STATSTGFc.cached) return;
- STATSTGFc.clazz = (*env)->GetObjectClass(env, lpObject);
- STATSTGFc.pwcsName = (*env)->GetFieldID(env, STATSTGFc.clazz, "pwcsName", "I");
- STATSTGFc.type = (*env)->GetFieldID(env, STATSTGFc.clazz, "type", "I");
- STATSTGFc.cbSize = (*env)->GetFieldID(env, STATSTGFc.clazz, "cbSize", "J");
- STATSTGFc.mtime_dwLowDateTime = (*env)->GetFieldID(env, STATSTGFc.clazz, "mtime_dwLowDateTime", "I");
- STATSTGFc.mtime_dwHighDateTime = (*env)->GetFieldID(env, STATSTGFc.clazz, "mtime_dwHighDateTime", "I");
- STATSTGFc.ctime_dwLowDateTime = (*env)->GetFieldID(env, STATSTGFc.clazz, "ctime_dwLowDateTime", "I");
- STATSTGFc.ctime_dwHighDateTime = (*env)->GetFieldID(env, STATSTGFc.clazz, "ctime_dwHighDateTime", "I");
- STATSTGFc.atime_dwLowDateTime = (*env)->GetFieldID(env, STATSTGFc.clazz, "atime_dwLowDateTime", "I");
- STATSTGFc.atime_dwHighDateTime = (*env)->GetFieldID(env, STATSTGFc.clazz, "atime_dwHighDateTime", "I");
- STATSTGFc.grfMode = (*env)->GetFieldID(env, STATSTGFc.clazz, "grfMode", "I");
- STATSTGFc.grfLocksSupported = (*env)->GetFieldID(env, STATSTGFc.clazz, "grfLocksSupported", "I");
- STATSTGFc.clsid_data1 = (*env)->GetFieldID(env, STATSTGFc.clazz, "clsid_data1", "I");
- STATSTGFc.clsid_data2 = (*env)->GetFieldID(env, STATSTGFc.clazz, "clsid_data2", "S");
- STATSTGFc.clsid_data3 = (*env)->GetFieldID(env, STATSTGFc.clazz, "clsid_data3", "S");
- STATSTGFc.clsid_b0 = (*env)->GetFieldID(env, STATSTGFc.clazz, "clsid_b0", "B");
- STATSTGFc.clsid_b1 = (*env)->GetFieldID(env, STATSTGFc.clazz, "clsid_b1", "B");
- STATSTGFc.clsid_b2 = (*env)->GetFieldID(env, STATSTGFc.clazz, "clsid_b2", "B");
- STATSTGFc.clsid_b3 = (*env)->GetFieldID(env, STATSTGFc.clazz, "clsid_b3", "B");
- STATSTGFc.clsid_b4 = (*env)->GetFieldID(env, STATSTGFc.clazz, "clsid_b4", "B");
- STATSTGFc.clsid_b5 = (*env)->GetFieldID(env, STATSTGFc.clazz, "clsid_b5", "B");
- STATSTGFc.clsid_b6 = (*env)->GetFieldID(env, STATSTGFc.clazz, "clsid_b6", "B");
- STATSTGFc.clsid_b7 = (*env)->GetFieldID(env, STATSTGFc.clazz, "clsid_b7", "B");
- STATSTGFc.grfStateBits = (*env)->GetFieldID(env, STATSTGFc.clazz, "grfStateBits", "I");
- STATSTGFc.reserved = (*env)->GetFieldID(env, STATSTGFc.clazz, "reserved", "I");
- STATSTGFc.cached = 1;
-}
-
-STATSTG *getSTATSTGFields(JNIEnv *env, jobject lpObject, STATSTG *lpStruct)
-{
- if (!STATSTGFc.cached) cacheSTATSTGFids(env, lpObject);
- lpStruct->pwcsName = (LPWSTR)(*env)->GetIntField(env, lpObject, STATSTGFc.pwcsName);
- lpStruct->type = (*env)->GetIntField(env, lpObject, STATSTGFc.type);
- lpStruct->cbSize.QuadPart = (*env)->GetLongField(env, lpObject, STATSTGFc.cbSize);
- lpStruct->mtime.dwLowDateTime = (*env)->GetIntField(env, lpObject, STATSTGFc.mtime_dwLowDateTime);
- lpStruct->mtime.dwHighDateTime = (*env)->GetIntField(env, lpObject, STATSTGFc.mtime_dwHighDateTime);
- lpStruct->ctime.dwLowDateTime = (*env)->GetIntField(env, lpObject, STATSTGFc.ctime_dwLowDateTime);
- lpStruct->ctime.dwHighDateTime = (*env)->GetIntField(env, lpObject, STATSTGFc.ctime_dwHighDateTime);
- lpStruct->atime.dwLowDateTime = (*env)->GetIntField(env, lpObject, STATSTGFc.atime_dwLowDateTime);
- lpStruct->atime.dwHighDateTime = (*env)->GetIntField(env, lpObject, STATSTGFc.atime_dwHighDateTime);
- lpStruct->grfMode = (*env)->GetIntField(env, lpObject, STATSTGFc.grfMode);
- lpStruct->grfLocksSupported = (*env)->GetIntField(env, lpObject, STATSTGFc.grfLocksSupported);
- lpStruct->clsid.Data4[7] = (*env)->GetByteField(env, lpObject, STATSTGFc.clsid_b7);
- lpStruct->clsid.Data4[6] = (*env)->GetByteField(env, lpObject, STATSTGFc.clsid_b6);
- lpStruct->clsid.Data4[5] = (*env)->GetByteField(env, lpObject, STATSTGFc.clsid_b5);
- lpStruct->clsid.Data4[4] = (*env)->GetByteField(env, lpObject, STATSTGFc.clsid_b4);
- lpStruct->clsid.Data4[3] = (*env)->GetByteField(env, lpObject, STATSTGFc.clsid_b3);
- lpStruct->clsid.Data4[2] = (*env)->GetByteField(env, lpObject, STATSTGFc.clsid_b2);
- lpStruct->clsid.Data4[1] = (*env)->GetByteField(env, lpObject, STATSTGFc.clsid_b1);
- lpStruct->clsid.Data4[0] = (*env)->GetByteField(env, lpObject, STATSTGFc.clsid_b0);
- lpStruct->clsid.Data3 = (*env)->GetShortField(env, lpObject, STATSTGFc.clsid_data3);
- lpStruct->clsid.Data2 = (*env)->GetShortField(env, lpObject, STATSTGFc.clsid_data2);
- lpStruct->clsid.Data1 = (*env)->GetIntField(env, lpObject, STATSTGFc.clsid_data1);
- lpStruct->grfStateBits = (*env)->GetIntField(env, lpObject, STATSTGFc.grfStateBits);
- lpStruct->reserved = (*env)->GetIntField(env, lpObject, STATSTGFc.reserved);
- return lpStruct;
-}
-
-void setSTATSTGFields(JNIEnv *env, jobject lpObject, STATSTG *lpStruct)
-{
- if (!STATSTGFc.cached) cacheSTATSTGFids(env, lpObject);
- (*env)->SetIntField(env, lpObject, STATSTGFc.pwcsName, (jint)lpStruct->pwcsName);
- (*env)->SetIntField(env, lpObject, STATSTGFc.type, (jint)lpStruct->type);
- (*env)->SetLongField(env, lpObject, STATSTGFc.cbSize, (jlong)lpStruct->cbSize.QuadPart);
- (*env)->SetIntField(env, lpObject, STATSTGFc.mtime_dwLowDateTime, (jint)lpStruct->mtime.dwLowDateTime);
- (*env)->SetIntField(env, lpObject, STATSTGFc.mtime_dwHighDateTime, (jint)lpStruct->mtime.dwHighDateTime);
- (*env)->SetIntField(env, lpObject, STATSTGFc.ctime_dwLowDateTime, (jint)lpStruct->ctime.dwLowDateTime);
- (*env)->SetIntField(env, lpObject, STATSTGFc.ctime_dwHighDateTime, (jint)lpStruct->ctime.dwHighDateTime);
- (*env)->SetIntField(env, lpObject, STATSTGFc.atime_dwLowDateTime, (jint)lpStruct->atime.dwLowDateTime);
- (*env)->SetIntField(env, lpObject, STATSTGFc.atime_dwHighDateTime, (jint)lpStruct->atime.dwHighDateTime);
- (*env)->SetIntField(env, lpObject, STATSTGFc.grfMode, (jint)lpStruct->grfMode);
- (*env)->SetIntField(env, lpObject, STATSTGFc.grfLocksSupported, (jint)lpStruct->grfLocksSupported);
- (*env)->SetByteField(env, lpObject, STATSTGFc.clsid_b7, lpStruct->clsid.Data4[7]);
- (*env)->SetByteField(env, lpObject, STATSTGFc.clsid_b6, lpStruct->clsid.Data4[6]);
- (*env)->SetByteField(env, lpObject, STATSTGFc.clsid_b5, lpStruct->clsid.Data4[5]);
- (*env)->SetByteField(env, lpObject, STATSTGFc.clsid_b4, lpStruct->clsid.Data4[4]);
- (*env)->SetByteField(env, lpObject, STATSTGFc.clsid_b3, lpStruct->clsid.Data4[3]);
- (*env)->SetByteField(env, lpObject, STATSTGFc.clsid_b2, lpStruct->clsid.Data4[2]);
- (*env)->SetByteField(env, lpObject, STATSTGFc.clsid_b1, lpStruct->clsid.Data4[1]);
- (*env)->SetByteField(env, lpObject, STATSTGFc.clsid_b0, lpStruct->clsid.Data4[0]);
- (*env)->SetShortField(env, lpObject, STATSTGFc.clsid_data3, lpStruct->clsid.Data3);
- (*env)->SetShortField(env, lpObject, STATSTGFc.clsid_data2, lpStruct->clsid.Data2);
- (*env)->SetIntField(env, lpObject, STATSTGFc.clsid_data1, lpStruct->clsid.Data1);
- (*env)->SetIntField(env, lpObject, STATSTGFc.grfStateBits, (jint)lpStruct->grfStateBits);
- (*env)->SetIntField(env, lpObject, STATSTGFc.reserved, (jint)lpStruct->reserved);
-}
-#endif /* NO_STATSTG */
-
-#ifndef NO_STGMEDIUM
-typedef struct STGMEDIUM_FID_CACHE {
- int cached;
- jclass clazz;
- jfieldID tymed, unionField, pUnkForRelease;
-} STGMEDIUM_FID_CACHE;
-
-STGMEDIUM_FID_CACHE STGMEDIUMFc;
-
-void cacheSTGMEDIUMFids(JNIEnv *env, jobject lpObject)
-{
- if (STGMEDIUMFc.cached) return;
- STGMEDIUMFc.clazz = (*env)->GetObjectClass(env, lpObject);
- STGMEDIUMFc.tymed = (*env)->GetFieldID(env, STGMEDIUMFc.clazz, "tymed", "I");
- STGMEDIUMFc.unionField = (*env)->GetFieldID(env, STGMEDIUMFc.clazz, "unionField", "I");
- STGMEDIUMFc.pUnkForRelease = (*env)->GetFieldID(env, STGMEDIUMFc.clazz, "pUnkForRelease", "I");
- STGMEDIUMFc.cached = 1;
-}
-
-STGMEDIUM *getSTGMEDIUMFields(JNIEnv *env, jobject lpObject, STGMEDIUM *lpStruct)
-{
- if (!STGMEDIUMFc.cached) cacheSTGMEDIUMFids(env, lpObject);
- lpStruct->tymed = (*env)->GetIntField(env, lpObject, STGMEDIUMFc.tymed);
- lpStruct->hGlobal = (HGLOBAL)(*env)->GetIntField(env, lpObject, STGMEDIUMFc.unionField);
- lpStruct->pUnkForRelease = (IUnknown *)(*env)->GetIntField(env, lpObject, STGMEDIUMFc.pUnkForRelease);
- return lpStruct;
-}
-
-void setSTGMEDIUMFields(JNIEnv *env, jobject lpObject, STGMEDIUM *lpStruct)
-{
- if (!STGMEDIUMFc.cached) cacheSTGMEDIUMFids(env, lpObject);
- (*env)->SetIntField(env, lpObject, STGMEDIUMFc.tymed, (jint)lpStruct->tymed);
- (*env)->SetIntField(env, lpObject, STGMEDIUMFc.unionField, (jint)lpStruct->hGlobal);
- (*env)->SetIntField(env, lpObject, STGMEDIUMFc.pUnkForRelease, (jint)lpStruct->pUnkForRelease);
-}
-#endif /* NO_STGMEDIUM */
-
-#ifndef NO_TYPEATTR
-typedef struct TYPEATTR_FID_CACHE {
- int cached;
- jclass clazz;
- 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;
-
-TYPEATTR_FID_CACHE TYPEATTRFc;
-
-void cacheTYPEATTRFids(JNIEnv *env, jobject lpObject)
-{
- if (TYPEATTRFc.cached) return;
- TYPEATTRFc.clazz = (*env)->GetObjectClass(env, lpObject);
- TYPEATTRFc.guid_data1 = (*env)->GetFieldID(env, TYPEATTRFc.clazz, "guid_data1", "I");
- TYPEATTRFc.guid_data2 = (*env)->GetFieldID(env, TYPEATTRFc.clazz, "guid_data2", "S");
- TYPEATTRFc.guid_data3 = (*env)->GetFieldID(env, TYPEATTRFc.clazz, "guid_data3", "S");
- TYPEATTRFc.guid_b0 = (*env)->GetFieldID(env, TYPEATTRFc.clazz, "guid_b0", "B");
- TYPEATTRFc.guid_b1 = (*env)->GetFieldID(env, TYPEATTRFc.clazz, "guid_b1", "B");
- TYPEATTRFc.guid_b2 = (*env)->GetFieldID(env, TYPEATTRFc.clazz, "guid_b2", "B");
- TYPEATTRFc.guid_b3 = (*env)->GetFieldID(env, TYPEATTRFc.clazz, "guid_b3", "B");
- TYPEATTRFc.guid_b4 = (*env)->GetFieldID(env, TYPEATTRFc.clazz, "guid_b4", "B");
- TYPEATTRFc.guid_b5 = (*env)->GetFieldID(env, TYPEATTRFc.clazz, "guid_b5", "B");
- TYPEATTRFc.guid_b6 = (*env)->GetFieldID(env, TYPEATTRFc.clazz, "guid_b6", "B");
- TYPEATTRFc.guid_b7 = (*env)->GetFieldID(env, TYPEATTRFc.clazz, "guid_b7", "B");
- TYPEATTRFc.lcid = (*env)->GetFieldID(env, TYPEATTRFc.clazz, "lcid", "I");
- TYPEATTRFc.dwReserved = (*env)->GetFieldID(env, TYPEATTRFc.clazz, "dwReserved", "I");
- TYPEATTRFc.memidConstructor = (*env)->GetFieldID(env, TYPEATTRFc.clazz, "memidConstructor", "I");
- TYPEATTRFc.memidDestructor = (*env)->GetFieldID(env, TYPEATTRFc.clazz, "memidDestructor", "I");
- TYPEATTRFc.lpstrSchema = (*env)->GetFieldID(env, TYPEATTRFc.clazz, "lpstrSchema", "I");
- TYPEATTRFc.cbSizeInstance = (*env)->GetFieldID(env, TYPEATTRFc.clazz, "cbSizeInstance", "I");
- TYPEATTRFc.typekind = (*env)->GetFieldID(env, TYPEATTRFc.clazz, "typekind", "I");
- TYPEATTRFc.cFuncs = (*env)->GetFieldID(env, TYPEATTRFc.clazz, "cFuncs", "S");
- TYPEATTRFc.cVars = (*env)->GetFieldID(env, TYPEATTRFc.clazz, "cVars", "S");
- TYPEATTRFc.cImplTypes = (*env)->GetFieldID(env, TYPEATTRFc.clazz, "cImplTypes", "S");
- TYPEATTRFc.cbSizeVft = (*env)->GetFieldID(env, TYPEATTRFc.clazz, "cbSizeVft", "S");
- TYPEATTRFc.cbAlignment = (*env)->GetFieldID(env, TYPEATTRFc.clazz, "cbAlignment", "S");
- TYPEATTRFc.wTypeFlags = (*env)->GetFieldID(env, TYPEATTRFc.clazz, "wTypeFlags", "S");
- TYPEATTRFc.wMajorVerNum = (*env)->GetFieldID(env, TYPEATTRFc.clazz, "wMajorVerNum", "S");
- TYPEATTRFc.wMinorVerNum = (*env)->GetFieldID(env, TYPEATTRFc.clazz, "wMinorVerNum", "S");
- TYPEATTRFc.tdescAlias_unionField = (*env)->GetFieldID(env, TYPEATTRFc.clazz, "tdescAlias_unionField", "I");
- TYPEATTRFc.tdescAlias_vt = (*env)->GetFieldID(env, TYPEATTRFc.clazz, "tdescAlias_vt", "S");
- TYPEATTRFc.idldescType_dwReserved = (*env)->GetFieldID(env, TYPEATTRFc.clazz, "idldescType_dwReserved", "I");
- TYPEATTRFc.idldescType_wIDLFlags = (*env)->GetFieldID(env, TYPEATTRFc.clazz, "idldescType_wIDLFlags", "S");
- TYPEATTRFc.cached = 1;
-}
-
-TYPEATTR *getTYPEATTRFields(JNIEnv *env, jobject lpObject, TYPEATTR *lpStruct)
-{
- if (!TYPEATTRFc.cached) cacheTYPEATTRFids(env, lpObject);
- lpStruct->idldescType.wIDLFlags = (*env)->GetShortField(env, lpObject, TYPEATTRFc.idldescType_wIDLFlags);
- lpStruct->idldescType.dwReserved = (*env)->GetIntField(env, lpObject, TYPEATTRFc.idldescType_dwReserved);
- lpStruct->tdescAlias.vt = (*env)->GetShortField(env, lpObject, TYPEATTRFc.tdescAlias_vt);
- lpStruct->tdescAlias.lptdesc = (struct FARSTRUCT tagTYPEDESC FAR *)(*env)->GetIntField(env, lpObject, TYPEATTRFc.tdescAlias_unionField);
- lpStruct->wMinorVerNum = (*env)->GetShortField(env, lpObject, TYPEATTRFc.wMinorVerNum);
- lpStruct->wMajorVerNum = (*env)->GetShortField(env, lpObject, TYPEATTRFc.wMajorVerNum);
- lpStruct->wTypeFlags = (*env)->GetShortField(env, lpObject, TYPEATTRFc.wTypeFlags);
- lpStruct->cbAlignment = (*env)->GetShortField(env, lpObject, TYPEATTRFc.cbAlignment);
- lpStruct->cbSizeVft = (*env)->GetShortField(env, lpObject, TYPEATTRFc.cbSizeVft);
- lpStruct->cImplTypes = (*env)->GetShortField(env, lpObject, TYPEATTRFc.cImplTypes);
- lpStruct->cVars = (*env)->GetShortField(env, lpObject, TYPEATTRFc.cVars);
- lpStruct->cFuncs = (*env)->GetShortField(env, lpObject, TYPEATTRFc.cFuncs);
- lpStruct->typekind = (*env)->GetIntField(env, lpObject, TYPEATTRFc.typekind);
- lpStruct->cbSizeInstance = (*env)->GetIntField(env, lpObject, TYPEATTRFc.cbSizeInstance);
- lpStruct->lpstrSchema = (OLECHAR FAR *)(*env)->GetIntField(env, lpObject, TYPEATTRFc.lpstrSchema);
- lpStruct->memidDestructor = (*env)->GetIntField(env, lpObject, TYPEATTRFc.memidDestructor);
- lpStruct->memidConstructor = (*env)->GetIntField(env, lpObject, TYPEATTRFc.memidConstructor);
- lpStruct->dwReserved = (*env)->GetIntField(env, lpObject, TYPEATTRFc.dwReserved);
- lpStruct->lcid = (*env)->GetIntField(env, lpObject, TYPEATTRFc.lcid);
- lpStruct->guid.Data4[7] = (*env)->GetByteField(env, lpObject, TYPEATTRFc.guid_b7);
- lpStruct->guid.Data4[6] = (*env)->GetByteField(env, lpObject, TYPEATTRFc.guid_b6);
- lpStruct->guid.Data4[5] = (*env)->GetByteField(env, lpObject, TYPEATTRFc.guid_b5);
- lpStruct->guid.Data4[4] = (*env)->GetByteField(env, lpObject, TYPEATTRFc.guid_b4);
- lpStruct->guid.Data4[3] = (*env)->GetByteField(env, lpObject, TYPEATTRFc.guid_b3);
- lpStruct->guid.Data4[2] = (*env)->GetByteField(env, lpObject, TYPEATTRFc.guid_b2);
- lpStruct->guid.Data4[1] = (*env)->GetByteField(env, lpObject, TYPEATTRFc.guid_b1);
- lpStruct->guid.Data4[0] = (*env)->GetByteField(env, lpObject, TYPEATTRFc.guid_b0);
- lpStruct->guid.Data3 = (*env)->GetShortField(env, lpObject, TYPEATTRFc.guid_data3);
- lpStruct->guid.Data2 = (*env)->GetShortField(env, lpObject, TYPEATTRFc.guid_data2);
- lpStruct->guid.Data1 = (*env)->GetIntField(env, lpObject, TYPEATTRFc.guid_data1);
- return lpStruct;
-}
-
-void setTYPEATTRFields(JNIEnv *env, jobject lpObject, TYPEATTR *lpStruct)
-{
- if (!TYPEATTRFc.cached) cacheTYPEATTRFids(env, lpObject);
- (*env)->SetShortField(env, lpObject, TYPEATTRFc.idldescType_wIDLFlags, lpStruct->idldescType.wIDLFlags);
- (*env)->SetIntField(env, lpObject, TYPEATTRFc.idldescType_dwReserved, lpStruct->idldescType.dwReserved);
- (*env)->SetShortField(env, lpObject, TYPEATTRFc.tdescAlias_vt, lpStruct->tdescAlias.vt);
- (*env)->SetIntField(env, lpObject, TYPEATTRFc.tdescAlias_unionField, (jint)lpStruct->tdescAlias.lptdesc);
- (*env)->SetShortField(env, lpObject, TYPEATTRFc.wMinorVerNum, lpStruct->wMinorVerNum);
- (*env)->SetShortField(env, lpObject, TYPEATTRFc.wMajorVerNum, lpStruct->wMajorVerNum);
- (*env)->SetShortField(env, lpObject, TYPEATTRFc.wTypeFlags, lpStruct->wTypeFlags);
- (*env)->SetShortField(env, lpObject, TYPEATTRFc.cbAlignment, lpStruct->cbAlignment);
- (*env)->SetShortField(env, lpObject, TYPEATTRFc.cbSizeVft, lpStruct->cbSizeVft);
- (*env)->SetShortField(env, lpObject, TYPEATTRFc.cImplTypes, lpStruct->cImplTypes);
- (*env)->SetShortField(env, lpObject, TYPEATTRFc.cVars, lpStruct->cVars);
- (*env)->SetShortField(env, lpObject, TYPEATTRFc.cFuncs, lpStruct->cFuncs);
- (*env)->SetIntField(env, lpObject, TYPEATTRFc.typekind, lpStruct->typekind);
- (*env)->SetIntField(env, lpObject, TYPEATTRFc.cbSizeInstance, lpStruct->cbSizeInstance);
- (*env)->SetIntField(env, lpObject, TYPEATTRFc.lpstrSchema, (jint)lpStruct->lpstrSchema);
- (*env)->SetIntField(env, lpObject, TYPEATTRFc.memidDestructor, lpStruct->memidDestructor);
- (*env)->SetIntField(env, lpObject, TYPEATTRFc.memidConstructor, lpStruct->memidConstructor);
- (*env)->SetIntField(env, lpObject, TYPEATTRFc.dwReserved, lpStruct->dwReserved);
- (*env)->SetIntField(env, lpObject, TYPEATTRFc.lcid, lpStruct->lcid);
- (*env)->SetByteField(env, lpObject, TYPEATTRFc.guid_b7, lpStruct->guid.Data4[7]);
- (*env)->SetByteField(env, lpObject, TYPEATTRFc.guid_b6, lpStruct->guid.Data4[6]);
- (*env)->SetByteField(env, lpObject, TYPEATTRFc.guid_b5, lpStruct->guid.Data4[5]);
- (*env)->SetByteField(env, lpObject, TYPEATTRFc.guid_b4, lpStruct->guid.Data4[4]);
- (*env)->SetByteField(env, lpObject, TYPEATTRFc.guid_b3, lpStruct->guid.Data4[3]);
- (*env)->SetByteField(env, lpObject, TYPEATTRFc.guid_b2, lpStruct->guid.Data4[2]);
- (*env)->SetByteField(env, lpObject, TYPEATTRFc.guid_b1, lpStruct->guid.Data4[1]);
- (*env)->SetByteField(env, lpObject, TYPEATTRFc.guid_b0, lpStruct->guid.Data4[0]);
- (*env)->SetShortField(env, lpObject, TYPEATTRFc.guid_data3, lpStruct->guid.Data3);
- (*env)->SetShortField(env, lpObject, TYPEATTRFc.guid_data2, lpStruct->guid.Data2);
- (*env)->SetIntField(env, lpObject, TYPEATTRFc.guid_data1, lpStruct->guid.Data1);
-}
-#endif /* NO_TYPEATTR */
-
-#ifndef NO_VARDESC1
-typedef struct VARDESC1_FID_CACHE {
- int cached;
- jclass clazz;
- jfieldID memid, lpstrSchema, unionField, elemdescVar_tdesc_union, elemdescVar_tdesc_vt, elemdescVar_paramdesc_pparamdescex, elemdescVar_paramdesc_wParamFlags, wVarFlags, varkind;
-} VARDESC1_FID_CACHE;
-
-VARDESC1_FID_CACHE VARDESC1Fc;
-
-void cacheVARDESC1Fids(JNIEnv *env, jobject lpObject)
-{
- if (VARDESC1Fc.cached) return;
- VARDESC1Fc.clazz = (*env)->GetObjectClass(env, lpObject);
- VARDESC1Fc.memid = (*env)->GetFieldID(env, VARDESC1Fc.clazz, "memid", "I");
- VARDESC1Fc.lpstrSchema = (*env)->GetFieldID(env, VARDESC1Fc.clazz, "lpstrSchema", "I");
- VARDESC1Fc.unionField = (*env)->GetFieldID(env, VARDESC1Fc.clazz, "unionField", "I");
- VARDESC1Fc.elemdescVar_tdesc_union = (*env)->GetFieldID(env, VARDESC1Fc.clazz, "elemdescVar_tdesc_union", "I");
- VARDESC1Fc.elemdescVar_tdesc_vt = (*env)->GetFieldID(env, VARDESC1Fc.clazz, "elemdescVar_tdesc_vt", "S");
- VARDESC1Fc.elemdescVar_paramdesc_pparamdescex = (*env)->GetFieldID(env, VARDESC1Fc.clazz, "elemdescVar_paramdesc_pparamdescex", "I");
- VARDESC1Fc.elemdescVar_paramdesc_wParamFlags = (*env)->GetFieldID(env, VARDESC1Fc.clazz, "elemdescVar_paramdesc_wParamFlags", "S");
- VARDESC1Fc.wVarFlags = (*env)->GetFieldID(env, VARDESC1Fc.clazz, "wVarFlags", "S");
- VARDESC1Fc.varkind = (*env)->GetFieldID(env, VARDESC1Fc.clazz, "varkind", "I");
- VARDESC1Fc.cached = 1;
-}
-
-VARDESC *getVARDESC1Fields(JNIEnv *env, jobject lpObject, VARDESC *lpStruct)
-{
- if (!VARDESC1Fc.cached) cacheVARDESC1Fids(env, lpObject);
- lpStruct->varkind = (*env)->GetIntField(env, lpObject, VARDESC1Fc.varkind);
- lpStruct->wVarFlags = (*env)->GetShortField(env, lpObject, VARDESC1Fc.wVarFlags);
- lpStruct->elemdescVar.paramdesc.wParamFlags = (*env)->GetShortField(env, lpObject, VARDESC1Fc.elemdescVar_paramdesc_wParamFlags);
- lpStruct->elemdescVar.paramdesc.pparamdescex = (LPPARAMDESCEX)(*env)->GetIntField(env, lpObject, VARDESC1Fc.elemdescVar_paramdesc_pparamdescex);
- lpStruct->elemdescVar.tdesc.vt = (*env)->GetShortField(env, lpObject, VARDESC1Fc.elemdescVar_tdesc_vt);
- lpStruct->elemdescVar.tdesc.lptdesc = (struct FARSTRUCT tagTYPEDESC FAR *)(*env)->GetIntField(env, lpObject, VARDESC1Fc.elemdescVar_tdesc_union);
- lpStruct->oInst = (*env)->GetIntField(env, lpObject, VARDESC1Fc.unionField);
- lpStruct->lpstrSchema = (OLECHAR FAR *)(*env)->GetIntField(env, lpObject, VARDESC1Fc.lpstrSchema);
- lpStruct->memid = (*env)->GetIntField(env, lpObject, VARDESC1Fc.memid);
- return lpStruct;
-}
-
-void setVARDESC1Fields(JNIEnv *env, jobject lpObject, VARDESC *lpStruct)
-{
- if (!VARDESC1Fc.cached) cacheVARDESC1Fids(env, lpObject);
- (*env)->SetIntField(env, lpObject, VARDESC1Fc.varkind, lpStruct->varkind);
- (*env)->SetShortField(env, lpObject, VARDESC1Fc.wVarFlags, lpStruct->wVarFlags);
- (*env)->SetShortField(env, lpObject, VARDESC1Fc.elemdescVar_paramdesc_wParamFlags, lpStruct->elemdescVar.paramdesc.wParamFlags);
- (*env)->SetIntField(env, lpObject, VARDESC1Fc.elemdescVar_paramdesc_pparamdescex, (jint)lpStruct->elemdescVar.paramdesc.pparamdescex);
- (*env)->SetShortField(env, lpObject, VARDESC1Fc.elemdescVar_tdesc_vt, lpStruct->elemdescVar.tdesc.vt);
- (*env)->SetIntField(env, lpObject, VARDESC1Fc.elemdescVar_tdesc_union, (jint)lpStruct->elemdescVar.tdesc.lptdesc);
- (*env)->SetIntField(env, lpObject, VARDESC1Fc.unionField, lpStruct->oInst);
- (*env)->SetIntField(env, lpObject, VARDESC1Fc.lpstrSchema, (jint)lpStruct->lpstrSchema);
- (*env)->SetIntField(env, lpObject, VARDESC1Fc.memid, lpStruct->memid);
-}
-#endif /* NO_VARDESC1 */
-
-#ifndef NO_VARDESC2
-typedef struct VARDESC2_FID_CACHE {
- int cached;
- jclass clazz;
- jfieldID memid, lpstrSchema, unionField, elemdescVar_tdesc_union, elemdescVar_tdesc_vt, elemdescFunc_idldesc_dwReserved, elemdescFunc_idldesc_wIDLFlags, wVarFlags, varkind;
-} VARDESC2_FID_CACHE;
-
-VARDESC2_FID_CACHE VARDESC2Fc;
-
-void cacheVARDESC2Fids(JNIEnv *env, jobject lpObject)
-{
- if (VARDESC2Fc.cached) return;
- VARDESC2Fc.clazz = (*env)->GetObjectClass(env, lpObject);
- VARDESC2Fc.memid = (*env)->GetFieldID(env, VARDESC2Fc.clazz, "memid", "I");
- VARDESC2Fc.lpstrSchema = (*env)->GetFieldID(env, VARDESC2Fc.clazz, "lpstrSchema", "I");
- VARDESC2Fc.unionField = (*env)->GetFieldID(env, VARDESC2Fc.clazz, "unionField", "I");
- VARDESC2Fc.elemdescVar_tdesc_union = (*env)->GetFieldID(env, VARDESC2Fc.clazz, "elemdescVar_tdesc_union", "I");
- VARDESC2Fc.elemdescVar_tdesc_vt = (*env)->GetFieldID(env, VARDESC2Fc.clazz, "elemdescVar_tdesc_vt", "S");
- VARDESC2Fc.elemdescFunc_idldesc_dwReserved = (*env)->GetFieldID(env, VARDESC2Fc.clazz, "elemdescFunc_idldesc_dwReserved", "I");
- VARDESC2Fc.elemdescFunc_idldesc_wIDLFlags = (*env)->GetFieldID(env, VARDESC2Fc.clazz, "elemdescFunc_idldesc_wIDLFlags", "S");
- VARDESC2Fc.wVarFlags = (*env)->GetFieldID(env, VARDESC2Fc.clazz, "wVarFlags", "S");
- VARDESC2Fc.varkind = (*env)->GetFieldID(env, VARDESC2Fc.clazz, "varkind", "I");
- VARDESC2Fc.cached = 1;
-}
-
-VARDESC *getVARDESC2Fields(JNIEnv *env, jobject lpObject, VARDESC *lpStruct)
-{
- if (!VARDESC2Fc.cached) cacheVARDESC2Fids(env, lpObject);
- lpStruct->varkind = (*env)->GetIntField(env, lpObject, VARDESC2Fc.varkind);
- lpStruct->wVarFlags = (*env)->GetShortField(env, lpObject, VARDESC2Fc.wVarFlags);
- lpStruct->elemdescVar.idldesc.wIDLFlags = (*env)->GetShortField(env, lpObject, VARDESC2Fc.elemdescFunc_idldesc_wIDLFlags);
- lpStruct->elemdescVar.idldesc.dwReserved = (*env)->GetIntField(env, lpObject, VARDESC2Fc.elemdescFunc_idldesc_dwReserved);
- lpStruct->elemdescVar.tdesc.vt = (*env)->GetShortField(env, lpObject, VARDESC2Fc.elemdescVar_tdesc_vt);
- lpStruct->elemdescVar.tdesc.lptdesc = (struct FARSTRUCT tagTYPEDESC FAR *)(*env)->GetIntField(env, lpObject, VARDESC2Fc.elemdescVar_tdesc_union);
- lpStruct->oInst = (*env)->GetIntField(env, lpObject, VARDESC2Fc.unionField);
- lpStruct->lpstrSchema = (OLECHAR FAR *)(*env)->GetIntField(env, lpObject, VARDESC2Fc.lpstrSchema);
- lpStruct->memid = (*env)->GetIntField(env, lpObject, VARDESC2Fc.memid);
- return lpStruct;
-}
-
-void setVARDESC2Fields(JNIEnv *env, jobject lpObject, VARDESC *lpStruct)
-{
- if (!VARDESC2Fc.cached) cacheVARDESC2Fids(env, lpObject);
- (*env)->SetIntField(env, lpObject, VARDESC2Fc.varkind, lpStruct->varkind);
- (*env)->SetShortField(env, lpObject, VARDESC2Fc.wVarFlags, lpStruct->wVarFlags);
- (*env)->SetShortField(env, lpObject, VARDESC2Fc.elemdescFunc_idldesc_wIDLFlags, lpStruct->elemdescVar.idldesc.wIDLFlags);
- (*env)->SetIntField(env, lpObject, VARDESC2Fc.elemdescFunc_idldesc_dwReserved, lpStruct->elemdescVar.idldesc.dwReserved);
- (*env)->SetShortField(env, lpObject, VARDESC2Fc.elemdescVar_tdesc_vt, lpStruct->elemdescVar.tdesc.vt);
- (*env)->SetIntField(env, lpObject, VARDESC2Fc.elemdescVar_tdesc_union, (jint)lpStruct->elemdescVar.tdesc.lptdesc);
- (*env)->SetIntField(env, lpObject, VARDESC2Fc.unionField, lpStruct->oInst);
- (*env)->SetIntField(env, lpObject, VARDESC2Fc.lpstrSchema, (jint)lpStruct->lpstrSchema);
- (*env)->SetIntField(env, lpObject, VARDESC2Fc.memid, lpStruct->memid);
-}
-#endif /* NO_VARDESC2 */
-
+/*
+ * Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
+ * This file is made available under the terms of the Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+/**
+ * JNI SWT object field getters and setters declarations for Windows structs
+ */
+
+#include "swt.h"
+#include "structs.h"
+
+#ifndef NO_ACCEL
+typedef struct ACCEL_FID_CACHE {
+ int cached;
+ jclass clazz;
+ jfieldID fVirt, key, cmd;
+} ACCEL_FID_CACHE;
+
+ACCEL_FID_CACHE ACCELFc;
+
+void cacheACCELFids(JNIEnv *env, jobject lpObject)
+{
+ if (ACCELFc.cached) return;
+ ACCELFc.clazz = (*env)->GetObjectClass(env, lpObject);
+ ACCELFc.fVirt = (*env)->GetFieldID(env, ACCELFc.clazz, "fVirt", "B");
+ ACCELFc.key = (*env)->GetFieldID(env, ACCELFc.clazz, "key", "S");
+ ACCELFc.cmd = (*env)->GetFieldID(env, ACCELFc.clazz, "cmd", "S");
+ ACCELFc.cached = 1;
+}
+
+ACCEL *getACCELFields(JNIEnv *env, jobject lpObject, ACCEL *lpStruct)
+{
+ if (!ACCELFc.cached) cacheACCELFids(env, lpObject);
+ lpStruct->fVirt = (*env)->GetByteField(env, lpObject, ACCELFc.fVirt);
+ lpStruct->key = (*env)->GetShortField(env, lpObject, ACCELFc.key);
+ lpStruct->cmd = (*env)->GetShortField(env, lpObject, ACCELFc.cmd);
+ return lpStruct;
+}
+
+void setACCELFields(JNIEnv *env, jobject lpObject, ACCEL *lpStruct)
+{
+ if (!ACCELFc.cached) cacheACCELFids(env, lpObject);
+ (*env)->SetByteField(env, lpObject, ACCELFc.fVirt, (jbyte)lpStruct->fVirt);
+ (*env)->SetShortField(env, lpObject, ACCELFc.key, (jshort)lpStruct->key);
+ (*env)->SetShortField(env, lpObject, ACCELFc.cmd, (jshort)lpStruct->cmd);
+}
+#endif /* NO_ACCEL */
+
+#ifndef NO_BITMAP
+typedef struct BITMAP_FID_CACHE {
+ int cached;
+ jclass clazz;
+ jfieldID bmType, bmWidth, bmHeight, bmWidthBytes, bmPlanes, bmBitsPixel, bmBits;
+} BITMAP_FID_CACHE;
+
+BITMAP_FID_CACHE BITMAPFc;
+
+void cacheBITMAPFids(JNIEnv *env, jobject lpObject)
+{
+ if (BITMAPFc.cached) return;
+ BITMAPFc.clazz = (*env)->GetObjectClass(env, lpObject);
+ BITMAPFc.bmType = (*env)->GetFieldID(env, BITMAPFc.clazz, "bmType", "I");
+ BITMAPFc.bmWidth = (*env)->GetFieldID(env, BITMAPFc.clazz, "bmWidth", "I");
+ BITMAPFc.bmHeight = (*env)->GetFieldID(env, BITMAPFc.clazz, "bmHeight", "I");
+ BITMAPFc.bmWidthBytes = (*env)->GetFieldID(env, BITMAPFc.clazz, "bmWidthBytes", "I");
+ BITMAPFc.bmPlanes = (*env)->GetFieldID(env, BITMAPFc.clazz, "bmPlanes", "S");
+ BITMAPFc.bmBitsPixel = (*env)->GetFieldID(env, BITMAPFc.clazz, "bmBitsPixel", "S");
+ BITMAPFc.bmBits = (*env)->GetFieldID(env, BITMAPFc.clazz, "bmBits", "I");
+ BITMAPFc.cached = 1;
+}
+
+BITMAP *getBITMAPFields(JNIEnv *env, jobject lpObject, BITMAP *lpStruct)
+{
+ if (!BITMAPFc.cached) cacheBITMAPFids(env, lpObject);
+ lpStruct->bmType = (*env)->GetIntField(env, lpObject, BITMAPFc.bmType);
+ lpStruct->bmWidth = (*env)->GetIntField(env, lpObject, BITMAPFc.bmWidth);
+ lpStruct->bmHeight = (*env)->GetIntField(env, lpObject, BITMAPFc.bmHeight);
+ lpStruct->bmWidthBytes = (*env)->GetIntField(env, lpObject, BITMAPFc.bmWidthBytes);
+ lpStruct->bmPlanes = (*env)->GetShortField(env, lpObject, BITMAPFc.bmPlanes);
+ lpStruct->bmBitsPixel = (*env)->GetShortField(env, lpObject, BITMAPFc.bmBitsPixel);
+ lpStruct->bmBits = (LPVOID)(*env)->GetIntField(env, lpObject, BITMAPFc.bmBits);
+ return lpStruct;
+}
+
+void setBITMAPFields(JNIEnv *env, jobject lpObject, BITMAP *lpStruct)
+{
+ if (!BITMAPFc.cached) cacheBITMAPFids(env, lpObject);
+ (*env)->SetIntField(env, lpObject, BITMAPFc.bmType, (jint)lpStruct->bmType);
+ (*env)->SetIntField(env, lpObject, BITMAPFc.bmWidth, (jint)lpStruct->bmWidth);
+ (*env)->SetIntField(env, lpObject, BITMAPFc.bmHeight, (jint)lpStruct->bmHeight);
+ (*env)->SetIntField(env, lpObject, BITMAPFc.bmWidthBytes, (jint)lpStruct->bmWidthBytes);
+ (*env)->SetShortField(env, lpObject, BITMAPFc.bmPlanes, (jshort)lpStruct->bmPlanes);
+ (*env)->SetShortField(env, lpObject, BITMAPFc.bmBitsPixel, (jshort)lpStruct->bmBitsPixel);
+ (*env)->SetIntField(env, lpObject, BITMAPFc.bmBits, (jint)lpStruct->bmBits);
+}
+#endif /* NO_BITMAP */
+
+#ifndef NO_BITMAPINFOHEADER
+typedef struct BITMAPINFOHEADER_FID_CACHE {
+ int cached;
+ jclass clazz;
+ jfieldID biClrImportant, biClrUsed, biYPelsPerMeter, biXPelsPerMeter, biSizeImage, biCompression, biBitCount, biPlanes, biHeight, biWidth, biSize;
+} BITMAPINFOHEADER_FID_CACHE;
+
+BITMAPINFOHEADER_FID_CACHE BITMAPINFOHEADERFc;
+
+void cacheBITMAPINFOHEADERFids(JNIEnv *env, jobject lpObject)
+{
+ if (BITMAPINFOHEADERFc.cached) return;
+ BITMAPINFOHEADERFc.clazz = (*env)->GetObjectClass(env, lpObject);
+ BITMAPINFOHEADERFc.biClrImportant = (*env)->GetFieldID(env, BITMAPINFOHEADERFc.clazz, "biClrImportant", "I");
+ BITMAPINFOHEADERFc.biClrUsed = (*env)->GetFieldID(env, BITMAPINFOHEADERFc.clazz, "biClrUsed", "I");
+ BITMAPINFOHEADERFc.biYPelsPerMeter = (*env)->GetFieldID(env, BITMAPINFOHEADERFc.clazz, "biYPelsPerMeter", "I");
+ BITMAPINFOHEADERFc.biXPelsPerMeter = (*env)->GetFieldID(env, BITMAPINFOHEADERFc.clazz, "biXPelsPerMeter", "I");
+ BITMAPINFOHEADERFc.biSizeImage = (*env)->GetFieldID(env, BITMAPINFOHEADERFc.clazz, "biSizeImage", "I");
+ BITMAPINFOHEADERFc.biCompression = (*env)->GetFieldID(env, BITMAPINFOHEADERFc.clazz, "biCompression", "I");
+ BITMAPINFOHEADERFc.biBitCount = (*env)->GetFieldID(env, BITMAPINFOHEADERFc.clazz, "biBitCount", "S");
+ BITMAPINFOHEADERFc.biPlanes = (*env)->GetFieldID(env, BITMAPINFOHEADERFc.clazz, "biPlanes", "S");
+ BITMAPINFOHEADERFc.biHeight = (*env)->GetFieldID(env, BITMAPINFOHEADERFc.clazz, "biHeight", "I");
+ BITMAPINFOHEADERFc.biWidth = (*env)->GetFieldID(env, BITMAPINFOHEADERFc.clazz, "biWidth", "I");
+ BITMAPINFOHEADERFc.biSize = (*env)->GetFieldID(env, BITMAPINFOHEADERFc.clazz, "biSize", "I");
+ BITMAPINFOHEADERFc.cached = 1;
+}
+
+BITMAPINFOHEADER *getBITMAPINFOHEADERFields(JNIEnv *env, jobject lpObject, BITMAPINFOHEADER *lpStruct)
+{
+ if (!BITMAPINFOHEADERFc.cached) cacheBITMAPINFOHEADERFids(env, lpObject);
+ lpStruct->biClrImportant = (*env)->GetIntField(env, lpObject, BITMAPINFOHEADERFc.biClrImportant);
+ lpStruct->biClrUsed = (*env)->GetIntField(env, lpObject, BITMAPINFOHEADERFc.biClrUsed);
+ lpStruct->biYPelsPerMeter = (*env)->GetIntField(env, lpObject, BITMAPINFOHEADERFc.biYPelsPerMeter);
+ lpStruct->biXPelsPerMeter = (*env)->GetIntField(env, lpObject, BITMAPINFOHEADERFc.biXPelsPerMeter);
+ lpStruct->biSizeImage = (*env)->GetIntField(env, lpObject, BITMAPINFOHEADERFc.biSizeImage);
+ lpStruct->biCompression = (*env)->GetIntField(env, lpObject, BITMAPINFOHEADERFc.biCompression);
+ lpStruct->biBitCount = (*env)->GetShortField(env, lpObject, BITMAPINFOHEADERFc.biBitCount);
+ lpStruct->biPlanes = (*env)->GetShortField(env, lpObject, BITMAPINFOHEADERFc.biPlanes);
+ lpStruct->biHeight = (*env)->GetIntField(env, lpObject, BITMAPINFOHEADERFc.biHeight);
+ lpStruct->biWidth = (*env)->GetIntField(env, lpObject, BITMAPINFOHEADERFc.biWidth);
+ lpStruct->biSize = (*env)->GetIntField(env, lpObject, BITMAPINFOHEADERFc.biSize);
+ return lpStruct;
+}
+
+void setBITMAPINFOHEADERFields(JNIEnv *env, jobject lpObject, BITMAPINFOHEADER *lpStruct)
+{
+ if (!BITMAPINFOHEADERFc.cached) cacheBITMAPINFOHEADERFids(env, lpObject);
+ (*env)->SetIntField(env, lpObject, BITMAPINFOHEADERFc.biClrImportant, (jint)lpStruct->biClrImportant);
+ (*env)->SetIntField(env, lpObject, BITMAPINFOHEADERFc.biClrUsed, (jint)lpStruct->biClrUsed);
+ (*env)->SetIntField(env, lpObject, BITMAPINFOHEADERFc.biYPelsPerMeter, (jint)lpStruct->biYPelsPerMeter);
+ (*env)->SetIntField(env, lpObject, BITMAPINFOHEADERFc.biXPelsPerMeter, (jint)lpStruct->biXPelsPerMeter);
+ (*env)->SetIntField(env, lpObject, BITMAPINFOHEADERFc.biSizeImage, (jint)lpStruct->biSizeImage);
+ (*env)->SetIntField(env, lpObject, BITMAPINFOHEADERFc.biCompression, (jint)lpStruct->biCompression);
+ (*env)->SetShortField(env, lpObject, BITMAPINFOHEADERFc.biBitCount, (jshort)lpStruct->biBitCount);
+ (*env)->SetShortField(env, lpObject, BITMAPINFOHEADERFc.biPlanes, (jshort)lpStruct->biPlanes);
+ (*env)->SetIntField(env, lpObject, BITMAPINFOHEADERFc.biHeight, (jint)lpStruct->biHeight);
+ (*env)->SetIntField(env, lpObject, BITMAPINFOHEADERFc.biWidth, (jint)lpStruct->biWidth);
+ (*env)->SetIntField(env, lpObject, BITMAPINFOHEADERFc.biSize, (jint)lpStruct->biSize);
+}
+#endif /* NO_BITMAPINFOHEADER */
+
+#ifndef NO_BROWSEINFO
+typedef struct BROWSEINFO_FID_CACHE {
+ int cached;
+ jclass clazz;
+ jfieldID hwndOwner, pidlRoot, pszDisplayName, lpszTitle, ulFlags, lpfn, lParam, iImage;
+} BROWSEINFO_FID_CACHE;
+
+BROWSEINFO_FID_CACHE BROWSEINFOFc;
+
+void cacheBROWSEINFOFids(JNIEnv *env, jobject lpObject)
+{
+ if (BROWSEINFOFc.cached) return;
+ BROWSEINFOFc.clazz = (*env)->GetObjectClass(env, lpObject);
+ BROWSEINFOFc.hwndOwner = (*env)->GetFieldID(env, BROWSEINFOFc.clazz, "hwndOwner", "I");
+ BROWSEINFOFc.pidlRoot = (*env)->GetFieldID(env, BROWSEINFOFc.clazz, "pidlRoot", "I");
+ BROWSEINFOFc.pszDisplayName = (*env)->GetFieldID(env, BROWSEINFOFc.clazz, "pszDisplayName", "I");
+ BROWSEINFOFc.lpszTitle = (*env)->GetFieldID(env, BROWSEINFOFc.clazz, "lpszTitle", "I");
+ BROWSEINFOFc.ulFlags = (*env)->GetFieldID(env, BROWSEINFOFc.clazz, "ulFlags", "I");
+ BROWSEINFOFc.lpfn = (*env)->GetFieldID(env, BROWSEINFOFc.clazz, "lpfn", "I");
+ BROWSEINFOFc.lParam = (*env)->GetFieldID(env, BROWSEINFOFc.clazz, "lParam", "I");
+ BROWSEINFOFc.iImage = (*env)->GetFieldID(env, BROWSEINFOFc.clazz, "iImage", "I");
+ BROWSEINFOFc.cached = 1;
+}
+
+BROWSEINFO *getBROWSEINFOFields(JNIEnv *env, jobject lpObject, BROWSEINFO *lpStruct)
+{
+ if (!BROWSEINFOFc.cached) cacheBROWSEINFOFids(env, lpObject);
+ lpStruct->hwndOwner = (HWND)(*env)->GetIntField(env, lpObject, BROWSEINFOFc.hwndOwner);
+ lpStruct->pidlRoot = (LPCITEMIDLIST)(*env)->GetIntField(env, lpObject, BROWSEINFOFc.pidlRoot);
+ lpStruct->pszDisplayName = (LPTSTR)(*env)->GetIntField(env, lpObject, BROWSEINFOFc.pszDisplayName);
+ lpStruct->lpszTitle = (LPCTSTR)(*env)->GetIntField(env, lpObject, BROWSEINFOFc.lpszTitle);
+ lpStruct->ulFlags = (*env)->GetIntField(env, lpObject, BROWSEINFOFc.ulFlags);
+ lpStruct->lpfn = (BFFCALLBACK)(*env)->GetIntField(env, lpObject, BROWSEINFOFc.lpfn);
+ lpStruct->lParam = (*env)->GetIntField(env, lpObject, BROWSEINFOFc.lParam);
+ lpStruct->iImage = (*env)->GetIntField(env, lpObject, BROWSEINFOFc.iImage);
+ return lpStruct;
+}
+
+void setBROWSEINFOFields(JNIEnv *env, jobject lpObject, BROWSEINFO *lpStruct)
+{
+ if (!BROWSEINFOFc.cached) cacheBROWSEINFOFids(env, lpObject);
+ (*env)->SetIntField(env, lpObject, BROWSEINFOFc.hwndOwner, (jint)lpStruct->hwndOwner);
+ (*env)->SetIntField(env, lpObject, BROWSEINFOFc.pidlRoot, (jint)lpStruct->pidlRoot);
+ (*env)->SetIntField(env, lpObject, BROWSEINFOFc.pszDisplayName, (jint)lpStruct->pszDisplayName);
+ (*env)->SetIntField(env, lpObject, BROWSEINFOFc.lpszTitle, (jint)lpStruct->lpszTitle);
+ (*env)->SetIntField(env, lpObject, BROWSEINFOFc.ulFlags, (jint)lpStruct->ulFlags);
+ (*env)->SetIntField(env, lpObject, BROWSEINFOFc.lpfn, (jint)lpStruct->lpfn);
+ (*env)->SetIntField(env, lpObject, BROWSEINFOFc.lParam, (jint)lpStruct->lParam);
+ (*env)->SetIntField(env, lpObject, BROWSEINFOFc.iImage, (jint)lpStruct->iImage);
+}
+#endif /* NO_BROWSEINFO */
+
+#ifndef NO_CHOOSECOLOR
+typedef struct CHOOSECOLOR_FID_CACHE {
+ int cached;
+ jclass clazz;
+ jfieldID lStructSize, hwndOwner, hInstance, rgbResult, lpCustColors, Flags, lCustData, lpfnHook, lpTemplateName;
+} CHOOSECOLOR_FID_CACHE;
+
+CHOOSECOLOR_FID_CACHE CHOOSECOLORFc;
+
+void cacheCHOOSECOLORFids(JNIEnv *env, jobject lpObject)
+{
+ if (CHOOSECOLORFc.cached) return;
+ CHOOSECOLORFc.clazz = (*env)->GetObjectClass(env, lpObject);
+ CHOOSECOLORFc.lStructSize = (*env)->GetFieldID(env, CHOOSECOLORFc.clazz, "lStructSize", "I");
+ CHOOSECOLORFc.hwndOwner = (*env)->GetFieldID(env, CHOOSECOLORFc.clazz, "hwndOwner", "I");
+ CHOOSECOLORFc.hInstance = (*env)->GetFieldID(env, CHOOSECOLORFc.clazz, "hInstance", "I");
+ CHOOSECOLORFc.rgbResult = (*env)->GetFieldID(env, CHOOSECOLORFc.clazz, "rgbResult", "I");
+ CHOOSECOLORFc.lpCustColors = (*env)->GetFieldID(env, CHOOSECOLORFc.clazz, "lpCustColors", "I");
+ CHOOSECOLORFc.Flags = (*env)->GetFieldID(env, CHOOSECOLORFc.clazz, "Flags", "I");
+ CHOOSECOLORFc.lCustData = (*env)->GetFieldID(env, CHOOSECOLORFc.clazz, "lCustData", "I");
+ CHOOSECOLORFc.lpfnHook = (*env)->GetFieldID(env, CHOOSECOLORFc.clazz, "lpfnHook", "I");
+ CHOOSECOLORFc.lpTemplateName = (*env)->GetFieldID(env, CHOOSECOLORFc.clazz, "lpTemplateName", "I");
+ CHOOSECOLORFc.cached = 1;
+}
+
+CHOOSECOLOR *getCHOOSECOLORFields(JNIEnv *env, jobject lpObject, CHOOSECOLOR *lpStruct)
+{
+ if (!CHOOSECOLORFc.cached) cacheCHOOSECOLORFids(env, lpObject);
+ lpStruct->lStructSize = (*env)->GetIntField(env, lpObject, CHOOSECOLORFc.lStructSize);
+ lpStruct->hwndOwner = (HWND)(*env)->GetIntField(env, lpObject, CHOOSECOLORFc.hwndOwner);
+ lpStruct->hInstance = (HANDLE)(*env)->GetIntField(env, lpObject, CHOOSECOLORFc.hInstance);
+ lpStruct->rgbResult = (*env)->GetIntField(env, lpObject, CHOOSECOLORFc.rgbResult);
+ lpStruct->lpCustColors = (COLORREF *)(*env)->GetIntField(env, lpObject, CHOOSECOLORFc.lpCustColors);
+ lpStruct->Flags = (*env)->GetIntField(env, lpObject, CHOOSECOLORFc.Flags);
+ lpStruct->lCustData = (*env)->GetIntField(env, lpObject, CHOOSECOLORFc.lCustData);
+ lpStruct->lpfnHook = (LPCCHOOKPROC)(*env)->GetIntField(env, lpObject, CHOOSECOLORFc.lpfnHook);
+ lpStruct->lpTemplateName = (LPCTSTR)(*env)->GetIntField(env, lpObject, CHOOSECOLORFc.lpTemplateName);
+ return lpStruct;
+}
+
+void setCHOOSECOLORFields(JNIEnv *env, jobject lpObject, CHOOSECOLOR *lpStruct)
+{
+ if (!CHOOSECOLORFc.cached) cacheCHOOSECOLORFids(env, lpObject);
+ (*env)->SetIntField(env, lpObject, CHOOSECOLORFc.lStructSize, (jint)lpStruct->lStructSize);
+ (*env)->SetIntField(env, lpObject, CHOOSECOLORFc.hwndOwner, (jint)lpStruct->hwndOwner);
+ (*env)->SetIntField(env, lpObject, CHOOSECOLORFc.hInstance, (jint)lpStruct->hInstance);
+ (*env)->SetIntField(env, lpObject, CHOOSECOLORFc.rgbResult, (jint)lpStruct->rgbResult);
+ (*env)->SetIntField(env, lpObject, CHOOSECOLORFc.lpCustColors, (jint)lpStruct->lpCustColors);
+ (*env)->SetIntField(env, lpObject, CHOOSECOLORFc.Flags, (jint)lpStruct->Flags);
+ (*env)->SetIntField(env, lpObject, CHOOSECOLORFc.lCustData, (jint)lpStruct->lCustData);
+ (*env)->SetIntField(env, lpObject, CHOOSECOLORFc.lpfnHook, (jint)lpStruct->lpfnHook);
+ (*env)->SetIntField(env, lpObject, CHOOSECOLORFc.lpTemplateName, (jint)lpStruct->lpTemplateName);
+}
+#endif /* NO_CHOOSECOLOR */
+
+#ifndef NO_CHOOSEFONT
+typedef struct CHOOSEFONT_FID_CACHE {
+ int cached;
+ jclass clazz;
+ jfieldID lStructSize, hwndOwner, hDC, lpLogFont, iPointSize, Flags, rgbColors, lCustData, lpfnHook, lpTemplateName, hInstance, lpszStyle, nFontType, nSizeMin, nSizeMax;
+} CHOOSEFONT_FID_CACHE;
+
+CHOOSEFONT_FID_CACHE CHOOSEFONTFc;
+
+void cacheCHOOSEFONTFids(JNIEnv *env, jobject lpObject)
+{
+ if (CHOOSEFONTFc.cached) return;
+ CHOOSEFONTFc.clazz = (*env)->GetObjectClass(env, lpObject);
+ CHOOSEFONTFc.lStructSize = (*env)->GetFieldID(env, CHOOSEFONTFc.clazz, "lStructSize", "I");
+ CHOOSEFONTFc.hwndOwner = (*env)->GetFieldID(env, CHOOSEFONTFc.clazz, "hwndOwner", "I");
+ CHOOSEFONTFc.hDC = (*env)->GetFieldID(env, CHOOSEFONTFc.clazz, "hDC", "I");
+ CHOOSEFONTFc.lpLogFont = (*env)->GetFieldID(env, CHOOSEFONTFc.clazz, "lpLogFont", "I");
+ CHOOSEFONTFc.iPointSize = (*env)->GetFieldID(env, CHOOSEFONTFc.clazz, "iPointSize", "I");
+ CHOOSEFONTFc.Flags = (*env)->GetFieldID(env, CHOOSEFONTFc.clazz, "Flags", "I");
+ CHOOSEFONTFc.rgbColors = (*env)->GetFieldID(env, CHOOSEFONTFc.clazz, "rgbColors", "I");
+ CHOOSEFONTFc.lCustData = (*env)->GetFieldID(env, CHOOSEFONTFc.clazz, "lCustData", "I");
+ CHOOSEFONTFc.lpfnHook = (*env)->GetFieldID(env, CHOOSEFONTFc.clazz, "lpfnHook", "I");
+ CHOOSEFONTFc.lpTemplateName = (*env)->GetFieldID(env, CHOOSEFONTFc.clazz, "lpTemplateName", "I");
+ CHOOSEFONTFc.hInstance = (*env)->GetFieldID(env, CHOOSEFONTFc.clazz, "hInstance", "I");
+ CHOOSEFONTFc.lpszStyle = (*env)->GetFieldID(env, CHOOSEFONTFc.clazz, "lpszStyle", "I");
+ CHOOSEFONTFc.nFontType = (*env)->GetFieldID(env, CHOOSEFONTFc.clazz, "nFontType", "S");
+ CHOOSEFONTFc.nSizeMin = (*env)->GetFieldID(env, CHOOSEFONTFc.clazz, "nSizeMin", "I");
+ CHOOSEFONTFc.nSizeMax = (*env)->GetFieldID(env, CHOOSEFONTFc.clazz, "nSizeMax", "I");
+ CHOOSEFONTFc.cached = 1;
+}
+
+CHOOSEFONT *getCHOOSEFONTFields(JNIEnv *env, jobject lpObject, CHOOSEFONT *lpStruct)
+{
+ if (!CHOOSEFONTFc.cached) cacheCHOOSEFONTFids(env, lpObject);
+ lpStruct->lStructSize = (*env)->GetIntField(env, lpObject, CHOOSEFONTFc.lStructSize);
+ lpStruct->hwndOwner = (HWND)(*env)->GetIntField(env, lpObject, CHOOSEFONTFc.hwndOwner);
+ lpStruct->hDC = (HDC)(*env)->GetIntField(env, lpObject, CHOOSEFONTFc.hDC);
+ lpStruct->lpLogFont = (LPLOGFONT)(*env)->GetIntField(env, lpObject, CHOOSEFONTFc.lpLogFont);
+ lpStruct->iPointSize = (*env)->GetIntField(env, lpObject, CHOOSEFONTFc.iPointSize);
+ lpStruct->Flags = (*env)->GetIntField(env, lpObject, CHOOSEFONTFc.Flags);
+ lpStruct->rgbColors = (*env)->GetIntField(env, lpObject, CHOOSEFONTFc.rgbColors);
+ lpStruct->lCustData = (*env)->GetIntField(env, lpObject, CHOOSEFONTFc.lCustData);
+ lpStruct->lpfnHook = (LPCFHOOKPROC)(*env)->GetIntField(env, lpObject, CHOOSEFONTFc.lpfnHook);
+ lpStruct->lpTemplateName = (LPCTSTR)(*env)->GetIntField(env, lpObject, CHOOSEFONTFc.lpTemplateName);
+ lpStruct->hInstance = (HINSTANCE)(*env)->GetIntField(env, lpObject, CHOOSEFONTFc.hInstance);
+ lpStruct->lpszStyle = (LPTSTR)(*env)->GetIntField(env, lpObject, CHOOSEFONTFc.lpszStyle);
+ lpStruct->nFontType = (*env)->GetShortField(env, lpObject, CHOOSEFONTFc.nFontType);
+ lpStruct->nSizeMin = (*env)->GetIntField(env, lpObject, CHOOSEFONTFc.nSizeMin);
+ lpStruct->nSizeMax = (*env)->GetIntField(env, lpObject, CHOOSEFONTFc.nSizeMax);
+ return lpStruct;
+}
+
+void setCHOOSEFONTFields(JNIEnv *env, jobject lpObject, CHOOSEFONT *lpStruct)
+{
+ if (!CHOOSEFONTFc.cached) cacheCHOOSEFONTFids(env, lpObject);
+ (*env)->SetIntField(env, lpObject, CHOOSEFONTFc.lStructSize, (jint)lpStruct->lStructSize);
+ (*env)->SetIntField(env, lpObject, CHOOSEFONTFc.hwndOwner, (jint)lpStruct->hwndOwner);
+ (*env)->SetIntField(env, lpObject, CHOOSEFONTFc.hDC, (jint)lpStruct->hDC);
+ (*env)->SetIntField(env, lpObject, CHOOSEFONTFc.lpLogFont, (jint)lpStruct->lpLogFont);
+ (*env)->SetIntField(env, lpObject, CHOOSEFONTFc.iPointSize, (jint)lpStruct->iPointSize);
+ (*env)->SetIntField(env, lpObject, CHOOSEFONTFc.Flags, (jint)lpStruct->Flags);
+ (*env)->SetIntField(env, lpObject, CHOOSEFONTFc.rgbColors, (jint)lpStruct->rgbColors);
+ (*env)->SetIntField(env, lpObject, CHOOSEFONTFc.lCustData, (jint)lpStruct->lCustData);
+ (*env)->SetIntField(env, lpObject, CHOOSEFONTFc.lpfnHook, (jint)lpStruct->lpfnHook);
+ (*env)->SetIntField(env, lpObject, CHOOSEFONTFc.lpTemplateName, (jint)lpStruct->lpTemplateName);
+ (*env)->SetIntField(env, lpObject, CHOOSEFONTFc.hInstance, (jint)lpStruct->hInstance);
+ (*env)->SetIntField(env, lpObject, CHOOSEFONTFc.lpszStyle, (jint)lpStruct->lpszStyle);
+ (*env)->SetShortField(env, lpObject, CHOOSEFONTFc.nFontType, (jshort)lpStruct->nFontType);
+ (*env)->SetIntField(env, lpObject, CHOOSEFONTFc.nSizeMin, (jint)lpStruct->nSizeMin);
+ (*env)->SetIntField(env, lpObject, CHOOSEFONTFc.nSizeMax, (jint)lpStruct->nSizeMax);
+}
+#endif /* NO_CHOOSEFONT */
+
+#ifndef NO_COMPOSITIONFORM
+typedef struct COMPOSITIONFORM_FID_CACHE {
+ int cached;
+ jclass clazz;
+ jfieldID dwStyle, x, y, left, top, right, bottom;
+} COMPOSITIONFORM_FID_CACHE;
+
+COMPOSITIONFORM_FID_CACHE COMPOSITIONFORMFc;
+
+void cacheCOMPOSITIONFORMFids(JNIEnv *env, jobject lpObject)
+{
+ if (COMPOSITIONFORMFc.cached) return;
+ COMPOSITIONFORMFc.clazz = (*env)->GetObjectClass(env, lpObject);
+ COMPOSITIONFORMFc.dwStyle = (*env)->GetFieldID(env, COMPOSITIONFORMFc.clazz, "dwStyle", "I");
+ COMPOSITIONFORMFc.x = (*env)->GetFieldID(env, COMPOSITIONFORMFc.clazz, "x", "I");
+ COMPOSITIONFORMFc.y = (*env)->GetFieldID(env, COMPOSITIONFORMFc.clazz, "y", "I");
+ COMPOSITIONFORMFc.left = (*env)->GetFieldID(env, COMPOSITIONFORMFc.clazz, "left", "I");
+ COMPOSITIONFORMFc.top = (*env)->GetFieldID(env, COMPOSITIONFORMFc.clazz, "top", "I");
+ COMPOSITIONFORMFc.right = (*env)->GetFieldID(env, COMPOSITIONFORMFc.clazz, "right", "I");
+ COMPOSITIONFORMFc.bottom = (*env)->GetFieldID(env, COMPOSITIONFORMFc.clazz, "bottom", "I");
+ COMPOSITIONFORMFc.cached = 1;
+}
+
+COMPOSITIONFORM *getCOMPOSITIONFORMFields(JNIEnv *env, jobject lpObject, COMPOSITIONFORM *lpStruct)
+{
+ if (!COMPOSITIONFORMFc.cached) cacheCOMPOSITIONFORMFids(env, lpObject);
+ lpStruct->dwStyle = (*env)->GetIntField(env, lpObject, COMPOSITIONFORMFc.dwStyle);
+ lpStruct->ptCurrentPos.x = (*env)->GetIntField(env, lpObject, COMPOSITIONFORMFc.x);
+ lpStruct->ptCurrentPos.y = (*env)->GetIntField(env, lpObject, COMPOSITIONFORMFc.y);
+ lpStruct->rcArea.left = (*env)->GetIntField(env, lpObject, COMPOSITIONFORMFc.left);
+ lpStruct->rcArea.top = (*env)->GetIntField(env, lpObject, COMPOSITIONFORMFc.top);
+ lpStruct->rcArea.right = (*env)->GetIntField(env, lpObject, COMPOSITIONFORMFc.right);
+ lpStruct->rcArea.bottom = (*env)->GetIntField(env, lpObject, COMPOSITIONFORMFc.bottom);
+ return lpStruct;
+}
+
+void setCOMPOSITIONFORMFields(JNIEnv *env, jobject lpObject, COMPOSITIONFORM *lpStruct)
+{
+ if (!COMPOSITIONFORMFc.cached) cacheCOMPOSITIONFORMFids(env, lpObject);
+ (*env)->SetIntField(env, lpObject, COMPOSITIONFORMFc.dwStyle, (jint)lpStruct->dwStyle);
+ (*env)->SetIntField(env, lpObject, COMPOSITIONFORMFc.x, (jint)lpStruct->ptCurrentPos.x);
+ (*env)->SetIntField(env, lpObject, COMPOSITIONFORMFc.y, (jint)lpStruct->ptCurrentPos.y);
+ (*env)->SetIntField(env, lpObject, COMPOSITIONFORMFc.left, (jint)lpStruct->rcArea.left);
+ (*env)->SetIntField(env, lpObject, COMPOSITIONFORMFc.top, (jint)lpStruct->rcArea.top);
+ (*env)->SetIntField(env, lpObject, COMPOSITIONFORMFc.right, (jint)lpStruct->rcArea.right);
+ (*env)->SetIntField(env, lpObject, COMPOSITIONFORMFc.bottom, (jint)lpStruct->rcArea.bottom);
+}
+#endif /* NO_COMPOSITIONFORM */
+
+#ifndef NO_CREATESTRUCT
+typedef struct CREATESTRUCT_FID_CACHE {
+ int cached;
+ jclass clazz;
+ jfieldID lpCreateParams, hInstance, hMenu, hwndParent, cy, cx, y, x, style, lpszName, lpszClass, dwExStyle;
+} CREATESTRUCT_FID_CACHE;
+
+CREATESTRUCT_FID_CACHE CREATESTRUCTFc;
+
+void cacheCREATESTRUCTFids(JNIEnv *env, jobject lpObject)
+{
+ if (CREATESTRUCTFc.cached) return;
+ CREATESTRUCTFc.clazz = (*env)->GetObjectClass(env, lpObject);
+ CREATESTRUCTFc.lpCreateParams = (*env)->GetFieldID(env, CREATESTRUCTFc.clazz, "lpCreateParams", "I");
+ CREATESTRUCTFc.hInstance = (*env)->GetFieldID(env, CREATESTRUCTFc.clazz, "hInstance", "I");
+ CREATESTRUCTFc.hMenu = (*env)->GetFieldID(env, CREATESTRUCTFc.clazz, "hMenu", "I");
+ CREATESTRUCTFc.hwndParent = (*env)->GetFieldID(env, CREATESTRUCTFc.clazz, "hwndParent", "I");
+ CREATESTRUCTFc.cy = (*env)->GetFieldID(env, CREATESTRUCTFc.clazz, "cy", "I");
+ CREATESTRUCTFc.cx = (*env)->GetFieldID(env, CREATESTRUCTFc.clazz, "cx", "I");
+ CREATESTRUCTFc.y = (*env)->GetFieldID(env, CREATESTRUCTFc.clazz, "y", "I");
+ CREATESTRUCTFc.x = (*env)->GetFieldID(env, CREATESTRUCTFc.clazz, "x", "I");
+ CREATESTRUCTFc.style = (*env)->GetFieldID(env, CREATESTRUCTFc.clazz, "style", "I");
+ CREATESTRUCTFc.lpszName = (*env)->GetFieldID(env, CREATESTRUCTFc.clazz, "lpszName", "I");
+ CREATESTRUCTFc.lpszClass = (*env)->GetFieldID(env, CREATESTRUCTFc.clazz, "lpszClass", "I");
+ CREATESTRUCTFc.dwExStyle = (*env)->GetFieldID(env, CREATESTRUCTFc.clazz, "dwExStyle", "I");
+ CREATESTRUCTFc.cached = 1;
+}
+
+CREATESTRUCT *getCREATESTRUCTFields(JNIEnv *env, jobject lpObject, CREATESTRUCT *lpStruct)
+{
+ if (!CREATESTRUCTFc.cached) cacheCREATESTRUCTFids(env, lpObject);
+ lpStruct->lpCreateParams = (LPVOID)(*env)->GetIntField(env, lpObject, CREATESTRUCTFc.lpCreateParams);
+ lpStruct->hInstance = (HINSTANCE)(*env)->GetIntField(env, lpObject, CREATESTRUCTFc.hInstance);
+ lpStruct->hMenu = (HMENU)(*env)->GetIntField(env, lpObject, CREATESTRUCTFc.hMenu);
+ lpStruct->hwndParent = (HWND)(*env)->GetIntField(env, lpObject, CREATESTRUCTFc.hwndParent);
+ lpStruct->cy = (*env)->GetIntField(env, lpObject, CREATESTRUCTFc.cy);
+ lpStruct->cx = (*env)->GetIntField(env, lpObject, CREATESTRUCTFc.cx);
+ lpStruct->y = (*env)->GetIntField(env, lpObject, CREATESTRUCTFc.y);
+ lpStruct->x = (*env)->GetIntField(env, lpObject, CREATESTRUCTFc.x);
+ lpStruct->style = (*env)->GetIntField(env, lpObject, CREATESTRUCTFc.style);
+ lpStruct->lpszName = (LPCTSTR)(*env)->GetIntField(env, lpObject, CREATESTRUCTFc.lpszName);
+ lpStruct->lpszClass = (LPCTSTR)(*env)->GetIntField(env, lpObject, CREATESTRUCTFc.lpszClass);
+ lpStruct->dwExStyle = (*env)->GetIntField(env, lpObject, CREATESTRUCTFc.dwExStyle);
+ return lpStruct;
+}
+
+void setCREATESTRUCTFields(JNIEnv *env, jobject lpObject, CREATESTRUCT *lpStruct)
+{
+ if (!CREATESTRUCTFc.cached) cacheCREATESTRUCTFids(env, lpObject);
+ (*env)->SetIntField(env, lpObject, CREATESTRUCTFc.lpCreateParams, (jint)lpStruct->lpCreateParams);
+ (*env)->SetIntField(env, lpObject, CREATESTRUCTFc.hInstance, (jint)lpStruct->hInstance);
+ (*env)->SetIntField(env, lpObject, CREATESTRUCTFc.hMenu, (jint)lpStruct->hMenu);
+ (*env)->SetIntField(env, lpObject, CREATESTRUCTFc.hwndParent, (jint)lpStruct->hwndParent);
+ (*env)->SetIntField(env, lpObject, CREATESTRUCTFc.cy, (jint)lpStruct->cy);
+ (*env)->SetIntField(env, lpObject, CREATESTRUCTFc.cx, (jint)lpStruct->cx);
+ (*env)->SetIntField(env, lpObject, CREATESTRUCTFc.y, (jint)lpStruct->y);
+ (*env)->SetIntField(env, lpObject, CREATESTRUCTFc.x, (jint)lpStruct->x);
+ (*env)->SetIntField(env, lpObject, CREATESTRUCTFc.style, (jint)lpStruct->style);
+ (*env)->SetIntField(env, lpObject, CREATESTRUCTFc.lpszName, (jint)lpStruct->lpszName);
+ (*env)->SetIntField(env, lpObject, CREATESTRUCTFc.lpszClass, (jint)lpStruct->lpszClass);
+ (*env)->SetIntField(env, lpObject, CREATESTRUCTFc.dwExStyle, (jint)lpStruct->dwExStyle);
+}
+#endif /* NO_CREATESTRUCT */
+
+#ifndef NO_DIBSECTION
+typedef struct DIBSECTION_FID_CACHE {
+ int cached;
+ jclass clazz;
+ jfieldID biSize, biWidth, biHeight, biPlanes, biBitCount, biCompression, biSizeImage, biXPelsPerMeter, biYPelsPerMeter, biClrUsed, biClrImportant, dsBitfields0, dsBitfields1, dsBitfields2, dshSection, dsOffset;
+} DIBSECTION_FID_CACHE;
+
+DIBSECTION_FID_CACHE DIBSECTIONFc;
+
+void cacheDIBSECTIONFids(JNIEnv *env, jobject lpObject)
+{
+ if (DIBSECTIONFc.cached) return;
+ cacheBITMAPFids(env, lpObject);
+ DIBSECTIONFc.clazz = (*env)->GetObjectClass(env, lpObject);
+ DIBSECTIONFc.biSize = (*env)->GetFieldID(env, DIBSECTIONFc.clazz, "biSize", "I");
+ DIBSECTIONFc.biWidth = (*env)->GetFieldID(env, DIBSECTIONFc.clazz, "biWidth", "I");
+ DIBSECTIONFc.biHeight = (*env)->GetFieldID(env, DIBSECTIONFc.clazz, "biHeight", "I");
+ DIBSECTIONFc.biPlanes = (*env)->GetFieldID(env, DIBSECTIONFc.clazz, "biPlanes", "S");
+ DIBSECTIONFc.biBitCount = (*env)->GetFieldID(env, DIBSECTIONFc.clazz, "biBitCount", "S");
+ DIBSECTIONFc.biCompression = (*env)->GetFieldID(env, DIBSECTIONFc.clazz, "biCompression", "I");
+ DIBSECTIONFc.biSizeImage = (*env)->GetFieldID(env, DIBSECTIONFc.clazz, "biSizeImage", "I");
+ DIBSECTIONFc.biXPelsPerMeter = (*env)->GetFieldID(env, DIBSECTIONFc.clazz, "biXPelsPerMeter", "I");
+ DIBSECTIONFc.biYPelsPerMeter = (*env)->GetFieldID(env, DIBSECTIONFc.clazz, "biYPelsPerMeter", "I");
+ DIBSECTIONFc.biClrUsed = (*env)->GetFieldID(env, DIBSECTIONFc.clazz, "biClrUsed", "I");
+ DIBSECTIONFc.biClrImportant = (*env)->GetFieldID(env, DIBSECTIONFc.clazz, "biClrImportant", "I");
+ DIBSECTIONFc.dsBitfields0 = (*env)->GetFieldID(env, DIBSECTIONFc.clazz, "dsBitfields0", "I");
+ DIBSECTIONFc.dsBitfields1 = (*env)->GetFieldID(env, DIBSECTIONFc.clazz, "dsBitfields1", "I");
+ DIBSECTIONFc.dsBitfields2 = (*env)->GetFieldID(env, DIBSECTIONFc.clazz, "dsBitfields2", "I");
+ DIBSECTIONFc.dshSection = (*env)->GetFieldID(env, DIBSECTIONFc.clazz, "dshSection", "I");
+ DIBSECTIONFc.dsOffset = (*env)->GetFieldID(env, DIBSECTIONFc.clazz, "dsOffset", "I");
+ DIBSECTIONFc.cached = 1;
+}
+
+DIBSECTION *getDIBSECTIONFields(JNIEnv *env, jobject lpObject, DIBSECTION *lpStruct)
+{
+ if (!DIBSECTIONFc.cached) cacheDIBSECTIONFids(env, lpObject);
+ getBITMAPFields(env, lpObject, (BITMAP *)lpStruct);
+ lpStruct->dsBmih.biSize = (*env)->GetIntField(env, lpObject, DIBSECTIONFc.biSize);
+ lpStruct->dsBmih.biWidth = (*env)->GetIntField(env, lpObject, DIBSECTIONFc.biWidth);
+ lpStruct->dsBmih.biHeight = (*env)->GetIntField(env, lpObject, DIBSECTIONFc.biHeight);
+ lpStruct->dsBmih.biPlanes = (*env)->GetShortField(env, lpObject, DIBSECTIONFc.biPlanes);
+ lpStruct->dsBmih.biBitCount = (*env)->GetShortField(env, lpObject, DIBSECTIONFc.biBitCount);
+ lpStruct->dsBmih.biCompression = (*env)->GetIntField(env, lpObject, DIBSECTIONFc.biCompression);
+ lpStruct->dsBmih.biSizeImage = (*env)->GetIntField(env, lpObject, DIBSECTIONFc.biSizeImage);
+ lpStruct->dsBmih.biXPelsPerMeter = (*env)->GetIntField(env, lpObject, DIBSECTIONFc.biXPelsPerMeter);
+ lpStruct->dsBmih.biYPelsPerMeter = (*env)->GetIntField(env, lpObject, DIBSECTIONFc.biYPelsPerMeter);
+ lpStruct->dsBmih.biClrUsed = (*env)->GetIntField(env, lpObject, DIBSECTIONFc.biClrUsed);
+ lpStruct->dsBmih.biClrImportant = (*env)->GetIntField(env, lpObject, DIBSECTIONFc.biClrImportant);
+ lpStruct->dsBitfields[0] = (*env)->GetIntField(env, lpObject, DIBSECTIONFc.dsBitfields0);
+ lpStruct->dsBitfields[1] = (*env)->GetIntField(env, lpObject, DIBSECTIONFc.dsBitfields1);
+ lpStruct->dsBitfields[2] = (*env)->GetIntField(env, lpObject, DIBSECTIONFc.dsBitfields2);
+ lpStruct->dshSection = (HANDLE)(*env)->GetIntField(env, lpObject, DIBSECTIONFc.dshSection);
+ lpStruct->dsOffset = (*env)->GetIntField(env, lpObject, DIBSECTIONFc.dsOffset);
+ return lpStruct;
+}
+
+void setDIBSECTIONFields(JNIEnv *env, jobject lpObject, DIBSECTION *lpStruct)
+{
+ if (!DIBSECTIONFc.cached) cacheDIBSECTIONFids(env, lpObject);
+ setBITMAPFields(env, lpObject, (BITMAP *)lpStruct);
+ (*env)->SetIntField(env, lpObject, DIBSECTIONFc.biSize, (jint)lpStruct->dsBmih.biSize);
+ (*env)->SetIntField(env, lpObject, DIBSECTIONFc.biWidth, (jint)lpStruct->dsBmih.biWidth);
+ (*env)->SetIntField(env, lpObject, DIBSECTIONFc.biHeight, (jint)lpStruct->dsBmih.biHeight);
+ (*env)->SetShortField(env, lpObject, DIBSECTIONFc.biPlanes, (jshort)lpStruct->dsBmih.biPlanes);
+ (*env)->SetShortField(env, lpObject, DIBSECTIONFc.biBitCount, (jshort)lpStruct->dsBmih.biBitCount);
+ (*env)->SetIntField(env, lpObject, DIBSECTIONFc.biCompression, (jint)lpStruct->dsBmih.biCompression);
+ (*env)->SetIntField(env, lpObject, DIBSECTIONFc.biSizeImage, (jint)lpStruct->dsBmih.biSizeImage);
+ (*env)->SetIntField(env, lpObject, DIBSECTIONFc.biXPelsPerMeter, (jint)lpStruct->dsBmih.biXPelsPerMeter);
+ (*env)->SetIntField(env, lpObject, DIBSECTIONFc.biYPelsPerMeter, (jint)lpStruct->dsBmih.biYPelsPerMeter);
+ (*env)->SetIntField(env, lpObject, DIBSECTIONFc.biClrUsed, (jint)lpStruct->dsBmih.biClrUsed);
+ (*env)->SetIntField(env, lpObject, DIBSECTIONFc.biClrImportant, (jint)lpStruct->dsBmih.biClrImportant);
+ (*env)->SetIntField(env, lpObject, DIBSECTIONFc.dsBitfields0, (jint)lpStruct->dsBitfields[0]);
+ (*env)->SetIntField(env, lpObject, DIBSECTIONFc.dsBitfields1, (jint)lpStruct->dsBitfields[1]);
+ (*env)->SetIntField(env, lpObject, DIBSECTIONFc.dsBitfields2, (jint)lpStruct->dsBitfields[2]);
+ (*env)->SetIntField(env, lpObject, DIBSECTIONFc.dshSection, (jint)lpStruct->dshSection);
+ (*env)->SetIntField(env, lpObject, DIBSECTIONFc.dsOffset, (jint)lpStruct->dsOffset);
+}
+#endif /* NO_DIBSECTION */
+
+#ifndef NO_DLLVERSIONINFO
+typedef struct DLLVERSIONINFO_FID_CACHE {
+ int cached;
+ jclass clazz;
+ jfieldID cbSize, dwMajorVersion, dwMinorVersion, dwBuildNumber, dwPlatformID;
+} DLLVERSIONINFO_FID_CACHE;
+
+DLLVERSIONINFO_FID_CACHE DLLVERSIONINFOFc;
+
+void cacheDLLVERSIONINFOFids(JNIEnv *env, jobject lpObject)
+{
+ if (DLLVERSIONINFOFc.cached) return;
+ DLLVERSIONINFOFc.clazz = (*env)->GetObjectClass(env, lpObject);
+ DLLVERSIONINFOFc.cbSize = (*env)->GetFieldID(env, DLLVERSIONINFOFc.clazz, "cbSize", "I");
+ DLLVERSIONINFOFc.dwMajorVersion = (*env)->GetFieldID(env, DLLVERSIONINFOFc.clazz, "dwMajorVersion", "I");
+ DLLVERSIONINFOFc.dwMinorVersion = (*env)->GetFieldID(env, DLLVERSIONINFOFc.clazz, "dwMinorVersion", "I");
+ DLLVERSIONINFOFc.dwBuildNumber = (*env)->GetFieldID(env, DLLVERSIONINFOFc.clazz, "dwBuildNumber", "I");
+ DLLVERSIONINFOFc.dwPlatformID = (*env)->GetFieldID(env, DLLVERSIONINFOFc.clazz, "dwPlatformID", "I");
+ DLLVERSIONINFOFc.cached = 1;
+}
+
+DLLVERSIONINFO *getDLLVERSIONINFOFields(JNIEnv *env, jobject lpObject, DLLVERSIONINFO *lpStruct)
+{
+ if (!DLLVERSIONINFOFc.cached) cacheDLLVERSIONINFOFids(env, lpObject);
+ lpStruct->cbSize = (*env)->GetIntField(env, lpObject, DLLVERSIONINFOFc.cbSize);
+ lpStruct->dwMajorVersion = (*env)->GetIntField(env, lpObject, DLLVERSIONINFOFc.dwMajorVersion);
+ lpStruct->dwMinorVersion = (*env)->GetIntField(env, lpObject, DLLVERSIONINFOFc.dwMinorVersion);
+ lpStruct->dwBuildNumber = (*env)->GetIntField(env, lpObject, DLLVERSIONINFOFc.dwBuildNumber);
+ lpStruct->dwPlatformID = (*env)->GetIntField(env, lpObject, DLLVERSIONINFOFc.dwPlatformID);
+ return lpStruct;
+}
+
+void setDLLVERSIONINFOFields(JNIEnv *env, jobject lpObject, DLLVERSIONINFO *lpStruct)
+{
+ if (!DLLVERSIONINFOFc.cached) cacheDLLVERSIONINFOFids(env, lpObject);
+ (*env)->SetIntField(env, lpObject, DLLVERSIONINFOFc.cbSize, (jint)lpStruct->cbSize);
+ (*env)->SetIntField(env, lpObject, DLLVERSIONINFOFc.dwMajorVersion, (jint)lpStruct->dwMajorVersion);
+ (*env)->SetIntField(env, lpObject, DLLVERSIONINFOFc.dwMinorVersion, (jint)lpStruct->dwMinorVersion);
+ (*env)->SetIntField(env, lpObject, DLLVERSIONINFOFc.dwBuildNumber, (jint)lpStruct->dwBuildNumber);
+ (*env)->SetIntField(env, lpObject, DLLVERSIONINFOFc.dwPlatformID, (jint)lpStruct->dwPlatformID);
+}
+#endif /* NO_DLLVERSIONINFO */
+
+#ifndef NO_DOCINFO
+typedef struct DOCINFO_FID_CACHE {
+ int cached;
+ jclass clazz;
+ jfieldID cbSize, lpszDocName, lpszOutput, lpszDatatype, fwType;
+} DOCINFO_FID_CACHE;
+
+DOCINFO_FID_CACHE DOCINFOFc;
+
+void cacheDOCINFOFids(JNIEnv *env, jobject lpObject)
+{
+ if (DOCINFOFc.cached) return;
+ DOCINFOFc.clazz = (*env)->GetObjectClass(env, lpObject);
+ DOCINFOFc.cbSize = (*env)->GetFieldID(env, DOCINFOFc.clazz, "cbSize", "I");
+ DOCINFOFc.lpszDocName = (*env)->GetFieldID(env, DOCINFOFc.clazz, "lpszDocName", "I");
+ DOCINFOFc.lpszOutput = (*env)->GetFieldID(env, DOCINFOFc.clazz, "lpszOutput", "I");
+ DOCINFOFc.lpszDatatype = (*env)->GetFieldID(env, DOCINFOFc.clazz, "lpszDatatype", "I");
+ DOCINFOFc.fwType = (*env)->GetFieldID(env, DOCINFOFc.clazz, "fwType", "I");
+ DOCINFOFc.cached = 1;
+}
+
+DOCINFO *getDOCINFOFields(JNIEnv *env, jobject lpObject, DOCINFO *lpStruct)
+{
+ if (!DOCINFOFc.cached) cacheDOCINFOFids(env, lpObject);
+ lpStruct->cbSize = (*env)->GetIntField(env, lpObject, DOCINFOFc.cbSize);
+ lpStruct->lpszDocName = (LPCTSTR)(*env)->GetIntField(env, lpObject, DOCINFOFc.lpszDocName);
+ lpStruct->lpszOutput = (LPCTSTR)(*env)->GetIntField(env, lpObject, DOCINFOFc.lpszOutput);
+ lpStruct->lpszDatatype = (LPCTSTR)(*env)->GetIntField(env, lpObject, DOCINFOFc.lpszDatatype);
+ lpStruct->fwType = (*env)->GetIntField(env, lpObject, DOCINFOFc.fwType);
+ return lpStruct;
+}
+
+void setDOCINFOFields(JNIEnv *env, jobject lpObject, DOCINFO *lpStruct)
+{
+ if (!DOCINFOFc.cached) cacheDOCINFOFids(env, lpObject);
+ (*env)->SetIntField(env, lpObject, DOCINFOFc.cbSize, (jint)lpStruct->cbSize);
+ (*env)->SetIntField(env, lpObject, DOCINFOFc.lpszDocName, (jint)lpStruct->lpszDocName);
+ (*env)->SetIntField(env, lpObject, DOCINFOFc.lpszOutput, (jint)lpStruct->lpszOutput);
+ (*env)->SetIntField(env, lpObject, DOCINFOFc.lpszDatatype, (jint)lpStruct->lpszDatatype);
+ (*env)->SetIntField(env, lpObject, DOCINFOFc.fwType, (jint)lpStruct->fwType);
+}
+#endif /* NO_DOCINFO */
+
+#ifndef NO_DRAWITEMSTRUCT
+typedef struct DRAWITEMSTRUCT_FID_CACHE {
+ int cached;
+ jclass clazz;
+ jfieldID CtlType, CtlID, itemID, itemAction, itemState, hwndItem, hDC, left, top, bottom, right, itemData;
+} DRAWITEMSTRUCT_FID_CACHE;
+
+DRAWITEMSTRUCT_FID_CACHE DRAWITEMSTRUCTFc;
+
+void cacheDRAWITEMSTRUCTFids(JNIEnv *env, jobject lpObject)
+{
+ if (DRAWITEMSTRUCTFc.cached) return;
+ DRAWITEMSTRUCTFc.clazz = (*env)->GetObjectClass(env, lpObject);
+ DRAWITEMSTRUCTFc.CtlType = (*env)->GetFieldID(env, DRAWITEMSTRUCTFc.clazz, "CtlType", "I");
+ DRAWITEMSTRUCTFc.CtlID = (*env)->GetFieldID(env, DRAWITEMSTRUCTFc.clazz, "CtlID", "I");
+ DRAWITEMSTRUCTFc.itemID = (*env)->GetFieldID(env, DRAWITEMSTRUCTFc.clazz, "itemID", "I");
+ DRAWITEMSTRUCTFc.itemAction = (*env)->GetFieldID(env, DRAWITEMSTRUCTFc.clazz, "itemAction", "I");
+ DRAWITEMSTRUCTFc.itemState = (*env)->GetFieldID(env, DRAWITEMSTRUCTFc.clazz, "itemState", "I");
+ DRAWITEMSTRUCTFc.hwndItem = (*env)->GetFieldID(env, DRAWITEMSTRUCTFc.clazz, "hwndItem", "I");
+ DRAWITEMSTRUCTFc.hDC = (*env)->GetFieldID(env, DRAWITEMSTRUCTFc.clazz, "hDC", "I");
+ DRAWITEMSTRUCTFc.left = (*env)->GetFieldID(env, DRAWITEMSTRUCTFc.clazz, "left", "I");
+ DRAWITEMSTRUCTFc.top = (*env)->GetFieldID(env, DRAWITEMSTRUCTFc.clazz, "top", "I");
+ DRAWITEMSTRUCTFc.bottom = (*env)->GetFieldID(env, DRAWITEMSTRUCTFc.clazz, "bottom", "I");
+ DRAWITEMSTRUCTFc.right = (*env)->GetFieldID(env, DRAWITEMSTRUCTFc.clazz, "right", "I");
+ DRAWITEMSTRUCTFc.itemData = (*env)->GetFieldID(env, DRAWITEMSTRUCTFc.clazz, "itemData", "I");
+ DRAWITEMSTRUCTFc.cached = 1;
+}
+
+DRAWITEMSTRUCT *getDRAWITEMSTRUCTFields(JNIEnv *env, jobject lpObject, DRAWITEMSTRUCT *lpStruct)
+{
+ if (!DRAWITEMSTRUCTFc.cached) cacheDRAWITEMSTRUCTFids(env, lpObject);
+ lpStruct->CtlType = (*env)->GetIntField(env, lpObject, DRAWITEMSTRUCTFc.CtlType);
+ lpStruct->CtlID = (*env)->GetIntField(env, lpObject, DRAWITEMSTRUCTFc.CtlID);
+ lpStruct->itemID = (*env)->GetIntField(env, lpObject, DRAWITEMSTRUCTFc.itemID);
+ lpStruct->itemAction = (*env)->GetIntField(env, lpObject, DRAWITEMSTRUCTFc.itemAction);
+ lpStruct->itemState = (*env)->GetIntField(env, lpObject, DRAWITEMSTRUCTFc.itemState);
+ lpStruct->hwndItem = (HWND)(*env)->GetIntField(env, lpObject, DRAWITEMSTRUCTFc.hwndItem);
+ lpStruct->hDC = (HDC)(*env)->GetIntField(env, lpObject, DRAWITEMSTRUCTFc.hDC);
+ lpStruct->rcItem.left = (*env)->GetIntField(env, lpObject, DRAWITEMSTRUCTFc.left);
+ lpStruct->rcItem.top = (*env)->GetIntField(env, lpObject, DRAWITEMSTRUCTFc.top);
+ lpStruct->rcItem.bottom = (*env)->GetIntField(env, lpObject, DRAWITEMSTRUCTFc.bottom);
+ lpStruct->rcItem.right = (*env)->GetIntField(env, lpObject, DRAWITEMSTRUCTFc.right);
+ lpStruct->itemData = (*env)->GetIntField(env, lpObject, DRAWITEMSTRUCTFc.itemData);
+ return lpStruct;
+}
+
+void setDRAWITEMSTRUCTFields(JNIEnv *env, jobject lpObject, DRAWITEMSTRUCT *lpStruct)
+{
+ if (!DRAWITEMSTRUCTFc.cached) cacheDRAWITEMSTRUCTFids(env, lpObject);
+ (*env)->SetIntField(env, lpObject, DRAWITEMSTRUCTFc.CtlType, (jint)lpStruct->CtlType);
+ (*env)->SetIntField(env, lpObject, DRAWITEMSTRUCTFc.CtlID, (jint)lpStruct->CtlID);
+ (*env)->SetIntField(env, lpObject, DRAWITEMSTRUCTFc.itemID, (jint)lpStruct->itemID);
+ (*env)->SetIntField(env, lpObject, DRAWITEMSTRUCTFc.itemAction, (jint)lpStruct->itemAction);
+ (*env)->SetIntField(env, lpObject, DRAWITEMSTRUCTFc.itemState, (jint)lpStruct->itemState);
+ (*env)->SetIntField(env, lpObject, DRAWITEMSTRUCTFc.hwndItem, (jint)lpStruct->hwndItem);
+ (*env)->SetIntField(env, lpObject, DRAWITEMSTRUCTFc.hDC, (jint)lpStruct->hDC);
+ (*env)->SetIntField(env, lpObject, DRAWITEMSTRUCTFc.left, (jint)lpStruct->rcItem.left);
+ (*env)->SetIntField(env, lpObject, DRAWITEMSTRUCTFc.top, (jint)lpStruct->rcItem.top);
+ (*env)->SetIntField(env, lpObject, DRAWITEMSTRUCTFc.bottom, (jint)lpStruct->rcItem.bottom);
+ (*env)->SetIntField(env, lpObject, DRAWITEMSTRUCTFc.right, (jint)lpStruct->rcItem.right);
+ (*env)->SetIntField(env, lpObject, DRAWITEMSTRUCTFc.itemData, (jint)lpStruct->itemData);
+}
+#endif /* NO_DRAWITEMSTRUCT */
+
+#ifndef NO_DROPFILES
+typedef struct DROPFILES_FID_CACHE {
+ int cached;
+ jclass clazz;
+ jfieldID pFiles, pt_x, pt_y, fNC, fWide;
+} DROPFILES_FID_CACHE;
+
+DROPFILES_FID_CACHE DROPFILESFc;
+
+void cacheDROPFILESFids(JNIEnv *env, jobject lpObject)
+{
+ if (DROPFILESFc.cached) return;
+ DROPFILESFc.clazz = (*env)->GetObjectClass(env, lpObject);
+ DROPFILESFc.pFiles = (*env)->GetFieldID(env, DROPFILESFc.clazz, "pFiles", "I");
+ DROPFILESFc.pt_x = (*env)->GetFieldID(env, DROPFILESFc.clazz, "pt_x", "I");
+ DROPFILESFc.pt_y = (*env)->GetFieldID(env, DROPFILESFc.clazz, "pt_y", "I");
+ DROPFILESFc.fNC = (*env)->GetFieldID(env, DROPFILESFc.clazz, "fNC", "I");
+ DROPFILESFc.fWide = (*env)->GetFieldID(env, DROPFILESFc.clazz, "fWide", "I");
+ DROPFILESFc.cached = 1;
+}
+
+DROPFILES *getDROPFILESFields(JNIEnv *env, jobject lpObject, DROPFILES *lpStruct)
+{
+ if (!DROPFILESFc.cached) cacheDROPFILESFids(env, lpObject);
+ lpStruct->pFiles = (*env)->GetIntField(env, lpObject, DROPFILESFc.pFiles);
+ lpStruct->pt.x = (*env)->GetIntField(env, lpObject, DROPFILESFc.pt_x);
+ lpStruct->pt.y = (*env)->GetIntField(env, lpObject, DROPFILESFc.pt_y);
+ lpStruct->fNC = (*env)->GetIntField(env, lpObject, DROPFILESFc.fNC);
+ lpStruct->fWide = (*env)->GetIntField(env, lpObject, DROPFILESFc.fWide);
+ return lpStruct;
+}
+
+void setDROPFILESFields(JNIEnv *env, jobject lpObject, DROPFILES *lpStruct)
+{
+ if (!DROPFILESFc.cached) cacheDROPFILESFids(env, lpObject);
+ (*env)->SetIntField(env, lpObject, DROPFILESFc.pFiles, (jint)lpStruct->pFiles);
+ (*env)->SetIntField(env, lpObject, DROPFILESFc.pt_x, (jint)lpStruct->pt.x);
+ (*env)->SetIntField(env, lpObject, DROPFILESFc.pt_y, (jint)lpStruct->pt.y);
+ (*env)->SetIntField(env, lpObject, DROPFILESFc.fNC, (jint)lpStruct->fNC);
+ (*env)->SetIntField(env, lpObject, DROPFILESFc.fWide, (jint)lpStruct->fWide);
+}
+#endif /* NO_DROPFILES */
+
+#ifndef NO_FILETIME
+typedef struct FILETIME_FID_CACHE {
+ int cached;
+ jclass clazz;
+ jfieldID dwLowDateTime, dwHighDateTime;
+} FILETIME_FID_CACHE;
+
+FILETIME_FID_CACHE FILETIMEFc;
+
+void cacheFILETIMEFids(JNIEnv *env, jobject lpObject)
+{
+ if (FILETIMEFc.cached) return;
+ FILETIMEFc.clazz = (*env)->GetObjectClass(env, lpObject);
+ FILETIMEFc.dwLowDateTime = (*env)->GetFieldID(env, FILETIMEFc.clazz, "dwLowDateTime", "I");
+ FILETIMEFc.dwHighDateTime = (*env)->GetFieldID(env, FILETIMEFc.clazz, "dwHighDateTime", "I");
+ FILETIMEFc.cached = 1;
+}
+
+FILETIME *getFILETIMEFields(JNIEnv *env, jobject lpObject, FILETIME *lpStruct)
+{
+ if (!FILETIMEFc.cached) cacheFILETIMEFids(env, lpObject);
+ lpStruct->dwLowDateTime = (*env)->GetIntField(env, lpObject, FILETIMEFc.dwLowDateTime);
+ lpStruct->dwHighDateTime = (*env)->GetIntField(env, lpObject, FILETIMEFc.dwHighDateTime);
+ return lpStruct;
+}
+
+void setFILETIMEFields(JNIEnv *env, jobject lpObject, FILETIME *lpStruct)
+{
+ if (!FILETIMEFc.cached) cacheFILETIMEFids(env, lpObject);
+ (*env)->SetIntField(env, lpObject, FILETIMEFc.dwLowDateTime, (jint)lpStruct->dwLowDateTime);
+ (*env)->SetIntField(env, lpObject, FILETIMEFc.dwHighDateTime, (jint)lpStruct->dwHighDateTime);
+}
+#endif /* NO_FILETIME */
+
+#ifndef NO_GCP_RESULTS
+typedef struct GCP_RESULTS_FID_CACHE {
+ int cached;
+ jclass clazz;
+ jfieldID lStructSize, lpOutString, lpOrder, lpDx, lpCaretPos, lpClass, lpGlyphs, nGlyphs, nMaxFit;
+} GCP_RESULTS_FID_CACHE;
+
+GCP_RESULTS_FID_CACHE GCP_RESULTSFc;
+
+void cacheGCP_RESULTSFids(JNIEnv *env, jobject lpObject)
+{
+ if (GCP_RESULTSFc.cached) return;
+ GCP_RESULTSFc.clazz = (*env)->GetObjectClass(env, lpObject);
+ GCP_RESULTSFc.lStructSize = (*env)->GetFieldID(env, GCP_RESULTSFc.clazz, "lStructSize", "I");
+ GCP_RESULTSFc.lpOutString = (*env)->GetFieldID(env, GCP_RESULTSFc.clazz, "lpOutString", "I");
+ GCP_RESULTSFc.lpOrder = (*env)->GetFieldID(env, GCP_RESULTSFc.clazz, "lpOrder", "I");
+ GCP_RESULTSFc.lpDx = (*env)->GetFieldID(env, GCP_RESULTSFc.clazz, "lpDx", "I");
+ GCP_RESULTSFc.lpCaretPos = (*env)->GetFieldID(env, GCP_RESULTSFc.clazz, "lpCaretPos", "I");
+ GCP_RESULTSFc.lpClass = (*env)->GetFieldID(env, GCP_RESULTSFc.clazz, "lpClass", "I");
+ GCP_RESULTSFc.lpGlyphs = (*env)->GetFieldID(env, GCP_RESULTSFc.clazz, "lpGlyphs", "I");
+ GCP_RESULTSFc.nGlyphs = (*env)->GetFieldID(env, GCP_RESULTSFc.clazz, "nGlyphs", "I");
+ GCP_RESULTSFc.nMaxFit = (*env)->GetFieldID(env, GCP_RESULTSFc.clazz, "nMaxFit", "I");
+ GCP_RESULTSFc.cached = 1;
+}
+
+GCP_RESULTS *getGCP_RESULTSFields(JNIEnv *env, jobject lpObject, GCP_RESULTS *lpStruct)
+{
+ if (!GCP_RESULTSFc.cached) cacheGCP_RESULTSFids(env, lpObject);
+ lpStruct->lStructSize = (*env)->GetIntField(env, lpObject, GCP_RESULTSFc.lStructSize);
+ lpStruct->lpOutString = (LPTSTR)(*env)->GetIntField(env, lpObject, GCP_RESULTSFc.lpOutString);
+ lpStruct->lpOrder = (UINT *)(*env)->GetIntField(env, lpObject, GCP_RESULTSFc.lpOrder);
+ lpStruct->lpDx = (int *)(*env)->GetIntField(env, lpObject, GCP_RESULTSFc.lpDx);
+ lpStruct->lpCaretPos = (int *)(*env)->GetIntField(env, lpObject, GCP_RESULTSFc.lpCaretPos);
+ lpStruct->lpClass = (LPSTR)(*env)->GetIntField(env, lpObject, GCP_RESULTSFc.lpClass);
+ lpStruct->lpGlyphs = (LPWSTR)(*env)->GetIntField(env, lpObject, GCP_RESULTSFc.lpGlyphs);
+ lpStruct->nGlyphs = (*env)->GetIntField(env, lpObject, GCP_RESULTSFc.nGlyphs);
+ lpStruct->nMaxFit = (*env)->GetIntField(env, lpObject, GCP_RESULTSFc.nMaxFit);
+ return lpStruct;
+}
+
+void setGCP_RESULTSFields(JNIEnv *env, jobject lpObject, GCP_RESULTS *lpStruct)
+{
+ if (!GCP_RESULTSFc.cached) cacheGCP_RESULTSFids(env, lpObject);
+ (*env)->SetIntField(env, lpObject, GCP_RESULTSFc.lStructSize, (jint)lpStruct->lStructSize);
+ (*env)->SetIntField(env, lpObject, GCP_RESULTSFc.lpOutString, (jint)lpStruct->lpOutString);
+ (*env)->SetIntField(env, lpObject, GCP_RESULTSFc.lpOrder, (jint)lpStruct->lpOrder);
+ (*env)->SetIntField(env, lpObject, GCP_RESULTSFc.lpDx, (jint)lpStruct->lpDx);
+ (*env)->SetIntField(env, lpObject, GCP_RESULTSFc.lpCaretPos, (jint)lpStruct->lpCaretPos);
+ (*env)->SetIntField(env, lpObject, GCP_RESULTSFc.lpClass, (jint)lpStruct->lpClass);
+ (*env)->SetIntField(env, lpObject, GCP_RESULTSFc.lpGlyphs, (jint)lpStruct->lpGlyphs);
+ (*env)->SetIntField(env, lpObject, GCP_RESULTSFc.nGlyphs, (jint)lpStruct->nGlyphs);
+ (*env)->SetIntField(env, lpObject, GCP_RESULTSFc.nMaxFit, (jint)lpStruct->nMaxFit);
+}
+#endif /* NO_GCP_RESULTS */
+
+#ifndef NO_GRADIENT_RECT
+typedef struct GRADIENT_RECT_FID_CACHE {
+ int cached;
+ jclass clazz;
+ jfieldID UpperLeft, LowerRight;
+} GRADIENT_RECT_FID_CACHE;
+
+GRADIENT_RECT_FID_CACHE GRADIENT_RECTFc;
+
+void cacheGRADIENT_RECTFids(JNIEnv *env, jobject lpObject)
+{
+ if (GRADIENT_RECTFc.cached) return;
+ GRADIENT_RECTFc.clazz = (*env)->GetObjectClass(env, lpObject);
+ GRADIENT_RECTFc.UpperLeft = (*env)->GetFieldID(env, GRADIENT_RECTFc.clazz, "UpperLeft", "I");
+ GRADIENT_RECTFc.LowerRight = (*env)->GetFieldID(env, GRADIENT_RECTFc.clazz, "LowerRight", "I");
+ GRADIENT_RECTFc.cached = 1;
+}
+
+GRADIENT_RECT *getGRADIENT_RECTFields(JNIEnv *env, jobject lpObject, GRADIENT_RECT *lpStruct)
+{
+ if (!GRADIENT_RECTFc.cached) cacheGRADIENT_RECTFids(env, lpObject);
+ lpStruct->UpperLeft = (*env)->GetIntField(env, lpObject, GRADIENT_RECTFc.UpperLeft);
+ lpStruct->LowerRight = (*env)->GetIntField(env, lpObject, GRADIENT_RECTFc.LowerRight);
+ return lpStruct;
+}
+
+void setGRADIENT_RECTFields(JNIEnv *env, jobject lpObject, GRADIENT_RECT *lpStruct)
+{
+ if (!GRADIENT_RECTFc.cached) cacheGRADIENT_RECTFids(env, lpObject);
+ (*env)->SetIntField(env, lpObject, GRADIENT_RECTFc.UpperLeft, (jint)lpStruct->UpperLeft);
+ (*env)->SetIntField(env, lpObject, GRADIENT_RECTFc.LowerRight, (jint)lpStruct->LowerRight);
+}
+#endif /* NO_GRADIENT_RECT */
+
+#ifndef NO_HDITEM
+typedef struct HDITEM_FID_CACHE {
+ int cached;
+ jclass clazz;
+ jfieldID mask, cxy, pszText, hbm, cchTextMax, fmt, lParam, iImage, iOrder;
+} HDITEM_FID_CACHE;
+
+HDITEM_FID_CACHE HDITEMFc;
+
+void cacheHDITEMFids(JNIEnv *env, jobject lpObject)
+{
+ if (HDITEMFc.cached) return;
+ HDITEMFc.clazz = (*env)->GetObjectClass(env, lpObject);
+ HDITEMFc.mask = (*env)->GetFieldID(env, HDITEMFc.clazz, "mask", "I");
+ HDITEMFc.cxy = (*env)->GetFieldID(env, HDITEMFc.clazz, "cxy", "I");
+ HDITEMFc.pszText = (*env)->GetFieldID(env, HDITEMFc.clazz, "pszText", "I");
+ HDITEMFc.hbm = (*env)->GetFieldID(env, HDITEMFc.clazz, "hbm", "I");
+ HDITEMFc.cchTextMax = (*env)->GetFieldID(env, HDITEMFc.clazz, "cchTextMax", "I");
+ HDITEMFc.fmt = (*env)->GetFieldID(env, HDITEMFc.clazz, "fmt", "I");
+ HDITEMFc.lParam = (*env)->GetFieldID(env, HDITEMFc.clazz, "lParam", "I");
+ HDITEMFc.iImage = (*env)->GetFieldID(env, HDITEMFc.clazz, "iImage", "I");
+ HDITEMFc.iOrder = (*env)->GetFieldID(env, HDITEMFc.clazz, "iOrder", "I");
+ HDITEMFc.cached = 1;
+}
+
+HDITEM *getHDITEMFields(JNIEnv *env, jobject lpObject, HDITEM *lpStruct)
+{
+ if (!HDITEMFc.cached) cacheHDITEMFids(env, lpObject);
+ lpStruct->mask = (*env)->GetIntField(env, lpObject, HDITEMFc.mask);
+ lpStruct->cxy = (*env)->GetIntField(env, lpObject, HDITEMFc.cxy);
+ lpStruct->pszText = (LPTSTR)(*env)->GetIntField(env, lpObject, HDITEMFc.pszText);
+ lpStruct->hbm = (HBITMAP)(*env)->GetIntField(env, lpObject, HDITEMFc.hbm);
+ lpStruct->cchTextMax = (*env)->GetIntField(env, lpObject, HDITEMFc.cchTextMax);
+ lpStruct->fmt = (*env)->GetIntField(env, lpObject, HDITEMFc.fmt);
+ lpStruct->lParam = (*env)->GetIntField(env, lpObject, HDITEMFc.lParam);
+ lpStruct->iImage = (*env)->GetIntField(env, lpObject, HDITEMFc.iImage);
+ lpStruct->iOrder = (*env)->GetIntField(env, lpObject, HDITEMFc.iOrder);
+ return lpStruct;
+}
+
+void setHDITEMFields(JNIEnv *env, jobject lpObject, HDITEM *lpStruct)
+{
+ if (!HDITEMFc.cached) cacheHDITEMFids(env, lpObject);
+ (*env)->SetIntField(env, lpObject, HDITEMFc.mask, (jint)lpStruct->mask);
+ (*env)->SetIntField(env, lpObject, HDITEMFc.cxy, (jint)lpStruct->cxy);
+ (*env)->SetIntField(env, lpObject, HDITEMFc.pszText, (jint)lpStruct->pszText);
+ (*env)->SetIntField(env, lpObject, HDITEMFc.hbm, (jint)lpStruct->hbm);
+ (*env)->SetIntField(env, lpObject, HDITEMFc.cchTextMax, (jint)lpStruct->cchTextMax);
+ (*env)->SetIntField(env, lpObject, HDITEMFc.fmt, (jint)lpStruct->fmt);
+ (*env)->SetIntField(env, lpObject, HDITEMFc.lParam, (jint)lpStruct->lParam);
+ (*env)->SetIntField(env, lpObject, HDITEMFc.iImage, (jint)lpStruct->iImage);
+ (*env)->SetIntField(env, lpObject, HDITEMFc.iOrder, (jint)lpStruct->iOrder);
+}
+#endif /* NO_HDITEM */
+
+#ifndef NO_HELPINFO
+typedef struct HELPINFO_FID_CACHE {
+ int cached;
+ jclass clazz;
+ jfieldID cbSize, iContextType, iCtrlId, hItemHandle, dwContextId, x, y;
+} HELPINFO_FID_CACHE;
+
+HELPINFO_FID_CACHE HELPINFOFc;
+
+void cacheHELPINFOFids(JNIEnv *env, jobject lpObject)
+{
+ if (HELPINFOFc.cached) return;
+ HELPINFOFc.clazz = (*env)->GetObjectClass(env, lpObject);
+ HELPINFOFc.cbSize = (*env)->GetFieldID(env, HELPINFOFc.clazz, "cbSize", "I");
+ HELPINFOFc.iContextType = (*env)->GetFieldID(env, HELPINFOFc.clazz, "iContextType", "I");
+ HELPINFOFc.iCtrlId = (*env)->GetFieldID(env, HELPINFOFc.clazz, "iCtrlId", "I");
+ HELPINFOFc.hItemHandle = (*env)->GetFieldID(env, HELPINFOFc.clazz, "hItemHandle", "I");
+ HELPINFOFc.dwContextId = (*env)->GetFieldID(env, HELPINFOFc.clazz, "dwContextId", "I");
+ HELPINFOFc.x = (*env)->GetFieldID(env, HELPINFOFc.clazz, "x", "I");
+ HELPINFOFc.y = (*env)->GetFieldID(env, HELPINFOFc.clazz, "y", "I");
+ HELPINFOFc.cached = 1;
+}
+
+HELPINFO *getHELPINFOFields(JNIEnv *env, jobject lpObject, HELPINFO *lpStruct)
+{
+ if (!HELPINFOFc.cached) cacheHELPINFOFids(env, lpObject);
+ lpStruct->cbSize = (*env)->GetIntField(env, lpObject, HELPINFOFc.cbSize);
+ lpStruct->iContextType = (*env)->GetIntField(env, lpObject, HELPINFOFc.iContextType);
+ lpStruct->iCtrlId = (*env)->GetIntField(env, lpObject, HELPINFOFc.iCtrlId);
+ lpStruct->hItemHandle = (HANDLE)(*env)->GetIntField(env, lpObject, HELPINFOFc.hItemHandle);
+ lpStruct->dwContextId = (*env)->GetIntField(env, lpObject, HELPINFOFc.dwContextId);
+ lpStruct->MousePos.x = (*env)->GetIntField(env, lpObject, HELPINFOFc.x);
+ lpStruct->MousePos.y = (*env)->GetIntField(env, lpObject, HELPINFOFc.y);
+ return lpStruct;
+}
+
+void setHELPINFOFields(JNIEnv *env, jobject lpObject, HELPINFO *lpStruct)
+{
+ if (!HELPINFOFc.cached) cacheHELPINFOFids(env, lpObject);
+ (*env)->SetIntField(env, lpObject, HELPINFOFc.cbSize, (jint)lpStruct->cbSize);
+ (*env)->SetIntField(env, lpObject, HELPINFOFc.iContextType, (jint)lpStruct->iContextType);
+ (*env)->SetIntField(env, lpObject, HELPINFOFc.iCtrlId, (jint)lpStruct->iCtrlId);
+ (*env)->SetIntField(env, lpObject, HELPINFOFc.hItemHandle, (jint)lpStruct->hItemHandle);
+ (*env)->SetIntField(env, lpObject, HELPINFOFc.dwContextId, (jint)lpStruct->dwContextId);
+ (*env)->SetIntField(env, lpObject, HELPINFOFc.x, (jint)lpStruct->MousePos.x);
+ (*env)->SetIntField(env, lpObject, HELPINFOFc.y, (jint)lpStruct->MousePos.y);
+}
+#endif /* NO_HELPINFO */
+
+#ifndef NO_ICONINFO
+typedef struct ICONINFO_FID_CACHE {
+ int cached;
+ jclass clazz;
+ jfieldID fIcon, xHotspot, yHotspot, hbmMask, hbmColor;
+} ICONINFO_FID_CACHE;
+
+ICONINFO_FID_CACHE ICONINFOFc;
+
+void cacheICONINFOFids(JNIEnv *env, jobject lpObject)
+{
+ if (ICONINFOFc.cached) return;
+ ICONINFOFc.clazz = (*env)->GetObjectClass(env, lpObject);
+ ICONINFOFc.fIcon = (*env)->GetFieldID(env, ICONINFOFc.clazz, "fIcon", "Z");
+ ICONINFOFc.xHotspot = (*env)->GetFieldID(env, ICONINFOFc.clazz, "xHotspot", "I");
+ ICONINFOFc.yHotspot = (*env)->GetFieldID(env, ICONINFOFc.clazz, "yHotspot", "I");
+ ICONINFOFc.hbmMask = (*env)->GetFieldID(env, ICONINFOFc.clazz, "hbmMask", "I");
+ ICONINFOFc.hbmColor = (*env)->GetFieldID(env, ICONINFOFc.clazz, "hbmColor", "I");
+ ICONINFOFc.cached = 1;
+}
+
+ICONINFO *getICONINFOFields(JNIEnv *env, jobject lpObject, ICONINFO *lpStruct)
+{
+ if (!ICONINFOFc.cached) cacheICONINFOFids(env, lpObject);
+ lpStruct->fIcon = (*env)->GetBooleanField(env, lpObject, ICONINFOFc.fIcon);
+ lpStruct->xHotspot = (*env)->GetIntField(env, lpObject, ICONINFOFc.xHotspot);
+ lpStruct->yHotspot = (*env)->GetIntField(env, lpObject, ICONINFOFc.yHotspot);
+ lpStruct->hbmMask = (HBITMAP)(*env)->GetIntField(env, lpObject, ICONINFOFc.hbmMask);
+ lpStruct->hbmColor = (HBITMAP)(*env)->GetIntField(env, lpObject, ICONINFOFc.hbmColor);
+ return lpStruct;
+}
+
+void setICONINFOFields(JNIEnv *env, jobject lpObject, ICONINFO *lpStruct)
+{
+ if (!ICONINFOFc.cached) cacheICONINFOFids(env, lpObject);
+ (*env)->SetBooleanField(env, lpObject, ICONINFOFc.fIcon, (jboolean)lpStruct->fIcon);
+ (*env)->SetIntField(env, lpObject, ICONINFOFc.xHotspot, (jint)lpStruct->xHotspot);
+ (*env)->SetIntField(env, lpObject, ICONINFOFc.yHotspot, (jint)lpStruct->yHotspot);
+ (*env)->SetIntField(env, lpObject, ICONINFOFc.hbmMask, (jint)lpStruct->hbmMask);
+ (*env)->SetIntField(env, lpObject, ICONINFOFc.hbmColor, (jint)lpStruct->hbmColor);
+}
+#endif /* NO_ICONINFO */
+
+#ifndef NO_INITCOMMONCONTROLSEX
+typedef struct INITCOMMONCONTROLSEX_FID_CACHE {
+ int cached;
+ jclass clazz;
+ jfieldID dwSize, dwICC;
+} INITCOMMONCONTROLSEX_FID_CACHE;
+
+INITCOMMONCONTROLSEX_FID_CACHE INITCOMMONCONTROLSEXFc;
+
+void cacheINITCOMMONCONTROLSEXFids(JNIEnv *env, jobject lpObject)
+{
+ if (INITCOMMONCONTROLSEXFc.cached) return;
+ INITCOMMONCONTROLSEXFc.clazz = (*env)->GetObjectClass(env, lpObject);
+ INITCOMMONCONTROLSEXFc.dwSize = (*env)->GetFieldID(env, INITCOMMONCONTROLSEXFc.clazz, "dwSize", "I");
+ INITCOMMONCONTROLSEXFc.dwICC = (*env)->GetFieldID(env, INITCOMMONCONTROLSEXFc.clazz, "dwICC", "I");
+ INITCOMMONCONTROLSEXFc.cached = 1;
+}
+
+INITCOMMONCONTROLSEX *getINITCOMMONCONTROLSEXFields(JNIEnv *env, jobject lpObject, INITCOMMONCONTROLSEX *lpStruct)
+{
+ if (!INITCOMMONCONTROLSEXFc.cached) cacheINITCOMMONCONTROLSEXFids(env, lpObject);
+ lpStruct->dwSize = (*env)->GetIntField(env, lpObject, INITCOMMONCONTROLSEXFc.dwSize);
+ lpStruct->dwICC = (*env)->GetIntField(env, lpObject, INITCOMMONCONTROLSEXFc.dwICC);
+ return lpStruct;
+}
+
+void setINITCOMMONCONTROLSEXFields(JNIEnv *env, jobject lpObject, INITCOMMONCONTROLSEX *lpStruct)
+{
+ if (!INITCOMMONCONTROLSEXFc.cached) cacheINITCOMMONCONTROLSEXFids(env, lpObject);
+ (*env)->SetIntField(env, lpObject, INITCOMMONCONTROLSEXFc.dwSize, (jint)lpStruct->dwSize);
+ (*env)->SetIntField(env, lpObject, INITCOMMONCONTROLSEXFc.dwICC, (jint)lpStruct->dwICC);
+}
+#endif /* NO_INITCOMMONCONTROLSEX */
+
+#ifndef NO_LOGBRUSH
+typedef struct LOGBRUSH_FID_CACHE {
+ int cached;
+ jclass clazz;
+ jfieldID lbStyle, lbColor, lbHatch;
+} LOGBRUSH_FID_CACHE;
+
+LOGBRUSH_FID_CACHE LOGBRUSHFc;
+
+void cacheLOGBRUSHFids(JNIEnv *env, jobject lpObject)
+{
+ if (LOGBRUSHFc.cached) return;
+ LOGBRUSHFc.clazz = (*env)->GetObjectClass(env, lpObject);
+ LOGBRUSHFc.lbStyle = (*env)->GetFieldID(env, LOGBRUSHFc.clazz, "lbStyle", "I");
+ LOGBRUSHFc.lbColor = (*env)->GetFieldID(env, LOGBRUSHFc.clazz, "lbColor", "I");
+ LOGBRUSHFc.lbHatch = (*env)->GetFieldID(env, LOGBRUSHFc.clazz, "lbHatch", "I");
+ LOGBRUSHFc.cached = 1;
+}
+
+LOGBRUSH *getLOGBRUSHFields(JNIEnv *env, jobject lpObject, LOGBRUSH *lpStruct)
+{
+ if (!LOGBRUSHFc.cached) cacheLOGBRUSHFids(env, lpObject);
+ lpStruct->lbStyle = (*env)->GetIntField(env, lpObject, LOGBRUSHFc.lbStyle);
+ lpStruct->lbColor = (*env)->GetIntField(env, lpObject, LOGBRUSHFc.lbColor);
+ lpStruct->lbHatch = (*env)->GetIntField(env, lpObject, LOGBRUSHFc.lbHatch);
+ return lpStruct;
+}
+
+void setLOGBRUSHFields(JNIEnv *env, jobject lpObject, LOGBRUSH *lpStruct)
+{
+ if (!LOGBRUSHFc.cached) cacheLOGBRUSHFids(env, lpObject);
+ (*env)->SetIntField(env, lpObject, LOGBRUSHFc.lbStyle, (jint)lpStruct->lbStyle);
+ (*env)->SetIntField(env, lpObject, LOGBRUSHFc.lbColor, (jint)lpStruct->lbColor);
+ (*env)->SetIntField(env, lpObject, LOGBRUSHFc.lbHatch, (jint)lpStruct->lbHatch);
+}
+#endif /* NO_LOGBRUSH */
+
+#ifndef NO_LOGFONT
+typedef struct LOGFONT_FID_CACHE {
+ int cached;
+ jclass clazz;
+ 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;
+
+LOGFONT_FID_CACHE LOGFONTFc;
+
+void cacheLOGFONTFids(JNIEnv *env, jobject lpObject)
+{
+ if (LOGFONTFc.cached) return;
+ LOGFONTFc.clazz = (*env)->GetObjectClass(env, lpObject);
+ LOGFONTFc.lfHeight = (*env)->GetFieldID(env, LOGFONTFc.clazz, "lfHeight", "I");
+ LOGFONTFc.lfWidth = (*env)->GetFieldID(env, LOGFONTFc.clazz, "lfWidth", "I");
+ LOGFONTFc.lfEscapement = (*env)->GetFieldID(env, LOGFONTFc.clazz, "lfEscapement", "I");
+ LOGFONTFc.lfOrientation = (*env)->GetFieldID(env, LOGFONTFc.clazz, "lfOrientation", "I");
+ LOGFONTFc.lfWeight = (*env)->GetFieldID(env, LOGFONTFc.clazz, "lfWeight", "I");
+ LOGFONTFc.lfItalic = (*env)->GetFieldID(env, LOGFONTFc.clazz, "lfItalic", "B");
+ LOGFONTFc.lfUnderline = (*env)->GetFieldID(env, LOGFONTFc.clazz, "lfUnderline", "B");
+ LOGFONTFc.lfStrikeOut = (*env)->GetFieldID(env, LOGFONTFc.clazz, "lfStrikeOut", "B");
+ LOGFONTFc.lfCharSet = (*env)->GetFieldID(env, LOGFONTFc.clazz, "lfCharSet", "B");
+ LOGFONTFc.lfOutPrecision = (*env)->GetFieldID(env, LOGFONTFc.clazz, "lfOutPrecision", "B");
+ LOGFONTFc.lfClipPrecision = (*env)->GetFieldID(env, LOGFONTFc.clazz, "lfClipPrecision", "B");
+ LOGFONTFc.lfQuality = (*env)->GetFieldID(env, LOGFONTFc.clazz, "lfQuality", "B");
+ LOGFONTFc.lfPitchAndFamily = (*env)->GetFieldID(env, LOGFONTFc.clazz, "lfPitchAndFamily", "B");
+ LOGFONTFc.lfFaceName0 = (*env)->GetFieldID(env, LOGFONTFc.clazz, "lfFaceName0", "C");
+ LOGFONTFc.lfFaceName1 = (*env)->GetFieldID(env, LOGFONTFc.clazz, "lfFaceName1", "C");
+ LOGFONTFc.lfFaceName2 = (*env)->GetFieldID(env, LOGFONTFc.clazz, "lfFaceName2", "C");
+ LOGFONTFc.lfFaceName3 = (*env)->GetFieldID(env, LOGFONTFc.clazz, "lfFaceName3", "C");
+ LOGFONTFc.lfFaceName4 = (*env)->GetFieldID(env, LOGFONTFc.clazz, "lfFaceName4", "C");
+ LOGFONTFc.lfFaceName5 = (*env)->GetFieldID(env, LOGFONTFc.clazz, "lfFaceName5", "C");
+ LOGFONTFc.lfFaceName6 = (*env)->GetFieldID(env, LOGFONTFc.clazz, "lfFaceName6", "C");
+ LOGFONTFc.lfFaceName7 = (*env)->GetFieldID(env, LOGFONTFc.clazz, "lfFaceName7", "C");
+ LOGFONTFc.lfFaceName8 = (*env)->GetFieldID(env, LOGFONTFc.clazz, "lfFaceName8", "C");
+ LOGFONTFc.lfFaceName9 = (*env)->GetFieldID(env, LOGFONTFc.clazz, "lfFaceName9", "C");
+ LOGFONTFc.lfFaceName10 = (*env)->GetFieldID(env, LOGFONTFc.clazz, "lfFaceName10", "C");
+ LOGFONTFc.lfFaceName11 = (*env)->GetFieldID(env, LOGFONTFc.clazz, "lfFaceName11", "C");
+ LOGFONTFc.lfFaceName12 = (*env)->GetFieldID(env, LOGFONTFc.clazz, "lfFaceName12", "C");
+ LOGFONTFc.lfFaceName13 = (*env)->GetFieldID(env, LOGFONTFc.clazz, "lfFaceName13", "C");
+ LOGFONTFc.lfFaceName14 = (*env)->GetFieldID(env, LOGFONTFc.clazz, "lfFaceName14", "C");
+ LOGFONTFc.lfFaceName15 = (*env)->GetFieldID(env, LOGFONTFc.clazz, "lfFaceName15", "C");
+ LOGFONTFc.lfFaceName16 = (*env)->GetFieldID(env, LOGFONTFc.clazz, "lfFaceName16", "C");
+ LOGFONTFc.lfFaceName17 = (*env)->GetFieldID(env, LOGFONTFc.clazz, "lfFaceName17", "C");
+ LOGFONTFc.lfFaceName18 = (*env)->GetFieldID(env, LOGFONTFc.clazz, "lfFaceName18", "C");
+ LOGFONTFc.lfFaceName19 = (*env)->GetFieldID(env, LOGFONTFc.clazz, "lfFaceName19", "C");
+ LOGFONTFc.lfFaceName20 = (*env)->GetFieldID(env, LOGFONTFc.clazz, "lfFaceName20", "C");
+ LOGFONTFc.lfFaceName21 = (*env)->GetFieldID(env, LOGFONTFc.clazz, "lfFaceName21", "C");
+ LOGFONTFc.lfFaceName22 = (*env)->GetFieldID(env, LOGFONTFc.clazz, "lfFaceName22", "C");
+ LOGFONTFc.lfFaceName23 = (*env)->GetFieldID(env, LOGFONTFc.clazz, "lfFaceName23", "C");
+ LOGFONTFc.lfFaceName24 = (*env)->GetFieldID(env, LOGFONTFc.clazz, "lfFaceName24", "C");
+ LOGFONTFc.lfFaceName25 = (*env)->GetFieldID(env, LOGFONTFc.clazz, "lfFaceName25", "C");
+ LOGFONTFc.lfFaceName26 = (*env)->GetFieldID(env, LOGFONTFc.clazz, "lfFaceName26", "C");
+ LOGFONTFc.lfFaceName27 = (*env)->GetFieldID(env, LOGFONTFc.clazz, "lfFaceName27", "C");
+ LOGFONTFc.lfFaceName28 = (*env)->GetFieldID(env, LOGFONTFc.clazz, "lfFaceName28", "C");
+ LOGFONTFc.lfFaceName29 = (*env)->GetFieldID(env, LOGFONTFc.clazz, "lfFaceName29", "C");
+ LOGFONTFc.lfFaceName30 = (*env)->GetFieldID(env, LOGFONTFc.clazz, "lfFaceName30", "C");
+ LOGFONTFc.lfFaceName31 = (*env)->GetFieldID(env, LOGFONTFc.clazz, "lfFaceName31", "C");
+ LOGFONTFc.cached = 1;
+}
+
+#ifndef NO_LOGFONTA
+LOGFONTA* getLOGFONTAFields(JNIEnv *env, jobject lpObject, LOGFONTA *lpStruct)
+{
+ if (!LOGFONTFc.cached) cacheLOGFONTFids(env, lpObject);
+ lpStruct->lfHeight = (*env)->GetIntField(env,lpObject,LOGFONTFc.lfHeight);
+ lpStruct->lfWidth = (*env)->GetIntField(env,lpObject,LOGFONTFc.lfWidth);
+ lpStruct->lfEscapement = (*env)->GetIntField(env,lpObject,LOGFONTFc.lfEscapement);
+ lpStruct->lfOrientation = (*env)->GetIntField(env,lpObject,LOGFONTFc.lfOrientation);
+ lpStruct->lfWeight = (*env)->GetIntField(env,lpObject,LOGFONTFc.lfWeight);
+ lpStruct->lfItalic = (*env)->GetByteField(env,lpObject,LOGFONTFc.lfItalic);
+ lpStruct->lfUnderline = (*env)->GetByteField(env,lpObject,LOGFONTFc.lfUnderline);
+ lpStruct->lfStrikeOut = (*env)->GetByteField(env,lpObject,LOGFONTFc.lfStrikeOut);
+ lpStruct->lfCharSet = (*env)->GetByteField(env,lpObject,LOGFONTFc.lfCharSet);
+ lpStruct->lfOutPrecision = (*env)->GetByteField(env,lpObject,LOGFONTFc.lfOutPrecision);
+ lpStruct->lfClipPrecision = (*env)->GetByteField(env,lpObject,LOGFONTFc.lfClipPrecision);
+ lpStruct->lfQuality = (*env)->GetByteField(env,lpObject,LOGFONTFc.lfQuality);
+ lpStruct->lfPitchAndFamily = (*env)->GetByteField(env,lpObject,LOGFONTFc.lfPitchAndFamily);
+ {
+ WCHAR lfFaceName [32];
+ lfFaceName[0] = (*env)->GetCharField(env,lpObject,LOGFONTFc.lfFaceName0);
+ lfFaceName[1] = (*env)->GetCharField(env,lpObject,LOGFONTFc.lfFaceName1);
+ lfFaceName[2] = (*env)->GetCharField(env,lpObject,LOGFONTFc.lfFaceName2);
+ lfFaceName[3] = (*env)->GetCharField(env,lpObject,LOGFONTFc.lfFaceName3);
+ lfFaceName[4] = (*env)->GetCharField(env,lpObject,LOGFONTFc.lfFaceName4);
+ lfFaceName[5] = (*env)->GetCharField(env,lpObject,LOGFONTFc.lfFaceName5);
+ lfFaceName[6] = (*env)->GetCharField(env,lpObject,LOGFONTFc.lfFaceName6);
+ lfFaceName[7] = (*env)->GetCharField(env,lpObject,LOGFONTFc.lfFaceName7);
+ lfFaceName[8] = (*env)->GetCharField(env,lpObject,LOGFONTFc.lfFaceName8);
+ lfFaceName[9] = (*env)->GetCharField(env,lpObject,LOGFONTFc.lfFaceName9);
+ lfFaceName[10] = (*env)->GetCharField(env,lpObject,LOGFONTFc.lfFaceName10);
+ lfFaceName[11] = (*env)->GetCharField(env,lpObject,LOGFONTFc.lfFaceName11);
+ lfFaceName[12] = (*env)->GetCharField(env,lpObject,LOGFONTFc.lfFaceName12);
+ lfFaceName[13] = (*env)->GetCharField(env,lpObject,LOGFONTFc.lfFaceName13);
+ lfFaceName[14] = (*env)->GetCharField(env,lpObject,LOGFONTFc.lfFaceName14);
+ lfFaceName[15] = (*env)->GetCharField(env,lpObject,LOGFONTFc.lfFaceName15);
+ lfFaceName[16] = (*env)->GetCharField(env,lpObject,LOGFONTFc.lfFaceName16);
+ lfFaceName[17] = (*env)->GetCharField(env,lpObject,LOGFONTFc.lfFaceName17);
+ lfFaceName[18] = (*env)->GetCharField(env,lpObject,LOGFONTFc.lfFaceName18);
+ lfFaceName[19] = (*env)->GetCharField(env,lpObject,LOGFONTFc.lfFaceName19);
+ lfFaceName[20] = (*env)->GetCharField(env,lpObject,LOGFONTFc.lfFaceName20);
+ lfFaceName[21] = (*env)->GetCharField(env,lpObject,LOGFONTFc.lfFaceName21);
+ lfFaceName[22] = (*env)->GetCharField(env,lpObject,LOGFONTFc.lfFaceName22);
+ lfFaceName[23] = (*env)->GetCharField(env,lpObject,LOGFONTFc.lfFaceName23);
+ lfFaceName[24] = (*env)->GetCharField(env,lpObject,LOGFONTFc.lfFaceName24);
+ lfFaceName[25] = (*env)->GetCharField(env,lpObject,LOGFONTFc.lfFaceName25);
+ lfFaceName[26] = (*env)->GetCharField(env,lpObject,LOGFONTFc.lfFaceName26);
+ lfFaceName[27] = (*env)->GetCharField(env,lpObject,LOGFONTFc.lfFaceName27);
+ lfFaceName[28] = (*env)->GetCharField(env,lpObject,LOGFONTFc.lfFaceName28);
+ lfFaceName[29] = (*env)->GetCharField(env,lpObject,LOGFONTFc.lfFaceName29);
+ lfFaceName[30] = (*env)->GetCharField(env,lpObject,LOGFONTFc.lfFaceName30);
+ lfFaceName[31] = (*env)->GetCharField(env,lpObject,LOGFONTFc.lfFaceName31);
+ WideCharToMultiByte (CP_ACP, 0, lfFaceName, 32, lpStruct->lfFaceName, 32, NULL, NULL);
+ }
+ return lpStruct;
+}
+
+void setLOGFONTAFields(JNIEnv *env, jobject lpObject, LOGFONTA *lpStruct)
+{
+ if (!LOGFONTFc.cached) cacheLOGFONTFids(env, lpObject);
+ (*env)->SetIntField(env,lpObject,LOGFONTFc.lfHeight, lpStruct->lfHeight);
+ (*env)->SetIntField(env,lpObject,LOGFONTFc.lfWidth, lpStruct->lfWidth);
+ (*env)->SetIntField(env,lpObject,LOGFONTFc.lfEscapement, lpStruct->lfEscapement);
+ (*env)->SetIntField(env,lpObject,LOGFONTFc.lfOrientation, lpStruct->lfOrientation);
+ (*env)->SetIntField(env,lpObject,LOGFONTFc.lfWeight, lpStruct->lfWeight);
+ (*env)->SetByteField(env,lpObject,LOGFONTFc.lfItalic, lpStruct->lfItalic);
+ (*env)->SetByteField(env,lpObject,LOGFONTFc.lfUnderline, lpStruct->lfUnderline);
+ (*env)->SetByteField(env,lpObject,LOGFONTFc.lfStrikeOut, lpStruct->lfStrikeOut);
+ (*env)->SetByteField(env,lpObject,LOGFONTFc.lfCharSet, lpStruct->lfCharSet);
+ (*env)->SetByteField(env,lpObject,LOGFONTFc.lfOutPrecision, lpStruct->lfOutPrecision);
+ (*env)->SetByteField(env,lpObject,LOGFONTFc.lfClipPrecision, lpStruct->lfClipPrecision);
+ (*env)->SetByteField(env,lpObject,LOGFONTFc.lfQuality, lpStruct->lfQuality);
+ (*env)->SetByteField(env,lpObject,LOGFONTFc.lfPitchAndFamily, lpStruct->lfPitchAndFamily);
+ {
+ WCHAR lfFaceName [32] = {0};
+ MultiByteToWideChar (CP_ACP, MB_PRECOMPOSED, lpStruct->lfFaceName, -1, lfFaceName, 32);
+ (*env)->SetCharField(env,lpObject,LOGFONTFc.lfFaceName0, lfFaceName[0]);
+ (*env)->SetCharField(env,lpObject,LOGFONTFc.lfFaceName1, lfFaceName[1]);
+ (*env)->SetCharField(env,lpObject,LOGFONTFc.lfFaceName2, lfFaceName[2]);
+ (*env)->SetCharField(env,lpObject,LOGFONTFc.lfFaceName3, lfFaceName[3]);
+ (*env)->SetCharField(env,lpObject,LOGFONTFc.lfFaceName4, lfFaceName[4]);
+ (*env)->SetCharField(env,lpObject,LOGFONTFc.lfFaceName5, lfFaceName[5]);
+ (*env)->SetCharField(env,lpObject,LOGFONTFc.lfFaceName6, lfFaceName[6]);
+ (*env)->SetCharField(env,lpObject,LOGFONTFc.lfFaceName7, lfFaceName[7]);
+ (*env)->SetCharField(env,lpObject,LOGFONTFc.lfFaceName8, lfFaceName[8]);
+ (*env)->SetCharField(env,lpObject,LOGFONTFc.lfFaceName9, lfFaceName[9]);
+ (*env)->SetCharField(env,lpObject,LOGFONTFc.lfFaceName10, lfFaceName[10]);
+ (*env)->SetCharField(env,lpObject,LOGFONTFc.lfFaceName11, lfFaceName[11]);
+ (*env)->SetCharField(env,lpObject,LOGFONTFc.lfFaceName12, lfFaceName[12]);
+ (*env)->SetCharField(env,lpObject,LOGFONTFc.lfFaceName13, lfFaceName[13]);
+ (*env)->SetCharField(env,lpObject,LOGFONTFc.lfFaceName14, lfFaceName[14]);
+ (*env)->SetCharField(env,lpObject,LOGFONTFc.lfFaceName15, lfFaceName[15]);
+ (*env)->SetCharField(env,lpObject,LOGFONTFc.lfFaceName16, lfFaceName[16]);
+ (*env)->SetCharField(env,lpObject,LOGFONTFc.lfFaceName17, lfFaceName[17]);
+ (*env)->SetCharField(env,lpObject,LOGFONTFc.lfFaceName18, lfFaceName[18]);
+ (*env)->SetCharField(env,lpObject,LOGFONTFc.lfFaceName19, lfFaceName[19]);
+ (*env)->SetCharField(env,lpObject,LOGFONTFc.lfFaceName20, lfFaceName[20]);
+ (*env)->SetCharField(env,lpObject,LOGFONTFc.lfFaceName21, lfFaceName[21]);
+ (*env)->SetCharField(env,lpObject,LOGFONTFc.lfFaceName22, lfFaceName[22]);
+ (*env)->SetCharField(env,lpObject,LOGFONTFc.lfFaceName23, lfFaceName[23]);
+ (*env)->SetCharField(env,lpObject,LOGFONTFc.lfFaceName24, lfFaceName[24]);
+ (*env)->SetCharField(env,lpObject,LOGFONTFc.lfFaceName25, lfFaceName[25]);
+ (*env)->SetCharField(env,lpObject,LOGFONTFc.lfFaceName26, lfFaceName[26]);
+ (*env)->SetCharField(env,lpObject,LOGFONTFc.lfFaceName27, lfFaceName[27]);
+ (*env)->SetCharField(env,lpObject,LOGFONTFc.lfFaceName28, lfFaceName[28]);
+ (*env)->SetCharField(env,lpObject,LOGFONTFc.lfFaceName29, lfFaceName[29]);
+ (*env)->SetCharField(env,lpObject,LOGFONTFc.lfFaceName30, lfFaceName[30]);
+ (*env)->SetCharField(env,lpObject,LOGFONTFc.lfFaceName31, lfFaceName[31]);
+ }
+}
+#endif /* NO_LOGFONTA */
+
+#ifndef NO_LOGFONTW
+LOGFONTW *getLOGFONTWFields(JNIEnv *env, jobject lpObject, LOGFONTW *lpStruct)
+{
+ if (!LOGFONTFc.cached) cacheLOGFONTFids(env, lpObject);
+ lpStruct->lfHeight = (*env)->GetIntField(env, lpObject, LOGFONTFc.lfHeight);
+ lpStruct->lfWidth = (*env)->GetIntField(env, lpObject, LOGFONTFc.lfWidth);
+ lpStruct->lfEscapement = (*env)->GetIntField(env, lpObject, LOGFONTFc.lfEscapement);
+ lpStruct->lfOrientation = (*env)->GetIntField(env, lpObject, LOGFONTFc.lfOrientation);
+ lpStruct->lfWeight = (*env)->GetIntField(env, lpObject, LOGFONTFc.lfWeight);
+ lpStruct->lfItalic = (*env)->GetByteField(env, lpObject, LOGFONTFc.lfItalic);
+ lpStruct->lfUnderline = (*env)->GetByteField(env, lpObject, LOGFONTFc.lfUnderline);
+ lpStruct->lfStrikeOut = (*env)->GetByteField(env, lpObject, LOGFONTFc.lfStrikeOut);
+ lpStruct->lfCharSet = (*env)->GetByteField(env, lpObject, LOGFONTFc.lfCharSet);
+ lpStruct->lfOutPrecision = (*env)->GetByteField(env, lpObject, LOGFONTFc.lfOutPrecision);
+ lpStruct->lfClipPrecision = (*env)->GetByteField(env, lpObject, LOGFONTFc.lfClipPrecision);
+ lpStruct->lfQuality = (*env)->GetByteField(env, lpObject, LOGFONTFc.lfQuality);
+ lpStruct->lfPitchAndFamily = (*env)->GetByteField(env, lpObject, LOGFONTFc.lfPitchAndFamily);
+ lpStruct->lfFaceName[0] = (*env)->GetCharField(env, lpObject, LOGFONTFc.lfFaceName0);
+ lpStruct->lfFaceName[1] = (*env)->GetCharField(env, lpObject, LOGFONTFc.lfFaceName1);
+ lpStruct->lfFaceName[2] = (*env)->GetCharField(env, lpObject, LOGFONTFc.lfFaceName2);
+ lpStruct->lfFaceName[3] = (*env)->GetCharField(env, lpObject, LOGFONTFc.lfFaceName3);
+ lpStruct->lfFaceName[4] = (*env)->GetCharField(env, lpObject, LOGFONTFc.lfFaceName4);
+ lpStruct->lfFaceName[5] = (*env)->GetCharField(env, lpObject, LOGFONTFc.lfFaceName5);
+ lpStruct->lfFaceName[6] = (*env)->GetCharField(env, lpObject, LOGFONTFc.lfFaceName6);
+ lpStruct->lfFaceName[7] = (*env)->GetCharField(env, lpObject, LOGFONTFc.lfFaceName7);
+ lpStruct->lfFaceName[8] = (*env)->GetCharField(env, lpObject, LOGFONTFc.lfFaceName8);
+ lpStruct->lfFaceName[9] = (*env)->GetCharField(env, lpObject, LOGFONTFc.lfFaceName9);
+ lpStruct->lfFaceName[10] = (*env)->GetCharField(env, lpObject, LOGFONTFc.lfFaceName10);
+ lpStruct->lfFaceName[11] = (*env)->GetCharField(env, lpObject, LOGFONTFc.lfFaceName11);
+ lpStruct->lfFaceName[12] = (*env)->GetCharField(env, lpObject, LOGFONTFc.lfFaceName12);
+ lpStruct->lfFaceName[13] = (*env)->GetCharField(env, lpObject, LOGFONTFc.lfFaceName13);
+ lpStruct->lfFaceName[14] = (*env)->GetCharField(env, lpObject, LOGFONTFc.lfFaceName14);
+ lpStruct->lfFaceName[15] = (*env)->GetCharField(env, lpObject, LOGFONTFc.lfFaceName15);
+ lpStruct->lfFaceName[16] = (*env)->GetCharField(env, lpObject, LOGFONTFc.lfFaceName16);
+ lpStruct->lfFaceName[17] = (*env)->GetCharField(env, lpObject, LOGFONTFc.lfFaceName17);
+ lpStruct->lfFaceName[18] = (*env)->GetCharField(env, lpObject, LOGFONTFc.lfFaceName18);
+ lpStruct->lfFaceName[19] = (*env)->GetCharField(env, lpObject, LOGFONTFc.lfFaceName19);
+ lpStruct->lfFaceName[20] = (*env)->GetCharField(env, lpObject, LOGFONTFc.lfFaceName20);
+ lpStruct->lfFaceName[21] = (*env)->GetCharField(env, lpObject, LOGFONTFc.lfFaceName21);
+ lpStruct->lfFaceName[22] = (*env)->GetCharField(env, lpObject, LOGFONTFc.lfFaceName22);
+ lpStruct->lfFaceName[23] = (*env)->GetCharField(env, lpObject, LOGFONTFc.lfFaceName23);
+ lpStruct->lfFaceName[24] = (*env)->GetCharField(env, lpObject, LOGFONTFc.lfFaceName24);
+ lpStruct->lfFaceName[25] = (*env)->GetCharField(env, lpObject, LOGFONTFc.lfFaceName25);
+ lpStruct->lfFaceName[26] = (*env)->GetCharField(env, lpObject, LOGFONTFc.lfFaceName26);
+ lpStruct->lfFaceName[27] = (*env)->GetCharField(env, lpObject, LOGFONTFc.lfFaceName27);
+ lpStruct->lfFaceName[28] = (*env)->GetCharField(env, lpObject, LOGFONTFc.lfFaceName28);
+ lpStruct->lfFaceName[29] = (*env)->GetCharField(env, lpObject, LOGFONTFc.lfFaceName29);
+ lpStruct->lfFaceName[30] = (*env)->GetCharField(env, lpObject, LOGFONTFc.lfFaceName30);
+ lpStruct->lfFaceName[31] = (*env)->GetCharField(env, lpObject, LOGFONTFc.lfFaceName31);
+ return lpStruct;
+}
+
+void setLOGFONTWFields(JNIEnv *env, jobject lpObject, LOGFONTW *lpStruct)
+{
+ if (!LOGFONTFc.cached) cacheLOGFONTFids(env, lpObject);
+ (*env)->SetIntField(env, lpObject, LOGFONTFc.lfHeight, (jint)lpStruct->lfHeight);
+ (*env)->SetIntField(env, lpObject, LOGFONTFc.lfWidth, (jint)lpStruct->lfWidth);
+ (*env)->SetIntField(env, lpObject, LOGFONTFc.lfEscapement, (jint)lpStruct->lfEscapement);
+ (*env)->SetIntField(env, lpObject, LOGFONTFc.lfOrientation, (jint)lpStruct->lfOrientation);
+ (*env)->SetIntField(env, lpObject, LOGFONTFc.lfWeight, (jint)lpStruct->lfWeight);
+ (*env)->SetByteField(env, lpObject, LOGFONTFc.lfItalic, (jbyte)lpStruct->lfItalic);
+ (*env)->SetByteField(env, lpObject, LOGFONTFc.lfUnderline, (jbyte)lpStruct->lfUnderline);
+ (*env)->SetByteField(env, lpObject, LOGFONTFc.lfStrikeOut, (jbyte)lpStruct->lfStrikeOut);
+ (*env)->SetByteField(env, lpObject, LOGFONTFc.lfCharSet, (jbyte)lpStruct->lfCharSet);
+ (*env)->SetByteField(env, lpObject, LOGFONTFc.lfOutPrecision, (jbyte)lpStruct->lfOutPrecision);
+ (*env)->SetByteField(env, lpObject, LOGFONTFc.lfClipPrecision, (jbyte)lpStruct->lfClipPrecision);
+ (*env)->SetByteField(env, lpObject, LOGFONTFc.lfQuality, (jbyte)lpStruct->lfQuality);
+ (*env)->SetByteField(env, lpObject, LOGFONTFc.lfPitchAndFamily, (jbyte)lpStruct->lfPitchAndFamily);
+ (*env)->SetCharField(env, lpObject, LOGFONTFc.lfFaceName0, (jchar)lpStruct->lfFaceName[0]);
+ (*env)->SetCharField(env, lpObject, LOGFONTFc.lfFaceName1, (jchar)lpStruct->lfFaceName[1]);
+ (*env)->SetCharField(env, lpObject, LOGFONTFc.lfFaceName2, (jchar)lpStruct->lfFaceName[2]);
+ (*env)->SetCharField(env, lpObject, LOGFONTFc.lfFaceName3, (jchar)lpStruct->lfFaceName[3]);
+ (*env)->SetCharField(env, lpObject, LOGFONTFc.lfFaceName4, (jchar)lpStruct->lfFaceName[4]);
+ (*env)->SetCharField(env, lpObject, LOGFONTFc.lfFaceName5, (jchar)lpStruct->lfFaceName[5]);
+ (*env)->SetCharField(env, lpObject, LOGFONTFc.lfFaceName6, (jchar)lpStruct->lfFaceName[6]);
+ (*env)->SetCharField(env, lpObject, LOGFONTFc.lfFaceName7, (jchar)lpStruct->lfFaceName[7]);
+ (*env)->SetCharField(env, lpObject, LOGFONTFc.lfFaceName8, (jchar)lpStruct->lfFaceName[8]);
+ (*env)->SetCharField(env, lpObject, LOGFONTFc.lfFaceName9, (jchar)lpStruct->lfFaceName[9]);
+ (*env)->SetCharField(env, lpObject, LOGFONTFc.lfFaceName10, (jchar)lpStruct->lfFaceName[10]);
+ (*env)->SetCharField(env, lpObject, LOGFONTFc.lfFaceName11, (jchar)lpStruct->lfFaceName[11]);
+ (*env)->SetCharField(env, lpObject, LOGFONTFc.lfFaceName12, (jchar)lpStruct->lfFaceName[12]);
+ (*env)->SetCharField(env, lpObject, LOGFONTFc.lfFaceName13, (jchar)lpStruct->lfFaceName[13]);
+ (*env)->SetCharField(env, lpObject, LOGFONTFc.lfFaceName14, (jchar)lpStruct->lfFaceName[14]);
+ (*env)->SetCharField(env, lpObject, LOGFONTFc.lfFaceName15, (jchar)lpStruct->lfFaceName[15]);
+ (*env)->SetCharField(env, lpObject, LOGFONTFc.lfFaceName16, (jchar)lpStruct->lfFaceName[16]);
+ (*env)->SetCharField(env, lpObject, LOGFONTFc.lfFaceName17, (jchar)lpStruct->lfFaceName[17]);
+ (*env)->SetCharField(env, lpObject, LOGFONTFc.lfFaceName18, (jchar)lpStruct->lfFaceName[18]);
+ (*env)->SetCharField(env, lpObject, LOGFONTFc.lfFaceName19, (jchar)lpStruct->lfFaceName[19]);
+ (*env)->SetCharField(env, lpObject, LOGFONTFc.lfFaceName20, (jchar)lpStruct->lfFaceName[20]);
+ (*env)->SetCharField(env, lpObject, LOGFONTFc.lfFaceName21, (jchar)lpStruct->lfFaceName[21]);
+ (*env)->SetCharField(env, lpObject, LOGFONTFc.lfFaceName22, (jchar)lpStruct->lfFaceName[22]);
+ (*env)->SetCharField(env, lpObject, LOGFONTFc.lfFaceName23, (jchar)lpStruct->lfFaceName[23]);
+ (*env)->SetCharField(env, lpObject, LOGFONTFc.lfFaceName24, (jchar)lpStruct->lfFaceName[24]);
+ (*env)->SetCharField(env, lpObject, LOGFONTFc.lfFaceName25, (jchar)lpStruct->lfFaceName[25]);
+ (*env)->SetCharField(env, lpObject, LOGFONTFc.lfFaceName26, (jchar)lpStruct->lfFaceName[26]);
+ (*env)->SetCharField(env, lpObject, LOGFONTFc.lfFaceName27, (jchar)lpStruct->lfFaceName[27]);
+ (*env)->SetCharField(env, lpObject, LOGFONTFc.lfFaceName28, (jchar)lpStruct->lfFaceName[28]);
+ (*env)->SetCharField(env, lpObject, LOGFONTFc.lfFaceName29, (jchar)lpStruct->lfFaceName[29]);
+ (*env)->SetCharField(env, lpObject, LOGFONTFc.lfFaceName30, (jchar)lpStruct->lfFaceName[30]);
+ (*env)->SetCharField(env, lpObject, LOGFONTFc.lfFaceName31, (jchar)lpStruct->lfFaceName[31]);
+}
+#endif /* NO_LOGFONTW */
+#endif /* NO_LOGFONT */
+
+#ifndef NO_LOGPEN
+typedef struct LOGPEN_FID_CACHE {
+ int cached;
+ jclass clazz;
+ jfieldID lopnStyle, x, y, lopnColor;
+} LOGPEN_FID_CACHE;
+
+LOGPEN_FID_CACHE LOGPENFc;
+
+void cacheLOGPENFids(JNIEnv *env, jobject lpObject)
+{
+ if (LOGPENFc.cached) return;
+ LOGPENFc.clazz = (*env)->GetObjectClass(env, lpObject);
+ LOGPENFc.lopnStyle = (*env)->GetFieldID(env, LOGPENFc.clazz, "lopnStyle", "I");
+ LOGPENFc.x = (*env)->GetFieldID(env, LOGPENFc.clazz, "x", "I");
+ LOGPENFc.y = (*env)->GetFieldID(env, LOGPENFc.clazz, "y", "I");
+ LOGPENFc.lopnColor = (*env)->GetFieldID(env, LOGPENFc.clazz, "lopnColor", "I");
+ LOGPENFc.cached = 1;
+}
+
+LOGPEN *getLOGPENFields(JNIEnv *env, jobject lpObject, LOGPEN *lpStruct)
+{
+ if (!LOGPENFc.cached) cacheLOGPENFids(env, lpObject);
+ lpStruct->lopnStyle = (*env)->GetIntField(env, lpObject, LOGPENFc.lopnStyle);
+ lpStruct->lopnWidth.x = (*env)->GetIntField(env, lpObject, LOGPENFc.x);
+ lpStruct->lopnWidth.y = (*env)->GetIntField(env, lpObject, LOGPENFc.y);
+ lpStruct->lopnColor = (*env)->GetIntField(env, lpObject, LOGPENFc.lopnColor);
+ return lpStruct;
+}
+
+void setLOGPENFields(JNIEnv *env, jobject lpObject, LOGPEN *lpStruct)
+{
+ if (!LOGPENFc.cached) cacheLOGPENFids(env, lpObject);
+ (*env)->SetIntField(env, lpObject, LOGPENFc.lopnStyle, (jint)lpStruct->lopnStyle);
+ (*env)->SetIntField(env, lpObject, LOGPENFc.x, (jint)lpStruct->lopnWidth.x);
+ (*env)->SetIntField(env, lpObject, LOGPENFc.y, (jint)lpStruct->lopnWidth.y);
+ (*env)->SetIntField(env, lpObject, LOGPENFc.lopnColor, (jint)lpStruct->lopnColor);
+}
+#endif /* NO_LOGPEN */
+
+#ifndef NO_LVCOLUMN
+typedef struct LVCOLUMN_FID_CACHE {
+ int cached;
+ jclass clazz;
+ jfieldID mask, fmt, cx, pszText, cchTextMax, iSubItem, iImage, iOrder;
+} LVCOLUMN_FID_CACHE;
+
+LVCOLUMN_FID_CACHE LVCOLUMNFc;
+
+void cacheLVCOLUMNFids(JNIEnv *env, jobject lpObject)
+{
+ if (LVCOLUMNFc.cached) return;
+ LVCOLUMNFc.clazz = (*env)->GetObjectClass(env, lpObject);
+ LVCOLUMNFc.mask = (*env)->GetFieldID(env, LVCOLUMNFc.clazz, "mask", "I");
+ LVCOLUMNFc.fmt = (*env)->GetFieldID(env, LVCOLUMNFc.clazz, "fmt", "I");
+ LVCOLUMNFc.cx = (*env)->GetFieldID(env, LVCOLUMNFc.clazz, "cx", "I");
+ LVCOLUMNFc.pszText = (*env)->GetFieldID(env, LVCOLUMNFc.clazz, "pszText", "I");
+ LVCOLUMNFc.cchTextMax = (*env)->GetFieldID(env, LVCOLUMNFc.clazz, "cchTextMax", "I");
+ LVCOLUMNFc.iSubItem = (*env)->GetFieldID(env, LVCOLUMNFc.clazz, "iSubItem", "I");
+ LVCOLUMNFc.iImage = (*env)->GetFieldID(env, LVCOLUMNFc.clazz, "iImage", "I");
+ LVCOLUMNFc.iOrder = (*env)->GetFieldID(env, LVCOLUMNFc.clazz, "iOrder", "I");
+ LVCOLUMNFc.cached = 1;
+}
+
+LVCOLUMN *getLVCOLUMNFields(JNIEnv *env, jobject lpObject, LVCOLUMN *lpStruct)
+{
+ if (!LVCOLUMNFc.cached) cacheLVCOLUMNFids(env, lpObject);
+ lpStruct->mask = (*env)->GetIntField(env, lpObject, LVCOLUMNFc.mask);
+ lpStruct->fmt = (*env)->GetIntField(env, lpObject, LVCOLUMNFc.fmt);
+ lpStruct->cx = (*env)->GetIntField(env, lpObject, LVCOLUMNFc.cx);
+ lpStruct->pszText = (LPTSTR)(*env)->GetIntField(env, lpObject, LVCOLUMNFc.pszText);
+ lpStruct->cchTextMax = (*env)->GetIntField(env, lpObject, LVCOLUMNFc.cchTextMax);
+ lpStruct->iSubItem = (*env)->GetIntField(env, lpObject, LVCOLUMNFc.iSubItem);
+ lpStruct->iImage = (*env)->GetIntField(env, lpObject, LVCOLUMNFc.iImage);
+ lpStruct->iOrder = (*env)->GetIntField(env, lpObject, LVCOLUMNFc.iOrder);
+ return lpStruct;
+}
+
+void setLVCOLUMNFields(JNIEnv *env, jobject lpObject, LVCOLUMN *lpStruct)
+{
+ if (!LVCOLUMNFc.cached) cacheLVCOLUMNFids(env, lpObject);
+ (*env)->SetIntField(env, lpObject, LVCOLUMNFc.mask, (jint)lpStruct->mask);
+ (*env)->SetIntField(env, lpObject, LVCOLUMNFc.fmt, (jint)lpStruct->fmt);
+ (*env)->SetIntField(env, lpObject, LVCOLUMNFc.cx, (jint)lpStruct->cx);
+ (*env)->SetIntField(env, lpObject, LVCOLUMNFc.pszText, (jint)lpStruct->pszText);
+ (*env)->SetIntField(env, lpObject, LVCOLUMNFc.cchTextMax, (jint)lpStruct->cchTextMax);
+ (*env)->SetIntField(env, lpObject, LVCOLUMNFc.iSubItem, (jint)lpStruct->iSubItem);
+ (*env)->SetIntField(env, lpObject, LVCOLUMNFc.iImage, (jint)lpStruct->iImage);
+ (*env)->SetIntField(env, lpObject, LVCOLUMNFc.iOrder, (jint)lpStruct->iOrder);
+}
+#endif /* NO_LVCOLUMN */
+
+#ifndef NO_LVHITTESTINFO
+typedef struct LVHITTESTINFO_FID_CACHE {
+ int cached;
+ jclass clazz;
+ jfieldID x, y, flags, iItem, iSubItem;
+} LVHITTESTINFO_FID_CACHE;
+
+LVHITTESTINFO_FID_CACHE LVHITTESTINFOFc;
+
+void cacheLVHITTESTINFOFids(JNIEnv *env, jobject lpObject)
+{
+ if (LVHITTESTINFOFc.cached) return;
+ LVHITTESTINFOFc.clazz = (*env)->GetObjectClass(env, lpObject);
+ LVHITTESTINFOFc.x = (*env)->GetFieldID(env, LVHITTESTINFOFc.clazz, "x", "I");
+ LVHITTESTINFOFc.y = (*env)->GetFieldID(env, LVHITTESTINFOFc.clazz, "y", "I");
+ LVHITTESTINFOFc.flags = (*env)->GetFieldID(env, LVHITTESTINFOFc.clazz, "flags", "I");
+ LVHITTESTINFOFc.iItem = (*env)->GetFieldID(env, LVHITTESTINFOFc.clazz, "iItem", "I");
+ LVHITTESTINFOFc.iSubItem = (*env)->GetFieldID(env, LVHITTESTINFOFc.clazz, "iSubItem", "I");
+ LVHITTESTINFOFc.cached = 1;
+}
+
+LVHITTESTINFO *getLVHITTESTINFOFields(JNIEnv *env, jobject lpObject, LVHITTESTINFO *lpStruct)
+{
+ if (!LVHITTESTINFOFc.cached) cacheLVHITTESTINFOFids(env, lpObject);
+ lpStruct->pt.x = (*env)->GetIntField(env, lpObject, LVHITTESTINFOFc.x);
+ lpStruct->pt.y = (*env)->GetIntField(env, lpObject, LVHITTESTINFOFc.y);
+ lpStruct->flags = (*env)->GetIntField(env, lpObject, LVHITTESTINFOFc.flags);
+ lpStruct->iItem = (*env)->GetIntField(env, lpObject, LVHITTESTINFOFc.iItem);
+ lpStruct->iSubItem = (*env)->GetIntField(env, lpObject, LVHITTESTINFOFc.iSubItem);
+ return lpStruct;
+}
+
+void setLVHITTESTINFOFields(JNIEnv *env, jobject lpObject, LVHITTESTINFO *lpStruct)
+{
+ if (!LVHITTESTINFOFc.cached) cacheLVHITTESTINFOFids(env, lpObject);
+ (*env)->SetIntField(env, lpObject, LVHITTESTINFOFc.x, (jint)lpStruct->pt.x);
+ (*env)->SetIntField(env, lpObject, LVHITTESTINFOFc.y, (jint)lpStruct->pt.y);
+ (*env)->SetIntField(env, lpObject, LVHITTESTINFOFc.flags, (jint)lpStruct->flags);
+ (*env)->SetIntField(env, lpObject, LVHITTESTINFOFc.iItem, (jint)lpStruct->iItem);
+ (*env)->SetIntField(env, lpObject, LVHITTESTINFOFc.iSubItem, (jint)lpStruct->iSubItem);
+}
+#endif /* NO_LVHITTESTINFO */
+
+#ifndef NO_LVITEM
+typedef struct LVITEM_FID_CACHE {
+ int cached;
+ jclass clazz;
+ jfieldID mask, iItem, iSubItem, state, stateMask, pszText, cchTextMax, iImage, lParam, iIndent;
+} LVITEM_FID_CACHE;
+
+LVITEM_FID_CACHE LVITEMFc;
+
+void cacheLVITEMFids(JNIEnv *env, jobject lpObject)
+{
+ if (LVITEMFc.cached) return;
+ LVITEMFc.clazz = (*env)->GetObjectClass(env, lpObject);
+ LVITEMFc.mask = (*env)->GetFieldID(env, LVITEMFc.clazz, "mask", "I");
+ LVITEMFc.iItem = (*env)->GetFieldID(env, LVITEMFc.clazz, "iItem", "I");
+ LVITEMFc.iSubItem = (*env)->GetFieldID(env, LVITEMFc.clazz, "iSubItem", "I");
+ LVITEMFc.state = (*env)->GetFieldID(env, LVITEMFc.clazz, "state", "I");
+ LVITEMFc.stateMask = (*env)->GetFieldID(env, LVITEMFc.clazz, "stateMask", "I");
+ LVITEMFc.pszText = (*env)->GetFieldID(env, LVITEMFc.clazz, "pszText", "I");
+ LVITEMFc.cchTextMax = (*env)->GetFieldID(env, LVITEMFc.clazz, "cchTextMax", "I");
+ LVITEMFc.iImage = (*env)->GetFieldID(env, LVITEMFc.clazz, "iImage", "I");
+ LVITEMFc.lParam = (*env)->GetFieldID(env, LVITEMFc.clazz, "lParam", "I");
+ LVITEMFc.iIndent = (*env)->GetFieldID(env, LVITEMFc.clazz, "iIndent", "I");
+ LVITEMFc.cached = 1;
+}
+
+LVITEM *getLVITEMFields(JNIEnv *env, jobject lpObject, LVITEM *lpStruct)
+{
+ if (!LVITEMFc.cached) cacheLVITEMFids(env, lpObject);
+ lpStruct->mask = (*env)->GetIntField(env, lpObject, LVITEMFc.mask);
+ lpStruct->iItem = (*env)->GetIntField(env, lpObject, LVITEMFc.iItem);
+ lpStruct->iSubItem = (*env)->GetIntField(env, lpObject, LVITEMFc.iSubItem);
+ lpStruct->state = (*env)->GetIntField(env, lpObject, LVITEMFc.state);
+ lpStruct->stateMask = (*env)->GetIntField(env, lpObject, LVITEMFc.stateMask);
+ lpStruct->pszText = (LPTSTR)(*env)->GetIntField(env, lpObject, LVITEMFc.pszText);
+ lpStruct->cchTextMax = (*env)->GetIntField(env, lpObject, LVITEMFc.cchTextMax);
+ lpStruct->iImage = (*env)->GetIntField(env, lpObject, LVITEMFc.iImage);
+ lpStruct->lParam = (*env)->GetIntField(env, lpObject, LVITEMFc.lParam);
+ lpStruct->iIndent = (*env)->GetIntField(env, lpObject, LVITEMFc.iIndent);
+ return lpStruct;
+}
+
+void setLVITEMFields(JNIEnv *env, jobject lpObject, LVITEM *lpStruct)
+{
+ if (!LVITEMFc.cached) cacheLVITEMFids(env, lpObject);
+ (*env)->SetIntField(env, lpObject, LVITEMFc.mask, (jint)lpStruct->mask);
+ (*env)->SetIntField(env, lpObject, LVITEMFc.iItem, (jint)lpStruct->iItem);
+ (*env)->SetIntField(env, lpObject, LVITEMFc.iSubItem, (jint)lpStruct->iSubItem);
+ (*env)->SetIntField(env, lpObject, LVITEMFc.state, (jint)lpStruct->state);
+ (*env)->SetIntField(env, lpObject, LVITEMFc.stateMask, (jint)lpStruct->stateMask);
+ (*env)->SetIntField(env, lpObject, LVITEMFc.pszText, (jint)lpStruct->pszText);
+ (*env)->SetIntField(env, lpObject, LVITEMFc.cchTextMax, (jint)lpStruct->cchTextMax);
+ (*env)->SetIntField(env, lpObject, LVITEMFc.iImage, (jint)lpStruct->iImage);
+ (*env)->SetIntField(env, lpObject, LVITEMFc.lParam, (jint)lpStruct->lParam);
+ (*env)->SetIntField(env, lpObject, LVITEMFc.iIndent, (jint)lpStruct->iIndent);
+}
+#endif /* NO_LVITEM */
+
+#ifndef NO_MEASUREITEMSTRUCT
+typedef struct MEASUREITEMSTRUCT_FID_CACHE {
+ int cached;
+ jclass clazz;
+ jfieldID CtlType, CtlID, itemID, itemWidth, itemHeight, itemData;
+} MEASUREITEMSTRUCT_FID_CACHE;
+
+MEASUREITEMSTRUCT_FID_CACHE MEASUREITEMSTRUCTFc;
+
+void cacheMEASUREITEMSTRUCTFids(JNIEnv *env, jobject lpObject)
+{
+ if (MEASUREITEMSTRUCTFc.cached) return;
+ MEASUREITEMSTRUCTFc.clazz = (*env)->GetObjectClass(env, lpObject);
+ MEASUREITEMSTRUCTFc.CtlType = (*env)->GetFieldID(env, MEASUREITEMSTRUCTFc.clazz, "CtlType", "I");
+ MEASUREITEMSTRUCTFc.CtlID = (*env)->GetFieldID(env, MEASUREITEMSTRUCTFc.clazz, "CtlID", "I");
+ MEASUREITEMSTRUCTFc.itemID = (*env)->GetFieldID(env, MEASUREITEMSTRUCTFc.clazz, "itemID", "I");
+ MEASUREITEMSTRUCTFc.itemWidth = (*env)->GetFieldID(env, MEASUREITEMSTRUCTFc.clazz, "itemWidth", "I");
+ MEASUREITEMSTRUCTFc.itemHeight = (*env)->GetFieldID(env, MEASUREITEMSTRUCTFc.clazz, "itemHeight", "I");
+ MEASUREITEMSTRUCTFc.itemData = (*env)->GetFieldID(env, MEASUREITEMSTRUCTFc.clazz, "itemData", "I");
+ MEASUREITEMSTRUCTFc.cached = 1;
+}
+
+MEASUREITEMSTRUCT *getMEASUREITEMSTRUCTFields(JNIEnv *env, jobject lpObject, MEASUREITEMSTRUCT *lpStruct)
+{
+ if (!MEASUREITEMSTRUCTFc.cached) cacheMEASUREITEMSTRUCTFids(env, lpObject);
+ lpStruct->CtlType = (*env)->GetIntField(env, lpObject, MEASUREITEMSTRUCTFc.CtlType);
+ lpStruct->CtlID = (*env)->GetIntField(env, lpObject, MEASUREITEMSTRUCTFc.CtlID);
+ lpStruct->itemID = (*env)->GetIntField(env, lpObject, MEASUREITEMSTRUCTFc.itemID);
+ lpStruct->itemWidth = (*env)->GetIntField(env, lpObject, MEASUREITEMSTRUCTFc.itemWidth);
+ lpStruct->itemHeight = (*env)->GetIntField(env, lpObject, MEASUREITEMSTRUCTFc.itemHeight);
+ lpStruct->itemData = (*env)->GetIntField(env, lpObject, MEASUREITEMSTRUCTFc.itemData);
+ return lpStruct;
+}
+
+void setMEASUREITEMSTRUCTFields(JNIEnv *env, jobject lpObject, MEASUREITEMSTRUCT *lpStruct)
+{
+ if (!MEASUREITEMSTRUCTFc.cached) cacheMEASUREITEMSTRUCTFids(env, lpObject);
+ (*env)->SetIntField(env, lpObject, MEASUREITEMSTRUCTFc.CtlType, (jint)lpStruct->CtlType);
+ (*env)->SetIntField(env, lpObject, MEASUREITEMSTRUCTFc.CtlID, (jint)lpStruct->CtlID);
+ (*env)->SetIntField(env, lpObject, MEASUREITEMSTRUCTFc.itemID, (jint)lpStruct->itemID);
+ (*env)->SetIntField(env, lpObject, MEASUREITEMSTRUCTFc.itemWidth, (jint)lpStruct->itemWidth);
+ (*env)->SetIntField(env, lpObject, MEASUREITEMSTRUCTFc.itemHeight, (jint)lpStruct->itemHeight);
+ (*env)->SetIntField(env, lpObject, MEASUREITEMSTRUCTFc.itemData, (jint)lpStruct->itemData);
+}
+#endif /* NO_MEASUREITEMSTRUCT */
+
+#ifndef NO_MENUINFO
+typedef struct MENUINFO_FID_CACHE {
+ int cached;
+ jclass clazz;
+ jfieldID cbSize, fMask, dwStyle, cyMax, hbrBack, dwContextHelpID, dwMenuData;
+} MENUINFO_FID_CACHE;
+
+MENUINFO_FID_CACHE MENUINFOFc;
+
+void cacheMENUINFOFids(JNIEnv *env, jobject lpObject)
+{
+ if (MENUINFOFc.cached) return;
+ MENUINFOFc.clazz = (*env)->GetObjectClass(env, lpObject);
+ MENUINFOFc.cbSize = (*env)->GetFieldID(env, MENUINFOFc.clazz, "cbSize", "I");
+ MENUINFOFc.fMask = (*env)->GetFieldID(env, MENUINFOFc.clazz, "fMask", "I");
+ MENUINFOFc.dwStyle = (*env)->GetFieldID(env, MENUINFOFc.clazz, "dwStyle", "I");
+ MENUINFOFc.cyMax = (*env)->GetFieldID(env, MENUINFOFc.clazz, "cyMax", "I");
+ MENUINFOFc.hbrBack = (*env)->GetFieldID(env, MENUINFOFc.clazz, "hbrBack", "I");
+ MENUINFOFc.dwContextHelpID = (*env)->GetFieldID(env, MENUINFOFc.clazz, "dwContextHelpID", "I");
+ MENUINFOFc.dwMenuData = (*env)->GetFieldID(env, MENUINFOFc.clazz, "dwMenuData", "I");
+ MENUINFOFc.cached = 1;
+}
+
+MENUINFO *getMENUINFOFields(JNIEnv *env, jobject lpObject, MENUINFO *lpStruct)
+{
+ if (!MENUINFOFc.cached) cacheMENUINFOFids(env, lpObject);
+ lpStruct->cbSize = (*env)->GetIntField(env, lpObject, MENUINFOFc.cbSize);
+ lpStruct->fMask = (*env)->GetIntField(env, lpObject, MENUINFOFc.fMask);
+ lpStruct->dwStyle = (*env)->GetIntField(env, lpObject, MENUINFOFc.dwStyle);
+ lpStruct->cyMax = (*env)->GetIntField(env, lpObject, MENUINFOFc.cyMax);
+ lpStruct->hbrBack = (HBRUSH)(*env)->GetIntField(env, lpObject, MENUINFOFc.hbrBack);
+ lpStruct->dwContextHelpID = (*env)->GetIntField(env, lpObject, MENUINFOFc.dwContextHelpID);
+ lpStruct->dwMenuData = (*env)->GetIntField(env, lpObject, MENUINFOFc.dwMenuData);
+ return lpStruct;
+}
+
+void setMENUINFOFields(JNIEnv *env, jobject lpObject, MENUINFO *lpStruct)
+{
+ if (!MENUINFOFc.cached) cacheMENUINFOFids(env, lpObject);
+ (*env)->SetIntField(env, lpObject, MENUINFOFc.cbSize, (jint)lpStruct->cbSize);
+ (*env)->SetIntField(env, lpObject, MENUINFOFc.fMask, (jint)lpStruct->fMask);
+ (*env)->SetIntField(env, lpObject, MENUINFOFc.dwStyle, (jint)lpStruct->dwStyle);
+ (*env)->SetIntField(env, lpObject, MENUINFOFc.cyMax, (jint)lpStruct->cyMax);
+ (*env)->SetIntField(env, lpObject, MENUINFOFc.hbrBack, (jint)lpStruct->hbrBack);
+ (*env)->SetIntField(env, lpObject, MENUINFOFc.dwContextHelpID, (jint)lpStruct->dwContextHelpID);
+ (*env)->SetIntField(env, lpObject, MENUINFOFc.dwMenuData, (jint)lpStruct->dwMenuData);
+}
+#endif /* NO_MENUINFO */
+
+#ifndef NO_MENUITEMINFO
+typedef struct MENUITEMINFO_FID_CACHE {
+ int cached;
+ jclass clazz;
+ jfieldID cbSize, fMask, fType, fState, wID, hSubMenu, hbmpChecked, hbmpUnchecked, dwItemData, dwTypeData, cch, hbmpItem;
+} MENUITEMINFO_FID_CACHE;
+
+MENUITEMINFO_FID_CACHE MENUITEMINFOFc;
+
+void cacheMENUITEMINFOFids(JNIEnv *env, jobject lpObject)
+{
+ if (MENUITEMINFOFc.cached) return;
+ MENUITEMINFOFc.clazz = (*env)->GetObjectClass(env, lpObject);
+ MENUITEMINFOFc.cbSize = (*env)->GetFieldID(env, MENUITEMINFOFc.clazz, "cbSize", "I");
+ MENUITEMINFOFc.fMask = (*env)->GetFieldID(env, MENUITEMINFOFc.clazz, "fMask", "I");
+ MENUITEMINFOFc.fType = (*env)->GetFieldID(env, MENUITEMINFOFc.clazz, "fType", "I");
+ MENUITEMINFOFc.fState = (*env)->GetFieldID(env, MENUITEMINFOFc.clazz, "fState", "I");
+ MENUITEMINFOFc.wID = (*env)->GetFieldID(env, MENUITEMINFOFc.clazz, "wID", "I");
+ MENUITEMINFOFc.hSubMenu = (*env)->GetFieldID(env, MENUITEMINFOFc.clazz, "hSubMenu", "I");
+ MENUITEMINFOFc.hbmpChecked = (*env)->GetFieldID(env, MENUITEMINFOFc.clazz, "hbmpChecked", "I");
+ MENUITEMINFOFc.hbmpUnchecked = (*env)->GetFieldID(env, MENUITEMINFOFc.clazz, "hbmpUnchecked", "I");
+ MENUITEMINFOFc.dwItemData = (*env)->GetFieldID(env, MENUITEMINFOFc.clazz, "dwItemData", "I");
+ MENUITEMINFOFc.dwTypeData = (*env)->GetFieldID(env, MENUITEMINFOFc.clazz, "dwTypeData", "I");
+ MENUITEMINFOFc.cch = (*env)->GetFieldID(env, MENUITEMINFOFc.clazz, "cch", "I");
+#ifndef _WIN32_WCE
+ MENUITEMINFOFc.hbmpItem = (*env)->GetFieldID(env, MENUITEMINFOFc.clazz, "hbmpItem", "I");
+#endif /* _WIN32_WCE */
+ MENUITEMINFOFc.cached = 1;
+}
+
+MENUITEMINFO *getMENUITEMINFOFields(JNIEnv *env, jobject lpObject, MENUITEMINFO *lpStruct)
+{
+ if (!MENUITEMINFOFc.cached) cacheMENUITEMINFOFids(env, lpObject);
+ lpStruct->cbSize = (*env)->GetIntField(env, lpObject, MENUITEMINFOFc.cbSize);
+ lpStruct->fMask = (*env)->GetIntField(env, lpObject, MENUITEMINFOFc.fMask);
+ lpStruct->fType = (*env)->GetIntField(env, lpObject, MENUITEMINFOFc.fType);
+ lpStruct->fState = (*env)->GetIntField(env, lpObject, MENUITEMINFOFc.fState);
+ lpStruct->wID = (*env)->GetIntField(env, lpObject, MENUITEMINFOFc.wID);
+ lpStruct->hSubMenu = (HMENU)(*env)->GetIntField(env, lpObject, MENUITEMINFOFc.hSubMenu);
+ lpStruct->hbmpChecked = (HBITMAP)(*env)->GetIntField(env, lpObject, MENUITEMINFOFc.hbmpChecked);
+ lpStruct->hbmpUnchecked = (HBITMAP)(*env)->GetIntField(env, lpObject, MENUITEMINFOFc.hbmpUnchecked);
+ lpStruct->dwItemData = (*env)->GetIntField(env, lpObject, MENUITEMINFOFc.dwItemData);
+ lpStruct->dwTypeData = (LPTSTR)(*env)->GetIntField(env, lpObject, MENUITEMINFOFc.dwTypeData);
+ lpStruct->cch = (*env)->GetIntField(env, lpObject, MENUITEMINFOFc.cch);
+#ifndef _WIN32_WCE
+ lpStruct->hbmpItem = (HBITMAP)(*env)->GetIntField(env, lpObject, MENUITEMINFOFc.hbmpItem);
+#endif /* _WIN32_WCE */
+ return lpStruct;
+}
+
+void setMENUITEMINFOFields(JNIEnv *env, jobject lpObject, MENUITEMINFO *lpStruct)
+{
+ if (!MENUITEMINFOFc.cached) cacheMENUITEMINFOFids(env, lpObject);
+ (*env)->SetIntField(env, lpObject, MENUITEMINFOFc.cbSize, (jint)lpStruct->cbSize);
+ (*env)->SetIntField(env, lpObject, MENUITEMINFOFc.fMask, (jint)lpStruct->fMask);
+ (*env)->SetIntField(env, lpObject, MENUITEMINFOFc.fType, (jint)lpStruct->fType);
+ (*env)->SetIntField(env, lpObject, MENUITEMINFOFc.fState, (jint)lpStruct->fState);
+ (*env)->SetIntField(env, lpObject, MENUITEMINFOFc.wID, (jint)lpStruct->wID);
+ (*env)->SetIntField(env, lpObject, MENUITEMINFOFc.hSubMenu, (jint)lpStruct->hSubMenu);
+ (*env)->SetIntField(env, lpObject, MENUITEMINFOFc.hbmpChecked, (jint)lpStruct->hbmpChecked);
+ (*env)->SetIntField(env, lpObject, MENUITEMINFOFc.hbmpUnchecked, (jint)lpStruct->hbmpUnchecked);
+ (*env)->SetIntField(env, lpObject, MENUITEMINFOFc.dwItemData, (jint)lpStruct->dwItemData);
+ (*env)->SetIntField(env, lpObject, MENUITEMINFOFc.dwTypeData, (jint)lpStruct->dwTypeData);
+ (*env)->SetIntField(env, lpObject, MENUITEMINFOFc.cch, (jint)lpStruct->cch);
+#ifndef _WIN32_WCE
+ (*env)->SetIntField(env, lpObject, MENUITEMINFOFc.hbmpItem, (jint)lpStruct->hbmpItem);
+#endif /* _WIN32_WCE */
+}
+#endif /* NO_MENUITEMINFO */
+
+#ifndef NO_MSG
+typedef struct MSG_FID_CACHE {
+ int cached;
+ jclass clazz;
+ jfieldID hwnd, message, wParam, lParam, time, x, y;
+} MSG_FID_CACHE;
+
+MSG_FID_CACHE MSGFc;
+
+void cacheMSGFids(JNIEnv *env, jobject lpObject)
+{
+ if (MSGFc.cached) return;
+ MSGFc.clazz = (*env)->GetObjectClass(env, lpObject);
+ MSGFc.hwnd = (*env)->GetFieldID(env, MSGFc.clazz, "hwnd", "I");
+ MSGFc.message = (*env)->GetFieldID(env, MSGFc.clazz, "message", "I");
+ MSGFc.wParam = (*env)->GetFieldID(env, MSGFc.clazz, "wParam", "I");
+ MSGFc.lParam = (*env)->GetFieldID(env, MSGFc.clazz, "lParam", "I");
+ MSGFc.time = (*env)->GetFieldID(env, MSGFc.clazz, "time", "I");
+ MSGFc.x = (*env)->GetFieldID(env, MSGFc.clazz, "x", "I");
+ MSGFc.y = (*env)->GetFieldID(env, MSGFc.clazz, "y", "I");
+ MSGFc.cached = 1;
+}
+
+MSG *getMSGFields(JNIEnv *env, jobject lpObject, MSG *lpStruct)
+{
+ if (!MSGFc.cached) cacheMSGFids(env, lpObject);
+ lpStruct->hwnd = (HWND)(*env)->GetIntField(env, lpObject, MSGFc.hwnd);
+ lpStruct->message = (*env)->GetIntField(env, lpObject, MSGFc.message);
+ lpStruct->wParam = (*env)->GetIntField(env, lpObject, MSGFc.wParam);
+ lpStruct->lParam = (*env)->GetIntField(env, lpObject, MSGFc.lParam);
+ lpStruct->time = (*env)->GetIntField(env, lpObject, MSGFc.time);
+ lpStruct->pt.x = (*env)->GetIntField(env, lpObject, MSGFc.x);
+ lpStruct->pt.y = (*env)->GetIntField(env, lpObject, MSGFc.y);
+ return lpStruct;
+}
+
+void setMSGFields(JNIEnv *env, jobject lpObject, MSG *lpStruct)
+{
+ if (!MSGFc.cached) cacheMSGFids(env, lpObject);
+ (*env)->SetIntField(env, lpObject, MSGFc.hwnd, (jint)lpStruct->hwnd);
+ (*env)->SetIntField(env, lpObject, MSGFc.message, (jint)lpStruct->message);
+ (*env)->SetIntField(env, lpObject, MSGFc.wParam, (jint)lpStruct->wParam);
+ (*env)->SetIntField(env, lpObject, MSGFc.lParam, (jint)lpStruct->lParam);
+ (*env)->SetIntField(env, lpObject, MSGFc.time, (jint)lpStruct->time);
+ (*env)->SetIntField(env, lpObject, MSGFc.x, (jint)lpStruct->pt.x);
+ (*env)->SetIntField(env, lpObject, MSGFc.y, (jint)lpStruct->pt.y);
+}
+#endif /* NO_MSG */
+
+#ifndef NO_NMHDR
+typedef struct NMHDR_FID_CACHE {
+ int cached;
+ jclass clazz;
+ jfieldID hwndFrom, idFrom, code;
+} NMHDR_FID_CACHE;
+
+NMHDR_FID_CACHE NMHDRFc;
+
+void cacheNMHDRFids(JNIEnv *env, jobject lpObject)
+{
+ if (NMHDRFc.cached) return;
+ NMHDRFc.clazz = (*env)->GetObjectClass(env, lpObject);
+ NMHDRFc.hwndFrom = (*env)->GetFieldID(env, NMHDRFc.clazz, "hwndFrom", "I");
+ NMHDRFc.idFrom = (*env)->GetFieldID(env, NMHDRFc.clazz, "idFrom", "I");
+ NMHDRFc.code = (*env)->GetFieldID(env, NMHDRFc.clazz, "code", "I");
+ NMHDRFc.cached = 1;
+}
+
+NMHDR *getNMHDRFields(JNIEnv *env, jobject lpObject, NMHDR *lpStruct)
+{
+ if (!NMHDRFc.cached) cacheNMHDRFids(env, lpObject);
+ lpStruct->hwndFrom = (HWND)(*env)->GetIntField(env, lpObject, NMHDRFc.hwndFrom);
+ lpStruct->idFrom = (*env)->GetIntField(env, lpObject, NMHDRFc.idFrom);
+ lpStruct->code = (*env)->GetIntField(env, lpObject, NMHDRFc.code);
+ return lpStruct;
+}
+
+void setNMHDRFields(JNIEnv *env, jobject lpObject, NMHDR *lpStruct)
+{
+ if (!NMHDRFc.cached) cacheNMHDRFids(env, lpObject);
+ (*env)->SetIntField(env, lpObject, NMHDRFc.hwndFrom, (jint)lpStruct->hwndFrom);
+ (*env)->SetIntField(env, lpObject, NMHDRFc.idFrom, (jint)lpStruct->idFrom);
+ (*env)->SetIntField(env, lpObject, NMHDRFc.code, (jint)lpStruct->code);
+}
+#endif /* NO_NMHDR */
+
+#ifndef NO_NMCUSTOMDRAW
+typedef struct NMCUSTOMDRAW_FID_CACHE {
+ int cached;
+ jclass clazz;
+ jfieldID dwDrawStage, hdc, left, top, right, bottom, dwItemSpec, uItemState, lItemlParam;
+} NMCUSTOMDRAW_FID_CACHE;
+
+NMCUSTOMDRAW_FID_CACHE NMCUSTOMDRAWFc;
+
+void cacheNMCUSTOMDRAWFids(JNIEnv *env, jobject lpObject)
+{
+ if (NMCUSTOMDRAWFc.cached) return;
+ cacheNMHDRFids(env, lpObject);
+ NMCUSTOMDRAWFc.clazz = (*env)->GetObjectClass(env, lpObject);
+ NMCUSTOMDRAWFc.dwDrawStage = (*env)->GetFieldID(env, NMCUSTOMDRAWFc.clazz, "dwDrawStage", "I");
+ NMCUSTOMDRAWFc.hdc = (*env)->GetFieldID(env, NMCUSTOMDRAWFc.clazz, "hdc", "I");
+ NMCUSTOMDRAWFc.left = (*env)->GetFieldID(env, NMCUSTOMDRAWFc.clazz, "left", "I");
+ NMCUSTOMDRAWFc.top = (*env)->GetFieldID(env, NMCUSTOMDRAWFc.clazz, "top", "I");
+ NMCUSTOMDRAWFc.right = (*env)->GetFieldID(env, NMCUSTOMDRAWFc.clazz, "right", "I");
+ NMCUSTOMDRAWFc.bottom = (*env)->GetFieldID(env, NMCUSTOMDRAWFc.clazz, "bottom", "I");
+ NMCUSTOMDRAWFc.dwItemSpec = (*env)->GetFieldID(env, NMCUSTOMDRAWFc.clazz, "dwItemSpec", "I");
+ NMCUSTOMDRAWFc.uItemState = (*env)->GetFieldID(env, NMCUSTOMDRAWFc.clazz, "uItemState", "I");
+ NMCUSTOMDRAWFc.lItemlParam = (*env)->GetFieldID(env, NMCUSTOMDRAWFc.clazz, "lItemlParam", "I");
+ NMCUSTOMDRAWFc.cached = 1;
+}
+
+NMCUSTOMDRAW *getNMCUSTOMDRAWFields(JNIEnv *env, jobject lpObject, NMCUSTOMDRAW *lpStruct)
+{
+ if (!NMCUSTOMDRAWFc.cached) cacheNMCUSTOMDRAWFids(env, lpObject);
+ getNMHDRFields(env, lpObject, (NMHDR *)lpStruct);
+ lpStruct->dwDrawStage = (*env)->GetIntField(env, lpObject, NMCUSTOMDRAWFc.dwDrawStage);
+ lpStruct->hdc = (HDC)(*env)->GetIntField(env, lpObject, NMCUSTOMDRAWFc.hdc);
+ lpStruct->rc.left = (*env)->GetIntField(env, lpObject, NMCUSTOMDRAWFc.left);
+ lpStruct->rc.top = (*env)->GetIntField(env, lpObject, NMCUSTOMDRAWFc.top);
+ lpStruct->rc.right = (*env)->GetIntField(env, lpObject, NMCUSTOMDRAWFc.right);
+ lpStruct->rc.bottom = (*env)->GetIntField(env, lpObject, NMCUSTOMDRAWFc.bottom);
+ lpStruct->dwItemSpec = (*env)->GetIntField(env, lpObject, NMCUSTOMDRAWFc.dwItemSpec);
+ lpStruct->uItemState = (*env)->GetIntField(env, lpObject, NMCUSTOMDRAWFc.uItemState);
+ lpStruct->lItemlParam = (*env)->GetIntField(env, lpObject, NMCUSTOMDRAWFc.lItemlParam);
+ return lpStruct;
+}
+
+void setNMCUSTOMDRAWFields(JNIEnv *env, jobject lpObject, NMCUSTOMDRAW *lpStruct)
+{
+ if (!NMCUSTOMDRAWFc.cached) cacheNMCUSTOMDRAWFids(env, lpObject);
+ setNMHDRFields(env, lpObject, (NMHDR *)lpStruct);
+ (*env)->SetIntField(env, lpObject, NMCUSTOMDRAWFc.dwDrawStage, (jint)lpStruct->dwDrawStage);
+ (*env)->SetIntField(env, lpObject, NMCUSTOMDRAWFc.hdc, (jint)lpStruct->hdc);
+ (*env)->SetIntField(env, lpObject, NMCUSTOMDRAWFc.left, (jint)lpStruct->rc.left);
+ (*env)->SetIntField(env, lpObject, NMCUSTOMDRAWFc.top, (jint)lpStruct->rc.top);
+ (*env)->SetIntField(env, lpObject, NMCUSTOMDRAWFc.right, (jint)lpStruct->rc.right);
+ (*env)->SetIntField(env, lpObject, NMCUSTOMDRAWFc.bottom, (jint)lpStruct->rc.bottom);
+ (*env)->SetIntField(env, lpObject, NMCUSTOMDRAWFc.dwItemSpec, (jint)lpStruct->dwItemSpec);
+ (*env)->SetIntField(env, lpObject, NMCUSTOMDRAWFc.uItemState, (jint)lpStruct->uItemState);
+ (*env)->SetIntField(env, lpObject, NMCUSTOMDRAWFc.lItemlParam, (jint)lpStruct->lItemlParam);
+}
+#endif /* NO_NMCUSTOMDRAW */
+
+#ifndef NO_NMHEADER
+typedef struct NMHEADER_FID_CACHE {
+ int cached;
+ jclass clazz;
+ jfieldID iItem, iButton, pitem;
+} NMHEADER_FID_CACHE;
+
+NMHEADER_FID_CACHE NMHEADERFc;
+
+void cacheNMHEADERFids(JNIEnv *env, jobject lpObject)
+{
+ if (NMHEADERFc.cached) return;
+ cacheNMHDRFids(env, lpObject);
+ NMHEADERFc.clazz = (*env)->GetObjectClass(env, lpObject);
+ NMHEADERFc.iItem = (*env)->GetFieldID(env, NMHEADERFc.clazz, "iItem", "I");
+ NMHEADERFc.iButton = (*env)->GetFieldID(env, NMHEADERFc.clazz, "iButton", "I");
+ NMHEADERFc.pitem = (*env)->GetFieldID(env, NMHEADERFc.clazz, "pitem", "I");
+ NMHEADERFc.cached = 1;
+}
+
+NMHEADER *getNMHEADERFields(JNIEnv *env, jobject lpObject, NMHEADER *lpStruct)
+{
+ if (!NMHEADERFc.cached) cacheNMHEADERFids(env, lpObject);
+ getNMHDRFields(env, lpObject, (NMHDR *)lpStruct);
+ lpStruct->iItem = (*env)->GetIntField(env, lpObject, NMHEADERFc.iItem);
+ lpStruct->iButton = (*env)->GetIntField(env, lpObject, NMHEADERFc.iButton);
+ lpStruct->pitem = (HDITEM FAR *)(*env)->GetIntField(env, lpObject, NMHEADERFc.pitem);
+ return lpStruct;
+}
+
+void setNMHEADERFields(JNIEnv *env, jobject lpObject, NMHEADER *lpStruct)
+{
+ if (!NMHEADERFc.cached) cacheNMHEADERFids(env, lpObject);
+ setNMHDRFields(env, lpObject, (NMHDR *)lpStruct);
+ (*env)->SetIntField(env, lpObject, NMHEADERFc.iItem, (jint)lpStruct->iItem);
+ (*env)->SetIntField(env, lpObject, NMHEADERFc.iButton, (jint)lpStruct->iButton);
+ (*env)->SetIntField(env, lpObject, NMHEADERFc.pitem, (jint)lpStruct->pitem);
+}
+#endif /* NO_NMHEADER */
+
+#ifndef NO_NMLISTVIEW
+typedef struct NMLISTVIEW_FID_CACHE {
+ int cached;
+ jclass clazz;
+ jfieldID iItem, iSubItem, uNewState, uOldState, uChanged, x, y, lParam;
+} NMLISTVIEW_FID_CACHE;
+
+NMLISTVIEW_FID_CACHE NMLISTVIEWFc;
+
+void cacheNMLISTVIEWFids(JNIEnv *env, jobject lpObject)
+{
+ if (NMLISTVIEWFc.cached) return;
+ cacheNMHDRFids(env, lpObject);
+ NMLISTVIEWFc.clazz = (*env)->GetObjectClass(env, lpObject);
+ NMLISTVIEWFc.iItem = (*env)->GetFieldID(env, NMLISTVIEWFc.clazz, "iItem", "I");
+ NMLISTVIEWFc.iSubItem = (*env)->GetFieldID(env, NMLISTVIEWFc.clazz, "iSubItem", "I");
+ NMLISTVIEWFc.uNewState = (*env)->GetFieldID(env, NMLISTVIEWFc.clazz, "uNewState", "I");
+ NMLISTVIEWFc.uOldState = (*env)->GetFieldID(env, NMLISTVIEWFc.clazz, "uOldState", "I");
+ NMLISTVIEWFc.uChanged = (*env)->GetFieldID(env, NMLISTVIEWFc.clazz, "uChanged", "I");
+ NMLISTVIEWFc.x = (*env)->GetFieldID(env, NMLISTVIEWFc.clazz, "x", "I");
+ NMLISTVIEWFc.y = (*env)->GetFieldID(env, NMLISTVIEWFc.clazz, "y", "I");
+ NMLISTVIEWFc.lParam = (*env)->GetFieldID(env, NMLISTVIEWFc.clazz, "lParam", "I");
+ NMLISTVIEWFc.cached = 1;
+}
+
+NMLISTVIEW *getNMLISTVIEWFields(JNIEnv *env, jobject lpObject, NMLISTVIEW *lpStruct)
+{
+ if (!NMLISTVIEWFc.cached) cacheNMLISTVIEWFids(env, lpObject);
+ getNMHDRFields(env, lpObject, (NMHDR *)lpStruct);
+ lpStruct->iItem = (*env)->GetIntField(env, lpObject, NMLISTVIEWFc.iItem);
+ lpStruct->iSubItem = (*env)->GetIntField(env, lpObject, NMLISTVIEWFc.iSubItem);
+ lpStruct->uNewState = (*env)->GetIntField(env, lpObject, NMLISTVIEWFc.uNewState);
+ lpStruct->uOldState = (*env)->GetIntField(env, lpObject, NMLISTVIEWFc.uOldState);
+ lpStruct->uChanged = (*env)->GetIntField(env, lpObject, NMLISTVIEWFc.uChanged);
+ lpStruct->ptAction.x = (*env)->GetIntField(env, lpObject, NMLISTVIEWFc.x);
+ lpStruct->ptAction.y = (*env)->GetIntField(env, lpObject, NMLISTVIEWFc.y);
+ lpStruct->lParam = (*env)->GetIntField(env, lpObject, NMLISTVIEWFc.lParam);
+ return lpStruct;
+}
+
+void setNMLISTVIEWFields(JNIEnv *env, jobject lpObject, NMLISTVIEW *lpStruct)
+{
+ if (!NMLISTVIEWFc.cached) cacheNMLISTVIEWFids(env, lpObject);
+ setNMHDRFields(env, lpObject, (NMHDR *)lpStruct);
+ (*env)->SetIntField(env, lpObject, NMLISTVIEWFc.iItem, (jint)lpStruct->iItem);
+ (*env)->SetIntField(env, lpObject, NMLISTVIEWFc.iSubItem, (jint)lpStruct->iSubItem);
+ (*env)->SetIntField(env, lpObject, NMLISTVIEWFc.uNewState, (jint)lpStruct->uNewState);
+ (*env)->SetIntField(env, lpObject, NMLISTVIEWFc.uOldState, (jint)lpStruct->uOldState);
+ (*env)->SetIntField(env, lpObject, NMLISTVIEWFc.uChanged, (jint)lpStruct->uChanged);
+ (*env)->SetIntField(env, lpObject, NMLISTVIEWFc.x, (jint)lpStruct->ptAction.x);
+ (*env)->SetIntField(env, lpObject, NMLISTVIEWFc.y, (jint)lpStruct->ptAction.y);
+ (*env)->SetIntField(env, lpObject, NMLISTVIEWFc.lParam, (jint)lpStruct->lParam);
+}
+#endif /* NO_NMLISTVIEW */
+
+#ifndef NO_NMLVCUSTOMDRAW
+typedef struct NMLVCUSTOMDRAW_FID_CACHE {
+ int cached;
+ jclass clazz;
+ jfieldID clrText, clrTextBk, iSubItem;
+} NMLVCUSTOMDRAW_FID_CACHE;
+
+NMLVCUSTOMDRAW_FID_CACHE NMLVCUSTOMDRAWFc;
+
+void cacheNMLVCUSTOMDRAWFids(JNIEnv *env, jobject lpObject)
+{
+ if (NMLVCUSTOMDRAWFc.cached) return;
+ cacheNMCUSTOMDRAWFids(env, lpObject);
+ NMLVCUSTOMDRAWFc.clazz = (*env)->GetObjectClass(env, lpObject);
+ NMLVCUSTOMDRAWFc.clrText = (*env)->GetFieldID(env, NMLVCUSTOMDRAWFc.clazz, "clrText", "I");
+ NMLVCUSTOMDRAWFc.clrTextBk = (*env)->GetFieldID(env, NMLVCUSTOMDRAWFc.clazz, "clrTextBk", "I");
+ NMLVCUSTOMDRAWFc.iSubItem = (*env)->GetFieldID(env, NMLVCUSTOMDRAWFc.clazz, "iSubItem", "I");
+ NMLVCUSTOMDRAWFc.cached = 1;
+}
+
+NMLVCUSTOMDRAW *getNMLVCUSTOMDRAWFields(JNIEnv *env, jobject lpObject, NMLVCUSTOMDRAW *lpStruct)
+{
+ if (!NMLVCUSTOMDRAWFc.cached) cacheNMLVCUSTOMDRAWFids(env, lpObject);
+ getNMCUSTOMDRAWFields(env, lpObject, (NMCUSTOMDRAW *)lpStruct);
+ lpStruct->clrText = (*env)->GetIntField(env, lpObject, NMLVCUSTOMDRAWFc.clrText);
+ lpStruct->clrTextBk = (*env)->GetIntField(env, lpObject, NMLVCUSTOMDRAWFc.clrTextBk);
+ lpStruct->iSubItem = (*env)->GetIntField(env, lpObject, NMLVCUSTOMDRAWFc.iSubItem);
+ return lpStruct;
+}
+
+void setNMLVCUSTOMDRAWFields(JNIEnv *env, jobject lpObject, NMLVCUSTOMDRAW *lpStruct)
+{
+ if (!NMLVCUSTOMDRAWFc.cached) cacheNMLVCUSTOMDRAWFids(env, lpObject);
+ setNMCUSTOMDRAWFields(env, lpObject, (NMCUSTOMDRAW *)lpStruct);
+ (*env)->SetIntField(env, lpObject, NMLVCUSTOMDRAWFc.clrText, (jint)lpStruct->clrText);
+ (*env)->SetIntField(env, lpObject, NMLVCUSTOMDRAWFc.clrTextBk, (jint)lpStruct->clrTextBk);
+ (*env)->SetIntField(env, lpObject, NMLVCUSTOMDRAWFc.iSubItem, (jint)lpStruct->iSubItem);
+}
+#endif /* NO_NMLVCUSTOMDRAW */
+
+#ifndef NO_NMREBARCHEVRON
+typedef struct NMREBARCHEVRON_FID_CACHE {
+ int cached;
+ jclass clazz;
+ jfieldID uBand, wID, lParam, left, top, right, bottom, lParamNM;
+} NMREBARCHEVRON_FID_CACHE;
+
+NMREBARCHEVRON_FID_CACHE NMREBARCHEVRONFc;
+
+void cacheNMREBARCHEVRONFids(JNIEnv *env, jobject lpObject)
+{
+ if (NMREBARCHEVRONFc.cached) return;
+ cacheNMHDRFids(env, lpObject);
+ NMREBARCHEVRONFc.clazz = (*env)->GetObjectClass(env, lpObject);
+ NMREBARCHEVRONFc.uBand = (*env)->GetFieldID(env, NMREBARCHEVRONFc.clazz, "uBand", "I");
+ NMREBARCHEVRONFc.wID = (*env)->GetFieldID(env, NMREBARCHEVRONFc.clazz, "wID", "I");
+ NMREBARCHEVRONFc.lParam = (*env)->GetFieldID(env, NMREBARCHEVRONFc.clazz, "lParam", "I");
+ NMREBARCHEVRONFc.left = (*env)->GetFieldID(env, NMREBARCHEVRONFc.clazz, "left", "I");
+ NMREBARCHEVRONFc.top = (*env)->GetFieldID(env, NMREBARCHEVRONFc.clazz, "top", "I");
+ NMREBARCHEVRONFc.right = (*env)->GetFieldID(env, NMREBARCHEVRONFc.clazz, "right", "I");
+ NMREBARCHEVRONFc.bottom = (*env)->GetFieldID(env, NMREBARCHEVRONFc.clazz, "bottom", "I");
+ NMREBARCHEVRONFc.lParamNM = (*env)->GetFieldID(env, NMREBARCHEVRONFc.clazz, "lParamNM", "I");
+ NMREBARCHEVRONFc.cached = 1;
+}
+
+NMREBARCHEVRON *getNMREBARCHEVRONFields(JNIEnv *env, jobject lpObject, NMREBARCHEVRON *lpStruct)
+{
+ if (!NMREBARCHEVRONFc.cached) cacheNMREBARCHEVRONFids(env, lpObject);
+ getNMHDRFields(env, lpObject, (NMHDR *)lpStruct);
+ lpStruct->uBand = (*env)->GetIntField(env, lpObject, NMREBARCHEVRONFc.uBand);
+ lpStruct->wID = (*env)->GetIntField(env, lpObject, NMREBARCHEVRONFc.wID);
+ lpStruct->lParam = (*env)->GetIntField(env, lpObject, NMREBARCHEVRONFc.lParam);
+ lpStruct->rc.left = (*env)->GetIntField(env, lpObject, NMREBARCHEVRONFc.left);
+ lpStruct->rc.top = (*env)->GetIntField(env, lpObject, NMREBARCHEVRONFc.top);
+ lpStruct->rc.right = (*env)->GetIntField(env, lpObject, NMREBARCHEVRONFc.right);
+ lpStruct->rc.bottom = (*env)->GetIntField(env, lpObject, NMREBARCHEVRONFc.bottom);
+ lpStruct->lParamNM = (*env)->GetIntField(env, lpObject, NMREBARCHEVRONFc.lParamNM);
+ return lpStruct;
+}
+
+void setNMREBARCHEVRONFields(JNIEnv *env, jobject lpObject, NMREBARCHEVRON *lpStruct)
+{
+ if (!NMREBARCHEVRONFc.cached) cacheNMREBARCHEVRONFids(env, lpObject);
+ setNMHDRFields(env, lpObject, (NMHDR *)lpStruct);
+ (*env)->SetIntField(env, lpObject, NMREBARCHEVRONFc.uBand, (jint)lpStruct->uBand);
+ (*env)->SetIntField(env, lpObject, NMREBARCHEVRONFc.wID, (jint)lpStruct->wID);
+ (*env)->SetIntField(env, lpObject, NMREBARCHEVRONFc.lParam, (jint)lpStruct->lParam);
+ (*env)->SetIntField(env, lpObject, NMREBARCHEVRONFc.left, (jint)lpStruct->rc.left);
+ (*env)->SetIntField(env, lpObject, NMREBARCHEVRONFc.top, (jint)lpStruct->rc.top);
+ (*env)->SetIntField(env, lpObject, NMREBARCHEVRONFc.right, (jint)lpStruct->rc.right);
+ (*env)->SetIntField(env, lpObject, NMREBARCHEVRONFc.bottom, (jint)lpStruct->rc.bottom);
+ (*env)->SetIntField(env, lpObject, NMREBARCHEVRONFc.lParamNM, (jint)lpStruct->lParamNM);
+}
+#endif /* NO_NMREBARCHEVRON */
+
+#ifndef NO_NMTOOLBAR
+typedef struct NMTOOLBAR_FID_CACHE {
+ int cached;
+ jclass clazz;
+ jfieldID iItem, iBitmap, idCommand, fsState, fsStyle, dwData, iString, cchText, pszText;
+#ifndef _WIN32_WCE
+ jfieldID left, top, right, bottom;
+#endif /* _WIN32_WCE */
+} NMTOOLBAR_FID_CACHE;
+
+NMTOOLBAR_FID_CACHE NMTOOLBARFc;
+
+void cacheNMTOOLBARFids(JNIEnv *env, jobject lpObject)
+{
+ if (NMTOOLBARFc.cached) return;
+ cacheNMHDRFids(env, lpObject);
+ NMTOOLBARFc.clazz = (*env)->GetObjectClass(env, lpObject);
+ NMTOOLBARFc.iItem = (*env)->GetFieldID(env, NMTOOLBARFc.clazz, "iItem", "I");
+ NMTOOLBARFc.iBitmap = (*env)->GetFieldID(env, NMTOOLBARFc.clazz, "iBitmap", "I");
+ NMTOOLBARFc.idCommand = (*env)->GetFieldID(env, NMTOOLBARFc.clazz, "idCommand", "I");
+ NMTOOLBARFc.fsState = (*env)->GetFieldID(env, NMTOOLBARFc.clazz, "fsState", "B");
+ NMTOOLBARFc.fsStyle = (*env)->GetFieldID(env, NMTOOLBARFc.clazz, "fsStyle", "B");
+ NMTOOLBARFc.dwData = (*env)->GetFieldID(env, NMTOOLBARFc.clazz, "dwData", "I");
+ NMTOOLBARFc.iString = (*env)->GetFieldID(env, NMTOOLBARFc.clazz, "iString", "I");
+ NMTOOLBARFc.cchText = (*env)->GetFieldID(env, NMTOOLBARFc.clazz, "cchText", "I");
+ NMTOOLBARFc.pszText = (*env)->GetFieldID(env, NMTOOLBARFc.clazz, "pszText", "I");
+#ifndef _WIN32_WCE
+ NMTOOLBARFc.left = (*env)->GetFieldID(env, NMTOOLBARFc.clazz, "left", "I");
+ NMTOOLBARFc.top = (*env)->GetFieldID(env, NMTOOLBARFc.clazz, "top", "I");
+ NMTOOLBARFc.right = (*env)->GetFieldID(env, NMTOOLBARFc.clazz, "right", "I");
+ NMTOOLBARFc.bottom = (*env)->GetFieldID(env, NMTOOLBARFc.clazz, "bottom", "I");
+#endif /* _WIN32_WCE */
+ NMTOOLBARFc.cached = 1;
+}
+
+NMTOOLBAR *getNMTOOLBARFields(JNIEnv *env, jobject lpObject, NMTOOLBAR *lpStruct)
+{
+ if (!NMTOOLBARFc.cached) cacheNMTOOLBARFids(env, lpObject);
+ getNMHDRFields(env, lpObject, (NMHDR *)lpStruct);
+ lpStruct->iItem = (*env)->GetIntField(env, lpObject, NMTOOLBARFc.iItem);
+ lpStruct->tbButton.iBitmap = (*env)->GetIntField(env, lpObject, NMTOOLBARFc.iBitmap);
+ lpStruct->tbButton.idCommand = (*env)->GetIntField(env, lpObject, NMTOOLBARFc.idCommand);
+ lpStruct->tbButton.fsState = (*env)->GetByteField(env, lpObject, NMTOOLBARFc.fsState);
+ lpStruct->tbButton.fsStyle = (*env)->GetByteField(env, lpObject, NMTOOLBARFc.fsStyle);
+ lpStruct->tbButton.dwData = (*env)->GetIntField(env, lpObject, NMTOOLBARFc.dwData);
+ lpStruct->tbButton.iString = (*env)->GetIntField(env, lpObject, NMTOOLBARFc.iString);
+ lpStruct->cchText = (*env)->GetIntField(env, lpObject, NMTOOLBARFc.cchText);
+ lpStruct->pszText = (LPTSTR)(*env)->GetIntField(env, lpObject, NMTOOLBARFc.pszText);
+#ifndef _WIN32_WCE
+ lpStruct->rcButton.left = (*env)->GetIntField(env, lpObject, NMTOOLBARFc.left);
+ lpStruct->rcButton.top = (*env)->GetIntField(env, lpObject, NMTOOLBARFc.top);
+ lpStruct->rcButton.right = (*env)->GetIntField(env, lpObject, NMTOOLBARFc.right);
+ lpStruct->rcButton.bottom = (*env)->GetIntField(env, lpObject, NMTOOLBARFc.bottom);
+#endif /* _WIN32_WCE */
+ return lpStruct;
+}
+
+void setNMTOOLBARFields(JNIEnv *env, jobject lpObject, NMTOOLBAR *lpStruct)
+{
+ if (!NMTOOLBARFc.cached) cacheNMTOOLBARFids(env, lpObject);
+ setNMHDRFields(env, lpObject, (NMHDR *)lpStruct);
+ (*env)->SetIntField(env, lpObject, NMTOOLBARFc.iItem, (jint)lpStruct->iItem);
+ (*env)->SetIntField(env, lpObject, NMTOOLBARFc.iBitmap, (jint)lpStruct->tbButton.iBitmap);
+ (*env)->SetIntField(env, lpObject, NMTOOLBARFc.idCommand, (jint)lpStruct->tbButton.idCommand);
+ (*env)->SetByteField(env, lpObject, NMTOOLBARFc.fsState, (jbyte)lpStruct->tbButton.fsState);
+ (*env)->SetByteField(env, lpObject, NMTOOLBARFc.fsStyle, (jbyte)lpStruct->tbButton.fsStyle);
+ (*env)->SetIntField(env, lpObject, NMTOOLBARFc.dwData, (jint)lpStruct->tbButton.dwData);
+ (*env)->SetIntField(env, lpObject, NMTOOLBARFc.iString, (jint)lpStruct->tbButton.iString);
+ (*env)->SetIntField(env, lpObject, NMTOOLBARFc.cchText, (jint)lpStruct->cchText);
+ (*env)->SetIntField(env, lpObject, NMTOOLBARFc.pszText, (jint)lpStruct->pszText);
+#ifndef _WIN32_WCE
+ (*env)->SetIntField(env, lpObject, NMTOOLBARFc.left, (jint)lpStruct->rcButton.left);
+ (*env)->SetIntField(env, lpObject, NMTOOLBARFc.top, (jint)lpStruct->rcButton.top);
+ (*env)->SetIntField(env, lpObject, NMTOOLBARFc.right, (jint)lpStruct->rcButton.right);
+ (*env)->SetIntField(env, lpObject, NMTOOLBARFc.bottom, (jint)lpStruct->rcButton.bottom);
+#endif /* _WIN32_WCE */
+}
+#endif /* NO_NMTOOLBAR */
+
+#ifndef NO_NMTTDISPINFO
+typedef struct NMTTDISPINFO_FID_CACHE {
+ int cached;
+ jclass clazz;
+ jfieldID lpszText, hinst, uFlags, lParam;
+} NMTTDISPINFO_FID_CACHE;
+
+NMTTDISPINFO_FID_CACHE NMTTDISPINFOFc;
+
+void cacheNMTTDISPINFOFids(JNIEnv *env, jobject lpObject)
+{
+ if (NMTTDISPINFOFc.cached) return;
+ cacheNMHDRFids(env, lpObject);
+ NMTTDISPINFOFc.clazz = (*env)->GetObjectClass(env, lpObject);
+ NMTTDISPINFOFc.lpszText = (*env)->GetFieldID(env, NMTTDISPINFOFc.clazz, "lpszText", "I");
+ NMTTDISPINFOFc.hinst = (*env)->GetFieldID(env, NMTTDISPINFOFc.clazz, "hinst", "I");
+ NMTTDISPINFOFc.uFlags = (*env)->GetFieldID(env, NMTTDISPINFOFc.clazz, "uFlags", "I");
+ NMTTDISPINFOFc.lParam = (*env)->GetFieldID(env, NMTTDISPINFOFc.clazz, "lParam", "I");
+ NMTTDISPINFOFc.cached = 1;
+}
+
+#ifndef NO_NMTTDISPINFOA
+NMTTDISPINFOA* getNMTTDISPINFOAFields(JNIEnv *env, jobject lpObject, NMTTDISPINFOA *lpStruct)
+{
+ if (!NMTTDISPINFOFc.cached) cacheNMTTDISPINFOFids(env, lpObject);
+ getNMHDRFields(env, lpObject, (NMHDR *)lpStruct);
+ lpStruct->lpszText = (LPTSTR)(*env)->GetIntField(env, lpObject, NMTTDISPINFOFc.lpszText);
+ lpStruct->hinst = (HINSTANCE)(*env)->GetIntField(env, lpObject, NMTTDISPINFOFc.hinst);
+ lpStruct->uFlags = (*env)->GetIntField(env, lpObject, NMTTDISPINFOFc.uFlags);
+ lpStruct->lParam = (*env)->GetIntField(env, lpObject, NMTTDISPINFOFc.lParam);
+ return lpStruct;
+}
+
+void setNMTTDISPINFOAFields(JNIEnv *env, jobject lpObject, NMTTDISPINFOA *lpStruct)
+{
+ if (!NMTTDISPINFOFc.cached) cacheNMTTDISPINFOFids(env, lpObject);
+ setNMHDRFields(env, lpObject, (NMHDR *)lpStruct);
+ (*env)->SetIntField(env, lpObject, NMTTDISPINFOFc.lpszText, (jint)lpStruct->lpszText);
+ (*env)->SetIntField(env, lpObject, NMTTDISPINFOFc.hinst, (jint)lpStruct->hinst);
+ (*env)->SetIntField(env, lpObject, NMTTDISPINFOFc.uFlags, lpStruct->uFlags);
+ (*env)->SetIntField(env, lpObject, NMTTDISPINFOFc.lParam, lpStruct->lParam);
+}
+#endif /* NO_NMTTDISPINFOA */
+
+#ifndef NO_NMTTDISPINFOW
+NMTTDISPINFOW *getNMTTDISPINFOWFields(JNIEnv *env, jobject lpObject, NMTTDISPINFOW *lpStruct)
+{
+ if (!NMTTDISPINFOFc.cached) cacheNMTTDISPINFOFids(env, lpObject);
+ getNMHDRFields(env, lpObject, (NMHDR *)lpStruct);
+ lpStruct->lpszText = (LPWSTR)(*env)->GetIntField(env, lpObject, NMTTDISPINFOFc.lpszText);
+ lpStruct->hinst = (HINSTANCE)(*env)->GetIntField(env, lpObject, NMTTDISPINFOFc.hinst);
+ lpStruct->uFlags = (*env)->GetIntField(env, lpObject, NMTTDISPINFOFc.uFlags);
+ lpStruct->lParam = (*env)->GetIntField(env, lpObject, NMTTDISPINFOFc.lParam);
+ return lpStruct;
+}
+
+void setNMTTDISPINFOWFields(JNIEnv *env, jobject lpObject, NMTTDISPINFOW *lpStruct)
+{
+ if (!NMTTDISPINFOFc.cached) cacheNMTTDISPINFOFids(env, lpObject);
+ setNMHDRFields(env, lpObject, (NMHDR *)lpStruct);
+ (*env)->SetIntField(env, lpObject, NMTTDISPINFOFc.lpszText, (jint)lpStruct->lpszText);
+ (*env)->SetIntField(env, lpObject, NMTTDISPINFOFc.hinst, (jint)lpStruct->hinst);
+ (*env)->SetIntField(env, lpObject, NMTTDISPINFOFc.uFlags, (jint)lpStruct->uFlags);
+ (*env)->SetIntField(env, lpObject, NMTTDISPINFOFc.lParam, (jint)lpStruct->lParam);
+}
+#endif /* NO_NMTTDISPINFOW */
+#endif /* NO_NMTTDISPINFO */
+
+#ifndef NO_NMTVCUSTOMDRAW
+typedef struct NMTVCUSTOMDRAW_FID_CACHE {
+ int cached;
+ jclass clazz;
+ jfieldID clrText, clrTextBk;
+#ifndef _WIN32_WCE
+ jfieldID iLevel;
+#endif /* _WIN32_WCE */
+} NMTVCUSTOMDRAW_FID_CACHE;
+
+NMTVCUSTOMDRAW_FID_CACHE NMTVCUSTOMDRAWFc;
+
+void cacheNMTVCUSTOMDRAWFids(JNIEnv *env, jobject lpObject)
+{
+ if (NMTVCUSTOMDRAWFc.cached) return;
+ cacheNMCUSTOMDRAWFids(env, lpObject);
+ NMTVCUSTOMDRAWFc.clazz = (*env)->GetObjectClass(env, lpObject);
+ NMTVCUSTOMDRAWFc.clrText = (*env)->GetFieldID(env, NMTVCUSTOMDRAWFc.clazz, "clrText", "I");
+ NMTVCUSTOMDRAWFc.clrTextBk = (*env)->GetFieldID(env, NMTVCUSTOMDRAWFc.clazz, "clrTextBk", "I");
+#ifndef _WIN32_WCE
+ NMTVCUSTOMDRAWFc.iLevel = (*env)->GetFieldID(env, NMTVCUSTOMDRAWFc.clazz, "iLevel", "I");
+#endif /* _WIN32_WCE */
+ NMTVCUSTOMDRAWFc.cached = 1;
+}
+
+NMTVCUSTOMDRAW *getNMTVCUSTOMDRAWFields(JNIEnv *env, jobject lpObject, NMTVCUSTOMDRAW *lpStruct)
+{
+ if (!NMTVCUSTOMDRAWFc.cached) cacheNMTVCUSTOMDRAWFids(env, lpObject);
+ getNMCUSTOMDRAWFields(env, lpObject, (NMCUSTOMDRAW *)lpStruct);
+ lpStruct->clrText = (*env)->GetIntField(env, lpObject, NMTVCUSTOMDRAWFc.clrText);
+ lpStruct->clrTextBk = (*env)->GetIntField(env, lpObject, NMTVCUSTOMDRAWFc.clrTextBk);
+#ifndef _WIN32_WCE
+ lpStruct->iLevel = (*env)->GetIntField(env, lpObject, NMTVCUSTOMDRAWFc.iLevel);
+#endif /* _WIN32_WCE */
+ return lpStruct;
+}
+
+void setNMTVCUSTOMDRAWFields(JNIEnv *env, jobject lpObject, NMTVCUSTOMDRAW *lpStruct)
+{
+ if (!NMTVCUSTOMDRAWFc.cached) cacheNMTVCUSTOMDRAWFids(env, lpObject);
+ setNMCUSTOMDRAWFields(env, lpObject, (NMCUSTOMDRAW *)lpStruct);
+ (*env)->SetIntField(env, lpObject, NMTVCUSTOMDRAWFc.clrText, (jint)lpStruct->clrText);
+ (*env)->SetIntField(env, lpObject, NMTVCUSTOMDRAWFc.clrTextBk, (jint)lpStruct->clrTextBk);
+#ifndef _WIN32_WCE
+ (*env)->SetIntField(env, lpObject, NMTVCUSTOMDRAWFc.iLevel, (jint)lpStruct->iLevel);
+#endif /* _WIN32_WCE */
+}
+#endif /* NO_NMTVCUSTOMDRAW */
+
+#ifndef NO_NONCLIENTMETRICS
+typedef struct NONCLIENTMETRICS_FID_CACHE {
+ int cached;
+ jclass clazz;
+ jfieldID cbSize, iBorderWidth, iScrollWidth, iScrollHeight, iCaptionWidth, iCaptionHeight, lfCaptionFont, iSmCaptionWidth, iSmCaptionHeight, lfSmCaptionFont, iMenuWidth, iMenuHeight, lfMenuFont, lfStatusFont, lfMessageFont;
+} NONCLIENTMETRICS_FID_CACHE;
+
+NONCLIENTMETRICS_FID_CACHE NONCLIENTMETRICSFc;
+
+void cacheNONCLIENTMETRICSFids(JNIEnv *env, jobject lpObject)
+{
+ if (NONCLIENTMETRICSFc.cached) return;
+ NONCLIENTMETRICSFc.clazz = (*env)->GetObjectClass(env, lpObject);
+ NONCLIENTMETRICSFc.cbSize = (*env)->GetFieldID(env, NONCLIENTMETRICSFc.clazz, "cbSize", "I");
+ NONCLIENTMETRICSFc.iBorderWidth = (*env)->GetFieldID(env, NONCLIENTMETRICSFc.clazz, "iBorderWidth", "I");
+ NONCLIENTMETRICSFc.iScrollWidth = (*env)->GetFieldID(env, NONCLIENTMETRICSFc.clazz, "iScrollWidth", "I");
+ NONCLIENTMETRICSFc.iScrollHeight = (*env)->GetFieldID(env, NONCLIENTMETRICSFc.clazz, "iScrollHeight", "I");
+ NONCLIENTMETRICSFc.iCaptionWidth = (*env)->GetFieldID(env, NONCLIENTMETRICSFc.clazz, "iCaptionWidth", "I");
+ NONCLIENTMETRICSFc.iCaptionHeight = (*env)->GetFieldID(env, NONCLIENTMETRICSFc.clazz, "iCaptionHeight", "I");
+ NONCLIENTMETRICSFc.lfCaptionFont = (*env)->GetFieldID(env, NONCLIENTMETRICSFc.clazz, "lfCaptionFont", "Lorg/eclipse/swt/internal/win32/LOGFONT;");
+ NONCLIENTMETRICSFc.iSmCaptionWidth = (*env)->GetFieldID(env, NONCLIENTMETRICSFc.clazz, "iSmCaptionWidth", "I");
+ NONCLIENTMETRICSFc.iSmCaptionHeight = (*env)->GetFieldID(env, NONCLIENTMETRICSFc.clazz, "iSmCaptionHeight", "I");
+ NONCLIENTMETRICSFc.lfSmCaptionFont = (*env)->GetFieldID(env, NONCLIENTMETRICSFc.clazz, "lfSmCaptionFont", "Lorg/eclipse/swt/internal/win32/LOGFONT;");
+ NONCLIENTMETRICSFc.iMenuWidth = (*env)->GetFieldID(env, NONCLIENTMETRICSFc.clazz, "iMenuWidth", "I");
+ NONCLIENTMETRICSFc.iMenuHeight = (*env)->GetFieldID(env, NONCLIENTMETRICSFc.clazz, "iMenuHeight", "I");
+ NONCLIENTMETRICSFc.lfMenuFont = (*env)->GetFieldID(env, NONCLIENTMETRICSFc.clazz, "lfMenuFont", "Lorg/eclipse/swt/internal/win32/LOGFONT;");
+ NONCLIENTMETRICSFc.lfStatusFont = (*env)->GetFieldID(env, NONCLIENTMETRICSFc.clazz, "lfStatusFont", "Lorg/eclipse/swt/internal/win32/LOGFONT;");
+ NONCLIENTMETRICSFc.lfMessageFont = (*env)->GetFieldID(env, NONCLIENTMETRICSFc.clazz, "lfMessageFont", "Lorg/eclipse/swt/internal/win32/LOGFONT;");
+ NONCLIENTMETRICSFc.cached = 1;
+}
+
+#ifndef NONCLIENTMETRICSA
+NONCLIENTMETRICSA* getNONCLIENTMETRICSAFields(JNIEnv *env, jobject lpObject, NONCLIENTMETRICSA *lpStruct)
+{
+ if (!NONCLIENTMETRICSFc.cached) cacheNONCLIENTMETRICSFids(env, lpObject);
+ lpStruct->cbSize = (*env)->GetIntField(env, lpObject, NONCLIENTMETRICSFc.cbSize);
+ lpStruct->iBorderWidth = (*env)->GetIntField(env, lpObject, NONCLIENTMETRICSFc.iBorderWidth);
+ lpStruct->iScrollWidth = (*env)->GetIntField(env, lpObject, NONCLIENTMETRICSFc.iScrollWidth);
+ lpStruct->iScrollHeight = (*env)->GetIntField(env, lpObject, NONCLIENTMETRICSFc.iScrollHeight);
+ lpStruct->iCaptionWidth = (*env)->GetIntField(env, lpObject, NONCLIENTMETRICSFc.iCaptionWidth);
+ lpStruct->iCaptionHeight = (*env)->GetIntField(env, lpObject, NONCLIENTMETRICSFc.iCaptionHeight);
+ {
+ jobject lpLogfont = (*env)->GetObjectField(env, lpObject, NONCLIENTMETRICSFc.lfCaptionFont);
+ getLOGFONTAFields(env, lpLogfont, &lpStruct->lfCaptionFont);
+ }
+ lpStruct->iSmCaptionWidth = (*env)->GetIntField(env, lpObject, NONCLIENTMETRICSFc.iSmCaptionWidth);
+ lpStruct->iSmCaptionHeight = (*env)->GetIntField(env, lpObject, NONCLIENTMETRICSFc.iSmCaptionHeight);
+ {
+ jobject lpLogfont = (*env)->GetObjectField(env, lpObject, NONCLIENTMETRICSFc.lfSmCaptionFont);
+ getLOGFONTAFields(env, lpLogfont, &lpStruct->lfSmCaptionFont);
+ }
+ lpStruct->iMenuWidth = (*env)->GetIntField(env, lpObject, NONCLIENTMETRICSFc.iMenuWidth);
+ lpStruct->iMenuHeight = (*env)->GetIntField(env, lpObject, NONCLIENTMETRICSFc.iMenuHeight);
+ {
+ jobject lpLogfont = (*env)->GetObjectField(env, lpObject, NONCLIENTMETRICSFc.lfMenuFont);
+ getLOGFONTAFields(env, lpLogfont, &lpStruct->lfMenuFont);
+ }
+ {
+ jobject lpLogfont = (*env)->GetObjectField(env, lpObject, NONCLIENTMETRICSFc.lfStatusFont);
+ getLOGFONTAFields(env, lpLogfont, &lpStruct->lfStatusFont);
+ }
+ {
+ jobject lpLogfont = (*env)->GetObjectField(env, lpObject, NONCLIENTMETRICSFc.lfMessageFont);
+ getLOGFONTAFields(env, lpLogfont, &lpStruct->lfMessageFont);
+ }
+ return lpStruct;
+}
+
+void setNONCLIENTMETRICSAFields(JNIEnv *env, jobject lpObject, NONCLIENTMETRICSA *lpStruct)
+{
+ if (!NONCLIENTMETRICSFc.cached) cacheNONCLIENTMETRICSFids(env, lpObject);
+ (*env)->SetIntField(env, lpObject, NONCLIENTMETRICSFc.cbSize, lpStruct->cbSize);
+ (*env)->SetIntField(env, lpObject, NONCLIENTMETRICSFc.iBorderWidth, lpStruct->iBorderWidth);
+ (*env)->SetIntField(env, lpObject, NONCLIENTMETRICSFc.iScrollWidth, lpStruct->iScrollWidth);
+ (*env)->SetIntField(env, lpObject, NONCLIENTMETRICSFc.iScrollHeight, lpStruct->iScrollHeight);
+ (*env)->SetIntField(env, lpObject, NONCLIENTMETRICSFc.iCaptionWidth, lpStruct->iCaptionWidth);
+ (*env)->SetIntField(env, lpObject, NONCLIENTMETRICSFc.iCaptionHeight, lpStruct->iCaptionHeight);
+ {
+ jobject lpLogfont = (*env)->GetObjectField(env, lpObject, NONCLIENTMETRICSFc.lfCaptionFont);
+ setLOGFONTAFields(env, lpLogfont, &lpStruct->lfCaptionFont);
+ }
+ (*env)->SetIntField(env, lpObject, NONCLIENTMETRICSFc.iSmCaptionWidth, lpStruct->iSmCaptionWidth);
+ (*env)->SetIntField(env, lpObject, NONCLIENTMETRICSFc.iSmCaptionHeight, lpStruct->iSmCaptionHeight);
+ {
+ jobject lpLogfont = (*env)->GetObjectField(env, lpObject, NONCLIENTMETRICSFc.lfSmCaptionFont);
+ setLOGFONTAFields(env, lpLogfont, &lpStruct->lfSmCaptionFont);
+ }
+ (*env)->SetIntField(env, lpObject, NONCLIENTMETRICSFc.iMenuWidth, lpStruct->iMenuWidth);
+ (*env)->SetIntField(env, lpObject, NONCLIENTMETRICSFc.iMenuHeight, lpStruct->iMenuHeight);
+ {
+ jobject lpLogfont = (*env)->GetObjectField(env, lpObject, NONCLIENTMETRICSFc.lfMenuFont);
+ setLOGFONTAFields(env, lpLogfont, &lpStruct->lfMenuFont);
+ }
+ {
+ jobject lpLogfont = (*env)->GetObjectField(env, lpObject, NONCLIENTMETRICSFc.lfStatusFont);
+ setLOGFONTAFields(env, lpLogfont, &lpStruct->lfStatusFont);
+ }
+ {
+ jobject lpLogfont = (*env)->GetObjectField(env, lpObject, NONCLIENTMETRICSFc.lfMessageFont);
+ setLOGFONTAFields(env, lpLogfont, &lpStruct->lfMessageFont);
+ }
+}
+#endif /* NONCLIENTMETRICSA */
+
+#ifndef NONCLIENTMETRICSW
+NONCLIENTMETRICSW *getNONCLIENTMETRICSWFields(JNIEnv *env, jobject lpObject, NONCLIENTMETRICSW *lpStruct)
+{
+ if (!NONCLIENTMETRICSFc.cached) cacheNONCLIENTMETRICSFids(env, lpObject);
+ lpStruct->cbSize = (*env)->GetIntField(env, lpObject, NONCLIENTMETRICSFc.cbSize);
+ lpStruct->iBorderWidth = (*env)->GetIntField(env, lpObject, NONCLIENTMETRICSFc.iBorderWidth);
+ lpStruct->iScrollWidth = (*env)->GetIntField(env, lpObject, NONCLIENTMETRICSFc.iScrollWidth);
+ lpStruct->iScrollHeight = (*env)->GetIntField(env, lpObject, NONCLIENTMETRICSFc.iScrollHeight);
+ lpStruct->iCaptionWidth = (*env)->GetIntField(env, lpObject, NONCLIENTMETRICSFc.iCaptionWidth);
+ lpStruct->iCaptionHeight = (*env)->GetIntField(env, lpObject, NONCLIENTMETRICSFc.iCaptionHeight);
+ {
+ jobject lpObject1 = (*env)->GetObjectField(env, lpObject, NONCLIENTMETRICSFc.lfCaptionFont);
+ getLOGFONTWFields(env, lpObject1, &lpStruct->lfCaptionFont);
+ }
+ lpStruct->iSmCaptionWidth = (*env)->GetIntField(env, lpObject, NONCLIENTMETRICSFc.iSmCaptionWidth);
+ lpStruct->iSmCaptionHeight = (*env)->GetIntField(env, lpObject, NONCLIENTMETRICSFc.iSmCaptionHeight);
+ {
+ jobject lpObject1 = (*env)->GetObjectField(env, lpObject, NONCLIENTMETRICSFc.lfSmCaptionFont);
+ getLOGFONTWFields(env, lpObject1, &lpStruct->lfSmCaptionFont);
+ }
+ lpStruct->iMenuWidth = (*env)->GetIntField(env, lpObject, NONCLIENTMETRICSFc.iMenuWidth);
+ lpStruct->iMenuHeight = (*env)->GetIntField(env, lpObject, NONCLIENTMETRICSFc.iMenuHeight);
+ {
+ jobject lpObject1 = (*env)->GetObjectField(env, lpObject, NONCLIENTMETRICSFc.lfMenuFont);
+ getLOGFONTWFields(env, lpObject1, &lpStruct->lfMenuFont);
+ }
+ {
+ jobject lpObject1 = (*env)->GetObjectField(env, lpObject, NONCLIENTMETRICSFc.lfStatusFont);
+ getLOGFONTWFields(env, lpObject1, &lpStruct->lfStatusFont);
+ }
+ {
+ jobject lpObject1 = (*env)->GetObjectField(env, lpObject, NONCLIENTMETRICSFc.lfMessageFont);
+ getLOGFONTWFields(env, lpObject1, &lpStruct->lfMessageFont);
+ }
+ return lpStruct;
+}
+
+void setNONCLIENTMETRICSWFields(JNIEnv *env, jobject lpObject, NONCLIENTMETRICSW *lpStruct)
+{
+ if (!NONCLIENTMETRICSFc.cached) cacheNONCLIENTMETRICSFids(env, lpObject);
+ (*env)->SetIntField(env, lpObject, NONCLIENTMETRICSFc.cbSize, (jint)lpStruct->cbSize);
+ (*env)->SetIntField(env, lpObject, NONCLIENTMETRICSFc.iBorderWidth, (jint)lpStruct->iBorderWidth);
+ (*env)->SetIntField(env, lpObject, NONCLIENTMETRICSFc.iScrollWidth, (jint)lpStruct->iScrollWidth);
+ (*env)->SetIntField(env, lpObject, NONCLIENTMETRICSFc.iScrollHeight, (jint)lpStruct->iScrollHeight);
+ (*env)->SetIntField(env, lpObject, NONCLIENTMETRICSFc.iCaptionWidth, (jint)lpStruct->iCaptionWidth);
+ (*env)->SetIntField(env, lpObject, NONCLIENTMETRICSFc.iCaptionHeight, (jint)lpStruct->iCaptionHeight);
+ {
+ jobject lpObject1 = (*env)->GetObjectField(env, lpObject, NONCLIENTMETRICSFc.lfCaptionFont);
+ setLOGFONTWFields(env, lpObject1, &lpStruct->lfCaptionFont);
+ }
+ (*env)->SetIntField(env, lpObject, NONCLIENTMETRICSFc.iSmCaptionWidth, (jint)lpStruct->iSmCaptionWidth);
+ (*env)->SetIntField(env, lpObject, NONCLIENTMETRICSFc.iSmCaptionHeight, (jint)lpStruct->iSmCaptionHeight);
+ {
+ jobject lpObject1 = (*env)->GetObjectField(env, lpObject, NONCLIENTMETRICSFc.lfSmCaptionFont);
+ setLOGFONTWFields(env, lpObject1, &lpStruct->lfSmCaptionFont);
+ }
+ (*env)->SetIntField(env, lpObject, NONCLIENTMETRICSFc.iMenuWidth, (jint)lpStruct->iMenuWidth);
+ (*env)->SetIntField(env, lpObject, NONCLIENTMETRICSFc.iMenuHeight, (jint)lpStruct->iMenuHeight);
+ {
+ jobject lpObject1 = (*env)->GetObjectField(env, lpObject, NONCLIENTMETRICSFc.lfMenuFont);
+ setLOGFONTWFields(env, lpObject1, &lpStruct->lfMenuFont);
+ }
+ {
+ jobject lpObject1 = (*env)->GetObjectField(env, lpObject, NONCLIENTMETRICSFc.lfStatusFont);
+ setLOGFONTWFields(env, lpObject1, &lpStruct->lfStatusFont);
+ }
+ {
+ jobject lpObject1 = (*env)->GetObjectField(env, lpObject, NONCLIENTMETRICSFc.lfMessageFont);
+ setLOGFONTWFields(env, lpObject1, &lpStruct->lfMessageFont);
+ }
+}
+#endif /* NONCLIENTMETRICSW */
+#endif /* NO_NONCLIENTMETRICS */
+
+#ifndef NO_OPENFILENAME
+typedef struct OPENFILENAME_FID_CACHE {
+ int cached;
+ jclass clazz;
+ jfieldID lStructSize, hwndOwner, hInstance, lpstrFilter, lpstrCustomFilter, nMaxCustFilter, nFilterIndex, lpstrFile, nMaxFile, lpstrFileTitle, nMaxFileTitle, lpstrInitialDir, lpstrTitle, Flags, nFileOffset, nFileExtension, lpstrDefExt, lCustData, lpfnHook, lpTemplateName;
+} OPENFILENAME_FID_CACHE;
+
+OPENFILENAME_FID_CACHE OPENFILENAMEFc;
+
+void cacheOPENFILENAMEFids(JNIEnv *env, jobject lpObject)
+{
+ if (OPENFILENAMEFc.cached) return;
+ OPENFILENAMEFc.clazz = (*env)->GetObjectClass(env, lpObject);
+ OPENFILENAMEFc.lStructSize = (*env)->GetFieldID(env, OPENFILENAMEFc.clazz, "lStructSize", "I");
+ OPENFILENAMEFc.hwndOwner = (*env)->GetFieldID(env, OPENFILENAMEFc.clazz, "hwndOwner", "I");
+ OPENFILENAMEFc.hInstance = (*env)->GetFieldID(env, OPENFILENAMEFc.clazz, "hInstance", "I");
+ OPENFILENAMEFc.lpstrFilter = (*env)->GetFieldID(env, OPENFILENAMEFc.clazz, "lpstrFilter", "I");
+ OPENFILENAMEFc.lpstrCustomFilter = (*env)->GetFieldID(env, OPENFILENAMEFc.clazz, "lpstrCustomFilter", "I");
+ OPENFILENAMEFc.nMaxCustFilter = (*env)->GetFieldID(env, OPENFILENAMEFc.clazz, "nMaxCustFilter", "I");
+ OPENFILENAMEFc.nFilterIndex = (*env)->GetFieldID(env, OPENFILENAMEFc.clazz, "nFilterIndex", "I");
+ OPENFILENAMEFc.lpstrFile = (*env)->GetFieldID(env, OPENFILENAMEFc.clazz, "lpstrFile", "I");
+ OPENFILENAMEFc.nMaxFile = (*env)->GetFieldID(env, OPENFILENAMEFc.clazz, "nMaxFile", "I");
+ OPENFILENAMEFc.lpstrFileTitle = (*env)->GetFieldID(env, OPENFILENAMEFc.clazz, "lpstrFileTitle", "I");
+ OPENFILENAMEFc.nMaxFileTitle = (*env)->GetFieldID(env, OPENFILENAMEFc.clazz, "nMaxFileTitle", "I");
+ OPENFILENAMEFc.lpstrInitialDir = (*env)->GetFieldID(env, OPENFILENAMEFc.clazz, "lpstrInitialDir", "I");
+ OPENFILENAMEFc.lpstrTitle = (*env)->GetFieldID(env, OPENFILENAMEFc.clazz, "lpstrTitle", "I");
+ OPENFILENAMEFc.Flags = (*env)->GetFieldID(env, OPENFILENAMEFc.clazz, "Flags", "I");
+ OPENFILENAMEFc.nFileOffset = (*env)->GetFieldID(env, OPENFILENAMEFc.clazz, "nFileOffset", "S");
+ OPENFILENAMEFc.nFileExtension = (*env)->GetFieldID(env, OPENFILENAMEFc.clazz, "nFileExtension", "S");
+ OPENFILENAMEFc.lpstrDefExt = (*env)->GetFieldID(env, OPENFILENAMEFc.clazz, "lpstrDefExt", "I");
+ OPENFILENAMEFc.lCustData = (*env)->GetFieldID(env, OPENFILENAMEFc.clazz, "lCustData", "I");
+ OPENFILENAMEFc.lpfnHook = (*env)->GetFieldID(env, OPENFILENAMEFc.clazz, "lpfnHook", "I");
+ OPENFILENAMEFc.lpTemplateName = (*env)->GetFieldID(env, OPENFILENAMEFc.clazz, "lpTemplateName", "I");
+ OPENFILENAMEFc.cached = 1;
+}
+
+OPENFILENAME *getOPENFILENAMEFields(JNIEnv *env, jobject lpObject, OPENFILENAME *lpStruct)
+{
+ if (!OPENFILENAMEFc.cached) cacheOPENFILENAMEFids(env, lpObject);
+ lpStruct->lStructSize = (*env)->GetIntField(env, lpObject, OPENFILENAMEFc.lStructSize);
+ lpStruct->hwndOwner = (HWND)(*env)->GetIntField(env, lpObject, OPENFILENAMEFc.hwndOwner);
+ lpStruct->hInstance = (HINSTANCE)(*env)->GetIntField(env, lpObject, OPENFILENAMEFc.hInstance);
+ lpStruct->lpstrFilter = (LPCTSTR)(*env)->GetIntField(env, lpObject, OPENFILENAMEFc.lpstrFilter);
+ lpStruct->lpstrCustomFilter = (LPTSTR)(*env)->GetIntField(env, lpObject, OPENFILENAMEFc.lpstrCustomFilter);
+ lpStruct->nMaxCustFilter = (*env)->GetIntField(env, lpObject, OPENFILENAMEFc.nMaxCustFilter);
+ lpStruct->nFilterIndex = (*env)->GetIntField(env, lpObject, OPENFILENAMEFc.nFilterIndex);
+ lpStruct->lpstrFile = (LPTSTR)(*env)->GetIntField(env, lpObject, OPENFILENAMEFc.lpstrFile);
+ lpStruct->nMaxFile = (*env)->GetIntField(env, lpObject, OPENFILENAMEFc.nMaxFile);
+ lpStruct->lpstrFileTitle = (LPTSTR)(*env)->GetIntField(env, lpObject, OPENFILENAMEFc.lpstrFileTitle);
+ lpStruct->nMaxFileTitle = (*env)->GetIntField(env, lpObject, OPENFILENAMEFc.nMaxFileTitle);
+ lpStruct->lpstrInitialDir = (LPCTSTR)(*env)->GetIntField(env, lpObject, OPENFILENAMEFc.lpstrInitialDir);
+ lpStruct->lpstrTitle = (LPCTSTR)(*env)->GetIntField(env, lpObject, OPENFILENAMEFc.lpstrTitle);
+ lpStruct->Flags = (*env)->GetIntField(env, lpObject, OPENFILENAMEFc.Flags);
+ lpStruct->nFileOffset = (*env)->GetShortField(env, lpObject, OPENFILENAMEFc.nFileOffset);
+ lpStruct->nFileExtension = (*env)->GetShortField(env, lpObject, OPENFILENAMEFc.nFileExtension);
+ lpStruct->lpstrDefExt = (LPCTSTR)(*env)->GetIntField(env, lpObject, OPENFILENAMEFc.lpstrDefExt);
+ lpStruct->lCustData = (*env)->GetIntField(env, lpObject, OPENFILENAMEFc.lCustData);
+ lpStruct->lpfnHook = (LPOFNHOOKPROC)(*env)->GetIntField(env, lpObject, OPENFILENAMEFc.lpfnHook);
+ lpStruct->lpTemplateName = (LPCTSTR)(*env)->GetIntField(env, lpObject, OPENFILENAMEFc.lpTemplateName);
+ return lpStruct;
+}
+
+void setOPENFILENAMEFields(JNIEnv *env, jobject lpObject, OPENFILENAME *lpStruct)
+{
+ if (!OPENFILENAMEFc.cached) cacheOPENFILENAMEFids(env, lpObject);
+ (*env)->SetIntField(env, lpObject, OPENFILENAMEFc.lStructSize, (jint)lpStruct->lStructSize);
+ (*env)->SetIntField(env, lpObject, OPENFILENAMEFc.hwndOwner, (jint)lpStruct->hwndOwner);
+ (*env)->SetIntField(env, lpObject, OPENFILENAMEFc.hInstance, (jint)lpStruct->hInstance);
+ (*env)->SetIntField(env, lpObject, OPENFILENAMEFc.lpstrFilter, (jint)lpStruct->lpstrFilter);
+ (*env)->SetIntField(env, lpObject, OPENFILENAMEFc.lpstrCustomFilter, (jint)lpStruct->lpstrCustomFilter);
+ (*env)->SetIntField(env, lpObject, OPENFILENAMEFc.nMaxCustFilter, (jint)lpStruct->nMaxCustFilter);
+ (*env)->SetIntField(env, lpObject, OPENFILENAMEFc.nFilterIndex, (jint)lpStruct->nFilterIndex);
+ (*env)->SetIntField(env, lpObject, OPENFILENAMEFc.lpstrFile, (jint)lpStruct->lpstrFile);
+ (*env)->SetIntField(env, lpObject, OPENFILENAMEFc.nMaxFile, (jint)lpStruct->nMaxFile);
+ (*env)->SetIntField(env, lpObject, OPENFILENAMEFc.lpstrFileTitle, (jint)lpStruct->lpstrFileTitle);
+ (*env)->SetIntField(env, lpObject, OPENFILENAMEFc.nMaxFileTitle, (jint)lpStruct->nMaxFileTitle);
+ (*env)->SetIntField(env, lpObject, OPENFILENAMEFc.lpstrInitialDir, (jint)lpStruct->lpstrInitialDir);
+ (*env)->SetIntField(env, lpObject, OPENFILENAMEFc.lpstrTitle, (jint)lpStruct->lpstrTitle);
+ (*env)->SetIntField(env, lpObject, OPENFILENAMEFc.Flags, (jint)lpStruct->Flags);
+ (*env)->SetShortField(env, lpObject, OPENFILENAMEFc.nFileOffset, (jshort)lpStruct->nFileOffset);
+ (*env)->SetShortField(env, lpObject, OPENFILENAMEFc.nFileExtension, (jshort)lpStruct->nFileExtension);
+ (*env)->SetIntField(env, lpObject, OPENFILENAMEFc.lpstrDefExt, (jint)lpStruct->lpstrDefExt);
+ (*env)->SetIntField(env, lpObject, OPENFILENAMEFc.lCustData, (jint)lpStruct->lCustData);
+ (*env)->SetIntField(env, lpObject, OPENFILENAMEFc.lpfnHook, (jint)lpStruct->lpfnHook);
+ (*env)->SetIntField(env, lpObject, OPENFILENAMEFc.lpTemplateName, (jint)lpStruct->lpTemplateName);
+}
+#endif /* NO_OPENFILENAME */
+
+#ifndef NO_OSVERSIONINFO
+typedef struct OSVERSIONINFO_FID_CACHE {
+ int cached;
+ jclass clazz;
+ jfieldID dwOSVersionInfoSize, dwMajorVersion, dwMinorVersion, dwBuildNumber, dwPlatformId;
+} OSVERSIONINFO_FID_CACHE;
+
+OSVERSIONINFO_FID_CACHE OSVERSIONINFOFc;
+
+void cacheOSVERSIONINFOFids(JNIEnv *env, jobject lpObject)
+{
+ if (OSVERSIONINFOFc.cached) return;
+ OSVERSIONINFOFc.clazz = (*env)->GetObjectClass(env, lpObject);
+ OSVERSIONINFOFc.dwOSVersionInfoSize = (*env)->GetFieldID(env, OSVERSIONINFOFc.clazz, "dwOSVersionInfoSize", "I");
+ OSVERSIONINFOFc.dwMajorVersion = (*env)->GetFieldID(env, OSVERSIONINFOFc.clazz, "dwMajorVersion", "I");
+ OSVERSIONINFOFc.dwMinorVersion = (*env)->GetFieldID(env, OSVERSIONINFOFc.clazz, "dwMinorVersion", "I");
+ OSVERSIONINFOFc.dwBuildNumber = (*env)->GetFieldID(env, OSVERSIONINFOFc.clazz, "dwBuildNumber", "I");
+ OSVERSIONINFOFc.dwPlatformId = (*env)->GetFieldID(env, OSVERSIONINFOFc.clazz, "dwPlatformId", "I");
+ OSVERSIONINFOFc.cached = 1;
+}
+
+#ifndef OSVERSIONINFOA
+OSVERSIONINFOA* getOSVERSIONINFOAFields(JNIEnv *env, jobject lpObject, OSVERSIONINFOA *lpStruct)
+{
+ if (!OSVERSIONINFOFc.cached) cacheOSVERSIONINFOFids(env, lpObject);
+ lpStruct->dwOSVersionInfoSize = (*env)->GetIntField(env, lpObject, OSVERSIONINFOFc.dwOSVersionInfoSize);
+ lpStruct->dwMajorVersion = (*env)->GetIntField(env, lpObject, OSVERSIONINFOFc.dwMajorVersion);
+ lpStruct->dwMinorVersion = (*env)->GetIntField(env, lpObject, OSVERSIONINFOFc.dwMinorVersion);
+ lpStruct->dwBuildNumber = (*env)->GetIntField(env, lpObject, OSVERSIONINFOFc.dwBuildNumber);
+ lpStruct->dwPlatformId = (*env)->GetIntField(env, lpObject, OSVERSIONINFOFc.dwPlatformId);
+ return lpStruct;
+}
+
+void setOSVERSIONINFOAFields(JNIEnv *env, jobject lpObject, OSVERSIONINFOA *lpStruct)
+{
+ if (!OSVERSIONINFOFc.cached) cacheOSVERSIONINFOFids(env, lpObject);
+ (*env)->SetIntField(env, lpObject, OSVERSIONINFOFc.dwOSVersionInfoSize, lpStruct->dwOSVersionInfoSize);
+ (*env)->SetIntField(env, lpObject, OSVERSIONINFOFc.dwMajorVersion, lpStruct->dwMajorVersion);
+ (*env)->SetIntField(env, lpObject, OSVERSIONINFOFc.dwMinorVersion, lpStruct->dwMinorVersion);
+ (*env)->SetIntField(env, lpObject, OSVERSIONINFOFc.dwBuildNumber, lpStruct->dwBuildNumber);
+ (*env)->SetIntField(env, lpObject, OSVERSIONINFOFc.dwPlatformId, lpStruct->dwPlatformId);
+}
+#endif /* OSVERSIONINFOA */
+
+#ifndef OSVERSIONINFOW
+OSVERSIONINFOW *getOSVERSIONINFOWFields(JNIEnv *env, jobject lpObject, OSVERSIONINFOW *lpStruct)
+{
+ if (!OSVERSIONINFOFc.cached) cacheOSVERSIONINFOFids(env, lpObject);
+ lpStruct->dwOSVersionInfoSize = (*env)->GetIntField(env, lpObject, OSVERSIONINFOFc.dwOSVersionInfoSize);
+ lpStruct->dwMajorVersion = (*env)->GetIntField(env, lpObject, OSVERSIONINFOFc.dwMajorVersion);
+ lpStruct->dwMinorVersion = (*env)->GetIntField(env, lpObject, OSVERSIONINFOFc.dwMinorVersion);
+ lpStruct->dwBuildNumber = (*env)->GetIntField(env, lpObject, OSVERSIONINFOFc.dwBuildNumber);
+ lpStruct->dwPlatformId = (*env)->GetIntField(env, lpObject, OSVERSIONINFOFc.dwPlatformId);
+ return lpStruct;
+}
+
+void setOSVERSIONINFOWFields(JNIEnv *env, jobject lpObject, OSVERSIONINFOW *lpStruct)
+{
+ if (!OSVERSIONINFOFc.cached) cacheOSVERSIONINFOFids(env, lpObject);
+ (*env)->SetIntField(env, lpObject, OSVERSIONINFOFc.dwOSVersionInfoSize, (jint)lpStruct->dwOSVersionInfoSize);
+ (*env)->SetIntField(env, lpObject, OSVERSIONINFOFc.dwMajorVersion, (jint)lpStruct->dwMajorVersion);
+ (*env)->SetIntField(env, lpObject, OSVERSIONINFOFc.dwMinorVersion, (jint)lpStruct->dwMinorVersion);
+ (*env)->SetIntField(env, lpObject, OSVERSIONINFOFc.dwBuildNumber, (jint)lpStruct->dwBuildNumber);
+ (*env)->SetIntField(env, lpObject, OSVERSIONINFOFc.dwPlatformId, (jint)lpStruct->dwPlatformId);
+}
+#endif /* OSVERSIONINFOW */
+#endif /* NO_OSVERSIONINFO */
+
+#ifndef NO_PAINTSTRUCT
+typedef struct PAINTSTRUCT_FID_CACHE {
+ int cached;
+ jclass clazz;
+ jfieldID hdc, fErase, left, top, right, bottom, fRestore, fIncUpdate /*, pad0, pad1, pad2, pad3, pad4, pad5, pad6, pad7 */;
+} PAINTSTRUCT_FID_CACHE;
+
+PAINTSTRUCT_FID_CACHE PAINTSTRUCTFc;
+
+void cachePAINTSTRUCTFids(JNIEnv *env, jobject lpObject)
+{
+ if (PAINTSTRUCTFc.cached) return;
+ PAINTSTRUCTFc.clazz = (*env)->GetObjectClass(env, lpObject);
+ PAINTSTRUCTFc.hdc = (*env)->GetFieldID(env, PAINTSTRUCTFc.clazz, "hdc", "I");
+ PAINTSTRUCTFc.fErase = (*env)->GetFieldID(env, PAINTSTRUCTFc.clazz, "fErase", "Z");
+ PAINTSTRUCTFc.left = (*env)->GetFieldID(env, PAINTSTRUCTFc.clazz, "left", "I");
+ PAINTSTRUCTFc.top = (*env)->GetFieldID(env, PAINTSTRUCTFc.clazz, "top", "I");
+ PAINTSTRUCTFc.right = (*env)->GetFieldID(env, PAINTSTRUCTFc.clazz, "right", "I");
+ PAINTSTRUCTFc.bottom = (*env)->GetFieldID(env, PAINTSTRUCTFc.clazz, "bottom", "I");
+ PAINTSTRUCTFc.fRestore = (*env)->GetFieldID(env, PAINTSTRUCTFc.clazz, "fRestore", "Z");
+ PAINTSTRUCTFc.fIncUpdate = (*env)->GetFieldID(env, PAINTSTRUCTFc.clazz, "fIncUpdate", "Z");
+ PAINTSTRUCTFc.cached = 1;
+}
+
+PAINTSTRUCT *getPAINTSTRUCTFields(JNIEnv *env, jobject lpObject, PAINTSTRUCT *lpStruct)
+{
+ if (!PAINTSTRUCTFc.cached) cachePAINTSTRUCTFids(env, lpObject);
+ lpStruct->hdc = (HDC)(*env)->GetIntField(env, lpObject, PAINTSTRUCTFc.hdc);
+ lpStruct->fErase = (*env)->GetBooleanField(env, lpObject, PAINTSTRUCTFc.fErase);
+ lpStruct->rcPaint.left = (*env)->GetIntField(env, lpObject, PAINTSTRUCTFc.left);
+ lpStruct->rcPaint.top = (*env)->GetIntField(env, lpObject, PAINTSTRUCTFc.top);
+ lpStruct->rcPaint.right = (*env)->GetIntField(env, lpObject, PAINTSTRUCTFc.right);
+ lpStruct->rcPaint.bottom = (*env)->GetIntField(env, lpObject, PAINTSTRUCTFc.bottom);
+ lpStruct->fRestore = (*env)->GetBooleanField(env, lpObject, PAINTSTRUCTFc.fRestore);
+ lpStruct->fIncUpdate = (*env)->GetBooleanField(env, lpObject, PAINTSTRUCTFc.fIncUpdate);
+ return lpStruct;
+}
+
+void setPAINTSTRUCTFields(JNIEnv *env, jobject lpObject, PAINTSTRUCT *lpStruct)
+{
+ if (!PAINTSTRUCTFc.cached) cachePAINTSTRUCTFids(env, lpObject);
+ (*env)->SetIntField(env, lpObject, PAINTSTRUCTFc.hdc, (jint)lpStruct->hdc);
+ (*env)->SetBooleanField(env, lpObject, PAINTSTRUCTFc.fErase, (jboolean)lpStruct->fErase);
+ (*env)->SetIntField(env, lpObject, PAINTSTRUCTFc.left, (jint)lpStruct->rcPaint.left);
+ (*env)->SetIntField(env, lpObject, PAINTSTRUCTFc.top, (jint)lpStruct->rcPaint.top);
+ (*env)->SetIntField(env, lpObject, PAINTSTRUCTFc.right, (jint)lpStruct->rcPaint.right);
+ (*env)->SetIntField(env, lpObject, PAINTSTRUCTFc.bottom, (jint)lpStruct->rcPaint.bottom);
+ (*env)->SetBooleanField(env, lpObject, PAINTSTRUCTFc.fRestore, (jboolean)lpStruct->fRestore);
+ (*env)->SetBooleanField(env, lpObject, PAINTSTRUCTFc.fIncUpdate, (jboolean)lpStruct->fIncUpdate);
+}
+#endif /* NO_PAINTSTRUCT */
+
+#ifndef NO_POINT
+typedef struct POINT_FID_CACHE {
+ int cached;
+ jclass clazz;
+ jfieldID x, y;
+} POINT_FID_CACHE;
+
+POINT_FID_CACHE POINTFc;
+
+void cachePOINTFids(JNIEnv *env, jobject lpObject)
+{
+ if (POINTFc.cached) return;
+ POINTFc.clazz = (*env)->GetObjectClass(env, lpObject);
+ POINTFc.x = (*env)->GetFieldID(env, POINTFc.clazz, "x", "I");
+ POINTFc.y = (*env)->GetFieldID(env, POINTFc.clazz, "y", "I");
+ POINTFc.cached = 1;
+}
+
+POINT *getPOINTFields(JNIEnv *env, jobject lpObject, POINT *lpStruct)
+{
+ if (!POINTFc.cached) cachePOINTFids(env, lpObject);
+ lpStruct->x = (*env)->GetIntField(env, lpObject, POINTFc.x);
+ lpStruct->y = (*env)->GetIntField(env, lpObject, POINTFc.y);
+ return lpStruct;
+}
+
+void setPOINTFields(JNIEnv *env, jobject lpObject, POINT *lpStruct)
+{
+ if (!POINTFc.cached) cachePOINTFids(env, lpObject);
+ (*env)->SetIntField(env, lpObject, POINTFc.x, (jint)lpStruct->x);
+ (*env)->SetIntField(env, lpObject, POINTFc.y, (jint)lpStruct->y);
+}
+#endif /* NO_POINT */
+
+#ifndef NO_PRINTDLG
+typedef struct PRINTDLG_FID_CACHE {
+ int cached;
+ jclass clazz;
+ jfieldID lStructSize, hwndOwner, hDevMode, hDevNames, hDC, Flags, nFromPage, nToPage, nMinPage, nMaxPage, nCopies, hInstance, lCustData, lpfnPrintHook, lpfnSetupHook, lpPrintTemplateName, lpSetupTemplateName, hPrintTemplate, hSetupTemplate;
+} PRINTDLG_FID_CACHE;
+
+PRINTDLG_FID_CACHE PRINTDLGFc;
+
+void cachePRINTDLGFids(JNIEnv *env, jobject lpObject)
+{
+ if (PRINTDLGFc.cached) return;
+ PRINTDLGFc.clazz = (*env)->GetObjectClass(env, lpObject);
+ PRINTDLGFc.lStructSize = (*env)->GetFieldID(env, PRINTDLGFc.clazz, "lStructSize", "I");
+ PRINTDLGFc.hwndOwner = (*env)->GetFieldID(env, PRINTDLGFc.clazz, "hwndOwner", "I");
+ PRINTDLGFc.hDevMode = (*env)->GetFieldID(env, PRINTDLGFc.clazz, "hDevMode", "I");
+ PRINTDLGFc.hDevNames = (*env)->GetFieldID(env, PRINTDLGFc.clazz, "hDevNames", "I");
+ PRINTDLGFc.hDC = (*env)->GetFieldID(env, PRINTDLGFc.clazz, "hDC", "I");
+ PRINTDLGFc.Flags = (*env)->GetFieldID(env, PRINTDLGFc.clazz, "Flags", "I");
+ PRINTDLGFc.nFromPage = (*env)->GetFieldID(env, PRINTDLGFc.clazz, "nFromPage", "S");
+ PRINTDLGFc.nToPage = (*env)->GetFieldID(env, PRINTDLGFc.clazz, "nToPage", "S");
+ PRINTDLGFc.nMinPage = (*env)->GetFieldID(env, PRINTDLGFc.clazz, "nMinPage", "S");
+ PRINTDLGFc.nMaxPage = (*env)->GetFieldID(env, PRINTDLGFc.clazz, "nMaxPage", "S");
+ PRINTDLGFc.nCopies = (*env)->GetFieldID(env, PRINTDLGFc.clazz, "nCopies", "S");
+ PRINTDLGFc.hInstance = (*env)->GetFieldID(env, PRINTDLGFc.clazz, "hInstance", "I");
+ PRINTDLGFc.lCustData = (*env)->GetFieldID(env, PRINTDLGFc.clazz, "lCustData", "I");
+ PRINTDLGFc.lpfnPrintHook = (*env)->GetFieldID(env, PRINTDLGFc.clazz, "lpfnPrintHook", "I");
+ PRINTDLGFc.lpfnSetupHook = (*env)->GetFieldID(env, PRINTDLGFc.clazz, "lpfnSetupHook", "I");
+ PRINTDLGFc.lpPrintTemplateName = (*env)->GetFieldID(env, PRINTDLGFc.clazz, "lpPrintTemplateName", "I");
+ PRINTDLGFc.lpSetupTemplateName = (*env)->GetFieldID(env, PRINTDLGFc.clazz, "lpSetupTemplateName", "I");
+ PRINTDLGFc.hPrintTemplate = (*env)->GetFieldID(env, PRINTDLGFc.clazz, "hPrintTemplate", "I");
+ PRINTDLGFc.hSetupTemplate = (*env)->GetFieldID(env, PRINTDLGFc.clazz, "hSetupTemplate", "I");
+ PRINTDLGFc.cached = 1;
+}
+
+PRINTDLG *getPRINTDLGFields(JNIEnv *env, jobject lpObject, PRINTDLG *lpStruct)
+{
+ if (!PRINTDLGFc.cached) cachePRINTDLGFids(env, lpObject);
+ lpStruct->lStructSize = (*env)->GetIntField(env, lpObject, PRINTDLGFc.lStructSize);
+ lpStruct->hwndOwner = (HWND)(*env)->GetIntField(env, lpObject, PRINTDLGFc.hwndOwner);
+ lpStruct->hDevMode = (HGLOBAL)(*env)->GetIntField(env, lpObject, PRINTDLGFc.hDevMode);
+ lpStruct->hDevNames = (HGLOBAL)(*env)->GetIntField(env, lpObject, PRINTDLGFc.hDevNames);
+ lpStruct->hDC = (HDC)(*env)->GetIntField(env, lpObject, PRINTDLGFc.hDC);
+ lpStruct->Flags = (*env)->GetIntField(env, lpObject, PRINTDLGFc.Flags);
+ lpStruct->nFromPage = (*env)->GetShortField(env, lpObject, PRINTDLGFc.nFromPage);
+ lpStruct->nToPage = (*env)->GetShortField(env, lpObject, PRINTDLGFc.nToPage);
+ lpStruct->nMinPage = (*env)->GetShortField(env, lpObject, PRINTDLGFc.nMinPage);
+ lpStruct->nMaxPage = (*env)->GetShortField(env, lpObject, PRINTDLGFc.nMaxPage);
+ lpStruct->nCopies = (*env)->GetShortField(env, lpObject, PRINTDLGFc.nCopies);
+ lpStruct->hInstance = (HINSTANCE)(*env)->GetIntField(env, lpObject, PRINTDLGFc.hInstance);
+ lpStruct->lCustData = (*env)->GetIntField(env, lpObject, PRINTDLGFc.lCustData);
+ lpStruct->lpfnPrintHook = (LPPRINTHOOKPROC)(*env)->GetIntField(env, lpObject, PRINTDLGFc.lpfnPrintHook);
+ lpStruct->lpfnSetupHook = (LPPRINTHOOKPROC)(*env)->GetIntField(env, lpObject, PRINTDLGFc.lpfnSetupHook);
+ lpStruct->lpPrintTemplateName = (LPCTSTR)(*env)->GetIntField(env, lpObject, PRINTDLGFc.lpPrintTemplateName);
+ lpStruct->lpSetupTemplateName = (LPCTSTR)(*env)->GetIntField(env, lpObject, PRINTDLGFc.lpSetupTemplateName);
+ lpStruct->hPrintTemplate = (HGLOBAL)(*env)->GetIntField(env, lpObject, PRINTDLGFc.hPrintTemplate);
+ lpStruct->hSetupTemplate = (HGLOBAL)(*env)->GetIntField(env, lpObject, PRINTDLGFc.hSetupTemplate);
+ return lpStruct;
+}
+
+void setPRINTDLGFields(JNIEnv *env, jobject lpObject, PRINTDLG *lpStruct)
+{
+ if (!PRINTDLGFc.cached) cachePRINTDLGFids(env, lpObject);
+ (*env)->SetIntField(env, lpObject, PRINTDLGFc.lStructSize, (jint)lpStruct->lStructSize);
+ (*env)->SetIntField(env, lpObject, PRINTDLGFc.hwndOwner, (jint)lpStruct->hwndOwner);
+ (*env)->SetIntField(env, lpObject, PRINTDLGFc.hDevMode, (jint)lpStruct->hDevMode);
+ (*env)->SetIntField(env, lpObject, PRINTDLGFc.hDevNames, (jint)lpStruct->hDevNames);
+ (*env)->SetIntField(env, lpObject, PRINTDLGFc.hDC, (jint)lpStruct->hDC);
+ (*env)->SetIntField(env, lpObject, PRINTDLGFc.Flags, (jint)lpStruct->Flags);
+ (*env)->SetShortField(env, lpObject, PRINTDLGFc.nFromPage, (jshort)lpStruct->nFromPage);
+ (*env)->SetShortField(env, lpObject, PRINTDLGFc.nToPage, (jshort)lpStruct->nToPage);
+ (*env)->SetShortField(env, lpObject, PRINTDLGFc.nMinPage, (jshort)lpStruct->nMinPage);
+ (*env)->SetShortField(env, lpObject, PRINTDLGFc.nMaxPage, (jshort)lpStruct->nMaxPage);
+ (*env)->SetShortField(env, lpObject, PRINTDLGFc.nCopies, (jshort)lpStruct->nCopies);
+ (*env)->SetIntField(env, lpObject, PRINTDLGFc.hInstance, (jint)lpStruct->hInstance);
+ (*env)->SetIntField(env, lpObject, PRINTDLGFc.lCustData, (jint)lpStruct->lCustData);
+ (*env)->SetIntField(env, lpObject, PRINTDLGFc.lpfnPrintHook, (jint)lpStruct->lpfnPrintHook);
+ (*env)->SetIntField(env, lpObject, PRINTDLGFc.lpfnSetupHook, (jint)lpStruct->lpfnSetupHook);
+ (*env)->SetIntField(env, lpObject, PRINTDLGFc.lpPrintTemplateName, (jint)lpStruct->lpPrintTemplateName);
+ (*env)->SetIntField(env, lpObject, PRINTDLGFc.lpSetupTemplateName, (jint)lpStruct->lpSetupTemplateName);
+ (*env)->SetIntField(env, lpObject, PRINTDLGFc.hPrintTemplate, (jint)lpStruct->hPrintTemplate);
+ (*env)->SetIntField(env, lpObject, PRINTDLGFc.hSetupTemplate, (jint)lpStruct->hSetupTemplate);
+}
+#endif /* NO_PRINTDLG */
+
+#ifndef NO_REBARBANDINFO
+typedef struct REBARBANDINFO_FID_CACHE {
+ int cached;
+ jclass clazz;
+ jfieldID cbSize, fMask, fStyle, clrFore, clrBack, lpText, cch, iImage, hwndChild, cxMinChild, cyMinChild, cx, hbmBack, wID, cyChild, cyMaxChild, cyIntegral, cxIdeal, lParam;
+#ifndef _WIN32_WCE
+ jfieldID cxHeader;
+#endif /* _WIN32_WCE */
+} REBARBANDINFO_FID_CACHE;
+
+REBARBANDINFO_FID_CACHE REBARBANDINFOFc;
+
+void cacheREBARBANDINFOFids(JNIEnv *env, jobject lpObject)
+{
+ if (REBARBANDINFOFc.cached) return;
+ REBARBANDINFOFc.clazz = (*env)->GetObjectClass(env, lpObject);
+ REBARBANDINFOFc.cbSize = (*env)->GetFieldID(env, REBARBANDINFOFc.clazz, "cbSize", "I");
+ REBARBANDINFOFc.fMask = (*env)->GetFieldID(env, REBARBANDINFOFc.clazz, "fMask", "I");
+ REBARBANDINFOFc.fStyle = (*env)->GetFieldID(env, REBARBANDINFOFc.clazz, "fStyle", "I");
+ REBARBANDINFOFc.clrFore = (*env)->GetFieldID(env, REBARBANDINFOFc.clazz, "clrFore", "I");
+ REBARBANDINFOFc.clrBack = (*env)->GetFieldID(env, REBARBANDINFOFc.clazz, "clrBack", "I");
+ REBARBANDINFOFc.lpText = (*env)->GetFieldID(env, REBARBANDINFOFc.clazz, "lpText", "I");
+ REBARBANDINFOFc.cch = (*env)->GetFieldID(env, REBARBANDINFOFc.clazz, "cch", "I");
+ REBARBANDINFOFc.iImage = (*env)->GetFieldID(env, REBARBANDINFOFc.clazz, "iImage", "I");
+ REBARBANDINFOFc.hwndChild = (*env)->GetFieldID(env, REBARBANDINFOFc.clazz, "hwndChild", "I");
+ REBARBANDINFOFc.cxMinChild = (*env)->GetFieldID(env, REBARBANDINFOFc.clazz, "cxMinChild", "I");
+ REBARBANDINFOFc.cyMinChild = (*env)->GetFieldID(env, REBARBANDINFOFc.clazz, "cyMinChild", "I");
+ REBARBANDINFOFc.cx = (*env)->GetFieldID(env, REBARBANDINFOFc.clazz, "cx", "I");
+ REBARBANDINFOFc.hbmBack = (*env)->GetFieldID(env, REBARBANDINFOFc.clazz, "hbmBack", "I");
+ REBARBANDINFOFc.wID = (*env)->GetFieldID(env, REBARBANDINFOFc.clazz, "wID", "I");
+ REBARBANDINFOFc.cyChild = (*env)->GetFieldID(env, REBARBANDINFOFc.clazz, "cyChild", "I");
+ REBARBANDINFOFc.cyMaxChild = (*env)->GetFieldID(env, REBARBANDINFOFc.clazz, "cyMaxChild", "I");
+ REBARBANDINFOFc.cyIntegral = (*env)->GetFieldID(env, REBARBANDINFOFc.clazz, "cyIntegral", "I");
+ REBARBANDINFOFc.cxIdeal = (*env)->GetFieldID(env, REBARBANDINFOFc.clazz, "cxIdeal", "I");
+ REBARBANDINFOFc.lParam = (*env)->GetFieldID(env, REBARBANDINFOFc.clazz, "lParam", "I");
+#ifndef _WIN32_WCE
+ REBARBANDINFOFc.cxHeader = (*env)->GetFieldID(env, REBARBANDINFOFc.clazz, "cxHeader", "I");
+#endif /* _WIN32_WCE */
+ REBARBANDINFOFc.cached = 1;
+}
+
+REBARBANDINFO *getREBARBANDINFOFields(JNIEnv *env, jobject lpObject, REBARBANDINFO *lpStruct)
+{
+ if (!REBARBANDINFOFc.cached) cacheREBARBANDINFOFids(env, lpObject);
+ lpStruct->cbSize = (*env)->GetIntField(env, lpObject, REBARBANDINFOFc.cbSize);
+ lpStruct->fMask = (*env)->GetIntField(env, lpObject, REBARBANDINFOFc.fMask);
+ lpStruct->fStyle = (*env)->GetIntField(env, lpObject, REBARBANDINFOFc.fStyle);
+ lpStruct->clrFore = (*env)->GetIntField(env, lpObject, REBARBANDINFOFc.clrFore);
+ lpStruct->clrBack = (*env)->GetIntField(env, lpObject, REBARBANDINFOFc.clrBack);
+ lpStruct->lpText = (LPTSTR)(*env)->GetIntField(env, lpObject, REBARBANDINFOFc.lpText);
+ lpStruct->cch = (*env)->GetIntField(env, lpObject, REBARBANDINFOFc.cch);
+ lpStruct->iImage = (*env)->GetIntField(env, lpObject, REBARBANDINFOFc.iImage);
+ lpStruct->hwndChild = (HWND)(*env)->GetIntField(env, lpObject, REBARBANDINFOFc.hwndChild);
+ lpStruct->cxMinChild = (*env)->GetIntField(env, lpObject, REBARBANDINFOFc.cxMinChild);
+ lpStruct->cyMinChild = (*env)->GetIntField(env, lpObject, REBARBANDINFOFc.cyMinChild);
+ lpStruct->cx = (*env)->GetIntField(env, lpObject, REBARBANDINFOFc.cx);
+ lpStruct->hbmBack = (HBITMAP)(*env)->GetIntField(env, lpObject, REBARBANDINFOFc.hbmBack);
+ lpStruct->wID = (*env)->GetIntField(env, lpObject, REBARBANDINFOFc.wID);
+ lpStruct->cyChild = (*env)->GetIntField(env, lpObject, REBARBANDINFOFc.cyChild);
+ lpStruct->cyMaxChild = (*env)->GetIntField(env, lpObject, REBARBANDINFOFc.cyMaxChild);
+ lpStruct->cyIntegral = (*env)->GetIntField(env, lpObject, REBARBANDINFOFc.cyIntegral);
+ lpStruct->cxIdeal = (*env)->GetIntField(env, lpObject, REBARBANDINFOFc.cxIdeal);
+ lpStruct->lParam = (*env)->GetIntField(env, lpObject, REBARBANDINFOFc.lParam);
+#ifndef _WIN32_WCE
+ lpStruct->cxHeader = (*env)->GetIntField(env, lpObject, REBARBANDINFOFc.cxHeader);
+#endif /* _WIN32_WCE */
+ return lpStruct;
+}
+
+void setREBARBANDINFOFields(JNIEnv *env, jobject lpObject, REBARBANDINFO *lpStruct)
+{
+ if (!REBARBANDINFOFc.cached) cacheREBARBANDINFOFids(env, lpObject);
+ (*env)->SetIntField(env, lpObject, REBARBANDINFOFc.cbSize, (jint)lpStruct->cbSize);
+ (*env)->SetIntField(env, lpObject, REBARBANDINFOFc.fMask, (jint)lpStruct->fMask);
+ (*env)->SetIntField(env, lpObject, REBARBANDINFOFc.fStyle, (jint)lpStruct->fStyle);
+ (*env)->SetIntField(env, lpObject, REBARBANDINFOFc.clrFore, (jint)lpStruct->clrFore);
+ (*env)->SetIntField(env, lpObject, REBARBANDINFOFc.clrBack, (jint)lpStruct->clrBack);
+ (*env)->SetIntField(env, lpObject, REBARBANDINFOFc.lpText, (jint)lpStruct->lpText);
+ (*env)->SetIntField(env, lpObject, REBARBANDINFOFc.cch, (jint)lpStruct->cch);
+ (*env)->SetIntField(env, lpObject, REBARBANDINFOFc.iImage, (jint)lpStruct->iImage);
+ (*env)->SetIntField(env, lpObject, REBARBANDINFOFc.hwndChild, (jint)lpStruct->hwndChild);
+ (*env)->SetIntField(env, lpObject, REBARBANDINFOFc.cxMinChild, (jint)lpStruct->cxMinChild);
+ (*env)->SetIntField(env, lpObject, REBARBANDINFOFc.cyMinChild, (jint)lpStruct->cyMinChild);
+ (*env)->SetIntField(env, lpObject, REBARBANDINFOFc.cx, (jint)lpStruct->cx);
+ (*env)->SetIntField(env, lpObject, REBARBANDINFOFc.hbmBack, (jint)lpStruct->hbmBack);
+ (*env)->SetIntField(env, lpObject, REBARBANDINFOFc.wID, (jint)lpStruct->wID);
+ (*env)->SetIntField(env, lpObject, REBARBANDINFOFc.cyChild, (jint)lpStruct->cyChild);
+ (*env)->SetIntField(env, lpObject, REBARBANDINFOFc.cyMaxChild, (jint)lpStruct->cyMaxChild);
+ (*env)->SetIntField(env, lpObject, REBARBANDINFOFc.cyIntegral, (jint)lpStruct->cyIntegral);
+ (*env)->SetIntField(env, lpObject, REBARBANDINFOFc.cxIdeal, (jint)lpStruct->cxIdeal);
+ (*env)->SetIntField(env, lpObject, REBARBANDINFOFc.lParam, (jint)lpStruct->lParam);
+#ifndef _WIN32_WCE
+ (*env)->SetIntField(env, lpObject, REBARBANDINFOFc.cxHeader, (jint)lpStruct->cxHeader);
+#endif /* _WIN32_WCE */
+}
+#endif /* NO_REBARBANDINFO */
+
+#ifndef NO_RECT
+typedef struct RECT_FID_CACHE {
+ int cached;
+ jclass clazz;
+ jfieldID left, top, right, bottom;
+} RECT_FID_CACHE;
+
+RECT_FID_CACHE RECTFc;
+
+void cacheRECTFids(JNIEnv *env, jobject lpObject)
+{
+ if (RECTFc.cached) return;
+ RECTFc.clazz = (*env)->GetObjectClass(env, lpObject);
+ RECTFc.left = (*env)->GetFieldID(env, RECTFc.clazz, "left", "I");
+ RECTFc.top = (*env)->GetFieldID(env, RECTFc.clazz, "top", "I");
+ RECTFc.right = (*env)->GetFieldID(env, RECTFc.clazz, "right", "I");
+ RECTFc.bottom = (*env)->GetFieldID(env, RECTFc.clazz, "bottom", "I");
+ RECTFc.cached = 1;
+}
+
+RECT *getRECTFields(JNIEnv *env, jobject lpObject, RECT *lpStruct)
+{
+ if (!RECTFc.cached) cacheRECTFids(env, lpObject);
+ lpStruct->left = (*env)->GetIntField(env, lpObject, RECTFc.left);
+ lpStruct->top = (*env)->GetIntField(env, lpObject, RECTFc.top);
+ lpStruct->right = (*env)->GetIntField(env, lpObject, RECTFc.right);
+ lpStruct->bottom = (*env)->GetIntField(env, lpObject, RECTFc.bottom);
+ return lpStruct;
+}
+
+void setRECTFields(JNIEnv *env, jobject lpObject, RECT *lpStruct)
+{
+ if (!RECTFc.cached) cacheRECTFids(env, lpObject);
+ (*env)->SetIntField(env, lpObject, RECTFc.left, (jint)lpStruct->left);
+ (*env)->SetIntField(env, lpObject, RECTFc.top, (jint)lpStruct->top);
+ (*env)->SetIntField(env, lpObject, RECTFc.right, (jint)lpStruct->right);
+ (*env)->SetIntField(env, lpObject, RECTFc.bottom, (jint)lpStruct->bottom);
+}
+#endif /* NO_RECT */
+
+#ifndef NO_SCROLLINFO
+typedef struct SCROLLINFO_FID_CACHE {
+ int cached;
+ jclass clazz;
+ jfieldID cbSize, fMask, nMin, nMax, nPage, nPos, nTrackPos;
+} SCROLLINFO_FID_CACHE;
+
+SCROLLINFO_FID_CACHE SCROLLINFOFc;
+
+void cacheSCROLLINFOFids(JNIEnv *env, jobject lpObject)
+{
+ if (SCROLLINFOFc.cached) return;
+ SCROLLINFOFc.clazz = (*env)->GetObjectClass(env, lpObject);
+ SCROLLINFOFc.cbSize = (*env)->GetFieldID(env, SCROLLINFOFc.clazz, "cbSize", "I");
+ SCROLLINFOFc.fMask = (*env)->GetFieldID(env, SCROLLINFOFc.clazz, "fMask", "I");
+ SCROLLINFOFc.nMin = (*env)->GetFieldID(env, SCROLLINFOFc.clazz, "nMin", "I");
+ SCROLLINFOFc.nMax = (*env)->GetFieldID(env, SCROLLINFOFc.clazz, "nMax", "I");
+ SCROLLINFOFc.nPage = (*env)->GetFieldID(env, SCROLLINFOFc.clazz, "nPage", "I");
+ SCROLLINFOFc.nPos = (*env)->GetFieldID(env, SCROLLINFOFc.clazz, "nPos", "I");
+ SCROLLINFOFc.nTrackPos = (*env)->GetFieldID(env, SCROLLINFOFc.clazz, "nTrackPos", "I");
+ SCROLLINFOFc.cached = 1;
+}
+
+SCROLLINFO *getSCROLLINFOFields(JNIEnv *env, jobject lpObject, SCROLLINFO *lpStruct)
+{
+ if (!SCROLLINFOFc.cached) cacheSCROLLINFOFids(env, lpObject);
+ lpStruct->cbSize = (*env)->GetIntField(env, lpObject, SCROLLINFOFc.cbSize);
+ lpStruct->fMask = (*env)->GetIntField(env, lpObject, SCROLLINFOFc.fMask);
+ lpStruct->nMin = (*env)->GetIntField(env, lpObject, SCROLLINFOFc.nMin);
+ lpStruct->nMax = (*env)->GetIntField(env, lpObject, SCROLLINFOFc.nMax);
+ lpStruct->nPage = (*env)->GetIntField(env, lpObject, SCROLLINFOFc.nPage);
+ lpStruct->nPos = (*env)->GetIntField(env, lpObject, SCROLLINFOFc.nPos);
+ lpStruct->nTrackPos = (*env)->GetIntField(env, lpObject, SCROLLINFOFc.nTrackPos);
+ return lpStruct;
+}
+
+void setSCROLLINFOFields(JNIEnv *env, jobject lpObject, SCROLLINFO *lpStruct)
+{
+ if (!SCROLLINFOFc.cached) cacheSCROLLINFOFids(env, lpObject);
+ (*env)->SetIntField(env, lpObject, SCROLLINFOFc.cbSize, (jint)lpStruct->cbSize);
+ (*env)->SetIntField(env, lpObject, SCROLLINFOFc.fMask, (jint)lpStruct->fMask);
+ (*env)->SetIntField(env, lpObject, SCROLLINFOFc.nMin, (jint)lpStruct->nMin);
+ (*env)->SetIntField(env, lpObject, SCROLLINFOFc.nMax, (jint)lpStruct->nMax);
+ (*env)->SetIntField(env, lpObject, SCROLLINFOFc.nPage, (jint)lpStruct->nPage);
+ (*env)->SetIntField(env, lpObject, SCROLLINFOFc.nPos, (jint)lpStruct->nPos);
+ (*env)->SetIntField(env, lpObject, SCROLLINFOFc.nTrackPos, (jint)lpStruct->nTrackPos);
+}
+#endif /* NO_SCROLLINFO */
+
+#ifndef NO_SHACTIVATEINFO
+typedef struct SHACTIVATEINFO_FID_CACHE {
+ int cached;
+ jclass clazz;
+ jfieldID cbSize, hwndLastFocus, fSipUp, fSipOnDeactivation, fActive, fReserved;
+} SHACTIVATEINFO_FID_CACHE;
+
+SHACTIVATEINFO_FID_CACHE SHACTIVATEINFOFc;
+
+void cacheSHACTIVATEINFOFids(JNIEnv *env, jobject lpObject)
+{
+ if (SHACTIVATEINFOFc.cached) return;
+ SHACTIVATEINFOFc.clazz = (*env)->GetObjectClass(env, lpObject);
+ SHACTIVATEINFOFc.cbSize = (*env)->GetFieldID(env, SHACTIVATEINFOFc.clazz, "cbSize", "I");
+ SHACTIVATEINFOFc.hwndLastFocus = (*env)->GetFieldID(env, SHACTIVATEINFOFc.clazz, "hwndLastFocus", "I");
+ SHACTIVATEINFOFc.fSipUp = (*env)->GetFieldID(env, SHACTIVATEINFOFc.clazz, "fSipUp", "I");
+ SHACTIVATEINFOFc.fSipOnDeactivation = (*env)->GetFieldID(env, SHACTIVATEINFOFc.clazz, "fSipOnDeactivation", "I");
+ SHACTIVATEINFOFc.fActive = (*env)->GetFieldID(env, SHACTIVATEINFOFc.clazz, "fActive", "I");
+ SHACTIVATEINFOFc.fReserved = (*env)->GetFieldID(env, SHACTIVATEINFOFc.clazz, "fReserved", "I");
+ SHACTIVATEINFOFc.cached = 1;
+}
+
+SHACTIVATEINFO *getSHACTIVATEINFOFields(JNIEnv *env, jobject lpObject, SHACTIVATEINFO *lpStruct)
+{
+ if (!SHACTIVATEINFOFc.cached) cacheSHACTIVATEINFOFids(env, lpObject);
+ lpStruct->cbSize = (*env)->GetIntField(env, lpObject, SHACTIVATEINFOFc.cbSize);
+ lpStruct->hwndLastFocus = (HWND)(*env)->GetIntField(env, lpObject, SHACTIVATEINFOFc.hwndLastFocus);
+ lpStruct->fSipUp = (*env)->GetIntField(env, lpObject, SHACTIVATEINFOFc.fSipUp);
+ lpStruct->fSipOnDeactivation = (*env)->GetIntField(env, lpObject, SHACTIVATEINFOFc.fSipOnDeactivation);
+ lpStruct->fActive = (*env)->GetIntField(env, lpObject, SHACTIVATEINFOFc.fActive);
+ lpStruct->fReserved = (*env)->GetIntField(env, lpObject, SHACTIVATEINFOFc.fReserved);
+ return lpStruct;
+}
+
+void setSHACTIVATEINFOFields(JNIEnv *env, jobject lpObject, SHACTIVATEINFO *lpStruct)
+{
+ if (!SHACTIVATEINFOFc.cached) cacheSHACTIVATEINFOFids(env, lpObject);
+ (*env)->SetIntField(env, lpObject, SHACTIVATEINFOFc.cbSize, (jint)lpStruct->cbSize);
+ (*env)->SetIntField(env, lpObject, SHACTIVATEINFOFc.hwndLastFocus, (jint)lpStruct->hwndLastFocus);
+ (*env)->SetIntField(env, lpObject, SHACTIVATEINFOFc.fSipUp, (jint)lpStruct->fSipUp);
+ (*env)->SetIntField(env, lpObject, SHACTIVATEINFOFc.fSipOnDeactivation, (jint)lpStruct->fSipOnDeactivation);
+ (*env)->SetIntField(env, lpObject, SHACTIVATEINFOFc.fActive, (jint)lpStruct->fActive);
+ (*env)->SetIntField(env, lpObject, SHACTIVATEINFOFc.fReserved, (jint)lpStruct->fReserved);
+}
+#endif /* NO_SHACTIVATEINFO */
+
+#ifndef NO_SHELLEXECUTEINFO
+typedef struct SHELLEXECUTEINFO_FID_CACHE {
+ int cached;
+ jclass clazz;
+ jfieldID cbSize, fMask, hwnd, lpVerb, lpFile, lpParameters, lpDirectory, nShow, hInstApp, lpIDList, lpClass, hkeyClass, dwHotKey, hIcon, hProcess;
+} SHELLEXECUTEINFO_FID_CACHE;
+
+SHELLEXECUTEINFO_FID_CACHE SHELLEXECUTEINFOFc;
+
+void cacheSHELLEXECUTEINFOFids(JNIEnv *env, jobject lpObject)
+{
+ if (SHELLEXECUTEINFOFc.cached) return;
+ SHELLEXECUTEINFOFc.clazz = (*env)->GetObjectClass(env, lpObject);
+ SHELLEXECUTEINFOFc.cbSize = (*env)->GetFieldID(env, SHELLEXECUTEINFOFc.clazz, "cbSize", "I");
+ SHELLEXECUTEINFOFc.fMask = (*env)->GetFieldID(env, SHELLEXECUTEINFOFc.clazz, "fMask", "I");
+ SHELLEXECUTEINFOFc.hwnd = (*env)->GetFieldID(env, SHELLEXECUTEINFOFc.clazz, "hwnd", "I");
+ SHELLEXECUTEINFOFc.lpVerb = (*env)->GetFieldID(env, SHELLEXECUTEINFOFc.clazz, "lpVerb", "I");
+ SHELLEXECUTEINFOFc.lpFile = (*env)->GetFieldID(env, SHELLEXECUTEINFOFc.clazz, "lpFile", "I");
+ SHELLEXECUTEINFOFc.lpParameters = (*env)->GetFieldID(env, SHELLEXECUTEINFOFc.clazz, "lpParameters", "I");
+ SHELLEXECUTEINFOFc.lpDirectory = (*env)->GetFieldID(env, SHELLEXECUTEINFOFc.clazz, "lpDirectory", "I");
+ SHELLEXECUTEINFOFc.nShow = (*env)->GetFieldID(env, SHELLEXECUTEINFOFc.clazz, "nShow", "I");
+ SHELLEXECUTEINFOFc.hInstApp = (*env)->GetFieldID(env, SHELLEXECUTEINFOFc.clazz, "hInstApp", "I");
+ SHELLEXECUTEINFOFc.lpIDList = (*env)->GetFieldID(env, SHELLEXECUTEINFOFc.clazz, "lpIDList", "I");
+ SHELLEXECUTEINFOFc.lpClass = (*env)->GetFieldID(env, SHELLEXECUTEINFOFc.clazz, "lpClass", "I");
+ SHELLEXECUTEINFOFc.hkeyClass = (*env)->GetFieldID(env, SHELLEXECUTEINFOFc.clazz, "hkeyClass", "I");
+ SHELLEXECUTEINFOFc.dwHotKey = (*env)->GetFieldID(env, SHELLEXECUTEINFOFc.clazz, "dwHotKey", "I");
+ SHELLEXECUTEINFOFc.hIcon = (*env)->GetFieldID(env, SHELLEXECUTEINFOFc.clazz, "hIcon", "I");
+ SHELLEXECUTEINFOFc.hProcess = (*env)->GetFieldID(env, SHELLEXECUTEINFOFc.clazz, "hProcess", "I");
+ SHELLEXECUTEINFOFc.cached = 1;
+}
+
+SHELLEXECUTEINFO *getSHELLEXECUTEINFOFields(JNIEnv *env, jobject lpObject, SHELLEXECUTEINFO *lpStruct)
+{
+ if (!SHELLEXECUTEINFOFc.cached) cacheSHELLEXECUTEINFOFids(env, lpObject);
+ lpStruct->cbSize = (*env)->GetIntField(env, lpObject, SHELLEXECUTEINFOFc.cbSize);
+ lpStruct->fMask = (*env)->GetIntField(env, lpObject, SHELLEXECUTEINFOFc.fMask);
+ lpStruct->hwnd = (HWND)(*env)->GetIntField(env, lpObject, SHELLEXECUTEINFOFc.hwnd);
+ lpStruct->lpVerb = (LPCTSTR)(*env)->GetIntField(env, lpObject, SHELLEXECUTEINFOFc.lpVerb);
+ lpStruct->lpFile = (LPCTSTR)(*env)->GetIntField(env, lpObject, SHELLEXECUTEINFOFc.lpFile);
+ lpStruct->lpParameters = (LPCTSTR)(*env)->GetIntField(env, lpObject, SHELLEXECUTEINFOFc.lpParameters);
+ lpStruct->lpDirectory = (LPCTSTR)(*env)->GetIntField(env, lpObject, SHELLEXECUTEINFOFc.lpDirectory);
+ lpStruct->nShow = (*env)->GetIntField(env, lpObject, SHELLEXECUTEINFOFc.nShow);
+ lpStruct->hInstApp = (HINSTANCE)(*env)->GetIntField(env, lpObject, SHELLEXECUTEINFOFc.hInstApp);
+ lpStruct->lpIDList = (LPVOID)(*env)->GetIntField(env, lpObject, SHELLEXECUTEINFOFc.lpIDList);
+ lpStruct->lpClass = (LPCTSTR)(*env)->GetIntField(env, lpObject, SHELLEXECUTEINFOFc.lpClass);
+ lpStruct->hkeyClass = (HKEY)(*env)->GetIntField(env, lpObject, SHELLEXECUTEINFOFc.hkeyClass);
+ lpStruct->dwHotKey = (*env)->GetIntField(env, lpObject, SHELLEXECUTEINFOFc.dwHotKey);
+ lpStruct->hIcon = (HANDLE)(*env)->GetIntField(env, lpObject, SHELLEXECUTEINFOFc.hIcon);
+ lpStruct->hProcess = (HANDLE)(*env)->GetIntField(env, lpObject, SHELLEXECUTEINFOFc.hProcess);
+ return lpStruct;
+}
+
+void setSHELLEXECUTEINFOFields(JNIEnv *env, jobject lpObject, SHELLEXECUTEINFO *lpStruct)
+{
+ if (!SHELLEXECUTEINFOFc.cached) cacheSHELLEXECUTEINFOFids(env, lpObject);
+ (*env)->SetIntField(env, lpObject, SHELLEXECUTEINFOFc.cbSize, (jint)lpStruct->cbSize);
+ (*env)->SetIntField(env, lpObject, SHELLEXECUTEINFOFc.fMask, (jint)lpStruct->fMask);
+ (*env)->SetIntField(env, lpObject, SHELLEXECUTEINFOFc.hwnd, (jint)lpStruct->hwnd);
+ (*env)->SetIntField(env, lpObject, SHELLEXECUTEINFOFc.lpVerb, (jint)lpStruct->lpVerb);
+ (*env)->SetIntField(env, lpObject, SHELLEXECUTEINFOFc.lpFile, (jint)lpStruct->lpFile);
+ (*env)->SetIntField(env, lpObject, SHELLEXECUTEINFOFc.lpParameters, (jint)lpStruct->lpParameters);
+ (*env)->SetIntField(env, lpObject, SHELLEXECUTEINFOFc.lpDirectory, (jint)lpStruct->lpDirectory);
+ (*env)->SetIntField(env, lpObject, SHELLEXECUTEINFOFc.nShow, (jint)lpStruct->nShow);
+ (*env)->SetIntField(env, lpObject, SHELLEXECUTEINFOFc.hInstApp, (jint)lpStruct->hInstApp);
+ (*env)->SetIntField(env, lpObject, SHELLEXECUTEINFOFc.lpIDList, (jint)lpStruct->lpIDList);
+ (*env)->SetIntField(env, lpObject, SHELLEXECUTEINFOFc.lpClass, (jint)lpStruct->lpClass);
+ (*env)->SetIntField(env, lpObject, SHELLEXECUTEINFOFc.hkeyClass, (jint)lpStruct->hkeyClass);
+ (*env)->SetIntField(env, lpObject, SHELLEXECUTEINFOFc.dwHotKey, (jint)lpStruct->dwHotKey);
+ (*env)->SetIntField(env, lpObject, SHELLEXECUTEINFOFc.hIcon, (jint)lpStruct->hIcon);
+ (*env)->SetIntField(env, lpObject, SHELLEXECUTEINFOFc.hProcess, (jint)lpStruct->hProcess);
+}
+#endif /* NO_SHELLEXECUTEINFO */
+
+#ifndef NO_SHMENUBARINFO
+typedef struct SHMENUBARINFO_FID_CACHE {
+ int cached;
+ jclass clazz;
+ jfieldID cbSize, hwndParent, dwFlags, nToolBarId, hInstRes, nBmpId, cBmpImages, hwndMB;
+} SHMENUBARINFO_FID_CACHE;
+
+SHMENUBARINFO_FID_CACHE SHMENUBARINFOFc;
+
+void cacheSHMENUBARINFOFids(JNIEnv *env, jobject lpObject)
+{
+ if (SHMENUBARINFOFc.cached) return;
+ SHMENUBARINFOFc.clazz = (*env)->GetObjectClass(env, lpObject);
+ SHMENUBARINFOFc.cbSize = (*env)->GetFieldID(env, SHMENUBARINFOFc.clazz, "cbSize", "I");
+ SHMENUBARINFOFc.hwndParent = (*env)->GetFieldID(env, SHMENUBARINFOFc.clazz, "hwndParent", "I");
+ SHMENUBARINFOFc.dwFlags = (*env)->GetFieldID(env, SHMENUBARINFOFc.clazz, "dwFlags", "I");
+ SHMENUBARINFOFc.nToolBarId = (*env)->GetFieldID(env, SHMENUBARINFOFc.clazz, "nToolBarId", "I");
+ SHMENUBARINFOFc.hInstRes = (*env)->GetFieldID(env, SHMENUBARINFOFc.clazz, "hInstRes", "I");
+ SHMENUBARINFOFc.nBmpId = (*env)->GetFieldID(env, SHMENUBARINFOFc.clazz, "nBmpId", "I");
+ SHMENUBARINFOFc.cBmpImages = (*env)->GetFieldID(env, SHMENUBARINFOFc.clazz, "cBmpImages", "I");
+ SHMENUBARINFOFc.hwndMB = (*env)->GetFieldID(env, SHMENUBARINFOFc.clazz, "hwndMB", "I");
+ SHMENUBARINFOFc.cached = 1;
+}
+
+SHMENUBARINFO *getSHMENUBARINFOFields(JNIEnv *env, jobject lpObject, SHMENUBARINFO *lpStruct)
+{
+ if (!SHMENUBARINFOFc.cached) cacheSHMENUBARINFOFids(env, lpObject);
+ lpStruct->cbSize = (DWORD)(*env)->GetIntField(env, lpObject, SHMENUBARINFOFc.cbSize);
+ lpStruct->hwndParent = (HWND)(*env)->GetIntField(env, lpObject, SHMENUBARINFOFc.hwndParent);
+ lpStruct->dwFlags = (DWORD)(*env)->GetIntField(env, lpObject, SHMENUBARINFOFc.dwFlags);
+ lpStruct->nToolBarId = (UINT)(*env)->GetIntField(env, lpObject, SHMENUBARINFOFc.nToolBarId);
+ lpStruct->hInstRes = (HINSTANCE)(*env)->GetIntField(env, lpObject, SHMENUBARINFOFc.hInstRes);
+ lpStruct->nBmpId = (*env)->GetIntField(env, lpObject, SHMENUBARINFOFc.nBmpId);
+ lpStruct->cBmpImages = (*env)->GetIntField(env, lpObject, SHMENUBARINFOFc.cBmpImages);
+ lpStruct->hwndMB = (HWND)(*env)->GetIntField(env, lpObject, SHMENUBARINFOFc.hwndMB);
+ return lpStruct;
+}
+
+void setSHMENUBARINFOFields(JNIEnv *env, jobject lpObject, SHMENUBARINFO *lpStruct)
+{
+ if (!SHMENUBARINFOFc.cached) cacheSHMENUBARINFOFids(env, lpObject);
+ (*env)->SetIntField(env, lpObject, SHMENUBARINFOFc.cbSize, (jint)lpStruct->cbSize);
+ (*env)->SetIntField(env, lpObject, SHMENUBARINFOFc.hwndParent, (jint)lpStruct->hwndParent);
+ (*env)->SetIntField(env, lpObject, SHMENUBARINFOFc.dwFlags, (jint)lpStruct->dwFlags);
+ (*env)->SetIntField(env, lpObject, SHMENUBARINFOFc.nToolBarId, (jint)lpStruct->nToolBarId);
+ (*env)->SetIntField(env, lpObject, SHMENUBARINFOFc.hInstRes, (jint)lpStruct->hInstRes);
+ (*env)->SetIntField(env, lpObject, SHMENUBARINFOFc.nBmpId, (jint)lpStruct->nBmpId);
+ (*env)->SetIntField(env, lpObject, SHMENUBARINFOFc.cBmpImages, (jint)lpStruct->cBmpImages);
+ (*env)->SetIntField(env, lpObject, SHMENUBARINFOFc.hwndMB, (jint)lpStruct->hwndMB);
+}
+#endif /* NO_SHMENUBARINFO */
+
+#ifndef NO_SHRGINFO
+typedef struct SHRGINFO_FID_CACHE {
+ int cached;
+ jclass clazz;
+ jfieldID dwFlags, ptDown_y, ptDown_x, hwndClient, cbSize;
+} SHRGINFO_FID_CACHE;
+
+SHRGINFO_FID_CACHE SHRGINFOFc;
+
+void cacheSHRGINFOFids(JNIEnv *env, jobject lpObject)
+{
+ if (SHRGINFOFc.cached) return;
+ SHRGINFOFc.clazz = (*env)->GetObjectClass(env, lpObject);
+ SHRGINFOFc.dwFlags = (*env)->GetFieldID(env, SHRGINFOFc.clazz, "dwFlags", "I");
+ SHRGINFOFc.ptDown_y = (*env)->GetFieldID(env, SHRGINFOFc.clazz, "ptDown_y", "I");
+ SHRGINFOFc.ptDown_x = (*env)->GetFieldID(env, SHRGINFOFc.clazz, "ptDown_x", "I");
+ SHRGINFOFc.hwndClient = (*env)->GetFieldID(env, SHRGINFOFc.clazz, "hwndClient", "I");
+ SHRGINFOFc.cbSize = (*env)->GetFieldID(env, SHRGINFOFc.clazz, "cbSize", "I");
+ SHRGINFOFc.cached = 1;
+}
+
+SHRGINFO *getSHRGINFOFields(JNIEnv *env, jobject lpObject, SHRGINFO *lpStruct)
+{
+ if (!SHRGINFOFc.cached) cacheSHRGINFOFids(env, lpObject);
+ lpStruct->dwFlags = (*env)->GetIntField(env, lpObject, SHRGINFOFc.dwFlags);
+ lpStruct->ptDown.y = (*env)->GetIntField(env, lpObject, SHRGINFOFc.ptDown_y);
+ lpStruct->ptDown.x = (*env)->GetIntField(env, lpObject, SHRGINFOFc.ptDown_x);
+ lpStruct->hwndClient = (HWND)(*env)->GetIntField(env, lpObject, SHRGINFOFc.hwndClient);
+ lpStruct->cbSize = (*env)->GetIntField(env, lpObject, SHRGINFOFc.cbSize);
+ return lpStruct;
+}
+
+void setSHRGINFOFields(JNIEnv *env, jobject lpObject, SHRGINFO *lpStruct)
+{
+ if (!SHRGINFOFc.cached) cacheSHRGINFOFids(env, lpObject);
+ (*env)->SetIntField(env, lpObject, SHRGINFOFc.dwFlags, (jint)lpStruct->dwFlags);
+ (*env)->SetIntField(env, lpObject, SHRGINFOFc.ptDown_y, (jint)lpStruct->ptDown.y);
+ (*env)->SetIntField(env, lpObject, SHRGINFOFc.ptDown_x, (jint)lpStruct->ptDown.x);
+ (*env)->SetIntField(env, lpObject, SHRGINFOFc.hwndClient, (jint)lpStruct->hwndClient);
+ (*env)->SetIntField(env, lpObject, SHRGINFOFc.cbSize, (jint)lpStruct->cbSize);
+}
+#endif /* NO_SHRGINFO */
+
+#ifndef NO_SIPINFO
+typedef struct SIPINFO_FID_CACHE {
+ int cached;
+ jclass clazz;
+ jfieldID cbSize, fdwFlags, rcVisibleDesktop_left, rcVisibleDesktop_top, rcVisibleDesktop_right, rcVisibleDesktop_bottom, rcSipRect_left, rcSipRect_top, rcSipRect_right, rcSipRect_bottom, dwImDataSize, pvImData;
+} SIPINFO_FID_CACHE;
+
+SIPINFO_FID_CACHE SIPINFOFc;
+
+void cacheSIPINFOFids(JNIEnv *env, jobject lpObject)
+{
+ if (SIPINFOFc.cached) return;
+ SIPINFOFc.clazz = (*env)->GetObjectClass(env, lpObject);
+ SIPINFOFc.cbSize = (*env)->GetFieldID(env, SIPINFOFc.clazz, "cbSize", "I");
+ SIPINFOFc.fdwFlags = (*env)->GetFieldID(env, SIPINFOFc.clazz, "fdwFlags", "I");
+ SIPINFOFc.rcVisibleDesktop_left = (*env)->GetFieldID(env, SIPINFOFc.clazz, "rcVisibleDesktop_left", "I");
+ SIPINFOFc.rcVisibleDesktop_top = (*env)->GetFieldID(env, SIPINFOFc.clazz, "rcVisibleDesktop_top", "I");
+ SIPINFOFc.rcVisibleDesktop_right = (*env)->GetFieldID(env, SIPINFOFc.clazz, "rcVisibleDesktop_right", "I");
+ SIPINFOFc.rcVisibleDesktop_bottom = (*env)->GetFieldID(env, SIPINFOFc.clazz, "rcVisibleDesktop_bottom", "I");
+ SIPINFOFc.rcSipRect_left = (*env)->GetFieldID(env, SIPINFOFc.clazz, "rcSipRect_left", "I");
+ SIPINFOFc.rcSipRect_top = (*env)->GetFieldID(env, SIPINFOFc.clazz, "rcSipRect_top", "I");
+ SIPINFOFc.rcSipRect_right = (*env)->GetFieldID(env, SIPINFOFc.clazz, "rcSipRect_right", "I");
+ SIPINFOFc.rcSipRect_bottom = (*env)->GetFieldID(env, SIPINFOFc.clazz, "rcSipRect_bottom", "I");
+ SIPINFOFc.dwImDataSize = (*env)->GetFieldID(env, SIPINFOFc.clazz, "dwImDataSize", "I");
+ SIPINFOFc.pvImData = (*env)->GetFieldID(env, SIPINFOFc.clazz, "pvImData", "I");
+ SIPINFOFc.cached = 1;
+}
+
+SIPINFO *getSIPINFOFields(JNIEnv *env, jobject lpObject, SIPINFO *lpStruct)
+{
+ if (!SIPINFOFc.cached) cacheSIPINFOFids(env, lpObject);
+ lpStruct->cbSize = (*env)->GetIntField(env, lpObject, SIPINFOFc.cbSize);
+ lpStruct->fdwFlags = (*env)->GetIntField(env, lpObject, SIPINFOFc.fdwFlags);
+ lpStruct->rcVisibleDesktop.left = (*env)->GetIntField(env, lpObject, SIPINFOFc.rcVisibleDesktop_left);
+ lpStruct->rcVisibleDesktop.top = (*env)->GetIntField(env, lpObject, SIPINFOFc.rcVisibleDesktop_top);
+ lpStruct->rcVisibleDesktop.right = (*env)->GetIntField(env, lpObject, SIPINFOFc.rcVisibleDesktop_right);
+ lpStruct->rcVisibleDesktop.bottom = (*env)->GetIntField(env, lpObject, SIPINFOFc.rcVisibleDesktop_bottom);
+ lpStruct->rcSipRect.left = (*env)->GetIntField(env, lpObject, SIPINFOFc.rcSipRect_left);
+ lpStruct->rcSipRect.top = (*env)->GetIntField(env, lpObject, SIPINFOFc.rcSipRect_top);
+ lpStruct->rcSipRect.right = (*env)->GetIntField(env, lpObject, SIPINFOFc.rcSipRect_right);
+ lpStruct->rcSipRect.bottom = (*env)->GetIntField(env, lpObject, SIPINFOFc.rcSipRect_bottom);
+ lpStruct->dwImDataSize = (*env)->GetIntField(env, lpObject, SIPINFOFc.dwImDataSize);
+ lpStruct->pvImData = (void*)(*env)->GetIntField(env, lpObject, SIPINFOFc.pvImData);
+ return lpStruct;
+}
+
+void setSIPINFOFields(JNIEnv *env, jobject lpObject, SIPINFO *lpStruct)
+{
+ if (!SIPINFOFc.cached) cacheSIPINFOFids(env, lpObject);
+ (*env)->SetIntField(env, lpObject, SIPINFOFc.cbSize, (jint)lpStruct->cbSize);
+ (*env)->SetIntField(env, lpObject, SIPINFOFc.fdwFlags, (jint)lpStruct->fdwFlags);
+ (*env)->SetIntField(env, lpObject, SIPINFOFc.rcVisibleDesktop_left, (jint)lpStruct->rcVisibleDesktop.left);
+ (*env)->SetIntField(env, lpObject, SIPINFOFc.rcVisibleDesktop_top, (jint)lpStruct->rcVisibleDesktop.top);
+ (*env)->SetIntField(env, lpObject, SIPINFOFc.rcVisibleDesktop_right, (jint)lpStruct->rcVisibleDesktop.right);
+ (*env)->SetIntField(env, lpObject, SIPINFOFc.rcVisibleDesktop_bottom, (jint)lpStruct->rcVisibleDesktop.bottom);
+ (*env)->SetIntField(env, lpObject, SIPINFOFc.rcSipRect_left, (jint)lpStruct->rcSipRect.left);
+ (*env)->SetIntField(env, lpObject, SIPINFOFc.rcSipRect_top, (jint)lpStruct->rcSipRect.top);
+ (*env)->SetIntField(env, lpObject, SIPINFOFc.rcSipRect_right, (jint)lpStruct->rcSipRect.right);
+ (*env)->SetIntField(env, lpObject, SIPINFOFc.rcSipRect_bottom, (jint)lpStruct->rcSipRect.bottom);
+ (*env)->SetIntField(env, lpObject, SIPINFOFc.dwImDataSize, (jint)lpStruct->dwImDataSize);
+ (*env)->SetIntField(env, lpObject, SIPINFOFc.pvImData, (jint)lpStruct->pvImData);
+}
+#endif /* NO_SIPINFO */
+
+#ifndef NO_SIZE
+typedef struct SIZE_FID_CACHE {
+ int cached;
+ jclass clazz;
+ jfieldID cx, cy;
+} SIZE_FID_CACHE;
+
+SIZE_FID_CACHE SIZEFc;
+
+void cacheSIZEFids(JNIEnv *env, jobject lpObject)
+{
+ if (SIZEFc.cached) return;
+ SIZEFc.clazz = (*env)->GetObjectClass(env, lpObject);
+ SIZEFc.cx = (*env)->GetFieldID(env, SIZEFc.clazz, "cx", "I");
+ SIZEFc.cy = (*env)->GetFieldID(env, SIZEFc.clazz, "cy", "I");
+ SIZEFc.cached = 1;
+}
+
+SIZE *getSIZEFields(JNIEnv *env, jobject lpObject, SIZE *lpStruct)
+{
+ if (!SIZEFc.cached) cacheSIZEFids(env, lpObject);
+ lpStruct->cx = (*env)->GetIntField(env, lpObject, SIZEFc.cx);
+ lpStruct->cy = (*env)->GetIntField(env, lpObject, SIZEFc.cy);
+ return lpStruct;
+}
+
+void setSIZEFields(JNIEnv *env, jobject lpObject, SIZE *lpStruct)
+{
+ if (!SIZEFc.cached) cacheSIZEFids(env, lpObject);
+ (*env)->SetIntField(env, lpObject, SIZEFc.cx, (jint)lpStruct->cx);
+ (*env)->SetIntField(env, lpObject, SIZEFc.cy, (jint)lpStruct->cy);
+}
+#endif /* NO_SIZE */
+
+#ifndef NO_TBBUTTON
+typedef struct TBBUTTON_FID_CACHE {
+ int cached;
+ jclass clazz;
+ jfieldID iBitmap, idCommand, fsState, fsStyle, dwData, iString;
+} TBBUTTON_FID_CACHE;
+
+TBBUTTON_FID_CACHE TBBUTTONFc;
+
+void cacheTBBUTTONFids(JNIEnv *env, jobject lpObject)
+{
+ if (TBBUTTONFc.cached) return;
+ TBBUTTONFc.clazz = (*env)->GetObjectClass(env, lpObject);
+ TBBUTTONFc.iBitmap = (*env)->GetFieldID(env, TBBUTTONFc.clazz, "iBitmap", "I");
+ TBBUTTONFc.idCommand = (*env)->GetFieldID(env, TBBUTTONFc.clazz, "idCommand", "I");
+ TBBUTTONFc.fsState = (*env)->GetFieldID(env, TBBUTTONFc.clazz, "fsState", "B");
+ TBBUTTONFc.fsStyle = (*env)->GetFieldID(env, TBBUTTONFc.clazz, "fsStyle", "B");
+ TBBUTTONFc.dwData = (*env)->GetFieldID(env, TBBUTTONFc.clazz, "dwData", "I");
+ TBBUTTONFc.iString = (*env)->GetFieldID(env, TBBUTTONFc.clazz, "iString", "I");
+ TBBUTTONFc.cached = 1;
+}
+
+TBBUTTON *getTBBUTTONFields(JNIEnv *env, jobject lpObject, TBBUTTON *lpStruct)
+{
+ if (!TBBUTTONFc.cached) cacheTBBUTTONFids(env, lpObject);
+ lpStruct->iBitmap = (*env)->GetIntField(env, lpObject, TBBUTTONFc.iBitmap);
+ lpStruct->idCommand = (*env)->GetIntField(env, lpObject, TBBUTTONFc.idCommand);
+ lpStruct->fsState = (*env)->GetByteField(env, lpObject, TBBUTTONFc.fsState);
+ lpStruct->fsStyle = (*env)->GetByteField(env, lpObject, TBBUTTONFc.fsStyle);
+ lpStruct->dwData = (*env)->GetIntField(env, lpObject, TBBUTTONFc.dwData);
+ lpStruct->iString = (*env)->GetIntField(env, lpObject, TBBUTTONFc.iString);
+ return lpStruct;
+}
+
+void setTBBUTTONFields(JNIEnv *env, jobject lpObject, TBBUTTON *lpStruct)
+{
+ if (!TBBUTTONFc.cached) cacheTBBUTTONFids(env, lpObject);
+ (*env)->SetIntField(env, lpObject, TBBUTTONFc.iBitmap, (jint)lpStruct->iBitmap);
+ (*env)->SetIntField(env, lpObject, TBBUTTONFc.idCommand, (jint)lpStruct->idCommand);
+ (*env)->SetByteField(env, lpObject, TBBUTTONFc.fsState, (jbyte)lpStruct->fsState);
+ (*env)->SetByteField(env, lpObject, TBBUTTONFc.fsStyle, (jbyte)lpStruct->fsStyle);
+ (*env)->SetIntField(env, lpObject, TBBUTTONFc.dwData, (jint)lpStruct->dwData);
+ (*env)->SetIntField(env, lpObject, TBBUTTONFc.iString, (jint)lpStruct->iString);
+}
+#endif /* NO_TBBUTTON */
+
+#ifndef NO_TBBUTTONINFO
+typedef struct TBBUTTONINFO_FID_CACHE {
+ int cached;
+ jclass clazz;
+ jfieldID cbSize, dwMask, idCommand, iImage, fsState, fsStyle, cx, lParam, pszText, cchText;
+} TBBUTTONINFO_FID_CACHE;
+
+TBBUTTONINFO_FID_CACHE TBBUTTONINFOFc;
+
+void cacheTBBUTTONINFOFids(JNIEnv *env, jobject lpObject)
+{
+ if (TBBUTTONINFOFc.cached) return;
+ TBBUTTONINFOFc.clazz = (*env)->GetObjectClass(env, lpObject);
+ TBBUTTONINFOFc.cbSize = (*env)->GetFieldID(env, TBBUTTONINFOFc.clazz, "cbSize", "I");
+ TBBUTTONINFOFc.dwMask = (*env)->GetFieldID(env, TBBUTTONINFOFc.clazz, "dwMask", "I");
+ TBBUTTONINFOFc.idCommand = (*env)->GetFieldID(env, TBBUTTONINFOFc.clazz, "idCommand", "I");
+ TBBUTTONINFOFc.iImage = (*env)->GetFieldID(env, TBBUTTONINFOFc.clazz, "iImage", "I");
+ TBBUTTONINFOFc.fsState = (*env)->GetFieldID(env, TBBUTTONINFOFc.clazz, "fsState", "B");
+ TBBUTTONINFOFc.fsStyle = (*env)->GetFieldID(env, TBBUTTONINFOFc.clazz, "fsStyle", "B");
+ TBBUTTONINFOFc.cx = (*env)->GetFieldID(env, TBBUTTONINFOFc.clazz, "cx", "S");
+ TBBUTTONINFOFc.lParam = (*env)->GetFieldID(env, TBBUTTONINFOFc.clazz, "lParam", "I");
+ TBBUTTONINFOFc.pszText = (*env)->GetFieldID(env, TBBUTTONINFOFc.clazz, "pszText", "I");
+ TBBUTTONINFOFc.cchText = (*env)->GetFieldID(env, TBBUTTONINFOFc.clazz, "cchText", "I");
+ TBBUTTONINFOFc.cached = 1;
+}
+
+TBBUTTONINFO *getTBBUTTONINFOFields(JNIEnv *env, jobject lpObject, TBBUTTONINFO *lpStruct)
+{
+ if (!TBBUTTONINFOFc.cached) cacheTBBUTTONINFOFids(env, lpObject);
+ lpStruct->cbSize = (*env)->GetIntField(env, lpObject, TBBUTTONINFOFc.cbSize);
+ lpStruct->dwMask = (*env)->GetIntField(env, lpObject, TBBUTTONINFOFc.dwMask);
+ lpStruct->idCommand = (*env)->GetIntField(env, lpObject, TBBUTTONINFOFc.idCommand);
+ lpStruct->iImage = (*env)->GetIntField(env, lpObject, TBBUTTONINFOFc.iImage);
+ lpStruct->fsState = (*env)->GetByteField(env, lpObject, TBBUTTONINFOFc.fsState);
+ lpStruct->fsStyle = (*env)->GetByteField(env, lpObject, TBBUTTONINFOFc.fsStyle);
+ lpStruct->cx = (*env)->GetShortField(env, lpObject, TBBUTTONINFOFc.cx);
+ lpStruct->lParam = (*env)->GetIntField(env, lpObject, TBBUTTONINFOFc.lParam);
+ lpStruct->pszText = (LPTSTR)(*env)->GetIntField(env, lpObject, TBBUTTONINFOFc.pszText);
+ lpStruct->cchText = (*env)->GetIntField(env, lpObject, TBBUTTONINFOFc.cchText);
+ return lpStruct;
+}
+
+void setTBBUTTONINFOFields(JNIEnv *env, jobject lpObject, TBBUTTONINFO *lpStruct)
+{
+ if (!TBBUTTONINFOFc.cached) cacheTBBUTTONINFOFids(env, lpObject);
+ (*env)->SetIntField(env, lpObject, TBBUTTONINFOFc.cbSize, (jint)lpStruct->cbSize);
+ (*env)->SetIntField(env, lpObject, TBBUTTONINFOFc.dwMask, (jint)lpStruct->dwMask);
+ (*env)->SetIntField(env, lpObject, TBBUTTONINFOFc.idCommand, (jint)lpStruct->idCommand);
+ (*env)->SetIntField(env, lpObject, TBBUTTONINFOFc.iImage, (jint)lpStruct->iImage);
+ (*env)->SetByteField(env, lpObject, TBBUTTONINFOFc.fsState, (jbyte)lpStruct->fsState);
+ (*env)->SetByteField(env, lpObject, TBBUTTONINFOFc.fsStyle, (jbyte)lpStruct->fsStyle);
+ (*env)->SetShortField(env, lpObject, TBBUTTONINFOFc.cx, (jshort)lpStruct->cx);
+ (*env)->SetIntField(env, lpObject, TBBUTTONINFOFc.lParam, (jint)lpStruct->lParam);
+ (*env)->SetIntField(env, lpObject, TBBUTTONINFOFc.pszText, (jint)lpStruct->pszText);
+ (*env)->SetIntField(env, lpObject, TBBUTTONINFOFc.cchText, (jint)lpStruct->cchText);
+}
+#endif /* NO_TBBUTTONINFO */
+
+#ifndef NO_TCITEM
+typedef struct TCITEM_FID_CACHE {
+ int cached;
+ jclass clazz;
+ jfieldID mask, dwState, dwStateMask, pszText, cchTextMax, iImage, lParam;
+} TCITEM_FID_CACHE;
+
+TCITEM_FID_CACHE TCITEMFc;
+
+void cacheTCITEMFids(JNIEnv *env, jobject lpObject)
+{
+ if (TCITEMFc.cached) return;
+ TCITEMFc.clazz = (*env)->GetObjectClass(env, lpObject);
+ TCITEMFc.mask = (*env)->GetFieldID(env, TCITEMFc.clazz, "mask", "I");
+ TCITEMFc.dwState = (*env)->GetFieldID(env, TCITEMFc.clazz, "dwState", "I");
+ TCITEMFc.dwStateMask = (*env)->GetFieldID(env, TCITEMFc.clazz, "dwStateMask", "I");
+ TCITEMFc.pszText = (*env)->GetFieldID(env, TCITEMFc.clazz, "pszText", "I");
+ TCITEMFc.cchTextMax = (*env)->GetFieldID(env, TCITEMFc.clazz, "cchTextMax", "I");
+ TCITEMFc.iImage = (*env)->GetFieldID(env, TCITEMFc.clazz, "iImage", "I");
+ TCITEMFc.lParam = (*env)->GetFieldID(env, TCITEMFc.clazz, "lParam", "I");
+ TCITEMFc.cached = 1;
+}
+
+TCITEM *getTCITEMFields(JNIEnv *env, jobject lpObject, TCITEM *lpStruct)
+{
+ if (!TCITEMFc.cached) cacheTCITEMFids(env, lpObject);
+ lpStruct->mask = (*env)->GetIntField(env, lpObject, TCITEMFc.mask);
+ lpStruct->dwState = (*env)->GetIntField(env, lpObject, TCITEMFc.dwState);
+ lpStruct->dwStateMask = (*env)->GetIntField(env, lpObject, TCITEMFc.dwStateMask);
+ lpStruct->pszText = (LPTSTR)(*env)->GetIntField(env, lpObject, TCITEMFc.pszText);
+ lpStruct->cchTextMax = (*env)->GetIntField(env, lpObject, TCITEMFc.cchTextMax);
+ lpStruct->iImage = (*env)->GetIntField(env, lpObject, TCITEMFc.iImage);
+ lpStruct->lParam = (*env)->GetIntField(env, lpObject, TCITEMFc.lParam);
+ return lpStruct;
+}
+
+void setTCITEMFields(JNIEnv *env, jobject lpObject, TCITEM *lpStruct)
+{
+ if (!TCITEMFc.cached) cacheTCITEMFids(env, lpObject);
+ (*env)->SetIntField(env, lpObject, TCITEMFc.mask, (jint)lpStruct->mask);
+ (*env)->SetIntField(env, lpObject, TCITEMFc.dwState, (jint)lpStruct->dwState);
+ (*env)->SetIntField(env, lpObject, TCITEMFc.dwStateMask, (jint)lpStruct->dwStateMask);
+ (*env)->SetIntField(env, lpObject, TCITEMFc.pszText, (jint)lpStruct->pszText);
+ (*env)->SetIntField(env, lpObject, TCITEMFc.cchTextMax, (jint)lpStruct->cchTextMax);
+ (*env)->SetIntField(env, lpObject, TCITEMFc.iImage, (jint)lpStruct->iImage);
+ (*env)->SetIntField(env, lpObject, TCITEMFc.lParam, (jint)lpStruct->lParam);
+}
+#endif /* NO_TCITEM */
+
+#ifndef NO_TEXTMETRIC
+typedef struct TEXTMETRIC_FID_CACHE {
+ int cached;
+ jclass clazz;
+ jfieldID tmHeight, tmAscent, tmDescent, tmInternalLeading, tmExternalLeading, tmAveCharWidth, tmMaxCharWidth, tmWeight, tmOverhang, tmDigitizedAspectX, tmDigitizedAspectY, tmItalic, tmUnderlined, tmStruckOut, tmPitchAndFamily, tmCharSet;
+} TEXTMETRIC_FID_CACHE;
+
+TEXTMETRIC_FID_CACHE TEXTMETRICFc;
+
+void cacheTEXTMETRICFids(JNIEnv *env, jobject lpObject)
+{
+ if (TEXTMETRICFc.cached) return;
+ TEXTMETRICFc.clazz = (*env)->GetObjectClass(env, lpObject);
+ TEXTMETRICFc.tmHeight = (*env)->GetFieldID(env, TEXTMETRICFc.clazz, "tmHeight", "I");
+ TEXTMETRICFc.tmAscent = (*env)->GetFieldID(env, TEXTMETRICFc.clazz, "tmAscent", "I");
+ TEXTMETRICFc.tmDescent = (*env)->GetFieldID(env, TEXTMETRICFc.clazz, "tmDescent", "I");
+ TEXTMETRICFc.tmInternalLeading = (*env)->GetFieldID(env, TEXTMETRICFc.clazz, "tmInternalLeading", "I");
+ TEXTMETRICFc.tmExternalLeading = (*env)->GetFieldID(env, TEXTMETRICFc.clazz, "tmExternalLeading", "I");
+ TEXTMETRICFc.tmAveCharWidth = (*env)->GetFieldID(env, TEXTMETRICFc.clazz, "tmAveCharWidth", "I");
+ TEXTMETRICFc.tmMaxCharWidth = (*env)->GetFieldID(env, TEXTMETRICFc.clazz, "tmMaxCharWidth", "I");
+ TEXTMETRICFc.tmWeight = (*env)->GetFieldID(env, TEXTMETRICFc.clazz, "tmWeight", "I");
+ TEXTMETRICFc.tmOverhang = (*env)->GetFieldID(env, TEXTMETRICFc.clazz, "tmOverhang", "I");
+ TEXTMETRICFc.tmDigitizedAspectX = (*env)->GetFieldID(env, TEXTMETRICFc.clazz, "tmDigitizedAspectX", "I");
+ TEXTMETRICFc.tmDigitizedAspectY = (*env)->GetFieldID(env, TEXTMETRICFc.clazz, "tmDigitizedAspectY", "I");
+ TEXTMETRICFc.tmItalic = (*env)->GetFieldID(env, TEXTMETRICFc.clazz, "tmItalic", "B");
+ TEXTMETRICFc.tmUnderlined = (*env)->GetFieldID(env, TEXTMETRICFc.clazz, "tmUnderlined", "B");
+ TEXTMETRICFc.tmStruckOut = (*env)->GetFieldID(env, TEXTMETRICFc.clazz, "tmStruckOut", "B");
+ TEXTMETRICFc.tmPitchAndFamily = (*env)->GetFieldID(env, TEXTMETRICFc.clazz, "tmPitchAndFamily", "B");
+ TEXTMETRICFc.tmCharSet = (*env)->GetFieldID(env, TEXTMETRICFc.clazz, "tmCharSet", "B");
+ TEXTMETRICFc.cached = 1;
+}
+#ifndef NO_TEXTMETRICA
+TEXTMETRICA* getTEXTMETRICAFields(JNIEnv *env, jobject lpObject, TEXTMETRICA *lpStruct)
+{
+ if (!TEXTMETRICFc.cached) cacheTEXTMETRICFids(env, lpObject);
+ lpStruct->tmHeight = (*env)->GetIntField(env, lpObject, TEXTMETRICFc.tmHeight);
+ lpStruct->tmAscent = (*env)->GetIntField(env, lpObject, TEXTMETRICFc.tmAscent);
+ lpStruct->tmDescent = (*env)->GetIntField(env, lpObject, TEXTMETRICFc.tmDescent);
+ lpStruct->tmInternalLeading = (*env)->GetIntField(env, lpObject, TEXTMETRICFc.tmInternalLeading);
+ lpStruct->tmExternalLeading = (*env)->GetIntField(env, lpObject, TEXTMETRICFc.tmExternalLeading);
+ lpStruct->tmAveCharWidth = (*env)->GetIntField(env, lpObject, TEXTMETRICFc.tmAveCharWidth);
+ lpStruct->tmMaxCharWidth = (*env)->GetIntField(env, lpObject, TEXTMETRICFc.tmMaxCharWidth);
+ lpStruct->tmWeight = (*env)->GetIntField(env, lpObject, TEXTMETRICFc.tmWeight);
+ lpStruct->tmOverhang = (*env)->GetIntField(env, lpObject, TEXTMETRICFc.tmOverhang);
+ lpStruct->tmDigitizedAspectX = (*env)->GetIntField(env, lpObject, TEXTMETRICFc.tmDigitizedAspectX);
+ lpStruct->tmDigitizedAspectY = (*env)->GetIntField(env, lpObject, TEXTMETRICFc.tmDigitizedAspectY);
+ lpStruct->tmItalic = (*env)->GetByteField(env, lpObject, TEXTMETRICFc.tmItalic);
+ lpStruct->tmUnderlined = (*env)->GetByteField(env, lpObject, TEXTMETRICFc.tmUnderlined);
+ lpStruct->tmStruckOut = (*env)->GetByteField(env, lpObject, TEXTMETRICFc.tmStruckOut);
+ lpStruct->tmPitchAndFamily = (*env)->GetByteField(env, lpObject, TEXTMETRICFc.tmPitchAndFamily);
+ lpStruct->tmCharSet = (*env)->GetByteField(env, lpObject, TEXTMETRICFc.tmCharSet);
+ return lpStruct;
+}
+
+void setTEXTMETRICAFields(JNIEnv *env, jobject lpObject, TEXTMETRICA *lpStruct)
+{
+ if (!TEXTMETRICFc.cached) cacheTEXTMETRICFids(env, lpObject);
+ (*env)->SetIntField(env, lpObject, TEXTMETRICFc.tmHeight, lpStruct->tmHeight);
+ (*env)->SetIntField(env, lpObject, TEXTMETRICFc.tmAscent, lpStruct->tmAscent);
+ (*env)->SetIntField(env, lpObject, TEXTMETRICFc.tmDescent, lpStruct->tmDescent);
+ (*env)->SetIntField(env, lpObject, TEXTMETRICFc.tmInternalLeading, lpStruct->tmInternalLeading);
+ (*env)->SetIntField(env, lpObject, TEXTMETRICFc.tmExternalLeading, lpStruct->tmExternalLeading);
+ (*env)->SetIntField(env, lpObject, TEXTMETRICFc.tmAveCharWidth, lpStruct->tmAveCharWidth);
+ (*env)->SetIntField(env, lpObject, TEXTMETRICFc.tmMaxCharWidth, lpStruct->tmMaxCharWidth);
+ (*env)->SetIntField(env, lpObject, TEXTMETRICFc.tmWeight, lpStruct->tmWeight);
+ (*env)->SetIntField(env, lpObject, TEXTMETRICFc.tmOverhang, lpStruct->tmOverhang);
+ (*env)->SetIntField(env, lpObject, TEXTMETRICFc.tmDigitizedAspectX, lpStruct->tmDigitizedAspectX);
+ (*env)->SetIntField(env, lpObject, TEXTMETRICFc.tmDigitizedAspectY, lpStruct->tmDigitizedAspectY);
+ (*env)->SetByteField(env, lpObject, TEXTMETRICFc.tmItalic, lpStruct->tmItalic);
+ (*env)->SetByteField(env, lpObject, TEXTMETRICFc.tmUnderlined, lpStruct->tmUnderlined);
+ (*env)->SetByteField(env, lpObject, TEXTMETRICFc.tmStruckOut, lpStruct->tmStruckOut);
+ (*env)->SetByteField(env, lpObject, TEXTMETRICFc.tmPitchAndFamily, lpStruct->tmPitchAndFamily);
+ (*env)->SetByteField(env, lpObject, TEXTMETRICFc.tmCharSet, lpStruct->tmCharSet);
+}
+#endif /* NO_TEXTMETRICA */
+
+#ifndef NO_TEXTMETRICW
+TEXTMETRICW *getTEXTMETRICWFields(JNIEnv *env, jobject lpObject, TEXTMETRICW *lpStruct)
+{
+ if (!TEXTMETRICFc.cached) cacheTEXTMETRICFids(env, lpObject);
+ lpStruct->tmHeight = (*env)->GetIntField(env, lpObject, TEXTMETRICFc.tmHeight);
+ lpStruct->tmAscent = (*env)->GetIntField(env, lpObject, TEXTMETRICFc.tmAscent);
+ lpStruct->tmDescent = (*env)->GetIntField(env, lpObject, TEXTMETRICFc.tmDescent);
+ lpStruct->tmInternalLeading = (*env)->GetIntField(env, lpObject, TEXTMETRICFc.tmInternalLeading);
+ lpStruct->tmExternalLeading = (*env)->GetIntField(env, lpObject, TEXTMETRICFc.tmExternalLeading);
+ lpStruct->tmAveCharWidth = (*env)->GetIntField(env, lpObject, TEXTMETRICFc.tmAveCharWidth);
+ lpStruct->tmMaxCharWidth = (*env)->GetIntField(env, lpObject, TEXTMETRICFc.tmMaxCharWidth);
+ lpStruct->tmWeight = (*env)->GetIntField(env, lpObject, TEXTMETRICFc.tmWeight);
+ lpStruct->tmOverhang = (*env)->GetIntField(env, lpObject, TEXTMETRICFc.tmOverhang);
+ lpStruct->tmDigitizedAspectX = (*env)->GetIntField(env, lpObject, TEXTMETRICFc.tmDigitizedAspectX);
+ lpStruct->tmDigitizedAspectY = (*env)->GetIntField(env, lpObject, TEXTMETRICFc.tmDigitizedAspectY);
+ lpStruct->tmItalic = (*env)->GetByteField(env, lpObject, TEXTMETRICFc.tmItalic);
+ lpStruct->tmUnderlined = (*env)->GetByteField(env, lpObject, TEXTMETRICFc.tmUnderlined);
+ lpStruct->tmStruckOut = (*env)->GetByteField(env, lpObject, TEXTMETRICFc.tmStruckOut);
+ lpStruct->tmPitchAndFamily = (*env)->GetByteField(env, lpObject, TEXTMETRICFc.tmPitchAndFamily);
+ lpStruct->tmCharSet = (*env)->GetByteField(env, lpObject, TEXTMETRICFc.tmCharSet);
+ return lpStruct;
+}
+
+void setTEXTMETRICWFields(JNIEnv *env, jobject lpObject, TEXTMETRICW *lpStruct)
+{
+ if (!TEXTMETRICFc.cached) cacheTEXTMETRICFids(env, lpObject);
+ (*env)->SetIntField(env, lpObject, TEXTMETRICFc.tmHeight, (jint)lpStruct->tmHeight);
+ (*env)->SetIntField(env, lpObject, TEXTMETRICFc.tmAscent, (jint)lpStruct->tmAscent);
+ (*env)->SetIntField(env, lpObject, TEXTMETRICFc.tmDescent, (jint)lpStruct->tmDescent);
+ (*env)->SetIntField(env, lpObject, TEXTMETRICFc.tmInternalLeading, (jint)lpStruct->tmInternalLeading);
+ (*env)->SetIntField(env, lpObject, TEXTMETRICFc.tmExternalLeading, (jint)lpStruct->tmExternalLeading);
+ (*env)->SetIntField(env, lpObject, TEXTMETRICFc.tmAveCharWidth, (jint)lpStruct->tmAveCharWidth);
+ (*env)->SetIntField(env, lpObject, TEXTMETRICFc.tmMaxCharWidth, (jint)lpStruct->tmMaxCharWidth);
+ (*env)->SetIntField(env, lpObject, TEXTMETRICFc.tmWeight, (jint)lpStruct->tmWeight);
+ (*env)->SetIntField(env, lpObject, TEXTMETRICFc.tmOverhang, (jint)lpStruct->tmOverhang);
+ (*env)->SetIntField(env, lpObject, TEXTMETRICFc.tmDigitizedAspectX, (jint)lpStruct->tmDigitizedAspectX);
+ (*env)->SetIntField(env, lpObject, TEXTMETRICFc.tmDigitizedAspectY, (jint)lpStruct->tmDigitizedAspectY);
+ (*env)->SetByteField(env, lpObject, TEXTMETRICFc.tmItalic, (jbyte)lpStruct->tmItalic);
+ (*env)->SetByteField(env, lpObject, TEXTMETRICFc.tmUnderlined, (jbyte)lpStruct->tmUnderlined);
+ (*env)->SetByteField(env, lpObject, TEXTMETRICFc.tmStruckOut, (jbyte)lpStruct->tmStruckOut);
+ (*env)->SetByteField(env, lpObject, TEXTMETRICFc.tmPitchAndFamily, (jbyte)lpStruct->tmPitchAndFamily);
+ (*env)->SetByteField(env, lpObject, TEXTMETRICFc.tmCharSet, (jbyte)lpStruct->tmCharSet);
+}
+#endif /* NO_TEXTMETRICW */
+#endif /* NO_TEXTMETRIC */
+
+#ifndef NO_TOOLINFO
+typedef struct TOOLINFO_FID_CACHE {
+ int cached;
+ jclass clazz;
+ jfieldID cbSize, uFlags, hwnd, uId, left, top, right, bottom, hinst, lpszText, lParam;
+} TOOLINFO_FID_CACHE;
+
+TOOLINFO_FID_CACHE TOOLINFOFc;
+
+void cacheTOOLINFOFids(JNIEnv *env, jobject lpObject)
+{
+ if (TOOLINFOFc.cached) return;
+ TOOLINFOFc.clazz = (*env)->GetObjectClass(env, lpObject);
+ TOOLINFOFc.cbSize = (*env)->GetFieldID(env, TOOLINFOFc.clazz, "cbSize", "I");
+ TOOLINFOFc.uFlags = (*env)->GetFieldID(env, TOOLINFOFc.clazz, "uFlags", "I");
+ TOOLINFOFc.hwnd = (*env)->GetFieldID(env, TOOLINFOFc.clazz, "hwnd", "I");
+ TOOLINFOFc.uId = (*env)->GetFieldID(env, TOOLINFOFc.clazz, "uId", "I");
+ TOOLINFOFc.left = (*env)->GetFieldID(env, TOOLINFOFc.clazz, "left", "I");
+ TOOLINFOFc.top = (*env)->GetFieldID(env, TOOLINFOFc.clazz, "top", "I");
+ TOOLINFOFc.right = (*env)->GetFieldID(env, TOOLINFOFc.clazz, "right", "I");
+ TOOLINFOFc.bottom = (*env)->GetFieldID(env, TOOLINFOFc.clazz, "bottom", "I");
+ TOOLINFOFc.hinst = (*env)->GetFieldID(env, TOOLINFOFc.clazz, "hinst", "I");
+ TOOLINFOFc.lpszText = (*env)->GetFieldID(env, TOOLINFOFc.clazz, "lpszText", "I");
+ TOOLINFOFc.lParam = (*env)->GetFieldID(env, TOOLINFOFc.clazz, "lParam", "I");
+ TOOLINFOFc.cached = 1;
+}
+
+TOOLINFO *getTOOLINFOFields(JNIEnv *env, jobject lpObject, TOOLINFO *lpStruct)
+{
+ if (!TOOLINFOFc.cached) cacheTOOLINFOFids(env, lpObject);
+ lpStruct->cbSize = (*env)->GetIntField(env, lpObject, TOOLINFOFc.cbSize);
+ lpStruct->uFlags = (*env)->GetIntField(env, lpObject, TOOLINFOFc.uFlags);
+ lpStruct->hwnd = (HWND)(*env)->GetIntField(env, lpObject, TOOLINFOFc.hwnd);
+ lpStruct->uId = (*env)->GetIntField(env, lpObject, TOOLINFOFc.uId);
+ lpStruct->rect.left = (*env)->GetIntField(env, lpObject, TOOLINFOFc.left);
+ lpStruct->rect.top = (*env)->GetIntField(env, lpObject, TOOLINFOFc.top);
+ lpStruct->rect.right = (*env)->GetIntField(env, lpObject, TOOLINFOFc.right);
+ lpStruct->rect.bottom = (*env)->GetIntField(env, lpObject, TOOLINFOFc.bottom);
+ lpStruct->hinst = (HINSTANCE)(*env)->GetIntField(env, lpObject, TOOLINFOFc.hinst);
+ lpStruct->lpszText = (LPTSTR)(*env)->GetIntField(env, lpObject, TOOLINFOFc.lpszText);
+ lpStruct->lParam = (*env)->GetIntField(env, lpObject, TOOLINFOFc.lParam);
+ return lpStruct;
+}
+
+void setTOOLINFOFields(JNIEnv *env, jobject lpObject, TOOLINFO *lpStruct)
+{
+ if (!TOOLINFOFc.cached) cacheTOOLINFOFids(env, lpObject);
+ (*env)->SetIntField(env, lpObject, TOOLINFOFc.cbSize, (jint)lpStruct->cbSize);
+ (*env)->SetIntField(env, lpObject, TOOLINFOFc.uFlags, (jint)lpStruct->uFlags);
+ (*env)->SetIntField(env, lpObject, TOOLINFOFc.hwnd, (jint)lpStruct->hwnd);
+ (*env)->SetIntField(env, lpObject, TOOLINFOFc.uId, (jint)lpStruct->uId);
+ (*env)->SetIntField(env, lpObject, TOOLINFOFc.left, (jint)lpStruct->rect.left);
+ (*env)->SetIntField(env, lpObject, TOOLINFOFc.top, (jint)lpStruct->rect.top);
+ (*env)->SetIntField(env, lpObject, TOOLINFOFc.right, (jint)lpStruct->rect.right);
+ (*env)->SetIntField(env, lpObject, TOOLINFOFc.bottom, (jint)lpStruct->rect.bottom);
+ (*env)->SetIntField(env, lpObject, TOOLINFOFc.hinst, (jint)lpStruct->hinst);
+ (*env)->SetIntField(env, lpObject, TOOLINFOFc.lpszText, (jint)lpStruct->lpszText);
+ (*env)->SetIntField(env, lpObject, TOOLINFOFc.lParam, (jint)lpStruct->lParam);
+}
+#endif /* NO_TOOLINFO */
+
+#ifndef NO_TRACKMOUSEEVENT
+typedef struct TRACKMOUSEEVENT_FID_CACHE {
+ int cached;
+ jclass clazz;
+ jfieldID cbSize, dwFlags, hwndTrack, dwHoverTime;
+} TRACKMOUSEEVENT_FID_CACHE;
+
+TRACKMOUSEEVENT_FID_CACHE TRACKMOUSEEVENTFc;
+
+void cacheTRACKMOUSEEVENTFids(JNIEnv *env, jobject lpObject)
+{
+ if (TRACKMOUSEEVENTFc.cached) return;
+ TRACKMOUSEEVENTFc.clazz = (*env)->GetObjectClass(env, lpObject);
+ TRACKMOUSEEVENTFc.cbSize = (*env)->GetFieldID(env, TRACKMOUSEEVENTFc.clazz, "cbSize", "I");
+ TRACKMOUSEEVENTFc.dwFlags = (*env)->GetFieldID(env, TRACKMOUSEEVENTFc.clazz, "dwFlags", "I");
+ TRACKMOUSEEVENTFc.hwndTrack = (*env)->GetFieldID(env, TRACKMOUSEEVENTFc.clazz, "hwndTrack", "I");
+ TRACKMOUSEEVENTFc.dwHoverTime = (*env)->GetFieldID(env, TRACKMOUSEEVENTFc.clazz, "dwHoverTime", "I");
+ TRACKMOUSEEVENTFc.cached = 1;
+}
+
+TRACKMOUSEEVENT *getTRACKMOUSEEVENTFields(JNIEnv *env, jobject lpObject, TRACKMOUSEEVENT *lpStruct)
+{
+ if (!TRACKMOUSEEVENTFc.cached) cacheTRACKMOUSEEVENTFids(env, lpObject);
+ lpStruct->cbSize = (*env)->GetIntField(env, lpObject, TRACKMOUSEEVENTFc.cbSize);
+ lpStruct->dwFlags = (*env)->GetIntField(env, lpObject, TRACKMOUSEEVENTFc.dwFlags);
+ lpStruct->hwndTrack = (HWND)(*env)->GetIntField(env, lpObject, TRACKMOUSEEVENTFc.hwndTrack);
+ lpStruct->dwHoverTime = (*env)->GetIntField(env, lpObject, TRACKMOUSEEVENTFc.dwHoverTime);
+ return lpStruct;
+}
+
+void setTRACKMOUSEEVENTFields(JNIEnv *env, jobject lpObject, TRACKMOUSEEVENT *lpStruct)
+{
+ if (!TRACKMOUSEEVENTFc.cached) cacheTRACKMOUSEEVENTFids(env, lpObject);
+ (*env)->SetIntField(env, lpObject, TRACKMOUSEEVENTFc.cbSize, (jint)lpStruct->cbSize);
+ (*env)->SetIntField(env, lpObject, TRACKMOUSEEVENTFc.dwFlags, (jint)lpStruct->dwFlags);
+ (*env)->SetIntField(env, lpObject, TRACKMOUSEEVENTFc.hwndTrack, (jint)lpStruct->hwndTrack);
+ (*env)->SetIntField(env, lpObject, TRACKMOUSEEVENTFc.dwHoverTime, (jint)lpStruct->dwHoverTime);
+}
+#endif /* NO_TRACKMOUSEEVENT */
+
+#ifndef NO_TRIVERTEX
+typedef struct TRIVERTEX_FID_CACHE {
+ int cached;
+ jclass clazz;
+ jfieldID x, y, Red, Green, Blue, Alpha;
+} TRIVERTEX_FID_CACHE;
+
+TRIVERTEX_FID_CACHE TRIVERTEXFc;
+
+void cacheTRIVERTEXFids(JNIEnv *env, jobject lpObject)
+{
+ if (TRIVERTEXFc.cached) return;
+ TRIVERTEXFc.clazz = (*env)->GetObjectClass(env, lpObject);
+ TRIVERTEXFc.x = (*env)->GetFieldID(env, TRIVERTEXFc.clazz, "x", "I");
+ TRIVERTEXFc.y = (*env)->GetFieldID(env, TRIVERTEXFc.clazz, "y", "I");
+ TRIVERTEXFc.Red = (*env)->GetFieldID(env, TRIVERTEXFc.clazz, "Red", "S");
+ TRIVERTEXFc.Green = (*env)->GetFieldID(env, TRIVERTEXFc.clazz, "Green", "S");
+ TRIVERTEXFc.Blue = (*env)->GetFieldID(env, TRIVERTEXFc.clazz, "Blue", "S");
+ TRIVERTEXFc.Alpha = (*env)->GetFieldID(env, TRIVERTEXFc.clazz, "Alpha", "S");
+ TRIVERTEXFc.cached = 1;
+}
+
+TRIVERTEX *getTRIVERTEXFields(JNIEnv *env, jobject lpObject, TRIVERTEX *lpStruct)
+{
+ if (!TRIVERTEXFc.cached) cacheTRIVERTEXFids(env, lpObject);
+ lpStruct->x = (*env)->GetIntField(env, lpObject, TRIVERTEXFc.x);
+ lpStruct->y = (*env)->GetIntField(env, lpObject, TRIVERTEXFc.y);
+ lpStruct->Red = (*env)->GetShortField(env, lpObject, TRIVERTEXFc.Red);
+ lpStruct->Green = (*env)->GetShortField(env, lpObject, TRIVERTEXFc.Green);
+ lpStruct->Blue = (*env)->GetShortField(env, lpObject, TRIVERTEXFc.Blue);
+ lpStruct->Alpha = (*env)->GetShortField(env, lpObject, TRIVERTEXFc.Alpha);
+ return lpStruct;
+}
+
+void setTRIVERTEXFields(JNIEnv *env, jobject lpObject, TRIVERTEX *lpStruct)
+{
+ if (!TRIVERTEXFc.cached) cacheTRIVERTEXFids(env, lpObject);
+ (*env)->SetIntField(env, lpObject, TRIVERTEXFc.x, (jint)lpStruct->x);
+ (*env)->SetIntField(env, lpObject, TRIVERTEXFc.y, (jint)lpStruct->y);
+ (*env)->SetShortField(env, lpObject, TRIVERTEXFc.Red, (jshort)lpStruct->Red);
+ (*env)->SetShortField(env, lpObject, TRIVERTEXFc.Green, (jshort)lpStruct->Green);
+ (*env)->SetShortField(env, lpObject, TRIVERTEXFc.Blue, (jshort)lpStruct->Blue);
+ (*env)->SetShortField(env, lpObject, TRIVERTEXFc.Alpha, (jshort)lpStruct->Alpha);
+}
+#endif /* NO_TRIVERTEX */
+
+#ifndef NO_TVHITTESTINFO
+typedef struct TVHITTESTINFO_FID_CACHE {
+ int cached;
+ jclass clazz;
+ jfieldID x, y, flags, hItem;
+} TVHITTESTINFO_FID_CACHE;
+
+TVHITTESTINFO_FID_CACHE TVHITTESTINFOFc;
+
+void cacheTVHITTESTINFOFids(JNIEnv *env, jobject lpObject)
+{
+ if (TVHITTESTINFOFc.cached) return;
+ TVHITTESTINFOFc.clazz = (*env)->GetObjectClass(env, lpObject);
+ TVHITTESTINFOFc.x = (*env)->GetFieldID(env, TVHITTESTINFOFc.clazz, "x", "I");
+ TVHITTESTINFOFc.y = (*env)->GetFieldID(env, TVHITTESTINFOFc.clazz, "y", "I");
+ TVHITTESTINFOFc.flags = (*env)->GetFieldID(env, TVHITTESTINFOFc.clazz, "flags", "I");
+ TVHITTESTINFOFc.hItem = (*env)->GetFieldID(env, TVHITTESTINFOFc.clazz, "hItem", "I");
+ TVHITTESTINFOFc.cached = 1;
+}
+
+TVHITTESTINFO *getTVHITTESTINFOFields(JNIEnv *env, jobject lpObject, TVHITTESTINFO *lpStruct)
+{
+ if (!TVHITTESTINFOFc.cached) cacheTVHITTESTINFOFids(env, lpObject);
+ lpStruct->pt.x = (*env)->GetIntField(env, lpObject, TVHITTESTINFOFc.x);
+ lpStruct->pt.y = (*env)->GetIntField(env, lpObject, TVHITTESTINFOFc.y);
+ lpStruct->flags = (*env)->GetIntField(env, lpObject, TVHITTESTINFOFc.flags);
+ lpStruct->hItem = (HTREEITEM)(*env)->GetIntField(env, lpObject, TVHITTESTINFOFc.hItem);
+ return lpStruct;
+}
+
+void setTVHITTESTINFOFields(JNIEnv *env, jobject lpObject, TVHITTESTINFO *lpStruct)
+{
+ if (!TVHITTESTINFOFc.cached) cacheTVHITTESTINFOFids(env, lpObject);
+ (*env)->SetIntField(env, lpObject, TVHITTESTINFOFc.x, (jint)lpStruct->pt.x);
+ (*env)->SetIntField(env, lpObject, TVHITTESTINFOFc.y, (jint)lpStruct->pt.y);
+ (*env)->SetIntField(env, lpObject, TVHITTESTINFOFc.flags, (jint)lpStruct->flags);
+ (*env)->SetIntField(env, lpObject, TVHITTESTINFOFc.hItem, (jint)lpStruct->hItem);
+}
+#endif /* NO_TVHITTESTINFO */
+
+#ifndef NO_TVINSERTSTRUCT
+typedef struct TVINSERTSTRUCT_FID_CACHE {
+ int cached;
+ jclass clazz;
+ jfieldID hParent, hInsertAfter, mask, hItem, state, stateMask, pszText, cchTextMax, iImage, iSelectedImage, cChildren, lParam;
+} TVINSERTSTRUCT_FID_CACHE;
+
+TVINSERTSTRUCT_FID_CACHE TVINSERTSTRUCTFc;
+
+void cacheTVINSERTSTRUCTFids(JNIEnv *env, jobject lpObject)
+{
+ if (TVINSERTSTRUCTFc.cached) return;
+ TVINSERTSTRUCTFc.clazz = (*env)->GetObjectClass(env, lpObject);
+ TVINSERTSTRUCTFc.hParent = (*env)->GetFieldID(env, TVINSERTSTRUCTFc.clazz, "hParent", "I");
+ TVINSERTSTRUCTFc.hInsertAfter = (*env)->GetFieldID(env, TVINSERTSTRUCTFc.clazz, "hInsertAfter", "I");
+ TVINSERTSTRUCTFc.mask = (*env)->GetFieldID(env, TVINSERTSTRUCTFc.clazz, "mask", "I");
+ TVINSERTSTRUCTFc.hItem = (*env)->GetFieldID(env, TVINSERTSTRUCTFc.clazz, "hItem", "I");
+ TVINSERTSTRUCTFc.state = (*env)->GetFieldID(env, TVINSERTSTRUCTFc.clazz, "state", "I");
+ TVINSERTSTRUCTFc.stateMask = (*env)->GetFieldID(env, TVINSERTSTRUCTFc.clazz, "stateMask", "I");
+ TVINSERTSTRUCTFc.pszText = (*env)->GetFieldID(env, TVINSERTSTRUCTFc.clazz, "pszText", "I");
+ TVINSERTSTRUCTFc.cchTextMax = (*env)->GetFieldID(env, TVINSERTSTRUCTFc.clazz, "cchTextMax", "I");
+ TVINSERTSTRUCTFc.iImage = (*env)->GetFieldID(env, TVINSERTSTRUCTFc.clazz, "iImage", "I");
+ TVINSERTSTRUCTFc.iSelectedImage = (*env)->GetFieldID(env, TVINSERTSTRUCTFc.clazz, "iSelectedImage", "I");
+ TVINSERTSTRUCTFc.cChildren = (*env)->GetFieldID(env, TVINSERTSTRUCTFc.clazz, "cChildren", "I");
+ TVINSERTSTRUCTFc.lParam = (*env)->GetFieldID(env, TVINSERTSTRUCTFc.clazz, "lParam", "I");
+ TVINSERTSTRUCTFc.cached = 1;
+}
+
+TVINSERTSTRUCT *getTVINSERTSTRUCTFields(JNIEnv *env, jobject lpObject, TVINSERTSTRUCT *lpStruct)
+{
+ if (!TVINSERTSTRUCTFc.cached) cacheTVINSERTSTRUCTFids(env, lpObject);
+ lpStruct->hParent = (HTREEITEM)(*env)->GetIntField(env, lpObject, TVINSERTSTRUCTFc.hParent);
+ lpStruct->hInsertAfter = (HTREEITEM)(*env)->GetIntField(env, lpObject, TVINSERTSTRUCTFc.hInsertAfter);
+ lpStruct->item.mask = (*env)->GetIntField(env, lpObject, TVINSERTSTRUCTFc.mask);
+ lpStruct->item.hItem = (HTREEITEM)(*env)->GetIntField(env, lpObject, TVINSERTSTRUCTFc.hItem);
+ lpStruct->item.state = (*env)->GetIntField(env, lpObject, TVINSERTSTRUCTFc.state);
+ lpStruct->item.stateMask = (*env)->GetIntField(env, lpObject, TVINSERTSTRUCTFc.stateMask);
+ lpStruct->item.pszText = (LPTSTR)(*env)->GetIntField(env, lpObject, TVINSERTSTRUCTFc.pszText);
+ lpStruct->item.cchTextMax = (*env)->GetIntField(env, lpObject, TVINSERTSTRUCTFc.cchTextMax);
+ lpStruct->item.iImage = (*env)->GetIntField(env, lpObject, TVINSERTSTRUCTFc.iImage);
+ lpStruct->item.iSelectedImage = (*env)->GetIntField(env, lpObject, TVINSERTSTRUCTFc.iSelectedImage);
+ lpStruct->item.cChildren = (*env)->GetIntField(env, lpObject, TVINSERTSTRUCTFc.cChildren);
+ lpStruct->item.lParam = (*env)->GetIntField(env, lpObject, TVINSERTSTRUCTFc.lParam);
+ return lpStruct;
+}
+
+void setTVINSERTSTRUCTFields(JNIEnv *env, jobject lpObject, TVINSERTSTRUCT *lpStruct)
+{
+ if (!TVINSERTSTRUCTFc.cached) cacheTVINSERTSTRUCTFids(env, lpObject);
+ (*env)->SetIntField(env, lpObject, TVINSERTSTRUCTFc.hParent, (jint)lpStruct->hParent);
+ (*env)->SetIntField(env, lpObject, TVINSERTSTRUCTFc.hInsertAfter, (jint)lpStruct->hInsertAfter);
+ (*env)->SetIntField(env, lpObject, TVINSERTSTRUCTFc.mask, (jint)lpStruct->item.mask);
+ (*env)->SetIntField(env, lpObject, TVINSERTSTRUCTFc.hItem, (jint)lpStruct->item.hItem);
+ (*env)->SetIntField(env, lpObject, TVINSERTSTRUCTFc.state, (jint)lpStruct->item.state);
+ (*env)->SetIntField(env, lpObject, TVINSERTSTRUCTFc.stateMask, (jint)lpStruct->item.stateMask);
+ (*env)->SetIntField(env, lpObject, TVINSERTSTRUCTFc.pszText, (jint)lpStruct->item.pszText);
+ (*env)->SetIntField(env, lpObject, TVINSERTSTRUCTFc.cchTextMax, (jint)lpStruct->item.cchTextMax);
+ (*env)->SetIntField(env, lpObject, TVINSERTSTRUCTFc.iImage, (jint)lpStruct->item.iImage);
+ (*env)->SetIntField(env, lpObject, TVINSERTSTRUCTFc.iSelectedImage, (jint)lpStruct->item.iSelectedImage);
+ (*env)->SetIntField(env, lpObject, TVINSERTSTRUCTFc.cChildren, (jint)lpStruct->item.cChildren);
+ (*env)->SetIntField(env, lpObject, TVINSERTSTRUCTFc.lParam, (jint)lpStruct->item.lParam);
+}
+#endif /* NO_TVINSERTSTRUCT */
+
+#ifndef NO_TVITEM
+typedef struct TVITEM_FID_CACHE {
+ int cached;
+ jclass clazz;
+ jfieldID mask, hItem, state, stateMask, pszText, cchTextMax, iImage, iSelectedImage, cChildren, lParam;
+} TVITEM_FID_CACHE;
+
+TVITEM_FID_CACHE TVITEMFc;
+
+void cacheTVITEMFids(JNIEnv *env, jobject lpObject)
+{
+ if (TVITEMFc.cached) return;
+ TVITEMFc.clazz = (*env)->GetObjectClass(env, lpObject);
+ TVITEMFc.mask = (*env)->GetFieldID(env, TVITEMFc.clazz, "mask", "I");
+ TVITEMFc.hItem = (*env)->GetFieldID(env, TVITEMFc.clazz, "hItem", "I");
+ TVITEMFc.state = (*env)->GetFieldID(env, TVITEMFc.clazz, "state", "I");
+ TVITEMFc.stateMask = (*env)->GetFieldID(env, TVITEMFc.clazz, "stateMask", "I");
+ TVITEMFc.pszText = (*env)->GetFieldID(env, TVITEMFc.clazz, "pszText", "I");
+ TVITEMFc.cchTextMax = (*env)->GetFieldID(env, TVITEMFc.clazz, "cchTextMax", "I");
+ TVITEMFc.iImage = (*env)->GetFieldID(env, TVITEMFc.clazz, "iImage", "I");
+ TVITEMFc.iSelectedImage = (*env)->GetFieldID(env, TVITEMFc.clazz, "iSelectedImage", "I");
+ TVITEMFc.cChildren = (*env)->GetFieldID(env, TVITEMFc.clazz, "cChildren", "I");
+ TVITEMFc.lParam = (*env)->GetFieldID(env, TVITEMFc.clazz, "lParam", "I");
+ TVITEMFc.cached = 1;
+}
+
+TVITEM *getTVITEMFields(JNIEnv *env, jobject lpObject, TVITEM *lpStruct)
+{
+ if (!TVITEMFc.cached) cacheTVITEMFids(env, lpObject);
+ lpStruct->mask = (*env)->GetIntField(env, lpObject, TVITEMFc.mask);
+ lpStruct->hItem = (HTREEITEM)(*env)->GetIntField(env, lpObject, TVITEMFc.hItem);
+ lpStruct->state = (*env)->GetIntField(env, lpObject, TVITEMFc.state);
+ lpStruct->stateMask = (*env)->GetIntField(env, lpObject, TVITEMFc.stateMask);
+ lpStruct->pszText = (LPTSTR)(*env)->GetIntField(env, lpObject, TVITEMFc.pszText);
+ lpStruct->cchTextMax = (*env)->GetIntField(env, lpObject, TVITEMFc.cchTextMax);
+ lpStruct->iImage = (*env)->GetIntField(env, lpObject, TVITEMFc.iImage);
+ lpStruct->iSelectedImage = (*env)->GetIntField(env, lpObject, TVITEMFc.iSelectedImage);
+ lpStruct->cChildren = (*env)->GetIntField(env, lpObject, TVITEMFc.cChildren);
+ lpStruct->lParam = (*env)->GetIntField(env, lpObject, TVITEMFc.lParam);
+ return lpStruct;
+}
+
+void setTVITEMFields(JNIEnv *env, jobject lpObject, TVITEM *lpStruct)
+{
+ if (!TVITEMFc.cached) cacheTVITEMFids(env, lpObject);
+ (*env)->SetIntField(env, lpObject, TVITEMFc.mask, (jint)lpStruct->mask);
+ (*env)->SetIntField(env, lpObject, TVITEMFc.hItem, (jint)lpStruct->hItem);
+ (*env)->SetIntField(env, lpObject, TVITEMFc.state, (jint)lpStruct->state);
+ (*env)->SetIntField(env, lpObject, TVITEMFc.stateMask, (jint)lpStruct->stateMask);
+ (*env)->SetIntField(env, lpObject, TVITEMFc.pszText, (jint)lpStruct->pszText);
+ (*env)->SetIntField(env, lpObject, TVITEMFc.cchTextMax, (jint)lpStruct->cchTextMax);
+ (*env)->SetIntField(env, lpObject, TVITEMFc.iImage, (jint)lpStruct->iImage);
+ (*env)->SetIntField(env, lpObject, TVITEMFc.iSelectedImage, (jint)lpStruct->iSelectedImage);
+ (*env)->SetIntField(env, lpObject, TVITEMFc.cChildren, (jint)lpStruct->cChildren);
+ (*env)->SetIntField(env, lpObject, TVITEMFc.lParam, (jint)lpStruct->lParam);
+}
+#endif /* NO_TVITEM */
+
+#ifndef NO_WINDOWPLACEMENT
+typedef struct WINDOWPLACEMENT_FID_CACHE {
+ int cached;
+ jclass clazz;
+ jfieldID length, flags, showCmd, ptMinPosition_x, ptMinPosition_y, ptMaxPosition_x, ptMaxPosition_y, left, top, right, bottom;
+} WINDOWPLACEMENT_FID_CACHE;
+
+WINDOWPLACEMENT_FID_CACHE WINDOWPLACEMENTFc;
+
+void cacheWINDOWPLACEMENTFids(JNIEnv *env, jobject lpObject)
+{
+ if (WINDOWPLACEMENTFc.cached) return;
+ WINDOWPLACEMENTFc.clazz = (*env)->GetObjectClass(env, lpObject);
+ WINDOWPLACEMENTFc.length = (*env)->GetFieldID(env, WINDOWPLACEMENTFc.clazz, "length", "I");
+ WINDOWPLACEMENTFc.flags = (*env)->GetFieldID(env, WINDOWPLACEMENTFc.clazz, "flags", "I");
+ WINDOWPLACEMENTFc.showCmd = (*env)->GetFieldID(env, WINDOWPLACEMENTFc.clazz, "showCmd", "I");
+ WINDOWPLACEMENTFc.ptMinPosition_x = (*env)->GetFieldID(env, WINDOWPLACEMENTFc.clazz, "ptMinPosition_x", "I");
+ WINDOWPLACEMENTFc.ptMinPosition_y = (*env)->GetFieldID(env, WINDOWPLACEMENTFc.clazz, "ptMinPosition_y", "I");
+ WINDOWPLACEMENTFc.ptMaxPosition_x = (*env)->GetFieldID(env, WINDOWPLACEMENTFc.clazz, "ptMaxPosition_x", "I");
+ WINDOWPLACEMENTFc.ptMaxPosition_y = (*env)->GetFieldID(env, WINDOWPLACEMENTFc.clazz, "ptMaxPosition_y", "I");
+ WINDOWPLACEMENTFc.left = (*env)->GetFieldID(env, WINDOWPLACEMENTFc.clazz, "left", "I");
+ WINDOWPLACEMENTFc.top = (*env)->GetFieldID(env, WINDOWPLACEMENTFc.clazz, "top", "I");
+ WINDOWPLACEMENTFc.right = (*env)->GetFieldID(env, WINDOWPLACEMENTFc.clazz, "right", "I");
+ WINDOWPLACEMENTFc.bottom = (*env)->GetFieldID(env, WINDOWPLACEMENTFc.clazz, "bottom", "I");
+ WINDOWPLACEMENTFc.cached = 1;
+}
+
+WINDOWPLACEMENT *getWINDOWPLACEMENTFields(JNIEnv *env, jobject lpObject, WINDOWPLACEMENT *lpStruct)
+{
+ if (!WINDOWPLACEMENTFc.cached) cacheWINDOWPLACEMENTFids(env, lpObject);
+ lpStruct->length = (*env)->GetIntField(env, lpObject, WINDOWPLACEMENTFc.length);
+ lpStruct->flags = (*env)->GetIntField(env, lpObject, WINDOWPLACEMENTFc.flags);
+ lpStruct->showCmd = (*env)->GetIntField(env, lpObject, WINDOWPLACEMENTFc.showCmd);
+ lpStruct->ptMinPosition.x = (*env)->GetIntField(env, lpObject, WINDOWPLACEMENTFc.ptMinPosition_x);
+ lpStruct->ptMinPosition.y = (*env)->GetIntField(env, lpObject, WINDOWPLACEMENTFc.ptMinPosition_y);
+ lpStruct->ptMaxPosition.x = (*env)->GetIntField(env, lpObject, WINDOWPLACEMENTFc.ptMaxPosition_x);
+ lpStruct->ptMaxPosition.y = (*env)->GetIntField(env, lpObject, WINDOWPLACEMENTFc.ptMaxPosition_y);
+ lpStruct->rcNormalPosition.left = (*env)->GetIntField(env, lpObject, WINDOWPLACEMENTFc.left);
+ lpStruct->rcNormalPosition.top = (*env)->GetIntField(env, lpObject, WINDOWPLACEMENTFc.top);
+ lpStruct->rcNormalPosition.right = (*env)->GetIntField(env, lpObject, WINDOWPLACEMENTFc.right);
+ lpStruct->rcNormalPosition.bottom = (*env)->GetIntField(env, lpObject, WINDOWPLACEMENTFc.bottom);
+ return lpStruct;
+}
+
+void setWINDOWPLACEMENTFields(JNIEnv *env, jobject lpObject, WINDOWPLACEMENT *lpStruct)
+{
+ if (!WINDOWPLACEMENTFc.cached) cacheWINDOWPLACEMENTFids(env, lpObject);
+ (*env)->SetIntField(env, lpObject, WINDOWPLACEMENTFc.length, (jint)lpStruct->length);
+ (*env)->SetIntField(env, lpObject, WINDOWPLACEMENTFc.flags, (jint)lpStruct->flags);
+ (*env)->SetIntField(env, lpObject, WINDOWPLACEMENTFc.showCmd, (jint)lpStruct->showCmd);
+ (*env)->SetIntField(env, lpObject, WINDOWPLACEMENTFc.ptMinPosition_x, (jint)lpStruct->ptMinPosition.x);
+ (*env)->SetIntField(env, lpObject, WINDOWPLACEMENTFc.ptMinPosition_y, (jint)lpStruct->ptMinPosition.y);
+ (*env)->SetIntField(env, lpObject, WINDOWPLACEMENTFc.ptMaxPosition_x, (jint)lpStruct->ptMaxPosition.x);
+ (*env)->SetIntField(env, lpObject, WINDOWPLACEMENTFc.ptMaxPosition_y, (jint)lpStruct->ptMaxPosition.y);
+ (*env)->SetIntField(env, lpObject, WINDOWPLACEMENTFc.left, (jint)lpStruct->rcNormalPosition.left);
+ (*env)->SetIntField(env, lpObject, WINDOWPLACEMENTFc.top, (jint)lpStruct->rcNormalPosition.top);
+ (*env)->SetIntField(env, lpObject, WINDOWPLACEMENTFc.right, (jint)lpStruct->rcNormalPosition.right);
+ (*env)->SetIntField(env, lpObject, WINDOWPLACEMENTFc.bottom, (jint)lpStruct->rcNormalPosition.bottom);
+}
+#endif /* NO_WINDOWPLACEMENT */
+
+#ifndef NO_WINDOWPOS
+typedef struct WINDOWPOS_FID_CACHE {
+ int cached;
+ jclass clazz;
+ jfieldID hwnd, hwndInsertAfter, x, y, cx, cy, flags;
+} WINDOWPOS_FID_CACHE;
+
+WINDOWPOS_FID_CACHE WINDOWPOSFc;
+
+void cacheWINDOWPOSFids(JNIEnv *env, jobject lpObject)
+{
+ if (WINDOWPOSFc.cached) return;
+ WINDOWPOSFc.clazz = (*env)->GetObjectClass(env, lpObject);
+ WINDOWPOSFc.hwnd = (*env)->GetFieldID(env, WINDOWPOSFc.clazz, "hwnd", "I");
+ WINDOWPOSFc.hwndInsertAfter = (*env)->GetFieldID(env, WINDOWPOSFc.clazz, "hwndInsertAfter", "I");
+ WINDOWPOSFc.x = (*env)->GetFieldID(env, WINDOWPOSFc.clazz, "x", "I");
+ WINDOWPOSFc.y = (*env)->GetFieldID(env, WINDOWPOSFc.clazz, "y", "I");
+ WINDOWPOSFc.cx = (*env)->GetFieldID(env, WINDOWPOSFc.clazz, "cx", "I");
+ WINDOWPOSFc.cy = (*env)->GetFieldID(env, WINDOWPOSFc.clazz, "cy", "I");
+ WINDOWPOSFc.flags = (*env)->GetFieldID(env, WINDOWPOSFc.clazz, "flags", "I");
+ WINDOWPOSFc.cached = 1;
+}
+
+WINDOWPOS *getWINDOWPOSFields(JNIEnv *env, jobject lpObject, WINDOWPOS *lpStruct)
+{
+ if (!WINDOWPOSFc.cached) cacheWINDOWPOSFids(env, lpObject);
+ lpStruct->hwnd = (HWND)(*env)->GetIntField(env, lpObject, WINDOWPOSFc.hwnd);
+ lpStruct->hwndInsertAfter = (HWND)(*env)->GetIntField(env, lpObject, WINDOWPOSFc.hwndInsertAfter);
+ lpStruct->x = (*env)->GetIntField(env, lpObject, WINDOWPOSFc.x);
+ lpStruct->y = (*env)->GetIntField(env, lpObject, WINDOWPOSFc.y);
+ lpStruct->cx = (*env)->GetIntField(env, lpObject, WINDOWPOSFc.cx);
+ lpStruct->cy = (*env)->GetIntField(env, lpObject, WINDOWPOSFc.cy);
+ lpStruct->flags = (*env)->GetIntField(env, lpObject, WINDOWPOSFc.flags);
+ return lpStruct;
+}
+
+void setWINDOWPOSFields(JNIEnv *env, jobject lpObject, WINDOWPOS *lpStruct)
+{
+ if (!WINDOWPOSFc.cached) cacheWINDOWPOSFids(env, lpObject);
+ (*env)->SetIntField(env, lpObject, WINDOWPOSFc.hwnd, (jint)lpStruct->hwnd);
+ (*env)->SetIntField(env, lpObject, WINDOWPOSFc.hwndInsertAfter, (jint)lpStruct->hwndInsertAfter);
+ (*env)->SetIntField(env, lpObject, WINDOWPOSFc.x, (jint)lpStruct->x);
+ (*env)->SetIntField(env, lpObject, WINDOWPOSFc.y, (jint)lpStruct->y);
+ (*env)->SetIntField(env, lpObject, WINDOWPOSFc.cx, (jint)lpStruct->cx);
+ (*env)->SetIntField(env, lpObject, WINDOWPOSFc.cy, (jint)lpStruct->cy);
+ (*env)->SetIntField(env, lpObject, WINDOWPOSFc.flags, (jint)lpStruct->flags);
+}
+#endif /* NO_WINDOWPOS */
+
+#ifndef NO_WNDCLASS
+typedef struct WNDCLASS_FID_CACHE {
+ int cached;
+ jclass clazz;
+ jfieldID style, lpfnWndProc, cbClsExtra, cbWndExtra, hInstance, hIcon, hCursor, hbrBackground, lpszMenuName, lpszClassName;
+} WNDCLASS_FID_CACHE;
+
+WNDCLASS_FID_CACHE WNDCLASSFc;
+
+void cacheWNDCLASSFids(JNIEnv *env, jobject lpObject)
+{
+ if (WNDCLASSFc.cached) return;
+ WNDCLASSFc.clazz = (*env)->GetObjectClass(env, lpObject);
+ WNDCLASSFc.style = (*env)->GetFieldID(env, WNDCLASSFc.clazz, "style", "I");
+ WNDCLASSFc.lpfnWndProc = (*env)->GetFieldID(env, WNDCLASSFc.clazz, "lpfnWndProc", "I");
+ WNDCLASSFc.cbClsExtra = (*env)->GetFieldID(env, WNDCLASSFc.clazz, "cbClsExtra", "I");
+ WNDCLASSFc.cbWndExtra = (*env)->GetFieldID(env, WNDCLASSFc.clazz, "cbWndExtra", "I");
+ WNDCLASSFc.hInstance = (*env)->GetFieldID(env, WNDCLASSFc.clazz, "hInstance", "I");
+ WNDCLASSFc.hIcon = (*env)->GetFieldID(env, WNDCLASSFc.clazz, "hIcon", "I");
+ WNDCLASSFc.hCursor = (*env)->GetFieldID(env, WNDCLASSFc.clazz, "hCursor", "I");
+ WNDCLASSFc.hbrBackground = (*env)->GetFieldID(env, WNDCLASSFc.clazz, "hbrBackground", "I");
+ WNDCLASSFc.lpszMenuName = (*env)->GetFieldID(env, WNDCLASSFc.clazz, "lpszMenuName", "I");
+ WNDCLASSFc.lpszClassName = (*env)->GetFieldID(env, WNDCLASSFc.clazz, "lpszClassName", "I");
+ WNDCLASSFc.cached = 1;
+}
+
+WNDCLASS *getWNDCLASSFields(JNIEnv *env, jobject lpObject, WNDCLASS *lpStruct)
+{
+ if (!WNDCLASSFc.cached) cacheWNDCLASSFids(env, lpObject);
+ lpStruct->style = (*env)->GetIntField(env, lpObject, WNDCLASSFc.style);
+ lpStruct->lpfnWndProc = (WNDPROC)(*env)->GetIntField(env, lpObject, WNDCLASSFc.lpfnWndProc);
+ lpStruct->cbClsExtra = (*env)->GetIntField(env, lpObject, WNDCLASSFc.cbClsExtra);
+ lpStruct->cbWndExtra = (*env)->GetIntField(env, lpObject, WNDCLASSFc.cbWndExtra);
+ lpStruct->hInstance = (HINSTANCE)(*env)->GetIntField(env, lpObject, WNDCLASSFc.hInstance);
+ lpStruct->hIcon = (HICON)(*env)->GetIntField(env, lpObject, WNDCLASSFc.hIcon);
+ lpStruct->hCursor = (HCURSOR)(*env)->GetIntField(env, lpObject, WNDCLASSFc.hCursor);
+ lpStruct->hbrBackground = (HBRUSH)(*env)->GetIntField(env, lpObject, WNDCLASSFc.hbrBackground);
+ lpStruct->lpszMenuName = (LPCTSTR)(*env)->GetIntField(env, lpObject, WNDCLASSFc.lpszMenuName);
+ lpStruct->lpszClassName = (LPCTSTR)(*env)->GetIntField(env, lpObject, WNDCLASSFc.lpszClassName);
+ return lpStruct;
+}
+
+void setWNDCLASSFields(JNIEnv *env, jobject lpObject, WNDCLASS *lpStruct)
+{
+ if (!WNDCLASSFc.cached) cacheWNDCLASSFids(env, lpObject);
+ (*env)->SetIntField(env, lpObject, WNDCLASSFc.style, (jint)lpStruct->style);
+ (*env)->SetIntField(env, lpObject, WNDCLASSFc.lpfnWndProc, (jint)lpStruct->lpfnWndProc);
+ (*env)->SetIntField(env, lpObject, WNDCLASSFc.cbClsExtra, (jint)lpStruct->cbClsExtra);
+ (*env)->SetIntField(env, lpObject, WNDCLASSFc.cbWndExtra, (jint)lpStruct->cbWndExtra);
+ (*env)->SetIntField(env, lpObject, WNDCLASSFc.hInstance, (jint)lpStruct->hInstance);
+ (*env)->SetIntField(env, lpObject, WNDCLASSFc.hIcon, (jint)lpStruct->hIcon);
+ (*env)->SetIntField(env, lpObject, WNDCLASSFc.hCursor, (jint)lpStruct->hCursor);
+ (*env)->SetIntField(env, lpObject, WNDCLASSFc.hbrBackground, (jint)lpStruct->hbrBackground);
+ (*env)->SetIntField(env, lpObject, WNDCLASSFc.lpszMenuName, (jint)lpStruct->lpszMenuName);
+ (*env)->SetIntField(env, lpObject, WNDCLASSFc.lpszClassName, (jint)lpStruct->lpszClassName);
+}
+#endif /* NO_WNDCLASS */
+
+/************************ OLE ***************************/
+
+#ifndef NO_CAUUID
+typedef struct CAUUID_FID_CACHE {
+ int cached;
+ jclass clazz;
+ jfieldID cElems, pElems;
+} CAUUID_FID_CACHE;
+
+CAUUID_FID_CACHE CAUUIDFc;
+
+void cacheCAUUIDFids(JNIEnv *env, jobject lpObject)
+{
+ if (CAUUIDFc.cached) return;
+ CAUUIDFc.clazz = (*env)->GetObjectClass(env, lpObject);
+ CAUUIDFc.cElems = (*env)->GetFieldID(env, CAUUIDFc.clazz, "cElems", "I");
+ CAUUIDFc.pElems = (*env)->GetFieldID(env, CAUUIDFc.clazz, "pElems", "I");
+ CAUUIDFc.cached = 1;
+}
+
+CAUUID *getCAUUIDFields(JNIEnv *env, jobject lpObject, CAUUID *lpStruct)
+{
+ if (!CAUUIDFc.cached) cacheCAUUIDFids(env, lpObject);
+ lpStruct->cElems = (*env)->GetIntField(env, lpObject, CAUUIDFc.cElems);
+ lpStruct->pElems = (GUID FAR *)(*env)->GetIntField(env, lpObject, CAUUIDFc.pElems);
+ return lpStruct;
+}
+
+void setCAUUIDFields(JNIEnv *env, jobject lpObject, CAUUID *lpStruct)
+{
+ if (!CAUUIDFc.cached) cacheCAUUIDFids(env, lpObject);
+ (*env)->SetIntField(env, lpObject, CAUUIDFc.cElems, (jint)lpStruct->cElems);
+ (*env)->SetIntField(env, lpObject, CAUUIDFc.pElems, (jint)lpStruct->pElems);
+}
+#endif /* NO_CAUUID */
+
+#ifndef NO_CONTROLINFO
+typedef struct CONTROLINFO_FID_CACHE {
+ int cached;
+ jclass clazz;
+ jfieldID cb, hAccel, cAccel, dwFlags;
+} CONTROLINFO_FID_CACHE;
+
+CONTROLINFO_FID_CACHE CONTROLINFOFc;
+
+void cacheCONTROLINFOFids(JNIEnv *env, jobject lpObject)
+{
+ if (CONTROLINFOFc.cached) return;
+ CONTROLINFOFc.clazz = (*env)->GetObjectClass(env, lpObject);
+ CONTROLINFOFc.cb = (*env)->GetFieldID(env, CONTROLINFOFc.clazz, "cb", "I");
+ CONTROLINFOFc.hAccel = (*env)->GetFieldID(env, CONTROLINFOFc.clazz, "hAccel", "I");
+ CONTROLINFOFc.cAccel = (*env)->GetFieldID(env, CONTROLINFOFc.clazz, "cAccel", "S");
+ CONTROLINFOFc.dwFlags = (*env)->GetFieldID(env, CONTROLINFOFc.clazz, "dwFlags", "I");
+ CONTROLINFOFc.cached = 1;
+}
+
+CONTROLINFO *getCONTROLINFOFields(JNIEnv *env, jobject lpObject, CONTROLINFO *lpStruct)
+{
+ if (!CONTROLINFOFc.cached) cacheCONTROLINFOFids(env, lpObject);
+ lpStruct->cb = (*env)->GetIntField(env, lpObject, CONTROLINFOFc.cb);
+ lpStruct->hAccel = (HACCEL)(*env)->GetIntField(env, lpObject, CONTROLINFOFc.hAccel);
+ lpStruct->cAccel = (*env)->GetShortField(env, lpObject, CONTROLINFOFc.cAccel);
+ lpStruct->dwFlags = (*env)->GetIntField(env, lpObject, CONTROLINFOFc.dwFlags);
+ return lpStruct;
+}
+
+void setCONTROLINFOFields(JNIEnv *env, jobject lpObject, CONTROLINFO *lpStruct)
+{
+ if (!CONTROLINFOFc.cached) cacheCONTROLINFOFids(env, lpObject);
+ (*env)->SetIntField(env, lpObject, CONTROLINFOFc.cb, (jint)lpStruct->cb);
+ (*env)->SetIntField(env, lpObject, CONTROLINFOFc.hAccel, (jint)lpStruct->hAccel);
+ (*env)->SetShortField(env, lpObject, CONTROLINFOFc.cAccel, (jshort)lpStruct->cAccel);
+ (*env)->SetIntField(env, lpObject, CONTROLINFOFc.dwFlags, (jint)lpStruct->dwFlags);
+}
+#endif /* NO_CONTROLINFO */
+
+#ifndef NO_COSERVERINFO
+typedef struct COSERVERINFO_FID_CACHE {
+ int cached;
+ jclass clazz;
+ jfieldID dwReserved1, pwszName, pAuthInfo, dwReserved2;
+} COSERVERINFO_FID_CACHE;
+
+COSERVERINFO_FID_CACHE COSERVERINFOFc;
+
+void cacheCOSERVERINFOFids(JNIEnv *env, jobject lpObject)
+{
+ if (COSERVERINFOFc.cached) return;
+ COSERVERINFOFc.clazz = (*env)->GetObjectClass(env, lpObject);
+ COSERVERINFOFc.dwReserved1 = (*env)->GetFieldID(env, COSERVERINFOFc.clazz, "dwReserved1", "I");
+ COSERVERINFOFc.pwszName = (*env)->GetFieldID(env, COSERVERINFOFc.clazz, "pwszName", "I");
+ COSERVERINFOFc.pAuthInfo = (*env)->GetFieldID(env, COSERVERINFOFc.clazz, "pAuthInfo", "I");
+ COSERVERINFOFc.dwReserved2 = (*env)->GetFieldID(env, COSERVERINFOFc.clazz, "dwReserved2", "I");
+ COSERVERINFOFc.cached = 1;
+}
+
+COSERVERINFO *getCOSERVERINFOFields(JNIEnv *env, jobject lpObject, COSERVERINFO *lpStruct)
+{
+ if (!COSERVERINFOFc.cached) cacheCOSERVERINFOFids(env, lpObject);
+ lpStruct->dwReserved1 = (*env)->GetIntField(env, lpObject, COSERVERINFOFc.dwReserved1);
+ lpStruct->pwszName = (LPWSTR)(*env)->GetIntField(env, lpObject, COSERVERINFOFc.pwszName);
+ lpStruct->pAuthInfo = (COAUTHINFO *)(*env)->GetIntField(env, lpObject, COSERVERINFOFc.pAuthInfo);
+ lpStruct->dwReserved2 = (*env)->GetIntField(env, lpObject, COSERVERINFOFc.dwReserved2);
+ return lpStruct;
+}
+
+void setCOSERVERINFOFields(JNIEnv *env, jobject lpObject, COSERVERINFO *lpStruct)
+{
+ if (!COSERVERINFOFc.cached) cacheCOSERVERINFOFids(env, lpObject);
+ (*env)->SetIntField(env, lpObject, COSERVERINFOFc.dwReserved1, (jint)lpStruct->dwReserved1);
+ (*env)->SetIntField(env, lpObject, COSERVERINFOFc.pwszName, (jint)lpStruct->pwszName);
+ (*env)->SetIntField(env, lpObject, COSERVERINFOFc.pAuthInfo, (jint)lpStruct->pAuthInfo);
+ (*env)->SetIntField(env, lpObject, COSERVERINFOFc.dwReserved2, (jint)lpStruct->dwReserved2);
+}
+#endif /* NO_COSERVERINFO */
+
+#ifndef NO_DISPPARAMS
+typedef struct DISPPARAMS_FID_CACHE {
+ int cached;
+ jclass clazz;
+ jfieldID rgvarg, rgdispidNamedArgs, cArgs, cNamedArgs;
+} DISPPARAMS_FID_CACHE;
+
+DISPPARAMS_FID_CACHE DISPPARAMSFc;
+
+void cacheDISPPARAMSFids(JNIEnv *env, jobject lpObject)
+{
+ if (DISPPARAMSFc.cached) return;
+ DISPPARAMSFc.clazz = (*env)->GetObjectClass(env, lpObject);
+ DISPPARAMSFc.rgvarg = (*env)->GetFieldID(env, DISPPARAMSFc.clazz, "rgvarg", "I");
+ DISPPARAMSFc.rgdispidNamedArgs = (*env)->GetFieldID(env, DISPPARAMSFc.clazz, "rgdispidNamedArgs", "I");
+ DISPPARAMSFc.cArgs = (*env)->GetFieldID(env, DISPPARAMSFc.clazz, "cArgs", "I");
+ DISPPARAMSFc.cNamedArgs = (*env)->GetFieldID(env, DISPPARAMSFc.clazz, "cNamedArgs", "I");
+ DISPPARAMSFc.cached = 1;
+}
+
+DISPPARAMS *getDISPPARAMSFields(JNIEnv *env, jobject lpObject, DISPPARAMS *lpStruct)
+{
+ if (!DISPPARAMSFc.cached) cacheDISPPARAMSFids(env, lpObject);
+ lpStruct->rgvarg = (VARIANTARG FAR *)(*env)->GetIntField(env, lpObject, DISPPARAMSFc.rgvarg);
+ lpStruct->rgdispidNamedArgs = (DISPID FAR *)(*env)->GetIntField(env, lpObject, DISPPARAMSFc.rgdispidNamedArgs);
+ lpStruct->cArgs = (*env)->GetIntField(env, lpObject, DISPPARAMSFc.cArgs);
+ lpStruct->cNamedArgs = (*env)->GetIntField(env, lpObject, DISPPARAMSFc.cNamedArgs);
+ return lpStruct;
+}
+
+void setDISPPARAMSFields(JNIEnv *env, jobject lpObject, DISPPARAMS *lpStruct)
+{
+ if (!DISPPARAMSFc.cached) cacheDISPPARAMSFids(env, lpObject);
+ (*env)->SetIntField(env, lpObject, DISPPARAMSFc.rgvarg, (jint)lpStruct->rgvarg);
+ (*env)->SetIntField(env, lpObject, DISPPARAMSFc.rgdispidNamedArgs, (jint)lpStruct->rgdispidNamedArgs);
+ (*env)->SetIntField(env, lpObject, DISPPARAMSFc.cArgs, (jint)lpStruct->cArgs);
+ (*env)->SetIntField(env, lpObject, DISPPARAMSFc.cNamedArgs, (jint)lpStruct->cNamedArgs);
+}
+#endif /* NO_DISPPARAMS */
+
+#ifndef NO_DVTARGETDEVICE
+typedef struct DVTARGETDEVICE_FID_CACHE {
+ int cached;
+ jclass clazz;
+ jfieldID tdSize, tdDriverNameOffset, tdDeviceNameOffset, tdPortNameOffset, tdExtDevmodeOffset, tdData;
+} DVTARGETDEVICE_FID_CACHE;
+
+DVTARGETDEVICE_FID_CACHE DVTARGETDEVICEFc;
+
+void cacheDVTARGETDEVICEFids(JNIEnv *env, jobject lpObject)
+{
+ if (DVTARGETDEVICEFc.cached) return;
+ DVTARGETDEVICEFc.clazz = (*env)->GetObjectClass(env, lpObject);
+ DVTARGETDEVICEFc.tdSize = (*env)->GetFieldID(env, DVTARGETDEVICEFc.clazz, "tdSize", "I");
+ DVTARGETDEVICEFc.tdDriverNameOffset = (*env)->GetFieldID(env, DVTARGETDEVICEFc.clazz, "tdDriverNameOffset", "S");
+ DVTARGETDEVICEFc.tdDeviceNameOffset = (*env)->GetFieldID(env, DVTARGETDEVICEFc.clazz, "tdDeviceNameOffset", "S");
+ DVTARGETDEVICEFc.tdPortNameOffset = (*env)->GetFieldID(env, DVTARGETDEVICEFc.clazz, "tdPortNameOffset", "S");
+ DVTARGETDEVICEFc.tdExtDevmodeOffset = (*env)->GetFieldID(env, DVTARGETDEVICEFc.clazz, "tdExtDevmodeOffset", "S");
+ DVTARGETDEVICEFc.tdData = (*env)->GetFieldID(env, DVTARGETDEVICEFc.clazz, "tdData", "B");
+ DVTARGETDEVICEFc.cached = 1;
+}
+
+DVTARGETDEVICE *getDVTARGETDEVICEFields(JNIEnv *env, jobject lpObject, DVTARGETDEVICE *lpStruct)
+{
+ if (!DVTARGETDEVICEFc.cached) cacheDVTARGETDEVICEFids(env, lpObject);
+ lpStruct->tdSize = (*env)->GetIntField(env, lpObject, DVTARGETDEVICEFc.tdSize);
+ lpStruct->tdDriverNameOffset = (*env)->GetShortField(env, lpObject, DVTARGETDEVICEFc.tdDriverNameOffset);
+ lpStruct->tdDeviceNameOffset = (*env)->GetShortField(env, lpObject, DVTARGETDEVICEFc.tdDeviceNameOffset);
+ lpStruct->tdPortNameOffset = (*env)->GetShortField(env, lpObject, DVTARGETDEVICEFc.tdPortNameOffset);
+ lpStruct->tdExtDevmodeOffset = (*env)->GetShortField(env, lpObject, DVTARGETDEVICEFc.tdExtDevmodeOffset);
+ *lpStruct->tdData = (*env)->GetByteField(env, lpObject, DVTARGETDEVICEFc.tdData);
+ return lpStruct;
+}
+
+void setDVTARGETDEVICEFields(JNIEnv *env, jobject lpObject, DVTARGETDEVICE *lpStruct)
+{
+ if (!DVTARGETDEVICEFc.cached) cacheDVTARGETDEVICEFids(env, lpObject);
+ (*env)->SetIntField(env, lpObject, DVTARGETDEVICEFc.tdSize, (jint)lpStruct->tdSize);
+ (*env)->SetShortField(env, lpObject, DVTARGETDEVICEFc.tdDriverNameOffset, (jshort)lpStruct->tdDriverNameOffset);
+ (*env)->SetShortField(env, lpObject, DVTARGETDEVICEFc.tdDeviceNameOffset, (jshort)lpStruct->tdDeviceNameOffset);
+ (*env)->SetShortField(env, lpObject, DVTARGETDEVICEFc.tdPortNameOffset, (jshort)lpStruct->tdPortNameOffset);
+ (*env)->SetShortField(env, lpObject, DVTARGETDEVICEFc.tdExtDevmodeOffset, (jshort)lpStruct->tdExtDevmodeOffset);
+ (*env)->SetByteField(env, lpObject, DVTARGETDEVICEFc.tdData, (jbyte)*lpStruct->tdData);
+}
+#endif /* NO_DVTARGETDEVICE */
+
+#ifndef NO_EXCEPINFO
+typedef struct EXCEPINFO_FID_CACHE {
+ int cached;
+ jclass clazz;
+ jfieldID wCode, wReserved, bstrSource, bstrDescription, bstrHelpFile, dwHelpContext, pvReserved, pfnDeferredFillIn, scode;
+} EXCEPINFO_FID_CACHE;
+
+EXCEPINFO_FID_CACHE EXCEPINFOFc;
+
+void cacheEXCEPINFOFids(JNIEnv *env, jobject lpObject)
+{
+ if (EXCEPINFOFc.cached) return;
+ EXCEPINFOFc.clazz = (*env)->GetObjectClass(env, lpObject);
+ EXCEPINFOFc.wCode = (*env)->GetFieldID(env, EXCEPINFOFc.clazz, "wCode", "S");
+ EXCEPINFOFc.wReserved = (*env)->GetFieldID(env, EXCEPINFOFc.clazz, "wReserved", "S");
+ EXCEPINFOFc.bstrSource = (*env)->GetFieldID(env, EXCEPINFOFc.clazz, "bstrSource", "I");
+ EXCEPINFOFc.bstrDescription = (*env)->GetFieldID(env, EXCEPINFOFc.clazz, "bstrDescription", "I");
+ EXCEPINFOFc.bstrHelpFile = (*env)->GetFieldID(env, EXCEPINFOFc.clazz, "bstrHelpFile", "I");
+ EXCEPINFOFc.dwHelpContext = (*env)->GetFieldID(env, EXCEPINFOFc.clazz, "dwHelpContext", "I");
+ EXCEPINFOFc.pvReserved = (*env)->GetFieldID(env, EXCEPINFOFc.clazz, "pvReserved", "I");
+ EXCEPINFOFc.pfnDeferredFillIn = (*env)->GetFieldID(env, EXCEPINFOFc.clazz, "pfnDeferredFillIn", "I");
+ EXCEPINFOFc.scode = (*env)->GetFieldID(env, EXCEPINFOFc.clazz, "scode", "I");
+ EXCEPINFOFc.cached = 1;
+}
+
+EXCEPINFO *getEXCEPINFOFields(JNIEnv *env, jobject lpObject, EXCEPINFO *lpStruct)
+{
+ if (!EXCEPINFOFc.cached) cacheEXCEPINFOFids(env, lpObject);
+ lpStruct->wCode = (*env)->GetShortField(env, lpObject, EXCEPINFOFc.wCode);
+ lpStruct->wReserved = (*env)->GetShortField(env, lpObject, EXCEPINFOFc.wReserved);
+ lpStruct->bstrSource = (BSTR)(*env)->GetIntField(env, lpObject, EXCEPINFOFc.bstrSource);
+ lpStruct->bstrDescription = (BSTR)(*env)->GetIntField(env, lpObject, EXCEPINFOFc.bstrDescription);
+ lpStruct->bstrHelpFile = (BSTR)(*env)->GetIntField(env, lpObject, EXCEPINFOFc.bstrHelpFile);
+ lpStruct->dwHelpContext = (*env)->GetIntField(env, lpObject, EXCEPINFOFc.dwHelpContext);
+ lpStruct->pvReserved = (void FAR *)(*env)->GetIntField(env, lpObject, EXCEPINFOFc.pvReserved);
+ lpStruct->pfnDeferredFillIn = (HRESULT (STDAPICALLTYPE FAR* )(struct tagEXCEPINFO FAR*))(*env)->GetIntField(env, lpObject, EXCEPINFOFc.pfnDeferredFillIn);
+ lpStruct->scode = (*env)->GetIntField(env, lpObject, EXCEPINFOFc.scode);
+ return lpStruct;
+}
+
+void setEXCEPINFOFields(JNIEnv *env, jobject lpObject, EXCEPINFO *lpStruct)
+{
+ if (!EXCEPINFOFc.cached) cacheEXCEPINFOFids(env, lpObject);
+ (*env)->SetShortField(env, lpObject, EXCEPINFOFc.wCode, (jshort)lpStruct->wCode);
+ (*env)->SetShortField(env, lpObject, EXCEPINFOFc.wReserved, (jshort)lpStruct->wReserved);
+ (*env)->SetIntField(env, lpObject, EXCEPINFOFc.bstrSource, (jint)lpStruct->bstrSource);
+ (*env)->SetIntField(env, lpObject, EXCEPINFOFc.bstrDescription, (jint)lpStruct->bstrDescription);
+ (*env)->SetIntField(env, lpObject, EXCEPINFOFc.bstrHelpFile, (jint)lpStruct->bstrHelpFile);
+ (*env)->SetIntField(env, lpObject, EXCEPINFOFc.dwHelpContext, (jint)lpStruct->dwHelpContext);
+ (*env)->SetIntField(env, lpObject, EXCEPINFOFc.pvReserved, (jint)lpStruct->pvReserved);
+ (*env)->SetIntField(env, lpObject, EXCEPINFOFc.pfnDeferredFillIn, (jint)lpStruct->pfnDeferredFillIn);
+ (*env)->SetIntField(env, lpObject, EXCEPINFOFc.scode, (jint)lpStruct->scode);
+}
+#endif /* NO_EXCEPINFO */
+
+#ifndef NO_FORMATETC
+typedef struct FORMATETC_FID_CACHE {
+ int cached;
+ jclass clazz;
+ jfieldID cfFormat, ptd, dwAspect, lindex, tymed;
+} FORMATETC_FID_CACHE;
+
+FORMATETC_FID_CACHE FORMATETCFc;
+
+void cacheFORMATETCFids(JNIEnv *env, jobject lpObject)
+{
+ if (FORMATETCFc.cached) return;
+ FORMATETCFc.clazz = (*env)->GetObjectClass(env, lpObject);
+ FORMATETCFc.cfFormat = (*env)->GetFieldID(env, FORMATETCFc.clazz, "cfFormat", "I");
+ FORMATETCFc.ptd = (*env)->GetFieldID(env, FORMATETCFc.clazz, "ptd", "I");
+ FORMATETCFc.dwAspect = (*env)->GetFieldID(env, FORMATETCFc.clazz, "dwAspect", "I");
+ FORMATETCFc.lindex = (*env)->GetFieldID(env, FORMATETCFc.clazz, "lindex", "I");
+ FORMATETCFc.tymed = (*env)->GetFieldID(env, FORMATETCFc.clazz, "tymed", "I");
+ FORMATETCFc.cached = 1;
+}
+
+FORMATETC *getFORMATETCFields(JNIEnv *env, jobject lpObject, FORMATETC *lpStruct)
+{
+ if (!FORMATETCFc.cached) cacheFORMATETCFids(env, lpObject);
+ lpStruct->cfFormat = (CLIPFORMAT)(*env)->GetIntField(env, lpObject, FORMATETCFc.cfFormat);
+ lpStruct->ptd = (DVTARGETDEVICE *)(*env)->GetIntField(env, lpObject, FORMATETCFc.ptd);
+ lpStruct->dwAspect = (*env)->GetIntField(env, lpObject, FORMATETCFc.dwAspect);
+ lpStruct->lindex = (*env)->GetIntField(env, lpObject, FORMATETCFc.lindex);
+ lpStruct->tymed = (*env)->GetIntField(env, lpObject, FORMATETCFc.tymed);
+ return lpStruct;
+}
+
+void setFORMATETCFields(JNIEnv *env, jobject lpObject, FORMATETC *lpStruct)
+{
+ if (!FORMATETCFc.cached) cacheFORMATETCFids(env, lpObject);
+ (*env)->SetIntField(env, lpObject, FORMATETCFc.cfFormat, (jint)lpStruct->cfFormat);
+ (*env)->SetIntField(env, lpObject, FORMATETCFc.ptd, (jint)lpStruct->ptd);
+ (*env)->SetIntField(env, lpObject, FORMATETCFc.dwAspect, (jint)lpStruct->dwAspect);
+ (*env)->SetIntField(env, lpObject, FORMATETCFc.lindex, (jint)lpStruct->lindex);
+ (*env)->SetIntField(env, lpObject, FORMATETCFc.tymed, (jint)lpStruct->tymed);
+}
+#endif /* NO_FORMATETC */
+
+#ifndef NO_FUNCDESC1
+typedef struct FUNCDESC1_FID_CACHE {
+ int cached;
+ jclass clazz;
+ jfieldID memid, lprgscode, lprgelemdescParam, funckind, invkind, callconv, cParams, cParamsOpt, oVft, cScodes, elemdescFunc_tdesc_union, elemdescFunc_tdesc_vt, elemdescFunc_paramdesc_pparamdescex, elemdescFunc_paramdesc_wParamFlags, wFuncFlags;
+} FUNCDESC1_FID_CACHE;
+
+FUNCDESC1_FID_CACHE FUNCDESC1Fc;
+
+void cacheFUNCDESC1Fids(JNIEnv *env, jobject lpObject)
+{
+ if (FUNCDESC1Fc.cached) return;
+ FUNCDESC1Fc.clazz = (*env)->GetObjectClass(env, lpObject);
+ FUNCDESC1Fc.memid = (*env)->GetFieldID(env, FUNCDESC1Fc.clazz, "memid", "I");
+ FUNCDESC1Fc.lprgscode = (*env)->GetFieldID(env, FUNCDESC1Fc.clazz, "lprgscode", "I");
+ FUNCDESC1Fc.lprgelemdescParam = (*env)->GetFieldID(env, FUNCDESC1Fc.clazz, "lprgelemdescParam", "I");
+ FUNCDESC1Fc.funckind = (*env)->GetFieldID(env, FUNCDESC1Fc.clazz, "funckind", "I");
+ FUNCDESC1Fc.invkind = (*env)->GetFieldID(env, FUNCDESC1Fc.clazz, "invkind", "I");
+ FUNCDESC1Fc.callconv = (*env)->GetFieldID(env, FUNCDESC1Fc.clazz, "callconv", "I");
+ FUNCDESC1Fc.cParams = (*env)->GetFieldID(env, FUNCDESC1Fc.clazz, "cParams", "S");
+ FUNCDESC1Fc.cParamsOpt = (*env)->GetFieldID(env, FUNCDESC1Fc.clazz, "cParamsOpt", "S");
+ FUNCDESC1Fc.oVft = (*env)->GetFieldID(env, FUNCDESC1Fc.clazz, "oVft", "S");
+ FUNCDESC1Fc.cScodes = (*env)->GetFieldID(env, FUNCDESC1Fc.clazz, "cScodes", "S");
+ FUNCDESC1Fc.elemdescFunc_tdesc_union = (*env)->GetFieldID(env, FUNCDESC1Fc.clazz, "elemdescFunc_tdesc_union", "I");
+ FUNCDESC1Fc.elemdescFunc_tdesc_vt = (*env)->GetFieldID(env, FUNCDESC1Fc.clazz, "elemdescFunc_tdesc_vt", "S");
+ FUNCDESC1Fc.elemdescFunc_paramdesc_pparamdescex = (*env)->GetFieldID(env, FUNCDESC1Fc.clazz, "elemdescFunc_paramdesc_pparamdescex", "I");
+ FUNCDESC1Fc.elemdescFunc_paramdesc_wParamFlags = (*env)->GetFieldID(env, FUNCDESC1Fc.clazz, "elemdescFunc_paramdesc_wParamFlags", "S");
+ FUNCDESC1Fc.wFuncFlags = (*env)->GetFieldID(env, FUNCDESC1Fc.clazz, "wFuncFlags", "S");
+ FUNCDESC1Fc.cached = 1;
+}
+
+FUNCDESC *getFUNCDESC1Fields(JNIEnv *env, jobject lpObject, FUNCDESC *lpStruct)
+{
+ if (!FUNCDESC1Fc.cached) cacheFUNCDESC1Fids(env, lpObject);
+ lpStruct->memid = (*env)->GetIntField(env, lpObject, FUNCDESC1Fc.memid);
+ lpStruct->lprgscode = (SCODE FAR *)(*env)->GetIntField(env, lpObject, FUNCDESC1Fc.lprgscode);
+ lpStruct->lprgelemdescParam = (ELEMDESC FAR *)(*env)->GetIntField(env, lpObject, FUNCDESC1Fc.lprgelemdescParam);
+ lpStruct->funckind = (*env)->GetIntField(env, lpObject, FUNCDESC1Fc.funckind);
+ lpStruct->invkind = (*env)->GetIntField(env, lpObject, FUNCDESC1Fc.invkind);
+ lpStruct->callconv = (*env)->GetIntField(env, lpObject, FUNCDESC1Fc.callconv);
+ lpStruct->cParams = (*env)->GetShortField(env, lpObject, FUNCDESC1Fc.cParams);
+ lpStruct->cParamsOpt = (*env)->GetShortField(env, lpObject, FUNCDESC1Fc.cParamsOpt);
+ lpStruct->oVft = (*env)->GetShortField(env, lpObject, FUNCDESC1Fc.oVft);
+ lpStruct->cScodes = (*env)->GetShortField(env, lpObject, FUNCDESC1Fc.cScodes);
+ lpStruct->elemdescFunc.tdesc.lptdesc = (struct FARSTRUCT tagTYPEDESC FAR* )(*env)->GetIntField(env, lpObject, FUNCDESC1Fc.elemdescFunc_tdesc_union);
+ lpStruct->elemdescFunc.tdesc.vt = (*env)->GetShortField(env, lpObject, FUNCDESC1Fc.elemdescFunc_tdesc_vt);
+ lpStruct->elemdescFunc.paramdesc.pparamdescex = (LPPARAMDESCEX)(*env)->GetIntField(env, lpObject, FUNCDESC1Fc.elemdescFunc_paramdesc_pparamdescex);
+ lpStruct->elemdescFunc.paramdesc.wParamFlags = (*env)->GetShortField(env, lpObject, FUNCDESC1Fc.elemdescFunc_paramdesc_wParamFlags);
+ lpStruct->wFuncFlags = (*env)->GetShortField(env, lpObject, FUNCDESC1Fc.wFuncFlags);
+ return lpStruct;
+}
+
+void setFUNCDESC1Fields(JNIEnv *env, jobject lpObject, FUNCDESC *lpStruct)
+{
+ if (!FUNCDESC1Fc.cached) cacheFUNCDESC1Fids(env, lpObject);
+ (*env)->SetIntField(env, lpObject, FUNCDESC1Fc.memid, (jint)lpStruct->memid);
+ (*env)->SetIntField(env, lpObject, FUNCDESC1Fc.lprgscode, (jint)lpStruct->lprgscode);
+ (*env)->SetIntField(env, lpObject, FUNCDESC1Fc.lprgelemdescParam, (jint)lpStruct->lprgelemdescParam);
+ (*env)->SetIntField(env, lpObject, FUNCDESC1Fc.funckind, (jint)lpStruct->funckind);
+ (*env)->SetIntField(env, lpObject, FUNCDESC1Fc.invkind, (jint)lpStruct->invkind);
+ (*env)->SetIntField(env, lpObject, FUNCDESC1Fc.callconv, (jint)lpStruct->callconv);
+ (*env)->SetShortField(env, lpObject, FUNCDESC1Fc.cParams, (jshort)lpStruct->cParams);
+ (*env)->SetShortField(env, lpObject, FUNCDESC1Fc.cParamsOpt, (jshort)lpStruct->cParamsOpt);
+ (*env)->SetShortField(env, lpObject, FUNCDESC1Fc.oVft, (jshort)lpStruct->oVft);
+ (*env)->SetShortField(env, lpObject, FUNCDESC1Fc.cScodes, (jshort)lpStruct->cScodes);
+ (*env)->SetIntField(env, lpObject, FUNCDESC1Fc.elemdescFunc_tdesc_union, (jint)lpStruct->elemdescFunc.tdesc.lptdesc);
+ (*env)->SetShortField(env, lpObject, FUNCDESC1Fc.elemdescFunc_tdesc_vt, (jshort)lpStruct->elemdescFunc.tdesc.vt);
+ (*env)->SetIntField(env, lpObject, FUNCDESC1Fc.elemdescFunc_paramdesc_pparamdescex, (jint)lpStruct->elemdescFunc.paramdesc.pparamdescex);
+ (*env)->SetShortField(env, lpObject, FUNCDESC1Fc.elemdescFunc_paramdesc_wParamFlags, (jshort)lpStruct->elemdescFunc.paramdesc.wParamFlags);
+ (*env)->SetShortField(env, lpObject, FUNCDESC1Fc.wFuncFlags, (jshort)lpStruct->wFuncFlags);
+}
+#endif /* NO_FUNCDESC1 */
+
+#ifndef NO_FUNCDESC2
+typedef struct FUNCDESC2_FID_CACHE {
+ int cached;
+ jclass clazz;
+ jfieldID memid, lprgscode, lprgelemdescParam, funckind, invkind, callconv, cParams, cParamsOpt, oVft, cScodes, elemdescFunc_tdesc_union, elemdescFunc_tdesc_vt, elemdescFunc_idldesc_dwReserved, elemdescFunc_idldesc_wIDLFlags, wFuncFlags;
+} FUNCDESC2_FID_CACHE;
+
+FUNCDESC2_FID_CACHE FUNCDESC2Fc;
+
+void cacheFUNCDESC2Fids(JNIEnv *env, jobject lpObject)
+{
+ if (FUNCDESC2Fc.cached) return;
+ FUNCDESC2Fc.clazz = (*env)->GetObjectClass(env, lpObject);
+ FUNCDESC2Fc.memid = (*env)->GetFieldID(env, FUNCDESC2Fc.clazz, "memid", "I");
+ FUNCDESC2Fc.lprgscode = (*env)->GetFieldID(env, FUNCDESC2Fc.clazz, "lprgscode", "I");
+ FUNCDESC2Fc.lprgelemdescParam = (*env)->GetFieldID(env, FUNCDESC2Fc.clazz, "lprgelemdescParam", "I");
+ FUNCDESC2Fc.funckind = (*env)->GetFieldID(env, FUNCDESC2Fc.clazz, "funckind", "I");
+ FUNCDESC2Fc.invkind = (*env)->GetFieldID(env, FUNCDESC2Fc.clazz, "invkind", "I");
+ FUNCDESC2Fc.callconv = (*env)->GetFieldID(env, FUNCDESC2Fc.clazz, "callconv", "I");
+ FUNCDESC2Fc.cParams = (*env)->GetFieldID(env, FUNCDESC2Fc.clazz, "cParams", "S");
+ FUNCDESC2Fc.cParamsOpt = (*env)->GetFieldID(env, FUNCDESC2Fc.clazz, "cParamsOpt", "S");
+ FUNCDESC2Fc.oVft = (*env)->GetFieldID(env, FUNCDESC2Fc.clazz, "oVft", "S");
+ FUNCDESC2Fc.cScodes = (*env)->GetFieldID(env, FUNCDESC2Fc.clazz, "cScodes", "S");
+ FUNCDESC2Fc.elemdescFunc_tdesc_union = (*env)->GetFieldID(env, FUNCDESC2Fc.clazz, "elemdescFunc_tdesc_union", "I");
+ FUNCDESC2Fc.elemdescFunc_tdesc_vt = (*env)->GetFieldID(env, FUNCDESC2Fc.clazz, "elemdescFunc_tdesc_vt", "S");
+ FUNCDESC2Fc.elemdescFunc_idldesc_dwReserved = (*env)->GetFieldID(env, FUNCDESC2Fc.clazz, "elemdescFunc_idldesc_dwReserved", "I");
+ FUNCDESC2Fc.elemdescFunc_idldesc_wIDLFlags = (*env)->GetFieldID(env, FUNCDESC2Fc.clazz, "elemdescFunc_idldesc_wIDLFlags", "S");
+ FUNCDESC2Fc.wFuncFlags = (*env)->GetFieldID(env, FUNCDESC2Fc.clazz, "wFuncFlags", "S");
+ FUNCDESC2Fc.cached = 1;
+}
+
+FUNCDESC *getFUNCDESC2Fields(JNIEnv *env, jobject lpObject, FUNCDESC *lpStruct)
+{
+ if (!FUNCDESC2Fc.cached) cacheFUNCDESC2Fids(env, lpObject);
+ lpStruct->memid = (*env)->GetIntField(env, lpObject, FUNCDESC2Fc.memid);
+ lpStruct->lprgscode = (SCODE FAR *)(*env)->GetIntField(env, lpObject, FUNCDESC2Fc.lprgscode);
+ lpStruct->lprgelemdescParam = (ELEMDESC FAR *)(*env)->GetIntField(env, lpObject, FUNCDESC2Fc.lprgelemdescParam);
+ lpStruct->funckind = (*env)->GetIntField(env, lpObject, FUNCDESC2Fc.funckind);
+ lpStruct->invkind = (*env)->GetIntField(env, lpObject, FUNCDESC2Fc.invkind);
+ lpStruct->callconv = (*env)->GetIntField(env, lpObject, FUNCDESC2Fc.callconv);
+ lpStruct->cParams = (*env)->GetShortField(env, lpObject, FUNCDESC2Fc.cParams);
+ lpStruct->cParamsOpt = (*env)->GetShortField(env, lpObject, FUNCDESC2Fc.cParamsOpt);
+ lpStruct->oVft = (*env)->GetShortField(env, lpObject, FUNCDESC2Fc.oVft);
+ lpStruct->cScodes = (*env)->GetShortField(env, lpObject, FUNCDESC2Fc.cScodes);
+ lpStruct->elemdescFunc.tdesc.lptdesc = (struct FARSTRUCT tagTYPEDESC FAR* )(*env)->GetIntField(env, lpObject, FUNCDESC2Fc.elemdescFunc_tdesc_union);
+ lpStruct->elemdescFunc.tdesc.vt = (*env)->GetShortField(env, lpObject, FUNCDESC2Fc.elemdescFunc_tdesc_vt);
+ lpStruct->elemdescFunc.idldesc.dwReserved = (*env)->GetIntField(env, lpObject, FUNCDESC2Fc.elemdescFunc_idldesc_dwReserved);
+ lpStruct->elemdescFunc.idldesc.wIDLFlags = (*env)->GetShortField(env, lpObject, FUNCDESC2Fc.elemdescFunc_idldesc_wIDLFlags);
+ lpStruct->wFuncFlags = (*env)->GetShortField(env, lpObject, FUNCDESC2Fc.wFuncFlags);
+ return lpStruct;
+}
+
+void setFUNCDESC2Fields(JNIEnv *env, jobject lpObject, FUNCDESC *lpStruct)
+{
+ if (!FUNCDESC2Fc.cached) cacheFUNCDESC2Fids(env, lpObject);
+ (*env)->SetIntField(env, lpObject, FUNCDESC2Fc.memid, (jint)lpStruct->memid);
+ (*env)->SetIntField(env, lpObject, FUNCDESC2Fc.lprgscode, (jint)lpStruct->lprgscode);
+ (*env)->SetIntField(env, lpObject, FUNCDESC2Fc.lprgelemdescParam, (jint)lpStruct->lprgelemdescParam);
+ (*env)->SetIntField(env, lpObject, FUNCDESC2Fc.funckind, (jint)lpStruct->funckind);
+ (*env)->SetIntField(env, lpObject, FUNCDESC2Fc.invkind, (jint)lpStruct->invkind);
+ (*env)->SetIntField(env, lpObject, FUNCDESC2Fc.callconv, (jint)lpStruct->callconv);
+ (*env)->SetShortField(env, lpObject, FUNCDESC2Fc.cParams, (jshort)lpStruct->cParams);
+ (*env)->SetShortField(env, lpObject, FUNCDESC2Fc.cParamsOpt, (jshort)lpStruct->cParamsOpt);
+ (*env)->SetShortField(env, lpObject, FUNCDESC2Fc.oVft, (jshort)lpStruct->oVft);
+ (*env)->SetShortField(env, lpObject, FUNCDESC2Fc.cScodes, (jshort)lpStruct->cScodes);
+ (*env)->SetIntField(env, lpObject, FUNCDESC2Fc.elemdescFunc_tdesc_union, (jint)lpStruct->elemdescFunc.tdesc.lptdesc);
+ (*env)->SetShortField(env, lpObject, FUNCDESC2Fc.elemdescFunc_tdesc_vt, (jshort)lpStruct->elemdescFunc.tdesc.vt);
+ (*env)->SetIntField(env, lpObject, FUNCDESC2Fc.elemdescFunc_idldesc_dwReserved, (jint)lpStruct->elemdescFunc.idldesc.dwReserved);
+ (*env)->SetShortField(env, lpObject, FUNCDESC2Fc.elemdescFunc_idldesc_wIDLFlags, (jshort)lpStruct->elemdescFunc.idldesc.wIDLFlags);
+ (*env)->SetShortField(env, lpObject, FUNCDESC2Fc.wFuncFlags, (jshort)lpStruct->wFuncFlags);
+}
+#endif /* NO_FUNCDESC2 */
+
+#ifndef NO_GUID
+typedef struct GUID_FID_CACHE {
+ int cached;
+ jclass clazz;
+ jfieldID data1, data2, data3, b0, b1, b2, b3, b4, b5, b6, b7;
+} GUID_FID_CACHE;
+
+GUID_FID_CACHE GUIDFc;
+
+void cacheGUIDFids(JNIEnv *env, jobject lpObject)
+{
+ if (GUIDFc.cached) return;
+ GUIDFc.clazz = (*env)->GetObjectClass(env, lpObject);
+ GUIDFc.data1 = (*env)->GetFieldID(env, GUIDFc.clazz, "data1", "I");
+ GUIDFc.data2 = (*env)->GetFieldID(env, GUIDFc.clazz, "data2", "S");
+ GUIDFc.data3 = (*env)->GetFieldID(env, GUIDFc.clazz, "data3", "S");
+ GUIDFc.b0 = (*env)->GetFieldID(env, GUIDFc.clazz, "b0", "B");
+ GUIDFc.b1 = (*env)->GetFieldID(env, GUIDFc.clazz, "b1", "B");
+ GUIDFc.b2 = (*env)->GetFieldID(env, GUIDFc.clazz, "b2", "B");
+ GUIDFc.b3 = (*env)->GetFieldID(env, GUIDFc.clazz, "b3", "B");
+ GUIDFc.b4 = (*env)->GetFieldID(env, GUIDFc.clazz, "b4", "B");
+ GUIDFc.b5 = (*env)->GetFieldID(env, GUIDFc.clazz, "b5", "B");
+ GUIDFc.b6 = (*env)->GetFieldID(env, GUIDFc.clazz, "b6", "B");
+ GUIDFc.b7 = (*env)->GetFieldID(env, GUIDFc.clazz, "b7", "B");
+ GUIDFc.cached = 1;
+}
+
+GUID *getGUIDFields(JNIEnv *env, jobject lpObject, GUID *lpStruct)
+{
+ if (!GUIDFc.cached) cacheGUIDFids(env, lpObject);
+ lpStruct->Data4[7] = (*env)->GetByteField(env, lpObject, GUIDFc.b7);
+ lpStruct->Data4[6] = (*env)->GetByteField(env, lpObject, GUIDFc.b6);
+ lpStruct->Data4[5] = (*env)->GetByteField(env, lpObject, GUIDFc.b5);
+ lpStruct->Data4[4] = (*env)->GetByteField(env, lpObject, GUIDFc.b4);
+ lpStruct->Data4[3] = (*env)->GetByteField(env, lpObject, GUIDFc.b3);
+ lpStruct->Data4[2] = (*env)->GetByteField(env, lpObject, GUIDFc.b2);
+ lpStruct->Data4[1] = (*env)->GetByteField(env, lpObject, GUIDFc.b1);
+ lpStruct->Data4[0] = (*env)->GetByteField(env, lpObject, GUIDFc.b0);
+ lpStruct->Data3 = (*env)->GetShortField(env, lpObject, GUIDFc.data3);
+ lpStruct->Data2 = (*env)->GetShortField(env, lpObject, GUIDFc.data2);
+ lpStruct->Data1 = (*env)->GetIntField(env, lpObject, GUIDFc.data1);
+ return lpStruct;
+}
+
+void setGUIDFields(JNIEnv *env, jobject lpObject, GUID *lpStruct)
+{
+ if (!GUIDFc.cached) cacheGUIDFids(env, lpObject);
+ (*env)->SetByteField(env, lpObject, GUIDFc.b7, lpStruct->Data4[7]);
+ (*env)->SetByteField(env, lpObject, GUIDFc.b6, lpStruct->Data4[6]);
+ (*env)->SetByteField(env, lpObject, GUIDFc.b5, lpStruct->Data4[5]);
+ (*env)->SetByteField(env, lpObject, GUIDFc.b4, lpStruct->Data4[4]);
+ (*env)->SetByteField(env, lpObject, GUIDFc.b3, lpStruct->Data4[3]);
+ (*env)->SetByteField(env, lpObject, GUIDFc.b2, lpStruct->Data4[2]);
+ (*env)->SetByteField(env, lpObject, GUIDFc.b1, lpStruct->Data4[1]);
+ (*env)->SetByteField(env, lpObject, GUIDFc.b0, lpStruct->Data4[0]);
+ (*env)->SetShortField(env, lpObject, GUIDFc.data3, lpStruct->Data3);
+ (*env)->SetShortField(env, lpObject, GUIDFc.data2, lpStruct->Data2);
+ (*env)->SetIntField(env, lpObject, GUIDFc.data1, lpStruct->Data1);
+}
+
+#endif /* NO_GUID */
+
+#ifndef NO_LICINFO
+typedef struct LICINFO_FID_CACHE {
+ int cached;
+ jclass clazz;
+ jfieldID cbLicInfo, fRuntimeKeyAvail, fLicVerified;
+} LICINFO_FID_CACHE;
+
+LICINFO_FID_CACHE LICINFOFc;
+
+void cacheLICINFOFids(JNIEnv *env, jobject lpObject)
+{
+ if (LICINFOFc.cached) return;
+ LICINFOFc.clazz = (*env)->GetObjectClass(env, lpObject);
+ LICINFOFc.cbLicInfo = (*env)->GetFieldID(env, LICINFOFc.clazz, "cbLicInfo", "I");
+ LICINFOFc.fRuntimeKeyAvail = (*env)->GetFieldID(env, LICINFOFc.clazz, "fRuntimeKeyAvail", "I");
+ LICINFOFc.fLicVerified = (*env)->GetFieldID(env, LICINFOFc.clazz, "fLicVerified", "I");
+ LICINFOFc.cached = 1;
+}
+
+LICINFO *getLICINFOFields(JNIEnv *env, jobject lpObject, LICINFO *lpStruct)
+{
+ if (!LICINFOFc.cached) cacheLICINFOFids(env, lpObject);
+ lpStruct->cbLicInfo = (*env)->GetIntField(env, lpObject, LICINFOFc.cbLicInfo);
+ lpStruct->fRuntimeKeyAvail = (*env)->GetIntField(env, lpObject, LICINFOFc.fRuntimeKeyAvail);
+ lpStruct->fLicVerified = (*env)->GetIntField(env, lpObject, LICINFOFc.fLicVerified);
+ return lpStruct;
+}
+
+void setLICINFOFields(JNIEnv *env, jobject lpObject, LICINFO *lpStruct)
+{
+ if (!LICINFOFc.cached) cacheLICINFOFids(env, lpObject);
+ (*env)->SetIntField(env, lpObject, LICINFOFc.cbLicInfo, (jint)lpStruct->cbLicInfo);
+ (*env)->SetIntField(env, lpObject, LICINFOFc.fRuntimeKeyAvail, (jint)lpStruct->fRuntimeKeyAvail);
+ (*env)->SetIntField(env, lpObject, LICINFOFc.fLicVerified, (jint)lpStruct->fLicVerified);
+}
+#endif /* NO_LICINFO */
+
+#ifndef NO_OLECMD
+typedef struct OLECMD_FID_CACHE {
+ int cached;
+ jclass clazz;
+ jfieldID cmdID, cmdf;
+} OLECMD_FID_CACHE;
+
+OLECMD_FID_CACHE OLECMDFc;
+
+void cacheOLECMDFids(JNIEnv *env, jobject lpObject)
+{
+ if (OLECMDFc.cached) return;
+ OLECMDFc.clazz = (*env)->GetObjectClass(env, lpObject);
+ OLECMDFc.cmdID = (*env)->GetFieldID(env, OLECMDFc.clazz, "cmdID", "I");
+ OLECMDFc.cmdf = (*env)->GetFieldID(env, OLECMDFc.clazz, "cmdf", "I");
+ OLECMDFc.cached = 1;
+}
+
+OLECMD *getOLECMDFields(JNIEnv *env, jobject lpObject, OLECMD *lpStruct)
+{
+ if (!OLECMDFc.cached) cacheOLECMDFids(env, lpObject);
+ lpStruct->cmdID = (*env)->GetIntField(env, lpObject, OLECMDFc.cmdID);
+ lpStruct->cmdf = (*env)->GetIntField(env, lpObject, OLECMDFc.cmdf);
+ return lpStruct;
+}
+
+void setOLECMDFields(JNIEnv *env, jobject lpObject, OLECMD *lpStruct)
+{
+ if (!OLECMDFc.cached) cacheOLECMDFids(env, lpObject);
+ (*env)->SetIntField(env, lpObject, OLECMDFc.cmdID, (jint)lpStruct->cmdID);
+ (*env)->SetIntField(env, lpObject, OLECMDFc.cmdf, (jint)lpStruct->cmdf);
+}
+#endif /* NO_OLECMD */
+
+#ifndef NO_OLECMDTEXT
+typedef struct OLECMDTEXT_FID_CACHE {
+ int cached;
+ jclass clazz;
+ jfieldID cmdtextf, cwActual, cwBuf, rgwz;
+} OLECMDTEXT_FID_CACHE;
+
+OLECMDTEXT_FID_CACHE OLECMDTEXTFc;
+
+void cacheOLECMDTEXTFids(JNIEnv *env, jobject lpObject)
+{
+ if (OLECMDTEXTFc.cached) return;
+ OLECMDTEXTFc.clazz = (*env)->GetObjectClass(env, lpObject);
+ OLECMDTEXTFc.cmdtextf = (*env)->GetFieldID(env, OLECMDTEXTFc.clazz, "cmdtextf", "I");
+ OLECMDTEXTFc.cwActual = (*env)->GetFieldID(env, OLECMDTEXTFc.clazz, "cwActual", "I");
+ OLECMDTEXTFc.cwBuf = (*env)->GetFieldID(env, OLECMDTEXTFc.clazz, "cwBuf", "I");
+ OLECMDTEXTFc.rgwz = (*env)->GetFieldID(env, OLECMDTEXTFc.clazz, "rgwz", "S");
+ OLECMDTEXTFc.cached = 1;
+}
+
+OLECMDTEXT *getOLECMDTEXTFields(JNIEnv *env, jobject lpObject, OLECMDTEXT *lpStruct)
+{
+ if (!OLECMDTEXTFc.cached) cacheOLECMDTEXTFids(env, lpObject);
+ lpStruct->cmdtextf = (*env)->GetIntField(env, lpObject, OLECMDTEXTFc.cmdtextf);
+ lpStruct->cwActual = (*env)->GetIntField(env, lpObject, OLECMDTEXTFc.cwActual);
+ lpStruct->cwBuf = (*env)->GetIntField(env, lpObject, OLECMDTEXTFc.cwBuf);
+ lpStruct->rgwz[0] = (*env)->GetShortField(env, lpObject, OLECMDTEXTFc.rgwz); /* SPECIAL */
+ return lpStruct;
+}
+
+void setOLECMDTEXTFields(JNIEnv *env, jobject lpObject, OLECMDTEXT *lpStruct)
+{
+ if (!OLECMDTEXTFc.cached) cacheOLECMDTEXTFids(env, lpObject);
+ (*env)->SetIntField(env, lpObject, OLECMDTEXTFc.cmdtextf, (jint)lpStruct->cmdtextf);
+ (*env)->SetIntField(env, lpObject, OLECMDTEXTFc.cwActual, (jint)lpStruct->cwActual);
+ (*env)->SetIntField(env, lpObject, OLECMDTEXTFc.cwBuf, (jint)lpStruct->cwBuf);
+ (*env)->SetShortField(env, lpObject, OLECMDTEXTFc.rgwz, (jshort)lpStruct->rgwz[0]); /* SPECIAL */
+}
+#endif /* NO_OLECMDTEXT */
+
+#ifndef NO_OLEINPLACEFRAMEINFO
+typedef struct OLEINPLACEFRAMEINFO_FID_CACHE {
+ int cached;
+ jclass clazz;
+ jfieldID cb, fMDIApp, hwndFrame, haccel, cAccelEntries;
+} OLEINPLACEFRAMEINFO_FID_CACHE;
+
+OLEINPLACEFRAMEINFO_FID_CACHE OLEINPLACEFRAMEINFOFc;
+
+void cacheOLEINPLACEFRAMEINFOFids(JNIEnv *env, jobject lpObject)
+{
+ if (OLEINPLACEFRAMEINFOFc.cached) return;
+ OLEINPLACEFRAMEINFOFc.clazz = (*env)->GetObjectClass(env, lpObject);
+ OLEINPLACEFRAMEINFOFc.cb = (*env)->GetFieldID(env, OLEINPLACEFRAMEINFOFc.clazz, "cb", "I");
+ OLEINPLACEFRAMEINFOFc.fMDIApp = (*env)->GetFieldID(env, OLEINPLACEFRAMEINFOFc.clazz, "fMDIApp", "I");
+ OLEINPLACEFRAMEINFOFc.hwndFrame = (*env)->GetFieldID(env, OLEINPLACEFRAMEINFOFc.clazz, "hwndFrame", "I");
+ OLEINPLACEFRAMEINFOFc.haccel = (*env)->GetFieldID(env, OLEINPLACEFRAMEINFOFc.clazz, "haccel", "I");
+ OLEINPLACEFRAMEINFOFc.cAccelEntries = (*env)->GetFieldID(env, OLEINPLACEFRAMEINFOFc.clazz, "cAccelEntries", "I");
+ OLEINPLACEFRAMEINFOFc.cached = 1;
+}
+
+OLEINPLACEFRAMEINFO *getOLEINPLACEFRAMEINFOFields(JNIEnv *env, jobject lpObject, OLEINPLACEFRAMEINFO *lpStruct)
+{
+ if (!OLEINPLACEFRAMEINFOFc.cached) cacheOLEINPLACEFRAMEINFOFids(env, lpObject);
+ lpStruct->cb = (*env)->GetIntField(env, lpObject, OLEINPLACEFRAMEINFOFc.cb);
+ lpStruct->fMDIApp = (*env)->GetIntField(env, lpObject, OLEINPLACEFRAMEINFOFc.fMDIApp);
+ lpStruct->hwndFrame = (HWND)(*env)->GetIntField(env, lpObject, OLEINPLACEFRAMEINFOFc.hwndFrame);
+ lpStruct->haccel = (HACCEL)(*env)->GetIntField(env, lpObject, OLEINPLACEFRAMEINFOFc.haccel);
+ lpStruct->cAccelEntries = (*env)->GetIntField(env, lpObject, OLEINPLACEFRAMEINFOFc.cAccelEntries);
+ return lpStruct;
+}
+
+void setOLEINPLACEFRAMEINFOFields(JNIEnv *env, jobject lpObject, OLEINPLACEFRAMEINFO *lpStruct)
+{
+ if (!OLEINPLACEFRAMEINFOFc.cached) cacheOLEINPLACEFRAMEINFOFids(env, lpObject);
+ (*env)->SetIntField(env, lpObject, OLEINPLACEFRAMEINFOFc.cb, (jint)lpStruct->cb);
+ (*env)->SetIntField(env, lpObject, OLEINPLACEFRAMEINFOFc.fMDIApp, (jint)lpStruct->fMDIApp);
+ (*env)->SetIntField(env, lpObject, OLEINPLACEFRAMEINFOFc.hwndFrame, (jint)lpStruct->hwndFrame);
+ (*env)->SetIntField(env, lpObject, OLEINPLACEFRAMEINFOFc.haccel, (jint)lpStruct->haccel);
+ (*env)->SetIntField(env, lpObject, OLEINPLACEFRAMEINFOFc.cAccelEntries, (jint)lpStruct->cAccelEntries);
+}
+#endif /* NO_OLEINPLACEFRAMEINFO */
+
+#ifndef NO_STATSTG
+typedef struct STATSTG_FID_CACHE {
+ int cached;
+ jclass clazz;
+ 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;
+
+STATSTG_FID_CACHE STATSTGFc;
+
+void cacheSTATSTGFids(JNIEnv *env, jobject lpObject)
+{
+ if (STATSTGFc.cached) return;
+ STATSTGFc.clazz = (*env)->GetObjectClass(env, lpObject);
+ STATSTGFc.pwcsName = (*env)->GetFieldID(env, STATSTGFc.clazz, "pwcsName", "I");
+ STATSTGFc.type = (*env)->GetFieldID(env, STATSTGFc.clazz, "type", "I");
+ STATSTGFc.cbSize = (*env)->GetFieldID(env, STATSTGFc.clazz, "cbSize", "J");
+ STATSTGFc.mtime_dwLowDateTime = (*env)->GetFieldID(env, STATSTGFc.clazz, "mtime_dwLowDateTime", "I");
+ STATSTGFc.mtime_dwHighDateTime = (*env)->GetFieldID(env, STATSTGFc.clazz, "mtime_dwHighDateTime", "I");
+ STATSTGFc.ctime_dwLowDateTime = (*env)->GetFieldID(env, STATSTGFc.clazz, "ctime_dwLowDateTime", "I");
+ STATSTGFc.ctime_dwHighDateTime = (*env)->GetFieldID(env, STATSTGFc.clazz, "ctime_dwHighDateTime", "I");
+ STATSTGFc.atime_dwLowDateTime = (*env)->GetFieldID(env, STATSTGFc.clazz, "atime_dwLowDateTime", "I");
+ STATSTGFc.atime_dwHighDateTime = (*env)->GetFieldID(env, STATSTGFc.clazz, "atime_dwHighDateTime", "I");
+ STATSTGFc.grfMode = (*env)->GetFieldID(env, STATSTGFc.clazz, "grfMode", "I");
+ STATSTGFc.grfLocksSupported = (*env)->GetFieldID(env, STATSTGFc.clazz, "grfLocksSupported", "I");
+ STATSTGFc.clsid_data1 = (*env)->GetFieldID(env, STATSTGFc.clazz, "clsid_data1", "I");
+ STATSTGFc.clsid_data2 = (*env)->GetFieldID(env, STATSTGFc.clazz, "clsid_data2", "S");
+ STATSTGFc.clsid_data3 = (*env)->GetFieldID(env, STATSTGFc.clazz, "clsid_data3", "S");
+ STATSTGFc.clsid_b0 = (*env)->GetFieldID(env, STATSTGFc.clazz, "clsid_b0", "B");
+ STATSTGFc.clsid_b1 = (*env)->GetFieldID(env, STATSTGFc.clazz, "clsid_b1", "B");
+ STATSTGFc.clsid_b2 = (*env)->GetFieldID(env, STATSTGFc.clazz, "clsid_b2", "B");
+ STATSTGFc.clsid_b3 = (*env)->GetFieldID(env, STATSTGFc.clazz, "clsid_b3", "B");
+ STATSTGFc.clsid_b4 = (*env)->GetFieldID(env, STATSTGFc.clazz, "clsid_b4", "B");
+ STATSTGFc.clsid_b5 = (*env)->GetFieldID(env, STATSTGFc.clazz, "clsid_b5", "B");
+ STATSTGFc.clsid_b6 = (*env)->GetFieldID(env, STATSTGFc.clazz, "clsid_b6", "B");
+ STATSTGFc.clsid_b7 = (*env)->GetFieldID(env, STATSTGFc.clazz, "clsid_b7", "B");
+ STATSTGFc.grfStateBits = (*env)->GetFieldID(env, STATSTGFc.clazz, "grfStateBits", "I");
+ STATSTGFc.reserved = (*env)->GetFieldID(env, STATSTGFc.clazz, "reserved", "I");
+ STATSTGFc.cached = 1;
+}
+
+STATSTG *getSTATSTGFields(JNIEnv *env, jobject lpObject, STATSTG *lpStruct)
+{
+ if (!STATSTGFc.cached) cacheSTATSTGFids(env, lpObject);
+ lpStruct->pwcsName = (LPWSTR)(*env)->GetIntField(env, lpObject, STATSTGFc.pwcsName);
+ lpStruct->type = (*env)->GetIntField(env, lpObject, STATSTGFc.type);
+ lpStruct->cbSize.QuadPart = (*env)->GetLongField(env, lpObject, STATSTGFc.cbSize);
+ lpStruct->mtime.dwLowDateTime = (*env)->GetIntField(env, lpObject, STATSTGFc.mtime_dwLowDateTime);
+ lpStruct->mtime.dwHighDateTime = (*env)->GetIntField(env, lpObject, STATSTGFc.mtime_dwHighDateTime);
+ lpStruct->ctime.dwLowDateTime = (*env)->GetIntField(env, lpObject, STATSTGFc.ctime_dwLowDateTime);
+ lpStruct->ctime.dwHighDateTime = (*env)->GetIntField(env, lpObject, STATSTGFc.ctime_dwHighDateTime);
+ lpStruct->atime.dwLowDateTime = (*env)->GetIntField(env, lpObject, STATSTGFc.atime_dwLowDateTime);
+ lpStruct->atime.dwHighDateTime = (*env)->GetIntField(env, lpObject, STATSTGFc.atime_dwHighDateTime);
+ lpStruct->grfMode = (*env)->GetIntField(env, lpObject, STATSTGFc.grfMode);
+ lpStruct->grfLocksSupported = (*env)->GetIntField(env, lpObject, STATSTGFc.grfLocksSupported);
+ lpStruct->clsid.Data4[7] = (*env)->GetByteField(env, lpObject, STATSTGFc.clsid_b7);
+ lpStruct->clsid.Data4[6] = (*env)->GetByteField(env, lpObject, STATSTGFc.clsid_b6);
+ lpStruct->clsid.Data4[5] = (*env)->GetByteField(env, lpObject, STATSTGFc.clsid_b5);
+ lpStruct->clsid.Data4[4] = (*env)->GetByteField(env, lpObject, STATSTGFc.clsid_b4);
+ lpStruct->clsid.Data4[3] = (*env)->GetByteField(env, lpObject, STATSTGFc.clsid_b3);
+ lpStruct->clsid.Data4[2] = (*env)->GetByteField(env, lpObject, STATSTGFc.clsid_b2);
+ lpStruct->clsid.Data4[1] = (*env)->GetByteField(env, lpObject, STATSTGFc.clsid_b1);
+ lpStruct->clsid.Data4[0] = (*env)->GetByteField(env, lpObject, STATSTGFc.clsid_b0);
+ lpStruct->clsid.Data3 = (*env)->GetShortField(env, lpObject, STATSTGFc.clsid_data3);
+ lpStruct->clsid.Data2 = (*env)->GetShortField(env, lpObject, STATSTGFc.clsid_data2);
+ lpStruct->clsid.Data1 = (*env)->GetIntField(env, lpObject, STATSTGFc.clsid_data1);
+ lpStruct->grfStateBits = (*env)->GetIntField(env, lpObject, STATSTGFc.grfStateBits);
+ lpStruct->reserved = (*env)->GetIntField(env, lpObject, STATSTGFc.reserved);
+ return lpStruct;
+}
+
+void setSTATSTGFields(JNIEnv *env, jobject lpObject, STATSTG *lpStruct)
+{
+ if (!STATSTGFc.cached) cacheSTATSTGFids(env, lpObject);
+ (*env)->SetIntField(env, lpObject, STATSTGFc.pwcsName, (jint)lpStruct->pwcsName);
+ (*env)->SetIntField(env, lpObject, STATSTGFc.type, (jint)lpStruct->type);
+ (*env)->SetLongField(env, lpObject, STATSTGFc.cbSize, (jlong)lpStruct->cbSize.QuadPart);
+ (*env)->SetIntField(env, lpObject, STATSTGFc.mtime_dwLowDateTime, (jint)lpStruct->mtime.dwLowDateTime);
+ (*env)->SetIntField(env, lpObject, STATSTGFc.mtime_dwHighDateTime, (jint)lpStruct->mtime.dwHighDateTime);
+ (*env)->SetIntField(env, lpObject, STATSTGFc.ctime_dwLowDateTime, (jint)lpStruct->ctime.dwLowDateTime);
+ (*env)->SetIntField(env, lpObject, STATSTGFc.ctime_dwHighDateTime, (jint)lpStruct->ctime.dwHighDateTime);
+ (*env)->SetIntField(env, lpObject, STATSTGFc.atime_dwLowDateTime, (jint)lpStruct->atime.dwLowDateTime);
+ (*env)->SetIntField(env, lpObject, STATSTGFc.atime_dwHighDateTime, (jint)lpStruct->atime.dwHighDateTime);
+ (*env)->SetIntField(env, lpObject, STATSTGFc.grfMode, (jint)lpStruct->grfMode);
+ (*env)->SetIntField(env, lpObject, STATSTGFc.grfLocksSupported, (jint)lpStruct->grfLocksSupported);
+ (*env)->SetByteField(env, lpObject, STATSTGFc.clsid_b7, lpStruct->clsid.Data4[7]);
+ (*env)->SetByteField(env, lpObject, STATSTGFc.clsid_b6, lpStruct->clsid.Data4[6]);
+ (*env)->SetByteField(env, lpObject, STATSTGFc.clsid_b5, lpStruct->clsid.Data4[5]);
+ (*env)->SetByteField(env, lpObject, STATSTGFc.clsid_b4, lpStruct->clsid.Data4[4]);
+ (*env)->SetByteField(env, lpObject, STATSTGFc.clsid_b3, lpStruct->clsid.Data4[3]);
+ (*env)->SetByteField(env, lpObject, STATSTGFc.clsid_b2, lpStruct->clsid.Data4[2]);
+ (*env)->SetByteField(env, lpObject, STATSTGFc.clsid_b1, lpStruct->clsid.Data4[1]);
+ (*env)->SetByteField(env, lpObject, STATSTGFc.clsid_b0, lpStruct->clsid.Data4[0]);
+ (*env)->SetShortField(env, lpObject, STATSTGFc.clsid_data3, lpStruct->clsid.Data3);
+ (*env)->SetShortField(env, lpObject, STATSTGFc.clsid_data2, lpStruct->clsid.Data2);
+ (*env)->SetIntField(env, lpObject, STATSTGFc.clsid_data1, lpStruct->clsid.Data1);
+ (*env)->SetIntField(env, lpObject, STATSTGFc.grfStateBits, (jint)lpStruct->grfStateBits);
+ (*env)->SetIntField(env, lpObject, STATSTGFc.reserved, (jint)lpStruct->reserved);
+}
+#endif /* NO_STATSTG */
+
+#ifndef NO_STGMEDIUM
+typedef struct STGMEDIUM_FID_CACHE {
+ int cached;
+ jclass clazz;
+ jfieldID tymed, unionField, pUnkForRelease;
+} STGMEDIUM_FID_CACHE;
+
+STGMEDIUM_FID_CACHE STGMEDIUMFc;
+
+void cacheSTGMEDIUMFids(JNIEnv *env, jobject lpObject)
+{
+ if (STGMEDIUMFc.cached) return;
+ STGMEDIUMFc.clazz = (*env)->GetObjectClass(env, lpObject);
+ STGMEDIUMFc.tymed = (*env)->GetFieldID(env, STGMEDIUMFc.clazz, "tymed", "I");
+ STGMEDIUMFc.unionField = (*env)->GetFieldID(env, STGMEDIUMFc.clazz, "unionField", "I");
+ STGMEDIUMFc.pUnkForRelease = (*env)->GetFieldID(env, STGMEDIUMFc.clazz, "pUnkForRelease", "I");
+ STGMEDIUMFc.cached = 1;
+}
+
+STGMEDIUM *getSTGMEDIUMFields(JNIEnv *env, jobject lpObject, STGMEDIUM *lpStruct)
+{
+ if (!STGMEDIUMFc.cached) cacheSTGMEDIUMFids(env, lpObject);
+ lpStruct->tymed = (*env)->GetIntField(env, lpObject, STGMEDIUMFc.tymed);
+ lpStruct->hGlobal = (HGLOBAL)(*env)->GetIntField(env, lpObject, STGMEDIUMFc.unionField);
+ lpStruct->pUnkForRelease = (IUnknown *)(*env)->GetIntField(env, lpObject, STGMEDIUMFc.pUnkForRelease);
+ return lpStruct;
+}
+
+void setSTGMEDIUMFields(JNIEnv *env, jobject lpObject, STGMEDIUM *lpStruct)
+{
+ if (!STGMEDIUMFc.cached) cacheSTGMEDIUMFids(env, lpObject);
+ (*env)->SetIntField(env, lpObject, STGMEDIUMFc.tymed, (jint)lpStruct->tymed);
+ (*env)->SetIntField(env, lpObject, STGMEDIUMFc.unionField, (jint)lpStruct->hGlobal);
+ (*env)->SetIntField(env, lpObject, STGMEDIUMFc.pUnkForRelease, (jint)lpStruct->pUnkForRelease);
+}
+#endif /* NO_STGMEDIUM */
+
+#ifndef NO_TYPEATTR
+typedef struct TYPEATTR_FID_CACHE {
+ int cached;
+ jclass clazz;
+ 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;
+
+TYPEATTR_FID_CACHE TYPEATTRFc;
+
+void cacheTYPEATTRFids(JNIEnv *env, jobject lpObject)
+{
+ if (TYPEATTRFc.cached) return;
+ TYPEATTRFc.clazz = (*env)->GetObjectClass(env, lpObject);
+ TYPEATTRFc.guid_data1 = (*env)->GetFieldID(env, TYPEATTRFc.clazz, "guid_data1", "I");
+ TYPEATTRFc.guid_data2 = (*env)->GetFieldID(env, TYPEATTRFc.clazz, "guid_data2", "S");
+ TYPEATTRFc.guid_data3 = (*env)->GetFieldID(env, TYPEATTRFc.clazz, "guid_data3", "S");
+ TYPEATTRFc.guid_b0 = (*env)->GetFieldID(env, TYPEATTRFc.clazz, "guid_b0", "B");
+ TYPEATTRFc.guid_b1 = (*env)->GetFieldID(env, TYPEATTRFc.clazz, "guid_b1", "B");
+ TYPEATTRFc.guid_b2 = (*env)->GetFieldID(env, TYPEATTRFc.clazz, "guid_b2", "B");
+ TYPEATTRFc.guid_b3 = (*env)->GetFieldID(env, TYPEATTRFc.clazz, "guid_b3", "B");
+ TYPEATTRFc.guid_b4 = (*env)->GetFieldID(env, TYPEATTRFc.clazz, "guid_b4", "B");
+ TYPEATTRFc.guid_b5 = (*env)->GetFieldID(env, TYPEATTRFc.clazz, "guid_b5", "B");
+ TYPEATTRFc.guid_b6 = (*env)->GetFieldID(env, TYPEATTRFc.clazz, "guid_b6", "B");
+ TYPEATTRFc.guid_b7 = (*env)->GetFieldID(env, TYPEATTRFc.clazz, "guid_b7", "B");
+ TYPEATTRFc.lcid = (*env)->GetFieldID(env, TYPEATTRFc.clazz, "lcid", "I");
+ TYPEATTRFc.dwReserved = (*env)->GetFieldID(env, TYPEATTRFc.clazz, "dwReserved", "I");
+ TYPEATTRFc.memidConstructor = (*env)->GetFieldID(env, TYPEATTRFc.clazz, "memidConstructor", "I");
+ TYPEATTRFc.memidDestructor = (*env)->GetFieldID(env, TYPEATTRFc.clazz, "memidDestructor", "I");
+ TYPEATTRFc.lpstrSchema = (*env)->GetFieldID(env, TYPEATTRFc.clazz, "lpstrSchema", "I");
+ TYPEATTRFc.cbSizeInstance = (*env)->GetFieldID(env, TYPEATTRFc.clazz, "cbSizeInstance", "I");
+ TYPEATTRFc.typekind = (*env)->GetFieldID(env, TYPEATTRFc.clazz, "typekind", "I");
+ TYPEATTRFc.cFuncs = (*env)->GetFieldID(env, TYPEATTRFc.clazz, "cFuncs", "S");
+ TYPEATTRFc.cVars = (*env)->GetFieldID(env, TYPEATTRFc.clazz, "cVars", "S");
+ TYPEATTRFc.cImplTypes = (*env)->GetFieldID(env, TYPEATTRFc.clazz, "cImplTypes", "S");
+ TYPEATTRFc.cbSizeVft = (*env)->GetFieldID(env, TYPEATTRFc.clazz, "cbSizeVft", "S");
+ TYPEATTRFc.cbAlignment = (*env)->GetFieldID(env, TYPEATTRFc.clazz, "cbAlignment", "S");
+ TYPEATTRFc.wTypeFlags = (*env)->GetFieldID(env, TYPEATTRFc.clazz, "wTypeFlags", "S");
+ TYPEATTRFc.wMajorVerNum = (*env)->GetFieldID(env, TYPEATTRFc.clazz, "wMajorVerNum", "S");
+ TYPEATTRFc.wMinorVerNum = (*env)->GetFieldID(env, TYPEATTRFc.clazz, "wMinorVerNum", "S");
+ TYPEATTRFc.tdescAlias_unionField = (*env)->GetFieldID(env, TYPEATTRFc.clazz, "tdescAlias_unionField", "I");
+ TYPEATTRFc.tdescAlias_vt = (*env)->GetFieldID(env, TYPEATTRFc.clazz, "tdescAlias_vt", "S");
+ TYPEATTRFc.idldescType_dwReserved = (*env)->GetFieldID(env, TYPEATTRFc.clazz, "idldescType_dwReserved", "I");
+ TYPEATTRFc.idldescType_wIDLFlags = (*env)->GetFieldID(env, TYPEATTRFc.clazz, "idldescType_wIDLFlags", "S");
+ TYPEATTRFc.cached = 1;
+}
+
+TYPEATTR *getTYPEATTRFields(JNIEnv *env, jobject lpObject, TYPEATTR *lpStruct)
+{
+ if (!TYPEATTRFc.cached) cacheTYPEATTRFids(env, lpObject);
+ lpStruct->idldescType.wIDLFlags = (*env)->GetShortField(env, lpObject, TYPEATTRFc.idldescType_wIDLFlags);
+ lpStruct->idldescType.dwReserved = (*env)->GetIntField(env, lpObject, TYPEATTRFc.idldescType_dwReserved);
+ lpStruct->tdescAlias.vt = (*env)->GetShortField(env, lpObject, TYPEATTRFc.tdescAlias_vt);
+ lpStruct->tdescAlias.lptdesc = (struct FARSTRUCT tagTYPEDESC FAR *)(*env)->GetIntField(env, lpObject, TYPEATTRFc.tdescAlias_unionField);
+ lpStruct->wMinorVerNum = (*env)->GetShortField(env, lpObject, TYPEATTRFc.wMinorVerNum);
+ lpStruct->wMajorVerNum = (*env)->GetShortField(env, lpObject, TYPEATTRFc.wMajorVerNum);
+ lpStruct->wTypeFlags = (*env)->GetShortField(env, lpObject, TYPEATTRFc.wTypeFlags);
+ lpStruct->cbAlignment = (*env)->GetShortField(env, lpObject, TYPEATTRFc.cbAlignment);
+ lpStruct->cbSizeVft = (*env)->GetShortField(env, lpObject, TYPEATTRFc.cbSizeVft);
+ lpStruct->cImplTypes = (*env)->GetShortField(env, lpObject, TYPEATTRFc.cImplTypes);
+ lpStruct->cVars = (*env)->GetShortField(env, lpObject, TYPEATTRFc.cVars);
+ lpStruct->cFuncs = (*env)->GetShortField(env, lpObject, TYPEATTRFc.cFuncs);
+ lpStruct->typekind = (*env)->GetIntField(env, lpObject, TYPEATTRFc.typekind);
+ lpStruct->cbSizeInstance = (*env)->GetIntField(env, lpObject, TYPEATTRFc.cbSizeInstance);
+ lpStruct->lpstrSchema = (OLECHAR FAR *)(*env)->GetIntField(env, lpObject, TYPEATTRFc.lpstrSchema);
+ lpStruct->memidDestructor = (*env)->GetIntField(env, lpObject, TYPEATTRFc.memidDestructor);
+ lpStruct->memidConstructor = (*env)->GetIntField(env, lpObject, TYPEATTRFc.memidConstructor);
+ lpStruct->dwReserved = (*env)->GetIntField(env, lpObject, TYPEATTRFc.dwReserved);
+ lpStruct->lcid = (*env)->GetIntField(env, lpObject, TYPEATTRFc.lcid);
+ lpStruct->guid.Data4[7] = (*env)->GetByteField(env, lpObject, TYPEATTRFc.guid_b7);
+ lpStruct->guid.Data4[6] = (*env)->GetByteField(env, lpObject, TYPEATTRFc.guid_b6);
+ lpStruct->guid.Data4[5] = (*env)->GetByteField(env, lpObject, TYPEATTRFc.guid_b5);
+ lpStruct->guid.Data4[4] = (*env)->GetByteField(env, lpObject, TYPEATTRFc.guid_b4);
+ lpStruct->guid.Data4[3] = (*env)->GetByteField(env, lpObject, TYPEATTRFc.guid_b3);
+ lpStruct->guid.Data4[2] = (*env)->GetByteField(env, lpObject, TYPEATTRFc.guid_b2);
+ lpStruct->guid.Data4[1] = (*env)->GetByteField(env, lpObject, TYPEATTRFc.guid_b1);
+ lpStruct->guid.Data4[0] = (*env)->GetByteField(env, lpObject, TYPEATTRFc.guid_b0);
+ lpStruct->guid.Data3 = (*env)->GetShortField(env, lpObject, TYPEATTRFc.guid_data3);
+ lpStruct->guid.Data2 = (*env)->GetShortField(env, lpObject, TYPEATTRFc.guid_data2);
+ lpStruct->guid.Data1 = (*env)->GetIntField(env, lpObject, TYPEATTRFc.guid_data1);
+ return lpStruct;
+}
+
+void setTYPEATTRFields(JNIEnv *env, jobject lpObject, TYPEATTR *lpStruct)
+{
+ if (!TYPEATTRFc.cached) cacheTYPEATTRFids(env, lpObject);
+ (*env)->SetShortField(env, lpObject, TYPEATTRFc.idldescType_wIDLFlags, lpStruct->idldescType.wIDLFlags);
+ (*env)->SetIntField(env, lpObject, TYPEATTRFc.idldescType_dwReserved, lpStruct->idldescType.dwReserved);
+ (*env)->SetShortField(env, lpObject, TYPEATTRFc.tdescAlias_vt, lpStruct->tdescAlias.vt);
+ (*env)->SetIntField(env, lpObject, TYPEATTRFc.tdescAlias_unionField, (jint)lpStruct->tdescAlias.lptdesc);
+ (*env)->SetShortField(env, lpObject, TYPEATTRFc.wMinorVerNum, lpStruct->wMinorVerNum);
+ (*env)->SetShortField(env, lpObject, TYPEATTRFc.wMajorVerNum, lpStruct->wMajorVerNum);
+ (*env)->SetShortField(env, lpObject, TYPEATTRFc.wTypeFlags, lpStruct->wTypeFlags);
+ (*env)->SetShortField(env, lpObject, TYPEATTRFc.cbAlignment, lpStruct->cbAlignment);
+ (*env)->SetShortField(env, lpObject, TYPEATTRFc.cbSizeVft, lpStruct->cbSizeVft);
+ (*env)->SetShortField(env, lpObject, TYPEATTRFc.cImplTypes, lpStruct->cImplTypes);
+ (*env)->SetShortField(env, lpObject, TYPEATTRFc.cVars, lpStruct->cVars);
+ (*env)->SetShortField(env, lpObject, TYPEATTRFc.cFuncs, lpStruct->cFuncs);
+ (*env)->SetIntField(env, lpObject, TYPEATTRFc.typekind, lpStruct->typekind);
+ (*env)->SetIntField(env, lpObject, TYPEATTRFc.cbSizeInstance, lpStruct->cbSizeInstance);
+ (*env)->SetIntField(env, lpObject, TYPEATTRFc.lpstrSchema, (jint)lpStruct->lpstrSchema);
+ (*env)->SetIntField(env, lpObject, TYPEATTRFc.memidDestructor, lpStruct->memidDestructor);
+ (*env)->SetIntField(env, lpObject, TYPEATTRFc.memidConstructor, lpStruct->memidConstructor);
+ (*env)->SetIntField(env, lpObject, TYPEATTRFc.dwReserved, lpStruct->dwReserved);
+ (*env)->SetIntField(env, lpObject, TYPEATTRFc.lcid, lpStruct->lcid);
+ (*env)->SetByteField(env, lpObject, TYPEATTRFc.guid_b7, lpStruct->guid.Data4[7]);
+ (*env)->SetByteField(env, lpObject, TYPEATTRFc.guid_b6, lpStruct->guid.Data4[6]);
+ (*env)->SetByteField(env, lpObject, TYPEATTRFc.guid_b5, lpStruct->guid.Data4[5]);
+ (*env)->SetByteField(env, lpObject, TYPEATTRFc.guid_b4, lpStruct->guid.Data4[4]);
+ (*env)->SetByteField(env, lpObject, TYPEATTRFc.guid_b3, lpStruct->guid.Data4[3]);
+ (*env)->SetByteField(env, lpObject, TYPEATTRFc.guid_b2, lpStruct->guid.Data4[2]);
+ (*env)->SetByteField(env, lpObject, TYPEATTRFc.guid_b1, lpStruct->guid.Data4[1]);
+ (*env)->SetByteField(env, lpObject, TYPEATTRFc.guid_b0, lpStruct->guid.Data4[0]);
+ (*env)->SetShortField(env, lpObject, TYPEATTRFc.guid_data3, lpStruct->guid.Data3);
+ (*env)->SetShortField(env, lpObject, TYPEATTRFc.guid_data2, lpStruct->guid.Data2);
+ (*env)->SetIntField(env, lpObject, TYPEATTRFc.guid_data1, lpStruct->guid.Data1);
+}
+#endif /* NO_TYPEATTR */
+
+#ifndef NO_VARDESC1
+typedef struct VARDESC1_FID_CACHE {
+ int cached;
+ jclass clazz;
+ jfieldID memid, lpstrSchema, unionField, elemdescVar_tdesc_union, elemdescVar_tdesc_vt, elemdescVar_paramdesc_pparamdescex, elemdescVar_paramdesc_wParamFlags, wVarFlags, varkind;
+} VARDESC1_FID_CACHE;
+
+VARDESC1_FID_CACHE VARDESC1Fc;
+
+void cacheVARDESC1Fids(JNIEnv *env, jobject lpObject)
+{
+ if (VARDESC1Fc.cached) return;
+ VARDESC1Fc.clazz = (*env)->GetObjectClass(env, lpObject);
+ VARDESC1Fc.memid = (*env)->GetFieldID(env, VARDESC1Fc.clazz, "memid", "I");
+ VARDESC1Fc.lpstrSchema = (*env)->GetFieldID(env, VARDESC1Fc.clazz, "lpstrSchema", "I");
+ VARDESC1Fc.unionField = (*env)->GetFieldID(env, VARDESC1Fc.clazz, "unionField", "I");
+ VARDESC1Fc.elemdescVar_tdesc_union = (*env)->GetFieldID(env, VARDESC1Fc.clazz, "elemdescVar_tdesc_union", "I");
+ VARDESC1Fc.elemdescVar_tdesc_vt = (*env)->GetFieldID(env, VARDESC1Fc.clazz, "elemdescVar_tdesc_vt", "S");
+ VARDESC1Fc.elemdescVar_paramdesc_pparamdescex = (*env)->GetFieldID(env, VARDESC1Fc.clazz, "elemdescVar_paramdesc_pparamdescex", "I");
+ VARDESC1Fc.elemdescVar_paramdesc_wParamFlags = (*env)->GetFieldID(env, VARDESC1Fc.clazz, "elemdescVar_paramdesc_wParamFlags", "S");
+ VARDESC1Fc.wVarFlags = (*env)->GetFieldID(env, VARDESC1Fc.clazz, "wVarFlags", "S");
+ VARDESC1Fc.varkind = (*env)->GetFieldID(env, VARDESC1Fc.clazz, "varkind", "I");
+ VARDESC1Fc.cached = 1;
+}
+
+VARDESC *getVARDESC1Fields(JNIEnv *env, jobject lpObject, VARDESC *lpStruct)
+{
+ if (!VARDESC1Fc.cached) cacheVARDESC1Fids(env, lpObject);
+ lpStruct->varkind = (*env)->GetIntField(env, lpObject, VARDESC1Fc.varkind);
+ lpStruct->wVarFlags = (*env)->GetShortField(env, lpObject, VARDESC1Fc.wVarFlags);
+ lpStruct->elemdescVar.paramdesc.wParamFlags = (*env)->GetShortField(env, lpObject, VARDESC1Fc.elemdescVar_paramdesc_wParamFlags);
+ lpStruct->elemdescVar.paramdesc.pparamdescex = (LPPARAMDESCEX)(*env)->GetIntField(env, lpObject, VARDESC1Fc.elemdescVar_paramdesc_pparamdescex);
+ lpStruct->elemdescVar.tdesc.vt = (*env)->GetShortField(env, lpObject, VARDESC1Fc.elemdescVar_tdesc_vt);
+ lpStruct->elemdescVar.tdesc.lptdesc = (struct FARSTRUCT tagTYPEDESC FAR *)(*env)->GetIntField(env, lpObject, VARDESC1Fc.elemdescVar_tdesc_union);
+ lpStruct->oInst = (*env)->GetIntField(env, lpObject, VARDESC1Fc.unionField);
+ lpStruct->lpstrSchema = (OLECHAR FAR *)(*env)->GetIntField(env, lpObject, VARDESC1Fc.lpstrSchema);
+ lpStruct->memid = (*env)->GetIntField(env, lpObject, VARDESC1Fc.memid);
+ return lpStruct;
+}
+
+void setVARDESC1Fields(JNIEnv *env, jobject lpObject, VARDESC *lpStruct)
+{
+ if (!VARDESC1Fc.cached) cacheVARDESC1Fids(env, lpObject);
+ (*env)->SetIntField(env, lpObject, VARDESC1Fc.varkind, lpStruct->varkind);
+ (*env)->SetShortField(env, lpObject, VARDESC1Fc.wVarFlags, lpStruct->wVarFlags);
+ (*env)->SetShortField(env, lpObject, VARDESC1Fc.elemdescVar_paramdesc_wParamFlags, lpStruct->elemdescVar.paramdesc.wParamFlags);
+ (*env)->SetIntField(env, lpObject, VARDESC1Fc.elemdescVar_paramdesc_pparamdescex, (jint)lpStruct->elemdescVar.paramdesc.pparamdescex);
+ (*env)->SetShortField(env, lpObject, VARDESC1Fc.elemdescVar_tdesc_vt, lpStruct->elemdescVar.tdesc.vt);
+ (*env)->SetIntField(env, lpObject, VARDESC1Fc.elemdescVar_tdesc_union, (jint)lpStruct->elemdescVar.tdesc.lptdesc);
+ (*env)->SetIntField(env, lpObject, VARDESC1Fc.unionField, lpStruct->oInst);
+ (*env)->SetIntField(env, lpObject, VARDESC1Fc.lpstrSchema, (jint)lpStruct->lpstrSchema);
+ (*env)->SetIntField(env, lpObject, VARDESC1Fc.memid, lpStruct->memid);
+}
+#endif /* NO_VARDESC1 */
+
+#ifndef NO_VARDESC2
+typedef struct VARDESC2_FID_CACHE {
+ int cached;
+ jclass clazz;
+ jfieldID memid, lpstrSchema, unionField, elemdescVar_tdesc_union, elemdescVar_tdesc_vt, elemdescFunc_idldesc_dwReserved, elemdescFunc_idldesc_wIDLFlags, wVarFlags, varkind;
+} VARDESC2_FID_CACHE;
+
+VARDESC2_FID_CACHE VARDESC2Fc;
+
+void cacheVARDESC2Fids(JNIEnv *env, jobject lpObject)
+{
+ if (VARDESC2Fc.cached) return;
+ VARDESC2Fc.clazz = (*env)->GetObjectClass(env, lpObject);
+ VARDESC2Fc.memid = (*env)->GetFieldID(env, VARDESC2Fc.clazz, "memid", "I");
+ VARDESC2Fc.lpstrSchema = (*env)->GetFieldID(env, VARDESC2Fc.clazz, "lpstrSchema", "I");
+ VARDESC2Fc.unionField = (*env)->GetFieldID(env, VARDESC2Fc.clazz, "unionField", "I");
+ VARDESC2Fc.elemdescVar_tdesc_union = (*env)->GetFieldID(env, VARDESC2Fc.clazz, "elemdescVar_tdesc_union", "I");
+ VARDESC2Fc.elemdescVar_tdesc_vt = (*env)->GetFieldID(env, VARDESC2Fc.clazz, "elemdescVar_tdesc_vt", "S");
+ VARDESC2Fc.elemdescFunc_idldesc_dwReserved = (*env)->GetFieldID(env, VARDESC2Fc.clazz, "elemdescFunc_idldesc_dwReserved", "I");
+ VARDESC2Fc.elemdescFunc_idldesc_wIDLFlags = (*env)->GetFieldID(env, VARDESC2Fc.clazz, "elemdescFunc_idldesc_wIDLFlags", "S");
+ VARDESC2Fc.wVarFlags = (*env)->GetFieldID(env, VARDESC2Fc.clazz, "wVarFlags", "S");
+ VARDESC2Fc.varkind = (*env)->GetFieldID(env, VARDESC2Fc.clazz, "varkind", "I");
+ VARDESC2Fc.cached = 1;
+}
+
+VARDESC *getVARDESC2Fields(JNIEnv *env, jobject lpObject, VARDESC *lpStruct)
+{
+ if (!VARDESC2Fc.cached) cacheVARDESC2Fids(env, lpObject);
+ lpStruct->varkind = (*env)->GetIntField(env, lpObject, VARDESC2Fc.varkind);
+ lpStruct->wVarFlags = (*env)->GetShortField(env, lpObject, VARDESC2Fc.wVarFlags);
+ lpStruct->elemdescVar.idldesc.wIDLFlags = (*env)->GetShortField(env, lpObject, VARDESC2Fc.elemdescFunc_idldesc_wIDLFlags);
+ lpStruct->elemdescVar.idldesc.dwReserved = (*env)->GetIntField(env, lpObject, VARDESC2Fc.elemdescFunc_idldesc_dwReserved);
+ lpStruct->elemdescVar.tdesc.vt = (*env)->GetShortField(env, lpObject, VARDESC2Fc.elemdescVar_tdesc_vt);
+ lpStruct->elemdescVar.tdesc.lptdesc = (struct FARSTRUCT tagTYPEDESC FAR *)(*env)->GetIntField(env, lpObject, VARDESC2Fc.elemdescVar_tdesc_union);
+ lpStruct->oInst = (*env)->GetIntField(env, lpObject, VARDESC2Fc.unionField);
+ lpStruct->lpstrSchema = (OLECHAR FAR *)(*env)->GetIntField(env, lpObject, VARDESC2Fc.lpstrSchema);
+ lpStruct->memid = (*env)->GetIntField(env, lpObject, VARDESC2Fc.memid);
+ return lpStruct;
+}
+
+void setVARDESC2Fields(JNIEnv *env, jobject lpObject, VARDESC *lpStruct)
+{
+ if (!VARDESC2Fc.cached) cacheVARDESC2Fids(env, lpObject);
+ (*env)->SetIntField(env, lpObject, VARDESC2Fc.varkind, lpStruct->varkind);
+ (*env)->SetShortField(env, lpObject, VARDESC2Fc.wVarFlags, lpStruct->wVarFlags);
+ (*env)->SetShortField(env, lpObject, VARDESC2Fc.elemdescFunc_idldesc_wIDLFlags, lpStruct->elemdescVar.idldesc.wIDLFlags);
+ (*env)->SetIntField(env, lpObject, VARDESC2Fc.elemdescFunc_idldesc_dwReserved, lpStruct->elemdescVar.idldesc.dwReserved);
+ (*env)->SetShortField(env, lpObject, VARDESC2Fc.elemdescVar_tdesc_vt, lpStruct->elemdescVar.tdesc.vt);
+ (*env)->SetIntField(env, lpObject, VARDESC2Fc.elemdescVar_tdesc_union, (jint)lpStruct->elemdescVar.tdesc.lptdesc);
+ (*env)->SetIntField(env, lpObject, VARDESC2Fc.unionField, lpStruct->oInst);
+ (*env)->SetIntField(env, lpObject, VARDESC2Fc.lpstrSchema, (jint)lpStruct->lpstrSchema);
+ (*env)->SetIntField(env, lpObject, VARDESC2Fc.memid, lpStruct->memid);
+}
+#endif /* NO_VARDESC2 */
+
/**************************** END OLE ****************************/ \ No newline at end of file
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/structs.h b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/structs.h
index edb016413b..f3e3e00cbd 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/structs.h
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/structs.h
@@ -1,817 +1,817 @@
-/*
- * Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
- * This file is made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-/**
- * JNI SWT object field getters and setters declarations for Windows structs.
- */
-
-#ifndef INC_structs_H
-#define INC_structs_H
-
-#define WINVER 0x0500
-#define _WIN32_IE 0x0500
-
-#if _MSC_VER > 1000
-#pragma once
-#endif // _MSC_VER > 1000
-
-#define VC_EXTRALEAN
-
-#include <windows.h>
-#include <winuser.h>
-#include <commctrl.h>
-#include <commdlg.h>
-#include <oaidl.h>
-#include <shlobj.h>
-#include <ole2.h>
-#include <olectl.h>
-#include <objbase.h>
-#include <shlwapi.h>
-#include <shellapi.h>
-
-#ifndef _WIN32_WCE
-#include <initguid.h>
-#include <oleacc.h>
-#endif // _WIN32_WCE
-
-#if defined(WIN32_PLATFORM_PSPC) || defined(WIN32_PLATFORM_WFSP)
-#include <aygshell.h>
-#endif // WIN32_PLATFORM_PSPC, WIN32_PLATFORM_WFSP
-
-#ifdef WIN32_PLATFORM_WFSP
-#include <tpcshell.h>
-#endif /* WIN32_PLATFORM_WFSP */
-
-/* Optional custom definitions to exclude some types */
-#include "defines.h"
-
-#ifdef _WIN32_WCE
-#define NO_BROWSEINFO
-#define NO_CHOOSEFONT
-#define NO_DOCINFO
-#define NO_GCP_RESULTS
-#define NO_GRADIENT_RECT
-#define NO_HELPINFO
-#define NO_MENUINFO
-#define NO_NMREBARCHEVRON
-#define NO_NMTTDISPINFO
-#define NO_NONCLIENTMETRICS
-#define NO_PRINTDLG
-#define NO_TOOLINFO
-#define NO_TRACKMOUSEEVENT
-#define NO_TRIVERTEX
-#define NO_WINDOWPLACEMENT
-#define NO_DROPFILES
-#define NO_OLECMD
-#define NO_OLECMDTEXT
-
-/* OLE */
-#define NO_CAUUID
-#define NO_CONTROLINFO
-#define NO_COSERVERINFO
-#define NO_DISPPARAMS
-#define NO_DVTARGETDEVICE
-#define NO_EXCEPINFO
-#define NO_FORMATETC
-#define NO_FUNCDESC1
-#define NO_FUNCDESC2
-#define NO_GUID
-#define NO_LICINFO
-#define NO_OLEINPLACEFRAMEINFO
-#define NO_STATSTG
-#define NO_STGMEDIUM
-#define NO_TYPEATTR
-#define NO_VARDESC1
-#define NO_VARDESC2
-#endif /* _WIN32_WCE */
-
-#if !defined(WIN32_PLATFORM_PSPC) && !defined(WIN32_PLATFORM_WFSP)
-#define NO_SHMENUBARINFO
-#endif /* WIN32_PLATFORM_PSPC, WIN32_PLATFORM_WFSP */
-
-#ifndef WIN32_PLATFORM_PSPC
-#define NO_SHACTIVATEINFO
-#define NO_SHRGINFO
-#define NO_SIPINFO
-#endif /* WIN32_PLATFORM_PSPC */
-
-/** Structs */
-#ifndef NO_ACCEL
-ACCEL *getACCELFields(JNIEnv *env, jobject lpObject, ACCEL *lpStruct);
-void setACCELFields(JNIEnv *env, jobject lpObject, ACCEL *lpStruct);
-#else
-#define getACCELFields(a,b,c) NULL
-#define setACCELFields(a,b,c)
-#endif /* NO_ACCEL */
-
-#ifndef NO_BITMAP
-BITMAP *getBITMAPFields(JNIEnv *env, jobject lpObject, BITMAP *lpStruct);
-void setBITMAPFields(JNIEnv *env, jobject lpObject, BITMAP *lpStruct);
-#else
-#define getBITMAPFields(a,b,c) NULL
-#define setBITMAPFields(a,b,c)
-#endif /* NO_BITMAP */
-
-#ifndef NO_BITMAPINFOHEADER
-BITMAPINFOHEADER *getBITMAPINFOHEADERFields(JNIEnv *env, jobject lpObject, BITMAPINFOHEADER *lpStruct);
-void setBITMAPINFOHEADERFields(JNIEnv *env, jobject lpObject, BITMAPINFOHEADER *lpStruct);
-#else
-#define getBITMAPINFOHEADERFields(a,b,c) NULL
-#define setBITMAPINFOHEADERFields(a,b,c)
-#endif /* NO_BITMAPINFOHEADER */
-
-#ifndef NO_BROWSEINFO
-BROWSEINFO *getBROWSEINFOFields(JNIEnv *env, jobject lpObject, BROWSEINFO *lpStruct);
-void setBROWSEINFOFields(JNIEnv *env, jobject lpObject, BROWSEINFO *lpStruct);
-#else
-#define getBROWSEINFOFields(a,b,c) NULL
-#define setBROWSEINFOFields(a,b,c)
-#endif /* NO_BROWSEINFO */
-
-#ifndef NO_CHOOSECOLOR
-CHOOSECOLOR *getCHOOSECOLORFields(JNIEnv *env, jobject lpObject, CHOOSECOLOR *lpStruct);
-void setCHOOSECOLORFields(JNIEnv *env, jobject lpObject, CHOOSECOLOR *lpStruct);
-#else
-#define getCHOOSECOLORFields(a,b,c) NULL
-#define setCHOOSECOLORFields(a,b,c)
-#endif /* NO_CHOOSECOLOR */
-
-#ifndef NO_CHOOSEFONT
-CHOOSEFONT *getCHOOSEFONTFields(JNIEnv *env, jobject lpObject, CHOOSEFONT *lpStruct);
-void setCHOOSEFONTFields(JNIEnv *env, jobject lpObject, CHOOSEFONT *lpStruct);
-#else
-#define getCHOOSEFONTFields(a,b,c) NULL
-#define setCHOOSEFONTFields(a,b,c)
-#endif /* NO_CHOOSEFONT */
-
-#ifndef NO_COMPOSITIONFORM
-COMPOSITIONFORM *getCOMPOSITIONFORMFields(JNIEnv *env, jobject lpObject, COMPOSITIONFORM *lpStruct);
-void setCOMPOSITIONFORMFields(JNIEnv *env, jobject lpObject, COMPOSITIONFORM *lpStruct);
-#else
-#define getCOMPOSITIONFORMFields(a,b,c) NULL
-#define setCOMPOSITIONFORMFields(a,b,c)
-#endif /* NO_COMPOSITIONFORM */
-
-#ifndef NO_CREATESTRUCT
-CREATESTRUCT *getCREATESTRUCTFields(JNIEnv *env, jobject lpObject, CREATESTRUCT *lpStruct);
-void setCREATESTRUCTFields(JNIEnv *env, jobject lpObject, CREATESTRUCT *lpStruct);
-#else
-#define getCREATESTRUCTFields(a,b,c) NULL
-#define setCREATESTRUCTFields(a,b,c)
-#endif /* NO_CREATESTRUCT */
-
-#ifndef NO_DIBSECTION
-DIBSECTION *getDIBSECTIONFields(JNIEnv *env, jobject lpObject, DIBSECTION *lpStruct);
-void setDIBSECTIONFields(JNIEnv *env, jobject lpObject, DIBSECTION *lpStruct);
-#else
-#define getDIBSECTIONFields(a,b,c) NULL
-#define setDIBSECTIONFields(a,b,c)
-#endif /* NO_DIBSECTION */
-
-#ifndef NO_DLLVERSIONINFO
-DLLVERSIONINFO *getDLLVERSIONINFOFields(JNIEnv *env, jobject lpObject, DLLVERSIONINFO *lpStruct);
-void setDLLVERSIONINFOFields(JNIEnv *env, jobject lpObject, DLLVERSIONINFO *lpStruct);
-#else
-#define getDLLVERSIONINFOFields(a,b,c) NULL
-#define setDLLVERSIONINFOFields(a,b,c)
-#endif /* NO_DLLVERSIONINFO */
-
-#ifndef NO_DOCINFO
-DOCINFO *getDOCINFOFields(JNIEnv *env, jobject lpObject, DOCINFO *lpStruct);
-void setDOCINFOFields(JNIEnv *env, jobject lpObject, DOCINFO *lpStruct);
-#else
-#define getDOCINFOFields(a,b,c) NULL
-#define setDOCINFOFields(a,b,c)
-#endif /* NO_DOCINFO */
-
-#ifndef NO_DRAWITEMSTRUCT
-DRAWITEMSTRUCT *getDRAWITEMSTRUCTFields(JNIEnv *env, jobject lpObject, DRAWITEMSTRUCT *lpStruct);
-void setDRAWITEMSTRUCTFields(JNIEnv *env, jobject lpObject, DRAWITEMSTRUCT *lpStruct);
-#else
-#define getDRAWITEMSTRUCTFields(a,b,c) NULL
-#define setDRAWITEMSTRUCTFields(a,b,c)
-#endif /* NO_DRAWITEMSTRUCT */
-
-#ifndef NO_DROPFILES
-DROPFILES *getDROPFILESFields(JNIEnv *env, jobject lpObject, DROPFILES *lpStruct);
-void setDROPFILESFields(JNIEnv *env, jobject lpObject, DROPFILES *lpStruct);
-#else
-#define getDROPFILESFields(a,b,c) NULL
-#define setDROPFILESFields(a,b,c)
-#endif /* NO_DROPFILES */
-
-#ifndef NO_FILETIME
-FILETIME *getFILETIMEFields(JNIEnv *env, jobject lpObject, FILETIME *lpStruct);
-void setFILETIMEFields(JNIEnv *env, jobject lpObject, FILETIME *lpStruct);
-#else
-#define getFILETIMEFields(a,b,c) NULL
-#define setFILETIMEFields(a,b,c)
-#endif /* NO_FILETIME */
-
-#ifndef NO_GCP_RESULTS
-GCP_RESULTS *getGCP_RESULTSFields(JNIEnv *env, jobject lpObject, GCP_RESULTS *lpStruct);
-void setGCP_RESULTSFields(JNIEnv *env, jobject lpObject, GCP_RESULTS *lpStruct);
-#else
-#define getGCP_RESULTSFields(a,b,c) NULL
-#define setGCP_RESULTSFields(a,b,c)
-#endif /* NO_GCP_RESULTS */
-
-#ifndef NO_GRADIENT_RECT
-GRADIENT_RECT *getGRADIENT_RECTFields(JNIEnv *env, jobject lpObject, GRADIENT_RECT *lpStruct);
-void setGRADIENT_RECTFields(JNIEnv *env, jobject lpObject, GRADIENT_RECT *lpStruct);
-#else
-#define getGRADIENT_RECTFields(a,b,c) NULL
-#define setGRADIENT_RECTFields(a,b,c)
-#endif /* NO_GRADIENT_RECT */
-
-#ifndef NO_HDITEM
-HDITEM *getHDITEMFields(JNIEnv *env, jobject lpObject, HDITEM *lpStruct);
-void setHDITEMFields(JNIEnv *env, jobject lpObject, HDITEM *lpStruct);
-#else
-#define getHDITEMFields(a,b,c) NULL
-#define setHDITEMFields(a,b,c)
-#endif /* NO_HDITEM */
-
-#ifndef NO_HELPINFO
-HELPINFO *getHELPINFOFields(JNIEnv *env, jobject lpObject, HELPINFO *lpStruct);
-void setHELPINFOFields(JNIEnv *env, jobject lpObject, HELPINFO *lpStruct);
-#else
-#define getHELPINFOFields(a,b,c) NULL
-#define setHELPINFOFields(a,b,c)
-#endif /* NO_HELPINFO */
-
-#ifndef NO_ICONINFO
-ICONINFO *getICONINFOFields(JNIEnv *env, jobject lpObject, ICONINFO *lpStruct);
-void setICONINFOFields(JNIEnv *env, jobject lpObject, ICONINFO *lpStruct);
-#else
-#define getICONINFOFields(a,b,c) NULL
-#define setICONINFOFields(a,b,c)
-#endif /* NO_ICONINFO */
-
-#ifndef NO_INITCOMMONCONTROLSEX
-INITCOMMONCONTROLSEX *getINITCOMMONCONTROLSEXFields(JNIEnv *env, jobject lpObject, INITCOMMONCONTROLSEX *lpStruct);
-void setINITCOMMONCONTROLSEXFields(JNIEnv *env, jobject lpObject, INITCOMMONCONTROLSEX *lpStruct);
-#else
-#define getINITCOMMONCONTROLSEXFields(a,b,c) NULL
-#define setINITCOMMONCONTROLSEXFields(a,b,c)
-#endif /* NO_INITCOMMONCONTROLSEX */
-
-#ifndef NO_LOGBRUSH
-LOGBRUSH *getLOGBRUSHFields(JNIEnv *env, jobject lpObject, LOGBRUSH *lpStruct);
-void setLOGBRUSHFields(JNIEnv *env, jobject lpObject, LOGBRUSH *lpStruct);
-#else
-#define getLOGBRUSHFields(a,b,c) NULL
-#define setLOGBRUSHFields(a,b,c)
-#endif /* NO_LOGBRUSH */
-
-#ifdef NO_LOGFONT
-#define NO_LOGFONTA
-#define NO_LOGFONTW
-#endif /* NO_LOGFONT */
-
-#ifndef NO_LOGFONTA
-LOGFONTA *getLOGFONTAFields(JNIEnv *env, jobject lpObject, LOGFONTA *lpStruct);
-void setLOGFONTAFields(JNIEnv *env, jobject lpObject, LOGFONTA *lpStruct);
-#else
-#define getLOGFONTAFields(a,b,c) NULL
-#define setLOGFONTAFields(a,b,c)
-#endif /* NO_LOGFONTA */
-
-#ifndef NO_LOGFONTW
-LOGFONTW *getLOGFONTWFields(JNIEnv *env, jobject lpObject, LOGFONTW *lpStruct);
-void setLOGFONTWFields(JNIEnv *env, jobject lpObject, LOGFONTW *lpStruct);
-#else
-#define getLOGFONTWFields(a,b,c) NULL
-#define setLOGFONTWFields(a,b,c)
-#endif /* NO_LOGFONTW */
-
-#ifndef NO_LOGPEN
-LOGPEN *getLOGPENFields(JNIEnv *env, jobject lpObject, LOGPEN *lpStruct);
-void setLOGPENFields(JNIEnv *env, jobject lpObject, LOGPEN *lpStruct);
-#else
-#define getLOGPENFields(a,b,c) NULL
-#define setLOGPENFields(a,b,c)
-#endif /* NO_LOGPEN */
-
-#ifndef NO_LVCOLUMN
-LVCOLUMN *getLVCOLUMNFields(JNIEnv *env, jobject lpObject, LVCOLUMN *lpStruct);
-void setLVCOLUMNFields(JNIEnv *env, jobject lpObject, LVCOLUMN *lpStruct);
-#else
-#define getLVCOLUMNFields(a,b,c) NULL
-#define setLVCOLUMNFields(a,b,c)
-#endif /* NO_LVCOLUMN */
-
-#ifndef NO_LVHITTESTINFO
-LVHITTESTINFO *getLVHITTESTINFOFields(JNIEnv *env, jobject lpObject, LVHITTESTINFO *lpStruct);
-void setLVHITTESTINFOFields(JNIEnv *env, jobject lpObject, LVHITTESTINFO *lpStruct);
-#else
-#define getLVHITTESTINFOFields(a,b,c) NULL
-#define setLVHITTESTINFOFields(a,b,c)
-#endif /* NO_LVHITTESTINFO */
-
-#ifndef NO_LVITEM
-LVITEM *getLVITEMFields(JNIEnv *env, jobject lpObject, LVITEM *lpStruct);
-void setLVITEMFields(JNIEnv *env, jobject lpObject, LVITEM *lpStruct);
-#else
-#define getLVITEMFields(a,b,c) NULL
-#define setLVITEMFields(a,b,c)
-#endif /* NO_LVITEM */
-
-#ifndef NO_MEASUREITEMSTRUCT
-MEASUREITEMSTRUCT *getMEASUREITEMSTRUCTFields(JNIEnv *env, jobject lpObject, MEASUREITEMSTRUCT *lpStruct);
-void setMEASUREITEMSTRUCTFields(JNIEnv *env, jobject lpObject, MEASUREITEMSTRUCT *lpStruct);
-#else
-#define getMEASUREITEMSTRUCTFields(a,b,c) NULL
-#define setMEASUREITEMSTRUCTFields(a,b,c)
-#endif /* NO_MEASUREITEMSTRUCT */
-
-#ifndef NO_MENUINFO
-MENUINFO *getMENUINFOFields(JNIEnv *env, jobject lpObject, MENUINFO *lpStruct);
-void setMENUINFOFields(JNIEnv *env, jobject lpObject, MENUINFO *lpStruct);
-#else
-#define getMENUINFOFields(a,b,c) NULL
-#define setMENUINFOFields(a,b,c)
-#endif /* NO_MENUINFO */
-
-#ifndef NO_MENUITEMINFO
-MENUITEMINFO *getMENUITEMINFOFields(JNIEnv *env, jobject lpObject, MENUITEMINFO *lpStruct);
-void setMENUITEMINFOFields(JNIEnv *env, jobject lpObject, MENUITEMINFO *lpStruct);
-#else
-#define getMENUITEMINFOFields(a,b,c) NULL
-#define setMENUITEMINFOFields(a,b,c)
-#endif /* NO_MENUITEMINFO */
-
-#ifndef NO_MSG
-MSG *getMSGFields(JNIEnv *env, jobject lpObject, MSG *lpStruct);
-void setMSGFields(JNIEnv *env, jobject lpObject, MSG *lpStruct);
-#else
-#define getMSGFields(a,b,c) NULL
-#define setMSGFields(a,b,c)
-#endif /* NO_MSG */
-
-#ifndef NO_NMCUSTOMDRAW
-NMCUSTOMDRAW *getNMCUSTOMDRAWFields(JNIEnv *env, jobject lpObject, NMCUSTOMDRAW *lpStruct);
-void setNMCUSTOMDRAWFields(JNIEnv *env, jobject lpObject, NMCUSTOMDRAW *lpStruct);
-#else
-#define getNMCUSTOMDRAWFields(a,b,c) NULL
-#define setNMCUSTOMDRAWFields(a,b,c)
-#endif /* NO_NMCUSTOMDRAW */
-
-#ifndef NO_NMHDR
-NMHDR *getNMHDRFields(JNIEnv *env, jobject lpObject, NMHDR *lpStruct);
-void setNMHDRFields(JNIEnv *env, jobject lpObject, NMHDR *lpStruct);
-#else
-#define getNMHDRFields(a,b,c) NULL
-#define setNMHDRFields(a,b,c)
-#endif /* NO_NMHDR */
-
-#ifndef NO_NMHEADER
-NMHEADER *getNMHEADERFields(JNIEnv *env, jobject lpObject, NMHEADER *lpStruct);
-void setNMHEADERFields(JNIEnv *env, jobject lpObject, NMHEADER *lpStruct);
-#else
-#define getNMHEADERFields(a,b,c) NULL
-#define setNMHEADERFields(a,b,c)
-#endif /* NO_NMHEADER */
-
-#ifndef NO_NMLISTVIEW
-NMLISTVIEW *getNMLISTVIEWFields(JNIEnv *env, jobject lpObject, NMLISTVIEW *lpStruct);
-void setNMLISTVIEWFields(JNIEnv *env, jobject lpObject, NMLISTVIEW *lpStruct);
-#else
-#define getNMLISTVIEWFields(a,b,c) NULL
-#define setNMLISTVIEWFields(a,b,c)
-#endif /* NO_NMLISTVIEW */
-
-#ifndef NO_NMLVCUSTOMDRAW
-NMLVCUSTOMDRAW *getNMLVCUSTOMDRAWFields(JNIEnv *env, jobject lpObject, NMLVCUSTOMDRAW *lpStruct);
-void setNMLVCUSTOMDRAWFields(JNIEnv *env, jobject lpObject, NMLVCUSTOMDRAW *lpStruct);
-#else
-#define getNMLVCUSTOMDRAWFields(a,b,c) NULL
-#define setNMLVCUSTOMDRAWFields(a,b,c)
-#endif /* NO_NMLVCUSTOMDRAW */
-
-#ifndef NO_NMREBARCHEVRON
-NMREBARCHEVRON *getNMREBARCHEVRONFields(JNIEnv *env, jobject lpObject, NMREBARCHEVRON *lpStruct);
-void setNMREBARCHEVRONFields(JNIEnv *env, jobject lpObject, NMREBARCHEVRON *lpStruct);
-#else
-#define getNMREBARCHEVRONFields(a,b,c) NULL
-#define setNMREBARCHEVRONFields(a,b,c)
-#endif /* NO_NMREBARCHEVRON */
-
-#ifndef NO_NMTOOLBAR
-NMTOOLBAR *getNMTOOLBARFields(JNIEnv *env, jobject lpObject, NMTOOLBAR *lpStruct);
-void setNMTOOLBARFields(JNIEnv *env, jobject lpObject, NMTOOLBAR *lpStruct);
-#else
-#define getNMTOOLBARFields(a,b,c) NULL
-#define setNMTOOLBARFields(a,b,c)
-#endif /* NO_NMTOOLBAR */
-
-#ifdef NO_NMTTDISPINFO
-#define NO_NMTTDISPINFOA
-#define NO_NMTTDISPINFOW
-#endif /* NO_NMTTDISPINFO */
-
-#ifndef NO_NMTTDISPINFOA
-NMTTDISPINFOA *getNMTTDISPINFOAFields(JNIEnv *env, jobject lpObject, NMTTDISPINFOA *lpStruct);
-void setNMTTDISPINFOAFields(JNIEnv *env, jobject lpObject, NMTTDISPINFOA *lpStruct);
-#else
-#define getNMTTDISPINFOAFields(a,b,c) NULL
-#define setNMTTDISPINFOAFields(a,b,c)
-#endif /* NO_NMTTDISPINFOA */
-
-#ifndef NO_NMTTDISPINFOW
-NMTTDISPINFOW *getNMTTDISPINFOWFields(JNIEnv *env, jobject lpObject, NMTTDISPINFOW *lpStruct);
-void setNMTTDISPINFOWFields(JNIEnv *env, jobject lpObject, NMTTDISPINFOW *lpStruct);
-#else
-#define getNMTTDISPINFOWFields(a,b,c) NULL
-#define setNMTTDISPINFOWFields(a,b,c)
-#endif /* NO_NMTTDISPINFOW */
-
-#ifndef NO_NMTVCUSTOMDRAW
-NMTVCUSTOMDRAW *getNMTVCUSTOMDRAWFields(JNIEnv *env, jobject lpObject, NMTVCUSTOMDRAW *lpStruct);
-void setNMTVCUSTOMDRAWFields(JNIEnv *env, jobject lpObject, NMTVCUSTOMDRAW *lpStruct);
-#else
-#define getNMTVCUSTOMDRAWFields(a,b,c) NULL
-#define setNMTVCUSTOMDRAWFields(a,b,c)
-#endif /* NO_NMTVCUSTOMDRAW */
-
-#ifdef NO_NONCLIENTMETRICS
-#define NO_NONCLIENTMETRICSA
-#define NO_NONCLIENTMETRICSW
-#endif /* NO_NONCLIENTMETRICS */
-
-#ifndef NO_NONCLIENTMETRICSA
-NONCLIENTMETRICSA *getNONCLIENTMETRICSAFields(JNIEnv *env, jobject lpObject, NONCLIENTMETRICSA *lpStruct);
-void setNONCLIENTMETRICSAFields(JNIEnv *env, jobject lpObject, NONCLIENTMETRICSA *lpStruct);
-#else
-#define getNONCLIENTMETRICSAFields(a,b,c) NULL
-#define setNONCLIENTMETRICSAFields(a,b,c)
-#endif /* NO_NONCLIENTMETRICSA */
-
-#ifndef NO_NONCLIENTMETRICSW
-NONCLIENTMETRICSW *getNONCLIENTMETRICSWFields(JNIEnv *env, jobject lpObject, NONCLIENTMETRICSW *lpStruct);
-void setNONCLIENTMETRICSWFields(JNIEnv *env, jobject lpObject, NONCLIENTMETRICSW *lpStruct);
-#else
-#define getNONCLIENTMETRICSWFields(a,b,c) NULL
-#define setNONCLIENTMETRICSWFields(a,b,c)
-#endif /* NO_NONCLIENTMETRICSW */
-
-#ifndef NO_OPENFILENAME
-OPENFILENAME *getOPENFILENAMEFields(JNIEnv *env, jobject lpObject, OPENFILENAME *lpStruct);
-void setOPENFILENAMEFields(JNIEnv *env, jobject lpObject, OPENFILENAME *lpStruct);
-#else
-#define getOPENFILENAMEFields(a,b,c) NULL
-#define setOPENFILENAMEFields(a,b,c)
-#endif /* NO_OPENFILENAME */
-
-#ifdef NO_OSVERSIONINFO
-#define NO_OSVERSIONINFOA
-#define NO_OSVERSIONINFOW
-#endif /* NO_OSVERSIONINFO */
-
-#ifndef NO_OSVERSIONINFOA
-OSVERSIONINFOA *getOSVERSIONINFOAFields(JNIEnv *env, jobject lpObject, OSVERSIONINFOA *lpStruct);
-void setOSVERSIONINFOAFields(JNIEnv *env, jobject lpObject, OSVERSIONINFOA *lpStruct);
-#else
-#define getOSVERSIONINFOAFields(a,b,c) NULL
-#define setOSVERSIONINFOAFields(a,b,c)
-#endif /* NO_OSVERSIONINFOA */
-
-#ifndef NO_OSVERSIONINFOW
-OSVERSIONINFOW *getOSVERSIONINFOWFields(JNIEnv *env, jobject lpObject, OSVERSIONINFOW *lpStruct);
-void setOSVERSIONINFOWFields(JNIEnv *env, jobject lpObject, OSVERSIONINFOW *lpStruct);
-#else
-#define getOSVERSIONINFOWFields(a,b,c) NULL
-#define setOSVERSIONINFOWFields(a,b,c)
-#endif /* NO_OSVERSIONINFOW */
-
-#ifndef NO_PAINTSTRUCT
-PAINTSTRUCT *getPAINTSTRUCTFields(JNIEnv *env, jobject lpObject, PAINTSTRUCT *lpStruct);
-void setPAINTSTRUCTFields(JNIEnv *env, jobject lpObject, PAINTSTRUCT *lpStruct);
-#else
-#define getPAINTSTRUCTFields(a,b,c) NULL
-#define setPAINTSTRUCTFields(a,b,c)
-#endif /* NO_PAINTSTRUCT */
-
-#ifndef NO_POINT
-POINT *getPOINTFields(JNIEnv *env, jobject lpObject, POINT *lpStruct);
-void setPOINTFields(JNIEnv *env, jobject lpObject, POINT *lpStruct);
-#else
-#define getPOINTFields(a,b,c) NULL
-#define setPOINTFields(a,b,c)
-#endif /* NO_POINT */
-
-#ifndef NO_PRINTDLG
-PRINTDLG *getPRINTDLGFields(JNIEnv *env, jobject lpObject, PRINTDLG *lpStruct);
-void setPRINTDLGFields(JNIEnv *env, jobject lpObject, PRINTDLG *lpStruct);
-#else
-#define getPRINTDLGFields(a,b,c) NULL
-#define setPRINTDLGFields(a,b,c)
-#endif /* NO_PRINTDLG */
-
-#ifndef NO_REBARBANDINFO
-REBARBANDINFO *getREBARBANDINFOFields(JNIEnv *env, jobject lpObject, REBARBANDINFO *lpStruct);
-void setREBARBANDINFOFields(JNIEnv *env, jobject lpObject, REBARBANDINFO *lpStruct);
-#else
-#define getREBARBANDINFOFields(a,b,c) NULL
-#define setREBARBANDINFOFields(a,b,c)
-#endif /* NO_REBARBANDINFO */
-
-#ifndef NO_RECT
-RECT *getRECTFields(JNIEnv *env, jobject lpObject, RECT *lpStruct);
-void setRECTFields(JNIEnv *env, jobject lpObject, RECT *lpStruct);
-#else
-#define getRECTFields(a,b,c) NULL
-#define setRECTFields(a,b,c)
-#endif /* NO_RECT */
-
-#ifndef NO_SCROLLINFO
-SCROLLINFO *getSCROLLINFOFields(JNIEnv *env, jobject lpObject, SCROLLINFO *lpStruct);
-void setSCROLLINFOFields(JNIEnv *env, jobject lpObject, SCROLLINFO *lpStruct);
-#else
-#define getSCROLLINFOFields(a,b,c) NULL
-#define setSCROLLINFOFields(a,b,c)
-#endif /* NO_SCROLLINFO */
-
-#ifndef NO_SHACTIVATEINFO
-SHACTIVATEINFO *getSHACTIVATEINFOFields(JNIEnv *env, jobject lpObject, SHACTIVATEINFO *lpStruct);
-void setSHACTIVATEINFOFields(JNIEnv *env, jobject lpObject, SHACTIVATEINFO *lpStruct);
-#else
-#define getSHACTIVATEINFOFields(a,b,c) NULL
-#define setSHACTIVATEINFOFields(a,b,c)
-#endif /* NO_SHACTIVATEINFO */
-
-#ifndef NO_SHELLEXECUTEINFO
-SHELLEXECUTEINFO *getSHELLEXECUTEINFOFields(JNIEnv *env, jobject lpObject, SHELLEXECUTEINFO *lpStruct);
-void setSHELLEXECUTEINFOFields(JNIEnv *env, jobject lpObject, SHELLEXECUTEINFO *lpStruct);
-#else
-#define getSHELLEXECUTEINFOFields(a,b,c) NULL
-#define setSHELLEXECUTEINFOFields(a,b,c)
-#endif /* NO_SHELLEXECUTEINFO */
-
-#ifndef NO_SHMENUBARINFO
-SHMENUBARINFO *getSHMENUBARINFOFields(JNIEnv *env, jobject lpObject, SHMENUBARINFO *lpStruct);
-void setSHMENUBARINFOFields(JNIEnv *env, jobject lpObject, SHMENUBARINFO *lpStruct);
-#else
-#define getSHMENUBARINFOFields(a,b,c) NULL
-#define setSHMENUBARINFOFields(a,b,c)
-#endif /* NO_SHMENUBARINFO */
-
-#ifndef NO_SHRGINFO
-SHRGINFO *getSHRGINFOFields(JNIEnv *env, jobject lpObject, SHRGINFO *lpStruct);
-void setSHRGINFOFields(JNIEnv *env, jobject lpObject, SHRGINFO *lpStruct);
-#else
-#define getSHRGINFOFields(a,b,c) NULL
-#define setSHRGINFOFields(a,b,c)
-#endif /* NO_SHRGINFO */
-
-#ifndef NO_SIPINFO
-SIPINFO *getSIPINFOFields(JNIEnv *env, jobject lpObject, SIPINFO *lpStruct);
-void setSIPINFOFields(JNIEnv *env, jobject lpObject, SIPINFO *lpStruct);
-#else
-#define getSIPINFOFields(a,b,c) NULL
-#define setSIPINFOFields(a,b,c)
-#endif /* NO_SIPINFO */
-
-#ifndef NO_SIZE
-SIZE *getSIZEFields(JNIEnv *env, jobject lpObject, SIZE *lpStruct);
-void setSIZEFields(JNIEnv *env, jobject lpObject, SIZE *lpStruct);
-#else
-#define getSIZEFields(a,b,c) NULL
-#define setSIZEFields(a,b,c)
-#endif /* NO_SIZE */
-
-#ifndef NO_TBBUTTON
-TBBUTTON *getTBBUTTONFields(JNIEnv *env, jobject lpObject, TBBUTTON *lpStruct);
-void setTBBUTTONFields(JNIEnv *env, jobject lpObject, TBBUTTON *lpStruct);
-#else
-#define getTBBUTTONFields(a,b,c) NULL
-#define setTBBUTTONFields(a,b,c)
-#endif /* NO_TBBUTTON */
-
-#ifndef NO_TBBUTTONINFO
-TBBUTTONINFO *getTBBUTTONINFOFields(JNIEnv *env, jobject lpObject, TBBUTTONINFO *lpStruct);
-void setTBBUTTONINFOFields(JNIEnv *env, jobject lpObject, TBBUTTONINFO *lpStruct);
-#else
-#define getTBBUTTONINFOFields(a,b,c) NULL
-#define setTBBUTTONINFOFields(a,b,c)
-#endif /* NO_TBBUTTONINFO */
-
-#ifndef NO_TCITEM
-TCITEM *getTCITEMFields(JNIEnv *env, jobject lpObject, TCITEM *lpStruct);
-void setTCITEMFields(JNIEnv *env, jobject lpObject, TCITEM *lpStruct);
-#else
-#define getTCITEMFields(a,b,c) NULL
-#define setTCITEMFields(a,b,c)
-#endif /* NO_TCITEM */
-
-#ifdef NO_TEXTMETRIC
-#define NO_TEXTMETRICA
-#define NO_TEXTMETRICW
-#endif /* NO_TEXTMETRIC */
-
-#ifndef NO_TEXTMETRICA
-TEXTMETRICA *getTEXTMETRICAFields(JNIEnv *env, jobject lpObject, TEXTMETRICA *lpStruct);
-void setTEXTMETRICAFields(JNIEnv *env, jobject lpObject, TEXTMETRICA *lpStruct);
-#else
-#define getTEXTMETRICAFields(a,b,c) NULL
-#define setTEXTMETRICAFields(a,b,c)
-#endif /* NO_TEXTMETRICA */
-
-#ifndef NO_TEXTMETRICW
-TEXTMETRICW *getTEXTMETRICWFields(JNIEnv *env, jobject lpObject, TEXTMETRICW *lpStruct);
-void setTEXTMETRICWFields(JNIEnv *env, jobject lpObject, TEXTMETRICW *lpStruct);
-#else
-#define getTEXTMETRICWFields(a,b,c) NULL
-#define setTEXTMETRICWFields(a,b,c)
-#endif /* NO_TEXTMETRICW */
-
-#ifndef NO_TOOLINFO
-TOOLINFO *getTOOLINFOFields(JNIEnv *env, jobject lpObject, TOOLINFO *lpStruct);
-void setTOOLINFOFields(JNIEnv *env, jobject lpObject, TOOLINFO *lpStruct);
-#else
-#define getTOOLINFOFields(a,b,c) NULL
-#define setTOOLINFOFields(a,b,c)
-#endif /* NO_TOOLINFO */
-
-#ifndef NO_TRACKMOUSEEVENT
-TRACKMOUSEEVENT *getTRACKMOUSEEVENTFields(JNIEnv *env, jobject lpObject, TRACKMOUSEEVENT *lpStruct);
-void setTRACKMOUSEEVENTFields(JNIEnv *env, jobject lpObject, TRACKMOUSEEVENT *lpStruct);
-#else
-#define getTRACKMOUSEEVENTFields(a,b,c) NULL
-#define setTRACKMOUSEEVENTFields(a,b,c)
-#endif /* NO_TRACKMOUSEEVENT */
-
-#ifndef NO_TRIVERTEX
-TRIVERTEX *getTRIVERTEXFields(JNIEnv *env, jobject lpObject, TRIVERTEX *lpStruct);
-void setTRIVERTEXFields(JNIEnv *env, jobject lpObject, TRIVERTEX *lpStruct);
-#else
-#define getTRIVERTEXFields(a,b,c) NULL
-#define setTRIVERTEXFields(a,b,c)
-#endif /* NO_TRIVERTEX */
-
-#ifndef NO_TVHITTESTINFO
-TVHITTESTINFO *getTVHITTESTINFOFields(JNIEnv *env, jobject lpObject, TVHITTESTINFO *lpStruct);
-void setTVHITTESTINFOFields(JNIEnv *env, jobject lpObject, TVHITTESTINFO *lpStruct);
-#else
-#define getTVHITTESTINFOFields(a,b,c) NULL
-#define setTVHITTESTINFOFields(a,b,c)
-#endif /* NO_TVHITTESTINFO */
-
-#ifndef NO_TVINSERTSTRUCT
-TVINSERTSTRUCT *getTVINSERTSTRUCTFields(JNIEnv *env, jobject lpObject, TVINSERTSTRUCT *lpStruct);
-void setTVINSERTSTRUCTFields(JNIEnv *env, jobject lpObject, TVINSERTSTRUCT *lpStruct);
-#else
-#define getTVINSERTSTRUCTFields(a,b,c) NULL
-#define setTVINSERTSTRUCTFields(a,b,c)
-#endif /* NO_TVINSERTSTRUCT */
-
-#ifndef NO_TVITEM
-TVITEM *getTVITEMFields(JNIEnv *env, jobject lpObject, TVITEM *lpStruct);
-void setTVITEMFields(JNIEnv *env, jobject lpObject, TVITEM *lpStruct);
-#else
-#define getTVITEMFields(a,b,c) NULL
-#define setTVITEMFields(a,b,c)
-#endif /* NO_TVITEM */
-
-#ifndef NO_WINDOWPLACEMENT
-WINDOWPLACEMENT *getWINDOWPLACEMENTFields(JNIEnv *env, jobject lpObject, WINDOWPLACEMENT *lpStruct);
-void setWINDOWPLACEMENTFields(JNIEnv *env, jobject lpObject, WINDOWPLACEMENT *lpStruct);
-#else
-#define getWINDOWPLACEMENTFields(a,b,c) NULL
-#define setWINDOWPLACEMENTFields(a,b,c)
-#endif /* NO_WINDOWPLACEMENT */
-
-#ifndef NO_WINDOWPOS
-WINDOWPOS *getWINDOWPOSFields(JNIEnv *env, jobject lpObject, WINDOWPOS *lpStruct);
-void setWINDOWPOSFields(JNIEnv *env, jobject lpObject, WINDOWPOS *lpStruct);
-#else
-#define getWINDOWPOSFields(a,b,c) NULL
-#define setWINDOWPOSFields(a,b,c)
-#endif /* NO_WINDOWPOS */
-
-#ifndef NO_WNDCLASS
-WNDCLASS *getWNDCLASSFields(JNIEnv *env, jobject lpObject, WNDCLASS *lpStruct);
-void setWNDCLASSFields(JNIEnv *env, jobject lpObject, WNDCLASS *lpStruct);
-#else
-#define getWNDCLASSFields(a,b,c) NULL
-#define setWNDCLASSFields(a,b,c)
-#endif /* NO_WNDCLASS */
-
-/************************ OLE ***************************/
-
-/* 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);
-
-#ifndef NO_CAUUID
-CAUUID *getCAUUIDFields(JNIEnv *env, jobject lpObject, CAUUID *lpStruct);
-void setCAUUIDFields(JNIEnv *env, jobject lpObject, CAUUID *lpStruct);
-#endif /* NO_CAUUID */
-
-#ifndef NO_CONTROLINFO
-CONTROLINFO *getCONTROLINFOFields(JNIEnv *env, jobject lpObject, CONTROLINFO *lpStruct);
-void setCONTROLINFOFields(JNIEnv *env, jobject lpObject, CONTROLINFO *lpStruct);
-#endif /* NO_CONTROLINFO */
-
-#ifndef NO_COSERVERINFO
-COSERVERINFO *getCOSERVERINFOFields(JNIEnv *env, jobject lpObject, COSERVERINFO *lpStruct);
-void setCOSERVERINFOFields(JNIEnv *env, jobject lpObject, COSERVERINFO *lpStruct);
-#endif /* NO_COSERVERINFO */
-
-#ifndef NO_DISPPARAMS
-DISPPARAMS *getDISPPARAMSFields(JNIEnv *env, jobject lpObject, DISPPARAMS *lpStruct);
-void setDISPPARAMSFields(JNIEnv *env, jobject lpObject, DISPPARAMS *lpStruct);
-#endif /* NO_DISPPARAMS */
-
-#ifndef NO_DVTARGETDEVICE
-DVTARGETDEVICE *getDVTARGETDEVICEFields(JNIEnv *env, jobject lpObject, DVTARGETDEVICE *lpStruct);
-void setDVTARGETDEVICEFields(JNIEnv *env, jobject lpObject, DVTARGETDEVICE *lpStruct);
-#endif /* NO_DVTARGETDEVICE */
-
-#ifndef NO_EXCEPINFO
-EXCEPINFO *getEXCEPINFOFields(JNIEnv *env, jobject lpObject, EXCEPINFO *lpStruct);
-void setEXCEPINFOFields(JNIEnv *env, jobject lpObject, EXCEPINFO *lpStruct);
-#endif /* NO_EXCEPINFO */
-
-#ifndef NO_FORMATETC
-FORMATETC *getFORMATETCFields(JNIEnv *env, jobject lpObject, FORMATETC *lpStruct);
-void setFORMATETCFields(JNIEnv *env, jobject lpObject, FORMATETC *lpStruct);
-#endif /* NO_FORMATETC */
-
-#ifndef NO_FUNCDESC1
-FUNCDESC *getFUNCDESC1Fields(JNIEnv *env, jobject lpObject, FUNCDESC *lpStruct);
-void setFUNCDESC1Fields(JNIEnv *env, jobject lpObject, FUNCDESC *lpStruct);
-#endif /* NO_FUNCDESC1 */
-
-#ifndef NO_FUNCDESC2
-FUNCDESC *getFUNCDESC2Fields(JNIEnv *env, jobject lpObject, FUNCDESC *lpStruct);
-void setFUNCDESC2Fields(JNIEnv *env, jobject lpObject, FUNCDESC *lpStruct);
-#endif /* NO_FUNCDESC2 */
-
-#ifndef NO_GUID
-GUID *getGUIDFields(JNIEnv *env, jobject lpObject, GUID *lpStruct);
-void setGUIDFields(JNIEnv *env, jobject lpObject, GUID *lpStruct);
-#endif /* NO_GUID */
-
-#ifndef NO_LICINFO
-LICINFO *getLICINFOFields(JNIEnv *env, jobject lpObject, LICINFO *lpStruct);
-void setLICINFOFields(JNIEnv *env, jobject lpObject, LICINFO *lpStruct);
-#endif /* NO_LICINFO */
-
-#ifndef NO_OLECMD
-OLECMD *getOLECMDFields(JNIEnv *env, jobject lpObject, OLECMD *lpStruct);
-void setOLECMDFields(JNIEnv *env, jobject lpObject, OLECMD *lpStruct);
-#endif /* NO_OLECMD */
-
-#ifndef NO_OLECMDTEXT
-OLECMDTEXT *getOLECMDTEXTFields(JNIEnv *env, jobject lpObject, OLECMDTEXT *lpStruct);
-void setOLECMDTEXTFields(JNIEnv *env, jobject lpObject, OLECMDTEXT *lpStruct);
-#endif /* NO_OLECMDTEXT */
-
-#ifndef NO_OLEINPLACEFRAMEINFO
-OLEINPLACEFRAMEINFO *getOLEINPLACEFRAMEINFOFields(JNIEnv *env, jobject lpObject, OLEINPLACEFRAMEINFO *lpStruct);
-void setOLEINPLACEFRAMEINFOFields(JNIEnv *env, jobject lpObject, OLEINPLACEFRAMEINFO *lpStruct);
-#endif /* NO_OLEINPLACEFRAMEINFO */
-
-#ifndef NO_STATSTG
-STATSTG *getSTATSTGFields(JNIEnv *env, jobject lpObject, STATSTG *lpStruct);
-void setSTATSTGFields(JNIEnv *env, jobject lpObject, STATSTG *lpStruct);
-#endif /* NO_STATSTG */
-
-#ifndef NO_STGMEDIUM
-STGMEDIUM *getSTGMEDIUMFields(JNIEnv *env, jobject lpObject, STGMEDIUM *lpStruct);
-void setSTGMEDIUMFields(JNIEnv *env, jobject lpObject, STGMEDIUM *lpStruct);
-#endif /* NO_STGMEDIUM */
-
-#ifndef NO_TYPEATTR
-TYPEATTR *getTYPEATTRFields(JNIEnv *env, jobject lpObject, TYPEATTR *lpStruct);
-void setTYPEATTRFields(JNIEnv *env, jobject lpObject, TYPEATTR *lpStruct);
-#endif /* NO_TYPEATTR */
-
-#ifndef NO_VARDESC1
-VARDESC *getVARDESC1Fields(JNIEnv *env, jobject lpObject, VARDESC *lpStruct);
-void setVARDESC1Fields(JNIEnv *env, jobject lpObject, VARDESC *lpStruct);
-#endif /* NO_VARDESC1 */
-
-#ifndef NO_VARDESC2
-VARDESC *getVARDESC2Fields(JNIEnv *env, jobject lpObject, VARDESC *lpStruct);
-void setVARDESC2Fields(JNIEnv *env, jobject lpObject, VARDESC *lpStruct);
-#endif /* NO_VARDESC2 */
-
-/**************************** END OLE ****************************/
-
-#endif // INC_structs_H
+/*
+ * Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
+ * This file is made available under the terms of the Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+/**
+ * JNI SWT object field getters and setters declarations for Windows structs.
+ */
+
+#ifndef INC_structs_H
+#define INC_structs_H
+
+#define WINVER 0x0500
+#define _WIN32_IE 0x0500
+
+#if _MSC_VER > 1000
+#pragma once
+#endif // _MSC_VER > 1000
+
+#define VC_EXTRALEAN
+
+#include <windows.h>
+#include <winuser.h>
+#include <commctrl.h>
+#include <commdlg.h>
+#include <oaidl.h>
+#include <shlobj.h>
+#include <ole2.h>
+#include <olectl.h>
+#include <objbase.h>
+#include <shlwapi.h>
+#include <shellapi.h>
+
+#ifndef _WIN32_WCE
+#include <initguid.h>
+#include <oleacc.h>
+#endif // _WIN32_WCE
+
+#if defined(WIN32_PLATFORM_PSPC) || defined(WIN32_PLATFORM_WFSP)
+#include <aygshell.h>
+#endif // WIN32_PLATFORM_PSPC, WIN32_PLATFORM_WFSP
+
+#ifdef WIN32_PLATFORM_WFSP
+#include <tpcshell.h>
+#endif /* WIN32_PLATFORM_WFSP */
+
+/* Optional custom definitions to exclude some types */
+#include "defines.h"
+
+#ifdef _WIN32_WCE
+#define NO_BROWSEINFO
+#define NO_CHOOSEFONT
+#define NO_DOCINFO
+#define NO_GCP_RESULTS
+#define NO_GRADIENT_RECT
+#define NO_HELPINFO
+#define NO_MENUINFO
+#define NO_NMREBARCHEVRON
+#define NO_NMTTDISPINFO
+#define NO_NONCLIENTMETRICS
+#define NO_PRINTDLG
+#define NO_TOOLINFO
+#define NO_TRACKMOUSEEVENT
+#define NO_TRIVERTEX
+#define NO_WINDOWPLACEMENT
+#define NO_DROPFILES
+#define NO_OLECMD
+#define NO_OLECMDTEXT
+
+/* OLE */
+#define NO_CAUUID
+#define NO_CONTROLINFO
+#define NO_COSERVERINFO
+#define NO_DISPPARAMS
+#define NO_DVTARGETDEVICE
+#define NO_EXCEPINFO
+#define NO_FORMATETC
+#define NO_FUNCDESC1
+#define NO_FUNCDESC2
+#define NO_GUID
+#define NO_LICINFO
+#define NO_OLEINPLACEFRAMEINFO
+#define NO_STATSTG
+#define NO_STGMEDIUM
+#define NO_TYPEATTR
+#define NO_VARDESC1
+#define NO_VARDESC2
+#endif /* _WIN32_WCE */
+
+#if !defined(WIN32_PLATFORM_PSPC) && !defined(WIN32_PLATFORM_WFSP)
+#define NO_SHMENUBARINFO
+#endif /* WIN32_PLATFORM_PSPC, WIN32_PLATFORM_WFSP */
+
+#ifndef WIN32_PLATFORM_PSPC
+#define NO_SHACTIVATEINFO
+#define NO_SHRGINFO
+#define NO_SIPINFO
+#endif /* WIN32_PLATFORM_PSPC */
+
+/** Structs */
+#ifndef NO_ACCEL
+ACCEL *getACCELFields(JNIEnv *env, jobject lpObject, ACCEL *lpStruct);
+void setACCELFields(JNIEnv *env, jobject lpObject, ACCEL *lpStruct);
+#else
+#define getACCELFields(a,b,c) NULL
+#define setACCELFields(a,b,c)
+#endif /* NO_ACCEL */
+
+#ifndef NO_BITMAP
+BITMAP *getBITMAPFields(JNIEnv *env, jobject lpObject, BITMAP *lpStruct);
+void setBITMAPFields(JNIEnv *env, jobject lpObject, BITMAP *lpStruct);
+#else
+#define getBITMAPFields(a,b,c) NULL
+#define setBITMAPFields(a,b,c)
+#endif /* NO_BITMAP */
+
+#ifndef NO_BITMAPINFOHEADER
+BITMAPINFOHEADER *getBITMAPINFOHEADERFields(JNIEnv *env, jobject lpObject, BITMAPINFOHEADER *lpStruct);
+void setBITMAPINFOHEADERFields(JNIEnv *env, jobject lpObject, BITMAPINFOHEADER *lpStruct);
+#else
+#define getBITMAPINFOHEADERFields(a,b,c) NULL
+#define setBITMAPINFOHEADERFields(a,b,c)
+#endif /* NO_BITMAPINFOHEADER */
+
+#ifndef NO_BROWSEINFO
+BROWSEINFO *getBROWSEINFOFields(JNIEnv *env, jobject lpObject, BROWSEINFO *lpStruct);
+void setBROWSEINFOFields(JNIEnv *env, jobject lpObject, BROWSEINFO *lpStruct);
+#else
+#define getBROWSEINFOFields(a,b,c) NULL
+#define setBROWSEINFOFields(a,b,c)
+#endif /* NO_BROWSEINFO */
+
+#ifndef NO_CHOOSECOLOR
+CHOOSECOLOR *getCHOOSECOLORFields(JNIEnv *env, jobject lpObject, CHOOSECOLOR *lpStruct);
+void setCHOOSECOLORFields(JNIEnv *env, jobject lpObject, CHOOSECOLOR *lpStruct);
+#else
+#define getCHOOSECOLORFields(a,b,c) NULL
+#define setCHOOSECOLORFields(a,b,c)
+#endif /* NO_CHOOSECOLOR */
+
+#ifndef NO_CHOOSEFONT
+CHOOSEFONT *getCHOOSEFONTFields(JNIEnv *env, jobject lpObject, CHOOSEFONT *lpStruct);
+void setCHOOSEFONTFields(JNIEnv *env, jobject lpObject, CHOOSEFONT *lpStruct);
+#else
+#define getCHOOSEFONTFields(a,b,c) NULL
+#define setCHOOSEFONTFields(a,b,c)
+#endif /* NO_CHOOSEFONT */
+
+#ifndef NO_COMPOSITIONFORM
+COMPOSITIONFORM *getCOMPOSITIONFORMFields(JNIEnv *env, jobject lpObject, COMPOSITIONFORM *lpStruct);
+void setCOMPOSITIONFORMFields(JNIEnv *env, jobject lpObject, COMPOSITIONFORM *lpStruct);
+#else
+#define getCOMPOSITIONFORMFields(a,b,c) NULL
+#define setCOMPOSITIONFORMFields(a,b,c)
+#endif /* NO_COMPOSITIONFORM */
+
+#ifndef NO_CREATESTRUCT
+CREATESTRUCT *getCREATESTRUCTFields(JNIEnv *env, jobject lpObject, CREATESTRUCT *lpStruct);
+void setCREATESTRUCTFields(JNIEnv *env, jobject lpObject, CREATESTRUCT *lpStruct);
+#else
+#define getCREATESTRUCTFields(a,b,c) NULL
+#define setCREATESTRUCTFields(a,b,c)
+#endif /* NO_CREATESTRUCT */
+
+#ifndef NO_DIBSECTION
+DIBSECTION *getDIBSECTIONFields(JNIEnv *env, jobject lpObject, DIBSECTION *lpStruct);
+void setDIBSECTIONFields(JNIEnv *env, jobject lpObject, DIBSECTION *lpStruct);
+#else
+#define getDIBSECTIONFields(a,b,c) NULL
+#define setDIBSECTIONFields(a,b,c)
+#endif /* NO_DIBSECTION */
+
+#ifndef NO_DLLVERSIONINFO
+DLLVERSIONINFO *getDLLVERSIONINFOFields(JNIEnv *env, jobject lpObject, DLLVERSIONINFO *lpStruct);
+void setDLLVERSIONINFOFields(JNIEnv *env, jobject lpObject, DLLVERSIONINFO *lpStruct);
+#else
+#define getDLLVERSIONINFOFields(a,b,c) NULL
+#define setDLLVERSIONINFOFields(a,b,c)
+#endif /* NO_DLLVERSIONINFO */
+
+#ifndef NO_DOCINFO
+DOCINFO *getDOCINFOFields(JNIEnv *env, jobject lpObject, DOCINFO *lpStruct);
+void setDOCINFOFields(JNIEnv *env, jobject lpObject, DOCINFO *lpStruct);
+#else
+#define getDOCINFOFields(a,b,c) NULL
+#define setDOCINFOFields(a,b,c)
+#endif /* NO_DOCINFO */
+
+#ifndef NO_DRAWITEMSTRUCT
+DRAWITEMSTRUCT *getDRAWITEMSTRUCTFields(JNIEnv *env, jobject lpObject, DRAWITEMSTRUCT *lpStruct);
+void setDRAWITEMSTRUCTFields(JNIEnv *env, jobject lpObject, DRAWITEMSTRUCT *lpStruct);
+#else
+#define getDRAWITEMSTRUCTFields(a,b,c) NULL
+#define setDRAWITEMSTRUCTFields(a,b,c)
+#endif /* NO_DRAWITEMSTRUCT */
+
+#ifndef NO_DROPFILES
+DROPFILES *getDROPFILESFields(JNIEnv *env, jobject lpObject, DROPFILES *lpStruct);
+void setDROPFILESFields(JNIEnv *env, jobject lpObject, DROPFILES *lpStruct);
+#else
+#define getDROPFILESFields(a,b,c) NULL
+#define setDROPFILESFields(a,b,c)
+#endif /* NO_DROPFILES */
+
+#ifndef NO_FILETIME
+FILETIME *getFILETIMEFields(JNIEnv *env, jobject lpObject, FILETIME *lpStruct);
+void setFILETIMEFields(JNIEnv *env, jobject lpObject, FILETIME *lpStruct);
+#else
+#define getFILETIMEFields(a,b,c) NULL
+#define setFILETIMEFields(a,b,c)
+#endif /* NO_FILETIME */
+
+#ifndef NO_GCP_RESULTS
+GCP_RESULTS *getGCP_RESULTSFields(JNIEnv *env, jobject lpObject, GCP_RESULTS *lpStruct);
+void setGCP_RESULTSFields(JNIEnv *env, jobject lpObject, GCP_RESULTS *lpStruct);
+#else
+#define getGCP_RESULTSFields(a,b,c) NULL
+#define setGCP_RESULTSFields(a,b,c)
+#endif /* NO_GCP_RESULTS */
+
+#ifndef NO_GRADIENT_RECT
+GRADIENT_RECT *getGRADIENT_RECTFields(JNIEnv *env, jobject lpObject, GRADIENT_RECT *lpStruct);
+void setGRADIENT_RECTFields(JNIEnv *env, jobject lpObject, GRADIENT_RECT *lpStruct);
+#else
+#define getGRADIENT_RECTFields(a,b,c) NULL
+#define setGRADIENT_RECTFields(a,b,c)
+#endif /* NO_GRADIENT_RECT */
+
+#ifndef NO_HDITEM
+HDITEM *getHDITEMFields(JNIEnv *env, jobject lpObject, HDITEM *lpStruct);
+void setHDITEMFields(JNIEnv *env, jobject lpObject, HDITEM *lpStruct);
+#else
+#define getHDITEMFields(a,b,c) NULL
+#define setHDITEMFields(a,b,c)
+#endif /* NO_HDITEM */
+
+#ifndef NO_HELPINFO
+HELPINFO *getHELPINFOFields(JNIEnv *env, jobject lpObject, HELPINFO *lpStruct);
+void setHELPINFOFields(JNIEnv *env, jobject lpObject, HELPINFO *lpStruct);
+#else
+#define getHELPINFOFields(a,b,c) NULL
+#define setHELPINFOFields(a,b,c)
+#endif /* NO_HELPINFO */
+
+#ifndef NO_ICONINFO
+ICONINFO *getICONINFOFields(JNIEnv *env, jobject lpObject, ICONINFO *lpStruct);
+void setICONINFOFields(JNIEnv *env, jobject lpObject, ICONINFO *lpStruct);
+#else
+#define getICONINFOFields(a,b,c) NULL
+#define setICONINFOFields(a,b,c)
+#endif /* NO_ICONINFO */
+
+#ifndef NO_INITCOMMONCONTROLSEX
+INITCOMMONCONTROLSEX *getINITCOMMONCONTROLSEXFields(JNIEnv *env, jobject lpObject, INITCOMMONCONTROLSEX *lpStruct);
+void setINITCOMMONCONTROLSEXFields(JNIEnv *env, jobject lpObject, INITCOMMONCONTROLSEX *lpStruct);
+#else
+#define getINITCOMMONCONTROLSEXFields(a,b,c) NULL
+#define setINITCOMMONCONTROLSEXFields(a,b,c)
+#endif /* NO_INITCOMMONCONTROLSEX */
+
+#ifndef NO_LOGBRUSH
+LOGBRUSH *getLOGBRUSHFields(JNIEnv *env, jobject lpObject, LOGBRUSH *lpStruct);
+void setLOGBRUSHFields(JNIEnv *env, jobject lpObject, LOGBRUSH *lpStruct);
+#else
+#define getLOGBRUSHFields(a,b,c) NULL
+#define setLOGBRUSHFields(a,b,c)
+#endif /* NO_LOGBRUSH */
+
+#ifdef NO_LOGFONT
+#define NO_LOGFONTA
+#define NO_LOGFONTW
+#endif /* NO_LOGFONT */
+
+#ifndef NO_LOGFONTA
+LOGFONTA *getLOGFONTAFields(JNIEnv *env, jobject lpObject, LOGFONTA *lpStruct);
+void setLOGFONTAFields(JNIEnv *env, jobject lpObject, LOGFONTA *lpStruct);
+#else
+#define getLOGFONTAFields(a,b,c) NULL
+#define setLOGFONTAFields(a,b,c)
+#endif /* NO_LOGFONTA */
+
+#ifndef NO_LOGFONTW
+LOGFONTW *getLOGFONTWFields(JNIEnv *env, jobject lpObject, LOGFONTW *lpStruct);
+void setLOGFONTWFields(JNIEnv *env, jobject lpObject, LOGFONTW *lpStruct);
+#else
+#define getLOGFONTWFields(a,b,c) NULL
+#define setLOGFONTWFields(a,b,c)
+#endif /* NO_LOGFONTW */
+
+#ifndef NO_LOGPEN
+LOGPEN *getLOGPENFields(JNIEnv *env, jobject lpObject, LOGPEN *lpStruct);
+void setLOGPENFields(JNIEnv *env, jobject lpObject, LOGPEN *lpStruct);
+#else
+#define getLOGPENFields(a,b,c) NULL
+#define setLOGPENFields(a,b,c)
+#endif /* NO_LOGPEN */
+
+#ifndef NO_LVCOLUMN
+LVCOLUMN *getLVCOLUMNFields(JNIEnv *env, jobject lpObject, LVCOLUMN *lpStruct);
+void setLVCOLUMNFields(JNIEnv *env, jobject lpObject, LVCOLUMN *lpStruct);
+#else
+#define getLVCOLUMNFields(a,b,c) NULL
+#define setLVCOLUMNFields(a,b,c)
+#endif /* NO_LVCOLUMN */
+
+#ifndef NO_LVHITTESTINFO
+LVHITTESTINFO *getLVHITTESTINFOFields(JNIEnv *env, jobject lpObject, LVHITTESTINFO *lpStruct);
+void setLVHITTESTINFOFields(JNIEnv *env, jobject lpObject, LVHITTESTINFO *lpStruct);
+#else
+#define getLVHITTESTINFOFields(a,b,c) NULL
+#define setLVHITTESTINFOFields(a,b,c)
+#endif /* NO_LVHITTESTINFO */
+
+#ifndef NO_LVITEM
+LVITEM *getLVITEMFields(JNIEnv *env, jobject lpObject, LVITEM *lpStruct);
+void setLVITEMFields(JNIEnv *env, jobject lpObject, LVITEM *lpStruct);
+#else
+#define getLVITEMFields(a,b,c) NULL
+#define setLVITEMFields(a,b,c)
+#endif /* NO_LVITEM */
+
+#ifndef NO_MEASUREITEMSTRUCT
+MEASUREITEMSTRUCT *getMEASUREITEMSTRUCTFields(JNIEnv *env, jobject lpObject, MEASUREITEMSTRUCT *lpStruct);
+void setMEASUREITEMSTRUCTFields(JNIEnv *env, jobject lpObject, MEASUREITEMSTRUCT *lpStruct);
+#else
+#define getMEASUREITEMSTRUCTFields(a,b,c) NULL
+#define setMEASUREITEMSTRUCTFields(a,b,c)
+#endif /* NO_MEASUREITEMSTRUCT */
+
+#ifndef NO_MENUINFO
+MENUINFO *getMENUINFOFields(JNIEnv *env, jobject lpObject, MENUINFO *lpStruct);
+void setMENUINFOFields(JNIEnv *env, jobject lpObject, MENUINFO *lpStruct);
+#else
+#define getMENUINFOFields(a,b,c) NULL
+#define setMENUINFOFields(a,b,c)
+#endif /* NO_MENUINFO */
+
+#ifndef NO_MENUITEMINFO
+MENUITEMINFO *getMENUITEMINFOFields(JNIEnv *env, jobject lpObject, MENUITEMINFO *lpStruct);
+void setMENUITEMINFOFields(JNIEnv *env, jobject lpObject, MENUITEMINFO *lpStruct);
+#else
+#define getMENUITEMINFOFields(a,b,c) NULL
+#define setMENUITEMINFOFields(a,b,c)
+#endif /* NO_MENUITEMINFO */
+
+#ifndef NO_MSG
+MSG *getMSGFields(JNIEnv *env, jobject lpObject, MSG *lpStruct);
+void setMSGFields(JNIEnv *env, jobject lpObject, MSG *lpStruct);
+#else
+#define getMSGFields(a,b,c) NULL
+#define setMSGFields(a,b,c)
+#endif /* NO_MSG */
+
+#ifndef NO_NMCUSTOMDRAW
+NMCUSTOMDRAW *getNMCUSTOMDRAWFields(JNIEnv *env, jobject lpObject, NMCUSTOMDRAW *lpStruct);
+void setNMCUSTOMDRAWFields(JNIEnv *env, jobject lpObject, NMCUSTOMDRAW *lpStruct);
+#else
+#define getNMCUSTOMDRAWFields(a,b,c) NULL
+#define setNMCUSTOMDRAWFields(a,b,c)
+#endif /* NO_NMCUSTOMDRAW */
+
+#ifndef NO_NMHDR
+NMHDR *getNMHDRFields(JNIEnv *env, jobject lpObject, NMHDR *lpStruct);
+void setNMHDRFields(JNIEnv *env, jobject lpObject, NMHDR *lpStruct);
+#else
+#define getNMHDRFields(a,b,c) NULL
+#define setNMHDRFields(a,b,c)
+#endif /* NO_NMHDR */
+
+#ifndef NO_NMHEADER
+NMHEADER *getNMHEADERFields(JNIEnv *env, jobject lpObject, NMHEADER *lpStruct);
+void setNMHEADERFields(JNIEnv *env, jobject lpObject, NMHEADER *lpStruct);
+#else
+#define getNMHEADERFields(a,b,c) NULL
+#define setNMHEADERFields(a,b,c)
+#endif /* NO_NMHEADER */
+
+#ifndef NO_NMLISTVIEW
+NMLISTVIEW *getNMLISTVIEWFields(JNIEnv *env, jobject lpObject, NMLISTVIEW *lpStruct);
+void setNMLISTVIEWFields(JNIEnv *env, jobject lpObject, NMLISTVIEW *lpStruct);
+#else
+#define getNMLISTVIEWFields(a,b,c) NULL
+#define setNMLISTVIEWFields(a,b,c)
+#endif /* NO_NMLISTVIEW */
+
+#ifndef NO_NMLVCUSTOMDRAW
+NMLVCUSTOMDRAW *getNMLVCUSTOMDRAWFields(JNIEnv *env, jobject lpObject, NMLVCUSTOMDRAW *lpStruct);
+void setNMLVCUSTOMDRAWFields(JNIEnv *env, jobject lpObject, NMLVCUSTOMDRAW *lpStruct);
+#else
+#define getNMLVCUSTOMDRAWFields(a,b,c) NULL
+#define setNMLVCUSTOMDRAWFields(a,b,c)
+#endif /* NO_NMLVCUSTOMDRAW */
+
+#ifndef NO_NMREBARCHEVRON
+NMREBARCHEVRON *getNMREBARCHEVRONFields(JNIEnv *env, jobject lpObject, NMREBARCHEVRON *lpStruct);
+void setNMREBARCHEVRONFields(JNIEnv *env, jobject lpObject, NMREBARCHEVRON *lpStruct);
+#else
+#define getNMREBARCHEVRONFields(a,b,c) NULL
+#define setNMREBARCHEVRONFields(a,b,c)
+#endif /* NO_NMREBARCHEVRON */
+
+#ifndef NO_NMTOOLBAR
+NMTOOLBAR *getNMTOOLBARFields(JNIEnv *env, jobject lpObject, NMTOOLBAR *lpStruct);
+void setNMTOOLBARFields(JNIEnv *env, jobject lpObject, NMTOOLBAR *lpStruct);
+#else
+#define getNMTOOLBARFields(a,b,c) NULL
+#define setNMTOOLBARFields(a,b,c)
+#endif /* NO_NMTOOLBAR */
+
+#ifdef NO_NMTTDISPINFO
+#define NO_NMTTDISPINFOA
+#define NO_NMTTDISPINFOW
+#endif /* NO_NMTTDISPINFO */
+
+#ifndef NO_NMTTDISPINFOA
+NMTTDISPINFOA *getNMTTDISPINFOAFields(JNIEnv *env, jobject lpObject, NMTTDISPINFOA *lpStruct);
+void setNMTTDISPINFOAFields(JNIEnv *env, jobject lpObject, NMTTDISPINFOA *lpStruct);
+#else
+#define getNMTTDISPINFOAFields(a,b,c) NULL
+#define setNMTTDISPINFOAFields(a,b,c)
+#endif /* NO_NMTTDISPINFOA */
+
+#ifndef NO_NMTTDISPINFOW
+NMTTDISPINFOW *getNMTTDISPINFOWFields(JNIEnv *env, jobject lpObject, NMTTDISPINFOW *lpStruct);
+void setNMTTDISPINFOWFields(JNIEnv *env, jobject lpObject, NMTTDISPINFOW *lpStruct);
+#else
+#define getNMTTDISPINFOWFields(a,b,c) NULL
+#define setNMTTDISPINFOWFields(a,b,c)
+#endif /* NO_NMTTDISPINFOW */
+
+#ifndef NO_NMTVCUSTOMDRAW
+NMTVCUSTOMDRAW *getNMTVCUSTOMDRAWFields(JNIEnv *env, jobject lpObject, NMTVCUSTOMDRAW *lpStruct);
+void setNMTVCUSTOMDRAWFields(JNIEnv *env, jobject lpObject, NMTVCUSTOMDRAW *lpStruct);
+#else
+#define getNMTVCUSTOMDRAWFields(a,b,c) NULL
+#define setNMTVCUSTOMDRAWFields(a,b,c)
+#endif /* NO_NMTVCUSTOMDRAW */
+
+#ifdef NO_NONCLIENTMETRICS
+#define NO_NONCLIENTMETRICSA
+#define NO_NONCLIENTMETRICSW
+#endif /* NO_NONCLIENTMETRICS */
+
+#ifndef NO_NONCLIENTMETRICSA
+NONCLIENTMETRICSA *getNONCLIENTMETRICSAFields(JNIEnv *env, jobject lpObject, NONCLIENTMETRICSA *lpStruct);
+void setNONCLIENTMETRICSAFields(JNIEnv *env, jobject lpObject, NONCLIENTMETRICSA *lpStruct);
+#else
+#define getNONCLIENTMETRICSAFields(a,b,c) NULL
+#define setNONCLIENTMETRICSAFields(a,b,c)
+#endif /* NO_NONCLIENTMETRICSA */
+
+#ifndef NO_NONCLIENTMETRICSW
+NONCLIENTMETRICSW *getNONCLIENTMETRICSWFields(JNIEnv *env, jobject lpObject, NONCLIENTMETRICSW *lpStruct);
+void setNONCLIENTMETRICSWFields(JNIEnv *env, jobject lpObject, NONCLIENTMETRICSW *lpStruct);
+#else
+#define getNONCLIENTMETRICSWFields(a,b,c) NULL
+#define setNONCLIENTMETRICSWFields(a,b,c)
+#endif /* NO_NONCLIENTMETRICSW */
+
+#ifndef NO_OPENFILENAME
+OPENFILENAME *getOPENFILENAMEFields(JNIEnv *env, jobject lpObject, OPENFILENAME *lpStruct);
+void setOPENFILENAMEFields(JNIEnv *env, jobject lpObject, OPENFILENAME *lpStruct);
+#else
+#define getOPENFILENAMEFields(a,b,c) NULL
+#define setOPENFILENAMEFields(a,b,c)
+#endif /* NO_OPENFILENAME */
+
+#ifdef NO_OSVERSIONINFO
+#define NO_OSVERSIONINFOA
+#define NO_OSVERSIONINFOW
+#endif /* NO_OSVERSIONINFO */
+
+#ifndef NO_OSVERSIONINFOA
+OSVERSIONINFOA *getOSVERSIONINFOAFields(JNIEnv *env, jobject lpObject, OSVERSIONINFOA *lpStruct);
+void setOSVERSIONINFOAFields(JNIEnv *env, jobject lpObject, OSVERSIONINFOA *lpStruct);
+#else
+#define getOSVERSIONINFOAFields(a,b,c) NULL
+#define setOSVERSIONINFOAFields(a,b,c)
+#endif /* NO_OSVERSIONINFOA */
+
+#ifndef NO_OSVERSIONINFOW
+OSVERSIONINFOW *getOSVERSIONINFOWFields(JNIEnv *env, jobject lpObject, OSVERSIONINFOW *lpStruct);
+void setOSVERSIONINFOWFields(JNIEnv *env, jobject lpObject, OSVERSIONINFOW *lpStruct);
+#else
+#define getOSVERSIONINFOWFields(a,b,c) NULL
+#define setOSVERSIONINFOWFields(a,b,c)
+#endif /* NO_OSVERSIONINFOW */
+
+#ifndef NO_PAINTSTRUCT
+PAINTSTRUCT *getPAINTSTRUCTFields(JNIEnv *env, jobject lpObject, PAINTSTRUCT *lpStruct);
+void setPAINTSTRUCTFields(JNIEnv *env, jobject lpObject, PAINTSTRUCT *lpStruct);
+#else
+#define getPAINTSTRUCTFields(a,b,c) NULL
+#define setPAINTSTRUCTFields(a,b,c)
+#endif /* NO_PAINTSTRUCT */
+
+#ifndef NO_POINT
+POINT *getPOINTFields(JNIEnv *env, jobject lpObject, POINT *lpStruct);
+void setPOINTFields(JNIEnv *env, jobject lpObject, POINT *lpStruct);
+#else
+#define getPOINTFields(a,b,c) NULL
+#define setPOINTFields(a,b,c)
+#endif /* NO_POINT */
+
+#ifndef NO_PRINTDLG
+PRINTDLG *getPRINTDLGFields(JNIEnv *env, jobject lpObject, PRINTDLG *lpStruct);
+void setPRINTDLGFields(JNIEnv *env, jobject lpObject, PRINTDLG *lpStruct);
+#else
+#define getPRINTDLGFields(a,b,c) NULL
+#define setPRINTDLGFields(a,b,c)
+#endif /* NO_PRINTDLG */
+
+#ifndef NO_REBARBANDINFO
+REBARBANDINFO *getREBARBANDINFOFields(JNIEnv *env, jobject lpObject, REBARBANDINFO *lpStruct);
+void setREBARBANDINFOFields(JNIEnv *env, jobject lpObject, REBARBANDINFO *lpStruct);
+#else
+#define getREBARBANDINFOFields(a,b,c) NULL
+#define setREBARBANDINFOFields(a,b,c)
+#endif /* NO_REBARBANDINFO */
+
+#ifndef NO_RECT
+RECT *getRECTFields(JNIEnv *env, jobject lpObject, RECT *lpStruct);
+void setRECTFields(JNIEnv *env, jobject lpObject, RECT *lpStruct);
+#else
+#define getRECTFields(a,b,c) NULL
+#define setRECTFields(a,b,c)
+#endif /* NO_RECT */
+
+#ifndef NO_SCROLLINFO
+SCROLLINFO *getSCROLLINFOFields(JNIEnv *env, jobject lpObject, SCROLLINFO *lpStruct);
+void setSCROLLINFOFields(JNIEnv *env, jobject lpObject, SCROLLINFO *lpStruct);
+#else
+#define getSCROLLINFOFields(a,b,c) NULL
+#define setSCROLLINFOFields(a,b,c)
+#endif /* NO_SCROLLINFO */
+
+#ifndef NO_SHACTIVATEINFO
+SHACTIVATEINFO *getSHACTIVATEINFOFields(JNIEnv *env, jobject lpObject, SHACTIVATEINFO *lpStruct);
+void setSHACTIVATEINFOFields(JNIEnv *env, jobject lpObject, SHACTIVATEINFO *lpStruct);
+#else
+#define getSHACTIVATEINFOFields(a,b,c) NULL
+#define setSHACTIVATEINFOFields(a,b,c)
+#endif /* NO_SHACTIVATEINFO */
+
+#ifndef NO_SHELLEXECUTEINFO
+SHELLEXECUTEINFO *getSHELLEXECUTEINFOFields(JNIEnv *env, jobject lpObject, SHELLEXECUTEINFO *lpStruct);
+void setSHELLEXECUTEINFOFields(JNIEnv *env, jobject lpObject, SHELLEXECUTEINFO *lpStruct);
+#else
+#define getSHELLEXECUTEINFOFields(a,b,c) NULL
+#define setSHELLEXECUTEINFOFields(a,b,c)
+#endif /* NO_SHELLEXECUTEINFO */
+
+#ifndef NO_SHMENUBARINFO
+SHMENUBARINFO *getSHMENUBARINFOFields(JNIEnv *env, jobject lpObject, SHMENUBARINFO *lpStruct);
+void setSHMENUBARINFOFields(JNIEnv *env, jobject lpObject, SHMENUBARINFO *lpStruct);
+#else
+#define getSHMENUBARINFOFields(a,b,c) NULL
+#define setSHMENUBARINFOFields(a,b,c)
+#endif /* NO_SHMENUBARINFO */
+
+#ifndef NO_SHRGINFO
+SHRGINFO *getSHRGINFOFields(JNIEnv *env, jobject lpObject, SHRGINFO *lpStruct);
+void setSHRGINFOFields(JNIEnv *env, jobject lpObject, SHRGINFO *lpStruct);
+#else
+#define getSHRGINFOFields(a,b,c) NULL
+#define setSHRGINFOFields(a,b,c)
+#endif /* NO_SHRGINFO */
+
+#ifndef NO_SIPINFO
+SIPINFO *getSIPINFOFields(JNIEnv *env, jobject lpObject, SIPINFO *lpStruct);
+void setSIPINFOFields(JNIEnv *env, jobject lpObject, SIPINFO *lpStruct);
+#else
+#define getSIPINFOFields(a,b,c) NULL
+#define setSIPINFOFields(a,b,c)
+#endif /* NO_SIPINFO */
+
+#ifndef NO_SIZE
+SIZE *getSIZEFields(JNIEnv *env, jobject lpObject, SIZE *lpStruct);
+void setSIZEFields(JNIEnv *env, jobject lpObject, SIZE *lpStruct);
+#else
+#define getSIZEFields(a,b,c) NULL
+#define setSIZEFields(a,b,c)
+#endif /* NO_SIZE */
+
+#ifndef NO_TBBUTTON
+TBBUTTON *getTBBUTTONFields(JNIEnv *env, jobject lpObject, TBBUTTON *lpStruct);
+void setTBBUTTONFields(JNIEnv *env, jobject lpObject, TBBUTTON *lpStruct);
+#else
+#define getTBBUTTONFields(a,b,c) NULL
+#define setTBBUTTONFields(a,b,c)
+#endif /* NO_TBBUTTON */
+
+#ifndef NO_TBBUTTONINFO
+TBBUTTONINFO *getTBBUTTONINFOFields(JNIEnv *env, jobject lpObject, TBBUTTONINFO *lpStruct);
+void setTBBUTTONINFOFields(JNIEnv *env, jobject lpObject, TBBUTTONINFO *lpStruct);
+#else
+#define getTBBUTTONINFOFields(a,b,c) NULL
+#define setTBBUTTONINFOFields(a,b,c)
+#endif /* NO_TBBUTTONINFO */
+
+#ifndef NO_TCITEM
+TCITEM *getTCITEMFields(JNIEnv *env, jobject lpObject, TCITEM *lpStruct);
+void setTCITEMFields(JNIEnv *env, jobject lpObject, TCITEM *lpStruct);
+#else
+#define getTCITEMFields(a,b,c) NULL
+#define setTCITEMFields(a,b,c)
+#endif /* NO_TCITEM */
+
+#ifdef NO_TEXTMETRIC
+#define NO_TEXTMETRICA
+#define NO_TEXTMETRICW
+#endif /* NO_TEXTMETRIC */
+
+#ifndef NO_TEXTMETRICA
+TEXTMETRICA *getTEXTMETRICAFields(JNIEnv *env, jobject lpObject, TEXTMETRICA *lpStruct);
+void setTEXTMETRICAFields(JNIEnv *env, jobject lpObject, TEXTMETRICA *lpStruct);
+#else
+#define getTEXTMETRICAFields(a,b,c) NULL
+#define setTEXTMETRICAFields(a,b,c)
+#endif /* NO_TEXTMETRICA */
+
+#ifndef NO_TEXTMETRICW
+TEXTMETRICW *getTEXTMETRICWFields(JNIEnv *env, jobject lpObject, TEXTMETRICW *lpStruct);
+void setTEXTMETRICWFields(JNIEnv *env, jobject lpObject, TEXTMETRICW *lpStruct);
+#else
+#define getTEXTMETRICWFields(a,b,c) NULL
+#define setTEXTMETRICWFields(a,b,c)
+#endif /* NO_TEXTMETRICW */
+
+#ifndef NO_TOOLINFO
+TOOLINFO *getTOOLINFOFields(JNIEnv *env, jobject lpObject, TOOLINFO *lpStruct);
+void setTOOLINFOFields(JNIEnv *env, jobject lpObject, TOOLINFO *lpStruct);
+#else
+#define getTOOLINFOFields(a,b,c) NULL
+#define setTOOLINFOFields(a,b,c)
+#endif /* NO_TOOLINFO */
+
+#ifndef NO_TRACKMOUSEEVENT
+TRACKMOUSEEVENT *getTRACKMOUSEEVENTFields(JNIEnv *env, jobject lpObject, TRACKMOUSEEVENT *lpStruct);
+void setTRACKMOUSEEVENTFields(JNIEnv *env, jobject lpObject, TRACKMOUSEEVENT *lpStruct);
+#else
+#define getTRACKMOUSEEVENTFields(a,b,c) NULL
+#define setTRACKMOUSEEVENTFields(a,b,c)
+#endif /* NO_TRACKMOUSEEVENT */
+
+#ifndef NO_TRIVERTEX
+TRIVERTEX *getTRIVERTEXFields(JNIEnv *env, jobject lpObject, TRIVERTEX *lpStruct);
+void setTRIVERTEXFields(JNIEnv *env, jobject lpObject, TRIVERTEX *lpStruct);
+#else
+#define getTRIVERTEXFields(a,b,c) NULL
+#define setTRIVERTEXFields(a,b,c)
+#endif /* NO_TRIVERTEX */
+
+#ifndef NO_TVHITTESTINFO
+TVHITTESTINFO *getTVHITTESTINFOFields(JNIEnv *env, jobject lpObject, TVHITTESTINFO *lpStruct);
+void setTVHITTESTINFOFields(JNIEnv *env, jobject lpObject, TVHITTESTINFO *lpStruct);
+#else
+#define getTVHITTESTINFOFields(a,b,c) NULL
+#define setTVHITTESTINFOFields(a,b,c)
+#endif /* NO_TVHITTESTINFO */
+
+#ifndef NO_TVINSERTSTRUCT
+TVINSERTSTRUCT *getTVINSERTSTRUCTFields(JNIEnv *env, jobject lpObject, TVINSERTSTRUCT *lpStruct);
+void setTVINSERTSTRUCTFields(JNIEnv *env, jobject lpObject, TVINSERTSTRUCT *lpStruct);
+#else
+#define getTVINSERTSTRUCTFields(a,b,c) NULL
+#define setTVINSERTSTRUCTFields(a,b,c)
+#endif /* NO_TVINSERTSTRUCT */
+
+#ifndef NO_TVITEM
+TVITEM *getTVITEMFields(JNIEnv *env, jobject lpObject, TVITEM *lpStruct);
+void setTVITEMFields(JNIEnv *env, jobject lpObject, TVITEM *lpStruct);
+#else
+#define getTVITEMFields(a,b,c) NULL
+#define setTVITEMFields(a,b,c)
+#endif /* NO_TVITEM */
+
+#ifndef NO_WINDOWPLACEMENT
+WINDOWPLACEMENT *getWINDOWPLACEMENTFields(JNIEnv *env, jobject lpObject, WINDOWPLACEMENT *lpStruct);
+void setWINDOWPLACEMENTFields(JNIEnv *env, jobject lpObject, WINDOWPLACEMENT *lpStruct);
+#else
+#define getWINDOWPLACEMENTFields(a,b,c) NULL
+#define setWINDOWPLACEMENTFields(a,b,c)
+#endif /* NO_WINDOWPLACEMENT */
+
+#ifndef NO_WINDOWPOS
+WINDOWPOS *getWINDOWPOSFields(JNIEnv *env, jobject lpObject, WINDOWPOS *lpStruct);
+void setWINDOWPOSFields(JNIEnv *env, jobject lpObject, WINDOWPOS *lpStruct);
+#else
+#define getWINDOWPOSFields(a,b,c) NULL
+#define setWINDOWPOSFields(a,b,c)
+#endif /* NO_WINDOWPOS */
+
+#ifndef NO_WNDCLASS
+WNDCLASS *getWNDCLASSFields(JNIEnv *env, jobject lpObject, WNDCLASS *lpStruct);
+void setWNDCLASSFields(JNIEnv *env, jobject lpObject, WNDCLASS *lpStruct);
+#else
+#define getWNDCLASSFields(a,b,c) NULL
+#define setWNDCLASSFields(a,b,c)
+#endif /* NO_WNDCLASS */
+
+/************************ OLE ***************************/
+
+/* 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);
+
+#ifndef NO_CAUUID
+CAUUID *getCAUUIDFields(JNIEnv *env, jobject lpObject, CAUUID *lpStruct);
+void setCAUUIDFields(JNIEnv *env, jobject lpObject, CAUUID *lpStruct);
+#endif /* NO_CAUUID */
+
+#ifndef NO_CONTROLINFO
+CONTROLINFO *getCONTROLINFOFields(JNIEnv *env, jobject lpObject, CONTROLINFO *lpStruct);
+void setCONTROLINFOFields(JNIEnv *env, jobject lpObject, CONTROLINFO *lpStruct);
+#endif /* NO_CONTROLINFO */
+
+#ifndef NO_COSERVERINFO
+COSERVERINFO *getCOSERVERINFOFields(JNIEnv *env, jobject lpObject, COSERVERINFO *lpStruct);
+void setCOSERVERINFOFields(JNIEnv *env, jobject lpObject, COSERVERINFO *lpStruct);
+#endif /* NO_COSERVERINFO */
+
+#ifndef NO_DISPPARAMS
+DISPPARAMS *getDISPPARAMSFields(JNIEnv *env, jobject lpObject, DISPPARAMS *lpStruct);
+void setDISPPARAMSFields(JNIEnv *env, jobject lpObject, DISPPARAMS *lpStruct);
+#endif /* NO_DISPPARAMS */
+
+#ifndef NO_DVTARGETDEVICE
+DVTARGETDEVICE *getDVTARGETDEVICEFields(JNIEnv *env, jobject lpObject, DVTARGETDEVICE *lpStruct);
+void setDVTARGETDEVICEFields(JNIEnv *env, jobject lpObject, DVTARGETDEVICE *lpStruct);
+#endif /* NO_DVTARGETDEVICE */
+
+#ifndef NO_EXCEPINFO
+EXCEPINFO *getEXCEPINFOFields(JNIEnv *env, jobject lpObject, EXCEPINFO *lpStruct);
+void setEXCEPINFOFields(JNIEnv *env, jobject lpObject, EXCEPINFO *lpStruct);
+#endif /* NO_EXCEPINFO */
+
+#ifndef NO_FORMATETC
+FORMATETC *getFORMATETCFields(JNIEnv *env, jobject lpObject, FORMATETC *lpStruct);
+void setFORMATETCFields(JNIEnv *env, jobject lpObject, FORMATETC *lpStruct);
+#endif /* NO_FORMATETC */
+
+#ifndef NO_FUNCDESC1
+FUNCDESC *getFUNCDESC1Fields(JNIEnv *env, jobject lpObject, FUNCDESC *lpStruct);
+void setFUNCDESC1Fields(JNIEnv *env, jobject lpObject, FUNCDESC *lpStruct);
+#endif /* NO_FUNCDESC1 */
+
+#ifndef NO_FUNCDESC2
+FUNCDESC *getFUNCDESC2Fields(JNIEnv *env, jobject lpObject, FUNCDESC *lpStruct);
+void setFUNCDESC2Fields(JNIEnv *env, jobject lpObject, FUNCDESC *lpStruct);
+#endif /* NO_FUNCDESC2 */
+
+#ifndef NO_GUID
+GUID *getGUIDFields(JNIEnv *env, jobject lpObject, GUID *lpStruct);
+void setGUIDFields(JNIEnv *env, jobject lpObject, GUID *lpStruct);
+#endif /* NO_GUID */
+
+#ifndef NO_LICINFO
+LICINFO *getLICINFOFields(JNIEnv *env, jobject lpObject, LICINFO *lpStruct);
+void setLICINFOFields(JNIEnv *env, jobject lpObject, LICINFO *lpStruct);
+#endif /* NO_LICINFO */
+
+#ifndef NO_OLECMD
+OLECMD *getOLECMDFields(JNIEnv *env, jobject lpObject, OLECMD *lpStruct);
+void setOLECMDFields(JNIEnv *env, jobject lpObject, OLECMD *lpStruct);
+#endif /* NO_OLECMD */
+
+#ifndef NO_OLECMDTEXT
+OLECMDTEXT *getOLECMDTEXTFields(JNIEnv *env, jobject lpObject, OLECMDTEXT *lpStruct);
+void setOLECMDTEXTFields(JNIEnv *env, jobject lpObject, OLECMDTEXT *lpStruct);
+#endif /* NO_OLECMDTEXT */
+
+#ifndef NO_OLEINPLACEFRAMEINFO
+OLEINPLACEFRAMEINFO *getOLEINPLACEFRAMEINFOFields(JNIEnv *env, jobject lpObject, OLEINPLACEFRAMEINFO *lpStruct);
+void setOLEINPLACEFRAMEINFOFields(JNIEnv *env, jobject lpObject, OLEINPLACEFRAMEINFO *lpStruct);
+#endif /* NO_OLEINPLACEFRAMEINFO */
+
+#ifndef NO_STATSTG
+STATSTG *getSTATSTGFields(JNIEnv *env, jobject lpObject, STATSTG *lpStruct);
+void setSTATSTGFields(JNIEnv *env, jobject lpObject, STATSTG *lpStruct);
+#endif /* NO_STATSTG */
+
+#ifndef NO_STGMEDIUM
+STGMEDIUM *getSTGMEDIUMFields(JNIEnv *env, jobject lpObject, STGMEDIUM *lpStruct);
+void setSTGMEDIUMFields(JNIEnv *env, jobject lpObject, STGMEDIUM *lpStruct);
+#endif /* NO_STGMEDIUM */
+
+#ifndef NO_TYPEATTR
+TYPEATTR *getTYPEATTRFields(JNIEnv *env, jobject lpObject, TYPEATTR *lpStruct);
+void setTYPEATTRFields(JNIEnv *env, jobject lpObject, TYPEATTR *lpStruct);
+#endif /* NO_TYPEATTR */
+
+#ifndef NO_VARDESC1
+VARDESC *getVARDESC1Fields(JNIEnv *env, jobject lpObject, VARDESC *lpStruct);
+void setVARDESC1Fields(JNIEnv *env, jobject lpObject, VARDESC *lpStruct);
+#endif /* NO_VARDESC1 */
+
+#ifndef NO_VARDESC2
+VARDESC *getVARDESC2Fields(JNIEnv *env, jobject lpObject, VARDESC *lpStruct);
+void setVARDESC2Fields(JNIEnv *env, jobject lpObject, VARDESC *lpStruct);
+#endif /* NO_VARDESC2 */
+
+/**************************** END OLE ****************************/
+
+#endif // INC_structs_H
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/swt.c b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/swt.c
index 851c0deeb0..6ee29754a5 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/swt.c
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/swt.c
@@ -1,7320 +1,7320 @@
-/*
- * Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
- * This file is made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-/**
- * SWT OS natives implementation.
- */
-
-#include "swt.h"
-#include "structs.h"
-
-#ifdef _WIN32_WCE
-#define NO_AbortDoc
-#define NO_ActivateKeyboardLayout
-#define NO_Arc
-#define NO_CallNextHookEx
-#define NO_CallWindowProcA
-#define NO_CharLowerA
-#define NO_CharUpperA
-#define NO_ChooseColorA
-#define NO_ChooseFontA
-#define NO_ChooseFontW
-#define NO_CopyImage
-#define NO_CreateAcceleratorTableA
-#define NO_CreateCursor
-#define NO_CreateDCA
-#define NO_CreateFontIndirectA__Lorg_eclipse_swt_internal_win32_LOGFONT_2
-#define NO_CreateFontIndirectA__I
-#define NO_CreateWindowExA
-#define NO_DefWindowProcA
-#define NO_DestroyCursor
-#define NO_DispatchMessageA
-#define NO_DragDetect
-#define NO_DragFinish
-#define NO_DragQueryFileA
-#define NO_DragQueryFileW
-#define NO_DrawStateA
-#define NO_DrawStateW
-#define NO_DrawTextA
-#define NO_EnableScrollBar
-#define NO_EndDoc
-#define NO_EndPage
-#define NO_EnumFontFamiliesA
-#define NO_EnumSystemLanguageGroupsA
-#define NO_EnumSystemLanguageGroupsW
-#define NO_EnumSystemLocalesA
-#define NO_ExpandEnvironmentStringsW
-#define NO_ExpandEnvironmentStringsA
-#define NO_ExtTextOutA
-#define NO_ExtractIconExA
-#define NO_FindWindowA
-#define NO_GetCharABCWidthsA
-#define NO_GetCharABCWidthsW
-#define NO_GetCharWidthA
-#define NO_GetCharWidthW
-#define NO_GetCharacterPlacementA
-#define NO_GetCharacterPlacementW
-#define NO_GetClassInfoA
-#define NO_GetClipboardFormatNameA
-#define NO_GetDIBColorTable
-#define NO_GetDIBits
-#define NO_GetFontLanguageInfo
-#define NO_GetIconInfo
-#define NO_GetKeyboardLayout
-#define NO_GetKeyboardLayoutList
-#define NO_GetKeyboardState
-#define NO_GetKeyNameTextA
-#define NO_GetKeyNameTextW
-#define NO_GetLastActivePopup
-#define NO_GetLocaleInfoA
-#define NO_GetMenu
-#define NO_GetMenuDefaultItem
-#define NO_GetMenuInfo
-#define NO_GetMenuItemCount
-#define NO_GetMenuItemInfoA
-#define NO_GetMessageA
-#define NO_GetMessageTime
-#define NO_GetModuleHandleA
-#define NO_GetObjectA__IILorg_eclipse_swt_internal_win32_LOGPEN_2
-#define NO_GetObjectA__IILorg_eclipse_swt_internal_win32_LOGFONT_2
-#define NO_GetObjectA__IILorg_eclipse_swt_internal_win32_LOGBRUSH_2
-#define NO_GetObjectA__IILorg_eclipse_swt_internal_win32_DIBSECTION_2
-#define NO_GetObjectA__IILorg_eclipse_swt_internal_win32_BITMAP_2
-#define NO_GetOpenFileNameA
-#define NO_GetProfileStringA
-#define NO_GetProfileStringW
-#define NO_GetROP2
-#define NO_GetSaveFileNameA
-#define NO_GetTextCharset
-#define NO_GetTextExtentPoint32A
-#define NO_GetTextMetricsA
-#define NO_GetVersionExA
-#define NO_GetWindowLongA
-#define NO_GetWindowPlacement
-#define NO_GetWindowTextA
-#define NO_GetWindowTextLengthA
-#define NO_GradientFill
-#define NO_ImmGetCompositionFontA
-#define NO_ImmGetCompositionStringA
-#define NO_ImmSetCompositionFontA
-#define NO_InsertMenuA
-#define NO_InsertMenuItemA
-#define NO_InsertMenuItemW
-#define NO_InvalidateRgn
-#define NO_IsIconic
-#define NO_IsZoomed
-#define NO_LineTo
-#define NO_LoadBitmapA
-#define NO_LoadCursorA
-#define NO_LoadIconA
-#define NO_LoadImageA
-#define NO_LoadLibraryA
-#define NO_MapVirtualKeyA
-#define NO_MessageBoxA
-#define NO_MoveMemory__ILorg_eclipse_swt_internal_win32_DROPFILES_2I
-#define NO_MoveMemory__Lorg_eclipse_swt_internal_win32_NMREBARCHEVRON_2II
-#define NO_MoveMemory__Lorg_eclipse_swt_internal_win32_HELPINFO_2II
-#define NO_MoveMemory__ILorg_eclipse_swt_internal_win32_TRIVERTEX_2I
-#define NO_MoveMemory__ILorg_eclipse_swt_internal_win32_GRADIENT_1RECT_2I
-#define NO_MoveMemoryA__Lorg_eclipse_swt_internal_win32_NMTTDISPINFO_2II
-#define NO_MoveMemoryW__Lorg_eclipse_swt_internal_win32_NMTTDISPINFO_2II
-#define NO_MoveMemoryA__ILorg_eclipse_swt_internal_win32_NMTTDISPINFO_2I
-#define NO_MoveMemoryW__ILorg_eclipse_swt_internal_win32_NMTTDISPINFO_2I
-#define NO_MoveMemoryA__Lorg_eclipse_swt_internal_win32_LOGFONT_2II
-#define NO_MoveMemoryA__ILorg_eclipse_swt_internal_win32_LOGFONT_2I
-#define NO_MoveToEx
-#define NO_OleInitialize
-#define NO_OleUninitialize
-#define NO_PeekMessageA
-#define NO_Pie
-#define NO_PostMessageA
-#define NO_PostThreadMessageA
-#define NO_PrintDlgA
-#define NO_PrintDlgW
-#define NO_RedrawWindow
-#define NO_RegEnumKeyExA
-#define NO_RegOpenKeyExA
-#define NO_RegQueryInfoKeyA
-#define NO_RegQueryValueExA
-#define NO_RegisterClassA
-#define NO_RegisterClipboardFormatA
-#define NO_SetLayout
-#define NO_SHBrowseForFolderA
-#define NO_SHBrowseForFolderW
-#define NO_SHGetPathFromIDListA
-#define NO_SHGetPathFromIDListW
-#define NO_SendMessageA__IIILorg_eclipse_swt_internal_win32_TVITEM_2
-#define NO_SendMessageA__IIILorg_eclipse_swt_internal_win32_TVINSERTSTRUCT_2
-#define NO_SendMessageA__IIILorg_eclipse_swt_internal_win32_TVHITTESTINFO_2
-#define NO_SendMessageA__IIILorg_eclipse_swt_internal_win32_TOOLINFO_2
-#define NO_SendMessageA__IIILorg_eclipse_swt_internal_win32_TCITEM_2
-#define NO_SendMessageA__IIILorg_eclipse_swt_internal_win32_TBBUTTONINFO_2
-#define NO_SendMessageA__IIILorg_eclipse_swt_internal_win32_TBBUTTON_2
-#define NO_SendMessageA__IIILorg_eclipse_swt_internal_win32_RECT_2
-#define NO_SendMessageA__IIILorg_eclipse_swt_internal_win32_REBARBANDINFO_2
-#define NO_SendMessageA__IIILorg_eclipse_swt_internal_win32_LVITEM_2
-#define NO_SendMessageA__IIILorg_eclipse_swt_internal_win32_LVHITTESTINFO_2
-#define NO_SendMessageA__IIILorg_eclipse_swt_internal_win32_LVCOLUMN_2
-#define NO_SendMessageA__IIII
-#define NO_SendMessageA__III_3S
-#define NO_SendMessageA__III_3I
-#define NO_SendMessageA__III_3B
-#define NO_SendMessageA__II_3II
-#define NO_SendMessageA__II_3I_3I
-#define NO_SendMessageW__IIILorg_eclipse_swt_internal_win32_TOOLINFO_2
-#define NO_SetDIBColorTable
-#define NO_SetMenu
-#define NO_SetMenuDefaultItem
-#define NO_SetMenuInfo
-#define NO_SetMenuItemInfoA
-#define NO_SetStretchBltMode
-#define NO_SetTextAlign
-#define NO_SetWindowLongA
-#define NO_SetWindowPlacement
-#define NO_SetWindowTextA
-#define NO_SetWindowsHookExA
-#define NO_SetWindowsHookExW
-#define NO_ShellExecuteExA
-#define NO_ShowOwnedPopups
-#define NO_ShowScrollBar
-#define NO_StartDocA
-#define NO_StartDocW
-#define NO_StartPage
-#define NO_SystemParametersInfoA__IILorg_eclipse_swt_internal_win32_RECT_2I
-#define NO_SystemParametersInfoA__IILorg_eclipse_swt_internal_win32_NONCLIENTMETRICS_2I
-#define NO_SystemParametersInfoA__II_3II
-#define NO_SystemParametersInfoW__IILorg_eclipse_swt_internal_win32_NONCLIENTMETRICS_2I
-#define NO_ToAscii
-#define NO_ToUnicode
-#define NO_TrackMouseEvent
-#define NO_TranslateAcceleratorA
-#define NO_UnhookWindowsHookEx
-#define NO_UnregisterClassA
-#define NO_VkKeyScanA
-#define NO_VkKeyScanW
-#define NO_WaitMessage
-#define NO_WindowFromDC
-
-#define ChooseColorW ChooseColor
-#define CHOOSECOLORW CHOOSECOLOR
-#define LPCHOOSECOLORW LPCHOOSECOLOR
-#define FONTENUMPROCW FONTENUMPROC
-#define ShellExecuteExW ShellExecuteEx
-#define LPSHELLEXECUTEINFOW LPSHELLEXECUTEINFO
-#endif /* _WIN32_WCE */
-
-#ifndef WIN32_PLATFORM_HPC2000
-#define NO_CommandBar_1AddAdornments
-#define NO_CommandBar_1Create
-#define NO_CommandBar_1DrawMenuBar
-#define NO_CommandBar_1Height
-#define NO_CommandBar_1InsertMenubarEx
-#define NO_CommandBar_1Show
-#endif /* WIN32_PLATFORM_HPC2000 */
-
-#if !defined(WIN32_PLATFORM_PSPC) && !defined(WIN32_PLATFORM_WFSP)
-#define NO_SHCreateMenuBar
-#define NO_SHSetAppKeyWndAssoc
-#endif /* WIN32_PLATFORM_PSPC, WIN32_PLATFORM_WFSP */
-
-#ifdef WIN32_PLATFORM_WFSP
-#define NO_CommDlgExtendedError
-#define NO_ChooseColorW
-#endif /* WIN32_PLATFORM_WFSP */
-
-#ifndef WIN32_PLATFORM_PSPC
-#define NO_SHHandleWMSettingChange
-#define NO_SHRecognizeGesture
-#define NO_SHSipPreference
-#define NO_SipGetInfo
-#endif /* WIN32_PLATFORM_PSPC */
-
-#ifndef WIN32_PLATFORM_WFSP
-#define NO_SHSendBackToFocusWindow
-#endif /* WIN32_PLATFORM_WFSP */
-
-#ifndef _WIN32_WCE
-#define NO_CommandBar_1Destroy
-#define NO_TransparentImage
-#endif /* _WIN32_WCE */
-
-/* Export the dll version info call */
-
-__declspec(dllexport) HRESULT DllGetVersion(DLLVERSIONINFO *dvi);
-
-HRESULT DllGetVersion(DLLVERSIONINFO *dvi)
-{
- dvi->dwMajorVersion = SWT_VERSION / 1000;
- dvi->dwMinorVersion = SWT_VERSION % 1000;
- dvi->dwBuildNumber = SWT_BUILD_NUM;
- dvi->dwPlatformID = DLLVER_PLATFORM_WINDOWS;
- return 1;
-}
-
-/* Cache the handle to the library */
-HINSTANCE g_hInstance = NULL;
-
-BOOL WINAPI DllMain(HANDLE hInstDLL, DWORD dwReason, LPVOID lpvReserved)
-{
- if (dwReason == DLL_PROCESS_ATTACH) {
- if (g_hInstance == NULL) g_hInstance = hInstDLL;
- }
- return TRUE;
-}
-
-/* Natives */
-
-#define OS_NATIVE(method) Java_org_eclipse_swt_internal_win32_OS_##method
-
-#ifndef NO_AbortDoc
-JNIEXPORT jint JNICALL OS_NATIVE(AbortDoc)
- (JNIEnv *env, jclass that, jint arg0)
-{
- DEBUG_CALL("AbortDoc\n")
-
- return (jint)AbortDoc((HDC)arg0);
-}
-#endif /* NO_AbortDoc */
-#ifndef NO_ActivateKeyboardLayout
-JNIEXPORT jint JNICALL OS_NATIVE(ActivateKeyboardLayout)
- (JNIEnv *env, jclass that, jint arg0, jint arg1)
-{
- DEBUG_CALL("ActivateKeyboardLayout\n")
-
- return (jint)ActivateKeyboardLayout((HKL)arg0, arg1);
-}
-#endif /* NO_ActivateKeyboardLayout */
-
-#ifndef NO_AdjustWindowRectEx
-JNIEXPORT jboolean JNICALL OS_NATIVE(AdjustWindowRectEx)
- (JNIEnv *env, jclass that, jobject arg0, jint arg1, jboolean arg2, jint arg3)
-{
- RECT _arg0, *lparg0=NULL;
- jboolean rc;
-
- DEBUG_CALL("AdjustWindowRectEx\n")
-
- if (arg0) lparg0 = getRECTFields(env, arg0, &_arg0);
- rc = (jboolean)AdjustWindowRectEx(lparg0, arg1, arg2, arg3);
- if (arg0) setRECTFields(env, arg0, lparg0);
- return rc;
-}
-#endif /* NO_AdjustWindowRectEx */
-
-#ifndef NO_Arc
-JNIEXPORT jboolean JNICALL OS_NATIVE(Arc)
- (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jint arg3, jint arg4, jint arg5, jint arg6, jint arg7, jint arg8)
-{
- DEBUG_CALL("Arc\n")
-
- return (jboolean)Arc((HDC)arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8);
-}
-#endif /* NO_Arc */
-
-#ifndef NO_BeginDeferWindowPos
-JNIEXPORT jint JNICALL OS_NATIVE(BeginDeferWindowPos)
- (JNIEnv *env, jclass that, jint arg0)
-{
- DEBUG_CALL("BeginDeferWindowPos\n")
-
- return (jint)BeginDeferWindowPos(arg0);
-}
-#endif /* NO_BeginDeferWindowPos */
-
-#ifndef NO_BeginPaint
-JNIEXPORT jint JNICALL OS_NATIVE(BeginPaint)
- (JNIEnv *env, jclass that, jint arg0, jobject arg1)
-{
- PAINTSTRUCT _arg1, *lparg1=NULL;
- jint rc;
-
- DEBUG_CALL("BeginPaint\n")
-
- if (arg1) lparg1 = &_arg1;
- rc = (jint)BeginPaint((HWND)arg0, lparg1);
- if (arg1) setPAINTSTRUCTFields(env, arg1, lparg1);
- return rc;
-}
-#endif /* NO_BeginPaint */
-
-#ifndef NO_BitBlt
-JNIEXPORT jboolean JNICALL OS_NATIVE(BitBlt)
- (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jint arg3, jint arg4, jint arg5, jint arg6, jint arg7, jint arg8)
-{
- DEBUG_CALL("BitBlt\n")
-
- return (jboolean)BitBlt((HDC)arg0, arg1, arg2, arg3, arg4, (HDC)arg5, arg6, arg7, arg8);
-}
-#endif /* NO_BitBlt */
-
-#ifndef NO_BringWindowToTop
-JNIEXPORT jboolean JNICALL OS_NATIVE(BringWindowToTop)
- (JNIEnv *env, jclass that, jint arg0)
-{
- DEBUG_CALL("BringWindowToTop\n")
-
- return (jboolean)BringWindowToTop((HWND)arg0);
-}
-#endif /* NO_BringWindowToTop */
-
-#ifndef NO_Call
-JNIEXPORT jint JNICALL OS_NATIVE(Call)
- (JNIEnv *env, jclass that, jint arg0, jobject arg1)
-{
- DLLVERSIONINFO _arg1, *lparg1=NULL;
- jint rc;
-
- DEBUG_CALL("Call\n")
-
- if (arg1) lparg1 = getDLLVERSIONINFOFields(env, arg1, &_arg1);
- rc = (jint)((DLLGETVERSIONPROC)arg0)(lparg1);
- if (arg1) setDLLVERSIONINFOFields(env, arg1, lparg1);
- return rc;
-}
-#endif /* NO_Call */
-
-#ifndef NO_CallNextHookEx
-JNIEXPORT jint JNICALL OS_NATIVE(CallNextHookEx)
- (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jint arg3)
-{
- DEBUG_CALL("CallNextHookEx\n")
-
- return (jint)CallNextHookEx((HHOOK)arg0, arg1, (WPARAM)arg2, (LPARAM)arg3);
-}
-#endif /* NO_CallNextHookEx */
-
-#ifndef NO_CallWindowProcA
-JNIEXPORT jint JNICALL OS_NATIVE(CallWindowProcA)
- (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jint arg3, jint arg4)
-{
- DEBUG_CALL("CallWindowProcA\n")
-
- return (jint)CallWindowProcA((WNDPROC)arg0, (HWND)arg1, arg2, arg3, arg4);
-}
-#endif /* NO_CallWindowProcA */
-
-#ifndef NO_CallWindowProcW
-JNIEXPORT jint JNICALL OS_NATIVE(CallWindowProcW)
- (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jint arg3, jint arg4)
-{
- DEBUG_CALL("CallWindowProcW\n")
-
- return (jint)CallWindowProcW((WNDPROC)arg0, (HWND)arg1, arg2, arg3, arg4);
-}
-#endif /* NO_CallWindowProcW */
-
-#ifndef NO_CharLowerA
-JNIEXPORT jshort JNICALL OS_NATIVE(CharLowerA)
- (JNIEnv *env, jclass that, jshort arg0)
-{
- DEBUG_CALL("CharLowerA\n")
-
- return (jshort)CharLowerA((LPSTR)arg0);
-}
-#endif /* NO_CharLowerA */
-
-#ifndef NO_CharLowerW
-JNIEXPORT jshort JNICALL OS_NATIVE(CharLowerW)
- (JNIEnv *env, jclass that, jshort arg0)
-{
- DEBUG_CALL("CharLowerW\n")
-
- return (jshort)CharLowerW((LPWSTR)arg0);
-}
-#endif /* NO_CharLowerW */
-
-#ifndef NO_CharUpperA
-JNIEXPORT jshort JNICALL OS_NATIVE(CharUpperA)
- (JNIEnv *env, jclass that, jshort arg0)
-{
- DEBUG_CALL("CharUpperA\n")
-
- return (jshort)CharUpperA((LPSTR)arg0);
-}
-#endif /* NO_CharUpperA */
-
-#ifndef NO_CharUpperW
-JNIEXPORT jshort JNICALL OS_NATIVE(CharUpperW)
- (JNIEnv *env, jclass that, jshort arg0)
-{
- DEBUG_CALL("CharUpperW\n")
-
- return (jshort)CharUpperW((LPWSTR)arg0);
-}
-#endif /* NO_CharUpperW */
-
-#ifndef NO_CheckMenuItem
-JNIEXPORT jboolean JNICALL OS_NATIVE(CheckMenuItem)
- (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2)
-{
- DEBUG_CALL("CheckMenuItem\n")
-
- return (jboolean)CheckMenuItem((HMENU)arg0, (UINT)arg1, (UINT)arg2);
-}
-#endif /* NO_CheckMenuItem */
-
-#ifndef NO_ChooseColorA
-JNIEXPORT jboolean JNICALL OS_NATIVE(ChooseColorA)
- (JNIEnv *env, jclass that, jobject arg0)
-{
- CHOOSECOLOR _arg0, *lparg0=NULL;
- jboolean rc;
-
- DEBUG_CALL("ChooseColorA\n")
-
- if (arg0) lparg0 = getCHOOSECOLORFields(env, arg0, &_arg0);
- rc = (jboolean)ChooseColorA(lparg0);
- if (arg0) setCHOOSECOLORFields(env, arg0, lparg0);
- return rc;
-}
-#endif /* NO_ChooseColorA */
-
-#ifndef NO_ChooseColorW
-JNIEXPORT jboolean JNICALL OS_NATIVE(ChooseColorW)
- (JNIEnv *env, jclass that, jobject arg0)
-{
- CHOOSECOLOR _arg0, *lparg0=NULL;
- jboolean rc;
-
- DEBUG_CALL("ChooseColorW\n")
-
- if (arg0) lparg0 = getCHOOSECOLORFields(env, arg0, &_arg0);
- rc = (jboolean)ChooseColorW((LPCHOOSECOLORW)lparg0);
- if (arg0) setCHOOSECOLORFields(env, arg0, lparg0);
- return rc;
-}
-#endif /* NO_ChooseColorW */
-
-#ifndef NO_ChooseFontA
-JNIEXPORT jboolean JNICALL OS_NATIVE(ChooseFontA)
- (JNIEnv *env, jclass that, jobject arg0)
-{
- CHOOSEFONT _arg0, *lparg0=NULL;
- jboolean rc;
-
- DEBUG_CALL("ChooseFontA\n")
-
- if (arg0) lparg0 = getCHOOSEFONTFields(env, arg0, &_arg0);
- rc = (jboolean)ChooseFontA(lparg0);
- if (arg0) setCHOOSEFONTFields(env, arg0, lparg0);
- return rc;
-}
-#endif /* NO_ChooseFontA */
-
-#ifndef NO_ChooseFontW
-JNIEXPORT jboolean JNICALL OS_NATIVE(ChooseFontW)
- (JNIEnv *env, jclass that, jobject arg0)
-{
- CHOOSEFONT _arg0, *lparg0=NULL;
- jboolean rc;
-
- DEBUG_CALL("ChooseFontW\n")
-
- if (arg0) lparg0 = getCHOOSEFONTFields(env, arg0, &_arg0);
- rc = (jboolean)ChooseFontW((LPCHOOSEFONTW)lparg0);
- if (arg0) setCHOOSEFONTFields(env, arg0, lparg0);
- return rc;
-}
-#endif /* NO_ChooseFontW */
-
-#ifndef NO_ClientToScreen
-JNIEXPORT jboolean JNICALL OS_NATIVE(ClientToScreen)
- (JNIEnv *env, jclass that, jint arg0, jobject arg1)
-{
- POINT _arg1, *lparg1=NULL;
- jboolean rc;
-
- DEBUG_CALL("ClientToScreen\n")
-
- if (arg1) lparg1 = getPOINTFields(env, arg1, &_arg1);
- rc = (jboolean)ClientToScreen((HWND)arg0, lparg1);
- if (arg1) setPOINTFields(env, arg1, lparg1);
- return rc;
-}
-#endif /* NO_ClientToScreen */
-
-#ifndef NO_CloseClipboard
-JNIEXPORT jboolean JNICALL OS_NATIVE(CloseClipboard)
- (JNIEnv *env, jclass that)
-{
- DEBUG_CALL("CloseClipboard\n")
-
- return (jboolean)CloseClipboard();
-}
-#endif /* NO_CloseClipboard */
-
-#ifndef NO_CombineRgn
-JNIEXPORT jint JNICALL OS_NATIVE(CombineRgn)
- (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jint arg3)
-{
- DEBUG_CALL("CombineRgn\n")
-
- return (jint)CombineRgn((HRGN)arg0, (HRGN)arg1, (HRGN)arg2, arg3);
-}
-#endif /* NO_CombineRgn */
-
-#ifndef NO_CommDlgExtendedError
-JNIEXPORT jint JNICALL OS_NATIVE(CommDlgExtendedError)
- (JNIEnv *env, jclass that)
-{
- DEBUG_CALL("CommDlgExtendedError\n")
-
- return (jint)CommDlgExtendedError();
-}
-#endif /* NO_CommDlgExtendedError */
-
-#ifndef NO_CommandBar_1AddAdornments
-JNIEXPORT jboolean JNICALL OS_NATIVE(CommandBar_1AddAdornments)
- (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2)
-{
- DEBUG_CALL("CommandBar_1AddAdornments\n")
-
- return (jboolean)CommandBar_AddAdornments((HWND)arg0, arg1, arg2);
-}
-#endif /* NO_CommandBar_1AddAdornments */
-
-#ifndef NO_CommandBar_1Create
-JNIEXPORT jint JNICALL OS_NATIVE(CommandBar_1Create)
- (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2)
-{
- DEBUG_CALL("CommandBar_1Create\n")
-
- return (jint)CommandBar_Create((HINSTANCE)arg0, (HWND)arg1, arg2);
-}
-#endif /* NO_CommandBar_1Create */
-
-#ifndef NO_CommandBar_1Destroy
-JNIEXPORT void JNICALL OS_NATIVE(CommandBar_1Destroy)
- (JNIEnv *env, jclass that, jint arg0)
-{
- DEBUG_CALL("CommandBar_1Destroy\n")
-
- CommandBar_Destroy((HWND)arg0);
-}
-#endif /* NO_CommandBar_1Destroy */
-
-#ifndef NO_CommandBar_1DrawMenuBar
-JNIEXPORT jboolean JNICALL OS_NATIVE(CommandBar_1DrawMenuBar)
- (JNIEnv *env, jclass that, jint arg0, jint arg1)
-{
- DEBUG_CALL("CommandBar_1DrawMenuBar\n")
-
- return (jboolean)CommandBar_DrawMenuBar((HWND)arg0, (WORD)arg1);
-}
-#endif /* NO_CommandBar_1DrawMenuBar */
-
-#ifndef NO_CommandBar_1Height
-JNIEXPORT jint JNICALL OS_NATIVE(CommandBar_1Height)
- (JNIEnv *env, jclass that, jint arg0)
-{
- DEBUG_CALL("CommandBar_1Height\n")
-
- return (jint)CommandBar_Height((HWND)arg0);
-}
-#endif /* NO_CommandBar_1Height */
-
-#ifndef NO_CommandBar_1InsertMenubarEx
-JNIEXPORT jboolean JNICALL OS_NATIVE(CommandBar_1InsertMenubarEx)
- (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jint arg3)
-{
- DEBUG_CALL("CommandBar_1InsertMenubarEx\n")
-
- return (jboolean)CommandBar_InsertMenubarEx((HWND)arg0, (HINSTANCE)arg1, (LPTSTR)arg2, (WORD)arg3);
-}
-#endif /* NO_CommandBar_1InsertMenubarEx */
-
-#ifndef NO_CommandBar_1Show
-JNIEXPORT jboolean JNICALL OS_NATIVE(CommandBar_1Show)
- (JNIEnv *env, jclass that, jint arg0, jboolean arg1)
-{
- DEBUG_CALL("CommandBar_1Show\n")
-
- return (jboolean)CommandBar_Show((HWND)arg0, (BOOL)arg1);
-}
-#endif /* NO_CommandBar_1Show */
-
-#ifndef NO_CopyImage
-JNIEXPORT jint JNICALL OS_NATIVE(CopyImage)
- (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jint arg3, jint arg4)
-{
- DEBUG_CALL("CopyImage\n")
-
- return (jint)CopyImage((HANDLE)arg0, arg1, arg2, arg3, arg4);
-}
-#endif /* NO_CopyImage */
-
-#ifndef NO_CreateAcceleratorTableA
-JNIEXPORT jint JNICALL OS_NATIVE(CreateAcceleratorTableA)
- (JNIEnv *env, jclass that, jbyteArray arg0, jint arg1)
-{
- jbyte *lparg0=NULL;
- jint rc;
-
- DEBUG_CALL("CreateAcceleratorTableA\n")
-
- if (arg0) lparg0 = (*env)->GetByteArrayElements(env, arg0, NULL);
- rc = (jint)CreateAcceleratorTableA((LPACCEL)lparg0, arg1);
- if (arg0) (*env)->ReleaseByteArrayElements(env, arg0, lparg0, 0);
- return rc;
-}
-#endif /* NO_CreateAcceleratorTableA */
-
-#ifndef NO_CreateAcceleratorTableW
-JNIEXPORT jint JNICALL OS_NATIVE(CreateAcceleratorTableW)
- (JNIEnv *env, jclass that, jbyteArray arg0, jint arg1)
-{
- jbyte *lparg0=NULL;
- jint rc;
-
- DEBUG_CALL("CreateAcceleratorTableW\n")
-
- if (arg0) lparg0 = (*env)->GetByteArrayElements(env, arg0, NULL);
- rc = (jint)CreateAcceleratorTableW((LPACCEL)lparg0, arg1);
- if (arg0) (*env)->ReleaseByteArrayElements(env, arg0, lparg0, 0);
- return rc;
-}
-#endif /* NO_CreateAcceleratorTableW */
-
-#ifndef NO_CreateBitmap
-JNIEXPORT jint JNICALL OS_NATIVE(CreateBitmap)
- (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jint arg3, jbyteArray arg4)
-{
- jbyte *lparg4=NULL;
- jint rc;
-
- DEBUG_CALL("CreateBitmap\n")
-
- if (arg4) lparg4 = (*env)->GetByteArrayElements(env, arg4, NULL);
- rc = (jint)CreateBitmap(arg0, arg1, arg2, arg3, (CONST VOID *)lparg4);
- if (arg4) (*env)->ReleaseByteArrayElements(env, arg4, lparg4, 0);
- return rc;
-}
-#endif /* NO_CreateBitmap */
-
-#ifndef NO_CreateCaret
-JNIEXPORT jboolean JNICALL OS_NATIVE(CreateCaret)
- (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jint arg3)
-{
- DEBUG_CALL("CreateCaret\n")
-
- return (jboolean)CreateCaret((HWND)arg0, (HBITMAP)arg1, arg2, arg3);
-}
-#endif /* NO_CreateCaret */
-
-#ifndef NO_CreateCompatibleBitmap
-JNIEXPORT jint JNICALL OS_NATIVE(CreateCompatibleBitmap)
- (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2)
-{
- DEBUG_CALL("CreateCompatibleBitmap\n")
-
- return (jint)CreateCompatibleBitmap((HDC)arg0, arg1, arg2);
-}
-#endif /* NO_CreateCompatibleBitmap */
-
-#ifndef NO_CreateCompatibleDC
-JNIEXPORT jint JNICALL OS_NATIVE(CreateCompatibleDC)
- (JNIEnv *env, jclass that, jint arg0)
-{
- DEBUG_CALL("CreateCompatibleDC\n")
-
- return (jint)CreateCompatibleDC((HDC)arg0);
-}
-#endif /* NO_CreateCompatibleDC */
-
-#ifndef NO_CreateCursor
-JNIEXPORT jint JNICALL OS_NATIVE(CreateCursor)
- (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jint arg3, jint arg4, jbyteArray arg5, jbyteArray arg6)
-{
- jbyte *lparg5=NULL;
- jbyte *lparg6=NULL;
- jint rc;
-
- DEBUG_CALL("CreateCursor\n")
-
- if (arg5) lparg5 = (*env)->GetByteArrayElements(env, arg5, NULL);
- if (arg6) lparg6 = (*env)->GetByteArrayElements(env, arg6, NULL);
- rc = (jint)CreateCursor((HINSTANCE)arg0, arg1, arg2, arg3, arg4, (CONST VOID *)lparg5, (CONST VOID *)lparg6);
- if (arg5) (*env)->ReleaseByteArrayElements(env, arg5, lparg5, 0);
- if (arg6) (*env)->ReleaseByteArrayElements(env, arg6, lparg6, 0);
- return rc;
-}
-#endif /* NO_CreateCursor */
-
-#ifndef NO_CreateDCA
-JNIEXPORT jint JNICALL OS_NATIVE(CreateDCA)
- (JNIEnv *env, jclass that, jbyteArray arg0, jbyteArray arg1, jint arg2, jint arg3)
-{
- jbyte *lparg0=NULL;
- jbyte *lparg1=NULL;
- jint rc;
-
- DEBUG_CALL("CreateDCA\n")
-
- if (arg0) lparg0 = (*env)->GetByteArrayElements(env, arg0, NULL);
- if (arg1) lparg1 = (*env)->GetByteArrayElements(env, arg1, NULL);
- rc = (jint)CreateDCA((LPSTR)lparg0, (LPSTR)lparg1, (LPSTR)arg2, (CONST DEVMODE *)arg3);
- if (arg0) (*env)->ReleaseByteArrayElements(env, arg0, lparg0, 0);
- if (arg1) (*env)->ReleaseByteArrayElements(env, arg1, lparg1, 0);
- return rc;
-}
-#endif /* NO_CreateDCA */
-
-#ifndef NO_CreateDCW
-JNIEXPORT jint JNICALL OS_NATIVE(CreateDCW)
- (JNIEnv *env, jclass that, jcharArray arg0, jcharArray arg1, jint arg2, jint arg3)
-{
- jchar *lparg0=NULL;
- jchar *lparg1=NULL;
- jint rc;
-
- DEBUG_CALL("CreateDCW\n")
-
- if (arg0) lparg0 = (*env)->GetCharArrayElements(env, arg0, NULL);
- if (arg1) lparg1 = (*env)->GetCharArrayElements(env, arg1, NULL);
- rc = (jint)CreateDCW((LPWSTR)lparg0, (LPWSTR)lparg1, (LPWSTR)arg2, (CONST DEVMODEW *)arg3);
- if (arg0) (*env)->ReleaseCharArrayElements(env, arg0, lparg0, 0);
- if (arg1) (*env)->ReleaseCharArrayElements(env, arg1, lparg1, 0);
- return rc;
-}
-#endif /* NO_CreateDCW */
-
-#ifndef NO_CreateDIBSection
-JNIEXPORT jint JNICALL OS_NATIVE(CreateDIBSection)
- (JNIEnv *env, jclass that, jint arg0, jbyteArray arg1, jint arg2, jintArray arg3, jint arg4, jint arg5)
-{
- jbyte *lparg1=NULL;
- jint *lparg3=NULL;
- jint rc;
-
- DEBUG_CALL("CreateDIBSection\n")
-
- if (arg1) lparg1 = (*env)->GetByteArrayElements(env, arg1, NULL);
- if (arg3) lparg3 = (*env)->GetIntArrayElements(env, arg3, NULL);
- rc = (jint)CreateDIBSection((HDC)arg0, (BITMAPINFO *)lparg1, arg2, (VOID **)lparg3, (HANDLE)arg4, arg5);
- if (arg1) (*env)->ReleaseByteArrayElements(env, arg1, lparg1, 0);
- if (arg3) (*env)->ReleaseIntArrayElements(env, arg3, lparg3, 0);
- return rc;
-}
-#endif /* NO_CreateDIBSection */
-
-#ifndef NO_CreateFontIndirectA__Lorg_eclipse_swt_internal_win32_LOGFONT_2
-JNIEXPORT jint JNICALL OS_NATIVE(CreateFontIndirectA__Lorg_eclipse_swt_internal_win32_LOGFONT_2)
- (JNIEnv *env, jclass that, jobject arg0)
-{
- LOGFONTA _arg0, *lparg0=NULL;
- jint rc;
-
- DEBUG_CALL("CreateFontIndirectA__Lorg_eclipse_swt_internal_win32_LOGFONT_2\n")
-
- if (arg0) lparg0 = getLOGFONTAFields(env, arg0, &_arg0);
- rc = (jint)CreateFontIndirectA(lparg0);
- if (arg0) setLOGFONTAFields(env, arg0, lparg0);
- return rc;
-}
-#endif /* NO_CreateFontIndirectA__Lorg_eclipse_swt_internal_win32_LOGFONT_2 */
-
-#ifndef NO_CreateFontIndirectA__I
-JNIEXPORT jint JNICALL OS_NATIVE(CreateFontIndirectA__I)
- (JNIEnv *env, jclass that, jint arg0)
-{
- DEBUG_CALL("CreateFontIndirectA__I\n")
-
- return (jint)CreateFontIndirectA((LPLOGFONTA)arg0);
-}
-#endif /* NO_CreateFontIndirectA__I */
-
-#ifndef NO_CreateFontIndirectW__Lorg_eclipse_swt_internal_win32_LOGFONT_2
-JNIEXPORT jint JNICALL OS_NATIVE(CreateFontIndirectW__Lorg_eclipse_swt_internal_win32_LOGFONT_2)
- (JNIEnv *env, jclass that, jobject arg0)
-{
- LOGFONTW _arg0, *lparg0=NULL;
- jint rc;
-
- DEBUG_CALL("CreateFontIndirectW__Lorg_eclipse_swt_internal_win32_LOGFONT_2\n")
-
- if (arg0) lparg0 = getLOGFONTWFields(env, arg0, &_arg0);
- rc = (jint)CreateFontIndirectW(lparg0);
- if (arg0) setLOGFONTWFields(env, arg0, lparg0);
- return rc;
-}
-#endif /* NO_CreateFontIndirectW__Lorg_eclipse_swt_internal_win32_LOGFONT_2 */
-
-#ifndef NO_CreateFontIndirectW__I
-JNIEXPORT jint JNICALL OS_NATIVE(CreateFontIndirectW__I)
- (JNIEnv *env, jclass that, jint arg0)
-{
- DEBUG_CALL("CreateFontIndirectW__I\n")
-
- return (jint)CreateFontIndirectW((LPLOGFONTW)arg0);
-}
-#endif /* NO_CreateFontIndirectW__I */
-
-#ifndef NO_CreateIconIndirect
-JNIEXPORT jint JNICALL OS_NATIVE(CreateIconIndirect)
- (JNIEnv *env, jclass that, jobject arg0)
-{
- ICONINFO _arg0, *lparg0=NULL;
- jint rc;
-
- DEBUG_CALL("CreateIconIndirect\n")
-
- if (arg0) lparg0 = getICONINFOFields(env, arg0, &_arg0);
- rc = (jint)CreateIconIndirect(lparg0);
- if (arg0) setICONINFOFields(env, arg0, lparg0);
- return rc;
-}
-#endif /* NO_CreateIconIndirect */
-
-#ifndef NO_CreateMenu
-JNIEXPORT jint JNICALL OS_NATIVE(CreateMenu)
- (JNIEnv *env, jclass that)
-{
- DEBUG_CALL("CreateMenu\n")
-
- return (jint)CreateMenu();
-}
-#endif /* NO_CreateMenu */
-
-#ifndef NO_CreatePalette
-JNIEXPORT jint JNICALL OS_NATIVE(CreatePalette)
- (JNIEnv *env, jclass that, jbyteArray arg0)
-{
- jbyte *lparg0=NULL;
- jint rc;
-
- DEBUG_CALL("CreatePalette\n")
-
- if (arg0) lparg0 = (*env)->GetByteArrayElements(env, arg0, NULL);
- rc = (jint)CreatePalette((LOGPALETTE *)lparg0);
- if (arg0) (*env)->ReleaseByteArrayElements(env, arg0, lparg0, 0);
- return rc;
-}
-#endif /* NO_CreatePalette */
-
-#ifndef NO_CreatePatternBrush
-JNIEXPORT jint JNICALL OS_NATIVE(CreatePatternBrush)
- (JNIEnv *env, jclass that, jint arg0)
-{
- DEBUG_CALL("CreatePatternBrush\n")
-
- return (jint)CreatePatternBrush((HBITMAP)arg0);
-}
-#endif /* NO_CreatePatternBrush */
-
-#ifndef NO_CreatePen
-JNIEXPORT jint JNICALL OS_NATIVE(CreatePen)
- (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2)
-{
- DEBUG_CALL("CreatePen\n")
-
- return (jint)CreatePen(arg0, arg1, (COLORREF)arg2);
-}
-#endif /* NO_CreatePen */
-
-#ifndef NO_CreatePopupMenu
-JNIEXPORT jint JNICALL OS_NATIVE(CreatePopupMenu)
- (JNIEnv *env, jclass that)
-{
- DEBUG_CALL("CreatePopupMenu\n")
-
- return (jint)CreatePopupMenu();
-}
-#endif /* NO_CreatePopupMenu */
-
-#ifndef NO_CreateRectRgn
-JNIEXPORT jint JNICALL OS_NATIVE(CreateRectRgn)
- (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jint arg3)
-{
- DEBUG_CALL("CreateRectRgn\n")
-
- return (jint)CreateRectRgn(arg0, arg1, arg2, arg3);
-}
-#endif /* NO_CreateRectRgn */
-
-#ifndef NO_CreateSolidBrush
-JNIEXPORT jint JNICALL OS_NATIVE(CreateSolidBrush)
- (JNIEnv *env, jclass that, jint arg0)
-{
- DEBUG_CALL("CreateSolidBrush\n")
-
- return (jint)CreateSolidBrush((COLORREF)arg0);
-}
-#endif /* NO_CreateSolidBrush */
-
-#ifndef NO_CreateWindowExA
-JNIEXPORT jint JNICALL OS_NATIVE(CreateWindowExA)
- (JNIEnv *env, jclass that, jint arg0, jbyteArray arg1, jbyteArray arg2, jint arg3, jint arg4, jint arg5, jint arg6, jint arg7, jint arg8, jint arg9, jint arg10, jobject arg11)
-{
- jbyte *lparg1=NULL;
- jbyte *lparg2=NULL;
- CREATESTRUCT _arg11, *lparg11=NULL;
- jint rc;
-
- DEBUG_CALL("CreateWindowExA\n")
-
- if (arg1) lparg1 = (*env)->GetByteArrayElements(env, arg1, NULL);
- if (arg2) lparg2 = (*env)->GetByteArrayElements(env, arg2, NULL);
- if (arg11) lparg11 = getCREATESTRUCTFields(env, arg11, &_arg11);
- rc = (jint)CreateWindowExA(arg0, (LPSTR)lparg1, lparg2, arg3, arg4, arg5, arg6, arg7, (HWND)arg8, (HMENU)arg9, (HINSTANCE)arg10, lparg11);
- if (arg1) (*env)->ReleaseByteArrayElements(env, arg1, lparg1, 0);
- if (arg2) (*env)->ReleaseByteArrayElements(env, arg2, lparg2, 0);
- if (arg11) setCREATESTRUCTFields(env, arg11, lparg11);
- return rc;
-}
-#endif /* NO_CreateWindowExA */
-
-#ifndef NO_CreateWindowExW
-JNIEXPORT jint JNICALL OS_NATIVE(CreateWindowExW)
- (JNIEnv *env, jclass that, jint arg0, jcharArray arg1, jcharArray arg2, jint arg3, jint arg4, jint arg5, jint arg6, jint arg7, jint arg8, jint arg9, jint arg10, jobject arg11)
-{
- jchar *lparg1=NULL;
- jchar *lparg2=NULL;
- CREATESTRUCT _arg11, *lparg11=NULL;
- jint rc;
-
- DEBUG_CALL("CreateWindowExW\n")
-
- if (arg1) lparg1 = (*env)->GetCharArrayElements(env, arg1, NULL);
- if (arg2) lparg2 = (*env)->GetCharArrayElements(env, arg2, NULL);
- if (arg11) lparg11 = getCREATESTRUCTFields(env, arg11, &_arg11);
- rc = (jint)CreateWindowExW(arg0, (LPWSTR)lparg1, (LPWSTR)lparg2, arg3, arg4, arg5, arg6, arg7, (HWND)arg8, (HMENU)arg9, (HINSTANCE)arg10, lparg11);
- if (arg1) (*env)->ReleaseCharArrayElements(env, arg1, lparg1, 0);
- if (arg2) (*env)->ReleaseCharArrayElements(env, arg2, lparg2, 0);
- if (arg11) setCREATESTRUCTFields(env, arg11, lparg11);
- return rc;
-}
-#endif /* NO_CreateWindowExW */
-
-#ifndef NO_DefWindowProcA
-JNIEXPORT jint JNICALL OS_NATIVE(DefWindowProcA)
- (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jint arg3)
-{
- DEBUG_CALL("DefWindowProcA\n")
-
- return (jint)DefWindowProcA((HWND)arg0, arg1, (WPARAM)arg2, (LPARAM)arg3);
-}
-#endif /* NO_DefWindowProcA */
-
-#ifndef NO_DefWindowProcW
-JNIEXPORT jint JNICALL OS_NATIVE(DefWindowProcW)
- (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jint arg3)
-{
- DEBUG_CALL("DefWindowProcW\n")
-
- return (jint)DefWindowProcW((HWND)arg0, arg1, (WPARAM)arg2, (LPARAM)arg3);
-}
-#endif /* NO_DefWindowProcW */
-
-#ifndef NO_DeferWindowPos
-JNIEXPORT jint JNICALL OS_NATIVE(DeferWindowPos)
- (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jint arg3, jint arg4, jint arg5, jint arg6, jint arg7)
-{
- DEBUG_CALL("DeferWindowPos\n")
-
- return (jint)DeferWindowPos((HDWP)arg0, (HWND)arg1, (HWND)arg2, arg3, arg4, arg5, arg6, arg7);
-}
-#endif /* NO_DeferWindowPos */
-
-#ifndef NO_DeleteDC
-JNIEXPORT jboolean JNICALL OS_NATIVE(DeleteDC)
- (JNIEnv *env, jclass that, jint arg0)
-{
- DEBUG_CALL("DeleteDC\n")
-
- return (jboolean)DeleteDC((HDC)arg0);
-}
-#endif /* NO_DeleteDC */
-
-#ifndef NO_DeleteMenu
-JNIEXPORT jboolean JNICALL OS_NATIVE(DeleteMenu)
- (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2)
-{
- DEBUG_CALL("DeleteMenu\n")
-
- return (jboolean)DeleteMenu((HMENU)arg0, arg1, arg2);
-}
-#endif /* NO_DeleteMenu */
-
-#ifndef NO_DeleteObject
-JNIEXPORT jboolean JNICALL OS_NATIVE(DeleteObject)
- (JNIEnv *env, jclass that, jint arg0)
-{
- DEBUG_CALL("DeleteObject\n")
-
- return (jboolean)DeleteObject((HGDIOBJ)arg0);
-}
-#endif /* NO_DeleteObject */
-
-#ifndef NO_DestroyAcceleratorTable
-JNIEXPORT jboolean JNICALL OS_NATIVE(DestroyAcceleratorTable)
- (JNIEnv *env, jclass that, jint arg0)
-{
- DEBUG_CALL("DestroyAcceleratorTable\n")
-
- return (jboolean)DestroyAcceleratorTable((HACCEL)arg0);
-}
-#endif /* NO_DestroyAcceleratorTable */
-
-#ifndef NO_DestroyCaret
-JNIEXPORT jboolean JNICALL OS_NATIVE(DestroyCaret)
- (JNIEnv *env, jclass that)
-{
- DEBUG_CALL("DestroyCaret\n")
-
- return (jboolean)DestroyCaret();
-}
-#endif /* NO_DestroyCaret */
-
-#ifndef NO_DestroyCursor
-JNIEXPORT jboolean JNICALL OS_NATIVE(DestroyCursor)
- (JNIEnv *env, jclass that, jint arg0)
-{
- DEBUG_CALL("DestroyCursor\n")
-
- return (jboolean)DestroyCursor((HCURSOR)arg0);
-}
-#endif /* NO_DestroyCursor */
-
-#ifndef NO_DestroyIcon
-JNIEXPORT jboolean JNICALL OS_NATIVE(DestroyIcon)
- (JNIEnv *env, jclass that, jint arg0)
-{
- DEBUG_CALL("DestroyIcon\n")
-
- return (jboolean)DestroyIcon((HICON)arg0);
-}
-#endif /* NO_DestroyIcon */
-
-#ifndef NO_DestroyMenu
-JNIEXPORT jboolean JNICALL OS_NATIVE(DestroyMenu)
- (JNIEnv *env, jclass that, jint arg0)
-{
- DEBUG_CALL("DestroyMenu\n")
-
- return (jboolean)DestroyMenu((HMENU)arg0);
-}
-#endif /* NO_DestroyMenu */
-
-#ifndef NO_DestroyWindow
-JNIEXPORT jboolean JNICALL OS_NATIVE(DestroyWindow)
- (JNIEnv *env, jclass that, jint arg0)
-{
- DEBUG_CALL("DestroyWindow\n")
-
- return (jboolean)DestroyWindow((HWND)arg0);
-}
-#endif /* NO_DestroyWindow */
-
-#ifndef NO_DispatchMessageA
-JNIEXPORT jint JNICALL OS_NATIVE(DispatchMessageA)
- (JNIEnv *env, jclass that, jobject arg0)
-{
- MSG _arg0, *lparg0=NULL;
-
- DEBUG_CALL("DispatchMessageA\n")
-
- if (arg0) lparg0 = getMSGFields(env, arg0, &_arg0);
- return (jint)DispatchMessageA(lparg0);
-}
-#endif /* NO_DispatchMessageA */
-
-#ifndef NO_DispatchMessageW
-JNIEXPORT jint JNICALL OS_NATIVE(DispatchMessageW)
- (JNIEnv *env, jclass that, jobject arg0)
-{
- MSG _arg0, *lparg0=NULL;
-
- DEBUG_CALL("DispatchMessageW\n")
-
- if (arg0) lparg0 = getMSGFields(env, arg0, &_arg0);
- return (jint)DispatchMessageW(lparg0);
-}
-#endif /* NO_DispatchMessageW */
-
-#ifndef NO_DragDetect
-JNIEXPORT jboolean JNICALL OS_NATIVE(DragDetect)
- (JNIEnv *env, jclass that, jint arg0, jobject arg1)
-{
- POINT _arg1, *lparg1=NULL;
-
- DEBUG_CALL("DragDetect\n")
-
- if (arg1) lparg1 = getPOINTFields(env, arg1, &_arg1);
- return (jboolean)DragDetect((HWND)arg0, *lparg1);
-}
-#endif /* NO_DragDetect */
-
-#ifndef NO_DragFinish
-JNIEXPORT void JNICALL OS_NATIVE(DragFinish)
- (JNIEnv *env, jclass that, jint arg0)
-{
- DEBUG_CALL("DragFinish\n")
-
- DragFinish((HDROP)arg0);
-}
-#endif /* NO_DragFinish */
-
-#ifndef NO_DragQueryFileA
-JNIEXPORT jint JNICALL OS_NATIVE(DragQueryFileA)
- (JNIEnv *env, jclass that, jint arg0, jint arg1, jbyteArray arg2, jint arg3)
-{
- jbyte *lparg2=NULL;
- jint rc;
-
- DEBUG_CALL("DragQueryFileA\n")
-
- if (arg2) lparg2 = (*env)->GetByteArrayElements(env, arg2, NULL);
- rc = (jint)DragQueryFileA((HDROP)arg0, arg1, (LPTSTR)lparg2, arg3);
- if (arg2) (*env)->ReleaseByteArrayElements(env, arg2, lparg2, 0);
- return rc;
-}
-#endif /* NO_DragQueryFileA */
-
-#ifndef NO_DragQueryFileW
-JNIEXPORT jint JNICALL OS_NATIVE(DragQueryFileW)
- (JNIEnv *env, jclass that, jint arg0, jint arg1, jcharArray arg2, jint arg3)
-{
- jchar *lparg2=NULL;
- jint rc;
-
- DEBUG_CALL("DragQueryFileW\n")
-
- if (arg2) lparg2 = (*env)->GetCharArrayElements(env, arg2, NULL);
- rc = (jint)DragQueryFileW((HDROP)arg0, arg1, (LPWSTR)lparg2, arg3);
- if (arg2) (*env)->ReleaseCharArrayElements(env, arg2, lparg2, 0);
- return rc;
-}
-#endif /* NO_DragQueryFileW */
-
-#ifndef NO_DrawEdge
-JNIEXPORT jboolean JNICALL OS_NATIVE(DrawEdge)
- (JNIEnv *env, jclass that, jint arg0, jobject arg1, jint arg2, jint arg3)
-{
- RECT _arg1, *lparg1=NULL;
- jboolean rc;
-
- DEBUG_CALL("DrawEdge\n")
-
- if (arg1) lparg1 = getRECTFields(env, arg1, &_arg1);
- rc = (jboolean)DrawEdge((HDC)arg0, lparg1, arg2, arg3);
- if (arg1) setRECTFields(env, arg1, lparg1);
- return rc;
-}
-#endif /* NO_DrawEdge */
-
-#ifndef NO_DrawFocusRect
-JNIEXPORT jboolean JNICALL OS_NATIVE(DrawFocusRect)
- (JNIEnv *env, jclass that, jint arg0, jobject arg1)
-{
- RECT _arg1, *lparg1=NULL;
- jboolean rc;
-
- DEBUG_CALL("DrawFocusRect\n")
-
- if (arg1) lparg1 = getRECTFields(env, arg1, &_arg1);
- rc = (jboolean)DrawFocusRect((HDC)arg0, lparg1);
- if (arg1) setRECTFields(env, arg1, lparg1);
- return rc;
-}
-#endif /* NO_DrawFocusRect */
-
-#ifndef NO_DrawFrameControl
-JNIEXPORT jboolean JNICALL OS_NATIVE(DrawFrameControl)
- (JNIEnv *env, jclass that, jint arg0, jobject arg1, jint arg2, jint arg3)
-{
- RECT _arg1, *lparg1=NULL;
- jboolean rc;
-
- DEBUG_CALL("DrawFrameControl\n")
-
- if (arg1) lparg1 = getRECTFields(env, arg1, &_arg1);
- rc = (jboolean)DrawFrameControl((HDC)arg0, lparg1, arg2, arg3);
- if (arg1) setRECTFields(env, arg1, lparg1);
- return rc;
-}
-#endif /* NO_DrawFrameControl */
-
-#ifndef NO_DrawIconEx
-JNIEXPORT jboolean JNICALL OS_NATIVE(DrawIconEx)
- (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jint arg3, jint arg4, jint arg5, jint arg6, jint arg7, jint arg8)
-{
- DEBUG_CALL("DrawIconEx\n")
-
- return (jboolean)DrawIconEx((HDC)arg0, arg1, arg2, (HICON)arg3, arg4, arg5, arg6, (HBRUSH)arg7, arg8);
-}
-#endif /* NO_DrawIconEx */
-
-#ifndef NO_DrawMenuBar
-JNIEXPORT jboolean JNICALL OS_NATIVE(DrawMenuBar)
- (JNIEnv *env, jclass that, jint arg0)
-{
- DEBUG_CALL("DrawMenuBar\n")
-
- return (jboolean)DrawMenuBar((HWND)arg0);
-}
-#endif /* NO_DrawMenuBar */
-
-#ifndef NO_DrawStateA
-JNIEXPORT jboolean JNICALL OS_NATIVE(DrawStateA)
- (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jint arg3, jint arg4, jint arg5, jint arg6, jint arg7, jint arg8, jint arg9)
-{
- DEBUG_CALL("DrawStateA\n")
-
- return (jboolean)DrawStateA((HDC)arg0, (HBRUSH)arg1, (DRAWSTATEPROC)arg2, (LPARAM)arg3, (WPARAM)arg4, arg5, arg6, arg7, arg8, arg9);
-}
-#endif /* NO_DrawStateA */
-
-#ifndef NO_DrawStateW
-JNIEXPORT jboolean JNICALL OS_NATIVE(DrawStateW)
- (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jint arg3, jint arg4, jint arg5, jint arg6, jint arg7, jint arg8, jint arg9)
-{
- DEBUG_CALL("DrawStateW\n")
-
- return (jboolean)DrawStateW((HDC)arg0, (HBRUSH)arg1, (DRAWSTATEPROC)arg2, (LPARAM)arg3, (WPARAM)arg4, arg5, arg6, arg7, arg8, arg9);
-}
-#endif /* NO_DrawStateW */
-
-#ifndef NO_DrawTextA
-JNIEXPORT jint JNICALL OS_NATIVE(DrawTextA)
- (JNIEnv *env, jclass that, jint arg0, jbyteArray arg1, jint arg2, jobject arg3, jint arg4)
-{
- jbyte *lparg1=NULL;
- RECT _arg3, *lparg3=NULL;
- jint rc;
-
- DEBUG_CALL("DrawTextA\n")
-
- if (arg1) lparg1 = (*env)->GetByteArrayElements(env, arg1, NULL);
- if (arg3) lparg3 = getRECTFields(env, arg3, &_arg3);
- rc = (jint)DrawTextA((HDC)arg0, (LPSTR)lparg1, arg2, lparg3, arg4);
- if (arg1) (*env)->ReleaseByteArrayElements(env, arg1, lparg1, 0);
- if (arg3) setRECTFields(env, arg3, lparg3);
- return rc;
-}
-#endif /* NO_DrawTextA */
-
-#ifndef NO_DrawTextW
-JNIEXPORT jint JNICALL OS_NATIVE(DrawTextW)
- (JNIEnv *env, jclass that, jint arg0, jcharArray arg1, jint arg2, jobject arg3, jint arg4)
-{
- jchar *lparg1=NULL;
- RECT _arg3, *lparg3=NULL;
- jint rc;
-
- DEBUG_CALL("DrawTextW\n")
-
- if (arg1) lparg1 = (*env)->GetCharArrayElements(env, arg1, NULL);
- if (arg3) lparg3 = getRECTFields(env, arg3, &_arg3);
- rc = (jint)DrawTextW((HDC)arg0, (LPWSTR)lparg1, arg2, lparg3, arg4);
- if (arg1) (*env)->ReleaseCharArrayElements(env, arg1, lparg1, 0);
- if (arg3) setRECTFields(env, arg3, lparg3);
- return rc;
-}
-#endif /* NO_DrawTextW */
-
-#ifndef NO_Ellipse
-JNIEXPORT jboolean JNICALL OS_NATIVE(Ellipse)
- (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jint arg3, jint arg4)
-{
- DEBUG_CALL("Ellipse\n")
-
- return (jboolean)Ellipse((HDC)arg0, arg1, arg2, arg3, arg4);
-}
-#endif /* NO_Ellipse */
-
-#ifndef NO_EnableMenuItem
-JNIEXPORT jboolean JNICALL OS_NATIVE(EnableMenuItem)
- (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2)
-{
- DEBUG_CALL("EnableMenuItem\n")
-
- return (jboolean)EnableMenuItem((HMENU)arg0, arg1, arg2);
-}
-#endif /* NO_EnableMenuItem */
-
-#ifndef NO_EnableScrollBar
-JNIEXPORT jboolean JNICALL OS_NATIVE(EnableScrollBar)
- (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2)
-{
- DEBUG_CALL("EnableScrollBar\n")
-
- return (jboolean)EnableScrollBar((HWND)arg0, arg1, arg2);
-}
-#endif /* NO_EnableScrollBar */
-
-#ifndef NO_EnableWindow
-JNIEXPORT jboolean JNICALL OS_NATIVE(EnableWindow)
- (JNIEnv *env, jclass that, jint arg0, jboolean arg1)
-{
- DEBUG_CALL("EnableWindow\n")
-
- return (jboolean)EnableWindow((HWND)arg0, arg1);
-}
-#endif /* NO_EnableWindow */
-
-#ifndef NO_EndDeferWindowPos
-JNIEXPORT jboolean JNICALL OS_NATIVE(EndDeferWindowPos)
- (JNIEnv *env, jclass that, jint arg0)
-{
- DEBUG_CALL("EndDeferWindowPos\n")
-
- return (jboolean)EndDeferWindowPos((HDWP)arg0);
-}
-#endif /* NO_EndDeferWindowPos */
-
-#ifndef NO_EndDoc
-JNIEXPORT jint JNICALL OS_NATIVE(EndDoc)
- (JNIEnv *env, jclass that, jint arg0)
-{
- DEBUG_CALL("EndDoc\n")
-
- return (jint)EndDoc((HDC)arg0);
-}
-#endif /* NO_EndDoc */
-
-#ifndef NO_EndPage
-JNIEXPORT jint JNICALL OS_NATIVE(EndPage)
- (JNIEnv *env, jclass that, jint arg0)
-{
- DEBUG_CALL("EndPage\n")
-
- return (jint)EndPage((HDC)arg0);
-}
-#endif /* NO_EndPage */
-
-#ifndef NO_EndPaint
-JNIEXPORT jint JNICALL OS_NATIVE(EndPaint)
- (JNIEnv *env, jclass that, jint arg0, jobject arg1)
-{
- PAINTSTRUCT _arg1, *lparg1=NULL;
-
- DEBUG_CALL("EndPaint\n")
-
- if (arg1) lparg1 = getPAINTSTRUCTFields(env, arg1, &_arg1);
- return (jint)EndPaint((HWND)arg0, lparg1);
-}
-#endif /* NO_EndPaint */
-
-#ifndef NO_EnumFontFamiliesA
-JNIEXPORT jint JNICALL OS_NATIVE(EnumFontFamiliesA)
- (JNIEnv *env, jclass that, jint arg0, jbyteArray arg1, jint arg2, jint arg3)
-{
- jbyte *lparg1=NULL;
- jint rc;
-
- DEBUG_CALL("EnumFontFamiliesA\n")
-
- if (arg1) lparg1 = (*env)->GetByteArrayElements(env, arg1, NULL);
- rc = (jint)EnumFontFamiliesA((HDC)arg0, (LPSTR)lparg1, (FONTENUMPROC)arg2, (LPARAM)arg3);
- if (arg1) (*env)->ReleaseByteArrayElements(env, arg1, lparg1, 0);
- return rc;
-}
-#endif /* NO_EnumFontFamiliesA */
-
-#ifndef NO_EnumFontFamiliesW
-JNIEXPORT jint JNICALL OS_NATIVE(EnumFontFamiliesW)
- (JNIEnv *env, jclass that, jint arg0, jcharArray arg1, jint arg2, jint arg3)
-{
- jchar *lparg1=NULL;
- jint rc;
-
- DEBUG_CALL("EnumFontFamiliesW\n")
-
- if (arg1) lparg1 = (*env)->GetCharArrayElements(env, arg1, NULL);
- rc = (jint)EnumFontFamiliesW((HDC)arg0, (LPCWSTR)lparg1, (FONTENUMPROCW)arg2, (LPARAM)arg3);
- if (arg1) (*env)->ReleaseCharArrayElements(env, arg1, lparg1, 0);
- return rc;
-}
-#endif /* NO_EnumFontFamiliesW */
-
-#ifndef NO_EnumSystemLanguageGroupsA
-JNIEXPORT jboolean JNICALL OS_NATIVE(EnumSystemLanguageGroupsA)
- (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2)
-{
- HMODULE hm;
- FARPROC fp;
-
- DEBUG_CALL("EnumSystemLanguageGroupsA\n")
-
- /* SPECIAL */
- /*
- * EnumSystemLanguageGroupsA is a Win2000 or later 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("kernel32.dll")) && (fp=GetProcAddress(hm, "EnumSystemLanguageGroupsA"))) {
-
- return (jboolean)(fp)((LANGUAGEGROUP_ENUMPROCA)arg0, arg1, (LONG_PTR)arg2);
-// return (jboolean)EnumSystemLanguageGroupsA((LANGUAGEGROUP_ENUMPROCA)arg0, arg1, (LONG_PTR)arg2);
- }
- return 0;
-}
-#endif /* NO_EnumSystemLanguageGroupsA */
-
-#ifndef NO_EnumSystemLanguageGroupsW
-JNIEXPORT jboolean JNICALL OS_NATIVE(EnumSystemLanguageGroupsW)
- (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2)
-{
- HMODULE hm;
- FARPROC fp;
-
- DEBUG_CALL("EnumSystemLanguageGroupsW\n")
-
- /* SPECIAL */
- /*
- * EnumSystemLanguageGroupsW is a Win2000 or later 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("kernel32.dll")) && (fp=GetProcAddress(hm, "EnumSystemLanguageGroupsW"))) {
-
- return (jboolean)(fp)((LANGUAGEGROUP_ENUMPROCW)arg0, arg1, (LONG_PTR)arg2);
-// return (jboolean)EnumSystemLanguageGroupsW((LANGUAGEGROUP_ENUMPROCW)arg0, arg1, (LONG_PTR)arg2);
- }
- return 0;
-}
-#endif /* NO_EnumSystemLanguageGroupsW */
-
-#ifndef NO_EnumSystemLocalesA
-JNIEXPORT jboolean JNICALL OS_NATIVE(EnumSystemLocalesA)
- (JNIEnv *env, jclass that, jint arg0, jint arg1)
-{
- DEBUG_CALL("EnumSystemLocalesA\n")
-
- return (jboolean)EnumSystemLocalesA((LOCALE_ENUMPROCA)arg0, arg1);
-}
-#endif /* NO_EnumSystemLocalesA */
-
-#ifndef NO_EnumSystemLocalesW
-JNIEXPORT jboolean JNICALL OS_NATIVE(EnumSystemLocalesW)
- (JNIEnv *env, jclass that, jint arg0, jint arg1)
-{
- DEBUG_CALL("EnumSystemLocalesW\n")
-
- return (jboolean)EnumSystemLocalesW((LOCALE_ENUMPROCW)arg0, arg1);
-}
-#endif /* NO_EnumSystemLocalesW */
-
-#ifndef NO_EqualRect
-JNIEXPORT jboolean JNICALL OS_NATIVE(EqualRect)
- (JNIEnv *env, jclass that, jobject arg0, jobject arg1)
-{
- RECT _arg0, *lparg0=NULL;
- RECT _arg1, *lparg1=NULL;
-
- DEBUG_CALL("EqualRect\n")
-
- if (arg0) lparg0 = getRECTFields(env, arg0, &_arg0);
- if (arg1) lparg1 = getRECTFields(env, arg1, &_arg1);
- return (jboolean)EqualRect((CONST RECT *)lparg0, (CONST RECT *)lparg1);
-}
-#endif /* NO_EqualRect */
-
-#ifndef NO_EqualRgn
-JNIEXPORT jboolean JNICALL OS_NATIVE(EqualRgn)
- (JNIEnv *env, jclass that, jint arg0, jint arg1)
-{
- DEBUG_CALL("EqualRgn\n")
-
- return (jboolean)EqualRgn((HRGN)arg0, (HRGN)arg1);
-}
-#endif /* NO_EqualRgn */
-
-#ifndef NO_ExpandEnvironmentStringsA
-JNIEXPORT jint JNICALL OS_NATIVE(ExpandEnvironmentStringsA)
- (JNIEnv *env, jclass that, jbyteArray arg0, jbyteArray arg1, jint arg2)
-{
- jbyte *lparg0=NULL;
- jbyte *lparg1=NULL;
- jint rc;
-
- DEBUG_CALL("ExpandEnvironmentStringsA\n")
-
- if (arg0) lparg0 = (*env)->GetByteArrayElements(env, arg0, NULL);
- if (arg1) lparg1 = (*env)->GetByteArrayElements(env, arg1, NULL);
- rc = (jint)ExpandEnvironmentStringsA(lparg0, lparg1, arg2);
- if (arg0) (*env)->ReleaseByteArrayElements(env, arg0, lparg0, 0);
- if (arg1) (*env)->ReleaseByteArrayElements(env, arg1, lparg1, 0);
- return rc;
-}
-#endif /* NO_ExpandEnvironmentStringsA */
-
-#ifndef NO_ExpandEnvironmentStringsW
-JNIEXPORT jint JNICALL OS_NATIVE(ExpandEnvironmentStringsW)
- (JNIEnv *env, jclass that, jcharArray arg0, jcharArray arg1, jint arg2)
-{
- jchar *lparg0=NULL;
- jchar *lparg1=NULL;
- jint rc;
-
- DEBUG_CALL("ExpandEnvironmentStringsW\n")
-
- if (arg0) lparg0 = (*env)->GetCharArrayElements(env, arg0, NULL);
- if (arg1) lparg1 = (*env)->GetCharArrayElements(env, arg1, NULL);
- rc = (jint)ExpandEnvironmentStringsW(lparg0, lparg1, arg2);
- if (arg0) (*env)->ReleaseCharArrayElements(env, arg0, lparg0, 0);
- if (arg1) (*env)->ReleaseCharArrayElements(env, arg1, lparg1, 0);
- return rc;
-}
-#endif /* NO_ExpandEnvironmentStringsW */
-
-#ifndef NO_ExtTextOutA
-JNIEXPORT jboolean JNICALL OS_NATIVE(ExtTextOutA)
- (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jint arg3, jobject arg4, jbyteArray arg5, jint arg6, jintArray arg7)
-{
- RECT _arg4, *lparg4=NULL;
- jbyte *lparg5=NULL;
- jint *lparg7=NULL;
- jboolean rc;
-
- DEBUG_CALL("ExtTextOutA\n")
-
- if (arg4) lparg4 = getRECTFields(env, arg4, &_arg4);
- if (arg5) lparg5 = (*env)->GetByteArrayElements(env, arg5, NULL);
- if (arg7) lparg7 = (*env)->GetIntArrayElements(env, arg7, NULL);
- rc = (jboolean)ExtTextOutA((HDC)arg0, arg1, arg2, arg3, lparg4, (LPSTR)lparg5, arg6, (CONST INT *)lparg7);
- if (arg4) setRECTFields(env, arg4, lparg4);
- if (arg5) (*env)->ReleaseByteArrayElements(env, arg5, lparg5, 0);
- if (arg7) (*env)->ReleaseIntArrayElements(env, arg7, lparg7, 0);
- return rc;
-}
-#endif /* NO_ExtTextOutA */
-
-#ifndef NO_ExtTextOutW
-JNIEXPORT jboolean JNICALL OS_NATIVE(ExtTextOutW)
- (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jint arg3, jobject arg4, jcharArray arg5, jint arg6, jintArray arg7)
-{
- RECT _arg4, *lparg4=NULL;
- jchar *lparg5=NULL;
- jint *lparg7=NULL;
- jboolean rc;
-
- DEBUG_CALL("ExtTextOutW\n")
-
- if (arg4) lparg4 = getRECTFields(env, arg4, &_arg4);
- if (arg5) lparg5 = (*env)->GetCharArrayElements(env, arg5, NULL);
- if (arg7) lparg7 = (*env)->GetIntArrayElements(env, arg7, NULL);
- rc = (jboolean)ExtTextOutW((HDC)arg0, arg1, arg2, arg3, lparg4, (LPWSTR)lparg5, arg6, (CONST INT*)lparg7);
- if (arg4) setRECTFields(env, arg4, lparg4);
- if (arg5) (*env)->ReleaseCharArrayElements(env, arg5, lparg5, 0);
- if (arg7) (*env)->ReleaseIntArrayElements(env, arg7, lparg7, 0);
- return rc;
-}
-#endif /* NO_ExtTextOutW */
-
-#ifndef NO_ExtractIconExA
-JNIEXPORT jint JNICALL OS_NATIVE(ExtractIconExA)
- (JNIEnv *env, jclass that, jbyteArray arg0, jint arg1, jintArray arg2, jintArray arg3, jint arg4)
-{
- jbyte *lparg0=NULL;
- jint *lparg2=NULL;
- jint *lparg3=NULL;
- jint rc;
-
- DEBUG_CALL("ExtractIconExA\n")
-
- if (arg0) lparg0 = (*env)->GetByteArrayElements(env, arg0, NULL);
- if (arg2) lparg2 = (*env)->GetIntArrayElements(env, arg2, NULL);
- if (arg3) lparg3 = (*env)->GetIntArrayElements(env, arg3, NULL);
- rc = (jint)ExtractIconExA((LPSTR)lparg0, arg1, (HICON FAR *)lparg2, (HICON FAR *)lparg3, arg4);
- if (arg0) (*env)->ReleaseByteArrayElements(env, arg0, lparg0, 0);
- if (arg2) (*env)->ReleaseIntArrayElements(env, arg2, lparg2, 0);
- if (arg3) (*env)->ReleaseIntArrayElements(env, arg3, lparg3, 0);
- return rc;
-}
-#endif /* NO_ExtractIconExA */
-
-#ifndef NO_ExtractIconExW
-JNIEXPORT jint JNICALL OS_NATIVE(ExtractIconExW)
- (JNIEnv *env, jclass that, jcharArray arg0, jint arg1, jintArray arg2, jintArray arg3, jint arg4)
-{
- jchar *lparg0=NULL;
- jint *lparg2=NULL;
- jint *lparg3=NULL;
- jint rc;
-
- DEBUG_CALL("ExtractIconExW\n")
-
- if (arg0) lparg0 = (*env)->GetCharArrayElements(env, arg0, NULL);
- if (arg2) lparg2 = (*env)->GetIntArrayElements(env, arg2, NULL);
- if (arg3) lparg3 = (*env)->GetIntArrayElements(env, arg3, NULL);
- rc = (jint)ExtractIconExW((LPWSTR)lparg0, arg1, (HICON FAR *)lparg2, (HICON FAR *)lparg3, arg4);
- if (arg0) (*env)->ReleaseCharArrayElements(env, arg0, lparg0, 0);
- if (arg2) (*env)->ReleaseIntArrayElements(env, arg2, lparg2, 0);
- if (arg3) (*env)->ReleaseIntArrayElements(env, arg3, lparg3, 0);
- return rc;
-}
-#endif /* NO_ExtractIconExW */
-
-#ifndef NO_FillRect
-JNIEXPORT jint JNICALL OS_NATIVE(FillRect)
- (JNIEnv *env, jclass that, jint arg0, jobject arg1, jint arg2)
-{
- RECT _arg1, *lparg1=NULL;
- jint rc;
-
- DEBUG_CALL("FillRect\n")
-
- if (arg1) lparg1 = getRECTFields(env, arg1, &_arg1);
- rc = (jint)FillRect((HDC)arg0, lparg1, (HBRUSH)arg2);
- if (arg1) setRECTFields(env, arg1, lparg1);
- return rc;
-}
-#endif /* NO_FillRect */
-
-#ifndef NO_FindWindowA
-JNIEXPORT jint JNICALL OS_NATIVE(FindWindowA)
- (JNIEnv *env, jclass that, jbyteArray arg0, jbyteArray arg1)
-{
- jbyte *lparg0=NULL;
- jbyte *lparg1=NULL;
- jint rc;
-
- DEBUG_CALL("FindWindowA\n")
-
- if (arg0) lparg0 = (*env)->GetByteArrayElements(env, arg0, NULL);
- if (arg1) lparg1 = (*env)->GetByteArrayElements(env, arg1, NULL);
- rc = (jint)FindWindowA((LPSTR)lparg0, (LPSTR)lparg1);
- if (arg0) (*env)->ReleaseByteArrayElements(env, arg0, lparg0, 0);
- if (arg1) (*env)->ReleaseByteArrayElements(env, arg1, lparg1, 0);
- return rc;
-}
-#endif /* NO_FindWindowA */
-
-#ifndef NO_FindWindowW
-JNIEXPORT jint JNICALL OS_NATIVE(FindWindowW)
- (JNIEnv *env, jclass that, jcharArray arg0, jcharArray arg1)
-{
- jchar *lparg0=NULL;
- jchar *lparg1=NULL;
- jint rc;
-
- DEBUG_CALL("FindWindowW\n")
-
- if (arg0) lparg0 = (*env)->GetCharArrayElements(env, arg0, NULL);
- if (arg1) lparg1 = (*env)->GetCharArrayElements(env, arg1, NULL);
- rc = (jint)FindWindowW((LPWSTR)lparg0, (LPWSTR)lparg1);
- if (arg0) (*env)->ReleaseCharArrayElements(env, arg0, lparg0, 0);
- if (arg1) (*env)->ReleaseCharArrayElements(env, arg1, lparg1, 0);
- return rc;
-}
-#endif /* NO_FindWindowW */
-
-#ifndef NO_FreeLibrary
-JNIEXPORT jboolean JNICALL OS_NATIVE(FreeLibrary)
- (JNIEnv *env, jclass that, jint arg0)
-{
- DEBUG_CALL("FreeLibrary\n")
-
- return (jboolean)FreeLibrary((HMODULE)arg0);
-}
-#endif /* NO_FreeLibrary */
-
-#ifndef NO_GetACP
-JNIEXPORT jint JNICALL OS_NATIVE(GetACP)
- (JNIEnv *env, jclass that)
-{
- DEBUG_CALL("GetACP\n")
-
- return (jint)GetACP();
-}
-#endif /* NO_GetACP */
-
-#ifndef NO_GetActiveWindow
-JNIEXPORT jint JNICALL OS_NATIVE(GetActiveWindow)
- (JNIEnv *env, jclass that)
-{
- DEBUG_CALL("GetActiveWindow\n")
-
- return (jint)GetActiveWindow();
-}
-#endif /* NO_GetActiveWindow */
-
-#ifndef NO_GetBkColor
-JNIEXPORT jint JNICALL OS_NATIVE(GetBkColor)
- (JNIEnv *env, jclass that, jint arg0)
-{
- DEBUG_CALL("GetBkColor\n")
-
- return (jint)GetBkColor((HDC)arg0);
-}
-#endif /* NO_GetBkColor */
-
-#ifndef NO_GetCapture
-JNIEXPORT jint JNICALL OS_NATIVE(GetCapture)
- (JNIEnv *env, jclass that)
-{
- DEBUG_CALL("GetCapture\n")
-
- return (jint)GetCapture();
-}
-#endif /* NO_GetCapture */
-
-#ifndef NO_GetCaretPos
-JNIEXPORT jboolean JNICALL OS_NATIVE(GetCaretPos)
- (JNIEnv *env, jclass that, jobject arg0)
-{
- POINT _arg0, *lparg0=NULL;
- jboolean rc;
-
- DEBUG_CALL("GetCaretPos\n")
-
- if (arg0) lparg0 = getPOINTFields(env, arg0, &_arg0);
- rc = (jboolean)GetCaretPos(lparg0);
- if (arg0) setPOINTFields(env, arg0, lparg0);
- return rc;
-}
-#endif /* NO_GetCaretPos */
-
-#ifndef NO_GetCharABCWidthsA
-JNIEXPORT jboolean JNICALL OS_NATIVE(GetCharABCWidthsA)
- (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jintArray arg3)
-{
- jint *lparg3=NULL;
- jboolean rc;
-
- DEBUG_CALL("GetCharABCWidthsA\n")
-
- if (arg3) lparg3 = (*env)->GetIntArrayElements(env, arg3, NULL);
- rc = (jboolean)GetCharABCWidthsA((HDC)arg0, arg1, arg2, (LPABC)lparg3);
- if (arg3) (*env)->ReleaseIntArrayElements(env, arg3, lparg3, 0);
- return rc;
-}
-#endif /* NO_GetCharABCWidthsA */
-
-#ifndef NO_GetCharABCWidthsW
-JNIEXPORT jboolean JNICALL OS_NATIVE(GetCharABCWidthsW)
- (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jintArray arg3)
-{
- jint *lparg3=NULL;
- jboolean rc;
-
- DEBUG_CALL("GetCharABCWidthsW\n")
-
- if (arg3) lparg3 = (*env)->GetIntArrayElements(env, arg3, NULL);
- rc = (jboolean)GetCharABCWidthsW((HDC)arg0, arg1, arg2, (LPABC)lparg3);
- if (arg3) (*env)->ReleaseIntArrayElements(env, arg3, lparg3, 0);
- return rc;
-}
-#endif /* NO_GetCharABCWidthsW */
-
-#ifndef NO_GetCharWidthA
-JNIEXPORT jboolean JNICALL OS_NATIVE(GetCharWidthA)
- (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jintArray arg3)
-{
- jint *lparg3=NULL;
- jboolean rc;
-
- DEBUG_CALL("GetCharWidthA\n")
-
- if (arg3) lparg3 = (*env)->GetIntArrayElements(env, arg3, NULL);
- rc = (jboolean)GetCharWidthA((HDC)arg0, arg1, arg2, (LPINT)lparg3);
- if (arg3) (*env)->ReleaseIntArrayElements(env, arg3, lparg3, 0);
- return rc;
-}
-#endif /* NO_GetCharWidthA */
-
-#ifndef NO_GetCharWidthW
-JNIEXPORT jboolean JNICALL OS_NATIVE(GetCharWidthW)
- (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jintArray arg3)
-{
- jint *lparg3=NULL;
- jboolean rc;
-
- DEBUG_CALL("GetCharWidthW\n")
-
- if (arg3) lparg3 = (*env)->GetIntArrayElements(env, arg3, NULL);
- rc = (jboolean)GetCharWidthW((HDC)arg0, arg1, arg2, (LPINT)lparg3);
- if (arg3) (*env)->ReleaseIntArrayElements(env, arg3, lparg3, 0);
- return rc;
-}
-#endif /* NO_GetCharWidthW */
-
-#ifndef NO_GetCharacterPlacementA
-JNIEXPORT jint JNICALL OS_NATIVE(GetCharacterPlacementA)
- (JNIEnv *env, jclass that, jint arg0, jbyteArray arg1, jint arg2, jint arg3, jobject arg4, jint arg5)
-{
- jbyte *lparg1=NULL;
- GCP_RESULTS _arg4, *lparg4=NULL;
- jint rc;
-
- DEBUG_CALL("GetCharacterPlacementA\n")
-
- if (arg1) lparg1 = (*env)->GetByteArrayElements(env, arg1, NULL);
- if (arg4) lparg4 = getGCP_RESULTSFields(env, arg4, &_arg4);
- rc = (jint)GetCharacterPlacementA((HDC)arg0, (LPSTR)lparg1, arg2, arg3, lparg4, arg5);
- if (arg1) (*env)->ReleaseByteArrayElements(env, arg1, lparg1, 0);
- if (arg4) setGCP_RESULTSFields(env, arg4, lparg4);
- return rc;
-}
-#endif /* NO_GetCharacterPlacementA */
-
-#ifndef NO_GetCharacterPlacementW
-JNIEXPORT jint JNICALL OS_NATIVE(GetCharacterPlacementW)
- (JNIEnv *env, jclass that, jint arg0, jcharArray arg1, jint arg2, jint arg3, jobject arg4, jint arg5)
-{
- jchar *lparg1=NULL;
- GCP_RESULTS _arg4, *lparg4=NULL;
- jint rc;
-
- DEBUG_CALL("GetCharacterPlacementW\n")
-
- if (arg1) lparg1 = (*env)->GetCharArrayElements(env, arg1, NULL);
- if (arg4) lparg4 = getGCP_RESULTSFields(env, arg4, &_arg4);
- rc = (jint)GetCharacterPlacementW((HDC)arg0, (LPWSTR)lparg1, arg2, arg3, (LPGCP_RESULTSW)lparg4, arg5);
- if (arg1) (*env)->ReleaseCharArrayElements(env, arg1, lparg1, 0);
- if (arg4) setGCP_RESULTSFields(env, arg4, lparg4);
- return rc;
-}
-#endif /* NO_GetCharacterPlacementW */
-
-#ifndef NO_GetClassInfoA
-JNIEXPORT jboolean JNICALL OS_NATIVE(GetClassInfoA)
- (JNIEnv *env, jclass that, jint arg0, jbyteArray arg1, jobject arg2)
-{
- jbyte *lparg1=NULL;
- WNDCLASS _arg2, *lparg2=NULL;
- jboolean rc;
-
- DEBUG_CALL("GetClassInfoA\n")
-
- if (arg1) lparg1 = (*env)->GetByteArrayElements(env, arg1, NULL);
- if (arg2) lparg2 = getWNDCLASSFields(env, arg2, &_arg2);
- rc = (jboolean)GetClassInfoA((HINSTANCE)arg0, (LPSTR)lparg1, lparg2);
- if (arg1) (*env)->ReleaseByteArrayElements(env, arg1, lparg1, 0);
- if (arg2) setWNDCLASSFields(env, arg2, lparg2);
- return rc;
-}
-#endif /* NO_GetClassInfoA */
-
-#ifndef NO_GetClassInfoW
-JNIEXPORT jboolean JNICALL OS_NATIVE(GetClassInfoW)
- (JNIEnv *env, jclass that, jint arg0, jcharArray arg1, jobject arg2)
-{
- jchar *lparg1=NULL;
- WNDCLASS _arg2, *lparg2=NULL;
- jboolean rc;
-
- DEBUG_CALL("GetClassInfoW\n")
-
- if (arg1) lparg1 = (*env)->GetCharArrayElements(env, arg1, NULL);
- if (arg2) lparg2 = getWNDCLASSFields(env, arg2, &_arg2);
- rc = (jboolean)GetClassInfoW((HINSTANCE)arg0, (LPWSTR)lparg1, (LPWNDCLASSW)lparg2);
- if (arg1) (*env)->ReleaseCharArrayElements(env, arg1, lparg1, 0);
- if (arg2) setWNDCLASSFields(env, arg2, lparg2);
- return rc;
-}
-#endif /* NO_GetClassInfoW */
-
-#ifndef NO_GetClientRect
-JNIEXPORT jboolean JNICALL OS_NATIVE(GetClientRect)
- (JNIEnv *env, jclass that, jint arg0, jobject arg1)
-{
- RECT _arg1, *lparg1=NULL;
- jboolean rc;
-
- DEBUG_CALL("GetClientRect\n")
-
- if (arg1) lparg1 = getRECTFields(env, arg1, &_arg1);
- rc = (jboolean)GetClientRect((HWND)arg0, lparg1);
- if (arg1) setRECTFields(env, arg1, lparg1);
- return rc;
-}
-#endif /* NO_GetClientRect */
-
-#ifndef NO_GetClipBox
-JNIEXPORT jint JNICALL OS_NATIVE(GetClipBox)
- (JNIEnv *env, jclass that, jint arg0, jobject arg1)
-{
- RECT _arg1, *lparg1=NULL;
- jint rc;
-
- DEBUG_CALL("GetClipBox\n")
-
- if (arg1) lparg1 = getRECTFields(env, arg1, &_arg1);
- rc = (jint)GetClipBox((HDC)arg0, lparg1);
- if (arg1) setRECTFields(env, arg1, lparg1);
- return rc;
-}
-#endif /* NO_GetClipBox */
-
-#ifndef NO_GetClipRgn
-JNIEXPORT jint JNICALL OS_NATIVE(GetClipRgn)
- (JNIEnv *env, jclass that, jint arg0, jint arg1)
-{
- DEBUG_CALL("GetClipRgn\n")
-
- return (jint)GetClipRgn((HDC)arg0, (HRGN)arg1);
-}
-#endif /* NO_GetClipRgn */
-
-#ifndef NO_GetClipboardData
-JNIEXPORT jint JNICALL OS_NATIVE(GetClipboardData)
- (JNIEnv *env, jclass that, jint arg0)
-{
- DEBUG_CALL("GetClipboardData\n")
-
- return (jint)GetClipboardData(arg0);
-}
-#endif /* NO_GetClipboardData */
-
-#ifndef NO_GetClipboardFormatNameA
-JNIEXPORT jint JNICALL OS_NATIVE(GetClipboardFormatNameA)
- (JNIEnv *env, jclass that, jint arg0, jbyteArray arg1, jint arg2)
-{
- jbyte *lparg1=NULL;
- jint rc;
-
- DEBUG_CALL("GetClipboardFormatNameA\n")
-
- if (arg1) lparg1 = (*env)->GetByteArrayElements(env, arg1, NULL);
- rc = (jint)GetClipboardFormatNameA(arg0, lparg1, arg2);
- if (arg1) (*env)->ReleaseByteArrayElements(env, arg1, lparg1, 0);
- return rc;
-}
-#endif /* NO_GetClipboardFormatNameA */
-
-#ifndef NO_GetClipboardFormatNameW
-JNIEXPORT jint JNICALL OS_NATIVE(GetClipboardFormatNameW)
- (JNIEnv *env, jclass that, jint arg0, jcharArray arg1, jint arg2)
-{
- jchar *lparg1=NULL;
- jint rc;
-
- DEBUG_CALL("GetClipboardFormatNameW\n")
-
- if (arg1) lparg1 = (*env)->GetCharArrayElements(env, arg1, NULL);
- rc = (jint)GetClipboardFormatNameW(arg0, (LPWSTR)lparg1, arg2);
- if (arg1) (*env)->ReleaseCharArrayElements(env, arg1, lparg1, 0);
- return rc;
-}
-#endif /* NO_GetClipboardFormatNameW */
-
-#ifndef NO_GetCurrentObject
-JNIEXPORT jint JNICALL OS_NATIVE(GetCurrentObject)
- (JNIEnv *env, jclass that, jint arg0, jint arg1)
-{
- DEBUG_CALL("GetCurrentObject\n")
-
- return (jint)GetCurrentObject((HDC)arg0, arg1);
-}
-#endif /* NO_GetCurrentObject */
-
-#ifndef NO_GetCurrentProcessId
-JNIEXPORT jint JNICALL OS_NATIVE(GetCurrentProcessId)
- (JNIEnv *env, jclass that)
-{
- DEBUG_CALL("GetCurrentProcessId\n")
-
- return (jint)GetCurrentProcessId();
-}
-#endif /* NO_GetCurrentProcessId */
-
-#ifndef NO_GetCurrentThreadId
-JNIEXPORT jint JNICALL OS_NATIVE(GetCurrentThreadId)
- (JNIEnv *env, jclass that)
-{
- DEBUG_CALL("GetCurrentThreadId\n")
-
- return (jint)GetCurrentThreadId();
-}
-#endif /* NO_GetCurrentThreadId */
-
-#ifndef NO_GetCursor
-JNIEXPORT jint JNICALL OS_NATIVE(GetCursor)
- (JNIEnv *env, jclass that)
-{
- DEBUG_CALL("GetCursor\n")
-
- return (jint)GetCursor();
-}
-#endif /* NO_GetCursor */
-
-#ifndef NO_GetCursorPos
-JNIEXPORT jboolean JNICALL OS_NATIVE(GetCursorPos)
- (JNIEnv *env, jclass that, jobject arg0)
-{
- POINT _arg0, *lparg0=NULL;
- jboolean rc;
-
- DEBUG_CALL("GetCursorPos\n")
-
- if (arg0) lparg0 = getPOINTFields(env, arg0, &_arg0);
- rc = (jboolean)GetCursorPos(lparg0);
- if (arg0) setPOINTFields(env, arg0, lparg0);
- return rc;
-}
-#endif /* NO_GetCursorPos */
-
-#ifndef NO_GetDC
-JNIEXPORT jint JNICALL OS_NATIVE(GetDC)
- (JNIEnv *env, jclass that, jint arg0)
-{
- DEBUG_CALL("GetDC\n")
-
- return (jint)GetDC((HWND)arg0);
-}
-#endif /* NO_GetDC */
-
-#ifndef NO_GetDCEx
-JNIEXPORT jint JNICALL OS_NATIVE(GetDCEx)
- (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2)
-{
- DEBUG_CALL("GetDCEx\n")
-
- return (jint)GetDCEx((HWND)arg0, (HRGN)arg1, arg2);
-}
-#endif /* NO_GetDCEx */
-
-#ifndef NO_GetDIBColorTable
-JNIEXPORT jint JNICALL OS_NATIVE(GetDIBColorTable)
- (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jbyteArray arg3)
-{
- jbyte *lparg3=NULL;
- jint rc;
-
- DEBUG_CALL("GetDIBColorTable\n")
-
- if (arg3) lparg3 = (*env)->GetByteArrayElements(env, arg3, NULL);
- rc = (jint)GetDIBColorTable((HDC)arg0, arg1, arg2, (RGBQUAD *)lparg3);
- if (arg3) (*env)->ReleaseByteArrayElements(env, arg3, lparg3, 0);
- return rc;
-}
-#endif /* NO_GetDIBColorTable */
-
-#ifndef NO_GetDIBits
-JNIEXPORT jint JNICALL OS_NATIVE(GetDIBits)
- (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jint arg3, jint arg4, jbyteArray arg5, jint arg6)
-{
- jbyte *lparg5=NULL;
- jint rc;
-
- DEBUG_CALL("GetDIBits\n")
-
- if (arg5) lparg5 = (*env)->GetByteArrayElements(env, arg5, NULL);
- rc = (jint)GetDIBits((HDC)arg0, (HBITMAP)arg1, arg2, arg3, (LPVOID)arg4, (LPBITMAPINFO)lparg5, arg6);
- if (arg5) (*env)->ReleaseByteArrayElements(env, arg5, lparg5, 0);
- return rc;
-}
-#endif /* NO_GetDIBits */
-
-#ifndef NO_GetDesktopWindow
-JNIEXPORT jint JNICALL OS_NATIVE(GetDesktopWindow)
- (JNIEnv *env, jclass that)
-{
- DEBUG_CALL("GetDesktopWindow\n")
-
- return (jint)GetDesktopWindow();
-}
-#endif /* NO_GetDesktopWindow */
-
-#ifndef NO_GetDeviceCaps
-JNIEXPORT jint JNICALL OS_NATIVE(GetDeviceCaps)
- (JNIEnv *env, jclass that, jint arg0, jint arg1)
-{
- DEBUG_CALL("GetDeviceCaps\n")
-
- return (jint)GetDeviceCaps((HDC)arg0, arg1);
-}
-#endif /* NO_GetDeviceCaps */
-
-#ifndef NO_GetDialogBaseUnits
-JNIEXPORT jint JNICALL OS_NATIVE(GetDialogBaseUnits)
- (JNIEnv *env, jclass that)
-{
- DEBUG_CALL("GetDialogBaseUnits\n")
-
- return (jint)GetDialogBaseUnits();
-}
-#endif /* NO_GetDialogBaseUnits */
-
-#ifndef NO_GetDlgItem
-JNIEXPORT jint JNICALL OS_NATIVE(GetDlgItem)
- (JNIEnv *env, jclass that, jint arg0, jint arg1)
-{
- DEBUG_CALL("GetDlgItem\n")
-
- return (jint)GetDlgItem((HWND)arg0, arg1);
-}
-#endif /* NO_GetDlgItem */
-
-#ifndef NO_GetDoubleClickTime
-JNIEXPORT jint JNICALL OS_NATIVE(GetDoubleClickTime)
- (JNIEnv *env, jclass that)
-{
- DEBUG_CALL("GetDoubleClickTime\n")
-
- return (jint)GetDoubleClickTime();
-}
-#endif /* NO_GetDoubleClickTime */
-
-#ifndef NO_GetFocus
-JNIEXPORT jint JNICALL OS_NATIVE(GetFocus)
- (JNIEnv *env, jclass that)
-{
- DEBUG_CALL("GetFocus\n")
-
- return (jint)GetFocus();
-}
-#endif /* NO_GetFocus */
-
-#ifndef NO_GetFontLanguageInfo
-JNIEXPORT jint JNICALL OS_NATIVE(GetFontLanguageInfo)
- (JNIEnv *env, jclass that, jint arg0)
-{
- DEBUG_CALL("GetFontLanguageInfo\n")
-
- return (jint)GetFontLanguageInfo((HDC)arg0);
-}
-#endif /* NO_GetFontLanguageInfo */
-
-#ifndef NO_GetIconInfo
-JNIEXPORT jboolean JNICALL OS_NATIVE(GetIconInfo)
- (JNIEnv *env, jclass that, jint arg0, jobject arg1)
-{
- ICONINFO _arg1, *lparg1=NULL;
- jboolean rc;
-
- DEBUG_CALL("GetIconInfo\n")
-
- if (arg1) lparg1 = getICONINFOFields(env, arg1, &_arg1);
- rc = (jboolean)GetIconInfo((HICON)arg0, lparg1);
- if (arg1) setICONINFOFields(env, arg1, lparg1);
- return rc;
-}
-#endif /* NO_GetIconInfo */
-
-#ifndef NO_GetKeyState
-JNIEXPORT jshort JNICALL OS_NATIVE(GetKeyState)
- (JNIEnv *env, jclass that, jint arg0)
-{
- DEBUG_CALL("GetKeyState\n")
-
- return (jshort)GetKeyState(arg0);
-}
-#endif /* NO_GetKeyState */
-
-#ifndef NO_GetKeyboardLayout
-JNIEXPORT jint JNICALL OS_NATIVE(GetKeyboardLayout)
- (JNIEnv *env, jclass that, jint arg0)
-{
- DEBUG_CALL("GetKeyboardLayout\n")
-
- return (jint)GetKeyboardLayout(arg0);
-}
-#endif /* NO_GetKeyboardLayout */
-
-#ifndef NO_GetKeyboardLayoutList
-JNIEXPORT jint JNICALL OS_NATIVE(GetKeyboardLayoutList)
- (JNIEnv *env, jclass that, jint arg0, jintArray arg1)
-{
- jint *lparg1=NULL;
- jint rc;
-
- DEBUG_CALL("GetKeyboardLayoutList\n")
-
- if (arg1) lparg1 = (*env)->GetIntArrayElements(env, arg1, NULL);
- rc = (jint)GetKeyboardLayoutList(arg0, (HKL FAR *)lparg1);
- if (arg1) (*env)->ReleaseIntArrayElements(env, arg1, lparg1, 0);
- return rc;
-}
-#endif /* NO_GetKeyboardLayoutList */
-
-#ifndef NO_GetKeyboardState
-JNIEXPORT jboolean JNICALL OS_NATIVE(GetKeyboardState)
- (JNIEnv *env, jclass that, jbyteArray arg0)
-{
- jbyte *lparg0=NULL;
- jboolean rc;
-
- DEBUG_CALL("GetKeyboardState\n")
-
- if (arg0) lparg0 = (*env)->GetByteArrayElements(env, arg0, NULL);
- rc = (jboolean)GetKeyboardState((PBYTE)lparg0);
- if (arg0) (*env)->ReleaseByteArrayElements(env, arg0, lparg0, 0);
- return rc;
-}
-#endif /* NO_GetKeyboardState */
-
-#ifndef NO_GetKeyNameTextA
-JNIEXPORT jint JNICALL OS_NATIVE(GetKeyNameTextA)
- (JNIEnv *env, jclass that, jint arg0, jbyteArray arg1, jint arg2)
-{
- jbyte *lparg1=NULL;
- jint rc;
-
- DEBUG_CALL("GetKeyNameTextA\n")
-
- if (arg1) lparg1 = (*env)->GetByteArrayElements(env, arg1, NULL);
- rc = (jint)GetKeyNameTextA(arg0, (LPSTR)lparg1, arg2);
- if (arg1) (*env)->ReleaseByteArrayElements(env, arg1, lparg1, 0);
- return rc;
-}
-#endif /* NO_GetKeyNameTextA */
-
-#ifndef NO_GetKeyNameTextW
-JNIEXPORT jint JNICALL OS_NATIVE(GetKeyNameTextW)
- (JNIEnv *env, jclass that, jint arg0, jcharArray arg1, jint arg2)
-{
- jchar *lparg1=NULL;
- jint rc;
-
- DEBUG_CALL("GetKeyNameTextW\n")
-
- if (arg1) lparg1 = (*env)->GetCharArrayElements(env, arg1, NULL);
- rc = (jint)GetKeyNameTextW(arg0, (LPWSTR)lparg1, arg2);
- if (arg1) (*env)->ReleaseCharArrayElements(env, arg1, lparg1, 0);
- return rc;
-}
-#endif /* NO_GetKeyNameTextW */
-
-#ifndef NO_GetLastActivePopup
-JNIEXPORT jint JNICALL OS_NATIVE(GetLastActivePopup)
- (JNIEnv *env, jclass that, jint arg0)
-{
- DEBUG_CALL("GetLastActivePopup\n")
-
- return (jint)GetLastActivePopup((HWND)arg0);
-}
-#endif /* NO_GetLastActivePopup */
-
-#ifndef NO_GetLastError
-JNIEXPORT jint JNICALL OS_NATIVE(GetLastError)
- (JNIEnv *env, jclass that)
-{
- DEBUG_CALL("GetLastError\n")
-
- return (jint)GetLastError();
-}
-#endif /* NO_GetLastError */
-
-#ifndef NO_GetLibraryHandle
-JNIEXPORT jint JNICALL OS_NATIVE(GetLibraryHandle)
- (JNIEnv *env, jclass that)
-{
- DEBUG_CALL("GetLibraryHandle\n")
-
- return (jint)g_hInstance;
-}
-#endif /* NO_GetLibraryHandle */
-
-#ifndef NO_GetLocaleInfoA
-JNIEXPORT jint JNICALL OS_NATIVE(GetLocaleInfoA)
- (JNIEnv *env, jclass that, jint arg0, jint arg1, jbyteArray arg2, jint arg3)
-{
- jbyte *lparg2=NULL;
- jint rc;
-
- DEBUG_CALL("GetLocaleInfoA\n")
-
- if (arg2) lparg2 = (*env)->GetByteArrayElements(env, arg2, NULL);
- rc = (jint)GetLocaleInfoA(arg0, arg1, (LPSTR)lparg2, arg3);
- if (arg2) (*env)->ReleaseByteArrayElements(env, arg2, lparg2, 0);
- return rc;
-}
-#endif /* NO_GetLocaleInfoA */
-
-#ifndef NO_GetLocaleInfoW
-JNIEXPORT jint JNICALL OS_NATIVE(GetLocaleInfoW)
- (JNIEnv *env, jclass that, jint arg0, jint arg1, jcharArray arg2, jint arg3)
-{
- jchar *lparg2=NULL;
- jint rc;
-
- DEBUG_CALL("GetLocaleInfoW\n")
-
- if (arg2) lparg2 = (*env)->GetCharArrayElements(env, arg2, NULL);
- rc = (jint)GetLocaleInfoW(arg0, arg1, (LPWSTR)lparg2, arg3);
- if (arg2) (*env)->ReleaseCharArrayElements(env, arg2, lparg2, 0);
- return rc;
-}
-#endif /* NO_GetLocaleInfoW */
-
-#ifndef NO_GetMenu
-JNIEXPORT jint JNICALL OS_NATIVE(GetMenu)
- (JNIEnv *env, jclass that, jint arg0)
-{
- DEBUG_CALL("GetMenu\n")
-
- return (jint)GetMenu((HWND)arg0);
-}
-#endif /* NO_GetMenu */
-
-#ifndef NO_GetMenuDefaultItem
-JNIEXPORT jint JNICALL OS_NATIVE(GetMenuDefaultItem)
- (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2)
-{
- DEBUG_CALL("GetMenuDefaultItem\n")
-
- return (jint)GetMenuDefaultItem((HMENU)arg0, arg1, arg2);
-}
-#endif /* NO_GetMenuDefaultItem */
-
-#ifndef NO_GetMenuInfo
-JNIEXPORT jboolean JNICALL OS_NATIVE(GetMenuInfo)
- (JNIEnv *env, jclass that, jint arg0, jobject arg1)
-{
- MENUINFO _arg1, *lparg1=NULL;
- jboolean rc = (jboolean)FALSE;
- HMODULE hm;
- FARPROC fp;
-
- DEBUG_CALL("GetMenuInfo\n")
-
- /* SPECIAL */
- /*
- * 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 (arg1) lparg1 = getMENUINFOFields(env, arg1, &_arg1);
-
- rc = (jboolean) (fp)((HMENU)arg0, lparg1);
-// rc = (jboolean)GetMenuInfo(arg0, lparg1);
-
- if (arg1) setMENUINFOFields(env, arg1, lparg1);
- }
-
- return rc;
-}
-#endif /* NO_GetMenuInfo */
-
-#ifndef NO_GetMenuItemCount
-JNIEXPORT jint JNICALL OS_NATIVE(GetMenuItemCount)
- (JNIEnv *env, jclass that, jint arg0)
-{
- DEBUG_CALL("GetMenuItemCount\n")
-
- return (jint)GetMenuItemCount((HMENU)arg0);
-}
-#endif /* NO_GetMenuItemCount */
-
-#ifndef NO_GetMenuItemInfoA
-JNIEXPORT jboolean JNICALL OS_NATIVE(GetMenuItemInfoA)
- (JNIEnv *env, jclass that, jint arg0, jint arg1, jboolean arg2, jobject arg3)
-{
- MENUITEMINFO _arg3, *lparg3=NULL;
- jboolean rc;
-
- DEBUG_CALL("GetMenuItemInfoA\n")
-
- if (arg3) lparg3 = getMENUITEMINFOFields(env, arg3, &_arg3);
- rc = (jboolean)GetMenuItemInfoA((HMENU)arg0, arg1, arg2, lparg3);
- if (arg3) setMENUITEMINFOFields(env, arg3, lparg3);
- return rc;
-}
-#endif /* NO_GetMenuItemInfoA */
-
-#ifndef NO_GetMenuItemInfoW
-JNIEXPORT jboolean JNICALL OS_NATIVE(GetMenuItemInfoW)
- (JNIEnv *env, jclass that, jint arg0, jint arg1, jboolean arg2, jobject arg3)
-{
- MENUITEMINFO _arg3, *lparg3=NULL;
- jboolean rc;
-
- DEBUG_CALL("GetMenuItemInfoW\n")
-
- if (arg3) lparg3 = getMENUITEMINFOFields(env, arg3, &_arg3);
- rc = (jboolean)GetMenuItemInfoW((HMENU)arg0, arg1, arg2, (LPMENUITEMINFOW)lparg3);
- if (arg3) setMENUITEMINFOFields(env, arg3, lparg3);
- return rc;
-}
-#endif /* NO_GetMenuItemInfoW */
-
-#ifndef NO_GetMessageA
-JNIEXPORT jboolean JNICALL OS_NATIVE(GetMessageA)
- (JNIEnv *env, jclass that, jobject arg0, jint arg1, jint arg2, jint arg3)
-{
- MSG _arg0, *lparg0=NULL;
- jboolean rc;
-
- DEBUG_CALL("GetMessageA\n")
-
- if (arg0) lparg0 = getMSGFields(env, arg0, &_arg0);
- rc = (jboolean)GetMessageA(lparg0, (HWND)arg1, arg2, arg3);
- if (arg0) setMSGFields(env, arg0, lparg0);
- return rc;
-}
-#endif /* NO_GetMessageA */
-
-#ifndef NO_GetMessagePos
-JNIEXPORT jint JNICALL OS_NATIVE(GetMessagePos)
- (JNIEnv *env, jclass that)
-{
- DEBUG_CALL("GetMessagePos\n")
-
- return (jint)GetMessagePos();
-}
-#endif /* NO_GetMessagePos */
-
-#ifndef NO_GetMessageTime
-JNIEXPORT jint JNICALL OS_NATIVE(GetMessageTime)
- (JNIEnv *env, jclass that)
-{
- DEBUG_CALL("GetMessageTime\n")
-
- return (jint)GetMessageTime();
-}
-#endif /* NO_GetMessageTime */
-
-#ifndef NO_GetMessageW
-JNIEXPORT jboolean JNICALL OS_NATIVE(GetMessageW)
- (JNIEnv *env, jclass that, jobject arg0, jint arg1, jint arg2, jint arg3)
-{
- MSG _arg0, *lparg0=NULL;
- jboolean rc;
-
- DEBUG_CALL("GetMessageW\n")
-
- if (arg0) lparg0 = getMSGFields(env, arg0, &_arg0);
- rc = (jboolean)GetMessageW(lparg0, (HWND)arg1, arg2, arg3);
- if (arg0) setMSGFields(env, arg0, lparg0);
- return rc;
-}
-#endif /* NO_GetMessageW */
-
-#ifndef NO_GetModuleHandleA
-JNIEXPORT jint JNICALL OS_NATIVE(GetModuleHandleA)
- (JNIEnv *env, jclass that, jbyteArray arg0)
-{
- jbyte *lparg0=NULL;
- jint rc;
-
- DEBUG_CALL("GetModuleHandleA\n")
-
- if (arg0) lparg0 = (*env)->GetByteArrayElements(env, arg0, NULL);
- rc = (jint)GetModuleHandleA((LPSTR)lparg0);
- if (arg0) (*env)->ReleaseByteArrayElements(env, arg0, lparg0, 0);
- return rc;
-}
-#endif /* NO_GetModuleHandleA */
-
-#ifndef NO_GetModuleHandleW
-JNIEXPORT jint JNICALL OS_NATIVE(GetModuleHandleW)
- (JNIEnv *env, jclass that, jcharArray arg0)
-{
- jchar *lparg0=NULL;
- jint rc;
-
- DEBUG_CALL("GetModuleHandleW\n")
-
- if (arg0) lparg0 = (*env)->GetCharArrayElements(env, arg0, NULL);
- rc = (jint)GetModuleHandleW((LPWSTR)lparg0);
- if (arg0) (*env)->ReleaseCharArrayElements(env, arg0, lparg0, 0);
- return rc;
-}
-#endif /* NO_GetModuleHandleW */
-
-#ifndef NO_GetNearestPaletteIndex
-JNIEXPORT jint JNICALL OS_NATIVE(GetNearestPaletteIndex)
- (JNIEnv *env, jclass that, jint arg0, jint arg1)
-{
- DEBUG_CALL("GetNearestPaletteIndex\n")
-
- return (jint)GetNearestPaletteIndex((HPALETTE)arg0, (COLORREF)arg1);
-}
-#endif /* NO_GetNearestPaletteIndex */
-
-#ifndef NO_GetObjectA__IILorg_eclipse_swt_internal_win32_LOGFONT_2
-JNIEXPORT jint JNICALL OS_NATIVE(GetObjectA__IILorg_eclipse_swt_internal_win32_LOGFONT_2)
- (JNIEnv *env, jclass that, jint arg0, jint arg1, jobject arg2)
-{
- LOGFONT _arg2, *lparg2=NULL;
- jint rc;
-
- DEBUG_CALL("GetObjectA__IILorg_eclipse_swt_internal_win32_LOGFONT_2\n")
-
- if (arg2) lparg2 = getLOGFONTAFields(env, arg2, &_arg2);
- rc = (jint)GetObjectA((HGDIOBJ)arg0, arg1, lparg2);
- if (arg2) setLOGFONTAFields(env, arg2, lparg2);
- return rc;
-}
-#endif /* NO_GetObjectA__IILorg_eclipse_swt_internal_win32_LOGFONT_2 */
-
-#ifndef NO_GetObjectA__IILorg_eclipse_swt_internal_win32_BITMAP_2
-JNIEXPORT jint JNICALL OS_NATIVE(GetObjectA__IILorg_eclipse_swt_internal_win32_BITMAP_2)
- (JNIEnv *env, jclass that, jint arg0, jint arg1, jobject arg2)
-{
- BITMAP _arg2, *lparg2=NULL;
- jint rc;
-
- DEBUG_CALL("GetObjectA__IILorg_eclipse_swt_internal_win32_BITMAP_2\n")
-
- if (arg2) lparg2 = getBITMAPFields(env, arg2, &_arg2);
- rc = (jint)GetObjectA((HGDIOBJ)arg0, arg1, lparg2);
- if (arg2) setBITMAPFields(env, arg2, lparg2);
- return rc;
-}
-#endif /* NO_GetObjectA__IILorg_eclipse_swt_internal_win32_BITMAP_2 */
-
-#ifndef NO_GetObjectA__IILorg_eclipse_swt_internal_win32_DIBSECTION_2
-JNIEXPORT jint JNICALL OS_NATIVE(GetObjectA__IILorg_eclipse_swt_internal_win32_DIBSECTION_2)
- (JNIEnv *env, jclass that, jint arg0, jint arg1, jobject arg2)
-{
- DIBSECTION _arg2, *lparg2=NULL;
- jint rc;
-
- DEBUG_CALL("GetObjectA__IILorg_eclipse_swt_internal_win32_DIBSECTION_2\n")
-
- if (arg2) lparg2 = getDIBSECTIONFields(env, arg2, &_arg2);
- rc = (jint)GetObjectA((HGDIOBJ)arg0, arg1, lparg2);
- if (arg2) setDIBSECTIONFields(env, arg2, lparg2);
- return rc;
-}
-#endif /* NO_GetObjectA__IILorg_eclipse_swt_internal_win32_DIBSECTION_2 */
-
-#ifndef NO_GetObjectA__IILorg_eclipse_swt_internal_win32_LOGPEN_2
-JNIEXPORT jint JNICALL OS_NATIVE(GetObjectA__IILorg_eclipse_swt_internal_win32_LOGPEN_2)
- (JNIEnv *env, jclass that, jint arg0, jint arg1, jobject arg2)
-{
- LOGPEN _arg2, *lparg2=NULL;
- jint rc;
-
- DEBUG_CALL("GetObjectA__IILorg_eclipse_swt_internal_win32_LOGPEN_2\n")
-
- if (arg2) lparg2 = getLOGPENFields(env, arg2, &_arg2);
- rc = (jint)GetObjectA((HGDIOBJ)arg0, arg1, lparg2);
- if (arg2) setLOGPENFields(env, arg2, lparg2);
- return rc;
-}
-#endif /* NO_GetObjectA__IILorg_eclipse_swt_internal_win32_LOGPEN_2 */
-
-#ifndef NO_GetObjectA__IILorg_eclipse_swt_internal_win32_LOGBRUSH_2
-JNIEXPORT jint JNICALL OS_NATIVE(GetObjectA__IILorg_eclipse_swt_internal_win32_LOGBRUSH_2)
- (JNIEnv *env, jclass that, jint arg0, jint arg1, jobject arg2)
-{
- LOGBRUSH _arg2, *lparg2=NULL;
- jint rc;
-
- DEBUG_CALL("GetObjectA__IILorg_eclipse_swt_internal_win32_LOGBRUSH_2\n")
-
- if (arg2) lparg2 = getLOGBRUSHFields(env, arg2, &_arg2);
- rc = (jint)GetObjectA((HGDIOBJ)arg0, arg1, lparg2);
- if (arg2) setLOGBRUSHFields(env, arg2, lparg2);
- return rc;
-}
-#endif /* NO_GetObjectA__IILorg_eclipse_swt_internal_win32_LOGBRUSH_2 */
-
-#ifndef NO_GetObjectW__IILorg_eclipse_swt_internal_win32_BITMAP_2
-JNIEXPORT jint JNICALL OS_NATIVE(GetObjectW__IILorg_eclipse_swt_internal_win32_BITMAP_2)
- (JNIEnv *env, jclass that, jint arg0, jint arg1, jobject arg2)
-{
- BITMAP _arg2, *lparg2=NULL;
- jint rc;
-
- DEBUG_CALL("GetObjectW__IILorg_eclipse_swt_internal_win32_BITMAP_2\n")
-
- if (arg2) lparg2 = getBITMAPFields(env, arg2, &_arg2);
- rc = (jint)GetObjectW((HGDIOBJ)arg0, arg1, lparg2);
- if (arg2) setBITMAPFields(env, arg2, lparg2);
- return rc;
-}
-#endif /* NO_GetObjectW__IILorg_eclipse_swt_internal_win32_BITMAP_2 */
-
-#ifndef NO_GetObjectW__IILorg_eclipse_swt_internal_win32_LOGBRUSH_2
-JNIEXPORT jint JNICALL OS_NATIVE(GetObjectW__IILorg_eclipse_swt_internal_win32_LOGBRUSH_2)
- (JNIEnv *env, jclass that, jint arg0, jint arg1, jobject arg2)
-{
- LOGBRUSH _arg2, *lparg2=NULL;
- jint rc;
-
- DEBUG_CALL("GetObjectW__IILorg_eclipse_swt_internal_win32_LOGBRUSH_2\n")
-
- if (arg2) lparg2 = getLOGBRUSHFields(env, arg2, &_arg2);
- rc = (jint)GetObjectW((HGDIOBJ)arg0, arg1, lparg2);
- if (arg2) setLOGBRUSHFields(env, arg2, lparg2);
- return rc;
-}
-#endif /* NO_GetObjectW__IILorg_eclipse_swt_internal_win32_LOGBRUSH_2 */
-
-#ifndef NO_GetObjectW__IILorg_eclipse_swt_internal_win32_LOGFONT_2
-JNIEXPORT jint JNICALL OS_NATIVE(GetObjectW__IILorg_eclipse_swt_internal_win32_LOGFONT_2)
- (JNIEnv *env, jclass that, jint arg0, jint arg1, jobject arg2)
-{
- LOGFONTW _arg2, *lparg2=NULL;
- jint rc;
-
- DEBUG_CALL("GetObjectW__IILorg_eclipse_swt_internal_win32_LOGFONT_2\n")
-
- if (arg2) lparg2 = getLOGFONTWFields(env, arg2, &_arg2);
- rc = (jint)GetObjectW((HGDIOBJ)arg0, arg1, lparg2);
- if (arg2) setLOGFONTWFields(env, arg2, lparg2);
- return rc;
-}
-#endif /* NO_GetObjectW__IILorg_eclipse_swt_internal_win32_LOGFONT_2 */
-
-#ifndef NO_GetObjectW__IILorg_eclipse_swt_internal_win32_DIBSECTION_2
-JNIEXPORT jint JNICALL OS_NATIVE(GetObjectW__IILorg_eclipse_swt_internal_win32_DIBSECTION_2)
- (JNIEnv *env, jclass that, jint arg0, jint arg1, jobject arg2)
-{
- DIBSECTION _arg2, *lparg2=NULL;
- jint rc;
-
- DEBUG_CALL("GetObjectW__IILorg_eclipse_swt_internal_win32_DIBSECTION_2\n")
-
- if (arg2) lparg2 = getDIBSECTIONFields(env, arg2, &_arg2);
- rc = (jint)GetObjectW((HGDIOBJ)arg0, arg1, lparg2);
- if (arg2) setDIBSECTIONFields(env, arg2, lparg2);
- return rc;
-}
-#endif /* NO_GetObjectW__IILorg_eclipse_swt_internal_win32_DIBSECTION_2 */
-
-#ifndef NO_GetObjectW__IILorg_eclipse_swt_internal_win32_LOGPEN_2
-JNIEXPORT jint JNICALL OS_NATIVE(GetObjectW__IILorg_eclipse_swt_internal_win32_LOGPEN_2)
- (JNIEnv *env, jclass that, jint arg0, jint arg1, jobject arg2)
-{
- LOGPEN _arg2, *lparg2=NULL;
- jint rc;
-
- DEBUG_CALL("GetObjectW__IILorg_eclipse_swt_internal_win32_LOGPEN_2\n")
-
- if (arg2) lparg2 = getLOGPENFields(env, arg2, &_arg2);
- rc = (jint)GetObjectW((HGDIOBJ)arg0, arg1, lparg2);
- if (arg2) setLOGPENFields(env, arg2, lparg2);
- return rc;
-}
-#endif /* NO_GetObjectW__IILorg_eclipse_swt_internal_win32_LOGPEN_2 */
-
-#ifndef NO_GetOpenFileNameA
-JNIEXPORT jboolean JNICALL OS_NATIVE(GetOpenFileNameA)
- (JNIEnv *env, jclass that, jobject arg0)
-{
- OPENFILENAME _arg0, *lparg0=NULL;
- jboolean rc;
-
- DEBUG_CALL("GetOpenFileNameA\n")
-
- if (arg0) lparg0 = getOPENFILENAMEFields(env, arg0, &_arg0);
- rc = (jboolean)GetOpenFileNameA(lparg0);
- if (arg0) setOPENFILENAMEFields(env, arg0, lparg0);
- return rc;
-}
-#endif /* NO_GetOpenFileNameA */
-
-#ifndef NO_GetOpenFileNameW
-JNIEXPORT jboolean JNICALL OS_NATIVE(GetOpenFileNameW)
- (JNIEnv *env, jclass that, jobject arg0)
-{
- OPENFILENAME _arg0, *lparg0=NULL;
- jboolean rc;
-
- DEBUG_CALL("GetOpenFileNameW\n")
-
- if (arg0) lparg0 = getOPENFILENAMEFields(env, arg0, &_arg0);
- rc = (jboolean)GetOpenFileNameW((LPOPENFILENAMEW)lparg0);
- if (arg0) setOPENFILENAMEFields(env, arg0, lparg0);
- return rc;
-}
-#endif /* NO_GetOpenFileNameW */
-
-#ifndef NO_GetPaletteEntries
-JNIEXPORT jint JNICALL OS_NATIVE(GetPaletteEntries)
- (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jbyteArray arg3)
-{
- jbyte *lparg3=NULL;
- jint rc;
-
- DEBUG_CALL("GetPaletteEntries\n")
-
- if (arg3) lparg3 = (*env)->GetByteArrayElements(env, arg3, NULL);
- rc = (jint)GetPaletteEntries((HPALETTE)arg0, arg1, arg2, (LPPALETTEENTRY)lparg3);
- if (arg3) (*env)->ReleaseByteArrayElements(env, arg3, lparg3, 0);
- return rc;
-}
-#endif /* NO_GetPaletteEntries */
-
-#ifndef NO_GetParent
-JNIEXPORT jint JNICALL OS_NATIVE(GetParent)
- (JNIEnv *env, jclass that, jint arg0)
-{
- DEBUG_CALL("GetParent\n")
-
- return (jint)GetParent((HWND)arg0);
-}
-#endif /* NO_GetParent */
-
-#ifndef NO_GetPixel
-JNIEXPORT jint JNICALL OS_NATIVE(GetPixel)
- (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2)
-{
- DEBUG_CALL("GetPixel\n")
-
- return (jint)GetPixel((HDC)arg0, arg1, arg2);
-}
-#endif /* NO_GetPixel */
-
-#ifndef NO_GetProcAddress
-JNIEXPORT jint JNICALL OS_NATIVE(GetProcAddress)
- (JNIEnv *env, jclass that, jint arg0, jbyteArray arg1)
-{
- jbyte *lparg1=NULL;
- jint rc;
-
- DEBUG_CALL("GetProcAddress\n")
-
- if (arg1) lparg1 = (*env)->GetByteArrayElements(env, arg1, NULL);
- rc = (jint)GetProcAddress((HMODULE)arg0, (LPCTSTR)lparg1);
- if (arg1) (*env)->ReleaseByteArrayElements(env, arg1, lparg1, 0);
- return rc;
-}
-#endif /* NO_GetProcAddress */
-
-#ifndef NO_GetProcessHeap
-JNIEXPORT jint JNICALL OS_NATIVE(GetProcessHeap)
- (JNIEnv *env, jclass that)
-{
- DEBUG_CALL("GetProcessHeap\n")
-
- return (jint)GetProcessHeap();
-}
-#endif /* NO_GetProcessHeap */
-
-#ifndef NO_GetProfileStringA
-JNIEXPORT jint JNICALL OS_NATIVE(GetProfileStringA)
- (JNIEnv *env, jclass that, jbyteArray arg0, jbyteArray arg1, jbyteArray arg2, jbyteArray arg3, jint arg4)
-{
- jbyte *lparg0=NULL;
- jbyte *lparg1=NULL;
- jbyte *lparg2=NULL;
- jbyte *lparg3=NULL;
- jint rc;
-
- DEBUG_CALL("GetProfileStringA\n")
-
- if (arg0) lparg0 = (*env)->GetByteArrayElements(env, arg0, NULL);
- if (arg1) lparg1 = (*env)->GetByteArrayElements(env, arg1, NULL);
- if (arg2) lparg2 = (*env)->GetByteArrayElements(env, arg2, NULL);
- if (arg3) lparg3 = (*env)->GetByteArrayElements(env, arg3, NULL);
- rc = (jint)GetProfileStringA((LPSTR)lparg0, (LPSTR)lparg1, (LPSTR)lparg2, (LPSTR)lparg3, arg4);
- if (arg0) (*env)->ReleaseByteArrayElements(env, arg0, lparg0, 0);
- if (arg1) (*env)->ReleaseByteArrayElements(env, arg1, lparg1, 0);
- if (arg2) (*env)->ReleaseByteArrayElements(env, arg2, lparg2, 0);
- if (arg3) (*env)->ReleaseByteArrayElements(env, arg3, lparg3, 0);
- return rc;
-}
-#endif /* NO_GetProfileStringA */
-
-#ifndef NO_GetProfileStringW
-JNIEXPORT jint JNICALL OS_NATIVE(GetProfileStringW)
- (JNIEnv *env, jclass that, jcharArray arg0, jcharArray arg1, jcharArray arg2, jcharArray arg3, jint arg4)
-{
- jchar *lparg0=NULL;
- jchar *lparg1=NULL;
- jchar *lparg2=NULL;
- jchar *lparg3=NULL;
- jint rc;
-
- DEBUG_CALL("GetProfileStringW\n")
-
- if (arg0) lparg0 = (*env)->GetCharArrayElements(env, arg0, NULL);
- if (arg1) lparg1 = (*env)->GetCharArrayElements(env, arg1, NULL);
- if (arg2) lparg2 = (*env)->GetCharArrayElements(env, arg2, NULL);
- if (arg3) lparg3 = (*env)->GetCharArrayElements(env, arg3, NULL);
- rc = (jint)GetProfileStringW((LPWSTR)lparg0, (LPWSTR)lparg1, (LPWSTR)lparg2, (LPWSTR)lparg3, arg4);
- if (arg0) (*env)->ReleaseCharArrayElements(env, arg0, lparg0, 0);
- if (arg1) (*env)->ReleaseCharArrayElements(env, arg1, lparg1, 0);
- if (arg2) (*env)->ReleaseCharArrayElements(env, arg2, lparg2, 0);
- if (arg3) (*env)->ReleaseCharArrayElements(env, arg3, lparg3, 0);
- return rc;
-}
-#endif /* NO_GetProfileStringW */
-
-#ifndef NO_GetROP2
-JNIEXPORT jint JNICALL OS_NATIVE(GetROP2)
- (JNIEnv *env, jclass that, jint arg0)
-{
- DEBUG_CALL("GetROP2\n")
-
- return (jint)GetROP2((HDC)arg0);
-}
-#endif /* NO_GetROP2 */
-
-#ifndef NO_GetRegionData
-JNIEXPORT jint JNICALL OS_NATIVE(GetRegionData)
- (JNIEnv *env, jclass that, jint arg0, jint arg1, jintArray arg2)
-{
- jint *lparg2=NULL;
- jint rc;
-
- DEBUG_CALL("GetRegionData\n")
-
- if (arg2) lparg2 = (*env)->GetIntArrayElements(env, arg2, NULL);
- rc = (jint)GetRegionData((HRGN)arg0, arg1, (RGNDATA *)lparg2);
- if (arg2) (*env)->ReleaseIntArrayElements(env, arg2, lparg2, 0);
- return rc;
-}
-#endif /* NO_GetRegionData */
-
-#ifndef NO_GetRgnBox
-JNIEXPORT jint JNICALL OS_NATIVE(GetRgnBox)
- (JNIEnv *env, jclass that, jint arg0, jobject arg1)
-{
- RECT _arg1, *lparg1=NULL;
- jint rc;
-
- DEBUG_CALL("GetRgnBox\n")
-
- if (arg1) lparg1 = getRECTFields(env, arg1, &_arg1);
- rc = (jint)GetRgnBox((HRGN)arg0, lparg1);
- if (arg1) setRECTFields(env, arg1, lparg1);
- return rc;
-}
-#endif /* NO_GetRgnBox */
-
-#ifndef NO_GetSaveFileNameA
-JNIEXPORT jboolean JNICALL OS_NATIVE(GetSaveFileNameA)
- (JNIEnv *env, jclass that, jobject arg0)
-{
- OPENFILENAME _arg0, *lparg0=NULL;
- jboolean rc;
-
- DEBUG_CALL("GetSaveFileNameA\n")
-
- if (arg0) lparg0 = getOPENFILENAMEFields(env, arg0, &_arg0);
- rc = (jboolean)GetSaveFileNameA(lparg0);
- if (arg0) setOPENFILENAMEFields(env, arg0, lparg0);
- return rc;
-}
-#endif /* NO_GetSaveFileNameA */
-
-#ifndef NO_GetSaveFileNameW
-JNIEXPORT jboolean JNICALL OS_NATIVE(GetSaveFileNameW)
- (JNIEnv *env, jclass that, jobject arg0)
-{
- OPENFILENAME _arg0, *lparg0=NULL;
- jboolean rc;
-
- DEBUG_CALL("GetSaveFileNameW\n")
-
- if (arg0) lparg0 = getOPENFILENAMEFields(env, arg0, &_arg0);
- rc = (jboolean)GetSaveFileNameW((LPOPENFILENAMEW)lparg0);
- if (arg0) setOPENFILENAMEFields(env, arg0, lparg0);
- return rc;
-}
-#endif /* NO_GetSaveFileNameW */
-
-#ifndef NO_GetScrollInfo
-JNIEXPORT jboolean JNICALL OS_NATIVE(GetScrollInfo)
- (JNIEnv *env, jclass that, jint arg0, jint arg1, jobject arg2)
-{
- SCROLLINFO _arg2, *lparg2=NULL;
- jboolean rc;
-
- DEBUG_CALL("GetScrollInfo\n")
-
- if (arg2) lparg2 = getSCROLLINFOFields(env, arg2, &_arg2);
- rc = (jboolean)GetScrollInfo((HWND)arg0, arg1, lparg2);
- if (arg2) setSCROLLINFOFields(env, arg2, lparg2);
- return rc;
-}
-#endif /* NO_GetScrollInfo */
-
-#ifndef NO_GetStockObject
-JNIEXPORT jint JNICALL OS_NATIVE(GetStockObject)
- (JNIEnv *env, jclass that, jint arg0)
-{
- DEBUG_CALL("GetStockObject\n")
-
- return (jint)GetStockObject(arg0);
-}
-#endif /* NO_GetStockObject */
-
-#ifndef NO_GetSysColor
-JNIEXPORT jint JNICALL OS_NATIVE(GetSysColor)
- (JNIEnv *env, jclass that, jint arg0)
-{
- DEBUG_CALL("GetSysColor\n")
-
- return (jint)GetSysColor(arg0);
-}
-#endif /* NO_GetSysColor */
-
-#ifndef NO_GetSysColorBrush
-JNIEXPORT jint JNICALL OS_NATIVE(GetSysColorBrush)
- (JNIEnv *env, jclass that, jint arg0)
-{
- DEBUG_CALL("GetSysColorBrush\n")
-
- return (jint)GetSysColorBrush(arg0);
-}
-#endif /* NO_GetSysColorBrush */
-
-#ifndef NO_GetSystemMenu
-JNIEXPORT jint JNICALL OS_NATIVE(GetSystemMenu)
- (JNIEnv *env, jclass that, jint arg0, jboolean arg1)
-{
- DEBUG_CALL("GetSystemMenu\n")
-
- return (jint)GetSystemMenu((HWND)arg0, arg1);
-}
-#endif /* NO_GetSystemMenu */
-
-#ifndef NO_GetSystemMetrics
-JNIEXPORT jint JNICALL OS_NATIVE(GetSystemMetrics)
- (JNIEnv *env, jclass that, jint arg0)
-{
- DEBUG_CALL("GetSystemMetrics\n")
-
- return (jint)GetSystemMetrics(arg0);
-}
-#endif /* NO_GetSystemMetrics */
-
-#ifndef NO_GetSystemPaletteEntries
-JNIEXPORT jint JNICALL OS_NATIVE(GetSystemPaletteEntries)
- (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jbyteArray arg3)
-{
- jbyte *lparg3=NULL;
- jint rc;
-
- DEBUG_CALL("GetSystemPaletteEntries\n");
-
- if (arg3) lparg3 = (*env)->GetByteArrayElements(env, arg3, NULL);
- rc = GetSystemPaletteEntries((HDC)arg0, (UINT)arg1, (UINT)arg2, (LPPALETTEENTRY)lparg3);
- if (arg3) (*env)->ReleaseByteArrayElements(env, arg3, lparg3, 0);
- return rc;
-}
-#endif /* NO_GetSystemPaletteEntries */
-
-#ifndef NO_GetTextCharset
-JNIEXPORT jint JNICALL OS_NATIVE(GetTextCharset)
- (JNIEnv *env, jclass that, jint arg0)
-{
- DEBUG_CALL("GetTextCharset\n")
-
- return (jint)GetTextCharset((HDC)arg0);
-}
-#endif /* NO_GetTextCharset */
-
-#ifndef NO_GetTextColor
-JNIEXPORT jint JNICALL OS_NATIVE(GetTextColor)
- (JNIEnv *env, jclass that, jint arg0)
-{
- DEBUG_CALL("GetTextColor\n")
-
- return (jint)GetTextColor((HDC)arg0);
-}
-#endif /* NO_GetTextColor */
-
-#ifndef NO_GetTextExtentPoint32A
-JNIEXPORT jboolean JNICALL OS_NATIVE(GetTextExtentPoint32A)
- (JNIEnv *env, jclass that, jint arg0, jbyteArray arg1, jint arg2, jobject arg3)
-{
- jbyte *lparg1=NULL;
- SIZE _arg3, *lparg3=NULL;
- jboolean rc;
-
- DEBUG_CALL("GetTextExtentPoint32A\n")
-
- if (arg1) lparg1 = (*env)->GetByteArrayElements(env, arg1, NULL);
- if (arg3) lparg3 = getSIZEFields(env, arg3, &_arg3);
- rc = (jboolean)GetTextExtentPoint32A((HDC)arg0, (LPSTR)lparg1, arg2, lparg3);
- if (arg1) (*env)->ReleaseByteArrayElements(env, arg1, lparg1, 0);
- if (arg3) setSIZEFields(env, arg3, lparg3);
- return rc;
-}
-#endif /* NO_GetTextExtentPoint32A */
-
-#ifndef NO_GetTextExtentPoint32W
-JNIEXPORT jboolean JNICALL OS_NATIVE(GetTextExtentPoint32W)
- (JNIEnv *env, jclass that, jint arg0, jcharArray arg1, jint arg2, jobject arg3)
-{
- jchar *lparg1=NULL;
- SIZE _arg3, *lparg3=NULL;
- jboolean rc;
-
- DEBUG_CALL("GetTextExtentPoint32W\n")
-
- if (arg1) lparg1 = (*env)->GetCharArrayElements(env, arg1, NULL);
- if (arg3) lparg3 = getSIZEFields(env, arg3, &_arg3);
- rc = (jboolean)GetTextExtentPoint32W((HDC)arg0, (LPWSTR)lparg1, arg2, lparg3);
- if (arg1) (*env)->ReleaseCharArrayElements(env, arg1, lparg1, 0);
- if (arg3) setSIZEFields(env, arg3, lparg3);
- return rc;
-}
-#endif /* NO_GetTextExtentPoint32W */
-
-#ifndef NO_GetTextMetricsA
-JNIEXPORT jboolean JNICALL OS_NATIVE(GetTextMetricsA)
- (JNIEnv *env, jclass that, jint arg0, jobject arg1)
-{
- TEXTMETRICA _arg1={0}, *lparg1=NULL; /* SPECIAL */
- jboolean rc;
-
- DEBUG_CALL("GetTextMetricsA\n")
-
- if (arg1) lparg1 = &_arg1;
- rc = (jboolean)GetTextMetricsA((HDC)arg0, lparg1);
- if (arg1) setTEXTMETRICAFields(env, arg1, lparg1);
- return rc;
-}
-#endif /* NO_GetTextMetricsA */
-
-#ifndef NO_GetTextMetricsW
-JNIEXPORT jboolean JNICALL OS_NATIVE(GetTextMetricsW)
- (JNIEnv *env, jclass that, jint arg0, jobject arg1)
-{
- TEXTMETRICW _arg1={0}, *lparg1=NULL; /* SPECIAL */
- jboolean rc;
-
- DEBUG_CALL("GetTextMetricsW\n")
-
- if (arg1) lparg1 = &_arg1;
- rc = (jboolean)GetTextMetricsW((HDC)arg0, lparg1);
- if (arg1) setTEXTMETRICWFields(env, arg1, lparg1);
- return rc;
-}
-#endif /* NO_GetTextMetricsW */
-
-#ifndef NO_GetTickCount
-JNIEXPORT jint JNICALL OS_NATIVE(GetTickCount)
- (JNIEnv *env, jclass that)
-{
- DEBUG_CALL("GetTickCount\n")
-
- return (jint)GetTickCount();
-}
-#endif /* NO_GetTickCount */
-
-#ifndef NO_GetUpdateRect
-JNIEXPORT jboolean JNICALL OS_NATIVE(GetUpdateRect)
- (JNIEnv *env, jclass that, jint arg0, jobject arg1, jboolean arg2)
-{
- RECT _arg1, *lparg1=NULL;
- jboolean rc;
-
- DEBUG_CALL("GetUpdateRect\n")
-
- if (arg1) lparg1 = getRECTFields(env, arg1, &_arg1);
- rc = (jboolean)GetUpdateRect((HWND)arg0, (LPRECT)lparg1, (BOOL)arg2);
- if (arg1) setRECTFields(env, arg1, lparg1);
- return rc;
-}
-#endif /* NO_GetUpdateRect */
-
-#ifndef NO_GetUpdateRgn
-JNIEXPORT jint JNICALL OS_NATIVE(GetUpdateRgn)
- (JNIEnv *env, jclass that, jint arg0, jint arg1, jboolean arg2)
-{
- DEBUG_CALL("GetUpdateRgn\n")
-
- return (jint)GetUpdateRgn((HWND)arg0, (HRGN)arg1, arg2);
-}
-#endif /* NO_GetUpdateRgn */
-
-#ifndef NO_GetVersionExA
-JNIEXPORT jboolean JNICALL OS_NATIVE(GetVersionExA)
- (JNIEnv *env, jclass that, jobject arg0)
-{
- OSVERSIONINFOA _arg0={0}, *lparg0=NULL; /* SPECIAL */
- jboolean rc;
-
- DEBUG_CALL("GetVersionExA\n")
-
- if (arg0) lparg0 = getOSVERSIONINFOAFields(env, arg0, &_arg0);
- rc = (jboolean)GetVersionExA(lparg0);
- if (arg0) setOSVERSIONINFOAFields(env, arg0, lparg0);
- return rc;
-}
-#endif /* NO_GetVersionExA */
-
-#ifndef NO_GetVersionExW
-JNIEXPORT jboolean JNICALL OS_NATIVE(GetVersionExW)
- (JNIEnv *env, jclass that, jobject arg0)
-{
- OSVERSIONINFOW _arg0={0}, *lparg0=NULL; /* SPECIAL */
- jboolean rc;
-
- DEBUG_CALL("GetVersionExW\n")
-
- if (arg0) lparg0 = getOSVERSIONINFOWFields(env, arg0, &_arg0);
- rc = (jboolean)GetVersionExW(lparg0);
- if (arg0) setOSVERSIONINFOWFields(env, arg0, lparg0);
- return rc;
-}
-#endif /* NO_GetVersionExW */
-
-#ifndef NO_GetWindow
-JNIEXPORT jint JNICALL OS_NATIVE(GetWindow)
- (JNIEnv *env, jclass that, jint arg0, jint arg1)
-{
- DEBUG_CALL("GetWindow\n")
-
- return (jint)GetWindow((HWND)arg0, arg1);
-}
-#endif /* NO_GetWindow */
-
-#ifndef NO_GetWindowLongA
-JNIEXPORT jint JNICALL OS_NATIVE(GetWindowLongA)
- (JNIEnv *env, jclass that, jint arg0, jint arg1)
-{
- DEBUG_CALL("GetWindowLongA\n")
-
- return (jint)GetWindowLongA((HWND)arg0, arg1);
-}
-#endif /* NO_GetWindowLongA */
-
-#ifndef NO_GetWindowLongW
-JNIEXPORT jint JNICALL OS_NATIVE(GetWindowLongW)
- (JNIEnv *env, jclass that, jint arg0, jint arg1)
-{
- DEBUG_CALL("GetWindowLongW\n")
-
- return (jint)GetWindowLongW((HWND)arg0, arg1);
-}
-#endif /* NO_GetWindowLongW */
-
-#ifndef NO_GetWindowPlacement
-JNIEXPORT jboolean JNICALL OS_NATIVE(GetWindowPlacement)
- (JNIEnv *env, jclass that, jint arg0, jobject arg1)
-{
- WINDOWPLACEMENT _arg1, *lparg1=NULL;
- jboolean rc;
-
- DEBUG_CALL("GetWindowPlacement\n")
-
- if (arg1) lparg1 = getWINDOWPLACEMENTFields(env, arg1, &_arg1);
- rc = (jboolean)GetWindowPlacement((HWND)arg0, lparg1);
- if (arg1) setWINDOWPLACEMENTFields(env, arg1, lparg1);
- return rc;
-}
-#endif /* NO_GetWindowPlacement */
-
-#ifndef NO_GetWindowRect
-JNIEXPORT jboolean JNICALL OS_NATIVE(GetWindowRect)
- (JNIEnv *env, jclass that, jint arg0, jobject arg1)
-{
- RECT _arg1, *lparg1=NULL;
- jboolean rc;
-
- DEBUG_CALL("GetWindowRect\n")
-
- if (arg1) lparg1 = getRECTFields(env, arg1, &_arg1);
- rc = (jboolean)GetWindowRect((HWND)arg0, lparg1);
- if (arg1) setRECTFields(env, arg1, lparg1);
- return rc;
-}
-#endif /* NO_GetWindowRect */
-
-#ifndef NO_GetWindowTextA
-JNIEXPORT jint JNICALL OS_NATIVE(GetWindowTextA)
- (JNIEnv *env, jclass that, jint arg0, jbyteArray arg1, jint arg2)
-{
- jbyte *lparg1=NULL;
- jint rc;
-
- DEBUG_CALL("GetWindowTextA\n")
-
- if (arg1) lparg1 = (*env)->GetByteArrayElements(env, arg1, NULL);
- rc = (jint)GetWindowTextA((HWND)arg0, (LPSTR)lparg1, arg2);
- if (arg1) (*env)->ReleaseByteArrayElements(env, arg1, lparg1, 0);
- return rc;
-}
-#endif /* NO_GetWindowTextA */
-
-#ifndef NO_GetWindowTextLengthA
-JNIEXPORT jint JNICALL OS_NATIVE(GetWindowTextLengthA)
- (JNIEnv *env, jclass that, jint arg0)
-{
- DEBUG_CALL("GetWindowTextLengthA\n")
-
- return (jint)GetWindowTextLengthA((HWND)arg0);
-}
-#endif /* NO_GetWindowTextLengthA */
-
-#ifndef NO_GetWindowTextLengthW
-JNIEXPORT jint JNICALL OS_NATIVE(GetWindowTextLengthW)
- (JNIEnv *env, jclass that, jint arg0)
-{
- DEBUG_CALL("GetWindowTextLengthW\n")
-
- return (jint)GetWindowTextLengthW((HWND)arg0);
-}
-#endif /* NO_GetWindowTextLengthW */
-
-#ifndef NO_GetWindowTextW
-JNIEXPORT jint JNICALL OS_NATIVE(GetWindowTextW)
- (JNIEnv *env, jclass that, jint arg0, jcharArray arg1, jint arg2)
-{
- jchar *lparg1=NULL;
- jint rc;
-
- DEBUG_CALL("GetWindowTextW\n")
-
- if (arg1) lparg1 = (*env)->GetCharArrayElements(env, arg1, NULL);
- rc = (jint)GetWindowTextW((HWND)arg0, (LPWSTR)lparg1, arg2);
- if (arg1) (*env)->ReleaseCharArrayElements(env, arg1, lparg1, 0);
- return rc;
-}
-#endif /* NO_GetWindowTextW */
-
-#ifndef NO_GetWindowThreadProcessId
-JNIEXPORT jint JNICALL OS_NATIVE(GetWindowThreadProcessId)
- (JNIEnv *env, jclass that, jint arg0, jintArray arg1)
-{
- jint *lparg1=NULL;
- jint rc;
-
- DEBUG_CALL("GetWindowThreadProcessId\n")
-
- if (arg1) lparg1 = (*env)->GetIntArrayElements(env, arg1, NULL);
- rc = (jint)GetWindowThreadProcessId((HWND)arg0, (LPDWORD)lparg1);
- if (arg1) (*env)->ReleaseIntArrayElements(env, arg1, lparg1, 0);
- return rc;
-}
-#endif /* NO_GetWindowThreadProcessId */
-
-#ifndef NO_GlobalAlloc
-JNIEXPORT jint JNICALL OS_NATIVE(GlobalAlloc)
- (JNIEnv *env, jclass that, jint arg0, jint arg1)
-{
- DEBUG_CALL("GlobalAlloc\n")
-
- return (jint)GlobalAlloc(arg0, arg1);
-}
-#endif /* NO_GlobalAlloc */
-
-#ifndef NO_GlobalFree
-JNIEXPORT jint JNICALL OS_NATIVE(GlobalFree)
- (JNIEnv *env, jclass that, jint arg0)
-{
- DEBUG_CALL("GlobalFree\n")
-
- return (jint)GlobalFree((HANDLE)arg0);
-}
-#endif /* NO_GlobalFree */
-
-#ifndef NO_GlobalLock
-JNIEXPORT jint JNICALL OS_NATIVE(GlobalLock)
- (JNIEnv *env, jclass that, jint arg0)
-{
- DEBUG_CALL("GlobalLock\n")
-
- return (jint)GlobalLock((HANDLE)arg0);
-}
-#endif /* NO_GlobalLock */
-
-#ifndef NO_GlobalSize
-JNIEXPORT jint JNICALL OS_NATIVE(GlobalSize)
- (JNIEnv *env, jclass that, jint arg0)
-{
- DEBUG_CALL("GlobalSize\n")
-
- return (jint)GlobalSize((HANDLE)arg0);
-}
-#endif /* NO_GlobalSize */
-
-#ifndef NO_GlobalUnlock
-JNIEXPORT jboolean JNICALL OS_NATIVE(GlobalUnlock)
- (JNIEnv *env, jclass that, jint arg0)
-{
- DEBUG_CALL("GlobalUnlock\n")
-
- return (jboolean)GlobalUnlock((HANDLE)arg0);
-}
-#endif /* NO_GlobalUnlock */
-
-#ifndef NO_GradientFill
-JNIEXPORT jboolean JNICALL OS_NATIVE(GradientFill)
- (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jint arg3, jint arg4, jint arg5)
-{
- HMODULE hm;
- FARPROC fp;
-
- DEBUG_CALL("GradientFill\n")
-
- /* SPECIAL */
- /*
- * GradientFill 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("msimg32.dll"))) hm = LoadLibrary("msimg32.dll");
- if (hm && (fp = GetProcAddress(hm, "GradientFill"))) {
-// return (jboolean)GradientFill((HDC)arg0, (PTRIVERTEX)arg1, (ULONG)arg2, (PVOID)arg3, (ULONG)arg4, (ULONG)arg5);
- return (jboolean)fp(arg0, arg1, arg2, arg3, arg4, arg5);
- }
- return (jboolean)FALSE;
-}
-#endif /* NO_GradientFill */
-
-#ifndef NO_HeapAlloc
-JNIEXPORT jint JNICALL OS_NATIVE(HeapAlloc)
- (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2)
-{
- DEBUG_CALL("HeapAlloc\n")
-
- return (jint)HeapAlloc((HANDLE)arg0, arg1, arg2);
-}
-#endif /* NO_HeapAlloc */
-
-#ifndef NO_HeapFree
-JNIEXPORT jboolean JNICALL OS_NATIVE(HeapFree)
- (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2)
-{
- DEBUG_CALL("HeapFree\n")
-
- return (jboolean)HeapFree((HANDLE)arg0, arg1, (LPVOID)arg2);
-}
-#endif /* NO_HeapFree */
-
-#ifndef NO_HideCaret
-JNIEXPORT jboolean JNICALL OS_NATIVE(HideCaret)
- (JNIEnv *env, jclass that, jint arg0)
-{
- DEBUG_CALL("HideCaret\n")
-
- return (jboolean)HideCaret((HWND)arg0);
-}
-#endif /* NO_HideCaret */
-
-#ifndef NO_ImageList_1Add
-JNIEXPORT jint JNICALL OS_NATIVE(ImageList_1Add)
- (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2)
-{
- DEBUG_CALL("ImageList_1Add\n")
-
- return (jint)ImageList_Add((HIMAGELIST)arg0, (HBITMAP)arg1, (HBITMAP)arg2);
-}
-#endif /* NO_ImageList_1Add */
-
-#ifndef NO_ImageList_1AddMasked
-JNIEXPORT jint JNICALL OS_NATIVE(ImageList_1AddMasked)
- (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2)
-{
- DEBUG_CALL("ImageList_1AddMasked\n")
-
- return (jint)ImageList_AddMasked((HIMAGELIST)arg0, (HBITMAP)arg1, (COLORREF)arg2);
-}
-#endif /* NO_ImageList_1AddMasked */
-
-#ifndef NO_ImageList_1Create
-JNIEXPORT jint JNICALL OS_NATIVE(ImageList_1Create)
- (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jint arg3, jint arg4)
-{
- DEBUG_CALL("ImageList_1Create\n")
-
- return (jint)ImageList_Create(arg0, arg1, arg2, arg3, arg4);
-}
-#endif /* NO_ImageList_1Create */
-
-#ifndef NO_ImageList_1Destroy
-JNIEXPORT jboolean JNICALL OS_NATIVE(ImageList_1Destroy)
- (JNIEnv *env, jclass that, jint arg0)
-{
- DEBUG_CALL("ImageList_1Destroy\n")
-
- return (jboolean)ImageList_Destroy((HIMAGELIST)arg0);
-}
-#endif /* NO_ImageList_1Destroy */
-
-#ifndef NO_ImageList_1GetIcon
-JNIEXPORT jint JNICALL OS_NATIVE(ImageList_1GetIcon)
- (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2)
-{
- DEBUG_CALL("ImageList_1GetIcon\n")
-
- return (jint)ImageList_GetIcon((HIMAGELIST)arg0, arg1, arg2);
-}
-#endif /* NO_ImageList_1GetIcon */
-
-#ifndef NO_ImageList_1GetIconSize
-JNIEXPORT jboolean JNICALL OS_NATIVE(ImageList_1GetIconSize)
- (JNIEnv *env, jclass that, jint arg0, jintArray arg1, jintArray arg2)
-{
- jint *lparg1=NULL;
- jint *lparg2=NULL;
- jboolean rc;
-
- DEBUG_CALL("ImageList_1GetIconSize\n")
-
- if (arg1) lparg1 = (*env)->GetIntArrayElements(env, arg1, NULL);
- if (arg2) lparg2 = (*env)->GetIntArrayElements(env, arg2, NULL);
- rc = (jboolean)ImageList_GetIconSize((HIMAGELIST)arg0, lparg1, lparg2);
- if (arg1) (*env)->ReleaseIntArrayElements(env, arg1, lparg1, 0);
- if (arg2) (*env)->ReleaseIntArrayElements(env, arg2, lparg2, 0);
- return rc;
-}
-#endif /* NO_ImageList_1GetIconSize */
-
-#ifndef NO_ImageList_1GetImageCount
-JNIEXPORT jint JNICALL OS_NATIVE(ImageList_1GetImageCount)
- (JNIEnv *env, jclass that, jint arg0)
-{
- DEBUG_CALL("ImageList_1GetImageCount\n")
-
- return (jint)ImageList_GetImageCount((HIMAGELIST)arg0);
-}
-#endif /* NO_ImageList_1GetImageCount */
-
-#ifndef NO_ImageList_1Remove
-JNIEXPORT jboolean JNICALL OS_NATIVE(ImageList_1Remove)
- (JNIEnv *env, jclass that, jint arg0, jint arg1)
-{
- DEBUG_CALL("ImageList_1Remove\n")
-
- return (jboolean)ImageList_Remove((HIMAGELIST)arg0, arg1);
-}
-#endif /* NO_ImageList_1Remove */
-
-#ifndef NO_ImageList_1Replace
-JNIEXPORT jboolean JNICALL OS_NATIVE(ImageList_1Replace)
- (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jint arg3)
-{
- DEBUG_CALL("ImageList_1Replace\n")
-
- return (jboolean)ImageList_Replace((HIMAGELIST)arg0, arg1, (HBITMAP)arg2, (HBITMAP)arg3);
-}
-#endif /* NO_ImageList_1Replace */
-
-#ifndef NO_ImageList_1ReplaceIcon
-JNIEXPORT jint JNICALL OS_NATIVE(ImageList_1ReplaceIcon)
- (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2)
-{
- DEBUG_CALL("ImageList_1ReplaceIcon\n")
-
- return (jint)ImageList_ReplaceIcon((HIMAGELIST)arg0, arg1, (HICON)arg2);
-}
-#endif /* NO_ImageList_1ReplaceIcon */
-
-#ifndef NO_ImageList_1SetIconSize
-JNIEXPORT jboolean JNICALL OS_NATIVE(ImageList_1SetIconSize)
- (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2)
-{
- DEBUG_CALL("ImageList_1SetIconSize\n")
-
- return (jboolean)ImageList_SetIconSize((HIMAGELIST)arg0, arg1, arg2);
-}
-#endif /* NO_ImageList_1SetIconSize */
-
-#ifndef NO_ImmAssociateContext
-JNIEXPORT jint JNICALL OS_NATIVE(ImmAssociateContext)
- (JNIEnv *env, jclass that, jint arg0, jint arg1)
-{
- DEBUG_CALL("ImmAssociateContext\n")
-
- return (jint)ImmAssociateContext((HWND)arg0, (HIMC)arg1);
-}
-#endif /* NO_ImmAssociateContext */
-
-#ifndef NO_ImmCreateContext
-JNIEXPORT jint JNICALL OS_NATIVE(ImmCreateContext)
- (JNIEnv *env, jclass that)
-{
- DEBUG_CALL("ImmCreateContext\n")
-
- return (jint)ImmCreateContext();
-}
-#endif /* NO_ImmCreateContext */
-
-#ifndef NO_ImmDestroyContext
-JNIEXPORT jboolean JNICALL OS_NATIVE(ImmDestroyContext)
- (JNIEnv *env, jclass that, jint arg0)
-{
- DEBUG_CALL("ImmDestroyContext\n")
-
- return (jboolean)ImmDestroyContext((HIMC)arg0);
-}
-#endif /* NO_ImmDestroyContext */
-
-#ifndef NO_ImmGetCompositionFontA
-JNIEXPORT jboolean JNICALL OS_NATIVE(ImmGetCompositionFontA)
- (JNIEnv *env, jclass that, jint arg0, jobject arg1)
-{
- LOGFONTA _arg1, *lparg1=NULL;
- jboolean rc;
-
- DEBUG_CALL("ImmGetCompositionFontA\n")
-
- if (arg1) lparg1 = getLOGFONTAFields(env, arg1, &_arg1);
- rc = (jboolean)ImmGetCompositionFontA((HIMC)arg0, lparg1);
- if (arg1) setLOGFONTAFields(env, arg1, lparg1);
- return rc;
-}
-#endif /* NO_ImmGetCompositionFontA */
-
-#ifndef NO_ImmGetCompositionFontW
-JNIEXPORT jboolean JNICALL OS_NATIVE(ImmGetCompositionFontW)
- (JNIEnv *env, jclass that, jint arg0, jobject arg1)
-{
- LOGFONTW _arg1, *lparg1=NULL;
- jboolean rc;
-
- DEBUG_CALL("ImmGetCompositionFontW\n")
-
- if (arg1) lparg1 = getLOGFONTWFields(env, arg1, &_arg1);
- rc = (jboolean)ImmGetCompositionFontW((HIMC)arg0, lparg1);
- if (arg1) setLOGFONTWFields(env, arg1, lparg1);
- return rc;
-}
-#endif /* NO_ImmGetCompositionFontW */
-
-#ifndef NO_ImmGetCompositionStringA
-JNIEXPORT jint JNICALL OS_NATIVE(ImmGetCompositionStringA)
- (JNIEnv *env, jclass that, jint arg0, jint arg1, jbyteArray arg2, jint arg3)
-{
- jbyte *lparg2=NULL;
- jint rc;
-
- DEBUG_CALL("ImmGetCompositionStringA\n")
-
- if (arg2) lparg2 = (*env)->GetByteArrayElements(env, arg2, NULL);
- rc = (jint)ImmGetCompositionStringA((HIMC)arg0, arg1, (LPSTR)lparg2, arg3);
- if (arg2) (*env)->ReleaseByteArrayElements(env, arg2, lparg2, 0);
- return rc;
-}
-#endif /* NO_ImmGetCompositionStringA */
-
-#ifndef NO_ImmGetCompositionStringW
-JNIEXPORT jint JNICALL OS_NATIVE(ImmGetCompositionStringW)
- (JNIEnv *env, jclass that, jint arg0, jint arg1, jcharArray arg2, jint arg3)
-{
- jchar *lparg2=NULL;
- jint rc;
-
- DEBUG_CALL("ImmGetCompositionStringW\n")
-
- if (arg2) lparg2 = (*env)->GetCharArrayElements(env, arg2, NULL);
- rc = (jint)ImmGetCompositionStringW((HIMC)arg0, arg1, (LPWSTR)lparg2, arg3);
- if (arg2) (*env)->ReleaseCharArrayElements(env, arg2, lparg2, 0);
- return rc;
-}
-#endif /* NO_ImmGetCompositionStringW */
-
-#ifndef NO_ImmGetContext
-JNIEXPORT jint JNICALL OS_NATIVE(ImmGetContext)
- (JNIEnv *env, jclass that, jint arg0)
-{
- DEBUG_CALL("ImmGetContext\n")
-
- return (jint)ImmGetContext((HWND)arg0);
-}
-#endif /* NO_ImmGetContext */
-
-#ifndef NO_ImmGetConversionStatus
-JNIEXPORT jboolean JNICALL OS_NATIVE(ImmGetConversionStatus)
- (JNIEnv *env, jclass that, jint arg0, jintArray arg1, jintArray arg2)
-{
- jint *lparg1=NULL;
- jint *lparg2=NULL;
- jboolean rc;
-
- DEBUG_CALL("ImmGetConversionStatus\n")
-
- if (arg1) lparg1 = (*env)->GetIntArrayElements(env, arg1, NULL);
- if (arg2) lparg2 = (*env)->GetIntArrayElements(env, arg2, NULL);
- rc = (jboolean)ImmGetConversionStatus((HIMC)arg0, lparg1, lparg2);
- if (arg1) (*env)->ReleaseIntArrayElements(env, arg1, lparg1, 0);
- if (arg2) (*env)->ReleaseIntArrayElements(env, arg2, lparg2, 0);
- return rc;
-}
-#endif /* NO_ImmGetConversionStatus */
-
-#ifndef NO_ImmGetDefaultIMEWnd
-JNIEXPORT jint JNICALL OS_NATIVE(ImmGetDefaultIMEWnd)
- (JNIEnv *env, jclass that, jint arg0)
-{
- DEBUG_CALL("ImmGetDefaultIMEWnd\n")
-
- return (jint)ImmGetDefaultIMEWnd((HWND)arg0);
-}
-#endif /* NO_ImmGetDefaultIMEWnd */
-
-#ifndef NO_ImmGetOpenStatus
-JNIEXPORT jboolean JNICALL OS_NATIVE(ImmGetOpenStatus)
- (JNIEnv *env, jclass that, jint arg0)
-{
- DEBUG_CALL("ImmGetOpenStatus\n")
-
- return (jboolean)ImmGetOpenStatus((HIMC)arg0);
-}
-#endif /* NO_ImmGetOpenStatus */
-
-#ifndef NO_ImmReleaseContext
-JNIEXPORT jboolean JNICALL OS_NATIVE(ImmReleaseContext)
- (JNIEnv *env, jclass that, jint arg0, jint arg1)
-{
- DEBUG_CALL("ImmReleaseContext\n")
-
- return (jboolean)ImmReleaseContext((HWND)arg0, (HIMC)arg1);
-}
-#endif /* NO_ImmReleaseContext */
-
-#ifndef NO_ImmSetCompositionFontA
-JNIEXPORT jboolean JNICALL OS_NATIVE(ImmSetCompositionFontA)
- (JNIEnv *env, jclass that, jint arg0, jobject arg1)
-{
- LOGFONTA _arg1, *lparg1=NULL;
-
- DEBUG_CALL("ImmSetCompositionFontA\n")
-
- if (arg1) lparg1 = getLOGFONTAFields(env, arg1, &_arg1);
- return (jboolean)ImmSetCompositionFontA((HIMC)arg0, lparg1);
-}
-#endif /* NO_ImmSetCompositionFontA */
-
-#ifndef NO_ImmSetCompositionFontW
-JNIEXPORT jboolean JNICALL OS_NATIVE(ImmSetCompositionFontW)
- (JNIEnv *env, jclass that, jint arg0, jobject arg1)
-{
- LOGFONTW _arg1, *lparg1=NULL;
-
- DEBUG_CALL("ImmSetCompositionFontW\n")
-
- if (arg1) lparg1 = getLOGFONTWFields(env, arg1, &_arg1);
- return (jboolean)ImmSetCompositionFontW((HIMC)arg0, lparg1);
-}
-#endif /* NO_ImmSetCompositionFontW */
-
-#ifndef NO_ImmSetCompositionWindow
-JNIEXPORT jboolean JNICALL OS_NATIVE(ImmSetCompositionWindow)
- (JNIEnv *env, jclass that, jint arg0, jobject arg1)
-{
- COMPOSITIONFORM _arg1, *lparg1=NULL;
- jboolean rc;
-
- DEBUG_CALL("ImmSetCompositionWindow\n")
-
- if (arg1) lparg1 = getCOMPOSITIONFORMFields(env, arg1, &_arg1);
- rc = (jboolean)ImmSetCompositionWindow((HIMC)arg0, lparg1);
- if (arg1) setCOMPOSITIONFORMFields(env, arg1, lparg1);
- return rc;
-}
-#endif /* NO_ImmSetCompositionWindow */
-
-#ifndef NO_ImmSetConversionStatus
-JNIEXPORT jboolean JNICALL OS_NATIVE(ImmSetConversionStatus)
- (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2)
-{
- DEBUG_CALL("ImmSetConversionStatus\n")
-
- return (jboolean)ImmSetConversionStatus((HIMC)arg0, arg1, arg2);
-}
-#endif /* NO_ImmSetConversionStatus */
-
-#ifndef NO_ImmSetOpenStatus
-JNIEXPORT jboolean JNICALL OS_NATIVE(ImmSetOpenStatus)
- (JNIEnv *env, jclass that, jint arg0, jboolean arg1)
-{
- DEBUG_CALL("ImmSetOpenStatus\n")
-
- return (jboolean)ImmSetOpenStatus((HIMC)arg0, arg1);
-}
-#endif /* NO_ImmSetOpenStatus */
-
-#ifndef NO_InitCommonControls
-JNIEXPORT void JNICALL OS_NATIVE(InitCommonControls)
- (JNIEnv *env, jclass that)
-{
- DEBUG_CALL("InitCommonControls\n")
-
- InitCommonControls();
-}
-#endif /* NO_InitCommonControls */
-
-#ifndef NO_InitCommonControlsEx
-JNIEXPORT jboolean JNICALL OS_NATIVE(InitCommonControlsEx)
- (JNIEnv *env, jclass that, jobject arg0)
-{
- INITCOMMONCONTROLSEX _arg0, *lparg0=NULL;
- jboolean rc;
-
- DEBUG_CALL("InitCommonControlsEx\n")
-
- if (arg0) lparg0 = getINITCOMMONCONTROLSEXFields(env, arg0, &_arg0);
- rc = (jboolean)InitCommonControlsEx(lparg0);
- if (arg0) setINITCOMMONCONTROLSEXFields(env, arg0, lparg0);
- return rc;
-}
-#endif /* NO_InitCommonControlsEx */
-
-#ifndef NO_InsertMenuA
-JNIEXPORT jboolean JNICALL OS_NATIVE(InsertMenuA)
- (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jint arg3, jbyteArray arg4)
-{
- jbyte *lparg4=NULL;
- jboolean rc;
-
- DEBUG_CALL("InsertMenuA\n")
-
- if (arg4) lparg4 = (*env)->GetByteArrayElements(env, arg4, NULL);
- rc = (jboolean)InsertMenuA((HMENU)arg0, arg1, arg2, arg3, lparg4);
- if (arg4) (*env)->ReleaseByteArrayElements(env, arg4, lparg4, 0);
- return rc;
-}
-#endif /* NO_InsertMenuA */
-
-#ifndef NO_InsertMenuItemA
-JNIEXPORT jboolean JNICALL OS_NATIVE(InsertMenuItemA)
- (JNIEnv *env, jclass that, jint arg0, jint arg1, jboolean arg2, jobject arg3)
-{
- MENUITEMINFO _arg3, *lparg3=NULL;
- jboolean rc;
-
- DEBUG_CALL("InsertMenuItemA\n")
-
- if (arg3) lparg3 = getMENUITEMINFOFields(env, arg3, &_arg3);
- rc = (jboolean)InsertMenuItemA((HMENU)arg0, arg1, arg2, lparg3);
- if (arg3) setMENUITEMINFOFields(env, arg3, lparg3);
- return rc;
-}
-#endif /* NO_InsertMenuItemA */
-
-#ifndef NO_InsertMenuItemW
-JNIEXPORT jboolean JNICALL OS_NATIVE(InsertMenuItemW)
- (JNIEnv *env, jclass that, jint arg0, jint arg1, jboolean arg2, jobject arg3)
-{
- MENUITEMINFO _arg3, *lparg3=NULL;
- jboolean rc;
-
- DEBUG_CALL("InsertMenuItemW\n")
-
- if (arg3) lparg3 = getMENUITEMINFOFields(env, arg3, &_arg3);
- rc = (jboolean)InsertMenuItemW((HMENU)arg0, arg1, arg2, (LPMENUITEMINFOW)lparg3);
- if (arg3) setMENUITEMINFOFields(env, arg3, lparg3);
- return rc;
-}
-#endif /* NO_InsertMenuItemW */
-
-#ifndef NO_InsertMenuW
-JNIEXPORT jboolean JNICALL OS_NATIVE(InsertMenuW)
- (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jint arg3, jcharArray arg4)
-{
- jchar *lparg4=NULL;
- jboolean rc;
-
- DEBUG_CALL("InsertMenuW\n")
-
- if (arg4) lparg4 = (*env)->GetCharArrayElements(env, arg4, NULL);
- rc = (jboolean)InsertMenuW((HMENU)arg0, arg1, arg2, arg3, lparg4);
- if (arg4) (*env)->ReleaseCharArrayElements(env, arg4, lparg4, 0);
- return rc;
-}
-#endif /* NO_InsertMenuW */
-
-#ifndef NO_InvalidateRect
-JNIEXPORT jboolean JNICALL OS_NATIVE(InvalidateRect)
- (JNIEnv *env, jclass that, jint arg0, jobject arg1, jboolean arg2)
-{
- RECT _arg1, *lparg1=NULL;
- jboolean rc;
-
- DEBUG_CALL("InvalidateRect\n")
-
- if (arg1) lparg1 = getRECTFields(env, arg1, &_arg1);
- rc = (jboolean)InvalidateRect((HWND)arg0, lparg1, arg2);
- if (arg1) setRECTFields(env, arg1, lparg1);
- return rc;
-}
-#endif /* NO_InvalidateRect */
-
-#ifndef NO_InvalidateRgn
-JNIEXPORT jboolean JNICALL OS_NATIVE(InvalidateRgn)
- (JNIEnv *env, jclass that, jint arg0, jint arg1, jboolean arg2)
-{
- DEBUG_CALL("InvalidateRgn\n")
-
- return (jboolean)InvalidateRgn((HWND)arg0, (HRGN)arg1, arg2);
-}
-#endif /* NO_InvalidateRgn */
-
-#ifndef NO_IsDBCSLeadByte
-JNIEXPORT jboolean JNICALL OS_NATIVE(IsDBCSLeadByte)
- (JNIEnv *env, jclass that, jbyte arg0)
-{
- DEBUG_CALL("IsDBCSLeadByte\n")
-
- return (jboolean)IsDBCSLeadByte(arg0);
-}
-#endif /* NO_IsDBCSLeadByte */
-
-#ifndef NO_IsIconic
-JNIEXPORT jboolean JNICALL OS_NATIVE(IsIconic)
- (JNIEnv *env, jclass that, jint arg0)
-{
- DEBUG_CALL("IsIconic\n")
-
- return (jboolean)IsIconic((HWND)arg0);
-}
-#endif /* NO_IsIconic */
-
-#ifndef NO_IsPPC
-/* SPECIAL */
-JNIEXPORT jboolean JNICALL OS_NATIVE(IsPPC)
- (JNIEnv *env, jclass that)
-{
- DEBUG_CALL("IsPPC\n")
-#ifdef WIN32_PLATFORM_PSPC
- return TRUE;
-#else
- return FALSE;
-#endif /* WIN32_PLATFORM_PSPC */
-}
-#endif /* NO_IsPPC */
-
-#ifndef NO_IsSP
-/* SPECIAL */
-JNIEXPORT jboolean JNICALL OS_NATIVE(IsSP)
- (JNIEnv *env, jclass that)
-{
- DEBUG_CALL("IsSP\n")
-#ifdef WIN32_PLATFORM_WFSP
- return TRUE;
-#else
- return FALSE;
-#endif /* WIN32_PLATFORM_WFSP */
-}
-#endif /* NO_IsSP */
-
-#ifndef NO_IsWindowEnabled
-JNIEXPORT jboolean JNICALL OS_NATIVE(IsWindowEnabled)
- (JNIEnv *env, jclass that, jint arg0)
-{
- DEBUG_CALL("IsWindowEnabled\n")
-
- return (jboolean)IsWindowEnabled((HWND)arg0);
-}
-#endif /* NO_IsWindowEnabled */
-
-#ifndef NO_IsWindowVisible
-JNIEXPORT jboolean JNICALL OS_NATIVE(IsWindowVisible)
- (JNIEnv *env, jclass that, jint arg0)
-{
- DEBUG_CALL("IsWindowVisible\n")
-
- return (jboolean)IsWindowVisible((HWND)arg0);
-}
-#endif /* NO_IsWindowVisible */
-
-#ifndef NO_IsZoomed
-JNIEXPORT jboolean JNICALL OS_NATIVE(IsZoomed)
- (JNIEnv *env, jclass that, jint arg0)
-{
- DEBUG_CALL("IsZoomed\n")
-
- return (jboolean)IsZoomed((HWND)arg0);
-}
-#endif /* NO_IsZoomed */
-
-#ifndef NO_KillTimer
-JNIEXPORT jboolean JNICALL OS_NATIVE(KillTimer)
- (JNIEnv *env, jclass that, jint arg0, jint arg1)
-{
- DEBUG_CALL("KillTimer\n")
-
- return (jboolean)KillTimer((HWND)arg0, arg1);
-}
-#endif /* NO_KillTimer */
-
-#ifndef NO_LineTo
-JNIEXPORT jboolean JNICALL OS_NATIVE(LineTo)
- (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2)
-{
- DEBUG_CALL("LineTo\n")
-
- return (jboolean)LineTo((HDC)arg0, arg1, arg2);
-}
-#endif /* NO_LineTo */
-
-#ifndef NO_LoadBitmapA
-JNIEXPORT jint JNICALL OS_NATIVE(LoadBitmapA)
- (JNIEnv *env, jclass that, jint arg0, jint arg1)
-{
- DEBUG_CALL("LoadBitmapA\n")
-
- return (jint)LoadBitmapA((HINSTANCE)arg0, (LPSTR)arg1);
-}
-#endif /* NO_LoadBitmapA */
-
-#ifndef NO_LoadBitmapW
-JNIEXPORT jint JNICALL OS_NATIVE(LoadBitmapW)
- (JNIEnv *env, jclass that, jint arg0, jint arg1)
-{
- DEBUG_CALL("LoadBitmapW\n")
-
- return (jint)LoadBitmapW((HINSTANCE)arg0, (LPWSTR)arg1);
-}
-#endif /* NO_LoadBitmapW */
-
-#ifndef NO_LoadCursorA
-JNIEXPORT jint JNICALL OS_NATIVE(LoadCursorA)
- (JNIEnv *env, jclass that, jint arg0, jint arg1)
-{
- DEBUG_CALL("LoadCursorA\n")
-
- return (jint)LoadCursorA((HINSTANCE)arg0, (LPSTR)arg1);
-}
-#endif /* NO_LoadCursorA */
-
-#ifndef NO_LoadCursorW
-JNIEXPORT jint JNICALL OS_NATIVE(LoadCursorW)
- (JNIEnv *env, jclass that, jint arg0, jint arg1)
-{
- DEBUG_CALL("LoadCursorW\n")
-
- return (jint)LoadCursorW((HINSTANCE)arg0, (LPWSTR)arg1);
-}
-#endif /* NO_LoadCursorW */
-
-#ifndef NO_LoadIconA
-JNIEXPORT jint JNICALL OS_NATIVE(LoadIconA)
- (JNIEnv *env, jclass that, jint arg0, jint arg1)
-{
- DEBUG_CALL("LoadIconA\n")
-
- return (jint)LoadIconA((HINSTANCE)arg0, (LPSTR)arg1);
-}
-#endif /* NO_LoadIconA */
-
-#ifndef NO_LoadIconW
-JNIEXPORT jint JNICALL OS_NATIVE(LoadIconW)
- (JNIEnv *env, jclass that, jint arg0, jint arg1)
-{
- DEBUG_CALL("LoadIconW\n")
-
- return (jint)LoadIconW((HINSTANCE)arg0, (LPWSTR)arg1);
-}
-#endif /* NO_LoadIconW */
-
-#ifndef NO_LoadImageA
-JNIEXPORT jint JNICALL OS_NATIVE(LoadImageA)
- (JNIEnv *env, jclass that, jint arg0, jbyteArray arg1, jint arg2, jint arg3, jint arg4, jint arg5)
-{
- jbyte *lparg1=NULL;
- jint rc;
-
- DEBUG_CALL("LoadImageA\n")
-
- if (arg1) lparg1 = (*env)->GetByteArrayElements(env, arg1, NULL);
- rc = (jint)LoadImageA((HINSTANCE)arg0, (LPSTR)lparg1, arg2, arg3, arg4, arg5);
- if (arg1) (*env)->ReleaseByteArrayElements(env, arg1, lparg1, 0);
- return rc;
-}
-#endif /* NO_LoadImageA */
-
-#ifndef NO_LoadImageW
-JNIEXPORT jint JNICALL OS_NATIVE(LoadImageW)
- (JNIEnv *env, jclass that, jint arg0, jcharArray arg1, jint arg2, jint arg3, jint arg4, jint arg5)
-{
- jchar *lparg1=NULL;
- jint rc;
-
- DEBUG_CALL("LoadImageW\n")
-
- if (arg1) lparg1 = (*env)->GetCharArrayElements(env, arg1, NULL);
- rc = (jint)LoadImageW((HINSTANCE)arg0, (LPWSTR)lparg1, arg2, arg3, arg4, arg5);
- if (arg1) (*env)->ReleaseCharArrayElements(env, arg1, lparg1, 0);
- return rc;
-}
-#endif /* NO_LoadImageW */
-
-#ifndef NO_LoadLibraryA
-JNIEXPORT jint JNICALL OS_NATIVE(LoadLibraryA)
- (JNIEnv *env, jclass that, jbyteArray arg0)
-{
- jbyte *lparg0=NULL;
- jint rc;
-
- DEBUG_CALL("LoadLibraryA\n")
-
- if (arg0) lparg0 = (*env)->GetByteArrayElements(env, arg0, NULL);
- rc = (jint)LoadLibraryA((LPSTR)lparg0);
- if (arg0) (*env)->ReleaseByteArrayElements(env, arg0, lparg0, 0);
- return rc;
-}
-#endif /* NO_LoadLibraryA */
-
-#ifndef NO_LoadLibraryW
-JNIEXPORT jint JNICALL OS_NATIVE(LoadLibraryW)
- (JNIEnv *env, jclass that, jcharArray arg0)
-{
- jchar *lparg0=NULL;
- jint rc;
-
- DEBUG_CALL("LoadLibraryW\n")
-
- if (arg0) lparg0 = (*env)->GetCharArrayElements(env, arg0, NULL);
- rc = (jint)LoadLibraryW((LPWSTR)lparg0);
- if (arg0) (*env)->ReleaseCharArrayElements(env, arg0, lparg0, 0);
- return rc;
-}
-#endif /* NO_LoadLibraryW */
-
-#ifndef NO_MapVirtualKeyA
-JNIEXPORT jint JNICALL OS_NATIVE(MapVirtualKeyA)
- (JNIEnv *env, jclass that, jint arg0, jint arg1)
-{
- DEBUG_CALL("MapVirtualKeyA\n")
-
- return (jint)MapVirtualKeyA(arg0, arg1);
-}
-#endif /* NO_MapVirtualKeyA */
-
-#ifndef NO_MapVirtualKeyW
-JNIEXPORT jint JNICALL OS_NATIVE(MapVirtualKeyW)
- (JNIEnv *env, jclass that, jint arg0, jint arg1)
-{
- DEBUG_CALL("MapVirtualKeyW\n")
-
- return (jint)MapVirtualKeyW(arg0, arg1);
-}
-#endif /* NO_MapVirtualKeyW */
-
-#ifndef NO_MapWindowPoints__IILorg_eclipse_swt_internal_win32_RECT_2I
-JNIEXPORT jint JNICALL OS_NATIVE(MapWindowPoints__IILorg_eclipse_swt_internal_win32_RECT_2I)
- (JNIEnv *env, jclass that, jint arg0, jint arg1, jobject arg2, jint arg3)
-{
- RECT _arg2, *lparg2=NULL;
- jint rc;
-
- DEBUG_CALL("MapWindowPoints__IILorg_eclipse_swt_internal_win32_RECT_2I\n")
-
- if (arg2) lparg2 = getRECTFields(env, arg2, &_arg2);
- rc = (jint)MapWindowPoints((HWND)arg0, (HWND)arg1, (LPPOINT)lparg2, arg3);
- if (arg2) setRECTFields(env, arg2, lparg2);
- return rc;
-}
-#endif /* NO_MapWindowPoints__IILorg_eclipse_swt_internal_win32_RECT_2I */
-
-#ifndef NO_MapWindowPoints__IILorg_eclipse_swt_internal_win32_POINT_2I
-JNIEXPORT jint JNICALL OS_NATIVE(MapWindowPoints__IILorg_eclipse_swt_internal_win32_POINT_2I)
- (JNIEnv *env, jclass that, jint arg0, jint arg1, jobject arg2, jint arg3)
-{
- POINT _arg2, *lparg2=NULL;
- jint rc;
-
- DEBUG_CALL("MapWindowPoints__IILorg_eclipse_swt_internal_win32_POINT_2I\n")
-
- if (arg2) lparg2 = getPOINTFields(env, arg2, &_arg2);
- rc = (jint)MapWindowPoints((HWND)arg0, (HWND)arg1, (LPPOINT)lparg2, arg3);
- if (arg2) setPOINTFields(env, arg2, lparg2);
- return rc;
-}
-#endif /* NO_MapWindowPoints__IILorg_eclipse_swt_internal_win32_POINT_2I */
-
-#ifndef NO_MessageBeep
-JNIEXPORT jboolean JNICALL OS_NATIVE(MessageBeep)
- (JNIEnv *env, jclass that, jint arg0)
-{
- DEBUG_CALL("MessageBeep\n")
-
- return (jboolean)MessageBeep(arg0);
-}
-#endif /* NO_MessageBeep */
-
-#ifndef NO_MessageBoxA
-JNIEXPORT jint JNICALL OS_NATIVE(MessageBoxA)
- (JNIEnv *env, jclass that, jint arg0, jbyteArray arg1, jbyteArray arg2, jint arg3)
-{
- jbyte *lparg1=NULL;
- jbyte *lparg2=NULL;
- jint rc;
-
- DEBUG_CALL("MessageBoxA\n")
-
- if (arg1) lparg1 = (*env)->GetByteArrayElements(env, arg1, NULL);
- if (arg2) lparg2 = (*env)->GetByteArrayElements(env, arg2, NULL);
- rc = (jint)MessageBoxA((HWND)arg0, (LPSTR)lparg1, (LPSTR)lparg2, arg3);
- if (arg1) (*env)->ReleaseByteArrayElements(env, arg1, lparg1, 0);
- if (arg2) (*env)->ReleaseByteArrayElements(env, arg2, lparg2, 0);
- return rc;
-}
-#endif /* NO_MessageBoxA */
-
-#ifndef NO_MessageBoxW
-JNIEXPORT jint JNICALL OS_NATIVE(MessageBoxW)
- (JNIEnv *env, jclass that, jint arg0, jcharArray arg1, jcharArray arg2, jint arg3)
-{
- jchar *lparg1=NULL;
- jchar *lparg2=NULL;
- jint rc;
-
- DEBUG_CALL("MessageBoxW\n")
-
- if (arg1) lparg1 = (*env)->GetCharArrayElements(env, arg1, NULL);
- if (arg2) lparg2 = (*env)->GetCharArrayElements(env, arg2, NULL);
- rc = (jint)MessageBoxW((HWND)arg0, (LPWSTR)lparg1, (LPWSTR)lparg2, arg3);
- if (arg1) (*env)->ReleaseCharArrayElements(env, arg1, lparg1, 0);
- if (arg2) (*env)->ReleaseCharArrayElements(env, arg2, lparg2, 0);
- return rc;
-}
-#endif /* NO_MessageBoxW */
-
-#ifndef NO_MoveMemory__Lorg_eclipse_swt_internal_win32_NMTOOLBAR_2II
-JNIEXPORT void JNICALL OS_NATIVE(MoveMemory__Lorg_eclipse_swt_internal_win32_NMTOOLBAR_2II)
- (JNIEnv *env, jclass that, jobject arg0, jint arg1, jint arg2)
-{
- NMTOOLBAR _arg0, *lparg0=NULL;
-
- DEBUG_CALL("MoveMemory__Lorg_eclipse_swt_internal_win32_NMTOOLBAR_2II\n")
- DEBUG_CHECK_NULL(env, arg1)
-
- if (arg0) lparg0 = &_arg0;
- MoveMemory((PVOID)lparg0, (CONST VOID *)arg1, arg2);
- if (arg0) setNMTOOLBARFields(env, arg0, lparg0);
-}
-#endif /* NO_MoveMemory__Lorg_eclipse_swt_internal_win32_NMTOOLBAR_2II */
-
-#ifndef NO_MoveMemory__ILorg_eclipse_swt_internal_win32_DROPFILES_2I
-JNIEXPORT void JNICALL OS_NATIVE(MoveMemory__ILorg_eclipse_swt_internal_win32_DROPFILES_2I)
- (JNIEnv *env, jclass that, jint arg0, jobject arg1, jint arg2)
-{
- DROPFILES _arg1, *lparg1=NULL;
-
- DEBUG_CALL("MoveMemory__ILorg_eclipse_swt_internal_win32_DROPFILES_2I\n")
- DEBUG_CHECK_NULL(env, arg0)
-
- if (arg1) lparg1 = getDROPFILESFields(env, arg1, &_arg1);
- MoveMemory((PVOID)arg0, (CONST VOID *)lparg1, arg2);
- if (arg1) setDROPFILESFields(env, arg1, lparg1);
-}
-#endif /* NO_MoveMemory__ILorg_eclipse_swt_internal_win32_DROPFILES_2I */
-
-#ifndef NO_MoveMemory___3DII
-JNIEXPORT void JNICALL OS_NATIVE(MoveMemory___3DII)
- (JNIEnv *env, jclass that, jdoubleArray arg0, jint arg1, jint arg2)
-{
- jdouble *lparg0=NULL;
-
- DEBUG_CALL("MoveMemory___3DII\n")
- DEBUG_CHECK_NULL(env, arg1)
-
- if (arg0) lparg0 = (*env)->GetDoubleArrayElements(env, arg0, NULL);
- MoveMemory((PVOID)lparg0, (CONST VOID *)arg1, arg2);
- if (arg0) (*env)->ReleaseDoubleArrayElements(env, arg0, lparg0, 0);
-}
-#endif /* NO_MoveMemory___3DII */
-
-#ifndef NO_MoveMemory___3FII
-JNIEXPORT void JNICALL OS_NATIVE(MoveMemory___3FII)
- (JNIEnv *env, jclass that, jfloatArray arg0, jint arg1, jint arg2)
-{
- jfloat *lparg0=NULL;
-
- DEBUG_CALL("MoveMemory___3FII\n")
- DEBUG_CHECK_NULL(env, arg1)
-
- if (arg0) lparg0 = (*env)->GetFloatArrayElements(env, arg0, NULL);
- MoveMemory((PVOID)lparg0, (CONST VOID *)arg1, arg2);
- if (arg0) (*env)->ReleaseFloatArrayElements(env, arg0, lparg0, 0);
-}
-#endif /* NO_MoveMemory___3FII */
-
-#ifndef NO_MoveMemory___3SII
-JNIEXPORT void JNICALL OS_NATIVE(MoveMemory___3SII)
- (JNIEnv *env, jclass that, jshortArray arg0, jint arg1, jint arg2)
-{
- jshort *lparg0=NULL;
-
- DEBUG_CALL("MoveMemory___3SII\n")
- DEBUG_CHECK_NULL(env, arg1)
-
- if (arg0) lparg0 = (*env)->GetShortArrayElements(env, arg0, NULL);
- MoveMemory((PVOID)lparg0, (CONST VOID *)arg1, arg2);
- if (arg0) (*env)->ReleaseShortArrayElements(env, arg0, lparg0, 0);
-}
-#endif /* NO_MoveMemory___3SII */
-
-#ifndef NO_MoveMemory__I_3DI
-JNIEXPORT void JNICALL OS_NATIVE(MoveMemory__I_3DI)
- (JNIEnv *env, jclass that, jint arg0, jdoubleArray arg1, jint arg2)
-{
- jdouble *lparg1=NULL;
-
- DEBUG_CALL("MoveMemory__I_3DI\n")
- DEBUG_CHECK_NULL(env, arg0)
-
- if (arg1) lparg1 = (*env)->GetDoubleArrayElements(env, arg1, NULL);
- MoveMemory((PVOID)arg0, (CONST VOID *)lparg1, arg2);
- if (arg1) (*env)->ReleaseDoubleArrayElements(env, arg1, lparg1, 0);
-}
-#endif /* NO_MoveMemory__I_3DI */
-
-#ifndef NO_MoveMemory__I_3FI
-JNIEXPORT void JNICALL OS_NATIVE(MoveMemory__I_3FI)
- (JNIEnv *env, jclass that, jint arg0, jfloatArray arg1, jint arg2)
-{
- jfloat *lparg1=NULL;
-
- DEBUG_CALL("MoveMemory__I_3FI\n")
- DEBUG_CHECK_NULL(env, arg0)
-
- if (arg1) lparg1 = (*env)->GetFloatArrayElements(env, arg1, NULL);
- MoveMemory((PVOID)arg0, (CONST VOID *)lparg1, arg2);
- if (arg1) (*env)->ReleaseFloatArrayElements(env, arg1, lparg1, 0);
-}
-#endif /* NO_MoveMemory__I_3FI */
-
-#ifndef NO_MoveMemory__Lorg_eclipse_swt_internal_win32_NMREBARCHEVRON_2II
-JNIEXPORT void JNICALL OS_NATIVE(MoveMemory__Lorg_eclipse_swt_internal_win32_NMREBARCHEVRON_2II)
- (JNIEnv *env, jclass that, jobject arg0, jint arg1, jint arg2)
-{
- NMREBARCHEVRON _arg0, *lparg0=NULL;
-
- DEBUG_CALL("MoveMemory__Lorg_eclipse_swt_internal_win32_NMREBARCHEVRON_2II\n")
- DEBUG_CHECK_NULL(env, arg1)
-
- if (arg0) lparg0 = &_arg0;
- MoveMemory((PVOID)lparg0, (CONST VOID *)arg1, arg2);
- if (arg0) setNMREBARCHEVRONFields(env, arg0, lparg0);
-}
-#endif /* NO_MoveMemory__Lorg_eclipse_swt_internal_win32_NMREBARCHEVRON_2II */
-
-#ifndef NO_MoveMemory__Lorg_eclipse_swt_internal_win32_MSG_2II
-JNIEXPORT void JNICALL OS_NATIVE(MoveMemory__Lorg_eclipse_swt_internal_win32_MSG_2II)
- (JNIEnv *env, jclass that, jobject arg0, jint arg1, jint arg2)
-{
- MSG _arg0, *lparg0=NULL;
-
- DEBUG_CALL("MoveMemory__Lorg_eclipse_swt_internal_win32_MSG_2II\n")
- DEBUG_CHECK_NULL(env, arg1)
-
- if (arg0) lparg0 = &_arg0;
- MoveMemory((PVOID)lparg0, (CONST VOID *)arg1, arg2);
- if (arg0) setMSGFields(env, arg0, lparg0);
-}
-#endif /* NO_MoveMemory__Lorg_eclipse_swt_internal_win32_MSG_2II */
-
-#ifndef NO_MoveMemory__Lorg_eclipse_swt_internal_win32_NMHEADER_2II
-JNIEXPORT void JNICALL OS_NATIVE(MoveMemory__Lorg_eclipse_swt_internal_win32_NMHEADER_2II)
- (JNIEnv *env, jclass that, jobject arg0, jint arg1, jint arg2)
-{
- NMHEADER _arg0, *lparg0=NULL;
-
- DEBUG_CALL("MoveMemory__Lorg_eclipse_swt_internal_win32_NMHEADER_2II\n")
- DEBUG_CHECK_NULL(env, arg1)
-
- if (arg0) lparg0 = &_arg0;
- MoveMemory((PVOID)lparg0, (CONST VOID *)arg1, arg2);
- if (arg0) setNMHEADERFields(env, arg0, lparg0);
-}
-#endif /* NO_MoveMemory__Lorg_eclipse_swt_internal_win32_NMHEADER_2II */
-
-#ifndef NO_MoveMemory__ILorg_eclipse_swt_internal_win32_NMTVCUSTOMDRAW_2I
-JNIEXPORT void JNICALL OS_NATIVE(MoveMemory__ILorg_eclipse_swt_internal_win32_NMTVCUSTOMDRAW_2I)
- (JNIEnv *env, jclass that, jint arg0, jobject arg1, jint arg2)
-{
- NMTVCUSTOMDRAW _arg1, *lparg1=NULL;
-
- DEBUG_CALL("MoveMemory__ILorg_eclipse_swt_internal_win32_NMTVCUSTOMDRAW_2I\n")
- DEBUG_CHECK_NULL(env, arg0)
-
- if (arg1) lparg1 = getNMTVCUSTOMDRAWFields(env, arg1, &_arg1);
- MoveMemory((PVOID)arg0, (CONST VOID *)lparg1, arg2);
- if (arg1) setNMTVCUSTOMDRAWFields(env, arg1, lparg1);
-}
-#endif /* NO_MoveMemory__ILorg_eclipse_swt_internal_win32_NMTVCUSTOMDRAW_2I */
-
-#ifndef NO_MoveMemory__ILorg_eclipse_swt_internal_win32_NMLVCUSTOMDRAW_2I
-JNIEXPORT void JNICALL OS_NATIVE(MoveMemory__ILorg_eclipse_swt_internal_win32_NMLVCUSTOMDRAW_2I)
- (JNIEnv *env, jclass that, jint arg0, jobject arg1, jint arg2)
-{
- NMLVCUSTOMDRAW _arg1, *lparg1=NULL;
-
- DEBUG_CALL("MoveMemory__ILorg_eclipse_swt_internal_win32_NMLVCUSTOMDRAW_2I\n")
- DEBUG_CHECK_NULL(env, arg0)
-
- if (arg1) lparg1 = getNMLVCUSTOMDRAWFields(env, arg1, &_arg1);
- MoveMemory((PVOID)arg0, (CONST VOID *)lparg1, arg2);
- if (arg1) setNMLVCUSTOMDRAWFields(env, arg1, lparg1);
-}
-#endif /* NO_MoveMemory__ILorg_eclipse_swt_internal_win32_NMLVCUSTOMDRAW_2I */
-
-#ifndef NO_MoveMemory__Lorg_eclipse_swt_internal_win32_NMTVCUSTOMDRAW_2II
-JNIEXPORT void JNICALL OS_NATIVE(MoveMemory__Lorg_eclipse_swt_internal_win32_NMTVCUSTOMDRAW_2II)
- (JNIEnv *env, jclass that, jobject arg0, jint arg1, jint arg2)
-{
- NMTVCUSTOMDRAW _arg0, *lparg0=NULL;
-
- DEBUG_CALL("MoveMemory__Lorg_eclipse_swt_internal_win32_NMTVCUSTOMDRAW_2II\n")
- DEBUG_CHECK_NULL(env, arg1)
-
- if (arg0) lparg0 = getNMTVCUSTOMDRAWFields(env, arg0, &_arg0);
- MoveMemory((PVOID)lparg0, (CONST VOID *)arg1, arg2);
- if (arg0) setNMTVCUSTOMDRAWFields(env, arg0, lparg0);
-}
-#endif /* NO_MoveMemory__Lorg_eclipse_swt_internal_win32_NMTVCUSTOMDRAW_2II */
-
-#ifndef NO_MoveMemory__I_3SI
-JNIEXPORT void JNICALL OS_NATIVE(MoveMemory__I_3SI)
- (JNIEnv *env, jclass that, jint arg0, jshortArray arg1, jint arg2)
-{
- jshort *lparg1=NULL;
-
- DEBUG_CALL("MoveMemory__I_3SI\n")
- DEBUG_CHECK_NULL(env, arg0)
-
- if (arg1) lparg1 = (*env)->GetShortArrayElements(env, arg1, NULL);
- MoveMemory((PVOID)arg0, (CONST VOID *)lparg1, arg2);
- if (arg1) (*env)->ReleaseShortArrayElements(env, arg1, lparg1, 0);
-}
-#endif /* NO_MoveMemory__I_3SI */
-
-#ifndef NO_MoveMemory__Lorg_eclipse_swt_internal_win32_NMLVCUSTOMDRAW_2II
-JNIEXPORT void JNICALL OS_NATIVE(MoveMemory__Lorg_eclipse_swt_internal_win32_NMLVCUSTOMDRAW_2II)
- (JNIEnv *env, jclass that, jobject arg0, jint arg1, jint arg2)
-{
- NMLVCUSTOMDRAW _arg0, *lparg0=NULL;
-
- DEBUG_CALL("MoveMemory__Lorg_eclipse_swt_internal_win32_NMLVCUSTOMDRAW_2II\n")
- DEBUG_CHECK_NULL(env, arg1)
-
- if (arg0) lparg0 = &_arg0;
- MoveMemory((PVOID)lparg0, (CONST VOID *)arg1, arg2);
- if (arg0) setNMLVCUSTOMDRAWFields(env, arg0, lparg0);
-}
-#endif /* NO_MoveMemory__Lorg_eclipse_swt_internal_win32_NMLVCUSTOMDRAW_2II */
-
-#ifndef NO_MoveMemory__Lorg_eclipse_swt_internal_win32_NMHDR_2II
-JNIEXPORT void JNICALL OS_NATIVE(MoveMemory__Lorg_eclipse_swt_internal_win32_NMHDR_2II)
- (JNIEnv *env, jclass that, jobject arg0, jint arg1, jint arg2)
-{
- NMHDR _arg0, *lparg0=NULL;
-
- DEBUG_CALL("MoveMemory__Lorg_eclipse_swt_internal_win32_NMHDR_2II\n")
- DEBUG_CHECK_NULL(env, arg1)
-
- if (arg0) lparg0 = &_arg0;
- MoveMemory((PVOID)lparg0, (CONST VOID *)arg1, arg2);
- if (arg0) setNMHDRFields(env, arg0, lparg0);
-}
-#endif /* NO_MoveMemory__Lorg_eclipse_swt_internal_win32_NMHDR_2II */
-
-#ifndef NO_MoveMemory__Lorg_eclipse_swt_internal_win32_MEASUREITEMSTRUCT_2II
-JNIEXPORT void JNICALL OS_NATIVE(MoveMemory__Lorg_eclipse_swt_internal_win32_MEASUREITEMSTRUCT_2II)
- (JNIEnv *env, jclass that, jobject arg0, jint arg1, jint arg2)
-{
- MEASUREITEMSTRUCT _arg0, *lparg0=NULL;
-
- DEBUG_CALL("MoveMemory__Lorg_eclipse_swt_internal_win32_MEASUREITEMSTRUCT_2II\n")
- DEBUG_CHECK_NULL(env, arg1)
-
- if (arg0) lparg0 = &_arg0;
- MoveMemory((PVOID)lparg0, (CONST VOID *)arg1, arg2);
- if (arg0) setMEASUREITEMSTRUCTFields(env, arg0, lparg0);
-}
-#endif /* NO_MoveMemory__Lorg_eclipse_swt_internal_win32_MEASUREITEMSTRUCT_2II */
-
-#ifndef NO_MoveMemory___3CII
-JNIEXPORT void JNICALL OS_NATIVE(MoveMemory___3CII)
- (JNIEnv *env, jclass that, jcharArray arg0, jint arg1, jint arg2)
-{
- jchar *lparg0=NULL;
-
- DEBUG_CALL("MoveMemory___3CII\n")
- DEBUG_CHECK_NULL(env, arg1)
-
- if (arg0) lparg0 = (*env)->GetCharArrayElements(env, arg0, NULL);
- MoveMemory((PVOID)lparg0, (CONST VOID *)arg1, arg2);
- if (arg0) (*env)->ReleaseCharArrayElements(env, arg0, lparg0, 0);
-}
-#endif /* NO_MoveMemory___3CII */
-
-#ifndef NO_MoveMemory__Lorg_eclipse_swt_internal_win32_NMLISTVIEW_2II
-JNIEXPORT void JNICALL OS_NATIVE(MoveMemory__Lorg_eclipse_swt_internal_win32_NMLISTVIEW_2II)
- (JNIEnv *env, jclass that, jobject arg0, jint arg1, jint arg2)
-{
- NMLISTVIEW _arg0, *lparg0=NULL;
-
- DEBUG_CALL("MoveMemory__Lorg_eclipse_swt_internal_win32_NMLISTVIEW_2II\n")
- DEBUG_CHECK_NULL(env, arg1)
-
- if (arg0) lparg0 = &_arg0;
- MoveMemory((PVOID)lparg0, (CONST VOID *)arg1, arg2);
- if (arg0) setNMLISTVIEWFields(env, arg0, lparg0);
-}
-#endif /* NO_MoveMemory__Lorg_eclipse_swt_internal_win32_NMLISTVIEW_2II */
-
-#ifndef NO_MoveMemory__Lorg_eclipse_swt_internal_win32_HELPINFO_2II
-JNIEXPORT void JNICALL OS_NATIVE(MoveMemory__Lorg_eclipse_swt_internal_win32_HELPINFO_2II)
- (JNIEnv *env, jclass that, jobject arg0, jint arg1, jint arg2)
-{
- HELPINFO _arg0, *lparg0=NULL;
-
- DEBUG_CALL("MoveMemory__Lorg_eclipse_swt_internal_win32_HELPINFO_2II\n")
- DEBUG_CHECK_NULL(env, arg1)
-
- if (arg0) lparg0 = &_arg0;
- MoveMemory((PVOID)lparg0, (CONST VOID *)arg1, arg2);
- if (arg0) setHELPINFOFields(env, arg0, lparg0);
-}
-#endif /* NO_MoveMemory__Lorg_eclipse_swt_internal_win32_HELPINFO_2II */
-
-#ifndef NO_MoveMemory__Lorg_eclipse_swt_internal_win32_HDITEM_2II
-JNIEXPORT void JNICALL OS_NATIVE(MoveMemory__Lorg_eclipse_swt_internal_win32_HDITEM_2II)
- (JNIEnv *env, jclass that, jobject arg0, jint arg1, jint arg2)
-{
- HDITEM _arg0, *lparg0=NULL;
-
- DEBUG_CALL("MoveMemory__Lorg_eclipse_swt_internal_win32_HDITEM_2II\n")
- DEBUG_CHECK_NULL(env, arg1)
-
- if (arg0) lparg0 = &_arg0;
- MoveMemory((PVOID)lparg0, (CONST VOID *)arg1, arg2);
- if (arg0) setHDITEMFields(env, arg0, lparg0);
-}
-#endif /* NO_MoveMemory__Lorg_eclipse_swt_internal_win32_HDITEM_2II */
-
-#ifndef NO_MoveMemory__Lorg_eclipse_swt_internal_win32_DRAWITEMSTRUCT_2II
-JNIEXPORT void JNICALL OS_NATIVE(MoveMemory__Lorg_eclipse_swt_internal_win32_DRAWITEMSTRUCT_2II)
- (JNIEnv *env, jclass that, jobject arg0, jint arg1, jint arg2)
-{
- DRAWITEMSTRUCT _arg0, *lparg0=NULL;
-
- DEBUG_CALL("MoveMemory__Lorg_eclipse_swt_internal_win32_DRAWITEMSTRUCT_2II\n")
- DEBUG_CHECK_NULL(env, arg1)
-
- if (arg0) lparg0 = &_arg0;
- MoveMemory((PVOID)lparg0, (CONST VOID *)arg1, arg2);
- if (arg0) setDRAWITEMSTRUCTFields(env, arg0, lparg0);
-}
-#endif /* NO_MoveMemory__Lorg_eclipse_swt_internal_win32_DRAWITEMSTRUCT_2II */
-
-#ifndef NO_MoveMemory__ILorg_eclipse_swt_internal_win32_WINDOWPOS_2I
-JNIEXPORT void JNICALL OS_NATIVE(MoveMemory__ILorg_eclipse_swt_internal_win32_WINDOWPOS_2I)
- (JNIEnv *env, jclass that, jint arg0, jobject arg1, jint arg2)
-{
- WINDOWPOS _arg1, *lparg1=NULL;
-
- DEBUG_CALL("MoveMemory__ILorg_eclipse_swt_internal_win32_WINDOWPOS_2I\n")
- DEBUG_CHECK_NULL(env, arg0)
-
- if (arg1) lparg1 = getWINDOWPOSFields(env, arg1, &_arg1);
- MoveMemory((PVOID)arg0, (CONST VOID *)lparg1, arg2);
-}
-#endif /* NO_MoveMemory__ILorg_eclipse_swt_internal_win32_WINDOWPOS_2I */
-
-#ifndef NO_MoveMemory__ILorg_eclipse_swt_internal_win32_TRIVERTEX_2I
-JNIEXPORT void JNICALL OS_NATIVE(MoveMemory__ILorg_eclipse_swt_internal_win32_TRIVERTEX_2I)
- (JNIEnv *env, jclass that, jint arg0, jobject arg1, jint arg2)
-{
- TRIVERTEX _arg1, *lparg1=NULL;
-
- DEBUG_CALL("MoveMemory__ILorg_eclipse_swt_internal_win32_TRIVERTEX_2I\n")
- DEBUG_CHECK_NULL(env, arg0)
-
- if (arg1) lparg1 = getTRIVERTEXFields(env, arg1, &_arg1);
- MoveMemory((PVOID)arg0, (CONST VOID *)lparg1, arg2);
-}
-#endif /* NO_MoveMemory__ILorg_eclipse_swt_internal_win32_TRIVERTEX_2I */
-
-#ifndef NO_MoveMemory__ILorg_eclipse_swt_internal_win32_RECT_2I
-JNIEXPORT void JNICALL OS_NATIVE(MoveMemory__ILorg_eclipse_swt_internal_win32_RECT_2I)
- (JNIEnv *env, jclass that, jint arg0, jobject arg1, jint arg2)
-{
- RECT _arg1, *lparg1=NULL;
-
- DEBUG_CALL("MoveMemory__ILorg_eclipse_swt_internal_win32_RECT_2I\n")
- DEBUG_CHECK_NULL(env, arg0)
-
- if (arg1) lparg1 = getRECTFields(env, arg1, &_arg1);
- MoveMemory((PVOID)arg0, (CONST VOID *)lparg1, arg2);
-}
-#endif /* NO_MoveMemory__ILorg_eclipse_swt_internal_win32_RECT_2I */
-
-#ifndef NO_MoveMemory__Lorg_eclipse_swt_internal_win32_WINDOWPOS_2II
-JNIEXPORT void JNICALL OS_NATIVE(MoveMemory__Lorg_eclipse_swt_internal_win32_WINDOWPOS_2II)
- (JNIEnv *env, jclass that, jobject arg0, jint arg1, jint arg2)
-{
- WINDOWPOS _arg0, *lparg0=NULL;
-
- DEBUG_CALL("MoveMemory__Lorg_eclipse_swt_internal_win32_WINDOWPOS_2II\n")
- DEBUG_CHECK_NULL(env, arg1)
-
- if (arg0) lparg0 = &_arg0;
- MoveMemory((PVOID)lparg0, (CONST VOID *)arg1, arg2);
- if (arg0) setWINDOWPOSFields(env, arg0, lparg0);
-}
-#endif /* NO_MoveMemory__Lorg_eclipse_swt_internal_win32_WINDOWPOS_2II */
-
-#ifndef NO_MoveMemory__Lorg_eclipse_swt_internal_win32_TVITEM_2II
-JNIEXPORT void JNICALL OS_NATIVE(MoveMemory__Lorg_eclipse_swt_internal_win32_TVITEM_2II)
- (JNIEnv *env, jclass that, jobject arg0, jint arg1, jint arg2)
-{
- TVITEM _arg0, *lparg0=NULL;
-
- DEBUG_CALL("MoveMemory__Lorg_eclipse_swt_internal_win32_TVITEM_2II\n")
- DEBUG_CHECK_NULL(env, arg1)
-
- if (arg0) lparg0 = &_arg0;
- MoveMemory((PVOID)lparg0, (CONST VOID *)arg1, arg2);
- if (arg0) setTVITEMFields(env, arg0, lparg0);
-}
-#endif /* NO_MoveMemory__Lorg_eclipse_swt_internal_win32_TVITEM_2II */
-
-#ifndef NO_MoveMemory___3BII
-JNIEXPORT void JNICALL OS_NATIVE(MoveMemory___3BII)
- (JNIEnv *env, jclass that, jbyteArray arg0, jint arg1, jint arg2)
-{
- jbyte *lparg0=NULL;
-
- DEBUG_CALL("MoveMemory___3BII\n")
- DEBUG_CHECK_NULL(env, arg1)
-
- if (arg0) lparg0 = (*env)->GetByteArrayElements(env, arg0, NULL);
- MoveMemory((PVOID)lparg0, (CONST VOID *)arg1, arg2);
- if (arg0) (*env)->ReleaseByteArrayElements(env, arg0, lparg0, 0);
-}
-#endif /* NO_MoveMemory___3BII */
-
-#ifndef NO_MoveMemory__ILorg_eclipse_swt_internal_win32_MEASUREITEMSTRUCT_2I
-JNIEXPORT void JNICALL OS_NATIVE(MoveMemory__ILorg_eclipse_swt_internal_win32_MEASUREITEMSTRUCT_2I)
- (JNIEnv *env, jclass that, jint arg0, jobject arg1, jint arg2)
-{
- MEASUREITEMSTRUCT _arg1, *lparg1=NULL;
-
- DEBUG_CALL("MoveMemory__ILorg_eclipse_swt_internal_win32_MEASUREITEMSTRUCT_2I\n")
- DEBUG_CHECK_NULL(env, arg0)
-
- if (arg1) lparg1 = getMEASUREITEMSTRUCTFields(env, arg1, &_arg1);
- MoveMemory((PVOID)arg0, (CONST VOID *)lparg1, arg2);
-}
-#endif /* NO_MoveMemory__ILorg_eclipse_swt_internal_win32_MEASUREITEMSTRUCT_2I */
-
-#ifndef NO_MoveMemory___3BLorg_eclipse_swt_internal_win32_ACCEL_2I
-JNIEXPORT void JNICALL OS_NATIVE(MoveMemory___3BLorg_eclipse_swt_internal_win32_ACCEL_2I)
- (JNIEnv *env, jclass that, jbyteArray arg0, jobject arg1, jint arg2)
-{
- jbyte *lparg0=NULL;
- ACCEL _arg1, *lparg1=NULL;
-
- DEBUG_CALL("MoveMemory___3BLorg_eclipse_swt_internal_win32_ACCEL_2I\n")
-
- if (arg0) lparg0 = (*env)->GetByteArrayElements(env, arg0, NULL);
- if (arg1) lparg1 = getACCELFields(env, arg1, &_arg1);
- MoveMemory((PVOID)lparg0, (CONST VOID *)lparg1, arg2);
- if (arg0) (*env)->ReleaseByteArrayElements(env, arg0, lparg0, 0);
-}
-#endif /* NO_MoveMemory___3BLorg_eclipse_swt_internal_win32_ACCEL_2I */
-
-#ifndef NO_MoveMemory___3BLorg_eclipse_swt_internal_win32_BITMAPINFOHEADER_2I
-JNIEXPORT void JNICALL OS_NATIVE(MoveMemory___3BLorg_eclipse_swt_internal_win32_BITMAPINFOHEADER_2I)
- (JNIEnv *env, jclass that, jbyteArray arg0, jobject arg1, jint arg2)
-{
- jbyte *lparg0=NULL;
- BITMAPINFOHEADER _arg1, *lparg1=NULL;
-
- DEBUG_CALL("MoveMemory___3BLorg_eclipse_swt_internal_win32_BITMAPINFOHEADER_2I\n")
-
- if (arg0) lparg0 = (*env)->GetByteArrayElements(env, arg0, NULL);
- if (arg1) lparg1 = getBITMAPINFOHEADERFields(env, arg1, &_arg1);
- MoveMemory((PVOID)lparg0, (CONST VOID *)lparg1, arg2);
- if (arg0) (*env)->ReleaseByteArrayElements(env, arg0, lparg0, 0);
-}
-#endif /* NO_MoveMemory___3BLorg_eclipse_swt_internal_win32_BITMAPINFOHEADER_2I */
-
-#ifndef NO_MoveMemory__Lorg_eclipse_swt_internal_win32_BITMAPINFOHEADER_2_3BI
-JNIEXPORT void JNICALL OS_NATIVE(MoveMemory__Lorg_eclipse_swt_internal_win32_BITMAPINFOHEADER_2_3BI)
- (JNIEnv *env, jclass that, jobject arg0, jbyteArray arg1, jint arg2)
-{
- BITMAPINFOHEADER _arg0={0}, *lparg0=NULL; /* SPECIAL */
- jbyte *lparg1=NULL;
-
- DEBUG_CALL("MoveMemory__Lorg_eclipse_swt_internal_win32_BITMAPINFOHEADER_2_3BI\n")
-
- if (arg0) lparg0 = &_arg0;
- if (arg1) lparg1 = (*env)->GetByteArrayElements(env, arg1, NULL);
- MoveMemory((PVOID)lparg0, (CONST VOID *)lparg1, arg2);
- if (arg0) setBITMAPINFOHEADERFields(env, arg0, lparg0);
- if (arg1) (*env)->ReleaseByteArrayElements(env, arg1, lparg1, 0);
-}
-#endif /* NO_MoveMemory__Lorg_eclipse_swt_internal_win32_BITMAPINFOHEADER_2_3BI */
-
-#ifndef NO_MoveMemory___3III
-JNIEXPORT void JNICALL OS_NATIVE(MoveMemory___3III)
- (JNIEnv *env, jclass that, jintArray arg0, jint arg1, jint arg2)
-{
- jint *lparg0=NULL;
-
- DEBUG_CALL("MoveMemory___3III\n")
- DEBUG_CHECK_NULL(env, arg1)
-
- if (arg0) lparg0 = (*env)->GetIntArrayElements(env, arg0, NULL);
- MoveMemory((PVOID)lparg0, (CONST VOID *)arg1, arg2);
- if (arg0) (*env)->ReleaseIntArrayElements(env, arg0, lparg0, 0);
-}
-#endif /* NO_MoveMemory___3III */
-
-#ifndef NO_MoveMemory__ILorg_eclipse_swt_internal_win32_GRADIENT_1RECT_2I
-JNIEXPORT void JNICALL OS_NATIVE(MoveMemory__ILorg_eclipse_swt_internal_win32_GRADIENT_1RECT_2I)
- (JNIEnv *env, jclass that, jint arg0, jobject arg1, jint arg2)
-{
- GRADIENT_RECT _arg1, *lparg1=NULL;
-
- DEBUG_CALL("MoveMemory__ILorg_eclipse_swt_internal_win32_GRADIENT_1RECT_2I\n")
- DEBUG_CHECK_NULL(env, arg0)
-
- if (arg1) lparg1 = getGRADIENT_RECTFields(env, arg1, &_arg1);
- MoveMemory((PVOID)arg0, (CONST VOID *)lparg1, arg2);
-}
-#endif /* NO_MoveMemory__ILorg_eclipse_swt_internal_win32_GRADIENT_1RECT_2I */
-
-#ifndef NO_MoveMemory__I_3II
-JNIEXPORT void JNICALL OS_NATIVE(MoveMemory__I_3II)
- (JNIEnv *env, jclass that, jint arg0, jintArray arg1, jint arg2)
-{
- jint *lparg1=NULL;
-
- DEBUG_CALL("MoveMemory__I_3II\n")
- DEBUG_CHECK_NULL(env, arg0)
-
- if (arg1) lparg1 = (*env)->GetIntArrayElements(env, arg1, NULL);
- MoveMemory((PVOID)arg0, (CONST VOID *)lparg1, arg2);
- if (arg1) (*env)->ReleaseIntArrayElements(env, arg1, lparg1, 0);
-}
-#endif /* NO_MoveMemory__I_3II */
-
-#ifndef NO_MoveMemory__I_3CI
-JNIEXPORT void JNICALL OS_NATIVE(MoveMemory__I_3CI)
- (JNIEnv *env, jclass that, jint arg0, jcharArray arg1, jint arg2)
-{
- jchar *lparg1=NULL;
-
- DEBUG_CALL("MoveMemory__I_3CI\n")
- DEBUG_CHECK_NULL(env, arg0)
-
- if (arg1) lparg1 = (*env)->GetCharArrayElements(env, arg1, NULL);
- MoveMemory((PVOID)arg0, (CONST VOID *)lparg1, arg2);
- if (arg1) (*env)->ReleaseCharArrayElements(env, arg1, lparg1, 0);
-}
-#endif /* NO_MoveMemory__I_3CI */
-
-#ifndef NO_MoveMemory__I_3BI
-JNIEXPORT void JNICALL OS_NATIVE(MoveMemory__I_3BI)
- (JNIEnv *env, jclass that, jint arg0, jbyteArray arg1, jint arg2)
-{
- jbyte *lparg1=NULL;
-
- DEBUG_CALL("MoveMemory__I_3BI\n")
- DEBUG_CHECK_NULL(env, arg0)
-
- if (arg1) lparg1 = (*env)->GetByteArrayElements(env, arg1, NULL);
- MoveMemory((PVOID)arg0, (CONST VOID *)lparg1, arg2);
- if (arg1) (*env)->ReleaseByteArrayElements(env, arg1, lparg1, 0);
-}
-#endif /* NO_MoveMemory__I_3BI */
-
-#ifndef NO_MoveMemoryA__ILorg_eclipse_swt_internal_win32_LOGFONT_2I
-JNIEXPORT void JNICALL OS_NATIVE(MoveMemoryA__ILorg_eclipse_swt_internal_win32_LOGFONT_2I)
- (JNIEnv *env, jclass that, jint arg0, jobject arg1, jint arg2)
-{
- LOGFONT _arg1, *lparg1=NULL;
-
- DEBUG_CALL("MoveMemoryA__ILorg_eclipse_swt_internal_win32_LOGFONT_2I\n")
- DEBUG_CHECK_NULL(env, arg0)
-
- if (arg1) lparg1 = getLOGFONTAFields(env, arg1, &_arg1);
- MoveMemory((PVOID)arg0, (CONST VOID *)lparg1, arg2);
-}
-#endif /* NO_MoveMemoryA__ILorg_eclipse_swt_internal_win32_LOGFONT_2I */
-
-#ifndef NO_MoveMemoryA__Lorg_eclipse_swt_internal_win32_LOGFONT_2II
-JNIEXPORT void JNICALL OS_NATIVE(MoveMemoryA__Lorg_eclipse_swt_internal_win32_LOGFONT_2II)
- (JNIEnv *env, jclass that, jobject arg0, jint arg1, jint arg2)
-{
- LOGFONT _arg0, *lparg0=NULL;
-
- DEBUG_CALL("MoveMemoryA__Lorg_eclipse_swt_internal_win32_LOGFONT_2II\n")
- DEBUG_CHECK_NULL(env, arg1)
-
- if (arg0) lparg0 = &_arg0;
- MoveMemory((PVOID)lparg0, (CONST VOID *)arg1, arg2);
- if (arg0) setLOGFONTAFields(env, arg0, lparg0);
-}
-#endif /* NO_MoveMemoryA__Lorg_eclipse_swt_internal_win32_LOGFONT_2II */
-
-#ifndef NO_MoveMemoryA__ILorg_eclipse_swt_internal_win32_NMTTDISPINFO_2I
-JNIEXPORT void JNICALL OS_NATIVE(MoveMemoryA__ILorg_eclipse_swt_internal_win32_NMTTDISPINFO_2I)
- (JNIEnv *env, jclass that, jint arg0, jobject arg1, jint arg2)
-{
- NMTTDISPINFOA _arg1={0}, *lparg1=NULL; /* SPECIAL */
-
- DEBUG_CALL("MoveMemoryA__ILorg_eclipse_swt_internal_win32_NMTTDISPINFO_2I\n")
- DEBUG_CHECK_NULL(env, arg0)
-
- if (arg1) lparg1 = getNMTTDISPINFOAFields(env, arg1, &_arg1);
- MoveMemory((PVOID)arg0, (CONST VOID *)lparg1, arg2);
-}
-#endif /* NO_MoveMemoryA__ILorg_eclipse_swt_internal_win32_NMTTDISPINFO_2I */
-
-#ifndef NO_MoveMemoryA__Lorg_eclipse_swt_internal_win32_NMTTDISPINFO_2II
-JNIEXPORT void JNICALL OS_NATIVE(MoveMemoryA__Lorg_eclipse_swt_internal_win32_NMTTDISPINFO_2II)
- (JNIEnv *env, jclass that, jobject arg0, jint arg1, jint arg2)
-{
- NMTTDISPINFOA _arg0={0}, *lparg0=NULL; /* SPECIAL */
-
- DEBUG_CALL("MoveMemoryA__Lorg_eclipse_swt_internal_win32_NMTTDISPINFO_2II\n")
- DEBUG_CHECK_NULL(env, arg1)
-
- if (arg0) lparg0 = &_arg0;
- MoveMemory((PVOID)lparg0, (CONST VOID *)arg1, arg2);
- if (arg0) setNMTTDISPINFOAFields(env, arg0, lparg0);
-}
-#endif /* NO_MoveMemoryA__Lorg_eclipse_swt_internal_win32_NMTTDISPINFO_2II */
-
-#ifndef NO_MoveMemoryW__Lorg_eclipse_swt_internal_win32_LOGFONT_2II
-JNIEXPORT void JNICALL OS_NATIVE(MoveMemoryW__Lorg_eclipse_swt_internal_win32_LOGFONT_2II)
- (JNIEnv *env, jclass that, jobject arg0, jint arg1, jint arg2)
-{
- LOGFONTW _arg0, *lparg0=NULL;
-
- DEBUG_CALL("MoveMemoryW__Lorg_eclipse_swt_internal_win32_LOGFONT_2II\n")
- DEBUG_CHECK_NULL(env, arg1)
-
- if (arg0) lparg0 = &_arg0;
- MoveMemory((PVOID)lparg0, (CONST VOID *)arg1, arg2);
- if (arg0) setLOGFONTWFields(env, arg0, lparg0);
-}
-#endif /* NO_MoveMemoryW__Lorg_eclipse_swt_internal_win32_LOGFONT_2II */
-
-#ifndef NO_MoveMemoryW__ILorg_eclipse_swt_internal_win32_LOGFONT_2I
-JNIEXPORT void JNICALL OS_NATIVE(MoveMemoryW__ILorg_eclipse_swt_internal_win32_LOGFONT_2I)
- (JNIEnv *env, jclass that, jint arg0, jobject arg1, jint arg2)
-{
- LOGFONTW _arg1, *lparg1=NULL;
-
- DEBUG_CALL("MoveMemoryW__ILorg_eclipse_swt_internal_win32_LOGFONT_2I\n")
- DEBUG_CHECK_NULL(env, arg0)
-
- if (arg1) lparg1 = getLOGFONTWFields(env, arg1, &_arg1);
- MoveMemory((PVOID)arg0, (CONST VOID *)lparg1, arg2);
-}
-#endif /* NO_MoveMemoryW__ILorg_eclipse_swt_internal_win32_LOGFONT_2I */
-
-#ifndef NO_MoveMemoryW__ILorg_eclipse_swt_internal_win32_NMTTDISPINFO_2I
-JNIEXPORT void JNICALL OS_NATIVE(MoveMemoryW__ILorg_eclipse_swt_internal_win32_NMTTDISPINFO_2I)
- (JNIEnv *env, jclass that, jint arg0, jobject arg1, jint arg2)
-{
- NMTTDISPINFOW _arg1={0}, *lparg1=NULL; /* SPECIAL */
-
- DEBUG_CALL("MoveMemoryW__ILorg_eclipse_swt_internal_win32_NMTTDISPINFO_2I\n")
- DEBUG_CHECK_NULL(env, arg0)
-
- if (arg1) lparg1 = getNMTTDISPINFOWFields(env, arg1, &_arg1);
- MoveMemory((PVOID)arg0, (CONST VOID *)lparg1, arg2);
-}
-#endif /* NO_MoveMemoryW__ILorg_eclipse_swt_internal_win32_NMTTDISPINFO_2I */
-
-#ifndef NO_MoveMemoryW__Lorg_eclipse_swt_internal_win32_NMTTDISPINFO_2II
-JNIEXPORT void JNICALL OS_NATIVE(MoveMemoryW__Lorg_eclipse_swt_internal_win32_NMTTDISPINFO_2II)
- (JNIEnv *env, jclass that, jobject arg0, jint arg1, jint arg2)
-{
- NMTTDISPINFOW _arg0={0}, *lparg0=NULL; /* SPECIAL */
-
- DEBUG_CALL("MoveMemoryW__Lorg_eclipse_swt_internal_win32_NMTTDISPINFO_2II\n")
- DEBUG_CHECK_NULL(env, arg1)
-
- if (arg0) lparg0 = &_arg0;
- MoveMemory((PVOID)lparg0, (CONST VOID *)arg1, arg2);
- if (arg0) setNMTTDISPINFOWFields(env, arg0, lparg0);
-}
-#endif /* NO_MoveMemoryW__Lorg_eclipse_swt_internal_win32_NMTTDISPINFO_2II */
-
-#ifndef NO_MoveToEx
-JNIEXPORT jboolean JNICALL OS_NATIVE(MoveToEx)
- (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jint arg3)
-{
- DEBUG_CALL("MoveToEx\n")
-
- return (jboolean)MoveToEx((HDC)arg0, arg1, arg2, (LPPOINT)arg3);
-}
-#endif /* NO_MoveToEx */
-
-#ifndef NO_MsgWaitForMultipleObjectsEx
-JNIEXPORT jint JNICALL OS_NATIVE(MsgWaitForMultipleObjectsEx)
- (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jint arg3, jint arg4)
-{
- DEBUG_CALL("MsgWaitForMultipleObjectsEx\n")
-
- return (jint)MsgWaitForMultipleObjectsEx((DWORD)arg0, (LPHANDLE)arg1, (DWORD)arg2, (DWORD)arg3, (DWORD)arg4);
-}
-#endif /* NO_MsgWaitForMultipleObjectsEx */
-
-#ifndef NO_MultiByteToWideChar__IIII_3CI
-JNIEXPORT jint JNICALL OS_NATIVE(MultiByteToWideChar__IIII_3CI)
- (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jint arg3, jcharArray arg4, jint arg5)
-{
- jchar *lparg4=NULL;
- jint rc;
-
- DEBUG_CALL("MultiByteToWideChar__IIII_3CI\n")
-
- if (arg4) lparg4 = (*env)->GetCharArrayElements(env, arg4, NULL);
- rc = (jint)MultiByteToWideChar(arg0, arg1, (LPCSTR)arg2, arg3, (LPWSTR)lparg4, arg5);
- if (arg4) (*env)->ReleaseCharArrayElements(env, arg4, lparg4, 0);
- return rc;
-}
-#endif /* NO_MultiByteToWideChar__IIII_3CI */
-
-#ifndef NO_MultiByteToWideChar__II_3BI_3CI
-JNIEXPORT jint JNICALL OS_NATIVE(MultiByteToWideChar__II_3BI_3CI)
- (JNIEnv *env, jclass that, jint arg0, jint arg1, jbyteArray arg2, jint arg3, jcharArray arg4, jint arg5)
-{
- jbyte *lparg2=NULL;
- jchar *lparg4=NULL;
- jint rc;
-
- DEBUG_CALL("MultiByteToWideChar__II_3BI_3CI\n")
-
- if (arg2) lparg2 = (*env)->GetByteArrayElements(env, arg2, NULL);
- if (arg4) lparg4 = (*env)->GetCharArrayElements(env, arg4, NULL);
- rc = (jint)MultiByteToWideChar(arg0, arg1, (LPCSTR)lparg2, arg3, (LPWSTR)lparg4, arg5);
- if (arg2) (*env)->ReleaseByteArrayElements(env, arg2, lparg2, 0);
- if (arg4) (*env)->ReleaseCharArrayElements(env, arg4, lparg4, 0);
- return rc;
-}
-#endif /* NO_MultiByteToWideChar__II_3BI_3CI */
-
-#ifndef NO_OleInitialize
-JNIEXPORT jint JNICALL OS_NATIVE(OleInitialize)
- (JNIEnv *env, jclass that, jint arg0)
-{
- DEBUG_CALL("OleInitialize\n")
-
- return (jint)OleInitialize((LPVOID)arg0);
-}
-#endif /* NO_OleInitialize */
-
-#ifndef NO_OleUninitialize
-JNIEXPORT void JNICALL OS_NATIVE(OleUninitialize)
- (JNIEnv *env, jclass that)
-{
- DEBUG_CALL("OleUninitialize\n")
-
- OleUninitialize();
-}
-#endif /* NO_OleUninitialize */
-
-#ifndef NO_OpenClipboard
-JNIEXPORT jboolean JNICALL OS_NATIVE(OpenClipboard)
- (JNIEnv *env, jclass that, jint arg0)
-{
- DEBUG_CALL("OpenClipboard\n")
-
- return (jboolean)OpenClipboard((HWND)arg0);
-}
-#endif /* NO_OpenClipboard */
-
-#ifndef NO_PatBlt
-JNIEXPORT jboolean JNICALL OS_NATIVE(PatBlt)
- (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jint arg3, jint arg4, jint arg5)
-{
- DEBUG_CALL("PatBlt\n")
-
- return (jboolean)PatBlt((HDC)arg0, arg1, arg2, arg3, arg4, arg5);
-}
-#endif /* NO_PatBlt */
-
-#ifndef NO_PeekMessageA
-JNIEXPORT jboolean JNICALL OS_NATIVE(PeekMessageA)
- (JNIEnv *env, jclass that, jobject arg0, jint arg1, jint arg2, jint arg3, jint arg4)
-{
- MSG _arg0, *lparg0=NULL;
- jboolean rc;
-
- DEBUG_CALL("PeekMessageA\n")
-
- if (arg0) lparg0 = getMSGFields(env, arg0, &_arg0);
- rc = (jboolean)PeekMessageA(lparg0, (HWND)arg1, arg2, arg3, arg4);
- if (arg0) setMSGFields(env, arg0, lparg0);
- return rc;
-}
-#endif /* NO_PeekMessageA */
-
-#ifndef NO_PeekMessageW
-JNIEXPORT jboolean JNICALL OS_NATIVE(PeekMessageW)
- (JNIEnv *env, jclass that, jobject arg0, jint arg1, jint arg2, jint arg3, jint arg4)
-{
- MSG _arg0, *lparg0=NULL;
- jboolean rc;
-
- DEBUG_CALL("PeekMessageW\n")
-
- if (arg0) lparg0 = getMSGFields(env, arg0, &_arg0);
- rc = (jboolean)PeekMessageW(lparg0, (HWND)arg1, arg2, arg3, arg4);
- if (arg0) setMSGFields(env, arg0, lparg0);
- return rc;
-}
-#endif /* NO_PeekMessageW */
-
-#ifndef NO_Pie
-JNIEXPORT jboolean JNICALL OS_NATIVE(Pie)
- (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jint arg3, jint arg4, jint arg5, jint arg6, jint arg7, jint arg8)
-{
- DEBUG_CALL("Pie\n")
-
- return (jboolean)Pie((HDC)arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8);
-}
-#endif /* NO_Pie */
-
-#ifndef NO_Polygon
-JNIEXPORT jboolean JNICALL OS_NATIVE(Polygon)
- (JNIEnv *env, jclass that, jint arg0, jintArray arg1, jint arg2)
-{
- jint *lparg1=NULL;
- jboolean rc;
-
- DEBUG_CALL("Polygon\n")
-
- if (arg1) lparg1 = (*env)->GetIntArrayElements(env, arg1, NULL);
- rc = (jboolean)Polygon((HDC)arg0, (CONST POINT *)lparg1, arg2);
- if (arg1) (*env)->ReleaseIntArrayElements(env, arg1, lparg1, 0);
- return rc;
-}
-#endif /* NO_Polygon */
-
-#ifndef NO_Polyline
-JNIEXPORT jboolean JNICALL OS_NATIVE(Polyline)
- (JNIEnv *env, jclass that, jint arg0, jintArray arg1, jint arg2)
-{
- jint *lparg1=NULL;
- jboolean rc;
-
- DEBUG_CALL("Polyline\n")
-
- if (arg1) lparg1 = (*env)->GetIntArrayElements(env, arg1, NULL);
- rc = (jboolean)Polyline((HDC)arg0, (CONST POINT *)lparg1, arg2);
- if (arg1) (*env)->ReleaseIntArrayElements(env, arg1, lparg1, 0);
- return rc;
-}
-#endif /* NO_Polyline */
-
-#ifndef NO_PostMessageA
-JNIEXPORT jboolean JNICALL OS_NATIVE(PostMessageA)
- (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jint arg3)
-{
- DEBUG_CALL("PostMessageA\n")
-
- return (jboolean)PostMessageA((HWND)arg0, arg1, (WPARAM)arg2, (LPARAM)arg3);
-}
-#endif /* NO_PostMessageA */
-
-#ifndef NO_PostMessageW
-JNIEXPORT jboolean JNICALL OS_NATIVE(PostMessageW)
- (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jint arg3)
-{
- DEBUG_CALL("PostMessageW\n")
-
- return (jboolean)PostMessageW((HWND)arg0, arg1, (WPARAM)arg2, (LPARAM)arg3);
-}
-#endif /* NO_PostMessageW */
-
-#ifndef NO_PostThreadMessageA
-JNIEXPORT jboolean JNICALL OS_NATIVE(PostThreadMessageA)
- (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jint arg3)
-{
- DEBUG_CALL("PostThreadMessageA\n")
-
- return (jboolean)PostThreadMessageA(arg0, arg1, (WPARAM)arg2, (LPARAM)arg3);
-}
-#endif /* NO_PostThreadMessageA */
-
-#ifndef NO_PostThreadMessageW
-JNIEXPORT jboolean JNICALL OS_NATIVE(PostThreadMessageW)
- (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jint arg3)
-{
- DEBUG_CALL("PostThreadMessageW\n")
-
- return (jboolean)PostThreadMessageW(arg0, arg1, (WPARAM)arg2, (LPARAM)arg3);
-}
-#endif /* NO_PostThreadMessageW */
-
-#ifndef NO_PrintDlgA
-JNIEXPORT jboolean JNICALL OS_NATIVE(PrintDlgA)
- (JNIEnv *env, jclass that, jobject arg0)
-{
- PRINTDLG _arg0, *lparg0=NULL;
- jboolean rc;
-
- DEBUG_CALL("PrintDlgA\n")
-
- if (arg0) lparg0 = getPRINTDLGFields(env, arg0, &_arg0);
- rc = (jboolean)PrintDlgA(lparg0);
- if (arg0) setPRINTDLGFields(env, arg0, lparg0);
- return rc;
-}
-#endif /* NO_PrintDlgA */
-
-#ifndef NO_PrintDlgW
-JNIEXPORT jboolean JNICALL OS_NATIVE(PrintDlgW)
- (JNIEnv *env, jclass that, jobject arg0)
-{
- PRINTDLG _arg0, *lparg0=NULL;
- jboolean rc;
-
- DEBUG_CALL("PrintDlgW\n")
-
- if (arg0) lparg0 = getPRINTDLGFields(env, arg0, &_arg0);
- rc = (jboolean)PrintDlgW((LPPRINTDLGW)lparg0);
- if (arg0) setPRINTDLGFields(env, arg0, lparg0);
- return rc;
-}
-#endif /* NO_PrintDlgW */
-
-#ifndef NO_PtInRect
-JNIEXPORT jboolean JNICALL OS_NATIVE(PtInRect)
- (JNIEnv *env, jclass that, jobject arg0, jobject arg1)
-{
- RECT _arg0, *lparg0=NULL;
- POINT _arg1, *lparg1=NULL;
- jboolean rc;
-
- DEBUG_CALL("PtInRect\n")
-
- if (arg0) lparg0 = getRECTFields(env, arg0, &_arg0);
- if (arg1) lparg1 = getPOINTFields(env, arg1, &_arg1);
- rc = (jboolean)PtInRect(lparg0, *lparg1);
- if (arg0) setRECTFields(env, arg0, lparg0);
- if (arg1) setPOINTFields(env, arg1, lparg1);
- return rc;
-}
-#endif /* NO_PtInRect */
-
-#ifndef NO_PtInRegion
-JNIEXPORT jboolean JNICALL OS_NATIVE(PtInRegion)
- (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2)
-{
- DEBUG_CALL("PtInRegion\n")
-
- return (jboolean)PtInRegion((HRGN)arg0, arg1, arg2);
-}
-#endif /* NO_PtInRegion */
-
-#ifndef NO_RealizePalette
-JNIEXPORT jint JNICALL OS_NATIVE(RealizePalette)
- (JNIEnv *env, jclass that, jint arg0)
-{
- DEBUG_CALL("RealizePalette\n")
-
- return (jint)RealizePalette((HDC)arg0);
-}
-#endif /* NO_RealizePalette */
-
-#ifndef NO_RectInRegion
-JNIEXPORT jboolean JNICALL OS_NATIVE(RectInRegion)
- (JNIEnv *env, jclass that, jint arg0, jobject arg1)
-{
- RECT _arg1, *lparg1=NULL;
- jboolean rc;
-
- DEBUG_CALL("RectInRegion\n")
-
- if (arg1) lparg1 = getRECTFields(env, arg1, &_arg1);
- rc = (jboolean)RectInRegion((HRGN)arg0, lparg1);
- if (arg1) setRECTFields(env, arg1, lparg1);
- return rc;
-}
-#endif /* NO_RectInRegion */
-
-#ifndef NO_Rectangle
-JNIEXPORT jboolean JNICALL OS_NATIVE(Rectangle)
- (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jint arg3, jint arg4)
-{
- DEBUG_CALL("Rectangle\n")
-
- return (jboolean)Rectangle((HDC)arg0, arg1, arg2, arg3, arg4);
-}
-#endif /* NO_Rectangle */
-
-#ifndef NO_RedrawWindow
-JNIEXPORT jboolean JNICALL OS_NATIVE(RedrawWindow)
- (JNIEnv *env, jclass that, jint arg0, jobject arg1, jint arg2, jint arg3)
-{
- RECT _arg1, *lparg1=NULL;
- jboolean rc;
-
- DEBUG_CALL("RedrawWindow\n")
-
- if (arg1) lparg1 = getRECTFields(env, arg1, &_arg1);
- rc = (jboolean)RedrawWindow((HWND)arg0, lparg1, (HRGN)arg2, arg3);
- if (arg1) setRECTFields(env, arg1, lparg1);
- return rc;
-}
-#endif /* NO_RedrawWindow */
-
-#ifndef NO_RegCloseKey
-JNIEXPORT jint JNICALL OS_NATIVE(RegCloseKey)
- (JNIEnv *env, jclass that, jint arg0)
-{
- DEBUG_CALL("RegCloseKey\n")
-
- return (jint)RegCloseKey((HKEY)arg0);
-}
-#endif /* NO_RegCloseKey */
-
-#ifndef NO_RegEnumKeyExA
-JNIEXPORT jint JNICALL OS_NATIVE(RegEnumKeyExA)
- (JNIEnv *env, jclass that, jint arg0, jint arg1, jbyteArray arg2, jintArray arg3, jintArray arg4, jbyteArray arg5, jintArray arg6, jobject arg7)
-{
- jbyte *lparg2=NULL;
- jint *lparg3=NULL;
- jint *lparg4=NULL;
- jbyte *lparg5=NULL;
- jint *lparg6=NULL;
- FILETIME _arg7, *lparg7=NULL;
- jint rc;
-
- DEBUG_CALL("RegEnumKeyExA\n")
-
- if (arg2) lparg2 = (*env)->GetByteArrayElements(env, arg2, NULL);
- if (arg3) lparg3 = (*env)->GetIntArrayElements(env, arg3, NULL);
- if (arg4) lparg4 = (*env)->GetIntArrayElements(env, arg4, NULL);
- if (arg5) lparg5 = (*env)->GetByteArrayElements(env, arg5, NULL);
- if (arg6) lparg6 = (*env)->GetIntArrayElements(env, arg6, NULL);
- if (arg7) lparg7 = getFILETIMEFields(env, arg7, &_arg7);
- rc = (jint)RegEnumKeyExA((HKEY)arg0, arg1, (LPSTR)lparg2, lparg3, lparg4, (LPSTR)lparg5, lparg6, lparg7);
- if (arg2) (*env)->ReleaseByteArrayElements(env, arg2, lparg2, 0);
- if (arg3) (*env)->ReleaseIntArrayElements(env, arg3, lparg3, 0);
- if (arg4) (*env)->ReleaseIntArrayElements(env, arg4, lparg4, 0);
- if (arg5) (*env)->ReleaseByteArrayElements(env, arg5, lparg5, 0);
- if (arg6) (*env)->ReleaseIntArrayElements(env, arg6, lparg6, 0);
- if (arg7) setFILETIMEFields(env, arg7, lparg7);
- return rc;
-}
-#endif /* NO_RegEnumKeyExA */
-
-#ifndef NO_RegEnumKeyExW
-JNIEXPORT jint JNICALL OS_NATIVE(RegEnumKeyExW)
- (JNIEnv *env, jclass that, jint arg0, jint arg1, jcharArray arg2, jintArray arg3, jintArray arg4, jcharArray arg5, jintArray arg6, jobject arg7)
-{
- jchar *lparg2=NULL;
- jint *lparg3=NULL;
- jint *lparg4=NULL;
- jchar *lparg5=NULL;
- jint *lparg6=NULL;
- FILETIME _arg7, *lparg7=NULL;
- jint rc;
-
- DEBUG_CALL("RegEnumKeyExW\n")
-
- if (arg2) lparg2 = (*env)->GetCharArrayElements(env, arg2, NULL);
- if (arg3) lparg3 = (*env)->GetIntArrayElements(env, arg3, NULL);
- if (arg4) lparg4 = (*env)->GetIntArrayElements(env, arg4, NULL);
- if (arg5) lparg5 = (*env)->GetCharArrayElements(env, arg5, NULL);
- if (arg6) lparg6 = (*env)->GetIntArrayElements(env, arg6, NULL);
- if (arg7) lparg7 = getFILETIMEFields(env, arg7, &_arg7);
- rc = (jint)RegEnumKeyExW((HKEY)arg0, arg1, (LPWSTR)lparg2, lparg3, lparg4, (LPWSTR)lparg5, lparg6, lparg7);
- if (arg2) (*env)->ReleaseCharArrayElements(env, arg2, lparg2, 0);
- if (arg3) (*env)->ReleaseIntArrayElements(env, arg3, lparg3, 0);
- if (arg4) (*env)->ReleaseIntArrayElements(env, arg4, lparg4, 0);
- if (arg5) (*env)->ReleaseCharArrayElements(env, arg5, lparg5, 0);
- if (arg6) (*env)->ReleaseIntArrayElements(env, arg6, lparg6, 0);
- if (arg7) setFILETIMEFields(env, arg7, lparg7);
- return rc;
-}
-#endif /* NO_RegEnumKeyExW */
-
-#ifndef NO_RegOpenKeyExA
-JNIEXPORT jint JNICALL OS_NATIVE(RegOpenKeyExA)
- (JNIEnv *env, jclass that, jint arg0, jbyteArray arg1, jint arg2, jint arg3, jintArray arg4)
-{
- jbyte *lparg1=NULL;
- jint *lparg4=NULL;
- jint rc;
-
- DEBUG_CALL("RegOpenKeyExA\n")
-
- if (arg1) lparg1 = (*env)->GetByteArrayElements(env, arg1, NULL);
- if (arg4) lparg4 = (*env)->GetIntArrayElements(env, arg4, NULL);
- rc = (jint)RegOpenKeyExA((HKEY)arg0, (LPSTR)lparg1, arg2, arg3, (PHKEY)lparg4);
- if (arg1) (*env)->ReleaseByteArrayElements(env, arg1, lparg1, 0);
- if (arg4) (*env)->ReleaseIntArrayElements(env, arg4, lparg4, 0);
- return rc;
-}
-#endif /* NO_RegOpenKeyExA */
-
-#ifndef NO_RegOpenKeyExW
-JNIEXPORT jint JNICALL OS_NATIVE(RegOpenKeyExW)
- (JNIEnv *env, jclass that, jint arg0, jcharArray arg1, jint arg2, jint arg3, jintArray arg4)
-{
- jchar *lparg1=NULL;
- jint *lparg4=NULL;
- jint rc;
-
- DEBUG_CALL("RegOpenKeyExW\n")
-
- if (arg1) lparg1 = (*env)->GetCharArrayElements(env, arg1, NULL);
- if (arg4) lparg4 = (*env)->GetIntArrayElements(env, arg4, NULL);
- rc = (jint)RegOpenKeyExW((HKEY)arg0, (LPWSTR)lparg1, arg2, arg3, (PHKEY)lparg4);
- if (arg1) (*env)->ReleaseCharArrayElements(env, arg1, lparg1, 0);
- if (arg4) (*env)->ReleaseIntArrayElements(env, arg4, lparg4, 0);
- return rc;
-}
-#endif /* NO_RegOpenKeyExW */
-
-#ifndef NO_RegQueryInfoKeyA
-JNIEXPORT jint JNICALL OS_NATIVE(RegQueryInfoKeyA)
- (JNIEnv *env, jclass that, jint arg0, jint arg1, jintArray arg2, jint arg3, jintArray arg4, jintArray arg5, jintArray arg6, jintArray arg7, jintArray arg8, jintArray arg9, jintArray arg10, jint arg11)
-{
- jint *lparg2=NULL;
- jint *lparg4=NULL;
- jint *lparg5=NULL;
- jint *lparg6=NULL;
- jint *lparg7=NULL;
- jint *lparg8=NULL;
- jint *lparg9=NULL;
- jint *lparg10=NULL;
- jint rc;
-
- DEBUG_CALL("RegQueryInfoKeyA\n")
-
- if (arg2) lparg2 = (*env)->GetIntArrayElements(env, arg2, NULL);
- if (arg4) lparg4 = (*env)->GetIntArrayElements(env, arg4, NULL);
- if (arg5) lparg5 = (*env)->GetIntArrayElements(env, arg5, NULL);
- if (arg6) lparg6 = (*env)->GetIntArrayElements(env, arg6, NULL);
- if (arg7) lparg7 = (*env)->GetIntArrayElements(env, arg7, NULL);
- if (arg8) lparg8 = (*env)->GetIntArrayElements(env, arg8, NULL);
- if (arg9) lparg9 = (*env)->GetIntArrayElements(env, arg9, NULL);
- if (arg10) lparg10 = (*env)->GetIntArrayElements(env, arg10, NULL);
- rc = (jint)RegQueryInfoKeyA((HKEY)arg0, (LPSTR)arg1, lparg2, (LPDWORD)arg3, lparg4, lparg5, lparg6, lparg7, lparg8, lparg9, lparg10, (PFILETIME)arg11);
- if (arg2) (*env)->ReleaseIntArrayElements(env, arg2, lparg2, 0);
- if (arg4) (*env)->ReleaseIntArrayElements(env, arg4, lparg4, 0);
- if (arg5) (*env)->ReleaseIntArrayElements(env, arg5, lparg5, 0);
- if (arg6) (*env)->ReleaseIntArrayElements(env, arg6, lparg6, 0);
- if (arg7) (*env)->ReleaseIntArrayElements(env, arg7, lparg7, 0);
- if (arg8) (*env)->ReleaseIntArrayElements(env, arg8, lparg8, 0);
- if (arg9) (*env)->ReleaseIntArrayElements(env, arg9, lparg9, 0);
- if (arg10) (*env)->ReleaseIntArrayElements(env, arg10, lparg10, 0);
- return rc;
-}
-#endif /* NO_RegQueryInfoKeyA */
-
-#ifndef NO_RegQueryInfoKeyW
-JNIEXPORT jint JNICALL OS_NATIVE(RegQueryInfoKeyW)
- (JNIEnv *env, jclass that, jint arg0, jint arg1, jintArray arg2, jint arg3, jintArray arg4, jintArray arg5, jintArray arg6, jintArray arg7, jintArray arg8, jintArray arg9, jintArray arg10, jint arg11)
-{
- jint *lparg2=NULL;
- jint *lparg4=NULL;
- jint *lparg5=NULL;
- jint *lparg6=NULL;
- jint *lparg7=NULL;
- jint *lparg8=NULL;
- jint *lparg9=NULL;
- jint *lparg10=NULL;
- jint rc;
-
- DEBUG_CALL("RegQueryInfoKeyW\n")
-
- if (arg2) lparg2 = (*env)->GetIntArrayElements(env, arg2, NULL);
- if (arg4) lparg4 = (*env)->GetIntArrayElements(env, arg4, NULL);
- if (arg5) lparg5 = (*env)->GetIntArrayElements(env, arg5, NULL);
- if (arg6) lparg6 = (*env)->GetIntArrayElements(env, arg6, NULL);
- if (arg7) lparg7 = (*env)->GetIntArrayElements(env, arg7, NULL);
- if (arg8) lparg8 = (*env)->GetIntArrayElements(env, arg8, NULL);
- if (arg9) lparg9 = (*env)->GetIntArrayElements(env, arg9, NULL);
- if (arg10) lparg10 = (*env)->GetIntArrayElements(env, arg10, NULL);
- rc = (jint)RegQueryInfoKeyW((HKEY)arg0, (LPWSTR)arg1, lparg2, (LPDWORD)arg3, lparg4, lparg5, lparg6, lparg7, lparg8, lparg9, lparg10, (PFILETIME)arg11);
- if (arg2) (*env)->ReleaseIntArrayElements(env, arg2, lparg2, 0);
- if (arg4) (*env)->ReleaseIntArrayElements(env, arg4, lparg4, 0);
- if (arg5) (*env)->ReleaseIntArrayElements(env, arg5, lparg5, 0);
- if (arg6) (*env)->ReleaseIntArrayElements(env, arg6, lparg6, 0);
- if (arg7) (*env)->ReleaseIntArrayElements(env, arg7, lparg7, 0);
- if (arg8) (*env)->ReleaseIntArrayElements(env, arg8, lparg8, 0);
- if (arg9) (*env)->ReleaseIntArrayElements(env, arg9, lparg9, 0);
- if (arg10) (*env)->ReleaseIntArrayElements(env, arg10, lparg10, 0);
- return rc;
-}
-#endif /* NO_RegQueryInfoKeyW */
-
-#ifndef NO_RegQueryValueExA
-JNIEXPORT jint JNICALL OS_NATIVE(RegQueryValueExA)
- (JNIEnv *env, jclass that, jint arg0, jbyteArray arg1, jint arg2, jintArray arg3, jbyteArray arg4, jintArray arg5)
-{
- jbyte *lparg1=NULL;
- jint *lparg3=NULL;
- jbyte *lparg4=NULL;
- jint *lparg5=NULL;
- jint rc;
-
- DEBUG_CALL("RegQueryValueExA\n")
-
- if (arg1) lparg1 = (*env)->GetByteArrayElements(env, arg1, NULL);
- if (arg3) lparg3 = (*env)->GetIntArrayElements(env, arg3, NULL);
- if (arg4) lparg4 = (*env)->GetByteArrayElements(env, arg4, NULL);
- if (arg5) lparg5 = (*env)->GetIntArrayElements(env, arg5, NULL);
- rc = (jint)RegQueryValueExA((HKEY)arg0, (LPSTR)lparg1, (LPDWORD)arg2, lparg3, (LPBYTE)lparg4, lparg5);
- if (arg1) (*env)->ReleaseByteArrayElements(env, arg1, lparg1, 0);
- if (arg3) (*env)->ReleaseIntArrayElements(env, arg3, lparg3, 0);
- if (arg4) (*env)->ReleaseByteArrayElements(env, arg4, lparg4, 0);
- if (arg5) (*env)->ReleaseIntArrayElements(env, arg5, lparg5, 0);
- return rc;
-}
-#endif /* NO_RegQueryValueExA */
-
-#ifndef NO_RegQueryValueExW
-JNIEXPORT jint JNICALL OS_NATIVE(RegQueryValueExW)
- (JNIEnv *env, jclass that, jint arg0, jcharArray arg1, jint arg2, jintArray arg3, jcharArray arg4, jintArray arg5)
-{
- jchar *lparg1=NULL;
- jint *lparg3=NULL;
- jchar *lparg4=NULL;
- jint *lparg5=NULL;
- jint rc;
-
- DEBUG_CALL("RegQueryValueExW\n")
-
- if (arg1) lparg1 = (*env)->GetCharArrayElements(env, arg1, NULL);
- if (arg3) lparg3 = (*env)->GetIntArrayElements(env, arg3, NULL);
- if (arg4) lparg4 = (*env)->GetCharArrayElements(env, arg4, NULL);
- if (arg5) lparg5 = (*env)->GetIntArrayElements(env, arg5, NULL);
- rc = (jint)RegQueryValueExW((HKEY)arg0, (LPWSTR)lparg1, (LPDWORD)arg2, lparg3, (LPBYTE)lparg4, lparg5);
- if (arg1) (*env)->ReleaseCharArrayElements(env, arg1, lparg1, 0);
- if (arg3) (*env)->ReleaseIntArrayElements(env, arg3, lparg3, 0);
- if (arg4) (*env)->ReleaseCharArrayElements(env, arg4, lparg4, 0);
- if (arg5) (*env)->ReleaseIntArrayElements(env, arg5, lparg5, 0);
- return rc;
-}
-#endif /* NO_RegQueryValueExW */
-
-#ifndef NO_RegisterClassA
-JNIEXPORT jint JNICALL OS_NATIVE(RegisterClassA)
- (JNIEnv *env, jclass that, jobject arg0)
-{
- WNDCLASS _arg0, *lparg0=NULL;
- jint rc;
-
- DEBUG_CALL("RegisterClassA\n")
-
- if (arg0) lparg0 = getWNDCLASSFields(env, arg0, &_arg0);
- rc = (jint)RegisterClassA(lparg0);
- if (arg0) setWNDCLASSFields(env, arg0, lparg0);
- return rc;
-}
-#endif /* NO_RegisterClassA */
-
-#ifndef NO_RegisterClassW
-JNIEXPORT jint JNICALL OS_NATIVE(RegisterClassW)
- (JNIEnv *env, jclass that, jobject arg0)
-{
- WNDCLASS _arg0, *lparg0=NULL;
- jint rc;
-
- DEBUG_CALL("RegisterClassW\n")
-
- if (arg0) lparg0 = getWNDCLASSFields(env, arg0, &_arg0);
- rc = (jint)RegisterClassW((LPWNDCLASSW)lparg0);
- if (arg0) setWNDCLASSFields(env, arg0, lparg0);
- return rc;
-}
-#endif /* NO_RegisterClassW */
-
-#ifndef NO_RegisterClipboardFormatA
-JNIEXPORT jint JNICALL OS_NATIVE(RegisterClipboardFormatA)
- (JNIEnv *env, jclass that, jbyteArray arg0)
-{
- jbyte *lparg0=NULL;
- jint rc;
-
- DEBUG_CALL("RegisterClipboardFormatA\n")
-
- if (arg0) lparg0 = (*env)->GetByteArrayElements(env, arg0, NULL);
- rc = (jint)RegisterClipboardFormatA((LPTSTR)lparg0);
- if (arg0) (*env)->ReleaseByteArrayElements(env, arg0, lparg0, 0);
- return rc;
-}
-#endif /* NO_RegisterClipboardFormatA */
-
-#ifndef NO_RegisterClipboardFormatW
-JNIEXPORT jint JNICALL OS_NATIVE(RegisterClipboardFormatW)
- (JNIEnv *env, jclass that, jcharArray arg0)
-{
- jchar *lparg0=NULL;
- jint rc;
-
- DEBUG_CALL("RegisterClipboardFormatW\n")
-
- if (arg0) lparg0 = (*env)->GetCharArrayElements(env, arg0, NULL);
- rc = (jint)RegisterClipboardFormatW((LPWSTR)lparg0);
- if (arg0) (*env)->ReleaseCharArrayElements(env, arg0, lparg0, 0);
- return rc;
-}
-#endif /* NO_RegisterClipboardFormatW */
-
-#ifndef NO_ReleaseCapture
-JNIEXPORT jboolean JNICALL OS_NATIVE(ReleaseCapture)
- (JNIEnv *env, jclass that)
-{
- DEBUG_CALL("ReleaseCapture\n")
-
- return (jboolean)ReleaseCapture();
-}
-#endif /* NO_ReleaseCapture */
-
-#ifndef NO_ReleaseDC
-JNIEXPORT jint JNICALL OS_NATIVE(ReleaseDC)
- (JNIEnv *env, jclass that, jint arg0, jint arg1)
-{
- DEBUG_CALL("ReleaseDC\n")
-
- return (jint)ReleaseDC((HWND)arg0, (HDC)arg1);
-}
-#endif /* NO_ReleaseDC */
-
-#ifndef NO_RemoveMenu
-JNIEXPORT jboolean JNICALL OS_NATIVE(RemoveMenu)
- (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2)
-{
- DEBUG_CALL("RemoveMenu\n")
-
- return (jboolean)RemoveMenu((HMENU)arg0, arg1, arg2);
-}
-#endif /* NO_RemoveMenu */
-
-#ifndef NO_RoundRect
-JNIEXPORT jboolean JNICALL OS_NATIVE(RoundRect)
- (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jint arg3, jint arg4, jint arg5, jint arg6)
-{
- DEBUG_CALL("RoundRect\n")
-
- return (jboolean)RoundRect((HDC)arg0, arg1, arg2, arg3, arg4, arg5, arg6);
-}
-#endif /* NO_RoundRect */
-
-#ifndef NO_SHBrowseForFolderA
-JNIEXPORT jint JNICALL OS_NATIVE(SHBrowseForFolderA)
- (JNIEnv *env, jclass that, jobject arg0)
-{
- BROWSEINFO _arg0, *lparg0=NULL;
- jint rc;
-
- DEBUG_CALL("SHBrowseForFolderA\n")
-
- if (arg0) lparg0 = getBROWSEINFOFields(env, arg0, &_arg0);
- rc = (jint)SHBrowseForFolderA(lparg0);
- if (arg0) setBROWSEINFOFields(env, arg0, lparg0);
- return rc;
-}
-#endif /* NO_SHBrowseForFolderA */
-
-#ifndef NO_SHBrowseForFolderW
-JNIEXPORT jint JNICALL OS_NATIVE(SHBrowseForFolderW)
- (JNIEnv *env, jclass that, jobject arg0)
-{
- BROWSEINFO _arg0, *lparg0=NULL;
- jint rc;
-
- DEBUG_CALL("SHBrowseForFolderW\n")
-
- if (arg0) lparg0 = getBROWSEINFOFields(env, arg0, &_arg0);
- rc = (jint)SHBrowseForFolderW((LPBROWSEINFOW)lparg0);
- if (arg0) setBROWSEINFOFields(env, arg0, lparg0);
- return rc;
-}
-#endif /* NO_SHBrowseForFolderW */
-
-#ifndef NO_SHCreateMenuBar
-JNIEXPORT jboolean JNICALL OS_NATIVE(SHCreateMenuBar)
- (JNIEnv *env, jclass that, jobject arg0)
-{
- SHMENUBARINFO _arg0, *lparg0=NULL;
- jboolean rc;
-
- DEBUG_CALL("SHCreateMenuBar\n")
-
- if (arg0) lparg0 = getSHMENUBARINFOFields(env, arg0, &_arg0);
- rc = (jboolean)SHCreateMenuBar((PSHMENUBARINFO)lparg0);
- if (arg0) setSHMENUBARINFOFields(env, arg0, lparg0);
- return rc;
-}
-#endif /* NO_SHCreateMenuBar */
-
-#ifndef NO_SHGetMalloc
-JNIEXPORT jint JNICALL OS_NATIVE(SHGetMalloc)
- (JNIEnv *env, jclass that, jintArray arg0)
-{
- jint *lparg0=NULL;
- jint rc;
-
- DEBUG_CALL("SHGetMalloc\n")
-
- if (arg0) lparg0 = (*env)->GetIntArrayElements(env, arg0, NULL);
- rc = (jint)SHGetMalloc((LPMALLOC *)lparg0);
- if (arg0) (*env)->ReleaseIntArrayElements(env, arg0, lparg0, 0);
- return rc;
-}
-#endif /* NO_SHGetMalloc */
-
-#ifndef NO_SHGetPathFromIDListA
-JNIEXPORT jboolean JNICALL OS_NATIVE(SHGetPathFromIDListA)
- (JNIEnv *env, jclass that, jint arg0, jbyteArray arg1)
-{
- jbyte *lparg1=NULL;
- jboolean rc;
-
- DEBUG_CALL("SHGetPathFromIDListA\n")
-
- if (arg1) lparg1 = (*env)->GetByteArrayElements(env, arg1, NULL);
- rc = (jboolean)SHGetPathFromIDListA((LPCITEMIDLIST)arg0, (LPSTR)lparg1);
- if (arg1) (*env)->ReleaseByteArrayElements(env, arg1, lparg1, 0);
- return rc;
-}
-#endif /* NO_SHGetPathFromIDListA */
-
-#ifndef NO_SHGetPathFromIDListW
-JNIEXPORT jboolean JNICALL OS_NATIVE(SHGetPathFromIDListW)
- (JNIEnv *env, jclass that, jint arg0, jcharArray arg1)
-{
- jchar *lparg1=NULL;
- jboolean rc;
-
- DEBUG_CALL("SHGetPathFromIDListW\n")
-
- if (arg1) lparg1 = (*env)->GetCharArrayElements(env, arg1, NULL);
- rc = (jboolean)SHGetPathFromIDListW((LPCITEMIDLIST)arg0, (LPWSTR)lparg1);
- if (arg1) (*env)->ReleaseCharArrayElements(env, arg1, lparg1, 0);
- return rc;
-}
-#endif /* NO_SHGetPathFromIDListW */
-
-#ifndef NO_SHHandleWMSettingChange
-JNIEXPORT jboolean JNICALL OS_NATIVE(SHHandleWMSettingChange)
- (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jobject arg3)
-{
- SHACTIVATEINFO _arg3, *lparg3=NULL;
- jboolean rc;
-
- DEBUG_CALL("SHHandleWMSettingChange\n")
-
- if (arg3) lparg3 = getSHACTIVATEINFOFields(env, arg3, &_arg3);
- rc = (jboolean)SHHandleWMSettingChange((HWND)arg0, arg1, arg2, lparg3);
- if (arg3) setSHACTIVATEINFOFields(env, arg3, lparg3);
- return rc;
-}
-#endif /* NO_SHHandleWMSettingChange */
-
-#ifndef NO_SHRecognizeGesture
-JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_win32_OS_SHRecognizeGesture
- (JNIEnv *env, jclass that, jobject arg0)
-{
- SHRGINFO _arg0, *lparg0=NULL;
- jint rc;
-
- DEBUG_CALL("SHRecognizeGesture\n")
-
- if (arg0) lparg0 = getSHRGINFOFields(env, arg0, &_arg0);
- rc = (jint)SHRecognizeGesture(lparg0);
- if (arg0) setSHRGINFOFields(env, arg0, lparg0);
- return rc;
-}
-#endif
-
-#ifndef NO_SHSendBackToFocusWindow
-JNIEXPORT void JNICALL OS_NATIVE(SHSendBackToFocusWindow)
- (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2)
-{
- DEBUG_CALL("SHSendBackToFocusWindow\n")
-
- SHSendBackToFocusWindow(arg0, arg1, arg2);
-}
-#endif /* NO_SHSendBackToFocusWindow */
-
-#ifndef NO_SHSetAppKeyWndAssoc
-JNIEXPORT jboolean JNICALL OS_NATIVE(SHSetAppKeyWndAssoc)
- (JNIEnv *env, jclass that, jbyte arg0, jint arg1)
-{
- DEBUG_CALL("SHSetAppKeyWndAssoc\n")
-
- return (jboolean)SHSetAppKeyWndAssoc((BYTE)arg0, (HWND)arg1);
-}
-#endif /* NO_SHSetAppKeyWndAssoc */
-
-#ifndef NO_SHSipPreference
-JNIEXPORT jboolean JNICALL OS_NATIVE(SHSipPreference)
- (JNIEnv *env, jclass that, jint arg0, jint arg1)
-{
- DEBUG_CALL("SHSipPreference\n")
-
- return (jboolean)SHSipPreference((HWND)arg0, arg1);
-}
-#endif /* NO_SHSipPreference */
-
-#ifndef NO_ScreenToClient
-JNIEXPORT jboolean JNICALL OS_NATIVE(ScreenToClient)
- (JNIEnv *env, jclass that, jint arg0, jobject arg1)
-{
- POINT _arg1, *lparg1=NULL;
- jboolean rc;
-
- DEBUG_CALL("ScreenToClient\n")
-
- if (arg1) lparg1 = getPOINTFields(env, arg1, &_arg1);
- rc = (jboolean)ScreenToClient((HWND)arg0, lparg1);
- if (arg1) setPOINTFields(env, arg1, lparg1);
- return rc;
-}
-#endif /* NO_ScreenToClient */
-
-#ifndef NO_ScrollWindowEx
-JNIEXPORT jint JNICALL OS_NATIVE(ScrollWindowEx)
- (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jobject arg3, jobject arg4, jint arg5, jobject arg6, jint arg7)
-{
- RECT _arg3, *lparg3=NULL;
- RECT _arg4, *lparg4=NULL;
- RECT _arg6, *lparg6=NULL;
- jint rc;
-
- DEBUG_CALL("ScrollWindowEx\n")
-
- if (arg3) lparg3 = getRECTFields(env, arg3, &_arg3);
- if (arg4) lparg4 = getRECTFields(env, arg4, &_arg4);
- if (arg6) lparg6 = getRECTFields(env, arg6, &_arg6);
- rc = (jint)ScrollWindowEx((HWND)arg0, arg1, arg2, lparg3, lparg4, (HRGN)arg5, lparg6, arg7);
- if (arg3) setRECTFields(env, arg3, lparg3);
- if (arg4) setRECTFields(env, arg4, lparg4);
- if (arg6) setRECTFields(env, arg6, lparg6);
- return rc;
-}
-#endif /* NO_ScrollWindowEx */
-
-#ifndef NO_SelectClipRgn
-JNIEXPORT jint JNICALL OS_NATIVE(SelectClipRgn)
- (JNIEnv *env, jclass that, jint arg0, jint arg1)
-{
- DEBUG_CALL("SelectClipRgn\n")
-
- return (jint)SelectClipRgn((HDC)arg0, (HRGN)arg1);
-}
-#endif /* NO_SelectClipRgn */
-
-#ifndef NO_SelectObject
-JNIEXPORT jint JNICALL OS_NATIVE(SelectObject)
- (JNIEnv *env, jclass that, jint arg0, jint arg1)
-{
- DEBUG_CALL("SelectObject\n")
-
- return (jint)SelectObject((HDC)arg0, (HGDIOBJ)arg1);
-}
-#endif /* NO_SelectObject */
-
-#ifndef NO_SelectPalette
-JNIEXPORT jint JNICALL OS_NATIVE(SelectPalette)
- (JNIEnv *env, jclass that, jint arg0, jint arg1, jboolean arg2)
-{
- DEBUG_CALL("SelectPalette\n")
-
- return (jint)SelectPalette((HDC)arg0, (HPALETTE)arg1, arg2);
-}
-#endif /* NO_SelectPalette */
-
-#ifndef NO_SendMessageA__III_3I
-JNIEXPORT jint JNICALL OS_NATIVE(SendMessageA__III_3I)
- (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jintArray arg3)
-{
- jint *lparg3=NULL;
- jint rc;
-
- DEBUG_CALL("SendMessageA__III_3I\n")
-
- if (arg3) lparg3 = (*env)->GetIntArrayElements(env, arg3, NULL);
- rc = (jint)SendMessageA((HWND)arg0, arg1, arg2, (LPARAM)lparg3);
- if (arg3) (*env)->ReleaseIntArrayElements(env, arg3, lparg3, 0);
- return rc;
-}
-#endif /* NO_SendMessageA__III_3I */
-
-#ifndef NO_SendMessageA__III_3B
-JNIEXPORT jint JNICALL OS_NATIVE(SendMessageA__III_3B)
- (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jbyteArray arg3)
-{
- jbyte *lparg3=NULL;
- jint rc;
-
- DEBUG_CALL("SendMessageA__III_3B\n")
-
- if (arg3) lparg3 = (*env)->GetByteArrayElements(env, arg3, NULL);
- rc = (jint)SendMessageA((HWND)arg0, arg1, arg2, (LPARAM)lparg3);
- if (arg3) (*env)->ReleaseByteArrayElements(env, arg3, lparg3, 0);
- return rc;
-}
-#endif /* NO_SendMessageA__III_3B */
-
-#ifndef NO_SendMessageA__II_3II
-JNIEXPORT jint JNICALL OS_NATIVE(SendMessageA__II_3II)
- (JNIEnv *env, jclass that, jint arg0, jint arg1, jintArray arg2, jint arg3)
-{
- jint *lparg2=NULL;
- jint rc;
-
- DEBUG_CALL("SendMessageA__II_3II\n")
-
- if (arg2) lparg2 = (*env)->GetIntArrayElements(env, arg2, NULL);
- rc = (jint)SendMessageA((HWND)arg0, arg1, (WPARAM)lparg2, (LPARAM)arg3);
- if (arg2) (*env)->ReleaseIntArrayElements(env, arg2, lparg2, 0);
- return rc;
-}
-#endif /* NO_SendMessageA__II_3II */
-
-#ifndef NO_SendMessageA__II_3I_3I
-JNIEXPORT jint JNICALL OS_NATIVE(SendMessageA__II_3I_3I)
- (JNIEnv *env, jclass that, jint arg0, jint arg1, jintArray arg2, jintArray arg3)
-{
- jint *lparg2=NULL;
- jint *lparg3=NULL;
- jint rc;
-
- DEBUG_CALL("SendMessageA__II_3I_3I\n")
-
- if (arg2) lparg2 = (*env)->GetIntArrayElements(env, arg2, NULL);
- if (arg3) lparg3 = (*env)->GetIntArrayElements(env, arg3, NULL);
- rc = (jint)SendMessageA((HWND)arg0, arg1, (WPARAM)lparg2, (LPARAM)lparg3);
- if (arg2) (*env)->ReleaseIntArrayElements(env, arg2, lparg2, 0);
- if (arg3) (*env)->ReleaseIntArrayElements(env, arg3, lparg3, 0);
- return rc;
-}
-#endif /* NO_SendMessageA__II_3I_3I */
-
-#ifndef NO_SendMessageA__IIII
-JNIEXPORT jint JNICALL OS_NATIVE(SendMessageA__IIII)
- (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jint arg3)
-{
- DEBUG_CALL("SendMessageA__IIII\n")
-
- return (jint)SendMessageA((HWND)arg0, arg1, arg2, arg3);
-}
-#endif /* NO_SendMessageA__IIII */
-
-#ifndef NO_SendMessageA__IIILorg_eclipse_swt_internal_win32_LVHITTESTINFO_2
-JNIEXPORT jint JNICALL OS_NATIVE(SendMessageA__IIILorg_eclipse_swt_internal_win32_LVHITTESTINFO_2)
- (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jobject arg3)
-{
- LVHITTESTINFO _arg3, *lparg3=NULL;
- jint rc;
-
- DEBUG_CALL("SendMessageA__IIILorg_eclipse_swt_internal_win32_LVHITTESTINFO_2\n")
-
- if (arg3) lparg3 = getLVHITTESTINFOFields(env, arg3, &_arg3);
- rc = (jint)SendMessageA((HWND)arg0, arg1, arg2, (LPARAM)lparg3);
- if (arg3) setLVHITTESTINFOFields(env, arg3, lparg3);
- return rc;
-}
-#endif /* NO_SendMessageA__IIILorg_eclipse_swt_internal_win32_LVHITTESTINFO_2 */
-
-#ifndef NO_SendMessageA__IIILorg_eclipse_swt_internal_win32_LVITEM_2
-JNIEXPORT jint JNICALL OS_NATIVE(SendMessageA__IIILorg_eclipse_swt_internal_win32_LVITEM_2)
- (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jobject arg3)
-{
- LVITEM _arg3, *lparg3=NULL;
- jint rc;
-
- DEBUG_CALL("SendMessageA__IIILorg_eclipse_swt_internal_win32_LVITEM_2\n")
-
- if (arg3) lparg3 = getLVITEMFields(env, arg3, &_arg3);
- rc = (jint)SendMessageA((HWND)arg0, arg1, arg2, (LPARAM)lparg3);
- if (arg3) setLVITEMFields(env, arg3, lparg3);
- return rc;
-}
-#endif /* NO_SendMessageA__IIILorg_eclipse_swt_internal_win32_LVITEM_2 */
-
-#ifndef NO_SendMessageA__IIILorg_eclipse_swt_internal_win32_REBARBANDINFO_2
-JNIEXPORT jint JNICALL OS_NATIVE(SendMessageA__IIILorg_eclipse_swt_internal_win32_REBARBANDINFO_2)
- (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jobject arg3)
-{
- REBARBANDINFO _arg3, *lparg3=NULL;
- jint rc;
-
- DEBUG_CALL("SendMessageA__IIILorg_eclipse_swt_internal_win32_REBARBANDINFO_2\n")
-
- if (arg3) lparg3 = getREBARBANDINFOFields(env, arg3, &_arg3);
- rc = (jint)SendMessageA((HWND)arg0, arg1, arg2, (LPARAM)lparg3);
- if (arg3) setREBARBANDINFOFields(env, arg3, lparg3);
- return rc;
-}
-#endif /* NO_SendMessageA__IIILorg_eclipse_swt_internal_win32_REBARBANDINFO_2 */
-
-#ifndef NO_SendMessageA__IIILorg_eclipse_swt_internal_win32_RECT_2
-JNIEXPORT jint JNICALL OS_NATIVE(SendMessageA__IIILorg_eclipse_swt_internal_win32_RECT_2)
- (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jobject arg3)
-{
- RECT _arg3, *lparg3=NULL;
- jint rc;
-
- DEBUG_CALL("SendMessageA__IIILorg_eclipse_swt_internal_win32_RECT_2\n")
-
- if (arg3) lparg3 = getRECTFields(env, arg3, &_arg3);
- rc = (jint)SendMessageA((HWND)arg0, arg1, arg2, (LPARAM)lparg3);
- if (arg3) setRECTFields(env, arg3, lparg3);
- return rc;
-}
-#endif /* NO_SendMessageA__IIILorg_eclipse_swt_internal_win32_RECT_2 */
-
-#ifndef NO_SendMessageA__IIILorg_eclipse_swt_internal_win32_TBBUTTON_2
-JNIEXPORT jint JNICALL OS_NATIVE(SendMessageA__IIILorg_eclipse_swt_internal_win32_TBBUTTON_2)
- (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jobject arg3)
-{
- TBBUTTON _arg3, *lparg3=NULL;
- jint rc;
-
- DEBUG_CALL("SendMessageA__IIILorg_eclipse_swt_internal_win32_TBBUTTON_2\n")
-
- if (arg3) lparg3 = getTBBUTTONFields(env, arg3, &_arg3);
- rc = (jint)SendMessageA((HWND)arg0, arg1, arg2, (LPARAM)lparg3);
- if (arg3) setTBBUTTONFields(env, arg3, lparg3);
- return rc;
-}
-#endif /* NO_SendMessageA__IIILorg_eclipse_swt_internal_win32_TBBUTTON_2 */
-
-#ifndef NO_SendMessageA__IIILorg_eclipse_swt_internal_win32_TBBUTTONINFO_2
-JNIEXPORT jint JNICALL OS_NATIVE(SendMessageA__IIILorg_eclipse_swt_internal_win32_TBBUTTONINFO_2)
- (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jobject arg3)
-{
- TBBUTTONINFO _arg3, *lparg3=NULL;
- jint rc;
-
- DEBUG_CALL("SendMessageA__IIILorg_eclipse_swt_internal_win32_TBBUTTONINFO_2\n")
-
- if (arg3) lparg3 = getTBBUTTONINFOFields(env, arg3, &_arg3);
- rc = (jint)SendMessageA((HWND)arg0, arg1, arg2, (LPARAM)lparg3);
- if (arg3) setTBBUTTONINFOFields(env, arg3, lparg3);
- return rc;
-}
-#endif /* NO_SendMessageA__IIILorg_eclipse_swt_internal_win32_TBBUTTONINFO_2 */
-
-#ifndef NO_SendMessageA__IIILorg_eclipse_swt_internal_win32_TCITEM_2
-JNIEXPORT jint JNICALL OS_NATIVE(SendMessageA__IIILorg_eclipse_swt_internal_win32_TCITEM_2)
- (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jobject arg3)
-{
- TCITEM _arg3, *lparg3=NULL;
- jint rc;
-
- DEBUG_CALL("SendMessageA__IIILorg_eclipse_swt_internal_win32_TCITEM_2\n")
-
- if (arg3) lparg3 = getTCITEMFields(env, arg3, &_arg3);
- rc = (jint)SendMessageA((HWND)arg0, arg1, arg2, (LPARAM)lparg3);
- if (arg3) setTCITEMFields(env, arg3, lparg3);
- return rc;
-}
-#endif /* NO_SendMessageA__IIILorg_eclipse_swt_internal_win32_TCITEM_2 */
-
-#ifndef NO_SendMessageA__IIILorg_eclipse_swt_internal_win32_TOOLINFO_2
-JNIEXPORT jint JNICALL OS_NATIVE(SendMessageA__IIILorg_eclipse_swt_internal_win32_TOOLINFO_2)
- (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jobject arg3)
-{
- TOOLINFO _arg3, *lparg3=NULL;
- jint rc;
-
- DEBUG_CALL("SendMessageA__IIILorg_eclipse_swt_internal_win32_TOOLINFO_2\n")
-
- if (arg3) lparg3 = getTOOLINFOFields(env, arg3, &_arg3);
- rc = (jint)SendMessageA((HWND)arg0, arg1, arg2, (LPARAM)lparg3);
- if (arg3) setTOOLINFOFields(env, arg3, lparg3);
- return rc;
-}
-#endif /* NO_SendMessageA__IIILorg_eclipse_swt_internal_win32_TOOLINFO_2 */
-
-#ifndef NO_SendMessageA__IIILorg_eclipse_swt_internal_win32_TVHITTESTINFO_2
-JNIEXPORT jint JNICALL OS_NATIVE(SendMessageA__IIILorg_eclipse_swt_internal_win32_TVHITTESTINFO_2)
- (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jobject arg3)
-{
- TVHITTESTINFO _arg3, *lparg3=NULL;
- jint rc;
-
- DEBUG_CALL("SendMessageA__IIILorg_eclipse_swt_internal_win32_TVHITTESTINFO_2\n")
-
- if (arg3) lparg3 = getTVHITTESTINFOFields(env, arg3, &_arg3);
- rc = (jint)SendMessageA((HWND)arg0, arg1, arg2, (LPARAM)lparg3);
- if (arg3) setTVHITTESTINFOFields(env, arg3, lparg3);
- return rc;
-}
-#endif /* NO_SendMessageA__IIILorg_eclipse_swt_internal_win32_TVHITTESTINFO_2 */
-
-#ifndef NO_SendMessageA__IIILorg_eclipse_swt_internal_win32_TVINSERTSTRUCT_2
-JNIEXPORT jint JNICALL OS_NATIVE(SendMessageA__IIILorg_eclipse_swt_internal_win32_TVINSERTSTRUCT_2)
- (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jobject arg3)
-{
- TVINSERTSTRUCT _arg3, *lparg3=NULL;
- jint rc;
-
- DEBUG_CALL("SendMessageA__IIILorg_eclipse_swt_internal_win32_TVINSERTSTRUCT_2\n")
-
- if (arg3) lparg3 = getTVINSERTSTRUCTFields(env, arg3, &_arg3);
- rc = (jint)SendMessageA((HWND)arg0, arg1, arg2, (LPARAM)lparg3);
- if (arg3) setTVINSERTSTRUCTFields(env, arg3, lparg3);
- return rc;
-}
-#endif /* NO_SendMessageA__IIILorg_eclipse_swt_internal_win32_TVINSERTSTRUCT_2 */
-
-#ifndef NO_SendMessageA__IIILorg_eclipse_swt_internal_win32_TVITEM_2
-JNIEXPORT jint JNICALL OS_NATIVE(SendMessageA__IIILorg_eclipse_swt_internal_win32_TVITEM_2)
- (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jobject arg3)
-{
- TVITEM _arg3, *lparg3=NULL;
- jint rc;
-
- DEBUG_CALL("SendMessageA__IIILorg_eclipse_swt_internal_win32_TVITEM_2\n")
-
- if (arg3) lparg3 = getTVITEMFields(env, arg3, &_arg3);
- rc = (jint)SendMessageA((HWND)arg0, arg1, arg2, (LPARAM)lparg3);
- if (arg3) setTVITEMFields(env, arg3, lparg3);
- return rc;
-}
-#endif /* NO_SendMessageA__IIILorg_eclipse_swt_internal_win32_TVITEM_2 */
-
-#ifndef NO_SendMessageA__III_3S
-JNIEXPORT jint JNICALL OS_NATIVE(SendMessageA__III_3S)
- (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jshortArray arg3)
-{
- jshort *lparg3=NULL;
- jint rc;
-
- DEBUG_CALL("SendMessageA__III_3S\n")
-
- if (arg3) lparg3 = (*env)->GetShortArrayElements(env, arg3, NULL);
- rc = (jint)SendMessageA((HWND)arg0, arg1, arg2, (LPARAM)lparg3);
- if (arg3) (*env)->ReleaseShortArrayElements(env, arg3, lparg3, 0);
- return rc;
-}
-#endif /* NO_SendMessageA__III_3S */
-
-#ifndef NO_SendMessageA__IIILorg_eclipse_swt_internal_win32_LVCOLUMN_2
-JNIEXPORT jint JNICALL OS_NATIVE(SendMessageA__IIILorg_eclipse_swt_internal_win32_LVCOLUMN_2)
- (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jobject arg3)
-{
- LVCOLUMN _arg3, *lparg3=NULL;
- jint rc;
-
- DEBUG_CALL("SendMessageA__IIILorg_eclipse_swt_internal_win32_LVCOLUMN_2\n")
-
- if (arg3) lparg3 = getLVCOLUMNFields(env, arg3, &_arg3);
- rc = (jint)SendMessageA((HWND)arg0, arg1, arg2, (LPARAM)lparg3);
- if (arg3) setLVCOLUMNFields(env, arg3, lparg3);
- return rc;
-}
-#endif /* NO_SendMessageA__IIILorg_eclipse_swt_internal_win32_LVCOLUMN_2 */
-
-#ifndef NO_SendMessageW__II_3I_3I
-JNIEXPORT jint JNICALL OS_NATIVE(SendMessageW__II_3I_3I)
- (JNIEnv *env, jclass that, jint arg0, jint arg1, jintArray arg2, jintArray arg3)
-{
- jint *lparg2=NULL;
- jint *lparg3=NULL;
- jint rc;
-
- DEBUG_CALL("SendMessageW\n")
-
- if (arg2) lparg2 = (*env)->GetIntArrayElements(env, arg2, NULL);
- if (arg3) lparg3 = (*env)->GetIntArrayElements(env, arg3, NULL);
-
-#ifdef _WIN32_WCE
- /* SPECIAL */
- /*
- * Bug on WinCE. SendMessage can fail (return 0) when being passed references
- * to parameters allocated from the heap. The workaround is to allocate
- * the parameters on the stack and to copy them back to the java array.
- * Observed on Pocket PC WinCE 3.0 with EM_GETSEL and CB_GETEDITSEL messages.
- */
- switch (arg1) {
- case EM_GETSEL:
- case CB_GETEDITSEL: {
- jint wParam = 0, lParam = 0;
- jint *lpwParam = NULL, *lplParam = NULL;
- if (lparg2 != NULL) lpwParam = &wParam;
- if (lparg3 != NULL) lplParam = &lParam;
- rc = (jint)SendMessageW((HWND)arg0, arg1, (WPARAM)lpwParam, (LPARAM)lplParam);
- if (lparg2 != NULL) lparg2[0] = wParam;
- if (lparg3 != NULL) lparg3[0] = lParam;
- break;
- }
- default:
- rc = (jint)SendMessageW((HWND)arg0, arg1, (WPARAM)lparg2, (LPARAM)lparg3);
- }
-#else
- rc = (jint)SendMessageW((HWND)arg0, arg1, (WPARAM)lparg2, (LPARAM)lparg3);
-#endif /* _WIN32_WCE */
-
- if (arg2) (*env)->ReleaseIntArrayElements(env, arg2, lparg2, 0);
- if (arg3) (*env)->ReleaseIntArrayElements(env, arg3, lparg3, 0);
-
- return rc;
-}
-#endif /* NO_SendMessageW__II_3I_3I */
-
-#ifndef NO_SendMessageW__II_3II
-JNIEXPORT jint JNICALL OS_NATIVE(SendMessageW__II_3II)
- (JNIEnv *env, jclass that, jint arg0, jint arg1, jintArray arg2, jint arg3)
-{
- jint *lparg2=NULL;
- jint rc;
-
- DEBUG_CALL("SendMessageW__II_3II\n")
-
- if (arg2) lparg2 = (*env)->GetIntArrayElements(env, arg2, NULL);
- rc = (jint)SendMessageW((HWND)arg0, arg1, (WPARAM)lparg2, (LPARAM)arg3);
- if (arg2) (*env)->ReleaseIntArrayElements(env, arg2, lparg2, 0);
- return rc;
-}
-#endif /* NO_SendMessageW__II_3II */
-
-#ifndef NO_SendMessageW__III_3C
-JNIEXPORT jint JNICALL OS_NATIVE(SendMessageW__III_3C)
- (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jcharArray arg3)
-{
- jchar *lparg3=NULL;
- jint rc;
-
- DEBUG_CALL("SendMessageW__III_3C\n")
-
- if (arg3) lparg3 = (*env)->GetCharArrayElements(env, arg3, NULL);
- rc = (jint)SendMessageW((HWND)arg0, arg1, arg2, (LPARAM)lparg3);
- if (arg3) (*env)->ReleaseCharArrayElements(env, arg3, lparg3, 0);
- return rc;
-}
-#endif /* NO_SendMessageW__III_3C */
-
-#ifndef NO_SendMessageW__III_3I
-JNIEXPORT jint JNICALL OS_NATIVE(SendMessageW__III_3I)
- (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jintArray arg3)
-{
- jint *lparg3=NULL;
- jint rc;
-
- DEBUG_CALL("SendMessageW__III_3I\n")
-
- if (arg3) lparg3 = (*env)->GetIntArrayElements(env, arg3, NULL);
- rc = (jint)SendMessageW((HWND)arg0, arg1, arg2, (LPARAM)lparg3);
- if (arg3) (*env)->ReleaseIntArrayElements(env, arg3, lparg3, 0);
- return rc;
-}
-#endif /* NO_SendMessageW__III_3I */
-
-#ifndef NO_SendMessageW__III_3S
-JNIEXPORT jint JNICALL OS_NATIVE(SendMessageW__III_3S)
- (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jshortArray arg3)
-{
- jshort *lparg3=NULL;
- jint rc;
-
- DEBUG_CALL("SendMessageW__III_3S\n")
-
- if (arg3) lparg3 = (*env)->GetShortArrayElements(env, arg3, NULL);
- rc = (jint)SendMessageW((HWND)arg0, arg1, arg2, (LPARAM)lparg3);
- if (arg3) (*env)->ReleaseShortArrayElements(env, arg3, lparg3, 0);
- return rc;
-}
-#endif /* NO_SendMessageW__III_3S */
-
-#ifndef NO_SendMessageW__IIII
-JNIEXPORT jint JNICALL OS_NATIVE(SendMessageW__IIII)
- (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jint arg3)
-{
- DEBUG_CALL("SendMessageW__IIII\n")
-
- return (jint)SendMessageW((HWND)arg0, arg1, arg2, (LPARAM)arg3);
-}
-#endif /* NO_SendMessageW__IIII */
-
-#ifndef NO_SendMessageW__IIILorg_eclipse_swt_internal_win32_LVHITTESTINFO_2
-JNIEXPORT jint JNICALL OS_NATIVE(SendMessageW__IIILorg_eclipse_swt_internal_win32_LVHITTESTINFO_2)
- (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jobject arg3)
-{
- LVHITTESTINFO _arg3, *lparg3=NULL;
- jint rc;
-
- DEBUG_CALL("SendMessageW__IIILorg_eclipse_swt_internal_win32_LVHITTESTINFO_2\n")
-
- if (arg3) lparg3 = getLVHITTESTINFOFields(env, arg3, &_arg3);
- rc = (jint)SendMessageW((HWND)arg0, arg1, arg2, (LPARAM)lparg3);
- if (arg3) setLVHITTESTINFOFields(env, arg3, lparg3);
- return rc;
-}
-#endif /* NO_SendMessageW__IIILorg_eclipse_swt_internal_win32_LVHITTESTINFO_2 */
-
-#ifndef NO_SendMessageW__IIILorg_eclipse_swt_internal_win32_LVITEM_2
-JNIEXPORT jint JNICALL OS_NATIVE(SendMessageW__IIILorg_eclipse_swt_internal_win32_LVITEM_2)
- (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jobject arg3)
-{
- LVITEM _arg3, *lparg3=NULL;
- jint rc;
-
- DEBUG_CALL("SendMessageW__IIILorg_eclipse_swt_internal_win32_LVITEM_2\n")
-
- if (arg3) lparg3 = getLVITEMFields(env, arg3, &_arg3);
- rc = (jint)SendMessageW((HWND)arg0, arg1, arg2, (LPARAM)lparg3);
- if (arg3) setLVITEMFields(env, arg3, lparg3);
- return rc;
-}
-#endif /* NO_SendMessageW__IIILorg_eclipse_swt_internal_win32_LVITEM_2 */
-
-#ifndef NO_SendMessageW__IIILorg_eclipse_swt_internal_win32_REBARBANDINFO_2
-JNIEXPORT jint JNICALL OS_NATIVE(SendMessageW__IIILorg_eclipse_swt_internal_win32_REBARBANDINFO_2)
- (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jobject arg3)
-{
- REBARBANDINFO _arg3, *lparg3=NULL;
- jint rc;
-
- DEBUG_CALL("SendMessageW__IIILorg_eclipse_swt_internal_win32_REBARBANDINFO_2\n")
-
- if (arg3) lparg3 = getREBARBANDINFOFields(env, arg3, &_arg3);
- rc = (jint)SendMessageW((HWND)arg0, arg1, arg2, (LPARAM)lparg3);
- if (arg3) setREBARBANDINFOFields(env, arg3, lparg3);
- return rc;
-}
-#endif /* NO_SendMessageW__IIILorg_eclipse_swt_internal_win32_REBARBANDINFO_2 */
-
-#ifndef NO_SendMessageW__IIILorg_eclipse_swt_internal_win32_RECT_2
-JNIEXPORT jint JNICALL OS_NATIVE(SendMessageW__IIILorg_eclipse_swt_internal_win32_RECT_2)
- (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jobject arg3)
-{
- RECT _arg3, *lparg3=NULL;
- jint rc;
-
- DEBUG_CALL("SendMessageW__IIILorg_eclipse_swt_internal_win32_RECT_2\n")
-
- if (arg3) lparg3 = getRECTFields(env, arg3, &_arg3);
- rc = (jint)SendMessageW((HWND)arg0, arg1, arg2, (LPARAM)lparg3);
- if (arg3) setRECTFields(env, arg3, lparg3);
- return rc;
-}
-#endif /* NO_SendMessageW__IIILorg_eclipse_swt_internal_win32_RECT_2 */
-
-#ifndef NO_SendMessageW__IIILorg_eclipse_swt_internal_win32_TBBUTTON_2
-JNIEXPORT jint JNICALL OS_NATIVE(SendMessageW__IIILorg_eclipse_swt_internal_win32_TBBUTTON_2)
- (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jobject arg3)
-{
- TBBUTTON _arg3, *lparg3=NULL;
- jint rc;
-
- DEBUG_CALL("SendMessageW__IIILorg_eclipse_swt_internal_win32_TBBUTTON_2\n")
-
- if (arg3) lparg3 = getTBBUTTONFields(env, arg3, &_arg3);
- rc = (jint)SendMessageW((HWND)arg0, arg1, arg2, (LPARAM)lparg3);
- if (arg3) setTBBUTTONFields(env, arg3, lparg3);
- return rc;
-}
-#endif /* NO_SendMessageW__IIILorg_eclipse_swt_internal_win32_TBBUTTON_2 */
-
-#ifndef NO_SendMessageW__IIILorg_eclipse_swt_internal_win32_TBBUTTONINFO_2
-JNIEXPORT jint JNICALL OS_NATIVE(SendMessageW__IIILorg_eclipse_swt_internal_win32_TBBUTTONINFO_2)
- (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jobject arg3)
-{
- TBBUTTONINFO _arg3, *lparg3=NULL;
- jint rc;
-
- DEBUG_CALL("SendMessageW__IIILorg_eclipse_swt_internal_win32_TBBUTTONINFO_2\n")
-
- if (arg3) lparg3 = getTBBUTTONINFOFields(env, arg3, &_arg3);
- rc = (jint)SendMessageW((HWND)arg0, arg1, arg2, (LPARAM)lparg3);
- if (arg3) setTBBUTTONINFOFields(env, arg3, lparg3);
- return rc;
-}
-#endif /* NO_SendMessageW__IIILorg_eclipse_swt_internal_win32_TBBUTTONINFO_2 */
-
-#ifndef NO_SendMessageW__IIILorg_eclipse_swt_internal_win32_TCITEM_2
-JNIEXPORT jint JNICALL OS_NATIVE(SendMessageW__IIILorg_eclipse_swt_internal_win32_TCITEM_2)
- (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jobject arg3)
-{
- TCITEM _arg3, *lparg3=NULL;
- jint rc;
-
- DEBUG_CALL("SendMessageW__IIILorg_eclipse_swt_internal_win32_TCITEM_2\n")
-
- if (arg3) lparg3 = getTCITEMFields(env, arg3, &_arg3);
- rc = (jint)SendMessageW((HWND)arg0, arg1, arg2, (LPARAM)lparg3);
- if (arg3) setTCITEMFields(env, arg3, lparg3);
- return rc;
-}
-#endif /* NO_SendMessageW__IIILorg_eclipse_swt_internal_win32_TCITEM_2 */
-
-#ifndef NO_SendMessageW__IIILorg_eclipse_swt_internal_win32_TOOLINFO_2
-JNIEXPORT jint JNICALL OS_NATIVE(SendMessageW__IIILorg_eclipse_swt_internal_win32_TOOLINFO_2)
- (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jobject arg3)
-{
- TOOLINFO _arg3, *lparg3=NULL;
- jint rc;
-
- DEBUG_CALL("SendMessageW__IIILorg_eclipse_swt_internal_win32_TOOLINFO_2\n")
-
- if (arg3) lparg3 = getTOOLINFOFields(env, arg3, &_arg3);
- rc = (jint)SendMessageW((HWND)arg0, arg1, arg2, (LPARAM)lparg3);
- if (arg3) setTOOLINFOFields(env, arg3, lparg3);
- return rc;
-}
-#endif /* NO_SendMessageW__IIILorg_eclipse_swt_internal_win32_TOOLINFO_2 */
-
-#ifndef NO_SendMessageW__IIILorg_eclipse_swt_internal_win32_TVHITTESTINFO_2
-JNIEXPORT jint JNICALL OS_NATIVE(SendMessageW__IIILorg_eclipse_swt_internal_win32_TVHITTESTINFO_2)
- (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jobject arg3)
-{
- TVHITTESTINFO _arg3, *lparg3=NULL;
- jint rc;
-
- DEBUG_CALL("SendMessageW__IIILorg_eclipse_swt_internal_win32_TVHITTESTINFO_2\n")
-
- if (arg3) lparg3 = getTVHITTESTINFOFields(env, arg3, &_arg3);
- rc = (jint)SendMessageW((HWND)arg0, arg1, arg2, (LPARAM)lparg3);
- if (arg3) setTVHITTESTINFOFields(env, arg3, lparg3);
- return rc;
-}
-#endif /* NO_SendMessageW__IIILorg_eclipse_swt_internal_win32_TVHITTESTINFO_2 */
-
-#ifndef NO_SendMessageW__IIILorg_eclipse_swt_internal_win32_TVINSERTSTRUCT_2
-JNIEXPORT jint JNICALL OS_NATIVE(SendMessageW__IIILorg_eclipse_swt_internal_win32_TVINSERTSTRUCT_2)
- (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jobject arg3)
-{
- TVINSERTSTRUCT _arg3, *lparg3=NULL;
- jint rc;
-
- DEBUG_CALL("SendMessageW__IIILorg_eclipse_swt_internal_win32_TVINSERTSTRUCT_2\n")
-
- if (arg3) lparg3 = getTVINSERTSTRUCTFields(env, arg3, &_arg3);
- rc = (jint)SendMessageW((HWND)arg0, arg1, arg2, (LPARAM)lparg3);
- if (arg3) setTVINSERTSTRUCTFields(env, arg3, lparg3);
- return rc;
-}
-#endif /* NO_SendMessageW__IIILorg_eclipse_swt_internal_win32_TVINSERTSTRUCT_2 */
-
-#ifndef NO_SendMessageW__IIILorg_eclipse_swt_internal_win32_TVITEM_2
-JNIEXPORT jint JNICALL OS_NATIVE(SendMessageW__IIILorg_eclipse_swt_internal_win32_TVITEM_2)
- (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jobject arg3)
-{
- TVITEM _arg3, *lparg3=NULL;
- jint rc;
-
- DEBUG_CALL("SendMessageW__IIILorg_eclipse_swt_internal_win32_TVITEM_2\n")
-
- if (arg3) lparg3 = getTVITEMFields(env, arg3, &_arg3);
- rc = (jint)SendMessageW((HWND)arg0, arg1, arg2, (LPARAM)lparg3);
- if (arg3) setTVITEMFields(env, arg3, lparg3);
- return rc;
-}
-#endif /* NO_SendMessageW__IIILorg_eclipse_swt_internal_win32_TVITEM_2 */
-
-#ifndef NO_SendMessageW__IIILorg_eclipse_swt_internal_win32_LVCOLUMN_2
-JNIEXPORT jint JNICALL OS_NATIVE(SendMessageW__IIILorg_eclipse_swt_internal_win32_LVCOLUMN_2)
- (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jobject arg3)
-{
- LVCOLUMN _arg3, *lparg3=NULL;
- jint rc;
-
- DEBUG_CALL("SendMessageW__IIILorg_eclipse_swt_internal_win32_LVCOLUMN_2\n")
-
- if (arg3) lparg3 = getLVCOLUMNFields(env, arg3, &_arg3);
- rc = (jint)SendMessageW((HWND)arg0, arg1, arg2, (LPARAM)lparg3);
- if (arg3) setLVCOLUMNFields(env, arg3, lparg3);
- return rc;
-}
-#endif /* NO_SendMessageW__IIILorg_eclipse_swt_internal_win32_LVCOLUMN_2 */
-
-#ifndef NO_SetActiveWindow
-JNIEXPORT jint JNICALL OS_NATIVE(SetActiveWindow)
- (JNIEnv *env, jclass that, jint arg0)
-{
- DEBUG_CALL("SetActiveWindow\n")
-
- return (jint)SetActiveWindow((HWND)arg0);
-}
-#endif /* NO_SetActiveWindow */
-
-#ifndef NO_SetBkColor
-JNIEXPORT jint JNICALL OS_NATIVE(SetBkColor)
- (JNIEnv *env, jclass that, jint arg0, jint arg1)
-{
- DEBUG_CALL("SetBkColor\n")
-
- return (jint)SetBkColor((HDC)arg0, (COLORREF)arg1);
-}
-#endif /* NO_SetBkColor */
-
-#ifndef NO_SetBkMode
-JNIEXPORT jint JNICALL OS_NATIVE(SetBkMode)
- (JNIEnv *env, jclass that, jint arg0, jint arg1)
-{
- DEBUG_CALL("SetBkMode\n")
-
- return (jint)SetBkMode((HDC)arg0, arg1);
-}
-#endif /* NO_SetBkMode */
-
-#ifndef NO_SetCapture
-JNIEXPORT jint JNICALL OS_NATIVE(SetCapture)
- (JNIEnv *env, jclass that, jint arg0)
-{
- DEBUG_CALL("SetCapture\n")
-
- return (jint)SetCapture((HWND)arg0);
-}
-#endif /* NO_SetCapture */
-
-#ifndef NO_SetCaretPos
-JNIEXPORT jboolean JNICALL OS_NATIVE(SetCaretPos)
- (JNIEnv *env, jclass that, jint arg0, jint arg1)
-{
- DEBUG_CALL("SetCaretPos\n")
-
- return (jboolean)SetCaretPos(arg0, arg1);
-}
-#endif /* NO_SetCaretPos */
-
-#ifndef NO_SetClipboardData
-JNIEXPORT jint JNICALL OS_NATIVE(SetClipboardData)
- (JNIEnv *env, jclass that, jint arg0, jint arg1)
-{
- DEBUG_CALL("SetClipboardData\n")
-
- return (jint)SetClipboardData(arg0, (HANDLE)arg1);
-}
-#endif /* NO_SetClipboardData */
-
-#ifndef NO_SetCursor
-JNIEXPORT jint JNICALL OS_NATIVE(SetCursor)
- (JNIEnv *env, jclass that, jint arg0)
-{
- DEBUG_CALL("SetCursor\n")
-
- return (jint)SetCursor((HCURSOR)arg0);
-}
-#endif /* NO_SetCursor */
-
-#ifndef NO_SetCursorPos
-JNIEXPORT jboolean JNICALL OS_NATIVE(SetCursorPos)
- (JNIEnv *env, jclass that, jint arg0, jint arg1)
-{
- DEBUG_CALL("SetCursorPos\n")
-
- return (jboolean)SetCursorPos(arg0, arg1);
-}
-#endif /* NO_SetCursorPos */
-
-#ifndef NO_SetDIBColorTable
-JNIEXPORT jint JNICALL OS_NATIVE(SetDIBColorTable)
- (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jbyteArray arg3)
-{
- jbyte *lparg3=NULL;
- jint rc;
-
- DEBUG_CALL("SetDIBColorTable\n")
-
- if (arg3) lparg3 = (*env)->GetByteArrayElements(env, arg3, NULL);
- rc = (jint)SetDIBColorTable((HDC)arg0, arg1, arg2, (RGBQUAD *)lparg3);
- if (arg3) (*env)->ReleaseByteArrayElements(env, arg3, lparg3, 0);
- return rc;
-}
-#endif /* NO_SetDIBColorTable */
-
-#ifndef NO_SetFocus
-JNIEXPORT jint JNICALL OS_NATIVE(SetFocus)
- (JNIEnv *env, jclass that, jint arg0)
-{
- DEBUG_CALL("SetFocus\n")
-
- return (jint)SetFocus((HWND)arg0);
-}
-#endif /* NO_SetFocus */
-
-#ifndef NO_SetForegroundWindow
-JNIEXPORT jboolean JNICALL OS_NATIVE(SetForegroundWindow)
- (JNIEnv *env, jclass that, jint arg0)
-{
- DEBUG_CALL("SetForegroundWindow\n")
-
- return (jboolean)SetForegroundWindow((HWND)arg0);
-}
-#endif /* NO_SetForegroundWindow */
-
-#ifndef NO_SetLayout
-JNIEXPORT jint JNICALL OS_NATIVE(SetLayout)
- (JNIEnv *env, jclass that, jint arg0, jint arg1)
-{
- HMODULE hm;
- FARPROC fp;
-
- DEBUG_CALL("SetLayout\n")
-
- /* SPECIAL */
- /*
- * SetLayout 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("gdi32.dll")) && (fp=GetProcAddress(hm, "SetLayout"))) {
- return (jint) (fp)((HDC)arg0, (DWORD)arg1);
-// return (jint)SetLayout((HDC)arg0, (DWORD)arg1);
- }
- return 0;
-}
-#endif /* NO_SetLayout */
-
-#ifndef NO_SetMenu
-JNIEXPORT jboolean JNICALL OS_NATIVE(SetMenu)
- (JNIEnv *env, jclass that, jint arg0, jint arg1)
-{
- DEBUG_CALL("SetMenu\n")
-
- return (jboolean)SetMenu((HWND)arg0, (HMENU)arg1);
-}
-#endif /* NO_SetMenu */
-
-#ifndef NO_SetMenuDefaultItem
-JNIEXPORT jboolean JNICALL OS_NATIVE(SetMenuDefaultItem)
- (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2)
-{
- DEBUG_CALL("SetMenuDefaultItem\n")
-
- return (jboolean)SetMenuDefaultItem((HMENU)arg0, arg1, arg2);
-}
-#endif /* NO_SetMenuDefaultItem */
-
-#ifndef NO_SetMenuInfo
-JNIEXPORT jboolean JNICALL OS_NATIVE(SetMenuInfo)
- (JNIEnv *env, jclass that, jint arg0, jobject arg1)
-{
- MENUINFO _arg1, *lparg1=NULL;
- jboolean rc = (jboolean)FALSE;
- HMODULE hm;
- FARPROC fp;
-
- DEBUG_CALL("SetMenuInfo\n")
-
- /* SPECIAL */
- /*
- * 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 (arg1) lparg1 = getMENUINFOFields(env, arg1, &_arg1);
-
- rc = (jboolean) (fp)((HMENU)arg0, lparg1);
-// rc = (jboolean)SetMenuInfo(arg0, lparg1);
-
- if (arg1) setMENUINFOFields(env, arg1, lparg1);
- }
-
- return rc;
-}
-#endif /* NO_SetMenuInfo */
-
-#ifndef NO_SetMenuItemInfoA
-JNIEXPORT jboolean JNICALL OS_NATIVE(SetMenuItemInfoA)
- (JNIEnv *env, jclass that, jint arg0, jint arg1, jboolean arg2, jobject arg3)
-{
- MENUITEMINFO _arg3, *lparg3=NULL;
- jboolean rc;
-
- DEBUG_CALL("SetMenuItemInfoA\n")
-
- if (arg3) lparg3 = getMENUITEMINFOFields(env, arg3, &_arg3);
- rc = (jboolean)SetMenuItemInfoA((HMENU)arg0, arg1, arg2, lparg3);
- if (arg3) setMENUITEMINFOFields(env, arg3, lparg3);
- return rc;
-}
-#endif /* NO_SetMenuItemInfoA */
-
-#ifndef NO_SetMenuItemInfoW
-JNIEXPORT jboolean JNICALL OS_NATIVE(SetMenuItemInfoW)
- (JNIEnv *env, jclass that, jint arg0, jint arg1, jboolean arg2, jobject arg3)
-{
- MENUITEMINFO _arg3, *lparg3=NULL;
- jboolean rc;
-
- DEBUG_CALL("SetMenuItemInfoW\n")
-
- if (arg3) lparg3 = getMENUITEMINFOFields(env, arg3, &_arg3);
- rc = (jboolean)SetMenuItemInfoW((HMENU)arg0, arg1, arg2, (LPMENUITEMINFOW)lparg3);
- if (arg3) setMENUITEMINFOFields(env, arg3, lparg3);
- return rc;
-}
-#endif /* NO_SetMenuItemInfoW */
-
-#ifndef NO_SetPaletteEntries
-JNIEXPORT jint JNICALL OS_NATIVE(SetPaletteEntries)
- (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jbyteArray arg3)
-{
- jbyte *lparg3=NULL;
- jint rc;
-
- DEBUG_CALL("SetPaletteEntries\n")
-
- if (arg3) lparg3 = (*env)->GetByteArrayElements(env, arg3, NULL);
- rc = (jint)SetPaletteEntries((HPALETTE)arg0, arg1, arg2, (PALETTEENTRY *)lparg3);
- if (arg3) (*env)->ReleaseByteArrayElements(env, arg3, lparg3, 0);
- return rc;
-}
-#endif /* NO_SetPaletteEntries */
-
-#ifndef NO_SetParent
-JNIEXPORT jint JNICALL OS_NATIVE(SetParent)
- (JNIEnv *env, jclass that, jint arg0, jint arg1)
-{
- DEBUG_CALL("SetParent\n")
-
- return (jint)SetParent((HWND)arg0, (HWND)arg1);
-}
-#endif /* NO_SetParent */
-
-#ifndef NO_SetPixel
-JNIEXPORT jint JNICALL OS_NATIVE(SetPixel)
- (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jint arg3)
-{
- DEBUG_CALL("SetPixel\n")
-
- return (jint)SetPixel((HDC)arg0, arg1, arg2, arg3);
-}
-#endif /* NO_SetPixel */
-
-#ifndef NO_SetROP2
-JNIEXPORT jint JNICALL OS_NATIVE(SetROP2)
- (JNIEnv *env, jclass that, jint arg0, jint arg1)
-{
- DEBUG_CALL("SetROP2\n")
-
- return (jint)SetROP2((HDC)arg0, arg1);
-}
-#endif /* NO_SetROP2 */
-
-#ifndef NO_SetRect
-JNIEXPORT jboolean JNICALL OS_NATIVE(SetRect)
- (JNIEnv *env, jclass that, jobject arg0, jint arg1, jint arg2, jint arg3, jint arg4)
-{
- RECT _arg0, *lparg0=NULL;
- jboolean rc;
-
- DEBUG_CALL("SetRect\n")
-
- if (arg0) lparg0 = getRECTFields(env, arg0, &_arg0);
- rc = (jboolean)SetRect(lparg0, arg1, arg2, arg3, arg4);
- if (arg0) setRECTFields(env, arg0, lparg0);
- return rc;
-}
-#endif /* NO_SetRect */
-
-#ifndef NO_SetRectRgn
-JNIEXPORT jboolean JNICALL OS_NATIVE(SetRectRgn)
- (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jint arg3, jint arg4)
-{
- DEBUG_CALL("SetRectRgn\n")
-
- return (jboolean)SetRectRgn((HRGN)arg0, arg1, arg2, arg3, arg4);
-}
-#endif /* NO_SetRectRgn */
-
-#ifndef NO_SetScrollInfo
-JNIEXPORT jboolean JNICALL OS_NATIVE(SetScrollInfo)
- (JNIEnv *env, jclass that, jint arg0, jint arg1, jobject arg2, jboolean arg3)
-{
- SCROLLINFO _arg2, *lparg2=NULL;
- jboolean rc;
-
- DEBUG_CALL("SetScrollInfo\n")
-
- if (arg2) lparg2 = getSCROLLINFOFields(env, arg2, &_arg2);
- rc = (jboolean)SetScrollInfo((HWND)arg0, arg1, lparg2, arg3);
- if (arg2) setSCROLLINFOFields(env, arg2, lparg2);
- return rc;
-}
-#endif /* NO_SetScrollInfo */
-
-#ifndef NO_SetStretchBltMode
-JNIEXPORT jint JNICALL OS_NATIVE(SetStretchBltMode)
- (JNIEnv *env, jclass that, jint arg0, jint arg1)
-{
- DEBUG_CALL("SetStretchBltMode\n")
-
- return (jint)SetStretchBltMode((HDC)arg0, arg1);
-}
-#endif /* NO_SetStretchBltMode */
-
-#ifndef NO_SetTextAlign
-JNIEXPORT jint JNICALL OS_NATIVE(SetTextAlign)
- (JNIEnv *env, jclass that, jint arg0, jint arg1)
-{
- DEBUG_CALL("SetTextAlign\n")
-
- return (jint)SetTextAlign((HDC)arg0, arg1);
-}
-#endif /* NO_SetTextAlign */
-
-#ifndef NO_SetTextColor
-JNIEXPORT jint JNICALL OS_NATIVE(SetTextColor)
- (JNIEnv *env, jclass that, jint arg0, jint arg1)
-{
- DEBUG_CALL("SetTextColor\n")
-
- return (jint)SetTextColor((HDC)arg0, (COLORREF)arg1);
-}
-#endif /* NO_SetTextColor */
-
-#ifndef NO_SetTimer
-JNIEXPORT jint JNICALL OS_NATIVE(SetTimer)
- (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jint arg3)
-{
- DEBUG_CALL("SetTimer\n")
-
- return (jint)SetTimer((HWND)arg0, arg1, arg2, (TIMERPROC)arg3);
-}
-#endif /* NO_SetTimer */
-
-#ifndef NO_SetWindowLongA
-JNIEXPORT jint JNICALL OS_NATIVE(SetWindowLongA)
- (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2)
-{
- DEBUG_CALL("SetWindowLongA\n")
-
- return (jint)SetWindowLongA((HWND)arg0, arg1, arg2);
-}
-#endif /* NO_SetWindowLongA */
-
-#ifndef NO_SetWindowLongW
-JNIEXPORT jint JNICALL OS_NATIVE(SetWindowLongW)
- (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2)
-{
- DEBUG_CALL("SetWindowLongW\n")
-
- return (jint)SetWindowLongW((HWND)arg0, arg1, arg2);
-}
-#endif /* NO_SetWindowLongW */
-
-#ifndef NO_SetWindowPlacement
-JNIEXPORT jboolean JNICALL OS_NATIVE(SetWindowPlacement)
- (JNIEnv *env, jclass that, jint arg0, jobject arg1)
-{
- WINDOWPLACEMENT _arg1, *lparg1=NULL;
- jboolean rc;
-
- DEBUG_CALL("SetWindowPlacement\n")
-
- if (arg1) lparg1 = getWINDOWPLACEMENTFields(env, arg1, &_arg1);
- rc = (jboolean)SetWindowPlacement((HWND)arg0, lparg1);
- if (arg1) setWINDOWPLACEMENTFields(env, arg1, lparg1);
- return rc;
-}
-#endif /* NO_SetWindowPlacement */
-
-#ifndef NO_SetWindowPos
-JNIEXPORT jboolean JNICALL OS_NATIVE(SetWindowPos)
- (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jint arg3, jint arg4, jint arg5, jint arg6)
-{
- DEBUG_CALL("SetWindowPos\n")
-
- return (jboolean)SetWindowPos((HWND)arg0, (HWND)arg1, arg2, arg3, arg4, arg5, arg6);
-}
-#endif /* NO_SetWindowPos */
-
-#ifndef NO_SetWindowTextA
-JNIEXPORT jboolean JNICALL OS_NATIVE(SetWindowTextA)
- (JNIEnv *env, jclass that, jint arg0, jbyteArray arg1)
-{
- jbyte *lparg1=NULL;
- jboolean rc;
-
- DEBUG_CALL("SetWindowTextA\n")
-
- if (arg1) lparg1 = (*env)->GetByteArrayElements(env, arg1, NULL);
- rc = (jboolean)SetWindowTextA((HWND)arg0, (LPSTR)lparg1);
- if (arg1) (*env)->ReleaseByteArrayElements(env, arg1, lparg1, 0);
- return rc;
-}
-#endif /* NO_SetWindowTextA */
-
-#ifndef NO_SetWindowTextW
-JNIEXPORT jboolean JNICALL OS_NATIVE(SetWindowTextW)
- (JNIEnv *env, jclass that, jint arg0, jcharArray arg1)
-{
- jchar *lparg1=NULL;
- jboolean rc;
-
- DEBUG_CALL("SetWindowTextW\n")
-
- if (arg1) lparg1 = (*env)->GetCharArrayElements(env, arg1, NULL);
- rc = (jboolean)SetWindowTextW((HWND)arg0, (LPWSTR)lparg1);
- if (arg1) (*env)->ReleaseCharArrayElements(env, arg1, lparg1, 0);
- return rc;
-}
-#endif /* NO_SetWindowTextW */
-
-#ifndef NO_SetWindowsHookExA
-JNIEXPORT jint JNICALL OS_NATIVE(SetWindowsHookExA)
- (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jint arg3)
-{
- DEBUG_CALL("SetWindowsHookExA\n")
-
- return (jint)SetWindowsHookExA(arg0, (HOOKPROC)arg1, (HINSTANCE)arg2, arg3);
-}
-#endif /* NO_SetWindowsHookExA */
-
-#ifndef NO_SetWindowsHookExW
-JNIEXPORT jint JNICALL OS_NATIVE(SetWindowsHookExW)
- (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jint arg3)
-{
- DEBUG_CALL("SetWindowsHookExW\n")
-
- return (jint)SetWindowsHookExW(arg0, (HOOKPROC)arg1, (HINSTANCE)arg2, arg3);
-}
-#endif /* NO_SetWindowsHookExW */
-
-#ifndef NO_ShellExecuteExA
-JNIEXPORT jboolean JNICALL OS_NATIVE(ShellExecuteExA)
- (JNIEnv *env, jclass that, jobject arg0)
-{
- SHELLEXECUTEINFO _arg0, *lparg0=NULL;
- jboolean rc;
-
- DEBUG_CALL("ShellExecuteExA\n")
-
- if (arg0) lparg0 = getSHELLEXECUTEINFOFields(env, arg0, &_arg0);
- rc = (jboolean)ShellExecuteExA(lparg0);
- if (arg0) setSHELLEXECUTEINFOFields(env, arg0, lparg0);
- return rc;
-}
-#endif /* NO_ShellExecuteExA */
-
-#ifndef NO_ShellExecuteExW
-JNIEXPORT jboolean JNICALL OS_NATIVE(ShellExecuteExW)
- (JNIEnv *env, jclass that, jobject arg0)
-{
- SHELLEXECUTEINFO _arg0, *lparg0=NULL;
- jboolean rc;
-
- DEBUG_CALL("ShellExecuteExW\n")
-
- if (arg0) lparg0 = getSHELLEXECUTEINFOFields(env, arg0, &_arg0);
- rc = (jboolean)ShellExecuteExW((LPSHELLEXECUTEINFOW)lparg0);
- if (arg0) setSHELLEXECUTEINFOFields(env, arg0, lparg0);
- return rc;
-}
-#endif /* NO_ShellExecuteExW */
-
-#ifndef NO_ShowCaret
-JNIEXPORT jboolean JNICALL OS_NATIVE(ShowCaret)
- (JNIEnv *env, jclass that, jint arg0)
-{
- DEBUG_CALL("ShowCaret\n")
-
- return (jboolean)ShowCaret((HWND)arg0);
-}
-#endif /* NO_ShowCaret */
-
-#ifndef NO_ShowOwnedPopups
-JNIEXPORT jboolean JNICALL OS_NATIVE(ShowOwnedPopups)
- (JNIEnv *env, jclass that, jint arg0, jboolean arg1)
-{
- DEBUG_CALL("ShowOwnedPopups\n")
-
- return (jboolean)ShowOwnedPopups((HWND)arg0, arg1);
-}
-#endif /* NO_ShowOwnedPopups */
-
-#ifndef NO_ShowScrollBar
-JNIEXPORT jboolean JNICALL OS_NATIVE(ShowScrollBar)
- (JNIEnv *env, jclass that, jint arg0, jint arg1, jboolean arg2)
-{
- DEBUG_CALL("ShowScrollBar\n")
-
- return (jboolean)ShowScrollBar((HWND)arg0, arg1, arg2);
-}
-#endif /* NO_ShowScrollBar */
-
-#ifndef NO_ShowWindow
-JNIEXPORT jboolean JNICALL OS_NATIVE(ShowWindow)
- (JNIEnv *env, jclass that, jint arg0, jint arg1)
-{
- DEBUG_CALL("ShowWindow\n")
-
- return (jboolean)ShowWindow((HWND)arg0, arg1);
-}
-#endif /* NO_ShowWindow */
-
-#ifndef NO_SipGetInfo
-JNIEXPORT jboolean JNICALL OS_NATIVE(SipGetInfo)
- (JNIEnv *env, jclass that, jobject arg0)
-{
- SIPINFO _arg0, *lparg0=NULL;
- jboolean rc;
-
- DEBUG_CALL("SipGetInfo\n")
-
- if (arg0) lparg0 = getSIPINFOFields(env, arg0, &_arg0);
- rc = (jboolean)SipGetInfo(lparg0);
- if (arg0) setSIPINFOFields(env, arg0, lparg0);
- return rc;
-}
-#endif /* NO_SipGetInfo */
-
-#ifndef NO_StartDocA
-JNIEXPORT jint JNICALL OS_NATIVE(StartDocA)
- (JNIEnv *env, jclass that, jint arg0, jobject arg1)
-{
- DOCINFO _arg1, *lparg1=NULL;
- jint rc;
-
- DEBUG_CALL("StartDocA\n")
-
- if (arg1) lparg1 = getDOCINFOFields(env, arg1, &_arg1);
- rc = (jint)StartDocA((HDC)arg0, lparg1);
- if (arg1) setDOCINFOFields(env, arg1, lparg1);
- return rc;
-}
-#endif /* NO_StartDocA */
-
-#ifndef NO_StartDocW
-JNIEXPORT jint JNICALL OS_NATIVE(StartDocW)
- (JNIEnv *env, jclass that, jint arg0, jobject arg1)
-{
- DOCINFO _arg1, *lparg1=NULL;
- jint rc;
-
- DEBUG_CALL("StartDocW\n")
-
- if (arg1) lparg1 = getDOCINFOFields(env, arg1, &_arg1);
- rc = (jint)StartDocW((HDC)arg0, (LPDOCINFOW)lparg1);
- if (arg1) setDOCINFOFields(env, arg1, lparg1);
- return rc;
-}
-#endif /* NO_StartDocW */
-
-#ifndef NO_StartPage
-JNIEXPORT jint JNICALL OS_NATIVE(StartPage)
- (JNIEnv *env, jclass that, jint arg0)
-{
- DEBUG_CALL("StartPage\n")
-
- return (jint)StartPage((HDC)arg0);
-}
-#endif /* NO_StartPage */
-
-#ifndef NO_StretchBlt
-JNIEXPORT jboolean JNICALL OS_NATIVE(StretchBlt)
- (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jint arg3, jint arg4, jint arg5, jint arg6, jint arg7, jint arg8, jint arg9, jint arg10)
-{
- DEBUG_CALL("StretchBlt\n")
-
- return (jboolean)StretchBlt((HDC)arg0, arg1, arg2, arg3, arg4, (HDC)arg5, arg6, arg7, arg8, arg9, arg10);
-}
-#endif /* NO_StretchBlt */
-
-#ifndef NO_SystemParametersInfoA__II_3II
-JNIEXPORT jboolean JNICALL OS_NATIVE(SystemParametersInfoA__II_3II)
- (JNIEnv *env, jclass that, jint arg0, jint arg1, jintArray arg2, jint arg3)
-{
- jint *lparg2=NULL;
- jboolean rc;
-
- DEBUG_CALL("SystemParametersInfoA__II_3II\n")
-
- if (arg2) lparg2 = (*env)->GetIntArrayElements(env, arg2, NULL);
- rc = (jboolean)SystemParametersInfoA(arg0, arg1, lparg2, arg3);
- if (arg2) (*env)->ReleaseIntArrayElements(env, arg2, lparg2, 0);
- return rc;
-}
-#endif /* NO_SystemParametersInfoA__II_3II */
-
-#ifndef NO_SystemParametersInfoA__IILorg_eclipse_swt_internal_win32_RECT_2I
-JNIEXPORT jboolean JNICALL OS_NATIVE(SystemParametersInfoA__IILorg_eclipse_swt_internal_win32_RECT_2I)
- (JNIEnv *env, jclass that, jint arg0, jint arg1, jobject arg2, jint arg3)
-{
- RECT _arg2, *lparg2=NULL;
- jboolean rc;
-
- DEBUG_CALL("SystemParametersInfoA__IILorg_eclipse_swt_internal_win32_RECT_2I\n")
-
- if (arg2) lparg2 = getRECTFields(env, arg2, &_arg2);
- rc = (jboolean)SystemParametersInfoA(arg0, arg1, lparg2, arg3);
- if (arg2) setRECTFields(env, arg2, lparg2);
- return rc;
-}
-#endif /* NO_SystemParametersInfoA__IILorg_eclipse_swt_internal_win32_RECT_2I */
-
-#ifndef NO_SystemParametersInfoA__IILorg_eclipse_swt_internal_win32_NONCLIENTMETRICS_2I
-JNIEXPORT jboolean JNICALL OS_NATIVE(SystemParametersInfoA__IILorg_eclipse_swt_internal_win32_NONCLIENTMETRICS_2I)
- (JNIEnv *env, jclass that, jint arg0, jint arg1, jobject arg2, jint arg3)
-{
- NONCLIENTMETRICSA _arg2, *lparg2=NULL;
- jboolean rc;
-
- DEBUG_CALL("SystemParametersInfoA__IILorg_eclipse_swt_internal_win32_NONCLIENTMETRICS_2I\n")
-
- if (arg2) lparg2 = getNONCLIENTMETRICSAFields(env, arg2, &_arg2);
- rc = (jboolean)SystemParametersInfoA(arg0, arg1, lparg2, arg3);
- if (arg2) setNONCLIENTMETRICSAFields(env, arg2, lparg2);
- return rc;
-}
-#endif /* NO_SystemParametersInfoA__IILorg_eclipse_swt_internal_win32_NONCLIENTMETRICS_2I */
-
-#ifndef NO_SystemParametersInfoW__IILorg_eclipse_swt_internal_win32_NONCLIENTMETRICS_2I
-JNIEXPORT jboolean JNICALL OS_NATIVE(SystemParametersInfoW__IILorg_eclipse_swt_internal_win32_NONCLIENTMETRICS_2I)
- (JNIEnv *env, jclass that, jint arg0, jint arg1, jobject arg2, jint arg3)
-{
- NONCLIENTMETRICSW _arg2, *lparg2=NULL;
- jboolean rc;
-
- DEBUG_CALL("SystemParametersInfoW__IILorg_eclipse_swt_internal_win32_NONCLIENTMETRICS_2I\n")
-
- if (arg2) lparg2 = getNONCLIENTMETRICSWFields(env, arg2, &_arg2);
- rc = (jboolean)SystemParametersInfoW(arg0, arg1, lparg2, arg3);
- if (arg2) setNONCLIENTMETRICSWFields(env, arg2, lparg2);
- return rc;
-}
-#endif /* NO_SystemParametersInfoW__IILorg_eclipse_swt_internal_win32_NONCLIENTMETRICS_2I */
-
-#ifndef NO_SystemParametersInfoW__II_3II
-JNIEXPORT jboolean JNICALL OS_NATIVE(SystemParametersInfoW__II_3II)
- (JNIEnv *env, jclass that, jint arg0, jint arg1, jintArray arg2, jint arg3)
-{
- jint *lparg2=NULL;
- jboolean rc;
-
- DEBUG_CALL("SystemParametersInfoW__II_3II\n")
-
- if (arg2) lparg2 = (*env)->GetIntArrayElements(env, arg2, NULL);
- rc = (jboolean)SystemParametersInfoW(arg0, arg1, lparg2, arg3);
- if (arg2) (*env)->ReleaseIntArrayElements(env, arg2, lparg2, 0);
- return rc;
-}
-#endif /* NO_SystemParametersInfoW__II_3II */
-
-#ifndef NO_SystemParametersInfoW__IILorg_eclipse_swt_internal_win32_RECT_2I
-JNIEXPORT jboolean JNICALL OS_NATIVE(SystemParametersInfoW__IILorg_eclipse_swt_internal_win32_RECT_2I)
- (JNIEnv *env, jclass that, jint arg0, jint arg1, jobject arg2, jint arg3)
-{
- RECT _arg2, *lparg2=NULL;
- jboolean rc;
-
- DEBUG_CALL("SystemParametersInfoW__IILorg_eclipse_swt_internal_win32_RECT_2I\n")
-
- if (arg2) lparg2 = getRECTFields(env, arg2, &_arg2);
- rc = (jboolean)SystemParametersInfoW(arg0, arg1, lparg2, arg3);
- if (arg2) setRECTFields(env, arg2, lparg2);
- return rc;
-}
-#endif /* NO_SystemParametersInfoW__IILorg_eclipse_swt_internal_win32_RECT_2I */
-
-#ifndef NO_ToAscii
-JNIEXPORT jint JNICALL OS_NATIVE(ToAscii)
- (JNIEnv *env, jclass that, jint arg0, jint arg1, jbyteArray arg2, jshortArray arg3, jint arg4)
-{
- jbyte *lparg2=NULL;
- jshort *lparg3=NULL;
- jint rc;
-
- DEBUG_CALL("ToAscii\n")
-
- if (arg2) lparg2 = (*env)->GetByteArrayElements(env, arg2, NULL);
- if (arg3) lparg3 = (*env)->GetShortArrayElements(env, arg3, NULL);
- rc = (jint)ToAscii(arg0, arg1, (PBYTE)lparg2, (LPWORD)lparg3, arg4);
- if (arg2) (*env)->ReleaseByteArrayElements(env, arg2, lparg2, 0);
- if (arg3) (*env)->ReleaseShortArrayElements(env, arg3, lparg3, 0);
- return rc;
-}
-#endif /* NO_ToAscii */
-
-#ifndef NO_ToUnicode
-JNIEXPORT jint JNICALL OS_NATIVE(ToUnicode)
- (JNIEnv *env, jclass that, jint arg0, jint arg1, jbyteArray arg2, jcharArray arg3, jint arg4, jint arg5)
-{
- jbyte *lparg2=NULL;
- jchar *lparg3=NULL;
- jint rc;
-
- DEBUG_CALL("ToUnicode\n")
-
- if (arg2) lparg2 = (*env)->GetByteArrayElements(env, arg2, NULL);
- if (arg3) lparg3 = (*env)->GetCharArrayElements(env, arg3, NULL);
- rc = (jint)ToUnicode(arg0, arg1, (PBYTE)lparg2, (LPWSTR)lparg3, arg4, arg5);
- if (arg2) (*env)->ReleaseByteArrayElements(env, arg2, lparg2, 0);
- if (arg3) (*env)->ReleaseCharArrayElements(env, arg3, lparg3, 0);
- return rc;
-}
-#endif /* NO_ToUnicode */
-
-#ifndef NO_TrackMouseEvent
-JNIEXPORT jboolean JNICALL OS_NATIVE(TrackMouseEvent)
- (JNIEnv *env, jclass that, jobject arg0)
-{
- TRACKMOUSEEVENT _arg0, *lparg0=NULL;
- jboolean rc;
-
- DEBUG_CALL("TrackMouseEvent\n")
-
- if (arg0) lparg0 = getTRACKMOUSEEVENTFields(env, arg0, &_arg0);
- rc = (jboolean)_TrackMouseEvent(lparg0);
- if (arg0) setTRACKMOUSEEVENTFields(env, arg0, lparg0);
- return rc;
-}
-#endif /* NO_TrackMouseEvent */
-
-#ifndef NO_TrackPopupMenu
-JNIEXPORT jboolean JNICALL OS_NATIVE(TrackPopupMenu)
- (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jint arg3, jint arg4, jint arg5, jobject arg6)
-{
- RECT _arg6, *lparg6=NULL;
- jboolean rc;
-
- DEBUG_CALL("TrackPopupMenu\n")
-
- if (arg6) lparg6 = getRECTFields(env, arg6, &_arg6);
- rc = (jboolean)TrackPopupMenu((HMENU)arg0, arg1, arg2, arg3, arg4, (HWND)arg5, lparg6);
- if (arg6) setRECTFields(env, arg6, lparg6);
- return rc;
-}
-#endif /* NO_TrackPopupMenu */
-
-#ifndef NO_TranslateAcceleratorA
-JNIEXPORT jint JNICALL OS_NATIVE(TranslateAcceleratorA)
- (JNIEnv *env, jclass that, jint arg0, jint arg1, jobject arg2)
-{
- MSG _arg2, *lparg2=NULL;
- jint rc;
-
- DEBUG_CALL("TranslateAcceleratorA\n")
-
- if (arg2) lparg2 = getMSGFields(env, arg2, &_arg2);
- rc = (jint)TranslateAcceleratorA((HWND)arg0, (HACCEL)arg1, lparg2);
- if (arg2) setMSGFields(env, arg2, lparg2);
- return rc;
-}
-#endif /* NO_TranslateAcceleratorA */
-
-#ifndef NO_TranslateAcceleratorW
-JNIEXPORT jint JNICALL OS_NATIVE(TranslateAcceleratorW)
- (JNIEnv *env, jclass that, jint arg0, jint arg1, jobject arg2)
-{
- MSG _arg2, *lparg2=NULL;
- jint rc;
-
- DEBUG_CALL("TranslateAcceleratorW\n")
-
- if (arg2) lparg2 = getMSGFields(env, arg2, &_arg2);
- rc = (jint)TranslateAcceleratorW((HWND)arg0, (HACCEL)arg1, lparg2);
- if (arg2) setMSGFields(env, arg2, lparg2);
- return rc;
-}
-#endif /* NO_TranslateAcceleratorW */
-
-#ifndef NO_TranslateCharsetInfo
-JNIEXPORT jboolean JNICALL OS_NATIVE(TranslateCharsetInfo)
- (JNIEnv *env, jclass that, jint arg0, jintArray arg1, jint arg2)
-{
- jint *lparg1=NULL;
- jboolean rc;
-
- DEBUG_CALL("TranslateCharsetInfo\n")
-
- if (arg1) lparg1 = (*env)->GetIntArrayElements(env, arg1, NULL);
- rc = (jboolean)TranslateCharsetInfo((DWORD *)arg0, (LPCHARSETINFO)lparg1, arg2);
- if (arg1) (*env)->ReleaseIntArrayElements(env, arg1, lparg1, 0);
- return rc;
-}
-#endif /* NO_TranslateCharsetInfo */
-
-#ifndef NO_TranslateMessage
-JNIEXPORT jboolean JNICALL OS_NATIVE(TranslateMessage)
- (JNIEnv *env, jclass that, jobject arg0)
-{
- MSG _arg0, *lparg0=NULL;
- jboolean rc;
-
- DEBUG_CALL("TranslateMessage\n")
-
- if (arg0) lparg0 = getMSGFields(env, arg0, &_arg0);
- rc = (jboolean)TranslateMessage(lparg0);
- if (arg0) setMSGFields(env, arg0, lparg0);
- return rc;
-}
-#endif /* NO_TranslateMessage */
-
-#ifndef NO_TransparentImage
-JNIEXPORT jboolean JNICALL OS_NATIVE(TransparentImage)
- (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jint arg3, jint arg4, jint arg5, jint arg6, jint arg7, jint arg8, jint arg9, jint arg10)
-{
- DEBUG_CALL("TransparentImage\n")
-
- return (jboolean)TransparentImage((HDC)arg0, arg1, arg2, arg3, arg4, (HANDLE)arg5, arg6, arg7, arg8, arg9, (COLORREF)arg10);
-}
-#endif /* NO_TransparentImage */
-
-#ifndef NO_UnhookWindowsHookEx
-JNIEXPORT jboolean JNICALL OS_NATIVE(UnhookWindowsHookEx)
- (JNIEnv *env, jclass that, jint arg0)
-{
- DEBUG_CALL("UnhookWindowsHookEx\n")
-
- return (jboolean)UnhookWindowsHookEx((HHOOK)arg0);
-}
-#endif /* NO_UnhookWindowsHookEx */
-
-#ifndef NO_UnregisterClassA
-JNIEXPORT jboolean JNICALL OS_NATIVE(UnregisterClassA)
- (JNIEnv *env, jclass that, jbyteArray arg0, jint arg1)
-{
- jbyte *lparg0=NULL;
- jboolean rc;
-
- DEBUG_CALL("UnregisterClassA\n")
-
- if (arg0) lparg0 = (*env)->GetByteArrayElements(env, arg0, NULL);
- rc = (jboolean)UnregisterClassA((LPSTR)lparg0, (HINSTANCE)arg1);
- if (arg0) (*env)->ReleaseByteArrayElements(env, arg0, lparg0, 0);
- return rc;
-}
-#endif /* NO_UnregisterClassA */
-
-#ifndef NO_UnregisterClassW
-JNIEXPORT jboolean JNICALL OS_NATIVE(UnregisterClassW)
- (JNIEnv *env, jclass that, jcharArray arg0, jint arg1)
-{
- jchar *lparg0=NULL;
- jboolean rc;
-
- DEBUG_CALL("UnregisterClassW\n")
-
- if (arg0) lparg0 = (*env)->GetCharArrayElements(env, arg0, NULL);
- rc = (jboolean)UnregisterClassW((LPWSTR)lparg0, (HINSTANCE)arg1);
- if (arg0) (*env)->ReleaseCharArrayElements(env, arg0, lparg0, 0);
- return rc;
-}
-#endif /* NO_UnregisterClassW */
-
-#ifndef NO_UpdateWindow
-JNIEXPORT jboolean JNICALL OS_NATIVE(UpdateWindow)
- (JNIEnv *env, jclass that, jint arg0)
-{
- DEBUG_CALL("UpdateWindow\n")
-
- return (jboolean)UpdateWindow((HWND)arg0);
-}
-#endif /* NO_UpdateWindow */
-
-#ifndef NO_ValidateRect
-JNIEXPORT jboolean JNICALL OS_NATIVE(ValidateRect)
- (JNIEnv *env, jclass that, jint arg0, jobject arg1)
-{
- RECT _arg1, *lparg1=NULL;
- jboolean rc;
-
- DEBUG_CALL("ValidateRect\n")
-
- if (arg1) lparg1 = getRECTFields(env, arg1, &_arg1);
- rc = (jboolean)ValidateRect((HWND)arg0, lparg1);
- if (arg1) setRECTFields(env, arg1, lparg1);
- return rc;
-}
-#endif /* NO_ValidateRect */
-
-#ifndef NO_VkKeyScanA
-JNIEXPORT jshort JNICALL OS_NATIVE(VkKeyScanA)
- (JNIEnv *env, jclass that, jshort arg0)
-{
- DEBUG_CALL("VkKeyScanA\n")
-
- return (jshort)VkKeyScanA((TCHAR)arg0);
-}
-#endif /* NO_VkKeyScanA */
-
-#ifndef NO_VkKeyScanW
-JNIEXPORT jshort JNICALL OS_NATIVE(VkKeyScanW)
- (JNIEnv *env, jclass that, jshort arg0)
-{
- DEBUG_CALL("VkKeyScanW\n")
-
- return (jshort)VkKeyScanW((WCHAR)arg0);
-}
-#endif /* NO_VkKeyScanW */
-
-#ifndef NO_VtblCall
-JNIEXPORT jint JNICALL OS_NATIVE(VtblCall)
- (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2)
-{
- P_OLE_FN_2 fn;
-
- DEBUG_CALL("VtblCall\n")
-
- fn = (P_OLE_FN_2)(*(int **)arg1)[arg0];
-
- return fn(arg1, arg2);
-}
-#endif /* NO_VtblCall */
-
-#ifndef NO_WaitMessage
-JNIEXPORT jboolean JNICALL OS_NATIVE(WaitMessage)
- (JNIEnv *env, jclass that)
-{
- DEBUG_CALL("WaitMessage\n")
-
- return (jboolean)WaitMessage();
-}
-#endif /* NO_WaitMessage */
-
-#ifndef NO_WideCharToMultiByte__II_3CI_3BI_3B_3Z
-JNIEXPORT jint JNICALL OS_NATIVE(WideCharToMultiByte__II_3CI_3BI_3B_3Z)
- (JNIEnv *env, jclass that, jint arg0, jint arg1, jcharArray arg2, jint arg3, jbyteArray arg4, jint arg5, jbyteArray arg6, jbooleanArray arg7)
-{
- jchar *lparg2=NULL;
- jbyte *lparg4=NULL;
- jbyte *lparg6=NULL;
- jboolean *lparg7=NULL;
- jint rc;
-
- DEBUG_CALL("WideCharToMultiByte__II_3CI_3BI_3B_3Z\n")
-
- if (arg2) lparg2 = (*env)->GetCharArrayElements(env, arg2, NULL);
- if (arg4) lparg4 = (*env)->GetByteArrayElements(env, arg4, NULL);
- if (arg6) lparg6 = (*env)->GetByteArrayElements(env, arg6, NULL);
- if (arg7) lparg7 = (*env)->GetBooleanArrayElements(env, arg7, NULL);
- rc = (jint)WideCharToMultiByte(arg0, arg1, (LPCWSTR)lparg2, arg3, (LPSTR)lparg4, arg5, (LPCSTR)lparg6, (LPBOOL)lparg7);
- if (arg2) (*env)->ReleaseCharArrayElements(env, arg2, lparg2, 0);
- if (arg4) (*env)->ReleaseByteArrayElements(env, arg4, lparg4, 0);
- if (arg6) (*env)->ReleaseByteArrayElements(env, arg6, lparg6, 0);
- if (arg7) (*env)->ReleaseBooleanArrayElements(env, arg7, lparg7, 0);
- return rc;
-}
-#endif /* NO_WideCharToMultiByte__II_3CI_3BI_3B_3Z */
-
-#ifndef NO_WideCharToMultiByte__II_3CIII_3B_3Z
-JNIEXPORT jint JNICALL OS_NATIVE(WideCharToMultiByte__II_3CIII_3B_3Z)
- (JNIEnv *env, jclass that, jint arg0, jint arg1, jcharArray arg2, jint arg3, jint arg4, jint arg5, jbyteArray arg6, jbooleanArray arg7)
-{
- jchar *lparg2=NULL;
- jbyte *lparg6=NULL;
- jboolean *lparg7=NULL;
- jint rc;
-
- DEBUG_CALL("WideCharToMultiByte__II_3CIII_3B_3Z\n")
-
- if (arg2) lparg2 = (*env)->GetCharArrayElements(env, arg2, NULL);
- if (arg6) lparg6 = (*env)->GetByteArrayElements(env, arg6, NULL);
- if (arg7) lparg7 = (*env)->GetBooleanArrayElements(env, arg7, NULL);
- rc = (jint)WideCharToMultiByte(arg0, arg1, (LPCWSTR)lparg2, arg3, (LPSTR)arg4, arg5, (LPCSTR)lparg6, (LPBOOL)lparg7);
- if (arg2) (*env)->ReleaseCharArrayElements(env, arg2, lparg2, 0);
- if (arg6) (*env)->ReleaseByteArrayElements(env, arg6, lparg6, 0);
- if (arg7) (*env)->ReleaseBooleanArrayElements(env, arg7, lparg7, 0);
- return rc;
-}
-#endif /* NO_WideCharToMultiByte__II_3CIII_3B_3Z */
-
-#ifndef NO_WindowFromDC
-JNIEXPORT jint JNICALL OS_NATIVE(WindowFromDC)
- (JNIEnv *env, jclass that, jint arg0)
-{
- DEBUG_CALL("WindowFromDC\n")
-
- return (jint)WindowFromDC((HDC)arg0);
-}
-#endif /* NO_WindowFromDC */
-
-#ifndef NO_WindowFromPoint
-JNIEXPORT jint JNICALL OS_NATIVE(WindowFromPoint)
- (JNIEnv *env, jclass that, jobject arg0)
-{
- POINT _arg0, *lparg0=NULL;
- jint rc;
-
- DEBUG_CALL("WindowFromPoint\n")
-
- if (arg0) lparg0 = getPOINTFields(env, arg0, &_arg0);
- rc = (jint)WindowFromPoint(*lparg0);
- if (arg0) setPOINTFields(env, arg0, lparg0);
- return rc;
-}
-#endif /* NO_WindowFromPoint */
-
+/*
+ * Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
+ * This file is made available under the terms of the Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+/**
+ * SWT OS natives implementation.
+ */
+
+#include "swt.h"
+#include "structs.h"
+
+#ifdef _WIN32_WCE
+#define NO_AbortDoc
+#define NO_ActivateKeyboardLayout
+#define NO_Arc
+#define NO_CallNextHookEx
+#define NO_CallWindowProcA
+#define NO_CharLowerA
+#define NO_CharUpperA
+#define NO_ChooseColorA
+#define NO_ChooseFontA
+#define NO_ChooseFontW
+#define NO_CopyImage
+#define NO_CreateAcceleratorTableA
+#define NO_CreateCursor
+#define NO_CreateDCA
+#define NO_CreateFontIndirectA__Lorg_eclipse_swt_internal_win32_LOGFONT_2
+#define NO_CreateFontIndirectA__I
+#define NO_CreateWindowExA
+#define NO_DefWindowProcA
+#define NO_DestroyCursor
+#define NO_DispatchMessageA
+#define NO_DragDetect
+#define NO_DragFinish
+#define NO_DragQueryFileA
+#define NO_DragQueryFileW
+#define NO_DrawStateA
+#define NO_DrawStateW
+#define NO_DrawTextA
+#define NO_EnableScrollBar
+#define NO_EndDoc
+#define NO_EndPage
+#define NO_EnumFontFamiliesA
+#define NO_EnumSystemLanguageGroupsA
+#define NO_EnumSystemLanguageGroupsW
+#define NO_EnumSystemLocalesA
+#define NO_ExpandEnvironmentStringsW
+#define NO_ExpandEnvironmentStringsA
+#define NO_ExtTextOutA
+#define NO_ExtractIconExA
+#define NO_FindWindowA
+#define NO_GetCharABCWidthsA
+#define NO_GetCharABCWidthsW
+#define NO_GetCharWidthA
+#define NO_GetCharWidthW
+#define NO_GetCharacterPlacementA
+#define NO_GetCharacterPlacementW
+#define NO_GetClassInfoA
+#define NO_GetClipboardFormatNameA
+#define NO_GetDIBColorTable
+#define NO_GetDIBits
+#define NO_GetFontLanguageInfo
+#define NO_GetIconInfo
+#define NO_GetKeyboardLayout
+#define NO_GetKeyboardLayoutList
+#define NO_GetKeyboardState
+#define NO_GetKeyNameTextA
+#define NO_GetKeyNameTextW
+#define NO_GetLastActivePopup
+#define NO_GetLocaleInfoA
+#define NO_GetMenu
+#define NO_GetMenuDefaultItem
+#define NO_GetMenuInfo
+#define NO_GetMenuItemCount
+#define NO_GetMenuItemInfoA
+#define NO_GetMessageA
+#define NO_GetMessageTime
+#define NO_GetModuleHandleA
+#define NO_GetObjectA__IILorg_eclipse_swt_internal_win32_LOGPEN_2
+#define NO_GetObjectA__IILorg_eclipse_swt_internal_win32_LOGFONT_2
+#define NO_GetObjectA__IILorg_eclipse_swt_internal_win32_LOGBRUSH_2
+#define NO_GetObjectA__IILorg_eclipse_swt_internal_win32_DIBSECTION_2
+#define NO_GetObjectA__IILorg_eclipse_swt_internal_win32_BITMAP_2
+#define NO_GetOpenFileNameA
+#define NO_GetProfileStringA
+#define NO_GetProfileStringW
+#define NO_GetROP2
+#define NO_GetSaveFileNameA
+#define NO_GetTextCharset
+#define NO_GetTextExtentPoint32A
+#define NO_GetTextMetricsA
+#define NO_GetVersionExA
+#define NO_GetWindowLongA
+#define NO_GetWindowPlacement
+#define NO_GetWindowTextA
+#define NO_GetWindowTextLengthA
+#define NO_GradientFill
+#define NO_ImmGetCompositionFontA
+#define NO_ImmGetCompositionStringA
+#define NO_ImmSetCompositionFontA
+#define NO_InsertMenuA
+#define NO_InsertMenuItemA
+#define NO_InsertMenuItemW
+#define NO_InvalidateRgn
+#define NO_IsIconic
+#define NO_IsZoomed
+#define NO_LineTo
+#define NO_LoadBitmapA
+#define NO_LoadCursorA
+#define NO_LoadIconA
+#define NO_LoadImageA
+#define NO_LoadLibraryA
+#define NO_MapVirtualKeyA
+#define NO_MessageBoxA
+#define NO_MoveMemory__ILorg_eclipse_swt_internal_win32_DROPFILES_2I
+#define NO_MoveMemory__Lorg_eclipse_swt_internal_win32_NMREBARCHEVRON_2II
+#define NO_MoveMemory__Lorg_eclipse_swt_internal_win32_HELPINFO_2II
+#define NO_MoveMemory__ILorg_eclipse_swt_internal_win32_TRIVERTEX_2I
+#define NO_MoveMemory__ILorg_eclipse_swt_internal_win32_GRADIENT_1RECT_2I
+#define NO_MoveMemoryA__Lorg_eclipse_swt_internal_win32_NMTTDISPINFO_2II
+#define NO_MoveMemoryW__Lorg_eclipse_swt_internal_win32_NMTTDISPINFO_2II
+#define NO_MoveMemoryA__ILorg_eclipse_swt_internal_win32_NMTTDISPINFO_2I
+#define NO_MoveMemoryW__ILorg_eclipse_swt_internal_win32_NMTTDISPINFO_2I
+#define NO_MoveMemoryA__Lorg_eclipse_swt_internal_win32_LOGFONT_2II
+#define NO_MoveMemoryA__ILorg_eclipse_swt_internal_win32_LOGFONT_2I
+#define NO_MoveToEx
+#define NO_OleInitialize
+#define NO_OleUninitialize
+#define NO_PeekMessageA
+#define NO_Pie
+#define NO_PostMessageA
+#define NO_PostThreadMessageA
+#define NO_PrintDlgA
+#define NO_PrintDlgW
+#define NO_RedrawWindow
+#define NO_RegEnumKeyExA
+#define NO_RegOpenKeyExA
+#define NO_RegQueryInfoKeyA
+#define NO_RegQueryValueExA
+#define NO_RegisterClassA
+#define NO_RegisterClipboardFormatA
+#define NO_SetLayout
+#define NO_SHBrowseForFolderA
+#define NO_SHBrowseForFolderW
+#define NO_SHGetPathFromIDListA
+#define NO_SHGetPathFromIDListW
+#define NO_SendMessageA__IIILorg_eclipse_swt_internal_win32_TVITEM_2
+#define NO_SendMessageA__IIILorg_eclipse_swt_internal_win32_TVINSERTSTRUCT_2
+#define NO_SendMessageA__IIILorg_eclipse_swt_internal_win32_TVHITTESTINFO_2
+#define NO_SendMessageA__IIILorg_eclipse_swt_internal_win32_TOOLINFO_2
+#define NO_SendMessageA__IIILorg_eclipse_swt_internal_win32_TCITEM_2
+#define NO_SendMessageA__IIILorg_eclipse_swt_internal_win32_TBBUTTONINFO_2
+#define NO_SendMessageA__IIILorg_eclipse_swt_internal_win32_TBBUTTON_2
+#define NO_SendMessageA__IIILorg_eclipse_swt_internal_win32_RECT_2
+#define NO_SendMessageA__IIILorg_eclipse_swt_internal_win32_REBARBANDINFO_2
+#define NO_SendMessageA__IIILorg_eclipse_swt_internal_win32_LVITEM_2
+#define NO_SendMessageA__IIILorg_eclipse_swt_internal_win32_LVHITTESTINFO_2
+#define NO_SendMessageA__IIILorg_eclipse_swt_internal_win32_LVCOLUMN_2
+#define NO_SendMessageA__IIII
+#define NO_SendMessageA__III_3S
+#define NO_SendMessageA__III_3I
+#define NO_SendMessageA__III_3B
+#define NO_SendMessageA__II_3II
+#define NO_SendMessageA__II_3I_3I
+#define NO_SendMessageW__IIILorg_eclipse_swt_internal_win32_TOOLINFO_2
+#define NO_SetDIBColorTable
+#define NO_SetMenu
+#define NO_SetMenuDefaultItem
+#define NO_SetMenuInfo
+#define NO_SetMenuItemInfoA
+#define NO_SetStretchBltMode
+#define NO_SetTextAlign
+#define NO_SetWindowLongA
+#define NO_SetWindowPlacement
+#define NO_SetWindowTextA
+#define NO_SetWindowsHookExA
+#define NO_SetWindowsHookExW
+#define NO_ShellExecuteExA
+#define NO_ShowOwnedPopups
+#define NO_ShowScrollBar
+#define NO_StartDocA
+#define NO_StartDocW
+#define NO_StartPage
+#define NO_SystemParametersInfoA__IILorg_eclipse_swt_internal_win32_RECT_2I
+#define NO_SystemParametersInfoA__IILorg_eclipse_swt_internal_win32_NONCLIENTMETRICS_2I
+#define NO_SystemParametersInfoA__II_3II
+#define NO_SystemParametersInfoW__IILorg_eclipse_swt_internal_win32_NONCLIENTMETRICS_2I
+#define NO_ToAscii
+#define NO_ToUnicode
+#define NO_TrackMouseEvent
+#define NO_TranslateAcceleratorA
+#define NO_UnhookWindowsHookEx
+#define NO_UnregisterClassA
+#define NO_VkKeyScanA
+#define NO_VkKeyScanW
+#define NO_WaitMessage
+#define NO_WindowFromDC
+
+#define ChooseColorW ChooseColor
+#define CHOOSECOLORW CHOOSECOLOR
+#define LPCHOOSECOLORW LPCHOOSECOLOR
+#define FONTENUMPROCW FONTENUMPROC
+#define ShellExecuteExW ShellExecuteEx
+#define LPSHELLEXECUTEINFOW LPSHELLEXECUTEINFO
+#endif /* _WIN32_WCE */
+
+#ifndef WIN32_PLATFORM_HPC2000
+#define NO_CommandBar_1AddAdornments
+#define NO_CommandBar_1Create
+#define NO_CommandBar_1DrawMenuBar
+#define NO_CommandBar_1Height
+#define NO_CommandBar_1InsertMenubarEx
+#define NO_CommandBar_1Show
+#endif /* WIN32_PLATFORM_HPC2000 */
+
+#if !defined(WIN32_PLATFORM_PSPC) && !defined(WIN32_PLATFORM_WFSP)
+#define NO_SHCreateMenuBar
+#define NO_SHSetAppKeyWndAssoc
+#endif /* WIN32_PLATFORM_PSPC, WIN32_PLATFORM_WFSP */
+
+#ifdef WIN32_PLATFORM_WFSP
+#define NO_CommDlgExtendedError
+#define NO_ChooseColorW
+#endif /* WIN32_PLATFORM_WFSP */
+
+#ifndef WIN32_PLATFORM_PSPC
+#define NO_SHHandleWMSettingChange
+#define NO_SHRecognizeGesture
+#define NO_SHSipPreference
+#define NO_SipGetInfo
+#endif /* WIN32_PLATFORM_PSPC */
+
+#ifndef WIN32_PLATFORM_WFSP
+#define NO_SHSendBackToFocusWindow
+#endif /* WIN32_PLATFORM_WFSP */
+
+#ifndef _WIN32_WCE
+#define NO_CommandBar_1Destroy
+#define NO_TransparentImage
+#endif /* _WIN32_WCE */
+
+/* Export the dll version info call */
+
+__declspec(dllexport) HRESULT DllGetVersion(DLLVERSIONINFO *dvi);
+
+HRESULT DllGetVersion(DLLVERSIONINFO *dvi)
+{
+ dvi->dwMajorVersion = SWT_VERSION / 1000;
+ dvi->dwMinorVersion = SWT_VERSION % 1000;
+ dvi->dwBuildNumber = SWT_BUILD_NUM;
+ dvi->dwPlatformID = DLLVER_PLATFORM_WINDOWS;
+ return 1;
+}
+
+/* Cache the handle to the library */
+HINSTANCE g_hInstance = NULL;
+
+BOOL WINAPI DllMain(HANDLE hInstDLL, DWORD dwReason, LPVOID lpvReserved)
+{
+ if (dwReason == DLL_PROCESS_ATTACH) {
+ if (g_hInstance == NULL) g_hInstance = hInstDLL;
+ }
+ return TRUE;
+}
+
+/* Natives */
+
+#define OS_NATIVE(method) Java_org_eclipse_swt_internal_win32_OS_##method
+
+#ifndef NO_AbortDoc
+JNIEXPORT jint JNICALL OS_NATIVE(AbortDoc)
+ (JNIEnv *env, jclass that, jint arg0)
+{
+ DEBUG_CALL("AbortDoc\n")
+
+ return (jint)AbortDoc((HDC)arg0);
+}
+#endif /* NO_AbortDoc */
+#ifndef NO_ActivateKeyboardLayout
+JNIEXPORT jint JNICALL OS_NATIVE(ActivateKeyboardLayout)
+ (JNIEnv *env, jclass that, jint arg0, jint arg1)
+{
+ DEBUG_CALL("ActivateKeyboardLayout\n")
+
+ return (jint)ActivateKeyboardLayout((HKL)arg0, arg1);
+}
+#endif /* NO_ActivateKeyboardLayout */
+
+#ifndef NO_AdjustWindowRectEx
+JNIEXPORT jboolean JNICALL OS_NATIVE(AdjustWindowRectEx)
+ (JNIEnv *env, jclass that, jobject arg0, jint arg1, jboolean arg2, jint arg3)
+{
+ RECT _arg0, *lparg0=NULL;
+ jboolean rc;
+
+ DEBUG_CALL("AdjustWindowRectEx\n")
+
+ if (arg0) lparg0 = getRECTFields(env, arg0, &_arg0);
+ rc = (jboolean)AdjustWindowRectEx(lparg0, arg1, arg2, arg3);
+ if (arg0) setRECTFields(env, arg0, lparg0);
+ return rc;
+}
+#endif /* NO_AdjustWindowRectEx */
+
+#ifndef NO_Arc
+JNIEXPORT jboolean JNICALL OS_NATIVE(Arc)
+ (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jint arg3, jint arg4, jint arg5, jint arg6, jint arg7, jint arg8)
+{
+ DEBUG_CALL("Arc\n")
+
+ return (jboolean)Arc((HDC)arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8);
+}
+#endif /* NO_Arc */
+
+#ifndef NO_BeginDeferWindowPos
+JNIEXPORT jint JNICALL OS_NATIVE(BeginDeferWindowPos)
+ (JNIEnv *env, jclass that, jint arg0)
+{
+ DEBUG_CALL("BeginDeferWindowPos\n")
+
+ return (jint)BeginDeferWindowPos(arg0);
+}
+#endif /* NO_BeginDeferWindowPos */
+
+#ifndef NO_BeginPaint
+JNIEXPORT jint JNICALL OS_NATIVE(BeginPaint)
+ (JNIEnv *env, jclass that, jint arg0, jobject arg1)
+{
+ PAINTSTRUCT _arg1, *lparg1=NULL;
+ jint rc;
+
+ DEBUG_CALL("BeginPaint\n")
+
+ if (arg1) lparg1 = &_arg1;
+ rc = (jint)BeginPaint((HWND)arg0, lparg1);
+ if (arg1) setPAINTSTRUCTFields(env, arg1, lparg1);
+ return rc;
+}
+#endif /* NO_BeginPaint */
+
+#ifndef NO_BitBlt
+JNIEXPORT jboolean JNICALL OS_NATIVE(BitBlt)
+ (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jint arg3, jint arg4, jint arg5, jint arg6, jint arg7, jint arg8)
+{
+ DEBUG_CALL("BitBlt\n")
+
+ return (jboolean)BitBlt((HDC)arg0, arg1, arg2, arg3, arg4, (HDC)arg5, arg6, arg7, arg8);
+}
+#endif /* NO_BitBlt */
+
+#ifndef NO_BringWindowToTop
+JNIEXPORT jboolean JNICALL OS_NATIVE(BringWindowToTop)
+ (JNIEnv *env, jclass that, jint arg0)
+{
+ DEBUG_CALL("BringWindowToTop\n")
+
+ return (jboolean)BringWindowToTop((HWND)arg0);
+}
+#endif /* NO_BringWindowToTop */
+
+#ifndef NO_Call
+JNIEXPORT jint JNICALL OS_NATIVE(Call)
+ (JNIEnv *env, jclass that, jint arg0, jobject arg1)
+{
+ DLLVERSIONINFO _arg1, *lparg1=NULL;
+ jint rc;
+
+ DEBUG_CALL("Call\n")
+
+ if (arg1) lparg1 = getDLLVERSIONINFOFields(env, arg1, &_arg1);
+ rc = (jint)((DLLGETVERSIONPROC)arg0)(lparg1);
+ if (arg1) setDLLVERSIONINFOFields(env, arg1, lparg1);
+ return rc;
+}
+#endif /* NO_Call */
+
+#ifndef NO_CallNextHookEx
+JNIEXPORT jint JNICALL OS_NATIVE(CallNextHookEx)
+ (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jint arg3)
+{
+ DEBUG_CALL("CallNextHookEx\n")
+
+ return (jint)CallNextHookEx((HHOOK)arg0, arg1, (WPARAM)arg2, (LPARAM)arg3);
+}
+#endif /* NO_CallNextHookEx */
+
+#ifndef NO_CallWindowProcA
+JNIEXPORT jint JNICALL OS_NATIVE(CallWindowProcA)
+ (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jint arg3, jint arg4)
+{
+ DEBUG_CALL("CallWindowProcA\n")
+
+ return (jint)CallWindowProcA((WNDPROC)arg0, (HWND)arg1, arg2, arg3, arg4);
+}
+#endif /* NO_CallWindowProcA */
+
+#ifndef NO_CallWindowProcW
+JNIEXPORT jint JNICALL OS_NATIVE(CallWindowProcW)
+ (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jint arg3, jint arg4)
+{
+ DEBUG_CALL("CallWindowProcW\n")
+
+ return (jint)CallWindowProcW((WNDPROC)arg0, (HWND)arg1, arg2, arg3, arg4);
+}
+#endif /* NO_CallWindowProcW */
+
+#ifndef NO_CharLowerA
+JNIEXPORT jshort JNICALL OS_NATIVE(CharLowerA)
+ (JNIEnv *env, jclass that, jshort arg0)
+{
+ DEBUG_CALL("CharLowerA\n")
+
+ return (jshort)CharLowerA((LPSTR)arg0);
+}
+#endif /* NO_CharLowerA */
+
+#ifndef NO_CharLowerW
+JNIEXPORT jshort JNICALL OS_NATIVE(CharLowerW)
+ (JNIEnv *env, jclass that, jshort arg0)
+{
+ DEBUG_CALL("CharLowerW\n")
+
+ return (jshort)CharLowerW((LPWSTR)arg0);
+}
+#endif /* NO_CharLowerW */
+
+#ifndef NO_CharUpperA
+JNIEXPORT jshort JNICALL OS_NATIVE(CharUpperA)
+ (JNIEnv *env, jclass that, jshort arg0)
+{
+ DEBUG_CALL("CharUpperA\n")
+
+ return (jshort)CharUpperA((LPSTR)arg0);
+}
+#endif /* NO_CharUpperA */
+
+#ifndef NO_CharUpperW
+JNIEXPORT jshort JNICALL OS_NATIVE(CharUpperW)
+ (JNIEnv *env, jclass that, jshort arg0)
+{
+ DEBUG_CALL("CharUpperW\n")
+
+ return (jshort)CharUpperW((LPWSTR)arg0);
+}
+#endif /* NO_CharUpperW */
+
+#ifndef NO_CheckMenuItem
+JNIEXPORT jboolean JNICALL OS_NATIVE(CheckMenuItem)
+ (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2)
+{
+ DEBUG_CALL("CheckMenuItem\n")
+
+ return (jboolean)CheckMenuItem((HMENU)arg0, (UINT)arg1, (UINT)arg2);
+}
+#endif /* NO_CheckMenuItem */
+
+#ifndef NO_ChooseColorA
+JNIEXPORT jboolean JNICALL OS_NATIVE(ChooseColorA)
+ (JNIEnv *env, jclass that, jobject arg0)
+{
+ CHOOSECOLOR _arg0, *lparg0=NULL;
+ jboolean rc;
+
+ DEBUG_CALL("ChooseColorA\n")
+
+ if (arg0) lparg0 = getCHOOSECOLORFields(env, arg0, &_arg0);
+ rc = (jboolean)ChooseColorA(lparg0);
+ if (arg0) setCHOOSECOLORFields(env, arg0, lparg0);
+ return rc;
+}
+#endif /* NO_ChooseColorA */
+
+#ifndef NO_ChooseColorW
+JNIEXPORT jboolean JNICALL OS_NATIVE(ChooseColorW)
+ (JNIEnv *env, jclass that, jobject arg0)
+{
+ CHOOSECOLOR _arg0, *lparg0=NULL;
+ jboolean rc;
+
+ DEBUG_CALL("ChooseColorW\n")
+
+ if (arg0) lparg0 = getCHOOSECOLORFields(env, arg0, &_arg0);
+ rc = (jboolean)ChooseColorW((LPCHOOSECOLORW)lparg0);
+ if (arg0) setCHOOSECOLORFields(env, arg0, lparg0);
+ return rc;
+}
+#endif /* NO_ChooseColorW */
+
+#ifndef NO_ChooseFontA
+JNIEXPORT jboolean JNICALL OS_NATIVE(ChooseFontA)
+ (JNIEnv *env, jclass that, jobject arg0)
+{
+ CHOOSEFONT _arg0, *lparg0=NULL;
+ jboolean rc;
+
+ DEBUG_CALL("ChooseFontA\n")
+
+ if (arg0) lparg0 = getCHOOSEFONTFields(env, arg0, &_arg0);
+ rc = (jboolean)ChooseFontA(lparg0);
+ if (arg0) setCHOOSEFONTFields(env, arg0, lparg0);
+ return rc;
+}
+#endif /* NO_ChooseFontA */
+
+#ifndef NO_ChooseFontW
+JNIEXPORT jboolean JNICALL OS_NATIVE(ChooseFontW)
+ (JNIEnv *env, jclass that, jobject arg0)
+{
+ CHOOSEFONT _arg0, *lparg0=NULL;
+ jboolean rc;
+
+ DEBUG_CALL("ChooseFontW\n")
+
+ if (arg0) lparg0 = getCHOOSEFONTFields(env, arg0, &_arg0);
+ rc = (jboolean)ChooseFontW((LPCHOOSEFONTW)lparg0);
+ if (arg0) setCHOOSEFONTFields(env, arg0, lparg0);
+ return rc;
+}
+#endif /* NO_ChooseFontW */
+
+#ifndef NO_ClientToScreen
+JNIEXPORT jboolean JNICALL OS_NATIVE(ClientToScreen)
+ (JNIEnv *env, jclass that, jint arg0, jobject arg1)
+{
+ POINT _arg1, *lparg1=NULL;
+ jboolean rc;
+
+ DEBUG_CALL("ClientToScreen\n")
+
+ if (arg1) lparg1 = getPOINTFields(env, arg1, &_arg1);
+ rc = (jboolean)ClientToScreen((HWND)arg0, lparg1);
+ if (arg1) setPOINTFields(env, arg1, lparg1);
+ return rc;
+}
+#endif /* NO_ClientToScreen */
+
+#ifndef NO_CloseClipboard
+JNIEXPORT jboolean JNICALL OS_NATIVE(CloseClipboard)
+ (JNIEnv *env, jclass that)
+{
+ DEBUG_CALL("CloseClipboard\n")
+
+ return (jboolean)CloseClipboard();
+}
+#endif /* NO_CloseClipboard */
+
+#ifndef NO_CombineRgn
+JNIEXPORT jint JNICALL OS_NATIVE(CombineRgn)
+ (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jint arg3)
+{
+ DEBUG_CALL("CombineRgn\n")
+
+ return (jint)CombineRgn((HRGN)arg0, (HRGN)arg1, (HRGN)arg2, arg3);
+}
+#endif /* NO_CombineRgn */
+
+#ifndef NO_CommDlgExtendedError
+JNIEXPORT jint JNICALL OS_NATIVE(CommDlgExtendedError)
+ (JNIEnv *env, jclass that)
+{
+ DEBUG_CALL("CommDlgExtendedError\n")
+
+ return (jint)CommDlgExtendedError();
+}
+#endif /* NO_CommDlgExtendedError */
+
+#ifndef NO_CommandBar_1AddAdornments
+JNIEXPORT jboolean JNICALL OS_NATIVE(CommandBar_1AddAdornments)
+ (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2)
+{
+ DEBUG_CALL("CommandBar_1AddAdornments\n")
+
+ return (jboolean)CommandBar_AddAdornments((HWND)arg0, arg1, arg2);
+}
+#endif /* NO_CommandBar_1AddAdornments */
+
+#ifndef NO_CommandBar_1Create
+JNIEXPORT jint JNICALL OS_NATIVE(CommandBar_1Create)
+ (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2)
+{
+ DEBUG_CALL("CommandBar_1Create\n")
+
+ return (jint)CommandBar_Create((HINSTANCE)arg0, (HWND)arg1, arg2);
+}
+#endif /* NO_CommandBar_1Create */
+
+#ifndef NO_CommandBar_1Destroy
+JNIEXPORT void JNICALL OS_NATIVE(CommandBar_1Destroy)
+ (JNIEnv *env, jclass that, jint arg0)
+{
+ DEBUG_CALL("CommandBar_1Destroy\n")
+
+ CommandBar_Destroy((HWND)arg0);
+}
+#endif /* NO_CommandBar_1Destroy */
+
+#ifndef NO_CommandBar_1DrawMenuBar
+JNIEXPORT jboolean JNICALL OS_NATIVE(CommandBar_1DrawMenuBar)
+ (JNIEnv *env, jclass that, jint arg0, jint arg1)
+{
+ DEBUG_CALL("CommandBar_1DrawMenuBar\n")
+
+ return (jboolean)CommandBar_DrawMenuBar((HWND)arg0, (WORD)arg1);
+}
+#endif /* NO_CommandBar_1DrawMenuBar */
+
+#ifndef NO_CommandBar_1Height
+JNIEXPORT jint JNICALL OS_NATIVE(CommandBar_1Height)
+ (JNIEnv *env, jclass that, jint arg0)
+{
+ DEBUG_CALL("CommandBar_1Height\n")
+
+ return (jint)CommandBar_Height((HWND)arg0);
+}
+#endif /* NO_CommandBar_1Height */
+
+#ifndef NO_CommandBar_1InsertMenubarEx
+JNIEXPORT jboolean JNICALL OS_NATIVE(CommandBar_1InsertMenubarEx)
+ (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jint arg3)
+{
+ DEBUG_CALL("CommandBar_1InsertMenubarEx\n")
+
+ return (jboolean)CommandBar_InsertMenubarEx((HWND)arg0, (HINSTANCE)arg1, (LPTSTR)arg2, (WORD)arg3);
+}
+#endif /* NO_CommandBar_1InsertMenubarEx */
+
+#ifndef NO_CommandBar_1Show
+JNIEXPORT jboolean JNICALL OS_NATIVE(CommandBar_1Show)
+ (JNIEnv *env, jclass that, jint arg0, jboolean arg1)
+{
+ DEBUG_CALL("CommandBar_1Show\n")
+
+ return (jboolean)CommandBar_Show((HWND)arg0, (BOOL)arg1);
+}
+#endif /* NO_CommandBar_1Show */
+
+#ifndef NO_CopyImage
+JNIEXPORT jint JNICALL OS_NATIVE(CopyImage)
+ (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jint arg3, jint arg4)
+{
+ DEBUG_CALL("CopyImage\n")
+
+ return (jint)CopyImage((HANDLE)arg0, arg1, arg2, arg3, arg4);
+}
+#endif /* NO_CopyImage */
+
+#ifndef NO_CreateAcceleratorTableA
+JNIEXPORT jint JNICALL OS_NATIVE(CreateAcceleratorTableA)
+ (JNIEnv *env, jclass that, jbyteArray arg0, jint arg1)
+{
+ jbyte *lparg0=NULL;
+ jint rc;
+
+ DEBUG_CALL("CreateAcceleratorTableA\n")
+
+ if (arg0) lparg0 = (*env)->GetByteArrayElements(env, arg0, NULL);
+ rc = (jint)CreateAcceleratorTableA((LPACCEL)lparg0, arg1);
+ if (arg0) (*env)->ReleaseByteArrayElements(env, arg0, lparg0, 0);
+ return rc;
+}
+#endif /* NO_CreateAcceleratorTableA */
+
+#ifndef NO_CreateAcceleratorTableW
+JNIEXPORT jint JNICALL OS_NATIVE(CreateAcceleratorTableW)
+ (JNIEnv *env, jclass that, jbyteArray arg0, jint arg1)
+{
+ jbyte *lparg0=NULL;
+ jint rc;
+
+ DEBUG_CALL("CreateAcceleratorTableW\n")
+
+ if (arg0) lparg0 = (*env)->GetByteArrayElements(env, arg0, NULL);
+ rc = (jint)CreateAcceleratorTableW((LPACCEL)lparg0, arg1);
+ if (arg0) (*env)->ReleaseByteArrayElements(env, arg0, lparg0, 0);
+ return rc;
+}
+#endif /* NO_CreateAcceleratorTableW */
+
+#ifndef NO_CreateBitmap
+JNIEXPORT jint JNICALL OS_NATIVE(CreateBitmap)
+ (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jint arg3, jbyteArray arg4)
+{
+ jbyte *lparg4=NULL;
+ jint rc;
+
+ DEBUG_CALL("CreateBitmap\n")
+
+ if (arg4) lparg4 = (*env)->GetByteArrayElements(env, arg4, NULL);
+ rc = (jint)CreateBitmap(arg0, arg1, arg2, arg3, (CONST VOID *)lparg4);
+ if (arg4) (*env)->ReleaseByteArrayElements(env, arg4, lparg4, 0);
+ return rc;
+}
+#endif /* NO_CreateBitmap */
+
+#ifndef NO_CreateCaret
+JNIEXPORT jboolean JNICALL OS_NATIVE(CreateCaret)
+ (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jint arg3)
+{
+ DEBUG_CALL("CreateCaret\n")
+
+ return (jboolean)CreateCaret((HWND)arg0, (HBITMAP)arg1, arg2, arg3);
+}
+#endif /* NO_CreateCaret */
+
+#ifndef NO_CreateCompatibleBitmap
+JNIEXPORT jint JNICALL OS_NATIVE(CreateCompatibleBitmap)
+ (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2)
+{
+ DEBUG_CALL("CreateCompatibleBitmap\n")
+
+ return (jint)CreateCompatibleBitmap((HDC)arg0, arg1, arg2);
+}
+#endif /* NO_CreateCompatibleBitmap */
+
+#ifndef NO_CreateCompatibleDC
+JNIEXPORT jint JNICALL OS_NATIVE(CreateCompatibleDC)
+ (JNIEnv *env, jclass that, jint arg0)
+{
+ DEBUG_CALL("CreateCompatibleDC\n")
+
+ return (jint)CreateCompatibleDC((HDC)arg0);
+}
+#endif /* NO_CreateCompatibleDC */
+
+#ifndef NO_CreateCursor
+JNIEXPORT jint JNICALL OS_NATIVE(CreateCursor)
+ (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jint arg3, jint arg4, jbyteArray arg5, jbyteArray arg6)
+{
+ jbyte *lparg5=NULL;
+ jbyte *lparg6=NULL;
+ jint rc;
+
+ DEBUG_CALL("CreateCursor\n")
+
+ if (arg5) lparg5 = (*env)->GetByteArrayElements(env, arg5, NULL);
+ if (arg6) lparg6 = (*env)->GetByteArrayElements(env, arg6, NULL);
+ rc = (jint)CreateCursor((HINSTANCE)arg0, arg1, arg2, arg3, arg4, (CONST VOID *)lparg5, (CONST VOID *)lparg6);
+ if (arg5) (*env)->ReleaseByteArrayElements(env, arg5, lparg5, 0);
+ if (arg6) (*env)->ReleaseByteArrayElements(env, arg6, lparg6, 0);
+ return rc;
+}
+#endif /* NO_CreateCursor */
+
+#ifndef NO_CreateDCA
+JNIEXPORT jint JNICALL OS_NATIVE(CreateDCA)
+ (JNIEnv *env, jclass that, jbyteArray arg0, jbyteArray arg1, jint arg2, jint arg3)
+{
+ jbyte *lparg0=NULL;
+ jbyte *lparg1=NULL;
+ jint rc;
+
+ DEBUG_CALL("CreateDCA\n")
+
+ if (arg0) lparg0 = (*env)->GetByteArrayElements(env, arg0, NULL);
+ if (arg1) lparg1 = (*env)->GetByteArrayElements(env, arg1, NULL);
+ rc = (jint)CreateDCA((LPSTR)lparg0, (LPSTR)lparg1, (LPSTR)arg2, (CONST DEVMODE *)arg3);
+ if (arg0) (*env)->ReleaseByteArrayElements(env, arg0, lparg0, 0);
+ if (arg1) (*env)->ReleaseByteArrayElements(env, arg1, lparg1, 0);
+ return rc;
+}
+#endif /* NO_CreateDCA */
+
+#ifndef NO_CreateDCW
+JNIEXPORT jint JNICALL OS_NATIVE(CreateDCW)
+ (JNIEnv *env, jclass that, jcharArray arg0, jcharArray arg1, jint arg2, jint arg3)
+{
+ jchar *lparg0=NULL;
+ jchar *lparg1=NULL;
+ jint rc;
+
+ DEBUG_CALL("CreateDCW\n")
+
+ if (arg0) lparg0 = (*env)->GetCharArrayElements(env, arg0, NULL);
+ if (arg1) lparg1 = (*env)->GetCharArrayElements(env, arg1, NULL);
+ rc = (jint)CreateDCW((LPWSTR)lparg0, (LPWSTR)lparg1, (LPWSTR)arg2, (CONST DEVMODEW *)arg3);
+ if (arg0) (*env)->ReleaseCharArrayElements(env, arg0, lparg0, 0);
+ if (arg1) (*env)->ReleaseCharArrayElements(env, arg1, lparg1, 0);
+ return rc;
+}
+#endif /* NO_CreateDCW */
+
+#ifndef NO_CreateDIBSection
+JNIEXPORT jint JNICALL OS_NATIVE(CreateDIBSection)
+ (JNIEnv *env, jclass that, jint arg0, jbyteArray arg1, jint arg2, jintArray arg3, jint arg4, jint arg5)
+{
+ jbyte *lparg1=NULL;
+ jint *lparg3=NULL;
+ jint rc;
+
+ DEBUG_CALL("CreateDIBSection\n")
+
+ if (arg1) lparg1 = (*env)->GetByteArrayElements(env, arg1, NULL);
+ if (arg3) lparg3 = (*env)->GetIntArrayElements(env, arg3, NULL);
+ rc = (jint)CreateDIBSection((HDC)arg0, (BITMAPINFO *)lparg1, arg2, (VOID **)lparg3, (HANDLE)arg4, arg5);
+ if (arg1) (*env)->ReleaseByteArrayElements(env, arg1, lparg1, 0);
+ if (arg3) (*env)->ReleaseIntArrayElements(env, arg3, lparg3, 0);
+ return rc;
+}
+#endif /* NO_CreateDIBSection */
+
+#ifndef NO_CreateFontIndirectA__Lorg_eclipse_swt_internal_win32_LOGFONT_2
+JNIEXPORT jint JNICALL OS_NATIVE(CreateFontIndirectA__Lorg_eclipse_swt_internal_win32_LOGFONT_2)
+ (JNIEnv *env, jclass that, jobject arg0)
+{
+ LOGFONTA _arg0, *lparg0=NULL;
+ jint rc;
+
+ DEBUG_CALL("CreateFontIndirectA__Lorg_eclipse_swt_internal_win32_LOGFONT_2\n")
+
+ if (arg0) lparg0 = getLOGFONTAFields(env, arg0, &_arg0);
+ rc = (jint)CreateFontIndirectA(lparg0);
+ if (arg0) setLOGFONTAFields(env, arg0, lparg0);
+ return rc;
+}
+#endif /* NO_CreateFontIndirectA__Lorg_eclipse_swt_internal_win32_LOGFONT_2 */
+
+#ifndef NO_CreateFontIndirectA__I
+JNIEXPORT jint JNICALL OS_NATIVE(CreateFontIndirectA__I)
+ (JNIEnv *env, jclass that, jint arg0)
+{
+ DEBUG_CALL("CreateFontIndirectA__I\n")
+
+ return (jint)CreateFontIndirectA((LPLOGFONTA)arg0);
+}
+#endif /* NO_CreateFontIndirectA__I */
+
+#ifndef NO_CreateFontIndirectW__Lorg_eclipse_swt_internal_win32_LOGFONT_2
+JNIEXPORT jint JNICALL OS_NATIVE(CreateFontIndirectW__Lorg_eclipse_swt_internal_win32_LOGFONT_2)
+ (JNIEnv *env, jclass that, jobject arg0)
+{
+ LOGFONTW _arg0, *lparg0=NULL;
+ jint rc;
+
+ DEBUG_CALL("CreateFontIndirectW__Lorg_eclipse_swt_internal_win32_LOGFONT_2\n")
+
+ if (arg0) lparg0 = getLOGFONTWFields(env, arg0, &_arg0);
+ rc = (jint)CreateFontIndirectW(lparg0);
+ if (arg0) setLOGFONTWFields(env, arg0, lparg0);
+ return rc;
+}
+#endif /* NO_CreateFontIndirectW__Lorg_eclipse_swt_internal_win32_LOGFONT_2 */
+
+#ifndef NO_CreateFontIndirectW__I
+JNIEXPORT jint JNICALL OS_NATIVE(CreateFontIndirectW__I)
+ (JNIEnv *env, jclass that, jint arg0)
+{
+ DEBUG_CALL("CreateFontIndirectW__I\n")
+
+ return (jint)CreateFontIndirectW((LPLOGFONTW)arg0);
+}
+#endif /* NO_CreateFontIndirectW__I */
+
+#ifndef NO_CreateIconIndirect
+JNIEXPORT jint JNICALL OS_NATIVE(CreateIconIndirect)
+ (JNIEnv *env, jclass that, jobject arg0)
+{
+ ICONINFO _arg0, *lparg0=NULL;
+ jint rc;
+
+ DEBUG_CALL("CreateIconIndirect\n")
+
+ if (arg0) lparg0 = getICONINFOFields(env, arg0, &_arg0);
+ rc = (jint)CreateIconIndirect(lparg0);
+ if (arg0) setICONINFOFields(env, arg0, lparg0);
+ return rc;
+}
+#endif /* NO_CreateIconIndirect */
+
+#ifndef NO_CreateMenu
+JNIEXPORT jint JNICALL OS_NATIVE(CreateMenu)
+ (JNIEnv *env, jclass that)
+{
+ DEBUG_CALL("CreateMenu\n")
+
+ return (jint)CreateMenu();
+}
+#endif /* NO_CreateMenu */
+
+#ifndef NO_CreatePalette
+JNIEXPORT jint JNICALL OS_NATIVE(CreatePalette)
+ (JNIEnv *env, jclass that, jbyteArray arg0)
+{
+ jbyte *lparg0=NULL;
+ jint rc;
+
+ DEBUG_CALL("CreatePalette\n")
+
+ if (arg0) lparg0 = (*env)->GetByteArrayElements(env, arg0, NULL);
+ rc = (jint)CreatePalette((LOGPALETTE *)lparg0);
+ if (arg0) (*env)->ReleaseByteArrayElements(env, arg0, lparg0, 0);
+ return rc;
+}
+#endif /* NO_CreatePalette */
+
+#ifndef NO_CreatePatternBrush
+JNIEXPORT jint JNICALL OS_NATIVE(CreatePatternBrush)
+ (JNIEnv *env, jclass that, jint arg0)
+{
+ DEBUG_CALL("CreatePatternBrush\n")
+
+ return (jint)CreatePatternBrush((HBITMAP)arg0);
+}
+#endif /* NO_CreatePatternBrush */
+
+#ifndef NO_CreatePen
+JNIEXPORT jint JNICALL OS_NATIVE(CreatePen)
+ (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2)
+{
+ DEBUG_CALL("CreatePen\n")
+
+ return (jint)CreatePen(arg0, arg1, (COLORREF)arg2);
+}
+#endif /* NO_CreatePen */
+
+#ifndef NO_CreatePopupMenu
+JNIEXPORT jint JNICALL OS_NATIVE(CreatePopupMenu)
+ (JNIEnv *env, jclass that)
+{
+ DEBUG_CALL("CreatePopupMenu\n")
+
+ return (jint)CreatePopupMenu();
+}
+#endif /* NO_CreatePopupMenu */
+
+#ifndef NO_CreateRectRgn
+JNIEXPORT jint JNICALL OS_NATIVE(CreateRectRgn)
+ (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jint arg3)
+{
+ DEBUG_CALL("CreateRectRgn\n")
+
+ return (jint)CreateRectRgn(arg0, arg1, arg2, arg3);
+}
+#endif /* NO_CreateRectRgn */
+
+#ifndef NO_CreateSolidBrush
+JNIEXPORT jint JNICALL OS_NATIVE(CreateSolidBrush)
+ (JNIEnv *env, jclass that, jint arg0)
+{
+ DEBUG_CALL("CreateSolidBrush\n")
+
+ return (jint)CreateSolidBrush((COLORREF)arg0);
+}
+#endif /* NO_CreateSolidBrush */
+
+#ifndef NO_CreateWindowExA
+JNIEXPORT jint JNICALL OS_NATIVE(CreateWindowExA)
+ (JNIEnv *env, jclass that, jint arg0, jbyteArray arg1, jbyteArray arg2, jint arg3, jint arg4, jint arg5, jint arg6, jint arg7, jint arg8, jint arg9, jint arg10, jobject arg11)
+{
+ jbyte *lparg1=NULL;
+ jbyte *lparg2=NULL;
+ CREATESTRUCT _arg11, *lparg11=NULL;
+ jint rc;
+
+ DEBUG_CALL("CreateWindowExA\n")
+
+ if (arg1) lparg1 = (*env)->GetByteArrayElements(env, arg1, NULL);
+ if (arg2) lparg2 = (*env)->GetByteArrayElements(env, arg2, NULL);
+ if (arg11) lparg11 = getCREATESTRUCTFields(env, arg11, &_arg11);
+ rc = (jint)CreateWindowExA(arg0, (LPSTR)lparg1, lparg2, arg3, arg4, arg5, arg6, arg7, (HWND)arg8, (HMENU)arg9, (HINSTANCE)arg10, lparg11);
+ if (arg1) (*env)->ReleaseByteArrayElements(env, arg1, lparg1, 0);
+ if (arg2) (*env)->ReleaseByteArrayElements(env, arg2, lparg2, 0);
+ if (arg11) setCREATESTRUCTFields(env, arg11, lparg11);
+ return rc;
+}
+#endif /* NO_CreateWindowExA */
+
+#ifndef NO_CreateWindowExW
+JNIEXPORT jint JNICALL OS_NATIVE(CreateWindowExW)
+ (JNIEnv *env, jclass that, jint arg0, jcharArray arg1, jcharArray arg2, jint arg3, jint arg4, jint arg5, jint arg6, jint arg7, jint arg8, jint arg9, jint arg10, jobject arg11)
+{
+ jchar *lparg1=NULL;
+ jchar *lparg2=NULL;
+ CREATESTRUCT _arg11, *lparg11=NULL;
+ jint rc;
+
+ DEBUG_CALL("CreateWindowExW\n")
+
+ if (arg1) lparg1 = (*env)->GetCharArrayElements(env, arg1, NULL);
+ if (arg2) lparg2 = (*env)->GetCharArrayElements(env, arg2, NULL);
+ if (arg11) lparg11 = getCREATESTRUCTFields(env, arg11, &_arg11);
+ rc = (jint)CreateWindowExW(arg0, (LPWSTR)lparg1, (LPWSTR)lparg2, arg3, arg4, arg5, arg6, arg7, (HWND)arg8, (HMENU)arg9, (HINSTANCE)arg10, lparg11);
+ if (arg1) (*env)->ReleaseCharArrayElements(env, arg1, lparg1, 0);
+ if (arg2) (*env)->ReleaseCharArrayElements(env, arg2, lparg2, 0);
+ if (arg11) setCREATESTRUCTFields(env, arg11, lparg11);
+ return rc;
+}
+#endif /* NO_CreateWindowExW */
+
+#ifndef NO_DefWindowProcA
+JNIEXPORT jint JNICALL OS_NATIVE(DefWindowProcA)
+ (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jint arg3)
+{
+ DEBUG_CALL("DefWindowProcA\n")
+
+ return (jint)DefWindowProcA((HWND)arg0, arg1, (WPARAM)arg2, (LPARAM)arg3);
+}
+#endif /* NO_DefWindowProcA */
+
+#ifndef NO_DefWindowProcW
+JNIEXPORT jint JNICALL OS_NATIVE(DefWindowProcW)
+ (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jint arg3)
+{
+ DEBUG_CALL("DefWindowProcW\n")
+
+ return (jint)DefWindowProcW((HWND)arg0, arg1, (WPARAM)arg2, (LPARAM)arg3);
+}
+#endif /* NO_DefWindowProcW */
+
+#ifndef NO_DeferWindowPos
+JNIEXPORT jint JNICALL OS_NATIVE(DeferWindowPos)
+ (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jint arg3, jint arg4, jint arg5, jint arg6, jint arg7)
+{
+ DEBUG_CALL("DeferWindowPos\n")
+
+ return (jint)DeferWindowPos((HDWP)arg0, (HWND)arg1, (HWND)arg2, arg3, arg4, arg5, arg6, arg7);
+}
+#endif /* NO_DeferWindowPos */
+
+#ifndef NO_DeleteDC
+JNIEXPORT jboolean JNICALL OS_NATIVE(DeleteDC)
+ (JNIEnv *env, jclass that, jint arg0)
+{
+ DEBUG_CALL("DeleteDC\n")
+
+ return (jboolean)DeleteDC((HDC)arg0);
+}
+#endif /* NO_DeleteDC */
+
+#ifndef NO_DeleteMenu
+JNIEXPORT jboolean JNICALL OS_NATIVE(DeleteMenu)
+ (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2)
+{
+ DEBUG_CALL("DeleteMenu\n")
+
+ return (jboolean)DeleteMenu((HMENU)arg0, arg1, arg2);
+}
+#endif /* NO_DeleteMenu */
+
+#ifndef NO_DeleteObject
+JNIEXPORT jboolean JNICALL OS_NATIVE(DeleteObject)
+ (JNIEnv *env, jclass that, jint arg0)
+{
+ DEBUG_CALL("DeleteObject\n")
+
+ return (jboolean)DeleteObject((HGDIOBJ)arg0);
+}
+#endif /* NO_DeleteObject */
+
+#ifndef NO_DestroyAcceleratorTable
+JNIEXPORT jboolean JNICALL OS_NATIVE(DestroyAcceleratorTable)
+ (JNIEnv *env, jclass that, jint arg0)
+{
+ DEBUG_CALL("DestroyAcceleratorTable\n")
+
+ return (jboolean)DestroyAcceleratorTable((HACCEL)arg0);
+}
+#endif /* NO_DestroyAcceleratorTable */
+
+#ifndef NO_DestroyCaret
+JNIEXPORT jboolean JNICALL OS_NATIVE(DestroyCaret)
+ (JNIEnv *env, jclass that)
+{
+ DEBUG_CALL("DestroyCaret\n")
+
+ return (jboolean)DestroyCaret();
+}
+#endif /* NO_DestroyCaret */
+
+#ifndef NO_DestroyCursor
+JNIEXPORT jboolean JNICALL OS_NATIVE(DestroyCursor)
+ (JNIEnv *env, jclass that, jint arg0)
+{
+ DEBUG_CALL("DestroyCursor\n")
+
+ return (jboolean)DestroyCursor((HCURSOR)arg0);
+}
+#endif /* NO_DestroyCursor */
+
+#ifndef NO_DestroyIcon
+JNIEXPORT jboolean JNICALL OS_NATIVE(DestroyIcon)
+ (JNIEnv *env, jclass that, jint arg0)
+{
+ DEBUG_CALL("DestroyIcon\n")
+
+ return (jboolean)DestroyIcon((HICON)arg0);
+}
+#endif /* NO_DestroyIcon */
+
+#ifndef NO_DestroyMenu
+JNIEXPORT jboolean JNICALL OS_NATIVE(DestroyMenu)
+ (JNIEnv *env, jclass that, jint arg0)
+{
+ DEBUG_CALL("DestroyMenu\n")
+
+ return (jboolean)DestroyMenu((HMENU)arg0);
+}
+#endif /* NO_DestroyMenu */
+
+#ifndef NO_DestroyWindow
+JNIEXPORT jboolean JNICALL OS_NATIVE(DestroyWindow)
+ (JNIEnv *env, jclass that, jint arg0)
+{
+ DEBUG_CALL("DestroyWindow\n")
+
+ return (jboolean)DestroyWindow((HWND)arg0);
+}
+#endif /* NO_DestroyWindow */
+
+#ifndef NO_DispatchMessageA
+JNIEXPORT jint JNICALL OS_NATIVE(DispatchMessageA)
+ (JNIEnv *env, jclass that, jobject arg0)
+{
+ MSG _arg0, *lparg0=NULL;
+
+ DEBUG_CALL("DispatchMessageA\n")
+
+ if (arg0) lparg0 = getMSGFields(env, arg0, &_arg0);
+ return (jint)DispatchMessageA(lparg0);
+}
+#endif /* NO_DispatchMessageA */
+
+#ifndef NO_DispatchMessageW
+JNIEXPORT jint JNICALL OS_NATIVE(DispatchMessageW)
+ (JNIEnv *env, jclass that, jobject arg0)
+{
+ MSG _arg0, *lparg0=NULL;
+
+ DEBUG_CALL("DispatchMessageW\n")
+
+ if (arg0) lparg0 = getMSGFields(env, arg0, &_arg0);
+ return (jint)DispatchMessageW(lparg0);
+}
+#endif /* NO_DispatchMessageW */
+
+#ifndef NO_DragDetect
+JNIEXPORT jboolean JNICALL OS_NATIVE(DragDetect)
+ (JNIEnv *env, jclass that, jint arg0, jobject arg1)
+{
+ POINT _arg1, *lparg1=NULL;
+
+ DEBUG_CALL("DragDetect\n")
+
+ if (arg1) lparg1 = getPOINTFields(env, arg1, &_arg1);
+ return (jboolean)DragDetect((HWND)arg0, *lparg1);
+}
+#endif /* NO_DragDetect */
+
+#ifndef NO_DragFinish
+JNIEXPORT void JNICALL OS_NATIVE(DragFinish)
+ (JNIEnv *env, jclass that, jint arg0)
+{
+ DEBUG_CALL("DragFinish\n")
+
+ DragFinish((HDROP)arg0);
+}
+#endif /* NO_DragFinish */
+
+#ifndef NO_DragQueryFileA
+JNIEXPORT jint JNICALL OS_NATIVE(DragQueryFileA)
+ (JNIEnv *env, jclass that, jint arg0, jint arg1, jbyteArray arg2, jint arg3)
+{
+ jbyte *lparg2=NULL;
+ jint rc;
+
+ DEBUG_CALL("DragQueryFileA\n")
+
+ if (arg2) lparg2 = (*env)->GetByteArrayElements(env, arg2, NULL);
+ rc = (jint)DragQueryFileA((HDROP)arg0, arg1, (LPTSTR)lparg2, arg3);
+ if (arg2) (*env)->ReleaseByteArrayElements(env, arg2, lparg2, 0);
+ return rc;
+}
+#endif /* NO_DragQueryFileA */
+
+#ifndef NO_DragQueryFileW
+JNIEXPORT jint JNICALL OS_NATIVE(DragQueryFileW)
+ (JNIEnv *env, jclass that, jint arg0, jint arg1, jcharArray arg2, jint arg3)
+{
+ jchar *lparg2=NULL;
+ jint rc;
+
+ DEBUG_CALL("DragQueryFileW\n")
+
+ if (arg2) lparg2 = (*env)->GetCharArrayElements(env, arg2, NULL);
+ rc = (jint)DragQueryFileW((HDROP)arg0, arg1, (LPWSTR)lparg2, arg3);
+ if (arg2) (*env)->ReleaseCharArrayElements(env, arg2, lparg2, 0);
+ return rc;
+}
+#endif /* NO_DragQueryFileW */
+
+#ifndef NO_DrawEdge
+JNIEXPORT jboolean JNICALL OS_NATIVE(DrawEdge)
+ (JNIEnv *env, jclass that, jint arg0, jobject arg1, jint arg2, jint arg3)
+{
+ RECT _arg1, *lparg1=NULL;
+ jboolean rc;
+
+ DEBUG_CALL("DrawEdge\n")
+
+ if (arg1) lparg1 = getRECTFields(env, arg1, &_arg1);
+ rc = (jboolean)DrawEdge((HDC)arg0, lparg1, arg2, arg3);
+ if (arg1) setRECTFields(env, arg1, lparg1);
+ return rc;
+}
+#endif /* NO_DrawEdge */
+
+#ifndef NO_DrawFocusRect
+JNIEXPORT jboolean JNICALL OS_NATIVE(DrawFocusRect)
+ (JNIEnv *env, jclass that, jint arg0, jobject arg1)
+{
+ RECT _arg1, *lparg1=NULL;
+ jboolean rc;
+
+ DEBUG_CALL("DrawFocusRect\n")
+
+ if (arg1) lparg1 = getRECTFields(env, arg1, &_arg1);
+ rc = (jboolean)DrawFocusRect((HDC)arg0, lparg1);
+ if (arg1) setRECTFields(env, arg1, lparg1);
+ return rc;
+}
+#endif /* NO_DrawFocusRect */
+
+#ifndef NO_DrawFrameControl
+JNIEXPORT jboolean JNICALL OS_NATIVE(DrawFrameControl)
+ (JNIEnv *env, jclass that, jint arg0, jobject arg1, jint arg2, jint arg3)
+{
+ RECT _arg1, *lparg1=NULL;
+ jboolean rc;
+
+ DEBUG_CALL("DrawFrameControl\n")
+
+ if (arg1) lparg1 = getRECTFields(env, arg1, &_arg1);
+ rc = (jboolean)DrawFrameControl((HDC)arg0, lparg1, arg2, arg3);
+ if (arg1) setRECTFields(env, arg1, lparg1);
+ return rc;
+}
+#endif /* NO_DrawFrameControl */
+
+#ifndef NO_DrawIconEx
+JNIEXPORT jboolean JNICALL OS_NATIVE(DrawIconEx)
+ (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jint arg3, jint arg4, jint arg5, jint arg6, jint arg7, jint arg8)
+{
+ DEBUG_CALL("DrawIconEx\n")
+
+ return (jboolean)DrawIconEx((HDC)arg0, arg1, arg2, (HICON)arg3, arg4, arg5, arg6, (HBRUSH)arg7, arg8);
+}
+#endif /* NO_DrawIconEx */
+
+#ifndef NO_DrawMenuBar
+JNIEXPORT jboolean JNICALL OS_NATIVE(DrawMenuBar)
+ (JNIEnv *env, jclass that, jint arg0)
+{
+ DEBUG_CALL("DrawMenuBar\n")
+
+ return (jboolean)DrawMenuBar((HWND)arg0);
+}
+#endif /* NO_DrawMenuBar */
+
+#ifndef NO_DrawStateA
+JNIEXPORT jboolean JNICALL OS_NATIVE(DrawStateA)
+ (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jint arg3, jint arg4, jint arg5, jint arg6, jint arg7, jint arg8, jint arg9)
+{
+ DEBUG_CALL("DrawStateA\n")
+
+ return (jboolean)DrawStateA((HDC)arg0, (HBRUSH)arg1, (DRAWSTATEPROC)arg2, (LPARAM)arg3, (WPARAM)arg4, arg5, arg6, arg7, arg8, arg9);
+}
+#endif /* NO_DrawStateA */
+
+#ifndef NO_DrawStateW
+JNIEXPORT jboolean JNICALL OS_NATIVE(DrawStateW)
+ (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jint arg3, jint arg4, jint arg5, jint arg6, jint arg7, jint arg8, jint arg9)
+{
+ DEBUG_CALL("DrawStateW\n")
+
+ return (jboolean)DrawStateW((HDC)arg0, (HBRUSH)arg1, (DRAWSTATEPROC)arg2, (LPARAM)arg3, (WPARAM)arg4, arg5, arg6, arg7, arg8, arg9);
+}
+#endif /* NO_DrawStateW */
+
+#ifndef NO_DrawTextA
+JNIEXPORT jint JNICALL OS_NATIVE(DrawTextA)
+ (JNIEnv *env, jclass that, jint arg0, jbyteArray arg1, jint arg2, jobject arg3, jint arg4)
+{
+ jbyte *lparg1=NULL;
+ RECT _arg3, *lparg3=NULL;
+ jint rc;
+
+ DEBUG_CALL("DrawTextA\n")
+
+ if (arg1) lparg1 = (*env)->GetByteArrayElements(env, arg1, NULL);
+ if (arg3) lparg3 = getRECTFields(env, arg3, &_arg3);
+ rc = (jint)DrawTextA((HDC)arg0, (LPSTR)lparg1, arg2, lparg3, arg4);
+ if (arg1) (*env)->ReleaseByteArrayElements(env, arg1, lparg1, 0);
+ if (arg3) setRECTFields(env, arg3, lparg3);
+ return rc;
+}
+#endif /* NO_DrawTextA */
+
+#ifndef NO_DrawTextW
+JNIEXPORT jint JNICALL OS_NATIVE(DrawTextW)
+ (JNIEnv *env, jclass that, jint arg0, jcharArray arg1, jint arg2, jobject arg3, jint arg4)
+{
+ jchar *lparg1=NULL;
+ RECT _arg3, *lparg3=NULL;
+ jint rc;
+
+ DEBUG_CALL("DrawTextW\n")
+
+ if (arg1) lparg1 = (*env)->GetCharArrayElements(env, arg1, NULL);
+ if (arg3) lparg3 = getRECTFields(env, arg3, &_arg3);
+ rc = (jint)DrawTextW((HDC)arg0, (LPWSTR)lparg1, arg2, lparg3, arg4);
+ if (arg1) (*env)->ReleaseCharArrayElements(env, arg1, lparg1, 0);
+ if (arg3) setRECTFields(env, arg3, lparg3);
+ return rc;
+}
+#endif /* NO_DrawTextW */
+
+#ifndef NO_Ellipse
+JNIEXPORT jboolean JNICALL OS_NATIVE(Ellipse)
+ (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jint arg3, jint arg4)
+{
+ DEBUG_CALL("Ellipse\n")
+
+ return (jboolean)Ellipse((HDC)arg0, arg1, arg2, arg3, arg4);
+}
+#endif /* NO_Ellipse */
+
+#ifndef NO_EnableMenuItem
+JNIEXPORT jboolean JNICALL OS_NATIVE(EnableMenuItem)
+ (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2)
+{
+ DEBUG_CALL("EnableMenuItem\n")
+
+ return (jboolean)EnableMenuItem((HMENU)arg0, arg1, arg2);
+}
+#endif /* NO_EnableMenuItem */
+
+#ifndef NO_EnableScrollBar
+JNIEXPORT jboolean JNICALL OS_NATIVE(EnableScrollBar)
+ (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2)
+{
+ DEBUG_CALL("EnableScrollBar\n")
+
+ return (jboolean)EnableScrollBar((HWND)arg0, arg1, arg2);
+}
+#endif /* NO_EnableScrollBar */
+
+#ifndef NO_EnableWindow
+JNIEXPORT jboolean JNICALL OS_NATIVE(EnableWindow)
+ (JNIEnv *env, jclass that, jint arg0, jboolean arg1)
+{
+ DEBUG_CALL("EnableWindow\n")
+
+ return (jboolean)EnableWindow((HWND)arg0, arg1);
+}
+#endif /* NO_EnableWindow */
+
+#ifndef NO_EndDeferWindowPos
+JNIEXPORT jboolean JNICALL OS_NATIVE(EndDeferWindowPos)
+ (JNIEnv *env, jclass that, jint arg0)
+{
+ DEBUG_CALL("EndDeferWindowPos\n")
+
+ return (jboolean)EndDeferWindowPos((HDWP)arg0);
+}
+#endif /* NO_EndDeferWindowPos */
+
+#ifndef NO_EndDoc
+JNIEXPORT jint JNICALL OS_NATIVE(EndDoc)
+ (JNIEnv *env, jclass that, jint arg0)
+{
+ DEBUG_CALL("EndDoc\n")
+
+ return (jint)EndDoc((HDC)arg0);
+}
+#endif /* NO_EndDoc */
+
+#ifndef NO_EndPage
+JNIEXPORT jint JNICALL OS_NATIVE(EndPage)
+ (JNIEnv *env, jclass that, jint arg0)
+{
+ DEBUG_CALL("EndPage\n")
+
+ return (jint)EndPage((HDC)arg0);
+}
+#endif /* NO_EndPage */
+
+#ifndef NO_EndPaint
+JNIEXPORT jint JNICALL OS_NATIVE(EndPaint)
+ (JNIEnv *env, jclass that, jint arg0, jobject arg1)
+{
+ PAINTSTRUCT _arg1, *lparg1=NULL;
+
+ DEBUG_CALL("EndPaint\n")
+
+ if (arg1) lparg1 = getPAINTSTRUCTFields(env, arg1, &_arg1);
+ return (jint)EndPaint((HWND)arg0, lparg1);
+}
+#endif /* NO_EndPaint */
+
+#ifndef NO_EnumFontFamiliesA
+JNIEXPORT jint JNICALL OS_NATIVE(EnumFontFamiliesA)
+ (JNIEnv *env, jclass that, jint arg0, jbyteArray arg1, jint arg2, jint arg3)
+{
+ jbyte *lparg1=NULL;
+ jint rc;
+
+ DEBUG_CALL("EnumFontFamiliesA\n")
+
+ if (arg1) lparg1 = (*env)->GetByteArrayElements(env, arg1, NULL);
+ rc = (jint)EnumFontFamiliesA((HDC)arg0, (LPSTR)lparg1, (FONTENUMPROC)arg2, (LPARAM)arg3);
+ if (arg1) (*env)->ReleaseByteArrayElements(env, arg1, lparg1, 0);
+ return rc;
+}
+#endif /* NO_EnumFontFamiliesA */
+
+#ifndef NO_EnumFontFamiliesW
+JNIEXPORT jint JNICALL OS_NATIVE(EnumFontFamiliesW)
+ (JNIEnv *env, jclass that, jint arg0, jcharArray arg1, jint arg2, jint arg3)
+{
+ jchar *lparg1=NULL;
+ jint rc;
+
+ DEBUG_CALL("EnumFontFamiliesW\n")
+
+ if (arg1) lparg1 = (*env)->GetCharArrayElements(env, arg1, NULL);
+ rc = (jint)EnumFontFamiliesW((HDC)arg0, (LPCWSTR)lparg1, (FONTENUMPROCW)arg2, (LPARAM)arg3);
+ if (arg1) (*env)->ReleaseCharArrayElements(env, arg1, lparg1, 0);
+ return rc;
+}
+#endif /* NO_EnumFontFamiliesW */
+
+#ifndef NO_EnumSystemLanguageGroupsA
+JNIEXPORT jboolean JNICALL OS_NATIVE(EnumSystemLanguageGroupsA)
+ (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2)
+{
+ HMODULE hm;
+ FARPROC fp;
+
+ DEBUG_CALL("EnumSystemLanguageGroupsA\n")
+
+ /* SPECIAL */
+ /*
+ * EnumSystemLanguageGroupsA is a Win2000 or later 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("kernel32.dll")) && (fp=GetProcAddress(hm, "EnumSystemLanguageGroupsA"))) {
+
+ return (jboolean)(fp)((LANGUAGEGROUP_ENUMPROCA)arg0, arg1, (LONG_PTR)arg2);
+// return (jboolean)EnumSystemLanguageGroupsA((LANGUAGEGROUP_ENUMPROCA)arg0, arg1, (LONG_PTR)arg2);
+ }
+ return 0;
+}
+#endif /* NO_EnumSystemLanguageGroupsA */
+
+#ifndef NO_EnumSystemLanguageGroupsW
+JNIEXPORT jboolean JNICALL OS_NATIVE(EnumSystemLanguageGroupsW)
+ (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2)
+{
+ HMODULE hm;
+ FARPROC fp;
+
+ DEBUG_CALL("EnumSystemLanguageGroupsW\n")
+
+ /* SPECIAL */
+ /*
+ * EnumSystemLanguageGroupsW is a Win2000 or later 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("kernel32.dll")) && (fp=GetProcAddress(hm, "EnumSystemLanguageGroupsW"))) {
+
+ return (jboolean)(fp)((LANGUAGEGROUP_ENUMPROCW)arg0, arg1, (LONG_PTR)arg2);
+// return (jboolean)EnumSystemLanguageGroupsW((LANGUAGEGROUP_ENUMPROCW)arg0, arg1, (LONG_PTR)arg2);
+ }
+ return 0;
+}
+#endif /* NO_EnumSystemLanguageGroupsW */
+
+#ifndef NO_EnumSystemLocalesA
+JNIEXPORT jboolean JNICALL OS_NATIVE(EnumSystemLocalesA)
+ (JNIEnv *env, jclass that, jint arg0, jint arg1)
+{
+ DEBUG_CALL("EnumSystemLocalesA\n")
+
+ return (jboolean)EnumSystemLocalesA((LOCALE_ENUMPROCA)arg0, arg1);
+}
+#endif /* NO_EnumSystemLocalesA */
+
+#ifndef NO_EnumSystemLocalesW
+JNIEXPORT jboolean JNICALL OS_NATIVE(EnumSystemLocalesW)
+ (JNIEnv *env, jclass that, jint arg0, jint arg1)
+{
+ DEBUG_CALL("EnumSystemLocalesW\n")
+
+ return (jboolean)EnumSystemLocalesW((LOCALE_ENUMPROCW)arg0, arg1);
+}
+#endif /* NO_EnumSystemLocalesW */
+
+#ifndef NO_EqualRect
+JNIEXPORT jboolean JNICALL OS_NATIVE(EqualRect)
+ (JNIEnv *env, jclass that, jobject arg0, jobject arg1)
+{
+ RECT _arg0, *lparg0=NULL;
+ RECT _arg1, *lparg1=NULL;
+
+ DEBUG_CALL("EqualRect\n")
+
+ if (arg0) lparg0 = getRECTFields(env, arg0, &_arg0);
+ if (arg1) lparg1 = getRECTFields(env, arg1, &_arg1);
+ return (jboolean)EqualRect((CONST RECT *)lparg0, (CONST RECT *)lparg1);
+}
+#endif /* NO_EqualRect */
+
+#ifndef NO_EqualRgn
+JNIEXPORT jboolean JNICALL OS_NATIVE(EqualRgn)
+ (JNIEnv *env, jclass that, jint arg0, jint arg1)
+{
+ DEBUG_CALL("EqualRgn\n")
+
+ return (jboolean)EqualRgn((HRGN)arg0, (HRGN)arg1);
+}
+#endif /* NO_EqualRgn */
+
+#ifndef NO_ExpandEnvironmentStringsA
+JNIEXPORT jint JNICALL OS_NATIVE(ExpandEnvironmentStringsA)
+ (JNIEnv *env, jclass that, jbyteArray arg0, jbyteArray arg1, jint arg2)
+{
+ jbyte *lparg0=NULL;
+ jbyte *lparg1=NULL;
+ jint rc;
+
+ DEBUG_CALL("ExpandEnvironmentStringsA\n")
+
+ if (arg0) lparg0 = (*env)->GetByteArrayElements(env, arg0, NULL);
+ if (arg1) lparg1 = (*env)->GetByteArrayElements(env, arg1, NULL);
+ rc = (jint)ExpandEnvironmentStringsA(lparg0, lparg1, arg2);
+ if (arg0) (*env)->ReleaseByteArrayElements(env, arg0, lparg0, 0);
+ if (arg1) (*env)->ReleaseByteArrayElements(env, arg1, lparg1, 0);
+ return rc;
+}
+#endif /* NO_ExpandEnvironmentStringsA */
+
+#ifndef NO_ExpandEnvironmentStringsW
+JNIEXPORT jint JNICALL OS_NATIVE(ExpandEnvironmentStringsW)
+ (JNIEnv *env, jclass that, jcharArray arg0, jcharArray arg1, jint arg2)
+{
+ jchar *lparg0=NULL;
+ jchar *lparg1=NULL;
+ jint rc;
+
+ DEBUG_CALL("ExpandEnvironmentStringsW\n")
+
+ if (arg0) lparg0 = (*env)->GetCharArrayElements(env, arg0, NULL);
+ if (arg1) lparg1 = (*env)->GetCharArrayElements(env, arg1, NULL);
+ rc = (jint)ExpandEnvironmentStringsW(lparg0, lparg1, arg2);
+ if (arg0) (*env)->ReleaseCharArrayElements(env, arg0, lparg0, 0);
+ if (arg1) (*env)->ReleaseCharArrayElements(env, arg1, lparg1, 0);
+ return rc;
+}
+#endif /* NO_ExpandEnvironmentStringsW */
+
+#ifndef NO_ExtTextOutA
+JNIEXPORT jboolean JNICALL OS_NATIVE(ExtTextOutA)
+ (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jint arg3, jobject arg4, jbyteArray arg5, jint arg6, jintArray arg7)
+{
+ RECT _arg4, *lparg4=NULL;
+ jbyte *lparg5=NULL;
+ jint *lparg7=NULL;
+ jboolean rc;
+
+ DEBUG_CALL("ExtTextOutA\n")
+
+ if (arg4) lparg4 = getRECTFields(env, arg4, &_arg4);
+ if (arg5) lparg5 = (*env)->GetByteArrayElements(env, arg5, NULL);
+ if (arg7) lparg7 = (*env)->GetIntArrayElements(env, arg7, NULL);
+ rc = (jboolean)ExtTextOutA((HDC)arg0, arg1, arg2, arg3, lparg4, (LPSTR)lparg5, arg6, (CONST INT *)lparg7);
+ if (arg4) setRECTFields(env, arg4, lparg4);
+ if (arg5) (*env)->ReleaseByteArrayElements(env, arg5, lparg5, 0);
+ if (arg7) (*env)->ReleaseIntArrayElements(env, arg7, lparg7, 0);
+ return rc;
+}
+#endif /* NO_ExtTextOutA */
+
+#ifndef NO_ExtTextOutW
+JNIEXPORT jboolean JNICALL OS_NATIVE(ExtTextOutW)
+ (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jint arg3, jobject arg4, jcharArray arg5, jint arg6, jintArray arg7)
+{
+ RECT _arg4, *lparg4=NULL;
+ jchar *lparg5=NULL;
+ jint *lparg7=NULL;
+ jboolean rc;
+
+ DEBUG_CALL("ExtTextOutW\n")
+
+ if (arg4) lparg4 = getRECTFields(env, arg4, &_arg4);
+ if (arg5) lparg5 = (*env)->GetCharArrayElements(env, arg5, NULL);
+ if (arg7) lparg7 = (*env)->GetIntArrayElements(env, arg7, NULL);
+ rc = (jboolean)ExtTextOutW((HDC)arg0, arg1, arg2, arg3, lparg4, (LPWSTR)lparg5, arg6, (CONST INT*)lparg7);
+ if (arg4) setRECTFields(env, arg4, lparg4);
+ if (arg5) (*env)->ReleaseCharArrayElements(env, arg5, lparg5, 0);
+ if (arg7) (*env)->ReleaseIntArrayElements(env, arg7, lparg7, 0);
+ return rc;
+}
+#endif /* NO_ExtTextOutW */
+
+#ifndef NO_ExtractIconExA
+JNIEXPORT jint JNICALL OS_NATIVE(ExtractIconExA)
+ (JNIEnv *env, jclass that, jbyteArray arg0, jint arg1, jintArray arg2, jintArray arg3, jint arg4)
+{
+ jbyte *lparg0=NULL;
+ jint *lparg2=NULL;
+ jint *lparg3=NULL;
+ jint rc;
+
+ DEBUG_CALL("ExtractIconExA\n")
+
+ if (arg0) lparg0 = (*env)->GetByteArrayElements(env, arg0, NULL);
+ if (arg2) lparg2 = (*env)->GetIntArrayElements(env, arg2, NULL);
+ if (arg3) lparg3 = (*env)->GetIntArrayElements(env, arg3, NULL);
+ rc = (jint)ExtractIconExA((LPSTR)lparg0, arg1, (HICON FAR *)lparg2, (HICON FAR *)lparg3, arg4);
+ if (arg0) (*env)->ReleaseByteArrayElements(env, arg0, lparg0, 0);
+ if (arg2) (*env)->ReleaseIntArrayElements(env, arg2, lparg2, 0);
+ if (arg3) (*env)->ReleaseIntArrayElements(env, arg3, lparg3, 0);
+ return rc;
+}
+#endif /* NO_ExtractIconExA */
+
+#ifndef NO_ExtractIconExW
+JNIEXPORT jint JNICALL OS_NATIVE(ExtractIconExW)
+ (JNIEnv *env, jclass that, jcharArray arg0, jint arg1, jintArray arg2, jintArray arg3, jint arg4)
+{
+ jchar *lparg0=NULL;
+ jint *lparg2=NULL;
+ jint *lparg3=NULL;
+ jint rc;
+
+ DEBUG_CALL("ExtractIconExW\n")
+
+ if (arg0) lparg0 = (*env)->GetCharArrayElements(env, arg0, NULL);
+ if (arg2) lparg2 = (*env)->GetIntArrayElements(env, arg2, NULL);
+ if (arg3) lparg3 = (*env)->GetIntArrayElements(env, arg3, NULL);
+ rc = (jint)ExtractIconExW((LPWSTR)lparg0, arg1, (HICON FAR *)lparg2, (HICON FAR *)lparg3, arg4);
+ if (arg0) (*env)->ReleaseCharArrayElements(env, arg0, lparg0, 0);
+ if (arg2) (*env)->ReleaseIntArrayElements(env, arg2, lparg2, 0);
+ if (arg3) (*env)->ReleaseIntArrayElements(env, arg3, lparg3, 0);
+ return rc;
+}
+#endif /* NO_ExtractIconExW */
+
+#ifndef NO_FillRect
+JNIEXPORT jint JNICALL OS_NATIVE(FillRect)
+ (JNIEnv *env, jclass that, jint arg0, jobject arg1, jint arg2)
+{
+ RECT _arg1, *lparg1=NULL;
+ jint rc;
+
+ DEBUG_CALL("FillRect\n")
+
+ if (arg1) lparg1 = getRECTFields(env, arg1, &_arg1);
+ rc = (jint)FillRect((HDC)arg0, lparg1, (HBRUSH)arg2);
+ if (arg1) setRECTFields(env, arg1, lparg1);
+ return rc;
+}
+#endif /* NO_FillRect */
+
+#ifndef NO_FindWindowA
+JNIEXPORT jint JNICALL OS_NATIVE(FindWindowA)
+ (JNIEnv *env, jclass that, jbyteArray arg0, jbyteArray arg1)
+{
+ jbyte *lparg0=NULL;
+ jbyte *lparg1=NULL;
+ jint rc;
+
+ DEBUG_CALL("FindWindowA\n")
+
+ if (arg0) lparg0 = (*env)->GetByteArrayElements(env, arg0, NULL);
+ if (arg1) lparg1 = (*env)->GetByteArrayElements(env, arg1, NULL);
+ rc = (jint)FindWindowA((LPSTR)lparg0, (LPSTR)lparg1);
+ if (arg0) (*env)->ReleaseByteArrayElements(env, arg0, lparg0, 0);
+ if (arg1) (*env)->ReleaseByteArrayElements(env, arg1, lparg1, 0);
+ return rc;
+}
+#endif /* NO_FindWindowA */
+
+#ifndef NO_FindWindowW
+JNIEXPORT jint JNICALL OS_NATIVE(FindWindowW)
+ (JNIEnv *env, jclass that, jcharArray arg0, jcharArray arg1)
+{
+ jchar *lparg0=NULL;
+ jchar *lparg1=NULL;
+ jint rc;
+
+ DEBUG_CALL("FindWindowW\n")
+
+ if (arg0) lparg0 = (*env)->GetCharArrayElements(env, arg0, NULL);
+ if (arg1) lparg1 = (*env)->GetCharArrayElements(env, arg1, NULL);
+ rc = (jint)FindWindowW((LPWSTR)lparg0, (LPWSTR)lparg1);
+ if (arg0) (*env)->ReleaseCharArrayElements(env, arg0, lparg0, 0);
+ if (arg1) (*env)->ReleaseCharArrayElements(env, arg1, lparg1, 0);
+ return rc;
+}
+#endif /* NO_FindWindowW */
+
+#ifndef NO_FreeLibrary
+JNIEXPORT jboolean JNICALL OS_NATIVE(FreeLibrary)
+ (JNIEnv *env, jclass that, jint arg0)
+{
+ DEBUG_CALL("FreeLibrary\n")
+
+ return (jboolean)FreeLibrary((HMODULE)arg0);
+}
+#endif /* NO_FreeLibrary */
+
+#ifndef NO_GetACP
+JNIEXPORT jint JNICALL OS_NATIVE(GetACP)
+ (JNIEnv *env, jclass that)
+{
+ DEBUG_CALL("GetACP\n")
+
+ return (jint)GetACP();
+}
+#endif /* NO_GetACP */
+
+#ifndef NO_GetActiveWindow
+JNIEXPORT jint JNICALL OS_NATIVE(GetActiveWindow)
+ (JNIEnv *env, jclass that)
+{
+ DEBUG_CALL("GetActiveWindow\n")
+
+ return (jint)GetActiveWindow();
+}
+#endif /* NO_GetActiveWindow */
+
+#ifndef NO_GetBkColor
+JNIEXPORT jint JNICALL OS_NATIVE(GetBkColor)
+ (JNIEnv *env, jclass that, jint arg0)
+{
+ DEBUG_CALL("GetBkColor\n")
+
+ return (jint)GetBkColor((HDC)arg0);
+}
+#endif /* NO_GetBkColor */
+
+#ifndef NO_GetCapture
+JNIEXPORT jint JNICALL OS_NATIVE(GetCapture)
+ (JNIEnv *env, jclass that)
+{
+ DEBUG_CALL("GetCapture\n")
+
+ return (jint)GetCapture();
+}
+#endif /* NO_GetCapture */
+
+#ifndef NO_GetCaretPos
+JNIEXPORT jboolean JNICALL OS_NATIVE(GetCaretPos)
+ (JNIEnv *env, jclass that, jobject arg0)
+{
+ POINT _arg0, *lparg0=NULL;
+ jboolean rc;
+
+ DEBUG_CALL("GetCaretPos\n")
+
+ if (arg0) lparg0 = getPOINTFields(env, arg0, &_arg0);
+ rc = (jboolean)GetCaretPos(lparg0);
+ if (arg0) setPOINTFields(env, arg0, lparg0);
+ return rc;
+}
+#endif /* NO_GetCaretPos */
+
+#ifndef NO_GetCharABCWidthsA
+JNIEXPORT jboolean JNICALL OS_NATIVE(GetCharABCWidthsA)
+ (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jintArray arg3)
+{
+ jint *lparg3=NULL;
+ jboolean rc;
+
+ DEBUG_CALL("GetCharABCWidthsA\n")
+
+ if (arg3) lparg3 = (*env)->GetIntArrayElements(env, arg3, NULL);
+ rc = (jboolean)GetCharABCWidthsA((HDC)arg0, arg1, arg2, (LPABC)lparg3);
+ if (arg3) (*env)->ReleaseIntArrayElements(env, arg3, lparg3, 0);
+ return rc;
+}
+#endif /* NO_GetCharABCWidthsA */
+
+#ifndef NO_GetCharABCWidthsW
+JNIEXPORT jboolean JNICALL OS_NATIVE(GetCharABCWidthsW)
+ (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jintArray arg3)
+{
+ jint *lparg3=NULL;
+ jboolean rc;
+
+ DEBUG_CALL("GetCharABCWidthsW\n")
+
+ if (arg3) lparg3 = (*env)->GetIntArrayElements(env, arg3, NULL);
+ rc = (jboolean)GetCharABCWidthsW((HDC)arg0, arg1, arg2, (LPABC)lparg3);
+ if (arg3) (*env)->ReleaseIntArrayElements(env, arg3, lparg3, 0);
+ return rc;
+}
+#endif /* NO_GetCharABCWidthsW */
+
+#ifndef NO_GetCharWidthA
+JNIEXPORT jboolean JNICALL OS_NATIVE(GetCharWidthA)
+ (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jintArray arg3)
+{
+ jint *lparg3=NULL;
+ jboolean rc;
+
+ DEBUG_CALL("GetCharWidthA\n")
+
+ if (arg3) lparg3 = (*env)->GetIntArrayElements(env, arg3, NULL);
+ rc = (jboolean)GetCharWidthA((HDC)arg0, arg1, arg2, (LPINT)lparg3);
+ if (arg3) (*env)->ReleaseIntArrayElements(env, arg3, lparg3, 0);
+ return rc;
+}
+#endif /* NO_GetCharWidthA */
+
+#ifndef NO_GetCharWidthW
+JNIEXPORT jboolean JNICALL OS_NATIVE(GetCharWidthW)
+ (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jintArray arg3)
+{
+ jint *lparg3=NULL;
+ jboolean rc;
+
+ DEBUG_CALL("GetCharWidthW\n")
+
+ if (arg3) lparg3 = (*env)->GetIntArrayElements(env, arg3, NULL);
+ rc = (jboolean)GetCharWidthW((HDC)arg0, arg1, arg2, (LPINT)lparg3);
+ if (arg3) (*env)->ReleaseIntArrayElements(env, arg3, lparg3, 0);
+ return rc;
+}
+#endif /* NO_GetCharWidthW */
+
+#ifndef NO_GetCharacterPlacementA
+JNIEXPORT jint JNICALL OS_NATIVE(GetCharacterPlacementA)
+ (JNIEnv *env, jclass that, jint arg0, jbyteArray arg1, jint arg2, jint arg3, jobject arg4, jint arg5)
+{
+ jbyte *lparg1=NULL;
+ GCP_RESULTS _arg4, *lparg4=NULL;
+ jint rc;
+
+ DEBUG_CALL("GetCharacterPlacementA\n")
+
+ if (arg1) lparg1 = (*env)->GetByteArrayElements(env, arg1, NULL);
+ if (arg4) lparg4 = getGCP_RESULTSFields(env, arg4, &_arg4);
+ rc = (jint)GetCharacterPlacementA((HDC)arg0, (LPSTR)lparg1, arg2, arg3, lparg4, arg5);
+ if (arg1) (*env)->ReleaseByteArrayElements(env, arg1, lparg1, 0);
+ if (arg4) setGCP_RESULTSFields(env, arg4, lparg4);
+ return rc;
+}
+#endif /* NO_GetCharacterPlacementA */
+
+#ifndef NO_GetCharacterPlacementW
+JNIEXPORT jint JNICALL OS_NATIVE(GetCharacterPlacementW)
+ (JNIEnv *env, jclass that, jint arg0, jcharArray arg1, jint arg2, jint arg3, jobject arg4, jint arg5)
+{
+ jchar *lparg1=NULL;
+ GCP_RESULTS _arg4, *lparg4=NULL;
+ jint rc;
+
+ DEBUG_CALL("GetCharacterPlacementW\n")
+
+ if (arg1) lparg1 = (*env)->GetCharArrayElements(env, arg1, NULL);
+ if (arg4) lparg4 = getGCP_RESULTSFields(env, arg4, &_arg4);
+ rc = (jint)GetCharacterPlacementW((HDC)arg0, (LPWSTR)lparg1, arg2, arg3, (LPGCP_RESULTSW)lparg4, arg5);
+ if (arg1) (*env)->ReleaseCharArrayElements(env, arg1, lparg1, 0);
+ if (arg4) setGCP_RESULTSFields(env, arg4, lparg4);
+ return rc;
+}
+#endif /* NO_GetCharacterPlacementW */
+
+#ifndef NO_GetClassInfoA
+JNIEXPORT jboolean JNICALL OS_NATIVE(GetClassInfoA)
+ (JNIEnv *env, jclass that, jint arg0, jbyteArray arg1, jobject arg2)
+{
+ jbyte *lparg1=NULL;
+ WNDCLASS _arg2, *lparg2=NULL;
+ jboolean rc;
+
+ DEBUG_CALL("GetClassInfoA\n")
+
+ if (arg1) lparg1 = (*env)->GetByteArrayElements(env, arg1, NULL);
+ if (arg2) lparg2 = getWNDCLASSFields(env, arg2, &_arg2);
+ rc = (jboolean)GetClassInfoA((HINSTANCE)arg0, (LPSTR)lparg1, lparg2);
+ if (arg1) (*env)->ReleaseByteArrayElements(env, arg1, lparg1, 0);
+ if (arg2) setWNDCLASSFields(env, arg2, lparg2);
+ return rc;
+}
+#endif /* NO_GetClassInfoA */
+
+#ifndef NO_GetClassInfoW
+JNIEXPORT jboolean JNICALL OS_NATIVE(GetClassInfoW)
+ (JNIEnv *env, jclass that, jint arg0, jcharArray arg1, jobject arg2)
+{
+ jchar *lparg1=NULL;
+ WNDCLASS _arg2, *lparg2=NULL;
+ jboolean rc;
+
+ DEBUG_CALL("GetClassInfoW\n")
+
+ if (arg1) lparg1 = (*env)->GetCharArrayElements(env, arg1, NULL);
+ if (arg2) lparg2 = getWNDCLASSFields(env, arg2, &_arg2);
+ rc = (jboolean)GetClassInfoW((HINSTANCE)arg0, (LPWSTR)lparg1, (LPWNDCLASSW)lparg2);
+ if (arg1) (*env)->ReleaseCharArrayElements(env, arg1, lparg1, 0);
+ if (arg2) setWNDCLASSFields(env, arg2, lparg2);
+ return rc;
+}
+#endif /* NO_GetClassInfoW */
+
+#ifndef NO_GetClientRect
+JNIEXPORT jboolean JNICALL OS_NATIVE(GetClientRect)
+ (JNIEnv *env, jclass that, jint arg0, jobject arg1)
+{
+ RECT _arg1, *lparg1=NULL;
+ jboolean rc;
+
+ DEBUG_CALL("GetClientRect\n")
+
+ if (arg1) lparg1 = getRECTFields(env, arg1, &_arg1);
+ rc = (jboolean)GetClientRect((HWND)arg0, lparg1);
+ if (arg1) setRECTFields(env, arg1, lparg1);
+ return rc;
+}
+#endif /* NO_GetClientRect */
+
+#ifndef NO_GetClipBox
+JNIEXPORT jint JNICALL OS_NATIVE(GetClipBox)
+ (JNIEnv *env, jclass that, jint arg0, jobject arg1)
+{
+ RECT _arg1, *lparg1=NULL;
+ jint rc;
+
+ DEBUG_CALL("GetClipBox\n")
+
+ if (arg1) lparg1 = getRECTFields(env, arg1, &_arg1);
+ rc = (jint)GetClipBox((HDC)arg0, lparg1);
+ if (arg1) setRECTFields(env, arg1, lparg1);
+ return rc;
+}
+#endif /* NO_GetClipBox */
+
+#ifndef NO_GetClipRgn
+JNIEXPORT jint JNICALL OS_NATIVE(GetClipRgn)
+ (JNIEnv *env, jclass that, jint arg0, jint arg1)
+{
+ DEBUG_CALL("GetClipRgn\n")
+
+ return (jint)GetClipRgn((HDC)arg0, (HRGN)arg1);
+}
+#endif /* NO_GetClipRgn */
+
+#ifndef NO_GetClipboardData
+JNIEXPORT jint JNICALL OS_NATIVE(GetClipboardData)
+ (JNIEnv *env, jclass that, jint arg0)
+{
+ DEBUG_CALL("GetClipboardData\n")
+
+ return (jint)GetClipboardData(arg0);
+}
+#endif /* NO_GetClipboardData */
+
+#ifndef NO_GetClipboardFormatNameA
+JNIEXPORT jint JNICALL OS_NATIVE(GetClipboardFormatNameA)
+ (JNIEnv *env, jclass that, jint arg0, jbyteArray arg1, jint arg2)
+{
+ jbyte *lparg1=NULL;
+ jint rc;
+
+ DEBUG_CALL("GetClipboardFormatNameA\n")
+
+ if (arg1) lparg1 = (*env)->GetByteArrayElements(env, arg1, NULL);
+ rc = (jint)GetClipboardFormatNameA(arg0, lparg1, arg2);
+ if (arg1) (*env)->ReleaseByteArrayElements(env, arg1, lparg1, 0);
+ return rc;
+}
+#endif /* NO_GetClipboardFormatNameA */
+
+#ifndef NO_GetClipboardFormatNameW
+JNIEXPORT jint JNICALL OS_NATIVE(GetClipboardFormatNameW)
+ (JNIEnv *env, jclass that, jint arg0, jcharArray arg1, jint arg2)
+{
+ jchar *lparg1=NULL;
+ jint rc;
+
+ DEBUG_CALL("GetClipboardFormatNameW\n")
+
+ if (arg1) lparg1 = (*env)->GetCharArrayElements(env, arg1, NULL);
+ rc = (jint)GetClipboardFormatNameW(arg0, (LPWSTR)lparg1, arg2);
+ if (arg1) (*env)->ReleaseCharArrayElements(env, arg1, lparg1, 0);
+ return rc;
+}
+#endif /* NO_GetClipboardFormatNameW */
+
+#ifndef NO_GetCurrentObject
+JNIEXPORT jint JNICALL OS_NATIVE(GetCurrentObject)
+ (JNIEnv *env, jclass that, jint arg0, jint arg1)
+{
+ DEBUG_CALL("GetCurrentObject\n")
+
+ return (jint)GetCurrentObject((HDC)arg0, arg1);
+}
+#endif /* NO_GetCurrentObject */
+
+#ifndef NO_GetCurrentProcessId
+JNIEXPORT jint JNICALL OS_NATIVE(GetCurrentProcessId)
+ (JNIEnv *env, jclass that)
+{
+ DEBUG_CALL("GetCurrentProcessId\n")
+
+ return (jint)GetCurrentProcessId();
+}
+#endif /* NO_GetCurrentProcessId */
+
+#ifndef NO_GetCurrentThreadId
+JNIEXPORT jint JNICALL OS_NATIVE(GetCurrentThreadId)
+ (JNIEnv *env, jclass that)
+{
+ DEBUG_CALL("GetCurrentThreadId\n")
+
+ return (jint)GetCurrentThreadId();
+}
+#endif /* NO_GetCurrentThreadId */
+
+#ifndef NO_GetCursor
+JNIEXPORT jint JNICALL OS_NATIVE(GetCursor)
+ (JNIEnv *env, jclass that)
+{
+ DEBUG_CALL("GetCursor\n")
+
+ return (jint)GetCursor();
+}
+#endif /* NO_GetCursor */
+
+#ifndef NO_GetCursorPos
+JNIEXPORT jboolean JNICALL OS_NATIVE(GetCursorPos)
+ (JNIEnv *env, jclass that, jobject arg0)
+{
+ POINT _arg0, *lparg0=NULL;
+ jboolean rc;
+
+ DEBUG_CALL("GetCursorPos\n")
+
+ if (arg0) lparg0 = getPOINTFields(env, arg0, &_arg0);
+ rc = (jboolean)GetCursorPos(lparg0);
+ if (arg0) setPOINTFields(env, arg0, lparg0);
+ return rc;
+}
+#endif /* NO_GetCursorPos */
+
+#ifndef NO_GetDC
+JNIEXPORT jint JNICALL OS_NATIVE(GetDC)
+ (JNIEnv *env, jclass that, jint arg0)
+{
+ DEBUG_CALL("GetDC\n")
+
+ return (jint)GetDC((HWND)arg0);
+}
+#endif /* NO_GetDC */
+
+#ifndef NO_GetDCEx
+JNIEXPORT jint JNICALL OS_NATIVE(GetDCEx)
+ (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2)
+{
+ DEBUG_CALL("GetDCEx\n")
+
+ return (jint)GetDCEx((HWND)arg0, (HRGN)arg1, arg2);
+}
+#endif /* NO_GetDCEx */
+
+#ifndef NO_GetDIBColorTable
+JNIEXPORT jint JNICALL OS_NATIVE(GetDIBColorTable)
+ (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jbyteArray arg3)
+{
+ jbyte *lparg3=NULL;
+ jint rc;
+
+ DEBUG_CALL("GetDIBColorTable\n")
+
+ if (arg3) lparg3 = (*env)->GetByteArrayElements(env, arg3, NULL);
+ rc = (jint)GetDIBColorTable((HDC)arg0, arg1, arg2, (RGBQUAD *)lparg3);
+ if (arg3) (*env)->ReleaseByteArrayElements(env, arg3, lparg3, 0);
+ return rc;
+}
+#endif /* NO_GetDIBColorTable */
+
+#ifndef NO_GetDIBits
+JNIEXPORT jint JNICALL OS_NATIVE(GetDIBits)
+ (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jint arg3, jint arg4, jbyteArray arg5, jint arg6)
+{
+ jbyte *lparg5=NULL;
+ jint rc;
+
+ DEBUG_CALL("GetDIBits\n")
+
+ if (arg5) lparg5 = (*env)->GetByteArrayElements(env, arg5, NULL);
+ rc = (jint)GetDIBits((HDC)arg0, (HBITMAP)arg1, arg2, arg3, (LPVOID)arg4, (LPBITMAPINFO)lparg5, arg6);
+ if (arg5) (*env)->ReleaseByteArrayElements(env, arg5, lparg5, 0);
+ return rc;
+}
+#endif /* NO_GetDIBits */
+
+#ifndef NO_GetDesktopWindow
+JNIEXPORT jint JNICALL OS_NATIVE(GetDesktopWindow)
+ (JNIEnv *env, jclass that)
+{
+ DEBUG_CALL("GetDesktopWindow\n")
+
+ return (jint)GetDesktopWindow();
+}
+#endif /* NO_GetDesktopWindow */
+
+#ifndef NO_GetDeviceCaps
+JNIEXPORT jint JNICALL OS_NATIVE(GetDeviceCaps)
+ (JNIEnv *env, jclass that, jint arg0, jint arg1)
+{
+ DEBUG_CALL("GetDeviceCaps\n")
+
+ return (jint)GetDeviceCaps((HDC)arg0, arg1);
+}
+#endif /* NO_GetDeviceCaps */
+
+#ifndef NO_GetDialogBaseUnits
+JNIEXPORT jint JNICALL OS_NATIVE(GetDialogBaseUnits)
+ (JNIEnv *env, jclass that)
+{
+ DEBUG_CALL("GetDialogBaseUnits\n")
+
+ return (jint)GetDialogBaseUnits();
+}
+#endif /* NO_GetDialogBaseUnits */
+
+#ifndef NO_GetDlgItem
+JNIEXPORT jint JNICALL OS_NATIVE(GetDlgItem)
+ (JNIEnv *env, jclass that, jint arg0, jint arg1)
+{
+ DEBUG_CALL("GetDlgItem\n")
+
+ return (jint)GetDlgItem((HWND)arg0, arg1);
+}
+#endif /* NO_GetDlgItem */
+
+#ifndef NO_GetDoubleClickTime
+JNIEXPORT jint JNICALL OS_NATIVE(GetDoubleClickTime)
+ (JNIEnv *env, jclass that)
+{
+ DEBUG_CALL("GetDoubleClickTime\n")
+
+ return (jint)GetDoubleClickTime();
+}
+#endif /* NO_GetDoubleClickTime */
+
+#ifndef NO_GetFocus
+JNIEXPORT jint JNICALL OS_NATIVE(GetFocus)
+ (JNIEnv *env, jclass that)
+{
+ DEBUG_CALL("GetFocus\n")
+
+ return (jint)GetFocus();
+}
+#endif /* NO_GetFocus */
+
+#ifndef NO_GetFontLanguageInfo
+JNIEXPORT jint JNICALL OS_NATIVE(GetFontLanguageInfo)
+ (JNIEnv *env, jclass that, jint arg0)
+{
+ DEBUG_CALL("GetFontLanguageInfo\n")
+
+ return (jint)GetFontLanguageInfo((HDC)arg0);
+}
+#endif /* NO_GetFontLanguageInfo */
+
+#ifndef NO_GetIconInfo
+JNIEXPORT jboolean JNICALL OS_NATIVE(GetIconInfo)
+ (JNIEnv *env, jclass that, jint arg0, jobject arg1)
+{
+ ICONINFO _arg1, *lparg1=NULL;
+ jboolean rc;
+
+ DEBUG_CALL("GetIconInfo\n")
+
+ if (arg1) lparg1 = getICONINFOFields(env, arg1, &_arg1);
+ rc = (jboolean)GetIconInfo((HICON)arg0, lparg1);
+ if (arg1) setICONINFOFields(env, arg1, lparg1);
+ return rc;
+}
+#endif /* NO_GetIconInfo */
+
+#ifndef NO_GetKeyState
+JNIEXPORT jshort JNICALL OS_NATIVE(GetKeyState)
+ (JNIEnv *env, jclass that, jint arg0)
+{
+ DEBUG_CALL("GetKeyState\n")
+
+ return (jshort)GetKeyState(arg0);
+}
+#endif /* NO_GetKeyState */
+
+#ifndef NO_GetKeyboardLayout
+JNIEXPORT jint JNICALL OS_NATIVE(GetKeyboardLayout)
+ (JNIEnv *env, jclass that, jint arg0)
+{
+ DEBUG_CALL("GetKeyboardLayout\n")
+
+ return (jint)GetKeyboardLayout(arg0);
+}
+#endif /* NO_GetKeyboardLayout */
+
+#ifndef NO_GetKeyboardLayoutList
+JNIEXPORT jint JNICALL OS_NATIVE(GetKeyboardLayoutList)
+ (JNIEnv *env, jclass that, jint arg0, jintArray arg1)
+{
+ jint *lparg1=NULL;
+ jint rc;
+
+ DEBUG_CALL("GetKeyboardLayoutList\n")
+
+ if (arg1) lparg1 = (*env)->GetIntArrayElements(env, arg1, NULL);
+ rc = (jint)GetKeyboardLayoutList(arg0, (HKL FAR *)lparg1);
+ if (arg1) (*env)->ReleaseIntArrayElements(env, arg1, lparg1, 0);
+ return rc;
+}
+#endif /* NO_GetKeyboardLayoutList */
+
+#ifndef NO_GetKeyboardState
+JNIEXPORT jboolean JNICALL OS_NATIVE(GetKeyboardState)
+ (JNIEnv *env, jclass that, jbyteArray arg0)
+{
+ jbyte *lparg0=NULL;
+ jboolean rc;
+
+ DEBUG_CALL("GetKeyboardState\n")
+
+ if (arg0) lparg0 = (*env)->GetByteArrayElements(env, arg0, NULL);
+ rc = (jboolean)GetKeyboardState((PBYTE)lparg0);
+ if (arg0) (*env)->ReleaseByteArrayElements(env, arg0, lparg0, 0);
+ return rc;
+}
+#endif /* NO_GetKeyboardState */
+
+#ifndef NO_GetKeyNameTextA
+JNIEXPORT jint JNICALL OS_NATIVE(GetKeyNameTextA)
+ (JNIEnv *env, jclass that, jint arg0, jbyteArray arg1, jint arg2)
+{
+ jbyte *lparg1=NULL;
+ jint rc;
+
+ DEBUG_CALL("GetKeyNameTextA\n")
+
+ if (arg1) lparg1 = (*env)->GetByteArrayElements(env, arg1, NULL);
+ rc = (jint)GetKeyNameTextA(arg0, (LPSTR)lparg1, arg2);
+ if (arg1) (*env)->ReleaseByteArrayElements(env, arg1, lparg1, 0);
+ return rc;
+}
+#endif /* NO_GetKeyNameTextA */
+
+#ifndef NO_GetKeyNameTextW
+JNIEXPORT jint JNICALL OS_NATIVE(GetKeyNameTextW)
+ (JNIEnv *env, jclass that, jint arg0, jcharArray arg1, jint arg2)
+{
+ jchar *lparg1=NULL;
+ jint rc;
+
+ DEBUG_CALL("GetKeyNameTextW\n")
+
+ if (arg1) lparg1 = (*env)->GetCharArrayElements(env, arg1, NULL);
+ rc = (jint)GetKeyNameTextW(arg0, (LPWSTR)lparg1, arg2);
+ if (arg1) (*env)->ReleaseCharArrayElements(env, arg1, lparg1, 0);
+ return rc;
+}
+#endif /* NO_GetKeyNameTextW */
+
+#ifndef NO_GetLastActivePopup
+JNIEXPORT jint JNICALL OS_NATIVE(GetLastActivePopup)
+ (JNIEnv *env, jclass that, jint arg0)
+{
+ DEBUG_CALL("GetLastActivePopup\n")
+
+ return (jint)GetLastActivePopup((HWND)arg0);
+}
+#endif /* NO_GetLastActivePopup */
+
+#ifndef NO_GetLastError
+JNIEXPORT jint JNICALL OS_NATIVE(GetLastError)
+ (JNIEnv *env, jclass that)
+{
+ DEBUG_CALL("GetLastError\n")
+
+ return (jint)GetLastError();
+}
+#endif /* NO_GetLastError */
+
+#ifndef NO_GetLibraryHandle
+JNIEXPORT jint JNICALL OS_NATIVE(GetLibraryHandle)
+ (JNIEnv *env, jclass that)
+{
+ DEBUG_CALL("GetLibraryHandle\n")
+
+ return (jint)g_hInstance;
+}
+#endif /* NO_GetLibraryHandle */
+
+#ifndef NO_GetLocaleInfoA
+JNIEXPORT jint JNICALL OS_NATIVE(GetLocaleInfoA)
+ (JNIEnv *env, jclass that, jint arg0, jint arg1, jbyteArray arg2, jint arg3)
+{
+ jbyte *lparg2=NULL;
+ jint rc;
+
+ DEBUG_CALL("GetLocaleInfoA\n")
+
+ if (arg2) lparg2 = (*env)->GetByteArrayElements(env, arg2, NULL);
+ rc = (jint)GetLocaleInfoA(arg0, arg1, (LPSTR)lparg2, arg3);
+ if (arg2) (*env)->ReleaseByteArrayElements(env, arg2, lparg2, 0);
+ return rc;
+}
+#endif /* NO_GetLocaleInfoA */
+
+#ifndef NO_GetLocaleInfoW
+JNIEXPORT jint JNICALL OS_NATIVE(GetLocaleInfoW)
+ (JNIEnv *env, jclass that, jint arg0, jint arg1, jcharArray arg2, jint arg3)
+{
+ jchar *lparg2=NULL;
+ jint rc;
+
+ DEBUG_CALL("GetLocaleInfoW\n")
+
+ if (arg2) lparg2 = (*env)->GetCharArrayElements(env, arg2, NULL);
+ rc = (jint)GetLocaleInfoW(arg0, arg1, (LPWSTR)lparg2, arg3);
+ if (arg2) (*env)->ReleaseCharArrayElements(env, arg2, lparg2, 0);
+ return rc;
+}
+#endif /* NO_GetLocaleInfoW */
+
+#ifndef NO_GetMenu
+JNIEXPORT jint JNICALL OS_NATIVE(GetMenu)
+ (JNIEnv *env, jclass that, jint arg0)
+{
+ DEBUG_CALL("GetMenu\n")
+
+ return (jint)GetMenu((HWND)arg0);
+}
+#endif /* NO_GetMenu */
+
+#ifndef NO_GetMenuDefaultItem
+JNIEXPORT jint JNICALL OS_NATIVE(GetMenuDefaultItem)
+ (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2)
+{
+ DEBUG_CALL("GetMenuDefaultItem\n")
+
+ return (jint)GetMenuDefaultItem((HMENU)arg0, arg1, arg2);
+}
+#endif /* NO_GetMenuDefaultItem */
+
+#ifndef NO_GetMenuInfo
+JNIEXPORT jboolean JNICALL OS_NATIVE(GetMenuInfo)
+ (JNIEnv *env, jclass that, jint arg0, jobject arg1)
+{
+ MENUINFO _arg1, *lparg1=NULL;
+ jboolean rc = (jboolean)FALSE;
+ HMODULE hm;
+ FARPROC fp;
+
+ DEBUG_CALL("GetMenuInfo\n")
+
+ /* SPECIAL */
+ /*
+ * 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 (arg1) lparg1 = getMENUINFOFields(env, arg1, &_arg1);
+
+ rc = (jboolean) (fp)((HMENU)arg0, lparg1);
+// rc = (jboolean)GetMenuInfo(arg0, lparg1);
+
+ if (arg1) setMENUINFOFields(env, arg1, lparg1);
+ }
+
+ return rc;
+}
+#endif /* NO_GetMenuInfo */
+
+#ifndef NO_GetMenuItemCount
+JNIEXPORT jint JNICALL OS_NATIVE(GetMenuItemCount)
+ (JNIEnv *env, jclass that, jint arg0)
+{
+ DEBUG_CALL("GetMenuItemCount\n")
+
+ return (jint)GetMenuItemCount((HMENU)arg0);
+}
+#endif /* NO_GetMenuItemCount */
+
+#ifndef NO_GetMenuItemInfoA
+JNIEXPORT jboolean JNICALL OS_NATIVE(GetMenuItemInfoA)
+ (JNIEnv *env, jclass that, jint arg0, jint arg1, jboolean arg2, jobject arg3)
+{
+ MENUITEMINFO _arg3, *lparg3=NULL;
+ jboolean rc;
+
+ DEBUG_CALL("GetMenuItemInfoA\n")
+
+ if (arg3) lparg3 = getMENUITEMINFOFields(env, arg3, &_arg3);
+ rc = (jboolean)GetMenuItemInfoA((HMENU)arg0, arg1, arg2, lparg3);
+ if (arg3) setMENUITEMINFOFields(env, arg3, lparg3);
+ return rc;
+}
+#endif /* NO_GetMenuItemInfoA */
+
+#ifndef NO_GetMenuItemInfoW
+JNIEXPORT jboolean JNICALL OS_NATIVE(GetMenuItemInfoW)
+ (JNIEnv *env, jclass that, jint arg0, jint arg1, jboolean arg2, jobject arg3)
+{
+ MENUITEMINFO _arg3, *lparg3=NULL;
+ jboolean rc;
+
+ DEBUG_CALL("GetMenuItemInfoW\n")
+
+ if (arg3) lparg3 = getMENUITEMINFOFields(env, arg3, &_arg3);
+ rc = (jboolean)GetMenuItemInfoW((HMENU)arg0, arg1, arg2, (LPMENUITEMINFOW)lparg3);
+ if (arg3) setMENUITEMINFOFields(env, arg3, lparg3);
+ return rc;
+}
+#endif /* NO_GetMenuItemInfoW */
+
+#ifndef NO_GetMessageA
+JNIEXPORT jboolean JNICALL OS_NATIVE(GetMessageA)
+ (JNIEnv *env, jclass that, jobject arg0, jint arg1, jint arg2, jint arg3)
+{
+ MSG _arg0, *lparg0=NULL;
+ jboolean rc;
+
+ DEBUG_CALL("GetMessageA\n")
+
+ if (arg0) lparg0 = getMSGFields(env, arg0, &_arg0);
+ rc = (jboolean)GetMessageA(lparg0, (HWND)arg1, arg2, arg3);
+ if (arg0) setMSGFields(env, arg0, lparg0);
+ return rc;
+}
+#endif /* NO_GetMessageA */
+
+#ifndef NO_GetMessagePos
+JNIEXPORT jint JNICALL OS_NATIVE(GetMessagePos)
+ (JNIEnv *env, jclass that)
+{
+ DEBUG_CALL("GetMessagePos\n")
+
+ return (jint)GetMessagePos();
+}
+#endif /* NO_GetMessagePos */
+
+#ifndef NO_GetMessageTime
+JNIEXPORT jint JNICALL OS_NATIVE(GetMessageTime)
+ (JNIEnv *env, jclass that)
+{
+ DEBUG_CALL("GetMessageTime\n")
+
+ return (jint)GetMessageTime();
+}
+#endif /* NO_GetMessageTime */
+
+#ifndef NO_GetMessageW
+JNIEXPORT jboolean JNICALL OS_NATIVE(GetMessageW)
+ (JNIEnv *env, jclass that, jobject arg0, jint arg1, jint arg2, jint arg3)
+{
+ MSG _arg0, *lparg0=NULL;
+ jboolean rc;
+
+ DEBUG_CALL("GetMessageW\n")
+
+ if (arg0) lparg0 = getMSGFields(env, arg0, &_arg0);
+ rc = (jboolean)GetMessageW(lparg0, (HWND)arg1, arg2, arg3);
+ if (arg0) setMSGFields(env, arg0, lparg0);
+ return rc;
+}
+#endif /* NO_GetMessageW */
+
+#ifndef NO_GetModuleHandleA
+JNIEXPORT jint JNICALL OS_NATIVE(GetModuleHandleA)
+ (JNIEnv *env, jclass that, jbyteArray arg0)
+{
+ jbyte *lparg0=NULL;
+ jint rc;
+
+ DEBUG_CALL("GetModuleHandleA\n")
+
+ if (arg0) lparg0 = (*env)->GetByteArrayElements(env, arg0, NULL);
+ rc = (jint)GetModuleHandleA((LPSTR)lparg0);
+ if (arg0) (*env)->ReleaseByteArrayElements(env, arg0, lparg0, 0);
+ return rc;
+}
+#endif /* NO_GetModuleHandleA */
+
+#ifndef NO_GetModuleHandleW
+JNIEXPORT jint JNICALL OS_NATIVE(GetModuleHandleW)
+ (JNIEnv *env, jclass that, jcharArray arg0)
+{
+ jchar *lparg0=NULL;
+ jint rc;
+
+ DEBUG_CALL("GetModuleHandleW\n")
+
+ if (arg0) lparg0 = (*env)->GetCharArrayElements(env, arg0, NULL);
+ rc = (jint)GetModuleHandleW((LPWSTR)lparg0);
+ if (arg0) (*env)->ReleaseCharArrayElements(env, arg0, lparg0, 0);
+ return rc;
+}
+#endif /* NO_GetModuleHandleW */
+
+#ifndef NO_GetNearestPaletteIndex
+JNIEXPORT jint JNICALL OS_NATIVE(GetNearestPaletteIndex)
+ (JNIEnv *env, jclass that, jint arg0, jint arg1)
+{
+ DEBUG_CALL("GetNearestPaletteIndex\n")
+
+ return (jint)GetNearestPaletteIndex((HPALETTE)arg0, (COLORREF)arg1);
+}
+#endif /* NO_GetNearestPaletteIndex */
+
+#ifndef NO_GetObjectA__IILorg_eclipse_swt_internal_win32_LOGFONT_2
+JNIEXPORT jint JNICALL OS_NATIVE(GetObjectA__IILorg_eclipse_swt_internal_win32_LOGFONT_2)
+ (JNIEnv *env, jclass that, jint arg0, jint arg1, jobject arg2)
+{
+ LOGFONT _arg2, *lparg2=NULL;
+ jint rc;
+
+ DEBUG_CALL("GetObjectA__IILorg_eclipse_swt_internal_win32_LOGFONT_2\n")
+
+ if (arg2) lparg2 = getLOGFONTAFields(env, arg2, &_arg2);
+ rc = (jint)GetObjectA((HGDIOBJ)arg0, arg1, lparg2);
+ if (arg2) setLOGFONTAFields(env, arg2, lparg2);
+ return rc;
+}
+#endif /* NO_GetObjectA__IILorg_eclipse_swt_internal_win32_LOGFONT_2 */
+
+#ifndef NO_GetObjectA__IILorg_eclipse_swt_internal_win32_BITMAP_2
+JNIEXPORT jint JNICALL OS_NATIVE(GetObjectA__IILorg_eclipse_swt_internal_win32_BITMAP_2)
+ (JNIEnv *env, jclass that, jint arg0, jint arg1, jobject arg2)
+{
+ BITMAP _arg2, *lparg2=NULL;
+ jint rc;
+
+ DEBUG_CALL("GetObjectA__IILorg_eclipse_swt_internal_win32_BITMAP_2\n")
+
+ if (arg2) lparg2 = getBITMAPFields(env, arg2, &_arg2);
+ rc = (jint)GetObjectA((HGDIOBJ)arg0, arg1, lparg2);
+ if (arg2) setBITMAPFields(env, arg2, lparg2);
+ return rc;
+}
+#endif /* NO_GetObjectA__IILorg_eclipse_swt_internal_win32_BITMAP_2 */
+
+#ifndef NO_GetObjectA__IILorg_eclipse_swt_internal_win32_DIBSECTION_2
+JNIEXPORT jint JNICALL OS_NATIVE(GetObjectA__IILorg_eclipse_swt_internal_win32_DIBSECTION_2)
+ (JNIEnv *env, jclass that, jint arg0, jint arg1, jobject arg2)
+{
+ DIBSECTION _arg2, *lparg2=NULL;
+ jint rc;
+
+ DEBUG_CALL("GetObjectA__IILorg_eclipse_swt_internal_win32_DIBSECTION_2\n")
+
+ if (arg2) lparg2 = getDIBSECTIONFields(env, arg2, &_arg2);
+ rc = (jint)GetObjectA((HGDIOBJ)arg0, arg1, lparg2);
+ if (arg2) setDIBSECTIONFields(env, arg2, lparg2);
+ return rc;
+}
+#endif /* NO_GetObjectA__IILorg_eclipse_swt_internal_win32_DIBSECTION_2 */
+
+#ifndef NO_GetObjectA__IILorg_eclipse_swt_internal_win32_LOGPEN_2
+JNIEXPORT jint JNICALL OS_NATIVE(GetObjectA__IILorg_eclipse_swt_internal_win32_LOGPEN_2)
+ (JNIEnv *env, jclass that, jint arg0, jint arg1, jobject arg2)
+{
+ LOGPEN _arg2, *lparg2=NULL;
+ jint rc;
+
+ DEBUG_CALL("GetObjectA__IILorg_eclipse_swt_internal_win32_LOGPEN_2\n")
+
+ if (arg2) lparg2 = getLOGPENFields(env, arg2, &_arg2);
+ rc = (jint)GetObjectA((HGDIOBJ)arg0, arg1, lparg2);
+ if (arg2) setLOGPENFields(env, arg2, lparg2);
+ return rc;
+}
+#endif /* NO_GetObjectA__IILorg_eclipse_swt_internal_win32_LOGPEN_2 */
+
+#ifndef NO_GetObjectA__IILorg_eclipse_swt_internal_win32_LOGBRUSH_2
+JNIEXPORT jint JNICALL OS_NATIVE(GetObjectA__IILorg_eclipse_swt_internal_win32_LOGBRUSH_2)
+ (JNIEnv *env, jclass that, jint arg0, jint arg1, jobject arg2)
+{
+ LOGBRUSH _arg2, *lparg2=NULL;
+ jint rc;
+
+ DEBUG_CALL("GetObjectA__IILorg_eclipse_swt_internal_win32_LOGBRUSH_2\n")
+
+ if (arg2) lparg2 = getLOGBRUSHFields(env, arg2, &_arg2);
+ rc = (jint)GetObjectA((HGDIOBJ)arg0, arg1, lparg2);
+ if (arg2) setLOGBRUSHFields(env, arg2, lparg2);
+ return rc;
+}
+#endif /* NO_GetObjectA__IILorg_eclipse_swt_internal_win32_LOGBRUSH_2 */
+
+#ifndef NO_GetObjectW__IILorg_eclipse_swt_internal_win32_BITMAP_2
+JNIEXPORT jint JNICALL OS_NATIVE(GetObjectW__IILorg_eclipse_swt_internal_win32_BITMAP_2)
+ (JNIEnv *env, jclass that, jint arg0, jint arg1, jobject arg2)
+{
+ BITMAP _arg2, *lparg2=NULL;
+ jint rc;
+
+ DEBUG_CALL("GetObjectW__IILorg_eclipse_swt_internal_win32_BITMAP_2\n")
+
+ if (arg2) lparg2 = getBITMAPFields(env, arg2, &_arg2);
+ rc = (jint)GetObjectW((HGDIOBJ)arg0, arg1, lparg2);
+ if (arg2) setBITMAPFields(env, arg2, lparg2);
+ return rc;
+}
+#endif /* NO_GetObjectW__IILorg_eclipse_swt_internal_win32_BITMAP_2 */
+
+#ifndef NO_GetObjectW__IILorg_eclipse_swt_internal_win32_LOGBRUSH_2
+JNIEXPORT jint JNICALL OS_NATIVE(GetObjectW__IILorg_eclipse_swt_internal_win32_LOGBRUSH_2)
+ (JNIEnv *env, jclass that, jint arg0, jint arg1, jobject arg2)
+{
+ LOGBRUSH _arg2, *lparg2=NULL;
+ jint rc;
+
+ DEBUG_CALL("GetObjectW__IILorg_eclipse_swt_internal_win32_LOGBRUSH_2\n")
+
+ if (arg2) lparg2 = getLOGBRUSHFields(env, arg2, &_arg2);
+ rc = (jint)GetObjectW((HGDIOBJ)arg0, arg1, lparg2);
+ if (arg2) setLOGBRUSHFields(env, arg2, lparg2);
+ return rc;
+}
+#endif /* NO_GetObjectW__IILorg_eclipse_swt_internal_win32_LOGBRUSH_2 */
+
+#ifndef NO_GetObjectW__IILorg_eclipse_swt_internal_win32_LOGFONT_2
+JNIEXPORT jint JNICALL OS_NATIVE(GetObjectW__IILorg_eclipse_swt_internal_win32_LOGFONT_2)
+ (JNIEnv *env, jclass that, jint arg0, jint arg1, jobject arg2)
+{
+ LOGFONTW _arg2, *lparg2=NULL;
+ jint rc;
+
+ DEBUG_CALL("GetObjectW__IILorg_eclipse_swt_internal_win32_LOGFONT_2\n")
+
+ if (arg2) lparg2 = getLOGFONTWFields(env, arg2, &_arg2);
+ rc = (jint)GetObjectW((HGDIOBJ)arg0, arg1, lparg2);
+ if (arg2) setLOGFONTWFields(env, arg2, lparg2);
+ return rc;
+}
+#endif /* NO_GetObjectW__IILorg_eclipse_swt_internal_win32_LOGFONT_2 */
+
+#ifndef NO_GetObjectW__IILorg_eclipse_swt_internal_win32_DIBSECTION_2
+JNIEXPORT jint JNICALL OS_NATIVE(GetObjectW__IILorg_eclipse_swt_internal_win32_DIBSECTION_2)
+ (JNIEnv *env, jclass that, jint arg0, jint arg1, jobject arg2)
+{
+ DIBSECTION _arg2, *lparg2=NULL;
+ jint rc;
+
+ DEBUG_CALL("GetObjectW__IILorg_eclipse_swt_internal_win32_DIBSECTION_2\n")
+
+ if (arg2) lparg2 = getDIBSECTIONFields(env, arg2, &_arg2);
+ rc = (jint)GetObjectW((HGDIOBJ)arg0, arg1, lparg2);
+ if (arg2) setDIBSECTIONFields(env, arg2, lparg2);
+ return rc;
+}
+#endif /* NO_GetObjectW__IILorg_eclipse_swt_internal_win32_DIBSECTION_2 */
+
+#ifndef NO_GetObjectW__IILorg_eclipse_swt_internal_win32_LOGPEN_2
+JNIEXPORT jint JNICALL OS_NATIVE(GetObjectW__IILorg_eclipse_swt_internal_win32_LOGPEN_2)
+ (JNIEnv *env, jclass that, jint arg0, jint arg1, jobject arg2)
+{
+ LOGPEN _arg2, *lparg2=NULL;
+ jint rc;
+
+ DEBUG_CALL("GetObjectW__IILorg_eclipse_swt_internal_win32_LOGPEN_2\n")
+
+ if (arg2) lparg2 = getLOGPENFields(env, arg2, &_arg2);
+ rc = (jint)GetObjectW((HGDIOBJ)arg0, arg1, lparg2);
+ if (arg2) setLOGPENFields(env, arg2, lparg2);
+ return rc;
+}
+#endif /* NO_GetObjectW__IILorg_eclipse_swt_internal_win32_LOGPEN_2 */
+
+#ifndef NO_GetOpenFileNameA
+JNIEXPORT jboolean JNICALL OS_NATIVE(GetOpenFileNameA)
+ (JNIEnv *env, jclass that, jobject arg0)
+{
+ OPENFILENAME _arg0, *lparg0=NULL;
+ jboolean rc;
+
+ DEBUG_CALL("GetOpenFileNameA\n")
+
+ if (arg0) lparg0 = getOPENFILENAMEFields(env, arg0, &_arg0);
+ rc = (jboolean)GetOpenFileNameA(lparg0);
+ if (arg0) setOPENFILENAMEFields(env, arg0, lparg0);
+ return rc;
+}
+#endif /* NO_GetOpenFileNameA */
+
+#ifndef NO_GetOpenFileNameW
+JNIEXPORT jboolean JNICALL OS_NATIVE(GetOpenFileNameW)
+ (JNIEnv *env, jclass that, jobject arg0)
+{
+ OPENFILENAME _arg0, *lparg0=NULL;
+ jboolean rc;
+
+ DEBUG_CALL("GetOpenFileNameW\n")
+
+ if (arg0) lparg0 = getOPENFILENAMEFields(env, arg0, &_arg0);
+ rc = (jboolean)GetOpenFileNameW((LPOPENFILENAMEW)lparg0);
+ if (arg0) setOPENFILENAMEFields(env, arg0, lparg0);
+ return rc;
+}
+#endif /* NO_GetOpenFileNameW */
+
+#ifndef NO_GetPaletteEntries
+JNIEXPORT jint JNICALL OS_NATIVE(GetPaletteEntries)
+ (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jbyteArray arg3)
+{
+ jbyte *lparg3=NULL;
+ jint rc;
+
+ DEBUG_CALL("GetPaletteEntries\n")
+
+ if (arg3) lparg3 = (*env)->GetByteArrayElements(env, arg3, NULL);
+ rc = (jint)GetPaletteEntries((HPALETTE)arg0, arg1, arg2, (LPPALETTEENTRY)lparg3);
+ if (arg3) (*env)->ReleaseByteArrayElements(env, arg3, lparg3, 0);
+ return rc;
+}
+#endif /* NO_GetPaletteEntries */
+
+#ifndef NO_GetParent
+JNIEXPORT jint JNICALL OS_NATIVE(GetParent)
+ (JNIEnv *env, jclass that, jint arg0)
+{
+ DEBUG_CALL("GetParent\n")
+
+ return (jint)GetParent((HWND)arg0);
+}
+#endif /* NO_GetParent */
+
+#ifndef NO_GetPixel
+JNIEXPORT jint JNICALL OS_NATIVE(GetPixel)
+ (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2)
+{
+ DEBUG_CALL("GetPixel\n")
+
+ return (jint)GetPixel((HDC)arg0, arg1, arg2);
+}
+#endif /* NO_GetPixel */
+
+#ifndef NO_GetProcAddress
+JNIEXPORT jint JNICALL OS_NATIVE(GetProcAddress)
+ (JNIEnv *env, jclass that, jint arg0, jbyteArray arg1)
+{
+ jbyte *lparg1=NULL;
+ jint rc;
+
+ DEBUG_CALL("GetProcAddress\n")
+
+ if (arg1) lparg1 = (*env)->GetByteArrayElements(env, arg1, NULL);
+ rc = (jint)GetProcAddress((HMODULE)arg0, (LPCTSTR)lparg1);
+ if (arg1) (*env)->ReleaseByteArrayElements(env, arg1, lparg1, 0);
+ return rc;
+}
+#endif /* NO_GetProcAddress */
+
+#ifndef NO_GetProcessHeap
+JNIEXPORT jint JNICALL OS_NATIVE(GetProcessHeap)
+ (JNIEnv *env, jclass that)
+{
+ DEBUG_CALL("GetProcessHeap\n")
+
+ return (jint)GetProcessHeap();
+}
+#endif /* NO_GetProcessHeap */
+
+#ifndef NO_GetProfileStringA
+JNIEXPORT jint JNICALL OS_NATIVE(GetProfileStringA)
+ (JNIEnv *env, jclass that, jbyteArray arg0, jbyteArray arg1, jbyteArray arg2, jbyteArray arg3, jint arg4)
+{
+ jbyte *lparg0=NULL;
+ jbyte *lparg1=NULL;
+ jbyte *lparg2=NULL;
+ jbyte *lparg3=NULL;
+ jint rc;
+
+ DEBUG_CALL("GetProfileStringA\n")
+
+ if (arg0) lparg0 = (*env)->GetByteArrayElements(env, arg0, NULL);
+ if (arg1) lparg1 = (*env)->GetByteArrayElements(env, arg1, NULL);
+ if (arg2) lparg2 = (*env)->GetByteArrayElements(env, arg2, NULL);
+ if (arg3) lparg3 = (*env)->GetByteArrayElements(env, arg3, NULL);
+ rc = (jint)GetProfileStringA((LPSTR)lparg0, (LPSTR)lparg1, (LPSTR)lparg2, (LPSTR)lparg3, arg4);
+ if (arg0) (*env)->ReleaseByteArrayElements(env, arg0, lparg0, 0);
+ if (arg1) (*env)->ReleaseByteArrayElements(env, arg1, lparg1, 0);
+ if (arg2) (*env)->ReleaseByteArrayElements(env, arg2, lparg2, 0);
+ if (arg3) (*env)->ReleaseByteArrayElements(env, arg3, lparg3, 0);
+ return rc;
+}
+#endif /* NO_GetProfileStringA */
+
+#ifndef NO_GetProfileStringW
+JNIEXPORT jint JNICALL OS_NATIVE(GetProfileStringW)
+ (JNIEnv *env, jclass that, jcharArray arg0, jcharArray arg1, jcharArray arg2, jcharArray arg3, jint arg4)
+{
+ jchar *lparg0=NULL;
+ jchar *lparg1=NULL;
+ jchar *lparg2=NULL;
+ jchar *lparg3=NULL;
+ jint rc;
+
+ DEBUG_CALL("GetProfileStringW\n")
+
+ if (arg0) lparg0 = (*env)->GetCharArrayElements(env, arg0, NULL);
+ if (arg1) lparg1 = (*env)->GetCharArrayElements(env, arg1, NULL);
+ if (arg2) lparg2 = (*env)->GetCharArrayElements(env, arg2, NULL);
+ if (arg3) lparg3 = (*env)->GetCharArrayElements(env, arg3, NULL);
+ rc = (jint)GetProfileStringW((LPWSTR)lparg0, (LPWSTR)lparg1, (LPWSTR)lparg2, (LPWSTR)lparg3, arg4);
+ if (arg0) (*env)->ReleaseCharArrayElements(env, arg0, lparg0, 0);
+ if (arg1) (*env)->ReleaseCharArrayElements(env, arg1, lparg1, 0);
+ if (arg2) (*env)->ReleaseCharArrayElements(env, arg2, lparg2, 0);
+ if (arg3) (*env)->ReleaseCharArrayElements(env, arg3, lparg3, 0);
+ return rc;
+}
+#endif /* NO_GetProfileStringW */
+
+#ifndef NO_GetROP2
+JNIEXPORT jint JNICALL OS_NATIVE(GetROP2)
+ (JNIEnv *env, jclass that, jint arg0)
+{
+ DEBUG_CALL("GetROP2\n")
+
+ return (jint)GetROP2((HDC)arg0);
+}
+#endif /* NO_GetROP2 */
+
+#ifndef NO_GetRegionData
+JNIEXPORT jint JNICALL OS_NATIVE(GetRegionData)
+ (JNIEnv *env, jclass that, jint arg0, jint arg1, jintArray arg2)
+{
+ jint *lparg2=NULL;
+ jint rc;
+
+ DEBUG_CALL("GetRegionData\n")
+
+ if (arg2) lparg2 = (*env)->GetIntArrayElements(env, arg2, NULL);
+ rc = (jint)GetRegionData((HRGN)arg0, arg1, (RGNDATA *)lparg2);
+ if (arg2) (*env)->ReleaseIntArrayElements(env, arg2, lparg2, 0);
+ return rc;
+}
+#endif /* NO_GetRegionData */
+
+#ifndef NO_GetRgnBox
+JNIEXPORT jint JNICALL OS_NATIVE(GetRgnBox)
+ (JNIEnv *env, jclass that, jint arg0, jobject arg1)
+{
+ RECT _arg1, *lparg1=NULL;
+ jint rc;
+
+ DEBUG_CALL("GetRgnBox\n")
+
+ if (arg1) lparg1 = getRECTFields(env, arg1, &_arg1);
+ rc = (jint)GetRgnBox((HRGN)arg0, lparg1);
+ if (arg1) setRECTFields(env, arg1, lparg1);
+ return rc;
+}
+#endif /* NO_GetRgnBox */
+
+#ifndef NO_GetSaveFileNameA
+JNIEXPORT jboolean JNICALL OS_NATIVE(GetSaveFileNameA)
+ (JNIEnv *env, jclass that, jobject arg0)
+{
+ OPENFILENAME _arg0, *lparg0=NULL;
+ jboolean rc;
+
+ DEBUG_CALL("GetSaveFileNameA\n")
+
+ if (arg0) lparg0 = getOPENFILENAMEFields(env, arg0, &_arg0);
+ rc = (jboolean)GetSaveFileNameA(lparg0);
+ if (arg0) setOPENFILENAMEFields(env, arg0, lparg0);
+ return rc;
+}
+#endif /* NO_GetSaveFileNameA */
+
+#ifndef NO_GetSaveFileNameW
+JNIEXPORT jboolean JNICALL OS_NATIVE(GetSaveFileNameW)
+ (JNIEnv *env, jclass that, jobject arg0)
+{
+ OPENFILENAME _arg0, *lparg0=NULL;
+ jboolean rc;
+
+ DEBUG_CALL("GetSaveFileNameW\n")
+
+ if (arg0) lparg0 = getOPENFILENAMEFields(env, arg0, &_arg0);
+ rc = (jboolean)GetSaveFileNameW((LPOPENFILENAMEW)lparg0);
+ if (arg0) setOPENFILENAMEFields(env, arg0, lparg0);
+ return rc;
+}
+#endif /* NO_GetSaveFileNameW */
+
+#ifndef NO_GetScrollInfo
+JNIEXPORT jboolean JNICALL OS_NATIVE(GetScrollInfo)
+ (JNIEnv *env, jclass that, jint arg0, jint arg1, jobject arg2)
+{
+ SCROLLINFO _arg2, *lparg2=NULL;
+ jboolean rc;
+
+ DEBUG_CALL("GetScrollInfo\n")
+
+ if (arg2) lparg2 = getSCROLLINFOFields(env, arg2, &_arg2);
+ rc = (jboolean)GetScrollInfo((HWND)arg0, arg1, lparg2);
+ if (arg2) setSCROLLINFOFields(env, arg2, lparg2);
+ return rc;
+}
+#endif /* NO_GetScrollInfo */
+
+#ifndef NO_GetStockObject
+JNIEXPORT jint JNICALL OS_NATIVE(GetStockObject)
+ (JNIEnv *env, jclass that, jint arg0)
+{
+ DEBUG_CALL("GetStockObject\n")
+
+ return (jint)GetStockObject(arg0);
+}
+#endif /* NO_GetStockObject */
+
+#ifndef NO_GetSysColor
+JNIEXPORT jint JNICALL OS_NATIVE(GetSysColor)
+ (JNIEnv *env, jclass that, jint arg0)
+{
+ DEBUG_CALL("GetSysColor\n")
+
+ return (jint)GetSysColor(arg0);
+}
+#endif /* NO_GetSysColor */
+
+#ifndef NO_GetSysColorBrush
+JNIEXPORT jint JNICALL OS_NATIVE(GetSysColorBrush)
+ (JNIEnv *env, jclass that, jint arg0)
+{
+ DEBUG_CALL("GetSysColorBrush\n")
+
+ return (jint)GetSysColorBrush(arg0);
+}
+#endif /* NO_GetSysColorBrush */
+
+#ifndef NO_GetSystemMenu
+JNIEXPORT jint JNICALL OS_NATIVE(GetSystemMenu)
+ (JNIEnv *env, jclass that, jint arg0, jboolean arg1)
+{
+ DEBUG_CALL("GetSystemMenu\n")
+
+ return (jint)GetSystemMenu((HWND)arg0, arg1);
+}
+#endif /* NO_GetSystemMenu */
+
+#ifndef NO_GetSystemMetrics
+JNIEXPORT jint JNICALL OS_NATIVE(GetSystemMetrics)
+ (JNIEnv *env, jclass that, jint arg0)
+{
+ DEBUG_CALL("GetSystemMetrics\n")
+
+ return (jint)GetSystemMetrics(arg0);
+}
+#endif /* NO_GetSystemMetrics */
+
+#ifndef NO_GetSystemPaletteEntries
+JNIEXPORT jint JNICALL OS_NATIVE(GetSystemPaletteEntries)
+ (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jbyteArray arg3)
+{
+ jbyte *lparg3=NULL;
+ jint rc;
+
+ DEBUG_CALL("GetSystemPaletteEntries\n");
+
+ if (arg3) lparg3 = (*env)->GetByteArrayElements(env, arg3, NULL);
+ rc = GetSystemPaletteEntries((HDC)arg0, (UINT)arg1, (UINT)arg2, (LPPALETTEENTRY)lparg3);
+ if (arg3) (*env)->ReleaseByteArrayElements(env, arg3, lparg3, 0);
+ return rc;
+}
+#endif /* NO_GetSystemPaletteEntries */
+
+#ifndef NO_GetTextCharset
+JNIEXPORT jint JNICALL OS_NATIVE(GetTextCharset)
+ (JNIEnv *env, jclass that, jint arg0)
+{
+ DEBUG_CALL("GetTextCharset\n")
+
+ return (jint)GetTextCharset((HDC)arg0);
+}
+#endif /* NO_GetTextCharset */
+
+#ifndef NO_GetTextColor
+JNIEXPORT jint JNICALL OS_NATIVE(GetTextColor)
+ (JNIEnv *env, jclass that, jint arg0)
+{
+ DEBUG_CALL("GetTextColor\n")
+
+ return (jint)GetTextColor((HDC)arg0);
+}
+#endif /* NO_GetTextColor */
+
+#ifndef NO_GetTextExtentPoint32A
+JNIEXPORT jboolean JNICALL OS_NATIVE(GetTextExtentPoint32A)
+ (JNIEnv *env, jclass that, jint arg0, jbyteArray arg1, jint arg2, jobject arg3)
+{
+ jbyte *lparg1=NULL;
+ SIZE _arg3, *lparg3=NULL;
+ jboolean rc;
+
+ DEBUG_CALL("GetTextExtentPoint32A\n")
+
+ if (arg1) lparg1 = (*env)->GetByteArrayElements(env, arg1, NULL);
+ if (arg3) lparg3 = getSIZEFields(env, arg3, &_arg3);
+ rc = (jboolean)GetTextExtentPoint32A((HDC)arg0, (LPSTR)lparg1, arg2, lparg3);
+ if (arg1) (*env)->ReleaseByteArrayElements(env, arg1, lparg1, 0);
+ if (arg3) setSIZEFields(env, arg3, lparg3);
+ return rc;
+}
+#endif /* NO_GetTextExtentPoint32A */
+
+#ifndef NO_GetTextExtentPoint32W
+JNIEXPORT jboolean JNICALL OS_NATIVE(GetTextExtentPoint32W)
+ (JNIEnv *env, jclass that, jint arg0, jcharArray arg1, jint arg2, jobject arg3)
+{
+ jchar *lparg1=NULL;
+ SIZE _arg3, *lparg3=NULL;
+ jboolean rc;
+
+ DEBUG_CALL("GetTextExtentPoint32W\n")
+
+ if (arg1) lparg1 = (*env)->GetCharArrayElements(env, arg1, NULL);
+ if (arg3) lparg3 = getSIZEFields(env, arg3, &_arg3);
+ rc = (jboolean)GetTextExtentPoint32W((HDC)arg0, (LPWSTR)lparg1, arg2, lparg3);
+ if (arg1) (*env)->ReleaseCharArrayElements(env, arg1, lparg1, 0);
+ if (arg3) setSIZEFields(env, arg3, lparg3);
+ return rc;
+}
+#endif /* NO_GetTextExtentPoint32W */
+
+#ifndef NO_GetTextMetricsA
+JNIEXPORT jboolean JNICALL OS_NATIVE(GetTextMetricsA)
+ (JNIEnv *env, jclass that, jint arg0, jobject arg1)
+{
+ TEXTMETRICA _arg1={0}, *lparg1=NULL; /* SPECIAL */
+ jboolean rc;
+
+ DEBUG_CALL("GetTextMetricsA\n")
+
+ if (arg1) lparg1 = &_arg1;
+ rc = (jboolean)GetTextMetricsA((HDC)arg0, lparg1);
+ if (arg1) setTEXTMETRICAFields(env, arg1, lparg1);
+ return rc;
+}
+#endif /* NO_GetTextMetricsA */
+
+#ifndef NO_GetTextMetricsW
+JNIEXPORT jboolean JNICALL OS_NATIVE(GetTextMetricsW)
+ (JNIEnv *env, jclass that, jint arg0, jobject arg1)
+{
+ TEXTMETRICW _arg1={0}, *lparg1=NULL; /* SPECIAL */
+ jboolean rc;
+
+ DEBUG_CALL("GetTextMetricsW\n")
+
+ if (arg1) lparg1 = &_arg1;
+ rc = (jboolean)GetTextMetricsW((HDC)arg0, lparg1);
+ if (arg1) setTEXTMETRICWFields(env, arg1, lparg1);
+ return rc;
+}
+#endif /* NO_GetTextMetricsW */
+
+#ifndef NO_GetTickCount
+JNIEXPORT jint JNICALL OS_NATIVE(GetTickCount)
+ (JNIEnv *env, jclass that)
+{
+ DEBUG_CALL("GetTickCount\n")
+
+ return (jint)GetTickCount();
+}
+#endif /* NO_GetTickCount */
+
+#ifndef NO_GetUpdateRect
+JNIEXPORT jboolean JNICALL OS_NATIVE(GetUpdateRect)
+ (JNIEnv *env, jclass that, jint arg0, jobject arg1, jboolean arg2)
+{
+ RECT _arg1, *lparg1=NULL;
+ jboolean rc;
+
+ DEBUG_CALL("GetUpdateRect\n")
+
+ if (arg1) lparg1 = getRECTFields(env, arg1, &_arg1);
+ rc = (jboolean)GetUpdateRect((HWND)arg0, (LPRECT)lparg1, (BOOL)arg2);
+ if (arg1) setRECTFields(env, arg1, lparg1);
+ return rc;
+}
+#endif /* NO_GetUpdateRect */
+
+#ifndef NO_GetUpdateRgn
+JNIEXPORT jint JNICALL OS_NATIVE(GetUpdateRgn)
+ (JNIEnv *env, jclass that, jint arg0, jint arg1, jboolean arg2)
+{
+ DEBUG_CALL("GetUpdateRgn\n")
+
+ return (jint)GetUpdateRgn((HWND)arg0, (HRGN)arg1, arg2);
+}
+#endif /* NO_GetUpdateRgn */
+
+#ifndef NO_GetVersionExA
+JNIEXPORT jboolean JNICALL OS_NATIVE(GetVersionExA)
+ (JNIEnv *env, jclass that, jobject arg0)
+{
+ OSVERSIONINFOA _arg0={0}, *lparg0=NULL; /* SPECIAL */
+ jboolean rc;
+
+ DEBUG_CALL("GetVersionExA\n")
+
+ if (arg0) lparg0 = getOSVERSIONINFOAFields(env, arg0, &_arg0);
+ rc = (jboolean)GetVersionExA(lparg0);
+ if (arg0) setOSVERSIONINFOAFields(env, arg0, lparg0);
+ return rc;
+}
+#endif /* NO_GetVersionExA */
+
+#ifndef NO_GetVersionExW
+JNIEXPORT jboolean JNICALL OS_NATIVE(GetVersionExW)
+ (JNIEnv *env, jclass that, jobject arg0)
+{
+ OSVERSIONINFOW _arg0={0}, *lparg0=NULL; /* SPECIAL */
+ jboolean rc;
+
+ DEBUG_CALL("GetVersionExW\n")
+
+ if (arg0) lparg0 = getOSVERSIONINFOWFields(env, arg0, &_arg0);
+ rc = (jboolean)GetVersionExW(lparg0);
+ if (arg0) setOSVERSIONINFOWFields(env, arg0, lparg0);
+ return rc;
+}
+#endif /* NO_GetVersionExW */
+
+#ifndef NO_GetWindow
+JNIEXPORT jint JNICALL OS_NATIVE(GetWindow)
+ (JNIEnv *env, jclass that, jint arg0, jint arg1)
+{
+ DEBUG_CALL("GetWindow\n")
+
+ return (jint)GetWindow((HWND)arg0, arg1);
+}
+#endif /* NO_GetWindow */
+
+#ifndef NO_GetWindowLongA
+JNIEXPORT jint JNICALL OS_NATIVE(GetWindowLongA)
+ (JNIEnv *env, jclass that, jint arg0, jint arg1)
+{
+ DEBUG_CALL("GetWindowLongA\n")
+
+ return (jint)GetWindowLongA((HWND)arg0, arg1);
+}
+#endif /* NO_GetWindowLongA */
+
+#ifndef NO_GetWindowLongW
+JNIEXPORT jint JNICALL OS_NATIVE(GetWindowLongW)
+ (JNIEnv *env, jclass that, jint arg0, jint arg1)
+{
+ DEBUG_CALL("GetWindowLongW\n")
+
+ return (jint)GetWindowLongW((HWND)arg0, arg1);
+}
+#endif /* NO_GetWindowLongW */
+
+#ifndef NO_GetWindowPlacement
+JNIEXPORT jboolean JNICALL OS_NATIVE(GetWindowPlacement)
+ (JNIEnv *env, jclass that, jint arg0, jobject arg1)
+{
+ WINDOWPLACEMENT _arg1, *lparg1=NULL;
+ jboolean rc;
+
+ DEBUG_CALL("GetWindowPlacement\n")
+
+ if (arg1) lparg1 = getWINDOWPLACEMENTFields(env, arg1, &_arg1);
+ rc = (jboolean)GetWindowPlacement((HWND)arg0, lparg1);
+ if (arg1) setWINDOWPLACEMENTFields(env, arg1, lparg1);
+ return rc;
+}
+#endif /* NO_GetWindowPlacement */
+
+#ifndef NO_GetWindowRect
+JNIEXPORT jboolean JNICALL OS_NATIVE(GetWindowRect)
+ (JNIEnv *env, jclass that, jint arg0, jobject arg1)
+{
+ RECT _arg1, *lparg1=NULL;
+ jboolean rc;
+
+ DEBUG_CALL("GetWindowRect\n")
+
+ if (arg1) lparg1 = getRECTFields(env, arg1, &_arg1);
+ rc = (jboolean)GetWindowRect((HWND)arg0, lparg1);
+ if (arg1) setRECTFields(env, arg1, lparg1);
+ return rc;
+}
+#endif /* NO_GetWindowRect */
+
+#ifndef NO_GetWindowTextA
+JNIEXPORT jint JNICALL OS_NATIVE(GetWindowTextA)
+ (JNIEnv *env, jclass that, jint arg0, jbyteArray arg1, jint arg2)
+{
+ jbyte *lparg1=NULL;
+ jint rc;
+
+ DEBUG_CALL("GetWindowTextA\n")
+
+ if (arg1) lparg1 = (*env)->GetByteArrayElements(env, arg1, NULL);
+ rc = (jint)GetWindowTextA((HWND)arg0, (LPSTR)lparg1, arg2);
+ if (arg1) (*env)->ReleaseByteArrayElements(env, arg1, lparg1, 0);
+ return rc;
+}
+#endif /* NO_GetWindowTextA */
+
+#ifndef NO_GetWindowTextLengthA
+JNIEXPORT jint JNICALL OS_NATIVE(GetWindowTextLengthA)
+ (JNIEnv *env, jclass that, jint arg0)
+{
+ DEBUG_CALL("GetWindowTextLengthA\n")
+
+ return (jint)GetWindowTextLengthA((HWND)arg0);
+}
+#endif /* NO_GetWindowTextLengthA */
+
+#ifndef NO_GetWindowTextLengthW
+JNIEXPORT jint JNICALL OS_NATIVE(GetWindowTextLengthW)
+ (JNIEnv *env, jclass that, jint arg0)
+{
+ DEBUG_CALL("GetWindowTextLengthW\n")
+
+ return (jint)GetWindowTextLengthW((HWND)arg0);
+}
+#endif /* NO_GetWindowTextLengthW */
+
+#ifndef NO_GetWindowTextW
+JNIEXPORT jint JNICALL OS_NATIVE(GetWindowTextW)
+ (JNIEnv *env, jclass that, jint arg0, jcharArray arg1, jint arg2)
+{
+ jchar *lparg1=NULL;
+ jint rc;
+
+ DEBUG_CALL("GetWindowTextW\n")
+
+ if (arg1) lparg1 = (*env)->GetCharArrayElements(env, arg1, NULL);
+ rc = (jint)GetWindowTextW((HWND)arg0, (LPWSTR)lparg1, arg2);
+ if (arg1) (*env)->ReleaseCharArrayElements(env, arg1, lparg1, 0);
+ return rc;
+}
+#endif /* NO_GetWindowTextW */
+
+#ifndef NO_GetWindowThreadProcessId
+JNIEXPORT jint JNICALL OS_NATIVE(GetWindowThreadProcessId)
+ (JNIEnv *env, jclass that, jint arg0, jintArray arg1)
+{
+ jint *lparg1=NULL;
+ jint rc;
+
+ DEBUG_CALL("GetWindowThreadProcessId\n")
+
+ if (arg1) lparg1 = (*env)->GetIntArrayElements(env, arg1, NULL);
+ rc = (jint)GetWindowThreadProcessId((HWND)arg0, (LPDWORD)lparg1);
+ if (arg1) (*env)->ReleaseIntArrayElements(env, arg1, lparg1, 0);
+ return rc;
+}
+#endif /* NO_GetWindowThreadProcessId */
+
+#ifndef NO_GlobalAlloc
+JNIEXPORT jint JNICALL OS_NATIVE(GlobalAlloc)
+ (JNIEnv *env, jclass that, jint arg0, jint arg1)
+{
+ DEBUG_CALL("GlobalAlloc\n")
+
+ return (jint)GlobalAlloc(arg0, arg1);
+}
+#endif /* NO_GlobalAlloc */
+
+#ifndef NO_GlobalFree
+JNIEXPORT jint JNICALL OS_NATIVE(GlobalFree)
+ (JNIEnv *env, jclass that, jint arg0)
+{
+ DEBUG_CALL("GlobalFree\n")
+
+ return (jint)GlobalFree((HANDLE)arg0);
+}
+#endif /* NO_GlobalFree */
+
+#ifndef NO_GlobalLock
+JNIEXPORT jint JNICALL OS_NATIVE(GlobalLock)
+ (JNIEnv *env, jclass that, jint arg0)
+{
+ DEBUG_CALL("GlobalLock\n")
+
+ return (jint)GlobalLock((HANDLE)arg0);
+}
+#endif /* NO_GlobalLock */
+
+#ifndef NO_GlobalSize
+JNIEXPORT jint JNICALL OS_NATIVE(GlobalSize)
+ (JNIEnv *env, jclass that, jint arg0)
+{
+ DEBUG_CALL("GlobalSize\n")
+
+ return (jint)GlobalSize((HANDLE)arg0);
+}
+#endif /* NO_GlobalSize */
+
+#ifndef NO_GlobalUnlock
+JNIEXPORT jboolean JNICALL OS_NATIVE(GlobalUnlock)
+ (JNIEnv *env, jclass that, jint arg0)
+{
+ DEBUG_CALL("GlobalUnlock\n")
+
+ return (jboolean)GlobalUnlock((HANDLE)arg0);
+}
+#endif /* NO_GlobalUnlock */
+
+#ifndef NO_GradientFill
+JNIEXPORT jboolean JNICALL OS_NATIVE(GradientFill)
+ (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jint arg3, jint arg4, jint arg5)
+{
+ HMODULE hm;
+ FARPROC fp;
+
+ DEBUG_CALL("GradientFill\n")
+
+ /* SPECIAL */
+ /*
+ * GradientFill 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("msimg32.dll"))) hm = LoadLibrary("msimg32.dll");
+ if (hm && (fp = GetProcAddress(hm, "GradientFill"))) {
+// return (jboolean)GradientFill((HDC)arg0, (PTRIVERTEX)arg1, (ULONG)arg2, (PVOID)arg3, (ULONG)arg4, (ULONG)arg5);
+ return (jboolean)fp(arg0, arg1, arg2, arg3, arg4, arg5);
+ }
+ return (jboolean)FALSE;
+}
+#endif /* NO_GradientFill */
+
+#ifndef NO_HeapAlloc
+JNIEXPORT jint JNICALL OS_NATIVE(HeapAlloc)
+ (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2)
+{
+ DEBUG_CALL("HeapAlloc\n")
+
+ return (jint)HeapAlloc((HANDLE)arg0, arg1, arg2);
+}
+#endif /* NO_HeapAlloc */
+
+#ifndef NO_HeapFree
+JNIEXPORT jboolean JNICALL OS_NATIVE(HeapFree)
+ (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2)
+{
+ DEBUG_CALL("HeapFree\n")
+
+ return (jboolean)HeapFree((HANDLE)arg0, arg1, (LPVOID)arg2);
+}
+#endif /* NO_HeapFree */
+
+#ifndef NO_HideCaret
+JNIEXPORT jboolean JNICALL OS_NATIVE(HideCaret)
+ (JNIEnv *env, jclass that, jint arg0)
+{
+ DEBUG_CALL("HideCaret\n")
+
+ return (jboolean)HideCaret((HWND)arg0);
+}
+#endif /* NO_HideCaret */
+
+#ifndef NO_ImageList_1Add
+JNIEXPORT jint JNICALL OS_NATIVE(ImageList_1Add)
+ (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2)
+{
+ DEBUG_CALL("ImageList_1Add\n")
+
+ return (jint)ImageList_Add((HIMAGELIST)arg0, (HBITMAP)arg1, (HBITMAP)arg2);
+}
+#endif /* NO_ImageList_1Add */
+
+#ifndef NO_ImageList_1AddMasked
+JNIEXPORT jint JNICALL OS_NATIVE(ImageList_1AddMasked)
+ (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2)
+{
+ DEBUG_CALL("ImageList_1AddMasked\n")
+
+ return (jint)ImageList_AddMasked((HIMAGELIST)arg0, (HBITMAP)arg1, (COLORREF)arg2);
+}
+#endif /* NO_ImageList_1AddMasked */
+
+#ifndef NO_ImageList_1Create
+JNIEXPORT jint JNICALL OS_NATIVE(ImageList_1Create)
+ (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jint arg3, jint arg4)
+{
+ DEBUG_CALL("ImageList_1Create\n")
+
+ return (jint)ImageList_Create(arg0, arg1, arg2, arg3, arg4);
+}
+#endif /* NO_ImageList_1Create */
+
+#ifndef NO_ImageList_1Destroy
+JNIEXPORT jboolean JNICALL OS_NATIVE(ImageList_1Destroy)
+ (JNIEnv *env, jclass that, jint arg0)
+{
+ DEBUG_CALL("ImageList_1Destroy\n")
+
+ return (jboolean)ImageList_Destroy((HIMAGELIST)arg0);
+}
+#endif /* NO_ImageList_1Destroy */
+
+#ifndef NO_ImageList_1GetIcon
+JNIEXPORT jint JNICALL OS_NATIVE(ImageList_1GetIcon)
+ (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2)
+{
+ DEBUG_CALL("ImageList_1GetIcon\n")
+
+ return (jint)ImageList_GetIcon((HIMAGELIST)arg0, arg1, arg2);
+}
+#endif /* NO_ImageList_1GetIcon */
+
+#ifndef NO_ImageList_1GetIconSize
+JNIEXPORT jboolean JNICALL OS_NATIVE(ImageList_1GetIconSize)
+ (JNIEnv *env, jclass that, jint arg0, jintArray arg1, jintArray arg2)
+{
+ jint *lparg1=NULL;
+ jint *lparg2=NULL;
+ jboolean rc;
+
+ DEBUG_CALL("ImageList_1GetIconSize\n")
+
+ if (arg1) lparg1 = (*env)->GetIntArrayElements(env, arg1, NULL);
+ if (arg2) lparg2 = (*env)->GetIntArrayElements(env, arg2, NULL);
+ rc = (jboolean)ImageList_GetIconSize((HIMAGELIST)arg0, lparg1, lparg2);
+ if (arg1) (*env)->ReleaseIntArrayElements(env, arg1, lparg1, 0);
+ if (arg2) (*env)->ReleaseIntArrayElements(env, arg2, lparg2, 0);
+ return rc;
+}
+#endif /* NO_ImageList_1GetIconSize */
+
+#ifndef NO_ImageList_1GetImageCount
+JNIEXPORT jint JNICALL OS_NATIVE(ImageList_1GetImageCount)
+ (JNIEnv *env, jclass that, jint arg0)
+{
+ DEBUG_CALL("ImageList_1GetImageCount\n")
+
+ return (jint)ImageList_GetImageCount((HIMAGELIST)arg0);
+}
+#endif /* NO_ImageList_1GetImageCount */
+
+#ifndef NO_ImageList_1Remove
+JNIEXPORT jboolean JNICALL OS_NATIVE(ImageList_1Remove)
+ (JNIEnv *env, jclass that, jint arg0, jint arg1)
+{
+ DEBUG_CALL("ImageList_1Remove\n")
+
+ return (jboolean)ImageList_Remove((HIMAGELIST)arg0, arg1);
+}
+#endif /* NO_ImageList_1Remove */
+
+#ifndef NO_ImageList_1Replace
+JNIEXPORT jboolean JNICALL OS_NATIVE(ImageList_1Replace)
+ (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jint arg3)
+{
+ DEBUG_CALL("ImageList_1Replace\n")
+
+ return (jboolean)ImageList_Replace((HIMAGELIST)arg0, arg1, (HBITMAP)arg2, (HBITMAP)arg3);
+}
+#endif /* NO_ImageList_1Replace */
+
+#ifndef NO_ImageList_1ReplaceIcon
+JNIEXPORT jint JNICALL OS_NATIVE(ImageList_1ReplaceIcon)
+ (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2)
+{
+ DEBUG_CALL("ImageList_1ReplaceIcon\n")
+
+ return (jint)ImageList_ReplaceIcon((HIMAGELIST)arg0, arg1, (HICON)arg2);
+}
+#endif /* NO_ImageList_1ReplaceIcon */
+
+#ifndef NO_ImageList_1SetIconSize
+JNIEXPORT jboolean JNICALL OS_NATIVE(ImageList_1SetIconSize)
+ (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2)
+{
+ DEBUG_CALL("ImageList_1SetIconSize\n")
+
+ return (jboolean)ImageList_SetIconSize((HIMAGELIST)arg0, arg1, arg2);
+}
+#endif /* NO_ImageList_1SetIconSize */
+
+#ifndef NO_ImmAssociateContext
+JNIEXPORT jint JNICALL OS_NATIVE(ImmAssociateContext)
+ (JNIEnv *env, jclass that, jint arg0, jint arg1)
+{
+ DEBUG_CALL("ImmAssociateContext\n")
+
+ return (jint)ImmAssociateContext((HWND)arg0, (HIMC)arg1);
+}
+#endif /* NO_ImmAssociateContext */
+
+#ifndef NO_ImmCreateContext
+JNIEXPORT jint JNICALL OS_NATIVE(ImmCreateContext)
+ (JNIEnv *env, jclass that)
+{
+ DEBUG_CALL("ImmCreateContext\n")
+
+ return (jint)ImmCreateContext();
+}
+#endif /* NO_ImmCreateContext */
+
+#ifndef NO_ImmDestroyContext
+JNIEXPORT jboolean JNICALL OS_NATIVE(ImmDestroyContext)
+ (JNIEnv *env, jclass that, jint arg0)
+{
+ DEBUG_CALL("ImmDestroyContext\n")
+
+ return (jboolean)ImmDestroyContext((HIMC)arg0);
+}
+#endif /* NO_ImmDestroyContext */
+
+#ifndef NO_ImmGetCompositionFontA
+JNIEXPORT jboolean JNICALL OS_NATIVE(ImmGetCompositionFontA)
+ (JNIEnv *env, jclass that, jint arg0, jobject arg1)
+{
+ LOGFONTA _arg1, *lparg1=NULL;
+ jboolean rc;
+
+ DEBUG_CALL("ImmGetCompositionFontA\n")
+
+ if (arg1) lparg1 = getLOGFONTAFields(env, arg1, &_arg1);
+ rc = (jboolean)ImmGetCompositionFontA((HIMC)arg0, lparg1);
+ if (arg1) setLOGFONTAFields(env, arg1, lparg1);
+ return rc;
+}
+#endif /* NO_ImmGetCompositionFontA */
+
+#ifndef NO_ImmGetCompositionFontW
+JNIEXPORT jboolean JNICALL OS_NATIVE(ImmGetCompositionFontW)
+ (JNIEnv *env, jclass that, jint arg0, jobject arg1)
+{
+ LOGFONTW _arg1, *lparg1=NULL;
+ jboolean rc;
+
+ DEBUG_CALL("ImmGetCompositionFontW\n")
+
+ if (arg1) lparg1 = getLOGFONTWFields(env, arg1, &_arg1);
+ rc = (jboolean)ImmGetCompositionFontW((HIMC)arg0, lparg1);
+ if (arg1) setLOGFONTWFields(env, arg1, lparg1);
+ return rc;
+}
+#endif /* NO_ImmGetCompositionFontW */
+
+#ifndef NO_ImmGetCompositionStringA
+JNIEXPORT jint JNICALL OS_NATIVE(ImmGetCompositionStringA)
+ (JNIEnv *env, jclass that, jint arg0, jint arg1, jbyteArray arg2, jint arg3)
+{
+ jbyte *lparg2=NULL;
+ jint rc;
+
+ DEBUG_CALL("ImmGetCompositionStringA\n")
+
+ if (arg2) lparg2 = (*env)->GetByteArrayElements(env, arg2, NULL);
+ rc = (jint)ImmGetCompositionStringA((HIMC)arg0, arg1, (LPSTR)lparg2, arg3);
+ if (arg2) (*env)->ReleaseByteArrayElements(env, arg2, lparg2, 0);
+ return rc;
+}
+#endif /* NO_ImmGetCompositionStringA */
+
+#ifndef NO_ImmGetCompositionStringW
+JNIEXPORT jint JNICALL OS_NATIVE(ImmGetCompositionStringW)
+ (JNIEnv *env, jclass that, jint arg0, jint arg1, jcharArray arg2, jint arg3)
+{
+ jchar *lparg2=NULL;
+ jint rc;
+
+ DEBUG_CALL("ImmGetCompositionStringW\n")
+
+ if (arg2) lparg2 = (*env)->GetCharArrayElements(env, arg2, NULL);
+ rc = (jint)ImmGetCompositionStringW((HIMC)arg0, arg1, (LPWSTR)lparg2, arg3);
+ if (arg2) (*env)->ReleaseCharArrayElements(env, arg2, lparg2, 0);
+ return rc;
+}
+#endif /* NO_ImmGetCompositionStringW */
+
+#ifndef NO_ImmGetContext
+JNIEXPORT jint JNICALL OS_NATIVE(ImmGetContext)
+ (JNIEnv *env, jclass that, jint arg0)
+{
+ DEBUG_CALL("ImmGetContext\n")
+
+ return (jint)ImmGetContext((HWND)arg0);
+}
+#endif /* NO_ImmGetContext */
+
+#ifndef NO_ImmGetConversionStatus
+JNIEXPORT jboolean JNICALL OS_NATIVE(ImmGetConversionStatus)
+ (JNIEnv *env, jclass that, jint arg0, jintArray arg1, jintArray arg2)
+{
+ jint *lparg1=NULL;
+ jint *lparg2=NULL;
+ jboolean rc;
+
+ DEBUG_CALL("ImmGetConversionStatus\n")
+
+ if (arg1) lparg1 = (*env)->GetIntArrayElements(env, arg1, NULL);
+ if (arg2) lparg2 = (*env)->GetIntArrayElements(env, arg2, NULL);
+ rc = (jboolean)ImmGetConversionStatus((HIMC)arg0, lparg1, lparg2);
+ if (arg1) (*env)->ReleaseIntArrayElements(env, arg1, lparg1, 0);
+ if (arg2) (*env)->ReleaseIntArrayElements(env, arg2, lparg2, 0);
+ return rc;
+}
+#endif /* NO_ImmGetConversionStatus */
+
+#ifndef NO_ImmGetDefaultIMEWnd
+JNIEXPORT jint JNICALL OS_NATIVE(ImmGetDefaultIMEWnd)
+ (JNIEnv *env, jclass that, jint arg0)
+{
+ DEBUG_CALL("ImmGetDefaultIMEWnd\n")
+
+ return (jint)ImmGetDefaultIMEWnd((HWND)arg0);
+}
+#endif /* NO_ImmGetDefaultIMEWnd */
+
+#ifndef NO_ImmGetOpenStatus
+JNIEXPORT jboolean JNICALL OS_NATIVE(ImmGetOpenStatus)
+ (JNIEnv *env, jclass that, jint arg0)
+{
+ DEBUG_CALL("ImmGetOpenStatus\n")
+
+ return (jboolean)ImmGetOpenStatus((HIMC)arg0);
+}
+#endif /* NO_ImmGetOpenStatus */
+
+#ifndef NO_ImmReleaseContext
+JNIEXPORT jboolean JNICALL OS_NATIVE(ImmReleaseContext)
+ (JNIEnv *env, jclass that, jint arg0, jint arg1)
+{
+ DEBUG_CALL("ImmReleaseContext\n")
+
+ return (jboolean)ImmReleaseContext((HWND)arg0, (HIMC)arg1);
+}
+#endif /* NO_ImmReleaseContext */
+
+#ifndef NO_ImmSetCompositionFontA
+JNIEXPORT jboolean JNICALL OS_NATIVE(ImmSetCompositionFontA)
+ (JNIEnv *env, jclass that, jint arg0, jobject arg1)
+{
+ LOGFONTA _arg1, *lparg1=NULL;
+
+ DEBUG_CALL("ImmSetCompositionFontA\n")
+
+ if (arg1) lparg1 = getLOGFONTAFields(env, arg1, &_arg1);
+ return (jboolean)ImmSetCompositionFontA((HIMC)arg0, lparg1);
+}
+#endif /* NO_ImmSetCompositionFontA */
+
+#ifndef NO_ImmSetCompositionFontW
+JNIEXPORT jboolean JNICALL OS_NATIVE(ImmSetCompositionFontW)
+ (JNIEnv *env, jclass that, jint arg0, jobject arg1)
+{
+ LOGFONTW _arg1, *lparg1=NULL;
+
+ DEBUG_CALL("ImmSetCompositionFontW\n")
+
+ if (arg1) lparg1 = getLOGFONTWFields(env, arg1, &_arg1);
+ return (jboolean)ImmSetCompositionFontW((HIMC)arg0, lparg1);
+}
+#endif /* NO_ImmSetCompositionFontW */
+
+#ifndef NO_ImmSetCompositionWindow
+JNIEXPORT jboolean JNICALL OS_NATIVE(ImmSetCompositionWindow)
+ (JNIEnv *env, jclass that, jint arg0, jobject arg1)
+{
+ COMPOSITIONFORM _arg1, *lparg1=NULL;
+ jboolean rc;
+
+ DEBUG_CALL("ImmSetCompositionWindow\n")
+
+ if (arg1) lparg1 = getCOMPOSITIONFORMFields(env, arg1, &_arg1);
+ rc = (jboolean)ImmSetCompositionWindow((HIMC)arg0, lparg1);
+ if (arg1) setCOMPOSITIONFORMFields(env, arg1, lparg1);
+ return rc;
+}
+#endif /* NO_ImmSetCompositionWindow */
+
+#ifndef NO_ImmSetConversionStatus
+JNIEXPORT jboolean JNICALL OS_NATIVE(ImmSetConversionStatus)
+ (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2)
+{
+ DEBUG_CALL("ImmSetConversionStatus\n")
+
+ return (jboolean)ImmSetConversionStatus((HIMC)arg0, arg1, arg2);
+}
+#endif /* NO_ImmSetConversionStatus */
+
+#ifndef NO_ImmSetOpenStatus
+JNIEXPORT jboolean JNICALL OS_NATIVE(ImmSetOpenStatus)
+ (JNIEnv *env, jclass that, jint arg0, jboolean arg1)
+{
+ DEBUG_CALL("ImmSetOpenStatus\n")
+
+ return (jboolean)ImmSetOpenStatus((HIMC)arg0, arg1);
+}
+#endif /* NO_ImmSetOpenStatus */
+
+#ifndef NO_InitCommonControls
+JNIEXPORT void JNICALL OS_NATIVE(InitCommonControls)
+ (JNIEnv *env, jclass that)
+{
+ DEBUG_CALL("InitCommonControls\n")
+
+ InitCommonControls();
+}
+#endif /* NO_InitCommonControls */
+
+#ifndef NO_InitCommonControlsEx
+JNIEXPORT jboolean JNICALL OS_NATIVE(InitCommonControlsEx)
+ (JNIEnv *env, jclass that, jobject arg0)
+{
+ INITCOMMONCONTROLSEX _arg0, *lparg0=NULL;
+ jboolean rc;
+
+ DEBUG_CALL("InitCommonControlsEx\n")
+
+ if (arg0) lparg0 = getINITCOMMONCONTROLSEXFields(env, arg0, &_arg0);
+ rc = (jboolean)InitCommonControlsEx(lparg0);
+ if (arg0) setINITCOMMONCONTROLSEXFields(env, arg0, lparg0);
+ return rc;
+}
+#endif /* NO_InitCommonControlsEx */
+
+#ifndef NO_InsertMenuA
+JNIEXPORT jboolean JNICALL OS_NATIVE(InsertMenuA)
+ (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jint arg3, jbyteArray arg4)
+{
+ jbyte *lparg4=NULL;
+ jboolean rc;
+
+ DEBUG_CALL("InsertMenuA\n")
+
+ if (arg4) lparg4 = (*env)->GetByteArrayElements(env, arg4, NULL);
+ rc = (jboolean)InsertMenuA((HMENU)arg0, arg1, arg2, arg3, lparg4);
+ if (arg4) (*env)->ReleaseByteArrayElements(env, arg4, lparg4, 0);
+ return rc;
+}
+#endif /* NO_InsertMenuA */
+
+#ifndef NO_InsertMenuItemA
+JNIEXPORT jboolean JNICALL OS_NATIVE(InsertMenuItemA)
+ (JNIEnv *env, jclass that, jint arg0, jint arg1, jboolean arg2, jobject arg3)
+{
+ MENUITEMINFO _arg3, *lparg3=NULL;
+ jboolean rc;
+
+ DEBUG_CALL("InsertMenuItemA\n")
+
+ if (arg3) lparg3 = getMENUITEMINFOFields(env, arg3, &_arg3);
+ rc = (jboolean)InsertMenuItemA((HMENU)arg0, arg1, arg2, lparg3);
+ if (arg3) setMENUITEMINFOFields(env, arg3, lparg3);
+ return rc;
+}
+#endif /* NO_InsertMenuItemA */
+
+#ifndef NO_InsertMenuItemW
+JNIEXPORT jboolean JNICALL OS_NATIVE(InsertMenuItemW)
+ (JNIEnv *env, jclass that, jint arg0, jint arg1, jboolean arg2, jobject arg3)
+{
+ MENUITEMINFO _arg3, *lparg3=NULL;
+ jboolean rc;
+
+ DEBUG_CALL("InsertMenuItemW\n")
+
+ if (arg3) lparg3 = getMENUITEMINFOFields(env, arg3, &_arg3);
+ rc = (jboolean)InsertMenuItemW((HMENU)arg0, arg1, arg2, (LPMENUITEMINFOW)lparg3);
+ if (arg3) setMENUITEMINFOFields(env, arg3, lparg3);
+ return rc;
+}
+#endif /* NO_InsertMenuItemW */
+
+#ifndef NO_InsertMenuW
+JNIEXPORT jboolean JNICALL OS_NATIVE(InsertMenuW)
+ (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jint arg3, jcharArray arg4)
+{
+ jchar *lparg4=NULL;
+ jboolean rc;
+
+ DEBUG_CALL("InsertMenuW\n")
+
+ if (arg4) lparg4 = (*env)->GetCharArrayElements(env, arg4, NULL);
+ rc = (jboolean)InsertMenuW((HMENU)arg0, arg1, arg2, arg3, lparg4);
+ if (arg4) (*env)->ReleaseCharArrayElements(env, arg4, lparg4, 0);
+ return rc;
+}
+#endif /* NO_InsertMenuW */
+
+#ifndef NO_InvalidateRect
+JNIEXPORT jboolean JNICALL OS_NATIVE(InvalidateRect)
+ (JNIEnv *env, jclass that, jint arg0, jobject arg1, jboolean arg2)
+{
+ RECT _arg1, *lparg1=NULL;
+ jboolean rc;
+
+ DEBUG_CALL("InvalidateRect\n")
+
+ if (arg1) lparg1 = getRECTFields(env, arg1, &_arg1);
+ rc = (jboolean)InvalidateRect((HWND)arg0, lparg1, arg2);
+ if (arg1) setRECTFields(env, arg1, lparg1);
+ return rc;
+}
+#endif /* NO_InvalidateRect */
+
+#ifndef NO_InvalidateRgn
+JNIEXPORT jboolean JNICALL OS_NATIVE(InvalidateRgn)
+ (JNIEnv *env, jclass that, jint arg0, jint arg1, jboolean arg2)
+{
+ DEBUG_CALL("InvalidateRgn\n")
+
+ return (jboolean)InvalidateRgn((HWND)arg0, (HRGN)arg1, arg2);
+}
+#endif /* NO_InvalidateRgn */
+
+#ifndef NO_IsDBCSLeadByte
+JNIEXPORT jboolean JNICALL OS_NATIVE(IsDBCSLeadByte)
+ (JNIEnv *env, jclass that, jbyte arg0)
+{
+ DEBUG_CALL("IsDBCSLeadByte\n")
+
+ return (jboolean)IsDBCSLeadByte(arg0);
+}
+#endif /* NO_IsDBCSLeadByte */
+
+#ifndef NO_IsIconic
+JNIEXPORT jboolean JNICALL OS_NATIVE(IsIconic)
+ (JNIEnv *env, jclass that, jint arg0)
+{
+ DEBUG_CALL("IsIconic\n")
+
+ return (jboolean)IsIconic((HWND)arg0);
+}
+#endif /* NO_IsIconic */
+
+#ifndef NO_IsPPC
+/* SPECIAL */
+JNIEXPORT jboolean JNICALL OS_NATIVE(IsPPC)
+ (JNIEnv *env, jclass that)
+{
+ DEBUG_CALL("IsPPC\n")
+#ifdef WIN32_PLATFORM_PSPC
+ return TRUE;
+#else
+ return FALSE;
+#endif /* WIN32_PLATFORM_PSPC */
+}
+#endif /* NO_IsPPC */
+
+#ifndef NO_IsSP
+/* SPECIAL */
+JNIEXPORT jboolean JNICALL OS_NATIVE(IsSP)
+ (JNIEnv *env, jclass that)
+{
+ DEBUG_CALL("IsSP\n")
+#ifdef WIN32_PLATFORM_WFSP
+ return TRUE;
+#else
+ return FALSE;
+#endif /* WIN32_PLATFORM_WFSP */
+}
+#endif /* NO_IsSP */
+
+#ifndef NO_IsWindowEnabled
+JNIEXPORT jboolean JNICALL OS_NATIVE(IsWindowEnabled)
+ (JNIEnv *env, jclass that, jint arg0)
+{
+ DEBUG_CALL("IsWindowEnabled\n")
+
+ return (jboolean)IsWindowEnabled((HWND)arg0);
+}
+#endif /* NO_IsWindowEnabled */
+
+#ifndef NO_IsWindowVisible
+JNIEXPORT jboolean JNICALL OS_NATIVE(IsWindowVisible)
+ (JNIEnv *env, jclass that, jint arg0)
+{
+ DEBUG_CALL("IsWindowVisible\n")
+
+ return (jboolean)IsWindowVisible((HWND)arg0);
+}
+#endif /* NO_IsWindowVisible */
+
+#ifndef NO_IsZoomed
+JNIEXPORT jboolean JNICALL OS_NATIVE(IsZoomed)
+ (JNIEnv *env, jclass that, jint arg0)
+{
+ DEBUG_CALL("IsZoomed\n")
+
+ return (jboolean)IsZoomed((HWND)arg0);
+}
+#endif /* NO_IsZoomed */
+
+#ifndef NO_KillTimer
+JNIEXPORT jboolean JNICALL OS_NATIVE(KillTimer)
+ (JNIEnv *env, jclass that, jint arg0, jint arg1)
+{
+ DEBUG_CALL("KillTimer\n")
+
+ return (jboolean)KillTimer((HWND)arg0, arg1);
+}
+#endif /* NO_KillTimer */
+
+#ifndef NO_LineTo
+JNIEXPORT jboolean JNICALL OS_NATIVE(LineTo)
+ (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2)
+{
+ DEBUG_CALL("LineTo\n")
+
+ return (jboolean)LineTo((HDC)arg0, arg1, arg2);
+}
+#endif /* NO_LineTo */
+
+#ifndef NO_LoadBitmapA
+JNIEXPORT jint JNICALL OS_NATIVE(LoadBitmapA)
+ (JNIEnv *env, jclass that, jint arg0, jint arg1)
+{
+ DEBUG_CALL("LoadBitmapA\n")
+
+ return (jint)LoadBitmapA((HINSTANCE)arg0, (LPSTR)arg1);
+}
+#endif /* NO_LoadBitmapA */
+
+#ifndef NO_LoadBitmapW
+JNIEXPORT jint JNICALL OS_NATIVE(LoadBitmapW)
+ (JNIEnv *env, jclass that, jint arg0, jint arg1)
+{
+ DEBUG_CALL("LoadBitmapW\n")
+
+ return (jint)LoadBitmapW((HINSTANCE)arg0, (LPWSTR)arg1);
+}
+#endif /* NO_LoadBitmapW */
+
+#ifndef NO_LoadCursorA
+JNIEXPORT jint JNICALL OS_NATIVE(LoadCursorA)
+ (JNIEnv *env, jclass that, jint arg0, jint arg1)
+{
+ DEBUG_CALL("LoadCursorA\n")
+
+ return (jint)LoadCursorA((HINSTANCE)arg0, (LPSTR)arg1);
+}
+#endif /* NO_LoadCursorA */
+
+#ifndef NO_LoadCursorW
+JNIEXPORT jint JNICALL OS_NATIVE(LoadCursorW)
+ (JNIEnv *env, jclass that, jint arg0, jint arg1)
+{
+ DEBUG_CALL("LoadCursorW\n")
+
+ return (jint)LoadCursorW((HINSTANCE)arg0, (LPWSTR)arg1);
+}
+#endif /* NO_LoadCursorW */
+
+#ifndef NO_LoadIconA
+JNIEXPORT jint JNICALL OS_NATIVE(LoadIconA)
+ (JNIEnv *env, jclass that, jint arg0, jint arg1)
+{
+ DEBUG_CALL("LoadIconA\n")
+
+ return (jint)LoadIconA((HINSTANCE)arg0, (LPSTR)arg1);
+}
+#endif /* NO_LoadIconA */
+
+#ifndef NO_LoadIconW
+JNIEXPORT jint JNICALL OS_NATIVE(LoadIconW)
+ (JNIEnv *env, jclass that, jint arg0, jint arg1)
+{
+ DEBUG_CALL("LoadIconW\n")
+
+ return (jint)LoadIconW((HINSTANCE)arg0, (LPWSTR)arg1);
+}
+#endif /* NO_LoadIconW */
+
+#ifndef NO_LoadImageA
+JNIEXPORT jint JNICALL OS_NATIVE(LoadImageA)
+ (JNIEnv *env, jclass that, jint arg0, jbyteArray arg1, jint arg2, jint arg3, jint arg4, jint arg5)
+{
+ jbyte *lparg1=NULL;
+ jint rc;
+
+ DEBUG_CALL("LoadImageA\n")
+
+ if (arg1) lparg1 = (*env)->GetByteArrayElements(env, arg1, NULL);
+ rc = (jint)LoadImageA((HINSTANCE)arg0, (LPSTR)lparg1, arg2, arg3, arg4, arg5);
+ if (arg1) (*env)->ReleaseByteArrayElements(env, arg1, lparg1, 0);
+ return rc;
+}
+#endif /* NO_LoadImageA */
+
+#ifndef NO_LoadImageW
+JNIEXPORT jint JNICALL OS_NATIVE(LoadImageW)
+ (JNIEnv *env, jclass that, jint arg0, jcharArray arg1, jint arg2, jint arg3, jint arg4, jint arg5)
+{
+ jchar *lparg1=NULL;
+ jint rc;
+
+ DEBUG_CALL("LoadImageW\n")
+
+ if (arg1) lparg1 = (*env)->GetCharArrayElements(env, arg1, NULL);
+ rc = (jint)LoadImageW((HINSTANCE)arg0, (LPWSTR)lparg1, arg2, arg3, arg4, arg5);
+ if (arg1) (*env)->ReleaseCharArrayElements(env, arg1, lparg1, 0);
+ return rc;
+}
+#endif /* NO_LoadImageW */
+
+#ifndef NO_LoadLibraryA
+JNIEXPORT jint JNICALL OS_NATIVE(LoadLibraryA)
+ (JNIEnv *env, jclass that, jbyteArray arg0)
+{
+ jbyte *lparg0=NULL;
+ jint rc;
+
+ DEBUG_CALL("LoadLibraryA\n")
+
+ if (arg0) lparg0 = (*env)->GetByteArrayElements(env, arg0, NULL);
+ rc = (jint)LoadLibraryA((LPSTR)lparg0);
+ if (arg0) (*env)->ReleaseByteArrayElements(env, arg0, lparg0, 0);
+ return rc;
+}
+#endif /* NO_LoadLibraryA */
+
+#ifndef NO_LoadLibraryW
+JNIEXPORT jint JNICALL OS_NATIVE(LoadLibraryW)
+ (JNIEnv *env, jclass that, jcharArray arg0)
+{
+ jchar *lparg0=NULL;
+ jint rc;
+
+ DEBUG_CALL("LoadLibraryW\n")
+
+ if (arg0) lparg0 = (*env)->GetCharArrayElements(env, arg0, NULL);
+ rc = (jint)LoadLibraryW((LPWSTR)lparg0);
+ if (arg0) (*env)->ReleaseCharArrayElements(env, arg0, lparg0, 0);
+ return rc;
+}
+#endif /* NO_LoadLibraryW */
+
+#ifndef NO_MapVirtualKeyA
+JNIEXPORT jint JNICALL OS_NATIVE(MapVirtualKeyA)
+ (JNIEnv *env, jclass that, jint arg0, jint arg1)
+{
+ DEBUG_CALL("MapVirtualKeyA\n")
+
+ return (jint)MapVirtualKeyA(arg0, arg1);
+}
+#endif /* NO_MapVirtualKeyA */
+
+#ifndef NO_MapVirtualKeyW
+JNIEXPORT jint JNICALL OS_NATIVE(MapVirtualKeyW)
+ (JNIEnv *env, jclass that, jint arg0, jint arg1)
+{
+ DEBUG_CALL("MapVirtualKeyW\n")
+
+ return (jint)MapVirtualKeyW(arg0, arg1);
+}
+#endif /* NO_MapVirtualKeyW */
+
+#ifndef NO_MapWindowPoints__IILorg_eclipse_swt_internal_win32_RECT_2I
+JNIEXPORT jint JNICALL OS_NATIVE(MapWindowPoints__IILorg_eclipse_swt_internal_win32_RECT_2I)
+ (JNIEnv *env, jclass that, jint arg0, jint arg1, jobject arg2, jint arg3)
+{
+ RECT _arg2, *lparg2=NULL;
+ jint rc;
+
+ DEBUG_CALL("MapWindowPoints__IILorg_eclipse_swt_internal_win32_RECT_2I\n")
+
+ if (arg2) lparg2 = getRECTFields(env, arg2, &_arg2);
+ rc = (jint)MapWindowPoints((HWND)arg0, (HWND)arg1, (LPPOINT)lparg2, arg3);
+ if (arg2) setRECTFields(env, arg2, lparg2);
+ return rc;
+}
+#endif /* NO_MapWindowPoints__IILorg_eclipse_swt_internal_win32_RECT_2I */
+
+#ifndef NO_MapWindowPoints__IILorg_eclipse_swt_internal_win32_POINT_2I
+JNIEXPORT jint JNICALL OS_NATIVE(MapWindowPoints__IILorg_eclipse_swt_internal_win32_POINT_2I)
+ (JNIEnv *env, jclass that, jint arg0, jint arg1, jobject arg2, jint arg3)
+{
+ POINT _arg2, *lparg2=NULL;
+ jint rc;
+
+ DEBUG_CALL("MapWindowPoints__IILorg_eclipse_swt_internal_win32_POINT_2I\n")
+
+ if (arg2) lparg2 = getPOINTFields(env, arg2, &_arg2);
+ rc = (jint)MapWindowPoints((HWND)arg0, (HWND)arg1, (LPPOINT)lparg2, arg3);
+ if (arg2) setPOINTFields(env, arg2, lparg2);
+ return rc;
+}
+#endif /* NO_MapWindowPoints__IILorg_eclipse_swt_internal_win32_POINT_2I */
+
+#ifndef NO_MessageBeep
+JNIEXPORT jboolean JNICALL OS_NATIVE(MessageBeep)
+ (JNIEnv *env, jclass that, jint arg0)
+{
+ DEBUG_CALL("MessageBeep\n")
+
+ return (jboolean)MessageBeep(arg0);
+}
+#endif /* NO_MessageBeep */
+
+#ifndef NO_MessageBoxA
+JNIEXPORT jint JNICALL OS_NATIVE(MessageBoxA)
+ (JNIEnv *env, jclass that, jint arg0, jbyteArray arg1, jbyteArray arg2, jint arg3)
+{
+ jbyte *lparg1=NULL;
+ jbyte *lparg2=NULL;
+ jint rc;
+
+ DEBUG_CALL("MessageBoxA\n")
+
+ if (arg1) lparg1 = (*env)->GetByteArrayElements(env, arg1, NULL);
+ if (arg2) lparg2 = (*env)->GetByteArrayElements(env, arg2, NULL);
+ rc = (jint)MessageBoxA((HWND)arg0, (LPSTR)lparg1, (LPSTR)lparg2, arg3);
+ if (arg1) (*env)->ReleaseByteArrayElements(env, arg1, lparg1, 0);
+ if (arg2) (*env)->ReleaseByteArrayElements(env, arg2, lparg2, 0);
+ return rc;
+}
+#endif /* NO_MessageBoxA */
+
+#ifndef NO_MessageBoxW
+JNIEXPORT jint JNICALL OS_NATIVE(MessageBoxW)
+ (JNIEnv *env, jclass that, jint arg0, jcharArray arg1, jcharArray arg2, jint arg3)
+{
+ jchar *lparg1=NULL;
+ jchar *lparg2=NULL;
+ jint rc;
+
+ DEBUG_CALL("MessageBoxW\n")
+
+ if (arg1) lparg1 = (*env)->GetCharArrayElements(env, arg1, NULL);
+ if (arg2) lparg2 = (*env)->GetCharArrayElements(env, arg2, NULL);
+ rc = (jint)MessageBoxW((HWND)arg0, (LPWSTR)lparg1, (LPWSTR)lparg2, arg3);
+ if (arg1) (*env)->ReleaseCharArrayElements(env, arg1, lparg1, 0);
+ if (arg2) (*env)->ReleaseCharArrayElements(env, arg2, lparg2, 0);
+ return rc;
+}
+#endif /* NO_MessageBoxW */
+
+#ifndef NO_MoveMemory__Lorg_eclipse_swt_internal_win32_NMTOOLBAR_2II
+JNIEXPORT void JNICALL OS_NATIVE(MoveMemory__Lorg_eclipse_swt_internal_win32_NMTOOLBAR_2II)
+ (JNIEnv *env, jclass that, jobject arg0, jint arg1, jint arg2)
+{
+ NMTOOLBAR _arg0, *lparg0=NULL;
+
+ DEBUG_CALL("MoveMemory__Lorg_eclipse_swt_internal_win32_NMTOOLBAR_2II\n")
+ DEBUG_CHECK_NULL(env, arg1)
+
+ if (arg0) lparg0 = &_arg0;
+ MoveMemory((PVOID)lparg0, (CONST VOID *)arg1, arg2);
+ if (arg0) setNMTOOLBARFields(env, arg0, lparg0);
+}
+#endif /* NO_MoveMemory__Lorg_eclipse_swt_internal_win32_NMTOOLBAR_2II */
+
+#ifndef NO_MoveMemory__ILorg_eclipse_swt_internal_win32_DROPFILES_2I
+JNIEXPORT void JNICALL OS_NATIVE(MoveMemory__ILorg_eclipse_swt_internal_win32_DROPFILES_2I)
+ (JNIEnv *env, jclass that, jint arg0, jobject arg1, jint arg2)
+{
+ DROPFILES _arg1, *lparg1=NULL;
+
+ DEBUG_CALL("MoveMemory__ILorg_eclipse_swt_internal_win32_DROPFILES_2I\n")
+ DEBUG_CHECK_NULL(env, arg0)
+
+ if (arg1) lparg1 = getDROPFILESFields(env, arg1, &_arg1);
+ MoveMemory((PVOID)arg0, (CONST VOID *)lparg1, arg2);
+ if (arg1) setDROPFILESFields(env, arg1, lparg1);
+}
+#endif /* NO_MoveMemory__ILorg_eclipse_swt_internal_win32_DROPFILES_2I */
+
+#ifndef NO_MoveMemory___3DII
+JNIEXPORT void JNICALL OS_NATIVE(MoveMemory___3DII)
+ (JNIEnv *env, jclass that, jdoubleArray arg0, jint arg1, jint arg2)
+{
+ jdouble *lparg0=NULL;
+
+ DEBUG_CALL("MoveMemory___3DII\n")
+ DEBUG_CHECK_NULL(env, arg1)
+
+ if (arg0) lparg0 = (*env)->GetDoubleArrayElements(env, arg0, NULL);
+ MoveMemory((PVOID)lparg0, (CONST VOID *)arg1, arg2);
+ if (arg0) (*env)->ReleaseDoubleArrayElements(env, arg0, lparg0, 0);
+}
+#endif /* NO_MoveMemory___3DII */
+
+#ifndef NO_MoveMemory___3FII
+JNIEXPORT void JNICALL OS_NATIVE(MoveMemory___3FII)
+ (JNIEnv *env, jclass that, jfloatArray arg0, jint arg1, jint arg2)
+{
+ jfloat *lparg0=NULL;
+
+ DEBUG_CALL("MoveMemory___3FII\n")
+ DEBUG_CHECK_NULL(env, arg1)
+
+ if (arg0) lparg0 = (*env)->GetFloatArrayElements(env, arg0, NULL);
+ MoveMemory((PVOID)lparg0, (CONST VOID *)arg1, arg2);
+ if (arg0) (*env)->ReleaseFloatArrayElements(env, arg0, lparg0, 0);
+}
+#endif /* NO_MoveMemory___3FII */
+
+#ifndef NO_MoveMemory___3SII
+JNIEXPORT void JNICALL OS_NATIVE(MoveMemory___3SII)
+ (JNIEnv *env, jclass that, jshortArray arg0, jint arg1, jint arg2)
+{
+ jshort *lparg0=NULL;
+
+ DEBUG_CALL("MoveMemory___3SII\n")
+ DEBUG_CHECK_NULL(env, arg1)
+
+ if (arg0) lparg0 = (*env)->GetShortArrayElements(env, arg0, NULL);
+ MoveMemory((PVOID)lparg0, (CONST VOID *)arg1, arg2);
+ if (arg0) (*env)->ReleaseShortArrayElements(env, arg0, lparg0, 0);
+}
+#endif /* NO_MoveMemory___3SII */
+
+#ifndef NO_MoveMemory__I_3DI
+JNIEXPORT void JNICALL OS_NATIVE(MoveMemory__I_3DI)
+ (JNIEnv *env, jclass that, jint arg0, jdoubleArray arg1, jint arg2)
+{
+ jdouble *lparg1=NULL;
+
+ DEBUG_CALL("MoveMemory__I_3DI\n")
+ DEBUG_CHECK_NULL(env, arg0)
+
+ if (arg1) lparg1 = (*env)->GetDoubleArrayElements(env, arg1, NULL);
+ MoveMemory((PVOID)arg0, (CONST VOID *)lparg1, arg2);
+ if (arg1) (*env)->ReleaseDoubleArrayElements(env, arg1, lparg1, 0);
+}
+#endif /* NO_MoveMemory__I_3DI */
+
+#ifndef NO_MoveMemory__I_3FI
+JNIEXPORT void JNICALL OS_NATIVE(MoveMemory__I_3FI)
+ (JNIEnv *env, jclass that, jint arg0, jfloatArray arg1, jint arg2)
+{
+ jfloat *lparg1=NULL;
+
+ DEBUG_CALL("MoveMemory__I_3FI\n")
+ DEBUG_CHECK_NULL(env, arg0)
+
+ if (arg1) lparg1 = (*env)->GetFloatArrayElements(env, arg1, NULL);
+ MoveMemory((PVOID)arg0, (CONST VOID *)lparg1, arg2);
+ if (arg1) (*env)->ReleaseFloatArrayElements(env, arg1, lparg1, 0);
+}
+#endif /* NO_MoveMemory__I_3FI */
+
+#ifndef NO_MoveMemory__Lorg_eclipse_swt_internal_win32_NMREBARCHEVRON_2II
+JNIEXPORT void JNICALL OS_NATIVE(MoveMemory__Lorg_eclipse_swt_internal_win32_NMREBARCHEVRON_2II)
+ (JNIEnv *env, jclass that, jobject arg0, jint arg1, jint arg2)
+{
+ NMREBARCHEVRON _arg0, *lparg0=NULL;
+
+ DEBUG_CALL("MoveMemory__Lorg_eclipse_swt_internal_win32_NMREBARCHEVRON_2II\n")
+ DEBUG_CHECK_NULL(env, arg1)
+
+ if (arg0) lparg0 = &_arg0;
+ MoveMemory((PVOID)lparg0, (CONST VOID *)arg1, arg2);
+ if (arg0) setNMREBARCHEVRONFields(env, arg0, lparg0);
+}
+#endif /* NO_MoveMemory__Lorg_eclipse_swt_internal_win32_NMREBARCHEVRON_2II */
+
+#ifndef NO_MoveMemory__Lorg_eclipse_swt_internal_win32_MSG_2II
+JNIEXPORT void JNICALL OS_NATIVE(MoveMemory__Lorg_eclipse_swt_internal_win32_MSG_2II)
+ (JNIEnv *env, jclass that, jobject arg0, jint arg1, jint arg2)
+{
+ MSG _arg0, *lparg0=NULL;
+
+ DEBUG_CALL("MoveMemory__Lorg_eclipse_swt_internal_win32_MSG_2II\n")
+ DEBUG_CHECK_NULL(env, arg1)
+
+ if (arg0) lparg0 = &_arg0;
+ MoveMemory((PVOID)lparg0, (CONST VOID *)arg1, arg2);
+ if (arg0) setMSGFields(env, arg0, lparg0);
+}
+#endif /* NO_MoveMemory__Lorg_eclipse_swt_internal_win32_MSG_2II */
+
+#ifndef NO_MoveMemory__Lorg_eclipse_swt_internal_win32_NMHEADER_2II
+JNIEXPORT void JNICALL OS_NATIVE(MoveMemory__Lorg_eclipse_swt_internal_win32_NMHEADER_2II)
+ (JNIEnv *env, jclass that, jobject arg0, jint arg1, jint arg2)
+{
+ NMHEADER _arg0, *lparg0=NULL;
+
+ DEBUG_CALL("MoveMemory__Lorg_eclipse_swt_internal_win32_NMHEADER_2II\n")
+ DEBUG_CHECK_NULL(env, arg1)
+
+ if (arg0) lparg0 = &_arg0;
+ MoveMemory((PVOID)lparg0, (CONST VOID *)arg1, arg2);
+ if (arg0) setNMHEADERFields(env, arg0, lparg0);
+}
+#endif /* NO_MoveMemory__Lorg_eclipse_swt_internal_win32_NMHEADER_2II */
+
+#ifndef NO_MoveMemory__ILorg_eclipse_swt_internal_win32_NMTVCUSTOMDRAW_2I
+JNIEXPORT void JNICALL OS_NATIVE(MoveMemory__ILorg_eclipse_swt_internal_win32_NMTVCUSTOMDRAW_2I)
+ (JNIEnv *env, jclass that, jint arg0, jobject arg1, jint arg2)
+{
+ NMTVCUSTOMDRAW _arg1, *lparg1=NULL;
+
+ DEBUG_CALL("MoveMemory__ILorg_eclipse_swt_internal_win32_NMTVCUSTOMDRAW_2I\n")
+ DEBUG_CHECK_NULL(env, arg0)
+
+ if (arg1) lparg1 = getNMTVCUSTOMDRAWFields(env, arg1, &_arg1);
+ MoveMemory((PVOID)arg0, (CONST VOID *)lparg1, arg2);
+ if (arg1) setNMTVCUSTOMDRAWFields(env, arg1, lparg1);
+}
+#endif /* NO_MoveMemory__ILorg_eclipse_swt_internal_win32_NMTVCUSTOMDRAW_2I */
+
+#ifndef NO_MoveMemory__ILorg_eclipse_swt_internal_win32_NMLVCUSTOMDRAW_2I
+JNIEXPORT void JNICALL OS_NATIVE(MoveMemory__ILorg_eclipse_swt_internal_win32_NMLVCUSTOMDRAW_2I)
+ (JNIEnv *env, jclass that, jint arg0, jobject arg1, jint arg2)
+{
+ NMLVCUSTOMDRAW _arg1, *lparg1=NULL;
+
+ DEBUG_CALL("MoveMemory__ILorg_eclipse_swt_internal_win32_NMLVCUSTOMDRAW_2I\n")
+ DEBUG_CHECK_NULL(env, arg0)
+
+ if (arg1) lparg1 = getNMLVCUSTOMDRAWFields(env, arg1, &_arg1);
+ MoveMemory((PVOID)arg0, (CONST VOID *)lparg1, arg2);
+ if (arg1) setNMLVCUSTOMDRAWFields(env, arg1, lparg1);
+}
+#endif /* NO_MoveMemory__ILorg_eclipse_swt_internal_win32_NMLVCUSTOMDRAW_2I */
+
+#ifndef NO_MoveMemory__Lorg_eclipse_swt_internal_win32_NMTVCUSTOMDRAW_2II
+JNIEXPORT void JNICALL OS_NATIVE(MoveMemory__Lorg_eclipse_swt_internal_win32_NMTVCUSTOMDRAW_2II)
+ (JNIEnv *env, jclass that, jobject arg0, jint arg1, jint arg2)
+{
+ NMTVCUSTOMDRAW _arg0, *lparg0=NULL;
+
+ DEBUG_CALL("MoveMemory__Lorg_eclipse_swt_internal_win32_NMTVCUSTOMDRAW_2II\n")
+ DEBUG_CHECK_NULL(env, arg1)
+
+ if (arg0) lparg0 = getNMTVCUSTOMDRAWFields(env, arg0, &_arg0);
+ MoveMemory((PVOID)lparg0, (CONST VOID *)arg1, arg2);
+ if (arg0) setNMTVCUSTOMDRAWFields(env, arg0, lparg0);
+}
+#endif /* NO_MoveMemory__Lorg_eclipse_swt_internal_win32_NMTVCUSTOMDRAW_2II */
+
+#ifndef NO_MoveMemory__I_3SI
+JNIEXPORT void JNICALL OS_NATIVE(MoveMemory__I_3SI)
+ (JNIEnv *env, jclass that, jint arg0, jshortArray arg1, jint arg2)
+{
+ jshort *lparg1=NULL;
+
+ DEBUG_CALL("MoveMemory__I_3SI\n")
+ DEBUG_CHECK_NULL(env, arg0)
+
+ if (arg1) lparg1 = (*env)->GetShortArrayElements(env, arg1, NULL);
+ MoveMemory((PVOID)arg0, (CONST VOID *)lparg1, arg2);
+ if (arg1) (*env)->ReleaseShortArrayElements(env, arg1, lparg1, 0);
+}
+#endif /* NO_MoveMemory__I_3SI */
+
+#ifndef NO_MoveMemory__Lorg_eclipse_swt_internal_win32_NMLVCUSTOMDRAW_2II
+JNIEXPORT void JNICALL OS_NATIVE(MoveMemory__Lorg_eclipse_swt_internal_win32_NMLVCUSTOMDRAW_2II)
+ (JNIEnv *env, jclass that, jobject arg0, jint arg1, jint arg2)
+{
+ NMLVCUSTOMDRAW _arg0, *lparg0=NULL;
+
+ DEBUG_CALL("MoveMemory__Lorg_eclipse_swt_internal_win32_NMLVCUSTOMDRAW_2II\n")
+ DEBUG_CHECK_NULL(env, arg1)
+
+ if (arg0) lparg0 = &_arg0;
+ MoveMemory((PVOID)lparg0, (CONST VOID *)arg1, arg2);
+ if (arg0) setNMLVCUSTOMDRAWFields(env, arg0, lparg0);
+}
+#endif /* NO_MoveMemory__Lorg_eclipse_swt_internal_win32_NMLVCUSTOMDRAW_2II */
+
+#ifndef NO_MoveMemory__Lorg_eclipse_swt_internal_win32_NMHDR_2II
+JNIEXPORT void JNICALL OS_NATIVE(MoveMemory__Lorg_eclipse_swt_internal_win32_NMHDR_2II)
+ (JNIEnv *env, jclass that, jobject arg0, jint arg1, jint arg2)
+{
+ NMHDR _arg0, *lparg0=NULL;
+
+ DEBUG_CALL("MoveMemory__Lorg_eclipse_swt_internal_win32_NMHDR_2II\n")
+ DEBUG_CHECK_NULL(env, arg1)
+
+ if (arg0) lparg0 = &_arg0;
+ MoveMemory((PVOID)lparg0, (CONST VOID *)arg1, arg2);
+ if (arg0) setNMHDRFields(env, arg0, lparg0);
+}
+#endif /* NO_MoveMemory__Lorg_eclipse_swt_internal_win32_NMHDR_2II */
+
+#ifndef NO_MoveMemory__Lorg_eclipse_swt_internal_win32_MEASUREITEMSTRUCT_2II
+JNIEXPORT void JNICALL OS_NATIVE(MoveMemory__Lorg_eclipse_swt_internal_win32_MEASUREITEMSTRUCT_2II)
+ (JNIEnv *env, jclass that, jobject arg0, jint arg1, jint arg2)
+{
+ MEASUREITEMSTRUCT _arg0, *lparg0=NULL;
+
+ DEBUG_CALL("MoveMemory__Lorg_eclipse_swt_internal_win32_MEASUREITEMSTRUCT_2II\n")
+ DEBUG_CHECK_NULL(env, arg1)
+
+ if (arg0) lparg0 = &_arg0;
+ MoveMemory((PVOID)lparg0, (CONST VOID *)arg1, arg2);
+ if (arg0) setMEASUREITEMSTRUCTFields(env, arg0, lparg0);
+}
+#endif /* NO_MoveMemory__Lorg_eclipse_swt_internal_win32_MEASUREITEMSTRUCT_2II */
+
+#ifndef NO_MoveMemory___3CII
+JNIEXPORT void JNICALL OS_NATIVE(MoveMemory___3CII)
+ (JNIEnv *env, jclass that, jcharArray arg0, jint arg1, jint arg2)
+{
+ jchar *lparg0=NULL;
+
+ DEBUG_CALL("MoveMemory___3CII\n")
+ DEBUG_CHECK_NULL(env, arg1)
+
+ if (arg0) lparg0 = (*env)->GetCharArrayElements(env, arg0, NULL);
+ MoveMemory((PVOID)lparg0, (CONST VOID *)arg1, arg2);
+ if (arg0) (*env)->ReleaseCharArrayElements(env, arg0, lparg0, 0);
+}
+#endif /* NO_MoveMemory___3CII */
+
+#ifndef NO_MoveMemory__Lorg_eclipse_swt_internal_win32_NMLISTVIEW_2II
+JNIEXPORT void JNICALL OS_NATIVE(MoveMemory__Lorg_eclipse_swt_internal_win32_NMLISTVIEW_2II)
+ (JNIEnv *env, jclass that, jobject arg0, jint arg1, jint arg2)
+{
+ NMLISTVIEW _arg0, *lparg0=NULL;
+
+ DEBUG_CALL("MoveMemory__Lorg_eclipse_swt_internal_win32_NMLISTVIEW_2II\n")
+ DEBUG_CHECK_NULL(env, arg1)
+
+ if (arg0) lparg0 = &_arg0;
+ MoveMemory((PVOID)lparg0, (CONST VOID *)arg1, arg2);
+ if (arg0) setNMLISTVIEWFields(env, arg0, lparg0);
+}
+#endif /* NO_MoveMemory__Lorg_eclipse_swt_internal_win32_NMLISTVIEW_2II */
+
+#ifndef NO_MoveMemory__Lorg_eclipse_swt_internal_win32_HELPINFO_2II
+JNIEXPORT void JNICALL OS_NATIVE(MoveMemory__Lorg_eclipse_swt_internal_win32_HELPINFO_2II)
+ (JNIEnv *env, jclass that, jobject arg0, jint arg1, jint arg2)
+{
+ HELPINFO _arg0, *lparg0=NULL;
+
+ DEBUG_CALL("MoveMemory__Lorg_eclipse_swt_internal_win32_HELPINFO_2II\n")
+ DEBUG_CHECK_NULL(env, arg1)
+
+ if (arg0) lparg0 = &_arg0;
+ MoveMemory((PVOID)lparg0, (CONST VOID *)arg1, arg2);
+ if (arg0) setHELPINFOFields(env, arg0, lparg0);
+}
+#endif /* NO_MoveMemory__Lorg_eclipse_swt_internal_win32_HELPINFO_2II */
+
+#ifndef NO_MoveMemory__Lorg_eclipse_swt_internal_win32_HDITEM_2II
+JNIEXPORT void JNICALL OS_NATIVE(MoveMemory__Lorg_eclipse_swt_internal_win32_HDITEM_2II)
+ (JNIEnv *env, jclass that, jobject arg0, jint arg1, jint arg2)
+{
+ HDITEM _arg0, *lparg0=NULL;
+
+ DEBUG_CALL("MoveMemory__Lorg_eclipse_swt_internal_win32_HDITEM_2II\n")
+ DEBUG_CHECK_NULL(env, arg1)
+
+ if (arg0) lparg0 = &_arg0;
+ MoveMemory((PVOID)lparg0, (CONST VOID *)arg1, arg2);
+ if (arg0) setHDITEMFields(env, arg0, lparg0);
+}
+#endif /* NO_MoveMemory__Lorg_eclipse_swt_internal_win32_HDITEM_2II */
+
+#ifndef NO_MoveMemory__Lorg_eclipse_swt_internal_win32_DRAWITEMSTRUCT_2II
+JNIEXPORT void JNICALL OS_NATIVE(MoveMemory__Lorg_eclipse_swt_internal_win32_DRAWITEMSTRUCT_2II)
+ (JNIEnv *env, jclass that, jobject arg0, jint arg1, jint arg2)
+{
+ DRAWITEMSTRUCT _arg0, *lparg0=NULL;
+
+ DEBUG_CALL("MoveMemory__Lorg_eclipse_swt_internal_win32_DRAWITEMSTRUCT_2II\n")
+ DEBUG_CHECK_NULL(env, arg1)
+
+ if (arg0) lparg0 = &_arg0;
+ MoveMemory((PVOID)lparg0, (CONST VOID *)arg1, arg2);
+ if (arg0) setDRAWITEMSTRUCTFields(env, arg0, lparg0);
+}
+#endif /* NO_MoveMemory__Lorg_eclipse_swt_internal_win32_DRAWITEMSTRUCT_2II */
+
+#ifndef NO_MoveMemory__ILorg_eclipse_swt_internal_win32_WINDOWPOS_2I
+JNIEXPORT void JNICALL OS_NATIVE(MoveMemory__ILorg_eclipse_swt_internal_win32_WINDOWPOS_2I)
+ (JNIEnv *env, jclass that, jint arg0, jobject arg1, jint arg2)
+{
+ WINDOWPOS _arg1, *lparg1=NULL;
+
+ DEBUG_CALL("MoveMemory__ILorg_eclipse_swt_internal_win32_WINDOWPOS_2I\n")
+ DEBUG_CHECK_NULL(env, arg0)
+
+ if (arg1) lparg1 = getWINDOWPOSFields(env, arg1, &_arg1);
+ MoveMemory((PVOID)arg0, (CONST VOID *)lparg1, arg2);
+}
+#endif /* NO_MoveMemory__ILorg_eclipse_swt_internal_win32_WINDOWPOS_2I */
+
+#ifndef NO_MoveMemory__ILorg_eclipse_swt_internal_win32_TRIVERTEX_2I
+JNIEXPORT void JNICALL OS_NATIVE(MoveMemory__ILorg_eclipse_swt_internal_win32_TRIVERTEX_2I)
+ (JNIEnv *env, jclass that, jint arg0, jobject arg1, jint arg2)
+{
+ TRIVERTEX _arg1, *lparg1=NULL;
+
+ DEBUG_CALL("MoveMemory__ILorg_eclipse_swt_internal_win32_TRIVERTEX_2I\n")
+ DEBUG_CHECK_NULL(env, arg0)
+
+ if (arg1) lparg1 = getTRIVERTEXFields(env, arg1, &_arg1);
+ MoveMemory((PVOID)arg0, (CONST VOID *)lparg1, arg2);
+}
+#endif /* NO_MoveMemory__ILorg_eclipse_swt_internal_win32_TRIVERTEX_2I */
+
+#ifndef NO_MoveMemory__ILorg_eclipse_swt_internal_win32_RECT_2I
+JNIEXPORT void JNICALL OS_NATIVE(MoveMemory__ILorg_eclipse_swt_internal_win32_RECT_2I)
+ (JNIEnv *env, jclass that, jint arg0, jobject arg1, jint arg2)
+{
+ RECT _arg1, *lparg1=NULL;
+
+ DEBUG_CALL("MoveMemory__ILorg_eclipse_swt_internal_win32_RECT_2I\n")
+ DEBUG_CHECK_NULL(env, arg0)
+
+ if (arg1) lparg1 = getRECTFields(env, arg1, &_arg1);
+ MoveMemory((PVOID)arg0, (CONST VOID *)lparg1, arg2);
+}
+#endif /* NO_MoveMemory__ILorg_eclipse_swt_internal_win32_RECT_2I */
+
+#ifndef NO_MoveMemory__Lorg_eclipse_swt_internal_win32_WINDOWPOS_2II
+JNIEXPORT void JNICALL OS_NATIVE(MoveMemory__Lorg_eclipse_swt_internal_win32_WINDOWPOS_2II)
+ (JNIEnv *env, jclass that, jobject arg0, jint arg1, jint arg2)
+{
+ WINDOWPOS _arg0, *lparg0=NULL;
+
+ DEBUG_CALL("MoveMemory__Lorg_eclipse_swt_internal_win32_WINDOWPOS_2II\n")
+ DEBUG_CHECK_NULL(env, arg1)
+
+ if (arg0) lparg0 = &_arg0;
+ MoveMemory((PVOID)lparg0, (CONST VOID *)arg1, arg2);
+ if (arg0) setWINDOWPOSFields(env, arg0, lparg0);
+}
+#endif /* NO_MoveMemory__Lorg_eclipse_swt_internal_win32_WINDOWPOS_2II */
+
+#ifndef NO_MoveMemory__Lorg_eclipse_swt_internal_win32_TVITEM_2II
+JNIEXPORT void JNICALL OS_NATIVE(MoveMemory__Lorg_eclipse_swt_internal_win32_TVITEM_2II)
+ (JNIEnv *env, jclass that, jobject arg0, jint arg1, jint arg2)
+{
+ TVITEM _arg0, *lparg0=NULL;
+
+ DEBUG_CALL("MoveMemory__Lorg_eclipse_swt_internal_win32_TVITEM_2II\n")
+ DEBUG_CHECK_NULL(env, arg1)
+
+ if (arg0) lparg0 = &_arg0;
+ MoveMemory((PVOID)lparg0, (CONST VOID *)arg1, arg2);
+ if (arg0) setTVITEMFields(env, arg0, lparg0);
+}
+#endif /* NO_MoveMemory__Lorg_eclipse_swt_internal_win32_TVITEM_2II */
+
+#ifndef NO_MoveMemory___3BII
+JNIEXPORT void JNICALL OS_NATIVE(MoveMemory___3BII)
+ (JNIEnv *env, jclass that, jbyteArray arg0, jint arg1, jint arg2)
+{
+ jbyte *lparg0=NULL;
+
+ DEBUG_CALL("MoveMemory___3BII\n")
+ DEBUG_CHECK_NULL(env, arg1)
+
+ if (arg0) lparg0 = (*env)->GetByteArrayElements(env, arg0, NULL);
+ MoveMemory((PVOID)lparg0, (CONST VOID *)arg1, arg2);
+ if (arg0) (*env)->ReleaseByteArrayElements(env, arg0, lparg0, 0);
+}
+#endif /* NO_MoveMemory___3BII */
+
+#ifndef NO_MoveMemory__ILorg_eclipse_swt_internal_win32_MEASUREITEMSTRUCT_2I
+JNIEXPORT void JNICALL OS_NATIVE(MoveMemory__ILorg_eclipse_swt_internal_win32_MEASUREITEMSTRUCT_2I)
+ (JNIEnv *env, jclass that, jint arg0, jobject arg1, jint arg2)
+{
+ MEASUREITEMSTRUCT _arg1, *lparg1=NULL;
+
+ DEBUG_CALL("MoveMemory__ILorg_eclipse_swt_internal_win32_MEASUREITEMSTRUCT_2I\n")
+ DEBUG_CHECK_NULL(env, arg0)
+
+ if (arg1) lparg1 = getMEASUREITEMSTRUCTFields(env, arg1, &_arg1);
+ MoveMemory((PVOID)arg0, (CONST VOID *)lparg1, arg2);
+}
+#endif /* NO_MoveMemory__ILorg_eclipse_swt_internal_win32_MEASUREITEMSTRUCT_2I */
+
+#ifndef NO_MoveMemory___3BLorg_eclipse_swt_internal_win32_ACCEL_2I
+JNIEXPORT void JNICALL OS_NATIVE(MoveMemory___3BLorg_eclipse_swt_internal_win32_ACCEL_2I)
+ (JNIEnv *env, jclass that, jbyteArray arg0, jobject arg1, jint arg2)
+{
+ jbyte *lparg0=NULL;
+ ACCEL _arg1, *lparg1=NULL;
+
+ DEBUG_CALL("MoveMemory___3BLorg_eclipse_swt_internal_win32_ACCEL_2I\n")
+
+ if (arg0) lparg0 = (*env)->GetByteArrayElements(env, arg0, NULL);
+ if (arg1) lparg1 = getACCELFields(env, arg1, &_arg1);
+ MoveMemory((PVOID)lparg0, (CONST VOID *)lparg1, arg2);
+ if (arg0) (*env)->ReleaseByteArrayElements(env, arg0, lparg0, 0);
+}
+#endif /* NO_MoveMemory___3BLorg_eclipse_swt_internal_win32_ACCEL_2I */
+
+#ifndef NO_MoveMemory___3BLorg_eclipse_swt_internal_win32_BITMAPINFOHEADER_2I
+JNIEXPORT void JNICALL OS_NATIVE(MoveMemory___3BLorg_eclipse_swt_internal_win32_BITMAPINFOHEADER_2I)
+ (JNIEnv *env, jclass that, jbyteArray arg0, jobject arg1, jint arg2)
+{
+ jbyte *lparg0=NULL;
+ BITMAPINFOHEADER _arg1, *lparg1=NULL;
+
+ DEBUG_CALL("MoveMemory___3BLorg_eclipse_swt_internal_win32_BITMAPINFOHEADER_2I\n")
+
+ if (arg0) lparg0 = (*env)->GetByteArrayElements(env, arg0, NULL);
+ if (arg1) lparg1 = getBITMAPINFOHEADERFields(env, arg1, &_arg1);
+ MoveMemory((PVOID)lparg0, (CONST VOID *)lparg1, arg2);
+ if (arg0) (*env)->ReleaseByteArrayElements(env, arg0, lparg0, 0);
+}
+#endif /* NO_MoveMemory___3BLorg_eclipse_swt_internal_win32_BITMAPINFOHEADER_2I */
+
+#ifndef NO_MoveMemory__Lorg_eclipse_swt_internal_win32_BITMAPINFOHEADER_2_3BI
+JNIEXPORT void JNICALL OS_NATIVE(MoveMemory__Lorg_eclipse_swt_internal_win32_BITMAPINFOHEADER_2_3BI)
+ (JNIEnv *env, jclass that, jobject arg0, jbyteArray arg1, jint arg2)
+{
+ BITMAPINFOHEADER _arg0={0}, *lparg0=NULL; /* SPECIAL */
+ jbyte *lparg1=NULL;
+
+ DEBUG_CALL("MoveMemory__Lorg_eclipse_swt_internal_win32_BITMAPINFOHEADER_2_3BI\n")
+
+ if (arg0) lparg0 = &_arg0;
+ if (arg1) lparg1 = (*env)->GetByteArrayElements(env, arg1, NULL);
+ MoveMemory((PVOID)lparg0, (CONST VOID *)lparg1, arg2);
+ if (arg0) setBITMAPINFOHEADERFields(env, arg0, lparg0);
+ if (arg1) (*env)->ReleaseByteArrayElements(env, arg1, lparg1, 0);
+}
+#endif /* NO_MoveMemory__Lorg_eclipse_swt_internal_win32_BITMAPINFOHEADER_2_3BI */
+
+#ifndef NO_MoveMemory___3III
+JNIEXPORT void JNICALL OS_NATIVE(MoveMemory___3III)
+ (JNIEnv *env, jclass that, jintArray arg0, jint arg1, jint arg2)
+{
+ jint *lparg0=NULL;
+
+ DEBUG_CALL("MoveMemory___3III\n")
+ DEBUG_CHECK_NULL(env, arg1)
+
+ if (arg0) lparg0 = (*env)->GetIntArrayElements(env, arg0, NULL);
+ MoveMemory((PVOID)lparg0, (CONST VOID *)arg1, arg2);
+ if (arg0) (*env)->ReleaseIntArrayElements(env, arg0, lparg0, 0);
+}
+#endif /* NO_MoveMemory___3III */
+
+#ifndef NO_MoveMemory__ILorg_eclipse_swt_internal_win32_GRADIENT_1RECT_2I
+JNIEXPORT void JNICALL OS_NATIVE(MoveMemory__ILorg_eclipse_swt_internal_win32_GRADIENT_1RECT_2I)
+ (JNIEnv *env, jclass that, jint arg0, jobject arg1, jint arg2)
+{
+ GRADIENT_RECT _arg1, *lparg1=NULL;
+
+ DEBUG_CALL("MoveMemory__ILorg_eclipse_swt_internal_win32_GRADIENT_1RECT_2I\n")
+ DEBUG_CHECK_NULL(env, arg0)
+
+ if (arg1) lparg1 = getGRADIENT_RECTFields(env, arg1, &_arg1);
+ MoveMemory((PVOID)arg0, (CONST VOID *)lparg1, arg2);
+}
+#endif /* NO_MoveMemory__ILorg_eclipse_swt_internal_win32_GRADIENT_1RECT_2I */
+
+#ifndef NO_MoveMemory__I_3II
+JNIEXPORT void JNICALL OS_NATIVE(MoveMemory__I_3II)
+ (JNIEnv *env, jclass that, jint arg0, jintArray arg1, jint arg2)
+{
+ jint *lparg1=NULL;
+
+ DEBUG_CALL("MoveMemory__I_3II\n")
+ DEBUG_CHECK_NULL(env, arg0)
+
+ if (arg1) lparg1 = (*env)->GetIntArrayElements(env, arg1, NULL);
+ MoveMemory((PVOID)arg0, (CONST VOID *)lparg1, arg2);
+ if (arg1) (*env)->ReleaseIntArrayElements(env, arg1, lparg1, 0);
+}
+#endif /* NO_MoveMemory__I_3II */
+
+#ifndef NO_MoveMemory__I_3CI
+JNIEXPORT void JNICALL OS_NATIVE(MoveMemory__I_3CI)
+ (JNIEnv *env, jclass that, jint arg0, jcharArray arg1, jint arg2)
+{
+ jchar *lparg1=NULL;
+
+ DEBUG_CALL("MoveMemory__I_3CI\n")
+ DEBUG_CHECK_NULL(env, arg0)
+
+ if (arg1) lparg1 = (*env)->GetCharArrayElements(env, arg1, NULL);
+ MoveMemory((PVOID)arg0, (CONST VOID *)lparg1, arg2);
+ if (arg1) (*env)->ReleaseCharArrayElements(env, arg1, lparg1, 0);
+}
+#endif /* NO_MoveMemory__I_3CI */
+
+#ifndef NO_MoveMemory__I_3BI
+JNIEXPORT void JNICALL OS_NATIVE(MoveMemory__I_3BI)
+ (JNIEnv *env, jclass that, jint arg0, jbyteArray arg1, jint arg2)
+{
+ jbyte *lparg1=NULL;
+
+ DEBUG_CALL("MoveMemory__I_3BI\n")
+ DEBUG_CHECK_NULL(env, arg0)
+
+ if (arg1) lparg1 = (*env)->GetByteArrayElements(env, arg1, NULL);
+ MoveMemory((PVOID)arg0, (CONST VOID *)lparg1, arg2);
+ if (arg1) (*env)->ReleaseByteArrayElements(env, arg1, lparg1, 0);
+}
+#endif /* NO_MoveMemory__I_3BI */
+
+#ifndef NO_MoveMemoryA__ILorg_eclipse_swt_internal_win32_LOGFONT_2I
+JNIEXPORT void JNICALL OS_NATIVE(MoveMemoryA__ILorg_eclipse_swt_internal_win32_LOGFONT_2I)
+ (JNIEnv *env, jclass that, jint arg0, jobject arg1, jint arg2)
+{
+ LOGFONT _arg1, *lparg1=NULL;
+
+ DEBUG_CALL("MoveMemoryA__ILorg_eclipse_swt_internal_win32_LOGFONT_2I\n")
+ DEBUG_CHECK_NULL(env, arg0)
+
+ if (arg1) lparg1 = getLOGFONTAFields(env, arg1, &_arg1);
+ MoveMemory((PVOID)arg0, (CONST VOID *)lparg1, arg2);
+}
+#endif /* NO_MoveMemoryA__ILorg_eclipse_swt_internal_win32_LOGFONT_2I */
+
+#ifndef NO_MoveMemoryA__Lorg_eclipse_swt_internal_win32_LOGFONT_2II
+JNIEXPORT void JNICALL OS_NATIVE(MoveMemoryA__Lorg_eclipse_swt_internal_win32_LOGFONT_2II)
+ (JNIEnv *env, jclass that, jobject arg0, jint arg1, jint arg2)
+{
+ LOGFONT _arg0, *lparg0=NULL;
+
+ DEBUG_CALL("MoveMemoryA__Lorg_eclipse_swt_internal_win32_LOGFONT_2II\n")
+ DEBUG_CHECK_NULL(env, arg1)
+
+ if (arg0) lparg0 = &_arg0;
+ MoveMemory((PVOID)lparg0, (CONST VOID *)arg1, arg2);
+ if (arg0) setLOGFONTAFields(env, arg0, lparg0);
+}
+#endif /* NO_MoveMemoryA__Lorg_eclipse_swt_internal_win32_LOGFONT_2II */
+
+#ifndef NO_MoveMemoryA__ILorg_eclipse_swt_internal_win32_NMTTDISPINFO_2I
+JNIEXPORT void JNICALL OS_NATIVE(MoveMemoryA__ILorg_eclipse_swt_internal_win32_NMTTDISPINFO_2I)
+ (JNIEnv *env, jclass that, jint arg0, jobject arg1, jint arg2)
+{
+ NMTTDISPINFOA _arg1={0}, *lparg1=NULL; /* SPECIAL */
+
+ DEBUG_CALL("MoveMemoryA__ILorg_eclipse_swt_internal_win32_NMTTDISPINFO_2I\n")
+ DEBUG_CHECK_NULL(env, arg0)
+
+ if (arg1) lparg1 = getNMTTDISPINFOAFields(env, arg1, &_arg1);
+ MoveMemory((PVOID)arg0, (CONST VOID *)lparg1, arg2);
+}
+#endif /* NO_MoveMemoryA__ILorg_eclipse_swt_internal_win32_NMTTDISPINFO_2I */
+
+#ifndef NO_MoveMemoryA__Lorg_eclipse_swt_internal_win32_NMTTDISPINFO_2II
+JNIEXPORT void JNICALL OS_NATIVE(MoveMemoryA__Lorg_eclipse_swt_internal_win32_NMTTDISPINFO_2II)
+ (JNIEnv *env, jclass that, jobject arg0, jint arg1, jint arg2)
+{
+ NMTTDISPINFOA _arg0={0}, *lparg0=NULL; /* SPECIAL */
+
+ DEBUG_CALL("MoveMemoryA__Lorg_eclipse_swt_internal_win32_NMTTDISPINFO_2II\n")
+ DEBUG_CHECK_NULL(env, arg1)
+
+ if (arg0) lparg0 = &_arg0;
+ MoveMemory((PVOID)lparg0, (CONST VOID *)arg1, arg2);
+ if (arg0) setNMTTDISPINFOAFields(env, arg0, lparg0);
+}
+#endif /* NO_MoveMemoryA__Lorg_eclipse_swt_internal_win32_NMTTDISPINFO_2II */
+
+#ifndef NO_MoveMemoryW__Lorg_eclipse_swt_internal_win32_LOGFONT_2II
+JNIEXPORT void JNICALL OS_NATIVE(MoveMemoryW__Lorg_eclipse_swt_internal_win32_LOGFONT_2II)
+ (JNIEnv *env, jclass that, jobject arg0, jint arg1, jint arg2)
+{
+ LOGFONTW _arg0, *lparg0=NULL;
+
+ DEBUG_CALL("MoveMemoryW__Lorg_eclipse_swt_internal_win32_LOGFONT_2II\n")
+ DEBUG_CHECK_NULL(env, arg1)
+
+ if (arg0) lparg0 = &_arg0;
+ MoveMemory((PVOID)lparg0, (CONST VOID *)arg1, arg2);
+ if (arg0) setLOGFONTWFields(env, arg0, lparg0);
+}
+#endif /* NO_MoveMemoryW__Lorg_eclipse_swt_internal_win32_LOGFONT_2II */
+
+#ifndef NO_MoveMemoryW__ILorg_eclipse_swt_internal_win32_LOGFONT_2I
+JNIEXPORT void JNICALL OS_NATIVE(MoveMemoryW__ILorg_eclipse_swt_internal_win32_LOGFONT_2I)
+ (JNIEnv *env, jclass that, jint arg0, jobject arg1, jint arg2)
+{
+ LOGFONTW _arg1, *lparg1=NULL;
+
+ DEBUG_CALL("MoveMemoryW__ILorg_eclipse_swt_internal_win32_LOGFONT_2I\n")
+ DEBUG_CHECK_NULL(env, arg0)
+
+ if (arg1) lparg1 = getLOGFONTWFields(env, arg1, &_arg1);
+ MoveMemory((PVOID)arg0, (CONST VOID *)lparg1, arg2);
+}
+#endif /* NO_MoveMemoryW__ILorg_eclipse_swt_internal_win32_LOGFONT_2I */
+
+#ifndef NO_MoveMemoryW__ILorg_eclipse_swt_internal_win32_NMTTDISPINFO_2I
+JNIEXPORT void JNICALL OS_NATIVE(MoveMemoryW__ILorg_eclipse_swt_internal_win32_NMTTDISPINFO_2I)
+ (JNIEnv *env, jclass that, jint arg0, jobject arg1, jint arg2)
+{
+ NMTTDISPINFOW _arg1={0}, *lparg1=NULL; /* SPECIAL */
+
+ DEBUG_CALL("MoveMemoryW__ILorg_eclipse_swt_internal_win32_NMTTDISPINFO_2I\n")
+ DEBUG_CHECK_NULL(env, arg0)
+
+ if (arg1) lparg1 = getNMTTDISPINFOWFields(env, arg1, &_arg1);
+ MoveMemory((PVOID)arg0, (CONST VOID *)lparg1, arg2);
+}
+#endif /* NO_MoveMemoryW__ILorg_eclipse_swt_internal_win32_NMTTDISPINFO_2I */
+
+#ifndef NO_MoveMemoryW__Lorg_eclipse_swt_internal_win32_NMTTDISPINFO_2II
+JNIEXPORT void JNICALL OS_NATIVE(MoveMemoryW__Lorg_eclipse_swt_internal_win32_NMTTDISPINFO_2II)
+ (JNIEnv *env, jclass that, jobject arg0, jint arg1, jint arg2)
+{
+ NMTTDISPINFOW _arg0={0}, *lparg0=NULL; /* SPECIAL */
+
+ DEBUG_CALL("MoveMemoryW__Lorg_eclipse_swt_internal_win32_NMTTDISPINFO_2II\n")
+ DEBUG_CHECK_NULL(env, arg1)
+
+ if (arg0) lparg0 = &_arg0;
+ MoveMemory((PVOID)lparg0, (CONST VOID *)arg1, arg2);
+ if (arg0) setNMTTDISPINFOWFields(env, arg0, lparg0);
+}
+#endif /* NO_MoveMemoryW__Lorg_eclipse_swt_internal_win32_NMTTDISPINFO_2II */
+
+#ifndef NO_MoveToEx
+JNIEXPORT jboolean JNICALL OS_NATIVE(MoveToEx)
+ (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jint arg3)
+{
+ DEBUG_CALL("MoveToEx\n")
+
+ return (jboolean)MoveToEx((HDC)arg0, arg1, arg2, (LPPOINT)arg3);
+}
+#endif /* NO_MoveToEx */
+
+#ifndef NO_MsgWaitForMultipleObjectsEx
+JNIEXPORT jint JNICALL OS_NATIVE(MsgWaitForMultipleObjectsEx)
+ (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jint arg3, jint arg4)
+{
+ DEBUG_CALL("MsgWaitForMultipleObjectsEx\n")
+
+ return (jint)MsgWaitForMultipleObjectsEx((DWORD)arg0, (LPHANDLE)arg1, (DWORD)arg2, (DWORD)arg3, (DWORD)arg4);
+}
+#endif /* NO_MsgWaitForMultipleObjectsEx */
+
+#ifndef NO_MultiByteToWideChar__IIII_3CI
+JNIEXPORT jint JNICALL OS_NATIVE(MultiByteToWideChar__IIII_3CI)
+ (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jint arg3, jcharArray arg4, jint arg5)
+{
+ jchar *lparg4=NULL;
+ jint rc;
+
+ DEBUG_CALL("MultiByteToWideChar__IIII_3CI\n")
+
+ if (arg4) lparg4 = (*env)->GetCharArrayElements(env, arg4, NULL);
+ rc = (jint)MultiByteToWideChar(arg0, arg1, (LPCSTR)arg2, arg3, (LPWSTR)lparg4, arg5);
+ if (arg4) (*env)->ReleaseCharArrayElements(env, arg4, lparg4, 0);
+ return rc;
+}
+#endif /* NO_MultiByteToWideChar__IIII_3CI */
+
+#ifndef NO_MultiByteToWideChar__II_3BI_3CI
+JNIEXPORT jint JNICALL OS_NATIVE(MultiByteToWideChar__II_3BI_3CI)
+ (JNIEnv *env, jclass that, jint arg0, jint arg1, jbyteArray arg2, jint arg3, jcharArray arg4, jint arg5)
+{
+ jbyte *lparg2=NULL;
+ jchar *lparg4=NULL;
+ jint rc;
+
+ DEBUG_CALL("MultiByteToWideChar__II_3BI_3CI\n")
+
+ if (arg2) lparg2 = (*env)->GetByteArrayElements(env, arg2, NULL);
+ if (arg4) lparg4 = (*env)->GetCharArrayElements(env, arg4, NULL);
+ rc = (jint)MultiByteToWideChar(arg0, arg1, (LPCSTR)lparg2, arg3, (LPWSTR)lparg4, arg5);
+ if (arg2) (*env)->ReleaseByteArrayElements(env, arg2, lparg2, 0);
+ if (arg4) (*env)->ReleaseCharArrayElements(env, arg4, lparg4, 0);
+ return rc;
+}
+#endif /* NO_MultiByteToWideChar__II_3BI_3CI */
+
+#ifndef NO_OleInitialize
+JNIEXPORT jint JNICALL OS_NATIVE(OleInitialize)
+ (JNIEnv *env, jclass that, jint arg0)
+{
+ DEBUG_CALL("OleInitialize\n")
+
+ return (jint)OleInitialize((LPVOID)arg0);
+}
+#endif /* NO_OleInitialize */
+
+#ifndef NO_OleUninitialize
+JNIEXPORT void JNICALL OS_NATIVE(OleUninitialize)
+ (JNIEnv *env, jclass that)
+{
+ DEBUG_CALL("OleUninitialize\n")
+
+ OleUninitialize();
+}
+#endif /* NO_OleUninitialize */
+
+#ifndef NO_OpenClipboard
+JNIEXPORT jboolean JNICALL OS_NATIVE(OpenClipboard)
+ (JNIEnv *env, jclass that, jint arg0)
+{
+ DEBUG_CALL("OpenClipboard\n")
+
+ return (jboolean)OpenClipboard((HWND)arg0);
+}
+#endif /* NO_OpenClipboard */
+
+#ifndef NO_PatBlt
+JNIEXPORT jboolean JNICALL OS_NATIVE(PatBlt)
+ (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jint arg3, jint arg4, jint arg5)
+{
+ DEBUG_CALL("PatBlt\n")
+
+ return (jboolean)PatBlt((HDC)arg0, arg1, arg2, arg3, arg4, arg5);
+}
+#endif /* NO_PatBlt */
+
+#ifndef NO_PeekMessageA
+JNIEXPORT jboolean JNICALL OS_NATIVE(PeekMessageA)
+ (JNIEnv *env, jclass that, jobject arg0, jint arg1, jint arg2, jint arg3, jint arg4)
+{
+ MSG _arg0, *lparg0=NULL;
+ jboolean rc;
+
+ DEBUG_CALL("PeekMessageA\n")
+
+ if (arg0) lparg0 = getMSGFields(env, arg0, &_arg0);
+ rc = (jboolean)PeekMessageA(lparg0, (HWND)arg1, arg2, arg3, arg4);
+ if (arg0) setMSGFields(env, arg0, lparg0);
+ return rc;
+}
+#endif /* NO_PeekMessageA */
+
+#ifndef NO_PeekMessageW
+JNIEXPORT jboolean JNICALL OS_NATIVE(PeekMessageW)
+ (JNIEnv *env, jclass that, jobject arg0, jint arg1, jint arg2, jint arg3, jint arg4)
+{
+ MSG _arg0, *lparg0=NULL;
+ jboolean rc;
+
+ DEBUG_CALL("PeekMessageW\n")
+
+ if (arg0) lparg0 = getMSGFields(env, arg0, &_arg0);
+ rc = (jboolean)PeekMessageW(lparg0, (HWND)arg1, arg2, arg3, arg4);
+ if (arg0) setMSGFields(env, arg0, lparg0);
+ return rc;
+}
+#endif /* NO_PeekMessageW */
+
+#ifndef NO_Pie
+JNIEXPORT jboolean JNICALL OS_NATIVE(Pie)
+ (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jint arg3, jint arg4, jint arg5, jint arg6, jint arg7, jint arg8)
+{
+ DEBUG_CALL("Pie\n")
+
+ return (jboolean)Pie((HDC)arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8);
+}
+#endif /* NO_Pie */
+
+#ifndef NO_Polygon
+JNIEXPORT jboolean JNICALL OS_NATIVE(Polygon)
+ (JNIEnv *env, jclass that, jint arg0, jintArray arg1, jint arg2)
+{
+ jint *lparg1=NULL;
+ jboolean rc;
+
+ DEBUG_CALL("Polygon\n")
+
+ if (arg1) lparg1 = (*env)->GetIntArrayElements(env, arg1, NULL);
+ rc = (jboolean)Polygon((HDC)arg0, (CONST POINT *)lparg1, arg2);
+ if (arg1) (*env)->ReleaseIntArrayElements(env, arg1, lparg1, 0);
+ return rc;
+}
+#endif /* NO_Polygon */
+
+#ifndef NO_Polyline
+JNIEXPORT jboolean JNICALL OS_NATIVE(Polyline)
+ (JNIEnv *env, jclass that, jint arg0, jintArray arg1, jint arg2)
+{
+ jint *lparg1=NULL;
+ jboolean rc;
+
+ DEBUG_CALL("Polyline\n")
+
+ if (arg1) lparg1 = (*env)->GetIntArrayElements(env, arg1, NULL);
+ rc = (jboolean)Polyline((HDC)arg0, (CONST POINT *)lparg1, arg2);
+ if (arg1) (*env)->ReleaseIntArrayElements(env, arg1, lparg1, 0);
+ return rc;
+}
+#endif /* NO_Polyline */
+
+#ifndef NO_PostMessageA
+JNIEXPORT jboolean JNICALL OS_NATIVE(PostMessageA)
+ (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jint arg3)
+{
+ DEBUG_CALL("PostMessageA\n")
+
+ return (jboolean)PostMessageA((HWND)arg0, arg1, (WPARAM)arg2, (LPARAM)arg3);
+}
+#endif /* NO_PostMessageA */
+
+#ifndef NO_PostMessageW
+JNIEXPORT jboolean JNICALL OS_NATIVE(PostMessageW)
+ (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jint arg3)
+{
+ DEBUG_CALL("PostMessageW\n")
+
+ return (jboolean)PostMessageW((HWND)arg0, arg1, (WPARAM)arg2, (LPARAM)arg3);
+}
+#endif /* NO_PostMessageW */
+
+#ifndef NO_PostThreadMessageA
+JNIEXPORT jboolean JNICALL OS_NATIVE(PostThreadMessageA)
+ (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jint arg3)
+{
+ DEBUG_CALL("PostThreadMessageA\n")
+
+ return (jboolean)PostThreadMessageA(arg0, arg1, (WPARAM)arg2, (LPARAM)arg3);
+}
+#endif /* NO_PostThreadMessageA */
+
+#ifndef NO_PostThreadMessageW
+JNIEXPORT jboolean JNICALL OS_NATIVE(PostThreadMessageW)
+ (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jint arg3)
+{
+ DEBUG_CALL("PostThreadMessageW\n")
+
+ return (jboolean)PostThreadMessageW(arg0, arg1, (WPARAM)arg2, (LPARAM)arg3);
+}
+#endif /* NO_PostThreadMessageW */
+
+#ifndef NO_PrintDlgA
+JNIEXPORT jboolean JNICALL OS_NATIVE(PrintDlgA)
+ (JNIEnv *env, jclass that, jobject arg0)
+{
+ PRINTDLG _arg0, *lparg0=NULL;
+ jboolean rc;
+
+ DEBUG_CALL("PrintDlgA\n")
+
+ if (arg0) lparg0 = getPRINTDLGFields(env, arg0, &_arg0);
+ rc = (jboolean)PrintDlgA(lparg0);
+ if (arg0) setPRINTDLGFields(env, arg0, lparg0);
+ return rc;
+}
+#endif /* NO_PrintDlgA */
+
+#ifndef NO_PrintDlgW
+JNIEXPORT jboolean JNICALL OS_NATIVE(PrintDlgW)
+ (JNIEnv *env, jclass that, jobject arg0)
+{
+ PRINTDLG _arg0, *lparg0=NULL;
+ jboolean rc;
+
+ DEBUG_CALL("PrintDlgW\n")
+
+ if (arg0) lparg0 = getPRINTDLGFields(env, arg0, &_arg0);
+ rc = (jboolean)PrintDlgW((LPPRINTDLGW)lparg0);
+ if (arg0) setPRINTDLGFields(env, arg0, lparg0);
+ return rc;
+}
+#endif /* NO_PrintDlgW */
+
+#ifndef NO_PtInRect
+JNIEXPORT jboolean JNICALL OS_NATIVE(PtInRect)
+ (JNIEnv *env, jclass that, jobject arg0, jobject arg1)
+{
+ RECT _arg0, *lparg0=NULL;
+ POINT _arg1, *lparg1=NULL;
+ jboolean rc;
+
+ DEBUG_CALL("PtInRect\n")
+
+ if (arg0) lparg0 = getRECTFields(env, arg0, &_arg0);
+ if (arg1) lparg1 = getPOINTFields(env, arg1, &_arg1);
+ rc = (jboolean)PtInRect(lparg0, *lparg1);
+ if (arg0) setRECTFields(env, arg0, lparg0);
+ if (arg1) setPOINTFields(env, arg1, lparg1);
+ return rc;
+}
+#endif /* NO_PtInRect */
+
+#ifndef NO_PtInRegion
+JNIEXPORT jboolean JNICALL OS_NATIVE(PtInRegion)
+ (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2)
+{
+ DEBUG_CALL("PtInRegion\n")
+
+ return (jboolean)PtInRegion((HRGN)arg0, arg1, arg2);
+}
+#endif /* NO_PtInRegion */
+
+#ifndef NO_RealizePalette
+JNIEXPORT jint JNICALL OS_NATIVE(RealizePalette)
+ (JNIEnv *env, jclass that, jint arg0)
+{
+ DEBUG_CALL("RealizePalette\n")
+
+ return (jint)RealizePalette((HDC)arg0);
+}
+#endif /* NO_RealizePalette */
+
+#ifndef NO_RectInRegion
+JNIEXPORT jboolean JNICALL OS_NATIVE(RectInRegion)
+ (JNIEnv *env, jclass that, jint arg0, jobject arg1)
+{
+ RECT _arg1, *lparg1=NULL;
+ jboolean rc;
+
+ DEBUG_CALL("RectInRegion\n")
+
+ if (arg1) lparg1 = getRECTFields(env, arg1, &_arg1);
+ rc = (jboolean)RectInRegion((HRGN)arg0, lparg1);
+ if (arg1) setRECTFields(env, arg1, lparg1);
+ return rc;
+}
+#endif /* NO_RectInRegion */
+
+#ifndef NO_Rectangle
+JNIEXPORT jboolean JNICALL OS_NATIVE(Rectangle)
+ (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jint arg3, jint arg4)
+{
+ DEBUG_CALL("Rectangle\n")
+
+ return (jboolean)Rectangle((HDC)arg0, arg1, arg2, arg3, arg4);
+}
+#endif /* NO_Rectangle */
+
+#ifndef NO_RedrawWindow
+JNIEXPORT jboolean JNICALL OS_NATIVE(RedrawWindow)
+ (JNIEnv *env, jclass that, jint arg0, jobject arg1, jint arg2, jint arg3)
+{
+ RECT _arg1, *lparg1=NULL;
+ jboolean rc;
+
+ DEBUG_CALL("RedrawWindow\n")
+
+ if (arg1) lparg1 = getRECTFields(env, arg1, &_arg1);
+ rc = (jboolean)RedrawWindow((HWND)arg0, lparg1, (HRGN)arg2, arg3);
+ if (arg1) setRECTFields(env, arg1, lparg1);
+ return rc;
+}
+#endif /* NO_RedrawWindow */
+
+#ifndef NO_RegCloseKey
+JNIEXPORT jint JNICALL OS_NATIVE(RegCloseKey)
+ (JNIEnv *env, jclass that, jint arg0)
+{
+ DEBUG_CALL("RegCloseKey\n")
+
+ return (jint)RegCloseKey((HKEY)arg0);
+}
+#endif /* NO_RegCloseKey */
+
+#ifndef NO_RegEnumKeyExA
+JNIEXPORT jint JNICALL OS_NATIVE(RegEnumKeyExA)
+ (JNIEnv *env, jclass that, jint arg0, jint arg1, jbyteArray arg2, jintArray arg3, jintArray arg4, jbyteArray arg5, jintArray arg6, jobject arg7)
+{
+ jbyte *lparg2=NULL;
+ jint *lparg3=NULL;
+ jint *lparg4=NULL;
+ jbyte *lparg5=NULL;
+ jint *lparg6=NULL;
+ FILETIME _arg7, *lparg7=NULL;
+ jint rc;
+
+ DEBUG_CALL("RegEnumKeyExA\n")
+
+ if (arg2) lparg2 = (*env)->GetByteArrayElements(env, arg2, NULL);
+ if (arg3) lparg3 = (*env)->GetIntArrayElements(env, arg3, NULL);
+ if (arg4) lparg4 = (*env)->GetIntArrayElements(env, arg4, NULL);
+ if (arg5) lparg5 = (*env)->GetByteArrayElements(env, arg5, NULL);
+ if (arg6) lparg6 = (*env)->GetIntArrayElements(env, arg6, NULL);
+ if (arg7) lparg7 = getFILETIMEFields(env, arg7, &_arg7);
+ rc = (jint)RegEnumKeyExA((HKEY)arg0, arg1, (LPSTR)lparg2, lparg3, lparg4, (LPSTR)lparg5, lparg6, lparg7);
+ if (arg2) (*env)->ReleaseByteArrayElements(env, arg2, lparg2, 0);
+ if (arg3) (*env)->ReleaseIntArrayElements(env, arg3, lparg3, 0);
+ if (arg4) (*env)->ReleaseIntArrayElements(env, arg4, lparg4, 0);
+ if (arg5) (*env)->ReleaseByteArrayElements(env, arg5, lparg5, 0);
+ if (arg6) (*env)->ReleaseIntArrayElements(env, arg6, lparg6, 0);
+ if (arg7) setFILETIMEFields(env, arg7, lparg7);
+ return rc;
+}
+#endif /* NO_RegEnumKeyExA */
+
+#ifndef NO_RegEnumKeyExW
+JNIEXPORT jint JNICALL OS_NATIVE(RegEnumKeyExW)
+ (JNIEnv *env, jclass that, jint arg0, jint arg1, jcharArray arg2, jintArray arg3, jintArray arg4, jcharArray arg5, jintArray arg6, jobject arg7)
+{
+ jchar *lparg2=NULL;
+ jint *lparg3=NULL;
+ jint *lparg4=NULL;
+ jchar *lparg5=NULL;
+ jint *lparg6=NULL;
+ FILETIME _arg7, *lparg7=NULL;
+ jint rc;
+
+ DEBUG_CALL("RegEnumKeyExW\n")
+
+ if (arg2) lparg2 = (*env)->GetCharArrayElements(env, arg2, NULL);
+ if (arg3) lparg3 = (*env)->GetIntArrayElements(env, arg3, NULL);
+ if (arg4) lparg4 = (*env)->GetIntArrayElements(env, arg4, NULL);
+ if (arg5) lparg5 = (*env)->GetCharArrayElements(env, arg5, NULL);
+ if (arg6) lparg6 = (*env)->GetIntArrayElements(env, arg6, NULL);
+ if (arg7) lparg7 = getFILETIMEFields(env, arg7, &_arg7);
+ rc = (jint)RegEnumKeyExW((HKEY)arg0, arg1, (LPWSTR)lparg2, lparg3, lparg4, (LPWSTR)lparg5, lparg6, lparg7);
+ if (arg2) (*env)->ReleaseCharArrayElements(env, arg2, lparg2, 0);
+ if (arg3) (*env)->ReleaseIntArrayElements(env, arg3, lparg3, 0);
+ if (arg4) (*env)->ReleaseIntArrayElements(env, arg4, lparg4, 0);
+ if (arg5) (*env)->ReleaseCharArrayElements(env, arg5, lparg5, 0);
+ if (arg6) (*env)->ReleaseIntArrayElements(env, arg6, lparg6, 0);
+ if (arg7) setFILETIMEFields(env, arg7, lparg7);
+ return rc;
+}
+#endif /* NO_RegEnumKeyExW */
+
+#ifndef NO_RegOpenKeyExA
+JNIEXPORT jint JNICALL OS_NATIVE(RegOpenKeyExA)
+ (JNIEnv *env, jclass that, jint arg0, jbyteArray arg1, jint arg2, jint arg3, jintArray arg4)
+{
+ jbyte *lparg1=NULL;
+ jint *lparg4=NULL;
+ jint rc;
+
+ DEBUG_CALL("RegOpenKeyExA\n")
+
+ if (arg1) lparg1 = (*env)->GetByteArrayElements(env, arg1, NULL);
+ if (arg4) lparg4 = (*env)->GetIntArrayElements(env, arg4, NULL);
+ rc = (jint)RegOpenKeyExA((HKEY)arg0, (LPSTR)lparg1, arg2, arg3, (PHKEY)lparg4);
+ if (arg1) (*env)->ReleaseByteArrayElements(env, arg1, lparg1, 0);
+ if (arg4) (*env)->ReleaseIntArrayElements(env, arg4, lparg4, 0);
+ return rc;
+}
+#endif /* NO_RegOpenKeyExA */
+
+#ifndef NO_RegOpenKeyExW
+JNIEXPORT jint JNICALL OS_NATIVE(RegOpenKeyExW)
+ (JNIEnv *env, jclass that, jint arg0, jcharArray arg1, jint arg2, jint arg3, jintArray arg4)
+{
+ jchar *lparg1=NULL;
+ jint *lparg4=NULL;
+ jint rc;
+
+ DEBUG_CALL("RegOpenKeyExW\n")
+
+ if (arg1) lparg1 = (*env)->GetCharArrayElements(env, arg1, NULL);
+ if (arg4) lparg4 = (*env)->GetIntArrayElements(env, arg4, NULL);
+ rc = (jint)RegOpenKeyExW((HKEY)arg0, (LPWSTR)lparg1, arg2, arg3, (PHKEY)lparg4);
+ if (arg1) (*env)->ReleaseCharArrayElements(env, arg1, lparg1, 0);
+ if (arg4) (*env)->ReleaseIntArrayElements(env, arg4, lparg4, 0);
+ return rc;
+}
+#endif /* NO_RegOpenKeyExW */
+
+#ifndef NO_RegQueryInfoKeyA
+JNIEXPORT jint JNICALL OS_NATIVE(RegQueryInfoKeyA)
+ (JNIEnv *env, jclass that, jint arg0, jint arg1, jintArray arg2, jint arg3, jintArray arg4, jintArray arg5, jintArray arg6, jintArray arg7, jintArray arg8, jintArray arg9, jintArray arg10, jint arg11)
+{
+ jint *lparg2=NULL;
+ jint *lparg4=NULL;
+ jint *lparg5=NULL;
+ jint *lparg6=NULL;
+ jint *lparg7=NULL;
+ jint *lparg8=NULL;
+ jint *lparg9=NULL;
+ jint *lparg10=NULL;
+ jint rc;
+
+ DEBUG_CALL("RegQueryInfoKeyA\n")
+
+ if (arg2) lparg2 = (*env)->GetIntArrayElements(env, arg2, NULL);
+ if (arg4) lparg4 = (*env)->GetIntArrayElements(env, arg4, NULL);
+ if (arg5) lparg5 = (*env)->GetIntArrayElements(env, arg5, NULL);
+ if (arg6) lparg6 = (*env)->GetIntArrayElements(env, arg6, NULL);
+ if (arg7) lparg7 = (*env)->GetIntArrayElements(env, arg7, NULL);
+ if (arg8) lparg8 = (*env)->GetIntArrayElements(env, arg8, NULL);
+ if (arg9) lparg9 = (*env)->GetIntArrayElements(env, arg9, NULL);
+ if (arg10) lparg10 = (*env)->GetIntArrayElements(env, arg10, NULL);
+ rc = (jint)RegQueryInfoKeyA((HKEY)arg0, (LPSTR)arg1, lparg2, (LPDWORD)arg3, lparg4, lparg5, lparg6, lparg7, lparg8, lparg9, lparg10, (PFILETIME)arg11);
+ if (arg2) (*env)->ReleaseIntArrayElements(env, arg2, lparg2, 0);
+ if (arg4) (*env)->ReleaseIntArrayElements(env, arg4, lparg4, 0);
+ if (arg5) (*env)->ReleaseIntArrayElements(env, arg5, lparg5, 0);
+ if (arg6) (*env)->ReleaseIntArrayElements(env, arg6, lparg6, 0);
+ if (arg7) (*env)->ReleaseIntArrayElements(env, arg7, lparg7, 0);
+ if (arg8) (*env)->ReleaseIntArrayElements(env, arg8, lparg8, 0);
+ if (arg9) (*env)->ReleaseIntArrayElements(env, arg9, lparg9, 0);
+ if (arg10) (*env)->ReleaseIntArrayElements(env, arg10, lparg10, 0);
+ return rc;
+}
+#endif /* NO_RegQueryInfoKeyA */
+
+#ifndef NO_RegQueryInfoKeyW
+JNIEXPORT jint JNICALL OS_NATIVE(RegQueryInfoKeyW)
+ (JNIEnv *env, jclass that, jint arg0, jint arg1, jintArray arg2, jint arg3, jintArray arg4, jintArray arg5, jintArray arg6, jintArray arg7, jintArray arg8, jintArray arg9, jintArray arg10, jint arg11)
+{
+ jint *lparg2=NULL;
+ jint *lparg4=NULL;
+ jint *lparg5=NULL;
+ jint *lparg6=NULL;
+ jint *lparg7=NULL;
+ jint *lparg8=NULL;
+ jint *lparg9=NULL;
+ jint *lparg10=NULL;
+ jint rc;
+
+ DEBUG_CALL("RegQueryInfoKeyW\n")
+
+ if (arg2) lparg2 = (*env)->GetIntArrayElements(env, arg2, NULL);
+ if (arg4) lparg4 = (*env)->GetIntArrayElements(env, arg4, NULL);
+ if (arg5) lparg5 = (*env)->GetIntArrayElements(env, arg5, NULL);
+ if (arg6) lparg6 = (*env)->GetIntArrayElements(env, arg6, NULL);
+ if (arg7) lparg7 = (*env)->GetIntArrayElements(env, arg7, NULL);
+ if (arg8) lparg8 = (*env)->GetIntArrayElements(env, arg8, NULL);
+ if (arg9) lparg9 = (*env)->GetIntArrayElements(env, arg9, NULL);
+ if (arg10) lparg10 = (*env)->GetIntArrayElements(env, arg10, NULL);
+ rc = (jint)RegQueryInfoKeyW((HKEY)arg0, (LPWSTR)arg1, lparg2, (LPDWORD)arg3, lparg4, lparg5, lparg6, lparg7, lparg8, lparg9, lparg10, (PFILETIME)arg11);
+ if (arg2) (*env)->ReleaseIntArrayElements(env, arg2, lparg2, 0);
+ if (arg4) (*env)->ReleaseIntArrayElements(env, arg4, lparg4, 0);
+ if (arg5) (*env)->ReleaseIntArrayElements(env, arg5, lparg5, 0);
+ if (arg6) (*env)->ReleaseIntArrayElements(env, arg6, lparg6, 0);
+ if (arg7) (*env)->ReleaseIntArrayElements(env, arg7, lparg7, 0);
+ if (arg8) (*env)->ReleaseIntArrayElements(env, arg8, lparg8, 0);
+ if (arg9) (*env)->ReleaseIntArrayElements(env, arg9, lparg9, 0);
+ if (arg10) (*env)->ReleaseIntArrayElements(env, arg10, lparg10, 0);
+ return rc;
+}
+#endif /* NO_RegQueryInfoKeyW */
+
+#ifndef NO_RegQueryValueExA
+JNIEXPORT jint JNICALL OS_NATIVE(RegQueryValueExA)
+ (JNIEnv *env, jclass that, jint arg0, jbyteArray arg1, jint arg2, jintArray arg3, jbyteArray arg4, jintArray arg5)
+{
+ jbyte *lparg1=NULL;
+ jint *lparg3=NULL;
+ jbyte *lparg4=NULL;
+ jint *lparg5=NULL;
+ jint rc;
+
+ DEBUG_CALL("RegQueryValueExA\n")
+
+ if (arg1) lparg1 = (*env)->GetByteArrayElements(env, arg1, NULL);
+ if (arg3) lparg3 = (*env)->GetIntArrayElements(env, arg3, NULL);
+ if (arg4) lparg4 = (*env)->GetByteArrayElements(env, arg4, NULL);
+ if (arg5) lparg5 = (*env)->GetIntArrayElements(env, arg5, NULL);
+ rc = (jint)RegQueryValueExA((HKEY)arg0, (LPSTR)lparg1, (LPDWORD)arg2, lparg3, (LPBYTE)lparg4, lparg5);
+ if (arg1) (*env)->ReleaseByteArrayElements(env, arg1, lparg1, 0);
+ if (arg3) (*env)->ReleaseIntArrayElements(env, arg3, lparg3, 0);
+ if (arg4) (*env)->ReleaseByteArrayElements(env, arg4, lparg4, 0);
+ if (arg5) (*env)->ReleaseIntArrayElements(env, arg5, lparg5, 0);
+ return rc;
+}
+#endif /* NO_RegQueryValueExA */
+
+#ifndef NO_RegQueryValueExW
+JNIEXPORT jint JNICALL OS_NATIVE(RegQueryValueExW)
+ (JNIEnv *env, jclass that, jint arg0, jcharArray arg1, jint arg2, jintArray arg3, jcharArray arg4, jintArray arg5)
+{
+ jchar *lparg1=NULL;
+ jint *lparg3=NULL;
+ jchar *lparg4=NULL;
+ jint *lparg5=NULL;
+ jint rc;
+
+ DEBUG_CALL("RegQueryValueExW\n")
+
+ if (arg1) lparg1 = (*env)->GetCharArrayElements(env, arg1, NULL);
+ if (arg3) lparg3 = (*env)->GetIntArrayElements(env, arg3, NULL);
+ if (arg4) lparg4 = (*env)->GetCharArrayElements(env, arg4, NULL);
+ if (arg5) lparg5 = (*env)->GetIntArrayElements(env, arg5, NULL);
+ rc = (jint)RegQueryValueExW((HKEY)arg0, (LPWSTR)lparg1, (LPDWORD)arg2, lparg3, (LPBYTE)lparg4, lparg5);
+ if (arg1) (*env)->ReleaseCharArrayElements(env, arg1, lparg1, 0);
+ if (arg3) (*env)->ReleaseIntArrayElements(env, arg3, lparg3, 0);
+ if (arg4) (*env)->ReleaseCharArrayElements(env, arg4, lparg4, 0);
+ if (arg5) (*env)->ReleaseIntArrayElements(env, arg5, lparg5, 0);
+ return rc;
+}
+#endif /* NO_RegQueryValueExW */
+
+#ifndef NO_RegisterClassA
+JNIEXPORT jint JNICALL OS_NATIVE(RegisterClassA)
+ (JNIEnv *env, jclass that, jobject arg0)
+{
+ WNDCLASS _arg0, *lparg0=NULL;
+ jint rc;
+
+ DEBUG_CALL("RegisterClassA\n")
+
+ if (arg0) lparg0 = getWNDCLASSFields(env, arg0, &_arg0);
+ rc = (jint)RegisterClassA(lparg0);
+ if (arg0) setWNDCLASSFields(env, arg0, lparg0);
+ return rc;
+}
+#endif /* NO_RegisterClassA */
+
+#ifndef NO_RegisterClassW
+JNIEXPORT jint JNICALL OS_NATIVE(RegisterClassW)
+ (JNIEnv *env, jclass that, jobject arg0)
+{
+ WNDCLASS _arg0, *lparg0=NULL;
+ jint rc;
+
+ DEBUG_CALL("RegisterClassW\n")
+
+ if (arg0) lparg0 = getWNDCLASSFields(env, arg0, &_arg0);
+ rc = (jint)RegisterClassW((LPWNDCLASSW)lparg0);
+ if (arg0) setWNDCLASSFields(env, arg0, lparg0);
+ return rc;
+}
+#endif /* NO_RegisterClassW */
+
+#ifndef NO_RegisterClipboardFormatA
+JNIEXPORT jint JNICALL OS_NATIVE(RegisterClipboardFormatA)
+ (JNIEnv *env, jclass that, jbyteArray arg0)
+{
+ jbyte *lparg0=NULL;
+ jint rc;
+
+ DEBUG_CALL("RegisterClipboardFormatA\n")
+
+ if (arg0) lparg0 = (*env)->GetByteArrayElements(env, arg0, NULL);
+ rc = (jint)RegisterClipboardFormatA((LPTSTR)lparg0);
+ if (arg0) (*env)->ReleaseByteArrayElements(env, arg0, lparg0, 0);
+ return rc;
+}
+#endif /* NO_RegisterClipboardFormatA */
+
+#ifndef NO_RegisterClipboardFormatW
+JNIEXPORT jint JNICALL OS_NATIVE(RegisterClipboardFormatW)
+ (JNIEnv *env, jclass that, jcharArray arg0)
+{
+ jchar *lparg0=NULL;
+ jint rc;
+
+ DEBUG_CALL("RegisterClipboardFormatW\n")
+
+ if (arg0) lparg0 = (*env)->GetCharArrayElements(env, arg0, NULL);
+ rc = (jint)RegisterClipboardFormatW((LPWSTR)lparg0);
+ if (arg0) (*env)->ReleaseCharArrayElements(env, arg0, lparg0, 0);
+ return rc;
+}
+#endif /* NO_RegisterClipboardFormatW */
+
+#ifndef NO_ReleaseCapture
+JNIEXPORT jboolean JNICALL OS_NATIVE(ReleaseCapture)
+ (JNIEnv *env, jclass that)
+{
+ DEBUG_CALL("ReleaseCapture\n")
+
+ return (jboolean)ReleaseCapture();
+}
+#endif /* NO_ReleaseCapture */
+
+#ifndef NO_ReleaseDC
+JNIEXPORT jint JNICALL OS_NATIVE(ReleaseDC)
+ (JNIEnv *env, jclass that, jint arg0, jint arg1)
+{
+ DEBUG_CALL("ReleaseDC\n")
+
+ return (jint)ReleaseDC((HWND)arg0, (HDC)arg1);
+}
+#endif /* NO_ReleaseDC */
+
+#ifndef NO_RemoveMenu
+JNIEXPORT jboolean JNICALL OS_NATIVE(RemoveMenu)
+ (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2)
+{
+ DEBUG_CALL("RemoveMenu\n")
+
+ return (jboolean)RemoveMenu((HMENU)arg0, arg1, arg2);
+}
+#endif /* NO_RemoveMenu */
+
+#ifndef NO_RoundRect
+JNIEXPORT jboolean JNICALL OS_NATIVE(RoundRect)
+ (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jint arg3, jint arg4, jint arg5, jint arg6)
+{
+ DEBUG_CALL("RoundRect\n")
+
+ return (jboolean)RoundRect((HDC)arg0, arg1, arg2, arg3, arg4, arg5, arg6);
+}
+#endif /* NO_RoundRect */
+
+#ifndef NO_SHBrowseForFolderA
+JNIEXPORT jint JNICALL OS_NATIVE(SHBrowseForFolderA)
+ (JNIEnv *env, jclass that, jobject arg0)
+{
+ BROWSEINFO _arg0, *lparg0=NULL;
+ jint rc;
+
+ DEBUG_CALL("SHBrowseForFolderA\n")
+
+ if (arg0) lparg0 = getBROWSEINFOFields(env, arg0, &_arg0);
+ rc = (jint)SHBrowseForFolderA(lparg0);
+ if (arg0) setBROWSEINFOFields(env, arg0, lparg0);
+ return rc;
+}
+#endif /* NO_SHBrowseForFolderA */
+
+#ifndef NO_SHBrowseForFolderW
+JNIEXPORT jint JNICALL OS_NATIVE(SHBrowseForFolderW)
+ (JNIEnv *env, jclass that, jobject arg0)
+{
+ BROWSEINFO _arg0, *lparg0=NULL;
+ jint rc;
+
+ DEBUG_CALL("SHBrowseForFolderW\n")
+
+ if (arg0) lparg0 = getBROWSEINFOFields(env, arg0, &_arg0);
+ rc = (jint)SHBrowseForFolderW((LPBROWSEINFOW)lparg0);
+ if (arg0) setBROWSEINFOFields(env, arg0, lparg0);
+ return rc;
+}
+#endif /* NO_SHBrowseForFolderW */
+
+#ifndef NO_SHCreateMenuBar
+JNIEXPORT jboolean JNICALL OS_NATIVE(SHCreateMenuBar)
+ (JNIEnv *env, jclass that, jobject arg0)
+{
+ SHMENUBARINFO _arg0, *lparg0=NULL;
+ jboolean rc;
+
+ DEBUG_CALL("SHCreateMenuBar\n")
+
+ if (arg0) lparg0 = getSHMENUBARINFOFields(env, arg0, &_arg0);
+ rc = (jboolean)SHCreateMenuBar((PSHMENUBARINFO)lparg0);
+ if (arg0) setSHMENUBARINFOFields(env, arg0, lparg0);
+ return rc;
+}
+#endif /* NO_SHCreateMenuBar */
+
+#ifndef NO_SHGetMalloc
+JNIEXPORT jint JNICALL OS_NATIVE(SHGetMalloc)
+ (JNIEnv *env, jclass that, jintArray arg0)
+{
+ jint *lparg0=NULL;
+ jint rc;
+
+ DEBUG_CALL("SHGetMalloc\n")
+
+ if (arg0) lparg0 = (*env)->GetIntArrayElements(env, arg0, NULL);
+ rc = (jint)SHGetMalloc((LPMALLOC *)lparg0);
+ if (arg0) (*env)->ReleaseIntArrayElements(env, arg0, lparg0, 0);
+ return rc;
+}
+#endif /* NO_SHGetMalloc */
+
+#ifndef NO_SHGetPathFromIDListA
+JNIEXPORT jboolean JNICALL OS_NATIVE(SHGetPathFromIDListA)
+ (JNIEnv *env, jclass that, jint arg0, jbyteArray arg1)
+{
+ jbyte *lparg1=NULL;
+ jboolean rc;
+
+ DEBUG_CALL("SHGetPathFromIDListA\n")
+
+ if (arg1) lparg1 = (*env)->GetByteArrayElements(env, arg1, NULL);
+ rc = (jboolean)SHGetPathFromIDListA((LPCITEMIDLIST)arg0, (LPSTR)lparg1);
+ if (arg1) (*env)->ReleaseByteArrayElements(env, arg1, lparg1, 0);
+ return rc;
+}
+#endif /* NO_SHGetPathFromIDListA */
+
+#ifndef NO_SHGetPathFromIDListW
+JNIEXPORT jboolean JNICALL OS_NATIVE(SHGetPathFromIDListW)
+ (JNIEnv *env, jclass that, jint arg0, jcharArray arg1)
+{
+ jchar *lparg1=NULL;
+ jboolean rc;
+
+ DEBUG_CALL("SHGetPathFromIDListW\n")
+
+ if (arg1) lparg1 = (*env)->GetCharArrayElements(env, arg1, NULL);
+ rc = (jboolean)SHGetPathFromIDListW((LPCITEMIDLIST)arg0, (LPWSTR)lparg1);
+ if (arg1) (*env)->ReleaseCharArrayElements(env, arg1, lparg1, 0);
+ return rc;
+}
+#endif /* NO_SHGetPathFromIDListW */
+
+#ifndef NO_SHHandleWMSettingChange
+JNIEXPORT jboolean JNICALL OS_NATIVE(SHHandleWMSettingChange)
+ (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jobject arg3)
+{
+ SHACTIVATEINFO _arg3, *lparg3=NULL;
+ jboolean rc;
+
+ DEBUG_CALL("SHHandleWMSettingChange\n")
+
+ if (arg3) lparg3 = getSHACTIVATEINFOFields(env, arg3, &_arg3);
+ rc = (jboolean)SHHandleWMSettingChange((HWND)arg0, arg1, arg2, lparg3);
+ if (arg3) setSHACTIVATEINFOFields(env, arg3, lparg3);
+ return rc;
+}
+#endif /* NO_SHHandleWMSettingChange */
+
+#ifndef NO_SHRecognizeGesture
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_win32_OS_SHRecognizeGesture
+ (JNIEnv *env, jclass that, jobject arg0)
+{
+ SHRGINFO _arg0, *lparg0=NULL;
+ jint rc;
+
+ DEBUG_CALL("SHRecognizeGesture\n")
+
+ if (arg0) lparg0 = getSHRGINFOFields(env, arg0, &_arg0);
+ rc = (jint)SHRecognizeGesture(lparg0);
+ if (arg0) setSHRGINFOFields(env, arg0, lparg0);
+ return rc;
+}
+#endif
+
+#ifndef NO_SHSendBackToFocusWindow
+JNIEXPORT void JNICALL OS_NATIVE(SHSendBackToFocusWindow)
+ (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2)
+{
+ DEBUG_CALL("SHSendBackToFocusWindow\n")
+
+ SHSendBackToFocusWindow(arg0, arg1, arg2);
+}
+#endif /* NO_SHSendBackToFocusWindow */
+
+#ifndef NO_SHSetAppKeyWndAssoc
+JNIEXPORT jboolean JNICALL OS_NATIVE(SHSetAppKeyWndAssoc)
+ (JNIEnv *env, jclass that, jbyte arg0, jint arg1)
+{
+ DEBUG_CALL("SHSetAppKeyWndAssoc\n")
+
+ return (jboolean)SHSetAppKeyWndAssoc((BYTE)arg0, (HWND)arg1);
+}
+#endif /* NO_SHSetAppKeyWndAssoc */
+
+#ifndef NO_SHSipPreference
+JNIEXPORT jboolean JNICALL OS_NATIVE(SHSipPreference)
+ (JNIEnv *env, jclass that, jint arg0, jint arg1)
+{
+ DEBUG_CALL("SHSipPreference\n")
+
+ return (jboolean)SHSipPreference((HWND)arg0, arg1);
+}
+#endif /* NO_SHSipPreference */
+
+#ifndef NO_ScreenToClient
+JNIEXPORT jboolean JNICALL OS_NATIVE(ScreenToClient)
+ (JNIEnv *env, jclass that, jint arg0, jobject arg1)
+{
+ POINT _arg1, *lparg1=NULL;
+ jboolean rc;
+
+ DEBUG_CALL("ScreenToClient\n")
+
+ if (arg1) lparg1 = getPOINTFields(env, arg1, &_arg1);
+ rc = (jboolean)ScreenToClient((HWND)arg0, lparg1);
+ if (arg1) setPOINTFields(env, arg1, lparg1);
+ return rc;
+}
+#endif /* NO_ScreenToClient */
+
+#ifndef NO_ScrollWindowEx
+JNIEXPORT jint JNICALL OS_NATIVE(ScrollWindowEx)
+ (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jobject arg3, jobject arg4, jint arg5, jobject arg6, jint arg7)
+{
+ RECT _arg3, *lparg3=NULL;
+ RECT _arg4, *lparg4=NULL;
+ RECT _arg6, *lparg6=NULL;
+ jint rc;
+
+ DEBUG_CALL("ScrollWindowEx\n")
+
+ if (arg3) lparg3 = getRECTFields(env, arg3, &_arg3);
+ if (arg4) lparg4 = getRECTFields(env, arg4, &_arg4);
+ if (arg6) lparg6 = getRECTFields(env, arg6, &_arg6);
+ rc = (jint)ScrollWindowEx((HWND)arg0, arg1, arg2, lparg3, lparg4, (HRGN)arg5, lparg6, arg7);
+ if (arg3) setRECTFields(env, arg3, lparg3);
+ if (arg4) setRECTFields(env, arg4, lparg4);
+ if (arg6) setRECTFields(env, arg6, lparg6);
+ return rc;
+}
+#endif /* NO_ScrollWindowEx */
+
+#ifndef NO_SelectClipRgn
+JNIEXPORT jint JNICALL OS_NATIVE(SelectClipRgn)
+ (JNIEnv *env, jclass that, jint arg0, jint arg1)
+{
+ DEBUG_CALL("SelectClipRgn\n")
+
+ return (jint)SelectClipRgn((HDC)arg0, (HRGN)arg1);
+}
+#endif /* NO_SelectClipRgn */
+
+#ifndef NO_SelectObject
+JNIEXPORT jint JNICALL OS_NATIVE(SelectObject)
+ (JNIEnv *env, jclass that, jint arg0, jint arg1)
+{
+ DEBUG_CALL("SelectObject\n")
+
+ return (jint)SelectObject((HDC)arg0, (HGDIOBJ)arg1);
+}
+#endif /* NO_SelectObject */
+
+#ifndef NO_SelectPalette
+JNIEXPORT jint JNICALL OS_NATIVE(SelectPalette)
+ (JNIEnv *env, jclass that, jint arg0, jint arg1, jboolean arg2)
+{
+ DEBUG_CALL("SelectPalette\n")
+
+ return (jint)SelectPalette((HDC)arg0, (HPALETTE)arg1, arg2);
+}
+#endif /* NO_SelectPalette */
+
+#ifndef NO_SendMessageA__III_3I
+JNIEXPORT jint JNICALL OS_NATIVE(SendMessageA__III_3I)
+ (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jintArray arg3)
+{
+ jint *lparg3=NULL;
+ jint rc;
+
+ DEBUG_CALL("SendMessageA__III_3I\n")
+
+ if (arg3) lparg3 = (*env)->GetIntArrayElements(env, arg3, NULL);
+ rc = (jint)SendMessageA((HWND)arg0, arg1, arg2, (LPARAM)lparg3);
+ if (arg3) (*env)->ReleaseIntArrayElements(env, arg3, lparg3, 0);
+ return rc;
+}
+#endif /* NO_SendMessageA__III_3I */
+
+#ifndef NO_SendMessageA__III_3B
+JNIEXPORT jint JNICALL OS_NATIVE(SendMessageA__III_3B)
+ (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jbyteArray arg3)
+{
+ jbyte *lparg3=NULL;
+ jint rc;
+
+ DEBUG_CALL("SendMessageA__III_3B\n")
+
+ if (arg3) lparg3 = (*env)->GetByteArrayElements(env, arg3, NULL);
+ rc = (jint)SendMessageA((HWND)arg0, arg1, arg2, (LPARAM)lparg3);
+ if (arg3) (*env)->ReleaseByteArrayElements(env, arg3, lparg3, 0);
+ return rc;
+}
+#endif /* NO_SendMessageA__III_3B */
+
+#ifndef NO_SendMessageA__II_3II
+JNIEXPORT jint JNICALL OS_NATIVE(SendMessageA__II_3II)
+ (JNIEnv *env, jclass that, jint arg0, jint arg1, jintArray arg2, jint arg3)
+{
+ jint *lparg2=NULL;
+ jint rc;
+
+ DEBUG_CALL("SendMessageA__II_3II\n")
+
+ if (arg2) lparg2 = (*env)->GetIntArrayElements(env, arg2, NULL);
+ rc = (jint)SendMessageA((HWND)arg0, arg1, (WPARAM)lparg2, (LPARAM)arg3);
+ if (arg2) (*env)->ReleaseIntArrayElements(env, arg2, lparg2, 0);
+ return rc;
+}
+#endif /* NO_SendMessageA__II_3II */
+
+#ifndef NO_SendMessageA__II_3I_3I
+JNIEXPORT jint JNICALL OS_NATIVE(SendMessageA__II_3I_3I)
+ (JNIEnv *env, jclass that, jint arg0, jint arg1, jintArray arg2, jintArray arg3)
+{
+ jint *lparg2=NULL;
+ jint *lparg3=NULL;
+ jint rc;
+
+ DEBUG_CALL("SendMessageA__II_3I_3I\n")
+
+ if (arg2) lparg2 = (*env)->GetIntArrayElements(env, arg2, NULL);
+ if (arg3) lparg3 = (*env)->GetIntArrayElements(env, arg3, NULL);
+ rc = (jint)SendMessageA((HWND)arg0, arg1, (WPARAM)lparg2, (LPARAM)lparg3);
+ if (arg2) (*env)->ReleaseIntArrayElements(env, arg2, lparg2, 0);
+ if (arg3) (*env)->ReleaseIntArrayElements(env, arg3, lparg3, 0);
+ return rc;
+}
+#endif /* NO_SendMessageA__II_3I_3I */
+
+#ifndef NO_SendMessageA__IIII
+JNIEXPORT jint JNICALL OS_NATIVE(SendMessageA__IIII)
+ (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jint arg3)
+{
+ DEBUG_CALL("SendMessageA__IIII\n")
+
+ return (jint)SendMessageA((HWND)arg0, arg1, arg2, arg3);
+}
+#endif /* NO_SendMessageA__IIII */
+
+#ifndef NO_SendMessageA__IIILorg_eclipse_swt_internal_win32_LVHITTESTINFO_2
+JNIEXPORT jint JNICALL OS_NATIVE(SendMessageA__IIILorg_eclipse_swt_internal_win32_LVHITTESTINFO_2)
+ (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jobject arg3)
+{
+ LVHITTESTINFO _arg3, *lparg3=NULL;
+ jint rc;
+
+ DEBUG_CALL("SendMessageA__IIILorg_eclipse_swt_internal_win32_LVHITTESTINFO_2\n")
+
+ if (arg3) lparg3 = getLVHITTESTINFOFields(env, arg3, &_arg3);
+ rc = (jint)SendMessageA((HWND)arg0, arg1, arg2, (LPARAM)lparg3);
+ if (arg3) setLVHITTESTINFOFields(env, arg3, lparg3);
+ return rc;
+}
+#endif /* NO_SendMessageA__IIILorg_eclipse_swt_internal_win32_LVHITTESTINFO_2 */
+
+#ifndef NO_SendMessageA__IIILorg_eclipse_swt_internal_win32_LVITEM_2
+JNIEXPORT jint JNICALL OS_NATIVE(SendMessageA__IIILorg_eclipse_swt_internal_win32_LVITEM_2)
+ (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jobject arg3)
+{
+ LVITEM _arg3, *lparg3=NULL;
+ jint rc;
+
+ DEBUG_CALL("SendMessageA__IIILorg_eclipse_swt_internal_win32_LVITEM_2\n")
+
+ if (arg3) lparg3 = getLVITEMFields(env, arg3, &_arg3);
+ rc = (jint)SendMessageA((HWND)arg0, arg1, arg2, (LPARAM)lparg3);
+ if (arg3) setLVITEMFields(env, arg3, lparg3);
+ return rc;
+}
+#endif /* NO_SendMessageA__IIILorg_eclipse_swt_internal_win32_LVITEM_2 */
+
+#ifndef NO_SendMessageA__IIILorg_eclipse_swt_internal_win32_REBARBANDINFO_2
+JNIEXPORT jint JNICALL OS_NATIVE(SendMessageA__IIILorg_eclipse_swt_internal_win32_REBARBANDINFO_2)
+ (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jobject arg3)
+{
+ REBARBANDINFO _arg3, *lparg3=NULL;
+ jint rc;
+
+ DEBUG_CALL("SendMessageA__IIILorg_eclipse_swt_internal_win32_REBARBANDINFO_2\n")
+
+ if (arg3) lparg3 = getREBARBANDINFOFields(env, arg3, &_arg3);
+ rc = (jint)SendMessageA((HWND)arg0, arg1, arg2, (LPARAM)lparg3);
+ if (arg3) setREBARBANDINFOFields(env, arg3, lparg3);
+ return rc;
+}
+#endif /* NO_SendMessageA__IIILorg_eclipse_swt_internal_win32_REBARBANDINFO_2 */
+
+#ifndef NO_SendMessageA__IIILorg_eclipse_swt_internal_win32_RECT_2
+JNIEXPORT jint JNICALL OS_NATIVE(SendMessageA__IIILorg_eclipse_swt_internal_win32_RECT_2)
+ (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jobject arg3)
+{
+ RECT _arg3, *lparg3=NULL;
+ jint rc;
+
+ DEBUG_CALL("SendMessageA__IIILorg_eclipse_swt_internal_win32_RECT_2\n")
+
+ if (arg3) lparg3 = getRECTFields(env, arg3, &_arg3);
+ rc = (jint)SendMessageA((HWND)arg0, arg1, arg2, (LPARAM)lparg3);
+ if (arg3) setRECTFields(env, arg3, lparg3);
+ return rc;
+}
+#endif /* NO_SendMessageA__IIILorg_eclipse_swt_internal_win32_RECT_2 */
+
+#ifndef NO_SendMessageA__IIILorg_eclipse_swt_internal_win32_TBBUTTON_2
+JNIEXPORT jint JNICALL OS_NATIVE(SendMessageA__IIILorg_eclipse_swt_internal_win32_TBBUTTON_2)
+ (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jobject arg3)
+{
+ TBBUTTON _arg3, *lparg3=NULL;
+ jint rc;
+
+ DEBUG_CALL("SendMessageA__IIILorg_eclipse_swt_internal_win32_TBBUTTON_2\n")
+
+ if (arg3) lparg3 = getTBBUTTONFields(env, arg3, &_arg3);
+ rc = (jint)SendMessageA((HWND)arg0, arg1, arg2, (LPARAM)lparg3);
+ if (arg3) setTBBUTTONFields(env, arg3, lparg3);
+ return rc;
+}
+#endif /* NO_SendMessageA__IIILorg_eclipse_swt_internal_win32_TBBUTTON_2 */
+
+#ifndef NO_SendMessageA__IIILorg_eclipse_swt_internal_win32_TBBUTTONINFO_2
+JNIEXPORT jint JNICALL OS_NATIVE(SendMessageA__IIILorg_eclipse_swt_internal_win32_TBBUTTONINFO_2)
+ (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jobject arg3)
+{
+ TBBUTTONINFO _arg3, *lparg3=NULL;
+ jint rc;
+
+ DEBUG_CALL("SendMessageA__IIILorg_eclipse_swt_internal_win32_TBBUTTONINFO_2\n")
+
+ if (arg3) lparg3 = getTBBUTTONINFOFields(env, arg3, &_arg3);
+ rc = (jint)SendMessageA((HWND)arg0, arg1, arg2, (LPARAM)lparg3);
+ if (arg3) setTBBUTTONINFOFields(env, arg3, lparg3);
+ return rc;
+}
+#endif /* NO_SendMessageA__IIILorg_eclipse_swt_internal_win32_TBBUTTONINFO_2 */
+
+#ifndef NO_SendMessageA__IIILorg_eclipse_swt_internal_win32_TCITEM_2
+JNIEXPORT jint JNICALL OS_NATIVE(SendMessageA__IIILorg_eclipse_swt_internal_win32_TCITEM_2)
+ (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jobject arg3)
+{
+ TCITEM _arg3, *lparg3=NULL;
+ jint rc;
+
+ DEBUG_CALL("SendMessageA__IIILorg_eclipse_swt_internal_win32_TCITEM_2\n")
+
+ if (arg3) lparg3 = getTCITEMFields(env, arg3, &_arg3);
+ rc = (jint)SendMessageA((HWND)arg0, arg1, arg2, (LPARAM)lparg3);
+ if (arg3) setTCITEMFields(env, arg3, lparg3);
+ return rc;
+}
+#endif /* NO_SendMessageA__IIILorg_eclipse_swt_internal_win32_TCITEM_2 */
+
+#ifndef NO_SendMessageA__IIILorg_eclipse_swt_internal_win32_TOOLINFO_2
+JNIEXPORT jint JNICALL OS_NATIVE(SendMessageA__IIILorg_eclipse_swt_internal_win32_TOOLINFO_2)
+ (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jobject arg3)
+{
+ TOOLINFO _arg3, *lparg3=NULL;
+ jint rc;
+
+ DEBUG_CALL("SendMessageA__IIILorg_eclipse_swt_internal_win32_TOOLINFO_2\n")
+
+ if (arg3) lparg3 = getTOOLINFOFields(env, arg3, &_arg3);
+ rc = (jint)SendMessageA((HWND)arg0, arg1, arg2, (LPARAM)lparg3);
+ if (arg3) setTOOLINFOFields(env, arg3, lparg3);
+ return rc;
+}
+#endif /* NO_SendMessageA__IIILorg_eclipse_swt_internal_win32_TOOLINFO_2 */
+
+#ifndef NO_SendMessageA__IIILorg_eclipse_swt_internal_win32_TVHITTESTINFO_2
+JNIEXPORT jint JNICALL OS_NATIVE(SendMessageA__IIILorg_eclipse_swt_internal_win32_TVHITTESTINFO_2)
+ (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jobject arg3)
+{
+ TVHITTESTINFO _arg3, *lparg3=NULL;
+ jint rc;
+
+ DEBUG_CALL("SendMessageA__IIILorg_eclipse_swt_internal_win32_TVHITTESTINFO_2\n")
+
+ if (arg3) lparg3 = getTVHITTESTINFOFields(env, arg3, &_arg3);
+ rc = (jint)SendMessageA((HWND)arg0, arg1, arg2, (LPARAM)lparg3);
+ if (arg3) setTVHITTESTINFOFields(env, arg3, lparg3);
+ return rc;
+}
+#endif /* NO_SendMessageA__IIILorg_eclipse_swt_internal_win32_TVHITTESTINFO_2 */
+
+#ifndef NO_SendMessageA__IIILorg_eclipse_swt_internal_win32_TVINSERTSTRUCT_2
+JNIEXPORT jint JNICALL OS_NATIVE(SendMessageA__IIILorg_eclipse_swt_internal_win32_TVINSERTSTRUCT_2)
+ (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jobject arg3)
+{
+ TVINSERTSTRUCT _arg3, *lparg3=NULL;
+ jint rc;
+
+ DEBUG_CALL("SendMessageA__IIILorg_eclipse_swt_internal_win32_TVINSERTSTRUCT_2\n")
+
+ if (arg3) lparg3 = getTVINSERTSTRUCTFields(env, arg3, &_arg3);
+ rc = (jint)SendMessageA((HWND)arg0, arg1, arg2, (LPARAM)lparg3);
+ if (arg3) setTVINSERTSTRUCTFields(env, arg3, lparg3);
+ return rc;
+}
+#endif /* NO_SendMessageA__IIILorg_eclipse_swt_internal_win32_TVINSERTSTRUCT_2 */
+
+#ifndef NO_SendMessageA__IIILorg_eclipse_swt_internal_win32_TVITEM_2
+JNIEXPORT jint JNICALL OS_NATIVE(SendMessageA__IIILorg_eclipse_swt_internal_win32_TVITEM_2)
+ (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jobject arg3)
+{
+ TVITEM _arg3, *lparg3=NULL;
+ jint rc;
+
+ DEBUG_CALL("SendMessageA__IIILorg_eclipse_swt_internal_win32_TVITEM_2\n")
+
+ if (arg3) lparg3 = getTVITEMFields(env, arg3, &_arg3);
+ rc = (jint)SendMessageA((HWND)arg0, arg1, arg2, (LPARAM)lparg3);
+ if (arg3) setTVITEMFields(env, arg3, lparg3);
+ return rc;
+}
+#endif /* NO_SendMessageA__IIILorg_eclipse_swt_internal_win32_TVITEM_2 */
+
+#ifndef NO_SendMessageA__III_3S
+JNIEXPORT jint JNICALL OS_NATIVE(SendMessageA__III_3S)
+ (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jshortArray arg3)
+{
+ jshort *lparg3=NULL;
+ jint rc;
+
+ DEBUG_CALL("SendMessageA__III_3S\n")
+
+ if (arg3) lparg3 = (*env)->GetShortArrayElements(env, arg3, NULL);
+ rc = (jint)SendMessageA((HWND)arg0, arg1, arg2, (LPARAM)lparg3);
+ if (arg3) (*env)->ReleaseShortArrayElements(env, arg3, lparg3, 0);
+ return rc;
+}
+#endif /* NO_SendMessageA__III_3S */
+
+#ifndef NO_SendMessageA__IIILorg_eclipse_swt_internal_win32_LVCOLUMN_2
+JNIEXPORT jint JNICALL OS_NATIVE(SendMessageA__IIILorg_eclipse_swt_internal_win32_LVCOLUMN_2)
+ (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jobject arg3)
+{
+ LVCOLUMN _arg3, *lparg3=NULL;
+ jint rc;
+
+ DEBUG_CALL("SendMessageA__IIILorg_eclipse_swt_internal_win32_LVCOLUMN_2\n")
+
+ if (arg3) lparg3 = getLVCOLUMNFields(env, arg3, &_arg3);
+ rc = (jint)SendMessageA((HWND)arg0, arg1, arg2, (LPARAM)lparg3);
+ if (arg3) setLVCOLUMNFields(env, arg3, lparg3);
+ return rc;
+}
+#endif /* NO_SendMessageA__IIILorg_eclipse_swt_internal_win32_LVCOLUMN_2 */
+
+#ifndef NO_SendMessageW__II_3I_3I
+JNIEXPORT jint JNICALL OS_NATIVE(SendMessageW__II_3I_3I)
+ (JNIEnv *env, jclass that, jint arg0, jint arg1, jintArray arg2, jintArray arg3)
+{
+ jint *lparg2=NULL;
+ jint *lparg3=NULL;
+ jint rc;
+
+ DEBUG_CALL("SendMessageW\n")
+
+ if (arg2) lparg2 = (*env)->GetIntArrayElements(env, arg2, NULL);
+ if (arg3) lparg3 = (*env)->GetIntArrayElements(env, arg3, NULL);
+
+#ifdef _WIN32_WCE
+ /* SPECIAL */
+ /*
+ * Bug on WinCE. SendMessage can fail (return 0) when being passed references
+ * to parameters allocated from the heap. The workaround is to allocate
+ * the parameters on the stack and to copy them back to the java array.
+ * Observed on Pocket PC WinCE 3.0 with EM_GETSEL and CB_GETEDITSEL messages.
+ */
+ switch (arg1) {
+ case EM_GETSEL:
+ case CB_GETEDITSEL: {
+ jint wParam = 0, lParam = 0;
+ jint *lpwParam = NULL, *lplParam = NULL;
+ if (lparg2 != NULL) lpwParam = &wParam;
+ if (lparg3 != NULL) lplParam = &lParam;
+ rc = (jint)SendMessageW((HWND)arg0, arg1, (WPARAM)lpwParam, (LPARAM)lplParam);
+ if (lparg2 != NULL) lparg2[0] = wParam;
+ if (lparg3 != NULL) lparg3[0] = lParam;
+ break;
+ }
+ default:
+ rc = (jint)SendMessageW((HWND)arg0, arg1, (WPARAM)lparg2, (LPARAM)lparg3);
+ }
+#else
+ rc = (jint)SendMessageW((HWND)arg0, arg1, (WPARAM)lparg2, (LPARAM)lparg3);
+#endif /* _WIN32_WCE */
+
+ if (arg2) (*env)->ReleaseIntArrayElements(env, arg2, lparg2, 0);
+ if (arg3) (*env)->ReleaseIntArrayElements(env, arg3, lparg3, 0);
+
+ return rc;
+}
+#endif /* NO_SendMessageW__II_3I_3I */
+
+#ifndef NO_SendMessageW__II_3II
+JNIEXPORT jint JNICALL OS_NATIVE(SendMessageW__II_3II)
+ (JNIEnv *env, jclass that, jint arg0, jint arg1, jintArray arg2, jint arg3)
+{
+ jint *lparg2=NULL;
+ jint rc;
+
+ DEBUG_CALL("SendMessageW__II_3II\n")
+
+ if (arg2) lparg2 = (*env)->GetIntArrayElements(env, arg2, NULL);
+ rc = (jint)SendMessageW((HWND)arg0, arg1, (WPARAM)lparg2, (LPARAM)arg3);
+ if (arg2) (*env)->ReleaseIntArrayElements(env, arg2, lparg2, 0);
+ return rc;
+}
+#endif /* NO_SendMessageW__II_3II */
+
+#ifndef NO_SendMessageW__III_3C
+JNIEXPORT jint JNICALL OS_NATIVE(SendMessageW__III_3C)
+ (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jcharArray arg3)
+{
+ jchar *lparg3=NULL;
+ jint rc;
+
+ DEBUG_CALL("SendMessageW__III_3C\n")
+
+ if (arg3) lparg3 = (*env)->GetCharArrayElements(env, arg3, NULL);
+ rc = (jint)SendMessageW((HWND)arg0, arg1, arg2, (LPARAM)lparg3);
+ if (arg3) (*env)->ReleaseCharArrayElements(env, arg3, lparg3, 0);
+ return rc;
+}
+#endif /* NO_SendMessageW__III_3C */
+
+#ifndef NO_SendMessageW__III_3I
+JNIEXPORT jint JNICALL OS_NATIVE(SendMessageW__III_3I)
+ (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jintArray arg3)
+{
+ jint *lparg3=NULL;
+ jint rc;
+
+ DEBUG_CALL("SendMessageW__III_3I\n")
+
+ if (arg3) lparg3 = (*env)->GetIntArrayElements(env, arg3, NULL);
+ rc = (jint)SendMessageW((HWND)arg0, arg1, arg2, (LPARAM)lparg3);
+ if (arg3) (*env)->ReleaseIntArrayElements(env, arg3, lparg3, 0);
+ return rc;
+}
+#endif /* NO_SendMessageW__III_3I */
+
+#ifndef NO_SendMessageW__III_3S
+JNIEXPORT jint JNICALL OS_NATIVE(SendMessageW__III_3S)
+ (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jshortArray arg3)
+{
+ jshort *lparg3=NULL;
+ jint rc;
+
+ DEBUG_CALL("SendMessageW__III_3S\n")
+
+ if (arg3) lparg3 = (*env)->GetShortArrayElements(env, arg3, NULL);
+ rc = (jint)SendMessageW((HWND)arg0, arg1, arg2, (LPARAM)lparg3);
+ if (arg3) (*env)->ReleaseShortArrayElements(env, arg3, lparg3, 0);
+ return rc;
+}
+#endif /* NO_SendMessageW__III_3S */
+
+#ifndef NO_SendMessageW__IIII
+JNIEXPORT jint JNICALL OS_NATIVE(SendMessageW__IIII)
+ (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jint arg3)
+{
+ DEBUG_CALL("SendMessageW__IIII\n")
+
+ return (jint)SendMessageW((HWND)arg0, arg1, arg2, (LPARAM)arg3);
+}
+#endif /* NO_SendMessageW__IIII */
+
+#ifndef NO_SendMessageW__IIILorg_eclipse_swt_internal_win32_LVHITTESTINFO_2
+JNIEXPORT jint JNICALL OS_NATIVE(SendMessageW__IIILorg_eclipse_swt_internal_win32_LVHITTESTINFO_2)
+ (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jobject arg3)
+{
+ LVHITTESTINFO _arg3, *lparg3=NULL;
+ jint rc;
+
+ DEBUG_CALL("SendMessageW__IIILorg_eclipse_swt_internal_win32_LVHITTESTINFO_2\n")
+
+ if (arg3) lparg3 = getLVHITTESTINFOFields(env, arg3, &_arg3);
+ rc = (jint)SendMessageW((HWND)arg0, arg1, arg2, (LPARAM)lparg3);
+ if (arg3) setLVHITTESTINFOFields(env, arg3, lparg3);
+ return rc;
+}
+#endif /* NO_SendMessageW__IIILorg_eclipse_swt_internal_win32_LVHITTESTINFO_2 */
+
+#ifndef NO_SendMessageW__IIILorg_eclipse_swt_internal_win32_LVITEM_2
+JNIEXPORT jint JNICALL OS_NATIVE(SendMessageW__IIILorg_eclipse_swt_internal_win32_LVITEM_2)
+ (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jobject arg3)
+{
+ LVITEM _arg3, *lparg3=NULL;
+ jint rc;
+
+ DEBUG_CALL("SendMessageW__IIILorg_eclipse_swt_internal_win32_LVITEM_2\n")
+
+ if (arg3) lparg3 = getLVITEMFields(env, arg3, &_arg3);
+ rc = (jint)SendMessageW((HWND)arg0, arg1, arg2, (LPARAM)lparg3);
+ if (arg3) setLVITEMFields(env, arg3, lparg3);
+ return rc;
+}
+#endif /* NO_SendMessageW__IIILorg_eclipse_swt_internal_win32_LVITEM_2 */
+
+#ifndef NO_SendMessageW__IIILorg_eclipse_swt_internal_win32_REBARBANDINFO_2
+JNIEXPORT jint JNICALL OS_NATIVE(SendMessageW__IIILorg_eclipse_swt_internal_win32_REBARBANDINFO_2)
+ (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jobject arg3)
+{
+ REBARBANDINFO _arg3, *lparg3=NULL;
+ jint rc;
+
+ DEBUG_CALL("SendMessageW__IIILorg_eclipse_swt_internal_win32_REBARBANDINFO_2\n")
+
+ if (arg3) lparg3 = getREBARBANDINFOFields(env, arg3, &_arg3);
+ rc = (jint)SendMessageW((HWND)arg0, arg1, arg2, (LPARAM)lparg3);
+ if (arg3) setREBARBANDINFOFields(env, arg3, lparg3);
+ return rc;
+}
+#endif /* NO_SendMessageW__IIILorg_eclipse_swt_internal_win32_REBARBANDINFO_2 */
+
+#ifndef NO_SendMessageW__IIILorg_eclipse_swt_internal_win32_RECT_2
+JNIEXPORT jint JNICALL OS_NATIVE(SendMessageW__IIILorg_eclipse_swt_internal_win32_RECT_2)
+ (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jobject arg3)
+{
+ RECT _arg3, *lparg3=NULL;
+ jint rc;
+
+ DEBUG_CALL("SendMessageW__IIILorg_eclipse_swt_internal_win32_RECT_2\n")
+
+ if (arg3) lparg3 = getRECTFields(env, arg3, &_arg3);
+ rc = (jint)SendMessageW((HWND)arg0, arg1, arg2, (LPARAM)lparg3);
+ if (arg3) setRECTFields(env, arg3, lparg3);
+ return rc;
+}
+#endif /* NO_SendMessageW__IIILorg_eclipse_swt_internal_win32_RECT_2 */
+
+#ifndef NO_SendMessageW__IIILorg_eclipse_swt_internal_win32_TBBUTTON_2
+JNIEXPORT jint JNICALL OS_NATIVE(SendMessageW__IIILorg_eclipse_swt_internal_win32_TBBUTTON_2)
+ (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jobject arg3)
+{
+ TBBUTTON _arg3, *lparg3=NULL;
+ jint rc;
+
+ DEBUG_CALL("SendMessageW__IIILorg_eclipse_swt_internal_win32_TBBUTTON_2\n")
+
+ if (arg3) lparg3 = getTBBUTTONFields(env, arg3, &_arg3);
+ rc = (jint)SendMessageW((HWND)arg0, arg1, arg2, (LPARAM)lparg3);
+ if (arg3) setTBBUTTONFields(env, arg3, lparg3);
+ return rc;
+}
+#endif /* NO_SendMessageW__IIILorg_eclipse_swt_internal_win32_TBBUTTON_2 */
+
+#ifndef NO_SendMessageW__IIILorg_eclipse_swt_internal_win32_TBBUTTONINFO_2
+JNIEXPORT jint JNICALL OS_NATIVE(SendMessageW__IIILorg_eclipse_swt_internal_win32_TBBUTTONINFO_2)
+ (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jobject arg3)
+{
+ TBBUTTONINFO _arg3, *lparg3=NULL;
+ jint rc;
+
+ DEBUG_CALL("SendMessageW__IIILorg_eclipse_swt_internal_win32_TBBUTTONINFO_2\n")
+
+ if (arg3) lparg3 = getTBBUTTONINFOFields(env, arg3, &_arg3);
+ rc = (jint)SendMessageW((HWND)arg0, arg1, arg2, (LPARAM)lparg3);
+ if (arg3) setTBBUTTONINFOFields(env, arg3, lparg3);
+ return rc;
+}
+#endif /* NO_SendMessageW__IIILorg_eclipse_swt_internal_win32_TBBUTTONINFO_2 */
+
+#ifndef NO_SendMessageW__IIILorg_eclipse_swt_internal_win32_TCITEM_2
+JNIEXPORT jint JNICALL OS_NATIVE(SendMessageW__IIILorg_eclipse_swt_internal_win32_TCITEM_2)
+ (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jobject arg3)
+{
+ TCITEM _arg3, *lparg3=NULL;
+ jint rc;
+
+ DEBUG_CALL("SendMessageW__IIILorg_eclipse_swt_internal_win32_TCITEM_2\n")
+
+ if (arg3) lparg3 = getTCITEMFields(env, arg3, &_arg3);
+ rc = (jint)SendMessageW((HWND)arg0, arg1, arg2, (LPARAM)lparg3);
+ if (arg3) setTCITEMFields(env, arg3, lparg3);
+ return rc;
+}
+#endif /* NO_SendMessageW__IIILorg_eclipse_swt_internal_win32_TCITEM_2 */
+
+#ifndef NO_SendMessageW__IIILorg_eclipse_swt_internal_win32_TOOLINFO_2
+JNIEXPORT jint JNICALL OS_NATIVE(SendMessageW__IIILorg_eclipse_swt_internal_win32_TOOLINFO_2)
+ (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jobject arg3)
+{
+ TOOLINFO _arg3, *lparg3=NULL;
+ jint rc;
+
+ DEBUG_CALL("SendMessageW__IIILorg_eclipse_swt_internal_win32_TOOLINFO_2\n")
+
+ if (arg3) lparg3 = getTOOLINFOFields(env, arg3, &_arg3);
+ rc = (jint)SendMessageW((HWND)arg0, arg1, arg2, (LPARAM)lparg3);
+ if (arg3) setTOOLINFOFields(env, arg3, lparg3);
+ return rc;
+}
+#endif /* NO_SendMessageW__IIILorg_eclipse_swt_internal_win32_TOOLINFO_2 */
+
+#ifndef NO_SendMessageW__IIILorg_eclipse_swt_internal_win32_TVHITTESTINFO_2
+JNIEXPORT jint JNICALL OS_NATIVE(SendMessageW__IIILorg_eclipse_swt_internal_win32_TVHITTESTINFO_2)
+ (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jobject arg3)
+{
+ TVHITTESTINFO _arg3, *lparg3=NULL;
+ jint rc;
+
+ DEBUG_CALL("SendMessageW__IIILorg_eclipse_swt_internal_win32_TVHITTESTINFO_2\n")
+
+ if (arg3) lparg3 = getTVHITTESTINFOFields(env, arg3, &_arg3);
+ rc = (jint)SendMessageW((HWND)arg0, arg1, arg2, (LPARAM)lparg3);
+ if (arg3) setTVHITTESTINFOFields(env, arg3, lparg3);
+ return rc;
+}
+#endif /* NO_SendMessageW__IIILorg_eclipse_swt_internal_win32_TVHITTESTINFO_2 */
+
+#ifndef NO_SendMessageW__IIILorg_eclipse_swt_internal_win32_TVINSERTSTRUCT_2
+JNIEXPORT jint JNICALL OS_NATIVE(SendMessageW__IIILorg_eclipse_swt_internal_win32_TVINSERTSTRUCT_2)
+ (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jobject arg3)
+{
+ TVINSERTSTRUCT _arg3, *lparg3=NULL;
+ jint rc;
+
+ DEBUG_CALL("SendMessageW__IIILorg_eclipse_swt_internal_win32_TVINSERTSTRUCT_2\n")
+
+ if (arg3) lparg3 = getTVINSERTSTRUCTFields(env, arg3, &_arg3);
+ rc = (jint)SendMessageW((HWND)arg0, arg1, arg2, (LPARAM)lparg3);
+ if (arg3) setTVINSERTSTRUCTFields(env, arg3, lparg3);
+ return rc;
+}
+#endif /* NO_SendMessageW__IIILorg_eclipse_swt_internal_win32_TVINSERTSTRUCT_2 */
+
+#ifndef NO_SendMessageW__IIILorg_eclipse_swt_internal_win32_TVITEM_2
+JNIEXPORT jint JNICALL OS_NATIVE(SendMessageW__IIILorg_eclipse_swt_internal_win32_TVITEM_2)
+ (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jobject arg3)
+{
+ TVITEM _arg3, *lparg3=NULL;
+ jint rc;
+
+ DEBUG_CALL("SendMessageW__IIILorg_eclipse_swt_internal_win32_TVITEM_2\n")
+
+ if (arg3) lparg3 = getTVITEMFields(env, arg3, &_arg3);
+ rc = (jint)SendMessageW((HWND)arg0, arg1, arg2, (LPARAM)lparg3);
+ if (arg3) setTVITEMFields(env, arg3, lparg3);
+ return rc;
+}
+#endif /* NO_SendMessageW__IIILorg_eclipse_swt_internal_win32_TVITEM_2 */
+
+#ifndef NO_SendMessageW__IIILorg_eclipse_swt_internal_win32_LVCOLUMN_2
+JNIEXPORT jint JNICALL OS_NATIVE(SendMessageW__IIILorg_eclipse_swt_internal_win32_LVCOLUMN_2)
+ (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jobject arg3)
+{
+ LVCOLUMN _arg3, *lparg3=NULL;
+ jint rc;
+
+ DEBUG_CALL("SendMessageW__IIILorg_eclipse_swt_internal_win32_LVCOLUMN_2\n")
+
+ if (arg3) lparg3 = getLVCOLUMNFields(env, arg3, &_arg3);
+ rc = (jint)SendMessageW((HWND)arg0, arg1, arg2, (LPARAM)lparg3);
+ if (arg3) setLVCOLUMNFields(env, arg3, lparg3);
+ return rc;
+}
+#endif /* NO_SendMessageW__IIILorg_eclipse_swt_internal_win32_LVCOLUMN_2 */
+
+#ifndef NO_SetActiveWindow
+JNIEXPORT jint JNICALL OS_NATIVE(SetActiveWindow)
+ (JNIEnv *env, jclass that, jint arg0)
+{
+ DEBUG_CALL("SetActiveWindow\n")
+
+ return (jint)SetActiveWindow((HWND)arg0);
+}
+#endif /* NO_SetActiveWindow */
+
+#ifndef NO_SetBkColor
+JNIEXPORT jint JNICALL OS_NATIVE(SetBkColor)
+ (JNIEnv *env, jclass that, jint arg0, jint arg1)
+{
+ DEBUG_CALL("SetBkColor\n")
+
+ return (jint)SetBkColor((HDC)arg0, (COLORREF)arg1);
+}
+#endif /* NO_SetBkColor */
+
+#ifndef NO_SetBkMode
+JNIEXPORT jint JNICALL OS_NATIVE(SetBkMode)
+ (JNIEnv *env, jclass that, jint arg0, jint arg1)
+{
+ DEBUG_CALL("SetBkMode\n")
+
+ return (jint)SetBkMode((HDC)arg0, arg1);
+}
+#endif /* NO_SetBkMode */
+
+#ifndef NO_SetCapture
+JNIEXPORT jint JNICALL OS_NATIVE(SetCapture)
+ (JNIEnv *env, jclass that, jint arg0)
+{
+ DEBUG_CALL("SetCapture\n")
+
+ return (jint)SetCapture((HWND)arg0);
+}
+#endif /* NO_SetCapture */
+
+#ifndef NO_SetCaretPos
+JNIEXPORT jboolean JNICALL OS_NATIVE(SetCaretPos)
+ (JNIEnv *env, jclass that, jint arg0, jint arg1)
+{
+ DEBUG_CALL("SetCaretPos\n")
+
+ return (jboolean)SetCaretPos(arg0, arg1);
+}
+#endif /* NO_SetCaretPos */
+
+#ifndef NO_SetClipboardData
+JNIEXPORT jint JNICALL OS_NATIVE(SetClipboardData)
+ (JNIEnv *env, jclass that, jint arg0, jint arg1)
+{
+ DEBUG_CALL("SetClipboardData\n")
+
+ return (jint)SetClipboardData(arg0, (HANDLE)arg1);
+}
+#endif /* NO_SetClipboardData */
+
+#ifndef NO_SetCursor
+JNIEXPORT jint JNICALL OS_NATIVE(SetCursor)
+ (JNIEnv *env, jclass that, jint arg0)
+{
+ DEBUG_CALL("SetCursor\n")
+
+ return (jint)SetCursor((HCURSOR)arg0);
+}
+#endif /* NO_SetCursor */
+
+#ifndef NO_SetCursorPos
+JNIEXPORT jboolean JNICALL OS_NATIVE(SetCursorPos)
+ (JNIEnv *env, jclass that, jint arg0, jint arg1)
+{
+ DEBUG_CALL("SetCursorPos\n")
+
+ return (jboolean)SetCursorPos(arg0, arg1);
+}
+#endif /* NO_SetCursorPos */
+
+#ifndef NO_SetDIBColorTable
+JNIEXPORT jint JNICALL OS_NATIVE(SetDIBColorTable)
+ (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jbyteArray arg3)
+{
+ jbyte *lparg3=NULL;
+ jint rc;
+
+ DEBUG_CALL("SetDIBColorTable\n")
+
+ if (arg3) lparg3 = (*env)->GetByteArrayElements(env, arg3, NULL);
+ rc = (jint)SetDIBColorTable((HDC)arg0, arg1, arg2, (RGBQUAD *)lparg3);
+ if (arg3) (*env)->ReleaseByteArrayElements(env, arg3, lparg3, 0);
+ return rc;
+}
+#endif /* NO_SetDIBColorTable */
+
+#ifndef NO_SetFocus
+JNIEXPORT jint JNICALL OS_NATIVE(SetFocus)
+ (JNIEnv *env, jclass that, jint arg0)
+{
+ DEBUG_CALL("SetFocus\n")
+
+ return (jint)SetFocus((HWND)arg0);
+}
+#endif /* NO_SetFocus */
+
+#ifndef NO_SetForegroundWindow
+JNIEXPORT jboolean JNICALL OS_NATIVE(SetForegroundWindow)
+ (JNIEnv *env, jclass that, jint arg0)
+{
+ DEBUG_CALL("SetForegroundWindow\n")
+
+ return (jboolean)SetForegroundWindow((HWND)arg0);
+}
+#endif /* NO_SetForegroundWindow */
+
+#ifndef NO_SetLayout
+JNIEXPORT jint JNICALL OS_NATIVE(SetLayout)
+ (JNIEnv *env, jclass that, jint arg0, jint arg1)
+{
+ HMODULE hm;
+ FARPROC fp;
+
+ DEBUG_CALL("SetLayout\n")
+
+ /* SPECIAL */
+ /*
+ * SetLayout 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("gdi32.dll")) && (fp=GetProcAddress(hm, "SetLayout"))) {
+ return (jint) (fp)((HDC)arg0, (DWORD)arg1);
+// return (jint)SetLayout((HDC)arg0, (DWORD)arg1);
+ }
+ return 0;
+}
+#endif /* NO_SetLayout */
+
+#ifndef NO_SetMenu
+JNIEXPORT jboolean JNICALL OS_NATIVE(SetMenu)
+ (JNIEnv *env, jclass that, jint arg0, jint arg1)
+{
+ DEBUG_CALL("SetMenu\n")
+
+ return (jboolean)SetMenu((HWND)arg0, (HMENU)arg1);
+}
+#endif /* NO_SetMenu */
+
+#ifndef NO_SetMenuDefaultItem
+JNIEXPORT jboolean JNICALL OS_NATIVE(SetMenuDefaultItem)
+ (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2)
+{
+ DEBUG_CALL("SetMenuDefaultItem\n")
+
+ return (jboolean)SetMenuDefaultItem((HMENU)arg0, arg1, arg2);
+}
+#endif /* NO_SetMenuDefaultItem */
+
+#ifndef NO_SetMenuInfo
+JNIEXPORT jboolean JNICALL OS_NATIVE(SetMenuInfo)
+ (JNIEnv *env, jclass that, jint arg0, jobject arg1)
+{
+ MENUINFO _arg1, *lparg1=NULL;
+ jboolean rc = (jboolean)FALSE;
+ HMODULE hm;
+ FARPROC fp;
+
+ DEBUG_CALL("SetMenuInfo\n")
+
+ /* SPECIAL */
+ /*
+ * 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 (arg1) lparg1 = getMENUINFOFields(env, arg1, &_arg1);
+
+ rc = (jboolean) (fp)((HMENU)arg0, lparg1);
+// rc = (jboolean)SetMenuInfo(arg0, lparg1);
+
+ if (arg1) setMENUINFOFields(env, arg1, lparg1);
+ }
+
+ return rc;
+}
+#endif /* NO_SetMenuInfo */
+
+#ifndef NO_SetMenuItemInfoA
+JNIEXPORT jboolean JNICALL OS_NATIVE(SetMenuItemInfoA)
+ (JNIEnv *env, jclass that, jint arg0, jint arg1, jboolean arg2, jobject arg3)
+{
+ MENUITEMINFO _arg3, *lparg3=NULL;
+ jboolean rc;
+
+ DEBUG_CALL("SetMenuItemInfoA\n")
+
+ if (arg3) lparg3 = getMENUITEMINFOFields(env, arg3, &_arg3);
+ rc = (jboolean)SetMenuItemInfoA((HMENU)arg0, arg1, arg2, lparg3);
+ if (arg3) setMENUITEMINFOFields(env, arg3, lparg3);
+ return rc;
+}
+#endif /* NO_SetMenuItemInfoA */
+
+#ifndef NO_SetMenuItemInfoW
+JNIEXPORT jboolean JNICALL OS_NATIVE(SetMenuItemInfoW)
+ (JNIEnv *env, jclass that, jint arg0, jint arg1, jboolean arg2, jobject arg3)
+{
+ MENUITEMINFO _arg3, *lparg3=NULL;
+ jboolean rc;
+
+ DEBUG_CALL("SetMenuItemInfoW\n")
+
+ if (arg3) lparg3 = getMENUITEMINFOFields(env, arg3, &_arg3);
+ rc = (jboolean)SetMenuItemInfoW((HMENU)arg0, arg1, arg2, (LPMENUITEMINFOW)lparg3);
+ if (arg3) setMENUITEMINFOFields(env, arg3, lparg3);
+ return rc;
+}
+#endif /* NO_SetMenuItemInfoW */
+
+#ifndef NO_SetPaletteEntries
+JNIEXPORT jint JNICALL OS_NATIVE(SetPaletteEntries)
+ (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jbyteArray arg3)
+{
+ jbyte *lparg3=NULL;
+ jint rc;
+
+ DEBUG_CALL("SetPaletteEntries\n")
+
+ if (arg3) lparg3 = (*env)->GetByteArrayElements(env, arg3, NULL);
+ rc = (jint)SetPaletteEntries((HPALETTE)arg0, arg1, arg2, (PALETTEENTRY *)lparg3);
+ if (arg3) (*env)->ReleaseByteArrayElements(env, arg3, lparg3, 0);
+ return rc;
+}
+#endif /* NO_SetPaletteEntries */
+
+#ifndef NO_SetParent
+JNIEXPORT jint JNICALL OS_NATIVE(SetParent)
+ (JNIEnv *env, jclass that, jint arg0, jint arg1)
+{
+ DEBUG_CALL("SetParent\n")
+
+ return (jint)SetParent((HWND)arg0, (HWND)arg1);
+}
+#endif /* NO_SetParent */
+
+#ifndef NO_SetPixel
+JNIEXPORT jint JNICALL OS_NATIVE(SetPixel)
+ (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jint arg3)
+{
+ DEBUG_CALL("SetPixel\n")
+
+ return (jint)SetPixel((HDC)arg0, arg1, arg2, arg3);
+}
+#endif /* NO_SetPixel */
+
+#ifndef NO_SetROP2
+JNIEXPORT jint JNICALL OS_NATIVE(SetROP2)
+ (JNIEnv *env, jclass that, jint arg0, jint arg1)
+{
+ DEBUG_CALL("SetROP2\n")
+
+ return (jint)SetROP2((HDC)arg0, arg1);
+}
+#endif /* NO_SetROP2 */
+
+#ifndef NO_SetRect
+JNIEXPORT jboolean JNICALL OS_NATIVE(SetRect)
+ (JNIEnv *env, jclass that, jobject arg0, jint arg1, jint arg2, jint arg3, jint arg4)
+{
+ RECT _arg0, *lparg0=NULL;
+ jboolean rc;
+
+ DEBUG_CALL("SetRect\n")
+
+ if (arg0) lparg0 = getRECTFields(env, arg0, &_arg0);
+ rc = (jboolean)SetRect(lparg0, arg1, arg2, arg3, arg4);
+ if (arg0) setRECTFields(env, arg0, lparg0);
+ return rc;
+}
+#endif /* NO_SetRect */
+
+#ifndef NO_SetRectRgn
+JNIEXPORT jboolean JNICALL OS_NATIVE(SetRectRgn)
+ (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jint arg3, jint arg4)
+{
+ DEBUG_CALL("SetRectRgn\n")
+
+ return (jboolean)SetRectRgn((HRGN)arg0, arg1, arg2, arg3, arg4);
+}
+#endif /* NO_SetRectRgn */
+
+#ifndef NO_SetScrollInfo
+JNIEXPORT jboolean JNICALL OS_NATIVE(SetScrollInfo)
+ (JNIEnv *env, jclass that, jint arg0, jint arg1, jobject arg2, jboolean arg3)
+{
+ SCROLLINFO _arg2, *lparg2=NULL;
+ jboolean rc;
+
+ DEBUG_CALL("SetScrollInfo\n")
+
+ if (arg2) lparg2 = getSCROLLINFOFields(env, arg2, &_arg2);
+ rc = (jboolean)SetScrollInfo((HWND)arg0, arg1, lparg2, arg3);
+ if (arg2) setSCROLLINFOFields(env, arg2, lparg2);
+ return rc;
+}
+#endif /* NO_SetScrollInfo */
+
+#ifndef NO_SetStretchBltMode
+JNIEXPORT jint JNICALL OS_NATIVE(SetStretchBltMode)
+ (JNIEnv *env, jclass that, jint arg0, jint arg1)
+{
+ DEBUG_CALL("SetStretchBltMode\n")
+
+ return (jint)SetStretchBltMode((HDC)arg0, arg1);
+}
+#endif /* NO_SetStretchBltMode */
+
+#ifndef NO_SetTextAlign
+JNIEXPORT jint JNICALL OS_NATIVE(SetTextAlign)
+ (JNIEnv *env, jclass that, jint arg0, jint arg1)
+{
+ DEBUG_CALL("SetTextAlign\n")
+
+ return (jint)SetTextAlign((HDC)arg0, arg1);
+}
+#endif /* NO_SetTextAlign */
+
+#ifndef NO_SetTextColor
+JNIEXPORT jint JNICALL OS_NATIVE(SetTextColor)
+ (JNIEnv *env, jclass that, jint arg0, jint arg1)
+{
+ DEBUG_CALL("SetTextColor\n")
+
+ return (jint)SetTextColor((HDC)arg0, (COLORREF)arg1);
+}
+#endif /* NO_SetTextColor */
+
+#ifndef NO_SetTimer
+JNIEXPORT jint JNICALL OS_NATIVE(SetTimer)
+ (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jint arg3)
+{
+ DEBUG_CALL("SetTimer\n")
+
+ return (jint)SetTimer((HWND)arg0, arg1, arg2, (TIMERPROC)arg3);
+}
+#endif /* NO_SetTimer */
+
+#ifndef NO_SetWindowLongA
+JNIEXPORT jint JNICALL OS_NATIVE(SetWindowLongA)
+ (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2)
+{
+ DEBUG_CALL("SetWindowLongA\n")
+
+ return (jint)SetWindowLongA((HWND)arg0, arg1, arg2);
+}
+#endif /* NO_SetWindowLongA */
+
+#ifndef NO_SetWindowLongW
+JNIEXPORT jint JNICALL OS_NATIVE(SetWindowLongW)
+ (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2)
+{
+ DEBUG_CALL("SetWindowLongW\n")
+
+ return (jint)SetWindowLongW((HWND)arg0, arg1, arg2);
+}
+#endif /* NO_SetWindowLongW */
+
+#ifndef NO_SetWindowPlacement
+JNIEXPORT jboolean JNICALL OS_NATIVE(SetWindowPlacement)
+ (JNIEnv *env, jclass that, jint arg0, jobject arg1)
+{
+ WINDOWPLACEMENT _arg1, *lparg1=NULL;
+ jboolean rc;
+
+ DEBUG_CALL("SetWindowPlacement\n")
+
+ if (arg1) lparg1 = getWINDOWPLACEMENTFields(env, arg1, &_arg1);
+ rc = (jboolean)SetWindowPlacement((HWND)arg0, lparg1);
+ if (arg1) setWINDOWPLACEMENTFields(env, arg1, lparg1);
+ return rc;
+}
+#endif /* NO_SetWindowPlacement */
+
+#ifndef NO_SetWindowPos
+JNIEXPORT jboolean JNICALL OS_NATIVE(SetWindowPos)
+ (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jint arg3, jint arg4, jint arg5, jint arg6)
+{
+ DEBUG_CALL("SetWindowPos\n")
+
+ return (jboolean)SetWindowPos((HWND)arg0, (HWND)arg1, arg2, arg3, arg4, arg5, arg6);
+}
+#endif /* NO_SetWindowPos */
+
+#ifndef NO_SetWindowTextA
+JNIEXPORT jboolean JNICALL OS_NATIVE(SetWindowTextA)
+ (JNIEnv *env, jclass that, jint arg0, jbyteArray arg1)
+{
+ jbyte *lparg1=NULL;
+ jboolean rc;
+
+ DEBUG_CALL("SetWindowTextA\n")
+
+ if (arg1) lparg1 = (*env)->GetByteArrayElements(env, arg1, NULL);
+ rc = (jboolean)SetWindowTextA((HWND)arg0, (LPSTR)lparg1);
+ if (arg1) (*env)->ReleaseByteArrayElements(env, arg1, lparg1, 0);
+ return rc;
+}
+#endif /* NO_SetWindowTextA */
+
+#ifndef NO_SetWindowTextW
+JNIEXPORT jboolean JNICALL OS_NATIVE(SetWindowTextW)
+ (JNIEnv *env, jclass that, jint arg0, jcharArray arg1)
+{
+ jchar *lparg1=NULL;
+ jboolean rc;
+
+ DEBUG_CALL("SetWindowTextW\n")
+
+ if (arg1) lparg1 = (*env)->GetCharArrayElements(env, arg1, NULL);
+ rc = (jboolean)SetWindowTextW((HWND)arg0, (LPWSTR)lparg1);
+ if (arg1) (*env)->ReleaseCharArrayElements(env, arg1, lparg1, 0);
+ return rc;
+}
+#endif /* NO_SetWindowTextW */
+
+#ifndef NO_SetWindowsHookExA
+JNIEXPORT jint JNICALL OS_NATIVE(SetWindowsHookExA)
+ (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jint arg3)
+{
+ DEBUG_CALL("SetWindowsHookExA\n")
+
+ return (jint)SetWindowsHookExA(arg0, (HOOKPROC)arg1, (HINSTANCE)arg2, arg3);
+}
+#endif /* NO_SetWindowsHookExA */
+
+#ifndef NO_SetWindowsHookExW
+JNIEXPORT jint JNICALL OS_NATIVE(SetWindowsHookExW)
+ (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jint arg3)
+{
+ DEBUG_CALL("SetWindowsHookExW\n")
+
+ return (jint)SetWindowsHookExW(arg0, (HOOKPROC)arg1, (HINSTANCE)arg2, arg3);
+}
+#endif /* NO_SetWindowsHookExW */
+
+#ifndef NO_ShellExecuteExA
+JNIEXPORT jboolean JNICALL OS_NATIVE(ShellExecuteExA)
+ (JNIEnv *env, jclass that, jobject arg0)
+{
+ SHELLEXECUTEINFO _arg0, *lparg0=NULL;
+ jboolean rc;
+
+ DEBUG_CALL("ShellExecuteExA\n")
+
+ if (arg0) lparg0 = getSHELLEXECUTEINFOFields(env, arg0, &_arg0);
+ rc = (jboolean)ShellExecuteExA(lparg0);
+ if (arg0) setSHELLEXECUTEINFOFields(env, arg0, lparg0);
+ return rc;
+}
+#endif /* NO_ShellExecuteExA */
+
+#ifndef NO_ShellExecuteExW
+JNIEXPORT jboolean JNICALL OS_NATIVE(ShellExecuteExW)
+ (JNIEnv *env, jclass that, jobject arg0)
+{
+ SHELLEXECUTEINFO _arg0, *lparg0=NULL;
+ jboolean rc;
+
+ DEBUG_CALL("ShellExecuteExW\n")
+
+ if (arg0) lparg0 = getSHELLEXECUTEINFOFields(env, arg0, &_arg0);
+ rc = (jboolean)ShellExecuteExW((LPSHELLEXECUTEINFOW)lparg0);
+ if (arg0) setSHELLEXECUTEINFOFields(env, arg0, lparg0);
+ return rc;
+}
+#endif /* NO_ShellExecuteExW */
+
+#ifndef NO_ShowCaret
+JNIEXPORT jboolean JNICALL OS_NATIVE(ShowCaret)
+ (JNIEnv *env, jclass that, jint arg0)
+{
+ DEBUG_CALL("ShowCaret\n")
+
+ return (jboolean)ShowCaret((HWND)arg0);
+}
+#endif /* NO_ShowCaret */
+
+#ifndef NO_ShowOwnedPopups
+JNIEXPORT jboolean JNICALL OS_NATIVE(ShowOwnedPopups)
+ (JNIEnv *env, jclass that, jint arg0, jboolean arg1)
+{
+ DEBUG_CALL("ShowOwnedPopups\n")
+
+ return (jboolean)ShowOwnedPopups((HWND)arg0, arg1);
+}
+#endif /* NO_ShowOwnedPopups */
+
+#ifndef NO_ShowScrollBar
+JNIEXPORT jboolean JNICALL OS_NATIVE(ShowScrollBar)
+ (JNIEnv *env, jclass that, jint arg0, jint arg1, jboolean arg2)
+{
+ DEBUG_CALL("ShowScrollBar\n")
+
+ return (jboolean)ShowScrollBar((HWND)arg0, arg1, arg2);
+}
+#endif /* NO_ShowScrollBar */
+
+#ifndef NO_ShowWindow
+JNIEXPORT jboolean JNICALL OS_NATIVE(ShowWindow)
+ (JNIEnv *env, jclass that, jint arg0, jint arg1)
+{
+ DEBUG_CALL("ShowWindow\n")
+
+ return (jboolean)ShowWindow((HWND)arg0, arg1);
+}
+#endif /* NO_ShowWindow */
+
+#ifndef NO_SipGetInfo
+JNIEXPORT jboolean JNICALL OS_NATIVE(SipGetInfo)
+ (JNIEnv *env, jclass that, jobject arg0)
+{
+ SIPINFO _arg0, *lparg0=NULL;
+ jboolean rc;
+
+ DEBUG_CALL("SipGetInfo\n")
+
+ if (arg0) lparg0 = getSIPINFOFields(env, arg0, &_arg0);
+ rc = (jboolean)SipGetInfo(lparg0);
+ if (arg0) setSIPINFOFields(env, arg0, lparg0);
+ return rc;
+}
+#endif /* NO_SipGetInfo */
+
+#ifndef NO_StartDocA
+JNIEXPORT jint JNICALL OS_NATIVE(StartDocA)
+ (JNIEnv *env, jclass that, jint arg0, jobject arg1)
+{
+ DOCINFO _arg1, *lparg1=NULL;
+ jint rc;
+
+ DEBUG_CALL("StartDocA\n")
+
+ if (arg1) lparg1 = getDOCINFOFields(env, arg1, &_arg1);
+ rc = (jint)StartDocA((HDC)arg0, lparg1);
+ if (arg1) setDOCINFOFields(env, arg1, lparg1);
+ return rc;
+}
+#endif /* NO_StartDocA */
+
+#ifndef NO_StartDocW
+JNIEXPORT jint JNICALL OS_NATIVE(StartDocW)
+ (JNIEnv *env, jclass that, jint arg0, jobject arg1)
+{
+ DOCINFO _arg1, *lparg1=NULL;
+ jint rc;
+
+ DEBUG_CALL("StartDocW\n")
+
+ if (arg1) lparg1 = getDOCINFOFields(env, arg1, &_arg1);
+ rc = (jint)StartDocW((HDC)arg0, (LPDOCINFOW)lparg1);
+ if (arg1) setDOCINFOFields(env, arg1, lparg1);
+ return rc;
+}
+#endif /* NO_StartDocW */
+
+#ifndef NO_StartPage
+JNIEXPORT jint JNICALL OS_NATIVE(StartPage)
+ (JNIEnv *env, jclass that, jint arg0)
+{
+ DEBUG_CALL("StartPage\n")
+
+ return (jint)StartPage((HDC)arg0);
+}
+#endif /* NO_StartPage */
+
+#ifndef NO_StretchBlt
+JNIEXPORT jboolean JNICALL OS_NATIVE(StretchBlt)
+ (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jint arg3, jint arg4, jint arg5, jint arg6, jint arg7, jint arg8, jint arg9, jint arg10)
+{
+ DEBUG_CALL("StretchBlt\n")
+
+ return (jboolean)StretchBlt((HDC)arg0, arg1, arg2, arg3, arg4, (HDC)arg5, arg6, arg7, arg8, arg9, arg10);
+}
+#endif /* NO_StretchBlt */
+
+#ifndef NO_SystemParametersInfoA__II_3II
+JNIEXPORT jboolean JNICALL OS_NATIVE(SystemParametersInfoA__II_3II)
+ (JNIEnv *env, jclass that, jint arg0, jint arg1, jintArray arg2, jint arg3)
+{
+ jint *lparg2=NULL;
+ jboolean rc;
+
+ DEBUG_CALL("SystemParametersInfoA__II_3II\n")
+
+ if (arg2) lparg2 = (*env)->GetIntArrayElements(env, arg2, NULL);
+ rc = (jboolean)SystemParametersInfoA(arg0, arg1, lparg2, arg3);
+ if (arg2) (*env)->ReleaseIntArrayElements(env, arg2, lparg2, 0);
+ return rc;
+}
+#endif /* NO_SystemParametersInfoA__II_3II */
+
+#ifndef NO_SystemParametersInfoA__IILorg_eclipse_swt_internal_win32_RECT_2I
+JNIEXPORT jboolean JNICALL OS_NATIVE(SystemParametersInfoA__IILorg_eclipse_swt_internal_win32_RECT_2I)
+ (JNIEnv *env, jclass that, jint arg0, jint arg1, jobject arg2, jint arg3)
+{
+ RECT _arg2, *lparg2=NULL;
+ jboolean rc;
+
+ DEBUG_CALL("SystemParametersInfoA__IILorg_eclipse_swt_internal_win32_RECT_2I\n")
+
+ if (arg2) lparg2 = getRECTFields(env, arg2, &_arg2);
+ rc = (jboolean)SystemParametersInfoA(arg0, arg1, lparg2, arg3);
+ if (arg2) setRECTFields(env, arg2, lparg2);
+ return rc;
+}
+#endif /* NO_SystemParametersInfoA__IILorg_eclipse_swt_internal_win32_RECT_2I */
+
+#ifndef NO_SystemParametersInfoA__IILorg_eclipse_swt_internal_win32_NONCLIENTMETRICS_2I
+JNIEXPORT jboolean JNICALL OS_NATIVE(SystemParametersInfoA__IILorg_eclipse_swt_internal_win32_NONCLIENTMETRICS_2I)
+ (JNIEnv *env, jclass that, jint arg0, jint arg1, jobject arg2, jint arg3)
+{
+ NONCLIENTMETRICSA _arg2, *lparg2=NULL;
+ jboolean rc;
+
+ DEBUG_CALL("SystemParametersInfoA__IILorg_eclipse_swt_internal_win32_NONCLIENTMETRICS_2I\n")
+
+ if (arg2) lparg2 = getNONCLIENTMETRICSAFields(env, arg2, &_arg2);
+ rc = (jboolean)SystemParametersInfoA(arg0, arg1, lparg2, arg3);
+ if (arg2) setNONCLIENTMETRICSAFields(env, arg2, lparg2);
+ return rc;
+}
+#endif /* NO_SystemParametersInfoA__IILorg_eclipse_swt_internal_win32_NONCLIENTMETRICS_2I */
+
+#ifndef NO_SystemParametersInfoW__IILorg_eclipse_swt_internal_win32_NONCLIENTMETRICS_2I
+JNIEXPORT jboolean JNICALL OS_NATIVE(SystemParametersInfoW__IILorg_eclipse_swt_internal_win32_NONCLIENTMETRICS_2I)
+ (JNIEnv *env, jclass that, jint arg0, jint arg1, jobject arg2, jint arg3)
+{
+ NONCLIENTMETRICSW _arg2, *lparg2=NULL;
+ jboolean rc;
+
+ DEBUG_CALL("SystemParametersInfoW__IILorg_eclipse_swt_internal_win32_NONCLIENTMETRICS_2I\n")
+
+ if (arg2) lparg2 = getNONCLIENTMETRICSWFields(env, arg2, &_arg2);
+ rc = (jboolean)SystemParametersInfoW(arg0, arg1, lparg2, arg3);
+ if (arg2) setNONCLIENTMETRICSWFields(env, arg2, lparg2);
+ return rc;
+}
+#endif /* NO_SystemParametersInfoW__IILorg_eclipse_swt_internal_win32_NONCLIENTMETRICS_2I */
+
+#ifndef NO_SystemParametersInfoW__II_3II
+JNIEXPORT jboolean JNICALL OS_NATIVE(SystemParametersInfoW__II_3II)
+ (JNIEnv *env, jclass that, jint arg0, jint arg1, jintArray arg2, jint arg3)
+{
+ jint *lparg2=NULL;
+ jboolean rc;
+
+ DEBUG_CALL("SystemParametersInfoW__II_3II\n")
+
+ if (arg2) lparg2 = (*env)->GetIntArrayElements(env, arg2, NULL);
+ rc = (jboolean)SystemParametersInfoW(arg0, arg1, lparg2, arg3);
+ if (arg2) (*env)->ReleaseIntArrayElements(env, arg2, lparg2, 0);
+ return rc;
+}
+#endif /* NO_SystemParametersInfoW__II_3II */
+
+#ifndef NO_SystemParametersInfoW__IILorg_eclipse_swt_internal_win32_RECT_2I
+JNIEXPORT jboolean JNICALL OS_NATIVE(SystemParametersInfoW__IILorg_eclipse_swt_internal_win32_RECT_2I)
+ (JNIEnv *env, jclass that, jint arg0, jint arg1, jobject arg2, jint arg3)
+{
+ RECT _arg2, *lparg2=NULL;
+ jboolean rc;
+
+ DEBUG_CALL("SystemParametersInfoW__IILorg_eclipse_swt_internal_win32_RECT_2I\n")
+
+ if (arg2) lparg2 = getRECTFields(env, arg2, &_arg2);
+ rc = (jboolean)SystemParametersInfoW(arg0, arg1, lparg2, arg3);
+ if (arg2) setRECTFields(env, arg2, lparg2);
+ return rc;
+}
+#endif /* NO_SystemParametersInfoW__IILorg_eclipse_swt_internal_win32_RECT_2I */
+
+#ifndef NO_ToAscii
+JNIEXPORT jint JNICALL OS_NATIVE(ToAscii)
+ (JNIEnv *env, jclass that, jint arg0, jint arg1, jbyteArray arg2, jshortArray arg3, jint arg4)
+{
+ jbyte *lparg2=NULL;
+ jshort *lparg3=NULL;
+ jint rc;
+
+ DEBUG_CALL("ToAscii\n")
+
+ if (arg2) lparg2 = (*env)->GetByteArrayElements(env, arg2, NULL);
+ if (arg3) lparg3 = (*env)->GetShortArrayElements(env, arg3, NULL);
+ rc = (jint)ToAscii(arg0, arg1, (PBYTE)lparg2, (LPWORD)lparg3, arg4);
+ if (arg2) (*env)->ReleaseByteArrayElements(env, arg2, lparg2, 0);
+ if (arg3) (*env)->ReleaseShortArrayElements(env, arg3, lparg3, 0);
+ return rc;
+}
+#endif /* NO_ToAscii */
+
+#ifndef NO_ToUnicode
+JNIEXPORT jint JNICALL OS_NATIVE(ToUnicode)
+ (JNIEnv *env, jclass that, jint arg0, jint arg1, jbyteArray arg2, jcharArray arg3, jint arg4, jint arg5)
+{
+ jbyte *lparg2=NULL;
+ jchar *lparg3=NULL;
+ jint rc;
+
+ DEBUG_CALL("ToUnicode\n")
+
+ if (arg2) lparg2 = (*env)->GetByteArrayElements(env, arg2, NULL);
+ if (arg3) lparg3 = (*env)->GetCharArrayElements(env, arg3, NULL);
+ rc = (jint)ToUnicode(arg0, arg1, (PBYTE)lparg2, (LPWSTR)lparg3, arg4, arg5);
+ if (arg2) (*env)->ReleaseByteArrayElements(env, arg2, lparg2, 0);
+ if (arg3) (*env)->ReleaseCharArrayElements(env, arg3, lparg3, 0);
+ return rc;
+}
+#endif /* NO_ToUnicode */
+
+#ifndef NO_TrackMouseEvent
+JNIEXPORT jboolean JNICALL OS_NATIVE(TrackMouseEvent)
+ (JNIEnv *env, jclass that, jobject arg0)
+{
+ TRACKMOUSEEVENT _arg0, *lparg0=NULL;
+ jboolean rc;
+
+ DEBUG_CALL("TrackMouseEvent\n")
+
+ if (arg0) lparg0 = getTRACKMOUSEEVENTFields(env, arg0, &_arg0);
+ rc = (jboolean)_TrackMouseEvent(lparg0);
+ if (arg0) setTRACKMOUSEEVENTFields(env, arg0, lparg0);
+ return rc;
+}
+#endif /* NO_TrackMouseEvent */
+
+#ifndef NO_TrackPopupMenu
+JNIEXPORT jboolean JNICALL OS_NATIVE(TrackPopupMenu)
+ (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jint arg3, jint arg4, jint arg5, jobject arg6)
+{
+ RECT _arg6, *lparg6=NULL;
+ jboolean rc;
+
+ DEBUG_CALL("TrackPopupMenu\n")
+
+ if (arg6) lparg6 = getRECTFields(env, arg6, &_arg6);
+ rc = (jboolean)TrackPopupMenu((HMENU)arg0, arg1, arg2, arg3, arg4, (HWND)arg5, lparg6);
+ if (arg6) setRECTFields(env, arg6, lparg6);
+ return rc;
+}
+#endif /* NO_TrackPopupMenu */
+
+#ifndef NO_TranslateAcceleratorA
+JNIEXPORT jint JNICALL OS_NATIVE(TranslateAcceleratorA)
+ (JNIEnv *env, jclass that, jint arg0, jint arg1, jobject arg2)
+{
+ MSG _arg2, *lparg2=NULL;
+ jint rc;
+
+ DEBUG_CALL("TranslateAcceleratorA\n")
+
+ if (arg2) lparg2 = getMSGFields(env, arg2, &_arg2);
+ rc = (jint)TranslateAcceleratorA((HWND)arg0, (HACCEL)arg1, lparg2);
+ if (arg2) setMSGFields(env, arg2, lparg2);
+ return rc;
+}
+#endif /* NO_TranslateAcceleratorA */
+
+#ifndef NO_TranslateAcceleratorW
+JNIEXPORT jint JNICALL OS_NATIVE(TranslateAcceleratorW)
+ (JNIEnv *env, jclass that, jint arg0, jint arg1, jobject arg2)
+{
+ MSG _arg2, *lparg2=NULL;
+ jint rc;
+
+ DEBUG_CALL("TranslateAcceleratorW\n")
+
+ if (arg2) lparg2 = getMSGFields(env, arg2, &_arg2);
+ rc = (jint)TranslateAcceleratorW((HWND)arg0, (HACCEL)arg1, lparg2);
+ if (arg2) setMSGFields(env, arg2, lparg2);
+ return rc;
+}
+#endif /* NO_TranslateAcceleratorW */
+
+#ifndef NO_TranslateCharsetInfo
+JNIEXPORT jboolean JNICALL OS_NATIVE(TranslateCharsetInfo)
+ (JNIEnv *env, jclass that, jint arg0, jintArray arg1, jint arg2)
+{
+ jint *lparg1=NULL;
+ jboolean rc;
+
+ DEBUG_CALL("TranslateCharsetInfo\n")
+
+ if (arg1) lparg1 = (*env)->GetIntArrayElements(env, arg1, NULL);
+ rc = (jboolean)TranslateCharsetInfo((DWORD *)arg0, (LPCHARSETINFO)lparg1, arg2);
+ if (arg1) (*env)->ReleaseIntArrayElements(env, arg1, lparg1, 0);
+ return rc;
+}
+#endif /* NO_TranslateCharsetInfo */
+
+#ifndef NO_TranslateMessage
+JNIEXPORT jboolean JNICALL OS_NATIVE(TranslateMessage)
+ (JNIEnv *env, jclass that, jobject arg0)
+{
+ MSG _arg0, *lparg0=NULL;
+ jboolean rc;
+
+ DEBUG_CALL("TranslateMessage\n")
+
+ if (arg0) lparg0 = getMSGFields(env, arg0, &_arg0);
+ rc = (jboolean)TranslateMessage(lparg0);
+ if (arg0) setMSGFields(env, arg0, lparg0);
+ return rc;
+}
+#endif /* NO_TranslateMessage */
+
+#ifndef NO_TransparentImage
+JNIEXPORT jboolean JNICALL OS_NATIVE(TransparentImage)
+ (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jint arg3, jint arg4, jint arg5, jint arg6, jint arg7, jint arg8, jint arg9, jint arg10)
+{
+ DEBUG_CALL("TransparentImage\n")
+
+ return (jboolean)TransparentImage((HDC)arg0, arg1, arg2, arg3, arg4, (HANDLE)arg5, arg6, arg7, arg8, arg9, (COLORREF)arg10);
+}
+#endif /* NO_TransparentImage */
+
+#ifndef NO_UnhookWindowsHookEx
+JNIEXPORT jboolean JNICALL OS_NATIVE(UnhookWindowsHookEx)
+ (JNIEnv *env, jclass that, jint arg0)
+{
+ DEBUG_CALL("UnhookWindowsHookEx\n")
+
+ return (jboolean)UnhookWindowsHookEx((HHOOK)arg0);
+}
+#endif /* NO_UnhookWindowsHookEx */
+
+#ifndef NO_UnregisterClassA
+JNIEXPORT jboolean JNICALL OS_NATIVE(UnregisterClassA)
+ (JNIEnv *env, jclass that, jbyteArray arg0, jint arg1)
+{
+ jbyte *lparg0=NULL;
+ jboolean rc;
+
+ DEBUG_CALL("UnregisterClassA\n")
+
+ if (arg0) lparg0 = (*env)->GetByteArrayElements(env, arg0, NULL);
+ rc = (jboolean)UnregisterClassA((LPSTR)lparg0, (HINSTANCE)arg1);
+ if (arg0) (*env)->ReleaseByteArrayElements(env, arg0, lparg0, 0);
+ return rc;
+}
+#endif /* NO_UnregisterClassA */
+
+#ifndef NO_UnregisterClassW
+JNIEXPORT jboolean JNICALL OS_NATIVE(UnregisterClassW)
+ (JNIEnv *env, jclass that, jcharArray arg0, jint arg1)
+{
+ jchar *lparg0=NULL;
+ jboolean rc;
+
+ DEBUG_CALL("UnregisterClassW\n")
+
+ if (arg0) lparg0 = (*env)->GetCharArrayElements(env, arg0, NULL);
+ rc = (jboolean)UnregisterClassW((LPWSTR)lparg0, (HINSTANCE)arg1);
+ if (arg0) (*env)->ReleaseCharArrayElements(env, arg0, lparg0, 0);
+ return rc;
+}
+#endif /* NO_UnregisterClassW */
+
+#ifndef NO_UpdateWindow
+JNIEXPORT jboolean JNICALL OS_NATIVE(UpdateWindow)
+ (JNIEnv *env, jclass that, jint arg0)
+{
+ DEBUG_CALL("UpdateWindow\n")
+
+ return (jboolean)UpdateWindow((HWND)arg0);
+}
+#endif /* NO_UpdateWindow */
+
+#ifndef NO_ValidateRect
+JNIEXPORT jboolean JNICALL OS_NATIVE(ValidateRect)
+ (JNIEnv *env, jclass that, jint arg0, jobject arg1)
+{
+ RECT _arg1, *lparg1=NULL;
+ jboolean rc;
+
+ DEBUG_CALL("ValidateRect\n")
+
+ if (arg1) lparg1 = getRECTFields(env, arg1, &_arg1);
+ rc = (jboolean)ValidateRect((HWND)arg0, lparg1);
+ if (arg1) setRECTFields(env, arg1, lparg1);
+ return rc;
+}
+#endif /* NO_ValidateRect */
+
+#ifndef NO_VkKeyScanA
+JNIEXPORT jshort JNICALL OS_NATIVE(VkKeyScanA)
+ (JNIEnv *env, jclass that, jshort arg0)
+{
+ DEBUG_CALL("VkKeyScanA\n")
+
+ return (jshort)VkKeyScanA((TCHAR)arg0);
+}
+#endif /* NO_VkKeyScanA */
+
+#ifndef NO_VkKeyScanW
+JNIEXPORT jshort JNICALL OS_NATIVE(VkKeyScanW)
+ (JNIEnv *env, jclass that, jshort arg0)
+{
+ DEBUG_CALL("VkKeyScanW\n")
+
+ return (jshort)VkKeyScanW((WCHAR)arg0);
+}
+#endif /* NO_VkKeyScanW */
+
+#ifndef NO_VtblCall
+JNIEXPORT jint JNICALL OS_NATIVE(VtblCall)
+ (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2)
+{
+ P_OLE_FN_2 fn;
+
+ DEBUG_CALL("VtblCall\n")
+
+ fn = (P_OLE_FN_2)(*(int **)arg1)[arg0];
+
+ return fn(arg1, arg2);
+}
+#endif /* NO_VtblCall */
+
+#ifndef NO_WaitMessage
+JNIEXPORT jboolean JNICALL OS_NATIVE(WaitMessage)
+ (JNIEnv *env, jclass that)
+{
+ DEBUG_CALL("WaitMessage\n")
+
+ return (jboolean)WaitMessage();
+}
+#endif /* NO_WaitMessage */
+
+#ifndef NO_WideCharToMultiByte__II_3CI_3BI_3B_3Z
+JNIEXPORT jint JNICALL OS_NATIVE(WideCharToMultiByte__II_3CI_3BI_3B_3Z)
+ (JNIEnv *env, jclass that, jint arg0, jint arg1, jcharArray arg2, jint arg3, jbyteArray arg4, jint arg5, jbyteArray arg6, jbooleanArray arg7)
+{
+ jchar *lparg2=NULL;
+ jbyte *lparg4=NULL;
+ jbyte *lparg6=NULL;
+ jboolean *lparg7=NULL;
+ jint rc;
+
+ DEBUG_CALL("WideCharToMultiByte__II_3CI_3BI_3B_3Z\n")
+
+ if (arg2) lparg2 = (*env)->GetCharArrayElements(env, arg2, NULL);
+ if (arg4) lparg4 = (*env)->GetByteArrayElements(env, arg4, NULL);
+ if (arg6) lparg6 = (*env)->GetByteArrayElements(env, arg6, NULL);
+ if (arg7) lparg7 = (*env)->GetBooleanArrayElements(env, arg7, NULL);
+ rc = (jint)WideCharToMultiByte(arg0, arg1, (LPCWSTR)lparg2, arg3, (LPSTR)lparg4, arg5, (LPCSTR)lparg6, (LPBOOL)lparg7);
+ if (arg2) (*env)->ReleaseCharArrayElements(env, arg2, lparg2, 0);
+ if (arg4) (*env)->ReleaseByteArrayElements(env, arg4, lparg4, 0);
+ if (arg6) (*env)->ReleaseByteArrayElements(env, arg6, lparg6, 0);
+ if (arg7) (*env)->ReleaseBooleanArrayElements(env, arg7, lparg7, 0);
+ return rc;
+}
+#endif /* NO_WideCharToMultiByte__II_3CI_3BI_3B_3Z */
+
+#ifndef NO_WideCharToMultiByte__II_3CIII_3B_3Z
+JNIEXPORT jint JNICALL OS_NATIVE(WideCharToMultiByte__II_3CIII_3B_3Z)
+ (JNIEnv *env, jclass that, jint arg0, jint arg1, jcharArray arg2, jint arg3, jint arg4, jint arg5, jbyteArray arg6, jbooleanArray arg7)
+{
+ jchar *lparg2=NULL;
+ jbyte *lparg6=NULL;
+ jboolean *lparg7=NULL;
+ jint rc;
+
+ DEBUG_CALL("WideCharToMultiByte__II_3CIII_3B_3Z\n")
+
+ if (arg2) lparg2 = (*env)->GetCharArrayElements(env, arg2, NULL);
+ if (arg6) lparg6 = (*env)->GetByteArrayElements(env, arg6, NULL);
+ if (arg7) lparg7 = (*env)->GetBooleanArrayElements(env, arg7, NULL);
+ rc = (jint)WideCharToMultiByte(arg0, arg1, (LPCWSTR)lparg2, arg3, (LPSTR)arg4, arg5, (LPCSTR)lparg6, (LPBOOL)lparg7);
+ if (arg2) (*env)->ReleaseCharArrayElements(env, arg2, lparg2, 0);
+ if (arg6) (*env)->ReleaseByteArrayElements(env, arg6, lparg6, 0);
+ if (arg7) (*env)->ReleaseBooleanArrayElements(env, arg7, lparg7, 0);
+ return rc;
+}
+#endif /* NO_WideCharToMultiByte__II_3CIII_3B_3Z */
+
+#ifndef NO_WindowFromDC
+JNIEXPORT jint JNICALL OS_NATIVE(WindowFromDC)
+ (JNIEnv *env, jclass that, jint arg0)
+{
+ DEBUG_CALL("WindowFromDC\n")
+
+ return (jint)WindowFromDC((HDC)arg0);
+}
+#endif /* NO_WindowFromDC */
+
+#ifndef NO_WindowFromPoint
+JNIEXPORT jint JNICALL OS_NATIVE(WindowFromPoint)
+ (JNIEnv *env, jclass that, jobject arg0)
+{
+ POINT _arg0, *lparg0=NULL;
+ jint rc;
+
+ DEBUG_CALL("WindowFromPoint\n")
+
+ if (arg0) lparg0 = getPOINTFields(env, arg0, &_arg0);
+ rc = (jint)WindowFromPoint(*lparg0);
+ if (arg0) setPOINTFields(env, arg0, lparg0);
+ return rc;
+}
+#endif /* NO_WindowFromPoint */
+
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/ole/win32/CAUUID.java b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/ole/win32/CAUUID.java
index d0714ff78f..f33339431b 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/ole/win32/CAUUID.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/ole/win32/CAUUID.java
@@ -1,15 +1,15 @@
-package org.eclipse.swt.internal.ole.win32;
-
-/*
+package org.eclipse.swt.internal.ole.win32;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-public final class CAUUID {
-
- public int cElems;
- public int pElems;
-
- public static final int sizeof = 8;
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+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 PI/win32/org/eclipse/swt/internal/ole/win32/COM.java b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/ole/win32/COM.java
index 0dee93d348..62ef45716d 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/ole/win32/COM.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/ole/win32/COM.java
@@ -1,670 +1,670 @@
-package org.eclipse.swt.internal.ole.win32;
-
-/*
+package org.eclipse.swt.internal.ole.win32;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-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}"); //$NON-NLS-1$
- public static final GUID IIDIEditorSiteProperty = IIDFromString("{D381A1F4-2326-4f3c-AFB9-B7537DB9E238}"); //$NON-NLS-1$
- public static final GUID IIDIEditorBaseProperty = IIDFromString("{61E55B0B-2647-47c4-8C89-E736EF15D636}"); //$NON-NLS-1$
- public static final GUID IIDIEditorSite = IIDFromString("{CDD88AB9-B01D-426E-B0F0-30973E9A074B}"); //$NON-NLS-1$
- public static final GUID IIDIEditorService = IIDFromString("{BEE283FE-7B42-4FF3-8232-0F07D43ABCF1}"); //$NON-NLS-1$
- public static final GUID IIDIEditorManager = IIDFromString("{EFDE08C4-BE87-4B1A-BF84-15FC30207180}"); //$NON-NLS-1$
-
- public static final GUID IIDIAccessible = IIDFromString("{618736E0-3C3D-11CF-810C-00AA00389B71}"); //$NON-NLS-1$
- //public static final GUID IIDIAccessibleHandler = IIDFromString("{03022430-ABC4-11D0-BDE2-00AA001A1953}"); //$NON-NLS-1$
- //public static final GUID IIDIAccessor = IIDFromString("{0C733A8C-2A1C-11CE-ADE5-00AA0044773D}"); //$NON-NLS-1$
-
- public static final GUID IIDIAdviseSink = IIDFromString("{0000010F-0000-0000-C000-000000000046}"); //$NON-NLS-1$
- //public static final GUID IIDIAdviseSink2 = IIDFromString("{00000125-0000-0000-C000-000000000046}"); //$NON-NLS-1$
- //public static final GUID IIDIBindCtx = IIDFromString("{0000000E-0000-0000-C000-000000000046}"); //$NON-NLS-1$
- //public static final GUID IIDIClassFactory = IIDFromString("{00000001-0000-0000-C000-000000000046}"); //$NON-NLS-1$
- public static final GUID IIDIClassFactory2 = IIDFromString("{B196B28F-BAB4-101A-B69C-00AA00341D07}"); //$NON-NLS-1$
- public static final GUID IIDIConnectionPoint = IIDFromString("{B196B286-BAB4-101A-B69C-00AA00341D07}"); //$NON-NLS-1$
- public static final GUID IIDIConnectionPointContainer = IIDFromString("{B196B284-BAB4-101A-B69C-00AA00341D07}"); //$NON-NLS-1$
- //public static final GUID IIDICreateErrorInfo = IIDFromString("{22F03340-547D-101B-8E65-08002B2BD119}"); //$NON-NLS-1$
- //public static final GUID IIDICreateTypeInfo = IIDFromString("{00020405-0000-0000-C000-000000000046}"); //$NON-NLS-1$
- //public static final GUID IIDICreateTypeLib = IIDFromString("{00020406-0000-0000-C000-000000000046}"); //$NON-NLS-1$
- //public static final GUID IIDIDataAdviseHolder = IIDFromString("{00000110-0000-0000-C000-000000000046}"); //$NON-NLS-1$
- public static final GUID IIDIDataObject = IIDFromString("{0000010E-0000-0000-C000-000000000046}"); //$NON-NLS-1$
- public static final GUID IIDIDispatch = IIDFromString("{00020400-0000-0000-C000-000000000046}"); //$NON-NLS-1$
- public static final GUID IIDIDropSource = IIDFromString("{00000121-0000-0000-C000-000000000046}"); //$NON-NLS-1$
- public static final GUID IIDIDropTarget = IIDFromString("{00000122-0000-0000-C000-000000000046}"); //$NON-NLS-1$
- //public static final GUID IIDIEnumConnectionPoints = IIDFromString("{B196B285-BAB4-101A-B69C-00AA00341D07}"); //$NON-NLS-1$
- //public static final GUID IIDIEnumConnections = IIDFromString("{B196B287-BAB4-101A-B69C-00AA00341D07}"); //$NON-NLS-1$
- public static final GUID IIDIEnumFORMATETC = IIDFromString("{00000103-0000-0000-C000-000000000046}"); //$NON-NLS-1$
- //public static final GUID IIDIEnumMoniker = IIDFromString("{00000102-0000-0000-C000-000000000046}"); //$NON-NLS-1$
- //public static final GUID IIDIEnumOLEVERB = IIDFromString("{00000104-0000-0000-C000-000000000046}"); //$NON-NLS-1$
- //public static final GUID IIDIEnumSTATDATA = IIDFromString("{00000105-0000-0000-C000-000000000046}"); //$NON-NLS-1$
- //public static final GUID IIDIEnumSTATSTG = IIDFromString("{0000000D-0000-0000-C000-000000000046}"); //$NON-NLS-1$
- //public static final GUID IIDIEnumString = IIDFromString("{00000101-0000-0000-C000-000000000046}"); //$NON-NLS-1$
- //public static final GUID IIDIEnumUnknown = IIDFromString("{00000100-0000-0000-C000-000000000046}"); //$NON-NLS-1$
- public static final GUID IIDIEnumVARIANT = IIDFromString("{00020404-0000-0000-C000-000000000046}"); //$NON-NLS-1$
- //public static final GUID IIDIErrorInfo = IIDFromString("{1CF2B120-547D-101B-8E65-08002B2BD119}"); //$NON-NLS-1$
- //public static final GUID IIDIErrorLog = IIDFromString("{3127CA40-446E-11CE-8135-00AA004BB851}"); //$NON-NLS-1$
- //public static final GUID IIDIExternalConnection = IIDFromString("{00000019-0000-0000-C000-000000000046}"); //$NON-NLS-1$
- public static final GUID IIDIFont = IIDFromString("{BEF6E002-A874-101A-8BBA-00AA00300CAB}"); //$NON-NLS-1$
- //public static final GUID IIDIFontDisp = IIDFromString("{BEF6E003-A874-101A-8BBA-00AA00300CAB}"); //$NON-NLS-1$
- //public static final GUID IIDILockBytes = IIDFromString("{0000000A-0000-0000-C000-000000000046}"); //$NON-NLS-1$
- //public static final GUID IIDIMalloc = IIDFromString("{00000002-0000-0000-C000-000000000046}"); //$NON-NLS-1$
- //public static final GUID IIDIMallocSpy = IIDFromString("{0000001D-0000-0000-C000-000000000046}"); //$NON-NLS-1$
- //public static final GUID IIDIMarshal = IIDFromString("{00000003-0000-0000-C000-000000000046}"); //$NON-NLS-1$
- //public static final GUID IIDIMessageFilter = IIDFromString("{00000016-0000-0000-C000-000000000046}"); //$NON-NLS-1$
- //public static final GUID IIDIMoniker = IIDFromString("{0000000F-0000-0000-C000-000000000046}"); //$NON-NLS-1$
- //public static final GUID IIDIOleAdviseHolder = IIDFromString("{00000111-0000-0000-C000-000000000046}"); //$NON-NLS-1$
- //public static final GUID IIDIOleCache = IIDFromString("{0000011E-0000-0000-C000-000000000046}"); //$NON-NLS-1$
- //public static final GUID IIDIOleCache2 = IIDFromString("{00000128-0000-0000-C000-000000000046}"); //$NON-NLS-1$
- //public static final GUID IIDIOleCacheControl = IIDFromString("{00000129-0000-0000-C000-000000000046}"); //$NON-NLS-1$
- public static final GUID IIDIOleClientSite = IIDFromString("{00000118-0000-0000-C000-000000000046}"); //$NON-NLS-1$
- public static final GUID IIDIOleCommandTarget = IIDFromString("{B722BCCB-4E68-101B-A2BC-00AA00404770}"); //$NON-NLS-1$
- public static final GUID IIDIOleContainer = IIDFromString("{0000011B-0000-0000-C000-000000000046}"); //$NON-NLS-1$
- public static final GUID IIDIOleControl = IIDFromString("{B196B288-BAB4-101A-B69C-00AA00341D07}"); //$NON-NLS-1$
- public static final GUID IIDIOleControlSite = IIDFromString("{B196B289-BAB4-101A-B69C-00AA00341D07}"); //$NON-NLS-1$
- public static final GUID IIDIOleDocument = IIDFromString("{B722BCC5-4E68-101B-A2BC-00AA00404770}"); //$NON-NLS-1$
- public static final GUID IIDIOleDocumentSite = IIDFromString("{B722BCC7-4E68-101B-A2BC-00AA00404770}"); //$NON-NLS-1$
- public static final GUID IIDIOleInPlaceActiveObject = IIDFromString("{00000117-0000-0000-C000-000000000046}"); //$NON-NLS-1$
- public static final GUID IIDIOleInPlaceFrame = IIDFromString("{00000116-0000-0000-C000-000000000046}"); //$NON-NLS-1$
- public static final GUID IIDIOleInPlaceObject = IIDFromString("{00000113-0000-0000-C000-000000000046}"); //$NON-NLS-1$
- public static final GUID IIDIOleInPlaceSite = IIDFromString("{00000119-0000-0000-C000-000000000046}"); //$NON-NLS-1$
- public static final GUID IIDIOleInPlaceUIWindow = IIDFromString("{00000115-0000-0000-C000-000000000046}"); //$NON-NLS-1$
- //public static final GUID IIDIOleItemContainer = IIDFromString("{0000011C-0000-0000-C000-000000000046}"); //$NON-NLS-1$
- public static final GUID IIDIOleLink = IIDFromString("{0000011D-0000-0000-C000-000000000046}"); //$NON-NLS-1$
- public static final GUID IIDIOleObject = IIDFromString("{00000112-0000-0000-C000-000000000046}"); //$NON-NLS-1$
- public static final GUID IIDIOleWindow = IIDFromString("{00000114-0000-0000-C000-000000000046}"); //$NON-NLS-1$
- //public static final GUID IIDIParseDisplayName = IIDFromString("{0000011A-0000-0000-C000-000000000046}"); //$NON-NLS-1$
- //public static final GUID IIDIPerPropertyBrowsing = IIDFromString("{376BD3AA-3845-101B-84ED-08002B2EC713}"); //$NON-NLS-1$
- public static final GUID IIDIPersist = IIDFromString("{0000010C-0000-0000-C000-000000000046}"); //$NON-NLS-1$
- public static final GUID IIDIPersistFile = IIDFromString("{0000010B-0000-0000-C000-000000000046}"); //$NON-NLS-1$
- //public static final GUID IIDIPersistMemory = IIDFromString("{BD1AE5E0-A6AE-11CE-BD37-504200C10000}"); //$NON-NLS-1$
- //public static final GUID IIDIPersistPropertyBag = IIDFromString("{37D84F60-42CB-11CE-8135-00AA004BB851}"); //$NON-NLS-1$
- public static final GUID IIDIPersistStorage = IIDFromString("{0000010A-0000-0000-C000-000000000046}"); //$NON-NLS-1$
- public static final GUID IIDIPersistStream = IIDFromString("{00000109-0000-0000-C000-000000000046}"); //$NON-NLS-1$
- //public static final GUID IIDIPersistStreamInit = IIDFromString("{7FD52380-4E07-101B-AE2D-08002B2EC713}"); //$NON-NLS-1$
- //public static final GUID IIDIPicture = IIDFromString("{7BF80980-BF32-101A-8BBB-00AA00300CAB}"); //$NON-NLS-1$
- //public static final GUID IIDIPictureDisp = IIDFromString("{7BF80981-BF32-101A-8BBB-00AA00300CAB}"); //$NON-NLS-1$
- //public static final GUID IIDIPropertyBag = IIDFromString("{55272A00-42CB-11CE-8135-00AA004BB851}"); //$NON-NLS-1$
- public static final GUID IIDIPropertyNotifySink = IIDFromString("{9BFBBC02-EFF1-101A-84ED-00AA00341D07}"); //$NON-NLS-1$
- //public static final GUID IIDIPropertyPage = IIDFromString("{B196B28D-BAB4-101A-B69C-00AA00341D07}"); //$NON-NLS-1$
- //public static final GUID IIDIPropertyPage2 = IIDFromString("{01E44665-24AC-101B-84ED-08002B2EC713}"); //$NON-NLS-1$
- //public static final GUID IIDIPropertyPageSite = IIDFromString("{B196B28C-BAB4-101A-B69C-00AA00341D07}"); //$NON-NLS-1$
- public static final GUID IIDIProvideClassInfo = IIDFromString("{B196B283-BAB4-101A-B69C-00AA00341D07}"); //$NON-NLS-1$
- public static final GUID IIDIProvideClassInfo2 = IIDFromString("{A6BC3AC0-DBAA-11CE-9DE3-00AA004BB851}"); //$NON-NLS-1$
- //public static final GUID IIDIPSFactoryBuffer = IIDFromString("{D5F569D0-593B-101A-B569-08002B2DBF7A}"); //$NON-NLS-1$
- //public static final GUID IIDIRootStorage = IIDFromString("{00000012-0000-0000-C000-000000000046}"); //$NON-NLS-1$
- //public static final GUID IIDIROTData = IIDFromString("{F29F6BC0-5021-11CE-AA15-00006901293F}"); //$NON-NLS-1$
- //public static final GUID IIDIRpcChannelBuffer = IIDFromString("{D5F56B60-593B-101A-B569-08002B2DBF7A}"); //$NON-NLS-1$
- //public static final GUID IIDIRpcProxyBuffer = IIDFromString("{D5F56A34-593B-101A-B569-08002B2DBF7A}"); //$NON-NLS-1$
- //public static final GUID IIDIRpcStubBuffer = IIDFromString("{D5F56AFC-593B-101A-B569-08002B2DBF7A}"); //$NON-NLS-1$
- //public static final GUID IIDIRunnableObject = IIDFromString("{00000126-0000-0000-C000-000000000046}"); //$NON-NLS-1$
- //public static final GUID IIDIRunningObjectTable = IIDFromString("{00000010-0000-0000-C000-000000000046}"); //$NON-NLS-1$
- //public static final GUID IIDISimpleFrameSite = IIDFromString("{742B0E01-14E6-101B-914E-00AA00300CAB}"); //$NON-NLS-1$
- public static final GUID IIDISpecifyPropertyPages = IIDFromString("{B196B28B-BAB4-101A-B69C-00AA00341D07}"); //$NON-NLS-1$
- //public static final GUID IIDIStdMarshalInfo = IIDFromString("{00000018-0000-0000-C000-000000000046}"); //$NON-NLS-1$
- public static final GUID IIDIStorage = IIDFromString("{0000000B-0000-0000-C000-000000000046}"); //$NON-NLS-1$
- public static final GUID IIDIStream = IIDFromString("{0000000C-0000-0000-C000-000000000046}"); //$NON-NLS-1$
- //public static final GUID IIDISupportErrorInfo = IIDFromString("{DF0B3D60-548F-101B-8E65-08002B2BD119}"); //$NON-NLS-1$
- //public static final GUID IIDITypeComp = IIDFromString("{00020403-0000-0000-C000-000000000046}"); //$NON-NLS-1$
- //public static final GUID IIDITypeLib = IIDFromString("{00020402-0000-0000-C000-000000000046}"); //$NON-NLS-1$
- public static final GUID IIDIUnknown = IIDFromString("{00000000-0000-0000-C000-000000000046}"); //$NON-NLS-1$
- //public static final GUID IIDIViewObject = IIDFromString("{0000010D-0000-0000-C000-000000000046}"); //$NON-NLS-1$
- public static final GUID IIDIViewObject2 = IIDFromString("{00000127-0000-0000-C000-000000000046}"); //$NON-NLS-1$
-
- //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 short VARIANT_TRUE = -1;
- public static final short VARIANT_FALSE = 0;
-
-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 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 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(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(STGMEDIUM Destination, int SourcePtr, 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 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(
- int 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 StringFromCLSID(GUID rclsid, int[] ppsz);
-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, MSG arg0);
-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, RECT arg0);
-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);
-
-/* Start ACCESSIBILITY */
-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, int arg2, int arg3, int arg4);
-public static final native int VtblCall(int fnNumber, int ppVtbl, int arg0, int arg1, int arg2, int arg3, int arg4, int arg5);
-public static final native int VtblCall(int fnNumber, int ppVtbl, int arg0, int arg1, int arg2, int arg3, int arg4, int arg5, int arg6, int arg7);
-
-public static final native int CreateStdAccessibleObject (int hwnd, int idObject, GUID riidInterface, int[] ppvObject);
-public static final native int LresultFromObject (GUID riid, int wParam, int pAcc);
-public static final native int NotifyWinEvent (int event, int hwnd, int idObject, int idChild);
-
-public static final int OBJID_WINDOW = 0x00000000;
-public static final int OBJID_CLIENT = 0xfffffffc;
-public static final int EVENT_OBJECT_FOCUS = 0x8005;
-//public static final int EVENT_OBJECT_SELECTION = 0x8006;
-public static final int CO_E_OBJNOTCONNECTED = 0x800401FD;
-
-public static final int STATE_SYSTEM_NORMAL = 0;
-//public static final int STATE_SYSTEM_UNAVAILABLE = 0x1;
-public static final int STATE_SYSTEM_SELECTED = 0x2;
-public static final int STATE_SYSTEM_FOCUSED = 0x4;
-public static final int STATE_SYSTEM_PRESSED = 0x8;
-public static final int STATE_SYSTEM_CHECKED = 0x10;
-//public static final int STATE_SYSTEM_MIXED = 0x20;
-//public static final int STATE_SYSTEM_INDETERMINATE = STATE_SYSTEM_MIXED;
-public static final int STATE_SYSTEM_READONLY = 0x40;
-public static final int STATE_SYSTEM_HOTTRACKED = 0x80;
-//public static final int STATE_SYSTEM_DEFAULT = 0x100;
-public static final int STATE_SYSTEM_EXPANDED = 0x200;
-public static final int STATE_SYSTEM_COLLAPSED = 0x400;
-public static final int STATE_SYSTEM_BUSY = 0x800;
-//public static final int STATE_SYSTEM_FLOATING = 0x1000;
-//public static final int STATE_SYSTEM_MARQUEED = 0x2000;
-//public static final int STATE_SYSTEM_ANIMATED = 0x4000;
-public static final int STATE_SYSTEM_INVISIBLE = 0x8000;
-public static final int STATE_SYSTEM_OFFSCREEN = 0x10000;
-public static final int STATE_SYSTEM_SIZEABLE = 0x20000;
-//public static final int STATE_SYSTEM_MOVEABLE = 0x40000;
-//public static final int STATE_SYSTEM_SELFVOICING = 0x80000;
-public static final int STATE_SYSTEM_FOCUSABLE = 0x100000;
-public static final int STATE_SYSTEM_SELECTABLE = 0x200000;
-//public static final int STATE_SYSTEM_LINKED = 0x400000;
-//public static final int STATE_SYSTEM_TRAVERSED = 0x800000;
-public static final int STATE_SYSTEM_MULTISELECTABLE = 0x1000000;
-//public static final int STATE_SYSTEM_EXTSELECTABLE = 0x2000000;
-//public static final int STATE_SYSTEM_ALERT_LOW = 0x4000000;
-//public static final int STATE_SYSTEM_ALERT_MEDIUM = 0x8000000;
-//public static final int STATE_SYSTEM_ALERT_HIGH = 0x10000000;
-//public static final int STATE_SYSTEM_PROTECTED = 0x20000000;
-//public static final int STATE_SYSTEM_VALID = 0x3fffffff;
-
-//public static final int ROLE_SYSTEM_TITLEBAR = 0x1;
-public static final int ROLE_SYSTEM_MENUBAR = 0x2;
-public static final int ROLE_SYSTEM_SCROLLBAR = 0x3;
-//public static final int ROLE_SYSTEM_GRIP = 0x4;
-//public static final int ROLE_SYSTEM_SOUND = 0x5;
-//public static final int ROLE_SYSTEM_CURSOR = 0x6;
-//public static final int ROLE_SYSTEM_CARET = 0x7;
-//public static final int ROLE_SYSTEM_ALERT = 0x8;
-public static final int ROLE_SYSTEM_WINDOW = 0x9;
-public static final int ROLE_SYSTEM_CLIENT = 0xa;
-public static final int ROLE_SYSTEM_MENUPOPUP = 0xb;
-public static final int ROLE_SYSTEM_MENUITEM = 0xc;
-public static final int ROLE_SYSTEM_TOOLTIP = 0xd;
-//public static final int ROLE_SYSTEM_APPLICATION = 0xe;
-//public static final int ROLE_SYSTEM_DOCUMENT = 0xf;
-//public static final int ROLE_SYSTEM_PANE = 0x10;
-//public static final int ROLE_SYSTEM_CHART = 0x11;
-public static final int ROLE_SYSTEM_DIALOG = 0x12;
-//public static final int ROLE_SYSTEM_BORDER = 0x13;
-//public static final int ROLE_SYSTEM_GROUPING = 0x14;
-public static final int ROLE_SYSTEM_SEPARATOR = 0x15;
-public static final int ROLE_SYSTEM_TOOLBAR = 0x16;
-//public static final int ROLE_SYSTEM_STATUSBAR = 0x17;
-public static final int ROLE_SYSTEM_TABLE = 0x18;
-public static final int ROLE_SYSTEM_COLUMNHEADER = 0x19;
-//public static final int ROLE_SYSTEM_ROWHEADER = 0x1a;
-//public static final int ROLE_SYSTEM_COLUMN = 0x1b;
-//public static final int ROLE_SYSTEM_ROW = 0x1c;
-//public static final int ROLE_SYSTEM_CELL = 0x1d;
-//public static final int ROLE_SYSTEM_LINK = 0x1e;
-//public static final int ROLE_SYSTEM_HELPBALLOON = 0x1f;
-//public static final int ROLE_SYSTEM_CHARACTER = 0x20;
-public static final int ROLE_SYSTEM_LIST = 0x21;
-public static final int ROLE_SYSTEM_LISTITEM = 0x22;
-public static final int ROLE_SYSTEM_OUTLINE = 0x23;
-//public static final int ROLE_SYSTEM_OUTLINEITEM = 0x24;
-public static final int ROLE_SYSTEM_PAGETAB = 0x25;
-//public static final int ROLE_SYSTEM_PROPERTYPAGE = 0x26;
-//public static final int ROLE_SYSTEM_INDICATOR = 0x27;
-//public static final int ROLE_SYSTEM_GRAPHIC = 0x28;
-public static final int ROLE_SYSTEM_STATICTEXT = 0x29;
-public static final int ROLE_SYSTEM_TEXT = 0x2a;
-public static final int ROLE_SYSTEM_PUSHBUTTON = 0x2b;
-public static final int ROLE_SYSTEM_CHECKBUTTON = 0x2c;
-public static final int ROLE_SYSTEM_RADIOBUTTON = 0x2d;
-public static final int ROLE_SYSTEM_COMBOBOX = 0x2e;
-//public static final int ROLE_SYSTEM_DROPLIST = 0x2f;
-public static final int ROLE_SYSTEM_PROGRESSBAR = 0x30;
-//public static final int ROLE_SYSTEM_DIAL = 0x31;
-//public static final int ROLE_SYSTEM_HOTKEYFIELD = 0x32;
-public static final int ROLE_SYSTEM_SLIDER = 0x33;
-//public static final int ROLE_SYSTEM_SPINBUTTON = 0x34;
-//public static final int ROLE_SYSTEM_DIAGRAM = 0x35;
-//public static final int ROLE_SYSTEM_ANIMATION = 0x36;
-//public static final int ROLE_SYSTEM_EQUATION = 0x37;
-//public static final int ROLE_SYSTEM_BUTTONDROPDOWN = 0x38;
-//public static final int ROLE_SYSTEM_BUTTONMENU = 0x39;
-//public static final int ROLE_SYSTEM_BUTTONDROPDOWNGRID = 0x3a;
-//public static final int ROLE_SYSTEM_WHITESPACE = 0x3b;
-public static final int ROLE_SYSTEM_PAGETABLIST = 0x3c;
-//public static final int ROLE_SYSTEM_CLOCK = 0x3d;
-
-public static final int CHILDID_SELF = 0;
-
-/* End ACCESSIBILITY */
-
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+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}"); //$NON-NLS-1$
+ public static final GUID IIDIEditorSiteProperty = IIDFromString("{D381A1F4-2326-4f3c-AFB9-B7537DB9E238}"); //$NON-NLS-1$
+ public static final GUID IIDIEditorBaseProperty = IIDFromString("{61E55B0B-2647-47c4-8C89-E736EF15D636}"); //$NON-NLS-1$
+ public static final GUID IIDIEditorSite = IIDFromString("{CDD88AB9-B01D-426E-B0F0-30973E9A074B}"); //$NON-NLS-1$
+ public static final GUID IIDIEditorService = IIDFromString("{BEE283FE-7B42-4FF3-8232-0F07D43ABCF1}"); //$NON-NLS-1$
+ public static final GUID IIDIEditorManager = IIDFromString("{EFDE08C4-BE87-4B1A-BF84-15FC30207180}"); //$NON-NLS-1$
+
+ public static final GUID IIDIAccessible = IIDFromString("{618736E0-3C3D-11CF-810C-00AA00389B71}"); //$NON-NLS-1$
+ //public static final GUID IIDIAccessibleHandler = IIDFromString("{03022430-ABC4-11D0-BDE2-00AA001A1953}"); //$NON-NLS-1$
+ //public static final GUID IIDIAccessor = IIDFromString("{0C733A8C-2A1C-11CE-ADE5-00AA0044773D}"); //$NON-NLS-1$
+
+ public static final GUID IIDIAdviseSink = IIDFromString("{0000010F-0000-0000-C000-000000000046}"); //$NON-NLS-1$
+ //public static final GUID IIDIAdviseSink2 = IIDFromString("{00000125-0000-0000-C000-000000000046}"); //$NON-NLS-1$
+ //public static final GUID IIDIBindCtx = IIDFromString("{0000000E-0000-0000-C000-000000000046}"); //$NON-NLS-1$
+ //public static final GUID IIDIClassFactory = IIDFromString("{00000001-0000-0000-C000-000000000046}"); //$NON-NLS-1$
+ public static final GUID IIDIClassFactory2 = IIDFromString("{B196B28F-BAB4-101A-B69C-00AA00341D07}"); //$NON-NLS-1$
+ public static final GUID IIDIConnectionPoint = IIDFromString("{B196B286-BAB4-101A-B69C-00AA00341D07}"); //$NON-NLS-1$
+ public static final GUID IIDIConnectionPointContainer = IIDFromString("{B196B284-BAB4-101A-B69C-00AA00341D07}"); //$NON-NLS-1$
+ //public static final GUID IIDICreateErrorInfo = IIDFromString("{22F03340-547D-101B-8E65-08002B2BD119}"); //$NON-NLS-1$
+ //public static final GUID IIDICreateTypeInfo = IIDFromString("{00020405-0000-0000-C000-000000000046}"); //$NON-NLS-1$
+ //public static final GUID IIDICreateTypeLib = IIDFromString("{00020406-0000-0000-C000-000000000046}"); //$NON-NLS-1$
+ //public static final GUID IIDIDataAdviseHolder = IIDFromString("{00000110-0000-0000-C000-000000000046}"); //$NON-NLS-1$
+ public static final GUID IIDIDataObject = IIDFromString("{0000010E-0000-0000-C000-000000000046}"); //$NON-NLS-1$
+ public static final GUID IIDIDispatch = IIDFromString("{00020400-0000-0000-C000-000000000046}"); //$NON-NLS-1$
+ public static final GUID IIDIDropSource = IIDFromString("{00000121-0000-0000-C000-000000000046}"); //$NON-NLS-1$
+ public static final GUID IIDIDropTarget = IIDFromString("{00000122-0000-0000-C000-000000000046}"); //$NON-NLS-1$
+ //public static final GUID IIDIEnumConnectionPoints = IIDFromString("{B196B285-BAB4-101A-B69C-00AA00341D07}"); //$NON-NLS-1$
+ //public static final GUID IIDIEnumConnections = IIDFromString("{B196B287-BAB4-101A-B69C-00AA00341D07}"); //$NON-NLS-1$
+ public static final GUID IIDIEnumFORMATETC = IIDFromString("{00000103-0000-0000-C000-000000000046}"); //$NON-NLS-1$
+ //public static final GUID IIDIEnumMoniker = IIDFromString("{00000102-0000-0000-C000-000000000046}"); //$NON-NLS-1$
+ //public static final GUID IIDIEnumOLEVERB = IIDFromString("{00000104-0000-0000-C000-000000000046}"); //$NON-NLS-1$
+ //public static final GUID IIDIEnumSTATDATA = IIDFromString("{00000105-0000-0000-C000-000000000046}"); //$NON-NLS-1$
+ //public static final GUID IIDIEnumSTATSTG = IIDFromString("{0000000D-0000-0000-C000-000000000046}"); //$NON-NLS-1$
+ //public static final GUID IIDIEnumString = IIDFromString("{00000101-0000-0000-C000-000000000046}"); //$NON-NLS-1$
+ //public static final GUID IIDIEnumUnknown = IIDFromString("{00000100-0000-0000-C000-000000000046}"); //$NON-NLS-1$
+ public static final GUID IIDIEnumVARIANT = IIDFromString("{00020404-0000-0000-C000-000000000046}"); //$NON-NLS-1$
+ //public static final GUID IIDIErrorInfo = IIDFromString("{1CF2B120-547D-101B-8E65-08002B2BD119}"); //$NON-NLS-1$
+ //public static final GUID IIDIErrorLog = IIDFromString("{3127CA40-446E-11CE-8135-00AA004BB851}"); //$NON-NLS-1$
+ //public static final GUID IIDIExternalConnection = IIDFromString("{00000019-0000-0000-C000-000000000046}"); //$NON-NLS-1$
+ public static final GUID IIDIFont = IIDFromString("{BEF6E002-A874-101A-8BBA-00AA00300CAB}"); //$NON-NLS-1$
+ //public static final GUID IIDIFontDisp = IIDFromString("{BEF6E003-A874-101A-8BBA-00AA00300CAB}"); //$NON-NLS-1$
+ //public static final GUID IIDILockBytes = IIDFromString("{0000000A-0000-0000-C000-000000000046}"); //$NON-NLS-1$
+ //public static final GUID IIDIMalloc = IIDFromString("{00000002-0000-0000-C000-000000000046}"); //$NON-NLS-1$
+ //public static final GUID IIDIMallocSpy = IIDFromString("{0000001D-0000-0000-C000-000000000046}"); //$NON-NLS-1$
+ //public static final GUID IIDIMarshal = IIDFromString("{00000003-0000-0000-C000-000000000046}"); //$NON-NLS-1$
+ //public static final GUID IIDIMessageFilter = IIDFromString("{00000016-0000-0000-C000-000000000046}"); //$NON-NLS-1$
+ //public static final GUID IIDIMoniker = IIDFromString("{0000000F-0000-0000-C000-000000000046}"); //$NON-NLS-1$
+ //public static final GUID IIDIOleAdviseHolder = IIDFromString("{00000111-0000-0000-C000-000000000046}"); //$NON-NLS-1$
+ //public static final GUID IIDIOleCache = IIDFromString("{0000011E-0000-0000-C000-000000000046}"); //$NON-NLS-1$
+ //public static final GUID IIDIOleCache2 = IIDFromString("{00000128-0000-0000-C000-000000000046}"); //$NON-NLS-1$
+ //public static final GUID IIDIOleCacheControl = IIDFromString("{00000129-0000-0000-C000-000000000046}"); //$NON-NLS-1$
+ public static final GUID IIDIOleClientSite = IIDFromString("{00000118-0000-0000-C000-000000000046}"); //$NON-NLS-1$
+ public static final GUID IIDIOleCommandTarget = IIDFromString("{B722BCCB-4E68-101B-A2BC-00AA00404770}"); //$NON-NLS-1$
+ public static final GUID IIDIOleContainer = IIDFromString("{0000011B-0000-0000-C000-000000000046}"); //$NON-NLS-1$
+ public static final GUID IIDIOleControl = IIDFromString("{B196B288-BAB4-101A-B69C-00AA00341D07}"); //$NON-NLS-1$
+ public static final GUID IIDIOleControlSite = IIDFromString("{B196B289-BAB4-101A-B69C-00AA00341D07}"); //$NON-NLS-1$
+ public static final GUID IIDIOleDocument = IIDFromString("{B722BCC5-4E68-101B-A2BC-00AA00404770}"); //$NON-NLS-1$
+ public static final GUID IIDIOleDocumentSite = IIDFromString("{B722BCC7-4E68-101B-A2BC-00AA00404770}"); //$NON-NLS-1$
+ public static final GUID IIDIOleInPlaceActiveObject = IIDFromString("{00000117-0000-0000-C000-000000000046}"); //$NON-NLS-1$
+ public static final GUID IIDIOleInPlaceFrame = IIDFromString("{00000116-0000-0000-C000-000000000046}"); //$NON-NLS-1$
+ public static final GUID IIDIOleInPlaceObject = IIDFromString("{00000113-0000-0000-C000-000000000046}"); //$NON-NLS-1$
+ public static final GUID IIDIOleInPlaceSite = IIDFromString("{00000119-0000-0000-C000-000000000046}"); //$NON-NLS-1$
+ public static final GUID IIDIOleInPlaceUIWindow = IIDFromString("{00000115-0000-0000-C000-000000000046}"); //$NON-NLS-1$
+ //public static final GUID IIDIOleItemContainer = IIDFromString("{0000011C-0000-0000-C000-000000000046}"); //$NON-NLS-1$
+ public static final GUID IIDIOleLink = IIDFromString("{0000011D-0000-0000-C000-000000000046}"); //$NON-NLS-1$
+ public static final GUID IIDIOleObject = IIDFromString("{00000112-0000-0000-C000-000000000046}"); //$NON-NLS-1$
+ public static final GUID IIDIOleWindow = IIDFromString("{00000114-0000-0000-C000-000000000046}"); //$NON-NLS-1$
+ //public static final GUID IIDIParseDisplayName = IIDFromString("{0000011A-0000-0000-C000-000000000046}"); //$NON-NLS-1$
+ //public static final GUID IIDIPerPropertyBrowsing = IIDFromString("{376BD3AA-3845-101B-84ED-08002B2EC713}"); //$NON-NLS-1$
+ public static final GUID IIDIPersist = IIDFromString("{0000010C-0000-0000-C000-000000000046}"); //$NON-NLS-1$
+ public static final GUID IIDIPersistFile = IIDFromString("{0000010B-0000-0000-C000-000000000046}"); //$NON-NLS-1$
+ //public static final GUID IIDIPersistMemory = IIDFromString("{BD1AE5E0-A6AE-11CE-BD37-504200C10000}"); //$NON-NLS-1$
+ //public static final GUID IIDIPersistPropertyBag = IIDFromString("{37D84F60-42CB-11CE-8135-00AA004BB851}"); //$NON-NLS-1$
+ public static final GUID IIDIPersistStorage = IIDFromString("{0000010A-0000-0000-C000-000000000046}"); //$NON-NLS-1$
+ public static final GUID IIDIPersistStream = IIDFromString("{00000109-0000-0000-C000-000000000046}"); //$NON-NLS-1$
+ //public static final GUID IIDIPersistStreamInit = IIDFromString("{7FD52380-4E07-101B-AE2D-08002B2EC713}"); //$NON-NLS-1$
+ //public static final GUID IIDIPicture = IIDFromString("{7BF80980-BF32-101A-8BBB-00AA00300CAB}"); //$NON-NLS-1$
+ //public static final GUID IIDIPictureDisp = IIDFromString("{7BF80981-BF32-101A-8BBB-00AA00300CAB}"); //$NON-NLS-1$
+ //public static final GUID IIDIPropertyBag = IIDFromString("{55272A00-42CB-11CE-8135-00AA004BB851}"); //$NON-NLS-1$
+ public static final GUID IIDIPropertyNotifySink = IIDFromString("{9BFBBC02-EFF1-101A-84ED-00AA00341D07}"); //$NON-NLS-1$
+ //public static final GUID IIDIPropertyPage = IIDFromString("{B196B28D-BAB4-101A-B69C-00AA00341D07}"); //$NON-NLS-1$
+ //public static final GUID IIDIPropertyPage2 = IIDFromString("{01E44665-24AC-101B-84ED-08002B2EC713}"); //$NON-NLS-1$
+ //public static final GUID IIDIPropertyPageSite = IIDFromString("{B196B28C-BAB4-101A-B69C-00AA00341D07}"); //$NON-NLS-1$
+ public static final GUID IIDIProvideClassInfo = IIDFromString("{B196B283-BAB4-101A-B69C-00AA00341D07}"); //$NON-NLS-1$
+ public static final GUID IIDIProvideClassInfo2 = IIDFromString("{A6BC3AC0-DBAA-11CE-9DE3-00AA004BB851}"); //$NON-NLS-1$
+ //public static final GUID IIDIPSFactoryBuffer = IIDFromString("{D5F569D0-593B-101A-B569-08002B2DBF7A}"); //$NON-NLS-1$
+ //public static final GUID IIDIRootStorage = IIDFromString("{00000012-0000-0000-C000-000000000046}"); //$NON-NLS-1$
+ //public static final GUID IIDIROTData = IIDFromString("{F29F6BC0-5021-11CE-AA15-00006901293F}"); //$NON-NLS-1$
+ //public static final GUID IIDIRpcChannelBuffer = IIDFromString("{D5F56B60-593B-101A-B569-08002B2DBF7A}"); //$NON-NLS-1$
+ //public static final GUID IIDIRpcProxyBuffer = IIDFromString("{D5F56A34-593B-101A-B569-08002B2DBF7A}"); //$NON-NLS-1$
+ //public static final GUID IIDIRpcStubBuffer = IIDFromString("{D5F56AFC-593B-101A-B569-08002B2DBF7A}"); //$NON-NLS-1$
+ //public static final GUID IIDIRunnableObject = IIDFromString("{00000126-0000-0000-C000-000000000046}"); //$NON-NLS-1$
+ //public static final GUID IIDIRunningObjectTable = IIDFromString("{00000010-0000-0000-C000-000000000046}"); //$NON-NLS-1$
+ //public static final GUID IIDISimpleFrameSite = IIDFromString("{742B0E01-14E6-101B-914E-00AA00300CAB}"); //$NON-NLS-1$
+ public static final GUID IIDISpecifyPropertyPages = IIDFromString("{B196B28B-BAB4-101A-B69C-00AA00341D07}"); //$NON-NLS-1$
+ //public static final GUID IIDIStdMarshalInfo = IIDFromString("{00000018-0000-0000-C000-000000000046}"); //$NON-NLS-1$
+ public static final GUID IIDIStorage = IIDFromString("{0000000B-0000-0000-C000-000000000046}"); //$NON-NLS-1$
+ public static final GUID IIDIStream = IIDFromString("{0000000C-0000-0000-C000-000000000046}"); //$NON-NLS-1$
+ //public static final GUID IIDISupportErrorInfo = IIDFromString("{DF0B3D60-548F-101B-8E65-08002B2BD119}"); //$NON-NLS-1$
+ //public static final GUID IIDITypeComp = IIDFromString("{00020403-0000-0000-C000-000000000046}"); //$NON-NLS-1$
+ //public static final GUID IIDITypeLib = IIDFromString("{00020402-0000-0000-C000-000000000046}"); //$NON-NLS-1$
+ public static final GUID IIDIUnknown = IIDFromString("{00000000-0000-0000-C000-000000000046}"); //$NON-NLS-1$
+ //public static final GUID IIDIViewObject = IIDFromString("{0000010D-0000-0000-C000-000000000046}"); //$NON-NLS-1$
+ public static final GUID IIDIViewObject2 = IIDFromString("{00000127-0000-0000-C000-000000000046}"); //$NON-NLS-1$
+
+ //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 short VARIANT_TRUE = -1;
+ public static final short VARIANT_FALSE = 0;
+
+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 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 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(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(STGMEDIUM Destination, int SourcePtr, 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 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(
+ int 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 StringFromCLSID(GUID rclsid, int[] ppsz);
+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, MSG arg0);
+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, RECT arg0);
+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);
+
+/* Start ACCESSIBILITY */
+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, int arg2, int arg3, int arg4);
+public static final native int VtblCall(int fnNumber, int ppVtbl, int arg0, int arg1, int arg2, int arg3, int arg4, int arg5);
+public static final native int VtblCall(int fnNumber, int ppVtbl, int arg0, int arg1, int arg2, int arg3, int arg4, int arg5, int arg6, int arg7);
+
+public static final native int CreateStdAccessibleObject (int hwnd, int idObject, GUID riidInterface, int[] ppvObject);
+public static final native int LresultFromObject (GUID riid, int wParam, int pAcc);
+public static final native int NotifyWinEvent (int event, int hwnd, int idObject, int idChild);
+
+public static final int OBJID_WINDOW = 0x00000000;
+public static final int OBJID_CLIENT = 0xfffffffc;
+public static final int EVENT_OBJECT_FOCUS = 0x8005;
+//public static final int EVENT_OBJECT_SELECTION = 0x8006;
+public static final int CO_E_OBJNOTCONNECTED = 0x800401FD;
+
+public static final int STATE_SYSTEM_NORMAL = 0;
+//public static final int STATE_SYSTEM_UNAVAILABLE = 0x1;
+public static final int STATE_SYSTEM_SELECTED = 0x2;
+public static final int STATE_SYSTEM_FOCUSED = 0x4;
+public static final int STATE_SYSTEM_PRESSED = 0x8;
+public static final int STATE_SYSTEM_CHECKED = 0x10;
+//public static final int STATE_SYSTEM_MIXED = 0x20;
+//public static final int STATE_SYSTEM_INDETERMINATE = STATE_SYSTEM_MIXED;
+public static final int STATE_SYSTEM_READONLY = 0x40;
+public static final int STATE_SYSTEM_HOTTRACKED = 0x80;
+//public static final int STATE_SYSTEM_DEFAULT = 0x100;
+public static final int STATE_SYSTEM_EXPANDED = 0x200;
+public static final int STATE_SYSTEM_COLLAPSED = 0x400;
+public static final int STATE_SYSTEM_BUSY = 0x800;
+//public static final int STATE_SYSTEM_FLOATING = 0x1000;
+//public static final int STATE_SYSTEM_MARQUEED = 0x2000;
+//public static final int STATE_SYSTEM_ANIMATED = 0x4000;
+public static final int STATE_SYSTEM_INVISIBLE = 0x8000;
+public static final int STATE_SYSTEM_OFFSCREEN = 0x10000;
+public static final int STATE_SYSTEM_SIZEABLE = 0x20000;
+//public static final int STATE_SYSTEM_MOVEABLE = 0x40000;
+//public static final int STATE_SYSTEM_SELFVOICING = 0x80000;
+public static final int STATE_SYSTEM_FOCUSABLE = 0x100000;
+public static final int STATE_SYSTEM_SELECTABLE = 0x200000;
+//public static final int STATE_SYSTEM_LINKED = 0x400000;
+//public static final int STATE_SYSTEM_TRAVERSED = 0x800000;
+public static final int STATE_SYSTEM_MULTISELECTABLE = 0x1000000;
+//public static final int STATE_SYSTEM_EXTSELECTABLE = 0x2000000;
+//public static final int STATE_SYSTEM_ALERT_LOW = 0x4000000;
+//public static final int STATE_SYSTEM_ALERT_MEDIUM = 0x8000000;
+//public static final int STATE_SYSTEM_ALERT_HIGH = 0x10000000;
+//public static final int STATE_SYSTEM_PROTECTED = 0x20000000;
+//public static final int STATE_SYSTEM_VALID = 0x3fffffff;
+
+//public static final int ROLE_SYSTEM_TITLEBAR = 0x1;
+public static final int ROLE_SYSTEM_MENUBAR = 0x2;
+public static final int ROLE_SYSTEM_SCROLLBAR = 0x3;
+//public static final int ROLE_SYSTEM_GRIP = 0x4;
+//public static final int ROLE_SYSTEM_SOUND = 0x5;
+//public static final int ROLE_SYSTEM_CURSOR = 0x6;
+//public static final int ROLE_SYSTEM_CARET = 0x7;
+//public static final int ROLE_SYSTEM_ALERT = 0x8;
+public static final int ROLE_SYSTEM_WINDOW = 0x9;
+public static final int ROLE_SYSTEM_CLIENT = 0xa;
+public static final int ROLE_SYSTEM_MENUPOPUP = 0xb;
+public static final int ROLE_SYSTEM_MENUITEM = 0xc;
+public static final int ROLE_SYSTEM_TOOLTIP = 0xd;
+//public static final int ROLE_SYSTEM_APPLICATION = 0xe;
+//public static final int ROLE_SYSTEM_DOCUMENT = 0xf;
+//public static final int ROLE_SYSTEM_PANE = 0x10;
+//public static final int ROLE_SYSTEM_CHART = 0x11;
+public static final int ROLE_SYSTEM_DIALOG = 0x12;
+//public static final int ROLE_SYSTEM_BORDER = 0x13;
+//public static final int ROLE_SYSTEM_GROUPING = 0x14;
+public static final int ROLE_SYSTEM_SEPARATOR = 0x15;
+public static final int ROLE_SYSTEM_TOOLBAR = 0x16;
+//public static final int ROLE_SYSTEM_STATUSBAR = 0x17;
+public static final int ROLE_SYSTEM_TABLE = 0x18;
+public static final int ROLE_SYSTEM_COLUMNHEADER = 0x19;
+//public static final int ROLE_SYSTEM_ROWHEADER = 0x1a;
+//public static final int ROLE_SYSTEM_COLUMN = 0x1b;
+//public static final int ROLE_SYSTEM_ROW = 0x1c;
+//public static final int ROLE_SYSTEM_CELL = 0x1d;
+//public static final int ROLE_SYSTEM_LINK = 0x1e;
+//public static final int ROLE_SYSTEM_HELPBALLOON = 0x1f;
+//public static final int ROLE_SYSTEM_CHARACTER = 0x20;
+public static final int ROLE_SYSTEM_LIST = 0x21;
+public static final int ROLE_SYSTEM_LISTITEM = 0x22;
+public static final int ROLE_SYSTEM_OUTLINE = 0x23;
+//public static final int ROLE_SYSTEM_OUTLINEITEM = 0x24;
+public static final int ROLE_SYSTEM_PAGETAB = 0x25;
+//public static final int ROLE_SYSTEM_PROPERTYPAGE = 0x26;
+//public static final int ROLE_SYSTEM_INDICATOR = 0x27;
+//public static final int ROLE_SYSTEM_GRAPHIC = 0x28;
+public static final int ROLE_SYSTEM_STATICTEXT = 0x29;
+public static final int ROLE_SYSTEM_TEXT = 0x2a;
+public static final int ROLE_SYSTEM_PUSHBUTTON = 0x2b;
+public static final int ROLE_SYSTEM_CHECKBUTTON = 0x2c;
+public static final int ROLE_SYSTEM_RADIOBUTTON = 0x2d;
+public static final int ROLE_SYSTEM_COMBOBOX = 0x2e;
+//public static final int ROLE_SYSTEM_DROPLIST = 0x2f;
+public static final int ROLE_SYSTEM_PROGRESSBAR = 0x30;
+//public static final int ROLE_SYSTEM_DIAL = 0x31;
+//public static final int ROLE_SYSTEM_HOTKEYFIELD = 0x32;
+public static final int ROLE_SYSTEM_SLIDER = 0x33;
+//public static final int ROLE_SYSTEM_SPINBUTTON = 0x34;
+//public static final int ROLE_SYSTEM_DIAGRAM = 0x35;
+//public static final int ROLE_SYSTEM_ANIMATION = 0x36;
+//public static final int ROLE_SYSTEM_EQUATION = 0x37;
+//public static final int ROLE_SYSTEM_BUTTONDROPDOWN = 0x38;
+//public static final int ROLE_SYSTEM_BUTTONMENU = 0x39;
+//public static final int ROLE_SYSTEM_BUTTONDROPDOWNGRID = 0x3a;
+//public static final int ROLE_SYSTEM_WHITESPACE = 0x3b;
+public static final int ROLE_SYSTEM_PAGETABLIST = 0x3c;
+//public static final int ROLE_SYSTEM_CLOCK = 0x3d;
+
+public static final int CHILDID_SELF = 0;
+
+/* End ACCESSIBILITY */
+
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/ole/win32/CONTROLINFO.java b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/ole/win32/CONTROLINFO.java
index 08e67f74e9..9f1ff0358a 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/ole/win32/CONTROLINFO.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/ole/win32/CONTROLINFO.java
@@ -1,17 +1,17 @@
-package org.eclipse.swt.internal.ole.win32;
-
-/*
+package org.eclipse.swt.internal.ole.win32;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-public final class CONTROLINFO
-{
- public int cb;
- public int hAccel;
- public short cAccel;
- public int dwFlags;
-
- public static final int sizeof = 16;
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+public final class CONTROLINFO
+{
+ public int cb;
+ public int hAccel;
+ public short cAccel;
+ public int dwFlags;
+
+ public static final int sizeof = 16;
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/ole/win32/COSERVERINFO.java b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/ole/win32/COSERVERINFO.java
index 1d13f89f7b..82ff7b0489 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/ole/win32/COSERVERINFO.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/ole/win32/COSERVERINFO.java
@@ -1,16 +1,16 @@
-package org.eclipse.swt.internal.ole.win32;
-
-/*
+package org.eclipse.swt.internal.ole.win32;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-public class COSERVERINFO {
- public int dwReserved1;
- public int pwszName;
- public int pAuthInfo;
- public int dwReserved2;
-
- public static final int sizeof = 16;
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+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 PI/win32/org/eclipse/swt/internal/ole/win32/DISPPARAMS.java b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/ole/win32/DISPPARAMS.java
index 0a4c362294..a2ebc78b70 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/ole/win32/DISPPARAMS.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/ole/win32/DISPPARAMS.java
@@ -1,18 +1,18 @@
-package org.eclipse.swt.internal.ole.win32;
-
-/*
+package org.eclipse.swt.internal.ole.win32;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-public final class DISPPARAMS
-{
- public int rgvarg;
- public int rgdispidNamedArgs;
- public int cArgs;
- public int cNamedArgs;
-
- public static final int sizeof = 16;
-
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+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 PI/win32/org/eclipse/swt/internal/ole/win32/DVTARGETDEVICE.java b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/ole/win32/DVTARGETDEVICE.java
index 1421febdb5..e1af6b7c29 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/ole/win32/DVTARGETDEVICE.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/ole/win32/DVTARGETDEVICE.java
@@ -1,19 +1,19 @@
-package org.eclipse.swt.internal.ole.win32;
-
-/*
+package org.eclipse.swt.internal.ole.win32;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-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;
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+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 PI/win32/org/eclipse/swt/internal/ole/win32/EXCEPINFO.java b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/ole/win32/EXCEPINFO.java
index ecc5e4e947..f98f166da4 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/ole/win32/EXCEPINFO.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/ole/win32/EXCEPINFO.java
@@ -1,22 +1,22 @@
-package org.eclipse.swt.internal.ole.win32;
-
-/*
+package org.eclipse.swt.internal.ole.win32;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-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;
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+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 PI/win32/org/eclipse/swt/internal/ole/win32/FORMATETC.java b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/ole/win32/FORMATETC.java
index c36be9d8b9..7554bb46ef 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/ole/win32/FORMATETC.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/ole/win32/FORMATETC.java
@@ -1,18 +1,18 @@
-package org.eclipse.swt.internal.ole.win32;
-
-/*
+package org.eclipse.swt.internal.ole.win32;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-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;
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+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 PI/win32/org/eclipse/swt/internal/ole/win32/FUNCDESC1.java b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/ole/win32/FUNCDESC1.java
index 341c6891b2..57359ddb0c 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/ole/win32/FUNCDESC1.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/ole/win32/FUNCDESC1.java
@@ -1,32 +1,32 @@
-package org.eclipse.swt.internal.ole.win32;
-
-/*
+package org.eclipse.swt.internal.ole.win32;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-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;
- //PARAMDESC elemdescFunc.paramdesc
- public int elemdescFunc_paramdesc_pparamdescex;
- public short elemdescFunc_paramdesc_wParamFlags;
- public short wFuncFlags;
-
- public static final int sizeof = 50;
-
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+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;
+ //PARAMDESC elemdescFunc.paramdesc
+ public int elemdescFunc_paramdesc_pparamdescex;
+ public short elemdescFunc_paramdesc_wParamFlags;
+ public short wFuncFlags;
+
+ public static final int sizeof = 50;
+
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/ole/win32/FUNCDESC2.java b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/ole/win32/FUNCDESC2.java
index 52feffc604..9d9f3637f3 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/ole/win32/FUNCDESC2.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/ole/win32/FUNCDESC2.java
@@ -1,32 +1,32 @@
-package org.eclipse.swt.internal.ole.win32;
-
-/*
+package org.eclipse.swt.internal.ole.win32;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-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;
- //IDLDESC elemdescFunc.idldesc
- public int elemdescFunc_idldesc_dwReserved;
- public short elemdescFunc_idldesc_wIDLFlags;
- public short wFuncFlags;
-
- public static final int sizeof = 50;
-
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+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;
+ //IDLDESC elemdescFunc.idldesc
+ public int elemdescFunc_idldesc_dwReserved;
+ public short elemdescFunc_idldesc_wIDLFlags;
+ public short wFuncFlags;
+
+ public static final int sizeof = 50;
+
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/ole/win32/GUID.java b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/ole/win32/GUID.java
index 35f8d9f532..12a118fc58 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/ole/win32/GUID.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/ole/win32/GUID.java
@@ -1,24 +1,24 @@
-package org.eclipse.swt.internal.ole.win32;
-
-/*
+package org.eclipse.swt.internal.ole.win32;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-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;
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+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 PI/win32/org/eclipse/swt/internal/ole/win32/IAccessible.java b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/ole/win32/IAccessible.java
index c91d16e7c3..b9652fa6a9 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/ole/win32/IAccessible.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/ole/win32/IAccessible.java
@@ -1,80 +1,80 @@
-package org.eclipse.swt.internal.ole.win32;
-
-/*
+package org.eclipse.swt.internal.ole.win32;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-public class IAccessible extends IDispatch {
-
-public IAccessible(int address) {
- super(address);
-}
-
-public int get_accParent(int ppdispParent) {
- return COM.VtblCall(7, address, ppdispParent);
-}
-public int get_accChildCount(int pcountChildren) {
- return COM.VtblCall(8, address, pcountChildren);
-}
-public int get_accChild(int varChild_vt, int varChild_reserved1, int varChild_lVal, int varChild_reserved2, int ppdispChild) {
- return COM.VtblCall(9, address, varChild_vt, varChild_reserved1, varChild_lVal, varChild_reserved2, ppdispChild);
-}
-public int get_accName(int varChild_vt, int varChild_reserved1, int varChild_lVal, int varChild_reserved2, int pszName) {
- return COM.VtblCall(10, address, varChild_vt, varChild_reserved1, varChild_lVal, varChild_reserved2, pszName);
-}
-public int get_accValue(int varChild_vt, int varChild_reserved1, int varChild_lVal, int varChild_reserved2, int pszValue) {
- return COM.VtblCall(11, address, varChild_vt, varChild_reserved1, varChild_lVal, varChild_reserved2, pszValue);
-}
-public int get_accDescription(int varChild_vt, int varChild_reserved1, int varChild_lVal, int varChild_reserved2, int pszDescription) {
- return COM.VtblCall(12, address, varChild_vt, varChild_reserved1, varChild_lVal, varChild_reserved2, pszDescription);
-}
-public int get_accRole(int varChild_vt, int varChild_reserved1, int varChild_lVal, int varChild_reserved2, int pvarRole) {
- return COM.VtblCall(13, address, varChild_vt, varChild_reserved1, varChild_lVal, varChild_reserved2, pvarRole);
-}
-public int get_accState(int varChild_vt, int varChild_reserved1, int varChild_lVal, int varChild_reserved2, int pvarState) {
- return COM.VtblCall(14, address, varChild_vt, varChild_reserved1, varChild_lVal, varChild_reserved2, pvarState);
-}
-public int get_accHelp(int varChild_vt, int varChild_reserved1, int varChild_lVal, int varChild_reserved2, int pszHelp) {
- return COM.VtblCall(15, address, varChild_vt, varChild_reserved1, varChild_lVal, varChild_reserved2, pszHelp);
-}
-public int get_accHelpTopic(int pszHelpFile, int varChild_vt, int varChild_reserved1, int varChild_lVal, int varChild_reserved2, int pidTopic) {
- return COM.VtblCall(16, address, pszHelpFile, varChild_vt, varChild_reserved1, varChild_lVal, varChild_reserved2, pidTopic);
-}
-public int get_accKeyboardShortcut(int varChild_vt, int varChild_reserved1, int varChild_lVal, int varChild_reserved2, int pszKeyboardShortcut) {
- return COM.VtblCall(17, address, varChild_vt, varChild_reserved1, varChild_lVal, varChild_reserved2, pszKeyboardShortcut);
-}
-public int get_accFocus(int pvarChild) {
- return COM.VtblCall(18, address, pvarChild);
-}
-public int get_accSelection(int pvarChildren) {
- return COM.VtblCall(19, address, pvarChildren);
-}
-public int get_accDefaultAction(int varChild_vt, int varChild_reserved1, int varChild_lVal, int varChild_reserved2, int pszDefaultAction) {
- return COM.VtblCall(20, address, varChild_vt, varChild_reserved1, varChild_lVal, varChild_reserved2, pszDefaultAction);
-}
-public int accSelect(int flagsSelect, int varChild_vt, int varChild_reserved1, int varChild_lVal, int varChild_reserved2) {
- return COM.VtblCall(21, address, flagsSelect, varChild_vt, varChild_reserved1, varChild_lVal, varChild_reserved2);
-}
-public int accLocation(int pxLeft, int pyTop, int pcxWidth, int pcyHeight,
- int varChild_vt, int varChild_reserved1, int varChild_lVal, int varChild_reserved2) {
- return COM.VtblCall(22, address, pxLeft, pyTop, pcxWidth, pcyHeight, varChild_vt, varChild_reserved1, varChild_lVal, varChild_reserved2);
-}
-public int accNavigate(int navDir, int varStart_vt, int varStart_reserved1, int varStart_lVal, int varStart_reserved2, int pvarEndUpAt) {
- return COM.VtblCall(23, address, navDir, varStart_vt, varStart_reserved1, varStart_lVal, varStart_reserved2, pvarEndUpAt);
-}
-public int accHitTest(int xLeft, int yTop, int pvarChild) {
- return COM.VtblCall(24, address, xLeft, yTop, pvarChild);
-}
-public int accDoDefaultAction(int varChild_vt, int varChild_reserved1, int varChild_lVal, int varChild_reserved2) {
- return COM.VtblCall(25, address, varChild_vt, varChild_reserved1, varChild_lVal, varChild_reserved2);
-}
-public int put_accName(int varChild_vt, int varChild_reserved1, int varChild_lVal, int varChild_reserved2, int szName) {
- return COM.VtblCall(26, address, varChild_vt, varChild_reserved1, varChild_lVal, varChild_reserved2, szName);
-}
-public int put_accValue(int varChild_vt, int varChild_reserved1, int varChild_lVal, int varChild_reserved2, int szValue) {
- return COM.VtblCall(27, address, varChild_vt, varChild_reserved1, varChild_lVal, varChild_reserved2, szValue);
-}
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+public class IAccessible extends IDispatch {
+
+public IAccessible(int address) {
+ super(address);
+}
+
+public int get_accParent(int ppdispParent) {
+ return COM.VtblCall(7, address, ppdispParent);
+}
+public int get_accChildCount(int pcountChildren) {
+ return COM.VtblCall(8, address, pcountChildren);
+}
+public int get_accChild(int varChild_vt, int varChild_reserved1, int varChild_lVal, int varChild_reserved2, int ppdispChild) {
+ return COM.VtblCall(9, address, varChild_vt, varChild_reserved1, varChild_lVal, varChild_reserved2, ppdispChild);
+}
+public int get_accName(int varChild_vt, int varChild_reserved1, int varChild_lVal, int varChild_reserved2, int pszName) {
+ return COM.VtblCall(10, address, varChild_vt, varChild_reserved1, varChild_lVal, varChild_reserved2, pszName);
+}
+public int get_accValue(int varChild_vt, int varChild_reserved1, int varChild_lVal, int varChild_reserved2, int pszValue) {
+ return COM.VtblCall(11, address, varChild_vt, varChild_reserved1, varChild_lVal, varChild_reserved2, pszValue);
+}
+public int get_accDescription(int varChild_vt, int varChild_reserved1, int varChild_lVal, int varChild_reserved2, int pszDescription) {
+ return COM.VtblCall(12, address, varChild_vt, varChild_reserved1, varChild_lVal, varChild_reserved2, pszDescription);
+}
+public int get_accRole(int varChild_vt, int varChild_reserved1, int varChild_lVal, int varChild_reserved2, int pvarRole) {
+ return COM.VtblCall(13, address, varChild_vt, varChild_reserved1, varChild_lVal, varChild_reserved2, pvarRole);
+}
+public int get_accState(int varChild_vt, int varChild_reserved1, int varChild_lVal, int varChild_reserved2, int pvarState) {
+ return COM.VtblCall(14, address, varChild_vt, varChild_reserved1, varChild_lVal, varChild_reserved2, pvarState);
+}
+public int get_accHelp(int varChild_vt, int varChild_reserved1, int varChild_lVal, int varChild_reserved2, int pszHelp) {
+ return COM.VtblCall(15, address, varChild_vt, varChild_reserved1, varChild_lVal, varChild_reserved2, pszHelp);
+}
+public int get_accHelpTopic(int pszHelpFile, int varChild_vt, int varChild_reserved1, int varChild_lVal, int varChild_reserved2, int pidTopic) {
+ return COM.VtblCall(16, address, pszHelpFile, varChild_vt, varChild_reserved1, varChild_lVal, varChild_reserved2, pidTopic);
+}
+public int get_accKeyboardShortcut(int varChild_vt, int varChild_reserved1, int varChild_lVal, int varChild_reserved2, int pszKeyboardShortcut) {
+ return COM.VtblCall(17, address, varChild_vt, varChild_reserved1, varChild_lVal, varChild_reserved2, pszKeyboardShortcut);
+}
+public int get_accFocus(int pvarChild) {
+ return COM.VtblCall(18, address, pvarChild);
+}
+public int get_accSelection(int pvarChildren) {
+ return COM.VtblCall(19, address, pvarChildren);
+}
+public int get_accDefaultAction(int varChild_vt, int varChild_reserved1, int varChild_lVal, int varChild_reserved2, int pszDefaultAction) {
+ return COM.VtblCall(20, address, varChild_vt, varChild_reserved1, varChild_lVal, varChild_reserved2, pszDefaultAction);
+}
+public int accSelect(int flagsSelect, int varChild_vt, int varChild_reserved1, int varChild_lVal, int varChild_reserved2) {
+ return COM.VtblCall(21, address, flagsSelect, varChild_vt, varChild_reserved1, varChild_lVal, varChild_reserved2);
+}
+public int accLocation(int pxLeft, int pyTop, int pcxWidth, int pcyHeight,
+ int varChild_vt, int varChild_reserved1, int varChild_lVal, int varChild_reserved2) {
+ return COM.VtblCall(22, address, pxLeft, pyTop, pcxWidth, pcyHeight, varChild_vt, varChild_reserved1, varChild_lVal, varChild_reserved2);
+}
+public int accNavigate(int navDir, int varStart_vt, int varStart_reserved1, int varStart_lVal, int varStart_reserved2, int pvarEndUpAt) {
+ return COM.VtblCall(23, address, navDir, varStart_vt, varStart_reserved1, varStart_lVal, varStart_reserved2, pvarEndUpAt);
+}
+public int accHitTest(int xLeft, int yTop, int pvarChild) {
+ return COM.VtblCall(24, address, xLeft, yTop, pvarChild);
+}
+public int accDoDefaultAction(int varChild_vt, int varChild_reserved1, int varChild_lVal, int varChild_reserved2) {
+ return COM.VtblCall(25, address, varChild_vt, varChild_reserved1, varChild_lVal, varChild_reserved2);
+}
+public int put_accName(int varChild_vt, int varChild_reserved1, int varChild_lVal, int varChild_reserved2, int szName) {
+ return COM.VtblCall(26, address, varChild_vt, varChild_reserved1, varChild_lVal, varChild_reserved2, szName);
+}
+public int put_accValue(int varChild_vt, int varChild_reserved1, int varChild_lVal, int varChild_reserved2, int szValue) {
+ return COM.VtblCall(27, address, varChild_vt, varChild_reserved1, varChild_lVal, varChild_reserved2, szValue);
+}
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/ole/win32/IClassFactory2.java b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/ole/win32/IClassFactory2.java
index 92739acc34..96dca9ceb3 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/ole/win32/IClassFactory2.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/ole/win32/IClassFactory2.java
@@ -1,23 +1,23 @@
-package org.eclipse.swt.internal.ole.win32;
-
-/*
+package org.eclipse.swt.internal.ole.win32;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-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);
-}
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+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 PI/win32/org/eclipse/swt/internal/ole/win32/IConnectionPoint.java b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/ole/win32/IConnectionPoint.java
index dacec0ed96..be9dc973c6 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/ole/win32/IConnectionPoint.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/ole/win32/IConnectionPoint.java
@@ -1,20 +1,20 @@
-package org.eclipse.swt.internal.ole.win32;
-
-/*
+package org.eclipse.swt.internal.ole.win32;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-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);
-}
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+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 PI/win32/org/eclipse/swt/internal/ole/win32/IConnectionPointContainer.java b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/ole/win32/IConnectionPointContainer.java
index 8119e30ed0..3c050042ed 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/ole/win32/IConnectionPointContainer.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/ole/win32/IConnectionPointContainer.java
@@ -1,17 +1,17 @@
-package org.eclipse.swt.internal.ole.win32;
-
-/*
+package org.eclipse.swt.internal.ole.win32;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-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);
-}
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+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 PI/win32/org/eclipse/swt/internal/ole/win32/IDataObject.java b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/ole/win32/IDataObject.java
index 266fd68f24..4212c2864a 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/ole/win32/IDataObject.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/ole/win32/IDataObject.java
@@ -1,39 +1,39 @@
-package org.eclipse.swt.internal.ole.win32;
-
-/*
+package org.eclipse.swt.internal.ole.win32;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-public class IDataObject extends IUnknown {
-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);
-}
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+public class IDataObject extends IUnknown {
+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 PI/win32/org/eclipse/swt/internal/ole/win32/IDispatch.java b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/ole/win32/IDispatch.java
index 6e8d780c3a..19cbabdf65 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/ole/win32/IDispatch.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/ole/win32/IDispatch.java
@@ -1,62 +1,62 @@
-package org.eclipse.swt.internal.ole.win32;
-
-/*
+package org.eclipse.swt.internal.ole.win32;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-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);
-}
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+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 PI/win32/org/eclipse/swt/internal/ole/win32/IEnum.java b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/ole/win32/IEnum.java
index 947c1aac88..2d26756458 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/ole/win32/IEnum.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/ole/win32/IEnum.java
@@ -1,26 +1,26 @@
-package org.eclipse.swt.internal.ole.win32;
-
-/*
+package org.eclipse.swt.internal.ole.win32;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-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);
-}
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+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 PI/win32/org/eclipse/swt/internal/ole/win32/IEnumFORMATETC.java b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/ole/win32/IEnumFORMATETC.java
index 2a8beca935..04075de9ce 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/ole/win32/IEnumFORMATETC.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/ole/win32/IEnumFORMATETC.java
@@ -1,13 +1,13 @@
-package org.eclipse.swt.internal.ole.win32;
-
-/*
+package org.eclipse.swt.internal.ole.win32;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-public class IEnumFORMATETC extends IEnum {
-public IEnumFORMATETC(int address) {
- super(address);
-}
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+public class IEnumFORMATETC extends IEnum {
+public IEnumFORMATETC(int address) {
+ super(address);
+}
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/ole/win32/IEnumSTATSTG.java b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/ole/win32/IEnumSTATSTG.java
index 86c7e73096..2292b0da9d 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/ole/win32/IEnumSTATSTG.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/ole/win32/IEnumSTATSTG.java
@@ -1,13 +1,13 @@
-package org.eclipse.swt.internal.ole.win32;
-
-/*
+package org.eclipse.swt.internal.ole.win32;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-public class IEnumSTATSTG extends IEnum {
-public IEnumSTATSTG(int address) {
- super(address);
-}
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+public class IEnumSTATSTG extends IEnum {
+public IEnumSTATSTG(int address) {
+ super(address);
+}
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/ole/win32/IFont.java b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/ole/win32/IFont.java
index a6ab0aa684..df797108e8 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/ole/win32/IFont.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/ole/win32/IFont.java
@@ -1,16 +1,16 @@
-package org.eclipse.swt.internal.ole.win32;
-
-/*
+package org.eclipse.swt.internal.ole.win32;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-public class IFont extends IUnknown {
-public IFont(int address) {
- super(address);
-}
-public int get_hFont(int[] phfont){
- return COM.VtblCall(3, address, phfont);
-}
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+public class IFont extends IUnknown {
+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 PI/win32/org/eclipse/swt/internal/ole/win32/IMoniker.java b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/ole/win32/IMoniker.java
index 076e455d5d..13c0b125fa 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/ole/win32/IMoniker.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/ole/win32/IMoniker.java
@@ -1,14 +1,14 @@
-package org.eclipse.swt.internal.ole.win32;
-
-/*
+package org.eclipse.swt.internal.ole.win32;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-public class IMoniker extends IPersist
-{
-public IMoniker(int address) {
- super(address);
-}
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+public class IMoniker extends IPersist
+{
+public IMoniker(int address) {
+ super(address);
+}
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/ole/win32/IOleCommandTarget.java b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/ole/win32/IOleCommandTarget.java
index 97f008e0a4..4ed13fb415 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/ole/win32/IOleCommandTarget.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/ole/win32/IOleCommandTarget.java
@@ -1,32 +1,32 @@
-package org.eclipse.swt.internal.ole.win32;
-
-/*
+package org.eclipse.swt.internal.ole.win32;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-public class IOleCommandTarget extends IUnknown {
-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);
-}
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+public class IOleCommandTarget extends IUnknown {
+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 PI/win32/org/eclipse/swt/internal/ole/win32/IOleControl.java b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/ole/win32/IOleControl.java
index ff023a8f5e..e5e11b777e 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/ole/win32/IOleControl.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/ole/win32/IOleControl.java
@@ -1,17 +1,17 @@
-package org.eclipse.swt.internal.ole.win32;
-
-/*
+package org.eclipse.swt.internal.ole.win32;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-public class IOleControl extends IUnknown
-{
-public IOleControl(int address) {
- super(address);
-}
-public int GetControlInfo(CONTROLINFO pCI) {
- return COM.VtblCall(3, address, pCI);
-}
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+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 PI/win32/org/eclipse/swt/internal/ole/win32/IOleInPlaceActiveObject.java b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/ole/win32/IOleInPlaceActiveObject.java
index b09032ea7a..5e610ea590 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/ole/win32/IOleInPlaceActiveObject.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/ole/win32/IOleInPlaceActiveObject.java
@@ -1,23 +1,23 @@
-package org.eclipse.swt.internal.ole.win32;
-
-/*
+package org.eclipse.swt.internal.ole.win32;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-import org.eclipse.swt.internal.win32.*;
-
-public class IOleInPlaceActiveObject extends IOleWindow
-{
-public IOleInPlaceActiveObject(int address) {
- super(address);
-}
-public int TranslateAccelerator(MSG lpmsg) {
- //lpmsg - Pointer to message that may need translating
- return COM.VtblCall(5, address, lpmsg);
-}
-public int ResizeBorder(RECT prcBorder, int pUIWindow, boolean fFrameWindow) {
- return COM.VtblCall(8, address, prcBorder, pUIWindow, fFrameWindow);
-}
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+import org.eclipse.swt.internal.win32.*;
+
+public class IOleInPlaceActiveObject extends IOleWindow
+{
+public IOleInPlaceActiveObject(int address) {
+ super(address);
+}
+public int TranslateAccelerator(MSG lpmsg) {
+ //lpmsg - Pointer to message that may need translating
+ return COM.VtblCall(5, address, lpmsg);
+}
+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 PI/win32/org/eclipse/swt/internal/ole/win32/IOleInPlaceObject.java b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/ole/win32/IOleInPlaceObject.java
index 22abe0315b..48fb06c62d 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/ole/win32/IOleInPlaceObject.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/ole/win32/IOleInPlaceObject.java
@@ -1,28 +1,28 @@
-package org.eclipse.swt.internal.ole.win32;
-
-/*
+package org.eclipse.swt.internal.ole.win32;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-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 UIDeactivate() {
- return COM.VtblCall(6, address);
-}
-public int SetObjectRects(RECT lprcPosRect, RECT lprcClipRect) {
- return COM.VtblCall(7, address, lprcPosRect, lprcClipRect);
-}
-public int ReactivateAndUndo() {
- return COM.VtblCall(8, address);
-}
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+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 UIDeactivate() {
+ return COM.VtblCall(6, address);
+}
+public int SetObjectRects(RECT lprcPosRect, RECT lprcClipRect) {
+ return COM.VtblCall(7, address, lprcPosRect, lprcClipRect);
+}
+public int ReactivateAndUndo() {
+ return COM.VtblCall(8, address);
+}
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/ole/win32/IOleLink.java b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/ole/win32/IOleLink.java
index 290537a5e1..0dfa3b6836 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/ole/win32/IOleLink.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/ole/win32/IOleLink.java
@@ -1,20 +1,20 @@
-package org.eclipse.swt.internal.ole.win32;
-
-/*
+package org.eclipse.swt.internal.ole.win32;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-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);
-}
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+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 PI/win32/org/eclipse/swt/internal/ole/win32/IOleObject.java b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/ole/win32/IOleObject.java
index ac4e0e399c..9254d567e2 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/ole/win32/IOleObject.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/ole/win32/IOleObject.java
@@ -1,56 +1,56 @@
-package org.eclipse.swt.internal.ole.win32;
-
-/*
+package org.eclipse.swt.internal.ole.win32;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-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);
-}
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+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 PI/win32/org/eclipse/swt/internal/ole/win32/IOleWindow.java b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/ole/win32/IOleWindow.java
index 89784bf9ba..118920aa28 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/ole/win32/IOleWindow.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/ole/win32/IOleWindow.java
@@ -1,16 +1,16 @@
-package org.eclipse.swt.internal.ole.win32;
-
-/*
+package org.eclipse.swt.internal.ole.win32;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-public class IOleWindow extends IUnknown {
-public IOleWindow(int address) {
- super(address);
-}
-public int GetWindow(int phwnd[]) {
- return COM.VtblCall(3, address, phwnd);
-}
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+public class IOleWindow extends IUnknown {
+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 PI/win32/org/eclipse/swt/internal/ole/win32/IPersist.java b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/ole/win32/IPersist.java
index 2fddf926fb..54ff8b9ac3 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/ole/win32/IPersist.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/ole/win32/IPersist.java
@@ -1,17 +1,17 @@
-package org.eclipse.swt.internal.ole.win32;
-
-/*
+package org.eclipse.swt.internal.ole.win32;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-public class IPersist extends IUnknown
-{
-public IPersist(int address) {
- super(address);
-}
-public int GetClassID(GUID pClassID) {
- return COM.VtblCall(3, address, pClassID);
-}
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+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 PI/win32/org/eclipse/swt/internal/ole/win32/IPersistStorage.java b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/ole/win32/IPersistStorage.java
index d415894d21..0c4ba15c30 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/ole/win32/IPersistStorage.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/ole/win32/IPersistStorage.java
@@ -1,32 +1,32 @@
-package org.eclipse.swt.internal.ole.win32;
-
-/*
+package org.eclipse.swt.internal.ole.win32;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-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);
-}
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+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 PI/win32/org/eclipse/swt/internal/ole/win32/IProvideClassInfo.java b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/ole/win32/IProvideClassInfo.java
index 2eb23dc71c..b0253d8a2d 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/ole/win32/IProvideClassInfo.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/ole/win32/IProvideClassInfo.java
@@ -1,17 +1,17 @@
-package org.eclipse.swt.internal.ole.win32;
-
-/*
+package org.eclipse.swt.internal.ole.win32;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-public class IProvideClassInfo extends IUnknown
-{
-public IProvideClassInfo(int address) {
- super(address);
-}
-public int GetClassInfo(int[] ppTI) {
- return COM.VtblCall(3, address, ppTI);
-}
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+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 PI/win32/org/eclipse/swt/internal/ole/win32/IProvideClassInfo2.java b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/ole/win32/IProvideClassInfo2.java
index a4f3ad0f3c..24c386f2a7 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/ole/win32/IProvideClassInfo2.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/ole/win32/IProvideClassInfo2.java
@@ -1,17 +1,17 @@
-package org.eclipse.swt.internal.ole.win32;
-
-/*
+package org.eclipse.swt.internal.ole.win32;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-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);
-}
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+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 PI/win32/org/eclipse/swt/internal/ole/win32/ISpecifyPropertyPages.java b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/ole/win32/ISpecifyPropertyPages.java
index e86bed924c..1068e64911 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/ole/win32/ISpecifyPropertyPages.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/ole/win32/ISpecifyPropertyPages.java
@@ -1,17 +1,17 @@
-package org.eclipse.swt.internal.ole.win32;
-
-/*
+package org.eclipse.swt.internal.ole.win32;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-public class ISpecifyPropertyPages extends IUnknown {
-
-public ISpecifyPropertyPages(int address) {
- super(address);
-}
-public int GetPages(CAUUID pPages){
- return COM.VtblCall(3, address, pPages);
-}
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+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 PI/win32/org/eclipse/swt/internal/ole/win32/IStorage.java b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/ole/win32/IStorage.java
index 0ee4068123..267f03e401 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/ole/win32/IStorage.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/ole/win32/IStorage.java
@@ -1,145 +1,145 @@
-package org.eclipse.swt.internal.ole.win32;
-
-/*
+package org.eclipse.swt.internal.ole.win32;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-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);
-}
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+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 PI/win32/org/eclipse/swt/internal/ole/win32/IStream.java b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/ole/win32/IStream.java
index 4d5fa15805..94f7f21f1e 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/ole/win32/IStream.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/ole/win32/IStream.java
@@ -1,31 +1,31 @@
-package org.eclipse.swt.internal.ole.win32;
-
-/*
+package org.eclipse.swt.internal.ole.win32;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-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);
-}
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+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 PI/win32/org/eclipse/swt/internal/ole/win32/ITypeInfo.java b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/ole/win32/ITypeInfo.java
index e02fecb41c..de8e8806eb 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/ole/win32/ITypeInfo.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/ole/win32/ITypeInfo.java
@@ -1,156 +1,156 @@
-package org.eclipse.swt.internal.ole.win32;
-
-/*
+package org.eclipse.swt.internal.ole.win32;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-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);
-}
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+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 PI/win32/org/eclipse/swt/internal/ole/win32/IUnknown.java b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/ole/win32/IUnknown.java
index e83d25e9a4..477b263a63 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/ole/win32/IUnknown.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/ole/win32/IUnknown.java
@@ -1,27 +1,27 @@
-package org.eclipse.swt.internal.ole.win32;
-
-/*
+package org.eclipse.swt.internal.ole.win32;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-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);
-}
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+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 PI/win32/org/eclipse/swt/internal/ole/win32/IViewObject2.java b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/ole/win32/IViewObject2.java
index 2b2227a655..ce8fdeb099 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/ole/win32/IViewObject2.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/ole/win32/IViewObject2.java
@@ -1,22 +1,22 @@
-package org.eclipse.swt.internal.ole.win32;
-
-/*
+package org.eclipse.swt.internal.ole.win32;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-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);
-}
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+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 PI/win32/org/eclipse/swt/internal/ole/win32/LICINFO.java b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/ole/win32/LICINFO.java
index a449e3562c..fc1e76def3 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/ole/win32/LICINFO.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/ole/win32/LICINFO.java
@@ -1,16 +1,16 @@
-package org.eclipse.swt.internal.ole.win32;
-
-/*
+package org.eclipse.swt.internal.ole.win32;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-public final class LICINFO
-{
- public int cbLicInfo;
- public int fRuntimeKeyAvail;
- public int fLicVerified;
-
- public static final int sizeof = 12;
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+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 PI/win32/org/eclipse/swt/internal/ole/win32/OLECMD.java b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/ole/win32/OLECMD.java
index 075ca96091..9ea4c7cc9a 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/ole/win32/OLECMD.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/ole/win32/OLECMD.java
@@ -1,14 +1,14 @@
-package org.eclipse.swt.internal.ole.win32;
-
-/*
+package org.eclipse.swt.internal.ole.win32;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-public class OLECMD {
- public int cmdID;
- public int cmdf;
-
- public static final int sizeof = 8;
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+public class OLECMD {
+ public int cmdID;
+ public int cmdf;
+
+ public static final int sizeof = 8;
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/ole/win32/OLECMDTEXT.java b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/ole/win32/OLECMDTEXT.java
index 1c682fb466..5781b1d1c4 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/ole/win32/OLECMDTEXT.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/ole/win32/OLECMDTEXT.java
@@ -1,18 +1,18 @@
-package org.eclipse.swt.internal.ole.win32;
-
-/*
+package org.eclipse.swt.internal.ole.win32;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-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.
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+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 PI/win32/org/eclipse/swt/internal/ole/win32/OLEINPLACEFRAMEINFO.java b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/ole/win32/OLEINPLACEFRAMEINFO.java
index 63069f342c..83553a493f 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/ole/win32/OLEINPLACEFRAMEINFO.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/ole/win32/OLEINPLACEFRAMEINFO.java
@@ -1,20 +1,20 @@
-package org.eclipse.swt.internal.ole.win32;
-
-/*
+package org.eclipse.swt.internal.ole.win32;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-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;
-
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+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 PI/win32/org/eclipse/swt/internal/ole/win32/STATSTG.java b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/ole/win32/STATSTG.java
index 38c3012b2f..31fce5f2d0 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/ole/win32/STATSTG.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/ole/win32/STATSTG.java
@@ -1,40 +1,40 @@
-package org.eclipse.swt.internal.ole.win32;
-
-/*
+package org.eclipse.swt.internal.ole.win32;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-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;
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+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 PI/win32/org/eclipse/swt/internal/ole/win32/STGMEDIUM.java b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/ole/win32/STGMEDIUM.java
index a7e8c90aac..73b46f9111 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/ole/win32/STGMEDIUM.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/ole/win32/STGMEDIUM.java
@@ -1,16 +1,16 @@
-package org.eclipse.swt.internal.ole.win32;
-
-/*
+package org.eclipse.swt.internal.ole.win32;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-public final class STGMEDIUM
-{
- public int tymed;
- public int unionField;
- public int pUnkForRelease;
-
- public static final int sizeof = 12;
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+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 PI/win32/org/eclipse/swt/internal/ole/win32/TYPEATTR.java b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/ole/win32/TYPEATTR.java
index e145806e66..4cd9f94ae0 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/ole/win32/TYPEATTR.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/ole/win32/TYPEATTR.java
@@ -1,49 +1,49 @@
-package org.eclipse.swt.internal.ole.win32;
-
-/*
+package org.eclipse.swt.internal.ole.win32;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-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;
-
- // public IDLDESC idldesctype
- public int idldescType_dwReserved;
- public short idldescType_wIDLFlags;
-
- public static final int sizeof = 74;
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+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;
+
+ // 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 PI/win32/org/eclipse/swt/internal/ole/win32/VARDESC1.java b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/ole/win32/VARDESC1.java
index ac9ca544ba..b262dd74df 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/ole/win32/VARDESC1.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/ole/win32/VARDESC1.java
@@ -1,25 +1,25 @@
-package org.eclipse.swt.internal.ole.win32;
-
-/*
+package org.eclipse.swt.internal.ole.win32;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-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;
- //PARAMDESC elemdescFunc.paramdesc
- public int elemdescVar_paramdesc_pparamdescex;
- public short elemdescVar_paramdesc_wParamFlags;
- public short wVarFlags;
- public int varkind;
-
- public static final int sizeof = 36;
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+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;
+ //PARAMDESC elemdescFunc.paramdesc
+ public int elemdescVar_paramdesc_pparamdescex;
+ public short elemdescVar_paramdesc_wParamFlags;
+ public short wVarFlags;
+ public int varkind;
+
+ public static final int sizeof = 36;
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/ole/win32/VARDESC2.java b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/ole/win32/VARDESC2.java
index 2772001750..7b7c36d687 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/ole/win32/VARDESC2.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/ole/win32/VARDESC2.java
@@ -1,25 +1,25 @@
-package org.eclipse.swt.internal.ole.win32;
-
-/*
+package org.eclipse.swt.internal.ole.win32;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-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;
- //IDLDESC elemdescFunc.idldesc
- public int elemdescFunc_idldesc_dwReserved;
- public short elemdescFunc_idldesc_wIDLFlags;
- public short wVarFlags;
- public int varkind;
-
- public static final int sizeof = 36;
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+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;
+ //IDLDESC elemdescFunc.idldesc
+ public int elemdescFunc_idldesc_dwReserved;
+ public short elemdescFunc_idldesc_wIDLFlags;
+ public short wVarFlags;
+ public int varkind;
+
+ public static final int sizeof = 36;
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/ACCEL.java b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/ACCEL.java
index 195f5e83c8..8a7aff3e6a 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/ACCEL.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/ACCEL.java
@@ -1,14 +1,14 @@
-package org.eclipse.swt.internal.win32;
-
-/*
+package org.eclipse.swt.internal.win32;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-public class ACCEL {
- public byte fVirt;
- public short key;
- public short cmd;
- public static final int sizeof = OS.IsWinCE ? 8 : 6;
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+public class ACCEL {
+ public byte fVirt;
+ public short key;
+ public short cmd;
+ public static final int sizeof = OS.IsWinCE ? 8 : 6;
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/BITMAP.java b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/BITMAP.java
index 6919a034fb..b0d2c9bff2 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/BITMAP.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/BITMAP.java
@@ -1,18 +1,18 @@
-package org.eclipse.swt.internal.win32;
-
-/*
+package org.eclipse.swt.internal.win32;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-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;
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+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 PI/win32/org/eclipse/swt/internal/win32/BROWSEINFO.java b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/BROWSEINFO.java
index a39607d54f..718b5665e7 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/BROWSEINFO.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/BROWSEINFO.java
@@ -1,19 +1,19 @@
-package org.eclipse.swt.internal.win32;
-
-/*
+package org.eclipse.swt.internal.win32;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-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;
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+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 PI/win32/org/eclipse/swt/internal/win32/CHOOSECOLOR.java b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/CHOOSECOLOR.java
index 8eebdca4e6..b7ea608292 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/CHOOSECOLOR.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/CHOOSECOLOR.java
@@ -1,20 +1,20 @@
-package org.eclipse.swt.internal.win32;
-
-/*
+package org.eclipse.swt.internal.win32;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-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;
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+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 PI/win32/org/eclipse/swt/internal/win32/CHOOSEFONT.java b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/CHOOSEFONT.java
index aa09292e1f..56df8abbe3 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/CHOOSEFONT.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/CHOOSEFONT.java
@@ -1,26 +1,26 @@
-package org.eclipse.swt.internal.win32;
-
-/*
+package org.eclipse.swt.internal.win32;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-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 int nSizeMin;
- public int nSizeMax;
- public static final int sizeof = 60;
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+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 int nSizeMin;
+ public int nSizeMax;
+ public static final int sizeof = 60;
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/COMPOSITIONFORM.java b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/COMPOSITIONFORM.java
index 1c595726eb..377773ccf2 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/COMPOSITIONFORM.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/COMPOSITIONFORM.java
@@ -1,16 +1,16 @@
-package org.eclipse.swt.internal.win32;
-
-/*
+package org.eclipse.swt.internal.win32;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-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;
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+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 PI/win32/org/eclipse/swt/internal/win32/CREATESTRUCT.java b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/CREATESTRUCT.java
index 42d4149ba0..5301abda80 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/CREATESTRUCT.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/CREATESTRUCT.java
@@ -1,23 +1,23 @@
-package org.eclipse.swt.internal.win32;
-
-/*
+package org.eclipse.swt.internal.win32;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-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;
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+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 PI/win32/org/eclipse/swt/internal/win32/DIBSECTION.java b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/DIBSECTION.java
index 1704e46e64..7c0f93475f 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/DIBSECTION.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/DIBSECTION.java
@@ -1,27 +1,27 @@
-package org.eclipse.swt.internal.win32;
-
-/*
+package org.eclipse.swt.internal.win32;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-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;
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+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 PI/win32/org/eclipse/swt/internal/win32/DLLVERSIONINFO.java b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/DLLVERSIONINFO.java
index 77895431be..954f91e7b2 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/DLLVERSIONINFO.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/DLLVERSIONINFO.java
@@ -1,16 +1,16 @@
-package org.eclipse.swt.internal.win32;
-
-/*
+package org.eclipse.swt.internal.win32;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-public class DLLVERSIONINFO {
- public int cbSize;
- public int dwMajorVersion;
- public int dwMinorVersion;
- public int dwBuildNumber;
- public int dwPlatformID;
- public static final int sizeof = 20;
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+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 PI/win32/org/eclipse/swt/internal/win32/DOCINFO.java b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/DOCINFO.java
index ebac71409e..ab57f3d890 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/DOCINFO.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/DOCINFO.java
@@ -1,16 +1,16 @@
-package org.eclipse.swt.internal.win32;
-
-/*
+package org.eclipse.swt.internal.win32;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-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;
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+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;
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/DRAWITEMSTRUCT.java b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/DRAWITEMSTRUCT.java
index 5d47abd636..11cc8335ee 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/DRAWITEMSTRUCT.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/DRAWITEMSTRUCT.java
@@ -1,21 +1,21 @@
-package org.eclipse.swt.internal.win32;
-
-/*
+package org.eclipse.swt.internal.win32;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-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;
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+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 PI/win32/org/eclipse/swt/internal/win32/DROPFILES.java b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/DROPFILES.java
index e1f400e35f..68e7126c04 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/DROPFILES.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/DROPFILES.java
@@ -1,22 +1,22 @@
-package org.eclipse.swt.internal.win32;
-
-/*
+package org.eclipse.swt.internal.win32;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-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;
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+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 PI/win32/org/eclipse/swt/internal/win32/FILETIME.java b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/FILETIME.java
index 8e68decf18..99ec58ddc9 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/FILETIME.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/FILETIME.java
@@ -1,14 +1,14 @@
-package org.eclipse.swt.internal.win32;
-
-/*
+package org.eclipse.swt.internal.win32;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-public class FILETIME {
- public int dwLowDateTime;
- public int dwHighDateTime;
- static final public int sizeof = 8;
-}
-
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+public class FILETIME {
+ public int dwLowDateTime;
+ public int dwHighDateTime;
+ static final public int sizeof = 8;
+}
+
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/GCP_RESULTS.java b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/GCP_RESULTS.java
index 1f544a8de6..f1f97cbe26 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/GCP_RESULTS.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/GCP_RESULTS.java
@@ -1,21 +1,21 @@
-package org.eclipse.swt.internal.win32;
-
-/*
+package org.eclipse.swt.internal.win32;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-public class GCP_RESULTS {
- public int lStructSize;
- public int lpOutString;
- public int lpOrder;
- public int lpDx;
- public int lpCaretPos;
- public int lpClass;
- public int lpGlyphs;
- public int nGlyphs;
- public int nMaxFit;
- public static final int sizeof = 36;
-}
-
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+public class GCP_RESULTS {
+ public int lStructSize;
+ public int lpOutString;
+ public int lpOrder;
+ public int lpDx;
+ public int lpCaretPos;
+ public int lpClass;
+ public int lpGlyphs;
+ public int nGlyphs;
+ public int nMaxFit;
+ public static final int sizeof = 36;
+}
+
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/GRADIENT_RECT.java b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/GRADIENT_RECT.java
index 28a490689e..cd60e6ac39 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/GRADIENT_RECT.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/GRADIENT_RECT.java
@@ -1,14 +1,14 @@
-package org.eclipse.swt.internal.win32;
-
-/*
+package org.eclipse.swt.internal.win32;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-public class GRADIENT_RECT {
- public int UpperLeft;
- public int LowerRight;
- public static final int sizeof = 8;
-}
-
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+public class GRADIENT_RECT {
+ public int UpperLeft;
+ public int LowerRight;
+ public static final int sizeof = 8;
+}
+
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/HDITEM.java b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/HDITEM.java
index dfaebf6d7f..7927c61b7e 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/HDITEM.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/HDITEM.java
@@ -1,20 +1,20 @@
-package org.eclipse.swt.internal.win32;
-
-/*
+package org.eclipse.swt.internal.win32;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-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;
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+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 PI/win32/org/eclipse/swt/internal/win32/HELPINFO.java b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/HELPINFO.java
index 73615fb37a..a45fda0872 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/HELPINFO.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/HELPINFO.java
@@ -1,19 +1,19 @@
-package org.eclipse.swt.internal.win32;
-
-/*
+package org.eclipse.swt.internal.win32;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-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;
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+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 PI/win32/org/eclipse/swt/internal/win32/ICONINFO.java b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/ICONINFO.java
index 78c0e34cda..571f202cc0 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/ICONINFO.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/ICONINFO.java
@@ -1,16 +1,16 @@
-package org.eclipse.swt.internal.win32;
-
-/*
+package org.eclipse.swt.internal.win32;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-public class ICONINFO {
- public boolean fIcon;
- public int xHotspot;
- public int yHotspot;
- public int hbmMask;
- public int hbmColor;
- public static final int sizeof = 20;
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+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 PI/win32/org/eclipse/swt/internal/win32/INITCOMMONCONTROLSEX.java b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/INITCOMMONCONTROLSEX.java
index b62707e1ce..af581f7fa9 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/INITCOMMONCONTROLSEX.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/INITCOMMONCONTROLSEX.java
@@ -1,13 +1,13 @@
-package org.eclipse.swt.internal.win32;
-
-/*
+package org.eclipse.swt.internal.win32;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-public class INITCOMMONCONTROLSEX {
- public int dwSize;
- public int dwICC;
- public static final int sizeof = 8;
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+public class INITCOMMONCONTROLSEX {
+ public int dwSize;
+ public int dwICC;
+ public static final int sizeof = 8;
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/LOGBRUSH.java b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/LOGBRUSH.java
index 08ea817968..7826238c03 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/LOGBRUSH.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/LOGBRUSH.java
@@ -1,14 +1,14 @@
-package org.eclipse.swt.internal.win32;
-
-/*
+package org.eclipse.swt.internal.win32;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-public class LOGBRUSH {
- public int lbStyle;
- public int lbColor;
- public int lbHatch;
- public static final int sizeof = 12;
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+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 PI/win32/org/eclipse/swt/internal/win32/LOGFONT.java b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/LOGFONT.java
index d398d1db47..fb8de6f93d 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/LOGFONT.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/LOGFONT.java
@@ -1,34 +1,34 @@
-package org.eclipse.swt.internal.win32;
-
-/*
+package org.eclipse.swt.internal.win32;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-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 char
- 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 = OS.IsUnicode ? 92 : 60;
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+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 char
+ 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 = OS.IsUnicode ? 92 : 60;
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/LOGPEN.java b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/LOGPEN.java
index a41eb4c89f..a3bcab4db6 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/LOGPEN.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/LOGPEN.java
@@ -1,16 +1,16 @@
-package org.eclipse.swt.internal.win32;
-
-/*
+package org.eclipse.swt.internal.win32;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-public class LOGPEN {
- public int lopnStyle;
-// POINT lopnWidth;
- public int x;
- public int y;
- public int lopnColor;
- public static final int sizeof = 16;
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+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 PI/win32/org/eclipse/swt/internal/win32/LRESULT.java b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/LRESULT.java
index e38f07aec6..7371d7dbe0 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/LRESULT.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/LRESULT.java
@@ -1,16 +1,16 @@
-package org.eclipse.swt.internal.win32;
-
-/*
+package org.eclipse.swt.internal.win32;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-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;
-}
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+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 PI/win32/org/eclipse/swt/internal/win32/LVCOLUMN.java b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/LVCOLUMN.java
index f2f2620b9b..83f0236982 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/LVCOLUMN.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/LVCOLUMN.java
@@ -1,19 +1,19 @@
-package org.eclipse.swt.internal.win32;
-
-/*
+package org.eclipse.swt.internal.win32;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-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;
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+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 PI/win32/org/eclipse/swt/internal/win32/LVHITTESTINFO.java b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/LVHITTESTINFO.java
index 6ea0114833..b841bdf5dc 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/LVHITTESTINFO.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/LVHITTESTINFO.java
@@ -1,17 +1,17 @@
-package org.eclipse.swt.internal.win32;
-
-/*
+package org.eclipse.swt.internal.win32;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-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;
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+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 PI/win32/org/eclipse/swt/internal/win32/LVITEM.java b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/LVITEM.java
index 19d0f7b690..619a1eb8f1 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/LVITEM.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/LVITEM.java
@@ -1,21 +1,21 @@
-package org.eclipse.swt.internal.win32;
-
-/*
+package org.eclipse.swt.internal.win32;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-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;
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+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 PI/win32/org/eclipse/swt/internal/win32/MEASUREITEMSTRUCT.java b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/MEASUREITEMSTRUCT.java
index 03cf3522de..85f6c4ccb9 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/MEASUREITEMSTRUCT.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/MEASUREITEMSTRUCT.java
@@ -1,17 +1,17 @@
-package org.eclipse.swt.internal.win32;
-
-/*
+package org.eclipse.swt.internal.win32;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-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;
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+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 PI/win32/org/eclipse/swt/internal/win32/MENUINFO.java b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/MENUINFO.java
index 14508e3565..5ee33ac085 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/MENUINFO.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/MENUINFO.java
@@ -1,18 +1,18 @@
-package org.eclipse.swt.internal.win32;
-
-/*
+package org.eclipse.swt.internal.win32;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-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;
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+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 PI/win32/org/eclipse/swt/internal/win32/MENUITEMINFO.java b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/MENUITEMINFO.java
index 1e509fff34..0fec8c66ee 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/MENUITEMINFO.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/MENUITEMINFO.java
@@ -1,34 +1,34 @@
-package org.eclipse.swt.internal.win32;
-
-/*
+package org.eclipse.swt.internal.win32;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-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 {
- sizeof = (OS.WIN32_MAJOR << 16 | OS.WIN32_MINOR) < (4 << 16 | 10) ? 44 : 48;
- }
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+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 {
+ sizeof = (OS.WIN32_MAJOR << 16 | OS.WIN32_MINOR) < (4 << 16 | 10) ? 44 : 48;
+ }
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/MSG.java b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/MSG.java
index 6a047fdc01..38bc39d3de 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/MSG.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/MSG.java
@@ -1,18 +1,18 @@
-package org.eclipse.swt.internal.win32;
-
-/*
+package org.eclipse.swt.internal.win32;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-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;
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+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 PI/win32/org/eclipse/swt/internal/win32/NMHDR.java b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/NMHDR.java
index 487225e3da..fb2bbe57a9 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/NMHDR.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/NMHDR.java
@@ -1,14 +1,14 @@
-package org.eclipse.swt.internal.win32;
-
-/*
+package org.eclipse.swt.internal.win32;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-public class NMHDR {
- public int hwndFrom;
- public int idFrom;
- public int code;
- public static final int sizeof = 12;
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+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 PI/win32/org/eclipse/swt/internal/win32/NMHEADER.java b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/NMHEADER.java
index 2915435526..6e14eb6978 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/NMHEADER.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/NMHEADER.java
@@ -1,14 +1,14 @@
-package org.eclipse.swt.internal.win32;
-
-/*
+package org.eclipse.swt.internal.win32;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-public class NMHEADER extends NMHDR {
- public int iItem;
- public int iButton;
- public int pitem;
- public static int sizeof = 24;
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+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 PI/win32/org/eclipse/swt/internal/win32/NMLISTVIEW.java b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/NMLISTVIEW.java
index 24a5ae03a9..fc66a93334 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/NMLISTVIEW.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/NMLISTVIEW.java
@@ -1,19 +1,19 @@
-package org.eclipse.swt.internal.win32;
-
-/*
+package org.eclipse.swt.internal.win32;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-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;
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+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 PI/win32/org/eclipse/swt/internal/win32/NMTOOLBAR.java b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/NMTOOLBAR.java
index e47c59cdf2..20f2ef9ebf 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/NMTOOLBAR.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/NMTOOLBAR.java
@@ -1,24 +1,24 @@
-package org.eclipse.swt.internal.win32;
-
-/*
+package org.eclipse.swt.internal.win32;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-public class NMTOOLBAR extends NMHDR {
- public int iItem;
-// TBBUTTON tbButton;
- public int iBitmap;
- public int idCommand;
- public byte fsState;
- public byte fsStyle;
- public int dwData;
- public int iString;
- public int cchText;
- public int pszText;
-// RECT rcButton;
- public int left, top, right, bottom;
- /* Note in WinCE. The field rcButton is not defined. */
- public static final int sizeof = OS.IsWinCE ? 44 : 60;
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+public class NMTOOLBAR extends NMHDR {
+ public int iItem;
+// TBBUTTON tbButton;
+ public int iBitmap;
+ public int idCommand;
+ public byte fsState;
+ public byte fsStyle;
+ public int dwData;
+ public int iString;
+ public int cchText;
+ public int pszText;
+// RECT rcButton;
+ public int left, top, right, bottom;
+ /* Note in WinCE. The field rcButton is not defined. */
+ public static final int sizeof = OS.IsWinCE ? 44 : 60;
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/NMTTDISPINFO.java b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/NMTTDISPINFO.java
index 7c0f4c1b24..9fdedd25e5 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/NMTTDISPINFO.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/NMTTDISPINFO.java
@@ -1,19 +1,19 @@
-package org.eclipse.swt.internal.win32;
-
-/*
+package org.eclipse.swt.internal.win32;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-public class NMTTDISPINFO extends NMHDR {
- public int lpszText;
-// char szText[80];
-// public char [] szText = new char [80];
- public int hinst;
- public int uFlags;
- public int lParam;
- public static final int sizeofW = 188;
- public static final int sizeofA = 108;
- public static final int sizeof = OS.IsUnicode ? sizeofW : sizeofA;
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+public class NMTTDISPINFO extends NMHDR {
+ public int lpszText;
+// char szText[80];
+// public char [] szText = new char [80];
+ public int hinst;
+ public int uFlags;
+ public int lParam;
+ public static final int sizeofW = 188;
+ public static final int sizeofA = 108;
+ public static final int sizeof = OS.IsUnicode ? sizeofW : sizeofA;
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/NONCLIENTMETRICS.java b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/NONCLIENTMETRICS.java
index 4aad6adaa6..ed4499985b 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/NONCLIENTMETRICS.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/NONCLIENTMETRICS.java
@@ -1,33 +1,33 @@
-package org.eclipse.swt.internal.win32;
-
-/*
+package org.eclipse.swt.internal.win32;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-public class NONCLIENTMETRICS {
- public int cbSize;
- public int iBorderWidth;
- public int iScrollWidth;
- public int iScrollHeight;
- public int iCaptionWidth;
- public int iCaptionHeight;
-// LOGFONT lfCaptionFont;
- public LOGFONT lfCaptionFont = new LOGFONT ();
- public int iSmCaptionWidth;
- public int iSmCaptionHeight;
-// LOGFONT lfSmCaptionFont;
- public LOGFONT lfSmCaptionFont = new LOGFONT ();
- public int iMenuWidth;
- public int iMenuHeight;
-// LOGFONT lfMenuFont;
- public LOGFONT lfMenuFont = new LOGFONT ();
-// LOGFONT lfStatusFont;
- public LOGFONT lfStatusFont = new LOGFONT ();
-// LOGFONT lfMessageFont;
- public LOGFONT lfMessageFont = new LOGFONT ();
- public static final int sizeof = OS.IsUnicode ? 500 : 340;
-}
-
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+public class NONCLIENTMETRICS {
+ public int cbSize;
+ public int iBorderWidth;
+ public int iScrollWidth;
+ public int iScrollHeight;
+ public int iCaptionWidth;
+ public int iCaptionHeight;
+// LOGFONT lfCaptionFont;
+ public LOGFONT lfCaptionFont = new LOGFONT ();
+ public int iSmCaptionWidth;
+ public int iSmCaptionHeight;
+// LOGFONT lfSmCaptionFont;
+ public LOGFONT lfSmCaptionFont = new LOGFONT ();
+ public int iMenuWidth;
+ public int iMenuHeight;
+// LOGFONT lfMenuFont;
+ public LOGFONT lfMenuFont = new LOGFONT ();
+// LOGFONT lfStatusFont;
+ public LOGFONT lfStatusFont = new LOGFONT ();
+// LOGFONT lfMessageFont;
+ public LOGFONT lfMessageFont = new LOGFONT ();
+ public static final int sizeof = OS.IsUnicode ? 500 : 340;
+}
+
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/OPENFILENAME.java b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/OPENFILENAME.java
index cd42d487e3..adf4c7c23b 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/OPENFILENAME.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/OPENFILENAME.java
@@ -1,31 +1,31 @@
-package org.eclipse.swt.internal.win32;
-
-/*
+package org.eclipse.swt.internal.win32;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-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;
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+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 PI/win32/org/eclipse/swt/internal/win32/OS.java b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/OS.java
index 254d10f666..d442a81cf6 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/OS.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/OS.java
@@ -1,2431 +1,2431 @@
-package org.eclipse.swt.internal.win32;
-
-/*
+package org.eclipse.swt.internal.win32;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-import org.eclipse.swt.internal.*;
-
-public class OS {
-
- /*
- * SWT Windows flags.
- */
- public static final boolean IsWin32s;
- public static final boolean IsWin95;
- public static final boolean IsWinNT;
- public static final boolean IsWinCE;
- public static final boolean IsPPC;
- public static final boolean IsHPC;
- public static final boolean IsSP;
- public static final boolean IsDBLocale;
- public static final boolean IsUnicode;
- public static final int WIN32_MAJOR, WIN32_MINOR;
-
- /*
- * Flags for Window API GetVersionEx
- */
- public static final int VER_PLATFORM_WIN32s = 0;
- public static final int VER_PLATFORM_WIN32_WINDOWS = 1;
- public static final int VER_PLATFORM_WIN32_NT = 2;
- public static final int VER_PLATFORM_WIN32_CE = 3;
-
- /*
- * Initialize the Windows flags
- */
- static {
-
- /* Load the SWT library */
- Library.loadLibrary ("swt");
-
- /*
- * Try the UNICODE version of GetVersionEx first
- * and then the ANSI version. The UNICODE version
- * is present on all versions of Windows but is not
- * implemented on Win95/98/ME.
- *
- * NOTE: The value of OSVERSIONINFO.sizeof cannot
- * be static final because it relies on the Windows
- * platform version to be initialized and IsUnicode
- * has not been calculated. It must be initialized
- * here, after the platform is determined in order
- * for the value to be correct.
- */
- OSVERSIONINFO info = new OSVERSIONINFO ();
-
- // TEMPORARY CODE
- String MBCS = System.getProperty ("MBCS");
- if (MBCS != null) {
- info.dwOSVersionInfoSize = OSVERSIONINFO.sizeofA;
- OS.GetVersionExA (info);
- } else {
- info.dwOSVersionInfoSize = OSVERSIONINFO.sizeofW;
- if (!OS.GetVersionExW (info)) {
- info.dwOSVersionInfoSize = OSVERSIONINFO.sizeofA;
- OS.GetVersionExA (info);
- }
- }
- OSVERSIONINFO.sizeof = info.dwOSVersionInfoSize;
-
- IsWin32s = info.dwPlatformId == VER_PLATFORM_WIN32s;
- IsWin95 = info.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS;
- IsWinNT = info.dwPlatformId == VER_PLATFORM_WIN32_NT;
- IsWinCE = info.dwPlatformId == VER_PLATFORM_WIN32_CE;
- IsSP = IsSP();
- IsPPC = IsPPC();
- IsHPC = IsWinCE && !IsPPC && !IsSP;
- WIN32_MAJOR = info.dwMajorVersion;
- WIN32_MINOR = info.dwMinorVersion;
-
- // TEMPORARY CODE
- if (MBCS != null) {
- IsUnicode = false;
- System.out.println ("*** SWT - Warning: Unicode disabled");
- } else {
- IsUnicode = !IsWin32s && !IsWin95;
- }
-
- /* Get the DBCS flag */
- int index = 0;
- while (index <= 0xFF) {
- if (OS.IsDBCSLeadByte ((byte) index)) break;
- index++;
- }
- IsDBLocale = index <= 0xFF;
- }
-
- /* Flag used on WinCE */
- static final int SYS_COLOR_INDEX_FLAG = OS.IsWinCE ? 0x40000000 : 0x0;
-
- /*
- * 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.
- */
-
- /* Constants */
- public static final int BFFM_INITIALIZED = 0x1;
- public static final int BFFM_SETSELECTION = IsUnicode ? 0x467 : 0x466;
- public static final int BFFM_VALIDATEFAILED = IsUnicode ? 0x4 : 0x3;
- public static final int BFFM_VALIDATEFAILEDW = 0x4;
- public static final int BFFM_VALIDATEFAILEDA = 0x3;
- public static final int BF_BOTTOM = 0x8;
- public static final int BF_RIGHT = 0x4;
- public static final int BIF_EDITBOX = 0x10;
- public static final int BIF_NEWDIALOGSTYLE = 0x40;
- public static final int BIF_RETURNONLYFSDIRS = 0x1;
- public static final int BIF_VALIDATE = 0x20;
- public static final int BITSPIXEL = 0xc;
- public static final int BI_BITFIELDS = 3;
- public static final int BI_RGB = 0;
- 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_SETCHECK = 0xf1;
- public static final int BM_SETIMAGE = 0xf7;
- public static final int BM_SETSTYLE = 0xf4;
- public static final int BN_CLICKED = 0x0;
- public static final int BN_DOUBLECLICKED = 0x5;
- public static final int BST_CHECKED = 0x1;
- public static final int BST_UNCHECKED = 0x0;
- public static final int BS_BITMAP = 0x80;
- public static final int BS_CENTER = 0x300;
- public static final int BS_CHECKBOX = 0x2;
- public static final int BS_DEFPUSHBUTTON = 0x1;
- public static final int BS_FLAT = 0x8000;
- public static final int BS_GROUPBOX = 0x7;
- public static final int BS_ICON = 0x40;
- public static final int BS_LEFT = 0x100;
- public static final int BS_NOTIFY = 0x4000;
- public static final int BS_OWNERDRAW = 0xb;
- 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_RIGHT = 0x200;
- public static final int BS_SOLID = 0x0;
- public static final int BTNS_AUTOSIZE = 0x10;
- public static final int BTNS_BUTTON = 0x0;
- public static final int BTNS_CHECK = 0x2;
- public static final int BTNS_CHECKGROUP = 0x6;
- public static final int BTNS_DROPDOWN = 0x8;
- public static final int BTNS_GROUP = 0x4;
- public static final int BTNS_SEP = 0x1;
- public static final int CBN_EDITCHANGE = 0x5;
- public static final int CBN_KILLFOCUS = 0x4;
- public static final int CBN_SELCHANGE = 0x1;
- public static final int CBN_SETFOCUS = 0x3;
- public static final int CBS_AUTOHSCROLL = 0x40;
- public static final int CBS_DROPDOWN = 0x2;
- public static final int CBS_DROPDOWNLIST = 0x3;
- public static final int CBS_NOINTEGRALHEIGHT = 0x400;
- public static final int CBS_SIMPLE = 0x1;
- public static final int CB_ADDSTRING = 0x143;
- public static final int CB_DELETESTRING = 0x144;
- public static final int CB_ERR = 0xffffffff;
- public static final int CB_ERRSPACE = 0xfffffffe;
- 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_GETEDITSEL = 0x140;
- 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_INSERTSTRING = 0x14a;
- public static final int CB_LIMITTEXT = 0x141;
- 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_SETEDITSEL = 0x142;
- public static final int CB_SHOWDROPDOWN = 0x14f;
- public static final int CCM_FIRST = 0x2000;
- public static final int CCM_SETBKCOLOR = 0x2001;
- public static final int CCS_NODIVIDER = 0x40;
- public static final int CCS_NORESIZE = 0x4;
- public static final int CC_ANYCOLOR = 0x100;
- public static final int CC_ENABLEHOOK = 0x10;
- public static final int CC_RGBINIT = 0x1;
- public static final int CDDS_PREPAINT = 0x00000001;
- public static final int CDDS_ITEM = 0x00010000;
- public static final int CDDS_ITEMPREPAINT = CDDS_ITEM | CDDS_PREPAINT;
- public static final int CDDS_SUBITEM = 0x00020000;
- 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_NOTIFYSUBITEMDRAW = 0x00000020;
- public static final int CFE_AUTOCOLOR = 0x40000000;
- public static final int CFE_ITALIC = 0x2;
- public static final int CFE_STRIKEOUT = 0x8;
- public static final int CFE_UNDERLINE = 0x4;
- public static final int CFM_BOLD = 0x1;
- public static final int CFM_CHARSET = 0x8000000;
- public static final int CFM_COLOR = 0x40000000;
- public static final int CFM_FACE = 0x20000000;
- public static final int CFM_ITALIC = 0x2;
- public static final int CFM_SIZE = 0x80000000;
- public static final int CFM_STRIKEOUT = 0x8;
- public static final int CFM_UNDERLINE = 0x4;
- public static final int CFM_WEIGHT = 0x400000;
- public static final int CFS_POINT = 0x2;
- public static final int CF_EFFECTS = 0x100;
- public static final int CF_INITTOLOGFONTSTRUCT = 0x40;
- public static final int CF_SCREENFONTS = 0x1;
- public static final int CF_TEXT = 0x1;
- public static final int CF_UNICODETEXT = 13;
- public static final int CF_USESTYLE = 0x80;
- public static final int CLR_DEFAULT = 0xff000000;
- public static final int CLR_INVALID = 0xffffffff;
- public static final int COLORONCOLOR = 0x3;
- public static final int COLOR_3DDKSHADOW = 0x15 | SYS_COLOR_INDEX_FLAG;
- public static final int COLOR_3DFACE = 0xf | SYS_COLOR_INDEX_FLAG;
- public static final int COLOR_3DHIGHLIGHT = 0x14 | SYS_COLOR_INDEX_FLAG;
- public static final int COLOR_3DHILIGHT = 0x14 | SYS_COLOR_INDEX_FLAG;
- public static final int COLOR_3DLIGHT = 0x16 | SYS_COLOR_INDEX_FLAG;
- public static final int COLOR_3DSHADOW = 0x10 | SYS_COLOR_INDEX_FLAG;
- public static final int COLOR_ACTIVECAPTION = 0x2 | SYS_COLOR_INDEX_FLAG;
- public static final int COLOR_BTNFACE = 0xf | SYS_COLOR_INDEX_FLAG;
- public static final int COLOR_BTNHIGHLIGHT = 0x14 | SYS_COLOR_INDEX_FLAG;
- public static final int COLOR_BTNSHADOW = 0x10 | SYS_COLOR_INDEX_FLAG;
- public static final int COLOR_BTNTEXT = 0x12 | SYS_COLOR_INDEX_FLAG;
- public static final int COLOR_CAPTIONTEXT = 0x9 | SYS_COLOR_INDEX_FLAG;
- public static final int COLOR_GRADIENTACTIVECAPTION = 0x1b | SYS_COLOR_INDEX_FLAG;
- public static final int COLOR_GRADIENTINACTIVECAPTION = 0x1c | SYS_COLOR_INDEX_FLAG;
- public static final int COLOR_HIGHLIGHT = 0xd | SYS_COLOR_INDEX_FLAG;
- public static final int COLOR_HIGHLIGHTTEXT = 0xe | SYS_COLOR_INDEX_FLAG;
- public static final int COLOR_INACTIVECAPTION = 0x3 | SYS_COLOR_INDEX_FLAG;
- public static final int COLOR_INACTIVECAPTIONTEXT = 0x13 | SYS_COLOR_INDEX_FLAG;
- public static final int COLOR_INFOBK = 0x18 | SYS_COLOR_INDEX_FLAG;
- public static final int COLOR_INFOTEXT = 0x17 | SYS_COLOR_INDEX_FLAG;
- public static final int COLOR_MENU = 0x4 | SYS_COLOR_INDEX_FLAG;
- public static final int COLOR_MENUTEXT = 0x7 | SYS_COLOR_INDEX_FLAG;
- public static final int COLOR_SCROLLBAR = 0x0 | SYS_COLOR_INDEX_FLAG;
- public static final int COLOR_WINDOW = 0x5 | SYS_COLOR_INDEX_FLAG;
- public static final int COLOR_WINDOWFRAME = 0x6 | SYS_COLOR_INDEX_FLAG;
- public static final int COLOR_WINDOWTEXT = 0x8 | SYS_COLOR_INDEX_FLAG;
- public static final int COMPLEXREGION = 0x3;
- public static final int CP_ACP = 0x0;
- public static final int CP_INSTALLED = 0x1;
- public static final int CS_BYTEALIGNWINDOW = 0x2000;
- public static final int CS_DBLCLKS = 0x8;
- public static final int CS_HREDRAW = 0x2;
- public static final int CS_VREDRAW = 0x1;
- 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 DEFAULT_CHARSET = 0x1;
- public static final int DEFAULT_GUI_FONT = 0x11;
- public static final int DFCS_BUTTONCHECK = 0x0;
- public static final int DFCS_CHECKED = 0x400;
- public static final int DFCS_FLAT = 0x4000;
- public static final int DFCS_INACTIVE = 0x100;
- public static final int DFCS_PUSHED = 0x200;
- 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_SCROLLUP = 0x0;
- public static final int DFC_BUTTON = 0x4;
- public static final int DFC_SCROLL = 0x3;
- public static final int DIB_RGB_COLORS = 0x0;
- public static final int DISP_E_EXCEPTION = 0x80020009;
- public static final int DI_NORMAL = 0x3;
- public static final int DLGC_BUTTON = 0x2000;
- public static final int DLGC_HASSETSEL = 0x8;
- public static final int DLGC_STATIC = 0x100;
- public static final int DLGC_WANTALLKEYS = 0x4;
- public static final int DLGC_WANTARROWS = 0x1;
- public static final int DLGC_WANTTAB = 0x2;
- public static final int DM_SETDEFID = OS.WM_USER + 1;
- public static final int DSS_DISABLED = 0x20;
- public static final int DSTINVERT = 0x550009;
- public static final int DST_BITMAP = 0x4;
- public static final int DST_ICON = 0x3;
- public static final int DT_CALCRECT = 0x400;
- public static final int DT_EDITCONTROL = 0x2000;
- public static final int DT_EXPANDTABS = 0x40;
- public static final int DT_LEFT = 0x0;
- public static final int DT_NOPREFIX = 0x800;
- public static final int DT_SINGLELINE = 0x20;
- public static final int DT_WORDBREAK = 0x10;
- public static final int ECOOP_AND = 0x3;
- public static final int ECOOP_OR = 0x2;
- public static final int ECO_AUTOHSCROLL = 0x80;
- public static final int EDGE_ETCHED = 0x6;
- public static final int EDGE_SUNKEN = 0xa;
- public static final int EM_CANUNDO = 0xc6;
- public static final int EM_CHARFROMPOS = 0xd7;
- public static final int EM_DISPLAYBAND = 0x433;
- public static final int EM_GETFIRSTVISIBLELINE = 0xce;
- 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_GETPASSWORDCHAR = 0xd2;
- public static final int EM_GETSCROLLPOS = 0x4dd;
- public static final int EM_GETSEL = 0xb0;
- 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_POSFROMCHAR = 0xd6;
- public static final int EM_REPLACESEL = 0xc2;
- public static final int EM_SCROLLCARET = 0xb7;
- public static final int EM_SETBKGNDCOLOR = 0x443;
- public static final int EM_SETLIMITTEXT = 0xc5;
- public static final int EM_SETOPTIONS = 0x44d;
- public static final int EM_SETPARAFORMAT = 0x447;
- public static final int EM_SETPASSWORDCHAR = 0xcc;
- public static final int EM_SETREADONLY = 0xcf;
- public static final int EM_SETSEL = 0xb1;
- public static final int EM_SETTABSTOPS = 0xcb;
- public static final int EN_CHANGE = 0x300;
- public static final int ERROR_NO_MORE_ITEMS = 0x103;
- public static final int ESB_DISABLE_BOTH = 0x3;
- public static final int ESB_ENABLE_BOTH = 0x0;
- public static final int ES_AUTOHSCROLL = 0x80;
- public static final int ES_CENTER = 0x1;
- public static final int ES_MULTILINE = 0x4;
- public static final int ES_NOHIDESEL = 0x100;
- public static final int ES_READONLY = 0x800;
- public static final int ES_RIGHT = 0x2;
- public static final int FALT = 0x10;
- public static final int FCONTROL = 0x8;
- public static final int FNERR_INVALIDFILENAME = 0x3002;
- public static final int FSHIFT = 0x4;
- public static final int FVIRTKEY = 0x1;
- public static final int GCS_COMPSTR = 0x8;
- public static final int GCS_RESULTSTR = 0x800;
- public static final int GMDI_USEDISABLED = 0x1;
- public static final int GMEM_FIXED = 0x0;
- public static final int GMEM_ZEROINIT = 0x40;
- public static final int GN_CONTEXTMENU = 1000;
- public static final int GPTR = 0x40;
- public static final int GRADIENT_FILL_RECT_H = 0x0;
- public static final int GRADIENT_FILL_RECT_V = 0x1;
- public static final int GTL_NUMBYTES = 0x10;
- public static final int GTL_NUMCHARS = 0x8;
- public static final int GTL_PRECISE = 0x2;
- public static final int GT_DEFAULT = 0x0;
- public static final int GWL_EXSTYLE = 0xffffffec;
- public static final int GWL_ID = -12;
- 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 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 HBMMENU_CALLBACK = 0xffffffff;
- public static final int HDI_WIDTH = 0x1;
- public static final int HDM_FIRST = 0x1200;
- public static final int HDM_GETBITMAPMARGIN = HDM_FIRST + 21;
- public static final int HDM_GETITEMCOUNT = 0x1200;
- public static final int HDN_BEGINTRACK = IsUnicode ? 0xfffffeba : 0xfffffece;
- public static final int HDN_BEGINTRACKW = 0xfffffeba;
- public static final int HDN_BEGINTRACKA = 0xfffffece;
- public static final int HDN_DIVIDERDBLCLICKA = OS.HDN_FIRST - 5;
- public static final int HDN_DIVIDERDBLCLICKW = OS.HDN_FIRST - 25;
- public static final int HDN_DIVIDERDBLCLICK = IsUnicode ? HDN_DIVIDERDBLCLICKW : HDN_DIVIDERDBLCLICKA;
- public static final int HDN_FIRST = 0xfffffed4;
- public static final int HDN_ITEMCHANGED = IsUnicode ? 0xfffffebf : 0xfffffed3;
- public static final int HDN_ITEMCHANGEDW = 0xfffffebf;
- public static final int HDN_ITEMCHANGEDA = 0xfffffed3;
- public static final int HEAP_ZERO_MEMORY = 0x8;
- public static final int HELPINFO_MENUITEM = 0x2;
- 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 HORZRES = 0x8;
- public static final int HTBORDER = 0x12;
- public static final int HTCLIENT = 0x1;
- public static final int HTERROR = -2;
- public static final int HTHSCROLL = 0x6;
- public static final int HTMENU = 0x5;
- public static final int HTNOWHERE = 0x0;
- public static final int HTTRANSPARENT = 0xffffffff;
- public static final int HTVSCROLL = 0x7;
- public static final int HWND_BOTTOM = 0x1;
- public static final int HWND_TOP = 0x0;
- public static final int HWND_TOPMOST = 0xffffffff;
- public static final int HWND_NOTOPMOST = -2;
- public static final int ICC_COOL_CLASSES = 0x400;
- public static final int ICM_NOTOPEN = 0x0;
- public static final int ICON_BIG = 0x1;
- public static final int ICON_SMALL = 0x0;
- public static final int I_IMAGENONE = -2;
- public static final int IDABORT = 0x3;
- public static final int IDB_STD_SMALL_COLOR = 0x0;
- public static final int IDC_APPSTARTING = 0x7f8a;
- public static final int IDC_ARROW = 0x7f00;
- public static final int IDC_CROSS = 0x7f03;
- 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_NO = 0x7f88;
- 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_UPARROW = 0x7f04;
- public static final int IDC_WAIT = 0x7f02;
- public static final int IDI_WINLOGO = 0x7f05;
- 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_MASK = 0x1;
- public static final int ILD_NORMAL = 0x0;
- 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 IME_CMODE_FULLSHAPE = 0x8;
- public static final int IME_CMODE_KATAKANA = 0x2;
- public static final int IME_CMODE_NATIVE = 0x1;
- public static final int IME_CMODE_ROMAN = 0x10;
- public static final int INFINITE = 0xffffffff;
- public static final int KEY_ENUMERATE_SUB_KEYS = 0x8;
- public static final int KEY_NOTIFY = 0x10;
- public static final int KEY_QUERY_VALUE = 0x1;
- public static final int KEY_READ = 0x20019;
- public static final int LBN_DBLCLK = 0x2;
- public static final int LBN_SELCHANGE = 0x1;
- public static final int LBS_EXTENDEDSEL = 0x800;
- public static final int LBS_MULTIPLESEL = 0x8;
- public static final int LBS_NOINTEGRALHEIGHT = 0x100;
- public static final int LBS_NOTIFY = 0x1;
- public static final int LB_ADDSTRING = 0x180;
- public static final int LB_DELETESTRING = 0x182;
- public static final int LB_ERR = 0xffffffff;
- public static final int LB_ERRSPACE = 0xfffffffe;
- public static final int LB_FINDSTRINGEXACT = 0x1a2;
- 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_GETITEMHEIGHT = 0x1a1;
- public static final int LB_GETITEMRECT = 0x198;
- 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_RESETCONTENT = 0x184;
- public static final int LB_SELITEMRANGE = 0x19b;
- public static final int LB_SELITEMRANGEEX = 0x183;
- public static final int LB_SETCARETINDEX = 0x19e;
- public static final int LB_SETCURSEL = 0x186;
- public static final int LB_SETHORIZONTALEXTENT = 0x194;
- public static final int LB_SETSEL = 0x185;
- public static final int LB_SETTOPINDEX = 0x197;
- public static final int LGRPID_ARABIC = 0xd;
- public static final int LGRPID_HEBREW = 0xc;
- public static final int LGRPID_INSTALLED = 1;
- public static final int LCID_SUPPORTED = 0x2;
- public static final int LOCALE_IDEFAULTANSICODEPAGE = 0x1004;
- public static final int LOCALE_SISO3166CTRYNAME = 0x5a;
- public static final int LOCALE_SISO639LANGNAME = 0x59;
- public static final int LOGPIXELSX = 0x58;
- public static final int LOGPIXELSY = 0x5a;
- public static final int LPSTR_TEXTCALLBACK = 0xffffffff;
- public static final int LR_DEFAULTCOLOR = 0x0;
- public static final int LVCFMT_CENTER = 0x2;
- public static final int LVCFMT_IMAGE = 0x800;
- public static final int LVCFMT_LEFT = 0x0;
- public static final int LVCFMT_RIGHT = 0x1;
- public static final int LVCF_FMT = 0x1;
- public static final int LVCF_IMAGE = 0x10;
- public static final int LVCF_TEXT = 0x4;
- public static final int LVCF_WIDTH = 0x2;
- 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 LVIF_IMAGE = 0x2;
- public static final int LVIF_INDENT = 0x10;
- 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 LVIS_DROPHILITED = 0x8;
- public static final int LVIS_FOCUSED = 0x1;
- public static final int LVIS_SELECTED = 0x2;
- public static final int LVIS_STATEIMAGEMASK = 0xf000;
- public static final int LVM_APPROXIMATEVIEWRECT = 0x1040;
- 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_ENSUREVISIBLE = 0x1013;
- public static final int LVM_FIRST = 0x1000;
- public static final int LVM_GETBKCOLOR = 0x1000;
- public static final int LVM_GETCOLUMN = IsUnicode ? 0x105f : 0x1019;
- public static final int LVM_GETCOLUMNWIDTH = 0x101d;
- public static final int LVM_GETCOUNTPERPAGE = 0x1028;
- public static final int LVM_GETEXTENDEDLISTVIEWSTYLE = 0x1037;
- public static final int LVM_GETHEADER = 0x101f;
- public static final int LVM_GETIMAGELIST = 0x1002;
- public static final int LVM_GETITEM = IsUnicode ? 0x104b : 0x1005;
- public static final int LVM_GETITEMW = 0x104b;
- public static final int LVM_GETITEMA = 0x1005;
- public static final int LVM_GETITEMCOUNT = 0x1004;
- public static final int LVM_GETITEMRECT = 0x100e;
- public static final int LVM_GETITEMSTATE = 0x102c;
- public static final int LVM_GETNEXTITEM = 0x100c;
- public static final int LVM_GETSELECTEDCOUNT = 0x1032;
- public static final int LVM_GETSTRINGWIDTH = IsUnicode ? 0x1057 : 0x1011;
- public static final int LVM_GETSUBITEMRECT = 0x1038;
- public static final int LVM_GETTEXTCOLOR = 0x1023;
- public static final int LVM_GETTOPINDEX = 0x1027;
- public static final int LVM_HITTEST = 0x1012;
- public static final int LVM_INSERTCOLUMN = IsUnicode ? 0x1061 : 0x101b;
- public static final int LVM_INSERTITEM = IsUnicode ? 0x104d : 0x1007;
- public static final int LVM_SCROLL = 0x1014;
- public static final int LVM_SETBKCOLOR = 0x1001;
- public static final int LVM_SETCOLUMN = IsUnicode ? 0x1060 : 0x101a;
- public static final int LVM_SETCOLUMNWIDTH = 0x101e;
- public static final int LVM_SETEXTENDEDLISTVIEWSTYLE = 0x1036;
- public static final int LVM_SETIMAGELIST = 0x1003;
- public static final int LVM_SETITEM = IsUnicode ? 0x104c : 0x1006;
- public static final int LVM_SETITEMSTATE = 0x102b;
- public static final int LVM_SETTEXTBKCOLOR = 0x1026;
- public static final int LVM_SETTEXTCOLOR = 0x1024;
- public static final int LVNI_FOCUSED = 0x1;
- public static final int LVNI_SELECTED = 0x2;
- public static final int LVN_BEGINDRAG = 0xffffff93;
- public static final int LVN_BEGINRDRAG = 0xffffff91;
- public static final int LVN_COLUMNCLICK = 0xffffff94;
- public static final int LVN_FIRST = 0xffffff9c;
- public static final int LVN_ITEMACTIVATE = 0xffffff8e;
- public static final int LVN_ITEMCHANGED = 0xffffff9b;
- public static final int LVN_MARQUEEBEGIN = 0xffffff64;
- public static final int LVSCW_AUTOSIZE = 0xffffffff;
- public static final int LVSCW_AUTOSIZE_USEHEADER = 0xfffffffe;
- public static final int LVSIL_SMALL = 0x1;
- public static final int LVSIL_STATE = 0x2;
- public static final int LVS_EX_FULLROWSELECT = 0x20;
- public static final int LVS_EX_GRIDLINES = 0x1;
- public static final int LVS_EX_LABELTIP = 0x4000;
- public static final int LVS_EX_ONECLICKACTIVATE = 0x40;
- public static final int LVS_EX_SUBITEMIMAGES = 0x2;
- public static final int LVS_EX_TRACKSELECT = 0x8;
- public static final int LVS_EX_TWOCLICKACTIVATE = 0x80;
- public static final int LVS_NOCOLUMNHEADER = 0x4000;
- public static final int LVS_NOSCROLL = 0x2000;
- 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 MA_NOACTIVATE = 0x3;
- public static final int MB_ABORTRETRYIGNORE = 0x2;
- public static final int MB_APPLMODAL = 0x0;
- public static final int MB_ICONERROR = 0x10;
- public static final int MB_ICONINFORMATION = 0x40;
- public static final int MB_ICONQUESTION = 0x20;
- public static final int MB_ICONWARNING = 0x30;
- 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_RTLREADING = 0x100000;
- public static final int MB_SYSTEMMODAL = 0x1000;
- public static final int MB_TASKMODAL = 0x2000;
- public static final int MB_YESNO = 0x4;
- public static final int MB_YESNOCANCEL = 0x3;
- public static final int MFS_CHECKED = 0x8;
- public static final int MFS_DISABLED = 0x3;
- public static final int MFS_GRAYED = 0x3;
- 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 MF_BYCOMMAND = 0x0;
- public static final int MF_BYPOSITION = 0x400;
- public static final int MF_CHECKED = 0x8;
- public static final int MF_DISABLED = 0x2;
- public static final int MF_ENABLED = 0x0;
- public static final int MF_GRAYED = 0x1;
- public static final int MF_HILITE = 0x80;
- public static final int MF_POPUP = 0x10;
- public static final int MF_SEPARATOR = 0x800;
- public static final int MF_SYSMENU = 0x2000;
- public static final int MF_UNCHECKED = 0x0;
- public static final int MIIM_BITMAP = 0x80;
- public static final int MIIM_DATA = 0x20;
- public static final int MIIM_ID = 0x2;
- public static final int MIIM_STATE = 0x1;
- public static final int MIIM_SUBMENU = 0x4;
- public static final int MIIM_TYPE = 0x10;
- public static final int MIM_STYLE = 0x10;
- 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 = 0x1;
- public static final int MNC_CLOSE = 0x1;
- public static final int MNS_CHECKORBMP = 0x4000000;
- public static final int MWMO_INPUTAVAILABLE = 0x4;
- public static final int NM_CLICK = 0xfffffffe;
- public static final int NM_CUSTOMDRAW = OS.NM_FIRST - 12;
- public static final int NM_DBLCLK = 0xfffffffd;
- public static final int NM_FIRST = 0x0;
- public static final int NM_RETURN = 0xfffffffc;
- public static final int NOTSRCCOPY = 0x330008;
- public static final int NULLREGION = 0x1;
- public static final int NULL_BRUSH = 0x5;
- public static final int NULL_PEN = 0x8;
- public static final int NUMRESERVED = 106;
- public static final int OBJID_CLIENT = 0xFFFFFFFC;
- public static final int OBJ_FONT = 0x6;
- public static final int OBJ_PEN = 0x1;
- public static final int OBM_CHECKBOXES = 0x7ff7;
- public static final int ODS_SELECTED = 0x1;
- public static final int ODT_MENU = 0x1;
- public static final int OFN_ALLOWMULTISELECT = 0x200;
- public static final int OFN_EXPLORER = 0x80000;
- public static final int OFN_HIDEREADONLY = 0x4;
- public static final int OFN_NOCHANGEDIR = 0x8;
- public static final int OPAQUE = 0x2;
- public static final int PATCOPY = 0xf00021;
- public static final int PATINVERT = 0x5a0049;
- public static final int PBM_GETPOS = 0x408;
- public static final int PBM_GETRANGE = 0x407;
- public static final int PBM_SETBARCOLOR = 0x409;
- public static final int PBM_SETBKCOLOR = 0x2001;
- public static final int PBM_SETPOS = 0x402;
- public static final int PBM_SETRANGE32 = 0x406;
- public static final int PBM_STEPIT = OS.WM_USER + 5;
- public static final int PBS_SMOOTH = 0x1;
- public static final int PBS_VERTICAL = 0x4;
- public static final int PD_ALLPAGES = 0x0;
- public static final int PD_COLLATE = 0x10;
- public static final int PD_PAGENUMS = 0x2;
- public static final int PD_PRINTTOFILE = 0x20;
- public static final int PD_RETURNDC = 0x100;
- public static final int PD_SELECTION = 0x1;
- public static final int PD_USEDEVMODECOPIESANDCOLLATE = 0x40000;
- public static final int PFM_TABSTOPS = 0x10;
- public static final int PHYSICALHEIGHT = 0x6f;
- public static final int PHYSICALOFFSETX = 0x70;
- public static final int PHYSICALOFFSETY = 0x71;
- public static final int PHYSICALWIDTH = 0x6e;
- public static final int PLANES = 0xe;
- public static final int PM_NOREMOVE = 0x0;
- public static final int PM_REMOVE = 0x1;
- public static final String PROGRESS_CLASS = "msctls_progress32";
- 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_GEOMETRIC = 0x10000;
- public static final int PS_JOIN_MITER = 0x2000;
- public static final int PS_SOLID = 0x0;
- public static final int PS_STYLE_MASK = 0xf;
- public static final int QS_KEY = 0x0001;
- public static final int QS_MOUSEMOVE = 0x0002;
- public static final int QS_MOUSEBUTTON = 0x0004;
- public static final int QS_POSTMESSAGE = 0x0008;
- public static final int QS_TIMER = 0x0010;
- public static final int QS_PAINT = 0x0020;
- public static final int QS_SENDMESSAGE = 0x0040;
- public static final int QS_ALLINPUT = QS_MOUSEMOVE | QS_MOUSEBUTTON | QS_KEY | QS_POSTMESSAGE | QS_TIMER | QS_PAINT | QS_SENDMESSAGE;
- public static final int R2_COPYPEN = 0xd;
- public static final int R2_XORPEN = 0x7;
- public static final int RASTERCAPS = 0x26;
- public static final int RASTER_FONTTYPE = 0x1;
- public static final int RBBIM_CHILD = 0x10;
- public static final int RBBIM_CHILDSIZE = 0x20;
- public static final int RBBIM_COLORS = 0x2;
- public static final int RBBIM_HEADERSIZE = 0x800;
- public static final int RBBIM_ID = 0x100;
- public static final int RBBIM_IDEALSIZE = 0x200;
- public static final int RBBIM_SIZE = 0x40;
- public static final int RBBIM_STYLE = 0x1;
- public static final int RBBIM_TEXT = 0x4;
- public static final int RBBS_BREAK = 0x1;
- public static final int RBBS_GRIPPERALWAYS = 0x80;
- public static final int RBBS_NOGRIPPER = 0x00000100;
- public static final int RBBS_USECHEVRON = 0x00000200;
- public static final int RBBS_VARIABLEHEIGHT = 0x40;
- public static final int RBN_FIRST = 0xfffffcc1;
- public static final int RBN_CHEVRONPUSHED = RBN_FIRST - 10;
- public static final int RBN_HEIGHTCHANGE = 0xfffffcc1;
- public static final int RBS_DBLCLKTOGGLE = 0x8000;
- public static final int RBS_BANDBORDERS = 0x400;
- public static final int RBS_VARHEIGHT = 0x200;
- public static final int RB_DELETEBAND = 0x402;
- public static final int RB_GETBANDBORDERS = 0x422;
- public static final int RB_GETBANDCOUNT = 0x40c;
- public static final int RB_GETBANDINFO = IsUnicode ? 0x41c : 0x41d;
- public static final int RB_GETBARHEIGHT = 0x41b;
- public static final int RB_GETBKCOLOR = 0x414;
- public static final int RB_GETRECT = 0x409;
- public static final int RB_GETTEXTCOLOR = 0x416;
- public static final int RB_IDTOINDEX = 0x410;
- public static final int RB_INSERTBAND = IsUnicode ? 0x40a : 0x401;
- public static final int RB_MOVEBAND = 0x427;
- public static final int RB_SETBANDINFO = IsUnicode ? 0x40b : 0x406;
- public static final int RB_SETBKCOLOR = 0x413;
- public static final int RB_SETTEXTCOLOR = 0x415;
- public static final int RC_BITBLT = 0x1;
- public static final int RC_PALETTE = 0x100;
- public static final int RDW_ALLCHILDREN = 0x80;
- public static final int RDW_ERASE = 0x4;
- public static final int RDW_FRAME = 0x400;
- public static final int RDW_INVALIDATE = 0x1;
- public static final int RDW_UPDATENOW = 0x100;
- public static final int READ_CONTROL = 0x20000;
- public static final String REBARCLASSNAME = "ReBarWindow32";
- public static final int RGN_OR = 0x2;
- public static final int SBS_HORZ = 0x0;
- public static final int SBS_VERT = 0x1;
- 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_HORZ = 0x0;
- public static final int SB_LINEDOWN = 0x1;
- public static final int SB_LINEUP = 0x0;
- public static final int SB_PAGEDOWN = 0x3;
- public static final int SB_PAGEUP = 0x2;
- 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 SCF_ALL = 0x4;
- public static final int SCF_DEFAULT = 0x0;
- public static final int SCF_SELECTION = 0x1;
- public static final int SC_CLOSE = 0xf060;
- public static final int SC_HSCROLL = 0xf080;
- public static final int SC_KEYMENU = 0xf100;
- public static final int SC_MAXIMIZE = 0xf030;
- public static final int SC_MINIMIZE = 0xf020;
- public static final int SC_RESTORE = 0xf120;
- 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 SF_RTF = 0x2;
- public static final int SHCMBF_HIDDEN = 0x2;
- public static final int SHCMBM_OVERRIDEKEY = OS.WM_USER + 403;
- public static final int SHCMBM_SETSUBMENU = 0x590;
- public static final int SHCMBM_GETSUBMENU = 0x591;
- public static final int SHMBOF_NODEFAULT = 0x1;
- public static final int SHMBOF_NOTIFY = 0x2;
- public static final int SHRG_RETURNCMD = 0x1;
- 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 SIP_DOWN = 1;
- public static final int SIP_UP = 0;
- public static final int SIPF_ON = 0x1;
- public static final int SIZE_MINIMIZED = 0x1;
- public static final int SIZEPALETTE = 104;
- public static final int SM_CMONITORS = 80;
- public static final int SM_CXBORDER = 0x5;
- public static final int SM_CXCURSOR = 0xd;
- public static final int SM_CXEDGE = 0x2d;
- public static final int SM_CXHSCROLL = 0x15;
- public static final int SM_CXICON = 0x0b;
- public static final int SM_CYICON = 0x0c;
- public static final int SM_CXVIRTUALSCREEN = 78;
- public static final int SM_CYVIRTUALSCREEN = 79;
- public static final int SM_CXSMICON = 49;
- public static final int SM_CYSMICON = 50;
- public static final int SM_CXSCREEN = 0x0;
- public static final int SM_XVIRTUALSCREEN = 76;
- public static final int SM_YVIRTUALSCREEN = 77;
- public static final int SM_CXVSCROLL = 0x2;
- public static final int SM_CYBORDER = 0x6;
- public static final int SM_CYCURSOR = 0xe;
- public static final int SM_CYHSCROLL = 0x3;
- public static final int SM_CYMENU = 0xf;
- public static final int SM_CYSCREEN = 0x1;
- public static final int SM_CYVSCROLL = 0x14;
- public static final int SPI_GETWORKAREA = 0x30;
- public static final int SPI_GETNONCLIENTMETRICS = 41;
- public static final int SPI_GETWHEELSCROLLLINES = 104;
- public static final int SPI_SETSIPINFO = 224;
- public static final int SRCAND = 0x8800c6;
- public static final int SRCCOPY = 0xcc0020;
- public static final int SRCINVERT = 0x660046;
- public static final int SRCPAINT = 0xee0086;
- public static final int SS_BITMAP = 0xe;
- public static final int SS_CENTER = 0x1;
- public static final int SS_CENTERIMAGE = 0x200;
- 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_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 STANDARD_RIGHTS_READ = 0x20000;
- public static final int STD_COPY = 0x1;
- public static final int STD_CUT = 0x0;
- 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_PASTE = 0x2;
- public static final int STM_SETIMAGE = 0x172;
- public static final int SWP_DRAWFRAME = 0x20;
- 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_NOREDRAW = 0x8;
- public static final int SWP_NOSIZE = 0x1;
- public static final int SWP_NOZORDER = 0x4;
- 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_PARENTOPENING = 0x3;
- public static final int SW_RESTORE = OS.IsWinCE ? 0xd : 0x9;
- public static final int SW_SCROLLCHILDREN = 0x1;
- public static final int SW_SHOW = 0x5;
- public static final int SW_SHOWMAXIMIZED = OS.IsWinCE ? 0xb : 0x3;
- 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 SYNCHRONIZE = 0x100000;
- public static final int SYSTEM_FONT = 0xd;
- public static final int S_OK = 0x0;
- public static final int TBIF_COMMAND = 0x20;
- public static final int TBIF_STATE = 0x4;
- public static final int TBIF_IMAGE = 0x1;
- public static final int TBIF_LPARAM = 0x10;
- public static final int TBIF_SIZE = 0x40;
- public static final int TBIF_STYLE = 0x8;
- public static final int TBIF_TEXT = 0x2;
- public static final int TBM_GETLINESIZE = 0x418;
- public static final int TBM_GETPAGESIZE = 0x416;
- public static final int TBM_GETPOS = 0x400;
- public static final int TBM_GETRANGEMAX = 0x402;
- public static final int TBM_GETRANGEMIN = 0x401;
- public static final int TBM_GETTHUMBRECT = 0x419;
- 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_SETRANGEMAX = 0x408;
- public static final int TBM_SETRANGEMIN = 0x407;
- public static final int TBM_SETTICFREQ = 0x414;
- public static final int TBN_DROPDOWN = 0xfffffd3a;
- public static final int TBN_FIRST = 0xfffffd44;
- public static final int TBSTATE_CHECKED = 0x1;
- public static final int TBSTYLE_DROPDOWN = 0x8;
- public static final int TBSTATE_ENABLED = 0x4;
- public static final int TBSTYLE_AUTOSIZE = 0x10;
- public static final int TBSTYLE_EX_DRAWDDARROWS = 0x1;
- public static final int TBSTYLE_FLAT = 0x800;
- public static final int TBSTYLE_LIST = 0x1000;
- 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 TBS_AUTOTICKS = 0x1;
- public static final int TBS_BOTH = 0x8;
- public static final int TBS_HORZ = 0x0;
- public static final int TBS_VERT = 0x2;
- public static final int TB_ADDSTRING = IsUnicode ? 0x44d : 0x41c;
- public static final int TB_BUTTONCOUNT = 0x418;
- public static final int TB_BUTTONSTRUCTSIZE = 0x41e;
- public static final int TB_COMMANDTOINDEX = 0x419;
- public static final int TB_DELETEBUTTON = 0x416;
- public static final int TB_ENDTRACK = 0x8;
- public static final int TB_GETBUTTON = 0x417;
- public static final int TB_GETBUTTONINFO = IsUnicode ? 0x43f : 0x441;
- public static final int TB_GETBUTTONSIZE = 0x43a;
- public static final int TB_GETBUTTONTEXT = IsUnicode ? 0x44b : 0x42d;
- public static final int TB_GETDISABLEDIMAGELIST = 0x437;
- public static final int TB_GETHOTIMAGELIST = 0x435;
- public static final int TB_GETHOTITEM = 0x0400 + 71;
- public static final int TB_GETIMAGELIST = 0x431;
- public static final int TB_GETITEMRECT = 0x41d;
- public static final int TB_GETROWS = 0x428;
- public static final int TB_GETSTATE = 0x412;
- public static final int TB_GETTOOLTIPS = 0x423;
- public static final int TB_INSERTBUTTON = IsUnicode ? 0x443 : 0x415;
- public static final int TB_LOADIMAGES = 0x432;
- public static final int TB_MAPACCELERATOR = 0x0400 + (IsUnicode ? 90 : 78);
- public static final int TB_SETBITMAPSIZE = 0x420;
- public static final int TB_SETBUTTONINFO = IsUnicode ? 0x440 : 0x442;
- public static final int TB_SETBUTTONSIZE = 0x41f;
- public static final int TB_SETDISABLEDIMAGELIST = 0x436;
- public static final int TB_SETEXTENDEDSTYLE = 0x454;
- public static final int TB_SETHOTIMAGELIST = 0x434;
- public static final int TB_SETHOTITEM = 0x0400 + 72;
- public static final int TB_SETIMAGELIST = 0x430;
- public static final int TB_SETROWS = 0x427;
- public static final int TB_SETSTATE = 0x411;
- public static final int TCIF_IMAGE = 0x2;
- public static final int TCIF_TEXT = 0x1;
- public static final int TCI_SRCCHARSET = 0x1;
- public static final int TCI_SRCCODEPAGE = 0x2;
- public static final int TCM_ADJUSTRECT = 0x1328;
- public static final int TCM_DELETEITEM = 0x1308;
- public static final int TCM_GETCURSEL = 0x130b;
- public static final int TCM_GETITEMCOUNT = 0x1304;
- public static final int TCM_GETITEMRECT = 0x130a;
- public static final int TCM_GETTOOLTIPS = 0x132d;
- public static final int TCM_INSERTITEM = IsUnicode ? 0x133e : 0x1307;
- public static final int TCM_SETCURSEL = 0x130c;
- public static final int TCM_SETIMAGELIST = 0x1303;
- public static final int TCM_SETITEM = IsUnicode ? 0x133d : 0x1306;
- public static final int TCN_SELCHANGE = 0xfffffdd9;
- public static final int TCN_SELCHANGING = 0xfffffdd8;
- public static final int TCS_FOCUSNEVER = 0x8000;
- public static final int TCS_MULTILINE = 0x200;
- public static final int TCS_TABS = 0x0;
- public static final int TCS_TOOLTIPS = 0x4000;
- public static final int TME_HOVER = 0x1;
- public static final int TME_LEAVE = 0x2;
- public static final int TME_QUERY = 0x40000000;
- public static final int TMPF_VECTOR = 0x2;
- public static final String TOOLBARCLASSNAME = "ToolbarWindow32";
- public static final String TOOLTIPS_CLASS = "tooltips_class32";
- public static final int TPM_LEFTALIGN = 0x0;
- public static final int TPM_LEFTBUTTON = 0x0;
- public static final int TPM_RIGHTBUTTON = 0x2;
- public static final int TPM_RIGHTALIGN = 0x8;
- public static final String TRACKBAR_CLASS = "msctls_trackbar32";
- public static final int TRANSPARENT = 0x1;
- public static final int TTF_IDISHWND = 0x1;
- public static final int TTF_SUBCLASS = 0x10;
- public static final int TTM_ADDTOOL = IsUnicode ? 0x432 : 0x404;
- public static final int TTM_DELTOOL = IsUnicode ? 0x433 : 0x405;
- public static final int TTM_SETMAXTIPWIDTH = 0x418;
- public static final int TTM_UPDATE = 0x41D;
- public static final int TTN_FIRST = 0xfffffdf8;
- public static final int TTN_GETDISPINFO = IsUnicode ? 0xfffffdee : 0xfffffdf8;
- public static final int TTN_GETDISPINFOW = 0xfffffdee;
- public static final int TTN_GETDISPINFOA = 0xfffffdf8;
- public static final int TTN_POP = TTN_FIRST - 2;
- public static final int TTN_SHOW = TTN_FIRST - 1;
- public static final int TTS_ALWAYSTIP = 0x1;
- public static final int TVE_COLLAPSE = 0x1;
- public static final int TVE_EXPAND = 0x2;
- public static final int TVGN_CARET = 0x9;
- public static final int TVGN_CHILD = 0x4;
- public static final int TVGN_FIRSTVISIBLE = 0x5;
- public static final int TVGN_LASTVISIBLE = 0xa;
- public static final int TVGN_NEXT = 0x1;
- public static final int TVGN_NEXTVISIBLE = 0x6;
- public static final int TVGN_PARENT = 0x3;
- public static final int TVGN_PREVIOUSVISIBLE = 0x7;
- public static final int TVGN_ROOT = 0x0;
- public static final int TVHT_ONITEM = 0x46;
- public static final int TVHT_ONITEMICON = 0x2;
- public static final int TVHT_ONITEMLABEL = 0x4;
- public static final int TVHT_ONITEMSTATEICON = 0x40;
- public static final int TVIF_HANDLE = 0x10;
- public static final int TVIF_IMAGE = 0x2;
- public static final int TVIF_PARAM = 0x4;
- public static final int TVIF_SELECTEDIMAGE = 0x20;
- public static final int TVIF_STATE = 0x8;
- public static final int TVIF_TEXT = 0x1;
- public static final int TVIS_DROPHILITED = 0x8;
- public static final int TVIS_EXPANDED = 0x20;
- public static final int TVIS_SELECTED = 0x2;
- public static final int TVIS_STATEIMAGEMASK = 0xf000;
- 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 TVM_DELETEITEM = 0x1101;
- public static final int TVM_ENSUREVISIBLE = 0x1114;
- public static final int TVM_EXPAND = 0x1102;
- public static final int TVM_GETBKCOLOR = 0x111f;
- public static final int TVM_GETCOUNT = 0x1105;
- public static final int TVM_GETIMAGELIST = 0x1108;
- public static final int TVM_GETITEM = IsUnicode ? 0x113e : 0x110c;
- public static final int TVM_GETITEMHEIGHT = 0x111c;
- public static final int TVM_GETITEMRECT = 0x1104;
- public static final int TVM_GETNEXTITEM = 0x110a;
- public static final int TVM_GETTEXTCOLOR = 0x1120;
- public static final int TVM_GETTOOLTIPS = OS.TV_FIRST + 25;
- public static final int TVM_GETVISIBLECOUNT = OS.TV_FIRST + 16;
- public static final int TVM_HITTEST = 0x1111;
- public static final int TVM_INSERTITEM = IsUnicode ? 0x1132 : 0x1100;
- public static final int TVM_SELECTITEM = 0x110b;
- public static final int TVM_SETBKCOLOR = 0x111d;
- public static final int TVM_SETIMAGELIST = 0x1109;
- public static final int TVM_SETINSERTMARK = 0x111a;
- public static final int TVM_SETITEM = IsUnicode ? 0x113f : 0x110d;
- public static final int TVM_SETTEXTCOLOR = 0x111e;
- public static final int TVN_BEGINDRAG = IsUnicode ? 0xfffffe38 : 0xfffffe69;
- public static final int TVN_BEGINDRAGW = 0xfffffe38;
- public static final int TVN_BEGINDRAGA = 0xfffffe69;
- public static final int TVN_BEGINRDRAG = IsUnicode ? 0xfffffe37 : 0xfffffe68;
- public static final int TVN_BEGINRDRAGW = 0xfffffe37;
- public static final int TVN_BEGINRDRAGA = 0xfffffe68;
- public static final int TVN_FIRST = 0xfffffe70;
- public static final int TVN_ITEMEXPANDING = IsUnicode ? 0xfffffe3a : 0xfffffe6b;
- public static final int TVN_ITEMEXPANDINGW = 0xfffffe3a;
- public static final int TVN_ITEMEXPANDINGA = 0xfffffe6b;
- public static final int TVN_SELCHANGED = IsUnicode ? 0xfffffe3d : 0xfffffe6e;
- public static final int TVN_SELCHANGEDW = 0xfffffe3d;
- public static final int TVN_SELCHANGEDA = 0xfffffe6e;
- public static final int TVN_SELCHANGING = IsUnicode ? 0xfffffe3e : 0xfffffe6f;
- public static final int TVN_SELCHANGINGW = 0xfffffe3e;
- public static final int TVN_SELCHANGINGA = 0xfffffe6f;
- public static final int TVSIL_NORMAL = 0x0;
- public static final int TVSIL_STATE = 0x2;
- public static final int TVS_DISABLEDRAGDROP = 0x10;
- public static final int TVS_FULLROWSELECT = 0x1000;
- public static final int TVS_HASBUTTONS = 0x1;
- public static final int TVS_HASLINES = 0x2;
- public static final int TVS_LINESATROOT = 0x4;
- public static final int TVS_NOTOOLTIPS = 0x80;
- public static final int TVS_SHOWSELALWAYS = 0x20;
- public static final int TV_FIRST = 0x1100;
- public static final int UIS_INITIALIZE = 3;
- public static final int VERTRES = 0xa;
- public static final int VK_BACK = 0x8;
- public static final int VK_CAPITAL = 0x14;
- public static final int VK_CONTROL = 0x11;
- 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_ESCAPE = 0x1b;
- 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_F2 = 0x71;
- public static final int VK_F3 = 0x72;
- public static final int VK_F4 = 0x73;
- public static final int VK_F5 = 0x74;
- public static final int VK_F6 = 0x75;
- public static final int VK_F7 = 0x76;
- public static final int VK_F8 = 0x77;
- public static final int VK_F9 = 0x78;
- 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_LEFT = 0x25;
- 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_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_PRIOR = 0x21;
- public static final int VK_RBUTTON = 0x2;
- public static final int VK_RETURN = 0xd;
- public static final int VK_RIGHT = 0x27;
- public static final int VK_SCROLL = 0x91;
- public static final int VK_SEPARATOR = 0x6C;
- public static final int VK_SHIFT = 0x10;
- 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_ADD = 0x6B;
- public static final int VK_APP1 = 0xc1;
- public static final int VK_APP2 = 0xc2;
- public static final int VK_APP3 = 0xc3;
- public static final int VK_APP4 = 0xc4;
- public static final int VK_APP5 = 0xc5;
- public static final int VK_APP6 = 0xc6;
- public static final String WC_LISTVIEW = "SysListView32";
- public static final String WC_TABCONTROL = "SysTabControl32";
- public static final String WC_TREEVIEW = "SysTreeView32";
- public static final int WH_GETMESSAGE = 0x3;
- public static final int WH_MSGFILTER = 0xFFFFFFFF;
- public static final int WHEEL_DELTA = 120;
- public static final int WHEEL_PAGESCROLL = 0xFFFFFFFF;
- public static final int WM_ACTIVATE = 0x6;
- public static final int WM_ACTIVATEAPP = 0x1c;
- public static final int WM_APP = 0x8000;
- public static final int WM_CANCELMODE = 0x1f;
- public static final int WM_CHANGEUISTATE = 0x0127;
- public static final int WM_CHAR = 0x102;
- 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_CONTEXTMENU = 0x7b;
- public static final int WM_COPY = 0x301;
- 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_DESTROY = 0x2;
- public static final int WM_DRAWITEM = 0x2b;
- public static final int WM_ENDSESSION = 0x16;
- public static final int WM_ERASEBKGND = 0x14;
- public static final int WM_GETDLGCODE = 0x87;
- public static final int WM_GETFONT = 0x31;
-// public static final int WM_GETICON = 0x7f;
- public static final int WM_GETOBJECT = 0x003D;
- public static final int WM_HELP = 0x53;
- public static final int WM_HOTKEY = 0x0312;
- public static final int WM_HSCROLL = 0x114;
- public static final int WM_IME_CHAR = 0x286;
- public static final int WM_IME_COMPOSITION = 0x10f;
- public static final int WM_INITDIALOG = 0x110;
- public static final int WM_INITMENUPOPUP = 0x117;
- 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_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_MOUSEHOVER = 0x2a1;
- public static final int WM_MOUSELEAVE = 0x2a3;
- public static final int WM_MOUSEMOVE = 0x200;
- public static final int WM_MOUSEWHEEL = 0x20a;
- public static final int WM_MOUSELAST = 0x20d;
- public static final int WM_MOVE = 0x3;
- public static final int WM_NCACTIVATE = 0x86;
- public static final int WM_NCCALCSIZE = 0x83;
- public static final int WM_NCHITTEST = 0x84;
- public static final int WM_NOTIFY = 0x4e;
- public static final int WM_NULL = 0x0;
- public static final int WM_PAINT = 0xf;
- public static final int WM_PALETTECHANGED = 0x311;
- public static final int WM_PASTE = 0x302;
- public static final int WM_PRINTCLIENT = 0x0318;
- 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_RBUTTONDBLCLK = 0x206;
- public static final int WM_RBUTTONDOWN = 0x204;
- public static final int WM_RBUTTONUP = 0x205;
- 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_SETICON = 0x80;
- public static final int WM_SETREDRAW = 0xb;
- 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_SYSCHAR = 0x106;
- public static final int WM_SYSCOLORCHANGE = 0x15;
- public static final int WM_SYSCOMMAND = 0x112;
- public static final int WM_SYSKEYDOWN = 0x104;
- public static final int WM_SYSKEYUP = 0x105;
- public static final int WM_TIMER = 0x113;
- public static final int WM_UNDO = 0x304;
- public static final int WM_USER = 0x400;
- public static final int WM_VSCROLL = 0x115;
- public static final int WM_WINDOWPOSCHANGING = 0x46;
- 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_CLIPCHILDREN = 0x2000000;
- public static final int WS_CLIPSIBLINGS = 0x4000000;
- public static final int WS_EX_CAPTIONOKBTN = 0x80000000;
- public static final int WS_EX_CLIENTEDGE = 0x200;
- public static final int WS_EX_DLGMODALFRAME = 0x1;
- public static final int WS_EX_LAYOUTRTL = 0x00400000;
- public static final int WS_EX_NOINHERITLAYOUT = 0x00100000;
- 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_HSCROLL = 0x100000;
- public static final int WS_MAXIMIZEBOX = OS.IsWinCE ? 0x20000 : 0x10000;
- public static final int WS_MINIMIZEBOX = OS.IsWinCE ? 0x10000 : 0x20000;
- public static final int WS_OVERLAPPED = OS.IsWinCE ? WS_BORDER | WS_CAPTION : 0x0;
- public static final int WS_OVERLAPPEDWINDOW = 0xcf0000;
- public static final int WS_POPUP = 0x80000000;
- 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_VISIBLE = 0x10000000;
- public static final int WS_VSCROLL = 0x200000;
-
-/** Ansi/Unicode wrappers */
-
-public static final int CallWindowProc (int lpPrevWndFunc, int hWnd, int Msg, int wParam, int lParam) {
- if (IsUnicode) return CallWindowProcW (lpPrevWndFunc, hWnd, Msg, wParam, lParam);
- return CallWindowProcA (lpPrevWndFunc, hWnd, Msg, wParam, lParam);
-}
-
-public static final short CharUpper (short ch) {
- if (IsUnicode) return CharUpperW (ch);
- return CharUpperA (ch);
-}
-
-public static final short CharLower (short ch) {
- if (IsUnicode) return CharLowerW (ch);
- return CharLowerA (ch);
-}
-
-public static final boolean ChooseColor (CHOOSECOLOR lpcc) {
- if (IsUnicode) return ChooseColorW (lpcc);
- return ChooseColorA (lpcc);
-}
-
-public static final boolean ChooseFont (CHOOSEFONT chooseFont) {
- if (IsUnicode) return ChooseFontW (chooseFont);
- return ChooseFontA (chooseFont);
-}
-
-public static final int CreateAcceleratorTable (byte [] lpaccl, int cEntries) {
- if (IsUnicode) return CreateAcceleratorTableW (lpaccl, cEntries);
- return CreateAcceleratorTableA (lpaccl, cEntries);
-}
-
-public static final int CreateDC (TCHAR lpszDriver, TCHAR lpszDevice, int lpszOutput, int lpInitData) {
- if (IsUnicode) {
- char [] lpszDriver1 = lpszDriver == null ? null : lpszDriver.chars;
- char [] lpszDevice1 = lpszDevice == null ? null : lpszDevice.chars;
- return CreateDCW (lpszDriver1, lpszDevice1, lpszOutput, lpInitData);
- }
- byte [] lpszDriver1 = lpszDriver == null ? null : lpszDriver.bytes;
- byte [] lpszDevice1 = lpszDevice == null ? null : lpszDevice.bytes;
- return CreateDCA (lpszDriver1, lpszDevice1, lpszOutput, lpInitData);
-}
-
-public static final int CreateFontIndirect (int lplf) {
- if (IsUnicode) return CreateFontIndirectW (lplf);
- return CreateFontIndirectA (lplf);
-}
-
-public static final int CreateFontIndirect (LOGFONT lplf) {
- if (IsUnicode) return CreateFontIndirectW (lplf);
- return CreateFontIndirectA (lplf);
-}
-
-public static final int CreateWindowEx (int dwExStyle, TCHAR lpClassName, TCHAR lpWindowName, int dwStyle, int X, int Y, int nWidth, int nHeight, int hWndParent, int hMenu, int hInstance, CREATESTRUCT lpParam) {
- if (IsUnicode) {
- char [] lpClassName1 = lpClassName == null ? null : lpClassName.chars;
- char [] lpWindowName1 = lpWindowName == null ? null : lpWindowName.chars;
- return CreateWindowExW (dwExStyle, lpClassName1, lpWindowName1, dwStyle, X, Y, nWidth, nHeight, hWndParent, hMenu, hInstance, lpParam);
- }
- byte [] lpClassName1 = lpClassName == null ? null : lpClassName.bytes;
- byte [] lpWindowName1 = lpWindowName == null ? null : lpWindowName.bytes;
- return CreateWindowExA (dwExStyle, lpClassName1, lpWindowName1, dwStyle, X, Y, nWidth, nHeight, hWndParent, hMenu, hInstance, lpParam);
-}
-
-public static final int DefWindowProc (int hWnd, int Msg, int wParam, int lParam) {
- if (IsUnicode) return DefWindowProcW (hWnd, Msg, wParam, lParam);
- return DefWindowProcA (hWnd, Msg, wParam, lParam);
-}
-
-public static final int DispatchMessage (MSG lpmsg) {
- if (IsUnicode) return DispatchMessageW (lpmsg);
- return DispatchMessageA (lpmsg);
-}
-
-public static final int DragQueryFile (int hDrop, int iFile, TCHAR lpszFile, int cch) {
- if (IsUnicode) {
- char [] lpszFile1 = lpszFile == null ? null : lpszFile.chars;
- return DragQueryFileW (hDrop, iFile, lpszFile1, cch);
- }
- byte [] lpszFile1 = lpszFile == null ? null : lpszFile.bytes;
- return DragQueryFileA (hDrop, iFile, lpszFile1, cch);
-}
-
-public static final boolean DrawState (int hdc, int hbr, int lpOutputFunc, int lData, int wData, int x, int y, int cx, int cy, int fuFlags) {
- if (IsUnicode) return DrawStateW (hdc, hbr, lpOutputFunc, lData, wData, x, y, cx, cy, fuFlags);
- return DrawStateA (hdc, hbr, lpOutputFunc, lData, wData, x, y, cx, cy, fuFlags);
-}
-
-public static final int DrawText (int hDC, TCHAR lpString, int nCount, RECT lpRect, int uFormat) {
- if (IsUnicode) {
- char [] lpString1 = lpString == null ? null : lpString.chars;
- return DrawTextW (hDC, lpString1, nCount, lpRect, uFormat);
- }
- byte [] lpString1 = lpString == null ? null : lpString.bytes;
- return DrawTextA (hDC, lpString1, nCount, lpRect, uFormat);
-}
-
-public static final int EnumFontFamilies (int hdc, TCHAR lpszFamily, int lpEnumFontFamProc, int lParam) {
- if (IsUnicode) {
- char [] lpszFamily1 = lpszFamily == null ? null : lpszFamily.chars;
- return EnumFontFamiliesW (hdc, lpszFamily1, lpEnumFontFamProc, lParam);
- }
- byte [] lpszFamily1 = lpszFamily == null ? null : lpszFamily.bytes;
- return EnumFontFamiliesA (hdc, lpszFamily1, lpEnumFontFamProc, lParam);
-}
-
-public static final boolean EnumSystemLocales (int lpLocaleEnumProc, int dwFlags) {
- if (IsUnicode) return EnumSystemLocalesW (lpLocaleEnumProc, dwFlags);
- return EnumSystemLocalesA (lpLocaleEnumProc, dwFlags);
-}
-
-public static final boolean EnumSystemLanguageGroups (int pLangGroupEnumProc, int dwFlags, int lParam) {
- if (IsUnicode) return EnumSystemLanguageGroupsW (pLangGroupEnumProc, dwFlags, lParam);
- return EnumSystemLanguageGroupsA (pLangGroupEnumProc, dwFlags, lParam);
-}
-
-public static final int ExpandEnvironmentStrings (TCHAR lpSrc, TCHAR lpDst, int nSize) {
- if (IsUnicode) {
- char [] lpSrc1 = lpSrc == null ? null : lpSrc.chars;
- char [] lpDst1 = lpDst == null ? null : lpDst.chars;
- return ExpandEnvironmentStringsW (lpSrc1, lpDst1, nSize);
- }
- byte [] lpSrc1 = lpSrc == null ? null : lpSrc.bytes;
- byte [] lpDst1 = lpDst == null ? null : lpDst.bytes;
- return ExpandEnvironmentStringsA (lpSrc1, lpDst1, nSize);
-}
-
-public static final int ExtractIconEx (TCHAR lpszFile, int nIconIndex, int [] phiconLarge, int [] phiconSmall, int nIcons) {
- if (IsUnicode) {
- char [] lpszFile1 = lpszFile == null ? null : lpszFile.chars;
- return ExtractIconExW (lpszFile1, nIconIndex, phiconLarge, phiconSmall, nIcons);
- }
- byte [] lpszFile1 = lpszFile == null ? null : lpszFile.bytes;
- return ExtractIconExA (lpszFile1, nIconIndex, phiconLarge, phiconSmall, nIcons);
-}
-
-public static final boolean ExtTextOut(int hdc, int X, int Y, int fuOptions, RECT lprc, TCHAR lpString, int cbCount, int[] lpDx) {
- if (IsUnicode) {
- char [] lpString1 = lpString == null ? null : lpString.chars;
- return ExtTextOutW (hdc, X, Y, fuOptions, lprc, lpString1, cbCount, lpDx);
- }
- byte [] lpString1 = lpString == null ? null : lpString.bytes;
- return ExtTextOutA (hdc, X, Y, fuOptions, lprc, lpString1, cbCount, lpDx);
-}
-
-public static final int FindWindow (TCHAR lpClassName, TCHAR lpWindowName) {
- if (IsUnicode) {
- char [] lpClassName1 = lpClassName == null ? null : lpClassName.chars;
- char [] lpWindowName1 = lpWindowName == null ? null : lpWindowName.chars;
- return FindWindowW (lpClassName1, lpWindowName1);
- }
- byte [] lpClassName1 = lpClassName == null ? null : lpClassName.bytes;
- byte [] lpWindowName1 = lpWindowName == null ? null : lpWindowName.bytes;
- return FindWindowA (lpClassName1, lpWindowName1);
-}
-
-public static final boolean GetCharABCWidths (int hdc, int iFirstChar, int iLastChar, int [] lpabc) {
- if (IsUnicode) return GetCharABCWidthsW (hdc,iFirstChar, iLastChar, lpabc);
- return GetCharABCWidthsA (hdc,iFirstChar, iLastChar, lpabc);
-}
-
-public static final int GetCharacterPlacement (int hdc, TCHAR lpString, int nCount, int nMaxExtent, GCP_RESULTS lpResults, int dwFlags) {
- if (IsUnicode) {
- char [] lpString1 = lpString == null ? null : lpString.chars;
- return GetCharacterPlacementW (hdc, lpString1, nCount, nMaxExtent, lpResults, dwFlags);
- }
- byte [] lpString1 = lpString == null ? null : lpString.bytes;
- return GetCharacterPlacementA (hdc, lpString1, nCount, nMaxExtent, lpResults, dwFlags);
-}
-
-public static final boolean GetCharWidth (int hdc, int iFirstChar, int iLastChar, int [] lpabc) {
- if (IsUnicode) return GetCharWidthW (hdc,iFirstChar, iLastChar, lpabc);
- return GetCharWidthA (hdc,iFirstChar, iLastChar, lpabc);
-}
-
-public static final boolean GetClassInfo (int hInstance, TCHAR lpClassName, WNDCLASS lpWndClass) {
- if (IsUnicode) {
- char [] lpClassName1 = lpClassName == null ? null : lpClassName.chars;
- return GetClassInfoW (hInstance, lpClassName1, lpWndClass);
- }
- byte [] lpClassName1 = lpClassName == null ? null : lpClassName.bytes;
- return GetClassInfoA (hInstance, lpClassName1, lpWndClass);
-}
-
-public static final int GetClipboardFormatName (int format, TCHAR lpszFormatName, int cchMaxCount) {
- if (IsUnicode) {
- char [] lpszFormatName1 = lpszFormatName == null ? null : lpszFormatName.chars;
- return GetClipboardFormatNameW (format, lpszFormatName1, cchMaxCount);
- }
- byte [] lpszFormatName1 = lpszFormatName == null ? null : lpszFormatName.bytes;
- return GetClipboardFormatNameA (format, lpszFormatName1, cchMaxCount);
-}
-
-public static final int GetKeyNameText (int lParam, TCHAR lpString, int nSize) {
- if (IsUnicode) {
- char [] lpString1 = lpString == null ? null : lpString.chars;
- return GetKeyNameTextW (lParam, lpString1, nSize);
- }
- byte [] lpString1 = lpString == null ? null : lpString.bytes;
- return GetKeyNameTextA (lParam, lpString1, nSize);
-}
-
-public static final int GetLocaleInfo (int Locale, int LCType, TCHAR lpLCData, int cchData) {
- if (IsUnicode) {
- char [] lpLCData1 = lpLCData == null ? null : lpLCData.chars;
- return GetLocaleInfoW (Locale, LCType, lpLCData1, cchData);
- }
- byte [] lpLCData1 = lpLCData == null ? null : lpLCData.bytes;
- return GetLocaleInfoA (Locale, LCType, lpLCData1, cchData);
-}
-
-public static final boolean GetMenuItemInfo (int hMenu, int uItem, boolean fByPosition, MENUITEMINFO lpmii) {
- if (IsUnicode) return GetMenuItemInfoW (hMenu, uItem, fByPosition, lpmii);
- return GetMenuItemInfoA (hMenu, uItem, fByPosition, lpmii);
-}
-
-public static final boolean GetMessage (MSG lpMsg, int hWnd, int wMsgFilterMin, int wMsgFilterMax) {
- if (IsUnicode) return GetMessageW (lpMsg, hWnd, wMsgFilterMin, wMsgFilterMax);
- return GetMessageA (lpMsg, hWnd, wMsgFilterMin, wMsgFilterMax);
-}
-
-public static final int GetModuleHandle (TCHAR lpModuleName) {
- if (IsUnicode) {
- char [] lpModuleName1 = lpModuleName == null ? null : lpModuleName.chars;
- return GetModuleHandleW (lpModuleName1);
- }
- byte [] lpModuleName1 = lpModuleName == null ? null : lpModuleName.bytes;
- return GetModuleHandleA (lpModuleName1);
-}
-
-public static final int GetObject (int hgdiobj, int cbBuffer, BITMAP lpvObject) {
- if (IsUnicode) return GetObjectW (hgdiobj, cbBuffer, lpvObject);
- return GetObjectA (hgdiobj, cbBuffer, lpvObject);
-}
-
-public static final int GetObject (int hgdiobj, int cbBuffer, DIBSECTION lpvObject) {
- if (IsUnicode) return GetObjectW (hgdiobj, cbBuffer, lpvObject);
- return GetObjectA (hgdiobj, cbBuffer, lpvObject);
-}
-
-public static final int GetObject (int hgdiobj, int cbBuffer, LOGBRUSH lpvObject) {
- if (IsUnicode) return GetObjectW (hgdiobj, cbBuffer, lpvObject);
- return GetObjectA (hgdiobj, cbBuffer, lpvObject);
-}
-
-public static final int GetObject (int hgdiobj, int cbBuffer, LOGFONT lpvObject) {
- if (IsUnicode) return GetObjectW (hgdiobj, cbBuffer, lpvObject);
- return GetObjectA (hgdiobj, cbBuffer, lpvObject);
-}
-
-public static final int GetObject (int hgdiobj, int cbBuffer, LOGPEN lpvObject) {
- if (IsUnicode) return GetObjectW (hgdiobj, cbBuffer, lpvObject);
- return GetObjectA (hgdiobj, cbBuffer, lpvObject);
-}
-
-public static final boolean GetOpenFileName (OPENFILENAME lpofn) {
- if (IsUnicode) return GetOpenFileNameW (lpofn);
- return GetOpenFileNameA (lpofn);
-}
-
-public static final int GetProfileString (TCHAR lpAppName, TCHAR lpKeyName, TCHAR lpDefault, TCHAR lpReturnedString, int nSize) {
- if (IsUnicode) {
- char [] lpAppName1 = lpAppName == null ? null : lpAppName.chars;
- char [] lpKeyName1 = lpKeyName == null ? null : lpKeyName.chars;
- char [] lpDefault1 = lpDefault == null ? null : lpDefault.chars;
- char [] lpReturnedString1 = lpReturnedString == null ? null : lpReturnedString.chars;
- return GetProfileStringW (lpAppName1, lpKeyName1, lpDefault1, lpReturnedString1, nSize);
- }
- byte [] lpAppName1 = lpAppName == null ? null : lpAppName.bytes;
- byte [] lpKeyName1 = lpKeyName == null ? null : lpKeyName.bytes;
- byte [] lpDefault1 = lpDefault == null ? null : lpDefault.bytes;
- byte [] lpReturnedString1 = lpReturnedString == null ? null : lpReturnedString.bytes;
- return GetProfileStringA (lpAppName1, lpKeyName1, lpDefault1, lpReturnedString1, nSize);
-}
-
-public static final boolean GetSaveFileName (OPENFILENAME lpofn) {
- if (IsUnicode) return GetSaveFileNameW (lpofn);
- return GetSaveFileNameA (lpofn);
-}
-
-public static final boolean GetTextExtentPoint32 (int hdc, TCHAR lpString, int cbString, SIZE lpSize) {
- if (IsUnicode) {
- char [] lpString1 = lpString == null ? null : lpString.chars;
- return GetTextExtentPoint32W (hdc, lpString1, cbString, lpSize);
- }
- byte [] lpString1 = lpString == null ? null : lpString.bytes;
- return GetTextExtentPoint32A (hdc, lpString1, cbString, lpSize);
-}
-
-public static final boolean GetTextMetrics (int hdc, TEXTMETRIC lptm) {
- if (IsUnicode) return GetTextMetricsW (hdc, lptm);
- return GetTextMetricsA (hdc, lptm);
-}
-
-public static final boolean GetVersionEx (OSVERSIONINFO lpVersionInfo) {
- if (IsUnicode) return GetVersionExW (lpVersionInfo);
- return GetVersionExA (lpVersionInfo);
-}
-
-public static final int GetWindowLong (int hWnd, int nIndex) {
- if (IsUnicode) return GetWindowLongW (hWnd, nIndex);
- return GetWindowLongA (hWnd, nIndex);
-}
-
-public static final int GetWindowText (int hWnd, TCHAR lpString, int nMaxCount) {
- if (IsUnicode) {
- char [] lpString1 = lpString == null ? null : lpString.chars;
- return GetWindowTextW (hWnd, lpString1, nMaxCount);
- }
- byte [] lpString1 = lpString == null ? null : lpString.bytes;
- return GetWindowTextA (hWnd, lpString1, nMaxCount);
-}
-
-public static final int GetWindowTextLength (int hWnd) {
- if (IsUnicode) return GetWindowTextLengthW (hWnd);
- return GetWindowTextLengthA (hWnd);
-}
-
-public static final boolean ImmGetCompositionFont (int hIMC, LOGFONT lplf) {
- if (IsUnicode) return ImmGetCompositionFontW (hIMC, lplf);
- return ImmGetCompositionFontA (hIMC, lplf);
-}
-
-public static final boolean ImmSetCompositionFont (int hIMC, LOGFONT lplf) {
- if (IsUnicode) return ImmSetCompositionFontW (hIMC, lplf);
- return ImmSetCompositionFontA (hIMC, lplf);
-}
-
-public static final int ImmGetCompositionString (int hIMC, int dwIndex, TCHAR lpBuf, int dwBufLen) {
- if (IsUnicode) {
- char [] lpBuf1 = lpBuf == null ? null : lpBuf.chars;
- return ImmGetCompositionStringW (hIMC, dwIndex, lpBuf1, dwBufLen);
- }
- byte [] lpBuf1 = lpBuf == null ? null : lpBuf.bytes;
- return ImmGetCompositionStringA (hIMC, dwIndex, lpBuf1, dwBufLen);
-}
-
-public static final boolean InsertMenu (int hMenu, int uPosition, int uFlags, int uIDNewItem, TCHAR lpNewItem) {
- if (IsUnicode) {
- char [] lpNewItem1 = lpNewItem == null ? null : lpNewItem.chars;
- return InsertMenuW (hMenu, uPosition, uFlags, uIDNewItem, lpNewItem1);
- }
- byte [] lpNewItem1 = lpNewItem == null ? null : lpNewItem.bytes;
- return InsertMenuA (hMenu, uPosition, uFlags, uIDNewItem, lpNewItem1);
-}
-
-public static final boolean InsertMenuItem (int hMenu, int uItem, boolean fByPosition, MENUITEMINFO lpmii) {
- if (IsUnicode) return InsertMenuItemW (hMenu, uItem, fByPosition, lpmii);
- return InsertMenuItemA (hMenu, uItem, fByPosition, lpmii);
-}
-
-public static final int LoadBitmap (int hInstance, int lpBitmapName) {
- if (IsUnicode) return LoadBitmapW (hInstance, lpBitmapName);
- return LoadBitmapA (hInstance, lpBitmapName);
-}
-
-public static final int LoadCursor (int hInstance, int lpCursorName) {
- if (IsUnicode) return LoadCursorW (hInstance, lpCursorName);
- return LoadCursorA (hInstance, lpCursorName);
-}
-
-public static final int LoadIcon (int hInstance, int lpIconName) {
- if (IsUnicode) return LoadIconW (hInstance, lpIconName);
- return LoadIconA (hInstance, lpIconName);
-}
-
-public static final int LoadImage (int hinst, TCHAR lpszName, int uType, int cxDesired, int cyDesired, int fuLoad) {
- if (IsUnicode) {
- char [] lpszName1 = lpszName == null ? null : lpszName.chars;
- return LoadImageW (hinst, lpszName1, uType, cxDesired, cyDesired, fuLoad);
- }
- byte [] lpszName1 = lpszName == null ? null : lpszName.bytes;
- return LoadImageA (hinst, lpszName1, uType, cxDesired, cyDesired, fuLoad);
-}
-
-public static final int LoadLibrary (TCHAR lpLibFileName) {
- if (IsUnicode) {
- char [] lpLibFileName1 = lpLibFileName == null ? null : lpLibFileName.chars;
- return LoadLibraryW (lpLibFileName1);
- }
- byte [] lpLibFileName1 = lpLibFileName == null ? null : lpLibFileName.bytes;
- return LoadLibraryA (lpLibFileName1);
-}
-
-public static final int MapVirtualKey (int uCode, int uMapType) {
- if (IsUnicode) return MapVirtualKeyW (uCode, uMapType);
- return MapVirtualKeyA (uCode, uMapType);
-}
-
-public static final int MessageBox (int hWnd, TCHAR lpText, TCHAR lpCaption, int uType) {
- if (IsUnicode) {
- char [] lpText1 = lpText == null ? null : lpText.chars;
- char [] lpCaption1 = lpCaption == null ? null : lpCaption.chars;
- return MessageBoxW (hWnd, lpText1, lpCaption1, uType);
- }
- byte [] lpText1 = lpText == null ? null : lpText.bytes;
- byte [] lpCaption1 = lpCaption == null ? null : lpCaption.bytes;
- return MessageBoxA (hWnd, lpText1, lpCaption1, uType);
-}
-
-public static final void MoveMemory (int Destination, TCHAR Source, int Length) {
- if (IsUnicode) {
- char [] Source1 = Source == null ? null : Source.chars;
- MoveMemory (Destination, Source1, Length);
- } else {
- byte [] Source1 = Source == null ? null : Source.bytes;
- MoveMemory (Destination, Source1, Length);
- }
-}
-
-public static final void MoveMemory (TCHAR Destination, int Source, int Length) {
- if (IsUnicode) {
- char [] Destination1 = Destination == null ? null : Destination.chars;
- MoveMemory (Destination1, Source, Length);
- } else {
- byte [] Destination1 = Destination == null ? null : Destination.bytes;
- MoveMemory (Destination1, Source, Length);
- }
-}
-
-public static final void MoveMemory (int Destination, LOGFONT Source, int Length) {
- if (IsUnicode) {
- MoveMemoryW (Destination, Source, Length);
- } else {
- MoveMemoryA (Destination, Source, Length);
- }
-}
-
-public static final void MoveMemory (LOGFONT Destination, int Source, int Length) {
- if (IsUnicode) {
- MoveMemoryW (Destination, Source, Length);
- } else {
- MoveMemoryA (Destination, Source, Length);
- }
-}
-
-public static final void MoveMemory (int Destination, NMTTDISPINFO Source, int Length) {
- if (IsUnicode) {
- MoveMemoryW (Destination, Source, Length);
- } else {
- MoveMemoryA (Destination, Source, Length);
- }
-}
-
-public static final void MoveMemory (NMTTDISPINFO Destination, int Source, int Length) {
- if (IsUnicode) {
- MoveMemoryW (Destination, Source, Length);
- } else {
- MoveMemoryA (Destination, Source, Length);
- }
-}
-
-public static final boolean PeekMessage (MSG lpMsg, int hWnd, int wMsgFilterMin, int wMsgFilterMax, int wRemoveMsg) {
- if (IsUnicode) return PeekMessageW (lpMsg, hWnd, wMsgFilterMin, wMsgFilterMax, wRemoveMsg);
- return PeekMessageA (lpMsg, hWnd, wMsgFilterMin, wMsgFilterMax, wRemoveMsg);
-}
-
-public static final boolean PostMessage (int hWnd, int Msg, int wParam, int lParam) {
- if (IsUnicode) return PostMessageW (hWnd, Msg, wParam, lParam);
- return PostMessageA (hWnd, Msg, wParam, lParam);
-}
-
-public static final boolean PostThreadMessage (int idThread, int Msg, int wParam, int lParam) {
- if (IsUnicode) return PostThreadMessageW (idThread, Msg, wParam, lParam);
- return PostThreadMessageA (idThread, Msg, wParam, lParam);
-}
-
-public static final boolean PrintDlg (PRINTDLG lppd) {
- if (IsUnicode) return PrintDlgW (lppd);
- return PrintDlgA (lppd);
-}
-
-public static final int RegEnumKeyEx (int hKey, int dwIndex, TCHAR lpName, int [] lpcName, int [] lpReserved, TCHAR lpClass, int [] lpcClass, FILETIME lpftLastWriteTime) {
- if (IsUnicode) {
- char [] lpName1 = lpName == null ? null : lpName.chars;
- char [] lpClass1 = lpClass == null ? null : lpClass.chars;
- return RegEnumKeyExW (hKey, dwIndex, lpName1, lpcName, lpReserved, lpClass1, lpcClass, lpftLastWriteTime);
- }
- byte [] lpName1 = lpName == null ? null : lpName.bytes;
- byte [] lpClass1 = lpClass == null ? null : lpClass.bytes;
- return RegEnumKeyExA (hKey, dwIndex, lpName1, lpcName, lpReserved, lpClass1, lpcClass, lpftLastWriteTime);
-}
-
-public static final int RegisterClass (WNDCLASS lpWndClass) {
- if (IsUnicode) return RegisterClassW (lpWndClass);
- return RegisterClassA (lpWndClass);
-}
-
-public static final int RegisterClipboardFormat (TCHAR lpszFormat) {
- if (IsUnicode) {
- char [] lpszFormat1 = lpszFormat == null ? null : lpszFormat.chars;
- return RegisterClipboardFormatW (lpszFormat1);
- }
- byte [] lpszFormat1 = lpszFormat == null ? null : lpszFormat.bytes;
- return RegisterClipboardFormatA (lpszFormat1);
-}
-
-public static final int RegOpenKeyEx (int hKey, TCHAR lpSubKey, int ulOptions, int samDesired, int[] phkResult) {
- if (IsUnicode) {
- char [] lpSubKey1 = lpSubKey == null ? null : lpSubKey.chars;
- return RegOpenKeyExW (hKey, lpSubKey1, ulOptions, samDesired, phkResult);
- }
- byte [] lpSubKey1 = lpSubKey == null ? null : lpSubKey.bytes;
- return RegOpenKeyExA (hKey, lpSubKey1, ulOptions, samDesired, phkResult);
-}
-
-public static final 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){
- if (IsUnicode) return RegQueryInfoKeyW (hKey, lpClass, lpcbClass, lpReserved, lpSubKeys, lpcbMaxSubKeyLen, lpcbMaxClassLen, lpcValues, lpcbMaxValueNameLen, lpcbMaxValueLen, lpcbSecurityDescriptor, lpftLastWriteTime);
- return RegQueryInfoKeyA (hKey, lpClass, lpcbClass, lpReserved, lpSubKeys, lpcbMaxSubKeyLen, lpcbMaxClassLen, lpcValues, lpcbMaxValueNameLen, lpcbMaxValueLen, lpcbSecurityDescriptor, lpftLastWriteTime);
-}
-
-public static final int RegQueryValueEx (int hKey, TCHAR lpValueName, int lpReserved, int[] lpType, TCHAR lpData, int[] lpcbData) {
- if (IsUnicode) {
- char [] lpValueName1 = lpValueName == null ? null : lpValueName.chars;
- char [] lpData1 = lpData == null ? null : lpData.chars;
- return RegQueryValueExW (hKey, lpValueName1, lpReserved, lpType, lpData1, lpcbData);
- }
- byte [] lpValueName1 = lpValueName == null ? null : lpValueName.bytes;
- byte [] lpData1 = lpData == null ? null : lpData.bytes;
- return RegQueryValueExA (hKey, lpValueName1, lpReserved, lpType, lpData1, lpcbData);
-}
-
-public static final int SendMessage (int hWnd, int Msg, int wParam, TCHAR lParam) {
- if (IsUnicode) {
- char [] lParam1 = lParam == null ? null : lParam.chars;
- return SendMessageW (hWnd, Msg, wParam, lParam1);
- }
- byte [] lParam1 = lParam == null ? null : lParam.bytes;
- return SendMessageA (hWnd, Msg, wParam, lParam1);
-}
-
-public static final int SendMessage (int hWnd, int Msg, int [] wParam, int [] lParam) {
- if (IsUnicode) return SendMessageW (hWnd, Msg, wParam, lParam);
- return SendMessageA (hWnd, Msg, wParam, lParam);
-}
-
-public static final int SendMessage (int hWnd, int Msg, int [] wParam, int lParam) {
- if (IsUnicode) return SendMessageW (hWnd, Msg, wParam, lParam);
- return SendMessageA (hWnd, Msg, wParam, lParam);
-}
-
-public static final int SendMessage (int hWnd, int Msg, int wParam, int [] lParam) {
- if (IsUnicode) return SendMessageW (hWnd, Msg, wParam, lParam);
- return SendMessageA (hWnd, Msg, wParam, lParam);
-}
-
-public static final int SendMessage (int hWnd, int Msg, int wParam, short [] lParam) {
- if (IsUnicode) return SendMessageW (hWnd, Msg, wParam, lParam);
- return SendMessageA (hWnd, Msg, wParam, lParam);
-}
-
-public static final int SendMessage (int hWnd, int Msg, int wParam, int lParam) {
- if (IsUnicode) return SendMessageW (hWnd, Msg, wParam, lParam);
- return SendMessageA (hWnd, Msg, wParam, lParam);
-}
-
-public static final int SendMessage (int hWnd, int Msg, int wParam, LVCOLUMN lParam) {
- if (IsUnicode) return SendMessageW (hWnd, Msg, wParam, lParam);
- return SendMessageA (hWnd, Msg, wParam, lParam);
-}
-
-public static final int SendMessage (int hWnd, int Msg, int wParam, LVHITTESTINFO lParam) {
- if (IsUnicode) return SendMessageW (hWnd, Msg, wParam, lParam);
- return SendMessageA (hWnd, Msg, wParam, lParam);
-}
-
-public static final int SendMessage (int hWnd, int Msg, int wParam, LVITEM lParam) {
- if (IsUnicode) return SendMessageW (hWnd, Msg, wParam, lParam);
- return SendMessageA (hWnd, Msg, wParam, lParam);
-}
-
-public static final int SendMessage (int hWnd, int Msg, int wParam, REBARBANDINFO lParam) {
- if (IsUnicode) return SendMessageW (hWnd, Msg, wParam, lParam);
- return SendMessageA (hWnd, Msg, wParam, lParam);
-}
-
-public static final int SendMessage (int hWnd, int Msg, int wParam, RECT lParam) {
- if (IsUnicode) return SendMessageW (hWnd, Msg, wParam, lParam);
- return SendMessageA (hWnd, Msg, wParam, lParam);
-}
-
-public static final int SendMessage (int hWnd, int Msg, int wParam, TBBUTTON lParam) {
- if (IsUnicode) return SendMessageW (hWnd, Msg, wParam, lParam);
- return SendMessageA (hWnd, Msg, wParam, lParam);
-}
-
-public static final int SendMessage (int hWnd, int Msg, int wParam, TBBUTTONINFO lParam) {
- if (IsUnicode) return SendMessageW (hWnd, Msg, wParam, lParam);
- return SendMessageA (hWnd, Msg, wParam, lParam);
-}
-
-public static final int SendMessage (int hWnd, int Msg, int wParam, TCITEM lParam) {
- if (IsUnicode) return SendMessageW (hWnd, Msg, wParam, lParam);
- return SendMessageA (hWnd, Msg, wParam, lParam);
-}
-
-public static final int SendMessage (int hWnd, int Msg, int wParam, TOOLINFO lParam) {
- if (IsUnicode) return SendMessageW (hWnd, Msg, wParam, lParam);
- return SendMessageA (hWnd, Msg, wParam, lParam);
-}
-
-public static final int SendMessage (int hWnd, int Msg, int wParam, TVHITTESTINFO lParam) {
- if (IsUnicode) return SendMessageW (hWnd, Msg, wParam, lParam);
- return SendMessageA (hWnd, Msg, wParam, lParam);
-}
-
-public static final int SendMessage (int hWnd, int Msg, int wParam, TVINSERTSTRUCT lParam) {
- if (IsUnicode) return SendMessageW (hWnd, Msg, wParam, lParam);
- return SendMessageA (hWnd, Msg, wParam, lParam);
-}
-
-public static final int SendMessage (int hWnd, int Msg, int wParam, TVITEM lParam) {
- if (IsUnicode) return SendMessageW (hWnd, Msg, wParam, lParam);
- return SendMessageA (hWnd, Msg, wParam, lParam);
-}
-
-public static final boolean SetMenuItemInfo (int hMenu, int uItem, boolean fByPosition, MENUITEMINFO lpmii) {
- if (IsUnicode) return SetMenuItemInfoW (hMenu, uItem, fByPosition, lpmii);
- return SetMenuItemInfoA (hMenu, uItem, fByPosition, lpmii);
-}
-
-public static final int SetWindowLong (int hWnd, int nIndex, int dwNewLong) {
- if (IsUnicode) return SetWindowLongW (hWnd, nIndex, dwNewLong);
- return SetWindowLongA (hWnd, nIndex, dwNewLong);
-}
-
-public static final int SetWindowsHookEx (int idHook, int lpfn, int hMod, int dwThreadId) {
- if (IsUnicode) return SetWindowsHookExW (idHook, lpfn, hMod, dwThreadId);
- return SetWindowsHookExA (idHook, lpfn, hMod, dwThreadId);
-}
-
-public static final boolean SetWindowText (int hWnd, TCHAR lpString) {
- if (IsUnicode) {
- char [] lpString1 = lpString == null ? null : lpString.chars;
- return SetWindowTextW (hWnd, lpString1);
- }
- byte [] lpString1 = lpString == null ? null : lpString.bytes;
- return SetWindowTextA (hWnd, lpString1);
-}
-
-public static final int SHBrowseForFolder (BROWSEINFO lpbi) {
- if (IsUnicode) return SHBrowseForFolderW (lpbi);
- return SHBrowseForFolderA (lpbi);
-}
-
-public static final boolean ShellExecuteEx (SHELLEXECUTEINFO lpExecInfo) {
- if (IsUnicode) return ShellExecuteExW (lpExecInfo);
- return ShellExecuteExA (lpExecInfo);
-}
-
-public static final boolean SHGetPathFromIDList (int pidl, TCHAR pszPath) {
- if (IsUnicode) {
- char [] pszPath1 = pszPath == null ? null : pszPath.chars;
- return SHGetPathFromIDListW (pidl, pszPath1);
- }
- byte [] pszPath1 = pszPath == null ? null : pszPath.bytes;
- return SHGetPathFromIDListA (pidl, pszPath1);
-}
-
-public static final int StartDoc (int hdc, DOCINFO lpdi) {
- if (IsUnicode) return StartDocW (hdc, lpdi);
- return StartDocA (hdc, lpdi);
-}
-
-public static final boolean SystemParametersInfo (int uiAction, int uiParam, RECT pvParam, int fWinIni) {
- if (IsUnicode) return SystemParametersInfoW (uiAction, uiParam, pvParam, fWinIni);
- return SystemParametersInfoA (uiAction, uiParam, pvParam, fWinIni);
-}
-
-public static final boolean SystemParametersInfo (int uiAction, int uiParam, NONCLIENTMETRICS pvParam, int fWinIni) {
- if (IsUnicode) return SystemParametersInfoW (uiAction, uiParam, pvParam, fWinIni);
- return SystemParametersInfoA (uiAction, uiParam, pvParam, fWinIni);
-}
-
-public static final boolean SystemParametersInfo (int uiAction, int uiParam, int[] pvParam, int fWinIni) {
- if (IsUnicode) return SystemParametersInfoW (uiAction, uiParam, pvParam, fWinIni);
- return SystemParametersInfoA (uiAction, uiParam, pvParam, fWinIni);
-}
-
-public static final int TranslateAccelerator (int hWnd, int hAccTable, MSG lpMsg) {
- if (IsUnicode) return TranslateAcceleratorW (hWnd, hAccTable, lpMsg);
- return TranslateAcceleratorA (hWnd, hAccTable, lpMsg);
-}
-
-public static final boolean UnregisterClass (TCHAR lpClassName, int hInstance) {
- if (IsUnicode) {
- char [] lpClassName1 = lpClassName == null ? null : lpClassName.chars;
- return UnregisterClassW (lpClassName1, hInstance);
- }
- byte [] lpClassName1 = lpClassName == null ? null : lpClassName.bytes;
- return UnregisterClassA (lpClassName1, hInstance);
-}
-
-public static final short VkKeyScan (short ch) {
- if (IsUnicode) return VkKeyScanW (ch);
- return VkKeyScanA (ch);
-}
-
-/** Natives */
-public static final native int AbortDoc (int hdc);
-public static final native int ActivateKeyboardLayout(int hkl, int Flags);
-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 CallNextHookEx(int hhk, int nCode, int wParam, int lParam);
-public static final native int CallWindowProcW (int lpPrevWndFunc, int hWnd, int Msg, int wParam, int lParam);
-public static final native int CallWindowProcA (int lpPrevWndFunc, int hWnd, int Msg, int wParam, int lParam);
-public static final native short CharLowerW (short ch);
-public static final native short CharLowerA (short ch);
-public static final native short CharUpperW (short ch);
-public static final native short CharUpperA (short ch);
-public static final native boolean CheckMenuItem (int hmenu, int uIDCheckItem, int uCheck);
-public static final native boolean ChooseColorW (CHOOSECOLOR lpcc);
-public static final native boolean ChooseColorA (CHOOSECOLOR lpcc);
-public static final native boolean ChooseFontW (CHOOSEFONT chooseFont);
-public static final native boolean ChooseFontA (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, int hrgnSrc1, int hrgnSrc2, int fnCombineMode);
-public static final native boolean CommandBar_AddAdornments (int hwndCB, int dwFlags, int dwReserved);
-public static final native int CommandBar_Create (int hInst, int hwndParent, int idCmdBar);
-public static final native void CommandBar_Destroy (int hwndCB);
-public static final native boolean CommandBar_DrawMenuBar (int hwndCB, int iButton);
-public static final native int CommandBar_Height (int hdnwCB);
-public static final native boolean CommandBar_InsertMenubarEx (int hwndCB, int hInst, int pszMenu, int iButton);
-public static final native boolean CommandBar_Show (int hwndCB, boolean fShow);
-public static final native int CommDlgExtendedError ();
-public static final native int CopyImage (int hImage, int uType, int cxDesired, int cyDesired, int fuFlags);
-public static final native int CreateAcceleratorTableW (byte [] lpaccl, int cEntries);
-public static final native int CreateAcceleratorTableA (byte [] lpaccl, int cEntries);
-public static final native int CreateBitmap (int nWidth, int nHeight, int cPlanes, int cBitsPerPel, byte [] lpvBits);
-public static final native boolean CreateCaret (int hWnd, int hBitmap, int nWidth, int nHeight);
-public static final native int CreateCompatibleBitmap (int hdc, int nWidth, int nHeight);
-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 CreateDCW (char [] lpszDriver, char [] lpszDevice, int lpszOutput, int lpInitData);
-public static final native int CreateDCA (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 CreateFontIndirectW (int lplf);
-public static final native int CreateFontIndirectA (int lplf);
-public static final native int CreateFontIndirectW (LOGFONT lplf);
-public static final native int CreateFontIndirectA (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 CreatePen (int fnPenStyle, int nWidth, int crColor);
-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 CreateWindowExW (int dwExStyle, char [] lpClassName, char [] lpWindowName, int dwStyle, int X, int Y, int nWidth, int nHeight, int hWndParent, int hMenu, int hInstance, CREATESTRUCT lpParam);
-public static final native int CreateWindowExA (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 DefWindowProcW (int hWnd, int Msg, int wParam, int lParam);
-public static final native int DefWindowProcA (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 DispatchMessageW (MSG lpmsg);
-public static final native int DispatchMessageA (MSG lpmsg);
-public static final native boolean DragDetect (int hwnd, POINT pt);
-public static final native void DragFinish (int hDrop);
-public static final native int DragQueryFileA (int hDrop, int iFile, byte[] lpszFile, int cch);
-public static final native int DragQueryFileW (int hDrop, int iFile, char[] lpszFile, int cch);
-public static final native boolean DrawEdge (int hdc, RECT qrc, int edge, int grfFlags);
-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, int xLeft, int yTop, int hIcon, int cxWidth, int cyWidth, int istepIfAniCur, int hbrFlickerFreeDraw, int diFlags);
-public static final native boolean DrawMenuBar (int hWnd);
-public static final native boolean DrawStateW (int hdc, int hbr, int lpOutputFunc, int lData, int wData, int x, int y, int cx, int cy, int fuFlags);
-public static final native boolean DrawStateA (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 DrawTextW (int hDC, char [] lpString, int nCount, RECT lpRect, int uFormat);
-public static final native int DrawTextA (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 EnumSystemLanguageGroupsW(int pLangGroupEnumProc, int dwFlags, int lParam);
-public static final native boolean EnumSystemLanguageGroupsA(int pLangGroupEnumProc, int dwFlags, int lParam);
-public static final native boolean EnumSystemLocalesW (int lpLocaleEnumProc, int dwFlags);
-public static final native boolean EnumSystemLocalesA (int lpLocaleEnumProc, int dwFlags);
-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 EnumFontFamiliesW (int hdc, char [] lpszFamily, int lpEnumFontFamProc, int lParam);
-public static final native int EnumFontFamiliesA (int hdc, byte [] lpszFamily, int lpEnumFontFamProc, int lParam);
-public static final native boolean EqualRect (RECT lprc1, RECT lprc2);
-public static final native boolean EqualRgn (int hSrcRgn1, int hSrcRgn2);
-public static final native int ExpandEnvironmentStringsW (char [] lpSrc, char [] lsDst, int nSize);
-public static final native int ExpandEnvironmentStringsA (byte [] lpSrc, byte [] lsDst, int nSize);
-public static final native boolean ExtTextOutW(int hdc, int X, int Y, int fuOptions, RECT lprc, char[] lpString, int cbCount, int[] lpDx);
-public static final native boolean ExtTextOutA(int hdc, int X, int Y, int fuOptions, RECT lprc, byte[] lpString, int cbCount, int[] lpDx);
-public static final native int ExtractIconExW (char [] lpszFile, int nIconIndex, int [] phiconLarge, int [] phiconSmall, int nIcons);
-public static final native int ExtractIconExA (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 int FindWindowA (byte [] lpClassName, byte [] lpWindowName);
-public static final native int FindWindowW (char [] lpClassName, char [] lpWindowName);
-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 GetCharABCWidthsA (int hdc, int iFirstChar, int iLastChar, int [] lpabc);
-public static final native boolean GetCharABCWidthsW (int hdc, int iFirstChar, int iLastChar, int [] lpabc);
-public static final native int GetCharacterPlacementW(int hdc, char[] lpString, int nCount, int nMaxExtent, GCP_RESULTS lpResults, int dwFlags);
-public static final native int GetCharacterPlacementA(int hdc, byte[] lpString, int nCount, int nMaxExtent, GCP_RESULTS lpResults, int dwFlags);
-public static final native boolean GetCharWidthA (int hdc, int iFirstChar, int iLastChar, int [] lpBuffer);
-public static final native boolean GetCharWidthW (int hdc, int iFirstChar, int iLastChar, int [] lpBuffer);
-public static final native boolean GetClassInfoW (int hInstance, char [] lpClassName, WNDCLASS lpWndClass);
-public static final native boolean GetClassInfoA (int hInstance, byte [] lpClassName, WNDCLASS lpWndClass);
-public static final native boolean GetClientRect (int hWnd, RECT lpRect);
-public static final native int GetClipboardData (int uFormat);
-public static final native int GetClipboardFormatNameA (int format, byte[] lpszFormatName, int cchMaxCount);
-public static final native int GetClipboardFormatNameW (int format, char[] lpszFormatName, int cchMaxCount);
-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, int nIDDlgItem);
-public static final native int GetDoubleClickTime ();
-public static final native int GetFocus ();
-public static final native int GetFontLanguageInfo(int hdc);
-public static final native boolean GetIconInfo (int hIcon, ICONINFO piconinfo);
-public static final native int GetKeyboardLayoutList(int nBuff, int[] lpList);
-public static final native int GetKeyboardLayout(int idThread);public static final native short GetKeyState (int nVirtKey);
-public static final native boolean GetKeyboardState (byte [] lpKeyState);
-public static final native int GetKeyNameTextW(int lParam, char [] lpString, int nSize);
-public static final native int GetKeyNameTextA(int lParam, byte [] lpString, int nSize);
-public static final native int GetLastActivePopup (int hWnd);
-public static final native int GetLastError ();
-/* returns the instance handle to the swt library */
-public static final native int GetLibraryHandle ();
-public static final native int GetLocaleInfoW (int Locale, int LCType, char [] lpLCData, int cchData);
-public static final native int GetLocaleInfoA (int Locale, int LCType, byte [] lpLCData, int cchData);
-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 GetMenuItemInfoW (int hMenu, int uItem, boolean fByPosition, MENUITEMINFO lpmii);
-public static final native boolean GetMenuItemInfoA (int hMenu, int uItem, boolean fByPosition, MENUITEMINFO lpmii);
-public static final native boolean GetMessageW (MSG lpMsg, int hWnd, int wMsgFilterMin, int wMsgFilterMax);
-public static final native boolean GetMessageA (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 GetTextCharset(int hdc);
-public static final native int GetTickCount ();
-public static final native int GetModuleHandleW (char [] lpModuleName);
-public static final native int GetModuleHandleA (byte [] lpModuleName);
-public static final native int GetNearestPaletteIndex(int hPal, int crColor);
-public static final native int GetObjectA (int hgdiobj, int cbBuffer, BITMAP lpvObject);
-public static final native int GetObjectW (int hgdiobj, int cbBuffer, BITMAP lpvObject);
-public static final native int GetObjectA (int hgdiobj, int cbBuffer, DIBSECTION lpvObject);
-public static final native int GetObjectW (int hgdiobj, int cbBuffer, DIBSECTION lpvObject);
-public static final native int GetObjectA (int hgdiobj, int cbBuffer, LOGBRUSH lpvObject);
-public static final native int GetObjectW (int hgdiobj, int cbBuffer, LOGBRUSH lpvObject);
-public static final native int GetObjectA (int hgdiobj, int cbBuffer, LOGFONT lpvObject);
-public static final native int GetObjectW (int hgdiobj, int cbBuffer, LOGFONT lpvObject);
-public static final native int GetObjectA (int hgdiobj, int cbBuffer, LOGPEN lpvObject);
-public static final native int GetObjectW (int hgdiobj, int cbBuffer, LOGPEN lpvObject);
-public static final native boolean GetOpenFileNameW (OPENFILENAME lpofn);
-public static final native boolean GetOpenFileNameA (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 GetPixel (int hdc, int x, int y);
-public static final native int GetProcAddress (int hModule, byte [] lpProcName);
-public static final native int GetProcessHeap ();
-public static final native int GetProfileStringW (char [] lpAppName, char [] lpKeyName, char [] lpDefault, char [] lpReturnedString, int nSize);
-public static final native int GetProfileStringA (byte [] lpAppName, byte [] lpKeyName, byte [] lpDefault, byte [] lpReturnedString, int nSize);
-public static final native int GetRegionData (int hRgn, int dwCount, int [] lpRgnData);
-public static final native int GetRgnBox (int hrgn, RECT lprc);
-public static final native int GetROP2 (int hdc);
-public static final native boolean GetSaveFileNameW (OPENFILENAME lpofn);
-public static final native boolean GetSaveFileNameA (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 GetSystemPaletteEntries(int hdc, int iStartIndex, int nEntries, byte[] lppe);
-public static final native int GetTextColor (int hDC);
-public static final native boolean GetTextExtentPoint32W (int hdc, char [] lpString, int cbString, SIZE lpSize);
-public static final native boolean GetTextExtentPoint32A (int hdc, byte [] lpString, int cbString, SIZE lpSize);
-public static final native boolean GetTextMetricsW (int hdc, TEXTMETRIC lptm);
-public static final native boolean GetTextMetricsA (int hdc, TEXTMETRIC lptm);
-public static final native boolean GetUpdateRect (int hWnd, RECT lpRect, boolean bErase);
-public static final native int GetUpdateRgn (int hWnd, int hRgn, boolean bErase);
-public static final native boolean GetVersionExW (OSVERSIONINFO lpVersionInfo);
-public static final native boolean GetVersionExA (OSVERSIONINFO lpVersionInfo);
-public static final native int GetWindow (int hWnd, int uCmd);
-public static final native int GetWindowLongW (int hWnd, int nIndex);
-public static final native int GetWindowLongA (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 GetWindowTextW (int hWnd, char [] lpString, int nMaxCount);
-public static final native int GetWindowTextA (int hWnd, byte [] lpString, int nMaxCount);
-public static final native int GetWindowTextLengthW (int hWnd);
-public static final native int GetWindowTextLengthA (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 boolean GradientFill(int hdc, int pVertex, int dwNumVertex, int pMesh, int dwNumMesh, int dwMode);
-public static final native int HeapAlloc (int hHeap, int dwFlags, int dwBytes);
-public static final native boolean HeapFree (int hHeap, int dwFlags, int lpMem);
-public static final native boolean HideCaret (int hWnd);
-public static final native int ImageList_Add (int himl, int hbmImage, int hbmMask);
-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 ImmGetCompositionFontW (int hIMC, LOGFONT lplf);
-public static final native boolean ImmGetCompositionFontA (int hIMC, LOGFONT lplf);
-public static final native int ImmGetCompositionStringW (int hIMC, int dwIndex, char [] lpBuf, int dwBufLen);
-public static final native int ImmGetCompositionStringA (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 ImmSetCompositionFontW (int hIMC, LOGFONT lplf);
-public static final native boolean ImmSetCompositionFontA (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 InsertMenuW (int hMenu, int uPosition, int uFlags, int uIDNewItem, char [] lpNewItem);
-public static final native boolean InsertMenuA (int hMenu, int uPosition, int uFlags, int uIDNewItem, byte [] lpNewItem);
-public static final native boolean InsertMenuItemW (int hMenu, int uItem, boolean fByPosition, MENUITEMINFO lpmii);
-public static final native boolean InsertMenuItemA (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 IsPPC();
-public static final native boolean IsSP();
-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 KillTimer (int hWnd, int uIDEvent);
-public static final native boolean LineTo (int hdc,int x1, int x2);
-public static final native int LoadBitmapW (int hInstance, int lpBitmapName);
-public static final native int LoadBitmapA (int hInstance, int lpBitmapName);
-public static final native int LoadCursorW (int hInstance, int lpCursorName);
-public static final native int LoadCursorA (int hInstance, int lpCursorName);
-public static final native int LoadIconW (int hInstance, int lpIconName);
-public static final native int LoadIconA (int hInstance, int lpIconName);
-public static final native int LoadImageW (int hinst, char [] lpszName, int uType, int cxDesired, int cyDesired, int fuLoad);
-public static final native int LoadImageA (int hinst, byte [] lpszName, int uType, int cxDesired, int cyDesired, int fuLoad);
-public static final native int LoadLibraryW (char [] lpLibFileName);
-public static final native int LoadLibraryA (byte [] lpLibFileName);
-public static final native int MapVirtualKeyW (int uCode, int uMapType);
-public static final native int MapVirtualKeyA (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 MessageBoxW (int hWnd, char [] lpText, char [] lpCaption, int uType);
-public static final native int MessageBoxA (int hWnd, byte [] lpText, byte [] lpCaption, int uType);
-public static final native void MoveMemory (char[] Destination, int SourcePtr, int Length);
-public static final native void MoveMemory (byte [] Destination, int Source, int Length);
-public static final native void MoveMemory (byte [] Destination, ACCEL Source, int Length);
-public static final native void MoveMemory (byte [] Destination, BITMAPINFOHEADER Source, int Length);
-public static final native void MoveMemory (int [] Destination, int Source, int Length);
-public static final native void MoveMemory (int Destination, byte [] Source, int Length);
-public static final native void MoveMemory (int Destination, char [] Source, int Length);
-public static final native void MoveMemory (int Destination, int [] Source, int Length);
-public static final native void MoveMemory (int Destination, GRADIENT_RECT Source, int Length);
-public static final native void MoveMemoryW (int Destination, LOGFONT Source, int Length);
-public static final native void MoveMemoryA (int Destination, LOGFONT Source, int Length);
-public static final native void MoveMemory (int Destination, MEASUREITEMSTRUCT Source, int Length);
-public static final native void MoveMemoryW (int Destination, NMTTDISPINFO Source, int Length);
-public static final native void MoveMemoryA (int Destination, NMTTDISPINFO Source, int Length);
-public static final native void MoveMemory (int Destination, RECT Source, int Length);
-public static final native void MoveMemory (int Destination, TRIVERTEX Source, int Length);
-public static final native void MoveMemory (int Destination, WINDOWPOS Source, int Length);
-public static final native void MoveMemory (BITMAPINFOHEADER Destination, byte [] Source, int Length);
-public static final native void MoveMemory (DRAWITEMSTRUCT Destination, int Source, int Length);
-public static final native void MoveMemory (HDITEM Destination, int Source, int Length);
-public static final native void MoveMemory (HELPINFO Destination, int Source, int Length);
-public static final native void MoveMemoryW (LOGFONT Destination, int Source, int Length);
-public static final native void MoveMemoryA (LOGFONT Destination, int Source, int Length);
-public static final native void MoveMemory (MEASUREITEMSTRUCT Destination, int Source, int Length);
-public static final native void MoveMemory (NMHDR Destination, int Source, int Length);
-public static final native void MoveMemory (NMLVCUSTOMDRAW Destination, int Source, int Length);
-public static final native void MoveMemory (NMTVCUSTOMDRAW Destination, int Source, int Length);
-public static final native void MoveMemory (int Destination, NMLVCUSTOMDRAW Source, int Length);
-public static final native void MoveMemory (int Destination, NMTVCUSTOMDRAW Source, int Length);
-public static final native void MoveMemory (NMHEADER Destination, int Source, int Length);
-public static final native void MoveMemory (NMLISTVIEW Destination, int Source, int Length);
-public static final native void MoveMemory (NMREBARCHEVRON Destination, int Source, int Length);
-public static final native void MoveMemory (NMTOOLBAR Destination, int Source, int Length);
-public static final native void MoveMemoryW (NMTTDISPINFO Destination, int Source, int Length);
-public static final native void MoveMemoryA (NMTTDISPINFO Destination, int Source, int Length);
-public static final native void MoveMemory (TVITEM Destination, int Source, int Length);
-public static final native void MoveMemory (WINDOWPOS Destination, int Source, int Length);
-public static final native void MoveMemory (MSG Destination, int Source, int Length);
-public static final native void MoveMemory(int Destination, DROPFILES Source, 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 boolean MoveToEx (int hdc,int x1, int x2, int lPoint);
-public static final native int MsgWaitForMultipleObjectsEx (int nCount, int pHandles, int dwMilliseconds, int dwWakeMask, int dwFlags);
-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 PeekMessageW (MSG lpMsg, int hWnd, int wMsgFilterMin, int wMsgFilterMax, int wRemoveMsg);
-public static final native boolean PeekMessageA (MSG lpMsg, int hWnd, int wMsgFilterMin, int wMsgFilterMax, int wRemoveMsg);
-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 PostMessageW (int hWnd, int Msg, int wParam, int lParam);
-public static final native boolean PostMessageA (int hWnd, int Msg, int wParam, int lParam);
-public static final native boolean PostThreadMessageW (int idThread, int Msg, int wParam, int lParam);
-public static final native boolean PostThreadMessageA (int idThread, int Msg, int wParam, int lParam);
-public static final native boolean PrintDlgW (PRINTDLG lppd);
-public static final native boolean PrintDlgA (PRINTDLG lppd);
-public static final native boolean PtInRect (RECT rect, POINT pt);
-public static final native boolean PtInRegion (int hrgn, int X, int Y);
-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, RECT lprc);
-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 RegisterClassW (WNDCLASS lpWndClass);
-public static final native int RegisterClassA (WNDCLASS lpWndClass);
-public static final native int RegEnumKeyExW (int hKey, int dwIndex, char [] lpName, int [] lpcName, int [] lpReserved, char [] lpClass, int [] lpcClass, FILETIME lpftLastWriteTime);
-public static final native int RegisterClipboardFormatA (byte[] lpszFormat);
-public static final native int RegisterClipboardFormatW (char[] lpszFormat);
-public static final native int RegOpenKeyExW (int hKey, char[] lpSubKey, int ulOptions, int samDesired, int[] phkResult);
-public static final native int RegQueryInfoKeyW (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 RegQueryValueExW (int hKey, char[] lpValueName, int lpReserved, int[] lpType, char [] lpData, int[] lpcbData);
-public static final native int RegEnumKeyExA (int hKey, int dwIndex, byte [] lpName, int [] lpcName, int [] lpReserved, byte [] lpClass, int [] lpcClass, FILETIME lpftLastWriteTime);
-public static final native int RegOpenKeyExA (int hKey, byte[] lpSubKey, int ulOptions, int samDesired, int[] phkResult);
-public static final native int RegQueryInfoKeyA (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 RegQueryValueExA (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 SendMessageW (int hWnd, int Msg, int [] wParam, int [] lParam);
-public static final native int SendMessageW (int hWnd, int Msg, int [] wParam, int lParam);
-public static final native int SendMessageW (int hWnd, int Msg, int wParam, char [] lParam);
-public static final native int SendMessageW (int hWnd, int Msg, int wParam, int [] lParam);
-public static final native int SendMessageW (int hWnd, int Msg, int wParam, short [] lParam);
-public static final native int SendMessageW (int hWnd, int Msg, int wParam, int lParam);
-public static final native int SendMessageW (int hWnd, int Msg, int wParam, LVCOLUMN lParam);
-public static final native int SendMessageW (int hWnd, int Msg, int wParam, LVHITTESTINFO lParam);
-public static final native int SendMessageW (int hWnd, int Msg, int wParam, LVITEM lParam);
-public static final native int SendMessageW (int hWnd, int Msg, int wParam, REBARBANDINFO lParam);
-public static final native int SendMessageW (int hWnd, int Msg, int wParam, RECT lParam);
-public static final native int SendMessageW (int hWnd, int Msg, int wParam, TBBUTTON lParam);
-public static final native int SendMessageW (int hWnd, int Msg, int wParam, TBBUTTONINFO lParam);
-public static final native int SendMessageW (int hWnd, int Msg, int wParam, TCITEM lParam);
-public static final native int SendMessageW (int hWnd, int Msg, int wParam, TOOLINFO lParam);
-public static final native int SendMessageW (int hWnd, int Msg, int wParam, TVHITTESTINFO lParam);
-public static final native int SendMessageW (int hWnd, int Msg, int wParam, TVINSERTSTRUCT lParam);
-public static final native int SendMessageW (int hWnd, int Msg, int wParam, TVITEM lParam);
-public static final native int SendMessageA (int hWnd, int Msg, int [] wParam, int [] lParam);
-public static final native int SendMessageA (int hWnd, int Msg, int [] wParam, int lParam);
-public static final native int SendMessageA (int hWnd, int Msg, int wParam, byte [] lParam);
-public static final native int SendMessageA (int hWnd, int Msg, int wParam, int [] lParam);
-public static final native int SendMessageA (int hWnd, int Msg, int wParam, short [] lParam);
-public static final native int SendMessageA (int hWnd, int Msg, int wParam, int lParam);
-public static final native int SendMessageA (int hWnd, int Msg, int wParam, LVCOLUMN lParam);
-public static final native int SendMessageA (int hWnd, int Msg, int wParam, LVHITTESTINFO lParam);
-public static final native int SendMessageA (int hWnd, int Msg, int wParam, LVITEM lParam);
-public static final native int SendMessageA (int hWnd, int Msg, int wParam, REBARBANDINFO lParam);
-public static final native int SendMessageA (int hWnd, int Msg, int wParam, RECT lParam);
-public static final native int SendMessageA (int hWnd, int Msg, int wParam, TBBUTTON lParam);
-public static final native int SendMessageA (int hWnd, int Msg, int wParam, TBBUTTONINFO lParam);
-public static final native int SendMessageA (int hWnd, int Msg, int wParam, TCITEM lParam);
-public static final native int SendMessageA (int hWnd, int Msg, int wParam, TOOLINFO lParam);
-public static final native int SendMessageA (int hWnd, int Msg, int wParam, TVHITTESTINFO lParam);
-public static final native int SendMessageA (int hWnd, int Msg, int wParam, TVINSERTSTRUCT lParam);
-public static final native int SendMessageA (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 boolean SetCursorPos (int X, int Y);
-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 boolean SetForegroundWindow (int hWnd);
-public static final native int SetLayout (int hdc, int dwLayout);
-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 SetMenuItemInfoW (int hMenu, int uItem, boolean fByPosition, MENUITEMINFO lpmii);
-public static final native boolean SetMenuItemInfoA (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 SetStretchBltMode(int hdc, int iStretchMode);
-public static final native int SetTextAlign(int hdc, int fMode);
-public static final native int SetTextColor (int hdc, int colorRef);
-public static final native int SetTimer (int hWnd, int nIDEvent, int Elapse, int lpTimerFunc);
-public static final native int SetWindowLongW (int hWnd, int nIndex, int dwNewLong);
-public static final native int SetWindowLongA (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 SetWindowTextW (int hWnd, char [] lpString);
-public static final native boolean SetWindowTextA (int hWnd, byte [] lpString);
-public static final native int SetWindowsHookExW (int idHook, int lpfn, int hMod, int dwThreadId);
-public static final native int SetWindowsHookExA (int idHook, int lpfn, int hMod, int dwThreadId);
-public static final native int SHBrowseForFolderW (BROWSEINFO lpbi);
-public static final native int SHBrowseForFolderA (BROWSEINFO lpbi);
-public static final native boolean SHCreateMenuBar(SHMENUBARINFO pmb);
-public static final native boolean SHHandleWMSettingChange (int hwnd, int wParam, int lParam, SHACTIVATEINFO psai);
-public static final native int SHRecognizeGesture(SHRGINFO shrg);
-public static final native void SHSendBackToFocusWindow (int uMsg, int wp, int lp);
-public static final native boolean SHSipPreference (int hwnd, int st);
-public static final native boolean ShellExecuteExW (SHELLEXECUTEINFO lpExecInfo);
-public static final native boolean ShellExecuteExA (SHELLEXECUTEINFO lpExecInfo);
-public static final native int SHGetMalloc (int [] ppMalloc);
-public static final native boolean SHGetPathFromIDListW (int pidl, char [] pszPath);
-public static final native boolean SHGetPathFromIDListA (int pidl, byte [] pszPath);
-public static final native boolean SHSetAppKeyWndAssoc(byte bVk, int hwnd);
-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 boolean SipGetInfo (SIPINFO pSipInfo);
-public static final native int StartDocW (int hdc, DOCINFO lpdi);
-public static final native int StartDocA (int hdc, DOCINFO lpdi);
-public static final native int StartPage (int hdc);
-public static final native boolean StretchBlt (int hdcDest, int nXOriginDest, int nYOriginDest, int nWidthDest, int nHeightDest, int hdcSrc, int nXOriginSrc, int nYOriginSrc, int nWidthSrc, int nHeightSrc, int dwRop);
-public static final native boolean SystemParametersInfoW (int uiAction, int uiParam, RECT pvParam, int fWinIni);
-public static final native boolean SystemParametersInfoA (int uiAction, int uiParam, RECT pvParam, int fWinIni);
-public static final native boolean SystemParametersInfoW (int uiAction, int uiParam, NONCLIENTMETRICS pvParam, int fWinIni);
-public static final native boolean SystemParametersInfoA (int uiAction, int uiParam, NONCLIENTMETRICS pvParam, int fWinIni);
-public static final native boolean SystemParametersInfoW (int uiAction, int uiParam, int[] pvParam, int fWinIni);
-public static final native boolean SystemParametersInfoA (int uiAction, int uiParam, int[] pvParam, int fWinIni);
-public static final native int ToAscii (int uVirtKey, int uScanCode, byte [] lpKeyState, short [] lpChar, int uFlags);
-public static final native int ToUnicode(int wVirtKey, int wScanCode, byte [] lpKeyState, char [] pwszBuff, int cchBuff, int wFlags);
-public static final native boolean TrackMouseEvent(TRACKMOUSEEVENT lpEventTrack);
-public static final native boolean TrackPopupMenu (int hMenu, int uFlags, int x, int y, int nReserved, int hWnd, RECT prcRect);
-public static final native int TranslateAcceleratorW (int hWnd, int hAccTable, MSG lpMsg);
-public static final native int TranslateAcceleratorA (int hWnd, int hAccTable, MSG lpMsg);
-public static final native boolean TranslateCharsetInfo(int lpSrc, int [] lpCs, int dwFlags);
-public static final native boolean TranslateMessage (MSG lpmsg);
-public static final native boolean TransparentImage (int hdcDest, int DstX, int DstY, int DstCx, int DstCy,int hSrc, int SrcX, int SrcY, int SrcCx, int SrcCy, int TransparentColor);public static final native boolean UnhookWindowsHookEx(int hhk);
-public static final native boolean UnregisterClassW (char [] lpClassName, int hInstance);
-public static final native boolean UnregisterClassA (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 VkKeyScanW (short ch);
-public static final native short VkKeyScanA (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 WideCharToMultiByte (int CodePage, int dwFlags, char [] lpWideCharStr, int cchWideChar, int lpMultiByteStr, int cchMultiByte, byte [] lpDefaultChar, boolean [] lpUsedDefaultChar);
-public static final native int WindowFromDC (int lpPoint);
-public static final native int WindowFromPoint (POINT lpPoint);
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+import org.eclipse.swt.internal.*;
+
+public class OS {
+
+ /*
+ * SWT Windows flags.
+ */
+ public static final boolean IsWin32s;
+ public static final boolean IsWin95;
+ public static final boolean IsWinNT;
+ public static final boolean IsWinCE;
+ public static final boolean IsPPC;
+ public static final boolean IsHPC;
+ public static final boolean IsSP;
+ public static final boolean IsDBLocale;
+ public static final boolean IsUnicode;
+ public static final int WIN32_MAJOR, WIN32_MINOR;
+
+ /*
+ * Flags for Window API GetVersionEx
+ */
+ public static final int VER_PLATFORM_WIN32s = 0;
+ public static final int VER_PLATFORM_WIN32_WINDOWS = 1;
+ public static final int VER_PLATFORM_WIN32_NT = 2;
+ public static final int VER_PLATFORM_WIN32_CE = 3;
+
+ /*
+ * Initialize the Windows flags
+ */
+ static {
+
+ /* Load the SWT library */
+ Library.loadLibrary ("swt");
+
+ /*
+ * Try the UNICODE version of GetVersionEx first
+ * and then the ANSI version. The UNICODE version
+ * is present on all versions of Windows but is not
+ * implemented on Win95/98/ME.
+ *
+ * NOTE: The value of OSVERSIONINFO.sizeof cannot
+ * be static final because it relies on the Windows
+ * platform version to be initialized and IsUnicode
+ * has not been calculated. It must be initialized
+ * here, after the platform is determined in order
+ * for the value to be correct.
+ */
+ OSVERSIONINFO info = new OSVERSIONINFO ();
+
+ // TEMPORARY CODE
+ String MBCS = System.getProperty ("MBCS");
+ if (MBCS != null) {
+ info.dwOSVersionInfoSize = OSVERSIONINFO.sizeofA;
+ OS.GetVersionExA (info);
+ } else {
+ info.dwOSVersionInfoSize = OSVERSIONINFO.sizeofW;
+ if (!OS.GetVersionExW (info)) {
+ info.dwOSVersionInfoSize = OSVERSIONINFO.sizeofA;
+ OS.GetVersionExA (info);
+ }
+ }
+ OSVERSIONINFO.sizeof = info.dwOSVersionInfoSize;
+
+ IsWin32s = info.dwPlatformId == VER_PLATFORM_WIN32s;
+ IsWin95 = info.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS;
+ IsWinNT = info.dwPlatformId == VER_PLATFORM_WIN32_NT;
+ IsWinCE = info.dwPlatformId == VER_PLATFORM_WIN32_CE;
+ IsSP = IsSP();
+ IsPPC = IsPPC();
+ IsHPC = IsWinCE && !IsPPC && !IsSP;
+ WIN32_MAJOR = info.dwMajorVersion;
+ WIN32_MINOR = info.dwMinorVersion;
+
+ // TEMPORARY CODE
+ if (MBCS != null) {
+ IsUnicode = false;
+ System.out.println ("*** SWT - Warning: Unicode disabled");
+ } else {
+ IsUnicode = !IsWin32s && !IsWin95;
+ }
+
+ /* Get the DBCS flag */
+ int index = 0;
+ while (index <= 0xFF) {
+ if (OS.IsDBCSLeadByte ((byte) index)) break;
+ index++;
+ }
+ IsDBLocale = index <= 0xFF;
+ }
+
+ /* Flag used on WinCE */
+ static final int SYS_COLOR_INDEX_FLAG = OS.IsWinCE ? 0x40000000 : 0x0;
+
+ /*
+ * 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.
+ */
+
+ /* Constants */
+ public static final int BFFM_INITIALIZED = 0x1;
+ public static final int BFFM_SETSELECTION = IsUnicode ? 0x467 : 0x466;
+ public static final int BFFM_VALIDATEFAILED = IsUnicode ? 0x4 : 0x3;
+ public static final int BFFM_VALIDATEFAILEDW = 0x4;
+ public static final int BFFM_VALIDATEFAILEDA = 0x3;
+ public static final int BF_BOTTOM = 0x8;
+ public static final int BF_RIGHT = 0x4;
+ public static final int BIF_EDITBOX = 0x10;
+ public static final int BIF_NEWDIALOGSTYLE = 0x40;
+ public static final int BIF_RETURNONLYFSDIRS = 0x1;
+ public static final int BIF_VALIDATE = 0x20;
+ public static final int BITSPIXEL = 0xc;
+ public static final int BI_BITFIELDS = 3;
+ public static final int BI_RGB = 0;
+ 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_SETCHECK = 0xf1;
+ public static final int BM_SETIMAGE = 0xf7;
+ public static final int BM_SETSTYLE = 0xf4;
+ public static final int BN_CLICKED = 0x0;
+ public static final int BN_DOUBLECLICKED = 0x5;
+ public static final int BST_CHECKED = 0x1;
+ public static final int BST_UNCHECKED = 0x0;
+ public static final int BS_BITMAP = 0x80;
+ public static final int BS_CENTER = 0x300;
+ public static final int BS_CHECKBOX = 0x2;
+ public static final int BS_DEFPUSHBUTTON = 0x1;
+ public static final int BS_FLAT = 0x8000;
+ public static final int BS_GROUPBOX = 0x7;
+ public static final int BS_ICON = 0x40;
+ public static final int BS_LEFT = 0x100;
+ public static final int BS_NOTIFY = 0x4000;
+ public static final int BS_OWNERDRAW = 0xb;
+ 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_RIGHT = 0x200;
+ public static final int BS_SOLID = 0x0;
+ public static final int BTNS_AUTOSIZE = 0x10;
+ public static final int BTNS_BUTTON = 0x0;
+ public static final int BTNS_CHECK = 0x2;
+ public static final int BTNS_CHECKGROUP = 0x6;
+ public static final int BTNS_DROPDOWN = 0x8;
+ public static final int BTNS_GROUP = 0x4;
+ public static final int BTNS_SEP = 0x1;
+ public static final int CBN_EDITCHANGE = 0x5;
+ public static final int CBN_KILLFOCUS = 0x4;
+ public static final int CBN_SELCHANGE = 0x1;
+ public static final int CBN_SETFOCUS = 0x3;
+ public static final int CBS_AUTOHSCROLL = 0x40;
+ public static final int CBS_DROPDOWN = 0x2;
+ public static final int CBS_DROPDOWNLIST = 0x3;
+ public static final int CBS_NOINTEGRALHEIGHT = 0x400;
+ public static final int CBS_SIMPLE = 0x1;
+ public static final int CB_ADDSTRING = 0x143;
+ public static final int CB_DELETESTRING = 0x144;
+ public static final int CB_ERR = 0xffffffff;
+ public static final int CB_ERRSPACE = 0xfffffffe;
+ 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_GETEDITSEL = 0x140;
+ 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_INSERTSTRING = 0x14a;
+ public static final int CB_LIMITTEXT = 0x141;
+ 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_SETEDITSEL = 0x142;
+ public static final int CB_SHOWDROPDOWN = 0x14f;
+ public static final int CCM_FIRST = 0x2000;
+ public static final int CCM_SETBKCOLOR = 0x2001;
+ public static final int CCS_NODIVIDER = 0x40;
+ public static final int CCS_NORESIZE = 0x4;
+ public static final int CC_ANYCOLOR = 0x100;
+ public static final int CC_ENABLEHOOK = 0x10;
+ public static final int CC_RGBINIT = 0x1;
+ public static final int CDDS_PREPAINT = 0x00000001;
+ public static final int CDDS_ITEM = 0x00010000;
+ public static final int CDDS_ITEMPREPAINT = CDDS_ITEM | CDDS_PREPAINT;
+ public static final int CDDS_SUBITEM = 0x00020000;
+ 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_NOTIFYSUBITEMDRAW = 0x00000020;
+ public static final int CFE_AUTOCOLOR = 0x40000000;
+ public static final int CFE_ITALIC = 0x2;
+ public static final int CFE_STRIKEOUT = 0x8;
+ public static final int CFE_UNDERLINE = 0x4;
+ public static final int CFM_BOLD = 0x1;
+ public static final int CFM_CHARSET = 0x8000000;
+ public static final int CFM_COLOR = 0x40000000;
+ public static final int CFM_FACE = 0x20000000;
+ public static final int CFM_ITALIC = 0x2;
+ public static final int CFM_SIZE = 0x80000000;
+ public static final int CFM_STRIKEOUT = 0x8;
+ public static final int CFM_UNDERLINE = 0x4;
+ public static final int CFM_WEIGHT = 0x400000;
+ public static final int CFS_POINT = 0x2;
+ public static final int CF_EFFECTS = 0x100;
+ public static final int CF_INITTOLOGFONTSTRUCT = 0x40;
+ public static final int CF_SCREENFONTS = 0x1;
+ public static final int CF_TEXT = 0x1;
+ public static final int CF_UNICODETEXT = 13;
+ public static final int CF_USESTYLE = 0x80;
+ public static final int CLR_DEFAULT = 0xff000000;
+ public static final int CLR_INVALID = 0xffffffff;
+ public static final int COLORONCOLOR = 0x3;
+ public static final int COLOR_3DDKSHADOW = 0x15 | SYS_COLOR_INDEX_FLAG;
+ public static final int COLOR_3DFACE = 0xf | SYS_COLOR_INDEX_FLAG;
+ public static final int COLOR_3DHIGHLIGHT = 0x14 | SYS_COLOR_INDEX_FLAG;
+ public static final int COLOR_3DHILIGHT = 0x14 | SYS_COLOR_INDEX_FLAG;
+ public static final int COLOR_3DLIGHT = 0x16 | SYS_COLOR_INDEX_FLAG;
+ public static final int COLOR_3DSHADOW = 0x10 | SYS_COLOR_INDEX_FLAG;
+ public static final int COLOR_ACTIVECAPTION = 0x2 | SYS_COLOR_INDEX_FLAG;
+ public static final int COLOR_BTNFACE = 0xf | SYS_COLOR_INDEX_FLAG;
+ public static final int COLOR_BTNHIGHLIGHT = 0x14 | SYS_COLOR_INDEX_FLAG;
+ public static final int COLOR_BTNSHADOW = 0x10 | SYS_COLOR_INDEX_FLAG;
+ public static final int COLOR_BTNTEXT = 0x12 | SYS_COLOR_INDEX_FLAG;
+ public static final int COLOR_CAPTIONTEXT = 0x9 | SYS_COLOR_INDEX_FLAG;
+ public static final int COLOR_GRADIENTACTIVECAPTION = 0x1b | SYS_COLOR_INDEX_FLAG;
+ public static final int COLOR_GRADIENTINACTIVECAPTION = 0x1c | SYS_COLOR_INDEX_FLAG;
+ public static final int COLOR_HIGHLIGHT = 0xd | SYS_COLOR_INDEX_FLAG;
+ public static final int COLOR_HIGHLIGHTTEXT = 0xe | SYS_COLOR_INDEX_FLAG;
+ public static final int COLOR_INACTIVECAPTION = 0x3 | SYS_COLOR_INDEX_FLAG;
+ public static final int COLOR_INACTIVECAPTIONTEXT = 0x13 | SYS_COLOR_INDEX_FLAG;
+ public static final int COLOR_INFOBK = 0x18 | SYS_COLOR_INDEX_FLAG;
+ public static final int COLOR_INFOTEXT = 0x17 | SYS_COLOR_INDEX_FLAG;
+ public static final int COLOR_MENU = 0x4 | SYS_COLOR_INDEX_FLAG;
+ public static final int COLOR_MENUTEXT = 0x7 | SYS_COLOR_INDEX_FLAG;
+ public static final int COLOR_SCROLLBAR = 0x0 | SYS_COLOR_INDEX_FLAG;
+ public static final int COLOR_WINDOW = 0x5 | SYS_COLOR_INDEX_FLAG;
+ public static final int COLOR_WINDOWFRAME = 0x6 | SYS_COLOR_INDEX_FLAG;
+ public static final int COLOR_WINDOWTEXT = 0x8 | SYS_COLOR_INDEX_FLAG;
+ public static final int COMPLEXREGION = 0x3;
+ public static final int CP_ACP = 0x0;
+ public static final int CP_INSTALLED = 0x1;
+ public static final int CS_BYTEALIGNWINDOW = 0x2000;
+ public static final int CS_DBLCLKS = 0x8;
+ public static final int CS_HREDRAW = 0x2;
+ public static final int CS_VREDRAW = 0x1;
+ 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 DEFAULT_CHARSET = 0x1;
+ public static final int DEFAULT_GUI_FONT = 0x11;
+ public static final int DFCS_BUTTONCHECK = 0x0;
+ public static final int DFCS_CHECKED = 0x400;
+ public static final int DFCS_FLAT = 0x4000;
+ public static final int DFCS_INACTIVE = 0x100;
+ public static final int DFCS_PUSHED = 0x200;
+ 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_SCROLLUP = 0x0;
+ public static final int DFC_BUTTON = 0x4;
+ public static final int DFC_SCROLL = 0x3;
+ public static final int DIB_RGB_COLORS = 0x0;
+ public static final int DISP_E_EXCEPTION = 0x80020009;
+ public static final int DI_NORMAL = 0x3;
+ public static final int DLGC_BUTTON = 0x2000;
+ public static final int DLGC_HASSETSEL = 0x8;
+ public static final int DLGC_STATIC = 0x100;
+ public static final int DLGC_WANTALLKEYS = 0x4;
+ public static final int DLGC_WANTARROWS = 0x1;
+ public static final int DLGC_WANTTAB = 0x2;
+ public static final int DM_SETDEFID = OS.WM_USER + 1;
+ public static final int DSS_DISABLED = 0x20;
+ public static final int DSTINVERT = 0x550009;
+ public static final int DST_BITMAP = 0x4;
+ public static final int DST_ICON = 0x3;
+ public static final int DT_CALCRECT = 0x400;
+ public static final int DT_EDITCONTROL = 0x2000;
+ public static final int DT_EXPANDTABS = 0x40;
+ public static final int DT_LEFT = 0x0;
+ public static final int DT_NOPREFIX = 0x800;
+ public static final int DT_SINGLELINE = 0x20;
+ public static final int DT_WORDBREAK = 0x10;
+ public static final int ECOOP_AND = 0x3;
+ public static final int ECOOP_OR = 0x2;
+ public static final int ECO_AUTOHSCROLL = 0x80;
+ public static final int EDGE_ETCHED = 0x6;
+ public static final int EDGE_SUNKEN = 0xa;
+ public static final int EM_CANUNDO = 0xc6;
+ public static final int EM_CHARFROMPOS = 0xd7;
+ public static final int EM_DISPLAYBAND = 0x433;
+ public static final int EM_GETFIRSTVISIBLELINE = 0xce;
+ 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_GETPASSWORDCHAR = 0xd2;
+ public static final int EM_GETSCROLLPOS = 0x4dd;
+ public static final int EM_GETSEL = 0xb0;
+ 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_POSFROMCHAR = 0xd6;
+ public static final int EM_REPLACESEL = 0xc2;
+ public static final int EM_SCROLLCARET = 0xb7;
+ public static final int EM_SETBKGNDCOLOR = 0x443;
+ public static final int EM_SETLIMITTEXT = 0xc5;
+ public static final int EM_SETOPTIONS = 0x44d;
+ public static final int EM_SETPARAFORMAT = 0x447;
+ public static final int EM_SETPASSWORDCHAR = 0xcc;
+ public static final int EM_SETREADONLY = 0xcf;
+ public static final int EM_SETSEL = 0xb1;
+ public static final int EM_SETTABSTOPS = 0xcb;
+ public static final int EN_CHANGE = 0x300;
+ public static final int ERROR_NO_MORE_ITEMS = 0x103;
+ public static final int ESB_DISABLE_BOTH = 0x3;
+ public static final int ESB_ENABLE_BOTH = 0x0;
+ public static final int ES_AUTOHSCROLL = 0x80;
+ public static final int ES_CENTER = 0x1;
+ public static final int ES_MULTILINE = 0x4;
+ public static final int ES_NOHIDESEL = 0x100;
+ public static final int ES_READONLY = 0x800;
+ public static final int ES_RIGHT = 0x2;
+ public static final int FALT = 0x10;
+ public static final int FCONTROL = 0x8;
+ public static final int FNERR_INVALIDFILENAME = 0x3002;
+ public static final int FSHIFT = 0x4;
+ public static final int FVIRTKEY = 0x1;
+ public static final int GCS_COMPSTR = 0x8;
+ public static final int GCS_RESULTSTR = 0x800;
+ public static final int GMDI_USEDISABLED = 0x1;
+ public static final int GMEM_FIXED = 0x0;
+ public static final int GMEM_ZEROINIT = 0x40;
+ public static final int GN_CONTEXTMENU = 1000;
+ public static final int GPTR = 0x40;
+ public static final int GRADIENT_FILL_RECT_H = 0x0;
+ public static final int GRADIENT_FILL_RECT_V = 0x1;
+ public static final int GTL_NUMBYTES = 0x10;
+ public static final int GTL_NUMCHARS = 0x8;
+ public static final int GTL_PRECISE = 0x2;
+ public static final int GT_DEFAULT = 0x0;
+ public static final int GWL_EXSTYLE = 0xffffffec;
+ public static final int GWL_ID = -12;
+ 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 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 HBMMENU_CALLBACK = 0xffffffff;
+ public static final int HDI_WIDTH = 0x1;
+ public static final int HDM_FIRST = 0x1200;
+ public static final int HDM_GETBITMAPMARGIN = HDM_FIRST + 21;
+ public static final int HDM_GETITEMCOUNT = 0x1200;
+ public static final int HDN_BEGINTRACK = IsUnicode ? 0xfffffeba : 0xfffffece;
+ public static final int HDN_BEGINTRACKW = 0xfffffeba;
+ public static final int HDN_BEGINTRACKA = 0xfffffece;
+ public static final int HDN_DIVIDERDBLCLICKA = OS.HDN_FIRST - 5;
+ public static final int HDN_DIVIDERDBLCLICKW = OS.HDN_FIRST - 25;
+ public static final int HDN_DIVIDERDBLCLICK = IsUnicode ? HDN_DIVIDERDBLCLICKW : HDN_DIVIDERDBLCLICKA;
+ public static final int HDN_FIRST = 0xfffffed4;
+ public static final int HDN_ITEMCHANGED = IsUnicode ? 0xfffffebf : 0xfffffed3;
+ public static final int HDN_ITEMCHANGEDW = 0xfffffebf;
+ public static final int HDN_ITEMCHANGEDA = 0xfffffed3;
+ public static final int HEAP_ZERO_MEMORY = 0x8;
+ public static final int HELPINFO_MENUITEM = 0x2;
+ 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 HORZRES = 0x8;
+ public static final int HTBORDER = 0x12;
+ public static final int HTCLIENT = 0x1;
+ public static final int HTERROR = -2;
+ public static final int HTHSCROLL = 0x6;
+ public static final int HTMENU = 0x5;
+ public static final int HTNOWHERE = 0x0;
+ public static final int HTTRANSPARENT = 0xffffffff;
+ public static final int HTVSCROLL = 0x7;
+ public static final int HWND_BOTTOM = 0x1;
+ public static final int HWND_TOP = 0x0;
+ public static final int HWND_TOPMOST = 0xffffffff;
+ public static final int HWND_NOTOPMOST = -2;
+ public static final int ICC_COOL_CLASSES = 0x400;
+ public static final int ICM_NOTOPEN = 0x0;
+ public static final int ICON_BIG = 0x1;
+ public static final int ICON_SMALL = 0x0;
+ public static final int I_IMAGENONE = -2;
+ public static final int IDABORT = 0x3;
+ public static final int IDB_STD_SMALL_COLOR = 0x0;
+ public static final int IDC_APPSTARTING = 0x7f8a;
+ public static final int IDC_ARROW = 0x7f00;
+ public static final int IDC_CROSS = 0x7f03;
+ 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_NO = 0x7f88;
+ 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_UPARROW = 0x7f04;
+ public static final int IDC_WAIT = 0x7f02;
+ public static final int IDI_WINLOGO = 0x7f05;
+ 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_MASK = 0x1;
+ public static final int ILD_NORMAL = 0x0;
+ 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 IME_CMODE_FULLSHAPE = 0x8;
+ public static final int IME_CMODE_KATAKANA = 0x2;
+ public static final int IME_CMODE_NATIVE = 0x1;
+ public static final int IME_CMODE_ROMAN = 0x10;
+ public static final int INFINITE = 0xffffffff;
+ public static final int KEY_ENUMERATE_SUB_KEYS = 0x8;
+ public static final int KEY_NOTIFY = 0x10;
+ public static final int KEY_QUERY_VALUE = 0x1;
+ public static final int KEY_READ = 0x20019;
+ public static final int LBN_DBLCLK = 0x2;
+ public static final int LBN_SELCHANGE = 0x1;
+ public static final int LBS_EXTENDEDSEL = 0x800;
+ public static final int LBS_MULTIPLESEL = 0x8;
+ public static final int LBS_NOINTEGRALHEIGHT = 0x100;
+ public static final int LBS_NOTIFY = 0x1;
+ public static final int LB_ADDSTRING = 0x180;
+ public static final int LB_DELETESTRING = 0x182;
+ public static final int LB_ERR = 0xffffffff;
+ public static final int LB_ERRSPACE = 0xfffffffe;
+ public static final int LB_FINDSTRINGEXACT = 0x1a2;
+ 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_GETITEMHEIGHT = 0x1a1;
+ public static final int LB_GETITEMRECT = 0x198;
+ 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_RESETCONTENT = 0x184;
+ public static final int LB_SELITEMRANGE = 0x19b;
+ public static final int LB_SELITEMRANGEEX = 0x183;
+ public static final int LB_SETCARETINDEX = 0x19e;
+ public static final int LB_SETCURSEL = 0x186;
+ public static final int LB_SETHORIZONTALEXTENT = 0x194;
+ public static final int LB_SETSEL = 0x185;
+ public static final int LB_SETTOPINDEX = 0x197;
+ public static final int LGRPID_ARABIC = 0xd;
+ public static final int LGRPID_HEBREW = 0xc;
+ public static final int LGRPID_INSTALLED = 1;
+ public static final int LCID_SUPPORTED = 0x2;
+ public static final int LOCALE_IDEFAULTANSICODEPAGE = 0x1004;
+ public static final int LOCALE_SISO3166CTRYNAME = 0x5a;
+ public static final int LOCALE_SISO639LANGNAME = 0x59;
+ public static final int LOGPIXELSX = 0x58;
+ public static final int LOGPIXELSY = 0x5a;
+ public static final int LPSTR_TEXTCALLBACK = 0xffffffff;
+ public static final int LR_DEFAULTCOLOR = 0x0;
+ public static final int LVCFMT_CENTER = 0x2;
+ public static final int LVCFMT_IMAGE = 0x800;
+ public static final int LVCFMT_LEFT = 0x0;
+ public static final int LVCFMT_RIGHT = 0x1;
+ public static final int LVCF_FMT = 0x1;
+ public static final int LVCF_IMAGE = 0x10;
+ public static final int LVCF_TEXT = 0x4;
+ public static final int LVCF_WIDTH = 0x2;
+ 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 LVIF_IMAGE = 0x2;
+ public static final int LVIF_INDENT = 0x10;
+ 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 LVIS_DROPHILITED = 0x8;
+ public static final int LVIS_FOCUSED = 0x1;
+ public static final int LVIS_SELECTED = 0x2;
+ public static final int LVIS_STATEIMAGEMASK = 0xf000;
+ public static final int LVM_APPROXIMATEVIEWRECT = 0x1040;
+ 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_ENSUREVISIBLE = 0x1013;
+ public static final int LVM_FIRST = 0x1000;
+ public static final int LVM_GETBKCOLOR = 0x1000;
+ public static final int LVM_GETCOLUMN = IsUnicode ? 0x105f : 0x1019;
+ public static final int LVM_GETCOLUMNWIDTH = 0x101d;
+ public static final int LVM_GETCOUNTPERPAGE = 0x1028;
+ public static final int LVM_GETEXTENDEDLISTVIEWSTYLE = 0x1037;
+ public static final int LVM_GETHEADER = 0x101f;
+ public static final int LVM_GETIMAGELIST = 0x1002;
+ public static final int LVM_GETITEM = IsUnicode ? 0x104b : 0x1005;
+ public static final int LVM_GETITEMW = 0x104b;
+ public static final int LVM_GETITEMA = 0x1005;
+ public static final int LVM_GETITEMCOUNT = 0x1004;
+ public static final int LVM_GETITEMRECT = 0x100e;
+ public static final int LVM_GETITEMSTATE = 0x102c;
+ public static final int LVM_GETNEXTITEM = 0x100c;
+ public static final int LVM_GETSELECTEDCOUNT = 0x1032;
+ public static final int LVM_GETSTRINGWIDTH = IsUnicode ? 0x1057 : 0x1011;
+ public static final int LVM_GETSUBITEMRECT = 0x1038;
+ public static final int LVM_GETTEXTCOLOR = 0x1023;
+ public static final int LVM_GETTOPINDEX = 0x1027;
+ public static final int LVM_HITTEST = 0x1012;
+ public static final int LVM_INSERTCOLUMN = IsUnicode ? 0x1061 : 0x101b;
+ public static final int LVM_INSERTITEM = IsUnicode ? 0x104d : 0x1007;
+ public static final int LVM_SCROLL = 0x1014;
+ public static final int LVM_SETBKCOLOR = 0x1001;
+ public static final int LVM_SETCOLUMN = IsUnicode ? 0x1060 : 0x101a;
+ public static final int LVM_SETCOLUMNWIDTH = 0x101e;
+ public static final int LVM_SETEXTENDEDLISTVIEWSTYLE = 0x1036;
+ public static final int LVM_SETIMAGELIST = 0x1003;
+ public static final int LVM_SETITEM = IsUnicode ? 0x104c : 0x1006;
+ public static final int LVM_SETITEMSTATE = 0x102b;
+ public static final int LVM_SETTEXTBKCOLOR = 0x1026;
+ public static final int LVM_SETTEXTCOLOR = 0x1024;
+ public static final int LVNI_FOCUSED = 0x1;
+ public static final int LVNI_SELECTED = 0x2;
+ public static final int LVN_BEGINDRAG = 0xffffff93;
+ public static final int LVN_BEGINRDRAG = 0xffffff91;
+ public static final int LVN_COLUMNCLICK = 0xffffff94;
+ public static final int LVN_FIRST = 0xffffff9c;
+ public static final int LVN_ITEMACTIVATE = 0xffffff8e;
+ public static final int LVN_ITEMCHANGED = 0xffffff9b;
+ public static final int LVN_MARQUEEBEGIN = 0xffffff64;
+ public static final int LVSCW_AUTOSIZE = 0xffffffff;
+ public static final int LVSCW_AUTOSIZE_USEHEADER = 0xfffffffe;
+ public static final int LVSIL_SMALL = 0x1;
+ public static final int LVSIL_STATE = 0x2;
+ public static final int LVS_EX_FULLROWSELECT = 0x20;
+ public static final int LVS_EX_GRIDLINES = 0x1;
+ public static final int LVS_EX_LABELTIP = 0x4000;
+ public static final int LVS_EX_ONECLICKACTIVATE = 0x40;
+ public static final int LVS_EX_SUBITEMIMAGES = 0x2;
+ public static final int LVS_EX_TRACKSELECT = 0x8;
+ public static final int LVS_EX_TWOCLICKACTIVATE = 0x80;
+ public static final int LVS_NOCOLUMNHEADER = 0x4000;
+ public static final int LVS_NOSCROLL = 0x2000;
+ 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 MA_NOACTIVATE = 0x3;
+ public static final int MB_ABORTRETRYIGNORE = 0x2;
+ public static final int MB_APPLMODAL = 0x0;
+ public static final int MB_ICONERROR = 0x10;
+ public static final int MB_ICONINFORMATION = 0x40;
+ public static final int MB_ICONQUESTION = 0x20;
+ public static final int MB_ICONWARNING = 0x30;
+ 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_RTLREADING = 0x100000;
+ public static final int MB_SYSTEMMODAL = 0x1000;
+ public static final int MB_TASKMODAL = 0x2000;
+ public static final int MB_YESNO = 0x4;
+ public static final int MB_YESNOCANCEL = 0x3;
+ public static final int MFS_CHECKED = 0x8;
+ public static final int MFS_DISABLED = 0x3;
+ public static final int MFS_GRAYED = 0x3;
+ 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 MF_BYCOMMAND = 0x0;
+ public static final int MF_BYPOSITION = 0x400;
+ public static final int MF_CHECKED = 0x8;
+ public static final int MF_DISABLED = 0x2;
+ public static final int MF_ENABLED = 0x0;
+ public static final int MF_GRAYED = 0x1;
+ public static final int MF_HILITE = 0x80;
+ public static final int MF_POPUP = 0x10;
+ public static final int MF_SEPARATOR = 0x800;
+ public static final int MF_SYSMENU = 0x2000;
+ public static final int MF_UNCHECKED = 0x0;
+ public static final int MIIM_BITMAP = 0x80;
+ public static final int MIIM_DATA = 0x20;
+ public static final int MIIM_ID = 0x2;
+ public static final int MIIM_STATE = 0x1;
+ public static final int MIIM_SUBMENU = 0x4;
+ public static final int MIIM_TYPE = 0x10;
+ public static final int MIM_STYLE = 0x10;
+ 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 = 0x1;
+ public static final int MNC_CLOSE = 0x1;
+ public static final int MNS_CHECKORBMP = 0x4000000;
+ public static final int MWMO_INPUTAVAILABLE = 0x4;
+ public static final int NM_CLICK = 0xfffffffe;
+ public static final int NM_CUSTOMDRAW = OS.NM_FIRST - 12;
+ public static final int NM_DBLCLK = 0xfffffffd;
+ public static final int NM_FIRST = 0x0;
+ public static final int NM_RETURN = 0xfffffffc;
+ public static final int NOTSRCCOPY = 0x330008;
+ public static final int NULLREGION = 0x1;
+ public static final int NULL_BRUSH = 0x5;
+ public static final int NULL_PEN = 0x8;
+ public static final int NUMRESERVED = 106;
+ public static final int OBJID_CLIENT = 0xFFFFFFFC;
+ public static final int OBJ_FONT = 0x6;
+ public static final int OBJ_PEN = 0x1;
+ public static final int OBM_CHECKBOXES = 0x7ff7;
+ public static final int ODS_SELECTED = 0x1;
+ public static final int ODT_MENU = 0x1;
+ public static final int OFN_ALLOWMULTISELECT = 0x200;
+ public static final int OFN_EXPLORER = 0x80000;
+ public static final int OFN_HIDEREADONLY = 0x4;
+ public static final int OFN_NOCHANGEDIR = 0x8;
+ public static final int OPAQUE = 0x2;
+ public static final int PATCOPY = 0xf00021;
+ public static final int PATINVERT = 0x5a0049;
+ public static final int PBM_GETPOS = 0x408;
+ public static final int PBM_GETRANGE = 0x407;
+ public static final int PBM_SETBARCOLOR = 0x409;
+ public static final int PBM_SETBKCOLOR = 0x2001;
+ public static final int PBM_SETPOS = 0x402;
+ public static final int PBM_SETRANGE32 = 0x406;
+ public static final int PBM_STEPIT = OS.WM_USER + 5;
+ public static final int PBS_SMOOTH = 0x1;
+ public static final int PBS_VERTICAL = 0x4;
+ public static final int PD_ALLPAGES = 0x0;
+ public static final int PD_COLLATE = 0x10;
+ public static final int PD_PAGENUMS = 0x2;
+ public static final int PD_PRINTTOFILE = 0x20;
+ public static final int PD_RETURNDC = 0x100;
+ public static final int PD_SELECTION = 0x1;
+ public static final int PD_USEDEVMODECOPIESANDCOLLATE = 0x40000;
+ public static final int PFM_TABSTOPS = 0x10;
+ public static final int PHYSICALHEIGHT = 0x6f;
+ public static final int PHYSICALOFFSETX = 0x70;
+ public static final int PHYSICALOFFSETY = 0x71;
+ public static final int PHYSICALWIDTH = 0x6e;
+ public static final int PLANES = 0xe;
+ public static final int PM_NOREMOVE = 0x0;
+ public static final int PM_REMOVE = 0x1;
+ public static final String PROGRESS_CLASS = "msctls_progress32";
+ 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_GEOMETRIC = 0x10000;
+ public static final int PS_JOIN_MITER = 0x2000;
+ public static final int PS_SOLID = 0x0;
+ public static final int PS_STYLE_MASK = 0xf;
+ public static final int QS_KEY = 0x0001;
+ public static final int QS_MOUSEMOVE = 0x0002;
+ public static final int QS_MOUSEBUTTON = 0x0004;
+ public static final int QS_POSTMESSAGE = 0x0008;
+ public static final int QS_TIMER = 0x0010;
+ public static final int QS_PAINT = 0x0020;
+ public static final int QS_SENDMESSAGE = 0x0040;
+ public static final int QS_ALLINPUT = QS_MOUSEMOVE | QS_MOUSEBUTTON | QS_KEY | QS_POSTMESSAGE | QS_TIMER | QS_PAINT | QS_SENDMESSAGE;
+ public static final int R2_COPYPEN = 0xd;
+ public static final int R2_XORPEN = 0x7;
+ public static final int RASTERCAPS = 0x26;
+ public static final int RASTER_FONTTYPE = 0x1;
+ public static final int RBBIM_CHILD = 0x10;
+ public static final int RBBIM_CHILDSIZE = 0x20;
+ public static final int RBBIM_COLORS = 0x2;
+ public static final int RBBIM_HEADERSIZE = 0x800;
+ public static final int RBBIM_ID = 0x100;
+ public static final int RBBIM_IDEALSIZE = 0x200;
+ public static final int RBBIM_SIZE = 0x40;
+ public static final int RBBIM_STYLE = 0x1;
+ public static final int RBBIM_TEXT = 0x4;
+ public static final int RBBS_BREAK = 0x1;
+ public static final int RBBS_GRIPPERALWAYS = 0x80;
+ public static final int RBBS_NOGRIPPER = 0x00000100;
+ public static final int RBBS_USECHEVRON = 0x00000200;
+ public static final int RBBS_VARIABLEHEIGHT = 0x40;
+ public static final int RBN_FIRST = 0xfffffcc1;
+ public static final int RBN_CHEVRONPUSHED = RBN_FIRST - 10;
+ public static final int RBN_HEIGHTCHANGE = 0xfffffcc1;
+ public static final int RBS_DBLCLKTOGGLE = 0x8000;
+ public static final int RBS_BANDBORDERS = 0x400;
+ public static final int RBS_VARHEIGHT = 0x200;
+ public static final int RB_DELETEBAND = 0x402;
+ public static final int RB_GETBANDBORDERS = 0x422;
+ public static final int RB_GETBANDCOUNT = 0x40c;
+ public static final int RB_GETBANDINFO = IsUnicode ? 0x41c : 0x41d;
+ public static final int RB_GETBARHEIGHT = 0x41b;
+ public static final int RB_GETBKCOLOR = 0x414;
+ public static final int RB_GETRECT = 0x409;
+ public static final int RB_GETTEXTCOLOR = 0x416;
+ public static final int RB_IDTOINDEX = 0x410;
+ public static final int RB_INSERTBAND = IsUnicode ? 0x40a : 0x401;
+ public static final int RB_MOVEBAND = 0x427;
+ public static final int RB_SETBANDINFO = IsUnicode ? 0x40b : 0x406;
+ public static final int RB_SETBKCOLOR = 0x413;
+ public static final int RB_SETTEXTCOLOR = 0x415;
+ public static final int RC_BITBLT = 0x1;
+ public static final int RC_PALETTE = 0x100;
+ public static final int RDW_ALLCHILDREN = 0x80;
+ public static final int RDW_ERASE = 0x4;
+ public static final int RDW_FRAME = 0x400;
+ public static final int RDW_INVALIDATE = 0x1;
+ public static final int RDW_UPDATENOW = 0x100;
+ public static final int READ_CONTROL = 0x20000;
+ public static final String REBARCLASSNAME = "ReBarWindow32";
+ public static final int RGN_OR = 0x2;
+ public static final int SBS_HORZ = 0x0;
+ public static final int SBS_VERT = 0x1;
+ 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_HORZ = 0x0;
+ public static final int SB_LINEDOWN = 0x1;
+ public static final int SB_LINEUP = 0x0;
+ public static final int SB_PAGEDOWN = 0x3;
+ public static final int SB_PAGEUP = 0x2;
+ 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 SCF_ALL = 0x4;
+ public static final int SCF_DEFAULT = 0x0;
+ public static final int SCF_SELECTION = 0x1;
+ public static final int SC_CLOSE = 0xf060;
+ public static final int SC_HSCROLL = 0xf080;
+ public static final int SC_KEYMENU = 0xf100;
+ public static final int SC_MAXIMIZE = 0xf030;
+ public static final int SC_MINIMIZE = 0xf020;
+ public static final int SC_RESTORE = 0xf120;
+ 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 SF_RTF = 0x2;
+ public static final int SHCMBF_HIDDEN = 0x2;
+ public static final int SHCMBM_OVERRIDEKEY = OS.WM_USER + 403;
+ public static final int SHCMBM_SETSUBMENU = 0x590;
+ public static final int SHCMBM_GETSUBMENU = 0x591;
+ public static final int SHMBOF_NODEFAULT = 0x1;
+ public static final int SHMBOF_NOTIFY = 0x2;
+ public static final int SHRG_RETURNCMD = 0x1;
+ 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 SIP_DOWN = 1;
+ public static final int SIP_UP = 0;
+ public static final int SIPF_ON = 0x1;
+ public static final int SIZE_MINIMIZED = 0x1;
+ public static final int SIZEPALETTE = 104;
+ public static final int SM_CMONITORS = 80;
+ public static final int SM_CXBORDER = 0x5;
+ public static final int SM_CXCURSOR = 0xd;
+ public static final int SM_CXEDGE = 0x2d;
+ public static final int SM_CXHSCROLL = 0x15;
+ public static final int SM_CXICON = 0x0b;
+ public static final int SM_CYICON = 0x0c;
+ public static final int SM_CXVIRTUALSCREEN = 78;
+ public static final int SM_CYVIRTUALSCREEN = 79;
+ public static final int SM_CXSMICON = 49;
+ public static final int SM_CYSMICON = 50;
+ public static final int SM_CXSCREEN = 0x0;
+ public static final int SM_XVIRTUALSCREEN = 76;
+ public static final int SM_YVIRTUALSCREEN = 77;
+ public static final int SM_CXVSCROLL = 0x2;
+ public static final int SM_CYBORDER = 0x6;
+ public static final int SM_CYCURSOR = 0xe;
+ public static final int SM_CYHSCROLL = 0x3;
+ public static final int SM_CYMENU = 0xf;
+ public static final int SM_CYSCREEN = 0x1;
+ public static final int SM_CYVSCROLL = 0x14;
+ public static final int SPI_GETWORKAREA = 0x30;
+ public static final int SPI_GETNONCLIENTMETRICS = 41;
+ public static final int SPI_GETWHEELSCROLLLINES = 104;
+ public static final int SPI_SETSIPINFO = 224;
+ public static final int SRCAND = 0x8800c6;
+ public static final int SRCCOPY = 0xcc0020;
+ public static final int SRCINVERT = 0x660046;
+ public static final int SRCPAINT = 0xee0086;
+ public static final int SS_BITMAP = 0xe;
+ public static final int SS_CENTER = 0x1;
+ public static final int SS_CENTERIMAGE = 0x200;
+ 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_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 STANDARD_RIGHTS_READ = 0x20000;
+ public static final int STD_COPY = 0x1;
+ public static final int STD_CUT = 0x0;
+ 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_PASTE = 0x2;
+ public static final int STM_SETIMAGE = 0x172;
+ public static final int SWP_DRAWFRAME = 0x20;
+ 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_NOREDRAW = 0x8;
+ public static final int SWP_NOSIZE = 0x1;
+ public static final int SWP_NOZORDER = 0x4;
+ 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_PARENTOPENING = 0x3;
+ public static final int SW_RESTORE = OS.IsWinCE ? 0xd : 0x9;
+ public static final int SW_SCROLLCHILDREN = 0x1;
+ public static final int SW_SHOW = 0x5;
+ public static final int SW_SHOWMAXIMIZED = OS.IsWinCE ? 0xb : 0x3;
+ 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 SYNCHRONIZE = 0x100000;
+ public static final int SYSTEM_FONT = 0xd;
+ public static final int S_OK = 0x0;
+ public static final int TBIF_COMMAND = 0x20;
+ public static final int TBIF_STATE = 0x4;
+ public static final int TBIF_IMAGE = 0x1;
+ public static final int TBIF_LPARAM = 0x10;
+ public static final int TBIF_SIZE = 0x40;
+ public static final int TBIF_STYLE = 0x8;
+ public static final int TBIF_TEXT = 0x2;
+ public static final int TBM_GETLINESIZE = 0x418;
+ public static final int TBM_GETPAGESIZE = 0x416;
+ public static final int TBM_GETPOS = 0x400;
+ public static final int TBM_GETRANGEMAX = 0x402;
+ public static final int TBM_GETRANGEMIN = 0x401;
+ public static final int TBM_GETTHUMBRECT = 0x419;
+ 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_SETRANGEMAX = 0x408;
+ public static final int TBM_SETRANGEMIN = 0x407;
+ public static final int TBM_SETTICFREQ = 0x414;
+ public static final int TBN_DROPDOWN = 0xfffffd3a;
+ public static final int TBN_FIRST = 0xfffffd44;
+ public static final int TBSTATE_CHECKED = 0x1;
+ public static final int TBSTYLE_DROPDOWN = 0x8;
+ public static final int TBSTATE_ENABLED = 0x4;
+ public static final int TBSTYLE_AUTOSIZE = 0x10;
+ public static final int TBSTYLE_EX_DRAWDDARROWS = 0x1;
+ public static final int TBSTYLE_FLAT = 0x800;
+ public static final int TBSTYLE_LIST = 0x1000;
+ 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 TBS_AUTOTICKS = 0x1;
+ public static final int TBS_BOTH = 0x8;
+ public static final int TBS_HORZ = 0x0;
+ public static final int TBS_VERT = 0x2;
+ public static final int TB_ADDSTRING = IsUnicode ? 0x44d : 0x41c;
+ public static final int TB_BUTTONCOUNT = 0x418;
+ public static final int TB_BUTTONSTRUCTSIZE = 0x41e;
+ public static final int TB_COMMANDTOINDEX = 0x419;
+ public static final int TB_DELETEBUTTON = 0x416;
+ public static final int TB_ENDTRACK = 0x8;
+ public static final int TB_GETBUTTON = 0x417;
+ public static final int TB_GETBUTTONINFO = IsUnicode ? 0x43f : 0x441;
+ public static final int TB_GETBUTTONSIZE = 0x43a;
+ public static final int TB_GETBUTTONTEXT = IsUnicode ? 0x44b : 0x42d;
+ public static final int TB_GETDISABLEDIMAGELIST = 0x437;
+ public static final int TB_GETHOTIMAGELIST = 0x435;
+ public static final int TB_GETHOTITEM = 0x0400 + 71;
+ public static final int TB_GETIMAGELIST = 0x431;
+ public static final int TB_GETITEMRECT = 0x41d;
+ public static final int TB_GETROWS = 0x428;
+ public static final int TB_GETSTATE = 0x412;
+ public static final int TB_GETTOOLTIPS = 0x423;
+ public static final int TB_INSERTBUTTON = IsUnicode ? 0x443 : 0x415;
+ public static final int TB_LOADIMAGES = 0x432;
+ public static final int TB_MAPACCELERATOR = 0x0400 + (IsUnicode ? 90 : 78);
+ public static final int TB_SETBITMAPSIZE = 0x420;
+ public static final int TB_SETBUTTONINFO = IsUnicode ? 0x440 : 0x442;
+ public static final int TB_SETBUTTONSIZE = 0x41f;
+ public static final int TB_SETDISABLEDIMAGELIST = 0x436;
+ public static final int TB_SETEXTENDEDSTYLE = 0x454;
+ public static final int TB_SETHOTIMAGELIST = 0x434;
+ public static final int TB_SETHOTITEM = 0x0400 + 72;
+ public static final int TB_SETIMAGELIST = 0x430;
+ public static final int TB_SETROWS = 0x427;
+ public static final int TB_SETSTATE = 0x411;
+ public static final int TCIF_IMAGE = 0x2;
+ public static final int TCIF_TEXT = 0x1;
+ public static final int TCI_SRCCHARSET = 0x1;
+ public static final int TCI_SRCCODEPAGE = 0x2;
+ public static final int TCM_ADJUSTRECT = 0x1328;
+ public static final int TCM_DELETEITEM = 0x1308;
+ public static final int TCM_GETCURSEL = 0x130b;
+ public static final int TCM_GETITEMCOUNT = 0x1304;
+ public static final int TCM_GETITEMRECT = 0x130a;
+ public static final int TCM_GETTOOLTIPS = 0x132d;
+ public static final int TCM_INSERTITEM = IsUnicode ? 0x133e : 0x1307;
+ public static final int TCM_SETCURSEL = 0x130c;
+ public static final int TCM_SETIMAGELIST = 0x1303;
+ public static final int TCM_SETITEM = IsUnicode ? 0x133d : 0x1306;
+ public static final int TCN_SELCHANGE = 0xfffffdd9;
+ public static final int TCN_SELCHANGING = 0xfffffdd8;
+ public static final int TCS_FOCUSNEVER = 0x8000;
+ public static final int TCS_MULTILINE = 0x200;
+ public static final int TCS_TABS = 0x0;
+ public static final int TCS_TOOLTIPS = 0x4000;
+ public static final int TME_HOVER = 0x1;
+ public static final int TME_LEAVE = 0x2;
+ public static final int TME_QUERY = 0x40000000;
+ public static final int TMPF_VECTOR = 0x2;
+ public static final String TOOLBARCLASSNAME = "ToolbarWindow32";
+ public static final String TOOLTIPS_CLASS = "tooltips_class32";
+ public static final int TPM_LEFTALIGN = 0x0;
+ public static final int TPM_LEFTBUTTON = 0x0;
+ public static final int TPM_RIGHTBUTTON = 0x2;
+ public static final int TPM_RIGHTALIGN = 0x8;
+ public static final String TRACKBAR_CLASS = "msctls_trackbar32";
+ public static final int TRANSPARENT = 0x1;
+ public static final int TTF_IDISHWND = 0x1;
+ public static final int TTF_SUBCLASS = 0x10;
+ public static final int TTM_ADDTOOL = IsUnicode ? 0x432 : 0x404;
+ public static final int TTM_DELTOOL = IsUnicode ? 0x433 : 0x405;
+ public static final int TTM_SETMAXTIPWIDTH = 0x418;
+ public static final int TTM_UPDATE = 0x41D;
+ public static final int TTN_FIRST = 0xfffffdf8;
+ public static final int TTN_GETDISPINFO = IsUnicode ? 0xfffffdee : 0xfffffdf8;
+ public static final int TTN_GETDISPINFOW = 0xfffffdee;
+ public static final int TTN_GETDISPINFOA = 0xfffffdf8;
+ public static final int TTN_POP = TTN_FIRST - 2;
+ public static final int TTN_SHOW = TTN_FIRST - 1;
+ public static final int TTS_ALWAYSTIP = 0x1;
+ public static final int TVE_COLLAPSE = 0x1;
+ public static final int TVE_EXPAND = 0x2;
+ public static final int TVGN_CARET = 0x9;
+ public static final int TVGN_CHILD = 0x4;
+ public static final int TVGN_FIRSTVISIBLE = 0x5;
+ public static final int TVGN_LASTVISIBLE = 0xa;
+ public static final int TVGN_NEXT = 0x1;
+ public static final int TVGN_NEXTVISIBLE = 0x6;
+ public static final int TVGN_PARENT = 0x3;
+ public static final int TVGN_PREVIOUSVISIBLE = 0x7;
+ public static final int TVGN_ROOT = 0x0;
+ public static final int TVHT_ONITEM = 0x46;
+ public static final int TVHT_ONITEMICON = 0x2;
+ public static final int TVHT_ONITEMLABEL = 0x4;
+ public static final int TVHT_ONITEMSTATEICON = 0x40;
+ public static final int TVIF_HANDLE = 0x10;
+ public static final int TVIF_IMAGE = 0x2;
+ public static final int TVIF_PARAM = 0x4;
+ public static final int TVIF_SELECTEDIMAGE = 0x20;
+ public static final int TVIF_STATE = 0x8;
+ public static final int TVIF_TEXT = 0x1;
+ public static final int TVIS_DROPHILITED = 0x8;
+ public static final int TVIS_EXPANDED = 0x20;
+ public static final int TVIS_SELECTED = 0x2;
+ public static final int TVIS_STATEIMAGEMASK = 0xf000;
+ 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 TVM_DELETEITEM = 0x1101;
+ public static final int TVM_ENSUREVISIBLE = 0x1114;
+ public static final int TVM_EXPAND = 0x1102;
+ public static final int TVM_GETBKCOLOR = 0x111f;
+ public static final int TVM_GETCOUNT = 0x1105;
+ public static final int TVM_GETIMAGELIST = 0x1108;
+ public static final int TVM_GETITEM = IsUnicode ? 0x113e : 0x110c;
+ public static final int TVM_GETITEMHEIGHT = 0x111c;
+ public static final int TVM_GETITEMRECT = 0x1104;
+ public static final int TVM_GETNEXTITEM = 0x110a;
+ public static final int TVM_GETTEXTCOLOR = 0x1120;
+ public static final int TVM_GETTOOLTIPS = OS.TV_FIRST + 25;
+ public static final int TVM_GETVISIBLECOUNT = OS.TV_FIRST + 16;
+ public static final int TVM_HITTEST = 0x1111;
+ public static final int TVM_INSERTITEM = IsUnicode ? 0x1132 : 0x1100;
+ public static final int TVM_SELECTITEM = 0x110b;
+ public static final int TVM_SETBKCOLOR = 0x111d;
+ public static final int TVM_SETIMAGELIST = 0x1109;
+ public static final int TVM_SETINSERTMARK = 0x111a;
+ public static final int TVM_SETITEM = IsUnicode ? 0x113f : 0x110d;
+ public static final int TVM_SETTEXTCOLOR = 0x111e;
+ public static final int TVN_BEGINDRAG = IsUnicode ? 0xfffffe38 : 0xfffffe69;
+ public static final int TVN_BEGINDRAGW = 0xfffffe38;
+ public static final int TVN_BEGINDRAGA = 0xfffffe69;
+ public static final int TVN_BEGINRDRAG = IsUnicode ? 0xfffffe37 : 0xfffffe68;
+ public static final int TVN_BEGINRDRAGW = 0xfffffe37;
+ public static final int TVN_BEGINRDRAGA = 0xfffffe68;
+ public static final int TVN_FIRST = 0xfffffe70;
+ public static final int TVN_ITEMEXPANDING = IsUnicode ? 0xfffffe3a : 0xfffffe6b;
+ public static final int TVN_ITEMEXPANDINGW = 0xfffffe3a;
+ public static final int TVN_ITEMEXPANDINGA = 0xfffffe6b;
+ public static final int TVN_SELCHANGED = IsUnicode ? 0xfffffe3d : 0xfffffe6e;
+ public static final int TVN_SELCHANGEDW = 0xfffffe3d;
+ public static final int TVN_SELCHANGEDA = 0xfffffe6e;
+ public static final int TVN_SELCHANGING = IsUnicode ? 0xfffffe3e : 0xfffffe6f;
+ public static final int TVN_SELCHANGINGW = 0xfffffe3e;
+ public static final int TVN_SELCHANGINGA = 0xfffffe6f;
+ public static final int TVSIL_NORMAL = 0x0;
+ public static final int TVSIL_STATE = 0x2;
+ public static final int TVS_DISABLEDRAGDROP = 0x10;
+ public static final int TVS_FULLROWSELECT = 0x1000;
+ public static final int TVS_HASBUTTONS = 0x1;
+ public static final int TVS_HASLINES = 0x2;
+ public static final int TVS_LINESATROOT = 0x4;
+ public static final int TVS_NOTOOLTIPS = 0x80;
+ public static final int TVS_SHOWSELALWAYS = 0x20;
+ public static final int TV_FIRST = 0x1100;
+ public static final int UIS_INITIALIZE = 3;
+ public static final int VERTRES = 0xa;
+ public static final int VK_BACK = 0x8;
+ public static final int VK_CAPITAL = 0x14;
+ public static final int VK_CONTROL = 0x11;
+ 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_ESCAPE = 0x1b;
+ 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_F2 = 0x71;
+ public static final int VK_F3 = 0x72;
+ public static final int VK_F4 = 0x73;
+ public static final int VK_F5 = 0x74;
+ public static final int VK_F6 = 0x75;
+ public static final int VK_F7 = 0x76;
+ public static final int VK_F8 = 0x77;
+ public static final int VK_F9 = 0x78;
+ 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_LEFT = 0x25;
+ 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_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_PRIOR = 0x21;
+ public static final int VK_RBUTTON = 0x2;
+ public static final int VK_RETURN = 0xd;
+ public static final int VK_RIGHT = 0x27;
+ public static final int VK_SCROLL = 0x91;
+ public static final int VK_SEPARATOR = 0x6C;
+ public static final int VK_SHIFT = 0x10;
+ 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_ADD = 0x6B;
+ public static final int VK_APP1 = 0xc1;
+ public static final int VK_APP2 = 0xc2;
+ public static final int VK_APP3 = 0xc3;
+ public static final int VK_APP4 = 0xc4;
+ public static final int VK_APP5 = 0xc5;
+ public static final int VK_APP6 = 0xc6;
+ public static final String WC_LISTVIEW = "SysListView32";
+ public static final String WC_TABCONTROL = "SysTabControl32";
+ public static final String WC_TREEVIEW = "SysTreeView32";
+ public static final int WH_GETMESSAGE = 0x3;
+ public static final int WH_MSGFILTER = 0xFFFFFFFF;
+ public static final int WHEEL_DELTA = 120;
+ public static final int WHEEL_PAGESCROLL = 0xFFFFFFFF;
+ public static final int WM_ACTIVATE = 0x6;
+ public static final int WM_ACTIVATEAPP = 0x1c;
+ public static final int WM_APP = 0x8000;
+ public static final int WM_CANCELMODE = 0x1f;
+ public static final int WM_CHANGEUISTATE = 0x0127;
+ public static final int WM_CHAR = 0x102;
+ 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_CONTEXTMENU = 0x7b;
+ public static final int WM_COPY = 0x301;
+ 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_DESTROY = 0x2;
+ public static final int WM_DRAWITEM = 0x2b;
+ public static final int WM_ENDSESSION = 0x16;
+ public static final int WM_ERASEBKGND = 0x14;
+ public static final int WM_GETDLGCODE = 0x87;
+ public static final int WM_GETFONT = 0x31;
+// public static final int WM_GETICON = 0x7f;
+ public static final int WM_GETOBJECT = 0x003D;
+ public static final int WM_HELP = 0x53;
+ public static final int WM_HOTKEY = 0x0312;
+ public static final int WM_HSCROLL = 0x114;
+ public static final int WM_IME_CHAR = 0x286;
+ public static final int WM_IME_COMPOSITION = 0x10f;
+ public static final int WM_INITDIALOG = 0x110;
+ public static final int WM_INITMENUPOPUP = 0x117;
+ 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_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_MOUSEHOVER = 0x2a1;
+ public static final int WM_MOUSELEAVE = 0x2a3;
+ public static final int WM_MOUSEMOVE = 0x200;
+ public static final int WM_MOUSEWHEEL = 0x20a;
+ public static final int WM_MOUSELAST = 0x20d;
+ public static final int WM_MOVE = 0x3;
+ public static final int WM_NCACTIVATE = 0x86;
+ public static final int WM_NCCALCSIZE = 0x83;
+ public static final int WM_NCHITTEST = 0x84;
+ public static final int WM_NOTIFY = 0x4e;
+ public static final int WM_NULL = 0x0;
+ public static final int WM_PAINT = 0xf;
+ public static final int WM_PALETTECHANGED = 0x311;
+ public static final int WM_PASTE = 0x302;
+ public static final int WM_PRINTCLIENT = 0x0318;
+ 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_RBUTTONDBLCLK = 0x206;
+ public static final int WM_RBUTTONDOWN = 0x204;
+ public static final int WM_RBUTTONUP = 0x205;
+ 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_SETICON = 0x80;
+ public static final int WM_SETREDRAW = 0xb;
+ 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_SYSCHAR = 0x106;
+ public static final int WM_SYSCOLORCHANGE = 0x15;
+ public static final int WM_SYSCOMMAND = 0x112;
+ public static final int WM_SYSKEYDOWN = 0x104;
+ public static final int WM_SYSKEYUP = 0x105;
+ public static final int WM_TIMER = 0x113;
+ public static final int WM_UNDO = 0x304;
+ public static final int WM_USER = 0x400;
+ public static final int WM_VSCROLL = 0x115;
+ public static final int WM_WINDOWPOSCHANGING = 0x46;
+ 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_CLIPCHILDREN = 0x2000000;
+ public static final int WS_CLIPSIBLINGS = 0x4000000;
+ public static final int WS_EX_CAPTIONOKBTN = 0x80000000;
+ public static final int WS_EX_CLIENTEDGE = 0x200;
+ public static final int WS_EX_DLGMODALFRAME = 0x1;
+ public static final int WS_EX_LAYOUTRTL = 0x00400000;
+ public static final int WS_EX_NOINHERITLAYOUT = 0x00100000;
+ 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_HSCROLL = 0x100000;
+ public static final int WS_MAXIMIZEBOX = OS.IsWinCE ? 0x20000 : 0x10000;
+ public static final int WS_MINIMIZEBOX = OS.IsWinCE ? 0x10000 : 0x20000;
+ public static final int WS_OVERLAPPED = OS.IsWinCE ? WS_BORDER | WS_CAPTION : 0x0;
+ public static final int WS_OVERLAPPEDWINDOW = 0xcf0000;
+ public static final int WS_POPUP = 0x80000000;
+ 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_VISIBLE = 0x10000000;
+ public static final int WS_VSCROLL = 0x200000;
+
+/** Ansi/Unicode wrappers */
+
+public static final int CallWindowProc (int lpPrevWndFunc, int hWnd, int Msg, int wParam, int lParam) {
+ if (IsUnicode) return CallWindowProcW (lpPrevWndFunc, hWnd, Msg, wParam, lParam);
+ return CallWindowProcA (lpPrevWndFunc, hWnd, Msg, wParam, lParam);
+}
+
+public static final short CharUpper (short ch) {
+ if (IsUnicode) return CharUpperW (ch);
+ return CharUpperA (ch);
+}
+
+public static final short CharLower (short ch) {
+ if (IsUnicode) return CharLowerW (ch);
+ return CharLowerA (ch);
+}
+
+public static final boolean ChooseColor (CHOOSECOLOR lpcc) {
+ if (IsUnicode) return ChooseColorW (lpcc);
+ return ChooseColorA (lpcc);
+}
+
+public static final boolean ChooseFont (CHOOSEFONT chooseFont) {
+ if (IsUnicode) return ChooseFontW (chooseFont);
+ return ChooseFontA (chooseFont);
+}
+
+public static final int CreateAcceleratorTable (byte [] lpaccl, int cEntries) {
+ if (IsUnicode) return CreateAcceleratorTableW (lpaccl, cEntries);
+ return CreateAcceleratorTableA (lpaccl, cEntries);
+}
+
+public static final int CreateDC (TCHAR lpszDriver, TCHAR lpszDevice, int lpszOutput, int lpInitData) {
+ if (IsUnicode) {
+ char [] lpszDriver1 = lpszDriver == null ? null : lpszDriver.chars;
+ char [] lpszDevice1 = lpszDevice == null ? null : lpszDevice.chars;
+ return CreateDCW (lpszDriver1, lpszDevice1, lpszOutput, lpInitData);
+ }
+ byte [] lpszDriver1 = lpszDriver == null ? null : lpszDriver.bytes;
+ byte [] lpszDevice1 = lpszDevice == null ? null : lpszDevice.bytes;
+ return CreateDCA (lpszDriver1, lpszDevice1, lpszOutput, lpInitData);
+}
+
+public static final int CreateFontIndirect (int lplf) {
+ if (IsUnicode) return CreateFontIndirectW (lplf);
+ return CreateFontIndirectA (lplf);
+}
+
+public static final int CreateFontIndirect (LOGFONT lplf) {
+ if (IsUnicode) return CreateFontIndirectW (lplf);
+ return CreateFontIndirectA (lplf);
+}
+
+public static final int CreateWindowEx (int dwExStyle, TCHAR lpClassName, TCHAR lpWindowName, int dwStyle, int X, int Y, int nWidth, int nHeight, int hWndParent, int hMenu, int hInstance, CREATESTRUCT lpParam) {
+ if (IsUnicode) {
+ char [] lpClassName1 = lpClassName == null ? null : lpClassName.chars;
+ char [] lpWindowName1 = lpWindowName == null ? null : lpWindowName.chars;
+ return CreateWindowExW (dwExStyle, lpClassName1, lpWindowName1, dwStyle, X, Y, nWidth, nHeight, hWndParent, hMenu, hInstance, lpParam);
+ }
+ byte [] lpClassName1 = lpClassName == null ? null : lpClassName.bytes;
+ byte [] lpWindowName1 = lpWindowName == null ? null : lpWindowName.bytes;
+ return CreateWindowExA (dwExStyle, lpClassName1, lpWindowName1, dwStyle, X, Y, nWidth, nHeight, hWndParent, hMenu, hInstance, lpParam);
+}
+
+public static final int DefWindowProc (int hWnd, int Msg, int wParam, int lParam) {
+ if (IsUnicode) return DefWindowProcW (hWnd, Msg, wParam, lParam);
+ return DefWindowProcA (hWnd, Msg, wParam, lParam);
+}
+
+public static final int DispatchMessage (MSG lpmsg) {
+ if (IsUnicode) return DispatchMessageW (lpmsg);
+ return DispatchMessageA (lpmsg);
+}
+
+public static final int DragQueryFile (int hDrop, int iFile, TCHAR lpszFile, int cch) {
+ if (IsUnicode) {
+ char [] lpszFile1 = lpszFile == null ? null : lpszFile.chars;
+ return DragQueryFileW (hDrop, iFile, lpszFile1, cch);
+ }
+ byte [] lpszFile1 = lpszFile == null ? null : lpszFile.bytes;
+ return DragQueryFileA (hDrop, iFile, lpszFile1, cch);
+}
+
+public static final boolean DrawState (int hdc, int hbr, int lpOutputFunc, int lData, int wData, int x, int y, int cx, int cy, int fuFlags) {
+ if (IsUnicode) return DrawStateW (hdc, hbr, lpOutputFunc, lData, wData, x, y, cx, cy, fuFlags);
+ return DrawStateA (hdc, hbr, lpOutputFunc, lData, wData, x, y, cx, cy, fuFlags);
+}
+
+public static final int DrawText (int hDC, TCHAR lpString, int nCount, RECT lpRect, int uFormat) {
+ if (IsUnicode) {
+ char [] lpString1 = lpString == null ? null : lpString.chars;
+ return DrawTextW (hDC, lpString1, nCount, lpRect, uFormat);
+ }
+ byte [] lpString1 = lpString == null ? null : lpString.bytes;
+ return DrawTextA (hDC, lpString1, nCount, lpRect, uFormat);
+}
+
+public static final int EnumFontFamilies (int hdc, TCHAR lpszFamily, int lpEnumFontFamProc, int lParam) {
+ if (IsUnicode) {
+ char [] lpszFamily1 = lpszFamily == null ? null : lpszFamily.chars;
+ return EnumFontFamiliesW (hdc, lpszFamily1, lpEnumFontFamProc, lParam);
+ }
+ byte [] lpszFamily1 = lpszFamily == null ? null : lpszFamily.bytes;
+ return EnumFontFamiliesA (hdc, lpszFamily1, lpEnumFontFamProc, lParam);
+}
+
+public static final boolean EnumSystemLocales (int lpLocaleEnumProc, int dwFlags) {
+ if (IsUnicode) return EnumSystemLocalesW (lpLocaleEnumProc, dwFlags);
+ return EnumSystemLocalesA (lpLocaleEnumProc, dwFlags);
+}
+
+public static final boolean EnumSystemLanguageGroups (int pLangGroupEnumProc, int dwFlags, int lParam) {
+ if (IsUnicode) return EnumSystemLanguageGroupsW (pLangGroupEnumProc, dwFlags, lParam);
+ return EnumSystemLanguageGroupsA (pLangGroupEnumProc, dwFlags, lParam);
+}
+
+public static final int ExpandEnvironmentStrings (TCHAR lpSrc, TCHAR lpDst, int nSize) {
+ if (IsUnicode) {
+ char [] lpSrc1 = lpSrc == null ? null : lpSrc.chars;
+ char [] lpDst1 = lpDst == null ? null : lpDst.chars;
+ return ExpandEnvironmentStringsW (lpSrc1, lpDst1, nSize);
+ }
+ byte [] lpSrc1 = lpSrc == null ? null : lpSrc.bytes;
+ byte [] lpDst1 = lpDst == null ? null : lpDst.bytes;
+ return ExpandEnvironmentStringsA (lpSrc1, lpDst1, nSize);
+}
+
+public static final int ExtractIconEx (TCHAR lpszFile, int nIconIndex, int [] phiconLarge, int [] phiconSmall, int nIcons) {
+ if (IsUnicode) {
+ char [] lpszFile1 = lpszFile == null ? null : lpszFile.chars;
+ return ExtractIconExW (lpszFile1, nIconIndex, phiconLarge, phiconSmall, nIcons);
+ }
+ byte [] lpszFile1 = lpszFile == null ? null : lpszFile.bytes;
+ return ExtractIconExA (lpszFile1, nIconIndex, phiconLarge, phiconSmall, nIcons);
+}
+
+public static final boolean ExtTextOut(int hdc, int X, int Y, int fuOptions, RECT lprc, TCHAR lpString, int cbCount, int[] lpDx) {
+ if (IsUnicode) {
+ char [] lpString1 = lpString == null ? null : lpString.chars;
+ return ExtTextOutW (hdc, X, Y, fuOptions, lprc, lpString1, cbCount, lpDx);
+ }
+ byte [] lpString1 = lpString == null ? null : lpString.bytes;
+ return ExtTextOutA (hdc, X, Y, fuOptions, lprc, lpString1, cbCount, lpDx);
+}
+
+public static final int FindWindow (TCHAR lpClassName, TCHAR lpWindowName) {
+ if (IsUnicode) {
+ char [] lpClassName1 = lpClassName == null ? null : lpClassName.chars;
+ char [] lpWindowName1 = lpWindowName == null ? null : lpWindowName.chars;
+ return FindWindowW (lpClassName1, lpWindowName1);
+ }
+ byte [] lpClassName1 = lpClassName == null ? null : lpClassName.bytes;
+ byte [] lpWindowName1 = lpWindowName == null ? null : lpWindowName.bytes;
+ return FindWindowA (lpClassName1, lpWindowName1);
+}
+
+public static final boolean GetCharABCWidths (int hdc, int iFirstChar, int iLastChar, int [] lpabc) {
+ if (IsUnicode) return GetCharABCWidthsW (hdc,iFirstChar, iLastChar, lpabc);
+ return GetCharABCWidthsA (hdc,iFirstChar, iLastChar, lpabc);
+}
+
+public static final int GetCharacterPlacement (int hdc, TCHAR lpString, int nCount, int nMaxExtent, GCP_RESULTS lpResults, int dwFlags) {
+ if (IsUnicode) {
+ char [] lpString1 = lpString == null ? null : lpString.chars;
+ return GetCharacterPlacementW (hdc, lpString1, nCount, nMaxExtent, lpResults, dwFlags);
+ }
+ byte [] lpString1 = lpString == null ? null : lpString.bytes;
+ return GetCharacterPlacementA (hdc, lpString1, nCount, nMaxExtent, lpResults, dwFlags);
+}
+
+public static final boolean GetCharWidth (int hdc, int iFirstChar, int iLastChar, int [] lpabc) {
+ if (IsUnicode) return GetCharWidthW (hdc,iFirstChar, iLastChar, lpabc);
+ return GetCharWidthA (hdc,iFirstChar, iLastChar, lpabc);
+}
+
+public static final boolean GetClassInfo (int hInstance, TCHAR lpClassName, WNDCLASS lpWndClass) {
+ if (IsUnicode) {
+ char [] lpClassName1 = lpClassName == null ? null : lpClassName.chars;
+ return GetClassInfoW (hInstance, lpClassName1, lpWndClass);
+ }
+ byte [] lpClassName1 = lpClassName == null ? null : lpClassName.bytes;
+ return GetClassInfoA (hInstance, lpClassName1, lpWndClass);
+}
+
+public static final int GetClipboardFormatName (int format, TCHAR lpszFormatName, int cchMaxCount) {
+ if (IsUnicode) {
+ char [] lpszFormatName1 = lpszFormatName == null ? null : lpszFormatName.chars;
+ return GetClipboardFormatNameW (format, lpszFormatName1, cchMaxCount);
+ }
+ byte [] lpszFormatName1 = lpszFormatName == null ? null : lpszFormatName.bytes;
+ return GetClipboardFormatNameA (format, lpszFormatName1, cchMaxCount);
+}
+
+public static final int GetKeyNameText (int lParam, TCHAR lpString, int nSize) {
+ if (IsUnicode) {
+ char [] lpString1 = lpString == null ? null : lpString.chars;
+ return GetKeyNameTextW (lParam, lpString1, nSize);
+ }
+ byte [] lpString1 = lpString == null ? null : lpString.bytes;
+ return GetKeyNameTextA (lParam, lpString1, nSize);
+}
+
+public static final int GetLocaleInfo (int Locale, int LCType, TCHAR lpLCData, int cchData) {
+ if (IsUnicode) {
+ char [] lpLCData1 = lpLCData == null ? null : lpLCData.chars;
+ return GetLocaleInfoW (Locale, LCType, lpLCData1, cchData);
+ }
+ byte [] lpLCData1 = lpLCData == null ? null : lpLCData.bytes;
+ return GetLocaleInfoA (Locale, LCType, lpLCData1, cchData);
+}
+
+public static final boolean GetMenuItemInfo (int hMenu, int uItem, boolean fByPosition, MENUITEMINFO lpmii) {
+ if (IsUnicode) return GetMenuItemInfoW (hMenu, uItem, fByPosition, lpmii);
+ return GetMenuItemInfoA (hMenu, uItem, fByPosition, lpmii);
+}
+
+public static final boolean GetMessage (MSG lpMsg, int hWnd, int wMsgFilterMin, int wMsgFilterMax) {
+ if (IsUnicode) return GetMessageW (lpMsg, hWnd, wMsgFilterMin, wMsgFilterMax);
+ return GetMessageA (lpMsg, hWnd, wMsgFilterMin, wMsgFilterMax);
+}
+
+public static final int GetModuleHandle (TCHAR lpModuleName) {
+ if (IsUnicode) {
+ char [] lpModuleName1 = lpModuleName == null ? null : lpModuleName.chars;
+ return GetModuleHandleW (lpModuleName1);
+ }
+ byte [] lpModuleName1 = lpModuleName == null ? null : lpModuleName.bytes;
+ return GetModuleHandleA (lpModuleName1);
+}
+
+public static final int GetObject (int hgdiobj, int cbBuffer, BITMAP lpvObject) {
+ if (IsUnicode) return GetObjectW (hgdiobj, cbBuffer, lpvObject);
+ return GetObjectA (hgdiobj, cbBuffer, lpvObject);
+}
+
+public static final int GetObject (int hgdiobj, int cbBuffer, DIBSECTION lpvObject) {
+ if (IsUnicode) return GetObjectW (hgdiobj, cbBuffer, lpvObject);
+ return GetObjectA (hgdiobj, cbBuffer, lpvObject);
+}
+
+public static final int GetObject (int hgdiobj, int cbBuffer, LOGBRUSH lpvObject) {
+ if (IsUnicode) return GetObjectW (hgdiobj, cbBuffer, lpvObject);
+ return GetObjectA (hgdiobj, cbBuffer, lpvObject);
+}
+
+public static final int GetObject (int hgdiobj, int cbBuffer, LOGFONT lpvObject) {
+ if (IsUnicode) return GetObjectW (hgdiobj, cbBuffer, lpvObject);
+ return GetObjectA (hgdiobj, cbBuffer, lpvObject);
+}
+
+public static final int GetObject (int hgdiobj, int cbBuffer, LOGPEN lpvObject) {
+ if (IsUnicode) return GetObjectW (hgdiobj, cbBuffer, lpvObject);
+ return GetObjectA (hgdiobj, cbBuffer, lpvObject);
+}
+
+public static final boolean GetOpenFileName (OPENFILENAME lpofn) {
+ if (IsUnicode) return GetOpenFileNameW (lpofn);
+ return GetOpenFileNameA (lpofn);
+}
+
+public static final int GetProfileString (TCHAR lpAppName, TCHAR lpKeyName, TCHAR lpDefault, TCHAR lpReturnedString, int nSize) {
+ if (IsUnicode) {
+ char [] lpAppName1 = lpAppName == null ? null : lpAppName.chars;
+ char [] lpKeyName1 = lpKeyName == null ? null : lpKeyName.chars;
+ char [] lpDefault1 = lpDefault == null ? null : lpDefault.chars;
+ char [] lpReturnedString1 = lpReturnedString == null ? null : lpReturnedString.chars;
+ return GetProfileStringW (lpAppName1, lpKeyName1, lpDefault1, lpReturnedString1, nSize);
+ }
+ byte [] lpAppName1 = lpAppName == null ? null : lpAppName.bytes;
+ byte [] lpKeyName1 = lpKeyName == null ? null : lpKeyName.bytes;
+ byte [] lpDefault1 = lpDefault == null ? null : lpDefault.bytes;
+ byte [] lpReturnedString1 = lpReturnedString == null ? null : lpReturnedString.bytes;
+ return GetProfileStringA (lpAppName1, lpKeyName1, lpDefault1, lpReturnedString1, nSize);
+}
+
+public static final boolean GetSaveFileName (OPENFILENAME lpofn) {
+ if (IsUnicode) return GetSaveFileNameW (lpofn);
+ return GetSaveFileNameA (lpofn);
+}
+
+public static final boolean GetTextExtentPoint32 (int hdc, TCHAR lpString, int cbString, SIZE lpSize) {
+ if (IsUnicode) {
+ char [] lpString1 = lpString == null ? null : lpString.chars;
+ return GetTextExtentPoint32W (hdc, lpString1, cbString, lpSize);
+ }
+ byte [] lpString1 = lpString == null ? null : lpString.bytes;
+ return GetTextExtentPoint32A (hdc, lpString1, cbString, lpSize);
+}
+
+public static final boolean GetTextMetrics (int hdc, TEXTMETRIC lptm) {
+ if (IsUnicode) return GetTextMetricsW (hdc, lptm);
+ return GetTextMetricsA (hdc, lptm);
+}
+
+public static final boolean GetVersionEx (OSVERSIONINFO lpVersionInfo) {
+ if (IsUnicode) return GetVersionExW (lpVersionInfo);
+ return GetVersionExA (lpVersionInfo);
+}
+
+public static final int GetWindowLong (int hWnd, int nIndex) {
+ if (IsUnicode) return GetWindowLongW (hWnd, nIndex);
+ return GetWindowLongA (hWnd, nIndex);
+}
+
+public static final int GetWindowText (int hWnd, TCHAR lpString, int nMaxCount) {
+ if (IsUnicode) {
+ char [] lpString1 = lpString == null ? null : lpString.chars;
+ return GetWindowTextW (hWnd, lpString1, nMaxCount);
+ }
+ byte [] lpString1 = lpString == null ? null : lpString.bytes;
+ return GetWindowTextA (hWnd, lpString1, nMaxCount);
+}
+
+public static final int GetWindowTextLength (int hWnd) {
+ if (IsUnicode) return GetWindowTextLengthW (hWnd);
+ return GetWindowTextLengthA (hWnd);
+}
+
+public static final boolean ImmGetCompositionFont (int hIMC, LOGFONT lplf) {
+ if (IsUnicode) return ImmGetCompositionFontW (hIMC, lplf);
+ return ImmGetCompositionFontA (hIMC, lplf);
+}
+
+public static final boolean ImmSetCompositionFont (int hIMC, LOGFONT lplf) {
+ if (IsUnicode) return ImmSetCompositionFontW (hIMC, lplf);
+ return ImmSetCompositionFontA (hIMC, lplf);
+}
+
+public static final int ImmGetCompositionString (int hIMC, int dwIndex, TCHAR lpBuf, int dwBufLen) {
+ if (IsUnicode) {
+ char [] lpBuf1 = lpBuf == null ? null : lpBuf.chars;
+ return ImmGetCompositionStringW (hIMC, dwIndex, lpBuf1, dwBufLen);
+ }
+ byte [] lpBuf1 = lpBuf == null ? null : lpBuf.bytes;
+ return ImmGetCompositionStringA (hIMC, dwIndex, lpBuf1, dwBufLen);
+}
+
+public static final boolean InsertMenu (int hMenu, int uPosition, int uFlags, int uIDNewItem, TCHAR lpNewItem) {
+ if (IsUnicode) {
+ char [] lpNewItem1 = lpNewItem == null ? null : lpNewItem.chars;
+ return InsertMenuW (hMenu, uPosition, uFlags, uIDNewItem, lpNewItem1);
+ }
+ byte [] lpNewItem1 = lpNewItem == null ? null : lpNewItem.bytes;
+ return InsertMenuA (hMenu, uPosition, uFlags, uIDNewItem, lpNewItem1);
+}
+
+public static final boolean InsertMenuItem (int hMenu, int uItem, boolean fByPosition, MENUITEMINFO lpmii) {
+ if (IsUnicode) return InsertMenuItemW (hMenu, uItem, fByPosition, lpmii);
+ return InsertMenuItemA (hMenu, uItem, fByPosition, lpmii);
+}
+
+public static final int LoadBitmap (int hInstance, int lpBitmapName) {
+ if (IsUnicode) return LoadBitmapW (hInstance, lpBitmapName);
+ return LoadBitmapA (hInstance, lpBitmapName);
+}
+
+public static final int LoadCursor (int hInstance, int lpCursorName) {
+ if (IsUnicode) return LoadCursorW (hInstance, lpCursorName);
+ return LoadCursorA (hInstance, lpCursorName);
+}
+
+public static final int LoadIcon (int hInstance, int lpIconName) {
+ if (IsUnicode) return LoadIconW (hInstance, lpIconName);
+ return LoadIconA (hInstance, lpIconName);
+}
+
+public static final int LoadImage (int hinst, TCHAR lpszName, int uType, int cxDesired, int cyDesired, int fuLoad) {
+ if (IsUnicode) {
+ char [] lpszName1 = lpszName == null ? null : lpszName.chars;
+ return LoadImageW (hinst, lpszName1, uType, cxDesired, cyDesired, fuLoad);
+ }
+ byte [] lpszName1 = lpszName == null ? null : lpszName.bytes;
+ return LoadImageA (hinst, lpszName1, uType, cxDesired, cyDesired, fuLoad);
+}
+
+public static final int LoadLibrary (TCHAR lpLibFileName) {
+ if (IsUnicode) {
+ char [] lpLibFileName1 = lpLibFileName == null ? null : lpLibFileName.chars;
+ return LoadLibraryW (lpLibFileName1);
+ }
+ byte [] lpLibFileName1 = lpLibFileName == null ? null : lpLibFileName.bytes;
+ return LoadLibraryA (lpLibFileName1);
+}
+
+public static final int MapVirtualKey (int uCode, int uMapType) {
+ if (IsUnicode) return MapVirtualKeyW (uCode, uMapType);
+ return MapVirtualKeyA (uCode, uMapType);
+}
+
+public static final int MessageBox (int hWnd, TCHAR lpText, TCHAR lpCaption, int uType) {
+ if (IsUnicode) {
+ char [] lpText1 = lpText == null ? null : lpText.chars;
+ char [] lpCaption1 = lpCaption == null ? null : lpCaption.chars;
+ return MessageBoxW (hWnd, lpText1, lpCaption1, uType);
+ }
+ byte [] lpText1 = lpText == null ? null : lpText.bytes;
+ byte [] lpCaption1 = lpCaption == null ? null : lpCaption.bytes;
+ return MessageBoxA (hWnd, lpText1, lpCaption1, uType);
+}
+
+public static final void MoveMemory (int Destination, TCHAR Source, int Length) {
+ if (IsUnicode) {
+ char [] Source1 = Source == null ? null : Source.chars;
+ MoveMemory (Destination, Source1, Length);
+ } else {
+ byte [] Source1 = Source == null ? null : Source.bytes;
+ MoveMemory (Destination, Source1, Length);
+ }
+}
+
+public static final void MoveMemory (TCHAR Destination, int Source, int Length) {
+ if (IsUnicode) {
+ char [] Destination1 = Destination == null ? null : Destination.chars;
+ MoveMemory (Destination1, Source, Length);
+ } else {
+ byte [] Destination1 = Destination == null ? null : Destination.bytes;
+ MoveMemory (Destination1, Source, Length);
+ }
+}
+
+public static final void MoveMemory (int Destination, LOGFONT Source, int Length) {
+ if (IsUnicode) {
+ MoveMemoryW (Destination, Source, Length);
+ } else {
+ MoveMemoryA (Destination, Source, Length);
+ }
+}
+
+public static final void MoveMemory (LOGFONT Destination, int Source, int Length) {
+ if (IsUnicode) {
+ MoveMemoryW (Destination, Source, Length);
+ } else {
+ MoveMemoryA (Destination, Source, Length);
+ }
+}
+
+public static final void MoveMemory (int Destination, NMTTDISPINFO Source, int Length) {
+ if (IsUnicode) {
+ MoveMemoryW (Destination, Source, Length);
+ } else {
+ MoveMemoryA (Destination, Source, Length);
+ }
+}
+
+public static final void MoveMemory (NMTTDISPINFO Destination, int Source, int Length) {
+ if (IsUnicode) {
+ MoveMemoryW (Destination, Source, Length);
+ } else {
+ MoveMemoryA (Destination, Source, Length);
+ }
+}
+
+public static final boolean PeekMessage (MSG lpMsg, int hWnd, int wMsgFilterMin, int wMsgFilterMax, int wRemoveMsg) {
+ if (IsUnicode) return PeekMessageW (lpMsg, hWnd, wMsgFilterMin, wMsgFilterMax, wRemoveMsg);
+ return PeekMessageA (lpMsg, hWnd, wMsgFilterMin, wMsgFilterMax, wRemoveMsg);
+}
+
+public static final boolean PostMessage (int hWnd, int Msg, int wParam, int lParam) {
+ if (IsUnicode) return PostMessageW (hWnd, Msg, wParam, lParam);
+ return PostMessageA (hWnd, Msg, wParam, lParam);
+}
+
+public static final boolean PostThreadMessage (int idThread, int Msg, int wParam, int lParam) {
+ if (IsUnicode) return PostThreadMessageW (idThread, Msg, wParam, lParam);
+ return PostThreadMessageA (idThread, Msg, wParam, lParam);
+}
+
+public static final boolean PrintDlg (PRINTDLG lppd) {
+ if (IsUnicode) return PrintDlgW (lppd);
+ return PrintDlgA (lppd);
+}
+
+public static final int RegEnumKeyEx (int hKey, int dwIndex, TCHAR lpName, int [] lpcName, int [] lpReserved, TCHAR lpClass, int [] lpcClass, FILETIME lpftLastWriteTime) {
+ if (IsUnicode) {
+ char [] lpName1 = lpName == null ? null : lpName.chars;
+ char [] lpClass1 = lpClass == null ? null : lpClass.chars;
+ return RegEnumKeyExW (hKey, dwIndex, lpName1, lpcName, lpReserved, lpClass1, lpcClass, lpftLastWriteTime);
+ }
+ byte [] lpName1 = lpName == null ? null : lpName.bytes;
+ byte [] lpClass1 = lpClass == null ? null : lpClass.bytes;
+ return RegEnumKeyExA (hKey, dwIndex, lpName1, lpcName, lpReserved, lpClass1, lpcClass, lpftLastWriteTime);
+}
+
+public static final int RegisterClass (WNDCLASS lpWndClass) {
+ if (IsUnicode) return RegisterClassW (lpWndClass);
+ return RegisterClassA (lpWndClass);
+}
+
+public static final int RegisterClipboardFormat (TCHAR lpszFormat) {
+ if (IsUnicode) {
+ char [] lpszFormat1 = lpszFormat == null ? null : lpszFormat.chars;
+ return RegisterClipboardFormatW (lpszFormat1);
+ }
+ byte [] lpszFormat1 = lpszFormat == null ? null : lpszFormat.bytes;
+ return RegisterClipboardFormatA (lpszFormat1);
+}
+
+public static final int RegOpenKeyEx (int hKey, TCHAR lpSubKey, int ulOptions, int samDesired, int[] phkResult) {
+ if (IsUnicode) {
+ char [] lpSubKey1 = lpSubKey == null ? null : lpSubKey.chars;
+ return RegOpenKeyExW (hKey, lpSubKey1, ulOptions, samDesired, phkResult);
+ }
+ byte [] lpSubKey1 = lpSubKey == null ? null : lpSubKey.bytes;
+ return RegOpenKeyExA (hKey, lpSubKey1, ulOptions, samDesired, phkResult);
+}
+
+public static final 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){
+ if (IsUnicode) return RegQueryInfoKeyW (hKey, lpClass, lpcbClass, lpReserved, lpSubKeys, lpcbMaxSubKeyLen, lpcbMaxClassLen, lpcValues, lpcbMaxValueNameLen, lpcbMaxValueLen, lpcbSecurityDescriptor, lpftLastWriteTime);
+ return RegQueryInfoKeyA (hKey, lpClass, lpcbClass, lpReserved, lpSubKeys, lpcbMaxSubKeyLen, lpcbMaxClassLen, lpcValues, lpcbMaxValueNameLen, lpcbMaxValueLen, lpcbSecurityDescriptor, lpftLastWriteTime);
+}
+
+public static final int RegQueryValueEx (int hKey, TCHAR lpValueName, int lpReserved, int[] lpType, TCHAR lpData, int[] lpcbData) {
+ if (IsUnicode) {
+ char [] lpValueName1 = lpValueName == null ? null : lpValueName.chars;
+ char [] lpData1 = lpData == null ? null : lpData.chars;
+ return RegQueryValueExW (hKey, lpValueName1, lpReserved, lpType, lpData1, lpcbData);
+ }
+ byte [] lpValueName1 = lpValueName == null ? null : lpValueName.bytes;
+ byte [] lpData1 = lpData == null ? null : lpData.bytes;
+ return RegQueryValueExA (hKey, lpValueName1, lpReserved, lpType, lpData1, lpcbData);
+}
+
+public static final int SendMessage (int hWnd, int Msg, int wParam, TCHAR lParam) {
+ if (IsUnicode) {
+ char [] lParam1 = lParam == null ? null : lParam.chars;
+ return SendMessageW (hWnd, Msg, wParam, lParam1);
+ }
+ byte [] lParam1 = lParam == null ? null : lParam.bytes;
+ return SendMessageA (hWnd, Msg, wParam, lParam1);
+}
+
+public static final int SendMessage (int hWnd, int Msg, int [] wParam, int [] lParam) {
+ if (IsUnicode) return SendMessageW (hWnd, Msg, wParam, lParam);
+ return SendMessageA (hWnd, Msg, wParam, lParam);
+}
+
+public static final int SendMessage (int hWnd, int Msg, int [] wParam, int lParam) {
+ if (IsUnicode) return SendMessageW (hWnd, Msg, wParam, lParam);
+ return SendMessageA (hWnd, Msg, wParam, lParam);
+}
+
+public static final int SendMessage (int hWnd, int Msg, int wParam, int [] lParam) {
+ if (IsUnicode) return SendMessageW (hWnd, Msg, wParam, lParam);
+ return SendMessageA (hWnd, Msg, wParam, lParam);
+}
+
+public static final int SendMessage (int hWnd, int Msg, int wParam, short [] lParam) {
+ if (IsUnicode) return SendMessageW (hWnd, Msg, wParam, lParam);
+ return SendMessageA (hWnd, Msg, wParam, lParam);
+}
+
+public static final int SendMessage (int hWnd, int Msg, int wParam, int lParam) {
+ if (IsUnicode) return SendMessageW (hWnd, Msg, wParam, lParam);
+ return SendMessageA (hWnd, Msg, wParam, lParam);
+}
+
+public static final int SendMessage (int hWnd, int Msg, int wParam, LVCOLUMN lParam) {
+ if (IsUnicode) return SendMessageW (hWnd, Msg, wParam, lParam);
+ return SendMessageA (hWnd, Msg, wParam, lParam);
+}
+
+public static final int SendMessage (int hWnd, int Msg, int wParam, LVHITTESTINFO lParam) {
+ if (IsUnicode) return SendMessageW (hWnd, Msg, wParam, lParam);
+ return SendMessageA (hWnd, Msg, wParam, lParam);
+}
+
+public static final int SendMessage (int hWnd, int Msg, int wParam, LVITEM lParam) {
+ if (IsUnicode) return SendMessageW (hWnd, Msg, wParam, lParam);
+ return SendMessageA (hWnd, Msg, wParam, lParam);
+}
+
+public static final int SendMessage (int hWnd, int Msg, int wParam, REBARBANDINFO lParam) {
+ if (IsUnicode) return SendMessageW (hWnd, Msg, wParam, lParam);
+ return SendMessageA (hWnd, Msg, wParam, lParam);
+}
+
+public static final int SendMessage (int hWnd, int Msg, int wParam, RECT lParam) {
+ if (IsUnicode) return SendMessageW (hWnd, Msg, wParam, lParam);
+ return SendMessageA (hWnd, Msg, wParam, lParam);
+}
+
+public static final int SendMessage (int hWnd, int Msg, int wParam, TBBUTTON lParam) {
+ if (IsUnicode) return SendMessageW (hWnd, Msg, wParam, lParam);
+ return SendMessageA (hWnd, Msg, wParam, lParam);
+}
+
+public static final int SendMessage (int hWnd, int Msg, int wParam, TBBUTTONINFO lParam) {
+ if (IsUnicode) return SendMessageW (hWnd, Msg, wParam, lParam);
+ return SendMessageA (hWnd, Msg, wParam, lParam);
+}
+
+public static final int SendMessage (int hWnd, int Msg, int wParam, TCITEM lParam) {
+ if (IsUnicode) return SendMessageW (hWnd, Msg, wParam, lParam);
+ return SendMessageA (hWnd, Msg, wParam, lParam);
+}
+
+public static final int SendMessage (int hWnd, int Msg, int wParam, TOOLINFO lParam) {
+ if (IsUnicode) return SendMessageW (hWnd, Msg, wParam, lParam);
+ return SendMessageA (hWnd, Msg, wParam, lParam);
+}
+
+public static final int SendMessage (int hWnd, int Msg, int wParam, TVHITTESTINFO lParam) {
+ if (IsUnicode) return SendMessageW (hWnd, Msg, wParam, lParam);
+ return SendMessageA (hWnd, Msg, wParam, lParam);
+}
+
+public static final int SendMessage (int hWnd, int Msg, int wParam, TVINSERTSTRUCT lParam) {
+ if (IsUnicode) return SendMessageW (hWnd, Msg, wParam, lParam);
+ return SendMessageA (hWnd, Msg, wParam, lParam);
+}
+
+public static final int SendMessage (int hWnd, int Msg, int wParam, TVITEM lParam) {
+ if (IsUnicode) return SendMessageW (hWnd, Msg, wParam, lParam);
+ return SendMessageA (hWnd, Msg, wParam, lParam);
+}
+
+public static final boolean SetMenuItemInfo (int hMenu, int uItem, boolean fByPosition, MENUITEMINFO lpmii) {
+ if (IsUnicode) return SetMenuItemInfoW (hMenu, uItem, fByPosition, lpmii);
+ return SetMenuItemInfoA (hMenu, uItem, fByPosition, lpmii);
+}
+
+public static final int SetWindowLong (int hWnd, int nIndex, int dwNewLong) {
+ if (IsUnicode) return SetWindowLongW (hWnd, nIndex, dwNewLong);
+ return SetWindowLongA (hWnd, nIndex, dwNewLong);
+}
+
+public static final int SetWindowsHookEx (int idHook, int lpfn, int hMod, int dwThreadId) {
+ if (IsUnicode) return SetWindowsHookExW (idHook, lpfn, hMod, dwThreadId);
+ return SetWindowsHookExA (idHook, lpfn, hMod, dwThreadId);
+}
+
+public static final boolean SetWindowText (int hWnd, TCHAR lpString) {
+ if (IsUnicode) {
+ char [] lpString1 = lpString == null ? null : lpString.chars;
+ return SetWindowTextW (hWnd, lpString1);
+ }
+ byte [] lpString1 = lpString == null ? null : lpString.bytes;
+ return SetWindowTextA (hWnd, lpString1);
+}
+
+public static final int SHBrowseForFolder (BROWSEINFO lpbi) {
+ if (IsUnicode) return SHBrowseForFolderW (lpbi);
+ return SHBrowseForFolderA (lpbi);
+}
+
+public static final boolean ShellExecuteEx (SHELLEXECUTEINFO lpExecInfo) {
+ if (IsUnicode) return ShellExecuteExW (lpExecInfo);
+ return ShellExecuteExA (lpExecInfo);
+}
+
+public static final boolean SHGetPathFromIDList (int pidl, TCHAR pszPath) {
+ if (IsUnicode) {
+ char [] pszPath1 = pszPath == null ? null : pszPath.chars;
+ return SHGetPathFromIDListW (pidl, pszPath1);
+ }
+ byte [] pszPath1 = pszPath == null ? null : pszPath.bytes;
+ return SHGetPathFromIDListA (pidl, pszPath1);
+}
+
+public static final int StartDoc (int hdc, DOCINFO lpdi) {
+ if (IsUnicode) return StartDocW (hdc, lpdi);
+ return StartDocA (hdc, lpdi);
+}
+
+public static final boolean SystemParametersInfo (int uiAction, int uiParam, RECT pvParam, int fWinIni) {
+ if (IsUnicode) return SystemParametersInfoW (uiAction, uiParam, pvParam, fWinIni);
+ return SystemParametersInfoA (uiAction, uiParam, pvParam, fWinIni);
+}
+
+public static final boolean SystemParametersInfo (int uiAction, int uiParam, NONCLIENTMETRICS pvParam, int fWinIni) {
+ if (IsUnicode) return SystemParametersInfoW (uiAction, uiParam, pvParam, fWinIni);
+ return SystemParametersInfoA (uiAction, uiParam, pvParam, fWinIni);
+}
+
+public static final boolean SystemParametersInfo (int uiAction, int uiParam, int[] pvParam, int fWinIni) {
+ if (IsUnicode) return SystemParametersInfoW (uiAction, uiParam, pvParam, fWinIni);
+ return SystemParametersInfoA (uiAction, uiParam, pvParam, fWinIni);
+}
+
+public static final int TranslateAccelerator (int hWnd, int hAccTable, MSG lpMsg) {
+ if (IsUnicode) return TranslateAcceleratorW (hWnd, hAccTable, lpMsg);
+ return TranslateAcceleratorA (hWnd, hAccTable, lpMsg);
+}
+
+public static final boolean UnregisterClass (TCHAR lpClassName, int hInstance) {
+ if (IsUnicode) {
+ char [] lpClassName1 = lpClassName == null ? null : lpClassName.chars;
+ return UnregisterClassW (lpClassName1, hInstance);
+ }
+ byte [] lpClassName1 = lpClassName == null ? null : lpClassName.bytes;
+ return UnregisterClassA (lpClassName1, hInstance);
+}
+
+public static final short VkKeyScan (short ch) {
+ if (IsUnicode) return VkKeyScanW (ch);
+ return VkKeyScanA (ch);
+}
+
+/** Natives */
+public static final native int AbortDoc (int hdc);
+public static final native int ActivateKeyboardLayout(int hkl, int Flags);
+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 CallNextHookEx(int hhk, int nCode, int wParam, int lParam);
+public static final native int CallWindowProcW (int lpPrevWndFunc, int hWnd, int Msg, int wParam, int lParam);
+public static final native int CallWindowProcA (int lpPrevWndFunc, int hWnd, int Msg, int wParam, int lParam);
+public static final native short CharLowerW (short ch);
+public static final native short CharLowerA (short ch);
+public static final native short CharUpperW (short ch);
+public static final native short CharUpperA (short ch);
+public static final native boolean CheckMenuItem (int hmenu, int uIDCheckItem, int uCheck);
+public static final native boolean ChooseColorW (CHOOSECOLOR lpcc);
+public static final native boolean ChooseColorA (CHOOSECOLOR lpcc);
+public static final native boolean ChooseFontW (CHOOSEFONT chooseFont);
+public static final native boolean ChooseFontA (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, int hrgnSrc1, int hrgnSrc2, int fnCombineMode);
+public static final native boolean CommandBar_AddAdornments (int hwndCB, int dwFlags, int dwReserved);
+public static final native int CommandBar_Create (int hInst, int hwndParent, int idCmdBar);
+public static final native void CommandBar_Destroy (int hwndCB);
+public static final native boolean CommandBar_DrawMenuBar (int hwndCB, int iButton);
+public static final native int CommandBar_Height (int hdnwCB);
+public static final native boolean CommandBar_InsertMenubarEx (int hwndCB, int hInst, int pszMenu, int iButton);
+public static final native boolean CommandBar_Show (int hwndCB, boolean fShow);
+public static final native int CommDlgExtendedError ();
+public static final native int CopyImage (int hImage, int uType, int cxDesired, int cyDesired, int fuFlags);
+public static final native int CreateAcceleratorTableW (byte [] lpaccl, int cEntries);
+public static final native int CreateAcceleratorTableA (byte [] lpaccl, int cEntries);
+public static final native int CreateBitmap (int nWidth, int nHeight, int cPlanes, int cBitsPerPel, byte [] lpvBits);
+public static final native boolean CreateCaret (int hWnd, int hBitmap, int nWidth, int nHeight);
+public static final native int CreateCompatibleBitmap (int hdc, int nWidth, int nHeight);
+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 CreateDCW (char [] lpszDriver, char [] lpszDevice, int lpszOutput, int lpInitData);
+public static final native int CreateDCA (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 CreateFontIndirectW (int lplf);
+public static final native int CreateFontIndirectA (int lplf);
+public static final native int CreateFontIndirectW (LOGFONT lplf);
+public static final native int CreateFontIndirectA (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 CreatePen (int fnPenStyle, int nWidth, int crColor);
+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 CreateWindowExW (int dwExStyle, char [] lpClassName, char [] lpWindowName, int dwStyle, int X, int Y, int nWidth, int nHeight, int hWndParent, int hMenu, int hInstance, CREATESTRUCT lpParam);
+public static final native int CreateWindowExA (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 DefWindowProcW (int hWnd, int Msg, int wParam, int lParam);
+public static final native int DefWindowProcA (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 DispatchMessageW (MSG lpmsg);
+public static final native int DispatchMessageA (MSG lpmsg);
+public static final native boolean DragDetect (int hwnd, POINT pt);
+public static final native void DragFinish (int hDrop);
+public static final native int DragQueryFileA (int hDrop, int iFile, byte[] lpszFile, int cch);
+public static final native int DragQueryFileW (int hDrop, int iFile, char[] lpszFile, int cch);
+public static final native boolean DrawEdge (int hdc, RECT qrc, int edge, int grfFlags);
+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, int xLeft, int yTop, int hIcon, int cxWidth, int cyWidth, int istepIfAniCur, int hbrFlickerFreeDraw, int diFlags);
+public static final native boolean DrawMenuBar (int hWnd);
+public static final native boolean DrawStateW (int hdc, int hbr, int lpOutputFunc, int lData, int wData, int x, int y, int cx, int cy, int fuFlags);
+public static final native boolean DrawStateA (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 DrawTextW (int hDC, char [] lpString, int nCount, RECT lpRect, int uFormat);
+public static final native int DrawTextA (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 EnumSystemLanguageGroupsW(int pLangGroupEnumProc, int dwFlags, int lParam);
+public static final native boolean EnumSystemLanguageGroupsA(int pLangGroupEnumProc, int dwFlags, int lParam);
+public static final native boolean EnumSystemLocalesW (int lpLocaleEnumProc, int dwFlags);
+public static final native boolean EnumSystemLocalesA (int lpLocaleEnumProc, int dwFlags);
+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 EnumFontFamiliesW (int hdc, char [] lpszFamily, int lpEnumFontFamProc, int lParam);
+public static final native int EnumFontFamiliesA (int hdc, byte [] lpszFamily, int lpEnumFontFamProc, int lParam);
+public static final native boolean EqualRect (RECT lprc1, RECT lprc2);
+public static final native boolean EqualRgn (int hSrcRgn1, int hSrcRgn2);
+public static final native int ExpandEnvironmentStringsW (char [] lpSrc, char [] lsDst, int nSize);
+public static final native int ExpandEnvironmentStringsA (byte [] lpSrc, byte [] lsDst, int nSize);
+public static final native boolean ExtTextOutW(int hdc, int X, int Y, int fuOptions, RECT lprc, char[] lpString, int cbCount, int[] lpDx);
+public static final native boolean ExtTextOutA(int hdc, int X, int Y, int fuOptions, RECT lprc, byte[] lpString, int cbCount, int[] lpDx);
+public static final native int ExtractIconExW (char [] lpszFile, int nIconIndex, int [] phiconLarge, int [] phiconSmall, int nIcons);
+public static final native int ExtractIconExA (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 int FindWindowA (byte [] lpClassName, byte [] lpWindowName);
+public static final native int FindWindowW (char [] lpClassName, char [] lpWindowName);
+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 GetCharABCWidthsA (int hdc, int iFirstChar, int iLastChar, int [] lpabc);
+public static final native boolean GetCharABCWidthsW (int hdc, int iFirstChar, int iLastChar, int [] lpabc);
+public static final native int GetCharacterPlacementW(int hdc, char[] lpString, int nCount, int nMaxExtent, GCP_RESULTS lpResults, int dwFlags);
+public static final native int GetCharacterPlacementA(int hdc, byte[] lpString, int nCount, int nMaxExtent, GCP_RESULTS lpResults, int dwFlags);
+public static final native boolean GetCharWidthA (int hdc, int iFirstChar, int iLastChar, int [] lpBuffer);
+public static final native boolean GetCharWidthW (int hdc, int iFirstChar, int iLastChar, int [] lpBuffer);
+public static final native boolean GetClassInfoW (int hInstance, char [] lpClassName, WNDCLASS lpWndClass);
+public static final native boolean GetClassInfoA (int hInstance, byte [] lpClassName, WNDCLASS lpWndClass);
+public static final native boolean GetClientRect (int hWnd, RECT lpRect);
+public static final native int GetClipboardData (int uFormat);
+public static final native int GetClipboardFormatNameA (int format, byte[] lpszFormatName, int cchMaxCount);
+public static final native int GetClipboardFormatNameW (int format, char[] lpszFormatName, int cchMaxCount);
+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, int nIDDlgItem);
+public static final native int GetDoubleClickTime ();
+public static final native int GetFocus ();
+public static final native int GetFontLanguageInfo(int hdc);
+public static final native boolean GetIconInfo (int hIcon, ICONINFO piconinfo);
+public static final native int GetKeyboardLayoutList(int nBuff, int[] lpList);
+public static final native int GetKeyboardLayout(int idThread);public static final native short GetKeyState (int nVirtKey);
+public static final native boolean GetKeyboardState (byte [] lpKeyState);
+public static final native int GetKeyNameTextW(int lParam, char [] lpString, int nSize);
+public static final native int GetKeyNameTextA(int lParam, byte [] lpString, int nSize);
+public static final native int GetLastActivePopup (int hWnd);
+public static final native int GetLastError ();
+/* returns the instance handle to the swt library */
+public static final native int GetLibraryHandle ();
+public static final native int GetLocaleInfoW (int Locale, int LCType, char [] lpLCData, int cchData);
+public static final native int GetLocaleInfoA (int Locale, int LCType, byte [] lpLCData, int cchData);
+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 GetMenuItemInfoW (int hMenu, int uItem, boolean fByPosition, MENUITEMINFO lpmii);
+public static final native boolean GetMenuItemInfoA (int hMenu, int uItem, boolean fByPosition, MENUITEMINFO lpmii);
+public static final native boolean GetMessageW (MSG lpMsg, int hWnd, int wMsgFilterMin, int wMsgFilterMax);
+public static final native boolean GetMessageA (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 GetTextCharset(int hdc);
+public static final native int GetTickCount ();
+public static final native int GetModuleHandleW (char [] lpModuleName);
+public static final native int GetModuleHandleA (byte [] lpModuleName);
+public static final native int GetNearestPaletteIndex(int hPal, int crColor);
+public static final native int GetObjectA (int hgdiobj, int cbBuffer, BITMAP lpvObject);
+public static final native int GetObjectW (int hgdiobj, int cbBuffer, BITMAP lpvObject);
+public static final native int GetObjectA (int hgdiobj, int cbBuffer, DIBSECTION lpvObject);
+public static final native int GetObjectW (int hgdiobj, int cbBuffer, DIBSECTION lpvObject);
+public static final native int GetObjectA (int hgdiobj, int cbBuffer, LOGBRUSH lpvObject);
+public static final native int GetObjectW (int hgdiobj, int cbBuffer, LOGBRUSH lpvObject);
+public static final native int GetObjectA (int hgdiobj, int cbBuffer, LOGFONT lpvObject);
+public static final native int GetObjectW (int hgdiobj, int cbBuffer, LOGFONT lpvObject);
+public static final native int GetObjectA (int hgdiobj, int cbBuffer, LOGPEN lpvObject);
+public static final native int GetObjectW (int hgdiobj, int cbBuffer, LOGPEN lpvObject);
+public static final native boolean GetOpenFileNameW (OPENFILENAME lpofn);
+public static final native boolean GetOpenFileNameA (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 GetPixel (int hdc, int x, int y);
+public static final native int GetProcAddress (int hModule, byte [] lpProcName);
+public static final native int GetProcessHeap ();
+public static final native int GetProfileStringW (char [] lpAppName, char [] lpKeyName, char [] lpDefault, char [] lpReturnedString, int nSize);
+public static final native int GetProfileStringA (byte [] lpAppName, byte [] lpKeyName, byte [] lpDefault, byte [] lpReturnedString, int nSize);
+public static final native int GetRegionData (int hRgn, int dwCount, int [] lpRgnData);
+public static final native int GetRgnBox (int hrgn, RECT lprc);
+public static final native int GetROP2 (int hdc);
+public static final native boolean GetSaveFileNameW (OPENFILENAME lpofn);
+public static final native boolean GetSaveFileNameA (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 GetSystemPaletteEntries(int hdc, int iStartIndex, int nEntries, byte[] lppe);
+public static final native int GetTextColor (int hDC);
+public static final native boolean GetTextExtentPoint32W (int hdc, char [] lpString, int cbString, SIZE lpSize);
+public static final native boolean GetTextExtentPoint32A (int hdc, byte [] lpString, int cbString, SIZE lpSize);
+public static final native boolean GetTextMetricsW (int hdc, TEXTMETRIC lptm);
+public static final native boolean GetTextMetricsA (int hdc, TEXTMETRIC lptm);
+public static final native boolean GetUpdateRect (int hWnd, RECT lpRect, boolean bErase);
+public static final native int GetUpdateRgn (int hWnd, int hRgn, boolean bErase);
+public static final native boolean GetVersionExW (OSVERSIONINFO lpVersionInfo);
+public static final native boolean GetVersionExA (OSVERSIONINFO lpVersionInfo);
+public static final native int GetWindow (int hWnd, int uCmd);
+public static final native int GetWindowLongW (int hWnd, int nIndex);
+public static final native int GetWindowLongA (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 GetWindowTextW (int hWnd, char [] lpString, int nMaxCount);
+public static final native int GetWindowTextA (int hWnd, byte [] lpString, int nMaxCount);
+public static final native int GetWindowTextLengthW (int hWnd);
+public static final native int GetWindowTextLengthA (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 boolean GradientFill(int hdc, int pVertex, int dwNumVertex, int pMesh, int dwNumMesh, int dwMode);
+public static final native int HeapAlloc (int hHeap, int dwFlags, int dwBytes);
+public static final native boolean HeapFree (int hHeap, int dwFlags, int lpMem);
+public static final native boolean HideCaret (int hWnd);
+public static final native int ImageList_Add (int himl, int hbmImage, int hbmMask);
+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 ImmGetCompositionFontW (int hIMC, LOGFONT lplf);
+public static final native boolean ImmGetCompositionFontA (int hIMC, LOGFONT lplf);
+public static final native int ImmGetCompositionStringW (int hIMC, int dwIndex, char [] lpBuf, int dwBufLen);
+public static final native int ImmGetCompositionStringA (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 ImmSetCompositionFontW (int hIMC, LOGFONT lplf);
+public static final native boolean ImmSetCompositionFontA (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 InsertMenuW (int hMenu, int uPosition, int uFlags, int uIDNewItem, char [] lpNewItem);
+public static final native boolean InsertMenuA (int hMenu, int uPosition, int uFlags, int uIDNewItem, byte [] lpNewItem);
+public static final native boolean InsertMenuItemW (int hMenu, int uItem, boolean fByPosition, MENUITEMINFO lpmii);
+public static final native boolean InsertMenuItemA (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 IsPPC();
+public static final native boolean IsSP();
+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 KillTimer (int hWnd, int uIDEvent);
+public static final native boolean LineTo (int hdc,int x1, int x2);
+public static final native int LoadBitmapW (int hInstance, int lpBitmapName);
+public static final native int LoadBitmapA (int hInstance, int lpBitmapName);
+public static final native int LoadCursorW (int hInstance, int lpCursorName);
+public static final native int LoadCursorA (int hInstance, int lpCursorName);
+public static final native int LoadIconW (int hInstance, int lpIconName);
+public static final native int LoadIconA (int hInstance, int lpIconName);
+public static final native int LoadImageW (int hinst, char [] lpszName, int uType, int cxDesired, int cyDesired, int fuLoad);
+public static final native int LoadImageA (int hinst, byte [] lpszName, int uType, int cxDesired, int cyDesired, int fuLoad);
+public static final native int LoadLibraryW (char [] lpLibFileName);
+public static final native int LoadLibraryA (byte [] lpLibFileName);
+public static final native int MapVirtualKeyW (int uCode, int uMapType);
+public static final native int MapVirtualKeyA (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 MessageBoxW (int hWnd, char [] lpText, char [] lpCaption, int uType);
+public static final native int MessageBoxA (int hWnd, byte [] lpText, byte [] lpCaption, int uType);
+public static final native void MoveMemory (char[] Destination, int SourcePtr, int Length);
+public static final native void MoveMemory (byte [] Destination, int Source, int Length);
+public static final native void MoveMemory (byte [] Destination, ACCEL Source, int Length);
+public static final native void MoveMemory (byte [] Destination, BITMAPINFOHEADER Source, int Length);
+public static final native void MoveMemory (int [] Destination, int Source, int Length);
+public static final native void MoveMemory (int Destination, byte [] Source, int Length);
+public static final native void MoveMemory (int Destination, char [] Source, int Length);
+public static final native void MoveMemory (int Destination, int [] Source, int Length);
+public static final native void MoveMemory (int Destination, GRADIENT_RECT Source, int Length);
+public static final native void MoveMemoryW (int Destination, LOGFONT Source, int Length);
+public static final native void MoveMemoryA (int Destination, LOGFONT Source, int Length);
+public static final native void MoveMemory (int Destination, MEASUREITEMSTRUCT Source, int Length);
+public static final native void MoveMemoryW (int Destination, NMTTDISPINFO Source, int Length);
+public static final native void MoveMemoryA (int Destination, NMTTDISPINFO Source, int Length);
+public static final native void MoveMemory (int Destination, RECT Source, int Length);
+public static final native void MoveMemory (int Destination, TRIVERTEX Source, int Length);
+public static final native void MoveMemory (int Destination, WINDOWPOS Source, int Length);
+public static final native void MoveMemory (BITMAPINFOHEADER Destination, byte [] Source, int Length);
+public static final native void MoveMemory (DRAWITEMSTRUCT Destination, int Source, int Length);
+public static final native void MoveMemory (HDITEM Destination, int Source, int Length);
+public static final native void MoveMemory (HELPINFO Destination, int Source, int Length);
+public static final native void MoveMemoryW (LOGFONT Destination, int Source, int Length);
+public static final native void MoveMemoryA (LOGFONT Destination, int Source, int Length);
+public static final native void MoveMemory (MEASUREITEMSTRUCT Destination, int Source, int Length);
+public static final native void MoveMemory (NMHDR Destination, int Source, int Length);
+public static final native void MoveMemory (NMLVCUSTOMDRAW Destination, int Source, int Length);
+public static final native void MoveMemory (NMTVCUSTOMDRAW Destination, int Source, int Length);
+public static final native void MoveMemory (int Destination, NMLVCUSTOMDRAW Source, int Length);
+public static final native void MoveMemory (int Destination, NMTVCUSTOMDRAW Source, int Length);
+public static final native void MoveMemory (NMHEADER Destination, int Source, int Length);
+public static final native void MoveMemory (NMLISTVIEW Destination, int Source, int Length);
+public static final native void MoveMemory (NMREBARCHEVRON Destination, int Source, int Length);
+public static final native void MoveMemory (NMTOOLBAR Destination, int Source, int Length);
+public static final native void MoveMemoryW (NMTTDISPINFO Destination, int Source, int Length);
+public static final native void MoveMemoryA (NMTTDISPINFO Destination, int Source, int Length);
+public static final native void MoveMemory (TVITEM Destination, int Source, int Length);
+public static final native void MoveMemory (WINDOWPOS Destination, int Source, int Length);
+public static final native void MoveMemory (MSG Destination, int Source, int Length);
+public static final native void MoveMemory(int Destination, DROPFILES Source, 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 boolean MoveToEx (int hdc,int x1, int x2, int lPoint);
+public static final native int MsgWaitForMultipleObjectsEx (int nCount, int pHandles, int dwMilliseconds, int dwWakeMask, int dwFlags);
+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 PeekMessageW (MSG lpMsg, int hWnd, int wMsgFilterMin, int wMsgFilterMax, int wRemoveMsg);
+public static final native boolean PeekMessageA (MSG lpMsg, int hWnd, int wMsgFilterMin, int wMsgFilterMax, int wRemoveMsg);
+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 PostMessageW (int hWnd, int Msg, int wParam, int lParam);
+public static final native boolean PostMessageA (int hWnd, int Msg, int wParam, int lParam);
+public static final native boolean PostThreadMessageW (int idThread, int Msg, int wParam, int lParam);
+public static final native boolean PostThreadMessageA (int idThread, int Msg, int wParam, int lParam);
+public static final native boolean PrintDlgW (PRINTDLG lppd);
+public static final native boolean PrintDlgA (PRINTDLG lppd);
+public static final native boolean PtInRect (RECT rect, POINT pt);
+public static final native boolean PtInRegion (int hrgn, int X, int Y);
+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, RECT lprc);
+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 RegisterClassW (WNDCLASS lpWndClass);
+public static final native int RegisterClassA (WNDCLASS lpWndClass);
+public static final native int RegEnumKeyExW (int hKey, int dwIndex, char [] lpName, int [] lpcName, int [] lpReserved, char [] lpClass, int [] lpcClass, FILETIME lpftLastWriteTime);
+public static final native int RegisterClipboardFormatA (byte[] lpszFormat);
+public static final native int RegisterClipboardFormatW (char[] lpszFormat);
+public static final native int RegOpenKeyExW (int hKey, char[] lpSubKey, int ulOptions, int samDesired, int[] phkResult);
+public static final native int RegQueryInfoKeyW (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 RegQueryValueExW (int hKey, char[] lpValueName, int lpReserved, int[] lpType, char [] lpData, int[] lpcbData);
+public static final native int RegEnumKeyExA (int hKey, int dwIndex, byte [] lpName, int [] lpcName, int [] lpReserved, byte [] lpClass, int [] lpcClass, FILETIME lpftLastWriteTime);
+public static final native int RegOpenKeyExA (int hKey, byte[] lpSubKey, int ulOptions, int samDesired, int[] phkResult);
+public static final native int RegQueryInfoKeyA (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 RegQueryValueExA (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 SendMessageW (int hWnd, int Msg, int [] wParam, int [] lParam);
+public static final native int SendMessageW (int hWnd, int Msg, int [] wParam, int lParam);
+public static final native int SendMessageW (int hWnd, int Msg, int wParam, char [] lParam);
+public static final native int SendMessageW (int hWnd, int Msg, int wParam, int [] lParam);
+public static final native int SendMessageW (int hWnd, int Msg, int wParam, short [] lParam);
+public static final native int SendMessageW (int hWnd, int Msg, int wParam, int lParam);
+public static final native int SendMessageW (int hWnd, int Msg, int wParam, LVCOLUMN lParam);
+public static final native int SendMessageW (int hWnd, int Msg, int wParam, LVHITTESTINFO lParam);
+public static final native int SendMessageW (int hWnd, int Msg, int wParam, LVITEM lParam);
+public static final native int SendMessageW (int hWnd, int Msg, int wParam, REBARBANDINFO lParam);
+public static final native int SendMessageW (int hWnd, int Msg, int wParam, RECT lParam);
+public static final native int SendMessageW (int hWnd, int Msg, int wParam, TBBUTTON lParam);
+public static final native int SendMessageW (int hWnd, int Msg, int wParam, TBBUTTONINFO lParam);
+public static final native int SendMessageW (int hWnd, int Msg, int wParam, TCITEM lParam);
+public static final native int SendMessageW (int hWnd, int Msg, int wParam, TOOLINFO lParam);
+public static final native int SendMessageW (int hWnd, int Msg, int wParam, TVHITTESTINFO lParam);
+public static final native int SendMessageW (int hWnd, int Msg, int wParam, TVINSERTSTRUCT lParam);
+public static final native int SendMessageW (int hWnd, int Msg, int wParam, TVITEM lParam);
+public static final native int SendMessageA (int hWnd, int Msg, int [] wParam, int [] lParam);
+public static final native int SendMessageA (int hWnd, int Msg, int [] wParam, int lParam);
+public static final native int SendMessageA (int hWnd, int Msg, int wParam, byte [] lParam);
+public static final native int SendMessageA (int hWnd, int Msg, int wParam, int [] lParam);
+public static final native int SendMessageA (int hWnd, int Msg, int wParam, short [] lParam);
+public static final native int SendMessageA (int hWnd, int Msg, int wParam, int lParam);
+public static final native int SendMessageA (int hWnd, int Msg, int wParam, LVCOLUMN lParam);
+public static final native int SendMessageA (int hWnd, int Msg, int wParam, LVHITTESTINFO lParam);
+public static final native int SendMessageA (int hWnd, int Msg, int wParam, LVITEM lParam);
+public static final native int SendMessageA (int hWnd, int Msg, int wParam, REBARBANDINFO lParam);
+public static final native int SendMessageA (int hWnd, int Msg, int wParam, RECT lParam);
+public static final native int SendMessageA (int hWnd, int Msg, int wParam, TBBUTTON lParam);
+public static final native int SendMessageA (int hWnd, int Msg, int wParam, TBBUTTONINFO lParam);
+public static final native int SendMessageA (int hWnd, int Msg, int wParam, TCITEM lParam);
+public static final native int SendMessageA (int hWnd, int Msg, int wParam, TOOLINFO lParam);
+public static final native int SendMessageA (int hWnd, int Msg, int wParam, TVHITTESTINFO lParam);
+public static final native int SendMessageA (int hWnd, int Msg, int wParam, TVINSERTSTRUCT lParam);
+public static final native int SendMessageA (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 boolean SetCursorPos (int X, int Y);
+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 boolean SetForegroundWindow (int hWnd);
+public static final native int SetLayout (int hdc, int dwLayout);
+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 SetMenuItemInfoW (int hMenu, int uItem, boolean fByPosition, MENUITEMINFO lpmii);
+public static final native boolean SetMenuItemInfoA (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 SetStretchBltMode(int hdc, int iStretchMode);
+public static final native int SetTextAlign(int hdc, int fMode);
+public static final native int SetTextColor (int hdc, int colorRef);
+public static final native int SetTimer (int hWnd, int nIDEvent, int Elapse, int lpTimerFunc);
+public static final native int SetWindowLongW (int hWnd, int nIndex, int dwNewLong);
+public static final native int SetWindowLongA (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 SetWindowTextW (int hWnd, char [] lpString);
+public static final native boolean SetWindowTextA (int hWnd, byte [] lpString);
+public static final native int SetWindowsHookExW (int idHook, int lpfn, int hMod, int dwThreadId);
+public static final native int SetWindowsHookExA (int idHook, int lpfn, int hMod, int dwThreadId);
+public static final native int SHBrowseForFolderW (BROWSEINFO lpbi);
+public static final native int SHBrowseForFolderA (BROWSEINFO lpbi);
+public static final native boolean SHCreateMenuBar(SHMENUBARINFO pmb);
+public static final native boolean SHHandleWMSettingChange (int hwnd, int wParam, int lParam, SHACTIVATEINFO psai);
+public static final native int SHRecognizeGesture(SHRGINFO shrg);
+public static final native void SHSendBackToFocusWindow (int uMsg, int wp, int lp);
+public static final native boolean SHSipPreference (int hwnd, int st);
+public static final native boolean ShellExecuteExW (SHELLEXECUTEINFO lpExecInfo);
+public static final native boolean ShellExecuteExA (SHELLEXECUTEINFO lpExecInfo);
+public static final native int SHGetMalloc (int [] ppMalloc);
+public static final native boolean SHGetPathFromIDListW (int pidl, char [] pszPath);
+public static final native boolean SHGetPathFromIDListA (int pidl, byte [] pszPath);
+public static final native boolean SHSetAppKeyWndAssoc(byte bVk, int hwnd);
+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 boolean SipGetInfo (SIPINFO pSipInfo);
+public static final native int StartDocW (int hdc, DOCINFO lpdi);
+public static final native int StartDocA (int hdc, DOCINFO lpdi);
+public static final native int StartPage (int hdc);
+public static final native boolean StretchBlt (int hdcDest, int nXOriginDest, int nYOriginDest, int nWidthDest, int nHeightDest, int hdcSrc, int nXOriginSrc, int nYOriginSrc, int nWidthSrc, int nHeightSrc, int dwRop);
+public static final native boolean SystemParametersInfoW (int uiAction, int uiParam, RECT pvParam, int fWinIni);
+public static final native boolean SystemParametersInfoA (int uiAction, int uiParam, RECT pvParam, int fWinIni);
+public static final native boolean SystemParametersInfoW (int uiAction, int uiParam, NONCLIENTMETRICS pvParam, int fWinIni);
+public static final native boolean SystemParametersInfoA (int uiAction, int uiParam, NONCLIENTMETRICS pvParam, int fWinIni);
+public static final native boolean SystemParametersInfoW (int uiAction, int uiParam, int[] pvParam, int fWinIni);
+public static final native boolean SystemParametersInfoA (int uiAction, int uiParam, int[] pvParam, int fWinIni);
+public static final native int ToAscii (int uVirtKey, int uScanCode, byte [] lpKeyState, short [] lpChar, int uFlags);
+public static final native int ToUnicode(int wVirtKey, int wScanCode, byte [] lpKeyState, char [] pwszBuff, int cchBuff, int wFlags);
+public static final native boolean TrackMouseEvent(TRACKMOUSEEVENT lpEventTrack);
+public static final native boolean TrackPopupMenu (int hMenu, int uFlags, int x, int y, int nReserved, int hWnd, RECT prcRect);
+public static final native int TranslateAcceleratorW (int hWnd, int hAccTable, MSG lpMsg);
+public static final native int TranslateAcceleratorA (int hWnd, int hAccTable, MSG lpMsg);
+public static final native boolean TranslateCharsetInfo(int lpSrc, int [] lpCs, int dwFlags);
+public static final native boolean TranslateMessage (MSG lpmsg);
+public static final native boolean TransparentImage (int hdcDest, int DstX, int DstY, int DstCx, int DstCy,int hSrc, int SrcX, int SrcY, int SrcCx, int SrcCy, int TransparentColor);public static final native boolean UnhookWindowsHookEx(int hhk);
+public static final native boolean UnregisterClassW (char [] lpClassName, int hInstance);
+public static final native boolean UnregisterClassA (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 VkKeyScanW (short ch);
+public static final native short VkKeyScanA (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 WideCharToMultiByte (int CodePage, int dwFlags, char [] lpWideCharStr, int cchWideChar, int lpMultiByteStr, int cchMultiByte, byte [] lpDefaultChar, boolean [] lpUsedDefaultChar);
+public static final native int WindowFromDC (int lpPoint);
+public static final native int WindowFromPoint (POINT lpPoint);
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/OSVERSIONINFO.java b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/OSVERSIONINFO.java
index 3a5a502142..96d1df70ce 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/OSVERSIONINFO.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/OSVERSIONINFO.java
@@ -1,21 +1,21 @@
-package org.eclipse.swt.internal.win32;
-
-/*
+package org.eclipse.swt.internal.win32;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-public class OSVERSIONINFO {
- public int dwOSVersionInfoSize;
- public int dwMajorVersion;
- public int dwMinorVersion;
- public int dwBuildNumber;
- public int dwPlatformId;
-// TCHAR szCSDVersion [128];
-// public char [] szCSDVersion = new char [128];
- public static final int sizeofW = 276;
- public static final int sizeofA = 148;
- public static /*final*/ int sizeof = OS.IsUnicode ? sizeofW : sizeofA;
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+public class OSVERSIONINFO {
+ public int dwOSVersionInfoSize;
+ public int dwMajorVersion;
+ public int dwMinorVersion;
+ public int dwBuildNumber;
+ public int dwPlatformId;
+// TCHAR szCSDVersion [128];
+// public char [] szCSDVersion = new char [128];
+ public static final int sizeofW = 276;
+ public static final int sizeofA = 148;
+ public static /*final*/ int sizeof = OS.IsUnicode ? sizeofW : sizeofA;
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/PAINTSTRUCT.java b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/PAINTSTRUCT.java
index 851d9c6c75..813e287c2a 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/PAINTSTRUCT.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/PAINTSTRUCT.java
@@ -1,19 +1,19 @@
-package org.eclipse.swt.internal.win32;
-
-/*
+package org.eclipse.swt.internal.win32;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-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;
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+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 PI/win32/org/eclipse/swt/internal/win32/POINT.java b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/POINT.java
index d971241f7c..69eaae7a1a 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/POINT.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/POINT.java
@@ -1,13 +1,13 @@
-package org.eclipse.swt.internal.win32;
-
-/*
+package org.eclipse.swt.internal.win32;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-public class POINT {
- public int x;
- public int y;
- public static final int sizeof = 8;
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+public class POINT {
+ public int x;
+ public int y;
+ public static final int sizeof = 8;
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/PRINTDLG.java b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/PRINTDLG.java
index 5a6dbfc59e..b9ac1eb9a7 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/PRINTDLG.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/PRINTDLG.java
@@ -1,30 +1,30 @@
-package org.eclipse.swt.internal.win32;
-
-/*
+package org.eclipse.swt.internal.win32;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-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;
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+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;
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/REBARBANDINFO.java b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/REBARBANDINFO.java
index 7d1de8ffe2..700a2fd678 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/REBARBANDINFO.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/REBARBANDINFO.java
@@ -1,32 +1,32 @@
-package org.eclipse.swt.internal.win32;
-
-/*
+package org.eclipse.swt.internal.win32;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-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;
- /* Note in WinCE. The field cxHeader is not defined. */
- public static final int sizeof = OS.IsWinCE ? 76 : 80;
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+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;
+ /* Note in WinCE. The field cxHeader is not defined. */
+ public static final int sizeof = OS.IsWinCE ? 76 : 80;
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/RECT.java b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/RECT.java
index f781cb98e1..07d86bfae8 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/RECT.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/RECT.java
@@ -1,15 +1,15 @@
-package org.eclipse.swt.internal.win32;
-
-/*
+package org.eclipse.swt.internal.win32;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-public class RECT {
- public int left;
- public int top;
- public int right;
- public int bottom;
- public static final int sizeof = 16;
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+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 PI/win32/org/eclipse/swt/internal/win32/SCROLLINFO.java b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/SCROLLINFO.java
index 4d5ca7dc31..c51bb55a0e 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/SCROLLINFO.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/SCROLLINFO.java
@@ -1,18 +1,18 @@
-package org.eclipse.swt.internal.win32;
-
-/*
+package org.eclipse.swt.internal.win32;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-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;
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+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 PI/win32/org/eclipse/swt/internal/win32/SHELLEXECUTEINFO.java b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/SHELLEXECUTEINFO.java
index a09489c7ed..5896efa8da 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/SHELLEXECUTEINFO.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/SHELLEXECUTEINFO.java
@@ -1,35 +1,35 @@
-package org.eclipse.swt.internal.win32;
-
-/*
+package org.eclipse.swt.internal.win32;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-public class SHELLEXECUTEINFO {
-
- public int cbSize;
- public int fMask;
- public int hwnd;
- public int lpVerb;
- public int lpFile;
- public int lpParameters;
- public int lpDirectory;
- public int nShow;
- public int hInstApp;
-
- // Optional members
- public int lpIDList;
- public int lpClass;
- public int hkeyClass;
- public int dwHotKey;
-// union {
-// HANDLE hIcon;
-// HANDLE hMonitor;
-// };
- public int hIcon;
- public int hProcess;
-
- public static final int sizeof = 60;
-}
-
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+public class SHELLEXECUTEINFO {
+
+ public int cbSize;
+ public int fMask;
+ public int hwnd;
+ public int lpVerb;
+ public int lpFile;
+ public int lpParameters;
+ public int lpDirectory;
+ public int nShow;
+ public int hInstApp;
+
+ // Optional members
+ public int lpIDList;
+ public int lpClass;
+ public int hkeyClass;
+ public int dwHotKey;
+// union {
+// HANDLE hIcon;
+// HANDLE hMonitor;
+// };
+ public int hIcon;
+ public int hProcess;
+
+ public static final int sizeof = 60;
+}
+
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/SHMENUBARINFO.java b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/SHMENUBARINFO.java
index 95ae3b7016..7658786ff2 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/SHMENUBARINFO.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/SHMENUBARINFO.java
@@ -1,19 +1,19 @@
-package org.eclipse.swt.internal.win32;
-
-/*
+package org.eclipse.swt.internal.win32;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-public class SHMENUBARINFO {
- public int cbSize;
- public int hwndParent;
- public int dwFlags;
- public int nToolBarId;
- public int hInstRes;
- public int nBmpId;
- public int cBmpImages;
- public int hwndMB;
- public static final int sizeof = OS.IsSP ? 36 : 32;
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+public class SHMENUBARINFO {
+ public int cbSize;
+ public int hwndParent;
+ public int dwFlags;
+ public int nToolBarId;
+ public int hInstRes;
+ public int nBmpId;
+ public int cBmpImages;
+ public int hwndMB;
+ public static final int sizeof = OS.IsSP ? 36 : 32;
} \ No newline at end of file
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/SIZE.java b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/SIZE.java
index 3bd291b081..56ab8a7f74 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/SIZE.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/SIZE.java
@@ -1,13 +1,13 @@
-package org.eclipse.swt.internal.win32;
-
-/*
+package org.eclipse.swt.internal.win32;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-public class SIZE {
- public int cx;
- public int cy;
- public static final int sizeof = 8;
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+public class SIZE {
+ public int cx;
+ public int cy;
+ public static final int sizeof = 8;
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/TBBUTTON.java b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/TBBUTTON.java
index 879cfe22dc..d0a4c17f6e 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/TBBUTTON.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/TBBUTTON.java
@@ -1,17 +1,17 @@
-package org.eclipse.swt.internal.win32;
-
-/*
+package org.eclipse.swt.internal.win32;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-public class TBBUTTON {
- public int iBitmap;
- public int idCommand;
- public byte fsState;
- public byte fsStyle;
- public int dwData;
- public int iString;
- public static final int sizeof = 20;
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+public class TBBUTTON {
+ public int iBitmap;
+ public int idCommand;
+ public byte fsState;
+ public byte fsStyle;
+ public int dwData;
+ public int iString;
+ public static final int sizeof = 20;
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/TBBUTTONINFO.java b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/TBBUTTONINFO.java
index 3ec0c847f5..bd230f6685 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/TBBUTTONINFO.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/TBBUTTONINFO.java
@@ -1,21 +1,21 @@
-package org.eclipse.swt.internal.win32;
-
-/*
+package org.eclipse.swt.internal.win32;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-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;
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+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 PI/win32/org/eclipse/swt/internal/win32/TCHAR.java b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/TCHAR.java
index 61b750d559..53612097f6 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/TCHAR.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/TCHAR.java
@@ -1,111 +1,111 @@
-package org.eclipse.swt.internal.win32;
-
-/*
+package org.eclipse.swt.internal.win32;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-/**
- * 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 class TCHAR {
-
-int codePage;
-char [] chars;
-byte [] bytes;
-int byteCount;
-
-public final static int sizeof = OS.IsUnicode ? 2 : 1;
-
-public TCHAR (int codePage, int length) {
- this.codePage = codePage;
- if (OS.IsUnicode) {
- chars = new char [length];
- } else {
- bytes = new byte [byteCount = length];
- }
-}
-
-public TCHAR (int codePage, char ch, boolean terminate) {
- this (codePage, String.valueOf (ch), terminate);
-}
-
-public TCHAR (int codePage, String string, boolean terminate) {
- this.codePage = codePage;
- int charCount = string.length ();
- char [] chars = new char [charCount + (terminate ? 1 : 0)];
- string.getChars (0, charCount, chars, 0);
- if (OS.IsUnicode) {
- this.chars = chars;
- } else {
- int cp = codePage != 0 ? codePage : OS.CP_ACP;
- bytes = new byte [byteCount = charCount * 2 + (terminate ? 1 : 0)];
- byteCount = OS.WideCharToMultiByte (cp, 0, chars, charCount, bytes, byteCount, null, null);
- if (terminate) byteCount++;
- }
-}
-
-public int length () {
- if (OS.IsUnicode) {
- return chars.length;
- } else {
- return byteCount;
- }
-}
-
-public int strlen () {
- if (OS.IsUnicode) {
- for (int i=0; i<chars.length; i++) {
- if (chars [i] == '\0') return i;
- }
- return chars.length;
- } else {
- for (int i=0; i<byteCount; i++) {
- if (bytes [i] == '\0') return i;
- }
- return byteCount;
- }
-}
-
-public int tcharAt (int index) {
- if (OS.IsUnicode) {
- return chars [index];
- } else {
- int ch = bytes [index] & 0xFF;
- if (OS.IsDBCSLeadByte ((byte) ch)) {
- ch = ch << 8 | (bytes [index + 1] & 0xFF);
- }
- return ch;
- }
-}
-
-public String toString () {
- return toString (0, length ());
-}
-
-public String toString (int start, int length) {
- if (OS.IsUnicode) {
- return new String (chars, start, length);
- } else {
- byte [] bytes = this.bytes;
- if (start != 0) {
- bytes = new byte [length];
- System.arraycopy (this.bytes, start, bytes, 0, length);
- }
- char [] chars = new char [length];
- int cp = codePage != 0 ? codePage : OS.CP_ACP;
- int charCount = OS.MultiByteToWideChar (cp, OS.MB_PRECOMPOSED, bytes, length, chars, length);
- return new String (chars, 0, charCount);
- }
-}
-
-}
-
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+/**
+ * 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 class TCHAR {
+
+int codePage;
+char [] chars;
+byte [] bytes;
+int byteCount;
+
+public final static int sizeof = OS.IsUnicode ? 2 : 1;
+
+public TCHAR (int codePage, int length) {
+ this.codePage = codePage;
+ if (OS.IsUnicode) {
+ chars = new char [length];
+ } else {
+ bytes = new byte [byteCount = length];
+ }
+}
+
+public TCHAR (int codePage, char ch, boolean terminate) {
+ this (codePage, String.valueOf (ch), terminate);
+}
+
+public TCHAR (int codePage, String string, boolean terminate) {
+ this.codePage = codePage;
+ int charCount = string.length ();
+ char [] chars = new char [charCount + (terminate ? 1 : 0)];
+ string.getChars (0, charCount, chars, 0);
+ if (OS.IsUnicode) {
+ this.chars = chars;
+ } else {
+ int cp = codePage != 0 ? codePage : OS.CP_ACP;
+ bytes = new byte [byteCount = charCount * 2 + (terminate ? 1 : 0)];
+ byteCount = OS.WideCharToMultiByte (cp, 0, chars, charCount, bytes, byteCount, null, null);
+ if (terminate) byteCount++;
+ }
+}
+
+public int length () {
+ if (OS.IsUnicode) {
+ return chars.length;
+ } else {
+ return byteCount;
+ }
+}
+
+public int strlen () {
+ if (OS.IsUnicode) {
+ for (int i=0; i<chars.length; i++) {
+ if (chars [i] == '\0') return i;
+ }
+ return chars.length;
+ } else {
+ for (int i=0; i<byteCount; i++) {
+ if (bytes [i] == '\0') return i;
+ }
+ return byteCount;
+ }
+}
+
+public int tcharAt (int index) {
+ if (OS.IsUnicode) {
+ return chars [index];
+ } else {
+ int ch = bytes [index] & 0xFF;
+ if (OS.IsDBCSLeadByte ((byte) ch)) {
+ ch = ch << 8 | (bytes [index + 1] & 0xFF);
+ }
+ return ch;
+ }
+}
+
+public String toString () {
+ return toString (0, length ());
+}
+
+public String toString (int start, int length) {
+ if (OS.IsUnicode) {
+ return new String (chars, start, length);
+ } else {
+ byte [] bytes = this.bytes;
+ if (start != 0) {
+ bytes = new byte [length];
+ System.arraycopy (this.bytes, start, bytes, 0, length);
+ }
+ char [] chars = new char [length];
+ int cp = codePage != 0 ? codePage : OS.CP_ACP;
+ int charCount = OS.MultiByteToWideChar (cp, OS.MB_PRECOMPOSED, bytes, length, chars, length);
+ return new String (chars, 0, charCount);
+ }
+}
+
+}
+
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/TCITEM.java b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/TCITEM.java
index 493d3af46e..5666f5124f 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/TCITEM.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/TCITEM.java
@@ -1,18 +1,18 @@
-package org.eclipse.swt.internal.win32;
-
-/*
+package org.eclipse.swt.internal.win32;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-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;
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+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 PI/win32/org/eclipse/swt/internal/win32/TEXTMETRIC.java b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/TEXTMETRIC.java
index 76bb358585..ae85423e17 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/TEXTMETRIC.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/TEXTMETRIC.java
@@ -1,35 +1,35 @@
-package org.eclipse.swt.internal.win32;
-
-/*
+package org.eclipse.swt.internal.win32;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-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;
-// TCHAR tmFirstChar;
-// TCHAR tmLastChar;
-// TCHAR tmDefaultChar;
-// TCHAR tmBreakChar;
-// public char tmFirstChar;
-// public char tmLastChar;
-// public char tmDefaultChar;
-// public char tmBreakChar;
- public byte tmItalic;
- public byte tmUnderlined;
- public byte tmStruckOut;
- public byte tmPitchAndFamily;
- public byte tmCharSet;
- public static final int sizeof = OS.IsUnicode ? 60 : 56;
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+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;
+// TCHAR tmFirstChar;
+// TCHAR tmLastChar;
+// TCHAR tmDefaultChar;
+// TCHAR tmBreakChar;
+// public char tmFirstChar;
+// public char tmLastChar;
+// public char tmDefaultChar;
+// public char tmBreakChar;
+ public byte tmItalic;
+ public byte tmUnderlined;
+ public byte tmStruckOut;
+ public byte tmPitchAndFamily;
+ public byte tmCharSet;
+ public static final int sizeof = OS.IsUnicode ? 60 : 56;
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/TOOLINFO.java b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/TOOLINFO.java
index ee05dcb2a6..32fa1a831f 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/TOOLINFO.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/TOOLINFO.java
@@ -1,20 +1,20 @@
-package org.eclipse.swt.internal.win32;
-
-/*
+package org.eclipse.swt.internal.win32;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-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;
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+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 PI/win32/org/eclipse/swt/internal/win32/TRACKMOUSEEVENT.java b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/TRACKMOUSEEVENT.java
index 41baf18ae6..a7491bf172 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/TRACKMOUSEEVENT.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/TRACKMOUSEEVENT.java
@@ -1,16 +1,16 @@
-package org.eclipse.swt.internal.win32;
-
-/*
+package org.eclipse.swt.internal.win32;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-public class TRACKMOUSEEVENT {
- public int cbSize;
- public int dwFlags;
- public int hwndTrack;
- public int dwHoverTime;
- public static final int sizeof = 16;
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+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 PI/win32/org/eclipse/swt/internal/win32/TRIVERTEX.java b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/TRIVERTEX.java
index 6674ba3313..48d8fa278e 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/TRIVERTEX.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/TRIVERTEX.java
@@ -1,18 +1,18 @@
-package org.eclipse.swt.internal.win32;
-
-/*
+package org.eclipse.swt.internal.win32;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-public class TRIVERTEX {
- public int x;
- public int y;
- public short Red;
- public short Green;
- public short Blue;
- public short Alpha;
- public static final int sizeof = 16;
-}
-
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+public class TRIVERTEX {
+ public int x;
+ public int y;
+ public short Red;
+ public short Green;
+ public short Blue;
+ public short Alpha;
+ public static final int sizeof = 16;
+}
+
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/TVHITTESTINFO.java b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/TVHITTESTINFO.java
index ee04f57d21..b8256e3261 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/TVHITTESTINFO.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/TVHITTESTINFO.java
@@ -1,16 +1,16 @@
-package org.eclipse.swt.internal.win32;
-
-/*
+package org.eclipse.swt.internal.win32;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-public class TVHITTESTINFO {
-// POINT pt;
- public int x;
- public int y;
- public int flags;
- public int hItem;
- public static int sizeof = 16;
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+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 PI/win32/org/eclipse/swt/internal/win32/TVINSERTSTRUCT.java b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/TVINSERTSTRUCT.java
index 18119bb8c0..7b644e8156 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/TVINSERTSTRUCT.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/TVINSERTSTRUCT.java
@@ -1,24 +1,24 @@
-package org.eclipse.swt.internal.win32;
-
-/*
+package org.eclipse.swt.internal.win32;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-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;
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+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 PI/win32/org/eclipse/swt/internal/win32/TVITEM.java b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/TVITEM.java
index 2a8c778c98..d12ffd9619 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/TVITEM.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/TVITEM.java
@@ -1,21 +1,21 @@
-package org.eclipse.swt.internal.win32;
-
-/*
+package org.eclipse.swt.internal.win32;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-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;
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+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 PI/win32/org/eclipse/swt/internal/win32/WINDOWPLACEMENT.java b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/WINDOWPLACEMENT.java
index 7bd5f7213c..1ac1d05e0b 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/WINDOWPLACEMENT.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/WINDOWPLACEMENT.java
@@ -1,25 +1,25 @@
-package org.eclipse.swt.internal.win32;
-
-/*
+package org.eclipse.swt.internal.win32;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-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;
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+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 PI/win32/org/eclipse/swt/internal/win32/WINDOWPOS.java b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/WINDOWPOS.java
index a5205285f1..e375726036 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/WINDOWPOS.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/WINDOWPOS.java
@@ -1,18 +1,18 @@
-package org.eclipse.swt.internal.win32;
-
-/*
+package org.eclipse.swt.internal.win32;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-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;
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+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 PI/win32/org/eclipse/swt/internal/win32/WNDCLASS.java b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/WNDCLASS.java
index 5f4b1bf92f..40f5419346 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/WNDCLASS.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/WNDCLASS.java
@@ -1,21 +1,21 @@
-package org.eclipse.swt.internal.win32;
-
-/*
+package org.eclipse.swt.internal.win32;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-public class WNDCLASS {
- 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 static final int sizeof = 40;
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+public class WNDCLASS {
+ 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 static final int sizeof = 40;
+}
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
index 377c36b16b..3a21d42973 100755
--- 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
@@ -1,162 +1,162 @@
-package org.eclipse.swt.printing;
-
-/*
+package org.eclipse.swt.printing;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-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 SWTError <ul>
- * <li>ERROR_NO_HANDLES - if an error occurred constructing the default printer data</li>
- * </ul>
- */
- public PrinterData() {
- }
-
- /**
- * Constructs an instance of this class with the given
- * printer driver and printer name.
- *
- * @param driver the printer driver for the printer
- * @param name the name of the printer
- *
- * @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 + "}";
- }
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+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 SWTError <ul>
+ * <li>ERROR_NO_HANDLES - if an error occurred constructing the default printer data</li>
+ * </ul>
+ */
+ public PrinterData() {
+ }
+
+ /**
+ * Constructs an instance of this class with the given
+ * printer driver and printer name.
+ *
+ * @param driver the printer driver for the printer
+ * @param name the name of the printer
+ *
+ * @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 + "}";
+ }
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Printing/gtk/org/eclipse/swt/printing/PrintDialog.java b/bundles/org.eclipse.swt/Eclipse SWT Printing/gtk/org/eclipse/swt/printing/PrintDialog.java
index 296b21c885..cc1e848af6 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT Printing/gtk/org/eclipse/swt/printing/PrintDialog.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT Printing/gtk/org/eclipse/swt/printing/PrintDialog.java
@@ -1,194 +1,194 @@
-package org.eclipse.swt.printing;
-
-/*
+package org.eclipse.swt.printing;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-import org.eclipse.swt.*;
-import org.eclipse.swt.widgets.*;
-
-/**
- * Instances of this class allow the user to select
- * a printer and various print-related parameters
- * prior to starting a print job.
- * <p>
- * IMPORTANT: This class is intended to be subclassed <em>only</em>
- * within the SWT implementation.
- * </p>
+ * http://www.eclipse.org/legal/cpl-v10.html
*/
-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
+
+import org.eclipse.swt.*;
+import org.eclipse.swt.widgets.*;
+
+/**
+ * Instances of this class allow the user to select
+ * a printer and various print-related parameters
+ * prior to starting a print job.
+ * <p>
+ * IMPORTANT: This class is intended to be subclassed <em>only</em>
+ * within the SWT implementation.
+ * </p>
*/
-public PrintDialog (Shell parent) {
- this (parent, SWT.PRIMARY_MODAL);
-}
-/**
- * Constructs a new instance of this class given its parent
- * and a style value describing its behavior and appearance.
- * <p>
- * The style value is either one of the style constants defined in
- * class <code>SWT</code> which is applicable to instances of this
- * class, or must be built by <em>bitwise OR</em>'ing together
- * (that is, using the <code>int</code> "|" operator) two or more
- * of those <code>SWT</code> style constants. The class description
- * lists the style constants that are applicable to the class.
- * Style bits are also inherited from superclasses.
- * </p>
- *
- * @param parent a composite control which will be the parent of the new instance (cannot be null)
- * @param style the style of control to construct
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
- * <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
- * </ul>
- *
- * @see SWT
- * @see Widget#checkSubclass
- * @see Widget#getStyle
+public 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, int style) {
- super (parent, style);
- 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 PrintDialog (Shell parent) {
+ this (parent, SWT.PRIMARY_MODAL);
+}
+/**
+ * Constructs a new instance of this class given its parent
+ * and a style value describing its behavior and appearance.
+ * <p>
+ * The style value is either one of the style constants defined in
+ * class <code>SWT</code> which is applicable to instances of this
+ * class, or must be built by <em>bitwise OR</em>'ing together
+ * (that is, using the <code>int</code> "|" operator) two or more
+ * of those <code>SWT</code> style constants. The class description
+ * lists the style constants that are applicable to the class.
+ * Style bits are also inherited from superclasses.
+ * </p>
+ *
+ * @param parent a composite control which will be the parent of the new instance (cannot be null)
+ * @param style the style of control to construct
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
+ * <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
+ * </ul>
+ *
+ * @see SWT
+ * @see Widget#checkSubclass
+ * @see Widget#getStyle
*/
-public PrinterData open() {
- /* Return the first printer in the list */
- PrinterData[] printers = Printer.getPrinterList();
- if (printers.length > 0) return printers[0];
- return null;
-}
-/**
- * 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 PrintDialog (Shell parent, int style) {
+ super (parent, style);
+ 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 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 PrinterData open() {
+ /* Return the first printer in the list */
+ PrinterData[] printers = Printer.getPrinterList();
+ if (printers.length > 0) return printers[0];
+ return null;
+}
+/**
+ * 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 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 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 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 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 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 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 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 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 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 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 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 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 void setPrintToFile(boolean printToFile) {
- this.printToFile = printToFile;
-}
-protected void checkSubclass() {
-}
-}
+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() {
+}
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Printing/gtk/org/eclipse/swt/printing/Printer.java b/bundles/org.eclipse.swt/Eclipse SWT Printing/gtk/org/eclipse/swt/printing/Printer.java
index 9d0177885a..77bb941163 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT Printing/gtk/org/eclipse/swt/printing/Printer.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT Printing/gtk/org/eclipse/swt/printing/Printer.java
@@ -1,14 +1,14 @@
-package org.eclipse.swt.printing;
-
-/*
+package org.eclipse.swt.printing;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-import org.eclipse.swt.graphics.*;
-
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+import org.eclipse.swt.graphics.*;
+
/**
* Instances of this class are used to print to a printer.
* Applications create a GC on a printer using <code>new GC(printer)</code>
@@ -29,33 +29,33 @@ import org.eclipse.swt.graphics.*;
* @see PrinterData
* @see PrintDialog
*/
-public final class Printer extends Device {
- PrinterData data;
-
+public final class Printer extends Device {
+ PrinterData data;
+
/**
* Returns an array of <code>PrinterData</code> objects
* representing all available printers.
*
* @return the list of available printers
*/
-public static PrinterData[] getPrinterList() {
- PrinterData printerList[] = new PrinterData[0];
- return printerList;
-}
-
-/**
- * Returns a <code>PrinterData</code> object representing
- * the default printer or <code>null</code> if there is no
- * printer available on the System.
- *
- * @return the default printer data or null
- *
- * @since 2.1
- */
-public static PrinterData getDefaultPrinterData() {
- return null;
-}
-
+public static PrinterData[] getPrinterList() {
+ PrinterData printerList[] = new PrinterData[0];
+ return printerList;
+}
+
+/**
+ * Returns a <code>PrinterData</code> object representing
+ * the default printer or <code>null</code> if there is no
+ * printer available on the System.
+ *
+ * @return the default printer data or null
+ *
+ * @since 2.1
+ */
+public static PrinterData getDefaultPrinterData() {
+ return null;
+}
+
/**
* Constructs a new printer representing the default printer.
* <p>
@@ -68,10 +68,10 @@ public static PrinterData getDefaultPrinterData() {
*
* @see #dispose
*/
-public Printer() {
- this(getDefaultPrinterData());
-}
-
+public Printer() {
+ this(getDefaultPrinterData());
+}
+
/**
* Constructs a new printer given a <code>PrinterData</code>
* object representing the desired printer.
@@ -88,11 +88,11 @@ public Printer() {
*
* @see #dispose
*/
-public Printer(PrinterData data) {
- super(data);
-}
-
-
+public Printer(PrinterData data) {
+ super(data);
+}
+
+
/**
* Invokes platform specific functionality to allocate a new GC handle.
* <p>
@@ -108,10 +108,10 @@ public Printer(PrinterData data) {
*
* @private
*/
-public int internal_new_GC(GCData data) {
- return 0;
-}
-
+public int internal_new_GC(GCData data) {
+ return 0;
+}
+
/**
* Invokes platform specific functionality to dispose a GC handle.
* <p>
@@ -127,9 +127,9 @@ public int internal_new_GC(GCData data) {
*
* @private
*/
-public void internal_dispose_GC(int xGC, GCData data) {
-}
-
+public void internal_dispose_GC(int xGC, GCData data) {
+}
+
/**
* Starts a print job and returns true if the job started successfully
* and false otherwise.
@@ -150,10 +150,10 @@ public void internal_dispose_GC(int xGC, GCData data) {
* @see #endPage
* @see #endJob
*/
-public boolean startJob(String jobName) {
- return true;
-}
-
+public boolean startJob(String jobName) {
+ return true;
+}
+
/**
* Ends the current print job.
*
@@ -165,9 +165,9 @@ public boolean startJob(String jobName) {
* @see #startPage
* @see #endPage
*/
-public void endJob() {
-}
-
+public void endJob() {
+}
+
/**
* Cancels a print job in progress.
*
@@ -175,9 +175,9 @@ public void endJob() {
* <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
* </ul>
*/
-public void cancelJob() {
-}
-
+public void cancelJob() {
+}
+
/**
* Starts a page and returns true if the page started successfully
* and false otherwise.
@@ -196,10 +196,10 @@ public void cancelJob() {
* @see #startJob
* @see #endJob
*/
-public boolean startPage() {
- return true;
-}
-
+public boolean startPage() {
+ return true;
+}
+
/**
* Ends the current page.
*
@@ -211,9 +211,9 @@ public boolean startPage() {
* @see #startJob
* @see #endJob
*/
-public void endPage() {
-}
-
+public void endPage() {
+}
+
/**
* Returns a point whose x coordinate is the horizontal
* dots per inch of the printer, and whose y coordinate
@@ -225,10 +225,10 @@ public void endPage() {
* <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
* </ul>
*/
-public Point getDPI() {
- return new Point(0, 0);
-}
-
+public Point getDPI() {
+ return new Point(0, 0);
+}
+
/**
* Returns a rectangle describing the receiver's size and location.
* For a printer, this is the size of a page, in pixels.
@@ -242,10 +242,10 @@ public Point getDPI() {
* @see #getClientArea
* @see #computeTrim
*/
-public Rectangle getBounds() {
- return null;
-}
-
+public Rectangle getBounds() {
+ return null;
+}
+
/**
* Returns a rectangle which describes the area of the
* receiver which is capable of displaying data.
@@ -261,10 +261,10 @@ public Rectangle getBounds() {
* @see #getBounds
* @see #computeTrim
*/
-public Rectangle getClientArea() {
- return null;
-}
-
+public Rectangle getClientArea() {
+ return null;
+}
+
/**
* Given a desired <em>client area</em> for the receiver
* (as described by the arguments), returns the bounding
@@ -291,18 +291,18 @@ public Rectangle getClientArea() {
* @see #getBounds
* @see #getClientArea
*/
-public Rectangle computeTrim(int x, int y, int width, int height) {
- return new Rectangle(0,0,0,0);
-}
-
-/**
- * Returns a <code>PrinterData</code> object representing the
- * target printer for this print job.
- *
- * @return a PrinterData object describing the receiver
+public Rectangle computeTrim(int x, int y, int width, int height) {
+ return new Rectangle(0,0,0,0);
+}
+
+/**
+ * Returns a <code>PrinterData</code> object representing the
+ * target printer for this print job.
+ *
+ * @return a PrinterData object describing the receiver
*/
-public PrinterData getPrinterData() {
- return data;
-}
-
-}
+public PrinterData getPrinterData() {
+ return data;
+}
+
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Printing/gtk1x/org/eclipse/swt/printing/PrintDialog.java b/bundles/org.eclipse.swt/Eclipse SWT Printing/gtk1x/org/eclipse/swt/printing/PrintDialog.java
index 1e9de141ec..f7c335f323 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT Printing/gtk1x/org/eclipse/swt/printing/PrintDialog.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT Printing/gtk1x/org/eclipse/swt/printing/PrintDialog.java
@@ -1,17 +1,17 @@
-package org.eclipse.swt.printing;
-
-/*
+package org.eclipse.swt.printing;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-import org.eclipse.swt.*;
-import org.eclipse.swt.graphics.*;
-import org.eclipse.swt.widgets.*;
-import org.eclipse.swt.internal.gtk.*;
-
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+import org.eclipse.swt.*;
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.widgets.*;
+import org.eclipse.swt.internal.gtk.*;
+
/**
* Instances of this class allow the user to select
* a printer and various print-related parameters
@@ -21,11 +21,11 @@ import org.eclipse.swt.internal.gtk.*;
* within the SWT implementation.
* </p>
*/
-public class PrintDialog extends Dialog {
- int scope = PrinterData.ALL_PAGES;
- int startPage = -1, endPage = -1;
- boolean printToFile = false;
-
+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.
*
@@ -43,9 +43,9 @@ public class PrintDialog extends Dialog {
* @see Widget#checkSubclass
* @see Widget#getStyle
*/
-public PrintDialog (Shell parent) {
- this (parent, SWT.PRIMARY_MODAL);
-}
+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.
@@ -74,10 +74,10 @@ public PrintDialog (Shell parent) {
* @see Widget#checkSubclass
* @see Widget#getStyle
*/
-public PrintDialog (Shell parent, int style) {
- super (parent, style);
- checkSubclass ();
-}
+public PrintDialog (Shell parent, int style) {
+ super (parent, style);
+ checkSubclass ();
+}
/**
* Makes the receiver visible and brings it to the front
* of the display.
@@ -89,12 +89,12 @@ public PrintDialog (Shell parent, int style) {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public PrinterData open() {
- /* Return the first printer in the list */
- PrinterData[] printers = Printer.getPrinterList();
- if (printers.length > 0) return printers[0];
- return null;
-}
+public PrinterData open() {
+ /* Return the first printer in the list */
+ PrinterData[] printers = Printer.getPrinterList();
+ if (printers.length > 0) return printers[0];
+ return null;
+}
/**
* Returns the print job scope that the user selected
* before pressing OK in the dialog. This will be one
@@ -110,9 +110,9 @@ public PrinterData open() {
*
* @return the scope setting that the user selected
*/
-public int getScope() {
- return scope;
-}
+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
@@ -128,9 +128,9 @@ public int getScope() {
*
* @param int the scope setting when the dialog is opened
*/
-public void setScope(int scope) {
- this.scope = scope;
-}
+public void setScope(int scope) {
+ this.scope = scope;
+}
/**
* Returns the start page setting that the user selected
* before pressing OK in the dialog.
@@ -140,18 +140,18 @@ public void setScope(int scope) {
*
* @return the start page setting that the user selected
*/
-public int getStartPage() {
- return startPage;
-}
+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;
-}
+public void setStartPage(int startPage) {
+ this.startPage = startPage;
+}
/**
* Returns the end page setting that the user selected
* before pressing OK in the dialog.
@@ -161,36 +161,36 @@ public void setStartPage(int startPage) {
*
* @return the end page setting that the user selected
*/
-public int getEndPage() {
- return endPage;
-}
+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;
-}
+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;
-}
+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() {
-}
-}
+public void setPrintToFile(boolean printToFile) {
+ this.printToFile = printToFile;
+}
+protected void checkSubclass() {
+}
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Printing/gtk1x/org/eclipse/swt/printing/Printer.java b/bundles/org.eclipse.swt/Eclipse SWT Printing/gtk1x/org/eclipse/swt/printing/Printer.java
index e838d154f7..19ad9a88b4 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT Printing/gtk1x/org/eclipse/swt/printing/Printer.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT Printing/gtk1x/org/eclipse/swt/printing/Printer.java
@@ -1,17 +1,17 @@
-package org.eclipse.swt.printing;
-
-/*
+package org.eclipse.swt.printing;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-import org.eclipse.swt.*;
-import org.eclipse.swt.graphics.*;
-import org.eclipse.swt.internal.*;
-import org.eclipse.swt.internal.gtk.*;
-
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+import org.eclipse.swt.*;
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.internal.*;
+import org.eclipse.swt.internal.gtk.*;
+
/**
* Instances of this class are used to print to a printer.
* Applications create a GC on a printer using <code>new GC(printer)</code>
@@ -32,32 +32,32 @@ import org.eclipse.swt.internal.gtk.*;
* @see PrinterData
* @see PrintDialog
*/
-public final class Printer extends Device {
- PrinterData data;
- int printContext, xScreen, xDrawable;
- int defaultFontList;
-
+public final class Printer extends Device {
+ PrinterData data;
+ int printContext, xScreen, xDrawable;
+ int defaultFontList;
+
/**
* Returns an array of <code>PrinterData</code> objects
* representing all available printers.
*
* @return the list of available printers
*/
-public static PrinterData[] getPrinterList() {
- PrinterData printerList[] = new PrinterData[0];
- 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 static PrinterData[] getPrinterList() {
+ PrinterData printerList[] = new PrinterData[0];
+ 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];
+}
+
/**
* Constructs a new printer representing the default printer.
* <p>
@@ -70,10 +70,10 @@ static PrinterData getDefaultPrinterData() {
*
* @see #dispose
*/
-public Printer() {
- this(getDefaultPrinterData());
-}
-
+public Printer() {
+ this(getDefaultPrinterData());
+}
+
/**
* Constructs a new printer given a <code>PrinterData</code>
* object representing the desired printer.
@@ -90,11 +90,11 @@ public Printer() {
*
* @see #dispose
*/
-public Printer(PrinterData data) {
- super(data);
-}
-
-
+public Printer(PrinterData data) {
+ super(data);
+}
+
+
/**
* Invokes platform specific functionality to allocate a new GC handle.
* <p>
@@ -110,10 +110,10 @@ public Printer(PrinterData data) {
*
* @private
*/
-public int internal_new_GC(GCData data) {
- return 0;
-}
-
+public int internal_new_GC(GCData data) {
+ return 0;
+}
+
/**
* Invokes platform specific functionality to dispose a GC handle.
* <p>
@@ -129,9 +129,9 @@ public int internal_new_GC(GCData data) {
*
* @private
*/
-public void internal_dispose_GC(int xGC, GCData data) {
-}
-
+public void internal_dispose_GC(int xGC, GCData data) {
+}
+
/**
* Starts a print job and returns true if the job started successfully
* and false otherwise.
@@ -152,10 +152,10 @@ public void internal_dispose_GC(int xGC, GCData data) {
* @see #endPage
* @see #endJob
*/
-public boolean startJob(String jobName) {
- return true;
-}
-
+public boolean startJob(String jobName) {
+ return true;
+}
+
/**
* Ends the current print job.
*
@@ -167,9 +167,9 @@ public boolean startJob(String jobName) {
* @see #startPage
* @see #endPage
*/
-public void endJob() {
-}
-
+public void endJob() {
+}
+
/**
* Cancels a print job in progress.
*
@@ -177,9 +177,9 @@ public void endJob() {
* <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
* </ul>
*/
-public void cancelJob() {
-}
-
+public void cancelJob() {
+}
+
/**
* Starts a page and returns true if the page started successfully
* and false otherwise.
@@ -198,10 +198,10 @@ public void cancelJob() {
* @see #startJob
* @see #endJob
*/
-public boolean startPage() {
- return true;
-}
-
+public boolean startPage() {
+ return true;
+}
+
/**
* Ends the current page.
*
@@ -213,9 +213,9 @@ public boolean startPage() {
* @see #startJob
* @see #endJob
*/
-public void endPage() {
-}
-
+public void endPage() {
+}
+
/**
* Returns a point whose x coordinate is the horizontal
* dots per inch of the printer, and whose y coordinate
@@ -227,10 +227,10 @@ public void endPage() {
* <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
* </ul>
*/
-public Point getDPI() {
- return new Point(0, 0);
-}
-
+public Point getDPI() {
+ return new Point(0, 0);
+}
+
/**
* Returns a rectangle describing the receiver's size and location.
* For a printer, this is the size of a page, in pixels.
@@ -244,10 +244,10 @@ public Point getDPI() {
* @see #getClientArea
* @see #computeTrim
*/
-public Rectangle getBounds() {
- return null;
-}
-
+public Rectangle getBounds() {
+ return null;
+}
+
/**
* Returns a rectangle which describes the area of the
* receiver which is capable of displaying data.
@@ -263,10 +263,10 @@ public Rectangle getBounds() {
* @see #getBounds
* @see #computeTrim
*/
-public Rectangle getClientArea() {
- return null;
-}
-
+public Rectangle getClientArea() {
+ return null;
+}
+
/**
* Given a desired <em>client area</em> for the receiver
* (as described by the arguments), returns the bounding
@@ -293,18 +293,18 @@ public Rectangle getClientArea() {
* @see #getBounds
* @see #getClientArea
*/
-public Rectangle computeTrim(int x, int y, int width, int height) {
- return new Rectangle(0,0,0,0);
-}
-
-/**
- * Returns a <code>PrinterData</code> object representing the
- * target printer for this print job.
- *
- * @return a PrinterData object describing the receiver
- */
-public PrinterData getPrinterData() {
- return data;
-}
-
-}
+public Rectangle computeTrim(int x, int y, int width, int height) {
+ return new Rectangle(0,0,0,0);
+}
+
+/**
+ * Returns a <code>PrinterData</code> object representing the
+ * target printer for this print job.
+ *
+ * @return a PrinterData object describing the receiver
+ */
+public PrinterData getPrinterData() {
+ return data;
+}
+
+}
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
index 296b21c885..cc1e848af6 100755
--- 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
@@ -1,194 +1,194 @@
-package org.eclipse.swt.printing;
-
-/*
+package org.eclipse.swt.printing;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-import org.eclipse.swt.*;
-import org.eclipse.swt.widgets.*;
-
-/**
- * Instances of this class allow the user to select
- * a printer and various print-related parameters
- * prior to starting a print job.
- * <p>
- * IMPORTANT: This class is intended to be subclassed <em>only</em>
- * within the SWT implementation.
- * </p>
+ * http://www.eclipse.org/legal/cpl-v10.html
*/
-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
+
+import org.eclipse.swt.*;
+import org.eclipse.swt.widgets.*;
+
+/**
+ * Instances of this class allow the user to select
+ * a printer and various print-related parameters
+ * prior to starting a print job.
+ * <p>
+ * IMPORTANT: This class is intended to be subclassed <em>only</em>
+ * within the SWT implementation.
+ * </p>
*/
-public PrintDialog (Shell parent) {
- this (parent, SWT.PRIMARY_MODAL);
-}
-/**
- * Constructs a new instance of this class given its parent
- * and a style value describing its behavior and appearance.
- * <p>
- * The style value is either one of the style constants defined in
- * class <code>SWT</code> which is applicable to instances of this
- * class, or must be built by <em>bitwise OR</em>'ing together
- * (that is, using the <code>int</code> "|" operator) two or more
- * of those <code>SWT</code> style constants. The class description
- * lists the style constants that are applicable to the class.
- * Style bits are also inherited from superclasses.
- * </p>
- *
- * @param parent a composite control which will be the parent of the new instance (cannot be null)
- * @param style the style of control to construct
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
- * <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
- * </ul>
- *
- * @see SWT
- * @see Widget#checkSubclass
- * @see Widget#getStyle
+public 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, int style) {
- super (parent, style);
- 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 PrintDialog (Shell parent) {
+ this (parent, SWT.PRIMARY_MODAL);
+}
+/**
+ * Constructs a new instance of this class given its parent
+ * and a style value describing its behavior and appearance.
+ * <p>
+ * The style value is either one of the style constants defined in
+ * class <code>SWT</code> which is applicable to instances of this
+ * class, or must be built by <em>bitwise OR</em>'ing together
+ * (that is, using the <code>int</code> "|" operator) two or more
+ * of those <code>SWT</code> style constants. The class description
+ * lists the style constants that are applicable to the class.
+ * Style bits are also inherited from superclasses.
+ * </p>
+ *
+ * @param parent a composite control which will be the parent of the new instance (cannot be null)
+ * @param style the style of control to construct
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
+ * <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
+ * </ul>
+ *
+ * @see SWT
+ * @see Widget#checkSubclass
+ * @see Widget#getStyle
*/
-public PrinterData open() {
- /* Return the first printer in the list */
- PrinterData[] printers = Printer.getPrinterList();
- if (printers.length > 0) return printers[0];
- return null;
-}
-/**
- * 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 PrintDialog (Shell parent, int style) {
+ super (parent, style);
+ 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 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 PrinterData open() {
+ /* Return the first printer in the list */
+ PrinterData[] printers = Printer.getPrinterList();
+ if (printers.length > 0) return printers[0];
+ return null;
+}
+/**
+ * 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 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 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 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 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 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 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 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 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 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 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 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 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 void setPrintToFile(boolean printToFile) {
- this.printToFile = printToFile;
-}
-protected void checkSubclass() {
-}
-}
+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() {
+}
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Printing/photon/org/eclipse/swt/printing/PrintDialog.java b/bundles/org.eclipse.swt/Eclipse SWT Printing/photon/org/eclipse/swt/printing/PrintDialog.java
index 296b21c885..cc1e848af6 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT Printing/photon/org/eclipse/swt/printing/PrintDialog.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT Printing/photon/org/eclipse/swt/printing/PrintDialog.java
@@ -1,194 +1,194 @@
-package org.eclipse.swt.printing;
-
-/*
+package org.eclipse.swt.printing;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-import org.eclipse.swt.*;
-import org.eclipse.swt.widgets.*;
-
-/**
- * Instances of this class allow the user to select
- * a printer and various print-related parameters
- * prior to starting a print job.
- * <p>
- * IMPORTANT: This class is intended to be subclassed <em>only</em>
- * within the SWT implementation.
- * </p>
+ * http://www.eclipse.org/legal/cpl-v10.html
*/
-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
+
+import org.eclipse.swt.*;
+import org.eclipse.swt.widgets.*;
+
+/**
+ * Instances of this class allow the user to select
+ * a printer and various print-related parameters
+ * prior to starting a print job.
+ * <p>
+ * IMPORTANT: This class is intended to be subclassed <em>only</em>
+ * within the SWT implementation.
+ * </p>
*/
-public PrintDialog (Shell parent) {
- this (parent, SWT.PRIMARY_MODAL);
-}
-/**
- * Constructs a new instance of this class given its parent
- * and a style value describing its behavior and appearance.
- * <p>
- * The style value is either one of the style constants defined in
- * class <code>SWT</code> which is applicable to instances of this
- * class, or must be built by <em>bitwise OR</em>'ing together
- * (that is, using the <code>int</code> "|" operator) two or more
- * of those <code>SWT</code> style constants. The class description
- * lists the style constants that are applicable to the class.
- * Style bits are also inherited from superclasses.
- * </p>
- *
- * @param parent a composite control which will be the parent of the new instance (cannot be null)
- * @param style the style of control to construct
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
- * <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
- * </ul>
- *
- * @see SWT
- * @see Widget#checkSubclass
- * @see Widget#getStyle
+public 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, int style) {
- super (parent, style);
- 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 PrintDialog (Shell parent) {
+ this (parent, SWT.PRIMARY_MODAL);
+}
+/**
+ * Constructs a new instance of this class given its parent
+ * and a style value describing its behavior and appearance.
+ * <p>
+ * The style value is either one of the style constants defined in
+ * class <code>SWT</code> which is applicable to instances of this
+ * class, or must be built by <em>bitwise OR</em>'ing together
+ * (that is, using the <code>int</code> "|" operator) two or more
+ * of those <code>SWT</code> style constants. The class description
+ * lists the style constants that are applicable to the class.
+ * Style bits are also inherited from superclasses.
+ * </p>
+ *
+ * @param parent a composite control which will be the parent of the new instance (cannot be null)
+ * @param style the style of control to construct
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
+ * <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
+ * </ul>
+ *
+ * @see SWT
+ * @see Widget#checkSubclass
+ * @see Widget#getStyle
*/
-public PrinterData open() {
- /* Return the first printer in the list */
- PrinterData[] printers = Printer.getPrinterList();
- if (printers.length > 0) return printers[0];
- return null;
-}
-/**
- * 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 PrintDialog (Shell parent, int style) {
+ super (parent, style);
+ 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 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 PrinterData open() {
+ /* Return the first printer in the list */
+ PrinterData[] printers = Printer.getPrinterList();
+ if (printers.length > 0) return printers[0];
+ return null;
+}
+/**
+ * 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 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 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 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 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 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 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 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 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 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 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 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 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 void setPrintToFile(boolean printToFile) {
- this.printToFile = printToFile;
-}
-protected void checkSubclass() {
-}
-}
+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() {
+}
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Printing/photon/org/eclipse/swt/printing/Printer.java b/bundles/org.eclipse.swt/Eclipse SWT Printing/photon/org/eclipse/swt/printing/Printer.java
index b95ae235a3..cf180a548e 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT Printing/photon/org/eclipse/swt/printing/Printer.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT Printing/photon/org/eclipse/swt/printing/Printer.java
@@ -1,14 +1,14 @@
-package org.eclipse.swt.printing;
-
-/*
+package org.eclipse.swt.printing;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-import org.eclipse.swt.graphics.*;
-
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+import org.eclipse.swt.graphics.*;
+
/**
* Instances of this class are used to print to a printer.
* Applications create a GC on a printer using <code>new GC(printer)</code>
@@ -29,34 +29,34 @@ import org.eclipse.swt.graphics.*;
* @see PrinterData
* @see PrintDialog
*/
-public final class Printer extends Device {
- PrinterData data;
- int defaultFontList;
-
+public final class Printer extends Device {
+ PrinterData data;
+ int defaultFontList;
+
/**
* Returns an array of <code>PrinterData</code> objects
* representing all available printers.
*
* @return the list of available printers
*/
-public static PrinterData[] getPrinterList() {
- PrinterData printerList[] = new PrinterData[0];
- return printerList;
-}
-
-/**
- * Returns a <code>PrinterData</code> object representing
- * the default printer or <code>null</code> if there is no
- * printer available on the System.
- *
- * @return the default printer data or null
- *
- * @since 2.1
- */
-public static PrinterData getDefaultPrinterData() {
- return null;
-}
-
+public static PrinterData[] getPrinterList() {
+ PrinterData printerList[] = new PrinterData[0];
+ return printerList;
+}
+
+/**
+ * Returns a <code>PrinterData</code> object representing
+ * the default printer or <code>null</code> if there is no
+ * printer available on the System.
+ *
+ * @return the default printer data or null
+ *
+ * @since 2.1
+ */
+public static PrinterData getDefaultPrinterData() {
+ return null;
+}
+
/**
* Constructs a new printer representing the default printer.
* <p>
@@ -69,10 +69,10 @@ public static PrinterData getDefaultPrinterData() {
*
* @see #dispose
*/
-public Printer() {
- this(getDefaultPrinterData());
-}
-
+public Printer() {
+ this(getDefaultPrinterData());
+}
+
/**
* Constructs a new printer given a <code>PrinterData</code>
* object representing the desired printer.
@@ -89,11 +89,11 @@ public Printer() {
*
* @see #dispose
*/
-public Printer(PrinterData data) {
- super(data);
-}
-
-
+public Printer(PrinterData data) {
+ super(data);
+}
+
+
/**
* Invokes platform specific functionality to allocate a new GC handle.
* <p>
@@ -109,10 +109,10 @@ public Printer(PrinterData data) {
*
* @private
*/
-public int internal_new_GC(GCData data) {
- return 0;
-}
-
+public int internal_new_GC(GCData data) {
+ return 0;
+}
+
/**
* Invokes platform specific functionality to dispose a GC handle.
* <p>
@@ -128,9 +128,9 @@ public int internal_new_GC(GCData data) {
*
* @private
*/
-public void internal_dispose_GC(int xGC, GCData data) {
-}
-
+public void internal_dispose_GC(int xGC, GCData data) {
+}
+
/**
* Starts a print job and returns true if the job started successfully
* and false otherwise.
@@ -151,10 +151,10 @@ public void internal_dispose_GC(int xGC, GCData data) {
* @see #endPage
* @see #endJob
*/
-public boolean startJob(String jobName) {
- return true;
-}
-
+public boolean startJob(String jobName) {
+ return true;
+}
+
/**
* Ends the current print job.
*
@@ -166,9 +166,9 @@ public boolean startJob(String jobName) {
* @see #startPage
* @see #endPage
*/
-public void endJob() {
-}
-
+public void endJob() {
+}
+
/**
* Cancels a print job in progress.
*
@@ -176,9 +176,9 @@ public void endJob() {
* <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
* </ul>
*/
-public void cancelJob() {
-}
-
+public void cancelJob() {
+}
+
/**
* Starts a page and returns true if the page started successfully
* and false otherwise.
@@ -197,10 +197,10 @@ public void cancelJob() {
* @see #startJob
* @see #endJob
*/
-public boolean startPage() {
- return true;
-}
-
+public boolean startPage() {
+ return true;
+}
+
/**
* Ends the current page.
*
@@ -212,9 +212,9 @@ public boolean startPage() {
* @see #startJob
* @see #endJob
*/
-public void endPage() {
-}
-
+public void endPage() {
+}
+
/**
* Returns a point whose x coordinate is the horizontal
* dots per inch of the printer, and whose y coordinate
@@ -226,10 +226,10 @@ public void endPage() {
* <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
* </ul>
*/
-public Point getDPI() {
- return new Point(0, 0);
-}
-
+public Point getDPI() {
+ return new Point(0, 0);
+}
+
/**
* Returns a rectangle describing the receiver's size and location.
* For a printer, this is the size of a page, in pixels.
@@ -243,10 +243,10 @@ public Point getDPI() {
* @see #getClientArea
* @see #computeTrim
*/
-public Rectangle getBounds() {
- return null;
-}
-
+public Rectangle getBounds() {
+ return null;
+}
+
/**
* Returns a rectangle which describes the area of the
* receiver which is capable of displaying data.
@@ -262,10 +262,10 @@ public Rectangle getBounds() {
* @see #getBounds
* @see #computeTrim
*/
-public Rectangle getClientArea() {
- return null;
-}
-
+public Rectangle getClientArea() {
+ return null;
+}
+
/**
* Given a desired <em>client area</em> for the receiver
* (as described by the arguments), returns the bounding
@@ -292,18 +292,18 @@ public Rectangle getClientArea() {
* @see #getBounds
* @see #getClientArea
*/
-public Rectangle computeTrim(int x, int y, int width, int height) {
- return new Rectangle(0,0,0,0);
-}
-
-/**
- * Returns a <code>PrinterData</code> object representing the
- * target printer for this print job.
- *
- * @return a PrinterData object describing the receiver
+public Rectangle computeTrim(int x, int y, int width, int height) {
+ return new Rectangle(0,0,0,0);
+}
+
+/**
+ * Returns a <code>PrinterData</code> object representing the
+ * target printer for this print job.
+ *
+ * @return a PrinterData object describing the receiver
*/
-public PrinterData getPrinterData() {
- return data;
-}
-
-}
+public PrinterData getPrinterData() {
+ return data;
+}
+
+}
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
index 164cc69c14..cc1abd9de4 100755
--- 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
@@ -1,293 +1,293 @@
-package org.eclipse.swt.printing;
-
-/*
- * Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
- * This file is made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-import org.eclipse.swt.*;
-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
- * lists the style constants that are applicable to the class.
- * Style bits are also inherited from superclasses.
- * </p>
- *
- * @param parent a composite control which will be the parent of the new instance (cannot be null)
- * @param style the style of control to construct
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
- * <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
- * </ul>
- *
- * @see SWT
- * @see Widget#checkSubclass
- * @see Widget#getStyle
- */
-public PrintDialog (Shell parent, int style) {
- super (parent, style);
- checkSubclass ();
-}
-
-/**
- * Returns the print job scope that the user selected
- * before pressing OK in the dialog. This will be one
- * of the following values:
- * <dl>
- * <dt><code>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 one based and 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.
- * <p>
- * Note that this value is one based and only valid if the scope is
- * <code>PAGE_RANGE</code>.
- * </p>
- *
- * @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 one based and 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.
- * <p>
- * Note that this value is one based and only valid if the scope is
- * <code>PAGE_RANGE</code>.
- * </p>
- *
- * @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;
- Control parent = getParent();
- if (parent != null) pd.hwndOwner = parent.handle;
- 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) Math.min (0xFFFF, Math.max (1, startPage));
- pd.nToPage = (short) Math.min (0xFFFF, Math.max (1, endPage));
- if (OS.PrintDlg(pd)) { // success
- /* Get driver and device from the DEVNAMES struct */
- int hMem = pd.hDevNames;
- /* Ensure size is a multiple of 2 bytes on UNICODE platforms */
- int size = OS.GlobalSize(hMem) / TCHAR.sizeof * TCHAR.sizeof;
- int ptr = OS.GlobalLock(hMem);
- short[] offsets = new short[4];
- OS.MoveMemory(offsets, ptr, 2 * offsets.length);
- TCHAR buffer = new TCHAR(0, size);
- OS.MoveMemory(buffer, ptr, size);
- OS.GlobalUnlock(hMem);
-
- int driverOffset = offsets[0];
- int i = 0;
- while (driverOffset + i < size) {
- if (buffer.tcharAt(driverOffset + i) == 0) break;
- i++;
- }
- String driver = buffer.toString(driverOffset, i);
-
- int deviceOffset = offsets[1];
- i = 0;
- while (deviceOffset + i < size) {
- if (buffer.tcharAt(deviceOffset + i) == 0) break;
- i++;
- }
- String device = buffer.toString(deviceOffset, i);
-
- int outputOffset = offsets[2];
- i = 0;
- while (outputOffset + i < size) {
- if (buffer.tcharAt(outputOffset + i) == 0) break;
- i++;
- }
- String output = buffer.toString(outputOffset, 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 & 0xFFFF;
- data.endPage = pd.nToPage & 0xFFFF;
- } else if ((pd.Flags & OS.PD_SELECTION) != 0) {
- data.scope = PrinterData.SELECTION;
- }
- data.printToFile = (pd.Flags & OS.PD_PRINTTOFILE) != 0;
- if (data.printToFile) data.fileName = output;
- data.copyCount = pd.nCopies;
- data.collate = (pd.Flags & OS.PD_COLLATE) != 0;
-
- /* Bulk-save the printer-specific settings in the DEVMODE struct */
- hMem = pd.hDevMode;
- size = OS.GlobalSize(hMem);
- ptr = OS.GlobalLock(hMem);
- data.otherData = new byte[size];
- OS.MoveMemory(data.otherData, ptr, size);
- OS.GlobalUnlock(hMem);
-
- endPage = data.endPage;
- printToFile = data.printToFile;
- scope = data.scope;
- startPage = data.startPage;
- return data;
- }
- return null;
-}
-}
+package org.eclipse.swt.printing;
+
+/*
+ * Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
+ * This file is made available under the terms of the Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+import org.eclipse.swt.*;
+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
+ * lists the style constants that are applicable to the class.
+ * Style bits are also inherited from superclasses.
+ * </p>
+ *
+ * @param parent a composite control which will be the parent of the new instance (cannot be null)
+ * @param style the style of control to construct
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
+ * <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
+ * </ul>
+ *
+ * @see SWT
+ * @see Widget#checkSubclass
+ * @see Widget#getStyle
+ */
+public PrintDialog (Shell parent, int style) {
+ super (parent, style);
+ checkSubclass ();
+}
+
+/**
+ * Returns the print job scope that the user selected
+ * before pressing OK in the dialog. This will be one
+ * of the following values:
+ * <dl>
+ * <dt><code>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 one based and 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.
+ * <p>
+ * Note that this value is one based and only valid if the scope is
+ * <code>PAGE_RANGE</code>.
+ * </p>
+ *
+ * @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 one based and 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.
+ * <p>
+ * Note that this value is one based and only valid if the scope is
+ * <code>PAGE_RANGE</code>.
+ * </p>
+ *
+ * @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;
+ Control parent = getParent();
+ if (parent != null) pd.hwndOwner = parent.handle;
+ 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) Math.min (0xFFFF, Math.max (1, startPage));
+ pd.nToPage = (short) Math.min (0xFFFF, Math.max (1, endPage));
+ if (OS.PrintDlg(pd)) { // success
+ /* Get driver and device from the DEVNAMES struct */
+ int hMem = pd.hDevNames;
+ /* Ensure size is a multiple of 2 bytes on UNICODE platforms */
+ int size = OS.GlobalSize(hMem) / TCHAR.sizeof * TCHAR.sizeof;
+ int ptr = OS.GlobalLock(hMem);
+ short[] offsets = new short[4];
+ OS.MoveMemory(offsets, ptr, 2 * offsets.length);
+ TCHAR buffer = new TCHAR(0, size);
+ OS.MoveMemory(buffer, ptr, size);
+ OS.GlobalUnlock(hMem);
+
+ int driverOffset = offsets[0];
+ int i = 0;
+ while (driverOffset + i < size) {
+ if (buffer.tcharAt(driverOffset + i) == 0) break;
+ i++;
+ }
+ String driver = buffer.toString(driverOffset, i);
+
+ int deviceOffset = offsets[1];
+ i = 0;
+ while (deviceOffset + i < size) {
+ if (buffer.tcharAt(deviceOffset + i) == 0) break;
+ i++;
+ }
+ String device = buffer.toString(deviceOffset, i);
+
+ int outputOffset = offsets[2];
+ i = 0;
+ while (outputOffset + i < size) {
+ if (buffer.tcharAt(outputOffset + i) == 0) break;
+ i++;
+ }
+ String output = buffer.toString(outputOffset, 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 & 0xFFFF;
+ data.endPage = pd.nToPage & 0xFFFF;
+ } else if ((pd.Flags & OS.PD_SELECTION) != 0) {
+ data.scope = PrinterData.SELECTION;
+ }
+ data.printToFile = (pd.Flags & OS.PD_PRINTTOFILE) != 0;
+ if (data.printToFile) data.fileName = output;
+ data.copyCount = pd.nCopies;
+ data.collate = (pd.Flags & OS.PD_COLLATE) != 0;
+
+ /* Bulk-save the printer-specific settings in the DEVMODE struct */
+ hMem = pd.hDevMode;
+ size = OS.GlobalSize(hMem);
+ ptr = OS.GlobalLock(hMem);
+ data.otherData = new byte[size];
+ OS.MoveMemory(data.otherData, ptr, size);
+ OS.GlobalUnlock(hMem);
+
+ endPage = data.endPage;
+ printToFile = data.printToFile;
+ scope = data.scope;
+ startPage = data.startPage;
+ return data;
+ }
+ return null;
+}
+}
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
index a18724f8c2..0813062b97 100755
--- 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
@@ -1,513 +1,513 @@
-package org.eclipse.swt.printing;
-
-/*
+package org.eclipse.swt.printing;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-import org.eclipse.swt.*;
-import org.eclipse.swt.graphics.*;
-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 TCHAR profile;
- static TCHAR appName;
- static TCHAR keyName;
- static {
- profile = new TCHAR(0, "PrinterPorts", true);
- appName = new TCHAR(0, "windows", true);
- keyName = new TCHAR(0, "device", true);
- }
-
-/**
- * Returns an array of <code>PrinterData</code> objects
- * representing all available printers.
- *
- * @return the list of available printers
- */
-public static PrinterData[] getPrinterList() {
- int length = 1024;
- /* Use the character encoding for the default locale */
- TCHAR buf = new TCHAR(0, length);
- TCHAR nullBuf = new TCHAR(0, 1);
- int n = OS.GetProfileString(profile, null, nullBuf, buf, length);
- if (n == 0) return new PrinterData[0];
- String[] deviceNames = new String[5];
- int nameCount = 0;
- int index = 0;
- for (int i = 0; i < n; i++) {
- if (buf.tcharAt(i) == 0) {
- if (nameCount == deviceNames.length) {
- String[] newNames = new String[deviceNames.length + 5];
- System.arraycopy(deviceNames, 0, newNames, 0, deviceNames.length);
- deviceNames = newNames;
- }
- deviceNames[nameCount] = buf.toString(index, i - index);
- nameCount++;
- index = i + 1;
- }
- }
- PrinterData printerList[] = new PrinterData[nameCount];
- for (int p = 0; p < nameCount; p++) {
- String device = deviceNames[p];
- String driver = "";
- if (OS.GetProfileString(profile, new TCHAR(0, device, true), nullBuf, buf, length) > 0) {
- int commaIndex = 0;
- while (buf.tcharAt(commaIndex) != ',' && commaIndex < length) commaIndex++;
- if (commaIndex < length) {
- driver = buf.toString(0, commaIndex);
- }
- }
- printerList[p] = new PrinterData(driver, device);
- }
- return printerList;
-}
-
-/**
- * Returns a <code>PrinterData</code> object representing
- * the default printer or <code>null</code> if there is no
- * printer available on the System.
- *
- * @return the default printer data or null
- *
- * @since 2.1
- */
-public static PrinterData getDefaultPrinterData() {
- String deviceName = null;
- int length = 1024;
- /* Use the character encoding for the default locale */
- TCHAR buf = new TCHAR(0, length);
- TCHAR nullBuf = new TCHAR(0, 1);
- int n = OS.GetProfileString(appName, keyName, nullBuf, buf, length);
- if (n == 0) return null;
- int commaIndex = 0;
- while(buf.tcharAt(commaIndex) != ',' && commaIndex < length) commaIndex++;
- if (commaIndex < length) {
- deviceName = buf.toString(0, commaIndex);
- }
- String driver = "";
- if (OS.GetProfileString(profile, new TCHAR(0, deviceName, true), nullBuf, buf, length) > 0) {
- commaIndex = 0;
- while (buf.tcharAt(commaIndex) != ',' && commaIndex < length) commaIndex++;
- if (commaIndex < length) {
- driver = buf.toString(0, commaIndex);
- }
- }
- return new PrinterData(driver, deviceName);
-}
-
-static DeviceData checkNull (PrinterData data) {
- if (data == null) data = new PrinterData();
- if (data.driver == null || data.name == null) {
- PrinterData defaultPrinter = getDefaultPrinterData();
- if (defaultPrinter == null) SWT.error(SWT.ERROR_NO_HANDLES);
- data.driver = defaultPrinter.driver;
- data.name = defaultPrinter.name;
- }
- return data;
-}
-
-/**
- * Constructs a new printer representing the default printer.
- * <p>
- * You must dispose the printer when it is no longer required.
- * </p>
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_UNSPECIFIED - if there are no valid printers
- * </ul>
- *
- * @see #dispose
- */
-public Printer() {
- this(null);
-}
-
-/**
- * Constructs a new printer given a <code>PrinterData</code>
- * object representing the desired printer.
- * <p>
- * You must dispose the printer when it is no longer required.
- * </p>
- *
- * @param data the printer data for the specified printer
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_INVALID_ARGUMENT - if the specified printer data does not represent a valid printer
- * <li>ERROR_UNSPECIFIED - if there are no valid printers
- * </ul>
- *
- * @see #dispose
- */
-public Printer(PrinterData data) {
- super(checkNull(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;
- /* Use the character encoding for the default locale */
- TCHAR driver = new TCHAR(0, data.driver, true);
- TCHAR device = new TCHAR(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) {
- /* Use the character encoding for the default locale */
- TCHAR buffer = new TCHAR(0, jobName, true);
- int byteCount = buffer.length() * TCHAR.sizeof;
- lpszDocName = OS.HeapAlloc(hHeap, OS.HEAP_ZERO_MEMORY, byteCount);
- OS.MoveMemory(lpszDocName, buffer, byteCount);
- di.lpszDocName = lpszDocName;
- }
- int lpszOutput = 0;
- if (data.printToFile && data.fileName != null) {
- /* Use the character encoding for the default locale */
- TCHAR buffer = new TCHAR(0, data.fileName, true);
- int byteCount = buffer.length() * TCHAR.sizeof;
- lpszOutput = OS.HeapAlloc(hHeap, OS.HEAP_ZERO_MEMORY, byteCount);
- OS.MoveMemory(lpszOutput, buffer, byteCount);
- 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 a <code>PrinterData</code> object representing the
- * target printer for this print job.
- *
- * @return a PrinterData object 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;
-}
-
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+import org.eclipse.swt.*;
+import org.eclipse.swt.graphics.*;
+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 TCHAR profile;
+ static TCHAR appName;
+ static TCHAR keyName;
+ static {
+ profile = new TCHAR(0, "PrinterPorts", true);
+ appName = new TCHAR(0, "windows", true);
+ keyName = new TCHAR(0, "device", true);
+ }
+
+/**
+ * Returns an array of <code>PrinterData</code> objects
+ * representing all available printers.
+ *
+ * @return the list of available printers
+ */
+public static PrinterData[] getPrinterList() {
+ int length = 1024;
+ /* Use the character encoding for the default locale */
+ TCHAR buf = new TCHAR(0, length);
+ TCHAR nullBuf = new TCHAR(0, 1);
+ int n = OS.GetProfileString(profile, null, nullBuf, buf, length);
+ if (n == 0) return new PrinterData[0];
+ String[] deviceNames = new String[5];
+ int nameCount = 0;
+ int index = 0;
+ for (int i = 0; i < n; i++) {
+ if (buf.tcharAt(i) == 0) {
+ if (nameCount == deviceNames.length) {
+ String[] newNames = new String[deviceNames.length + 5];
+ System.arraycopy(deviceNames, 0, newNames, 0, deviceNames.length);
+ deviceNames = newNames;
+ }
+ deviceNames[nameCount] = buf.toString(index, i - index);
+ nameCount++;
+ index = i + 1;
+ }
+ }
+ PrinterData printerList[] = new PrinterData[nameCount];
+ for (int p = 0; p < nameCount; p++) {
+ String device = deviceNames[p];
+ String driver = "";
+ if (OS.GetProfileString(profile, new TCHAR(0, device, true), nullBuf, buf, length) > 0) {
+ int commaIndex = 0;
+ while (buf.tcharAt(commaIndex) != ',' && commaIndex < length) commaIndex++;
+ if (commaIndex < length) {
+ driver = buf.toString(0, commaIndex);
+ }
+ }
+ printerList[p] = new PrinterData(driver, device);
+ }
+ return printerList;
+}
+
+/**
+ * Returns a <code>PrinterData</code> object representing
+ * the default printer or <code>null</code> if there is no
+ * printer available on the System.
+ *
+ * @return the default printer data or null
+ *
+ * @since 2.1
+ */
+public static PrinterData getDefaultPrinterData() {
+ String deviceName = null;
+ int length = 1024;
+ /* Use the character encoding for the default locale */
+ TCHAR buf = new TCHAR(0, length);
+ TCHAR nullBuf = new TCHAR(0, 1);
+ int n = OS.GetProfileString(appName, keyName, nullBuf, buf, length);
+ if (n == 0) return null;
+ int commaIndex = 0;
+ while(buf.tcharAt(commaIndex) != ',' && commaIndex < length) commaIndex++;
+ if (commaIndex < length) {
+ deviceName = buf.toString(0, commaIndex);
+ }
+ String driver = "";
+ if (OS.GetProfileString(profile, new TCHAR(0, deviceName, true), nullBuf, buf, length) > 0) {
+ commaIndex = 0;
+ while (buf.tcharAt(commaIndex) != ',' && commaIndex < length) commaIndex++;
+ if (commaIndex < length) {
+ driver = buf.toString(0, commaIndex);
+ }
+ }
+ return new PrinterData(driver, deviceName);
+}
+
+static DeviceData checkNull (PrinterData data) {
+ if (data == null) data = new PrinterData();
+ if (data.driver == null || data.name == null) {
+ PrinterData defaultPrinter = getDefaultPrinterData();
+ if (defaultPrinter == null) SWT.error(SWT.ERROR_NO_HANDLES);
+ data.driver = defaultPrinter.driver;
+ data.name = defaultPrinter.name;
+ }
+ return data;
+}
+
+/**
+ * Constructs a new printer representing the default printer.
+ * <p>
+ * You must dispose the printer when it is no longer required.
+ * </p>
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_UNSPECIFIED - if there are no valid printers
+ * </ul>
+ *
+ * @see #dispose
+ */
+public Printer() {
+ this(null);
+}
+
+/**
+ * Constructs a new printer given a <code>PrinterData</code>
+ * object representing the desired printer.
+ * <p>
+ * You must dispose the printer when it is no longer required.
+ * </p>
+ *
+ * @param data the printer data for the specified printer
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_INVALID_ARGUMENT - if the specified printer data does not represent a valid printer
+ * <li>ERROR_UNSPECIFIED - if there are no valid printers
+ * </ul>
+ *
+ * @see #dispose
+ */
+public Printer(PrinterData data) {
+ super(checkNull(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;
+ /* Use the character encoding for the default locale */
+ TCHAR driver = new TCHAR(0, data.driver, true);
+ TCHAR device = new TCHAR(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) {
+ /* Use the character encoding for the default locale */
+ TCHAR buffer = new TCHAR(0, jobName, true);
+ int byteCount = buffer.length() * TCHAR.sizeof;
+ lpszDocName = OS.HeapAlloc(hHeap, OS.HEAP_ZERO_MEMORY, byteCount);
+ OS.MoveMemory(lpszDocName, buffer, byteCount);
+ di.lpszDocName = lpszDocName;
+ }
+ int lpszOutput = 0;
+ if (data.printToFile && data.fileName != null) {
+ /* Use the character encoding for the default locale */
+ TCHAR buffer = new TCHAR(0, data.fileName, true);
+ int byteCount = buffer.length() * TCHAR.sizeof;
+ lpszOutput = OS.HeapAlloc(hHeap, OS.HEAP_ZERO_MEMORY, byteCount);
+ OS.MoveMemory(lpszOutput, buffer, byteCount);
+ 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 a <code>PrinterData</code> object representing the
+ * target printer for this print job.
+ *
+ * @return a PrinterData object 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/photon/org/eclipse/swt/program/Program.java b/bundles/org.eclipse.swt/Eclipse SWT Program/photon/org/eclipse/swt/program/Program.java
index e32c48ca80..90a9502db9 100755
--- 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
@@ -1,256 +1,256 @@
-package org.eclipse.swt.program;
-
-/*
+package org.eclipse.swt.program;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-import org.eclipse.swt.internal.*;
-import org.eclipse.swt.internal.photon.*;
-import org.eclipse.swt.*;
-import org.eclipse.swt.graphics.*;
-
-import java.io.*;
-
-/**
- * Instances of this class represent programs and
- * their assoicated file extensions in the operating
- * system.
+ * http://www.eclipse.org/legal/cpl-v10.html
*/
-public final class Program {
- String name;
- String extension;
- String command;
-
-/**
- * Prevents uninitialized instances from being created outside the package.
+
+import org.eclipse.swt.internal.*;
+import org.eclipse.swt.internal.photon.*;
+import org.eclipse.swt.*;
+import org.eclipse.swt.graphics.*;
+
+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>
+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;
- String[][] table = loadAssociationTable ();
- if (table == null) return null;
- for (int i = 0; i < table.length; i++) {
- String[] entry = table [i];
- if (entry == null) break;
- String [] exts = expandExtensions (entry [0]);
- for (int j = 0; j < exts.length; j++) {
- String ext = exts[j];
- if (ext == null) break;
- if (ext.endsWith (extension)) {
- Program program = new Program ();
- program.extension = ext;
- program.command = entry [1];
- int index;
- String name = entry [1];
- if ((index = name.indexOf(' ')) != -1) {
- name = name.substring (0, index);
- }
- program.name = name;
- return program;
- }
- }
- }
- return null;
-}
-
-/**
- * Answer all program extensions in the operating system.
- *
- * @return an array of extensions
+public static Program findProgram (String extension) {
+ if (extension == null) SWT.error (SWT.ERROR_NULL_ARGUMENT);
+ if (extension.length () == 0) return null;
+ String[][] table = loadAssociationTable ();
+ if (table == null) return null;
+ for (int i = 0; i < table.length; i++) {
+ String[] entry = table [i];
+ if (entry == null) break;
+ String [] exts = expandExtensions (entry [0]);
+ for (int j = 0; j < exts.length; j++) {
+ String ext = exts[j];
+ if (ext == null) break;
+ if (ext.endsWith (extension)) {
+ Program program = new Program ();
+ program.extension = ext;
+ program.command = entry [1];
+ int index;
+ String name = entry [1];
+ if ((index = name.indexOf(' ')) != -1) {
+ name = name.substring (0, index);
+ }
+ program.name = name;
+ return program;
+ }
+ }
+ }
+ return null;
+}
+
+/**
+ * Answer all program extensions in the operating system.
+ *
+ * @return an array of extensions
*/
-public static String [] getExtensions () {
- String[][] table = loadAssociationTable ();
- if (table == null) return new String [0];
- int count = 0;
- String[] extensions = new String [50];
+public static String [] getExtensions () {
+ String[][] table = loadAssociationTable ();
+ if (table == null) return new String [0];
+ int count = 0;
+ String[] extensions = new String [50];
for (int i = 0; i < table.length; i++) {
- String[] entry = table [i];
+ String[] entry = table [i];
if (entry == null) break;
- String [] exts = expandExtensions (entry [0]);
+ String [] exts = expandExtensions (entry [0]);
for (int j = 0; j < exts.length; j++) {
String ext = exts[j];
if (ext == null) break;
- if (count == extensions.length) {
- String [] newExtensions = new String [count + 50];
- System.arraycopy (extensions, 0, newExtensions, 0, count);
- extensions = newExtensions;
- }
+ if (count == extensions.length) {
+ String [] newExtensions = new String [count + 50];
+ System.arraycopy (extensions, 0, newExtensions, 0, count);
+ extensions = newExtensions;
+ }
extensions[count++] = ext;
- }
- }
- if (count != extensions.length) {
- String [] newExtensions = new String [count];
- System.arraycopy (extensions, 0, newExtensions, 0, count);
- extensions = newExtensions;
- }
- return extensions;
-}
-
-/**
- * Answers all available programs in the operating system.
- *
- * @return an array of programs
+ }
+ }
+ if (count != extensions.length) {
+ String [] newExtensions = new String [count];
+ System.arraycopy (extensions, 0, newExtensions, 0, count);
+ extensions = newExtensions;
+ }
+ return extensions;
+}
+
+/**
+ * Answers all available programs in the operating system.
+ *
+ * @return an array of programs
*/
-public static Program [] getPrograms () {
- String[][] table = loadAssociationTable ();
- if (table == null) return new Program [0];
- int count = 0;
- Program [] programs = new Program [50];
- for (int i = 0; i < table.length; i++) {
- String [] entry = table [i];
- if (entry == null) break;
- String [] extensions = expandExtensions (entry [0]);
+public static Program [] getPrograms () {
+ String[][] table = loadAssociationTable ();
+ if (table == null) return new Program [0];
+ int count = 0;
+ Program [] programs = new Program [50];
+ for (int i = 0; i < table.length; i++) {
+ String [] entry = table [i];
+ if (entry == null) break;
+ String [] extensions = expandExtensions (entry [0]);
for (int j = 0; j < extensions.length; j++) {
- String extension = extensions[j];
- if (extension == null) break;
- Program program = new Program ();
- program.extension = extension;
- program.command = entry [1];
- int index;
- String name = entry [1];
- if ((index = name.indexOf(' ')) != -1) {
- name = name.substring (0, index);
- }
- program.name = name;
- if (count == programs.length) {
- Program [] newPrograms = new Program [count + 50];
- System.arraycopy (programs, 0, newPrograms, 0, count);
- programs = newPrograms;
- }
+ String extension = extensions[j];
+ if (extension == null) break;
+ Program program = new Program ();
+ program.extension = extension;
+ program.command = entry [1];
+ int index;
+ String name = entry [1];
+ if ((index = name.indexOf(' ')) != -1) {
+ name = name.substring (0, index);
+ }
+ program.name = name;
+ if (count == programs.length) {
+ Program [] newPrograms = new Program [count + 50];
+ System.arraycopy (programs, 0, newPrograms, 0, count);
+ programs = newPrograms;
+ }
programs [count++] = program;
- }
- }
- 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>
+ }
+ }
+ 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 {
- Compatibility.exec(fileName);
- return true;
- } catch (IOException e) {
- return false;
- }
-}
-
-static String [] expandExtensions (String ext) {
- int start = 0, index = 0, count = 0, length = ext.length ();
- String[] extensions = new String [5];
- while (index < length) {
- index = ext.indexOf ('|', start);
- if (index == -1) index = length;
- String extension = ext.substring (start, index).trim();
- start = index + 1;
- int bracketStart = extension.indexOf('[');
- if (bracketStart != -1) {
- int bracketEnd = extension.indexOf(']', bracketStart);
- if (bracketEnd != -1) {
- String prefix = extension.substring (0, bracketStart);
- String suffix = extension.substring (bracketEnd + 1, extension.length ());
- String chars = extension.substring (bracketStart + 1, bracketEnd);
- for (int i=0; i<chars.length (); i++) {
- if (count == extensions.length) {
- String [] newExtensions = new String [count + 5];
- System.arraycopy (extensions, 0, newExtensions, 0, count);
- extensions = newExtensions;
- }
- extensions [count++] = prefix + chars.charAt (i) + suffix;
- }
- }
- } else {
- if (count == extensions.length) {
- String [] newExtensions = new String [count + 5];
- System.arraycopy (extensions, 0, newExtensions, 0, count);
- extensions = newExtensions;
- }
- extensions [count++] = extension;
- }
- }
- return extensions;
-}
-
-static String [][] loadAssociationTable () {
- FileInputStream is = null;
- try {
- byte[] buffer = Converter.wcsToMbcs (null, "HOME", true);
- int ptr = OS.getenv (buffer);
- if (ptr == 0) return null;
- int length = OS.strlen (ptr);
- if (length == 0) return null;
- buffer = new byte [length];
- OS.memmove (buffer, ptr, length);
- String home = new String (Converter.mbcsToWcs (null, buffer));
- is = new FileInputStream (home + "/.ph/pfm/associate.003");
- BufferedReader reader = new BufferedReader (new InputStreamReader (is));
- String line;
- int count = 0;
- String [][] table = new String [50][];
- while ((line = reader.readLine ()) != null) {
- if (line.trim().startsWith ("#")) continue;
- int start = 0, tabIndex = line.indexOf ('\t', start);
- if (tabIndex == -1) continue;
- String extension = line.substring (start, tabIndex);
- start = tabIndex + 1;
- tabIndex = line.indexOf ('\t', start);
- if (tabIndex == -1) continue;
- String command = line.substring (start, tabIndex);
- if (count == table.length) {
- String [][] newTable = new String [table.length + 50][];
- System.arraycopy (table, 0, newTable, 0, table.length);
- table = newTable;
- }
- String[] entry = new String [] {extension, command};
- table [count++] = entry;
- }
- return table;
- } catch (IOException e) {
- } finally {
- try {
- if (is != null) is.close();
- } catch (IOException e) {}
- }
- return null;
-}
-
+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 {
+ Compatibility.exec(fileName);
+ return true;
+ } catch (IOException e) {
+ return false;
+ }
+}
+
+static String [] expandExtensions (String ext) {
+ int start = 0, index = 0, count = 0, length = ext.length ();
+ String[] extensions = new String [5];
+ while (index < length) {
+ index = ext.indexOf ('|', start);
+ if (index == -1) index = length;
+ String extension = ext.substring (start, index).trim();
+ start = index + 1;
+ int bracketStart = extension.indexOf('[');
+ if (bracketStart != -1) {
+ int bracketEnd = extension.indexOf(']', bracketStart);
+ if (bracketEnd != -1) {
+ String prefix = extension.substring (0, bracketStart);
+ String suffix = extension.substring (bracketEnd + 1, extension.length ());
+ String chars = extension.substring (bracketStart + 1, bracketEnd);
+ for (int i=0; i<chars.length (); i++) {
+ if (count == extensions.length) {
+ String [] newExtensions = new String [count + 5];
+ System.arraycopy (extensions, 0, newExtensions, 0, count);
+ extensions = newExtensions;
+ }
+ extensions [count++] = prefix + chars.charAt (i) + suffix;
+ }
+ }
+ } else {
+ if (count == extensions.length) {
+ String [] newExtensions = new String [count + 5];
+ System.arraycopy (extensions, 0, newExtensions, 0, count);
+ extensions = newExtensions;
+ }
+ extensions [count++] = extension;
+ }
+ }
+ return extensions;
+}
+
+static String [][] loadAssociationTable () {
+ FileInputStream is = null;
+ try {
+ byte[] buffer = Converter.wcsToMbcs (null, "HOME", true);
+ int ptr = OS.getenv (buffer);
+ if (ptr == 0) return null;
+ int length = OS.strlen (ptr);
+ if (length == 0) return null;
+ buffer = new byte [length];
+ OS.memmove (buffer, ptr, length);
+ String home = new String (Converter.mbcsToWcs (null, buffer));
+ is = new FileInputStream (home + "/.ph/pfm/associate.003");
+ BufferedReader reader = new BufferedReader (new InputStreamReader (is));
+ String line;
+ int count = 0;
+ String [][] table = new String [50][];
+ while ((line = reader.readLine ()) != null) {
+ if (line.trim().startsWith ("#")) continue;
+ int start = 0, tabIndex = line.indexOf ('\t', start);
+ if (tabIndex == -1) continue;
+ String extension = line.substring (start, tabIndex);
+ start = tabIndex + 1;
+ tabIndex = line.indexOf ('\t', start);
+ if (tabIndex == -1) continue;
+ String command = line.substring (start, tabIndex);
+ if (count == table.length) {
+ String [][] newTable = new String [table.length + 50][];
+ System.arraycopy (table, 0, newTable, 0, table.length);
+ table = newTable;
+ }
+ String[] entry = new String [] {extension, command};
+ table [count++] = entry;
+ }
+ return table;
+ } catch (IOException e) {
+ } finally {
+ try {
+ if (is != null) is.close();
+ } catch (IOException e) {}
+ }
+ return null;
+}
+
/**
* Executes the program with the file as the single argument
* in the operating system. It is the responsibility of the
@@ -264,82 +264,82 @@ static String [][] loadAssociationTable () {
* <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 = -1;
- String prefix = command, suffix = "", location = "";
- String[] locations = {"file://$PWD/@", "$PWD/@", "@"};
+public boolean execute (String fileName) {
+ if (fileName == null) SWT.error (SWT.ERROR_NULL_ARGUMENT);
+ int index = -1;
+ String prefix = command, suffix = "", location = "";
+ String[] locations = {"file://$PWD/@", "$PWD/@", "@"};
for (int i = 0; i < locations.length; i++) {
location = locations[i];
- index = command.indexOf (location);
+ index = command.indexOf (location);
if (index != -1) break;
- }
- if (index != -1) {
- int start = 0;
- prefix = command.substring (start, index);
- start = index + location.length() + 1;
- if (start < command.length ()) {
- suffix = command.substring (start, command.length ());
- }
- }
- try {
- Compatibility.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, may be null
+ }
+ if (index != -1) {
+ int start = 0;
+ prefix = command.substring (start, index);
+ start = index + location.length() + 1;
+ if (start < command.length ()) {
+ suffix = command.substring (start, command.length ());
+ }
+ }
+ try {
+ Compatibility.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, may be null
*/
-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 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;
-}
-
-/**
- * Returns true if the receiver and the argument represent
- * the same program.
- *
- * @return true if the programs are the same
+public String getName () {
+ return name;
+}
+
+/**
+ * Returns true if the receiver and the argument represent
+ * the same program.
+ *
+ * @return true if the programs are the same
*/
-public boolean equals(Object other) {
- if (this == other) return true;
- if (other instanceof Program) {
- final Program program = (Program) other;
- return extension.equals(program.extension) && name.equals(program.name) &&
- command.equals(program.command);
- }
- return false;
-}
-
-/**
- * Returns a hash code suitable for this object.
- *
- * @return a hash code
+public boolean equals(Object other) {
+ if (this == other) return true;
+ if (other instanceof Program) {
+ final Program program = (Program) other;
+ return extension.equals(program.extension) && name.equals(program.name) &&
+ command.equals(program.command);
+ }
+ return false;
+}
+
+/**
+ * Returns a hash code suitable for this object.
+ *
+ * @return a hash code
*/
-public int hashCode() {
- return extension.hashCode() ^ name.hashCode() ^ command.hashCode();
-}
-
-public String toString () {
- return "Program {" + name + "}";
-}
-
+public int hashCode() {
+ return extension.hashCode() ^ name.hashCode() ^ command.hashCode();
+}
+
+public String toString () {
+ return "Program {" + name + "}";
+}
+
}
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
index d9d166de9a..a81f624a57 100755
--- 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
@@ -1,328 +1,328 @@
-package org.eclipse.swt.program;
-
-/*
+package org.eclipse.swt.program;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-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;
- /* Use the character encoding for the default locale */
- TCHAR key = new TCHAR (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};
- TCHAR lpData = new TCHAR (0, 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.toString (0, lpData.strlen ()));
-}
-
-/**
- * Answer all program extensions in the operating system.
- *
- * @return an array of extensions
- */
-public static String [] getExtensions () {
- String [] extensions = new String [1024];
- /* Use the character encoding for the default locale */
- TCHAR lpName = new TCHAR (0, 1024);
- int [] lpcName = new int [] {lpName.length ()};
- FILETIME ft = new FILETIME ();
- int dwIndex = 0, count = 0;
- while (OS.RegEnumKeyEx (OS.HKEY_CLASSES_ROOT, dwIndex, lpName, lpcName, null, null, null, ft) != OS.ERROR_NO_MORE_ITEMS) {
- String extension = lpName.toString (0, lpcName [0]);
- lpcName [0] = lpName.length ();
- if (extension.length () > 0 && extension.charAt (0) == '.') {
- if (count == extensions.length) {
- String [] newExtensions = new String [extensions.length + 1024];
- System.arraycopy (extensions, 0, newExtensions, 0, extensions.length);
- extensions = newExtensions;
- }
- extensions [count++] = extension;
- }
- dwIndex++;
- }
- if (count != extensions.length) {
- String [] newExtension = new String [count];
- System.arraycopy (extensions, 0, newExtension, 0, count);
- extensions = newExtension;
- }
- return extensions;
-}
-
-static String getKeyValue (String string, boolean expand) {
- /* Use the character encoding for the default locale */
- TCHAR key = new TCHAR (0, string, true);
- 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], (TCHAR) null, 0, null, null, lpcbData) == 0) {
- /* Use the character encoding for the default locale */
- TCHAR lpData = new TCHAR (0, lpcbData [0] / TCHAR.sizeof);
- if (OS.RegQueryValueEx (phkResult [0], null, 0, null, lpData, lpcbData) == 0) {
- if (!OS.IsWinCE && expand) {
- int nSize = OS.ExpandEnvironmentStrings (lpData, null, 0);
- TCHAR lpDst = new TCHAR (0, nSize);
- OS.ExpandEnvironmentStrings (lpData, lpDst, nSize);
- result = lpDst.toString (0, Math.max (0, nSize - 1));
- } else {
- int length = Math.max (0, lpData.length () - 1);
- result = lpData.toString (0, length);
- }
- }
- }
- if (phkResult [0] != 0) OS.RegCloseKey (phkResult [0]);
- return result;
-}
-
-static Program getProgram (String key) {
-
- /* Name */
- String name = getKeyValue (key, false);
- if (name == null || name.length () == 0) return null;
-
- /* Command */
- String COMMAND = "\\shell\\open\\command";
- String command = getKeyValue (key + COMMAND, true);
- if (command == null || command.length () == 0) return null;
-
- /* Icon */
- String DEFAULT_ICON = "\\DefaultIcon";
- String iconName = getKeyValue (key + DEFAULT_ICON, true);
- 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];
- /* Use the character encoding for the default locale */
- TCHAR lpName = new TCHAR (0, 1024);
- int [] lpcName = new int [] {lpName.length ()};
- FILETIME ft = new FILETIME ();
- int dwIndex = 0, count = 0;
- while (OS.RegEnumKeyEx (OS.HKEY_CLASSES_ROOT, dwIndex, lpName, lpcName, null, null, null, ft) != OS.ERROR_NO_MORE_ITEMS) {
- String path = lpName.toString (0, lpcName [0]);
- lpcName [0] = lpName.length ();
- Program program = getProgram (path);
- 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;
- }
- dwIndex++;
- }
- 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);
-
- /* Use the character encoding for the default locale */
- int hHeap = OS.GetProcessHeap ();
- TCHAR buffer1 = new TCHAR (0, "open", true);
- int byteCount1 = buffer1.length () * TCHAR.sizeof;
- int lpVerb = OS.HeapAlloc (hHeap, OS.HEAP_ZERO_MEMORY, byteCount1);
- OS.MoveMemory (lpVerb, buffer1, byteCount1);
- TCHAR buffer2 = new TCHAR (0, fileName, true);
- int byteCount2 = buffer2.length () * TCHAR.sizeof;
- int lpFile = OS.HeapAlloc (hHeap, OS.HEAP_ZERO_MEMORY, byteCount2);
- OS.MoveMemory (lpFile, buffer2, byteCount2);
-
- SHELLEXECUTEINFO info = new SHELLEXECUTEINFO ();
- info.cbSize = SHELLEXECUTEINFO.sizeof;
- info.lpVerb = lpVerb;
- info.lpFile = lpFile;
- info.nShow = OS.SW_SHOW;
-
- boolean result = OS.ShellExecuteEx (info);
-
- if (lpVerb != 0) OS.HeapFree (hHeap, 0, lpVerb);
- if (lpFile != 0) OS.HeapFree (hHeap, 0, lpFile);
-
- return result;
-}
-
-/**
- * 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);
- boolean quote = true;
- String prefix = command, suffix = "";
- int index = command.indexOf ("%1");
- if (index != -1) {
- int count=0;
- int i=index + 2, length = command.length ();
- while (i < length) {
- if (command.charAt (i) == '"') count++;
- i++;
- }
- quote = count % 2 == 0;
- prefix = command.substring (0, index);
- suffix = command.substring (index + 2, length);
- }
- if (quote) fileName = " \"" + fileName + "\"";
- try {
- Compatibility.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, may be null
- */
-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) {};
- }
- /* Use the character encoding for the default locale */
- TCHAR lpszFile = new TCHAR (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;
-}
-
-/**
- * Returns true if the receiver and the argument represent
- * the same program.
- *
- * @return true if the programs are the same
- */
-public boolean equals(Object other) {
- if (this == other) return true;
- if (other instanceof Program) {
- final Program program = (Program) other;
- return name.equals(program.name) && command.equals(program.command)
- && iconName.equals(program.iconName);
- }
- return false;
-}
-
-/**
- * Returns a hash code suitable for this object.
- *
- * @return a hash code
- */
-public int hashCode() {
- return name.hashCode() ^ command.hashCode() ^ iconName.hashCode();
-}
-
-public String toString () {
- return "Program {" + name + "}";
-}
-
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+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;
+ /* Use the character encoding for the default locale */
+ TCHAR key = new TCHAR (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};
+ TCHAR lpData = new TCHAR (0, 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.toString (0, lpData.strlen ()));
+}
+
+/**
+ * Answer all program extensions in the operating system.
+ *
+ * @return an array of extensions
+ */
+public static String [] getExtensions () {
+ String [] extensions = new String [1024];
+ /* Use the character encoding for the default locale */
+ TCHAR lpName = new TCHAR (0, 1024);
+ int [] lpcName = new int [] {lpName.length ()};
+ FILETIME ft = new FILETIME ();
+ int dwIndex = 0, count = 0;
+ while (OS.RegEnumKeyEx (OS.HKEY_CLASSES_ROOT, dwIndex, lpName, lpcName, null, null, null, ft) != OS.ERROR_NO_MORE_ITEMS) {
+ String extension = lpName.toString (0, lpcName [0]);
+ lpcName [0] = lpName.length ();
+ if (extension.length () > 0 && extension.charAt (0) == '.') {
+ if (count == extensions.length) {
+ String [] newExtensions = new String [extensions.length + 1024];
+ System.arraycopy (extensions, 0, newExtensions, 0, extensions.length);
+ extensions = newExtensions;
+ }
+ extensions [count++] = extension;
+ }
+ dwIndex++;
+ }
+ if (count != extensions.length) {
+ String [] newExtension = new String [count];
+ System.arraycopy (extensions, 0, newExtension, 0, count);
+ extensions = newExtension;
+ }
+ return extensions;
+}
+
+static String getKeyValue (String string, boolean expand) {
+ /* Use the character encoding for the default locale */
+ TCHAR key = new TCHAR (0, string, true);
+ 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], (TCHAR) null, 0, null, null, lpcbData) == 0) {
+ /* Use the character encoding for the default locale */
+ TCHAR lpData = new TCHAR (0, lpcbData [0] / TCHAR.sizeof);
+ if (OS.RegQueryValueEx (phkResult [0], null, 0, null, lpData, lpcbData) == 0) {
+ if (!OS.IsWinCE && expand) {
+ int nSize = OS.ExpandEnvironmentStrings (lpData, null, 0);
+ TCHAR lpDst = new TCHAR (0, nSize);
+ OS.ExpandEnvironmentStrings (lpData, lpDst, nSize);
+ result = lpDst.toString (0, Math.max (0, nSize - 1));
+ } else {
+ int length = Math.max (0, lpData.length () - 1);
+ result = lpData.toString (0, length);
+ }
+ }
+ }
+ if (phkResult [0] != 0) OS.RegCloseKey (phkResult [0]);
+ return result;
+}
+
+static Program getProgram (String key) {
+
+ /* Name */
+ String name = getKeyValue (key, false);
+ if (name == null || name.length () == 0) return null;
+
+ /* Command */
+ String COMMAND = "\\shell\\open\\command";
+ String command = getKeyValue (key + COMMAND, true);
+ if (command == null || command.length () == 0) return null;
+
+ /* Icon */
+ String DEFAULT_ICON = "\\DefaultIcon";
+ String iconName = getKeyValue (key + DEFAULT_ICON, true);
+ 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];
+ /* Use the character encoding for the default locale */
+ TCHAR lpName = new TCHAR (0, 1024);
+ int [] lpcName = new int [] {lpName.length ()};
+ FILETIME ft = new FILETIME ();
+ int dwIndex = 0, count = 0;
+ while (OS.RegEnumKeyEx (OS.HKEY_CLASSES_ROOT, dwIndex, lpName, lpcName, null, null, null, ft) != OS.ERROR_NO_MORE_ITEMS) {
+ String path = lpName.toString (0, lpcName [0]);
+ lpcName [0] = lpName.length ();
+ Program program = getProgram (path);
+ 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;
+ }
+ dwIndex++;
+ }
+ 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);
+
+ /* Use the character encoding for the default locale */
+ int hHeap = OS.GetProcessHeap ();
+ TCHAR buffer1 = new TCHAR (0, "open", true);
+ int byteCount1 = buffer1.length () * TCHAR.sizeof;
+ int lpVerb = OS.HeapAlloc (hHeap, OS.HEAP_ZERO_MEMORY, byteCount1);
+ OS.MoveMemory (lpVerb, buffer1, byteCount1);
+ TCHAR buffer2 = new TCHAR (0, fileName, true);
+ int byteCount2 = buffer2.length () * TCHAR.sizeof;
+ int lpFile = OS.HeapAlloc (hHeap, OS.HEAP_ZERO_MEMORY, byteCount2);
+ OS.MoveMemory (lpFile, buffer2, byteCount2);
+
+ SHELLEXECUTEINFO info = new SHELLEXECUTEINFO ();
+ info.cbSize = SHELLEXECUTEINFO.sizeof;
+ info.lpVerb = lpVerb;
+ info.lpFile = lpFile;
+ info.nShow = OS.SW_SHOW;
+
+ boolean result = OS.ShellExecuteEx (info);
+
+ if (lpVerb != 0) OS.HeapFree (hHeap, 0, lpVerb);
+ if (lpFile != 0) OS.HeapFree (hHeap, 0, lpFile);
+
+ return result;
+}
+
+/**
+ * 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);
+ boolean quote = true;
+ String prefix = command, suffix = "";
+ int index = command.indexOf ("%1");
+ if (index != -1) {
+ int count=0;
+ int i=index + 2, length = command.length ();
+ while (i < length) {
+ if (command.charAt (i) == '"') count++;
+ i++;
+ }
+ quote = count % 2 == 0;
+ prefix = command.substring (0, index);
+ suffix = command.substring (index + 2, length);
+ }
+ if (quote) fileName = " \"" + fileName + "\"";
+ try {
+ Compatibility.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, may be null
+ */
+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) {};
+ }
+ /* Use the character encoding for the default locale */
+ TCHAR lpszFile = new TCHAR (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;
+}
+
+/**
+ * Returns true if the receiver and the argument represent
+ * the same program.
+ *
+ * @return true if the programs are the same
+ */
+public boolean equals(Object other) {
+ if (this == other) return true;
+ if (other instanceof Program) {
+ final Program program = (Program) other;
+ return name.equals(program.name) && command.equals(program.command)
+ && iconName.equals(program.iconName);
+ }
+ return false;
+}
+
+/**
+ * Returns a hash code suitable for this object.
+ *
+ * @return a hash code
+ */
+public int hashCode() {
+ return name.hashCode() ^ command.hashCode() ^ iconName.hashCode();
+}
+
+public String toString () {
+ return "Program {" + name + "}";
+}
+
} \ No newline at end of file
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/common/library/swt.h b/bundles/org.eclipse.swt/Eclipse SWT/common/library/swt.h
index 0bdba60b2b..b2af780054 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/common/library/swt.h
+++ b/bundles/org.eclipse.swt/Eclipse SWT/common/library/swt.h
@@ -5,24 +5,24 @@
* http://www.eclipse.org/legal/cpl-v10.html
*/
-/**
- * swt.h
- *
- * This file contains the global macro declarations for the
- * SWT library.
- *
- */
-
+/**
+ * swt.h
+ *
+ * This file contains the global macro declarations for the
+ * SWT library.
+ *
+ */
+
#ifndef INC_swt_H
#define INC_swt_H
#include "jni.h"
-/* For debugging */
+/* For debugging */
#define DEBUG_PRINTF(x)
-/*#define DEBUG_PRINTF(x) printf x; */
-
-/* define this to print out debug statements */
+/*#define DEBUG_PRINTF(x) printf x; */
+
+/* define this to print out debug statements */
/* #define DEBUG_CALL_PRINTS */
/* #define DEBUG_CHECK_NULL_EXCEPTIONS */
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
index b605ea0cea..583abe368e 100755
--- 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
@@ -1,2381 +1,2381 @@
-package org.eclipse.swt;
-
-/*
+package org.eclipse.swt;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-import org.eclipse.swt.internal.*;
-
-/**
- * This class provides access to a small number of SWT system-wide
- * methods, and in addition defines the public constants provided
- * by SWT.
- * <p>
- * By defining constants like UP and DOWN in a single class, SWT
- * can share common names and concepts at the same time minimizing
- * the number of classes, names and constants for the application
- * programmer.
- * </p><p>
- * Note that some of the constants provided by this class represent
- * optional, appearance related aspects of widgets which are available
- * either only on some window systems, or for a differing set of
- * widgets on each window system. These constants are marked
- * as <em>HINT</em>s. The set of widgets which support a particular
- * <em>HINT</em> may change from release to release, although we typically
- * will not withdraw support for a <em>HINT</em> once it is made available.
- * </p>
- */
-
-/* NOTE:
- * Good javadoc coding style is to put the values of static final
- * constants in the comments. This reinforces the fact that
- * consumers are allowed to rely on the value (and they must
- * since the values are compiled inline in their code). We
- * can <em>not</em> change the values of these constants between
- * releases.
- */
-public class SWT {
-
- /* Initialize the class */
-// static {
-// /* NOTE: the static initialization is at the end of file */
-// }
-
- /* 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;
-
- /**
- * move 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;
-
- /**
- * hardware key down event type (value is 33)
- */
- public static final int HardKeyDown = 33;
-
- /**
- * hardware key up event type (value is 34)
- */
- public static final int HardKeyUp = 34;
-
- /* 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;
-
- /**
- * style constant for menu bar behavior (value is 1&lt;&lt;1)
- * <p><b>Used By:</b><ul>
- * <li><code>Menu</code></li>
- * </ul></p>
- */
- public static final int BAR = 1 << 1;
-
- /**
- * style constant for drop down menu/list behavior (value is 1&lt;&lt;2)
- * <p><b>Used By:</b><ul>
- * <li><code>Menu</code></li>
- * <li><code>ToolItem</code></li>
- * <li><code>CoolItem</code></li>
- * <li><code>Combo</code></li>
- * </ul></p>
- */
- public static final int DROP_DOWN = 1 << 2;
-
- /**
- * style constant for pop up menu behavior (value is 1&lt;&lt;3)
- * <p><b>Used By:</b><ul>
- * <li><code>Menu</code></li>
- * </ul></p>
- */
- public static final int POP_UP = 1 << 3;
-
- /**
- * style constant for line separator behavior (value is 1&lt;&lt;1)
- * <p><b>Used By:</b><ul>
- * <li><code>Label</code></li>
- * <li><code>MenuItem</code></li>
- * <li><code>ToolItem</code></li>
- * </ul></p>
- */
- public static final int SEPARATOR = 1 << 1;
-
- /**
- * style constant for toggle button behavior (value is 1&lt;&lt;1)
- * <p><b>Used By:</b><ul>
- * <li><code>Button</code></li>
- * </ul></p>
- */
- public static final int TOGGLE = 1 << 1;
-
- /**
- * style constant for arrow button behavior (value is 1&lt;&lt;2)
- * <p><b>Used By:</b><ul>
- * <li><code>Button</code></li>
- * </ul></p>
- */
- public static final int ARROW = 1 << 2;
-
- /**
- * style constant for push button behavior (value is 1&lt;&lt;3)
- * <p><b>Used By:</b><ul>
- * <li><code>Button</code></li>
- * <li><code>MenuItem</code></li>
- * <li><code>ToolItem</code></li>
- * </ul></p>
- */
- public static final int PUSH = 1 << 3;
-
- /**
- * style constant for radio button behavior (value is 1&lt;&lt;4)
- * <p><b>Used By:</b><ul>
- * <li><code>Button</code></li>
- * <li><code>MenuItem</code></li>
- * <li><code>ToolItem</code></li>
- * </ul></p>
- */
- public static final int RADIO = 1 << 4;
-
- /**
- * style constant for check box behavior (value is 1&lt;&lt;5)
- * <p><b>Used By:</b><ul>
- * <li><code>Button</code></li>
- * <li><code>MenuItem</code></li>
- * <li><code>ToolItem</code></li>
- * <li><code>Table</code></li>
- * <li><code>Tree</code></li>
- * </ul></p>
- */
- public static final int CHECK = 1 << 5;
-
- /**
- * style constant for cascade behavior (value is 1&lt;&lt;6)
- * <p><b>Used By:</b><ul>
- * <li><code>MenuItem</code></li>
- * </ul></p>
- */
- public static final int CASCADE = 1 << 6;
-
- /**
- * style constant for multi-selection behavior in lists
- * and multiple line support on text fields (value is 1&lt;&lt;1)
- * <p><b>Used By:</b><ul>
- * <li><code>Text</code></li>
- * <li><code>List</code></li>
- * <li><code>FileDialog</code></li>
- * </ul></p>
- */
- public static final int MULTI = 1 << 1;
-
- /**
- * style constant for single selection behavior in lists
- * and single line support on text fields (value is 1&lt;&lt;2)
- * <p><b>Used By:</b><ul>
- * <li><code>Text</code></li>
- * <li><code>List</code></li>
- * <li><code>Table</code></li>
- * <li><code>Tree</code></li>
- * </ul></p>
- */
- public static final int SINGLE = 1 << 2;
-
- /**
- * style constant for read-only behavior (value is 1&lt;&lt;3)
- * <p><b>Used By:</b><ul>
- * <li><code>Combo</code></li>
- * <li><code>Text</code></li>
- * </ul></p>
- */
- public static final int READ_ONLY = 1 << 3;
-
- /**
- * style constant for automatic line wrap behavior (value is 1&lt;&lt;6)
- * <p><b>Used By:</b><ul>
- * <li><code>Label</code></li>
- * <li><code>Text</code></li>
- * <li><code>ToolBar</code></li>
- * </ul></p>
- */
- public static final int WRAP = 1 << 6;
-
- /**
- * style constant for simple (not drop down) behavior (value is 1&lt;&lt;6)
- * <p><b>Used By:</b><ul>
- * <li><code>Combo</code></li>
- * </ul></p>
- */
- public static final int SIMPLE = 1 << 6;
-
- /**
- * style constant for shadow in behavior (value is 1&lt;&lt;2)
- * <br>Note that this is a <em>HINT</em>.
- * <p><b>Used By:</b><ul>
- * <li><code>Label</code></li>
- * <li><code>Group</code></li>
- * </ul></p>
- */
- public static final int SHADOW_IN = 1 << 2;
-
- /**
- * style constant for shadow out behavior (value is 1&lt;&lt;3)
- * <br>Note that this is a <em>HINT</em>.
- * <p><b>Used By:</b><ul>
- * <li><code>Label</code></li>
- * <li><code>Group</code></li>
- * <li><code>ToolBar</code></li>
- * </ul></p>
- */
- public static final int SHADOW_OUT = 1 << 3;
-
- /**
- * style constant for shadow etched in behavior (value is 1&lt;&lt;4)
- * <br>Note that this is a <em>HINT</em>. It is ignored on all platforms except Motif.
- * <p><b>Used By:</b><ul>
- * <li><code>Group</code></li>
- * </ul></p>
- */
- public static final int SHADOW_ETCHED_IN = 1 << 4;
-
- /**
- * style constant for shadow etched out behavior (value is 1&lt;&lt;6)
- * <br>Note that this is a <em>HINT</em>. It is ignored on all platforms except Motif.
- * <p><b>Used By:</b><ul>
- * <li><code>Group</code></li>
- * </ul></p>
- */
- public static final int SHADOW_ETCHED_OUT = 1 << 6;
-
- /**
- * style constant for no shadow behavior (value is 1&lt;&lt;5)
- * <br>Note that this is a <em>HINT</em>.
- * <p><b>Used By:</b><ul>
- * <li><code>Label</code></li>
- * <li><code>Group</code></li>
- * </ul></p>
- */
- public static final int SHADOW_NONE = 1 << 5;
-
- /**
- * style constant for progress bar behavior (value is 1&lt;&lt;1)
- * <p><b>Used By:</b><ul>
- * <li><code>ProgressBar</code></li>
- * </ul></p>
- */
- public static final int INDETERMINATE = 1 << 1;
-
- /**
- * style constant for tool window behavior (value is 1&lt;&lt;2)
- * <p>
- * A tool window is a window intended to be used as a floating toolbar.
- * It typically has a title bar that is shorter than a normal title bar,
- * and the window title is typically drawn using a smaller font.
- * <br>Note that this is a <em>HINT</em>.
- * </p><p><b>Used By:</b><ul>
- * <li><code>Decorations</code> and subclasses</li>
- * </ul></p>
- */
- public static final int TOOL = 1 << 2;
-
- /**
- * style constant to ensure no trimmings are used (value is 1&lt;&lt;3)
- * <br>Note that this overrides all other trim styles.
- * <p><b>Used By:</b><ul>
- * <li><code>Decorations</code> and subclasses</li>
- * </ul></p>
- */
- public static final int NO_TRIM = 1 << 3;
-
- /**
- * style constant for resize box trim (value is 1&lt;&lt;4)
- * <p><b>Used By:</b><ul>
- * <li><code>Decorations</code> and subclasses</li>
- * <li><code>Tracker</code></li>
- * </ul></p>
- */
- public static final int RESIZE = 1 << 4;
-
- /**
- * style constant for title area trim (value is 1&lt;&lt;5)
- * <p><b>Used By:</b><ul>
- * <li><code>Decorations</code> and subclasses</li>
- * </ul></p>
- */
- public static final int TITLE = 1 << 5;
-
- /**
- * style constant for close box trim (value is 1&lt;&lt;6,
- * since we do not distinguish between CLOSE style and MENU style)
- * <p><b>Used By:</b><ul>
- * <li><code>Decorations</code> and subclasses</li>
- * </ul></p>
- */
- public static final int CLOSE = 1 << 6;
-
- /**
- * style constant for shell menu trim (value is 1&lt;&lt;6,
- * since we do not distinguish between CLOSE style and MENU style)
- * <p><b>Used By:</b><ul>
- * <li><code>Decorations</code> and subclasses</li>
- * </ul></p>
- */
- public static final int MENU = CLOSE;
-
- /**
- * style constant for minimize box trim (value is 1&lt;&lt;7)
- * <p><b>Used By:</b><ul>
- * <li><code>Decorations</code> and subclasses</li>
- * </ul></p>
- */
- public static final int MIN = 1 << 7;
-
- /**
- * style constant for maximize box trim (value is 1&lt;&lt;10)
- * <p><b>Used By:</b><ul>
- * <li><code>Decorations</code> and subclasses</li>
- * </ul></p>
- */
- public static final int MAX = 1 << 10;
-
- /**
- * style constant for horizontal scrollbar behavior (value is 1&lt;&lt;8)
- * <p><b>Used By:</b><ul>
- * <li><code>Scrollable</code> and subclasses</li>
- * </ul></p>
- */
- public static final int H_SCROLL = 1 << 8;
-
- /**
- * style constant for vertical scrollbar behavior (value is 1&lt;&lt;9)
- * <p><b>Used By:</b><ul>
- * <li><code>Scrollable</code> and subclasses</li>
- * </ul></p>
- */
- public static final int V_SCROLL = 1 << 9;
-
- /**
- * style constant for bordered behavior (value is 1&lt;&lt;11)
- * <br>Note that this is a <em>HINT</em>.
- * <p><b>Used By:</b><ul>
- * <li><code>Control</code> and subclasses</li>
- * </ul></p>
- */
- public static final int BORDER = 1 << 11;
-
- /**
- * style constant indicating that the window manager should clip
- * a widget's children with respect to its viewable area. (value is 1&lt;&lt;12)
- * <br>Note that this is a <em>HINT</em>.
- * <p><b>Used By:</b><ul>
- * <li><code>Control</code> and subclasses</li>
- * </ul></p>
- */
- public static final int CLIP_CHILDREN = 1 << 12;
-
- /**
- * style constant indicating that the window manager should clip
- * a widget's siblings with respect to its viewable area. (value is 1&lt;&lt;13)
- * <br>Note that this is a <em>HINT</em>.
- * <p><b>Used By:</b><ul>
- * <li><code>Control</code> and subclasses</li>
- * </ul></p>
- */
- public static final int CLIP_SIBLINGS = 1 << 13;
-
- /**
- * style constant for always on top behavior (value is 1&lt;&lt;14)
- * <br>Note that this is a <em>HINT</em>.
- * <p><b>Used By:</b><ul>
- * <li><code>Decorations</code>and subclasses</li>
- * </ul></p>
- */
- public static final int ON_TOP = 1 << 14;
-
- /**
- * trim style convenience constant for the most common top level shell appearance
- * (value is CLOSE|TITLE|MIN|MAX|RESIZE)
- * <p><b>Used By:</b><ul>
- * <li><code>Shell</code></li>
- * </ul></p>
- */
- public static final int SHELL_TRIM = CLOSE | TITLE | MIN | MAX | RESIZE;
-
- /**
- * trim style convenience constant for the most common dialog shell appearance
- * (value is CLOSE|TITLE|BORDER)
- * <p><b>Used By:</b><ul>
- * <li><code>Shell</code></li>
- * </ul></p>
- */
- public static final int DIALOG_TRIM = TITLE | CLOSE | BORDER;
-
- /**
- * style constant for modeless behavior (value is 0)
- * <br>Note that this is a <em>HINT</em>.
- * <p><b>Used By:</b><ul>
- * <li><code>Dialog</code></li>
- * <li><code>Shell</code></li>
- * </ul></p>
- */
- public static final int MODELESS = 0;
-
- /**
- * style constant for primary modal behavior (value is 1&lt;&lt;15)
- * <br>Note that this is a <em>HINT</em>.
- * <p><b>Used By:</b><ul>
- * <li><code>Dialog</code></li>
- * <li><code>Shell</code></li>
- * </ul></p>
- */
- public static final int PRIMARY_MODAL = 1 << 15;
-
- /**
- * style constant for application modal behavior (value is 1&lt;&lt;16)
- * <br>Note that this is a <em>HINT</em>.
- * <p><b>Used By:</b><ul>
- * <li><code>Dialog</code></li>
- * <li><code>Shell</code></li>
- * </ul></p>
- */
- public static final int APPLICATION_MODAL = 1 << 16;
-
- /**
- * style constant for system modal behavior (value is 1&lt;&lt;17)
- * <br>Note that this is a <em>HINT</em>.
- * <p><b>Used By:</b><ul>
- * <li><code>Dialog</code></li>
- * <li><code>Shell</code></li>
- * </ul></p>
- */
- public static final int SYSTEM_MODAL = 1 << 17;
-
- /**
- * style constant for selection hiding behavior. (value is 1&lt;&lt;15)
- * <br>Note that this is a <em>HINT</em>.
- * <p><b>Used By:</b><ul>
- * <li><code>Table</code></li>
- * </ul></p>
- */
- public static final int HIDE_SELECTION = 1 << 15;
-
- /**
- * style constant for full row selection behavior. (value is 1&lt;&lt;16)
- * <br>Note that this is a <em>HINT</em>.
- * <p><b>Used By:</b><ul>
- * <li><code>Table</code></li>
- * </ul></p>
- */
- public static final int FULL_SELECTION = 1 << 16;
-
- /**
- * style constant for flat appearance. (value is 1&lt;&lt;23)
- * <br>Note that this is a <em>HINT</em>.
- * <p><b>Used By:</b><ul>
- * <li><code>Button</code></li>
- * <li><code>ToolBar</code></li>
- * </ul></p>
- */
- public static final int FLAT = 1 << 23;
-
- /**
- * style constant for flat appearance. (value is 1&lt;&lt;16)
- * <br>Note that this is a <em>HINT</em>.
- * <p><b>Used By:</b><ul>
- * <li><code>ProgressBar</code></li>
- * </ul></p>
- */
- public static final int SMOOTH = 1 << 16;
-
- /**
- * style constant for no background behavior (value is 1&lt;&lt;18)
- * <p>
- * By default, before a widget paints, the client area is filled with the current background color.
- * When this style is specified, the background is not filled, and the application is responsible
- * for filling every pixel of the client area.
- * This style might be used as an alternative to "double-buffering" in order to reduce flicker.
- * This style does not mean "transparent" - widgets that are obscured will not draw through.
- * </p><p><b>Used By:</b><ul>
- * <li><code>Composite</code></li>
- * </ul></p>
- */
- public static final int NO_BACKGROUND = 1 << 18;
-
- /**
- * style constant for does not take focus behavior (value is 1&lt;&lt;19)
- * <br>Note that this is a <em>HINT</em>.
- * <p><b>Used By:</b><ul>
- * <li><code>Composite</code></li>
- * </ul></p>
- */
- public static final int NO_FOCUS = 1 << 19;
-
- /**
- * style constant for no redraw on resize behavior (value is 1&lt;&lt;20)
- * <p>
- * This style stops the entire client area from being invalidated when the size
- * of the Canvas changes. Specifically, when the size of the Canvas gets smaller,
- * the SWT.Paint event is not sent. When it gets bigger, an SWT.Paint event is
- * sent with a GC clipped to only the new areas to be painted. Without this
- * style, the entire client area will be repainted.
- * </p><p><b>Used By:</b><ul>
- * <li><code>Composite</code></li>
- * </ul></p>
- */
- public static final int NO_REDRAW_RESIZE = 1 << 20;
-
- /**
- * style constant for no paint event merging behavior (value is 1&lt;&lt;21)
- * <p><b>Used By:</b><ul>
- * <li><code>Composite</code></li>
- * </ul></p>
- */
- public static final int NO_MERGE_PAINTS = 1 << 21;
-
- /**
- * style constant for preventing child radio group behavior (value is 1&lt;&lt;22)
- * <p><b>Used By:</b><ul>
- * <li><code>Composite</code></li>
- * </ul></p>
- */
- public static final int NO_RADIO_GROUP = 1 << 22;
-
- /**
- * style constant for left to right orientation (value is 1&lt;&lt;25)
- * <p>
- * When orientation is not explicitly specified, orientation is
- * inherited. This means that children will be assigned the
- * orientation of their parent. To override this behavior and
- * force an orientation for a child, explicitly set the orientation
- * of the child when that child is created.
- * </p>
- * <p><b>Used By:</b><ul>
- * <li><code>Control</code></li>
- * <li><code>Menu</code></li>
- * </ul></p>
- *
- * <p>
- * <b>NOTE:</b> This API element is part of an interim API that is still under
- * development and is expected to change significantly before reaching stability.
- * It is being made available at this early stage to solicit feedback from
- * pioneering adopters on the understanding that any code that uses this API
- * will almost certainly be broken (repeatedly) as the API evolves.
- * </p>
- *
- * @since 2.1
- */
- public static final int LEFT_TO_RIGHT = 1 << 25;
-
- /**
- * style constant for right to left orientation (value is 1&lt;&lt;26)
- * <p>
- * When orientation is not explicitly specified, orientation is
- * inherited. This means that children will be assigned the
- * orientation of their parent. To override this behavior and
- * force an orientation for a child, explicitly set the orientation
- * of the child when that child is created.
- * </p>
- * <p><b>Used By:</b><ul>
- * <li><code>Control</code></li>
- * <li><code>Menu</code></li>
- * </ul></p>
- *
- * <p>
- * <b>NOTE:</b> This API element is part of an interim API that is still under
- * development and is expected to change significantly before reaching stability.
- * It is being made available at this early stage to solicit feedback from
- * pioneering adopters on the understanding that any code that uses this API
- * will almost certainly be broken (repeatedly) as the API evolves.
- * </p>
- *
- * @since 2.1
- */
- public static final int RIGHT_TO_LEFT = 1 << 26;
-
- /**
- * style constant to indicate coordinate mirroring (value is 1&lt;&lt;27)
- * <p><b>Used By:</b><ul>
- * <li><code>Control</code></li>
- * <li><code>Menu</code></li>
- * </ul></p>
- *
- * <p>
- * <b>NOTE:</b> This API element is part of an interim API that is still under
- * development and is expected to change significantly before reaching stability.
- * It is being made available at this early stage to solicit feedback from
- * pioneering adopters on the understanding that any code that uses this API
- * will almost certainly be broken (repeatedly) as the API evolves.
- * </p>
- *
- * @since 2.1
- */
- public static final int MIRRORED = 1 << 27;
-
- /**
- * style constant for align up behavior (value is 1&lt;&lt;7,
- * since align UP and align TOP are considered the same)
- * <p><b>Used By:</b><ul>
- * <li><code>Button</code> with <code>ARROW</code> style</li>
- * <li><code>Tracker</code></li>
- * </ul></p>
- */
- public static final int UP = 1 << 7;
-
- /**
- * style constant for align top behavior (value is 1&lt;&lt;7,
- * since align UP and align TOP are considered the same)
- * <p><b>Used By:</b><ul>
- * <li><code>FormAttachment</code> in a <code>FormLayout</code></li>
- * </ul></p>
- */
- public static final int TOP = UP;
-
- /**
- * style constant for align down behavior (value is 1&lt;&lt;10,
- * since align DOWN and align BOTTOM are considered the same)
- * <p><b>Used By:</b><ul>
- * <li><code>Button</code> with <code>ARROW</code> style</li>
- * <li><code>Tracker</code></li>
- * </ul></p>
- */
- public static final int DOWN = 1 << 10;
-
- /**
- * style constant for align bottom behavior (value is 1&lt;&lt;10,
- * since align DOWN and align BOTTOM are considered the same)
- * <p><b>Used By:</b><ul>
- * <li><code>FormAttachment</code> in a <code>FormLayout</code></li>
- * </ul></p>
- */
- public static final int BOTTOM = DOWN;
-
- /**
- * style constant for align left behavior (value is 1&lt;&lt;14)
- * <p><b>Used By:</b><ul>
- * <li><code>Button</code></li>
- * <li><code>Label</code></li>
- * <li><code>TableColumn</code></li>
- * <li><code>Tracker</code></li>
- * <li><code>FormAttachment</code> in a <code>FormLayout</code></li>
- * </ul></p>
- */
- public static final int LEFT = 1 << 14;
-
- /**
- * style constant for align right behavior (value is 1&lt;&lt;17)
- * <p><b>Used By:</b><ul>
- * <li><code>Button</code></li>
- * <li><code>Label</code></li>
- * <li><code>TableColumn</code></li>
- * <li><code>Tracker</code></li>
- * <li><code>FormAttachment</code> in a <code>FormLayout</code></li>
- * </ul></p>
- */
- public static final int RIGHT = 1 << 17;
-
- /**
- * style constant for align center behavior (value is 1&lt;&lt;24)
- * <p><b>Used By:</b><ul>
- * <li><code>Button</code></li>
- * <li><code>Label</code></li>
- * <li><code>TableColumn</code></li>
- * <li><code>FormAttachment</code> in a <code>FormLayout</code></li>
- * </ul></p>
- */
- public static final int CENTER = 1 << 24;
-
- /**
- * style constant for horizontal alignment or orientation behavior (value is 1&lt;&lt;8)
- * <p><b>Used By:</b><ul>
- * <li><code>Label</code></li>
- * <li><code>ProgressBar</code></li>
- * <li><code>Sash</code></li>
- * <li><code>Scale</code></li>
- * <li><code>ScrollBar</code></li>
- * <li><code>Slider</code></li>
- * <li><code>ToolBar</code></li>
- * <li><code>FillLayout</code> type</li>
- * <li><code>RowLayout</code> type</li>
- * </ul></p>
- */
- public static final int HORIZONTAL = 1 << 8;
-
- /**
- * style constant for vertical alignment or orientation behavior (value is 1&lt;&lt;9)
- * <p><b>Used By:</b><ul>
- * <li><code>Label</code></li>
- * <li><code>ProgressBar</code></li>
- * <li><code>Sash</code></li>
- * <li><code>Scale</code></li>
- * <li><code>ScrollBar</code></li>
- * <li><code>Slider</code></li>
- * <li><code>ToolBar</code></li>
- * <li><code>FillLayout</code> type</li>
- * <li><code>RowLayout</code> type</li>
- * </ul></p>
- */
- public static final int VERTICAL = 1 << 9;
-
- /**
- * Input Method Editor style constant for double byte
- * input behavior (value is 1&lt;&lt;1)
- */
- public static final int DBCS = 1 << 1;
-
- /**
- * Input Method Editor style constant for alpha
- * input behavior (value is 1&lt;&lt;2)
- */
- public static final int ALPHA = 1 << 2;
-
- /**
- * Input Method Editor style constant for native
- * input behavior (value is 1&lt;&lt;3)
- */
- public static final int NATIVE = 1 << 3;
-
- /**
- * Input Method Editor style constant for phonetic
- * input behavior (value is 1&lt;&lt;4)
- */
- public static final int PHONETIC = 1 << 4;
-
- /**
- * Input Method Editor style constant for romanicized
- * input behavior (value is 1&lt;&lt;5)
- */
- public static final int ROMAN = 1 << 5;
-
- /**
- * ASCII character convenience constant for the backspace character
- * (value is the <code>char</code> '\b')
- */
- public static final char BS = '\b';
-
- /**
- * ASCII character convenience constant for the carriage return character
- * (value is the <code>char</code> '\r')
- */
- public static final char CR = '\r';
-
- /**
- * ASCII character convenience constant for the delete character
- * (value is the <code>char</code> with value 127)
- */
- public static final char DEL = 0x7F;
-
- /**
- * ASCII character convenience constant for the escape character
- * (value is the <code>char</code> with value 27)
- */
- public static final char ESC = 0x1B;
-
- /**
- * ASCII character convenience constant for the line feed character
- * (value is the <code>char</code> '\n')
- */
- public static final char LF = '\n';
-
- /**
- * ASCII character convenience constant for the tab character
- * (value is the <code>char</code> '\t')
- *
- * @since 2.1
- */
- public static final char TAB = '\t';
-
- /**
- * keyboard and/or mouse event mask indicating that the ALT key
- * was pushed on the keyboard when the event was generated
- * (value is 1&lt;&lt;16)
- */
- public static final int ALT = 1 << 16;
-
- /**
- * keyboard and/or mouse event mask indicating that the SHIFT key
- * was pushed on the keyboard when the event was generated
- * (value is 1&lt;&lt;17)
- */
- public static final int SHIFT = 1 << 17;
-
- /**
- * keyboard and/or mouse event mask indicating that the CTRL key
- * was pushed on the keyboard when the event was generated
- * (value is 1&lt;&lt;18)
- */
- public static final int CTRL = 1 << 18;
-
- /**
- * keyboard and/or mouse event mask indicating that the CTRL key
- * was pushed on the keyboard when the event was generated. This
- * is a synonym for CTRL (value is 1&lt;&lt;18)
- */
- public static final int CONTROL = CTRL;
-
- /**
- * keyboard and/or mouse event mask indicating that the COMMAND key
- * was pushed on the keyboard when the event was generated
- * (value is 1&lt;&lt;22)
- *
- * @since 2.1
- */
- public static final int COMMAND = 1 << 22;
-
- /**
- * keyboard and/or mouse event mask indicating all possible
- * keyboard modifiers. To allow for the future, this mask
- * is intended to be used in place of code that references
- * each individual keyboard mask. For example, the following
- * expression will determine whether any modifer is pressed
- * and will continue to work as new modifier masks are added.
- *
- * <code>(stateMask & SWT.MODIFIER_MASK) != 0</code>.
- *
- * @since 2.1
- */
- public static final int MODIFIER_MASK;
-
- /**
- * keyboard and/or mouse event mask indicating that mouse button one
- * was pushed when the event was generated. (value is 1&lt;&lt;19)
- */
- public static final int BUTTON1 = 1 << 19;
-
- /**
- * keyboard and/or mouse event mask indicating that mouse button two
- * was pushed when the event was generated. (value is 1&lt;&lt;20)
- */
- public static final int BUTTON2 = 1 << 20;
-
- /**
- * keyboard and/or mouse event mask indicating that mouse button three
- * was pushed when the event was generated. (value is 1&lt;&lt;21)
- */
- public static final int BUTTON3 = 1 << 21;
-
- /**
- * keyboard and/or mouse event mask indicating all possible
- * mouse buttons. To allow for the future, this mask
- * is intended to be used in place of code that references
- * each individual button mask. For example, the following
- * expression will determine whether any button is pressed
- * and will continue to work as new button masks are added.
- *
- * <code>(stateMask & SWT.BUTTON_MASK) != 0</code>.
- *
- * @since 2.1
- */
- public static final int BUTTON_MASK;
-
- /**
- * keyboard and/or mouse event mask indicating that the MOD1 key
- * was pushed on the keyboard when the event was generated. This
- * is the primary keyboard modifier for the platform.
- *
- * @since 2.1
- */
- public static final int MOD1;
-
- /**
- * keyboard and/or mouse event mask indicating that the MOD2 key
- * was pushed on the keyboard when the event was generated. This
- * is the secondary keyboard modifier for the platform.
- *
- * @since 2.1
- */
- public static final int MOD2;
-
- /**
- * keyboard and/or mouse event mask indicating that the MOD3 key
- * was pushed on the keyboard when the event was generated.
- *
- * @since 2.1
- */
- public static final int MOD3;
-
- /**
- * keyboard and/or mouse event mask indicating that the MOD4 key
- * was pushed on the keyboard when the event was generated.
- *
- * @since 2.1
- */
- public static final int MOD4;
-
- /**
- * accelerator constant used to differentiate a key code from a
- * unicode character. If this bit is set, then the key stroke
- * portion of an accelerator represents a key code. If this bit
- * is not set, then the key stroke portion of an accelerator is
- * a unicode character.
- *
- * The following expression is false:
- *
- * <code>((SWT.MOD1 | SWT.MOD2 | 'T') & SWT.KEYCODE_BIT) != 0</code>.
- *
- * The following expression is true:
- *
- * <code>((SWT.MOD3 | SWT.F2) & SWT.KEYCODE_BIT) != 0</code>.
- *
- * (value is (1&lt;&lt;24))
- *
- * @since 2.1
- */
- public static final int KEYCODE_BIT = (1 << 24);
-
- /**
- * accelerator constant used to extract the key stroke portion of
- * an accelerator. The key stroke may be a key code or a unicode
- * value. If the key stroke is a key code <code>KEYCODE_BIT</code>
- * will be set.
- *
- * @since 2.1
- */
- public static final int KEY_MASK = KEYCODE_BIT + 0xFFFF;
-
- /**
- * keyboard event constant representing the UP ARROW key
- * (value is (1&lt;&lt;24)+1)
- */
- public static final int ARROW_UP = KEYCODE_BIT + 1;
-
- /**
- * keyboard event constant representing the DOWN ARROW key
- * (value is (1&lt;&lt;24)+2)
- */
- public static final int ARROW_DOWN = KEYCODE_BIT + 2;
-
- /**
- * keyboard event constant representing the LEFT ARROW key
- * (value is (1&lt;&lt;24)+3)
- */
- public static final int ARROW_LEFT = KEYCODE_BIT + 3;
-
- /**
- * keyboard event constant representing the RIGHT ARROW key
- * (value is (1&lt;&lt;24)+4)
- */
- public static final int ARROW_RIGHT = KEYCODE_BIT + 4;
-
- /**
- * keyboard event constant representing the PAGE UP key
- * (value is (1&lt;&lt;24)+5)
- */
- public static final int PAGE_UP = KEYCODE_BIT + 5;
-
- /**
- * keyboard event constant representing the PAGE DOWN key
- * (value is (1&lt;&lt;24)+6)
- */
- public static final int PAGE_DOWN = KEYCODE_BIT + 6;
-
- /**
- * keyboard event constant representing the HOME key
- * (value is (1&lt;&lt;24)+7)
- */
- public static final int HOME = KEYCODE_BIT + 7;
-
- /**
- * keyboard event constant representing the END key
- * (value is (1&lt;&lt;24)+8)
- */
- public static final int END = KEYCODE_BIT + 8;
-
- /**
- * keyboard event constant representing the INSERT key
- * (value is (1&lt;&lt;24)+9)
- */
- public static final int INSERT = KEYCODE_BIT + 9;
-
- /**
- * keyboard event constant representing the F1 key
- * (value is (1&lt;&lt;24)+10)
- */
- public static final int F1 = KEYCODE_BIT + 10;
-
- /**
- * keyboard event constant representing the F2 key
- * (value is (1&lt;&lt;24)+11)
- */
- public static final int F2 = KEYCODE_BIT + 11;
-
- /**
- * keyboard event constant representing the F3 key
- * (value is (1&lt;&lt;24)+12)
- */
- public static final int F3 = KEYCODE_BIT + 12;
-
- /**
- * keyboard event constant representing the F4 key
- * (value is (1&lt;&lt;24)+13)
- */
- public static final int F4 = KEYCODE_BIT + 13;
-
- /**
- * keyboard event constant representing the F5 key
- * (value is (1&lt;&lt;24)+14)
- */
- public static final int F5 = KEYCODE_BIT + 14;
-
- /**
- * keyboard event constant representing the F6 key
- * (value is (1&lt;&lt;24)+15)
- */
- public static final int F6 = KEYCODE_BIT + 15;
-
- /**
- * keyboard event constant representing the F7 key
- * (value is (1&lt;&lt;24)+16)
- */
- public static final int F7 = KEYCODE_BIT + 16;
-
- /**
- * keyboard event constant representing the F8 key
- * (value is (1&lt;&lt;24)+17)
- */
- public static final int F8 = KEYCODE_BIT + 17;
-
- /**
- * keyboard event constant representing the F9 key
- * (value is (1&lt;&lt;24)+18)
- */
- public static final int F9 = KEYCODE_BIT + 18;
-
- /**
- * keyboard event constant representing the F10 key
- * (value is (1&lt;&lt;24)+19)
- */
- public static final int F10 = KEYCODE_BIT + 19;
-
- /**
- * keyboard event constant representing the F11 key
- * (value is (1&lt;&lt;24)+20)
- */
- public static final int F11 = KEYCODE_BIT + 20;
-
- /**
- * keyboard event constant representing the F12 key
- * (value is (1&lt;&lt;24)+21)
- */
- public static final int F12 = KEYCODE_BIT + 21;
-
- /**
- * <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&lt;&lt;1)
- */
- public static final int ICON_INFORMATION = 1 << 1;
-
- /**
- * <code>MessageBox</code> style constant for question icon
- * behavior (value is 1&lt;&lt;2)
- */
- public static final int ICON_QUESTION = 1 << 2;
-
- /**
- * <code>MessageBox</code> style constant for warning icon
- * behavior (value is 1&lt;&lt;3)
- */
- public static final int ICON_WARNING = 1 << 3;
-
- /**
- * <code>MessageBox</code> style constant for "working" icon
- * behavior (value is 1&lt;&lt;4)
- */
- 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&lt;&lt;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&lt;&lt;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&lt;&lt;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&lt;&lt;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&lt;&lt;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&lt;&lt;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&lt;&lt;11)
- */
- public static final int IGNORE = 1 << 11;
-
- /**
- * <code>FileDialog</code> style constant for open file dialog behavior
- * (value is 1&lt;&lt;12)
- */
- public static final int OPEN = 1 << 12;
-
- /**
- * <code>FileDialog</code> style constant for save file dialog behavior
- * (value is 1&lt;&lt;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;
-
- /**
- * draw constant indicating whether the drawing operation
- * should fill the background (value is 1&lt;&lt;0)
- */
- public static final int DRAW_TRANSPARENT = 1 << 0;
-
- /**
- * draw constant indicating whether the string drawing operation
- * should handle line-delimeters (value is 1&lt;&lt;1)
- */
- public static final int DRAW_DELIMITER = 1 << 1;
-
- /**
- * draw constant indicating whether the string drawing operation
- * should expand TAB characters (value is 1&lt;&lt;2)
- */
- public static final int DRAW_TAB = 1 << 2;
-
- /**
- * draw constant indicating whether the string drawing operation
- * should handle mnemonics (value is 1&lt;&lt;3)
- */
- public static final int DRAW_MNEMONIC = 1 << 3;
-
- /**
- * 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 org.eclipse.swt.widgets.Widget#checkSubclass
- */
- public static final int ERROR_INVALID_SUBCLASS = 43;
-
- /**
- * SWT error constant indicating that an attempt was made to
- * invoke an SWT operation using a graphics object which had
- * already been disposed.
- * (value is 44)
- */
- public static final int ERROR_GRAPHIC_DISPOSED = 44;
-
- /**
- * SWT error constant indicating that an attempt was made to
- * invoke an SWT operation using a device which had already
- * been disposed.
- * (value is 45)
- */
- public static final int ERROR_DEVICE_DISPOSED = 45;
-
- /**
- * SWT error constant indicating that an exception happened
- * when executing a runnable.
- * (value is 46)
- */
- public static final int ERROR_FAILED_EXEC = 46;
-
- /**
- * SWT error constant indicating that an unsatisfied link
- * error occured while attempting to load a library.
- * (value is 47)
- */
- public static final int ERROR_FAILED_LOAD_LIBRARY = 47;
-
- /**
- * traversal event detail field value indicating that no
- * traversal action should be taken.
- * (value is 0)
- */
- public static final int TRAVERSE_NONE = 0;
-
- /**
- * traversal event detail field value indicating that the
- * key which designates that a dialog should be cancelled was
- * pressed; typically, this is the ESC key
- * (value is 1&lt;&lt;1)
- */
- public static final int TRAVERSE_ESCAPE = 1 << 1;
-
- /**
- * traversal event detail field value indicating that the
- * key which activates the default button in a dialog was
- * pressed; typically, this is the ENTER key
- * (value is 1&lt;&lt;2)
- */
- public static final int TRAVERSE_RETURN = 1 << 2;
-
- /**
- * traversal event detail field value indicating that the
- * key which designates that focus should be given to the
- * previous tab group was pressed; typically, this is the
- * SHIFT-TAB key sequence
- * (value is 1&lt;&lt;3)
- */
- public static final int TRAVERSE_TAB_PREVIOUS = 1 << 3;
-
- /**
- * traversal event detail field value indicating that the
- * key which designates that focus should be given to the
- * next tab group was pressed; typically, this is the
- * TAB key
- * (value is 1&lt;&lt;4)
- */
- public static final int TRAVERSE_TAB_NEXT = 1 << 4;
-
- /**
- * traversal event detail field value indicating that the
- * key which designates that focus should be given to the
- * previous tab item was pressed; typically, this is either
- * the LEFT-ARROW or UP-ARROW keys
- * (value is 1&lt;&lt;5)
- */
- public static final int TRAVERSE_ARROW_PREVIOUS = 1 << 5;
-
- /**
- * traversal event detail field value indicating that the
- * key which designates that focus should be given to the
- * previous tab item was pressed; typically, this is either
- * the RIGHT-ARROW or DOWN-ARROW keys
- * (value is 1&lt;&lt;6)
- */
- public static final int TRAVERSE_ARROW_NEXT = 1 << 6;
-
- /**
- * traversal event detail field value indicating that a
- * mnemonic key sequence was pressed
- * (value is 1&lt;&lt;7)
- */
- public static final int TRAVERSE_MNEMONIC = 1 << 7;
-
- /**
- * traversal event detail field value indicating that the
- * key which designates that the previous page of a multi-page
- * window should be shown was pressed; typically, this
- * is the CTRL-PAGEUP key sequence
- * (value is 1&lt;&lt;8)
- */
- public static final int TRAVERSE_PAGE_PREVIOUS = 1 << 8;
-
- /**
- * traversal event detail field value indicating that the
- * key which designates that the next page of a multi-page
- * window should be shown was pressed; typically, this
- * is the CTRL-PAGEDOWN key sequence
- * (value is 1&lt;&lt;9)
- */
- public static final int TRAVERSE_PAGE_NEXT = 1 << 9;
-
- /**
- * 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&lt;&lt;0)
- */
- public static final int BOLD = 1 << 0;
-
- /**
- * font style constant indicating an italic font
- * (value is 1&lt;&lt;1)
- */
- public static final int ITALIC = 1 << 1;
-
- /**
- * system arrow cursor (value is 0)
- */
- public static final int CURSOR_ARROW = 0;
-
- /**
- * system wait cursor (value is 1)
- */
- public static final int CURSOR_WAIT = 1;
-
- /**
- * system cross hair cursor (value is 2)
- */
- public static final int CURSOR_CROSS = 2;
-
- /**
- * system app startup cursor (value is 3)
- */
- public static final int CURSOR_APPSTARTING = 3;
-
- /**
- * system help cursor (value is 4)
- */
- public static final int CURSOR_HELP = 4;
-
- /**
- * system resize all directions cursor (value is 5)
- */
- public static final int CURSOR_SIZEALL = 5;
-
- /**
- * system resize north-east-south-west cursor (value is 6)
- */
- public static final int CURSOR_SIZENESW = 6;
-
- /**
- * system resize north-south cursor (value is 7)
- */
- public static final int CURSOR_SIZENS = 7;
-
- /**
- * system resize north-west-south-east cursor (value is 8)
- */
- public static final int CURSOR_SIZENWSE = 8;
-
- /**
- * system resize west-east cursor (value is 9)
- */
- public static final int CURSOR_SIZEWE = 9;
-
- /**
- * system resize north cursor (value is 10)
- */
- public static final int CURSOR_SIZEN = 10;
-
- /**
- * system resize south cursor (value is 11)
- */
- public static final int CURSOR_SIZES = 11;
-
- /**
- * system resize east cursor (value is 12)
- */
- public static final int CURSOR_SIZEE = 12;
-
- /**
- * system resize west cursor (value is 13)
- */
- public static final int CURSOR_SIZEW = 13;
-
- /**
- * system resize north-east cursor (value is 14)
- */
- public static final int CURSOR_SIZENE = 14;
-
- /**
- * system resize south-east cursor (value is 15)
- */
- public static final int CURSOR_SIZESE = 15;
-
- /**
- * system resize south-west cursor (value is 16)
- */
- public static final int CURSOR_SIZESW = 16;
-
- /**
- * system resize north-west cursor (value is 17)
- */
- public static final int CURSOR_SIZENW = 17;
-
- /**
- * system up arrow cursor (value is 18)
- */
- public static final int CURSOR_UPARROW = 18;
-
- /**
- * system i-beam cursor (value is 19)
- */
- public static final int CURSOR_IBEAM = 19;
-
- /**
- * system "not allowed" cursor (value is 20)
- */
- public static final int CURSOR_NO = 20;
-
- /**
- * system hand cursor (value is 21)
- */
- public static final int CURSOR_HAND = 21;
-
- /**
- * line drawing style for 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 alpha transparency information (value is 1&lt;&lt;0)
- */
- public static final int TRANSPARENCY_ALPHA = 1 << 0;
-
- /**
- * image transparency constant indicating that the image
- * contains a transparency mask (value is 1&lt;&lt;1)
- */
- public static final int TRANSPARENCY_MASK = 1 << 1;
-
- /**
- * image transparency constant indicating that the image
- * contains a transparent pixel (value is 1&lt;&lt;2)
- */
- public static final int TRANSPARENCY_PIXEL = 1 << 2;
-
-/**
- * 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";
- case ERROR_FAILED_EXEC: return "Failed to execute runnable";
- case ERROR_FAILED_LOAD_LIBRARY: return "Unable to load library";
- }
- return "Unknown error";
-}
-
-/**
- * Returns the NLS'ed message for the given argument.
- *
- * @param key the key to look up
- * @return the message for the given key
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the key is null</li>
- * </ul>
- */
-public static String getMessage(String key) {
- return Compatibility.getMessage(key);
-}
-
-/**
- * Returns the SWT platform name.
- * Examples: "win32", "motif", "gtk", "photon", "carbon"
- *
- * @return the SWT platform name
- */
-public static String getPlatform () {
- return Callback.getPlatform ();
-}
-
-/**
- * Returns the SWT version number as an integer.
- * Example: "SWT051" == 51
- *
- * @return the SWT version number
- */
-public static int getVersion () {
- return Library.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_FAILED_EXEC:
- 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_FAILED_LOAD_LIBRARY:
- 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;
-}
-
-static {
- /*
- * These values represent bit masks that may need to
- * expand in the future. Therefore they are not initialized
- * in the declaration to stop the compiler from inlining.
- */
- BUTTON_MASK = BUTTON1 | BUTTON2 | BUTTON3;
- MODIFIER_MASK = ALT | SHIFT | CTRL | COMMAND;
-
- /*
- * These values can be different on different platforms.
- * Therefore they are not initialized in the declaration
- * to stop the compiler from inlining.
- */
- String platform = getPlatform ();
- if ("carbon".equals (platform)) {
- MOD1 = COMMAND;
- MOD2 = SHIFT;
- MOD3 = ALT;
- MOD4 = CONTROL;
- } else {
- MOD1 = CONTROL;
- MOD2 = SHIFT;
- MOD3 = ALT;
- MOD4 = ALT;
- }
-}
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+import org.eclipse.swt.internal.*;
+
+/**
+ * This class provides access to a small number of SWT system-wide
+ * methods, and in addition defines the public constants provided
+ * by SWT.
+ * <p>
+ * By defining constants like UP and DOWN in a single class, SWT
+ * can share common names and concepts at the same time minimizing
+ * the number of classes, names and constants for the application
+ * programmer.
+ * </p><p>
+ * Note that some of the constants provided by this class represent
+ * optional, appearance related aspects of widgets which are available
+ * either only on some window systems, or for a differing set of
+ * widgets on each window system. These constants are marked
+ * as <em>HINT</em>s. The set of widgets which support a particular
+ * <em>HINT</em> may change from release to release, although we typically
+ * will not withdraw support for a <em>HINT</em> once it is made available.
+ * </p>
+ */
+
+/* NOTE:
+ * Good javadoc coding style is to put the values of static final
+ * constants in the comments. This reinforces the fact that
+ * consumers are allowed to rely on the value (and they must
+ * since the values are compiled inline in their code). We
+ * can <em>not</em> change the values of these constants between
+ * releases.
+ */
+public class SWT {
+
+ /* Initialize the class */
+// static {
+// /* NOTE: the static initialization is at the end of file */
+// }
+
+ /* 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;
+
+ /**
+ * move 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;
+
+ /**
+ * hardware key down event type (value is 33)
+ */
+ public static final int HardKeyDown = 33;
+
+ /**
+ * hardware key up event type (value is 34)
+ */
+ public static final int HardKeyUp = 34;
+
+ /* 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;
+
+ /**
+ * style constant for menu bar behavior (value is 1&lt;&lt;1)
+ * <p><b>Used By:</b><ul>
+ * <li><code>Menu</code></li>
+ * </ul></p>
+ */
+ public static final int BAR = 1 << 1;
+
+ /**
+ * style constant for drop down menu/list behavior (value is 1&lt;&lt;2)
+ * <p><b>Used By:</b><ul>
+ * <li><code>Menu</code></li>
+ * <li><code>ToolItem</code></li>
+ * <li><code>CoolItem</code></li>
+ * <li><code>Combo</code></li>
+ * </ul></p>
+ */
+ public static final int DROP_DOWN = 1 << 2;
+
+ /**
+ * style constant for pop up menu behavior (value is 1&lt;&lt;3)
+ * <p><b>Used By:</b><ul>
+ * <li><code>Menu</code></li>
+ * </ul></p>
+ */
+ public static final int POP_UP = 1 << 3;
+
+ /**
+ * style constant for line separator behavior (value is 1&lt;&lt;1)
+ * <p><b>Used By:</b><ul>
+ * <li><code>Label</code></li>
+ * <li><code>MenuItem</code></li>
+ * <li><code>ToolItem</code></li>
+ * </ul></p>
+ */
+ public static final int SEPARATOR = 1 << 1;
+
+ /**
+ * style constant for toggle button behavior (value is 1&lt;&lt;1)
+ * <p><b>Used By:</b><ul>
+ * <li><code>Button</code></li>
+ * </ul></p>
+ */
+ public static final int TOGGLE = 1 << 1;
+
+ /**
+ * style constant for arrow button behavior (value is 1&lt;&lt;2)
+ * <p><b>Used By:</b><ul>
+ * <li><code>Button</code></li>
+ * </ul></p>
+ */
+ public static final int ARROW = 1 << 2;
+
+ /**
+ * style constant for push button behavior (value is 1&lt;&lt;3)
+ * <p><b>Used By:</b><ul>
+ * <li><code>Button</code></li>
+ * <li><code>MenuItem</code></li>
+ * <li><code>ToolItem</code></li>
+ * </ul></p>
+ */
+ public static final int PUSH = 1 << 3;
+
+ /**
+ * style constant for radio button behavior (value is 1&lt;&lt;4)
+ * <p><b>Used By:</b><ul>
+ * <li><code>Button</code></li>
+ * <li><code>MenuItem</code></li>
+ * <li><code>ToolItem</code></li>
+ * </ul></p>
+ */
+ public static final int RADIO = 1 << 4;
+
+ /**
+ * style constant for check box behavior (value is 1&lt;&lt;5)
+ * <p><b>Used By:</b><ul>
+ * <li><code>Button</code></li>
+ * <li><code>MenuItem</code></li>
+ * <li><code>ToolItem</code></li>
+ * <li><code>Table</code></li>
+ * <li><code>Tree</code></li>
+ * </ul></p>
+ */
+ public static final int CHECK = 1 << 5;
+
+ /**
+ * style constant for cascade behavior (value is 1&lt;&lt;6)
+ * <p><b>Used By:</b><ul>
+ * <li><code>MenuItem</code></li>
+ * </ul></p>
+ */
+ public static final int CASCADE = 1 << 6;
+
+ /**
+ * style constant for multi-selection behavior in lists
+ * and multiple line support on text fields (value is 1&lt;&lt;1)
+ * <p><b>Used By:</b><ul>
+ * <li><code>Text</code></li>
+ * <li><code>List</code></li>
+ * <li><code>FileDialog</code></li>
+ * </ul></p>
+ */
+ public static final int MULTI = 1 << 1;
+
+ /**
+ * style constant for single selection behavior in lists
+ * and single line support on text fields (value is 1&lt;&lt;2)
+ * <p><b>Used By:</b><ul>
+ * <li><code>Text</code></li>
+ * <li><code>List</code></li>
+ * <li><code>Table</code></li>
+ * <li><code>Tree</code></li>
+ * </ul></p>
+ */
+ public static final int SINGLE = 1 << 2;
+
+ /**
+ * style constant for read-only behavior (value is 1&lt;&lt;3)
+ * <p><b>Used By:</b><ul>
+ * <li><code>Combo</code></li>
+ * <li><code>Text</code></li>
+ * </ul></p>
+ */
+ public static final int READ_ONLY = 1 << 3;
+
+ /**
+ * style constant for automatic line wrap behavior (value is 1&lt;&lt;6)
+ * <p><b>Used By:</b><ul>
+ * <li><code>Label</code></li>
+ * <li><code>Text</code></li>
+ * <li><code>ToolBar</code></li>
+ * </ul></p>
+ */
+ public static final int WRAP = 1 << 6;
+
+ /**
+ * style constant for simple (not drop down) behavior (value is 1&lt;&lt;6)
+ * <p><b>Used By:</b><ul>
+ * <li><code>Combo</code></li>
+ * </ul></p>
+ */
+ public static final int SIMPLE = 1 << 6;
+
+ /**
+ * style constant for shadow in behavior (value is 1&lt;&lt;2)
+ * <br>Note that this is a <em>HINT</em>.
+ * <p><b>Used By:</b><ul>
+ * <li><code>Label</code></li>
+ * <li><code>Group</code></li>
+ * </ul></p>
+ */
+ public static final int SHADOW_IN = 1 << 2;
+
+ /**
+ * style constant for shadow out behavior (value is 1&lt;&lt;3)
+ * <br>Note that this is a <em>HINT</em>.
+ * <p><b>Used By:</b><ul>
+ * <li><code>Label</code></li>
+ * <li><code>Group</code></li>
+ * <li><code>ToolBar</code></li>
+ * </ul></p>
+ */
+ public static final int SHADOW_OUT = 1 << 3;
+
+ /**
+ * style constant for shadow etched in behavior (value is 1&lt;&lt;4)
+ * <br>Note that this is a <em>HINT</em>. It is ignored on all platforms except Motif.
+ * <p><b>Used By:</b><ul>
+ * <li><code>Group</code></li>
+ * </ul></p>
+ */
+ public static final int SHADOW_ETCHED_IN = 1 << 4;
+
+ /**
+ * style constant for shadow etched out behavior (value is 1&lt;&lt;6)
+ * <br>Note that this is a <em>HINT</em>. It is ignored on all platforms except Motif.
+ * <p><b>Used By:</b><ul>
+ * <li><code>Group</code></li>
+ * </ul></p>
+ */
+ public static final int SHADOW_ETCHED_OUT = 1 << 6;
+
+ /**
+ * style constant for no shadow behavior (value is 1&lt;&lt;5)
+ * <br>Note that this is a <em>HINT</em>.
+ * <p><b>Used By:</b><ul>
+ * <li><code>Label</code></li>
+ * <li><code>Group</code></li>
+ * </ul></p>
+ */
+ public static final int SHADOW_NONE = 1 << 5;
+
+ /**
+ * style constant for progress bar behavior (value is 1&lt;&lt;1)
+ * <p><b>Used By:</b><ul>
+ * <li><code>ProgressBar</code></li>
+ * </ul></p>
+ */
+ public static final int INDETERMINATE = 1 << 1;
+
+ /**
+ * style constant for tool window behavior (value is 1&lt;&lt;2)
+ * <p>
+ * A tool window is a window intended to be used as a floating toolbar.
+ * It typically has a title bar that is shorter than a normal title bar,
+ * and the window title is typically drawn using a smaller font.
+ * <br>Note that this is a <em>HINT</em>.
+ * </p><p><b>Used By:</b><ul>
+ * <li><code>Decorations</code> and subclasses</li>
+ * </ul></p>
+ */
+ public static final int TOOL = 1 << 2;
+
+ /**
+ * style constant to ensure no trimmings are used (value is 1&lt;&lt;3)
+ * <br>Note that this overrides all other trim styles.
+ * <p><b>Used By:</b><ul>
+ * <li><code>Decorations</code> and subclasses</li>
+ * </ul></p>
+ */
+ public static final int NO_TRIM = 1 << 3;
+
+ /**
+ * style constant for resize box trim (value is 1&lt;&lt;4)
+ * <p><b>Used By:</b><ul>
+ * <li><code>Decorations</code> and subclasses</li>
+ * <li><code>Tracker</code></li>
+ * </ul></p>
+ */
+ public static final int RESIZE = 1 << 4;
+
+ /**
+ * style constant for title area trim (value is 1&lt;&lt;5)
+ * <p><b>Used By:</b><ul>
+ * <li><code>Decorations</code> and subclasses</li>
+ * </ul></p>
+ */
+ public static final int TITLE = 1 << 5;
+
+ /**
+ * style constant for close box trim (value is 1&lt;&lt;6,
+ * since we do not distinguish between CLOSE style and MENU style)
+ * <p><b>Used By:</b><ul>
+ * <li><code>Decorations</code> and subclasses</li>
+ * </ul></p>
+ */
+ public static final int CLOSE = 1 << 6;
+
+ /**
+ * style constant for shell menu trim (value is 1&lt;&lt;6,
+ * since we do not distinguish between CLOSE style and MENU style)
+ * <p><b>Used By:</b><ul>
+ * <li><code>Decorations</code> and subclasses</li>
+ * </ul></p>
+ */
+ public static final int MENU = CLOSE;
+
+ /**
+ * style constant for minimize box trim (value is 1&lt;&lt;7)
+ * <p><b>Used By:</b><ul>
+ * <li><code>Decorations</code> and subclasses</li>
+ * </ul></p>
+ */
+ public static final int MIN = 1 << 7;
+
+ /**
+ * style constant for maximize box trim (value is 1&lt;&lt;10)
+ * <p><b>Used By:</b><ul>
+ * <li><code>Decorations</code> and subclasses</li>
+ * </ul></p>
+ */
+ public static final int MAX = 1 << 10;
+
+ /**
+ * style constant for horizontal scrollbar behavior (value is 1&lt;&lt;8)
+ * <p><b>Used By:</b><ul>
+ * <li><code>Scrollable</code> and subclasses</li>
+ * </ul></p>
+ */
+ public static final int H_SCROLL = 1 << 8;
+
+ /**
+ * style constant for vertical scrollbar behavior (value is 1&lt;&lt;9)
+ * <p><b>Used By:</b><ul>
+ * <li><code>Scrollable</code> and subclasses</li>
+ * </ul></p>
+ */
+ public static final int V_SCROLL = 1 << 9;
+
+ /**
+ * style constant for bordered behavior (value is 1&lt;&lt;11)
+ * <br>Note that this is a <em>HINT</em>.
+ * <p><b>Used By:</b><ul>
+ * <li><code>Control</code> and subclasses</li>
+ * </ul></p>
+ */
+ public static final int BORDER = 1 << 11;
+
+ /**
+ * style constant indicating that the window manager should clip
+ * a widget's children with respect to its viewable area. (value is 1&lt;&lt;12)
+ * <br>Note that this is a <em>HINT</em>.
+ * <p><b>Used By:</b><ul>
+ * <li><code>Control</code> and subclasses</li>
+ * </ul></p>
+ */
+ public static final int CLIP_CHILDREN = 1 << 12;
+
+ /**
+ * style constant indicating that the window manager should clip
+ * a widget's siblings with respect to its viewable area. (value is 1&lt;&lt;13)
+ * <br>Note that this is a <em>HINT</em>.
+ * <p><b>Used By:</b><ul>
+ * <li><code>Control</code> and subclasses</li>
+ * </ul></p>
+ */
+ public static final int CLIP_SIBLINGS = 1 << 13;
+
+ /**
+ * style constant for always on top behavior (value is 1&lt;&lt;14)
+ * <br>Note that this is a <em>HINT</em>.
+ * <p><b>Used By:</b><ul>
+ * <li><code>Decorations</code>and subclasses</li>
+ * </ul></p>
+ */
+ public static final int ON_TOP = 1 << 14;
+
+ /**
+ * trim style convenience constant for the most common top level shell appearance
+ * (value is CLOSE|TITLE|MIN|MAX|RESIZE)
+ * <p><b>Used By:</b><ul>
+ * <li><code>Shell</code></li>
+ * </ul></p>
+ */
+ public static final int SHELL_TRIM = CLOSE | TITLE | MIN | MAX | RESIZE;
+
+ /**
+ * trim style convenience constant for the most common dialog shell appearance
+ * (value is CLOSE|TITLE|BORDER)
+ * <p><b>Used By:</b><ul>
+ * <li><code>Shell</code></li>
+ * </ul></p>
+ */
+ public static final int DIALOG_TRIM = TITLE | CLOSE | BORDER;
+
+ /**
+ * style constant for modeless behavior (value is 0)
+ * <br>Note that this is a <em>HINT</em>.
+ * <p><b>Used By:</b><ul>
+ * <li><code>Dialog</code></li>
+ * <li><code>Shell</code></li>
+ * </ul></p>
+ */
+ public static final int MODELESS = 0;
+
+ /**
+ * style constant for primary modal behavior (value is 1&lt;&lt;15)
+ * <br>Note that this is a <em>HINT</em>.
+ * <p><b>Used By:</b><ul>
+ * <li><code>Dialog</code></li>
+ * <li><code>Shell</code></li>
+ * </ul></p>
+ */
+ public static final int PRIMARY_MODAL = 1 << 15;
+
+ /**
+ * style constant for application modal behavior (value is 1&lt;&lt;16)
+ * <br>Note that this is a <em>HINT</em>.
+ * <p><b>Used By:</b><ul>
+ * <li><code>Dialog</code></li>
+ * <li><code>Shell</code></li>
+ * </ul></p>
+ */
+ public static final int APPLICATION_MODAL = 1 << 16;
+
+ /**
+ * style constant for system modal behavior (value is 1&lt;&lt;17)
+ * <br>Note that this is a <em>HINT</em>.
+ * <p><b>Used By:</b><ul>
+ * <li><code>Dialog</code></li>
+ * <li><code>Shell</code></li>
+ * </ul></p>
+ */
+ public static final int SYSTEM_MODAL = 1 << 17;
+
+ /**
+ * style constant for selection hiding behavior. (value is 1&lt;&lt;15)
+ * <br>Note that this is a <em>HINT</em>.
+ * <p><b>Used By:</b><ul>
+ * <li><code>Table</code></li>
+ * </ul></p>
+ */
+ public static final int HIDE_SELECTION = 1 << 15;
+
+ /**
+ * style constant for full row selection behavior. (value is 1&lt;&lt;16)
+ * <br>Note that this is a <em>HINT</em>.
+ * <p><b>Used By:</b><ul>
+ * <li><code>Table</code></li>
+ * </ul></p>
+ */
+ public static final int FULL_SELECTION = 1 << 16;
+
+ /**
+ * style constant for flat appearance. (value is 1&lt;&lt;23)
+ * <br>Note that this is a <em>HINT</em>.
+ * <p><b>Used By:</b><ul>
+ * <li><code>Button</code></li>
+ * <li><code>ToolBar</code></li>
+ * </ul></p>
+ */
+ public static final int FLAT = 1 << 23;
+
+ /**
+ * style constant for flat appearance. (value is 1&lt;&lt;16)
+ * <br>Note that this is a <em>HINT</em>.
+ * <p><b>Used By:</b><ul>
+ * <li><code>ProgressBar</code></li>
+ * </ul></p>
+ */
+ public static final int SMOOTH = 1 << 16;
+
+ /**
+ * style constant for no background behavior (value is 1&lt;&lt;18)
+ * <p>
+ * By default, before a widget paints, the client area is filled with the current background color.
+ * When this style is specified, the background is not filled, and the application is responsible
+ * for filling every pixel of the client area.
+ * This style might be used as an alternative to "double-buffering" in order to reduce flicker.
+ * This style does not mean "transparent" - widgets that are obscured will not draw through.
+ * </p><p><b>Used By:</b><ul>
+ * <li><code>Composite</code></li>
+ * </ul></p>
+ */
+ public static final int NO_BACKGROUND = 1 << 18;
+
+ /**
+ * style constant for does not take focus behavior (value is 1&lt;&lt;19)
+ * <br>Note that this is a <em>HINT</em>.
+ * <p><b>Used By:</b><ul>
+ * <li><code>Composite</code></li>
+ * </ul></p>
+ */
+ public static final int NO_FOCUS = 1 << 19;
+
+ /**
+ * style constant for no redraw on resize behavior (value is 1&lt;&lt;20)
+ * <p>
+ * This style stops the entire client area from being invalidated when the size
+ * of the Canvas changes. Specifically, when the size of the Canvas gets smaller,
+ * the SWT.Paint event is not sent. When it gets bigger, an SWT.Paint event is
+ * sent with a GC clipped to only the new areas to be painted. Without this
+ * style, the entire client area will be repainted.
+ * </p><p><b>Used By:</b><ul>
+ * <li><code>Composite</code></li>
+ * </ul></p>
+ */
+ public static final int NO_REDRAW_RESIZE = 1 << 20;
+
+ /**
+ * style constant for no paint event merging behavior (value is 1&lt;&lt;21)
+ * <p><b>Used By:</b><ul>
+ * <li><code>Composite</code></li>
+ * </ul></p>
+ */
+ public static final int NO_MERGE_PAINTS = 1 << 21;
+
+ /**
+ * style constant for preventing child radio group behavior (value is 1&lt;&lt;22)
+ * <p><b>Used By:</b><ul>
+ * <li><code>Composite</code></li>
+ * </ul></p>
+ */
+ public static final int NO_RADIO_GROUP = 1 << 22;
+
+ /**
+ * style constant for left to right orientation (value is 1&lt;&lt;25)
+ * <p>
+ * When orientation is not explicitly specified, orientation is
+ * inherited. This means that children will be assigned the
+ * orientation of their parent. To override this behavior and
+ * force an orientation for a child, explicitly set the orientation
+ * of the child when that child is created.
+ * </p>
+ * <p><b>Used By:</b><ul>
+ * <li><code>Control</code></li>
+ * <li><code>Menu</code></li>
+ * </ul></p>
+ *
+ * <p>
+ * <b>NOTE:</b> This API element is part of an interim API that is still under
+ * development and is expected to change significantly before reaching stability.
+ * It is being made available at this early stage to solicit feedback from
+ * pioneering adopters on the understanding that any code that uses this API
+ * will almost certainly be broken (repeatedly) as the API evolves.
+ * </p>
+ *
+ * @since 2.1
+ */
+ public static final int LEFT_TO_RIGHT = 1 << 25;
+
+ /**
+ * style constant for right to left orientation (value is 1&lt;&lt;26)
+ * <p>
+ * When orientation is not explicitly specified, orientation is
+ * inherited. This means that children will be assigned the
+ * orientation of their parent. To override this behavior and
+ * force an orientation for a child, explicitly set the orientation
+ * of the child when that child is created.
+ * </p>
+ * <p><b>Used By:</b><ul>
+ * <li><code>Control</code></li>
+ * <li><code>Menu</code></li>
+ * </ul></p>
+ *
+ * <p>
+ * <b>NOTE:</b> This API element is part of an interim API that is still under
+ * development and is expected to change significantly before reaching stability.
+ * It is being made available at this early stage to solicit feedback from
+ * pioneering adopters on the understanding that any code that uses this API
+ * will almost certainly be broken (repeatedly) as the API evolves.
+ * </p>
+ *
+ * @since 2.1
+ */
+ public static final int RIGHT_TO_LEFT = 1 << 26;
+
+ /**
+ * style constant to indicate coordinate mirroring (value is 1&lt;&lt;27)
+ * <p><b>Used By:</b><ul>
+ * <li><code>Control</code></li>
+ * <li><code>Menu</code></li>
+ * </ul></p>
+ *
+ * <p>
+ * <b>NOTE:</b> This API element is part of an interim API that is still under
+ * development and is expected to change significantly before reaching stability.
+ * It is being made available at this early stage to solicit feedback from
+ * pioneering adopters on the understanding that any code that uses this API
+ * will almost certainly be broken (repeatedly) as the API evolves.
+ * </p>
+ *
+ * @since 2.1
+ */
+ public static final int MIRRORED = 1 << 27;
+
+ /**
+ * style constant for align up behavior (value is 1&lt;&lt;7,
+ * since align UP and align TOP are considered the same)
+ * <p><b>Used By:</b><ul>
+ * <li><code>Button</code> with <code>ARROW</code> style</li>
+ * <li><code>Tracker</code></li>
+ * </ul></p>
+ */
+ public static final int UP = 1 << 7;
+
+ /**
+ * style constant for align top behavior (value is 1&lt;&lt;7,
+ * since align UP and align TOP are considered the same)
+ * <p><b>Used By:</b><ul>
+ * <li><code>FormAttachment</code> in a <code>FormLayout</code></li>
+ * </ul></p>
+ */
+ public static final int TOP = UP;
+
+ /**
+ * style constant for align down behavior (value is 1&lt;&lt;10,
+ * since align DOWN and align BOTTOM are considered the same)
+ * <p><b>Used By:</b><ul>
+ * <li><code>Button</code> with <code>ARROW</code> style</li>
+ * <li><code>Tracker</code></li>
+ * </ul></p>
+ */
+ public static final int DOWN = 1 << 10;
+
+ /**
+ * style constant for align bottom behavior (value is 1&lt;&lt;10,
+ * since align DOWN and align BOTTOM are considered the same)
+ * <p><b>Used By:</b><ul>
+ * <li><code>FormAttachment</code> in a <code>FormLayout</code></li>
+ * </ul></p>
+ */
+ public static final int BOTTOM = DOWN;
+
+ /**
+ * style constant for align left behavior (value is 1&lt;&lt;14)
+ * <p><b>Used By:</b><ul>
+ * <li><code>Button</code></li>
+ * <li><code>Label</code></li>
+ * <li><code>TableColumn</code></li>
+ * <li><code>Tracker</code></li>
+ * <li><code>FormAttachment</code> in a <code>FormLayout</code></li>
+ * </ul></p>
+ */
+ public static final int LEFT = 1 << 14;
+
+ /**
+ * style constant for align right behavior (value is 1&lt;&lt;17)
+ * <p><b>Used By:</b><ul>
+ * <li><code>Button</code></li>
+ * <li><code>Label</code></li>
+ * <li><code>TableColumn</code></li>
+ * <li><code>Tracker</code></li>
+ * <li><code>FormAttachment</code> in a <code>FormLayout</code></li>
+ * </ul></p>
+ */
+ public static final int RIGHT = 1 << 17;
+
+ /**
+ * style constant for align center behavior (value is 1&lt;&lt;24)
+ * <p><b>Used By:</b><ul>
+ * <li><code>Button</code></li>
+ * <li><code>Label</code></li>
+ * <li><code>TableColumn</code></li>
+ * <li><code>FormAttachment</code> in a <code>FormLayout</code></li>
+ * </ul></p>
+ */
+ public static final int CENTER = 1 << 24;
+
+ /**
+ * style constant for horizontal alignment or orientation behavior (value is 1&lt;&lt;8)
+ * <p><b>Used By:</b><ul>
+ * <li><code>Label</code></li>
+ * <li><code>ProgressBar</code></li>
+ * <li><code>Sash</code></li>
+ * <li><code>Scale</code></li>
+ * <li><code>ScrollBar</code></li>
+ * <li><code>Slider</code></li>
+ * <li><code>ToolBar</code></li>
+ * <li><code>FillLayout</code> type</li>
+ * <li><code>RowLayout</code> type</li>
+ * </ul></p>
+ */
+ public static final int HORIZONTAL = 1 << 8;
+
+ /**
+ * style constant for vertical alignment or orientation behavior (value is 1&lt;&lt;9)
+ * <p><b>Used By:</b><ul>
+ * <li><code>Label</code></li>
+ * <li><code>ProgressBar</code></li>
+ * <li><code>Sash</code></li>
+ * <li><code>Scale</code></li>
+ * <li><code>ScrollBar</code></li>
+ * <li><code>Slider</code></li>
+ * <li><code>ToolBar</code></li>
+ * <li><code>FillLayout</code> type</li>
+ * <li><code>RowLayout</code> type</li>
+ * </ul></p>
+ */
+ public static final int VERTICAL = 1 << 9;
+
+ /**
+ * Input Method Editor style constant for double byte
+ * input behavior (value is 1&lt;&lt;1)
+ */
+ public static final int DBCS = 1 << 1;
+
+ /**
+ * Input Method Editor style constant for alpha
+ * input behavior (value is 1&lt;&lt;2)
+ */
+ public static final int ALPHA = 1 << 2;
+
+ /**
+ * Input Method Editor style constant for native
+ * input behavior (value is 1&lt;&lt;3)
+ */
+ public static final int NATIVE = 1 << 3;
+
+ /**
+ * Input Method Editor style constant for phonetic
+ * input behavior (value is 1&lt;&lt;4)
+ */
+ public static final int PHONETIC = 1 << 4;
+
+ /**
+ * Input Method Editor style constant for romanicized
+ * input behavior (value is 1&lt;&lt;5)
+ */
+ public static final int ROMAN = 1 << 5;
+
+ /**
+ * ASCII character convenience constant for the backspace character
+ * (value is the <code>char</code> '\b')
+ */
+ public static final char BS = '\b';
+
+ /**
+ * ASCII character convenience constant for the carriage return character
+ * (value is the <code>char</code> '\r')
+ */
+ public static final char CR = '\r';
+
+ /**
+ * ASCII character convenience constant for the delete character
+ * (value is the <code>char</code> with value 127)
+ */
+ public static final char DEL = 0x7F;
+
+ /**
+ * ASCII character convenience constant for the escape character
+ * (value is the <code>char</code> with value 27)
+ */
+ public static final char ESC = 0x1B;
+
+ /**
+ * ASCII character convenience constant for the line feed character
+ * (value is the <code>char</code> '\n')
+ */
+ public static final char LF = '\n';
+
+ /**
+ * ASCII character convenience constant for the tab character
+ * (value is the <code>char</code> '\t')
+ *
+ * @since 2.1
+ */
+ public static final char TAB = '\t';
+
+ /**
+ * keyboard and/or mouse event mask indicating that the ALT key
+ * was pushed on the keyboard when the event was generated
+ * (value is 1&lt;&lt;16)
+ */
+ public static final int ALT = 1 << 16;
+
+ /**
+ * keyboard and/or mouse event mask indicating that the SHIFT key
+ * was pushed on the keyboard when the event was generated
+ * (value is 1&lt;&lt;17)
+ */
+ public static final int SHIFT = 1 << 17;
+
+ /**
+ * keyboard and/or mouse event mask indicating that the CTRL key
+ * was pushed on the keyboard when the event was generated
+ * (value is 1&lt;&lt;18)
+ */
+ public static final int CTRL = 1 << 18;
+
+ /**
+ * keyboard and/or mouse event mask indicating that the CTRL key
+ * was pushed on the keyboard when the event was generated. This
+ * is a synonym for CTRL (value is 1&lt;&lt;18)
+ */
+ public static final int CONTROL = CTRL;
+
+ /**
+ * keyboard and/or mouse event mask indicating that the COMMAND key
+ * was pushed on the keyboard when the event was generated
+ * (value is 1&lt;&lt;22)
+ *
+ * @since 2.1
+ */
+ public static final int COMMAND = 1 << 22;
+
+ /**
+ * keyboard and/or mouse event mask indicating all possible
+ * keyboard modifiers. To allow for the future, this mask
+ * is intended to be used in place of code that references
+ * each individual keyboard mask. For example, the following
+ * expression will determine whether any modifer is pressed
+ * and will continue to work as new modifier masks are added.
+ *
+ * <code>(stateMask & SWT.MODIFIER_MASK) != 0</code>.
+ *
+ * @since 2.1
+ */
+ public static final int MODIFIER_MASK;
+
+ /**
+ * keyboard and/or mouse event mask indicating that mouse button one
+ * was pushed when the event was generated. (value is 1&lt;&lt;19)
+ */
+ public static final int BUTTON1 = 1 << 19;
+
+ /**
+ * keyboard and/or mouse event mask indicating that mouse button two
+ * was pushed when the event was generated. (value is 1&lt;&lt;20)
+ */
+ public static final int BUTTON2 = 1 << 20;
+
+ /**
+ * keyboard and/or mouse event mask indicating that mouse button three
+ * was pushed when the event was generated. (value is 1&lt;&lt;21)
+ */
+ public static final int BUTTON3 = 1 << 21;
+
+ /**
+ * keyboard and/or mouse event mask indicating all possible
+ * mouse buttons. To allow for the future, this mask
+ * is intended to be used in place of code that references
+ * each individual button mask. For example, the following
+ * expression will determine whether any button is pressed
+ * and will continue to work as new button masks are added.
+ *
+ * <code>(stateMask & SWT.BUTTON_MASK) != 0</code>.
+ *
+ * @since 2.1
+ */
+ public static final int BUTTON_MASK;
+
+ /**
+ * keyboard and/or mouse event mask indicating that the MOD1 key
+ * was pushed on the keyboard when the event was generated. This
+ * is the primary keyboard modifier for the platform.
+ *
+ * @since 2.1
+ */
+ public static final int MOD1;
+
+ /**
+ * keyboard and/or mouse event mask indicating that the MOD2 key
+ * was pushed on the keyboard when the event was generated. This
+ * is the secondary keyboard modifier for the platform.
+ *
+ * @since 2.1
+ */
+ public static final int MOD2;
+
+ /**
+ * keyboard and/or mouse event mask indicating that the MOD3 key
+ * was pushed on the keyboard when the event was generated.
+ *
+ * @since 2.1
+ */
+ public static final int MOD3;
+
+ /**
+ * keyboard and/or mouse event mask indicating that the MOD4 key
+ * was pushed on the keyboard when the event was generated.
+ *
+ * @since 2.1
+ */
+ public static final int MOD4;
+
+ /**
+ * accelerator constant used to differentiate a key code from a
+ * unicode character. If this bit is set, then the key stroke
+ * portion of an accelerator represents a key code. If this bit
+ * is not set, then the key stroke portion of an accelerator is
+ * a unicode character.
+ *
+ * The following expression is false:
+ *
+ * <code>((SWT.MOD1 | SWT.MOD2 | 'T') & SWT.KEYCODE_BIT) != 0</code>.
+ *
+ * The following expression is true:
+ *
+ * <code>((SWT.MOD3 | SWT.F2) & SWT.KEYCODE_BIT) != 0</code>.
+ *
+ * (value is (1&lt;&lt;24))
+ *
+ * @since 2.1
+ */
+ public static final int KEYCODE_BIT = (1 << 24);
+
+ /**
+ * accelerator constant used to extract the key stroke portion of
+ * an accelerator. The key stroke may be a key code or a unicode
+ * value. If the key stroke is a key code <code>KEYCODE_BIT</code>
+ * will be set.
+ *
+ * @since 2.1
+ */
+ public static final int KEY_MASK = KEYCODE_BIT + 0xFFFF;
+
+ /**
+ * keyboard event constant representing the UP ARROW key
+ * (value is (1&lt;&lt;24)+1)
+ */
+ public static final int ARROW_UP = KEYCODE_BIT + 1;
+
+ /**
+ * keyboard event constant representing the DOWN ARROW key
+ * (value is (1&lt;&lt;24)+2)
+ */
+ public static final int ARROW_DOWN = KEYCODE_BIT + 2;
+
+ /**
+ * keyboard event constant representing the LEFT ARROW key
+ * (value is (1&lt;&lt;24)+3)
+ */
+ public static final int ARROW_LEFT = KEYCODE_BIT + 3;
+
+ /**
+ * keyboard event constant representing the RIGHT ARROW key
+ * (value is (1&lt;&lt;24)+4)
+ */
+ public static final int ARROW_RIGHT = KEYCODE_BIT + 4;
+
+ /**
+ * keyboard event constant representing the PAGE UP key
+ * (value is (1&lt;&lt;24)+5)
+ */
+ public static final int PAGE_UP = KEYCODE_BIT + 5;
+
+ /**
+ * keyboard event constant representing the PAGE DOWN key
+ * (value is (1&lt;&lt;24)+6)
+ */
+ public static final int PAGE_DOWN = KEYCODE_BIT + 6;
+
+ /**
+ * keyboard event constant representing the HOME key
+ * (value is (1&lt;&lt;24)+7)
+ */
+ public static final int HOME = KEYCODE_BIT + 7;
+
+ /**
+ * keyboard event constant representing the END key
+ * (value is (1&lt;&lt;24)+8)
+ */
+ public static final int END = KEYCODE_BIT + 8;
+
+ /**
+ * keyboard event constant representing the INSERT key
+ * (value is (1&lt;&lt;24)+9)
+ */
+ public static final int INSERT = KEYCODE_BIT + 9;
+
+ /**
+ * keyboard event constant representing the F1 key
+ * (value is (1&lt;&lt;24)+10)
+ */
+ public static final int F1 = KEYCODE_BIT + 10;
+
+ /**
+ * keyboard event constant representing the F2 key
+ * (value is (1&lt;&lt;24)+11)
+ */
+ public static final int F2 = KEYCODE_BIT + 11;
+
+ /**
+ * keyboard event constant representing the F3 key
+ * (value is (1&lt;&lt;24)+12)
+ */
+ public static final int F3 = KEYCODE_BIT + 12;
+
+ /**
+ * keyboard event constant representing the F4 key
+ * (value is (1&lt;&lt;24)+13)
+ */
+ public static final int F4 = KEYCODE_BIT + 13;
+
+ /**
+ * keyboard event constant representing the F5 key
+ * (value is (1&lt;&lt;24)+14)
+ */
+ public static final int F5 = KEYCODE_BIT + 14;
+
+ /**
+ * keyboard event constant representing the F6 key
+ * (value is (1&lt;&lt;24)+15)
+ */
+ public static final int F6 = KEYCODE_BIT + 15;
+
+ /**
+ * keyboard event constant representing the F7 key
+ * (value is (1&lt;&lt;24)+16)
+ */
+ public static final int F7 = KEYCODE_BIT + 16;
+
+ /**
+ * keyboard event constant representing the F8 key
+ * (value is (1&lt;&lt;24)+17)
+ */
+ public static final int F8 = KEYCODE_BIT + 17;
+
+ /**
+ * keyboard event constant representing the F9 key
+ * (value is (1&lt;&lt;24)+18)
+ */
+ public static final int F9 = KEYCODE_BIT + 18;
+
+ /**
+ * keyboard event constant representing the F10 key
+ * (value is (1&lt;&lt;24)+19)
+ */
+ public static final int F10 = KEYCODE_BIT + 19;
+
+ /**
+ * keyboard event constant representing the F11 key
+ * (value is (1&lt;&lt;24)+20)
+ */
+ public static final int F11 = KEYCODE_BIT + 20;
+
+ /**
+ * keyboard event constant representing the F12 key
+ * (value is (1&lt;&lt;24)+21)
+ */
+ public static final int F12 = KEYCODE_BIT + 21;
+
+ /**
+ * <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&lt;&lt;1)
+ */
+ public static final int ICON_INFORMATION = 1 << 1;
+
+ /**
+ * <code>MessageBox</code> style constant for question icon
+ * behavior (value is 1&lt;&lt;2)
+ */
+ public static final int ICON_QUESTION = 1 << 2;
+
+ /**
+ * <code>MessageBox</code> style constant for warning icon
+ * behavior (value is 1&lt;&lt;3)
+ */
+ public static final int ICON_WARNING = 1 << 3;
+
+ /**
+ * <code>MessageBox</code> style constant for "working" icon
+ * behavior (value is 1&lt;&lt;4)
+ */
+ 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&lt;&lt;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&lt;&lt;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&lt;&lt;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&lt;&lt;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&lt;&lt;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&lt;&lt;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&lt;&lt;11)
+ */
+ public static final int IGNORE = 1 << 11;
+
+ /**
+ * <code>FileDialog</code> style constant for open file dialog behavior
+ * (value is 1&lt;&lt;12)
+ */
+ public static final int OPEN = 1 << 12;
+
+ /**
+ * <code>FileDialog</code> style constant for save file dialog behavior
+ * (value is 1&lt;&lt;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;
+
+ /**
+ * draw constant indicating whether the drawing operation
+ * should fill the background (value is 1&lt;&lt;0)
+ */
+ public static final int DRAW_TRANSPARENT = 1 << 0;
+
+ /**
+ * draw constant indicating whether the string drawing operation
+ * should handle line-delimeters (value is 1&lt;&lt;1)
+ */
+ public static final int DRAW_DELIMITER = 1 << 1;
+
+ /**
+ * draw constant indicating whether the string drawing operation
+ * should expand TAB characters (value is 1&lt;&lt;2)
+ */
+ public static final int DRAW_TAB = 1 << 2;
+
+ /**
+ * draw constant indicating whether the string drawing operation
+ * should handle mnemonics (value is 1&lt;&lt;3)
+ */
+ public static final int DRAW_MNEMONIC = 1 << 3;
+
+ /**
+ * 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 org.eclipse.swt.widgets.Widget#checkSubclass
+ */
+ public static final int ERROR_INVALID_SUBCLASS = 43;
+
+ /**
+ * SWT error constant indicating that an attempt was made to
+ * invoke an SWT operation using a graphics object which had
+ * already been disposed.
+ * (value is 44)
+ */
+ public static final int ERROR_GRAPHIC_DISPOSED = 44;
+
+ /**
+ * SWT error constant indicating that an attempt was made to
+ * invoke an SWT operation using a device which had already
+ * been disposed.
+ * (value is 45)
+ */
+ public static final int ERROR_DEVICE_DISPOSED = 45;
+
+ /**
+ * SWT error constant indicating that an exception happened
+ * when executing a runnable.
+ * (value is 46)
+ */
+ public static final int ERROR_FAILED_EXEC = 46;
+
+ /**
+ * SWT error constant indicating that an unsatisfied link
+ * error occured while attempting to load a library.
+ * (value is 47)
+ */
+ public static final int ERROR_FAILED_LOAD_LIBRARY = 47;
+
+ /**
+ * traversal event detail field value indicating that no
+ * traversal action should be taken.
+ * (value is 0)
+ */
+ public static final int TRAVERSE_NONE = 0;
+
+ /**
+ * traversal event detail field value indicating that the
+ * key which designates that a dialog should be cancelled was
+ * pressed; typically, this is the ESC key
+ * (value is 1&lt;&lt;1)
+ */
+ public static final int TRAVERSE_ESCAPE = 1 << 1;
+
+ /**
+ * traversal event detail field value indicating that the
+ * key which activates the default button in a dialog was
+ * pressed; typically, this is the ENTER key
+ * (value is 1&lt;&lt;2)
+ */
+ public static final int TRAVERSE_RETURN = 1 << 2;
+
+ /**
+ * traversal event detail field value indicating that the
+ * key which designates that focus should be given to the
+ * previous tab group was pressed; typically, this is the
+ * SHIFT-TAB key sequence
+ * (value is 1&lt;&lt;3)
+ */
+ public static final int TRAVERSE_TAB_PREVIOUS = 1 << 3;
+
+ /**
+ * traversal event detail field value indicating that the
+ * key which designates that focus should be given to the
+ * next tab group was pressed; typically, this is the
+ * TAB key
+ * (value is 1&lt;&lt;4)
+ */
+ public static final int TRAVERSE_TAB_NEXT = 1 << 4;
+
+ /**
+ * traversal event detail field value indicating that the
+ * key which designates that focus should be given to the
+ * previous tab item was pressed; typically, this is either
+ * the LEFT-ARROW or UP-ARROW keys
+ * (value is 1&lt;&lt;5)
+ */
+ public static final int TRAVERSE_ARROW_PREVIOUS = 1 << 5;
+
+ /**
+ * traversal event detail field value indicating that the
+ * key which designates that focus should be given to the
+ * previous tab item was pressed; typically, this is either
+ * the RIGHT-ARROW or DOWN-ARROW keys
+ * (value is 1&lt;&lt;6)
+ */
+ public static final int TRAVERSE_ARROW_NEXT = 1 << 6;
+
+ /**
+ * traversal event detail field value indicating that a
+ * mnemonic key sequence was pressed
+ * (value is 1&lt;&lt;7)
+ */
+ public static final int TRAVERSE_MNEMONIC = 1 << 7;
+
+ /**
+ * traversal event detail field value indicating that the
+ * key which designates that the previous page of a multi-page
+ * window should be shown was pressed; typically, this
+ * is the CTRL-PAGEUP key sequence
+ * (value is 1&lt;&lt;8)
+ */
+ public static final int TRAVERSE_PAGE_PREVIOUS = 1 << 8;
+
+ /**
+ * traversal event detail field value indicating that the
+ * key which designates that the next page of a multi-page
+ * window should be shown was pressed; typically, this
+ * is the CTRL-PAGEDOWN key sequence
+ * (value is 1&lt;&lt;9)
+ */
+ public static final int TRAVERSE_PAGE_NEXT = 1 << 9;
+
+ /**
+ * 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&lt;&lt;0)
+ */
+ public static final int BOLD = 1 << 0;
+
+ /**
+ * font style constant indicating an italic font
+ * (value is 1&lt;&lt;1)
+ */
+ public static final int ITALIC = 1 << 1;
+
+ /**
+ * system arrow cursor (value is 0)
+ */
+ public static final int CURSOR_ARROW = 0;
+
+ /**
+ * system wait cursor (value is 1)
+ */
+ public static final int CURSOR_WAIT = 1;
+
+ /**
+ * system cross hair cursor (value is 2)
+ */
+ public static final int CURSOR_CROSS = 2;
+
+ /**
+ * system app startup cursor (value is 3)
+ */
+ public static final int CURSOR_APPSTARTING = 3;
+
+ /**
+ * system help cursor (value is 4)
+ */
+ public static final int CURSOR_HELP = 4;
+
+ /**
+ * system resize all directions cursor (value is 5)
+ */
+ public static final int CURSOR_SIZEALL = 5;
+
+ /**
+ * system resize north-east-south-west cursor (value is 6)
+ */
+ public static final int CURSOR_SIZENESW = 6;
+
+ /**
+ * system resize north-south cursor (value is 7)
+ */
+ public static final int CURSOR_SIZENS = 7;
+
+ /**
+ * system resize north-west-south-east cursor (value is 8)
+ */
+ public static final int CURSOR_SIZENWSE = 8;
+
+ /**
+ * system resize west-east cursor (value is 9)
+ */
+ public static final int CURSOR_SIZEWE = 9;
+
+ /**
+ * system resize north cursor (value is 10)
+ */
+ public static final int CURSOR_SIZEN = 10;
+
+ /**
+ * system resize south cursor (value is 11)
+ */
+ public static final int CURSOR_SIZES = 11;
+
+ /**
+ * system resize east cursor (value is 12)
+ */
+ public static final int CURSOR_SIZEE = 12;
+
+ /**
+ * system resize west cursor (value is 13)
+ */
+ public static final int CURSOR_SIZEW = 13;
+
+ /**
+ * system resize north-east cursor (value is 14)
+ */
+ public static final int CURSOR_SIZENE = 14;
+
+ /**
+ * system resize south-east cursor (value is 15)
+ */
+ public static final int CURSOR_SIZESE = 15;
+
+ /**
+ * system resize south-west cursor (value is 16)
+ */
+ public static final int CURSOR_SIZESW = 16;
+
+ /**
+ * system resize north-west cursor (value is 17)
+ */
+ public static final int CURSOR_SIZENW = 17;
+
+ /**
+ * system up arrow cursor (value is 18)
+ */
+ public static final int CURSOR_UPARROW = 18;
+
+ /**
+ * system i-beam cursor (value is 19)
+ */
+ public static final int CURSOR_IBEAM = 19;
+
+ /**
+ * system "not allowed" cursor (value is 20)
+ */
+ public static final int CURSOR_NO = 20;
+
+ /**
+ * system hand cursor (value is 21)
+ */
+ public static final int CURSOR_HAND = 21;
+
+ /**
+ * line drawing style for 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 alpha transparency information (value is 1&lt;&lt;0)
+ */
+ public static final int TRANSPARENCY_ALPHA = 1 << 0;
+
+ /**
+ * image transparency constant indicating that the image
+ * contains a transparency mask (value is 1&lt;&lt;1)
+ */
+ public static final int TRANSPARENCY_MASK = 1 << 1;
+
+ /**
+ * image transparency constant indicating that the image
+ * contains a transparent pixel (value is 1&lt;&lt;2)
+ */
+ public static final int TRANSPARENCY_PIXEL = 1 << 2;
+
+/**
+ * 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";
+ case ERROR_FAILED_EXEC: return "Failed to execute runnable";
+ case ERROR_FAILED_LOAD_LIBRARY: return "Unable to load library";
+ }
+ return "Unknown error";
+}
+
+/**
+ * Returns the NLS'ed message for the given argument.
+ *
+ * @param key the key to look up
+ * @return the message for the given key
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if the key is null</li>
+ * </ul>
+ */
+public static String getMessage(String key) {
+ return Compatibility.getMessage(key);
+}
+
+/**
+ * Returns the SWT platform name.
+ * Examples: "win32", "motif", "gtk", "photon", "carbon"
+ *
+ * @return the SWT platform name
+ */
+public static String getPlatform () {
+ return Callback.getPlatform ();
+}
+
+/**
+ * Returns the SWT version number as an integer.
+ * Example: "SWT051" == 51
+ *
+ * @return the SWT version number
+ */
+public static int getVersion () {
+ return Library.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_FAILED_EXEC:
+ 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_FAILED_LOAD_LIBRARY:
+ 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;
+}
+
+static {
+ /*
+ * These values represent bit masks that may need to
+ * expand in the future. Therefore they are not initialized
+ * in the declaration to stop the compiler from inlining.
+ */
+ BUTTON_MASK = BUTTON1 | BUTTON2 | BUTTON3;
+ MODIFIER_MASK = ALT | SHIFT | CTRL | COMMAND;
+
+ /*
+ * These values can be different on different platforms.
+ * Therefore they are not initialized in the declaration
+ * to stop the compiler from inlining.
+ */
+ String platform = getPlatform ();
+ if ("carbon".equals (platform)) {
+ MOD1 = COMMAND;
+ MOD2 = SHIFT;
+ MOD3 = ALT;
+ MOD4 = CONTROL;
+ } else {
+ MOD1 = CONTROL;
+ MOD2 = SHIFT;
+ MOD3 = ALT;
+ MOD4 = ALT;
+ }
+}
+}
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
index 1aa1b3b730..8e9566168a 100755
--- 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
@@ -1,113 +1,113 @@
-package org.eclipse.swt;
-
-/*
+package org.eclipse.swt;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-/**
- * 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;
-}
-
-/**
- * Returns the string describing this SWTError object.
- * <p>
- * It is combined with the message string of the Throwable
- * which caused this SWTError (if this information is available).
- * </p>
- * @return the error message string of this SWTError object
- */
-public String getMessage() {
- if (throwable == null)
- return super.getMessage();
- else
- return super.getMessage() + " (" + throwable.toString() + ")";
-}
-
-/**
- * Outputs a printable representation of this error's
- * walkback on the standard error stream.
- * <p>
- * Note: printStackTrace(PrintStream) and printStackTrace(PrintWriter)
- * are not provided in order to maintain compatibility with CLDC.
- * </p>
- */
-public synchronized void printStackTrace() {
- super.printStackTrace();
- if (throwable != null) {
- System.err.println("*** Stack trace of contained error ***");
- throwable.printStackTrace();
- }
-}
-
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+/**
+ * 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;
+}
+
+/**
+ * Returns the string describing this SWTError object.
+ * <p>
+ * It is combined with the message string of the Throwable
+ * which caused this SWTError (if this information is available).
+ * </p>
+ * @return the error message string of this SWTError object
+ */
+public String getMessage() {
+ if (throwable == null)
+ return super.getMessage();
+ else
+ return super.getMessage() + " (" + throwable.toString() + ")";
+}
+
+/**
+ * Outputs a printable representation of this error's
+ * walkback on the standard error stream.
+ * <p>
+ * Note: printStackTrace(PrintStream) and printStackTrace(PrintWriter)
+ * are not provided in order to maintain compatibility with CLDC.
+ * </p>
+ */
+public synchronized void printStackTrace() {
+ super.printStackTrace();
+ if (throwable != null) {
+ System.err.println("*** Stack trace of contained error ***");
+ throwable.printStackTrace();
+ }
+}
+
+}
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
index 74c76f6d41..674a6dd40a 100755
--- 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
@@ -1,106 +1,106 @@
-package org.eclipse.swt;
-
-/*
+package org.eclipse.swt;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-/**
- * 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;
-}
-
-/**
- * Returns the string describing this SWTException object.
- * <p>
- * It is combined with the message string of the Throwable
- * which caused this SWTException (if this information is available).
- * </p>
- * @return the error message string of this SWTException object
- */
-public String getMessage() {
- if (throwable == null)
- return super.getMessage();
- else
- return super.getMessage() + " (" + throwable.toString() + ")";
-}
-
-/**
- * Outputs a printable representation of this exception's
- * walkback on the standard error stream.
- * <p>
- * Note: printStackTrace(PrintStream) and printStackTrace(PrintWriter)
- * are not provided in order to maintain compatibility with CLDC.
- * </p>
- */
-public void printStackTrace() {
- super.printStackTrace();
- if (throwable != null) {
- System.err.println("*** Stack trace of contained exception ***");
- throwable.printStackTrace();
- }
-}
-
-}
-
-
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+/**
+ * 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;
+}
+
+/**
+ * Returns the string describing this SWTException object.
+ * <p>
+ * It is combined with the message string of the Throwable
+ * which caused this SWTException (if this information is available).
+ * </p>
+ * @return the error message string of this SWTException object
+ */
+public String getMessage() {
+ if (throwable == null)
+ return super.getMessage();
+ else
+ return super.getMessage() + " (" + throwable.toString() + ")";
+}
+
+/**
+ * Outputs a printable representation of this exception's
+ * walkback on the standard error stream.
+ * <p>
+ * Note: printStackTrace(PrintStream) and printStackTrace(PrintWriter)
+ * are not provided in order to maintain compatibility with CLDC.
+ * </p>
+ */
+public void printStackTrace() {
+ super.printStackTrace();
+ if (throwable != null) {
+ System.err.println("*** Stack trace of contained exception ***");
+ throwable.printStackTrace();
+ }
+}
+
+}
+
+
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
index df645735e1..f16bf68834 100755
--- 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
@@ -1,31 +1,31 @@
-package org.eclipse.swt.events;
-
-/*
+package org.eclipse.swt.events;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-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);
-}
-
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+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
index 8df5ab46cc..73b6df6b58 100755
--- 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
@@ -1,34 +1,34 @@
-package org.eclipse.swt.events;
-
-/*
+package org.eclipse.swt.events;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-import org.eclipse.swt.internal.SWTEventListener;
-
-/**
- * Classes which implement this interface provide a method
- * that deals with the event that is generated when a widget,
- * such as a menu item, is armed.
- * <p>
- * After creating an instance of a class that implements
- * this interface it can be added to a widget using the
- * <code>addArmListener</code> method and removed using
- * the <code>removeArmListener</code> method. When the
- * widget is armed, the widgetArmed method will be invoked.
- * </p>
- *
- * @see ArmEvent
- */
-public interface ArmListener extends SWTEventListener {
-
-/**
- * Sent when a widget is armed, or 'about to be selected'.
- *
- * @param e an event containing information about the arm
- */
-public void widgetArmed(ArmEvent e);
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+import org.eclipse.swt.internal.SWTEventListener;
+
+/**
+ * Classes which implement this interface provide a method
+ * that deals with the event that is generated when a widget,
+ * such as a menu item, is armed.
+ * <p>
+ * After creating an instance of a class that implements
+ * this interface it can be added to a widget using the
+ * <code>addArmListener</code> method and removed using
+ * the <code>removeArmListener</code> method. When the
+ * widget is armed, the widgetArmed method will be invoked.
+ * </p>
+ *
+ * @see ArmEvent
+ */
+public interface ArmListener extends SWTEventListener {
+
+/**
+ * Sent when a widget is armed, or 'about to be selected'.
+ *
+ * @param e an event containing information about the arm
+ */
+public void widgetArmed(ArmEvent e);
+}
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
index 2edaedd813..502a130841 100755
--- 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
@@ -1,42 +1,42 @@
-package org.eclipse.swt.events;
-
-/*
+package org.eclipse.swt.events;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-/**
- * 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) {
-}
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+/**
+ * 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
index 6dde2b2614..84934d83a7 100755
--- 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
@@ -1,33 +1,33 @@
-package org.eclipse.swt.events;
-
-/*
+package org.eclipse.swt.events;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-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);
-}
-
-}
-
-
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+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
index fc44d77263..46679df5d8 100755
--- 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
@@ -1,44 +1,44 @@
-package org.eclipse.swt.events;
-
-/*
+package org.eclipse.swt.events;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-import org.eclipse.swt.internal.SWTEventListener;
-
-/**
- * Classes which implement this interface provide methods
- * that deal with the events that are generated by moving
- * and resizing controls.
- * <p>
- * After creating an instance of a class that implements
- * this interface it can be added to a control using the
- * <code>addControlListener</code> method and removed using
- * the <code>removeControlListener</code> method. When a
- * control is moved or resized, the appropriate method will
- * be invoked.
- * </p>
- *
- * @see ControlAdapter
- * @see ControlEvent
- */
-public interface ControlListener extends SWTEventListener {
-
-/**
- * Sent when the location (x, y) of a control changes relative
- * to its parent (or relative to the display, for <code>Shell</code>s).
- *
- * @param e an event containing information about the move
- */
-public void controlMoved(ControlEvent e);
-
-/**
- * Sent when the size (width, height) of a control changes.
- *
- * @param e an event containing information about the resize
- */
-public void controlResized(ControlEvent e);
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+import org.eclipse.swt.internal.SWTEventListener;
+
+/**
+ * Classes which implement this interface provide methods
+ * that deal with the events that are generated by moving
+ * and resizing controls.
+ * <p>
+ * After creating an instance of a class that implements
+ * this interface it can be added to a control using the
+ * <code>addControlListener</code> method and removed using
+ * the <code>removeControlListener</code> method. When a
+ * control is moved or resized, the appropriate method will
+ * be invoked.
+ * </p>
+ *
+ * @see ControlAdapter
+ * @see ControlEvent
+ */
+public interface ControlListener extends SWTEventListener {
+
+/**
+ * Sent when the location (x, y) of a control changes relative
+ * to its parent (or relative to the display, for <code>Shell</code>s).
+ *
+ * @param e an event containing information about the move
+ */
+public void controlMoved(ControlEvent e);
+
+/**
+ * Sent when the size (width, height) of a control changes.
+ *
+ * @param e an event containing information about the resize
+ */
+public void controlResized(ControlEvent e);
+}
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
index 28db666b51..9fcf3dfb02 100755
--- 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
@@ -1,32 +1,32 @@
-package org.eclipse.swt.events;
-
-/*
+package org.eclipse.swt.events;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-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);
-}
-
-}
-
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+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
index 1cc032f89b..cb381854e6 100755
--- 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
@@ -1,35 +1,35 @@
-package org.eclipse.swt.events;
-
-/*
+package org.eclipse.swt.events;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-import org.eclipse.swt.internal.SWTEventListener;
-
-/**
- * Classes which implement this interface provide a method
- * that deals with the event that is generated when a widget
- * is disposed.
- * <p>
- * After creating an instance of a class that implements
- * this interface it can be added to a widget using the
- * <code>addDisposeListener</code> method and removed using
- * the <code>removeDisposeListener</code> method. When a
- * widget is disposed, the widgetDisposed method will
- * be invoked.
- * </p>
- *
- * @see DisposeEvent
- */
-public interface DisposeListener extends SWTEventListener {
-
-/**
- * Sent when the widget is disposed.
- *
- * @param e an event containing information about the dispose
- */
-public void widgetDisposed(DisposeEvent e);
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+import org.eclipse.swt.internal.SWTEventListener;
+
+/**
+ * Classes which implement this interface provide a method
+ * that deals with the event that is generated when a widget
+ * is disposed.
+ * <p>
+ * After creating an instance of a class that implements
+ * this interface it can be added to a widget using the
+ * <code>addDisposeListener</code> method and removed using
+ * the <code>removeDisposeListener</code> method. When a
+ * widget is disposed, the widgetDisposed method will
+ * be invoked.
+ * </p>
+ *
+ * @see DisposeEvent
+ */
+public interface DisposeListener extends SWTEventListener {
+
+/**
+ * Sent when the widget is disposed.
+ *
+ * @param e an event containing information about the dispose
+ */
+public void widgetDisposed(DisposeEvent e);
+}
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
index 309480e9da..520689571e 100755
--- 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
@@ -1,41 +1,41 @@
-package org.eclipse.swt.events;
-
-/*
+package org.eclipse.swt.events;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-/**
- * 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) {
-}
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+/**
+ * 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
index 5dc9227e09..66fba93a51 100755
--- 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
@@ -1,32 +1,32 @@
-package org.eclipse.swt.events;
-
-/*
+package org.eclipse.swt.events;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-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);
-}
-
-}
-
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+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
index 75bb0c3692..74250720a6 100755
--- 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
@@ -1,44 +1,44 @@
-package org.eclipse.swt.events;
-
-/*
+package org.eclipse.swt.events;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-import org.eclipse.swt.internal.SWTEventListener;
-
-/**
- * Classes which implement this interface provide methods
- * that deal with the events that are generated as controls
- * gain and lose focus.
- * <p>
- * After creating an instance of a class that implements
- * this interface it can be added to a control using the
- * <code>addFocusListener</code> method and removed using
- * the <code>removeFocusListener</code> method. When a
- * control gains or loses focus, the appropriate method
- * will be invoked.
- * </p>
- *
- * @see FocusAdapter
- * @see FocusEvent
- */
-public interface FocusListener extends SWTEventListener {
-
-/**
- * Sent when a control gets focus.
- *
- * @param e an event containing information about the focus change
- */
-public void focusGained(FocusEvent e);
-
-/**
- * Sent when a control loses focus.
- *
- * @param e an event containing information about the focus change
- */
-public void focusLost(FocusEvent e);
-}
-
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+import org.eclipse.swt.internal.SWTEventListener;
+
+/**
+ * Classes which implement this interface provide methods
+ * that deal with the events that are generated as controls
+ * gain and lose focus.
+ * <p>
+ * After creating an instance of a class that implements
+ * this interface it can be added to a control using the
+ * <code>addFocusListener</code> method and removed using
+ * the <code>removeFocusListener</code> method. When a
+ * control gains or loses focus, the appropriate method
+ * will be invoked.
+ * </p>
+ *
+ * @see FocusAdapter
+ * @see FocusEvent
+ */
+public interface FocusListener extends SWTEventListener {
+
+/**
+ * Sent when a control gets focus.
+ *
+ * @param e an event containing information about the focus change
+ */
+public void focusGained(FocusEvent e);
+
+/**
+ * Sent when a control loses focus.
+ *
+ * @param e an event containing information about the focus change
+ */
+public void focusLost(FocusEvent e);
+}
+
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
index bbce9429f3..3fbb3e793a 100755
--- 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
@@ -1,32 +1,32 @@
-package org.eclipse.swt.events;
-
-/*
+package org.eclipse.swt.events;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-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);
-}
-
-}
-
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+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
index b1c6c6f8d1..0a301522c4 100755
--- 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
@@ -1,36 +1,36 @@
-package org.eclipse.swt.events;
-
-/*
+package org.eclipse.swt.events;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-import org.eclipse.swt.internal.SWTEventListener;
-
-/**
- * Classes which implement this interface provide a method
- * that deals with the event that is generated when help is
- * requested for a control, typically when the user presses F1.
- * <p>
- * After creating an instance of a class that implements
- * this interface it can be added to a control using the
- * <code>addHelpListener</code> method and removed using
- * the <code>removeHelpListener</code> method. When help
- * is requested for a control, the helpRequested method
- * will be invoked.
- * </p>
- *
- * @see HelpEvent
- */
-public interface HelpListener extends SWTEventListener {
-
-/**
- * Sent when help is requested for a control, typically
- * when the user presses F1.
- *
- * @param e an event containing information about the help
- */
-public void helpRequested(HelpEvent e);
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+import org.eclipse.swt.internal.SWTEventListener;
+
+/**
+ * Classes which implement this interface provide a method
+ * that deals with the event that is generated when help is
+ * requested for a control, typically when the user presses F1.
+ * <p>
+ * After creating an instance of a class that implements
+ * this interface it can be added to a control using the
+ * <code>addHelpListener</code> method and removed using
+ * the <code>removeHelpListener</code> method. When help
+ * is requested for a control, the helpRequested method
+ * will be invoked.
+ * </p>
+ *
+ * @see HelpEvent
+ */
+public interface HelpListener extends SWTEventListener {
+
+/**
+ * Sent when help is requested for a control, typically
+ * when the user presses F1.
+ *
+ * @param e an event containing information about the help
+ */
+public void helpRequested(HelpEvent e);
+}
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
index daeba33f89..2cbc44a3a0 100755
--- 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
@@ -1,41 +1,41 @@
-package org.eclipse.swt.events;
-
-/*
+package org.eclipse.swt.events;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-/**
- * 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) {
-}
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+/**
+ * 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
index 8142831776..8415afffed 100755
--- 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
@@ -1,62 +1,62 @@
-package org.eclipse.swt.events;
-
-/*
+package org.eclipse.swt.events;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-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.
- * This is the final character that results after all modifiers have been
- * applied. For example, when the user types Ctrl+A, the character value
- * is 0x01 (NUL). It is important that applications do not attempt to modify
- * the character value based on a stateMask (such as SWT.CTRL) or the resulting
- * character will not be correct.
- */
- public char character;
-
- /**
- * the key code of the key that was typed,
- * as defined by the key code constants in class <code>SWT</code>.
- * When the character field of the event is ambiguous, this field
- * contains the unicode value of the original character. For example,
- * typing Ctrl+M or Return both result in the character '\r' but the
- * keyCode field will also contain '\r' when Return was typed.
- *
- * @see SWT
- */
- 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;
-}
-
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+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.
+ * This is the final character that results after all modifiers have been
+ * applied. For example, when the user types Ctrl+A, the character value
+ * is 0x01 (NUL). It is important that applications do not attempt to modify
+ * the character value based on a stateMask (such as SWT.CTRL) or the resulting
+ * character will not be correct.
+ */
+ public char character;
+
+ /**
+ * the key code of the key that was typed,
+ * as defined by the key code constants in class <code>SWT</code>.
+ * When the character field of the event is ambiguous, this field
+ * contains the unicode value of the original character. For example,
+ * typing Ctrl+M or Return both result in the character '\r' but the
+ * keyCode field will also contain '\r' when Return was typed.
+ *
+ * @see SWT
+ */
+ 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
index 4e8270a9b5..61315d5536 100755
--- 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
@@ -1,43 +1,43 @@
-package org.eclipse.swt.events;
-
-/*
+package org.eclipse.swt.events;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-import org.eclipse.swt.internal.SWTEventListener;
-
-/**
- * Classes which implement this interface provide methods
- * that deal with the events that are generated as keys
- * are pressed on the system keyboard.
- * <p>
- * After creating an instance of a class that implements
- * this interface it can be added to a control using the
- * <code>addKeyListener</code> method and removed using
- * the <code>removeKeyListener</code> method. When a
- * key is pressed or released, the appropriate method will
- * be invoked.
- * </p>
- *
- * @see KeyAdapter
- * @see KeyEvent
- */
-public interface KeyListener extends SWTEventListener {
-
-/**
- * Sent when a key is pressed on the system keyboard.
- *
- * @param e an event containing information about the key press
- */
-public void keyPressed(KeyEvent e);
-
-/**
- * Sent when a key is released on the system keyboard.
- *
- * @param e an event containing information about the key release
- */
-public void keyReleased(KeyEvent e);
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+import org.eclipse.swt.internal.SWTEventListener;
+
+/**
+ * Classes which implement this interface provide methods
+ * that deal with the events that are generated as keys
+ * are pressed on the system keyboard.
+ * <p>
+ * After creating an instance of a class that implements
+ * this interface it can be added to a control using the
+ * <code>addKeyListener</code> method and removed using
+ * the <code>removeKeyListener</code> method. When a
+ * key is pressed or released, the appropriate method will
+ * be invoked.
+ * </p>
+ *
+ * @see KeyAdapter
+ * @see KeyEvent
+ */
+public interface KeyListener extends SWTEventListener {
+
+/**
+ * Sent when a key is pressed on the system keyboard.
+ *
+ * @param e an event containing information about the key press
+ */
+public void keyPressed(KeyEvent e);
+
+/**
+ * Sent when a key is released on the system keyboard.
+ *
+ * @param e an event containing information about the key release
+ */
+public void keyReleased(KeyEvent e);
+}
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
index 209a35353b..e089640377 100755
--- 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
@@ -1,41 +1,41 @@
-package org.eclipse.swt.events;
-
-/*
+package org.eclipse.swt.events;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-/**
- * 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) {
-}
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+/**
+ * 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
index 4f4878e5cd..1a836492ed 100755
--- 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
@@ -1,32 +1,32 @@
-package org.eclipse.swt.events;
-
-/*
+package org.eclipse.swt.events;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-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);
-}
-
-}
-
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+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
index 6dab527839..ae53b2ce09 100755
--- 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
@@ -1,42 +1,42 @@
-package org.eclipse.swt.events;
-
-/*
+package org.eclipse.swt.events;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-import org.eclipse.swt.internal.SWTEventListener;
-
-/**
- * Classes which implement this interface provide methods
- * that deal with the hiding and showing of menus.
- * <p>
- * After creating an instance of a class that implements
- * this interface it can be added to a 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 SWTEventListener {
-
-/**
- * Sent when a menu is hidden.
- *
- * @param e an event containing information about the menu operation
- */
-public void menuHidden(MenuEvent e);
-
-/**
- * Sent when a menu is shown.
- *
- * @param e an event containing information about the menu operation
- */
-public void menuShown(MenuEvent e);
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+import org.eclipse.swt.internal.SWTEventListener;
+
+/**
+ * Classes which implement this interface provide methods
+ * that deal with the hiding and showing of menus.
+ * <p>
+ * After creating an instance of a class that implements
+ * this interface it can be added to a 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 SWTEventListener {
+
+/**
+ * Sent when a menu is hidden.
+ *
+ * @param e an event containing information about the menu operation
+ */
+public void menuHidden(MenuEvent e);
+
+/**
+ * Sent when a menu is shown.
+ *
+ * @param e an event containing information about the menu operation
+ */
+public void menuShown(MenuEvent e);
+}
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
index 35c2637318..11f3575ed4 100755
--- 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
@@ -1,32 +1,32 @@
-package org.eclipse.swt.events;
-
-/*
+package org.eclipse.swt.events;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-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);
-}
-
-}
-
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+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
index a32f26e7c0..440b19e99b 100755
--- 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
@@ -1,34 +1,34 @@
-package org.eclipse.swt.events;
-
-/*
+package org.eclipse.swt.events;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-import org.eclipse.swt.internal.SWTEventListener;
-
-/**
- * Classes which implement this interface provide a method
- * that deals with the events that are generated when text
- * is modified.
- * <p>
- * After creating an instance of a class that implements
- * this interface it can be added to a text widget using the
- * <code>addModifyListener</code> method and removed using
- * the <code>removeModifyListener</code> method. When the
- * text is modified, the modifyText method will be invoked.
- * </p>
- *
- * @see ModifyEvent
- */
-public interface ModifyListener extends SWTEventListener {
-
-/**
- * Sent when the text is modified.
- *
- * @param e an event containing information about the modify
- */
-public void modifyText(ModifyEvent e);
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+import org.eclipse.swt.internal.SWTEventListener;
+
+/**
+ * Classes which implement this interface provide a method
+ * that deals with the events that are generated when text
+ * is modified.
+ * <p>
+ * After creating an instance of a class that implements
+ * this interface it can be added to a text widget using the
+ * <code>addModifyListener</code> method and removed using
+ * the <code>removeModifyListener</code> method. When the
+ * text is modified, the modifyText method will be invoked.
+ * </p>
+ *
+ * @see ModifyEvent
+ */
+public interface ModifyListener extends SWTEventListener {
+
+/**
+ * Sent when the text is modified.
+ *
+ * @param e an event containing information about the modify
+ */
+public void modifyText(ModifyEvent e);
+}
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
index 9ba388ea78..7f6bea71db 100755
--- 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
@@ -1,54 +1,54 @@
-package org.eclipse.swt.events;
-
-/*
+package org.eclipse.swt.events;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-/**
- * 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 org.eclipse.swt.widgets.Display#getDoubleClickTime
- */
-public void mouseDoubleClick(MouseEvent e) {
-}
-
-/**
- * Sent when a mouse button is pressed.
- * The default behavior is to do nothing.
- *
- * @param e an event containing information about the mouse button press
- */
-public void mouseDown(MouseEvent e) {
-}
-
-/**
- * Sent when a mouse button is released.
- * The default behavior is to do nothing.
- *
- * @param e an event containing information about the mouse button release
- */
-public void mouseUp(MouseEvent e) {
-}
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+/**
+ * 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 org.eclipse.swt.widgets.Display#getDoubleClickTime
+ */
+public void mouseDoubleClick(MouseEvent e) {
+}
+
+/**
+ * Sent when a mouse button is pressed.
+ * The default behavior is to do nothing.
+ *
+ * @param e an event containing information about the mouse button press
+ */
+public void mouseDown(MouseEvent e) {
+}
+
+/**
+ * Sent when a mouse button is released.
+ * The default behavior is to do nothing.
+ *
+ * @param e an event containing information about the mouse button release
+ */
+public void mouseUp(MouseEvent e) {
+}
+}
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
index a4b6c71ba1..b03ef7a048 100755
--- 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
@@ -1,70 +1,70 @@
-package org.eclipse.swt.events;
-
-/*
+package org.eclipse.swt.events;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-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;
-}
-
-}
-
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+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
index 704d58e1ff..35170ccd2e 100755
--- 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
@@ -1,53 +1,53 @@
-package org.eclipse.swt.events;
-
-/*
+package org.eclipse.swt.events;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-import org.eclipse.swt.internal.SWTEventListener;
-
-/**
- * Classes which implement this interface provide methods
- * that deal with the events that are generated as mouse buttons
- * are pressed.
- * <p>
- * After creating an instance of a class that implements
- * this interface it can be added to a control using the
- * <code>addMouseListener</code> method and removed using
- * the <code>removeMouseListener</code> method. When a
- * mouse button is pressed or released, the appropriate method
- * will be invoked.
- * </p>
- *
- * @see MouseAdapter
- * @see MouseEvent
- */
-public interface MouseListener extends SWTEventListener {
-
-/**
- * Sent when a mouse button is pressed twice within the
- * (operating system specified) double click period.
- *
- * @param e an event containing information about the mouse double click
- *
- * @see org.eclipse.swt.widgets.Display#getDoubleClickTime
- */
-public void mouseDoubleClick(MouseEvent e);
-
-/**
- * Sent when a mouse button is pressed.
- *
- * @param e an event containing information about the mouse button press
- */
-public void mouseDown(MouseEvent e);
-
-/**
- * Sent when a mouse button is released.
- *
- * @param e an event containing information about the mouse button release
- */
-public void mouseUp(MouseEvent e);
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+import org.eclipse.swt.internal.SWTEventListener;
+
+/**
+ * Classes which implement this interface provide methods
+ * that deal with the events that are generated as mouse buttons
+ * are pressed.
+ * <p>
+ * After creating an instance of a class that implements
+ * this interface it can be added to a control using the
+ * <code>addMouseListener</code> method and removed using
+ * the <code>removeMouseListener</code> method. When a
+ * mouse button is pressed or released, the appropriate method
+ * will be invoked.
+ * </p>
+ *
+ * @see MouseAdapter
+ * @see MouseEvent
+ */
+public interface MouseListener extends SWTEventListener {
+
+/**
+ * Sent when a mouse button is pressed twice within the
+ * (operating system specified) double click period.
+ *
+ * @param e an event containing information about the mouse double click
+ *
+ * @see org.eclipse.swt.widgets.Display#getDoubleClickTime
+ */
+public void mouseDoubleClick(MouseEvent e);
+
+/**
+ * Sent when a mouse button is pressed.
+ *
+ * @param e an event containing information about the mouse button press
+ */
+public void mouseDown(MouseEvent e);
+
+/**
+ * Sent when a mouse button is released.
+ *
+ * @param e an event containing information about the mouse button release
+ */
+public void mouseUp(MouseEvent e);
+}
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
index a1338afa50..838057ceb4 100755
--- 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
@@ -1,34 +1,34 @@
-package org.eclipse.swt.events;
-
-/*
+package org.eclipse.swt.events;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-import org.eclipse.swt.internal.SWTEventListener;
-
-/**
- * Classes which implement this interface provide a method
- * that deals with the events that are generated as the mouse
- * pointer moves.
- * <p>
- * After creating an instance of a class that implements
- * this interface it can be added to a control using the
- * <code>addMouseMoveListener</code> method and removed using
- * the <code>removeMouseMoveListener</code> method. As the
- * mouse moves, the mouseMove method will be invoked.
- * </p>
- *
- * @see MouseEvent
- */
-public interface MouseMoveListener extends SWTEventListener {
-
-/**
- * Sent when the mouse moves.
- *
- * @param e an event containing information about the mouse move
- */
-public void mouseMove(MouseEvent e);
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+import org.eclipse.swt.internal.SWTEventListener;
+
+/**
+ * Classes which implement this interface provide a method
+ * that deals with the events that are generated as the mouse
+ * pointer moves.
+ * <p>
+ * After creating an instance of a class that implements
+ * this interface it can be added to a control using the
+ * <code>addMouseMoveListener</code> method and removed using
+ * the <code>removeMouseMoveListener</code> method. As the
+ * mouse moves, the mouseMove method will be invoked.
+ * </p>
+ *
+ * @see MouseEvent
+ */
+public interface MouseMoveListener extends SWTEventListener {
+
+/**
+ * Sent when the mouse moves.
+ *
+ * @param e an event containing information about the mouse move
+ */
+public void mouseMove(MouseEvent e);
+}
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
index 172ff0f66c..1b5cbae896 100755
--- 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
@@ -1,55 +1,55 @@
-package org.eclipse.swt.events;
-
-/*
+package org.eclipse.swt.events;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-/**
- * 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) {
-}
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+/**
+ * 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
index b82e5eae9d..e6ba65f6fa 100755
--- 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
@@ -1,55 +1,55 @@
-package org.eclipse.swt.events;
-
-/*
+package org.eclipse.swt.events;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-import org.eclipse.swt.internal.SWTEventListener;
-
-/**
- * Classes which implement this interface provide methods
- * that deal with the events that are generated as the mouse
- * pointer passes (or hovers) over controls.
- * <p>
- * After creating an instance of a class that implements
- * this interface it can be added to a control using the
- * <code>addMouseTrackListener</code> method and removed using
- * the <code>removeMouseTrackListener</code> method. When the
- * mouse pointer passes into or out of the area of the screen
- * covered by a control or pauses while over a control, the
- * appropriate method will be invoked.
- * </p>
- *
- * @see MouseTrackAdapter
- * @see MouseEvent
- */
-public interface MouseTrackListener extends SWTEventListener {
-
-/**
- * Sent when the mouse pointer passes into the area of
- * the screen covered by a control.
- *
- * @param e an event containing information about the mouse enter
- */
-public void mouseEnter(MouseEvent e);
-
-/**
- * Sent when the mouse pointer passes out of the area of
- * the screen covered by a control.
- *
- * @param e an event containing information about the mouse exit
- */
-public void mouseExit(MouseEvent e);
-
-/**
- * Sent when the mouse pointer hovers (that is, stops moving
- * for an (operating system specified) period of time) over
- * a control.
- *
- * @param e an event containing information about the hover
- */
-public void mouseHover(MouseEvent e);
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+import org.eclipse.swt.internal.SWTEventListener;
+
+/**
+ * Classes which implement this interface provide methods
+ * that deal with the events that are generated as the mouse
+ * pointer passes (or hovers) over controls.
+ * <p>
+ * After creating an instance of a class that implements
+ * this interface it can be added to a control using the
+ * <code>addMouseTrackListener</code> method and removed using
+ * the <code>removeMouseTrackListener</code> method. When the
+ * mouse pointer passes into or out of the area of the screen
+ * covered by a control or pauses while over a control, the
+ * appropriate method will be invoked.
+ * </p>
+ *
+ * @see MouseTrackAdapter
+ * @see MouseEvent
+ */
+public interface MouseTrackListener extends SWTEventListener {
+
+/**
+ * Sent when the mouse pointer passes into the area of
+ * the screen covered by a control.
+ *
+ * @param e an event containing information about the mouse enter
+ */
+public void mouseEnter(MouseEvent e);
+
+/**
+ * Sent when the mouse pointer passes out of the area of
+ * the screen covered by a control.
+ *
+ * @param e an event containing information about the mouse exit
+ */
+public void mouseExit(MouseEvent e);
+
+/**
+ * Sent when the mouse pointer hovers (that is, stops moving
+ * for an (operating system specified) period of time) over
+ * a control.
+ *
+ * @param e an event containing information about the hover
+ */
+public void mouseHover(MouseEvent e);
}
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
index 3231819e8d..16b0ca2e5c 100755
--- 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
@@ -1,78 +1,78 @@
-package org.eclipse.swt.events;
-
-/*
+package org.eclipse.swt.events;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-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;
-}
-
-}
-
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+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
index f8ae91bc58..8e15870f60 100755
--- 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
@@ -1,35 +1,35 @@
-package org.eclipse.swt.events;
-
-/*
+package org.eclipse.swt.events;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-import org.eclipse.swt.internal.SWTEventListener;
-
-/**
- * Classes which implement this interface provide methods
- * that deal with the events that are generated when the
- * control needs to be painted.
- * <p>
- * After creating an instance of a class that implements
- * this interface it can be added to a control using the
- * <code>addPaintListener</code> method and removed using
- * the <code>removePaintListener</code> method. When a
- * paint event occurs, the paintControl method will be
- * invoked.
- * </p>
- *
- * @see PaintEvent
- */
-public interface PaintListener extends SWTEventListener {
-
-/**
- * Sent when a paint event occurs for the control.
- *
- * @param e an event containing information about the paint
- */
-public void paintControl(PaintEvent e);
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+import org.eclipse.swt.internal.SWTEventListener;
+
+/**
+ * Classes which implement this interface provide methods
+ * that deal with the events that are generated when the
+ * control needs to be painted.
+ * <p>
+ * After creating an instance of a class that implements
+ * this interface it can be added to a control using the
+ * <code>addPaintListener</code> method and removed using
+ * the <code>removePaintListener</code> method. When a
+ * paint event occurs, the paintControl method will be
+ * invoked.
+ * </p>
+ *
+ * @see PaintEvent
+ */
+public interface PaintListener extends SWTEventListener {
+
+/**
+ * Sent when a paint event occurs for the control.
+ *
+ * @param e an event containing information about the paint
+ */
+public void paintControl(PaintEvent e);
+}
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
index c4773a5f39..b5ffd2538d 100755
--- 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
@@ -1,41 +1,41 @@
-package org.eclipse.swt.events;
-
-/*
+package org.eclipse.swt.events;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-/**
- * 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) {
-}
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+/**
+ * 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
index 6567ebb84c..9973a17bdf 100755
--- 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
@@ -1,99 +1,99 @@
-package org.eclipse.swt.events;
-
-/*
+package org.eclipse.swt.events;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-import org.eclipse.swt.widgets.*;
-
-/**
- * Instances of this class are sent as a result of
- * widgets being selected.
- * <p>
- * Note: The fields that are filled in depend on the widget.
- * </p>
- *
- * @see SelectionListener
- */
-
-public class SelectionEvent extends TypedEvent {
-
- /**
- * the item that was selected
- */
- public Widget item;
-
- /**
- * extra detail information about the selection, depending on the widget
- * <p><b>Sash</b><ul>
- * <li>{@link SWT#DRAG}</li>
- * </ul></p><p><b>ScrollBar and Slider</b><ul>
- * <li>{@link SWT#DRAG}</li>
- * <li>{@link SWT#HOME}</li>
- * <li>{@link SWT#END}</li>
- * <li>{@link SWT#ARROW_DOWN}</li>
- * <li>{@link SWT#ARROW_UP}</li>
- * <li>{@link SWT#PAGE_DOWN}</li>
- * <li>{@link SWT#PAGE_UP}</li>
- * </ul></p><p><b>Table, Tree and TableTree</b><ul>
- * <li>{@link SWT#CHECK}</li>
- * </ul></p><p><b>CoolItem and ToolItem</b><ul>
- * <li>{@link SWT#ARROW}</li>
- * </ul></p>
- */
- public int detail;
-
- /**
- * the x location of the selected area
- */
- public int x;
-
- /**
- * the y location of selected area
- */
- public int y;
-
- /**
- * the width of selected area
- */
- public int width;
-
- /**
- * the height of selected area
- */
- public int height;
-
- /**
- * the state of the keyboard modifier keys at the time
- * the event was generated.
- */
- public int stateMask;
-
- /**
- * 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.stateMask = e.stateMask;
- this.doit = e.doit;
-}
-
-}
-
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+import org.eclipse.swt.widgets.*;
+
+/**
+ * Instances of this class are sent as a result of
+ * widgets being selected.
+ * <p>
+ * Note: The fields that are filled in depend on the widget.
+ * </p>
+ *
+ * @see SelectionListener
+ */
+
+public class SelectionEvent extends TypedEvent {
+
+ /**
+ * the item that was selected
+ */
+ public Widget item;
+
+ /**
+ * extra detail information about the selection, depending on the widget
+ * <p><b>Sash</b><ul>
+ * <li>{@link SWT#DRAG}</li>
+ * </ul></p><p><b>ScrollBar and Slider</b><ul>
+ * <li>{@link SWT#DRAG}</li>
+ * <li>{@link SWT#HOME}</li>
+ * <li>{@link SWT#END}</li>
+ * <li>{@link SWT#ARROW_DOWN}</li>
+ * <li>{@link SWT#ARROW_UP}</li>
+ * <li>{@link SWT#PAGE_DOWN}</li>
+ * <li>{@link SWT#PAGE_UP}</li>
+ * </ul></p><p><b>Table, Tree and TableTree</b><ul>
+ * <li>{@link SWT#CHECK}</li>
+ * </ul></p><p><b>CoolItem and ToolItem</b><ul>
+ * <li>{@link SWT#ARROW}</li>
+ * </ul></p>
+ */
+ public int detail;
+
+ /**
+ * the x location of the selected area
+ */
+ public int x;
+
+ /**
+ * the y location of selected area
+ */
+ public int y;
+
+ /**
+ * the width of selected area
+ */
+ public int width;
+
+ /**
+ * the height of selected area
+ */
+ public int height;
+
+ /**
+ * the state of the keyboard modifier keys at the time
+ * the event was generated.
+ */
+ public int stateMask;
+
+ /**
+ * 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.stateMask = e.stateMask;
+ 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
index a782fa697c..522abb37f3 100755
--- 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
@@ -1,52 +1,52 @@
-package org.eclipse.swt.events;
-
-/*
+package org.eclipse.swt.events;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-import org.eclipse.swt.internal.SWTEventListener;
-
-/**
- * Classes which implement this interface provide methods
- * that deal with the events that are generated when selection
- * occurs in a control.
- * <p>
- * After creating an instance of a class that implements
- * this interface it can be added to a control using the
- * <code>addSelectionListener</code> method and removed using
- * the <code>removeSelectionListener</code> method. When
- * selection occurs in a control the appropriate method
- * will be invoked.
- * </p>
- *
- * @see SelectionAdapter
- * @see SelectionEvent
- */
-public interface SelectionListener extends SWTEventListener {
-
-/**
- * Sent when selection occurs in the control.
- * <p>
- * For example, 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);
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+import org.eclipse.swt.internal.SWTEventListener;
+
+/**
+ * Classes which implement this interface provide methods
+ * that deal with the events that are generated when selection
+ * occurs in a control.
+ * <p>
+ * After creating an instance of a class that implements
+ * this interface it can be added to a control using the
+ * <code>addSelectionListener</code> method and removed using
+ * the <code>removeSelectionListener</code> method. When
+ * selection occurs in a control the appropriate method
+ * will be invoked.
+ * </p>
+ *
+ * @see SelectionAdapter
+ * @see SelectionEvent
+ */
+public interface SelectionListener extends SWTEventListener {
+
+/**
+ * Sent when selection occurs in the control.
+ * <p>
+ * For example, 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
index 99af81306d..edbbdaef53 100755
--- 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
@@ -1,68 +1,68 @@
-package org.eclipse.swt.events;
-
-/*
+package org.eclipse.swt.events;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-/**
- * 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) {
-}
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+/**
+ * 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
index 7bd0a87eed..5156f48443 100755
--- 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
@@ -1,32 +1,32 @@
-package org.eclipse.swt.events;
-
-/*
+package org.eclipse.swt.events;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-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;
-}
-
-}
-
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+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
index d118fde7be..85ffb47973 100755
--- 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
@@ -1,63 +1,63 @@
-package org.eclipse.swt.events;
-
-/*
+package org.eclipse.swt.events;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-import org.eclipse.swt.internal.SWTEventListener;
-
-/**
- * Classes which implement this interface provide methods
- * that deal with changes in state of <code>Shell</code>s.
- * <p>
- * After creating an instance of a class that implements
- * this interface it can be added to a 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 SWTEventListener {
-
-/**
- * Sent when a shell becomes the active window.
- *
- * @param e an event containing information about the activation
- */
-public void shellActivated(ShellEvent e);
-
-/**
- * Sent when a shell is closed.
- *
- * @param e an event containing information about the close
- */
-public void shellClosed(ShellEvent e);
-
-/**
- * Sent when a shell stops being the active window.
- *
- * @param e an event containing information about the deactivation
- */
-public void shellDeactivated(ShellEvent e);
-
-/**
- * Sent when a shell is un-minimized.
- *
- * @param e an event containing information about the un-minimization
- */
-public void shellDeiconified(ShellEvent e);
-
-/**
- * Sent when a shell is minimized.
- *
- * @param e an event containing information about the minimization
- */
-public void shellIconified(ShellEvent e);
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+import org.eclipse.swt.internal.SWTEventListener;
+
+/**
+ * Classes which implement this interface provide methods
+ * that deal with changes in state of <code>Shell</code>s.
+ * <p>
+ * After creating an instance of a class that implements
+ * this interface it can be added to a 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 SWTEventListener {
+
+/**
+ * Sent when a shell becomes the active window.
+ *
+ * @param e an event containing information about the activation
+ */
+public void shellActivated(ShellEvent e);
+
+/**
+ * Sent when a shell is closed.
+ *
+ * @param e an event containing information about the close
+ */
+public void shellClosed(ShellEvent e);
+
+/**
+ * Sent when a shell stops being the active window.
+ *
+ * @param e an event containing information about the deactivation
+ */
+public void shellDeactivated(ShellEvent e);
+
+/**
+ * Sent when a shell is un-minimized.
+ *
+ * @param e an event containing information about the un-minimization
+ */
+public void shellDeiconified(ShellEvent e);
+
+/**
+ * Sent when a shell is minimized.
+ *
+ * @param e an event containing information about the minimization
+ */
+public void shellIconified(ShellEvent e);
+}
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
index 90181c3ec1..18faee5489 100755
--- 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
@@ -1,123 +1,123 @@
-package org.eclipse.swt.events;
-
-/*
+package org.eclipse.swt.events;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-import org.eclipse.swt.widgets.*;
-
-/**
- * Instances of this class are sent as a result of
- * widget traversal actions.
- * <p>
- * The traversal event allows fine control over keyboard traversal
- * in a control both to implement traversal and override the default
- * traversal behavior defined by the system. This is achieved using
- * two fields, <code>detail</code> and <code>doit</code>.
- * </p><p>
- * When a control is traversed, a traverse event is sent. The detail
- * describes the type of traversal and the doit indicates the default
- * behavior of the system. For example, when a right arrow key is pressed
- * in a text control, the detail field is <code>TRAVERSE_ARROW_NEXT</code>
- * and the doit field is <code>false</code>, indicating that the system
- * will not traverse to the next tab item and the arrow key will be
- * delivered to the text control. If the same key is pressed in a radio
- * button, the doit field will be <code>true</code>, indicating that
- * traversal is to proceed to the next tab item, possibly another
- * radio button in the group and that the arrow key is not be delivered
- * to the radio button.
- * </p><p>
- * How can the traversal event be used to implement traversal?
- * When a tab key is pressed in a canvas, the detail field will be
- * <code>TRAVERSE_TAB_NEXT</code> and the doit field will be
- * <code>false</code>. The default behavior of the system is to
- * provide no traversal for canvas controls. This means that by
- * default in a canvas, a key listener will see every key that
- * user types, including traversal keys. To understand why this
- * is so, it is important to understand that only the widget implementor
- * can decide which traversal is appropriate for the widget. Returning
- * to the <code>TRAVERSE_TAB_NEXT</code> example, a text widget implemented
- * by a canvas, would typically want to use the tab key to insert a
- * tab character into the widget. A list widget implementation, on the
- * other hand, would like the system default traversal behavior. Using
- * only the doit flag, both implementations are possible. The text widget
- * implementor sets doit to <code>false</false>, ensuring that the system
- * will not traverse and that the tab key will be delivered to key listeners.
- * The list widget implementor sets doit to <code>true</code>, indicating
- * that the system should perform tab traversal and that the key should not
- * be delivered to the list widget.
- * </p><p>
- * How can the traversal event be used to override system traversal?
- * When the return key is pressed in a single line text control, the
- * detail field is be <code>TRAVERSE_RETURN</code> and the doit field
- * is <code>true</code>. This means that the return key will processed
- * by the default button, not the text widget. If the text widget has
- * a default selection listener, it will not run because the return key
- * will be processed by the default button. Imagine that the text control
- * is being used as an in-place editor and return is used to dispose the
- * widget. Setting doit to <code>false</code> will stop the system from
- * activating the default button but the key will be delivered to the text
- * control, running the key and selection listeners for the text. How
- * can <code>TRAVERSE_RETURN be implemented so that the default button
- * will not be activated and the text widget will not see the return key?
- * This is achieved by setting doit to <code>true</code>, and the detail
- * to <code>TRAVERSE_NONE</code>.
- * </p><p>
- * Note: A widget implementor will typically implement traversal using
- * only the doit flag to either enable or disable system traversal.
- * </p>
- *
- * @see TraverseListener
- */
-
-public class TraverseEvent extends KeyEvent {
-
- /**
- * the type of traversal
- * <p><ul>
- * <li>{@link SWT#TRAVERSE_NONE}</li>
- * <li>{@link SWT#TRAVERSE_ESCAPE}</li>
- * <li>{@link SWT#TRAVERSE_RETURN}</li>
- * <li>{@link SWT#TRAVERSE_TAB_NEXT}</li>
- * <li>{@link SWT#TRAVERSE_TAB_PREVIOUS}</li>
- * <li>{@link SWT#TRAVERSE_ARROW_NEXT}</li>
- * <li>{@link SWT#TRAVERSE_ARROW_PREVIOUS}</li>
- * <li>{@link SWT#TRAVERSE_MNEMONIC}</li>
- * <li>{@link SWT#TRAVERSE_PAGE_NEXT}</li>
- * <li>{@link SWT#TRAVERSE_PAGE_PREVIOUS}</li>
- * </ul></p>
- *
- * Setting this field will change the type of traversal.
- * For example, setting the detail to <code>TRAVERSE_NONE</code>
- * causes no traversal action to be taked. The traversal detail,
- * in conjuction with the <code>doit</code> field can be useful
- * when overriding the default traversal mechanism for a control.
- *
- */
- public int detail;
-
- /**
- * a flag indicating whether the operation should be allowed.
- * Setting this field to <code>false</code> will cancel the operation
- * and allow the traversal key stroke to be delivered to the control.
- * A value of true indicates that the traversal, described by the
- * traversal <code>detail</code> is to be performed.
- */
- 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;
-}
-
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+import org.eclipse.swt.widgets.*;
+
+/**
+ * Instances of this class are sent as a result of
+ * widget traversal actions.
+ * <p>
+ * The traversal event allows fine control over keyboard traversal
+ * in a control both to implement traversal and override the default
+ * traversal behavior defined by the system. This is achieved using
+ * two fields, <code>detail</code> and <code>doit</code>.
+ * </p><p>
+ * When a control is traversed, a traverse event is sent. The detail
+ * describes the type of traversal and the doit indicates the default
+ * behavior of the system. For example, when a right arrow key is pressed
+ * in a text control, the detail field is <code>TRAVERSE_ARROW_NEXT</code>
+ * and the doit field is <code>false</code>, indicating that the system
+ * will not traverse to the next tab item and the arrow key will be
+ * delivered to the text control. If the same key is pressed in a radio
+ * button, the doit field will be <code>true</code>, indicating that
+ * traversal is to proceed to the next tab item, possibly another
+ * radio button in the group and that the arrow key is not be delivered
+ * to the radio button.
+ * </p><p>
+ * How can the traversal event be used to implement traversal?
+ * When a tab key is pressed in a canvas, the detail field will be
+ * <code>TRAVERSE_TAB_NEXT</code> and the doit field will be
+ * <code>false</code>. The default behavior of the system is to
+ * provide no traversal for canvas controls. This means that by
+ * default in a canvas, a key listener will see every key that
+ * user types, including traversal keys. To understand why this
+ * is so, it is important to understand that only the widget implementor
+ * can decide which traversal is appropriate for the widget. Returning
+ * to the <code>TRAVERSE_TAB_NEXT</code> example, a text widget implemented
+ * by a canvas, would typically want to use the tab key to insert a
+ * tab character into the widget. A list widget implementation, on the
+ * other hand, would like the system default traversal behavior. Using
+ * only the doit flag, both implementations are possible. The text widget
+ * implementor sets doit to <code>false</false>, ensuring that the system
+ * will not traverse and that the tab key will be delivered to key listeners.
+ * The list widget implementor sets doit to <code>true</code>, indicating
+ * that the system should perform tab traversal and that the key should not
+ * be delivered to the list widget.
+ * </p><p>
+ * How can the traversal event be used to override system traversal?
+ * When the return key is pressed in a single line text control, the
+ * detail field is be <code>TRAVERSE_RETURN</code> and the doit field
+ * is <code>true</code>. This means that the return key will processed
+ * by the default button, not the text widget. If the text widget has
+ * a default selection listener, it will not run because the return key
+ * will be processed by the default button. Imagine that the text control
+ * is being used as an in-place editor and return is used to dispose the
+ * widget. Setting doit to <code>false</code> will stop the system from
+ * activating the default button but the key will be delivered to the text
+ * control, running the key and selection listeners for the text. How
+ * can <code>TRAVERSE_RETURN be implemented so that the default button
+ * will not be activated and the text widget will not see the return key?
+ * This is achieved by setting doit to <code>true</code>, and the detail
+ * to <code>TRAVERSE_NONE</code>.
+ * </p><p>
+ * Note: A widget implementor will typically implement traversal using
+ * only the doit flag to either enable or disable system traversal.
+ * </p>
+ *
+ * @see TraverseListener
+ */
+
+public class TraverseEvent extends KeyEvent {
+
+ /**
+ * the type of traversal
+ * <p><ul>
+ * <li>{@link SWT#TRAVERSE_NONE}</li>
+ * <li>{@link SWT#TRAVERSE_ESCAPE}</li>
+ * <li>{@link SWT#TRAVERSE_RETURN}</li>
+ * <li>{@link SWT#TRAVERSE_TAB_NEXT}</li>
+ * <li>{@link SWT#TRAVERSE_TAB_PREVIOUS}</li>
+ * <li>{@link SWT#TRAVERSE_ARROW_NEXT}</li>
+ * <li>{@link SWT#TRAVERSE_ARROW_PREVIOUS}</li>
+ * <li>{@link SWT#TRAVERSE_MNEMONIC}</li>
+ * <li>{@link SWT#TRAVERSE_PAGE_NEXT}</li>
+ * <li>{@link SWT#TRAVERSE_PAGE_PREVIOUS}</li>
+ * </ul></p>
+ *
+ * Setting this field will change the type of traversal.
+ * For example, setting the detail to <code>TRAVERSE_NONE</code>
+ * causes no traversal action to be taked. The traversal detail,
+ * in conjuction with the <code>doit</code> field can be useful
+ * when overriding the default traversal mechanism for a control.
+ *
+ */
+ public int detail;
+
+ /**
+ * a flag indicating whether the operation should be allowed.
+ * Setting this field to <code>false</code> will cancel the operation
+ * and allow the traversal key stroke to be delivered to the control.
+ * A value of true indicates that the traversal, described by the
+ * traversal <code>detail</code> is to be performed.
+ */
+ 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;
+}
+
}
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
index 95d4d94714..a8c6bd3a95 100755
--- 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
@@ -1,42 +1,42 @@
-package org.eclipse.swt.events;
-
-/*
+package org.eclipse.swt.events;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-import org.eclipse.swt.internal.SWTEventListener;
-
-/**
- * Classes which implement this interface provide a method
- * that deals with the events that are generated when a
- * traverse event occurs in a control.
- * <p>
- * After creating an instance of a class that implements
- * this interface it can be added to a control using the
- * <code>addTraverseListener</code> method and removed using
- * the <code>removeTraverseListener</code> method. When a
- * traverse event occurs in a control, the keyTraversed method
- * will be invoked.
- * </p>
- *
- * @see TraverseEvent
- */
-public interface TraverseListener extends SWTEventListener {
-
-/**
- * Sent when a traverse event occurs in a control.
- * <p>
- * A traverse event occurs when the user presses a traversal
- * key. Traversal keys are typically tab and arrow keys, along
- * with certain other keys on some platforms. Traversal key
- * constants beginning with <code>TRAVERSE_</code> are defined
- * in the <code>SWT</code> class.
- * </p>
- *
- * @param e an event containing information about the traverse
- */
-public void keyTraversed(TraverseEvent e);
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+import org.eclipse.swt.internal.SWTEventListener;
+
+/**
+ * Classes which implement this interface provide a method
+ * that deals with the events that are generated when a
+ * traverse event occurs in a control.
+ * <p>
+ * After creating an instance of a class that implements
+ * this interface it can be added to a control using the
+ * <code>addTraverseListener</code> method and removed using
+ * the <code>removeTraverseListener</code> method. When a
+ * traverse event occurs in a control, the keyTraversed method
+ * will be invoked.
+ * </p>
+ *
+ * @see TraverseEvent
+ */
+public interface TraverseListener extends SWTEventListener {
+
+/**
+ * Sent when a traverse event occurs in a control.
+ * <p>
+ * A traverse event occurs when the user presses a traversal
+ * key. Traversal keys are typically tab and arrow keys, along
+ * with certain other keys on some platforms. Traversal key
+ * constants beginning with <code>TRAVERSE_</code> are defined
+ * in the <code>SWT</code> class.
+ * </p>
+ *
+ * @param e an event containing information about the traverse
+ */
+public void keyTraversed(TraverseEvent e);
}
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
index f1da6f472c..cfa2817bfb 100755
--- 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
@@ -1,41 +1,41 @@
-package org.eclipse.swt.events;
-
-/*
+package org.eclipse.swt.events;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-/**
- * 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) {
-}
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+/**
+ * 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
index 0776d19dae..23634de5a0 100755
--- 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
@@ -1,32 +1,32 @@
-package org.eclipse.swt.events;
-
-/*
+package org.eclipse.swt.events;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-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);
-}
-
-}
-
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+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
index 82039e035a..b910e12ea4 100755
--- 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
@@ -1,43 +1,43 @@
-package org.eclipse.swt.events;
-
-/*
+package org.eclipse.swt.events;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-import org.eclipse.swt.internal.SWTEventListener;
-
-/**
- * Classes which implement this interface provide methods
- * that deal with the expanding and collapsing of tree
- * branches.
- * <p>
- * After creating an instance of a class that implements
- * this interface it can be added to a 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 SWTEventListener {
-
-/**
- * Sent when a tree branch is collapsed.
- *
- * @param e an event containing information about the tree operation
- */
-public void treeCollapsed(TreeEvent e);
-
-/**
- * Sent when a tree branch is expanded.
- *
- * @param e an event containing information about the tree operation
- */
-public void treeExpanded(TreeEvent e);
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+import org.eclipse.swt.internal.SWTEventListener;
+
+/**
+ * Classes which implement this interface provide methods
+ * that deal with the expanding and collapsing of tree
+ * branches.
+ * <p>
+ * After creating an instance of a class that implements
+ * this interface it can be added to a 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 SWTEventListener {
+
+/**
+ * Sent when a tree branch is collapsed.
+ *
+ * @param e an event containing information about the tree operation
+ */
+public void treeCollapsed(TreeEvent e);
+
+/**
+ * Sent when a tree branch is expanded.
+ *
+ * @param e an event containing information about the tree operation
+ */
+public void treeExpanded(TreeEvent e);
+}
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
index bea11e8879..7d90cf6ad0 100755
--- 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
@@ -1,71 +1,71 @@
-package org.eclipse.swt.events;
-
-/*
+package org.eclipse.swt.events;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-import org.eclipse.swt.widgets.*;
-import org.eclipse.swt.internal.SWTEventObject;
-
-/**
- * This is the super class for all typed event classes provided
- * by SWT. Typed events contain particular information which is
- * applicable to the event occurance.
- *
- * @see org.eclipse.swt.widgets.Event
- */
-public class TypedEvent extends SWTEventObject {
-
- /**
- * the display where the event occurred
- *
- * @since 2.0
- */
- public Display display;
-
- /**
- * the widget that issued the event
- */
- public Widget widget;
-
- /**
- * the time that the event occurred.
- *
- * NOTE: This field is an unsigned integer and should
- * be AND'ed with 0xFFFFFFFFL so that it can be treated
- * as a signed long.
- */
- public int time;
-
- /**
- * a field for application use
- */
- public Object data;
-
-/**
- * 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.display = e.display;
- this.widget = e.widget;
- this.time = e.time;
- this.data = e.data;
-}
-
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+import org.eclipse.swt.widgets.*;
+import org.eclipse.swt.internal.SWTEventObject;
+
+/**
+ * This is the super class for all typed event classes provided
+ * by SWT. Typed events contain particular information which is
+ * applicable to the event occurance.
+ *
+ * @see org.eclipse.swt.widgets.Event
+ */
+public class TypedEvent extends SWTEventObject {
+
+ /**
+ * the display where the event occurred
+ *
+ * @since 2.0
+ */
+ public Display display;
+
+ /**
+ * the widget that issued the event
+ */
+ public Widget widget;
+
+ /**
+ * the time that the event occurred.
+ *
+ * NOTE: This field is an unsigned integer and should
+ * be AND'ed with 0xFFFFFFFFL so that it can be treated
+ * as a signed long.
+ */
+ public int time;
+
+ /**
+ * a field for application use
+ */
+ public Object data;
+
+/**
+ * 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.display = e.display;
+ this.widget = e.widget;
+ this.time = e.time;
+ this.data = e.data;
+}
+
+}
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
index b5a0e1bfca..6281209110 100755
--- 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
@@ -1,57 +1,57 @@
-package org.eclipse.swt.events;
-
-/*
+package org.eclipse.swt.events;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-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.
- * Setting these fields has no effect.
- */
- public int start, end;
-
- /**
- * the new text that will be inserted.
- * Setting this field will change the text that is about to
- * be inserted or deleted.
- */
- public String text;
-
- /**
- * a flag indicating whether the operation should be allowed.
- * Setting this field to false will cancel the operation.
- */
- 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;
-}
-
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+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.
+ * Setting these fields has no effect.
+ */
+ public int start, end;
+
+ /**
+ * the new text that will be inserted.
+ * Setting this field will change the text that is about to
+ * be inserted or deleted.
+ */
+ public String text;
+
+ /**
+ * a flag indicating whether the operation should be allowed.
+ * Setting this field to false will cancel the operation.
+ */
+ 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
index cbffca9bad..2a2fb493ea 100755
--- 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
@@ -1,41 +1,41 @@
-package org.eclipse.swt.events;
-
-/*
+package org.eclipse.swt.events;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-import org.eclipse.swt.internal.SWTEventListener;
-
-/**
- * Classes which implement this interface provide a method
- * that deals with the events that are generated when text
- * is about to be modified.
- * <p>
- * After creating an instance of a class that implements
- * this interface it can be added to a text 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 SWTEventListener {
-
-/**
- * Sent when the text is about to be modified.
- * <p>
- * A verify event occurs after the user has done something
- * to modify the text (typically typed a key), but before
- * the text is modified. The doit field in the verify event
- * indicates whether or not to modify the text.
- * </p>
- *
- * @param e an event containing information about the verify
- */
-public void verifyText(VerifyEvent e);
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+import org.eclipse.swt.internal.SWTEventListener;
+
+/**
+ * Classes which implement this interface provide a method
+ * that deals with the events that are generated when text
+ * is about to be modified.
+ * <p>
+ * After creating an instance of a class that implements
+ * this interface it can be added to a text 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 SWTEventListener {
+
+/**
+ * Sent when the text is about to be modified.
+ * <p>
+ * A verify event occurs after the user has done something
+ * to modify the text (typically typed a key), but before
+ * the text is modified. The doit field in the verify event
+ * indicates whether or not to modify the text.
+ * </p>
+ *
+ * @param e an event containing information about the verify
+ */
+public void verifyText(VerifyEvent e);
+}
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
index 903e9df135..cb647efdba 100755
--- 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
@@ -1,47 +1,47 @@
-package org.eclipse.swt.graphics;
-
-/*
+package org.eclipse.swt.graphics;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-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);
-
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+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);
+
}
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
index e7587a4fe7..6d663d23b9 100755
--- 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
@@ -1,3551 +1,3551 @@
-package org.eclipse.swt.graphics;
-
-/*
+package org.eclipse.swt.graphics;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-import java.io.*;
-import org.eclipse.swt.*;
-import org.eclipse.swt.internal.CloneableCompatibility;
-
-/**
- * Instances of this class are device-independent descriptions
- * of images. They are typically used as an intermediate format
- * between loading from or writing to streams and creating an
- * <code>Image</code>.
- * <p>
- * Note that the public fields <code>x</code>, <code>y</code>,
- * <code>disposalMethod</code> and <code>delayTime</code> are
- * typically only used when the image is in a set of images used
- * for animation.
- * </p>
- *
- * @see Image
- * @see ImageLoader
- */
-
-public final class ImageData implements CloneableCompatibility {
-
- /**
- * the width of the image, in pixels
- */
- public int width;
-
- /**
- * the height of the image, in pixels
- */
- public int height;
-
- /**
- * the color depth of the image, in bits per pixel
- * <p>
- * Note that a depth of 8 or less does not necessary
- * mean that the image is palette indexed, or
- * conversely that a depth greater than 8 means that
- * the image is direct color. Check the associated
- * PaletteData's isDirect field for such determinations.
- */
- public int depth;
-
- /**
- * the scanline padding
- * <p>
- * If one scanline of the image is not a multiple of
- * this number, it will be padded with zeros until it is.
- * </p>
- */
- public int scanlinePad;
-
- /**
- * the number of bytes per scanline
- * <p>
- * This is a multiple of the scanline padding.
- * </p>
- */
- public int bytesPerLine;
-
- /**
- * the pixel data of the image
- * <p>
- * Note that for 16 bit depth images the pixel data is stored
- * in least significant byte order; however, for 24bit and
- * 32bit depth images the pixel data is stored in most
- * significant byte order.
- * </p>
- */
- public byte[] data;
-
- /**
- * the color table for the image
- */
- public PaletteData palette;
-
- /**
- * the transparent pixel
- * <p>
- * Pixels with this value are transparent.
- * </p><p>
- * The default is -1 which means 'no transparent pixel'.
- * </p>
- */
- public int transparentPixel;
-
- /**
- * icon-specific field containing the data from the icon mask
- * <p>
- * This is a 1 bit bitmap stored with the most significant
- * bit first. The number of bytes per scanline is
- * '((width + 7) / 8 + (maskPad - 1)) / maskPad * maskPad'.
- * </p><p>
- * The default is null which means 'no transparency mask'.
- * </p>
- */
- public byte[] maskData;
-
- /**
- * icon-specific field containing the scanline pad of the mask
- * <p>
- * If one scanline of the transparency mask is not a
- * multiple of this number, it will be padded with zeros until
- * it is.
- * </p>
- */
- public int maskPad;
-
- /**
- * the alpha data of the image
- * <p>
- * Every pixel can have an <em>alpha blending</em> value that
- * varies from 0, meaning fully transparent, to 255 meaning
- * fully opaque. The number of bytes per scanline is
- * 'width'.
- * </p>
- */
- public byte[] alphaData;
-
- /**
- * the global alpha value to be used for every pixel
- * <p>
- * If this value is set, the <code>alphaData</code> field
- * is ignored and when the image is rendered each pixel
- * will be blended with the background an amount
- * proportional to this value.
- * </p><p>
- * The default is -1 which means 'no global alpha value'
- * </p>
- */
- public int alpha;
-
- /**
- * the type of file 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;
-
- /**
- * Arbitrary channel width data to 8-bit conversion table
- */
- static final byte[][] ANY_TO_EIGHT = new byte[9][];
- static {
- for (int b = 0; b < 9; ++b) {
- byte[] data = ANY_TO_EIGHT[b] = new byte[1 << b];
- if (b == 0) continue;
- int inc = 0;
- for (int bit = 0x10000; (bit >>= b) != 0;) inc |= bit;
- for (int v = 0, p = 0; v < 0x10000; v+= inc) data[p++] = (byte)(v >> 8);
- }
- }
- static final byte[] ONE_TO_ONE_MAPPING = ANY_TO_EIGHT[8];
-
- /**
- * Scaled 8x8 Bayer dither matrix
- */
- static final int[][] DITHER_MATRIX = {
- { 0xfc0000, 0x7c0000, 0xdc0000, 0x5c0000, 0xf40000, 0x740000, 0xd40000, 0x540000 },
- { 0x3c0000, 0xbc0000, 0x1c0000, 0x9c0000, 0x340000, 0xb40000, 0x140000, 0x940000 },
- { 0xcc0000, 0x4c0000, 0xec0000, 0x6c0000, 0xc40000, 0x440000, 0xe40000, 0x640000 },
- { 0x0c0000, 0x8c0000, 0x2c0000, 0xac0000, 0x040000, 0x840000, 0x240000, 0xa40000 },
- { 0xf00000, 0x700000, 0xd00000, 0x500000, 0xf80000, 0x780000, 0xd80000, 0x580000 },
- { 0x300000, 0xb00000, 0x100000, 0x900000, 0x380000, 0xb80000, 0x180000, 0x980000 },
- { 0xc00000, 0x400000, 0xe00000, 0x600000, 0xc80000, 0x480000, 0xe80000, 0x680000 },
- { 0x000000, 0x800000, 0x200000, 0xa00000, 0x080000, 0x880000, 0x280000, 0xa80000 }
- };
-
-/**
- * Constructs a new, empty ImageData with the given width, height,
- * depth and palette. The data will be initialized to an (all zero)
- * array of the appropriate size.
- *
- * @param width the width of the image
- * @param height the height of the image
- * @param depth the depth of the image
- * @param palette the palette of the image (must not be null)
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_INVALID_ARGUMENT - if the width or height is negative</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 IndexOutOfBoundsException if getWidth is too large
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if pixels is null</li>
- * <li>ERROR_INVALID_ARGUMENT - if x or y is out of bounds</li>
- * <li>ERROR_INVALID_ARGUMENT - if getWidth is negative</li>
- * </ul>
- */
-public void getAlphas(int x, int y, int getWidth, byte[] alphas, int startIndex) {
- if (alphas == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
- if (getWidth < 0 || x >= width || y >= height || x < 0 || y < 0) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
- if (getWidth == 0) return;
-
- if (alphaData == null) {
- int endIndex = startIndex + getWidth;
- for (int i = startIndex; i < endIndex; i++) {
- alphas[i] = (byte)255;
- }
- return;
- }
- // may throw an IndexOutOfBoundsException
- System.arraycopy(alphaData, y * width + x, alphas, startIndex, getWidth);
-}
-
-/**
- * Returns the pixel value at offset <code>x</code> in
- * scanline <code>y</code> in the receiver's data.
- *
- * @param x the x position of the pixel to get
- * @param y the y position of the pixel to get
- * @return the pixel at the given coordinates
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_INVALID_ARGUMENT - if either argument is out of bounds</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_UNSUPPORTED_DEPTH if the depth is not one of 1, 2, 4, 8, 16, 24 or 32</li>
- * </ul>
- */
-public int getPixel(int x, int y) {
- if (x >= width || y >= height || x < 0 || y < 0) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
- int index;
- int theByte;
- int mask;
- 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 IndexOutOfBoundsException if getWidth is too large
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if pixels is null</li>
- * <li>ERROR_INVALID_ARGUMENT - if x or y is out of bounds</li>
- * <li>ERROR_INVALID_ARGUMENT - if getWidth is negative</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_UNSUPPORTED_DEPTH - if the depth is not one of 1, 2, 4 or 8
- * (For higher depths, use the int[] version of this method.)</li>
- * </ul>
- */
-public void getPixels(int x, int y, int getWidth, byte[] pixels, int startIndex) {
- if (pixels == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
- if (getWidth < 0 || x >= width || y >= height || x < 0 || y < 0) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
- if (getWidth == 0) return;
- int index;
- int theByte;
- int mask = 0;
- int n = getWidth;
- int i = startIndex;
- int srcX = x, srcY = y;
- 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 IndexOutOfBoundsException if getWidth is too large
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if pixels is null</li>
- * <li>ERROR_INVALID_ARGUMENT - if x or y is out of bounds</li>
- * <li>ERROR_INVALID_ARGUMENT - if getWidth is negative</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_UNSUPPORTED_DEPTH - if the depth is not one of 1, 2, 4, 8, 16, 24 or 32</li>
- * </ul>
- */
-public void getPixels(int x, int y, int getWidth, int[] pixels, int startIndex) {
- if (pixels == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
- if (getWidth < 0 || x >= width || y >= height || x < 0 || y < 0) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
- if (getWidth == 0) return;
- int index;
- int theByte;
- int mask;
- int n = getWidth;
- int i = startIndex;
- int srcX = x, srcY = y;
- 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 the byte order of the receiver.
- *
- * @return MSB_FIRST or LSB_FIRST
- */
-int getByteOrder() {
- return depth != 16 ? MSB_FIRST : LSB_FIRST;
-}
-
-/**
- * Returns a copy of the receiver which has been stretched or
- * shrunk to the specified size. If either the width or height
- * is negative, the resulting image will be inverted in the
- * associated axis.
- *
- * @param width the width of the new ImageData
- * @param height the height of the new ImageData
- * @return a scaled copy of the image
- */
-public ImageData scaledTo(int width, int height) {
- /* Create a destination image with no data */
- final boolean flipX = (width < 0);
- if (flipX) width = - width;
- final boolean flipY = (height < 0);
- if (flipY) height = - height;
-
- ImageData dest = new ImageData(
- width, height, depth, palette,
- scanlinePad, null, 0, null,
- null, -1, transparentPixel, type,
- x, y, disposalMethod, delayTime);
-
- /* Scale the image contents */
- if (palette.isDirect) blit(BLIT_SRC,
- this.data, this.depth, this.bytesPerLine, this.getByteOrder(), 0, 0, this.width, this.height, 0, 0, 0,
- ALPHA_OPAQUE, null, 0, 0, 0,
- dest.data, dest.depth, dest.bytesPerLine, dest.getByteOrder(), 0, 0, dest.width, dest.height, 0, 0, 0,
- flipX, flipY);
- else blit(BLIT_SRC,
- this.data, this.depth, this.bytesPerLine, this.getByteOrder(), 0, 0, this.width, this.height, null, null, null,
- ALPHA_OPAQUE, null, 0, 0, 0,
- dest.data, dest.depth, dest.bytesPerLine, dest.getByteOrder(), 0, 0, dest.width, dest.height, null, null, null,
- flipX, flipY);
-
- /* Scale the image mask or alpha */
- if (maskData != null) {
- dest.maskPad = this.maskPad;
- int destBpl = (dest.width + 7) / 8;
- destBpl = (destBpl + (dest.maskPad - 1)) / dest.maskPad * dest.maskPad;
- dest.maskData = new byte[destBpl * dest.height];
- int srcBpl = (this.width + 7) / 8;
- srcBpl = (srcBpl + (this.maskPad - 1)) / this.maskPad * this.maskPad;
- blit(BLIT_SRC,
- this.maskData, 1, srcBpl, MSB_FIRST, 0, 0, this.width, this.height, null, null, null,
- ALPHA_OPAQUE, null, 0, 0, 0,
- dest.maskData, 1, destBpl, MSB_FIRST, 0, 0, dest.width, dest.height, null, null, null,
- flipX, flipY);
- } else if (alpha != -1) {
- dest.alpha = this.alpha;
- } else if (alphaData != null) {
- dest.alphaData = new byte[dest.width * dest.height];
- blit(BLIT_SRC,
- this.alphaData, 8, this.width, MSB_FIRST, 0, 0, this.width, this.height, null, null, null,
- ALPHA_OPAQUE, null, 0, 0, 0,
- dest.alphaData, 8, dest.width, MSB_FIRST, 0, 0, dest.width, dest.height, null, null, null,
- flipX, flipY);
- }
- return dest;
-}
-
-/**
- * Sets the alpha value at offset <code>x</code> in
- * scanline <code>y</code> in the receiver's alpha data.
- *
- * @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 IndexOutOfBoundsException if putWidth is too large
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if pixels is null</li>
- * <li>ERROR_INVALID_ARGUMENT - if x or y is out of bounds</li>
- * <li>ERROR_INVALID_ARGUMENT - if putWidth is negative</li>
- * </ul>
- */
-public void setAlphas(int x, int y, int putWidth, byte[] alphas, int startIndex) {
- if (alphas == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
- if (putWidth < 0 || x >= width || y >= height || x < 0 || y < 0) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
- if (putWidth == 0) return;
-
- if (alphaData == null) alphaData = new byte[width * height];
- // may throw an IndexOutOfBoundsException
- System.arraycopy(alphas, startIndex, alphaData, y * width + x, putWidth);
-}
-
-/**
- * Sets the pixel value at offset <code>x</code> in
- * scanline <code>y</code> in the receiver's data.
- *
- * @param x the x coordinate of the pixel to set
- * @param y the y coordinate of the pixel to set
- * @param pixelValue the value to set the pixel to
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_INVALID_ARGUMENT - if x or y is out of bounds</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_UNSUPPORTED_DEPTH if the depth is not one of 1, 2, 4, 8, 16, 24 or 32</li>
- * </ul>
- */
-public void setPixel(int x, int y, int pixelValue) {
- if (x >= width || y >= height || x < 0 || y < 0) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
- int index;
- byte theByte;
- int mask;
- 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 IndexOutOfBoundsException if putWidth is too large
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if pixels is null</li>
- * <li>ERROR_INVALID_ARGUMENT - if x or y is out of bounds</li>
- * <li>ERROR_INVALID_ARGUMENT - if putWidth is negative</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_UNSUPPORTED_DEPTH if the depth is not one of 1, 2, 4, 8
- * (For higher depths, use the int[] version of this method.)</li>
- * </ul>
- */
-public void setPixels(int x, int y, int putWidth, byte[] pixels, int startIndex) {
- if (pixels == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
- if (putWidth < 0 || x >= width || y >= height || x < 0 || y < 0) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
- if (putWidth == 0) return;
- int index;
- int theByte;
- int mask;
- int n = putWidth;
- int i = startIndex;
- int srcX = x, srcY = y;
- 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 IndexOutOfBoundsException if putWidth is too large
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if pixels is null</li>
- * <li>ERROR_INVALID_ARGUMENT - if x or y is out of bounds</li>
- * <li>ERROR_INVALID_ARGUMENT - if putWidth is negative</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_UNSUPPORTED_DEPTH if the depth is not one of 1, 2, 4, 8, 16, 24 or 32</li>
- * </ul>
- */
-public void setPixels(int x, int y, int putWidth, int[] pixels, int startIndex) {
- if (pixels == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
- if (putWidth < 0 || x >= width || y >= height || x < 0 || y < 0) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
- if (putWidth == 0) return;
- int index;
- int theByte;
- int mask;
- int n = putWidth;
- int i = startIndex;
- int pixel;
- int srcX = x, srcY = y;
- 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)});
-}
-
-/**
- * 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;
-}
-
-/**
- * Blit operation bits to be OR'ed together to specify the desired operation.
- */
-static final int
- BLIT_SRC = 1, // copy source directly, else applies logic operations
- BLIT_ALPHA = 2, // enable alpha blending
- BLIT_DITHER = 4; // enable dithering in low color modes
-
-/**
- * Alpha mode, values 0 - 255 specify global alpha level
- */
-static final int
- ALPHA_OPAQUE = 255, // Fully opaque (ignores any alpha data)
- ALPHA_TRANSPARENT = 0, // Fully transparent (ignores any alpha data)
- ALPHA_CHANNEL_SEPARATE = -1, // Use alpha channel from separate alphaData
- ALPHA_CHANNEL_SOURCE = -2, // Use alpha channel embedded in sourceData
- ALPHA_MASK_UNPACKED = -3, // Use transparency mask formed by bytes in alphaData (non-zero is opaque)
- ALPHA_MASK_PACKED = -4, // Use transparency mask formed by packed bits in alphaData
- ALPHA_MASK_INDEX = -5, // Consider source palette indices transparent if in alphaData array
- ALPHA_MASK_RGB = -6; // Consider source RGBs transparent if in RGB888 format alphaData array
-
-/**
- * Byte and bit order constants.
- */
-static final int LSB_FIRST = 0;
-static final int MSB_FIRST = 1;
-
-/**
- * Data types (internal)
- */
-private static final int
- // direct / true color formats with arbitrary masks & shifts
- TYPE_GENERIC_8 = 0,
- TYPE_GENERIC_16_MSB = 1,
- TYPE_GENERIC_16_LSB = 2,
- TYPE_GENERIC_24 = 3,
- TYPE_GENERIC_32_MSB = 4,
- TYPE_GENERIC_32_LSB = 5,
- // palette indexed color formats
- TYPE_INDEX_8 = 6,
- TYPE_INDEX_4 = 7,
- TYPE_INDEX_2 = 8,
- TYPE_INDEX_1_MSB = 9,
- TYPE_INDEX_1_LSB = 10;
-
-/**
- * Blits a direct palette image into a direct palette image.
- * <p>
- * Note: When the source and destination depth, order and masks
- * are pairwise equal and the blitter operation is BLIT_SRC,
- * the masks are ignored. Hence when not changing the image
- * data format, 0 may be specified for the masks.
- * </p>
- *
- * @param op the blitter operation: a combination of BLIT_xxx flags
- * (see BLIT_xxx constants)
- * @param srcData the source byte array containing image data
- * @param srcDepth the source depth: one of 8, 16, 24, 32
- * @param srcStride the source number of bytes per line
- * @param srcOrder the source byte ordering: one of MSB_FIRST or LSB_FIRST;
- * ignored if srcDepth is not 16 or 32
- * @param srcX the top-left x-coord of the source blit region
- * @param srcY the top-left y-coord of the source blit region
- * @param srcWidth the width of the source blit region
- * @param srcHeight the height of the source blit region
- * @param srcRedMask the source red channel mask
- * @param srcGreenMask the source green channel mask
- * @param srcBlueMask the source blue channel mask
- * @param alphaMode the alpha blending or mask mode, may be
- * an integer 0-255 for global alpha; ignored if BLIT_ALPHA
- * not specified in the blitter operations
- * (see ALPHA_MODE_xxx constants)
- * @param alphaData the alpha blending or mask data, varies depending
- * on the value of alphaMode and sometimes ignored
- * @param alphaStride the alpha data number of bytes per line
- * @param alphaX the top-left x-coord of the alpha blit region
- * @param alphaY the top-left y-coord of the alpha blit region
- * @param destData the destination byte array containing image data
- * @param destDepth the destination depth: one of 8, 16, 24, 32
- * @param destStride the destination number of bytes per line
- * @param destOrder the destination byte ordering: one of MSB_FIRST or LSB_FIRST;
- * ignored if destDepth is not 16 or 32
- * @param destX the top-left x-coord of the destination blit region
- * @param destY the top-left y-coord of the destination blit region
- * @param destWidth the width of the destination blit region
- * @param destHeight the height of the destination blit region
- * @param destRedMask the destination red channel mask
- * @param destGreenMask the destination green channel mask
- * @param destBlueMask the destination blue channel mask
- * @param flipX if true the resulting image is flipped along the vertical axis
- * @param flipY if true the resulting image is flipped along the horizontal axis
- */
-static void blit(int op,
- byte[] srcData, int srcDepth, int srcStride, int srcOrder,
- int srcX, int srcY, int srcWidth, int srcHeight,
- int srcRedMask, int srcGreenMask, int srcBlueMask,
- int alphaMode, byte[] alphaData, int alphaStride, int alphaX, int alphaY,
- byte[] destData, int destDepth, int destStride, int destOrder,
- int destX, int destY, int destWidth, int destHeight,
- int destRedMask, int destGreenMask, int destBlueMask,
- boolean flipX, boolean flipY) {
- if ((destWidth <= 0) || (destHeight <= 0) || (alphaMode == ALPHA_TRANSPARENT)) return;
-
- // these should be supplied as params later
- final int srcAlphaMask = 0, destAlphaMask = 0;
-
- /*** Prepare scaling data ***/
- final int dwm1 = destWidth - 1;
- final int sfxi = (dwm1 != 0) ? (int)((((long)srcWidth << 16) - 1) / dwm1) : 0;
- final int dhm1 = destHeight - 1;
- final int sfyi = (dhm1 != 0) ? (int)((((long)srcHeight << 16) - 1) / dhm1) : 0;
-
- /*** Prepare source-related data ***/
- final int sbpp, stype;
- switch (srcDepth) {
- case 8:
- sbpp = 1;
- stype = TYPE_GENERIC_8;
- break;
- case 16:
- sbpp = 2;
- stype = (srcOrder == MSB_FIRST) ? TYPE_GENERIC_16_MSB : TYPE_GENERIC_16_LSB;
- break;
- case 24:
- sbpp = 3;
- stype = TYPE_GENERIC_24;
- break;
- case 32:
- sbpp = 4;
- stype = (srcOrder == MSB_FIRST) ? TYPE_GENERIC_32_MSB : TYPE_GENERIC_32_LSB;
- break;
- default:
- //throw new IllegalArgumentException("Invalid source type");
- return;
- }
- int spr = srcY * srcStride + srcX * sbpp;
-
- /*** Prepare destination-related data ***/
- final int dbpp, dtype;
- switch (destDepth) {
- case 8:
- dbpp = 1;
- dtype = TYPE_GENERIC_8;
- break;
- case 16:
- dbpp = 2;
- dtype = (destOrder == MSB_FIRST) ? TYPE_GENERIC_16_MSB : TYPE_GENERIC_16_LSB;
- break;
- case 24:
- dbpp = 3;
- dtype = TYPE_GENERIC_24;
- break;
- case 32:
- dbpp = 4;
- dtype = (destOrder == MSB_FIRST) ? TYPE_GENERIC_32_MSB : TYPE_GENERIC_32_LSB;
- break;
- default:
- //throw new IllegalArgumentException("Invalid destination type");
- return;
- }
- int dpr = ((flipY) ? destY + dhm1 : destY) * destStride + ((flipX) ? destX + dwm1 : destX) * dbpp;
- final int dprxi = (flipX) ? -dbpp : dbpp;
- final int dpryi = (flipY) ? -destStride : destStride;
-
- /*** Prepare special processing data ***/
- int apr;
- if ((op & BLIT_ALPHA) != 0) {
- switch (alphaMode) {
- case ALPHA_MASK_UNPACKED:
- case ALPHA_CHANNEL_SEPARATE:
- if (alphaData == null) alphaMode = 0x10000;
- apr = alphaY * alphaStride + alphaX;
- break;
- case ALPHA_MASK_PACKED:
- if (alphaData == null) alphaMode = 0x10000;
- alphaStride <<= 3;
- apr = alphaY * alphaStride + alphaX;
- break;
- case ALPHA_MASK_INDEX:
- //throw new IllegalArgumentException("Invalid alpha type");
- return;
- case ALPHA_MASK_RGB:
- if (alphaData == null) alphaMode = 0x10000;
- apr = 0;
- break;
- default:
- alphaMode = (alphaMode << 16) / 255; // prescale
- case ALPHA_CHANNEL_SOURCE:
- apr = 0;
- break;
- }
- } else {
- alphaMode = 0x10000;
- apr = 0;
- }
-
- /*** Blit ***/
- int dp = dpr;
- int sp = spr;
- if ((alphaMode == 0x10000) && (stype == dtype) &&
- (srcRedMask == destRedMask) && (srcGreenMask == destGreenMask) &&
- (srcBlueMask == destBlueMask) && (srcAlphaMask == destAlphaMask)) {
- /*** Fast blit (straight copy) ***/
- switch (sbpp) {
- case 1:
- for (int dy = destHeight, sfy = sfyi; dy > 0; --dy, sp = spr += (sfy >>> 16) * srcStride, sfy = (sfy & 0xffff) + sfyi, dp = dpr += dpryi) {
- for (int dx = destWidth, sfx = sfxi; dx > 0; --dx, dp += dprxi, sfx = (sfx & 0xffff) + sfxi) {
- destData[dp] = srcData[sp];
- sp += (sfx >>> 16);
- }
- }
- break;
- case 2:
- for (int dy = destHeight, sfy = sfyi; dy > 0; --dy, sp = spr += (sfy >>> 16) * srcStride, sfy = (sfy & 0xffff) + sfyi, dp = dpr += dpryi) {
- for (int dx = destWidth, sfx = sfxi; dx > 0; --dx, dp += dprxi, sfx = (sfx & 0xffff) + sfxi) {
- destData[dp] = srcData[sp];
- destData[dp + 1] = srcData[sp + 1];
- sp += (sfx >>> 16) * 2;
- }
- }
- break;
- case 3:
- for (int dy = destHeight, sfy = sfyi; dy > 0; --dy, sp = spr += (sfy >>> 16) * srcStride, sfy = (sfy & 0xffff) + sfyi, dp = dpr += dpryi) {
- for (int dx = destWidth, sfx = sfxi; dx > 0; --dx, dp += dprxi, sfx = (sfx & 0xffff) + sfxi) {
- destData[dp] = srcData[sp];
- destData[dp + 1] = srcData[sp + 1];
- destData[dp + 2] = srcData[sp + 2];
- sp += (sfx >>> 16) * 3;
- }
- }
- break;
- case 4:
- for (int dy = destHeight, sfy = sfyi; dy > 0; --dy, sp = spr += (sfy >>> 16) * srcStride, sfy = (sfy & 0xffff) + sfyi, dp = dpr += dpryi) {
- for (int dx = destWidth, sfx = sfxi; dx > 0; --dx, dp += dprxi, sfx = (sfx & 0xffff) + sfxi) {
- destData[dp] = srcData[sp];
- destData[dp + 1] = srcData[sp + 1];
- destData[dp + 2] = srcData[sp + 2];
- destData[dp + 3] = srcData[sp + 3];
- sp += (sfx >>> 16) * 4;
- }
- }
- break;
- }
- return;
- }
- /*** Comprehensive blit (apply transformations) ***/
- final int srcRedShift = getChannelShift(srcRedMask);
- final byte[] srcReds = ANY_TO_EIGHT[getChannelWidth(srcRedMask, srcRedShift)];
- final int srcGreenShift = getChannelShift(srcGreenMask);
- final byte[] srcGreens = ANY_TO_EIGHT[getChannelWidth(srcGreenMask, srcGreenShift)];
- final int srcBlueShift = getChannelShift(srcBlueMask);
- final byte[] srcBlues = ANY_TO_EIGHT[getChannelWidth(srcBlueMask, srcBlueShift)];
- final int srcAlphaShift = getChannelShift(srcAlphaMask);
- final byte[] srcAlphas = ANY_TO_EIGHT[getChannelWidth(srcAlphaMask, srcAlphaShift)];
-
- final int destRedShift = getChannelShift(destRedMask);
- final int destRedWidth = getChannelWidth(destRedMask, destRedShift);
- final byte[] destReds = ANY_TO_EIGHT[destRedWidth];
- final int destRedPreShift = 8 - destRedWidth;
- final int destGreenShift = getChannelShift(destGreenMask);
- final int destGreenWidth = getChannelWidth(destGreenMask, destGreenShift);
- final byte[] destGreens = ANY_TO_EIGHT[destGreenWidth];
- final int destGreenPreShift = 8 - destGreenWidth;
- final int destBlueShift = getChannelShift(destBlueMask);
- final int destBlueWidth = getChannelWidth(destBlueMask, destBlueShift);
- final byte[] destBlues = ANY_TO_EIGHT[destBlueWidth];
- final int destBluePreShift = 8 - destBlueWidth;
- final int destAlphaShift = getChannelShift(destAlphaMask);
- final int destAlphaWidth = getChannelWidth(destAlphaMask, destAlphaShift);
- final byte[] destAlphas = ANY_TO_EIGHT[destAlphaWidth];
- final int destAlphaPreShift = 8 - destAlphaWidth;
-
- int ap = apr, alpha = alphaMode;
- int r = 0, g = 0, b = 0, a = 0;
- int rq = 0, gq = 0, bq = 0, aq = 0;
- for (int dy = destHeight, sfy = sfyi; dy > 0; --dy,
- sp = spr += (sfy >>> 16) * srcStride,
- ap = apr += (sfy >>> 16) * alphaStride,
- sfy = (sfy & 0xffff) + sfyi,
- dp = dpr += dpryi) {
- for (int dx = destWidth, sfx = sfxi; dx > 0; --dx,
- dp += dprxi,
- sfx = (sfx & 0xffff) + sfxi) {
- /*** READ NEXT PIXEL ***/
- switch (stype) {
- case TYPE_GENERIC_8: {
- final int data = srcData[sp] & 0xff;
- sp += (sfx >>> 16);
- r = srcReds[(data & srcRedMask) >>> srcRedShift] & 0xff;
- g = srcGreens[(data & srcGreenMask) >>> srcGreenShift] & 0xff;
- b = srcBlues[(data & srcBlueMask) >>> srcBlueShift] & 0xff;
- a = srcAlphas[(data & srcAlphaMask) >>> srcAlphaShift] & 0xff;
- } break;
- case TYPE_GENERIC_16_MSB: {
- final int data = ((srcData[sp] & 0xff) << 8) | (srcData[sp + 1] & 0xff);
- sp += (sfx >>> 16) * 2;
- r = srcReds[(data & srcRedMask) >>> srcRedShift] & 0xff;
- g = srcGreens[(data & srcGreenMask) >>> srcGreenShift] & 0xff;
- b = srcBlues[(data & srcBlueMask) >>> srcBlueShift] & 0xff;
- a = srcAlphas[(data & srcAlphaMask) >>> srcAlphaShift] & 0xff;
- } break;
- case TYPE_GENERIC_16_LSB: {
- final int data = ((srcData[sp + 1] & 0xff) << 8) | (srcData[sp] & 0xff);
- sp += (sfx >>> 16) * 2;
- r = srcReds[(data & srcRedMask) >>> srcRedShift] & 0xff;
- g = srcGreens[(data & srcGreenMask) >>> srcGreenShift] & 0xff;
- b = srcBlues[(data & srcBlueMask) >>> srcBlueShift] & 0xff;
- a = srcAlphas[(data & srcAlphaMask) >>> srcAlphaShift] & 0xff;
- } break;
- case TYPE_GENERIC_24: {
- final int data = (( ((srcData[sp] & 0xff) << 8) |
- (srcData[sp + 1] & 0xff)) << 8) |
- (srcData[sp + 2] & 0xff);
- sp += (sfx >>> 16) * 3;
- r = srcReds[(data & srcRedMask) >>> srcRedShift] & 0xff;
- g = srcGreens[(data & srcGreenMask) >>> srcGreenShift] & 0xff;
- b = srcBlues[(data & srcBlueMask) >>> srcBlueShift] & 0xff;
- a = srcAlphas[(data & srcAlphaMask) >>> srcAlphaShift] & 0xff;
- } break;
- case TYPE_GENERIC_32_MSB: {
- final int data = (( (( ((srcData[sp] & 0xff) << 8) |
- (srcData[sp + 1] & 0xff)) << 8) |
- (srcData[sp + 2] & 0xff)) << 8) |
- (srcData[sp + 3] & 0xff);
- sp += (sfx >>> 16) * 4;
- r = srcReds[(data & srcRedMask) >>> srcRedShift] & 0xff;
- g = srcGreens[(data & srcGreenMask) >>> srcGreenShift] & 0xff;
- b = srcBlues[(data & srcBlueMask) >>> srcBlueShift] & 0xff;
- a = srcAlphas[(data & srcAlphaMask) >>> srcAlphaShift] & 0xff;
- } break;
- case TYPE_GENERIC_32_LSB: {
- final int data = (( (( ((srcData[sp + 3] & 0xff) << 8) |
- (srcData[sp + 2] & 0xff)) << 8) |
- (srcData[sp + 1] & 0xff)) << 8) |
- (srcData[sp] & 0xff);
- sp += (sfx >>> 16) * 4;
- r = srcReds[(data & srcRedMask) >>> srcRedShift] & 0xff;
- g = srcGreens[(data & srcGreenMask) >>> srcGreenShift] & 0xff;
- b = srcBlues[(data & srcBlueMask) >>> srcBlueShift] & 0xff;
- a = srcAlphas[(data & srcAlphaMask) >>> srcAlphaShift] & 0xff;
- } break;
- }
-
- /*** DO SPECIAL PROCESSING IF REQUIRED ***/
- switch (alphaMode) {
- case ALPHA_CHANNEL_SEPARATE:
- alpha = ((alphaData[ap] & 0xff) << 16) / 255;
- ap += (sfx >> 16);
- break;
- case ALPHA_CHANNEL_SOURCE:
- alpha = (a << 16) / 255;
- break;
- case ALPHA_MASK_UNPACKED:
- alpha = (alphaData[ap] != 0) ? 0x10000 : 0;
- ap += (sfx >> 16);
- break;
- case ALPHA_MASK_PACKED:
- alpha = (alphaData[ap >> 3] << ((ap & 7) + 9)) & 0x10000;
- ap += (sfx >> 16);
- break;
- case ALPHA_MASK_RGB:
- alpha = 0x10000;
- for (int i = 0; i < alphaData.length; i += 3) {
- if ((r == alphaData[i]) && (g == alphaData[i + 1]) && (b == alphaData[i + 2])) {
- alpha = 0x0000;
- break;
- }
- }
- break;
- }
- if (alpha != 0x10000) {
- if (alpha == 0x0000) continue;
- switch (dtype) {
- case TYPE_GENERIC_8: {
- final int data = destData[dp] & 0xff;
- rq = destReds[(data & destRedMask) >>> destRedShift] & 0xff;
- gq = destGreens[(data & destGreenMask) >>> destGreenShift] & 0xff;
- bq = destBlues[(data & destBlueMask) >>> destBlueShift] & 0xff;
- aq = destAlphas[(data & destAlphaMask) >>> destAlphaShift] & 0xff;
- } break;
- case TYPE_GENERIC_16_MSB: {
- final int data = ((destData[dp] & 0xff) << 8) | (destData[dp + 1] & 0xff);
- rq = destReds[(data & destRedMask) >>> destRedShift] & 0xff;
- gq = destGreens[(data & destGreenMask) >>> destGreenShift] & 0xff;
- bq = destBlues[(data & destBlueMask) >>> destBlueShift] & 0xff;
- aq = destAlphas[(data & destAlphaMask) >>> destAlphaShift] & 0xff;
- } break;
- case TYPE_GENERIC_16_LSB: {
- final int data = ((destData[dp + 1] & 0xff) << 8) | (destData[dp] & 0xff);
- rq = destReds[(data & destRedMask) >>> destRedShift] & 0xff;
- gq = destGreens[(data & destGreenMask) >>> destGreenShift] & 0xff;
- bq = destBlues[(data & destBlueMask) >>> destBlueShift] & 0xff;
- aq = destAlphas[(data & destAlphaMask) >>> destAlphaShift] & 0xff;
- } break;
- case TYPE_GENERIC_24: {
- final int data = (( ((destData[dp] & 0xff) << 8) |
- (destData[dp + 1] & 0xff)) << 8) |
- (destData[dp + 2] & 0xff);
- rq = destReds[(data & destRedMask) >>> destRedShift] & 0xff;
- gq = destGreens[(data & destGreenMask) >>> destGreenShift] & 0xff;
- bq = destBlues[(data & destBlueMask) >>> destBlueShift] & 0xff;
- aq = destAlphas[(data & destAlphaMask) >>> destAlphaShift] & 0xff;
- } break;
- case TYPE_GENERIC_32_MSB: {
- final int data = (( (( ((destData[dp] & 0xff) << 8) |
- (destData[dp + 1] & 0xff)) << 8) |
- (destData[dp + 2] & 0xff)) << 8) |
- (destData[dp + 3] & 0xff);
- rq = destReds[(data & destRedMask) >>> destRedShift] & 0xff;
- gq = destGreens[(data & destGreenMask) >>> destGreenShift] & 0xff;
- bq = destBlues[(data & destBlueMask) >>> destBlueShift] & 0xff;
- aq = destAlphas[(data & destAlphaMask) >>> destAlphaShift] & 0xff;
- } break;
- case TYPE_GENERIC_32_LSB: {
- final int data = (( (( ((destData[dp + 3] & 0xff) << 8) |
- (destData[dp + 2] & 0xff)) << 8) |
- (destData[dp + 1] & 0xff)) << 8) |
- (destData[dp] & 0xff);
- rq = destReds[(data & destRedMask) >>> destRedShift] & 0xff;
- gq = destGreens[(data & destGreenMask) >>> destGreenShift] & 0xff;
- bq = destBlues[(data & destBlueMask) >>> destBlueShift] & 0xff;
- aq = destAlphas[(data & destAlphaMask) >>> destAlphaShift] & 0xff;
- } break;
- }
- // Perform alpha blending
- a = aq + ((a - aq) * alpha >> 16);
- r = rq + ((r - rq) * alpha >> 16);
- g = gq + ((g - gq) * alpha >> 16);
- b = bq + ((b - bq) * alpha >> 16);
- }
-
- /*** WRITE NEXT PIXEL ***/
- final int data =
- (r >>> destRedPreShift << destRedShift) |
- (g >>> destGreenPreShift << destGreenShift) |
- (b >>> destBluePreShift << destBlueShift) |
- (a >>> destAlphaPreShift << destAlphaShift);
- switch (dtype) {
- case TYPE_GENERIC_8: {
- destData[dp] = (byte) data;
- } break;
- case TYPE_GENERIC_16_MSB: {
- destData[dp] = (byte) (data >>> 8);
- destData[dp + 1] = (byte) (data & 0xff);
- } break;
- case TYPE_GENERIC_16_LSB: {
- destData[dp] = (byte) (data & 0xff);
- destData[dp + 1] = (byte) (data >>> 8);
- } break;
- case TYPE_GENERIC_24: {
- destData[dp] = (byte) (data >>> 16);
- destData[dp + 1] = (byte) (data >>> 8);
- destData[dp + 2] = (byte) (data & 0xff);
- } break;
- case TYPE_GENERIC_32_MSB: {
- destData[dp] = (byte) (data >>> 24);
- destData[dp + 1] = (byte) (data >>> 16);
- destData[dp + 2] = (byte) (data >>> 8);
- destData[dp + 3] = (byte) (data & 0xff);
- } break;
- case TYPE_GENERIC_32_LSB: {
- destData[dp] = (byte) (data & 0xff);
- destData[dp + 1] = (byte) (data >>> 8);
- destData[dp + 2] = (byte) (data >>> 16);
- destData[dp + 3] = (byte) (data >>> 24);
- } break;
- }
- }
- }
-}
-
-/**
- * Blits an index palette image into an index palette image.
- * <p>
- * Note: The source and destination red, green, and blue
- * arrays may be null if no alpha blending or dither is to be
- * performed.
- * </p>
- *
- * @param op the blitter operation: a combination of BLIT_xxx flags
- * (see BLIT_xxx constants)
- * @param srcData the source byte array containing image data
- * @param srcDepth the source depth: one of 1, 2, 4, 8
- * @param srcStride the source number of bytes per line
- * @param srcOrder the source byte ordering: one of MSB_FIRST or LSB_FIRST;
- * ignored if srcDepth is not 1
- * @param srcX the top-left x-coord of the source blit region
- * @param srcY the top-left y-coord of the source blit region
- * @param srcWidth the width of the source blit region
- * @param srcHeight the height of the source blit region
- * @param srcReds the source palette red component intensities
- * @param srcGreens the source palette green component intensities
- * @param srcBlues the source palette blue component intensities
- * @param alphaMode the alpha blending or mask mode, may be
- * an integer 0-255 for global alpha; ignored if BLIT_ALPHA
- * not specified in the blitter operations
- * (see ALPHA_MODE_xxx constants)
- * @param alphaData the alpha blending or mask data, varies depending
- * on the value of alphaMode and sometimes ignored
- * @param alphaStride the alpha data number of bytes per line
- * @param alphaX the top-left x-coord of the alpha blit region
- * @param alphaY the top-left y-coord of the alpha blit region
- * @param destData the destination byte array containing image data
- * @param destDepth the destination depth: one of 1, 2, 4, 8
- * @param destStride the destination number of bytes per line
- * @param destOrder the destination byte ordering: one of MSB_FIRST or LSB_FIRST;
- * ignored if destDepth is not 1
- * @param destX the top-left x-coord of the destination blit region
- * @param destY the top-left y-coord of the destination blit region
- * @param destWidth the width of the destination blit region
- * @param destHeight the height of the destination blit region
- * @param destReds the destination palette red component intensities
- * @param destGreens the destination palette green component intensities
- * @param destBlues the destination palette blue component intensities
- * @param flipX if true the resulting image is flipped along the vertical axis
- * @param flipY if true the resulting image is flipped along the horizontal axis
- */
-static void blit(int op,
- byte[] srcData, int srcDepth, int srcStride, int srcOrder,
- int srcX, int srcY, int srcWidth, int srcHeight,
- byte[] srcReds, byte[] srcGreens, byte[] srcBlues,
- int alphaMode, byte[] alphaData, int alphaStride, int alphaX, int alphaY,
- byte[] destData, int destDepth, int destStride, int destOrder,
- int destX, int destY, int destWidth, int destHeight,
- byte[] destReds, byte[] destGreens, byte[] destBlues,
- boolean flipX, boolean flipY) {
- if ((destWidth <= 0) || (destHeight <= 0) || (alphaMode == ALPHA_TRANSPARENT)) return;
-
- /*** Prepare scaling data ***/
- final int dwm1 = destWidth - 1;
- final int sfxi = (dwm1 != 0) ? (int)((((long)srcWidth << 16) - 1) / dwm1) : 0;
- final int dhm1 = destHeight - 1;
- final int sfyi = (dhm1 != 0) ? (int)((((long)srcHeight << 16) - 1) / dhm1) : 0;
-
- /*** Prepare source-related data ***/
- final int stype;
- switch (srcDepth) {
- case 8:
- stype = TYPE_INDEX_8;
- break;
- case 4:
- srcStride <<= 1;
- stype = TYPE_INDEX_4;
- break;
- case 2:
- srcStride <<= 2;
- stype = TYPE_INDEX_2;
- break;
- case 1:
- srcStride <<= 3;
- stype = (srcOrder == MSB_FIRST) ? TYPE_INDEX_1_MSB : TYPE_INDEX_1_LSB;
- break;
- default:
- //throw new IllegalArgumentException("Invalid source type");
- return;
- }
- int spr = srcY * srcStride + srcX;
-
- /*** Prepare destination-related data ***/
- final int dtype;
- switch (destDepth) {
- case 8:
- dtype = TYPE_INDEX_8;
- break;
- case 4:
- destStride <<= 1;
- dtype = TYPE_INDEX_4;
- break;
- case 2:
- destStride <<= 2;
- dtype = TYPE_INDEX_2;
- break;
- case 1:
- destStride <<= 3;
- dtype = (destOrder == MSB_FIRST) ? TYPE_INDEX_1_MSB : TYPE_INDEX_1_LSB;
- break;
- default:
- //throw new IllegalArgumentException("Invalid source type");
- return;
- }
- int dpr = ((flipY) ? destY + dhm1 : destY) * destStride + ((flipX) ? destX + dwm1 : destX);
- final int dprxi = (flipX) ? -1 : 1;
- final int dpryi = (flipY) ? -destStride : destStride;
-
- /*** Prepare special processing data ***/
- int apr;
- if ((op & BLIT_ALPHA) != 0) {
- switch (alphaMode) {
- case ALPHA_MASK_UNPACKED:
- case ALPHA_CHANNEL_SEPARATE:
- if (alphaData == null) alphaMode = 0x10000;
- apr = alphaY * alphaStride + alphaX;
- break;
- case ALPHA_MASK_PACKED:
- if (alphaData == null) alphaMode = 0x10000;
- alphaStride <<= 3;
- apr = alphaY * alphaStride + alphaX;
- break;
- case ALPHA_MASK_INDEX:
- case ALPHA_MASK_RGB:
- if (alphaData == null) alphaMode = 0x10000;
- apr = 0;
- break;
- default:
- alphaMode = (alphaMode << 16) / 255; // prescale
- case ALPHA_CHANNEL_SOURCE:
- apr = 0;
- break;
- }
- } else {
- alphaMode = 0x10000;
- apr = 0;
- }
- final boolean ditherEnabled = (op & BLIT_DITHER) != 0;
-
- /*** Blit ***/
- int dp = dpr;
- int sp = spr;
- int ap = apr;
- int destPaletteSize = 1 << destDepth;
- if ((destReds != null) && (destReds.length < destPaletteSize)) destPaletteSize = destReds.length;
- byte[] paletteMapping = null;
- boolean isExactPaletteMapping = true;
- switch (alphaMode) {
- case 0x10000:
- /*** If the palettes and formats are equivalent use a one-to-one mapping ***/
- if ((stype == dtype) &&
- (srcReds == destReds) && (srcGreens == destGreens) && (srcBlues == destBlues)) {
- paletteMapping = ONE_TO_ONE_MAPPING;
- break;
- /*** If palettes have not been supplied, supply a suitable mapping ***/
- } else if ((srcReds == null) || (destReds == null)) {
- if (srcDepth <= destDepth) {
- paletteMapping = ONE_TO_ONE_MAPPING;
- } else {
- paletteMapping = new byte[1 << srcDepth];
- int mask = (0xff << destDepth) >>> 8;
- for (int i = 0; i < paletteMapping.length; ++i) paletteMapping[i] = (byte)(i & mask);
- }
- break;
- }
- case ALPHA_MASK_UNPACKED:
- case ALPHA_MASK_PACKED:
- case ALPHA_MASK_INDEX:
- case ALPHA_MASK_RGB:
- /*** Generate a palette mapping ***/
- int srcPaletteSize = 1 << srcDepth;
- paletteMapping = new byte[srcPaletteSize];
- if ((srcReds != null) && (srcReds.length < srcPaletteSize)) srcPaletteSize = srcReds.length;
- for (int i = 0, r, g, b, index; i < srcPaletteSize; ++i) {
- r = srcReds[i] & 0xff;
- g = srcGreens[i] & 0xff;
- b = srcBlues[i] & 0xff;
- index = 0;
- int minDistance = 0x7fffffff;
- for (int j = 0, dr, dg, db, distance; j < destPaletteSize; ++j) {
- dr = (destReds[j] & 0xff) - r;
- dg = (destGreens[j] & 0xff) - g;
- db = (destBlues[j] & 0xff) - b;
- distance = dr * dr + dg * dg + db * db;
- if (distance < minDistance) {
- index = j;
- if (distance == 0) break;
- minDistance = distance;
- }
- }
- paletteMapping[i] = (byte)index;
- if (minDistance != 0) isExactPaletteMapping = false;
- }
- break;
- }
- if ((paletteMapping != null) && (isExactPaletteMapping || ! ditherEnabled)) {
- if ((stype == dtype) && (alphaMode == 0x10000)) {
- /*** Fast blit (copy w/ mapping) ***/
- switch (stype) {
- case TYPE_INDEX_8:
- for (int dy = destHeight, sfy = sfyi; dy > 0; --dy, sp = spr += (sfy >>> 16) * srcStride, sfy = (sfy & 0xffff) + sfyi, dp = dpr += dpryi) {
- for (int dx = destWidth, sfx = sfxi; dx > 0; --dx, dp += dprxi, sfx = (sfx & 0xffff) + sfxi) {
- destData[dp] = paletteMapping[srcData[sp] & 0xff];
- sp += (sfx >>> 16);
- }
- }
- break;
- case TYPE_INDEX_4:
- for (int dy = destHeight, sfy = sfyi; dy > 0; --dy, sp = spr += (sfy >>> 16) * srcStride, sfy = (sfy & 0xffff) + sfyi, dp = dpr += dpryi) {
- for (int dx = destWidth, sfx = sfxi; dx > 0; --dx, dp += dprxi, sfx = (sfx & 0xffff) + sfxi) {
- final int v;
- if ((sp & 1) != 0) v = paletteMapping[srcData[sp >> 1] & 0x0f];
- else v = (srcData[sp >> 1] >>> 4) & 0x0f;
- sp += (sfx >>> 16);
- if ((dp & 1) != 0) destData[dp >> 1] = (byte)((destData[dp >> 1] & 0xf0) | v);
- else destData[dp >> 1] = (byte)((destData[dp >> 1] & 0x0f) | (v << 4));
- }
- }
- break;
- case TYPE_INDEX_2:
- for (int dy = destHeight, sfy = sfyi; dy > 0; --dy, sp = spr += (sfy >>> 16) * srcStride, sfy = (sfy & 0xffff) + sfyi, dp = dpr += dpryi) {
- for (int dx = destWidth, sfx = sfxi; dx > 0; --dx, dp += dprxi, sfx = (sfx & 0xffff) + sfxi) {
- final int index = paletteMapping[(srcData[sp >> 2] >>> (6 - (sp & 3) * 2)) & 0x03];
- sp += (sfx >>> 16);
- final int shift = 6 - (dp & 3) * 2;
- destData[dp >> 2] = (byte)(destData[dp >> 2] & ~(0x03 << shift) | (index << shift));
- }
- }
- break;
- case TYPE_INDEX_1_MSB:
- for (int dy = destHeight, sfy = sfyi; dy > 0; --dy, sp = spr += (sfy >>> 16) * srcStride, sfy = (sfy & 0xffff) + sfyi, dp = dpr += dpryi) {
- for (int dx = destWidth, sfx = sfxi; dx > 0; --dx, dp += dprxi, sfx = (sfx & 0xffff) + sfxi) {
- final int index = paletteMapping[(srcData[sp >> 3] >>> (7 - (sp & 7))) & 0x01];
- sp += (sfx >>> 16);
- final int shift = 7 - (dp & 7);
- destData[dp >> 3] = (byte)(destData[dp >> 3] & ~(0x01 << shift) | (index << shift));
- }
- }
- break;
- case TYPE_INDEX_1_LSB:
- for (int dy = destHeight, sfy = sfyi; dy > 0; --dy, sp = spr += (sfy >>> 16) * srcStride, sfy = (sfy & 0xffff) + sfyi, dp = dpr += dpryi) {
- for (int dx = destWidth, sfx = sfxi; dx > 0; --dx, dp += dprxi, sfx = (sfx & 0xffff) + sfxi) {
- final int index = paletteMapping[(srcData[sp >> 3] >>> (sp & 7)) & 0x01];
- sp += (sfx >>> 16);
- final int shift = dp & 7;
- destData[dp >> 3] = (byte)(destData[dp >> 3] & ~(0x01 << shift) | (index << shift));
- }
- }
- break;
- }
- } else {
- /*** Convert between indexed modes using mapping and mask ***/
- for (int dy = destHeight, sfy = sfyi; dy > 0; --dy,
- sp = spr += (sfy >>> 16) * srcStride,
- sfy = (sfy & 0xffff) + sfyi,
- dp = dpr += dpryi) {
- for (int dx = destWidth, sfx = sfxi; dx > 0; --dx,
- dp += dprxi,
- sfx = (sfx & 0xffff) + sfxi) {
- int index;
- /*** READ NEXT PIXEL ***/
- switch (stype) {
- case TYPE_INDEX_8:
- index = srcData[sp] & 0xff;
- sp += (sfx >>> 16);
- break;
- case TYPE_INDEX_4:
- if ((sp & 1) != 0) index = srcData[sp >> 1] & 0x0f;
- else index = (srcData[sp >> 1] >>> 4) & 0x0f;
- sp += (sfx >>> 16);
- break;
- case TYPE_INDEX_2:
- index = (srcData[sp >> 2] >>> (6 - (sp & 3) * 2)) & 0x03;
- sp += (sfx >>> 16);
- break;
- case TYPE_INDEX_1_MSB:
- index = (srcData[sp >> 3] >>> (7 - (sp & 7))) & 0x01;
- sp += (sfx >>> 16);
- break;
- case TYPE_INDEX_1_LSB:
- index = (srcData[sp >> 3] >>> (sp & 7)) & 0x01;
- sp += (sfx >>> 16);
- break;
- default:
- return;
- }
- /*** APPLY MASK ***/
- switch (alphaMode) {
- case ALPHA_MASK_UNPACKED: {
- final byte mask = alphaData[ap];
- ap += (sfx >> 16);
- if (mask == 0) continue;
- } break;
- case ALPHA_MASK_PACKED: {
- final int mask = alphaData[ap >> 3] & (1 << (ap & 7));
- ap += (sfx >> 16);
- if (mask == 0) continue;
- } break;
- case ALPHA_MASK_INDEX: {
- int i = 0;
- while (i < alphaData.length) {
- if (index == (alphaData[i] & 0xff)) break;
- }
- if (i < alphaData.length) continue;
- } break;
- case ALPHA_MASK_RGB: {
- final byte r = srcReds[index], g = srcGreens[index], b = srcBlues[index];
- int i = 0;
- while (i < alphaData.length) {
- if ((r == alphaData[i]) && (g == alphaData[i + 1]) && (b == alphaData[i + 2])) break;
- i += 3;
- }
- if (i < alphaData.length) continue;
- } break;
- }
- index = paletteMapping[index] & 0xff;
-
- /*** WRITE NEXT PIXEL ***/
- switch (dtype) {
- case TYPE_INDEX_8:
- destData[dp] = (byte) index;
- break;
- case TYPE_INDEX_4:
- if ((dp & 1) != 0) destData[dp >> 1] = (byte)((destData[dp >> 1] & 0xf0) | index);
- else destData[dp >> 1] = (byte)((destData[dp >> 1] & 0x0f) | (index << 4));
- break;
- case TYPE_INDEX_2: {
- final int shift = 6 - (dp & 3) * 2;
- destData[dp >> 2] = (byte)(destData[dp >> 2] & ~(0x03 << shift) | (index << shift));
- } break;
- case TYPE_INDEX_1_MSB: {
- final int shift = 7 - (dp & 7);
- destData[dp >> 3] = (byte)(destData[dp >> 3] & ~(0x01 << shift) | (index << shift));
- } break;
- case TYPE_INDEX_1_LSB: {
- final int shift = dp & 7;
- destData[dp >> 3] = (byte)(destData[dp >> 3] & ~(0x01 << shift) | (index << shift));
- } break;
- }
- }
- }
- }
- return;
- }
-
- /*** Comprehensive blit (apply transformations) ***/
- int alpha = alphaMode;
- int index = 0;
- int indexq = 0;
- int lastindex = 0, lastr = -1, lastg = -1, lastb = -1;
- final int[] rerr, gerr, berr;
- if (ditherEnabled) {
- rerr = new int[destWidth + 2];
- gerr = new int[destWidth + 2];
- berr = new int[destWidth + 2];
- } else {
- rerr = null; gerr = null; berr = null;
- }
- for (int dy = destHeight, sfy = sfyi; dy > 0; --dy,
- sp = spr += (sfy >>> 16) * srcStride,
- ap = apr += (sfy >>> 16) * alphaStride,
- sfy = (sfy & 0xffff) + sfyi,
- dp = dpr += dpryi) {
- int lrerr = 0, lgerr = 0, lberr = 0;
- for (int dx = destWidth, sfx = sfxi; dx > 0; --dx,
- dp += dprxi,
- sfx = (sfx & 0xffff) + sfxi) {
- /*** READ NEXT PIXEL ***/
- switch (stype) {
- case TYPE_INDEX_8:
- index = srcData[sp] & 0xff;
- sp += (sfx >>> 16);
- break;
- case TYPE_INDEX_4:
- if ((sp & 1) != 0) index = srcData[sp >> 1] & 0x0f;
- else index = (srcData[sp >> 1] >>> 4) & 0x0f;
- sp += (sfx >>> 16);
- break;
- case TYPE_INDEX_2:
- index = (srcData[sp >> 2] >>> (6 - (sp & 3) * 2)) & 0x03;
- sp += (sfx >>> 16);
- break;
- case TYPE_INDEX_1_MSB:
- index = (srcData[sp >> 3] >>> (7 - (sp & 7))) & 0x01;
- sp += (sfx >>> 16);
- break;
- case TYPE_INDEX_1_LSB:
- index = (srcData[sp >> 3] >>> (sp & 7)) & 0x01;
- sp += (sfx >>> 16);
- break;
- }
-
- /*** DO SPECIAL PROCESSING IF REQUIRED ***/
- int r = srcReds[index] & 0xff, g = srcGreens[index] & 0xff, b = srcBlues[index] & 0xff;
- switch (alphaMode) {
- case ALPHA_CHANNEL_SEPARATE:
- alpha = ((alphaData[ap] & 0xff) << 16) / 255;
- ap += (sfx >> 16);
- break;
- case ALPHA_MASK_UNPACKED:
- alpha = (alphaData[ap] != 0) ? 0x10000 : 0;
- ap += (sfx >> 16);
- break;
- case ALPHA_MASK_PACKED:
- alpha = (alphaData[ap >> 3] << ((ap & 7) + 9)) & 0x10000;
- ap += (sfx >> 16);
- break;
- case ALPHA_MASK_INDEX: { // could speed up using binary search if we sorted the indices
- int i = 0;
- while (i < alphaData.length) {
- if (index == (alphaData[i] & 0xff)) break;
- }
- if (i < alphaData.length) continue;
- } break;
- case ALPHA_MASK_RGB: {
- int i = 0;
- while (i < alphaData.length) {
- if ((r == (alphaData[i] & 0xff)) &&
- (g == (alphaData[i + 1] & 0xff)) &&
- (b == (alphaData[i + 2] & 0xff))) break;
- i += 3;
- }
- if (i < alphaData.length) continue;
- } break;
- }
- if (alpha != 0x10000) {
- if (alpha == 0x0000) continue;
- switch (dtype) {
- case TYPE_INDEX_8:
- indexq = destData[dp] & 0xff;
- break;
- case TYPE_INDEX_4:
- if ((dp & 1) != 0) indexq = destData[dp >> 1] & 0x0f;
- else indexq = (destData[dp >> 1] >>> 4) & 0x0f;
- break;
- case TYPE_INDEX_2:
- indexq = (destData[dp >> 2] >>> (6 - (dp & 3) * 2)) & 0x03;
- break;
- case TYPE_INDEX_1_MSB:
- indexq = (destData[dp >> 3] >>> (7 - (dp & 7))) & 0x01;
- break;
- case TYPE_INDEX_1_LSB:
- indexq = (destData[dp >> 3] >>> (dp & 7)) & 0x01;
- break;
- }
- // Perform alpha blending
- final int rq = destReds[indexq] & 0xff;
- final int gq = destGreens[indexq] & 0xff;
- final int bq = destBlues[indexq] & 0xff;
- r = rq + ((r - rq) * alpha >> 16);
- g = gq + ((g - gq) * alpha >> 16);
- b = bq + ((b - bq) * alpha >> 16);
- }
-
- /*** MAP COLOR TO THE PALETTE ***/
- if (ditherEnabled) {
- // Floyd-Steinberg error diffusion
- r += rerr[dx] >> 4;
- if (r < 0) r = 0; else if (r > 255) r = 255;
- g += gerr[dx] >> 4;
- if (g < 0) g = 0; else if (g > 255) g = 255;
- b += berr[dx] >> 4;
- if (b < 0) b = 0; else if (b > 255) b = 255;
- rerr[dx] = lrerr;
- gerr[dx] = lgerr;
- berr[dx] = lberr;
- }
- if (r != lastr || g != lastg || b != lastb) {
- // moving the variable declarations out seems to make the JDK JIT happier...
- for (int j = 0, dr, dg, db, distance, minDistance = 0x7fffffff; j < destPaletteSize; ++j) {
- dr = (destReds[j] & 0xff) - r;
- dg = (destGreens[j] & 0xff) - g;
- db = (destBlues[j] & 0xff) - b;
- distance = dr * dr + dg * dg + db * db;
- if (distance < minDistance) {
- lastindex = j;
- if (distance == 0) break;
- minDistance = distance;
- }
- }
- lastr = r; lastg = g; lastb = b;
- }
- if (ditherEnabled) {
- // Floyd-Steinberg error diffusion, cont'd...
- final int dxm1 = dx - 1, dxp1 = dx + 1;
- int acc;
- rerr[dxp1] += acc = (lrerr = r - (destReds[lastindex] & 0xff)) + lrerr + lrerr;
- rerr[dx] += acc += lrerr + lrerr;
- rerr[dxm1] += acc + lrerr + lrerr;
- gerr[dxp1] += acc = (lgerr = g - (destGreens[lastindex] & 0xff)) + lgerr + lgerr;
- gerr[dx] += acc += lgerr + lgerr;
- gerr[dxm1] += acc + lgerr + lgerr;
- berr[dxp1] += acc = (lberr = b - (destBlues[lastindex] & 0xff)) + lberr + lberr;
- berr[dx] += acc += lberr + lberr;
- berr[dxm1] += acc + lberr + lberr;
- }
-
- /*** WRITE NEXT PIXEL ***/
- switch (dtype) {
- case TYPE_INDEX_8:
- destData[dp] = (byte) lastindex;
- break;
- case TYPE_INDEX_4:
- if ((dp & 1) != 0) destData[dp >> 1] = (byte)((destData[dp >> 1] & 0xf0) | lastindex);
- else destData[dp >> 1] = (byte)((destData[dp >> 1] & 0x0f) | (lastindex << 4));
- break;
- case TYPE_INDEX_2: {
- final int shift = 6 - (dp & 3) * 2;
- destData[dp >> 2] = (byte)(destData[dp >> 2] & ~(0x03 << shift) | (lastindex << shift));
- } break;
- case TYPE_INDEX_1_MSB: {
- final int shift = 7 - (dp & 7);
- destData[dp >> 3] = (byte)(destData[dp >> 3] & ~(0x01 << shift) | (lastindex << shift));
- } break;
- case TYPE_INDEX_1_LSB: {
- final int shift = dp & 7;
- destData[dp >> 3] = (byte)(destData[dp >> 3] & ~(0x01 << shift) | (lastindex << shift));
- } break;
- }
- }
- }
-}
-
-/**
- * Blits an index palette image into a direct palette image.
- * <p>
- * Note: The source and destination masks and palettes must
- * always be fully specified.
- * </p>
- *
- * @param op the blitter operation: a combination of BLIT_xxx flags
- * (see BLIT_xxx constants)
- * @param srcData the source byte array containing image data
- * @param srcDepth the source depth: one of 1, 2, 4, 8
- * @param srcStride the source number of bytes per line
- * @param srcOrder the source byte ordering: one of MSB_FIRST or LSB_FIRST;
- * ignored if srcDepth is not 1
- * @param srcX the top-left x-coord of the source blit region
- * @param srcY the top-left y-coord of the source blit region
- * @param srcWidth the width of the source blit region
- * @param srcHeight the height of the source blit region
- * @param srcReds the source palette red component intensities
- * @param srcGreens the source palette green component intensities
- * @param srcBlues the source palette blue component intensities
- * @param alphaMode the alpha blending or mask mode, may be
- * an integer 0-255 for global alpha; ignored if BLIT_ALPHA
- * not specified in the blitter operations
- * (see ALPHA_MODE_xxx constants)
- * @param alphaData the alpha blending or mask data, varies depending
- * on the value of alphaMode and sometimes ignored
- * @param alphaStride the alpha data number of bytes per line
- * @param alphaX the top-left x-coord of the alpha blit region
- * @param alphaY the top-left y-coord of the alpha blit region
- * @param destData the destination byte array containing image data
- * @param destDepth the destination depth: one of 8, 16, 24, 32
- * @param destStride the destination number of bytes per line
- * @param destOrder the destination byte ordering: one of MSB_FIRST or LSB_FIRST;
- * ignored if destDepth is not 16 or 32
- * @param destX the top-left x-coord of the destination blit region
- * @param destY the top-left y-coord of the destination blit region
- * @param destWidth the width of the destination blit region
- * @param destHeight the height of the destination blit region
- * @param destRedMask the destination red channel mask
- * @param destGreenMask the destination green channel mask
- * @param destBlueMask the destination blue channel mask
- * @param flipX if true the resulting image is flipped along the vertical axis
- * @param flipY if true the resulting image is flipped along the horizontal axis
- */
-static void blit(int op,
- byte[] srcData, int srcDepth, int srcStride, int srcOrder,
- int srcX, int srcY, int srcWidth, int srcHeight,
- byte[] srcReds, byte[] srcGreens, byte[] srcBlues,
- int alphaMode, byte[] alphaData, int alphaStride, int alphaX, int alphaY,
- byte[] destData, int destDepth, int destStride, int destOrder,
- int destX, int destY, int destWidth, int destHeight,
- int destRedMask, int destGreenMask, int destBlueMask,
- boolean flipX, boolean flipY) {
- if ((destWidth <= 0) || (destHeight <= 0) || (alphaMode == ALPHA_TRANSPARENT)) return;
-
- // these should be supplied as params later
- final int destAlphaMask = 0;
-
- /*** Prepare scaling data ***/
- final int dwm1 = destWidth - 1;
- final int sfxi = (dwm1 != 0) ? (int)((((long)srcWidth << 16) - 1) / dwm1) : 0;
- final int dhm1 = destHeight - 1;
- final int sfyi = (dhm1 != 0) ? (int)((((long)srcHeight << 16) - 1) / dhm1) : 0;
-
- /*** Prepare source-related data ***/
- final int stype;
- switch (srcDepth) {
- case 8:
- stype = TYPE_INDEX_8;
- break;
- case 4:
- srcStride <<= 1;
- stype = TYPE_INDEX_4;
- break;
- case 2:
- srcStride <<= 2;
- stype = TYPE_INDEX_2;
- break;
- case 1:
- srcStride <<= 3;
- stype = (srcOrder == MSB_FIRST) ? TYPE_INDEX_1_MSB : TYPE_INDEX_1_LSB;
- break;
- default:
- //throw new IllegalArgumentException("Invalid source type");
- return;
- }
- int spr = srcY * srcStride + srcX;
-
- /*** Prepare destination-related data ***/
- final int dbpp, dtype;
- switch (destDepth) {
- case 8:
- dbpp = 1;
- dtype = TYPE_GENERIC_8;
- break;
- case 16:
- dbpp = 2;
- dtype = (destOrder == MSB_FIRST) ? TYPE_GENERIC_16_MSB : TYPE_GENERIC_16_LSB;
- break;
- case 24:
- dbpp = 3;
- dtype = TYPE_GENERIC_24;
- break;
- case 32:
- dbpp = 4;
- dtype = (destOrder == MSB_FIRST) ? TYPE_GENERIC_32_MSB : TYPE_GENERIC_32_LSB;
- break;
- default:
- //throw new IllegalArgumentException("Invalid destination type");
- return;
- }
- int dpr = ((flipY) ? destY + dhm1 : destY) * destStride + ((flipX) ? destX + dwm1 : destX) * dbpp;
- final int dprxi = (flipX) ? -dbpp : dbpp;
- final int dpryi = (flipY) ? -destStride : destStride;
-
- /*** Prepare special processing data ***/
- int apr;
- if ((op & BLIT_ALPHA) != 0) {
- switch (alphaMode) {
- case ALPHA_MASK_UNPACKED:
- case ALPHA_CHANNEL_SEPARATE:
- if (alphaData == null) alphaMode = 0x10000;
- apr = alphaY * alphaStride + alphaX;
- break;
- case ALPHA_MASK_PACKED:
- if (alphaData == null) alphaMode = 0x10000;
- alphaStride <<= 3;
- apr = alphaY * alphaStride + alphaX;
- break;
- case ALPHA_MASK_INDEX:
- case ALPHA_MASK_RGB:
- if (alphaData == null) alphaMode = 0x10000;
- apr = 0;
- break;
- default:
- alphaMode = (alphaMode << 16) / 255; // prescale
- case ALPHA_CHANNEL_SOURCE:
- apr = 0;
- break;
- }
- } else {
- alphaMode = 0x10000;
- apr = 0;
- }
-
- /*** Comprehensive blit (apply transformations) ***/
- final int destRedShift = getChannelShift(destRedMask);
- final int destRedWidth = getChannelWidth(destRedMask, destRedShift);
- final byte[] destReds = ANY_TO_EIGHT[destRedWidth];
- final int destRedPreShift = 8 - destRedWidth;
- final int destGreenShift = getChannelShift(destGreenMask);
- final int destGreenWidth = getChannelWidth(destGreenMask, destGreenShift);
- final byte[] destGreens = ANY_TO_EIGHT[destGreenWidth];
- final int destGreenPreShift = 8 - destGreenWidth;
- final int destBlueShift = getChannelShift(destBlueMask);
- final int destBlueWidth = getChannelWidth(destBlueMask, destBlueShift);
- final byte[] destBlues = ANY_TO_EIGHT[destBlueWidth];
- final int destBluePreShift = 8 - destBlueWidth;
- final int destAlphaShift = getChannelShift(destAlphaMask);
- final int destAlphaWidth = getChannelWidth(destAlphaMask, destAlphaShift);
- final byte[] destAlphas = ANY_TO_EIGHT[destAlphaWidth];
- final int destAlphaPreShift = 8 - destAlphaWidth;
-
- int dp = dpr;
- int sp = spr;
- int ap = apr, alpha = alphaMode;
- int r = 0, g = 0, b = 0, a = 0, index = 0;
- int rq = 0, gq = 0, bq = 0, aq = 0;
- for (int dy = destHeight, sfy = sfyi; dy > 0; --dy,
- sp = spr += (sfy >>> 16) * srcStride,
- ap = apr += (sfy >>> 16) * alphaStride,
- sfy = (sfy & 0xffff) + sfyi,
- dp = dpr += dpryi) {
- for (int dx = destWidth, sfx = sfxi; dx > 0; --dx,
- dp += dprxi,
- sfx = (sfx & 0xffff) + sfxi) {
- /*** READ NEXT PIXEL ***/
- switch (stype) {
- case TYPE_INDEX_8:
- index = srcData[sp] & 0xff;
- sp += (sfx >>> 16);
- break;
- case TYPE_INDEX_4:
- if ((sp & 1) != 0) index = srcData[sp >> 1] & 0x0f;
- else index = (srcData[sp >> 1] >>> 4) & 0x0f;
- sp += (sfx >>> 16);
- break;
- case TYPE_INDEX_2:
- index = (srcData[sp >> 2] >>> (6 - (sp & 3) * 2)) & 0x03;
- sp += (sfx >>> 16);
- break;
- case TYPE_INDEX_1_MSB:
- index = (srcData[sp >> 3] >>> (7 - (sp & 7))) & 0x01;
- sp += (sfx >>> 16);
- break;
- case TYPE_INDEX_1_LSB:
- index = (srcData[sp >> 3] >>> (sp & 7)) & 0x01;
- sp += (sfx >>> 16);
- break;
- }
-
- /*** DO SPECIAL PROCESSING IF REQUIRED ***/
- r = srcReds[index] & 0xff;
- g = srcGreens[index] & 0xff;
- b = srcBlues[index] & 0xff;
- switch (alphaMode) {
- case ALPHA_CHANNEL_SEPARATE:
- alpha = ((alphaData[ap] & 0xff) << 16) / 255;
- ap += (sfx >> 16);
- break;
- case ALPHA_MASK_UNPACKED:
- alpha = (alphaData[ap] != 0) ? 0x10000 : 0;
- ap += (sfx >> 16);
- break;
- case ALPHA_MASK_PACKED:
- alpha = (alphaData[ap >> 3] << ((ap & 7) + 9)) & 0x10000;
- ap += (sfx >> 16);
- break;
- case ALPHA_MASK_INDEX: { // could speed up using binary search if we sorted the indices
- int i = 0;
- while (i < alphaData.length) {
- if (index == (alphaData[i] & 0xff)) break;
- }
- if (i < alphaData.length) continue;
- } break;
- case ALPHA_MASK_RGB: {
- int i = 0;
- while (i < alphaData.length) {
- if ((r == (alphaData[i] & 0xff)) &&
- (g == (alphaData[i + 1] & 0xff)) &&
- (b == (alphaData[i + 2] & 0xff))) break;
- i += 3;
- }
- if (i < alphaData.length) continue;
- } break;
- }
- if (alpha != 0x10000) {
- if (alpha == 0x0000) continue;
- switch (dtype) {
- case TYPE_GENERIC_8: {
- final int data = destData[dp] & 0xff;
- rq = destReds[(data & destRedMask) >>> destRedShift] & 0xff;
- gq = destGreens[(data & destGreenMask) >>> destGreenShift] & 0xff;
- bq = destBlues[(data & destBlueMask) >>> destBlueShift] & 0xff;
- aq = destAlphas[(data & destAlphaMask) >>> destAlphaShift] & 0xff;
- } break;
- case TYPE_GENERIC_16_MSB: {
- final int data = ((destData[dp] & 0xff) << 8) | (destData[dp + 1] & 0xff);
- rq = destReds[(data & destRedMask) >>> destRedShift] & 0xff;
- gq = destGreens[(data & destGreenMask) >>> destGreenShift] & 0xff;
- bq = destBlues[(data & destBlueMask) >>> destBlueShift] & 0xff;
- aq = destAlphas[(data & destAlphaMask) >>> destAlphaShift] & 0xff;
- } break;
- case TYPE_GENERIC_16_LSB: {
- final int data = ((destData[dp + 1] & 0xff) << 8) | (destData[dp] & 0xff);
- rq = destReds[(data & destRedMask) >>> destRedShift] & 0xff;
- gq = destGreens[(data & destGreenMask) >>> destGreenShift] & 0xff;
- bq = destBlues[(data & destBlueMask) >>> destBlueShift] & 0xff;
- aq = destAlphas[(data & destAlphaMask) >>> destAlphaShift] & 0xff;
- } break;
- case TYPE_GENERIC_24: {
- final int data = (( ((destData[dp] & 0xff) << 8) |
- (destData[dp + 1] & 0xff)) << 8) |
- (destData[dp + 2] & 0xff);
- rq = destReds[(data & destRedMask) >>> destRedShift] & 0xff;
- gq = destGreens[(data & destGreenMask) >>> destGreenShift] & 0xff;
- bq = destBlues[(data & destBlueMask) >>> destBlueShift] & 0xff;
- aq = destAlphas[(data & destAlphaMask) >>> destAlphaShift] & 0xff;
- } break;
- case TYPE_GENERIC_32_MSB: {
- final int data = (( (( ((destData[dp] & 0xff) << 8) |
- (destData[dp + 1] & 0xff)) << 8) |
- (destData[dp + 2] & 0xff)) << 8) |
- (destData[dp + 3] & 0xff);
- rq = destReds[(data & destRedMask) >>> destRedShift] & 0xff;
- gq = destGreens[(data & destGreenMask) >>> destGreenShift] & 0xff;
- bq = destBlues[(data & destBlueMask) >>> destBlueShift] & 0xff;
- aq = destAlphas[(data & destAlphaMask) >>> destAlphaShift] & 0xff;
- } break;
- case TYPE_GENERIC_32_LSB: {
- final int data = (( (( ((destData[dp + 3] & 0xff) << 8) |
- (destData[dp + 2] & 0xff)) << 8) |
- (destData[dp + 1] & 0xff)) << 8) |
- (destData[dp] & 0xff);
- rq = destReds[(data & destRedMask) >>> destRedShift] & 0xff;
- gq = destGreens[(data & destGreenMask) >>> destGreenShift] & 0xff;
- bq = destBlues[(data & destBlueMask) >>> destBlueShift] & 0xff;
- aq = destAlphas[(data & destAlphaMask) >>> destAlphaShift] & 0xff;
- } break;
- }
- // Perform alpha blending
- a = aq + ((a - aq) * alpha >> 16);
- r = rq + ((r - rq) * alpha >> 16);
- g = gq + ((g - gq) * alpha >> 16);
- b = bq + ((b - bq) * alpha >> 16);
- }
-
- /*** WRITE NEXT PIXEL ***/
- final int data =
- (r >>> destRedPreShift << destRedShift) |
- (g >>> destGreenPreShift << destGreenShift) |
- (b >>> destBluePreShift << destBlueShift) |
- (a >>> destAlphaPreShift << destAlphaShift);
- switch (dtype) {
- case TYPE_GENERIC_8: {
- destData[dp] = (byte) data;
- } break;
- case TYPE_GENERIC_16_MSB: {
- destData[dp] = (byte) (data >>> 8);
- destData[dp + 1] = (byte) (data & 0xff);
- } break;
- case TYPE_GENERIC_16_LSB: {
- destData[dp] = (byte) (data & 0xff);
- destData[dp + 1] = (byte) (data >>> 8);
- } break;
- case TYPE_GENERIC_24: {
- destData[dp] = (byte) (data >>> 16);
- destData[dp + 1] = (byte) (data >>> 8);
- destData[dp + 2] = (byte) (data & 0xff);
- } break;
- case TYPE_GENERIC_32_MSB: {
- destData[dp] = (byte) (data >>> 24);
- destData[dp + 1] = (byte) (data >>> 16);
- destData[dp + 2] = (byte) (data >>> 8);
- destData[dp + 3] = (byte) (data & 0xff);
- } break;
- case TYPE_GENERIC_32_LSB: {
- destData[dp] = (byte) (data & 0xff);
- destData[dp + 1] = (byte) (data >>> 8);
- destData[dp + 2] = (byte) (data >>> 16);
- destData[dp + 3] = (byte) (data >>> 24);
- } break;
- }
- }
- }
-}
-
-/**
- * Blits a direct palette image into an index palette image.
- * <p>
- * Note: The source and destination masks and palettes must
- * always be fully specified.
- * </p>
- *
- * @param op the blitter operation: a combination of BLIT_xxx flags
- * (see BLIT_xxx constants)
- * @param srcData the source byte array containing image data
- * @param srcDepth the source depth: one of 8, 16, 24, 32
- * @param srcStride the source number of bytes per line
- * @param srcOrder the source byte ordering: one of MSB_FIRST or LSB_FIRST;
- * ignored if srcDepth is not 16 or 32
- * @param srcX the top-left x-coord of the source blit region
- * @param srcY the top-left y-coord of the source blit region
- * @param srcWidth the width of the source blit region
- * @param srcHeight the height of the source blit region
- * @param srcRedMask the source red channel mask
- * @param srcGreenMask the source green channel mask
- * @param srcBlueMask the source blue channel mask
- * @param alphaMode the alpha blending or mask mode, may be
- * an integer 0-255 for global alpha; ignored if BLIT_ALPHA
- * not specified in the blitter operations
- * (see ALPHA_MODE_xxx constants)
- * @param alphaData the alpha blending or mask data, varies depending
- * on the value of alphaMode and sometimes ignored
- * @param alphaStride the alpha data number of bytes per line
- * @param alphaX the top-left x-coord of the alpha blit region
- * @param alphaY the top-left y-coord of the alpha blit region
- * @param destData the destination byte array containing image data
- * @param destDepth the destination depth: one of 1, 2, 4, 8
- * @param destStride the destination number of bytes per line
- * @param destOrder the destination byte ordering: one of MSB_FIRST or LSB_FIRST;
- * ignored if destDepth is not 1
- * @param destX the top-left x-coord of the destination blit region
- * @param destY the top-left y-coord of the destination blit region
- * @param destWidth the width of the destination blit region
- * @param destHeight the height of the destination blit region
- * @param destReds the destination palette red component intensities
- * @param destGreens the destination palette green component intensities
- * @param destBlues the destination palette blue component intensities
- * @param flipX if true the resulting image is flipped along the vertical axis
- * @param flipY if true the resulting image is flipped along the horizontal axis
- */
-static void blit(int op,
- byte[] srcData, int srcDepth, int srcStride, int srcOrder,
- int srcX, int srcY, int srcWidth, int srcHeight,
- int srcRedMask, int srcGreenMask, int srcBlueMask,
- int alphaMode, byte[] alphaData, int alphaStride, int alphaX, int alphaY,
- byte[] destData, int destDepth, int destStride, int destOrder,
- int destX, int destY, int destWidth, int destHeight,
- byte[] destReds, byte[] destGreens, byte[] destBlues,
- boolean flipX, boolean flipY) {
- if ((destWidth <= 0) || (destHeight <= 0) || (alphaMode == ALPHA_TRANSPARENT)) return;
-
- // these should be supplied as params later
- final int srcAlphaMask = 0;
-
- /*** Prepare scaling data ***/
- final int dwm1 = destWidth - 1;
- final int sfxi = (dwm1 != 0) ? (int)((((long)srcWidth << 16) - 1) / dwm1) : 0;
- final int dhm1 = destHeight - 1;
- final int sfyi = (dhm1 != 0) ? (int)((((long)srcHeight << 16) - 1) / dhm1) : 0;
-
- /*** Prepare source-related data ***/
- final int sbpp, stype;
- switch (srcDepth) {
- case 8:
- sbpp = 1;
- stype = TYPE_GENERIC_8;
- break;
- case 16:
- sbpp = 2;
- stype = (srcOrder == MSB_FIRST) ? TYPE_GENERIC_16_MSB : TYPE_GENERIC_16_LSB;
- break;
- case 24:
- sbpp = 3;
- stype = TYPE_GENERIC_24;
- break;
- case 32:
- sbpp = 4;
- stype = (srcOrder == MSB_FIRST) ? TYPE_GENERIC_32_MSB : TYPE_GENERIC_32_LSB;
- break;
- default:
- //throw new IllegalArgumentException("Invalid source type");
- return;
- }
- int spr = srcY * srcStride + srcX * sbpp;
-
- /*** Prepare destination-related data ***/
- final int dtype;
- switch (destDepth) {
- case 8:
- dtype = TYPE_INDEX_8;
- break;
- case 4:
- destStride <<= 1;
- dtype = TYPE_INDEX_4;
- break;
- case 2:
- destStride <<= 2;
- dtype = TYPE_INDEX_2;
- break;
- case 1:
- destStride <<= 3;
- dtype = (destOrder == MSB_FIRST) ? TYPE_INDEX_1_MSB : TYPE_INDEX_1_LSB;
- break;
- default:
- //throw new IllegalArgumentException("Invalid source type");
- return;
- }
- int dpr = ((flipY) ? destY + dhm1 : destY) * destStride + ((flipX) ? destX + dwm1 : destX);
- final int dprxi = (flipX) ? -1 : 1;
- final int dpryi = (flipY) ? -destStride : destStride;
-
- /*** Prepare special processing data ***/
- int apr;
- if ((op & BLIT_ALPHA) != 0) {
- switch (alphaMode) {
- case ALPHA_MASK_UNPACKED:
- case ALPHA_CHANNEL_SEPARATE:
- if (alphaData == null) alphaMode = 0x10000;
- apr = alphaY * alphaStride + alphaX;
- break;
- case ALPHA_MASK_PACKED:
- if (alphaData == null) alphaMode = 0x10000;
- alphaStride <<= 3;
- apr = alphaY * alphaStride + alphaX;
- break;
- case ALPHA_MASK_INDEX:
- //throw new IllegalArgumentException("Invalid alpha type");
- return;
- case ALPHA_MASK_RGB:
- if (alphaData == null) alphaMode = 0x10000;
- apr = 0;
- break;
- default:
- alphaMode = (alphaMode << 16) / 255; // prescale
- case ALPHA_CHANNEL_SOURCE:
- apr = 0;
- break;
- }
- } else {
- alphaMode = 0x10000;
- apr = 0;
- }
- final boolean ditherEnabled = (op & BLIT_DITHER) != 0;
-
- /*** Comprehensive blit (apply transformations) ***/
- final int srcRedShift = getChannelShift(srcRedMask);
- final byte[] srcReds = ANY_TO_EIGHT[getChannelWidth(srcRedMask, srcRedShift)];
- final int srcGreenShift = getChannelShift(srcGreenMask);
- final byte[] srcGreens = ANY_TO_EIGHT[getChannelWidth(srcGreenMask, srcGreenShift)];
- final int srcBlueShift = getChannelShift(srcBlueMask);
- final byte[] srcBlues = ANY_TO_EIGHT[getChannelWidth(srcBlueMask, srcBlueShift)];
- final int srcAlphaShift = getChannelShift(srcAlphaMask);
- final byte[] srcAlphas = ANY_TO_EIGHT[getChannelWidth(srcAlphaMask, srcAlphaShift)];
-
- int dp = dpr;
- int sp = spr;
- int ap = apr, alpha = alphaMode;
- int r = 0, g = 0, b = 0, a = 0;
- int indexq = 0;
- int lastindex = 0, lastr = -1, lastg = -1, lastb = -1;
- final int[] rerr, gerr, berr;
- int destPaletteSize = 1 << destDepth;
- if ((destReds != null) && (destReds.length < destPaletteSize)) destPaletteSize = destReds.length;
- if (ditherEnabled) {
- rerr = new int[destWidth + 2];
- gerr = new int[destWidth + 2];
- berr = new int[destWidth + 2];
- } else {
- rerr = null; gerr = null; berr = null;
- }
- for (int dy = destHeight, sfy = sfyi; dy > 0; --dy,
- sp = spr += (sfy >>> 16) * srcStride,
- ap = apr += (sfy >>> 16) * alphaStride,
- sfy = (sfy & 0xffff) + sfyi,
- dp = dpr += dpryi) {
- int lrerr = 0, lgerr = 0, lberr = 0;
- for (int dx = destWidth, sfx = sfxi; dx > 0; --dx,
- dp += dprxi,
- sfx = (sfx & 0xffff) + sfxi) {
- /*** READ NEXT PIXEL ***/
- switch (stype) {
- case TYPE_GENERIC_8: {
- final int data = srcData[sp] & 0xff;
- sp += (sfx >>> 16);
- r = srcReds[(data & srcRedMask) >>> srcRedShift] & 0xff;
- g = srcGreens[(data & srcGreenMask) >>> srcGreenShift] & 0xff;
- b = srcBlues[(data & srcBlueMask) >>> srcBlueShift] & 0xff;
- a = srcAlphas[(data & srcAlphaMask) >>> srcAlphaShift] & 0xff;
- } break;
- case TYPE_GENERIC_16_MSB: {
- final int data = ((srcData[sp] & 0xff) << 8) | (srcData[sp + 1] & 0xff);
- sp += (sfx >>> 16) * 2;
- r = srcReds[(data & srcRedMask) >>> srcRedShift] & 0xff;
- g = srcGreens[(data & srcGreenMask) >>> srcGreenShift] & 0xff;
- b = srcBlues[(data & srcBlueMask) >>> srcBlueShift] & 0xff;
- a = srcAlphas[(data & srcAlphaMask) >>> srcAlphaShift] & 0xff;
- } break;
- case TYPE_GENERIC_16_LSB: {
- final int data = ((srcData[sp + 1] & 0xff) << 8) | (srcData[sp] & 0xff);
- sp += (sfx >>> 16) * 2;
- r = srcReds[(data & srcRedMask) >>> srcRedShift] & 0xff;
- g = srcGreens[(data & srcGreenMask) >>> srcGreenShift] & 0xff;
- b = srcBlues[(data & srcBlueMask) >>> srcBlueShift] & 0xff;
- a = srcAlphas[(data & srcAlphaMask) >>> srcAlphaShift] & 0xff;
- } break;
- case TYPE_GENERIC_24: {
- final int data = (( ((srcData[sp] & 0xff) << 8) |
- (srcData[sp + 1] & 0xff)) << 8) |
- (srcData[sp + 2] & 0xff);
- sp += (sfx >>> 16) * 3;
- r = srcReds[(data & srcRedMask) >>> srcRedShift] & 0xff;
- g = srcGreens[(data & srcGreenMask) >>> srcGreenShift] & 0xff;
- b = srcBlues[(data & srcBlueMask) >>> srcBlueShift] & 0xff;
- a = srcAlphas[(data & srcAlphaMask) >>> srcAlphaShift] & 0xff;
- } break;
- case TYPE_GENERIC_32_MSB: {
- final int data = (( (( ((srcData[sp] & 0xff) << 8) |
- (srcData[sp + 1] & 0xff)) << 8) |
- (srcData[sp + 2] & 0xff)) << 8) |
- (srcData[sp + 3] & 0xff);
- sp += (sfx >>> 16) * 4;
- r = srcReds[(data & srcRedMask) >>> srcRedShift] & 0xff;
- g = srcGreens[(data & srcGreenMask) >>> srcGreenShift] & 0xff;
- b = srcBlues[(data & srcBlueMask) >>> srcBlueShift] & 0xff;
- a = srcAlphas[(data & srcAlphaMask) >>> srcAlphaShift] & 0xff;
- } break;
- case TYPE_GENERIC_32_LSB: {
- final int data = (( (( ((srcData[sp + 3] & 0xff) << 8) |
- (srcData[sp + 2] & 0xff)) << 8) |
- (srcData[sp + 1] & 0xff)) << 8) |
- (srcData[sp] & 0xff);
- sp += (sfx >>> 16) * 4;
- r = srcReds[(data & srcRedMask) >>> srcRedShift] & 0xff;
- g = srcGreens[(data & srcGreenMask) >>> srcGreenShift] & 0xff;
- b = srcBlues[(data & srcBlueMask) >>> srcBlueShift] & 0xff;
- a = srcAlphas[(data & srcAlphaMask) >>> srcAlphaShift] & 0xff;
- } break;
- }
-
- /*** DO SPECIAL PROCESSING IF REQUIRED ***/
- switch (alphaMode) {
- case ALPHA_CHANNEL_SEPARATE:
- alpha = ((alphaData[ap] & 0xff) << 16) / 255;
- ap += (sfx >> 16);
- break;
- case ALPHA_CHANNEL_SOURCE:
- alpha = (a << 16) / 255;
- break;
- case ALPHA_MASK_UNPACKED:
- alpha = (alphaData[ap] != 0) ? 0x10000 : 0;
- ap += (sfx >> 16);
- break;
- case ALPHA_MASK_PACKED:
- alpha = (alphaData[ap >> 3] << ((ap & 7) + 9)) & 0x10000;
- ap += (sfx >> 16);
- break;
- case ALPHA_MASK_RGB:
- alpha = 0x10000;
- for (int i = 0; i < alphaData.length; i += 3) {
- if ((r == alphaData[i]) && (g == alphaData[i + 1]) && (b == alphaData[i + 2])) {
- alpha = 0x0000;
- break;
- }
- }
- break;
- }
- if (alpha != 0x10000) {
- if (alpha == 0x0000) continue;
- switch (dtype) {
- case TYPE_INDEX_8:
- indexq = destData[dp] & 0xff;
- break;
- case TYPE_INDEX_4:
- if ((dp & 1) != 0) indexq = destData[dp >> 1] & 0x0f;
- else indexq = (destData[dp >> 1] >>> 4) & 0x0f;
- break;
- case TYPE_INDEX_2:
- indexq = (destData[dp >> 2] >>> (6 - (dp & 3) * 2)) & 0x03;
- break;
- case TYPE_INDEX_1_MSB:
- indexq = (destData[dp >> 3] >>> (7 - (dp & 7))) & 0x01;
- break;
- case TYPE_INDEX_1_LSB:
- indexq = (destData[dp >> 3] >>> (dp & 7)) & 0x01;
- break;
- }
- // Perform alpha blending
- final int rq = destReds[indexq] & 0xff;
- final int gq = destGreens[indexq] & 0xff;
- final int bq = destBlues[indexq] & 0xff;
- r = rq + ((r - rq) * alpha >> 16);
- g = gq + ((g - gq) * alpha >> 16);
- b = bq + ((b - bq) * alpha >> 16);
- }
-
- /*** MAP COLOR TO THE PALETTE ***/
- if (ditherEnabled) {
- // Floyd-Steinberg error diffusion
- r += rerr[dx] >> 4;
- if (r < 0) r = 0; else if (r > 255) r = 255;
- g += gerr[dx] >> 4;
- if (g < 0) g = 0; else if (g > 255) g = 255;
- b += berr[dx] >> 4;
- if (b < 0) b = 0; else if (b > 255) b = 255;
- rerr[dx] = lrerr;
- gerr[dx] = lgerr;
- berr[dx] = lberr;
- }
- if (r != lastr || g != lastg || b != lastb) {
- // moving the variable declarations out seems to make the JDK JIT happier...
- for (int j = 0, dr, dg, db, distance, minDistance = 0x7fffffff; j < destPaletteSize; ++j) {
- dr = (destReds[j] & 0xff) - r;
- dg = (destGreens[j] & 0xff) - g;
- db = (destBlues[j] & 0xff) - b;
- distance = dr * dr + dg * dg + db * db;
- if (distance < minDistance) {
- lastindex = j;
- if (distance == 0) break;
- minDistance = distance;
- }
- }
- lastr = r; lastg = g; lastb = b;
- }
- if (ditherEnabled) {
- // Floyd-Steinberg error diffusion, cont'd...
- final int dxm1 = dx - 1, dxp1 = dx + 1;
- int acc;
- rerr[dxp1] += acc = (lrerr = r - (destReds[lastindex] & 0xff)) + lrerr + lrerr;
- rerr[dx] += acc += lrerr + lrerr;
- rerr[dxm1] += acc + lrerr + lrerr;
- gerr[dxp1] += acc = (lgerr = g - (destGreens[lastindex] & 0xff)) + lgerr + lgerr;
- gerr[dx] += acc += lgerr + lgerr;
- gerr[dxm1] += acc + lgerr + lgerr;
- berr[dxp1] += acc = (lberr = b - (destBlues[lastindex] & 0xff)) + lberr + lberr;
- berr[dx] += acc += lberr + lberr;
- berr[dxm1] += acc + lberr + lberr;
- }
-
- /*** WRITE NEXT PIXEL ***/
- switch (dtype) {
- case TYPE_INDEX_8:
- destData[dp] = (byte) lastindex;
- break;
- case TYPE_INDEX_4:
- if ((dp & 1) != 0) destData[dp >> 1] = (byte)((destData[dp >> 1] & 0xf0) | lastindex);
- else destData[dp >> 1] = (byte)((destData[dp >> 1] & 0x0f) | (lastindex << 4));
- break;
- case TYPE_INDEX_2: {
- final int shift = 6 - (dp & 3) * 2;
- destData[dp >> 2] = (byte)(destData[dp >> 2] & ~(0x03 << shift) | (lastindex << shift));
- } break;
- case TYPE_INDEX_1_MSB: {
- final int shift = 7 - (dp & 7);
- destData[dp >> 3] = (byte)(destData[dp >> 3] & ~(0x01 << shift) | (lastindex << shift));
- } break;
- case TYPE_INDEX_1_LSB: {
- final int shift = dp & 7;
- destData[dp >> 3] = (byte)(destData[dp >> 3] & ~(0x01 << shift) | (lastindex << shift));
- } break;
- }
- }
- }
-}
-
-/**
- * Computes the required channel shift from a mask.
- */
-static int getChannelShift(int mask) {
- if (mask == 0) return 0;
- int i;
- for (i = 0; ((mask & 1) == 0) && (i < 32); ++i) {
- mask >>>= 1;
- }
- return i;
-}
-
-/**
- * Computes the required channel width (depth) from a mask.
- */
-static int getChannelWidth(int mask, int shift) {
- if (mask == 0) return 0;
- int i;
- mask >>>= shift;
- for (i = shift; ((mask & 1) != 0) && (i < 32); ++i) {
- mask >>>= 1;
- }
- return i - shift;
-}
-
-/**
- * Extracts a field from packed RGB data given a mask for that field.
- */
-static byte getChannelField(int data, int mask) {
- final int shift = getChannelShift(mask);
- return ANY_TO_EIGHT[getChannelWidth(mask, shift)][(data & mask) >>> shift];
-}
-
-/**
- * Creates an ImageData containing one band's worth of a gradient filled
- * block. If <code>vertical</code> is true, the band must be tiled
- * horizontally to fill a region, otherwise it must be tiled vertically.
- *
- * @param width the width of the region to be filled
- * @param height the height of the region to be filled
- * @param vertical if true sweeps from top to bottom, else
- * sweeps from left to right
- * @param fromRGB the color to start with
- * @param toRGB the color to end with
- * @param redBits the number of significant red bits, 0 for palette modes
- * @param greenBits the number of significant green bits, 0 for palette modes
- * @param blueBits the number of significant blue bits, 0 for palette modes
- * @return the new ImageData
- */
-static ImageData createGradientBand(
- int width, int height, boolean vertical,
- RGB fromRGB, RGB toRGB,
- int redBits, int greenBits, int blueBits) {
- /* Gradients are drawn as tiled bands */
- final int bandWidth, bandHeight, bitmapDepth;
- final byte[] bitmapData;
- final PaletteData paletteData;
- /* Select an algorithm depending on the depth of the screen */
- if (redBits != 0 && greenBits != 0 && blueBits != 0) {
- paletteData = new PaletteData(0x0000ff00, 0x00ff0000, 0xff000000);
- bitmapDepth = 32;
- if (redBits >= 8 && greenBits >= 8 && blueBits >= 8) {
- /* Precise color */
- final int steps;
- if (vertical) {
- bandWidth = 1;
- bandHeight = height;
- steps = bandHeight > 1 ? bandHeight - 1 : 1;
- } else {
- bandWidth = width;
- bandHeight = 1;
- steps = bandWidth > 1 ? bandWidth - 1 : 1;
- }
- final int bytesPerLine = bandWidth * 4;
- bitmapData = new byte[bandHeight * bytesPerLine];
- buildPreciseGradientChannel(fromRGB.blue, toRGB.blue, steps, bandWidth, bandHeight, vertical, bitmapData, 0, bytesPerLine);
- buildPreciseGradientChannel(fromRGB.green, toRGB.green, steps, bandWidth, bandHeight, vertical, bitmapData, 1, bytesPerLine);
- buildPreciseGradientChannel(fromRGB.red, toRGB.red, steps, bandWidth, bandHeight, vertical, bitmapData, 2, bytesPerLine);
- } else {
- /* Dithered color */
- final int steps;
- if (vertical) {
- bandWidth = (width < 8) ? width : 8;
- bandHeight = height;
- steps = bandHeight > 1 ? bandHeight - 1 : 1;
- } else {
- bandWidth = width;
- bandHeight = (height < 8) ? height : 8;
- steps = bandWidth > 1 ? bandWidth - 1 : 1;
- }
- final int bytesPerLine = bandWidth * 4;
- bitmapData = new byte[bandHeight * bytesPerLine];
- buildDitheredGradientChannel(fromRGB.blue, toRGB.blue, steps, bandWidth, bandHeight, vertical, bitmapData, 0, bytesPerLine, blueBits);
- buildDitheredGradientChannel(fromRGB.green, toRGB.green, steps, bandWidth, bandHeight, vertical, bitmapData, 1, bytesPerLine, greenBits);
- buildDitheredGradientChannel(fromRGB.red, toRGB.red, steps, bandWidth, bandHeight, vertical, bitmapData, 2, bytesPerLine, redBits);
- }
- } else {
- /* Dithered two tone */
- paletteData = new PaletteData(new RGB[] { fromRGB, toRGB });
- bitmapDepth = 8;
- final int blendi;
- if (vertical) {
- bandWidth = (width < 8) ? width : 8;
- bandHeight = height;
- blendi = (bandHeight > 1) ? 0x1040000 / (bandHeight - 1) + 1 : 1;
- } else {
- bandWidth = width;
- bandHeight = (height < 8) ? height : 8;
- blendi = (bandWidth > 1) ? 0x1040000 / (bandWidth - 1) + 1 : 1;
- }
- final int bytesPerLine = (bandWidth + 3) & -4;
- bitmapData = new byte[bandHeight * bytesPerLine];
- if (vertical) {
- for (int dy = 0, blend = 0, dp = 0; dy < bandHeight;
- ++dy, blend += blendi, dp += bytesPerLine) {
- for (int dx = 0; dx < bandWidth; ++dx) {
- bitmapData[dp + dx] = (blend + DITHER_MATRIX[dy & 7][dx]) <
- 0x1000000 ? (byte)0 : (byte)1;
- }
- }
- } else {
- for (int dx = 0, blend = 0; dx < bandWidth; ++dx, blend += blendi) {
- for (int dy = 0, dptr = dx; dy < bandHeight; ++dy, dptr += bytesPerLine) {
- bitmapData[dptr] = (blend + DITHER_MATRIX[dy][dx & 7]) <
- 0x1000000 ? (byte)0 : (byte)1;
- }
- }
- }
- }
- return new ImageData(bandWidth, bandHeight, bitmapDepth, paletteData, 4, bitmapData);
-}
-
-/*
- * Fill in gradated values for a color channel
- */
-static final void buildPreciseGradientChannel(int from, int to, int steps,
- int bandWidth, int bandHeight, boolean vertical,
- byte[] bitmapData, int dp, int bytesPerLine) {
- int val = from << 16;
- final int inc = ((to << 16) - val) / steps + 1;
- if (vertical) {
- for (int dy = 0; dy < bandHeight; ++dy, dp += bytesPerLine) {
- bitmapData[dp] = (byte)(val >>> 16);
- val += inc;
- }
- } else {
- for (int dx = 0; dx < bandWidth; ++dx, dp += 4) {
- bitmapData[dp] = (byte)(val >>> 16);
- val += inc;
- }
- }
-}
-
-/*
- * Fill in dithered gradated values for a color channel
- */
-static final void buildDitheredGradientChannel(int from, int to, int steps,
- int bandWidth, int bandHeight, boolean vertical,
- byte[] bitmapData, int dp, int bytesPerLine, int bits) {
- final int mask = 0xff00 >>> bits;
- int val = from << 16;
- final int inc = ((to << 16) - val) / steps + 1;
- if (vertical) {
- for (int dy = 0; dy < bandHeight; ++dy, dp += bytesPerLine) {
- for (int dx = 0, dptr = dp; dx < bandWidth; ++dx, dptr += 4) {
- final int thresh = DITHER_MATRIX[dy & 7][dx] >>> bits;
- int temp = val + thresh;
- if (temp > 0xffffff) bitmapData[dptr] = -1;
- else bitmapData[dptr] = (byte)((temp >>> 16) & mask);
- }
- val += inc;
- }
- } else {
- for (int dx = 0; dx < bandWidth; ++dx, dp += 4) {
- for (int dy = 0, dptr = dp; dy < bandHeight; ++dy, dptr += bytesPerLine) {
- final int thresh = DITHER_MATRIX[dy][dx & 7] >>> bits;
- int temp = val + thresh;
- if (temp > 0xffffff) bitmapData[dptr] = -1;
- else bitmapData[dptr] = (byte)((temp >>> 16) & mask);
- }
- val += inc;
- }
- }
-}
-
-/**
- * Renders a gradient onto a GC.
- * <p>
- * This is a GC helper.
- * </p>
- *
- * @param gc the GC to render the gradient onto
- * @param device the device the GC belongs to
- * @param x the top-left x coordinate of the region to be filled
- * @param y the top-left y coordinate of the region to be filled
- * @param width the width of the region to be filled
- * @param height the height of the region to be filled
- * @param vertical if true sweeps from top to bottom, else
- * sweeps from left to right
- * @param fromRGB the color to start with
- * @param toRGB the color to end with
- * @param redBits the number of significant red bits, 0 for palette modes
- * @param greenBits the number of significant green bits, 0 for palette modes
- * @param blueBits the number of significant blue bits, 0 for palette modes
- */
-static void fillGradientRectangle(GC gc, Device device,
- int x, int y, int width, int height, boolean vertical,
- RGB fromRGB, RGB toRGB,
- int redBits, int greenBits, int blueBits) {
- /* Create the bitmap and tile it */
- ImageData band = createGradientBand(width, height, vertical,
- fromRGB, toRGB, redBits, greenBits, blueBits);
- Image image = new Image(device, band);
- if ((band.width == 1) || (band.height == 1)) {
- gc.drawImage(image, 0, 0, band.width, band.height, x, y, width, height);
- } else {
- if (vertical) {
- for (int dx = 0; dx < width; dx += band.width) {
- int blitWidth = width - dx;
- if (blitWidth > band.width) blitWidth = band.width;
- gc.drawImage(image, 0, 0, blitWidth, band.height, dx + x, y, blitWidth, band.height);
- }
- } else {
- for (int dy = 0; dy < height; dy += band.height) {
- int blitHeight = height - dy;
- if (blitHeight > band.height) blitHeight = band.height;
- gc.drawImage(image, 0, 0, band.width, blitHeight, x, dy + y, band.width, blitHeight);
- }
- }
- }
- image.dispose();
-}
-
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+import java.io.*;
+import org.eclipse.swt.*;
+import org.eclipse.swt.internal.CloneableCompatibility;
+
+/**
+ * Instances of this class are device-independent descriptions
+ * of images. They are typically used as an intermediate format
+ * between loading from or writing to streams and creating an
+ * <code>Image</code>.
+ * <p>
+ * Note that the public fields <code>x</code>, <code>y</code>,
+ * <code>disposalMethod</code> and <code>delayTime</code> are
+ * typically only used when the image is in a set of images used
+ * for animation.
+ * </p>
+ *
+ * @see Image
+ * @see ImageLoader
+ */
+
+public final class ImageData implements CloneableCompatibility {
+
+ /**
+ * the width of the image, in pixels
+ */
+ public int width;
+
+ /**
+ * the height of the image, in pixels
+ */
+ public int height;
+
+ /**
+ * the color depth of the image, in bits per pixel
+ * <p>
+ * Note that a depth of 8 or less does not necessary
+ * mean that the image is palette indexed, or
+ * conversely that a depth greater than 8 means that
+ * the image is direct color. Check the associated
+ * PaletteData's isDirect field for such determinations.
+ */
+ public int depth;
+
+ /**
+ * the scanline padding
+ * <p>
+ * If one scanline of the image is not a multiple of
+ * this number, it will be padded with zeros until it is.
+ * </p>
+ */
+ public int scanlinePad;
+
+ /**
+ * the number of bytes per scanline
+ * <p>
+ * This is a multiple of the scanline padding.
+ * </p>
+ */
+ public int bytesPerLine;
+
+ /**
+ * the pixel data of the image
+ * <p>
+ * Note that for 16 bit depth images the pixel data is stored
+ * in least significant byte order; however, for 24bit and
+ * 32bit depth images the pixel data is stored in most
+ * significant byte order.
+ * </p>
+ */
+ public byte[] data;
+
+ /**
+ * the color table for the image
+ */
+ public PaletteData palette;
+
+ /**
+ * the transparent pixel
+ * <p>
+ * Pixels with this value are transparent.
+ * </p><p>
+ * The default is -1 which means 'no transparent pixel'.
+ * </p>
+ */
+ public int transparentPixel;
+
+ /**
+ * icon-specific field containing the data from the icon mask
+ * <p>
+ * This is a 1 bit bitmap stored with the most significant
+ * bit first. The number of bytes per scanline is
+ * '((width + 7) / 8 + (maskPad - 1)) / maskPad * maskPad'.
+ * </p><p>
+ * The default is null which means 'no transparency mask'.
+ * </p>
+ */
+ public byte[] maskData;
+
+ /**
+ * icon-specific field containing the scanline pad of the mask
+ * <p>
+ * If one scanline of the transparency mask is not a
+ * multiple of this number, it will be padded with zeros until
+ * it is.
+ * </p>
+ */
+ public int maskPad;
+
+ /**
+ * the alpha data of the image
+ * <p>
+ * Every pixel can have an <em>alpha blending</em> value that
+ * varies from 0, meaning fully transparent, to 255 meaning
+ * fully opaque. The number of bytes per scanline is
+ * 'width'.
+ * </p>
+ */
+ public byte[] alphaData;
+
+ /**
+ * the global alpha value to be used for every pixel
+ * <p>
+ * If this value is set, the <code>alphaData</code> field
+ * is ignored and when the image is rendered each pixel
+ * will be blended with the background an amount
+ * proportional to this value.
+ * </p><p>
+ * The default is -1 which means 'no global alpha value'
+ * </p>
+ */
+ public int alpha;
+
+ /**
+ * the type of file 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;
+
+ /**
+ * Arbitrary channel width data to 8-bit conversion table
+ */
+ static final byte[][] ANY_TO_EIGHT = new byte[9][];
+ static {
+ for (int b = 0; b < 9; ++b) {
+ byte[] data = ANY_TO_EIGHT[b] = new byte[1 << b];
+ if (b == 0) continue;
+ int inc = 0;
+ for (int bit = 0x10000; (bit >>= b) != 0;) inc |= bit;
+ for (int v = 0, p = 0; v < 0x10000; v+= inc) data[p++] = (byte)(v >> 8);
+ }
+ }
+ static final byte[] ONE_TO_ONE_MAPPING = ANY_TO_EIGHT[8];
+
+ /**
+ * Scaled 8x8 Bayer dither matrix
+ */
+ static final int[][] DITHER_MATRIX = {
+ { 0xfc0000, 0x7c0000, 0xdc0000, 0x5c0000, 0xf40000, 0x740000, 0xd40000, 0x540000 },
+ { 0x3c0000, 0xbc0000, 0x1c0000, 0x9c0000, 0x340000, 0xb40000, 0x140000, 0x940000 },
+ { 0xcc0000, 0x4c0000, 0xec0000, 0x6c0000, 0xc40000, 0x440000, 0xe40000, 0x640000 },
+ { 0x0c0000, 0x8c0000, 0x2c0000, 0xac0000, 0x040000, 0x840000, 0x240000, 0xa40000 },
+ { 0xf00000, 0x700000, 0xd00000, 0x500000, 0xf80000, 0x780000, 0xd80000, 0x580000 },
+ { 0x300000, 0xb00000, 0x100000, 0x900000, 0x380000, 0xb80000, 0x180000, 0x980000 },
+ { 0xc00000, 0x400000, 0xe00000, 0x600000, 0xc80000, 0x480000, 0xe80000, 0x680000 },
+ { 0x000000, 0x800000, 0x200000, 0xa00000, 0x080000, 0x880000, 0x280000, 0xa80000 }
+ };
+
+/**
+ * Constructs a new, empty ImageData with the given width, height,
+ * depth and palette. The data will be initialized to an (all zero)
+ * array of the appropriate size.
+ *
+ * @param width the width of the image
+ * @param height the height of the image
+ * @param depth the depth of the image
+ * @param palette the palette of the image (must not be null)
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_INVALID_ARGUMENT - if the width or height is negative</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 IndexOutOfBoundsException if getWidth is too large
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if pixels is null</li>
+ * <li>ERROR_INVALID_ARGUMENT - if x or y is out of bounds</li>
+ * <li>ERROR_INVALID_ARGUMENT - if getWidth is negative</li>
+ * </ul>
+ */
+public void getAlphas(int x, int y, int getWidth, byte[] alphas, int startIndex) {
+ if (alphas == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ if (getWidth < 0 || x >= width || y >= height || x < 0 || y < 0) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+ if (getWidth == 0) return;
+
+ if (alphaData == null) {
+ int endIndex = startIndex + getWidth;
+ for (int i = startIndex; i < endIndex; i++) {
+ alphas[i] = (byte)255;
+ }
+ return;
+ }
+ // may throw an IndexOutOfBoundsException
+ System.arraycopy(alphaData, y * width + x, alphas, startIndex, getWidth);
+}
+
+/**
+ * Returns the pixel value at offset <code>x</code> in
+ * scanline <code>y</code> in the receiver's data.
+ *
+ * @param x the x position of the pixel to get
+ * @param y the y position of the pixel to get
+ * @return the pixel at the given coordinates
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_INVALID_ARGUMENT - if either argument is out of bounds</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_UNSUPPORTED_DEPTH if the depth is not one of 1, 2, 4, 8, 16, 24 or 32</li>
+ * </ul>
+ */
+public int getPixel(int x, int y) {
+ if (x >= width || y >= height || x < 0 || y < 0) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+ int index;
+ int theByte;
+ int mask;
+ 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 IndexOutOfBoundsException if getWidth is too large
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if pixels is null</li>
+ * <li>ERROR_INVALID_ARGUMENT - if x or y is out of bounds</li>
+ * <li>ERROR_INVALID_ARGUMENT - if getWidth is negative</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_UNSUPPORTED_DEPTH - if the depth is not one of 1, 2, 4 or 8
+ * (For higher depths, use the int[] version of this method.)</li>
+ * </ul>
+ */
+public void getPixels(int x, int y, int getWidth, byte[] pixels, int startIndex) {
+ if (pixels == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ if (getWidth < 0 || x >= width || y >= height || x < 0 || y < 0) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+ if (getWidth == 0) return;
+ int index;
+ int theByte;
+ int mask = 0;
+ int n = getWidth;
+ int i = startIndex;
+ int srcX = x, srcY = y;
+ 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 IndexOutOfBoundsException if getWidth is too large
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if pixels is null</li>
+ * <li>ERROR_INVALID_ARGUMENT - if x or y is out of bounds</li>
+ * <li>ERROR_INVALID_ARGUMENT - if getWidth is negative</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_UNSUPPORTED_DEPTH - if the depth is not one of 1, 2, 4, 8, 16, 24 or 32</li>
+ * </ul>
+ */
+public void getPixels(int x, int y, int getWidth, int[] pixels, int startIndex) {
+ if (pixels == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ if (getWidth < 0 || x >= width || y >= height || x < 0 || y < 0) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+ if (getWidth == 0) return;
+ int index;
+ int theByte;
+ int mask;
+ int n = getWidth;
+ int i = startIndex;
+ int srcX = x, srcY = y;
+ 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 the byte order of the receiver.
+ *
+ * @return MSB_FIRST or LSB_FIRST
+ */
+int getByteOrder() {
+ return depth != 16 ? MSB_FIRST : LSB_FIRST;
+}
+
+/**
+ * Returns a copy of the receiver which has been stretched or
+ * shrunk to the specified size. If either the width or height
+ * is negative, the resulting image will be inverted in the
+ * associated axis.
+ *
+ * @param width the width of the new ImageData
+ * @param height the height of the new ImageData
+ * @return a scaled copy of the image
+ */
+public ImageData scaledTo(int width, int height) {
+ /* Create a destination image with no data */
+ final boolean flipX = (width < 0);
+ if (flipX) width = - width;
+ final boolean flipY = (height < 0);
+ if (flipY) height = - height;
+
+ ImageData dest = new ImageData(
+ width, height, depth, palette,
+ scanlinePad, null, 0, null,
+ null, -1, transparentPixel, type,
+ x, y, disposalMethod, delayTime);
+
+ /* Scale the image contents */
+ if (palette.isDirect) blit(BLIT_SRC,
+ this.data, this.depth, this.bytesPerLine, this.getByteOrder(), 0, 0, this.width, this.height, 0, 0, 0,
+ ALPHA_OPAQUE, null, 0, 0, 0,
+ dest.data, dest.depth, dest.bytesPerLine, dest.getByteOrder(), 0, 0, dest.width, dest.height, 0, 0, 0,
+ flipX, flipY);
+ else blit(BLIT_SRC,
+ this.data, this.depth, this.bytesPerLine, this.getByteOrder(), 0, 0, this.width, this.height, null, null, null,
+ ALPHA_OPAQUE, null, 0, 0, 0,
+ dest.data, dest.depth, dest.bytesPerLine, dest.getByteOrder(), 0, 0, dest.width, dest.height, null, null, null,
+ flipX, flipY);
+
+ /* Scale the image mask or alpha */
+ if (maskData != null) {
+ dest.maskPad = this.maskPad;
+ int destBpl = (dest.width + 7) / 8;
+ destBpl = (destBpl + (dest.maskPad - 1)) / dest.maskPad * dest.maskPad;
+ dest.maskData = new byte[destBpl * dest.height];
+ int srcBpl = (this.width + 7) / 8;
+ srcBpl = (srcBpl + (this.maskPad - 1)) / this.maskPad * this.maskPad;
+ blit(BLIT_SRC,
+ this.maskData, 1, srcBpl, MSB_FIRST, 0, 0, this.width, this.height, null, null, null,
+ ALPHA_OPAQUE, null, 0, 0, 0,
+ dest.maskData, 1, destBpl, MSB_FIRST, 0, 0, dest.width, dest.height, null, null, null,
+ flipX, flipY);
+ } else if (alpha != -1) {
+ dest.alpha = this.alpha;
+ } else if (alphaData != null) {
+ dest.alphaData = new byte[dest.width * dest.height];
+ blit(BLIT_SRC,
+ this.alphaData, 8, this.width, MSB_FIRST, 0, 0, this.width, this.height, null, null, null,
+ ALPHA_OPAQUE, null, 0, 0, 0,
+ dest.alphaData, 8, dest.width, MSB_FIRST, 0, 0, dest.width, dest.height, null, null, null,
+ flipX, flipY);
+ }
+ return dest;
+}
+
+/**
+ * Sets the alpha value at offset <code>x</code> in
+ * scanline <code>y</code> in the receiver's alpha data.
+ *
+ * @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 IndexOutOfBoundsException if putWidth is too large
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if pixels is null</li>
+ * <li>ERROR_INVALID_ARGUMENT - if x or y is out of bounds</li>
+ * <li>ERROR_INVALID_ARGUMENT - if putWidth is negative</li>
+ * </ul>
+ */
+public void setAlphas(int x, int y, int putWidth, byte[] alphas, int startIndex) {
+ if (alphas == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ if (putWidth < 0 || x >= width || y >= height || x < 0 || y < 0) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+ if (putWidth == 0) return;
+
+ if (alphaData == null) alphaData = new byte[width * height];
+ // may throw an IndexOutOfBoundsException
+ System.arraycopy(alphas, startIndex, alphaData, y * width + x, putWidth);
+}
+
+/**
+ * Sets the pixel value at offset <code>x</code> in
+ * scanline <code>y</code> in the receiver's data.
+ *
+ * @param x the x coordinate of the pixel to set
+ * @param y the y coordinate of the pixel to set
+ * @param pixelValue the value to set the pixel to
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_INVALID_ARGUMENT - if x or y is out of bounds</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_UNSUPPORTED_DEPTH if the depth is not one of 1, 2, 4, 8, 16, 24 or 32</li>
+ * </ul>
+ */
+public void setPixel(int x, int y, int pixelValue) {
+ if (x >= width || y >= height || x < 0 || y < 0) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+ int index;
+ byte theByte;
+ int mask;
+ 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 IndexOutOfBoundsException if putWidth is too large
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if pixels is null</li>
+ * <li>ERROR_INVALID_ARGUMENT - if x or y is out of bounds</li>
+ * <li>ERROR_INVALID_ARGUMENT - if putWidth is negative</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_UNSUPPORTED_DEPTH if the depth is not one of 1, 2, 4, 8
+ * (For higher depths, use the int[] version of this method.)</li>
+ * </ul>
+ */
+public void setPixels(int x, int y, int putWidth, byte[] pixels, int startIndex) {
+ if (pixels == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ if (putWidth < 0 || x >= width || y >= height || x < 0 || y < 0) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+ if (putWidth == 0) return;
+ int index;
+ int theByte;
+ int mask;
+ int n = putWidth;
+ int i = startIndex;
+ int srcX = x, srcY = y;
+ 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 IndexOutOfBoundsException if putWidth is too large
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if pixels is null</li>
+ * <li>ERROR_INVALID_ARGUMENT - if x or y is out of bounds</li>
+ * <li>ERROR_INVALID_ARGUMENT - if putWidth is negative</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_UNSUPPORTED_DEPTH if the depth is not one of 1, 2, 4, 8, 16, 24 or 32</li>
+ * </ul>
+ */
+public void setPixels(int x, int y, int putWidth, int[] pixels, int startIndex) {
+ if (pixels == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ if (putWidth < 0 || x >= width || y >= height || x < 0 || y < 0) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+ if (putWidth == 0) return;
+ int index;
+ int theByte;
+ int mask;
+ int n = putWidth;
+ int i = startIndex;
+ int pixel;
+ int srcX = x, srcY = y;
+ 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)});
+}
+
+/**
+ * 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;
+}
+
+/**
+ * Blit operation bits to be OR'ed together to specify the desired operation.
+ */
+static final int
+ BLIT_SRC = 1, // copy source directly, else applies logic operations
+ BLIT_ALPHA = 2, // enable alpha blending
+ BLIT_DITHER = 4; // enable dithering in low color modes
+
+/**
+ * Alpha mode, values 0 - 255 specify global alpha level
+ */
+static final int
+ ALPHA_OPAQUE = 255, // Fully opaque (ignores any alpha data)
+ ALPHA_TRANSPARENT = 0, // Fully transparent (ignores any alpha data)
+ ALPHA_CHANNEL_SEPARATE = -1, // Use alpha channel from separate alphaData
+ ALPHA_CHANNEL_SOURCE = -2, // Use alpha channel embedded in sourceData
+ ALPHA_MASK_UNPACKED = -3, // Use transparency mask formed by bytes in alphaData (non-zero is opaque)
+ ALPHA_MASK_PACKED = -4, // Use transparency mask formed by packed bits in alphaData
+ ALPHA_MASK_INDEX = -5, // Consider source palette indices transparent if in alphaData array
+ ALPHA_MASK_RGB = -6; // Consider source RGBs transparent if in RGB888 format alphaData array
+
+/**
+ * Byte and bit order constants.
+ */
+static final int LSB_FIRST = 0;
+static final int MSB_FIRST = 1;
+
+/**
+ * Data types (internal)
+ */
+private static final int
+ // direct / true color formats with arbitrary masks & shifts
+ TYPE_GENERIC_8 = 0,
+ TYPE_GENERIC_16_MSB = 1,
+ TYPE_GENERIC_16_LSB = 2,
+ TYPE_GENERIC_24 = 3,
+ TYPE_GENERIC_32_MSB = 4,
+ TYPE_GENERIC_32_LSB = 5,
+ // palette indexed color formats
+ TYPE_INDEX_8 = 6,
+ TYPE_INDEX_4 = 7,
+ TYPE_INDEX_2 = 8,
+ TYPE_INDEX_1_MSB = 9,
+ TYPE_INDEX_1_LSB = 10;
+
+/**
+ * Blits a direct palette image into a direct palette image.
+ * <p>
+ * Note: When the source and destination depth, order and masks
+ * are pairwise equal and the blitter operation is BLIT_SRC,
+ * the masks are ignored. Hence when not changing the image
+ * data format, 0 may be specified for the masks.
+ * </p>
+ *
+ * @param op the blitter operation: a combination of BLIT_xxx flags
+ * (see BLIT_xxx constants)
+ * @param srcData the source byte array containing image data
+ * @param srcDepth the source depth: one of 8, 16, 24, 32
+ * @param srcStride the source number of bytes per line
+ * @param srcOrder the source byte ordering: one of MSB_FIRST or LSB_FIRST;
+ * ignored if srcDepth is not 16 or 32
+ * @param srcX the top-left x-coord of the source blit region
+ * @param srcY the top-left y-coord of the source blit region
+ * @param srcWidth the width of the source blit region
+ * @param srcHeight the height of the source blit region
+ * @param srcRedMask the source red channel mask
+ * @param srcGreenMask the source green channel mask
+ * @param srcBlueMask the source blue channel mask
+ * @param alphaMode the alpha blending or mask mode, may be
+ * an integer 0-255 for global alpha; ignored if BLIT_ALPHA
+ * not specified in the blitter operations
+ * (see ALPHA_MODE_xxx constants)
+ * @param alphaData the alpha blending or mask data, varies depending
+ * on the value of alphaMode and sometimes ignored
+ * @param alphaStride the alpha data number of bytes per line
+ * @param alphaX the top-left x-coord of the alpha blit region
+ * @param alphaY the top-left y-coord of the alpha blit region
+ * @param destData the destination byte array containing image data
+ * @param destDepth the destination depth: one of 8, 16, 24, 32
+ * @param destStride the destination number of bytes per line
+ * @param destOrder the destination byte ordering: one of MSB_FIRST or LSB_FIRST;
+ * ignored if destDepth is not 16 or 32
+ * @param destX the top-left x-coord of the destination blit region
+ * @param destY the top-left y-coord of the destination blit region
+ * @param destWidth the width of the destination blit region
+ * @param destHeight the height of the destination blit region
+ * @param destRedMask the destination red channel mask
+ * @param destGreenMask the destination green channel mask
+ * @param destBlueMask the destination blue channel mask
+ * @param flipX if true the resulting image is flipped along the vertical axis
+ * @param flipY if true the resulting image is flipped along the horizontal axis
+ */
+static void blit(int op,
+ byte[] srcData, int srcDepth, int srcStride, int srcOrder,
+ int srcX, int srcY, int srcWidth, int srcHeight,
+ int srcRedMask, int srcGreenMask, int srcBlueMask,
+ int alphaMode, byte[] alphaData, int alphaStride, int alphaX, int alphaY,
+ byte[] destData, int destDepth, int destStride, int destOrder,
+ int destX, int destY, int destWidth, int destHeight,
+ int destRedMask, int destGreenMask, int destBlueMask,
+ boolean flipX, boolean flipY) {
+ if ((destWidth <= 0) || (destHeight <= 0) || (alphaMode == ALPHA_TRANSPARENT)) return;
+
+ // these should be supplied as params later
+ final int srcAlphaMask = 0, destAlphaMask = 0;
+
+ /*** Prepare scaling data ***/
+ final int dwm1 = destWidth - 1;
+ final int sfxi = (dwm1 != 0) ? (int)((((long)srcWidth << 16) - 1) / dwm1) : 0;
+ final int dhm1 = destHeight - 1;
+ final int sfyi = (dhm1 != 0) ? (int)((((long)srcHeight << 16) - 1) / dhm1) : 0;
+
+ /*** Prepare source-related data ***/
+ final int sbpp, stype;
+ switch (srcDepth) {
+ case 8:
+ sbpp = 1;
+ stype = TYPE_GENERIC_8;
+ break;
+ case 16:
+ sbpp = 2;
+ stype = (srcOrder == MSB_FIRST) ? TYPE_GENERIC_16_MSB : TYPE_GENERIC_16_LSB;
+ break;
+ case 24:
+ sbpp = 3;
+ stype = TYPE_GENERIC_24;
+ break;
+ case 32:
+ sbpp = 4;
+ stype = (srcOrder == MSB_FIRST) ? TYPE_GENERIC_32_MSB : TYPE_GENERIC_32_LSB;
+ break;
+ default:
+ //throw new IllegalArgumentException("Invalid source type");
+ return;
+ }
+ int spr = srcY * srcStride + srcX * sbpp;
+
+ /*** Prepare destination-related data ***/
+ final int dbpp, dtype;
+ switch (destDepth) {
+ case 8:
+ dbpp = 1;
+ dtype = TYPE_GENERIC_8;
+ break;
+ case 16:
+ dbpp = 2;
+ dtype = (destOrder == MSB_FIRST) ? TYPE_GENERIC_16_MSB : TYPE_GENERIC_16_LSB;
+ break;
+ case 24:
+ dbpp = 3;
+ dtype = TYPE_GENERIC_24;
+ break;
+ case 32:
+ dbpp = 4;
+ dtype = (destOrder == MSB_FIRST) ? TYPE_GENERIC_32_MSB : TYPE_GENERIC_32_LSB;
+ break;
+ default:
+ //throw new IllegalArgumentException("Invalid destination type");
+ return;
+ }
+ int dpr = ((flipY) ? destY + dhm1 : destY) * destStride + ((flipX) ? destX + dwm1 : destX) * dbpp;
+ final int dprxi = (flipX) ? -dbpp : dbpp;
+ final int dpryi = (flipY) ? -destStride : destStride;
+
+ /*** Prepare special processing data ***/
+ int apr;
+ if ((op & BLIT_ALPHA) != 0) {
+ switch (alphaMode) {
+ case ALPHA_MASK_UNPACKED:
+ case ALPHA_CHANNEL_SEPARATE:
+ if (alphaData == null) alphaMode = 0x10000;
+ apr = alphaY * alphaStride + alphaX;
+ break;
+ case ALPHA_MASK_PACKED:
+ if (alphaData == null) alphaMode = 0x10000;
+ alphaStride <<= 3;
+ apr = alphaY * alphaStride + alphaX;
+ break;
+ case ALPHA_MASK_INDEX:
+ //throw new IllegalArgumentException("Invalid alpha type");
+ return;
+ case ALPHA_MASK_RGB:
+ if (alphaData == null) alphaMode = 0x10000;
+ apr = 0;
+ break;
+ default:
+ alphaMode = (alphaMode << 16) / 255; // prescale
+ case ALPHA_CHANNEL_SOURCE:
+ apr = 0;
+ break;
+ }
+ } else {
+ alphaMode = 0x10000;
+ apr = 0;
+ }
+
+ /*** Blit ***/
+ int dp = dpr;
+ int sp = spr;
+ if ((alphaMode == 0x10000) && (stype == dtype) &&
+ (srcRedMask == destRedMask) && (srcGreenMask == destGreenMask) &&
+ (srcBlueMask == destBlueMask) && (srcAlphaMask == destAlphaMask)) {
+ /*** Fast blit (straight copy) ***/
+ switch (sbpp) {
+ case 1:
+ for (int dy = destHeight, sfy = sfyi; dy > 0; --dy, sp = spr += (sfy >>> 16) * srcStride, sfy = (sfy & 0xffff) + sfyi, dp = dpr += dpryi) {
+ for (int dx = destWidth, sfx = sfxi; dx > 0; --dx, dp += dprxi, sfx = (sfx & 0xffff) + sfxi) {
+ destData[dp] = srcData[sp];
+ sp += (sfx >>> 16);
+ }
+ }
+ break;
+ case 2:
+ for (int dy = destHeight, sfy = sfyi; dy > 0; --dy, sp = spr += (sfy >>> 16) * srcStride, sfy = (sfy & 0xffff) + sfyi, dp = dpr += dpryi) {
+ for (int dx = destWidth, sfx = sfxi; dx > 0; --dx, dp += dprxi, sfx = (sfx & 0xffff) + sfxi) {
+ destData[dp] = srcData[sp];
+ destData[dp + 1] = srcData[sp + 1];
+ sp += (sfx >>> 16) * 2;
+ }
+ }
+ break;
+ case 3:
+ for (int dy = destHeight, sfy = sfyi; dy > 0; --dy, sp = spr += (sfy >>> 16) * srcStride, sfy = (sfy & 0xffff) + sfyi, dp = dpr += dpryi) {
+ for (int dx = destWidth, sfx = sfxi; dx > 0; --dx, dp += dprxi, sfx = (sfx & 0xffff) + sfxi) {
+ destData[dp] = srcData[sp];
+ destData[dp + 1] = srcData[sp + 1];
+ destData[dp + 2] = srcData[sp + 2];
+ sp += (sfx >>> 16) * 3;
+ }
+ }
+ break;
+ case 4:
+ for (int dy = destHeight, sfy = sfyi; dy > 0; --dy, sp = spr += (sfy >>> 16) * srcStride, sfy = (sfy & 0xffff) + sfyi, dp = dpr += dpryi) {
+ for (int dx = destWidth, sfx = sfxi; dx > 0; --dx, dp += dprxi, sfx = (sfx & 0xffff) + sfxi) {
+ destData[dp] = srcData[sp];
+ destData[dp + 1] = srcData[sp + 1];
+ destData[dp + 2] = srcData[sp + 2];
+ destData[dp + 3] = srcData[sp + 3];
+ sp += (sfx >>> 16) * 4;
+ }
+ }
+ break;
+ }
+ return;
+ }
+ /*** Comprehensive blit (apply transformations) ***/
+ final int srcRedShift = getChannelShift(srcRedMask);
+ final byte[] srcReds = ANY_TO_EIGHT[getChannelWidth(srcRedMask, srcRedShift)];
+ final int srcGreenShift = getChannelShift(srcGreenMask);
+ final byte[] srcGreens = ANY_TO_EIGHT[getChannelWidth(srcGreenMask, srcGreenShift)];
+ final int srcBlueShift = getChannelShift(srcBlueMask);
+ final byte[] srcBlues = ANY_TO_EIGHT[getChannelWidth(srcBlueMask, srcBlueShift)];
+ final int srcAlphaShift = getChannelShift(srcAlphaMask);
+ final byte[] srcAlphas = ANY_TO_EIGHT[getChannelWidth(srcAlphaMask, srcAlphaShift)];
+
+ final int destRedShift = getChannelShift(destRedMask);
+ final int destRedWidth = getChannelWidth(destRedMask, destRedShift);
+ final byte[] destReds = ANY_TO_EIGHT[destRedWidth];
+ final int destRedPreShift = 8 - destRedWidth;
+ final int destGreenShift = getChannelShift(destGreenMask);
+ final int destGreenWidth = getChannelWidth(destGreenMask, destGreenShift);
+ final byte[] destGreens = ANY_TO_EIGHT[destGreenWidth];
+ final int destGreenPreShift = 8 - destGreenWidth;
+ final int destBlueShift = getChannelShift(destBlueMask);
+ final int destBlueWidth = getChannelWidth(destBlueMask, destBlueShift);
+ final byte[] destBlues = ANY_TO_EIGHT[destBlueWidth];
+ final int destBluePreShift = 8 - destBlueWidth;
+ final int destAlphaShift = getChannelShift(destAlphaMask);
+ final int destAlphaWidth = getChannelWidth(destAlphaMask, destAlphaShift);
+ final byte[] destAlphas = ANY_TO_EIGHT[destAlphaWidth];
+ final int destAlphaPreShift = 8 - destAlphaWidth;
+
+ int ap = apr, alpha = alphaMode;
+ int r = 0, g = 0, b = 0, a = 0;
+ int rq = 0, gq = 0, bq = 0, aq = 0;
+ for (int dy = destHeight, sfy = sfyi; dy > 0; --dy,
+ sp = spr += (sfy >>> 16) * srcStride,
+ ap = apr += (sfy >>> 16) * alphaStride,
+ sfy = (sfy & 0xffff) + sfyi,
+ dp = dpr += dpryi) {
+ for (int dx = destWidth, sfx = sfxi; dx > 0; --dx,
+ dp += dprxi,
+ sfx = (sfx & 0xffff) + sfxi) {
+ /*** READ NEXT PIXEL ***/
+ switch (stype) {
+ case TYPE_GENERIC_8: {
+ final int data = srcData[sp] & 0xff;
+ sp += (sfx >>> 16);
+ r = srcReds[(data & srcRedMask) >>> srcRedShift] & 0xff;
+ g = srcGreens[(data & srcGreenMask) >>> srcGreenShift] & 0xff;
+ b = srcBlues[(data & srcBlueMask) >>> srcBlueShift] & 0xff;
+ a = srcAlphas[(data & srcAlphaMask) >>> srcAlphaShift] & 0xff;
+ } break;
+ case TYPE_GENERIC_16_MSB: {
+ final int data = ((srcData[sp] & 0xff) << 8) | (srcData[sp + 1] & 0xff);
+ sp += (sfx >>> 16) * 2;
+ r = srcReds[(data & srcRedMask) >>> srcRedShift] & 0xff;
+ g = srcGreens[(data & srcGreenMask) >>> srcGreenShift] & 0xff;
+ b = srcBlues[(data & srcBlueMask) >>> srcBlueShift] & 0xff;
+ a = srcAlphas[(data & srcAlphaMask) >>> srcAlphaShift] & 0xff;
+ } break;
+ case TYPE_GENERIC_16_LSB: {
+ final int data = ((srcData[sp + 1] & 0xff) << 8) | (srcData[sp] & 0xff);
+ sp += (sfx >>> 16) * 2;
+ r = srcReds[(data & srcRedMask) >>> srcRedShift] & 0xff;
+ g = srcGreens[(data & srcGreenMask) >>> srcGreenShift] & 0xff;
+ b = srcBlues[(data & srcBlueMask) >>> srcBlueShift] & 0xff;
+ a = srcAlphas[(data & srcAlphaMask) >>> srcAlphaShift] & 0xff;
+ } break;
+ case TYPE_GENERIC_24: {
+ final int data = (( ((srcData[sp] & 0xff) << 8) |
+ (srcData[sp + 1] & 0xff)) << 8) |
+ (srcData[sp + 2] & 0xff);
+ sp += (sfx >>> 16) * 3;
+ r = srcReds[(data & srcRedMask) >>> srcRedShift] & 0xff;
+ g = srcGreens[(data & srcGreenMask) >>> srcGreenShift] & 0xff;
+ b = srcBlues[(data & srcBlueMask) >>> srcBlueShift] & 0xff;
+ a = srcAlphas[(data & srcAlphaMask) >>> srcAlphaShift] & 0xff;
+ } break;
+ case TYPE_GENERIC_32_MSB: {
+ final int data = (( (( ((srcData[sp] & 0xff) << 8) |
+ (srcData[sp + 1] & 0xff)) << 8) |
+ (srcData[sp + 2] & 0xff)) << 8) |
+ (srcData[sp + 3] & 0xff);
+ sp += (sfx >>> 16) * 4;
+ r = srcReds[(data & srcRedMask) >>> srcRedShift] & 0xff;
+ g = srcGreens[(data & srcGreenMask) >>> srcGreenShift] & 0xff;
+ b = srcBlues[(data & srcBlueMask) >>> srcBlueShift] & 0xff;
+ a = srcAlphas[(data & srcAlphaMask) >>> srcAlphaShift] & 0xff;
+ } break;
+ case TYPE_GENERIC_32_LSB: {
+ final int data = (( (( ((srcData[sp + 3] & 0xff) << 8) |
+ (srcData[sp + 2] & 0xff)) << 8) |
+ (srcData[sp + 1] & 0xff)) << 8) |
+ (srcData[sp] & 0xff);
+ sp += (sfx >>> 16) * 4;
+ r = srcReds[(data & srcRedMask) >>> srcRedShift] & 0xff;
+ g = srcGreens[(data & srcGreenMask) >>> srcGreenShift] & 0xff;
+ b = srcBlues[(data & srcBlueMask) >>> srcBlueShift] & 0xff;
+ a = srcAlphas[(data & srcAlphaMask) >>> srcAlphaShift] & 0xff;
+ } break;
+ }
+
+ /*** DO SPECIAL PROCESSING IF REQUIRED ***/
+ switch (alphaMode) {
+ case ALPHA_CHANNEL_SEPARATE:
+ alpha = ((alphaData[ap] & 0xff) << 16) / 255;
+ ap += (sfx >> 16);
+ break;
+ case ALPHA_CHANNEL_SOURCE:
+ alpha = (a << 16) / 255;
+ break;
+ case ALPHA_MASK_UNPACKED:
+ alpha = (alphaData[ap] != 0) ? 0x10000 : 0;
+ ap += (sfx >> 16);
+ break;
+ case ALPHA_MASK_PACKED:
+ alpha = (alphaData[ap >> 3] << ((ap & 7) + 9)) & 0x10000;
+ ap += (sfx >> 16);
+ break;
+ case ALPHA_MASK_RGB:
+ alpha = 0x10000;
+ for (int i = 0; i < alphaData.length; i += 3) {
+ if ((r == alphaData[i]) && (g == alphaData[i + 1]) && (b == alphaData[i + 2])) {
+ alpha = 0x0000;
+ break;
+ }
+ }
+ break;
+ }
+ if (alpha != 0x10000) {
+ if (alpha == 0x0000) continue;
+ switch (dtype) {
+ case TYPE_GENERIC_8: {
+ final int data = destData[dp] & 0xff;
+ rq = destReds[(data & destRedMask) >>> destRedShift] & 0xff;
+ gq = destGreens[(data & destGreenMask) >>> destGreenShift] & 0xff;
+ bq = destBlues[(data & destBlueMask) >>> destBlueShift] & 0xff;
+ aq = destAlphas[(data & destAlphaMask) >>> destAlphaShift] & 0xff;
+ } break;
+ case TYPE_GENERIC_16_MSB: {
+ final int data = ((destData[dp] & 0xff) << 8) | (destData[dp + 1] & 0xff);
+ rq = destReds[(data & destRedMask) >>> destRedShift] & 0xff;
+ gq = destGreens[(data & destGreenMask) >>> destGreenShift] & 0xff;
+ bq = destBlues[(data & destBlueMask) >>> destBlueShift] & 0xff;
+ aq = destAlphas[(data & destAlphaMask) >>> destAlphaShift] & 0xff;
+ } break;
+ case TYPE_GENERIC_16_LSB: {
+ final int data = ((destData[dp + 1] & 0xff) << 8) | (destData[dp] & 0xff);
+ rq = destReds[(data & destRedMask) >>> destRedShift] & 0xff;
+ gq = destGreens[(data & destGreenMask) >>> destGreenShift] & 0xff;
+ bq = destBlues[(data & destBlueMask) >>> destBlueShift] & 0xff;
+ aq = destAlphas[(data & destAlphaMask) >>> destAlphaShift] & 0xff;
+ } break;
+ case TYPE_GENERIC_24: {
+ final int data = (( ((destData[dp] & 0xff) << 8) |
+ (destData[dp + 1] & 0xff)) << 8) |
+ (destData[dp + 2] & 0xff);
+ rq = destReds[(data & destRedMask) >>> destRedShift] & 0xff;
+ gq = destGreens[(data & destGreenMask) >>> destGreenShift] & 0xff;
+ bq = destBlues[(data & destBlueMask) >>> destBlueShift] & 0xff;
+ aq = destAlphas[(data & destAlphaMask) >>> destAlphaShift] & 0xff;
+ } break;
+ case TYPE_GENERIC_32_MSB: {
+ final int data = (( (( ((destData[dp] & 0xff) << 8) |
+ (destData[dp + 1] & 0xff)) << 8) |
+ (destData[dp + 2] & 0xff)) << 8) |
+ (destData[dp + 3] & 0xff);
+ rq = destReds[(data & destRedMask) >>> destRedShift] & 0xff;
+ gq = destGreens[(data & destGreenMask) >>> destGreenShift] & 0xff;
+ bq = destBlues[(data & destBlueMask) >>> destBlueShift] & 0xff;
+ aq = destAlphas[(data & destAlphaMask) >>> destAlphaShift] & 0xff;
+ } break;
+ case TYPE_GENERIC_32_LSB: {
+ final int data = (( (( ((destData[dp + 3] & 0xff) << 8) |
+ (destData[dp + 2] & 0xff)) << 8) |
+ (destData[dp + 1] & 0xff)) << 8) |
+ (destData[dp] & 0xff);
+ rq = destReds[(data & destRedMask) >>> destRedShift] & 0xff;
+ gq = destGreens[(data & destGreenMask) >>> destGreenShift] & 0xff;
+ bq = destBlues[(data & destBlueMask) >>> destBlueShift] & 0xff;
+ aq = destAlphas[(data & destAlphaMask) >>> destAlphaShift] & 0xff;
+ } break;
+ }
+ // Perform alpha blending
+ a = aq + ((a - aq) * alpha >> 16);
+ r = rq + ((r - rq) * alpha >> 16);
+ g = gq + ((g - gq) * alpha >> 16);
+ b = bq + ((b - bq) * alpha >> 16);
+ }
+
+ /*** WRITE NEXT PIXEL ***/
+ final int data =
+ (r >>> destRedPreShift << destRedShift) |
+ (g >>> destGreenPreShift << destGreenShift) |
+ (b >>> destBluePreShift << destBlueShift) |
+ (a >>> destAlphaPreShift << destAlphaShift);
+ switch (dtype) {
+ case TYPE_GENERIC_8: {
+ destData[dp] = (byte) data;
+ } break;
+ case TYPE_GENERIC_16_MSB: {
+ destData[dp] = (byte) (data >>> 8);
+ destData[dp + 1] = (byte) (data & 0xff);
+ } break;
+ case TYPE_GENERIC_16_LSB: {
+ destData[dp] = (byte) (data & 0xff);
+ destData[dp + 1] = (byte) (data >>> 8);
+ } break;
+ case TYPE_GENERIC_24: {
+ destData[dp] = (byte) (data >>> 16);
+ destData[dp + 1] = (byte) (data >>> 8);
+ destData[dp + 2] = (byte) (data & 0xff);
+ } break;
+ case TYPE_GENERIC_32_MSB: {
+ destData[dp] = (byte) (data >>> 24);
+ destData[dp + 1] = (byte) (data >>> 16);
+ destData[dp + 2] = (byte) (data >>> 8);
+ destData[dp + 3] = (byte) (data & 0xff);
+ } break;
+ case TYPE_GENERIC_32_LSB: {
+ destData[dp] = (byte) (data & 0xff);
+ destData[dp + 1] = (byte) (data >>> 8);
+ destData[dp + 2] = (byte) (data >>> 16);
+ destData[dp + 3] = (byte) (data >>> 24);
+ } break;
+ }
+ }
+ }
+}
+
+/**
+ * Blits an index palette image into an index palette image.
+ * <p>
+ * Note: The source and destination red, green, and blue
+ * arrays may be null if no alpha blending or dither is to be
+ * performed.
+ * </p>
+ *
+ * @param op the blitter operation: a combination of BLIT_xxx flags
+ * (see BLIT_xxx constants)
+ * @param srcData the source byte array containing image data
+ * @param srcDepth the source depth: one of 1, 2, 4, 8
+ * @param srcStride the source number of bytes per line
+ * @param srcOrder the source byte ordering: one of MSB_FIRST or LSB_FIRST;
+ * ignored if srcDepth is not 1
+ * @param srcX the top-left x-coord of the source blit region
+ * @param srcY the top-left y-coord of the source blit region
+ * @param srcWidth the width of the source blit region
+ * @param srcHeight the height of the source blit region
+ * @param srcReds the source palette red component intensities
+ * @param srcGreens the source palette green component intensities
+ * @param srcBlues the source palette blue component intensities
+ * @param alphaMode the alpha blending or mask mode, may be
+ * an integer 0-255 for global alpha; ignored if BLIT_ALPHA
+ * not specified in the blitter operations
+ * (see ALPHA_MODE_xxx constants)
+ * @param alphaData the alpha blending or mask data, varies depending
+ * on the value of alphaMode and sometimes ignored
+ * @param alphaStride the alpha data number of bytes per line
+ * @param alphaX the top-left x-coord of the alpha blit region
+ * @param alphaY the top-left y-coord of the alpha blit region
+ * @param destData the destination byte array containing image data
+ * @param destDepth the destination depth: one of 1, 2, 4, 8
+ * @param destStride the destination number of bytes per line
+ * @param destOrder the destination byte ordering: one of MSB_FIRST or LSB_FIRST;
+ * ignored if destDepth is not 1
+ * @param destX the top-left x-coord of the destination blit region
+ * @param destY the top-left y-coord of the destination blit region
+ * @param destWidth the width of the destination blit region
+ * @param destHeight the height of the destination blit region
+ * @param destReds the destination palette red component intensities
+ * @param destGreens the destination palette green component intensities
+ * @param destBlues the destination palette blue component intensities
+ * @param flipX if true the resulting image is flipped along the vertical axis
+ * @param flipY if true the resulting image is flipped along the horizontal axis
+ */
+static void blit(int op,
+ byte[] srcData, int srcDepth, int srcStride, int srcOrder,
+ int srcX, int srcY, int srcWidth, int srcHeight,
+ byte[] srcReds, byte[] srcGreens, byte[] srcBlues,
+ int alphaMode, byte[] alphaData, int alphaStride, int alphaX, int alphaY,
+ byte[] destData, int destDepth, int destStride, int destOrder,
+ int destX, int destY, int destWidth, int destHeight,
+ byte[] destReds, byte[] destGreens, byte[] destBlues,
+ boolean flipX, boolean flipY) {
+ if ((destWidth <= 0) || (destHeight <= 0) || (alphaMode == ALPHA_TRANSPARENT)) return;
+
+ /*** Prepare scaling data ***/
+ final int dwm1 = destWidth - 1;
+ final int sfxi = (dwm1 != 0) ? (int)((((long)srcWidth << 16) - 1) / dwm1) : 0;
+ final int dhm1 = destHeight - 1;
+ final int sfyi = (dhm1 != 0) ? (int)((((long)srcHeight << 16) - 1) / dhm1) : 0;
+
+ /*** Prepare source-related data ***/
+ final int stype;
+ switch (srcDepth) {
+ case 8:
+ stype = TYPE_INDEX_8;
+ break;
+ case 4:
+ srcStride <<= 1;
+ stype = TYPE_INDEX_4;
+ break;
+ case 2:
+ srcStride <<= 2;
+ stype = TYPE_INDEX_2;
+ break;
+ case 1:
+ srcStride <<= 3;
+ stype = (srcOrder == MSB_FIRST) ? TYPE_INDEX_1_MSB : TYPE_INDEX_1_LSB;
+ break;
+ default:
+ //throw new IllegalArgumentException("Invalid source type");
+ return;
+ }
+ int spr = srcY * srcStride + srcX;
+
+ /*** Prepare destination-related data ***/
+ final int dtype;
+ switch (destDepth) {
+ case 8:
+ dtype = TYPE_INDEX_8;
+ break;
+ case 4:
+ destStride <<= 1;
+ dtype = TYPE_INDEX_4;
+ break;
+ case 2:
+ destStride <<= 2;
+ dtype = TYPE_INDEX_2;
+ break;
+ case 1:
+ destStride <<= 3;
+ dtype = (destOrder == MSB_FIRST) ? TYPE_INDEX_1_MSB : TYPE_INDEX_1_LSB;
+ break;
+ default:
+ //throw new IllegalArgumentException("Invalid source type");
+ return;
+ }
+ int dpr = ((flipY) ? destY + dhm1 : destY) * destStride + ((flipX) ? destX + dwm1 : destX);
+ final int dprxi = (flipX) ? -1 : 1;
+ final int dpryi = (flipY) ? -destStride : destStride;
+
+ /*** Prepare special processing data ***/
+ int apr;
+ if ((op & BLIT_ALPHA) != 0) {
+ switch (alphaMode) {
+ case ALPHA_MASK_UNPACKED:
+ case ALPHA_CHANNEL_SEPARATE:
+ if (alphaData == null) alphaMode = 0x10000;
+ apr = alphaY * alphaStride + alphaX;
+ break;
+ case ALPHA_MASK_PACKED:
+ if (alphaData == null) alphaMode = 0x10000;
+ alphaStride <<= 3;
+ apr = alphaY * alphaStride + alphaX;
+ break;
+ case ALPHA_MASK_INDEX:
+ case ALPHA_MASK_RGB:
+ if (alphaData == null) alphaMode = 0x10000;
+ apr = 0;
+ break;
+ default:
+ alphaMode = (alphaMode << 16) / 255; // prescale
+ case ALPHA_CHANNEL_SOURCE:
+ apr = 0;
+ break;
+ }
+ } else {
+ alphaMode = 0x10000;
+ apr = 0;
+ }
+ final boolean ditherEnabled = (op & BLIT_DITHER) != 0;
+
+ /*** Blit ***/
+ int dp = dpr;
+ int sp = spr;
+ int ap = apr;
+ int destPaletteSize = 1 << destDepth;
+ if ((destReds != null) && (destReds.length < destPaletteSize)) destPaletteSize = destReds.length;
+ byte[] paletteMapping = null;
+ boolean isExactPaletteMapping = true;
+ switch (alphaMode) {
+ case 0x10000:
+ /*** If the palettes and formats are equivalent use a one-to-one mapping ***/
+ if ((stype == dtype) &&
+ (srcReds == destReds) && (srcGreens == destGreens) && (srcBlues == destBlues)) {
+ paletteMapping = ONE_TO_ONE_MAPPING;
+ break;
+ /*** If palettes have not been supplied, supply a suitable mapping ***/
+ } else if ((srcReds == null) || (destReds == null)) {
+ if (srcDepth <= destDepth) {
+ paletteMapping = ONE_TO_ONE_MAPPING;
+ } else {
+ paletteMapping = new byte[1 << srcDepth];
+ int mask = (0xff << destDepth) >>> 8;
+ for (int i = 0; i < paletteMapping.length; ++i) paletteMapping[i] = (byte)(i & mask);
+ }
+ break;
+ }
+ case ALPHA_MASK_UNPACKED:
+ case ALPHA_MASK_PACKED:
+ case ALPHA_MASK_INDEX:
+ case ALPHA_MASK_RGB:
+ /*** Generate a palette mapping ***/
+ int srcPaletteSize = 1 << srcDepth;
+ paletteMapping = new byte[srcPaletteSize];
+ if ((srcReds != null) && (srcReds.length < srcPaletteSize)) srcPaletteSize = srcReds.length;
+ for (int i = 0, r, g, b, index; i < srcPaletteSize; ++i) {
+ r = srcReds[i] & 0xff;
+ g = srcGreens[i] & 0xff;
+ b = srcBlues[i] & 0xff;
+ index = 0;
+ int minDistance = 0x7fffffff;
+ for (int j = 0, dr, dg, db, distance; j < destPaletteSize; ++j) {
+ dr = (destReds[j] & 0xff) - r;
+ dg = (destGreens[j] & 0xff) - g;
+ db = (destBlues[j] & 0xff) - b;
+ distance = dr * dr + dg * dg + db * db;
+ if (distance < minDistance) {
+ index = j;
+ if (distance == 0) break;
+ minDistance = distance;
+ }
+ }
+ paletteMapping[i] = (byte)index;
+ if (minDistance != 0) isExactPaletteMapping = false;
+ }
+ break;
+ }
+ if ((paletteMapping != null) && (isExactPaletteMapping || ! ditherEnabled)) {
+ if ((stype == dtype) && (alphaMode == 0x10000)) {
+ /*** Fast blit (copy w/ mapping) ***/
+ switch (stype) {
+ case TYPE_INDEX_8:
+ for (int dy = destHeight, sfy = sfyi; dy > 0; --dy, sp = spr += (sfy >>> 16) * srcStride, sfy = (sfy & 0xffff) + sfyi, dp = dpr += dpryi) {
+ for (int dx = destWidth, sfx = sfxi; dx > 0; --dx, dp += dprxi, sfx = (sfx & 0xffff) + sfxi) {
+ destData[dp] = paletteMapping[srcData[sp] & 0xff];
+ sp += (sfx >>> 16);
+ }
+ }
+ break;
+ case TYPE_INDEX_4:
+ for (int dy = destHeight, sfy = sfyi; dy > 0; --dy, sp = spr += (sfy >>> 16) * srcStride, sfy = (sfy & 0xffff) + sfyi, dp = dpr += dpryi) {
+ for (int dx = destWidth, sfx = sfxi; dx > 0; --dx, dp += dprxi, sfx = (sfx & 0xffff) + sfxi) {
+ final int v;
+ if ((sp & 1) != 0) v = paletteMapping[srcData[sp >> 1] & 0x0f];
+ else v = (srcData[sp >> 1] >>> 4) & 0x0f;
+ sp += (sfx >>> 16);
+ if ((dp & 1) != 0) destData[dp >> 1] = (byte)((destData[dp >> 1] & 0xf0) | v);
+ else destData[dp >> 1] = (byte)((destData[dp >> 1] & 0x0f) | (v << 4));
+ }
+ }
+ break;
+ case TYPE_INDEX_2:
+ for (int dy = destHeight, sfy = sfyi; dy > 0; --dy, sp = spr += (sfy >>> 16) * srcStride, sfy = (sfy & 0xffff) + sfyi, dp = dpr += dpryi) {
+ for (int dx = destWidth, sfx = sfxi; dx > 0; --dx, dp += dprxi, sfx = (sfx & 0xffff) + sfxi) {
+ final int index = paletteMapping[(srcData[sp >> 2] >>> (6 - (sp & 3) * 2)) & 0x03];
+ sp += (sfx >>> 16);
+ final int shift = 6 - (dp & 3) * 2;
+ destData[dp >> 2] = (byte)(destData[dp >> 2] & ~(0x03 << shift) | (index << shift));
+ }
+ }
+ break;
+ case TYPE_INDEX_1_MSB:
+ for (int dy = destHeight, sfy = sfyi; dy > 0; --dy, sp = spr += (sfy >>> 16) * srcStride, sfy = (sfy & 0xffff) + sfyi, dp = dpr += dpryi) {
+ for (int dx = destWidth, sfx = sfxi; dx > 0; --dx, dp += dprxi, sfx = (sfx & 0xffff) + sfxi) {
+ final int index = paletteMapping[(srcData[sp >> 3] >>> (7 - (sp & 7))) & 0x01];
+ sp += (sfx >>> 16);
+ final int shift = 7 - (dp & 7);
+ destData[dp >> 3] = (byte)(destData[dp >> 3] & ~(0x01 << shift) | (index << shift));
+ }
+ }
+ break;
+ case TYPE_INDEX_1_LSB:
+ for (int dy = destHeight, sfy = sfyi; dy > 0; --dy, sp = spr += (sfy >>> 16) * srcStride, sfy = (sfy & 0xffff) + sfyi, dp = dpr += dpryi) {
+ for (int dx = destWidth, sfx = sfxi; dx > 0; --dx, dp += dprxi, sfx = (sfx & 0xffff) + sfxi) {
+ final int index = paletteMapping[(srcData[sp >> 3] >>> (sp & 7)) & 0x01];
+ sp += (sfx >>> 16);
+ final int shift = dp & 7;
+ destData[dp >> 3] = (byte)(destData[dp >> 3] & ~(0x01 << shift) | (index << shift));
+ }
+ }
+ break;
+ }
+ } else {
+ /*** Convert between indexed modes using mapping and mask ***/
+ for (int dy = destHeight, sfy = sfyi; dy > 0; --dy,
+ sp = spr += (sfy >>> 16) * srcStride,
+ sfy = (sfy & 0xffff) + sfyi,
+ dp = dpr += dpryi) {
+ for (int dx = destWidth, sfx = sfxi; dx > 0; --dx,
+ dp += dprxi,
+ sfx = (sfx & 0xffff) + sfxi) {
+ int index;
+ /*** READ NEXT PIXEL ***/
+ switch (stype) {
+ case TYPE_INDEX_8:
+ index = srcData[sp] & 0xff;
+ sp += (sfx >>> 16);
+ break;
+ case TYPE_INDEX_4:
+ if ((sp & 1) != 0) index = srcData[sp >> 1] & 0x0f;
+ else index = (srcData[sp >> 1] >>> 4) & 0x0f;
+ sp += (sfx >>> 16);
+ break;
+ case TYPE_INDEX_2:
+ index = (srcData[sp >> 2] >>> (6 - (sp & 3) * 2)) & 0x03;
+ sp += (sfx >>> 16);
+ break;
+ case TYPE_INDEX_1_MSB:
+ index = (srcData[sp >> 3] >>> (7 - (sp & 7))) & 0x01;
+ sp += (sfx >>> 16);
+ break;
+ case TYPE_INDEX_1_LSB:
+ index = (srcData[sp >> 3] >>> (sp & 7)) & 0x01;
+ sp += (sfx >>> 16);
+ break;
+ default:
+ return;
+ }
+ /*** APPLY MASK ***/
+ switch (alphaMode) {
+ case ALPHA_MASK_UNPACKED: {
+ final byte mask = alphaData[ap];
+ ap += (sfx >> 16);
+ if (mask == 0) continue;
+ } break;
+ case ALPHA_MASK_PACKED: {
+ final int mask = alphaData[ap >> 3] & (1 << (ap & 7));
+ ap += (sfx >> 16);
+ if (mask == 0) continue;
+ } break;
+ case ALPHA_MASK_INDEX: {
+ int i = 0;
+ while (i < alphaData.length) {
+ if (index == (alphaData[i] & 0xff)) break;
+ }
+ if (i < alphaData.length) continue;
+ } break;
+ case ALPHA_MASK_RGB: {
+ final byte r = srcReds[index], g = srcGreens[index], b = srcBlues[index];
+ int i = 0;
+ while (i < alphaData.length) {
+ if ((r == alphaData[i]) && (g == alphaData[i + 1]) && (b == alphaData[i + 2])) break;
+ i += 3;
+ }
+ if (i < alphaData.length) continue;
+ } break;
+ }
+ index = paletteMapping[index] & 0xff;
+
+ /*** WRITE NEXT PIXEL ***/
+ switch (dtype) {
+ case TYPE_INDEX_8:
+ destData[dp] = (byte) index;
+ break;
+ case TYPE_INDEX_4:
+ if ((dp & 1) != 0) destData[dp >> 1] = (byte)((destData[dp >> 1] & 0xf0) | index);
+ else destData[dp >> 1] = (byte)((destData[dp >> 1] & 0x0f) | (index << 4));
+ break;
+ case TYPE_INDEX_2: {
+ final int shift = 6 - (dp & 3) * 2;
+ destData[dp >> 2] = (byte)(destData[dp >> 2] & ~(0x03 << shift) | (index << shift));
+ } break;
+ case TYPE_INDEX_1_MSB: {
+ final int shift = 7 - (dp & 7);
+ destData[dp >> 3] = (byte)(destData[dp >> 3] & ~(0x01 << shift) | (index << shift));
+ } break;
+ case TYPE_INDEX_1_LSB: {
+ final int shift = dp & 7;
+ destData[dp >> 3] = (byte)(destData[dp >> 3] & ~(0x01 << shift) | (index << shift));
+ } break;
+ }
+ }
+ }
+ }
+ return;
+ }
+
+ /*** Comprehensive blit (apply transformations) ***/
+ int alpha = alphaMode;
+ int index = 0;
+ int indexq = 0;
+ int lastindex = 0, lastr = -1, lastg = -1, lastb = -1;
+ final int[] rerr, gerr, berr;
+ if (ditherEnabled) {
+ rerr = new int[destWidth + 2];
+ gerr = new int[destWidth + 2];
+ berr = new int[destWidth + 2];
+ } else {
+ rerr = null; gerr = null; berr = null;
+ }
+ for (int dy = destHeight, sfy = sfyi; dy > 0; --dy,
+ sp = spr += (sfy >>> 16) * srcStride,
+ ap = apr += (sfy >>> 16) * alphaStride,
+ sfy = (sfy & 0xffff) + sfyi,
+ dp = dpr += dpryi) {
+ int lrerr = 0, lgerr = 0, lberr = 0;
+ for (int dx = destWidth, sfx = sfxi; dx > 0; --dx,
+ dp += dprxi,
+ sfx = (sfx & 0xffff) + sfxi) {
+ /*** READ NEXT PIXEL ***/
+ switch (stype) {
+ case TYPE_INDEX_8:
+ index = srcData[sp] & 0xff;
+ sp += (sfx >>> 16);
+ break;
+ case TYPE_INDEX_4:
+ if ((sp & 1) != 0) index = srcData[sp >> 1] & 0x0f;
+ else index = (srcData[sp >> 1] >>> 4) & 0x0f;
+ sp += (sfx >>> 16);
+ break;
+ case TYPE_INDEX_2:
+ index = (srcData[sp >> 2] >>> (6 - (sp & 3) * 2)) & 0x03;
+ sp += (sfx >>> 16);
+ break;
+ case TYPE_INDEX_1_MSB:
+ index = (srcData[sp >> 3] >>> (7 - (sp & 7))) & 0x01;
+ sp += (sfx >>> 16);
+ break;
+ case TYPE_INDEX_1_LSB:
+ index = (srcData[sp >> 3] >>> (sp & 7)) & 0x01;
+ sp += (sfx >>> 16);
+ break;
+ }
+
+ /*** DO SPECIAL PROCESSING IF REQUIRED ***/
+ int r = srcReds[index] & 0xff, g = srcGreens[index] & 0xff, b = srcBlues[index] & 0xff;
+ switch (alphaMode) {
+ case ALPHA_CHANNEL_SEPARATE:
+ alpha = ((alphaData[ap] & 0xff) << 16) / 255;
+ ap += (sfx >> 16);
+ break;
+ case ALPHA_MASK_UNPACKED:
+ alpha = (alphaData[ap] != 0) ? 0x10000 : 0;
+ ap += (sfx >> 16);
+ break;
+ case ALPHA_MASK_PACKED:
+ alpha = (alphaData[ap >> 3] << ((ap & 7) + 9)) & 0x10000;
+ ap += (sfx >> 16);
+ break;
+ case ALPHA_MASK_INDEX: { // could speed up using binary search if we sorted the indices
+ int i = 0;
+ while (i < alphaData.length) {
+ if (index == (alphaData[i] & 0xff)) break;
+ }
+ if (i < alphaData.length) continue;
+ } break;
+ case ALPHA_MASK_RGB: {
+ int i = 0;
+ while (i < alphaData.length) {
+ if ((r == (alphaData[i] & 0xff)) &&
+ (g == (alphaData[i + 1] & 0xff)) &&
+ (b == (alphaData[i + 2] & 0xff))) break;
+ i += 3;
+ }
+ if (i < alphaData.length) continue;
+ } break;
+ }
+ if (alpha != 0x10000) {
+ if (alpha == 0x0000) continue;
+ switch (dtype) {
+ case TYPE_INDEX_8:
+ indexq = destData[dp] & 0xff;
+ break;
+ case TYPE_INDEX_4:
+ if ((dp & 1) != 0) indexq = destData[dp >> 1] & 0x0f;
+ else indexq = (destData[dp >> 1] >>> 4) & 0x0f;
+ break;
+ case TYPE_INDEX_2:
+ indexq = (destData[dp >> 2] >>> (6 - (dp & 3) * 2)) & 0x03;
+ break;
+ case TYPE_INDEX_1_MSB:
+ indexq = (destData[dp >> 3] >>> (7 - (dp & 7))) & 0x01;
+ break;
+ case TYPE_INDEX_1_LSB:
+ indexq = (destData[dp >> 3] >>> (dp & 7)) & 0x01;
+ break;
+ }
+ // Perform alpha blending
+ final int rq = destReds[indexq] & 0xff;
+ final int gq = destGreens[indexq] & 0xff;
+ final int bq = destBlues[indexq] & 0xff;
+ r = rq + ((r - rq) * alpha >> 16);
+ g = gq + ((g - gq) * alpha >> 16);
+ b = bq + ((b - bq) * alpha >> 16);
+ }
+
+ /*** MAP COLOR TO THE PALETTE ***/
+ if (ditherEnabled) {
+ // Floyd-Steinberg error diffusion
+ r += rerr[dx] >> 4;
+ if (r < 0) r = 0; else if (r > 255) r = 255;
+ g += gerr[dx] >> 4;
+ if (g < 0) g = 0; else if (g > 255) g = 255;
+ b += berr[dx] >> 4;
+ if (b < 0) b = 0; else if (b > 255) b = 255;
+ rerr[dx] = lrerr;
+ gerr[dx] = lgerr;
+ berr[dx] = lberr;
+ }
+ if (r != lastr || g != lastg || b != lastb) {
+ // moving the variable declarations out seems to make the JDK JIT happier...
+ for (int j = 0, dr, dg, db, distance, minDistance = 0x7fffffff; j < destPaletteSize; ++j) {
+ dr = (destReds[j] & 0xff) - r;
+ dg = (destGreens[j] & 0xff) - g;
+ db = (destBlues[j] & 0xff) - b;
+ distance = dr * dr + dg * dg + db * db;
+ if (distance < minDistance) {
+ lastindex = j;
+ if (distance == 0) break;
+ minDistance = distance;
+ }
+ }
+ lastr = r; lastg = g; lastb = b;
+ }
+ if (ditherEnabled) {
+ // Floyd-Steinberg error diffusion, cont'd...
+ final int dxm1 = dx - 1, dxp1 = dx + 1;
+ int acc;
+ rerr[dxp1] += acc = (lrerr = r - (destReds[lastindex] & 0xff)) + lrerr + lrerr;
+ rerr[dx] += acc += lrerr + lrerr;
+ rerr[dxm1] += acc + lrerr + lrerr;
+ gerr[dxp1] += acc = (lgerr = g - (destGreens[lastindex] & 0xff)) + lgerr + lgerr;
+ gerr[dx] += acc += lgerr + lgerr;
+ gerr[dxm1] += acc + lgerr + lgerr;
+ berr[dxp1] += acc = (lberr = b - (destBlues[lastindex] & 0xff)) + lberr + lberr;
+ berr[dx] += acc += lberr + lberr;
+ berr[dxm1] += acc + lberr + lberr;
+ }
+
+ /*** WRITE NEXT PIXEL ***/
+ switch (dtype) {
+ case TYPE_INDEX_8:
+ destData[dp] = (byte) lastindex;
+ break;
+ case TYPE_INDEX_4:
+ if ((dp & 1) != 0) destData[dp >> 1] = (byte)((destData[dp >> 1] & 0xf0) | lastindex);
+ else destData[dp >> 1] = (byte)((destData[dp >> 1] & 0x0f) | (lastindex << 4));
+ break;
+ case TYPE_INDEX_2: {
+ final int shift = 6 - (dp & 3) * 2;
+ destData[dp >> 2] = (byte)(destData[dp >> 2] & ~(0x03 << shift) | (lastindex << shift));
+ } break;
+ case TYPE_INDEX_1_MSB: {
+ final int shift = 7 - (dp & 7);
+ destData[dp >> 3] = (byte)(destData[dp >> 3] & ~(0x01 << shift) | (lastindex << shift));
+ } break;
+ case TYPE_INDEX_1_LSB: {
+ final int shift = dp & 7;
+ destData[dp >> 3] = (byte)(destData[dp >> 3] & ~(0x01 << shift) | (lastindex << shift));
+ } break;
+ }
+ }
+ }
+}
+
+/**
+ * Blits an index palette image into a direct palette image.
+ * <p>
+ * Note: The source and destination masks and palettes must
+ * always be fully specified.
+ * </p>
+ *
+ * @param op the blitter operation: a combination of BLIT_xxx flags
+ * (see BLIT_xxx constants)
+ * @param srcData the source byte array containing image data
+ * @param srcDepth the source depth: one of 1, 2, 4, 8
+ * @param srcStride the source number of bytes per line
+ * @param srcOrder the source byte ordering: one of MSB_FIRST or LSB_FIRST;
+ * ignored if srcDepth is not 1
+ * @param srcX the top-left x-coord of the source blit region
+ * @param srcY the top-left y-coord of the source blit region
+ * @param srcWidth the width of the source blit region
+ * @param srcHeight the height of the source blit region
+ * @param srcReds the source palette red component intensities
+ * @param srcGreens the source palette green component intensities
+ * @param srcBlues the source palette blue component intensities
+ * @param alphaMode the alpha blending or mask mode, may be
+ * an integer 0-255 for global alpha; ignored if BLIT_ALPHA
+ * not specified in the blitter operations
+ * (see ALPHA_MODE_xxx constants)
+ * @param alphaData the alpha blending or mask data, varies depending
+ * on the value of alphaMode and sometimes ignored
+ * @param alphaStride the alpha data number of bytes per line
+ * @param alphaX the top-left x-coord of the alpha blit region
+ * @param alphaY the top-left y-coord of the alpha blit region
+ * @param destData the destination byte array containing image data
+ * @param destDepth the destination depth: one of 8, 16, 24, 32
+ * @param destStride the destination number of bytes per line
+ * @param destOrder the destination byte ordering: one of MSB_FIRST or LSB_FIRST;
+ * ignored if destDepth is not 16 or 32
+ * @param destX the top-left x-coord of the destination blit region
+ * @param destY the top-left y-coord of the destination blit region
+ * @param destWidth the width of the destination blit region
+ * @param destHeight the height of the destination blit region
+ * @param destRedMask the destination red channel mask
+ * @param destGreenMask the destination green channel mask
+ * @param destBlueMask the destination blue channel mask
+ * @param flipX if true the resulting image is flipped along the vertical axis
+ * @param flipY if true the resulting image is flipped along the horizontal axis
+ */
+static void blit(int op,
+ byte[] srcData, int srcDepth, int srcStride, int srcOrder,
+ int srcX, int srcY, int srcWidth, int srcHeight,
+ byte[] srcReds, byte[] srcGreens, byte[] srcBlues,
+ int alphaMode, byte[] alphaData, int alphaStride, int alphaX, int alphaY,
+ byte[] destData, int destDepth, int destStride, int destOrder,
+ int destX, int destY, int destWidth, int destHeight,
+ int destRedMask, int destGreenMask, int destBlueMask,
+ boolean flipX, boolean flipY) {
+ if ((destWidth <= 0) || (destHeight <= 0) || (alphaMode == ALPHA_TRANSPARENT)) return;
+
+ // these should be supplied as params later
+ final int destAlphaMask = 0;
+
+ /*** Prepare scaling data ***/
+ final int dwm1 = destWidth - 1;
+ final int sfxi = (dwm1 != 0) ? (int)((((long)srcWidth << 16) - 1) / dwm1) : 0;
+ final int dhm1 = destHeight - 1;
+ final int sfyi = (dhm1 != 0) ? (int)((((long)srcHeight << 16) - 1) / dhm1) : 0;
+
+ /*** Prepare source-related data ***/
+ final int stype;
+ switch (srcDepth) {
+ case 8:
+ stype = TYPE_INDEX_8;
+ break;
+ case 4:
+ srcStride <<= 1;
+ stype = TYPE_INDEX_4;
+ break;
+ case 2:
+ srcStride <<= 2;
+ stype = TYPE_INDEX_2;
+ break;
+ case 1:
+ srcStride <<= 3;
+ stype = (srcOrder == MSB_FIRST) ? TYPE_INDEX_1_MSB : TYPE_INDEX_1_LSB;
+ break;
+ default:
+ //throw new IllegalArgumentException("Invalid source type");
+ return;
+ }
+ int spr = srcY * srcStride + srcX;
+
+ /*** Prepare destination-related data ***/
+ final int dbpp, dtype;
+ switch (destDepth) {
+ case 8:
+ dbpp = 1;
+ dtype = TYPE_GENERIC_8;
+ break;
+ case 16:
+ dbpp = 2;
+ dtype = (destOrder == MSB_FIRST) ? TYPE_GENERIC_16_MSB : TYPE_GENERIC_16_LSB;
+ break;
+ case 24:
+ dbpp = 3;
+ dtype = TYPE_GENERIC_24;
+ break;
+ case 32:
+ dbpp = 4;
+ dtype = (destOrder == MSB_FIRST) ? TYPE_GENERIC_32_MSB : TYPE_GENERIC_32_LSB;
+ break;
+ default:
+ //throw new IllegalArgumentException("Invalid destination type");
+ return;
+ }
+ int dpr = ((flipY) ? destY + dhm1 : destY) * destStride + ((flipX) ? destX + dwm1 : destX) * dbpp;
+ final int dprxi = (flipX) ? -dbpp : dbpp;
+ final int dpryi = (flipY) ? -destStride : destStride;
+
+ /*** Prepare special processing data ***/
+ int apr;
+ if ((op & BLIT_ALPHA) != 0) {
+ switch (alphaMode) {
+ case ALPHA_MASK_UNPACKED:
+ case ALPHA_CHANNEL_SEPARATE:
+ if (alphaData == null) alphaMode = 0x10000;
+ apr = alphaY * alphaStride + alphaX;
+ break;
+ case ALPHA_MASK_PACKED:
+ if (alphaData == null) alphaMode = 0x10000;
+ alphaStride <<= 3;
+ apr = alphaY * alphaStride + alphaX;
+ break;
+ case ALPHA_MASK_INDEX:
+ case ALPHA_MASK_RGB:
+ if (alphaData == null) alphaMode = 0x10000;
+ apr = 0;
+ break;
+ default:
+ alphaMode = (alphaMode << 16) / 255; // prescale
+ case ALPHA_CHANNEL_SOURCE:
+ apr = 0;
+ break;
+ }
+ } else {
+ alphaMode = 0x10000;
+ apr = 0;
+ }
+
+ /*** Comprehensive blit (apply transformations) ***/
+ final int destRedShift = getChannelShift(destRedMask);
+ final int destRedWidth = getChannelWidth(destRedMask, destRedShift);
+ final byte[] destReds = ANY_TO_EIGHT[destRedWidth];
+ final int destRedPreShift = 8 - destRedWidth;
+ final int destGreenShift = getChannelShift(destGreenMask);
+ final int destGreenWidth = getChannelWidth(destGreenMask, destGreenShift);
+ final byte[] destGreens = ANY_TO_EIGHT[destGreenWidth];
+ final int destGreenPreShift = 8 - destGreenWidth;
+ final int destBlueShift = getChannelShift(destBlueMask);
+ final int destBlueWidth = getChannelWidth(destBlueMask, destBlueShift);
+ final byte[] destBlues = ANY_TO_EIGHT[destBlueWidth];
+ final int destBluePreShift = 8 - destBlueWidth;
+ final int destAlphaShift = getChannelShift(destAlphaMask);
+ final int destAlphaWidth = getChannelWidth(destAlphaMask, destAlphaShift);
+ final byte[] destAlphas = ANY_TO_EIGHT[destAlphaWidth];
+ final int destAlphaPreShift = 8 - destAlphaWidth;
+
+ int dp = dpr;
+ int sp = spr;
+ int ap = apr, alpha = alphaMode;
+ int r = 0, g = 0, b = 0, a = 0, index = 0;
+ int rq = 0, gq = 0, bq = 0, aq = 0;
+ for (int dy = destHeight, sfy = sfyi; dy > 0; --dy,
+ sp = spr += (sfy >>> 16) * srcStride,
+ ap = apr += (sfy >>> 16) * alphaStride,
+ sfy = (sfy & 0xffff) + sfyi,
+ dp = dpr += dpryi) {
+ for (int dx = destWidth, sfx = sfxi; dx > 0; --dx,
+ dp += dprxi,
+ sfx = (sfx & 0xffff) + sfxi) {
+ /*** READ NEXT PIXEL ***/
+ switch (stype) {
+ case TYPE_INDEX_8:
+ index = srcData[sp] & 0xff;
+ sp += (sfx >>> 16);
+ break;
+ case TYPE_INDEX_4:
+ if ((sp & 1) != 0) index = srcData[sp >> 1] & 0x0f;
+ else index = (srcData[sp >> 1] >>> 4) & 0x0f;
+ sp += (sfx >>> 16);
+ break;
+ case TYPE_INDEX_2:
+ index = (srcData[sp >> 2] >>> (6 - (sp & 3) * 2)) & 0x03;
+ sp += (sfx >>> 16);
+ break;
+ case TYPE_INDEX_1_MSB:
+ index = (srcData[sp >> 3] >>> (7 - (sp & 7))) & 0x01;
+ sp += (sfx >>> 16);
+ break;
+ case TYPE_INDEX_1_LSB:
+ index = (srcData[sp >> 3] >>> (sp & 7)) & 0x01;
+ sp += (sfx >>> 16);
+ break;
+ }
+
+ /*** DO SPECIAL PROCESSING IF REQUIRED ***/
+ r = srcReds[index] & 0xff;
+ g = srcGreens[index] & 0xff;
+ b = srcBlues[index] & 0xff;
+ switch (alphaMode) {
+ case ALPHA_CHANNEL_SEPARATE:
+ alpha = ((alphaData[ap] & 0xff) << 16) / 255;
+ ap += (sfx >> 16);
+ break;
+ case ALPHA_MASK_UNPACKED:
+ alpha = (alphaData[ap] != 0) ? 0x10000 : 0;
+ ap += (sfx >> 16);
+ break;
+ case ALPHA_MASK_PACKED:
+ alpha = (alphaData[ap >> 3] << ((ap & 7) + 9)) & 0x10000;
+ ap += (sfx >> 16);
+ break;
+ case ALPHA_MASK_INDEX: { // could speed up using binary search if we sorted the indices
+ int i = 0;
+ while (i < alphaData.length) {
+ if (index == (alphaData[i] & 0xff)) break;
+ }
+ if (i < alphaData.length) continue;
+ } break;
+ case ALPHA_MASK_RGB: {
+ int i = 0;
+ while (i < alphaData.length) {
+ if ((r == (alphaData[i] & 0xff)) &&
+ (g == (alphaData[i + 1] & 0xff)) &&
+ (b == (alphaData[i + 2] & 0xff))) break;
+ i += 3;
+ }
+ if (i < alphaData.length) continue;
+ } break;
+ }
+ if (alpha != 0x10000) {
+ if (alpha == 0x0000) continue;
+ switch (dtype) {
+ case TYPE_GENERIC_8: {
+ final int data = destData[dp] & 0xff;
+ rq = destReds[(data & destRedMask) >>> destRedShift] & 0xff;
+ gq = destGreens[(data & destGreenMask) >>> destGreenShift] & 0xff;
+ bq = destBlues[(data & destBlueMask) >>> destBlueShift] & 0xff;
+ aq = destAlphas[(data & destAlphaMask) >>> destAlphaShift] & 0xff;
+ } break;
+ case TYPE_GENERIC_16_MSB: {
+ final int data = ((destData[dp] & 0xff) << 8) | (destData[dp + 1] & 0xff);
+ rq = destReds[(data & destRedMask) >>> destRedShift] & 0xff;
+ gq = destGreens[(data & destGreenMask) >>> destGreenShift] & 0xff;
+ bq = destBlues[(data & destBlueMask) >>> destBlueShift] & 0xff;
+ aq = destAlphas[(data & destAlphaMask) >>> destAlphaShift] & 0xff;
+ } break;
+ case TYPE_GENERIC_16_LSB: {
+ final int data = ((destData[dp + 1] & 0xff) << 8) | (destData[dp] & 0xff);
+ rq = destReds[(data & destRedMask) >>> destRedShift] & 0xff;
+ gq = destGreens[(data & destGreenMask) >>> destGreenShift] & 0xff;
+ bq = destBlues[(data & destBlueMask) >>> destBlueShift] & 0xff;
+ aq = destAlphas[(data & destAlphaMask) >>> destAlphaShift] & 0xff;
+ } break;
+ case TYPE_GENERIC_24: {
+ final int data = (( ((destData[dp] & 0xff) << 8) |
+ (destData[dp + 1] & 0xff)) << 8) |
+ (destData[dp + 2] & 0xff);
+ rq = destReds[(data & destRedMask) >>> destRedShift] & 0xff;
+ gq = destGreens[(data & destGreenMask) >>> destGreenShift] & 0xff;
+ bq = destBlues[(data & destBlueMask) >>> destBlueShift] & 0xff;
+ aq = destAlphas[(data & destAlphaMask) >>> destAlphaShift] & 0xff;
+ } break;
+ case TYPE_GENERIC_32_MSB: {
+ final int data = (( (( ((destData[dp] & 0xff) << 8) |
+ (destData[dp + 1] & 0xff)) << 8) |
+ (destData[dp + 2] & 0xff)) << 8) |
+ (destData[dp + 3] & 0xff);
+ rq = destReds[(data & destRedMask) >>> destRedShift] & 0xff;
+ gq = destGreens[(data & destGreenMask) >>> destGreenShift] & 0xff;
+ bq = destBlues[(data & destBlueMask) >>> destBlueShift] & 0xff;
+ aq = destAlphas[(data & destAlphaMask) >>> destAlphaShift] & 0xff;
+ } break;
+ case TYPE_GENERIC_32_LSB: {
+ final int data = (( (( ((destData[dp + 3] & 0xff) << 8) |
+ (destData[dp + 2] & 0xff)) << 8) |
+ (destData[dp + 1] & 0xff)) << 8) |
+ (destData[dp] & 0xff);
+ rq = destReds[(data & destRedMask) >>> destRedShift] & 0xff;
+ gq = destGreens[(data & destGreenMask) >>> destGreenShift] & 0xff;
+ bq = destBlues[(data & destBlueMask) >>> destBlueShift] & 0xff;
+ aq = destAlphas[(data & destAlphaMask) >>> destAlphaShift] & 0xff;
+ } break;
+ }
+ // Perform alpha blending
+ a = aq + ((a - aq) * alpha >> 16);
+ r = rq + ((r - rq) * alpha >> 16);
+ g = gq + ((g - gq) * alpha >> 16);
+ b = bq + ((b - bq) * alpha >> 16);
+ }
+
+ /*** WRITE NEXT PIXEL ***/
+ final int data =
+ (r >>> destRedPreShift << destRedShift) |
+ (g >>> destGreenPreShift << destGreenShift) |
+ (b >>> destBluePreShift << destBlueShift) |
+ (a >>> destAlphaPreShift << destAlphaShift);
+ switch (dtype) {
+ case TYPE_GENERIC_8: {
+ destData[dp] = (byte) data;
+ } break;
+ case TYPE_GENERIC_16_MSB: {
+ destData[dp] = (byte) (data >>> 8);
+ destData[dp + 1] = (byte) (data & 0xff);
+ } break;
+ case TYPE_GENERIC_16_LSB: {
+ destData[dp] = (byte) (data & 0xff);
+ destData[dp + 1] = (byte) (data >>> 8);
+ } break;
+ case TYPE_GENERIC_24: {
+ destData[dp] = (byte) (data >>> 16);
+ destData[dp + 1] = (byte) (data >>> 8);
+ destData[dp + 2] = (byte) (data & 0xff);
+ } break;
+ case TYPE_GENERIC_32_MSB: {
+ destData[dp] = (byte) (data >>> 24);
+ destData[dp + 1] = (byte) (data >>> 16);
+ destData[dp + 2] = (byte) (data >>> 8);
+ destData[dp + 3] = (byte) (data & 0xff);
+ } break;
+ case TYPE_GENERIC_32_LSB: {
+ destData[dp] = (byte) (data & 0xff);
+ destData[dp + 1] = (byte) (data >>> 8);
+ destData[dp + 2] = (byte) (data >>> 16);
+ destData[dp + 3] = (byte) (data >>> 24);
+ } break;
+ }
+ }
+ }
+}
+
+/**
+ * Blits a direct palette image into an index palette image.
+ * <p>
+ * Note: The source and destination masks and palettes must
+ * always be fully specified.
+ * </p>
+ *
+ * @param op the blitter operation: a combination of BLIT_xxx flags
+ * (see BLIT_xxx constants)
+ * @param srcData the source byte array containing image data
+ * @param srcDepth the source depth: one of 8, 16, 24, 32
+ * @param srcStride the source number of bytes per line
+ * @param srcOrder the source byte ordering: one of MSB_FIRST or LSB_FIRST;
+ * ignored if srcDepth is not 16 or 32
+ * @param srcX the top-left x-coord of the source blit region
+ * @param srcY the top-left y-coord of the source blit region
+ * @param srcWidth the width of the source blit region
+ * @param srcHeight the height of the source blit region
+ * @param srcRedMask the source red channel mask
+ * @param srcGreenMask the source green channel mask
+ * @param srcBlueMask the source blue channel mask
+ * @param alphaMode the alpha blending or mask mode, may be
+ * an integer 0-255 for global alpha; ignored if BLIT_ALPHA
+ * not specified in the blitter operations
+ * (see ALPHA_MODE_xxx constants)
+ * @param alphaData the alpha blending or mask data, varies depending
+ * on the value of alphaMode and sometimes ignored
+ * @param alphaStride the alpha data number of bytes per line
+ * @param alphaX the top-left x-coord of the alpha blit region
+ * @param alphaY the top-left y-coord of the alpha blit region
+ * @param destData the destination byte array containing image data
+ * @param destDepth the destination depth: one of 1, 2, 4, 8
+ * @param destStride the destination number of bytes per line
+ * @param destOrder the destination byte ordering: one of MSB_FIRST or LSB_FIRST;
+ * ignored if destDepth is not 1
+ * @param destX the top-left x-coord of the destination blit region
+ * @param destY the top-left y-coord of the destination blit region
+ * @param destWidth the width of the destination blit region
+ * @param destHeight the height of the destination blit region
+ * @param destReds the destination palette red component intensities
+ * @param destGreens the destination palette green component intensities
+ * @param destBlues the destination palette blue component intensities
+ * @param flipX if true the resulting image is flipped along the vertical axis
+ * @param flipY if true the resulting image is flipped along the horizontal axis
+ */
+static void blit(int op,
+ byte[] srcData, int srcDepth, int srcStride, int srcOrder,
+ int srcX, int srcY, int srcWidth, int srcHeight,
+ int srcRedMask, int srcGreenMask, int srcBlueMask,
+ int alphaMode, byte[] alphaData, int alphaStride, int alphaX, int alphaY,
+ byte[] destData, int destDepth, int destStride, int destOrder,
+ int destX, int destY, int destWidth, int destHeight,
+ byte[] destReds, byte[] destGreens, byte[] destBlues,
+ boolean flipX, boolean flipY) {
+ if ((destWidth <= 0) || (destHeight <= 0) || (alphaMode == ALPHA_TRANSPARENT)) return;
+
+ // these should be supplied as params later
+ final int srcAlphaMask = 0;
+
+ /*** Prepare scaling data ***/
+ final int dwm1 = destWidth - 1;
+ final int sfxi = (dwm1 != 0) ? (int)((((long)srcWidth << 16) - 1) / dwm1) : 0;
+ final int dhm1 = destHeight - 1;
+ final int sfyi = (dhm1 != 0) ? (int)((((long)srcHeight << 16) - 1) / dhm1) : 0;
+
+ /*** Prepare source-related data ***/
+ final int sbpp, stype;
+ switch (srcDepth) {
+ case 8:
+ sbpp = 1;
+ stype = TYPE_GENERIC_8;
+ break;
+ case 16:
+ sbpp = 2;
+ stype = (srcOrder == MSB_FIRST) ? TYPE_GENERIC_16_MSB : TYPE_GENERIC_16_LSB;
+ break;
+ case 24:
+ sbpp = 3;
+ stype = TYPE_GENERIC_24;
+ break;
+ case 32:
+ sbpp = 4;
+ stype = (srcOrder == MSB_FIRST) ? TYPE_GENERIC_32_MSB : TYPE_GENERIC_32_LSB;
+ break;
+ default:
+ //throw new IllegalArgumentException("Invalid source type");
+ return;
+ }
+ int spr = srcY * srcStride + srcX * sbpp;
+
+ /*** Prepare destination-related data ***/
+ final int dtype;
+ switch (destDepth) {
+ case 8:
+ dtype = TYPE_INDEX_8;
+ break;
+ case 4:
+ destStride <<= 1;
+ dtype = TYPE_INDEX_4;
+ break;
+ case 2:
+ destStride <<= 2;
+ dtype = TYPE_INDEX_2;
+ break;
+ case 1:
+ destStride <<= 3;
+ dtype = (destOrder == MSB_FIRST) ? TYPE_INDEX_1_MSB : TYPE_INDEX_1_LSB;
+ break;
+ default:
+ //throw new IllegalArgumentException("Invalid source type");
+ return;
+ }
+ int dpr = ((flipY) ? destY + dhm1 : destY) * destStride + ((flipX) ? destX + dwm1 : destX);
+ final int dprxi = (flipX) ? -1 : 1;
+ final int dpryi = (flipY) ? -destStride : destStride;
+
+ /*** Prepare special processing data ***/
+ int apr;
+ if ((op & BLIT_ALPHA) != 0) {
+ switch (alphaMode) {
+ case ALPHA_MASK_UNPACKED:
+ case ALPHA_CHANNEL_SEPARATE:
+ if (alphaData == null) alphaMode = 0x10000;
+ apr = alphaY * alphaStride + alphaX;
+ break;
+ case ALPHA_MASK_PACKED:
+ if (alphaData == null) alphaMode = 0x10000;
+ alphaStride <<= 3;
+ apr = alphaY * alphaStride + alphaX;
+ break;
+ case ALPHA_MASK_INDEX:
+ //throw new IllegalArgumentException("Invalid alpha type");
+ return;
+ case ALPHA_MASK_RGB:
+ if (alphaData == null) alphaMode = 0x10000;
+ apr = 0;
+ break;
+ default:
+ alphaMode = (alphaMode << 16) / 255; // prescale
+ case ALPHA_CHANNEL_SOURCE:
+ apr = 0;
+ break;
+ }
+ } else {
+ alphaMode = 0x10000;
+ apr = 0;
+ }
+ final boolean ditherEnabled = (op & BLIT_DITHER) != 0;
+
+ /*** Comprehensive blit (apply transformations) ***/
+ final int srcRedShift = getChannelShift(srcRedMask);
+ final byte[] srcReds = ANY_TO_EIGHT[getChannelWidth(srcRedMask, srcRedShift)];
+ final int srcGreenShift = getChannelShift(srcGreenMask);
+ final byte[] srcGreens = ANY_TO_EIGHT[getChannelWidth(srcGreenMask, srcGreenShift)];
+ final int srcBlueShift = getChannelShift(srcBlueMask);
+ final byte[] srcBlues = ANY_TO_EIGHT[getChannelWidth(srcBlueMask, srcBlueShift)];
+ final int srcAlphaShift = getChannelShift(srcAlphaMask);
+ final byte[] srcAlphas = ANY_TO_EIGHT[getChannelWidth(srcAlphaMask, srcAlphaShift)];
+
+ int dp = dpr;
+ int sp = spr;
+ int ap = apr, alpha = alphaMode;
+ int r = 0, g = 0, b = 0, a = 0;
+ int indexq = 0;
+ int lastindex = 0, lastr = -1, lastg = -1, lastb = -1;
+ final int[] rerr, gerr, berr;
+ int destPaletteSize = 1 << destDepth;
+ if ((destReds != null) && (destReds.length < destPaletteSize)) destPaletteSize = destReds.length;
+ if (ditherEnabled) {
+ rerr = new int[destWidth + 2];
+ gerr = new int[destWidth + 2];
+ berr = new int[destWidth + 2];
+ } else {
+ rerr = null; gerr = null; berr = null;
+ }
+ for (int dy = destHeight, sfy = sfyi; dy > 0; --dy,
+ sp = spr += (sfy >>> 16) * srcStride,
+ ap = apr += (sfy >>> 16) * alphaStride,
+ sfy = (sfy & 0xffff) + sfyi,
+ dp = dpr += dpryi) {
+ int lrerr = 0, lgerr = 0, lberr = 0;
+ for (int dx = destWidth, sfx = sfxi; dx > 0; --dx,
+ dp += dprxi,
+ sfx = (sfx & 0xffff) + sfxi) {
+ /*** READ NEXT PIXEL ***/
+ switch (stype) {
+ case TYPE_GENERIC_8: {
+ final int data = srcData[sp] & 0xff;
+ sp += (sfx >>> 16);
+ r = srcReds[(data & srcRedMask) >>> srcRedShift] & 0xff;
+ g = srcGreens[(data & srcGreenMask) >>> srcGreenShift] & 0xff;
+ b = srcBlues[(data & srcBlueMask) >>> srcBlueShift] & 0xff;
+ a = srcAlphas[(data & srcAlphaMask) >>> srcAlphaShift] & 0xff;
+ } break;
+ case TYPE_GENERIC_16_MSB: {
+ final int data = ((srcData[sp] & 0xff) << 8) | (srcData[sp + 1] & 0xff);
+ sp += (sfx >>> 16) * 2;
+ r = srcReds[(data & srcRedMask) >>> srcRedShift] & 0xff;
+ g = srcGreens[(data & srcGreenMask) >>> srcGreenShift] & 0xff;
+ b = srcBlues[(data & srcBlueMask) >>> srcBlueShift] & 0xff;
+ a = srcAlphas[(data & srcAlphaMask) >>> srcAlphaShift] & 0xff;
+ } break;
+ case TYPE_GENERIC_16_LSB: {
+ final int data = ((srcData[sp + 1] & 0xff) << 8) | (srcData[sp] & 0xff);
+ sp += (sfx >>> 16) * 2;
+ r = srcReds[(data & srcRedMask) >>> srcRedShift] & 0xff;
+ g = srcGreens[(data & srcGreenMask) >>> srcGreenShift] & 0xff;
+ b = srcBlues[(data & srcBlueMask) >>> srcBlueShift] & 0xff;
+ a = srcAlphas[(data & srcAlphaMask) >>> srcAlphaShift] & 0xff;
+ } break;
+ case TYPE_GENERIC_24: {
+ final int data = (( ((srcData[sp] & 0xff) << 8) |
+ (srcData[sp + 1] & 0xff)) << 8) |
+ (srcData[sp + 2] & 0xff);
+ sp += (sfx >>> 16) * 3;
+ r = srcReds[(data & srcRedMask) >>> srcRedShift] & 0xff;
+ g = srcGreens[(data & srcGreenMask) >>> srcGreenShift] & 0xff;
+ b = srcBlues[(data & srcBlueMask) >>> srcBlueShift] & 0xff;
+ a = srcAlphas[(data & srcAlphaMask) >>> srcAlphaShift] & 0xff;
+ } break;
+ case TYPE_GENERIC_32_MSB: {
+ final int data = (( (( ((srcData[sp] & 0xff) << 8) |
+ (srcData[sp + 1] & 0xff)) << 8) |
+ (srcData[sp + 2] & 0xff)) << 8) |
+ (srcData[sp + 3] & 0xff);
+ sp += (sfx >>> 16) * 4;
+ r = srcReds[(data & srcRedMask) >>> srcRedShift] & 0xff;
+ g = srcGreens[(data & srcGreenMask) >>> srcGreenShift] & 0xff;
+ b = srcBlues[(data & srcBlueMask) >>> srcBlueShift] & 0xff;
+ a = srcAlphas[(data & srcAlphaMask) >>> srcAlphaShift] & 0xff;
+ } break;
+ case TYPE_GENERIC_32_LSB: {
+ final int data = (( (( ((srcData[sp + 3] & 0xff) << 8) |
+ (srcData[sp + 2] & 0xff)) << 8) |
+ (srcData[sp + 1] & 0xff)) << 8) |
+ (srcData[sp] & 0xff);
+ sp += (sfx >>> 16) * 4;
+ r = srcReds[(data & srcRedMask) >>> srcRedShift] & 0xff;
+ g = srcGreens[(data & srcGreenMask) >>> srcGreenShift] & 0xff;
+ b = srcBlues[(data & srcBlueMask) >>> srcBlueShift] & 0xff;
+ a = srcAlphas[(data & srcAlphaMask) >>> srcAlphaShift] & 0xff;
+ } break;
+ }
+
+ /*** DO SPECIAL PROCESSING IF REQUIRED ***/
+ switch (alphaMode) {
+ case ALPHA_CHANNEL_SEPARATE:
+ alpha = ((alphaData[ap] & 0xff) << 16) / 255;
+ ap += (sfx >> 16);
+ break;
+ case ALPHA_CHANNEL_SOURCE:
+ alpha = (a << 16) / 255;
+ break;
+ case ALPHA_MASK_UNPACKED:
+ alpha = (alphaData[ap] != 0) ? 0x10000 : 0;
+ ap += (sfx >> 16);
+ break;
+ case ALPHA_MASK_PACKED:
+ alpha = (alphaData[ap >> 3] << ((ap & 7) + 9)) & 0x10000;
+ ap += (sfx >> 16);
+ break;
+ case ALPHA_MASK_RGB:
+ alpha = 0x10000;
+ for (int i = 0; i < alphaData.length; i += 3) {
+ if ((r == alphaData[i]) && (g == alphaData[i + 1]) && (b == alphaData[i + 2])) {
+ alpha = 0x0000;
+ break;
+ }
+ }
+ break;
+ }
+ if (alpha != 0x10000) {
+ if (alpha == 0x0000) continue;
+ switch (dtype) {
+ case TYPE_INDEX_8:
+ indexq = destData[dp] & 0xff;
+ break;
+ case TYPE_INDEX_4:
+ if ((dp & 1) != 0) indexq = destData[dp >> 1] & 0x0f;
+ else indexq = (destData[dp >> 1] >>> 4) & 0x0f;
+ break;
+ case TYPE_INDEX_2:
+ indexq = (destData[dp >> 2] >>> (6 - (dp & 3) * 2)) & 0x03;
+ break;
+ case TYPE_INDEX_1_MSB:
+ indexq = (destData[dp >> 3] >>> (7 - (dp & 7))) & 0x01;
+ break;
+ case TYPE_INDEX_1_LSB:
+ indexq = (destData[dp >> 3] >>> (dp & 7)) & 0x01;
+ break;
+ }
+ // Perform alpha blending
+ final int rq = destReds[indexq] & 0xff;
+ final int gq = destGreens[indexq] & 0xff;
+ final int bq = destBlues[indexq] & 0xff;
+ r = rq + ((r - rq) * alpha >> 16);
+ g = gq + ((g - gq) * alpha >> 16);
+ b = bq + ((b - bq) * alpha >> 16);
+ }
+
+ /*** MAP COLOR TO THE PALETTE ***/
+ if (ditherEnabled) {
+ // Floyd-Steinberg error diffusion
+ r += rerr[dx] >> 4;
+ if (r < 0) r = 0; else if (r > 255) r = 255;
+ g += gerr[dx] >> 4;
+ if (g < 0) g = 0; else if (g > 255) g = 255;
+ b += berr[dx] >> 4;
+ if (b < 0) b = 0; else if (b > 255) b = 255;
+ rerr[dx] = lrerr;
+ gerr[dx] = lgerr;
+ berr[dx] = lberr;
+ }
+ if (r != lastr || g != lastg || b != lastb) {
+ // moving the variable declarations out seems to make the JDK JIT happier...
+ for (int j = 0, dr, dg, db, distance, minDistance = 0x7fffffff; j < destPaletteSize; ++j) {
+ dr = (destReds[j] & 0xff) - r;
+ dg = (destGreens[j] & 0xff) - g;
+ db = (destBlues[j] & 0xff) - b;
+ distance = dr * dr + dg * dg + db * db;
+ if (distance < minDistance) {
+ lastindex = j;
+ if (distance == 0) break;
+ minDistance = distance;
+ }
+ }
+ lastr = r; lastg = g; lastb = b;
+ }
+ if (ditherEnabled) {
+ // Floyd-Steinberg error diffusion, cont'd...
+ final int dxm1 = dx - 1, dxp1 = dx + 1;
+ int acc;
+ rerr[dxp1] += acc = (lrerr = r - (destReds[lastindex] & 0xff)) + lrerr + lrerr;
+ rerr[dx] += acc += lrerr + lrerr;
+ rerr[dxm1] += acc + lrerr + lrerr;
+ gerr[dxp1] += acc = (lgerr = g - (destGreens[lastindex] & 0xff)) + lgerr + lgerr;
+ gerr[dx] += acc += lgerr + lgerr;
+ gerr[dxm1] += acc + lgerr + lgerr;
+ berr[dxp1] += acc = (lberr = b - (destBlues[lastindex] & 0xff)) + lberr + lberr;
+ berr[dx] += acc += lberr + lberr;
+ berr[dxm1] += acc + lberr + lberr;
+ }
+
+ /*** WRITE NEXT PIXEL ***/
+ switch (dtype) {
+ case TYPE_INDEX_8:
+ destData[dp] = (byte) lastindex;
+ break;
+ case TYPE_INDEX_4:
+ if ((dp & 1) != 0) destData[dp >> 1] = (byte)((destData[dp >> 1] & 0xf0) | lastindex);
+ else destData[dp >> 1] = (byte)((destData[dp >> 1] & 0x0f) | (lastindex << 4));
+ break;
+ case TYPE_INDEX_2: {
+ final int shift = 6 - (dp & 3) * 2;
+ destData[dp >> 2] = (byte)(destData[dp >> 2] & ~(0x03 << shift) | (lastindex << shift));
+ } break;
+ case TYPE_INDEX_1_MSB: {
+ final int shift = 7 - (dp & 7);
+ destData[dp >> 3] = (byte)(destData[dp >> 3] & ~(0x01 << shift) | (lastindex << shift));
+ } break;
+ case TYPE_INDEX_1_LSB: {
+ final int shift = dp & 7;
+ destData[dp >> 3] = (byte)(destData[dp >> 3] & ~(0x01 << shift) | (lastindex << shift));
+ } break;
+ }
+ }
+ }
+}
+
+/**
+ * Computes the required channel shift from a mask.
+ */
+static int getChannelShift(int mask) {
+ if (mask == 0) return 0;
+ int i;
+ for (i = 0; ((mask & 1) == 0) && (i < 32); ++i) {
+ mask >>>= 1;
+ }
+ return i;
+}
+
+/**
+ * Computes the required channel width (depth) from a mask.
+ */
+static int getChannelWidth(int mask, int shift) {
+ if (mask == 0) return 0;
+ int i;
+ mask >>>= shift;
+ for (i = shift; ((mask & 1) != 0) && (i < 32); ++i) {
+ mask >>>= 1;
+ }
+ return i - shift;
+}
+
+/**
+ * Extracts a field from packed RGB data given a mask for that field.
+ */
+static byte getChannelField(int data, int mask) {
+ final int shift = getChannelShift(mask);
+ return ANY_TO_EIGHT[getChannelWidth(mask, shift)][(data & mask) >>> shift];
+}
+
+/**
+ * Creates an ImageData containing one band's worth of a gradient filled
+ * block. If <code>vertical</code> is true, the band must be tiled
+ * horizontally to fill a region, otherwise it must be tiled vertically.
+ *
+ * @param width the width of the region to be filled
+ * @param height the height of the region to be filled
+ * @param vertical if true sweeps from top to bottom, else
+ * sweeps from left to right
+ * @param fromRGB the color to start with
+ * @param toRGB the color to end with
+ * @param redBits the number of significant red bits, 0 for palette modes
+ * @param greenBits the number of significant green bits, 0 for palette modes
+ * @param blueBits the number of significant blue bits, 0 for palette modes
+ * @return the new ImageData
+ */
+static ImageData createGradientBand(
+ int width, int height, boolean vertical,
+ RGB fromRGB, RGB toRGB,
+ int redBits, int greenBits, int blueBits) {
+ /* Gradients are drawn as tiled bands */
+ final int bandWidth, bandHeight, bitmapDepth;
+ final byte[] bitmapData;
+ final PaletteData paletteData;
+ /* Select an algorithm depending on the depth of the screen */
+ if (redBits != 0 && greenBits != 0 && blueBits != 0) {
+ paletteData = new PaletteData(0x0000ff00, 0x00ff0000, 0xff000000);
+ bitmapDepth = 32;
+ if (redBits >= 8 && greenBits >= 8 && blueBits >= 8) {
+ /* Precise color */
+ final int steps;
+ if (vertical) {
+ bandWidth = 1;
+ bandHeight = height;
+ steps = bandHeight > 1 ? bandHeight - 1 : 1;
+ } else {
+ bandWidth = width;
+ bandHeight = 1;
+ steps = bandWidth > 1 ? bandWidth - 1 : 1;
+ }
+ final int bytesPerLine = bandWidth * 4;
+ bitmapData = new byte[bandHeight * bytesPerLine];
+ buildPreciseGradientChannel(fromRGB.blue, toRGB.blue, steps, bandWidth, bandHeight, vertical, bitmapData, 0, bytesPerLine);
+ buildPreciseGradientChannel(fromRGB.green, toRGB.green, steps, bandWidth, bandHeight, vertical, bitmapData, 1, bytesPerLine);
+ buildPreciseGradientChannel(fromRGB.red, toRGB.red, steps, bandWidth, bandHeight, vertical, bitmapData, 2, bytesPerLine);
+ } else {
+ /* Dithered color */
+ final int steps;
+ if (vertical) {
+ bandWidth = (width < 8) ? width : 8;
+ bandHeight = height;
+ steps = bandHeight > 1 ? bandHeight - 1 : 1;
+ } else {
+ bandWidth = width;
+ bandHeight = (height < 8) ? height : 8;
+ steps = bandWidth > 1 ? bandWidth - 1 : 1;
+ }
+ final int bytesPerLine = bandWidth * 4;
+ bitmapData = new byte[bandHeight * bytesPerLine];
+ buildDitheredGradientChannel(fromRGB.blue, toRGB.blue, steps, bandWidth, bandHeight, vertical, bitmapData, 0, bytesPerLine, blueBits);
+ buildDitheredGradientChannel(fromRGB.green, toRGB.green, steps, bandWidth, bandHeight, vertical, bitmapData, 1, bytesPerLine, greenBits);
+ buildDitheredGradientChannel(fromRGB.red, toRGB.red, steps, bandWidth, bandHeight, vertical, bitmapData, 2, bytesPerLine, redBits);
+ }
+ } else {
+ /* Dithered two tone */
+ paletteData = new PaletteData(new RGB[] { fromRGB, toRGB });
+ bitmapDepth = 8;
+ final int blendi;
+ if (vertical) {
+ bandWidth = (width < 8) ? width : 8;
+ bandHeight = height;
+ blendi = (bandHeight > 1) ? 0x1040000 / (bandHeight - 1) + 1 : 1;
+ } else {
+ bandWidth = width;
+ bandHeight = (height < 8) ? height : 8;
+ blendi = (bandWidth > 1) ? 0x1040000 / (bandWidth - 1) + 1 : 1;
+ }
+ final int bytesPerLine = (bandWidth + 3) & -4;
+ bitmapData = new byte[bandHeight * bytesPerLine];
+ if (vertical) {
+ for (int dy = 0, blend = 0, dp = 0; dy < bandHeight;
+ ++dy, blend += blendi, dp += bytesPerLine) {
+ for (int dx = 0; dx < bandWidth; ++dx) {
+ bitmapData[dp + dx] = (blend + DITHER_MATRIX[dy & 7][dx]) <
+ 0x1000000 ? (byte)0 : (byte)1;
+ }
+ }
+ } else {
+ for (int dx = 0, blend = 0; dx < bandWidth; ++dx, blend += blendi) {
+ for (int dy = 0, dptr = dx; dy < bandHeight; ++dy, dptr += bytesPerLine) {
+ bitmapData[dptr] = (blend + DITHER_MATRIX[dy][dx & 7]) <
+ 0x1000000 ? (byte)0 : (byte)1;
+ }
+ }
+ }
+ }
+ return new ImageData(bandWidth, bandHeight, bitmapDepth, paletteData, 4, bitmapData);
+}
+
+/*
+ * Fill in gradated values for a color channel
+ */
+static final void buildPreciseGradientChannel(int from, int to, int steps,
+ int bandWidth, int bandHeight, boolean vertical,
+ byte[] bitmapData, int dp, int bytesPerLine) {
+ int val = from << 16;
+ final int inc = ((to << 16) - val) / steps + 1;
+ if (vertical) {
+ for (int dy = 0; dy < bandHeight; ++dy, dp += bytesPerLine) {
+ bitmapData[dp] = (byte)(val >>> 16);
+ val += inc;
+ }
+ } else {
+ for (int dx = 0; dx < bandWidth; ++dx, dp += 4) {
+ bitmapData[dp] = (byte)(val >>> 16);
+ val += inc;
+ }
+ }
+}
+
+/*
+ * Fill in dithered gradated values for a color channel
+ */
+static final void buildDitheredGradientChannel(int from, int to, int steps,
+ int bandWidth, int bandHeight, boolean vertical,
+ byte[] bitmapData, int dp, int bytesPerLine, int bits) {
+ final int mask = 0xff00 >>> bits;
+ int val = from << 16;
+ final int inc = ((to << 16) - val) / steps + 1;
+ if (vertical) {
+ for (int dy = 0; dy < bandHeight; ++dy, dp += bytesPerLine) {
+ for (int dx = 0, dptr = dp; dx < bandWidth; ++dx, dptr += 4) {
+ final int thresh = DITHER_MATRIX[dy & 7][dx] >>> bits;
+ int temp = val + thresh;
+ if (temp > 0xffffff) bitmapData[dptr] = -1;
+ else bitmapData[dptr] = (byte)((temp >>> 16) & mask);
+ }
+ val += inc;
+ }
+ } else {
+ for (int dx = 0; dx < bandWidth; ++dx, dp += 4) {
+ for (int dy = 0, dptr = dp; dy < bandHeight; ++dy, dptr += bytesPerLine) {
+ final int thresh = DITHER_MATRIX[dy][dx & 7] >>> bits;
+ int temp = val + thresh;
+ if (temp > 0xffffff) bitmapData[dptr] = -1;
+ else bitmapData[dptr] = (byte)((temp >>> 16) & mask);
+ }
+ val += inc;
+ }
+ }
+}
+
+/**
+ * Renders a gradient onto a GC.
+ * <p>
+ * This is a GC helper.
+ * </p>
+ *
+ * @param gc the GC to render the gradient onto
+ * @param device the device the GC belongs to
+ * @param x the top-left x coordinate of the region to be filled
+ * @param y the top-left y coordinate of the region to be filled
+ * @param width the width of the region to be filled
+ * @param height the height of the region to be filled
+ * @param vertical if true sweeps from top to bottom, else
+ * sweeps from left to right
+ * @param fromRGB the color to start with
+ * @param toRGB the color to end with
+ * @param redBits the number of significant red bits, 0 for palette modes
+ * @param greenBits the number of significant green bits, 0 for palette modes
+ * @param blueBits the number of significant blue bits, 0 for palette modes
+ */
+static void fillGradientRectangle(GC gc, Device device,
+ int x, int y, int width, int height, boolean vertical,
+ RGB fromRGB, RGB toRGB,
+ int redBits, int greenBits, int blueBits) {
+ /* Create the bitmap and tile it */
+ ImageData band = createGradientBand(width, height, vertical,
+ fromRGB, toRGB, redBits, greenBits, blueBits);
+ Image image = new Image(device, band);
+ if ((band.width == 1) || (band.height == 1)) {
+ gc.drawImage(image, 0, 0, band.width, band.height, x, y, width, height);
+ } else {
+ if (vertical) {
+ for (int dx = 0; dx < width; dx += band.width) {
+ int blitWidth = width - dx;
+ if (blitWidth > band.width) blitWidth = band.width;
+ gc.drawImage(image, 0, 0, blitWidth, band.height, dx + x, y, blitWidth, band.height);
+ }
+ } else {
+ for (int dy = 0; dy < height; dy += band.height) {
+ int blitHeight = height - dy;
+ if (blitHeight > band.height) blitHeight = band.height;
+ gc.drawImage(image, 0, 0, band.width, blitHeight, x, dy + y, band.width, blitHeight);
+ }
+ }
+ }
+ image.dispose();
+}
+
} \ No newline at end of file
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
index e0c9dd4b14..abb4931eb1 100755
--- 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
@@ -1,294 +1,294 @@
-package org.eclipse.swt.graphics;
-
-/*
+package org.eclipse.swt.graphics;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-import java.io.*;
-import java.util.Vector;
-import org.eclipse.swt.*;
-import org.eclipse.swt.internal.Compatibility;
-import org.eclipse.swt.internal.image.*;
-
-/**
- * Instances of this class are used to load images from,
- * and save images to, a file or stream.
- * <p>
- * Currently supported image formats are:
- * </p><ul>
- * <li>BMP (Windows 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 = Compatibility.newFileInputStream(filename);
- return load(stream);
- } catch (IOException e) {
- SWT.error(SWT.ERROR_IO, e);
- } finally {
- try {
- if (stream != null) stream.close();
- } catch (IOException e) {
- // Ignore error
- }
- }
- return null;
-}
-
-/**
- * Saves the image data in this ImageLoader to the specified stream.
- * The format parameter can have one of the following values:
- * <dl>
- * <dt><code>IMAGE_BMP</code></dt>
- * <dd>Windows BMP file format, no compression</dd>
- * <dt><code>IMAGE_BMP_RLE</code></dt>
- * <dd>Windows BMP file format, RLE compression if appropriate</dd>
- * <dt><code>IMAGE_GIF</code></dt>
- * <dd>GIF file format</dd>
- * <dt><code>IMAGE_ICO</code></dt>
- * <dd>Windows ICO file format</dd>
- * <dt><code>IMAGE_JPEG</code></dt>
- * <dd>JPEG file format</dd>
- * <dt><code>IMAGE_PNG</code></dt>
- * <dd>PNG file format</dd>
- * </dl>
- *
- * @param stream the output stream to write the images to
- * @param format the format to write the images in
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the stream is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_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 = Compatibility.newFileOutputStream(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);
- }
-}
-
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+import java.io.*;
+import java.util.Vector;
+import org.eclipse.swt.*;
+import org.eclipse.swt.internal.Compatibility;
+import org.eclipse.swt.internal.image.*;
+
+/**
+ * Instances of this class are used to load images from,
+ * and save images to, a file or stream.
+ * <p>
+ * Currently supported image formats are:
+ * </p><ul>
+ * <li>BMP (Windows 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 = Compatibility.newFileInputStream(filename);
+ return load(stream);
+ } catch (IOException e) {
+ SWT.error(SWT.ERROR_IO, e);
+ } finally {
+ try {
+ if (stream != null) stream.close();
+ } catch (IOException e) {
+ // Ignore error
+ }
+ }
+ return null;
+}
+
+/**
+ * Saves the image data in this ImageLoader to the specified stream.
+ * The format parameter can have one of the following values:
+ * <dl>
+ * <dt><code>IMAGE_BMP</code></dt>
+ * <dd>Windows BMP file format, no compression</dd>
+ * <dt><code>IMAGE_BMP_RLE</code></dt>
+ * <dd>Windows BMP file format, RLE compression if appropriate</dd>
+ * <dt><code>IMAGE_GIF</code></dt>
+ * <dd>GIF file format</dd>
+ * <dt><code>IMAGE_ICO</code></dt>
+ * <dd>Windows ICO file format</dd>
+ * <dt><code>IMAGE_JPEG</code></dt>
+ * <dd>JPEG file format</dd>
+ * <dt><code>IMAGE_PNG</code></dt>
+ * <dd>PNG file format</dd>
+ * </dl>
+ *
+ * @param stream the output stream to write the images to
+ * @param format the format to write the images in
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if the stream is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_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 = Compatibility.newFileOutputStream(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);
+ }
+}
+
}
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
index 012d70d716..10796c777b 100755
--- 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
@@ -1,80 +1,80 @@
-package org.eclipse.swt.graphics;
-
-/*
+package org.eclipse.swt.graphics;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-import org.eclipse.swt.internal.SWTEventObject;
-
-/**
- * Instances of this class are sent as a result of the incremental
- * loading of image data.
- * <p>
- * <b>Notes:</b>
- * </p><ul>
- * <li>The number of events which will be sent when loading images
- * is not constant. It varies by image type, and for JPEG images it
- * varies from image to image.</li>
- * <li>For image sources which contain multiple images, the
- * <code>endOfImage</code> flag in the event will be set to true
- * after each individual image is loaded.</li>
- * </ul>
- *
- * @see ImageLoader
- * @see ImageLoaderListener
- */
-
-public class ImageLoaderEvent extends SWTEventObject {
-
- /**
- * if the <code>endOfImage</code> flag is false, then this is a
- * partially complete copy of the current <code>ImageData</code>,
- * otherwise this is a completely loaded <code>ImageData</code>
- */
- public ImageData imageData;
-
- /**
- * the zero-based count of image data increments -- this is
- * equivalent to the number of events that have been generated
- * while loading a particular image
- */
- public int incrementCount;
-
- /**
- * If this flag is true, then the current image data has been
- * completely loaded, otherwise the image data is only partially
- * loaded, and further ImageLoader events will occur unless an
- * exception is thrown
- */
- public boolean endOfImage;
-
-/**
- * Constructs a new instance of this class given the event source and
- * the values to store in its fields.
- *
- * @param source the ImageLoader that was loading when the event occurred
- * @param imageData the image data for the event
- * @param incrementCount the image data increment for the event
- * @param endOfImage the end of image flag for the event
- */
-public ImageLoaderEvent(ImageLoader source, ImageData imageData, int incrementCount, boolean endOfImage) {
- super(source);
- this.imageData = imageData;
- this.incrementCount = incrementCount;
- this.endOfImage = endOfImage;
-}
-
-/**
- * Returns a string containing a concise, human-readable
- * description of the receiver.
- *
- * @return a string representation of the event
- */
-public String toString () {
- return "ImageLoaderEvent {source=" + source + " imageData=" + imageData + " incrementCount=" + incrementCount + " endOfImage=" + endOfImage + "}";
-}
-
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+import org.eclipse.swt.internal.SWTEventObject;
+
+/**
+ * Instances of this class are sent as a result of the incremental
+ * loading of image data.
+ * <p>
+ * <b>Notes:</b>
+ * </p><ul>
+ * <li>The number of events which will be sent when loading images
+ * is not constant. It varies by image type, and for JPEG images it
+ * varies from image to image.</li>
+ * <li>For image sources which contain multiple images, the
+ * <code>endOfImage</code> flag in the event will be set to true
+ * after each individual image is loaded.</li>
+ * </ul>
+ *
+ * @see ImageLoader
+ * @see ImageLoaderListener
+ */
+
+public class ImageLoaderEvent extends SWTEventObject {
+
+ /**
+ * if the <code>endOfImage</code> flag is false, then this is a
+ * partially complete copy of the current <code>ImageData</code>,
+ * otherwise this is a completely loaded <code>ImageData</code>
+ */
+ public ImageData imageData;
+
+ /**
+ * the zero-based count of image data increments -- this is
+ * equivalent to the number of events that have been generated
+ * while loading a particular image
+ */
+ public int incrementCount;
+
+ /**
+ * If this flag is true, then the current image data has been
+ * completely loaded, otherwise the image data is only partially
+ * loaded, and further ImageLoader events will occur unless an
+ * exception is thrown
+ */
+ public boolean endOfImage;
+
+/**
+ * Constructs a new instance of this class given the event source and
+ * the values to store in its fields.
+ *
+ * @param source the ImageLoader that was loading when the event occurred
+ * @param imageData the image data for the event
+ * @param incrementCount the image data increment for the event
+ * @param endOfImage the end of image flag for the event
+ */
+public ImageLoaderEvent(ImageLoader source, ImageData imageData, int incrementCount, boolean endOfImage) {
+ super(source);
+ this.imageData = imageData;
+ this.incrementCount = incrementCount;
+ this.endOfImage = endOfImage;
+}
+
+/**
+ * Returns a string containing a concise, human-readable
+ * description of the receiver.
+ *
+ * @return a string representation of the event
+ */
+public String toString () {
+ return "ImageLoaderEvent {source=" + source + " imageData=" + imageData + " incrementCount=" + incrementCount + " endOfImage=" + endOfImage + "}";
+}
+
}
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
index b566ec435d..e6097a02fe 100755
--- 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
@@ -1,41 +1,41 @@
-package org.eclipse.swt.graphics;
-
-/*
+package org.eclipse.swt.graphics;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-import org.eclipse.swt.internal.SWTEventListener;
-
-/**
- * Classes which implement this interface provide methods
- * that deal with the incremental loading of image data.
- * <p>
- * After creating an instance of a class that implements
- * this interface it can be added to an image loader using the
- * <code>addImageLoaderListener</code> method and removed using
- * the <code>removeImageLoaderListener</code> method. When
- * image data is either partially or completely loaded, this
- * method will be invoked.
- * </p>
- *
- * @see ImageLoader
- * @see ImageLoaderEvent
- */
-
-public interface ImageLoaderListener extends SWTEventListener {
-
-/**
- * Sent when image data is either partially or completely loaded.
- * <p>
- * The timing of when this method is called varies depending on
- * the format of the image being loaded.
- * </p>
- *
- * @param e an event containing information about the image loading operation
- */
-public void imageDataLoaded(ImageLoaderEvent e);
-
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+import org.eclipse.swt.internal.SWTEventListener;
+
+/**
+ * Classes which implement this interface provide methods
+ * that deal with the incremental loading of image data.
+ * <p>
+ * After creating an instance of a class that implements
+ * this interface it can be added to an image loader using the
+ * <code>addImageLoaderListener</code> method and removed using
+ * the <code>removeImageLoaderListener</code> method. When
+ * image data is either partially or completely loaded, this
+ * method will be invoked.
+ * </p>
+ *
+ * @see ImageLoader
+ * @see ImageLoaderEvent
+ */
+
+public interface ImageLoaderListener extends SWTEventListener {
+
+/**
+ * Sent when image data is either partially or completely loaded.
+ * <p>
+ * The timing of when this method is called varies depending on
+ * the format of the image being loaded.
+ * </p>
+ *
+ * @param e an event containing information about the image loading operation
+ */
+public void imageDataLoaded(ImageLoaderEvent e);
+
}
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
index e8aaf581f4..7ee714d91d 100755
--- 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
@@ -1,207 +1,207 @@
-package org.eclipse.swt.graphics;
-
-/*
+package org.eclipse.swt.graphics;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-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;
-}
-
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+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
index 33eaedd022..7ef2794e7c 100755
--- 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
@@ -1,95 +1,95 @@
-package org.eclipse.swt.graphics;
-
-/*
+package org.eclipse.swt.graphics;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-import org.eclipse.swt.internal.SerializableCompatibility;
-
-/**
- * Instances of this class represent places on the (x, y)
- * coordinate plane.
- * <p>
- * The coordinate space for rectangles and points is considered
- * to have increasing values downward and to the right from its
- * origin making this the normal, computer graphics oriented notion
- * of (x, y) coordinates rather than the strict mathematical one.
- * </p>
- * <p>
- * 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 SerializableCompatibility {
-
- /**
- * 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 + "}";
-}
-
-}
-
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+import org.eclipse.swt.internal.SerializableCompatibility;
+
+/**
+ * Instances of this class represent places on the (x, y)
+ * coordinate plane.
+ * <p>
+ * The coordinate space for rectangles and points is considered
+ * to have increasing values downward and to the right from its
+ * origin making this the normal, computer graphics oriented notion
+ * of (x, y) coordinates rather than the strict mathematical one.
+ * </p>
+ * <p>
+ * 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 SerializableCompatibility {
+
+ /**
+ * 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
index 954846ad27..d8bba1da67 100755
--- 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
@@ -1,110 +1,110 @@
-package org.eclipse.swt.graphics;
-
-/*
+package org.eclipse.swt.graphics;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-import org.eclipse.swt.internal.SerializableCompatibility;
-import org.eclipse.swt.*;
-
-/**
- * Instances of this class are descriptions of colors in
- * terms of the primary additive color model (red, green and
- * blue). A color may be described in terms of the relative
- * intensities of these three primary colors. The brightness
- * of each color is specified by a value in the range 0 to 255,
- * where 0 indicates no color (blackness) and 255 indicates
- * maximum intensity.
- * <p>
- * 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 SerializableCompatibility {
-
- /**
- * the red component of the RGB
- */
- public int red;
-
- /**
- * the green component of the RGB
- */
- public int green;
-
- /**
- * the blue component of the RGB
- */
- public int blue;
-
-/**
- * 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 + "}";
-}
-
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+import org.eclipse.swt.internal.SerializableCompatibility;
+import org.eclipse.swt.*;
+
+/**
+ * Instances of this class are descriptions of colors in
+ * terms of the primary additive color model (red, green and
+ * blue). A color may be described in terms of the relative
+ * intensities of these three primary colors. The brightness
+ * of each color is specified by a value in the range 0 to 255,
+ * where 0 indicates no color (blackness) and 255 indicates
+ * maximum intensity.
+ * <p>
+ * 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 SerializableCompatibility {
+
+ /**
+ * the red component of the RGB
+ */
+ public int red;
+
+ /**
+ * the green component of the RGB
+ */
+ public int green;
+
+ /**
+ * the blue component of the RGB
+ */
+ public int blue;
+
+/**
+ * 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
index 269c532827..708e5ca03b 100755
--- 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
@@ -1,275 +1,275 @@
-package org.eclipse.swt.graphics;
-
-/*
+package org.eclipse.swt.graphics;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-import org.eclipse.swt.internal.SerializableCompatibility;
-import org.eclipse.swt.*;
-
-/**
- * Instances of this class represent rectangular areas in an
- * (x, y) coordinate system. The top left corner of the rectangle
- * is specified by its x and y values, and the extent of the
- * rectangle is specified by its width and height.
- * <p>
- * The coordinate space for rectangles and points is considered
- * to have increasing values downward and to the right from its
- * origin making this the normal, computer graphics oriented notion
- * of (x, y) coordinates rather than the strict mathematical one.
- * </p>
- * <p>
- * 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 SerializableCompatibility {
-
- /**
- * the x coordinate of the rectangle
- */
- public int x;
-
- /**
- * the y coordinate of the rectangle
- */
- public int y;
-
- /**
- * the width of the rectangle
- */
- public int width;
-
- /**
- * the height of the rectangle
- */
- public int height;
-
-/**
- * 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 (
- right < left ? 0 : left,
- bottom < top ? 0 : top,
- right < left ? 0 : right - left,
- bottom < top ? 0 : 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.
- * <p>
- * The union of two rectangles is the smallest single rectangle
- * that completely covers both of the areas covered by the two
- * given rectangles.
- * </p>
- *
- * @param rect the rectangle to perform union with
- * @return the union of the receiver and the argument
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the argument is null</li>
- * </ul>
- *
- * @see #add
- */
-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);
-}
-
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+import org.eclipse.swt.internal.SerializableCompatibility;
+import org.eclipse.swt.*;
+
+/**
+ * Instances of this class represent rectangular areas in an
+ * (x, y) coordinate system. The top left corner of the rectangle
+ * is specified by its x and y values, and the extent of the
+ * rectangle is specified by its width and height.
+ * <p>
+ * The coordinate space for rectangles and points is considered
+ * to have increasing values downward and to the right from its
+ * origin making this the normal, computer graphics oriented notion
+ * of (x, y) coordinates rather than the strict mathematical one.
+ * </p>
+ * <p>
+ * 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 SerializableCompatibility {
+
+ /**
+ * the x coordinate of the rectangle
+ */
+ public int x;
+
+ /**
+ * the y coordinate of the rectangle
+ */
+ public int y;
+
+ /**
+ * the width of the rectangle
+ */
+ public int width;
+
+ /**
+ * the height of the rectangle
+ */
+ public int height;
+
+/**
+ * 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 (
+ right < left ? 0 : left,
+ bottom < top ? 0 : top,
+ right < left ? 0 : right - left,
+ bottom < top ? 0 : 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.
+ * <p>
+ * The union of two rectangles is the smallest single rectangle
+ * that completely covers both of the areas covered by the two
+ * given rectangles.
+ * </p>
+ *
+ * @param rect the rectangle to perform union with
+ * @return the union of the receiver and the argument
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if the argument is null</li>
+ * </ul>
+ *
+ * @see #add
+ */
+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/internal/Callback.java b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal/Callback.java
index 6e02365662..1b9246a8db 100755
--- 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
@@ -1,189 +1,189 @@
-package org.eclipse.swt.internal;
-
-/*
+package org.eclipse.swt.internal;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-/**
- * 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;
-
- /* Load the SWT library */
- static {
- Library.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 platform name.
- *
- * @return the platform name of the currently running SWT
- */
-public static native String getPlatform ();
-
-/**
- * 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);
-}
-
-/**
- * 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);
-
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+/**
+ * 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;
+
+ /* Load the SWT library */
+ static {
+ Library.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 platform name.
+ *
+ * @return the platform name of the currently running SWT
+ */
+public static native String getPlatform ();
+
+/**
+ * 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);
+}
+
+/**
+ * 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
index 9804a02af7..633f2f2539 100755
--- 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
@@ -1,110 +1,110 @@
-package org.eclipse.swt.internal.image;
-
-/*
+package org.eclipse.swt.internal.image;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-import java.io.*;
-import org.eclipse.swt.*;
-import org.eclipse.swt.graphics.*;
-
-public abstract class FileFormat {
- static final String FORMAT_PACKAGE = "org.eclipse.swt.internal.image";
- static final String FORMAT_SUFFIX = "FileFormat";
- static final String[] FORMATS = {"WinBMP", "WinBMP", "GIF", "WinICO", "JPEG", "PNG"};
-
- LEDataInputStream inputStream;
- LEDataOutputStream outputStream;
- ImageLoader loader;
- int compression;
-
-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;
-}
-
-/**
- * Return whether or not the specified input stream
- * represents a supported file format.
- */
-abstract boolean isFileFormat(LEDataInputStream stream);
-
-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);
- boolean isSupported = false;
- for (int i = 1; i < FORMATS.length; i++) {
- if (FORMATS[i] != null) {
- try {
- Class clazz = Class.forName(FORMAT_PACKAGE + '.' + FORMATS[i] + FORMAT_SUFFIX);
- fileFormat = (FileFormat) clazz.newInstance();
- if (fileFormat.isFileFormat(stream)) {
- isSupported = true;
- break;
- }
- } catch (ClassNotFoundException e) {
- FORMATS[i] = null;
- } catch (Exception e) {
- }
- }
- }
- if (!isSupported) SWT.error(SWT.ERROR_UNSUPPORTED_FORMAT);
- fileFormat.loader = loader;
- return fileFormat.loadFromStream(stream);
-}
-
-public static void save(OutputStream os, int format, ImageLoader loader) {
- if (format < 0 || format >= FORMATS.length) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
- if (FORMATS[format] == null) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
-
- /* 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);
- FileFormat fileFormat = null;
- try {
- Class clazz = Class.forName(FORMAT_PACKAGE + '.' + FORMATS[format] + FORMAT_SUFFIX);
- fileFormat = (FileFormat) clazz.newInstance();
- } catch (Exception e) {
- SWT.error(SWT.ERROR_INVALID_ARGUMENT);
- }
- if (format == SWT.IMAGE_BMP_RLE) {
- switch (data.depth) {
- case 8: fileFormat.compression = 1; break;
- case 4: fileFormat.compression = 2; break;
- }
- }
- fileFormat.unloadIntoStream(data, stream);
-}
-
-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);
- }
-}
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+import java.io.*;
+import org.eclipse.swt.*;
+import org.eclipse.swt.graphics.*;
+
+public abstract class FileFormat {
+ static final String FORMAT_PACKAGE = "org.eclipse.swt.internal.image";
+ static final String FORMAT_SUFFIX = "FileFormat";
+ static final String[] FORMATS = {"WinBMP", "WinBMP", "GIF", "WinICO", "JPEG", "PNG"};
+
+ LEDataInputStream inputStream;
+ LEDataOutputStream outputStream;
+ ImageLoader loader;
+ int compression;
+
+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;
+}
+
+/**
+ * Return whether or not the specified input stream
+ * represents a supported file format.
+ */
+abstract boolean isFileFormat(LEDataInputStream stream);
+
+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);
+ boolean isSupported = false;
+ for (int i = 1; i < FORMATS.length; i++) {
+ if (FORMATS[i] != null) {
+ try {
+ Class clazz = Class.forName(FORMAT_PACKAGE + '.' + FORMATS[i] + FORMAT_SUFFIX);
+ fileFormat = (FileFormat) clazz.newInstance();
+ if (fileFormat.isFileFormat(stream)) {
+ isSupported = true;
+ break;
+ }
+ } catch (ClassNotFoundException e) {
+ FORMATS[i] = null;
+ } catch (Exception e) {
+ }
+ }
+ }
+ if (!isSupported) SWT.error(SWT.ERROR_UNSUPPORTED_FORMAT);
+ fileFormat.loader = loader;
+ return fileFormat.loadFromStream(stream);
+}
+
+public static void save(OutputStream os, int format, ImageLoader loader) {
+ if (format < 0 || format >= FORMATS.length) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+ if (FORMATS[format] == null) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+
+ /* 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);
+ FileFormat fileFormat = null;
+ try {
+ Class clazz = Class.forName(FORMAT_PACKAGE + '.' + FORMATS[format] + FORMAT_SUFFIX);
+ fileFormat = (FileFormat) clazz.newInstance();
+ } catch (Exception e) {
+ SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+ }
+ if (format == SWT.IMAGE_BMP_RLE) {
+ switch (data.depth) {
+ case 8: fileFormat.compression = 1; break;
+ case 4: fileFormat.compression = 2; break;
+ }
+ }
+ fileFormat.unloadIntoStream(data, stream);
+}
+
+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
index f63aa72196..8b62ec6fce 100755
--- 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
@@ -1,527 +1,527 @@
-package org.eclipse.swt.internal.image;
-
-/*
+package org.eclipse.swt.internal.image;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-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, defaultDepth;
- 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;
-
- /**
- * Answer a palette containing numGrays
- * shades of gray, ranging from black to white.
- */
- static PaletteData grayRamp(int numGrays) {
- int n = numGrays - 1;
- RGB[] colors = new RGB[numGrays];
- for (int i = 0; i < numGrays; i++) {
- int intensity = (byte)((i * 3) * 256 / n);
- colors[i] = new RGB(intensity, intensity, intensity);
- }
- return new PaletteData(colors);
- }
-
- boolean isFileFormat(LEDataInputStream stream) {
- try {
- byte[] signature = new byte[3];
- stream.read(signature);
- stream.unread(signature);
- return new String(signature).equals("GIF");
- } catch (Exception e) {
- return false;
- }
- }
-
- /**
- * Load the GIF image(s) stored in the input stream.
- * Return an array of ImageData representing the image(s).
- */
- ImageData[] loadFromByteStream() {
- byte[] 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;
- defaultDepth = (bitField & 0x7) + 1;
- PaletteData palette = null;
- if ((bitField & 0x80) != 0) {
- // Global palette.
- sorted = (bitField & 0x8) != 0;
- palette = readPalette(1 << defaultDepth);
- } else {
- // No global palette.
- sorted = false;
- backgroundPixel = -1;
- defaultDepth = bitsPerPixel;
- }
- loader.backgroundPixel = backgroundPixel;
-
- getExtensions();
- int id = readID();
- ImageData[] images = new ImageData[0];
- while (id == GIF_IMAGE_BLOCK_ID) {
- ImageData image = readImageBlock(palette);
- if (loader.hasListeners()) {
- loader.notifyListeners(new ImageLoaderEvent(loader, image, 3, true));
- }
- ImageData[] oldImages = images;
- images = new ImageData[oldImages.length + 1];
- System.arraycopy(oldImages, 0, images, 0, oldImages.length);
- images[images.length - 1] = image;
- try {
- /* Read the 0-byte terminator at the end of the image. */
- id = inputStream.read();
- if (id > 0) {
- /* We read the terminator earlier. */
- inputStream.unread(new byte[] {(byte)id});
- }
- } catch (IOException e) {
- SWT.error(SWT.ERROR_IO, e);
- }
- getExtensions();
- id = readID();
- }
- return images;
- }
-
- /**
- * Read and return the next block or extension identifier from the file.
- */
- int readID() {
- try {
- return inputStream.read();
- } catch (IOException e) {
- SWT.error(SWT.ERROR_IO, e);
- }
- return -1;
- }
-
- /**
- * Read extensions until an image descriptor appears.
- * In the future, if we care about the extensions, they
- * should be properly grouped with the image data before
- * which they appeared. Right now, the interesting parts
- * of some extensions are kept, but the rest is discarded.
- * Throw an error if an error occurs.
- */
- void getExtensions() {
- int id = readID();
- while (id != GIF_IMAGE_BLOCK_ID && id != GIF_TRAILER_ID && id > 0) {
- if (id == GIF_EXTENSION_BLOCK_ID) {
- readExtension();
- } else {
- SWT.error(SWT.ERROR_INVALID_IMAGE);
- }
- id = readID();
- }
- if (id == GIF_IMAGE_BLOCK_ID || id == GIF_TRAILER_ID) {
- try {
- inputStream.unread(new byte[] {(byte)id});
- } catch (IOException e) {
- SWT.error(SWT.ERROR_IO, e);
- }
- }
- }
-
- /**
- * Read a control extension.
- * Return the extension block data.
- */
- byte[] readExtension() {
- int extensionID = readID();
- if (extensionID == GIF_COMMENT_BLOCK_ID)
- return readCommentExtension();
- if (extensionID == GIF_PLAIN_TEXT_BLOCK_ID)
- return readPlainTextExtension();
- if (extensionID == GIF_GRAPHICS_CONTROL_BLOCK_ID)
- return readGraphicsControlExtension();
- if (extensionID == GIF_APPLICATION_EXTENSION_BLOCK_ID)
- return readApplicationExtension();
- // Otherwise, we don't recognize the block. If the
- // field size is correct, we can just skip over
- // the block contents.
- try {
- int extSize = inputStream.read();
- if (extSize < 0) {
- SWT.error(SWT.ERROR_INVALID_IMAGE);
- }
- byte[] ext = new byte[extSize];
- inputStream.read(ext, 0, extSize);
- return ext;
- } catch (IOException e) {
- SWT.error(SWT.ERROR_IO, e);
- return null;
- }
- }
-
- /**
- * We have just read the Comment extension identifier
- * from the input stream. Read in the rest of the comment
- * and return it. GIF comment blocks are variable size.
- */
- byte[] readCommentExtension() {
- try {
- byte[] comment = new byte[0];
- byte[] block = new byte[255];
- int size = inputStream.read();
- while ((size > 0) && (inputStream.read(block, 0, size) != -1)) {
- byte[] oldComment = comment;
- comment = new byte[oldComment.length + size];
- System.arraycopy(oldComment, 0, comment, 0, oldComment.length);
- System.arraycopy(block, 0, comment, oldComment.length, size);
- size = inputStream.read();
- }
- return comment;
- } catch (Exception e) {
- SWT.error(SWT.ERROR_IO, e);
- return null;
- }
- }
-
- /**
- * We have just read the PlainText extension identifier
- * from the input stream. Read in the plain text info and text,
- * and return the text. GIF plain text blocks are variable size.
- */
- byte[] readPlainTextExtension() {
- try {
- // Read size of block = 0x0C.
- inputStream.read();
- // Read the text information (x, y, width, height, colors).
- byte[] info = new byte[12];
- inputStream.read(info);
- // Read the text.
- byte[] text = new byte[0];
- byte[] block = new byte[255];
- int size = inputStream.read();
- while ((size > 0) && (inputStream.read(block, 0, size) != -1)) {
- byte[] oldText = text;
- text = new byte[oldText.length + size];
- System.arraycopy(oldText, 0, text, 0, oldText.length);
- System.arraycopy(block, 0, text, oldText.length, size);
- size = inputStream.read();
- }
- return text;
- } catch (Exception e) {
- SWT.error(SWT.ERROR_IO, e);
- return null;
- }
- }
-
- /**
- * We have just read the GraphicsControl extension identifier
- * from the input stream. Read in the control information, store
- * it, and return it.
- */
- byte[] readGraphicsControlExtension() {
- try {
- // Read size of block = 0x04.
- inputStream.read();
- // Read the control block.
- byte[] controlBlock = new byte[4];
- inputStream.read(controlBlock);
- byte bitField = controlBlock[0];
- // Store the user input field.
- userInput = (bitField & 0x02) != 0;
- // Store the disposal method.
- disposalMethod = (bitField >> 2) & 0x07;
- // Store the delay time.
- delayTime = (controlBlock[1] & 0xFF) | ((controlBlock[2] & 0xFF) << 8);
- // Store the transparent color.
- if ((bitField & 0x01) != 0) {
- int colorIndex = controlBlock[3] & 0xFF;
- /* Work around: a customer has a GIF that specifies an
- * invalid color index that is larger than the number
- * of entries in the palette. Detect this case, and
- * ignore the specified color index. */
- if (colorIndex <= 1 << defaultDepth) {
- transparentPixel = colorIndex;
- }
- } 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(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);
- }
- }
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+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, defaultDepth;
+ 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;
+
+ /**
+ * Answer a palette containing numGrays
+ * shades of gray, ranging from black to white.
+ */
+ static PaletteData grayRamp(int numGrays) {
+ int n = numGrays - 1;
+ RGB[] colors = new RGB[numGrays];
+ for (int i = 0; i < numGrays; i++) {
+ int intensity = (byte)((i * 3) * 256 / n);
+ colors[i] = new RGB(intensity, intensity, intensity);
+ }
+ return new PaletteData(colors);
+ }
+
+ boolean isFileFormat(LEDataInputStream stream) {
+ try {
+ byte[] signature = new byte[3];
+ stream.read(signature);
+ stream.unread(signature);
+ return new String(signature).equals("GIF");
+ } catch (Exception e) {
+ return false;
+ }
+ }
+
+ /**
+ * Load the GIF image(s) stored in the input stream.
+ * Return an array of ImageData representing the image(s).
+ */
+ ImageData[] loadFromByteStream() {
+ byte[] 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;
+ defaultDepth = (bitField & 0x7) + 1;
+ PaletteData palette = null;
+ if ((bitField & 0x80) != 0) {
+ // Global palette.
+ sorted = (bitField & 0x8) != 0;
+ palette = readPalette(1 << defaultDepth);
+ } else {
+ // No global palette.
+ sorted = false;
+ backgroundPixel = -1;
+ defaultDepth = bitsPerPixel;
+ }
+ loader.backgroundPixel = backgroundPixel;
+
+ getExtensions();
+ int id = readID();
+ ImageData[] images = new ImageData[0];
+ while (id == GIF_IMAGE_BLOCK_ID) {
+ ImageData image = readImageBlock(palette);
+ if (loader.hasListeners()) {
+ loader.notifyListeners(new ImageLoaderEvent(loader, image, 3, true));
+ }
+ ImageData[] oldImages = images;
+ images = new ImageData[oldImages.length + 1];
+ System.arraycopy(oldImages, 0, images, 0, oldImages.length);
+ images[images.length - 1] = image;
+ try {
+ /* Read the 0-byte terminator at the end of the image. */
+ id = inputStream.read();
+ if (id > 0) {
+ /* We read the terminator earlier. */
+ inputStream.unread(new byte[] {(byte)id});
+ }
+ } catch (IOException e) {
+ SWT.error(SWT.ERROR_IO, e);
+ }
+ getExtensions();
+ id = readID();
+ }
+ return images;
+ }
+
+ /**
+ * Read and return the next block or extension identifier from the file.
+ */
+ int readID() {
+ try {
+ return inputStream.read();
+ } catch (IOException e) {
+ SWT.error(SWT.ERROR_IO, e);
+ }
+ return -1;
+ }
+
+ /**
+ * Read extensions until an image descriptor appears.
+ * In the future, if we care about the extensions, they
+ * should be properly grouped with the image data before
+ * which they appeared. Right now, the interesting parts
+ * of some extensions are kept, but the rest is discarded.
+ * Throw an error if an error occurs.
+ */
+ void getExtensions() {
+ int id = readID();
+ while (id != GIF_IMAGE_BLOCK_ID && id != GIF_TRAILER_ID && id > 0) {
+ if (id == GIF_EXTENSION_BLOCK_ID) {
+ readExtension();
+ } else {
+ SWT.error(SWT.ERROR_INVALID_IMAGE);
+ }
+ id = readID();
+ }
+ if (id == GIF_IMAGE_BLOCK_ID || id == GIF_TRAILER_ID) {
+ try {
+ inputStream.unread(new byte[] {(byte)id});
+ } catch (IOException e) {
+ SWT.error(SWT.ERROR_IO, e);
+ }
+ }
+ }
+
+ /**
+ * Read a control extension.
+ * Return the extension block data.
+ */
+ byte[] readExtension() {
+ int extensionID = readID();
+ if (extensionID == GIF_COMMENT_BLOCK_ID)
+ return readCommentExtension();
+ if (extensionID == GIF_PLAIN_TEXT_BLOCK_ID)
+ return readPlainTextExtension();
+ if (extensionID == GIF_GRAPHICS_CONTROL_BLOCK_ID)
+ return readGraphicsControlExtension();
+ if (extensionID == GIF_APPLICATION_EXTENSION_BLOCK_ID)
+ return readApplicationExtension();
+ // Otherwise, we don't recognize the block. If the
+ // field size is correct, we can just skip over
+ // the block contents.
+ try {
+ int extSize = inputStream.read();
+ if (extSize < 0) {
+ SWT.error(SWT.ERROR_INVALID_IMAGE);
+ }
+ byte[] ext = new byte[extSize];
+ inputStream.read(ext, 0, extSize);
+ return ext;
+ } catch (IOException e) {
+ SWT.error(SWT.ERROR_IO, e);
+ return null;
+ }
+ }
+
+ /**
+ * We have just read the Comment extension identifier
+ * from the input stream. Read in the rest of the comment
+ * and return it. GIF comment blocks are variable size.
+ */
+ byte[] readCommentExtension() {
+ try {
+ byte[] comment = new byte[0];
+ byte[] block = new byte[255];
+ int size = inputStream.read();
+ while ((size > 0) && (inputStream.read(block, 0, size) != -1)) {
+ byte[] oldComment = comment;
+ comment = new byte[oldComment.length + size];
+ System.arraycopy(oldComment, 0, comment, 0, oldComment.length);
+ System.arraycopy(block, 0, comment, oldComment.length, size);
+ size = inputStream.read();
+ }
+ return comment;
+ } catch (Exception e) {
+ SWT.error(SWT.ERROR_IO, e);
+ return null;
+ }
+ }
+
+ /**
+ * We have just read the PlainText extension identifier
+ * from the input stream. Read in the plain text info and text,
+ * and return the text. GIF plain text blocks are variable size.
+ */
+ byte[] readPlainTextExtension() {
+ try {
+ // Read size of block = 0x0C.
+ inputStream.read();
+ // Read the text information (x, y, width, height, colors).
+ byte[] info = new byte[12];
+ inputStream.read(info);
+ // Read the text.
+ byte[] text = new byte[0];
+ byte[] block = new byte[255];
+ int size = inputStream.read();
+ while ((size > 0) && (inputStream.read(block, 0, size) != -1)) {
+ byte[] oldText = text;
+ text = new byte[oldText.length + size];
+ System.arraycopy(oldText, 0, text, 0, oldText.length);
+ System.arraycopy(block, 0, text, oldText.length, size);
+ size = inputStream.read();
+ }
+ return text;
+ } catch (Exception e) {
+ SWT.error(SWT.ERROR_IO, e);
+ return null;
+ }
+ }
+
+ /**
+ * We have just read the GraphicsControl extension identifier
+ * from the input stream. Read in the control information, store
+ * it, and return it.
+ */
+ byte[] readGraphicsControlExtension() {
+ try {
+ // Read size of block = 0x04.
+ inputStream.read();
+ // Read the control block.
+ byte[] controlBlock = new byte[4];
+ inputStream.read(controlBlock);
+ byte bitField = controlBlock[0];
+ // Store the user input field.
+ userInput = (bitField & 0x02) != 0;
+ // Store the disposal method.
+ disposalMethod = (bitField >> 2) & 0x07;
+ // Store the delay time.
+ delayTime = (controlBlock[1] & 0xFF) | ((controlBlock[2] & 0xFF) << 8);
+ // Store the transparent color.
+ if ((bitField & 0x01) != 0) {
+ int colorIndex = controlBlock[3] & 0xFF;
+ /* Work around: a customer has a GIF that specifies an
+ * invalid color index that is larger than the number
+ * of entries in the palette. Detect this case, and
+ * ignore the specified color index. */
+ if (colorIndex <= 1 << defaultDepth) {
+ transparentPixel = colorIndex;
+ }
+ } 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(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
index 9598910863..82046aef0e 100755
--- 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
@@ -1,24 +1,24 @@
-package org.eclipse.swt.internal.image;
-
-/*
+package org.eclipse.swt.internal.image;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-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;
- }
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+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
index 6fe82d3ecb..f0ce9f436b 100755
--- 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
@@ -1,19 +1,19 @@
-package org.eclipse.swt.internal.image;
-
-/*
+package org.eclipse.swt.internal.image;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-final class JPEGArithmeticConditioningTable extends JPEGVariableSizeSegment {
-
- public JPEGArithmeticConditioningTable(LEDataInputStream byteStream) {
- super(byteStream);
- }
-
- public int signature() {
- return JPEGFileFormat.DAC;
- }
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+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
index 7348adeea8..e5bfffa4d8 100755
--- 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
@@ -1,23 +1,23 @@
-package org.eclipse.swt.internal.image;
-
-/*
+package org.eclipse.swt.internal.image;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-final class JPEGComment extends JPEGVariableSizeSegment {
-
- public JPEGComment(byte[] reference) {
- super(reference);
- }
-
- public JPEGComment(LEDataInputStream byteStream) {
- super(byteStream);
- }
-
- public int signature() {
- return JPEGFileFormat.COM;
- }
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+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
index 354ed570e8..a70ca5f919 100755
--- 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
@@ -1,27 +1,27 @@
-package org.eclipse.swt.internal.image;
-
-/*
+package org.eclipse.swt.internal.image;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-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;
- }
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+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
index 407ec66238..1370110464 100755
--- 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
@@ -1,1892 +1,1892 @@
-package org.eclipse.swt.internal.image;
-
-/*
+package org.eclipse.swt.internal.image;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-import org.eclipse.swt.*;
-import org.eclipse.swt.graphics.*;
-import java.io.*;
-
-final class JPEGFileFormat extends FileFormat {
- int restartInterval;
- JPEGFrameHeader frameHeader;
- int imageWidth, imageHeight;
- int interleavedMcuCols, interleavedMcuRows;
- int maxV, maxH;
- boolean progressive;
- int samplePrecision;
- int nComponents;
- int[][] frameComponents;
- int[] componentIds;
- byte[][] imageComponents;
- int[] dataUnit;
- int[][][] dataUnits;
- int[] precedingDCs;
- JPEGScanHeader scanHeader;
- byte[] dataBuffer;
- int currentBitCount;
- int bufferCurrentPosition;
- int restartsToGo;
- int nextRestartNumber;
- 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;
- /* JFIF Component Constants */
- public static final int ID_Y = 1 - 1;
- public static final int ID_CB = 2 - 1;
- public static final int ID_CR = 3 - 1;
-
- public static final 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;
- imageComponents = new byte[nComponents][];
- for (int i = 0; i < nComponents; i++) {
- frameComponent = frameComponents[componentIds[i]];
- imageComponents[i] = new byte[frameComponent[CW] * frameComponent[CH]];
- }
- frameComponent = frameComponents[componentIds[ID_Y]];
- for (int yPos = 0; yPos < srcHeight; yPos++) {
- int srcOfs = yPos * srcWidth;
- int dstOfs = yPos * frameComponent[CW];
- System.arraycopy(dataYComp, srcOfs, imageComponents[ID_Y], dstOfs, srcWidth);
- }
- frameComponent = frameComponents[componentIds[ID_CB]];
- for (int yPos = 0; yPos < srcHeight / maxV; yPos++) {
- int destRowIndex = yPos * frameComponent[CW];
- for (int xPos = 0; xPos < srcWidth / maxH; xPos++) {
- int sum = 0;
- for (int iv = 0; iv < maxV; iv++) {
- int srcIndex = (yPos * maxV + iv) * srcWidth + (xPos * maxH);
- for (int ih = 0; ih < maxH; ih++) {
- sum += dataCbComp[srcIndex + ih] & 0xFF;
- }
- }
- imageComponents[ID_CB][destRowIndex + xPos] = (byte)(sum / vhFactor);
- }
- }
- frameComponent = frameComponents[componentIds[ID_CR]];
- for (int yPos = 0; yPos < srcHeight / maxV; yPos++) {
- int destRowIndex = yPos * frameComponent[CW];
- for (int xPos = 0; xPos < srcWidth / maxH; xPos++) {
- int sum = 0;
- for (int iv = 0; iv < maxV; iv++) {
- int srcIndex = (yPos * maxV + iv) * srcWidth + (xPos * maxH);
- for (int ih = 0; ih < maxH; ih++) {
- sum += dataCrComp[srcIndex + ih] & 0xFF;
- }
- }
- imageComponents[ID_CR][destRowIndex + xPos] = (byte)(sum / vhFactor);
- }
- }
- for (int iComp = 0; iComp < nComponents; iComp++) {
- byte[] imageComponent = imageComponents[iComp];
- frameComponent = frameComponents[componentIds[iComp]];
- int hFactor = frameComponent[HI];
- int vFactor = frameComponent[VI];
- int componentWidth = frameComponent[CW];
- int componentHeight = frameComponent[CH];
- int compressedWidth = srcWidth / (maxH / hFactor);
- int compressedHeight = srcHeight / (maxV / vFactor);
- if (compressedWidth < componentWidth) {
- int delta = componentWidth - compressedWidth;
- for (int yPos = 0; yPos < compressedHeight; yPos++) {
- int dstOfs = ((yPos + 1) * componentWidth - delta);
- int dataValue = imageComponent[dstOfs - 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:
- case 32:
- convertMultiRGBToYCbCr(image);
- return;
- default:
- SWT.error(SWT.ERROR_UNSUPPORTED_DEPTH);
- }
- return;
-}
-void convertMultiRGBToYCbCr(ImageData image) {
- int srcWidth = image.width;
- int srcHeight = image.height;
- int bSize = srcWidth * srcHeight;
- byte[] dataYComp = new byte[bSize];
- byte[] dataCbComp = new byte[bSize];
- byte[] dataCrComp = new byte[bSize];
- PaletteData palette = image.palette;
- int[] buffer = new int[srcWidth];
- if (palette.isDirect) {
- int redMask = palette.redMask;
- int greenMask = palette.greenMask;
- int blueMask = palette.blueMask;
- int redShift = palette.redShift;
- int greenShift = palette.greenShift;
- int blueShift = palette.blueShift;
- for (int yPos = 0; yPos < srcHeight; yPos++) {
- image.getPixels(0, yPos, srcWidth, buffer, 0);
- int dstRowIndex = yPos * srcWidth;
- for (int xPos = 0; xPos < srcWidth; xPos++) {
- int pixel = buffer[xPos];
- int dstDataIndex = dstRowIndex + xPos;
- int r = pixel & redMask;
- r = (redShift < 0) ? r >>> -redShift : r << redShift;
- int g = pixel & greenMask;
- g = (greenShift < 0) ? g >>> -greenShift : g << greenShift;
- int b = pixel & blueMask;
- b = (blueShift < 0) ? b >>> -blueShift : b << blueShift;
- dataYComp[dstDataIndex] = (byte)((RYTable[r] + GYTable[g] + BYTable[b]) / 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 = frameComponents[componentIds[ID_Y]][CW];
- int bytesPerLine = (((imageWidth * 8 + 7) / 8) + 3) / 4 * 4;
- byte[] data = new byte[bytesPerLine * imageHeight];
- byte[] yComp = imageComponents[ID_Y];
- int destIndex = 0;
- for (int i = 0; i < imageHeight; i++) {
- int srcIndex = i * compWidth;
- for (int j = 0; j < bytesPerLine; j++) {
- int y = yComp[srcIndex] & 0xFF;
- if (y < 0) {
- y = 0;
- } else {
- if (y > 255) y = 255;
- }
- if (j >= imageWidth) {
- y = 0;
- }
- data[destIndex] = (byte)y;
- srcIndex++;
- destIndex++;
- }
- }
- return data;
-}
-byte[] convertYCbCrToRGB() {
- /**
- * Convert existing image components into an RGB format.
- * YCbCr is defined per CCIR 601-1, except that Cb and Cr are
- * normalized to the range 0..MAXJSAMPLE rather than -0.5 .. 0.5.
- * The conversion equations to be implemented are therefore
- * R = Y + 1.40200 * Cr
- * G = Y - 0.34414 * Cb - 0.71414 * Cr
- * B = Y + 1.77200 * Cb
- * where Cb and Cr represent the incoming values less MAXJSAMPLE/2.
- * (These numbers are derived from TIFF 6.0 section 21, dated 3-June-92.)
- *
- * To avoid floating-point arithmetic, we represent the fractional constants
- * as integers scaled up by 2^16 (about 4 digits precision); we have to divide
- * the products by 2^16, with appropriate rounding, to get the correct answer.
- * Notice that Y, being an integral input, does not contribute any fraction
- * so it need not participate in the rounding.
- *
- * For even more speed, we avoid doing any multiplications in the inner loop
- * by precalculating the constants times Cb and Cr for all possible values.
- * For 8-bit JSAMPLEs this is very reasonable (only 256 entries per table);
- * for 12-bit samples it is still acceptable. It's not very reasonable for
- * 16-bit samples, but if you want lossless storage you shouldn't be changing
- * colorspace anyway.
- * The Cr=>R and Cb=>B values can be rounded to integers in advance; the
- * values for the G calculation are left scaled up, since we must add them
- * together before rounding.
- */
- int bSize = imageWidth * imageHeight * nComponents;
- byte[] rgbData = new byte[bSize];
- int destIndex = 0;
- expandImageComponents();
- byte[] yComp = imageComponents[ID_Y];
- byte[] cbComp = imageComponents[ID_CB];
- byte[] crComp = imageComponents[ID_CR];
- int compWidth = frameComponents[componentIds[ID_Y]][CW];
- for (int v = 0; v < imageHeight; v++) {
- int srcIndex = v * compWidth;
- for (int i = 0; i < imageWidth; i++) {
- int y = yComp[srcIndex] & 0xFF;
- int cb = cbComp[srcIndex] & 0xFF;
- int cr = crComp[srcIndex] & 0xFF;
- int r = y + CrRTable[cr];
- int g = y + ((CbGTable[cb] + CrGTable[cr]) / 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[componentIds[iComp]];
- JPEGHuffmanTable acTable = acHuffmanTables[sParams[AC]];
- int k = 1;
- while (k < 64) {
- int rs = decodeUsingTable(acTable);
- int r = rs >> 4;
- int s = rs & 0xF;
- if (s == 0) {
- if (r == 15) {
- k += 16;
- } else {
- break;
- }
- } else {
- k += r;
- int bits = receive(s);
- dataUnit[ZigZag8x8[k]] = extendBy(bits, s);
- k++;
- }
- }
-}
-void decodeACFirstCoefficients(int[] dataUnit, int iComp, int start, int end, int approxBit) {
- if (eobrun > 0) {
- eobrun--;
- return;
- }
- int[] sParams = scanHeader.componentParameters[componentIds[iComp]];
- JPEGHuffmanTable acTable = acHuffmanTables[sParams[AC]];
- int k = start;
- while (k <= end) {
- int rs = decodeUsingTable(acTable);
- int r = rs >> 4;
- int s = rs & 0xF;
- if (s == 0) {
- if (r == 15) {
- k += 16;
- } else {
- eobrun = (1 << r) + receive(r) - 1;
- break;
- }
- } else {
- k += r;
- int bits = receive(s);
- dataUnit[ZigZag8x8[k]] = extendBy(bits, s) << approxBit;
- k++;
- }
- }
-}
-void decodeACRefineCoefficients(int[] dataUnit, int iComp, int start, int end, int approxBit) {
- int[] sParams = scanHeader.componentParameters[componentIds[iComp]];
- JPEGHuffmanTable acTable = acHuffmanTables[sParams[AC]];
- int k = start;
- while (k <= end) {
- if (eobrun > 0) {
- while (k <= end) {
- int zzIndex = ZigZag8x8[k];
- if (dataUnit[zzIndex] != 0) {
- dataUnit[zzIndex] = refineAC(dataUnit[zzIndex], approxBit);
- }
- k++;
- }
- eobrun--;
- } else {
- int rs = decodeUsingTable(acTable);
- int r = rs >> 4;
- int s = rs & 0xF;
- if (s == 0) {
- if (r == 15) {
- int zeros = 0;
- while (zeros < 16 && k <= end) {
- int zzIndex = ZigZag8x8[k];
- if (dataUnit[zzIndex] != 0) {
- dataUnit[zzIndex] = refineAC(dataUnit[zzIndex], approxBit);
- } else {
- zeros++;
- }
- k++;
- }
- } else {
- eobrun = (1 << r) + receive(r);
- }
- } else {
- int bit = receive(s);
- int zeros = 0;
- int zzIndex = ZigZag8x8[k];
- while ((zeros < r || dataUnit[zzIndex] != 0) && k <= end) {
- if (dataUnit[zzIndex] != 0) {
- dataUnit[zzIndex] = refineAC(dataUnit[zzIndex], approxBit);
- } else {
- zeros++;
- }
- k++;
- zzIndex = ZigZag8x8[k];
- }
- if (bit != 0) {
- dataUnit[zzIndex] = 1 << approxBit;
- } else {
- dataUnit[zzIndex] = -1 << approxBit;
- }
- k++;
- }
- }
- }
-}
-int refineAC(int ac, int approxBit) {
- if (ac > 0) {
- int bit = nextBit();
- if (bit != 0) {
- ac = 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[componentIds[iComp]];
- JPEGHuffmanTable dcTable = dcHuffmanTables[sParams[DC]];
- int lastDC = 0;
- if (progressive && !first) {
- int bit = nextBit();
- lastDC = dataUnit[0] + (bit << approxBit);
- } else {
- lastDC = precedingDCs[iComp];
- int nBits = decodeUsingTable(dcTable);
- if (nBits != 0) {
- int bits = receive(nBits);
- int diff = extendBy(bits, nBits);
- lastDC = lastDC + diff;
- precedingDCs[iComp] = lastDC;
- }
- if (progressive) {
- lastDC = lastDC << approxBit;
- }
- }
- dataUnit[0] = lastDC;
-}
-void dequantize(int[] dataUnit, int iComp) {
- int[] qTable = quantizationTables[frameComponents[componentIds[iComp]][TQI]];
- for (int i = 0; i < dataUnit.length; i++) {
- int zzIndex = ZigZag8x8[i];
- dataUnit[zzIndex] = dataUnit[zzIndex] * qTable[i];
- }
-}
-byte[] decodeImageComponents() {
- 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[componentIds[scanComponent]] == null) {
- scanComponent++;
- }
- int[] frameComponent = frameComponents[componentIds[scanComponent]];
- int hi = frameComponent[HI];
- int vi = frameComponent[VI];
- if (nComponentsInScan == 1) {
- hi = 1;
- vi = 1;
- }
- int compWidth = frameComponent[CW];
- for (int ivi = 0; ivi < vi; ivi++) {
- for (int ihi = 0; ihi < hi; ihi++) {
- if (progressive) {
- // Progressive: First scan - create a new data unit.
- // Subsequent scans - refine the existing data unit.
- int index = (ymcu * vi + ivi) * compWidth + xmcu * hi + ihi;
- dataUnit = dataUnits[scanComponent][index];
- if (dataUnit == null) {
- dataUnit = new int[64];
- dataUnits[scanComponent][index] = dataUnit;
- }
- } else {
- // Sequential: Clear and reuse the data unit buffer.
- for (int i = 0; i < dataUnit.length; i++) {
- dataUnit[i] = 0;
- }
- }
- if (!progressive || scanHeader.isDCProgressiveScan()) {
- decodeDCCoefficient(dataUnit, scanComponent, first, approxBit);
- }
- if (!progressive) {
- decodeACCoefficients(dataUnit, scanComponent);
- } else {
- if (scanHeader.isACProgressiveScan()) {
- if (first) {
- decodeACFirstCoefficients(dataUnit, scanComponent, start, end, approxBit);
- } else {
- decodeACRefineCoefficients(dataUnit, scanComponent, start, end, approxBit);
- }
- }
- if (loader.hasListeners()) {
- // Dequantization, IDCT, up-sampling and color conversion
- // are done on a copy of the coefficient data in order to
- // display the image incrementally.
- int[] temp = dataUnit;
- dataUnit = new int[64];
- System.arraycopy(temp, 0, dataUnit, 0, 64);
- }
- }
- if (!progressive || (progressive && loader.hasListeners())) {
- dequantize(dataUnit, scanComponent);
- inverseDCT(dataUnit);
- storeData(dataUnit, scanComponent, xmcu, ymcu, hi, ihi, vi, ivi);
- }
- }
- }
- }
-}
-void decodeScan() {
- if (progressive && !scanHeader.verifyProgressiveScan()) {
- SWT.error(SWT.ERROR_INVALID_IMAGE);
- }
- int nComponentsInScan = scanHeader.getNumberOfImageComponents();
- int mcuRowsInScan = interleavedMcuRows;
- int mcusPerRow = interleavedMcuCols;
- if (nComponentsInScan == 1) {
- // Non-interleaved.
- int scanComponent = 0;
- while (scanHeader.componentParameters[componentIds[scanComponent]] == null) {
- scanComponent++;
- }
- int[] frameComponent = frameComponents[componentIds[scanComponent]];
- int hi = frameComponent[HI];
- int vi = frameComponent[VI];
- int mcuWidth = DCTSIZE * maxH / hi;
- int mcuHeight = DCTSIZE * maxV / vi;
- mcusPerRow = (imageWidth + mcuWidth - 1) / mcuWidth;
- mcuRowsInScan = (imageHeight + mcuHeight - 1) / mcuHeight;
- }
- boolean first = scanHeader.isFirstScan();
- int start = scanHeader.getStartOfSpectralSelection();
- int end = scanHeader.getEndOfSpectralSelection();
- int approxBit = scanHeader.getApproxBitPositionLow();
- restartsToGo = restartInterval;
- nextRestartNumber = 0;
- for (int ymcu = 0; ymcu < mcuRowsInScan; ymcu++) {
- for (int xmcu = 0; xmcu < mcusPerRow; xmcu++) {
- if (restartInterval != 0) {
- if (restartsToGo == 0) processRestartInterval();
- restartsToGo--;
- }
- decodeMCUAtXAndY(xmcu, ymcu, nComponentsInScan, first, start, end, approxBit);
- }
- }
-}
-int decodeUsingTable(JPEGHuffmanTable huffmanTable) {
- int i = 0;
- int[] maxCodes = huffmanTable.getDhMaxCodes();
- int[] minCodes = huffmanTable.getDhMinCodes();
- int[] valPtrs = huffmanTable.getDhValPtrs();
- int[] huffVals = huffmanTable.getDhValues();
- int code = nextBit();
- while (code > maxCodes[i]) {
- code = code * 2 + nextBit();
- i++;
- }
- int j = valPtrs[i];
- 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[componentIds[iComp]];
- int hi = frameComponent[HI];
- int vi = frameComponent[VI];
- for (int ivi = 0; ivi < vi; ivi++) {
- for (int ihi = 0; ihi < hi; ihi++) {
- extractData(dataUnit, iComp, xmcu, ymcu, ihi, ivi);
- forwardDCT(dataUnit);
- quantizeData(dataUnit, iComp);
- encodeDCCoefficients(dataUnit, iComp);
- encodeACCoefficients(dataUnit, iComp);
- }
- }
- }
-}
-void encodeScan() {
- for (int ymcu = 0; ymcu < interleavedMcuRows; ymcu++) {
- for (int xmcu = 0; xmcu < interleavedMcuCols; xmcu++) {
- encodeMCUAtXAndY(xmcu, ymcu);
- }
- }
- if (currentBitCount != 0) {
- emitByte((byte)currentByte);
- }
- resetOutputBuffer();
-}
-void expandImageComponents() {
- for (int iComp = 0; iComp < nComponents; iComp++) {
- int[] frameComponent = frameComponents[componentIds[iComp]];
- int hi = frameComponent[HI];
- int vi = frameComponent[VI];
- int upH = maxH / hi;
- int upV = maxV / vi;
- if ((upH * upV) > 1) {
- byte[] component = imageComponents[iComp];
- int compWidth = frameComponent[CW];
- int compHeight = frameComponent[CH];
- int upCompWidth = compWidth * upH;
- int upCompHeight = compHeight * upV;
- 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[componentIds[iComp]];
- int hi = frameComponent[HI];
- int vi = frameComponent[VI];
- int compWidth = frameComponent[CW];
- int srcIndex = ((ymcu * vi + ivi) * compWidth * DCTSIZE) + ((xmcu * hi + ihi) * DCTSIZE);
- int destIndex = 0;
- for (int i = 0; i < DCTSIZE; i++) {
- for (int col = 0; col < DCTSIZE; col++) {
- dataUnit[destIndex] = (compImage[srcIndex + col] & 0xFF) - 128;
- destIndex++;
- }
- srcIndex += compWidth;
- }
-}
-void forwardDCT(int[] dataUnit) {
- for (int row = 0; row < 8; row++) {
- int rIndex = row * DCTSIZE;
- int tmp0 = dataUnit[rIndex] + dataUnit[rIndex + 7];
- int tmp7 = dataUnit[rIndex] - dataUnit[rIndex + 7];
- int tmp1 = dataUnit[rIndex + 1] + dataUnit[rIndex + 6];
- int tmp6 = dataUnit[rIndex + 1] - dataUnit[rIndex + 6];
- int tmp2 = dataUnit[rIndex + 2] + dataUnit[rIndex + 5];
- int tmp5 = dataUnit[rIndex + 2] - dataUnit[rIndex + 5];
- int tmp3 = dataUnit[rIndex + 3] + dataUnit[rIndex + 4];
- int tmp4 = dataUnit[rIndex + 3] - dataUnit[rIndex + 4];
-
- /**
- * Even part per LL&M figure 1 --- note that published figure
- * is faulty; rotator 'sqrt(2)*c1' should be 'sqrt(2)*c6'.
- */
- int tmp10 = tmp0 + tmp3;
- int tmp13 = tmp0 - tmp3;
- int tmp11 = tmp1 + tmp2;
- int tmp12 = tmp1 - tmp2;
-
- dataUnit[rIndex] = (tmp10 + tmp11) * 4;
- dataUnit[rIndex + 4] = (tmp10 - tmp11) * 4;
-
- int z1 = (tmp12 + tmp13) * FIX_0_541196100;
- int 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 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;
- }
- }
-}
-boolean isFileFormat(LEDataInputStream stream) {
- try {
- JPEGStartOfImage soi = new JPEGStartOfImage(stream);
- stream.unread(soi.reference);
- return soi.verify(); // we no longer check for appN
- } catch (Exception e) {
- return false;
- }
-}
-boolean isZeroInColumn(int[] dataUnit, int col) {
- return (dataUnit[col + 8] + 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;
- componentIds = frameHeader.componentIdentifiers;
- imageComponents = new byte[nComponents][];
- if (progressive) {
- // Progressive jpeg: need to keep all of the data units.
- dataUnits = new int[nComponents][][];
- } else {
- // Sequential jpeg: only need one data unit.
- dataUnit = new int[8 * 8];
- }
- for (int i = 0; i < nComponents; i++) {
- int[] frameComponent = frameComponents[componentIds[i]];
- int bufferSize = frameComponent[CW] * frameComponent[CH];
- imageComponents[i] = new byte[bufferSize];
- if (progressive) {
- dataUnits[i] = new int[bufferSize][];
- }
- }
-
- /* Process the tables preceding the scan header. */
- processTables();
-
- /* Start of Scan. */
- scanHeader = new JPEGScanHeader(inputStream);
- if (!scanHeader.verify()) SWT.error(SWT.ERROR_INVALID_IMAGE);
-
- /* Process scan(s) and further tables until EOI. */
- int progressiveScanCount = 0;
- boolean done = false;
- while(!done) {
- resetInputBuffer();
- precedingDCs = new int[4];
- decodeScan();
- if (progressive && loader.hasListeners()) {
- ImageData imageData = createImageData();
- loader.notifyListeners(new ImageLoaderEvent(loader, imageData, progressiveScanCount, false));
- progressiveScanCount++;
- }
-
- /* Unread any buffered data before looking for tables again. */
- int delta = 512 - bufferCurrentPosition - 1;
- if (delta > 0) {
- byte[] unreadBuffer = new byte[delta];
- System.arraycopy(dataBuffer, bufferCurrentPosition + 1, unreadBuffer, 0, delta);
- try {
- inputStream.unread(unreadBuffer);
- } catch (IOException e) {
- SWT.error(SWT.ERROR_IO, e);
- }
- }
-
- /* Process the tables preceding the next scan header. */
- JPEGSegment jpegSegment = processTables();
- if (jpegSegment == null || jpegSegment.getSegmentMarker() == EOI) {
- done = true;
- } else {
- scanHeader = new JPEGScanHeader(inputStream);
- if (!scanHeader.verify()) SWT.error(SWT.ERROR_INVALID_IMAGE);
- }
- }
-
- if (progressive) {
- for (int ymcu = 0; ymcu < interleavedMcuRows; ymcu++) {
- for (int xmcu = 0; xmcu < interleavedMcuCols; xmcu++) {
- for (int iComp = 0; iComp < nComponents; iComp++) {
- int[] frameComponent = frameComponents[componentIds[iComp]];
- int hi = frameComponent[HI];
- int vi = frameComponent[VI];
- int compWidth = frameComponent[CW];
- for (int ivi = 0; ivi < vi; ivi++) {
- for (int ihi = 0; ihi < hi; ihi++) {
- int index = (ymcu * vi + ivi) * compWidth + xmcu * hi + ihi;
- dataUnit = dataUnits[iComp][index];
- dequantize(dataUnit, iComp);
- inverseDCT(dataUnit);
- storeData(dataUnit, iComp, xmcu, ymcu, hi, ihi, vi, ivi);
- }
- }
- }
- }
- }
- }
- 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[componentIds[iComp]][TQI]];
- for (int i = 0; i < dataUnit.length; i++) {
- int zzIndex = ZigZag8x8[i];
- int data = dataUnit[zzIndex];
- int absData = data < 0 ? 0 - data : data;
- int qValue = qTable[i];
- int q2 = qValue / 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[componentIds[iComp]];
- int compWidth = frameComponent[CW];
- int destIndex = ((ymcu * vi + ivi) * compWidth * DCTSIZE) + ((xmcu * hi + ihi) * DCTSIZE);
- int srcIndex = 0;
- for (int i = 0; i < DCTSIZE; i++) {
- for (int col = 0; col < DCTSIZE; col++) {
- int x = dataUnit[srcIndex] + 128;
- if (x < 0) {
- x = 0;
- } else {
- if (x > 255) x = 255;
- }
- compImage[destIndex + col] = (byte)x;
- srcIndex++;
- }
- destIndex += compWidth;
- }
-}
-void unloadIntoByteStream(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.componentIdentifiers = new int[] {0, 1, 2};
- frameHeader.initializeContents();
- if (!frameHeader.writeToStream(outputStream)) {
- SWT.error(SWT.ERROR_IO);
- }
- frameComponents = frameParams;
- componentIds = frameHeader.componentIdentifiers;
- maxH = frameHeader.getMaxHFactor();
- maxV = frameHeader.getMaxVFactor();
- int mcuWidth = maxH * DCTSIZE;
- int mcuHeight = maxV * DCTSIZE;
- interleavedMcuCols = (imageWidth + mcuWidth - 1) / mcuWidth;
- interleavedMcuRows = (imageHeight + mcuHeight - 1) / mcuHeight;
- acHuffmanTables = new JPEGHuffmanTable[4];
- dcHuffmanTables = new JPEGHuffmanTable[4];
- JPEGHuffmanTable[] dhtTables = new JPEGHuffmanTable[] {
- JPEGHuffmanTable.getDefaultDCLuminanceTable(),
- JPEGHuffmanTable.getDefaultDCChrominanceTable(),
- JPEGHuffmanTable.getDefaultACLuminanceTable(),
- JPEGHuffmanTable.getDefaultACChrominanceTable()
- };
- for (int i = 0; i < dhtTables.length; i++) {
- JPEGHuffmanTable dhtTable = dhtTables[i];
- if (!dhtTable.writeToStream(outputStream)) {
- SWT.error(SWT.ERROR_IO);
- }
- JPEGHuffmanTable[] allTables = dhtTable.getAllTables();
- for (int j = 0; j < allTables.length; j++) {
- JPEGHuffmanTable huffmanTable = allTables[j];
- if (huffmanTable.getTableClass() == 0) {
- dcHuffmanTables[huffmanTable.getTableIdentifier()] = huffmanTable;
- } else {
- acHuffmanTables[huffmanTable.getTableIdentifier()] = huffmanTable;
- }
- }
- }
- precedingDCs = new int[4];
- scanHeader = new JPEGScanHeader(new byte[14]);
- scanHeader.setSegmentMarker(SOS);
- scanHeader.setSegmentLength(scanLength);
- scanHeader.setNumberOfImageComponents(nComponents);
- scanHeader.setStartOfSpectralSelection(0);
- scanHeader.setEndOfSpectralSelection(63);
- scanHeader.componentParameters = scanParams;
- scanHeader.initializeContents();
- if (!scanHeader.writeToStream(outputStream)) {
- SWT.error(SWT.ERROR_IO);
- }
- convertImageToYCbCr(image);
- resetOutputBuffer();
- currentByte = 0;
- currentBitCount = 0;
- encodeScan();
- if (!new JPEGEndOfImage().writeToStream(outputStream)) {
- SWT.error(SWT.ERROR_IO);
- }
-}
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+import org.eclipse.swt.*;
+import org.eclipse.swt.graphics.*;
+import java.io.*;
+
+final class JPEGFileFormat extends FileFormat {
+ int restartInterval;
+ JPEGFrameHeader frameHeader;
+ int imageWidth, imageHeight;
+ int interleavedMcuCols, interleavedMcuRows;
+ int maxV, maxH;
+ boolean progressive;
+ int samplePrecision;
+ int nComponents;
+ int[][] frameComponents;
+ int[] componentIds;
+ byte[][] imageComponents;
+ int[] dataUnit;
+ int[][][] dataUnits;
+ int[] precedingDCs;
+ JPEGScanHeader scanHeader;
+ byte[] dataBuffer;
+ int currentBitCount;
+ int bufferCurrentPosition;
+ int restartsToGo;
+ int nextRestartNumber;
+ 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;
+ /* JFIF Component Constants */
+ public static final int ID_Y = 1 - 1;
+ public static final int ID_CB = 2 - 1;
+ public static final int ID_CR = 3 - 1;
+
+ public static final 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;
+ imageComponents = new byte[nComponents][];
+ for (int i = 0; i < nComponents; i++) {
+ frameComponent = frameComponents[componentIds[i]];
+ imageComponents[i] = new byte[frameComponent[CW] * frameComponent[CH]];
+ }
+ frameComponent = frameComponents[componentIds[ID_Y]];
+ for (int yPos = 0; yPos < srcHeight; yPos++) {
+ int srcOfs = yPos * srcWidth;
+ int dstOfs = yPos * frameComponent[CW];
+ System.arraycopy(dataYComp, srcOfs, imageComponents[ID_Y], dstOfs, srcWidth);
+ }
+ frameComponent = frameComponents[componentIds[ID_CB]];
+ for (int yPos = 0; yPos < srcHeight / maxV; yPos++) {
+ int destRowIndex = yPos * frameComponent[CW];
+ for (int xPos = 0; xPos < srcWidth / maxH; xPos++) {
+ int sum = 0;
+ for (int iv = 0; iv < maxV; iv++) {
+ int srcIndex = (yPos * maxV + iv) * srcWidth + (xPos * maxH);
+ for (int ih = 0; ih < maxH; ih++) {
+ sum += dataCbComp[srcIndex + ih] & 0xFF;
+ }
+ }
+ imageComponents[ID_CB][destRowIndex + xPos] = (byte)(sum / vhFactor);
+ }
+ }
+ frameComponent = frameComponents[componentIds[ID_CR]];
+ for (int yPos = 0; yPos < srcHeight / maxV; yPos++) {
+ int destRowIndex = yPos * frameComponent[CW];
+ for (int xPos = 0; xPos < srcWidth / maxH; xPos++) {
+ int sum = 0;
+ for (int iv = 0; iv < maxV; iv++) {
+ int srcIndex = (yPos * maxV + iv) * srcWidth + (xPos * maxH);
+ for (int ih = 0; ih < maxH; ih++) {
+ sum += dataCrComp[srcIndex + ih] & 0xFF;
+ }
+ }
+ imageComponents[ID_CR][destRowIndex + xPos] = (byte)(sum / vhFactor);
+ }
+ }
+ for (int iComp = 0; iComp < nComponents; iComp++) {
+ byte[] imageComponent = imageComponents[iComp];
+ frameComponent = frameComponents[componentIds[iComp]];
+ int hFactor = frameComponent[HI];
+ int vFactor = frameComponent[VI];
+ int componentWidth = frameComponent[CW];
+ int componentHeight = frameComponent[CH];
+ int compressedWidth = srcWidth / (maxH / hFactor);
+ int compressedHeight = srcHeight / (maxV / vFactor);
+ if (compressedWidth < componentWidth) {
+ int delta = componentWidth - compressedWidth;
+ for (int yPos = 0; yPos < compressedHeight; yPos++) {
+ int dstOfs = ((yPos + 1) * componentWidth - delta);
+ int dataValue = imageComponent[dstOfs - 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:
+ case 32:
+ convertMultiRGBToYCbCr(image);
+ return;
+ default:
+ SWT.error(SWT.ERROR_UNSUPPORTED_DEPTH);
+ }
+ return;
+}
+void convertMultiRGBToYCbCr(ImageData image) {
+ int srcWidth = image.width;
+ int srcHeight = image.height;
+ int bSize = srcWidth * srcHeight;
+ byte[] dataYComp = new byte[bSize];
+ byte[] dataCbComp = new byte[bSize];
+ byte[] dataCrComp = new byte[bSize];
+ PaletteData palette = image.palette;
+ int[] buffer = new int[srcWidth];
+ if (palette.isDirect) {
+ int redMask = palette.redMask;
+ int greenMask = palette.greenMask;
+ int blueMask = palette.blueMask;
+ int redShift = palette.redShift;
+ int greenShift = palette.greenShift;
+ int blueShift = palette.blueShift;
+ for (int yPos = 0; yPos < srcHeight; yPos++) {
+ image.getPixels(0, yPos, srcWidth, buffer, 0);
+ int dstRowIndex = yPos * srcWidth;
+ for (int xPos = 0; xPos < srcWidth; xPos++) {
+ int pixel = buffer[xPos];
+ int dstDataIndex = dstRowIndex + xPos;
+ int r = pixel & redMask;
+ r = (redShift < 0) ? r >>> -redShift : r << redShift;
+ int g = pixel & greenMask;
+ g = (greenShift < 0) ? g >>> -greenShift : g << greenShift;
+ int b = pixel & blueMask;
+ b = (blueShift < 0) ? b >>> -blueShift : b << blueShift;
+ dataYComp[dstDataIndex] = (byte)((RYTable[r] + GYTable[g] + BYTable[b]) / 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 = frameComponents[componentIds[ID_Y]][CW];
+ int bytesPerLine = (((imageWidth * 8 + 7) / 8) + 3) / 4 * 4;
+ byte[] data = new byte[bytesPerLine * imageHeight];
+ byte[] yComp = imageComponents[ID_Y];
+ int destIndex = 0;
+ for (int i = 0; i < imageHeight; i++) {
+ int srcIndex = i * compWidth;
+ for (int j = 0; j < bytesPerLine; j++) {
+ int y = yComp[srcIndex] & 0xFF;
+ if (y < 0) {
+ y = 0;
+ } else {
+ if (y > 255) y = 255;
+ }
+ if (j >= imageWidth) {
+ y = 0;
+ }
+ data[destIndex] = (byte)y;
+ srcIndex++;
+ destIndex++;
+ }
+ }
+ return data;
+}
+byte[] convertYCbCrToRGB() {
+ /**
+ * Convert existing image components into an RGB format.
+ * YCbCr is defined per CCIR 601-1, except that Cb and Cr are
+ * normalized to the range 0..MAXJSAMPLE rather than -0.5 .. 0.5.
+ * The conversion equations to be implemented are therefore
+ * R = Y + 1.40200 * Cr
+ * G = Y - 0.34414 * Cb - 0.71414 * Cr
+ * B = Y + 1.77200 * Cb
+ * where Cb and Cr represent the incoming values less MAXJSAMPLE/2.
+ * (These numbers are derived from TIFF 6.0 section 21, dated 3-June-92.)
+ *
+ * To avoid floating-point arithmetic, we represent the fractional constants
+ * as integers scaled up by 2^16 (about 4 digits precision); we have to divide
+ * the products by 2^16, with appropriate rounding, to get the correct answer.
+ * Notice that Y, being an integral input, does not contribute any fraction
+ * so it need not participate in the rounding.
+ *
+ * For even more speed, we avoid doing any multiplications in the inner loop
+ * by precalculating the constants times Cb and Cr for all possible values.
+ * For 8-bit JSAMPLEs this is very reasonable (only 256 entries per table);
+ * for 12-bit samples it is still acceptable. It's not very reasonable for
+ * 16-bit samples, but if you want lossless storage you shouldn't be changing
+ * colorspace anyway.
+ * The Cr=>R and Cb=>B values can be rounded to integers in advance; the
+ * values for the G calculation are left scaled up, since we must add them
+ * together before rounding.
+ */
+ int bSize = imageWidth * imageHeight * nComponents;
+ byte[] rgbData = new byte[bSize];
+ int destIndex = 0;
+ expandImageComponents();
+ byte[] yComp = imageComponents[ID_Y];
+ byte[] cbComp = imageComponents[ID_CB];
+ byte[] crComp = imageComponents[ID_CR];
+ int compWidth = frameComponents[componentIds[ID_Y]][CW];
+ for (int v = 0; v < imageHeight; v++) {
+ int srcIndex = v * compWidth;
+ for (int i = 0; i < imageWidth; i++) {
+ int y = yComp[srcIndex] & 0xFF;
+ int cb = cbComp[srcIndex] & 0xFF;
+ int cr = crComp[srcIndex] & 0xFF;
+ int r = y + CrRTable[cr];
+ int g = y + ((CbGTable[cb] + CrGTable[cr]) / 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[componentIds[iComp]];
+ JPEGHuffmanTable acTable = acHuffmanTables[sParams[AC]];
+ int k = 1;
+ while (k < 64) {
+ int rs = decodeUsingTable(acTable);
+ int r = rs >> 4;
+ int s = rs & 0xF;
+ if (s == 0) {
+ if (r == 15) {
+ k += 16;
+ } else {
+ break;
+ }
+ } else {
+ k += r;
+ int bits = receive(s);
+ dataUnit[ZigZag8x8[k]] = extendBy(bits, s);
+ k++;
+ }
+ }
+}
+void decodeACFirstCoefficients(int[] dataUnit, int iComp, int start, int end, int approxBit) {
+ if (eobrun > 0) {
+ eobrun--;
+ return;
+ }
+ int[] sParams = scanHeader.componentParameters[componentIds[iComp]];
+ JPEGHuffmanTable acTable = acHuffmanTables[sParams[AC]];
+ int k = start;
+ while (k <= end) {
+ int rs = decodeUsingTable(acTable);
+ int r = rs >> 4;
+ int s = rs & 0xF;
+ if (s == 0) {
+ if (r == 15) {
+ k += 16;
+ } else {
+ eobrun = (1 << r) + receive(r) - 1;
+ break;
+ }
+ } else {
+ k += r;
+ int bits = receive(s);
+ dataUnit[ZigZag8x8[k]] = extendBy(bits, s) << approxBit;
+ k++;
+ }
+ }
+}
+void decodeACRefineCoefficients(int[] dataUnit, int iComp, int start, int end, int approxBit) {
+ int[] sParams = scanHeader.componentParameters[componentIds[iComp]];
+ JPEGHuffmanTable acTable = acHuffmanTables[sParams[AC]];
+ int k = start;
+ while (k <= end) {
+ if (eobrun > 0) {
+ while (k <= end) {
+ int zzIndex = ZigZag8x8[k];
+ if (dataUnit[zzIndex] != 0) {
+ dataUnit[zzIndex] = refineAC(dataUnit[zzIndex], approxBit);
+ }
+ k++;
+ }
+ eobrun--;
+ } else {
+ int rs = decodeUsingTable(acTable);
+ int r = rs >> 4;
+ int s = rs & 0xF;
+ if (s == 0) {
+ if (r == 15) {
+ int zeros = 0;
+ while (zeros < 16 && k <= end) {
+ int zzIndex = ZigZag8x8[k];
+ if (dataUnit[zzIndex] != 0) {
+ dataUnit[zzIndex] = refineAC(dataUnit[zzIndex], approxBit);
+ } else {
+ zeros++;
+ }
+ k++;
+ }
+ } else {
+ eobrun = (1 << r) + receive(r);
+ }
+ } else {
+ int bit = receive(s);
+ int zeros = 0;
+ int zzIndex = ZigZag8x8[k];
+ while ((zeros < r || dataUnit[zzIndex] != 0) && k <= end) {
+ if (dataUnit[zzIndex] != 0) {
+ dataUnit[zzIndex] = refineAC(dataUnit[zzIndex], approxBit);
+ } else {
+ zeros++;
+ }
+ k++;
+ zzIndex = ZigZag8x8[k];
+ }
+ if (bit != 0) {
+ dataUnit[zzIndex] = 1 << approxBit;
+ } else {
+ dataUnit[zzIndex] = -1 << approxBit;
+ }
+ k++;
+ }
+ }
+ }
+}
+int refineAC(int ac, int approxBit) {
+ if (ac > 0) {
+ int bit = nextBit();
+ if (bit != 0) {
+ ac = 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[componentIds[iComp]];
+ JPEGHuffmanTable dcTable = dcHuffmanTables[sParams[DC]];
+ int lastDC = 0;
+ if (progressive && !first) {
+ int bit = nextBit();
+ lastDC = dataUnit[0] + (bit << approxBit);
+ } else {
+ lastDC = precedingDCs[iComp];
+ int nBits = decodeUsingTable(dcTable);
+ if (nBits != 0) {
+ int bits = receive(nBits);
+ int diff = extendBy(bits, nBits);
+ lastDC = lastDC + diff;
+ precedingDCs[iComp] = lastDC;
+ }
+ if (progressive) {
+ lastDC = lastDC << approxBit;
+ }
+ }
+ dataUnit[0] = lastDC;
+}
+void dequantize(int[] dataUnit, int iComp) {
+ int[] qTable = quantizationTables[frameComponents[componentIds[iComp]][TQI]];
+ for (int i = 0; i < dataUnit.length; i++) {
+ int zzIndex = ZigZag8x8[i];
+ dataUnit[zzIndex] = dataUnit[zzIndex] * qTable[i];
+ }
+}
+byte[] decodeImageComponents() {
+ 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[componentIds[scanComponent]] == null) {
+ scanComponent++;
+ }
+ int[] frameComponent = frameComponents[componentIds[scanComponent]];
+ int hi = frameComponent[HI];
+ int vi = frameComponent[VI];
+ if (nComponentsInScan == 1) {
+ hi = 1;
+ vi = 1;
+ }
+ int compWidth = frameComponent[CW];
+ for (int ivi = 0; ivi < vi; ivi++) {
+ for (int ihi = 0; ihi < hi; ihi++) {
+ if (progressive) {
+ // Progressive: First scan - create a new data unit.
+ // Subsequent scans - refine the existing data unit.
+ int index = (ymcu * vi + ivi) * compWidth + xmcu * hi + ihi;
+ dataUnit = dataUnits[scanComponent][index];
+ if (dataUnit == null) {
+ dataUnit = new int[64];
+ dataUnits[scanComponent][index] = dataUnit;
+ }
+ } else {
+ // Sequential: Clear and reuse the data unit buffer.
+ for (int i = 0; i < dataUnit.length; i++) {
+ dataUnit[i] = 0;
+ }
+ }
+ if (!progressive || scanHeader.isDCProgressiveScan()) {
+ decodeDCCoefficient(dataUnit, scanComponent, first, approxBit);
+ }
+ if (!progressive) {
+ decodeACCoefficients(dataUnit, scanComponent);
+ } else {
+ if (scanHeader.isACProgressiveScan()) {
+ if (first) {
+ decodeACFirstCoefficients(dataUnit, scanComponent, start, end, approxBit);
+ } else {
+ decodeACRefineCoefficients(dataUnit, scanComponent, start, end, approxBit);
+ }
+ }
+ if (loader.hasListeners()) {
+ // Dequantization, IDCT, up-sampling and color conversion
+ // are done on a copy of the coefficient data in order to
+ // display the image incrementally.
+ int[] temp = dataUnit;
+ dataUnit = new int[64];
+ System.arraycopy(temp, 0, dataUnit, 0, 64);
+ }
+ }
+ if (!progressive || (progressive && loader.hasListeners())) {
+ dequantize(dataUnit, scanComponent);
+ inverseDCT(dataUnit);
+ storeData(dataUnit, scanComponent, xmcu, ymcu, hi, ihi, vi, ivi);
+ }
+ }
+ }
+ }
+}
+void decodeScan() {
+ if (progressive && !scanHeader.verifyProgressiveScan()) {
+ SWT.error(SWT.ERROR_INVALID_IMAGE);
+ }
+ int nComponentsInScan = scanHeader.getNumberOfImageComponents();
+ int mcuRowsInScan = interleavedMcuRows;
+ int mcusPerRow = interleavedMcuCols;
+ if (nComponentsInScan == 1) {
+ // Non-interleaved.
+ int scanComponent = 0;
+ while (scanHeader.componentParameters[componentIds[scanComponent]] == null) {
+ scanComponent++;
+ }
+ int[] frameComponent = frameComponents[componentIds[scanComponent]];
+ int hi = frameComponent[HI];
+ int vi = frameComponent[VI];
+ int mcuWidth = DCTSIZE * maxH / hi;
+ int mcuHeight = DCTSIZE * maxV / vi;
+ mcusPerRow = (imageWidth + mcuWidth - 1) / mcuWidth;
+ mcuRowsInScan = (imageHeight + mcuHeight - 1) / mcuHeight;
+ }
+ boolean first = scanHeader.isFirstScan();
+ int start = scanHeader.getStartOfSpectralSelection();
+ int end = scanHeader.getEndOfSpectralSelection();
+ int approxBit = scanHeader.getApproxBitPositionLow();
+ restartsToGo = restartInterval;
+ nextRestartNumber = 0;
+ for (int ymcu = 0; ymcu < mcuRowsInScan; ymcu++) {
+ for (int xmcu = 0; xmcu < mcusPerRow; xmcu++) {
+ if (restartInterval != 0) {
+ if (restartsToGo == 0) processRestartInterval();
+ restartsToGo--;
+ }
+ decodeMCUAtXAndY(xmcu, ymcu, nComponentsInScan, first, start, end, approxBit);
+ }
+ }
+}
+int decodeUsingTable(JPEGHuffmanTable huffmanTable) {
+ int i = 0;
+ int[] maxCodes = huffmanTable.getDhMaxCodes();
+ int[] minCodes = huffmanTable.getDhMinCodes();
+ int[] valPtrs = huffmanTable.getDhValPtrs();
+ int[] huffVals = huffmanTable.getDhValues();
+ int code = nextBit();
+ while (code > maxCodes[i]) {
+ code = code * 2 + nextBit();
+ i++;
+ }
+ int j = valPtrs[i];
+ 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[componentIds[iComp]];
+ int hi = frameComponent[HI];
+ int vi = frameComponent[VI];
+ for (int ivi = 0; ivi < vi; ivi++) {
+ for (int ihi = 0; ihi < hi; ihi++) {
+ extractData(dataUnit, iComp, xmcu, ymcu, ihi, ivi);
+ forwardDCT(dataUnit);
+ quantizeData(dataUnit, iComp);
+ encodeDCCoefficients(dataUnit, iComp);
+ encodeACCoefficients(dataUnit, iComp);
+ }
+ }
+ }
+}
+void encodeScan() {
+ for (int ymcu = 0; ymcu < interleavedMcuRows; ymcu++) {
+ for (int xmcu = 0; xmcu < interleavedMcuCols; xmcu++) {
+ encodeMCUAtXAndY(xmcu, ymcu);
+ }
+ }
+ if (currentBitCount != 0) {
+ emitByte((byte)currentByte);
+ }
+ resetOutputBuffer();
+}
+void expandImageComponents() {
+ for (int iComp = 0; iComp < nComponents; iComp++) {
+ int[] frameComponent = frameComponents[componentIds[iComp]];
+ int hi = frameComponent[HI];
+ int vi = frameComponent[VI];
+ int upH = maxH / hi;
+ int upV = maxV / vi;
+ if ((upH * upV) > 1) {
+ byte[] component = imageComponents[iComp];
+ int compWidth = frameComponent[CW];
+ int compHeight = frameComponent[CH];
+ int upCompWidth = compWidth * upH;
+ int upCompHeight = compHeight * upV;
+ 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[componentIds[iComp]];
+ int hi = frameComponent[HI];
+ int vi = frameComponent[VI];
+ int compWidth = frameComponent[CW];
+ int srcIndex = ((ymcu * vi + ivi) * compWidth * DCTSIZE) + ((xmcu * hi + ihi) * DCTSIZE);
+ int destIndex = 0;
+ for (int i = 0; i < DCTSIZE; i++) {
+ for (int col = 0; col < DCTSIZE; col++) {
+ dataUnit[destIndex] = (compImage[srcIndex + col] & 0xFF) - 128;
+ destIndex++;
+ }
+ srcIndex += compWidth;
+ }
+}
+void forwardDCT(int[] dataUnit) {
+ for (int row = 0; row < 8; row++) {
+ int rIndex = row * DCTSIZE;
+ int tmp0 = dataUnit[rIndex] + dataUnit[rIndex + 7];
+ int tmp7 = dataUnit[rIndex] - dataUnit[rIndex + 7];
+ int tmp1 = dataUnit[rIndex + 1] + dataUnit[rIndex + 6];
+ int tmp6 = dataUnit[rIndex + 1] - dataUnit[rIndex + 6];
+ int tmp2 = dataUnit[rIndex + 2] + dataUnit[rIndex + 5];
+ int tmp5 = dataUnit[rIndex + 2] - dataUnit[rIndex + 5];
+ int tmp3 = dataUnit[rIndex + 3] + dataUnit[rIndex + 4];
+ int tmp4 = dataUnit[rIndex + 3] - dataUnit[rIndex + 4];
+
+ /**
+ * Even part per LL&M figure 1 --- note that published figure
+ * is faulty; rotator 'sqrt(2)*c1' should be 'sqrt(2)*c6'.
+ */
+ int tmp10 = tmp0 + tmp3;
+ int tmp13 = tmp0 - tmp3;
+ int tmp11 = tmp1 + tmp2;
+ int tmp12 = tmp1 - tmp2;
+
+ dataUnit[rIndex] = (tmp10 + tmp11) * 4;
+ dataUnit[rIndex + 4] = (tmp10 - tmp11) * 4;
+
+ int z1 = (tmp12 + tmp13) * FIX_0_541196100;
+ int 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 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;
+ }
+ }
+}
+boolean isFileFormat(LEDataInputStream stream) {
+ try {
+ JPEGStartOfImage soi = new JPEGStartOfImage(stream);
+ stream.unread(soi.reference);
+ return soi.verify(); // we no longer check for appN
+ } catch (Exception e) {
+ return false;
+ }
+}
+boolean isZeroInColumn(int[] dataUnit, int col) {
+ return (dataUnit[col + 8] + 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;
+ componentIds = frameHeader.componentIdentifiers;
+ imageComponents = new byte[nComponents][];
+ if (progressive) {
+ // Progressive jpeg: need to keep all of the data units.
+ dataUnits = new int[nComponents][][];
+ } else {
+ // Sequential jpeg: only need one data unit.
+ dataUnit = new int[8 * 8];
+ }
+ for (int i = 0; i < nComponents; i++) {
+ int[] frameComponent = frameComponents[componentIds[i]];
+ int bufferSize = frameComponent[CW] * frameComponent[CH];
+ imageComponents[i] = new byte[bufferSize];
+ if (progressive) {
+ dataUnits[i] = new int[bufferSize][];
+ }
+ }
+
+ /* Process the tables preceding the scan header. */
+ processTables();
+
+ /* Start of Scan. */
+ scanHeader = new JPEGScanHeader(inputStream);
+ if (!scanHeader.verify()) SWT.error(SWT.ERROR_INVALID_IMAGE);
+
+ /* Process scan(s) and further tables until EOI. */
+ int progressiveScanCount = 0;
+ boolean done = false;
+ while(!done) {
+ resetInputBuffer();
+ precedingDCs = new int[4];
+ decodeScan();
+ if (progressive && loader.hasListeners()) {
+ ImageData imageData = createImageData();
+ loader.notifyListeners(new ImageLoaderEvent(loader, imageData, progressiveScanCount, false));
+ progressiveScanCount++;
+ }
+
+ /* Unread any buffered data before looking for tables again. */
+ int delta = 512 - bufferCurrentPosition - 1;
+ if (delta > 0) {
+ byte[] unreadBuffer = new byte[delta];
+ System.arraycopy(dataBuffer, bufferCurrentPosition + 1, unreadBuffer, 0, delta);
+ try {
+ inputStream.unread(unreadBuffer);
+ } catch (IOException e) {
+ SWT.error(SWT.ERROR_IO, e);
+ }
+ }
+
+ /* Process the tables preceding the next scan header. */
+ JPEGSegment jpegSegment = processTables();
+ if (jpegSegment == null || jpegSegment.getSegmentMarker() == EOI) {
+ done = true;
+ } else {
+ scanHeader = new JPEGScanHeader(inputStream);
+ if (!scanHeader.verify()) SWT.error(SWT.ERROR_INVALID_IMAGE);
+ }
+ }
+
+ if (progressive) {
+ for (int ymcu = 0; ymcu < interleavedMcuRows; ymcu++) {
+ for (int xmcu = 0; xmcu < interleavedMcuCols; xmcu++) {
+ for (int iComp = 0; iComp < nComponents; iComp++) {
+ int[] frameComponent = frameComponents[componentIds[iComp]];
+ int hi = frameComponent[HI];
+ int vi = frameComponent[VI];
+ int compWidth = frameComponent[CW];
+ for (int ivi = 0; ivi < vi; ivi++) {
+ for (int ihi = 0; ihi < hi; ihi++) {
+ int index = (ymcu * vi + ivi) * compWidth + xmcu * hi + ihi;
+ dataUnit = dataUnits[iComp][index];
+ dequantize(dataUnit, iComp);
+ inverseDCT(dataUnit);
+ storeData(dataUnit, iComp, xmcu, ymcu, hi, ihi, vi, ivi);
+ }
+ }
+ }
+ }
+ }
+ }
+ 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[componentIds[iComp]][TQI]];
+ for (int i = 0; i < dataUnit.length; i++) {
+ int zzIndex = ZigZag8x8[i];
+ int data = dataUnit[zzIndex];
+ int absData = data < 0 ? 0 - data : data;
+ int qValue = qTable[i];
+ int q2 = qValue / 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[componentIds[iComp]];
+ int compWidth = frameComponent[CW];
+ int destIndex = ((ymcu * vi + ivi) * compWidth * DCTSIZE) + ((xmcu * hi + ihi) * DCTSIZE);
+ int srcIndex = 0;
+ for (int i = 0; i < DCTSIZE; i++) {
+ for (int col = 0; col < DCTSIZE; col++) {
+ int x = dataUnit[srcIndex] + 128;
+ if (x < 0) {
+ x = 0;
+ } else {
+ if (x > 255) x = 255;
+ }
+ compImage[destIndex + col] = (byte)x;
+ srcIndex++;
+ }
+ destIndex += compWidth;
+ }
+}
+void unloadIntoByteStream(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.componentIdentifiers = new int[] {0, 1, 2};
+ frameHeader.initializeContents();
+ if (!frameHeader.writeToStream(outputStream)) {
+ SWT.error(SWT.ERROR_IO);
+ }
+ frameComponents = frameParams;
+ componentIds = frameHeader.componentIdentifiers;
+ maxH = frameHeader.getMaxHFactor();
+ maxV = frameHeader.getMaxVFactor();
+ int mcuWidth = maxH * DCTSIZE;
+ int mcuHeight = maxV * DCTSIZE;
+ interleavedMcuCols = (imageWidth + mcuWidth - 1) / mcuWidth;
+ interleavedMcuRows = (imageHeight + mcuHeight - 1) / mcuHeight;
+ acHuffmanTables = new JPEGHuffmanTable[4];
+ dcHuffmanTables = new JPEGHuffmanTable[4];
+ JPEGHuffmanTable[] dhtTables = new JPEGHuffmanTable[] {
+ JPEGHuffmanTable.getDefaultDCLuminanceTable(),
+ JPEGHuffmanTable.getDefaultDCChrominanceTable(),
+ JPEGHuffmanTable.getDefaultACLuminanceTable(),
+ JPEGHuffmanTable.getDefaultACChrominanceTable()
+ };
+ for (int i = 0; i < dhtTables.length; i++) {
+ JPEGHuffmanTable dhtTable = dhtTables[i];
+ if (!dhtTable.writeToStream(outputStream)) {
+ SWT.error(SWT.ERROR_IO);
+ }
+ JPEGHuffmanTable[] allTables = dhtTable.getAllTables();
+ for (int j = 0; j < allTables.length; j++) {
+ JPEGHuffmanTable huffmanTable = allTables[j];
+ if (huffmanTable.getTableClass() == 0) {
+ dcHuffmanTables[huffmanTable.getTableIdentifier()] = huffmanTable;
+ } else {
+ acHuffmanTables[huffmanTable.getTableIdentifier()] = huffmanTable;
+ }
+ }
+ }
+ precedingDCs = new int[4];
+ scanHeader = new JPEGScanHeader(new byte[14]);
+ scanHeader.setSegmentMarker(SOS);
+ scanHeader.setSegmentLength(scanLength);
+ scanHeader.setNumberOfImageComponents(nComponents);
+ scanHeader.setStartOfSpectralSelection(0);
+ scanHeader.setEndOfSpectralSelection(63);
+ scanHeader.componentParameters = scanParams;
+ scanHeader.initializeContents();
+ if (!scanHeader.writeToStream(outputStream)) {
+ SWT.error(SWT.ERROR_IO);
+ }
+ convertImageToYCbCr(image);
+ resetOutputBuffer();
+ currentByte = 0;
+ currentBitCount = 0;
+ encodeScan();
+ if (!new JPEGEndOfImage().writeToStream(outputStream)) {
+ SWT.error(SWT.ERROR_IO);
+ }
+}
+}
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
index 3f168acba1..13c7482385 100755
--- 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
@@ -1,40 +1,40 @@
-package org.eclipse.swt.internal.image;
-
-/*
+package org.eclipse.swt.internal.image;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-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) {
- }
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+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
index 59a1af75e4..c5e4106c08 100755
--- 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
@@ -1,210 +1,210 @@
-package org.eclipse.swt.internal.image;
-
-/*
+package org.eclipse.swt.internal.image;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-import org.eclipse.swt.*;
-
-final class JPEGFrameHeader extends JPEGVariableSizeSegment {
- int maxVFactor;
- int maxHFactor;
- public int[] componentIdentifiers;
- public int[][] componentParameters;
-
- public JPEGFrameHeader(byte[] reference) {
- super(reference);
- }
-
- public JPEGFrameHeader(LEDataInputStream byteStream) {
- super(byteStream);
- initializeComponentParameters();
- }
-
- public int getSamplePrecision() {
- return reference[4] & 0xFF;
- }
-
- public int getNumberOfLines() {
- return (reference[5] & 0xFF) << 8 | (reference[6] & 0xFF);
- }
-
- public int getSamplesPerLine() {
- return (reference[7] & 0xFF) << 8 | (reference[8] & 0xFF);
- }
-
- public int getNumberOfImageComponents() {
- return reference[9] & 0xFF;
- }
-
- public void setSamplePrecision(int precision) {
- reference[4] = (byte)(precision & 0xFF);
- }
-
- public void setNumberOfLines(int anInteger) {
- reference[5] = (byte)((anInteger & 0xFF00) >> 8);
- reference[6] = (byte)(anInteger & 0xFF);
- }
-
- public void setSamplesPerLine(int samples) {
- reference[7] = (byte)((samples & 0xFF00) >> 8);
- reference[8] = (byte)(samples & 0xFF);
- }
-
- public void setNumberOfImageComponents(int anInteger) {
- reference[9] = (byte)(anInteger & 0xFF);
- }
-
- public int getMaxHFactor() {
- return maxHFactor;
- }
-
- public int getMaxVFactor() {
- return maxVFactor;
- }
-
- public void setMaxHFactor(int anInteger) {
- maxHFactor = anInteger;
- }
-
- public void setMaxVFactor(int anInteger) {
- maxVFactor = anInteger;
- }
-
- /* Used when decoding. */
- void initializeComponentParameters() {
- int nf = getNumberOfImageComponents();
- componentIdentifiers = new int[nf];
- int[][] compSpecParams = new int[0][];
- int hmax = 1;
- int vmax = 1;
- for (int i = 0; i < nf; i++) {
- int ofs = i * 3 + 10;
- int ci = reference[ofs] & 0xFF;
- componentIdentifiers[i] = ci - 1;
- 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 < nf; i++) {
- int[] compParam = compSpecParams[componentIdentifiers[i]];
- int hi = compParam[1];
- int vi = compParam[2];
- int compWidth = (x * hi + hmax - 1) / hmax;
- int compHeight = (y * vi + vmax - 1) / vmax;
- int dsWidth = roundUpToMultiple(compWidth, multiples[hi - 1]);
- int dsHeight = roundUpToMultiple(compHeight, multiples[vi - 1]);
- compParam[3] = dsWidth;
- compParam[4] = dsHeight;
- }
- setMaxHFactor(hmax);
- setMaxVFactor(vmax);
- componentParameters = compSpecParams;
- }
-
- /* Used when encoding. */
- public void initializeContents() {
- int nf = getNumberOfImageComponents();
- if (nf == 0 || nf != componentParameters.length) {
- SWT.error(SWT.ERROR_INVALID_IMAGE);
- }
- int hmax = 0;
- int vmax = 0;
- int[][] compSpecParams = componentParameters;
- for (int i = 0; i < nf; i++) {
- int ofs = i * 3 + 10;
- int[] compParam = compSpecParams[componentIdentifiers[i]];
- int hi = compParam[1];
- int vi = compParam[2];
- if (hi * vi > 4) {
- SWT.error(SWT.ERROR_INVALID_IMAGE);
- }
- reference[ofs] = (byte)(i + 1);
- reference[ofs + 1] = (byte)(hi * 16 + vi);
- reference[ofs + 2] = (byte)(compParam[0]);
- if (hi > hmax) hmax = hi;
- if (vi > vmax) vmax = vi;
- }
- int x = getSamplesPerLine();
- int y = getNumberOfLines();
- int[] multiples = new int[] {8, 16, 24, 32};
- for (int i = 0; i < nf; i++) {
- int[] compParam = compSpecParams[componentIdentifiers[i]];
- int hi = compParam[1];
- int vi = compParam[2];
- int compWidth = (x * hi + hmax - 1) / hmax;
- int compHeight = (y * vi + vmax - 1) / vmax;
- int dsWidth = roundUpToMultiple(compWidth, multiples[hi - 1]);
- int dsHeight = roundUpToMultiple(compHeight, multiples[vi - 1]);
- compParam[3] = dsWidth;
- compParam[4] = dsHeight;
- }
- setMaxHFactor(hmax);
- setMaxVFactor(vmax);
- }
-
- int roundUpToMultiple(int anInteger, int mInteger) {
- int a = anInteger + mInteger - 1;
- return a - (a % mInteger);
- }
-
- /*
- * Verify the information contained in the receiver is correct.
- * Answer true if the header contains a valid marker. Otherwise,
- * answer false. Valid Start Of Frame markers are:
- * SOF_0 - Baseline DCT, Huffman coding
- * SOF_1 - Extended sequential DCT, Huffman coding
- * SOF_2 - Progressive DCT, Huffman coding
- * SOF_3 - Lossless (sequential), Huffman coding
- * SOF_5 - Differential sequential, Huffman coding
- * SOF_6 - Differential progressive, Huffman coding
- * SOF_7 - Differential lossless, Huffman coding
- * SOF_9 - Extended sequential DCT, arithmetic coding
- * SOF_10 - Progressive DCT, arithmetic coding
- * SOF_11 - Lossless (sequential), arithmetic coding
- * SOF_13 - Differential sequential, arithmetic coding
- * SOF_14 - Differential progressive, arithmetic coding
- * SOF_15 - Differential lossless, arithmetic coding
- */
- public boolean verify() {
- int marker = getSegmentMarker();
- return (marker >= JPEGFileFormat.SOF0 && marker <= JPEGFileFormat.SOF3) ||
- (marker >= JPEGFileFormat.SOF5 && marker <= JPEGFileFormat.SOF7) ||
- (marker >= JPEGFileFormat.SOF9 && marker <= JPEGFileFormat.SOF11) ||
- (marker >= JPEGFileFormat.SOF13 && marker <= JPEGFileFormat.SOF15);
- }
-
- public boolean isProgressive() {
- int marker = getSegmentMarker();
- return marker == JPEGFileFormat.SOF2
- || marker == JPEGFileFormat.SOF6
- || marker == JPEGFileFormat.SOF10
- || marker == JPEGFileFormat.SOF14;
- }
-
- public boolean isArithmeticCoding() {
- return getSegmentMarker() >= JPEGFileFormat.SOF9;
- }
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+import org.eclipse.swt.*;
+
+final class JPEGFrameHeader extends JPEGVariableSizeSegment {
+ int maxVFactor;
+ int maxHFactor;
+ public int[] componentIdentifiers;
+ public int[][] componentParameters;
+
+ public JPEGFrameHeader(byte[] reference) {
+ super(reference);
+ }
+
+ public JPEGFrameHeader(LEDataInputStream byteStream) {
+ super(byteStream);
+ initializeComponentParameters();
+ }
+
+ public int getSamplePrecision() {
+ return reference[4] & 0xFF;
+ }
+
+ public int getNumberOfLines() {
+ return (reference[5] & 0xFF) << 8 | (reference[6] & 0xFF);
+ }
+
+ public int getSamplesPerLine() {
+ return (reference[7] & 0xFF) << 8 | (reference[8] & 0xFF);
+ }
+
+ public int getNumberOfImageComponents() {
+ return reference[9] & 0xFF;
+ }
+
+ public void setSamplePrecision(int precision) {
+ reference[4] = (byte)(precision & 0xFF);
+ }
+
+ public void setNumberOfLines(int anInteger) {
+ reference[5] = (byte)((anInteger & 0xFF00) >> 8);
+ reference[6] = (byte)(anInteger & 0xFF);
+ }
+
+ public void setSamplesPerLine(int samples) {
+ reference[7] = (byte)((samples & 0xFF00) >> 8);
+ reference[8] = (byte)(samples & 0xFF);
+ }
+
+ public void setNumberOfImageComponents(int anInteger) {
+ reference[9] = (byte)(anInteger & 0xFF);
+ }
+
+ public int getMaxHFactor() {
+ return maxHFactor;
+ }
+
+ public int getMaxVFactor() {
+ return maxVFactor;
+ }
+
+ public void setMaxHFactor(int anInteger) {
+ maxHFactor = anInteger;
+ }
+
+ public void setMaxVFactor(int anInteger) {
+ maxVFactor = anInteger;
+ }
+
+ /* Used when decoding. */
+ void initializeComponentParameters() {
+ int nf = getNumberOfImageComponents();
+ componentIdentifiers = new int[nf];
+ int[][] compSpecParams = new int[0][];
+ int hmax = 1;
+ int vmax = 1;
+ for (int i = 0; i < nf; i++) {
+ int ofs = i * 3 + 10;
+ int ci = reference[ofs] & 0xFF;
+ componentIdentifiers[i] = ci - 1;
+ 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 < nf; i++) {
+ int[] compParam = compSpecParams[componentIdentifiers[i]];
+ int hi = compParam[1];
+ int vi = compParam[2];
+ int compWidth = (x * hi + hmax - 1) / hmax;
+ int compHeight = (y * vi + vmax - 1) / vmax;
+ int dsWidth = roundUpToMultiple(compWidth, multiples[hi - 1]);
+ int dsHeight = roundUpToMultiple(compHeight, multiples[vi - 1]);
+ compParam[3] = dsWidth;
+ compParam[4] = dsHeight;
+ }
+ setMaxHFactor(hmax);
+ setMaxVFactor(vmax);
+ componentParameters = compSpecParams;
+ }
+
+ /* Used when encoding. */
+ public void initializeContents() {
+ int nf = getNumberOfImageComponents();
+ if (nf == 0 || nf != componentParameters.length) {
+ SWT.error(SWT.ERROR_INVALID_IMAGE);
+ }
+ int hmax = 0;
+ int vmax = 0;
+ int[][] compSpecParams = componentParameters;
+ for (int i = 0; i < nf; i++) {
+ int ofs = i * 3 + 10;
+ int[] compParam = compSpecParams[componentIdentifiers[i]];
+ int hi = compParam[1];
+ int vi = compParam[2];
+ if (hi * vi > 4) {
+ SWT.error(SWT.ERROR_INVALID_IMAGE);
+ }
+ reference[ofs] = (byte)(i + 1);
+ reference[ofs + 1] = (byte)(hi * 16 + vi);
+ reference[ofs + 2] = (byte)(compParam[0]);
+ if (hi > hmax) hmax = hi;
+ if (vi > vmax) vmax = vi;
+ }
+ int x = getSamplesPerLine();
+ int y = getNumberOfLines();
+ int[] multiples = new int[] {8, 16, 24, 32};
+ for (int i = 0; i < nf; i++) {
+ int[] compParam = compSpecParams[componentIdentifiers[i]];
+ int hi = compParam[1];
+ int vi = compParam[2];
+ int compWidth = (x * hi + hmax - 1) / hmax;
+ int compHeight = (y * vi + vmax - 1) / vmax;
+ int dsWidth = roundUpToMultiple(compWidth, multiples[hi - 1]);
+ int dsHeight = roundUpToMultiple(compHeight, multiples[vi - 1]);
+ compParam[3] = dsWidth;
+ compParam[4] = dsHeight;
+ }
+ setMaxHFactor(hmax);
+ setMaxVFactor(vmax);
+ }
+
+ int roundUpToMultiple(int anInteger, int mInteger) {
+ int a = anInteger + mInteger - 1;
+ return a - (a % mInteger);
+ }
+
+ /*
+ * Verify the information contained in the receiver is correct.
+ * Answer true if the header contains a valid marker. Otherwise,
+ * answer false. Valid Start Of Frame markers are:
+ * SOF_0 - Baseline DCT, Huffman coding
+ * SOF_1 - Extended sequential DCT, Huffman coding
+ * SOF_2 - Progressive DCT, Huffman coding
+ * SOF_3 - Lossless (sequential), Huffman coding
+ * SOF_5 - Differential sequential, Huffman coding
+ * SOF_6 - Differential progressive, Huffman coding
+ * SOF_7 - Differential lossless, Huffman coding
+ * SOF_9 - Extended sequential DCT, arithmetic coding
+ * SOF_10 - Progressive DCT, arithmetic coding
+ * SOF_11 - Lossless (sequential), arithmetic coding
+ * SOF_13 - Differential sequential, arithmetic coding
+ * SOF_14 - Differential progressive, arithmetic coding
+ * SOF_15 - Differential lossless, arithmetic coding
+ */
+ public boolean verify() {
+ int marker = getSegmentMarker();
+ return (marker >= JPEGFileFormat.SOF0 && marker <= JPEGFileFormat.SOF3) ||
+ (marker >= JPEGFileFormat.SOF5 && marker <= JPEGFileFormat.SOF7) ||
+ (marker >= JPEGFileFormat.SOF9 && marker <= JPEGFileFormat.SOF11) ||
+ (marker >= JPEGFileFormat.SOF13 && marker <= JPEGFileFormat.SOF15);
+ }
+
+ public boolean isProgressive() {
+ int marker = getSegmentMarker();
+ return marker == JPEGFileFormat.SOF2
+ || marker == JPEGFileFormat.SOF6
+ || marker == JPEGFileFormat.SOF10
+ || marker == JPEGFileFormat.SOF14;
+ }
+
+ public boolean isArithmeticCoding() {
+ return getSegmentMarker() >= JPEGFileFormat.SOF9;
+ }
+}
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
index 55f9c581b5..7990ff5583 100755
--- 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
@@ -1,264 +1,264 @@
-package org.eclipse.swt.internal.image;
-
-/*
+package org.eclipse.swt.internal.image;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-/**
- * 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;
-}
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+/**
+ * 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
index f5c5911914..a41b1d1d7d 100755
--- 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
@@ -1,161 +1,161 @@
-package org.eclipse.swt.internal.image;
-
-/*
+package org.eclipse.swt.internal.image;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-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;
-}
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+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
index 4facb96066..c97510a3a8 100755
--- 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
@@ -1,27 +1,27 @@
-package org.eclipse.swt.internal.image;
-
-/*
+package org.eclipse.swt.internal.image;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-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;
- }
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+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
index e69a1eaa1c..604d237d61 100755
--- 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
@@ -1,119 +1,119 @@
-package org.eclipse.swt.internal.image;
-
-/*
+package org.eclipse.swt.internal.image;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-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;
-}
-
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+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
index 49ce0e2084..19a986cf0e 100755
--- 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
@@ -1,54 +1,54 @@
-package org.eclipse.swt.internal.image;
-
-/*
+package org.eclipse.swt.internal.image;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-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;
- }
- }
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+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
index d37e024c90..8ea7052946 100755
--- 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
@@ -1,31 +1,31 @@
-package org.eclipse.swt.internal.image;
-
-/*
+package org.eclipse.swt.internal.image;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-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;
- }
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+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
index 458ea134d9..ab43a9fde8 100755
--- 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
@@ -1,34 +1,34 @@
-package org.eclipse.swt.internal.image;
-
-/*
+package org.eclipse.swt.internal.image;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-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);
- }
- }
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+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
index 15b7345b9e..d1b2d38393 100755
--- 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
@@ -1,181 +1,181 @@
-package org.eclipse.swt.internal.image;
-
-/*
+package org.eclipse.swt.internal.image;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-import java.io.*;
-
-final class LEDataInputStream extends InputStream {
- int position;
- InputStream in;
-
- /**
- * The byte array containing the bytes to read.
- */
- protected byte[] buf;
-
- /**
- * The current position within the byte array <code>buf</code>. A value
- * equal to buf.length indicates no bytes available. A value of
- * 0 indicates the buffer is full.
- */
- protected int pos;
-
-
- public LEDataInputStream(InputStream input) {
- this(input, 512);
- }
-
- public LEDataInputStream(InputStream input, int bufferSize) {
- this.in = input;
- if (bufferSize > 0) {
- buf = new byte[bufferSize];
- pos = bufferSize;
- }
- else throw new IllegalArgumentException();
- }
-
- public void close() throws IOException {
- buf = null;
- if (in != null) {
- in.close();
- in = null;
- }
- }
-
- /**
- * Answer how many bytes were read.
- */
- public int getPosition() {
- return position;
- }
-
- /**
- * Answers how many bytes are available for reading without blocking
- */
- public int available() throws IOException {
- if (buf == null) throw new IOException();
- return (buf.length - pos) + in.available();
- }
-
- /**
- * Answer the next byte of the input stream.
- */
- public int read() throws IOException {
- if (buf == null) throw new IOException();
- position++;
- if (pos < buf.length) return (buf[pos++] & 0xFF);
- 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 = readData(b, off, len);
- while (true) {
- if (result == -1) return -1;
- position += result;
- if (result == left) return len;
- left -= result;
- off += result;
- result = readData(b, off, left);
- }
- }
-
- /**
- * Reads at most <code>length</code> bytes from this LEDataInputStream and
- * stores them in byte array <code>buffer</code> starting at <code>offset</code>.
- * <p>
- * Answer the number of bytes actually read or -1 if no bytes were read and
- * end of stream was encountered. This implementation reads bytes from
- * the pushback buffer first, then the target stream if more bytes are required
- * to satisfy <code>count</code>.
- * </p>
- * @param buffer the byte array in which to store the read bytes.
- * @param offset the offset in <code>buffer</code> to store the read bytes.
- * @param length the maximum number of bytes to store in <code>buffer</code>.
- *
- * @return int the number of bytes actually read or -1 if end of stream.
- *
- * @exception java.io.IOException if an IOException occurs.
- */
- private int readData(byte[] buffer, int offset, int length) throws IOException {
- if (buf == null) throw new IOException();
- if (offset < 0 || offset > buffer.length ||
- length < 0 || (length > buffer.length - offset)) {
- throw new ArrayIndexOutOfBoundsException();
- }
-
- int cacheCopied = 0;
- int newOffset = offset;
-
- // Are there pushback bytes available?
- int available = buf.length - pos;
- if (available > 0) {
- cacheCopied = (available >= length) ? length : available;
- System.arraycopy(buf, pos, buffer, newOffset, cacheCopied);
- newOffset += cacheCopied;
- pos += cacheCopied;
- }
-
- // Have we copied enough?
- if (cacheCopied == length) return length;
-
- int inCopied = in.read(buffer, newOffset, length - cacheCopied);
-
- if (inCopied > 0) return inCopied + cacheCopied;
- if (cacheCopied == 0) return inCopied;
- return cacheCopied;
- }
-
- /**
- * Answer an integer comprised of the next
- * four bytes of the input stream.
- */
- public int readInt() throws IOException {
- byte[] buf = new byte[4];
- read(buf);
- return ((((((buf[3] & 0xFF) << 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));
- }
-
- /**
- * Push back the entire content of the given buffer <code>b</code>.
- * <p>
- * The bytes are pushed so that they would be read back b[0], b[1], etc.
- * If the push back buffer cannot handle the bytes copied from <code>b</code>,
- * an IOException will be thrown and no byte will be pushed back.
- * </p>
- *
- * @param b the byte array containing bytes to push back into the stream
- *
- * @exception java.io.IOException if the pushback buffer is too small
- */
- public void unread(byte[] b) throws IOException {
- int length = b.length;
- if (length > pos) throw new IOException();
- position -= length;
- pos -= length;
- System.arraycopy(b, 0, buf, pos, length);
- }
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+import java.io.*;
+
+final class LEDataInputStream extends InputStream {
+ int position;
+ InputStream in;
+
+ /**
+ * The byte array containing the bytes to read.
+ */
+ protected byte[] buf;
+
+ /**
+ * The current position within the byte array <code>buf</code>. A value
+ * equal to buf.length indicates no bytes available. A value of
+ * 0 indicates the buffer is full.
+ */
+ protected int pos;
+
+
+ public LEDataInputStream(InputStream input) {
+ this(input, 512);
+ }
+
+ public LEDataInputStream(InputStream input, int bufferSize) {
+ this.in = input;
+ if (bufferSize > 0) {
+ buf = new byte[bufferSize];
+ pos = bufferSize;
+ }
+ else throw new IllegalArgumentException();
+ }
+
+ public void close() throws IOException {
+ buf = null;
+ if (in != null) {
+ in.close();
+ in = null;
+ }
+ }
+
+ /**
+ * Answer how many bytes were read.
+ */
+ public int getPosition() {
+ return position;
+ }
+
+ /**
+ * Answers how many bytes are available for reading without blocking
+ */
+ public int available() throws IOException {
+ if (buf == null) throw new IOException();
+ return (buf.length - pos) + in.available();
+ }
+
+ /**
+ * Answer the next byte of the input stream.
+ */
+ public int read() throws IOException {
+ if (buf == null) throw new IOException();
+ position++;
+ if (pos < buf.length) return (buf[pos++] & 0xFF);
+ 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 = readData(b, off, len);
+ while (true) {
+ if (result == -1) return -1;
+ position += result;
+ if (result == left) return len;
+ left -= result;
+ off += result;
+ result = readData(b, off, left);
+ }
+ }
+
+ /**
+ * Reads at most <code>length</code> bytes from this LEDataInputStream and
+ * stores them in byte array <code>buffer</code> starting at <code>offset</code>.
+ * <p>
+ * Answer the number of bytes actually read or -1 if no bytes were read and
+ * end of stream was encountered. This implementation reads bytes from
+ * the pushback buffer first, then the target stream if more bytes are required
+ * to satisfy <code>count</code>.
+ * </p>
+ * @param buffer the byte array in which to store the read bytes.
+ * @param offset the offset in <code>buffer</code> to store the read bytes.
+ * @param length the maximum number of bytes to store in <code>buffer</code>.
+ *
+ * @return int the number of bytes actually read or -1 if end of stream.
+ *
+ * @exception java.io.IOException if an IOException occurs.
+ */
+ private int readData(byte[] buffer, int offset, int length) throws IOException {
+ if (buf == null) throw new IOException();
+ if (offset < 0 || offset > buffer.length ||
+ length < 0 || (length > buffer.length - offset)) {
+ throw new ArrayIndexOutOfBoundsException();
+ }
+
+ int cacheCopied = 0;
+ int newOffset = offset;
+
+ // Are there pushback bytes available?
+ int available = buf.length - pos;
+ if (available > 0) {
+ cacheCopied = (available >= length) ? length : available;
+ System.arraycopy(buf, pos, buffer, newOffset, cacheCopied);
+ newOffset += cacheCopied;
+ pos += cacheCopied;
+ }
+
+ // Have we copied enough?
+ if (cacheCopied == length) return length;
+
+ int inCopied = in.read(buffer, newOffset, length - cacheCopied);
+
+ if (inCopied > 0) return inCopied + cacheCopied;
+ if (cacheCopied == 0) return inCopied;
+ return cacheCopied;
+ }
+
+ /**
+ * Answer an integer comprised of the next
+ * four bytes of the input stream.
+ */
+ public int readInt() throws IOException {
+ byte[] buf = new byte[4];
+ read(buf);
+ return ((((((buf[3] & 0xFF) << 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));
+ }
+
+ /**
+ * Push back the entire content of the given buffer <code>b</code>.
+ * <p>
+ * The bytes are pushed so that they would be read back b[0], b[1], etc.
+ * If the push back buffer cannot handle the bytes copied from <code>b</code>,
+ * an IOException will be thrown and no byte will be pushed back.
+ * </p>
+ *
+ * @param b the byte array containing bytes to push back into the stream
+ *
+ * @exception java.io.IOException if the pushback buffer is too small
+ */
+ public void unread(byte[] b) throws IOException {
+ int length = b.length;
+ if (length > pos) throw new IOException();
+ position -= length;
+ pos -= length;
+ System.arraycopy(b, 0, buf, pos, length);
+ }
} \ No newline at end of file
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
index 96847dab59..b8a8359145 100755
--- 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
@@ -1,53 +1,53 @@
-package org.eclipse.swt.internal.image;
-
-/*
+package org.eclipse.swt.internal.image;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-import java.io.*;
-
-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);
-}
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+import java.io.*;
+
+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
index 42e5a0ef00..51e80f9ce2 100755
--- 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
@@ -1,478 +1,478 @@
-package org.eclipse.swt.internal.image;
-
-/*
+package org.eclipse.swt.internal.image;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-import org.eclipse.swt.*;
-import org.eclipse.swt.graphics.*;
-
-final class LZWCodec {
- int bitsPerPixel, blockSize, blockIndex, currentByte, bitsLeft,
- codeSize, clearCode, endCode, newCodes, topSlot, currentSlot,
- imageWidth, imageHeight, imageX, imageY, pass, line, codeMask, 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);
- }
-}
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+import org.eclipse.swt.*;
+import org.eclipse.swt.graphics.*;
+
+final class LZWCodec {
+ int bitsPerPixel, blockSize, blockIndex, currentByte, bitsLeft,
+ codeSize, clearCode, endCode, newCodes, topSlot, currentSlot,
+ imageWidth, imageHeight, imageX, imageY, pass, line, codeMask, 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
index b53e45cf8e..0a0eb64344 100755
--- 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
@@ -1,13 +1,13 @@
-package org.eclipse.swt.internal.image;
-
-/*
+package org.eclipse.swt.internal.image;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-final class LZWNode {
- public LZWNode left, right, children;
- public int code, prefix, suffix;
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+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
index f1ab0ec561..af955def8a 100755
--- 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
@@ -1,534 +1,534 @@
-package org.eclipse.swt.internal.image;
-
-/*
+package org.eclipse.swt.internal.image;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-import java.io.*;
-import org.eclipse.swt.*;
-import org.eclipse.swt.graphics.*;
-
-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);
-}
-boolean isFileFormat(LEDataInputStream stream) {
- try {
- byte[] signature = new byte[SIGNATURE_LENGTH];
- stream.read(signature);
- stream.unread(signature);
- if ((signature[0] & 0xFF) != 137) return false; //137
- if ((signature[1] & 0xFF) != 80) return false; //P
- if ((signature[2] & 0xFF) != 78) return false; //N
- if ((signature[3] & 0xFF) != 71) return false; //G
- if ((signature[4] & 0xFF) != 13) return false; //<RETURN>
- if ((signature[5] & 0xFF) != 10) return false; //<LINEFEED>
- if ((signature[6] & 0xFF) != 26) return false; //<CTRL/Z>
- if ((signature[7] & 0xFF) != 10) return false; //<LINEFEED>
- return true;
- } catch (Exception e) {
- return false;
- }
-}
-/**
- * SWT does not support 16-bit depths. If this image uses
- * 16-bit depths, convert the data to an 8-bit depth.
- */
-byte[] validateBitDepth(byte[] data) {
- if (headerChunk.getBitDepth() > 8) {
- byte[] result = new byte[data.length / 2];
- compress16BitDepthTo8BitDepth(data, 0, result, 0, result.length);
- return result;
- } else {
- return data;
- }
-}
-/**
- * SWT does not support greyscale as a color type. For
- * plain grayscale, we create a palette. For Grayscale
- * with Alpha, however, we need to convert the pixels
- * to use RGB values.
- * Note: This method assumes that the bit depth of the
- * data has already been restricted to 8 or less.
- */
-void setPixelData(byte[] data, ImageData imageData) {
- switch (headerChunk.getColorType()) {
- case PngIhdrChunk.COLOR_TYPE_GRAYSCALE_WITH_ALPHA:
- {
- int width = imageData.width;
- int height = imageData.height;
- int destBytesPerLine = imageData.bytesPerLine;
- /*
- * If the image uses 16-bit depth, it is converted
- * to an 8-bit depth image.
- */
- int srcBytesPerLine = getAlignedBytesPerRow();
- if (headerChunk.getBitDepth() > 8) srcBytesPerLine /= 2;
-
- byte[] rgbData = new byte[destBytesPerLine * height];
- byte[] alphaData = new byte[width * height];
- for (int y = 0; y < height; y++) {
- int srcIndex = srcBytesPerLine * y;
- int destIndex = destBytesPerLine * y;
- int destAlphaIndex = width * y;
- for (int x = 0; x < width; x++) {
- byte grey = data[srcIndex];
- byte alpha = data[srcIndex + 1];
- rgbData[destIndex + 0] = grey;
- rgbData[destIndex + 1] = grey;
- rgbData[destIndex + 2] = grey;
- alphaData[destAlphaIndex] = alpha;
- srcIndex += 2;
- destIndex += 3;
- destAlphaIndex++;
- }
- }
- imageData.data = rgbData;
- imageData.alphaData = alphaData;
- break;
- }
- case PngIhdrChunk.COLOR_TYPE_RGB_WITH_ALPHA:
- {
- int width = imageData.width;
- int height = imageData.height;
- int destBytesPerLine = imageData.bytesPerLine;
- int srcBytesPerLine = getAlignedBytesPerRow();
- /*
- * If the image uses 16-bit depth, it is converted
- * to an 8-bit depth image.
- */
- if (headerChunk.getBitDepth() > 8) srcBytesPerLine /= 2;
-
- byte[] rgbData = new byte[destBytesPerLine * height];
- byte[] alphaData = new byte[width * height];
- for (int y = 0; y < height; y++) {
- int srcIndex = srcBytesPerLine * y;
- int destIndex = destBytesPerLine * y;
- int destAlphaIndex = width * y;
- for (int x = 0; x < width; x++) {
- rgbData[destIndex + 0] = data[srcIndex + 0];
- rgbData[destIndex + 1] = data[srcIndex + 1];
- rgbData[destIndex + 2] = data[srcIndex + 2];
- alphaData[destAlphaIndex] = data[srcIndex + 3];
- srcIndex += 4;
- destIndex += 3;
- destAlphaIndex++;
- }
- }
- imageData.data = rgbData;
- imageData.alphaData = alphaData;
- break;
- }
- case PngIhdrChunk.COLOR_TYPE_RGB:
- imageData.data = data;
- break;
- case PngIhdrChunk.COLOR_TYPE_PALETTE:
- imageData.data = data;
- if (alphaPalette != null) {
- int size = imageData.width * imageData.height;
- byte[] alphaData = new byte[size];
- byte[] pixelData = new byte[size];
- imageData.getPixels(0, 0, size, pixelData, 0);
- for (int i = 0; i < pixelData.length; i++) {
- alphaData[i] = alphaPalette[pixelData[i] & 0xFF];
- }
- imageData.alphaData = alphaData;
- }
- break;
- default:
- imageData.data = data;
- break;
- }
-}
-/**
- * PNG supports some color types and bit depths that are
- * unsupported by SWT. If the image uses an unsupported
- * color type (either of the gray scale types) or bit
- * depth (16), convert the data to an SWT-supported
- * format. Then assign the data into the ImageData given.
- */
-void setImageDataValues(byte[] data, ImageData imageData) {
- byte[] result = validateBitDepth(data);
- setPixelData(result, imageData);
-}
-/**
- * Read the image data from the data stream. This must handle
- * decoding the data, filtering, and interlacing.
- */
-void readPixelData(PngIdatChunk chunk, PngChunkReader chunkReader) {
- 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 = (Compatibility.pow2(8) - 1) / (Compatibility.pow2(16) - 1);
- for (int i = 0; i < numberOfValues; i++) {
- int sourceIndex = sourceOffset + (2 * i);
- int destinationIndex = destinationOffset + i;
- //int value = (source[sourceIndex] << 8) | source[sourceIndex + 1];
- //byte compressedValue = (byte)(value * multiplier);
- byte compressedValue = source[sourceIndex];
- destination[destinationIndex] = compressedValue;
- }
-}
-/**
- * SWT does not support 16-bit depth color formats.
- * Convert the 16-bit data to 8-bit data.
- * The correct way to do this is to multiply each
- * 16 bit value by the value:
- * (2^8 - 1) / (2^16 - 1).
- * The fast way to do this is just to drop the low
- * byte of the 16-bit value.
- */
-static int compress16BitDepthTo8BitDepth(int value) {
- //double multiplier = (Compatibility.pow2(8) - 1) / (Compatibility.pow2(16) - 1);
- //byte compressedValue = (byte)(value * multiplier);
- return value >> 8;
-}
-/**
- * PNG supports four filtering types. These types are applied
- * per row of image data. This method unfilters the given row
- * based on the filterType.
- */
-void filterRow(byte[] row, byte[] previousRow, int filterType) {
- int byteOffset = headerChunk.getFilterByteOffset();
- switch (filterType) {
- case PngIhdrChunk.FILTER_NONE:
- break;
- case PngIhdrChunk.FILTER_SUB:
- for (int i = byteOffset; i < row.length; i++) {
- int current = row[i] & 0xFF;
- int left = row[i - byteOffset] & 0xFF;
- row[i] = (byte)((current + left) & 0xFF);
- }
- break;
- case PngIhdrChunk.FILTER_UP:
- for (int i = 0; i < row.length; i++) {
- int current = row[i] & 0xFF;
- int above = previousRow[i] & 0xFF;
- row[i] = (byte)((current + above) & 0xFF);
- }
- break;
- case PngIhdrChunk.FILTER_AVERAGE:
- for (int i = 0; i < row.length; i++) {
- int left = (i < byteOffset) ? 0 : row[i - byteOffset] & 0xFF;
- int above = previousRow[i] & 0xFF;
- int current = row[i] & 0xFF;
- row[i] = (byte)((current + ((left + above) / 2)) & 0xFF);
- }
- break;
- case PngIhdrChunk.FILTER_PAETH:
- for (int i = 0; i < row.length; i++) {
- int left = (i < byteOffset) ? 0 : row[i - byteOffset] & 0xFF;
- int aboveLeft = (i < byteOffset) ? 0 : previousRow[i - byteOffset] & 0xFF;
- int above = previousRow[i] & 0xFF;
-
- int a = Math.abs(above - aboveLeft);
- int b = Math.abs(left - aboveLeft);
- int c = Math.abs(left - aboveLeft + above - aboveLeft);
-
- int preductor = 0;
- if (a <= b && a <= c) {
- preductor = left;
- } else if (b <= c) {
- preductor = above;
- } else {
- preductor = aboveLeft;
- }
-
- int currentValue = row[i] & 0xFF;
- row[i] = (byte) ((currentValue + preductor) & 0xFF);
- }
- break;
- }
-}
-
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+import java.io.*;
+import org.eclipse.swt.*;
+import org.eclipse.swt.graphics.*;
+
+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);
+}
+boolean isFileFormat(LEDataInputStream stream) {
+ try {
+ byte[] signature = new byte[SIGNATURE_LENGTH];
+ stream.read(signature);
+ stream.unread(signature);
+ if ((signature[0] & 0xFF) != 137) return false; //137
+ if ((signature[1] & 0xFF) != 80) return false; //P
+ if ((signature[2] & 0xFF) != 78) return false; //N
+ if ((signature[3] & 0xFF) != 71) return false; //G
+ if ((signature[4] & 0xFF) != 13) return false; //<RETURN>
+ if ((signature[5] & 0xFF) != 10) return false; //<LINEFEED>
+ if ((signature[6] & 0xFF) != 26) return false; //<CTRL/Z>
+ if ((signature[7] & 0xFF) != 10) return false; //<LINEFEED>
+ return true;
+ } catch (Exception e) {
+ return false;
+ }
+}
+/**
+ * SWT does not support 16-bit depths. If this image uses
+ * 16-bit depths, convert the data to an 8-bit depth.
+ */
+byte[] validateBitDepth(byte[] data) {
+ if (headerChunk.getBitDepth() > 8) {
+ byte[] result = new byte[data.length / 2];
+ compress16BitDepthTo8BitDepth(data, 0, result, 0, result.length);
+ return result;
+ } else {
+ return data;
+ }
+}
+/**
+ * SWT does not support greyscale as a color type. For
+ * plain grayscale, we create a palette. For Grayscale
+ * with Alpha, however, we need to convert the pixels
+ * to use RGB values.
+ * Note: This method assumes that the bit depth of the
+ * data has already been restricted to 8 or less.
+ */
+void setPixelData(byte[] data, ImageData imageData) {
+ switch (headerChunk.getColorType()) {
+ case PngIhdrChunk.COLOR_TYPE_GRAYSCALE_WITH_ALPHA:
+ {
+ int width = imageData.width;
+ int height = imageData.height;
+ int destBytesPerLine = imageData.bytesPerLine;
+ /*
+ * If the image uses 16-bit depth, it is converted
+ * to an 8-bit depth image.
+ */
+ int srcBytesPerLine = getAlignedBytesPerRow();
+ if (headerChunk.getBitDepth() > 8) srcBytesPerLine /= 2;
+
+ byte[] rgbData = new byte[destBytesPerLine * height];
+ byte[] alphaData = new byte[width * height];
+ for (int y = 0; y < height; y++) {
+ int srcIndex = srcBytesPerLine * y;
+ int destIndex = destBytesPerLine * y;
+ int destAlphaIndex = width * y;
+ for (int x = 0; x < width; x++) {
+ byte grey = data[srcIndex];
+ byte alpha = data[srcIndex + 1];
+ rgbData[destIndex + 0] = grey;
+ rgbData[destIndex + 1] = grey;
+ rgbData[destIndex + 2] = grey;
+ alphaData[destAlphaIndex] = alpha;
+ srcIndex += 2;
+ destIndex += 3;
+ destAlphaIndex++;
+ }
+ }
+ imageData.data = rgbData;
+ imageData.alphaData = alphaData;
+ break;
+ }
+ case PngIhdrChunk.COLOR_TYPE_RGB_WITH_ALPHA:
+ {
+ int width = imageData.width;
+ int height = imageData.height;
+ int destBytesPerLine = imageData.bytesPerLine;
+ int srcBytesPerLine = getAlignedBytesPerRow();
+ /*
+ * If the image uses 16-bit depth, it is converted
+ * to an 8-bit depth image.
+ */
+ if (headerChunk.getBitDepth() > 8) srcBytesPerLine /= 2;
+
+ byte[] rgbData = new byte[destBytesPerLine * height];
+ byte[] alphaData = new byte[width * height];
+ for (int y = 0; y < height; y++) {
+ int srcIndex = srcBytesPerLine * y;
+ int destIndex = destBytesPerLine * y;
+ int destAlphaIndex = width * y;
+ for (int x = 0; x < width; x++) {
+ rgbData[destIndex + 0] = data[srcIndex + 0];
+ rgbData[destIndex + 1] = data[srcIndex + 1];
+ rgbData[destIndex + 2] = data[srcIndex + 2];
+ alphaData[destAlphaIndex] = data[srcIndex + 3];
+ srcIndex += 4;
+ destIndex += 3;
+ destAlphaIndex++;
+ }
+ }
+ imageData.data = rgbData;
+ imageData.alphaData = alphaData;
+ break;
+ }
+ case PngIhdrChunk.COLOR_TYPE_RGB:
+ imageData.data = data;
+ break;
+ case PngIhdrChunk.COLOR_TYPE_PALETTE:
+ imageData.data = data;
+ if (alphaPalette != null) {
+ int size = imageData.width * imageData.height;
+ byte[] alphaData = new byte[size];
+ byte[] pixelData = new byte[size];
+ imageData.getPixels(0, 0, size, pixelData, 0);
+ for (int i = 0; i < pixelData.length; i++) {
+ alphaData[i] = alphaPalette[pixelData[i] & 0xFF];
+ }
+ imageData.alphaData = alphaData;
+ }
+ break;
+ default:
+ imageData.data = data;
+ break;
+ }
+}
+/**
+ * PNG supports some color types and bit depths that are
+ * unsupported by SWT. If the image uses an unsupported
+ * color type (either of the gray scale types) or bit
+ * depth (16), convert the data to an SWT-supported
+ * format. Then assign the data into the ImageData given.
+ */
+void setImageDataValues(byte[] data, ImageData imageData) {
+ byte[] result = validateBitDepth(data);
+ setPixelData(result, imageData);
+}
+/**
+ * Read the image data from the data stream. This must handle
+ * decoding the data, filtering, and interlacing.
+ */
+void readPixelData(PngIdatChunk chunk, PngChunkReader chunkReader) {
+ 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 = (Compatibility.pow2(8) - 1) / (Compatibility.pow2(16) - 1);
+ for (int i = 0; i < numberOfValues; i++) {
+ int sourceIndex = sourceOffset + (2 * i);
+ int destinationIndex = destinationOffset + i;
+ //int value = (source[sourceIndex] << 8) | source[sourceIndex + 1];
+ //byte compressedValue = (byte)(value * multiplier);
+ byte compressedValue = source[sourceIndex];
+ destination[destinationIndex] = compressedValue;
+ }
+}
+/**
+ * SWT does not support 16-bit depth color formats.
+ * Convert the 16-bit data to 8-bit data.
+ * The correct way to do this is to multiply each
+ * 16 bit value by the value:
+ * (2^8 - 1) / (2^16 - 1).
+ * The fast way to do this is just to drop the low
+ * byte of the 16-bit value.
+ */
+static int compress16BitDepthTo8BitDepth(int value) {
+ //double multiplier = (Compatibility.pow2(8) - 1) / (Compatibility.pow2(16) - 1);
+ //byte compressedValue = (byte)(value * multiplier);
+ return value >> 8;
+}
+/**
+ * PNG supports four filtering types. These types are applied
+ * per row of image data. This method unfilters the given row
+ * based on the filterType.
+ */
+void filterRow(byte[] row, byte[] previousRow, int filterType) {
+ int byteOffset = headerChunk.getFilterByteOffset();
+ switch (filterType) {
+ case PngIhdrChunk.FILTER_NONE:
+ break;
+ case PngIhdrChunk.FILTER_SUB:
+ for (int i = byteOffset; i < row.length; i++) {
+ int current = row[i] & 0xFF;
+ int left = row[i - byteOffset] & 0xFF;
+ row[i] = (byte)((current + left) & 0xFF);
+ }
+ break;
+ case PngIhdrChunk.FILTER_UP:
+ for (int i = 0; i < row.length; i++) {
+ int current = row[i] & 0xFF;
+ int above = previousRow[i] & 0xFF;
+ row[i] = (byte)((current + above) & 0xFF);
+ }
+ break;
+ case PngIhdrChunk.FILTER_AVERAGE:
+ for (int i = 0; i < row.length; i++) {
+ int left = (i < byteOffset) ? 0 : row[i - byteOffset] & 0xFF;
+ int above = previousRow[i] & 0xFF;
+ int current = row[i] & 0xFF;
+ row[i] = (byte)((current + ((left + above) / 2)) & 0xFF);
+ }
+ break;
+ case PngIhdrChunk.FILTER_PAETH:
+ for (int i = 0; i < row.length; i++) {
+ int left = (i < byteOffset) ? 0 : row[i - byteOffset] & 0xFF;
+ int aboveLeft = (i < byteOffset) ? 0 : previousRow[i - byteOffset] & 0xFF;
+ int above = previousRow[i] & 0xFF;
+
+ int a = Math.abs(above - aboveLeft);
+ int b = Math.abs(left - aboveLeft);
+ int c = Math.abs(left - aboveLeft + above - aboveLeft);
+
+ int preductor = 0;
+ if (a <= b && a <= c) {
+ preductor = left;
+ } else if (b <= c) {
+ preductor = above;
+ } else {
+ preductor = aboveLeft;
+ }
+
+ int currentValue = row[i] & 0xFF;
+ row[i] = (byte) ((currentValue + preductor) & 0xFF);
+ }
+ break;
+ }
+}
+
}
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
index 534e333671..a74f3d9d18 100755
--- 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
@@ -1,336 +1,336 @@
-package org.eclipse.swt.internal.image;
-
-/*
+package org.eclipse.swt.internal.image;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-import org.eclipse.swt.*;
-import org.eclipse.swt.internal.Compatibility;
-import java.io.*;
-
-class PngChunk extends Object {
- byte[] reference;
-
- static final int LENGTH_OFFSET = 0;
- static final int TYPE_OFFSET = 4;
- static final int DATA_OFFSET = 8;
-
- static final int TYPE_FIELD_LENGTH = 4;
- static final int LENGTH_FIELD_LENGTH = 4;
- static final int MIN_LENGTH = 12;
-
- static final int CHUNK_UNKNOWN = -1;
- // Critical chunks.
- static final int CHUNK_IHDR = 0;
- static final int CHUNK_PLTE = 1;
- static final int CHUNK_IDAT = 2;
- static final int CHUNK_IEND = 3;
- // Non-critical chunks.
- static final int CHUNK_tRNS = 5;
-
- static final byte[] TYPE_IHDR = {(byte) 'I', (byte) 'H', (byte) 'D', (byte) 'R'};
- static final byte[] TYPE_PLTE = {(byte) 'P', (byte) 'L', (byte) 'T', (byte) 'E'};
- static final byte[] TYPE_IDAT = {(byte) 'I', (byte) 'D', (byte) 'A', (byte) 'T'};
- static final byte[] TYPE_IEND = {(byte) 'I', (byte) 'E', (byte) 'N', (byte) 'D'};
- static final byte[] TYPE_tRNS = {(byte) 't', (byte) 'R', (byte) 'N', (byte) 'S'};
-
- static final int[] CRC_TABLE;
- static {
- CRC_TABLE = new int[256];
- for (int i = 0; i < 256; i++) {
- CRC_TABLE[i] = i;
- for (int j = 0; j < 8; j++) {
- if ((CRC_TABLE[i] & 0x1) == 0) {
- CRC_TABLE[i] = (CRC_TABLE[i] >> 1) & 0x7FFFFFFF;
- } else {
- CRC_TABLE[i] = 0xEDB88320 ^ ((CRC_TABLE[i] >> 1) & 0x7FFFFFFF);
- }
- }
- }
- }
-
-/**
- * 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) {
- SWT.error (SWT.ERROR_INVALID_ARGUMENT);
- }
- System.arraycopy(value, 0, reference, TYPE_OFFSET, TYPE_FIELD_LENGTH);
-}
-
-/**
- * Get the chunk's data.
- */
-byte[] getData() {
- int dataLength = getLength();
- if (reference.length < MIN_LENGTH + dataLength) {
- SWT.error (SWT.ERROR_INVALID_RANGE);
- }
- byte[] data = new byte[dataLength];
- System.arraycopy(reference, DATA_OFFSET, data, 0, dataLength);
- return data;
-}
-
-/**
- * Set the chunk's data.
- * This method has two side-effects.
- * 1. It will set the length field to be the length
- * of the data array given.
- * 2. It will set the CRC field to the computed CRC
- * value of the data array given.
- */
-void setData(byte[] data) {
- setLength(data.length);
- System.arraycopy(data, 0, reference, DATA_OFFSET, data.length);
- setCRC(computeCRC());
-}
-
-/**
- * Get the CRC value for the chunk's data.
- * Ensure that the length field has a good
- * value before making this call.
- */
-int getCRC() {
- int crcOffset = DATA_OFFSET + getLength();
- return getInt32(crcOffset);
-}
-
-/**
- * Set the CRC value for the chunk's data.
- * Ensure that the length field has a good
- * value before making this call.
- */
-void setCRC(int value) {
- int crcOffset = DATA_OFFSET + getLength();
- setInt32(crcOffset, value);
-}
-
-/**
- * Get the chunk's total size including the length, type, and crc fields.
- */
-int getSize() {
- return MIN_LENGTH + getLength();
-}
-
-/**
- * Compute the CRC value for the chunk's data. Answer
- * whether this value matches the value stored in the
- * chunk.
- */
-boolean checkCRC() {
- int crc = computeCRC();
- int storedCRC = getCRC();
- return crc == storedCRC;
-}
-
-/**
- * Answer the CRC value of chunk's data.
- */
-int computeCRC() {
- int crc = 0xFFFFFFFF;
- int start = TYPE_OFFSET;
- int stop = DATA_OFFSET + getLength();
- for (int i = start; i < stop; i++) {
- int index = (crc ^ reference[i]) & 0xFF;
- crc = CRC_TABLE[index] ^ ((crc >> 8) & 0x00FFFFFF);
- }
- return ~crc;
-}
-
-boolean typeMatchesArray(byte[] array) {
- for (int i = 0; i < TYPE_FIELD_LENGTH; i++) {
- if (reference[TYPE_OFFSET + i] != array[i]){
- return false;
- }
- }
- return true;
-}
-
-boolean isCritical() {
- 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 (!Compatibility.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();
-}
-
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+import org.eclipse.swt.*;
+import org.eclipse.swt.internal.Compatibility;
+import java.io.*;
+
+class PngChunk extends Object {
+ byte[] reference;
+
+ static final int LENGTH_OFFSET = 0;
+ static final int TYPE_OFFSET = 4;
+ static final int DATA_OFFSET = 8;
+
+ static final int TYPE_FIELD_LENGTH = 4;
+ static final int LENGTH_FIELD_LENGTH = 4;
+ static final int MIN_LENGTH = 12;
+
+ static final int CHUNK_UNKNOWN = -1;
+ // Critical chunks.
+ static final int CHUNK_IHDR = 0;
+ static final int CHUNK_PLTE = 1;
+ static final int CHUNK_IDAT = 2;
+ static final int CHUNK_IEND = 3;
+ // Non-critical chunks.
+ static final int CHUNK_tRNS = 5;
+
+ static final byte[] TYPE_IHDR = {(byte) 'I', (byte) 'H', (byte) 'D', (byte) 'R'};
+ static final byte[] TYPE_PLTE = {(byte) 'P', (byte) 'L', (byte) 'T', (byte) 'E'};
+ static final byte[] TYPE_IDAT = {(byte) 'I', (byte) 'D', (byte) 'A', (byte) 'T'};
+ static final byte[] TYPE_IEND = {(byte) 'I', (byte) 'E', (byte) 'N', (byte) 'D'};
+ static final byte[] TYPE_tRNS = {(byte) 't', (byte) 'R', (byte) 'N', (byte) 'S'};
+
+ static final int[] CRC_TABLE;
+ static {
+ CRC_TABLE = new int[256];
+ for (int i = 0; i < 256; i++) {
+ CRC_TABLE[i] = i;
+ for (int j = 0; j < 8; j++) {
+ if ((CRC_TABLE[i] & 0x1) == 0) {
+ CRC_TABLE[i] = (CRC_TABLE[i] >> 1) & 0x7FFFFFFF;
+ } else {
+ CRC_TABLE[i] = 0xEDB88320 ^ ((CRC_TABLE[i] >> 1) & 0x7FFFFFFF);
+ }
+ }
+ }
+ }
+
+/**
+ * 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) {
+ SWT.error (SWT.ERROR_INVALID_ARGUMENT);
+ }
+ System.arraycopy(value, 0, reference, TYPE_OFFSET, TYPE_FIELD_LENGTH);
+}
+
+/**
+ * Get the chunk's data.
+ */
+byte[] getData() {
+ int dataLength = getLength();
+ if (reference.length < MIN_LENGTH + dataLength) {
+ SWT.error (SWT.ERROR_INVALID_RANGE);
+ }
+ byte[] data = new byte[dataLength];
+ System.arraycopy(reference, DATA_OFFSET, data, 0, dataLength);
+ return data;
+}
+
+/**
+ * Set the chunk's data.
+ * This method has two side-effects.
+ * 1. It will set the length field to be the length
+ * of the data array given.
+ * 2. It will set the CRC field to the computed CRC
+ * value of the data array given.
+ */
+void setData(byte[] data) {
+ setLength(data.length);
+ System.arraycopy(data, 0, reference, DATA_OFFSET, data.length);
+ setCRC(computeCRC());
+}
+
+/**
+ * Get the CRC value for the chunk's data.
+ * Ensure that the length field has a good
+ * value before making this call.
+ */
+int getCRC() {
+ int crcOffset = DATA_OFFSET + getLength();
+ return getInt32(crcOffset);
+}
+
+/**
+ * Set the CRC value for the chunk's data.
+ * Ensure that the length field has a good
+ * value before making this call.
+ */
+void setCRC(int value) {
+ int crcOffset = DATA_OFFSET + getLength();
+ setInt32(crcOffset, value);
+}
+
+/**
+ * Get the chunk's total size including the length, type, and crc fields.
+ */
+int getSize() {
+ return MIN_LENGTH + getLength();
+}
+
+/**
+ * Compute the CRC value for the chunk's data. Answer
+ * whether this value matches the value stored in the
+ * chunk.
+ */
+boolean checkCRC() {
+ int crc = computeCRC();
+ int storedCRC = getCRC();
+ return crc == storedCRC;
+}
+
+/**
+ * Answer the CRC value of chunk's data.
+ */
+int computeCRC() {
+ int crc = 0xFFFFFFFF;
+ int start = TYPE_OFFSET;
+ int stop = DATA_OFFSET + getLength();
+ for (int i = start; i < stop; i++) {
+ int index = (crc ^ reference[i]) & 0xFF;
+ crc = CRC_TABLE[index] ^ ((crc >> 8) & 0x00FFFFFF);
+ }
+ return ~crc;
+}
+
+boolean typeMatchesArray(byte[] array) {
+ for (int i = 0; i < TYPE_FIELD_LENGTH; i++) {
+ if (reference[TYPE_OFFSET + i] != array[i]){
+ return false;
+ }
+ }
+ return true;
+}
+
+boolean isCritical() {
+ 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 (!Compatibility.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();
+}
+
}
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
index 86bf69275c..febd9148e8 100755
--- 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
@@ -1,66 +1,66 @@
-package org.eclipse.swt.internal.image;
-
-/*
+package org.eclipse.swt.internal.image;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-import org.eclipse.swt.*;
-
-public class PngChunkReader {
- LEDataInputStream inputStream;
- PngFileReadState readState;
- PngIhdrChunk headerChunk;
- PngPlteChunk paletteChunk;
-
-PngChunkReader(LEDataInputStream inputStream) {
- this.inputStream = inputStream;
- readState = new PngFileReadState();
- headerChunk = null;
-}
-
-PngIhdrChunk getIhdrChunk() {
- if (headerChunk == null) {
- try {
- PngChunk chunk = PngChunk.readNextFromStream(inputStream);
- 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;
-}
-
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+import org.eclipse.swt.*;
+
+public class PngChunkReader {
+ LEDataInputStream inputStream;
+ PngFileReadState readState;
+ PngIhdrChunk headerChunk;
+ PngPlteChunk paletteChunk;
+
+PngChunkReader(LEDataInputStream inputStream) {
+ this.inputStream = inputStream;
+ readState = new PngFileReadState();
+ headerChunk = null;
+}
+
+PngIhdrChunk getIhdrChunk() {
+ if (headerChunk == null) {
+ try {
+ PngChunk chunk = PngChunk.readNextFromStream(inputStream);
+ 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;
+}
+
}
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
index 350b3f6f0e..b17e342e10 100755
--- 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
@@ -1,132 +1,132 @@
-package org.eclipse.swt.internal.image;
-
-/*
+package org.eclipse.swt.internal.image;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-import org.eclipse.swt.*;
-
-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 & 0xFF) << 8) | (headerByte2 & 0xFF);
- if (number % 31 != 0) error();
-
- int compressionMethod = headerByte1 & 0x0F;
- if (compressionMethod != 8) error();
-
- int windowSizeHint = (headerByte1 & 0xF0) >> 4;
- if (windowSizeHint > 7) error();
- int windowSize = (1 << (windowSizeHint + 8));
- lzBlockReader.setWindowSize(windowSize);
-
- int dictionary = (headerByte2 & (1 << 5));
- if (dictionary != 0) error();
-
-// int compressionLevel = (headerByte2 & 0xC0) >> 6;
-}
-
-void checkAdler() {
- int storedAdler = ((getNextIdatByte() & 0xFF) << 24)
- | ((getNextIdatByte() & 0xFF) << 16)
- | ((getNextIdatByte() & 0xFF) << 8)
- | (getNextIdatByte() & 0xFF);
- if (storedAdler != adlerValue) error();
-}
-
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+import org.eclipse.swt.*;
+
+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 & 0xFF) << 8) | (headerByte2 & 0xFF);
+ if (number % 31 != 0) error();
+
+ int compressionMethod = headerByte1 & 0x0F;
+ if (compressionMethod != 8) error();
+
+ int windowSizeHint = (headerByte1 & 0xF0) >> 4;
+ if (windowSizeHint > 7) error();
+ int windowSize = (1 << (windowSizeHint + 8));
+ lzBlockReader.setWindowSize(windowSize);
+
+ int dictionary = (headerByte2 & (1 << 5));
+ if (dictionary != 0) error();
+
+// int compressionLevel = (headerByte2 & 0xC0) >> 6;
+}
+
+void checkAdler() {
+ int storedAdler = ((getNextIdatByte() & 0xFF) << 24)
+ | ((getNextIdatByte() & 0xFF) << 16)
+ | ((getNextIdatByte() & 0xFF) << 8)
+ | (getNextIdatByte() & 0xFF);
+ if (storedAdler != adlerValue) error();
+}
+
}
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
index 0a7103f844..fc4c4e5a0e 100755
--- 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
@@ -1,22 +1,22 @@
-package org.eclipse.swt.internal.image;
-
-/*
+package org.eclipse.swt.internal.image;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-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;
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+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;
}
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
index 483c1672ed..1d5602d236 100755
--- 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
@@ -1,124 +1,124 @@
-package org.eclipse.swt.internal.image;
-
-/*
+package org.eclipse.swt.internal.image;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-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;
-}
-
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+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;
+}
+
}
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
index 5d0dcde249..c88a983a01 100755
--- 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
@@ -1,158 +1,158 @@
-package org.eclipse.swt.internal.image;
-
-/*
+package org.eclipse.swt.internal.image;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-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);
-}
-
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+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);
+}
+
}
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
index 744c0d3765..8dbb505539 100755
--- 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
@@ -1,38 +1,38 @@
-package org.eclipse.swt.internal.image;
-
-/*
+package org.eclipse.swt.internal.image;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-import org.eclipse.swt.*;
-
-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];
-}
-
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+import org.eclipse.swt.*;
+
+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];
+}
+
}
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
index 914fad1e02..57fa44c7c2 100755
--- 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
@@ -1,41 +1,41 @@
-package org.eclipse.swt.internal.image;
-
-/*
+package org.eclipse.swt.internal.image;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-import org.eclipse.swt.*;
-
-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);
-}
-
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+import org.eclipse.swt.*;
+
+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);
+}
+
}
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
index 780e6051e5..4c2a60182e 100755
--- 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
@@ -1,375 +1,375 @@
-package org.eclipse.swt.internal.image;
-
-/*
+package org.eclipse.swt.internal.image;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-import org.eclipse.swt.*;
-import org.eclipse.swt.graphics.*;
-import org.eclipse.swt.internal.Compatibility;
-
-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 = Compatibility.pow2(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;
- }
-}
-
-
-
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+import org.eclipse.swt.*;
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.internal.Compatibility;
+
+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 = Compatibility.pow2(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;
+ }
+}
+
+
+
}
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
index 4f3fd815e4..95a3651fc6 100755
--- 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
@@ -1,169 +1,169 @@
-package org.eclipse.swt.internal.image;
-
-/*
+package org.eclipse.swt.internal.image;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-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) {
- byte b1 = stream.getNextIdatByte();
- byte b2 = stream.getNextIdatByte();
- byte b3 = stream.getNextIdatByte();
- byte b4 = stream.getNextIdatByte();
- if (b1 != ~b3 || b2 != ~b4) stream.error();
- uncompressedBytesRemaining = (b1 & 0xFF) | ((b2 & 0xFF) << 8);
- } else if (compressionType == COMPRESSED_DYNAMIC) {
- huffmanTables = PngHuffmanTables.getDynamicTables(stream);
- } else {
- huffmanTables = PngHuffmanTables.getFixedTables();
- }
-}
-
-byte getNextByte() {
- 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];
- window[windowIndex] = value;
- copyBytesRemaining--;
-
- copyIndex++;
- windowIndex++;
- if (copyIndex == window.length) copyIndex = 0;
- if (windowIndex == window.length) windowIndex = 0;
-
- return value;
- }
-
- int value = huffmanTables.getNextLiteralValue(stream);
- if (value < END_OF_COMPRESSED_BLOCK) {
- window[windowIndex] = (byte) (value & 0xFF);
- windowIndex++;
- if (windowIndex >= window.length) windowIndex = 0;
- return (byte) (value & 0xFF);
- } else if (value == END_OF_COMPRESSED_BLOCK) {
- readNextBlockHeader();
- return 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;
- }
-}
-
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+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) {
+ byte b1 = stream.getNextIdatByte();
+ byte b2 = stream.getNextIdatByte();
+ byte b3 = stream.getNextIdatByte();
+ byte b4 = stream.getNextIdatByte();
+ if (b1 != ~b3 || b2 != ~b4) stream.error();
+ uncompressedBytesRemaining = (b1 & 0xFF) | ((b2 & 0xFF) << 8);
+ } else if (compressionType == COMPRESSED_DYNAMIC) {
+ huffmanTables = PngHuffmanTables.getDynamicTables(stream);
+ } else {
+ huffmanTables = PngHuffmanTables.getFixedTables();
+ }
+}
+
+byte getNextByte() {
+ 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];
+ window[windowIndex] = value;
+ copyBytesRemaining--;
+
+ copyIndex++;
+ windowIndex++;
+ if (copyIndex == window.length) copyIndex = 0;
+ if (windowIndex == window.length) windowIndex = 0;
+
+ return value;
+ }
+
+ int value = huffmanTables.getNextLiteralValue(stream);
+ if (value < END_OF_COMPRESSED_BLOCK) {
+ window[windowIndex] = (byte) (value & 0xFF);
+ windowIndex++;
+ if (windowIndex >= window.length) windowIndex = 0;
+ return (byte) (value & 0xFF);
+ } else if (value == END_OF_COMPRESSED_BLOCK) {
+ readNextBlockHeader();
+ return 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;
+ }
+}
+
}
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
index 752a39a076..c78f96c05c 100755
--- 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
@@ -1,90 +1,90 @@
-package org.eclipse.swt.internal.image;
-
-/*
+package org.eclipse.swt.internal.image;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-import org.eclipse.swt.*;
-import org.eclipse.swt.graphics.*;
-import org.eclipse.swt.internal.Compatibility;
-
-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 (Compatibility.pow2(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());
-}
-
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+import org.eclipse.swt.*;
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.internal.Compatibility;
+
+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 (Compatibility.pow2(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());
+}
+
}
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
index aeb8ca330f..560368ebd1 100755
--- 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
@@ -1,135 +1,135 @@
-package org.eclipse.swt.internal.image;
-
-/*
+package org.eclipse.swt.internal.image;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-import org.eclipse.swt.*;
-
-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;
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+import org.eclipse.swt.*;
+
+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;
+}
}
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
index e03ad73744..205cdd0fd3 100755
--- 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
@@ -1,665 +1,665 @@
-package org.eclipse.swt.internal.image;
-
-/*
+package org.eclipse.swt.internal.image;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-import org.eclipse.swt.*;
-import org.eclipse.swt.graphics.*;
-import java.io.*;
-
-final class WinBMPFileFormat extends FileFormat {
- 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;
-}
-boolean isFileFormat(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);
- if (depth == 24) return new PaletteData(0xFF, 0xFF00, 0xFF0000);
- return new PaletteData(0xFF00, 0xFF0000, 0xFF000000);
-}
-PaletteData paletteFromBytes(byte[] bytes, int numColors) {
- int bytesOffset = 0;
- RGB[] colors = new RGB[numColors];
- for (int i = 0; i < numColors; i++) {
- colors[i] = new RGB(bytes[bytesOffset + 2] & 0xFF,
- bytes[bytesOffset + 1] & 0xFF,
- bytes[bytesOffset] & 0xFF);
- bytesOffset += 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) || (image.depth == 32)))
- SWT.error(SWT.ERROR_UNSUPPORTED_DEPTH);
- int comp = this.compression;
- if (!((comp == 0) || ((comp == 1) && (image.depth == 8)) ||
- ((comp == 2) && (image.depth == 4))))
- SWT.error(SWT.ERROR_INVALID_IMAGE);
- PaletteData pal = image.palette;
- if ((image.depth == 16) || (image.depth == 24) || (image.depth == 32)) {
- if (!pal.isDirect)
- SWT.error(SWT.ERROR_INVALID_IMAGE);
- numCols = 0;
- rgbs = null;
- } else {
- if (pal.isDirect)
- SWT.error(SWT.ERROR_INVALID_IMAGE);
- numCols = pal.colors.length;
- rgbs = paletteToBytes(pal);
- }
- // Fill in file header, except for bfsize, which is done later.
- int headersSize = 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;
- }
-}
-
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+import org.eclipse.swt.*;
+import org.eclipse.swt.graphics.*;
+import java.io.*;
+
+final class WinBMPFileFormat extends FileFormat {
+ 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;
+}
+boolean isFileFormat(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);
+ if (depth == 24) return new PaletteData(0xFF, 0xFF00, 0xFF0000);
+ return new PaletteData(0xFF00, 0xFF0000, 0xFF000000);
+}
+PaletteData paletteFromBytes(byte[] bytes, int numColors) {
+ int bytesOffset = 0;
+ RGB[] colors = new RGB[numColors];
+ for (int i = 0; i < numColors; i++) {
+ colors[i] = new RGB(bytes[bytesOffset + 2] & 0xFF,
+ bytes[bytesOffset + 1] & 0xFF,
+ bytes[bytesOffset] & 0xFF);
+ bytesOffset += 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) || (image.depth == 32)))
+ SWT.error(SWT.ERROR_UNSUPPORTED_DEPTH);
+ int comp = this.compression;
+ if (!((comp == 0) || ((comp == 1) && (image.depth == 8)) ||
+ ((comp == 2) && (image.depth == 4))))
+ SWT.error(SWT.ERROR_INVALID_IMAGE);
+ PaletteData pal = image.palette;
+ if ((image.depth == 16) || (image.depth == 24) || (image.depth == 32)) {
+ if (!pal.isDirect)
+ SWT.error(SWT.ERROR_INVALID_IMAGE);
+ numCols = 0;
+ rgbs = null;
+ } else {
+ if (pal.isDirect)
+ SWT.error(SWT.ERROR_INVALID_IMAGE);
+ numCols = pal.colors.length;
+ rgbs = paletteToBytes(pal);
+ }
+ // Fill in file header, except for bfsize, which is done later.
+ int headersSize = 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
index ebac34ad41..1da16ed8d2 100755
--- 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
@@ -1,284 +1,284 @@
-package org.eclipse.swt.internal.image;
-
-/*
+package org.eclipse.swt.internal.image;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-import org.eclipse.swt.*;
-import org.eclipse.swt.graphics.*;
-import java.io.*;
-
-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;
-}
-boolean isFileFormat(LEDataInputStream stream) {
- try {
- byte[] header = new byte[4];
- stream.read(header);
- stream.unread(header);
- return header[0] == 0 && header[1] == 0 && header[2] == 1 && header[3] == 0;
- } catch (Exception e) {
- return false;
- }
-}
-boolean isValidIcon(ImageData i) {
- 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]; // the number of colors is in the low byte, but the high byte must be 0
- if (numColors == 0) numColors = 256; // this is specified: '00' represents '256' (0x100) colors
- if ((numColors != 2) && (numColors != 8) && (numColors != 16) &&
- (numColors != 32) && (numColors != 256))
- SWT.error(SWT.ERROR_INVALID_IMAGE);
- if (inputStream.getPosition() < iconHeader[6]) {
- // Seek to the specified offset
- try {
- inputStream.skip(iconHeader[6] - inputStream.getPosition());
- } catch (IOException e) {
- SWT.error(SWT.ERROR_IO, e);
- return null;
- }
- }
- byte[] infoHeader = new byte[WinBMPFileFormat.BMPHeaderFixedSize];
- try {
- inputStream.read(infoHeader);
- } catch (IOException e) {
- SWT.error(SWT.ERROR_IO, e);
- }
- if (((infoHeader[12] & 0xFF) | ((infoHeader[13] & 0xFF) << 8)) != 1)
- SWT.error(SWT.ERROR_INVALID_IMAGE);
- int infoWidth = (infoHeader[4] & 0xFF) | ((infoHeader[5] & 0xFF) << 8) | ((infoHeader[6] & 0xFF) << 16) | ((infoHeader[7] & 0xFF) << 24);
- int infoHeight = (infoHeader[8] & 0xFF) | ((infoHeader[9] & 0xFF) << 8) | ((infoHeader[10] & 0xFF) << 16) | ((infoHeader[11] & 0xFF) << 24);
- int bitCount = (infoHeader[14] & 0xFF) | ((infoHeader[15] & 0xFF) << 8);
- if (height == infoHeight && bitCount == 1) height /= 2;
- if (!((width == infoWidth) && (height * 2 == infoHeight) &&
- ((bitCount == 1) || (bitCount == 4) || (bitCount == 8))))
- 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);
- }
-}
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+import org.eclipse.swt.*;
+import org.eclipse.swt.graphics.*;
+import java.io.*;
+
+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;
+}
+boolean isFileFormat(LEDataInputStream stream) {
+ try {
+ byte[] header = new byte[4];
+ stream.read(header);
+ stream.unread(header);
+ return header[0] == 0 && header[1] == 0 && header[2] == 1 && header[3] == 0;
+ } catch (Exception e) {
+ return false;
+ }
+}
+boolean isValidIcon(ImageData i) {
+ 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]; // the number of colors is in the low byte, but the high byte must be 0
+ if (numColors == 0) numColors = 256; // this is specified: '00' represents '256' (0x100) colors
+ if ((numColors != 2) && (numColors != 8) && (numColors != 16) &&
+ (numColors != 32) && (numColors != 256))
+ SWT.error(SWT.ERROR_INVALID_IMAGE);
+ if (inputStream.getPosition() < iconHeader[6]) {
+ // Seek to the specified offset
+ try {
+ inputStream.skip(iconHeader[6] - inputStream.getPosition());
+ } catch (IOException e) {
+ SWT.error(SWT.ERROR_IO, e);
+ return null;
+ }
+ }
+ byte[] infoHeader = new byte[WinBMPFileFormat.BMPHeaderFixedSize];
+ try {
+ inputStream.read(infoHeader);
+ } catch (IOException e) {
+ SWT.error(SWT.ERROR_IO, e);
+ }
+ if (((infoHeader[12] & 0xFF) | ((infoHeader[13] & 0xFF) << 8)) != 1)
+ SWT.error(SWT.ERROR_INVALID_IMAGE);
+ int infoWidth = (infoHeader[4] & 0xFF) | ((infoHeader[5] & 0xFF) << 8) | ((infoHeader[6] & 0xFF) << 16) | ((infoHeader[7] & 0xFF) << 24);
+ int infoHeight = (infoHeader[8] & 0xFF) | ((infoHeader[9] & 0xFF) << 8) | ((infoHeader[10] & 0xFF) << 16) | ((infoHeader[11] & 0xFF) << 24);
+ int bitCount = (infoHeader[14] & 0xFF) | ((infoHeader[15] & 0xFF) << 8);
+ if (height == infoHeight && bitCount == 1) height /= 2;
+ if (!((width == infoWidth) && (height * 2 == infoHeight) &&
+ ((bitCount == 1) || (bitCount == 4) || (bitCount == 8))))
+ 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/layout/FillLayout.java b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/layout/FillLayout.java
index fd82c6a586..1b27a2774d 100755
--- 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
@@ -1,111 +1,111 @@
-package org.eclipse.swt.layout;
-
-/*
+package org.eclipse.swt.layout;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-import org.eclipse.swt.*;
-import org.eclipse.swt.graphics.*;
-import org.eclipse.swt.widgets.*;
-
-/**
- * <code>FillLayout</code> is the simplest layout class. It lays out
- * controls in a single row or column, forcing them to be the same size.
- * <p>
- * Initially, the controls will all be as tall as the tallest control,
- * and as wide as the widest. <code>FillLayout</code> does not wrap,
- * and you cannot specify margins or spacing. You might use it to
- * lay out buttons in a task bar or tool bar, or to stack checkboxes
- * in a <code>Group</code>. <code>FillLayout</code> can also be used
- * when a <code>Composite</code> only has one child. For example,
- * if a <code>Shell</code> has a single <code>Group</code> child,
- * <code>FillLayout</code> will cause the <code>Group</code> to
- * completely fill the <code>Shell</code>.
- * </p>
- * <p>
- * Example code: first a <code>FillLayout</code> is created and
- * its type field is set, and then the layout is set into the
- * <code>Composite</code>. Note that in a <code>FillLayout</code>,
- * children are always the same size, and they fill all available space.
- * <pre>
- * FillLayout fillLayout = new FillLayout();
- * fillLayout.type = SWT.VERTICAL;
- * shell.setLayout(fillLayout);
- * </pre>
- * </p>
- */
-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;
-
-/**
- * Constructs a new instance of this class.
- */
-public FillLayout () {
-}
-
-/**
- * Constructs a new instance of this class given the type.
- *
- * @param type the type of fill layout
- *
- * @since 2.0
- */
-public FillLayout (int type) {
- this.type = type;
-}
-
-protected Point computeSize (Composite composite, int wHint, int hHint, boolean flushCache) {
- Control [] children = composite.getChildren ();
- int count = children.length;
- int maxWidth = 0, maxHeight = 0;
- for (int i=0; i<count; i++) {
- Control child = children [i];
- 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;
- }
-}
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+import org.eclipse.swt.*;
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.widgets.*;
+
+/**
+ * <code>FillLayout</code> is the simplest layout class. It lays out
+ * controls in a single row or column, forcing them to be the same size.
+ * <p>
+ * Initially, the controls will all be as tall as the tallest control,
+ * and as wide as the widest. <code>FillLayout</code> does not wrap,
+ * and you cannot specify margins or spacing. You might use it to
+ * lay out buttons in a task bar or tool bar, or to stack checkboxes
+ * in a <code>Group</code>. <code>FillLayout</code> can also be used
+ * when a <code>Composite</code> only has one child. For example,
+ * if a <code>Shell</code> has a single <code>Group</code> child,
+ * <code>FillLayout</code> will cause the <code>Group</code> to
+ * completely fill the <code>Shell</code>.
+ * </p>
+ * <p>
+ * Example code: first a <code>FillLayout</code> is created and
+ * its type field is set, and then the layout is set into the
+ * <code>Composite</code>. Note that in a <code>FillLayout</code>,
+ * children are always the same size, and they fill all available space.
+ * <pre>
+ * FillLayout fillLayout = new FillLayout();
+ * fillLayout.type = SWT.VERTICAL;
+ * shell.setLayout(fillLayout);
+ * </pre>
+ * </p>
+ */
+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;
+
+/**
+ * Constructs a new instance of this class.
+ */
+public FillLayout () {
+}
+
+/**
+ * Constructs a new instance of this class given the type.
+ *
+ * @param type the type of fill layout
+ *
+ * @since 2.0
+ */
+public FillLayout (int type) {
+ this.type = type;
+}
+
+protected Point computeSize (Composite composite, int wHint, int hHint, boolean flushCache) {
+ Control [] children = composite.getChildren ();
+ int count = children.length;
+ int maxWidth = 0, maxHeight = 0;
+ for (int i=0; i<count; i++) {
+ Control child = children [i];
+ 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/FormAttachment.java b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/layout/FormAttachment.java
index 109a78a30c..e9fafdb6ff 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/layout/FormAttachment.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/layout/FormAttachment.java
@@ -1,261 +1,261 @@
-package org.eclipse.swt.layout;
-
-/*
+package org.eclipse.swt.layout;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-import org.eclipse.swt.*;
-import org.eclipse.swt.widgets.*;
-
-/**
- * Instances of this class are used to define the edges of a control
- * within a <code>FormLayout</code>.
- * <p>
- * <code>FormAttachments</code> are set into the top, bottom, left,
- * and right fields of the <code>FormData</code> for a control.
- * For example:
- * <pre>
- * FormData data = new FormData();
- * data.top = new FormAttachment(0,5);
- * data.bottom = new FormAttachment(100,-5);
- * data.left = new FormAttachment(0,5);
- * data.right = new FormAttachment(100,-5);
- * button.setLayoutData(data);
- * </pre>
- * </p>
- * <p>
- * A <code>FormAttachment</code> defines where to attach the side of
- * a control by using the equation, y = ax + b. The "a" term represents
- * a fraction of the parent composite's width (from the left) or height
- * (from the top). It can be defined using a numerator and denominator,
- * or just a percentage value. If a percentage is used, the denominator
- * is set to 100. The "b" term in the equation represents an offset, in
- * pixels, from the attachment position. For example:
- * <pre>
- * FormAttachment attach = new FormAttachment (20, -5);
- * </pre>
- * specifies that the side to which the <code>FormAttachment</code>
- * object belongs will lie at 20% of the parent composite, minus 5 pixels.
- * </p>
- * <p>
- * Control sides can also be attached to another control.
- * For example:
- * <pre>
- * FormAttachment attach = new FormAttachment (button, 10);
- * </pre>
- * specifies that the side to which the <code>FormAttachment</code>
- * object belongs will lie in the same position as the adjacent side of
- * the <code>button</code> control, plus 10 pixels. The control side can
- * also be attached to the opposite side of the specified control.
- * For example:
- * <pre>
- * FormData data = new FormData ();
- * data.left = new FormAttachment (button, 0, SWT.LEFT);
- * </pre>
- * specifies that the left side of the control will lie in the same position
- * as the left side of the <code>button</code> control. The control can also
- * be attached in a position that will center the control on the specified
- * control. For example:
- * <pre>
- * data.left = new FormAttachment (button, 0, SWT.CENTER);
- * </pre>
- * specifies that the left side of the control will be positioned so that it is
- * centered between the left and right sides of the <code>button</code> control.
- * If the alignment is not specified, the default is to attach to the adjacent side.
- * </p>
- *
- * @see FormLayout
- * @see FormData
- *
- * @since 2.0
- */
-public final class FormAttachment {
- /**
- * numerator specifies the numerator of the "a" term in the
- * equation, y = ax + b, which defines the attachment.
- */
- public int numerator;
- /**
- * denominator specifies the denominator of the "a" term in the
- * equation, y = ax + b, which defines the attachment.
- *
- * The default value is 100.
- */
- public int denominator = 100;
- /**
- * offset specifies the offset, in pixels, of the control side
- * from the attachment position.
- * If the offset is positive, then the control side is offset
- * to the right of or below the attachment position. If it is
- * negative, then the control side is offset to the left of or
- * above the attachment position.
- *
- * This is equivalent to the "b" term in the equation y = ax + b.
- * The default value is 0.
- */
- public int offset;
- /**
- * control specifies the control to which the control side is
- * attached.
- */
- public Control control;
- /**
- * alignment specifies the alignment of the control side that is
- * attached to a control.
- * For top and bottom attachments, TOP, BOTTOM and CENTER are used. For left
- * and right attachments, LEFT, RIGHT and CENTER are used. If any other case
- * occurs, the default will be used instead.
- *
- * Possible values are:
- *
- * TOP: Attach the side to the top side of the specified control.
- * BOTTOM : Attach the side to the bottom side of the specified control.
- * LEFT: Attach the side to the left side of the specified control.
- * RIGHT: Attach the side to the right side of the specified control.
- * CENTER: Attach the side at a position which will center the control on
- * the specified control.
- * DEFAULT: Attach the side to the adjacent side of the specified control.
- */
- public int alignment;
-
-FormAttachment () {
-}
-
-/**
- * Constructs a new instance of this class given a numerator
- * and denominator and an offset. The position of the side is
- * given by the fraction of the form defined by the numerator
- * and denominator.
- *
- * @param numerator the numerator of the position
- * @param denominator the denominator of the position
- * @param offset the offset of the side from the position
- */
-public FormAttachment (int numerator, int denominator, int offset) {
- if (denominator == 0) SWT.error (SWT.ERROR_CANNOT_BE_ZERO);
- this.numerator = numerator;
- this.denominator = denominator;
- this.offset = offset;
-}
-
-/**
- * Constructs a new instance of this class given a numerator
- * and an offset. Since no denominator is specified, the default
- * is to read the numerator as a percentage of the form, with a
- * denominator of 100.
- *
- * @param numerator the percentage of the position
- * @param offset the offset of the side from the position
- */
-public FormAttachment (int numerator, int offset) {
- this (numerator, 100, offset);
-}
-
-/**
- * Constructs a new instance of this class given a control,
- * an offset and an alignment.
- *
- * @param control the control the side is attached to
- * @param offset the offset of the side from the control
- * @param alignment the alignment of the side to the control it is attached to
- */
-public FormAttachment (Control control, int offset, int alignment) {
- this.control = control;
- this.offset = offset;
- this.alignment = alignment;
-}
-
-/**
- * Constructs a new instance of this class given a control
- * and an offset. Since no alignment is specified, the default
- * alignment is to attach the side to the adjacent side of the
- * specified control.
- *
- * @param control the control the side is attached to
- * @param offset the offset of the side from the control
- */
-public FormAttachment (Control control, int offset) {
- this (control, offset, SWT.DEFAULT);
-}
-
-/**
- * Constructs a new instance of this class given a control.
- * Since no alignment is specified, the default alignment is
- * to attach the side to the adjacent side of the specified
- * control. Since no offset is specified, an offset of 0 is
- * used.
- *
- * @param control the control the side is attached to
- */
-public FormAttachment (Control control) {
- this (control, 0, SWT.DEFAULT);
-}
-
-FormAttachment divide (int value) {
- return new FormAttachment (numerator, denominator * value, offset / value);
-}
-
-int gcd (int m, int n) {
- int temp;
- m = Math.abs (m); n = Math.abs (n);
- if (m < n) {
- temp = m;
- m = n;
- n = temp;
- }
- while (n != 0){
- temp = m;
- m = n;
- n = temp % n;
- }
- return m;
-}
-
-FormAttachment minus (FormAttachment attachment) {
- FormAttachment solution = new FormAttachment ();
- solution.numerator = numerator * attachment.denominator - denominator * attachment.numerator;
- solution.denominator = denominator * attachment.denominator;
- int gcd = gcd (solution.denominator, solution.numerator);
- solution.numerator = solution.numerator / gcd;
- solution.denominator = solution.denominator / gcd;
- solution.offset = offset - attachment.offset;
- return solution;
-}
-
-FormAttachment minus (int value) {
- return new FormAttachment (numerator, denominator, offset - value);
-}
-
-FormAttachment plus (FormAttachment attachment) {
- FormAttachment solution = new FormAttachment ();
- solution.numerator = numerator * attachment.denominator + denominator * attachment.numerator;
- solution.denominator = denominator * attachment.denominator;
- int gcd = gcd (solution.denominator, solution.numerator);
- solution.numerator = solution.numerator / gcd;
- solution.denominator = solution.denominator / gcd;
- solution.offset = offset + attachment.offset;
- return solution;
-}
-
-FormAttachment plus (int value) {
- return new FormAttachment (numerator, denominator, offset + value);
-}
-
-int solveX (int value) {
- if (denominator == 0) SWT.error (SWT.ERROR_CANNOT_BE_ZERO);
- return ((numerator * value) / denominator) + offset;
-}
-
-int solveY (int value) {
- if (numerator == 0) SWT.error (SWT.ERROR_CANNOT_BE_ZERO);
- return (value - offset) * denominator / numerator;
-}
-
-public String toString () {
- String string = control != null ? control.toString () : numerator + "/" + denominator;
- return "y = (" + string + (offset >= 0 ? ")x + " + offset: ")x - " + (-offset));
-}
-
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+import org.eclipse.swt.*;
+import org.eclipse.swt.widgets.*;
+
+/**
+ * Instances of this class are used to define the edges of a control
+ * within a <code>FormLayout</code>.
+ * <p>
+ * <code>FormAttachments</code> are set into the top, bottom, left,
+ * and right fields of the <code>FormData</code> for a control.
+ * For example:
+ * <pre>
+ * FormData data = new FormData();
+ * data.top = new FormAttachment(0,5);
+ * data.bottom = new FormAttachment(100,-5);
+ * data.left = new FormAttachment(0,5);
+ * data.right = new FormAttachment(100,-5);
+ * button.setLayoutData(data);
+ * </pre>
+ * </p>
+ * <p>
+ * A <code>FormAttachment</code> defines where to attach the side of
+ * a control by using the equation, y = ax + b. The "a" term represents
+ * a fraction of the parent composite's width (from the left) or height
+ * (from the top). It can be defined using a numerator and denominator,
+ * or just a percentage value. If a percentage is used, the denominator
+ * is set to 100. The "b" term in the equation represents an offset, in
+ * pixels, from the attachment position. For example:
+ * <pre>
+ * FormAttachment attach = new FormAttachment (20, -5);
+ * </pre>
+ * specifies that the side to which the <code>FormAttachment</code>
+ * object belongs will lie at 20% of the parent composite, minus 5 pixels.
+ * </p>
+ * <p>
+ * Control sides can also be attached to another control.
+ * For example:
+ * <pre>
+ * FormAttachment attach = new FormAttachment (button, 10);
+ * </pre>
+ * specifies that the side to which the <code>FormAttachment</code>
+ * object belongs will lie in the same position as the adjacent side of
+ * the <code>button</code> control, plus 10 pixels. The control side can
+ * also be attached to the opposite side of the specified control.
+ * For example:
+ * <pre>
+ * FormData data = new FormData ();
+ * data.left = new FormAttachment (button, 0, SWT.LEFT);
+ * </pre>
+ * specifies that the left side of the control will lie in the same position
+ * as the left side of the <code>button</code> control. The control can also
+ * be attached in a position that will center the control on the specified
+ * control. For example:
+ * <pre>
+ * data.left = new FormAttachment (button, 0, SWT.CENTER);
+ * </pre>
+ * specifies that the left side of the control will be positioned so that it is
+ * centered between the left and right sides of the <code>button</code> control.
+ * If the alignment is not specified, the default is to attach to the adjacent side.
+ * </p>
+ *
+ * @see FormLayout
+ * @see FormData
+ *
+ * @since 2.0
+ */
+public final class FormAttachment {
+ /**
+ * numerator specifies the numerator of the "a" term in the
+ * equation, y = ax + b, which defines the attachment.
+ */
+ public int numerator;
+ /**
+ * denominator specifies the denominator of the "a" term in the
+ * equation, y = ax + b, which defines the attachment.
+ *
+ * The default value is 100.
+ */
+ public int denominator = 100;
+ /**
+ * offset specifies the offset, in pixels, of the control side
+ * from the attachment position.
+ * If the offset is positive, then the control side is offset
+ * to the right of or below the attachment position. If it is
+ * negative, then the control side is offset to the left of or
+ * above the attachment position.
+ *
+ * This is equivalent to the "b" term in the equation y = ax + b.
+ * The default value is 0.
+ */
+ public int offset;
+ /**
+ * control specifies the control to which the control side is
+ * attached.
+ */
+ public Control control;
+ /**
+ * alignment specifies the alignment of the control side that is
+ * attached to a control.
+ * For top and bottom attachments, TOP, BOTTOM and CENTER are used. For left
+ * and right attachments, LEFT, RIGHT and CENTER are used. If any other case
+ * occurs, the default will be used instead.
+ *
+ * Possible values are:
+ *
+ * TOP: Attach the side to the top side of the specified control.
+ * BOTTOM : Attach the side to the bottom side of the specified control.
+ * LEFT: Attach the side to the left side of the specified control.
+ * RIGHT: Attach the side to the right side of the specified control.
+ * CENTER: Attach the side at a position which will center the control on
+ * the specified control.
+ * DEFAULT: Attach the side to the adjacent side of the specified control.
+ */
+ public int alignment;
+
+FormAttachment () {
+}
+
+/**
+ * Constructs a new instance of this class given a numerator
+ * and denominator and an offset. The position of the side is
+ * given by the fraction of the form defined by the numerator
+ * and denominator.
+ *
+ * @param numerator the numerator of the position
+ * @param denominator the denominator of the position
+ * @param offset the offset of the side from the position
+ */
+public FormAttachment (int numerator, int denominator, int offset) {
+ if (denominator == 0) SWT.error (SWT.ERROR_CANNOT_BE_ZERO);
+ this.numerator = numerator;
+ this.denominator = denominator;
+ this.offset = offset;
+}
+
+/**
+ * Constructs a new instance of this class given a numerator
+ * and an offset. Since no denominator is specified, the default
+ * is to read the numerator as a percentage of the form, with a
+ * denominator of 100.
+ *
+ * @param numerator the percentage of the position
+ * @param offset the offset of the side from the position
+ */
+public FormAttachment (int numerator, int offset) {
+ this (numerator, 100, offset);
+}
+
+/**
+ * Constructs a new instance of this class given a control,
+ * an offset and an alignment.
+ *
+ * @param control the control the side is attached to
+ * @param offset the offset of the side from the control
+ * @param alignment the alignment of the side to the control it is attached to
+ */
+public FormAttachment (Control control, int offset, int alignment) {
+ this.control = control;
+ this.offset = offset;
+ this.alignment = alignment;
+}
+
+/**
+ * Constructs a new instance of this class given a control
+ * and an offset. Since no alignment is specified, the default
+ * alignment is to attach the side to the adjacent side of the
+ * specified control.
+ *
+ * @param control the control the side is attached to
+ * @param offset the offset of the side from the control
+ */
+public FormAttachment (Control control, int offset) {
+ this (control, offset, SWT.DEFAULT);
+}
+
+/**
+ * Constructs a new instance of this class given a control.
+ * Since no alignment is specified, the default alignment is
+ * to attach the side to the adjacent side of the specified
+ * control. Since no offset is specified, an offset of 0 is
+ * used.
+ *
+ * @param control the control the side is attached to
+ */
+public FormAttachment (Control control) {
+ this (control, 0, SWT.DEFAULT);
+}
+
+FormAttachment divide (int value) {
+ return new FormAttachment (numerator, denominator * value, offset / value);
+}
+
+int gcd (int m, int n) {
+ int temp;
+ m = Math.abs (m); n = Math.abs (n);
+ if (m < n) {
+ temp = m;
+ m = n;
+ n = temp;
+ }
+ while (n != 0){
+ temp = m;
+ m = n;
+ n = temp % n;
+ }
+ return m;
+}
+
+FormAttachment minus (FormAttachment attachment) {
+ FormAttachment solution = new FormAttachment ();
+ solution.numerator = numerator * attachment.denominator - denominator * attachment.numerator;
+ solution.denominator = denominator * attachment.denominator;
+ int gcd = gcd (solution.denominator, solution.numerator);
+ solution.numerator = solution.numerator / gcd;
+ solution.denominator = solution.denominator / gcd;
+ solution.offset = offset - attachment.offset;
+ return solution;
+}
+
+FormAttachment minus (int value) {
+ return new FormAttachment (numerator, denominator, offset - value);
+}
+
+FormAttachment plus (FormAttachment attachment) {
+ FormAttachment solution = new FormAttachment ();
+ solution.numerator = numerator * attachment.denominator + denominator * attachment.numerator;
+ solution.denominator = denominator * attachment.denominator;
+ int gcd = gcd (solution.denominator, solution.numerator);
+ solution.numerator = solution.numerator / gcd;
+ solution.denominator = solution.denominator / gcd;
+ solution.offset = offset + attachment.offset;
+ return solution;
+}
+
+FormAttachment plus (int value) {
+ return new FormAttachment (numerator, denominator, offset + value);
+}
+
+int solveX (int value) {
+ if (denominator == 0) SWT.error (SWT.ERROR_CANNOT_BE_ZERO);
+ return ((numerator * value) / denominator) + offset;
+}
+
+int solveY (int value) {
+ if (numerator == 0) SWT.error (SWT.ERROR_CANNOT_BE_ZERO);
+ return (value - offset) * denominator / numerator;
+}
+
+public String toString () {
+ String string = control != null ? control.toString () : numerator + "/" + denominator;
+ return "y = (" + string + (offset >= 0 ? ")x + " + offset: ")x - " + (-offset));
+}
+
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/layout/FormLayout.java b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/layout/FormLayout.java
index 50b1e09c9b..393d0f0907 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/layout/FormLayout.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/layout/FormLayout.java
@@ -10,8 +10,8 @@ package org.eclipse.swt.layout;
import org.eclipse.swt.*;
import org.eclipse.swt.graphics.*;
import org.eclipse.swt.widgets.*;
-
-/**
+
+/**
* Instances of this class control the position and size of the
* children of a composite control by using <code>FormAttachments</code>
* to optionally configure the left, top, right and bottom edge of
@@ -80,7 +80,7 @@ import org.eclipse.swt.widgets.*;
*
* @since 2.0
*
- */
+ */
public final class FormLayout extends Layout {
/**
* marginWidth specifies the number of pixels of horizontal margin
@@ -253,5 +253,5 @@ Point layout (Composite composite, boolean move, int x, int y, int width, int he
}
return move ? null : new Point (width, 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
index 184320e044..646d50ff8d 100755
--- 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
@@ -1,195 +1,195 @@
-package org.eclipse.swt.layout;
-
-/*
+package org.eclipse.swt.layout;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-import org.eclipse.swt.*;
-
-/**
- * <code>GridData</code> is the layout data object associated with
- * <code>GridLayout</code>. To set a <code>GridData</code> object into a
- * control, you use the <code>setLayoutData ()</code> method.
- * <p>
- * There are two ways to create a <code>GridData</code> object with certain
- * fields set. The first is to set the fields directly, like this:
- * <pre>
- * GridData gridData = new GridData();
- * gridData.horizontalAlignment = GridData.FILL;
- * gridData.grabExcessHorizontalSpace = true;
- * button1.setLayoutData(gridData);
- * </pre>
- * The second is to take advantage of convenience style bits defined
- * by <code>GridData</code>:
- * <pre>
- * button1.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.GRAB_HORIZONTAL));
- * </pre>
- * </p>
- * <p>
- * NOTE: Do not reuse <code>GridData</code> objects. Every control in a
- * <code>Composite</code> that is managed by a <code>GridLayout</code>
- * must have a unique <code>GridData</code> object. If the layout data
- * for a control in a <code>GridLayout</code> is null at layout time,
- * a unique <code>GridData</code> object is created for it.
- * </p>
- *
- * @see GridLayout
- */
-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
- /**
- * FILL_VERTICAL = VERTICAL_ALIGN_FILL | GRAB_VERTICAL
- */
- public static final int FILL_VERTICAL = VERTICAL_ALIGN_FILL | GRAB_VERTICAL;
- /**
- * FILL_HORIZONTAL = HORIZONTAL_ALIGN_FILL | GRAB_HORIZONTAL
- */
- public static final int FILL_HORIZONTAL = HORIZONTAL_ALIGN_FILL | GRAB_HORIZONTAL;
- /**
- * FILL_BOTH = FILL_VERTICAL | FILL_HORIZONTAL
- */
- public static final int FILL_BOTH = FILL_VERTICAL | FILL_HORIZONTAL;
-
- // Private
- int childIndex;
- boolean isItemData = true;
- int hSpan;
-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;
-}
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+import org.eclipse.swt.*;
+
+/**
+ * <code>GridData</code> is the layout data object associated with
+ * <code>GridLayout</code>. To set a <code>GridData</code> object into a
+ * control, you use the <code>setLayoutData ()</code> method.
+ * <p>
+ * There are two ways to create a <code>GridData</code> object with certain
+ * fields set. The first is to set the fields directly, like this:
+ * <pre>
+ * GridData gridData = new GridData();
+ * gridData.horizontalAlignment = GridData.FILL;
+ * gridData.grabExcessHorizontalSpace = true;
+ * button1.setLayoutData(gridData);
+ * </pre>
+ * The second is to take advantage of convenience style bits defined
+ * by <code>GridData</code>:
+ * <pre>
+ * button1.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.GRAB_HORIZONTAL));
+ * </pre>
+ * </p>
+ * <p>
+ * NOTE: Do not reuse <code>GridData</code> objects. Every control in a
+ * <code>Composite</code> that is managed by a <code>GridLayout</code>
+ * must have a unique <code>GridData</code> object. If the layout data
+ * for a control in a <code>GridLayout</code> is null at layout time,
+ * a unique <code>GridData</code> object is created for it.
+ * </p>
+ *
+ * @see GridLayout
+ */
+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
+ /**
+ * FILL_VERTICAL = VERTICAL_ALIGN_FILL | GRAB_VERTICAL
+ */
+ public static final int FILL_VERTICAL = VERTICAL_ALIGN_FILL | GRAB_VERTICAL;
+ /**
+ * FILL_HORIZONTAL = HORIZONTAL_ALIGN_FILL | GRAB_HORIZONTAL
+ */
+ public static final int FILL_HORIZONTAL = HORIZONTAL_ALIGN_FILL | GRAB_HORIZONTAL;
+ /**
+ * FILL_BOTH = FILL_VERTICAL | FILL_HORIZONTAL
+ */
+ public static final int FILL_BOTH = FILL_VERTICAL | FILL_HORIZONTAL;
+
+ // Private
+ int childIndex;
+ boolean isItemData = true;
+ int hSpan;
+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
index a6c5e55583..fdc5914afe 100755
--- 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
@@ -1,691 +1,691 @@
-package org.eclipse.swt.layout;
-
-/*
+package org.eclipse.swt.layout;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-import org.eclipse.swt.*;
-import org.eclipse.swt.widgets.*;
-import org.eclipse.swt.graphics.*;
-import java.util.Enumeration;
-import java.util.Hashtable;
-import java.util.Vector;
-
-/**
- * Instances of this class lay out the control children of a
- * <code>Composite</code> in a grid.
- * <p>
- * <code>GridLayout</code> has a number of configuration fields, and the
- * controls it lays out can have an associated layout data object, called
- * <code>GridData</code>. The power of <code>GridLayout</code> lies in the
- * ability to configure <code>GridData</code> for each control in the layout.
- * </p>
- * <p>
- * The following code creates a shell managed by a <code>GridLayout</code>
- * with 3 columns:
- * <pre>
- * Display display = new Display();
- * Shell shell = new Shell(display);
- * GridLayout gridLayout = new GridLayout();
- * gridLayout.numColumns = 3;
- * shell.setLayout(gridLayout);
- * </pre>
- * The <code>numColumns</code> field is the most important field in a
- * <code>GridLayout</code>. Widgets are laid out in columns from left
- * to right, and a new row is created when <code>numColumns</code> + 1
- * controls are added to the <code>Composite<code>.
- * </p>
- *
- * @see GridData
- */
-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.
- Vector grid = new Vector();
- int [] pixelColumnWidths;
- int [] pixelRowHeights;
- int [] expandableColumns;
- int [] expandableRows;
-
-/**
- * Constructs a new instance of this class.
- */
-public GridLayout() {
-}
-
-/**
- * Constructs a new instance of this class given the
- * number of columns, and whether or not the columns
- * should be forced to have the same width.
- *
- * @param numColumns the number of columns in the grid
- * @param makeColumnsEqualWidth whether or not the columns will have equal width
- *
- * @since 2.0
- */
-public GridLayout(int numColumns, boolean makeColumnsEqualWidth) {
- this.numColumns = numColumns;
- this.makeColumnsEqualWidth = makeColumnsEqualWidth;
-}
-
-void adjustGridDimensions(Composite composite, boolean flushCache) {
- // Ensure that controls 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.hSpan > 1) {
- Control child = composite.getChildren()[spec.childIndex];
- Point extent = child.computeSize(spec.widthHint, spec.heightHint, flushCache);
-
- // Calculate the size of the control's spanned columns.
- int lastSpanIndex = column + spec.hSpan;
- 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 control, 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.hSpan - 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 control'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 control'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 control'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 control, 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 control'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 control'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 control.
- 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.hSpan == 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 control.
- 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()) {
- 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 control grabs excess horizontal space, the last column that the control spans
- // will be expandable. Similarly, if a control grabs excess vertical space, the
- // last row that the control 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.hSpan - 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 controls.
- 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);
-
- if (flushCache) {
- // Cause the grid and its related information to be calculated
- // again.
- grid.removeAllElements();
- }
- return computeLayoutSize(composite, wHint, hHint, flushCache);
-}
-Point getFirstEmptyCell(int row, int column) {
- GridData[] rowData = (GridData[]) grid.elementAt(row);
- while (column < numColumns && rowData[column] != null) {
- column++;
- }
- if (column == numColumns) {
- row++;
- column = 0;
- if (row == grid.size()) {
- grid.addElement(emptyRow());
- }
- return getFirstEmptyCell(row, column);
- }
- return new Point(row, column);
-}
-Point getLastEmptyCell(int row, int column) {
- GridData[] rowData = (GridData[])grid.elementAt(row);
- while (column < numColumns && rowData[column] == null ) {
- column++;
- }
- return new Point(row, column - 1);
-}
-Point getCell(int row, int column, int width, int height) {
- Point start = getFirstEmptyCell(row, column);
- Point end = getLastEmptyCell(start.x, start.y);
- if (end.y + 1 - start.y >= width) return start;
- GridData[] rowData = (GridData[]) grid.elementAt(start.x);
- for (int j = start.y; j < end.y + 1; j++) {
- GridData spacerSpec = new GridData();
- spacerSpec.isItemData = false;
- rowData[j] = spacerSpec;
- }
- return getCell(end.x, end.y, width, height);
-}
-void createGrid(Composite composite) {
- int row, column, rowFill, columnFill;
- 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();
- if (spec == null) {
- spec = new GridData();
- child.setLayoutData(spec);
- }
- spec.hSpan = Math.min(spec.horizontalSpan, numColumns);
- Point p = getCell(row, column, spec.hSpan, spec.verticalSpan);
- row = p.x; column = p.y;
-
- // 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.hSpan - 1;
- for (int r = 1; r <= rowFill; r++) {
- for (int c = 0; c < spec.hSpan; 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.hSpan - 1;
- }
-
- // Fill out empty grid cells with spacers.
- for (int r = row; r < grid.size(); r++) {
- GridData[] rowData = (GridData[]) grid.elementAt(r);
- for (int c = 0; c < numColumns; c++) {
- if (rowData[c] == null) {
- spacerSpec = new GridData();
- spacerSpec.isItemData = false;
- rowData[c] = spacerSpec;
- }
- }
- }
-}
-GridData[] emptyRow() {
- GridData[] row = new GridData[numColumns];
- for (int i = 0; i < numColumns; i++) {
- row[i] = null;}
- return row;
-}
-protected void layout(Composite composite, boolean flushCache) {
- int[] columnWidths;
- int[] rowHeights;
- int 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;
- 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 control 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];
- if (spec.hSpan == 1) {
- 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];
- if (spec.verticalSpan == 1) {
- 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 control 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.hSpan; 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 control.
- if (hAlign == GridData.CENTER) {
- widgetX = widgetX + (spannedWidth / 2) - (childExtent.x / 2);
- } else
- if (hAlign == GridData.END) {
- widgetX = widgetX + spannedWidth - childExtent.x - spec.horizontalIndent;
- } else {
- widgetX = widgetX + spec.horizontalIndent;
- }
- if (hAlign == GridData.FILL) {
- widgetW = spannedWidth - spec.horizontalIndent;
- widgetX = columnX + spec.horizontalIndent;
- } else {
- widgetW = childExtent.x;
- }
-
- // Calculate the y and height values for the control.
- vAlign = spec.verticalAlignment;
- widgetY = rowY;
- if (vAlign == GridData.CENTER) {
- widgetY = widgetY + (spannedHeight / 2) - (childExtent.y / 2);
- } else
- if (vAlign == GridData.END) {
- widgetY = widgetY + spannedHeight - childExtent.y;
- }
- if (vAlign == GridData.FILL) {
- widgetH = spannedHeight;
- widgetY = rowY;
- } else {
- widgetH = childExtent.y;
- }
- // Place the control.
- 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;
- }
-}
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+import org.eclipse.swt.*;
+import org.eclipse.swt.widgets.*;
+import org.eclipse.swt.graphics.*;
+import java.util.Enumeration;
+import java.util.Hashtable;
+import java.util.Vector;
+
+/**
+ * Instances of this class lay out the control children of a
+ * <code>Composite</code> in a grid.
+ * <p>
+ * <code>GridLayout</code> has a number of configuration fields, and the
+ * controls it lays out can have an associated layout data object, called
+ * <code>GridData</code>. The power of <code>GridLayout</code> lies in the
+ * ability to configure <code>GridData</code> for each control in the layout.
+ * </p>
+ * <p>
+ * The following code creates a shell managed by a <code>GridLayout</code>
+ * with 3 columns:
+ * <pre>
+ * Display display = new Display();
+ * Shell shell = new Shell(display);
+ * GridLayout gridLayout = new GridLayout();
+ * gridLayout.numColumns = 3;
+ * shell.setLayout(gridLayout);
+ * </pre>
+ * The <code>numColumns</code> field is the most important field in a
+ * <code>GridLayout</code>. Widgets are laid out in columns from left
+ * to right, and a new row is created when <code>numColumns</code> + 1
+ * controls are added to the <code>Composite<code>.
+ * </p>
+ *
+ * @see GridData
+ */
+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.
+ Vector grid = new Vector();
+ int [] pixelColumnWidths;
+ int [] pixelRowHeights;
+ int [] expandableColumns;
+ int [] expandableRows;
+
+/**
+ * Constructs a new instance of this class.
+ */
+public GridLayout() {
+}
+
+/**
+ * Constructs a new instance of this class given the
+ * number of columns, and whether or not the columns
+ * should be forced to have the same width.
+ *
+ * @param numColumns the number of columns in the grid
+ * @param makeColumnsEqualWidth whether or not the columns will have equal width
+ *
+ * @since 2.0
+ */
+public GridLayout(int numColumns, boolean makeColumnsEqualWidth) {
+ this.numColumns = numColumns;
+ this.makeColumnsEqualWidth = makeColumnsEqualWidth;
+}
+
+void adjustGridDimensions(Composite composite, boolean flushCache) {
+ // Ensure that controls 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.hSpan > 1) {
+ Control child = composite.getChildren()[spec.childIndex];
+ Point extent = child.computeSize(spec.widthHint, spec.heightHint, flushCache);
+
+ // Calculate the size of the control's spanned columns.
+ int lastSpanIndex = column + spec.hSpan;
+ 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 control, 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.hSpan - 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 control'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 control'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 control'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 control, 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 control'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 control'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 control.
+ 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.hSpan == 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 control.
+ 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()) {
+ 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 control grabs excess horizontal space, the last column that the control spans
+ // will be expandable. Similarly, if a control grabs excess vertical space, the
+ // last row that the control 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.hSpan - 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 controls.
+ 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);
+
+ if (flushCache) {
+ // Cause the grid and its related information to be calculated
+ // again.
+ grid.removeAllElements();
+ }
+ return computeLayoutSize(composite, wHint, hHint, flushCache);
+}
+Point getFirstEmptyCell(int row, int column) {
+ GridData[] rowData = (GridData[]) grid.elementAt(row);
+ while (column < numColumns && rowData[column] != null) {
+ column++;
+ }
+ if (column == numColumns) {
+ row++;
+ column = 0;
+ if (row == grid.size()) {
+ grid.addElement(emptyRow());
+ }
+ return getFirstEmptyCell(row, column);
+ }
+ return new Point(row, column);
+}
+Point getLastEmptyCell(int row, int column) {
+ GridData[] rowData = (GridData[])grid.elementAt(row);
+ while (column < numColumns && rowData[column] == null ) {
+ column++;
+ }
+ return new Point(row, column - 1);
+}
+Point getCell(int row, int column, int width, int height) {
+ Point start = getFirstEmptyCell(row, column);
+ Point end = getLastEmptyCell(start.x, start.y);
+ if (end.y + 1 - start.y >= width) return start;
+ GridData[] rowData = (GridData[]) grid.elementAt(start.x);
+ for (int j = start.y; j < end.y + 1; j++) {
+ GridData spacerSpec = new GridData();
+ spacerSpec.isItemData = false;
+ rowData[j] = spacerSpec;
+ }
+ return getCell(end.x, end.y, width, height);
+}
+void createGrid(Composite composite) {
+ int row, column, rowFill, columnFill;
+ 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();
+ if (spec == null) {
+ spec = new GridData();
+ child.setLayoutData(spec);
+ }
+ spec.hSpan = Math.min(spec.horizontalSpan, numColumns);
+ Point p = getCell(row, column, spec.hSpan, spec.verticalSpan);
+ row = p.x; column = p.y;
+
+ // 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.hSpan - 1;
+ for (int r = 1; r <= rowFill; r++) {
+ for (int c = 0; c < spec.hSpan; 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.hSpan - 1;
+ }
+
+ // Fill out empty grid cells with spacers.
+ for (int r = row; r < grid.size(); r++) {
+ GridData[] rowData = (GridData[]) grid.elementAt(r);
+ for (int c = 0; c < numColumns; c++) {
+ if (rowData[c] == null) {
+ spacerSpec = new GridData();
+ spacerSpec.isItemData = false;
+ rowData[c] = spacerSpec;
+ }
+ }
+ }
+}
+GridData[] emptyRow() {
+ GridData[] row = new GridData[numColumns];
+ for (int i = 0; i < numColumns; i++) {
+ row[i] = null;}
+ return row;
+}
+protected void layout(Composite composite, boolean flushCache) {
+ int[] columnWidths;
+ int[] rowHeights;
+ int 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;
+ 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 control 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];
+ if (spec.hSpan == 1) {
+ 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];
+ if (spec.verticalSpan == 1) {
+ 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 control 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.hSpan; 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 control.
+ if (hAlign == GridData.CENTER) {
+ widgetX = widgetX + (spannedWidth / 2) - (childExtent.x / 2);
+ } else
+ if (hAlign == GridData.END) {
+ widgetX = widgetX + spannedWidth - childExtent.x - spec.horizontalIndent;
+ } else {
+ widgetX = widgetX + spec.horizontalIndent;
+ }
+ if (hAlign == GridData.FILL) {
+ widgetW = spannedWidth - spec.horizontalIndent;
+ widgetX = columnX + spec.horizontalIndent;
+ } else {
+ widgetW = childExtent.x;
+ }
+
+ // Calculate the y and height values for the control.
+ vAlign = spec.verticalAlignment;
+ widgetY = rowY;
+ if (vAlign == GridData.CENTER) {
+ widgetY = widgetY + (spannedHeight / 2) - (childExtent.y / 2);
+ } else
+ if (vAlign == GridData.END) {
+ widgetY = widgetY + spannedHeight - childExtent.y;
+ }
+ if (vAlign == GridData.FILL) {
+ widgetH = spannedHeight;
+ widgetY = rowY;
+ } else {
+ widgetH = childExtent.y;
+ }
+ // Place the control.
+ 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
index 05d4019e35..9f44d42b2f 100755
--- 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
@@ -1,53 +1,53 @@
-package org.eclipse.swt.layout;
-
-/*
+package org.eclipse.swt.layout;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-import org.eclipse.swt.*;
-import org.eclipse.swt.graphics.*;
-
-/**
- * Each control controlled by a <code>RowLayout</code> can have its initial
- * width and height specified by setting a <code>RowData</code> object
- * into the control.
- * <p>
- * The following code uses a <code>RowData</code> object to change the initial
- * size of a <code>Button</code> in a <code>Shell</code>:
- * <pre>
- * Display display = new Display();
- * Shell shell = new Shell(display);
- * shell.setLayout(new RowLayout());
- * Button button1 = new Button(shell, SWT.PUSH);
- * button1.setText("Button 1");
- * button1.setLayoutData(new RowData(50, 40));
- * </pre>
- * </p>
- *
- * @see RowLayout
- */
-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);
-}
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+import org.eclipse.swt.*;
+import org.eclipse.swt.graphics.*;
+
+/**
+ * Each control controlled by a <code>RowLayout</code> can have its initial
+ * width and height specified by setting a <code>RowData</code> object
+ * into the control.
+ * <p>
+ * The following code uses a <code>RowData</code> object to change the initial
+ * size of a <code>Button</code> in a <code>Shell</code>:
+ * <pre>
+ * Display display = new Display();
+ * Shell shell = new Shell(display);
+ * shell.setLayout(new RowLayout());
+ * Button button1 = new Button(shell, SWT.PUSH);
+ * button1.setText("Button 1");
+ * button1.setLayoutData(new RowData(50, 40));
+ * </pre>
+ * </p>
+ *
+ * @see RowLayout
+ */
+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
index d99d0c1a57..f6463fa49b 100755
--- 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
@@ -1,297 +1,297 @@
-package org.eclipse.swt.layout;
-
-/*
+package org.eclipse.swt.layout;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-import org.eclipse.swt.*;
-import org.eclipse.swt.graphics.*;
-import org.eclipse.swt.widgets.*;
-
-/**
- * Instances of this class determine the size and position of the
- * children of a <code>Composite</code> by placing them either in
- * horizontal rows or vertical columns within the parent <code>Composite</code>.
- * <p>
- * <code>RowLayout</code> aligns all controls in one row if the
- * <code>type</code> is set to horizontal, and one column if it is
- * set to vertical. It has the ability to wrap, and provides configurable
- * margins and spacing. <code>RowLayout</code> has a number of configuration
- * fields. In addition, the height and width of each control in a
- * <code>RowLayout</code> can be specified by setting a <code>RowData</code>
- * object into the control using <code>setLayoutData ()</code>.
- * </p>
- * <p>
- * The following example code creates a <code>RowLayout</code>, sets all
- * of its fields to non-default values, and then sets it into a
- * <code>Shell</code>.
- * <pre>
- * RowLayout rowLayout = new RowLayout();
- * rowLayout.wrap = false;
- * rowLayout.pack = false;
- * rowLayout.justify = true;
- * rowLayout.type = SWT.VERTICAL;
- * rowLayout.marginLeft = 5;
- * rowLayout.marginTop = 5;
- * rowLayout.marginRight = 5;
- * rowLayout.marginBottom = 5;
- * rowLayout.spacing = 0;
- * shell.setLayout(rowLayout);
- * </pre>
- * If you are using the default field values, you only need one line of code:
- * <pre>
- * shell.setLayout(new RowLayout());
- * </pre>
- * </p>
- *
- * @see RowData
- */
-public final class RowLayout extends Layout {
- /**
- * type specifies whether the layout places controls in rows or
- * columns.
- *
- * The default value is HORIZONTAL.
- *
- * Possible values are:
- *
- * HORIZONTAL: Position the controls horizontally from left to right
- * VERTICAL: Position the controls vertically from top to bottom
- *
- * @since 2.0
- */
- public int type = SWT.HORIZONTAL;
- /**
- * wrap specifies whether a control will be wrapped to the next
- * row if there is insufficient space on the current row.
- *
- * The default value is true.
- */
- public boolean wrap = true;
- /**
- * pack specifies whether all controls in the layout take
- * their preferred size. If pack is false, all controls will
- * have the same size which is the size required to accommodate the
- * largest preferred height and the largest preferred width of all
- * the controls in the layout.
- *
- * The default value is true.
- */
- public boolean pack = true;
- /**
- * 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;
-
-/**
- * Constructs a new instance of this class.
- */
-public RowLayout () {
-}
-
-/**
- * Constructs a new instance of this class given the type.
- *
- * @param type the type of row layout
- *
- * @since 2.0
- */
-public RowLayout (int type) {
- this.type = type;
-}
-
-protected Point computeSize (Composite composite, int wHint, int hHint, boolean flushCache) {
- Point extent;
- if (type == SWT.HORIZONTAL) {
- extent = layoutHorizontal (composite, false, (wHint != SWT.DEFAULT) && wrap, wHint, flushCache);
- } else {
- extent = layoutVertical (composite, false, (hHint != SWT.DEFAULT) && wrap, hHint, flushCache);
- }
- if (wHint != SWT.DEFAULT) extent.x = wHint;
- if (hHint != SWT.DEFAULT) extent.y = hHint;
- return extent;
-}
-
-Point 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 ();
- if (type == SWT.HORIZONTAL) {
- layoutHorizontal (composite, true, wrap, clientArea.width, flushCache);
- } else {
- layoutVertical (composite, true, wrap, clientArea.height, flushCache);
- }
-}
-
-Point layoutHorizontal (Composite composite, boolean move, boolean wrap, int width, boolean flushCache) {
- Control [] children = composite.getChildren ();
- int count = 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);
-}
-
-Point layoutVertical (Composite composite, boolean move, boolean wrap, int height, boolean flushCache) {
- Control [] children = composite.getChildren ();
- int count = children.length;
- int childWidth = 0, childHeight = 0, maxWidth = 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);
- }
- maxWidth = childWidth;
- }
- 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 maxY = 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) && (y + childHeight > height)) {
- wrapped = true;
- x += spacing + maxWidth; y = marginTop;
- }
- if (pack) {
- maxWidth = Math.max (maxWidth, childWidth);
- }
- 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);
- }
- }
- y += spacing + childHeight;
- maxY = Math.max (maxY, y);
- }
- if (!wrap) maxY = y + marginBottom;
- if (move && justify) {
- int space = 0, margin = 0;
- if (!wrapped) {
- space = Math.max (0, (height - maxY) / (count + 1));
- margin = Math.max (0, ((height - maxY) % (count + 1)) / 2);
- }
- for (int i=0; i<count; i++) {
- Control child = children [i];
- bounds [i].y += (space * (i + 1)) + margin;
- child.setBounds (bounds [i]);
- }
- }
- return new Point (x + maxWidth + marginRight, maxY);
-}
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+import org.eclipse.swt.*;
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.widgets.*;
+
+/**
+ * Instances of this class determine the size and position of the
+ * children of a <code>Composite</code> by placing them either in
+ * horizontal rows or vertical columns within the parent <code>Composite</code>.
+ * <p>
+ * <code>RowLayout</code> aligns all controls in one row if the
+ * <code>type</code> is set to horizontal, and one column if it is
+ * set to vertical. It has the ability to wrap, and provides configurable
+ * margins and spacing. <code>RowLayout</code> has a number of configuration
+ * fields. In addition, the height and width of each control in a
+ * <code>RowLayout</code> can be specified by setting a <code>RowData</code>
+ * object into the control using <code>setLayoutData ()</code>.
+ * </p>
+ * <p>
+ * The following example code creates a <code>RowLayout</code>, sets all
+ * of its fields to non-default values, and then sets it into a
+ * <code>Shell</code>.
+ * <pre>
+ * RowLayout rowLayout = new RowLayout();
+ * rowLayout.wrap = false;
+ * rowLayout.pack = false;
+ * rowLayout.justify = true;
+ * rowLayout.type = SWT.VERTICAL;
+ * rowLayout.marginLeft = 5;
+ * rowLayout.marginTop = 5;
+ * rowLayout.marginRight = 5;
+ * rowLayout.marginBottom = 5;
+ * rowLayout.spacing = 0;
+ * shell.setLayout(rowLayout);
+ * </pre>
+ * If you are using the default field values, you only need one line of code:
+ * <pre>
+ * shell.setLayout(new RowLayout());
+ * </pre>
+ * </p>
+ *
+ * @see RowData
+ */
+public final class RowLayout extends Layout {
+ /**
+ * type specifies whether the layout places controls in rows or
+ * columns.
+ *
+ * The default value is HORIZONTAL.
+ *
+ * Possible values are:
+ *
+ * HORIZONTAL: Position the controls horizontally from left to right
+ * VERTICAL: Position the controls vertically from top to bottom
+ *
+ * @since 2.0
+ */
+ public int type = SWT.HORIZONTAL;
+ /**
+ * wrap specifies whether a control will be wrapped to the next
+ * row if there is insufficient space on the current row.
+ *
+ * The default value is true.
+ */
+ public boolean wrap = true;
+ /**
+ * pack specifies whether all controls in the layout take
+ * their preferred size. If pack is false, all controls will
+ * have the same size which is the size required to accommodate the
+ * largest preferred height and the largest preferred width of all
+ * the controls in the layout.
+ *
+ * The default value is true.
+ */
+ public boolean pack = true;
+ /**
+ * 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;
+
+/**
+ * Constructs a new instance of this class.
+ */
+public RowLayout () {
+}
+
+/**
+ * Constructs a new instance of this class given the type.
+ *
+ * @param type the type of row layout
+ *
+ * @since 2.0
+ */
+public RowLayout (int type) {
+ this.type = type;
+}
+
+protected Point computeSize (Composite composite, int wHint, int hHint, boolean flushCache) {
+ Point extent;
+ if (type == SWT.HORIZONTAL) {
+ extent = layoutHorizontal (composite, false, (wHint != SWT.DEFAULT) && wrap, wHint, flushCache);
+ } else {
+ extent = layoutVertical (composite, false, (hHint != SWT.DEFAULT) && wrap, hHint, flushCache);
+ }
+ if (wHint != SWT.DEFAULT) extent.x = wHint;
+ if (hHint != SWT.DEFAULT) extent.y = hHint;
+ return extent;
+}
+
+Point 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 ();
+ if (type == SWT.HORIZONTAL) {
+ layoutHorizontal (composite, true, wrap, clientArea.width, flushCache);
+ } else {
+ layoutVertical (composite, true, wrap, clientArea.height, flushCache);
+ }
+}
+
+Point layoutHorizontal (Composite composite, boolean move, boolean wrap, int width, boolean flushCache) {
+ Control [] children = composite.getChildren ();
+ int count = 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);
+}
+
+Point layoutVertical (Composite composite, boolean move, boolean wrap, int height, boolean flushCache) {
+ Control [] children = composite.getChildren ();
+ int count = children.length;
+ int childWidth = 0, childHeight = 0, maxWidth = 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);
+ }
+ maxWidth = childWidth;
+ }
+ 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 maxY = 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) && (y + childHeight > height)) {
+ wrapped = true;
+ x += spacing + maxWidth; y = marginTop;
+ }
+ if (pack) {
+ maxWidth = Math.max (maxWidth, childWidth);
+ }
+ 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);
+ }
+ }
+ y += spacing + childHeight;
+ maxY = Math.max (maxY, y);
+ }
+ if (!wrap) maxY = y + marginBottom;
+ if (move && justify) {
+ int space = 0, margin = 0;
+ if (!wrapped) {
+ space = Math.max (0, (height - maxY) / (count + 1));
+ margin = Math.max (0, ((height - maxY) % (count + 1)) / 2);
+ }
+ for (int i=0; i<count; i++) {
+ Control child = children [i];
+ bounds [i].y += (space * (i + 1)) + margin;
+ child.setBounds (bounds [i]);
+ }
+ }
+ return new Point (x + maxWidth + marginRight, maxY);
+}
+}
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
index cfdfa57a1c..a45ffc96a5 100755
--- 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
@@ -1,253 +1,253 @@
-package org.eclipse.swt.widgets;
-
-/*
+package org.eclipse.swt.widgets;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-import org.eclipse.swt.*;
-
-/**
- * This class is the abstract superclass of the classes
- * that represent the built in platform dialogs.
- * A <code>Dialog</code> typically contains other widgets
- * that are not accessible. A <code>Dialog</code> is not
- * a <code>Widget</code>.
- * <p>
- * This class can also be used as the abstract superclass
- * for user-designed dialogs. Such dialogs usually consist
- * of a Shell with child widgets. The basic template for a
- * user-defined dialog typically looks something like this:
- * <code>
- * public class MyDialog extends Dialog {
- * Object result;
- *
- * public MyDialog (Shell parent, int style) {
- * super (parent, style);
- * }
- * public MyDialog (Shell parent) {
- * this (parent, 0); // your default style bits go here (not the Shell's style bits)
- * }
- * public Object open () {
- * Shell parent = getParent();
- * Shell shell = new Shell(parent, SWT.DIALOG_TRIM | SWT.APPLICATION_MODAL);
- * shell.setText(getText());
- * // Your code goes here (widget creation, set result, etc).
- * shell.open();
- * Display display = parent.getDisplay();
- * while (!shell.isDisposed()) {
- * if (!display.readAndDispatch()) display.sleep();
- * }
- * return result;
- * }
- * }
- * </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 on every platform. If a modality style
- * is not supported, it is "upgraded" to a more restrictive modality
- * style that is supported. For example, if <code>PRIMARY_MODAL</code>
- * is not supported by a particular dialog, it would be upgraded to
- * <code>APPLICATION_MODAL</code>. In addition, as is the case
- * for shells, the window manager for the desktop on which the
- * instance is visible has ultimate control over the appearance
- * and behavior of the instance, including its modality.
- * <dl>
- * <dt><b>Styles:</b></dt>
- * <dd>APPLICATION_MODAL, 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>
- * </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
- * lists the style constants that are applicable to the class.
- * Style bits are also inherited from superclasses.
- * </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>
- * </ul>
- */
-public Dialog (Shell parent, int style) {
- checkParent (parent);
- this.parent = parent;
- this.style = style;
- title = "";
-}
-
-/**
- * Checks that this class can be subclassed.
- * <p>
- * IMPORTANT: See the comment in <code>Widget.checkSubclass()</code>.
- * </p>
- *
- * @exception SWTException <ul>
- * <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
- * </ul>
- *
- * @see Widget#checkSubclass
- */
-protected void checkSubclass () {
- if (!Display.isValidClass (getClass ())) {
- error (SWT.ERROR_INVALID_SUBCLASS);
- }
-}
-
-/**
- * Throws an exception if the specified widget can not be
- * used as a parent for the receiver.
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
- * <li>ERROR_INVALID_ARGUMENT - if the parent is disposed</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
- * </ul>
- */
-void checkParent (Shell parent) {
- if (parent == null) error (SWT.ERROR_NULL_ARGUMENT);
- if (!parent.isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
- if (parent.isDisposed()) error (SWT.ERROR_INVALID_ARGUMENT);
-}
-
-/**
- * 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 must not be null.
- *
- * @param text the new text
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the text is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public void setText (String string) {
- if (string == null) error (SWT.ERROR_NULL_ARGUMENT);
- title = string;
-}
-
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+import org.eclipse.swt.*;
+
+/**
+ * This class is the abstract superclass of the classes
+ * that represent the built in platform dialogs.
+ * A <code>Dialog</code> typically contains other widgets
+ * that are not accessible. A <code>Dialog</code> is not
+ * a <code>Widget</code>.
+ * <p>
+ * This class can also be used as the abstract superclass
+ * for user-designed dialogs. Such dialogs usually consist
+ * of a Shell with child widgets. The basic template for a
+ * user-defined dialog typically looks something like this:
+ * <code>
+ * public class MyDialog extends Dialog {
+ * Object result;
+ *
+ * public MyDialog (Shell parent, int style) {
+ * super (parent, style);
+ * }
+ * public MyDialog (Shell parent) {
+ * this (parent, 0); // your default style bits go here (not the Shell's style bits)
+ * }
+ * public Object open () {
+ * Shell parent = getParent();
+ * Shell shell = new Shell(parent, SWT.DIALOG_TRIM | SWT.APPLICATION_MODAL);
+ * shell.setText(getText());
+ * // Your code goes here (widget creation, set result, etc).
+ * shell.open();
+ * Display display = parent.getDisplay();
+ * while (!shell.isDisposed()) {
+ * if (!display.readAndDispatch()) display.sleep();
+ * }
+ * return result;
+ * }
+ * }
+ * </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 on every platform. If a modality style
+ * is not supported, it is "upgraded" to a more restrictive modality
+ * style that is supported. For example, if <code>PRIMARY_MODAL</code>
+ * is not supported by a particular dialog, it would be upgraded to
+ * <code>APPLICATION_MODAL</code>. In addition, as is the case
+ * for shells, the window manager for the desktop on which the
+ * instance is visible has ultimate control over the appearance
+ * and behavior of the instance, including its modality.
+ * <dl>
+ * <dt><b>Styles:</b></dt>
+ * <dd>APPLICATION_MODAL, 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>
+ * </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
+ * lists the style constants that are applicable to the class.
+ * Style bits are also inherited from superclasses.
+ * </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>
+ * </ul>
+ */
+public Dialog (Shell parent, int style) {
+ checkParent (parent);
+ this.parent = parent;
+ this.style = style;
+ title = "";
+}
+
+/**
+ * Checks that this class can be subclassed.
+ * <p>
+ * IMPORTANT: See the comment in <code>Widget.checkSubclass()</code>.
+ * </p>
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
+ * </ul>
+ *
+ * @see Widget#checkSubclass
+ */
+protected void checkSubclass () {
+ if (!Display.isValidClass (getClass ())) {
+ error (SWT.ERROR_INVALID_SUBCLASS);
+ }
+}
+
+/**
+ * Throws an exception if the specified widget can not be
+ * used as a parent for the receiver.
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
+ * <li>ERROR_INVALID_ARGUMENT - if the parent is disposed</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
+ * </ul>
+ */
+void checkParent (Shell parent) {
+ if (parent == null) error (SWT.ERROR_NULL_ARGUMENT);
+ if (!parent.isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (parent.isDisposed()) error (SWT.ERROR_INVALID_ARGUMENT);
+}
+
+/**
+ * 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 must not be null.
+ *
+ * @param text the new text
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if the text is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setText (String string) {
+ if (string == null) error (SWT.ERROR_NULL_ARGUMENT);
+ title = string;
+}
+
+}
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
index 2bc9da03a9..6ae5cc2ef6 100755
--- 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
@@ -1,208 +1,208 @@
-package org.eclipse.swt.widgets;
-
-/*
+package org.eclipse.swt.widgets;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-import org.eclipse.swt.graphics.*;
-
-/**
- * Instances of this class provide a description of a particular
- * event which occurred within SWT. The SWT <em>untyped listener</em>
- * API uses these instances for all event dispatching.
- * <p>
- * Note: For a given event, only the fields which are appropriate
- * will be filled in. The contents of the fields which are not used
- * by the event are unspecified.
- * </p>
- *
- * @see Listener
- * @see org.eclipse.swt.events.TypedEvent
- */
-
-public class Event {
-
- /**
- * the display where the event occurred
- *
- * @since 2.0
- */
- public Display display;
-
- /**
- * the widget that issued the event
- */
- public Widget widget;
-
- /**
- * the type of event, as defined by the event type constants
- * in class <code>SWT</code>
- *
- * @see SWT
- */
- public int type;
-
- /**
- * the event specific detail field, as defined by the detail constants
- * in class <code>SWT</code>
- *
- * @see SWT
- */
- public int detail;
-
- /**
- * the item that the event occurred in (can be null)
- */
- public Widget item;
-
- /**
- * the graphics context to use when painting
- * that is configured to use the colors, font and
- * damaged region of the control. It is valid
- * only during the paint and must not be disposed
- */
- public GC gc;
-
- /**
- * depending on the event type, the x offset of the bounding
- * rectangle of the region that requires painting or the
- * widget-relative, x coordinate of the pointer at the
- * time the mouse button was pressed or released
- */
- public int x;
-
- /**
- * depending on the event type, the y offset of the bounding
- * rectangle of the region that requires painting or the
- * widget-relative, y coordinate of the pointer at the
- * time the mouse button was pressed or released
- */
- public int y;
-
- /**
- * the width of the bounding rectangle of the
- * region that requires painting
- */
- public int width;
-
- /**
- * the height of the bounding rectangle of the
- * region that requires painting
- */
- public int height;
-
- /**
- * the number of following paint events which
- * are pending which may always be zero on
- * some platforms
- */
- public int count;
-
- /**
- * the time that the event occurred.
- *
- * NOTE: This field is an unsigned integer and should
- * be AND'ed with 0xFFFFFFFFL so that it can be treated
- * as a signed long.
- */
- public int time;
-
- /**
- * the button that was pressed or released; 1 for the
- * first button, 2 for the second button, and 3 for the
- * third button, etc.
- */
- public int button;
-
- /**
- * depending on the event, the character represented by the key
- * that was typed. This is the final character that results
- * after all modifiers have been applied. For example, when the
- * user types Ctrl+A, the character value is 0x01 (NUL). It is
- * important that applications do not attempt to modify the character
- * value based on a stateMask (such as SWT.CTRL) or the resulting
- * character will not be correct.
- */
- public char character;
-
- /**
- * depending on the event, the key code of the key that was typed,
- * as defined by the key code constants in class <code>SWT</code>.
- * When the character field of the event is ambiguous, this field
- * contains the unicode value of the original character. For example,
- * typing Ctrl+M or Return both result in the character '\r' but the
- * keyCode field will also contain '\r' when Return was typed.
- *
- * @see SWT
- */
- public int keyCode;
-
- /**
- * depending on the event, the state of the keyboard modifier
- * keys and mouse masks at the time the event was generated.
- *
- * @see SWT
- */
- public int stateMask;
-
- /**
- * depending on the event, the range of text being modified.
- * Setting these fields has no effect.
- */
- public int start, end;
-
- /**
- * depending on the event, the new text that will be inserted.
- * Setting this field will change the text that is about to
- * be inserted or deleted.
- */
- public String text;
-
- /**
- * depending on the event, a flag indicating whether the operation
- * should be allowed. Setting this field to false will cancel the
- * operation.
- */
- public boolean doit = true;
-
- /**
- * a field for application use
- */
- public Object data;
-
-/**
-* Gets the bounds.
-* <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 + "}";
-}
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+import org.eclipse.swt.graphics.*;
+
+/**
+ * Instances of this class provide a description of a particular
+ * event which occurred within SWT. The SWT <em>untyped listener</em>
+ * API uses these instances for all event dispatching.
+ * <p>
+ * Note: For a given event, only the fields which are appropriate
+ * will be filled in. The contents of the fields which are not used
+ * by the event are unspecified.
+ * </p>
+ *
+ * @see Listener
+ * @see org.eclipse.swt.events.TypedEvent
+ */
+
+public class Event {
+
+ /**
+ * the display where the event occurred
+ *
+ * @since 2.0
+ */
+ public Display display;
+
+ /**
+ * the widget that issued the event
+ */
+ public Widget widget;
+
+ /**
+ * the type of event, as defined by the event type constants
+ * in class <code>SWT</code>
+ *
+ * @see SWT
+ */
+ public int type;
+
+ /**
+ * the event specific detail field, as defined by the detail constants
+ * in class <code>SWT</code>
+ *
+ * @see SWT
+ */
+ public int detail;
+
+ /**
+ * the item that the event occurred in (can be null)
+ */
+ public Widget item;
+
+ /**
+ * the graphics context to use when painting
+ * that is configured to use the colors, font and
+ * damaged region of the control. It is valid
+ * only during the paint and must not be disposed
+ */
+ public GC gc;
+
+ /**
+ * depending on the event type, the x offset of the bounding
+ * rectangle of the region that requires painting or the
+ * widget-relative, x coordinate of the pointer at the
+ * time the mouse button was pressed or released
+ */
+ public int x;
+
+ /**
+ * depending on the event type, the y offset of the bounding
+ * rectangle of the region that requires painting or the
+ * widget-relative, y coordinate of the pointer at the
+ * time the mouse button was pressed or released
+ */
+ public int y;
+
+ /**
+ * the width of the bounding rectangle of the
+ * region that requires painting
+ */
+ public int width;
+
+ /**
+ * the height of the bounding rectangle of the
+ * region that requires painting
+ */
+ public int height;
+
+ /**
+ * the number of following paint events which
+ * are pending which may always be zero on
+ * some platforms
+ */
+ public int count;
+
+ /**
+ * the time that the event occurred.
+ *
+ * NOTE: This field is an unsigned integer and should
+ * be AND'ed with 0xFFFFFFFFL so that it can be treated
+ * as a signed long.
+ */
+ public int time;
+
+ /**
+ * the button that was pressed or released; 1 for the
+ * first button, 2 for the second button, and 3 for the
+ * third button, etc.
+ */
+ public int button;
+
+ /**
+ * depending on the event, the character represented by the key
+ * that was typed. This is the final character that results
+ * after all modifiers have been applied. For example, when the
+ * user types Ctrl+A, the character value is 0x01 (NUL). It is
+ * important that applications do not attempt to modify the character
+ * value based on a stateMask (such as SWT.CTRL) or the resulting
+ * character will not be correct.
+ */
+ public char character;
+
+ /**
+ * depending on the event, the key code of the key that was typed,
+ * as defined by the key code constants in class <code>SWT</code>.
+ * When the character field of the event is ambiguous, this field
+ * contains the unicode value of the original character. For example,
+ * typing Ctrl+M or Return both result in the character '\r' but the
+ * keyCode field will also contain '\r' when Return was typed.
+ *
+ * @see SWT
+ */
+ public int keyCode;
+
+ /**
+ * depending on the event, the state of the keyboard modifier
+ * keys and mouse masks at the time the event was generated.
+ *
+ * @see SWT
+ */
+ public int stateMask;
+
+ /**
+ * depending on the event, the range of text being modified.
+ * Setting these fields has no effect.
+ */
+ public int start, end;
+
+ /**
+ * depending on the event, the new text that will be inserted.
+ * Setting this field will change the text that is about to
+ * be inserted or deleted.
+ */
+ public String text;
+
+ /**
+ * depending on the event, a flag indicating whether the operation
+ * should be allowed. Setting this field to false will cancel the
+ * operation.
+ */
+ public boolean doit = true;
+
+ /**
+ * a field for application use
+ */
+ public Object data;
+
+/**
+* Gets the bounds.
+* <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
index 702ff474c5..712f718feb 100755
--- 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
@@ -1,130 +1,130 @@
-package org.eclipse.swt.widgets;
-
-/*
+package org.eclipse.swt.widgets;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-import org.eclipse.swt.internal.SWTEventListener;
-
-
-/**
- * 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 [] listeners;
- int level;
-
-public void hook (int eventType, Listener listener) {
- if (types == null) types = new int [4];
- if (listeners == null) listeners = new Listener [4];
- int length = types.length, index = length - 1;
- while (index >= 0) {
- if (types [index] != 0) break;
- --index;
- }
- index++;
- if (index == length) {
- if (level == 0) {
- index = 0;
- for (int i=0; i<types.length; i++) {
- if (types [i] != 0) {
- types [index] = types [i];
- listeners [index] = listeners [i];
- index++;
- }
- }
- for (int i=index; i<types.length; i++) {
- types [i] = 0;
- listeners [i] = null;
- }
- }
- if (index == length) {
- int [] newTypes = new int [length + 4];
- System.arraycopy (types, 0, newTypes, 0, length);
- types = newTypes;
- Listener [] newListeners = new Listener [length + 4];
- System.arraycopy (listeners, 0, newListeners, 0, length);
- listeners = newListeners;
- }
- }
- types [index] = eventType;
- listeners [index] = listener;
-}
-
-public boolean hooks (int eventType) {
- if (types == null) return false;
- for (int i=0; i<types.length; i++) {
- if (types [i] == eventType) return true;
- }
- return false;
-}
-
-public void sendEvent (Event event) {
- if (types == null) return;
- level++;
- try {
- for (int i=0; i<types.length; i++) {
- if (types [i] == event.type) {
- Listener listener = listeners [i];
- if (listener != null) listener.handleEvent (event);
- }
- }
- } finally {
- --level;
- }
-}
-
-public int size () {
- if (types == null) return 0;
- int count = 0;
- for (int i=0; i<types.length; i++) {
- if (types [i] != 0) count++;
- }
- return count;
-}
-
-void remove (int index) {
- if (level == 0) {
- int end = types.length - 1;
- System.arraycopy (types, index + 1, types, index, end - index);
- System.arraycopy (listeners, index + 1, listeners, index, end - index);
- index = end;
- }
- types [index] = 0;
- listeners [index] = null;
-}
-
-public void unhook (int eventType, Listener listener) {
- if (types == null) return;
- for (int i=0; i<types.length; i++) {
- if (types [i] == eventType && listeners [i] == listener) {
- remove (i);
- return;
- }
- }
-}
-
-public void unhook (int eventType, SWTEventListener listener) {
- if (types == null) return;
- for (int i=0; i<types.length; i++) {
- if (types [i] == eventType) {
- if (listeners [i] instanceof TypedListener) {
- TypedListener typedListener = (TypedListener) listeners [i];
- if (typedListener.getEventListener () == listener) {
- remove (i);
- return;
- }
- }
- }
- }
-}
-
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+import org.eclipse.swt.internal.SWTEventListener;
+
+
+/**
+ * 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 [] listeners;
+ int level;
+
+public void hook (int eventType, Listener listener) {
+ if (types == null) types = new int [4];
+ if (listeners == null) listeners = new Listener [4];
+ int length = types.length, index = length - 1;
+ while (index >= 0) {
+ if (types [index] != 0) break;
+ --index;
+ }
+ index++;
+ if (index == length) {
+ if (level == 0) {
+ index = 0;
+ for (int i=0; i<types.length; i++) {
+ if (types [i] != 0) {
+ types [index] = types [i];
+ listeners [index] = listeners [i];
+ index++;
+ }
+ }
+ for (int i=index; i<types.length; i++) {
+ types [i] = 0;
+ listeners [i] = null;
+ }
+ }
+ if (index == length) {
+ int [] newTypes = new int [length + 4];
+ System.arraycopy (types, 0, newTypes, 0, length);
+ types = newTypes;
+ Listener [] newListeners = new Listener [length + 4];
+ System.arraycopy (listeners, 0, newListeners, 0, length);
+ listeners = newListeners;
+ }
+ }
+ types [index] = eventType;
+ listeners [index] = listener;
+}
+
+public boolean hooks (int eventType) {
+ if (types == null) return false;
+ for (int i=0; i<types.length; i++) {
+ if (types [i] == eventType) return true;
+ }
+ return false;
+}
+
+public void sendEvent (Event event) {
+ if (types == null) return;
+ level++;
+ try {
+ for (int i=0; i<types.length; i++) {
+ if (types [i] == event.type) {
+ Listener listener = listeners [i];
+ if (listener != null) listener.handleEvent (event);
+ }
+ }
+ } finally {
+ --level;
+ }
+}
+
+public int size () {
+ if (types == null) return 0;
+ int count = 0;
+ for (int i=0; i<types.length; i++) {
+ if (types [i] != 0) count++;
+ }
+ return count;
+}
+
+void remove (int index) {
+ if (level == 0) {
+ int end = types.length - 1;
+ System.arraycopy (types, index + 1, types, index, end - index);
+ System.arraycopy (listeners, index + 1, listeners, index, end - index);
+ index = end;
+ }
+ types [index] = 0;
+ listeners [index] = null;
+}
+
+public void unhook (int eventType, Listener listener) {
+ if (types == null) return;
+ for (int i=0; i<types.length; i++) {
+ if (types [i] == eventType && listeners [i] == listener) {
+ remove (i);
+ return;
+ }
+ }
+}
+
+public void unhook (int eventType, SWTEventListener listener) {
+ if (types == null) return;
+ for (int i=0; i<types.length; i++) {
+ if (types [i] == eventType) {
+ if (listeners [i] instanceof TypedListener) {
+ TypedListener typedListener = (TypedListener) listeners [i];
+ if (typedListener.getEventListener () == listener) {
+ remove (i);
+ return;
+ }
+ }
+ }
+ }
+}
+
+}
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
index 189440f0d9..8a561af97a 100755
--- 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
@@ -1,177 +1,177 @@
-package org.eclipse.swt.widgets;
-
-/*
+package org.eclipse.swt.widgets;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-import org.eclipse.swt.*;
-import org.eclipse.swt.graphics.*;
-
-/**
- * This class is the abstract superclass of all non-windowed
- * user interface objects that occur within specific controls.
- * For example, a tree will contain tree items.
- * <dl>
- * <dt><b>Styles:</b></dt>
- * <dd>(none)</dd>
- * <dt><b>Events:</b></dt>
- * <dd>(none)</dd>
- * </dl>
- */
-
-public abstract class Item extends Widget {
- String text;
- Image image;
-
-/**
- * Constructs a new instance of this class given its parent
- * and a style value describing its behavior and appearance.
- * The item is added to the end of the items maintained by its parent.
- * <p>
- * The style value is either one of the style constants defined in
- * class <code>SWT</code> which is applicable to instances of this
- * class, or must be built by <em>bitwise OR</em>'ing together
- * (that is, using the <code>int</code> "|" operator) two or more
- * of those <code>SWT</code> style constants. The class description
- * lists the style constants that are applicable to the class.
- * Style bits are also inherited from superclasses.
- * </p>
- *
- * @param parent a widget which will be the parent of the new instance (cannot be null)
- * @param style the style of item to construct
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
- * </ul>
- *
- * @see SWT
- * @see #getStyle
- */
-public Item (Widget parent, int style) {
- super (parent, style);
- text = "";
-}
-
-/**
- * Constructs a new instance of this class given its parent
- * and a style value describing its behavior and appearance,
- * and the index at which to place it in the items maintained
- * by its parent.
- * <p>
- * The style value is either one of the style constants defined in
- * class <code>SWT</code> which is applicable to instances of this
- * class, or must be built by <em>bitwise OR</em>'ing together
- * (that is, using the <code>int</code> "|" operator) two or more
- * of those <code>SWT</code> style constants. The class description
- * lists the style constants that are applicable to the class.
- * Style bits are also inherited from superclasses.
- * </p>
- *
- * @param parent a widget which will be the parent of the new instance (cannot be null)
- * @param style the style of item to construct
- * @param index the index at which to store the receiver in its parent
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
- * </ul>
- *
- * @see SWT
- * @see #getStyle
- */
-public Item (Widget parent, int style, int index) {
- this (parent, style);
-}
-
-protected void checkSubclass () {
- /* Do Nothing - Subclassing is allowed */
-}
-
-/**
- * Returns the receiver's image if it has one, or null
- * if it does not.
- *
- * @return the receiver's image
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public Image getImage () {
- checkWidget ();
- return image;
-}
-
-String getNameText () {
- return getText ();
-}
-
-/**
- * Returns the receiver's text, which will be an empty
- * string if it has never been set.
- *
- * @return the receiver's text
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public String getText () {
- checkWidget();
- return text;
-}
-
-void releaseWidget () {
- super.releaseWidget ();
- text = null;
- image = null;
-}
-/**
- * Sets the receiver's image to the argument, which may be
- * null indicating that no image should be displayed.
- *
- * @param image the image to display on the receiver (may be null)
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_INVALID_ARGUMENT - if the image has been disposed</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public void setImage (Image image) {
- checkWidget ();
- if (image != null && image.isDisposed()) error(SWT.ERROR_INVALID_ARGUMENT);
- this.image = image;
-}
-
-/**
- * Sets the receiver's text.
- *
- * @param string the new text
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the text is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public void setText (String string) {
- checkWidget ();
- text = string;
-}
-
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+import org.eclipse.swt.*;
+import org.eclipse.swt.graphics.*;
+
+/**
+ * This class is the abstract superclass of all non-windowed
+ * user interface objects that occur within specific controls.
+ * For example, a tree will contain tree items.
+ * <dl>
+ * <dt><b>Styles:</b></dt>
+ * <dd>(none)</dd>
+ * <dt><b>Events:</b></dt>
+ * <dd>(none)</dd>
+ * </dl>
+ */
+
+public abstract class Item extends Widget {
+ String text;
+ Image image;
+
+/**
+ * Constructs a new instance of this class given its parent
+ * and a style value describing its behavior and appearance.
+ * The item is added to the end of the items maintained by its parent.
+ * <p>
+ * The style value is either one of the style constants defined in
+ * class <code>SWT</code> which is applicable to instances of this
+ * class, or must be built by <em>bitwise OR</em>'ing together
+ * (that is, using the <code>int</code> "|" operator) two or more
+ * of those <code>SWT</code> style constants. The class description
+ * lists the style constants that are applicable to the class.
+ * Style bits are also inherited from superclasses.
+ * </p>
+ *
+ * @param parent a widget which will be the parent of the new instance (cannot be null)
+ * @param style the style of item to construct
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
+ * </ul>
+ *
+ * @see SWT
+ * @see #getStyle
+ */
+public Item (Widget parent, int style) {
+ super (parent, style);
+ text = "";
+}
+
+/**
+ * Constructs a new instance of this class given its parent
+ * and a style value describing its behavior and appearance,
+ * and the index at which to place it in the items maintained
+ * by its parent.
+ * <p>
+ * The style value is either one of the style constants defined in
+ * class <code>SWT</code> which is applicable to instances of this
+ * class, or must be built by <em>bitwise OR</em>'ing together
+ * (that is, using the <code>int</code> "|" operator) two or more
+ * of those <code>SWT</code> style constants. The class description
+ * lists the style constants that are applicable to the class.
+ * Style bits are also inherited from superclasses.
+ * </p>
+ *
+ * @param parent a widget which will be the parent of the new instance (cannot be null)
+ * @param style the style of item to construct
+ * @param index the index at which to store the receiver in its parent
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
+ * </ul>
+ *
+ * @see SWT
+ * @see #getStyle
+ */
+public Item (Widget parent, int style, int index) {
+ this (parent, style);
+}
+
+protected void checkSubclass () {
+ /* Do Nothing - Subclassing is allowed */
+}
+
+/**
+ * Returns the receiver's image if it has one, or null
+ * if it does not.
+ *
+ * @return the receiver's image
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public Image getImage () {
+ checkWidget ();
+ return image;
+}
+
+String getNameText () {
+ return getText ();
+}
+
+/**
+ * Returns the receiver's text, which will be an empty
+ * string if it has never been set.
+ *
+ * @return the receiver's text
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public String getText () {
+ checkWidget();
+ return text;
+}
+
+void releaseWidget () {
+ super.releaseWidget ();
+ text = null;
+ image = null;
+}
+/**
+ * Sets the receiver's image to the argument, which may be
+ * null indicating that no image should be displayed.
+ *
+ * @param image the image to display on the receiver (may be null)
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_INVALID_ARGUMENT - if the image has been disposed</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setImage (Image image) {
+ checkWidget ();
+ if (image != null && image.isDisposed()) error(SWT.ERROR_INVALID_ARGUMENT);
+ this.image = image;
+}
+
+/**
+ * Sets the receiver's text.
+ *
+ * @param string the new text
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if the text is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setText (String string) {
+ checkWidget ();
+ 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
index af6450636e..93e0fb0afa 100755
--- 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
@@ -1,83 +1,83 @@
-package org.eclipse.swt.widgets;
-
-/*
+package org.eclipse.swt.widgets;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-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
- * @see Control#getBorderWidth
- * @see Control#getBounds
- * @see Control#getSize
- * @see Control#pack
- * @see "computeTrim, getClientArea for controls that implement them"
- */
-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);
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+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
+ * @see Control#getBorderWidth
+ * @see Control#getBounds
+ * @see Control#getSize
+ * @see Control#pack
+ * @see "computeTrim, getClientArea for controls that implement them"
+ */
+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
index df23674df5..624dc129cc 100755
--- 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
@@ -1,47 +1,47 @@
-package org.eclipse.swt.widgets;
-
-/*
+package org.eclipse.swt.widgets;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-/**
- * <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);
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+/**
+ * <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
index ae9ea81a26..543c44dc00 100755
--- 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
@@ -1,35 +1,35 @@
-package org.eclipse.swt.widgets;
-
-/*
+package org.eclipse.swt.widgets;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-/**
- * 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;
- Throwable throwable;
-
-RunnableLock (Runnable runnable) {
- this.runnable = runnable;
-}
-
-boolean done () {
- return runnable == null || throwable != null;
-}
-
-void run () {
- if (runnable != null) runnable.run ();
- runnable = null;
-}
-
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+/**
+ * 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;
+ Throwable throwable;
+
+RunnableLock (Runnable runnable) {
+ this.runnable = runnable;
+}
+
+boolean done () {
+ return runnable == null || throwable != 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
index f3565259e6..11e30e40aa 100755
--- 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
@@ -1,155 +1,155 @@
-package org.eclipse.swt.widgets;
-
-/*
- * Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
- * This file is made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-import org.eclipse.swt.*;
-import org.eclipse.swt.internal.Compatibility;
-
-/**
- * Instances of this class provide synchronization support
- * for displays. A default instance is created automatically
- * for each display, and this instance is sufficient for almost
- * all applications.
- * <p>
- * <b>IMPORTANT:</b> Typical application code <em>never</em>
- * needs to deal with this class. It is provided only to
- * allow applications which require non-standard
- * synchronization behavior to plug in the support they
- * require. <em>Subclasses which override the methods in
- * this class must ensure that the superclass methods are
- * invoked in their implementations</em>
- * </p>
- *
- * @see Display#setSynchronizer
- */
-public class Synchronizer {
- Display display;
- int messageCount;
- RunnableLock [] messages;
- Object messageLock = new Object ();
- Thread syncThread;
-
-public Synchronizer (Display display) {
- this.display = display;
-}
-
-void addLast (RunnableLock lock) {
- synchronized (messageLock) {
- if (messages == null) messages = new RunnableLock [4];
- if (messageCount == messages.length) {
- RunnableLock[] newMessages = new RunnableLock [messageCount + 4];
- System.arraycopy (messages, 0, newMessages, 0, messageCount);
- messages = newMessages;
- }
- messages [messageCount++] = lock;
- }
-}
-
-/**
- * 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 (messageCount == 0) return null;
- RunnableLock lock = messages [0];
- System.arraycopy (messages, 1, messages, 0, --messageCount);
- messages [messageCount] = null;
- if (messageCount == 0) messages = null;
- return lock;
- }
-}
-
-boolean runAsyncMessages () {
- if (messageCount == 0) return false;
- RunnableLock lock = removeFirst ();
- if (lock == null) return true;
- synchronized (lock) {
- syncThread = lock.thread;
- try {
- lock.run ();
- } catch (Throwable t) {
- lock.throwable = t;
- SWT.error (SWT.ERROR_FAILED_EXEC, t);
- } finally {
- syncThread = null;
- lock.notifyAll ();
- }
- }
- return 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.
- *
- * @exception SWTException <ul>
- * <li>ERROR_FAILED_EXEC - if an exception occured when executing the runnable</li>
- * </ul>
- *
- * @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) {
- Compatibility.interrupt();
- }
- if (lock.throwable != null) {
- SWT.error (SWT.ERROR_FAILED_EXEC, lock.throwable);
- }
- }
-}
-
-}
+package org.eclipse.swt.widgets;
+
+/*
+ * Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
+ * This file is made available under the terms of the Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+import org.eclipse.swt.*;
+import org.eclipse.swt.internal.Compatibility;
+
+/**
+ * Instances of this class provide synchronization support
+ * for displays. A default instance is created automatically
+ * for each display, and this instance is sufficient for almost
+ * all applications.
+ * <p>
+ * <b>IMPORTANT:</b> Typical application code <em>never</em>
+ * needs to deal with this class. It is provided only to
+ * allow applications which require non-standard
+ * synchronization behavior to plug in the support they
+ * require. <em>Subclasses which override the methods in
+ * this class must ensure that the superclass methods are
+ * invoked in their implementations</em>
+ * </p>
+ *
+ * @see Display#setSynchronizer
+ */
+public class Synchronizer {
+ Display display;
+ int messageCount;
+ RunnableLock [] messages;
+ Object messageLock = new Object ();
+ Thread syncThread;
+
+public Synchronizer (Display display) {
+ this.display = display;
+}
+
+void addLast (RunnableLock lock) {
+ synchronized (messageLock) {
+ if (messages == null) messages = new RunnableLock [4];
+ if (messageCount == messages.length) {
+ RunnableLock[] newMessages = new RunnableLock [messageCount + 4];
+ System.arraycopy (messages, 0, newMessages, 0, messageCount);
+ messages = newMessages;
+ }
+ messages [messageCount++] = lock;
+ }
+}
+
+/**
+ * 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 (messageCount == 0) return null;
+ RunnableLock lock = messages [0];
+ System.arraycopy (messages, 1, messages, 0, --messageCount);
+ messages [messageCount] = null;
+ if (messageCount == 0) messages = null;
+ return lock;
+ }
+}
+
+boolean runAsyncMessages () {
+ if (messageCount == 0) return false;
+ RunnableLock lock = removeFirst ();
+ if (lock == null) return true;
+ synchronized (lock) {
+ syncThread = lock.thread;
+ try {
+ lock.run ();
+ } catch (Throwable t) {
+ lock.throwable = t;
+ SWT.error (SWT.ERROR_FAILED_EXEC, t);
+ } finally {
+ syncThread = null;
+ lock.notifyAll ();
+ }
+ }
+ return 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.
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_FAILED_EXEC - if an exception occured when executing the runnable</li>
+ * </ul>
+ *
+ * @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) {
+ Compatibility.interrupt();
+ }
+ if (lock.throwable != null) {
+ SWT.error (SWT.ERROR_FAILED_EXEC, lock.throwable);
+ }
+ }
+}
+
+}
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
index bc053d803e..2484e3124c 100755
--- 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
@@ -1,224 +1,224 @@
-package org.eclipse.swt.widgets;
-
-/*
+package org.eclipse.swt.widgets;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-import org.eclipse.swt.internal.SWTEventListener;
-import org.eclipse.swt.*;
-import org.eclipse.swt.events.*;
-
-/**
- * Instances of this class are <em>internal SWT implementation</em>
- * objects which provide a mapping between the typed and untyped
- * listener mechanisms that SWT supports.
- * <p>
- * <b>IMPORTANT:</b> This class is <em>not</em> part of the SWT
- * public API. It is marked public only so that it can be shared
- * within the packages provided by SWT. It should never be
- * referenced from application code.
- * </p>
- *
- * @see Listener
- *
- * @private
- */
-public class TypedListener implements Listener {
-
- /**
- * The receiver's event listener
- */
- protected SWTEventListener eventListener;
-
-/**
- * Constructs a new instance of this class for the given event listener.
- * <p>
- * <b>IMPORTANT:</b> This method is <em>not</em> part of the SWT
- * public API. It is marked public only so that it can be shared
- * within the packages provided by SWT. It should never be
- * referenced from application code.
- * </p>
- *
- * @param listener the event listener to store in the receiver
- */
-public TypedListener (SWTEventListener listener) {
- eventListener = listener;
-}
-
-/**
- * Returns the receiver's event listener.
- * <p>
- * <b>IMPORTANT:</b> This method is <em>not</em> part of the SWT
- * public API. It is marked public only so that it can be shared
- * within the packages provided by SWT. It should never be
- * referenced from application code.
- * </p>
- *
- * @return the receiver's event listener
- */
-public SWTEventListener getEventListener () {
- return eventListener;
-}
-
-/**
- * Handles the given event.
- * <p>
- * <b>IMPORTANT:</b> This method is <em>not</em> part of the SWT
- * public API. It is marked public only so that it can be shared
- * within the packages provided by SWT. It should never be
- * referenced from application code.
- * </p>
- */
-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;
- }
-
- }
-}
-
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+import org.eclipse.swt.internal.SWTEventListener;
+import org.eclipse.swt.*;
+import org.eclipse.swt.events.*;
+
+/**
+ * Instances of this class are <em>internal SWT implementation</em>
+ * objects which provide a mapping between the typed and untyped
+ * listener mechanisms that SWT supports.
+ * <p>
+ * <b>IMPORTANT:</b> This class is <em>not</em> part of the SWT
+ * public API. It is marked public only so that it can be shared
+ * within the packages provided by SWT. It should never be
+ * referenced from application code.
+ * </p>
+ *
+ * @see Listener
+ *
+ * @private
+ */
+public class TypedListener implements Listener {
+
+ /**
+ * The receiver's event listener
+ */
+ protected SWTEventListener eventListener;
+
+/**
+ * Constructs a new instance of this class for the given event listener.
+ * <p>
+ * <b>IMPORTANT:</b> This method is <em>not</em> part of the SWT
+ * public API. It is marked public only so that it can be shared
+ * within the packages provided by SWT. It should never be
+ * referenced from application code.
+ * </p>
+ *
+ * @param listener the event listener to store in the receiver
+ */
+public TypedListener (SWTEventListener listener) {
+ eventListener = listener;
+}
+
+/**
+ * Returns the receiver's event listener.
+ * <p>
+ * <b>IMPORTANT:</b> This method is <em>not</em> part of the SWT
+ * public API. It is marked public only so that it can be shared
+ * within the packages provided by SWT. It should never be
+ * referenced from application code.
+ * </p>
+ *
+ * @return the receiver's event listener
+ */
+public SWTEventListener getEventListener () {
+ return eventListener;
+}
+
+/**
+ * Handles the given event.
+ * <p>
+ * <b>IMPORTANT:</b> This method is <em>not</em> part of the SWT
+ * public API. It is marked public only so that it can be shared
+ * within the packages provided by SWT. It should never be
+ * referenced from application code.
+ * </p>
+ */
+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/version.txt b/bundles/org.eclipse.swt/Eclipse SWT/common/version.txt
index 9f8d3cf97e..ad7435eb54 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/common/version.txt
+++ b/bundles/org.eclipse.swt/Eclipse SWT/common/version.txt
@@ -1 +1 @@
-version 2.131
+version 2.131
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/common_j2me/org/eclipse/swt/internal/CloneableCompatibility.java b/bundles/org.eclipse.swt/Eclipse SWT/common_j2me/org/eclipse/swt/internal/CloneableCompatibility.java
index 1972538a89..7c1ad12b80 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/common_j2me/org/eclipse/swt/internal/CloneableCompatibility.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/common_j2me/org/eclipse/swt/internal/CloneableCompatibility.java
@@ -1,27 +1,27 @@
-package org.eclipse.swt.internal;
-
-/*
+package org.eclipse.swt.internal;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-/**
- * This interface is the cross-platform version of the
- * java.lang.Cloneable interface.
- * <p>
- * It is part of our effort to provide support for both J2SE
- * and J2ME platforms. Under this scheme, classes need to
- * implement CloneableCompatibility instead of java.lang.Cloneable.
- * </p>
- * <p>
- * Note: java.lang.Cloneable is not part of CLDC.
- * </p>
- * <p>
- * IMPORTANT: CDC mandates Cloneable. Behavior on CLDC will have
- * to be discussed further.
- * </p>
- */
-public interface CloneableCompatibility {
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+/**
+ * This interface is the cross-platform version of the
+ * java.lang.Cloneable interface.
+ * <p>
+ * It is part of our effort to provide support for both J2SE
+ * and J2ME platforms. Under this scheme, classes need to
+ * implement CloneableCompatibility instead of java.lang.Cloneable.
+ * </p>
+ * <p>
+ * Note: java.lang.Cloneable is not part of CLDC.
+ * </p>
+ * <p>
+ * IMPORTANT: CDC mandates Cloneable. Behavior on CLDC will have
+ * to be discussed further.
+ * </p>
+ */
+public interface CloneableCompatibility {
} \ No newline at end of file
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/common_j2me/org/eclipse/swt/internal/Compatibility.java b/bundles/org.eclipse.swt/Eclipse SWT/common_j2me/org/eclipse/swt/internal/Compatibility.java
index 72b155ab0f..01cc49118f 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/common_j2me/org/eclipse/swt/internal/Compatibility.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/common_j2me/org/eclipse/swt/internal/Compatibility.java
@@ -1,392 +1,392 @@
-package org.eclipse.swt.internal;
-
-/*
+package org.eclipse.swt.internal;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-import org.eclipse.swt.SWT;
-import java.io.*;
-
-/**
- * This class is a placeholder for utility methods commonly
- * used on J2SE platforms but not supported on some J2ME
- * profiles.
- * <p>
- * It is part of our effort to provide support for both J2SE
- * and J2ME platforms.
- * </p>
- * <p>
- * IMPORTANT: some of the methods have been modified from their
- * J2SE parents. Refer to the description of each method for
- * specific changes.
- * </p>
- * <ul>
- * <li>Exceptions thrown may differ since J2ME's set of
- * exceptions is a subset of J2SE's one.
- * </li>
- * <li>The range of the mathematic functions is subject to
- * change.
- * </li>
- * </ul>
- */
-public final class Compatibility {
-
-/**
- * Sine table
- * <p>
- * Values represent sine for each degree between 0 and 90. Values have
- * been multiplied by 65536 and rounded.
- * </p>
- */
-static int[] sineTable = {
- 0, 1143, 2287, 3429, 4571, 5711, 6850, 7986, 9120, 10252, // 0 to 9 degrees
- 11380, 12504, 13625, 14742, 15854, 16961, 18064, 19160, 20251, 21336, // 10 to 19 degrees
- 22414, 23486, 24550, 25606, 26655, 27696, 28729, 29752, 30767, 31772, // 20 to 29 degrees
- 32767, 33753, 34728, 35693, 36647, 37589, 38521, 39440, 40347, 41243, // 30 to 39 degrees
- 42125, 42995, 43852, 44695, 45525, 46340, 47142, 47929, 48702, 49460, // 40 to 49 degrees
- 50203, 50931, 51643, 52339, 53019, 53683, 54331, 54963, 55577, 56175, // 50 to 59 degrees
- 56755, 57319, 57864, 58393, 58903, 59395, 59870, 60326, 60763, 61183, // 60 to 69 degrees
- 61583, 61965, 62328, 62672, 62997, 63302, 63589, 63856, 64103, 64331, // 70 to 79 degrees
- 64540, 64729, 64898, 65047, 65176, 65286, 65376, 65446, 65496, 65526, // 80 to 89 degrees
- 65536 }; // 90 degrees
-
-/**
- * Answers the length of the side adjacent to the given angle
- * of a right triangle. In other words, it returns the integer
- * conversion of length * cos (angle).
- * <p>
- * IMPORTANT: the j2me version has an additional restriction on
- * the argument. length must be between -32767 and 32767 (inclusive).
- * </p>
- *
- * @param angle the angle in degrees
- * @param length the length of the triangle's hypotenuse
- * @return the integer conversion of length * cos (angle)
- */
-public static int cos(int angle, int length) {
- return sin(90 - angle, length);
-}
-
-/**
- * Answers the length of the side opposite to the given angle
- * of a right triangle. In other words, it returns the integer
- * conversion of length * sin (angle).
- * <p>
- * IMPORTANT: the j2me version has an additional restriction on
- * the argument. length must be between -32767 and 32767 (inclusive).
- * </p>
- *
- * @param angle the angle in degrees
- * @param length the length of the triangle's hypotenuse
- * @return the integer conversion of length * sin (angle)
- */
-public static int sin(int angle, int length) {
- if (length < -32767 || length > 32767) {
- SWT.error(SWT.ERROR_INVALID_RANGE);
- }
- if (angle < 0 || angle >= 360) {
- angle = angle % 360;
- if (angle < 0) angle += 360;
- }
-
- int sineValue;
- if (angle >= 0 && angle < 90) sineValue = sineTable[angle];
- else if (angle >= 90 && angle < 180) sineValue = sineTable[180 - angle];
- else if (angle >= 180 && angle < 270) sineValue = 0 - sineTable[angle - 180];
- else {
- // angle >= 270 && angle < 360
- sineValue = 0 - sineTable[360 - angle];
- }
-
- return (sineValue * length) >> 16;
-}
-
-/**
- * Answers the most negative (i.e. closest to negative infinity)
- * integer value which is greater than the number obtained by dividing
- * the first argument p by the second argument q.
- *
- * @param p numerator
- * @param q denominator (must be different from zero)
- * @return the ceiling of the rational number p / q.
- */
-public static int ceil(int p, int q) {
- int res = p / q;
- if ((p % q == 0) ||
- (res < 0) ||
- ((res == 0) && ((p < 0 && q > 0) || (p > 0 && q < 0))))
- return res;
- else
- return res + 1;
-}
-
-/**
- * Answers the most positive (i.e. closest to positive infinity)
- * integer value which is less than the number obtained by dividing
- * the first argument p by the second argument q.
- *
- * @param p numerator
- * @param q denominator (must be different from zero)
- * @return the floor of the rational number p / q.
- */
-public static int floor(int p, int q) {
- int res = p / q;
- if ((p % q == 0) ||
- (res > 0) ||
- ((res == 0) && ((p > 0 && q > 0) || (p < 0 && q < 0))))
- return res;
- else
- return res - 1;
-}
-
-/**
- * Answers the result of rounding to the closest integer the number obtained
- * by dividing the first argument p by the second argument q.
- * <p>
- * IMPORTANT: the j2me version has an additional restriction on
- * the arguments. p must be within the range 0 - 32767 (inclusive).
- * q must be within the range 1 - 32767 (inclusive).
- * </p>
- *
- * @param p numerator
- * @param q denominator (must be different from zero)
- * @return the closest integer to the rational number p / q
- */
-public static int round(int p, int q) {
- if (p < 0 || p > 32767 || q < 1 || q > 32767) {
- SWT.error(SWT.ERROR_INVALID_RANGE);
- }
- return (2 * p + q) / (2 * q);
-}
-
-/**
- * Returns 2 raised to the power of the argument.
- *
- * @param n an int value between 0 and 30 (inclusive)
- * @return 2 raised to the power of the argument
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_INVALID_RANGE - if the argument is not between 0 and 30 (inclusive)</li>
- * </ul>
- */
-public static int pow2(int n) {
- if (n >= 1 && n <= 30)
- return 2 << (n - 1);
- else if (n != 0) {
- SWT.error(SWT.ERROR_INVALID_RANGE);
- }
- return 1;
-}
-
-/**
- * Open a file if such things are supported.
- *
- * @param filename the name of the file to open
- * @return a stream on the file if it could be opened.
- */
-public static InputStream newFileInputStream (String filename) throws IOException {
- throw new IOException();
-}
-
-/**
- * Open a file if such things are supported.
- *
- * @param filename the name of the file to open
- * @return a stream on the file if it could be opened.
- */
-public static OutputStream newFileOutputStream (String filename) throws IOException {
- throw new IOException();
-}
-
-/**
- * Answers whether the character is a letter.
- *
- * @param c the character
- * @return true when the character is a letter
- */
-public static boolean isLetter(char c) {
- return (Character.isUpperCase(c)) || (Character.isLowerCase(c));
-}
-
-/**
- * Answers whether the character is a letter or a digit.
- *
- * @param c the character
- * @return true when the character is a letter or a digit
- */
-public static boolean isLetterOrDigit(char c) {
- return isLetter(c) || Character.isDigit(c);
-}
-
-/**
- * Answers whether the character is a Unicode space character.
- *
- * @param c the character
- * @return true when the character is a Unicode space character
- */
-public static boolean isSpaceChar(char c) {
- return c == ' ';
-}
-
-/**
- * Answers whether the character is whitespace character.
- *
- * @param c the character
- * @return true when the character is a whitespace character
- */
-public static boolean isWhitespace(char c) {
- // Optimized case for ASCII
- if ((c >= 0x1c && c <= 0x20) || (c >= 0x9 && c <= 0xd))
- return true;
- return false;
-}
-
-/**
- * Execute a program in a separate platform process if the
- * underlying platform support this.
- * <p>
- * The new process inherits the environment of the caller.
- * </p>
- *
- * @param program the name of the program to execute
- *
- * @exception IOException
- * if the program cannot be executed
- * @exception SecurityException
- * if the current SecurityManager disallows program execution
- */
-public static void exec(String prog) throws java.io.IOException {
- throw new IOException();
-}
-
-/**
- * Execute progArray[0] in a separate platform process if the
- * underlying platform support this.
- * <p>
- * The new process inherits the environment of the caller.
- * <p>
- *
- * @param progArray array containing the program to execute and its arguments
- *
- * @exception IOException
- * if the program cannot be executed
- * @exception SecurityException
- * if the current SecurityManager disallows program execution
- */
-public static void exec(String[] progArray) throws java.io.IOException{
- throw new IOException();
-}
-
-/**
- * Returns the NLS'ed message for the given argument. This is only being
- * called from SWT.
- *
- * @param key the key to look up
- * @return the message for the given key
- *
- * @see SWT#getMessage
- */
-public static String getMessage(String key) {
- if (key == null) SWT.error (SWT.ERROR_NULL_ARGUMENT);
- if (key.equals("SWT_Yes")) return "Yes";
- if (key.equals("SWT_No")) return "No";
- if (key.equals("SWT_OK")) return "OK";
- if (key.equals("SWT_Cancel")) return "Cancel";
- if (key.equals("SWT_Abort")) return "Abort";
- if (key.equals("SWT_Retry")) return "Retry";
- if (key.equals("SWT_Ignore")) return "Ignore";
- if (key.equals("SWT_Sample")) return "Sample";
- if (key.equals("SWT_A_Sample_Text")) return "A Sample Text";
- if (key.equals("SWT_Selection")) return "Selection";
- if (key.equals("SWT_Current_Selection")) return "Current Selection";
- if (key.equals("SWT_Character_set")) return "Character set";
- if (key.equals("SWT_Font")) return "Font";
- if (key.equals("SWT_Extended_style")) return "Extended style";
- if (key.equals("SWT_Size")) return "Size";
- if (key.equals("SWT_Style")) return "Style";
- if (key.equals("SWT_Save")) return "Save";
- if (key.equals("SWT_Character_set")) return "Character set";
- if (key.equals("SWT_ColorDialog_Title")) return "Colors";
- if (key.equals("SWT_FontDialog_Title")) return "Fonts";
- if (key.equals("SWT_Charset_Western")) return "western";
- if (key.equals("SWT_Charset_EastEuropean")) return "east european";
- if (key.equals("SWT_Charset_SouthEuropean")) return "south european";
- if (key.equals("SWT_Charset_NorthEuropean")) return "north european";
- if (key.equals("SWT_Charset_Cyrillic")) return "cyrillic";
- if (key.equals("SWT_Charset_Arabic")) return "arabic";
- if (key.equals("SWT_Charset_Greek")) return "greek";
- if (key.equals("SWT_Charset_Hebrew")) return "hebrew";
- if (key.equals("SWT_Charset_Turkish")) return "turkish";
- if (key.equals("SWT_Charset_Nordic")) return "nordic";
- if (key.equals("SWT_Charset_Thai")) return "thai";
- if (key.equals("SWT_Charset_BalticRim")) return "baltic rim";
- if (key.equals("SWT_Charset_Celtic")) return "celtic";
- if (key.equals("SWT_Charset_Euro")) return "euro";
- if (key.equals("SWT_Charset_Romanian")) return "romanian";
- if (key.equals("SWT_Charset_SimplifiedChinese")) return "simplified chinese";
- if (key.equals("SWT_Charset_TraditionalChinese")) return "traditional chinese";
- if (key.equals("SWT_Charset_Japanese")) return "japanese";
- if (key.equals("SWT_Charset_Korean")) return "korean";
- if (key.equals("SWT_Charset_Unicode")) return "unicode";
- if (key.equals("SWT_Charset_ASCII")) return "ASCII";
- if (key.equals("SWT_InputMethods")) return "Input Methods";
- return key;
-}
-
-/**
- * Interrupt the current thread.
- * <p>
- * Note that this is not available on CLDC.
- * </p>
- */
-public static void interrupt() {
-}
-
-/**
- * Compares two instances of class String ignoring the case of the
- * characters and answers if they are equal.
- *
- * @param s1 string
- * @param s2 string
- * @return true if the two instances of class String are equal
- */
-public static boolean equalsIgnoreCase(String s1, String s2) {
- if (s1 == s2) return true;
- if (s2 == null || s1.length() != s2.length()) return false;
-
- char[] cArray1 = s1.toCharArray();
- char[] cArray2 = s2.toCharArray();
- int length = s1.length();
- char c1, c2;
-
- for (int index = 0; index < length; index++) {
- c1 = cArray1[index];
- c2 = cArray2[index];
- if (c1 != c2 &&
- Character.toUpperCase(c1) != Character.toUpperCase(c2) &&
- Character.toLowerCase(c1) != Character.toLowerCase(c2)) {
- return false;
- }
- }
- return true;
-}
-
-/**
- * Copies a range of characters into a new String.
- *
- * @param buffer the StringBuffer we want to copy from
- * @param start the offset of the first character
- * @param end the offset one past the last character
- * @return a new String containing the characters from start to end - 1
- *
- * @exception IndexOutOfBoundsException
- * when <code>start < 0, start > end</code> or <code>end > length()</code>
- */
-public static String substring(StringBuffer buffer, int start, int end) {
- return buffer.toString().substring(start, end);
-}
-
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+import org.eclipse.swt.SWT;
+import java.io.*;
+
+/**
+ * This class is a placeholder for utility methods commonly
+ * used on J2SE platforms but not supported on some J2ME
+ * profiles.
+ * <p>
+ * It is part of our effort to provide support for both J2SE
+ * and J2ME platforms.
+ * </p>
+ * <p>
+ * IMPORTANT: some of the methods have been modified from their
+ * J2SE parents. Refer to the description of each method for
+ * specific changes.
+ * </p>
+ * <ul>
+ * <li>Exceptions thrown may differ since J2ME's set of
+ * exceptions is a subset of J2SE's one.
+ * </li>
+ * <li>The range of the mathematic functions is subject to
+ * change.
+ * </li>
+ * </ul>
+ */
+public final class Compatibility {
+
+/**
+ * Sine table
+ * <p>
+ * Values represent sine for each degree between 0 and 90. Values have
+ * been multiplied by 65536 and rounded.
+ * </p>
+ */
+static int[] sineTable = {
+ 0, 1143, 2287, 3429, 4571, 5711, 6850, 7986, 9120, 10252, // 0 to 9 degrees
+ 11380, 12504, 13625, 14742, 15854, 16961, 18064, 19160, 20251, 21336, // 10 to 19 degrees
+ 22414, 23486, 24550, 25606, 26655, 27696, 28729, 29752, 30767, 31772, // 20 to 29 degrees
+ 32767, 33753, 34728, 35693, 36647, 37589, 38521, 39440, 40347, 41243, // 30 to 39 degrees
+ 42125, 42995, 43852, 44695, 45525, 46340, 47142, 47929, 48702, 49460, // 40 to 49 degrees
+ 50203, 50931, 51643, 52339, 53019, 53683, 54331, 54963, 55577, 56175, // 50 to 59 degrees
+ 56755, 57319, 57864, 58393, 58903, 59395, 59870, 60326, 60763, 61183, // 60 to 69 degrees
+ 61583, 61965, 62328, 62672, 62997, 63302, 63589, 63856, 64103, 64331, // 70 to 79 degrees
+ 64540, 64729, 64898, 65047, 65176, 65286, 65376, 65446, 65496, 65526, // 80 to 89 degrees
+ 65536 }; // 90 degrees
+
+/**
+ * Answers the length of the side adjacent to the given angle
+ * of a right triangle. In other words, it returns the integer
+ * conversion of length * cos (angle).
+ * <p>
+ * IMPORTANT: the j2me version has an additional restriction on
+ * the argument. length must be between -32767 and 32767 (inclusive).
+ * </p>
+ *
+ * @param angle the angle in degrees
+ * @param length the length of the triangle's hypotenuse
+ * @return the integer conversion of length * cos (angle)
+ */
+public static int cos(int angle, int length) {
+ return sin(90 - angle, length);
+}
+
+/**
+ * Answers the length of the side opposite to the given angle
+ * of a right triangle. In other words, it returns the integer
+ * conversion of length * sin (angle).
+ * <p>
+ * IMPORTANT: the j2me version has an additional restriction on
+ * the argument. length must be between -32767 and 32767 (inclusive).
+ * </p>
+ *
+ * @param angle the angle in degrees
+ * @param length the length of the triangle's hypotenuse
+ * @return the integer conversion of length * sin (angle)
+ */
+public static int sin(int angle, int length) {
+ if (length < -32767 || length > 32767) {
+ SWT.error(SWT.ERROR_INVALID_RANGE);
+ }
+ if (angle < 0 || angle >= 360) {
+ angle = angle % 360;
+ if (angle < 0) angle += 360;
+ }
+
+ int sineValue;
+ if (angle >= 0 && angle < 90) sineValue = sineTable[angle];
+ else if (angle >= 90 && angle < 180) sineValue = sineTable[180 - angle];
+ else if (angle >= 180 && angle < 270) sineValue = 0 - sineTable[angle - 180];
+ else {
+ // angle >= 270 && angle < 360
+ sineValue = 0 - sineTable[360 - angle];
+ }
+
+ return (sineValue * length) >> 16;
+}
+
+/**
+ * Answers the most negative (i.e. closest to negative infinity)
+ * integer value which is greater than the number obtained by dividing
+ * the first argument p by the second argument q.
+ *
+ * @param p numerator
+ * @param q denominator (must be different from zero)
+ * @return the ceiling of the rational number p / q.
+ */
+public static int ceil(int p, int q) {
+ int res = p / q;
+ if ((p % q == 0) ||
+ (res < 0) ||
+ ((res == 0) && ((p < 0 && q > 0) || (p > 0 && q < 0))))
+ return res;
+ else
+ return res + 1;
+}
+
+/**
+ * Answers the most positive (i.e. closest to positive infinity)
+ * integer value which is less than the number obtained by dividing
+ * the first argument p by the second argument q.
+ *
+ * @param p numerator
+ * @param q denominator (must be different from zero)
+ * @return the floor of the rational number p / q.
+ */
+public static int floor(int p, int q) {
+ int res = p / q;
+ if ((p % q == 0) ||
+ (res > 0) ||
+ ((res == 0) && ((p > 0 && q > 0) || (p < 0 && q < 0))))
+ return res;
+ else
+ return res - 1;
+}
+
+/**
+ * Answers the result of rounding to the closest integer the number obtained
+ * by dividing the first argument p by the second argument q.
+ * <p>
+ * IMPORTANT: the j2me version has an additional restriction on
+ * the arguments. p must be within the range 0 - 32767 (inclusive).
+ * q must be within the range 1 - 32767 (inclusive).
+ * </p>
+ *
+ * @param p numerator
+ * @param q denominator (must be different from zero)
+ * @return the closest integer to the rational number p / q
+ */
+public static int round(int p, int q) {
+ if (p < 0 || p > 32767 || q < 1 || q > 32767) {
+ SWT.error(SWT.ERROR_INVALID_RANGE);
+ }
+ return (2 * p + q) / (2 * q);
+}
+
+/**
+ * Returns 2 raised to the power of the argument.
+ *
+ * @param n an int value between 0 and 30 (inclusive)
+ * @return 2 raised to the power of the argument
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_INVALID_RANGE - if the argument is not between 0 and 30 (inclusive)</li>
+ * </ul>
+ */
+public static int pow2(int n) {
+ if (n >= 1 && n <= 30)
+ return 2 << (n - 1);
+ else if (n != 0) {
+ SWT.error(SWT.ERROR_INVALID_RANGE);
+ }
+ return 1;
+}
+
+/**
+ * Open a file if such things are supported.
+ *
+ * @param filename the name of the file to open
+ * @return a stream on the file if it could be opened.
+ */
+public static InputStream newFileInputStream (String filename) throws IOException {
+ throw new IOException();
+}
+
+/**
+ * Open a file if such things are supported.
+ *
+ * @param filename the name of the file to open
+ * @return a stream on the file if it could be opened.
+ */
+public static OutputStream newFileOutputStream (String filename) throws IOException {
+ throw new IOException();
+}
+
+/**
+ * Answers whether the character is a letter.
+ *
+ * @param c the character
+ * @return true when the character is a letter
+ */
+public static boolean isLetter(char c) {
+ return (Character.isUpperCase(c)) || (Character.isLowerCase(c));
+}
+
+/**
+ * Answers whether the character is a letter or a digit.
+ *
+ * @param c the character
+ * @return true when the character is a letter or a digit
+ */
+public static boolean isLetterOrDigit(char c) {
+ return isLetter(c) || Character.isDigit(c);
+}
+
+/**
+ * Answers whether the character is a Unicode space character.
+ *
+ * @param c the character
+ * @return true when the character is a Unicode space character
+ */
+public static boolean isSpaceChar(char c) {
+ return c == ' ';
+}
+
+/**
+ * Answers whether the character is whitespace character.
+ *
+ * @param c the character
+ * @return true when the character is a whitespace character
+ */
+public static boolean isWhitespace(char c) {
+ // Optimized case for ASCII
+ if ((c >= 0x1c && c <= 0x20) || (c >= 0x9 && c <= 0xd))
+ return true;
+ return false;
+}
+
+/**
+ * Execute a program in a separate platform process if the
+ * underlying platform support this.
+ * <p>
+ * The new process inherits the environment of the caller.
+ * </p>
+ *
+ * @param program the name of the program to execute
+ *
+ * @exception IOException
+ * if the program cannot be executed
+ * @exception SecurityException
+ * if the current SecurityManager disallows program execution
+ */
+public static void exec(String prog) throws java.io.IOException {
+ throw new IOException();
+}
+
+/**
+ * Execute progArray[0] in a separate platform process if the
+ * underlying platform support this.
+ * <p>
+ * The new process inherits the environment of the caller.
+ * <p>
+ *
+ * @param progArray array containing the program to execute and its arguments
+ *
+ * @exception IOException
+ * if the program cannot be executed
+ * @exception SecurityException
+ * if the current SecurityManager disallows program execution
+ */
+public static void exec(String[] progArray) throws java.io.IOException{
+ throw new IOException();
+}
+
+/**
+ * Returns the NLS'ed message for the given argument. This is only being
+ * called from SWT.
+ *
+ * @param key the key to look up
+ * @return the message for the given key
+ *
+ * @see SWT#getMessage
+ */
+public static String getMessage(String key) {
+ if (key == null) SWT.error (SWT.ERROR_NULL_ARGUMENT);
+ if (key.equals("SWT_Yes")) return "Yes";
+ if (key.equals("SWT_No")) return "No";
+ if (key.equals("SWT_OK")) return "OK";
+ if (key.equals("SWT_Cancel")) return "Cancel";
+ if (key.equals("SWT_Abort")) return "Abort";
+ if (key.equals("SWT_Retry")) return "Retry";
+ if (key.equals("SWT_Ignore")) return "Ignore";
+ if (key.equals("SWT_Sample")) return "Sample";
+ if (key.equals("SWT_A_Sample_Text")) return "A Sample Text";
+ if (key.equals("SWT_Selection")) return "Selection";
+ if (key.equals("SWT_Current_Selection")) return "Current Selection";
+ if (key.equals("SWT_Character_set")) return "Character set";
+ if (key.equals("SWT_Font")) return "Font";
+ if (key.equals("SWT_Extended_style")) return "Extended style";
+ if (key.equals("SWT_Size")) return "Size";
+ if (key.equals("SWT_Style")) return "Style";
+ if (key.equals("SWT_Save")) return "Save";
+ if (key.equals("SWT_Character_set")) return "Character set";
+ if (key.equals("SWT_ColorDialog_Title")) return "Colors";
+ if (key.equals("SWT_FontDialog_Title")) return "Fonts";
+ if (key.equals("SWT_Charset_Western")) return "western";
+ if (key.equals("SWT_Charset_EastEuropean")) return "east european";
+ if (key.equals("SWT_Charset_SouthEuropean")) return "south european";
+ if (key.equals("SWT_Charset_NorthEuropean")) return "north european";
+ if (key.equals("SWT_Charset_Cyrillic")) return "cyrillic";
+ if (key.equals("SWT_Charset_Arabic")) return "arabic";
+ if (key.equals("SWT_Charset_Greek")) return "greek";
+ if (key.equals("SWT_Charset_Hebrew")) return "hebrew";
+ if (key.equals("SWT_Charset_Turkish")) return "turkish";
+ if (key.equals("SWT_Charset_Nordic")) return "nordic";
+ if (key.equals("SWT_Charset_Thai")) return "thai";
+ if (key.equals("SWT_Charset_BalticRim")) return "baltic rim";
+ if (key.equals("SWT_Charset_Celtic")) return "celtic";
+ if (key.equals("SWT_Charset_Euro")) return "euro";
+ if (key.equals("SWT_Charset_Romanian")) return "romanian";
+ if (key.equals("SWT_Charset_SimplifiedChinese")) return "simplified chinese";
+ if (key.equals("SWT_Charset_TraditionalChinese")) return "traditional chinese";
+ if (key.equals("SWT_Charset_Japanese")) return "japanese";
+ if (key.equals("SWT_Charset_Korean")) return "korean";
+ if (key.equals("SWT_Charset_Unicode")) return "unicode";
+ if (key.equals("SWT_Charset_ASCII")) return "ASCII";
+ if (key.equals("SWT_InputMethods")) return "Input Methods";
+ return key;
+}
+
+/**
+ * Interrupt the current thread.
+ * <p>
+ * Note that this is not available on CLDC.
+ * </p>
+ */
+public static void interrupt() {
+}
+
+/**
+ * Compares two instances of class String ignoring the case of the
+ * characters and answers if they are equal.
+ *
+ * @param s1 string
+ * @param s2 string
+ * @return true if the two instances of class String are equal
+ */
+public static boolean equalsIgnoreCase(String s1, String s2) {
+ if (s1 == s2) return true;
+ if (s2 == null || s1.length() != s2.length()) return false;
+
+ char[] cArray1 = s1.toCharArray();
+ char[] cArray2 = s2.toCharArray();
+ int length = s1.length();
+ char c1, c2;
+
+ for (int index = 0; index < length; index++) {
+ c1 = cArray1[index];
+ c2 = cArray2[index];
+ if (c1 != c2 &&
+ Character.toUpperCase(c1) != Character.toUpperCase(c2) &&
+ Character.toLowerCase(c1) != Character.toLowerCase(c2)) {
+ return false;
+ }
+ }
+ return true;
+}
+
+/**
+ * Copies a range of characters into a new String.
+ *
+ * @param buffer the StringBuffer we want to copy from
+ * @param start the offset of the first character
+ * @param end the offset one past the last character
+ * @return a new String containing the characters from start to end - 1
+ *
+ * @exception IndexOutOfBoundsException
+ * when <code>start < 0, start > end</code> or <code>end > length()</code>
+ */
+public static String substring(StringBuffer buffer, int start, int end) {
+ return buffer.toString().substring(start, end);
+}
+
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/common_j2me/org/eclipse/swt/internal/SWTEventListener.java b/bundles/org.eclipse.swt/Eclipse SWT/common_j2me/org/eclipse/swt/internal/SWTEventListener.java
index a31d38ef82..4f8bb49e46 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/common_j2me/org/eclipse/swt/internal/SWTEventListener.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/common_j2me/org/eclipse/swt/internal/SWTEventListener.java
@@ -1,23 +1,23 @@
-package org.eclipse.swt.internal;
-
-/*
+package org.eclipse.swt.internal;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-/**
- * This interface is the cross-platform version of the
- * java.util.EventListener interface.
- * <p>
- * It is part of our effort to provide support for both J2SE
- * and J2ME platforms. Under this scheme, classes need to
- * implement SWTEventListener instead of java.util.EventListener.
- * </p>
- * <p>
- * Note: java.util.EventListener is not part of CDC and CLDC.
- * </p>
- */
-public interface SWTEventListener {
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+/**
+ * This interface is the cross-platform version of the
+ * java.util.EventListener interface.
+ * <p>
+ * It is part of our effort to provide support for both J2SE
+ * and J2ME platforms. Under this scheme, classes need to
+ * implement SWTEventListener instead of java.util.EventListener.
+ * </p>
+ * <p>
+ * Note: java.util.EventListener is not part of CDC and CLDC.
+ * </p>
+ */
+public interface SWTEventListener {
} \ No newline at end of file
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/common_j2me/org/eclipse/swt/internal/SWTEventObject.java b/bundles/org.eclipse.swt/Eclipse SWT/common_j2me/org/eclipse/swt/internal/SWTEventObject.java
index fd5be03d13..c1fdf3c007 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/common_j2me/org/eclipse/swt/internal/SWTEventObject.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/common_j2me/org/eclipse/swt/internal/SWTEventObject.java
@@ -1,57 +1,57 @@
-package org.eclipse.swt.internal;
-
-/*
+package org.eclipse.swt.internal;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-/**
- * This class is the cross-platform version of the
- * java.util.EventObject class.
- * <p>
- * It is part of our effort to provide support for both J2SE
- * and J2ME platforms. Under this scheme, classes need to
- * extend SWTEventObject instead of java.util.EventObject.
- * </p>
- * <p>
- * Note: java.util.EventObject is not part of CDC and CLDC.
- * </p>
- */
-public class SWTEventObject implements SerializableCompatibility {
-
- /**
- * The event source.
- */
- protected transient Object source;
-
-/**
- * Constructs a new instance of this class.
- *
- * @param source the object which fired the event
- */
-public SWTEventObject(Object source) {
- if (source != null) this.source = source;
- else throw new IllegalArgumentException();
-}
-
-/**
- * Answers the event source.
- *
- * @return the object which fired the event
- */
-public Object getSource() {
- return source;
-}
-
-/**
- * Answers the string representation of this SWTEventObject.
- *
- * @return the string representation of this SWTEventObject
- */
-public String toString() {
- return getClass().getName() + "[source=" + String.valueOf(source) + ']';
-}
-
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+/**
+ * This class is the cross-platform version of the
+ * java.util.EventObject class.
+ * <p>
+ * It is part of our effort to provide support for both J2SE
+ * and J2ME platforms. Under this scheme, classes need to
+ * extend SWTEventObject instead of java.util.EventObject.
+ * </p>
+ * <p>
+ * Note: java.util.EventObject is not part of CDC and CLDC.
+ * </p>
+ */
+public class SWTEventObject implements SerializableCompatibility {
+
+ /**
+ * The event source.
+ */
+ protected transient Object source;
+
+/**
+ * Constructs a new instance of this class.
+ *
+ * @param source the object which fired the event
+ */
+public SWTEventObject(Object source) {
+ if (source != null) this.source = source;
+ else throw new IllegalArgumentException();
+}
+
+/**
+ * Answers the event source.
+ *
+ * @return the object which fired the event
+ */
+public Object getSource() {
+ return source;
+}
+
+/**
+ * Answers the string representation of this SWTEventObject.
+ *
+ * @return the string representation of this SWTEventObject
+ */
+public String toString() {
+ return getClass().getName() + "[source=" + String.valueOf(source) + ']';
+}
+
} \ No newline at end of file
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/common_j2me/org/eclipse/swt/internal/SerializableCompatibility.java b/bundles/org.eclipse.swt/Eclipse SWT/common_j2me/org/eclipse/swt/internal/SerializableCompatibility.java
index 1d9ea39120..acf71e235a 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/common_j2me/org/eclipse/swt/internal/SerializableCompatibility.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/common_j2me/org/eclipse/swt/internal/SerializableCompatibility.java
@@ -1,28 +1,28 @@
-package org.eclipse.swt.internal;
-
-/*
+package org.eclipse.swt.internal;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-/**
- * This interface is the cross-platform version of the
- * java.io.Serializable interface.
- * <p>
- * It is part of our effort to provide support for both J2SE
- * and J2ME platforms. Under this scheme, classes need to
- * implement SerializableCompatibility instead of
- * java.io.Serializable.
- * </p>
- * <p>
- * Note: java.io.Serializable is not part of CLDC.
- * </p>
- * <p>
- * IMPORTANT: CDC mandates Serializable. Behavior on CLDC will have
- * to be discussed further.
- * </p>
- */
-public interface SerializableCompatibility {
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+/**
+ * This interface is the cross-platform version of the
+ * java.io.Serializable interface.
+ * <p>
+ * It is part of our effort to provide support for both J2SE
+ * and J2ME platforms. Under this scheme, classes need to
+ * implement SerializableCompatibility instead of
+ * java.io.Serializable.
+ * </p>
+ * <p>
+ * Note: java.io.Serializable is not part of CLDC.
+ * </p>
+ * <p>
+ * IMPORTANT: CDC mandates Serializable. Behavior on CLDC will have
+ * to be discussed further.
+ * </p>
+ */
+public interface SerializableCompatibility {
} \ No newline at end of file
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/common_j2se/org/eclipse/swt/internal/CloneableCompatibility.java b/bundles/org.eclipse.swt/Eclipse SWT/common_j2se/org/eclipse/swt/internal/CloneableCompatibility.java
index 54b8d35d25..b5f679f934 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/common_j2se/org/eclipse/swt/internal/CloneableCompatibility.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/common_j2se/org/eclipse/swt/internal/CloneableCompatibility.java
@@ -1,23 +1,23 @@
-package org.eclipse.swt.internal;
-
-/*
+package org.eclipse.swt.internal;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-/**
- * This interface is the cross-platform version of the
- * java.lang.Cloneable interface.
- * <p>
- * It is part of our effort to provide support for both J2SE
- * and J2ME platforms. Under this scheme, classes need to
- * implement CloneableCompatibility instead of java.lang.Cloneable.
- * </p>
- * <p>
- * Note: java.lang.Cloneable is not part of CLDC.
- * </p>
- */
-public interface CloneableCompatibility extends Cloneable {
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+/**
+ * This interface is the cross-platform version of the
+ * java.lang.Cloneable interface.
+ * <p>
+ * It is part of our effort to provide support for both J2SE
+ * and J2ME platforms. Under this scheme, classes need to
+ * implement CloneableCompatibility instead of java.lang.Cloneable.
+ * </p>
+ * <p>
+ * Note: java.lang.Cloneable is not part of CLDC.
+ * </p>
+ */
+public interface CloneableCompatibility extends Cloneable {
} \ No newline at end of file
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/common_j2se/org/eclipse/swt/internal/Compatibility.java b/bundles/org.eclipse.swt/Eclipse SWT/common_j2se/org/eclipse/swt/internal/Compatibility.java
index 068e57a933..2f10d38af5 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/common_j2se/org/eclipse/swt/internal/Compatibility.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/common_j2se/org/eclipse/swt/internal/Compatibility.java
@@ -1,303 +1,303 @@
-package org.eclipse.swt.internal;
-
-/*
+package org.eclipse.swt.internal;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-import java.io.*;
-import java.util.MissingResourceException;
-import java.util.ResourceBundle;
-import org.eclipse.swt.SWT;
-
-/**
- * This class is a placeholder for utility methods commonly
- * used on J2SE platforms but not supported on some J2ME
- * profiles.
- * <p>
- * It is part of our effort to provide support for both J2SE
- * and J2ME platforms.
- * </p>
- * <p>
- * IMPORTANT: some of the methods have been modified from their
- * J2SE parents. Refer to the description of each method for
- * specific changes.
- * </p>
- * <ul>
- * <li>Exceptions thrown may differ since J2ME's set of
- * exceptions is a subset of J2SE's one.
- * </li>
- * <li>The range of the mathematic functions is subject to
- * change.
- * </li>
- * </ul>
- */
-public final class Compatibility {
-
-static double pi = 3.1415926535;
-static double toRadians = pi / 180;
-
-/**
- * Answers the length of the side adjacent to the given angle
- * of a right triangle. In other words, it returns the integer
- * conversion of length * cos (angle).
- * <p>
- * IMPORTANT: the j2me version has an additional restriction on
- * the argument. length must be between -32767 and 32767 (inclusive).
- * </p>
- *
- * @param angle the angle in degrees
- * @param length the length of the triangle's hypotenuse
- * @return the integer conversion of length * cos (angle)
- */
-public static int cos(int angle, int length) {
- return (int)(Math.cos(angle * toRadians) * length);
-}
-
-/**
- * Answers the length of the side opposite to the given angle
- * of a right triangle. In other words, it returns the integer
- * conversion of length * sin (angle).
- * <p>
- * IMPORTANT: the j2me version has an additional restriction on
- * the argument. length must be between -32767 and 32767 (inclusive).
- * </p>
- *
- * @param angle the angle in degrees
- * @param length the length of the triangle's hypotenuse
- * @return the integer conversion of length * sin (angle)
- */
-public static int sin(int angle, int length) {
- return (int)(Math.sin(angle * toRadians) * length);
-}
-
-/**
- * Answers the most negative (i.e. closest to negative infinity)
- * integer value which is greater than the number obtained by dividing
- * the first argument p by the second argument q.
- *
- * @param p numerator
- * @param q denominator (must be different from zero)
- * @return the ceiling of the rational number p / q.
- */
-public static int ceil(int p, int q) {
- return (int)Math.ceil((float)p / q);
-}
-
-/**
- * Answers the most positive (i.e. closest to positive infinity)
- * integer value which is less than the number obtained by dividing
- * the first argument p by the second argument q.
- *
- * @param p numerator
- * @param q denominator (must be different from zero)
- * @return the floor of the rational number p / q.
- */
-public static int floor(int p, int q) {
- return (int)Math.floor((double)p / q);
-}
-
-/**
- * Answers the result of rounding to the closest integer the number obtained
- * by dividing the first argument p by the second argument q.
- * <p>
- * IMPORTANT: the j2me version has an additional restriction on
- * the arguments. p must be within the range 0 - 32767 (inclusive).
- * q must be within the range 1 - 32767 (inclusive).
- * </p>
- *
- * @param p numerator
- * @param q denominator (must be different from zero)
- * @return the closest integer to the rational number p / q
- */
-public static int round(int p, int q) {
- return (int)Math.round((float)p / q);
-}
-
-/**
- * Returns 2 raised to the power of the argument.
- *
- * @param n an int value between 0 and 30 (inclusive)
- * @return 2 raised to the power of the argument
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_INVALID_RANGE - if the argument is not between 0 and 30 (inclusive)</li>
- * </ul>
- */
-public static int pow2(int n) {
- if (n >= 1 && n <= 30)
- return 2 << (n - 1);
- else if (n != 0) {
- SWT.error(SWT.ERROR_INVALID_RANGE);
- }
- return 1;
-}
-
-/**
- * Open a file if such things are supported.
- *
- * @param filename the name of the file to open
- * @return a stream on the file if it could be opened.
- */
-public static InputStream newFileInputStream(String filename) throws IOException {
- return new FileInputStream(filename);
-}
-
-/**
- * Open a file if such things are supported.
- *
- * @param filename the name of the file to open
- * @return a stream on the file if it could be opened.
- */
-public static OutputStream newFileOutputStream(String filename) throws IOException {
- return new FileOutputStream(filename);
-}
-
-/**
- * Answers whether the character is a letter.
- *
- * @param c the character
- * @return true when the character is a letter
- */
-public static boolean isLetter(char c) {
- return Character.isLetter(c);
-}
-
-/**
- * Answers whether the character is a letter or a digit.
- *
- * @param c the character
- * @return true when the character is a letter or a digit
- */
-public static boolean isLetterOrDigit(char c) {
- return Character.isLetterOrDigit(c);
-}
-
-/**
- * Answers whether the character is a Unicode space character.
- *
- * @param c the character
- * @return true when the character is a Unicode space character
- */
-public static boolean isSpaceChar(char c) {
- return Character.isSpaceChar(c);
-}
-
-/**
- * Answers whether the character is a whitespace character.
- *
- * @param ch the character to test
- * @return true if the character is whitespace
- */
-public static boolean isWhitespace(char c) {
- return Character.isWhitespace(c);
-}
-
-/**
- * Execute a program in a separate platform process if the
- * underlying platform support this.
- * <p>
- * The new process inherits the environment of the caller.
- * </p>
- *
- * @param program the name of the program to execute
- *
- * @exception IOException
- * if the program cannot be executed
- * @exception SecurityException
- * if the current SecurityManager disallows program execution
- */
-public static void exec(String prog) throws java.io.IOException {
- Runtime.getRuntime().exec(prog);
-}
-
-/**
- * Execute progArray[0] in a separate platform process if the
- * underlying platform support this.
- * <p>
- * The new process inherits the environment of the caller.
- * <p>
- *
- * @param progArray array containing the program to execute and its arguments
- *
- * @exception IOException
- * if the program cannot be executed
- * @exception SecurityException
- * if the current SecurityManager disallows program execution
- */
-public static void exec(String[] progArray) throws java.io.IOException{
- Runtime.getRuntime().exec(progArray);
-}
-
-private static ResourceBundle msgs = null;
-
-/**
- * Returns the NLS'ed message for the given argument. This is only being
- * called from SWT.
- *
- * @param key the key to look up
- * @return the message for the given key
- *
- * @see SWT#getMessage
- */
-public static String getMessage(String key) {
- String answer = key;
-
- if (key == null) {
- SWT.error (SWT.ERROR_NULL_ARGUMENT);
- }
- if (msgs == null) {
- try {
- msgs = ResourceBundle.getBundle("org.eclipse.swt.internal.SWTMessages");
- } catch (MissingResourceException ex) {
- answer = key + " (no resource bundle)";
- }
- }
- if (msgs != null) {
- try {
- answer = msgs.getString(key);
- } catch (MissingResourceException ex2) {}
- }
- return answer;
-}
-
-/**
- * Interrupt the current thread.
- * <p>
- * Note that this is not available on CLDC.
- * </p>
- */
-public static void interrupt() {
- Thread.currentThread().interrupt();
-}
-
-/**
- * Compares two instances of class String ignoring the case of the
- * characters and answers if they are equal.
- *
- * @param s1 string
- * @param s2 string
- * @return true if the two instances of class String are equal
- */
-public static boolean equalsIgnoreCase(String s1, String s2) {
- return s1.equalsIgnoreCase(s2);
-}
-
-/**
- * Copies a range of characters into a new String.
- *
- * @param buffer the StringBuffer we want to copy from
- * @param start the offset of the first character
- * @param end the offset one past the last character
- * @return a new String containing the characters from start to end - 1
- *
- * @exception IndexOutOfBoundsException
- * when <code>start < 0, start > end</code> or <code>end > length()</code>
- */
-public static String substring(StringBuffer buffer, int start, int end) {
- return buffer.substring(start, end);
-}
-
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+import java.io.*;
+import java.util.MissingResourceException;
+import java.util.ResourceBundle;
+import org.eclipse.swt.SWT;
+
+/**
+ * This class is a placeholder for utility methods commonly
+ * used on J2SE platforms but not supported on some J2ME
+ * profiles.
+ * <p>
+ * It is part of our effort to provide support for both J2SE
+ * and J2ME platforms.
+ * </p>
+ * <p>
+ * IMPORTANT: some of the methods have been modified from their
+ * J2SE parents. Refer to the description of each method for
+ * specific changes.
+ * </p>
+ * <ul>
+ * <li>Exceptions thrown may differ since J2ME's set of
+ * exceptions is a subset of J2SE's one.
+ * </li>
+ * <li>The range of the mathematic functions is subject to
+ * change.
+ * </li>
+ * </ul>
+ */
+public final class Compatibility {
+
+static double pi = 3.1415926535;
+static double toRadians = pi / 180;
+
+/**
+ * Answers the length of the side adjacent to the given angle
+ * of a right triangle. In other words, it returns the integer
+ * conversion of length * cos (angle).
+ * <p>
+ * IMPORTANT: the j2me version has an additional restriction on
+ * the argument. length must be between -32767 and 32767 (inclusive).
+ * </p>
+ *
+ * @param angle the angle in degrees
+ * @param length the length of the triangle's hypotenuse
+ * @return the integer conversion of length * cos (angle)
+ */
+public static int cos(int angle, int length) {
+ return (int)(Math.cos(angle * toRadians) * length);
+}
+
+/**
+ * Answers the length of the side opposite to the given angle
+ * of a right triangle. In other words, it returns the integer
+ * conversion of length * sin (angle).
+ * <p>
+ * IMPORTANT: the j2me version has an additional restriction on
+ * the argument. length must be between -32767 and 32767 (inclusive).
+ * </p>
+ *
+ * @param angle the angle in degrees
+ * @param length the length of the triangle's hypotenuse
+ * @return the integer conversion of length * sin (angle)
+ */
+public static int sin(int angle, int length) {
+ return (int)(Math.sin(angle * toRadians) * length);
+}
+
+/**
+ * Answers the most negative (i.e. closest to negative infinity)
+ * integer value which is greater than the number obtained by dividing
+ * the first argument p by the second argument q.
+ *
+ * @param p numerator
+ * @param q denominator (must be different from zero)
+ * @return the ceiling of the rational number p / q.
+ */
+public static int ceil(int p, int q) {
+ return (int)Math.ceil((float)p / q);
+}
+
+/**
+ * Answers the most positive (i.e. closest to positive infinity)
+ * integer value which is less than the number obtained by dividing
+ * the first argument p by the second argument q.
+ *
+ * @param p numerator
+ * @param q denominator (must be different from zero)
+ * @return the floor of the rational number p / q.
+ */
+public static int floor(int p, int q) {
+ return (int)Math.floor((double)p / q);
+}
+
+/**
+ * Answers the result of rounding to the closest integer the number obtained
+ * by dividing the first argument p by the second argument q.
+ * <p>
+ * IMPORTANT: the j2me version has an additional restriction on
+ * the arguments. p must be within the range 0 - 32767 (inclusive).
+ * q must be within the range 1 - 32767 (inclusive).
+ * </p>
+ *
+ * @param p numerator
+ * @param q denominator (must be different from zero)
+ * @return the closest integer to the rational number p / q
+ */
+public static int round(int p, int q) {
+ return (int)Math.round((float)p / q);
+}
+
+/**
+ * Returns 2 raised to the power of the argument.
+ *
+ * @param n an int value between 0 and 30 (inclusive)
+ * @return 2 raised to the power of the argument
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_INVALID_RANGE - if the argument is not between 0 and 30 (inclusive)</li>
+ * </ul>
+ */
+public static int pow2(int n) {
+ if (n >= 1 && n <= 30)
+ return 2 << (n - 1);
+ else if (n != 0) {
+ SWT.error(SWT.ERROR_INVALID_RANGE);
+ }
+ return 1;
+}
+
+/**
+ * Open a file if such things are supported.
+ *
+ * @param filename the name of the file to open
+ * @return a stream on the file if it could be opened.
+ */
+public static InputStream newFileInputStream(String filename) throws IOException {
+ return new FileInputStream(filename);
+}
+
+/**
+ * Open a file if such things are supported.
+ *
+ * @param filename the name of the file to open
+ * @return a stream on the file if it could be opened.
+ */
+public static OutputStream newFileOutputStream(String filename) throws IOException {
+ return new FileOutputStream(filename);
+}
+
+/**
+ * Answers whether the character is a letter.
+ *
+ * @param c the character
+ * @return true when the character is a letter
+ */
+public static boolean isLetter(char c) {
+ return Character.isLetter(c);
+}
+
+/**
+ * Answers whether the character is a letter or a digit.
+ *
+ * @param c the character
+ * @return true when the character is a letter or a digit
+ */
+public static boolean isLetterOrDigit(char c) {
+ return Character.isLetterOrDigit(c);
+}
+
+/**
+ * Answers whether the character is a Unicode space character.
+ *
+ * @param c the character
+ * @return true when the character is a Unicode space character
+ */
+public static boolean isSpaceChar(char c) {
+ return Character.isSpaceChar(c);
+}
+
+/**
+ * Answers whether the character is a whitespace character.
+ *
+ * @param ch the character to test
+ * @return true if the character is whitespace
+ */
+public static boolean isWhitespace(char c) {
+ return Character.isWhitespace(c);
+}
+
+/**
+ * Execute a program in a separate platform process if the
+ * underlying platform support this.
+ * <p>
+ * The new process inherits the environment of the caller.
+ * </p>
+ *
+ * @param program the name of the program to execute
+ *
+ * @exception IOException
+ * if the program cannot be executed
+ * @exception SecurityException
+ * if the current SecurityManager disallows program execution
+ */
+public static void exec(String prog) throws java.io.IOException {
+ Runtime.getRuntime().exec(prog);
+}
+
+/**
+ * Execute progArray[0] in a separate platform process if the
+ * underlying platform support this.
+ * <p>
+ * The new process inherits the environment of the caller.
+ * <p>
+ *
+ * @param progArray array containing the program to execute and its arguments
+ *
+ * @exception IOException
+ * if the program cannot be executed
+ * @exception SecurityException
+ * if the current SecurityManager disallows program execution
+ */
+public static void exec(String[] progArray) throws java.io.IOException{
+ Runtime.getRuntime().exec(progArray);
+}
+
+private static ResourceBundle msgs = null;
+
+/**
+ * Returns the NLS'ed message for the given argument. This is only being
+ * called from SWT.
+ *
+ * @param key the key to look up
+ * @return the message for the given key
+ *
+ * @see SWT#getMessage
+ */
+public static String getMessage(String key) {
+ String answer = key;
+
+ if (key == null) {
+ SWT.error (SWT.ERROR_NULL_ARGUMENT);
+ }
+ if (msgs == null) {
+ try {
+ msgs = ResourceBundle.getBundle("org.eclipse.swt.internal.SWTMessages");
+ } catch (MissingResourceException ex) {
+ answer = key + " (no resource bundle)";
+ }
+ }
+ if (msgs != null) {
+ try {
+ answer = msgs.getString(key);
+ } catch (MissingResourceException ex2) {}
+ }
+ return answer;
+}
+
+/**
+ * Interrupt the current thread.
+ * <p>
+ * Note that this is not available on CLDC.
+ * </p>
+ */
+public static void interrupt() {
+ Thread.currentThread().interrupt();
+}
+
+/**
+ * Compares two instances of class String ignoring the case of the
+ * characters and answers if they are equal.
+ *
+ * @param s1 string
+ * @param s2 string
+ * @return true if the two instances of class String are equal
+ */
+public static boolean equalsIgnoreCase(String s1, String s2) {
+ return s1.equalsIgnoreCase(s2);
+}
+
+/**
+ * Copies a range of characters into a new String.
+ *
+ * @param buffer the StringBuffer we want to copy from
+ * @param start the offset of the first character
+ * @param end the offset one past the last character
+ * @return a new String containing the characters from start to end - 1
+ *
+ * @exception IndexOutOfBoundsException
+ * when <code>start < 0, start > end</code> or <code>end > length()</code>
+ */
+public static String substring(StringBuffer buffer, int start, int end) {
+ return buffer.substring(start, end);
+}
+
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/common_j2se/org/eclipse/swt/internal/SWTEventListener.java b/bundles/org.eclipse.swt/Eclipse SWT/common_j2se/org/eclipse/swt/internal/SWTEventListener.java
index a2f1cd6999..7099aad332 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/common_j2se/org/eclipse/swt/internal/SWTEventListener.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/common_j2se/org/eclipse/swt/internal/SWTEventListener.java
@@ -1,25 +1,25 @@
-package org.eclipse.swt.internal;
-
-/*
+package org.eclipse.swt.internal;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-import java.util.EventListener;
-
-/**
- * This interface is the cross-platform version of the
- * java.util.EventListener interface.
- * <p>
- * It is part of our effort to provide support for both J2SE
- * and J2ME platforms. Under this scheme, classes need to
- * implement SWTEventListener instead of java.util.EventListener.
- * </p>
- * <p>
- * Note: java.util.EventListener is not part of CDC and CLDC.
- * </p>
- */
-public interface SWTEventListener extends EventListener {
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+import java.util.EventListener;
+
+/**
+ * This interface is the cross-platform version of the
+ * java.util.EventListener interface.
+ * <p>
+ * It is part of our effort to provide support for both J2SE
+ * and J2ME platforms. Under this scheme, classes need to
+ * implement SWTEventListener instead of java.util.EventListener.
+ * </p>
+ * <p>
+ * Note: java.util.EventListener is not part of CDC and CLDC.
+ * </p>
+ */
+public interface SWTEventListener extends EventListener {
} \ No newline at end of file
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/common_j2se/org/eclipse/swt/internal/SWTEventObject.java b/bundles/org.eclipse.swt/Eclipse SWT/common_j2se/org/eclipse/swt/internal/SWTEventObject.java
index af6499fc12..1232f736f6 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/common_j2se/org/eclipse/swt/internal/SWTEventObject.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/common_j2se/org/eclipse/swt/internal/SWTEventObject.java
@@ -1,34 +1,34 @@
-package org.eclipse.swt.internal;
-
-/*
+package org.eclipse.swt.internal;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-import java.util.EventObject;
-
-/**
- * This class is the cross-platform version of the
- * java.util.EventObject class.
- * <p>
- * It is part of our effort to provide support for both J2SE
- * and J2ME platforms. Under this scheme, classes need to
- * extend SWTEventObject instead of java.util.EventObject.
- * </p>
- * <p>
- * Note: java.util.EventObject is not part of CDC and CLDC.
- * </p>
- */
-public class SWTEventObject extends EventObject {
-
-/**
- * Constructs a new instance of this class.
- *
- * @param source the object which fired the event
- */
-public SWTEventObject(Object source) {
- super(source);
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+import java.util.EventObject;
+
+/**
+ * This class is the cross-platform version of the
+ * java.util.EventObject class.
+ * <p>
+ * It is part of our effort to provide support for both J2SE
+ * and J2ME platforms. Under this scheme, classes need to
+ * extend SWTEventObject instead of java.util.EventObject.
+ * </p>
+ * <p>
+ * Note: java.util.EventObject is not part of CDC and CLDC.
+ * </p>
+ */
+public class SWTEventObject extends EventObject {
+
+/**
+ * Constructs a new instance of this class.
+ *
+ * @param source the object which fired the event
+ */
+public SWTEventObject(Object source) {
+ super(source);
+}
} \ No newline at end of file
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/common_j2se/org/eclipse/swt/internal/SWTMessages.properties b/bundles/org.eclipse.swt/Eclipse SWT/common_j2se/org/eclipse/swt/internal/SWTMessages.properties
index fd8b229a67..5c5e43ac4f 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/common_j2se/org/eclipse/swt/internal/SWTMessages.properties
+++ b/bundles/org.eclipse.swt/Eclipse SWT/common_j2se/org/eclipse/swt/internal/SWTMessages.properties
@@ -1,42 +1,42 @@
-SWT_Yes=Yes
-SWT_No=No
-SWT_OK=OK
-SWT_Cancel=Cancel
-SWT_Abort=Abort
-SWT_Retry=Retry
-SWT_Ignore=Ignore
-SWT_Sample=Sample
-SWT_A_Sample_Text=A Sample Text
-SWT_Selection=Selection
-SWT_Current_Selection=Current Selection
-SWT_Font=Font
-SWT_Color=Color
-SWT_Extended_style=Extended style
-SWT_Size=Size
-SWT_Style=Style
-SWT_Save=Save
-SWT_Character_set=Character set
-SWT_ColorDialog_Title=Colors
-SWT_FontDialog_Title=Fonts
-SWT_Charset_Western=western
-SWT_Charset_EastEuropean=east european
-SWT_Charset_SouthEuropean=south european
-SWT_Charset_NorthEuropean=north european
-SWT_Charset_Cyrillic=cyrillic
-SWT_Charset_Arabic=arabic
-SWT_Charset_Greek=greek
-SWT_Charset_Hebrew=hebrew
-SWT_Charset_Turkish=turkish
-SWT_Charset_Nordic=nordic
-SWT_Charset_Thai=thai
-SWT_Charset_BalticRim=baltic rim
-SWT_Charset_Celtic=celtic
-SWT_Charset_Euro=euro
-SWT_Charset_Romanian=romanian
-SWT_Charset_SimplifiedChinese=simplified chinese
-SWT_Charset_TraditionalChinese=traditional chinese
-SWT_Charset_Japanese=japanese
-SWT_Charset_Korean=korean
-SWT_Charset_Unicode=unicode
-SWT_Charset_ASCII=ASCII
+SWT_Yes=Yes
+SWT_No=No
+SWT_OK=OK
+SWT_Cancel=Cancel
+SWT_Abort=Abort
+SWT_Retry=Retry
+SWT_Ignore=Ignore
+SWT_Sample=Sample
+SWT_A_Sample_Text=A Sample Text
+SWT_Selection=Selection
+SWT_Current_Selection=Current Selection
+SWT_Font=Font
+SWT_Color=Color
+SWT_Extended_style=Extended style
+SWT_Size=Size
+SWT_Style=Style
+SWT_Save=Save
+SWT_Character_set=Character set
+SWT_ColorDialog_Title=Colors
+SWT_FontDialog_Title=Fonts
+SWT_Charset_Western=western
+SWT_Charset_EastEuropean=east european
+SWT_Charset_SouthEuropean=south european
+SWT_Charset_NorthEuropean=north european
+SWT_Charset_Cyrillic=cyrillic
+SWT_Charset_Arabic=arabic
+SWT_Charset_Greek=greek
+SWT_Charset_Hebrew=hebrew
+SWT_Charset_Turkish=turkish
+SWT_Charset_Nordic=nordic
+SWT_Charset_Thai=thai
+SWT_Charset_BalticRim=baltic rim
+SWT_Charset_Celtic=celtic
+SWT_Charset_Euro=euro
+SWT_Charset_Romanian=romanian
+SWT_Charset_SimplifiedChinese=simplified chinese
+SWT_Charset_TraditionalChinese=traditional chinese
+SWT_Charset_Japanese=japanese
+SWT_Charset_Korean=korean
+SWT_Charset_Unicode=unicode
+SWT_Charset_ASCII=ASCII
SWT_InputMethods=Input Methods \ No newline at end of file
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/common_j2se/org/eclipse/swt/internal/SerializableCompatibility.java b/bundles/org.eclipse.swt/Eclipse SWT/common_j2se/org/eclipse/swt/internal/SerializableCompatibility.java
index 13399fd72b..67ab74a64b 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/common_j2se/org/eclipse/swt/internal/SerializableCompatibility.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/common_j2se/org/eclipse/swt/internal/SerializableCompatibility.java
@@ -1,26 +1,26 @@
-package org.eclipse.swt.internal;
-
-/*
+package org.eclipse.swt.internal;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-import java.io.Serializable;
-
-/**
- * This interface is the cross-platform version of the
- * java.io.Serializable interface.
- * <p>
- * It is part of our effort to provide support for both J2SE
- * and J2ME platforms. Under this scheme, classes need to
- * implement SerializableCompatibility instead of
- * java.io.Serializable.
- * </p>
- * <p>
- * Note: java.io.Serializable is not part of CLDC.
- * </p>
- */
-public interface SerializableCompatibility extends Serializable {
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+import java.io.Serializable;
+
+/**
+ * This interface is the cross-platform version of the
+ * java.io.Serializable interface.
+ * <p>
+ * It is part of our effort to provide support for both J2SE
+ * and J2ME platforms. Under this scheme, classes need to
+ * implement SerializableCompatibility instead of
+ * java.io.Serializable.
+ * </p>
+ * <p>
+ * Note: java.io.Serializable is not part of CLDC.
+ * </p>
+ */
+public interface SerializableCompatibility extends Serializable {
} \ No newline at end of file
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/emulated/bidi/org/eclipse/swt/internal/BidiUtil.java b/bundles/org.eclipse.swt/Eclipse SWT/emulated/bidi/org/eclipse/swt/internal/BidiUtil.java
index 999b1c4e1d..33119cb970 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/emulated/bidi/org/eclipse/swt/internal/BidiUtil.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/emulated/bidi/org/eclipse/swt/internal/BidiUtil.java
@@ -1,86 +1,86 @@
package org.eclipse.swt.internal; /* * Copyright (c) 2001, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html */
-import org.eclipse.swt.graphics.GC;
-
-/*
- * This class is supplied so that the StyledText code that supports bidi text (supported
- * for win platforms) is not platform dependent. Bidi text is not implemented on
- * emulated platforms.
- */
-public class BidiUtil {
- // Keyboard language types
- public static final int KEYBOARD_NON_BIDI = 0;
- public static final int KEYBOARD_BIDI = 1;
-
- // bidi rendering input flag constants, not used
- // on emulated platforms
- public static final int CLASSIN = 1;
- public static final int LINKBEFORE = 2;
- public static final int LINKAFTER = 4;
-
- // bidi rendering/ordering constants, not used on
- // emulated platforms
- public static final int CLASS_HEBREW = 2;
- public static final int CLASS_ARABIC = 2;
- public static final int CLASS_LOCALNUMBER = 4;
- public static final int REORDER = 0;
- public static final int LIGATE = 0;
- public static final int GLYPHSHAPE = 0;
-
-/*
- * Not implemented.
- */
-public static void addLanguageListener(int hwnd, Runnable runnable) {
-}
-/*
- * Not implemented.
- *
- */
-public static void drawGlyphs(GC gc, char[] renderBuffer, int[] renderDx, int x, int y) {
-}
-/*
- * Bidi not supported on emulated platforms.
- *
- */
-public static boolean isBidiPlatform() {
- return false;
-}
-/* * Not implemented. */ public static boolean isKeyboardBidi() { return false; } /*
- * Not implemented.
- */
-public static int getFontBidiAttributes(GC gc) {
- return 0;
-}
-/*
- * Not implemented.
- *
- */
-public static void getOrderInfo(GC gc, String text, int[] order, byte[] classBuffer, int flags, int [] offsets) {
-}
-/*
- * Not implemented. Returns null.
- *
- */
-public static char[] getRenderInfo(GC gc, String text, int[] order, byte[] classBuffer, int[] dx, int flags, int[] offsets) {
- return null;
-}
-/*
- * Not implemented. Returns 0.
- */
-public static int getKeyboardLanguage() {
- return 0;
-}
-/*
- * Not implemented.
- */
-public static void removeLanguageListener(int hwnd) {
-}
-/*
- * Not implemented.
- */
-public static void setKeyboardLanguage(int language) {
-}
-
+ * http://www.eclipse.org/legal/cpl-v10.html */
+import org.eclipse.swt.graphics.GC;
+
+/*
+ * This class is supplied so that the StyledText code that supports bidi text (supported
+ * for win platforms) is not platform dependent. Bidi text is not implemented on
+ * emulated platforms.
+ */
+public class BidiUtil {
+ // Keyboard language types
+ public static final int KEYBOARD_NON_BIDI = 0;
+ public static final int KEYBOARD_BIDI = 1;
+
+ // bidi rendering input flag constants, not used
+ // on emulated platforms
+ public static final int CLASSIN = 1;
+ public static final int LINKBEFORE = 2;
+ public static final int LINKAFTER = 4;
+
+ // bidi rendering/ordering constants, not used on
+ // emulated platforms
+ public static final int CLASS_HEBREW = 2;
+ public static final int CLASS_ARABIC = 2;
+ public static final int CLASS_LOCALNUMBER = 4;
+ public static final int REORDER = 0;
+ public static final int LIGATE = 0;
+ public static final int GLYPHSHAPE = 0;
+
+/*
+ * Not implemented.
+ */
+public static void addLanguageListener(int hwnd, Runnable runnable) {
+}
+/*
+ * Not implemented.
+ *
+ */
+public static void drawGlyphs(GC gc, char[] renderBuffer, int[] renderDx, int x, int y) {
+}
+/*
+ * Bidi not supported on emulated platforms.
+ *
+ */
+public static boolean isBidiPlatform() {
+ return false;
+}
+/* * Not implemented. */ public static boolean isKeyboardBidi() { return false; } /*
+ * Not implemented.
+ */
+public static int getFontBidiAttributes(GC gc) {
+ return 0;
+}
+/*
+ * Not implemented.
+ *
+ */
+public static void getOrderInfo(GC gc, String text, int[] order, byte[] classBuffer, int flags, int [] offsets) {
+}
+/*
+ * Not implemented. Returns null.
+ *
+ */
+public static char[] getRenderInfo(GC gc, String text, int[] order, byte[] classBuffer, int[] dx, int flags, int[] offsets) {
+ return null;
+}
+/*
+ * Not implemented. Returns 0.
+ */
+public static int getKeyboardLanguage() {
+ return 0;
+}
+/*
+ * Not implemented.
+ */
+public static void removeLanguageListener(int hwnd) {
+}
+/*
+ * Not implemented.
+ */
+public static void setKeyboardLanguage(int language) {
+}
+
} \ No newline at end of file
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/emulated/coolbar/org/eclipse/swt/widgets/CoolBar.java b/bundles/org.eclipse.swt/Eclipse SWT/emulated/coolbar/org/eclipse/swt/widgets/CoolBar.java
index 472937c2a6..fe4c0a3138 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/emulated/coolbar/org/eclipse/swt/widgets/CoolBar.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/emulated/coolbar/org/eclipse/swt/widgets/CoolBar.java
@@ -1,1071 +1,1071 @@
-package org.eclipse.swt.widgets;
-
-/*
+package org.eclipse.swt.widgets;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-import org.eclipse.swt.*;
-import org.eclipse.swt.graphics.*;
-
-/**
- * Instances of this class provide an area for dynamically
- * positioning the items they contain.
- * <p>
- * The item children that may be added to instances of this class
- * must be of type <code>CoolItem</code>.
- * </p><p>
- * Note that although this class is a subclass of <code>Composite</code>,
- * it does not make sense to add <code>Control</code> children to it,
- * or set a layout on it.
- * </p><p>
- * <dl>
- * <dt><b>Styles:</b></dt>
- * <dd>(none)</dd>
- * <dt><b>Events:</b></dt>
- * <dd>(none)</dd>
- * </dl>
- * <p>
- * IMPORTANT: This class is <em>not</em> intended to be subclassed.
- * </p>
+ * http://www.eclipse.org/legal/cpl-v10.html
*/
-public class CoolBar extends Composite {
- CoolItem[][] items = new CoolItem[0][0];
- CoolItem[] originalItems = new CoolItem[0];
- Cursor hoverCursor, dragCursor;
- CoolItem dragging = null;
- int mouseXOffset, itemXOffset;
- static final int ROW_SPACING = 2;
- static final int CLICK_DISTANCE = 3;
-
- boolean isLocked = false;
- boolean inDispose = false;
-/**
- * Constructs a new instance of this class given its parent
- * and a style value describing its behavior and appearance.
- * <p>
- * The style value is either one of the style constants defined in
- * class <code>SWT</code> which is applicable to instances of this
- * class, or must be built by <em>bitwise OR</em>'ing together
- * (that is, using the <code>int</code> "|" operator) two or more
- * of those <code>SWT</code> style constants. The class description
- * lists the style constants that are applicable to the class.
- * Style bits are also inherited from superclasses.
- * </p>
- *
- * @param parent a 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
+
+import org.eclipse.swt.*;
+import org.eclipse.swt.graphics.*;
+
+/**
+ * Instances of this class provide an area for dynamically
+ * positioning the items they contain.
+ * <p>
+ * The item children that may be added to instances of this class
+ * must be of type <code>CoolItem</code>.
+ * </p><p>
+ * Note that although this class is a subclass of <code>Composite</code>,
+ * it does not make sense to add <code>Control</code> children to it,
+ * or set a layout on it.
+ * </p><p>
+ * <dl>
+ * <dt><b>Styles:</b></dt>
+ * <dd>(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 CoolBar (Composite parent, int style) {
- super (parent, checkStyle(style));
- Display display = getDisplay();
- hoverCursor = new Cursor(display, SWT.CURSOR_SIZEWE);
- dragCursor = new Cursor(display, SWT.CURSOR_SIZEALL);
- Listener listener = new Listener() {
- public void handleEvent(Event event) {
- switch (event.type) {
- case SWT.Dispose: onDispose(); break;
- case SWT.MouseDown: onMouseDown(event); break;
- case SWT.MouseExit: onMouseExit(); break;
- case SWT.MouseMove: onMouseMove(event); break;
- case SWT.MouseUp: onMouseUp(event); break;
- case SWT.MouseDoubleClick: onMouseDoubleClick(event); break;
- case SWT.Paint: onPaint(event); break;
- }
- }
- };
- int[] events = new int[] {
- SWT.Dispose,
- SWT.MouseDown,
- SWT.MouseExit,
- SWT.MouseMove,
- SWT.MouseUp,
- SWT.MouseDoubleClick,
- SWT.Paint
- };
- for (int i = 0; i < events.length; i++) {
- addListener(events[i], listener);
- }
-}
-private static int checkStyle (int style) {
- return (style | SWT.NO_REDRAW_RESIZE) & ~(SWT.V_SCROLL | SWT.H_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;
- for (int row = 0; row < items.length; row++) {
- int rowWidth = 0, rowHeight = 0;
- for (int i = 0; i < items[row].length; i++) {
- rowWidth += items[row][i].preferredWidth;
- rowHeight = Math.max(rowHeight, items[row][i].getSize().y);
- }
- height += rowHeight;
- if (row > 0) height += ROW_SPACING;
- width = Math.max(width, rowWidth);
- }
- 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);
- return new Point(trim.width, trim.height);
-}
-CoolItem getGrabbedItem(int x, int y) {
- for (int row = 0; row < items.length; row++) {
- for (int i = 0; i < items[row].length; i++) {
- CoolItem item = items[row][i];
- Rectangle bounds = item.getBounds();
- bounds.width = CoolItem.MINIMUM_WIDTH;
- if (bounds.x > x) break;
- if (bounds.y > y) return null;
- if (bounds.contains(x, y)) {
- return item;
- }
- }
- }
- return null;
-}
-/**
- * Returns the item that is currently displayed at the given,
- * zero-relative index. Throws an exception if the index is
- * out of range.
- *
- * @param index the visual index of the item to return
- * @return the item at the given visual index
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_INVALID_RANGE - if the index is not between 0 and the number of elements in the list minus 1 (inclusive)</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- * @exception SWTError <ul>
- * <li>ERROR_CANNOT_GET_ITEM - if the operation fails because of an operating system failure</li>
- * </ul>
+public class CoolBar extends Composite {
+ CoolItem[][] items = new CoolItem[0][0];
+ CoolItem[] originalItems = new CoolItem[0];
+ Cursor hoverCursor, dragCursor;
+ CoolItem dragging = null;
+ int mouseXOffset, itemXOffset;
+ static final int ROW_SPACING = 2;
+ static final int CLICK_DISTANCE = 3;
+
+ boolean isLocked = false;
+ boolean inDispose = false;
+/**
+ * Constructs a new instance of this class given its parent
+ * and a style value describing its behavior and appearance.
+ * <p>
+ * The style value is either one of the style constants defined in
+ * class <code>SWT</code> which is applicable to instances of this
+ * class, or must be built by <em>bitwise OR</em>'ing together
+ * (that is, using the <code>int</code> "|" operator) two or more
+ * of those <code>SWT</code> style constants. The class description
+ * lists the style constants that are applicable to the class.
+ * Style bits are also inherited from superclasses.
+ * </p>
+ *
+ * @param parent a 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 getItem (int index) {
- checkWidget();
- if (index < 0) error (SWT.ERROR_INVALID_RANGE);
- for (int row = 0; row < items.length; row++) {
- if (items[row].length > index) {
- return items[row][index];
- } else {
- index -= items[row].length;
- }
- }
- error (SWT.ERROR_INVALID_RANGE);
- return null;
-}
-/**
- * Returns the number of items contained in the receiver.
- *
- * @return the number of items
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- * @exception SWTError <ul>
- * <li>ERROR_CANNOT_GET_COUNT - if the operation fails because of an operating system failure</li>
- * </ul>
+public CoolBar (Composite parent, int style) {
+ super (parent, checkStyle(style));
+ Display display = getDisplay();
+ hoverCursor = new Cursor(display, SWT.CURSOR_SIZEWE);
+ dragCursor = new Cursor(display, SWT.CURSOR_SIZEALL);
+ Listener listener = new Listener() {
+ public void handleEvent(Event event) {
+ switch (event.type) {
+ case SWT.Dispose: onDispose(); break;
+ case SWT.MouseDown: onMouseDown(event); break;
+ case SWT.MouseExit: onMouseExit(); break;
+ case SWT.MouseMove: onMouseMove(event); break;
+ case SWT.MouseUp: onMouseUp(event); break;
+ case SWT.MouseDoubleClick: onMouseDoubleClick(event); break;
+ case SWT.Paint: onPaint(event); break;
+ }
+ }
+ };
+ int[] events = new int[] {
+ SWT.Dispose,
+ SWT.MouseDown,
+ SWT.MouseExit,
+ SWT.MouseMove,
+ SWT.MouseUp,
+ SWT.MouseDoubleClick,
+ SWT.Paint
+ };
+ for (int i = 0; i < events.length; i++) {
+ addListener(events[i], listener);
+ }
+}
+private static int checkStyle (int style) {
+ return (style | SWT.NO_REDRAW_RESIZE) & ~(SWT.V_SCROLL | SWT.H_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;
+ for (int row = 0; row < items.length; row++) {
+ int rowWidth = 0, rowHeight = 0;
+ for (int i = 0; i < items[row].length; i++) {
+ rowWidth += items[row][i].preferredWidth;
+ rowHeight = Math.max(rowHeight, items[row][i].getSize().y);
+ }
+ height += rowHeight;
+ if (row > 0) height += ROW_SPACING;
+ width = Math.max(width, rowWidth);
+ }
+ 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);
+ return new Point(trim.width, trim.height);
+}
+CoolItem getGrabbedItem(int x, int y) {
+ for (int row = 0; row < items.length; row++) {
+ for (int i = 0; i < items[row].length; i++) {
+ CoolItem item = items[row][i];
+ Rectangle bounds = item.getBounds();
+ bounds.width = CoolItem.MINIMUM_WIDTH;
+ if (bounds.x > x) break;
+ if (bounds.y > y) return null;
+ if (bounds.contains(x, y)) {
+ return item;
+ }
+ }
+ }
+ return null;
+}
+/**
+ * Returns the item that is currently displayed at the given,
+ * zero-relative index. Throws an exception if the index is
+ * out of range.
+ *
+ * @param index the visual index of the item to return
+ * @return the item at the given visual index
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_INVALID_RANGE - if the index is not between 0 and the number of elements in the list minus 1 (inclusive)</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * @exception SWTError <ul>
+ * <li>ERROR_CANNOT_GET_ITEM - if the operation fails because of an operating system failure</li>
+ * </ul>
*/
-public int getItemCount () {
- checkWidget();
- return originalItems.length;
-}
-/**
- * Returns an array of <code>CoolItem</code>s in the order
- * in which they are currently being displayed.
- * <p>
- * Note: This is not the actual structure used by the receiver
- * to maintain its list of items, so modifying the array will
- * not affect the receiver.
- * </p>
- *
- * @return the receiver's items in their current visual order
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- * @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();
+ if (index < 0) error (SWT.ERROR_INVALID_RANGE);
+ for (int row = 0; row < items.length; row++) {
+ if (items[row].length > index) {
+ return items[row][index];
+ } else {
+ index -= items[row].length;
+ }
+ }
+ error (SWT.ERROR_INVALID_RANGE);
+ return null;
+}
+/**
+ * Returns the number of items contained in the receiver.
+ *
+ * @return the number of items
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * @exception SWTError <ul>
+ * <li>ERROR_CANNOT_GET_COUNT - if the operation fails because of an operating system failure</li>
+ * </ul>
*/
-public CoolItem [] getItems () {
- checkWidget();
- CoolItem [] result = new CoolItem [getItemCount()];
- int offset = 0;
- for (int row = 0; row < items.length; row++) {
- System.arraycopy(items[row], 0, result, offset, items[row].length);
- offset += items[row].length;
- }
- return result;
-}
-Point findItem (CoolItem item) {
- for (int row = 0; row < items.length; row++) {
- for (int i = 0; i < items[row].length; i++) {
- if (items[row][i].equals(item)) return new Point(i, row);
- }
- }
- return new Point(-1, -1);
-}
-/**
- * Searches the receiver's items in the order they are currently
- * being displayed, starting at the first item (index 0), until
- * an item is found that is equal to the argument, and returns
- * the index of that item. If no item is found, returns -1.
- *
- * @param item the search item
- * @return the visual order index of the search item, or -1 if the item is not found
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the item is null</li>
- * <li>ERROR_INVALID_ARGUMENT - if the item is disposed</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
+public int getItemCount () {
+ checkWidget();
+ return originalItems.length;
+}
+/**
+ * Returns an array of <code>CoolItem</code>s in the order
+ * in which they are currently being displayed.
+ * <p>
+ * Note: This is not the actual structure used by the receiver
+ * to maintain its list of items, so modifying the array will
+ * not affect the receiver.
+ * </p>
+ *
+ * @return the receiver's items in their current visual order
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * @exception SWTError <ul>
+ * <li>ERROR_CANNOT_GET_ITEM - if the operation fails because of an operating system failure</li>
+ * </ul>
*/
-public int indexOf (CoolItem item) {
- checkWidget();
- if (item == null) error (SWT.ERROR_NULL_ARGUMENT);
- if (item.isDisposed()) error (SWT.ERROR_INVALID_ARGUMENT);
- int answer = 0;
- for (int row = 0; row < items.length; row++) {
- for (int i = 0; i < items[row].length; i++) {
- if (items[row][i].equals(item)) {
- return answer;
- } else {
- answer++;
- }
- }
- }
- return -1;
-}
-/**
- * Insert the item into the row. Adjust the x and width values
- * appropriately.
+public CoolItem [] getItems () {
+ checkWidget();
+ CoolItem [] result = new CoolItem [getItemCount()];
+ int offset = 0;
+ for (int row = 0; row < items.length; row++) {
+ System.arraycopy(items[row], 0, result, offset, items[row].length);
+ offset += items[row].length;
+ }
+ return result;
+}
+Point findItem (CoolItem item) {
+ for (int row = 0; row < items.length; row++) {
+ for (int i = 0; i < items[row].length; i++) {
+ if (items[row][i].equals(item)) return new Point(i, row);
+ }
+ }
+ return new Point(-1, -1);
+}
+/**
+ * Searches the receiver's items in the order they are currently
+ * being displayed, starting at the first item (index 0), until
+ * an item is found that is equal to the argument, and returns
+ * the index of that item. If no item is found, returns -1.
+ *
+ * @param item the search item
+ * @return the visual order index of the search item, or -1 if the item is not found
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if the item is null</li>
+ * <li>ERROR_INVALID_ARGUMENT - if the item is disposed</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
*/
-void insertItemIntoRow(CoolItem item, int rowIndex, int x_root) {
- int barWidth = getSize().x;
- int rowY = items[rowIndex][0].getBounds().y;
- int x = Math.max(0, x_root - toDisplay(new Point(0, 0)).x);
-
- /* Find the insertion index and add the item. */
- int index;
- for (index = 0; index < items[rowIndex].length; index++) {
- if (x < items[rowIndex][index].getBounds().x) break;
- }
- int oldLength = items[rowIndex].length;
- CoolItem[] newRow = new CoolItem[oldLength + 1];
- System.arraycopy(items[rowIndex], 0, newRow, 0, index);
- newRow[index] = item;
- System.arraycopy(items[rowIndex], index, newRow, index + 1, oldLength - index);
- items[rowIndex] = newRow;
-
- /* Adjust the width of the item to the left. */
- if (index > 0) {
- CoolItem left = items[rowIndex][index - 1];
- Rectangle leftBounds = left.getBounds();
- int newWidth = x - leftBounds.x;
- if (newWidth < left.internalGetMinimumWidth()) {
- x += left.internalGetMinimumWidth() - newWidth;
- newWidth = left.internalGetMinimumWidth();
- }
- left.setBounds(leftBounds.x, leftBounds.y, newWidth, leftBounds.height);
- left.requestedWidth = newWidth;
- }
-
- /* Set the item's bounds. */
- int width = 0, height = item.getSize().y;
- if (index < items[rowIndex].length - 1) {
- CoolItem right = items[rowIndex][index + 1];
- width = right.getBounds().x - x;
- if (width < right.internalGetMinimumWidth()) {
- moveRight(right, right.internalGetMinimumWidth() - width);
- width = right.getBounds().x - x;
- }
- item.setBounds(x, rowY, width, height);
- if (width < item.internalGetMinimumWidth()) moveLeft(item, item.internalGetMinimumWidth() - width);
- } else {
- width = Math.max(item.internalGetMinimumWidth(), barWidth - x);
- item.setBounds(x, rowY, width, height);
- if (x + width > barWidth) moveLeft(item, x + width - barWidth);
- }
- Rectangle bounds = item.getBounds();
- item.requestedWidth = bounds.width;
- redraw(bounds.x, bounds.y, item.internalGetMinimumWidth(), bounds.height, false);
-}
-void createItem (CoolItem item, int index) {
- int itemCount = getItemCount(), row = 0;
- if (!(0 <= index && index <= itemCount)) error (SWT.ERROR_INVALID_RANGE);
- if (items.length == 0) {
- items = new CoolItem[1][1];
- items[0][0] = item;
- }
- else {
- int i = index;
- /* find the row to insert into */
- if (index < itemCount) {
- while (i > items[row].length) {
- i -= items[row].length;
- row++;
- }
- }
- else {
- row = items.length - 1;
- i = items[row].length;
- }
-
- // Set the last item in the row to the preferred size
- // and add the new one just to it's right
- int lastIndex = items[row].length - 1;
- CoolItem lastItem = items[row][lastIndex];
- if (lastItem.ideal) {
- Rectangle bounds = lastItem.getBounds();
- bounds.width = lastItem.preferredWidth;
- lastItem.requestedWidth = lastItem.preferredWidth;
- lastItem.setBounds(bounds.x, bounds.y, bounds.width, bounds.height);
- }
- int oldLength = items[row].length;
- CoolItem[] newRow = new CoolItem[oldLength + 1];
- System.arraycopy(items[row], 0, newRow, 0, i);
- newRow[i] = item;
- System.arraycopy(items[row], i, newRow, i + 1, oldLength - i);
- items[row] = newRow;
- }
- item.requestedWidth = CoolItem.MINIMUM_WIDTH;
- layoutItems();
-
- int length = originalItems.length;
- CoolItem [] newOriginals = new CoolItem [length + 1];
- System.arraycopy (originalItems, 0, newOriginals, 0, index);
- System.arraycopy (originalItems, index, newOriginals, index + 1, length - index);
- newOriginals [index] = item;
- originalItems = newOriginals;
-}
-void destroyItem(CoolItem item) {
- if (inDispose) return;
- int row = findItem(item).y;
- if (row == -1) return;
- Rectangle bounds = item.getBounds();
- removeItemFromRow(item, row, true);
- redraw(bounds.x, bounds.y, CoolItem.MINIMUM_WIDTH, bounds.height, false);
- relayout();
-
- int index = 0;
- while (index < originalItems.length) {
- if (originalItems [index] == item) break;
- index++;
- }
- int length = originalItems.length - 1;
- CoolItem [] newOriginals = new CoolItem [length];
- System.arraycopy (originalItems, 0, newOriginals, 0, index);
- System.arraycopy (originalItems, index + 1, newOriginals, index, length - index);
- originalItems = newOriginals;
-}
-void moveDown(CoolItem item, int x_root) {
- int oldRowIndex = findItem(item).y;
- boolean resize = false;
- if (items[oldRowIndex].length == 1) {
- resize = true;
- /* If this is the only item in the bottom row, don't move it. */
- if (oldRowIndex == items.length - 1) return;
- }
- int newRowIndex = (items[oldRowIndex].length == 1) ? oldRowIndex : oldRowIndex + 1;
- removeItemFromRow(item, oldRowIndex, false);
- Rectangle old = item.getBounds();
- redraw(old.x, old.y, CoolItem.MINIMUM_WIDTH, old.height, false);
- if (newRowIndex == items.length) {
- /* Create a new bottom row for the item. */
- CoolItem[][] newRows = new CoolItem[items.length + 1][];
- System.arraycopy(items, 0, newRows, 0, items.length);
- int row = items.length;
- newRows[row] = new CoolItem[1];
- newRows[row][0] = item;
- items = newRows;
- resize = true;
- }
- else {
- insertItemIntoRow(item, newRowIndex, x_root);
- }
- if (resize) relayout();
- else layoutItems();
-}
-void moveLeft(CoolItem item, int pixels) {
- Point point = findItem(item);
- int row = point.y;
- int index = point.x;
- if (index == 0) return;
- Rectangle bounds = item.getBounds();
- int minSpaceOnLeft = 0;
- for (int i = 0; i < index; i++) {
- minSpaceOnLeft += items[row][i].internalGetMinimumWidth();
- }
- int x = Math.max(minSpaceOnLeft, bounds.x - pixels);
- CoolItem left = items[row][index - 1];
- Rectangle leftBounds = left.getBounds();
- if (leftBounds.x + left.internalGetMinimumWidth() > x) {
- int shift = leftBounds.x + left.internalGetMinimumWidth() - x;
- moveLeft(left, shift);
- leftBounds = left.getBounds();
- }
- int leftWidth = Math.max(left.internalGetMinimumWidth(), leftBounds.width - pixels);
- left.setBounds(leftBounds.x, leftBounds.y, leftWidth, leftBounds.height);
- left.requestedWidth = leftWidth;
- int width = bounds.width + (bounds.x - x);
- item.setBounds(x, bounds.y, width, bounds.height);
- item.requestedWidth = width;
-
- int damagedWidth = bounds.x - x + CoolItem.MINIMUM_WIDTH;
- if (damagedWidth > CoolItem.MINIMUM_WIDTH) {
- redraw(x, bounds.y, damagedWidth, bounds.height, false);
- }
-}
-void moveRight(CoolItem item, int pixels) {
- Point point = findItem(item);
- int row = point.y;
- int index = point.x;
- if (index == 0) return;
- Rectangle bounds = item.getBounds();
- int minSpaceOnRight = 0;
- for (int i = index; i < items[row].length; i++) {
- minSpaceOnRight += items[row][i].internalGetMinimumWidth();
- }
- int max = getBounds().width - minSpaceOnRight;
- int x = Math.min(max, bounds.x + pixels);
- int width = 0;
- if (index + 1 == items[row].length) {
- width = getBounds().width - x;
- } else {
- CoolItem right = items[row][index + 1];
- Rectangle rightBounds = right.getBounds();
- if (x + item.internalGetMinimumWidth() > rightBounds.x) {
- int shift = x + item.internalGetMinimumWidth() - rightBounds.x;
- moveRight(right, shift);
- rightBounds = right.getBounds();
- }
- width = rightBounds.x - x;
- }
- item.setBounds(x, bounds.y, width, bounds.height);
- item.requestedWidth = width;
- CoolItem left = items[row][index - 1];
- Rectangle leftBounds = left.getBounds();
- int leftWidth = x - leftBounds.x;
- left.setBounds(leftBounds.x, leftBounds.y, leftWidth, leftBounds.height);
- left.requestedWidth = leftWidth;
-
- int damagedWidth = x - bounds.x + CoolItem.MINIMUM_WIDTH + CoolItem.MARGIN_WIDTH;
- if (x - bounds.x > 0) {
- redraw(bounds.x - CoolItem.MARGIN_WIDTH, bounds.y, damagedWidth, bounds.height, false);
- }
-}
-void moveUp(CoolItem item, int x_root) {
- Point point = findItem(item);
- int oldRowIndex = point.y;
- boolean resize = false;
- if (items[oldRowIndex].length == 1) {
- resize = true;
- /* If this is the only item in the top row, don't move it. */
- if (oldRowIndex == 0) return;
- }
- removeItemFromRow(item, oldRowIndex, false);
- Rectangle old = item.getBounds();
- redraw(old.x, old.y, CoolItem.MINIMUM_WIDTH, old.height, false);
- int newRowIndex = Math.max(0, oldRowIndex - 1);
- if (oldRowIndex == 0) {
- /* Create a new top row for the item. */
- CoolItem[][] newRows = new CoolItem[items.length + 1][];
- System.arraycopy(items, 0, newRows, 1, items.length);
- newRows[0] = new CoolItem[1];
- newRows[0][0] = item;
- items = newRows;
- resize = true;
- }
- else {
- insertItemIntoRow(item, newRowIndex, x_root);
- }
- if (resize) relayout();
- else layoutItems();
-}
-void onDispose() {
- /*
- * Usually when an item is disposed, destroyItem will change the size of the items array
- * and reset the bounds of all the remaining cool items.
- * Since the whole cool bar is being disposed, this is not necessary. For speed
- * the inDispose flag is used to skip over this part of the item dispose.
- */
- inDispose = true;
- for (int i = 0; i < items.length; i++) {
- for (int j = 0; j < items[i].length; j++) {
- items[i][j].dispose();
- }
- }
- hoverCursor.dispose();
- dragCursor.dispose();
-}
-void onMouseDown(Event event) {
- if (isLocked || event.button != 1) return;
- dragging = getGrabbedItem(event.x, event.y);
- if (dragging != null) {
- mouseXOffset = event.x;
- itemXOffset = mouseXOffset - dragging.getBounds().x;
- setCursor(dragCursor);
- }
-}
-void onMouseExit() {
- if (dragging == null) setCursor(null);
-}
-void onMouseMove(Event event) {
- if (isLocked) return;
- CoolItem grabbed = getGrabbedItem(event.x, event.y);
- if (dragging != null) {
- int left_root = toDisplay(new Point(event.x, event.y)).x - itemXOffset;
- Rectangle bounds = dragging.getBounds();
- if (event.y < bounds.y) {
- moveUp(dragging, left_root);
- }
- else if (event.y > bounds.y + bounds.height){
- moveDown(dragging, left_root);
- }
- else if (event.x < mouseXOffset) {
- int distance = Math.min(mouseXOffset, bounds.x + itemXOffset) - event.x;
- if (distance > 0) moveLeft(dragging, distance);
- }
- else if (event.x > mouseXOffset) {
- int distance = event.x - Math.max(mouseXOffset, bounds.x + itemXOffset);
- if (distance > 0) moveRight(dragging, distance);
- }
- mouseXOffset = event.x;
- return;
- }
- if (grabbed != null) {
- setCursor(hoverCursor);
- }
- else {
- setCursor(null);
- }
-}
-void onMouseUp(Event event) {
- setCursor(null);
- dragging = null;
-}
-void onMouseDoubleClick(Event event) {
- if (isLocked) return;
- dragging = null;
- CoolItem target = getGrabbedItem(event.x, event.y);
- if (target == null) {
- setCursor(null);
- return;
- }
-
- Point location = findItem(target);
- int row = location.y;
- int index = location.x;
- if (items[row].length > 1) {
- Point size = target.getSize();
- int maxSize = getSize().x;
- for (int i = 0; i < items[row].length; i++) {
- if (i != index) {
- maxSize -= items[row][i].internalGetMinimumWidth();
- }
- }
- if (size.x == maxSize) {
- /* The item is at its maximum width. It should be resized to its minimum width. */
- int distance = size.x - target.internalGetMinimumWidth();
- if (index + 1 < items[row].length) {
- /* There is an item to the right. Maximize it. */
- CoolItem right = items[row][index + 1];
- moveLeft(right, distance);
- }
- else {
- /* There is no item to the right. Move the item all the way right. */
- moveRight(target, distance);
- }
- }
- else if (size.x < target.preferredWidth) {
- /* The item is less than its preferredWidth. Resize to preferredWidth. */
- int distance = target.preferredWidth - size.x;
- if (index + 1 < items[row].length) {
- CoolItem right = items[row][index + 1];
- moveRight(right, distance);
- distance = target.preferredWidth - target.getSize().x;
- }
- if (distance > 0) {
- moveLeft(target, distance);
- }
- }
- else {
- /* The item is at its minimum width. Maximize it. */
- for (int i = 0; i < items[row].length; i++) {
- if (i != index) {
- CoolItem item = items[row][i];
- item.requestedWidth = Math.max(item.internalGetMinimumWidth(), CoolItem.MINIMUM_WIDTH);
- }
- }
- target.requestedWidth = maxSize;
- layoutItems();
- }
- setCursor(hoverCursor);
- }
-}
-void onPaint(Event event) {
- GC gc = event.gc;
- if (items.length == 0) return;
- Display display = getDisplay();
- Color shadowColor = display.getSystemColor(SWT.COLOR_WIDGET_NORMAL_SHADOW);
- Color highlightColor = display.getSystemColor(SWT.COLOR_WIDGET_HIGHLIGHT_SHADOW);
-
- int stopX = getBounds().width;
- for (int row = 0; row < items.length; row++) {
- Rectangle bounds = new Rectangle(0, 0, 0, 0);
- for (int i = 0; i < items[row].length; i++) {
- bounds = items[row][i].getBounds();
- if (!gc.getClipping().intersects(bounds)) continue;
-
- /* Draw separator. */
- if (i != 0) {
- gc.setForeground(shadowColor);
- gc.drawLine(bounds.x, bounds.y, bounds.x, bounds.y + bounds.height - 1);
- gc.setForeground(highlightColor);
- gc.drawLine(bounds.x + 1, bounds.y, bounds.x + 1, bounds.y + bounds.height - 1);
- }
-
- /* Draw grabber. */
- if (!isLocked) {
- int grabberTrim = 2;
- int grabberHeight = bounds.height - (2 * CoolItem.MARGIN_HEIGHT) - (2 * grabberTrim) - 1;
- gc.setForeground(shadowColor);
- gc.drawRectangle(
- bounds.x + CoolItem.MARGIN_WIDTH,
- bounds.y + CoolItem.MARGIN_HEIGHT + grabberTrim,
- 2,
- grabberHeight);
- gc.setForeground(highlightColor);
- gc.drawLine(
- bounds.x + CoolItem.MARGIN_WIDTH,
- bounds.y + CoolItem.MARGIN_HEIGHT + grabberTrim + 1,
- bounds.x + CoolItem.MARGIN_WIDTH,
- bounds.y + CoolItem.MARGIN_HEIGHT + grabberTrim + grabberHeight - 1);
- gc.drawLine(
- bounds.x + CoolItem.MARGIN_WIDTH,
- bounds.y + CoolItem.MARGIN_HEIGHT + grabberTrim,
- bounds.x + CoolItem.MARGIN_WIDTH + 1,
- bounds.y + CoolItem.MARGIN_HEIGHT + grabberTrim);
- }
- }
- if (row + 1 < items.length) {
- /* Draw row separator. */
- int separatorY = bounds.y + bounds.height;
- gc.setForeground(shadowColor);
- gc.drawLine(0, separatorY, stopX, separatorY);
- gc.setForeground(highlightColor);
- gc.drawLine(0, separatorY + 1, stopX, separatorY + 1);
- }
- }
-}
-/**
- * Remove the item from the row. Adjust the x and width values
- * appropriately.
+public int indexOf (CoolItem item) {
+ checkWidget();
+ if (item == null) error (SWT.ERROR_NULL_ARGUMENT);
+ if (item.isDisposed()) error (SWT.ERROR_INVALID_ARGUMENT);
+ int answer = 0;
+ for (int row = 0; row < items.length; row++) {
+ for (int i = 0; i < items[row].length; i++) {
+ if (items[row][i].equals(item)) {
+ return answer;
+ } else {
+ answer++;
+ }
+ }
+ }
+ return -1;
+}
+/**
+ * Insert the item into the row. Adjust the x and width values
+ * appropriately.
*/
-void removeItemFromRow(CoolItem item, int rowIndex, boolean disposed) {
- int index = findItem(item).x;
- int newLength = items[rowIndex].length - 1;
- Rectangle itemBounds = item.getBounds();
- if (newLength > 0) {
- CoolItem[] newRow = new CoolItem[newLength];
- System.arraycopy(items[rowIndex], 0, newRow, 0, index);
- System.arraycopy(items[rowIndex], index + 1, newRow, index, newRow.length - index);
- items[rowIndex] = newRow;
- }
- else {
- CoolItem[][] newRows = new CoolItem[items.length - 1][];
- System.arraycopy(items, 0, newRows, 0, rowIndex);
- System.arraycopy(items, rowIndex + 1, newRows, rowIndex, newRows.length - rowIndex);
- items = newRows;
- return;
- }
- if (!disposed) {
- if (index == 0) {
- CoolItem first = items[rowIndex][0];
- Rectangle bounds = first.getBounds();
- int width = bounds.x + bounds.width;
- first.setBounds(0, bounds.y, width, bounds.height);
- first.requestedWidth = width;
- redraw(bounds.x, bounds.y, CoolItem.MINIMUM_WIDTH, bounds.height, false);
- } else {
- CoolItem previous = items[rowIndex][index - 1];
- Rectangle bounds = previous.getBounds();
- int width = bounds.width + itemBounds.width;
- previous.setBounds(bounds.x, bounds.y, width, bounds.height);
- previous.requestedWidth = width;
- }
- }
-}
-/**
- * Return the height of the bar after it has
- * been properly layed out for the given width.
+void insertItemIntoRow(CoolItem item, int rowIndex, int x_root) {
+ int barWidth = getSize().x;
+ int rowY = items[rowIndex][0].getBounds().y;
+ int x = Math.max(0, x_root - toDisplay(new Point(0, 0)).x);
+
+ /* Find the insertion index and add the item. */
+ int index;
+ for (index = 0; index < items[rowIndex].length; index++) {
+ if (x < items[rowIndex][index].getBounds().x) break;
+ }
+ int oldLength = items[rowIndex].length;
+ CoolItem[] newRow = new CoolItem[oldLength + 1];
+ System.arraycopy(items[rowIndex], 0, newRow, 0, index);
+ newRow[index] = item;
+ System.arraycopy(items[rowIndex], index, newRow, index + 1, oldLength - index);
+ items[rowIndex] = newRow;
+
+ /* Adjust the width of the item to the left. */
+ if (index > 0) {
+ CoolItem left = items[rowIndex][index - 1];
+ Rectangle leftBounds = left.getBounds();
+ int newWidth = x - leftBounds.x;
+ if (newWidth < left.internalGetMinimumWidth()) {
+ x += left.internalGetMinimumWidth() - newWidth;
+ newWidth = left.internalGetMinimumWidth();
+ }
+ left.setBounds(leftBounds.x, leftBounds.y, newWidth, leftBounds.height);
+ left.requestedWidth = newWidth;
+ }
+
+ /* Set the item's bounds. */
+ int width = 0, height = item.getSize().y;
+ if (index < items[rowIndex].length - 1) {
+ CoolItem right = items[rowIndex][index + 1];
+ width = right.getBounds().x - x;
+ if (width < right.internalGetMinimumWidth()) {
+ moveRight(right, right.internalGetMinimumWidth() - width);
+ width = right.getBounds().x - x;
+ }
+ item.setBounds(x, rowY, width, height);
+ if (width < item.internalGetMinimumWidth()) moveLeft(item, item.internalGetMinimumWidth() - width);
+ } else {
+ width = Math.max(item.internalGetMinimumWidth(), barWidth - x);
+ item.setBounds(x, rowY, width, height);
+ if (x + width > barWidth) moveLeft(item, x + width - barWidth);
+ }
+ Rectangle bounds = item.getBounds();
+ item.requestedWidth = bounds.width;
+ redraw(bounds.x, bounds.y, item.internalGetMinimumWidth(), bounds.height, false);
+}
+void createItem (CoolItem item, int index) {
+ int itemCount = getItemCount(), row = 0;
+ if (!(0 <= index && index <= itemCount)) error (SWT.ERROR_INVALID_RANGE);
+ if (items.length == 0) {
+ items = new CoolItem[1][1];
+ items[0][0] = item;
+ }
+ else {
+ int i = index;
+ /* find the row to insert into */
+ if (index < itemCount) {
+ while (i > items[row].length) {
+ i -= items[row].length;
+ row++;
+ }
+ }
+ else {
+ row = items.length - 1;
+ i = items[row].length;
+ }
+
+ // Set the last item in the row to the preferred size
+ // and add the new one just to it's right
+ int lastIndex = items[row].length - 1;
+ CoolItem lastItem = items[row][lastIndex];
+ if (lastItem.ideal) {
+ Rectangle bounds = lastItem.getBounds();
+ bounds.width = lastItem.preferredWidth;
+ lastItem.requestedWidth = lastItem.preferredWidth;
+ lastItem.setBounds(bounds.x, bounds.y, bounds.width, bounds.height);
+ }
+ int oldLength = items[row].length;
+ CoolItem[] newRow = new CoolItem[oldLength + 1];
+ System.arraycopy(items[row], 0, newRow, 0, i);
+ newRow[i] = item;
+ System.arraycopy(items[row], i, newRow, i + 1, oldLength - i);
+ items[row] = newRow;
+ }
+ item.requestedWidth = CoolItem.MINIMUM_WIDTH;
+ layoutItems();
+
+ int length = originalItems.length;
+ CoolItem [] newOriginals = new CoolItem [length + 1];
+ System.arraycopy (originalItems, 0, newOriginals, 0, index);
+ System.arraycopy (originalItems, index, newOriginals, index + 1, length - index);
+ newOriginals [index] = item;
+ originalItems = newOriginals;
+}
+void destroyItem(CoolItem item) {
+ if (inDispose) return;
+ int row = findItem(item).y;
+ if (row == -1) return;
+ Rectangle bounds = item.getBounds();
+ removeItemFromRow(item, row, true);
+ redraw(bounds.x, bounds.y, CoolItem.MINIMUM_WIDTH, bounds.height, false);
+ relayout();
+
+ int index = 0;
+ while (index < originalItems.length) {
+ if (originalItems [index] == item) break;
+ index++;
+ }
+ int length = originalItems.length - 1;
+ CoolItem [] newOriginals = new CoolItem [length];
+ System.arraycopy (originalItems, 0, newOriginals, 0, index);
+ System.arraycopy (originalItems, index + 1, newOriginals, index, length - index);
+ originalItems = newOriginals;
+}
+void moveDown(CoolItem item, int x_root) {
+ int oldRowIndex = findItem(item).y;
+ boolean resize = false;
+ if (items[oldRowIndex].length == 1) {
+ resize = true;
+ /* If this is the only item in the bottom row, don't move it. */
+ if (oldRowIndex == items.length - 1) return;
+ }
+ int newRowIndex = (items[oldRowIndex].length == 1) ? oldRowIndex : oldRowIndex + 1;
+ removeItemFromRow(item, oldRowIndex, false);
+ Rectangle old = item.getBounds();
+ redraw(old.x, old.y, CoolItem.MINIMUM_WIDTH, old.height, false);
+ if (newRowIndex == items.length) {
+ /* Create a new bottom row for the item. */
+ CoolItem[][] newRows = new CoolItem[items.length + 1][];
+ System.arraycopy(items, 0, newRows, 0, items.length);
+ int row = items.length;
+ newRows[row] = new CoolItem[1];
+ newRows[row][0] = item;
+ items = newRows;
+ resize = true;
+ }
+ else {
+ insertItemIntoRow(item, newRowIndex, x_root);
+ }
+ if (resize) relayout();
+ else layoutItems();
+}
+void moveLeft(CoolItem item, int pixels) {
+ Point point = findItem(item);
+ int row = point.y;
+ int index = point.x;
+ if (index == 0) return;
+ Rectangle bounds = item.getBounds();
+ int minSpaceOnLeft = 0;
+ for (int i = 0; i < index; i++) {
+ minSpaceOnLeft += items[row][i].internalGetMinimumWidth();
+ }
+ int x = Math.max(minSpaceOnLeft, bounds.x - pixels);
+ CoolItem left = items[row][index - 1];
+ Rectangle leftBounds = left.getBounds();
+ if (leftBounds.x + left.internalGetMinimumWidth() > x) {
+ int shift = leftBounds.x + left.internalGetMinimumWidth() - x;
+ moveLeft(left, shift);
+ leftBounds = left.getBounds();
+ }
+ int leftWidth = Math.max(left.internalGetMinimumWidth(), leftBounds.width - pixels);
+ left.setBounds(leftBounds.x, leftBounds.y, leftWidth, leftBounds.height);
+ left.requestedWidth = leftWidth;
+ int width = bounds.width + (bounds.x - x);
+ item.setBounds(x, bounds.y, width, bounds.height);
+ item.requestedWidth = width;
+
+ int damagedWidth = bounds.x - x + CoolItem.MINIMUM_WIDTH;
+ if (damagedWidth > CoolItem.MINIMUM_WIDTH) {
+ redraw(x, bounds.y, damagedWidth, bounds.height, false);
+ }
+}
+void moveRight(CoolItem item, int pixels) {
+ Point point = findItem(item);
+ int row = point.y;
+ int index = point.x;
+ if (index == 0) return;
+ Rectangle bounds = item.getBounds();
+ int minSpaceOnRight = 0;
+ for (int i = index; i < items[row].length; i++) {
+ minSpaceOnRight += items[row][i].internalGetMinimumWidth();
+ }
+ int max = getBounds().width - minSpaceOnRight;
+ int x = Math.min(max, bounds.x + pixels);
+ int width = 0;
+ if (index + 1 == items[row].length) {
+ width = getBounds().width - x;
+ } else {
+ CoolItem right = items[row][index + 1];
+ Rectangle rightBounds = right.getBounds();
+ if (x + item.internalGetMinimumWidth() > rightBounds.x) {
+ int shift = x + item.internalGetMinimumWidth() - rightBounds.x;
+ moveRight(right, shift);
+ rightBounds = right.getBounds();
+ }
+ width = rightBounds.x - x;
+ }
+ item.setBounds(x, bounds.y, width, bounds.height);
+ item.requestedWidth = width;
+ CoolItem left = items[row][index - 1];
+ Rectangle leftBounds = left.getBounds();
+ int leftWidth = x - leftBounds.x;
+ left.setBounds(leftBounds.x, leftBounds.y, leftWidth, leftBounds.height);
+ left.requestedWidth = leftWidth;
+
+ int damagedWidth = x - bounds.x + CoolItem.MINIMUM_WIDTH + CoolItem.MARGIN_WIDTH;
+ if (x - bounds.x > 0) {
+ redraw(bounds.x - CoolItem.MARGIN_WIDTH, bounds.y, damagedWidth, bounds.height, false);
+ }
+}
+void moveUp(CoolItem item, int x_root) {
+ Point point = findItem(item);
+ int oldRowIndex = point.y;
+ boolean resize = false;
+ if (items[oldRowIndex].length == 1) {
+ resize = true;
+ /* If this is the only item in the top row, don't move it. */
+ if (oldRowIndex == 0) return;
+ }
+ removeItemFromRow(item, oldRowIndex, false);
+ Rectangle old = item.getBounds();
+ redraw(old.x, old.y, CoolItem.MINIMUM_WIDTH, old.height, false);
+ int newRowIndex = Math.max(0, oldRowIndex - 1);
+ if (oldRowIndex == 0) {
+ /* Create a new top row for the item. */
+ CoolItem[][] newRows = new CoolItem[items.length + 1][];
+ System.arraycopy(items, 0, newRows, 1, items.length);
+ newRows[0] = new CoolItem[1];
+ newRows[0][0] = item;
+ items = newRows;
+ resize = true;
+ }
+ else {
+ insertItemIntoRow(item, newRowIndex, x_root);
+ }
+ if (resize) relayout();
+ else layoutItems();
+}
+void onDispose() {
+ /*
+ * Usually when an item is disposed, destroyItem will change the size of the items array
+ * and reset the bounds of all the remaining cool items.
+ * Since the whole cool bar is being disposed, this is not necessary. For speed
+ * the inDispose flag is used to skip over this part of the item dispose.
+ */
+ inDispose = true;
+ for (int i = 0; i < items.length; i++) {
+ for (int j = 0; j < items[i].length; j++) {
+ items[i][j].dispose();
+ }
+ }
+ hoverCursor.dispose();
+ dragCursor.dispose();
+}
+void onMouseDown(Event event) {
+ if (isLocked || event.button != 1) return;
+ dragging = getGrabbedItem(event.x, event.y);
+ if (dragging != null) {
+ mouseXOffset = event.x;
+ itemXOffset = mouseXOffset - dragging.getBounds().x;
+ setCursor(dragCursor);
+ }
+}
+void onMouseExit() {
+ if (dragging == null) setCursor(null);
+}
+void onMouseMove(Event event) {
+ if (isLocked) return;
+ CoolItem grabbed = getGrabbedItem(event.x, event.y);
+ if (dragging != null) {
+ int left_root = toDisplay(new Point(event.x, event.y)).x - itemXOffset;
+ Rectangle bounds = dragging.getBounds();
+ if (event.y < bounds.y) {
+ moveUp(dragging, left_root);
+ }
+ else if (event.y > bounds.y + bounds.height){
+ moveDown(dragging, left_root);
+ }
+ else if (event.x < mouseXOffset) {
+ int distance = Math.min(mouseXOffset, bounds.x + itemXOffset) - event.x;
+ if (distance > 0) moveLeft(dragging, distance);
+ }
+ else if (event.x > mouseXOffset) {
+ int distance = event.x - Math.max(mouseXOffset, bounds.x + itemXOffset);
+ if (distance > 0) moveRight(dragging, distance);
+ }
+ mouseXOffset = event.x;
+ return;
+ }
+ if (grabbed != null) {
+ setCursor(hoverCursor);
+ }
+ else {
+ setCursor(null);
+ }
+}
+void onMouseUp(Event event) {
+ setCursor(null);
+ dragging = null;
+}
+void onMouseDoubleClick(Event event) {
+ if (isLocked) return;
+ dragging = null;
+ CoolItem target = getGrabbedItem(event.x, event.y);
+ if (target == null) {
+ setCursor(null);
+ return;
+ }
+
+ Point location = findItem(target);
+ int row = location.y;
+ int index = location.x;
+ if (items[row].length > 1) {
+ Point size = target.getSize();
+ int maxSize = getSize().x;
+ for (int i = 0; i < items[row].length; i++) {
+ if (i != index) {
+ maxSize -= items[row][i].internalGetMinimumWidth();
+ }
+ }
+ if (size.x == maxSize) {
+ /* The item is at its maximum width. It should be resized to its minimum width. */
+ int distance = size.x - target.internalGetMinimumWidth();
+ if (index + 1 < items[row].length) {
+ /* There is an item to the right. Maximize it. */
+ CoolItem right = items[row][index + 1];
+ moveLeft(right, distance);
+ }
+ else {
+ /* There is no item to the right. Move the item all the way right. */
+ moveRight(target, distance);
+ }
+ }
+ else if (size.x < target.preferredWidth) {
+ /* The item is less than its preferredWidth. Resize to preferredWidth. */
+ int distance = target.preferredWidth - size.x;
+ if (index + 1 < items[row].length) {
+ CoolItem right = items[row][index + 1];
+ moveRight(right, distance);
+ distance = target.preferredWidth - target.getSize().x;
+ }
+ if (distance > 0) {
+ moveLeft(target, distance);
+ }
+ }
+ else {
+ /* The item is at its minimum width. Maximize it. */
+ for (int i = 0; i < items[row].length; i++) {
+ if (i != index) {
+ CoolItem item = items[row][i];
+ item.requestedWidth = Math.max(item.internalGetMinimumWidth(), CoolItem.MINIMUM_WIDTH);
+ }
+ }
+ target.requestedWidth = maxSize;
+ layoutItems();
+ }
+ setCursor(hoverCursor);
+ }
+}
+void onPaint(Event event) {
+ GC gc = event.gc;
+ if (items.length == 0) return;
+ Display display = getDisplay();
+ Color shadowColor = display.getSystemColor(SWT.COLOR_WIDGET_NORMAL_SHADOW);
+ Color highlightColor = display.getSystemColor(SWT.COLOR_WIDGET_HIGHLIGHT_SHADOW);
+
+ int stopX = getBounds().width;
+ for (int row = 0; row < items.length; row++) {
+ Rectangle bounds = new Rectangle(0, 0, 0, 0);
+ for (int i = 0; i < items[row].length; i++) {
+ bounds = items[row][i].getBounds();
+ if (!gc.getClipping().intersects(bounds)) continue;
+
+ /* Draw separator. */
+ if (i != 0) {
+ gc.setForeground(shadowColor);
+ gc.drawLine(bounds.x, bounds.y, bounds.x, bounds.y + bounds.height - 1);
+ gc.setForeground(highlightColor);
+ gc.drawLine(bounds.x + 1, bounds.y, bounds.x + 1, bounds.y + bounds.height - 1);
+ }
+
+ /* Draw grabber. */
+ if (!isLocked) {
+ int grabberTrim = 2;
+ int grabberHeight = bounds.height - (2 * CoolItem.MARGIN_HEIGHT) - (2 * grabberTrim) - 1;
+ gc.setForeground(shadowColor);
+ gc.drawRectangle(
+ bounds.x + CoolItem.MARGIN_WIDTH,
+ bounds.y + CoolItem.MARGIN_HEIGHT + grabberTrim,
+ 2,
+ grabberHeight);
+ gc.setForeground(highlightColor);
+ gc.drawLine(
+ bounds.x + CoolItem.MARGIN_WIDTH,
+ bounds.y + CoolItem.MARGIN_HEIGHT + grabberTrim + 1,
+ bounds.x + CoolItem.MARGIN_WIDTH,
+ bounds.y + CoolItem.MARGIN_HEIGHT + grabberTrim + grabberHeight - 1);
+ gc.drawLine(
+ bounds.x + CoolItem.MARGIN_WIDTH,
+ bounds.y + CoolItem.MARGIN_HEIGHT + grabberTrim,
+ bounds.x + CoolItem.MARGIN_WIDTH + 1,
+ bounds.y + CoolItem.MARGIN_HEIGHT + grabberTrim);
+ }
+ }
+ if (row + 1 < items.length) {
+ /* Draw row separator. */
+ int separatorY = bounds.y + bounds.height;
+ gc.setForeground(shadowColor);
+ gc.drawLine(0, separatorY, stopX, separatorY);
+ gc.setForeground(highlightColor);
+ gc.drawLine(0, separatorY + 1, stopX, separatorY + 1);
+ }
+ }
+}
+/**
+ * Remove the item from the row. Adjust the x and width values
+ * appropriately.
*/
-int layoutItems () {
- int y = 0, maxWidth = 0, width = getSize().x;
- for (int row = 0; row < items.length; row++) {
- int count = items[row].length;
- int x = 0;
-
- /* determine the height and the available width for the row */
- int rowHeight = 0;
- int available = width;
- for (int i = 0; i < items[row].length; i++) {
- CoolItem item = items[row][i];
- if (item.control != null) {
- rowHeight = Math.max(rowHeight, item.control.getSize().y);
- }
- available -= item.internalGetMinimumWidth();
- if (available < 0 && (width > item.internalGetMinimumWidth())) {
- /* push the next items into the next row */
- available += item.internalGetMinimumWidth();
- int amount = items[row].length - i;
- CoolItem[] nextRow;
- if (row + 1 == items.length) { /* Adding a new row */
- nextRow = new CoolItem [amount];
- CoolItem[][] newItems = new CoolItem [items.length + 1][];
- System.arraycopy(items, 0, newItems, 0, items.length);
- items = newItems;
- } else {
- nextRow = new CoolItem [amount + items [row + 1].length];
- System.arraycopy(items[row+1], 0, nextRow, amount, items [row + 1].length);
- }
- System.arraycopy(items[row], i, nextRow, 0, amount);
- items [row + 1] = nextRow;
- CoolItem[] thisRow = new CoolItem[i];
- System.arraycopy(items[row], 0, thisRow, 0, i);
- items[row] = thisRow;
- break;
- }
- }
- rowHeight += 2 * CoolItem.MARGIN_HEIGHT;
- if (row > 0) y += ROW_SPACING;
-
-
- /* lay the items out */
- for (int i = 0; i < items[row].length; i++) {
- CoolItem child = items[row][i];
- int newWidth = available + child.internalGetMinimumWidth();
- if (i + 1 < count) {
- newWidth = Math.min(newWidth, child.requestedWidth);
- available -= (newWidth - child.internalGetMinimumWidth());
- }
- Rectangle oldBounds = child.getBounds();
- Rectangle newBounds = new Rectangle(x, y, newWidth, rowHeight);
- if (!oldBounds.equals(newBounds)) {
- child.setBounds(newBounds.x, newBounds.y, newBounds.width, newBounds.height);
- Rectangle damage = new Rectangle(0, 0, 0, 0);
- /* Cases are in descending order from most area to redraw to least. */
- if (oldBounds.y != newBounds.y) {
- damage = newBounds;
- damage.add(oldBounds);
- /* Redraw the row separator as well. */
- damage.y -= ROW_SPACING;
- damage.height += 2 * ROW_SPACING;
- }
- else if (oldBounds.height != newBounds.height) {
- /*
- * Draw from the bottom of the gripper to the bottom of the new area.
- * (Bottom of the gripper is -3 from the bottom of the item).
- */
- damage.y = newBounds.y + Math.min(oldBounds.height, newBounds.height) - 3;
- damage.height = newBounds.y + newBounds.height + ROW_SPACING;
- damage.x = oldBounds.x - CoolItem.MARGIN_WIDTH;
- damage.width = oldBounds.width + CoolItem.MARGIN_WIDTH;
- }
- else if (oldBounds.x != newBounds.x) {
- /* Redraw only the difference between the separators. */
- damage.x = Math.min(oldBounds.x, newBounds.x);
- damage.width = Math.abs(oldBounds.x - newBounds.x) + CoolItem.MINIMUM_WIDTH;
- damage.y = oldBounds.y;
- damage.height = oldBounds.height;
- }
- redraw(damage.x, damage.y, damage.width, damage.height, false);
- }
- x += newWidth;
- }
- maxWidth = Math.max(maxWidth, x);
- y += rowHeight;
- }
- return y;
-}
-void relayout() {
- Point size = getSize();
- int height = layoutItems();
- Rectangle trim = computeTrim (0, 0, 0, height);
- if (height != size.y) super.setSize(size.x, trim.height);
-}
-public void setBounds (int x, int y, int width, int height) {
- super.setBounds (x, y, width, height);
- layoutItems();
-}
-public void setSize (int width, int height) {
- super.setSize (width, height);
- layoutItems();
-}
-/**
- * Returns an array of zero-relative ints that map
- * the creation order of the receiver's items to the
- * order in which they are currently being displayed.
- * <p>
- * Specifically, the indices of the returned array represent
- * the current visual order of the items, and the contents
- * of the array represent the creation order of the items.
- * </p><p>
- * Note: This is not the actual structure used by the receiver
- * to maintain its list of items, so modifying the array will
- * not affect the receiver.
- * </p>
- *
- * @return the current visual order of the receiver's items
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- * @exception SWTError <ul>
- * <li>ERROR_CANNOT_GET_ITEM - if the operation fails because of an operating system failure</li>
- * </ul>
+void removeItemFromRow(CoolItem item, int rowIndex, boolean disposed) {
+ int index = findItem(item).x;
+ int newLength = items[rowIndex].length - 1;
+ Rectangle itemBounds = item.getBounds();
+ if (newLength > 0) {
+ CoolItem[] newRow = new CoolItem[newLength];
+ System.arraycopy(items[rowIndex], 0, newRow, 0, index);
+ System.arraycopy(items[rowIndex], index + 1, newRow, index, newRow.length - index);
+ items[rowIndex] = newRow;
+ }
+ else {
+ CoolItem[][] newRows = new CoolItem[items.length - 1][];
+ System.arraycopy(items, 0, newRows, 0, rowIndex);
+ System.arraycopy(items, rowIndex + 1, newRows, rowIndex, newRows.length - rowIndex);
+ items = newRows;
+ return;
+ }
+ if (!disposed) {
+ if (index == 0) {
+ CoolItem first = items[rowIndex][0];
+ Rectangle bounds = first.getBounds();
+ int width = bounds.x + bounds.width;
+ first.setBounds(0, bounds.y, width, bounds.height);
+ first.requestedWidth = width;
+ redraw(bounds.x, bounds.y, CoolItem.MINIMUM_WIDTH, bounds.height, false);
+ } else {
+ CoolItem previous = items[rowIndex][index - 1];
+ Rectangle bounds = previous.getBounds();
+ int width = bounds.width + itemBounds.width;
+ previous.setBounds(bounds.x, bounds.y, width, bounds.height);
+ previous.requestedWidth = width;
+ }
+ }
+}
+/**
+ * Return the height of the bar after it has
+ * been properly layed out for the given width.
*/
-public int[] getItemOrder () {
- checkWidget ();
- int count = getItemCount ();
- int [] indices = new int [count];
- count = 0;
- for (int i = 0; i < items.length; i++) {
- for (int j = 0; j < items[i].length; j++) {
- CoolItem item = items[i][j];
- int index = 0;
- while (index<originalItems.length) {
- if (originalItems [index] == item) break;
- index++;
- }
- if (index == originalItems.length) error (SWT.ERROR_CANNOT_GET_ITEM);
- indices [count++] = index;
- }
- }
- return indices;
-}
-void setItemOrder (int[] itemOrder) {
- if (itemOrder == null) error(SWT.ERROR_NULL_ARGUMENT);
- int count = originalItems.length;
- if (itemOrder.length != count) error(SWT.ERROR_INVALID_ARGUMENT);
-
- /* Ensure that itemOrder does not contain any duplicates. */
- boolean [] set = new boolean [count];
- for (int i = 0; i < set.length; i++) set [i] = false;
- for (int i = 0; i < itemOrder.length; i++) {
- if (itemOrder [i] < 0 || itemOrder [i] >= count) error (SWT.ERROR_INVALID_ARGUMENT);
- if (set [itemOrder [i]]) error (SWT.ERROR_INVALID_ARGUMENT);
- set [itemOrder [i]] = true;
- }
-
- CoolItem[] row = new CoolItem[count];
- for (int i = 0; i < count; i++) {
- row[i] = originalItems[itemOrder[i]];
- }
- items = new CoolItem[1][count];
- items[0] = row;
-}
-/**
- * Returns an array of points whose x and y coordinates describe
- * the widths and heights (respectively) of the items in the receiver
- * in the order in which they are currently being displayed.
- *
- * @return the receiver's item sizes in their current visual order
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
+int layoutItems () {
+ int y = 0, maxWidth = 0, width = getSize().x;
+ for (int row = 0; row < items.length; row++) {
+ int count = items[row].length;
+ int x = 0;
+
+ /* determine the height and the available width for the row */
+ int rowHeight = 0;
+ int available = width;
+ for (int i = 0; i < items[row].length; i++) {
+ CoolItem item = items[row][i];
+ if (item.control != null) {
+ rowHeight = Math.max(rowHeight, item.control.getSize().y);
+ }
+ available -= item.internalGetMinimumWidth();
+ if (available < 0 && (width > item.internalGetMinimumWidth())) {
+ /* push the next items into the next row */
+ available += item.internalGetMinimumWidth();
+ int amount = items[row].length - i;
+ CoolItem[] nextRow;
+ if (row + 1 == items.length) { /* Adding a new row */
+ nextRow = new CoolItem [amount];
+ CoolItem[][] newItems = new CoolItem [items.length + 1][];
+ System.arraycopy(items, 0, newItems, 0, items.length);
+ items = newItems;
+ } else {
+ nextRow = new CoolItem [amount + items [row + 1].length];
+ System.arraycopy(items[row+1], 0, nextRow, amount, items [row + 1].length);
+ }
+ System.arraycopy(items[row], i, nextRow, 0, amount);
+ items [row + 1] = nextRow;
+ CoolItem[] thisRow = new CoolItem[i];
+ System.arraycopy(items[row], 0, thisRow, 0, i);
+ items[row] = thisRow;
+ break;
+ }
+ }
+ rowHeight += 2 * CoolItem.MARGIN_HEIGHT;
+ if (row > 0) y += ROW_SPACING;
+
+
+ /* lay the items out */
+ for (int i = 0; i < items[row].length; i++) {
+ CoolItem child = items[row][i];
+ int newWidth = available + child.internalGetMinimumWidth();
+ if (i + 1 < count) {
+ newWidth = Math.min(newWidth, child.requestedWidth);
+ available -= (newWidth - child.internalGetMinimumWidth());
+ }
+ Rectangle oldBounds = child.getBounds();
+ Rectangle newBounds = new Rectangle(x, y, newWidth, rowHeight);
+ if (!oldBounds.equals(newBounds)) {
+ child.setBounds(newBounds.x, newBounds.y, newBounds.width, newBounds.height);
+ Rectangle damage = new Rectangle(0, 0, 0, 0);
+ /* Cases are in descending order from most area to redraw to least. */
+ if (oldBounds.y != newBounds.y) {
+ damage = newBounds;
+ damage.add(oldBounds);
+ /* Redraw the row separator as well. */
+ damage.y -= ROW_SPACING;
+ damage.height += 2 * ROW_SPACING;
+ }
+ else if (oldBounds.height != newBounds.height) {
+ /*
+ * Draw from the bottom of the gripper to the bottom of the new area.
+ * (Bottom of the gripper is -3 from the bottom of the item).
+ */
+ damage.y = newBounds.y + Math.min(oldBounds.height, newBounds.height) - 3;
+ damage.height = newBounds.y + newBounds.height + ROW_SPACING;
+ damage.x = oldBounds.x - CoolItem.MARGIN_WIDTH;
+ damage.width = oldBounds.width + CoolItem.MARGIN_WIDTH;
+ }
+ else if (oldBounds.x != newBounds.x) {
+ /* Redraw only the difference between the separators. */
+ damage.x = Math.min(oldBounds.x, newBounds.x);
+ damage.width = Math.abs(oldBounds.x - newBounds.x) + CoolItem.MINIMUM_WIDTH;
+ damage.y = oldBounds.y;
+ damage.height = oldBounds.height;
+ }
+ redraw(damage.x, damage.y, damage.width, damage.height, false);
+ }
+ x += newWidth;
+ }
+ maxWidth = Math.max(maxWidth, x);
+ y += rowHeight;
+ }
+ return y;
+}
+void relayout() {
+ Point size = getSize();
+ int height = layoutItems();
+ Rectangle trim = computeTrim (0, 0, 0, height);
+ if (height != size.y) super.setSize(size.x, trim.height);
+}
+public void setBounds (int x, int y, int width, int height) {
+ super.setBounds (x, y, width, height);
+ layoutItems();
+}
+public void setSize (int width, int height) {
+ super.setSize (width, height);
+ layoutItems();
+}
+/**
+ * Returns an array of zero-relative ints that map
+ * the creation order of the receiver's items to the
+ * order in which they are currently being displayed.
+ * <p>
+ * Specifically, the indices of the returned array represent
+ * the current visual order of the items, and the contents
+ * of the array represent the creation order of the items.
+ * </p><p>
+ * Note: This is not the actual structure used by the receiver
+ * to maintain its list of items, so modifying the array will
+ * not affect the receiver.
+ * </p>
+ *
+ * @return the current visual order of the receiver's items
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * @exception SWTError <ul>
+ * <li>ERROR_CANNOT_GET_ITEM - if the operation fails because of an operating system failure</li>
+ * </ul>
*/
-public Point[] getItemSizes () {
- checkWidget();
- CoolItem[] items = getItems();
- Point[] sizes = new Point[items.length];
- for (int i = 0; i < items.length; i++) {
- sizes[i] = items[i].getSize();
- }
- return sizes;
-}
-void setItemSizes (Point[] sizes) {
- if (sizes == null) error(SWT.ERROR_NULL_ARGUMENT);
- CoolItem[] items = getItems();
- if (sizes.length != items.length) error(SWT.ERROR_INVALID_ARGUMENT);
- for (int i = 0; i < items.length; i++) {
- items[i].setSize(sizes[i]);
- }
-}
-/**
- * Returns whether or not the receiver is 'locked'. When a coolbar
- * is locked, its items cannot be repositioned.
- *
- * @return true if the coolbar is locked, false otherwise
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @since 2.0
+public int[] getItemOrder () {
+ checkWidget ();
+ int count = getItemCount ();
+ int [] indices = new int [count];
+ count = 0;
+ for (int i = 0; i < items.length; i++) {
+ for (int j = 0; j < items[i].length; j++) {
+ CoolItem item = items[i][j];
+ int index = 0;
+ while (index<originalItems.length) {
+ if (originalItems [index] == item) break;
+ index++;
+ }
+ if (index == originalItems.length) error (SWT.ERROR_CANNOT_GET_ITEM);
+ indices [count++] = index;
+ }
+ }
+ return indices;
+}
+void setItemOrder (int[] itemOrder) {
+ if (itemOrder == null) error(SWT.ERROR_NULL_ARGUMENT);
+ int count = originalItems.length;
+ if (itemOrder.length != count) error(SWT.ERROR_INVALID_ARGUMENT);
+
+ /* Ensure that itemOrder does not contain any duplicates. */
+ boolean [] set = new boolean [count];
+ for (int i = 0; i < set.length; i++) set [i] = false;
+ for (int i = 0; i < itemOrder.length; i++) {
+ if (itemOrder [i] < 0 || itemOrder [i] >= count) error (SWT.ERROR_INVALID_ARGUMENT);
+ if (set [itemOrder [i]]) error (SWT.ERROR_INVALID_ARGUMENT);
+ set [itemOrder [i]] = true;
+ }
+
+ CoolItem[] row = new CoolItem[count];
+ for (int i = 0; i < count; i++) {
+ row[i] = originalItems[itemOrder[i]];
+ }
+ items = new CoolItem[1][count];
+ items[0] = row;
+}
+/**
+ * Returns an array of points whose x and y coordinates describe
+ * the widths and heights (respectively) of the items in the receiver
+ * in the order in which they are currently being displayed.
+ *
+ * @return the receiver's item sizes in their current visual order
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
*/
-public boolean getLocked () {
- checkWidget ();
- return isLocked;
-}
-/**
- * Returns an array of ints that describe the zero-relative
- * indices of any item(s) in the receiver that will begin on
- * a new row. The 0th visible item always begins the first row,
- * therefore it does not count as a wrap index.
- *
- * @return an array containing the receiver's wrap indices, or an empty array if all items are in one row
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
+public Point[] getItemSizes () {
+ checkWidget();
+ CoolItem[] items = getItems();
+ Point[] sizes = new Point[items.length];
+ for (int i = 0; i < items.length; i++) {
+ sizes[i] = items[i].getSize();
+ }
+ return sizes;
+}
+void setItemSizes (Point[] sizes) {
+ if (sizes == null) error(SWT.ERROR_NULL_ARGUMENT);
+ CoolItem[] items = getItems();
+ if (sizes.length != items.length) error(SWT.ERROR_INVALID_ARGUMENT);
+ for (int i = 0; i < items.length; i++) {
+ items[i].setSize(sizes[i]);
+ }
+}
+/**
+ * Returns whether or not the receiver is 'locked'. When a coolbar
+ * is locked, its items cannot be repositioned.
+ *
+ * @return true if the coolbar is locked, false otherwise
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @since 2.0
*/
-public int[] getWrapIndices () {
- checkWidget();
- if (items.length <= 1) return new int[]{};
- int[] data = new int[items.length - 1];
- int i = 0, nextWrap = items[0].length;
- for (int row = 1; row < items.length; row++) {
- data[i++] = nextWrap;
- nextWrap += items[row].length;
- }
- return data;
-}
-/**
- * Sets whether or not the receiver is 'locked'. When a coolbar
- * is locked, its items cannot be repositioned.
- *
- * @param locked lock the coolbar if true, otherwise unlock the coolbar
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @since 2.0
+public boolean getLocked () {
+ checkWidget ();
+ return isLocked;
+}
+/**
+ * Returns an array of ints that describe the zero-relative
+ * indices of any item(s) in the receiver that will begin on
+ * a new row. The 0th visible item always begins the first row,
+ * therefore it does not count as a wrap index.
+ *
+ * @return an array containing the receiver's wrap indices, or an empty array if all items are in one row
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
*/
-public void setLocked (boolean locked) {
- checkWidget ();
- if (isLocked != locked) {
- redraw();
- }
- isLocked = locked;
-
-}
-/**
- * Sets the indices of all item(s) in the receiver that will
- * begin on a new row. The indices are given in the order in
- * which they are currently being displayed. The 0th item
- * always begins the first row, therefore it does not count
- * as a wrap index. If indices is null or empty, the items
- * will be placed on one line.
- *
- * @param indices an array of wrap indices, or null
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
+public int[] getWrapIndices () {
+ checkWidget();
+ if (items.length <= 1) return new int[]{};
+ int[] data = new int[items.length - 1];
+ int i = 0, nextWrap = items[0].length;
+ for (int row = 1; row < items.length; row++) {
+ data[i++] = nextWrap;
+ nextWrap += items[row].length;
+ }
+ return data;
+}
+/**
+ * Sets whether or not the receiver is 'locked'. When a coolbar
+ * is locked, its items cannot be repositioned.
+ *
+ * @param locked lock the coolbar if true, otherwise unlock the coolbar
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @since 2.0
*/
-public void setWrapIndices (int[] data) {
- checkWidget();
- if (data == null) data = new int[0];
- for (int i=0; i<data.length; i++) {
- if (data[i] < 0 || data[i] >= originalItems.length) error (SWT.ERROR_INVALID_ARGUMENT);
- }
- if (items.length == 0) return;
-
- CoolItem[] allItems = getItems();
- items = new CoolItem[0][];
- CoolItem[][] newItems;
- CoolItem[] row;
- int itemIndex = 0;
- for (int i = 0; i <= data.length; i++) {
- int nextWrap = (i < data.length) ? data[i] : allItems.length;
- if (nextWrap != 0) {
- row = new CoolItem[nextWrap - itemIndex];
- System.arraycopy(allItems, itemIndex, row, 0, row.length);
- itemIndex += row.length;
- newItems = new CoolItem[items.length + 1][];
- System.arraycopy(items, 0, newItems, 0, items.length);
- newItems[items.length] = row;
- items = newItems;
- }
- }
- relayout();
-}
-/**
- * Sets the receiver's item order, wrap indices, and item sizes
- * all at once. This method is typically used to restore the
- * displayed state of the receiver to a previously stored state.
- * <p>
- * The item order is the order in which the items in the receiver
- * should be displayed, given in terms of the zero-relative ordering
- * of when the items were added.
- * </p><p>
- * The wrap indices are the indices of all item(s) in the receiver
- * that will begin on a new row. The indices are given in the order
- * specified by the item order. The 0th item always begins the first
- * row, therefore it does not count as a wrap index. If wrap indices
- * is null or empty, the items will be placed on one line.
- * </p><p>
- * The sizes are specified in an array of points whose x and y
- * coordinates describe the new widths and heights (respectively)
- * of the receiver's items in the order specified by the item order.
- * </p>
- *
- * @param itemOrder an array of indices that describe the new order to display the items in
- * @param wrapIndices an array of wrap indices, or null
- * @param sizes an array containing the new sizes for each of the receiver's items in visual order
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if item order or sizes is null</li>
- * <li>ERROR_INVALID_ARGUMENT - if item order or sizes is not the same length as the number of items</li>
- * </ul>
- * @exception SWTError <ul>
- * <li>ERROR_CANNOT_GET_ITEM - if the operation fails because of an operating system failure</li>
- * </ul>
+public void setLocked (boolean locked) {
+ checkWidget ();
+ if (isLocked != locked) {
+ redraw();
+ }
+ isLocked = locked;
+
+}
+/**
+ * Sets the indices of all item(s) in the receiver that will
+ * begin on a new row. The indices are given in the order in
+ * which they are currently being displayed. The 0th item
+ * always begins the first row, therefore it does not count
+ * as a wrap index. If indices is null or empty, the items
+ * will be placed on one line.
+ *
+ * @param indices an array of wrap indices, or null
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
*/
-public void setItemLayout (int[] itemOrder, int[] wrapIndices, Point[] sizes) {
- checkWidget();
- setItemOrder(itemOrder);
- setWrapIndices(wrapIndices);
- setItemSizes(sizes);
- relayout();
-}
-}
+public void setWrapIndices (int[] data) {
+ checkWidget();
+ if (data == null) data = new int[0];
+ for (int i=0; i<data.length; i++) {
+ if (data[i] < 0 || data[i] >= originalItems.length) error (SWT.ERROR_INVALID_ARGUMENT);
+ }
+ if (items.length == 0) return;
+
+ CoolItem[] allItems = getItems();
+ items = new CoolItem[0][];
+ CoolItem[][] newItems;
+ CoolItem[] row;
+ int itemIndex = 0;
+ for (int i = 0; i <= data.length; i++) {
+ int nextWrap = (i < data.length) ? data[i] : allItems.length;
+ if (nextWrap != 0) {
+ row = new CoolItem[nextWrap - itemIndex];
+ System.arraycopy(allItems, itemIndex, row, 0, row.length);
+ itemIndex += row.length;
+ newItems = new CoolItem[items.length + 1][];
+ System.arraycopy(items, 0, newItems, 0, items.length);
+ newItems[items.length] = row;
+ items = newItems;
+ }
+ }
+ relayout();
+}
+/**
+ * Sets the receiver's item order, wrap indices, and item sizes
+ * all at once. This method is typically used to restore the
+ * displayed state of the receiver to a previously stored state.
+ * <p>
+ * The item order is the order in which the items in the receiver
+ * should be displayed, given in terms of the zero-relative ordering
+ * of when the items were added.
+ * </p><p>
+ * The wrap indices are the indices of all item(s) in the receiver
+ * that will begin on a new row. The indices are given in the order
+ * specified by the item order. The 0th item always begins the first
+ * row, therefore it does not count as a wrap index. If wrap indices
+ * is null or empty, the items will be placed on one line.
+ * </p><p>
+ * The sizes are specified in an array of points whose x and y
+ * coordinates describe the new widths and heights (respectively)
+ * of the receiver's items in the order specified by the item order.
+ * </p>
+ *
+ * @param itemOrder an array of indices that describe the new order to display the items in
+ * @param wrapIndices an array of wrap indices, or null
+ * @param sizes an array containing the new sizes for each of the receiver's items in visual order
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if item order or sizes is null</li>
+ * <li>ERROR_INVALID_ARGUMENT - if item order or sizes is not the same length as the number of items</li>
+ * </ul>
+ * @exception SWTError <ul>
+ * <li>ERROR_CANNOT_GET_ITEM - if the operation fails because of an operating system failure</li>
+ * </ul>
+ */
+public void setItemLayout (int[] itemOrder, int[] wrapIndices, Point[] sizes) {
+ checkWidget();
+ setItemOrder(itemOrder);
+ setWrapIndices(wrapIndices);
+ setItemSizes(sizes);
+ relayout();
+}
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/emulated/coolbar/org/eclipse/swt/widgets/CoolItem.java b/bundles/org.eclipse.swt/Eclipse SWT/emulated/coolbar/org/eclipse/swt/widgets/CoolItem.java
index 043dcddd4b..325a1bc8a8 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/emulated/coolbar/org/eclipse/swt/widgets/CoolItem.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/emulated/coolbar/org/eclipse/swt/widgets/CoolItem.java
@@ -1,639 +1,639 @@
-package org.eclipse.swt.widgets;
-
-/*
+package org.eclipse.swt.widgets;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-import org.eclipse.swt.*;
-import org.eclipse.swt.events.*;
-import org.eclipse.swt.graphics.*;
-
-/**
- * Instances of this class are selectable user interface
- * objects that represent the dynamically positionable
- * areas of a <code>CoolBar</code>.
- * <dl>
- * <dt><b>Styles:</b></dt>
- * <dd>DROP_DOWN</dd>
- * <dt><b>Events:</b></dt>
- * <dd>Selection</dd>
- * </dl>
- * <p>
- * IMPORTANT: This class is <em>not</em> intended to be subclassed.
- * </p>
+ * http://www.eclipse.org/legal/cpl-v10.html
*/
-public class CoolItem extends Item {
- Control control;
- CoolBar parent;
- int preferredWidth, requestedWidth;
- boolean ideal;
- Point minimumSize = new Point (MINIMUM_WIDTH, 2 * MARGIN_HEIGHT);
- Rectangle itemBounds = new Rectangle(0, 0, 0, 0);
-
- static final int MARGIN_WIDTH = 4;
- static final int MARGIN_HEIGHT = 0;
- static final int GRABBER_WIDTH = 2;
-
- private int CHEVRON_HORIZONTAL_TRIM = -1; //platform dependent values
- private int CHEVRON_VERTICAL_TRIM = -1;
- private static final int CHEVRON_LEFT_MARGIN = 2;
- private static final int CHEVRON_IMAGE_WIDTH = 8; //Width to draw the double arrow
-
- static final int MINIMUM_WIDTH = (2 * MARGIN_WIDTH) + GRABBER_WIDTH;
-
- ToolBar chevron;
- Image arrowImage = null;
-
-/**
- * Constructs a new instance of this class given its parent
- * (which must be a <code>CoolBar</code>) and a style value
- * describing its behavior and appearance. The item is added
- * to the end of the items maintained by its parent.
- * <p>
- * The style value is either one of the style constants defined in
- * class <code>SWT</code> which is applicable to instances of this
- * class, or must be built by <em>bitwise OR</em>'ing together
- * (that is, using the <code>int</code> "|" operator) two or more
- * of those <code>SWT</code> style constants. The class description
- * lists the style constants that are applicable to the class.
- * Style bits are also inherited from superclasses.
- * </p>
- *
- * @param parent a composite control which will be the parent of the new instance (cannot be null)
- * @param style the style of control to construct
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
- * <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
- * </ul>
- *
- * @see SWT#DROP_DOWN
- * @see Widget#checkSubclass
- * @see Widget#getStyle
+
+import org.eclipse.swt.*;
+import org.eclipse.swt.events.*;
+import org.eclipse.swt.graphics.*;
+
+/**
+ * Instances of this class are selectable user interface
+ * objects that represent the dynamically positionable
+ * areas of a <code>CoolBar</code>.
+ * <dl>
+ * <dt><b>Styles:</b></dt>
+ * <dd>DROP_DOWN</dd>
+ * <dt><b>Events:</b></dt>
+ * <dd>Selection</dd>
+ * </dl>
+ * <p>
+ * IMPORTANT: This class is <em>not</em> intended to be subclassed.
+ * </p>
*/
-public CoolItem (CoolBar parent, int style) {
- super (parent, style);
- this.parent = parent;
- parent.createItem (this, parent.getItemCount());
- calculateChevronTrim ();
-}
-/**
- * Constructs a new instance of this class given its parent
- * (which must be a <code>CoolBar</code>), a style value
- * describing its behavior and appearance, and the index
- * at which to place it in the items maintained by its parent.
- * <p>
- * The style value is either one of the style constants defined in
- * class <code>SWT</code> which is applicable to instances of this
- * class, or must be built by <em>bitwise OR</em>'ing together
- * (that is, using the <code>int</code> "|" operator) two or more
- * of those <code>SWT</code> style constants. The class description
- * lists the style constants that are applicable to the class.
- * Style bits are also inherited from superclasses.
- * </p>
- *
- * @param parent a composite control which will be the parent of the new instance (cannot be null)
- * @param style the style of control to construct
- * @param index the index at which 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#DROP_DOWN
- * @see Widget#checkSubclass
- * @see Widget#getStyle
+public class CoolItem extends Item {
+ Control control;
+ CoolBar parent;
+ int preferredWidth, requestedWidth;
+ boolean ideal;
+ Point minimumSize = new Point (MINIMUM_WIDTH, 2 * MARGIN_HEIGHT);
+ Rectangle itemBounds = new Rectangle(0, 0, 0, 0);
+
+ static final int MARGIN_WIDTH = 4;
+ static final int MARGIN_HEIGHT = 0;
+ static final int GRABBER_WIDTH = 2;
+
+ private int CHEVRON_HORIZONTAL_TRIM = -1; //platform dependent values
+ private int CHEVRON_VERTICAL_TRIM = -1;
+ private static final int CHEVRON_LEFT_MARGIN = 2;
+ private static final int CHEVRON_IMAGE_WIDTH = 8; //Width to draw the double arrow
+
+ static final int MINIMUM_WIDTH = (2 * MARGIN_WIDTH) + GRABBER_WIDTH;
+
+ ToolBar chevron;
+ Image arrowImage = null;
+
+/**
+ * Constructs a new instance of this class given its parent
+ * (which must be a <code>CoolBar</code>) and a style value
+ * describing its behavior and appearance. The item is added
+ * to the end of the items maintained by its parent.
+ * <p>
+ * The style value is either one of the style constants defined in
+ * class <code>SWT</code> which is applicable to instances of this
+ * class, or must be built by <em>bitwise OR</em>'ing together
+ * (that is, using the <code>int</code> "|" operator) two or more
+ * of those <code>SWT</code> style constants. The class description
+ * lists the style constants that are applicable to the class.
+ * Style bits are also inherited from superclasses.
+ * </p>
+ *
+ * @param parent a composite control which will be the parent of the new instance (cannot be null)
+ * @param style the style of control to construct
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
+ * <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
+ * </ul>
+ *
+ * @see SWT#DROP_DOWN
+ * @see Widget#checkSubclass
+ * @see Widget#getStyle
*/
-public CoolItem (CoolBar parent, int style, int index) {
- super(parent, style);
- this.parent = parent;
- parent.createItem (this, index);
- calculateChevronTrim ();
-}
-/**
- * Adds the listener to the collection of listeners that will
- * be notified when the control is selected, by sending it one
- * of the messages defined in the <code>SelectionListener</code>
- * interface.
- * <p>
- * If <code>widgetSelected</code> is called when the mouse is over
- * the drop-down arrow (or 'chevron') portion of the cool item,
- * the event object detail field contains the value <code>SWT.ARROW</code>,
- * and the x and y fields in the event object represent the point at
- * the bottom left of the chevron, where the menu should be popped up.
- * <code>widgetDefaultSelected</code> is not called.
- * </p>
- *
- * @param listener the listener which should be notified
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see SelectionListener
- * @see #removeSelectionListener
- * @see SelectionEvent
- *
- * @since 2.0
+public CoolItem (CoolBar parent, int style) {
+ super (parent, style);
+ this.parent = parent;
+ parent.createItem (this, parent.getItemCount());
+ calculateChevronTrim ();
+}
+/**
+ * Constructs a new instance of this class given its parent
+ * (which must be a <code>CoolBar</code>), a style value
+ * describing its behavior and appearance, and the index
+ * at which to place it in the items maintained by its parent.
+ * <p>
+ * The style value is either one of the style constants defined in
+ * class <code>SWT</code> which is applicable to instances of this
+ * class, or must be built by <em>bitwise OR</em>'ing together
+ * (that is, using the <code>int</code> "|" operator) two or more
+ * of those <code>SWT</code> style constants. The class description
+ * lists the style constants that are applicable to the class.
+ * Style bits are also inherited from superclasses.
+ * </p>
+ *
+ * @param parent a composite control which will be the parent of the new instance (cannot be null)
+ * @param style the style of control to construct
+ * @param index the index at which 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#DROP_DOWN
+ * @see Widget#checkSubclass
+ * @see Widget#getStyle
*/
-public void addSelectionListener(SelectionListener listener) {
- checkWidget();
- if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
- TypedListener typedListener = new TypedListener (listener);
- addListener (SWT.Selection,typedListener);
- addListener (SWT.DefaultSelection,typedListener);
-}
-protected void checkSubclass () {
- if (!isValidSubclass ()) error (SWT.ERROR_INVALID_SUBCLASS);
-}
-
-/*
- * Find the trim size of the Toolbar widget in the current platform.
- */
-void calculateChevronTrim () {
- ToolBar tb = new ToolBar (parent, SWT.FLAT);
- ToolItem ti = new ToolItem (tb, SWT.PUSH);
- Image image = new Image (getDisplay(), 1, 1);
- ti.setImage (image);
- Point size = tb.computeSize (SWT.DEFAULT, SWT.DEFAULT);
- CHEVRON_HORIZONTAL_TRIM = size.x - 1;
- CHEVRON_VERTICAL_TRIM = size.y - 1;
- tb.dispose ();
- ti.dispose ();
- image.dispose ();
-}
-/**
- * Returns the preferred size of the receiver.
- * <p>
- * The <em>preferred size</em> of a <code>CoolItem</code> is the size that
- * it would best be displayed at. The width hint and height hint arguments
- * allow the caller to ask the instance questions such as "Given a particular
- * width, how high does it need to be to show all of the contents?"
- * To indicate that the caller does not wish to constrain a particular
- * dimension, the constant <code>SWT.DEFAULT</code> is passed for the hint.
- * </p>
- *
- * @param wHint the width hint (can be <code>SWT.DEFAULT</code>)
- * @param hHint the height hint (can be <code>SWT.DEFAULT</code>)
- * @return the preferred size
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see Layout
- * @see #getBounds
- * @see #getSize
- * @see CoolBar#getBorderWidth
- * @see CoolBar#computeTrim
- * @see CoolBar#getClientArea
+public CoolItem (CoolBar parent, int style, int index) {
+ super(parent, style);
+ this.parent = parent;
+ parent.createItem (this, index);
+ calculateChevronTrim ();
+}
+/**
+ * Adds the listener to the collection of listeners that will
+ * be notified when the control is selected, by sending it one
+ * of the messages defined in the <code>SelectionListener</code>
+ * interface.
+ * <p>
+ * If <code>widgetSelected</code> is called when the mouse is over
+ * the drop-down arrow (or 'chevron') portion of the cool item,
+ * the event object detail field contains the value <code>SWT.ARROW</code>,
+ * and the x and y fields in the event object represent the point at
+ * the bottom left of the chevron, where the menu should be popped up.
+ * <code>widgetDefaultSelected</code> is not called.
+ * </p>
+ *
+ * @param listener the listener which should be notified
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see SelectionListener
+ * @see #removeSelectionListener
+ * @see SelectionEvent
+ *
+ * @since 2.0
*/
-public Point computeSize (int wHint, int hHint) {
- checkWidget();
- int width = wHint, height = hHint;
- if (wHint == SWT.DEFAULT) width = 32;
- if (hHint == SWT.DEFAULT) height = 32;
- width += MINIMUM_WIDTH + MARGIN_WIDTH;
- height += 2 * MARGIN_HEIGHT;
- return new Point (width, height);
-}
-public void dispose () {
- if (isDisposed()) return;
-
- /*
- * Must call parent.destroyItem() before super.dispose(), since it needs to
- * query the bounds to properly remove the item.
- */
- parent.destroyItem(this);
- super.dispose ();
- parent = null;
- control = null;
-
- /*
- * Although the parent for the chevron is the CoolBar (CoolItem can not be the parent)
- * it has to be disposed with the item
- */
- if (chevron != null && !chevron.isDisposed()) chevron.dispose();
- chevron = null;
- if (arrowImage != null && !arrowImage.isDisposed()) arrowImage.dispose();
- arrowImage = null;
-}
-
-Image createArrowImage (int width, int height) {
- Display display = getDisplay ();
- Color foreground = parent.getForeground ();
- Color black = display.getSystemColor (SWT.COLOR_BLACK);
- Color background = parent.getBackground ();
-
- PaletteData palette = new PaletteData (new RGB[]{foreground.getRGB(), background.getRGB(), black.getRGB()});
- ImageData imageData = new ImageData (width, height, 4, palette);
- imageData.transparentPixel = 1;
- Image image = new Image (display, imageData);
-
- GC gc = new GC (image);
- gc.setBackground (background);
- gc.fillRectangle (0, 0, width, height);
- gc.setForeground (black);
-
- int startX = 0 ;
- int startY = height / 6;
- int step = 2;
- gc.drawLine (startX, startY, startX + step, startY + step);
- gc.drawLine (startX, startY + (2 * step), startX + step, startY + step);
- startX++;
- gc.drawLine (startX, startY, startX + step, startY + step);
- gc.drawLine (startX, startY + (2 * step), startX + step, startY + step);
- startX += 3;
- gc.drawLine (startX, startY, startX + step, startY + step);
- gc.drawLine (startX, startY + (2 * step), startX + step, startY + step);
- startX++;
- gc.drawLine (startX, startY, startX + step, startY + step);
- gc.drawLine (startX, startY + (2 * step), startX + step, startY + step);
- gc.dispose ();
- return image;
-}
-/**
- * Returns a rectangle describing the receiver's size and location
- * relative to its parent.
- *
- * @return the receiver's bounding rectangle
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
+public void addSelectionListener(SelectionListener listener) {
+ checkWidget();
+ if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+ TypedListener typedListener = new TypedListener (listener);
+ addListener (SWT.Selection,typedListener);
+ addListener (SWT.DefaultSelection,typedListener);
+}
+protected void checkSubclass () {
+ if (!isValidSubclass ()) error (SWT.ERROR_INVALID_SUBCLASS);
+}
+
+/*
+ * Find the trim size of the Toolbar widget in the current platform.
*/
-public Rectangle getBounds () {
- checkWidget();
- return new Rectangle(itemBounds.x, itemBounds.y, itemBounds.width, itemBounds.height);
-}
-/**
- * Returns the control that is associated with the receiver.
- *
- * @return the control that is contained by the receiver
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
+void calculateChevronTrim () {
+ ToolBar tb = new ToolBar (parent, SWT.FLAT);
+ ToolItem ti = new ToolItem (tb, SWT.PUSH);
+ Image image = new Image (getDisplay(), 1, 1);
+ ti.setImage (image);
+ Point size = tb.computeSize (SWT.DEFAULT, SWT.DEFAULT);
+ CHEVRON_HORIZONTAL_TRIM = size.x - 1;
+ CHEVRON_VERTICAL_TRIM = size.y - 1;
+ tb.dispose ();
+ ti.dispose ();
+ image.dispose ();
+}
+/**
+ * Returns the preferred size of the receiver.
+ * <p>
+ * The <em>preferred size</em> of a <code>CoolItem</code> is the size that
+ * it would best be displayed at. The width hint and height hint arguments
+ * allow the caller to ask the instance questions such as "Given a particular
+ * width, how high does it need to be to show all of the contents?"
+ * To indicate that the caller does not wish to constrain a particular
+ * dimension, the constant <code>SWT.DEFAULT</code> is passed for the hint.
+ * </p>
+ *
+ * @param wHint the width hint (can be <code>SWT.DEFAULT</code>)
+ * @param hHint the height hint (can be <code>SWT.DEFAULT</code>)
+ * @return the preferred size
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see Layout
+ * @see #getBounds
+ * @see #getSize
+ * @see CoolBar#getBorderWidth
+ * @see CoolBar#computeTrim
+ * @see CoolBar#getClientArea
*/
-public Control getControl () {
- checkWidget();
- return control;
-}
-public Display getDisplay () {
- Composite parent = this.parent;
- if (parent == null) error (SWT.ERROR_WIDGET_DISPOSED);
- return parent.getDisplay ();
-}
-/**
- * Returns the minimum size that the cool item can
- * be resized to using the cool item's gripper.
- *
- * @return a point containing the minimum width and height of the cool item, in pixels
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @since 2.0
+public Point computeSize (int wHint, int hHint) {
+ checkWidget();
+ int width = wHint, height = hHint;
+ if (wHint == SWT.DEFAULT) width = 32;
+ if (hHint == SWT.DEFAULT) height = 32;
+ width += MINIMUM_WIDTH + MARGIN_WIDTH;
+ height += 2 * MARGIN_HEIGHT;
+ return new Point (width, height);
+}
+public void dispose () {
+ if (isDisposed()) return;
+
+ /*
+ * Must call parent.destroyItem() before super.dispose(), since it needs to
+ * query the bounds to properly remove the item.
+ */
+ parent.destroyItem(this);
+ super.dispose ();
+ parent = null;
+ control = null;
+
+ /*
+ * Although the parent for the chevron is the CoolBar (CoolItem can not be the parent)
+ * it has to be disposed with the item
+ */
+ if (chevron != null && !chevron.isDisposed()) chevron.dispose();
+ chevron = null;
+ if (arrowImage != null && !arrowImage.isDisposed()) arrowImage.dispose();
+ arrowImage = null;
+}
+
+Image createArrowImage (int width, int height) {
+ Display display = getDisplay ();
+ Color foreground = parent.getForeground ();
+ Color black = display.getSystemColor (SWT.COLOR_BLACK);
+ Color background = parent.getBackground ();
+
+ PaletteData palette = new PaletteData (new RGB[]{foreground.getRGB(), background.getRGB(), black.getRGB()});
+ ImageData imageData = new ImageData (width, height, 4, palette);
+ imageData.transparentPixel = 1;
+ Image image = new Image (display, imageData);
+
+ GC gc = new GC (image);
+ gc.setBackground (background);
+ gc.fillRectangle (0, 0, width, height);
+ gc.setForeground (black);
+
+ int startX = 0 ;
+ int startY = height / 6;
+ int step = 2;
+ gc.drawLine (startX, startY, startX + step, startY + step);
+ gc.drawLine (startX, startY + (2 * step), startX + step, startY + step);
+ startX++;
+ gc.drawLine (startX, startY, startX + step, startY + step);
+ gc.drawLine (startX, startY + (2 * step), startX + step, startY + step);
+ startX += 3;
+ gc.drawLine (startX, startY, startX + step, startY + step);
+ gc.drawLine (startX, startY + (2 * step), startX + step, startY + step);
+ startX++;
+ gc.drawLine (startX, startY, startX + step, startY + step);
+ gc.drawLine (startX, startY + (2 * step), startX + step, startY + step);
+ gc.dispose ();
+ return image;
+}
+/**
+ * Returns a rectangle describing the receiver's size and location
+ * relative to its parent.
+ *
+ * @return the receiver's bounding rectangle
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
*/
-public Point getMinimumSize () {
- checkWidget();
- return minimumSize;
-}
-/**
- * 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 Rectangle getBounds () {
+ checkWidget();
+ return new Rectangle(itemBounds.x, itemBounds.y, itemBounds.width, itemBounds.height);
+}
+/**
+ * Returns the control that is associated with the receiver.
+ *
+ * @return the control that is contained by the receiver
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
*/
-public CoolBar getParent () {
- checkWidget();
- return parent;
-}
-/**
- * Returns a point describing the receiver's ideal size.
- * The x coordinate of the result is the ideal width of the receiver.
- * The y coordinate of the result is the ideal height of the receiver.
- *
- * @return the receiver's ideal size
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
+public Control getControl () {
+ checkWidget();
+ return control;
+}
+public Display getDisplay () {
+ Composite parent = this.parent;
+ if (parent == null) error (SWT.ERROR_WIDGET_DISPOSED);
+ return parent.getDisplay ();
+}
+/**
+ * Returns the minimum size that the cool item can
+ * be resized to using the cool item's gripper.
+ *
+ * @return a point containing the minimum width and height of the cool item, in pixels
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @since 2.0
*/
-public Point getPreferredSize () {
- checkWidget();
- int height = getSize().y;
- return new Point(preferredWidth, height);
-}
-/**
- * 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 getMinimumSize () {
+ checkWidget();
+ return minimumSize;
+}
+/**
+ * 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 Point getSize () {
- checkWidget();
- return new Point (itemBounds.width, itemBounds.height);
-}
-int internalGetMinimumWidth () {
- int width = minimumSize.x;
- width += MINIMUM_WIDTH + MARGIN_WIDTH;
- if ((style & SWT.DROP_DOWN) != 0 && width < preferredWidth) {
- width += CHEVRON_IMAGE_WIDTH + CHEVRON_HORIZONTAL_TRIM + CHEVRON_LEFT_MARGIN;
- }
- return width;
-}
-/*
- * Called when the chevron is selected.
- */
-void onSelection (Event ev) {
- Rectangle bounds = chevron.getBounds();
- Event event = new Event();
- event.detail = SWT.ARROW;
- event.x = bounds.x;
- event.y = bounds.y + bounds.height;
- postEvent (SWT.Selection, event);
-}
-/**
- * Removes the listener from the collection of listeners that
- * will be notified when the control is selected.
- *
- * @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
- *
- * @since 2.0
+public CoolBar getParent () {
+ checkWidget();
+ return parent;
+}
+/**
+ * Returns a point describing the receiver's ideal size.
+ * The x coordinate of the result is the ideal width of the receiver.
+ * The y coordinate of the result is the ideal height of the receiver.
+ *
+ * @return the receiver's ideal size
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
*/
-public void removeSelectionListener(SelectionListener listener) {
- checkWidget();
- if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
- if (eventTable == null) return;
- eventTable.unhook (SWT.Selection, listener);
- eventTable.unhook (SWT.DefaultSelection,listener);
-}
-void setBounds (int x, int y, int width, int height) {
- itemBounds.x = x;
- itemBounds.y = y;
- itemBounds.width = width;
- itemBounds.height = height;
- if (control != null) {
- int controlHeight = Math.min (height, control.getSize().y);
- int controlWidth = width - MINIMUM_WIDTH - MARGIN_WIDTH;
- if ((style & SWT.DROP_DOWN) != 0 && width < preferredWidth) {
- controlWidth -= CHEVRON_IMAGE_WIDTH + CHEVRON_HORIZONTAL_TRIM + CHEVRON_LEFT_MARGIN;
- }
- control.setBounds (
- x + MINIMUM_WIDTH,
- y + MARGIN_HEIGHT,
- controlWidth,
- controlHeight);
- }
- updateChevron();
-}
-/**
- * Sets the control that is associated with the receiver
- * to the argument.
- *
- * @param control the new control that will be contained by the receiver
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_INVALID_ARGUMENT - if the control has been disposed</li>
- * <li>ERROR_INVALID_PARENT - if the control is not in the same widget tree</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
+public Point getPreferredSize () {
+ checkWidget();
+ int height = getSize().y;
+ return new Point(preferredWidth, height);
+}
+/**
+ * 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 void setControl (Control control) {
- checkWidget();
- if (control != null) {
- if (control.isDisposed()) error (SWT.ERROR_INVALID_ARGUMENT);
- if (control.parent != parent) error (SWT.ERROR_INVALID_PARENT);
- }
- if (this.control != null && this.control.isDisposed ()) {
- this.control = null;
- }
- Control oldControl = this.control;
- if (oldControl != null) oldControl.setVisible(false);
- this.control = control;
- if (control != null && !control.isDisposed ()) {
- Rectangle bounds = getBounds();
- control.setBounds (
- bounds.x + MINIMUM_WIDTH,
- bounds.y + MARGIN_HEIGHT,
- bounds.width - MINIMUM_WIDTH - MARGIN_WIDTH,
- bounds.height - (2 * MARGIN_HEIGHT));
- control.setVisible(true);
- }
-}
-/**
- * Sets the minimum size that the cool item can be resized to
- * using the cool item's gripper, to the point specified by the arguments.
- *
- * @param width the minimum width of the cool item, in pixels
- * @param height the minimum height of the cool item, in pixels
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @since 2.0
+public Point getSize () {
+ checkWidget();
+ return new Point (itemBounds.width, itemBounds.height);
+}
+int internalGetMinimumWidth () {
+ int width = minimumSize.x;
+ width += MINIMUM_WIDTH + MARGIN_WIDTH;
+ if ((style & SWT.DROP_DOWN) != 0 && width < preferredWidth) {
+ width += CHEVRON_IMAGE_WIDTH + CHEVRON_HORIZONTAL_TRIM + CHEVRON_LEFT_MARGIN;
+ }
+ return width;
+}
+/*
+ * Called when the chevron is selected.
*/
-public void setMinimumSize (int width, int height) {
- checkWidget ();
- setMinimumSize(new Point(width, height));
-}
-/**
- * Sets the minimum size that the cool item can be resized to
- * using the cool item's gripper, to the point specified by the argument.
- *
- * @param size a point representing the minimum width and height of the cool item, in pixels
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the point is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @since 2.0
+void onSelection (Event ev) {
+ Rectangle bounds = chevron.getBounds();
+ Event event = new Event();
+ event.detail = SWT.ARROW;
+ event.x = bounds.x;
+ event.y = bounds.y + bounds.height;
+ postEvent (SWT.Selection, event);
+}
+/**
+ * Removes the listener from the collection of listeners that
+ * will be notified when the control is selected.
+ *
+ * @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
+ *
+ * @since 2.0
*/
-public void setMinimumSize (Point size) {
- checkWidget ();
- if (size == null) error(SWT.ERROR_NULL_ARGUMENT);
- minimumSize = size;
-}
-/**
- * Sets the receiver's ideal size to the point specified by the arguments.
- *
- * @param width the new ideal width for the receiver
- * @param height the new ideal height for the receiver
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
+public void removeSelectionListener(SelectionListener listener) {
+ checkWidget();
+ if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+ if (eventTable == null) return;
+ eventTable.unhook (SWT.Selection, listener);
+ eventTable.unhook (SWT.DefaultSelection,listener);
+}
+void setBounds (int x, int y, int width, int height) {
+ itemBounds.x = x;
+ itemBounds.y = y;
+ itemBounds.width = width;
+ itemBounds.height = height;
+ if (control != null) {
+ int controlHeight = Math.min (height, control.getSize().y);
+ int controlWidth = width - MINIMUM_WIDTH - MARGIN_WIDTH;
+ if ((style & SWT.DROP_DOWN) != 0 && width < preferredWidth) {
+ controlWidth -= CHEVRON_IMAGE_WIDTH + CHEVRON_HORIZONTAL_TRIM + CHEVRON_LEFT_MARGIN;
+ }
+ control.setBounds (
+ x + MINIMUM_WIDTH,
+ y + MARGIN_HEIGHT,
+ controlWidth,
+ controlHeight);
+ }
+ updateChevron();
+}
+/**
+ * Sets the control that is associated with the receiver
+ * to the argument.
+ *
+ * @param control the new control that will be contained by the receiver
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_INVALID_ARGUMENT - if the control has been disposed</li>
+ * <li>ERROR_INVALID_PARENT - if the control is not in the same widget tree</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
*/
-public void setPreferredSize (int width, int height) {
- checkWidget();
- ideal = true;
- preferredWidth = Math.max (width, MINIMUM_WIDTH);
- Rectangle bounds = getBounds();
- setBounds(bounds.x, bounds.y, bounds.width, height);
- if (height != bounds.height) parent.relayout();
-}
-/**
- * Sets the receiver's ideal size to the point specified by the argument.
- *
- * @param size the new ideal size for the receiver
- * @param height the new ideal 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 setControl (Control control) {
+ checkWidget();
+ if (control != null) {
+ if (control.isDisposed()) error (SWT.ERROR_INVALID_ARGUMENT);
+ if (control.parent != parent) error (SWT.ERROR_INVALID_PARENT);
+ }
+ if (this.control != null && this.control.isDisposed ()) {
+ this.control = null;
+ }
+ Control oldControl = this.control;
+ if (oldControl != null) oldControl.setVisible(false);
+ this.control = control;
+ if (control != null && !control.isDisposed ()) {
+ Rectangle bounds = getBounds();
+ control.setBounds (
+ bounds.x + MINIMUM_WIDTH,
+ bounds.y + MARGIN_HEIGHT,
+ bounds.width - MINIMUM_WIDTH - MARGIN_WIDTH,
+ bounds.height - (2 * MARGIN_HEIGHT));
+ control.setVisible(true);
+ }
+}
+/**
+ * Sets the minimum size that the cool item can be resized to
+ * using the cool item's gripper, to the point specified by the arguments.
+ *
+ * @param width the minimum width of the cool item, in pixels
+ * @param height the minimum height of the cool item, in pixels
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @since 2.0
*/
-public void setPreferredSize (Point size) {
- checkWidget();
- if (size == null) error(SWT.ERROR_NULL_ARGUMENT);
- setPreferredSize(size.x, size.y);
-}
-/**
- * Sets the receiver's size to the point specified by the arguments.
- * <p>
- * Note: Attempting to set the width or height of the
- * receiver to a negative number will cause that
- * value to be set to zero instead.
- * </p>
- *
- * @param width the new width for the receiver
- * @param height the new height for the receiver
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
+public void setMinimumSize (int width, int height) {
+ checkWidget ();
+ setMinimumSize(new Point(width, height));
+}
+/**
+ * Sets the minimum size that the cool item can be resized to
+ * using the cool item's gripper, to the point specified by the argument.
+ *
+ * @param size a point representing the minimum width and height of the cool item, in pixels
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if the point is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @since 2.0
*/
-public void setSize (int width, int height) {
- checkWidget();
- int newWidth = Math.max (width, MINIMUM_WIDTH);
- itemBounds.width = requestedWidth = newWidth;
- if (!ideal) preferredWidth = newWidth;
- itemBounds.height = height;
- if (control != null) {
- int controlWidth = newWidth - MINIMUM_WIDTH - MARGIN_WIDTH;
- if ((style & SWT.DROP_DOWN) != 0 && width < preferredWidth) {
- controlWidth -= CHEVRON_IMAGE_WIDTH + CHEVRON_HORIZONTAL_TRIM + CHEVRON_LEFT_MARGIN;
- }
- int controlHeight = height - (2 * MARGIN_HEIGHT);
- control.setSize(controlWidth, controlHeight);
- }
- parent.relayout();
- updateChevron();
-}
-/**
- * Sets the receiver's size to the point specified by the argument.
- * <p>
- * Note: Attempting to set the width or height of the
- * receiver to a negative number will cause them to be
- * set to zero instead.
- * </p>
- *
- * @param size the new size for the receiver
- * @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 setMinimumSize (Point size) {
+ checkWidget ();
+ if (size == null) error(SWT.ERROR_NULL_ARGUMENT);
+ minimumSize = size;
+}
+/**
+ * Sets the receiver's ideal size to the point specified by the arguments.
+ *
+ * @param width the new ideal width for the receiver
+ * @param height the new ideal height for the receiver
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
*/
-public void setSize (Point size) {
- checkWidget();
- if (size == null) error (SWT.ERROR_NULL_ARGUMENT);
- setSize (size.x, size.y);
-}
-void updateChevron() {
- if (control != null) {
- int width = itemBounds.width;
- if ((style & SWT.DROP_DOWN) != 0 && width < preferredWidth) {
- int height = Math.min (control.getSize ().y, itemBounds.height);
- if (chevron == null) {
- chevron = new ToolBar (parent, SWT.FLAT | SWT.NO_FOCUS);
- ToolItem toolItem = new ToolItem (chevron, SWT.PUSH);
- chevron.setBackground (parent.getBackground());
- toolItem.addListener (SWT.Selection, new Listener() {
- public void handleEvent (Event event) {
- CoolItem.this.onSelection (event);
- }
- });
- }
- int imageHeight = Math.max(1, height - CHEVRON_VERTICAL_TRIM);
- if (arrowImage == null || (arrowImage != null && arrowImage.getBounds().height != imageHeight)) {
- Image image = createArrowImage (CHEVRON_IMAGE_WIDTH, imageHeight);
- chevron.getItem (0).setImage (image);
- if (arrowImage != null) arrowImage.dispose ();
- arrowImage = image;
- }
- chevron.setBounds (
- itemBounds.x + width - CHEVRON_LEFT_MARGIN - CHEVRON_IMAGE_WIDTH - CHEVRON_HORIZONTAL_TRIM,
- itemBounds.y + MARGIN_HEIGHT,
- CHEVRON_IMAGE_WIDTH + CHEVRON_HORIZONTAL_TRIM,
- height);
- chevron.setVisible(true);
- } else {
- if (chevron != null) {
- chevron.setVisible(false);
- }
- }
- }
-}
-}
+public void setPreferredSize (int width, int height) {
+ checkWidget();
+ ideal = true;
+ preferredWidth = Math.max (width, MINIMUM_WIDTH);
+ Rectangle bounds = getBounds();
+ setBounds(bounds.x, bounds.y, bounds.width, height);
+ if (height != bounds.height) parent.relayout();
+}
+/**
+ * Sets the receiver's ideal size to the point specified by the argument.
+ *
+ * @param size the new ideal size for the receiver
+ * @param height the new ideal 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 setPreferredSize (Point size) {
+ checkWidget();
+ if (size == null) error(SWT.ERROR_NULL_ARGUMENT);
+ setPreferredSize(size.x, size.y);
+}
+/**
+ * Sets the receiver's size to the point specified by the arguments.
+ * <p>
+ * Note: Attempting to set the width or height of the
+ * receiver to a negative number will cause that
+ * value to be set to zero instead.
+ * </p>
+ *
+ * @param width the new width for the receiver
+ * @param height the new height for the receiver
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setSize (int width, int height) {
+ checkWidget();
+ int newWidth = Math.max (width, MINIMUM_WIDTH);
+ itemBounds.width = requestedWidth = newWidth;
+ if (!ideal) preferredWidth = newWidth;
+ itemBounds.height = height;
+ if (control != null) {
+ int controlWidth = newWidth - MINIMUM_WIDTH - MARGIN_WIDTH;
+ if ((style & SWT.DROP_DOWN) != 0 && width < preferredWidth) {
+ controlWidth -= CHEVRON_IMAGE_WIDTH + CHEVRON_HORIZONTAL_TRIM + CHEVRON_LEFT_MARGIN;
+ }
+ int controlHeight = height - (2 * MARGIN_HEIGHT);
+ control.setSize(controlWidth, controlHeight);
+ }
+ parent.relayout();
+ updateChevron();
+}
+/**
+ * Sets the receiver's size to the point specified by the argument.
+ * <p>
+ * Note: Attempting to set the width or height of the
+ * receiver to a negative number will cause them to be
+ * set to zero instead.
+ * </p>
+ *
+ * @param size the new size for the receiver
+ * @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);
+}
+void updateChevron() {
+ if (control != null) {
+ int width = itemBounds.width;
+ if ((style & SWT.DROP_DOWN) != 0 && width < preferredWidth) {
+ int height = Math.min (control.getSize ().y, itemBounds.height);
+ if (chevron == null) {
+ chevron = new ToolBar (parent, SWT.FLAT | SWT.NO_FOCUS);
+ ToolItem toolItem = new ToolItem (chevron, SWT.PUSH);
+ chevron.setBackground (parent.getBackground());
+ toolItem.addListener (SWT.Selection, new Listener() {
+ public void handleEvent (Event event) {
+ CoolItem.this.onSelection (event);
+ }
+ });
+ }
+ int imageHeight = Math.max(1, height - CHEVRON_VERTICAL_TRIM);
+ if (arrowImage == null || (arrowImage != null && arrowImage.getBounds().height != imageHeight)) {
+ Image image = createArrowImage (CHEVRON_IMAGE_WIDTH, imageHeight);
+ chevron.getItem (0).setImage (image);
+ if (arrowImage != null) arrowImage.dispose ();
+ arrowImage = image;
+ }
+ chevron.setBounds (
+ itemBounds.x + width - CHEVRON_LEFT_MARGIN - CHEVRON_IMAGE_WIDTH - CHEVRON_HORIZONTAL_TRIM,
+ itemBounds.y + MARGIN_HEIGHT,
+ CHEVRON_IMAGE_WIDTH + CHEVRON_HORIZONTAL_TRIM,
+ height);
+ chevron.setVisible(true);
+ } else {
+ if (chevron != null) {
+ chevron.setVisible(false);
+ }
+ }
+ }
+}
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/emulated/tabfolder/org/eclipse/swt/widgets/TabFolder.java b/bundles/org.eclipse.swt/Eclipse SWT/emulated/tabfolder/org/eclipse/swt/widgets/TabFolder.java
index 0ff216082e..448d9c7335 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/emulated/tabfolder/org/eclipse/swt/widgets/TabFolder.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/emulated/tabfolder/org/eclipse/swt/widgets/TabFolder.java
@@ -1,1152 +1,1152 @@
-package org.eclipse.swt.widgets;
-
-/*
+package org.eclipse.swt.widgets;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-import org.eclipse.swt.*;
-import org.eclipse.swt.events.*;
-import org.eclipse.swt.graphics.*;
-
-/**
- * Instances of this class implement the notebook user interface
- * metaphor. It allows the user to select a notebook page from
- * set of pages.
- * <p>
- * The item children that may be added to instances of this class
- * must be of type <code>TabItem</code>.
- * <code>Control</code> children are created and then set into a
- * tab item using <code>TabItem#setControl</code>.
- * </p><p>
- * Note that although this class is a subclass of <code>Composite</code>,
- * it does not make sense to set a layout on it.
- * </p><p>
- * <dl>
- * <dt><b>Styles:</b></dt>
- * <dd>(none)</dd>
- * <dt><b>Events:</b></dt>
- * <dd>Selection</dd>
- * </dl>
- * <p>
- * IMPORTANT: This class is <em>not</em> intended to be subclassed.
- * </p>
+ * http://www.eclipse.org/legal/cpl-v10.html
*/
-public class TabFolder extends Composite {
- TabItem items[] = new TabItem [0];
- 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;
- String toolTipText;
-
- // 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
-
-/**
- * Constructs a new instance of this class given its parent
- * and a style value describing its behavior and appearance.
- * <p>
- * The style value is either one of the style constants defined in
- * class <code>SWT</code> which is applicable to instances of this
- * class, or must be built by <em>bitwise OR</em>'ing together
- * (that is, using the <code>int</code> "|" operator) two or more
- * of those <code>SWT</code> style constants. The class description
- * lists the style constants that are applicable to the class.
- * Style bits are also inherited from superclasses.
- * </p>
- *
- * @param parent a composite control which will be the parent of the new instance (cannot be null)
- * @param style the style of control to construct
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
- * <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
- * </ul>
- *
- * @see SWT
- * @see Widget#checkSubclass
- * @see Widget#getStyle
+
+import org.eclipse.swt.*;
+import org.eclipse.swt.events.*;
+import org.eclipse.swt.graphics.*;
+
+/**
+ * Instances of this class implement the notebook user interface
+ * metaphor. It allows the user to select a notebook page from
+ * set of pages.
+ * <p>
+ * The item children that may be added to instances of this class
+ * must be of type <code>TabItem</code>.
+ * <code>Control</code> children are created and then set into a
+ * tab item using <code>TabItem#setControl</code>.
+ * </p><p>
+ * Note that although this class is a subclass of <code>Composite</code>,
+ * it does not make sense to set a layout on it.
+ * </p><p>
+ * <dl>
+ * <dt><b>Styles:</b></dt>
+ * <dd>(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 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.MouseHover, listener);
- addListener (SWT.Paint, listener);
- addListener (SWT.Resize, listener);
- addListener (SWT.Traverse, listener);
- addListener (SWT.KeyDown, listener);
- addListener (SWT.FocusIn, listener);
- addListener (SWT.FocusOut, listener);
-}
-/**
- * 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.
- * <p>
- * When <code>widgetSelected</code> is called, the item field of the event object is valid.
- * <code>widgetDefaultSelected</code> is not called.
- * </p>
- *
- * @param listener the listener which should be notified
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see SelectionListener
- * @see #removeSelectionListener
- * @see SelectionEvent
+public class TabFolder extends Composite {
+ TabItem items[] = new TabItem [0];
+ 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;
+ String toolTipText;
+
+ // 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
+
+/**
+ * Constructs a new instance of this class given its parent
+ * and a style value describing its behavior and appearance.
+ * <p>
+ * The style value is either one of the style constants defined in
+ * class <code>SWT</code> which is applicable to instances of this
+ * class, or must be built by <em>bitwise OR</em>'ing together
+ * (that is, using the <code>int</code> "|" operator) two or more
+ * of those <code>SWT</code> style constants. The class description
+ * lists the style constants that are applicable to the class.
+ * Style bits are also inherited from superclasses.
+ * </p>
+ *
+ * @param parent a composite control which will be the parent of the new instance (cannot be null)
+ * @param style the style of control to construct
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
+ * <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
+ * </ul>
+ *
+ * @see SWT
+ * @see Widget#checkSubclass
+ * @see Widget#getStyle
*/
-public 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) {
- /*
- * 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 = CLIENT_MARGIN_WIDTH * 2 + TabItem.SHADOW_WIDTH * 2;
- int height = 0;
-
- if (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 (wHint, hHint, changed);
- }
- if (size.x == 0) size.x = DEFAULT_WIDTH;
- if (size.y == 0) size.y = DEFAULT_HEIGHT;
- if (wHint != SWT.DEFAULT) size.x = wHint;
- if (hHint != SWT.DEFAULT) size.y = hHint;
- 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);
-}
-public Rectangle computeTrim (int x, int y, int width, int height) {
- checkWidget();
- 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.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'.
+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.MouseHover, listener);
+ addListener (SWT.Paint, listener);
+ addListener (SWT.Resize, listener);
+ addListener (SWT.Traverse, listener);
+ addListener (SWT.KeyDown, listener);
+ addListener (SWT.FocusIn, listener);
+ addListener (SWT.FocusOut, listener);
+}
+/**
+ * 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.
+ * <p>
+ * When <code>widgetSelected</code> is called, the item field of the event object is valid.
+ * <code>widgetDefaultSelected</code> is not called.
+ * </p>
+ *
+ * @param listener the listener which should be notified
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see SelectionListener
+ * @see #removeSelectionListener
+ * @see SelectionEvent
*/
-void createChild (TabItem item, int index) {
- boolean isTabScrolling = isTabScrolling();
-
- if (!(0 <= index && index <= getItemCount ())) error (SWT.ERROR_INVALID_RANGE);
- item.parent = this;
-
- // 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
- setSelection(0, true);
- }
-}
-/**
- * Destroy the specified item.
+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) {
+ /*
+ * 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 = CLIENT_MARGIN_WIDTH * 2 + TabItem.SHADOW_WIDTH * 2;
+ int height = 0;
+
+ if (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 (wHint, hHint, changed);
+ }
+ if (size.x == 0) size.x = DEFAULT_WIDTH;
+ if (size.y == 0) size.y = DEFAULT_HEIGHT;
+ if (wHint != SWT.DEFAULT) size.x = wHint;
+ if (hHint != SWT.DEFAULT) size.y = hHint;
+ 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);
+}
+public Rectangle computeTrim (int x, int y, int width, int height) {
+ checkWidget();
+ 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.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 destroyChild (TabItem item) {
- int index = indexOf(item);
- if (index == -1) return; // should trigger an error?
- if (items.length == 1) {
- items = new TabItem [0];
- selectedIndex = -1;
- topTabIndex = 0;
- if (!inDispose){
- Control control = item.control;
- 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.control;
- if (control != null && !control.isDisposed()) {
- control.setVisible(false);
- }
- selectedIndex = -1;
- setSelection(Math.max(0, index - 1), true);
- }
- } 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 createChild (TabItem item, int index) {
+ boolean isTabScrolling = isTabScrolling();
+
+ if (!(0 <= index && index <= getItemCount ())) error (SWT.ERROR_INVALID_RANGE);
+ item.parent = this;
+
+ // 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
+ setSelection(0, true);
+ }
+}
+/**
+ * Destroy the specified item.
*/
-void doDispose() {
- inDispose = true;
- // items array is resized during TabItem.dispose
- // it is length 0 if the last item is removed
- while (items.length > 0) {
- 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 destroyChild (TabItem item) {
+ int index = indexOf(item);
+ if (index == -1) return; // should trigger an error?
+ if (items.length == 1) {
+ items = new TabItem [0];
+ selectedIndex = -1;
+ topTabIndex = 0;
+ if (!inDispose){
+ Control control = item.control;
+ 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.control;
+ if (control != null && !control.isDisposed()) {
+ control.setVisible(false);
+ }
+ selectedIndex = -1;
+ setSelection(Math.max(0, index - 1), true);
+ }
+ } 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 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 doDispose() {
+ inDispose = true;
+ // items array is resized during TabItem.dispose
+ // it is length 0 if the last item is removed
+ while (items.length > 0) {
+ 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 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 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 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 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 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 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 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 (tabIndex < 0 || tabIndex >= items.length) return;
- if (!isTabScrolling()) return;
- if (tabIndex < topTabIndex) {
- topTabIndex = tabIndex;
- layoutItems();
- redrawTabs();
- return;
- }
- int rightEdge = getScrollButtonArea().x;
- TabItem tabItem = items[tabIndex];
- while (tabItem.x + tabItem.width > rightEdge && tabIndex != topTabIndex) {
- topTabIndex++;
- layoutItems();
- redrawTabs();
- }
-}
-void focus (Event e) {
- if (selectedIndex == -1) return;
- TabItem tab = items[selectedIndex];
- redraw(tab.x, tab.y, tab.width, tab.height);
-}
-
-public Rectangle getClientArea() {
- checkWidget();
- 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.
+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.
*/
-int getImageHeight() {
- return imageHeight;
-}
-/**
- * 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>
+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.
*/
-public TabItem getItem (int index) {
- checkWidget();
- if (!(0 <= index && index < getItemCount())) 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>
+void ensureVisible(int tabIndex) {
+ if (tabIndex < 0 || tabIndex >= items.length) return;
+ if (!isTabScrolling()) return;
+ if (tabIndex < topTabIndex) {
+ topTabIndex = tabIndex;
+ layoutItems();
+ redrawTabs();
+ return;
+ }
+ int rightEdge = getScrollButtonArea().x;
+ TabItem tabItem = items[tabIndex];
+ while (tabItem.x + tabItem.width > rightEdge && tabIndex != topTabIndex) {
+ topTabIndex++;
+ layoutItems();
+ redrawTabs();
+ }
+}
+void focus (Event e) {
+ if (selectedIndex == -1) return;
+ TabItem tab = items[selectedIndex];
+ redraw(tab.x, tab.y, tab.width, tab.height);
+}
+
+public Rectangle getClientArea() {
+ checkWidget();
+ 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.
*/
-public int getItemCount(){
- checkWidget();
- return items.length;
-}
-/**
- * Returns an array of <code>TabItem</code>s which are the items
- * in the receiver.
- * <p>
- * Note: This is not the actual structure used by the receiver
- * to maintain its list of items, so modifying the array will
- * not affect the receiver.
- * </p>
- *
- * @return the items in the receiver
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
+int getImageHeight() {
+ return imageHeight;
+}
+/**
+ * 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 [] getItems() {
- checkWidget();
- TabItem[] tabItems = new TabItem [items.length];
- System.arraycopy(items, 0, tabItems, 0, items.length);
- return tabItems;
-}
-/**
- * Returns the area where the two scroll buttons are drawn.
+public TabItem getItem (int index) {
+ checkWidget();
+ if (!(0 <= index && index < getItemCount())) 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>
*/
-Rectangle getScrollButtonArea() {
- return new Rectangle(
- super.getClientArea().width - SCROLL_BUTTON_SIZE * 2, SELECTED_TAB_TOP_EXPANSION,
- SCROLL_BUTTON_SIZE * 2, SCROLL_BUTTON_SIZE);
-}
-/**
- * Returns an array of <code>TabItem</code>s that are currently
- * selected in the receiver. An empty array indicates that no
- * items are selected.
- * <p>
- * Note: This is not the actual structure used by the receiver
- * to maintain its selection, so modifying the array will
- * not affect the receiver.
- * </p>
- * @return an array representing the selection
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
+public int getItemCount(){
+ checkWidget();
+ return items.length;
+}
+/**
+ * Returns an array of <code>TabItem</code>s which are the items
+ * in the receiver.
+ * <p>
+ * Note: This is not the actual structure used by the receiver
+ * to maintain its list of items, so modifying the array will
+ * not affect the receiver.
+ * </p>
+ *
+ * @return the items in the receiver
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
*/
-public TabItem [] getSelection() {
- checkWidget();
- if (selectedIndex == -1) return new TabItem [0];
- return new TabItem [] {items[selectedIndex]};
-}
-/**
- * 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 TabItem [] getItems() {
+ checkWidget();
+ TabItem[] tabItems = new TabItem [items.length];
+ System.arraycopy(items, 0, tabItems, 0, items.length);
+ return tabItems;
+}
+/**
+ * Returns the area where the two scroll buttons are drawn.
*/
-public int getSelectionIndex() {
- checkWidget();
- return selectedIndex;
-}
-public String getToolTipText () {
- checkWidget();
- return toolTipText;
-}
-/**
- * Handle the events that I have hooked on the canvas.
+Rectangle getScrollButtonArea() {
+ return new Rectangle(
+ super.getClientArea().width - SCROLL_BUTTON_SIZE * 2, SELECTED_TAB_TOP_EXPANSION,
+ SCROLL_BUTTON_SIZE * 2, SCROLL_BUTTON_SIZE);
+}
+/**
+ * Returns an array of <code>TabItem</code>s that are currently
+ * selected in the receiver. An empty array indicates that no
+ * items are selected.
+ * <p>
+ * Note: This is not the actual structure used by the receiver
+ * to maintain its selection, so modifying the array will
+ * not affect the receiver.
+ * </p>
+ * @return an array representing the selection
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
*/
-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;
- case SWT.MouseHover:
- mouseHover(event);
- break;
- case SWT.Traverse:
- traversal(event);
- break;
- case SWT.FocusIn:
- case SWT.FocusOut:
- focus(event);
- break;
- case SWT.KeyDown:
- //do nothing - this callback exists so that widget is included in tab order
- break;
- default:
- break;
- }
-}
-/**
- * Searches the receiver's list starting at the first item
- * (index 0) until an item is found that is equal to the
- * argument, and returns the index of that item. If no item
- * is found, returns -1.
- *
- * @param 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 TabItem [] getSelection() {
+ checkWidget();
+ if (selectedIndex == -1) return new TabItem [0];
+ return new TabItem [] {items[selectedIndex]};
+}
+/**
+ * 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 indexOf(TabItem item) {
- checkWidget();
- if (item == null) {
- error(SWT.ERROR_NULL_ARGUMENT);
- }
- 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.
+public int getSelectionIndex() {
+ checkWidget();
+ return selectedIndex;
+}
+public String getToolTipText () {
+ checkWidget();
+ return toolTipText;
+}
+/**
+ * Handle the events that I have hooked on the canvas.
*/
-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.
+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;
+ case SWT.MouseHover:
+ mouseHover(event);
+ break;
+ case SWT.Traverse:
+ traversal(event);
+ break;
+ case SWT.FocusIn:
+ case SWT.FocusOut:
+ focus(event);
+ break;
+ case SWT.KeyDown:
+ //do nothing - this callback exists so that widget is included in tab order
+ break;
+ default:
+ break;
+ }
+}
+/**
+ * Searches the receiver's list starting at the first item
+ * (index 0) until an item is found that is equal to the
+ * argument, and returns the index of that item. If no item
+ * is found, returns -1.
+ *
+ * @param 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>
*/
-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.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.
+public int indexOf(TabItem item) {
+ checkWidget();
+ if (item == null) {
+ error(SWT.ERROR_NULL_ARGUMENT);
+ }
+ 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.
*/
-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.
+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.
*/
-void layoutItems() {
- int x = SELECTED_TAB_HORIZONTAL_EXPANSION;
- int y = SELECTED_TAB_TOP_EXPANSION;
- int tabHeight = 0;
-
- 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);
-}
-Point minimumSize (int wHint, int hHint, boolean flushCache) {
- Control [] children = _getChildren ();
- int width = 0, height = 0;
- for (int i=0; i<children.length; i++) {
- Control child = children [i];
- int index = 0;
- while (index < items.length) {
- if (items [index].control == child) break;
- index++;
- }
- if (index == items.length) {
- Rectangle rect = child.getBounds ();
- width = Math.max (width, rect.x + rect.width);
- height = Math.max (height, rect.y + rect.height);
- } else {
- Point size = child.computeSize (wHint, hHint, flushCache);
- width = Math.max (width, size.x);
- height = Math.max (height, size.y);
- }
- }
- return new Point (width, height);
-}
-/**
- * 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.
+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.
*/
-void mouseDown(Event event) {
- 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))) {
- forceFocus();
- setSelection(i, true);
- return;
- }
- }
- }
-}
-void mouseHover(Event event) {
- String current = super.getToolTipText();
- if (toolTipText == null) {
- Point point = new Point(event.x, event.y);
- for (int i=0; i<items.length; i++) {
- if (items[i].getBounds().contains(point)) {
- String string = items[i].getToolTipText();
- if (string != null && !string.equals(current)) {
- super.setToolTipText(string);
- }
- return;
- }
- }
- if (current != null) super.setToolTipText(null);
- return;
- }
- if (!toolTipText.equals(current)) {
- super.setToolTipText(toolTipText);
- }
-}
-/**
- * A mouse button was released.
+boolean isTabScrolling() {
+ boolean isVisible = false;
+
+ if (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 mouseUp(Event event) {
- if (scrollButtonDown && event.button == 1) {
- scrollButtonDown = false;
- redrawHitButton(event);
- }
-}
-/**
- * Paint the receiver.
+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 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 layoutItems() {
+ int x = SELECTED_TAB_HORIZONTAL_EXPANSION;
+ int y = SELECTED_TAB_TOP_EXPANSION;
+ int tabHeight = 0;
+
+ 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);
+}
+Point minimumSize (int wHint, int hHint, boolean flushCache) {
+ Control [] children = _getChildren ();
+ int width = 0, height = 0;
+ for (int i=0; i<children.length; i++) {
+ Control child = children [i];
+ int index = 0;
+ while (index < items.length) {
+ if (items [index].control == child) break;
+ index++;
+ }
+ if (index == items.length) {
+ Rectangle rect = child.getBounds ();
+ width = Math.max (width, rect.x + rect.width);
+ height = Math.max (height, rect.y + rect.height);
+ } else {
+ Point size = child.computeSize (wHint, hHint, flushCache);
+ width = Math.max (width, size.x);
+ height = Math.max (height, size.y);
+ }
+ }
+ return new Point (width, height);
+}
+/**
+ * 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 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 mouseDown(Event event) {
+ 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))) {
+ forceFocus();
+ setSelection(i, true);
+ return;
+ }
+ }
+ }
+}
+void mouseHover(Event event) {
+ String current = super.getToolTipText();
+ if (toolTipText == null) {
+ Point point = new Point(event.x, event.y);
+ for (int i=0; i<items.length; i++) {
+ if (items[i].getBounds().contains(point)) {
+ String string = items[i].getToolTipText();
+ if (string != null && !string.equals(current)) {
+ super.setToolTipText(string);
+ }
+ return;
+ }
+ }
+ if (current != null) super.setToolTipText(null);
+ return;
+ }
+ if (!toolTipText.equals(current)) {
+ super.setToolTipText(toolTipText);
+ }
+}
+/**
+ * A mouse button was released.
*/
-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 mouseUp(Event event) {
+ if (scrollButtonDown && event.button == 1) {
+ scrollButtonDown = false;
+ redrawHitButton(event);
+ }
+}
+/**
+ * Paint the receiver.
*/
-void redrawScrollButtons() {
- Rectangle scrollButtonArea = getScrollButtonArea();
-
- redraw(
- scrollButtonArea.x, scrollButtonArea.y,
- scrollButtonArea.width, scrollButtonArea.height, false);
-}
-/**
- * Redraw the tabs at the specified indexes.
+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 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 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 redrawTabs() {
- redraw(0, 0, super.getClientArea().width, getClientArea().y);
-}
-/**
- * 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
+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
*/
-public void removeSelectionListener(SelectionListener listener) {
- checkWidget();
- 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 redrawScrollButtons() {
+ Rectangle scrollButtonArea = getScrollButtonArea();
+
+ redraw(
+ scrollButtonArea.x, scrollButtonArea.y,
+ scrollButtonArea.width, scrollButtonArea.height, false);
+}
+/**
+ * Redraw the tabs at the specified indexes.
*/
-void scrollLeft() {
- if (topTabIndex > 0) {
- --topTabIndex;
- layoutItems();
- redrawTabs();
- }
-}
-/**
- * Scroll the tab items to the right.
+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 scrollRight() {
- if (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();
- }
- }
-}
-public void setFont(Font font) {
- checkWidget();
- if (font != null && font.equals(getFont())) return;
- super.setFont(font);
- layoutItems();
- redrawTabs();
-}
-/**
- * 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>
+void redrawTabs() {
+ redraw(0, 0, super.getClientArea().width, getClientArea().y);
+}
+/**
+ * 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 setSelection(int index) {
- checkWidget();
- setSelection(index, false);
-}
-/**
- * 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 removeSelectionListener(SelectionListener listener) {
+ checkWidget();
+ 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.
*/
-public void setSelection(TabItem selectedItems[]) {
- checkWidget();
- if (selectedItems == null) error(SWT.ERROR_NULL_ARGUMENT);
- int index = -1;
- if (selectedItems.length > 0) {
- index = indexOf(selectedItems[0]);
- }
- setSelection(index, false);
-}
-/**
- * Set the selection to the tab at the specified index.
+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 setSelection(int index, boolean notify) {
-
- 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);
- }
- }
-
- if (notify) {
- if (selectedIndex != oldIndex && selectedIndex != -1) {
- Event event = new Event();
- event.item = getSelection()[0];
- notifyListeners(SWT.Selection, event);
- }
- }
-}
-public void setToolTipText (String string) {
- checkWidget();
- super.setToolTipText (string);
- toolTipText = string;
-}
-void traversal(Event event) {
- switch (event.detail) {
- case SWT.TRAVERSE_ESCAPE:
- case SWT.TRAVERSE_RETURN:
- case SWT.TRAVERSE_TAB_NEXT:
- case SWT.TRAVERSE_TAB_PREVIOUS:
- event.doit = true;
- break;
- case SWT.TRAVERSE_MNEMONIC:
- event.doit = mnemonicTraversal(event);
- if (event.doit) event.detail = SWT.TRAVERSE_NONE;
- break;
- case SWT.TRAVERSE_PAGE_NEXT:
- case SWT.TRAVERSE_PAGE_PREVIOUS:
- event.doit = pageTraversal(event);
- if (event.doit) event.detail = SWT.TRAVERSE_NONE;
- break;
- case SWT.TRAVERSE_ARROW_NEXT:
- if (selectedIndex < items.length - 1) {
- setSelection(selectedIndex + 1, true);
- }
- event.doit = true;
- event.detail = SWT.TRAVERSE_NONE;
- break;
- case SWT.TRAVERSE_ARROW_PREVIOUS:
- if (selectedIndex > 0) {
- setSelection(selectedIndex - 1, true);
- }
- event.doit = true;
- event.detail = SWT.TRAVERSE_NONE;
- break;
- }
-}
-
-boolean pageTraversal(Event event) {
- int count = getItemCount ();
- if (count == 0) return false;
- int index = getSelectionIndex ();
- if (index == -1) {
- index = 0;
- } else {
- int offset = (event.detail == SWT.TRAVERSE_PAGE_NEXT) ? 1 : -1;
- index = (index + offset + count) % count;
- }
- setSelection (index, true);
- return true;
-}
-
-boolean mnemonicTraversal (Event event) {
- char key = event.character;
- for (int i = 0; i < items.length; i++) {
- if (items[i] != null) {
- char mnemonic = getMnemonic (items[i].getText ());
- if (mnemonic != '\0') {
- if (Character.toUpperCase (key) == Character.toUpperCase (mnemonic)) {
- setSelection(i, true);
- return true;
- }
- }
- }
- }
- return false;
-}
-char getMnemonic (String string) {
- int index = 0;
- int length = string.length ();
- do {
- while ((index < length) && (string.charAt (index) != '&')) index++;
- if (++index >= length) return '\0';
- if (string.charAt (index) != '&') return string.charAt (index);
- index++;
- } while (index < length);
- return '\0';
-}
-}
+void scrollLeft() {
+ if (topTabIndex > 0) {
+ --topTabIndex;
+ layoutItems();
+ redrawTabs();
+ }
+}
+/**
+ * Scroll the tab items to the right.
+ */
+void scrollRight() {
+ if (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();
+ }
+ }
+}
+public void setFont(Font font) {
+ checkWidget();
+ if (font != null && font.equals(getFont())) return;
+ super.setFont(font);
+ layoutItems();
+ redrawTabs();
+}
+/**
+ * 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();
+ setSelection(index, false);
+}
+/**
+ * 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 selectedItems[]) {
+ checkWidget();
+ if (selectedItems == null) error(SWT.ERROR_NULL_ARGUMENT);
+ int index = -1;
+ if (selectedItems.length > 0) {
+ index = indexOf(selectedItems[0]);
+ }
+ setSelection(index, false);
+}
+/**
+ * Set the selection to the tab at the specified index.
+ */
+void setSelection(int index, boolean notify) {
+
+ 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);
+ }
+ }
+
+ if (notify) {
+ if (selectedIndex != oldIndex && selectedIndex != -1) {
+ Event event = new Event();
+ event.item = getSelection()[0];
+ notifyListeners(SWT.Selection, event);
+ }
+ }
+}
+public void setToolTipText (String string) {
+ checkWidget();
+ super.setToolTipText (string);
+ toolTipText = string;
+}
+void traversal(Event event) {
+ switch (event.detail) {
+ case SWT.TRAVERSE_ESCAPE:
+ case SWT.TRAVERSE_RETURN:
+ case SWT.TRAVERSE_TAB_NEXT:
+ case SWT.TRAVERSE_TAB_PREVIOUS:
+ event.doit = true;
+ break;
+ case SWT.TRAVERSE_MNEMONIC:
+ event.doit = mnemonicTraversal(event);
+ if (event.doit) event.detail = SWT.TRAVERSE_NONE;
+ break;
+ case SWT.TRAVERSE_PAGE_NEXT:
+ case SWT.TRAVERSE_PAGE_PREVIOUS:
+ event.doit = pageTraversal(event);
+ if (event.doit) event.detail = SWT.TRAVERSE_NONE;
+ break;
+ case SWT.TRAVERSE_ARROW_NEXT:
+ if (selectedIndex < items.length - 1) {
+ setSelection(selectedIndex + 1, true);
+ }
+ event.doit = true;
+ event.detail = SWT.TRAVERSE_NONE;
+ break;
+ case SWT.TRAVERSE_ARROW_PREVIOUS:
+ if (selectedIndex > 0) {
+ setSelection(selectedIndex - 1, true);
+ }
+ event.doit = true;
+ event.detail = SWT.TRAVERSE_NONE;
+ break;
+ }
+}
+
+boolean pageTraversal(Event event) {
+ int count = getItemCount ();
+ if (count == 0) return false;
+ int index = getSelectionIndex ();
+ if (index == -1) {
+ index = 0;
+ } else {
+ int offset = (event.detail == SWT.TRAVERSE_PAGE_NEXT) ? 1 : -1;
+ index = (index + offset + count) % count;
+ }
+ setSelection (index, true);
+ return true;
+}
+
+boolean mnemonicTraversal (Event event) {
+ char key = event.character;
+ for (int i = 0; i < items.length; i++) {
+ if (items[i] != null) {
+ char mnemonic = getMnemonic (items[i].getText ());
+ if (mnemonic != '\0') {
+ if (Character.toUpperCase (key) == Character.toUpperCase (mnemonic)) {
+ setSelection(i, true);
+ return true;
+ }
+ }
+ }
+ }
+ return false;
+}
+char getMnemonic (String string) {
+ int index = 0;
+ int length = string.length ();
+ do {
+ while ((index < length) && (string.charAt (index) != '&')) index++;
+ if (++index >= length) return '\0';
+ if (string.charAt (index) != '&') return string.charAt (index);
+ index++;
+ } while (index < length);
+ return '\0';
+}
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/emulated/tabfolder/org/eclipse/swt/widgets/TabItem.java b/bundles/org.eclipse.swt/Eclipse SWT/emulated/tabfolder/org/eclipse/swt/widgets/TabItem.java
index cbd2ad0053..a4fd023f1d 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/emulated/tabfolder/org/eclipse/swt/widgets/TabItem.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/emulated/tabfolder/org/eclipse/swt/widgets/TabItem.java
@@ -1,408 +1,408 @@
-package org.eclipse.swt.widgets;
-
-/*
+package org.eclipse.swt.widgets;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-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>
+ * http://www.eclipse.org/legal/cpl-v10.html
*/
-public 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
-/**
- * Constructs a new instance of this class given its parent
- * (which must be a <code>TabFolder</code>) and a style value
- * describing its behavior and appearance. The item is added
- * to the end of the items maintained by its parent.
- * <p>
- * The style value is either one of the style constants defined in
- * class <code>SWT</code> which is applicable to instances of this
- * class, or must be built by <em>bitwise OR</em>'ing together
- * (that is, using the <code>int</code> "|" operator) two or more
- * of those <code>SWT</code> style constants. The class description
- * lists the style constants that are applicable to the class.
- * Style bits are also inherited from superclasses.
- * </p>
- *
- * @param parent a composite control which will be the parent of the new instance (cannot be null)
- * @param style the style of control to construct
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
- * <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
- * </ul>
- *
- * @see SWT
- * @see Widget#checkSubclass
- * @see Widget#getStyle
+
+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 TabItem (TabFolder parent, int style) {
- this(parent, style, parent.getItemCount());
-}
-
-/**
- * Constructs a new instance of this class given its parent
- * (which must be a <code>TabFolder</code>), a style value
- * describing its behavior and appearance, and the index
- * at which to place it in the items maintained by its parent.
- * <p>
- * The style value is either one of the style constants defined in
- * class <code>SWT</code> which is applicable to instances of this
- * class, or must be built by <em>bitwise OR</em>'ing together
- * (that is, using the <code>int</code> "|" operator) two or more
- * of those <code>SWT</code> style constants. The class description
- * lists the style constants that are applicable to the class.
- * Style bits are also inherited from superclasses.
- * </p>
- *
- * @param parent a composite control which will be the parent of the new instance (cannot be null)
- * @param style the style of control to construct
- * @param index the 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 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
+/**
+ * Constructs a new instance of this class given its parent
+ * (which must be a <code>TabFolder</code>) and a style value
+ * describing its behavior and appearance. The item is added
+ * to the end of the items maintained by its parent.
+ * <p>
+ * The style value is either one of the style constants defined in
+ * class <code>SWT</code> which is applicable to instances of this
+ * class, or must be built by <em>bitwise OR</em>'ing together
+ * (that is, using the <code>int</code> "|" operator) two or more
+ * of those <code>SWT</code> style constants. The class description
+ * lists the style constants that are applicable to the class.
+ * Style bits are also inherited from superclasses.
+ * </p>
+ *
+ * @param parent a composite control which will be the parent of the new instance (cannot be null)
+ * @param style the style of control to construct
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
+ * <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
+ * </ul>
+ *
+ * @see SWT
+ * @see Widget#checkSubclass
+ * @see Widget#getStyle
*/
-public TabItem (TabFolder parent, int style, int index) {
- super (parent, style);
- parent.createChild (this, index);
-}
-
-protected void checkSubclass () {
- if (!isValidSubclass ()) error (SWT.ERROR_INVALID_SUBCLASS);
-}
-
-public void dispose() {
- if (isDisposed()) return;
- super.dispose();
- 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.
+public TabItem (TabFolder parent, int style) {
+ this(parent, style, parent.getItemCount());
+}
+
+/**
+ * Constructs a new instance of this class given its parent
+ * (which must be a <code>TabFolder</code>), a style value
+ * describing its behavior and appearance, and the index
+ * at which to place it in the items maintained by its parent.
+ * <p>
+ * The style value is either one of the style constants defined in
+ * class <code>SWT</code> which is applicable to instances of this
+ * class, or must be built by <em>bitwise OR</em>'ing together
+ * (that is, using the <code>int</code> "|" operator) two or more
+ * of those <code>SWT</code> style constants. The class description
+ * lists the style constants that are applicable to the class.
+ * Style bits are also inherited from superclasses.
+ * </p>
+ *
+ * @param parent a composite control which will be the parent of the new instance (cannot be null)
+ * @param style the style of control to construct
+ * @param index the 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
*/
-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.
+public TabItem (TabFolder parent, int style, int index) {
+ super (parent, style);
+ parent.createChild (this, index);
+}
+
+protected void checkSubclass () {
+ if (!isValidSubclass ()) error (SWT.ERROR_INVALID_SUBCLASS);
+}
+
+public void dispose() {
+ if (isDisposed()) return;
+ super.dispose();
+ 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.
*/
-Rectangle getBounds () {
- return new Rectangle(x, y, width, height);
-}
-/**
- * Returns the control that is used to fill the client area of
- * the tab folder when the user selects the tab item. If no
- * control has been set, return <code>null</code>.
- * <p>
- * @return the control
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
+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.
*/
-public Control getControl () {
- checkWidget();
- return control;
-}
-public Display getDisplay() {
- 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>
+Rectangle getBounds () {
+ return new Rectangle(x, y, width, height);
+}
+/**
+ * Returns the control that is used to fill the client area of
+ * the tab folder when the user selects the tab item. If no
+ * control has been set, return <code>null</code>.
+ * <p>
+ * @return the control
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
*/
-public 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 Control getControl () {
+ checkWidget();
+ return control;
+}
+public Display getDisplay() {
+ 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 String getToolTipText () {
- checkWidget();
- return toolTipText;
-}
-/**
- * Answer true if the receiver has been layed out.
+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>
*/
-boolean hasLocation() {
- return !(width == 0 && height == 0 && x == 0 && y == 0);
-}
-/**
- * Answer the image height.
+public String getToolTipText () {
+ checkWidget();
+ return toolTipText;
+}
+/**
+ * Answer true if the receiver has been layed out.
*/
-private int imageHeight() {
- Image image = getImage();
-
- if (parent.getImageHeight() != -1) {
- return parent.getImageHeight();
- } else if (image != null && !image.isDisposed()) {
- return image.getBounds().height;
- }
- else {
- return 0;
- }
-}
-/**
- * Answer the icon width.
+boolean hasLocation() {
+ return !(width == 0 && height == 0 && x == 0 && y == 0);
+}
+/**
+ * Answer the image height.
*/
-private int imageWidth() {
- Image image = getImage();
-
- if (image != null && !image.isDisposed()) {
- return image.getBounds().width;
- } else {
- return 0;
- }
-}
-/**
- * Paint the receiver.
+private int imageHeight() {
+ Image image = getImage();
+
+ if (parent.getImageHeight() != -1) {
+ return parent.getImageHeight();
+ } else if (image != null && !image.isDisposed()) {
+ return image.getBounds().height;
+ }
+ else {
+ return 0;
+ }
+}
+/**
+ * Answer the icon width.
*/
-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);
-
- if (parent.isFocusControl() && isSelected) {
- // draw a focus rectangle
- gc.drawFocus(x + 3, y + 3, width - 6, height - 3);
- }
-
- // 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;
- int flags = SWT.DRAW_MNEMONIC;
- gc.drawText(getText(), xDraw, yCenter, flags);
-}
-/**
- * Answer the preferred height of the receiver for the GC.
+private int imageWidth() {
+ Image image = getImage();
+
+ if (image != null && !image.isDisposed()) {
+ return image.getBounds().width;
+ } else {
+ return 0;
+ }
+}
+/**
+ * Paint the receiver.
*/
-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.
+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);
+
+ if (parent.isFocusControl() && isSelected) {
+ // draw a focus rectangle
+ gc.drawFocus(x + 3, y + 3, width - 6, height - 3);
+ }
+
+ // 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;
+ int flags = SWT.DRAW_MNEMONIC;
+ gc.drawText(getText(), xDraw, yCenter, flags);
+}
+/**
+ * Answer the preferred height 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 that is used to fill the client area of
- * the tab folder when the user selects the tab item.
- * <p>
- * @param control the new control (or null)
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_INVALID_ARGUMENT - if the control has been disposed</li>
- * <li>ERROR_INVALID_PARENT - if the control is not in the same widget tree</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
+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.
*/
-public void setControl (Control control) {
- checkWidget();
- if (control != null) {
- if (control.isDisposed()) error (SWT.ERROR_INVALID_ARGUMENT);
- if (control.parent != parent) error (SWT.ERROR_INVALID_PARENT);
- }
- if (this.control != null && this.control.isDisposed ()) {
- this.control = null;
- }
- 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();
- Image oldImage = this.image;
-
- super.setImage(image);
- if (image == null || !image.equals(oldImage)) {
- parent.itemChanged(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>
+int preferredWidth(GC gc) {
+ return imageWidth() + textWidth(gc) + LEFT_HORIZONTAL_MARGIN +
+ RIGHT_HORIZONTAL_MARGIN + ICON_MARGIN + SHADOW_WIDTH * 2;
+}
+/**
+ * Sets the control that is used to fill the client area of
+ * the tab folder when the user selects the tab item.
+ * <p>
+ * @param control the new control (or null)
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_INVALID_ARGUMENT - if the control has been disposed</li>
+ * <li>ERROR_INVALID_PARENT - if the control is not in the same widget tree</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
*/
-public void setText (String string) {
- checkWidget();
- String oldText = text;
-
- if (string == null) error (SWT.ERROR_NULL_ARGUMENT);
- super.setText(string);
- if (!string.equals(oldText)) {
- parent.itemChanged(this);
- }
-}
-/**
- * Sets the receiver's tool tip text to the argument, which
- * may be null indicating that no tool tip text should be shown.
- *
- * @param 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 setControl (Control control) {
+ checkWidget();
+ if (control != null) {
+ if (control.isDisposed()) error (SWT.ERROR_INVALID_ARGUMENT);
+ if (control.parent != parent) error (SWT.ERROR_INVALID_PARENT);
+ }
+ if (this.control != null && this.control.isDisposed ()) {
+ this.control = null;
+ }
+ 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();
+ Image oldImage = this.image;
+
+ super.setImage(image);
+ if (image == null || !image.equals(oldImage)) {
+ parent.itemChanged(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 setToolTipText (String string) {
- checkWidget();
- toolTipText = string;
-}
-/**
- * Answer the text height.
+public void setText (String string) {
+ checkWidget();
+ String oldText = text;
+
+ if (string == null) error (SWT.ERROR_NULL_ARGUMENT);
+ super.setText(string);
+ if (!string.equals(oldText)) {
+ parent.itemChanged(this);
+ }
+}
+/**
+ * Sets the receiver's tool tip text to the argument, which
+ * may be null indicating that no tool tip text should be shown.
+ *
+ * @param 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>
*/
-private int textHeight(GC gc) {
- String text = getText();
-
- if (text == null) {
- return 0;
- } else {
- int flags = SWT.DRAW_MNEMONIC;
- return gc.textExtent(text, flags).y;
- }
-}
-/**
- * Answer the text width.
+public void setToolTipText (String string) {
+ checkWidget();
+ toolTipText = string;
+}
+/**
+ * Answer the text height.
*/
-private int textWidth(GC gc) {
- String text = getText();
- int textWidth = 0;
-
- if (text != null) {
- int flags = SWT.DRAW_MNEMONIC;
- textWidth = gc.textExtent(text, flags).x;
- }
- if (textWidth == 0) {
- textWidth = DEFAULT_TEXT_WIDTH;
- }
- return textWidth;
-}
-}
+private int textHeight(GC gc) {
+ String text = getText();
+
+ if (text == null) {
+ return 0;
+ } else {
+ int flags = SWT.DRAW_MNEMONIC;
+ return gc.textExtent(text, flags).y;
+ }
+}
+/**
+ * Answer the text width.
+ */
+private int textWidth(GC gc) {
+ String text = getText();
+ int textWidth = 0;
+
+ if (text != null) {
+ int flags = SWT.DRAW_MNEMONIC;
+ textWidth = gc.textExtent(text, flags).x;
+ }
+ if (textWidth == 0) {
+ textWidth = DEFAULT_TEXT_WIDTH;
+ }
+ return textWidth;
+}
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/emulated/treetable/org/eclipse/swt/widgets/AbstractTreeItem.java b/bundles/org.eclipse.swt/Eclipse SWT/emulated/treetable/org/eclipse/swt/widgets/AbstractTreeItem.java
index b48dde3da5..485a2afacd 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/emulated/treetable/org/eclipse/swt/widgets/AbstractTreeItem.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/emulated/treetable/org/eclipse/swt/widgets/AbstractTreeItem.java
@@ -1,313 +1,313 @@
-package org.eclipse.swt.widgets;
-
-/*
+package org.eclipse.swt.widgets;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-import org.eclipse.swt.*;
-import java.util.Enumeration;
-import java.util.Vector;
-
-/**
- * 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();
- }
-}
-public void dispose() {
- if (isDisposed()) return;
- Vector children = getChildren();
- AbstractTreeItem child;
- while (children.size() > 0) { // TreeItem objects are removed from vector during dispose
- child = (AbstractTreeItem) children.firstElement();
- child.dispose();
- }
- super.dispose();
-}
-void doDispose() {
- setChildren(null);
- visibleItemCount = 0;
- super.doDispose();
-}
-/**
- * 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() {
- checkWidget();
-
- return isExpanded;
-}
-/**
- * Answer the number of children.
- */
-public int getItemCount() {
- checkWidget();
-
- 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;
-}
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+import org.eclipse.swt.*;
+import java.util.Enumeration;
+import java.util.Vector;
+
+/**
+ * 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();
+ }
+}
+public void dispose() {
+ if (isDisposed()) return;
+ Vector children = getChildren();
+ AbstractTreeItem child;
+ while (children.size() > 0) { // TreeItem objects are removed from vector during dispose
+ child = (AbstractTreeItem) children.firstElement();
+ child.dispose();
+ }
+ super.dispose();
+}
+void doDispose() {
+ setChildren(null);
+ visibleItemCount = 0;
+ super.doDispose();
+}
+/**
+ * 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() {
+ checkWidget();
+
+ return isExpanded;
+}
+/**
+ * Answer the number of children.
+ */
+public int getItemCount() {
+ checkWidget();
+
+ 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/emulated/treetable/org/eclipse/swt/widgets/SelectableItem.java b/bundles/org.eclipse.swt/Eclipse SWT/emulated/treetable/org/eclipse/swt/widgets/SelectableItem.java
index 36c88ff9c4..b47e21db05 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/emulated/treetable/org/eclipse/swt/widgets/SelectableItem.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/emulated/treetable/org/eclipse/swt/widgets/SelectableItem.java
@@ -1,318 +1,318 @@
-package org.eclipse.swt.widgets;
-
-/*
+package org.eclipse.swt.widgets;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-import org.eclipse.swt.*;
-import org.eclipse.swt.graphics.*;
-
-/**
- * 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);
-}
-public void dispose() {
- if (isDisposed()) return;
- super.dispose();
- doDispose();
-}
-void doDispose() {
- 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() {
- checkWidget();
- 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 () {
- checkWidget();
- 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) {
- checkWidget();
- 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) {
- checkWidget();
- 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;
-}
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+import org.eclipse.swt.*;
+import org.eclipse.swt.graphics.*;
+
+/**
+ * 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);
+}
+public void dispose() {
+ if (isDisposed()) return;
+ super.dispose();
+ doDispose();
+}
+void doDispose() {
+ 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() {
+ checkWidget();
+ 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 () {
+ checkWidget();
+ 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) {
+ checkWidget();
+ 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) {
+ checkWidget();
+ 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/emulated/treetable/org/eclipse/swt/widgets/SelectableItemWidget.java b/bundles/org.eclipse.swt/Eclipse SWT/emulated/treetable/org/eclipse/swt/widgets/SelectableItemWidget.java
index d433e1e281..5e15179df7 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/emulated/treetable/org/eclipse/swt/widgets/SelectableItemWidget.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/emulated/treetable/org/eclipse/swt/widgets/SelectableItemWidget.java
@@ -1,2066 +1,2066 @@
-package org.eclipse.swt.widgets;
-
-/*
+package org.eclipse.swt.widgets;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-import org.eclipse.swt.*;
-import org.eclipse.swt.graphics.*;
-import org.eclipse.swt.internal.Compatibility;
-
-import java.util.Enumeration;
-import java.util.Vector;
-
-/**
- * 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) {
- checkWidget();
- int width = getContentWidth();
- int height = getItemCount() * getItemHeight();
- 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.MOD1 && isMultiSelect() == true) {
- setLastFocus(newFocus, true);
- }
- else
- if (keyMask == SWT.MOD2 && 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.MOD1 && isMultiSelect() == true) {
- setLastFocus(newFocus, true);
- }
- else
- if (keyMask == SWT.MOD2 && 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.MOD1 && isMultiSelect() == true) {
- setLastFocus(newFocus, true);
- }
- else
- if (keyMask == SWT.MOD2 && 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.MOD1 && isMultiSelect() == true) {
- setLastFocus(newFocus, true);
- }
- else
- if (keyMask == SWT.MOD2 && 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 (button != 1 && item.isSelected() == true) {
- // If the item is already selected, do not change the selection when using
- // button 2 or 3. These buttons may invoke drag and drop or open the
- // context menu for the current selection.
- return;
- }
- if (((eventStateMask & SWT.MOD1) != 0) &&
- ((eventStateMask & SWT.MOD2) != 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.MOD2) != 0) && (isMultiSelect() == true)) {
- shiftSelect(item, itemIndex);
- setCtrlSelection(false);
- }
- else
- if (((eventStateMask & SWT.MOD1) != 0) && (isMultiSelect() == true)) {
- toggleSelectionNotify(item);
- setCtrlSelection(true);
- }
- else
- if ((eventStateMask & (SWT.MOD3 | SWT.MOD4)) == 0) {
- // On MacOSX, holding the control key down while pressing button 1 brings up the context menu.
- // Do not change the selection in this case.
- 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.MOD1 && isMultiSelect() == true) {
- setLastFocus(newFocus, true);
- }
- else
- if (keyMask == SWT.MOD2 && 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.MOD1 && isMultiSelect() == true) {
- setLastFocus(newFocus, true);
- }
- else
- if (keyMask == SWT.MOD2 && 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();
- if (item == null) return;
- if (item.isCheckable() == true) doCheckItem(item);
- 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) {
- return;
- }
- if (keyMask == SWT.MOD1) {
- toggleSelectionNotify(item);
- }
- else
- if (((keyMask & SWT.MOD1) != 0) && ((keyMask & SWT.MOD2) != 0)) {
- deselectAllExcept(item);
- selectNotify(item);
- }
- else
- if (keyMask == SWT.MOD2) {
- 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() {
-
- 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 = Compatibility.ceil(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() {
- checkWidget();
- 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() {
- checkWidget();
- 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() {
-
- if (uncheckedImage == null) {
- uncheckedImage = new Image(getDisplay(), UncheckedImageData);
- }
- return uncheckedImage;
-}
-
-/**
- * Answer the image for the grayed eck box.
- */
-Image getGrayUncheckedImage() {
-
- 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;
- case SWT.Traverse:
- switch (event.detail) {
- case SWT.TRAVERSE_ESCAPE:
- case SWT.TRAVERSE_RETURN:
- case SWT.TRAVERSE_TAB_NEXT:
- case SWT.TRAVERSE_TAB_PREVIOUS:
- event.doit = true;
- break;
- }
- 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);
- addListener(SWT.Traverse, 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.MOD1) {
- 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.MOD1);
- }
- //forward the enter key pressed to defaultSelection listenters
- if(event.character == SWT.CR){
- Event forwardEvent = new Event();
- forwardEvent.item = getLastFocus();
- notifyListeners(SWT.DefaultSelection, forwardEvent);
- }
- 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 () {
- checkWidget();
- 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) {
- checkWidget();
- 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);
-}
-void scrollShowItem(int index) {
- int itemIndexFromTop = index - 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
- * @param asyncNotify
- * true=send the selection event asynchronously
- * false=send the selection event immediately
- */
-void selectNotify(final SelectableItem item, boolean asyncNotify) {
- if (isRemovingAll() == false) {
- if (item.isSelected() == false) {
- select(item);
- setLastSelection(item, true);
- update(); // looks better when event notification takes long to return
- }
- if (asyncNotify == false) {
- Event event = new Event();
- event.item = item;
- notifyListeners(SWT.Selection, event);
- }
- else {
- getDisplay().asyncExec(new Runnable() {
- public void run() {
- // Only send a selection event when the item has not been disposed.
- // Fixes 1GE6XQA
- if (item.isDisposed() == false) {
- Event event = new Event();
- event.item = item;
- notifyListeners(SWT.Selection, event);
- }
- }
- });
- }
- }
-}
-/**
- * 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) {
- selectNotify(item, false);
-}
-/**
- * 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) {
- checkWidget();
- 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) {
- checkWidget();
- 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) {
- if (selectionItems[i].isDisposed()) error(SWT.ERROR_INVALID_ARGUMENT);
- 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;
- }
- int index = getIndex (item);
- showSelectableItem(index);
-}
-/**
- * Make 'index' visible by scrolling it into the receiver's client
- * area if necessary.
- * @param index - the item index that should be made visible to the user.
- */
-void showSelectableItem(int index) {
- scrollShowItem(index);
- scrollShowItem(index); // 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() {
- checkWidget();
- 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);
- }
-}
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+import org.eclipse.swt.*;
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.internal.Compatibility;
+
+import java.util.Enumeration;
+import java.util.Vector;
+
+/**
+ * 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) {
+ checkWidget();
+ int width = getContentWidth();
+ int height = getItemCount() * getItemHeight();
+ 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.MOD1 && isMultiSelect() == true) {
+ setLastFocus(newFocus, true);
+ }
+ else
+ if (keyMask == SWT.MOD2 && 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.MOD1 && isMultiSelect() == true) {
+ setLastFocus(newFocus, true);
+ }
+ else
+ if (keyMask == SWT.MOD2 && 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.MOD1 && isMultiSelect() == true) {
+ setLastFocus(newFocus, true);
+ }
+ else
+ if (keyMask == SWT.MOD2 && 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.MOD1 && isMultiSelect() == true) {
+ setLastFocus(newFocus, true);
+ }
+ else
+ if (keyMask == SWT.MOD2 && 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 (button != 1 && item.isSelected() == true) {
+ // If the item is already selected, do not change the selection when using
+ // button 2 or 3. These buttons may invoke drag and drop or open the
+ // context menu for the current selection.
+ return;
+ }
+ if (((eventStateMask & SWT.MOD1) != 0) &&
+ ((eventStateMask & SWT.MOD2) != 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.MOD2) != 0) && (isMultiSelect() == true)) {
+ shiftSelect(item, itemIndex);
+ setCtrlSelection(false);
+ }
+ else
+ if (((eventStateMask & SWT.MOD1) != 0) && (isMultiSelect() == true)) {
+ toggleSelectionNotify(item);
+ setCtrlSelection(true);
+ }
+ else
+ if ((eventStateMask & (SWT.MOD3 | SWT.MOD4)) == 0) {
+ // On MacOSX, holding the control key down while pressing button 1 brings up the context menu.
+ // Do not change the selection in this case.
+ 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.MOD1 && isMultiSelect() == true) {
+ setLastFocus(newFocus, true);
+ }
+ else
+ if (keyMask == SWT.MOD2 && 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.MOD1 && isMultiSelect() == true) {
+ setLastFocus(newFocus, true);
+ }
+ else
+ if (keyMask == SWT.MOD2 && 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();
+ if (item == null) return;
+ if (item.isCheckable() == true) doCheckItem(item);
+ 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) {
+ return;
+ }
+ if (keyMask == SWT.MOD1) {
+ toggleSelectionNotify(item);
+ }
+ else
+ if (((keyMask & SWT.MOD1) != 0) && ((keyMask & SWT.MOD2) != 0)) {
+ deselectAllExcept(item);
+ selectNotify(item);
+ }
+ else
+ if (keyMask == SWT.MOD2) {
+ 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() {
+
+ 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 = Compatibility.ceil(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() {
+ checkWidget();
+ 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() {
+ checkWidget();
+ 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() {
+
+ if (uncheckedImage == null) {
+ uncheckedImage = new Image(getDisplay(), UncheckedImageData);
+ }
+ return uncheckedImage;
+}
+
+/**
+ * Answer the image for the grayed eck box.
+ */
+Image getGrayUncheckedImage() {
+
+ 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;
+ case SWT.Traverse:
+ switch (event.detail) {
+ case SWT.TRAVERSE_ESCAPE:
+ case SWT.TRAVERSE_RETURN:
+ case SWT.TRAVERSE_TAB_NEXT:
+ case SWT.TRAVERSE_TAB_PREVIOUS:
+ event.doit = true;
+ break;
+ }
+ 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);
+ addListener(SWT.Traverse, 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.MOD1) {
+ 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.MOD1);
+ }
+ //forward the enter key pressed to defaultSelection listenters
+ if(event.character == SWT.CR){
+ Event forwardEvent = new Event();
+ forwardEvent.item = getLastFocus();
+ notifyListeners(SWT.DefaultSelection, forwardEvent);
+ }
+ 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 () {
+ checkWidget();
+ 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) {
+ checkWidget();
+ 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);
+}
+void scrollShowItem(int index) {
+ int itemIndexFromTop = index - 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
+ * @param asyncNotify
+ * true=send the selection event asynchronously
+ * false=send the selection event immediately
+ */
+void selectNotify(final SelectableItem item, boolean asyncNotify) {
+ if (isRemovingAll() == false) {
+ if (item.isSelected() == false) {
+ select(item);
+ setLastSelection(item, true);
+ update(); // looks better when event notification takes long to return
+ }
+ if (asyncNotify == false) {
+ Event event = new Event();
+ event.item = item;
+ notifyListeners(SWT.Selection, event);
+ }
+ else {
+ getDisplay().asyncExec(new Runnable() {
+ public void run() {
+ // Only send a selection event when the item has not been disposed.
+ // Fixes 1GE6XQA
+ if (item.isDisposed() == false) {
+ Event event = new Event();
+ event.item = item;
+ notifyListeners(SWT.Selection, event);
+ }
+ }
+ });
+ }
+ }
+}
+/**
+ * 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) {
+ selectNotify(item, false);
+}
+/**
+ * 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) {
+ checkWidget();
+ 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) {
+ checkWidget();
+ 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) {
+ if (selectionItems[i].isDisposed()) error(SWT.ERROR_INVALID_ARGUMENT);
+ 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;
+ }
+ int index = getIndex (item);
+ showSelectableItem(index);
+}
+/**
+ * Make 'index' visible by scrolling it into the receiver's client
+ * area if necessary.
+ * @param index - the item index that should be made visible to the user.
+ */
+void showSelectableItem(int index) {
+ scrollShowItem(index);
+ scrollShowItem(index); // 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() {
+ checkWidget();
+ 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);
+ }
+}
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/emulated/treetable/org/eclipse/swt/widgets/Table.java b/bundles/org.eclipse.swt/Eclipse SWT/emulated/treetable/org/eclipse/swt/widgets/Table.java
index df5871f9fe..b51dc1faaa 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/emulated/treetable/org/eclipse/swt/widgets/Table.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/emulated/treetable/org/eclipse/swt/widgets/Table.java
@@ -1,2701 +1,2701 @@
-package org.eclipse.swt.widgets;
-
-/*
+package org.eclipse.swt.widgets;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-import org.eclipse.swt.events.*;
-import org.eclipse.swt.graphics.*;
-import org.eclipse.swt.*;
-import java.util.Enumeration;
-import java.util.Vector;
-
-/**
- * Instances of this class implement a selectable user interface
- * object that displays a list of images and strings and issue
- * notificiation when selected.
- * <p>
- * The item children that may be added to instances of this class
- * must be of type <code>TableItem</code>.
- * </p><p>
- * Note that although this class is a subclass of <code>Composite</code>,
- * it does not make sense to add <code>Control</code> children to it,
- * or set a layout on it.
- * </p><p>
- * <dl>
- * <dt><b>Styles:</b></dt>
- * <dd>SINGLE, MULTI, CHECK, FULL_SELECTION, HIDE_SELECTION</dd>
- * <dt><b>Events:</b></dt>
- * <dd>Selection, DefaultSelection</dd>
- * </dl>
- * <p>
- * Note: Only one of the styles SINGLE, and MULTI may be specified.
- * </p><p>
- * IMPORTANT: This class is <em>not</em> intended to be subclassed.
- * </p>
- */
-public 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 Vector items;
- private Vector columns;
- private boolean drawGridLines = false;
- 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; // width of the static String dots (see above)
- private int fontHeight; // font height, avoid use GC.stringExtend for each pain
-
-/**
- * Constructs a new instance of this class given its parent
- * and a style value describing its behavior and appearance.
- * <p>
- * The style value is either one of the style constants defined in
- * class <code>SWT</code> which is applicable to instances of this
- * class, or must be built by <em>bitwise OR</em>'ing together
- * (that is, using the <code>int</code> "|" operator) two or more
- * of those <code>SWT</code> style constants. The class description
- * lists the style constants that are applicable to the class.
- * Style bits are also inherited from superclasses.
- * </p>
- *
- * @param parent a composite control which will be the parent of the new instance (cannot be null)
- * @param style the style of control to construct
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
- * <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
- * </ul>
- *
- * @see SWT#SINGLE
- * @see SWT#MULTI
- * @see SWT#CHECK
- * @see SWT#FULL_SELECTION
- * @see SWT#HIDE_SELECTION
- * @see Widget#checkSubclass
- * @see Widget#getStyle
- */
-public Table(Composite parent, int style) {
- // use NO_REDRAW_RESIZE to avoid flashing during widget resize redraw
- super(parent, checkStyle(style| SWT.NO_REDRAW_RESIZE));
-}
-
-/**
- * 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 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.
- * <p>
- * When <code>widgetSelected</code> is called, the item field of the event object is valid.
- * If the reciever has <code>SWT.CHECK</code> style set and the check selection changes,
- * the event object detail field contains the value <code>SWT.CHECK</code>.
- * <code>widgetDefaultSelected</code> is typically called when an item is double-clicked.
- * The item field of the event object is valid for default selection, but the detail field is not used.
- * </p>
- *
- * @param listener the listener which should be notified
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see SelectionListener
- * @see #removeSelectionListener
- * @see SelectionEvent
- */
-public void addSelectionListener (SelectionListener listener) {
- checkWidget();
- if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
- TypedListener typedListener = new TypedListener(listener);
- addListener(SWT.Selection,typedListener);
- addListener(SWT.DefaultSelection,typedListener);
-}
-static int checkStyle (int style) {
- return checkBits (style, SWT.SINGLE, SWT.MULTI, 0, 0, 0, 0);
-}
-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) {
- getHeader().widthChange(columnIndex, widthChange);
- 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);
- }
- }
-}
-/**
- * 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;
- boolean isFullSelection = (getStyle () & SWT.FULL_SELECTION) != 0;
-
- if (isFocusControl () == false) {
- forceFocus ();
- }
- if (hitColumn != null) {
- itemIndex = (event.y - getHeaderHeight()) / itemHeight + getTopIndex();
- hitItem = (TableItem) getVisibleItem(itemIndex);
- if (hitItem != null &&
- (hitColumn.getIndex() == TableColumn.FIRST || isFullSelection)) {
- if (hitItem.isSelectionHit(event.x) == true) {
- columnDblClickEvent = new Event();
- columnDblClickEvent.item = hitItem;
- notifyListeners(SWT.DefaultSelection, columnDblClickEvent);
- }
- }
- }
-}
-/**
- * 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) {
- forceFocus ();
- }
- 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) {
- // only react to button one clicks. fixes bug 6770
- if (event.button != 1) {
- return;
- }
- doCheckItem(hitItem);
- }
- }
- }
-}
-/**
- * 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);
- }
-}
-public Point computeSize(int wHint, int hHint, boolean changed) {
- checkWidget();
- 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;
-}
-/**
- * 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();
- 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);
- }
-}
-/**
- * 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();
- SelectableItem item = getVisibleItem(index);
-
- if (item != null) {
- deselect(item);
- setLastSelection(item, 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();
- SelectableItem item = null;
-
- for (int i=start; i<=end; i++) {
- item = getVisibleItem(i);
- if (item != null) {
- deselect(item);
- }
- }
- if (item != null) {
- setLastSelection(item, 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();
-
- deselectAllExcept((SelectableItem) null);
-}
-/**
- * Free resources.
- */
-void doDispose() {
- Vector items = getItemVector();
-
- super.doDispose();
- for (int i = items.size() - 1; i >= 0; i--) {
- ((TableItem) items.elementAt(i)).dispose();
- }
- setItemVector(null);
- 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;
- int lineWidth = getGridLineWidth();
-
- redraw(getColumnResizeX() - lineWidth, 0, 1, lineHeight, false);
- setColumnResizeX(xPosition);
- gc.drawLine(xPosition - lineWidth, 0, xPosition - lineWidth, 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);
-}
-
-/**
- * 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);
-}
-
-/**
- * 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();
- 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;
-}
-/**
- * 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();
- 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;
-}
-/**
- * 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 affect the receiver.
- * </p>
- *
- * @return the items in the receiver
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public TableColumn [] getColumns() {
- checkWidget();
- 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) {
- return dotsWidth;
-}
-/**
- * Answer the column used to occupy any space left to the
- * right of all the user created columns.
- */
-TableColumn getFillColumn() {
- return fillColumn;
-}
-/**
- * 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;
-}
-/**
- * Answer the table header widget.
- */
-Header getHeader() {
- return tableHeader;
-}
-/**
- * Returns the height of the receiver's header
- *
- * @return the height of the header or zero if the header is not visible
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @since 2.0
- */
-public int getHeaderHeight() {
- checkWidget();
- Header header = getHeader();
- int height = 0;
-
- if (header.getVisible() == true) {
- height = header.getBounds().height;
- }
- return height;
-}
-/**
- * Returns <code>true</code> if the receiver's header is visible,
- * and <code>false</code> otherwise.
- * <p>
- * If one of the receiver's ancestors is not visible or some
- * other condition makes the receiver not visible, this method
- * may still indicate that it is considered visible even though
- * it may not actually be showing.
- * </p>
- *
- * @return the receiver's header's visibility state
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public boolean getHeaderVisible() {
- checkWidget();
-
- return 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;
-}
-/**
- * Returns the item at the given, zero-relative index in the
- * receiver. Throws an exception if the index is out of range.
- *
- * @param index the index of the item to return
- * @return the item at the given index
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_INVALID_RANGE - if the index is not between 0 and the number of elements in the list minus 1 (inclusive)</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public TableItem getItem(int index) {
- checkWidget();
-
- if (!(0 <= index && index < getItemCount())) {
- error(SWT.ERROR_INVALID_RANGE);
- }
- return (TableItem) getVisibleItem(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);
- 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;
-}
-/**
- * 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 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();
-}
-/**
- * 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();
-
- return super.getItemHeight();
-}
-/**
- * Answer the number of pixels that should be added to the item height.
- */
-int getItemPadding() {
- return getGridLineWidth() + getDisplay().textHighlightThickness + 1;
-}
-/**
- * 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 affect the receiver.
- * </p>
- *
- * @return the items in the receiver
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public TableItem [] getItems() {
- checkWidget();
- Vector items = getItemVector();
- TableItem itemArray[] = new TableItem[items.size()];
-
- items.copyInto(itemArray);
- return itemArray;
-}
-/**
- * Answer all items of the receiver.
- */
-Vector getItemVector() {
- return items;
-}
-/**
- * Returns <code>true</code> if the receiver's lines are visible,
- * and <code>false</code> otherwise.
- * <p>
- * If one of the receiver's ancestors is not visible or some
- * other condition makes the receiver not visible, this method
- * may still indicate that it is considered visible even though
- * it may not actually be showing.
- * </p>
- *
- * @return the visibility state of the lines
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public boolean getLinesVisible() {
- checkWidget();
-
- return 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;
-}
-/**
- * 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 affect the receiver.
- * </p>
- * @return an array representing the selection
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public TableItem [] getSelection() {
- checkWidget();
- Vector selectionVector = getSelectionVector();
- TableItem[] selectionArray = new TableItem[selectionVector.size()];
-
- selectionVector.copyInto(selectionArray);
- sort(selectionArray, 0, selectionArray.length);
- return selectionArray;
-}
-
-/**
- * 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 super.getSelectionCount();
-}
-
-int getFontHeight(){
- return fontHeight;
-}
-/**
- * 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;
-}
-/**
- * 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 index = -1;
-
- if (getSelectionCount() > 0) {
- index = getIndex(getSelection()[0]);
- }
- return index;
-}
-/**
- * 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 affect the receiver.
- * </p>
- * @return the array of indices of the selected items
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public int [] getSelectionIndices() {
- checkWidget();
- TableItem[] items = getSelection();
- int indices[] = new int[items.length];
-
- for (int i = 0; i < items.length; i++) {
- indices[i] = getIndex(items[i]);
- }
- 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 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;
-}
-/**
- * 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);
-
- // only react to button one clicks. fixes bug 6770
- if (event.button != 1) {
- return;
- }
- 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
- }
-}
-/**
- * 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);
- }
- return internalGetColumnVector().indexOf(column);
-}
-/**
- * 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);
- }
- return getIndex(item);
-}
-/**
- * Initialize the receiver. Create a header widget and an empty column.
- */
-void initialize() {
- columns = new Vector();
- setItemVector(new Vector());
- GC gc = new GC(this);
- Point extent = gc.stringExtent(DOT_STRING);
- dotsWidth = extent.x;
- fontHeight = extent.y;
- gc.dispose();
- 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();
- Listener listener = getListener();
-
- super.installListeners();
- tableHeader.addListener(SWT.MouseMove, listener);
- tableHeader.addListener(SWT.MouseDown, listener);
- tableHeader.addListener(SWT.MouseUp, 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);
- if (hotColumn == null) return false;
- 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);
-}
-/**
- * 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();
- 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;
- redraw ();
- }
- 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) {
- redraw(resizeXPosition - getGridLineWidth(), 0, 1, getClientArea().height, false); // remove resize line
- update(); // to avoid cheese caused by scrolling the resize line
- }
- if (widthChange != 0) {
- 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;
- GC gc = event.gc;
- Color selectionColor = getDisplay().getSystemColor(SWT.COLOR_LIST_SELECTION);
- Point fullSelectionExtent;
- int paintXPosition;
- int paintYPosition;
-
- topPaintIndex += getTopIndex();
- bottomPaintIndex += getTopIndex();
- for (int i = topPaintIndex; i <= bottomPaintIndex; i++) {
- paintItem = (TableItem) getVisibleItem(i);
- paintXPosition = paintItem.getSelectionX();
- paintYPosition = getRedrawY(paintItem);
- fullSelectionExtent = getFullSelectionExtent(paintItem);
- gc.setBackground(paintItem.getBackground());
- gc.fillRectangle(paintXPosition, paintYPosition, fullSelectionExtent.x, fullSelectionExtent.y);
-
- if (paintItem.isSelected() == true) {
- selectionExtent = paintItem.getSelectionExtent();
- gc.setBackground(selectionColor);
- gc.fillRectangle(paintXPosition, paintYPosition, selectionExtent.x, selectionExtent.y);
- }
- columns = paintColumns.elements();
- while (columns.hasMoreElements() == true) {
- column = (TableColumn) columns.nextElement();
- paintSubItem(event, paintItem, column, paintYPosition);
- }
- 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();
- Point paintPosition;
- 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,
- Math.max(0, itemDrawStopX - clipX), event.height);
- }
- paintPosition = new Point(columnBounds.x, paintYPosition);
- paintItem.paint(event.gc, paintPosition, column);
- 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);
- }
-}
-/**
- * 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();
- SelectableItem item;
- int [] sortedIndices;
- int last = -1;
- int sortedIndex;
-
- 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++) {
- sortedIndex = sortedIndices[i];
- if (sortedIndex != last) {
- item = getVisibleItem(sortedIndex);
- if (item != null) {
- item.dispose();
- }
- else {
- if (0 <= sortedIndex && sortedIndex < getItemVector().size()) {
- error(SWT.ERROR_ITEM_NOT_REMOVED);
- }
- else {
- error(SWT.ERROR_INVALID_RANGE);
- }
- }
- last = sortedIndex;
- }
- }
-}
-/**
- * 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();
- SelectableItem item = getVisibleItem(index);
-
- if (item != null) {
- item.dispose();
- }
- else {
- if (0 <= index && index < getItemVector().size()) {
- error(SWT.ERROR_ITEM_NOT_REMOVED);
- }
- else {
- error(SWT.ERROR_INVALID_RANGE);
- }
- }
-}
-/**
- * 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();
- SelectableItem item;
-
- for (int i = end; i >= start; i--) {
- item = getVisibleItem(i);
- if (item != null) {
- item.dispose();
- }
- else {
- 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();
- Vector items = getItemVector();
-
- setRedraw(false);
- setRemovingAll(true);
- for (int i = items.size() - 1; i >= 0; i--) {
- ((TableItem) items.elementAt(i)).dispose();
- }
- setItemVector(new Vector());
- reset();
- calculateVerticalScrollbar();
- setRemovingAll(false);
- setRedraw(true);
-}
-/**
- * Remove 'column' from the receiver.
- */
-void removeColumn(TableColumn column) {
- 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);
- }
- else {
- redraw();
- getHeader().redraw();
- }
- 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(), columnWidth * -1);
- redraw();
- getHeader().redraw();
-}
-/**
- * 'item' has been removed from the receiver.
- * Update the display and the scroll bars.
- */
-void removedItem(SelectableItem item) {
- int oldHeight = getItemHeight();
- super.removedItem (item);
- if (getItemCount() == 0 && drawGridLines && oldHeight != getItemHeight()) {
- redraw();
- }
-}
-/**
- * Remove 'item' from the receiver.
- * @param item - item that should be removed from the receiver
- */
-void removeItem(TableItem item) {
- if (isRemovingAll() == true) return;
-
- Vector items = getItemVector();
- int index = items.indexOf(item);
- if (index != -1) {
- removingItem(item);
- items.removeElementAt(index);
- for (int i = index; i < items.size(); i++) {
- TableItem anItem = (TableItem) items.elementAt(i);
- anItem.setIndex(anItem.getIndex() - 1);
- }
- removedItem(item);
- }
-}
-/**
- * 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);
- }
- 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);
-}
-/**
- * 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 array of indices is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public void select(int indices[]) {
- checkWidget();
- 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);
- }
-}
-/**
- * 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();
- SelectableItem item = getVisibleItem(index);
-
- if (isMultiSelect() == false) {
- deselectAllExcept(getVisibleItem(index));
- }
- if (item != null) {
- select(item);
- setLastSelection(item, 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();
- SelectableItem item = null;
-
- 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);
- }
-}
-/**
- * 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();
- 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.
- }
- }
-}
-public void setFont(Font font) {
- checkWidget();
- int itemCount = getItemCount();
-
- if (font == null || font.equals(getFont()) == true) {
- return;
- }
- setRedraw(false); // disable redraw because itemChanged() triggers undesired redraw
- resetItemData();
- super.setFont(font);
-
- GC gc = new GC(this);
- Point extent = gc.stringExtent(DOT_STRING);
- dotsWidth = extent.x;
- fontHeight = extent.y;
- gc.dispose();
-
- for (int i = 0; i < itemCount; i++) {
- itemChanged(getItem(i), 0, getClientArea().width);
- }
- setRedraw(true); // re-enable redraw
- getHeader().setFont(font);
-}
-/**
- * Marks the receiver's header as visible if the argument is <code>true</code>,
- * and marks it invisible otherwise.
- * <p>
- * If one of the receiver's ancestors is not visible or some
- * other condition makes the receiver not visible, marking
- * it visible may not actually cause it to be displayed.
- * </p>
- *
- * @param 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 headerVisible) {
- checkWidget();
- 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;
-}
-/**
- * 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 drawGridLines) {
- checkWidget();
- if (this.drawGridLines != drawGridLines) {
- this.drawGridLines = drawGridLines;
- redraw();
- }
-}
-public void setRedraw(boolean redraw) {
- checkWidget();
- 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;
-}
-/**
- * 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 array of indices is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see Table#deselectAll()
- * @see Table#select(int[])
- */
-public void setSelection(int [] indices) {
- checkWidget();
- 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);
- showSelection ();
-}
-/**
- * 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 array of items is null</li>
- * <li>ERROR_INVALID_ARGUMENT - if one of the item has been disposed</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see Table#deselectAll()
- * @see Table#select(int)
- */
-public void setSelection(TableItem selectionItems[]) {
- checkWidget();
- if (selectionItems == null) {
- error(SWT.ERROR_NULL_ARGUMENT);
- }
- setSelectableSelection(selectionItems);
-}
-/**
- * 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) {
- checkWidget();
- deselectAllExcept(getVisibleItem(index));
- select(index);
- showSelection ();
-}
-/**
- * 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) {
- checkWidget();
- Vector keepSelected = new Vector();
-
- for (int i = start; i <= end; i++) {
- SelectableItem item = getVisibleItem(i);
- if (item != null) {
- keepSelected.addElement(item);
- }
- }
- deselectAllExcept(keepSelected);
- select(start, end);
- showSelection ();
-}
-/**
- * Sets the zero-relative index of the item which is currently
- * at the top of the receiver. This index can change when items
- * are scrolled or new items are added and removed.
- *
- * @param index the index of the top item
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public void setTopIndex(int index) {
- checkWidget();
- int itemCount = getItemCount();
- int itemCountWhole = getItemCountWhole();
- if (index < 0 || itemCount == 0) return;
- if (index >= itemCount) index = itemCount - 1;
- if (itemCount > itemCountWhole) {
- if (index + itemCountWhole <= itemCount) {
- setTopIndex(index, true);
- } else if (index > itemCount - itemCountWhole) {
- setTopIndex(itemCount - itemCountWhole, true);
- } else {
- showSelectableItem(index);
- }
- }
-}
-/**
- * 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();
-}
-/**
- * Shows the item. If the item is already showing in the receiver,
- * this method simply returns. Otherwise, the items are scrolled until
- * the item is visible.
- *
- * @param item the item to be shown
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the item is null</li>
- * <li>ERROR_INVALID_ARGUMENT - if the item has been disposed</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see Table#showSelection()
- */
-public void showItem(TableItem item) {
- checkWidget();
- if (item == null) error (SWT.ERROR_NULL_ARGUMENT);
- if (item.isDisposed()) error(SWT.ERROR_INVALID_ARGUMENT);
- showSelectableItem(item);
-}
-/**
- * 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();
- 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;
-}
-
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+import org.eclipse.swt.events.*;
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.*;
+import java.util.Enumeration;
+import java.util.Vector;
+
+/**
+ * Instances of this class implement a selectable user interface
+ * object that displays a list of images and strings and issue
+ * notificiation when selected.
+ * <p>
+ * The item children that may be added to instances of this class
+ * must be of type <code>TableItem</code>.
+ * </p><p>
+ * Note that although this class is a subclass of <code>Composite</code>,
+ * it does not make sense to add <code>Control</code> children to it,
+ * or set a layout on it.
+ * </p><p>
+ * <dl>
+ * <dt><b>Styles:</b></dt>
+ * <dd>SINGLE, MULTI, CHECK, FULL_SELECTION, HIDE_SELECTION</dd>
+ * <dt><b>Events:</b></dt>
+ * <dd>Selection, DefaultSelection</dd>
+ * </dl>
+ * <p>
+ * Note: Only one of the styles SINGLE, and MULTI may be specified.
+ * </p><p>
+ * IMPORTANT: This class is <em>not</em> intended to be subclassed.
+ * </p>
+ */
+public 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 Vector items;
+ private Vector columns;
+ private boolean drawGridLines = false;
+ 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; // width of the static String dots (see above)
+ private int fontHeight; // font height, avoid use GC.stringExtend for each pain
+
+/**
+ * Constructs a new instance of this class given its parent
+ * and a style value describing its behavior and appearance.
+ * <p>
+ * The style value is either one of the style constants defined in
+ * class <code>SWT</code> which is applicable to instances of this
+ * class, or must be built by <em>bitwise OR</em>'ing together
+ * (that is, using the <code>int</code> "|" operator) two or more
+ * of those <code>SWT</code> style constants. The class description
+ * lists the style constants that are applicable to the class.
+ * Style bits are also inherited from superclasses.
+ * </p>
+ *
+ * @param parent a composite control which will be the parent of the new instance (cannot be null)
+ * @param style the style of control to construct
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
+ * <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
+ * </ul>
+ *
+ * @see SWT#SINGLE
+ * @see SWT#MULTI
+ * @see SWT#CHECK
+ * @see SWT#FULL_SELECTION
+ * @see SWT#HIDE_SELECTION
+ * @see Widget#checkSubclass
+ * @see Widget#getStyle
+ */
+public Table(Composite parent, int style) {
+ // use NO_REDRAW_RESIZE to avoid flashing during widget resize redraw
+ super(parent, checkStyle(style| SWT.NO_REDRAW_RESIZE));
+}
+
+/**
+ * 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 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.
+ * <p>
+ * When <code>widgetSelected</code> is called, the item field of the event object is valid.
+ * If the reciever has <code>SWT.CHECK</code> style set and the check selection changes,
+ * the event object detail field contains the value <code>SWT.CHECK</code>.
+ * <code>widgetDefaultSelected</code> is typically called when an item is double-clicked.
+ * The item field of the event object is valid for default selection, but the detail field is not used.
+ * </p>
+ *
+ * @param listener the listener which should be notified
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see SelectionListener
+ * @see #removeSelectionListener
+ * @see SelectionEvent
+ */
+public void addSelectionListener (SelectionListener listener) {
+ checkWidget();
+ if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+ TypedListener typedListener = new TypedListener(listener);
+ addListener(SWT.Selection,typedListener);
+ addListener(SWT.DefaultSelection,typedListener);
+}
+static int checkStyle (int style) {
+ return checkBits (style, SWT.SINGLE, SWT.MULTI, 0, 0, 0, 0);
+}
+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) {
+ getHeader().widthChange(columnIndex, widthChange);
+ 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);
+ }
+ }
+}
+/**
+ * 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;
+ boolean isFullSelection = (getStyle () & SWT.FULL_SELECTION) != 0;
+
+ if (isFocusControl () == false) {
+ forceFocus ();
+ }
+ if (hitColumn != null) {
+ itemIndex = (event.y - getHeaderHeight()) / itemHeight + getTopIndex();
+ hitItem = (TableItem) getVisibleItem(itemIndex);
+ if (hitItem != null &&
+ (hitColumn.getIndex() == TableColumn.FIRST || isFullSelection)) {
+ if (hitItem.isSelectionHit(event.x) == true) {
+ columnDblClickEvent = new Event();
+ columnDblClickEvent.item = hitItem;
+ notifyListeners(SWT.DefaultSelection, columnDblClickEvent);
+ }
+ }
+ }
+}
+/**
+ * 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) {
+ forceFocus ();
+ }
+ 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) {
+ // only react to button one clicks. fixes bug 6770
+ if (event.button != 1) {
+ return;
+ }
+ doCheckItem(hitItem);
+ }
+ }
+ }
+}
+/**
+ * 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);
+ }
+}
+public Point computeSize(int wHint, int hHint, boolean changed) {
+ checkWidget();
+ 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;
+}
+/**
+ * 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();
+ 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);
+ }
+}
+/**
+ * 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();
+ SelectableItem item = getVisibleItem(index);
+
+ if (item != null) {
+ deselect(item);
+ setLastSelection(item, 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();
+ SelectableItem item = null;
+
+ for (int i=start; i<=end; i++) {
+ item = getVisibleItem(i);
+ if (item != null) {
+ deselect(item);
+ }
+ }
+ if (item != null) {
+ setLastSelection(item, 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();
+
+ deselectAllExcept((SelectableItem) null);
+}
+/**
+ * Free resources.
+ */
+void doDispose() {
+ Vector items = getItemVector();
+
+ super.doDispose();
+ for (int i = items.size() - 1; i >= 0; i--) {
+ ((TableItem) items.elementAt(i)).dispose();
+ }
+ setItemVector(null);
+ 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;
+ int lineWidth = getGridLineWidth();
+
+ redraw(getColumnResizeX() - lineWidth, 0, 1, lineHeight, false);
+ setColumnResizeX(xPosition);
+ gc.drawLine(xPosition - lineWidth, 0, xPosition - lineWidth, 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);
+}
+
+/**
+ * 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);
+}
+
+/**
+ * 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();
+ 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;
+}
+/**
+ * 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();
+ 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;
+}
+/**
+ * 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 affect the receiver.
+ * </p>
+ *
+ * @return the items in the receiver
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public TableColumn [] getColumns() {
+ checkWidget();
+ 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) {
+ return dotsWidth;
+}
+/**
+ * Answer the column used to occupy any space left to the
+ * right of all the user created columns.
+ */
+TableColumn getFillColumn() {
+ return fillColumn;
+}
+/**
+ * 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;
+}
+/**
+ * Answer the table header widget.
+ */
+Header getHeader() {
+ return tableHeader;
+}
+/**
+ * Returns the height of the receiver's header
+ *
+ * @return the height of the header or zero if the header is not visible
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @since 2.0
+ */
+public int getHeaderHeight() {
+ checkWidget();
+ Header header = getHeader();
+ int height = 0;
+
+ if (header.getVisible() == true) {
+ height = header.getBounds().height;
+ }
+ return height;
+}
+/**
+ * Returns <code>true</code> if the receiver's header is visible,
+ * and <code>false</code> otherwise.
+ * <p>
+ * If one of the receiver's ancestors is not visible or some
+ * other condition makes the receiver not visible, this method
+ * may still indicate that it is considered visible even though
+ * it may not actually be showing.
+ * </p>
+ *
+ * @return the receiver's header's visibility state
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public boolean getHeaderVisible() {
+ checkWidget();
+
+ return 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;
+}
+/**
+ * Returns the item at the given, zero-relative index in the
+ * receiver. Throws an exception if the index is out of range.
+ *
+ * @param index the index of the item to return
+ * @return the item at the given index
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_INVALID_RANGE - if the index is not between 0 and the number of elements in the list minus 1 (inclusive)</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public TableItem getItem(int index) {
+ checkWidget();
+
+ if (!(0 <= index && index < getItemCount())) {
+ error(SWT.ERROR_INVALID_RANGE);
+ }
+ return (TableItem) getVisibleItem(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);
+ 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;
+}
+/**
+ * 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 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();
+}
+/**
+ * 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();
+
+ return super.getItemHeight();
+}
+/**
+ * Answer the number of pixels that should be added to the item height.
+ */
+int getItemPadding() {
+ return getGridLineWidth() + getDisplay().textHighlightThickness + 1;
+}
+/**
+ * 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 affect the receiver.
+ * </p>
+ *
+ * @return the items in the receiver
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public TableItem [] getItems() {
+ checkWidget();
+ Vector items = getItemVector();
+ TableItem itemArray[] = new TableItem[items.size()];
+
+ items.copyInto(itemArray);
+ return itemArray;
+}
+/**
+ * Answer all items of the receiver.
+ */
+Vector getItemVector() {
+ return items;
+}
+/**
+ * Returns <code>true</code> if the receiver's lines are visible,
+ * and <code>false</code> otherwise.
+ * <p>
+ * If one of the receiver's ancestors is not visible or some
+ * other condition makes the receiver not visible, this method
+ * may still indicate that it is considered visible even though
+ * it may not actually be showing.
+ * </p>
+ *
+ * @return the visibility state of the lines
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public boolean getLinesVisible() {
+ checkWidget();
+
+ return 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;
+}
+/**
+ * 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 affect the receiver.
+ * </p>
+ * @return an array representing the selection
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public TableItem [] getSelection() {
+ checkWidget();
+ Vector selectionVector = getSelectionVector();
+ TableItem[] selectionArray = new TableItem[selectionVector.size()];
+
+ selectionVector.copyInto(selectionArray);
+ sort(selectionArray, 0, selectionArray.length);
+ return selectionArray;
+}
+
+/**
+ * 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 super.getSelectionCount();
+}
+
+int getFontHeight(){
+ return fontHeight;
+}
+/**
+ * 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;
+}
+/**
+ * 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 index = -1;
+
+ if (getSelectionCount() > 0) {
+ index = getIndex(getSelection()[0]);
+ }
+ return index;
+}
+/**
+ * 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 affect the receiver.
+ * </p>
+ * @return the array of indices of the selected items
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public int [] getSelectionIndices() {
+ checkWidget();
+ TableItem[] items = getSelection();
+ int indices[] = new int[items.length];
+
+ for (int i = 0; i < items.length; i++) {
+ indices[i] = getIndex(items[i]);
+ }
+ 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 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;
+}
+/**
+ * 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);
+
+ // only react to button one clicks. fixes bug 6770
+ if (event.button != 1) {
+ return;
+ }
+ 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
+ }
+}
+/**
+ * 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);
+ }
+ return internalGetColumnVector().indexOf(column);
+}
+/**
+ * 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);
+ }
+ return getIndex(item);
+}
+/**
+ * Initialize the receiver. Create a header widget and an empty column.
+ */
+void initialize() {
+ columns = new Vector();
+ setItemVector(new Vector());
+ GC gc = new GC(this);
+ Point extent = gc.stringExtent(DOT_STRING);
+ dotsWidth = extent.x;
+ fontHeight = extent.y;
+ gc.dispose();
+ 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();
+ Listener listener = getListener();
+
+ super.installListeners();
+ tableHeader.addListener(SWT.MouseMove, listener);
+ tableHeader.addListener(SWT.MouseDown, listener);
+ tableHeader.addListener(SWT.MouseUp, 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);
+ if (hotColumn == null) return false;
+ 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);
+}
+/**
+ * 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();
+ 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;
+ redraw ();
+ }
+ 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) {
+ redraw(resizeXPosition - getGridLineWidth(), 0, 1, getClientArea().height, false); // remove resize line
+ update(); // to avoid cheese caused by scrolling the resize line
+ }
+ if (widthChange != 0) {
+ 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;
+ GC gc = event.gc;
+ Color selectionColor = getDisplay().getSystemColor(SWT.COLOR_LIST_SELECTION);
+ Point fullSelectionExtent;
+ int paintXPosition;
+ int paintYPosition;
+
+ topPaintIndex += getTopIndex();
+ bottomPaintIndex += getTopIndex();
+ for (int i = topPaintIndex; i <= bottomPaintIndex; i++) {
+ paintItem = (TableItem) getVisibleItem(i);
+ paintXPosition = paintItem.getSelectionX();
+ paintYPosition = getRedrawY(paintItem);
+ fullSelectionExtent = getFullSelectionExtent(paintItem);
+ gc.setBackground(paintItem.getBackground());
+ gc.fillRectangle(paintXPosition, paintYPosition, fullSelectionExtent.x, fullSelectionExtent.y);
+
+ if (paintItem.isSelected() == true) {
+ selectionExtent = paintItem.getSelectionExtent();
+ gc.setBackground(selectionColor);
+ gc.fillRectangle(paintXPosition, paintYPosition, selectionExtent.x, selectionExtent.y);
+ }
+ columns = paintColumns.elements();
+ while (columns.hasMoreElements() == true) {
+ column = (TableColumn) columns.nextElement();
+ paintSubItem(event, paintItem, column, paintYPosition);
+ }
+ 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();
+ Point paintPosition;
+ 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,
+ Math.max(0, itemDrawStopX - clipX), event.height);
+ }
+ paintPosition = new Point(columnBounds.x, paintYPosition);
+ paintItem.paint(event.gc, paintPosition, column);
+ 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);
+ }
+}
+/**
+ * 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();
+ SelectableItem item;
+ int [] sortedIndices;
+ int last = -1;
+ int sortedIndex;
+
+ 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++) {
+ sortedIndex = sortedIndices[i];
+ if (sortedIndex != last) {
+ item = getVisibleItem(sortedIndex);
+ if (item != null) {
+ item.dispose();
+ }
+ else {
+ if (0 <= sortedIndex && sortedIndex < getItemVector().size()) {
+ error(SWT.ERROR_ITEM_NOT_REMOVED);
+ }
+ else {
+ error(SWT.ERROR_INVALID_RANGE);
+ }
+ }
+ last = sortedIndex;
+ }
+ }
+}
+/**
+ * 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();
+ SelectableItem item = getVisibleItem(index);
+
+ if (item != null) {
+ item.dispose();
+ }
+ else {
+ if (0 <= index && index < getItemVector().size()) {
+ error(SWT.ERROR_ITEM_NOT_REMOVED);
+ }
+ else {
+ error(SWT.ERROR_INVALID_RANGE);
+ }
+ }
+}
+/**
+ * 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();
+ SelectableItem item;
+
+ for (int i = end; i >= start; i--) {
+ item = getVisibleItem(i);
+ if (item != null) {
+ item.dispose();
+ }
+ else {
+ 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();
+ Vector items = getItemVector();
+
+ setRedraw(false);
+ setRemovingAll(true);
+ for (int i = items.size() - 1; i >= 0; i--) {
+ ((TableItem) items.elementAt(i)).dispose();
+ }
+ setItemVector(new Vector());
+ reset();
+ calculateVerticalScrollbar();
+ setRemovingAll(false);
+ setRedraw(true);
+}
+/**
+ * Remove 'column' from the receiver.
+ */
+void removeColumn(TableColumn column) {
+ 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);
+ }
+ else {
+ redraw();
+ getHeader().redraw();
+ }
+ 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(), columnWidth * -1);
+ redraw();
+ getHeader().redraw();
+}
+/**
+ * 'item' has been removed from the receiver.
+ * Update the display and the scroll bars.
+ */
+void removedItem(SelectableItem item) {
+ int oldHeight = getItemHeight();
+ super.removedItem (item);
+ if (getItemCount() == 0 && drawGridLines && oldHeight != getItemHeight()) {
+ redraw();
+ }
+}
+/**
+ * Remove 'item' from the receiver.
+ * @param item - item that should be removed from the receiver
+ */
+void removeItem(TableItem item) {
+ if (isRemovingAll() == true) return;
+
+ Vector items = getItemVector();
+ int index = items.indexOf(item);
+ if (index != -1) {
+ removingItem(item);
+ items.removeElementAt(index);
+ for (int i = index; i < items.size(); i++) {
+ TableItem anItem = (TableItem) items.elementAt(i);
+ anItem.setIndex(anItem.getIndex() - 1);
+ }
+ removedItem(item);
+ }
+}
+/**
+ * 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);
+ }
+ 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);
+}
+/**
+ * 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 array of indices is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void select(int indices[]) {
+ checkWidget();
+ 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);
+ }
+}
+/**
+ * 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();
+ SelectableItem item = getVisibleItem(index);
+
+ if (isMultiSelect() == false) {
+ deselectAllExcept(getVisibleItem(index));
+ }
+ if (item != null) {
+ select(item);
+ setLastSelection(item, 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();
+ SelectableItem item = null;
+
+ 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);
+ }
+}
+/**
+ * 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();
+ 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.
+ }
+ }
+}
+public void setFont(Font font) {
+ checkWidget();
+ int itemCount = getItemCount();
+
+ if (font == null || font.equals(getFont()) == true) {
+ return;
+ }
+ setRedraw(false); // disable redraw because itemChanged() triggers undesired redraw
+ resetItemData();
+ super.setFont(font);
+
+ GC gc = new GC(this);
+ Point extent = gc.stringExtent(DOT_STRING);
+ dotsWidth = extent.x;
+ fontHeight = extent.y;
+ gc.dispose();
+
+ for (int i = 0; i < itemCount; i++) {
+ itemChanged(getItem(i), 0, getClientArea().width);
+ }
+ setRedraw(true); // re-enable redraw
+ getHeader().setFont(font);
+}
+/**
+ * Marks the receiver's header as visible if the argument is <code>true</code>,
+ * and marks it invisible otherwise.
+ * <p>
+ * If one of the receiver's ancestors is not visible or some
+ * other condition makes the receiver not visible, marking
+ * it visible may not actually cause it to be displayed.
+ * </p>
+ *
+ * @param 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 headerVisible) {
+ checkWidget();
+ 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;
+}
+/**
+ * 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 drawGridLines) {
+ checkWidget();
+ if (this.drawGridLines != drawGridLines) {
+ this.drawGridLines = drawGridLines;
+ redraw();
+ }
+}
+public void setRedraw(boolean redraw) {
+ checkWidget();
+ 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;
+}
+/**
+ * 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 array of indices is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see Table#deselectAll()
+ * @see Table#select(int[])
+ */
+public void setSelection(int [] indices) {
+ checkWidget();
+ 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);
+ showSelection ();
+}
+/**
+ * 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 array of items is null</li>
+ * <li>ERROR_INVALID_ARGUMENT - if one of the item has been disposed</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see Table#deselectAll()
+ * @see Table#select(int)
+ */
+public void setSelection(TableItem selectionItems[]) {
+ checkWidget();
+ if (selectionItems == null) {
+ error(SWT.ERROR_NULL_ARGUMENT);
+ }
+ setSelectableSelection(selectionItems);
+}
+/**
+ * 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) {
+ checkWidget();
+ deselectAllExcept(getVisibleItem(index));
+ select(index);
+ showSelection ();
+}
+/**
+ * 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) {
+ checkWidget();
+ Vector keepSelected = new Vector();
+
+ for (int i = start; i <= end; i++) {
+ SelectableItem item = getVisibleItem(i);
+ if (item != null) {
+ keepSelected.addElement(item);
+ }
+ }
+ deselectAllExcept(keepSelected);
+ select(start, end);
+ showSelection ();
+}
+/**
+ * Sets the zero-relative index of the item which is currently
+ * at the top of the receiver. This index can change when items
+ * are scrolled or new items are added and removed.
+ *
+ * @param index the index of the top item
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setTopIndex(int index) {
+ checkWidget();
+ int itemCount = getItemCount();
+ int itemCountWhole = getItemCountWhole();
+ if (index < 0 || itemCount == 0) return;
+ if (index >= itemCount) index = itemCount - 1;
+ if (itemCount > itemCountWhole) {
+ if (index + itemCountWhole <= itemCount) {
+ setTopIndex(index, true);
+ } else if (index > itemCount - itemCountWhole) {
+ setTopIndex(itemCount - itemCountWhole, true);
+ } else {
+ showSelectableItem(index);
+ }
+ }
+}
+/**
+ * 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();
+}
+/**
+ * Shows the item. If the item is already showing in the receiver,
+ * this method simply returns. Otherwise, the items are scrolled until
+ * the item is visible.
+ *
+ * @param item the item to be shown
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if the item is null</li>
+ * <li>ERROR_INVALID_ARGUMENT - if the item has been disposed</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see Table#showSelection()
+ */
+public void showItem(TableItem item) {
+ checkWidget();
+ if (item == null) error (SWT.ERROR_NULL_ARGUMENT);
+ if (item.isDisposed()) error(SWT.ERROR_INVALID_ARGUMENT);
+ showSelectableItem(item);
+}
+/**
+ * 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();
+ 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;
+}
+
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/emulated/treetable/org/eclipse/swt/widgets/TableColumn.java b/bundles/org.eclipse.swt/Eclipse SWT/emulated/treetable/org/eclipse/swt/widgets/TableColumn.java
index 4dfefadc65..ffd2bfddbd 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/emulated/treetable/org/eclipse/swt/widgets/TableColumn.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/emulated/treetable/org/eclipse/swt/widgets/TableColumn.java
@@ -1,536 +1,536 @@
-package org.eclipse.swt.widgets;
-
-/*
+package org.eclipse.swt.widgets;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-import org.eclipse.swt.*;
-import org.eclipse.swt.events.*;
-import org.eclipse.swt.graphics.*;
-
-/**
- * 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>
- * Note: Only one of the styles LEFT, RIGHT and CENTER may be specified.
- * </p><p>
- * IMPORTANT: This class is <em>not</em> intended to be subclassed.
- * </p>
+ * http://www.eclipse.org/legal/cpl-v10.html
*/
-public 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.
+
+import org.eclipse.swt.*;
+import org.eclipse.swt.events.*;
+import org.eclipse.swt.graphics.*;
+
+/**
+ * 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>
+ * Note: Only one of the styles LEFT, RIGHT and CENTER may be specified.
+ * </p><p>
+ * IMPORTANT: This class is <em>not</em> intended to be subclassed.
+ * </p>
*/
-TableColumn(Table parent) {
- super(parent, SWT.NULL);
- this.parent = parent;
-}
-
-/**
- * Constructs a new instance of this class given its parent
- * (which must be a <code>Table</code>) and a style value
- * describing its behavior and appearance. The item is added
- * to the end of the items maintained by its parent.
- * <p>
- * The style value is either one of the style constants defined in
- * class <code>SWT</code> which is applicable to instances of this
- * class, or must be built by <em>bitwise OR</em>'ing together
- * (that is, using the <code>int</code> "|" operator) two or more
- * of those <code>SWT</code> style constants. The class description
- * lists the style constants that are applicable to the class.
- * Style bits are also inherited from superclasses.
- * </p>
- *
- * @param parent a composite control which will be the parent of the new instance (cannot be null)
- * @param style the style of control to construct
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
- * <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
- * </ul>
- *
- * @see SWT#LEFT
- * @see SWT#RIGHT
- * @see SWT#CENTER
- * @see Widget#checkSubclass
- * @see Widget#getStyle
+public 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.
*/
-public TableColumn(Table parent, int style) {
- this(parent, style, checkNull(parent).getColumnCount());
-}
-
-/**
- * Constructs a new instance of this class given its parent
- * (which must be a <code>Table</code>), a style value
- * describing its behavior and appearance, and the index
- * at which to place it in the items maintained by its parent.
- * <p>
- * The style value is either one of the style constants defined in
- * class <code>SWT</code> which is applicable to instances of this
- * class, or must be built by <em>bitwise OR</em>'ing together
- * (that is, using the <code>int</code> "|" operator) two or more
- * of those <code>SWT</code> style constants. The class description
- * lists the style constants that are applicable to the class.
- * Style bits are also inherited from superclasses.
- * </p>
- *
- * @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#LEFT
- * @see SWT#RIGHT
- * @see SWT#CENTER
- * @see Widget#checkSubclass
- * @see Widget#getStyle
+TableColumn(Table parent) {
+ super(parent, SWT.NULL);
+ this.parent = parent;
+}
+
+/**
+ * Constructs a new instance of this class given its parent
+ * (which must be a <code>Table</code>) and a style value
+ * describing its behavior and appearance. The item is added
+ * to the end of the items maintained by its parent.
+ * <p>
+ * The style value is either one of the style constants defined in
+ * class <code>SWT</code> which is applicable to instances of this
+ * class, or must be built by <em>bitwise OR</em>'ing together
+ * (that is, using the <code>int</code> "|" operator) two or more
+ * of those <code>SWT</code> style constants. The class description
+ * lists the style constants that are applicable to the class.
+ * Style bits are also inherited from superclasses.
+ * </p>
+ *
+ * @param parent a composite control which will be the parent of the new instance (cannot be null)
+ * @param style the style of control to construct
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
+ * <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
+ * </ul>
+ *
+ * @see SWT#LEFT
+ * @see SWT#RIGHT
+ * @see SWT#CENTER
+ * @see Widget#checkSubclass
+ * @see Widget#getStyle
*/
-public TableColumn(Table parent, int style, 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 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 TableColumn(Table parent, int style) {
+ this(parent, style, checkNull(parent).getColumnCount());
+}
+
+/**
+ * Constructs a new instance of this class given its parent
+ * (which must be a <code>Table</code>), a style value
+ * describing its behavior and appearance, and the index
+ * at which to place it in the items maintained by its parent.
+ * <p>
+ * The style value is either one of the style constants defined in
+ * class <code>SWT</code> which is applicable to instances of this
+ * class, or must be built by <em>bitwise OR</em>'ing together
+ * (that is, using the <code>int</code> "|" operator) two or more
+ * of those <code>SWT</code> style constants. The class description
+ * lists the style constants that are applicable to the class.
+ * Style bits are also inherited from superclasses.
+ * </p>
+ *
+ * @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#LEFT
+ * @see SWT#RIGHT
+ * @see SWT#CENTER
+ * @see Widget#checkSubclass
+ * @see Widget#getStyle
*/
-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.
- * <p>
- * <code>widgetSelected</code> is called when the column header is selected.
- * <code>widgetDefaultSelected</code> is not called.
- * </p>
- *
- * @param listener the listener which should be notified
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see SelectionListener
- * @see #removeSelectionListener
- * @see SelectionEvent
+public 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 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 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);
-}
-/**
- * Throw an SWT.ERROR_NULL_ARGUMENT exception if 'table' is null.
- * Otherwise return 'table'
+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.
+ * <p>
+ * <code>widgetSelected</code> is called when the column header is selected.
+ * <code>widgetDefaultSelected</code> is not called.
+ * </p>
+ *
+ * @param listener the listener which should be notified
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see SelectionListener
+ * @see #removeSelectionListener
+ * @see SelectionEvent
*/
-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.
+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);
+}
+/**
+ * Throw an SWT.ERROR_NULL_ARGUMENT exception if 'table' is null.
+ * Otherwise return 'table'
*/
-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 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 createFillColumn(Table parent) {
- TableColumn fillColumn = new TableColumn(parent);
-
- fillColumn.setIndex(FILL);
- return fillColumn;
-}
-/**
- * Remove the receiver from its parent
+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.
*/
-void disposeColumn() {
- getParent().removeColumn(this);
-}
-/**
- * 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>
+static TableColumn createFillColumn(Table parent) {
+ TableColumn fillColumn = new TableColumn(parent);
+
+ fillColumn.setIndex(FILL);
+ return fillColumn;
+}
+/**
+ * Remove the receiver from its parent
*/
-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;
-}
-
-/**
- * Answer the bounding rectangle of the receiver.
+void disposeColumn() {
+ getParent().removeColumn(this);
+}
+/**
+ * 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>
*/
-Rectangle getBounds() {
- return new Rectangle(bounds.x, bounds.y, bounds.width, bounds.height); // copy the object to prevent changes
-}
-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.
+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;
+}
+
+/**
+ * Answer the bounding rectangle of the receiver.
*/
-int getIndex() {
- return index;
-}
-/**
- * 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>
+Rectangle getBounds() {
+ return new Rectangle(bounds.x, bounds.y, bounds.width, bounds.height); // copy the object to prevent changes
+}
+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.
*/
-public Table getParent() {
- checkWidget();
- return parent;
-}
-/**
- * Gets the resizable attribute. A column that is
- * not resizable cannot be dragged by the user but
- * may be resized by the programmer.
- *
- * @return the resizable attribute
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
+int getIndex() {
+ return index;
+}
+/**
+ * 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 boolean getResizable() {
- checkWidget();
- return resize;
-}
-/**
- * Gets the width of the receiver.
- *
- * @return the width
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
+public Table getParent() {
+ checkWidget();
+ return parent;
+}
+/**
+ * Gets the resizable attribute. A column that is
+ * not resizable cannot be dragged by the user but
+ * may be resized by the programmer.
+ *
+ * @return the resizable attribute
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
*/
-public int getWidth () {
- checkWidget();
- return getBounds().width;
-}
-/**
- * Set the colun bounds.
+public boolean getResizable() {
+ checkWidget();
+ return resize;
+}
+/**
+ * Gets the width of the receiver.
+ *
+ * @return the width
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
*/
-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.
+public int getWidth () {
+ checkWidget();
+ return getBounds().width;
+}
+/**
+ * Set the colun bounds.
*/
-boolean isDefaultWidth() {
- return isDefaultWidth;
-}
-/**
- * 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>
- *
+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.
*/
-public void pack() {
- checkWidget();
- Table parent = getParent();
- int index = parent.indexOf(this);
-
- if (getIndex() != TableColumn.FILL && index != -1) {
- setWidth(parent.getPreferredColumnWidth(index));
- }
-}
-
-/**
- * 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
+boolean isDefaultWidth() {
+ return isDefaultWidth;
+}
+/**
+ * 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 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 pack() {
+ checkWidget();
+ Table parent = getParent();
+ int index = parent.indexOf(this);
+
+ if (getIndex() != TableColumn.FILL && index != -1) {
+ setWidth(parent.getPreferredColumnWidth(index));
+ }
+}
+
+/**
+ * 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 removeSelectionListener(SelectionListener listener) {
- checkWidget();
- if (listener == null) {
- error(SWT.ERROR_NULL_ARGUMENT);
- }
- removeListener(SWT.Selection, listener);
- removeListener(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 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 setAlignment(int alignment) {
- checkWidget();
- 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
+public void removeSelectionListener(SelectionListener listener) {
+ checkWidget();
+ if (listener == null) {
+ error(SWT.ERROR_NULL_ARGUMENT);
+ }
+ removeListener(SWT.Selection, listener);
+ removeListener(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>
*/
-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
+public void setAlignment(int alignment) {
+ checkWidget();
+ 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 setDefaultWidth(boolean isDefaultWidth) {
- this.isDefaultWidth = isDefaultWidth;
-}
-public void setImage(Image image) {
- super.setImage(image);
- Header header = parent.getHeader();
- header.setHeaderHeight();
- header.redraw();
- parent.redraw();
-}
-/**
- * Set the index of the receiver to 'newIndex'. The index specifies the
- * position of the receiver relative to other columns in the parent.
+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 setIndex(int newIndex) {
- this.index = newIndex;
-}
-/**
- * Sets the resizable attribute. A column that is
- * not resizable cannot be dragged by the user but
- * may be resized by the programmer.
- *
- * @param resizable the resize attribute
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
+void setDefaultWidth(boolean isDefaultWidth) {
+ this.isDefaultWidth = isDefaultWidth;
+}
+public void setImage(Image image) {
+ super.setImage(image);
+ Header header = parent.getHeader();
+ header.setHeaderHeight();
+ header.redraw();
+ parent.redraw();
+}
+/**
+ * Set the index of the receiver to 'newIndex'. The index specifies the
+ * position of the receiver relative to other columns in the parent.
*/
-public void setResizable(boolean resize) {
- checkWidget();
- this.resize = resize;
-}
-public void setText(String newText) {
- checkWidget();
- 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 of the receiver.
- *
- * @param width the new width
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
+void setIndex(int newIndex) {
+ this.index = newIndex;
+}
+/**
+ * Sets the resizable attribute. A column that is
+ * not resizable cannot be dragged by the user but
+ * may be resized by the programmer.
+ *
+ * @param resizable the resize attribute
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
*/
-public void setWidth(int width) {
- checkWidget();
- 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
- }
-
- sendEvent(SWT.Resize, new Event ());
- int count = parent.getColumnCount();
- for (int i = index + 1; i < count; i++) {
- parent.getColumn(i).sendEvent(SWT.Move, new Event ());
- }
-}
-}
+public void setResizable(boolean resize) {
+ checkWidget();
+ this.resize = resize;
+}
+public void setText(String newText) {
+ checkWidget();
+ 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 of the receiver.
+ *
+ * @param width the new width
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setWidth(int width) {
+ checkWidget();
+ 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
+ }
+
+ sendEvent(SWT.Resize, new Event ());
+ int count = parent.getColumnCount();
+ for (int i = index + 1; i < count; i++) {
+ parent.getColumn(i).sendEvent(SWT.Move, new Event ());
+ }
+}
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/emulated/treetable/org/eclipse/swt/widgets/TableItem.java b/bundles/org.eclipse.swt/Eclipse SWT/emulated/treetable/org/eclipse/swt/widgets/TableItem.java
index f4f0b02fb8..cafaf2b892 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/emulated/treetable/org/eclipse/swt/widgets/TableItem.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/emulated/treetable/org/eclipse/swt/widgets/TableItem.java
@@ -1,1257 +1,1257 @@
-package org.eclipse.swt.widgets;
-
-/*
+package org.eclipse.swt.widgets;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-import org.eclipse.swt.*;
-import org.eclipse.swt.graphics.*;
-import java.util.Vector;
-
-/**
- * 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>
+ * http://www.eclipse.org/legal/cpl-v10.html
*/
-public 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; // 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
-
- Color background = null;
- Color foreground = null;
-
-/**
- * Constructs a new instance of this class given its parent
- * (which must be a <code>Table</code>) and a style value
- * describing its behavior and appearance. The item is added
- * to the end of the items maintained by its parent.
- * <p>
- * The style value is either one of the style constants defined in
- * class <code>SWT</code> which is applicable to instances of this
- * class, or must be built by <em>bitwise OR</em>'ing together
- * (that is, using the <code>int</code> "|" operator) two or more
- * of those <code>SWT</code> style constants. The class description
- * lists the style constants that are applicable to the class.
- * Style bits are also inherited from superclasses.
- * </p>
- *
- * @param parent a composite control which will be the parent of the new instance (cannot be null)
- * @param style the style of control to construct
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
- * <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
- * </ul>
- *
- * @see SWT
- * @see Widget#checkSubclass
- * @see Widget#getStyle
+
+import org.eclipse.swt.*;
+import org.eclipse.swt.graphics.*;
+import java.util.Vector;
+
+/**
+ * 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 TableItem(Table parent, int style) {
- this(parent, style, checkNull(parent).getItemCount());
-}
-
-/**
- * Constructs a new instance of this class given its parent
- * (which must be a <code>Table</code>), a style value
- * describing its behavior and appearance, and the index
- * at which to place it in the items maintained by its parent.
- * <p>
- * The style value is either one of the style constants defined in
- * class <code>SWT</code> which is applicable to instances of this
- * class, or must be built by <em>bitwise OR</em>'ing together
- * (that is, using the <code>int</code> "|" operator) two or more
- * of those <code>SWT</code> style constants. The class description
- * lists the style constants that are applicable to the class.
- * Style bits are also inherited from superclasses.
- * </p>
- *
- * @param parent a composite control which will be the parent of the new instance (cannot be null)
- * @param style the style of control to construct
- * @param index the 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 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; // 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
+
+ Color background = null;
+ Color foreground = null;
+
+/**
+ * Constructs a new instance of this class given its parent
+ * (which must be a <code>Table</code>) and a style value
+ * describing its behavior and appearance. The item is added
+ * to the end of the items maintained by its parent.
+ * <p>
+ * The style value is either one of the style constants defined in
+ * class <code>SWT</code> which is applicable to instances of this
+ * class, or must be built by <em>bitwise OR</em>'ing together
+ * (that is, using the <code>int</code> "|" operator) two or more
+ * of those <code>SWT</code> style constants. The class description
+ * lists the style constants that are applicable to the class.
+ * Style bits are also inherited from superclasses.
+ * </p>
+ *
+ * @param parent a composite control which will be the parent of the new instance (cannot be null)
+ * @param style the style of control to construct
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
+ * <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
+ * </ul>
+ *
+ * @see SWT
+ * @see Widget#checkSubclass
+ * @see Widget#getStyle
*/
-public TableItem(Table parent, int style, int index) {
- super(parent, style);
- trimmedLabels = new String[parent.internalGetColumnCount()];
- 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).
+public TableItem(Table parent, int style) {
+ this(parent, style, checkNull(parent).getItemCount());
+}
+
+/**
+ * Constructs a new instance of this class given its parent
+ * (which must be a <code>Table</code>), a style value
+ * describing its behavior and appearance, and the index
+ * at which to place it in the items maintained by its parent.
+ * <p>
+ * The style value is either one of the style constants defined in
+ * class <code>SWT</code> which is applicable to instances of this
+ * class, or must be built by <em>bitwise OR</em>'ing together
+ * (that is, using the <code>int</code> "|" operator) two or more
+ * of those <code>SWT</code> style constants. The class description
+ * lists the style constants that are applicable to the class.
+ * Style bits are also inherited from superclasses.
+ * </p>
+ *
+ * @param parent a composite control which will be the parent of the new instance (cannot be null)
+ * @param style the style of control to construct
+ * @param index the 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
*/
-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'
+public TableItem(Table parent, int style, int index) {
+ super(parent, style);
+ trimmedLabels = new String[parent.internalGetColumnCount()];
+ 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).
*/
-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);
-}
-public void dispose() {
- if (isDisposed()) return;
- Table parent = getParent();
- parent.removeItem(this);
- super.dispose();
-}
-void doDispose() {
- dataLabels = null;
- trimmedLabels = null;
- images = null;
- selectionExtent = null;
- super.doDispose();
-}
-
-/**
- * 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.
+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'
*/
-Point drawImage(GC gc, Point destinationPosition, int index) {
- Table parent = getParent();
- Image image = getImage(index);
- Rectangle sourceImageBounds;
- Point destinationImageExtent = parent.getImageExtent();
- int imageOffset;
-
- 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);
- }
- imageOffset = (parent.getItemHeight() - destinationImageExtent.y) / 2;
- gc.drawImage(
- image, 0, 0, // source x, y
- sourceImageBounds.width, sourceImageBounds.height, // source width, height
- destinationPosition.x, destinationPosition.y + imageOffset, // 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
+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);
+}
+public void dispose() {
+ if (isDisposed()) return;
+ Table parent = getParent();
+ parent.removeItem(this);
+ super.dispose();
+}
+void doDispose() {
+ dataLabels = null;
+ trimmedLabels = null;
+ images = null;
+ selectionExtent = null;
+ super.doDispose();
+}
+
+/**
+ * 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.
*/
-void drawText(String label, GC gc, Point position, int index) {
- Table parent = getParent();
- boolean drawSelection;
- int textOffset, alignmentOffset;
-
- if (label != null) {
- drawSelection = (index == TableColumn.FIRST || (parent.getStyle() & SWT.FULL_SELECTION) != 0);
- if (isSelected() == true && drawSelection == true) {
- gc.setForeground(getSelectionForegroundColor());
- } else {
- gc.setForeground(getForeground());
- }
- alignmentOffset = getAlignmentOffset (index, getBounds(index).width, gc);
- textOffset = (parent.getItemHeight() - parent.getFontHeight()) / 2; // vertically center the text
- gc.drawString(label, position.x + alignmentOffset, position.y + textOffset, true);
- }
-}
-int getAlignmentOffset(int columnIndex, int columnWidth, GC gc) {
- Table parent = getParent();
- TableColumn column = parent.internalGetColumn (columnIndex);
- Image image = getImage(columnIndex);
- int alignmentOffset = 0;
- int alignment = column.getAlignment();
- String label = getText(gc, column);
- int imageWidth = 0;
- int textWidth = gc.stringExtent (label).x;
- Point imageExtent = parent.getImageExtent();
- 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
- image != null)) && // only when the item actually has an image
- imageExtent != null) {
- textWidth += imageExtent.x;
- }
- if ((alignment & SWT.RIGHT) != 0) {
- alignmentOffset = columnWidth - textWidth - imageWidth - TEXT_INDENT - TEXT_INDENT;
- }
- if ((alignment & SWT.CENTER) != 0) {
- alignmentOffset = ((columnWidth - textWidth) / 2) - imageWidth - TEXT_INDENT;
- }
- if (alignmentOffset < 0) alignmentOffset = 0;
- return alignmentOffset;
-}
-/**
- * Returns the receiver's background color.
- *
- * @return the background color
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @since 2.0
- *
+Point drawImage(GC gc, Point destinationPosition, int index) {
+ Table parent = getParent();
+ Image image = getImage(index);
+ Rectangle sourceImageBounds;
+ Point destinationImageExtent = parent.getImageExtent();
+ int imageOffset;
+
+ 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);
+ }
+ imageOffset = (parent.getItemHeight() - destinationImageExtent.y) / 2;
+ gc.drawImage(
+ image, 0, 0, // source x, y
+ sourceImageBounds.width, sourceImageBounds.height, // source width, height
+ destinationPosition.x, destinationPosition.y + imageOffset, // 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
*/
-public Color getBackground(){
- checkWidget ();
- if (background != null) return background;
- Table parent = getParent();
- return parent.getBackground();
-}
-/**
- * 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>
+void drawText(String label, GC gc, Point position, int index) {
+ Table parent = getParent();
+ boolean drawSelection;
+ int textOffset, alignmentOffset;
+
+ if (label != null) {
+ drawSelection = (index == TableColumn.FIRST || (parent.getStyle() & SWT.FULL_SELECTION) != 0);
+ if (isSelected() == true && drawSelection == true) {
+ gc.setForeground(getSelectionForegroundColor());
+ } else {
+ gc.setForeground(getForeground());
+ }
+ alignmentOffset = getAlignmentOffset (index, getBounds(index).width, gc);
+ textOffset = (parent.getItemHeight() - parent.getFontHeight()) / 2; // vertically center the text
+ gc.drawString(label, position.x + alignmentOffset, position.y + textOffset, true);
+ }
+}
+int getAlignmentOffset(int columnIndex, int columnWidth, GC gc) {
+ Table parent = getParent();
+ TableColumn column = parent.internalGetColumn (columnIndex);
+ Image image = getImage(columnIndex);
+ int alignmentOffset = 0;
+ int alignment = column.getAlignment();
+ String label = getText(gc, column);
+ int imageWidth = 0;
+ int textWidth = gc.stringExtent (label).x;
+ Point imageExtent = parent.getImageExtent();
+ 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
+ image != null)) && // only when the item actually has an image
+ imageExtent != null) {
+ textWidth += imageExtent.x;
+ }
+ if ((alignment & SWT.RIGHT) != 0) {
+ alignmentOffset = columnWidth - textWidth - imageWidth - TEXT_INDENT - TEXT_INDENT;
+ }
+ if ((alignment & SWT.CENTER) != 0) {
+ alignmentOffset = ((columnWidth - textWidth) / 2) - imageWidth - TEXT_INDENT;
+ }
+ if (alignmentOffset < 0) alignmentOffset = 0;
+ return alignmentOffset;
+}
+/**
+ * Returns the receiver's background color.
+ *
+ * @return the background color
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @since 2.0
+ *
*/
-public Rectangle getBounds(int index) {
- checkWidget();
- Rectangle itemBounds;
- Rectangle columnBounds;
- Rectangle checkboxBounds;
- Table parent = getParent();
- TableColumn column;
- int itemIndex = parent.indexOf(this);
- int itemHeight = parent.getItemHeight();
- int gridLineWidth = parent.getLinesVisible() ? parent.getGridLineWidth() : 0;
- 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;
-}
-
-/**
- * Returns <code>true</code> if the receiver is checked,
- * and false otherwise. When the parent does not have
- * the <code>CHECK style, return false.
- *
- * @return the checked state of the checkbox
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
+public Color getBackground(){
+ checkWidget ();
+ if (background != null) return background;
+ Table parent = getParent();
+ return parent.getBackground();
+}
+/**
+ * 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 boolean getChecked() {
- checkWidget();
- return super.getChecked();
-}
-/**
- * Answer the x position of the item check box
+public Rectangle getBounds(int index) {
+ checkWidget();
+ Rectangle itemBounds;
+ Rectangle columnBounds;
+ Rectangle checkboxBounds;
+ Table parent = getParent();
+ TableColumn column;
+ int itemIndex = parent.indexOf(this);
+ int itemHeight = parent.getItemHeight();
+ int gridLineWidth = parent.getLinesVisible() ? parent.getGridLineWidth() : 0;
+ 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;
+}
+
+/**
+ * Returns <code>true</code> if the receiver is checked,
+ * and false otherwise. When the parent does not have
+ * the <code>CHECK style, return false.
+ *
+ * @return the checked state of the checkbox
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
*/
-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.
+public boolean getChecked() {
+ checkWidget();
+ return super.getChecked();
+}
+/**
+ * Answer the x position of the item check box
*/
-Vector getDataLabels() {
- return dataLabels;
-}
-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 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.
*/
-int getDotStartX(int columnIndex, int columnWidth) {
- GC gc;
- Table parent = getParent();
- String label = getText(columnIndex);
- int alignment = parent.internalGetColumn (columnIndex).getAlignment();
- int dotStartX = -1;
- int maxWidth;
-
- if (label != null) {
- gc = new GC(parent);
- dotStartX = getAlignmentOffset(columnIndex, columnWidth, gc);
- if ((alignment & SWT.LEFT) != 0) {
- maxWidth = getMaxTextWidth(columnIndex, columnWidth);
- label = parent.trimItemText(label, maxWidth, gc);
- if (label.endsWith(Table.DOT_STRING)) {
- dotStartX = gc.stringExtent(label).x - parent.getDotsWidth(gc);
- // add indents, margins and image width
- dotStartX += getImageStopX(columnIndex);
- dotStartX += getTextIndent(columnIndex);
- }
- }
- gc.dispose();
- }
- return dotStartX;
-}
-/**
- * Returns the foreground color that the receiver will use to draw.
- *
- * @return the receiver's foreground color
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @since 2.0
- *
+Vector getDataLabels() {
+ return dataLabels;
+}
+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
*/
-public Color getForeground(){
- checkWidget ();
- if (foreground != null) return foreground;
- Table parent = getParent();
- return parent.getForeground();
-}
-/**
- * Returns <code>true</code> if the receiver is grayed,
- * and false otherwise. When the parent does not have
- * the <code>CHECK</code> style, return false.
- *
- * @return the grayed state of the checkbox
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
+int getDotStartX(int columnIndex, int columnWidth) {
+ GC gc;
+ Table parent = getParent();
+ String label = getText(columnIndex);
+ int alignment = parent.internalGetColumn (columnIndex).getAlignment();
+ int dotStartX = -1;
+ int maxWidth;
+
+ if (label != null) {
+ gc = new GC(parent);
+ dotStartX = getAlignmentOffset(columnIndex, columnWidth, gc);
+ if ((alignment & SWT.LEFT) != 0) {
+ maxWidth = getMaxTextWidth(columnIndex, columnWidth);
+ label = parent.trimItemText(label, maxWidth, gc);
+ if (label.endsWith(Table.DOT_STRING)) {
+ dotStartX = gc.stringExtent(label).x - parent.getDotsWidth(gc);
+ // add indents, margins and image width
+ dotStartX += getImageStopX(columnIndex);
+ dotStartX += getTextIndent(columnIndex);
+ }
+ }
+ gc.dispose();
+ }
+ return dotStartX;
+}
+/**
+ * Returns the foreground color that the receiver will use to draw.
+ *
+ * @return the receiver's foreground color
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @since 2.0
+ *
*/
-public boolean getGrayed() {
- checkWidget();
- return super.getGrayed();
-}
-public Image getImage() {
- checkWidget();
- return getImage(0);
-}
-/**
- * Returns the image stored at the given column index in the receiver,
- * or null if the image has not been set or if the column does not exist.
- *
- * @param index the column index
- * @return the image stored at the given column index in the receiver
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
+public Color getForeground(){
+ checkWidget ();
+ if (foreground != null) return foreground;
+ Table parent = getParent();
+ return parent.getForeground();
+}
+/**
+ * Returns <code>true</code> if the receiver is grayed,
+ * and false otherwise. When the parent does not have
+ * the <code>CHECK</code> style, return false.
+ *
+ * @return the grayed state of the checkbox
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
*/
-public Image getImage(int columnIndex) {
- checkWidget();
- 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;
-}
-/**
- * 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 boolean getGrayed() {
+ checkWidget();
+ return super.getGrayed();
+}
+public Image getImage() {
+ checkWidget();
+ return getImage(0);
+}
+/**
+ * Returns the image stored at the given column index in the receiver,
+ * or null if the image has not been set or if the column does not exist.
+ *
+ * @param index the column index
+ * @return the image stored at the given column index in the receiver
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
*/
-public Rectangle getImageBounds(int index) {
- checkWidget();
- Table parent = getParent();
- int itemIndex = parent.indexOf (this);
- int imageWidth = 0;
- Point imageExtent = parent.getImageExtent();
- 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;
- if (imageBounds.height > 0 && !parent.getLinesVisible()) {
- imageBounds.height -= parent.getGridLineWidth();
- }
- return imageBounds;
-}
-/**
- * Gets the image indent.
- *
- * @return the indent
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
+public Image getImage(int columnIndex) {
+ checkWidget();
+ 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;
+}
+/**
+ * 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 int getImageIndent() {
- checkWidget();
- 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.
+public Rectangle getImageBounds(int index) {
+ checkWidget();
+ Table parent = getParent();
+ int itemIndex = parent.indexOf (this);
+ int imageWidth = 0;
+ Point imageExtent = parent.getImageExtent();
+ 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;
+ if (imageBounds.height > 0 && !parent.getLinesVisible()) {
+ imageBounds.height -= parent.getGridLineWidth();
+ }
+ return imageBounds;
+}
+/**
+ * Gets the image indent.
+ *
+ * @return the indent
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
*/
-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.
+public int getImageIndent() {
+ checkWidget();
+ 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.
*/
-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 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.
*/
-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.
+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 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.
+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.
*/
-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 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.
*/
-int getMaxTextWidth(int columnIndex, int columnWidth) {
- int itemWidth = getImageStopX(columnIndex) + getTextIndent(columnIndex) * 2;
- return columnWidth - itemWidth;
-}
-/**
- * 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>
+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'
*/
-public Table getParent() {
- checkWidget();
- return (Table) super.getSelectableParent();
-}
-/**
- * Answer the width of the item required to display the complete contents.
+int getMaxTextWidth(int columnIndex, int columnWidth) {
+ int itemWidth = getImageStopX(columnIndex) + getTextIndent(columnIndex) * 2;
+ return columnWidth - itemWidth;
+}
+/**
+ * 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>
*/
-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
+public Table getParent() {
+ checkWidget();
+ return (Table) super.getSelectableParent();
+}
+/**
+ * Answer the width of the item required to display the complete contents.
*/
-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 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
*/
-int getSelectionX() {
- return getImageStopX(TableColumn.FIRST) + getParent().getHorizontalOffset();
-}
-public String getText() {
- checkWidget();
- return getText(0);
-}
-/**
- * Returns the text stored at the given column index in the receiver,
- * or empty string if the text has not been set.
- *
- * @param index the column index
- * @return the text stored at the given column index in the receiver
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- * @exception SWTError <ul>
- * <li>ERROR_CANNOT_GET_TEXT - if the column at index does not exist</li>
- * </ul>
+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
*/
-public String getText(int columnIndex) {
- checkWidget();
- 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
+int getSelectionX() {
+ return getImageStopX(TableColumn.FIRST) + getParent().getHorizontalOffset();
+}
+public String getText() {
+ checkWidget();
+ return getText(0);
+}
+/**
+ * Returns the text stored at the given column index in the receiver,
+ * or empty string if the text has not been set.
+ *
+ * @param index the column index
+ * @return the text stored at the given column index in the receiver
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * @exception SWTError <ul>
+ * <li>ERROR_CANNOT_GET_TEXT - if the column at index does not exist</li>
+ * </ul>
*/
-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.
+public String getText(int columnIndex) {
+ checkWidget();
+ 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
*/
-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 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.
*/
-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.
+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 [] getTrimmedTexts() {
- return trimmedLabels;
-}
-/**
- * Ensure that the image and label vectors have at least
- * 'newSize' number of elements.
+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.
*/
-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.
+String [] getTrimmedTexts() {
+ return trimmedLabels;
+}
+/**
+ * Ensure that the image and label vectors have at least
+ * 'newSize' number of elements.
*/
-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);
-
- String[] tempTrimmed = new String[trimmedLabels.length + 1];
- System.arraycopy(trimmedLabels, 0, tempTrimmed, 0, index);
- System.arraycopy(trimmedLabels, index, tempTrimmed, index + 1, trimmedLabels.length - index);
- trimmedLabels = tempTrimmed;
-
-}
-/**
- * Sets the image at an index.
- *
- * @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 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 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;
- }
- if (image != null && image.isDisposed()) error(SWT.ERROR_INVALID_ARGUMENT);
- 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.
- *
- * 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 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);
+
+ String[] tempTrimmed = new String[trimmedLabels.length + 1];
+ System.arraycopy(trimmedLabels, 0, tempTrimmed, 0, index);
+ System.arraycopy(trimmedLabels, index, tempTrimmed, index + 1, trimmedLabels.length - index);
+ trimmedLabels = tempTrimmed;
+
+}
+/**
+ * Sets the image at an index.
+ *
+ * @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 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
+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;
+ }
+ if (image != null && image.isDisposed()) error(SWT.ERROR_INVALID_ARGUMENT);
+ 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.
+ *
+ * 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
+ *
*/
-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 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
*/
-void notifyImageChanged(int columnIndex, boolean imageWasNull) {
- Table parent = getParent();
- Rectangle changedColumnBounds;
- Image currentImage;
- int redrawStartX = 0;
- int redrawWidth = 0;
- int columnCount = parent.internalGetColumnCount();
-
- if (columnIndex >= 0 && columnIndex < columnCount && parent.getVisibleRedrawY(this) != -1) {
- changedColumnBounds = parent.internalGetColumn(columnIndex).getBounds();
- currentImage = getImage(columnIndex);
- redrawStartX = Math.max(0, getImageBounds(columnIndex).x);
- if (parent.getImageExtent() != null && imageWasNull == false && currentImage != null) {
- 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.
+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 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 notifyImageChanged(int columnIndex, boolean imageWasNull) {
+ Table parent = getParent();
+ Rectangle changedColumnBounds;
+ Image currentImage;
+ int redrawStartX = 0;
+ int redrawWidth = 0;
+ int columnCount = parent.internalGetColumnCount();
+
+ if (columnIndex >= 0 && columnIndex < columnCount && parent.getVisibleRedrawY(this) != -1) {
+ changedColumnBounds = parent.internalGetColumn(columnIndex).getBounds();
+ currentImage = getImage(columnIndex);
+ redrawStartX = Math.max(0, getImageBounds(columnIndex).x);
+ if (parent.getImageExtent() != null && imageWasNull == false && currentImage != null) {
+ 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 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 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 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);
- }
-
- if (trimmedLabels.length == 1) {
- trimmedLabels = new String[0];
- } else {
- String[] tempTrimmed = new String[trimmedLabels.length - 1];
- System.arraycopy(trimmedLabels, 0, tempTrimmed, 0, index);
- System.arraycopy(trimmedLabels, index +1, tempTrimmed, index, trimmedLabels.length - index -1);
- trimmedLabels = tempTrimmed;
- }
-
-}
-/**
- * Reset the cached trimmed label for the sub item identified by
- * 'index'.
- * @param index - index of the label that should be reset.
+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 reset(int index) {
- String trimmedLabels[] = getTrimmedTexts();
-
- if (index >= 0 && index < trimmedLabels.length) {
- trimmedLabels[index] = null;
- }
- if (index == TableColumn.FIRST) {
- selectionExtent = null;
- }
-}
-
-void redraw(){
- Table parent = getParent();
- int y = parent.getRedrawY(this);
- parent.redraw(0, y, parent.getClientArea().width, parent.getItemHeight(), false);
-}
-/**
- * Sets the receiver's background color to the color specified
- * by the argument, or to the default system color for the item
- * if the argument is null.
- *
- * @param color the new color (or null)
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_INVALID_ARGUMENT - if the argument has been disposed</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @since 2.0
- *
+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);
+ }
+
+ if (trimmedLabels.length == 1) {
+ trimmedLabels = new String[0];
+ } else {
+ String[] tempTrimmed = new String[trimmedLabels.length - 1];
+ System.arraycopy(trimmedLabels, 0, tempTrimmed, 0, index);
+ System.arraycopy(trimmedLabels, index +1, tempTrimmed, index, trimmedLabels.length - index -1);
+ trimmedLabels = tempTrimmed;
+ }
+
+}
+/**
+ * Reset the cached trimmed label for the sub item identified by
+ * 'index'.
+ * @param index - index of the label that should be reset.
*/
-public void setBackground (Color color) {
- checkWidget ();
- if (color != null && color.isDisposed ())
- SWT.error (SWT.ERROR_INVALID_ARGUMENT);
- background = color;
- redraw();
-}
-/**
- * Sets the receiver's foreground color to the color specified
- * by the argument, or to the default system color for the item
- * if the argument is null.
- *
- * @param color the new color (or null)
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_INVALID_ARGUMENT - if the argument has been disposed</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @since 2.0
- *
+void reset(int index) {
+ String trimmedLabels[] = getTrimmedTexts();
+
+ if (index >= 0 && index < trimmedLabels.length) {
+ trimmedLabels[index] = null;
+ }
+ if (index == TableColumn.FIRST) {
+ selectionExtent = null;
+ }
+}
+
+void redraw(){
+ Table parent = getParent();
+ int y = parent.getRedrawY(this);
+ parent.redraw(0, y, parent.getClientArea().width, parent.getItemHeight(), false);
+}
+/**
+ * Sets the receiver's background color to the color specified
+ * by the argument, or to the default system color for the item
+ * if the argument is null.
+ *
+ * @param color the new color (or null)
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_INVALID_ARGUMENT - if the argument has been disposed</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @since 2.0
+ *
*/
-public void setForeground (Color color){
- checkWidget ();
- if (color != null && color.isDisposed ())
- SWT.error (SWT.ERROR_INVALID_ARGUMENT);
- foreground = color;
- redraw();
-}
-/**
- * Sets the image for multiple columns in the Table.
- *
- * @param images the array of new images
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the array of images is null</li>
- * <li>ERROR_INVALID_ARGUMENT - if one of the images has been disposed</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
+public void setBackground (Color color) {
+ checkWidget ();
+ if (color != null && color.isDisposed ())
+ SWT.error (SWT.ERROR_INVALID_ARGUMENT);
+ background = color;
+ redraw();
+}
+/**
+ * Sets the receiver's foreground color to the color specified
+ * by the argument, or to the default system color for the item
+ * if the argument is null.
+ *
+ * @param color the new color (or null)
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_INVALID_ARGUMENT - if the argument has been disposed</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @since 2.0
+ *
*/
-public void setImage(Image [] images) {
- checkWidget();
- 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 receiver's image at a column.
- *
- * @param index the column index
- * @param image the new image
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_INVALID_ARGUMENT - if the image has been disposed</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
+public void setForeground (Color color){
+ checkWidget ();
+ if (color != null && color.isDisposed ())
+ SWT.error (SWT.ERROR_INVALID_ARGUMENT);
+ foreground = color;
+ redraw();
+}
+/**
+ * Sets the image for multiple columns in the Table.
+ *
+ * @param images the array of new images
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if the array of images is null</li>
+ * <li>ERROR_INVALID_ARGUMENT - if one of the images has been disposed</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
*/
-public void setImage(int index, Image image) {
- checkWidget();
- if (getParent().indexOf(this) != -1) {
- internalSetImage(index, image);
- }
-}
-public void setImage(Image image) {
- checkWidget();
- setImage(0, image);
-}
-/**
- * Sets the image indent.
- *
- * @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 setImage(Image [] images) {
+ checkWidget();
+ 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 receiver's image at a column.
+ *
+ * @param index the column index
+ * @param image the new image
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_INVALID_ARGUMENT - if the image has been disposed</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
*/
-public void setImageIndent(int indent) {
- checkWidget();
- 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);
- }
-}
-/**
- * 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 setImage(int index, Image image) {
+ checkWidget();
+ if (getParent().indexOf(this) != -1) {
+ internalSetImage(index, image);
+ }
+}
+public void setImage(Image image) {
+ checkWidget();
+ setImage(0, image);
+}
+/**
+ * Sets the image indent.
+ *
+ * @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 setText(String [] strings) {
- checkWidget();
- 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 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 setImageIndent(int indent) {
+ checkWidget();
+ 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);
+ }
+}
+/**
+ * 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 (int index, String string) {
- checkWidget();
- if (string == null) {
- error(SWT.ERROR_NULL_ARGUMENT);
- }
- if (getParent().indexOf(this) != -1) {
- internalSetText(index, string);
- }
-}
-public void setText(String text) {
- checkWidget();
- 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.
+public void setText(String [] strings) {
+ checkWidget();
+ 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 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>
*/
-void setTrimmedText(String label, int columnIndex) {
- String labels[] = getTrimmedTexts();
-
- if (columnIndex < labels.length) {
- labels[columnIndex] = label;
- }
-}
-/**
- * Sets the checked state of the checkbox for this item. This state change
- * only applies if the Table was created with the SWT.CHECK style.
- *
- * @param checked the new checked state of the checkbox
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
+public void setText (int index, String string) {
+ checkWidget();
+ if (string == null) {
+ error(SWT.ERROR_NULL_ARGUMENT);
+ }
+ if (getParent().indexOf(this) != -1) {
+ internalSetText(index, string);
+ }
+}
+public void setText(String text) {
+ checkWidget();
+ 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.
*/
-public void setChecked(boolean checked) {
- checkWidget();
- super.setChecked(checked);
-}
-/**
- * Sets the grayed state of the checkbox for this item. This state change
- * only applies if the Table was created with the SWT.CHECK style.
- *
- * @param grayed the new grayed state of the checkbox
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
+void setTrimmedText(String label, int columnIndex) {
+ String labels[] = getTrimmedTexts();
+
+ if (columnIndex < labels.length) {
+ labels[columnIndex] = label;
+ }
+}
+/**
+ * Sets the checked state of the checkbox for this item. This state change
+ * only applies if the Table was created with the SWT.CHECK style.
+ *
+ * @param checked the new checked state of the checkbox
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
*/
-public void setGrayed (boolean grayed) {
- checkWidget();
- super.setGrayed(grayed);
-}
-/**
- * Set the index of this item in its parent widget to 'newIndex'.
+public void setChecked(boolean checked) {
+ checkWidget();
+ super.setChecked(checked);
+}
+/**
+ * Sets the grayed state of the checkbox for this item. This state change
+ * only applies if the Table was created with the SWT.CHECK style.
+ *
+ * @param grayed the new grayed state of the checkbox
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
*/
-void setIndex(int newIndex) {
- index = newIndex;
-}
-
-}
-
+public void setGrayed (boolean grayed) {
+ checkWidget();
+ super.setGrayed(grayed);
+}
+/**
+ * Set the index of this item in its parent widget to 'newIndex'.
+ */
+void setIndex(int newIndex) {
+ index = newIndex;
+}
+
+}
+
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/emulated/treetable/org/eclipse/swt/widgets/Tree.java b/bundles/org.eclipse.swt/Eclipse SWT/emulated/treetable/org/eclipse/swt/widgets/Tree.java
index 5ba359ac39..8c6e90d894 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/emulated/treetable/org/eclipse/swt/widgets/Tree.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/emulated/treetable/org/eclipse/swt/widgets/Tree.java
@@ -1,1657 +1,1657 @@
-package org.eclipse.swt.widgets;
-
-/*
+package org.eclipse.swt.widgets;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-import org.eclipse.swt.*;
-import org.eclipse.swt.events.*;
-import org.eclipse.swt.graphics.*;
-import java.util.Enumeration;
-import java.util.Stack;
-import java.util.Vector;
-
-/**
- * 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>
- * The item children that may be added to instances of this class
- * must be of type <code>TreeItem</code>.
- * </p><p>
- * Note that although this class is a subclass of <code>Composite</code>,
- * it does not make sense to add <code>Control</code> children to it,
- * or set a layout on it.
- * </p><p>
- * <dl>
- * <dt><b>Styles:</b></dt>
- * <dd>SINGLE, MULTI, CHECK</dd>
- * <dt><b>Events:</b></dt>
- * <dd>Selection, DefaultSelection, Collapse, Expand</dd>
- * </dl>
- * <p>
- * Note: Only one of the styles SINGLE and MULTI may be specified.
- * </p><p>
- * IMPORTANT: This class is <em>not</em> intended to be subclassed.
- * </p>
- */
-public 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)
-
-/**
- * Constructs a new instance of this class given its parent
- * and a style value describing its behavior and appearance.
- * <p>
- * The style value is either one of the style constants defined in
- * class <code>SWT</code> which is applicable to instances of this
- * class, or must be built by <em>bitwise OR</em>'ing together
- * (that is, using the <code>int</code> "|" operator) two or more
- * of those <code>SWT</code> style constants. The class description
- * lists the style constants that are applicable to the class.
- * Style bits are also inherited from superclasses.
- * </p>
- *
- * @param parent a composite control which will be the parent of the new instance (cannot be null)
- * @param style the style of control to construct
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
- * <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
- * </ul>
- *
- * @see SWT#SINGLE
- * @see SWT#MULTI
- * @see SWT#CHECK
- * @see Widget#checkSubclass
- * @see Widget#getStyle
- */
-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 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.
- * <p>
- * When <code>widgetSelected</code> is called, the item field of the event object is valid.
- * If the reciever has <code>SWT.CHECK</code> style set and the check selection changes,
- * the event object detail field contains the value <code>SWT.CHECK</code>.
- * <code>widgetDefaultSelected</code> is typically called when an item is double-clicked.
- * The item field of the event object is valid for default selection, but the detail field is not used.
- * </p>
- *
- * @param listener the listener which should be notified
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see SelectionListener
- * @see #removeSelectionListener
- * @see SelectionEvent
- */
-public void addSelectionListener(SelectionListener listener) {
- checkWidget();
- 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 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();
- 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) {
-
- 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);
-}
-
-public Point computeSize(int wHint, int hHint, boolean changed) {
- checkWidget();
- 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 (wHint == SWT.DEFAULT && 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;
-}
-/**
- * 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();
- 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.MOD1) {
- 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.MOD1) {
- 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();
- boolean nestedExpand = expandingItem != null;
-
- if (item.getExpanded() == true || item.getExpanding() == true) {
- return;
- }
- item.setExpanding(true);
- if (nestedExpand == false) {
- setExpandingItem(item);
- }
- if (notifyListeners == true) {
- event.item = item;
- notifyListeners(SWT.Expand, event);
- }
- scrollForExpand(item);
- item.internalSetExpanded(true);
- // redraw hierarchy image
- item.redrawExpanded(item.getVisibleIndex() - getTopIndex());
- calculateVerticalScrollbar();
- if (nestedExpand == false && isVisible() == true) {
- 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);
- }
- item.setExpanding(false);
-}
-/**
- * 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;
-}
-/**
- * Returns the number of items contained in the receiver
- * that are direct item children of the receiver. The
- * number that is returned is the number of roots in the
- * tree.
- *
- * @return the number of items
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public int getItemCount() {
- checkWidget();
- return getRoot().getItemCount();
-}
-/**
- * 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 super.getItemHeight();
-}
-/**
- * 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 affect 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();
- 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;
-}
-/**
- * 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;
-}
-/**
- * Answer the object that holds the root items of the receiver.
- */
-TreeRoots getRoot() {
- return root;
-}
-/**
- * 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 affect the receiver.
- * </p>
- * @return an array representing the selection
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public TreeItem [] getSelection() {
- checkWidget();
- 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 || itemAction(hitItem, event.x, event.y) != ActionSelect) {
- return;
- }
- if (isListening(SWT.DefaultSelection) == true) {
- newEvent = new Event();
- newEvent.item = hitItem;
- notifyListeners(SWT.DefaultSelection, newEvent);
- }
- else
- if (hitItem.isLeaf() == false) { // item with children was hit. Default behavior is expand/collapse item
- 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;
-
- hitItemIndex = event.y / getItemHeight();
- hitItem = getRoot().getVisibleItem(hitItemIndex + getTopIndex());
- if (hitItem == null) {
- return;
- }
- if (!isFocusControl()) forceFocus();
- switch (itemAction = itemAction(hitItem, event.x, event.y)) {
- case ActionExpandCollapse:
- if (event.button != 1) return;
- 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:
- if (event.button != 1) return;
- 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;
-}
-
-/**
- * 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();
- 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 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);
- }
- removeListener (SWT.Selection, listener);
- removeListener (SWT.DefaultSelection, listener);
-}
-/**
- * Removes the listener from the collection of listeners who will
- * be notified when items in the receiver are expanded or collapsed..
- *
- * @param listener the listener which should no longer be notified
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see TreeListener
- * @see #addTreeListener
- */
-public void removeTreeListener(TreeListener listener) {
- checkWidget();
- if (listener == null) {
- 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, true);
- }
- }
- 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);
-}
-/**
- * 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();
- 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;
-}
-public void setFont(Font font) {
- checkWidget();
- 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.
- *
- * @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 IllegalArgumentException <ul>
- * <li>ERROR_INVALID_ARGUMENT - if the item has been disposed</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public void setInsertMark(TreeItem item, boolean before){
- checkWidget();
- if (item != null && item.isDisposed()) error(SWT.ERROR_INVALID_ARGUMENT);
- motif_setInsertMark(item, !before);
-}
-/**
- * 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 array of items is null</li>
- * <li>ERROR_INVALID_ARGUMENT - if one of the item has been disposed</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see Tree#deselectAll()
- */
-public void setSelection(TreeItem selectionItems[]) {
- checkWidget();
- 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);
-}
-public void setTopItem(TreeItem item) {
- checkWidget();
- if (item == null) error(SWT.ERROR_NULL_ARGUMENT);
- if (item.isDisposed()) error(SWT.ERROR_INVALID_ARGUMENT);
- if (item.isVisible() == false) {
- item.makeVisible();
- }
- scrollExpandedItemsIntoView(item);
-}
-/**
- * Shows the item. If the item is already showing in the receiver,
- * this method simply returns. Otherwise, the items are scrolled
- * and expanded until the item is visible.
- *
- * @param item the item to be shown
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the item is null</li>
- * <li>ERROR_INVALID_ARGUMENT - if the item has been disposed</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see Tree#showSelection()
- */
-public void showItem(TreeItem item) {
- checkWidget();
- if (item == null) error (SWT.ERROR_NULL_ARGUMENT);
- if (item.isDisposed()) error(SWT.ERROR_INVALID_ARGUMENT);
- 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);
-}
-/**
- * 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);
- 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 pt = new Point(point.x, point.y);
- pt.x -= hitItem.getPaintStartX();
- pt.y -= itemHeight * hitItemIndex;
- if (hitItem.isSelectionHit(pt) == false) {
- hitItem = null;
- }
- }
- return hitItem;
-}
-/**
- * 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 super.getSelectionCount();
-}
-public TreeItem getTopItem() {
- checkWidget();
- return (TreeItem)getVisibleItem(getTopIndex());
-}
-/**
- * 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();
- super.showSelection();
-}
-
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+import org.eclipse.swt.*;
+import org.eclipse.swt.events.*;
+import org.eclipse.swt.graphics.*;
+import java.util.Enumeration;
+import java.util.Stack;
+import java.util.Vector;
+
+/**
+ * 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>
+ * The item children that may be added to instances of this class
+ * must be of type <code>TreeItem</code>.
+ * </p><p>
+ * Note that although this class is a subclass of <code>Composite</code>,
+ * it does not make sense to add <code>Control</code> children to it,
+ * or set a layout on it.
+ * </p><p>
+ * <dl>
+ * <dt><b>Styles:</b></dt>
+ * <dd>SINGLE, MULTI, CHECK</dd>
+ * <dt><b>Events:</b></dt>
+ * <dd>Selection, DefaultSelection, Collapse, Expand</dd>
+ * </dl>
+ * <p>
+ * Note: Only one of the styles SINGLE and MULTI may be specified.
+ * </p><p>
+ * IMPORTANT: This class is <em>not</em> intended to be subclassed.
+ * </p>
+ */
+public 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)
+
+/**
+ * Constructs a new instance of this class given its parent
+ * and a style value describing its behavior and appearance.
+ * <p>
+ * The style value is either one of the style constants defined in
+ * class <code>SWT</code> which is applicable to instances of this
+ * class, or must be built by <em>bitwise OR</em>'ing together
+ * (that is, using the <code>int</code> "|" operator) two or more
+ * of those <code>SWT</code> style constants. The class description
+ * lists the style constants that are applicable to the class.
+ * Style bits are also inherited from superclasses.
+ * </p>
+ *
+ * @param parent a composite control which will be the parent of the new instance (cannot be null)
+ * @param style the style of control to construct
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
+ * <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
+ * </ul>
+ *
+ * @see SWT#SINGLE
+ * @see SWT#MULTI
+ * @see SWT#CHECK
+ * @see Widget#checkSubclass
+ * @see Widget#getStyle
+ */
+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 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.
+ * <p>
+ * When <code>widgetSelected</code> is called, the item field of the event object is valid.
+ * If the reciever has <code>SWT.CHECK</code> style set and the check selection changes,
+ * the event object detail field contains the value <code>SWT.CHECK</code>.
+ * <code>widgetDefaultSelected</code> is typically called when an item is double-clicked.
+ * The item field of the event object is valid for default selection, but the detail field is not used.
+ * </p>
+ *
+ * @param listener the listener which should be notified
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see SelectionListener
+ * @see #removeSelectionListener
+ * @see SelectionEvent
+ */
+public void addSelectionListener(SelectionListener listener) {
+ checkWidget();
+ 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 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();
+ 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) {
+
+ 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);
+}
+
+public Point computeSize(int wHint, int hHint, boolean changed) {
+ checkWidget();
+ 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 (wHint == SWT.DEFAULT && 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;
+}
+/**
+ * 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();
+ 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.MOD1) {
+ 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.MOD1) {
+ 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();
+ boolean nestedExpand = expandingItem != null;
+
+ if (item.getExpanded() == true || item.getExpanding() == true) {
+ return;
+ }
+ item.setExpanding(true);
+ if (nestedExpand == false) {
+ setExpandingItem(item);
+ }
+ if (notifyListeners == true) {
+ event.item = item;
+ notifyListeners(SWT.Expand, event);
+ }
+ scrollForExpand(item);
+ item.internalSetExpanded(true);
+ // redraw hierarchy image
+ item.redrawExpanded(item.getVisibleIndex() - getTopIndex());
+ calculateVerticalScrollbar();
+ if (nestedExpand == false && isVisible() == true) {
+ 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);
+ }
+ item.setExpanding(false);
+}
+/**
+ * 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;
+}
+/**
+ * Returns the number of items contained in the receiver
+ * that are direct item children of the receiver. The
+ * number that is returned is the number of roots in the
+ * tree.
+ *
+ * @return the number of items
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public int getItemCount() {
+ checkWidget();
+ return getRoot().getItemCount();
+}
+/**
+ * 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 super.getItemHeight();
+}
+/**
+ * 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 affect 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();
+ 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;
+}
+/**
+ * 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;
+}
+/**
+ * Answer the object that holds the root items of the receiver.
+ */
+TreeRoots getRoot() {
+ return root;
+}
+/**
+ * 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 affect the receiver.
+ * </p>
+ * @return an array representing the selection
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public TreeItem [] getSelection() {
+ checkWidget();
+ 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 || itemAction(hitItem, event.x, event.y) != ActionSelect) {
+ return;
+ }
+ if (isListening(SWT.DefaultSelection) == true) {
+ newEvent = new Event();
+ newEvent.item = hitItem;
+ notifyListeners(SWT.DefaultSelection, newEvent);
+ }
+ else
+ if (hitItem.isLeaf() == false) { // item with children was hit. Default behavior is expand/collapse item
+ 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;
+
+ hitItemIndex = event.y / getItemHeight();
+ hitItem = getRoot().getVisibleItem(hitItemIndex + getTopIndex());
+ if (hitItem == null) {
+ return;
+ }
+ if (!isFocusControl()) forceFocus();
+ switch (itemAction = itemAction(hitItem, event.x, event.y)) {
+ case ActionExpandCollapse:
+ if (event.button != 1) return;
+ 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:
+ if (event.button != 1) return;
+ 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;
+}
+
+/**
+ * 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();
+ 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 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);
+ }
+ removeListener (SWT.Selection, listener);
+ removeListener (SWT.DefaultSelection, listener);
+}
+/**
+ * Removes the listener from the collection of listeners who will
+ * be notified when items in the receiver are expanded or collapsed..
+ *
+ * @param listener the listener which should no longer be notified
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see TreeListener
+ * @see #addTreeListener
+ */
+public void removeTreeListener(TreeListener listener) {
+ checkWidget();
+ if (listener == null) {
+ 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, true);
+ }
+ }
+ 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);
+}
+/**
+ * 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();
+ 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;
+}
+public void setFont(Font font) {
+ checkWidget();
+ 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.
+ *
+ * @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 IllegalArgumentException <ul>
+ * <li>ERROR_INVALID_ARGUMENT - if the item has been disposed</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setInsertMark(TreeItem item, boolean before){
+ checkWidget();
+ if (item != null && item.isDisposed()) error(SWT.ERROR_INVALID_ARGUMENT);
+ motif_setInsertMark(item, !before);
+}
+/**
+ * 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 array of items is null</li>
+ * <li>ERROR_INVALID_ARGUMENT - if one of the item has been disposed</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see Tree#deselectAll()
+ */
+public void setSelection(TreeItem selectionItems[]) {
+ checkWidget();
+ 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);
+}
+public void setTopItem(TreeItem item) {
+ checkWidget();
+ if (item == null) error(SWT.ERROR_NULL_ARGUMENT);
+ if (item.isDisposed()) error(SWT.ERROR_INVALID_ARGUMENT);
+ if (item.isVisible() == false) {
+ item.makeVisible();
+ }
+ scrollExpandedItemsIntoView(item);
+}
+/**
+ * Shows the item. If the item is already showing in the receiver,
+ * this method simply returns. Otherwise, the items are scrolled
+ * and expanded until the item is visible.
+ *
+ * @param item the item to be shown
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if the item is null</li>
+ * <li>ERROR_INVALID_ARGUMENT - if the item has been disposed</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see Tree#showSelection()
+ */
+public void showItem(TreeItem item) {
+ checkWidget();
+ if (item == null) error (SWT.ERROR_NULL_ARGUMENT);
+ if (item.isDisposed()) error(SWT.ERROR_INVALID_ARGUMENT);
+ 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);
+}
+/**
+ * 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);
+ 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 pt = new Point(point.x, point.y);
+ pt.x -= hitItem.getPaintStartX();
+ pt.y -= itemHeight * hitItemIndex;
+ if (hitItem.isSelectionHit(pt) == false) {
+ hitItem = null;
+ }
+ }
+ return hitItem;
+}
+/**
+ * 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 super.getSelectionCount();
+}
+public TreeItem getTopItem() {
+ checkWidget();
+ return (TreeItem)getVisibleItem(getTopIndex());
+}
+/**
+ * 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();
+ super.showSelection();
+}
+
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/emulated/treetable/org/eclipse/swt/widgets/TreeItem.java b/bundles/org.eclipse.swt/Eclipse SWT/emulated/treetable/org/eclipse/swt/widgets/TreeItem.java
index 2894f062b8..e12d74dc14 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/emulated/treetable/org/eclipse/swt/widgets/TreeItem.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/emulated/treetable/org/eclipse/swt/widgets/TreeItem.java
@@ -1,1358 +1,1358 @@
-package org.eclipse.swt.widgets;
-
-/*
+package org.eclipse.swt.widgets;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-import org.eclipse.swt.*;
-import org.eclipse.swt.graphics.*;
-import java.util.Enumeration;
-import java.util.Vector;
-
-/**
- * Instances of this class represent a selectable user interface object
- * that represents a hierarchy of tree items in a tree widget.
- *
- * <dl>
- * <dt><b>Styles:</b></dt>
- * <dd>(none)</dd>
- * <dt><b>Events:</b></dt>
- * <dd>(none)</dd>
- * </dl>
- * <p>
- * IMPORTANT: This class is <em>not</em> intended to be subclassed.
- * </p>
- */
-public class TreeItem extends AbstractTreeItem {
-/*
- * This class caches geometric 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;
- */
- 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
-
-
- //Determine whether the item is being expanded
- private boolean isExpanding = false;
- Color background = null;
- Color foreground = null;
-
-/**
- * Constructs a new instance of this class given its parent
- * (which must be a <code>Tree</code> or a <code>TreeItem</code>)
- * and a style value describing its behavior and appearance.
- * The item is added to the end of the items maintained by its parent.
- * <p>
- * The style value is either one of the style constants defined in
- * class <code>SWT</code> which is applicable to instances of this
- * class, or must be built by <em>bitwise OR</em>'ing together
- * (that is, using the <code>int</code> "|" operator) two or more
- * of those <code>SWT</code> style constants. The class description
- * lists the style constants that are applicable to the class.
- * Style bits are also inherited from superclasses.
- * </p>
- *
- * @param parent a 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 TreeItem(Tree parent, int style) {
- this(parent, style, checkNull(parent).getItemCount());
-}
-
-/**
- * Constructs a new instance of this class given its parent
- * (which must be a <code>Tree</code> or a <code>TreeItem</code>),
- * a style value describing its behavior and appearance, and the index
- * at which to place it in the items maintained by its parent.
- * <p>
- * The style value is either one of the style constants defined in
- * class <code>SWT</code> which is applicable to instances of this
- * class, or must be built by <em>bitwise OR</em>'ing together
- * (that is, using the <code>int</code> "|" operator) two or more
- * of those <code>SWT</code> style constants. The class description
- * lists the style constants that are applicable to the class.
- * Style bits are also inherited from superclasses.
- * </p>
- *
- * @param parent a 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 TreeItem(Tree parent, int style, int index) {
- super(parent, style);
- parent.addItem(this, index);
-}
-
-/**
- * Constructs a new instance of this class given its parent
- * (which must be a <code>Tree</code> or a <code>TreeItem</code>)
- * and a style value describing its behavior and appearance.
- * The item is added to the end of the items maintained by its parent.
- * <p>
- * The style value is either one of the style constants defined in
- * class <code>SWT</code> which is applicable to instances of this
- * class, or must be built by <em>bitwise OR</em>'ing together
- * (that is, using the <code>int</code> "|" operator) two or more
- * of those <code>SWT</code> style constants. The class description
- * lists the style constants that are applicable to the class.
- * Style bits are also inherited from superclasses.
- * </p>
- *
- * @param parentItem a 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 TreeItem(TreeItem parentItem, int style) {
- this(parentItem, style, checkNull(parentItem).getItemCount());
-}
-
-/**
- * Constructs a new instance of this class given its parent
- * (which must be a <code>Tree</code> or a <code>TreeItem</code>),
- * a style value describing its behavior and appearance, and the index
- * at which to place it in the items maintained by its parent.
- * <p>
- * The style value is either one of the style constants defined in
- * class <code>SWT</code> which is applicable to instances of this
- * class, or must be built by <em>bitwise OR</em>'ing together
- * (that is, using the <code>int</code> "|" operator) two or more
- * of those <code>SWT</code> style constants. The class description
- * lists the style constants that are applicable to the class.
- * Style bits are also inherited from superclasses.
- * </p>
- *
- * @param parentItem a 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 TreeItem(TreeItem parentItem, int style, int index) {
- super(checkNull(parentItem).getParent(), style);
- setParentItem(parentItem);
- parentItem.add(this, index);
-}
-
-/**
- * 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);
-}
-
-/**
- * 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 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 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;
-}
-/**
- * Returns the receiver's background color.
- *
- * @return the background color
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @since 2.0
- *
- */
-public Color getBackground () {
- checkWidget ();
- if (background != null) return background;
- Tree parent = getParent();
- return parent.getBackground();
-}
-/**
- * Returns a rectangle describing the receiver's size and location
- * relative to its parent.
- *
- * @return the receiver's bounding rectangle
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public Rectangle getBounds() {
- checkWidget();
- 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;
-}
-/**
- * Returns the foreground color that the receiver will use to draw.
- *
- * @return the receiver's foreground color
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @since 2.0
- *
- */
-public Color getForeground () {
- checkWidget ();
- if (foreground != null) return foreground;
- Tree parent = getParent();
- return parent.getForeground();
-}
-/**
- * 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;
-}
-/**
- * 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();
- 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;
-}
-/**
- * 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 affect the receiver.
- * </p>
- *
- * @return the receiver's items
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public TreeItem [] getItems() {
- checkWidget();
- 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());
-}
-/**
- * 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 (Tree) super.getSelectableParent();
-}
-/**
- * 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 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) {
- if (isVisible() == false) {
- return;
- }
-
- Tree parent = getParent();
- Point paintPosition = new Point(getPaintStartX(), yPosition);
- Point extent = getSelectionExtent();
- 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));
- if (isSelected() == true) {
- gc.setBackground(getSelectionBackgroundColor());
- gc.setForeground(getSelectionForegroundColor());
- gc.fillRectangle(paintPosition.x, paintPosition.y, extent.x, extent.y);
- } else {
- gc.setBackground(getBackground());
- gc.setForeground(getForeground());
- if(getBackground() != parent.getBackground()){
- gc.fillRectangle(paintPosition.x, paintPosition.y, extent.x, extent.y);
- }
- }
- if (text != null) {
- gc.drawString(text, getTextXPos(), paintPosition.y + getTextYPosition(gc), true);
- }
- if (this == parent.getInsertItem()) {
- drawInsertMark(gc, paintPosition);
- }
- drawSelectionFocus(gc, paintPosition);
-}
-
-void redraw(){
- Rectangle bounds = getBounds();
- getParent().redraw(bounds.x, bounds.y, bounds.width, bounds.height, false);
-}
-
-/**
- * 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);
-}
-/**
- * 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 expand) {
- checkWidget();
- if (isLeaf() == false && expand == true) {
- getParent().expand(this, false);
- }
- else {
- getParent().collapse(this, false);
- }
-}
-public void setImage(Image newImage) {
- checkWidget();
- 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;
-}
-/**
- * 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) {
- checkWidget();
- 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;
-}
-
-public void dispose() {
- if (isDisposed()) return;
- // 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
- Tree parent = getParent();
- if (parent.isRemovingAll() == false) {
- parent.collapseNoRedraw(this);
- }
-
- if (parentItem != null) {
- parentItem.removeItem(this);
- }
- else {
- parent.removeItem(this);
- }
-
- super.dispose();
-}
-
-void doDispose() {
- // Notify the parent that the receiver is being removed.
- // Reset cached data.
- setParentItem(null);
- setImageExtent(null);
- setItemExtent(null);
- setIndex(-1);
- setPaintStartX(-1);
- setTextYPosition(-1);
-
- super.doDispose();
-}
-/**
- * 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();
- return super.getChecked();
-}
-public Display getDisplay() {
- return super.getDisplay();
-}
-boolean getExpanding(){
- return isExpanding;
-}
-/**
- * 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();
- return super.getGrayed();
-}
-/**
- * Sets the receiver's background color to the color specified
- * by the argument, or to the default system color for the item
- * if the argument is null.
- *
- * @param color the new color (or null)
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_INVALID_ARGUMENT - if the argument has been disposed</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @since 2.0
- *
- */
-public void setBackground (Color color) {
- checkWidget ();
- if (color != null && color.isDisposed ())
- SWT.error (SWT.ERROR_INVALID_ARGUMENT);
- background = color;
- redraw();
-}
-/**
- * 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();
- super.setChecked(checked);
-}
-void setExpanding(boolean expanding){
- isExpanding = expanding;
-}
-/**
- * Sets the receiver's foreground color to the color specified
- * by the argument, or to the default system color for the item
- * if the argument is null.
- *
- * @param color the new color (or null)
- *
- * @since 2.0
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_INVALID_ARGUMENT - if the argument has been disposed</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @since 2.0
- *
- */
-public void setForeground (Color color) {
- checkWidget ();
- if (color != null && color.isDisposed ())
- SWT.error (SWT.ERROR_INVALID_ARGUMENT);
- foreground = color;
- redraw();
-}
-/**
- * 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();
- super.setGrayed(grayed);
-}
-
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+import org.eclipse.swt.*;
+import org.eclipse.swt.graphics.*;
+import java.util.Enumeration;
+import java.util.Vector;
+
+/**
+ * Instances of this class represent a selectable user interface object
+ * that represents a hierarchy of tree items in a tree widget.
+ *
+ * <dl>
+ * <dt><b>Styles:</b></dt>
+ * <dd>(none)</dd>
+ * <dt><b>Events:</b></dt>
+ * <dd>(none)</dd>
+ * </dl>
+ * <p>
+ * IMPORTANT: This class is <em>not</em> intended to be subclassed.
+ * </p>
+ */
+public class TreeItem extends AbstractTreeItem {
+/*
+ * This class caches geometric 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;
+ */
+ 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
+
+
+ //Determine whether the item is being expanded
+ private boolean isExpanding = false;
+ Color background = null;
+ Color foreground = null;
+
+/**
+ * Constructs a new instance of this class given its parent
+ * (which must be a <code>Tree</code> or a <code>TreeItem</code>)
+ * and a style value describing its behavior and appearance.
+ * The item is added to the end of the items maintained by its parent.
+ * <p>
+ * The style value is either one of the style constants defined in
+ * class <code>SWT</code> which is applicable to instances of this
+ * class, or must be built by <em>bitwise OR</em>'ing together
+ * (that is, using the <code>int</code> "|" operator) two or more
+ * of those <code>SWT</code> style constants. The class description
+ * lists the style constants that are applicable to the class.
+ * Style bits are also inherited from superclasses.
+ * </p>
+ *
+ * @param parent a 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 TreeItem(Tree parent, int style) {
+ this(parent, style, checkNull(parent).getItemCount());
+}
+
+/**
+ * Constructs a new instance of this class given its parent
+ * (which must be a <code>Tree</code> or a <code>TreeItem</code>),
+ * a style value describing its behavior and appearance, and the index
+ * at which to place it in the items maintained by its parent.
+ * <p>
+ * The style value is either one of the style constants defined in
+ * class <code>SWT</code> which is applicable to instances of this
+ * class, or must be built by <em>bitwise OR</em>'ing together
+ * (that is, using the <code>int</code> "|" operator) two or more
+ * of those <code>SWT</code> style constants. The class description
+ * lists the style constants that are applicable to the class.
+ * Style bits are also inherited from superclasses.
+ * </p>
+ *
+ * @param parent a 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 TreeItem(Tree parent, int style, int index) {
+ super(parent, style);
+ parent.addItem(this, index);
+}
+
+/**
+ * Constructs a new instance of this class given its parent
+ * (which must be a <code>Tree</code> or a <code>TreeItem</code>)
+ * and a style value describing its behavior and appearance.
+ * The item is added to the end of the items maintained by its parent.
+ * <p>
+ * The style value is either one of the style constants defined in
+ * class <code>SWT</code> which is applicable to instances of this
+ * class, or must be built by <em>bitwise OR</em>'ing together
+ * (that is, using the <code>int</code> "|" operator) two or more
+ * of those <code>SWT</code> style constants. The class description
+ * lists the style constants that are applicable to the class.
+ * Style bits are also inherited from superclasses.
+ * </p>
+ *
+ * @param parentItem a 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 TreeItem(TreeItem parentItem, int style) {
+ this(parentItem, style, checkNull(parentItem).getItemCount());
+}
+
+/**
+ * Constructs a new instance of this class given its parent
+ * (which must be a <code>Tree</code> or a <code>TreeItem</code>),
+ * a style value describing its behavior and appearance, and the index
+ * at which to place it in the items maintained by its parent.
+ * <p>
+ * The style value is either one of the style constants defined in
+ * class <code>SWT</code> which is applicable to instances of this
+ * class, or must be built by <em>bitwise OR</em>'ing together
+ * (that is, using the <code>int</code> "|" operator) two or more
+ * of those <code>SWT</code> style constants. The class description
+ * lists the style constants that are applicable to the class.
+ * Style bits are also inherited from superclasses.
+ * </p>
+ *
+ * @param parentItem a 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 TreeItem(TreeItem parentItem, int style, int index) {
+ super(checkNull(parentItem).getParent(), style);
+ setParentItem(parentItem);
+ parentItem.add(this, index);
+}
+
+/**
+ * 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);
+}
+
+/**
+ * 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 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 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;
+}
+/**
+ * Returns the receiver's background color.
+ *
+ * @return the background color
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @since 2.0
+ *
+ */
+public Color getBackground () {
+ checkWidget ();
+ if (background != null) return background;
+ Tree parent = getParent();
+ return parent.getBackground();
+}
+/**
+ * Returns a rectangle describing the receiver's size and location
+ * relative to its parent.
+ *
+ * @return the receiver's bounding rectangle
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public Rectangle getBounds() {
+ checkWidget();
+ 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;
+}
+/**
+ * Returns the foreground color that the receiver will use to draw.
+ *
+ * @return the receiver's foreground color
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @since 2.0
+ *
+ */
+public Color getForeground () {
+ checkWidget ();
+ if (foreground != null) return foreground;
+ Tree parent = getParent();
+ return parent.getForeground();
+}
+/**
+ * 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;
+}
+/**
+ * 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();
+ 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;
+}
+/**
+ * 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 affect the receiver.
+ * </p>
+ *
+ * @return the receiver's items
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public TreeItem [] getItems() {
+ checkWidget();
+ 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());
+}
+/**
+ * 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 (Tree) super.getSelectableParent();
+}
+/**
+ * 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 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) {
+ if (isVisible() == false) {
+ return;
+ }
+
+ Tree parent = getParent();
+ Point paintPosition = new Point(getPaintStartX(), yPosition);
+ Point extent = getSelectionExtent();
+ 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));
+ if (isSelected() == true) {
+ gc.setBackground(getSelectionBackgroundColor());
+ gc.setForeground(getSelectionForegroundColor());
+ gc.fillRectangle(paintPosition.x, paintPosition.y, extent.x, extent.y);
+ } else {
+ gc.setBackground(getBackground());
+ gc.setForeground(getForeground());
+ if(getBackground() != parent.getBackground()){
+ gc.fillRectangle(paintPosition.x, paintPosition.y, extent.x, extent.y);
+ }
+ }
+ if (text != null) {
+ gc.drawString(text, getTextXPos(), paintPosition.y + getTextYPosition(gc), true);
+ }
+ if (this == parent.getInsertItem()) {
+ drawInsertMark(gc, paintPosition);
+ }
+ drawSelectionFocus(gc, paintPosition);
+}
+
+void redraw(){
+ Rectangle bounds = getBounds();
+ getParent().redraw(bounds.x, bounds.y, bounds.width, bounds.height, false);
+}
+
+/**
+ * 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);
+}
+/**
+ * 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 expand) {
+ checkWidget();
+ if (isLeaf() == false && expand == true) {
+ getParent().expand(this, false);
+ }
+ else {
+ getParent().collapse(this, false);
+ }
+}
+public void setImage(Image newImage) {
+ checkWidget();
+ 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;
+}
+/**
+ * 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) {
+ checkWidget();
+ 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;
+}
+
+public void dispose() {
+ if (isDisposed()) return;
+ // 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
+ Tree parent = getParent();
+ if (parent.isRemovingAll() == false) {
+ parent.collapseNoRedraw(this);
+ }
+
+ if (parentItem != null) {
+ parentItem.removeItem(this);
+ }
+ else {
+ parent.removeItem(this);
+ }
+
+ super.dispose();
+}
+
+void doDispose() {
+ // Notify the parent that the receiver is being removed.
+ // Reset cached data.
+ setParentItem(null);
+ setImageExtent(null);
+ setItemExtent(null);
+ setIndex(-1);
+ setPaintStartX(-1);
+ setTextYPosition(-1);
+
+ super.doDispose();
+}
+/**
+ * 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();
+ return super.getChecked();
+}
+public Display getDisplay() {
+ return super.getDisplay();
+}
+boolean getExpanding(){
+ return isExpanding;
+}
+/**
+ * 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();
+ return super.getGrayed();
+}
+/**
+ * Sets the receiver's background color to the color specified
+ * by the argument, or to the default system color for the item
+ * if the argument is null.
+ *
+ * @param color the new color (or null)
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_INVALID_ARGUMENT - if the argument has been disposed</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @since 2.0
+ *
+ */
+public void setBackground (Color color) {
+ checkWidget ();
+ if (color != null && color.isDisposed ())
+ SWT.error (SWT.ERROR_INVALID_ARGUMENT);
+ background = color;
+ redraw();
+}
+/**
+ * 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();
+ super.setChecked(checked);
+}
+void setExpanding(boolean expanding){
+ isExpanding = expanding;
+}
+/**
+ * Sets the receiver's foreground color to the color specified
+ * by the argument, or to the default system color for the item
+ * if the argument is null.
+ *
+ * @param color the new color (or null)
+ *
+ * @since 2.0
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_INVALID_ARGUMENT - if the argument has been disposed</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @since 2.0
+ *
+ */
+public void setForeground (Color color) {
+ checkWidget ();
+ if (color != null && color.isDisposed ())
+ SWT.error (SWT.ERROR_INVALID_ARGUMENT);
+ foreground = color;
+ redraw();
+}
+/**
+ * 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();
+ super.setGrayed(grayed);
+}
+
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/emulated/treetable/org/eclipse/swt/widgets/TreeRoots.java b/bundles/org.eclipse.swt/Eclipse SWT/emulated/treetable/org/eclipse/swt/widgets/TreeRoots.java
index b50fab0422..a60f4e6082 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/emulated/treetable/org/eclipse/swt/widgets/TreeRoots.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/emulated/treetable/org/eclipse/swt/widgets/TreeRoots.java
@@ -1,159 +1,159 @@
-package org.eclipse.swt.widgets;
-
-/*
+package org.eclipse.swt.widgets;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-import org.eclipse.swt.graphics.*;
-import java.util.Enumeration;
-import java.util.Vector;
-
-/**
- * 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() {}
-
-public void dispose() {
- if (isDisposed()) return;
- 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.dispose();
- 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;
-}
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+import org.eclipse.swt.graphics.*;
+import java.util.Enumeration;
+import java.util.Vector;
+
+/**
+ * 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() {}
+
+public void dispose() {
+ if (isDisposed()) return;
+ 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.dispose();
+ 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/gtk/org/eclipse/swt/graphics/Color.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/Color.java
index d10b1322ba..b01043f7d1 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/Color.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/Color.java
@@ -10,23 +10,23 @@ package org.eclipse.swt.graphics;
import org.eclipse.swt.internal.gtk.*;
import org.eclipse.swt.*;
-/**
- * Instances of this class manage the operating system resources that
- * implement SWT's RGB color model. To create a color you can either
- * specify the individual color components as integers in the range
- * 0 to 255 or provide an instance of an <code>RGB</code>.
- * <p>
- * Application code must explicitly invoke the <code>Color.dispose()</code>
- * method to release the operating system resources managed by each instance
- * when those instances are no longer required.
- * </p>
- *
- * @see RGB
+/**
+ * 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)
+ /**
+ * the handle to the OS color resource
+ * (Warning: This field is platform dependent)
*/
public GdkColor handle;
@@ -38,29 +38,29 @@ public final class Color {
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_NULL_ARGUMENT - if device is null and there is no current device</li>
- * <li>ERROR_INVALID_ARGUMENT - if the red, green or blue argument is not between 0 and 255</li>
- * </ul>
- *
- * @see #dispose
+/**
+ * Constructs a new instance of this class given a device and the
+ * desired red, green and blue values expressed as ints in the range
+ * 0 to 255 (where 0 is black and 255 is full brightness). On limited
+ * color devices, the color instance created by this call may not have
+ * the same RGB values as the ones specified by the arguments. The
+ * RGB values on the returned instance will be the color values of
+ * the operating system color.
+ * <p>
+ * You must dispose the color when it is no longer required.
+ * </p>
+ *
+ * @param device the device on which to allocate the color
+ * @param red the amount of red in the color
+ * @param green the amount of green in the color
+ * @param blue the amount of blue in the color
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if device is null and there is no current device</li>
+ * <li>ERROR_INVALID_ARGUMENT - if the red, green or blue argument is not between 0 and 255</li>
+ * </ul>
+ *
+ * @see #dispose
*/
public Color(Device device, int red, int green, int blue) {
if (device == null) device = Device.getDevice();
@@ -69,27 +69,27 @@ public Color(Device device, int red, int green, int 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_NULL_ARGUMENT - if device is null and there is no current device</li>
- * <li>ERROR_NULL_ARGUMENT - if the rgb argument is null</li>
- * <li>ERROR_INVALID_ARGUMENT - if the red, green or blue components of the argument are not between 0 and 255</li>
- * </ul>
- *
- * @see #dispose
+/**
+ * Constructs a new instance of this class given a device and an
+ * <code>RGB</code> describing the desired red, green and blue values.
+ * On limited color devices, the color instance created by this call
+ * may not have the same RGB values as the ones specified by the
+ * argument. The RGB values on the returned instance will be the color
+ * values of the operating system color.
+ * <p>
+ * You must dispose the color when it is no longer required.
+ * </p>
+ *
+ * @param device the device on which to allocate the color
+ * @param RGB the RGB values of the desired color
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if device is null and there is no current device</li>
+ * <li>ERROR_NULL_ARGUMENT - if the rgb argument is null</li>
+ * <li>ERROR_INVALID_ARGUMENT - if the red, green or blue components of the argument are not between 0 and 255</li>
+ * </ul>
+ *
+ * @see #dispose
*/
public Color(Device device, RGB rgb) {
if (device == null) device = Device.getDevice();
@@ -99,10 +99,10 @@ public Color(Device device, RGB rgb) {
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.
+/**
+ * Disposes of the operating system resources associated with
+ * the color. Applications must dispose of all colors which
+ * they allocate.
*/
public void dispose() {
if (handle == null) return;
@@ -121,15 +121,15 @@ public void dispose() {
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
+/**
+ * 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;
@@ -141,69 +141,69 @@ public boolean equals(Object object) {
handle.green == gdkColor.green && handle.blue == gdkColor.blue;
}
-/**
- * Returns the amount of blue in the color, from 0 to 255.
- *
- * @return the blue component of the color
- *
- * @exception SWTException <ul>
- * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
- * </ul>
+/**
+ * Returns the amount of blue in the color, from 0 to 255.
+ *
+ * @return the blue component of the color
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
*/
public int getBlue() {
if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
return (handle.blue >> 8) & 0xFF;
}
-/**
- * Returns the amount of green in the color, from 0 to 255.
- *
- * @return the green component of the color
- *
- * @exception SWTException <ul>
- * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
- * </ul>
+/**
+ * Returns the amount of green in the color, from 0 to 255.
+ *
+ * @return the green component of the color
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
*/
public int getGreen() {
if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
return (handle.green >> 8) & 0xFF;
}
-/**
- * Returns the amount of red in the color, from 0 to 255.
- *
- * @return the red component of the color
- *
- * @exception SWTException <ul>
- * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
- * </ul>
+/**
+ * Returns the amount of red in the color, from 0 to 255.
+ *
+ * @return the red component of the color
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
*/
public int getRed() {
if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
return (handle.red >> 8) & 0xFF;
}
-/**
- * Returns an integer hash code for the receiver. Any two
- * objects 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
+/**
+ * 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() {
if (isDisposed()) return 0;
return handle.red ^ handle.green ^ handle.blue;
}
-/**
- * Returns an <code>RGB</code> representing the receiver.
- *
- * @exception SWTException <ul>
- * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
- * </ul>
+/**
+ * Returns an <code>RGB</code> representing the receiver.
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
*/
public RGB getRGB () {
if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
@@ -263,25 +263,25 @@ void init(Device device, int red, int green, int blue) {
}
}
-/**
- * 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
+/**
+ * Returns <code>true</code> if the color has been disposed,
+ * and <code>false</code> otherwise.
+ * <p>
+ * This method gets the dispose state for the color.
+ * When a color has been disposed, it is an error to
+ * invoke any other method using the color.
+ *
+ * @return <code>true</code> when the color is disposed and <code>false</code> otherwise
*/
public boolean isDisposed() {
return handle == null;
}
-/**
- * Returns a string containing a concise, human-readable
- * description of the receiver.
- *
- * @return a string representation of the receiver
+/**
+ * Returns a string containing a concise, human-readable
+ * description of the receiver.
+ *
+ * @return a string representation of the receiver
*/
public String toString () {
if (isDisposed()) return "Color {*DISPOSED*}";
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/Cursor.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/Cursor.java
index 4fe50d063a..9f269831e1 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/Cursor.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/Cursor.java
@@ -10,34 +10,34 @@ package org.eclipse.swt.graphics;
import org.eclipse.swt.*;
import org.eclipse.swt.internal.gtk.*;
-/**
- * Instances of this class manage operating system resources that
- * specify the appearance of the on-screen pointer. To create a
- * cursor you specify the device and either a simple cursor style
- * describing one of the standard operating system provided cursors
- * or the image and mask data for the desired appearance.
- * <p>
- * Application code must explicitly invoke the <code>Cursor.dispose()</code>
- * method to release the operating system resources managed by each instance
- * when those instances are no longer required.
- * </p>
- * <dl>
- * <dt><b>Styles:</b></dt>
- * <dd>
- * CURSOR_ARROW, CURSOR_WAIT, CURSOR_CROSS, CURSOR_APPSTARTING, CURSOR_HELP,
- * CURSOR_SIZEALL, CURSOR_SIZENESW, CURSOR_SIZENS, CURSOR_SIZENWSE, CURSOR_SIZEWE,
- * CURSOR_SIZEN, CURSOR_SIZES, CURSOR_SIZEE, CURSOR_SIZEW, CURSOR_SIZENE, CURSOR_SIZESE,
- * CURSOR_SIZESW, CURSOR_SIZENW, CURSOR_UPARROW, CURSOR_IBEAM, CURSOR_NO, CURSOR_HAND
- * </dd>
- * </dl>
- * <p>
- * Note: Only one of the above styles may be specified.
- * </p>
+/**
+ * Instances of this class manage operating system resources that
+ * specify the appearance of the on-screen pointer. To create a
+ * cursor you specify the device and either a simple cursor style
+ * describing one of the standard operating system provided cursors
+ * or the image and mask data for the desired appearance.
+ * <p>
+ * Application code must explicitly invoke the <code>Cursor.dispose()</code>
+ * method to release the operating system resources managed by each instance
+ * when those instances are no longer required.
+ * </p>
+ * <dl>
+ * <dt><b>Styles:</b></dt>
+ * <dd>
+ * CURSOR_ARROW, CURSOR_WAIT, CURSOR_CROSS, CURSOR_APPSTARTING, CURSOR_HELP,
+ * CURSOR_SIZEALL, CURSOR_SIZENESW, CURSOR_SIZENS, CURSOR_SIZENWSE, CURSOR_SIZEWE,
+ * CURSOR_SIZEN, CURSOR_SIZES, CURSOR_SIZEE, CURSOR_SIZEW, CURSOR_SIZENE, CURSOR_SIZESE,
+ * CURSOR_SIZESW, CURSOR_SIZENW, CURSOR_UPARROW, CURSOR_IBEAM, CURSOR_NO, CURSOR_HAND
+ * </dd>
+ * </dl>
+ * <p>
+ * Note: Only one of the above styles may be specified.
+ * </p>
*/
public final class Cursor {
- /**
- * the handle to the OS cursor resource
- * (Warning: This field is platform dependent)
+ /**
+ * the handle to the OS cursor resource
+ * (Warning: This field is platform dependent)
*/
public int handle;
@@ -49,46 +49,46 @@ public final class Cursor {
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_NULL_ARGUMENT - if device is null and there is no current device</li>
- * <li>ERROR_INVALID_ARGUMENT - when an unknown style is specified</li>
- * </ul>
- * @exception SWTError <ul>
- * <li>ERROR_NO_HANDLES - if a handle could not be obtained for cursor creation</li>
- * </ul>
- *
- * @see SWT#CURSOR_ARROW
- * @see SWT#CURSOR_WAIT
- * @see SWT#CURSOR_CROSS
- * @see SWT#CURSOR_APPSTARTING
- * @see SWT#CURSOR_HELP
- * @see SWT#CURSOR_SIZEALL
- * @see SWT#CURSOR_SIZENESW
- * @see SWT#CURSOR_SIZENS
- * @see SWT#CURSOR_SIZENWSE
- * @see SWT#CURSOR_SIZEWE
- * @see SWT#CURSOR_SIZEN
- * @see SWT#CURSOR_SIZES
- * @see SWT#CURSOR_SIZEE
- * @see SWT#CURSOR_SIZEW
- * @see SWT#CURSOR_SIZENE
- * @see SWT#CURSOR_SIZESE
- * @see SWT#CURSOR_SIZESW
- * @see SWT#CURSOR_SIZENW
- * @see SWT#CURSOR_UPARROW
- * @see SWT#CURSOR_IBEAM
- * @see SWT#CURSOR_NO
- * @see SWT#CURSOR_HAND
+/**
+ * Constructs a new cursor given a device and a style
+ * constant describing the desired cursor appearance.
+ * <p>
+ * You must dispose the cursor when it is no longer required.
+ * </p>
+ *
+ * @param device the device on which to allocate the cursor
+ * @param style the style of cursor to allocate
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if device is null and there is no current device</li>
+ * <li>ERROR_INVALID_ARGUMENT - when an unknown style is specified</li>
+ * </ul>
+ * @exception SWTError <ul>
+ * <li>ERROR_NO_HANDLES - if a handle could not be obtained for cursor creation</li>
+ * </ul>
+ *
+ * @see SWT#CURSOR_ARROW
+ * @see SWT#CURSOR_WAIT
+ * @see SWT#CURSOR_CROSS
+ * @see SWT#CURSOR_APPSTARTING
+ * @see SWT#CURSOR_HELP
+ * @see SWT#CURSOR_SIZEALL
+ * @see SWT#CURSOR_SIZENESW
+ * @see SWT#CURSOR_SIZENS
+ * @see SWT#CURSOR_SIZENWSE
+ * @see SWT#CURSOR_SIZEWE
+ * @see SWT#CURSOR_SIZEN
+ * @see SWT#CURSOR_SIZES
+ * @see SWT#CURSOR_SIZEE
+ * @see SWT#CURSOR_SIZEW
+ * @see SWT#CURSOR_SIZENE
+ * @see SWT#CURSOR_SIZESE
+ * @see SWT#CURSOR_SIZESW
+ * @see SWT#CURSOR_SIZENW
+ * @see SWT#CURSOR_UPARROW
+ * @see SWT#CURSOR_IBEAM
+ * @see SWT#CURSOR_NO
+ * @see SWT#CURSOR_HAND
*/
public Cursor(Device device, int style) {
if (device == null) device = Device.getDevice();
@@ -170,37 +170,37 @@ public Cursor(Device device, int style) {
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 - if device is null and there is no current device</li>
- * <li>ERROR_NULL_ARGUMENT - if the source is null</li>
- * <li>ERROR_NULL_ARGUMENT - if the mask is null and the source does not have a mask</li>
- * <li>ERROR_INVALID_ARGUMENT - if the source and the mask are not the same
- * size, or 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 a handle could not be obtained for cursor creation</li>
- * </ul>
+/**
+ * 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 - if device is null and there is no current device</li>
+ * <li>ERROR_NULL_ARGUMENT - if the source is null</li>
+ * <li>ERROR_NULL_ARGUMENT - if the mask is null and the source does not have a mask</li>
+ * <li>ERROR_INVALID_ARGUMENT - if the source and the mask are not the same
+ * size, or 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 a handle could not be obtained for cursor creation</li>
+ * </ul>
*/
public Cursor(Device device, ImageData source, ImageData mask, int hotspotX, int hotspotY) {
if (device == null) device = Device.getDevice();
@@ -280,10 +280,10 @@ public Cursor(Device device, ImageData source, ImageData mask, int hotspotX, int
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.
+/**
+ * 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) OS.gdk_cursor_destroy(handle);
@@ -292,15 +292,15 @@ public void dispose() {
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
+/**
+ * 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;
@@ -332,39 +332,39 @@ public static Cursor gtk_new(Device device, int handle) {
return cursor;
}
-/**
- * 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
+/**
+ * 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
+/**
+ * Returns <code>true</code> if the cursor has been disposed,
+ * and <code>false</code> otherwise.
+ * <p>
+ * This method gets the dispose state for the cursor.
+ * When a cursor has been disposed, it is an error to
+ * invoke any other method using the cursor.
+ *
+ * @return <code>true</code> when the cursor is disposed and <code>false</code> otherwise
*/
public boolean isDisposed() {
return handle == 0;
}
-/**
- * Returns a string containing a concise, human-readable
- * description of the receiver.
- *
- * @return a string representation of the receiver
+/**
+ * Returns a string containing a concise, human-readable
+ * description of the receiver.
+ *
+ * @return a string representation of the receiver
*/
public String toString () {
if (isDisposed()) return "Cursor {*DISPOSED*}";
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/Device.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/Device.java
index 622db39b11..9144cb18fe 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/Device.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/Device.java
@@ -11,11 +11,11 @@ import org.eclipse.swt.*;
import org.eclipse.swt.internal.*;
import org.eclipse.swt.internal.gtk.*;
-/**
- * This class is the abstract superclass of all device objects,
- * such as the Display device and the Printer device. Devices
- * can have a graphics context (GC) created for them, and they
- * can be drawn on by sending messages to the associated GC.
+/**
+ * This class is the abstract superclass of all device objects,
+ * such as the Display device and the Printer device. Devices
+ * can have a graphics context (GC) created for them, and they
+ * can be drawn on by sending messages to the associated GC.
*/
public abstract class Device implements Drawable {
@@ -83,17 +83,17 @@ static Device getDevice () {
return device;
}
-/**
- * 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
+/**
+ * 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) {
if (data != null) {
@@ -118,15 +118,15 @@ protected void checkDevice () {
protected void create (DeviceData data) {
}
-/**
- * Disposes of the operating system resources associated with
- * the receiver. After this method has been invoked, the receiver
- * will answer <code>true</code> when sent the message
- * <code>isDisposed()</code>.
- *
- * @see #release
- * @see #destroy
- * @see #checkDevice
+/**
+ * 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;
@@ -153,32 +153,32 @@ void dispose_Object (Object object) {
protected void destroy () {
}
-/**
- * Returns a rectangle describing the receiver's size and location.
- *
- * @return the bounding rectangle
- *
- * @exception SWTException <ul>
- * <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
- * </ul>
+/**
+ * Returns a rectangle describing the receiver's size and location.
+ *
+ * @return the bounding rectangle
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
*/
public Rectangle getBounds () {
checkDevice ();
return new Rectangle(0, 0, 0, 0);
}
-/**
- * Returns a <code>DeviceData</code> based on the receiver.
- * Modifications made to this <code>DeviceData</code> will not
- * affect the receiver.
- *
- * @return a <code>DeviceData</code> containing the device's data and attributes
- *
- * @exception SWTException <ul>
- * <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
- * </ul>
- *
- * @see DeviceData
+/**
+ * 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();
@@ -203,68 +203,68 @@ public DeviceData getDeviceData () {
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
+/**
+ * Returns a rectangle which describes the area of the
+ * receiver which is capable of displaying data.
+ *
+ * @return the client area
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ *
+ * @see #getBounds
*/
public Rectangle getClientArea () {
checkDevice ();
return getBounds ();
}
-/**
- * Returns the bit depth of the screen, which is the number of
- * bits it takes to represent the number of unique colors that
- * the screen is currently capable of displaying. This number
- * will typically be one of 1, 8, 15, 16, 24 or 32.
- *
- * @return the depth of the screen
- *
- * @exception SWTException <ul>
- * <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
- * </ul>
+/**
+ * Returns the bit depth of the screen, which is the number of
+ * bits it takes to represent the number of unique colors that
+ * the screen is currently capable of displaying. This number
+ * will typically be one of 1, 8, 15, 16, 24 or 32.
+ *
+ * @return the depth of the screen
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
*/
public int getDepth () {
checkDevice ();
return 0;
}
-/**
- * Returns a point whose x coordinate is the horizontal
- * dots per inch of the display, and whose y coordinate
- * is the vertical dots per inch of the display.
- *
- * @return the horizontal and vertical DPI
- *
- * @exception SWTException <ul>
- * <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
- * </ul>
+/**
+ * Returns a point whose x coordinate is the horizontal
+ * dots per inch of the display, and whose y coordinate
+ * is the vertical dots per inch of the display.
+ *
+ * @return the horizontal and vertical DPI
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
*/
public Point getDPI () {
checkDevice ();
return new Point (72, 72);
}
-/**
- * Returns <code>FontData</code> objects which describe
- * the fonts that match the given arguments. If the
- * <code>faceName</code> is null, all fonts will be returned.
- *
- * @param faceName the name of the font to look for, or null
- * @param scalable 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>
+/**
+ * Returns <code>FontData</code> objects which describe
+ * the fonts that match the given arguments. If the
+ * <code>faceName</code> is null, all fonts will be returned.
+ *
+ * @param faceName the name of the font to look for, or null
+ * @param scalable 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 ();
@@ -309,23 +309,23 @@ public FontData[] getFontList (String faceName, boolean scalable) {
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
+/**
+ * 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 ();
@@ -350,41 +350,41 @@ public Color getSystemColor (int id) {
return COLOR_BLACK;
}
-/**
- * Returns a reasonable font for applications to use.
- * On some platforms, this will match the "default font"
- * or "system font" if such can be found. This font
- * should not be 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>
+/**
+ * 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 ();
return systemFont;
}
-/**
- * Returns <code>true</code> if the underlying window system prints out
- * warning messages on the console, and <code>setWarnings</code>
- * had previously been called with <code>true</code>.
- *
- * @return <code>true</code>if warnings are being handled, and <code>false</code> otherwise
- *
- * @exception SWTException <ul>
- * <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
- * </ul>
+/**
+ * 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 ();
@@ -426,49 +426,49 @@ protected void init () {
COLOR_WHITE = new Color (this, 0xFF,0xFF,0xFF);
}
-/**
- * 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
+/**
+ * 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
+/**
+ * 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 handle, GCData data);
-/**
- * Returns <code>true</code> if the device has been disposed,
- * and <code>false</code> otherwise.
- * <p>
- * This method gets the dispose state for the device.
- * When a device has been disposed, it is an error to
- * invoke any other method using the device.
- *
- * @return <code>true</code> when the device is disposed and <code>false</code> otherwise
+/**
+ * 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;
@@ -532,17 +532,17 @@ protected void release () {
logProc = 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>
+/**
+ * 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 ();
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/Font.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/Font.java
index dca0c2d364..edbaea1494 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/Font.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/Font.java
@@ -11,23 +11,23 @@ import org.eclipse.swt.*;
import org.eclipse.swt.internal.*;
import org.eclipse.swt.internal.gtk.*;
-/**
- * Instances of this class manage operating system resources that
- * define how text looks when it is displayed. Fonts may be constructed
- * by providing a device and either name, size and style information
- * or a <code>FontData</code> object which encapsulates this data.
- * <p>
- * Application code must explicitly invoke the <code>Font.dispose()</code>
- * method to release the operating system resources managed by each instance
- * when those instances are no longer required.
- * </p>
- *
- * @see FontData
+/**
+ * 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)
+ /**
+ * the handle to the OS font resource
+ * (Warning: This field is platform dependent)
*/
public int handle;
@@ -39,23 +39,23 @@ public final class Font {
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 device is null and there is no current device</li>
- * <li>ERROR_NULL_ARGUMENT - if the fd argument is null</li>
- * </ul>
- * @exception SWTError <ul>
- * <li>ERROR_NO_HANDLES - if a font could not be created from the given font data</li>
- * </ul>
+/**
+ * Constructs a new font given a device and font data
+ * which describes the desired font's appearance.
+ * <p>
+ * You must dispose the font when it is no longer required.
+ * </p>
+ *
+ * @param device the device to create the font on
+ * @param fd the FontData that describes the desired font (must not be null)
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if device is null and there is no current device</li>
+ * <li>ERROR_NULL_ARGUMENT - if the fd argument is null</li>
+ * </ul>
+ * @exception SWTError <ul>
+ * <li>ERROR_NO_HANDLES - if a font could not be created from the given font data</li>
+ * </ul>
*/
public Font(Device device, FontData fd) {
if (device == null) device = Device.getDevice();
@@ -96,27 +96,27 @@ public Font(Device device, FontData[] fds) {
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 device is null and there is no current device</li>
- * <li>ERROR_NULL_ARGUMENT - if the name argument is null</li>
- * <li>ERROR_INVALID_ARGUMENT - if the height is negative</li>
- * </ul>
- * @exception SWTError <ul>
- * <li>ERROR_NO_HANDLES - if a font could not be created from the given arguments</li>
- * </ul>
+/**
+ * Constructs a new font given a device, a font name,
+ * the height of the desired font in points, and a font
+ * style.
+ * <p>
+ * You must dispose the font when it is no longer required.
+ * </p>
+ *
+ * @param device the device to create the font on
+ * @param name the name of the font (must not be null)
+ * @param height the font height in points
+ * @param style a bit or combination of NORMAL, BOLD, ITALIC
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if device is null and there is no current device</li>
+ * <li>ERROR_NULL_ARGUMENT - if the name argument is null</li>
+ * <li>ERROR_INVALID_ARGUMENT - if the height is negative</li>
+ * </ul>
+ * @exception SWTError <ul>
+ * <li>ERROR_NO_HANDLES - if a font could not be created from the given arguments</li>
+ * </ul>
*/
public Font(Device device, String name, int height, int style) {
if (device == null) device = Device.getDevice();
@@ -125,10 +125,10 @@ public Font(Device device, String name, int height, int 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.
+/**
+ * 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) OS.pango_font_description_free(handle);
@@ -137,15 +137,15 @@ public void dispose() {
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
+/**
+ * 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;
@@ -153,17 +153,17 @@ public boolean equals(Object object) {
return handle == ((Font)object).handle;
}
-/**
- * Returns an array of <code>FontData</code>s representing the receiver.
- * On Windows, only one FontData will be returned per font. On X however,
- * a <code>Font</code> object <em>may</em> be composed of multiple X
- * fonts. To support this case, we return an array of font data objects.
- *
- * @return an array of font data objects describing the receiver
- *
- * @exception SWTException <ul>
- * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
- * </ul>
+/**
+ * Returns an array of <code>FontData</code>s representing the receiver.
+ * On Windows, only one FontData will be returned per font. On X however,
+ * a <code>Font</code> object <em>may</em> be composed of multiple X
+ * fonts. To support this case, we return an array of font data objects.
+ *
+ * @return an array of font data objects describing the receiver
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
*/
public FontData[] getFontData() {
if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
@@ -213,15 +213,15 @@ public static Font gtk_new(Device device, int handle) {
return font;
}
-/**
- * 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
+/**
+ * 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;
@@ -251,25 +251,25 @@ void init(Device device, String name, int height, int style, byte[] fontString)
}
}
-/**
- * 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
+/**
+ * Returns <code>true</code> if the font has been disposed,
+ * and <code>false</code> otherwise.
+ * <p>
+ * This method gets the dispose state for the font.
+ * When a font has been disposed, it is an error to
+ * invoke any other method using the font.
+ *
+ * @return <code>true</code> when the font is disposed and <code>false</code> otherwise
*/
public boolean isDisposed() {
return handle == 0;
}
-/**
- * Returns a string containing a concise, human-readable
- * description of the receiver.
- *
- * @return a string representation of the receiver
+/**
+ * Returns a string containing a concise, human-readable
+ * description of the receiver.
+ *
+ * @return a string representation of the receiver
*/
public String toString () {
if (isDisposed()) return "Font {*DISPOSED*}";
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/FontData.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/FontData.java
index e725a5e473..28788204a2 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/FontData.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/FontData.java
@@ -1,77 +1,77 @@
-package org.eclipse.swt.graphics;
-
-/*
+package org.eclipse.swt.graphics;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-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
+ * http://www.eclipse.org/legal/cpl-v10.html
*/
-public final class FontData {
- /**
- * the font name
- * (Warning: This field is platform dependent)
+
+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 {
+ /**
+ * the font name
+ * (Warning: This field is platform dependent)
*/
- public String name;
-
- /**
- * The height of the font data in points
- * (Warning: This field is platform dependent)
+ public String name;
+
+ /**
+ * The height of the font data in points
+ * (Warning: This field is platform dependent)
*/
- public int height;
-
- /**
- * the font style
- * (Warning: This field is platform dependent)
+ public int height;
+
+ /**
+ * the font style
+ * (Warning: This field is platform dependent)
*/
- public int style;
-
- /**
- * the Pango string
- * (Warning: This field is platform dependent)
+ public int style;
+
+ /**
+ * the Pango string
+ * (Warning: This field is platform dependent)
*/
- public byte[] string;
-
- /**
- * The locales of the font
- * (Warning: These fields are platform dependent)
+ public byte[] string;
+
+ /**
+ * The locales of the font
+ * (Warning: These fields are platform dependent)
*/
- String lang, country, variant;
-
+ String lang, country, variant;
+
/**
* Constructs a new un-initialized font data.
*/
-public FontData () {
- this("", 12, SWT.NORMAL);
-}
-
+public FontData () {
+ this("", 12, SWT.NORMAL);
+}
+
/**
* Constructs a new FontData given a string representation
* in the form generated by the <code>FontData.toString</code>
@@ -91,61 +91,61 @@ public FontData () {
*
* @see #toString
*/
-public FontData(String string) {
- if (string == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
- int start = 0;
- int end = string.indexOf('|');
- if (end == -1) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
- String version1 = string.substring(start, end);
- try {
- if (Integer.parseInt(version1) != 1) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
- } catch (NumberFormatException e) {
- SWT.error(SWT.ERROR_INVALID_ARGUMENT);
- }
-
- start = end + 1;
- end = string.indexOf('|', start);
- if (end == -1) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
- String name = string.substring(start, end);
-
- start = end + 1;
- end = string.indexOf('|', start);
- if (end == -1) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
- 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("GTK") && version2.equals("1")) {
- return;
- }
-}
-
+public FontData(String string) {
+ if (string == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ int start = 0;
+ int end = string.indexOf('|');
+ if (end == -1) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+ String version1 = string.substring(start, end);
+ try {
+ if (Integer.parseInt(version1) != 1) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+ } catch (NumberFormatException e) {
+ SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+ }
+
+ start = end + 1;
+ end = string.indexOf('|', start);
+ if (end == -1) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+ String name = string.substring(start, end);
+
+ start = end + 1;
+ end = string.indexOf('|', start);
+ if (end == -1) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+ 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("GTK") && version2.equals("1")) {
+ return;
+ }
+}
+
/**
* Constructs a new font data given a font name,
* the height of the desired font in points,
@@ -160,66 +160,66 @@ public FontData(String string) {
* <li>ERROR_INVALID_ARGUMENT - if the height is negative</li>
* </ul>
*/
-public FontData(String name, int height, int style) {
- setName(name);
- setHeight(height);
- setStyle(style);
-}
-
-/**
- * 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 FontData(String name, int height, int style) {
+ setName(name);
+ setHeight(height);
+ setStyle(style);
+}
+
+/**
+ * Compares the argument to the receiver, and returns true
+ * if they represent the <em>same</em> object using a class
+ * specific comparison.
+ *
+ * @param object the object to compare with this object
+ * @return <code>true</code> if the object is the same as this object and <code>false</code> otherwise
+ *
+ * @see #hashCode
*/
-public boolean equals (Object object) {
- if (object == this) return true;
- if (!(object instanceof FontData)) return false;
- FontData data = (FontData)object;
- return name.equals(data.name) && height == data.height && style == data.style;
-}
-
-/**
- * Returns the height of the receiver in points.
- *
- * @return the height of this FontData
- *
- * @see #setHeight
+public boolean equals (Object object) {
+ if (object == this) return true;
+ if (!(object instanceof FontData)) return false;
+ FontData data = (FontData)object;
+ return name.equals(data.name) && height == data.height && style == data.style;
+}
+
+/**
+ * Returns the height of the receiver in points.
+ *
+ * @return the height of this FontData
+ *
+ * @see #setHeight
*/
-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 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() {
- return name;
-}
-
-/**
- * Returns the style of the receiver which is a bitwise OR of
- * one or more of the <code>SWT</code> constants NORMAL, BOLD
- * and ITALIC.
- *
- * @return the style of this <code>FontData</code>
- *
- * @see #setStyle
+public String getName() {
+ return name;
+}
+
+/**
+ * Returns the style of the receiver which is a bitwise OR of
+ * one or more of the <code>SWT</code> constants NORMAL, BOLD
+ * and ITALIC.
+ *
+ * @return the style of this <code>FontData</code>
+ *
+ * @see #setStyle
*/
-public int getStyle() {
- return style;
-}
-
+public int getStyle() {
+ return style;
+}
+
/**
* Returns an integer hash code for the receiver. Any two
* objects which return <code>true</code> when passed to
@@ -230,10 +230,10 @@ public int getStyle() {
*
* @see #equals
*/
-public int hashCode () {
- return name.hashCode() ^ height ^ style;
-}
-
+public int hashCode () {
+ return name.hashCode() ^ height ^ style;
+}
+
/**
* Sets the height of the receiver. The parameter is
* specified in terms of points, where a point is one
@@ -247,49 +247,49 @@ public int hashCode () {
*
* @see #getHeight
*/
-public void setHeight(int height) {
- if (height < 0) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
- this.height = height;
- this.string = null;
-}
-
-/**
- * Sets the locale of the receiver.
- * <p>
- * The locale determines which platform character set this
- * font is going to use. Widgets and graphics operations that
- * use this font will convert UNICODE strings to the platform
- * character set of the specified locale.
- * </p>
- * <p>
- * On platforms which there are multiple character sets for a
- * given language/country locale, the variant portion of the
- * locale will determine the character set.
- * </p>
- *
- * @param locale the <code>String</code> representing a Locale object
- * @see java.util.Locale#toString
+public void setHeight(int height) {
+ if (height < 0) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+ this.height = height;
+ this.string = null;
+}
+
+/**
+ * Sets the locale of the receiver.
+ * <p>
+ * The locale determines which platform character set this
+ * font is going to use. Widgets and graphics operations that
+ * use this font will convert UNICODE strings to the platform
+ * character set of the specified locale.
+ * </p>
+ * <p>
+ * On platforms which there are multiple character sets for a
+ * given language/country locale, the variant portion of the
+ * locale will determine the character set.
+ * </p>
+ *
+ * @param locale the <code>String</code> representing a Locale object
+ * @see java.util.Locale#toString
*/
-public void setLocale(String locale) {
- lang = country = variant = null;
- if (locale != null) {
- char sep = '_';
- int length = locale.length();
- int firstSep, secondSep;
-
- firstSep = locale.indexOf(sep);
- if (firstSep == -1) {
- firstSep = secondSep = length;
- } else {
- secondSep = locale.indexOf(sep, firstSep + 1);
- if (secondSep == -1) secondSep = length;
- }
- if (firstSep > 0) lang = locale.substring(0, firstSep);
- if (secondSep > firstSep + 1) country = locale.substring(firstSep + 1, secondSep);
- if (length > secondSep + 1) variant = locale.substring(secondSep + 1);
- }
-}
-
+public void setLocale(String locale) {
+ lang = country = variant = null;
+ if (locale != null) {
+ char sep = '_';
+ int length = locale.length();
+ int firstSep, secondSep;
+
+ firstSep = locale.indexOf(sep);
+ if (firstSep == -1) {
+ firstSep = secondSep = length;
+ } else {
+ secondSep = locale.indexOf(sep, firstSep + 1);
+ if (secondSep == -1) secondSep = length;
+ }
+ if (firstSep > 0) lang = locale.substring(0, firstSep);
+ if (secondSep > firstSep + 1) country = locale.substring(firstSep + 1, secondSep);
+ if (length > secondSep + 1) variant = locale.substring(secondSep + 1);
+ }
+}
+
/**
* Sets the name of the receiver.
* <p>
@@ -315,12 +315,12 @@ public void setLocale(String locale) {
*
* @see #getName
*/
-public void setName(String name) {
- if (name == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
- this.name = name;
- this.string = null;
-}
-
+public void setName(String name) {
+ if (name == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ this.name = name;
+ this.string = null;
+}
+
/**
* Sets the style of the receiver to the argument which must
* be a bitwise OR of one or more of the <code>SWT</code>
@@ -330,11 +330,11 @@ public void setName(String name) {
*
* @see #getStyle
*/
-public void setStyle(int style) {
- this.style = style;
- this.string = null;
-}
-
+public void setStyle(int style) {
+ this.style = style;
+ this.string = null;
+}
+
/**
* Returns a string representation of the receiver which is suitable
* for constructing an equivalent instance using the
@@ -344,17 +344,17 @@ public void setStyle(int style) {
*
* @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("GTK|1|");
- return buffer.toString();
-}
-
-}
+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("GTK|1|");
+ return buffer.toString();
+}
+
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/FontMetrics.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/FontMetrics.java
index ca8787fbe6..5a65657044 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/FontMetrics.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/FontMetrics.java
@@ -1,12 +1,12 @@
-package org.eclipse.swt.graphics;
-
-/*
+package org.eclipse.swt.graphics;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
/**
* Instances of this class provide measurement information
* about fonts including ascent, descent, height, leading
@@ -16,12 +16,12 @@ package org.eclipse.swt.graphics;
*
* @see GC#getFontMetrics
*/
-public final class FontMetrics {
- int ascent, descent, averageCharWidth, leading, height;
-
-FontMetrics() {
-}
-
+public final class FontMetrics {
+ int ascent, descent, averageCharWidth, leading, height;
+
+FontMetrics() {
+}
+
/**
* Compares the argument to the receiver, and returns true
* if they represent the <em>same</em> object using a class
@@ -32,15 +32,15 @@ FontMetrics() {
*
* @see #hashCode
*/
-public boolean equals (Object object) {
- if (object == this) return true;
- if (!(object instanceof FontMetrics)) return false;
- FontMetrics metrics = (FontMetrics)object;
- return ascent == metrics.ascent && descent == metrics.descent &&
- averageCharWidth == metrics.averageCharWidth && leading == metrics.leading &&
- height == metrics.height;
-}
-
+public boolean equals (Object object) {
+ if (object == this) return true;
+ if (!(object instanceof FontMetrics)) return false;
+ FontMetrics metrics = (FontMetrics)object;
+ return ascent == metrics.ascent && descent == metrics.descent &&
+ averageCharWidth == metrics.averageCharWidth && leading == metrics.leading &&
+ height == metrics.height;
+}
+
/**
* Returns the ascent of the font described by the receiver. A
* font's <em>ascent</em> is the distance from the baseline to the
@@ -49,20 +49,20 @@ public boolean equals (Object object) {
*
* @return the ascent of the font
*/
-public int getAscent() {
- return ascent;
-}
-
+public int getAscent() {
+ return ascent;
+}
+
/**
* Returns the average character width, measured in pixels,
* of the font described by the receiver.
*
* @return the average character width of the font
*/
-public int getAverageCharWidth() {
- return averageCharWidth;
-}
-
+public int getAverageCharWidth() {
+ return averageCharWidth;
+}
+
/**
* Returns the descent of the font described by the receiver. A
* font's <em>descent</em> is the distance from the baseline to the
@@ -71,10 +71,10 @@ public int getAverageCharWidth() {
*
* @return the descent of the font
*/
-public int getDescent() {
- return descent;
-}
-
+public int getDescent() {
+ return descent;
+}
+
/**
* Returns the height of the font described by the receiver,
* measured in pixels. A font's <em>height</em> is the sum of
@@ -86,10 +86,10 @@ public int getDescent() {
* @see #getDescent
* @see #getLeading
*/
-public int getHeight() {
- return height;
-}
-
+public int getHeight() {
+ return height;
+}
+
/**
* Returns the leading area of the font described by the
* receiver. A font's <em>leading area</em> is the space
@@ -97,10 +97,10 @@ public int getHeight() {
*
* @return the leading space of the font
*/
-public int getLeading() {
- return leading;
-}
-
+public int getLeading() {
+ return leading;
+}
+
/**
* Returns an integer hash code for the receiver. Any two
* objects which return <code>true</code> when passed to
@@ -111,8 +111,8 @@ public int getLeading() {
*
* @see #equals
*/
-public int hashCode() {
- return ascent ^ descent ^ averageCharWidth ^ leading ^ height;
-}
-
-}
+public int hashCode() {
+ return ascent ^ descent ^ averageCharWidth ^ leading ^ height;
+}
+
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/GC.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/GC.java
index 5df563ea03..e043ae233a 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/GC.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/GC.java
@@ -11,24 +11,24 @@ import org.eclipse.swt.internal.gtk.*;
import org.eclipse.swt.internal.*;
import org.eclipse.swt.*;
-/**
- * Class <code>GC</code> is where all of the drawing capabilities that are
- * supported by SWT are located. Instances are used to draw on either an
- * <code>Image</code>, a <code>Control</code>, or directly on a <code>Display</code>.
- * <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 org.eclipse.swt.events.PaintEvent
+/**
+ * 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 org.eclipse.swt.events.PaintEvent
*/
public final class GC {
- /**
- * the handle to the OS device context
- * (Warning: This field is platform dependent)
+ /**
+ * the handle to the OS device context
+ * (Warning: This field is platform dependent)
*/
public int handle;
@@ -38,26 +38,26 @@ public final class GC {
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_NULL_ARGUMENT - if there is no current device</li>
- * <li>ERROR_INVALID_ARGUMENT
- * - if the drawable is an image that is not a bitmap or an icon
- * - if the drawable is an image or printer that is already selected
- * into another graphics context</li>
- * </ul>
- * @exception SWTError <ul>
- * <li>ERROR_NO_HANDLES if a handle could not be obtained for gc creation</li>
- * </ul>
+/**
+ * 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_NULL_ARGUMENT - if there is no current device</li>
+ * <li>ERROR_INVALID_ARGUMENT
+ * - if the drawable is an image that is not a bitmap or an icon
+ * - if the drawable is an image or printer that is already selected
+ * into another graphics context</li>
+ * </ul>
+ * @exception SWTError <ul>
+ * <li>ERROR_NO_HANDLES if a handle could not be obtained for gc creation</li>
+ * </ul>
*/
public GC(Drawable drawable) {
if (drawable == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
@@ -71,20 +71,20 @@ public GC(Drawable drawable) {
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 or has been disposed</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
- * </ul>
+/**
+ * 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 or has been disposed</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
*/
public void copyArea(Image image, int x, int y) {
if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
@@ -98,20 +98,20 @@ public void copyArea(Image image, int x, int y) {
OS.g_object_unref(gdkGC);
}
-/**
- * Copies a rectangular area of the receiver at the source
- * position onto the receiver at the destination position.
- *
- * @param srcX the x coordinate in the receiver of the area to be copied
- * @param srcY the y coordinate in the receiver of the area to be copied
- * @param width the width of the area to copy
- * @param height the height of the area to copy
- * @param destX the x coordinate in the receiver of the area to copy to
- * @param destY the y coordinate in the receiver of the area to copy to
- *
- * @exception SWTException <ul>
- * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
- * </ul>
+/**
+ * Copies a rectangular area of the receiver at the source
+ * position onto the receiver at the destination position.
+ *
+ * @param srcX the x coordinate in the receiver of the area to be copied
+ * @param srcY the y coordinate in the receiver of the area to be copied
+ * @param width the width of the area to copy
+ * @param height the height of the area to copy
+ * @param destX the x coordinate in the receiver of the area to copy to
+ * @param destY the y coordinate in the receiver of the area to copy to
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
*/
public void copyArea(int srcX, int srcY, int width, int height, int destX, int destY) {
if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
@@ -156,10 +156,10 @@ public void copyArea(int srcX, int srcY, int width, int height, int destX, int d
}
}
-/**
- * Disposes of the operating system resources associated with
- * the graphics context. Applications must dispose of all GCs
- * which they allocate.
+/**
+ * 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;
@@ -192,37 +192,37 @@ public void dispose() {
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>
- * @exception SWTException <ul>
- * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
- * </ul>
+/**
+ * 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>
+ * @exception SWTException <ul>
+ * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
*/
public void drawArc(int x, int y, int width, int height, int startAngle, int endAngle) {
if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
@@ -240,22 +240,22 @@ public void drawArc(int x, int y, int width, int height, int startAngle, int end
OS.gdk_draw_arc(data.drawable, handle, 0, x, y, width, height, startAngle * 64, endAngle * 64);
}
-/**
- * Draws a rectangle, based on the specified arguments, which has
- * the appearance of the platform's <em>focus rectangle</em> if the
- * platform supports such a notion, and otherwise draws a simple
- * rectangle in the receiver's foreground color.
- *
- * @param x the x coordinate of the rectangle
- * @param y the y coordinate of the rectangle
- * @param width the width of the rectangle
- * @param height the height of the rectangle
- *
- * @exception SWTException <ul>
- * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
- * </ul>
- *
- * @see #drawRectangle
+/**
+ * Draws a rectangle, based on the specified arguments, which has
+ * the appearance of the platform's <em>focus rectangle</em> if the
+ * platform supports such a notion, and otherwise draws a simple
+ * rectangle in the receiver's foreground color.
+ *
+ * @param x the x coordinate of the rectangle
+ * @param y the y coordinate of the rectangle
+ * @param width the width of the rectangle
+ * @param height the height of the rectangle
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ *
+ * @see #drawRectangle
*/
public void drawFocus(int x, int y, int width, int height) {
if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
@@ -278,24 +278,24 @@ public void drawFocus(int x, int y, int width, int height) {
OS.gdk_gc_set_foreground(handle, color);
}
-/**
- * Draws the given image in the receiver at the specified
- * coordinates.
- *
- * @param image the image to draw
- * @param x the x coordinate of where to draw
- * @param y the y coordinate of where to draw
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the image is null</li>
- * <li>ERROR_INVALID_ARGUMENT - if the image has been disposed</li>
- * <li>ERROR_INVALID_ARGUMENT - if the given coordinates are outside the bounds of the image</li>
- * @exception SWTError <ul>
- * <li>ERROR_NO_HANDLES - if no handles are available to perform the operation</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
- * </ul>
+/**
+ * Draws the given image in the receiver at the specified
+ * coordinates.
+ *
+ * @param image the image to draw
+ * @param x the x coordinate of where to draw
+ * @param y the y coordinate of where to draw
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if the image is null</li>
+ * <li>ERROR_INVALID_ARGUMENT - if the image has been disposed</li>
+ * <li>ERROR_INVALID_ARGUMENT - if the given coordinates are outside the bounds of the image</li>
+ * @exception SWTError <ul>
+ * <li>ERROR_NO_HANDLES - if no handles are available to perform the operation</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
*/
public void drawImage(Image image, int x, int y) {
if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
@@ -304,37 +304,37 @@ public void drawImage(Image image, int x, int y) {
drawImage(image, 0, 0, -1, -1, x, y, -1, -1, true);
}
-/**
- * Copies a rectangular area from the source image into a (potentially
- * different sized) rectangular area in the receiver. If the source
- * and destination areas are of differing sizes, then the source
- * area will be stretched or shrunk to fit the destination area
- * as it is copied. The copy fails if any part of the source rectangle
- * lies outside the bounds of the source image, or if any of the width
- * or height arguments are negative.
- *
- * @param image the source image
- * @param srcX the x coordinate in the source image to copy from
- * @param srcY the y coordinate in the source image to copy from
- * @param srcWidth the width in pixels to copy from the source
- * @param srcHeight the height in pixels to copy from the source
- * @param destX the x coordinate in the destination to copy to
- * @param destY the y coordinate in the destination to copy to
- * @param destWidth the width in pixels of the destination rectangle
- * @param destHeight the height in pixels of the destination rectangle
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the image is null</li>
- * <li>ERROR_INVALID_ARGUMENT - if the image has been disposed</li>
- * <li>ERROR_INVALID_ARGUMENT - if any of the width or height arguments are negative.
- * <li>ERROR_INVALID_ARGUMENT - if the source rectangle is not contained within the bounds of the source image</li>
- * </ul>
- * @exception SWTError <ul>
- * <li>ERROR_NO_HANDLES - if no handles are available to perform the operation</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
- * </ul>
+/**
+ * Copies a rectangular area from the source image into a (potentially
+ * different sized) rectangular area in the receiver. If the source
+ * and destination areas are of differing sizes, then the source
+ * area will be stretched or shrunk to fit the destination area
+ * as it is copied. The copy fails if any part of the source rectangle
+ * lies outside the bounds of the source image, or if any of the width
+ * or height arguments are negative.
+ *
+ * @param image the source image
+ * @param srcX the x coordinate in the source image to copy from
+ * @param srcY the y coordinate in the source image to copy from
+ * @param srcWidth the width in pixels to copy from the source
+ * @param srcHeight the height in pixels to copy from the source
+ * @param destX the x coordinate in the destination to copy to
+ * @param destY the y coordinate in the destination to copy to
+ * @param destWidth the width in pixels of the destination rectangle
+ * @param destHeight the height in pixels of the destination rectangle
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if the image is null</li>
+ * <li>ERROR_INVALID_ARGUMENT - if the image has been disposed</li>
+ * <li>ERROR_INVALID_ARGUMENT - if any of the width or height arguments are negative.
+ * <li>ERROR_INVALID_ARGUMENT - if the source rectangle is not contained within the bounds of the source image</li>
+ * </ul>
+ * @exception SWTError <ul>
+ * <li>ERROR_NO_HANDLES - if no handles are available to perform the operation</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
*/
public void drawImage(Image image, int srcX, int srcY, int srcWidth, int srcHeight, int destX, int destY, int destWidth, int destHeight) {
if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
@@ -482,44 +482,44 @@ int scale(int src, int srcX, int srcY, int srcWidth, int srcHeight, int destWidt
return scaledPixbuf;
}
-/**
- * Draws a line, using the foreground color, between the points
- * (<code>x1</code>, <code>y1</code>) and (<code>x2</code>, <code>y2</code>).
- *
- * @param x1 the first point's x coordinate
- * @param y1 the first point's y coordinate
- * @param x2 the second point's x coordinate
- * @param y2 the second point's y coordinate
- *
- * @exception SWTException <ul>
- * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
- * </ul>
+/**
+ * Draws a line, using the foreground color, between the points
+ * (<code>x1</code>, <code>y1</code>) and (<code>x2</code>, <code>y2</code>).
+ *
+ * @param x1 the first point's x coordinate
+ * @param y1 the first point's y coordinate
+ * @param x2 the second point's x coordinate
+ * @param y2 the second point's y coordinate
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
*/
public void drawLine(int x1, int y1, int x2, int y2) {
if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
OS.gdk_draw_line (data.drawable, handle, x1, y1, x2, y2);
}
-/**
- * Draws the outline of an oval, using the foreground color,
- * within the specified rectangular area.
- * <p>
- * The result is a circle or ellipse that fits within the
- * rectangle specified by the <code>x</code>, <code>y</code>,
- * <code>width</code>, and <code>height</code> arguments.
- * </p><p>
- * The oval covers an area that is <code>width + 1</code>
- * pixels wide and <code>height + 1</code> pixels tall.
- * </p>
- *
- * @param x the x coordinate of the upper left corner of the oval to be drawn
- * @param y the y coordinate of the upper left corner of the oval to be drawn
- * @param width the width of the oval to be drawn
- * @param height the height of the oval to be drawn
- *
- * @exception SWTException <ul>
- * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
- * </ul>
+/**
+ * Draws the outline of an oval, using the foreground color,
+ * within the specified rectangular area.
+ * <p>
+ * The result is a circle or ellipse that fits within the
+ * rectangle specified by the <code>x</code>, <code>y</code>,
+ * <code>width</code>, and <code>height</code> arguments.
+ * </p><p>
+ * The oval covers an area that is <code>width + 1</code>
+ * pixels wide and <code>height + 1</code> pixels tall.
+ * </p>
+ *
+ * @param x the x coordinate of the upper left corner of the oval to be drawn
+ * @param y the y coordinate of the upper left corner of the oval to be drawn
+ * @param width the width of the oval to be drawn
+ * @param height the height of the oval to be drawn
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
*/
public void drawOval(int x, int y, int width, int height) {
if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
@@ -534,44 +534,44 @@ public void drawOval(int x, int y, int width, int height) {
OS.gdk_draw_arc(data.drawable, handle, 0, x, y, width, height, 0, 23040);
}
-/**
- * Draws the closed polygon which is defined by the specified array
- * of integer coordinates, using the receiver's foreground color. The array
- * contains alternating x and y values which are considered to represent
- * points which are the vertices of the polygon. Lines are drawn between
- * each consecutive pair, and between the first pair and last pair in the
- * array.
- *
- * @param pointArray an array of alternating x and y values which are the vertices of the polygon
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT if pointArray is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
- * </ul>
+/**
+ * Draws the closed polygon which is defined by the specified array
+ * of integer coordinates, using the receiver's foreground color. The array
+ * contains alternating x and y values which are considered to represent
+ * points which are the vertices of the polygon. Lines are drawn between
+ * each consecutive pair, and between the first pair and last pair in the
+ * array.
+ *
+ * @param pointArray an array of alternating x and y values which are the vertices of the polygon
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT if pointArray is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
*/
public void drawPolygon(int[] pointArray) {
if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
if (pointArray == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
OS.gdk_draw_polygon(data.drawable, handle, 0, pointArray, pointArray.length / 2);
}
-/**
- * Draws the polyline which is defined by the specified array
- * of integer coordinates, using the receiver's foreground color. The array
- * contains alternating x and y values which are considered to represent
- * points which are the corners of the polyline. Lines are drawn between
- * each consecutive pair, but not between the first pair and last pair in
- * the array.
- *
- * @param pointArray an array of alternating x and y values which are the corners of the polyline
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the point array is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
- * </ul>
+/**
+ * Draws the polyline which is defined by the specified array
+ * of integer coordinates, using the receiver's foreground color. The array
+ * contains alternating x and y values which are considered to represent
+ * points which are the corners of the polyline. Lines are drawn between
+ * each consecutive pair, but not between the first pair and last pair in
+ * the array.
+ *
+ * @param pointArray an array of alternating x and y values which are the corners of the polyline
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if the point array is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
*/
public void drawPolyline(int[] pointArray) {
if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
@@ -579,20 +579,20 @@ public void drawPolyline(int[] pointArray) {
OS.gdk_draw_lines(data.drawable, 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
- *
- * @exception SWTException <ul>
- * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
- * </ul>
+/**
+ * Draws the outline of the rectangle specified by the arguments,
+ * using the receiver's foreground color. The left and right edges
+ * of the rectangle are at <code>x</code> and <code>x + width</code>.
+ * The top and bottom edges are at <code>y</code> and <code>y + height</code>.
+ *
+ * @param x the x coordinate of the rectangle to be drawn
+ * @param y the y coordinate of the rectangle to be drawn
+ * @param width the width of the rectangle to be drawn
+ * @param height the height of the rectangle to be drawn
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
*/
public void drawRectangle(int x, int y, int width, int height) {
if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
@@ -607,44 +607,44 @@ public void drawRectangle(int x, int y, int width, int height) {
OS.gdk_draw_rectangle(data.drawable, handle, 0, x, y, width, height);
}
-/**
- * Draws the outline of the specified rectangle, using the receiver's
- * foreground color. The left and right edges of the rectangle are at
- * <code>rect.x</code> and <code>rect.x + rect.width</code>. The top
- * and bottom edges are at <code>rect.y</code> and
- * <code>rect.y + rect.height</code>.
- *
- * @param rect the rectangle to draw
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the rectangle is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
- * </ul>
+/**
+ * Draws the outline of the specified rectangle, using the receiver's
+ * foreground color. The left and right edges of the rectangle are at
+ * <code>rect.x</code> and <code>rect.x + rect.width</code>. The top
+ * and bottom edges are at <code>rect.y</code> and
+ * <code>rect.y + rect.height</code>.
+ *
+ * @param rect the rectangle to draw
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if the rectangle is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
*/
public void drawRectangle(Rectangle rect) {
if (rect == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
drawRectangle (rect.x, rect.y, rect.width, rect.height);
}
-/**
- * Draws the outline of the round-cornered rectangle specified by
- * the arguments, using the receiver's foreground color. The left and
- * right edges of the rectangle are at <code>x</code> and <code>x + width</code>.
- * The top and bottom edges are at <code>y</code> and <code>y + height</code>.
- * The <em>roundness</em> of the corners is specified by the
- * <code>arcWidth</code> and <code>arcHeight</code> arguments.
- *
- * @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
- *
- * @exception SWTException <ul>
- * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
- * </ul>
+/**
+ * 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
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
*/
public void drawRoundRectangle(int x, int y, int width, int height, int arcWidth, int arcHeight) {
if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
@@ -700,46 +700,46 @@ public void drawRoundRectangle(int x, int y, int width, int height, int arcWidth
}
}
-/**
- * Draws the given string, using the receiver's current font and
- * foreground color. No tab expansion or carriage return processing
- * will be performed. The background of the rectangular area where
- * the string is being drawn will be filled with the receiver's
- * background color.
- *
- * @param string the string to be drawn
- * @param x the x coordinate of the top left corner of the rectangular area where the string is to be drawn
- * @param y the y coordinate of the top left corner of the rectangular area where the string is to be drawn
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the string is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
- * </ul>
+/**
+ * Draws the given string, using the receiver's current font and
+ * foreground color. No tab expansion or carriage return processing
+ * will be performed. The background of the rectangular area where
+ * the string is being drawn will be filled with the receiver's
+ * background color.
+ *
+ * @param string the string to be drawn
+ * @param x the x coordinate of the top left corner of the rectangular area where the string is to be drawn
+ * @param y the y coordinate of the top left corner of the rectangular area where the string is to be drawn
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if the string is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
*/
public void drawString (String string, int x, int y) {
drawString(string, x, y, false);
}
-/**
- * Draws the given string, using the receiver's current font and
- * foreground color. No tab expansion or carriage return processing
- * will be performed. If <code>isTransparent</code> is <code>true</code>,
- * then the background of the rectangular area where the string is being
- * drawn will not be modified, otherwise it will be filled with the
- * receiver's background color.
- *
- * @param string the string to be drawn
- * @param x the x coordinate of the top left corner of the rectangular area where the string is to be drawn
- * @param y the y coordinate of the top left corner of the rectangular area where the string is to be drawn
- * @param isTransparent if <code>true</code> the background will be transparent, otherwise it will be opaque
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the string is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
- * </ul>
+/**
+ * Draws the given string, using the receiver's current font and
+ * foreground color. No tab expansion or carriage return processing
+ * will be performed. If <code>isTransparent</code> is <code>true</code>,
+ * then the background of the rectangular area where the string is being
+ * drawn will not be modified, otherwise it will be filled with the
+ * receiver's background color.
+ *
+ * @param string the string to be drawn
+ * @param x the x coordinate of the top left corner of the rectangular area where the string is to be drawn
+ * @param y the y coordinate of the top left corner of the rectangular area where the string is to be drawn
+ * @param isTransparent if <code>true</code> the background will be transparent, otherwise it will be opaque
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if the string is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
*/
public void drawString(String string, int x, int y, boolean isTransparent) {
if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
@@ -751,47 +751,47 @@ public void drawString(String string, int x, int y, boolean isTransparent) {
OS.gdk_draw_layout(data.drawable, handle, x, y, layout);
}
-/**
- * Draws the given string, using the receiver's current font and
- * foreground color. Tab expansion and carriage return processing
- * are performed. The background of the rectangular area where
- * the text is being drawn will be filled with the receiver's
- * background color.
- *
- * @param string the string to be drawn
- * @param x the x coordinate of the top left corner of the rectangular area where the text is to be drawn
- * @param y the y coordinate of the top left corner of the rectangular area where the text is to be drawn
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the string is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
- * </ul>
+/**
+ * Draws the given string, using the receiver's current font and
+ * foreground color. Tab expansion and carriage return processing
+ * are performed. The background of the rectangular area where
+ * the text is being drawn will be filled with the receiver's
+ * background color.
+ *
+ * @param string the string to be drawn
+ * @param x the x coordinate of the top left corner of the rectangular area where the text is to be drawn
+ * @param y the y coordinate of the top left corner of the rectangular area where the text is to be drawn
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if the string is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
*/
public void drawText(String string, int x, int y) {
drawText(string, x, y, SWT.DRAW_DELIMITER | SWT.DRAW_TAB);
}
-/**
- * Draws the given string, using the receiver's current font and
- * foreground color. Tab expansion and carriage return processing
- * are performed. If <code>isTransparent</code> is <code>true</code>,
- * then the background of the rectangular area where the text is being
- * drawn will not be modified, otherwise it will be filled with the
- * receiver's background color.
- *
- * @param string the string to be drawn
- * @param x the x coordinate of the top left corner of the rectangular area where the text is to be drawn
- * @param y the y coordinate of the top left corner of the rectangular area where the text is to be drawn
- * @param isTransparent if <code>true</code> the background will be transparent, otherwise it will be opaque
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the string is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
- * </ul>
+/**
+ * Draws the given string, using the receiver's current font and
+ * foreground color. Tab expansion and carriage return processing
+ * are performed. If <code>isTransparent</code> is <code>true</code>,
+ * then the background of the rectangular area where the text is being
+ * drawn will not be modified, otherwise it will be filled with the
+ * receiver's background color.
+ *
+ * @param string the string to be drawn
+ * @param x the x coordinate of the top left corner of the rectangular area where the text is to be drawn
+ * @param y the y coordinate of the top left corner of the rectangular area where the text is to be drawn
+ * @param isTransparent if <code>true</code> the background will be transparent, otherwise it will be opaque
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if the string is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
*/
public void drawText(String string, int x, int y, boolean isTransparent) {
int flags = SWT.DRAW_DELIMITER | SWT.DRAW_TAB;
@@ -799,39 +799,39 @@ public void drawText(String string, int x, int y, boolean isTransparent) {
drawText(string, x, y, flags);
}
-/**
- * Draws the given string, using the receiver's current font and
- * foreground color. Tab expansion, line delimiter and mnemonic
- * processing are performed according to the specified flags. If
- * <code>flags</code> includes <code>DRAW_TRANSPARENT</code>,
- * then the background of the rectangular area where the text is being
- * drawn will not be modified, otherwise it will be filled with the
- * receiver's background color.
- * <p>
- * The parameter <code>flags</code> may be a combination of:
- * <dl>
- * <dt><b>DRAW_DELIMITER</b></dt>
- * <dd>draw multiple lines</dd>
- * <dt><b>DRAW_TAB</b></dt>
- * <dd>expand tabs</dd>
- * <dt><b>DRAW_MNEMONIC</b></dt>
- * <dd>underline the mnemonic character</dd>
- * <dt><b>DRAW_TRANSPARENT</b></dt>
- * <dd>transparent background</dd>
- * </dl>
- * </p>
- *
- * @param string the string to be drawn
- * @param x the x coordinate of the top left corner of the rectangular area where the text is to be drawn
- * @param y the y coordinate of the top left corner of the rectangular area where the text is to be drawn
- * @param flags the flags specifing how to process the text
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the string is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
- * </ul>
+/**
+ * Draws the given string, using the receiver's current font and
+ * foreground color. Tab expansion, line delimiter and mnemonic
+ * processing are performed according to the specified flags. If
+ * <code>flags</code> includes <code>DRAW_TRANSPARENT</code>,
+ * then the background of the rectangular area where the text is being
+ * drawn will not be modified, otherwise it will be filled with the
+ * receiver's background color.
+ * <p>
+ * The parameter <code>flags</code> may be a combination of:
+ * <dl>
+ * <dt><b>DRAW_DELIMITER</b></dt>
+ * <dd>draw multiple lines</dd>
+ * <dt><b>DRAW_TAB</b></dt>
+ * <dd>expand tabs</dd>
+ * <dt><b>DRAW_MNEMONIC</b></dt>
+ * <dd>underline the mnemonic character</dd>
+ * <dt><b>DRAW_TRANSPARENT</b></dt>
+ * <dd>transparent background</dd>
+ * </dl>
+ * </p>
+ *
+ * @param string the string to be drawn
+ * @param x the x coordinate of the top left corner of the rectangular area where the text is to be drawn
+ * @param y the y coordinate of the top left corner of the rectangular area where the text is to be drawn
+ * @param flags the flags specifing how to process the text
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if the string is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
*/
public void drawText (String string, int x, int y, int flags) {
if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
@@ -843,15 +843,15 @@ public void drawText (String string, int x, int y, int flags) {
OS.gdk_draw_layout(data.drawable, handle, x, y, layout);
}
-/**
- * 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
+/**
+ * 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;
@@ -859,40 +859,40 @@ public boolean equals(Object object) {
return handle == ((GC)object).handle;
}
-/**
- * Fills the interior of a circular or elliptical arc within
- * the specified rectangular area, with the receiver's background
- * color.
- * <p>
- * The resulting arc begins at <code>startAngle</code> and extends
- * for <code>arcAngle</code> degrees, using the current color.
- * Angles are interpreted such that 0 degrees is at the 3 o'clock
- * position. A positive value indicates a counter-clockwise rotation
- * while a negative value indicates a clockwise rotation.
- * </p><p>
- * The center of the arc is the center of the rectangle whose origin
- * is (<code>x</code>, <code>y</code>) and whose size is specified by the
- * <code>width</code> and <code>height</code> arguments.
- * </p><p>
- * The resulting arc covers an area <code>width + 1</code> pixels wide
- * by <code>height + 1</code> pixels tall.
- * </p>
- *
- * @param x the x coordinate of the upper-left corner of the arc to be filled
- * @param y the y coordinate of the upper-left corner of the arc to be filled
- * @param width the width of the arc to be filled
- * @param height the height of the arc to be filled
- * @param startAngle the beginning angle
- * @param arcAngle the angular extent of the arc, relative to the start angle
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_INVALID_ARGUMENT - if any of the width, height or endAngle is zero.</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
- * </ul>
- *
- * @see #drawArc
+/**
+ * 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>
+ * @exception SWTException <ul>
+ * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ *
+ * @see #drawArc
*/
public void fillArc(int x, int y, int width, int height, int startAngle, int endAngle) {
if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
@@ -917,25 +917,25 @@ public void fillArc(int x, int y, int width, int height, int startAngle, int end
OS.gdk_gc_set_foreground(handle, color);
}
-/**
- * Fills the interior of the specified rectangle with a gradient
- * sweeping from left to right or top to bottom progressing
- * from the receiver's foreground color to its background color.
- *
- * @param x the x coordinate of the rectangle to be filled
- * @param y the y coordinate of the rectangle to be filled
- * @param width the width of the rectangle to be filled, may be negative
- * (inverts direction of gradient if horizontal)
- * @param height the height of the rectangle to be filled, may be negative
- * (inverts direction of gradient if vertical)
- * @param vertical if true sweeps from top to bottom, else
- * sweeps from left to right
- *
- * @exception SWTException <ul>
- * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
- * </ul>
- *
- * @see #drawRectangle
+/**
+ * Fills the interior of the specified rectangle with a gradient
+ * sweeping from left to right or top to bottom progressing
+ * from the receiver's foreground color to its background color.
+ *
+ * @param x the x coordinate of the rectangle to be filled
+ * @param y the y coordinate of the rectangle to be filled
+ * @param width the width of the rectangle to be filled, may be negative
+ * (inverts direction of gradient if horizontal)
+ * @param height the height of the rectangle to be filled, may be negative
+ * (inverts direction of gradient if vertical)
+ * @param vertical if true sweeps from top to bottom, else
+ * sweeps from left to right
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ *
+ * @see #drawRectangle
*/
public void fillGradientRectangle(int x, int y, int width, int height, boolean vertical) {
if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
@@ -975,21 +975,21 @@ public void fillGradientRectangle(int x, int y, int width, int height, boolean v
8, 8, 8);
}
-/**
- * Fills the interior of an oval, within the specified
- * rectangular area, with the receiver's background
- * color.
- *
- * @param x the x coordinate of the upper left corner of the oval to be filled
- * @param y the y coordinate of the upper left corner of the oval to be filled
- * @param width the width of the oval to be filled
- * @param height the height of the oval to be filled
- *
- * @exception SWTException <ul>
- * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
- * </ul>
- *
- * @see #drawOval
+/**
+ * Fills the interior of an oval, within the specified
+ * rectangular area, with the receiver's background
+ * color.
+ *
+ * @param x the x coordinate of the upper left corner of the oval to be filled
+ * @param y the y coordinate of the upper left corner of the oval to be filled
+ * @param width the width of the oval to be filled
+ * @param height the height of the oval to be filled
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ *
+ * @see #drawOval
*/
public void fillOval(int x, int y, int width, int height) {
if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
@@ -1011,24 +1011,24 @@ public void fillOval(int x, int y, int width, int height) {
OS.gdk_gc_set_foreground(handle, color);
}
-/**
- * Fills the interior of the closed polygon which is defined by the
- * specified array of integer coordinates, using the receiver's
- * background color. The array contains alternating x and y values
- * which are considered to represent points which are the vertices of
- * the polygon. Lines are drawn between each consecutive pair, and
- * between the first pair and last pair in the array.
- *
- * @param pointArray an array of alternating x and y values which are the vertices of the polygon
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT if pointArray is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
- * </ul>
- *
- * @see #drawPolygon
+/**
+ * Fills the interior of the closed polygon which is defined by the
+ * specified array of integer coordinates, using the receiver's
+ * background color. The array contains alternating x and y values
+ * which are considered to represent points which are the vertices of
+ * the polygon. Lines are drawn between each consecutive pair, and
+ * between the first pair and last pair in the array.
+ *
+ * @param pointArray an array of alternating x and y values which are the vertices of the polygon
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT if pointArray is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ *
+ * @see #drawPolygon
*/
public void fillPolygon(int[] pointArray) {
if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
@@ -1043,20 +1043,20 @@ public void fillPolygon(int[] pointArray) {
OS.gdk_gc_set_foreground(handle, color);
}
-/**
- * Fills the interior of the rectangle specified by the arguments,
- * using the receiver's background color.
- *
- * @param x the x coordinate of the rectangle to be filled
- * @param y the y coordinate of the rectangle to be filled
- * @param width the width of the rectangle to be filled
- * @param height the height of the rectangle to be filled
- *
- * @exception SWTException <ul>
- * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
- * </ul>
- *
- * @see #drawRectangle
+/**
+ * Fills the interior of the rectangle specified by the arguments,
+ * using the receiver's background color.
+ *
+ * @param x the x coordinate of the rectangle to be filled
+ * @param y the y coordinate of the rectangle to be filled
+ * @param width the width of the rectangle to be filled
+ * @param height the height of the rectangle to be filled
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ *
+ * @see #drawRectangle
*/
public void fillRectangle(int x, int y, int width, int height) {
if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
@@ -1078,20 +1078,20 @@ public void fillRectangle(int x, int y, int width, int height) {
OS.gdk_gc_set_foreground(handle, color);
}
-/**
- * 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>
- * @exception SWTException <ul>
- * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
- * </ul>
- *
- * @see #drawRectangle
+/**
+ * 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>
+ * @exception SWTException <ul>
+ * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ *
+ * @see #drawRectangle
*/
public void fillRectangle(Rectangle rect) {
if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
@@ -1099,22 +1099,22 @@ public void fillRectangle(Rectangle rect) {
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
- *
- * @exception SWTException <ul>
- * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
- * </ul>
- *
- * @see #drawRoundRectangle
+/**
+ * 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
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ *
+ * @see #drawRoundRectangle
*/
public void fillRoundRectangle(int x, int y, int width, int height, int arcWidth, int arcHeight) {
if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
@@ -1176,20 +1176,20 @@ public void fillRoundRectangle(int x, int y, int width, int height, int arcWidth
OS.gdk_gc_set_foreground(handle, color);
}
-/**
- * Returns the <em>advance width</em> of the specified character in
- * the font which is currently selected into the receiver.
- * <p>
- * The advance width is defined as the horizontal distance the cursor
- * should move after printing the character in the selected font.
- * </p>
- *
- * @param ch the character to measure
- * @return the distance in the x direction to move past the character before painting the next
- *
- * @exception SWTException <ul>
- * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
- * </ul>
+/**
+ * Returns the <em>advance width</em> of the specified character in
+ * the font which is currently selected into the receiver.
+ * <p>
+ * The advance width is defined as the horizontal distance the cursor
+ * should move after printing the character in the selected font.
+ * </p>
+ *
+ * @param ch the character to measure
+ * @return the distance in the x direction to move past the character before painting the next
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
*/
public int getAdvanceWidth(char ch) {
if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
@@ -1197,14 +1197,14 @@ public int getAdvanceWidth(char ch) {
return stringExtent(new String(new char[]{ch})).x;
}
-/**
- * Returns the background color.
- *
- * @return the receiver's background color
- *
- * @exception SWTException <ul>
- * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
- * </ul>
+/**
+ * Returns the background color.
+ *
+ * @return the receiver's background color
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
*/
public Color getBackground() {
if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
@@ -1217,21 +1217,21 @@ public Color getBackground() {
return Color.gtk_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
- *
- * @exception SWTException <ul>
- * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
- * </ul>
+/**
+ * Returns the width of the specified character in the font
+ * selected into the receiver.
+ * <p>
+ * The width is defined as the space taken up by the actual
+ * character, not including the leading and tailing whitespace
+ * or overhang.
+ * </p>
+ *
+ * @param ch the character to measure
+ * @return the width of the character
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
*/
public int getCharWidth(char ch) {
if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
@@ -1239,17 +1239,17 @@ public int getCharWidth(char ch) {
return stringExtent(new String(new char[]{ch})).x;
}
-/**
- * Returns the bounding rectangle of the receiver's clipping
- * region. If no clipping region is set, the return value
- * will be a rectangle which covers the entire bounds of the
- * object the receiver is drawing on.
- *
- * @return the bounding rectangle of the clipping region
- *
- * @exception SWTException <ul>
- * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
- * </ul>
+/**
+ * Returns the bounding rectangle of the receiver's clipping
+ * region. If no clipping region is set, the return value
+ * will be a rectangle which covers the entire bounds of the
+ * object the receiver is drawing on.
+ *
+ * @return the bounding rectangle of the clipping region
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
*/
public Rectangle getClipping() {
if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
@@ -1264,18 +1264,18 @@ public Rectangle getClipping() {
return new Rectangle(rect.x, rect.y, rect.width, rect.height);
}
-/**
- * Sets the region managed by the argument to the current
- * clipping region of the receiver.
- *
- * @param region the region to fill with the clipping region
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the region is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
- * </ul>
+/**
+ * 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>
+ * @exception SWTException <ul>
+ * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
*/
public void getClipping(Region region) {
if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
@@ -1294,31 +1294,31 @@ public void getClipping(Region region) {
}
OS.gdk_region_union(hRegion, clipRgn);
}
-/**
- * Returns the font currently being used by the receiver
- * to draw and measure text.
- *
- * @return the receiver's font
- *
- * @exception SWTException <ul>
- * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
- * </ul>
+/**
+ * Returns the font currently being used by the receiver
+ * to draw and measure text.
+ *
+ * @return the receiver's font
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
*/
public Font getFont() {
if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
return Font.gtk_new(data.device, data.font);
}
-/**
- * Returns a FontMetrics which contains information
- * about the font currently being used by the receiver
- * to draw and measure text.
- *
- * @return font metrics for the receiver's font
- *
- * @exception SWTException <ul>
- * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
- * </ul>
+/**
+ * Returns a FontMetrics which contains information
+ * about the font currently being used by the receiver
+ * to draw and measure text.
+ *
+ * @return font metrics for the receiver's font
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
*/
public FontMetrics getFontMetrics() {
if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
@@ -1334,14 +1334,14 @@ public FontMetrics getFontMetrics() {
return fm;
}
-/**
- * Returns the receiver's foreground color.
- *
- * @return the color used for drawing foreground things
- *
- * @exception SWTException <ul>
- * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
- * </ul>
+/**
+ * Returns the receiver's foreground color.
+ *
+ * @return the color used for drawing foreground things
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
*/
public Color getForeground() {
if (handle == 0) SWT.error(SWT.ERROR_WIDGET_DISPOSED);
@@ -1354,34 +1354,34 @@ public Color getForeground() {
return Color.gtk_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
- *
- * @exception SWTException <ul>
- * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
- * </ul>
+/**
+ * Returns the receiver's line style, which will be one
+ * of the constants <code>SWT.LINE_SOLID</code>, <code>SWT.LINE_DASH</code>,
+ * <code>SWT.LINE_DOT</code>, <code>SWT.LINE_DASHDOT</code> or
+ * <code>SWT.LINE_DASHDOTDOT</code>.
+ *
+ * @return the style used for drawing lines
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
*/
public int getLineStyle() {
if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
return data.lineStyle;
}
-/**
- * Returns the width that will be used when drawing lines
- * for all of the figure drawing operations (that is,
- * <code>drawLine</code>, <code>drawRectangle</code>,
- * <code>drawPolyline</code>, and so forth.
- *
- * @return the receiver's line width
- *
- * @exception SWTException <ul>
- * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
- * </ul>
+/**
+ * Returns the width that will be used when drawing lines
+ * for all of the figure drawing operations (that is,
+ * <code>drawLine</code>, <code>drawRectangle</code>,
+ * <code>drawPolyline</code>, and so forth.
+ *
+ * @return the receiver's line width
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
*/
public int getLineWidth() {
if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
@@ -1390,19 +1390,19 @@ public int getLineWidth() {
return values.line_width;
}
-/**
- * Returns <code>true</code> if this GC is drawing in the mode
- * where the resulting color in the destination is the
- * <em>exclusive or</em> of the color values in the source
- * and the destination, and <code>false</code> if it is
- * drawing in the mode where the destination color is being
- * replaced with the source color value.
- *
- * @return <code>true</code> true if the receiver is in XOR mode, and false otherwise
- *
- * @exception SWTException <ul>
- * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
- * </ul>
+/**
+ * Returns <code>true</code> if this GC is drawing in the mode
+ * where the resulting color in the destination is the
+ * <em>exclusive or</em> of the color values in the source
+ * and the destination, and <code>false</code> if it is
+ * drawing in the mode where the destination color is being
+ * replaced with the source color value.
+ *
+ * @return <code>true</code> true if the receiver is in XOR mode, and false otherwise
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
*/
public boolean getXORMode() {
if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
@@ -1411,19 +1411,19 @@ public boolean getXORMode() {
return values.function == OS.GDK_XOR;
}
-/**
- * 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
- *
- * @exception SWTException <ul>
- * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
- * </ul>
- *
- * @see #equals
+/**
+ * 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
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ *
+ * @see #equals
*/
public int hashCode() {
return handle;
@@ -1460,53 +1460,53 @@ void init(Drawable drawable, GCData data, int gdkGC) {
handle = gdkGC;
}
-/**
- * Returns <code>true</code> if the receiver has a clipping
- * region set into it, and <code>false</code> otherwise.
- * If this method returns false, the receiver will draw on all
- * available space in the destination. If it returns true,
- * it will draw only in the area that is covered by the region
- * that can be accessed with <code>getClipping(region)</code>.
- *
- * @return <code>true</code> if the GC has a clipping region, and <code>false</code> otherwise
- *
- * @exception SWTException <ul>
- * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
- * </ul>
+/**
+ * Returns <code>true</code> if the receiver has a clipping
+ * region set into it, and <code>false</code> otherwise.
+ * If this method returns false, the receiver will draw on all
+ * available space in the destination. If it returns true,
+ * it will draw only in the area that is covered by the region
+ * that can be accessed with <code>getClipping(region)</code>.
+ *
+ * @return <code>true</code> if the GC has a clipping region, and <code>false</code> otherwise
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
*/
public boolean isClipped() {
if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
return data.clipRgn != 0;
}
-/**
- * Returns <code>true</code> if the GC has been disposed,
- * and <code>false</code> otherwise.
- * <p>
- * This method gets the dispose state for the GC.
- * When a GC has been disposed, it is an error to
- * invoke any other method using the GC.
- *
- * @return <code>true</code> when the GC is disposed and <code>false</code> otherwise
+/**
+ * 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>
- * <li>ERROR_INVALID_ARGUMENT - if the color has been disposed</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
- * </ul>
+/**
+ * Sets the background color. The background color is used
+ * for fill operations and as the background color when text
+ * is drawn.
+ *
+ * @param color the new background color for the receiver
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if the color is null</li>
+ * <li>ERROR_INVALID_ARGUMENT - if the color has been disposed</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
*/
public void setBackground(Color color) {
if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
@@ -1515,19 +1515,19 @@ public void setBackground(Color color) {
OS.gdk_gc_set_background(handle, color.handle);
}
-/**
- * Sets the area of the receiver which can be changed
- * by drawing operations to the rectangular area specified
- * by the arguments.
- *
- * @param x the x coordinate of the clipping rectangle
- * @param y the y coordinate of the clipping rectangle
- * @param width the width of the clipping rectangle
- * @param height the height of the clipping rectangle
- *
- * @exception SWTException <ul>
- * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
- * </ul>
+/**
+ * Sets the area of the receiver which can be changed
+ * by drawing operations to the rectangular area specified
+ * by the arguments.
+ *
+ * @param x the x coordinate of the clipping rectangle
+ * @param y the y coordinate of the clipping rectangle
+ * @param width the width of the clipping rectangle
+ * @param height the height of the clipping rectangle
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
*/
public void setClipping(int x, int y, int width, int height) {
if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
@@ -1543,16 +1543,16 @@ public void setClipping(int x, int y, int width, int height) {
OS.gdk_gc_set_clip_rectangle(handle, rect);
OS.gdk_region_union_with_rect(clipRgn, rect);
}
-/**
- * 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 SWTException <ul>
- * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
- * </ul>
+/**
+ * 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 SWTException <ul>
+ * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
*/
public void setClipping(Rectangle rect) {
if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
@@ -1567,16 +1567,16 @@ public void setClipping(Rectangle rect) {
}
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.
- *
- * @exception SWTException <ul>
- * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
- * </ul>
+/**
+ * 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.
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
*/
public void setClipping(Region region) {
if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
@@ -1598,20 +1598,20 @@ public void setClipping(Region region) {
}
}
-/**
- * Sets the font which will be used by the receiver
- * to draw and measure text to the argument. If the
- * argument is null, then a default font appropriate
- * for the platform will be used instead.
- *
- * @param font the new font for the receiver, or null to indicate a default font
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_INVALID_ARGUMENT - if the font has been disposed</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
- * </ul>
+/**
+ * Sets the font which will be used by the receiver
+ * to draw and measure text to the argument. If the
+ * argument is null, then a default font appropriate
+ * for the platform will be used instead.
+ *
+ * @param font the new font for the receiver, or null to indicate a default font
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_INVALID_ARGUMENT - if the font has been disposed</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
*/
public void setFont(Font font) {
if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
@@ -1621,19 +1621,19 @@ public void setFont(Font font) {
OS.pango_layout_set_font_description(data.layout, fontHandle);
}
-/**
- * Sets the foreground color. The foreground color is used
- * for drawing operations including when text is drawn.
- *
- * @param color the new foreground color for the receiver
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the color is null</li>
- * <li>ERROR_INVALID_ARGUMENT - if the color has been disposed</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
- * </ul>
+/**
+ * Sets the foreground color. The foreground color is used
+ * for drawing operations including when text is drawn.
+ *
+ * @param color the new foreground color for the receiver
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if the color is null</li>
+ * <li>ERROR_INVALID_ARGUMENT - if the color has been disposed</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
*/
public void setForeground(Color color) {
if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
@@ -1642,17 +1642,17 @@ public void setForeground(Color color) {
OS.gdk_gc_set_foreground(handle, color.handle);
}
-/**
- * Sets the receiver's line style to the argument, which must be one
- * of the constants <code>SWT.LINE_SOLID</code>, <code>SWT.LINE_DASH</code>,
- * <code>SWT.LINE_DOT</code>, <code>SWT.LINE_DASHDOT</code> or
- * <code>SWT.LINE_DASHDOTDOT</code>.
- *
- * @param lineStyle the style to be used for drawing lines
- *
- * @exception SWTException <ul>
- * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
- * </ul>
+/**
+ * Sets the receiver's line style to the argument, which must be one
+ * of the constants <code>SWT.LINE_SOLID</code>, <code>SWT.LINE_DASH</code>,
+ * <code>SWT.LINE_DOT</code>, <code>SWT.LINE_DASHDOT</code> or
+ * <code>SWT.LINE_DASHDOTDOT</code>.
+ *
+ * @param lineStyle the style to be used for drawing lines
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
*/
public void setLineStyle(int lineStyle) {
if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
@@ -1680,17 +1680,17 @@ public void setLineStyle(int lineStyle) {
OS.gdk_gc_set_line_attributes(handle, 0, OS.GDK_LINE_ON_OFF_DASH, OS.GDK_CAP_BUTT, OS.GDK_JOIN_MITER);
}
-/**
- * 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
- *
- * @exception SWTException <ul>
- * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
- * </ul>
+/**
+ * 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
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
*/
public void setLineWidth(int width) {
if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
@@ -1701,43 +1701,43 @@ public void setLineWidth(int width) {
}
}
-/**
- * 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
- *
- * @exception SWTException <ul>
- * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
- * </ul>
+/**
+ * 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
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
*/
public void setXORMode(boolean val) {
if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
OS.gdk_gc_set_function(handle, val ? OS.GDK_XOR : OS.GDK_COPY);
}
-/**
- * Returns the extent of the given string. No tab
- * expansion or carriage return processing will be performed.
- * <p>
- * The <em>extent</em> of a string is the width and height of
- * the rectangular area it would cover if drawn in a particular
- * font (in this case, the current font in the receiver).
- * </p>
- *
- * @param string the string to measure
- * @return a point containing the extent of the string
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the string is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
- * </ul>
+/**
+ * Returns the extent of the given string. No tab
+ * expansion or carriage return processing will be performed.
+ * <p>
+ * The <em>extent</em> of a string is the width and height of
+ * the rectangular area it would cover if drawn in a particular
+ * font (in this case, the current font in the receiver).
+ * </p>
+ *
+ * @param string the string to measure
+ * @return a point containing the extent of the string
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if the string is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
*/
public Point stringExtent(String string) {
if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
@@ -1752,59 +1752,59 @@ public Point stringExtent(String string) {
return new Point(OS.PANGO_PIXELS(width[0]), OS.PANGO_PIXELS(height[0]));
}
-/**
- * Returns the extent of the given string. Tab expansion and
- * carriage return processing are performed.
- * <p>
- * The <em>extent</em> of a string is the width and height of
- * the rectangular area it would cover if drawn in a particular
- * font (in this case, the current font in the receiver).
- * </p>
- *
- * @param string the string to measure
- * @return a point containing the extent of the string
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the string is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
- * </ul>
+/**
+ * Returns the extent of the given string. Tab expansion and
+ * carriage return processing are performed.
+ * <p>
+ * The <em>extent</em> of a string is the width and height of
+ * the rectangular area it would cover if drawn in a particular
+ * font (in this case, the current font in the receiver).
+ * </p>
+ *
+ * @param string the string to measure
+ * @return a point containing the extent of the string
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if the string is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
*/
public Point textExtent(String string) {
return textExtent(string, SWT.DRAW_DELIMITER | SWT.DRAW_TAB);
}
-/**
- * Returns the extent of the given string. Tab expansion, line
- * delimiter and mnemonic processing are performed according to
- * the specified flags, which can be a combination of:
- * <dl>
- * <dt><b>DRAW_DELIMITER</b></dt>
- * <dd>draw multiple lines</dd>
- * <dt><b>DRAW_TAB</b></dt>
- * <dd>expand tabs</dd>
- * <dt><b>DRAW_MNEMONIC</b></dt>
- * <dd>underline the mnemonic character</dd>
- * <dt><b>DRAW_TRANSPARENT</b></dt>
- * <dd>transparent background</dd>
- * </dl>
- * <p>
- * The <em>extent</em> of a string is the width and height of
- * the rectangular area it would cover if drawn in a particular
- * font (in this case, the current font in the receiver).
- * </p>
- *
- * @param string the string to measure
- * @param flags the flags specifing how to process the text
- * @return a point containing the extent of the string
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the string is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
- * </ul>
+/**
+ * Returns the extent of the given string. Tab expansion, line
+ * delimiter and mnemonic processing are performed according to
+ * the specified flags, which can be a combination of:
+ * <dl>
+ * <dt><b>DRAW_DELIMITER</b></dt>
+ * <dd>draw multiple lines</dd>
+ * <dt><b>DRAW_TAB</b></dt>
+ * <dd>expand tabs</dd>
+ * <dt><b>DRAW_MNEMONIC</b></dt>
+ * <dd>underline the mnemonic character</dd>
+ * <dt><b>DRAW_TRANSPARENT</b></dt>
+ * <dd>transparent background</dd>
+ * </dl>
+ * <p>
+ * The <em>extent</em> of a string is the width and height of
+ * the rectangular area it would cover if drawn in a particular
+ * font (in this case, the current font in the receiver).
+ * </p>
+ *
+ * @param string the string to measure
+ * @param flags the flags specifing how to process the text
+ * @return a point containing the extent of the string
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if the string is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
*/
public Point textExtent(String string, int flags) {
if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
@@ -1819,11 +1819,11 @@ public Point textExtent(String string, int flags) {
return new Point(OS.PANGO_PIXELS(width[0]), OS.PANGO_PIXELS(height[0]));
}
-/**
- * Returns a string containing a concise, human-readable
- * description of the receiver.
- *
- * @return a string representation of the receiver
+/**
+ * Returns a string containing a concise, human-readable
+ * description of the receiver.
+ *
+ * @return a string representation of the receiver
*/
public String toString () {
if (isDisposed()) return "GC {*DISPOSED*}";
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/GCData.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/GCData.java
index e3fd3d689c..620d611c0f 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/GCData.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/GCData.java
@@ -1,36 +1,36 @@
-package org.eclipse.swt.graphics;
-
-/*
+package org.eclipse.swt.graphics;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-import org.eclipse.swt.internal.gtk.*;
-import org.eclipse.swt.*;
-
-/**
- * Instances of this class are descriptions of GCs in terms
- * of unallocated platform-specific data fields.
- * <p>
- * <b>IMPORTANT:</b> This class is <em>not</em> part of the public
- * API for SWT. It is marked public only so that it can be shared
- * within the packages provided by SWT. It is not available on all
- * platforms, and should never be called from application code.
- * </p>
- *
- * @private
+ * http://www.eclipse.org/legal/cpl-v10.html
*/
-public final class GCData {
- public Device device;
- public Image image;
- public int drawable;
- public GdkColor foreground;
- public GdkColor background;
- public int font;
- public int context;
- public int layout;
- public int clipRgn;
- public int lineStyle = SWT.LINE_SOLID;
+
+import org.eclipse.swt.internal.gtk.*;
+import org.eclipse.swt.*;
+
+/**
+ * Instances of this class are descriptions of GCs in terms
+ * of unallocated platform-specific data fields.
+ * <p>
+ * <b>IMPORTANT:</b> This class is <em>not</em> part of the public
+ * API for SWT. It is marked public only so that it can be shared
+ * within the packages provided by SWT. It is not available on all
+ * platforms, and should never be called from application code.
+ * </p>
+ *
+ * @private
+ */
+public final class GCData {
+ public Device device;
+ public Image image;
+ public int drawable;
+ public GdkColor foreground;
+ public GdkColor background;
+ public int font;
+ public int context;
+ public int layout;
+ public int clipRgn;
+ public int lineStyle = SWT.LINE_SOLID;
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/Image.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/Image.java
index ae7658aae8..871e2b6e57 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/Image.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/Image.java
@@ -11,58 +11,58 @@ import org.eclipse.swt.internal.gtk.*;
import org.eclipse.swt.*;
import java.io.*;
-/**
- * Instances of this class are graphics which have been prepared
- * for display on a specific device. That is, they are ready
- * to paint using methods such as <code>GC.drawImage()</code>
- * and display on widgets with, for example, <code>Button.setImage()</code>.
- * <p>
- * If loaded from a file format that supports it, an
- * <code>Image</code> may have transparency, meaning that certain
- * pixels are specified as being transparent when drawn. Examples
- * of file formats that support transparency are GIF and PNG.
- * </p><p>
- * There are two primary ways to use <code>Images</code>.
- * The first is to load a graphic file from disk and create an
- * <code>Image</code> from it. This is done using an <code>Image</code>
- * constructor, for example:
- * <pre>
- * Image i = new Image(device, "C:\\graphic.bmp");
- * </pre>
- * A graphic file may contain a color table specifying which
- * colors the image was intended to possess. In the above example,
- * these colors will be mapped to the closest available color in
- * SWT. It is possible to get more control over the mapping of
- * colors as the image is being created, using code of the form:
- * <pre>
- * ImageData data = new ImageData("C:\\graphic.bmp");
- * RGB[] rgbs = data.getRGBs();
- * // At this point, rgbs contains specifications of all
- * // the colors contained within this image. You may
- * // allocate as many of these colors as you wish by
- * // using the Color constructor Color(RGB), then
- * // create the image:
- * Image i = new Image(device, data);
- * </pre>
- * <p>
- * Applications which require even greater control over the image
- * loading process should use the support provided in class
- * <code>ImageLoader</code>.
- * </p><p>
- * Application code must 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
+/**
+ * Instances of this class are graphics which have been prepared
+ * for display on a specific device. That is, they are ready
+ * to paint using methods such as <code>GC.drawImage()</code>
+ * and display on widgets with, for example, <code>Button.setImage()</code>.
+ * <p>
+ * If loaded from a file format that supports it, an
+ * <code>Image</code> may have transparency, meaning that certain
+ * pixels are specified as being transparent when drawn. Examples
+ * of file formats that support transparency are GIF and PNG.
+ * </p><p>
+ * There are two primary ways to use <code>Images</code>.
+ * The first is to load a graphic file from disk and create an
+ * <code>Image</code> from it. This is done using an <code>Image</code>
+ * constructor, for example:
+ * <pre>
+ * Image i = new Image(device, "C:\\graphic.bmp");
+ * </pre>
+ * A graphic file may contain a color table specifying which
+ * colors the image was intended to possess. In the above example,
+ * these colors will be mapped to the closest available color in
+ * SWT. It is possible to get more control over the mapping of
+ * colors as the image is being created, using code of the form:
+ * <pre>
+ * ImageData data = new ImageData("C:\\graphic.bmp");
+ * RGB[] rgbs = data.getRGBs();
+ * // At this point, rgbs contains specifications of all
+ * // the colors contained within this image. You may
+ * // allocate as many of these colors as you wish by
+ * // using the Color constructor Color(RGB), then
+ * // create the image:
+ * Image i = new Image(device, data);
+ * </pre>
+ * <p>
+ * Applications which require even greater control over the image
+ * loading process should use the support provided in class
+ * <code>ImageLoader</code>.
+ * </p><p>
+ * Application code must 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>)
+ /**
+ * specifies whether the receiver is a bitmap or an icon
+ * (one of <code>SWT.BITMAP</code>, <code>SWT.ICON</code>)
*/
public int type;
@@ -116,35 +116,35 @@ public final class Image implements Drawable{
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>
- * <p>
- * Note: Some platforms may have a limitation on the size
- * of image that can be created (size depends on width, height,
- * and depth). For example, Windows 95, 98, and ME do not allow
- * images larger than 16M.
- * </p>
- *
- * @param device the device on which to create the image
- * @param width the width of the new image
- * @param height the height of the new image
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if device is null and there is no current device</li>
- * <li>ERROR_INVALID_ARGUMENT - if either the width or height is negative or zero</li>
- * </ul>
- * @exception SWTError <ul>
- * <li>ERROR_NO_HANDLES if a handle could not be obtained for image creation</li>
- * </ul>
+/**
+ * Constructs an empty instance of this class with the
+ * specified width and height. The result may be drawn upon
+ * by creating a GC and using any of its drawing operations,
+ * as shown in the following example:
+ * <pre>
+ * Image i = new Image(device, width, height);
+ * GC gc = new GC(i);
+ * gc.drawRectangle(0, 0, 50, 50);
+ * gc.dispose();
+ * </pre>
+ * <p>
+ * Note: Some platforms may have a limitation on the size
+ * of image that can be created (size depends on width, height,
+ * and depth). For example, Windows 95, 98, and ME do not allow
+ * images larger than 16M.
+ * </p>
+ *
+ * @param device the device on which to create the image
+ * @param width the width of the new image
+ * @param height the height of the new image
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if device is null and there is no current device</li>
+ * <li>ERROR_INVALID_ARGUMENT - if either the width or height is negative or zero</li>
+ * </ul>
+ * @exception SWTError <ul>
+ * <li>ERROR_NO_HANDLES if a handle could not be obtained for image creation</li>
+ * </ul>
*/
public Image(Device device, int width, int height) {
if (device == null) device = Device.getDevice();
@@ -153,36 +153,36 @@ public Image(Device device, int width, int 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 device is null and there is no current device</li>
- * <li>ERROR_NULL_ARGUMENT - if srcImage is null</li>
- * <li>ERROR_INVALID_ARGUMENT - if the flag is not one of <code>IMAGE_COPY</code>, <code>IMAGE_DISABLE</code> or <code>IMAGE_GRAY</code></li>
- * <li>ERROR_INVALID_ARGUMENT - if the image has been disposed</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_INVALID_IMAGE - if the image is not a bitmap or an icon, or
- * is otherwise in an invalid state</li>
- * </ul>
- * @exception SWTError <ul>
- * <li>ERROR_NO_HANDLES if a handle could not be obtained for image creation</li>
- * </ul>
+/**
+ * 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 device is null and there is no current device</li>
+ * <li>ERROR_NULL_ARGUMENT - if srcImage is null</li>
+ * <li>ERROR_INVALID_ARGUMENT - if the flag is not one of <code>IMAGE_COPY</code>, <code>IMAGE_DISABLE</code> or <code>IMAGE_GRAY</code></li>
+ * <li>ERROR_INVALID_ARGUMENT - if the image has been disposed</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_INVALID_IMAGE - if the image is not a bitmap or an icon, or
+ * is otherwise in an invalid state</li>
+ * </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();
@@ -322,35 +322,35 @@ public Image(Device device, Image srcImage, int flag) {
if (device.tracking) device.new_Object(this);
}
-/**
- * Constructs an empty instance of this class with the
- * width and height of the specified rectangle. The result
- * may be drawn upon by creating a GC and using any of its
- * drawing operations, as shown in the following example:
- * <pre>
- * Image i = new Image(device, boundsRectangle);
- * GC gc = new GC(i);
- * gc.drawRectangle(0, 0, 50, 50);
- * gc.dispose();
- * </pre>
- * <p>
- * Note: Some platforms may have a limitation on the size
- * of image that can be created (size depends on width, height,
- * and depth). For example, Windows 95, 98, and ME do not allow
- * images larger than 16M.
- * </p>
- *
- * @param device the device on which to create the image
- * @param bounds a rectangle specifying the image's width and height (must not be null)
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if device is null and there is no current device</li>
- * <li>ERROR_NULL_ARGUMENT - if the bounds rectangle is null</li>
- * <li>ERROR_INVALID_ARGUMENT - if either the rectangle's width or height is negative</li>
- * </ul>
- * @exception SWTError <ul>
- * <li>ERROR_NO_HANDLES if a handle could not be obtained for image creation</li>
- * </ul>
+/**
+ * Constructs an empty instance of this class with the
+ * width and height of the specified rectangle. The result
+ * may be drawn upon by creating a GC and using any of its
+ * drawing operations, as shown in the following example:
+ * <pre>
+ * Image i = new Image(device, boundsRectangle);
+ * GC gc = new GC(i);
+ * gc.drawRectangle(0, 0, 50, 50);
+ * gc.dispose();
+ * </pre>
+ * <p>
+ * Note: Some platforms may have a limitation on the size
+ * of image that can be created (size depends on width, height,
+ * and depth). For example, Windows 95, 98, and ME do not allow
+ * images larger than 16M.
+ * </p>
+ *
+ * @param device the device on which to create the image
+ * @param bounds a rectangle specifying the image's width and height (must not be null)
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if device is null and there is no current device</li>
+ * <li>ERROR_NULL_ARGUMENT - if the bounds rectangle is null</li>
+ * <li>ERROR_INVALID_ARGUMENT - if either the rectangle's width or height is negative</li>
+ * </ul>
+ * @exception SWTError <ul>
+ * <li>ERROR_NO_HANDLES if a handle could not be obtained for image creation</li>
+ * </ul>
*/
public Image(Device device, Rectangle bounds) {
if (device == null) device = Device.getDevice();
@@ -360,20 +360,20 @@ public Image(Device device, Rectangle bounds) {
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 device is null and there is no current device</li>
- * <li>ERROR_NULL_ARGUMENT - if the image data is null</li>
- * </ul>
- * @exception SWTError <ul>
- * <li>ERROR_NO_HANDLES if a handle could not be obtained for image creation</li>
- * </ul>
+/**
+ * Constructs an instance of this class from the given
+ * <code>ImageData</code>.
+ *
+ * @param device the device on which to create the image
+ * @param data the image data to create the image from (must not be null)
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if device is null and there is no current device</li>
+ * <li>ERROR_NULL_ARGUMENT - if the image data is null</li>
+ * </ul>
+ * @exception SWTError <ul>
+ * <li>ERROR_NO_HANDLES if a handle could not be obtained for image creation</li>
+ * </ul>
*/
public Image(Device device, ImageData data) {
if (device == null) device = Device.getDevice();
@@ -382,34 +382,34 @@ public Image(Device device, ImageData 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 device is null and there is no current device</li>
- * <li>ERROR_NULL_ARGUMENT - if either the source or mask is null </li>
- * <li>ERROR_INVALID_ARGUMENT - if source and mask are different sizes or
- * if the mask is not monochrome, or if either the source or mask
- * is already an icon</li>
- * </ul>
- * @exception SWTError <ul>
- * <li>ERROR_NO_HANDLES if a handle could not be obtained for image creation</li>
- * </ul>
+/**
+ * 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 device is null and there is no current device</li>
+ * <li>ERROR_NULL_ARGUMENT - if either the source or mask is null </li>
+ * <li>ERROR_INVALID_ARGUMENT - if source and mask are different sizes or
+ * if the mask is not monochrome, or if either the source or mask
+ * is already an icon</li>
+ * </ul>
+ * @exception SWTError <ul>
+ * <li>ERROR_NO_HANDLES if a handle could not be obtained for image creation</li>
+ * </ul>
*/
public Image(Device device, ImageData source, ImageData mask) {
if (device == null) device = Device.getDevice();
@@ -427,37 +427,37 @@ public Image(Device device, ImageData source, ImageData mask) {
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 IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if device is null and there is no current device</li>
- * <li>ERROR_NULL_ARGUMENT - if the stream is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_INVALID_IMAGE - if the image file contains invalid data </li>
- * <li>ERROR_IO - if an IO error occurs while reading data</li>
- * </ul>
- * @exception SWTError <ul>
- * <li>ERROR_NO_HANDLES if a handle could not be obtained for image creation</li>
- * </ul>
+/**
+ * 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 IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if device is null and there is no current device</li>
+ * <li>ERROR_NULL_ARGUMENT - if the stream is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_INVALID_IMAGE - if the image file contains invalid data </li>
+ * <li>ERROR_IO - if an IO error occurs while reading data</li>
+ * </ul>
+ * @exception SWTError <ul>
+ * <li>ERROR_NO_HANDLES if a handle could not be obtained for image creation</li>
+ * </ul>
*/
public Image(Device device, InputStream stream) {
if (device == null) device = Device.getDevice();
@@ -466,30 +466,30 @@ public Image(Device device, InputStream 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 IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if device is null and there is no current device</li>
- * <li>ERROR_NULL_ARGUMENT - if the file name is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_INVALID_IMAGE - if the image file contains invalid data </li>
- * <li>ERROR_IO - if an IO error occurs while reading data</li>
- * </ul>
- * @exception SWTError <ul>
- * <li>ERROR_NO_HANDLES if a handle could not be obtained for image creation</li>
- * </ul>
+/**
+ * Constructs an instance of this class by loading its representation
+ * from the file with the specified name. Throws an error if an error
+ * occurs while loading the image, or if the result is an image
+ * of an unsupported type.
+ * <p>
+ * This constructor is provided for convenience when loading
+ * a single image only. If the specified file contains
+ * multiple images, only the first one will be used.
+ *
+ * @param device the device on which to create the image
+ * @param filename the name of the file to load the image from
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if device is null and there is no current device</li>
+ * <li>ERROR_NULL_ARGUMENT - if the file name is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_INVALID_IMAGE - if the image file contains invalid data </li>
+ * <li>ERROR_IO - if an IO error occurs while reading data</li>
+ * </ul>
+ * @exception SWTError <ul>
+ * <li>ERROR_NO_HANDLES if a handle could not be obtained for image creation</li>
+ * </ul>
*/
public Image(Device device, String filename) {
if (device == null) device = Device.getDevice();
@@ -525,10 +525,10 @@ void destroyMask() {
mask = 0;
}
-/**
- * Disposes of the operating system resources associated with
- * the image. Applications must dispose of all images which
- * they allocate.
+/**
+ * Disposes of the operating system resources associated with
+ * the image. Applications must dispose of all images which
+ * they allocate.
*/
public void dispose () {
if (pixmap == 0) return;
@@ -541,15 +541,15 @@ public void dispose () {
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
+/**
+ * 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;
@@ -558,23 +558,23 @@ public boolean equals (Object object) {
return device == image.device && pixmap == image.pixmap;
}
-/**
- * Returns the color to which to map the transparent pixel, or null if
- * the receiver has no transparent pixel.
- * <p>
- * There are certain uses of Images that do not support transparency
- * (for example, setting an image into a button or label). In these cases,
- * it may be desired to simulate transparency by using the background
- * color of the widget to paint the transparent pixels of the image.
- * Use this method to check which color will be used in these cases
- * in place of transparency. This value may be set with setBackground().
- * <p>
- *
- * @return the background color of the image, or null if there is no transparency in the image
- *
- * @exception SWTException <ul>
- * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
- * </ul>
+/**
+ * Returns the color to which to map the transparent pixel, or null if
+ * the receiver has no transparent pixel.
+ * <p>
+ * There are certain uses of Images that do not support transparency
+ * (for example, setting an image into a button or label). In these cases,
+ * it may be desired to simulate transparency by using the background
+ * color of the widget to paint the transparent pixels of the image.
+ * Use this method to check which color will be used in these cases
+ * in place of transparency. This value may be set with setBackground().
+ * <p>
+ *
+ * @return the background color of the image, or null if there is no transparency in the image
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
*/
public Color getBackground() {
if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
@@ -583,17 +583,17 @@ public Color getBackground() {
return null;
}
-/**
- * Returns the bounds of the receiver. The rectangle will always
- * have x and y values of 0, and the width and height of the
- * image.
- *
- * @return a rectangle specifying the image's bounds
- *
- * @exception SWTException <ul>
- * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_INVALID_IMAGE - if the image is not a bitmap or an icon</li>
- * </ul>
+/**
+ * Returns the bounds of the receiver. The rectangle will always
+ * have x and y values of 0, and the width and height of the
+ * image.
+ *
+ * @return a rectangle specifying the image's bounds
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_INVALID_IMAGE - if the image is not a bitmap or an icon</li>
+ * </ul>
*/
public Rectangle getBounds() {
if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
@@ -602,19 +602,19 @@ public Rectangle getBounds() {
return new Rectangle(0, 0, width[0], height[0]);
}
-/**
- * Returns an <code>ImageData</code> based on the receiver
- * Modifications made to this <code>ImageData</code> will not
- * affect the Image.
- *
- * @return an <code>ImageData</code> containing the image's data and attributes
- *
- * @exception SWTException <ul>
- * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_INVALID_IMAGE - if the image is not a bitmap or an icon</li>
- * </ul>
- *
- * @see ImageData
+/**
+ * Returns an <code>ImageData</code> based on the receiver
+ * Modifications made to this <code>ImageData</code> will not
+ * affect the Image.
+ *
+ * @return an <code>ImageData</code> containing the image's data and attributes
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_INVALID_IMAGE - if the image is not a bitmap or an icon</li>
+ * </ul>
+ *
+ * @see ImageData
*/
public ImageData getImageData() {
if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
@@ -693,15 +693,15 @@ public static Image gtk_new(Device device, int type, int pixmap, int mask) {
return image;
}
-/**
- * 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
+/**
+ * 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 pixmap;
@@ -838,20 +838,20 @@ void init(Device device, ImageData image) {
this.pixmap = pixmap;
}
-/**
- * Invokes platform specific functionality to allocate a new GC handle.
- * <p>
- * <b>IMPORTANT:</b> This method is <em>not</em> part of the public
- * API for <code>Image</code>. It is marked public only so that it
- * can be shared within the packages provided by SWT. It is not
- * available on all platforms, and should never be called from
- * application code.
- * </p>
- *
- * @param data the platform specific GC data
- * @return the platform specific GC handle
- *
- * @private
+/**
+ * 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) {
if (pixmap == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
@@ -868,72 +868,72 @@ public int internal_new_GC (GCData data) {
return gdkGC;
}
-/**
- * Invokes platform specific functionality to dispose a GC handle.
- * <p>
- * <b>IMPORTANT:</b> This method is <em>not</em> part of the public
- * API for <code>Image</code>. It is marked public only so that it
- * can be shared within the packages provided by SWT. It is not
- * available on all platforms, and should never be called from
- * application code.
- * </p>
- *
- * @param handle the platform specific GC handle
- * @param data the platform specific GC data
- *
- * @private
+/**
+ * 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 gdkGC, GCData data) {
OS.g_object_unref(gdkGC);
}
-/**
- * Returns <code>true</code> if the image has been disposed,
- * and <code>false</code> otherwise.
- * <p>
- * This method gets the dispose state for the image.
- * When an image has been disposed, it is an error to
- * invoke any other method using the image.
- *
- * @return <code>true</code> when the image is disposed and <code>false</code> otherwise
+/**
+ * Returns <code>true</code> if the image has been disposed,
+ * and <code>false</code> otherwise.
+ * <p>
+ * This method gets the dispose state for the image.
+ * When an image has been disposed, it is an error to
+ * invoke any other method using the image.
+ *
+ * @return <code>true</code> when the image is disposed and <code>false</code> otherwise
*/
public boolean isDisposed() {
return pixmap == 0;
}
-/**
- * Sets the color to which to map the transparent pixel.
- * <p>
- * There are certain uses of <code>Images</code> that do not support
- * transparency (for example, setting an image into a button or label).
- * In these cases, it may be desired to simulate transparency by using
- * the background color of the widget to paint the transparent pixels
- * of the image. This method specifies the color that will be used in
- * these cases. For example:
- * <pre>
- * Button b = new Button();
- * image.setBackground(b.getBackground());>
- * b.setImage(image);
- * </pre>
- * </p><p>
- * The image may be modified by this operation (in effect, the
- * transparent regions may be filled with the supplied color). Hence
- * this operation is not reversible and it is not legal to call
- * this function twice or with a null argument.
- * </p><p>
- * This method has no effect if the receiver does not have a transparent
- * pixel value.
- * </p>
- *
- * @param color the color to use when a transparent pixel is specified
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the color is null</li>
- * <li>ERROR_INVALID_ARGUMENT - if the color has been disposed</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
- * </ul>
+/**
+ * Sets the color to which to map the transparent pixel.
+ * <p>
+ * There are certain uses of <code>Images</code> that do not support
+ * transparency (for example, setting an image into a button or label).
+ * In these cases, it may be desired to simulate transparency by using
+ * the background color of the widget to paint the transparent pixels
+ * of the image. This method specifies the color that will be used in
+ * these cases. For example:
+ * <pre>
+ * Button b = new Button();
+ * image.setBackground(b.getBackground());>
+ * b.setImage(image);
+ * </pre>
+ * </p><p>
+ * The image may be modified by this operation (in effect, the
+ * transparent regions may be filled with the supplied color). Hence
+ * this operation is not reversible and it is not legal to call
+ * this function twice or with a null argument.
+ * </p><p>
+ * This method has no effect if the receiver does not have a transparent
+ * pixel value.
+ * </p>
+ *
+ * @param color the color to use when a transparent pixel is specified
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if the color is null</li>
+ * <li>ERROR_INVALID_ARGUMENT - if the color has been disposed</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
*/
public void setBackground(Color color) {
if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
@@ -943,11 +943,11 @@ public void setBackground(Color color) {
//NOT DONE
}
-/**
- * Returns a string containing a concise, human-readable
- * description of the receiver.
- *
- * @return a string representation of the receiver
+/**
+ * Returns a string containing a concise, human-readable
+ * description of the receiver.
+ *
+ * @return a string representation of the receiver
*/
public String toString () {
if (isDisposed()) return "Image {*DISPOSED*}";
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/Region.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/Region.java
index bed035b3c6..7cd5011b3c 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/Region.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/Region.java
@@ -1,283 +1,283 @@
-package org.eclipse.swt.graphics;
-
-/*
+package org.eclipse.swt.graphics;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-import org.eclipse.swt.internal.gtk.*;
-import org.eclipse.swt.*;
-
-/**
- * Instances of this class represent areas of an x-y coordinate
- * system that are aggregates of the areas covered by a number
- * of 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>
+ * http://www.eclipse.org/legal/cpl-v10.html
*/
-public final class Region {
- /**
- * the OS resource for the region
- * (Warning: This field is platform dependent)
+
+import org.eclipse.swt.internal.gtk.*;
+import org.eclipse.swt.*;
+
+/**
+ * Instances of this class represent areas of an x-y coordinate
+ * system that are aggregates of the areas covered by a number
+ * of 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.
- *
- * @exception SWTError <ul>
- * <li>ERROR_NO_HANDLES if a handle could not be obtained for region creation</li>
- * </ul>
+ public int handle;
+
+/**
+ * Constructs a new empty region.
+ *
+ * @exception SWTError <ul>
+ * <li>ERROR_NO_HANDLES if a handle could not be obtained for region creation</li>
+ * </ul>
*/
-public Region() {
- handle = OS.gdk_region_new();
-}
-
-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>
- * <li>ERROR_INVALID_ARGUMENT - if the rectangle's width or height is negative</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
- * </ul>
+public Region() {
+ handle = OS.gdk_region_new();
+}
+
+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>
+ * <li>ERROR_INVALID_ARGUMENT - if the rectangle's width or height is negative</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
*/
-public void add(Rectangle rect) {
- if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- if (rect == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
- if (rect.width < 0 || rect.height < 0) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
- GdkRectangle gdkRect = new GdkRectangle();
- gdkRect.x = rect.x;
- gdkRect.y = rect.y;
- gdkRect.width = rect.width;
- gdkRect.height = rect.height;
- OS.gdk_region_union_with_rect(handle, gdkRect);
-}
-
-/**
- * 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>
- * <li>ERROR_INVALID_ARGUMENT - if the argument has been disposed</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
- * </ul>
+public void add(Rectangle rect) {
+ if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ if (rect == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ if (rect.width < 0 || rect.height < 0) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+ GdkRectangle gdkRect = new GdkRectangle();
+ gdkRect.x = rect.x;
+ gdkRect.y = rect.y;
+ gdkRect.width = rect.width;
+ gdkRect.height = rect.height;
+ OS.gdk_region_union_with_rect(handle, gdkRect);
+}
+
+/**
+ * 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>
+ * <li>ERROR_INVALID_ARGUMENT - if the argument has been disposed</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
*/
-public void add(Region region) {
- if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- if (region == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
- if (region.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
- OS.gdk_region_union(handle, region.handle);
-}
-
-/**
- * Returns <code>true</code> if the point specified by the
- * arguments is inside the area specified by the receiver,
- * and <code>false</code> otherwise.
- *
- * @param x the x coordinate of the point to test for containment
- * @param y the y coordinate of the point to test for containment
- * @return <code>true</code> if the region contains the point and <code>false</code> otherwise
- *
- * @exception SWTException <ul>
- * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
- * </ul>
+public void add(Region region) {
+ if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ if (region == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ if (region.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+ OS.gdk_region_union(handle, region.handle);
+}
+
+/**
+ * Returns <code>true</code> if the point specified by the
+ * arguments is inside the area specified by the receiver,
+ * and <code>false</code> otherwise.
+ *
+ * @param x the x coordinate of the point to test for containment
+ * @param y the y coordinate of the point to test for containment
+ * @return <code>true</code> if the region contains the point and <code>false</code> otherwise
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
*/
-public boolean contains(int x, int y) {
- if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- return OS.gdk_region_point_in(handle, x, y);
-}
-
-/**
- * Returns <code>true</code> if the given point is inside the
- * area specified by the receiver, and <code>false</code>
- * otherwise.
- *
- * @param pt the point to test for containment
- * @return <code>true</code> if the region contains the point and <code>false</code> otherwise
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the argument is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
- * </ul>
+public boolean contains(int x, int y) {
+ if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ return OS.gdk_region_point_in(handle, x, y);
+}
+
+/**
+ * Returns <code>true</code> if the given point is inside the
+ * area specified by the receiver, and <code>false</code>
+ * otherwise.
+ *
+ * @param pt the point to test for containment
+ * @return <code>true</code> if the region contains the point and <code>false</code> otherwise
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if the argument is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
*/
-public boolean contains(Point pt) {
- if (pt == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
- return contains(pt.x, pt.y);
-}
-/**
- * Disposes of the operating system resources associated with
- * the region. Applications must dispose of all regions which
- * they allocate.
+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.gdk_region_destroy(handle);
- handle = 0;
-}
-
-/**
- * Compares the argument to the receiver, and returns true
- * if they represent the <em>same</em> object using a class
- * specific comparison.
- *
- * @param object the object to compare with this object
- * @return <code>true</code> if the object is the same as this object and <code>false</code> otherwise
- *
- * @see #hashCode
+public void dispose() {
+ if (handle != 0) OS.gdk_region_destroy(handle);
+ handle = 0;
+}
+
+/**
+ * Compares the argument to the receiver, and returns true
+ * if they represent the <em>same</em> object using a class
+ * specific comparison.
+ *
+ * @param object the object to compare with this object
+ * @return <code>true</code> if the object is the same as this object and <code>false</code> otherwise
+ *
+ * @see #hashCode
*/
-public boolean equals(Object object) {
- if (this == object) return true;
- if (!(object instanceof Region)) return false;
- Region region = (Region)object;
- return handle == region.handle;
-}
-
-/**
- * Returns a rectangle which represents the rectangular
- * union of the collection of rectangles the receiver
- * maintains to describe its area.
- *
- * @return a bounding rectangle for the region
- *
- * @exception SWTException <ul>
- * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
- * </ul>
- *
- * @see Rectangle#union
+public boolean equals(Object object) {
+ if (this == object) return true;
+ if (!(object instanceof Region)) return false;
+ Region region = (Region)object;
+ return handle == region.handle;
+}
+
+/**
+ * Returns a rectangle which represents the rectangular
+ * union of the collection of rectangles the receiver
+ * maintains to describe its area.
+ *
+ * @return a bounding rectangle for the region
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ *
+ * @see Rectangle#union
*/
-public Rectangle getBounds() {
- if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- GdkRectangle gdkRect = new GdkRectangle();
- OS.gdk_region_get_clipbox(handle, gdkRect);
- return new Rectangle(gdkRect.x, gdkRect.y, gdkRect.width, gdkRect.height);
-}
-
-public static Region gtk_new(int handle) {
- return new Region(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 Rectangle getBounds() {
+ if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ GdkRectangle gdkRect = new GdkRectangle();
+ OS.gdk_region_get_clipbox(handle, gdkRect);
+ return new Rectangle(gdkRect.x, gdkRect.y, gdkRect.width, gdkRect.height);
+}
+
+public static Region gtk_new(int handle) {
+ return new Region(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 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
- *
- * @exception SWTException <ul>
- * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
- * </ul>
- *
- * @see Rectangle#intersects
+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
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ *
+ * @see Rectangle#intersects
*/
-public boolean intersects (int x, int y, int width, int height) {
- if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- GdkRectangle gdkRect = new GdkRectangle();
- gdkRect.x = x;
- gdkRect.y = y;
- gdkRect.width = width;
- gdkRect.height = height;
- return OS.gdk_region_rect_in(handle, gdkRect) != OS.GDK_OVERLAP_RECTANGLE_OUT;
-}
-/**
- * Returns <code>true</code> if the given rectangle intersects
- * with any of the 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>
- * @exception SWTException <ul>
- * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
- * </ul>
- *
- * @see Rectangle#intersects
+public boolean intersects (int x, int y, int width, int height) {
+ if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ GdkRectangle gdkRect = new GdkRectangle();
+ gdkRect.x = x;
+ gdkRect.y = y;
+ gdkRect.width = width;
+ gdkRect.height = height;
+ return OS.gdk_region_rect_in(handle, gdkRect) != OS.GDK_OVERLAP_RECTANGLE_OUT;
+}
+/**
+ * Returns <code>true</code> if the given rectangle intersects
+ * with any of the 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>
+ * @exception SWTException <ul>
+ * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</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 intersects(Rectangle rect) {
+ if (rect == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ return intersects(rect.x, rect.y, rect.width, rect.height);
+}
+
+/**
+ * Returns <code>true</code> if the region has been disposed,
+ * and <code>false</code> otherwise.
+ * <p>
+ * This method gets the dispose state for the region.
+ * When a region has been disposed, it is an error to
+ * invoke any other method using the region.
+ *
+ * @return <code>true</code> when the region is disposed, and <code>false</code> otherwise
*/
-public boolean isDisposed() {
- return handle == 0;
-}
-
-/**
- * Returns <code>true</code> if the receiver does not cover any
- * area in the (x, y) coordinate plane, and <code>false</code> if
- * the receiver does cover some area in the plane.
- *
- * @return <code>true</code> if the receiver is empty, and <code>false</code> otherwise
- *
- * @exception SWTException <ul>
- * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
- * </ul>
+public boolean isDisposed() {
+ return handle == 0;
+}
+
+/**
+ * Returns <code>true</code> if the receiver does not cover any
+ * area in the (x, y) coordinate plane, and <code>false</code> if
+ * the receiver does cover some area in the plane.
+ *
+ * @return <code>true</code> if the receiver is empty, and <code>false</code> otherwise
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
*/
-public boolean isEmpty() {
- if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- return OS.gdk_region_empty(handle);
-}
-
-/**
- * Returns a string containing a concise, human-readable
- * description of the receiver.
- *
- * @return a string representation of the receiver
+public boolean isEmpty() {
+ if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ return OS.gdk_region_empty(handle);
+}
+
+/**
+ * Returns a string containing a concise, human-readable
+ * description of the receiver.
+ *
+ * @return a string representation of the receiver
*/
-public String toString () {
- if (isDisposed()) return "Region {*DISPOSED*}";
- return "Region {" + handle + "}";
-}
-}
+public String toString () {
+ if (isDisposed()) return "Region {*DISPOSED*}";
+ return "Region {" + handle + "}";
+}
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/internal/Converter.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/internal/Converter.java
index 2e267e5b84..855722553b 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/internal/Converter.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/internal/Converter.java
@@ -1,14 +1,14 @@
-package org.eclipse.swt.internal;
-
-/*
+package org.eclipse.swt.internal;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-import org.eclipse.swt.internal.gtk.OS;
-
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+import org.eclipse.swt.internal.gtk.OS;
+
/**
* This class implements the conversions between unicode characters
* and the <em>platform supported</em> representation for characters.
@@ -16,51 +16,51 @@ import org.eclipse.swt.internal.gtk.OS;
* Note that, unicode characters which can not be found in the platform
* encoding will be converted to an arbitrary platform specific character.
* </p>
- */
-public final class Converter {
- public static final byte [] NullByteArray = new byte [1];
- public static final byte [] EmptyByteArray = new byte [0];
- public static final char [] EmptyCharArray = new char [0];
-
+ */
+public final class Converter {
+ public static final byte [] NullByteArray = new byte [1];
+ public static final byte [] EmptyByteArray = new byte [0];
+ public static final char [] EmptyCharArray = new char [0];
+
/**
* Returns the default code page for the platform where the
* application is currently running.
*
* @return the default code page
*/
-public static String defaultCodePage () {
- return "UTF8";
-}
-
-public static char [] mbcsToWcs (String codePage, byte [] buffer) {
- int [] items_written = new int [1];
- int ptr = OS.g_utf8_to_utf16 (buffer, buffer.length, null, items_written, null);
- if (ptr == 0) return EmptyCharArray;
- int length = items_written [0];
- char [] chars = new char [length];
- OS.memmove (chars, ptr, length * 2);
- OS.g_free (ptr);
- return chars;
-}
-
-public static byte [] wcsToMbcs (String codePage, String string, boolean terminate) {
- int length = string.length ();
- char [] buffer = new char [length];
- string.getChars (0, length, buffer, 0);
- return wcsToMbcs (codePage, buffer, terminate);
-}
-
-public static byte [] wcsToMbcs (String codePage, char [] buffer, boolean terminate) {
- int [] items_read = new int [1], items_written = new int [1];
- int ptr = OS.g_utf16_to_utf8 (buffer, buffer.length, items_read, items_written, null);
- if (ptr == 0) return terminate ? NullByteArray : EmptyByteArray;
- int written = items_written [0];
- //TEMPORARY CODE - convertion stops at the first NULL
- if (items_read [0] != buffer.length && !terminate) written++;
- byte [] bytes = new byte [written + (terminate ? 1 : 0)];
- OS.memmove (bytes, ptr, written);
- OS.g_free (ptr);
- return bytes;
-}
-
-}
+public static String defaultCodePage () {
+ return "UTF8";
+}
+
+public static char [] mbcsToWcs (String codePage, byte [] buffer) {
+ int [] items_written = new int [1];
+ int ptr = OS.g_utf8_to_utf16 (buffer, buffer.length, null, items_written, null);
+ if (ptr == 0) return EmptyCharArray;
+ int length = items_written [0];
+ char [] chars = new char [length];
+ OS.memmove (chars, ptr, length * 2);
+ OS.g_free (ptr);
+ return chars;
+}
+
+public static byte [] wcsToMbcs (String codePage, String string, boolean terminate) {
+ int length = string.length ();
+ char [] buffer = new char [length];
+ string.getChars (0, length, buffer, 0);
+ return wcsToMbcs (codePage, buffer, terminate);
+}
+
+public static byte [] wcsToMbcs (String codePage, char [] buffer, boolean terminate) {
+ int [] items_read = new int [1], items_written = new int [1];
+ int ptr = OS.g_utf16_to_utf8 (buffer, buffer.length, items_read, items_written, null);
+ if (ptr == 0) return terminate ? NullByteArray : EmptyByteArray;
+ int written = items_written [0];
+ //TEMPORARY CODE - convertion stops at the first NULL
+ if (items_read [0] != buffer.length && !terminate) written++;
+ byte [] bytes = new byte [written + (terminate ? 1 : 0)];
+ OS.memmove (bytes, ptr, written);
+ OS.g_free (ptr);
+ return bytes;
+}
+
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Button.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Button.java
index b2daae9a6c..103f152da4 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Button.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Button.java
@@ -13,69 +13,69 @@ import org.eclipse.swt.*;
import org.eclipse.swt.graphics.*;
import org.eclipse.swt.events.*;
-/**
- * Instances of this class represent a selectable user interface object that
- * issues notification when pressed and released.
- * <dl>
- * <dt><b>Styles:</b></dt>
- * <dd>ARROW, CHECK, PUSH, RADIO, TOGGLE, FLAT</dd>
- * <dd>UP, DOWN, LEFT, RIGHT, CENTER</dd>
- * <dt><b>Events:</b></dt>
- * <dd>Selection</dd>
- * </dl>
- * <p>
- * Note: Only one of the styles ARROW, CHECK, PUSH, RADIO, and TOGGLE
- * may be specified.
- * </p><p>
- * Note: Only one of the styles LEFT, RIGHT, and CENTER may be specified.
- * </p><p>
- * Note: Only one of the styles UP, DOWN, LEFT, and RIGHT may be specified
- * when the ARROW style is specified.
- * </p><p>
- * IMPORTANT: This class is intended to be subclassed <em>only</em>
- * within the SWT implementation.
- * </p>
+/**
+ * Instances of this class represent a selectable user interface object that
+ * issues notification when pressed and released.
+ * <dl>
+ * <dt><b>Styles:</b></dt>
+ * <dd>ARROW, CHECK, PUSH, RADIO, TOGGLE, FLAT</dd>
+ * <dd>UP, DOWN, LEFT, RIGHT, CENTER</dd>
+ * <dt><b>Events:</b></dt>
+ * <dd>Selection</dd>
+ * </dl>
+ * <p>
+ * Note: Only one of the styles ARROW, CHECK, PUSH, RADIO, and TOGGLE
+ * may be specified.
+ * </p><p>
+ * Note: Only one of the styles LEFT, RIGHT, and CENTER may be specified.
+ * </p><p>
+ * Note: Only one of the styles UP, DOWN, LEFT, and RIGHT may be specified
+ * when the ARROW style is specified.
+ * </p><p>
+ * IMPORTANT: This class is intended to be subclassed <em>only</em>
+ * within the SWT implementation.
+ * </p>
*/
public class Button extends Control {
int boxHandle, labelHandle, imageHandle, arrowHandle;
Image image;
String text;
-/**
- * Constructs a new instance of this class given its parent
- * and a style value describing its behavior and appearance.
- * <p>
- * The style value is either one of the style constants defined in
- * class <code>SWT</code> which is applicable to instances of this
- * class, or must be built by <em>bitwise OR</em>'ing together
- * (that is, using the <code>int</code> "|" operator) two or more
- * of those <code>SWT</code> style constants. The class description
- * lists the style constants that are applicable to the class.
- * Style bits are also inherited from superclasses.
- * </p>
- *
- * @param parent a composite control which will be the parent of the new instance (cannot be null)
- * @param style the style of control to construct
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
- * <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
- * </ul>
- *
- * @see SWT#ARROW
- * @see SWT#CHECK
- * @see SWT#PUSH
- * @see SWT#RADIO
- * @see SWT#TOGGLE
- * @see SWT#FLAT
- * @see SWT#LEFT
- * @see SWT#RIGHT
- * @see SWT#CENTER
- * @see Widget#checkSubclass
- * @see Widget#getStyle
+/**
+ * Constructs a new instance of this class given its parent
+ * and a style value describing its behavior and appearance.
+ * <p>
+ * The style value is either one of the style constants defined in
+ * class <code>SWT</code> which is applicable to instances of this
+ * class, or must be built by <em>bitwise OR</em>'ing together
+ * (that is, using the <code>int</code> "|" operator) two or more
+ * of those <code>SWT</code> style constants. The class description
+ * lists the style constants that are applicable to the class.
+ * Style bits are also inherited from superclasses.
+ * </p>
+ *
+ * @param parent a composite control which will be the parent of the new instance (cannot be null)
+ * @param style the style of control to construct
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
+ * <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
+ * </ul>
+ *
+ * @see SWT#ARROW
+ * @see SWT#CHECK
+ * @see SWT#PUSH
+ * @see SWT#RADIO
+ * @see SWT#TOGGLE
+ * @see SWT#FLAT
+ * @see SWT#LEFT
+ * @see SWT#RIGHT
+ * @see SWT#CENTER
+ * @see Widget#checkSubclass
+ * @see Widget#getStyle
*/
public Button (Composite parent, int style) {
super (parent, checkStyle (style));
@@ -95,29 +95,29 @@ static int checkStyle (int style) {
return 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.
- * <p>
- * <code>widgetSelected</code> is called when the control is selected.
- * <code>widgetDefaultSelected</code> is not called.
- * </p>
- *
- * @param listener the listener which should be notified
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see SelectionListener
- * @see #removeSelectionListener
- * @see SelectionEvent
+/**
+ * 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.
+ * <p>
+ * <code>widgetSelected</code> is called when the control is selected.
+ * <code>widgetDefaultSelected</code> is not called.
+ * </p>
+ *
+ * @param listener the listener which should be notified
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see SelectionListener
+ * @see #removeSelectionListener
+ * @see SelectionEvent
*/
public void addSelectionListener (SelectionListener listener) {
checkWidget ();
@@ -237,21 +237,21 @@ int fontHandle () {
return super.fontHandle ();
}
-/**
- * Returns a value which describes the position of the
- * text or image in the receiver. The value will be one of
- * <code>LEFT</code>, <code>RIGHT</code> or <code>CENTER</code>
- * unless the receiver is an <code>ARROW</code> button, in
- * which case, the alignment will indicate the direction of
- * the arrow (one of <code>LEFT</code>, <code>RIGHT</code>,
- * <code>UP</code> or <code>DOWN</code>).
- *
- * @return the alignment
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
+/**
+ * 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 ();
@@ -268,16 +268,16 @@ public int getAlignment () {
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>
+/**
+ * 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 ();
@@ -288,21 +288,21 @@ String getNameText () {
return getText ();
}
-/**
- * Returns <code>true</code> if the receiver is selected,
- * and false otherwise.
- * <p>
- * When the receiver is of type <code>CHECK</code> or <code>RADIO</code>,
- * it is selected when it is checked. When it is of type <code>TOGGLE</code>,
- * it is selected when it is pushed in. If the receiver is of any other type,
- * this method returns false.
- *
- * @return the selection state
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
+/**
+ * Returns <code>true</code> if the receiver is selected,
+ * and false otherwise.
+ * <p>
+ * When the receiver is of type <code>CHECK</code> or <code>RADIO</code>,
+ * it is selected when it is checked. When it is of type <code>TOGGLE</code>,
+ * it is selected when it is pushed in. If the receiver is of any other type,
+ * this method returns false.
+ *
+ * @return the selection state
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
*/
public boolean getSelection () {
checkWidget ();
@@ -310,16 +310,16 @@ public boolean getSelection () {
return OS.gtk_toggle_button_get_active (handle);
}
-/**
- * Returns the receiver's text, which will be an empty
- * string if it has never been set.
- *
- * @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>
+/**
+ * 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();
@@ -388,22 +388,22 @@ void releaseWidget () {
text = 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
+/**
+ * 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();
@@ -413,21 +413,21 @@ public void removeSelectionListener (SelectionListener listener) {
eventTable.unhook (SWT.DefaultSelection,listener);
}
-/**
- * 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>
+/**
+ * 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 ();
@@ -488,19 +488,19 @@ void setForegroundColor (GdkColor color) {
if (imageHandle != 0) OS.gtk_widget_modify_fg (imageHandle, 0, color);
}
-/**
- * Sets the receiver's image to the argument, which may be
- * null indicating that no image should be displayed.
- *
- * @param image the image to display on the receiver (may be null)
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_INVALID_ARGUMENT - if the image has been disposed</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
+/**
+ * Sets the receiver's image to the argument, which may be
+ * null indicating that no image should be displayed.
+ *
+ * @param image the image to display on the receiver (may be null)
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_INVALID_ARGUMENT - if the image has been disposed</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
*/
public void setImage (Image image) {
checkWidget ();
@@ -525,21 +525,21 @@ public void setImage (Image image) {
OS.gtk_widget_size_request (handle, requisition);
}
-/**
- * Sets the selection state of the receiver, if it is of type <code>CHECK</code>,
- * <code>RADIO</code>, or <code>TOGGLE</code>.
- *
- * <p>
- * When the receiver is of type <code>CHECK</code> or <code>RADIO</code>,
- * it is selected when it is checked. When it is of type <code>TOGGLE</code>,
- * it is selected when it is pushed in.
- *
- * @param selected the new selection state
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
+/**
+ * Sets the selection state of the receiver, if it is of type <code>CHECK</code>,
+ * <code>RADIO</code>, or <code>TOGGLE</code>.
+ *
+ * <p>
+ * When the receiver is of type <code>CHECK</code> or <code>RADIO</code>,
+ * it is selected when it is checked. When it is of type <code>TOGGLE</code>,
+ * it is selected when it is pushed in.
+ *
+ * @param selected the new selection state
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
*/
public void setSelection (boolean selected) {
checkWidget();
@@ -549,22 +549,22 @@ public void setSelection (boolean selected) {
OS.g_signal_handlers_unblock_matched (handle, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, CLICKED);
}
-/**
- * Sets the receiver's text.
- * <p>
- * This method sets the button label. The label may include
- * the mnemonic character but must not contain line delimiters.
- * </p>
- *
- * @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>
+/**
+ * Sets the receiver's text.
+ * <p>
+ * This method sets the button label. The label may include
+ * the mnemonic character but must not contain line delimiters.
+ * </p>
+ *
+ * @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 ();
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Canvas.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Canvas.java
index 5a9bc9b21b..c8e88faf06 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Canvas.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Canvas.java
@@ -11,79 +11,79 @@ import org.eclipse.swt.graphics.*;
import org.eclipse.swt.internal.gtk.*;
import org.eclipse.swt.*;
-/**
- * Instances of this class provide a surface for drawing
- * arbitrary graphics.
- * <dl>
- * <dt><b>Styles:</b></dt>
- * <dd>(none)</dd>
- * <dt><b>Events:</b></dt>
- * <dd>(none)</dd>
- * </dl>
- * <p>
- * This class may be subclassed by custom control implementors
- * who are building controls that are <em>not</em> constructed
- * from aggregates of other controls. That is, they are either
- * painted using SWT graphics calls or are handled by native
- * methods.
- * </p>
- *
- * @see Composite
+/**
+ * Instances of this class provide a surface for drawing
+ * arbitrary graphics.
+ * <dl>
+ * <dt><b>Styles:</b></dt>
+ * <dd>(none)</dd>
+ * <dt><b>Events:</b></dt>
+ * <dd>(none)</dd>
+ * </dl>
+ * <p>
+ * This class may be subclassed by custom control implementors
+ * who are building controls that are <em>not</em> constructed
+ * from aggregates of other controls. That is, they are either
+ * painted using SWT graphics calls or are handled by native
+ * methods.
+ * </p>
+ *
+ * @see Composite
*/
public class Canvas extends Composite {
Caret caret;
Canvas () {}
-/**
- * Constructs a new instance of this class given its parent
- * and a style value describing its behavior and appearance.
- * <p>
- * The style value is either one of the style constants defined in
- * class <code>SWT</code> which is applicable to instances of this
- * class, or must be built by <em>bitwise OR</em>'ing together
- * (that is, using the <code>int</code> "|" operator) two or more
- * of those <code>SWT</code> style constants. The class description
- * lists the style constants that are applicable to the class.
- * Style bits are also inherited from superclasses.
- * </p>
- *
- * @param parent a composite control which will be the parent of the new instance (cannot be null)
- * @param style the style of control to construct
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
- * <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
- * </ul>
- *
- * @see SWT
- * @see Widget#checkSubclass
- * @see Widget#getStyle
+/**
+ * Constructs a new instance of this class given its parent
+ * and a style value describing its behavior and appearance.
+ * <p>
+ * The style value is either one of the style constants defined in
+ * class <code>SWT</code> which is applicable to instances of this
+ * class, or must be built by <em>bitwise OR</em>'ing together
+ * (that is, using the <code>int</code> "|" operator) two or more
+ * of those <code>SWT</code> style constants. The class description
+ * lists the style constants that are applicable to the class.
+ * Style bits are also inherited from superclasses.
+ * </p>
+ *
+ * @param parent a composite control which will be the parent of the new instance (cannot be null)
+ * @param style the style of control to construct
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
+ * <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
+ * </ul>
+ *
+ * @see SWT
+ * @see Widget#checkSubclass
+ * @see Widget#getStyle
*/
public Canvas (Composite parent, int style) {
super (parent, style);
}
-/**
- * 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>
+/**
+ * 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();
@@ -128,27 +128,27 @@ void releaseWidget () {
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>
+/**
+ * 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();
@@ -233,25 +233,25 @@ boolean setBounds (int x, int y, int width, int height, boolean move, boolean re
return changed;
}
-/**
- * Sets the receiver's caret.
- * <p>
- * The caret for the control is automatically hidden
- * and shown when the control is painted or resized,
- * when focus is gained or lost and when an the control
- * is scrolled. To avoid drawing on top of the caret,
- * the programmer must hide and show the caret when
- * drawing in the window any other time.
- * </p>
- * @param caret the new caret for the receiver, may be null
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_INVALID_ARGUMENT - if the caret has been disposed</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
+/**
+ * Sets the receiver's caret.
+ * <p>
+ * The caret for the control is automatically hidden
+ * and shown when the control is painted or resized,
+ * when focus is gained or lost and when an the control
+ * is scrolled. To avoid drawing on top of the caret,
+ * the programmer must hide and show the caret when
+ * drawing in the window any other time.
+ * </p>
+ * @param caret the new caret for the receiver, may be null
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_INVALID_ARGUMENT - if the caret has been disposed</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
*/
public void setCaret (Caret caret) {
checkWidget();
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Caret.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Caret.java
index 496e49749d..f7a7abf241 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Caret.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Caret.java
@@ -11,19 +11,19 @@ import org.eclipse.swt.*;
import org.eclipse.swt.internal.gtk.*;
import org.eclipse.swt.graphics.*;
-/**
- * Instances of this class provide an i-beam that is typically used
- * as the insertion point for text.
- * <dl>
- * <dt><b>Styles:</b></dt>
- * <dd>(none)</dd>
- * <dt><b>Events:</b></dt>
- * <dd>(none)</dd>
- * </dl>
- * <p>
- * IMPORTANT: This class is intended to be subclassed <em>only</em>
- * within the SWT implementation.
- * </p>
+/**
+ * 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;
@@ -33,33 +33,33 @@ public class Caret extends Widget {
Image image;
Font font;
-/**
- * Constructs a new instance of this class given its parent
- * and a style value describing its behavior and appearance.
- * <p>
- * The style value is either one of the style constants defined in
- * class <code>SWT</code> which is applicable to instances of this
- * class, or must be built by <em>bitwise OR</em>'ing together
- * (that is, using the <code>int</code> "|" operator) two or more
- * of those <code>SWT</code> style constants. The class description
- * lists the style constants that are applicable to the class.
- * Style bits are also inherited from superclasses.
- * </p>
- *
- * @param parent a 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
+/**
+ * Constructs a new instance of this class given its parent
+ * and a style value describing its behavior and appearance.
+ * <p>
+ * The style value is either one of the style constants defined in
+ * class <code>SWT</code> which is applicable to instances of this
+ * class, or must be built by <em>bitwise OR</em>'ing together
+ * (that is, using the <code>int</code> "|" operator) two or more
+ * of those <code>SWT</code> style constants. The class description
+ * lists the style constants that are applicable to the class.
+ * Style bits are also inherited from superclasses.
+ * </p>
+ *
+ * @param parent a composite control which will be the parent of the new instance (cannot be null)
+ * @param style the style of control to construct
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
+ * <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
+ * </ul>
+ *
+ * @see SWT
+ * @see Widget#checkSubclass
+ * @see Widget#getStyle
*/
public Caret (Canvas parent, int style) {
super (parent, style);
@@ -108,16 +108,16 @@ boolean drawCaret () {
return true;
}
-/**
- * Returns a rectangle describing the receiver's size and location
- * relative to its parent (or its display if its parent is null).
- *
- * @return the receiver's bounding rectangle
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
+/**
+ * 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();
@@ -134,15 +134,15 @@ public Display getDisplay () {
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>
+/**
+ * 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();
@@ -150,61 +150,61 @@ public Font getFont () {
return parent.getFont ();
}
-/**
- * Returns the image that the receiver will use to paint the caret.
- *
- * @return the receiver's image
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
+/**
+ * Returns the image that the receiver will use to paint the caret.
+ *
+ * @return the receiver's image
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
*/
public Image getImage () {
checkWidget();
return image;
}
-/**
- * Returns a point describing the receiver's location relative
- * to its parent (or its display if its parent is null).
- *
- * @return the receiver's location
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
+/**
+ * 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>
+/**
+ * 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>
+/**
+ * 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();
@@ -215,22 +215,22 @@ public Point getSize () {
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>
+/**
+ * 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();
@@ -290,21 +290,21 @@ void releaseWidget () {
image = null;
}
-/**
- * Sets the receiver's size and location to the rectangular
- * area specified by the arguments. The <code>x</code> and
- * <code>y</code> arguments are relative to the receiver's
- * parent (or its display if its parent is null).
- *
- * @param x the new x coordinate for the receiver
- * @param y the new y coordinate for the receiver
- * @param width the new width for the receiver
- * @param height the new height for the receiver
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
+/**
+ * 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();
@@ -317,18 +317,18 @@ public void setBounds (int x, int y, int width, int height) {
if (isFocus) showCaret ();
}
-/**
- * Sets the receiver's size and location to the rectangular
- * area specified by the argument. The <code>x</code> and
- * <code>y</code> fields of the rectangle are relative to
- * the receiver's parent (or its display if its parent is null).
- *
- * @param rect the new bounds for the receiver
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
+/**
+ * Sets the receiver's size and location to the rectangular
+ * area specified by the argument. The <code>x</code> and
+ * <code>y</code> fields of the rectangle are relative to
+ * the receiver's parent (or its display if its parent is null).
+ *
+ * @param rect the new bounds for the receiver
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
*/
public void setBounds (Rectangle rect) {
checkWidget();
@@ -343,20 +343,20 @@ void setFocus () {
if (isVisible) showCaret ();
}
-/**
- * Sets the font that the receiver will use to paint textual information
- * to the font specified by the argument, or to the default font for that
- * kind of control if the argument is null.
- *
- * @param font the new font (or null)
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_INVALID_ARGUMENT - if the font has been disposed</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
+/**
+ * Sets the font that the receiver will use to paint textual information
+ * to the font specified by the argument, or to the default font for that
+ * kind of control if the argument is null.
+ *
+ * @param font the new font (or null)
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_INVALID_ARGUMENT - if the font has been disposed</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
*/
public void setFont (Font font) {
checkWidget();
@@ -366,20 +366,20 @@ public void setFont (Font font) {
this.font = font;
}
-/**
- * Sets the image that the receiver will use to paint the caret
- * to the image specified by the argument, or to the default
- * which is a filled rectangle if the argument is null
- *
- * @param font the new font (or null)
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_INVALID_ARGUMENT - if the image has been disposed</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
+/**
+ * Sets the image that the receiver will use to paint the caret
+ * to the image specified by the argument, or to the default
+ * which is a filled rectangle if the argument is null
+ *
+ * @param font the new font (or null)
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_INVALID_ARGUMENT - if the image has been disposed</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
*/
public void setImage (Image image) {
checkWidget();
@@ -392,35 +392,35 @@ public void setImage (Image image) {
if (isFocus) showCaret ();
}
-/**
- * Sets the receiver's location to the point specified by
- * the arguments which are relative to the receiver's
- * parent (or its display if its parent is null).
- *
- * @param x the new x coordinate for the receiver
- * @param y the new y coordinate for the receiver
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
+/**
+ * Sets the receiver's location to the point specified by
+ * the arguments which are relative to the receiver's
+ * parent (or its display if its parent is null).
+ *
+ * @param x the new x coordinate for the receiver
+ * @param y the new y coordinate for the receiver
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
*/
public void setLocation (int x, int y) {
checkWidget();
setBounds (x, y, width, height);
}
-/**
- * Sets the receiver's location to the point specified by
- * the argument which is relative to the receiver's
- * parent (or its display if its parent is null).
- *
- * @param location the new location for the receiver
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
+/**
+ * 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();
@@ -428,35 +428,35 @@ public void setLocation (Point location) {
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>
+/**
+ * Sets the receiver's size to the point specified by the arguments.
+ *
+ * @param width the new width for the receiver
+ * @param height the new height for the receiver
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
*/
public void setSize (int width, int height) {
checkWidget();
setBounds (x, y, width, height);
}
-/**
- * Sets the receiver's size to the point specified by the argument.
- *
- * @param size the new extent for the receiver
- * @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>
+/**
+ * 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();
@@ -464,21 +464,21 @@ public void setSize (Point size) {
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>
+/**
+ * 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();
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ColorDialog.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ColorDialog.java
index 9c2b3c5733..1349f4aaac 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ColorDialog.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ColorDialog.java
@@ -1,147 +1,147 @@
-package org.eclipse.swt.widgets;
-
-/*
+package org.eclipse.swt.widgets;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-import org.eclipse.swt.*;
-import org.eclipse.swt.internal.*;
-import org.eclipse.swt.internal.gtk.*;
-import org.eclipse.swt.graphics.*;
-
-/**
- * Instances of this class allow the user to select a color
- * from a predefined set of available colors.
- * <dl>
- * <dt><b>Styles:</b></dt>
- * <dd>(none)</dd>
- * <dt><b>Events:</b></dt>
- * <dd>(none)</dd>
- * </dl>
- * <p>
- * IMPORTANT: This class is intended to be subclassed <em>only</em>
- * within the SWT implementation.
- * </p>
+ * http://www.eclipse.org/legal/cpl-v10.html
*/
-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
+
+import org.eclipse.swt.*;
+import org.eclipse.swt.internal.*;
+import org.eclipse.swt.internal.gtk.*;
+import org.eclipse.swt.graphics.*;
+
+/**
+ * Instances of this class allow the user to select a color
+ * from a predefined set of available colors.
+ * <dl>
+ * <dt><b>Styles:</b></dt>
+ * <dd>(none)</dd>
+ * <dt><b>Events:</b></dt>
+ * <dd>(none)</dd>
+ * </dl>
+ * <p>
+ * IMPORTANT: This class is intended to be subclassed <em>only</em>
+ * within the SWT implementation.
+ * </p>
*/
-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
- * lists the style constants that are applicable to the class.
- * Style bits are also inherited from superclasses.
- * </p>
- *
- * @param parent a composite control which will be the parent of the new instance (cannot be null)
- * @param style the style of control to construct
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
- * <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
- * </ul>
- *
- * @see SWT
- * @see Widget#checkSubclass
- * @see Widget#getStyle
+public 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, int style) {
- super (parent, style);
- checkSubclass ();
-}
-
-/**
- * Returns the currently selected color in the receiver.
- *
- * @return the RGB value for the selected color, may be null
- *
- * @see PaletteData#getRGBs
+public 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
+ * lists the style constants that are applicable to the class.
+ * Style bits are also inherited from superclasses.
+ * </p>
+ *
+ * @param parent a composite control which will be the parent of the new instance (cannot be null)
+ * @param style the style of control to construct
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
+ * <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
+ * </ul>
+ *
+ * @see SWT
+ * @see Widget#checkSubclass
+ * @see Widget#getStyle
*/
-public RGB getRGB () {
- return rgb;
-}
-/**
- * Makes the receiver visible and brings it to the front
- * of the display.
- *
- * @return the selected color, or null if the dialog was
- * cancelled, no color was selected, or an error
- * occurred
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
+public ColorDialog (Shell parent, int style) {
+ super (parent, style);
+ checkSubclass ();
+}
+
+/**
+ * Returns the currently selected color in the receiver.
+ *
+ * @return the RGB value for the selected color, may be null
+ *
+ * @see PaletteData#getRGBs
*/
-public RGB open () {
- byte [] buffer = Converter.wcsToMbcs (null, title, true);
- int handle = OS.gtk_color_selection_dialog_new (buffer);
- if (parent!=null) {
- OS.gtk_window_set_transient_for(handle, parent.topHandle());
- }
- GtkColorSelectionDialog dialog = new GtkColorSelectionDialog ();
- OS.memmove(dialog, handle);
- GdkColor color = new GdkColor();
- if (rgb != null) {
- color.red = (short)((rgb.red & 0xFF) | ((rgb.red & 0xFF) << 8));
- color.green = (short)((rgb.green & 0xFF) | ((rgb.green & 0xFF) << 8));
- color.blue = (short)((rgb.blue & 0xFF) | ((rgb.blue & 0xFF) << 8));
- OS.gtk_color_selection_set_current_color (dialog.colorsel, color);
- }
- int response = OS.gtk_dialog_run(handle);
- boolean success = response == OS.GTK_RESPONSE_OK;
- if (success) {
- OS.gtk_color_selection_get_current_color (dialog.colorsel, color);
- int red = (color.red >> 8) & 0xFF;
- int green = (color.green >> 8) & 0xFF;
- int blue = (color.blue >> 8) & 0xFF;
- rgb = new RGB (red, green, blue);
- }
- OS.gtk_widget_destroy(handle);
- if (!success) return null;
- return rgb;
-}
-/**
- * Returns the receiver's selected color to be the argument.
- *
- * @param rgb the new RGB value for the selected color, may be
- * null to let the platform to select a default when
- * open() is called
- *
- * @see PaletteData#getRGBs
+public RGB getRGB () {
+ return rgb;
+}
+/**
+ * Makes the receiver visible and brings it to the front
+ * of the display.
+ *
+ * @return the selected color, or null if the dialog was
+ * cancelled, no color was selected, or an error
+ * occurred
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
*/
-public void setRGB (RGB rgb) {
- this.rgb = rgb;
-}
-}
+public RGB open () {
+ byte [] buffer = Converter.wcsToMbcs (null, title, true);
+ int handle = OS.gtk_color_selection_dialog_new (buffer);
+ if (parent!=null) {
+ OS.gtk_window_set_transient_for(handle, parent.topHandle());
+ }
+ GtkColorSelectionDialog dialog = new GtkColorSelectionDialog ();
+ OS.memmove(dialog, handle);
+ GdkColor color = new GdkColor();
+ if (rgb != null) {
+ color.red = (short)((rgb.red & 0xFF) | ((rgb.red & 0xFF) << 8));
+ color.green = (short)((rgb.green & 0xFF) | ((rgb.green & 0xFF) << 8));
+ color.blue = (short)((rgb.blue & 0xFF) | ((rgb.blue & 0xFF) << 8));
+ OS.gtk_color_selection_set_current_color (dialog.colorsel, color);
+ }
+ int response = OS.gtk_dialog_run(handle);
+ boolean success = response == OS.GTK_RESPONSE_OK;
+ if (success) {
+ OS.gtk_color_selection_get_current_color (dialog.colorsel, color);
+ int red = (color.red >> 8) & 0xFF;
+ int green = (color.green >> 8) & 0xFF;
+ int blue = (color.blue >> 8) & 0xFF;
+ rgb = new RGB (red, green, blue);
+ }
+ OS.gtk_widget_destroy(handle);
+ if (!success) return null;
+ return rgb;
+}
+/**
+ * Returns the receiver's selected color to be the argument.
+ *
+ * @param rgb the new RGB value for the selected color, may be
+ * null to let the platform to select a default when
+ * open() is called
+ *
+ * @see PaletteData#getRGBs
+ */
+public void setRGB (RGB rgb) {
+ this.rgb = rgb;
+}
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Combo.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Combo.java
index f95acf6d97..f9b32b7f84 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Combo.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Combo.java
@@ -13,48 +13,48 @@ import org.eclipse.swt.internal.gtk.*;
import org.eclipse.swt.graphics.*;
import org.eclipse.swt.events.*;
-/**
- * Instances of this class are controls that allow the user
- * to choose an item from a list of items, or optionally
- * enter a new value by typing it into an editable text
- * field. Often, <code>Combo</code>s are used in the same place
- * where a single selection <code>List</code> widget could
- * be used but space is limited. A <code>Combo</code> takes
- * less space than a <code>List</code> widget and shows
- * similar information.
- * <p>
- * Note: Since <code>Combo</code>s can contain both a list
- * and an editable text field, it is possible to confuse methods
- * which access one versus the other (compare for example,
- * <code>clearSelection()</code> and <code>deselectAll()</code>).
- * The API documentation is careful to indicate either "the
- * receiver's list" or the "the receiver's text field" to
- * distinguish between the two cases.
- * </p><p>
- * Note that although this class is a subclass of <code>Composite</code>,
- * it does not make sense to add children to it, or set a layout on it.
- * </p>
- * <dl>
- * <dt><b>Styles:</b></dt>
- * <dd>DROP_DOWN, READ_ONLY, SIMPLE</dd>
- * <dt><b>Events:</b></dt>
- * <dd>DefaultSelection, Modify, Selection</dd>
- * </dl>
- * <p>
- * Note: Only one of the styles DROP_DOWN and SIMPLE
- * may be specified.
- * </p><p>
- * IMPORTANT: This class is <em>not</em> intended to be subclassed.
- * </p>
- *
- * @see List
+/**
+ * Instances of this class are controls that allow the user
+ * to choose an item from a list of items, or optionally
+ * enter a new value by typing it into an editable text
+ * field. Often, <code>Combo</code>s are used in the same place
+ * where a single selection <code>List</code> widget could
+ * be used but space is limited. A <code>Combo</code> takes
+ * less space than a <code>List</code> widget and shows
+ * similar information.
+ * <p>
+ * Note: Since <code>Combo</code>s can contain both a list
+ * and an editable text field, it is possible to confuse methods
+ * which access one versus the other (compare for example,
+ * <code>clearSelection()</code> and <code>deselectAll()</code>).
+ * The API documentation is careful to indicate either "the
+ * receiver's list" or the "the receiver's text field" to
+ * distinguish between the two cases.
+ * </p><p>
+ * Note that although this class is a subclass of <code>Composite</code>,
+ * it does not make sense to add children to it, or set a layout on it.
+ * </p>
+ * <dl>
+ * <dt><b>Styles:</b></dt>
+ * <dd>DROP_DOWN, READ_ONLY, SIMPLE</dd>
+ * <dt><b>Events:</b></dt>
+ * <dd>DefaultSelection, Modify, Selection</dd>
+ * </dl>
+ * <p>
+ * Note: Only one of the styles DROP_DOWN and SIMPLE
+ * may be specified.
+ * </p><p>
+ * IMPORTANT: This class is <em>not</em> intended to be subclassed.
+ * </p>
+ *
+ * @see List
*/
public class Combo extends Composite {
int arrowHandle, entryHandle, listHandle;
String [] items = new String [0];
- /**
- * the operating system limit for the number of characters
- * that the text field in an instance of this class can hold
+ /**
+ * the operating system limit for the number of characters
+ * that the text field in an instance of this class can hold
*/
public final static int LIMIT;
@@ -67,57 +67,57 @@ public class Combo extends Composite {
LIMIT = 0xFFFF;
}
-/**
- * Constructs a new instance of this class given its parent
- * and a style value describing its behavior and appearance.
- * <p>
- * The style value is either one of the style constants defined in
- * class <code>SWT</code> which is applicable to instances of this
- * class, or must be built by <em>bitwise OR</em>'ing together
- * (that is, using the <code>int</code> "|" operator) two or more
- * of those <code>SWT</code> style constants. The class description
- * lists the style constants that are applicable to the class.
- * Style bits are also inherited from superclasses.
- * </p>
- *
- * @param parent a composite control which will be the parent of the new instance (cannot be null)
- * @param style the style of control to construct
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
- * <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
- * </ul>
- *
- * @see SWT#DROP_DOWN
- * @see SWT#READ_ONLY
- * @see SWT#SIMPLE
- * @see Widget#checkSubclass
- * @see Widget#getStyle
+/**
+ * Constructs a new instance of this class given its parent
+ * and a style value describing its behavior and appearance.
+ * <p>
+ * The style value is either one of the style constants defined in
+ * class <code>SWT</code> which is applicable to instances of this
+ * class, or must be built by <em>bitwise OR</em>'ing together
+ * (that is, using the <code>int</code> "|" operator) two or more
+ * of those <code>SWT</code> style constants. The class description
+ * lists the style constants that are applicable to the class.
+ * Style bits are also inherited from superclasses.
+ * </p>
+ *
+ * @param parent a composite control which will be the parent of the new instance (cannot be null)
+ * @param style the style of control to construct
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
+ * <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
+ * </ul>
+ *
+ * @see SWT#DROP_DOWN
+ * @see SWT#READ_ONLY
+ * @see SWT#SIMPLE
+ * @see Widget#checkSubclass
+ * @see Widget#getStyle
*/
public Combo (Composite parent, int style) {
super (parent, checkStyle (style));
}
-/**
- * Adds the argument to the end of the receiver's list.
- *
- * @param string the new item
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the string is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- * @exception SWTError <ul>
- * <li>ERROR_ITEM_NOT_ADDED - if the operation fails because of an operating system failure</li>
- * </ul>
- *
- * @see #add(String,int)
+/**
+ * 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();
@@ -128,31 +128,31 @@ public void add (String string) {
setItems (newItems, true, 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)
+/**
+ * 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();
@@ -167,24 +167,24 @@ public void add (String string, int index) {
setItems (newItems, true, true);
}
-/**
- * Adds the listener to the collection of listeners who will
- * be notified when the receiver's text is modified, by sending
- * it one of the messages defined in the <code>ModifyListener</code>
- * interface.
- *
- * @param listener the listener which should be notified
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see ModifyListener
- * @see #removeModifyListener
+/**
+ * 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();
@@ -193,29 +193,29 @@ public void addModifyListener (ModifyListener 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.
- * <p>
- * <code>widgetSelected</code> is called when the combo's list selection changes.
- * <code>widgetDefaultSelected</code> is typically called when ENTER is pressed the combo's text area.
- * </p>
- *
- * @param listener the listener which should be notified
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see SelectionListener
- * @see #removeSelectionListener
- * @see SelectionEvent
+/**
+ * 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.
+ * <p>
+ * <code>widgetSelected</code> is called when the combo's list selection changes.
+ * <code>widgetDefaultSelected</code> is typically called when ENTER is pressed the combo's text area.
+ * </p>
+ *
+ * @param listener the listener which should be notified
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see SelectionListener
+ * @see #removeSelectionListener
+ * @see SelectionEvent
*/
public void addSelectionListener(SelectionListener listener) {
checkWidget();
@@ -253,22 +253,22 @@ static int checkStyle (int style) {
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
+/**
+ * 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();
@@ -452,36 +452,36 @@ void hookEvents () {
}
}
-/**
- * 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>
+/**
+ * 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();
setItems (items, true, getSelectionIndex () != index);
}
-/**
- * Deselects all selected items in the receiver's list.
- * <p>
- * Note: To clear the selection in the receiver's text field,
- * use <code>clearSelection()</code>.
- * </p>
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see #clearSelection
+/**
+ * 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();
@@ -500,24 +500,24 @@ GdkColor getForegroundColor () {
return getTextColor ();
}
-/**
- * Returns the item at the given, zero-relative index in the
- * receiver's list. Throws an exception if the index is out
- * of range.
- *
- * @param index the index of the item to return
- * @return the item at the given index
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_INVALID_RANGE - if the index is not between 0 and the number of elements in the list minus 1 (inclusive)</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- * @exception SWTError <ul>
- * <li>ERROR_CANNOT_GET_ITEM - if the operation fails because of an operating system failure</li>
- * </ul>
+/**
+ * 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();
@@ -527,61 +527,61 @@ public String getItem (int index) {
return items [index];
}
-/**
- * Returns the number of items contained in the receiver's list.
- *
- * @return the number of items
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- * @exception SWTError <ul>
- * <li>ERROR_CANNOT_GET_COUNT - if the operation fails because of an operating system failure</li>
- * </ul>
+/**
+ * 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();
return items.length;
}
-/**
- * Returns the height of the area which would be used to
- * display <em>one</em> of the items in the receiver's list.
- *
- * @return the height of one item
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- * @exception SWTError <ul>
- * <li>ERROR_CANNOT_GET_ITEM_HEIGHT - if the operation fails because of an operating system failure</li>
- * </ul>
+/**
+ * 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();
return fontHeight (getFontDescription (), listHandle != 0 ? listHandle : handle);
}
-/**
- * Returns an array of <code>String</code>s which are the items
- * in the receiver's list.
- * <p>
- * Note: This is not the actual structure used by the receiver
- * to maintain its list of items, so modifying the array will
- * not affect the receiver.
- * </p>
- *
- * @return the items in the receiver's list
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- * @exception SWTError <ul>
- * <li>ERROR_CANNOT_GET_ITEM - if the operation fails because of an operating system failure</li>
- * </ul>
+/**
+ * Returns an array of <code>String</code>s which are the items
+ * in the receiver's list.
+ * <p>
+ * Note: This is not the actual structure used by the receiver
+ * to maintain its list of items, so modifying the array will
+ * not affect the receiver.
+ * </p>
+ *
+ * @return the items in the receiver's list
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * @exception SWTError <ul>
+ * <li>ERROR_CANNOT_GET_ITEM - if the operation fails because of an operating system failure</li>
+ * </ul>
*/
public String [] getItems () {
checkWidget();
@@ -590,19 +590,19 @@ public String [] getItems () {
return result;
}
-/**
- * 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>
+/**
+ * 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 ();
@@ -612,16 +612,16 @@ public Point getSelection () {
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>
+/**
+ * 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();
@@ -629,16 +629,16 @@ public int getSelectionIndex () {
return indexOf (getText ());
}
-/**
- * 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>
+/**
+ * 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();
@@ -658,36 +658,36 @@ String getText (int start, int stop) {
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>
+/**
+ * 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();
return fontHeight (getFontDescription (), entryHandle != 0 ? entryHandle : handle) + 8;
}
-/**
- * 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>
+/**
+ * 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();
@@ -710,45 +710,45 @@ int gtk_select_child (int list, int widget) {
return 0;
}
-/**
- * Searches the receiver's list starting at the first item
- * (index 0) until an item is found that is equal to the
- * argument, and returns the index of that item. If no item
- * is found, returns -1.
- *
- * @param string the search item
- * @return the index of the item
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the string is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
+/**
+ * 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>
+/**
+ * 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();
@@ -794,22 +794,22 @@ void releaseHandle () {
entryHandle = listHandle = 0;
}
-/**
- * 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>
+/**
+ * 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();
@@ -823,24 +823,24 @@ public void remove (int index) {
setItems (newItems, true, true);
}
-/**
- * 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>
+/**
+ * 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();
@@ -854,24 +854,24 @@ public void remove (int start, int end) {
setItems (newItems, true, true);
}
-/**
- * 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>
+/**
+ * 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();
@@ -880,35 +880,35 @@ public void remove (String string) {
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>
+/**
+ * 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();
setItems (new String [0], false, false);
}
-/**
- * Removes the listener from the collection of listeners who will
- * be notified when the receiver's text is modified.
- *
- * @param listener the listener which should no longer be notified
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see ModifyListener
- * @see #addModifyListener
+/**
+ * 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();
@@ -917,22 +917,22 @@ public void removeModifyListener (ModifyListener listener) {
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
+/**
+ * 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();
@@ -942,17 +942,17 @@ public void removeSelectionListener (SelectionListener 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>
+/**
+ * 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();
@@ -983,26 +983,26 @@ void setForegroundColor (GdkColor color) {
if (listHandle != 0) OS.gtk_widget_modify_text (listHandle, 0, color);
}
-/**
- * Sets the text of the item in the receiver's list at the given
- * zero-relative index to the string argument. This is equivalent
- * to <code>remove</code>'ing the old item at the index, and then
- * <code>add</code>'ing the new item at that index.
- *
- * @param index the index for the item
- * @param string the new text for the item
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_INVALID_RANGE - if the index is not between 0 and the number of elements in the list minus 1 (inclusive)</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - 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>
+/**
+ * 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();
@@ -1014,18 +1014,18 @@ public void setItem (int index, String string) {
setItems (items, true, true);
}
-/**
- * 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>
+/**
+ * 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();
@@ -1090,21 +1090,21 @@ void setItems (String [] items, boolean keepText, boolean keepSelection) {
if (!keepText) OS.gtk_editable_delete_text (entryHandle, 0, -1);
}
-/**
- * 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>
+/**
+ * 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();
@@ -1113,26 +1113,26 @@ public void setSelection (Point selection) {
OS.gtk_editable_select_region (entryHandle, selection.x, selection.y);
}
-/**
- * Sets the contents of the receiver's text field to the
- * given string.
- * <p>
- * Note: The text field in a <code>Combo</code> is typically
- * only capable of displaying a single line of text. Thus,
- * setting the text to a string containing line breaks or
- * other special characters will probably cause it to
- * display incorrectly.
- * </p>
- *
- * @param 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>
+/**
+ * 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();
@@ -1143,19 +1143,19 @@ public void setText (String string) {
OS.g_signal_handlers_unblock_matched (listHandle, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, SELECT_CHILD);
}
-/**
- * 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>
+/**
+ * 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();
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Composite.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Composite.java
index e37a86aced..fca3ed2854 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Composite.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Composite.java
@@ -11,28 +11,28 @@ import org.eclipse.swt.*;
import org.eclipse.swt.internal.gtk.*;
import org.eclipse.swt.graphics.*;
-/**
- * Instances of this class are controls which are capable
- * of containing other controls.
- * <dl>
- * <dt><b>Styles:</b></dt>
- * <dd>NO_BACKGROUND, NO_FOCUS, NO_MERGE_PAINTS, NO_REDRAW_RESIZE, NO_RADIO_GROUP</dd>
- * <dt><b>Events:</b></dt>
- * <dd>(none)</dd>
- * </dl>
- * <p>
- * Note: The <code>NO_BACKGROUND</code>, <code>NO_FOCUS</code>, <code>NO_MERGE_PAINTS</code>,
- * and <code>NO_REDRAW_RESIZE</code> styles are intended for use with <code>Canvas</code>.
- * They can be used with <code>Composite</code> if you are drawing your own, but their
- * behavior is undefined if they are used with subclasses of <code>Composite</code> other
- * than <code>Canvas</code>.
- * </p><p>
- * This class may be subclassed by custom control implementors
- * who are building controls that are constructed from aggregates
- * of other controls.
- * </p>
- *
- * @see Canvas
+/**
+ * Instances of this class are controls which are capable
+ * of containing other controls.
+ * <dl>
+ * <dt><b>Styles:</b></dt>
+ * <dd>NO_BACKGROUND, NO_FOCUS, NO_MERGE_PAINTS, NO_REDRAW_RESIZE, NO_RADIO_GROUP</dd>
+ * <dt><b>Events:</b></dt>
+ * <dd>(none)</dd>
+ * </dl>
+ * <p>
+ * Note: The <code>NO_BACKGROUND</code>, <code>NO_FOCUS</code>, <code>NO_MERGE_PAINTS</code>,
+ * and <code>NO_REDRAW_RESIZE</code> styles are intended for use with <code>Canvas</code>.
+ * They can be used with <code>Composite</code> if you are drawing your own, but their
+ * behavior is undefined if they are used with subclasses of <code>Composite</code> other
+ * than <code>Canvas</code>.
+ * </p><p>
+ * This class may be subclassed by custom control implementors
+ * who are building controls that are constructed from aggregates
+ * of other controls.
+ * </p>
+ *
+ * @see Canvas
*/
public class Composite extends Scrollable {
int radioHandle, imHandle;
@@ -43,35 +43,35 @@ Composite () {
/* Do nothing */
}
-/**
- * Constructs a new instance of this class given its parent
- * and a style value describing its behavior and appearance.
- * <p>
- * The style value is either one of the style constants defined in
- * class <code>SWT</code> which is applicable to instances of this
- * class, or must be built by <em>bitwise OR</em>'ing together
- * (that is, using the <code>int</code> "|" operator) two or more
- * of those <code>SWT</code> style constants. The class description
- * lists the style constants that are applicable to the class.
- * Style bits are also inherited from superclasses.
- * </p>
- *
- * @param parent a widget which will be the parent of the new instance (cannot be null)
- * @param style the style of widget to construct
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
- * </ul>
- *
- * @see SWT#NO_BACKGROUND
- * @see SWT#NO_FOCUS
- * @see SWT#NO_MERGE_PAINTS
- * @see SWT#NO_REDRAW_RESIZE
- * @see SWT#NO_RADIO_GROUP
- * @see Widget#getStyle
+/**
+ * Constructs a new instance of this class given its parent
+ * and a style value describing its behavior and appearance.
+ * <p>
+ * The style value is either one of the style constants defined in
+ * class <code>SWT</code> which is applicable to instances of this
+ * class, or must be built by <em>bitwise OR</em>'ing together
+ * (that is, using the <code>int</code> "|" operator) two or more
+ * of those <code>SWT</code> style constants. The class description
+ * lists the style constants that are applicable to the class.
+ * Style bits are also inherited from superclasses.
+ * </p>
+ *
+ * @param parent a widget which will be the parent of the new instance (cannot be null)
+ * @param style the style of widget to construct
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
+ * </ul>
+ *
+ * @see SWT#NO_BACKGROUND
+ * @see SWT#NO_FOCUS
+ * @see SWT#NO_MERGE_PAINTS
+ * @see SWT#NO_REDRAW_RESIZE
+ * @see SWT#NO_RADIO_GROUP
+ * @see Widget#getStyle
*/
public Composite (Composite parent, int style) {
super (parent, style);
@@ -104,23 +104,23 @@ Control [] _getChildren () {
return newChildren;
}
-Control [] _getTabList () {
- if (tabList == null) return tabList;
- int count = 0;
- for (int i=0; i<tabList.length; i++) {
- if (!tabList [i].isDisposed ()) count++;
- }
- if (count == tabList.length) return tabList;
- Control [] newList = new Control [count];
- int index = 0;
- for (int i=0; i<tabList.length; i++) {
- if (!tabList [i].isDisposed ()) {
- newList [index++] = tabList [i];
- }
- }
- tabList = newList;
- return tabList;
-}
+Control [] _getTabList () {
+ if (tabList == null) return tabList;
+ int count = 0;
+ for (int i=0; i<tabList.length; i++) {
+ if (!tabList [i].isDisposed ()) count++;
+ }
+ if (count == tabList.length) return tabList;
+ Control [] newList = new Control [count];
+ int index = 0;
+ for (int i=0; i<tabList.length; i++) {
+ if (!tabList [i].isDisposed ()) {
+ newList [index++] = tabList [i];
+ }
+ }
+ tabList = newList;
+ return tabList;
+}
protected void checkSubclass () {
/* Do nothing - Subclassing is allowed */
@@ -244,36 +244,36 @@ public int getBorderWidth () {
return OS.gtk_container_get_border_width (topHandle);
}
-/**
- * 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 affect 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>
+/**
+ * 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 affect 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 ();
}
-/**
- * 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>
+/**
+ * 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();
@@ -398,39 +398,39 @@ int imHandle () {
return imHandle;
}
-/**
- * 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>
+/**
+ * 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 () {
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>
+/**
+ * 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();
@@ -574,16 +574,16 @@ public boolean setFocus () {
return super.setFocus ();
}
-/**
- * Sets the layout which is associated with the receiver to be
- * the argument which may be null.
- *
- * @param layout the receiver's new layout or null
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
+/**
+ * Sets the layout which is associated with the receiver to be
+ * the argument which may be null.
+ *
+ * @param layout the receiver's new layout or null
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
*/
public void setLayout (Layout layout) {
checkWidget();
@@ -617,20 +617,20 @@ boolean setTabItemFocus () {
return super.setTabItemFocus ();
}
-/**
- * Sets the tabbing order for the specified controls to
- * match the order that they occur in the argument list.
- *
- * @param tabList the ordered list of controls representing the tab order or null
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_INVALID_ARGUMENT - if a widget in the tabList is null or has been disposed</li>
- * <li>ERROR_INVALID_PARENT - if widget in the tabList is not in the same widget tree</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
+/**
+ * Sets the tabbing order for the specified controls to
+ * match the order that they occur in the argument list.
+ *
+ * @param tabList the ordered list of controls representing the tab order or null
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_INVALID_ARGUMENT - if a widget in the tabList is null or has been disposed</li>
+ * <li>ERROR_INVALID_PARENT - if widget in the tabList is not in the same widget tree</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
*/
public void setTabList (Control [] tabList) {
checkWidget ();
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Control.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Control.java
index 842909ebc0..48a06d439e 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Control.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Control.java
@@ -14,20 +14,20 @@ import org.eclipse.swt.graphics.*;
import org.eclipse.swt.events.*;
import org.eclipse.swt.accessibility.*;
-/**
- * Control is the abstract superclass of all windowed user interface classes.
- * <p>
- * <dl>
- * <dt><b>Styles:</b>
- * <dd>BORDER</dd>
- * <dt><b>Events:</b>
- * <dd>FocusIn, FocusOut, Help, KeyDown, KeyUp, MouseDoubleClick, 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>
+/**
+ * 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>FocusIn, FocusOut, Help, KeyDown, KeyUp, MouseDoubleClick, 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 {
int fixedHandle;
@@ -41,33 +41,33 @@ public abstract class Control extends Widget implements Drawable {
Control () {
}
-/**
- * Constructs a new instance of this class given its parent
- * and a style value describing its behavior and appearance.
- * <p>
- * The style value is either one of the style constants defined in
- * class <code>SWT</code> which is applicable to instances of this
- * class, or must be built by <em>bitwise OR</em>'ing together
- * (that is, using the <code>int</code> "|" operator) two or more
- * of those <code>SWT</code> style constants. The class description
- * lists the style constants that are applicable to the class.
- * Style bits are also inherited from superclasses.
- * </p>
- *
- * @param parent a composite control which will be the parent of the new instance (cannot be null)
- * @param style the style of control to construct
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
- * <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
- * </ul>
- *
- * @see SWT#BORDER
- * @see Widget#checkSubclass
- * @see Widget#getStyle
+/**
+ * Constructs a new instance of this class given its parent
+ * and a style value describing its behavior and appearance.
+ * <p>
+ * The style value is either one of the style constants defined in
+ * class <code>SWT</code> which is applicable to instances of this
+ * class, or must be built by <em>bitwise OR</em>'ing together
+ * (that is, using the <code>int</code> "|" operator) two or more
+ * of those <code>SWT</code> style constants. The class description
+ * lists the style constants that are applicable to the class.
+ * Style bits are also inherited from superclasses.
+ * </p>
+ *
+ * @param parent a composite control which will be the parent of the new instance (cannot be null)
+ * @param style the style of control to construct
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
+ * <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
+ * </ul>
+ *
+ * @see SWT#BORDER
+ * @see Widget#checkSubclass
+ * @see Widget#getStyle
*/
public Control (Composite parent, int style) {
super (parent, style);
@@ -199,32 +199,32 @@ int paintWindow () {
return OS.GTK_WIDGET_WINDOW (paintHandle);
}
-/**
- * Returns the preferred size of the receiver.
- * <p>
- * The <em>preferred size</em> of a control is the size that it would
- * best be displayed at. The width hint and height hint arguments
- * allow the caller to ask a control questions such as "Given a particular
- * width, how high does the control need to be to show all of the contents?"
- * To indicate that the caller does not wish to constrain a particular
- * dimension, the constant <code>SWT.DEFAULT</code> is passed for the hint.
- * </p>
- *
- * @param wHint the width hint (can be <code>SWT.DEFAULT</code>)
- * @param hHint the height hint (can be <code>SWT.DEFAULT</code>)
- * @return the preferred size of the control
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see Layout
- * @see #getBorderWidth
- * @see #getBounds
- * @see #getSize
- * @see #pack
- * @see "computeTrim, getClientArea for controls that implement them"
+/**
+ * Returns the preferred size of the receiver.
+ * <p>
+ * The <em>preferred size</em> of a control is the size that it would
+ * best be displayed at. The width hint and height hint arguments
+ * allow the caller to ask a control questions such as "Given a particular
+ * width, how high does the control need to be to show all of the contents?"
+ * To indicate that the caller does not wish to constrain a particular
+ * dimension, the constant <code>SWT.DEFAULT</code> is passed for the hint.
+ * </p>
+ *
+ * @param wHint the width hint (can be <code>SWT.DEFAULT</code>)
+ * @param hHint the height hint (can be <code>SWT.DEFAULT</code>)
+ * @return the preferred size of the control
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see Layout
+ * @see #getBorderWidth
+ * @see #getBounds
+ * @see #getSize
+ * @see #pack
+ * @see "computeTrim, getClientArea for controls that implement them"
*/
public Point computeSize (int wHint, int hHint) {
return computeSize (wHint, hHint, true);
@@ -266,39 +266,39 @@ void createWidget (int index) {
setZOrder (null, false);
}
-/**
- * Returns the preferred size of the receiver.
- * <p>
- * The <em>preferred size</em> of a control is the size that it would
- * best be displayed at. The width hint and height hint arguments
- * allow the caller to ask a control questions such as "Given a particular
- * width, how high does the control need to be to show all of the contents?"
- * To indicate that the caller does not wish to constrain a particular
- * dimension, the constant <code>SWT.DEFAULT</code> is passed for the hint.
- * </p><p>
- * If the changed flag is <code>true</code>, it indicates that the receiver's
- * <em>contents</em> have changed, therefore any caches that a layout manager
- * containing the control may have been keeping need to be flushed. When the
- * control is resized, the changed flag will be <code>false</code>, so layout
- * manager caches can be retained.
- * </p>
- *
- * @param wHint the width hint (can be <code>SWT.DEFAULT</code>)
- * @param hHint the height hint (can be <code>SWT.DEFAULT</code>)
- * @param changed <code>true</code> if the control's contents have changed, and <code>false</code> otherwise
- * @return the preferred size of the control.
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see Layout
- * @see #getBorderWidth
- * @see #getBounds
- * @see #getSize
- * @see #pack
- * @see "computeTrim, getClientArea for controls that implement them"
+/**
+ * Returns the preferred size of the receiver.
+ * <p>
+ * The <em>preferred size</em> of a control is the size that it would
+ * best be displayed at. The width hint and height hint arguments
+ * allow the caller to ask a control questions such as "Given a particular
+ * width, how high does the control need to be to show all of the contents?"
+ * To indicate that the caller does not wish to constrain a particular
+ * dimension, the constant <code>SWT.DEFAULT</code> is passed for the hint.
+ * </p><p>
+ * If the changed flag is <code>true</code>, it indicates that the receiver's
+ * <em>contents</em> have changed, therefore any caches that a layout manager
+ * containing the control may have been keeping need to be flushed. When the
+ * control is resized, the changed flag will be <code>false</code>, so layout
+ * manager caches can be retained.
+ * </p>
+ *
+ * @param wHint the width hint (can be <code>SWT.DEFAULT</code>)
+ * @param hHint the height hint (can be <code>SWT.DEFAULT</code>)
+ * @param changed <code>true</code> if the control's contents have changed, and <code>false</code> otherwise
+ * @return the preferred size of the control.
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see Layout
+ * @see #getBorderWidth
+ * @see #getBounds
+ * @see #getSize
+ * @see #pack
+ * @see "computeTrim, getClientArea for controls that implement them"
*/
public Point computeSize (int wHint, int hHint, boolean changed) {
checkWidget();
@@ -317,22 +317,22 @@ Point computeNativeSize (int h, int wHint, int hHint, boolean changed) {
return new Point (width, height);
}
-/**
- * Returns the accessible object for the receiver.
- * If this is the first time this object is requested,
- * then the object is created and returned.
- *
- * @return the accessible object
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see Accessible#addAccessibleListener
- * @see Accessible#addAccessibleControlListener
- *
- * @since 2.0
+/**
+ * Returns the accessible object for the receiver.
+ * If this is the first time this object is requested,
+ * then the object is created and returned.
+ *
+ * @return the accessible object
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see Accessible#addAccessibleListener
+ * @see Accessible#addAccessibleControlListener
+ *
+ * @since 2.0
*/
public Accessible getAccessible () {
checkWidget ();
@@ -342,16 +342,16 @@ public Accessible getAccessible () {
return accessible;
}
-/**
- * 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>
+/**
+ * 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();
@@ -363,23 +363,23 @@ public Rectangle getBounds () {
return new Rectangle (x, y, width, height);
}
-/**
- * Sets the receiver's size and location to the rectangular
- * area specified by the argument. The <code>x</code> and
- * <code>y</code> fields of the rectangle are relative to
- * the receiver's parent (or its display if its parent is null).
- * <p>
- * Note: Attempting to set the width or height of the
- * receiver to a negative number will cause that
- * value to be set to zero instead.
- * </p>
- *
- * @param rect the new bounds for the receiver
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
+/**
+ * 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 ();
@@ -387,26 +387,26 @@ public void setBounds (Rectangle rect) {
setBounds (rect.x, rect.y, rect.width, rect.height);
}
-/**
- * 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>
+/**
+ * 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();
@@ -478,16 +478,16 @@ boolean setBounds (int x, int y, int width, int height, boolean move, boolean re
return !sameOrigin || !sameExtent;
}
-/**
- * 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>
+/**
+ * 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();
@@ -497,17 +497,17 @@ public Point getLocation () {
return new Point (x, y);
}
-/**
- * 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>
+/**
+ * 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 ();
@@ -515,36 +515,36 @@ public void setLocation (Point location) {
setLocation (location.x, location.y);
}
-/**
- * Sets the receiver's location to the point specified by
- * the arguments which are relative to the receiver's
- * parent (or its display if its parent is null).
- *
- * @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>
+/**
+ * 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, true, false);
}
-/**
- * Returns a point describing the receiver's size. The
- * x coordinate of the result is the width of the receiver.
- * The y coordinate of the result is the height of the
- * receiver.
- *
- * @return the receiver's size
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
+/**
+ * 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();
@@ -554,24 +554,24 @@ public Point getSize () {
return new Point (width, height);
}
-/**
- * Sets the receiver's size to the point specified by the argument.
- * <p>
- * Note: Attempting to set the width or height of the
- * receiver to a negative number will cause them to be
- * set to zero instead.
- * </p>
- *
- * @param size the new size for the receiver
- * @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>
+/**
+ * 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 ();
@@ -579,43 +579,43 @@ public void setSize (Point size) {
setSize (size.x, size.y);
}
-/**
- * Sets the receiver's size to the point specified by the arguments.
- * <p>
- * Note: Attempting to set the width or height of the
- * receiver to a negative number will cause that
- * value to be set to zero instead.
- * </p>
- *
- * @param width the new width for the receiver
- * @param height the new height for the receiver
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
+/**
+ * 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, width, height, false, true);
}
-/**
- * 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 IllegalArgumentException <ul>
- * <li>ERROR_INVALID_ARGUMENT - if the control has been disposed</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
+/**
+ * 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 IllegalArgumentException <ul>
+ * <li>ERROR_INVALID_ARGUMENT - if the control has been disposed</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
*/
public void moveAbove (Control control) {
checkWidget();
@@ -626,22 +626,22 @@ public void moveAbove (Control control) {
setZOrder (control, true);
}
-/**
- * Moves the receiver below the specified control in the
- * drawing order. If the argument is null, then the receiver
- * is moved to the bottom of the drawing order. The control at
- * the bottom of the drawing order will be covered by all other
- * controls which occupy intersecting areas.
- *
- * @param the sibling control (or null)
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_INVALID_ARGUMENT - if the control has been disposed</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
+/**
+ * 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 IllegalArgumentException <ul>
+ * <li>ERROR_INVALID_ARGUMENT - if the control has been disposed</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
*/
public void moveBelow (Control control) {
checkWidget();
@@ -652,54 +652,54 @@ public void moveBelow (Control control) {
setZOrder (control, false);
}
-/**
- * Causes the receiver to be resized to its preferred size.
- * For a composite, this involves computing the preferred size
- * from its layout, if there is one.
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see #computeSize
+/**
+ * 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 () {
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
+/**
+ * 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) {
setSize (computeSize (SWT.DEFAULT, SWT.DEFAULT, changed));
}
-/**
- * Sets the layout data associated with the receiver to the argument.
- *
- * @param layoutData the new layout data for the receiver.
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
+/**
+ * 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();
@@ -715,20 +715,20 @@ public Point toControl (int x, int y) {
return new Point (x - origin_x [0], y - origin_y [0]);
}
-/**
- * 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>
+/**
+ * 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 ();
@@ -745,20 +745,20 @@ public Point toDisplay (int x, int y) {
return new Point (origin_x [0] + x, origin_y [0] + 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>
+/**
+ * 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();
@@ -766,24 +766,24 @@ public Point toDisplay (Point point) {
return toDisplay (point.x, point.y);
}
-/**
- * Adds the listener to the collection of listeners who will
- * be notified when the control is moved or resized, by sending
- * it one of the messages defined in the <code>ControlListener</code>
- * interface.
- *
- * @param listener the listener which should be notified
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see ControlListener
- * @see #removeControlListener
+/**
+ * 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();
@@ -793,24 +793,24 @@ public void addControlListener(ControlListener listener) {
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
+/**
+ * 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();
@@ -820,24 +820,24 @@ public void addFocusListener(FocusListener listener) {
addListener(SWT.FocusOut,typedListener);
}
-/**
- * Adds the listener to the collection of listeners who will
- * be notified when help events are generated for the control,
- * by sending it one of the messages defined in the
- * <code>HelpListener</code> interface.
- *
- * @param listener the listener which should be notified
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see HelpListener
- * @see #removeHelpListener
+/**
+ * Adds the listener to the collection of listeners who will
+ * be notified when help events are generated for the control,
+ * by sending it one of the messages defined in the
+ * <code>HelpListener</code> interface.
+ *
+ * @param listener the listener which should be notified
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see HelpListener
+ * @see #removeHelpListener
*/
public void addHelpListener (HelpListener listener) {
checkWidget();
@@ -846,24 +846,24 @@ public void addHelpListener (HelpListener 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
+/**
+ * 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();
@@ -873,24 +873,24 @@ public void addKeyListener(KeyListener listener) {
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
+/**
+ * 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();
@@ -901,24 +901,24 @@ public void addMouseListener(MouseListener listener) {
addListener(SWT.MouseDoubleClick,typedListener);
}
-/**
- * Adds the listener to the collection of listeners who will
- * be notified when the mouse moves, by sending it one of the
- * messages defined in the <code>MouseMoveListener</code>
- * interface.
- *
- * @param listener the listener which should be notified
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see MouseMoveListener
- * @see #removeMouseMoveListener
+/**
+ * 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();
@@ -927,24 +927,24 @@ public void addMouseMoveListener(MouseMoveListener listener) {
addListener(SWT.MouseMove,typedListener);
}
-/**
- * Adds the listener to the collection of listeners who will
- * be notified when the mouse passes or hovers over controls, by sending
- * it one of the messages defined in the <code>MouseTrackListener</code>
- * interface.
- *
- * @param listener the listener which should be notified
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see MouseTrackListener
- * @see #removeMouseTrackListener
+/**
+ * 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();
@@ -955,24 +955,24 @@ public void addMouseTrackListener (MouseTrackListener listener) {
addListener (SWT.MouseHover,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
+/**
+ * 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();
@@ -981,24 +981,24 @@ public void addPaintListener(PaintListener 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
+/**
+ * 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();
@@ -1007,22 +1007,22 @@ public void addTraverseListener (TraverseListener listener) {
addListener (SWT.Traverse,typedListener);
}
-/**
- * Removes the listener from the collection of listeners who will
- * be notified when the control is moved or resized.
- *
- * @param listener the listener which should 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
+/**
+ * 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();
@@ -1031,22 +1031,22 @@ public void removeControlListener (ControlListener listener) {
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
+/**
+ * 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();
@@ -1055,22 +1055,22 @@ public void removeFocusListener(FocusListener listener) {
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
+/**
+ * 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();
@@ -1078,22 +1078,22 @@ public void removeHelpListener (HelpListener listener) {
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
+/**
+ * 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();
@@ -1102,22 +1102,22 @@ public void removeKeyListener(KeyListener listener) {
eventTable.unhook (SWT.KeyUp, listener);
eventTable.unhook (SWT.KeyDown, 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
+/**
+ * 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();
@@ -1127,22 +1127,22 @@ public void removeMouseListener (MouseListener 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
+/**
+ * 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();
@@ -1151,22 +1151,22 @@ public void removeMouseMoveListener(MouseMoveListener listener) {
eventTable.unhook (SWT.MouseMove, listener);
}
-/**
- * Removes the listener from the collection of listeners who will
- * be notified when the mouse passes or hovers over controls.
- *
- * @param listener the listener which should 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
+/**
+ * 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();
@@ -1177,22 +1177,22 @@ public void removeMouseTrackListener(MouseTrackListener listener) {
eventTable.unhook (SWT.MouseHover, 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
+/**
+ * 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();
@@ -1201,22 +1201,22 @@ public void removePaintListener(PaintListener listener) {
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
+/**
+ * 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 ();
@@ -1226,18 +1226,18 @@ public void removeTraverseListener(TraverseListener listener) {
}
-/**
- * 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
+/**
+ * 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();
@@ -1249,15 +1249,15 @@ public boolean forceFocus () {
return OS.gtk_widget_is_focus (handle);
}
-/**
- * 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>
+/**
+ * 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();
@@ -1292,30 +1292,30 @@ GdkColor getBaseColor () {
return color;
}
-/**
- * Returns the receiver's border width.
- *
- * @return the border width
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
+/**
+ * Returns the receiver's border width.
+ *
+ * @return the border width
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
*/
public int getBorderWidth () {
checkWidget();
return 0;
}
-/**
- * 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>
+/**
+ * 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 () {
if (parent == null) {
@@ -1323,33 +1323,33 @@ public Display getDisplay () {
}
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>
+/**
+ * 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 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>
+/**
+ * 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();
@@ -1364,15 +1364,15 @@ int getFontDescription () {
return style.font_desc;
}
-/**
- * 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>
+/**
+ * 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();
@@ -1411,51 +1411,51 @@ GdkColor getTextColor () {
return color;
}
-/**
- * Returns layout data which is associated with the receiver.
- *
- * @return the receiver's layout data
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
+/**
+ * Returns layout data which is associated with the receiver.
+ *
+ * @return the receiver's layout data
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
*/
public Object getLayoutData () {
checkWidget();
return layoutData;
}
-/**
- * Returns the receiver's pop up menu if it has one, or null
- * if it does not. All controls may optionally have a pop up
- * menu that is displayed when the user requests one for
- * the control. The sequence of key strokes, button presses
- * and/or button releases that are used to request a pop up
- * menu is platform specific.
- *
- * @return the receiver's menu
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
+/**
+ * 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>
+/**
+ * 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();
@@ -1479,20 +1479,20 @@ Control [] getPath () {
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
+/**
+ * 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();
@@ -1502,37 +1502,37 @@ Shell _getShell() {
return parent._getShell();
}
-/**
- * Returns the receiver's tool tip text, or null if it has
- * not been set.
- *
- * @return the receiver's tool tip text
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
+/**
+ * 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>
+/**
+ * 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();
@@ -1778,20 +1778,20 @@ int gtk_show_help (int widget, int helpType) {
return 0;
}
-/**
- * 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
+/**
+ * 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) {
checkWidget ();
@@ -1826,36 +1826,36 @@ int imHandle () {
return 0;
}
-/**
- * Invokes platform specific functionality to dispose a GC handle.
- * <p>
- * <b>IMPORTANT:</b> This method is <em>not</em> part of the public
- * API for <code>Control</code>. It is marked public only so that it
- * can be shared within the packages provided by SWT. It is not
- * available on all platforms, and should never be called from
- * application code.
- * </p>
- *
- * @param handle the platform specific GC handle
- * @param data the platform specific GC data
- *
- * @private
+/**
+ * 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 gdkGC, GCData data) {
checkWidget ();
OS.g_object_unref (gdkGC);
}
-/**
- * Returns <code>true</code> if the underlying operating
- * system supports this reparenting, otherwise <code>false</code>
- *
- * @return <code>true</code> if the widget can be reparented, otherwise <code>false</code>
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
+/**
+ * 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();
@@ -1928,16 +1928,16 @@ boolean isFocusAncestor () {
return control == this;
}
-/**
- * Returns <code>true</code> if the receiver has the user-interface
- * focus, and <code>false</code> otherwise.
- *
- * @return the receiver's focus state
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
+/**
+ * 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();
@@ -1975,17 +1975,17 @@ void register () {
}
-/**
- * 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
+/**
+ * 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();
@@ -1994,28 +1994,28 @@ public void redraw () {
int height = OS.GTK_WIDGET_HEIGHT (paintHandle);
redrawWidget (0, 0, width, height, true);
}
-/**
- * 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
+/**
+ * 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();
@@ -2100,20 +2100,20 @@ void sendMouseEvent (int type, int button, int gdkEvent) {
postEvent (type, event);
}
-/**
- * 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 IllegalArgumentException <ul>
- * <li>ERROR_INVALID_ARGUMENT - if the argument has been disposed</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
+/**
+ * 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 IllegalArgumentException <ul>
+ * <li>ERROR_INVALID_ARGUMENT - if the argument has been disposed</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
*/
public void setBackground (Color color) {
checkWidget();
@@ -2131,17 +2131,17 @@ void setBackgroundColor (GdkColor color) {
OS.gtk_widget_modify_bg (handle, 0, color);
}
-/**
- * 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>
+/**
+ * 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();
@@ -2154,24 +2154,24 @@ public void setCapture (boolean capture) {
}
*/
}
-/**
- * Sets the receiver's cursor to the cursor specified by the
- * argument, or to the default cursor for that kind of control
- * if the argument is null.
- * <p>
- * When the mouse pointer passes over a control its appearance
- * is changed to match the control's cursor.
- * </p>
- *
- * @param cursor the new cursor (or null)
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_INVALID_ARGUMENT - if the argument has been disposed</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
+/**
+ * Sets the receiver's cursor to the cursor specified by the
+ * argument, or to the default cursor for that kind of control
+ * if the argument is null.
+ * <p>
+ * When the mouse pointer passes over a control its appearance
+ * is changed to match the control's cursor.
+ * </p>
+ *
+ * @param cursor the new cursor (or null)
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_INVALID_ARGUMENT - if the argument has been disposed</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
*/
public void setCursor (Cursor cursor) {
checkWidget();
@@ -2186,18 +2186,18 @@ public void setCursor (Cursor cursor) {
}
}
-/**
- * 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>
+/**
+ * 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();
@@ -2213,38 +2213,38 @@ public void setEnabled (boolean enabled) {
if (fixFocus) fixFocus ();
}
-/**
- * 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
+/**
+ * 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 IllegalArgumentException <ul>
- * <li>ERROR_INVALID_ARGUMENT - if the argument has been disposed</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
+/**
+ * Sets the font that the receiver will use to paint textual information
+ * to the font specified by the argument, or to the default font for that
+ * kind of control if the argument is null.
+ *
+ * @param font the new font (or null)
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_INVALID_ARGUMENT - if the argument has been disposed</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
*/
public void setFont (Font font) {
checkWidget();
@@ -2263,20 +2263,20 @@ void setFontDescription (int font) {
OS.gtk_widget_modify_font (handle, font);
}
-/**
- * Sets the receiver's foreground color to the color specified
- * by the argument, or to the default system color for the control
- * if the argument is null.
- *
- * @param color the new color (or null)
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_INVALID_ARGUMENT - if the argument has been disposed</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
+/**
+ * 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 IllegalArgumentException <ul>
+ * <li>ERROR_INVALID_ARGUMENT - if the argument has been disposed</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
*/
public void setForeground (Color color) {
checkWidget();
@@ -2303,25 +2303,25 @@ void setInitialSize () {
OS.gtk_container_resize_children (parentHandle);
}
-/**
- * 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>
- * <li>ERROR_INVALID_ARGUMENT - if the menu has been disposed</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
+/**
+ * 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>
+ * <li>ERROR_INVALID_ARGUMENT - if the menu has been disposed</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
*/
public void setMenu (Menu menu) {
checkWidget();
@@ -2336,21 +2336,21 @@ public void setMenu (Menu menu) {
this.menu = menu;
}
-/**
- * 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 IllegalArgumentException <ul>
- * <li>ERROR_INVALID_ARGUMENT - if the argument has been disposed</li>
- * </ul>
- * @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>
+/**
+ * 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 IllegalArgumentException <ul>
+ * <li>ERROR_INVALID_ARGUMENT - if the argument has been disposed</li>
+ * </ul>
+ * @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();
@@ -2358,27 +2358,27 @@ public boolean setParent (Composite parent) {
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
+/**
+ * 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();
@@ -2392,16 +2392,16 @@ 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>
+/**
+ * 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();
@@ -2415,21 +2415,21 @@ public void setToolTipText (String string) {
OS.gtk_tooltips_set_tip (tooltipsHandle, handle, buffer, null);
}
-/**
- * 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>
+/**
+ * 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();
@@ -2496,20 +2496,20 @@ void sort (int [] items) {
}
}
-/**
- * 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>
+/**
+ * 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 ();
@@ -2705,16 +2705,16 @@ boolean traverseMnemonic (Event event) {
return true;
}
-/**
- * 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
+/**
+ * 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 ();
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Decorations.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Decorations.java
index 57b650e9a6..a6bb057931 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Decorations.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Decorations.java
@@ -1,554 +1,554 @@
-package org.eclipse.swt.widgets;
-
-/*
+package org.eclipse.swt.widgets;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-import org.eclipse.swt.*;
-import org.eclipse.swt.internal.gtk.*;
-import org.eclipse.swt.graphics.*;
-
-/**
- * Instances of this class provide the appearance and
- * behavior of <code>Shells</code>, but are not top
- * level shells or dialogs. Class <code>Shell</code>
- * shares a significant amount of code with this class,
- * and is a subclass.
- * <p>
- * Instances are always displayed in one of the maximized,
- * minimized or normal states:
- * <ul>
- * <li>
- * When an instance is marked as <em>maximized</em>, the
- * window manager will typically resize it to fill the
- * entire visible area of the display, and the instance
- * is usually put in a state where it can not be resized
- * (even if it has style <code>RESIZE</code>) until it is
- * no longer maximized.
- * </li><li>
- * When an instance is in the <em>normal</em> state (neither
- * maximized or minimized), its appearance is controlled by
- * the style constants which were specified when it was created
- * and the restrictions of the window manager (see below).
- * </li><li>
- * When an instance has been marked as <em>minimized</em>,
- * its contents (client area) will usually not be visible,
- * and depending on the window manager, it may be
- * "iconified" (that is, replaced on the desktop by a small
- * simplified representation of itself), relocated to a
- * distinguished area of the screen, or hidden. Combinations
- * of these changes are also possible.
- * </li>
- * </ul>
- * </p>
- * Note: The styles supported by this class must be treated
- * as <em>HINT</em>s, since the window manager for the
- * desktop on which the instance is visible has ultimate
- * control over the appearance and behavior of decorations.
- * For example, some window managers only support resizable
- * windows and will always assume the RESIZE style, even if
- * it is not set.
- * <dl>
- * <dt><b>Styles:</b></dt>
- * <dd>BORDER, CLOSE, MIN, MAX, NO_TRIM, RESIZE, TITLE, ON_TOP, TOOL</dd>
- * <dt><b>Events:</b></dt>
- * <dd>(none)</dd>
- * </dl>
- * Class <code>SWT</code> provides two "convenience constants"
- * for the most commonly required style combinations:
- * <dl>
- * <dt><code>SHELL_TRIM</code></dt>
- * <dd>
- * the result of combining the constants which are required
- * to produce a typical application top level shell: (that
- * is, <code>CLOSE | TITLE | MIN | MAX | RESIZE</code>)
- * </dd>
- * <dt><code>DIALOG_TRIM</code></dt>
- * <dd>
- * the result of combining the constants which are required
- * to produce a typical application dialog shell: (that
- * is, <code>TITLE | CLOSE | BORDER</code>)
- * </dd>
- * </dl>
- * <p>
- * IMPORTANT: This class is intended to be subclassed <em>only</em>
- * within the SWT implementation.
- * </p>
- *
- * @see #getMinimized
- * @see #getMaximized
- * @see Shell
- * @see SWT
+ * http://www.eclipse.org/legal/cpl-v10.html
*/
-public class Decorations extends Canvas {
- String text;
- Image image;
- boolean minimized, maximized;
- Menu menuBar;
- Menu [] menus;
- Control savedFocus;
- Button defaultButton, saveDefault;
- int accelGroup;
-
-Decorations () {
- /* Do nothing */
-}
-
-/**
- * Constructs a new instance of this class given its parent
- * and a style value describing its behavior and appearance.
- * <p>
- * The style value is either one of the style constants defined in
- * class <code>SWT</code> which is applicable to instances of this
- * class, or must be built by <em>bitwise OR</em>'ing together
- * (that is, using the <code>int</code> "|" operator) two or more
- * of those <code>SWT</code> style constants. The class description
- * lists the style constants that are applicable to the class.
- * Style bits are also inherited from superclasses.
- * </p>
- *
- * @param parent a composite control which will be the parent of the new instance (cannot be null)
- * @param style the style of control to construct
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
- * <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
- * </ul>
- *
- * @see SWT#BORDER
- * @see SWT#CLOSE
- * @see SWT#MIN
- * @see SWT#MAX
- * @see SWT#RESIZE
- * @see SWT#TITLE
- * @see SWT#NO_TRIM
- * @see SWT#SHELL_TRIM
- * @see SWT#DIALOG_TRIM
- * @see SWT#ON_TOP
- * @see SWT#TOOL
- * @see Widget#checkSubclass
- * @see Widget#getStyle
+
+import org.eclipse.swt.*;
+import org.eclipse.swt.internal.gtk.*;
+import org.eclipse.swt.graphics.*;
+
+/**
+ * Instances of this class provide the appearance and
+ * behavior of <code>Shells</code>, but are not top
+ * level shells or dialogs. Class <code>Shell</code>
+ * shares a significant amount of code with this class,
+ * and is a subclass.
+ * <p>
+ * Instances are always displayed in one of the maximized,
+ * minimized or normal states:
+ * <ul>
+ * <li>
+ * When an instance is marked as <em>maximized</em>, the
+ * window manager will typically resize it to fill the
+ * entire visible area of the display, and the instance
+ * is usually put in a state where it can not be resized
+ * (even if it has style <code>RESIZE</code>) until it is
+ * no longer maximized.
+ * </li><li>
+ * When an instance is in the <em>normal</em> state (neither
+ * maximized or minimized), its appearance is controlled by
+ * the style constants which were specified when it was created
+ * and the restrictions of the window manager (see below).
+ * </li><li>
+ * When an instance has been marked as <em>minimized</em>,
+ * its contents (client area) will usually not be visible,
+ * and depending on the window manager, it may be
+ * "iconified" (that is, replaced on the desktop by a small
+ * simplified representation of itself), relocated to a
+ * distinguished area of the screen, or hidden. Combinations
+ * of these changes are also possible.
+ * </li>
+ * </ul>
+ * </p>
+ * Note: The styles supported by this class must be treated
+ * as <em>HINT</em>s, since the window manager for the
+ * desktop on which the instance is visible has ultimate
+ * control over the appearance and behavior of decorations.
+ * For example, some window managers only support resizable
+ * windows and will always assume the RESIZE style, even if
+ * it is not set.
+ * <dl>
+ * <dt><b>Styles:</b></dt>
+ * <dd>BORDER, CLOSE, MIN, MAX, NO_TRIM, RESIZE, TITLE, ON_TOP, TOOL</dd>
+ * <dt><b>Events:</b></dt>
+ * <dd>(none)</dd>
+ * </dl>
+ * Class <code>SWT</code> provides two "convenience constants"
+ * for the most commonly required style combinations:
+ * <dl>
+ * <dt><code>SHELL_TRIM</code></dt>
+ * <dd>
+ * the result of combining the constants which are required
+ * to produce a typical application top level shell: (that
+ * is, <code>CLOSE | TITLE | MIN | MAX | RESIZE</code>)
+ * </dd>
+ * <dt><code>DIALOG_TRIM</code></dt>
+ * <dd>
+ * the result of combining the constants which are required
+ * to produce a typical application dialog shell: (that
+ * is, <code>TITLE | CLOSE | BORDER</code>)
+ * </dd>
+ * </dl>
+ * <p>
+ * IMPORTANT: This class is intended to be subclassed <em>only</em>
+ * within the SWT implementation.
+ * </p>
+ *
+ * @see #getMinimized
+ * @see #getMaximized
+ * @see Shell
+ * @see SWT
*/
-public Decorations (Composite parent, int style) {
- super (parent, checkStyle (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;
-}
-
-Control computeTabGroup () {
- return this;
-}
-
-Control computeTabRoot () {
- return this;
-}
-
-void createAccelGroup () {
- if (accelGroup != 0) return;
- accelGroup = OS.gtk_accel_group_new ();
- if (accelGroup == 0) SWT.error (SWT.ERROR_NO_HANDLES);
- //FIXME - what should we do for Decorations
- int shellHandle = topHandle ();
- OS.gtk_window_add_accel_group (shellHandle, accelGroup);
-}
-
-void createWidget (int index) {
- super.createWidget (index);
- text = "";
-}
-
-void destroyAccelGroup () {
- if (accelGroup == 0) return;
- int shellHandle = topHandle ();
- OS.gtk_window_remove_accel_group (shellHandle, accelGroup);
- //TEMPORARY CODE
-// OS.g_object_unref (accelGroup);
- accelGroup = 0;
-}
-
-/**
- * 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 class Decorations extends Canvas {
+ String text;
+ Image image;
+ boolean minimized, maximized;
+ Menu menuBar;
+ Menu [] menus;
+ Control savedFocus;
+ Button defaultButton, saveDefault;
+ int accelGroup;
+
+Decorations () {
+ /* Do nothing */
+}
+
+/**
+ * Constructs a new instance of this class given its parent
+ * and a style value describing its behavior and appearance.
+ * <p>
+ * The style value is either one of the style constants defined in
+ * class <code>SWT</code> which is applicable to instances of this
+ * class, or must be built by <em>bitwise OR</em>'ing together
+ * (that is, using the <code>int</code> "|" operator) two or more
+ * of those <code>SWT</code> style constants. The class description
+ * lists the style constants that are applicable to the class.
+ * Style bits are also inherited from superclasses.
+ * </p>
+ *
+ * @param parent a composite control which will be the parent of the new instance (cannot be null)
+ * @param style the style of control to construct
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
+ * <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
+ * </ul>
+ *
+ * @see SWT#BORDER
+ * @see SWT#CLOSE
+ * @see SWT#MIN
+ * @see SWT#MAX
+ * @see SWT#RESIZE
+ * @see SWT#TITLE
+ * @see SWT#NO_TRIM
+ * @see SWT#SHELL_TRIM
+ * @see SWT#DIALOG_TRIM
+ * @see SWT#ON_TOP
+ * @see SWT#TOOL
+ * @see Widget#checkSubclass
+ * @see Widget#getStyle
*/
-public Button getDefaultButton () {
- checkWidget();
- return defaultButton != null ? defaultButton : saveDefault;
-}
-
-/**
- * Returns the receiver's image if it had previously been
- * set using <code>setImage()</code>. The image is typically
- * displayed by the window manager when the instance is
- * marked as iconified, and may also be displayed somewhere
- * in the trim when the instance is in normal or maximized
- * states.
- * <p>
- * Note: This method will return null if called before
- * <code>setImage()</code> is called. It does not provide
- * access to a window manager provided, "default" image
- * even if one exists.
- * </p>
- *
- * @return the image
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
+public Decorations (Composite parent, int style) {
+ super (parent, checkStyle (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;
+}
+
+Control computeTabGroup () {
+ return this;
+}
+
+Control computeTabRoot () {
+ return this;
+}
+
+void createAccelGroup () {
+ if (accelGroup != 0) return;
+ accelGroup = OS.gtk_accel_group_new ();
+ if (accelGroup == 0) SWT.error (SWT.ERROR_NO_HANDLES);
+ //FIXME - what should we do for Decorations
+ int shellHandle = topHandle ();
+ OS.gtk_window_add_accel_group (shellHandle, accelGroup);
+}
+
+void createWidget (int index) {
+ super.createWidget (index);
+ text = "";
+}
+
+void destroyAccelGroup () {
+ if (accelGroup == 0) return;
+ int shellHandle = topHandle ();
+ OS.gtk_window_remove_accel_group (shellHandle, accelGroup);
+ //TEMPORARY CODE
+// OS.g_object_unref (accelGroup);
+ accelGroup = 0;
+}
+
+/**
+ * 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 Image getImage () {
- checkWidget();
- return image;
-}
-
-/**
- * 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 Button getDefaultButton () {
+ checkWidget();
+ return defaultButton != null ? defaultButton : saveDefault;
+}
+
+/**
+ * Returns the receiver's image if it had previously been
+ * set using <code>setImage()</code>. The image is typically
+ * displayed by the window manager when the instance is
+ * marked as iconified, and may also be displayed somewhere
+ * in the trim when the instance is in normal or maximized
+ * states.
+ * <p>
+ * Note: This method will return null if called before
+ * <code>setImage()</code> is called. It does not provide
+ * access to a window manager provided, "default" image
+ * even if one exists.
+ * </p>
+ *
+ * @return the image
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
*/
-public boolean getMaximized () {
- checkWidget();
- return maximized;
-}
-
-/**
- * Returns the receiver's menu bar if one had previously
- * been set, otherwise returns null.
- *
- * @return the menu bar or null
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
+public Image getImage () {
+ checkWidget();
+ return image;
+}
+
+/**
+ * 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 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 getMaximized () {
+ checkWidget();
+ return maximized;
+}
+
+/**
+ * Returns the receiver's menu bar if one had previously
+ * been set, otherwise returns null.
+ *
+ * @return the menu bar or null
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
*/
-public boolean getMinimized () {
- checkWidget();
- return minimized;
-}
-
-String getNameText () {
- return getText ();
-}
-
-/**
- * Returns the receiver's text, which is the string that the
- * window manager will typically display as the receiver's
- * <em>title</em>. If the text has not previously been set,
- * returns an empty string.
- *
- * @return the text
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
+public 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 String getText () {
- checkWidget();
- return text;
-}
-
-boolean isTabGroup () {
- return true;
-}
-
-boolean isTabItem () {
- return false;
-}
-
-Decorations menuShell () {
- return this;
-}
-
-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 releaseWidget () {
- if (menuBar != null) menuBar.releaseResources ();
- 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 ();
- image = null;
-}
-
-boolean restoreFocus () {
- if (savedFocus != null && savedFocus.isDisposed ()) savedFocus = null;
- boolean restored = savedFocus != null && savedFocus.setFocus ();
- savedFocus = null;
- /*
- * This code is intentionally commented. When no widget
- * has been given focus, some platforms give focus to the
- * default button. Motif doesn't do this.
- */
-// if (restored) return true;
-// if (defaultButton != null && !defaultButton.isDisposed ()) {
-// if (defaultButton.setFocus ()) return true;
-// }
-// return false;
- return restored;
-}
-
-/**
- * If the argument is not null, sets the receiver's default
- * button to the argument, and if the argument is null, sets
- * the receiver's default button to the first button which
- * was set as the receiver's default button (called the
- * <em>saved default button</em>). If no default button had
- * previously been set, or the saved default button was
- * disposed, the receiver's default button will be set to
- * null.
- *
- * @param the new default button
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_INVALID_ARGUMENT - if the button has been disposed</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
+public boolean getMinimized () {
+ checkWidget();
+ return minimized;
+}
+
+String getNameText () {
+ return getText ();
+}
+
+/**
+ * Returns the receiver's text, which is the string that the
+ * window manager will typically display as the receiver's
+ * <em>title</em>. If the text has not previously been set,
+ * returns an empty string.
+ *
+ * @return the text
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
*/
-public void setDefaultButton (Button button) {
- checkWidget();
- int buttonHandle = 0;
- if (button != null) {
- if (button.isDisposed ()) error (SWT.ERROR_INVALID_ARGUMENT);
- buttonHandle = button.handle;
- }
- saveDefault = defaultButton = button;
- OS.gtk_window_set_default (topHandle (), buttonHandle);
-}
-
-/**
- * Sets the receiver's image to the argument, which may
- * be null. The image is typically displayed by the window
- * manager when the instance is marked as iconified, and
- * may also be displayed somewhere in the trim when the
- * instance is in normal or maximized states.
- *
- * @param image the new image (or null)
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_INVALID_ARGUMENT - if the image has been disposed</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
+public String getText () {
+ checkWidget();
+ return text;
+}
+
+boolean isTabGroup () {
+ return true;
+}
+
+boolean isTabItem () {
+ return false;
+}
+
+Decorations menuShell () {
+ return this;
+}
+
+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 releaseWidget () {
+ if (menuBar != null) menuBar.releaseResources ();
+ 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 ();
+ image = null;
+}
+
+boolean restoreFocus () {
+ if (savedFocus != null && savedFocus.isDisposed ()) savedFocus = null;
+ boolean restored = savedFocus != null && savedFocus.setFocus ();
+ savedFocus = null;
+ /*
+ * This code is intentionally commented. When no widget
+ * has been given focus, some platforms give focus to the
+ * default button. Motif doesn't do this.
+ */
+// if (restored) return true;
+// if (defaultButton != null && !defaultButton.isDisposed ()) {
+// if (defaultButton.setFocus ()) return true;
+// }
+// return false;
+ return restored;
+}
+
+/**
+ * If the argument is not null, sets the receiver's default
+ * button to the argument, and if the argument is null, sets
+ * the receiver's default button to the first button which
+ * was set as the receiver's default button (called the
+ * <em>saved default button</em>). If no default button had
+ * previously been set, or the saved default button was
+ * disposed, the receiver's default button will be set to
+ * null.
+ *
+ * @param the new default button
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_INVALID_ARGUMENT - if the button has been disposed</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
*/
-public void setImage (Image image) {
- checkWidget();
- this.image = image;
- int pixmap = 0, mask = 0;
- if (image != null) {
- pixmap = image.pixmap;
- mask = image.mask;
- }
- int window = OS.GTK_WIDGET_WINDOW(topHandle());
- OS.gdk_window_set_icon (window, 0, pixmap, mask);
-}
-
-/**
- * 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 setDefaultButton (Button button) {
+ checkWidget();
+ int buttonHandle = 0;
+ if (button != null) {
+ if (button.isDisposed ()) error (SWT.ERROR_INVALID_ARGUMENT);
+ buttonHandle = button.handle;
+ }
+ saveDefault = defaultButton = button;
+ OS.gtk_window_set_default (topHandle (), buttonHandle);
+}
+
+/**
+ * Sets the receiver's image to the argument, which may
+ * be null. The image is typically displayed by the window
+ * manager when the instance is marked as iconified, and
+ * may also be displayed somewhere in the trim when the
+ * instance is in normal or maximized states.
+ *
+ * @param image the new image (or null)
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_INVALID_ARGUMENT - if the image has been disposed</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
*/
-public void setMaximized (boolean maximized) {
- checkWidget();
- this.maximized = maximized;
-}
-
-/**
- * Sets the receiver's menu bar to the argument, which
- * may be null.
- *
- * @param menu the new menu bar
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_INVALID_ARGUMENT - if the menu has been disposed</li>
- * <li>ERROR_INVALID_PARENT - if the menu is not in the same widget tree</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
+public void setImage (Image image) {
+ checkWidget();
+ this.image = image;
+ int pixmap = 0, mask = 0;
+ if (image != null) {
+ pixmap = image.pixmap;
+ mask = image.mask;
+ }
+ int window = OS.GTK_WIDGET_WINDOW(topHandle());
+ OS.gdk_window_set_icon (window, 0, pixmap, mask);
+}
+
+/**
+ * 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 setMenuBar (Menu menu) {
- checkWidget();
- if (menuBar == menu) return;
- if (menu != null) {
- if ((menu.style & SWT.BAR) == 0) error (SWT.ERROR_MENU_NOT_BAR);
- if (menu.parent != this) error (SWT.ERROR_INVALID_PARENT);
- }
- menuBar = menu;
-}
-
-/**
- * Sets the minimized stated of the receiver.
- * If the argument is <code>true</code> causes the receiver
- * to switch to the minimized state, and if the argument is
- * <code>false</code> and the receiver was previously minimized,
- * causes the receiver to switch back to either the maximized
- * or normal states.
- * <p>
- * Note: The result of intermixing calls to<code>setMaximized(true)</code>
- * and <code>setMinimized(true)</code> will vary by platform. Typically,
- * the behavior will match the platform user's expectations, but not
- * always. This should be avoided if possible.
- * </p>
- *
- * @param 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 setMaximized (boolean maximized) {
+ checkWidget();
+ this.maximized = maximized;
+}
+
+/**
+ * Sets the receiver's menu bar to the argument, which
+ * may be null.
+ *
+ * @param menu the new menu bar
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_INVALID_ARGUMENT - if the menu has been disposed</li>
+ * <li>ERROR_INVALID_PARENT - if the menu is not in the same widget tree</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
*/
-public void setMinimized (boolean minimized) {
- checkWidget();
- this.minimized = minimized;
-}
-
-void setSavedFocus (Control control) {
- if (this == control) return;
- savedFocus = control;
-}
-
-/**
- * Sets the receiver's text, which is the string that the
- * window manager will typically display as the receiver's
- * <em>title</em>, to the argument, which 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 setMenuBar (Menu menu) {
+ checkWidget();
+ if (menuBar == menu) return;
+ if (menu != null) {
+ if ((menu.style & SWT.BAR) == 0) error (SWT.ERROR_MENU_NOT_BAR);
+ if (menu.parent != this) error (SWT.ERROR_INVALID_PARENT);
+ }
+ menuBar = menu;
+}
+
+/**
+ * Sets the minimized stated of the receiver.
+ * If the argument is <code>true</code> causes the receiver
+ * to switch to the minimized state, and if the argument is
+ * <code>false</code> and the receiver was previously minimized,
+ * causes the receiver to switch back to either the maximized
+ * or normal states.
+ * <p>
+ * Note: The result of intermixing calls to<code>setMaximized(true)</code>
+ * and <code>setMinimized(true)</code> will vary by platform. Typically,
+ * the behavior will match the platform user's expectations, but not
+ * always. This should be avoided if possible.
+ * </p>
+ *
+ * @param 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 setText (String string) {
- checkWidget();
- if (string == null) error (SWT.ERROR_NULL_ARGUMENT);
- text = string;
-}
-
-boolean traverseItem (boolean next) {
- return false;
-}
-
-boolean traverseReturn () {
- Button button = defaultButton != null ? defaultButton: saveDefault;
- if (button == null || button.isDisposed ()) return false;
- /*
- * Bug in GTK. When a default button that is disabled is
- * activated using the Enter key, GTK GP's. The fix is to
- * detect this case and stop GTK from processing the Enter
- * key.
- */
- if (!button.isVisible () || !button.isEnabled ()) return true;
- int shellHandle = _getShell ().topHandle ();
- return OS.gtk_window_activate_default (shellHandle);
-}
-
-}
+public void setMinimized (boolean minimized) {
+ checkWidget();
+ this.minimized = minimized;
+}
+
+void setSavedFocus (Control control) {
+ if (this == control) return;
+ savedFocus = control;
+}
+
+/**
+ * Sets the receiver's text, which is the string that the
+ * window manager will typically display as the receiver's
+ * <em>title</em>, to the argument, which 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);
+ text = string;
+}
+
+boolean traverseItem (boolean next) {
+ return false;
+}
+
+boolean traverseReturn () {
+ Button button = defaultButton != null ? defaultButton: saveDefault;
+ if (button == null || button.isDisposed ()) return false;
+ /*
+ * Bug in GTK. When a default button that is disabled is
+ * activated using the Enter key, GTK GP's. The fix is to
+ * detect this case and stop GTK from processing the Enter
+ * key.
+ */
+ if (!button.isVisible () || !button.isEnabled ()) return true;
+ int shellHandle = _getShell ().topHandle ();
+ return OS.gtk_window_activate_default (shellHandle);
+}
+
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/DirectoryDialog.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/DirectoryDialog.java
index 23ae7714ec..d9dd4ac4d3 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/DirectoryDialog.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/DirectoryDialog.java
@@ -1,186 +1,186 @@
-package org.eclipse.swt.widgets;
-
-/*
+package org.eclipse.swt.widgets;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-import org.eclipse.swt.*;
-import org.eclipse.swt.internal.*;
-import org.eclipse.swt.internal.gtk.*;
-
-/**
- * Instances of this class allow the user to navigate
- * the file system and select a directory.
- * <p>
- * IMPORTANT: This class is intended to be subclassed <em>only</em>
- * within the SWT implementation.
- * </p>
+ * http://www.eclipse.org/legal/cpl-v10.html
*/
-public class DirectoryDialog extends Dialog {
- String message = "", filterPath = "";
-
-/**
- * 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>
+
+import org.eclipse.swt.*;
+import org.eclipse.swt.internal.*;
+import org.eclipse.swt.internal.gtk.*;
+
+/**
+ * Instances of this class allow the user to navigate
+ * the file system and select a directory.
+ * <p>
+ * IMPORTANT: This class is intended to be subclassed <em>only</em>
+ * within the SWT implementation.
+ * </p>
*/
-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
- * lists the style constants that are applicable to the class.
- * Style bits are also inherited from superclasses.
- * </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 class DirectoryDialog extends Dialog {
+ String message = "", filterPath = "";
+
+/**
+ * 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, int style) {
- super (parent, style);
- checkSubclass ();
-}
-/**
- * Returns the path which the dialog will use to filter
- * the directories it shows.
- *
- * @return the filter path
+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
+ * lists the style constants that are applicable to the class.
+ * Style bits are also inherited from superclasses.
+ * </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 String getFilterPath () {
- return filterPath;
-}
-/**
- * Returns the dialog's message, which is a description of
- * the purpose for which it was opened. This message will be
- * visible on the dialog while it is open.
- *
- * @return the message
+public DirectoryDialog (Shell parent, int style) {
+ super (parent, style);
+ checkSubclass ();
+}
+/**
+ * Returns the path which the dialog will use to filter
+ * the directories it shows.
+ *
+ * @return the filter path
*/
-public String getMessage () {
- return message;
-}
-/**
- * Makes the dialog visible and brings it to the front
- * of the display.
- *
- * @return a string describing the absolute path of the selected directory,
- * or null if the dialog was cancelled or an error occurred
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the dialog has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the dialog</li>
- * </ul>
+public String getFilterPath () {
+ return filterPath;
+}
+/**
+ * Returns the dialog's message, which is a description of
+ * the purpose for which it was opened. This message will be
+ * visible on the dialog while it is open.
+ *
+ * @return the message
*/
-public String open () {
- byte [] titleBytes = Converter.wcsToMbcs (null, title, true);
- int handle = OS.gtk_file_selection_new (titleBytes);
- if (parent != null) {
- OS.gtk_window_set_transient_for (handle, parent.topHandle ());
- }
- String answer = null;
- if (filterPath != null) {
- int length = filterPath.length ();
- char [] buffer = new char [length + 1];
- filterPath.getChars (0, length, buffer, 0);
- int utf8Ptr = OS.g_utf16_to_utf8 (buffer, -1, null, null, null);
- int fileNamePtr = OS.g_filename_from_utf8 (utf8Ptr, -1, null, null, null);
- OS.gtk_file_selection_set_filename (handle, fileNamePtr);
- OS.g_free (utf8Ptr);
- OS.g_free (fileNamePtr);
- }
- GtkFileSelection selection = new GtkFileSelection ();
- OS.memmove (selection, handle);
- OS.gtk_file_selection_hide_fileop_buttons (handle);
- int fileListParent = OS.gtk_widget_get_parent (selection.file_list);
- OS.gtk_widget_hide (selection.file_list);
- OS.gtk_widget_hide (fileListParent);
- int response = OS.gtk_dialog_run (handle);
- if (response == OS.GTK_RESPONSE_OK) {
- int fileNamePtr = OS.gtk_file_selection_get_filename (handle);
- int utf8Ptr = OS.g_filename_to_utf8 (fileNamePtr, -1, null, null, null);
- int [] items_written = new int [1];
- int utf16Ptr = OS.g_utf8_to_utf16 (utf8Ptr, -1, null, items_written, null);
- int length = items_written [0];
- char [] buffer = new char [length];
- OS.memmove (buffer, utf16Ptr, length * 2);
- String osAnswer = new String (buffer);
- OS.g_free (utf16Ptr);
- OS.g_free (utf8Ptr);
- if (osAnswer != null) {
- answer = osAnswer;
- // add trailing separator if not already present
- char separator = System.getProperty ("file.separator").charAt (0);
- int separatorIndex = answer.lastIndexOf (separator);
- if (separatorIndex != answer.length () - 1) answer += separator;
- }
- }
- OS.gtk_widget_destroy (handle);
- return answer;
-}
-/**
- * Sets the path which the dialog will use to filter
- * the directories it shows to the argument, which may be
- * null.
- *
- * @param string the filter path
+public String getMessage () {
+ return message;
+}
+/**
+ * Makes the dialog visible and brings it to the front
+ * of the display.
+ *
+ * @return a string describing the absolute path of the selected directory,
+ * or null if the dialog was cancelled or an error occurred
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the dialog has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the dialog</li>
+ * </ul>
*/
-public void setFilterPath (String string) {
- filterPath = string;
-}
-/**
- * Sets the dialog's message, which is a description of
- * the purpose for which it was opened. This message will be
- * visible on the dialog while it is open.
- *
- * @param string the message
+public String open () {
+ byte [] titleBytes = Converter.wcsToMbcs (null, title, true);
+ int handle = OS.gtk_file_selection_new (titleBytes);
+ if (parent != null) {
+ OS.gtk_window_set_transient_for (handle, parent.topHandle ());
+ }
+ String answer = null;
+ if (filterPath != null) {
+ int length = filterPath.length ();
+ char [] buffer = new char [length + 1];
+ filterPath.getChars (0, length, buffer, 0);
+ int utf8Ptr = OS.g_utf16_to_utf8 (buffer, -1, null, null, null);
+ int fileNamePtr = OS.g_filename_from_utf8 (utf8Ptr, -1, null, null, null);
+ OS.gtk_file_selection_set_filename (handle, fileNamePtr);
+ OS.g_free (utf8Ptr);
+ OS.g_free (fileNamePtr);
+ }
+ GtkFileSelection selection = new GtkFileSelection ();
+ OS.memmove (selection, handle);
+ OS.gtk_file_selection_hide_fileop_buttons (handle);
+ int fileListParent = OS.gtk_widget_get_parent (selection.file_list);
+ OS.gtk_widget_hide (selection.file_list);
+ OS.gtk_widget_hide (fileListParent);
+ int response = OS.gtk_dialog_run (handle);
+ if (response == OS.GTK_RESPONSE_OK) {
+ int fileNamePtr = OS.gtk_file_selection_get_filename (handle);
+ int utf8Ptr = OS.g_filename_to_utf8 (fileNamePtr, -1, null, null, null);
+ int [] items_written = new int [1];
+ int utf16Ptr = OS.g_utf8_to_utf16 (utf8Ptr, -1, null, items_written, null);
+ int length = items_written [0];
+ char [] buffer = new char [length];
+ OS.memmove (buffer, utf16Ptr, length * 2);
+ String osAnswer = new String (buffer);
+ OS.g_free (utf16Ptr);
+ OS.g_free (utf8Ptr);
+ if (osAnswer != null) {
+ answer = osAnswer;
+ // add trailing separator if not already present
+ char separator = System.getProperty ("file.separator").charAt (0);
+ int separatorIndex = answer.lastIndexOf (separator);
+ if (separatorIndex != answer.length () - 1) answer += separator;
+ }
+ }
+ OS.gtk_widget_destroy (handle);
+ return answer;
+}
+/**
+ * Sets the path which the dialog will use to filter
+ * the directories it shows to the argument, which may be
+ * null.
+ *
+ * @param string the filter path
*/
-public void setMessage (String string) {
- /*
- * The native Gtk file selection dialog does not support message
- * strings other than the dialog title. However, we maintain the set
- * message so at least the application programs get back the same string.
- */
- message = string;
-}
-}
+public void setFilterPath (String string) {
+ filterPath = string;
+}
+/**
+ * Sets the dialog's message, which is a description of
+ * the purpose for which it was opened. This message will be
+ * visible on the dialog while it is open.
+ *
+ * @param string the message
+ */
+public void setMessage (String string) {
+ /*
+ * The native Gtk file selection dialog does not support message
+ * strings other than the dialog title. However, we maintain the set
+ * message so at least the application programs get back the same string.
+ */
+ message = string;
+}
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Display.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Display.java
index 51b3d8b44c..7f883f95f8 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Display.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Display.java
@@ -12,80 +12,80 @@ import org.eclipse.swt.internal.*;
import org.eclipse.swt.internal.gtk.*;
import org.eclipse.swt.graphics.*;
-/**
- * Instances of this class are responsible for managing the
- * connection between SWT and the underlying operating
- * system. Their most important function is to implement
- * the SWT event loop in terms of the platform event model.
- * They also provide various methods for accessing information
- * about the operating system, and have overall control over
- * the operating system resources which SWT allocates.
- * <p>
- * Applications which are built with SWT will <em>almost always</em>
- * require only a single display. In particular, some platforms
- * which SWT supports will not allow more than one <em>active</em>
- * display. In other words, some platforms do not support
- * creating a new display if one already exists that has not been
- * sent the <code>dispose()</code> message.
- * <p>
- * In SWT, the thread which creates a <code>Display</code>
- * instance is distinguished as the <em>user-interface thread</em>
- * for that display.
- * </p>
- * The user-interface thread for a particular display has the
- * following special attributes:
- * <ul>
- * <li>
- * The event loop for that display must be run from the thread.
- * </li>
- * <li>
- * Some SWT API methods (notably, most of the public methods in
- * <code>Widget</code> and its subclasses), may only be called
- * from the thread. (To support multi-threaded user-interface
- * applications, class <code>Display</code> provides inter-thread
- * communication methods which allow threads other than the
- * user-interface thread to request that it perform operations
- * on their behalf.)
- * </li>
- * <li>
- * The thread is not allowed to construct other
- * <code>Display</code>s until that display has been disposed.
- * (Note that, this is in addition to the restriction mentioned
- * above concerning platform support for multiple displays. Thus,
- * the only way to have multiple simultaneously active displays,
- * even on platforms which support it, is to have multiple threads.)
- * </li>
- * </ul>
- * Enforcing these attributes allows SWT to be implemented directly
- * on the underlying operating system's event model. This has
- * numerous benefits including smaller footprint, better use of
- * resources, safer memory management, clearer program logic,
- * better performance, and fewer overall operating system threads
- * required. The down side however, is that care must be taken
- * (only) when constructing multi-threaded applications to use the
- * inter-thread communication mechanisms which this class provides
- * when required.
- * </p><p>
- * All SWT API methods which may only be called from the user-interface
- * thread are distinguished in their documentation by indicating that
- * they throw the "<code>ERROR_THREAD_INVALID_ACCESS</code>"
- * SWT exception.
- * </p>
- * <dl>
- * <dt><b>Styles:</b></dt>
- * <dd>(none)</dd>
- * <dt><b>Events:</b></dt>
- * <dd>Close, Dispose</dd>
- * </dl>
- * <p>
- * IMPORTANT: This class is <em>not</em> intended to be subclassed.
- * </p>
- * @see #syncExec
- * @see #asyncExec
- * @see #wake
- * @see #readAndDispatch
- * @see #sleep
- * @see #dispose
+/**
+ * Instances of this class are responsible for managing the
+ * connection between SWT and the underlying operating
+ * system. Their most important function is to implement
+ * the SWT event loop in terms of the platform event model.
+ * They also provide various methods for accessing information
+ * about the operating system, and have overall control over
+ * the operating system resources which SWT allocates.
+ * <p>
+ * Applications which are built with SWT will <em>almost always</em>
+ * require only a single display. In particular, some platforms
+ * which SWT supports will not allow more than one <em>active</em>
+ * display. In other words, some platforms do not support
+ * creating a new display if one already exists that has not been
+ * sent the <code>dispose()</code> message.
+ * <p>
+ * In SWT, the thread which creates a <code>Display</code>
+ * instance is distinguished as the <em>user-interface thread</em>
+ * for that display.
+ * </p>
+ * The user-interface thread for a particular display has the
+ * following special attributes:
+ * <ul>
+ * <li>
+ * The event loop for that display must be run from the thread.
+ * </li>
+ * <li>
+ * Some SWT API methods (notably, most of the public methods in
+ * <code>Widget</code> and its subclasses), may only be called
+ * from the thread. (To support multi-threaded user-interface
+ * applications, class <code>Display</code> provides inter-thread
+ * communication methods which allow threads other than the
+ * user-interface thread to request that it perform operations
+ * on their behalf.)
+ * </li>
+ * <li>
+ * The thread is not allowed to construct other
+ * <code>Display</code>s until that display has been disposed.
+ * (Note that, this is in addition to the restriction mentioned
+ * above concerning platform support for multiple displays. Thus,
+ * the only way to have multiple simultaneously active displays,
+ * even on platforms which support it, is to have multiple threads.)
+ * </li>
+ * </ul>
+ * Enforcing these attributes allows SWT to be implemented directly
+ * on the underlying operating system's event model. This has
+ * numerous benefits including smaller footprint, better use of
+ * resources, safer memory management, clearer program logic,
+ * better performance, and fewer overall operating system threads
+ * required. The down side however, is that care must be taken
+ * (only) when constructing multi-threaded applications to use the
+ * inter-thread communication mechanisms which this class provides
+ * when required.
+ * </p><p>
+ * All SWT API methods which may only be called from the user-interface
+ * thread are distinguished in their documentation by indicating that
+ * they throw the "<code>ERROR_THREAD_INVALID_ACCESS</code>"
+ * SWT exception.
+ * </p>
+ * <dl>
+ * <dt><b>Styles:</b></dt>
+ * <dd>(none)</dd>
+ * <dt><b>Events:</b></dt>
+ * <dd>Close, Dispose</dd>
+ * </dl>
+ * <p>
+ * IMPORTANT: This class is <em>not</em> intended to be subclassed.
+ * </p>
+ * @see #syncExec
+ * @see #asyncExec
+ * @see #wake
+ * @see #readAndDispatch
+ * @see #sleep
+ * @see #dispose
*/
public class Display extends Device {
@@ -272,24 +272,24 @@ static void setDevice (Device device) {
CurrentDevice = device;
}
-/**
- * Constructs a new instance of this class.
- * <p>
- * Note: The resulting display is marked as the <em>current</em>
- * display. If this is the first display which has been
- * constructed since the application started, it is also
- * marked as the <em>default</em> display.
- * </p>
- *
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS - if 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
+/**
+ * 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);
@@ -328,26 +328,26 @@ void addFilter (int eventType, Listener listener) {
filterTable.hook (eventType, listener);
}
-/**
- * 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 display, the listener is notified by
- * sending it the <code>handleEvent()</code> message.
- *
- * @param eventType the type of event to listen for
- * @param listener the listener which should be notified when the event occurs
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see Listener
- * @see #removeListener
- *
- * @since 2.0
+/**
+ * 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 display, the listener is notified by
+ * sending it the <code>handleEvent()</code> message.
+ *
+ * @param eventType the type of event to listen for
+ * @param listener the listener which should be notified when the event occurs
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see Listener
+ * @see #removeListener
+ *
+ * @since 2.0
*/
public void addListener (int eventType, Listener listener) {
checkDevice ();
@@ -362,25 +362,25 @@ void addMouseHoverTimeout (int handle) {
mouseHoverHandle = handle;
}
-/**
- * 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
+/**
+ * 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).
+/**
+ * Causes the system hardware to emit a short sound
+ * (if it supports this capability).
*/
public void beep () {
if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
@@ -405,17 +405,17 @@ protected void checkSubclass () {
if (!isValidClass (getClass ())) error (SWT.ERROR_INVALID_SUBCLASS);
}
-/**
- * Requests that the connection between SWT and the underlying
- * operating system be closed.
- *
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see #dispose
- *
- * @since 2.0
+/**
+ * Requests that the connection between SWT and the underlying
+ * operating system be closed.
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see #dispose
+ *
+ * @since 2.0
*/
public void close () {
checkDevice ();
@@ -480,13 +480,13 @@ protected void destroy () {
void destroyDisplay () {
}
-/**
- * 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
+/**
+ * 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++) {
@@ -498,12 +498,12 @@ public static synchronized Display findDisplay (Thread thread) {
return null;
}
-/**
- * Causes the <code>run()</code> method of the runnable to
- * be invoked by the user-interface thread just before the
- * receiver is disposed.
- *
- * @param runnable code to run at dispose time.
+/**
+ * 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 ();
@@ -577,34 +577,34 @@ int eventProc (int event, int data) {
return 0;
}
-/**
- * Given the operating system handle for a widget, returns
- * the instance of the <code>Widget</code> subclass which
- * represents it in the currently running application, if
- * such exists, or null if no matching widget can be found.
- *
- * @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>
+/**
+ * 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);
}
-/**
- * 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>
+/**
+ * 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 ();
@@ -615,26 +615,26 @@ public Shell getActiveShell () {
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>
+/**
+ * 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 ();
return new Rectangle (0, 0, OS.gdk_screen_width (), OS.gdk_screen_height ());
}
-/**
- * Returns the display which the currently running thread is
- * the user-interface thread for, or null if the currently
- * running thread is not a user-interface thread for any display.
- *
- * @return the current display
+/**
+ * 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 () {
Thread current = Thread.currentThread ();
@@ -645,16 +645,16 @@ public static synchronized Display getCurrent () {
return null;
}
-/**
- * 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>
+/**
+ * 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();
@@ -685,15 +685,15 @@ boolean filters (int eventType) {
return filterTable.hooks (eventType);
}
-/**
- * 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>
+/**
+ * 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 ();
@@ -702,29 +702,29 @@ public Point getCursorLocation () {
return new Point (x [0], y [0]);
}
-/**
- * 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
+/**
+ * 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 ();
@@ -736,27 +736,27 @@ public Object getData (String key) {
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
+/**
+ * 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 ();
@@ -782,12 +782,12 @@ public Point getDPI () {
return new Point (dpi, dpi);
}
-/**
- * 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
+/**
+ * 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 ();
@@ -805,33 +805,33 @@ public int getDismissalAlignment () {
return SWT.RIGHT;
}
-/**
- * Returns the longest duration, in milliseconds, between
- * two mouse button clicks that will be considered a
- * <em>double click</em> by the underlying operating system.
- *
- * @return the double click time
- *
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
+/**
+ * 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 DOUBLE_CLICK_TIME;
}
-/**
- * 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>
+/**
+ * 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 ();
@@ -857,16 +857,16 @@ public int getDepth () {
return visual.depth;
}
-/**
- * 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>
+/**
+ * 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 ();
@@ -877,15 +877,15 @@ int getLastEventTime () {
return OS.gtk_get_current_event_time ();
}
-/**
- * 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>
+/**
+ * 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 ();
@@ -908,39 +908,39 @@ public Shell [] getShells () {
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
+/**
+ * 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
+/**
+ * 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 ();
@@ -1135,35 +1135,35 @@ void initializeSystemResources () {
OS.gtk_widget_destroy (shellHandle);
}
-/**
- * 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>
+/**
+ * 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 ();
return Font.gtk_new (this, defaultFont);
}
-/**
- * Returns the user-interface thread for the receiver.
- *
- * @return the receiver's user-interface thread
+/**
+ * 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);
@@ -1214,39 +1214,39 @@ void initializeCallbacks () {
if (treeSelectionProc == 0) error (SWT.ERROR_NO_MORE_CALLBACKS);
}
-/**
- * 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
+/**
+ * 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 gdkGC, GCData data) {
OS.g_object_unref (gdkGC);
}
-/**
- * Invokes platform specific functionality to allocate a new GC handle.
- * <p>
- * <b>IMPORTANT:</b> This method is <em>not</em> part of the public
- * API for <code>Display</code>. It is marked public only so that it
- * can be shared within the packages provided by SWT. It is not
- * available on all platforms, and should never be called from
- * application code.
- * </p>
- *
- * @param data the platform specific GC data
- * @return the platform specific GC handle
- *
- * @private
+/**
+ * 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) {
if (isDisposed()) SWT.error(SWT.ERROR_DEVICE_DISPOSED);
@@ -1293,27 +1293,27 @@ void postEvent (Event event) {
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
+/**
+ * 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 ();
@@ -1447,24 +1447,24 @@ void removeFilter (int eventType, Listener listener) {
if (filterTable.size () == 0) filterTable = 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_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see Listener
- * @see #addListener
- *
- * @since 2.0
+/**
+ * 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_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see Listener
+ * @see #addListener
+ *
+ * @since 2.0
*/
public void removeListener (int eventType, Listener listener) {
checkDevice ();
@@ -1524,12 +1524,12 @@ boolean runDeferredEvents () {
return true;
}
-/**
- * On platforms which support it, sets the application name
- * to be the argument. On Motif, for example, this can be used
- * to set the name used for resource lookup.
- *
- * @param name the new app name
+/**
+ * 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) {
APP_NAME = name;
@@ -1540,17 +1540,17 @@ public void setCursorLocation (int x, int y) {
/* This is not supported on GTK */
}
-/**
- * Sets the location of the on-screen pointer relative to the top left corner
- * of the screen. <b>Note: It is typically considered bad practice for a
- * program to move the on-screen pointer location.</b>
- *
- * @param point new position
- * @since 2.0
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * <li>ERROR_NULL_ARGUMENT - if the point is null
- * </ul>
+/**
+ * Sets the location of the on-screen pointer relative to the top left corner
+ * of the screen. <b>Note: It is typically considered bad practice for a
+ * program to move the on-screen pointer location.</b>
+ *
+ * @param point new position
+ * @since 2.0
+ * @exception SWTException <ul>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * <li>ERROR_NULL_ARGUMENT - if the point is null
+ * </ul>
*/
public void setCursorLocation (Point point) {
checkDevice ();
@@ -1558,29 +1558,29 @@ public void setCursorLocation (Point point) {
setCursorLocation (point.x, point.y);
}
-/**
- * Sets the application defined property of the receiver
- * with the specified name to the given argument.
- * <p>
- * Applications may have associated arbitrary objects with the
- * receiver in this fashion. If the objects stored in the
- * properties need to be notified when the display is disposed
- * of, it is the application's responsibility provide a
- * <code>disposeExec()</code> handler which does so.
- * </p>
- *
- * @param key the name of the property
- * @param value the new value for the property
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the key is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see #setData
- * @see #disposeExec
+/**
+ * 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 ();
@@ -1630,45 +1630,45 @@ public void setData (String key, Object value) {
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
+/**
+ * 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;
}
-/**
- * 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>
+/**
+ * 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 ();
@@ -1712,18 +1712,18 @@ void showIMWindow (Control control) {
if (pangoAttrs [0] != 0) OS.pango_attr_list_unref (pangoAttrs [0]);
}
-/**
- * Causes the user-interface thread to <em>sleep</em> (that is,
- * to be put in a state where it does not consume CPU cycles)
- * until an event is received or it is otherwise awakened.
- *
- * @return <code>true</code> if an event requiring dispatching was placed on the queue.
- *
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see #wake
+/**
+ * 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 ();
@@ -1734,23 +1734,23 @@ public boolean sleep () {
return true;
}
-/**
- * Causes the <code>run()</code> method of the runnable to
- * be invoked by the user-interface thread after the specified
- * number of milliseconds have elapsed. If milliseconds is less
- * than zero, the runnable is not executed.
- *
- * @param milliseconds the delay before running the runnable
- * @param runnable code to run on the user-interface thread
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the runnable is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see #asyncExec
+/**
+ * Causes the <code>run()</code> method of the runnable to
+ * be invoked by the user-interface thread after the specified
+ * number of milliseconds have elapsed. If milliseconds is less
+ * than zero, the runnable is not executed.
+ *
+ * @param milliseconds the delay before running the runnable
+ * @param runnable code to run on the user-interface thread
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if the runnable is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see #asyncExec
*/
public void timerExec (int milliseconds, Runnable runnable) {
checkDevice ();
@@ -1843,19 +1843,19 @@ void setCurrentCaret (Caret caret) {
caretId = OS.gtk_timeout_add (blinkRate, caretProc, 0);
}
-/**
- * Causes the <code>run()</code> method of the runnable to
- * be invoked by the user-interface thread at the next
- * reasonable opportunity. The thread which calls this method
- * is suspended until the runnable completes.
- *
- * @param runnable code to run on the user-interface thread.
- *
- * @exception SWTException <ul>
- * <li>ERROR_FAILED_EXEC - if an exception occured when executing the runnable</li>
- * </ul>
- *
- * @see #asyncExec
+/**
+ * Causes the <code>run()</code> method of the runnable to
+ * be invoked by the user-interface thread at the next
+ * reasonable opportunity. The thread which calls this method
+ * is suspended until the runnable completes.
+ *
+ * @param runnable code to run on the user-interface thread.
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_FAILED_EXEC - if an exception occured when executing the runnable</li>
+ * </ul>
+ *
+ * @see #asyncExec
*/
public void syncExec (Runnable runnable) {
if (isDisposed ()) error (SWT.ERROR_DEVICE_DISPOSED);
@@ -1876,11 +1876,11 @@ static int untranslateKey (int key) {
return 0;
}
-/**
- * Forces all outstanding paint requests for the display
- * to be processed before this method returns.
- *
- * @see Control#update
+/**
+ * Forces all outstanding paint requests for the display
+ * to be processed before this method returns.
+ *
+ * @see Control#update
*/
public void update () {
checkDevice ();
@@ -1891,12 +1891,12 @@ public void 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
+/**
+ * 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 () {
// NOT IMPLEMENTED - need to wake up the event loop
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/FileDialog.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/FileDialog.java
index 1ec06e658a..ac02ff869f 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/FileDialog.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/FileDialog.java
@@ -1,307 +1,307 @@
-package org.eclipse.swt.widgets;
-
-/*
+package org.eclipse.swt.widgets;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-import org.eclipse.swt.*;
-import org.eclipse.swt.internal.*;
-import org.eclipse.swt.internal.gtk.*;
-
-/**
- * Instances of this class allow the user to navigate
- * the file system and select or enter a file name.
- * <dl>
- * <dt><b>Styles:</b></dt>
- * <dd>SAVE, OPEN, MULTI</dd>
- * <dt><b>Events:</b></dt>
- * <dd>(none)</dd>
- * </dl>
- * <p>
- * IMPORTANT: This class is intended to be subclassed <em>only</em>
- * within the SWT implementation.
- * </p>
+ * http://www.eclipse.org/legal/cpl-v10.html
*/
-public class FileDialog extends Dialog {
- String [] filterNames = new String [0];
- String [] filterExtensions = new String [0];
- String filterPath = "";
- String fileName = "";
- String[] fileNames;
- String fullPath = "";
- int handle;
- static final char SEPARATOR = System.getProperty ("file.separator").charAt (0);
-
-/**
- * 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>
+
+import org.eclipse.swt.*;
+import org.eclipse.swt.internal.*;
+import org.eclipse.swt.internal.gtk.*;
+
+/**
+ * Instances of this class allow the user to navigate
+ * the file system and select or enter a file name.
+ * <dl>
+ * <dt><b>Styles:</b></dt>
+ * <dd>SAVE, OPEN, MULTI</dd>
+ * <dt><b>Events:</b></dt>
+ * <dd>(none)</dd>
+ * </dl>
+ * <p>
+ * IMPORTANT: This class is intended to be subclassed <em>only</em>
+ * within the SWT implementation.
+ * </p>
*/
-public FileDialog (Shell parent) {
- this (parent, SWT.PRIMARY_MODAL);
-}
-/**
- * Constructs a new instance of this class given its parent
- * and a style value describing its behavior and appearance.
- * <p>
- * The style value is either one of the style constants defined in
- * class <code>SWT</code> which is applicable to instances of this
- * class, or must be built by <em>bitwise OR</em>'ing together
- * (that is, using the <code>int</code> "|" operator) two or more
- * of those <code>SWT</code> style constants. The class description
- * lists the style constants that are applicable to the class.
- * Style bits are also inherited from superclasses.
- * </p>
- * 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 class FileDialog extends Dialog {
+ String [] filterNames = new String [0];
+ String [] filterExtensions = new String [0];
+ String filterPath = "";
+ String fileName = "";
+ String[] fileNames;
+ String fullPath = "";
+ int handle;
+ static final char SEPARATOR = System.getProperty ("file.separator").charAt (0);
+
+/**
+ * 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 FileDialog (Shell parent, int style) {
- super (parent, style);
- checkSubclass ();
-}
-/**
- * Returns the path of the first file that was
- * selected in the dialog relative to the filter path
- *
- * @return the relative path of the file
+public FileDialog (Shell parent) {
+ this (parent, SWT.PRIMARY_MODAL);
+}
+/**
+ * Constructs a new instance of this class given its parent
+ * and a style value describing its behavior and appearance.
+ * <p>
+ * The style value is either one of the style constants defined in
+ * class <code>SWT</code> which is applicable to instances of this
+ * class, or must be built by <em>bitwise OR</em>'ing together
+ * (that is, using the <code>int</code> "|" operator) two or more
+ * of those <code>SWT</code> style constants. The class description
+ * lists the style constants that are applicable to the class.
+ * Style bits are also inherited from superclasses.
+ * </p>
+ * 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 String getFileName () {
- return fileName;
-}
-/**
- * Returns the paths of all files that were selected
- * in the dialog relative to the filter path, or null
- * if none are available.
- *
- * @return the relative paths of the files
+public FileDialog (Shell parent, int style) {
+ super (parent, style);
+ checkSubclass ();
+}
+/**
+ * Returns the path of the first file that was
+ * selected in the dialog relative to the filter path
+ *
+ * @return the relative path of the file
*/
-public String [] getFileNames () {
- return fileNames;
-}
-/**
- * Returns the file extensions which the dialog will
- * use to filter the files it shows.
- *
- * @return the file extensions filter
+public String getFileName () {
+ return fileName;
+}
+/**
+ * Returns the paths of all files that were selected
+ * in the dialog relative to the filter path, or null
+ * if none are available.
+ *
+ * @return the relative paths of the files
*/
-public String [] getFilterExtensions () {
- return filterExtensions;
-}
-/**
- * Returns the file names which the dialog will
- * use to filter the files it shows.
- *
- * @return the file name filter
+public String [] getFileNames () {
+ return fileNames;
+}
+/**
+ * Returns the file extensions which the dialog will
+ * use to filter the files it shows.
+ *
+ * @return the file extensions filter
*/
-public String [] getFilterNames () {
- return filterNames;
-}
-/**
- * Returns the directory path that the dialog will use.
- * File names in this path will appear in the dialog,
- * filtered according to the filter extensions.
- *
- * @return the directory path string
- *
- * @see #setFilterExtensions
+public String [] getFilterExtensions () {
+ return filterExtensions;
+}
+/**
+ * Returns the file names which the dialog will
+ * use to filter the files it shows.
+ *
+ * @return the file name filter
*/
-public String getFilterPath () {
- return filterPath;
-}
-/**
- * Makes the dialog visible and brings it to the front
- * of the display.
- *
- * @return a string describing the absolute path of the first selected file,
- * or null if the dialog was cancelled or an error occurred
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the dialog has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the dialog</li>
- * </ul>
+public String [] getFilterNames () {
+ return filterNames;
+}
+/**
+ * Returns the directory path that the dialog will use.
+ * File names in this path will appear in the dialog,
+ * filtered according to the filter extensions.
+ *
+ * @return the directory path string
+ *
+ * @see #setFilterExtensions
*/
-public String open () {
- byte [] titleBytes = Converter.wcsToMbcs (null, title, true);
- handle = OS.gtk_file_selection_new (titleBytes);
- if (parent != null) {
- OS.gtk_window_set_transient_for (handle, parent.topHandle());
- }
- String answer = null;
- preset ();
- int response = OS.gtk_dialog_run (handle);
- if (response == OS.GTK_RESPONSE_OK) {
- int fileNamePtr = OS.gtk_file_selection_get_filename (handle);
- int utf8Ptr = OS.g_filename_to_utf8 (fileNamePtr, -1, null, null, null);
- int [] items_written = new int [1];
- int utf16Ptr = OS.g_utf8_to_utf16 (utf8Ptr, -1, null, items_written, null);
- int length = items_written [0];
- char [] buffer = new char [length];
- OS.memmove (buffer, utf16Ptr, length * 2);
- String osAnswer = new String (buffer);
- OS.g_free (utf16Ptr);
- OS.g_free (utf8Ptr);
- answer = interpretOsAnswer (osAnswer);
- }
- OS.gtk_widget_destroy (handle);
- return answer;
-}
-/**
- * Set the initial filename which the dialog will
- * select by default when opened to the argument,
- * which may be null. The name will be prefixed with
- * the filter path when one is supplied.
- *
- * @param string the file name
+public String getFilterPath () {
+ return filterPath;
+}
+/**
+ * Makes the dialog visible and brings it to the front
+ * of the display.
+ *
+ * @return a string describing the absolute path of the first selected file,
+ * or null if the dialog was cancelled or an error occurred
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the dialog has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the dialog</li>
+ * </ul>
*/
-public void setFileName (String string) {
- fileName = string;
-}
-/**
- * Set the file extensions which the dialog will
- * use to filter the files it shows to the argument,
- * which may be null.
- *
- * @param extensions the file extension filter
+public String open () {
+ byte [] titleBytes = Converter.wcsToMbcs (null, title, true);
+ handle = OS.gtk_file_selection_new (titleBytes);
+ if (parent != null) {
+ OS.gtk_window_set_transient_for (handle, parent.topHandle());
+ }
+ String answer = null;
+ preset ();
+ int response = OS.gtk_dialog_run (handle);
+ if (response == OS.GTK_RESPONSE_OK) {
+ int fileNamePtr = OS.gtk_file_selection_get_filename (handle);
+ int utf8Ptr = OS.g_filename_to_utf8 (fileNamePtr, -1, null, null, null);
+ int [] items_written = new int [1];
+ int utf16Ptr = OS.g_utf8_to_utf16 (utf8Ptr, -1, null, items_written, null);
+ int length = items_written [0];
+ char [] buffer = new char [length];
+ OS.memmove (buffer, utf16Ptr, length * 2);
+ String osAnswer = new String (buffer);
+ OS.g_free (utf16Ptr);
+ OS.g_free (utf8Ptr);
+ answer = interpretOsAnswer (osAnswer);
+ }
+ OS.gtk_widget_destroy (handle);
+ return answer;
+}
+/**
+ * Set the initial filename which the dialog will
+ * select by default when opened to the argument,
+ * which may be null. The name will be prefixed with
+ * the filter path when one is supplied.
+ *
+ * @param string the file name
*/
-public void setFilterExtensions (String [] extensions) {
- filterExtensions = extensions;
-}
-/**
- * Sets the file names which the dialog will
- * use to filter the files it shows to the argument,
- * which may be null.
- *
- * @param names the file name filter
+public void setFileName (String string) {
+ fileName = string;
+}
+/**
+ * Set the file extensions which the dialog will
+ * use to filter the files it shows to the argument,
+ * which may be null.
+ *
+ * @param extensions the file extension filter
*/
-public void setFilterNames (String [] names) {
- filterNames = names;
-}
-/**
- * Sets the directory path that the dialog will use
- * to the argument, which may be null. File names in this
- * path will appear in the dialog, filtered according
- * to the filter extensions.
- *
- * @param string the directory path
- *
- * @see #setFilterExtensions
+public void setFilterExtensions (String [] extensions) {
+ filterExtensions = extensions;
+}
+/**
+ * Sets the file names which the dialog will
+ * use to filter the files it shows to the argument,
+ * which may be null.
+ *
+ * @param names the file name filter
*/
-public void setFilterPath (String string) {
- filterPath = string;
-}
-void preset() {
- OS.gtk_file_selection_set_select_multiple(handle, (style & SWT.MULTI) != 0);
-
- /* Calculate the fully-specified file name and convert to bytes */
- StringBuffer stringBuffer = new StringBuffer ();
- if (filterPath == null) {
- filterPath = "";
- } else {
- if (filterPath.length () > 0) {
- stringBuffer.append (filterPath);
- if (filterPath.charAt (filterPath.length () - 1) != SEPARATOR) {
- stringBuffer.append (SEPARATOR);
- }
- }
- }
- if (fileName == null) {
- fileName = "";
- } else {
- stringBuffer.append (fileName);
- }
- fullPath = stringBuffer.toString ();
- int length = fullPath.length ();
- char [] buffer = new char [length + 1];
- fullPath.getChars (0, length, buffer, 0);
- int utf8Ptr = OS.g_utf16_to_utf8 (buffer, -1, null, null, null);
- int fileNamePtr = OS.g_filename_from_utf8 (utf8Ptr, -1, null, null, null);
- OS.gtk_file_selection_set_filename (handle, fileNamePtr);
- OS.g_free (utf8Ptr);
- OS.g_free (fileNamePtr);
-
- /* Set the extension */
- if (filterNames == null) filterNames = new String [0];
- if (filterExtensions == null) filterExtensions = new String [0];
- if (filterExtensions.length == 1) {
- String ext = filterExtensions [0];
- byte [] extBytes = Converter.wcsToMbcs (null, ext, true);
- OS.gtk_file_selection_complete (handle, extBytes);
- }
- fullPath = null;
-}
-String interpretOsAnswer(String osAnswer) {
- if (osAnswer==null) return null;
- int separatorIndex = osAnswer.lastIndexOf (SEPARATOR);
- if (separatorIndex+1 == osAnswer.length ()) return null;
-
- String answer = fullPath = osAnswer;
- fileName = fullPath.substring (separatorIndex+1);
- filterPath = fullPath.substring (0, separatorIndex);
- if ((style & SWT.MULTI) == 0) {
- fileNames = new String[] {fileName};
- } else {
- int namesPtr = OS.gtk_file_selection_get_selections (handle);
- int namesPtr1 = namesPtr;
- int [] namePtr = new int [1];
- OS.memmove (namePtr, namesPtr1, 4);
- int length = 0;
- while (namePtr[0] != 0) {
- length++;
- namesPtr1+=4;
- OS.memmove(namePtr, namesPtr1, 4);
- }
- fileNames = new String [length];
- namePtr = new int [length];
- OS.memmove (namePtr, namesPtr, length * 4);
- for (int i = 0; i < length; i++) {
- int utf8Ptr = OS.g_filename_to_utf8 (namePtr [i], -1, null, null, null);
- int [] items_written = new int [1];
- int utf16Ptr = OS.g_utf8_to_utf16 (utf8Ptr, -1, null, items_written, null);
- char[] buffer = new char [items_written [0]];
- OS.memmove (buffer, utf16Ptr, items_written [0] * 2);
- String name = new String (buffer);
- fileNames [i] = name.substring (name.lastIndexOf (SEPARATOR) + 1);
- OS.g_free (utf16Ptr);
- OS.g_free (utf8Ptr);
- }
- OS.g_strfreev (namesPtr);
- }
- return answer;
-}
-
-}
+public void setFilterNames (String [] names) {
+ filterNames = names;
+}
+/**
+ * Sets the directory path that the dialog will use
+ * to the argument, which may be null. File names in this
+ * path will appear in the dialog, filtered according
+ * to the filter extensions.
+ *
+ * @param string the directory path
+ *
+ * @see #setFilterExtensions
+ */
+public void setFilterPath (String string) {
+ filterPath = string;
+}
+void preset() {
+ OS.gtk_file_selection_set_select_multiple(handle, (style & SWT.MULTI) != 0);
+
+ /* Calculate the fully-specified file name and convert to bytes */
+ StringBuffer stringBuffer = new StringBuffer ();
+ if (filterPath == null) {
+ filterPath = "";
+ } else {
+ if (filterPath.length () > 0) {
+ stringBuffer.append (filterPath);
+ if (filterPath.charAt (filterPath.length () - 1) != SEPARATOR) {
+ stringBuffer.append (SEPARATOR);
+ }
+ }
+ }
+ if (fileName == null) {
+ fileName = "";
+ } else {
+ stringBuffer.append (fileName);
+ }
+ fullPath = stringBuffer.toString ();
+ int length = fullPath.length ();
+ char [] buffer = new char [length + 1];
+ fullPath.getChars (0, length, buffer, 0);
+ int utf8Ptr = OS.g_utf16_to_utf8 (buffer, -1, null, null, null);
+ int fileNamePtr = OS.g_filename_from_utf8 (utf8Ptr, -1, null, null, null);
+ OS.gtk_file_selection_set_filename (handle, fileNamePtr);
+ OS.g_free (utf8Ptr);
+ OS.g_free (fileNamePtr);
+
+ /* Set the extension */
+ if (filterNames == null) filterNames = new String [0];
+ if (filterExtensions == null) filterExtensions = new String [0];
+ if (filterExtensions.length == 1) {
+ String ext = filterExtensions [0];
+ byte [] extBytes = Converter.wcsToMbcs (null, ext, true);
+ OS.gtk_file_selection_complete (handle, extBytes);
+ }
+ fullPath = null;
+}
+String interpretOsAnswer(String osAnswer) {
+ if (osAnswer==null) return null;
+ int separatorIndex = osAnswer.lastIndexOf (SEPARATOR);
+ if (separatorIndex+1 == osAnswer.length ()) return null;
+
+ String answer = fullPath = osAnswer;
+ fileName = fullPath.substring (separatorIndex+1);
+ filterPath = fullPath.substring (0, separatorIndex);
+ if ((style & SWT.MULTI) == 0) {
+ fileNames = new String[] {fileName};
+ } else {
+ int namesPtr = OS.gtk_file_selection_get_selections (handle);
+ int namesPtr1 = namesPtr;
+ int [] namePtr = new int [1];
+ OS.memmove (namePtr, namesPtr1, 4);
+ int length = 0;
+ while (namePtr[0] != 0) {
+ length++;
+ namesPtr1+=4;
+ OS.memmove(namePtr, namesPtr1, 4);
+ }
+ fileNames = new String [length];
+ namePtr = new int [length];
+ OS.memmove (namePtr, namesPtr, length * 4);
+ for (int i = 0; i < length; i++) {
+ int utf8Ptr = OS.g_filename_to_utf8 (namePtr [i], -1, null, null, null);
+ int [] items_written = new int [1];
+ int utf16Ptr = OS.g_utf8_to_utf16 (utf8Ptr, -1, null, items_written, null);
+ char[] buffer = new char [items_written [0]];
+ OS.memmove (buffer, utf16Ptr, items_written [0] * 2);
+ String name = new String (buffer);
+ fileNames [i] = name.substring (name.lastIndexOf (SEPARATOR) + 1);
+ OS.g_free (utf16Ptr);
+ OS.g_free (utf8Ptr);
+ }
+ OS.g_strfreev (namesPtr);
+ }
+ return answer;
+}
+
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/FontDialog.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/FontDialog.java
index ff6c96be46..3ab4e64e66 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/FontDialog.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/FontDialog.java
@@ -1,177 +1,177 @@
-package org.eclipse.swt.widgets;
-
-/*
+package org.eclipse.swt.widgets;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-import org.eclipse.swt.*;
-import org.eclipse.swt.internal.*;
-import org.eclipse.swt.internal.gtk.*;
-import org.eclipse.swt.graphics.*;
-
-/**
- * Instances of this class allow the user to select a font
- * from all available fonts in the system.
- * <p>
- * IMPORTANT: This class is intended to be subclassed <em>only</em>
- * within the SWT implementation.
- * </p>
+ * http://www.eclipse.org/legal/cpl-v10.html
*/
-public class FontDialog extends Dialog {
- FontData fontData;
- RGB rgb;
-/**
- * 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>
+
+import org.eclipse.swt.*;
+import org.eclipse.swt.internal.*;
+import org.eclipse.swt.internal.gtk.*;
+import org.eclipse.swt.graphics.*;
+
+/**
+ * Instances of this class allow the user to select a font
+ * from all available fonts in the system.
+ * <p>
+ * IMPORTANT: This class is intended to be subclassed <em>only</em>
+ * within the SWT implementation.
+ * </p>
*/
-public FontDialog (Shell parent) {
- this (parent, SWT.PRIMARY_MODAL);
-}
-/**
- * Constructs a new instance of this class given its parent
- * and a style value describing its behavior and appearance.
- * <p>
- * The style value is either one of the style constants defined in
- * class <code>SWT</code> which is applicable to instances of this
- * class, or must be built by <em>bitwise OR</em>'ing together
- * (that is, using the <code>int</code> "|" operator) two or more
- * of those <code>SWT</code> style constants. The class description
- * lists the style constants that are applicable to the class.
- * Style bits are also inherited from superclasses.
- * </p>
- * 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 class FontDialog extends Dialog {
+ FontData fontData;
+ RGB rgb;
+/**
+ * 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 FontDialog (Shell parent, int style) {
- super (parent, style);
- checkSubclass ();
-}
-
-/**
- * Returns a FontData object describing the font that was
- * selected in the dialog, or null if none is available.
- *
- * @return the FontData for the selected font, or null
+public FontDialog (Shell parent) {
+ this (parent, SWT.PRIMARY_MODAL);
+}
+/**
+ * Constructs a new instance of this class given its parent
+ * and a style value describing its behavior and appearance.
+ * <p>
+ * The style value is either one of the style constants defined in
+ * class <code>SWT</code> which is applicable to instances of this
+ * class, or must be built by <em>bitwise OR</em>'ing together
+ * (that is, using the <code>int</code> "|" operator) two or more
+ * of those <code>SWT</code> style constants. The class description
+ * lists the style constants that are applicable to the class.
+ * Style bits are also inherited from superclasses.
+ * </p>
+ * 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 FontData getFontData() {
- return fontData;
-}
-
-/**
- * Returns the currently selected color in the receiver.
- *
- * @return the RGB value for the selected color, may be null
- *
- * @see PaletteData#getRGBs
- */
-public RGB getRGB () {
- return rgb;
-}
-
-/**
- * Makes the dialog visible and brings it to the front
- * of the display.
- *
- * @return a FontData object describing the font that was selected,
- * or null if the dialog was cancelled or an error occurred
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the dialog has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the dialog</li>
- * </ul>
+public FontDialog (Shell parent, int style) {
+ super (parent, style);
+ checkSubclass ();
+}
+
+/**
+ * Returns a FontData object describing the font that was
+ * selected in the dialog, or null if none is available.
+ *
+ * @return the FontData for the selected font, or null
*/
-public FontData open () {
- int handle;
- byte [] titleBytes;
- titleBytes = Converter.wcsToMbcs (null, title, true);
- handle = OS.gtk_font_selection_dialog_new (titleBytes);
- if (parent!=null) {
- OS.gtk_window_set_transient_for(handle, parent.topHandle());
- }
- if (fontData != null) {
- Display display = parent != null ? parent.getDisplay () : Display.getCurrent ();
- Font font = new Font (display, fontData);
- int fontName = OS.pango_font_description_to_string (font.handle);
- int length = OS.strlen (fontName);
- byte [] buffer = new byte [length + 1];
- OS.memmove (buffer, fontName, length);
- font.dispose();
- OS.g_free (fontName);
- OS.gtk_font_selection_dialog_set_font_name (handle, buffer);
- }
- int response = OS.gtk_dialog_run(handle);
- boolean success = response == OS.GTK_RESPONSE_OK;
- if (success) {
- int fontName = OS.gtk_font_selection_dialog_get_font_name (handle);
- int length = OS.strlen (fontName);
- byte [] buffer = new byte [length + 1];
- OS.memmove (buffer, fontName, length);
- int fontDesc = OS.pango_font_description_from_string (buffer);
- Display display = parent != null ? parent.getDisplay () : Display.getCurrent ();
- Font font = Font.gtk_new (display, fontDesc);
- fontData = font.getFontData () [0];
- OS.pango_font_description_free (fontDesc);
- }
- OS.gtk_widget_destroy(handle);
- if (!success) return null;
- return fontData;
-}
-/**
- * Sets a FontData object describing the font to be
- * selected by default in the dialog, or null to let
- * the platform choose one.
- *
- * @param fontData the FontData to use initially, or null
+public FontData getFontData() {
+ return fontData;
+}
+
+/**
+ * Returns the currently selected color in the receiver.
+ *
+ * @return the RGB value for the selected color, may be null
+ *
+ * @see PaletteData#getRGBs
*/
-public void setFontData (FontData fontData) {
- this.fontData = fontData;
-}
-/**
- * Returns the receiver's selected color to be the argument.
- *
- * @param rgb the new RGB value for the selected color, may be
- * null to let the platform to select a default when
- * open() is called
- *
- * @see PaletteData#getRGBs
- */
-public void setRGB (RGB rgb) {
- this.rgb = rgb;
-}
-}
+public RGB getRGB () {
+ return rgb;
+}
+
+/**
+ * Makes the dialog visible and brings it to the front
+ * of the display.
+ *
+ * @return a FontData object describing the font that was selected,
+ * or null if the dialog was cancelled or an error occurred
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the dialog has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the dialog</li>
+ * </ul>
+ */
+public FontData open () {
+ int handle;
+ byte [] titleBytes;
+ titleBytes = Converter.wcsToMbcs (null, title, true);
+ handle = OS.gtk_font_selection_dialog_new (titleBytes);
+ if (parent!=null) {
+ OS.gtk_window_set_transient_for(handle, parent.topHandle());
+ }
+ if (fontData != null) {
+ Display display = parent != null ? parent.getDisplay () : Display.getCurrent ();
+ Font font = new Font (display, fontData);
+ int fontName = OS.pango_font_description_to_string (font.handle);
+ int length = OS.strlen (fontName);
+ byte [] buffer = new byte [length + 1];
+ OS.memmove (buffer, fontName, length);
+ font.dispose();
+ OS.g_free (fontName);
+ OS.gtk_font_selection_dialog_set_font_name (handle, buffer);
+ }
+ int response = OS.gtk_dialog_run(handle);
+ boolean success = response == OS.GTK_RESPONSE_OK;
+ if (success) {
+ int fontName = OS.gtk_font_selection_dialog_get_font_name (handle);
+ int length = OS.strlen (fontName);
+ byte [] buffer = new byte [length + 1];
+ OS.memmove (buffer, fontName, length);
+ int fontDesc = OS.pango_font_description_from_string (buffer);
+ Display display = parent != null ? parent.getDisplay () : Display.getCurrent ();
+ Font font = Font.gtk_new (display, fontDesc);
+ fontData = font.getFontData () [0];
+ OS.pango_font_description_free (fontDesc);
+ }
+ OS.gtk_widget_destroy(handle);
+ if (!success) return null;
+ return fontData;
+}
+/**
+ * Sets a FontData object describing the font to be
+ * selected by default in the dialog, or null to let
+ * the platform choose one.
+ *
+ * @param fontData the FontData to use initially, or null
+ */
+public void setFontData (FontData fontData) {
+ this.fontData = fontData;
+}
+/**
+ * Returns the receiver's selected color to be the argument.
+ *
+ * @param rgb the new RGB value for the selected color, may be
+ * null to let the platform to select a default when
+ * open() is called
+ *
+ * @see PaletteData#getRGBs
+ */
+public void setRGB (RGB rgb) {
+ this.rgb = rgb;
+}
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Group.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Group.java
index cabe9e2c07..84da604f97 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Group.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Group.java
@@ -12,61 +12,61 @@ import org.eclipse.swt.internal.*;
import org.eclipse.swt.internal.gtk.*;
import org.eclipse.swt.graphics.*;
-/**
- * Instances of this class provide an etched border
- * with an optional title.
- * <p>
- * Shadow styles are hints and may not be honoured
- * by the platform. To create a group with the
- * default shadow style for the platform, do not
- * specify a shadow style.
- * <dl>
- * <dt><b>Styles:</b></dt>
- * <dd>SHADOW_ETCHED_IN, SHADOW_ETCHED_OUT, SHADOW_IN, SHADOW_OUT, SHADOW_NONE</dd>
- * <dt><b>Events:</b></dt>
- * <dd>(none)</dd>
- * </dl>
- * <p>
- * Note: Only one of the above styles may be specified.
- * </p><p>
- * IMPORTANT: This class is <em>not</em> intended to be subclassed.
- * </p>
+/**
+ * Instances of this class provide an etched border
+ * with an optional title.
+ * <p>
+ * Shadow styles are hints and may not be honoured
+ * by the platform. To create a group with the
+ * default shadow style for the platform, do not
+ * specify a shadow style.
+ * <dl>
+ * <dt><b>Styles:</b></dt>
+ * <dd>SHADOW_ETCHED_IN, SHADOW_ETCHED_OUT, SHADOW_IN, SHADOW_OUT, SHADOW_NONE</dd>
+ * <dt><b>Events:</b></dt>
+ * <dd>(none)</dd>
+ * </dl>
+ * <p>
+ * Note: Only one of the above styles may be specified.
+ * </p><p>
+ * IMPORTANT: This class is <em>not</em> intended to be subclassed.
+ * </p>
*/
public class Group extends Composite {
int clientHandle, labelHandle;
String text = "";
-/**
- * Constructs a new instance of this class given its parent
- * and a style value describing its behavior and appearance.
- * <p>
- * The style value is either one of the style constants defined in
- * class <code>SWT</code> which is applicable to instances of this
- * class, or must be built by <em>bitwise OR</em>'ing together
- * (that is, using the <code>int</code> "|" operator) two or more
- * of those <code>SWT</code> style constants. The class description
- * lists the style constants that are applicable to the class.
- * Style bits are also inherited from superclasses.
- * </p>
- *
- * @param parent a composite control which will be the parent of the new instance (cannot be null)
- * @param style the style of control to construct
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
- * <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
- * </ul>
- *
- * @see SWT#SHADOW_ETCHED_IN
- * @see SWT#SHADOW_ETCHED_OUT
- * @see SWT#SHADOW_IN
- * @see SWT#SHADOW_OUT
- * @see SWT#SHADOW_NONE
- * @see Widget#checkSubclass
- * @see Widget#getStyle
+/**
+ * Constructs a new instance of this class given its parent
+ * and a style value describing its behavior and appearance.
+ * <p>
+ * The style value is either one of the style constants defined in
+ * class <code>SWT</code> which is applicable to instances of this
+ * class, or must be built by <em>bitwise OR</em>'ing together
+ * (that is, using the <code>int</code> "|" operator) two or more
+ * of those <code>SWT</code> style constants. The class description
+ * lists the style constants that are applicable to the class.
+ * Style bits are also inherited from superclasses.
+ * </p>
+ *
+ * @param parent a composite control which will be the parent of the new instance (cannot be null)
+ * @param style the style of control to construct
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
+ * <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
+ * </ul>
+ *
+ * @see SWT#SHADOW_ETCHED_IN
+ * @see SWT#SHADOW_ETCHED_OUT
+ * @see SWT#SHADOW_IN
+ * @see SWT#SHADOW_OUT
+ * @see SWT#SHADOW_NONE
+ * @see Widget#checkSubclass
+ * @see Widget#getStyle
*/
public Group (Composite parent, int style) {
super (parent, checkStyle (style));
@@ -212,17 +212,17 @@ 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>
+/**
+ * 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();
@@ -264,20 +264,20 @@ void setForegroundColor (GdkColor color) {
OS.gtk_widget_modify_fg (labelHandle, 0, color);
}
-/**
- * Sets the receiver's text, which is the string that will
- * be displayed as the receiver's <em>title</em>, to the argument,
- * which may not be null.
- *
- * @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>
+/**
+ * Sets the receiver's text, which is the string that will
+ * be displayed as the receiver's <em>title</em>, to the argument,
+ * which may not be null.
+ *
+ * @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();
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Label.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Label.java
index e530851422..6feb04783e 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Label.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Label.java
@@ -12,69 +12,69 @@ import org.eclipse.swt.internal.*;
import org.eclipse.swt.internal.gtk.*;
import org.eclipse.swt.graphics.*;
-/**
- * Instances of this class represent a non-selectable
- * user interface object that displays a string or image.
- * When SEPARATOR is specified, displays a single
- * vertical or horizontal line.
- * <dl>
- * <dt><b>Styles:</b></dt>
- * <dd>SEPARATOR, HORIZONTAL, VERTICAL</dd>
- * <dd>SHADOW_IN, SHADOW_OUT, SHADOW_NONE</dd>
- * <dd>CENTER, LEFT, RIGHT, WRAP</dd>
- * <dt><b>Events:</b></dt>
- * <dd>(none)</dd>
- * </dl>
- * <p>
- * Note: Only one of SHADOW_IN, SHADOW_OUT and SHADOW_NONE may be specified.
- * SHADOW_NONE is a HINT. Only one of HORIZONTAL and VERTICAL may be specified.
- * Only one of CENTER, LEFT and RIGHT may be specified.
- * </p><p>
- * IMPORTANT: This class is intended to be subclassed <em>only</em>
- * within the SWT implementation.
- * </p>
+/**
+ * Instances of this class represent a non-selectable
+ * user interface object that displays a string or image.
+ * When SEPARATOR is specified, displays a single
+ * vertical or horizontal line.
+ * <dl>
+ * <dt><b>Styles:</b></dt>
+ * <dd>SEPARATOR, HORIZONTAL, VERTICAL</dd>
+ * <dd>SHADOW_IN, SHADOW_OUT, SHADOW_NONE</dd>
+ * <dd>CENTER, LEFT, RIGHT, WRAP</dd>
+ * <dt><b>Events:</b></dt>
+ * <dd>(none)</dd>
+ * </dl>
+ * <p>
+ * Note: Only one of SHADOW_IN, SHADOW_OUT and SHADOW_NONE may be specified.
+ * SHADOW_NONE is a HINT. Only one of HORIZONTAL and VERTICAL may be specified.
+ * Only one of CENTER, LEFT and RIGHT may be specified.
+ * </p><p>
+ * IMPORTANT: This class is intended to be subclassed <em>only</em>
+ * within the SWT implementation.
+ * </p>
*/
public class Label extends Control {
int frameHandle, labelHandle, imageHandle;
Image image;
String text;
-/**
- * Constructs a new instance of this class given its parent
- * and a style value describing its behavior and appearance.
- * <p>
- * The style value is either one of the style constants defined in
- * class <code>SWT</code> which is applicable to instances of this
- * class, or must be built by <em>bitwise OR</em>'ing together
- * (that is, using the <code>int</code> "|" operator) two or more
- * of those <code>SWT</code> style constants. The class description
- * lists the style constants that are applicable to the class.
- * Style bits are also inherited from superclasses.
- * </p>
- *
- * @param parent a composite control which will be the parent of the new instance (cannot be null)
- * @param style the style of control to construct
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
- * <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
- * </ul>
- *
- * @see SWT#SEPARATOR
- * @see SWT#HORIZONTAL
- * @see SWT#VERTICAL
- * @see SWT#SHADOW_IN
- * @see SWT#SHADOW_OUT
- * @see SWT#SHADOW_NONE
- * @see SWT#CENTER
- * @see SWT#LEFT
- * @see SWT#RIGHT
- * @see SWT#WRAP
- * @see Widget#checkSubclass
- * @see Widget#getStyle
+/**
+ * Constructs a new instance of this class given its parent
+ * and a style value describing its behavior and appearance.
+ * <p>
+ * The style value is either one of the style constants defined in
+ * class <code>SWT</code> which is applicable to instances of this
+ * class, or must be built by <em>bitwise OR</em>'ing together
+ * (that is, using the <code>int</code> "|" operator) two or more
+ * of those <code>SWT</code> style constants. The class description
+ * lists the style constants that are applicable to the class.
+ * Style bits are also inherited from superclasses.
+ * </p>
+ *
+ * @param parent a composite control which will be the parent of the new instance (cannot be null)
+ * @param style the style of control to construct
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
+ * <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
+ * </ul>
+ *
+ * @see SWT#SEPARATOR
+ * @see SWT#HORIZONTAL
+ * @see SWT#VERTICAL
+ * @see SWT#SHADOW_IN
+ * @see SWT#SHADOW_OUT
+ * @see SWT#SHADOW_NONE
+ * @see SWT#CENTER
+ * @see SWT#LEFT
+ * @see SWT#RIGHT
+ * @see SWT#WRAP
+ * @see Widget#checkSubclass
+ * @see Widget#getStyle
*/
public Label (Composite parent, int style) {
super (parent, checkStyle (style));
@@ -198,19 +198,19 @@ int eventHandle () {
return fixedHandle;
}
-/**
- * Returns a value which describes the position of the
- * text or image in the receiver. The value will be one of
- * <code>LEFT</code>, <code>RIGHT</code> or <code>CENTER</code>
- * unless the receiver is a <code>SEPARATOR</code> label, in
- * which case, <code>NONE</code> is returned.
- *
- * @return the alignment
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
+/**
+ * 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 ();
@@ -221,16 +221,16 @@ public int getAlignment () {
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>
+/**
+ * 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 ();
@@ -241,17 +241,17 @@ 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>
+/**
+ * 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 ();
@@ -326,18 +326,18 @@ void resizeHandle (int width, int height) {
OS.gtk_widget_size_request (widgetHandle, requisition);
}
-/**
- * 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>
+/**
+ * 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 ();
@@ -420,19 +420,19 @@ void setForegroundColor (GdkColor color) {
if (imageHandle != 0) OS.gtk_widget_modify_fg (imageHandle, 0, color);
}
-/**
- * Sets the receiver's image to the argument, which may be
- * null indicating that no image should be displayed.
- *
- * @param image the image to display on the receiver (may be null)
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_INVALID_ARGUMENT - if the image has been disposed</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
+/**
+ * Sets the receiver's image to the argument, which may be
+ * null indicating that no image should be displayed.
+ *
+ * @param image the image to display on the receiver (may be null)
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_INVALID_ARGUMENT - if the image has been disposed</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
*/
public void setImage (Image image) {
checkWidget ();
@@ -449,22 +449,22 @@ public void setImage (Image image) {
}
}
-/**
- * Sets the receiver's text.
- * <p>
- * This method sets the widget label. The label may include
- * the mnemonic characters and line delimiters.
- * </p>
- *
- * @param string the new text
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the text is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
+/**
+ * Sets the receiver's text.
+ * <p>
+ * This method sets the widget label. The label may include
+ * the mnemonic characters and line delimiters.
+ * </p>
+ *
+ * @param string the new text
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if the text is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
*/
public void setText (String string) {
checkWidget();
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/List.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/List.java
index 2ce6f11dfb..a307fa4beb 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/List.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/List.java
@@ -13,76 +13,76 @@ import org.eclipse.swt.internal.gtk.*;
import org.eclipse.swt.graphics.*;
import org.eclipse.swt.events.*;
-/**
- * Instances of this class represent a selectable user interface
- * object that displays a list of strings and issues 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>
- * Note: Only one of SINGLE and MULTI may be specified.
- * </p><p>
- * IMPORTANT: This class is <em>not</em> intended to be subclassed.
- * </p>
+/**
+ * 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>
+ * Note: Only one of SINGLE and MULTI may be specified.
+ * </p><p>
+ * IMPORTANT: This class is <em>not</em> intended to be subclassed.
+ * </p>
*/
public class List extends Scrollable {
int modelHandle;
-/**
- * Constructs a new instance of this class given its parent
- * and a style value describing its behavior and appearance.
- * <p>
- * The style value is either one of the style constants defined in
- * class <code>SWT</code> which is applicable to instances of this
- * class, or must be built by <em>bitwise OR</em>'ing together
- * (that is, using the <code>int</code> "|" operator) two or more
- * of those <code>SWT</code> style constants. The class description
- * lists the style constants that are applicable to the class.
- * Style bits are also inherited from superclasses.
- * </p>
- *
- * @param parent a composite control which will be the parent of the new instance (cannot be null)
- * @param style the style of control to construct
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
- * <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
- * </ul>
- *
- * @see SWT#SINGLE
- * @see SWT#MULTI
- * @see Widget#checkSubclass
- * @see Widget#getStyle
+/**
+ * Constructs a new instance of this class given its parent
+ * and a style value describing its behavior and appearance.
+ * <p>
+ * The style value is either one of the style constants defined in
+ * class <code>SWT</code> which is applicable to instances of this
+ * class, or must be built by <em>bitwise OR</em>'ing together
+ * (that is, using the <code>int</code> "|" operator) two or more
+ * of those <code>SWT</code> style constants. The class description
+ * lists the style constants that are applicable to the class.
+ * Style bits are also inherited from superclasses.
+ * </p>
+ *
+ * @param parent a composite control which will be the parent of the new instance (cannot be null)
+ * @param style the style of control to construct
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
+ * <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
+ * </ul>
+ *
+ * @see SWT#SINGLE
+ * @see SWT#MULTI
+ * @see Widget#checkSubclass
+ * @see Widget#getStyle
*/
public List (Composite parent, int style) {
super (parent, checkStyle (style));
}
-/**
- * Adds the argument to the end of the receiver's list.
- *
- * @param string the new item
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the string is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- * @exception SWTError <ul>
- * <li>ERROR_ITEM_NOT_ADDED - if the operation fails because of an operating system failure</li>
- * </ul>
- *
- * @see #add(String,int)
+/**
+ * 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();
@@ -95,31 +95,31 @@ public void add (String string) {
OS.g_free (iter);
}
-/**
- * Adds the argument to the receiver's list at the given
- * zero-relative index.
- * <p>
- * Note: To add an item at the end of the list, use the
- * result of calling <code>getItemCount()</code> as the
- * index or use <code>add(String)</code>.
- * </p>
- *
- * @param string the new item
- * @param index the index for the item
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the string is null</li>
- * <li>ERROR_INVALID_RANGE - if the index is not between 0 and the number of elements in the list (inclusive)</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- * @exception SWTError <ul>
- * <li>ERROR_ITEM_NOT_ADDED - if the operation fails because of an operating system failure</li>
- * </ul>
- *
- * @see #add(String)
+/**
+ * Adds the argument to the receiver's list at the given
+ * zero-relative index.
+ * <p>
+ * Note: To add an item at the end of the list, use the
+ * result of calling <code>getItemCount()</code> as the
+ * index or use <code>add(String)</code>.
+ * </p>
+ *
+ * @param string the new item
+ * @param index the index for the item
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if the string is null</li>
+ * <li>ERROR_INVALID_RANGE - if the index is not between 0 and the number of elements in the list (inclusive)</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * @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();
@@ -135,29 +135,29 @@ public void add (String string, int index) {
OS.g_free (iter);
}
-/**
- * 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.
- * <p>
- * <code>widgetSelected</code> is called when the selection changes.
- * <code>widgetDefaultSelected</code> is typically called when an item is double-clicked.
- * </p>
- *
- * @param listener the listener which should be notified
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see SelectionListener
- * @see #removeSelectionListener
- * @see SelectionEvent
+/**
+ * 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.
+ * <p>
+ * <code>widgetSelected</code> is called when the selection changes.
+ * <code>widgetDefaultSelected</code> is typically called when an item is double-clicked.
+ * </p>
+ *
+ * @param listener the listener which should be notified
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see SelectionListener
+ * @see #removeSelectionListener
+ * @see SelectionEvent
*/
public void addSelectionListener(SelectionListener listener) {
checkWidget();
@@ -236,17 +236,17 @@ void deregister() {
WidgetTable.remove (OS.gtk_tree_view_get_selection (handle));
}
-/**
- * Deselects the item at the given zero-relative index in the receiver.
- * If the item at the index was already deselected, it remains
- * deselected. Indices that are out of range are ignored.
- *
- * @param index the index of the item to deselect
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
+/**
+ * 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();
@@ -260,20 +260,20 @@ public void deselect (int index) {
OS.g_free (iter);
}
-/**
- * Deselects the items at the given zero-relative indices in the receiver.
- * If the item at the given zero-relative index in the receiver
- * is selected, it is deselected. If the item at the index
- * was not selected, it remains deselected. The range of the
- * indices is inclusive. Indices that are out of range are ignored.
- *
- * @param start the start index of the items to deselect
- * @param end the end index of the items to deselect
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
+/**
+ * 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();
@@ -293,22 +293,22 @@ public void deselect (int start, int end) {
OS.g_free (iter);
}
-/**
- * Deselects the items at the given zero-relative indices in the receiver.
- * If the item at the given zero-relative index in the receiver
- * is selected, it is deselected. If the item at the index
- * was not selected, it remains deselected. Indices that are out
- * of range and duplicate indices are ignored.
- *
- * @param indices the array of indices for the items to deselect
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the 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>
+/**
+ * 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();
@@ -327,13 +327,13 @@ public void deselect (int [] indices) {
OS.g_free (iter);
}
-/**
- * Deselects all selected items in the receiver.
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
+/**
+ * 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();
@@ -347,16 +347,16 @@ GdkColor getBackgroundColor () {
return getBaseColor ();
}
-/**
- * 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>
+/**
+ * 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();
@@ -374,23 +374,23 @@ GdkColor getForegroundColor () {
return getTextColor ();
}
-/**
- * Returns the item at the given, zero-relative index in the
- * receiver. Throws an exception if the index is out of range.
- *
- * @param index the index of the item to return
- * @return the item at the given index
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_INVALID_RANGE - if the index is not between 0 and the number of elements in the list minus 1 (inclusive)</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- * @exception SWTError <ul>
- * <li>ERROR_CANNOT_GET_ITEM - if the operation fails because of an operating system failure</li>
- * </ul>
+/**
+ * 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();
@@ -410,37 +410,37 @@ public String getItem (int index) {
return new String (Converter.mbcsToWcs (null, buffer2));
}
-/**
- * Returns the number of items contained in the receiver.
- *
- * @return the number of items
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- * @exception SWTError <ul>
- * <li>ERROR_CANNOT_GET_COUNT - if the operation fails because of an operating system failure</li>
- * </ul>
+/**
+ * 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.gtk_tree_model_iter_n_children (modelHandle, 0);
}
-/**
- * Returns the height of the area which would be used to
- * display <em>one</em> of the items in the tree.
- *
- * @return the height of one item
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- * @exception SWTError <ul>
- * <li>ERROR_CANNOT_GET_ITEM_HEIGHT - if the operation fails because of an operating system failure</li>
- * </ul>
+/**
+ * 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>
+ * @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();
@@ -453,25 +453,25 @@ public int getItemHeight () {
return h [0];
}
-/**
- * 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 affect the receiver.
- * </p>
- *
- * @return the items in the receiver's list
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- * @exception SWTError <ul>
- * <li>ERROR_CANNOT_GET_ITEM - if the operation fails because of an operating system failure while getting an item</li>
- * <li>ERROR_CANNOT_GET_COUNT - if the operation fails because of an operating system failure while getting the item count</li>
- * </ul>
+/**
+ * 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 affect the receiver.
+ * </p>
+ *
+ * @return the items in the receiver's list
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * @exception SWTError <ul>
+ * <li>ERROR_CANNOT_GET_ITEM - if the operation fails because of an operating system failure while getting an item</li>
+ * <li>ERROR_CANNOT_GET_COUNT - if the operation fails because of an operating system failure while getting the item count</li>
+ * </ul>
*/
public String [] getItems () {
checkWidget();
@@ -494,25 +494,25 @@ public String [] getItems () {
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 affect the receiver.
- * </p>
- * @return an array representing the selection
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- * @exception SWTError <ul>
- * <li>ERROR_CANNOT_GET_SELECTION - if the operation fails because of an operating system failure while getting the selection</li>
- * <li>ERROR_CANNOT_GET_ITEM - if the operation fails because of an operating system failure while getting an item</li>
- * </ul>
+/**
+ * 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 affect the receiver.
+ * </p>
+ * @return an array representing the selection
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * @exception SWTError <ul>
+ * <li>ERROR_CANNOT_GET_SELECTION - if the operation fails because of an operating system failure while getting the selection</li>
+ * <li>ERROR_CANNOT_GET_ITEM - if the operation fails because of an operating system failure while getting an item</li>
+ * </ul>
*/
public String [] getSelection () {
checkWidget();
@@ -524,18 +524,18 @@ public String [] getSelection () {
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>
- * @exception SWTError <ul>
- * <li>ERROR_CANNOT_GET_COUNT - if the operation fails because of an operating system failure</li>
- * </ul>
+/**
+ * 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>
+ * @exception SWTError <ul>
+ * <li>ERROR_CANNOT_GET_COUNT - if the operation fails because of an operating system failure</li>
+ * </ul>
*/
public int getSelectionCount () {
checkWidget();
@@ -547,19 +547,19 @@ public int getSelectionCount () {
return display.treeSelectionLength;
}
-/**
- * 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>
- * @exception SWTError <ul>
- * <li>ERROR_CANNOT_GET_SELECTION - if the operation fails because of an operating system failure</li>
- * </ul>
+/**
+ * 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>
+ * @exception SWTError <ul>
+ * <li>ERROR_CANNOT_GET_SELECTION - if the operation fails because of an operating system failure</li>
+ * </ul>
*/
public int getSelectionIndex () {
checkWidget();
@@ -573,23 +573,23 @@ public int getSelectionIndex () {
return display.treeSelection [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 affect the receiver.
- * </p>
- * @return the array of indices of the selected items
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- * @exception SWTError <ul>
- * <li>ERROR_CANNOT_GET_SELECTION - if the operation fails because of an operating system failure</li>
- * </ul>
+/**
+ * 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 affect the receiver.
+ * </p>
+ * @return the array of indices of the selected items
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * @exception SWTError <ul>
+ * <li>ERROR_CANNOT_GET_SELECTION - if the operation fails because of an operating system failure</li>
+ * </ul>
*/
public int [] getSelectionIndices () {
checkWidget();
@@ -605,17 +605,17 @@ public int [] getSelectionIndices () {
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>
+/**
+ * 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();
@@ -699,51 +699,51 @@ void hookEvents () {
OS.g_signal_connect (handle, OS.row_activated, display.windowProc4, ROW_ACTIVATED);
}
-/**
- * Gets the index of an item.
- * <p>
- * The list is searched starting at 0 until an
- * item is found that is equal to the search item.
- * If no item is found, -1 is returned. Indexing
- * is zero based.
- *
- * @param string the search item
- * @return the index of the item
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the string is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
+/**
+ * Gets the index of an item.
+ * <p>
+ * The list is searched starting at 0 until an
+ * item is found that is equal to the search item.
+ * If no item is found, -1 is returned. Indexing
+ * is zero based.
+ *
+ * @param string the search item
+ * @return the index of the item
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if the string is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
*/
public int indexOf (String string) {
checkWidget();
return indexOf (string, 0);
}
-/**
- * Searches the receiver's list starting at the given,
- * zero-relative index until an item is found that is equal
- * to the argument, and returns the index of that item. If
- * no item is found or the starting index is out of range,
- * returns -1.
- *
- * @param string the search item
- * @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>
- * @exception SWTError <ul>
- * <li>ERROR_CANNOT_GET_COUNT - if the operation fails because of an operating system failure while getting the item count</li>
- * <li>ERROR_CANNOT_GET_ITEM - if the operation fails because of an operating system failure while getting an item</li>
- * </ul>
+/**
+ * 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>
+ * @exception SWTError <ul>
+ * <li>ERROR_CANNOT_GET_COUNT - if the operation fails because of an operating system failure while getting the item count</li>
+ * <li>ERROR_CANNOT_GET_ITEM - if the operation fails because of an operating system failure while getting an item</li>
+ * </ul>
*/
public int indexOf (String string, int start) {
checkWidget();
@@ -755,18 +755,18 @@ public int indexOf (String string, int start) {
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>
+/**
+ * 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();
@@ -794,22 +794,22 @@ void releaseWidget () {
modelHandle = 0;
}
-/**
- * Removes the item from the receiver at the given
- * zero-relative index.
- *
- * @param index the index for the item
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_INVALID_RANGE - if the index is not between 0 and the number of elements in the list minus 1 (inclusive)</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- * @exception SWTError <ul>
- * <li>ERROR_ITEM_NOT_REMOVED - if the operation fails because of an operating system failure</li>
- * </ul>
+/**
+ * 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();
@@ -825,24 +825,24 @@ public void remove (int index) {
OS.g_free (iter);
}
-/**
- * Removes the items from the receiver which are
- * between the given zero-relative start and end
- * indices (inclusive).
- *
- * @param start the start of the range
- * @param end the end of the range
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_INVALID_RANGE - if either the start or end are not between 0 and the number of elements in the list minus 1 (inclusive)</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- * @exception SWTError <ul>
- * <li>ERROR_ITEM_NOT_REMOVED - if the operation fails because of an operating system failure</li>
- * </ul>
+/**
+ * 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();
@@ -851,7 +851,7 @@ public void remove (int start, int end) {
int count = OS.gtk_tree_model_iter_n_children (modelHandle, 0);
int iter = OS.g_malloc (OS.GtkTreeIter_sizeof ());
int selection = OS.gtk_tree_view_get_selection (handle);
- OS.g_signal_handlers_block_matched (selection, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, CHANGED);
+ OS.g_signal_handlers_block_matched (selection, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, CHANGED);
for (int index=Math.min(end,count-1); index>=start; index--) {
OS.gtk_tree_model_iter_nth_child (modelHandle, iter, 0, index);
OS.gtk_list_store_remove (modelHandle, iter);
@@ -863,24 +863,24 @@ public void remove (int start, int end) {
}
}
-/**
- * Searches the receiver's list starting at the first item
- * until an item is found that is equal to the argument,
- * and removes that item from the list.
- *
- * @param string the item to remove
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the string is null</li>
- * <li>ERROR_INVALID_ARGUMENT - if the string is not found in the list</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- * @exception SWTError <ul>
- * <li>ERROR_ITEM_NOT_REMOVED - if the operation fails because of an operating system failure</li>
- * </ul>
+/**
+ * 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();
@@ -889,22 +889,22 @@ public void remove (String string) {
remove (index);
}
-/**
- * Removes the items from the receiver at the given
- * zero-relative indices.
- *
- * @param indices the array of indices of the items
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_INVALID_RANGE - if the index is not between 0 and the number of elements in the list minus 1 (inclusive)</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - 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>
+/**
+ * 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();
@@ -935,13 +935,13 @@ public void remove (int [] indices) {
OS.g_free (iter);
}
-/**
- * Removes all of the items from the receiver.
- * <p>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
+/**
+ * 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();
@@ -951,22 +951,22 @@ public void removeAll () {
OS.g_signal_handlers_unblock_matched (selection, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, CHANGED);
}
-/**
- * Removes the listener from the collection of listeners who will
- * be notified when the 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
+/**
+ * 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();
@@ -976,17 +976,17 @@ public void removeSelectionListener(SelectionListener 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>
+/**
+ * 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();
@@ -1006,19 +1006,19 @@ public void select (int index) {
OS.g_free (iter);
}
-/**
- * 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>
+/**
+ * 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();
@@ -1044,22 +1044,22 @@ public void select (int start, int end) {
OS.g_free (iter);
}
-/**
- * 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>
+/**
+ * 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();
@@ -1085,13 +1085,13 @@ public void select (int [] indices) {
OS.g_free (iter);
}
-/**
- * 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>
+/**
+ * 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();
@@ -1126,26 +1126,26 @@ void setForegroundColor (GdkColor color) {
OS.gtk_widget_modify_text (handle, 0, color);
}
-/**
- * Sets the text of the item in the receiver's list at the given
- * zero-relative index to the string argument. This is equivalent
- * to <code>remove</code>'ing the old item at the index, and then
- * <code>add</code>'ing the new item at that index.
- *
- * @param index the index for the item
- * @param string the new text for the item
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_INVALID_RANGE - if the index is not between 0 and the number of elements in the list minus 1 (inclusive)</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - 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>
+/**
+ * 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();
@@ -1160,18 +1160,18 @@ public void setItem (int index, String string) {
OS.g_free (iter);
}
-/**
- * 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>
+/**
+ * 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();
@@ -1195,20 +1195,20 @@ public void setItems (String [] items) {
OS.g_free (iter);
}
-/**
- * Selects the item at the given zero-relative index in the receiver.
- * If the item at the index was already selected, it remains selected.
- * The current 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)
+/**
+ * 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) {
checkWidget();
@@ -1217,20 +1217,20 @@ public void setSelection (int index) {
showSelection ();
}
-/**
- * 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)
+/**
+ * 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) {
checkWidget();
@@ -1239,22 +1239,22 @@ public void setSelection (int start, int end) {
showSelection ();
}
-/**
- * Selects the items at the given zero-relative indices in the receiver.
- * The current selection 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 List#deselectAll()
- * @see List#select(int[])
+/**
+ * Selects the items at the given zero-relative indices in the receiver.
+ * The current selection 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 List#deselectAll()
+ * @see List#select(int[])
*/
public void setSelection(int[] indices) {
checkWidget();
@@ -1264,23 +1264,23 @@ public void setSelection(int[] indices) {
showSelection ();
}
-/**
- * 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)
+/**
+ * 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();
@@ -1304,17 +1304,17 @@ public void setSelection (String [] items) {
showSelection ();
}
-/**
- * Sets the zero-relative index of the item which is currently
- * at the top of the receiver. This index can change when items
- * are scrolled or new items are added and removed.
- *
- * @param index the index of the top item
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
+/**
+ * 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();
@@ -1328,18 +1328,18 @@ public void setTopIndex (int index) {
OS.g_free (iter);
}
-/**
- * Shows the selection. If the selection is already showing in the receiver,
- * this method simply returns. Otherwise, the items are scrolled until
- * the selection is visible.
- *
- * @exception 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>
+/**
+ * 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();
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Menu.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Menu.java
index fab7f3a7db..357ea3c399 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Menu.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Menu.java
@@ -1,18 +1,18 @@
-package org.eclipse.swt.widgets;
-
-/*
+package org.eclipse.swt.widgets;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-import org.eclipse.swt.internal.*;
-import org.eclipse.swt.internal.gtk.*;
-import org.eclipse.swt.*;
-import org.eclipse.swt.events.*;
-import org.eclipse.swt.graphics.*;
-
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+import org.eclipse.swt.internal.*;
+import org.eclipse.swt.internal.gtk.*;
+import org.eclipse.swt.*;
+import org.eclipse.swt.events.*;
+import org.eclipse.swt.graphics.*;
+
/**
* Instances of this class are user interface objects that contain
* menu items.
@@ -28,13 +28,13 @@ import org.eclipse.swt.graphics.*;
* IMPORTANT: This class is <em>not</em> intended to be subclassed.
* </p>
*/
-public class Menu extends Widget {
- int x, y;
- boolean hasLocation;
- MenuItem cascade, selectedItem;
- Decorations parent;
- int imItem, imSeparator, imHandle;
-
+public class Menu extends Widget {
+ int x, y;
+ boolean hasLocation;
+ MenuItem cascade, selectedItem;
+ Decorations parent;
+ int imItem, imSeparator, imHandle;
+
/**
* Constructs a new instance of this class given its parent,
* and sets the style for the instance so that the instance
@@ -54,10 +54,10 @@ public class Menu extends Widget {
* @see Widget#checkSubclass
* @see Widget#getStyle
*/
-public Menu (Control parent) {
- this (parent.getShell (), SWT.POP_UP);
-}
-
+public Menu (Control parent) {
+ this (parent.getShell (), SWT.POP_UP);
+}
+
/**
* Constructs a new instance of this class given its parent
* (which must be a <code>Decorations</code>) and a style value
@@ -89,12 +89,12 @@ public Menu (Control parent) {
* @see Widget#checkSubclass
* @see Widget#getStyle
*/
-public Menu (Decorations parent, int style) {
- super (parent, checkStyle (style));
- this.parent = parent;
- createWidget (0);
-}
-
+public Menu (Decorations parent, int style) {
+ super (parent, checkStyle (style));
+ this.parent = parent;
+ createWidget (0);
+}
+
/**
* Constructs a new instance of this class given its parent
* (which must be a <code>Menu</code>) and sets the style
@@ -115,10 +115,10 @@ public Menu (Decorations parent, int style) {
* @see Widget#checkSubclass
* @see Widget#getStyle
*/
-public Menu (Menu parentMenu) {
- this (parentMenu.parent, SWT.DROP_DOWN);
-}
-
+public Menu (Menu parentMenu) {
+ this (parentMenu.parent, SWT.DROP_DOWN);
+}
+
/**
* Constructs a new instance of this class given its parent
* (which must be a <code>MenuItem</code>) and sets the style
@@ -139,22 +139,22 @@ public Menu (Menu parentMenu) {
* @see Widget#checkSubclass
* @see Widget#getStyle
*/
-public Menu (MenuItem parentItem) {
- this (parentItem.parent);
-}
-
-static int checkStyle (int style) {
- return checkBits (style, SWT.POP_UP, SWT.BAR, SWT.DROP_DOWN, 0, 0, 0);
-}
-
-void addAccelerators (int accelGroup) {
- MenuItem [] items = getItems ();
+public Menu (MenuItem parentItem) {
+ this (parentItem.parent);
+}
+
+static int checkStyle (int style) {
+ return checkBits (style, SWT.POP_UP, SWT.BAR, SWT.DROP_DOWN, 0, 0, 0);
+}
+
+void addAccelerators (int accelGroup) {
+ MenuItem [] items = getItems ();
for (int i = 0; i < items.length; i++) {
MenuItem item = items[i];
item.addAccelerators (accelGroup);
- }
-}
-
+ }
+}
+
/**
* Adds the listener to the collection of listeners who will
* be notified when menus are hidden or shown, by sending it
@@ -174,14 +174,14 @@ void addAccelerators (int accelGroup) {
* @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);
-}
-
+public void addMenuListener (MenuListener listener) {
+ checkWidget();
+ if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+ TypedListener typedListener = new TypedListener (listener);
+ addListener (SWT.Hide,typedListener);
+ addListener (SWT.Show,typedListener);
+}
+
/**
* Adds the listener to the collection of listeners who will
* be notified when help events are generated for the control,
@@ -201,62 +201,62 @@ public void addMenuListener (MenuListener listener) {
* @see HelpListener
* @see #removeHelpListener
*/
-public void addHelpListener (HelpListener listener) {
- checkWidget();
- if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
- TypedListener typedListener = new TypedListener (listener);
- addListener (SWT.Help, typedListener);
-}
-
-void createHandle (int index) {
- state |= HANDLE;
- if ((style & SWT.BAR) != 0) {
- handle = OS.gtk_menu_bar_new ();
- if (handle == 0) error (SWT.ERROR_NO_HANDLES);
- int parentHandle = parent.fixedHandle;
- OS.gtk_container_add (parentHandle, handle);
- } else {
- handle = OS.gtk_menu_new ();
- if (handle == 0) error (SWT.ERROR_NO_HANDLES);
- }
-}
-
-void createIMMenu (int imHandle) {
- if (this.imHandle == imHandle) return;
- this.imHandle = imHandle;
- if (imHandle == 0) {
- if (imItem != 0) {
- OS.gtk_widget_destroy (imItem);
- imItem = 0;
- }
- if (imSeparator != 0) {
- OS.gtk_widget_destroy (imSeparator);
- imSeparator = 0;
- }
- return;
- }
- if (imSeparator == 0) {
- imSeparator = OS.gtk_separator_menu_item_new ();
- OS.gtk_widget_show (imSeparator);
- OS.gtk_menu_shell_insert (handle, imSeparator, -1);
- }
- if (imItem == 0) {
- byte[] buffer = Converter.wcsToMbcs (null, SWT.getMessage("SWT_InputMethods"), true);
- imItem = OS.gtk_image_menu_item_new_with_label (buffer);
- OS.gtk_widget_show (imItem);
- OS.gtk_menu_shell_insert (handle, imItem, -1);
- }
- int imSubmenu = OS.gtk_menu_new ();
- OS.gtk_im_multicontext_append_menuitems (imHandle, imSubmenu);
- OS.gtk_menu_item_set_submenu (imItem, imSubmenu);
-}
-
-void createWidget (int index) {
- checkOrientation (parent);
- super.createWidget (index);
- parent.add (this);
-}
-
+public void addHelpListener (HelpListener listener) {
+ checkWidget();
+ if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+ TypedListener typedListener = new TypedListener (listener);
+ addListener (SWT.Help, typedListener);
+}
+
+void createHandle (int index) {
+ state |= HANDLE;
+ if ((style & SWT.BAR) != 0) {
+ handle = OS.gtk_menu_bar_new ();
+ if (handle == 0) error (SWT.ERROR_NO_HANDLES);
+ int parentHandle = parent.fixedHandle;
+ OS.gtk_container_add (parentHandle, handle);
+ } else {
+ handle = OS.gtk_menu_new ();
+ if (handle == 0) error (SWT.ERROR_NO_HANDLES);
+ }
+}
+
+void createIMMenu (int imHandle) {
+ if (this.imHandle == imHandle) return;
+ this.imHandle = imHandle;
+ if (imHandle == 0) {
+ if (imItem != 0) {
+ OS.gtk_widget_destroy (imItem);
+ imItem = 0;
+ }
+ if (imSeparator != 0) {
+ OS.gtk_widget_destroy (imSeparator);
+ imSeparator = 0;
+ }
+ return;
+ }
+ if (imSeparator == 0) {
+ imSeparator = OS.gtk_separator_menu_item_new ();
+ OS.gtk_widget_show (imSeparator);
+ OS.gtk_menu_shell_insert (handle, imSeparator, -1);
+ }
+ if (imItem == 0) {
+ byte[] buffer = Converter.wcsToMbcs (null, SWT.getMessage("SWT_InputMethods"), true);
+ imItem = OS.gtk_image_menu_item_new_with_label (buffer);
+ OS.gtk_widget_show (imItem);
+ OS.gtk_menu_shell_insert (handle, imItem, -1);
+ }
+ int imSubmenu = OS.gtk_menu_new ();
+ OS.gtk_im_multicontext_append_menuitems (imHandle, imSubmenu);
+ OS.gtk_menu_item_set_submenu (imItem, imSubmenu);
+}
+
+void createWidget (int index) {
+ checkOrientation (parent);
+ super.createWidget (index);
+ parent.add (this);
+}
+
/**
* Returns the default menu item or null if none has
* been previously set.
@@ -269,17 +269,17 @@ void createWidget (int index) {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public MenuItem getDefaultItem () {
- checkWidget();
- return null;
-}
-
-public Display getDisplay () {
- Decorations parent = this.parent;
- if (parent == null) error (SWT.ERROR_WIDGET_DISPOSED);
- return parent.getDisplay ();
-}
-
+public MenuItem getDefaultItem () {
+ checkWidget();
+ 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
@@ -293,11 +293,11 @@ public Display getDisplay () {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public boolean getEnabled () {
- checkWidget();
- return OS.GTK_WIDGET_SENSITIVE (handle);
-}
-
+public boolean getEnabled () {
+ checkWidget();
+ return OS.GTK_WIDGET_SENSITIVE (handle);
+}
+
/**
* Returns the item at the given, zero-relative index in the
* receiver. Throws an exception if the index is out of range.
@@ -313,20 +313,20 @@ public boolean getEnabled () {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public MenuItem getItem (int index) {
- checkWidget();
- int list = OS.gtk_container_get_children (handle);
- if (list == 0) error (SWT.ERROR_CANNOT_GET_ITEM);
- int count = OS.g_list_length (list);
- if (imSeparator != 0) count--;
- if (imItem != 0) count--;
- if (!(0 <= index && index < count)) error (SWT.ERROR_INVALID_RANGE);
- int data = OS.g_list_nth_data (list, index);
- OS.g_list_free (list);
- if (data == 0) error (SWT.ERROR_CANNOT_GET_ITEM);
- return (MenuItem) WidgetTable.get (data);
-}
-
+public MenuItem getItem (int index) {
+ checkWidget();
+ int list = OS.gtk_container_get_children (handle);
+ if (list == 0) error (SWT.ERROR_CANNOT_GET_ITEM);
+ int count = OS.g_list_length (list);
+ if (imSeparator != 0) count--;
+ if (imItem != 0) count--;
+ if (!(0 <= index && index < count)) error (SWT.ERROR_INVALID_RANGE);
+ int data = OS.g_list_nth_data (list, index);
+ OS.g_list_free (list);
+ if (data == 0) error (SWT.ERROR_CANNOT_GET_ITEM);
+ return (MenuItem) WidgetTable.get (data);
+}
+
/**
* Returns the number of items contained in the receiver.
*
@@ -337,17 +337,17 @@ public MenuItem getItem (int index) {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public int getItemCount () {
- checkWidget();
- int list = OS.gtk_container_get_children (handle);
- if (list == 0) return 0;
- int count = OS.g_list_length (list);
- OS.g_list_free (list);
- if (imSeparator != 0) count--;
- if (imItem != 0) count--;
- return count;
-}
-
+public int getItemCount () {
+ checkWidget();
+ int list = OS.gtk_container_get_children (handle);
+ if (list == 0) return 0;
+ int count = OS.g_list_length (list);
+ OS.g_list_free (list);
+ if (imSeparator != 0) count--;
+ if (imItem != 0) count--;
+ return count;
+}
+
/**
* Returns an array of <code>MenuItem</code>s which are the items
* in the receiver.
@@ -364,35 +364,35 @@ public int getItemCount () {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public MenuItem [] getItems () {
- checkWidget();
- int list = OS.gtk_container_get_children (handle);
- if (list == 0) return new MenuItem [0];
- int count = OS.g_list_length (list);
- if (imSeparator != 0) count--;
- if (imItem != 0) count--;
- MenuItem [] items = new MenuItem [count];
- for (int i=0; i<count; i++) {
- int data = OS.g_list_nth_data (list, i);
- items [i] = (MenuItem) WidgetTable.get (data);
- }
- OS.g_list_free (list);
- 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;
-}
-
+public MenuItem [] getItems () {
+ checkWidget();
+ int list = OS.gtk_container_get_children (handle);
+ if (list == 0) return new MenuItem [0];
+ int count = OS.g_list_length (list);
+ if (imSeparator != 0) count--;
+ if (imItem != 0) count--;
+ MenuItem [] items = new MenuItem [count];
+ for (int i=0; i<count; i++) {
+ int data = OS.g_list_nth_data (list, i);
+ items [i] = (MenuItem) WidgetTable.get (data);
+ }
+ OS.g_list_free (list);
+ 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>.
*
@@ -403,11 +403,11 @@ String getNameText () {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public Decorations getParent () {
- checkWidget();
- return parent;
-}
-
+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
@@ -420,11 +420,11 @@ public Decorations getParent () {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public MenuItem getParentItem () {
- checkWidget();
- return cascade;
-}
-
+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
@@ -437,12 +437,12 @@ public MenuItem getParentItem () {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public Menu getParentMenu () {
- checkWidget();
- if (cascade == null) return null;
- return cascade.getParent ();
-}
-
+public Menu getParentMenu () {
+ checkWidget();
+ if (cascade == null) return null;
+ return cascade.getParent ();
+}
+
/**
* Returns the receiver's shell. For all controls other than
* shells, this simply returns the control's nearest ancestor
@@ -458,11 +458,11 @@ public Menu getParentMenu () {
*
* @see #getParent
*/
-public Shell getShell () {
- checkWidget();
- return parent.getShell ();
-}
-
+public Shell getShell () {
+ checkWidget();
+ return parent.getShell ();
+}
+
/**
* Returns <code>true</code> if the receiver is visible, and
* <code>false</code> otherwise.
@@ -480,43 +480,43 @@ public Shell getShell () {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public boolean getVisible () {
- checkWidget();
- return OS.GTK_WIDGET_MAPPED (handle);
-}
-
-int GtkMenuPositionFunc (int menu, int x, int y, int push_in, int user_data) {
- if (x != 0) OS.memmove (x, new int [] {this.x}, 4);
- if (y != 0) OS.memmove (y, new int [] {this.y}, 4);
- return 0;
-}
-
-int gtk_hide (int widget) {
- sendEvent (SWT.Hide);
- return 0;
-}
-
-int gtk_show (int widget) {
- if ((style & SWT.POP_UP) != 0) return 0;
- sendEvent (SWT.Show);
- return 0;
-}
-
-int gtk_show_help (int widget, int helpType) {
- if (sendHelpEvent (helpType)) OS.gtk_menu_shell_deactivate (handle);
- return 0;
-}
-
-void hookEvents () {
- super.hookEvents ();
- Display display = getDisplay ();
- int windowProc2 = display.windowProc2;
- int windowProc3 = display.windowProc3;
- OS.g_signal_connect (handle, OS.show, windowProc2, SHOW);
- OS.g_signal_connect (handle, OS.hide, windowProc2, HIDE);
- OS.g_signal_connect (handle, OS.show_help, windowProc3, SHOW_HELP);
-}
-
+public boolean getVisible () {
+ checkWidget();
+ return OS.GTK_WIDGET_MAPPED (handle);
+}
+
+int GtkMenuPositionFunc (int menu, int x, int y, int push_in, int user_data) {
+ if (x != 0) OS.memmove (x, new int [] {this.x}, 4);
+ if (y != 0) OS.memmove (y, new int [] {this.y}, 4);
+ return 0;
+}
+
+int gtk_hide (int widget) {
+ sendEvent (SWT.Hide);
+ return 0;
+}
+
+int gtk_show (int widget) {
+ if ((style & SWT.POP_UP) != 0) return 0;
+ sendEvent (SWT.Show);
+ return 0;
+}
+
+int gtk_show_help (int widget, int helpType) {
+ if (sendHelpEvent (helpType)) OS.gtk_menu_shell_deactivate (handle);
+ return 0;
+}
+
+void hookEvents () {
+ super.hookEvents ();
+ Display display = getDisplay ();
+ int windowProc2 = display.windowProc2;
+ int windowProc3 = display.windowProc3;
+ OS.g_signal_connect (handle, OS.show, windowProc2, SHOW);
+ OS.g_signal_connect (handle, OS.hide, windowProc2, HIDE);
+ OS.g_signal_connect (handle, OS.show_help, windowProc3, SHOW_HELP);
+}
+
/**
* Searches the receiver's list starting at the first item
* (index 0) until an item is found that is equal to the
@@ -534,78 +534,78 @@ void hookEvents () {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public int indexOf (MenuItem item) {
- checkWidget();
- if (item == null) error (SWT.ERROR_NULL_ARGUMENT);
- MenuItem [] items = getItems ();
- for (int i=0; i<items.length; i++) {
- if (items [i] == item) return i;
- }
- return -1;
-}
-
-/**
- * Returns <code>true</code> if the receiver is enabled and all
- * of the receiver's ancestors are enabled, and <code>false</code>
- * otherwise. A disabled control is typically not selectable from the
- * user interface and draws with an inactive or "grayed" look.
- *
- * @return the receiver's enabled state
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see #getEnabled
+public int indexOf (MenuItem item) {
+ checkWidget();
+ if (item == null) error (SWT.ERROR_NULL_ARGUMENT);
+ MenuItem [] items = getItems ();
+ for (int i=0; i<items.length; i++) {
+ if (items [i] == item) return i;
+ }
+ return -1;
+}
+
+/**
+ * Returns <code>true</code> if the receiver is enabled and all
+ * of the receiver's ancestors are enabled, and <code>false</code>
+ * otherwise. A disabled control is typically not selectable from the
+ * user interface and draws with an inactive or "grayed" look.
+ *
+ * @return the receiver's enabled state
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see #getEnabled
*/
-public boolean isEnabled () {
- checkWidget();
- Menu parentMenu = getParentMenu ();
- if (parentMenu == null) return getEnabled ();
- return getEnabled () && parentMenu.isEnabled ();
-}
-
-/**
- * Returns <code>true</code> if the receiver is visible and all
- * of the receiver's ancestors are visible and <code>false</code>
- * otherwise.
- *
- * @return the receiver's visibility state
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see #getVisible
+public boolean isEnabled () {
+ checkWidget();
+ Menu parentMenu = getParentMenu ();
+ if (parentMenu == null) return getEnabled ();
+ return getEnabled () && parentMenu.isEnabled ();
+}
+
+/**
+ * Returns <code>true</code> if the receiver is visible and all
+ * of the receiver's ancestors are visible and <code>false</code>
+ * otherwise.
+ *
+ * @return the receiver's visibility state
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see #getVisible
*/
-public boolean isVisible () {
- checkWidget();
- return getVisible ();
-}
-
-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.releaseResources ();
- }
- if (parent != null) parent.remove (this);
- super.releaseWidget ();
- parent = null;
- cascade = null;
- imItem = imSeparator = imHandle = 0;
-}
-
+public boolean isVisible () {
+ checkWidget();
+ return getVisible ();
+}
+
+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.releaseResources ();
+ }
+ if (parent != null) parent.remove (this);
+ super.releaseWidget ();
+ parent = null;
+ cascade = null;
+ imItem = imSeparator = imHandle = 0;
+}
+
/**
* Removes the listener from the collection of listeners who will
* be notified when the menu events are generated for the control.
@@ -623,22 +623,22 @@ void releaseWidget () {
* @see MenuListener
* @see #addMenuListener
*/
-public void removeMenuListener (MenuListener listener) {
- checkWidget();
- if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
- if (eventTable == null) return;
- eventTable.unhook (SWT.Hide, listener);
- eventTable.unhook (SWT.Show, listener);
-}
-
-void removeAccelerators (int accelGroup) {
- MenuItem [] items = getItems ();
- for (int i = 0; i < items.length; i++) {
- MenuItem item = items[i];
- item.removeAccelerators (accelGroup);
- }
-}
-
+public void removeMenuListener (MenuListener listener) {
+ checkWidget();
+ if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+ if (eventTable == null) return;
+ eventTable.unhook (SWT.Hide, listener);
+ eventTable.unhook (SWT.Show, listener);
+}
+
+void removeAccelerators (int accelGroup) {
+ MenuItem [] items = getItems ();
+ for (int i = 0; i < items.length; i++) {
+ MenuItem item = items[i];
+ item.removeAccelerators (accelGroup);
+ }
+}
+
/**
* Removes the listener from the collection of listeners who will
* be notified when the help events are generated for the control.
@@ -656,27 +656,27 @@ void removeAccelerators (int accelGroup) {
* @see HelpListener
* @see #addHelpListener
*/
-public void removeHelpListener (HelpListener listener) {
- checkWidget();
- if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
- if (eventTable == null) return;
- eventTable.unhook (SWT.Help, listener);
-}
-
-boolean sendHelpEvent (int helpType) {
- if (selectedItem != null && !selectedItem.isDisposed()) {
- if (selectedItem.hooks (SWT.Help)) {
- selectedItem.postEvent (SWT.Help);
- return true;
- }
- }
- if (hooks (SWT.Help)) {
- postEvent (SWT.Help);
- return true;
- }
- return parent.sendHelpEvent (helpType);
-}
-
+public void removeHelpListener (HelpListener listener) {
+ checkWidget();
+ if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+ if (eventTable == null) return;
+ eventTable.unhook (SWT.Help, listener);
+}
+
+boolean sendHelpEvent (int helpType) {
+ if (selectedItem != null && !selectedItem.isDisposed()) {
+ if (selectedItem.hooks (SWT.Help)) {
+ selectedItem.postEvent (SWT.Help);
+ return true;
+ }
+ }
+ if (hooks (SWT.Help)) {
+ postEvent (SWT.Help);
+ return true;
+ }
+ return parent.sendHelpEvent (helpType);
+}
+
/**
* Sets the default menu item to the argument or removes
* the default emphasis when the argument is <code>null</code>.
@@ -691,10 +691,10 @@ boolean sendHelpEvent (int helpType) {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public void setDefaultItem (MenuItem item) {
- checkWidget();
-}
-
+public void setDefaultItem (MenuItem item) {
+ checkWidget();
+}
+
/**
* Enables the receiver if the argument is <code>true</code>,
* and disables it otherwise. A disabled control is typically
@@ -708,15 +708,15 @@ public void setDefaultItem (MenuItem item) {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public void setEnabled (boolean enabled) {
- checkWidget();
- if (enabled) {
- OS.GTK_WIDGET_SET_FLAGS (handle, OS.GTK_SENSITIVE);
- } else {
- OS.GTK_WIDGET_UNSET_FLAGS (handle, OS.GTK_SENSITIVE);
- }
-}
-
+public void setEnabled (boolean enabled) {
+ checkWidget();
+ if (enabled) {
+ OS.GTK_WIDGET_SET_FLAGS (handle, OS.GTK_SENSITIVE);
+ } else {
+ OS.GTK_WIDGET_UNSET_FLAGS (handle, OS.GTK_SENSITIVE);
+ }
+}
+
/**
* Sets the receiver's location to the point specified by
* the arguments which are relative to the display.
@@ -733,20 +733,20 @@ public void setEnabled (boolean enabled) {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public void setLocation (int x, int y) {
- checkWidget();
- if ((style & (SWT.BAR | SWT.DROP_DOWN)) != 0) return;
- this.x = x;
- this.y = y;
- hasLocation = true;
-}
-
-public void setLocation (Point location) {
- checkWidget();
- if (location == null) error (SWT.ERROR_NULL_ARGUMENT);
- setLocation (location.x, location.y);
-}
-
+public void setLocation (int x, int y) {
+ checkWidget();
+ if ((style & (SWT.BAR | SWT.DROP_DOWN)) != 0) return;
+ this.x = x;
+ this.y = y;
+ hasLocation = true;
+}
+
+public void setLocation (Point location) {
+ checkWidget();
+ if (location == null) error (SWT.ERROR_NULL_ARGUMENT);
+ setLocation (location.x, location.y);
+}
+
/**
* Marks the receiver as visible if the argument is <code>true</code>,
* and marks it invisible otherwise.
@@ -763,26 +763,26 @@ public void setLocation (Point location) {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public void setVisible (boolean visible) {
- checkWidget();
- if ((style & (SWT.BAR | SWT.DROP_DOWN)) != 0) return;
- if (visible == OS.GTK_WIDGET_MAPPED (handle)) return;
- if (visible) {
- sendEvent (SWT.Show);
- if (getItemCount () != 0) {
- int address = 0;
- Callback GtkMenuPositionFunc = null;
- if (hasLocation) {
- GtkMenuPositionFunc = new Callback (this, "GtkMenuPositionFunc", 5);
- address = GtkMenuPositionFunc.getAddress ();
- }
- OS.gtk_menu_popup (handle, 0, 0, address, 0, 0, OS.gtk_get_current_event_time());
- if (GtkMenuPositionFunc != null) GtkMenuPositionFunc.dispose ();
- } else {
- sendEvent (SWT.Hide);
- }
- } else {
- OS.gtk_menu_popdown (handle);
- }
-}
-}
+public void setVisible (boolean visible) {
+ checkWidget();
+ if ((style & (SWT.BAR | SWT.DROP_DOWN)) != 0) return;
+ if (visible == OS.GTK_WIDGET_MAPPED (handle)) return;
+ if (visible) {
+ sendEvent (SWT.Show);
+ if (getItemCount () != 0) {
+ int address = 0;
+ Callback GtkMenuPositionFunc = null;
+ if (hasLocation) {
+ GtkMenuPositionFunc = new Callback (this, "GtkMenuPositionFunc", 5);
+ address = GtkMenuPositionFunc.getAddress ();
+ }
+ OS.gtk_menu_popup (handle, 0, 0, address, 0, 0, OS.gtk_get_current_event_time());
+ if (GtkMenuPositionFunc != null) GtkMenuPositionFunc.dispose ();
+ } else {
+ sendEvent (SWT.Hide);
+ }
+ } else {
+ OS.gtk_menu_popdown (handle);
+ }
+}
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/MenuItem.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/MenuItem.java
index 66fc22a16e..df4d279723 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/MenuItem.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/MenuItem.java
@@ -1,18 +1,18 @@
-package org.eclipse.swt.widgets;
-
-/*
+package org.eclipse.swt.widgets;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-import org.eclipse.swt.*;
-import org.eclipse.swt.internal.*;
-import org.eclipse.swt.internal.gtk.*;
-import org.eclipse.swt.graphics.*;
-import org.eclipse.swt.events.*;
-
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+import org.eclipse.swt.*;
+import org.eclipse.swt.internal.*;
+import org.eclipse.swt.internal.gtk.*;
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.events.*;
+
/**
* Instances of this class represent a selectable user interface object
* that issues notification when pressed and released.
@@ -29,10 +29,10 @@ import org.eclipse.swt.events.*;
* IMPORTANT: This class is <em>not</em> intended to be subclassed.
* </p>
*/
-public class MenuItem extends Item {
- Menu parent, menu;
- int accelerator;
-
+public class MenuItem extends Item {
+ Menu parent, menu;
+ int accelerator;
+
/**
* Constructs a new instance of this class given its parent
* (which must be a <code>Menu</code>) and a style value
@@ -67,12 +67,12 @@ public class MenuItem extends Item {
* @see Widget#checkSubclass
* @see Widget#getStyle
*/
-public MenuItem (Menu parent, int style) {
- super (parent, checkStyle (style));
- this.parent = parent;
- createWidget (parent.getItemCount ());
-}
-
+public MenuItem (Menu parent, int style) {
+ super (parent, checkStyle (style));
+ this.parent = parent;
+ createWidget (parent.getItemCount ());
+}
+
/**
* Constructs a new instance of this class given its parent
* (which must be a <code>Menu</code>), a style value
@@ -108,25 +108,25 @@ public MenuItem (Menu parent, int style) {
* @see Widget#checkSubclass
* @see Widget#getStyle
*/
-public MenuItem (Menu parent, int style, int index) {
- super (parent, checkStyle (style));
- this.parent = parent;
- int count = parent.getItemCount ();
- if (!(0 <= index && index <= count)) {
- error (SWT.ERROR_INVALID_RANGE);
- }
- createWidget (index);
-}
-
-void addAccelerator (int accelGroup) {
- updateAccelerator (accelGroup, true);
-}
-
-void addAccelerators (int accelGroup) {
- addAccelerator (accelGroup);
- if (menu != null) menu.addAccelerators (accelGroup);
-}
-
+public MenuItem (Menu parent, int style, int index) {
+ super (parent, checkStyle (style));
+ this.parent = parent;
+ int count = parent.getItemCount ();
+ if (!(0 <= index && index <= count)) {
+ error (SWT.ERROR_INVALID_RANGE);
+ }
+ createWidget (index);
+}
+
+void addAccelerator (int accelGroup) {
+ updateAccelerator (accelGroup, true);
+}
+
+void addAccelerators (int accelGroup) {
+ addAccelerator (accelGroup);
+ if (menu != null) menu.addAccelerators (accelGroup);
+}
+
/**
* Adds the listener to the collection of listeners who will
* be notified when the arm events are generated for the control, by sending
@@ -146,13 +146,13 @@ void addAccelerators (int accelGroup) {
* @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);
-}
-
+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
@@ -172,81 +172,81 @@ public void addArmListener (ArmListener listener) {
* @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.
- * <p>
- * When <code>widgetSelected</code> is called, the stateMask field of the event object is valid.
- * <code>widgetDefaultSelected</code> is not called.
- * </p>
- *
- * @param listener the listener which should be notified
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see SelectionListener
- * @see #removeSelectionListener
- * @see SelectionEvent
+public void 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.
+ * <p>
+ * When <code>widgetSelected</code> is called, the stateMask field of the event object is valid.
+ * <code>widgetDefaultSelected</code> is not called.
+ * </p>
+ *
+ * @param listener the listener which should be notified
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see SelectionListener
+ * @see #removeSelectionListener
+ * @see SelectionEvent
*/
-public void addSelectionListener (SelectionListener listener) {
- checkWidget();
- if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
- TypedListener typedListener = new TypedListener(listener);
- addListener (SWT.Selection,typedListener);
- addListener (SWT.DefaultSelection,typedListener);
-}
-
-static int checkStyle (int style) {
- return checkBits (style, SWT.PUSH, SWT.CHECK, SWT.RADIO, SWT.SEPARATOR, SWT.CASCADE, 0);
-}
-
-void createHandle (int index) {
- state |= HANDLE;
- byte [] buffer = new byte [1];
- int bits = SWT.CHECK | SWT.RADIO | SWT.PUSH | SWT.SEPARATOR;
- switch (style & bits) {
- case SWT.SEPARATOR:
- handle = OS.gtk_separator_menu_item_new ();
- break;
- case SWT.RADIO:
-// handle = OS.gtk_radio_menu_item_new_with_label (0, buffer);
-// break;
- case SWT.CHECK:
- handle = OS.gtk_check_menu_item_new_with_label (buffer);
- break;
- case SWT.PUSH:
- default:
- handle = OS.gtk_image_menu_item_new_with_label (buffer);
- break;
- }
- if (handle == 0) error (SWT.ERROR_NO_HANDLES);
- if ((style & SWT.SEPARATOR) == 0) {
- int label = OS.gtk_bin_get_child (handle);
- OS.gtk_accel_label_set_accel_widget (label, 0);
- }
- int parentHandle = parent.handle;
- boolean enabled = OS.GTK_WIDGET_SENSITIVE (parentHandle);
- if (!enabled) OS.GTK_WIDGET_SET_FLAGS (parentHandle, OS.GTK_SENSITIVE);
- OS.gtk_menu_shell_insert (parentHandle, handle, index);
- if (!enabled) OS.GTK_WIDGET_UNSET_FLAGS (parentHandle, OS.GTK_SENSITIVE);
- OS.gtk_widget_show (handle);
-}
-
+public void addSelectionListener (SelectionListener listener) {
+ checkWidget();
+ if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+ TypedListener typedListener = new TypedListener(listener);
+ addListener (SWT.Selection,typedListener);
+ addListener (SWT.DefaultSelection,typedListener);
+}
+
+static int checkStyle (int style) {
+ return checkBits (style, SWT.PUSH, SWT.CHECK, SWT.RADIO, SWT.SEPARATOR, SWT.CASCADE, 0);
+}
+
+void createHandle (int index) {
+ state |= HANDLE;
+ byte [] buffer = new byte [1];
+ int bits = SWT.CHECK | SWT.RADIO | SWT.PUSH | SWT.SEPARATOR;
+ switch (style & bits) {
+ case SWT.SEPARATOR:
+ handle = OS.gtk_separator_menu_item_new ();
+ break;
+ case SWT.RADIO:
+// handle = OS.gtk_radio_menu_item_new_with_label (0, buffer);
+// break;
+ case SWT.CHECK:
+ handle = OS.gtk_check_menu_item_new_with_label (buffer);
+ break;
+ case SWT.PUSH:
+ default:
+ handle = OS.gtk_image_menu_item_new_with_label (buffer);
+ break;
+ }
+ if (handle == 0) error (SWT.ERROR_NO_HANDLES);
+ if ((style & SWT.SEPARATOR) == 0) {
+ int label = OS.gtk_bin_get_child (handle);
+ OS.gtk_accel_label_set_accel_widget (label, 0);
+ }
+ int parentHandle = parent.handle;
+ boolean enabled = OS.GTK_WIDGET_SENSITIVE (parentHandle);
+ if (!enabled) OS.GTK_WIDGET_SET_FLAGS (parentHandle, OS.GTK_SENSITIVE);
+ OS.gtk_menu_shell_insert (parentHandle, handle, index);
+ if (!enabled) OS.GTK_WIDGET_UNSET_FLAGS (parentHandle, OS.GTK_SENSITIVE);
+ OS.gtk_widget_show (handle);
+}
+
/**
* Return the widget accelerator. An accelerator is the bit-wise
* OR of zero or more modifier masks and a key. Examples:
@@ -260,26 +260,26 @@ void createHandle (int index) {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public int getAccelerator () {
- checkWidget();
- return accelerator;
-}
-
-int getAccelGroup () {
- Menu menu = parent;
- while (menu != null && menu.cascade != null) {
- menu = menu.cascade.parent;
- }
- Decorations shell = menu.parent;
- return shell.menuBar == menu ? shell.accelGroup : 0;
-}
-
-public Display getDisplay () {
- Menu parent = this.parent;
- if (parent == null) error (SWT.ERROR_WIDGET_DISPOSED);
- return parent.getDisplay ();
-}
-
+public int getAccelerator () {
+ checkWidget();
+ return accelerator;
+}
+
+int getAccelGroup () {
+ Menu menu = parent;
+ while (menu != null && menu.cascade != null) {
+ menu = menu.cascade.parent;
+ }
+ Decorations shell = menu.parent;
+ return shell.menuBar == menu ? shell.accelGroup : 0;
+}
+
+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
@@ -293,11 +293,11 @@ public Display getDisplay () {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public boolean getEnabled () {
- checkWidget();
- return OS.GTK_WIDGET_SENSITIVE(handle);
-}
-
+public boolean getEnabled () {
+ checkWidget();
+ return OS.GTK_WIDGET_SENSITIVE(handle);
+}
+
/**
* Returns the receiver's cascade menu if it has one or null
* if it does not. Only <code>CASCADE</code> menu items can have
@@ -312,11 +312,11 @@ public boolean getEnabled () {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public Menu getMenu () {
- checkWidget();
- return menu;
-}
-
+public Menu getMenu () {
+ checkWidget();
+ return menu;
+}
+
/**
* Returns the receiver's parent, which must be a <code>Menu</code>.
*
@@ -327,11 +327,11 @@ public Menu getMenu () {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public Menu getParent () {
- checkWidget();
- return parent;
-}
-
+public Menu getParent () {
+ checkWidget();
+ return parent;
+}
+
/**
* Returns <code>true</code> if the receiver is selected,
* and false otherwise.
@@ -346,124 +346,124 @@ public Menu getParent () {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public boolean getSelection () {
- checkWidget();
- if ((style & (SWT.CHECK | SWT.RADIO)) == 0) return false;
- return OS.gtk_check_menu_item_get_active(handle);
-}
-
-int gtk_activate (int widget) {
- if ((style & SWT.CASCADE) != 0 && menu != null) return 0;
- /*
- * Bug in GTK. When an ancestor menu is disabled and
- * the user types an accelerator key, GTK delivers the
- * the activate signal even though the menu item cannot
- * be invoked using the mouse. The fix is to ignore activate
- * signals when an ancestor menu is disabled.
- */
- if (!isEnabled ()) return 0;
- Event event = new Event ();
- int ptr = OS.gtk_get_current_event ();
- if (ptr != 0) {
- GdkEvent gdkEvent = new GdkEvent ();
- OS.memmove (gdkEvent, ptr, GdkEvent.sizeof);
- switch (gdkEvent.type) {
- case OS.GDK_KEY_PRESS:
- case OS.GDK_KEY_RELEASE:
- case OS.GDK_BUTTON_PRESS:
- case OS.GDK_2BUTTON_PRESS:
- case OS.GDK_BUTTON_RELEASE: {
- int [] state = new int [1];
- OS.gdk_event_get_state (ptr, state);
- setInputState (event, state [0]);
- break;
- }
- }
- OS.gdk_event_free (ptr);
- }
- if ((style & SWT.RADIO) != 0) {
- if ((parent.getStyle () & SWT.NO_RADIO_GROUP) == 0) {
- selectRadio ();
- }
- }
- postEvent (SWT.Selection, event);
- return 0;
-}
-
-int gtk_select (int item) {
- parent.selectedItem = this;
- postEvent (SWT.Arm);
- return 0;
-}
-
-int gtk_show_help (int widget, int helpType) {
- boolean hooks = hooks (SWT.Help);
- if (hooks) {
- postEvent (SWT.Help);
- } else {
- hooks = parent.sendHelpEvent (helpType);
- }
- if (hooks) OS.gtk_menu_shell_deactivate (parent.handle);
- return 0;
-}
-
-void hookEvents () {
- super.hookEvents ();
- Display display = getDisplay ();
- int windowProc2 = display.windowProc2;
- int windowProc3 = display.windowProc3;
- OS.g_signal_connect (handle, OS.activate, windowProc2, ACTIVATE);
- OS.g_signal_connect (handle, OS.select, windowProc2, SELECT);
- OS.g_signal_connect (handle, OS.show_help, windowProc3, SHOW_HELP);
-}
-
-/**
- * Returns <code>true</code> if the receiver is enabled and all
- * of the receiver's ancestors are enabled, and <code>false</code>
- * otherwise. A disabled control is typically not selectable from the
- * user interface and draws with an inactive or "grayed" look.
- *
- * @return the receiver's enabled state
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see #getEnabled
+public boolean getSelection () {
+ checkWidget();
+ if ((style & (SWT.CHECK | SWT.RADIO)) == 0) return false;
+ return OS.gtk_check_menu_item_get_active(handle);
+}
+
+int gtk_activate (int widget) {
+ if ((style & SWT.CASCADE) != 0 && menu != null) return 0;
+ /*
+ * Bug in GTK. When an ancestor menu is disabled and
+ * the user types an accelerator key, GTK delivers the
+ * the activate signal even though the menu item cannot
+ * be invoked using the mouse. The fix is to ignore activate
+ * signals when an ancestor menu is disabled.
+ */
+ if (!isEnabled ()) return 0;
+ Event event = new Event ();
+ int ptr = OS.gtk_get_current_event ();
+ if (ptr != 0) {
+ GdkEvent gdkEvent = new GdkEvent ();
+ OS.memmove (gdkEvent, ptr, GdkEvent.sizeof);
+ switch (gdkEvent.type) {
+ case OS.GDK_KEY_PRESS:
+ case OS.GDK_KEY_RELEASE:
+ case OS.GDK_BUTTON_PRESS:
+ case OS.GDK_2BUTTON_PRESS:
+ case OS.GDK_BUTTON_RELEASE: {
+ int [] state = new int [1];
+ OS.gdk_event_get_state (ptr, state);
+ setInputState (event, state [0]);
+ break;
+ }
+ }
+ OS.gdk_event_free (ptr);
+ }
+ if ((style & SWT.RADIO) != 0) {
+ if ((parent.getStyle () & SWT.NO_RADIO_GROUP) == 0) {
+ selectRadio ();
+ }
+ }
+ postEvent (SWT.Selection, event);
+ return 0;
+}
+
+int gtk_select (int item) {
+ parent.selectedItem = this;
+ postEvent (SWT.Arm);
+ return 0;
+}
+
+int gtk_show_help (int widget, int helpType) {
+ boolean hooks = hooks (SWT.Help);
+ if (hooks) {
+ postEvent (SWT.Help);
+ } else {
+ hooks = parent.sendHelpEvent (helpType);
+ }
+ if (hooks) OS.gtk_menu_shell_deactivate (parent.handle);
+ return 0;
+}
+
+void hookEvents () {
+ super.hookEvents ();
+ Display display = getDisplay ();
+ int windowProc2 = display.windowProc2;
+ int windowProc3 = display.windowProc3;
+ OS.g_signal_connect (handle, OS.activate, windowProc2, ACTIVATE);
+ OS.g_signal_connect (handle, OS.select, windowProc2, SELECT);
+ OS.g_signal_connect (handle, OS.show_help, windowProc3, SHOW_HELP);
+}
+
+/**
+ * Returns <code>true</code> if the receiver is enabled and all
+ * of the receiver's ancestors are enabled, and <code>false</code>
+ * otherwise. A disabled control is typically not selectable from the
+ * user interface and draws with an inactive or "grayed" look.
+ *
+ * @return the receiver's enabled state
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see #getEnabled
*/
-public boolean isEnabled () {
- return getEnabled () && parent.isEnabled ();
-}
-
-void releaseChild () {
- super.releaseChild ();
- if (menu != null) {
- if (menu.selectedItem == this) menu.selectedItem = null;
- menu.dispose ();
- }
- menu = null;
-}
-
-void releaseWidget () {
- if (menu != null) menu.releaseResources ();
- menu = null;
- super.releaseWidget ();
- int accelGroup = getAccelGroup ();
- if (accelGroup != 0) removeAccelerator (accelGroup);
- accelerator = 0;
- parent = null;
-}
-
-void removeAccelerator (int accelGroup) {
- updateAccelerator (accelGroup, false);
-}
-
-void removeAccelerators (int accelGroup) {
- removeAccelerator (accelGroup);
- if (menu != null) menu.removeAccelerators (accelGroup);
-}
-
+public boolean isEnabled () {
+ return getEnabled () && parent.isEnabled ();
+}
+
+void releaseChild () {
+ super.releaseChild ();
+ if (menu != null) {
+ if (menu.selectedItem == this) menu.selectedItem = null;
+ menu.dispose ();
+ }
+ menu = null;
+}
+
+void releaseWidget () {
+ if (menu != null) menu.releaseResources ();
+ menu = null;
+ super.releaseWidget ();
+ int accelGroup = getAccelGroup ();
+ if (accelGroup != 0) removeAccelerator (accelGroup);
+ accelerator = 0;
+ parent = null;
+}
+
+void removeAccelerator (int accelGroup) {
+ updateAccelerator (accelGroup, false);
+}
+
+void removeAccelerators (int accelGroup) {
+ removeAccelerator (accelGroup);
+ if (menu != null) menu.removeAccelerators (accelGroup);
+}
+
/**
* Removes the listener from the collection of listeners who will
* be notified when the arm events are generated for the control.
@@ -481,13 +481,13 @@ void removeAccelerators (int accelGroup) {
* @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);
-}
-
+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.
@@ -505,13 +505,13 @@ public void removeArmListener (ArmListener listener) {
* @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);
-}
-
+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.
@@ -529,23 +529,23 @@ public void removeHelpListener (HelpListener listener) {
* @see SelectionListener
* @see #addSelectionListener
*/
-public void removeSelectionListener (SelectionListener listener) {
- checkWidget();
- if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
- if (eventTable == null) return;
- eventTable.unhook (SWT.Selection, listener);
- eventTable.unhook (SWT.DefaultSelection,listener);
-}
-void selectRadio () {
- int index = 0;
- MenuItem [] items = parent.getItems ();
- while (index < items.length && items [index] != this) index++;
- int i = index - 1;
- while (i >= 0 && items [i].setRadioSelection (false)) --i;
- int j = index + 1;
- while (j < items.length && items [j].setRadioSelection (false)) j++;
- setSelection (true);
-}
+public void removeSelectionListener (SelectionListener listener) {
+ checkWidget();
+ if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+ if (eventTable == null) return;
+ eventTable.unhook (SWT.Selection, listener);
+ eventTable.unhook (SWT.DefaultSelection,listener);
+}
+void selectRadio () {
+ int index = 0;
+ MenuItem [] items = parent.getItems ();
+ while (index < items.length && items [index] != this) index++;
+ int i = index - 1;
+ while (i >= 0 && items [i].setRadioSelection (false)) --i;
+ int j = index + 1;
+ while (j < items.length && items [j].setRadioSelection (false)) j++;
+ setSelection (true);
+}
/**
* Sets the widget accelerator. An accelerator is the bit-wise
* OR of zero or more modifier masks and a key. Examples:
@@ -559,15 +559,15 @@ void selectRadio () {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public void setAccelerator (int accelerator) {
- checkWidget();
- if (this.accelerator == accelerator) return;
- int accelGroup = getAccelGroup ();
- if (accelGroup != 0) removeAccelerator (accelGroup);
- this.accelerator = accelerator;
- if (accelGroup != 0) addAccelerator (accelGroup);
-}
-
+public void setAccelerator (int accelerator) {
+ checkWidget();
+ if (this.accelerator == accelerator) return;
+ int accelGroup = getAccelGroup ();
+ if (accelGroup != 0) removeAccelerator (accelGroup);
+ this.accelerator = accelerator;
+ if (accelGroup != 0) addAccelerator (accelGroup);
+}
+
/**
* Enables the receiver if the argument is <code>true</code>,
* and disables it otherwise. A disabled control is typically
@@ -581,11 +581,11 @@ public void setAccelerator (int accelerator) {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public void setEnabled (boolean enabled) {
- checkWidget();
- OS.gtk_widget_set_sensitive (handle, enabled);
-}
-
+public void setEnabled (boolean enabled) {
+ checkWidget();
+ OS.gtk_widget_set_sensitive (handle, enabled);
+}
+
/**
* Sets the image the receiver will display to the argument.
* <p>
@@ -599,20 +599,20 @@ public void setEnabled (boolean enabled) {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public void setImage (Image image) {
- checkWidget();
- if ((style & SWT.SEPARATOR) != 0) return;
- super.setImage (image);
- if ((style & SWT.PUSH) == 0) return;
- if (image != null) {
- int imageHandle = OS.gtk_image_new_from_pixmap (image.pixmap, image.mask);
- OS.gtk_image_menu_item_set_image (handle, imageHandle);
- OS.gtk_widget_show (imageHandle);
- } else {
- OS.gtk_image_menu_item_set_image (handle, 0);
- }
-}
-
+public void setImage (Image image) {
+ checkWidget();
+ if ((style & SWT.SEPARATOR) != 0) return;
+ super.setImage (image);
+ if ((style & SWT.PUSH) == 0) return;
+ if (image != null) {
+ int imageHandle = OS.gtk_image_new_from_pixmap (image.pixmap, image.mask);
+ OS.gtk_image_menu_item_set_image (handle, imageHandle);
+ OS.gtk_widget_show (imageHandle);
+ } else {
+ OS.gtk_image_menu_item_set_image (handle, 0);
+ }
+}
+
/**
* Sets the receiver's pull down menu to the argument.
* Only <code>CASCADE</code> menu items can have a
@@ -633,52 +633,52 @@ public void setImage (Image image) {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public void setMenu (Menu menu) {
- checkWidget ();
-
- /* Check to make sure the new menu is valid */
- if ((style & SWT.CASCADE) == 0) {
- error (SWT.ERROR_MENUITEM_NOT_CASCADE);
- }
- if (menu != null) {
- if ((menu.style & SWT.DROP_DOWN) == 0) {
- error (SWT.ERROR_MENU_NOT_DROP_DOWN);
- }
- if (menu.parent != parent.parent) {
- error (SWT.ERROR_INVALID_PARENT);
- }
- }
-
- /* Assign the new menu */
- Menu oldMenu = this.menu;
- if (oldMenu == menu) return;
- int accelGroup = getAccelGroup ();
- if (accelGroup != 0) removeAccelerators (accelGroup);
- if (oldMenu != null) {
- oldMenu.cascade = null;
- /*
- * Add a reference to the menu we are about
- * to replace or GTK will destroy it.
- */
- OS.g_object_ref (oldMenu.handle);
- OS.gtk_menu_item_remove_submenu (handle);
- }
- if ((this.menu = menu) != null) {
- menu.cascade = this;
- OS.gtk_menu_item_set_submenu (handle, menu.handle);
- }
- if (accelGroup != 0) addAccelerators (accelGroup);
-}
-
-boolean setRadioSelection (boolean value) {
- if ((style & SWT.RADIO) == 0) return false;
- if (getSelection () != value) {
- setSelection (value);
- postEvent (SWT.Selection);
- }
- return true;
-}
-
+public void setMenu (Menu menu) {
+ checkWidget ();
+
+ /* Check to make sure the new menu is valid */
+ if ((style & SWT.CASCADE) == 0) {
+ error (SWT.ERROR_MENUITEM_NOT_CASCADE);
+ }
+ if (menu != null) {
+ if ((menu.style & SWT.DROP_DOWN) == 0) {
+ error (SWT.ERROR_MENU_NOT_DROP_DOWN);
+ }
+ if (menu.parent != parent.parent) {
+ error (SWT.ERROR_INVALID_PARENT);
+ }
+ }
+
+ /* Assign the new menu */
+ Menu oldMenu = this.menu;
+ if (oldMenu == menu) return;
+ int accelGroup = getAccelGroup ();
+ if (accelGroup != 0) removeAccelerators (accelGroup);
+ if (oldMenu != null) {
+ oldMenu.cascade = null;
+ /*
+ * Add a reference to the menu we are about
+ * to replace or GTK will destroy it.
+ */
+ OS.g_object_ref (oldMenu.handle);
+ OS.gtk_menu_item_remove_submenu (handle);
+ }
+ if ((this.menu = menu) != null) {
+ menu.cascade = this;
+ OS.gtk_menu_item_set_submenu (handle, menu.handle);
+ }
+ if (accelGroup != 0) addAccelerators (accelGroup);
+}
+
+boolean setRadioSelection (boolean value) {
+ if ((style & SWT.RADIO) == 0) return false;
+ if (getSelection () != value) {
+ setSelection (value);
+ postEvent (SWT.Selection);
+ }
+ return true;
+}
+
/**
* Sets the selection state of the receiver.
* <p>
@@ -692,57 +692,57 @@ boolean setRadioSelection (boolean value) {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public void setSelection (boolean selected) {
- checkWidget();
- if ((style & (SWT.CHECK | SWT.RADIO)) == 0) return;
- OS.g_signal_handlers_block_matched (handle, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, ACTIVATE);
- OS.gtk_check_menu_item_set_active (handle, selected);
- OS.g_signal_handlers_unblock_matched (handle, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, ACTIVATE);
-}
-
-public void setText (String string) {
- checkWidget();
- if (string == null) error (SWT.ERROR_NULL_ARGUMENT);
- if ((style & SWT.SEPARATOR) != 0) return;
- super.setText (string);
- String accelString = "";
- int index = string.indexOf ('\t');
- if (index != -1) {
- accelString = string.substring (index, string.length());
- string = string.substring (0, index);
- }
- char [] chars = fixMnemonic (string);
- byte [] buffer = Converter.wcsToMbcs (null, chars, false);
- int label = OS.gtk_bin_get_child (handle);
- OS.gtk_label_set_text_with_mnemonic (label, buffer);
- buffer = Converter.wcsToMbcs (null, accelString, true);
- int ptr = OS.g_malloc (buffer.length);
- OS.memmove (ptr, buffer, buffer.length);
- int oldPtr = OS.GTK_ACCEL_LABEL_ACCEL_STRING (label);
- OS.GTK_ACCEL_LABEL_ACCEL_STRING (label, ptr);
- if (oldPtr != 0) OS.g_free (oldPtr);
-}
-
-void updateAccelerator (int accelGroup, boolean add) {
- if (accelerator == 0) return;
- int mask = 0;
- if ((accelerator & SWT.ALT) != 0) mask |= OS.GDK_MOD1_MASK;
- if ((accelerator & SWT.SHIFT) != 0) mask |= OS.GDK_SHIFT_MASK;
- if ((accelerator & SWT.CONTROL) != 0) mask |= OS.GDK_CONTROL_MASK;
- int keysym = accelerator & SWT.KEY_MASK;
- int newKey = Display.untranslateKey (keysym);
- if (newKey != 0) {
- keysym = newKey;
- } else {
- switch (keysym) {
- case '\r': keysym = OS.GDK_Return; break;
- default: keysym = wcsToMbcs ((char) keysym);
- }
- }
- if (add) {
- OS.gtk_widget_add_accelerator (handle, OS.activate, accelGroup, keysym, mask, OS.GTK_ACCEL_VISIBLE);
- } else {
- OS.gtk_widget_remove_accelerator (handle, accelGroup, keysym, mask);
- }
-}
-}
+public void setSelection (boolean selected) {
+ checkWidget();
+ if ((style & (SWT.CHECK | SWT.RADIO)) == 0) return;
+ OS.g_signal_handlers_block_matched (handle, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, ACTIVATE);
+ OS.gtk_check_menu_item_set_active (handle, selected);
+ OS.g_signal_handlers_unblock_matched (handle, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, ACTIVATE);
+}
+
+public void setText (String string) {
+ checkWidget();
+ if (string == null) error (SWT.ERROR_NULL_ARGUMENT);
+ if ((style & SWT.SEPARATOR) != 0) return;
+ super.setText (string);
+ String accelString = "";
+ int index = string.indexOf ('\t');
+ if (index != -1) {
+ accelString = string.substring (index, string.length());
+ string = string.substring (0, index);
+ }
+ char [] chars = fixMnemonic (string);
+ byte [] buffer = Converter.wcsToMbcs (null, chars, false);
+ int label = OS.gtk_bin_get_child (handle);
+ OS.gtk_label_set_text_with_mnemonic (label, buffer);
+ buffer = Converter.wcsToMbcs (null, accelString, true);
+ int ptr = OS.g_malloc (buffer.length);
+ OS.memmove (ptr, buffer, buffer.length);
+ int oldPtr = OS.GTK_ACCEL_LABEL_ACCEL_STRING (label);
+ OS.GTK_ACCEL_LABEL_ACCEL_STRING (label, ptr);
+ if (oldPtr != 0) OS.g_free (oldPtr);
+}
+
+void updateAccelerator (int accelGroup, boolean add) {
+ if (accelerator == 0) return;
+ int mask = 0;
+ if ((accelerator & SWT.ALT) != 0) mask |= OS.GDK_MOD1_MASK;
+ if ((accelerator & SWT.SHIFT) != 0) mask |= OS.GDK_SHIFT_MASK;
+ if ((accelerator & SWT.CONTROL) != 0) mask |= OS.GDK_CONTROL_MASK;
+ int keysym = accelerator & SWT.KEY_MASK;
+ int newKey = Display.untranslateKey (keysym);
+ if (newKey != 0) {
+ keysym = newKey;
+ } else {
+ switch (keysym) {
+ case '\r': keysym = OS.GDK_Return; break;
+ default: keysym = wcsToMbcs ((char) keysym);
+ }
+ }
+ if (add) {
+ OS.gtk_widget_add_accelerator (handle, OS.activate, accelGroup, keysym, mask, OS.GTK_ACCEL_VISIBLE);
+ } else {
+ OS.gtk_widget_remove_accelerator (handle, accelGroup, keysym, mask);
+ }
+}
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TabFolder.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TabFolder.java
index a8c7eef48d..06237750a3 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TabFolder.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TabFolder.java
@@ -1,43 +1,43 @@
-package org.eclipse.swt.widgets;
-
-/*
+package org.eclipse.swt.widgets;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-import org.eclipse.swt.*;
-import org.eclipse.swt.internal.gtk.*;
-import org.eclipse.swt.graphics.*;
-import org.eclipse.swt.events.*;
-
-/**
- * Instances of this class implement the notebook user interface
- * metaphor. It allows the user to select a notebook page from
- * set of pages.
- * <p>
- * The item children that may be added to instances of this class
- * must be of type <code>TabItem</code>.
- * <code>Control</code> children are created and then set into a
- * tab item using <code>TabItem#setControl</code>.
- * </p><p>
- * Note that although this class is a subclass of <code>Composite</code>,
- * it does not make sense to set a layout on it.
- * </p><p>
- * <dl>
- * <dt><b>Styles:</b></dt>
- * <dd>(none)</dd>
- * <dt><b>Events:</b></dt>
- * <dd>Selection</dd>
- * </dl>
- * <p>
- * IMPORTANT: This class is <em>not</em> intended to be subclassed.
- * </p>
+ * http://www.eclipse.org/legal/cpl-v10.html
*/
-public class TabFolder extends Composite {
- TabItem [] items;
-
+
+import org.eclipse.swt.*;
+import org.eclipse.swt.internal.gtk.*;
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.events.*;
+
+/**
+ * Instances of this class implement the notebook user interface
+ * metaphor. It allows the user to select a notebook page from
+ * set of pages.
+ * <p>
+ * The item children that may be added to instances of this class
+ * must be of type <code>TabItem</code>.
+ * <code>Control</code> children are created and then set into a
+ * tab item using <code>TabItem#setControl</code>.
+ * </p><p>
+ * Note that although this class is a subclass of <code>Composite</code>,
+ * it does not make sense to set a layout on it.
+ * </p><p>
+ * <dl>
+ * <dt><b>Styles:</b></dt>
+ * <dd>(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;
+
/**
* Constructs a new instance of this class given its parent
* and a style value describing its behavior and appearance.
@@ -66,233 +66,233 @@ public class TabFolder extends Composite {
* @see Widget#checkSubclass
* @see Widget#getStyle
*/
-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);
-}
-
-
-/**
- * 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.
- * <p>
- * When <code>widgetSelected</code> is called, the item field of the event object is valid.
- * <code>widgetDefaultSelected</code> is not called.
- * </p>
- *
- * @param listener the listener which should be notified
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see SelectionListener
- * @see #removeSelectionListener
- * @see SelectionEvent
+public 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);
+}
+
+
+/**
+ * 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.
+ * <p>
+ * When <code>widgetSelected</code> is called, the item field of the event object is valid.
+ * <code>widgetDefaultSelected</code> is not called.
+ * </p>
+ *
+ * @param listener the listener which should be notified
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see SelectionListener
+ * @see #removeSelectionListener
+ * @see SelectionEvent
*/
-public void addSelectionListener(SelectionListener listener) {
- checkWidget ();
- if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
- TypedListener typedListener = new TypedListener(listener);
- addListener(SWT.Selection,typedListener);
- addListener(SWT.DefaultSelection,typedListener);
-}
-
-int clientHandle () {
- int index = OS.gtk_notebook_get_current_page (handle);
- if (index != -1 && items [index] != null) {
- return items [index].pageHandle;
- }
- return handle;
-}
-
-public Point computeSize (int wHint, int hHint, boolean changed) {
- checkWidget ();
- int width = OS.GTK_WIDGET_WIDTH (fixedHandle);
- int height = OS.GTK_WIDGET_HEIGHT (fixedHandle);
- OS.gtk_widget_set_size_request (handle, wHint, hHint);
- GtkRequisition requisition = new GtkRequisition ();
- boolean scrollable = OS.gtk_notebook_get_scrollable (handle);
- OS.gtk_notebook_set_scrollable (handle, false);
- OS.gtk_widget_size_request (handle, requisition);
- OS.gtk_notebook_set_scrollable (handle, scrollable);
- OS.gtk_widget_set_size_request (handle, width, height);
- width = wHint == SWT.DEFAULT ? requisition.width : wHint;
- height = hHint == SWT.DEFAULT ? requisition.height : hHint;
- Point size;
- if (layout != null) {
- size = layout.computeSize (this, wHint, hHint, changed);
- } else {
- size = minimumSize (wHint, hHint, changed);
- }
- Rectangle trim = computeTrim (0, 0, size.x, size.y);
- size.x = trim.width; size.y = trim.height;
- 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);
- return new Point (width, height);
-}
-
-public Rectangle computeTrim (int x, int y, int width, int height) {
- checkWidget();
- int clientHandle = clientHandle ();
- int clientX = OS.GTK_WIDGET_X (clientHandle);
- int clientY = OS.GTK_WIDGET_Y (clientHandle);
- x -= clientX;
- y -= clientY;
- width += clientX + clientX;
- height += clientX + clientY;
- return new Rectangle (x, y, width, height);
-}
-
-void createHandle (int index) {
- state |= HANDLE;
- fixedHandle = OS.gtk_fixed_new ();
- if (fixedHandle == 0) error (SWT.ERROR_NO_HANDLES);
- OS.gtk_fixed_set_has_window (fixedHandle, true);
- handle = OS.gtk_notebook_new ();
- if (handle == 0) error (SWT.ERROR_NO_HANDLES);
- int parentHandle = parent.parentingHandle ();
- OS.gtk_container_add (parentHandle, fixedHandle);
- OS.gtk_container_add (fixedHandle, handle);
- OS.gtk_widget_show (handle);
- OS.gtk_widget_show (fixedHandle);
- OS.gtk_notebook_set_scrollable (handle, true);
- OS.gtk_notebook_set_show_tabs (handle, true);
-}
-
-void createWidget (int index) {
- super.createWidget(index);
- items = new TabItem [4];
-}
-
-void createItem (TabItem item, int index) {
- int list = OS.gtk_container_get_children (handle);
- int itemCount = 0;
- if (list != 0) {
- itemCount = OS.g_list_length (list);
- OS.g_list_free (list);
- }
- if (!(0 <= index && index <= itemCount)) error (SWT.ERROR_ITEM_NOT_ADDED);
- if (itemCount == items.length) {
- TabItem [] newItems = new TabItem [items.length + 4];
- System.arraycopy (items, 0, newItems, 0, items.length);
- items = newItems;
- }
- int boxHandle = OS.gtk_hbox_new (false, 0);
- if (boxHandle == 0) error (SWT.ERROR_NO_HANDLES);
- int labelHandle = OS.gtk_label_new_with_mnemonic (null);
- if (labelHandle == 0) error (SWT.ERROR_NO_HANDLES);
- int imageHandle = OS.gtk_image_new ();
- if (imageHandle == 0) error (SWT.ERROR_NO_HANDLES);
- OS.gtk_container_add (boxHandle, imageHandle);
- OS.gtk_container_add (boxHandle, labelHandle);
- int pageHandle = OS.gtk_fixed_new ();
- if (pageHandle == 0) error (SWT.ERROR_NO_HANDLES);
- OS.g_signal_handlers_block_matched (handle, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, SWITCH_PAGE);
- OS.gtk_notebook_insert_page (handle, pageHandle, boxHandle, index);
- OS.g_signal_handlers_unblock_matched (handle, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, SWITCH_PAGE);
- OS.gtk_widget_show (boxHandle);
- OS.gtk_widget_show (labelHandle);
- OS.gtk_widget_show (pageHandle);
- item.state |= HANDLE;
- item.handle = boxHandle;
- item.labelHandle = labelHandle;
- item.imageHandle = imageHandle;
- item.pageHandle = pageHandle;
- System.arraycopy (items, index, items, index + 1, itemCount++ - index);
- items [index] = item;
- item.setForegroundColor (getForegroundColor ());
- item.setFontDescription (getFontDescription ());
- if (itemCount == 1) {
- fixPage ();
- Event event = new Event();
- event.item = items[0];
- sendEvent (SWT.Selection, event);
- // the widget could be destroyed at this point
- }
-}
-
-void fixPage () {
- /*
- * Feature in GTK. For some reason, the positioning of
- * tab labels and pages become corrupted when when there
- * is no current page. The fix is to force the notebook
- * to resize which causes the current page to be set.
- */
-// int index = OS.gtk_notebook_get_current_page (handle);
-// if (index != -1) return;
- OS.g_signal_handlers_block_matched (handle, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, SWITCH_PAGE);
- int flags = OS.GTK_WIDGET_FLAGS (handle);
- OS.GTK_WIDGET_SET_FLAGS(handle, OS.GTK_VISIBLE);
- GtkRequisition requisition = new GtkRequisition ();
- OS.gtk_widget_size_request (handle, requisition);
- OS.gtk_container_resize_children (handle);
- if ((flags & OS.GTK_VISIBLE) == 0) {
- OS.GTK_WIDGET_UNSET_FLAGS(handle, OS.GTK_VISIBLE);
- }
- OS.g_signal_handlers_unblock_matched (handle, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, SWITCH_PAGE);
-}
-
-void destroyItem (TabItem item) {
- int index = 0;
- int itemCount = getItemCount();
- while (index < itemCount) {
- if (items [index] == item) break;
- index++;
- }
- if (index == itemCount) error (SWT.ERROR_ITEM_NOT_REMOVED);
- int oldIndex = OS.gtk_notebook_get_current_page (handle);
- OS.g_signal_handlers_block_matched (handle, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, SWITCH_PAGE);
- OS.gtk_notebook_remove_page (handle, index);
- OS.g_signal_handlers_unblock_matched (handle, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, SWITCH_PAGE);
- System.arraycopy (items, index + 1, items, index, --itemCount - index);
- items [itemCount] = null;
- item.handle = 0;
- if (index == oldIndex) {
- fixPage ();
- int newIndex = OS.gtk_notebook_get_current_page (handle);
- if (newIndex != -1) {
- Control control = items [newIndex].getControl ();
- if (control != null && !control.isDisposed ()) {
- control.setBounds (getClientArea());
- control.setVisible (true);
- }
- Event event = new Event ();
- event.item = items [newIndex];
- sendEvent (SWT.Selection, event);
- // the widget could be destroyed at this point
- }
- }
-}
-
-void enableWidget (boolean enabled) {
- OS.gtk_widget_set_sensitive (handle, enabled);
-}
-
-int eventHandle () {
- return fixedHandle;
-}
-
+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 clientHandle () {
+ int index = OS.gtk_notebook_get_current_page (handle);
+ if (index != -1 && items [index] != null) {
+ return items [index].pageHandle;
+ }
+ return handle;
+}
+
+public Point computeSize (int wHint, int hHint, boolean changed) {
+ checkWidget ();
+ int width = OS.GTK_WIDGET_WIDTH (fixedHandle);
+ int height = OS.GTK_WIDGET_HEIGHT (fixedHandle);
+ OS.gtk_widget_set_size_request (handle, wHint, hHint);
+ GtkRequisition requisition = new GtkRequisition ();
+ boolean scrollable = OS.gtk_notebook_get_scrollable (handle);
+ OS.gtk_notebook_set_scrollable (handle, false);
+ OS.gtk_widget_size_request (handle, requisition);
+ OS.gtk_notebook_set_scrollable (handle, scrollable);
+ OS.gtk_widget_set_size_request (handle, width, height);
+ width = wHint == SWT.DEFAULT ? requisition.width : wHint;
+ height = hHint == SWT.DEFAULT ? requisition.height : hHint;
+ Point size;
+ if (layout != null) {
+ size = layout.computeSize (this, wHint, hHint, changed);
+ } else {
+ size = minimumSize (wHint, hHint, changed);
+ }
+ Rectangle trim = computeTrim (0, 0, size.x, size.y);
+ size.x = trim.width; size.y = trim.height;
+ 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);
+ return new Point (width, height);
+}
+
+public Rectangle computeTrim (int x, int y, int width, int height) {
+ checkWidget();
+ int clientHandle = clientHandle ();
+ int clientX = OS.GTK_WIDGET_X (clientHandle);
+ int clientY = OS.GTK_WIDGET_Y (clientHandle);
+ x -= clientX;
+ y -= clientY;
+ width += clientX + clientX;
+ height += clientX + clientY;
+ return new Rectangle (x, y, width, height);
+}
+
+void createHandle (int index) {
+ state |= HANDLE;
+ fixedHandle = OS.gtk_fixed_new ();
+ if (fixedHandle == 0) error (SWT.ERROR_NO_HANDLES);
+ OS.gtk_fixed_set_has_window (fixedHandle, true);
+ handle = OS.gtk_notebook_new ();
+ if (handle == 0) error (SWT.ERROR_NO_HANDLES);
+ int parentHandle = parent.parentingHandle ();
+ OS.gtk_container_add (parentHandle, fixedHandle);
+ OS.gtk_container_add (fixedHandle, handle);
+ OS.gtk_widget_show (handle);
+ OS.gtk_widget_show (fixedHandle);
+ OS.gtk_notebook_set_scrollable (handle, true);
+ OS.gtk_notebook_set_show_tabs (handle, true);
+}
+
+void createWidget (int index) {
+ super.createWidget(index);
+ items = new TabItem [4];
+}
+
+void createItem (TabItem item, int index) {
+ int list = OS.gtk_container_get_children (handle);
+ int itemCount = 0;
+ if (list != 0) {
+ itemCount = OS.g_list_length (list);
+ OS.g_list_free (list);
+ }
+ if (!(0 <= index && index <= itemCount)) error (SWT.ERROR_ITEM_NOT_ADDED);
+ if (itemCount == items.length) {
+ TabItem [] newItems = new TabItem [items.length + 4];
+ System.arraycopy (items, 0, newItems, 0, items.length);
+ items = newItems;
+ }
+ int boxHandle = OS.gtk_hbox_new (false, 0);
+ if (boxHandle == 0) error (SWT.ERROR_NO_HANDLES);
+ int labelHandle = OS.gtk_label_new_with_mnemonic (null);
+ if (labelHandle == 0) error (SWT.ERROR_NO_HANDLES);
+ int imageHandle = OS.gtk_image_new ();
+ if (imageHandle == 0) error (SWT.ERROR_NO_HANDLES);
+ OS.gtk_container_add (boxHandle, imageHandle);
+ OS.gtk_container_add (boxHandle, labelHandle);
+ int pageHandle = OS.gtk_fixed_new ();
+ if (pageHandle == 0) error (SWT.ERROR_NO_HANDLES);
+ OS.g_signal_handlers_block_matched (handle, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, SWITCH_PAGE);
+ OS.gtk_notebook_insert_page (handle, pageHandle, boxHandle, index);
+ OS.g_signal_handlers_unblock_matched (handle, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, SWITCH_PAGE);
+ OS.gtk_widget_show (boxHandle);
+ OS.gtk_widget_show (labelHandle);
+ OS.gtk_widget_show (pageHandle);
+ item.state |= HANDLE;
+ item.handle = boxHandle;
+ item.labelHandle = labelHandle;
+ item.imageHandle = imageHandle;
+ item.pageHandle = pageHandle;
+ System.arraycopy (items, index, items, index + 1, itemCount++ - index);
+ items [index] = item;
+ item.setForegroundColor (getForegroundColor ());
+ item.setFontDescription (getFontDescription ());
+ if (itemCount == 1) {
+ fixPage ();
+ Event event = new Event();
+ event.item = items[0];
+ sendEvent (SWT.Selection, event);
+ // the widget could be destroyed at this point
+ }
+}
+
+void fixPage () {
+ /*
+ * Feature in GTK. For some reason, the positioning of
+ * tab labels and pages become corrupted when when there
+ * is no current page. The fix is to force the notebook
+ * to resize which causes the current page to be set.
+ */
+// int index = OS.gtk_notebook_get_current_page (handle);
+// if (index != -1) return;
+ OS.g_signal_handlers_block_matched (handle, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, SWITCH_PAGE);
+ int flags = OS.GTK_WIDGET_FLAGS (handle);
+ OS.GTK_WIDGET_SET_FLAGS(handle, OS.GTK_VISIBLE);
+ GtkRequisition requisition = new GtkRequisition ();
+ OS.gtk_widget_size_request (handle, requisition);
+ OS.gtk_container_resize_children (handle);
+ if ((flags & OS.GTK_VISIBLE) == 0) {
+ OS.GTK_WIDGET_UNSET_FLAGS(handle, OS.GTK_VISIBLE);
+ }
+ OS.g_signal_handlers_unblock_matched (handle, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, SWITCH_PAGE);
+}
+
+void destroyItem (TabItem item) {
+ int index = 0;
+ int itemCount = getItemCount();
+ while (index < itemCount) {
+ if (items [index] == item) break;
+ index++;
+ }
+ if (index == itemCount) error (SWT.ERROR_ITEM_NOT_REMOVED);
+ int oldIndex = OS.gtk_notebook_get_current_page (handle);
+ OS.g_signal_handlers_block_matched (handle, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, SWITCH_PAGE);
+ OS.gtk_notebook_remove_page (handle, index);
+ OS.g_signal_handlers_unblock_matched (handle, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, SWITCH_PAGE);
+ System.arraycopy (items, index + 1, items, index, --itemCount - index);
+ items [itemCount] = null;
+ item.handle = 0;
+ if (index == oldIndex) {
+ fixPage ();
+ int newIndex = OS.gtk_notebook_get_current_page (handle);
+ if (newIndex != -1) {
+ Control control = items [newIndex].getControl ();
+ if (control != null && !control.isDisposed ()) {
+ control.setBounds (getClientArea());
+ control.setVisible (true);
+ }
+ Event event = new Event ();
+ event.item = items [newIndex];
+ sendEvent (SWT.Selection, event);
+ // the widget could be destroyed at this point
+ }
+ }
+}
+
+void enableWidget (boolean enabled) {
+ OS.gtk_widget_set_sensitive (handle, enabled);
+}
+
+int eventHandle () {
+ return fixedHandle;
+}
+
/**
* Returns the item at the given, zero-relative index in the
* receiver. Throws an exception if the index is out of range.
@@ -308,17 +308,17 @@ int eventHandle () {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public TabItem getItem (int index) {
- checkWidget();
- if (!(0 <= index && index < getItemCount())) error (SWT.ERROR_INVALID_RANGE);
- int list = OS.gtk_container_get_children (handle);
- if (list == 0) error (SWT.ERROR_CANNOT_GET_ITEM);
- int itemCount = OS.g_list_length (list);
- OS.g_list_free (list);
- if (!(0 <= index && index < itemCount)) error (SWT.ERROR_CANNOT_GET_ITEM);
- return items [index];
-}
-
+public TabItem getItem (int index) {
+ checkWidget();
+ if (!(0 <= index && index < getItemCount())) error (SWT.ERROR_INVALID_RANGE);
+ int list = OS.gtk_container_get_children (handle);
+ if (list == 0) error (SWT.ERROR_CANNOT_GET_ITEM);
+ int itemCount = OS.g_list_length (list);
+ OS.g_list_free (list);
+ if (!(0 <= index && index < itemCount)) error (SWT.ERROR_CANNOT_GET_ITEM);
+ return items [index];
+}
+
/**
* Returns the number of items contained in the receiver.
*
@@ -329,15 +329,15 @@ public TabItem getItem (int index) {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public int getItemCount () {
- checkWidget();
- int list = OS.gtk_container_get_children (handle);
- if (list == 0) return 0;
- int itemCount = OS.g_list_length (list);
- OS.g_list_free (list);
- return itemCount;
-}
-
+public int getItemCount () {
+ checkWidget();
+ int list = OS.gtk_container_get_children (handle);
+ if (list == 0) return 0;
+ int itemCount = OS.g_list_length (list);
+ OS.g_list_free (list);
+ return itemCount;
+}
+
/**
* Returns an array of <code>TabItem</code>s which are the items
* in the receiver.
@@ -354,14 +354,14 @@ public int getItemCount () {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public TabItem [] getItems () {
- checkWidget();
- int count = getItemCount ();
- TabItem [] result = new TabItem [count];
- System.arraycopy (items, 0, result, 0, count);
- return result;
-}
-
+public TabItem [] getItems () {
+ checkWidget();
+ int count = getItemCount ();
+ TabItem [] result = new TabItem [count];
+ System.arraycopy (items, 0, result, 0, count);
+ return result;
+}
+
/**
* Returns an array of <code>TabItem</code>s that are currently
* selected in the receiver. An empty array indicates that no
@@ -378,13 +378,13 @@ public TabItem [] getItems () {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public TabItem [] getSelection () {
- checkWidget();
- int index = OS.gtk_notebook_get_current_page (handle);
- if (index == -1) return new TabItem [0];
- return new TabItem [] {items [index]};
-}
-
+public TabItem [] getSelection () {
+ checkWidget();
+ int index = OS.gtk_notebook_get_current_page (handle);
+ if (index == -1) return new TabItem [0];
+ return new TabItem [] {items [index]};
+}
+
/**
* Returns the zero-relative index of the item which is currently
* selected in the receiver, or -1 if no item is selected.
@@ -396,36 +396,36 @@ public TabItem [] getSelection () {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public int getSelectionIndex () {
- checkWidget();
- return OS.gtk_notebook_get_current_page (handle);
-}
-
-int gtk_switch_page (int widget, int page, int page_num) {
- int index = OS.gtk_notebook_get_current_page (handle);
- if (index != -1) {
- Control control = items [index].getControl ();
- if (control != null && !control.isDisposed ()) {
- control.setVisible (false);
- }
- }
- Control control = items [page_num].getControl ();
- if (control != null && !control.isDisposed ()) {
- control.setBounds(getClientArea());
- control.setVisible (true);
- }
- Event event = new Event();
- event.item = items[page_num];
- postEvent(SWT.Selection, event);
- return 0;
-}
-
-void hookEvents () {
- super.hookEvents ();
- Display display = getDisplay ();
- OS.g_signal_connect (handle, OS.switch_page, display.windowProc4, SWITCH_PAGE);
-}
-
+public int getSelectionIndex () {
+ checkWidget();
+ return OS.gtk_notebook_get_current_page (handle);
+}
+
+int gtk_switch_page (int widget, int page, int page_num) {
+ int index = OS.gtk_notebook_get_current_page (handle);
+ if (index != -1) {
+ Control control = items [index].getControl ();
+ if (control != null && !control.isDisposed ()) {
+ control.setVisible (false);
+ }
+ }
+ Control control = items [page_num].getControl ();
+ if (control != null && !control.isDisposed ()) {
+ control.setBounds(getClientArea());
+ control.setVisible (true);
+ }
+ Event event = new Event();
+ event.item = items[page_num];
+ postEvent(SWT.Selection, event);
+ return 0;
+}
+
+void hookEvents () {
+ super.hookEvents ();
+ Display display = getDisplay ();
+ OS.g_signal_connect (handle, OS.switch_page, display.windowProc4, SWITCH_PAGE);
+}
+
/**
* Searches the receiver's list starting at the first item
* (index 0) until an item is found that is equal to the
@@ -443,58 +443,58 @@ void hookEvents () {
* <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 list = OS.gtk_container_get_children (handle);
- if (list == 0) return -1;
- int count = OS.g_list_length (list);
- OS.g_list_free (list);
- for (int i=0; i<count; i++) {
- if (items [i] == item) return i;
- }
- return -1;
-}
-
-Point minimumSize (int wHint, int hHint, boolean flushCache) {
- Control [] children = _getChildren ();
- int width = 0, height = 0;
- for (int i=0; i<children.length; i++) {
- Control child = children [i];
- int index = 0;
- int count = 0;
- int list = OS.gtk_container_get_children (handle);
- if (list != 0) {
- count = OS.g_list_length (list);
- OS.g_list_free (list);
- }
- while (index < count) {
- if (items [index].control == child) break;
- index++;
- }
- if (index == count) {
- Rectangle rect = child.getBounds ();
- width = Math.max (width, rect.x + rect.width);
- height = Math.max (height, rect.y + rect.height);
- } else {
- Point size = child.computeSize (wHint, hHint, flushCache);
- width = Math.max (width, size.x);
- height = Math.max (height, size.y);
- }
- }
- return new Point (width, height);
-}
-
-void releaseWidget () {
- int count = getItemCount ();
- for (int i=0; i<count; i++) {
- TabItem item = items [i];
- if (!item.isDisposed ()) item.releaseResources ();
- }
- items = null;
- super.releaseWidget ();
-}
-
+public int indexOf (TabItem item) {
+ checkWidget();
+ if (item == null) error (SWT.ERROR_NULL_ARGUMENT);
+ int list = OS.gtk_container_get_children (handle);
+ if (list == 0) return -1;
+ int count = OS.g_list_length (list);
+ OS.g_list_free (list);
+ for (int i=0; i<count; i++) {
+ if (items [i] == item) return i;
+ }
+ return -1;
+}
+
+Point minimumSize (int wHint, int hHint, boolean flushCache) {
+ Control [] children = _getChildren ();
+ int width = 0, height = 0;
+ for (int i=0; i<children.length; i++) {
+ Control child = children [i];
+ int index = 0;
+ int count = 0;
+ int list = OS.gtk_container_get_children (handle);
+ if (list != 0) {
+ count = OS.g_list_length (list);
+ OS.g_list_free (list);
+ }
+ while (index < count) {
+ if (items [index].control == child) break;
+ index++;
+ }
+ if (index == count) {
+ Rectangle rect = child.getBounds ();
+ width = Math.max (width, rect.x + rect.width);
+ height = Math.max (height, rect.y + rect.height);
+ } else {
+ Point size = child.computeSize (wHint, hHint, flushCache);
+ width = Math.max (width, size.x);
+ height = Math.max (height, size.y);
+ }
+ }
+ return new Point (width, height);
+}
+
+void releaseWidget () {
+ int count = getItemCount ();
+ for (int i=0; i<count; i++) {
+ TabItem item = items [i];
+ if (!item.isDisposed ()) item.releaseResources ();
+ }
+ items = null;
+ super.releaseWidget ();
+}
+
/**
* Removes the listener from the collection of listeners who will
* be notified when the receiver's selection changes.
@@ -512,49 +512,49 @@ void releaseWidget () {
* @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);
-}
-
-boolean setBounds (int x, int y, int width, int height, boolean move, boolean resize) {
- boolean changed = super.setBounds (x, y, width, height, move, resize);
- if (changed && resize) {
- int index = getSelectionIndex ();
- if (index != -1) {
- TabItem item = items [index];
- Control control = item.control;
- if (control != null && !control.isDisposed ()) {
- control.setBounds (getClientArea ());
- }
- }
- }
- return changed;
-}
-
-void setFontDescription (int font) {
- super.setFontDescription (font);
- TabItem [] items = getItems ();
- for (int i = 0; i < items.length; i++) {
- if (items[i] != null) {
- items[i].setFontDescription (font);
- }
- }
-}
-
-void setForegroundColor (GdkColor color) {
- super.setForegroundColor (color);
- TabItem [] items = getItems ();
- for (int i = 0; i < items.length; i++) {
- if (items[i] != null) {
- items[i].setForegroundColor (color);
- }
- }
-}
-
+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);
+}
+
+boolean setBounds (int x, int y, int width, int height, boolean move, boolean resize) {
+ boolean changed = super.setBounds (x, y, width, height, move, resize);
+ if (changed && resize) {
+ int index = getSelectionIndex ();
+ if (index != -1) {
+ TabItem item = items [index];
+ Control control = item.control;
+ if (control != null && !control.isDisposed ()) {
+ control.setBounds (getClientArea ());
+ }
+ }
+ }
+ return changed;
+}
+
+void setFontDescription (int font) {
+ super.setFontDescription (font);
+ TabItem [] items = getItems ();
+ for (int i = 0; i < items.length; i++) {
+ if (items[i] != null) {
+ items[i].setFontDescription (font);
+ }
+ }
+}
+
+void setForegroundColor (GdkColor color) {
+ super.setForegroundColor (color);
+ TabItem [] items = getItems ();
+ for (int i = 0; i < items.length; i++) {
+ if (items[i] != null) {
+ items[i].setForegroundColor (color);
+ }
+ }
+}
+
/**
* Selects the item at the given zero-relative index in the receiver.
* If the item at the index was already selected, it remains selected.
@@ -568,40 +568,40 @@ void setForegroundColor (GdkColor color) {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public void setSelection (int index) {
- checkWidget ();
- setSelection (index, false);
-}
-
-void setSelection (int index, boolean notify) {
- if (index < 0) return;
- int oldIndex = OS.gtk_notebook_get_current_page (handle);
- if (oldIndex != -1) {
- TabItem item = items [oldIndex];
- Control control = item.control;
- if (control != null && !control.isDisposed ()) {
- control.setVisible (false);
- }
- }
- OS.g_signal_handlers_block_matched (handle, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, SWITCH_PAGE);
- OS.gtk_notebook_set_current_page (handle, index);
- OS.g_signal_handlers_unblock_matched (handle, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, SWITCH_PAGE);
- int newIndex = OS.gtk_notebook_get_current_page (handle);
- if (newIndex != -1) {
- TabItem item = items [newIndex];
- Control control = item.control;
- if (control != null && !control.isDisposed ()) {
- control.setBounds (getClientArea ());
- control.setVisible (true);
- }
- if (notify) {
- Event event = new Event ();
- event.item = item;
- sendEvent (SWT.Selection, event);
- }
- }
-}
-
+public void setSelection (int index) {
+ checkWidget ();
+ setSelection (index, false);
+}
+
+void setSelection (int index, boolean notify) {
+ if (index < 0) return;
+ int oldIndex = OS.gtk_notebook_get_current_page (handle);
+ if (oldIndex != -1) {
+ TabItem item = items [oldIndex];
+ Control control = item.control;
+ if (control != null && !control.isDisposed ()) {
+ control.setVisible (false);
+ }
+ }
+ OS.g_signal_handlers_block_matched (handle, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, SWITCH_PAGE);
+ OS.gtk_notebook_set_current_page (handle, index);
+ OS.g_signal_handlers_unblock_matched (handle, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, SWITCH_PAGE);
+ int newIndex = OS.gtk_notebook_get_current_page (handle);
+ if (newIndex != -1) {
+ TabItem item = items [newIndex];
+ Control control = item.control;
+ if (control != null && !control.isDisposed ()) {
+ control.setBounds (getClientArea ());
+ control.setVisible (true);
+ }
+ if (notify) {
+ Event event = new Event ();
+ event.item = item;
+ sendEvent (SWT.Selection, event);
+ }
+ }
+}
+
/**
* Sets the receiver's selection to be the given array of items.
* The current selected is first cleared, then the new items are
@@ -614,17 +614,17 @@ void setSelection (int index, boolean notify) {
* <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);
- }
-}
-
-}
+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);
+ }
+}
+
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TabItem.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TabItem.java
index 4d97d71115..b1b55d03c2 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TabItem.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TabItem.java
@@ -1,17 +1,17 @@
-package org.eclipse.swt.widgets;
-
-/*
+package org.eclipse.swt.widgets;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-import org.eclipse.swt.*;
-import org.eclipse.swt.internal.*;
-import org.eclipse.swt.internal.gtk.*;
-import org.eclipse.swt.graphics.*;
-
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+import org.eclipse.swt.*;
+import org.eclipse.swt.internal.*;
+import org.eclipse.swt.internal.gtk.*;
+import org.eclipse.swt.graphics.*;
+
/**
* Instances of this class represent a selectable user interface object
* corresponding to a tab for a page in a tab folder.
@@ -25,12 +25,12 @@ import org.eclipse.swt.graphics.*;
* IMPORTANT: This class is <em>not</em> intended to be subclassed.
* </p>
*/
-public class TabItem extends Item {
- int labelHandle, imageHandle, pageHandle;
- Control control;
- TabFolder parent;
- String toolTipText;
-
+public class TabItem extends Item {
+ int labelHandle, imageHandle, pageHandle;
+ Control control;
+ TabFolder parent;
+ String toolTipText;
+
/**
* Constructs a new instance of this class given its parent
* (which must be a <code>TabFolder</code>) and a style value
@@ -61,12 +61,12 @@ public class TabItem extends Item {
* @see Widget#checkSubclass
* @see Widget#getStyle
*/
-public TabItem (TabFolder parent, int style) {
- super (parent, style);
- this.parent = parent;
- parent.createItem (this, parent.getItemCount ());
-}
-
+public TabItem (TabFolder 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>TabFolder</code>), a style value
@@ -98,12 +98,12 @@ public TabItem (TabFolder parent, int style) {
* @see Widget#checkSubclass
* @see Widget#getStyle
*/
-public TabItem (TabFolder parent, int style, int index) {
- super (parent, style);
- this.parent = parent;
- parent.createItem (this, index);
-}
-
+public TabItem (TabFolder parent, int style, int index) {
+ super (parent, style);
+ this.parent = parent;
+ parent.createItem (this, index);
+}
+
/**
* Returns the control that is used to fill the client area of
* the tab folder when the user selects the tab item. If no
@@ -116,17 +116,17 @@ public TabItem (TabFolder parent, int style, int index) {
* <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 ();
-}
-
+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>.
*
@@ -137,11 +137,11 @@ public Display getDisplay () {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public TabFolder getParent () {
- checkWidget ();
- return parent;
-}
-
+public TabFolder getParent () {
+ checkWidget ();
+ return parent;
+}
+
/**
* Returns the receiver's tool tip text, or null if it has
* not been set.
@@ -153,30 +153,30 @@ public TabFolder getParent () {
* <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 releaseHandle () {
- super.releaseHandle ();
- pageHandle = labelHandle = imageHandle = 0;
-}
-
-void releaseWidget () {
- super.releaseWidget ();
- parent = null;
-}
-
+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 releaseHandle () {
+ super.releaseHandle ();
+ pageHandle = labelHandle = imageHandle = 0;
+}
+
+void releaseWidget () {
+ super.releaseWidget ();
+ parent = null;
+}
+
/**
* Sets the control that is used to fill the client area of
* the tab folder when the user selects the tab item.
@@ -192,60 +192,60 @@ void releaseWidget () {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public void setControl (Control control) {
- checkWidget ();
- Control oldControl = this.control, newControl = control;
- this.control = control;
- int index = parent.indexOf (this);
- if (index != parent.getSelectionIndex ()) {
- if (newControl != null) newControl.setVisible (false);
- return;
- }
- if (newControl != null) {
- newControl.setBounds (parent.getClientArea ());
- newControl.setVisible (true);
- }
- if (oldControl != null) oldControl.setVisible (false);
-}
-
-void setFontDescription (int font) {
- OS.gtk_widget_modify_font (labelHandle, font);
- OS.gtk_widget_modify_font (imageHandle, font);
-}
-
-void setForegroundColor (GdkColor color) {
- OS.gtk_widget_modify_fg (labelHandle, 0, color);
- OS.gtk_widget_modify_fg (imageHandle, 0, color);
-}
-
-public void setImage (Image image) {
- checkWidget ();
- super.setImage (image);
- if (image != null) {
- OS.gtk_image_set_from_pixmap (imageHandle, image.pixmap, image.mask);
- OS.gtk_widget_show (imageHandle);
- } else {
- OS.gtk_image_set_from_pixmap (imageHandle, 0, 0);
- OS.gtk_widget_hide (imageHandle);
- }
- parent.fixPage ();
-}
-
-public void setText (String string) {
- checkWidget ();
- if (string == null) error (SWT.ERROR_NULL_ARGUMENT);
- super.setText (string);
- char [] chars = fixMnemonic (string);
- byte [] buffer = Converter.wcsToMbcs (null, chars, false);
- OS.gtk_label_set_text_with_mnemonic (labelHandle, buffer);
- if (string.length () != 0) {
- OS.gtk_widget_show (labelHandle);
- } else {
- OS.gtk_widget_hide (labelHandle);
- }
- parent.fixPage ();
-}
-
+public void setControl (Control control) {
+ checkWidget ();
+ Control oldControl = this.control, newControl = control;
+ this.control = control;
+ int index = parent.indexOf (this);
+ if (index != parent.getSelectionIndex ()) {
+ if (newControl != null) newControl.setVisible (false);
+ return;
+ }
+ if (newControl != null) {
+ newControl.setBounds (parent.getClientArea ());
+ newControl.setVisible (true);
+ }
+ if (oldControl != null) oldControl.setVisible (false);
+}
+
+void setFontDescription (int font) {
+ OS.gtk_widget_modify_font (labelHandle, font);
+ OS.gtk_widget_modify_font (imageHandle, font);
+}
+
+void setForegroundColor (GdkColor color) {
+ OS.gtk_widget_modify_fg (labelHandle, 0, color);
+ OS.gtk_widget_modify_fg (imageHandle, 0, color);
+}
+
+public void setImage (Image image) {
+ checkWidget ();
+ super.setImage (image);
+ if (image != null) {
+ OS.gtk_image_set_from_pixmap (imageHandle, image.pixmap, image.mask);
+ OS.gtk_widget_show (imageHandle);
+ } else {
+ OS.gtk_image_set_from_pixmap (imageHandle, 0, 0);
+ OS.gtk_widget_hide (imageHandle);
+ }
+ parent.fixPage ();
+}
+
+public void setText (String string) {
+ checkWidget ();
+ if (string == null) error (SWT.ERROR_NULL_ARGUMENT);
+ super.setText (string);
+ char [] chars = fixMnemonic (string);
+ byte [] buffer = Converter.wcsToMbcs (null, chars, false);
+ OS.gtk_label_set_text_with_mnemonic (labelHandle, buffer);
+ if (string.length () != 0) {
+ OS.gtk_widget_show (labelHandle);
+ } else {
+ OS.gtk_widget_hide (labelHandle);
+ }
+ parent.fixPage ();
+}
+
/**
* Sets the receiver's tool tip text to the argument, which
* may be null indicating that no tool tip text should be shown.
@@ -257,9 +257,9 @@ public void setText (String string) {
* <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;
-}
-
-}
+public void setToolTipText (String string) {
+ checkWidget ();
+ toolTipText = string;
+}
+
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ToolBar.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ToolBar.java
index dd18eebabf..e82690e095 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ToolBar.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ToolBar.java
@@ -259,8 +259,8 @@ public int indexOf (ToolItem item) {
// TEMPORARY CODE
ToolItem [] items = getItems ();
- for (int i=0; i<items.length; i++) {
- if (item == items[i]) return i;
+ for (int i=0; i<items.length; i++) {
+ if (item == items[i]) return i;
}
return -1;
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Tracker.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Tracker.java
index 66fd6cf59e..62f8bea8fa 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Tracker.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Tracker.java
@@ -1,46 +1,46 @@
-package org.eclipse.swt.widgets;
-
-/*
+package org.eclipse.swt.widgets;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-import org.eclipse.swt.*;
-import org.eclipse.swt.internal.gtk.*;
-import org.eclipse.swt.graphics.*;
-import org.eclipse.swt.events.*;
-
-/**
- * Instances of this class implement rubber banding rectangles that are
- * drawn onto a parent <code>Composite</code> or <code>Display</code>.
- * These rectangles can be specified to respond to mouse and key events
- * by either moving or resizing themselves accordingly. Trackers are
- * typically used to represent window geometries in a lightweight manner.
- *
- * <dl>
- * <dt><b>Styles:</b></dt>
- * <dd>LEFT, RIGHT, UP, DOWN, RESIZE</dd>
- * <dt><b>Events:</b></dt>
- * <dd>Move, Resize</dd>
- * </dl>
- * <p>
- * Note: Rectangle move behavior is assumed unless RESIZE is specified.
- * </p><p>
- * IMPORTANT: This class is <em>not</em> intended to be subclassed.
- * </p>
- */
-public class Tracker extends Widget {
- Composite parent;
- Display display;
- int cursor, lastCursor;
- boolean tracking, stippled;
- Rectangle [] rectangles = new Rectangle [0];
- int xWindow;
- int ptrGrabResult;
-
-
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+import org.eclipse.swt.*;
+import org.eclipse.swt.internal.gtk.*;
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.events.*;
+
+/**
+ * Instances of this class implement rubber banding rectangles that are
+ * drawn onto a parent <code>Composite</code> or <code>Display</code>.
+ * These rectangles can be specified to respond to mouse and key events
+ * by either moving or resizing themselves accordingly. Trackers are
+ * typically used to represent window geometries in a lightweight manner.
+ *
+ * <dl>
+ * <dt><b>Styles:</b></dt>
+ * <dd>LEFT, RIGHT, UP, DOWN, RESIZE</dd>
+ * <dt><b>Events:</b></dt>
+ * <dd>Move, Resize</dd>
+ * </dl>
+ * <p>
+ * Note: Rectangle move behavior is assumed unless RESIZE is specified.
+ * </p><p>
+ * IMPORTANT: This class is <em>not</em> intended to be subclassed.
+ * </p>
+ */
+public class Tracker extends Widget {
+ Composite parent;
+ Display display;
+ int cursor, lastCursor;
+ boolean tracking, stippled;
+ Rectangle [] rectangles = new Rectangle [0];
+ int xWindow;
+ int ptrGrabResult;
+
+
/**
* Constructs a new instance of this class given its parent
* and a style value describing its behavior and appearance.
@@ -73,13 +73,13 @@ public class Tracker extends Widget {
* @see Widget#checkSubclass
* @see Widget#getStyle
*/
-public Tracker (Composite parent, int style) {
- super (parent, checkStyle(style));
- this.parent = parent;
- display = parent.getDisplay ();
- xWindow = calculateWindow();
-}
-
+public Tracker (Composite parent, int style) {
+ super (parent, checkStyle(style));
+ this.parent = parent;
+ display = parent.getDisplay ();
+ xWindow = calculateWindow();
+}
+
/**
* Constructs a new instance of this class given the display
* to create it on and a style value describing its behavior
@@ -114,115 +114,115 @@ public Tracker (Composite parent, int style) {
* @see SWT#UP
* @see SWT#DOWN
*/
-public Tracker (Display display, int style) {
- if (display == null) display = Display.getCurrent ();
- if (display == null) display = Display.getDefault ();
- if (!display.isValidThread ()) {
- error (SWT.ERROR_THREAD_INVALID_ACCESS);
- }
- this.style = checkStyle (style);
- this.display = display;
- xWindow = calculateWindow();
-}
-
-
-/*
- * === ADD / REMOVE LISTENERS ===
- */
-
-/**
- * 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 Tracker (Display display, int style) {
+ if (display == null) display = Display.getCurrent ();
+ if (display == null) display = Display.getDefault ();
+ if (!display.isValidThread ()) {
+ error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ }
+ this.style = checkStyle (style);
+ this.display = display;
+ xWindow = calculateWindow();
+}
+
+
+/*
+ * === ADD / REMOVE LISTENERS ===
*/
-public void addControlListener(ControlListener listener) {
- checkWidget();
- if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
- TypedListener typedListener = new TypedListener (listener);
- addListener (SWT.Move,typedListener);
-}
-
-/**
- * Removes the listener from the collection of listeners who will
- * be notified when the control is moved or resized.
- *
- * @param listener the listener which should 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
+
+/**
+ * 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 removeControlListener (ControlListener listener) {
- checkWidget();
- if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
- if (eventTable == null) return;
- eventTable.unhook (SWT.Move, listener);
-}
-
-
-
-
-/*
- * === PUBLIC ACCESSORS ===
- */
-
-public Display getDisplay () {
- return display;
-}
-
-/**
- * Returns the bounds that are being drawn, expressed relative to the parent
- * widget. If the parent is a <code>Display</code> then these are screen
- * coordinates.
- *
- * @return the bounds of the Rectangles being drawn
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
+public void addControlListener(ControlListener listener) {
+ checkWidget();
+ if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+ TypedListener typedListener = new TypedListener (listener);
+ addListener (SWT.Move,typedListener);
+}
+
+/**
+ * Removes the listener from the collection of listeners who will
+ * be notified when the control is moved or resized.
+ *
+ * @param listener the listener which should 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);
+}
+
+
+
+
+/*
+ * === PUBLIC ACCESSORS ===
+ */
+
+public Display getDisplay () {
+ return display;
+}
+
+/**
+ * Returns the bounds that are being drawn, expressed relative to the parent
+ * widget. If the parent is a <code>Display</code> then these are screen
+ * coordinates.
+ *
+ * @return the bounds of the Rectangles being drawn
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
*/
-public Rectangle [] getRectangles () {
- checkWidget();
- 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 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;
-}
-
+public boolean getStippled () {
+ checkWidget();
+ return stippled;
+}
+
/**
* Specifies the rectangles that should be drawn, expressed relative to the parent
* widget. If the parent is a Display then these are screen coordinates.
@@ -234,207 +234,207 @@ public boolean getStippled () {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public void setRectangles (Rectangle [] rectangles) {
- checkWidget();
- this.rectangles = rectangles;
-}
-
-/**
- * Changes the appearance of the line used to draw the rectangles.
- *
- * @param stippled <code>true</code> if rectangle should appear stippled
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
+public void setRectangles (Rectangle [] rectangles) {
+ checkWidget();
+ this.rectangles = rectangles;
+}
+
+/**
+ * Changes the appearance of the line used to draw the rectangles.
+ *
+ * @param stippled <code>true</code> if rectangle should appear stippled
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setStippled (boolean stippled) {
+ checkWidget();
+ this.stippled = stippled;
+}
+
+
+
+/*
+ * === PUBLIC FUNCTIONALITY ===
+ */
+
+/**
+ * Stops displaying the tracker rectangles. Note that this is not considered
+ * to be a cancelation by the user.
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void close () {
+ checkWidget();
+ tracking = false;
+}
+
+/**
+ * Displays the Tracker rectangles for manipulation by the user. Returns when
+ * the user has either finished manipulating the rectangles or has cancelled the
+ * Tracker.
+ *
+ * @return <code>true</code> if the user did not cancel the Tracker, <code>false</code> otherwise
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public boolean open () {
+ checkWidget();
+ boolean cancelled=false;
+ tracking = true;
+ drawRectangles ();
+
+ int[] newX = new int[1];
+ int[] newY = new int[1];
+ int[] oldX = new int[1];
+ int[] oldY = new int[1];
+ OS.gdk_window_get_pointer(xWindow, oldX,oldY, null);
+ grab();
+
+ /*
+ * Tracker behaves like a Dialog with its own OS event loop.
+ */
+ while (tracking) {
+ if (parent != null && parent.isDisposed ()) break;
+ // wait for an event
+ int eventPtr;
+ while (true) {
+ eventPtr = OS.gdk_event_get();
+ if (eventPtr != 0) {
+ break;
+ }
+ else {
+ try { Thread.sleep(50); } catch (Exception ex) {}
+ }
+ }
+
+ GdkEvent osEvent = new GdkEvent();
+ OS.memmove(osEvent, eventPtr, GdkEvent.sizeof);
+ int eventType = osEvent.type;
+ switch (eventType) {
+ case OS.GDK_BUTTON_RELEASE:
+ case OS.GDK_MOTION_NOTIFY:
+ if (cursor != lastCursor) { ungrab(); grab(); }
+ OS.gdk_window_get_pointer(xWindow, newX,newY, null);
+ 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];
+ }
+ Event event = new Event();
+ event.x = newX[0];
+ event.y = newY[0];
+ sendEvent (SWT.Move,event);
+ drawRectangles ();
+ oldX [0] = newX [0]; oldY [0] = newY [0];
+ }
+ tracking = (eventType != OS.GDK_BUTTON_RELEASE);
+ break;
+ case OS.GDK_KEY_PRESS:
+ GdkEventKey gdkEvent = new GdkEventKey ();
+ OS.memmove (gdkEvent, eventPtr, GdkEventKey.sizeof);
+ switch (gdkEvent.keyval) {
+ case OS.GDK_Escape:
+ cancelled = true;
+ // fallthrough
+ case OS.GDK_Return:
+ tracking = false;
+ break;
+ }
+ break;
+ } // switch
+ OS.gdk_event_free(eventPtr);
+ } // while
+ drawRectangles();
+ ungrab();
+ return !cancelled;
+}
+
+private void drawRectangles () {
+ if (parent != null) {
+ if (parent.isDisposed ()) return;
+ parent.getShell ().update ();
+ } else {
+ display.update ();
+ }
+
+ int gc = OS.gdk_gc_new(xWindow);
+ if (gc==0) error(SWT.ERROR_UNSPECIFIED);
+
+ /* White foreground */
+ int colormap = OS.gdk_colormap_get_system();
+ GdkColor color = new GdkColor();
+ OS.gdk_color_white(colormap, color);
+ OS.gdk_gc_set_foreground(gc, color);
+
+ /* Draw on top of inferior widgets */
+ OS.gdk_gc_set_subwindow(gc, OS.GDK_INCLUDE_INFERIORS);
+
+ /* XOR */
+ OS.gdk_gc_set_function(gc, OS.GDK_XOR);
+
+ for (int i=0; i<rectangles.length; i++) {
+ Rectangle rect = rectangles [i];
+ OS.gdk_draw_rectangle(xWindow, gc, 0, rect.x, rect.y, rect.width, rect.height);
+ }
+ OS.g_object_unref(gc);
+}
+
+/*
+ * Figure which GdkWindow we'll draw on.
+ * That's normally the root X window, or the parent's GdkWindow if we have a parent.
+ */
+private int calculateWindow() {
+ int answer;
+ if (parent == null) answer = OS.GDK_ROOT_PARENT();
+ else answer = OS.GTK_WIDGET_WINDOW(parent.paintHandle());
+ if (answer==0) error(SWT.ERROR_UNSPECIFIED);
+ return answer;
+}
+
+/**
+ * Sets the <code>Cursor</code> of the Tracker. If this cursor is <code>null</code>
+ * then the cursor reverts to the default.
+ *
+ * @param newCursor the new <code>Cursor</code> to display
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
*/
-public void setStippled (boolean stippled) {
- checkWidget();
- this.stippled = stippled;
-}
-
-
-
-/*
- * === PUBLIC FUNCTIONALITY ===
- */
-
-/**
- * Stops displaying the tracker rectangles. Note that this is not considered
- * to be a cancelation by the user.
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public void close () {
- checkWidget();
- tracking = false;
-}
-
-/**
- * Displays the Tracker rectangles for manipulation by the user. Returns when
- * the user has either finished manipulating the rectangles or has cancelled the
- * Tracker.
- *
- * @return <code>true</code> if the user did not cancel the Tracker, <code>false</code> otherwise
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public boolean open () {
- checkWidget();
- boolean cancelled=false;
- tracking = true;
- drawRectangles ();
-
- int[] newX = new int[1];
- int[] newY = new int[1];
- int[] oldX = new int[1];
- int[] oldY = new int[1];
- OS.gdk_window_get_pointer(xWindow, oldX,oldY, null);
- grab();
-
- /*
- * Tracker behaves like a Dialog with its own OS event loop.
- */
- while (tracking) {
- if (parent != null && parent.isDisposed ()) break;
- // wait for an event
- int eventPtr;
- while (true) {
- eventPtr = OS.gdk_event_get();
- if (eventPtr != 0) {
- break;
- }
- else {
- try { Thread.sleep(50); } catch (Exception ex) {}
- }
- }
-
- GdkEvent osEvent = new GdkEvent();
- OS.memmove(osEvent, eventPtr, GdkEvent.sizeof);
- int eventType = osEvent.type;
- switch (eventType) {
- case OS.GDK_BUTTON_RELEASE:
- case OS.GDK_MOTION_NOTIFY:
- if (cursor != lastCursor) { ungrab(); grab(); }
- OS.gdk_window_get_pointer(xWindow, newX,newY, null);
- 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];
- }
- Event event = new Event();
- event.x = newX[0];
- event.y = newY[0];
- sendEvent (SWT.Move,event);
- drawRectangles ();
- oldX [0] = newX [0]; oldY [0] = newY [0];
- }
- tracking = (eventType != OS.GDK_BUTTON_RELEASE);
- break;
- case OS.GDK_KEY_PRESS:
- GdkEventKey gdkEvent = new GdkEventKey ();
- OS.memmove (gdkEvent, eventPtr, GdkEventKey.sizeof);
- switch (gdkEvent.keyval) {
- case OS.GDK_Escape:
- cancelled = true;
- // fallthrough
- case OS.GDK_Return:
- tracking = false;
- break;
- }
- break;
- } // switch
- OS.gdk_event_free(eventPtr);
- } // while
- drawRectangles();
- ungrab();
- return !cancelled;
-}
-
-private void drawRectangles () {
- if (parent != null) {
- if (parent.isDisposed ()) return;
- parent.getShell ().update ();
- } else {
- display.update ();
- }
-
- int gc = OS.gdk_gc_new(xWindow);
- if (gc==0) error(SWT.ERROR_UNSPECIFIED);
-
- /* White foreground */
- int colormap = OS.gdk_colormap_get_system();
- GdkColor color = new GdkColor();
- OS.gdk_color_white(colormap, color);
- OS.gdk_gc_set_foreground(gc, color);
-
- /* Draw on top of inferior widgets */
- OS.gdk_gc_set_subwindow(gc, OS.GDK_INCLUDE_INFERIORS);
-
- /* XOR */
- OS.gdk_gc_set_function(gc, OS.GDK_XOR);
-
- for (int i=0; i<rectangles.length; i++) {
- Rectangle rect = rectangles [i];
- OS.gdk_draw_rectangle(xWindow, gc, 0, rect.x, rect.y, rect.width, rect.height);
- }
- OS.g_object_unref(gc);
-}
-
-/*
- * Figure which GdkWindow we'll draw on.
- * That's normally the root X window, or the parent's GdkWindow if we have a parent.
- */
-private int calculateWindow() {
- int answer;
- if (parent == null) answer = OS.GDK_ROOT_PARENT();
- else answer = OS.GTK_WIDGET_WINDOW(parent.paintHandle());
- if (answer==0) error(SWT.ERROR_UNSPECIFIED);
- return answer;
-}
-
-/**
- * Sets the <code>Cursor</code> of the Tracker. If this cursor is <code>null</code>
- * then the cursor reverts to the default.
- *
- * @param newCursor the new <code>Cursor</code> to display
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public void setCursor (Cursor value) {
- checkWidget ();
- cursor = 0;
- if (value != null) cursor = value.handle;
-}
-void grab() {
- ptrGrabResult = OS.gdk_pointer_grab(xWindow,
- false,
- OS.GDK_POINTER_MOTION_MASK | OS.GDK_BUTTON_RELEASE_MASK,
- xWindow,
- cursor,
- OS.GDK_CURRENT_TIME);
- lastCursor = cursor;
-}
-void ungrab() {
- if (ptrGrabResult == OS.GDK_GRAB_SUCCESS)
- OS.gdk_pointer_ungrab(OS.GDK_CURRENT_TIME);
-
-}
-static int checkStyle (int style) {
- if ((style & (SWT.LEFT | SWT.RIGHT | SWT.UP | SWT.DOWN)) == 0) {
- style |= SWT.LEFT | SWT.RIGHT | SWT.UP | SWT.DOWN;
- }
- return style;
-}
-}
+public void setCursor (Cursor value) {
+ checkWidget ();
+ cursor = 0;
+ if (value != null) cursor = value.handle;
+}
+void grab() {
+ ptrGrabResult = OS.gdk_pointer_grab(xWindow,
+ false,
+ OS.GDK_POINTER_MOTION_MASK | OS.GDK_BUTTON_RELEASE_MASK,
+ xWindow,
+ cursor,
+ OS.GDK_CURRENT_TIME);
+ lastCursor = cursor;
+}
+void ungrab() {
+ if (ptrGrabResult == OS.GDK_GRAB_SUCCESS)
+ OS.gdk_pointer_ungrab(OS.GDK_CURRENT_TIME);
+
+}
+static int checkStyle (int style) {
+ if ((style & (SWT.LEFT | SWT.RIGHT | SWT.UP | SWT.DOWN)) == 0) {
+ style |= SWT.LEFT | SWT.RIGHT | SWT.UP | SWT.DOWN;
+ }
+ return style;
+}
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TreeItem.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TreeItem.java
index 862665c731..226329cb51 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TreeItem.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TreeItem.java
@@ -1,35 +1,35 @@
-package org.eclipse.swt.widgets;
-
-/*
+package org.eclipse.swt.widgets;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-import org.eclipse.swt.*;
-import org.eclipse.swt.internal.*;
-import org.eclipse.swt.internal.gtk.*;
-import org.eclipse.swt.graphics.*;
-
-/**
- * Instances of this class represent a selectable user interface object
- * that represents a hierarchy of tree items in a tree widget.
- *
- * <dl>
- * <dt><b>Styles:</b></dt>
- * <dd>(none)</dd>
- * <dt><b>Events:</b></dt>
- * <dd>(none)</dd>
- * </dl>
- * <p>
- * IMPORTANT: This class is <em>not</em> intended to be subclassed.
- * </p>
+ * http://www.eclipse.org/legal/cpl-v10.html
*/
-public class TreeItem extends Item {
- Tree parent;
- boolean grayed;
-
+
+import org.eclipse.swt.*;
+import org.eclipse.swt.internal.*;
+import org.eclipse.swt.internal.gtk.*;
+import org.eclipse.swt.graphics.*;
+
+/**
+ * Instances of this class represent a selectable user interface object
+ * that represents a hierarchy of tree items in a tree widget.
+ *
+ * <dl>
+ * <dt><b>Styles:</b></dt>
+ * <dd>(none)</dd>
+ * <dt><b>Events:</b></dt>
+ * <dd>(none)</dd>
+ * </dl>
+ * <p>
+ * IMPORTANT: This class is <em>not</em> intended to be subclassed.
+ * </p>
+ */
+public class TreeItem extends Item {
+ Tree parent;
+ boolean grayed;
+
/**
* Constructs a new instance of this class given its parent
* (which must be a <code>Tree</code> or a <code>TreeItem</code>)
@@ -60,12 +60,12 @@ public class TreeItem extends Item {
* @see Widget#checkSubclass
* @see Widget#getStyle
*/
-public TreeItem (Tree parent, int style) {
- super (parent, style);
- this.parent = parent;
- parent.createItem (this, 0, -1);
-}
-
+public TreeItem (Tree parent, int style) {
+ super (parent, style);
+ this.parent = parent;
+ parent.createItem (this, 0, -1);
+}
+
/**
* Constructs a new instance of this class given its parent
* (which must be a <code>Tree</code> or a <code>TreeItem</code>),
@@ -97,13 +97,13 @@ public TreeItem (Tree parent, int style) {
* @see Widget#checkSubclass
* @see Widget#getStyle
*/
-public TreeItem (Tree parent, int style, int index) {
- super (parent, style);
- if (index < 0) error (SWT.ERROR_INVALID_RANGE);
- this.parent = parent;
- parent.createItem (this, 0, index);
-}
-
+public TreeItem (Tree parent, int style, int index) {
+ super (parent, style);
+ if (index < 0) error (SWT.ERROR_INVALID_RANGE);
+ this.parent = parent;
+ parent.createItem (this, 0, index);
+}
+
/**
* Constructs a new instance of this class given its parent
* (which must be a <code>Tree</code> or a <code>TreeItem</code>)
@@ -134,12 +134,12 @@ public TreeItem (Tree parent, int style, int index) {
* @see Widget#checkSubclass
* @see Widget#getStyle
*/
-public TreeItem (TreeItem parentItem, int style) {
- super (checkNull (parentItem).parent, style);
- this.parent = parentItem.parent;
- parent.createItem (this, parentItem.handle, -1);
-}
-
+public TreeItem (TreeItem parentItem, int style) {
+ super (checkNull (parentItem).parent, style);
+ this.parent = parentItem.parent;
+ parent.createItem (this, parentItem.handle, -1);
+}
+
/**
* Constructs a new instance of this class given its parent
* (which must be a <code>Tree</code> or a <code>TreeItem</code>),
@@ -171,41 +171,41 @@ public TreeItem (TreeItem parentItem, int style) {
* @see Widget#checkSubclass
* @see Widget#getStyle
*/
-public TreeItem (TreeItem parentItem, int style, int index) {
- super (checkNull (parentItem).parent, style);
- if (index < 0) error (SWT.ERROR_ITEM_NOT_ADDED);
- this.parent = parentItem.parent;
- parent.createItem (this, parentItem.handle, index);
-}
-
-static TreeItem checkNull (TreeItem item) {
- if (item == null) SWT.error (SWT.ERROR_NULL_ARGUMENT);
- return item;
-}
-
-/**
- * Returns the receiver's background color.
- *
- * @return the background color
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @since 2.0
- *
- */
-public Color getBackground () {
- checkWidget ();
- int[] ptr = new int[1];
- OS.gtk_tree_model_get (parent.modelHandle, handle, 3, ptr, -1);
- if (ptr [0] == 0) return parent.getBackground ();
- GdkColor gdkColor = new GdkColor ();
- OS.memmove (gdkColor, ptr [0], GdkColor.sizeof);
- return Color.gtk_new (getDisplay (), gdkColor);
-}
-
+public TreeItem (TreeItem parentItem, int style, int index) {
+ super (checkNull (parentItem).parent, style);
+ if (index < 0) error (SWT.ERROR_ITEM_NOT_ADDED);
+ this.parent = parentItem.parent;
+ parent.createItem (this, parentItem.handle, index);
+}
+
+static TreeItem checkNull (TreeItem item) {
+ if (item == null) SWT.error (SWT.ERROR_NULL_ARGUMENT);
+ return item;
+}
+
+/**
+ * Returns the receiver's background color.
+ *
+ * @return the background color
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @since 2.0
+ *
+ */
+public Color getBackground () {
+ checkWidget ();
+ int[] ptr = new int[1];
+ OS.gtk_tree_model_get (parent.modelHandle, handle, 3, ptr, -1);
+ if (ptr [0] == 0) return parent.getBackground ();
+ GdkColor gdkColor = new GdkColor ();
+ OS.memmove (gdkColor, ptr [0], GdkColor.sizeof);
+ return Color.gtk_new (getDisplay (), gdkColor);
+}
+
/**
* Returns a rectangle describing the receiver's size and location
* relative to its parent.
@@ -217,17 +217,17 @@ public Color getBackground () {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public Rectangle getBounds () {
- checkWidget ();
- int parentHandle = parent.handle;
- GdkRectangle rect = new GdkRectangle ();
- int column = OS.gtk_tree_view_get_column (parentHandle, 0);
- int path = OS.gtk_tree_model_get_path (parent.modelHandle, handle);
- OS.gtk_tree_view_get_cell_area (parentHandle, path, column, rect);
- OS.gtk_tree_path_free (path);
- return new Rectangle (rect.x, rect.y, rect.width, rect.height);
-}
-
+public Rectangle getBounds () {
+ checkWidget ();
+ int parentHandle = parent.handle;
+ GdkRectangle rect = new GdkRectangle ();
+ int column = OS.gtk_tree_view_get_column (parentHandle, 0);
+ int path = OS.gtk_tree_model_get_path (parent.modelHandle, handle);
+ OS.gtk_tree_view_get_cell_area (parentHandle, path, column, rect);
+ OS.gtk_tree_path_free (path);
+ return new Rectangle (rect.x, rect.y, rect.width, rect.height);
+}
+
/**
* Returns <code>true</code> if the receiver is checked,
* and false otherwise. When the parent does not have
@@ -241,19 +241,19 @@ public Rectangle getBounds () {
* <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 [] ptr = new int [1];
- OS.gtk_tree_model_get (parent.modelHandle, handle, 5, ptr, -1);
- return ptr [0] != 0;
-}
-
-public Display getDisplay () {
- if (parent == null) error (SWT.ERROR_WIDGET_DISPOSED);
- return parent.getDisplay ();
-}
-
+public boolean getChecked () {
+ checkWidget();
+ if ((parent.style & SWT.CHECK) == 0) return false;
+ int [] ptr = new int [1];
+ OS.gtk_tree_model_get (parent.modelHandle, handle, 5, ptr, -1);
+ return ptr [0] != 0;
+}
+
+public Display getDisplay () {
+ if (parent == null) error (SWT.ERROR_WIDGET_DISPOSED);
+ return parent.getDisplay ();
+}
+
/**
* Returns <code>true</code> if the receiver is expanded,
* and false otherwise.
@@ -266,37 +266,37 @@ public Display getDisplay () {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public boolean getExpanded () {
- checkWidget();
- int path = OS.gtk_tree_model_get_path (parent.modelHandle, handle);
- boolean answer = OS.gtk_tree_view_row_expanded (parent.handle, path);
- OS.gtk_tree_path_free (path);
- return answer;
-}
-
-/**
- * Returns the foreground color that the receiver will use to draw.
- *
- * @return the receiver's foreground color
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @since 2.0
- *
+public boolean getExpanded () {
+ checkWidget();
+ int path = OS.gtk_tree_model_get_path (parent.modelHandle, handle);
+ boolean answer = OS.gtk_tree_view_row_expanded (parent.handle, path);
+ OS.gtk_tree_path_free (path);
+ return answer;
+}
+
+/**
+ * Returns the foreground color that the receiver will use to draw.
+ *
+ * @return the receiver's foreground color
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @since 2.0
+ *
*/
-public Color getForeground () {
- checkWidget ();
- int [] ptr = new int [1];
- OS.gtk_tree_model_get (parent.modelHandle, handle, 2, ptr, -1);
- if (ptr [0]==0) return parent.getForeground();
- GdkColor gdkColor = new GdkColor ();
- OS.memmove (gdkColor, ptr [0], GdkColor.sizeof);
- return Color.gtk_new (getDisplay (), gdkColor);
-}
-
+public Color getForeground () {
+ checkWidget ();
+ int [] ptr = new int [1];
+ OS.gtk_tree_model_get (parent.modelHandle, handle, 2, ptr, -1);
+ if (ptr [0]==0) return parent.getForeground();
+ GdkColor gdkColor = new GdkColor ();
+ OS.memmove (gdkColor, ptr [0], GdkColor.sizeof);
+ return Color.gtk_new (getDisplay (), gdkColor);
+}
+
/**
* Returns <code>true</code> if the receiver is grayed,
* and false otherwise. When the parent does not have
@@ -310,12 +310,12 @@ public Color getForeground () {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public boolean getGrayed() {
- checkWidget();
- //NOT IMPLEMENTED
- return grayed;
-}
-
+public boolean getGrayed() {
+ checkWidget();
+ //NOT IMPLEMENTED
+ return grayed;
+}
+
/**
* Returns the number of items contained in the receiver
* that are direct item children of the receiver.
@@ -327,32 +327,32 @@ public boolean getGrayed() {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public int getItemCount () {
- checkWidget();
- return OS.gtk_tree_model_iter_n_children (parent.modelHandle, handle);
-}
-
-/**
- * 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 affect the receiver.
- * </p>
- *
- * @return the receiver's items
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
+public int getItemCount () {
+ checkWidget();
+ return OS.gtk_tree_model_iter_n_children (parent.modelHandle, handle);
+}
+
+/**
+ * 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 affect the receiver.
+ * </p>
+ *
+ * @return the receiver's items
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
*/
-public TreeItem [] getItems () {
- checkWidget();
- return parent.getItems (handle);
-}
-
+public TreeItem [] getItems () {
+ checkWidget();
+ return parent.getItems (handle);
+}
+
/**
* Returns the receiver's parent, which must be a <code>Tree</code>.
*
@@ -363,11 +363,11 @@ public TreeItem [] getItems () {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public Tree getParent () {
- checkWidget();
- return parent;
-}
-
+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
@@ -380,35 +380,35 @@ public Tree getParent () {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public TreeItem getParentItem () {
- checkWidget();
- int path = OS.gtk_tree_model_get_path (parent.modelHandle, handle);
- if (OS.gtk_tree_path_get_depth (path) < 2) {
- OS.gtk_tree_path_free (path);
- return null;
- }
- OS.gtk_tree_path_up (path);
- int iter = OS.g_malloc (OS.GtkTreeIter_sizeof ());
- OS.gtk_tree_model_get_iter (parent.modelHandle, iter, path);
- int [] index = new int [1];
- OS.gtk_tree_model_get (parent.modelHandle, iter, 4, index, -1);
- OS.g_free (iter);
- OS.gtk_tree_path_free (path);
- return parent.items [index [0]];
-}
-
-void releaseChild () {
- super.releaseChild ();
- parent.destroyItem (this);
-}
-
-void releaseWidget () {
- super.releaseWidget ();
- if (handle != 0) OS.g_free (handle);
- handle = 0;
- parent = null;
-}
-
+public TreeItem getParentItem () {
+ checkWidget();
+ int path = OS.gtk_tree_model_get_path (parent.modelHandle, handle);
+ if (OS.gtk_tree_path_get_depth (path) < 2) {
+ OS.gtk_tree_path_free (path);
+ return null;
+ }
+ OS.gtk_tree_path_up (path);
+ int iter = OS.g_malloc (OS.GtkTreeIter_sizeof ());
+ OS.gtk_tree_model_get_iter (parent.modelHandle, iter, path);
+ int [] index = new int [1];
+ OS.gtk_tree_model_get (parent.modelHandle, iter, 4, index, -1);
+ OS.g_free (iter);
+ OS.gtk_tree_path_free (path);
+ return parent.items [index [0]];
+}
+
+void releaseChild () {
+ super.releaseChild ();
+ parent.destroyItem (this);
+}
+
+void releaseWidget () {
+ super.releaseWidget ();
+ if (handle != 0) OS.g_free (handle);
+ handle = 0;
+ parent = null;
+}
+
/**
* Sets the receiver's background color to the color specified
* by the argument, or to the default system color for the item
@@ -427,15 +427,15 @@ void releaseWidget () {
* @since 2.0
*
*/
-public void setBackground (Color color) {
- checkWidget ();
- if (color != null && color.isDisposed ()) {
- SWT.error (SWT.ERROR_INVALID_ARGUMENT);
- }
- GdkColor gdkColor = color != null ? color.handle : null;
- OS.gtk_tree_store_set (parent.modelHandle, handle, 3, gdkColor, -1);
-}
-
+public void setBackground (Color color) {
+ checkWidget ();
+ if (color != null && color.isDisposed ()) {
+ SWT.error (SWT.ERROR_INVALID_ARGUMENT);
+ }
+ GdkColor gdkColor = color != null ? color.handle : null;
+ OS.gtk_tree_store_set (parent.modelHandle, handle, 3, gdkColor, -1);
+}
+
/**
* Sets the checked state of the receiver.
* <p>
@@ -447,12 +447,12 @@ public void setBackground (Color color) {
* <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;
- OS.gtk_tree_store_set (parent.modelHandle, handle, 5, checked, -1);
-}
-
+public void setChecked (boolean checked) {
+ checkWidget();
+ if ((parent.style & SWT.CHECK) == 0) return;
+ OS.gtk_tree_store_set (parent.modelHandle, handle, 5, checked, -1);
+}
+
/**
* Sets the grayed state of the receiver.
* <p>
@@ -464,12 +464,12 @@ public void setChecked (boolean checked) {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public void setGrayed (boolean grayed) {
- checkWidget();
- //NOT IMPLEMENTED
- this.grayed = grayed;
-}
-
+public void setGrayed (boolean grayed) {
+ checkWidget();
+ //NOT IMPLEMENTED
+ this.grayed = grayed;
+}
+
/**
* Sets the expanded state of the receiver.
* <p>
@@ -481,21 +481,21 @@ public void setGrayed (boolean grayed) {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public void setExpanded (boolean expanded) {
- checkWidget();
- int path = OS.gtk_tree_model_get_path (parent.modelHandle, handle);
- if (expanded) {
- OS.g_signal_handlers_block_matched (parent.handle, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, ROW_EXPANDED);
- OS.gtk_tree_view_expand_row (parent.handle, path, false);
- OS.g_signal_handlers_unblock_matched (parent.handle, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, ROW_EXPANDED);
- } else {
- OS.g_signal_handlers_block_matched (parent.handle, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, ROW_COLLAPSED);
- OS.gtk_tree_view_collapse_row (parent.handle, path);
- OS.g_signal_handlers_unblock_matched (parent.handle, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, ROW_COLLAPSED);
- }
- OS.gtk_tree_path_free (path);
-}
-
+public void setExpanded (boolean expanded) {
+ checkWidget();
+ int path = OS.gtk_tree_model_get_path (parent.modelHandle, handle);
+ if (expanded) {
+ OS.g_signal_handlers_block_matched (parent.handle, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, ROW_EXPANDED);
+ OS.gtk_tree_view_expand_row (parent.handle, path, false);
+ OS.g_signal_handlers_unblock_matched (parent.handle, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, ROW_EXPANDED);
+ } else {
+ OS.g_signal_handlers_block_matched (parent.handle, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, ROW_COLLAPSED);
+ OS.gtk_tree_view_collapse_row (parent.handle, path);
+ OS.g_signal_handlers_unblock_matched (parent.handle, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, ROW_COLLAPSED);
+ }
+ OS.gtk_tree_path_free (path);
+}
+
/**
* Sets the receiver's foreground color to the color specified
* by the argument, or to the default system color for the item
@@ -516,43 +516,43 @@ public void setExpanded (boolean expanded) {
* @since 2.0
*
*/
-public void setForeground (Color color){
- checkWidget ();
- if (color != null && color.isDisposed ()) {
- SWT.error (SWT.ERROR_INVALID_ARGUMENT);
- }
- GdkColor gdkColor = color != null ? color.handle : null;
- OS.gtk_tree_store_set (parent.modelHandle, handle, 2, gdkColor, -1);
-}
-
-public void setImage (Image image) {
- checkWidget();
- if (image != null && image.isDisposed()) {
- error(SWT.ERROR_INVALID_ARGUMENT);
- }
- super.setImage (image);
- int pixbuf = 0;
- if (image != null) {
- ImageList imageList = parent.imageList;
- if (imageList == null) imageList = parent.imageList = new ImageList ();
- int imageIndex = imageList.indexOf (image);
- if (imageIndex == -1) imageIndex = imageList.add (image);
- pixbuf = imageList.getPixbuf (imageIndex);
- }
- OS.gtk_tree_store_set (parent.modelHandle, handle, 1, pixbuf, -1);
-}
-
+public void setForeground (Color color){
+ checkWidget ();
+ if (color != null && color.isDisposed ()) {
+ SWT.error (SWT.ERROR_INVALID_ARGUMENT);
+ }
+ GdkColor gdkColor = color != null ? color.handle : null;
+ OS.gtk_tree_store_set (parent.modelHandle, handle, 2, gdkColor, -1);
+}
+
+public void setImage (Image image) {
+ checkWidget();
+ if (image != null && image.isDisposed()) {
+ error(SWT.ERROR_INVALID_ARGUMENT);
+ }
+ super.setImage (image);
+ int pixbuf = 0;
+ if (image != null) {
+ ImageList imageList = parent.imageList;
+ if (imageList == null) imageList = parent.imageList = new ImageList ();
+ int imageIndex = imageList.indexOf (image);
+ if (imageIndex == -1) imageIndex = imageList.add (image);
+ pixbuf = imageList.getPixbuf (imageIndex);
+ }
+ OS.gtk_tree_store_set (parent.modelHandle, handle, 1, pixbuf, -1);
+}
+
/**
* 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 string) {
- checkWidget();
- if (string == null) error (SWT.ERROR_NULL_ARGUMENT);
- super.setText (string);
- byte[] buffer = Converter.wcsToMbcs (null, string, true);
- OS.gtk_tree_store_set (parent.modelHandle, handle, 0, buffer, -1);
-}
-
-}
+public void setText (String string) {
+ checkWidget();
+ if (string == null) error (SWT.ERROR_NULL_ARGUMENT);
+ super.setText (string);
+ byte[] buffer = Converter.wcsToMbcs (null, string, true);
+ OS.gtk_tree_store_set (parent.modelHandle, handle, 0, buffer, -1);
+}
+
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/WidgetTable.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/WidgetTable.java
index 91b7a1e07a..0f0bc86331 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/WidgetTable.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/WidgetTable.java
@@ -1,103 +1,103 @@
-package org.eclipse.swt.widgets;
-
-/*
+package org.eclipse.swt.widgets;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-import org.eclipse.swt.internal.*;
-import org.eclipse.swt.internal.gtk.*;
-
-class WidgetTable {
- static int FreeSlot = 0;
- static int GrowSize = 1024;
- static int [] IndexTable = new int [GrowSize];
- static Widget [] WidgetTable = new Widget [GrowSize];
- static final int SWT_OBJECT_INDEX;
- static {
- byte [] buffer = Converter.wcsToMbcs (null, "SWT_OBJECT_INDEX", true);
- SWT_OBJECT_INDEX = OS.g_quark_from_string (buffer);
- 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;
- int index = OS.g_object_get_qdata (handle, SWT_OBJECT_INDEX) - 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;
- }
- int index = FreeSlot + 1;
- OS.g_object_set_qdata (handle, SWT_OBJECT_INDEX, index);
- int oldSlot = FreeSlot;
- FreeSlot = IndexTable[oldSlot];
- IndexTable [oldSlot] = -2;
- WidgetTable [oldSlot] = widget;
-}
-
-public static synchronized Widget remove (int handle) {
- if (handle == 0) return null;
- Widget widget = null;
- int index = OS.g_object_get_qdata (handle, SWT_OBJECT_INDEX) - 1;
- if (0 <= index && index < WidgetTable.length) {
- widget = WidgetTable [index];
- WidgetTable [index] = null;
- IndexTable [index] = FreeSlot;
- FreeSlot = index;
- OS.g_object_set_qdata (handle, SWT_OBJECT_INDEX, 0);
- }
- return widget;
-}
-
-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) {
- int j = 0;
- while (j < index) {
- if (result [j] == widget) break;
- j++;
- }
- if (j == index) result [index++] = (Shell) widget;
- }
- }
- if (index == length) return result;
- Shell [] newResult = new Shell [index];
- System.arraycopy (result, 0, newResult, 0, index);
- return newResult;
-}
-
-public static synchronized int size () {
- int size = 0;
- for (int i=0; i<WidgetTable.length; i++) {
- if (WidgetTable [i] != null) size++;
- }
- return size;
-}
-
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+import org.eclipse.swt.internal.*;
+import org.eclipse.swt.internal.gtk.*;
+
+class WidgetTable {
+ static int FreeSlot = 0;
+ static int GrowSize = 1024;
+ static int [] IndexTable = new int [GrowSize];
+ static Widget [] WidgetTable = new Widget [GrowSize];
+ static final int SWT_OBJECT_INDEX;
+ static {
+ byte [] buffer = Converter.wcsToMbcs (null, "SWT_OBJECT_INDEX", true);
+ SWT_OBJECT_INDEX = OS.g_quark_from_string (buffer);
+ 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;
+ int index = OS.g_object_get_qdata (handle, SWT_OBJECT_INDEX) - 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;
+ }
+ int index = FreeSlot + 1;
+ OS.g_object_set_qdata (handle, SWT_OBJECT_INDEX, index);
+ int oldSlot = FreeSlot;
+ FreeSlot = IndexTable[oldSlot];
+ IndexTable [oldSlot] = -2;
+ WidgetTable [oldSlot] = widget;
+}
+
+public static synchronized Widget remove (int handle) {
+ if (handle == 0) return null;
+ Widget widget = null;
+ int index = OS.g_object_get_qdata (handle, SWT_OBJECT_INDEX) - 1;
+ if (0 <= index && index < WidgetTable.length) {
+ widget = WidgetTable [index];
+ WidgetTable [index] = null;
+ IndexTable [index] = FreeSlot;
+ FreeSlot = index;
+ OS.g_object_set_qdata (handle, SWT_OBJECT_INDEX, 0);
+ }
+ return widget;
+}
+
+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) {
+ int j = 0;
+ while (j < index) {
+ if (result [j] == widget) break;
+ j++;
+ }
+ if (j == index) result [index++] = (Shell) widget;
+ }
+ }
+ if (index == length) return result;
+ Shell [] newResult = new Shell [index];
+ System.arraycopy (result, 0, newResult, 0, index);
+ return newResult;
+}
+
+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/gtk1x/org/eclipse/swt/graphics/DefaultGtkStyle.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk1x/org/eclipse/swt/graphics/DefaultGtkStyle.java
index e45c97f342..0b6860b5fd 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk1x/org/eclipse/swt/graphics/DefaultGtkStyle.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk1x/org/eclipse/swt/graphics/DefaultGtkStyle.java
@@ -1,118 +1,118 @@
-package org.eclipse.swt.graphics;
-
-/*
+package org.eclipse.swt.graphics;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-import org.eclipse.swt.*;
-import org.eclipse.swt.internal.gtk.*;
-
-class DefaultGtkStyle {
-
- private static DefaultGtkStyle instance = null;
- private GtkStyle style = null;
- private int defaultFont;
-
- public Color foregroundColorNORMAL() {
- return new Color(null,
- ((short)0xFF00 & style.fg0_red)>>8,
- ((short)0xFF00 & style.fg0_green)>>8,
- ((short)0xFF00 & style.fg0_blue)>>8);
- }
-
- public Color backgroundColorNORMAL() {
- return new Color(null,
- ((short)0xFF00 & style.bg0_red)>>8,
- ((short)0xFF00 & style.bg0_green)>>8,
- ((short)0xFF00 & style.bg0_blue)>>8);
- }
-
- public Color foregroundColorACTIVE() {
- return new Color(null,
- ((short)0xFF00 & style.fg1_red)>>8,
- ((short)0xFF00 & style.fg1_green)>>8,
- ((short)0xFF00 & style.fg1_blue)>>8);
- }
-
- public Color backgroundColorACTIVE() {
- return new Color(null,
- ((short)0xFF00 & style.bg1_red)>>8,
- ((short)0xFF00 & style.bg1_green)>>8,
- ((short)0xFF00 & style.bg1_blue)>>8);
- }
-
- public Color foregroundColorPRELIGHT() {
- return new Color(null,
- ((short)0xFF00 & style.fg2_red)>>8,
- ((short)0xFF00 & style.fg2_green)>>8,
- ((short)0xFF00 & style.fg2_blue)>>8);
- }
-
- public Color backgroundColorPRELIGHT() {
- return new Color(null,
- ((short)0xFF00 & style.bg2_red)>>8,
- ((short)0xFF00 & style.bg2_green)>>8,
- ((short)0xFF00 & style.bg2_blue)>>8);
- }
-
- public Color foregroundColorSELECTED() {
- return new Color(null,
- ((short)0xFF00 & style.fg3_red)>>8,
- ((short)0xFF00 & style.fg3_green)>>8,
- ((short)0xFF00 & style.fg3_blue)>>8);
- }
-
- public Color backgroundColorSELECTED() {
- return new Color(null,
- ((short)0xFF00 & style.bg3_red)>>8,
- ((short)0xFF00 & style.bg3_green)>>8,
- ((short)0xFF00 & style.bg3_blue)>>8);
- }
-
- public Color foregroundColorINSENSITIVE() {
- return new Color(null,
- ((short)0xFF00 & style.fg4_red)>>8,
- ((short)0xFF00 & style.fg4_green)>>8,
- ((short)0xFF00 & style.fg4_blue)>>8);
- }
-
- public Color backgroundColorINSENSITIVE() {
- return new Color(null,
- ((short)0xFF00 & style.bg4_red)>>8,
- ((short)0xFF00 & style.bg4_green)>>8,
- ((short)0xFF00 & style.bg4_blue)>>8);
- }
-
- public int loadDefaultFont() {
- if (defaultFont == 0) {
- int fnames = Font.getFontNameList(style.font);
- int slength = OS.g_slist_length(fnames);
- if (slength < 1) SWT.error(SWT.ERROR_UNSPECIFIED);
- int name1 = OS.g_slist_nth_data(fnames, 0);
- int length = OS.strlen(name1);
- byte [] buffer1 = new byte[length];
- OS.memmove(buffer1, name1, length);
- defaultFont = OS.gdk_font_load(buffer1);
- if (defaultFont==0) SWT.error(SWT.ERROR_UNSPECIFIED);
- GdkFont gdkFont = new GdkFont();
- OS.memmove(gdkFont, defaultFont, GdkFont.sizeof);
- if (gdkFont.type != OS.GDK_FONT_FONT) SWT.error(SWT.ERROR_UNSPECIFIED);
- }
- return defaultFont;
- }
-
- public static DefaultGtkStyle instance() {
- if (instance==null) instance = new DefaultGtkStyle();
- return instance;
- }
-
- private DefaultGtkStyle() {
- style = new GtkStyle();
- OS.memmove(style, OS.gtk_widget_get_default_style(), GtkStyle.sizeof);
- }
-
-}
-
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+import org.eclipse.swt.*;
+import org.eclipse.swt.internal.gtk.*;
+
+class DefaultGtkStyle {
+
+ private static DefaultGtkStyle instance = null;
+ private GtkStyle style = null;
+ private int defaultFont;
+
+ public Color foregroundColorNORMAL() {
+ return new Color(null,
+ ((short)0xFF00 & style.fg0_red)>>8,
+ ((short)0xFF00 & style.fg0_green)>>8,
+ ((short)0xFF00 & style.fg0_blue)>>8);
+ }
+
+ public Color backgroundColorNORMAL() {
+ return new Color(null,
+ ((short)0xFF00 & style.bg0_red)>>8,
+ ((short)0xFF00 & style.bg0_green)>>8,
+ ((short)0xFF00 & style.bg0_blue)>>8);
+ }
+
+ public Color foregroundColorACTIVE() {
+ return new Color(null,
+ ((short)0xFF00 & style.fg1_red)>>8,
+ ((short)0xFF00 & style.fg1_green)>>8,
+ ((short)0xFF00 & style.fg1_blue)>>8);
+ }
+
+ public Color backgroundColorACTIVE() {
+ return new Color(null,
+ ((short)0xFF00 & style.bg1_red)>>8,
+ ((short)0xFF00 & style.bg1_green)>>8,
+ ((short)0xFF00 & style.bg1_blue)>>8);
+ }
+
+ public Color foregroundColorPRELIGHT() {
+ return new Color(null,
+ ((short)0xFF00 & style.fg2_red)>>8,
+ ((short)0xFF00 & style.fg2_green)>>8,
+ ((short)0xFF00 & style.fg2_blue)>>8);
+ }
+
+ public Color backgroundColorPRELIGHT() {
+ return new Color(null,
+ ((short)0xFF00 & style.bg2_red)>>8,
+ ((short)0xFF00 & style.bg2_green)>>8,
+ ((short)0xFF00 & style.bg2_blue)>>8);
+ }
+
+ public Color foregroundColorSELECTED() {
+ return new Color(null,
+ ((short)0xFF00 & style.fg3_red)>>8,
+ ((short)0xFF00 & style.fg3_green)>>8,
+ ((short)0xFF00 & style.fg3_blue)>>8);
+ }
+
+ public Color backgroundColorSELECTED() {
+ return new Color(null,
+ ((short)0xFF00 & style.bg3_red)>>8,
+ ((short)0xFF00 & style.bg3_green)>>8,
+ ((short)0xFF00 & style.bg3_blue)>>8);
+ }
+
+ public Color foregroundColorINSENSITIVE() {
+ return new Color(null,
+ ((short)0xFF00 & style.fg4_red)>>8,
+ ((short)0xFF00 & style.fg4_green)>>8,
+ ((short)0xFF00 & style.fg4_blue)>>8);
+ }
+
+ public Color backgroundColorINSENSITIVE() {
+ return new Color(null,
+ ((short)0xFF00 & style.bg4_red)>>8,
+ ((short)0xFF00 & style.bg4_green)>>8,
+ ((short)0xFF00 & style.bg4_blue)>>8);
+ }
+
+ public int loadDefaultFont() {
+ if (defaultFont == 0) {
+ int fnames = Font.getFontNameList(style.font);
+ int slength = OS.g_slist_length(fnames);
+ if (slength < 1) SWT.error(SWT.ERROR_UNSPECIFIED);
+ int name1 = OS.g_slist_nth_data(fnames, 0);
+ int length = OS.strlen(name1);
+ byte [] buffer1 = new byte[length];
+ OS.memmove(buffer1, name1, length);
+ defaultFont = OS.gdk_font_load(buffer1);
+ if (defaultFont==0) SWT.error(SWT.ERROR_UNSPECIFIED);
+ GdkFont gdkFont = new GdkFont();
+ OS.memmove(gdkFont, defaultFont, GdkFont.sizeof);
+ if (gdkFont.type != OS.GDK_FONT_FONT) SWT.error(SWT.ERROR_UNSPECIFIED);
+ }
+ return defaultFont;
+ }
+
+ public static DefaultGtkStyle instance() {
+ if (instance==null) instance = new DefaultGtkStyle();
+ return instance;
+ }
+
+ private DefaultGtkStyle() {
+ style = new GtkStyle();
+ OS.memmove(style, OS.gtk_widget_get_default_style(), GtkStyle.sizeof);
+ }
+
+}
+
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk1x/org/eclipse/swt/graphics/FontData.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk1x/org/eclipse/swt/graphics/FontData.java
index 5a7775fcef..7ee07bde3f 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk1x/org/eclipse/swt/graphics/FontData.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk1x/org/eclipse/swt/graphics/FontData.java
@@ -1,121 +1,121 @@
-package org.eclipse.swt.graphics;
-
-/*
+package org.eclipse.swt.graphics;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-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 {
- /**
- * 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;
- /**
- * The locales of the font
- * (Warning: These fields are platform dependent)
- */
- String lang, country, variant;
-
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+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 {
+ /**
+ * 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;
+ /**
+ * The locales of the font
+ * (Warning: These fields are platform dependent)
+ */
+ String lang, country, variant;
+
/**
* Constructs a new un-initialized font data.
*/
-public FontData () {
-}
+public FontData () {
+}
/**
* Constructs a new FontData given a string representation
* in the form generated by the <code>FontData.toString</code>
@@ -135,75 +135,75 @@ public FontData () {
*
* @see #toString
*/
-public FontData(String string) {
- if (string == null) error(SWT.ERROR_NULL_ARGUMENT);
- int start = 0;
- int end = string.indexOf('|');
- if (end == -1) error(SWT.ERROR_NULL_ARGUMENT);
- String version1 = string.substring(start, end);
-
- start = end + 1;
- end = string.indexOf('|', start);
- if (end == -1) error(SWT.ERROR_NULL_ARGUMENT);
- String name = string.substring(start, end);
-
- start = end + 1;
- end = string.indexOf('|', start);
- if (end == -1) error(SWT.ERROR_NULL_ARGUMENT);
- int height = 0;
- try {
- height = Integer.parseInt(string.substring(start, end));
- } catch (NumberFormatException e) {
- error(SWT.ERROR_NULL_ARGUMENT);
- }
-
- start = end + 1;
- end = string.indexOf('|', start);
- if (end == -1) error(SWT.ERROR_NULL_ARGUMENT);
- int style = 0;
- try {
- style = Integer.parseInt(string.substring(start, end));
- } catch (NumberFormatException e) {
- 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 string) {
+ if (string == null) error(SWT.ERROR_NULL_ARGUMENT);
+ int start = 0;
+ int end = string.indexOf('|');
+ if (end == -1) error(SWT.ERROR_NULL_ARGUMENT);
+ String version1 = string.substring(start, end);
+
+ start = end + 1;
+ end = string.indexOf('|', start);
+ if (end == -1) error(SWT.ERROR_NULL_ARGUMENT);
+ String name = string.substring(start, end);
+
+ start = end + 1;
+ end = string.indexOf('|', start);
+ if (end == -1) error(SWT.ERROR_NULL_ARGUMENT);
+ int height = 0;
+ try {
+ height = Integer.parseInt(string.substring(start, end));
+ } catch (NumberFormatException e) {
+ error(SWT.ERROR_NULL_ARGUMENT);
+ }
+
+ start = end + 1;
+ end = string.indexOf('|', start);
+ if (end == -1) error(SWT.ERROR_NULL_ARGUMENT);
+ int style = 0;
+ try {
+ style = Integer.parseInt(string.substring(start, end));
+ } catch (NumberFormatException e) {
+ 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);
+}
/**
* Constructs a new font data given a font name,
* the height of the desired font in points,
@@ -218,119 +218,119 @@ public FontData(String string) {
* <li>ERROR_INVALID_ARGUMENT - if the height is negative</li>
* </ul>
*/
-public FontData(String name, int height, int style) {
- if (name == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
- if (height < 0) error(SWT.ERROR_INVALID_ARGUMENT);
- 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 getters
- */
-
-/**
- * Returns the height of the receiver in points.
- *
- * @return the height of this FontData
- *
- * @see #setHeight
- */
-public int getHeight() {
- return points / 10;
-}
-
-/**
- * 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() {
- StringBuffer buffer = new StringBuffer();
- if (foundry != null) {
- buffer.append(foundry);
- buffer.append("-");
- }
- if (fontFamily != null) buffer.append(fontFamily);
- return buffer.toString();
-}
-
-/**
- * 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 = 0;
- if (weight.equals("bold"))
- style |= SWT.BOLD;
- if (slant.equals("i"))
- style |= SWT.ITALIC;
- return style;
-}
-
-/**
- * We need this in FontDialog, so we can't just get rid of it or make it private.
- */
-public String gtk_getXlfd() { return getXlfd(); }
-
-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;
-// The following line has been intentionally commented.
-// we don not know the exact average width as in the font definition,
-// so if someone tries to get a similar font, they'd get something weird
-// if (averageWidth != 0) s12 = Integer.toString(averageWidth);
- if (characterSetRegistry != null) s13 = characterSetRegistry;
- if (characterSetName != null) s14 = characterSetName;
-
- String xlfd = "-" + s1+ "-" + s2 + "-" + s3 + "-" + s4 + "-" + s5 + "-" + s6 + "-" + s7 + "-" + s8 + "-"
- + s9 + "-" + s10 + "-" + s11 + "-" + s12 + "-" + s13 + "-" + s14;
- return xlfd;
-}
-public static FontData gtk_new(String xlfd) {
- FontData fontData = new FontData();
- fontData.setXlfd(xlfd);
- return fontData;
-}
+public FontData(String name, int height, int style) {
+ if (name == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ if (height < 0) error(SWT.ERROR_INVALID_ARGUMENT);
+ 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 getters
+ */
+
+/**
+ * Returns the height of the receiver in points.
+ *
+ * @return the height of this FontData
+ *
+ * @see #setHeight
+ */
+public int getHeight() {
+ return points / 10;
+}
+
+/**
+ * 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() {
+ StringBuffer buffer = new StringBuffer();
+ if (foundry != null) {
+ buffer.append(foundry);
+ buffer.append("-");
+ }
+ if (fontFamily != null) buffer.append(fontFamily);
+ return buffer.toString();
+}
+
+/**
+ * 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 = 0;
+ if (weight.equals("bold"))
+ style |= SWT.BOLD;
+ if (slant.equals("i"))
+ style |= SWT.ITALIC;
+ return style;
+}
+
+/**
+ * We need this in FontDialog, so we can't just get rid of it or make it private.
+ */
+public String gtk_getXlfd() { return getXlfd(); }
+
+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;
+// The following line has been intentionally commented.
+// we don not know the exact average width as in the font definition,
+// so if someone tries to get a similar font, they'd get something weird
+// if (averageWidth != 0) s12 = Integer.toString(averageWidth);
+ if (characterSetRegistry != null) s13 = characterSetRegistry;
+ if (characterSetName != null) s14 = characterSetName;
+
+ String xlfd = "-" + s1+ "-" + s2 + "-" + s3 + "-" + s4 + "-" + s5 + "-" + s6 + "-" + s7 + "-" + s8 + "-"
+ + s9 + "-" + s10 + "-" + s11 + "-" + s12 + "-" + s13 + "-" + s14;
+ return xlfd;
+}
+public static FontData gtk_new(String xlfd) {
+ FontData fontData = new FontData();
+ fontData.setXlfd(xlfd);
+ return fontData;
+}
/**
* Returns an integer hash code for the receiver. Any two
* objects which return <code>true</code> when passed to
@@ -341,9 +341,9 @@ public static FontData gtk_new(String xlfd) {
*
* @see #equals
*/
-public int hashCode () {
- return getXlfd().hashCode();
-}
+public int hashCode () {
+ return getXlfd().hashCode();
+}
/**
* Sets the height of the receiver. The parameter is
* specified in terms of points, where a point is one
@@ -357,47 +357,47 @@ public int hashCode () {
*
* @see #getHeight
*/
-public void setHeight(int height) {
- if (height < 0) error(SWT.ERROR_INVALID_ARGUMENT);
- points = height * 10;
-}
-
-/**
- * Sets the locale of the receiver.
- * <p>
- * The locale determines which platform character set this
- * font is going to use. Widgets and graphics operations that
- * use this font will convert UNICODE strings to the platform
- * character set of the specified locale.
- * </p>
- * <p>
- * On platforms which there are multiple character sets for a
- * given language/country locale, the variant portion of the
- * locale will determine the character set.
- * </p>
- *
- * @param locale the <code>String</code> representing a Locale object
- * @see java.util.Locale#toString
- */
-public void setLocale(String locale) {
- lang = country = variant = null;
- if (locale != null) {
- char sep = '_';
- int length = locale.length();
- int firstSep, secondSep;
-
- firstSep = locale.indexOf(sep);
- if (firstSep == -1) {
- firstSep = secondSep = length;
- } else {
- secondSep = locale.indexOf(sep, firstSep + 1);
- if (secondSep == -1) secondSep = length;
- }
- if (firstSep > 0) lang = locale.substring(0, firstSep);
- if (secondSep > firstSep + 1) country = locale.substring(firstSep + 1, secondSep);
- if (length > secondSep + 1) variant = locale.substring(secondSep + 1);
- }
-}
+public void setHeight(int height) {
+ if (height < 0) error(SWT.ERROR_INVALID_ARGUMENT);
+ points = height * 10;
+}
+
+/**
+ * Sets the locale of the receiver.
+ * <p>
+ * The locale determines which platform character set this
+ * font is going to use. Widgets and graphics operations that
+ * use this font will convert UNICODE strings to the platform
+ * character set of the specified locale.
+ * </p>
+ * <p>
+ * On platforms which there are multiple character sets for a
+ * given language/country locale, the variant portion of the
+ * locale will determine the character set.
+ * </p>
+ *
+ * @param locale the <code>String</code> representing a Locale object
+ * @see java.util.Locale#toString
+ */
+public void setLocale(String locale) {
+ lang = country = variant = null;
+ if (locale != null) {
+ char sep = '_';
+ int length = locale.length();
+ int firstSep, secondSep;
+
+ firstSep = locale.indexOf(sep);
+ if (firstSep == -1) {
+ firstSep = secondSep = length;
+ } else {
+ secondSep = locale.indexOf(sep, firstSep + 1);
+ if (secondSep == -1) secondSep = length;
+ }
+ if (firstSep > 0) lang = locale.substring(0, firstSep);
+ if (secondSep > firstSep + 1) country = locale.substring(firstSep + 1, secondSep);
+ if (length > secondSep + 1) variant = locale.substring(secondSep + 1);
+ }
+}
/**
* Sets the name of the receiver.
* <p>
@@ -423,16 +423,16 @@ public void setLocale(String locale) {
*
* @see #getName
*/
-public void setName(String name) {
- if (name == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
- int dash = name.indexOf('-');
- if (dash != -1) {
- foundry = name.substring(0, dash);
- fontFamily = name.substring(dash + 1);
- } else {
- fontFamily = name;
- }
-}
+public void setName(String name) {
+ if (name == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ int dash = name.indexOf('-');
+ if (dash != -1) {
+ foundry = name.substring(0, dash);
+ fontFamily = name.substring(dash + 1);
+ } else {
+ fontFamily = name;
+ }
+}
/**
* Sets the style of the receiver to the argument which must
* be a bitwise OR of one or more of the <code>SWT</code>
@@ -442,79 +442,79 @@ public void setName(String name) {
*
* @see #getStyle
*/
-public void setStyle(int style) {
- if ((style & SWT.BOLD) == SWT.BOLD)
- weight = "bold";
- else
- weight = "medium";
- 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 void setStyle(int style) {
+ if ((style & SWT.BOLD) == SWT.BOLD)
+ weight = "bold";
+ else
+ weight = "medium";
+ 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;
+}
/**
* Returns a string representation of the receiver which is suitable
* for constructing an equivalent instance using the
@@ -524,11 +524,11 @@ void setXlfd(String xlfd) {
*
* @see FontData
*/
-public String toString() {
- return "1|" + fontFamily + "|" + getHeight() + "|" + getStyle() + "|" +
- "GTK|1|" + getXlfd();
-}
-
+public String toString() {
+ return "1|" + fontFamily + "|" + getHeight() + "|" + getStyle() + "|" +
+ "GTK|1|" + getXlfd();
+}
+
/**
* Compares the argument to the receiver, and returns true
* if they represent the <em>same</em> object using a class
@@ -539,11 +539,11 @@ public String toString() {
*
* @see #hashCode
*/
-public boolean equals (Object object) {
- return (object == this) || ((object instanceof FontData) &&
- getXlfd().equals(((FontData)object).getXlfd()));
-}
-void error(int code) {
- throw new SWTError(code);
-}
-}
+public boolean equals (Object object) {
+ return (object == this) || ((object instanceof FontData) &&
+ getXlfd().equals(((FontData)object).getXlfd()));
+}
+void error(int code) {
+ throw new SWTError(code);
+}
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk1x/org/eclipse/swt/graphics/FontMetrics.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk1x/org/eclipse/swt/graphics/FontMetrics.java
index b813e7c3e2..0d1cc835b4 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk1x/org/eclipse/swt/graphics/FontMetrics.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk1x/org/eclipse/swt/graphics/FontMetrics.java
@@ -1,14 +1,14 @@
-package org.eclipse.swt.graphics;
-
-/*
+package org.eclipse.swt.graphics;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-import org.eclipse.swt.internal.gtk.*;
-
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+import org.eclipse.swt.internal.gtk.*;
+
/**
* Instances of this class provide measurement information
* about fonts including ascent, descent, height, leading
@@ -18,11 +18,11 @@ import org.eclipse.swt.internal.gtk.*;
*
* @see GC#getFontMetrics
*/
-
-public final class FontMetrics {
- int ascent, descent, averageCharWidth, leading, height;
-FontMetrics() {
-}
+
+public final class FontMetrics {
+ int ascent, descent, averageCharWidth, leading, height;
+FontMetrics() {
+}
/**
* Compares the argument to the receiver, and returns true
* if they represent the <em>same</em> object using a class
@@ -33,14 +33,14 @@ FontMetrics() {
*
* @see #hashCode
*/
-public boolean equals (Object object) {
- if (object == this) return true;
- if (!(object instanceof FontMetrics)) return false;
- FontMetrics metrics = (FontMetrics)object;
- return ascent == metrics.ascent && descent == metrics.descent &&
- averageCharWidth == metrics.averageCharWidth && leading == metrics.leading &&
- height == metrics.height;
-}
+public boolean equals (Object object) {
+ if (object == this) return true;
+ if (!(object instanceof FontMetrics)) return false;
+ FontMetrics metrics = (FontMetrics)object;
+ return ascent == metrics.ascent && descent == metrics.descent &&
+ averageCharWidth == metrics.averageCharWidth && leading == metrics.leading &&
+ height == metrics.height;
+}
/**
* Returns the ascent of the font described by the receiver. A
* font's <em>ascent</em> is the distance from the baseline to the
@@ -49,18 +49,18 @@ public boolean equals (Object object) {
*
* @return the ascent of the font
*/
-public int getAscent() {
- return ascent;
-}
+public int getAscent() {
+ return ascent;
+}
/**
* Returns the average character width, measured in pixels,
* of the font described by the receiver.
*
* @return the average character width of the font
*/
-public int getAverageCharWidth() {
- return averageCharWidth;
-}
+public int getAverageCharWidth() {
+ return averageCharWidth;
+}
/**
* Returns the descent of the font described by the receiver. A
* font's <em>descent</em> is the distance from the baseline to the
@@ -69,9 +69,9 @@ public int getAverageCharWidth() {
*
* @return the descent of the font
*/
-public int getDescent() {
- return descent;
-}
+public int getDescent() {
+ return descent;
+}
/**
* Returns the height of the font described by the receiver,
* measured in pixels. A font's <em>height</em> is the sum of
@@ -83,9 +83,9 @@ public int getDescent() {
* @see #getDescent
* @see #getLeading
*/
-public int getHeight() {
- return height;
-}
+public int getHeight() {
+ return height;
+}
/**
* Returns the leading area of the font described by the
* receiver. A font's <em>leading area</em> is the space
@@ -93,21 +93,21 @@ public int getHeight() {
*
* @return the leading space of the font
*/
-public int getLeading() {
- return leading;
-}
-public static FontMetrics gtk_new(int fontHandle) {
- GdkFont f = new GdkFont();
- OS.memmove (f, fontHandle, GdkFont.sizeof);
-
- FontMetrics fontMetrics = new FontMetrics();
- fontMetrics.ascent = f.ascent;
- fontMetrics.descent = f.descent;
- fontMetrics.averageCharWidth = OS.gdk_char_width(fontHandle, (byte)'a');
- fontMetrics.leading = 3;
- fontMetrics.height = fontMetrics.ascent+fontMetrics.descent+3;
- return fontMetrics;
-}
+public int getLeading() {
+ return leading;
+}
+public static FontMetrics gtk_new(int fontHandle) {
+ GdkFont f = new GdkFont();
+ OS.memmove (f, fontHandle, GdkFont.sizeof);
+
+ FontMetrics fontMetrics = new FontMetrics();
+ fontMetrics.ascent = f.ascent;
+ fontMetrics.descent = f.descent;
+ fontMetrics.averageCharWidth = OS.gdk_char_width(fontHandle, (byte)'a');
+ fontMetrics.leading = 3;
+ fontMetrics.height = fontMetrics.ascent+fontMetrics.descent+3;
+ return fontMetrics;
+}
/**
* Returns an integer hash code for the receiver. Any two
* objects which return <code>true</code> when passed to
@@ -118,7 +118,7 @@ public static FontMetrics gtk_new(int fontHandle) {
*
* @see #equals
*/
-public int hashCode() {
- return ascent ^ descent ^ averageCharWidth ^ leading ^ height;
-}
-}
+public int hashCode() {
+ return ascent ^ descent ^ averageCharWidth ^ leading ^ height;
+}
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk1x/org/eclipse/swt/graphics/GCData.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk1x/org/eclipse/swt/graphics/GCData.java
index a974c8f92a..1ea5305461 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk1x/org/eclipse/swt/graphics/GCData.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk1x/org/eclipse/swt/graphics/GCData.java
@@ -1,14 +1,14 @@
-package org.eclipse.swt.graphics;
-
-/*
+package org.eclipse.swt.graphics;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-import org.eclipse.swt.*;
-
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+import org.eclipse.swt.*;
+
/**
* Instances of this class are descriptions of GCs in terms
* of unallocated platform-specific data fields.
@@ -21,10 +21,10 @@ import org.eclipse.swt.*;
*
* @private
*/
-public final class GCData {
- public Image image;
- public int drawable;
- public int clipRgn;
- public int lineStyle = SWT.LINE_SOLID;
- public int renderTable;
+public final class GCData {
+ public Image image;
+ public int drawable;
+ public int clipRgn;
+ public int lineStyle = SWT.LINE_SOLID;
+ public int renderTable;
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk1x/org/eclipse/swt/graphics/Region.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk1x/org/eclipse/swt/graphics/Region.java
index e94f7cf2d3..b0eadc948d 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk1x/org/eclipse/swt/graphics/Region.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk1x/org/eclipse/swt/graphics/Region.java
@@ -1,15 +1,15 @@
-package org.eclipse.swt.graphics;
-
-/*
+package org.eclipse.swt.graphics;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-import org.eclipse.swt.internal.gtk.*;
-import org.eclipse.swt.*;
-
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+import org.eclipse.swt.internal.gtk.*;
+import org.eclipse.swt.*;
+
/**
* Instances of this class represent areas of an x-y coordinate
* system that are aggregates of the areas covered by a number
@@ -20,21 +20,21 @@ import org.eclipse.swt.*;
* when those instances are no longer required.
* </p>
*/
-public final class Region {
+public final class Region {
/**
* the OS resource for the region
* (Warning: This field is platform dependent)
*/
- public int handle;
+ public int handle;
/**
* Constructs a new empty region.
*/
-public Region() {
- handle = OS.gdk_region_new();
-}
-Region(int handle) {
- this.handle = handle;
-}
+public Region() {
+ handle = OS.gdk_region_new();
+}
+Region(int handle) {
+ this.handle = handle;
+}
/**
* Adds the given rectangle to the collection of rectangles
* the receiver maintains to describe its area.
@@ -49,22 +49,22 @@ Region(int handle) {
* <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
* </ul>
*/
-public void add(Rectangle rect) {
- if (rect == null) error(SWT.ERROR_NULL_ARGUMENT);
- if (rect.width < 0 || rect.height < 0) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
- GdkRectangle gdkRect = new GdkRectangle();
- gdkRect.x = (short)rect.x;
- gdkRect.y = (short)rect.y;
- gdkRect.width = (short)rect.width;
- gdkRect.height = (short)rect.height;
- int hOld = handle;
- /**
- * Feature in GDK. Due to the way the GDK region calls work,
- * we have to reassign the handle and destroy the old one.
- */
- handle = OS.gdk_region_union_with_rect(handle, gdkRect);
- OS.gdk_region_destroy(hOld);
-}
+public void add(Rectangle rect) {
+ if (rect == null) error(SWT.ERROR_NULL_ARGUMENT);
+ if (rect.width < 0 || rect.height < 0) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+ GdkRectangle gdkRect = new GdkRectangle();
+ gdkRect.x = (short)rect.x;
+ gdkRect.y = (short)rect.y;
+ gdkRect.width = (short)rect.width;
+ gdkRect.height = (short)rect.height;
+ int hOld = handle;
+ /**
+ * Feature in GDK. Due to the way the GDK region calls work,
+ * we have to reassign the handle and destroy the old one.
+ */
+ handle = OS.gdk_region_union_with_rect(handle, gdkRect);
+ OS.gdk_region_destroy(hOld);
+}
/**
* Adds all of the rectangles which make up the area covered
* by the argument to the collection of rectangles the receiver
@@ -80,16 +80,16 @@ public void add(Rectangle rect) {
* <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
* </ul>
*/
-public void add(Region region) {
- if (region == null) error(SWT.ERROR_NULL_ARGUMENT);
- /**
- * Feature in GDK. Due to the way the GDK region calls work,
- * we have to reassign the handle and destroy the old one.
- */
- int hOld = handle;
- handle = OS.gdk_regions_union(handle, region.handle);
- OS.gdk_region_destroy(hOld);
-}
+public void add(Region region) {
+ if (region == null) error(SWT.ERROR_NULL_ARGUMENT);
+ /**
+ * Feature in GDK. Due to the way the GDK region calls work,
+ * we have to reassign the handle and destroy the old one.
+ */
+ int hOld = handle;
+ handle = OS.gdk_regions_union(handle, region.handle);
+ OS.gdk_region_destroy(hOld);
+}
/**
* Returns <code>true</code> if the point specified by the
* arguments is inside the area specified by the receiver,
@@ -103,9 +103,9 @@ public void add(Region region) {
* <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
* </ul>
*/
-public boolean contains(int x, int y) {
- return OS.gdk_region_point_in(handle, x, y);
-}
+public boolean contains(int x, int y) {
+ return OS.gdk_region_point_in(handle, x, y);
+}
/**
* Returns <code>true</code> if the given point is inside the
* area specified by the receiver, and <code>false</code>
@@ -121,19 +121,19 @@ public boolean contains(int x, int y) {
* <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
* </ul>
*/
-public boolean contains(Point pt) {
- if (pt == null) error(SWT.ERROR_NULL_ARGUMENT);
- return contains(pt.x, pt.y);
-}
+public boolean contains(Point pt) {
+ if (pt == null) 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.gdk_region_destroy(handle);
- handle = 0;
-}
+public void dispose() {
+ if (handle != 0) OS.gdk_region_destroy(handle);
+ handle = 0;
+}
/**
* Compares the argument to the receiver, and returns true
* if they represent the <em>same</em> object using a class
@@ -144,17 +144,17 @@ public void dispose() {
*
* @see #hashCode
*/
-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.gdk_region_equal(handle, xRegion);
-}
-void error(int code) {
- throw new SWTError(code);
-}
+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.gdk_region_equal(handle, xRegion);
+}
+void error(int code) {
+ throw new SWTError(code);
+}
/**
* Returns a rectangle which represents the rectangular
* union of the collection of rectangles the receiver
@@ -168,14 +168,14 @@ void error(int code) {
*
* @see Rectangle#union
*/
-public Rectangle getBounds() {
- GdkRectangle rect = new GdkRectangle();
- OS.gdk_region_get_clipbox(handle, rect);
- return new Rectangle(rect.x, rect.y, rect.width, rect.height);
-}
-public static Region gtk_new(int handle) {
- return new Region(handle);
-}
+public Rectangle getBounds() {
+ GdkRectangle rect = new GdkRectangle();
+ OS.gdk_region_get_clipbox(handle, rect);
+ return new Rectangle(rect.x, rect.y, rect.width, rect.height);
+}
+public static Region gtk_new(int handle) {
+ return new Region(handle);
+}
/**
* Returns an integer hash code for the receiver. Any two
* objects which return <code>true</code> when passed to
@@ -186,9 +186,9 @@ public static Region gtk_new(int handle) {
*
* @see #equals
*/
-public int hashCode() {
- return handle;
-}
+public int hashCode() {
+ return handle;
+}
/**
* Returns <code>true</code> if the rectangle described by the
* arguments intersects with any of the rectangles the receiver
@@ -206,14 +206,14 @@ public int hashCode() {
*
* @see Rectangle#intersects
*/
-public boolean intersects (int x, int y, int width, int height) {
- GdkRectangle osRect = new GdkRectangle();
- osRect.x = (short)x;
- osRect.y = (short)y;
- osRect.width = (short)width;
- osRect.height = (short)height;
- return OS.gdk_region_rect_in(handle, osRect) != OS.GDK_OVERLAP_RECTANGLE_OUT;
-}
+public boolean intersects (int x, int y, int width, int height) {
+ GdkRectangle osRect = new GdkRectangle();
+ osRect.x = (short)x;
+ osRect.y = (short)y;
+ osRect.width = (short)width;
+ osRect.height = (short)height;
+ return OS.gdk_region_rect_in(handle, osRect) != OS.GDK_OVERLAP_RECTANGLE_OUT;
+}
/**
* Returns <code>true</code> if the given rectangle intersects
* with any of the rectangles the receiver mainains to describe
@@ -231,10 +231,10 @@ public boolean intersects (int x, int y, int width, int height) {
*
* @see Rectangle#intersects
*/
-public boolean intersects(Rectangle rect) {
- if (rect == null) error(SWT.ERROR_NULL_ARGUMENT);
- return intersects(rect.x, rect.y, rect.width, rect.height);
-}
+public boolean intersects(Rectangle rect) {
+ if (rect == null) 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.
@@ -245,9 +245,9 @@ public boolean intersects(Rectangle rect) {
*
* @return <code>true</code> when the region is disposed, and <code>false</code> otherwise
*/
-public boolean isDisposed() {
- return handle == 0;
-}
+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
@@ -259,17 +259,17 @@ public boolean isDisposed() {
* <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
* </ul>
*/
-public boolean isEmpty() {
- return OS.gdk_region_empty(handle);
-}
-/**
- * Returns a string containing a concise, human-readable
- * description of the receiver.
- *
- * @return a string representation of the receiver
- */
-public String toString () {
- if (isDisposed()) return "Region {*DISPOSED*}";
- return "Region {" + handle + "}";
-}
-}
+public boolean isEmpty() {
+ return OS.gdk_region_empty(handle);
+}
+/**
+ * Returns a string containing a concise, human-readable
+ * description of the receiver.
+ *
+ * @return a string representation of the receiver
+ */
+public String toString () {
+ if (isDisposed()) return "Region {*DISPOSED*}";
+ return "Region {" + handle + "}";
+}
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk1x/org/eclipse/swt/internal/Converter.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk1x/org/eclipse/swt/internal/Converter.java
index 642aaa1fef..0efeadd167 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk1x/org/eclipse/swt/internal/Converter.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk1x/org/eclipse/swt/internal/Converter.java
@@ -1,12 +1,12 @@
-package org.eclipse.swt.internal;
-
-/*
+package org.eclipse.swt.internal;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
/**
* This class implements the conversions between unicode characters
* and the <em>platform supported</em> representation for characters.
@@ -14,59 +14,59 @@ package org.eclipse.swt.internal;
* Note that, unicode characters which can not be found in the platform
* encoding will be converted to an arbitrary platform specific character.
* </p>
- */
-public final class Converter {
- public static final byte [] NullByteArray = new byte [1];
- public static final char [] NullCharArray = new char [1];
- public static final byte [] EmptyByteArray = new byte [0];
- public static final char [] EmptyCharArray = new char [0];
+ */
+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];
/**
* Returns the default code page for the platform where the
* application is currently running.
*
* @return the default code page
*/
-public static String defaultCodePage () {
- 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;
-}
-}
+public static String defaultCodePage () {
+ 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/gtk1x/org/eclipse/swt/widgets/ColorDialog.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk1x/org/eclipse/swt/widgets/ColorDialog.java
index 623dd809bc..c7c4f0db46 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk1x/org/eclipse/swt/widgets/ColorDialog.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk1x/org/eclipse/swt/widgets/ColorDialog.java
@@ -1,17 +1,17 @@
-package org.eclipse.swt.widgets;
-
-/*
+package org.eclipse.swt.widgets;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-import org.eclipse.swt.*;
-import org.eclipse.swt.internal.*;
-import org.eclipse.swt.internal.gtk.*;
-import org.eclipse.swt.graphics.*;
-
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+import org.eclipse.swt.*;
+import org.eclipse.swt.internal.*;
+import org.eclipse.swt.internal.gtk.*;
+import org.eclipse.swt.graphics.*;
+
/**
* Instances of this class allow the user to select a color
* from a predefined set of available colors.
@@ -25,9 +25,9 @@ import org.eclipse.swt.graphics.*;
* IMPORTANT: This class is intended to be subclassed <em>only</em>
* within the SWT implementation.
* </p>
- */
-public class ColorDialog extends Dialog {
- RGB rgb;
+ */
+public class ColorDialog extends Dialog {
+ RGB rgb;
/**
* Constructs a new instance of this class given only its parent.
*
@@ -45,9 +45,9 @@ public class ColorDialog extends Dialog {
* @see Widget#checkSubclass
* @see Widget#getStyle
*/
-public ColorDialog (Shell parent) {
- this (parent, SWT.NULL);
-}
+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.
@@ -76,18 +76,18 @@ public ColorDialog (Shell parent) {
* @see Widget#checkSubclass
* @see Widget#getStyle
*/
-public ColorDialog (Shell parent, int style) {
- super (parent, style);
- checkSubclass ();
-}
-int cancelFunc (int widget, int callData) {
- OS.gtk_widget_destroy (callData);
- return 0;
-}
-int destroyFunc (int widget, int colorInfo) {
- OS.gtk_main_quit ();
- return 0;
-}
+public ColorDialog (Shell parent, int style) {
+ super (parent, style);
+ checkSubclass ();
+}
+int cancelFunc (int widget, int callData) {
+ OS.gtk_widget_destroy (callData);
+ return 0;
+}
+int destroyFunc (int widget, int colorInfo) {
+ OS.gtk_main_quit ();
+ return 0;
+}
/**
* Returns the currently selected color in the receiver.
*
@@ -95,18 +95,18 @@ int destroyFunc (int widget, int colorInfo) {
*
* @see PaletteData#getRGBs
*/
-public RGB getRGB () {
- return rgb;
-}
-int okFunc (int widget, int callData) {
- GtkColorSelectionDialog dialog = new GtkColorSelectionDialog ();
- OS.memmove (dialog, callData, GtkColorSelectionDialog.sizeof);
- double [] color = new double [4];
- OS.gtk_color_selection_get_color (dialog.colorsel, color);
- rgb = new RGB ((int)(color [0] * 256), (int)(color [1] * 256), (int)(color [2] * 256));
- OS.gtk_widget_destroy (callData);
- return 0;
-}
+public RGB getRGB () {
+ return rgb;
+}
+int okFunc (int widget, int callData) {
+ GtkColorSelectionDialog dialog = new GtkColorSelectionDialog ();
+ OS.memmove (dialog, callData, GtkColorSelectionDialog.sizeof);
+ double [] color = new double [4];
+ OS.gtk_color_selection_get_color (dialog.colorsel, color);
+ rgb = new RGB ((int)(color [0] * 256), (int)(color [1] * 256), (int)(color [2] * 256));
+ OS.gtk_widget_destroy (callData);
+ return 0;
+}
/**
* Makes the receiver visible and brings it to the front
* of the display.
@@ -120,43 +120,43 @@ int okFunc (int widget, int callData) {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public RGB open () {
- int handle;
- byte [] titleBytes;
- titleBytes = Converter.wcsToMbcs (null, title, true);
- handle = OS.gtk_color_selection_dialog_new (titleBytes);
- if (parent!=null) {
- OS.gtk_window_set_modal(handle, true);
- OS.gtk_window_set_transient_for(handle, parent.topHandle());
- } GtkColorSelectionDialog dialog = new GtkColorSelectionDialog ();
- OS.memmove (dialog, handle, GtkColorSelectionDialog.sizeof);
- OS.gtk_widget_hide (dialog.help_button);
- if (rgb != null) {
- double [] color = new double [4];
- color [0] = (double)rgb.red / 256;
- color [1] = (double)rgb.green / 256;
- color [2] = (double)rgb.blue / 256;
- OS.gtk_color_selection_set_color (dialog.colorsel, color);
- }
- Callback destroyCallback = new Callback (this, "destroyFunc", 2);
- int destroyFunc = destroyCallback.getAddress ();
- byte [] destroy = Converter.wcsToMbcs (null, "destroy", true);
- OS.gtk_signal_connect (handle, destroy, destroyFunc, handle);
- byte [] clicked = Converter.wcsToMbcs (null, "clicked", true);
- Callback okCallback = new Callback (this, "okFunc", 2);
- int okFunc = okCallback.getAddress ();
- Callback cancelCallback = new Callback (this, "cancelFunc", 2);
- int cancelFunc = cancelCallback.getAddress ();
- OS.gtk_signal_connect (dialog.ok_button, clicked, okFunc, handle);
- OS.gtk_signal_connect (dialog.cancel_button, clicked, cancelFunc, handle);
- rgb = null;
- OS.gtk_widget_show_now (handle);
- OS.gtk_main ();
- destroyCallback.dispose ();
- okCallback.dispose ();
- cancelCallback.dispose ();
- return rgb;
-}
+public RGB open () {
+ int handle;
+ byte [] titleBytes;
+ titleBytes = Converter.wcsToMbcs (null, title, true);
+ handle = OS.gtk_color_selection_dialog_new (titleBytes);
+ if (parent!=null) {
+ OS.gtk_window_set_modal(handle, true);
+ OS.gtk_window_set_transient_for(handle, parent.topHandle());
+ } GtkColorSelectionDialog dialog = new GtkColorSelectionDialog ();
+ OS.memmove (dialog, handle, GtkColorSelectionDialog.sizeof);
+ OS.gtk_widget_hide (dialog.help_button);
+ if (rgb != null) {
+ double [] color = new double [4];
+ color [0] = (double)rgb.red / 256;
+ color [1] = (double)rgb.green / 256;
+ color [2] = (double)rgb.blue / 256;
+ OS.gtk_color_selection_set_color (dialog.colorsel, color);
+ }
+ Callback destroyCallback = new Callback (this, "destroyFunc", 2);
+ int destroyFunc = destroyCallback.getAddress ();
+ byte [] destroy = Converter.wcsToMbcs (null, "destroy", true);
+ OS.gtk_signal_connect (handle, destroy, destroyFunc, handle);
+ byte [] clicked = Converter.wcsToMbcs (null, "clicked", true);
+ Callback okCallback = new Callback (this, "okFunc", 2);
+ int okFunc = okCallback.getAddress ();
+ Callback cancelCallback = new Callback (this, "cancelFunc", 2);
+ int cancelFunc = cancelCallback.getAddress ();
+ OS.gtk_signal_connect (dialog.ok_button, clicked, okFunc, handle);
+ OS.gtk_signal_connect (dialog.cancel_button, clicked, cancelFunc, handle);
+ rgb = null;
+ OS.gtk_widget_show_now (handle);
+ OS.gtk_main ();
+ destroyCallback.dispose ();
+ okCallback.dispose ();
+ cancelCallback.dispose ();
+ return rgb;
+}
/**
* Returns the receiver's selected color to be the argument.
*
@@ -166,7 +166,7 @@ public RGB open () {
*
* @see PaletteData#getRGBs
*/
-public void setRGB (RGB rgb) {
- this.rgb = rgb;
-}
-}
+public void setRGB (RGB rgb) {
+ this.rgb = rgb;
+}
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk1x/org/eclipse/swt/widgets/Decorations.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk1x/org/eclipse/swt/widgets/Decorations.java
index f060d6a0d3..3ea79e4c4c 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk1x/org/eclipse/swt/widgets/Decorations.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk1x/org/eclipse/swt/widgets/Decorations.java
@@ -1,18 +1,18 @@
-package org.eclipse.swt.widgets;
-
-/*
+package org.eclipse.swt.widgets;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-import org.eclipse.swt.*;
-import org.eclipse.swt.internal.*;
-import org.eclipse.swt.internal.gtk.*;
-import org.eclipse.swt.graphics.*;
-import org.eclipse.swt.graphics.*;
-
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+import org.eclipse.swt.*;
+import org.eclipse.swt.internal.*;
+import org.eclipse.swt.internal.gtk.*;
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.graphics.*;
+
/**
* Instances of this class provide the appearance and
* behavior of <code>Shells</code>, but are not top
@@ -84,17 +84,17 @@ import org.eclipse.swt.graphics.*;
* @see #getMaximized
* @see Shell
* @see SWT
- */
-
-public class Decorations extends Canvas {
- String text;
- Image image;
- Menu menuBar;
- Menu [] menus;
- Button defaultButton, saveDefault;
-Decorations () {
- /* Do nothing */
-}
+ */
+
+public class Decorations extends Canvas {
+ String text;
+ Image image;
+ Menu menuBar;
+ Menu [] menus;
+ Button defaultButton, saveDefault;
+Decorations () {
+ /* Do nothing */
+}
/**
* Constructs a new instance of this class given its parent
* and a style value describing its behavior and appearance.
@@ -122,36 +122,36 @@ Decorations () {
* @see SWT
* @see Widget#checkSubclass
* @see Widget#getStyle
- */
-public Decorations (Composite parent, int style) {
- super (parent, checkStyle (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 createWidget (int index) {
- super.createWidget (index);
- text = "";
-}
-
+ */
+public Decorations (Composite parent, int style) {
+ super (parent, checkStyle (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 createWidget (int index) {
+ super.createWidget (index);
+ text = "";
+}
+
/**
* Returns the receiver's default button if one had
* previously been set, otherwise returns null.
@@ -164,11 +164,11 @@ void createWidget (int index) {
* </ul>
*
* @see #setDefaultButton
- */
-public Button getDefaultButton () {
- checkWidget();
- return defaultButton;
-}
+ */
+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
@@ -189,11 +189,11 @@ public Button getDefaultButton () {
* <li>ERROR_WIDGET_DISPOSED - if 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 Image getImage () {
+ checkWidget();
+ return image;
+}
/**
* Returns <code>true</code> if the receiver is currently
* maximized, and false otherwise.
@@ -207,11 +207,11 @@ public Image getImage () {
* </ul>
*
* @see #setMaximized
- */
-public boolean getMaximized () {
- checkWidget();
- return false;
-}
+ */
+public boolean getMaximized () {
+ checkWidget();
+ return false;
+}
/**
* Returns the receiver's menu bar if one had previously
* been set, otherwise returns null.
@@ -222,11 +222,11 @@ public boolean getMaximized () {
* <li>ERROR_WIDGET_DISPOSED - if 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;
-}
+ */
+public Menu getMenuBar () {
+ checkWidget();
+ return menuBar;
+}
/**
* Returns <code>true</code> if the receiver is currently
* minimized, and false otherwise.
@@ -240,14 +240,14 @@ public Menu getMenuBar () {
* </ul>
*
* @see #setMinimized
- */
-public boolean getMinimized () {
- checkWidget();
- return false;
-}
-String getNameText () {
- return getText ();
-}
+ */
+public boolean getMinimized () {
+ checkWidget();
+ return false;
+}
+String getNameText () {
+ return getText ();
+}
/**
* Returns the receiver's text, which is the string that the
* window manager will typically display as the receiver's
@@ -260,44 +260,44 @@ String getNameText () {
* <li>ERROR_WIDGET_DISPOSED - if 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;
-}
-Decorations menuShell () {
- return this;
-}
-
-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 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 ();
- image = null;
- defaultButton = saveDefault = null;
-}
+ */
+public String getText () {
+ checkWidget();
+ return text;
+}
+Decorations menuShell () {
+ return this;
+}
+
+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 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 ();
+ image = null;
+ defaultButton = saveDefault = null;
+}
/**
* If the argument is not null, sets the receiver's default
* button to the argument, and if the argument is null, sets
@@ -317,10 +317,10 @@ void releaseWidget () {
* <li>ERROR_WIDGET_DISPOSED - if the 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();
-}
+ */
+public void setDefaultButton (Button button) {
+ checkWidget();
+}
/**
* Sets the receiver's image to the argument, which may
* be null. The image is typically displayed by the window
@@ -337,19 +337,19 @@ public void setDefaultButton (Button button) {
* <li>ERROR_WIDGET_DISPOSED - if the 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;
- int pixmap = 0, mask = 0;
- if (image != null) {
- pixmap = image.pixmap;
- mask = image.mask;
- }
- GtkWidget widget = new GtkWidget ();
- OS.memmove(widget, topHandle(), GtkWidget.sizeof);
- OS.gdk_window_set_icon (widget.window, 0, pixmap, mask);
-}
+ */
+public void setImage (Image image) {
+ checkWidget();
+ this.image = image;
+ int pixmap = 0, mask = 0;
+ if (image != null) {
+ pixmap = image.pixmap;
+ mask = image.mask;
+ }
+ GtkWidget widget = new GtkWidget ();
+ OS.memmove(widget, topHandle(), GtkWidget.sizeof);
+ OS.gdk_window_set_icon (widget.window, 0, pixmap, mask);
+}
/**
* Sets the maximized state of the receiver.
* If the argument is <code>true</code> causes the receiver
@@ -372,10 +372,10 @@ public void setImage (Image image) {
* </ul>
*
* @see #setMinimized
- */
-public void setMaximized (boolean maximized) {
- checkWidget();
-}
+ */
+public void setMaximized (boolean maximized) {
+ checkWidget();
+}
/**
* Sets the receiver's menu bar to the argument, which
* may be null.
@@ -390,16 +390,16 @@ public void setMaximized (boolean maximized) {
* <li>ERROR_WIDGET_DISPOSED - if the 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;
-}
+ */
+public void setMenuBar (Menu menu) {
+ checkWidget();
+ if (menuBar == menu) return;
+ if (menu != null) {
+ if ((menu.style & SWT.BAR) == 0) error (SWT.ERROR_MENU_NOT_BAR);
+ if (menu.parent != this) error (SWT.ERROR_INVALID_PARENT);
+ }
+ menuBar = menu;
+}
/**
* Sets the minimized stated of the receiver.
* If the argument is <code>true</code> causes the receiver
@@ -422,10 +422,10 @@ public void setMenuBar (Menu menu) {
* </ul>
*
* @see #setMaximized
- */
-public void setMinimized (boolean minimized) {
- checkWidget();
-}
+ */
+public void setMinimized (boolean minimized) {
+ checkWidget();
+}
/**
* Sets the receiver's text, which is the string that the
* window manager will typically display as the receiver's
@@ -440,10 +440,10 @@ public void setMinimized (boolean minimized) {
* <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
- */
-public void setText (String string) {
- checkWidget();
- if (string == null) error (SWT.ERROR_NULL_ARGUMENT);
- text = string;
-}
-}
+ */
+public void setText (String string) {
+ checkWidget();
+ if (string == null) error (SWT.ERROR_NULL_ARGUMENT);
+ text = string;
+}
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk1x/org/eclipse/swt/widgets/DirectoryDialog.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk1x/org/eclipse/swt/widgets/DirectoryDialog.java
index 2e5c13d72d..65074221a7 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk1x/org/eclipse/swt/widgets/DirectoryDialog.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk1x/org/eclipse/swt/widgets/DirectoryDialog.java
@@ -1,17 +1,17 @@
-package org.eclipse.swt.widgets;
-
-/*
+package org.eclipse.swt.widgets;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-import org.eclipse.swt.*;
-import org.eclipse.swt.internal.*;
-import org.eclipse.swt.internal.gtk.*;
-import org.eclipse.swt.widgets.*;
-
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+import org.eclipse.swt.*;
+import org.eclipse.swt.internal.*;
+import org.eclipse.swt.internal.gtk.*;
+import org.eclipse.swt.widgets.*;
+
/**
* Instances of this class allow the user to navigate
* the file system and select a directory.
@@ -19,12 +19,12 @@ import org.eclipse.swt.widgets.*;
* IMPORTANT: This class is intended to be subclassed <em>only</em>
* within the SWT implementation.
* </p>
- */
-
-public class DirectoryDialog extends GtkFileDialog {
- String message = "", filterPath = "";
- String directoryPath;
-
+ */
+
+public class DirectoryDialog extends GtkFileDialog {
+ String message = "", filterPath = "";
+ String directoryPath;
+
/**
* Constructs a new instance of this class given only its
* parent.
@@ -47,9 +47,9 @@ public class DirectoryDialog extends GtkFileDialog {
* <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
* </ul>
*/
-public DirectoryDialog (Shell parent) {
- this (parent, SWT.PRIMARY_MODAL);
-}
+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.
@@ -80,19 +80,19 @@ public DirectoryDialog (Shell parent) {
* <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
* </ul>
*/
-public DirectoryDialog (Shell parent, int style) {
- super (parent, style);
- checkSubclass ();
-}
+public DirectoryDialog (Shell parent, int style) {
+ super (parent, style);
+ checkSubclass ();
+}
/**
* Returns the path which the dialog will use to filter
* the directories it shows.
*
* @return the filter path
*/
-public String getFilterPath () {
- return filterPath;
-}
+public String getFilterPath () {
+ return filterPath;
+}
/**
* Returns the dialog's message, which is a description of
* the purpose for which it was opened. This message will be
@@ -100,10 +100,10 @@ public String getFilterPath () {
*
* @return the message
*/
-public String getMessage () {
- return message;
-}
-
+public String getMessage () {
+ return message;
+}
+
/**
* Makes the dialog visible and brings it to the front
* of the display.
@@ -116,10 +116,10 @@ public String getMessage () {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the dialog</li>
* </ul>
*/
-public String open () {
- return super.open();
-}
-
+public String open () {
+ return super.open();
+}
+
/**
* Sets the path which the dialog will use to filter
* the directories it shows to the argument, which may be
@@ -127,9 +127,9 @@ public String open () {
*
* @param string the filter path
*/
-public void setFilterPath (String string) {
- filterPath = string;
-}
+public void setFilterPath (String string) {
+ filterPath = string;
+}
/**
* Sets the dialog's message, which is a description of
* the purpose for which it was opened. This message will be
@@ -137,15 +137,15 @@ public void setFilterPath (String string) {
*
* @param string the message
*/
-public void setMessage (String string) {
- message = string;
-}
-
-boolean getAnswer() {
- String fileNameFromOS = getFileNameFromOS();
- int separatorIndex = calculateLastSeparatorIndex(fileNameFromOS);
- if (separatorIndex+1 != fileNameFromOS.length()) return false; // the user selected a file
- directoryPath = answer = fileNameFromOS;
- return true;
-}
-}
+public void setMessage (String string) {
+ message = string;
+}
+
+boolean getAnswer() {
+ String fileNameFromOS = getFileNameFromOS();
+ int separatorIndex = calculateLastSeparatorIndex(fileNameFromOS);
+ if (separatorIndex+1 != fileNameFromOS.length()) return false; // the user selected a file
+ directoryPath = answer = fileNameFromOS;
+ return true;
+}
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk1x/org/eclipse/swt/widgets/FileDialog.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk1x/org/eclipse/swt/widgets/FileDialog.java
index d4e21d8e7e..0c9691c09d 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk1x/org/eclipse/swt/widgets/FileDialog.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk1x/org/eclipse/swt/widgets/FileDialog.java
@@ -1,14 +1,14 @@
-package org.eclipse.swt.widgets;
-
-/*
+package org.eclipse.swt.widgets;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-import org.eclipse.swt.*;
-
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+import org.eclipse.swt.*;
+
/**
* Instances of this class allow the user to navigate
* the file system and select or enter a file name.
@@ -22,12 +22,12 @@ import org.eclipse.swt.*;
* IMPORTANT: This class is intended to be subclassed <em>only</em>
* within the SWT implementation.
* </p>
- */
-public class FileDialog extends GtkFileDialog {
-
- String fullPath, fileName, filterPath;
- String[] filterNames, filterExtensions;
-
+ */
+public class FileDialog extends GtkFileDialog {
+
+ String fullPath, fileName, filterPath;
+ String[] filterNames, filterExtensions;
+
/**
* Constructs a new instance of this class given only its
* parent.
@@ -50,9 +50,9 @@ public class FileDialog extends GtkFileDialog {
* <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
* </ul>
*/
-public FileDialog (Shell parent) {
- this (parent, SWT.PRIMARY_MODAL);
-}
+public FileDialog (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.
@@ -83,11 +83,11 @@ public FileDialog (Shell parent) {
* <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
* </ul>
*/
-public FileDialog (Shell parent, int style) {
- super (parent, style);
- checkSubclass ();
-}
-
+public FileDialog (Shell parent, int style) {
+ super (parent, style);
+ checkSubclass ();
+}
+
/**
* Returns the path of the first file that was
* selected in the dialog relative to the filter path,
@@ -95,47 +95,47 @@ public FileDialog (Shell parent, int style) {
*
* @return the relative path of the file
*/
-public String getFileName () {
- return fileName;
-}
-/**
- * Returns the paths of all files that were selected
- * in the dialog relative to the filter path, or null
- * if none are available.
- *
- * @return the relative paths of the files
- */
-public String [] getFileNames () {
- return new String[] {fileName};
-}
+public String getFileName () {
+ return fileName;
+}
+/**
+ * Returns the paths of all files that were selected
+ * in the dialog relative to the filter path, or null
+ * if none are available.
+ *
+ * @return the relative paths of the files
+ */
+public String [] getFileNames () {
+ return new String[] {fileName};
+}
/**
* Returns the file extensions which the dialog will
* use to filter the files it shows.
*
* @return the file extensions filter
*/
-public String [] getFilterExtensions () {
- return filterExtensions;
-}
+public String [] getFilterExtensions () {
+ return filterExtensions;
+}
/**
* Returns the file names which the dialog will
* use to filter the files it shows.
*
* @return the file name filter
*/
-public String [] getFilterNames () {
- return filterNames;
-}
+public String [] getFilterNames () {
+ return filterNames;
+}
/**
* Returns the path which the dialog will use to filter
* the files it shows.
*
* @return the filter path
*/
-public String getFilterPath () {
- return filterPath;
-}
-
+public String getFilterPath () {
+ return filterPath;
+}
+
/**
* Set the initial filename which the dialog will
* select by default when opened to the argument,
@@ -144,9 +144,9 @@ public String getFilterPath () {
*
* @param string the file name
*/
-public void setFileName (String string) {
- fileName = string;
-}
+public void setFileName (String string) {
+ fileName = string;
+}
/**
* Set the file extensions which the dialog will
* use to filter the files it shows to the argument,
@@ -154,9 +154,9 @@ public void setFileName (String string) {
*
* @param extensions the file extension filter
*/
-public void setFilterExtensions (String [] extensions) {
- filterExtensions = extensions;
-}
+public void setFilterExtensions (String [] extensions) {
+ filterExtensions = extensions;
+}
/**
* Sets the file names which the dialog will
* use to filter the files it shows to the argument,
@@ -164,9 +164,9 @@ public void setFilterExtensions (String [] extensions) {
*
* @param names the file name filter
*/
-public void setFilterNames (String [] names) {
- filterNames = names;
-}
+public void setFilterNames (String [] names) {
+ filterNames = names;
+}
/**
* Sets the path which the dialog will use to filter
* the files it shows to the argument, which may be
@@ -174,17 +174,17 @@ public void setFilterNames (String [] names) {
*
* @param string the filter path
*/
-public void setFilterPath (String string) {
- filterPath = string;
-}
-
-boolean getAnswer() {
- String fileNameFromOS = getFileNameFromOS();
- int separatorIndex = calculateLastSeparatorIndex(fileNameFromOS);
- if (separatorIndex+1 == fileNameFromOS.length()) return false; // the user selected a directory
- fullPath = answer = fileNameFromOS;
- fileName = fullPath.substring (separatorIndex + 1, fullPath.length ());
- filterPath = fullPath.substring (0, separatorIndex);
- return true;
-}
-}
+public void setFilterPath (String string) {
+ filterPath = string;
+}
+
+boolean getAnswer() {
+ String fileNameFromOS = getFileNameFromOS();
+ int separatorIndex = calculateLastSeparatorIndex(fileNameFromOS);
+ if (separatorIndex+1 == fileNameFromOS.length()) return false; // the user selected a directory
+ fullPath = answer = fileNameFromOS;
+ fileName = fullPath.substring (separatorIndex + 1, fullPath.length ());
+ filterPath = fullPath.substring (0, separatorIndex);
+ return true;
+}
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk1x/org/eclipse/swt/widgets/FontDialog.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk1x/org/eclipse/swt/widgets/FontDialog.java
index baf03d3b6e..bbd078290d 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk1x/org/eclipse/swt/widgets/FontDialog.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk1x/org/eclipse/swt/widgets/FontDialog.java
@@ -1,17 +1,17 @@
-package org.eclipse.swt.widgets;
-
-/*
+package org.eclipse.swt.widgets;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-import org.eclipse.swt.*;
-import org.eclipse.swt.internal.*;
-import org.eclipse.swt.internal.gtk.*;
-import org.eclipse.swt.graphics.*;
-
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+import org.eclipse.swt.*;
+import org.eclipse.swt.internal.*;
+import org.eclipse.swt.internal.gtk.*;
+import org.eclipse.swt.graphics.*;
+
/**
* Instances of this class allow the user to select a font
* from all available fonts in the system.
@@ -19,10 +19,10 @@ import org.eclipse.swt.graphics.*;
* IMPORTANT: This class is intended to be subclassed <em>only</em>
* within the SWT implementation.
* </p>
- */
-
-public class FontDialog extends Dialog {
- FontData fontData;
+ */
+
+public class FontDialog extends Dialog {
+ FontData fontData;
/**
* Constructs a new instance of this class given only its
* parent.
@@ -45,9 +45,9 @@ public class FontDialog extends Dialog {
* <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
* </ul>
*/
-public FontDialog (Shell parent) {
- this (parent, SWT.PRIMARY_MODAL);
-}
+public FontDialog (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.
@@ -78,37 +78,37 @@ public FontDialog (Shell parent) {
* <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
* </ul>
*/
-public FontDialog (Shell parent, int style) {
- super (parent, style);
- checkSubclass ();
-}
-int cancelFunc (int widget, int callData) {
- OS.gtk_widget_destroy (callData);
- return 0;
-}
-int destroyFunc (int widget, int colorInfo) {
- OS.gtk_main_quit ();
- return 0;
-}
+public FontDialog (Shell parent, int style) {
+ super (parent, style);
+ checkSubclass ();
+}
+int cancelFunc (int widget, int callData) {
+ OS.gtk_widget_destroy (callData);
+ return 0;
+}
+int destroyFunc (int widget, int colorInfo) {
+ OS.gtk_main_quit ();
+ return 0;
+}
/**
* Returns a FontData object describing the font that was
* selected in the dialog, or null if none is available.
*
* @return the FontData for the selected font, or null
*/
-public FontData getFontData() {
- return fontData;
-}
-int okFunc (int widget, int callData) {
- int hFontName = OS.gtk_font_selection_dialog_get_font_name (callData);
- int fontSize = OS.strlen (hFontName);
- byte [] buffer = new byte [fontSize];
- OS.memmove (buffer, hFontName, fontSize);
- char [] fontName = Converter.mbcsToWcs (null, buffer);
- fontData = FontData.gtk_new(new String (fontName));
- OS.gtk_widget_destroy (callData);
- return 0;
-}
+public FontData getFontData() {
+ return fontData;
+}
+int okFunc (int widget, int callData) {
+ int hFontName = OS.gtk_font_selection_dialog_get_font_name (callData);
+ int fontSize = OS.strlen (hFontName);
+ byte [] buffer = new byte [fontSize];
+ OS.memmove (buffer, hFontName, fontSize);
+ char [] fontName = Converter.mbcsToWcs (null, buffer);
+ fontData = FontData.gtk_new(new String (fontName));
+ OS.gtk_widget_destroy (callData);
+ return 0;
+}
/**
* Makes the dialog visible and brings it to the front
* of the display.
@@ -121,40 +121,40 @@ int okFunc (int widget, int callData) {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the dialog</li>
* </ul>
*/
-public FontData open () {
- int handle;
- byte [] titleBytes;
- titleBytes = Converter.wcsToMbcs (null, title, true);
- handle = OS.gtk_font_selection_dialog_new (titleBytes);
- GtkFontSelectionDialog dialog = new GtkFontSelectionDialog ();
- OS.memmove (dialog, handle, GtkFontSelectionDialog.sizeof);
- if (parent!=null) {
- OS.gtk_window_set_modal(handle, true);
- OS.gtk_window_set_transient_for(handle, parent.topHandle);
- }
- if (fontData != null) {
- byte[] buffer = Converter.wcsToMbcs(null, fontData.gtk_getXlfd(), true);
- OS.gtk_font_selection_set_font_name(dialog.fontsel, buffer);
- }
- Callback destroyCallback = new Callback (this, "destroyFunc", 2);
- int destroyFunc = destroyCallback.getAddress ();
- byte [] destroy = Converter.wcsToMbcs (null, "destroy", true);
- OS.gtk_signal_connect (handle, destroy, destroyFunc, handle);
- byte [] clicked = Converter.wcsToMbcs (null, "clicked", true);
- Callback okCallback = new Callback (this, "okFunc", 2);
- int okFunc = okCallback.getAddress ();
- Callback cancelCallback = new Callback (this, "cancelFunc", 2);
- int cancelFunc = cancelCallback.getAddress ();
- OS.gtk_signal_connect (dialog.ok_button, clicked, okFunc, handle);
- OS.gtk_signal_connect (dialog.cancel_button, clicked, cancelFunc, handle);
- fontData = null;
- OS.gtk_widget_show_now (handle);
- OS.gtk_main ();
- destroyCallback.dispose ();
- okCallback.dispose ();
- cancelCallback.dispose ();
- return fontData;
-}
+public FontData open () {
+ int handle;
+ byte [] titleBytes;
+ titleBytes = Converter.wcsToMbcs (null, title, true);
+ handle = OS.gtk_font_selection_dialog_new (titleBytes);
+ GtkFontSelectionDialog dialog = new GtkFontSelectionDialog ();
+ OS.memmove (dialog, handle, GtkFontSelectionDialog.sizeof);
+ if (parent!=null) {
+ OS.gtk_window_set_modal(handle, true);
+ OS.gtk_window_set_transient_for(handle, parent.topHandle);
+ }
+ if (fontData != null) {
+ byte[] buffer = Converter.wcsToMbcs(null, fontData.gtk_getXlfd(), true);
+ OS.gtk_font_selection_set_font_name(dialog.fontsel, buffer);
+ }
+ Callback destroyCallback = new Callback (this, "destroyFunc", 2);
+ int destroyFunc = destroyCallback.getAddress ();
+ byte [] destroy = Converter.wcsToMbcs (null, "destroy", true);
+ OS.gtk_signal_connect (handle, destroy, destroyFunc, handle);
+ byte [] clicked = Converter.wcsToMbcs (null, "clicked", true);
+ Callback okCallback = new Callback (this, "okFunc", 2);
+ int okFunc = okCallback.getAddress ();
+ Callback cancelCallback = new Callback (this, "cancelFunc", 2);
+ int cancelFunc = cancelCallback.getAddress ();
+ OS.gtk_signal_connect (dialog.ok_button, clicked, okFunc, handle);
+ OS.gtk_signal_connect (dialog.cancel_button, clicked, cancelFunc, handle);
+ fontData = null;
+ OS.gtk_widget_show_now (handle);
+ OS.gtk_main ();
+ destroyCallback.dispose ();
+ okCallback.dispose ();
+ cancelCallback.dispose ();
+ return fontData;
+}
/**
* Sets a FontData object describing the font to be
* selected by default in the dialog, or null to let
@@ -162,7 +162,7 @@ public FontData open () {
*
* @param fontData the FontData to use initially, or null
*/
-public void setFontData (FontData fontData) {
- this.fontData = fontData;
-}
-}
+public void setFontData (FontData fontData) {
+ this.fontData = fontData;
+}
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk1x/org/eclipse/swt/widgets/Menu.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk1x/org/eclipse/swt/widgets/Menu.java
index a0bfbd3eb2..441561ed44 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk1x/org/eclipse/swt/widgets/Menu.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk1x/org/eclipse/swt/widgets/Menu.java
@@ -1,18 +1,18 @@
-package org.eclipse.swt.widgets;
-
-/*
+package org.eclipse.swt.widgets;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-import org.eclipse.swt.*;
-import org.eclipse.swt.internal.*;
-import org.eclipse.swt.internal.gtk.*;
-import org.eclipse.swt.graphics.*;
-import org.eclipse.swt.events.*;
-
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+import org.eclipse.swt.*;
+import org.eclipse.swt.internal.*;
+import org.eclipse.swt.internal.gtk.*;
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.events.*;
+
/**
* Instances of this class are user interface objects that contain
* menu items.
@@ -22,42 +22,42 @@ import org.eclipse.swt.events.*;
* <dt><b>Events:</b></dt>
* <dd>Help, Hide, Show </dd>
* </dl>
- * <p>
- * Note: Only one of BAR, DROP_DOWN and POP_UP may be specified.
- * </p><p>
+ * <p>
+ * Note: Only one of BAR, DROP_DOWN and POP_UP may be specified.
+ * </p><p>
* IMPORTANT: This class is <em>not</em> intended to be subclassed.
* </p>
- */
-
-public class Menu extends Widget {
- MenuItem cascade;
- Decorations parent;
-/**
-* Creates a new instance of the widget.
-*/
-public Menu (Control parent) {
- this (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 (parentMenu.parent, SWT.DROP_DOWN);
-}
-/**
-* Creates a new instance of the widget.
-*/
-public Menu (MenuItem parentItem) {
- this (parentItem.parent);
-}
+ */
+
+public class Menu extends Widget {
+ MenuItem cascade;
+ Decorations parent;
+/**
+* Creates a new instance of the widget.
+*/
+public Menu (Control parent) {
+ this (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 (parentMenu.parent, SWT.DROP_DOWN);
+}
+/**
+* Creates a new instance of the widget.
+*/
+public Menu (MenuItem parentItem) {
+ this (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
@@ -76,16 +76,16 @@ public Menu (MenuItem parentItem) {
*
* @see MenuListener
* @see #removeMenuListener
- */
-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);
-}
-
+ */
+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);
+}
+
/**
* Adds the listener to the collection of listeners who will
* be notified when the help events are generated for the control, by sending
@@ -105,33 +105,33 @@ public void addMenuListener (MenuListener listener) {
* @see HelpListener
* @see #removeHelpListener
*/
-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);
-}
-
-static int checkStyle (int style) {
- return checkBits (style, SWT.POP_UP, SWT.BAR, SWT.DROP_DOWN, 0, 0, 0);
-}
-void createHandle (int index) {
- state |= HANDLE;
- if ((style & SWT.BAR) != 0) {
- handle = OS.gtk_menu_bar_new ();
- OS.gtk_widget_show (handle);
- } else {
- handle = OS.gtk_menu_new ();
- }
- if (handle == 0) error (SWT.ERROR_NO_HANDLES);
-}
-
-void createWidget (int index) {
- super.createWidget (index);
- parent.add (this);
-}
-
+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);
+}
+
+static int checkStyle (int style) {
+ return checkBits (style, SWT.POP_UP, SWT.BAR, SWT.DROP_DOWN, 0, 0, 0);
+}
+void createHandle (int index) {
+ state |= HANDLE;
+ if ((style & SWT.BAR) != 0) {
+ handle = OS.gtk_menu_bar_new ();
+ OS.gtk_widget_show (handle);
+ } else {
+ handle = OS.gtk_menu_new ();
+ }
+ if (handle == 0) error (SWT.ERROR_NO_HANDLES);
+}
+
+void createWidget (int index) {
+ super.createWidget (index);
+ parent.add (this);
+}
+
/**
* Returns the default menu item or null if none has
* been previously set.
@@ -143,17 +143,17 @@ void createWidget (int index) {
* <li>ERROR_WIDGET_DISPOSED - if 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 () {
- if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
- if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
- return null;
-}
-public Display getDisplay () {
- Decorations parent = this.parent;
- if (parent == null) error (SWT.ERROR_WIDGET_DISPOSED);
- return parent.getDisplay ();
-}
+ */
+public MenuItem getDefaultItem () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ 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
@@ -166,14 +166,14 @@ public Display getDisplay () {
* <li>ERROR_WIDGET_DISPOSED - if 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);
- GtkWidget widget = new GtkWidget ();
- OS.memmove (widget, handle, GtkWidget.sizeof);
- return (widget.flags & OS.GTK_SENSITIVE) != 0;
-}
+ */
+public boolean getEnabled () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ GtkWidget widget = new GtkWidget ();
+ OS.memmove (widget, handle, GtkWidget.sizeof);
+ return (widget.flags & OS.GTK_SENSITIVE) != 0;
+}
/**
* Returns the item at the given, zero-relative index in the
* receiver. Throws an exception if the index is out of range.
@@ -188,15 +188,15 @@ public boolean getEnabled () {
* <li>ERROR_WIDGET_DISPOSED - if 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) {
- if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
- if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
- int list = OS.gtk_container_children (handle);
- int data = OS.g_list_nth_data (list, index);
- if (data == 0) error (SWT.ERROR_CANNOT_GET_ITEM);
- return (MenuItem) WidgetTable.get (data);
-}
+ */
+public MenuItem getItem (int index) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int list = OS.gtk_container_children (handle);
+ int data = OS.g_list_nth_data (list, index);
+ if (data == 0) error (SWT.ERROR_CANNOT_GET_ITEM);
+ return (MenuItem) WidgetTable.get (data);
+}
/**
* Returns the number of items contained in the receiver.
*
@@ -206,13 +206,13 @@ public MenuItem getItem (int index) {
* <li>ERROR_WIDGET_DISPOSED - if 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 () {
- if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
- if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
- int list = OS.gtk_container_children (handle);
- return OS.g_list_length (list);
-}
+ */
+public int getItemCount () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int list = OS.gtk_container_children (handle);
+ return OS.g_list_length (list);
+}
/**
* Returns an array of <code>MenuItem</code>s which are the items
* in the receiver.
@@ -228,19 +228,19 @@ public int getItemCount () {
* <li>ERROR_WIDGET_DISPOSED - if 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 () {
- if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
- if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
- int list = OS.gtk_container_children (handle);
- int count = OS.g_list_length (list);
- MenuItem [] items = new MenuItem [count];
- for (int i=0; i<count; i++) {
- int data = OS.g_list_nth_data (list, i);
- items [i] = (MenuItem) WidgetTable.get (data);
- }
- return items;
-}
+ */
+public MenuItem [] getItems () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int list = OS.gtk_container_children (handle);
+ int count = OS.g_list_length (list);
+ MenuItem [] items = new MenuItem [count];
+ for (int i=0; i<count; i++) {
+ int data = OS.g_list_nth_data (list, i);
+ items [i] = (MenuItem) WidgetTable.get (data);
+ }
+ return items;
+}
/**
* Returns the receiver's parent, which must be a <code>Decorations</code>.
*
@@ -250,12 +250,12 @@ public MenuItem [] getItems () {
* <li>ERROR_WIDGET_DISPOSED - if 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 () {
- if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
- if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
- return parent;
-}
+ */
+public Decorations getParent () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ return parent;
+}
/**
* Returns the receiver's parent item, which must be a
* <code>MenuItem</code> or null when the receiver is a
@@ -267,12 +267,12 @@ public Decorations getParent () {
* <li>ERROR_WIDGET_DISPOSED - if 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 () {
- if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
- if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
- return cascade;
-}
+ */
+public MenuItem getParentItem () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ return cascade;
+}
/**
* Returns the receiver's parent item, which must be a
* <code>Menu</code> or null when the receiver is a
@@ -284,13 +284,13 @@ public MenuItem getParentItem () {
* <li>ERROR_WIDGET_DISPOSED - if 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 () {
- if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
- if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
- if (cascade == null) return null;
- return cascade.getParent ();
-}
+ */
+public Menu getParentMenu () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (cascade == null) return null;
+ return cascade.getParent ();
+}
/**
* Returns the receiver's shell. For all controls other than
* shells, this simply returns the control's nearest ancestor
@@ -305,12 +305,12 @@ public Menu getParentMenu () {
* </ul>
*
* @see #getParent
- */
-public Shell getShell () {
- if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
- if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
- return parent.getShell ();
-}
+ */
+public Shell getShell () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ return parent.getShell ();
+}
/**
* Returns <code>true</code> if the receiver is visible, and
* <code>false</code> otherwise.
@@ -327,14 +327,14 @@ public Shell getShell () {
* <li>ERROR_WIDGET_DISPOSED - if 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);
- GtkWidget widget = new GtkWidget ();
- OS.memmove (widget, handle, GtkWidget.sizeof);
- return (widget.flags & OS.GTK_MAPPED) != 0;
-}
+ */
+public boolean getVisible () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ GtkWidget widget = new GtkWidget ();
+ OS.memmove (widget, handle, GtkWidget.sizeof);
+ return (widget.flags & OS.GTK_MAPPED) != 0;
+}
/**
* Searches the receiver's list starting at the first item
* (index 0) until an item is found that is equal to the
@@ -351,17 +351,17 @@ public boolean getVisible () {
* <li>ERROR_WIDGET_DISPOSED - if 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) {
- if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
- if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
- if (item == null) error (SWT.ERROR_NULL_ARGUMENT);
- MenuItem [] items = getItems ();
- for (int i=0; i<items.length; i++) {
- if (items [i] == item) return i;
- }
- return -1;
-}
+ */
+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);
+ MenuItem [] items = getItems ();
+ for (int i=0; i<items.length; i++) {
+ if (items [i] == item) return i;
+ }
+ return -1;
+}
/**
* Returns <code>true</code> if the receiver is enabled, and
* <code>false</code> otherwise. A disabled control is typically
@@ -374,12 +374,12 @@ public int indexOf (MenuItem item) {
* <li>ERROR_WIDGET_DISPOSED - if 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 () && getParent ().getEnabled ();
-}
+ */
+public boolean isEnabled () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ return getEnabled () && getParent ().getEnabled ();
+}
/**
* Returns <code>true</code> if the receiver is visible, and
* <code>false</code> otherwise.
@@ -396,33 +396,33 @@ public boolean isEnabled () {
* <li>ERROR_WIDGET_DISPOSED - if 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 ();
-}
-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 ();
- }
- }
- if (parent != null) parent.remove (this);
- super.releaseWidget ();
- parent = null;
- cascade = null;
-}
+ */
+public boolean isVisible () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ return getVisible ();
+}
+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 ();
+ }
+ }
+ if (parent != null) parent.remove (this);
+ super.releaseWidget ();
+ parent = null;
+ cascade = null;
+}
/**
* Removes the listener from the collection of listeners who will
* be notified when the menu events are generated for the control.
@@ -439,16 +439,16 @@ void releaseWidget () {
*
* @see MenuListener
* @see #addMenuListener
- */
-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 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);
+}
+
/**
* Removes the listener from the collection of listeners who will
* be notified when the help events are generated for the control.
@@ -466,14 +466,14 @@ public void removeMenuListener (MenuListener listener) {
* @see HelpListener
* @see #addHelpListener
*/
-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 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);
+}
+
/**
* Sets the default menu item to the argument or removes
* the default emphasis when the argument is <code>null</code>.
@@ -487,11 +487,11 @@ public void removeHelpListener (HelpListener listener) {
* <li>ERROR_WIDGET_DISPOSED - if the 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) {
- if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
- if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
-}
+ */
+public void setDefaultItem (MenuItem item) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+}
/**
* Enables the receiver if the argument is <code>true</code>,
* and disables it otherwise. A disabled control is typically
@@ -504,13 +504,13 @@ public void setDefaultItem (MenuItem item) {
* <li>ERROR_WIDGET_DISPOSED - if the 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);
- OS.gtk_widget_set_sensitive (handle, enabled);
-}
-
+ */
+public void setEnabled (boolean enabled) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ OS.gtk_widget_set_sensitive (handle, enabled);
+}
+
/**
* Sets the receiver's location to the point specified by
* the arguments which are relative to the display.
@@ -527,15 +527,15 @@ public void setEnabled (boolean enabled) {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-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;
-// OS.gtk_widget_set_uposition(handle, x, y);
-// OS.gtk_widget_set_uposition(handle, 0, 0);
- sendEvent(SWT.Move);
-}
-
+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;
+// OS.gtk_widget_set_uposition(handle, x, y);
+// OS.gtk_widget_set_uposition(handle, 0, 0);
+ sendEvent(SWT.Move);
+}
+
/**
* Marks the receiver as visible if the argument is <code>true</code>,
* and marks it invisible otherwise.
@@ -551,17 +551,17 @@ public void setLocation (int x, int y) {
* <li>ERROR_WIDGET_DISPOSED - if the 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);
- if ((style & SWT.BAR) != 0) return;
- if (visible) {
- sendEvent(SWT.Show);
- OS.gtk_menu_popup (handle, 0, 0, 0, 0, 3, 0);
- } else {
- OS.gtk_menu_popdown (handle);
- sendEvent(SWT.Hide);
- }
-}
-}
+ */
+public void setVisible (boolean visible) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if ((style & SWT.BAR) != 0) return;
+ if (visible) {
+ sendEvent(SWT.Show);
+ OS.gtk_menu_popup (handle, 0, 0, 0, 0, 3, 0);
+ } else {
+ OS.gtk_menu_popdown (handle);
+ sendEvent(SWT.Hide);
+ }
+}
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk1x/org/eclipse/swt/widgets/MenuItem.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk1x/org/eclipse/swt/widgets/MenuItem.java
index ce8f52cd1d..6a898c9365 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk1x/org/eclipse/swt/widgets/MenuItem.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk1x/org/eclipse/swt/widgets/MenuItem.java
@@ -1,18 +1,18 @@
-package org.eclipse.swt.widgets;
-
-/*
+package org.eclipse.swt.widgets;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-import org.eclipse.swt.*;
-import org.eclipse.swt.internal.*;
-import org.eclipse.swt.internal.gtk.*;
-import org.eclipse.swt.graphics.*;
-import org.eclipse.swt.events.*;
-
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+import org.eclipse.swt.*;
+import org.eclipse.swt.internal.*;
+import org.eclipse.swt.internal.gtk.*;
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.events.*;
+
/**
* Instances of this class represent a selectable user interface object
* that issues notification when pressed and released.
@@ -22,18 +22,18 @@ import org.eclipse.swt.events.*;
* <dt><b>Events:</b></dt>
* <dd>Arm, Help, Selection</dd>
* </dl>
- * <p>
- * Note: Only one of the styles CHECK, CASCADE, PUSH, RADIO, and SEPARATOR
- * may be specified.
- * </p><p>
+ * <p>
+ * Note: Only one of the styles CHECK, CASCADE, PUSH, RADIO, and SEPARATOR
+ * may be specified.
+ * </p><p>
* IMPORTANT: This class is <em>not</em> intended to be subclassed.
* </p>
- */
-
-public class MenuItem extends Item {
- Menu parent, menu;
- int accelerator;
-
+ */
+
+public class MenuItem extends Item {
+ Menu parent, menu;
+ int accelerator;
+
/**
* Constructs a new instance of this class given its parent
* (which must be a <code>Menu</code>) and a style value
@@ -63,12 +63,12 @@ public class MenuItem extends Item {
* @see SWT
* @see Widget#checkSubclass
* @see Widget#getStyle
- */
-public MenuItem (Menu parent, int style) {
- super (parent, checkStyle (style));
- this.parent = parent;
- createWidget (parent.getItemCount ());
-}
+ */
+public MenuItem (Menu parent, int style) {
+ super (parent, checkStyle (style));
+ this.parent = parent;
+ createWidget (parent.getItemCount ());
+}
/**
* Constructs a new instance of this class given its parent
* (which must be a <code>Menu</code>), a style value
@@ -99,33 +99,33 @@ public MenuItem (Menu parent, int style) {
* @see SWT
* @see Widget#checkSubclass
* @see Widget#getStyle
- */
-public MenuItem (Menu parent, int style, int index) {
- super (parent, checkStyle (style));
- this.parent = parent;
- int count = parent.getItemCount ();
- if (!(0 <= index && index <= count)) {
- error (SWT.ERROR_ITEM_NOT_ADDED);
- }
- createWidget (index);
-}
-void addAccelerator (int accel_group) {
- if (accel_group == 0) return;
- if (accelerator == 0) return;
- byte [] activate = Converter.wcsToMbcs (null, "activate", true);
- int mask = 0;
- if ((accelerator & SWT.CONTROL) != 0) mask |= OS.GDK_CONTROL_MASK;
- if ((accelerator & SWT.ALT) != 0) mask |= OS.GDK_MOD1_MASK;
- if ((accelerator & SWT.SHIFT) != 0) mask |= OS.GDK_SHIFT_MASK;
- int keysym = accelerator & ~(SWT.ALT | SWT.SHIFT | SWT.CTRL);
- int newKey = Display.untranslateKey (keysym);
- if (newKey != 0) {
- keysym = newKey;
- } else {
- keysym = wcsToMbcs ((char) keysym);
- }
- OS.gtk_widget_add_accelerator (handle, activate, accel_group, keysym, mask, OS.GTK_ACCEL_VISIBLE);
-}
+ */
+public MenuItem (Menu parent, int style, int index) {
+ super (parent, checkStyle (style));
+ this.parent = parent;
+ int count = parent.getItemCount ();
+ if (!(0 <= index && index <= count)) {
+ error (SWT.ERROR_ITEM_NOT_ADDED);
+ }
+ createWidget (index);
+}
+void addAccelerator (int accel_group) {
+ if (accel_group == 0) return;
+ if (accelerator == 0) return;
+ byte [] activate = Converter.wcsToMbcs (null, "activate", true);
+ int mask = 0;
+ if ((accelerator & SWT.CONTROL) != 0) mask |= OS.GDK_CONTROL_MASK;
+ if ((accelerator & SWT.ALT) != 0) mask |= OS.GDK_MOD1_MASK;
+ if ((accelerator & SWT.SHIFT) != 0) mask |= OS.GDK_SHIFT_MASK;
+ int keysym = accelerator & ~(SWT.ALT | SWT.SHIFT | SWT.CTRL);
+ int newKey = Display.untranslateKey (keysym);
+ if (newKey != 0) {
+ keysym = newKey;
+ } else {
+ keysym = wcsToMbcs ((char) keysym);
+ }
+ OS.gtk_widget_add_accelerator (handle, activate, accel_group, keysym, mask, OS.GTK_ACCEL_VISIBLE);
+}
/**
* Adds the listener to the collection of listeners who will
* be notified when the arm events are generated for the control, by sending
@@ -144,15 +144,15 @@ void addAccelerator (int accel_group) {
*
* @see ArmListener
* @see #removeArmListener
- */
-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 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 the collection of listeners who will
* be notified when the help events are generated for the control, by sending
@@ -172,79 +172,79 @@ public void addArmListener (ArmListener listener) {
* @see HelpListener
* @see #removeHelpListener
*/
-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 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.
- * <p>
- * When <code>widgetSelected</code> is called, the stateMask field of the event object is valid.
- * <code>widgetDefaultSelected</code> is not called.
- * </p>
- *
- * @param listener the listener which should be notified
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see SelectionListener
- * @see #removeSelectionListener
- * @see SelectionEvent
- */
-public void addSelectionListener (SelectionListener listener) {
- 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);
-}
-void createHandle (int index) {
- state |= HANDLE;
- byte [] buffer = new byte [1];
- int bits = SWT.CHECK | SWT.RADIO | SWT.PUSH | SWT.SEPARATOR;
- switch (style & bits) {
- case SWT.SEPARATOR:
- handle = OS.gtk_menu_item_new ();
- break;
- case SWT.RADIO:
-// handle = OS.gtk_radio_menu_item_new_with_label (0, buffer);
-// break;
- case SWT.CHECK:
- handle = OS.gtk_check_menu_item_new_with_label (buffer);
- break;
- case SWT.PUSH:
- default:
- handle = OS.gtk_menu_item_new_with_label (buffer);
- break;
- }
- if (handle == 0) error (SWT.ERROR_NO_HANDLES);
- if ((style & (SWT.CHECK | SWT.RADIO)) != 0) {
- OS.gtk_check_menu_item_set_show_toggle (handle, true);
- }
- if ((parent.style & SWT.BAR) != 0) {
- OS.gtk_menu_bar_insert (parent.handle, handle, index);
- } else {
- OS.gtk_menu_insert (parent.handle, handle, index);
- }
- OS.gtk_widget_show (handle);
-}
+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 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.
+ * <p>
+ * When <code>widgetSelected</code> is called, the stateMask field of the event object is valid.
+ * <code>widgetDefaultSelected</code> is not called.
+ * </p>
+ *
+ * @param listener the listener which should be notified
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see SelectionListener
+ * @see #removeSelectionListener
+ * @see SelectionEvent
+ */
+public void addSelectionListener (SelectionListener listener) {
+ 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);
+}
+void createHandle (int index) {
+ state |= HANDLE;
+ byte [] buffer = new byte [1];
+ int bits = SWT.CHECK | SWT.RADIO | SWT.PUSH | SWT.SEPARATOR;
+ switch (style & bits) {
+ case SWT.SEPARATOR:
+ handle = OS.gtk_menu_item_new ();
+ break;
+ case SWT.RADIO:
+// handle = OS.gtk_radio_menu_item_new_with_label (0, buffer);
+// break;
+ case SWT.CHECK:
+ handle = OS.gtk_check_menu_item_new_with_label (buffer);
+ break;
+ case SWT.PUSH:
+ default:
+ handle = OS.gtk_menu_item_new_with_label (buffer);
+ break;
+ }
+ if (handle == 0) error (SWT.ERROR_NO_HANDLES);
+ if ((style & (SWT.CHECK | SWT.RADIO)) != 0) {
+ OS.gtk_check_menu_item_set_show_toggle (handle, true);
+ }
+ if ((parent.style & SWT.BAR) != 0) {
+ OS.gtk_menu_bar_insert (parent.handle, handle, index);
+ } else {
+ OS.gtk_menu_insert (parent.handle, handle, index);
+ }
+ OS.gtk_widget_show (handle);
+}
/**
* Return the widget accelerator. An accelerator is the bit-wise
* OR of zero or more modifier masks and a key. Examples:
@@ -257,17 +257,17 @@ void createHandle (int index) {
* <li>ERROR_WIDGET_DISPOSED - if 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 () {
- if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
- if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
- return accelerator;
-}
-public Display getDisplay () {
- Menu parent = this.parent;
- if (parent == null) error (SWT.ERROR_WIDGET_DISPOSED);
- return parent.getDisplay ();
-}
+ */
+public int getAccelerator () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ 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
@@ -280,14 +280,14 @@ public Display getDisplay () {
* <li>ERROR_WIDGET_DISPOSED - if 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);
- GtkWidget widget = new GtkWidget ();
- OS.memmove (widget, handle, GtkWidget.sizeof);
- return (widget.flags & OS.GTK_SENSITIVE) != 0;
-}
+ */
+public boolean getEnabled () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ GtkWidget widget = new GtkWidget ();
+ OS.memmove (widget, handle, GtkWidget.sizeof);
+ return (widget.flags & OS.GTK_SENSITIVE) != 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
@@ -301,12 +301,12 @@ public boolean getEnabled () {
* <li>ERROR_WIDGET_DISPOSED - if 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 () {
- if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
- if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
- return menu;
-}
+ */
+public Menu getMenu () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ return menu;
+}
/**
* Returns the receiver's parent, which must be a <code>Menu</code>.
*
@@ -316,12 +316,12 @@ public Menu getMenu () {
* <li>ERROR_WIDGET_DISPOSED - if 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 () {
- if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
- if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
- return parent;
-}
+ */
+public Menu getParent () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ return parent;
+}
/**
* Returns <code>true</code> if the receiver is selected,
* and false otherwise.
@@ -335,22 +335,22 @@ public Menu getParent () {
* <li>ERROR_WIDGET_DISPOSED - if 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 () {
- if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
- if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
- if ((style & (SWT.CHECK | SWT.RADIO)) == 0) return false;
- GtkCheckMenuItem menuItem = new GtkCheckMenuItem ();
- OS.memmove (menuItem, handle, GtkCheckMenuItem.sizeof);
- return menuItem.active != 0;
-}
-void hookEvents () {
- super.hookEvents ();
- Display display = getDisplay ();
- int windowProc2 = display.windowProc2;
- byte [] activate_event = Converter.wcsToMbcs (null, "activate", true);
- OS.gtk_signal_connect (handle, activate_event, windowProc2, SWT.Selection);
-}
+ */
+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;
+ GtkCheckMenuItem menuItem = new GtkCheckMenuItem ();
+ OS.memmove (menuItem, handle, GtkCheckMenuItem.sizeof);
+ return menuItem.active != 0;
+}
+void hookEvents () {
+ super.hookEvents ();
+ Display display = getDisplay ();
+ int windowProc2 = display.windowProc2;
+ byte [] activate_event = Converter.wcsToMbcs (null, "activate", true);
+ OS.gtk_signal_connect (handle, activate_event, windowProc2, SWT.Selection);
+}
/**
* Returns <code>true</code> if the receiver is enabled, and
* <code>false</code> otherwise. A disabled control is typically
@@ -363,48 +363,48 @@ void hookEvents () {
* <li>ERROR_WIDGET_DISPOSED - if 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 ();
-}
-int processSelection (int int0, int int1, int int2) {
- postEvent (SWT.Selection);
- return 0;
-}
-void releaseChild () {
- super.releaseChild ();
- if (menu != null) menu.dispose ();
- menu = null;
-}
-void releaseWidget () {
- if (menu != null) {
- menu.releaseWidget ();
- menu.releaseHandle ();
- }
- menu = null;
- super.releaseWidget ();
- int accel_group = parent.getShell ().accelGroup;
- removeAccelerator (accel_group);
- accelerator = 0;
- parent = null;
-}
-void removeAccelerator (int accel_group) {
- if (accel_group == 0) return;
- if (accelerator == 0) return;
- int mask = 0;
- if ((accelerator & SWT.CONTROL) != 0) mask |= OS.GDK_CONTROL_MASK;
- if ((accelerator & SWT.ALT) != 0) mask |= OS.GDK_MOD1_MASK;
- if ((accelerator & SWT.SHIFT) != 0) mask |= OS.GDK_SHIFT_MASK;
- int keysym = accelerator & ~(SWT.ALT | SWT.SHIFT | SWT.CTRL);
- int newKey = Display.untranslateKey (keysym);
- if (newKey != 0) {
- keysym = newKey;
- } else {
- keysym = wcsToMbcs ((char) keysym);
- }
- OS.gtk_widget_remove_accelerator (handle, accel_group, keysym, mask);
- accelerator = 0;
-}
+ */
+public boolean isEnabled () {
+ return getEnabled ();
+}
+int processSelection (int int0, int int1, int int2) {
+ postEvent (SWT.Selection);
+ return 0;
+}
+void releaseChild () {
+ super.releaseChild ();
+ if (menu != null) menu.dispose ();
+ menu = null;
+}
+void releaseWidget () {
+ if (menu != null) {
+ menu.releaseWidget ();
+ menu.releaseHandle ();
+ }
+ menu = null;
+ super.releaseWidget ();
+ int accel_group = parent.getShell ().accelGroup;
+ removeAccelerator (accel_group);
+ accelerator = 0;
+ parent = null;
+}
+void removeAccelerator (int accel_group) {
+ if (accel_group == 0) return;
+ if (accelerator == 0) return;
+ int mask = 0;
+ if ((accelerator & SWT.CONTROL) != 0) mask |= OS.GDK_CONTROL_MASK;
+ if ((accelerator & SWT.ALT) != 0) mask |= OS.GDK_MOD1_MASK;
+ if ((accelerator & SWT.SHIFT) != 0) mask |= OS.GDK_SHIFT_MASK;
+ int keysym = accelerator & ~(SWT.ALT | SWT.SHIFT | SWT.CTRL);
+ int newKey = Display.untranslateKey (keysym);
+ if (newKey != 0) {
+ keysym = newKey;
+ } else {
+ keysym = wcsToMbcs ((char) keysym);
+ }
+ OS.gtk_widget_remove_accelerator (handle, accel_group, keysym, mask);
+ accelerator = 0;
+}
/**
* Removes the listener from the collection of listeners who will
* be notified when the arm events are generated for the control.
@@ -421,15 +421,15 @@ void removeAccelerator (int accel_group) {
*
* @see ArmListener
* @see #addArmListener
- */
-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 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 from the collection of listeners who will
* be notified when the help events are generated for the control.
@@ -447,14 +447,14 @@ public void removeArmListener (ArmListener listener) {
* @see HelpListener
* @see #addHelpListener
*/
-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 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 from the collection of listeners who will
* be notified when the control is selected.
@@ -471,15 +471,15 @@ public void removeHelpListener (HelpListener listener) {
*
* @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);
-}
+ */
+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 widget accelerator. An accelerator is the bit-wise
* OR of zero or more modifier masks and a key. Examples:
@@ -492,15 +492,15 @@ public void removeSelectionListener (SelectionListener listener) {
* <li>ERROR_WIDGET_DISPOSED - if the 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) {
- if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
- if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
- int accel_group = parent.getShell ().accelGroup;
- if (accelerator != 0) removeAccelerator (accel_group);
- this.accelerator = accelerator;
- if (accelerator != 0) addAccelerator (accel_group);
-}
+ */
+public void setAccelerator (int accelerator) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int accel_group = parent.getShell ().accelGroup;
+ if (accelerator != 0) removeAccelerator (accel_group);
+ this.accelerator = accelerator;
+ if (accelerator != 0) addAccelerator (accel_group);
+}
/**
* Enables the receiver if the argument is <code>true</code>,
* and disables it otherwise. A disabled control is typically
@@ -513,15 +513,15 @@ public void setAccelerator (int accelerator) {
* <li>ERROR_WIDGET_DISPOSED - if the 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);
- OS.gtk_widget_set_sensitive (handle, enabled);
-}
-
-
-
+ */
+public void setEnabled (boolean enabled) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ OS.gtk_widget_set_sensitive (handle, enabled);
+}
+
+
+
/**
* Sets the receiver's pull down menu to the argument.
* Only <code>CASCADE</code> menu items can have a
@@ -541,42 +541,42 @@ public void setEnabled (boolean enabled) {
* <li>ERROR_WIDGET_DISPOSED - if the 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;
- /*
- * Add a reference to the menu we are about
- * to replace or GTK will destroy it.
- */
- OS.gtk_object_ref (oldMenu.handle);
- OS.gtk_menu_item_remove_submenu (handle);
- }
- if ((this.menu = menu) != null) {
- menu.cascade = this;
- OS.gtk_menu_item_set_submenu (handle, menu.handle);
- }
-
-
-}
+ */
+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;
+ /*
+ * Add a reference to the menu we are about
+ * to replace or GTK will destroy it.
+ */
+ OS.gtk_object_ref (oldMenu.handle);
+ OS.gtk_menu_item_remove_submenu (handle);
+ }
+ if ((this.menu = menu) != null) {
+ menu.cascade = this;
+ OS.gtk_menu_item_set_submenu (handle, menu.handle);
+ }
+
+
+}
/**
* Sets the selection state of the receiver.
* <p>
@@ -589,48 +589,48 @@ public void setMenu (Menu menu) {
* <li>ERROR_WIDGET_DISPOSED - if the 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) {
- if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
- if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
- if ((style & (SWT.CHECK | SWT.RADIO)) == 0) return;
- OS.gtk_signal_handler_block_by_data (handle, SWT.Selection);
- OS.gtk_check_menu_item_set_active (handle, selected);
- OS.gtk_signal_handler_unblock_by_data (handle, SWT.Selection);
-}
-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;
- text = string;
- if ((style & SWT.ARROW) != 0) return;
- int length = string.length ();
- int index = string.indexOf('\t');
- if (index != -1) length = index;
- char [] text = new char [length + 1];
- char [] pattern = new char [length + 1];
- string.getChars (0, length, text, 0);
- int i = 0, j = 0;
- while (i < length) {
- pattern [j] = ' ';
- if (text [i] == '&') {
- i++;
- if (i < length && text [i] != '&') {
- pattern [j] = '_';
- }
- }
- text [j++] = text [i++];
- }
- while (j < i) {
- text [j] = pattern [j] = '\0';
- j++;
- }
- int list = OS.gtk_container_children (handle);
- int label = OS.g_list_nth_data (list, 0);
- byte [] buffer1 = Converter.wcsToMbcs (null, text);
- OS.gtk_label_set_text (label, buffer1);
- byte [] buffer2 = Converter.wcsToMbcs (null, pattern);
- OS.gtk_label_set_pattern (label, buffer2);
-}
-}
+ */
+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;
+ OS.gtk_signal_handler_block_by_data (handle, SWT.Selection);
+ OS.gtk_check_menu_item_set_active (handle, selected);
+ OS.gtk_signal_handler_unblock_by_data (handle, SWT.Selection);
+}
+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;
+ text = string;
+ if ((style & SWT.ARROW) != 0) return;
+ int length = string.length ();
+ int index = string.indexOf('\t');
+ if (index != -1) length = index;
+ char [] text = new char [length + 1];
+ char [] pattern = new char [length + 1];
+ string.getChars (0, length, text, 0);
+ int i = 0, j = 0;
+ while (i < length) {
+ pattern [j] = ' ';
+ if (text [i] == '&') {
+ i++;
+ if (i < length && text [i] != '&') {
+ pattern [j] = '_';
+ }
+ }
+ text [j++] = text [i++];
+ }
+ while (j < i) {
+ text [j] = pattern [j] = '\0';
+ j++;
+ }
+ int list = OS.gtk_container_children (handle);
+ int label = OS.g_list_nth_data (list, 0);
+ byte [] buffer1 = Converter.wcsToMbcs (null, text);
+ OS.gtk_label_set_text (label, buffer1);
+ byte [] buffer2 = Converter.wcsToMbcs (null, pattern);
+ OS.gtk_label_set_pattern (label, buffer2);
+}
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk1x/org/eclipse/swt/widgets/TabFolder.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk1x/org/eclipse/swt/widgets/TabFolder.java
index 7334f0b75b..cd946c1657 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk1x/org/eclipse/swt/widgets/TabFolder.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk1x/org/eclipse/swt/widgets/TabFolder.java
@@ -1,273 +1,273 @@
-package org.eclipse.swt.widgets;
-
-/*
+package org.eclipse.swt.widgets;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-import org.eclipse.swt.*;
-import org.eclipse.swt.internal.gtk.*;
-import org.eclipse.swt.graphics.*;
-import org.eclipse.swt.events.*;
-
-/**
- * Instances of this class implement the notebook user interface
- * metaphor. It allows the user to select a notebook page from
- * set of pages.
- * <p>
- * The item children that may be added to instances of this class
- * must be of type <code>TabItem</code>.
- * <code>Control</code> children are created and then set into a
- * tab item using <code>TabItem#setControl</code>.
- * </p><p>
- * Note that although this class is a subclass of <code>Composite</code>,
- * it does not make sense to set a layout on it.
- * </p><p>
- * <dl>
- * <dt><b>Styles:</b></dt>
- * <dd>(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 {
- int notebookHandle;
- TabItem [] items;
-
-
-/*
- * == CONSTRUCTORS ==
- */
-
-/**
- * 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 TabFolder (Composite parent, int style) {
- super (parent, checkStyle (style));
-}
-
-/*
- * == HANDLE DANCES, FIRST SPECIES ==
- */
-
-void createHandle (int index) {
- state |= HANDLE;
- eventBoxHandle = OS.gtk_event_box_new();
- fixedHandle = OS.gtk_fixed_new ();
- notebookHandle = OS.gtk_notebook_new ();
- handle = OS.gtk_fixed_new();
-}
-
-void configure () {
- _connectParent();
- OS.gtk_container_add(eventBoxHandle, fixedHandle);
- OS.gtk_fixed_put (fixedHandle, notebookHandle, (short)0, (short)0);
- OS.gtk_fixed_put (fixedHandle, handle, (short)2, (short)33);
-}
-
-void showHandle() {
- OS.gtk_widget_show(eventBoxHandle);
- OS.gtk_widget_show(fixedHandle);
- OS.gtk_widget_show(notebookHandle);
- OS.gtk_widget_show(handle);
- OS.gtk_widget_realize (notebookHandle);
- OS.gtk_widget_realize (handle);
-}
-
-void register () {
- super.register ();
- WidgetTable.put (notebookHandle, this);
-}
-
-void hookEvents () {
- super.hookEvents ();
- signal_connect (notebookHandle, "size_allocate", SWT.Resize, 3);
- signal_connect (notebookHandle, "switch_page", SWT.Selection, 4);
-}
-
-void createWidget (int index) {
- super.createWidget(index);
- items = new TabItem [4];
-}
-
-int topHandle () { return eventBoxHandle; }
-int paintHandle () { return notebookHandle; }
-int parentingHandle () { return handle; }
-boolean isMyHandle(int h) {
- if (h==eventBoxHandle) return true;
- if (h==notebookHandle) return true;
- if (h==fixedHandle) return true;
- if (h==handle) return true;
- return false;
-}
-
-public Point computeSize (int wHint, int hHint, boolean changed) {
- checkWidget ();
- //notebookHandle
- int width = _computeSize(wHint, hHint, changed).x;
- int height = 0;
- 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);
-}
-
-/**
-* Computes the widget trim.
-*/
-public Rectangle computeTrim (int x, int y, int width, int height) {
- checkWidget();
- return new Rectangle(x-2, y-33, width+4, height+35);
-}
-
-/*
- **** Layout code ****
- */
-
-boolean _setSize(int width, int height) {
- boolean differentExtent = UtilFuncs.setSize(eventBoxHandle, width,height);
- UtilFuncs.setSize (fixedHandle, width,height);
- UtilFuncs.setSize (notebookHandle, width,height);
- UtilFuncs.setSize (handle, width-4, height-35);
- layoutCurrent();
- return differentExtent;
-}
-
-public Rectangle _getClientArea () {
- org.eclipse.swt.graphics.Point size = _getSize();
- int x = Math.max(size.x-4, 3);
- int y = Math.max(size.y-35, 3);
- return new Rectangle(0,0, x, y);
-}
-
-void layoutCurrent() {
- int index=getSelectionIndex();
- if (index==-1) return;
- Control control = items[index].control;
- if (control==null) return;
- if (control.isDisposed()) return;
- control.setBounds(getClientArea());
-}
-
-void createItem (TabItem item, int index) {
- int list = OS.gtk_container_children (notebookHandle);
- int itemCount = OS.g_list_length (list);
- if (!(0 <= index && index <= itemCount)) error (SWT.ERROR_ITEM_NOT_ADDED);
- if (itemCount == items.length) {
- TabItem [] newItems = new TabItem [items.length + 4];
- System.arraycopy (items, 0, newItems, 0, items.length);
- items = newItems;
- }
-
- // create a new label
- byte [] buffer = new byte [] {0};
- int labelHandle = OS.gtk_label_new (buffer);
-
- // create a new fake page
- int stubPage = OS.gtk_fixed_new();
-
- // put the label and the fake page inside the notebook
- OS.gtk_signal_handler_block_by_data (notebookHandle, SWT.Selection);
- OS.gtk_notebook_append_page(notebookHandle, stubPage, labelHandle);
- OS.gtk_signal_handler_unblock_by_data (notebookHandle, SWT.Selection);
-
- OS.gtk_widget_show(labelHandle);
- OS.gtk_widget_show(stubPage);
-
- item.state |= HANDLE;
- item.handle = labelHandle;
- System.arraycopy (items, index, items, index + 1, itemCount++ - index);
- items [index] = item;
- OS.gtk_notebook_set_show_tabs (notebookHandle, 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.
- * <p>
- * When <code>widgetSelected</code> is called, the item field of the event object is valid.
- * <code>widgetDefaultSelected</code> is not called.
- * </p>
- *
- * @param listener the listener which should be notified
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see SelectionListener
- * @see #removeSelectionListener
- * @see SelectionEvent
- */
-public void addSelectionListener(SelectionListener listener) {
- 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 destroyItem (TabItem item) {
- int index = 0;
- int itemCount = getItemCount();
- while (index < itemCount) {
- if (items [index] == item) break;
- index++;
- }
- if (index == itemCount) error (SWT.ERROR_ITEM_NOT_REMOVED);
- OS.gtk_notebook_remove_page (notebookHandle, index);
- System.arraycopy (items, index + 1, items, index, --itemCount - index);
- items [itemCount] = null;
- item.handle = 0;
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+import org.eclipse.swt.*;
+import org.eclipse.swt.internal.gtk.*;
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.events.*;
+
+/**
+ * Instances of this class implement the notebook user interface
+ * metaphor. It allows the user to select a notebook page from
+ * set of pages.
+ * <p>
+ * The item children that may be added to instances of this class
+ * must be of type <code>TabItem</code>.
+ * <code>Control</code> children are created and then set into a
+ * tab item using <code>TabItem#setControl</code>.
+ * </p><p>
+ * Note that although this class is a subclass of <code>Composite</code>,
+ * it does not make sense to set a layout on it.
+ * </p><p>
+ * <dl>
+ * <dt><b>Styles:</b></dt>
+ * <dd>(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 {
+ int notebookHandle;
+ TabItem [] items;
+
+
+/*
+ * == CONSTRUCTORS ==
+ */
+
+/**
+ * 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 TabFolder (Composite parent, int style) {
+ super (parent, checkStyle (style));
+}
+
+/*
+ * == HANDLE DANCES, FIRST SPECIES ==
+ */
+
+void createHandle (int index) {
+ state |= HANDLE;
+ eventBoxHandle = OS.gtk_event_box_new();
+ fixedHandle = OS.gtk_fixed_new ();
+ notebookHandle = OS.gtk_notebook_new ();
+ handle = OS.gtk_fixed_new();
+}
+
+void configure () {
+ _connectParent();
+ OS.gtk_container_add(eventBoxHandle, fixedHandle);
+ OS.gtk_fixed_put (fixedHandle, notebookHandle, (short)0, (short)0);
+ OS.gtk_fixed_put (fixedHandle, handle, (short)2, (short)33);
+}
+
+void showHandle() {
+ OS.gtk_widget_show(eventBoxHandle);
+ OS.gtk_widget_show(fixedHandle);
+ OS.gtk_widget_show(notebookHandle);
+ OS.gtk_widget_show(handle);
+ OS.gtk_widget_realize (notebookHandle);
+ OS.gtk_widget_realize (handle);
+}
+
+void register () {
+ super.register ();
+ WidgetTable.put (notebookHandle, this);
+}
+
+void hookEvents () {
+ super.hookEvents ();
+ signal_connect (notebookHandle, "size_allocate", SWT.Resize, 3);
+ signal_connect (notebookHandle, "switch_page", SWT.Selection, 4);
+}
+
+void createWidget (int index) {
+ super.createWidget(index);
+ items = new TabItem [4];
+}
+
+int topHandle () { return eventBoxHandle; }
+int paintHandle () { return notebookHandle; }
+int parentingHandle () { return handle; }
+boolean isMyHandle(int h) {
+ if (h==eventBoxHandle) return true;
+ if (h==notebookHandle) return true;
+ if (h==fixedHandle) return true;
+ if (h==handle) return true;
+ return false;
+}
+
+public Point computeSize (int wHint, int hHint, boolean changed) {
+ checkWidget ();
+ //notebookHandle
+ int width = _computeSize(wHint, hHint, changed).x;
+ int height = 0;
+ 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);
+}
+
+/**
+* Computes the widget trim.
+*/
+public Rectangle computeTrim (int x, int y, int width, int height) {
+ checkWidget();
+ return new Rectangle(x-2, y-33, width+4, height+35);
+}
+
+/*
+ **** Layout code ****
+ */
+
+boolean _setSize(int width, int height) {
+ boolean differentExtent = UtilFuncs.setSize(eventBoxHandle, width,height);
+ UtilFuncs.setSize (fixedHandle, width,height);
+ UtilFuncs.setSize (notebookHandle, width,height);
+ UtilFuncs.setSize (handle, width-4, height-35);
+ layoutCurrent();
+ return differentExtent;
+}
+
+public Rectangle _getClientArea () {
+ org.eclipse.swt.graphics.Point size = _getSize();
+ int x = Math.max(size.x-4, 3);
+ int y = Math.max(size.y-35, 3);
+ return new Rectangle(0,0, x, y);
+}
+
+void layoutCurrent() {
+ int index=getSelectionIndex();
+ if (index==-1) return;
+ Control control = items[index].control;
+ if (control==null) return;
+ if (control.isDisposed()) return;
+ control.setBounds(getClientArea());
+}
+
+void createItem (TabItem item, int index) {
+ int list = OS.gtk_container_children (notebookHandle);
+ int itemCount = OS.g_list_length (list);
+ if (!(0 <= index && index <= itemCount)) error (SWT.ERROR_ITEM_NOT_ADDED);
+ if (itemCount == items.length) {
+ TabItem [] newItems = new TabItem [items.length + 4];
+ System.arraycopy (items, 0, newItems, 0, items.length);
+ items = newItems;
+ }
+
+ // create a new label
+ byte [] buffer = new byte [] {0};
+ int labelHandle = OS.gtk_label_new (buffer);
+
+ // create a new fake page
+ int stubPage = OS.gtk_fixed_new();
+
+ // put the label and the fake page inside the notebook
+ OS.gtk_signal_handler_block_by_data (notebookHandle, SWT.Selection);
+ OS.gtk_notebook_append_page(notebookHandle, stubPage, labelHandle);
+ OS.gtk_signal_handler_unblock_by_data (notebookHandle, SWT.Selection);
+
+ OS.gtk_widget_show(labelHandle);
+ OS.gtk_widget_show(stubPage);
+
+ item.state |= HANDLE;
+ item.handle = labelHandle;
+ System.arraycopy (items, index, items, index + 1, itemCount++ - index);
+ items [index] = item;
+ OS.gtk_notebook_set_show_tabs (notebookHandle, 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.
+ * <p>
+ * When <code>widgetSelected</code> is called, the item field of the event object is valid.
+ * <code>widgetDefaultSelected</code> is not called.
+ * </p>
+ *
+ * @param listener the listener which should be notified
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see SelectionListener
+ * @see #removeSelectionListener
+ * @see SelectionEvent
+ */
+public void addSelectionListener(SelectionListener listener) {
+ 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 destroyItem (TabItem item) {
+ int index = 0;
+ int itemCount = getItemCount();
+ while (index < itemCount) {
+ if (items [index] == item) break;
+ index++;
+ }
+ if (index == itemCount) error (SWT.ERROR_ITEM_NOT_REMOVED);
+ OS.gtk_notebook_remove_page (notebookHandle, index);
+ System.arraycopy (items, index + 1, items, index, --itemCount - index);
+ items [itemCount] = null;
+ item.handle = 0;
+}
/**
* Returns the item at the given, zero-relative index in the
* receiver. Throws an exception if the index is out of range.
@@ -282,16 +282,16 @@ void destroyItem (TabItem item) {
* <li>ERROR_WIDGET_DISPOSED - if 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) {
- if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
- if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
- int list = OS.gtk_container_children (notebookHandle);
- int itemCount = OS.g_list_length (list);
- if (!(0 <= index && index < itemCount)) error (SWT.ERROR_CANNOT_GET_ITEM);
- return items [index];
-}
+ */
+
+public TabItem getItem (int index) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int list = OS.gtk_container_children (notebookHandle);
+ int itemCount = OS.g_list_length (list);
+ if (!(0 <= index && index < itemCount)) error (SWT.ERROR_CANNOT_GET_ITEM);
+ return items [index];
+}
/**
* Returns the number of items contained in the receiver.
*
@@ -301,14 +301,14 @@ public TabItem getItem (int index) {
* <li>ERROR_WIDGET_DISPOSED - if 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 () {
- if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
- if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
- //return itemCount;
- int list = OS.gtk_container_children (notebookHandle);
- return OS.g_list_length (list);
-}
+ */
+public int getItemCount () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ //return itemCount;
+ int list = OS.gtk_container_children (notebookHandle);
+ return OS.g_list_length (list);
+}
/**
* Returns an array of <code>TabItem</code>s which are the items
* in the receiver.
@@ -324,16 +324,16 @@ public int getItemCount () {
* <li>ERROR_WIDGET_DISPOSED - if 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 () {
- if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
- if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
- int list = OS.gtk_container_children (notebookHandle);
- int itemCount = OS.g_list_length (list);
- TabItem [] result = new TabItem [itemCount];
- System.arraycopy (items, 0, result, 0, itemCount);
- return result;
-}
+ */
+public TabItem [] getItems () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int list = OS.gtk_container_children (notebookHandle);
+ int itemCount = OS.g_list_length (list);
+ TabItem [] result = new TabItem [itemCount];
+ System.arraycopy (items, 0, result, 0, itemCount);
+ return result;
+}
/**
* Returns an array of <code>TabItem</code>s that are currently
* selected in the receiver. An empty array indicates that no
@@ -349,14 +349,14 @@ public TabItem [] getItems () {
* <li>ERROR_WIDGET_DISPOSED - if 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 () {
- if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
- if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
- int index = OS.gtk_notebook_get_current_page (notebookHandle);
- if (index == -1) return new TabItem [0];
- return new TabItem [] {items [index]};
-}
+ */
+public TabItem [] getSelection () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int index = OS.gtk_notebook_get_current_page (notebookHandle);
+ 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.
@@ -367,13 +367,13 @@ public TabItem [] getSelection () {
* <li>ERROR_WIDGET_DISPOSED - if 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 () {
- if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
- if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
- return OS.gtk_notebook_get_current_page (notebookHandle);
-}
-
+ */
+public int getSelectionIndex () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ return OS.gtk_notebook_get_current_page (notebookHandle);
+}
+
/**
* Searches the receiver's list starting at the first item
* (index 0) until an item is found that is equal to the
@@ -390,38 +390,38 @@ public int getSelectionIndex () {
* <li>ERROR_WIDGET_DISPOSED - if 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) {
- if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
- if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
- if (item == null) error (SWT.ERROR_NULL_ARGUMENT);
- int list = OS.gtk_container_children (notebookHandle);
- int itemCount = OS.g_list_length (list);
- for (int i=0; i<itemCount; i++) {
- if (items [i] == item) return i;
- }
- return -1;
-}
-
-int processSelection (int int0, int int1, int int2) {
- int index = OS.gtk_notebook_get_current_page (notebookHandle);
- if (index != -1) {
- Control control = items [index].getControl ();
- if (control != null && !control.isDisposed ()) {
- control.setVisible (false);
- }
- }
- Control control = items [int1].getControl ();
- if (control != null && !control.isDisposed ()) {
- control.setBounds(getClientArea());
- control.setVisible (true);
- }
- Event event = new Event();
- event.item = items[int1];
- postEvent(SWT.Selection, event);
- return 0;
-}
-
+ */
+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 list = OS.gtk_container_children (notebookHandle);
+ int itemCount = OS.g_list_length (list);
+ for (int i=0; i<itemCount; i++) {
+ if (items [i] == item) return i;
+ }
+ return -1;
+}
+
+int processSelection (int int0, int int1, int int2) {
+ int index = OS.gtk_notebook_get_current_page (notebookHandle);
+ if (index != -1) {
+ Control control = items [index].getControl ();
+ if (control != null && !control.isDisposed ()) {
+ control.setVisible (false);
+ }
+ }
+ Control control = items [int1].getControl ();
+ if (control != null && !control.isDisposed ()) {
+ control.setBounds(getClientArea());
+ control.setVisible (true);
+ }
+ Event event = new Event();
+ event.item = items[int1];
+ postEvent(SWT.Selection, event);
+ return 0;
+}
+
/**
* Removes the listener from the collection of listeners who will
* be notified when the receiver's selection changes.
@@ -438,15 +438,15 @@ int processSelection (int int0, int int1, int int2) {
*
* @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);
-}
+ */
+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 the item at the given zero-relative index in the receiver.
* If the item at the index was already selected, it remains selected.
@@ -459,15 +459,15 @@ public void removeSelectionListener (SelectionListener listener) {
* <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
- */
-public void setSelection (int index) {
- checkWidget();
- if (index == -1) return;
- OS.gtk_signal_handler_block_by_data (notebookHandle, SWT.Selection);
- OS.gtk_notebook_set_page (notebookHandle, index);
- OS.gtk_signal_handler_unblock_by_data (notebookHandle, SWT.Selection);
-}
-
+ */
+public void setSelection (int index) {
+ checkWidget();
+ if (index == -1) return;
+ OS.gtk_signal_handler_block_by_data (notebookHandle, SWT.Selection);
+ OS.gtk_notebook_set_page (notebookHandle, index);
+ OS.gtk_signal_handler_unblock_by_data (notebookHandle, SWT.Selection);
+}
+
/**
* Sets the receiver's selection to be the given array of items.
* The current selected is first cleared, then the new items are
@@ -479,78 +479,78 @@ public void setSelection (int index) {
* <li>ERROR_WIDGET_DISPOSED - if the 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) {
- 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);
- }
-}
-
-/*
- * == DESTRUCTION ===
- */
-
-void deregister () {
- super.deregister ();
- WidgetTable.remove (notebookHandle);
-}
-
-void releaseChildren() {
- int list = OS.gtk_container_children (notebookHandle);
- int itemCount = OS.g_list_length (list);
- for (int i=0; i<itemCount; i++) {
- TabItem item = items [i];
- if (!item.isDisposed ()) {
- item.releaseWidget ();
- item.releaseHandle ();
- }
- }
-
- // Now, the non-item children
- list = OS.gtk_container_children(parentingHandle());
- int childCount = OS.g_list_length (list);
- for (int i=0; i<childCount; i++) {
- int childHandle = OS.g_list_nth_data(list, i);
- if (!isMyHandle(childHandle)) {
- Widget w = WidgetTable.get(childHandle);
- if (!(w==null) && !(w.isDisposed())) {
- w.releaseWidget();
- w.releaseHandle();
- }
- }
- }
-}
-
-void releaseHandle () {
- super.releaseHandle ();
- notebookHandle = 0;
-}
-
-void releaseWidget () {
- super.releaseWidget();
- items = null;
-}
-
-/*
- * == AS YET UNCLASSIFIED ===
- */
-
-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 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);
+ }
+}
+
+/*
+ * == DESTRUCTION ===
+ */
+
+void deregister () {
+ super.deregister ();
+ WidgetTable.remove (notebookHandle);
+}
+
+void releaseChildren() {
+ int list = OS.gtk_container_children (notebookHandle);
+ int itemCount = OS.g_list_length (list);
+ for (int i=0; i<itemCount; i++) {
+ TabItem item = items [i];
+ if (!item.isDisposed ()) {
+ item.releaseWidget ();
+ item.releaseHandle ();
+ }
+ }
+
+ // Now, the non-item children
+ list = OS.gtk_container_children(parentingHandle());
+ int childCount = OS.g_list_length (list);
+ for (int i=0; i<childCount; i++) {
+ int childHandle = OS.g_list_nth_data(list, i);
+ if (!isMyHandle(childHandle)) {
+ Widget w = WidgetTable.get(childHandle);
+ if (!(w==null) && !(w.isDisposed())) {
+ w.releaseWidget();
+ w.releaseHandle();
+ }
+ }
+ }
+}
+
+void releaseHandle () {
+ super.releaseHandle ();
+ notebookHandle = 0;
+}
+
+void releaseWidget () {
+ super.releaseWidget();
+ items = null;
+}
+
+/*
+ * == AS YET UNCLASSIFIED ===
+ */
+
+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);
+}
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk1x/org/eclipse/swt/widgets/TabItem.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk1x/org/eclipse/swt/widgets/TabItem.java
index 13a5eab531..2e2fb57381 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk1x/org/eclipse/swt/widgets/TabItem.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk1x/org/eclipse/swt/widgets/TabItem.java
@@ -1,17 +1,17 @@
-package org.eclipse.swt.widgets;
-
-/*
+package org.eclipse.swt.widgets;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-import org.eclipse.swt.*;
-import org.eclipse.swt.internal.*;
-import org.eclipse.swt.internal.gtk.*;
-import org.eclipse.swt.graphics.*;
-
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+import org.eclipse.swt.*;
+import org.eclipse.swt.internal.*;
+import org.eclipse.swt.internal.gtk.*;
+import org.eclipse.swt.graphics.*;
+
/**
* Instances of this class represent a selectable user interface object
* corresponding to a tab for a page in a tab folder.
@@ -24,11 +24,11 @@ import org.eclipse.swt.graphics.*;
* <p>
* IMPORTANT: This class is <em>not</em> intended to be subclassed.
* </p>
- */
-
-public class TabItem extends Item {
- Control control;
- TabFolder parent;
+ */
+
+public class TabItem extends Item {
+ Control control;
+ TabFolder parent;
/**
* Constructs a new instance of this class given its parent
* (which must be a <code>TabFolder</code>) and a style value
@@ -58,12 +58,12 @@ public class TabItem extends Item {
* @see SWT
* @see Widget#checkSubclass
* @see Widget#getStyle
- */
-public TabItem (TabFolder parent, int style) {
- super (parent, style);
- this.parent = parent;
- parent.createItem (this, parent.getItemCount ());
-}
+ */
+public TabItem (TabFolder 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>TabFolder</code>), a style value
@@ -94,12 +94,12 @@ public TabItem (TabFolder parent, int style) {
* @see SWT
* @see Widget#checkSubclass
* @see Widget#getStyle
- */
-public TabItem (TabFolder parent, int style, int index) {
- super (parent, style);
- this.parent = parent;
- parent.createItem (this, index);
-}
+ */
+public TabItem (TabFolder parent, int style, int index) {
+ super (parent, style);
+ this.parent = parent;
+ parent.createItem (this, index);
+}
/**
* Returns the control that is used to fill the client area of
* the tab folder when the user selects the tab item. If no
@@ -111,17 +111,17 @@ public TabItem (TabFolder parent, int style, int index) {
* <li>ERROR_WIDGET_DISPOSED - if 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 () {
- 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 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 ();
+}
/**
* Returns the receiver's parent, which must be a <code>TabFolder</code>.
*
@@ -131,12 +131,12 @@ public Display getDisplay () {
* <li>ERROR_WIDGET_DISPOSED - if 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 () {
- if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
- if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
- return parent;
-}
+ */
+public TabFolder getParent () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ return parent;
+}
/**
* Returns the receiver's tool tip text, or null if it has
* not been set.
@@ -147,20 +147,20 @@ public TabFolder getParent () {
* <li>ERROR_WIDGET_DISPOSED - if 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 () {
- if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
- if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
- return "";
-}
-void releaseChild () {
- super.releaseChild ();
- parent.destroyItem (this);
-}
-void releaseWidget () {
- super.releaseWidget ();
- parent = null;
-}
+ */
+public String getToolTipText () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ return "";
+}
+void releaseChild () {
+ super.releaseChild ();
+ parent.destroyItem (this);
+}
+void releaseWidget () {
+ super.releaseWidget ();
+ parent = null;
+}
/**
* Sets the control that is used to fill the client area of
* the tab folder when the user selects the tab item.
@@ -175,33 +175,33 @@ void releaseWidget () {
* <li>ERROR_WIDGET_DISPOSED - if the 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) {
- if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
- if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
- 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);
- super.setImage (image);
-}
-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);
- byte [] buffer = string2bytesConvertMnemonic(string);
- OS.gtk_label_parse_uline(handle, buffer);
-}
+ */
+public void setControl (Control control) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ 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);
+ super.setImage (image);
+}
+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);
+ byte [] buffer = string2bytesConvertMnemonic(string);
+ OS.gtk_label_parse_uline(handle, buffer);
+}
/**
* Sets the receiver's tool tip text to the argument, which
* may be null indicating that no tool tip text should be shown.
@@ -212,9 +212,9 @@ public void setText (String string) {
* <li>ERROR_WIDGET_DISPOSED - if the 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) {
- if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
- if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
-}
-}
+ */
+public void setToolTipText (String string) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+}
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk1x/org/eclipse/swt/widgets/TableColumn.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk1x/org/eclipse/swt/widgets/TableColumn.java
index 021c46b64b..db974376ea 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk1x/org/eclipse/swt/widgets/TableColumn.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk1x/org/eclipse/swt/widgets/TableColumn.java
@@ -1,18 +1,18 @@
-package org.eclipse.swt.widgets;
-
-/*
+package org.eclipse.swt.widgets;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-import org.eclipse.swt.*;
-import org.eclipse.swt.internal.*;
-import org.eclipse.swt.internal.gtk.*;
-import org.eclipse.swt.graphics.*;
-import org.eclipse.swt.events.*;
-
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+import org.eclipse.swt.*;
+import org.eclipse.swt.internal.*;
+import org.eclipse.swt.internal.gtk.*;
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.events.*;
+
/**
* Instances of this class represent a column in a table widget.
* <dl>
@@ -21,15 +21,15 @@ import org.eclipse.swt.events.*;
* <dt><b>Events:</b></dt>
* <dd> Move, Resize, Selection</dd>
* </dl>
- * <p>
- * Note: Only one of the styles LEFT, RIGHT and CENTER may be specified.
- * </p><p>
+ * <p>
+ * Note: Only one of the styles LEFT, RIGHT and CENTER may be specified.
+ * </p><p>
* IMPORTANT: This class is <em>not</em> intended to be subclassed.
* </p>
- */
-
-public class TableColumn extends Item {
- Table parent;
+ */
+
+public class TableColumn extends Item {
+ Table parent;
/**
* Constructs a new instance of this class given its parent
* (which must be a <code>Table</code>) and a style value
@@ -59,12 +59,12 @@ public class TableColumn extends Item {
* @see SWT
* @see Widget#checkSubclass
* @see Widget#getStyle
- */
-public TableColumn (Table parent, int style) {
- super (parent, checkStyle (style));
- this.parent = parent;
- createWidget (parent.getColumnCount ());
-}
+ */
+public TableColumn (Table parent, int style) {
+ super (parent, checkStyle (style));
+ this.parent = parent;
+ createWidget (parent.getColumnCount ());
+}
/**
* Constructs a new instance of this class given its parent
* (which must be a <code>Table</code>), a style value
@@ -95,12 +95,12 @@ public TableColumn (Table parent, int style) {
* @see SWT
* @see Widget#checkSubclass
* @see Widget#getStyle
- */
-public TableColumn (Table parent, int style, int index) {
- super (parent, checkStyle (style));
- this.parent = parent;
- createWidget (index);
-}
+ */
+public TableColumn (Table parent, int style, int index) {
+ super (parent, checkStyle (style));
+ this.parent = parent;
+ createWidget (index);
+}
/**
* Adds the listener to the collection of listeners who will
* be notified when the control is moved or resized, by sending
@@ -119,54 +119,54 @@ public TableColumn (Table parent, int style, int index) {
*
* @see ControlListener
* @see #removeControlListener
- */
-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 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.
- * <p>
- * <code>widgetSelected</code> is called when the column header is selected.
- * <code>widgetDefaultSelected</code> is not called.
- * </p>
- *
- * @param listener the listener which should be notified
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see SelectionListener
- * @see #removeSelectionListener
- * @see SelectionEvent
- */
-public void addSelectionListener (SelectionListener listener) {
- 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.LEFT, SWT.CENTER, SWT.RIGHT, 0, 0, 0);
-}
-void createWidget (int index) {
- parent.createItem (this, index);
- text = "";
-}
+ */
+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 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.
+ * <p>
+ * <code>widgetSelected</code> is called when the column header is selected.
+ * <code>widgetDefaultSelected</code> is not called.
+ * </p>
+ *
+ * @param listener the listener which should be notified
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see SelectionListener
+ * @see #removeSelectionListener
+ * @see SelectionEvent
+ */
+public void addSelectionListener (SelectionListener listener) {
+ 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.LEFT, SWT.CENTER, SWT.RIGHT, 0, 0, 0);
+}
+void createWidget (int index) {
+ parent.createItem (this, index);
+ text = "";
+}
/**
* Returns a value which describes the position of the
* text or image in the receiver. The value will be one of
@@ -178,20 +178,20 @@ void createWidget (int index) {
* <li>ERROR_WIDGET_DISPOSED - if 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 () {
- 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;
-}
-public Display getDisplay () {
- Table parent = this.parent;
- if (parent == null) error (SWT.ERROR_WIDGET_DISPOSED);
- return parent.getDisplay ();
-}
+ */
+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;
+}
+public Display getDisplay () {
+ Table parent = this.parent;
+ if (parent == null) error (SWT.ERROR_WIDGET_DISPOSED);
+ return parent.getDisplay ();
+}
/**
* Returns the receiver's parent, which must be a <code>Table</code>.
*
@@ -201,12 +201,12 @@ public Display getDisplay () {
* <li>ERROR_WIDGET_DISPOSED - if 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 () {
- if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
- if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
- return parent;
-}
+ */
+public Table getParent () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ return parent;
+}
/**
* Gets the resizable attribute. A column that is
* not resizable cannot be dragged by the user but
@@ -218,19 +218,19 @@ public Table getParent () {
* <li>ERROR_WIDGET_DISPOSED - if 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 () {
- if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
- if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
- int index = parent.indexOf (this);
- if (index == -1) return false;
- GtkCList gtkclist = new GtkCList();
- OS.memmove(gtkclist, parent.handle, GtkCList.sizeof);
- int chandle=gtkclist.column;
- GtkCListColumn gtkcolumn = new GtkCListColumn();
- OS.memmove(gtkcolumn, chandle+index*GtkCListColumn.sizeof, GtkCListColumn.sizeof);
- return (gtkcolumn.resizeable == 1) ? true : false;
-}
+ */
+public boolean getResizable () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int index = parent.indexOf (this);
+ if (index == -1) return false;
+ GtkCList gtkclist = new GtkCList();
+ OS.memmove(gtkclist, parent.handle, GtkCList.sizeof);
+ int chandle=gtkclist.column;
+ GtkCListColumn gtkcolumn = new GtkCListColumn();
+ OS.memmove(gtkcolumn, chandle+index*GtkCListColumn.sizeof, GtkCListColumn.sizeof);
+ return (gtkcolumn.resizeable == 1) ? true : false;
+}
/**
* Gets the width of the receiver.
*
@@ -240,19 +240,19 @@ public boolean getResizable () {
* <li>ERROR_WIDGET_DISPOSED - if 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 () {
- if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
- if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
- int index = parent.indexOf (this);
- if (index == -1) return 0;
- GtkCList gtkclist = new GtkCList();
- OS.memmove(gtkclist, parent.handle, GtkCList.sizeof);
- int chandle=gtkclist.column;
- GtkCListColumn gtkcolumn = new GtkCListColumn();
- OS.memmove(gtkcolumn, chandle+index*GtkCListColumn.sizeof, GtkCListColumn.sizeof);
- return gtkcolumn.width;
-}
+ */
+public int getWidth () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int index = parent.indexOf (this);
+ if (index == -1) return 0;
+ GtkCList gtkclist = new GtkCList();
+ OS.memmove(gtkclist, parent.handle, GtkCList.sizeof);
+ int chandle=gtkclist.column;
+ GtkCListColumn gtkcolumn = new GtkCListColumn();
+ OS.memmove(gtkcolumn, chandle+index*GtkCListColumn.sizeof, GtkCListColumn.sizeof);
+ return gtkcolumn.width;
+}
/**
* Causes the receiver to be resized to its preferred size.
* For a composite, this involves computing the preferred size
@@ -263,20 +263,20 @@ public int getWidth () {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*
- */
-public void pack () {
- if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
- if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
-}
-void releaseChild () {
- super.releaseChild ();
- parent.destroyItem (this);
-}
-void releaseWidget () {
- super.releaseWidget ();
- text = null;
- parent = null;
-}
+ */
+public void pack () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+}
+void releaseChild () {
+ super.releaseChild ();
+ parent.destroyItem (this);
+}
+void releaseWidget () {
+ super.releaseWidget ();
+ text = null;
+ parent = null;
+}
/**
* Removes the listener from the collection of listeners who will
* be notified when the control is moved or resized.
@@ -293,15 +293,15 @@ void releaseWidget () {
*
* @see ControlListener
* @see #addControlListener
- */
-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 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 from the collection of listeners who will
* be notified when the control is selected.
@@ -318,15 +318,15 @@ public void removeControlListener (ControlListener listener) {
*
* @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);
-}
+ */
+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);
+}
/**
* Controls how text and images will be displayed in the receiver.
* The argument should be one of <code>LEFT</code>, <code>RIGHT</code>
@@ -338,22 +338,22 @@ public void removeSelectionListener(SelectionListener listener) {
* <li>ERROR_WIDGET_DISPOSED - if the 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) {
- if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
- if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
- if ((alignment & (SWT.LEFT | SWT.RIGHT | SWT.CENTER)) == 0) return;
- int index = parent.indexOf (this);
- if (index == -1 || index == 0) return;
- int table = parent.handle;
- style &= ~(SWT.LEFT | SWT.RIGHT | SWT.CENTER);
- style |= alignment & (SWT.LEFT | SWT.RIGHT | SWT.CENTER);
- int justification = 0;
- if ((style & SWT.LEFT) == SWT.LEFT) justification |= OS.GTK_JUSTIFY_LEFT;
- if ((style & SWT.CENTER) == SWT.CENTER) justification |= OS.GTK_JUSTIFY_CENTER;
- if ((style & SWT.RIGHT) == SWT.RIGHT) justification |= OS.GTK_JUSTIFY_RIGHT;
- OS.gtk_clist_set_column_justification (table, index, justification);
-}
+ */
+public void setAlignment (int alignment) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if ((alignment & (SWT.LEFT | SWT.RIGHT | SWT.CENTER)) == 0) return;
+ int index = parent.indexOf (this);
+ if (index == -1 || index == 0) return;
+ int table = parent.handle;
+ style &= ~(SWT.LEFT | SWT.RIGHT | SWT.CENTER);
+ style |= alignment & (SWT.LEFT | SWT.RIGHT | SWT.CENTER);
+ int justification = 0;
+ if ((style & SWT.LEFT) == SWT.LEFT) justification |= OS.GTK_JUSTIFY_LEFT;
+ if ((style & SWT.CENTER) == SWT.CENTER) justification |= OS.GTK_JUSTIFY_CENTER;
+ if ((style & SWT.RIGHT) == SWT.RIGHT) justification |= OS.GTK_JUSTIFY_RIGHT;
+ OS.gtk_clist_set_column_justification (table, index, justification);
+}
/**
* Sets the resizable attribute. A column that is
* not resizable cannot be dragged by the user but
@@ -365,26 +365,26 @@ public void setAlignment (int alignment) {
* <li>ERROR_WIDGET_DISPOSED - if the 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) {
- if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
- if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
- int index = parent.indexOf (this);
- if (index == -1) return;
- int table = parent.handle;
- OS.gtk_clist_set_column_resizeable (table, index, resizable);
-}
-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);
- int index = parent.indexOf (this);
- if (index == -1) return;
- int table = parent.handle;
- byte [] buffer = Converter.wcsToMbcs (null, string, true);
- OS.gtk_clist_set_column_title (table, index, buffer);
-}
+ */
+public void setResizable (boolean resizable) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int index = parent.indexOf (this);
+ if (index == -1) return;
+ int table = parent.handle;
+ OS.gtk_clist_set_column_resizeable (table, index, resizable);
+}
+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);
+ int index = parent.indexOf (this);
+ if (index == -1) return;
+ int table = parent.handle;
+ byte [] buffer = Converter.wcsToMbcs (null, string, true);
+ OS.gtk_clist_set_column_title (table, index, buffer);
+}
/**
* Sets the width of the receiver.
*
@@ -394,14 +394,14 @@ public void setText (String string) {
* <li>ERROR_WIDGET_DISPOSED - if the 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) {
- if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
- if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
- int index = parent.indexOf (this);
- if (index == -1) return;
- int table = parent.handle;
- OS.gtk_clist_set_column_width (table, index, width);
-}
-
-}
+ */
+public void setWidth (int width) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int index = parent.indexOf (this);
+ if (index == -1) return;
+ int table = parent.handle;
+ OS.gtk_clist_set_column_width (table, index, width);
+}
+
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk1x/org/eclipse/swt/widgets/TableItem.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk1x/org/eclipse/swt/widgets/TableItem.java
index fcf6cad597..82239af3c2 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk1x/org/eclipse/swt/widgets/TableItem.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk1x/org/eclipse/swt/widgets/TableItem.java
@@ -1,18 +1,18 @@
-package org.eclipse.swt.widgets;
-
-/*
+package org.eclipse.swt.widgets;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-import org.eclipse.swt.*;
-import org.eclipse.swt.internal.*;
-import org.eclipse.swt.internal.gtk.*;
-import org.eclipse.swt.graphics.*;
-import org.eclipse.swt.graphics.*;
-
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+import org.eclipse.swt.*;
+import org.eclipse.swt.internal.*;
+import org.eclipse.swt.internal.gtk.*;
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.graphics.*;
+
/**
* Instances of this class represent a selectable user interface object
* that represents an item in a table.
@@ -25,10 +25,10 @@ import org.eclipse.swt.graphics.*;
* <p>
* IMPORTANT: This class is <em>not</em> intended to be subclassed.
* </p>
- */
-
-public class TableItem extends Item {
- Table parent;
+ */
+
+public class TableItem extends Item {
+ Table parent;
/**
* Constructs a new instance of this class given its parent
* (which must be a <code>Table</code>) and a style value
@@ -59,12 +59,12 @@ public class TableItem extends Item {
* @see Widget#checkSubclass
* @see Widget#getStyle
*/
-public TableItem (Table parent, int style) {
- super (parent, style);
- this.parent = parent;
- parent.createItem (this, parent.getItemCount ());
- _setChecked(false);
-}
+public TableItem (Table parent, int style) {
+ super (parent, style);
+ this.parent = parent;
+ parent.createItem (this, parent.getItemCount ());
+ _setChecked(false);
+}
/**
* Constructs a new instance of this class given its parent
* (which must be a <code>Table</code>), a style value
@@ -96,30 +96,30 @@ public TableItem (Table parent, int style) {
* @see Widget#checkSubclass
* @see Widget#getStyle
*/
-public TableItem (Table parent, int style, int index) {
- super (parent, style);
- this.parent = parent;
- parent.createItem (this, index);
- _setChecked(false);
-}
-/**
- * Returns the receiver's background color.
- *
- * @return the background color
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @since 2.0
- *
- */
-public Color getBackground () {
- checkWidget ();
- Table parent = getParent();
- return parent.getBackground();
-}
+public TableItem (Table parent, int style, int index) {
+ super (parent, style);
+ this.parent = parent;
+ parent.createItem (this, index);
+ _setChecked(false);
+}
+/**
+ * Returns the receiver's background color.
+ *
+ * @return the background color
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @since 2.0
+ *
+ */
+public Color getBackground () {
+ checkWidget ();
+ Table parent = getParent();
+ return parent.getBackground();
+}
/**
* Returns a rectangle describing the receiver's size and location
* relative to its parent at a column in the table.
@@ -131,38 +131,38 @@ public Color getBackground () {
* <li>ERROR_WIDGET_DISPOSED - if 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) {
- if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
- if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
- int CELL_SPACING=1;
- GtkCList table = new GtkCList();
- OS.memmove(table, parent.handle, GtkCList.sizeof);
- int columnHandle = table.column;
- columnHandle= columnHandle+index*GtkCListColumn.sizeof;
- GtkCListColumn column=new GtkCListColumn();
- OS.memmove(column, columnHandle, GtkCListColumn.sizeof);
- GtkAdjustment adjustment=new GtkAdjustment();
- OS.memmove(adjustment, table.vadjustment, GtkAdjustment.sizeof);
- float vaj = adjustment.value;
- OS.memmove(adjustment, table.hadjustment, GtkAdjustment.sizeof);
- float haj = adjustment.value;
- int x=(short)column.area_x+table.hoffset;
- int width=(short)column.area_width;
- int height=parent.getItemHeight();
- int row=parent.indexOf(this);
- int y=table.column_title_area_height+height*row+(row+2)*CELL_SPACING-(int)vaj;
- return new Rectangle (x, y, width, height);
-}
-
-/**
- * Return whether or not the receiver has a check box and can
- * be checked.
- */
-boolean isCheckable() {
- return (parent.style & SWT.CHECK) != 0;
-}
-
+ */
+public Rectangle getBounds (int index) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int CELL_SPACING=1;
+ GtkCList table = new GtkCList();
+ OS.memmove(table, parent.handle, GtkCList.sizeof);
+ int columnHandle = table.column;
+ columnHandle= columnHandle+index*GtkCListColumn.sizeof;
+ GtkCListColumn column=new GtkCListColumn();
+ OS.memmove(column, columnHandle, GtkCListColumn.sizeof);
+ GtkAdjustment adjustment=new GtkAdjustment();
+ OS.memmove(adjustment, table.vadjustment, GtkAdjustment.sizeof);
+ float vaj = adjustment.value;
+ OS.memmove(adjustment, table.hadjustment, GtkAdjustment.sizeof);
+ float haj = adjustment.value;
+ int x=(short)column.area_x+table.hoffset;
+ int width=(short)column.area_width;
+ int height=parent.getItemHeight();
+ int row=parent.indexOf(this);
+ int y=table.column_title_area_height+height*row+(row+2)*CELL_SPACING-(int)vaj;
+ return new Rectangle (x, y, width, height);
+}
+
+/**
+ * Return whether or not the receiver has a check box and can
+ * be checked.
+ */
+boolean isCheckable() {
+ return (parent.style & SWT.CHECK) != 0;
+}
+
/**
* Returns <code>true</code> if the receiver is checked,
* and false otherwise. When the parent does not have
@@ -174,50 +174,50 @@ boolean isCheckable() {
* <li>ERROR_WIDGET_DISPOSED - if 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;
- return _getChecked();
-}
-
-boolean _getChecked () {
- int row = parent.indexOf (this);
- if (row == -1) return false;
- int clist = parent.handle;
-
- int[] text = new int[1];
- int[] spacing = new int[1];
- int[] pixmap = new int[1];
- int[] mask = new int[1];
- OS.gtk_clist_get_pixtext(clist, row, 0, text, spacing, pixmap, mask);
-
- return pixmap[0]==parent.check;
-}
-
-public Display getDisplay () {
- Table parent = this.parent;
- if (parent == null) error (SWT.ERROR_WIDGET_DISPOSED);
- return parent.getDisplay ();
-}
-/**
- * Returns the foreground color that the receiver will use to draw.
- *
- * @return the receiver's foreground color
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @since 2.0
- *
- */
-public Color getForeground () {
- checkWidget ();
- Table parent = getParent();
- return parent.getForeground();
-}
+ */
+public boolean getChecked () {
+ checkWidget();
+ if ((parent.style & SWT.CHECK) == 0) return false;
+ return _getChecked();
+}
+
+boolean _getChecked () {
+ int row = parent.indexOf (this);
+ if (row == -1) return false;
+ int clist = parent.handle;
+
+ int[] text = new int[1];
+ int[] spacing = new int[1];
+ int[] pixmap = new int[1];
+ int[] mask = new int[1];
+ OS.gtk_clist_get_pixtext(clist, row, 0, text, spacing, pixmap, mask);
+
+ return pixmap[0]==parent.check;
+}
+
+public Display getDisplay () {
+ Table parent = this.parent;
+ if (parent == null) error (SWT.ERROR_WIDGET_DISPOSED);
+ return parent.getDisplay ();
+}
+/**
+ * Returns the foreground color that the receiver will use to draw.
+ *
+ * @return the receiver's foreground color
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @since 2.0
+ *
+ */
+public Color getForeground () {
+ checkWidget ();
+ Table parent = getParent();
+ return parent.getForeground();
+}
/**
* Returns <code>true</code> if the receiver is grayed,
* and false otherwise. When the parent does not have
@@ -229,36 +229,36 @@ public Color getForeground () {
* <li>ERROR_WIDGET_DISPOSED - if 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 () {
- if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
- if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
- if ((parent.style & SWT.CHECK) == 0) return false;
- return false;
-}
-
-/**
-* Gets the image 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 image
-* @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 (int index) {
- if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
- if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
- return null;
-}
+ */
+public boolean getGrayed () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if ((parent.style & SWT.CHECK) == 0) return false;
+ return false;
+}
+
+/**
+* Gets the image 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 image
+* @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 (int index) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ return null;
+}
/**
* Returns a rectangle describing the size and location
* relative to its parent of an image at a column in the
@@ -271,12 +271,12 @@ public Image getImage (int index) {
* <li>ERROR_WIDGET_DISPOSED - if 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) {
- if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
- if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
- return new Rectangle (0, 0, 0, 0);
-}
+ */
+public Rectangle getImageBounds (int index) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ return new Rectangle (0, 0, 0, 0);
+}
/**
* Gets the image indent.
*
@@ -286,12 +286,12 @@ public Rectangle getImageBounds (int index) {
* <li>ERROR_WIDGET_DISPOSED - if 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 () {
- if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
- if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
- return 0;
-}
+ */
+public int getImageIndent () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ return 0;
+}
/**
* Returns the receiver's parent, which must be a <code>Table</code>.
*
@@ -301,67 +301,67 @@ public int getImageIndent () {
* <li>ERROR_WIDGET_DISPOSED - if 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 () {
- if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
- if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
- return parent;
-}
-/**
-* Gets the item text 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_TEXT)
-* when the operation fails
-*/
-public String getText (int index) {
- if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
- if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
- return "";
-}
-void releaseChild () {
- super.releaseChild ();
- parent.destroyItem (this);
-}
-void releaseWidget () {
- super.releaseWidget ();
- parent = null;
-}
-/**
- * Sets the receiver's background color to the color specified
- * by the argument, or to the default system color for the item
- * if the argument is null.
- *
- * @param color the new color (or null)
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_INVALID_ARGUMENT - if the argument has been disposed</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @since 2.0
- *
- */
-public void setBackground (Color color) {
- checkWidget ();
- if (color != null && color.isDisposed ())
- SWT.error (SWT.ERROR_INVALID_ARGUMENT);
-}
+ */
+public Table getParent () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ return parent;
+}
+/**
+* Gets the item text 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_TEXT)
+* when the operation fails
+*/
+public String getText (int index) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ return "";
+}
+void releaseChild () {
+ super.releaseChild ();
+ parent.destroyItem (this);
+}
+void releaseWidget () {
+ super.releaseWidget ();
+ parent = null;
+}
+/**
+ * Sets the receiver's background color to the color specified
+ * by the argument, or to the default system color for the item
+ * if the argument is null.
+ *
+ * @param color the new color (or null)
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_INVALID_ARGUMENT - if the argument has been disposed</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @since 2.0
+ *
+ */
+public void setBackground (Color color) {
+ checkWidget ();
+ if (color != null && color.isDisposed ())
+ SWT.error (SWT.ERROR_INVALID_ARGUMENT);
+}
/**
* Sets the checked state of the receiver.
*
@@ -371,46 +371,46 @@ public void setBackground (Color color) {
* <li>ERROR_WIDGET_DISPOSED - if the 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();
- _setChecked (checked);
-}
-void _setChecked (boolean checked) {
- if ((parent.style & SWT.CHECK) == 0) return; /* needed here because we don't verify in the constructor */
-
- int row = parent.indexOf (this);
- if (row == -1) return;
- int ctable = parent.handle;
- byte [] buffer = Converter.wcsToMbcs (null, text, true);
- if (checked) OS.gtk_clist_set_pixtext (ctable, row, 0, buffer, (byte) 2, parent.check, 0);
- else OS.gtk_clist_set_pixtext (ctable, row, 0, buffer, (byte) 2, parent.uncheck, 0);
-}
-
-/**
- * Sets the receiver's foreground color to the color specified
- * by the argument, or to the default system color for the item
- * if the argument is null.
- *
- * @param color the new color (or null)
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_INVALID_ARGUMENT - if the argument has been disposed</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @since 2.0
- *
- */
-public void setForeground (Color color){
- checkWidget ();
- if (color != null && color.isDisposed ())
- SWT.error (SWT.ERROR_INVALID_ARGUMENT);
-}
-
+ */
+public void setChecked (boolean checked) {
+ checkWidget();
+ _setChecked (checked);
+}
+void _setChecked (boolean checked) {
+ if ((parent.style & SWT.CHECK) == 0) return; /* needed here because we don't verify in the constructor */
+
+ int row = parent.indexOf (this);
+ if (row == -1) return;
+ int ctable = parent.handle;
+ byte [] buffer = Converter.wcsToMbcs (null, text, true);
+ if (checked) OS.gtk_clist_set_pixtext (ctable, row, 0, buffer, (byte) 2, parent.check, 0);
+ else OS.gtk_clist_set_pixtext (ctable, row, 0, buffer, (byte) 2, parent.uncheck, 0);
+}
+
+/**
+ * Sets the receiver's foreground color to the color specified
+ * by the argument, or to the default system color for the item
+ * if the argument is null.
+ *
+ * @param color the new color (or null)
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_INVALID_ARGUMENT - if the argument has been disposed</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @since 2.0
+ *
+ */
+public void setForeground (Color color){
+ checkWidget ();
+ if (color != null && color.isDisposed ())
+ SWT.error (SWT.ERROR_INVALID_ARGUMENT);
+}
+
/**
* Sets the grayed state of the receiver.
*
@@ -420,10 +420,10 @@ public void setForeground (Color color){
* <li>ERROR_WIDGET_DISPOSED - if the 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();
-}
+ */
+public void setGrayed (boolean grayed) {
+ checkWidget();
+}
/**
* Sets the receiver's image at a column.
*
@@ -437,48 +437,48 @@ public void setGrayed (boolean grayed) {
* <li>ERROR_WIDGET_DISPOSED - if the 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) {
- if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
- if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
-// if (index == 0) {
-// setImage (image);
-// return;
-// }
- int row = parent.indexOf (this);
- if (row == -1) return;
- int pixmap = 0, mask = 0;
- if (image != null) {
- pixmap = image.pixmap;
- mask = image.mask;
- }
- int ctable = parent.handle;
- if (text != null) {
- byte [] buffer = Converter.wcsToMbcs (null, text, true);
- OS.gtk_clist_set_pixtext (ctable, row, index, buffer, (byte) 2, pixmap, mask);
- } else {
- OS.gtk_clist_set_pixmap (ctable, row, index, pixmap, mask);
- }
-}
-public void setImage (Image image) {
- if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
- if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
- int row = parent.indexOf (this);
- if (row == -1) return;
- super.setImage (image);
- int ctable = parent.handle;
- int pixmap = 0, mask = 0;
- if (image != null) {
- pixmap = image.pixmap;
- mask = image.mask;
- }
- if (text != null) {
- byte [] buffer = Converter.wcsToMbcs (null, text, true);
- OS.gtk_clist_set_pixtext (ctable, row, 0, buffer, (byte) 2, pixmap, mask);
- } else {
- OS.gtk_clist_set_pixmap (ctable, row, 0, pixmap, mask);
- }
-}
+ */
+public void setImage (int index, Image image) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+// if (index == 0) {
+// setImage (image);
+// return;
+// }
+ int row = parent.indexOf (this);
+ if (row == -1) return;
+ int pixmap = 0, mask = 0;
+ if (image != null) {
+ pixmap = image.pixmap;
+ mask = image.mask;
+ }
+ int ctable = parent.handle;
+ if (text != null) {
+ byte [] buffer = Converter.wcsToMbcs (null, text, true);
+ OS.gtk_clist_set_pixtext (ctable, row, index, buffer, (byte) 2, pixmap, mask);
+ } else {
+ OS.gtk_clist_set_pixmap (ctable, row, index, pixmap, mask);
+ }
+}
+public void setImage (Image image) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int row = parent.indexOf (this);
+ if (row == -1) return;
+ super.setImage (image);
+ int ctable = parent.handle;
+ int pixmap = 0, mask = 0;
+ if (image != null) {
+ pixmap = image.pixmap;
+ mask = image.mask;
+ }
+ if (text != null) {
+ byte [] buffer = Converter.wcsToMbcs (null, text, true);
+ OS.gtk_clist_set_pixtext (ctable, row, 0, buffer, (byte) 2, pixmap, mask);
+ } else {
+ OS.gtk_clist_set_pixmap (ctable, row, 0, pixmap, mask);
+ }
+}
/**
* Sets the image for multiple columns in the Table.
*
@@ -492,15 +492,15 @@ public void setImage (Image image) {
* <li>ERROR_WIDGET_DISPOSED - if the 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) {
- if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
- if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
- if (images == null) error (SWT.ERROR_NULL_ARGUMENT);
- for (int i=0; i<images.length; i++) {
- setImage (i, images [i]);
- }
-}
+ */
+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);
+ for (int i=0; i<images.length; i++) {
+ setImage (i, images [i]);
+ }
+}
/**
* Sets the image indent.
*
@@ -511,11 +511,11 @@ public void setImage (Image [] images) {
* <li>ERROR_WIDGET_DISPOSED - if the 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) {
- if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
- if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
-}
+ */
+public void setImageIndent (int indent) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+}
/**
* Sets the receiver's text at a column
*
@@ -529,40 +529,40 @@ public void setImageIndent (int indent) {
* <li>ERROR_WIDGET_DISPOSED - if the 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) {
- 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 == 0) {
- setText (string);
- return;
- }
- int row = parent.indexOf (this);
- if (row == -1) return;
- int ctree = parent.handle;
- byte [] buffer = Converter.wcsToMbcs (null, string, true);
- if (image != null) {
- OS.gtk_clist_set_pixtext(ctree, row, index, buffer, (byte) 2, image.pixmap, image.mask);
- } else {
- OS.gtk_clist_set_text (ctree, row, index, buffer);
- }
-}
-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 row = parent.indexOf (this);
- if (row == -1) return;
- super.setText (string);
- int ctree = parent.handle;
- byte [] buffer = Converter.wcsToMbcs (null, string, true);
- if (image != null) {
- OS.gtk_clist_set_pixtext(ctree, row, 0, buffer, (byte) 2, image.pixmap, image.mask);
- } else {
- OS.gtk_clist_set_text (ctree, row, 0, buffer);
- }
-}
+ */
+public void setText (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 == 0) {
+ setText (string);
+ return;
+ }
+ int row = parent.indexOf (this);
+ if (row == -1) return;
+ int ctree = parent.handle;
+ byte [] buffer = Converter.wcsToMbcs (null, string, true);
+ if (image != null) {
+ OS.gtk_clist_set_pixtext(ctree, row, index, buffer, (byte) 2, image.pixmap, image.mask);
+ } else {
+ OS.gtk_clist_set_text (ctree, row, index, buffer);
+ }
+}
+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 row = parent.indexOf (this);
+ if (row == -1) return;
+ super.setText (string);
+ int ctree = parent.handle;
+ byte [] buffer = Converter.wcsToMbcs (null, string, true);
+ if (image != null) {
+ OS.gtk_clist_set_pixtext(ctree, row, 0, buffer, (byte) 2, image.pixmap, image.mask);
+ } else {
+ OS.gtk_clist_set_text (ctree, row, 0, buffer);
+ }
+}
/**
* Sets the text for multiple columns in the table.
*
@@ -575,14 +575,14 @@ public void setText (String string) {
* <li>ERROR_WIDGET_DISPOSED - if the 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) {
- if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
- if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
- 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);
- }
-}
-}
+ */
+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);
+ for (int i=0; i<strings.length; i++) {
+ String string = strings [i];
+ if (string != null) setText (i, string);
+ }
+}
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk1x/org/eclipse/swt/widgets/ToolBar.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk1x/org/eclipse/swt/widgets/ToolBar.java
index 827c071bd8..ceaf15f7d6 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk1x/org/eclipse/swt/widgets/ToolBar.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk1x/org/eclipse/swt/widgets/ToolBar.java
@@ -307,8 +307,8 @@ public int indexOf (ToolItem item) {
// TEMPORARY CODE
ToolItem [] items = getItems ();
- for (int i=0; i<items.length; i++) {
- if (item == items[i]) return i;
+ for (int i=0; i<items.length; i++) {
+ if (item == items[i]) return i;
}
return -1;
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk1x/org/eclipse/swt/widgets/Tracker.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk1x/org/eclipse/swt/widgets/Tracker.java
index 9d9e66a476..5e7acf50c9 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk1x/org/eclipse/swt/widgets/Tracker.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk1x/org/eclipse/swt/widgets/Tracker.java
@@ -1,392 +1,392 @@
-package org.eclipse.swt.widgets;
-
-/*
+package org.eclipse.swt.widgets;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-import org.eclipse.swt.*;
-import org.eclipse.swt.internal.*;
-import org.eclipse.swt.internal.gtk.*;
-import org.eclipse.swt.graphics.*;
-import org.eclipse.swt.events.*;
-
-/**
- * Instances of this class implement 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 {
- Composite parent;
- Display display;
- boolean tracking, stippled;
- Rectangle [] rectangles = new Rectangle [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 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 Tracker (Composite parent, int style) {
- super (parent, style);
- this.parent = parent;
- display = parent.getDisplay ();
-}
-
-/**
- * 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 tracker on the currently active
- * display if there is one. If there is no current display, the
- * tracker is created on a "default" display. <b>Passing in null as
- * the display argument is not considered to be good coding style,
- * and may not be supported in a future release of SWT.</b>
- * </p>
- *
- * @param display the display to create the tracker on
- * @param style the style of control to construct
- *
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
- * <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
- * </ul>
- */
-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;
-}
-
-
-
-/*
- * === ADD / REMOVE LISTENERS ===
- */
-
-/**
- * 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);
-}
-
-/**
- * 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);
-}
-
-
-
-
-/*
- * === PUBLIC ACCESSORS ===
- */
-
-public Display getDisplay () {
- return display;
-}
-
-/**
- * Returns the bounds that are being drawn, expressed relative to the parent
- * widget. If the parent is a Display then these are screen coordinates.
- *
- * @return the bounds of the Rectangles being drawn
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public Rectangle [] getRectangles () {
- checkWidget();
- 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;
-}
-
-/**
- * Specify the rectangles that should be drawn, expressed relative to the parent
- * widget. If the parent is a Display then these are screen coordinates.
- *
- * @param rectangles the bounds of the rectangles to be drawn
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the 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();
- 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;
-}
-
-
-
-/*
- * === PUBLIC FUNCTIONALITY ===
- */
-
-/**
- * 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;
-}
-
-/**
- * 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();
- int xWindow = calculateWindow();
- boolean cancelled=false;
- tracking = true;
- drawRectangles ();
-
- int[] newX = new int[1];
- int[] newY = new int[1];
- int[] oldX = new int[1];
- int[] oldY = new int[1];
- OS.gdk_window_get_pointer(xWindow, oldX,oldY, 0);
-
- while (tracking) {
- if (parent != null && parent.isDisposed ()) break;
- int eventType = waitEvent();
- switch (eventType) {
- case OS.GDK_BUTTON_RELEASE:
- case OS.GDK_MOTION_NOTIFY:
- OS.gdk_window_get_pointer(xWindow, newX,newY, 0);
- 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];
- }
- Event event = new Event();
- event.x = newX[0];
- event.y = newY[0];
- sendEvent (SWT.Move,event);
- drawRectangles ();
- oldX [0] = newX [0]; oldY [0] = newY [0];
- }
- tracking = (eventType != OS.GDK_BUTTON_RELEASE);
- break;
- case OS.GDK_KEY_PRESS:
-// error(SWT.ERROR_NOT_IMPLEMENTED);
- /*
- 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, null);
- keysym [0] &= 0xFFFF;
- tracking = keysym [0] != OS.XK_Escape && keysym [0] != OS.XK_Cancel;
- cancelled = !tracking;
- }*/
- break;
- } // switch
- } // while
- drawRectangles(); // clean up our mess
- tracking = false;
- return !cancelled;
-}
-
-
-
-private void drawRectangles () {
- int xWindow = calculateWindow();
- if (parent != null) {
- if (parent.isDisposed ()) return;
- parent.getShell ().update ();
- } else {
- display.update ();
- }
-
- int gc = OS.gdk_gc_new(xWindow);
- if (gc==0) error(SWT.ERROR_UNSPECIFIED);
-
- /* White foreground */
- int colormap = OS.gdk_colormap_get_system();
- GdkColor color = new GdkColor();
- OS.gdk_color_white(colormap, color);
- OS.gdk_gc_set_foreground(gc, color);
-
- /* Draw on top of inferior widgets */
- OS.gdk_gc_set_subwindow(gc, OS.GDK_INCLUDE_INFERIORS);
-
- /* XOR */
- OS.gdk_gc_set_function(gc, OS.GDK_XOR);
-
- for (int i=0; i<rectangles.length; i++) {
- Rectangle rect = rectangles [i];
- OS.gdk_draw_rectangle(xWindow, gc, 0, rect.x, rect.y, rect.width, rect.height);
- }
- OS.gdk_gc_destroy(gc);
-}
-/*
- * Wait for an event to show up.
- * Return the event's type as a GdkEventType.
- */
-private int waitEvent() {
- int[] eventType = new int[1];
- int eventPtr;
-
- while (true) {
- eventPtr = OS.gdk_event_get();
- if (eventPtr != 0) {
- // hack, must implement memmove properly
- // GdkEvent event = new GdkEvent(eventPtr);
- OS.memmove(eventType, eventPtr, 4);
- OS.gdk_event_free(eventPtr);
- return eventType[0];
- }
- else {
- try { Thread.sleep(50); } catch (Exception ex) {}
- }
- }
-}
-
-/*
- * Figure which GdkWindow we'll draw on.
- * That's normally the root X window, or the parent's GdkWindow if we have a parent.
- */
-private int calculateWindow() {
- int answer;
- if (parent == null) {
- answer = OS.GDK_ROOT_PARENT();
- } else {
- answer = parent._gdkWindow();
- }
- if (answer==0) error(SWT.ERROR_UNSPECIFIED);
- return answer;
-}
-
-public void setCursor (Cursor value) {
-}
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+import org.eclipse.swt.*;
+import org.eclipse.swt.internal.*;
+import org.eclipse.swt.internal.gtk.*;
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.events.*;
+
+/**
+ * Instances of this class implement 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 {
+ Composite parent;
+ Display display;
+ boolean tracking, stippled;
+ Rectangle [] rectangles = new Rectangle [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 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 Tracker (Composite parent, int style) {
+ super (parent, style);
+ this.parent = parent;
+ display = parent.getDisplay ();
+}
+
+/**
+ * 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 tracker on the currently active
+ * display if there is one. If there is no current display, the
+ * tracker is created on a "default" display. <b>Passing in null as
+ * the display argument is not considered to be good coding style,
+ * and may not be supported in a future release of SWT.</b>
+ * </p>
+ *
+ * @param display the display to create the tracker on
+ * @param style the style of control to construct
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
+ * <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
+ * </ul>
+ */
+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;
+}
+
+
+
+/*
+ * === ADD / REMOVE LISTENERS ===
+ */
+
+/**
+ * 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);
+}
+
+/**
+ * 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);
+}
+
+
+
+
+/*
+ * === PUBLIC ACCESSORS ===
+ */
+
+public Display getDisplay () {
+ return display;
+}
+
+/**
+ * Returns the bounds that are being drawn, expressed relative to the parent
+ * widget. If the parent is a Display then these are screen coordinates.
+ *
+ * @return the bounds of the Rectangles being drawn
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public Rectangle [] getRectangles () {
+ checkWidget();
+ 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;
+}
+
+/**
+ * Specify the rectangles that should be drawn, expressed relative to the parent
+ * widget. If the parent is a Display then these are screen coordinates.
+ *
+ * @param rectangles the bounds of the rectangles to be drawn
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the 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();
+ 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;
+}
+
+
+
+/*
+ * === PUBLIC FUNCTIONALITY ===
+ */
+
+/**
+ * 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;
+}
+
+/**
+ * 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();
+ int xWindow = calculateWindow();
+ boolean cancelled=false;
+ tracking = true;
+ drawRectangles ();
+
+ int[] newX = new int[1];
+ int[] newY = new int[1];
+ int[] oldX = new int[1];
+ int[] oldY = new int[1];
+ OS.gdk_window_get_pointer(xWindow, oldX,oldY, 0);
+
+ while (tracking) {
+ if (parent != null && parent.isDisposed ()) break;
+ int eventType = waitEvent();
+ switch (eventType) {
+ case OS.GDK_BUTTON_RELEASE:
+ case OS.GDK_MOTION_NOTIFY:
+ OS.gdk_window_get_pointer(xWindow, newX,newY, 0);
+ 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];
+ }
+ Event event = new Event();
+ event.x = newX[0];
+ event.y = newY[0];
+ sendEvent (SWT.Move,event);
+ drawRectangles ();
+ oldX [0] = newX [0]; oldY [0] = newY [0];
+ }
+ tracking = (eventType != OS.GDK_BUTTON_RELEASE);
+ break;
+ case OS.GDK_KEY_PRESS:
+// error(SWT.ERROR_NOT_IMPLEMENTED);
+ /*
+ 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, null);
+ keysym [0] &= 0xFFFF;
+ tracking = keysym [0] != OS.XK_Escape && keysym [0] != OS.XK_Cancel;
+ cancelled = !tracking;
+ }*/
+ break;
+ } // switch
+ } // while
+ drawRectangles(); // clean up our mess
+ tracking = false;
+ return !cancelled;
+}
+
+
+
+private void drawRectangles () {
+ int xWindow = calculateWindow();
+ if (parent != null) {
+ if (parent.isDisposed ()) return;
+ parent.getShell ().update ();
+ } else {
+ display.update ();
+ }
+
+ int gc = OS.gdk_gc_new(xWindow);
+ if (gc==0) error(SWT.ERROR_UNSPECIFIED);
+
+ /* White foreground */
+ int colormap = OS.gdk_colormap_get_system();
+ GdkColor color = new GdkColor();
+ OS.gdk_color_white(colormap, color);
+ OS.gdk_gc_set_foreground(gc, color);
+
+ /* Draw on top of inferior widgets */
+ OS.gdk_gc_set_subwindow(gc, OS.GDK_INCLUDE_INFERIORS);
+
+ /* XOR */
+ OS.gdk_gc_set_function(gc, OS.GDK_XOR);
+
+ for (int i=0; i<rectangles.length; i++) {
+ Rectangle rect = rectangles [i];
+ OS.gdk_draw_rectangle(xWindow, gc, 0, rect.x, rect.y, rect.width, rect.height);
+ }
+ OS.gdk_gc_destroy(gc);
+}
+/*
+ * Wait for an event to show up.
+ * Return the event's type as a GdkEventType.
+ */
+private int waitEvent() {
+ int[] eventType = new int[1];
+ int eventPtr;
+
+ while (true) {
+ eventPtr = OS.gdk_event_get();
+ if (eventPtr != 0) {
+ // hack, must implement memmove properly
+ // GdkEvent event = new GdkEvent(eventPtr);
+ OS.memmove(eventType, eventPtr, 4);
+ OS.gdk_event_free(eventPtr);
+ return eventType[0];
+ }
+ else {
+ try { Thread.sleep(50); } catch (Exception ex) {}
+ }
+ }
+}
+
+/*
+ * Figure which GdkWindow we'll draw on.
+ * That's normally the root X window, or the parent's GdkWindow if we have a parent.
+ */
+private int calculateWindow() {
+ int answer;
+ if (parent == null) {
+ answer = OS.GDK_ROOT_PARENT();
+ } else {
+ answer = parent._gdkWindow();
+ }
+ if (answer==0) error(SWT.ERROR_UNSPECIFIED);
+ return answer;
+}
+
+public void setCursor (Cursor value) {
+}
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk1x/org/eclipse/swt/widgets/TreeItem.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk1x/org/eclipse/swt/widgets/TreeItem.java
index aa258edf77..ef23d5cc0d 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk1x/org/eclipse/swt/widgets/TreeItem.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk1x/org/eclipse/swt/widgets/TreeItem.java
@@ -1,109 +1,109 @@
-package org.eclipse.swt.widgets;
-
-/*
+package org.eclipse.swt.widgets;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-import org.eclipse.swt.*;
-import org.eclipse.swt.internal.*;
-import org.eclipse.swt.internal.gtk.*;
-import org.eclipse.swt.graphics.*;
-
-/**
- * Instances of this class represent a selectable user interface object
- * that represents a hierarchy of tree items in a tree widget.
- *
- * <dl>
- * <dt><b>Styles:</b></dt>
- * <dd>(none)</dd>
- * <dt><b>Events:</b></dt>
- * <dd>(none)</dd>
- * </dl>
- * <p>
- * IMPORTANT: This class is <em>not</em> intended to be subclassed.
- * </p>
- */
-public class TreeItem extends Item {
- Tree parent;
- int index;
-
-/**
- * Constructs a new instance of this class given its parent
- * (which must be a <code>Tree</code> or a <code>TreeItem</code>)
- * and a style value describing its behavior and appearance.
- * The item is added to the end of the items maintained by its parent.
- * <p>
- * The style value is either one of the style constants defined in
- * class <code>SWT</code> which is applicable to instances of this
- * class, or must be built by <em>bitwise OR</em>'ing together
- * (that is, using the <code>int</code> "|" operator) two or more
- * of those <code>SWT</code> style constants. The class description
- * 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 TreeItem (Tree parent, int style) {
- super (parent, style);
- this.parent = parent;
- parent.createItem (this, 0, -1);
-}
-
-/**
- * Constructs a new instance of this class given its parent
- * (which must be a <code>Tree</code> or a <code>TreeItem</code>),
- * a style value describing its behavior and appearance, and the index
- * at which to place it in the items maintained by its parent.
- * <p>
- * The style value is either one of the style constants defined in
- * class <code>SWT</code> which is applicable to instances of this
- * class, or must be built by <em>bitwise OR</em>'ing together
- * (that is, using the <code>int</code> "|" operator) two or more
- * of those <code>SWT</code> style constants. The class description
- * 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 TreeItem (Tree parent, int style, int index) {
- super (parent, style);
- if (index < 0) error (SWT.ERROR_INVALID_RANGE);
- this.parent = parent;
- parent.createItem (this, 0, index);
-}
-
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+import org.eclipse.swt.*;
+import org.eclipse.swt.internal.*;
+import org.eclipse.swt.internal.gtk.*;
+import org.eclipse.swt.graphics.*;
+
+/**
+ * Instances of this class represent a selectable user interface object
+ * that represents a hierarchy of tree items in a tree widget.
+ *
+ * <dl>
+ * <dt><b>Styles:</b></dt>
+ * <dd>(none)</dd>
+ * <dt><b>Events:</b></dt>
+ * <dd>(none)</dd>
+ * </dl>
+ * <p>
+ * IMPORTANT: This class is <em>not</em> intended to be subclassed.
+ * </p>
+ */
+public class TreeItem extends Item {
+ Tree parent;
+ int index;
+
+/**
+ * Constructs a new instance of this class given its parent
+ * (which must be a <code>Tree</code> or a <code>TreeItem</code>)
+ * and a style value describing its behavior and appearance.
+ * The item is added to the end of the items maintained by its parent.
+ * <p>
+ * The style value is either one of the style constants defined in
+ * class <code>SWT</code> which is applicable to instances of this
+ * class, or must be built by <em>bitwise OR</em>'ing together
+ * (that is, using the <code>int</code> "|" operator) two or more
+ * of those <code>SWT</code> style constants. The class description
+ * 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 TreeItem (Tree parent, int style) {
+ super (parent, style);
+ this.parent = parent;
+ parent.createItem (this, 0, -1);
+}
+
+/**
+ * Constructs a new instance of this class given its parent
+ * (which must be a <code>Tree</code> or a <code>TreeItem</code>),
+ * a style value describing its behavior and appearance, and the index
+ * at which to place it in the items maintained by its parent.
+ * <p>
+ * The style value is either one of the style constants defined in
+ * class <code>SWT</code> which is applicable to instances of this
+ * class, or must be built by <em>bitwise OR</em>'ing together
+ * (that is, using the <code>int</code> "|" operator) two or more
+ * of those <code>SWT</code> style constants. The class description
+ * 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 TreeItem (Tree parent, int style, int index) {
+ super (parent, style);
+ if (index < 0) error (SWT.ERROR_INVALID_RANGE);
+ this.parent = parent;
+ parent.createItem (this, 0, index);
+}
+
/**
* Constructs a new instance of this class given its parent
* (which must be a <code>Tree</code> or a <code>TreeItem</code>)
@@ -133,13 +133,13 @@ public TreeItem (Tree parent, int style, int index) {
* @see SWT
* @see Widget#checkSubclass
* @see Widget#getStyle
- */
-public TreeItem (TreeItem parentItem, int style) {
- super (checkNull (parentItem).getParent(), style);
- this.parent = parentItem.getParent ();
- parent.createItem (this, parentItem.handle, -1);
-}
-
+ */
+public TreeItem (TreeItem parentItem, int style) {
+ super (checkNull (parentItem).getParent(), style);
+ this.parent = parentItem.getParent ();
+ parent.createItem (this, parentItem.handle, -1);
+}
+
/**
* Constructs a new instance of this class given its parent
* (which must be a <code>Tree</code> or a <code>TreeItem</code>),
@@ -170,38 +170,38 @@ public TreeItem (TreeItem parentItem, int style) {
* @see SWT
* @see Widget#checkSubclass
* @see Widget#getStyle
- */
-public TreeItem (TreeItem parentItem, int style, int index) {
- super (checkNull (parentItem).getParent (), style);
- if (index < 0) error (SWT.ERROR_ITEM_NOT_ADDED);
- this.parent = parentItem.getParent ();
- parent.createItem (this, parentItem.handle, index);
-}
-
-static TreeItem checkNull (TreeItem item) {
- if (item == null) SWT.error (SWT.ERROR_NULL_ARGUMENT);
- return item;
-}
-
-/**
- * Returns the receiver's background color.
- *
- * @return the background color
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @since 2.0
- *
- */
-public Color getBackground () {
- checkWidget ();
- Tree parent = getParent();
- return parent.getBackground();
-}
-
+ */
+public TreeItem (TreeItem parentItem, int style, int index) {
+ super (checkNull (parentItem).getParent (), style);
+ if (index < 0) error (SWT.ERROR_ITEM_NOT_ADDED);
+ this.parent = parentItem.getParent ();
+ parent.createItem (this, parentItem.handle, index);
+}
+
+static TreeItem checkNull (TreeItem item) {
+ if (item == null) SWT.error (SWT.ERROR_NULL_ARGUMENT);
+ return item;
+}
+
+/**
+ * Returns the receiver's background color.
+ *
+ * @return the background color
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @since 2.0
+ *
+ */
+public Color getBackground () {
+ checkWidget ();
+ Tree parent = getParent();
+ return parent.getBackground();
+}
+
/**
* Returns a rectangle describing the receiver's size and location
* relative to its parent.
@@ -213,56 +213,56 @@ public Color getBackground () {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public Rectangle getBounds () {
- int ctree = parent.handle;
- GtkCTree tree = new GtkCTree();
- OS.memmove(tree, ctree, GtkCTree.sizeof);
-
- GtkAdjustment adjustment = new GtkAdjustment ();
- OS.memmove (adjustment, tree.vadjustment, GtkAdjustment.sizeof);
- float vaj = adjustment.value;
- OS.memmove (adjustment, tree.hadjustment, GtkAdjustment.sizeof);
- float haj = adjustment.value;
- int columnHandle = tree.column;
-
- int height=parent.getItemHeight();
-
- int row_list = tree.row_list; int level=0;
- int count = OS.g_list_length (row_list);
- int index=0;
- while (index<count) {
- int data = OS.g_list_nth (row_list, index);
- if (handle == data){
- int rowHandle = OS.g_list_nth_data (row_list, index);
- GtkCTreeRow row = new GtkCTreeRow();
- OS.memmove(row, rowHandle, GtkCTreeRow.sizeof);
- level = row.level;
- break;
- }
- index++;
- }
- int y = height*index + Tree.CELL_SPACING + tree.voffset + 2;
-
- int [] buffer = new int [1]; byte [] spacing = new byte [1];
- boolean [] is_leaf = new boolean [1], expanded = new boolean [1];
- int [] pixmap_closed = new int [1], mask_closed= new int [1], pixmap_opened= new int [1], mask_opened= new int [1];
- OS.gtk_ctree_get_node_info (ctree, handle, buffer, spacing, pixmap_closed, mask_closed, pixmap_opened, mask_opened, is_leaf, expanded);
- int length = OS.strlen (buffer[0]);
- byte [] buffer1 = new byte [length];
- OS.memmove (buffer1, buffer[0], length);
- int styleHandle = OS.gtk_ctree_node_get_row_style(ctree, handle);
- if (styleHandle == 0)
- styleHandle = OS.gtk_widget_get_style(ctree);
- GtkStyle style = new GtkStyle();
- OS.memmove(style, styleHandle, GtkStyle.sizeof);
- int width = OS.gdk_string_width(style.font, buffer1);
-
-// x = (short)column.area_x+tree.tree_indent*(level-1)+spacing[0]+tree.hoffset;
- int x = 33+tree.tree_indent*(level-1)+spacing[0]+tree.hoffset;
-
- return new Rectangle (x, y, width, height);
-}
-
+public Rectangle getBounds () {
+ int ctree = parent.handle;
+ GtkCTree tree = new GtkCTree();
+ OS.memmove(tree, ctree, GtkCTree.sizeof);
+
+ GtkAdjustment adjustment = new GtkAdjustment ();
+ OS.memmove (adjustment, tree.vadjustment, GtkAdjustment.sizeof);
+ float vaj = adjustment.value;
+ OS.memmove (adjustment, tree.hadjustment, GtkAdjustment.sizeof);
+ float haj = adjustment.value;
+ int columnHandle = tree.column;
+
+ int height=parent.getItemHeight();
+
+ int row_list = tree.row_list; int level=0;
+ int count = OS.g_list_length (row_list);
+ int index=0;
+ while (index<count) {
+ int data = OS.g_list_nth (row_list, index);
+ if (handle == data){
+ int rowHandle = OS.g_list_nth_data (row_list, index);
+ GtkCTreeRow row = new GtkCTreeRow();
+ OS.memmove(row, rowHandle, GtkCTreeRow.sizeof);
+ level = row.level;
+ break;
+ }
+ index++;
+ }
+ int y = height*index + Tree.CELL_SPACING + tree.voffset + 2;
+
+ int [] buffer = new int [1]; byte [] spacing = new byte [1];
+ boolean [] is_leaf = new boolean [1], expanded = new boolean [1];
+ int [] pixmap_closed = new int [1], mask_closed= new int [1], pixmap_opened= new int [1], mask_opened= new int [1];
+ OS.gtk_ctree_get_node_info (ctree, handle, buffer, spacing, pixmap_closed, mask_closed, pixmap_opened, mask_opened, is_leaf, expanded);
+ int length = OS.strlen (buffer[0]);
+ byte [] buffer1 = new byte [length];
+ OS.memmove (buffer1, buffer[0], length);
+ int styleHandle = OS.gtk_ctree_node_get_row_style(ctree, handle);
+ if (styleHandle == 0)
+ styleHandle = OS.gtk_widget_get_style(ctree);
+ GtkStyle style = new GtkStyle();
+ OS.memmove(style, styleHandle, GtkStyle.sizeof);
+ int width = OS.gdk_string_width(style.font, buffer1);
+
+// x = (short)column.area_x+tree.tree_indent*(level-1)+spacing[0]+tree.hoffset;
+ int x = 33+tree.tree_indent*(level-1)+spacing[0]+tree.hoffset;
+
+ return new Rectangle (x, y, width, height);
+}
+
/**
* Returns <code>true</code> if the receiver is checked,
* and false otherwise. When the parent does not have
@@ -275,21 +275,21 @@ public Rectangle getBounds () {
* <li>ERROR_WIDGET_DISPOSED - if 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 ctree = parent.handle;
- int [] pixmap = new int [1];
- OS.gtk_ctree_get_node_info (ctree, handle, null, null, pixmap, null, null, null, null, null);
- return pixmap [0] == parent.check;
-}
-
-public Display getDisplay () {
- if (parent == null) error (SWT.ERROR_WIDGET_DISPOSED);
- return parent.getDisplay ();
-}
-
+ */
+public boolean getChecked () {
+ checkWidget();
+ if ((parent.style & SWT.CHECK) == 0) return false;
+ int ctree = parent.handle;
+ int [] pixmap = new int [1];
+ OS.gtk_ctree_get_node_info (ctree, handle, null, null, pixmap, null, null, null, null, null);
+ return pixmap [0] == parent.check;
+}
+
+public Display getDisplay () {
+ if (parent == null) error (SWT.ERROR_WIDGET_DISPOSED);
+ return parent.getDisplay ();
+}
+
/**
* Returns <code>true</code> if the receiver is expanded,
* and false otherwise.
@@ -301,34 +301,34 @@ public Display getDisplay () {
* <li>ERROR_WIDGET_DISPOSED - if 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 ctree = parent.handle;
- boolean [] buffer = new boolean [1];
- OS.gtk_ctree_get_node_info (ctree, handle, null, null, null, null, null, null, null, buffer);
- return buffer [0];
-}
-
-/**
- * Returns the foreground color that the receiver will use to draw.
- *
- * @return the receiver's foreground color
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @since 2.0
- *
- */
-public Color getForeground () {
- checkWidget ();
- Tree parent = getParent();
- return parent.getForeground();
-}
-
+ */
+public boolean getExpanded () {
+ checkWidget();
+ int ctree = parent.handle;
+ boolean [] buffer = new boolean [1];
+ OS.gtk_ctree_get_node_info (ctree, handle, null, null, null, null, null, null, null, buffer);
+ return buffer [0];
+}
+
+/**
+ * Returns the foreground color that the receiver will use to draw.
+ *
+ * @return the receiver's foreground color
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @since 2.0
+ *
+ */
+public Color getForeground () {
+ checkWidget ();
+ Tree parent = getParent();
+ return parent.getForeground();
+}
+
/**
* Returns <code>true</code> if the receiver is grayed,
* and false otherwise. When the parent does not have
@@ -342,11 +342,11 @@ public Color getForeground () {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public boolean getGrayed() {
- checkWidget();
- return false;
-}
-
+public boolean getGrayed() {
+ checkWidget();
+ return false;
+}
+
/**
* Returns the number of items contained in the receiver
* that are direct item children of the receiver.
@@ -357,33 +357,33 @@ public boolean getGrayed() {
* <li>ERROR_WIDGET_DISPOSED - if 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 parent.getItemCount (handle);
-}
-
-/**
- * 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 affect the receiver.
- * </p>
- *
- * @return the receiver's items
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public TreeItem [] getItems () {
- checkWidget();
- return parent.getItems (handle);
-}
-
+ */
+public int getItemCount () {
+ checkWidget();
+ return parent.getItemCount (handle);
+}
+
+/**
+ * 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 affect the receiver.
+ * </p>
+ *
+ * @return the receiver's items
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public TreeItem [] getItems () {
+ checkWidget();
+ return parent.getItems (handle);
+}
+
/**
* Returns the receiver's parent, which must be a <code>Tree</code>.
*
@@ -393,12 +393,12 @@ public TreeItem [] getItems () {
* <li>ERROR_WIDGET_DISPOSED - if 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;
-}
-
+ */
+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
@@ -410,52 +410,52 @@ public Tree getParent () {
* <li>ERROR_WIDGET_DISPOSED - if 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 data = OS.g_list_nth_data (handle, 0);
- GtkCTreeRow row = new GtkCTreeRow ();
- OS.memmove (row, data, GtkCTreeRow.sizeof);
- if (row.parent == 0) return null;
- int ctree = parent.handle;
- int index = OS.gtk_ctree_node_get_row_data (ctree, row.parent) - 1;
- return parent.items [index];
-}
-
-void releaseChild () {
- super.releaseChild ();
- parent.destroyItem (this);
-}
-
-void releaseWidget () {
- super.releaseWidget ();
- parent = null;
-}
-
-/**
- * Sets the receiver's background color to the color specified
- * by the argument, or to the default system color for the item
- * if the argument is null.
- *
- * @param color the new color (or null)
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_INVALID_ARGUMENT - if the argument has been disposed</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @since 2.0
- *
- */
-public void setBackground (Color color) {
- checkWidget ();
- if (color != null && color.isDisposed ())
- SWT.error (SWT.ERROR_INVALID_ARGUMENT);
-}
-
+ */
+public TreeItem getParentItem () {
+ checkWidget();
+ int data = OS.g_list_nth_data (handle, 0);
+ GtkCTreeRow row = new GtkCTreeRow ();
+ OS.memmove (row, data, GtkCTreeRow.sizeof);
+ if (row.parent == 0) return null;
+ int ctree = parent.handle;
+ int index = OS.gtk_ctree_node_get_row_data (ctree, row.parent) - 1;
+ return parent.items [index];
+}
+
+void releaseChild () {
+ super.releaseChild ();
+ parent.destroyItem (this);
+}
+
+void releaseWidget () {
+ super.releaseWidget ();
+ parent = null;
+}
+
+/**
+ * Sets the receiver's background color to the color specified
+ * by the argument, or to the default system color for the item
+ * if the argument is null.
+ *
+ * @param color the new color (or null)
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_INVALID_ARGUMENT - if the argument has been disposed</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @since 2.0
+ *
+ */
+public void setBackground (Color color) {
+ checkWidget ();
+ if (color != null && color.isDisposed ())
+ SWT.error (SWT.ERROR_INVALID_ARGUMENT);
+}
+
/**
* Sets the checked state of the receiver.
* <p>
@@ -466,48 +466,48 @@ public void setBackground (Color color) {
* <li>ERROR_WIDGET_DISPOSED - if the 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 ctree = parent.handle;
- byte [] spacing = new byte [1];
- int [] pixmap = new int [1], mask = new int [1];
- boolean [] is_leaf = new boolean [1], expanded = new boolean [1];
- byte [] buffer = Converter.wcsToMbcs (null, text, true);
- OS.gtk_ctree_get_node_info (ctree, handle, null, spacing, pixmap, mask, pixmap, mask, is_leaf, expanded);
- if (checked && pixmap [0] == parent.check) return;
- if (!checked && pixmap [0] == parent.uncheck) return;
- pixmap [0] = checked ? parent.check : parent.uncheck;
- OS.gtk_ctree_set_node_info (ctree, handle, buffer, spacing [0], pixmap [0], mask [0], pixmap [0], mask [0], is_leaf [0], expanded [0]);
-}
-
-/**
- * Sets the receiver's foreground color to the color specified
- * by the argument, or to the default system color for the item
- * if the argument is null.
- *
- * @param color the new color (or null)
- *
- * @since 2.0
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_INVALID_ARGUMENT - if the argument has been disposed</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @since 2.0
- *
- */
-public void setForeground (Color color) {
- checkWidget ();
- if (color != null && color.isDisposed ())
- SWT.error (SWT.ERROR_INVALID_ARGUMENT);
-}
-
+ */
+public void setChecked (boolean checked) {
+ checkWidget();
+ if ((parent.style & SWT.CHECK) == 0) return;
+ int ctree = parent.handle;
+ byte [] spacing = new byte [1];
+ int [] pixmap = new int [1], mask = new int [1];
+ boolean [] is_leaf = new boolean [1], expanded = new boolean [1];
+ byte [] buffer = Converter.wcsToMbcs (null, text, true);
+ OS.gtk_ctree_get_node_info (ctree, handle, null, spacing, pixmap, mask, pixmap, mask, is_leaf, expanded);
+ if (checked && pixmap [0] == parent.check) return;
+ if (!checked && pixmap [0] == parent.uncheck) return;
+ pixmap [0] = checked ? parent.check : parent.uncheck;
+ OS.gtk_ctree_set_node_info (ctree, handle, buffer, spacing [0], pixmap [0], mask [0], pixmap [0], mask [0], is_leaf [0], expanded [0]);
+}
+
+/**
+ * Sets the receiver's foreground color to the color specified
+ * by the argument, or to the default system color for the item
+ * if the argument is null.
+ *
+ * @param color the new color (or null)
+ *
+ * @since 2.0
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_INVALID_ARGUMENT - if the argument has been disposed</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @since 2.0
+ *
+ */
+public void setForeground (Color color) {
+ checkWidget ();
+ if (color != null && color.isDisposed ())
+ SWT.error (SWT.ERROR_INVALID_ARGUMENT);
+}
+
/**
* Sets the grayed state of the receiver.
* <p>
@@ -519,10 +519,10 @@ public void setForeground (Color color) {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public void setGrayed (boolean grayed) {
- checkWidget();
-}
-
+public void setGrayed (boolean grayed) {
+ checkWidget();
+}
+
/**
* Sets the expanded state of the receiver.
* <p>
@@ -533,54 +533,54 @@ public void setGrayed (boolean grayed) {
* <li>ERROR_WIDGET_DISPOSED - if the 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 ctree = parent.handle;
- if (expanded) {
- OS.gtk_signal_handler_block_by_data (ctree, SWT.Expand);
- OS.gtk_ctree_expand (ctree, handle);
- OS.gtk_signal_handler_unblock_by_data (ctree, SWT.Expand);
- } else {
- OS.gtk_signal_handler_block_by_data (ctree, SWT.Collapse);
- OS.gtk_ctree_collapse (ctree, handle);
- OS.gtk_signal_handler_unblock_by_data (ctree, SWT.Collapse);
- }
-}
-
-public void setImage (Image image) {
- checkWidget();
- if (image != null && image.isDisposed()) error(SWT.ERROR_INVALID_ARGUMENT);
- if ((parent.style & SWT.CHECK) != 0) return;
- this.image = image;
- int pixmap = 0, mask = 0;
- if (image != null) {
- pixmap = image.pixmap;
- mask = image.mask;
- }
- int ctree = parent.handle;
- byte [] spacing = new byte [1];
- boolean [] is_leaf = new boolean [1], expanded = new boolean [1];
- byte [] buffer = Converter.wcsToMbcs (null, text, true);
- OS.gtk_ctree_get_node_info (ctree, handle, null, spacing, null, null, null, null, is_leaf, expanded);
- OS.gtk_ctree_set_node_info (ctree, handle, buffer, spacing [0], pixmap, mask, pixmap, mask, is_leaf [0], expanded [0]);
-}
-
+ */
+public void setExpanded (boolean expanded) {
+ checkWidget();
+ int ctree = parent.handle;
+ if (expanded) {
+ OS.gtk_signal_handler_block_by_data (ctree, SWT.Expand);
+ OS.gtk_ctree_expand (ctree, handle);
+ OS.gtk_signal_handler_unblock_by_data (ctree, SWT.Expand);
+ } else {
+ OS.gtk_signal_handler_block_by_data (ctree, SWT.Collapse);
+ OS.gtk_ctree_collapse (ctree, handle);
+ OS.gtk_signal_handler_unblock_by_data (ctree, SWT.Collapse);
+ }
+}
+
+public void setImage (Image image) {
+ checkWidget();
+ if (image != null && image.isDisposed()) error(SWT.ERROR_INVALID_ARGUMENT);
+ if ((parent.style & SWT.CHECK) != 0) return;
+ this.image = image;
+ int pixmap = 0, mask = 0;
+ if (image != null) {
+ pixmap = image.pixmap;
+ mask = image.mask;
+ }
+ int ctree = parent.handle;
+ byte [] spacing = new byte [1];
+ boolean [] is_leaf = new boolean [1], expanded = new boolean [1];
+ byte [] buffer = Converter.wcsToMbcs (null, text, true);
+ OS.gtk_ctree_get_node_info (ctree, handle, null, spacing, null, null, null, null, is_leaf, expanded);
+ OS.gtk_ctree_set_node_info (ctree, handle, buffer, spacing [0], pixmap, mask, pixmap, mask, is_leaf [0], expanded [0]);
+}
+
/**
* 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 string) {
- checkWidget();
- if (string == null) error (SWT.ERROR_NULL_ARGUMENT);
- super.setText (string);
- int ctree = parent.handle;
- byte [] buffer = Converter.wcsToMbcs (null, string, true);
- byte [] spacing = new byte [1];
- boolean [] is_leaf = new boolean [1], expanded = new boolean [1];
- int [] pixmap_closed = new int [1], mask_closed= new int [1], pixmap_opened= new int [1], mask_opened= new int [1];
- OS.gtk_ctree_get_node_info (ctree, handle, null, spacing, pixmap_closed, mask_closed, pixmap_opened, mask_opened, is_leaf, expanded);
- OS.gtk_ctree_set_node_info (ctree, handle, buffer, spacing [0], pixmap_closed [0], mask_closed [0], pixmap_opened [0], mask_opened [0], is_leaf [0], expanded [0]);
-}
-}
+ */
+public void setText (String string) {
+ checkWidget();
+ if (string == null) error (SWT.ERROR_NULL_ARGUMENT);
+ super.setText (string);
+ int ctree = parent.handle;
+ byte [] buffer = Converter.wcsToMbcs (null, string, true);
+ byte [] spacing = new byte [1];
+ boolean [] is_leaf = new boolean [1], expanded = new boolean [1];
+ int [] pixmap_closed = new int [1], mask_closed= new int [1], pixmap_opened= new int [1], mask_opened= new int [1];
+ OS.gtk_ctree_get_node_info (ctree, handle, null, spacing, pixmap_closed, mask_closed, pixmap_opened, mask_opened, is_leaf, expanded);
+ OS.gtk_ctree_set_node_info (ctree, handle, buffer, spacing [0], pixmap_closed [0], mask_closed [0], pixmap_opened [0], mask_opened [0], is_leaf [0], expanded [0]);
+}
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk1x/org/eclipse/swt/widgets/WidgetTable.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk1x/org/eclipse/swt/widgets/WidgetTable.java
index c8a98801ef..cce97ee237 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk1x/org/eclipse/swt/widgets/WidgetTable.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk1x/org/eclipse/swt/widgets/WidgetTable.java
@@ -1,91 +1,91 @@
-package org.eclipse.swt.widgets;
-
-/*
+package org.eclipse.swt.widgets;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-import org.eclipse.swt.internal.gtk.*;
-
-class WidgetTable {
- static int FreeSlot = 0;
- static int GrowSize = 1024;
- static int [] IndexTable = new int [GrowSize];
- static Widget [] WidgetTable = new Widget [GrowSize];
- 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;
- int index = OS.gtk_object_get_user_data (handle) - 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;
- }
- int index = FreeSlot + 1;
- OS.gtk_object_set_user_data (handle, index);
- int oldSlot = FreeSlot;
- FreeSlot = IndexTable[oldSlot];
- IndexTable [oldSlot] = -2;
- WidgetTable [oldSlot] = widget;
-}
-
-public static synchronized Widget remove (int handle) {
- if (handle == 0) return null;
- Widget widget = null;
- int index = OS.gtk_object_get_user_data (handle) - 1;
- if (0 <= index && index < WidgetTable.length) {
- widget = WidgetTable [index];
- WidgetTable [index] = null;
- IndexTable [index] = FreeSlot;
- FreeSlot = index;
- OS.gtk_object_set_user_data (handle, 0);
- }
- 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;
-}
-
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+import org.eclipse.swt.internal.gtk.*;
+
+class WidgetTable {
+ static int FreeSlot = 0;
+ static int GrowSize = 1024;
+ static int [] IndexTable = new int [GrowSize];
+ static Widget [] WidgetTable = new Widget [GrowSize];
+ 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;
+ int index = OS.gtk_object_get_user_data (handle) - 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;
+ }
+ int index = FreeSlot + 1;
+ OS.gtk_object_set_user_data (handle, index);
+ int oldSlot = FreeSlot;
+ FreeSlot = IndexTable[oldSlot];
+ IndexTable [oldSlot] = -2;
+ WidgetTable [oldSlot] = widget;
+}
+
+public static synchronized Widget remove (int handle) {
+ if (handle == 0) return null;
+ Widget widget = null;
+ int index = OS.gtk_object_get_user_data (handle) - 1;
+ if (0 <= index && index < WidgetTable.length) {
+ widget = WidgetTable [index];
+ WidgetTable [index] = null;
+ IndexTable [index] = FreeSlot;
+ FreeSlot = index;
+ OS.gtk_object_set_user_data (handle, 0);
+ }
+ 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/motif/org/eclipse/swt/graphics/Color.java b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/graphics/Color.java
index bfb0a3d75d..704ff260d2 100755
--- 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
@@ -1,15 +1,15 @@
-package org.eclipse.swt.graphics;
-
-/*
+package org.eclipse.swt.graphics;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-import org.eclipse.swt.internal.motif.*;
-import org.eclipse.swt.*;
-
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+import org.eclipse.swt.internal.motif.*;
+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
@@ -23,20 +23,20 @@ import org.eclipse.swt.*;
*
* @see RGB
*/
-public final class Color {
+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.
+ public XColor handle;
+
+ /**
+ * The device where this image was created.
*/
- Device device;
-
-Color() {
-}
+ Device device;
+
+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
@@ -61,12 +61,12 @@ Color() {
*
* @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);
-}
+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.
@@ -89,35 +89,35 @@ public Color (Device device, int red, int green, int blue) {
*
* @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);
-}
+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() {
+public void dispose() {
if (handle == null) return;
- if (device.isDisposed()) return;
+ if (device.isDisposed()) 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);
- handle = null;
- if (device.tracking) device.dispose_Object(this);
- device = null;
-}
+ 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);
+ handle = 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
@@ -128,15 +128,15 @@ public void dispose() {
*
* @see #hashCode
*/
-public boolean equals (Object object) {
- if (object == this) return true;
- if (!(object instanceof Color)) return false;
- Color color = (Color)object;
- XColor xColor = color.handle;
- if (handle == xColor) return true;
- return device == color.device && handle.red == xColor.red &&
- handle.green == xColor.green && handle.blue == xColor.blue;
-}
+public boolean equals (Object object) {
+ if (object == this) return true;
+ if (!(object instanceof Color)) return false;
+ Color color = (Color)object;
+ XColor xColor = color.handle;
+ if (handle == xColor) return true;
+ return device == color.device && handle.red == xColor.red &&
+ handle.green == xColor.green && handle.blue == xColor.blue;
+}
/**
* Returns the amount of blue in the color, from 0 to 255.
*
@@ -146,10 +146,10 @@ public boolean equals (Object object) {
* <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
* </ul>
*/
-public int getBlue () {
- if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- return (handle.blue >> 8) & 0xFF;
-}
+public int getBlue () {
+ if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ return (handle.blue >> 8) & 0xFF;
+}
/**
* Returns the amount of green in the color, from 0 to 255.
*
@@ -159,10 +159,10 @@ public int getBlue () {
* <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
* </ul>
*/
-public int getGreen () {
- if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- return (handle.green >> 8) & 0xFF;
-}
+public int getGreen () {
+ if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ return (handle.green >> 8) & 0xFF;
+}
/**
* Returns the amount of red in the color, from 0 to 255.
*
@@ -172,10 +172,10 @@ public int getGreen () {
* <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
* </ul>
*/
-public int getRed () {
- if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- return (handle.red >> 8) & 0xFF;
-}
+public int getRed () {
+ if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ return (handle.red >> 8) & 0xFF;
+}
/**
* Returns an <code>RGB</code> representing the receiver.
*
@@ -183,10 +183,10 @@ public int getRed () {
* <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
* </ul>
*/
-public RGB getRGB () {
- if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- return new RGB((handle.red >> 8) & 0xFF, (handle.green >> 8) & 0xFF, (handle.blue >> 8) & 0xFF);
-}
+public RGB getRGB () {
+ if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ return new RGB((handle.red >> 8) & 0xFF, (handle.green >> 8) & 0xFF, (handle.blue >> 8) & 0xFF);
+}
/**
* Returns an integer hash code for the receiver. Any two
* objects which return <code>true</code> when passed to
@@ -197,117 +197,117 @@ public RGB getRGB () {
*
* @see #equals
*/
-public int hashCode () {
- if (isDisposed()) return 0;
- return handle.red ^ handle.green ^ handle.blue;
-}
-void init(Device device, int red, int green, int blue) {
- 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.
+public int hashCode () {
+ if (isDisposed()) return 0;
+ return handle.red ^ handle.green ^ handle.blue;
+}
+void init(Device device, int red, int green, int blue) {
+ 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.
+ 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++) {
+ 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.
+ 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]++;
- }
-}
+ 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]++;
+ }
+}
/**
* Returns <code>true</code> if the color has been disposed,
* and <code>false</code> otherwise.
@@ -318,24 +318,24 @@ void init(Device device, int red, int green, int blue) {
*
* @return <code>true</code> when the color is disposed and <code>false</code> otherwise
*/
-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;
-}
+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;
+}
/**
* Returns a string containing a concise, human-readable
* description of the receiver.
*
* @return a string representation of the receiver
*/
-public String toString () {
- if (isDisposed()) return "Color {*DISPOSED*}";
- return "Color {" + getRed() + ", " + getGreen() + ", " + getBlue() + "}";
-}
-}
+public String toString () {
+ if (isDisposed()) return "Color {*DISPOSED*}";
+ 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
index d08bbf56dc..faf2c8696d 100755
--- 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
@@ -1,15 +1,15 @@
-package org.eclipse.swt.graphics;
-
-/*
+package org.eclipse.swt.graphics;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-import org.eclipse.swt.internal.motif.*;
-import org.eclipse.swt.*;
-
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+import org.eclipse.swt.internal.motif.*;
+import org.eclipse.swt.*;
+
/**
* Instances of this class manage operating system resources that
* specify the appearance of the on-screen pointer. To create a
@@ -34,20 +34,20 @@ import org.eclipse.swt.*;
* Note: Only one of the above styles may be specified.
* </p>
*/
-public final class Cursor {
+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.
+ public int handle;
+
+ /**
+ * The device where this image was created.
*/
- Device device;
-
-Cursor () {
-}
+ Device device;
+
+Cursor () {
+}
/**
* Constructs a new cursor given a device and a style
* constant describing the desired cursor appearance.
@@ -89,40 +89,40 @@ Cursor () {
* @see SWT#CURSOR_NO
* @see SWT#CURSOR_HAND
*/
-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);
- if (device.tracking) device.new_Object(this);
-}
+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);
+ 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
@@ -155,92 +155,92 @@ public Cursor (Device device, int style) {
* <li>ERROR_NO_HANDLES - if a handle could not be obtained for cursor creation</li>
* </ul>
*/
-public Cursor (Device device, ImageData source, ImageData mask, int hotspotX, int hotspotY) {
- 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_INVALID_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);
- 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;
+ if (source == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ if (mask == null) {
+ if (source.getTransparencyType() != SWT.TRANSPARENCY_MASK) {
+ SWT.error(SWT.ERROR_INVALID_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);
+ 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 () {
+public void dispose () {
if (handle == 0) return;
if (device.isDisposed()) return;
- OS.XFreeCursor(device.xDisplay, handle);
- handle = 0;
- if (device.tracking) device.dispose_Object(this);
- device = null;
-}
+ OS.XFreeCursor(device.xDisplay, 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
@@ -251,12 +251,12 @@ public void dispose () {
*
* @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;
-}
+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
@@ -267,9 +267,9 @@ public boolean equals (Object object) {
*
* @see #equals
*/
-public int hashCode () {
- return handle;
-}
+public int hashCode () {
+ return handle;
+}
/**
* Returns <code>true</code> if the cursor has been disposed,
* and <code>false</code> otherwise.
@@ -280,24 +280,24 @@ public int hashCode () {
*
* @return <code>true</code> when the cursor is disposed and <code>false</code> otherwise
*/
-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;
-}
-/**
- * Returns a string containing a concise, human-readable
- * description of the receiver.
- *
- * @return a string representation of the receiver
+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;
+}
+/**
+ * Returns a string containing a concise, human-readable
+ * description of the receiver.
+ *
+ * @return a string representation of the receiver
*/
-public String toString () {
- if (isDisposed()) return "Cursor {*DISPOSED*}";
- return "Cursor {" + handle + "}";
-}
-}
+public String toString () {
+ if (isDisposed()) return "Cursor {*DISPOSED*}";
+ return "Cursor {" + handle + "}";
+}
+}
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
index 091c2cdf36..b8d8bc4d6c 100755
--- 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
@@ -1,100 +1,100 @@
-package org.eclipse.swt.graphics;
-
-/*
+package org.eclipse.swt.graphics;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-import org.eclipse.swt.*;
-import org.eclipse.swt.internal.*;
-import org.eclipse.swt.internal.motif.*;
-
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+import org.eclipse.swt.*;
+import org.eclipse.swt.internal.*;
+import org.eclipse.swt.internal.motif.*;
+
/**
* This class is the abstract superclass of all device objects,
* such as the Display device and the Printer device. Devices
* can have a graphics context (GC) created for them, and they
* can be drawn on by sending messages to the associated GC.
*/
-public abstract class Device implements Drawable {
- /**
- * the handle to the X Display
- * (Warning: This field is platform dependent)
+public abstract class Device implements Drawable {
+ /**
+ * the handle to the X Display
+ * (Warning: This field is platform dependent)
+ */
+ public int xDisplay;
+
+ /**
+ * whether the XLFD resolution should match the
+ * resolution of the device when fonts are created
+ * (Warning: This field is platform dependent)
*/
- public int xDisplay;
-
- /**
- * whether the XLFD resolution should match the
- * resolution of the device when fonts are created
- * (Warning: This field is platform dependent)
- */
- // TEMPORARY CODE
- public boolean setDPI;
-
- /* Debugging */
- public static boolean DEBUG;
- boolean debug = DEBUG;
- boolean tracking = DEBUG;
- Error [] errors;
- Object [] objects;
-
- /* Arguments for XtOpenDisplay */
- String display_name;
- String application_name;
- String application_class;
-
- /* 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;
+ // TEMPORARY CODE
+ public boolean setDPI;
+
+ /* Debugging */
+ public static boolean DEBUG;
+ boolean debug = DEBUG;
+ boolean tracking = DEBUG;
+ Error [] errors;
+ Object [] objects;
+
+ /* Arguments for XtOpenDisplay */
+ String display_name;
+ String application_name;
+ String application_class;
+
+ /* 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;
/* System Font */
- Font systemFont;
-
- /* Warning and Error Handlers */
- boolean warnings = true;
- Callback xErrorCallback, xtWarningCallback, xIOErrorCallback, xtErrorCallback;
- int xErrorProc, xtWarningProc, xIOErrorProc, xtErrorProc;
- int xNullErrorProc, xtNullWarningProc, xNullIOErrorProc, xtNullErrorProc;
-
- /* Parsing Tables */
- int tabMapping, crMapping, tabPointer, crPointer;
-
- /*
- * TEMPORARY CODE. When a graphics object is
- * created and the device parameter is null,
- * the current Display is used. This presents
- * a problem because SWT graphics does not
- * reference classes in SWT widgets. The correct
- * fix is to remove this feature. Unfortunately,
- * too many application programs rely on this
- * feature.
- *
- * This code will be removed in the future.
- */
- protected static Device CurrentDevice;
- protected static Runnable DeviceFinder;
- static {
- try {
- Class.forName ("org.eclipse.swt.widgets.Display");
- } catch (Throwable e) {}
- }
-
-/*
-* TEMPORARY CODE
-*/
-static Device getDevice () {
- if (DeviceFinder != null) DeviceFinder.run();
- Device device = CurrentDevice;
- CurrentDevice = null;
- return device;
-}
-
+ Font systemFont;
+
+ /* Warning and Error Handlers */
+ boolean warnings = true;
+ Callback xErrorCallback, xtWarningCallback, xIOErrorCallback, xtErrorCallback;
+ int xErrorProc, xtWarningProc, xIOErrorProc, xtErrorProc;
+ int xNullErrorProc, xtNullWarningProc, xNullIOErrorProc, xtNullErrorProc;
+
+ /* Parsing Tables */
+ int tabMapping, crMapping, tabPointer, crPointer;
+
+ /*
+ * TEMPORARY CODE. When a graphics object is
+ * created and the device parameter is null,
+ * the current Display is used. This presents
+ * a problem because SWT graphics does not
+ * reference classes in SWT widgets. The correct
+ * fix is to remove this feature. Unfortunately,
+ * too many application programs rely on this
+ * feature.
+ *
+ * This code will be removed in the future.
+ */
+ protected static Device CurrentDevice;
+ protected static Runnable DeviceFinder;
+ static {
+ try {
+ Class.forName ("org.eclipse.swt.widgets.Display");
+ } catch (Throwable e) {}
+ }
+
+/*
+* TEMPORARY CODE
+*/
+static Device getDevice () {
+ if (DeviceFinder != null) DeviceFinder.run();
+ Device device = CurrentDevice;
+ CurrentDevice = null;
+ return device;
+}
+
/**
* Constructs a new instance of this class.
* <p>
@@ -107,35 +107,35 @@ static Device getDevice () {
* @see #init
* @see DeviceData
*/
-public Device(DeviceData data) {
- 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];
- }
- create (data);
- init ();
+public Device(DeviceData data) {
+ 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];
+ }
+ create (data);
+ init ();
- /* Initialize the system font slot */
- systemFont = getSystemFont ();
-}
-
-protected void checkDevice () {
- if (xDisplay == 0) SWT.error (SWT.ERROR_DEVICE_DISPOSED);
-}
-
-protected void create (DeviceData data) {
-}
-
-protected void destroy () {
-}
-
+ /* Initialize the system font slot */
+ systemFont = getSystemFont ();
+}
+
+protected void checkDevice () {
+ if (xDisplay == 0) SWT.error (SWT.ERROR_DEVICE_DISPOSED);
+}
+
+protected void create (DeviceData data) {
+}
+
+protected void destroy () {
+}
+
/**
* Disposes of the operating system resources associated with
* the receiver. After this method has been invoked, the receiver
@@ -146,28 +146,28 @@ protected void destroy () {
* @see #destroy
* @see #checkDevice
*/
-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 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;
+ }
+ }
+}
+
/**
* Returns a rectangle describing the receiver's size and location.
*
@@ -177,14 +177,14 @@ void dispose_Object (Object object) {
* <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
* </ul>
*/
-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 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);
+}
+
/**
* Returns a rectangle which describes the area of the
* receiver which is capable of displaying data.
@@ -197,10 +197,10 @@ public Rectangle getBounds () {
*
* @see #getBounds
*/
-public Rectangle getClientArea () {
- return getBounds ();
-}
-
+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
@@ -213,12 +213,12 @@ public Rectangle getClientArea () {
* <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
* </ul>
*/
-public int getDepth () {
- checkDevice ();
- int xScreenPtr = OS.XDefaultScreenOfDisplay (xDisplay);
- return OS.XDefaultDepthOfScreen (xScreenPtr);
-}
-
+public int getDepth () {
+ checkDevice ();
+ int xScreenPtr = OS.XDefaultScreenOfDisplay (xDisplay);
+ return OS.XDefaultDepthOfScreen (xScreenPtr);
+}
+
/**
* Returns a <code>DeviceData</code> based on the receiver.
* Modifications made to this <code>DeviceData</code> will not
@@ -232,32 +232,32 @@ public int getDepth () {
*
* @see DeviceData
*/
-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 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;
+}
+
/**
* Returns a point whose x coordinate is the horizontal
* dots per inch of the display, and whose y coordinate
@@ -269,21 +269,21 @@ public DeviceData getDeviceData () {
* <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
* </ul>
*/
-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 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);
+}
+
/**
* Returns <code>FontData</code> objects which describe
* the fonts that match the given arguments. If the
@@ -297,49 +297,49 @@ public Point getDPI () {
* <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
* </ul>
*/
-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 + "-*-*-*-*-*-*-*-*-*-*-*-*";
- }
- }
- /* Use the character encoding for the default locale */
- 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);
- /* Use the character encoding for the default locale */
- 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 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 + "-*-*-*-*-*-*-*-*-*-*-*-*";
+ }
+ }
+ /* Use the character encoding for the default locale */
+ 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);
+ /* Use the character encoding for the default locale */
+ 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;
+}
+
/**
* Returns the matching standard color for the given
* constant, which should be one of the color constants
@@ -358,31 +358,31 @@ public FontData [] getFontList (String faceName, boolean scalable) {
*
* @see SWT
*/
-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 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);
+}
+
/**
* Returns a reasonable font for applications to use.
* On some platforms, this will match the "default font"
@@ -403,11 +403,11 @@ public Color getSystemColor (int id) {
* <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
* </ul>
*/
-public Font getSystemFont () {
- checkDevice ();
- return systemFont;
-}
-
+public Font getSystemFont () {
+ checkDevice ();
+ return systemFont;
+}
+
/**
* Returns <code>true</code> if the underlying window system prints out
* warning messages on the console, and <code>setWarnings</code>
@@ -419,93 +419,93 @@ public Font getSystemFont () {
* <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
* </ul>
*/
-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);
-
- /* Create the parsing tables */
- 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,
- };
- 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,
- };
- crMapping = OS.XmParseMappingCreate(argList, argList.length / 2);
- OS.XmStringFree(crString);
-}
-
+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);
+
+ /* Create the parsing tables */
+ 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,
+ };
+ 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,
+ };
+ crMapping = OS.XmParseMappingCreate(argList, argList.length / 2);
+ OS.XmStringFree(crString);
+}
+
/**
* Invokes platform specific functionality to allocate a new GC handle.
* <p>
@@ -521,8 +521,8 @@ protected void init () {
*
* @private
*/
-public abstract int internal_new_GC (GCData data);
-
+public abstract int internal_new_GC (GCData data);
+
/**
* Invokes platform specific functionality to dispose a GC handle.
* <p>
@@ -538,8 +538,8 @@ public abstract int internal_new_GC (GCData data);
*
* @private
*/
-public abstract void internal_dispose_GC (int handle, GCData data);
-
+public abstract void internal_dispose_GC (int handle, GCData data);
+
/**
* Returns <code>true</code> if the device has been disposed,
* and <code>false</code> otherwise.
@@ -550,61 +550,61 @@ public abstract void internal_dispose_GC (int handle, GCData data);
*
* @return <code>true</code> when the device is disposed and <code>false</code> otherwise
*/
-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 parsing tables */
- OS.XtFree(tabPointer);
- OS.XtFree(crPointer);
- OS.XmParseMappingFree(tabMapping);
- OS.XmParseMappingFree(crMapping);
- tabPointer = crPointer = tabMapping = crMapping = 0;
-
- /*
- * 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;
+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 parsing tables */
+ OS.XtFree(tabPointer);
+ OS.XtFree(crPointer);
+ OS.XmParseMappingFree(tabMapping);
+ OS.XmParseMappingFree(crMapping);
+ tabPointer = crPointer = tabMapping = crMapping = 0;
+
+ /*
+ * 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;
/* Free the Xt error handler */
int xtContext = OS.XtDisplayToApplicationContext (xDisplay);
@@ -637,9 +637,9 @@ protected void release () {
OS.XSetErrorHandler (xNullErrorProc);
// OS.XSetErrorHandler (xErrorProc);
// xErrorCallback.dispose (); xErrorCallback = null;
-// xNullErrorProc = xErrorProc = 0;
-}
-
+// xNullErrorProc = xErrorProc = 0;
+}
+
/**
* If the underlying window system supports printing warning messages
* to the console, setting warnings to <code>true</code> prevents these
@@ -652,50 +652,50 @@ protected void release () {
* <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
* </ul>
*/
-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 || (debug && warnings)) {
- new SWTError ().printStackTrace ();
- OS.Call (xErrorProc, xDisplay, xErrorEvent);
- }
- return 0;
-}
-
-int xIOErrorProc (int xDisplay) {
- if (DEBUG || debug) {
- new SWTError ().printStackTrace ();
- OS.Call (xIOErrorProc, xDisplay, 0);
- }
- return 0;
-}
-
-int xtErrorProc (int message) {
- if (DEBUG || debug) {
- new SWTError ().printStackTrace ();
- OS.Call (xtErrorProc, message, 0);
- }
- return 0;
-}
-
-int xtWarningProc (int message) {
- if (DEBUG || (debug && warnings)) {
- new SWTError ().printStackTrace ();
- OS.Call (xtWarningProc, message, 0);
- }
- return 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 || (debug && warnings)) {
+ new SWTError ().printStackTrace ();
+ OS.Call (xErrorProc, xDisplay, xErrorEvent);
+ }
+ return 0;
+}
+
+int xIOErrorProc (int xDisplay) {
+ if (DEBUG || debug) {
+ new SWTError ().printStackTrace ();
+ OS.Call (xIOErrorProc, xDisplay, 0);
+ }
+ return 0;
+}
+
+int xtErrorProc (int message) {
+ if (DEBUG || debug) {
+ new SWTError ().printStackTrace ();
+ OS.Call (xtErrorProc, message, 0);
+ }
+ return 0;
+}
+
+int xtWarningProc (int message) {
+ if (DEBUG || (debug && warnings)) {
+ new SWTError ().printStackTrace ();
+ OS.Call (xtWarningProc, message, 0);
+ }
+ return 0;
+}
+
}
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
index ed4d6ba458..aad8e1fe72 100755
--- 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
@@ -1,26 +1,26 @@
-package org.eclipse.swt.graphics;
-
-/*
+package org.eclipse.swt.graphics;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-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;
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+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;
}
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
index 837fbe51d9..dcaab66578 100755
--- 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
@@ -1,16 +1,16 @@
-package org.eclipse.swt.graphics;
-
-/*
+package org.eclipse.swt.graphics;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-import org.eclipse.swt.internal.*;
-import org.eclipse.swt.internal.motif.*;
-import org.eclipse.swt.*;
-
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+import org.eclipse.swt.internal.*;
+import org.eclipse.swt.internal.motif.*;
+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
@@ -24,29 +24,29 @@ import org.eclipse.swt.*;
*
* @see FontData
*/
-public final class Font {
+public final class Font {
/**
* the handle to the OS font resource
* (Warning: This field is platform dependent)
*/
- public int handle;
-
- /**
- * the code page of the font
- * (Warning: This field is platform dependent)
- *
- * @since 2.0
+ public int handle;
+
+ /**
+ * the code page of the font
+ * (Warning: This field is platform dependent)
+ *
+ * @since 2.0
*/
- public String codePage;
-
- /**
- * The device where this image was created.
+ public String codePage;
+
+ /**
+ * The device where this image was created.
*/
- Device device;
-
-Font () {
-}
-
+ Device device;
+
+Font () {
+}
+
/**
* Constructs a new font given a device and font data
* which describes the desired font's appearance.
@@ -65,46 +65,46 @@ Font () {
* <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);
- if (fd == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
- init(device, new FontData[] {fd});
- if (device.tracking) device.new_Object(this);
-}
-
-/**
- * Constructs a new font given a device and font datas
- * which describes the desired font's appearance.
- * <p>
- * You must dispose the font when it is no longer required.
- * </p>
- *
- * @param device the device to create the font on
- * @param fds the array of FontData that describes the desired font (must not be null)
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if device is null and there is no current device</li>
- * <li>ERROR_NULL_ARGUMENT - if the fds argument is null</li>
- * <li>ERROR_INVALID_ARGUMENT - if the length of fds is zero</li>
- * <li>ERROR_NULL_ARGUMENT - if any fd in the array is null</li>
- * </ul>
- * @exception SWTError <ul>
- * <li>ERROR_NO_HANDLES - if a font could not be created from the given font data</li>
- * </ul>
- */
-public Font (Device device, FontData[] fds) {
- if (device == null) device = Device.getDevice();
- if (device == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
- if (fds == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
- if (fds.length == 0) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
- for (int i=0; i<fds.length; i++) {
- if (fds[i] == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
- }
- init(device, fds);
- if (device.tracking) device.new_Object(this);
-}
-
+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, new FontData[] {fd});
+ if (device.tracking) device.new_Object(this);
+}
+
+/**
+ * Constructs a new font given a device and font datas
+ * which describes the desired font's appearance.
+ * <p>
+ * You must dispose the font when it is no longer required.
+ * </p>
+ *
+ * @param device the device to create the font on
+ * @param fds the array of FontData that describes the desired font (must not be null)
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if device is null and there is no current device</li>
+ * <li>ERROR_NULL_ARGUMENT - if the fds argument is null</li>
+ * <li>ERROR_INVALID_ARGUMENT - if the length of fds is zero</li>
+ * <li>ERROR_NULL_ARGUMENT - if any fd in the array is null</li>
+ * </ul>
+ * @exception SWTError <ul>
+ * <li>ERROR_NO_HANDLES - if a font could not be created from the given font data</li>
+ * </ul>
+ */
+public Font (Device device, FontData[] fds) {
+ if (device == null) device = Device.getDevice();
+ if (device == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ if (fds == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ if (fds.length == 0) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+ for (int i=0; i<fds.length; i++) {
+ if (fds[i] == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ }
+ init(device, fds);
+ 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
@@ -127,29 +127,29 @@ public Font (Device device, FontData[] fds) {
* <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[]{new FontData(name, height, style)});
- 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, new FontData[]{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 () {
+public void dispose () {
if (handle == 0) return;
- if (device.isDisposed()) return;
+ if (device.isDisposed()) return;
if (handle == device.systemFont.handle) return;
- OS.XmFontListFree (handle);
- handle = 0;
+ OS.XmFontListFree (handle);
+ handle = 0;
if (device.tracking) device.dispose_Object(this);
- device = null;
-}
-
+ device = null;
+}
+
/**
* Compares the argument to the receiver, and returns true
* if they represent the <em>same</em> object using a class
@@ -160,87 +160,87 @@ public void dispose () {
*
* @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 the code page for the specified font list.
- *
- * @return the code page for the font list
- */
-static String getCodePage (int xDisplay, int fontList) {
- int[] buffer = new int[1];
- if (!OS.XmFontListInitFontContext(buffer, fontList)) return null;
- int context = buffer[0];
- XFontStruct fontStruct = new XFontStruct();
- int fontListEntry;
- String codePage = null;
- /* Go through each entry in the font list */
- while ((fontListEntry = OS.XmFontListNextEntry(context)) != 0) {
- int fontPtr = OS.XmFontListEntryGetFont(fontListEntry, buffer);
- if (buffer[0] == OS.XmFONT_IS_FONT) {
- /* 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 */
- int ptr = OS.XmGetAtomName(xDisplay, prop[1]);
- int length = OS.strlen(ptr);
- byte[] nameBuf = new byte[length];
- OS.memmove(nameBuf, ptr, length);
- /* Use the character encoding for the default locale */
- String xlfd = new String(Converter.mbcsToWcs(null, nameBuf)).toLowerCase();
- int start = xlfd.lastIndexOf ('-');
- if (start != -1 && start > 0) {
- start = xlfd.lastIndexOf ('-', start - 1);
- if (start != -1) {
- codePage = xlfd.substring (start + 1, xlfd.length ());
- if (codePage.indexOf ("iso") == 0) {
- if (OS.IsLinux) {
- codePage = "ISO-" + codePage.substring (3, codePage.length ());
- }
- }
- }
- }
- OS.XtFree(ptr);
- break;
- }
- propPtr += 8;
- }
- }
- else {
- /* FontList contains a fontSet */
-
- /* Get the font set locale */
- int localePtr = OS.XLocaleOfFontSet(fontPtr);
- int length = OS.strlen (localePtr);
- byte [] locale = new byte [length + 1];
- OS.memmove (locale, localePtr, length);
-
- /* Get code page for the font set locale */
- OS.setlocale (OS.LC_CTYPE, locale);
- int codesetPtr = OS.nl_langinfo (OS.CODESET);
- length = OS.strlen (codesetPtr);
- byte [] codeset = new byte [length];
- OS.memmove (codeset, codesetPtr, length);
- codePage = new String(Converter.mbcsToWcs(null, codeset));
-
- /* Reset the locale */
- OS.setlocale (OS.LC_CTYPE, new byte[1]);
- }
- }
- OS.XmFontListFreeFontContext(context);
- return codePage;
-}
-
+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 the code page for the specified font list.
+ *
+ * @return the code page for the font list
+ */
+static String getCodePage (int xDisplay, int fontList) {
+ int[] buffer = new int[1];
+ if (!OS.XmFontListInitFontContext(buffer, fontList)) return null;
+ int context = buffer[0];
+ XFontStruct fontStruct = new XFontStruct();
+ int fontListEntry;
+ String codePage = null;
+ /* Go through each entry in the font list */
+ while ((fontListEntry = OS.XmFontListNextEntry(context)) != 0) {
+ int fontPtr = OS.XmFontListEntryGetFont(fontListEntry, buffer);
+ if (buffer[0] == OS.XmFONT_IS_FONT) {
+ /* 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 */
+ int ptr = OS.XmGetAtomName(xDisplay, prop[1]);
+ int length = OS.strlen(ptr);
+ byte[] nameBuf = new byte[length];
+ OS.memmove(nameBuf, ptr, length);
+ /* Use the character encoding for the default locale */
+ String xlfd = new String(Converter.mbcsToWcs(null, nameBuf)).toLowerCase();
+ int start = xlfd.lastIndexOf ('-');
+ if (start != -1 && start > 0) {
+ start = xlfd.lastIndexOf ('-', start - 1);
+ if (start != -1) {
+ codePage = xlfd.substring (start + 1, xlfd.length ());
+ if (codePage.indexOf ("iso") == 0) {
+ if (OS.IsLinux) {
+ codePage = "ISO-" + codePage.substring (3, codePage.length ());
+ }
+ }
+ }
+ }
+ OS.XtFree(ptr);
+ break;
+ }
+ propPtr += 8;
+ }
+ }
+ else {
+ /* FontList contains a fontSet */
+
+ /* Get the font set locale */
+ int localePtr = OS.XLocaleOfFontSet(fontPtr);
+ int length = OS.strlen (localePtr);
+ byte [] locale = new byte [length + 1];
+ OS.memmove (locale, localePtr, length);
+
+ /* Get code page for the font set locale */
+ OS.setlocale (OS.LC_CTYPE, locale);
+ int codesetPtr = OS.nl_langinfo (OS.CODESET);
+ length = OS.strlen (codesetPtr);
+ byte [] codeset = new byte [length];
+ OS.memmove (codeset, codesetPtr, length);
+ codePage = new String(Converter.mbcsToWcs(null, codeset));
+
+ /* Reset the locale */
+ OS.setlocale (OS.LC_CTYPE, new byte[1]);
+ }
+ }
+ OS.XmFontListFreeFontContext(context);
+ return codePage;
+}
+
/**
* Returns an array of <code>FontData</code>s representing the receiver.
* On Windows, only one FontData will be returned per font. On X however,
@@ -253,102 +253,102 @@ static String getCodePage (int xDisplay, int fontList) {
* <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
* </ul>
*/
-public FontData[] getFontData() {
- if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- 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.
+public FontData[] getFontData() {
+ if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ 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] == OS.XmFONT_IS_FONT) {
- /* 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 */
- int ptr = OS.XmGetAtomName(xDisplay, prop[1]);
- int length = OS.strlen(ptr);
- byte[] nameBuf = new byte[length];
- OS.memmove(nameBuf, ptr, length);
- /* Use the character encoding for the default locale */
- 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 */
- 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.
+ 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] == OS.XmFONT_IS_FONT) {
+ /* 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 */
+ int ptr = OS.XmGetAtomName(xDisplay, prop[1]);
+ int length = OS.strlen(ptr);
+ byte[] nameBuf = new byte[length];
+ OS.memmove(nameBuf, ptr, length);
+ /* Use the character encoding for the default locale */
+ 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 */
+ 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;
-}
-
+ return null;
+ }
+ return fontData;
+}
+
/**
* Returns an integer hash code for the receiver. Any two
* objects which return <code>true</code> when passed to
@@ -359,93 +359,93 @@ public FontData[] getFontData() {
*
* @see #equals
*/
-public int hashCode () {
- return handle;
-}
-
-void init (Device device, FontData[] fds) {
- this.device = device;
-
- /* Change current locale if needed. Note: only the first font data is used */
- FontData firstFd = fds[0];
- if (firstFd.lang != null) {
- String lang = firstFd.lang;
- String country = firstFd.country;
- String variant = firstFd.variant;
- String osLocale = lang;
- if (country != null) osLocale += "_" + country;
- if (variant != null) osLocale += "." + variant;
- int length = osLocale.length();
- byte [] buffer = new byte[length + 1];
- for (int i=0; i<length; i++) {
- buffer[i] = (byte)osLocale.charAt(i);
- }
- OS.setlocale (OS.LC_CTYPE, buffer);
- }
-
- /* Generate desire font name */
- Point dpi = null;
- if (device.setDPI) dpi = device.getDPI();
- StringBuffer stringBuffer = new StringBuffer();
- for (int i = 0; i < fds.length; i++) {
- FontData fd = fds[i];
- int hRes = fd.horizontalResolution, vRes = fd.verticalResolution;
- if (dpi != null) {
- fd.horizontalResolution = dpi.x;
- fd.verticalResolution = dpi.y;
- }
- stringBuffer.append(fd.getXlfd());
- stringBuffer.append(',');
- fd.horizontalResolution = hRes;
- fd.verticalResolution = vRes;
- }
-
- /* Append simplified font name */
- FontData newFd = new FontData();
- newFd.points = firstFd.points;
- /*
- * Bug in Motif. In Japanese AIX only, in some cases loading a bold Japanese
- * font takes a very long time (10 minutes) when there are no Japanese bold
- * fonts available. The fix is to wildcard the field weight.
- */
- if (OS.IsAIX && OS.IsDBLocale) {
- stringBuffer.append(newFd.getXlfd());
- } else {
- newFd.weight = firstFd.weight;
- newFd.slant = firstFd.slant;
- stringBuffer.append(newFd.getXlfd());
- newFd.weight = null;
- newFd.slant = null;
- stringBuffer.append(',');
- stringBuffer.append(newFd.getXlfd());
- }
-
- /* Load font list entry */
- boolean warnings = device.getWarnings ();
- device.setWarnings (false);
- byte[] buffer = Converter.wcsToMbcs(null, stringBuffer.toString() , true);
- int fontListEntry = OS.XmFontListEntryLoad(device.xDisplay, buffer, OS.XmFONT_IS_FONTSET, OS.XmFONTLIST_DEFAULT_TAG);
- device.setWarnings (warnings);
- if (fontListEntry != 0) {
- handle = OS.XmFontListAppendEntry(0, fontListEntry);
- OS.XmFontListEntryFree(new int[]{fontListEntry});
- int codesetPtr = OS.nl_langinfo(OS.CODESET);
- int length = OS.strlen(codesetPtr);
- byte[] codeset = new byte[length];
- OS.memmove(codeset, codesetPtr, length);
- codePage = new String(Converter.mbcsToWcs(null, codeset));
- } else {
- Font systemFont = device.systemFont;
- handle = systemFont.handle;
- codePage = systemFont.codePage;
- }
-
- /* Reset current locale if needed */
- if (firstFd.lang != null) OS.setlocale(OS.LC_CTYPE, new byte[0]);
-
- if (handle == 0) SWT.error(SWT.ERROR_NO_HANDLES);
-}
-
+public int hashCode () {
+ return handle;
+}
+
+void init (Device device, FontData[] fds) {
+ this.device = device;
+
+ /* Change current locale if needed. Note: only the first font data is used */
+ FontData firstFd = fds[0];
+ if (firstFd.lang != null) {
+ String lang = firstFd.lang;
+ String country = firstFd.country;
+ String variant = firstFd.variant;
+ String osLocale = lang;
+ if (country != null) osLocale += "_" + country;
+ if (variant != null) osLocale += "." + variant;
+ int length = osLocale.length();
+ byte [] buffer = new byte[length + 1];
+ for (int i=0; i<length; i++) {
+ buffer[i] = (byte)osLocale.charAt(i);
+ }
+ OS.setlocale (OS.LC_CTYPE, buffer);
+ }
+
+ /* Generate desire font name */
+ Point dpi = null;
+ if (device.setDPI) dpi = device.getDPI();
+ StringBuffer stringBuffer = new StringBuffer();
+ for (int i = 0; i < fds.length; i++) {
+ FontData fd = fds[i];
+ int hRes = fd.horizontalResolution, vRes = fd.verticalResolution;
+ if (dpi != null) {
+ fd.horizontalResolution = dpi.x;
+ fd.verticalResolution = dpi.y;
+ }
+ stringBuffer.append(fd.getXlfd());
+ stringBuffer.append(',');
+ fd.horizontalResolution = hRes;
+ fd.verticalResolution = vRes;
+ }
+
+ /* Append simplified font name */
+ FontData newFd = new FontData();
+ newFd.points = firstFd.points;
+ /*
+ * Bug in Motif. In Japanese AIX only, in some cases loading a bold Japanese
+ * font takes a very long time (10 minutes) when there are no Japanese bold
+ * fonts available. The fix is to wildcard the field weight.
+ */
+ if (OS.IsAIX && OS.IsDBLocale) {
+ stringBuffer.append(newFd.getXlfd());
+ } else {
+ newFd.weight = firstFd.weight;
+ newFd.slant = firstFd.slant;
+ stringBuffer.append(newFd.getXlfd());
+ newFd.weight = null;
+ newFd.slant = null;
+ stringBuffer.append(',');
+ stringBuffer.append(newFd.getXlfd());
+ }
+
+ /* Load font list entry */
+ boolean warnings = device.getWarnings ();
+ device.setWarnings (false);
+ byte[] buffer = Converter.wcsToMbcs(null, stringBuffer.toString() , true);
+ int fontListEntry = OS.XmFontListEntryLoad(device.xDisplay, buffer, OS.XmFONT_IS_FONTSET, OS.XmFONTLIST_DEFAULT_TAG);
+ device.setWarnings (warnings);
+ if (fontListEntry != 0) {
+ handle = OS.XmFontListAppendEntry(0, fontListEntry);
+ OS.XmFontListEntryFree(new int[]{fontListEntry});
+ int codesetPtr = OS.nl_langinfo(OS.CODESET);
+ int length = OS.strlen(codesetPtr);
+ byte[] codeset = new byte[length];
+ OS.memmove(codeset, codesetPtr, length);
+ codePage = new String(Converter.mbcsToWcs(null, codeset));
+ } else {
+ Font systemFont = device.systemFont;
+ handle = systemFont.handle;
+ codePage = systemFont.codePage;
+ }
+
+ /* Reset current locale if needed */
+ if (firstFd.lang != null) OS.setlocale(OS.LC_CTYPE, new byte[0]);
+
+ if (handle == 0) SWT.error(SWT.ERROR_NO_HANDLES);
+}
+
/**
* Returns <code>true</code> if the font has been disposed,
* and <code>false</code> otherwise.
@@ -456,27 +456,27 @@ void init (Device device, FontData[] fds) {
*
* @return <code>true</code> when the font is disposed and <code>false</code> otherwise
*/
-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;
- font.codePage = getCodePage(device.xDisplay, handle);
- return font;
-}
-
-/**
- * Returns a string containing a concise, human-readable
- * description of the receiver.
- *
- * @return a string representation of the receiver
+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;
+ font.codePage = getCodePage(device.xDisplay, handle);
+ return font;
+}
+
+/**
+ * Returns a string containing a concise, human-readable
+ * description of the receiver.
+ *
+ * @return a string representation of the receiver
*/
-public String toString () {
- if (isDisposed()) return "Font {*DISPOSED*}";
- return "Font {" + handle + "}";
-}
-}
+public String toString () {
+ if (isDisposed()) return "Font {*DISPOSED*}";
+ return "Font {" + handle + "}";
+}
+}
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
index d6dfc76f5e..32fd6df6c9 100755
--- 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
@@ -1,14 +1,14 @@
-package org.eclipse.swt.graphics;
-
-/*
+package org.eclipse.swt.graphics;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-import org.eclipse.swt.*;
-
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+import org.eclipse.swt.*;
+
/**
* Instances of this class describe operating system fonts.
* Only the public API of this type is platform independent.
@@ -34,88 +34,88 @@ import org.eclipse.swt.*;
*
* @see Font
*/
-public final class FontData {
- /**
- * The company that produced the font
- * Warning: This field is platform dependent.
+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 foundry;
+ /**
+ * The common name of the font
+ * Warning: This field is platform dependent.
*/
- public String fontFamily;
- /**
- * The weight ("medium", "bold")
- * Warning: This field is platform dependent.
+ public String fontFamily;
+ /**
+ * The weight ("medium", "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 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 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 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 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 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 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 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 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 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 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 characterSetRegistry;
+ /**
+ * The ISO character set name
+ * Warning: This field is platform dependent.
*/
- public String characterSetName;
-
- /**
- * The locales of the font
- * (Warning: These fields are platform dependent)
+ public String characterSetName;
+
+ /**
+ * The locales of the font
+ * (Warning: These fields are platform dependent)
*/
- String lang, country, variant;
+ String lang, country, variant;
/**
* Constructs a new un-initialized font data.
*/
-public FontData () {
-}
+public FontData () {
+}
/**
* Constructs a new FontData given a string representation
* in the form generated by the <code>FontData.toString</code>
@@ -135,80 +135,80 @@ public FontData () {
*
* @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_NULL_ARGUMENT);
- String version1 = string.substring(start, end);
- try {
- if (Integer.parseInt(version1) != 1) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
- } catch (NumberFormatException e) {
- SWT.error(SWT.ERROR_INVALID_ARGUMENT);
- }
-
- start = end + 1;
- end = string.indexOf('|', start);
- if (end == -1) SWT.error(SWT.ERROR_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 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);
+ try {
+ if (Integer.parseInt(version1) != 1) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+ } catch (NumberFormatException e) {
+ SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+ }
+
+ start = end + 1;
+ end = string.indexOf('|', start);
+ if (end == -1) SWT.error(SWT.ERROR_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);
+}
/**
* Constructs a new font data given a font name,
* the height of the desired font in points,
@@ -223,20 +223,20 @@ public FontData(String string) {
* <li>ERROR_INVALID_ARGUMENT - if the height is negative</li>
* </ul>
*/
-public FontData (String name, int height, int style) {
- if (name == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
- if (height < 0) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
- int dash = name.indexOf('-');
- if (dash != -1) {
- foundry = name.substring(0, dash);
- fontFamily = name.substring(dash + 1);
- } else {
- fontFamily = name;
- }
- points = height * 10;
- weight = (style & SWT.BOLD) != 0 ? "bold" : "medium";
- slant = (style & SWT.ITALIC) != 0 ? "i" : "r";
-}
+public FontData (String name, int height, int style) {
+ if (name == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ if (height < 0) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+ int dash = name.indexOf('-');
+ if (dash != -1) {
+ foundry = name.substring(0, dash);
+ fontFamily = name.substring(dash + 1);
+ } else {
+ fontFamily = name;
+ }
+ points = height * 10;
+ weight = (style & SWT.BOLD) != 0 ? "bold" : "medium";
+ slant = (style & SWT.ITALIC) != 0 ? "i" : "r";
+}
/**
* Compares the argument to the receiver, and returns true
* if they represent the <em>same</em> object using a class
@@ -247,10 +247,10 @@ public FontData (String name, int height, int style) {
*
* @see #hashCode
*/
-public boolean equals (Object object) {
- return (object == this) || ((object instanceof FontData) &&
- getXlfd().equals(((FontData)object).getXlfd()));
-}
+public boolean equals (Object object) {
+ return (object == this) || ((object instanceof FontData) &&
+ getXlfd().equals(((FontData)object).getXlfd()));
+}
/**
* Returns the height of the receiver in points.
*
@@ -258,9 +258,9 @@ public boolean equals (Object object) {
*
* @see #setHeight
*/
-public int getHeight() {
- return points / 10;
-}
+public int getHeight() {
+ return points / 10;
+}
/**
* Returns the name of the receiver.
* On platforms that support font foundries, the return value will
@@ -270,15 +270,15 @@ public int getHeight() {
*
* @see #setName
*/
-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 String getName() {
+ StringBuffer buffer = new StringBuffer();
+ if (foundry != null) {
+ buffer.append(foundry);
+ buffer.append("-");
+ }
+ if (fontFamily != null) buffer.append(fontFamily);
+ return buffer.toString();
+}
/**
* Returns the style of the receiver which is a bitwise OR of
* one or more of the <code>SWT</code> constants NORMAL, BOLD
@@ -288,34 +288,34 @@ public String getName() {
*
* @see #setStyle
*/
-public int getStyle() {
- int style = 0;
- if (weight != null && weight.equals("bold")) style |= SWT.BOLD;
- if (slant != null && 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 getStyle() {
+ int style = 0;
+ if (weight != null && weight.equals("bold")) style |= SWT.BOLD;
+ if (slant != null && 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;
+}
/**
* Returns an integer hash code for the receiver. Any two
* objects which return <code>true</code> when passed to
@@ -326,14 +326,14 @@ String getXlfd() {
*
* @see #equals
*/
-public int hashCode () {
- return getXlfd().hashCode();
-}
-public static FontData motif_new(String xlfd) {
- FontData fontData = new FontData();
- fontData.setXlfd(xlfd);
- return fontData;
-}
+public int hashCode () {
+ return getXlfd().hashCode();
+}
+public static FontData motif_new(String xlfd) {
+ FontData fontData = new FontData();
+ fontData.setXlfd(xlfd);
+ return fontData;
+}
/**
* Sets the height of the receiver. The parameter is
* specified in terms of points, where a point is one
@@ -347,10 +347,10 @@ public static FontData motif_new(String xlfd) {
*
* @see #getHeight
*/
-public void setHeight(int height) {
- if (height < 0) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
- points = height * 10;
-}
+public void setHeight(int height) {
+ if (height < 0) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+ points = height * 10;
+}
/**
* Sets the name of the receiver.
* <p>
@@ -376,52 +376,52 @@ public void setHeight(int height) {
*
* @see #getName
*/
-public void setName(String name) {
- if (name == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
- int dash = name.indexOf('-');
- if (dash != -1) {
- foundry = name.substring(0, dash);
- fontFamily = name.substring(dash + 1);
- } else {
- fontFamily = name;
- }
-}
-/**
- * Sets the locale of the receiver.
- * <p>
- * The locale determines which platform character set this
- * font is going to use. Widgets and graphics operations that
- * use this font will convert UNICODE strings to the platform
- * character set of the specified locale.
- * </p>
- * <p>
- * On platforms which there are multiple character sets for a
- * given language/country locale, the variant portion of the
- * locale will determine the character set.
- * </p>
- *
- * @param locale the <code>String</code> representing a Locale object
- * @see java.util.Locale#toString
+public void setName(String name) {
+ if (name == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ int dash = name.indexOf('-');
+ if (dash != -1) {
+ foundry = name.substring(0, dash);
+ fontFamily = name.substring(dash + 1);
+ } else {
+ fontFamily = name;
+ }
+}
+/**
+ * Sets the locale of the receiver.
+ * <p>
+ * The locale determines which platform character set this
+ * font is going to use. Widgets and graphics operations that
+ * use this font will convert UNICODE strings to the platform
+ * character set of the specified locale.
+ * </p>
+ * <p>
+ * On platforms which there are multiple character sets for a
+ * given language/country locale, the variant portion of the
+ * locale will determine the character set.
+ * </p>
+ *
+ * @param locale the <code>String</code> representing a Locale object
+ * @see java.util.Locale#toString
*/
-public void setLocale(String locale) {
- lang = country = variant = null;
- if (locale != null) {
- char sep = '_';
- int length = locale.length();
- int firstSep, secondSep;
-
- firstSep = locale.indexOf(sep);
- if (firstSep == -1) {
- firstSep = secondSep = length;
- } else {
- secondSep = locale.indexOf(sep, firstSep + 1);
- if (secondSep == -1) secondSep = length;
- }
- if (firstSep > 0) lang = locale.substring(0, firstSep);
- if (secondSep > firstSep + 1) country = locale.substring(firstSep + 1, secondSep);
- if (length > secondSep + 1) variant = locale.substring(secondSep + 1);
- }
-}
+public void setLocale(String locale) {
+ lang = country = variant = null;
+ if (locale != null) {
+ char sep = '_';
+ int length = locale.length();
+ int firstSep, secondSep;
+
+ firstSep = locale.indexOf(sep);
+ if (firstSep == -1) {
+ firstSep = secondSep = length;
+ } else {
+ secondSep = locale.indexOf(sep, firstSep + 1);
+ if (secondSep == -1) secondSep = length;
+ }
+ if (firstSep > 0) lang = locale.substring(0, firstSep);
+ if (secondSep > firstSep + 1) country = locale.substring(firstSep + 1, secondSep);
+ if (length > secondSep + 1) variant = locale.substring(secondSep + 1);
+ }
+}
/**
* Sets the style of the receiver to the argument which must
* be a bitwise OR of one or more of the <code>SWT</code>
@@ -431,74 +431,74 @@ public void setLocale(String locale) {
*
* @see #getStyle
*/
-public void setStyle(int style) {
- weight = (style & SWT.BOLD) != 0 ? "bold" : "medium";
- slant = (style & SWT.ITALIC) != 0 ? "i" : "r";
- averageWidth = 0;
-}
-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 void setStyle(int style) {
+ weight = (style & SWT.BOLD) != 0 ? "bold" : "medium";
+ slant = (style & SWT.ITALIC) != 0 ? "i" : "r";
+ averageWidth = 0;
+}
+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;
+}
/**
* Returns a string representation of the receiver which is suitable
* for constructing an equivalent instance using the
@@ -508,8 +508,8 @@ void setXlfd(String xlfd) {
*
* @see FontData
*/
-public String toString() {
- return "1|" + fontFamily + "|" + getHeight() + "|" + getStyle() + "|" +
- "MOTIF|1|" + getXlfd();
-}
-}
+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
index 8deaa41af6..2a04827982 100755
--- 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
@@ -1,25 +1,25 @@
-package org.eclipse.swt.graphics;
-
-/*
+package org.eclipse.swt.graphics;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-/**
- * 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
+ * http://www.eclipse.org/legal/cpl-v10.html
*/
-public final class FontMetrics {
- int ascent, descent, averageCharWidth, leading, height;
-FontMetrics() {
-}
+
+/**
+ * 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 {
+ int ascent, descent, averageCharWidth, leading, height;
+FontMetrics() {
+}
/**
* Compares the argument to the receiver, and returns true
* if they represent the <em>same</em> object using a class
@@ -30,14 +30,14 @@ FontMetrics() {
*
* @see #hashCode
*/
-public boolean equals (Object object) {
- if (object == this) return true;
- if (!(object instanceof FontMetrics)) return false;
- FontMetrics metrics = (FontMetrics)object;
- return ascent == metrics.ascent && descent == metrics.descent &&
- averageCharWidth == metrics.averageCharWidth && leading == metrics.leading &&
- height == metrics.height;
-}
+public boolean equals (Object object) {
+ if (object == this) return true;
+ if (!(object instanceof FontMetrics)) return false;
+ FontMetrics metrics = (FontMetrics)object;
+ return ascent == metrics.ascent && descent == metrics.descent &&
+ averageCharWidth == metrics.averageCharWidth && leading == metrics.leading &&
+ height == metrics.height;
+}
/**
* Returns the ascent of the font described by the receiver. A
* font's <em>ascent</em> is the distance from the baseline to the
@@ -46,18 +46,18 @@ public boolean equals (Object object) {
*
* @return the ascent of the font
*/
-public int getAscent() {
- return ascent;
-}
+public int getAscent() {
+ return ascent;
+}
/**
* Returns the average character width, measured in pixels,
* of the font described by the receiver.
*
* @return the average character width of the font
*/
-public int getAverageCharWidth() {
- return averageCharWidth;
-}
+public int getAverageCharWidth() {
+ return averageCharWidth;
+}
/**
* Returns the descent of the font described by the receiver. A
* font's <em>descent</em> is the distance from the baseline to the
@@ -66,9 +66,9 @@ public int getAverageCharWidth() {
*
* @return the descent of the font
*/
-public int getDescent() {
- return descent;
-}
+public int getDescent() {
+ return descent;
+}
/**
* Returns the height of the font described by the receiver,
* measured in pixels. A font's <em>height</em> is the sum of
@@ -80,9 +80,9 @@ public int getDescent() {
* @see #getDescent
* @see #getLeading
*/
-public int getHeight() {
- return height;
-}
+public int getHeight() {
+ return height;
+}
/**
* Returns the leading area of the font described by the
* receiver. A font's <em>leading area</em> is the space
@@ -90,9 +90,9 @@ public int getHeight() {
*
* @return the leading space of the font
*/
-public int getLeading() {
- return leading;
-}
+public int getLeading() {
+ return leading;
+}
/**
* Returns an integer hash code for the receiver. Any two
* objects which return <code>true</code> when passed to
@@ -103,16 +103,16 @@ public int getLeading() {
*
* @see #equals
*/
-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;
-}
-}
+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
index 7e604386c8..d09e66a986 100755
--- 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
@@ -1,16 +1,16 @@
-package org.eclipse.swt.graphics;
-
-/*
+package org.eclipse.swt.graphics;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-import org.eclipse.swt.internal.*;
-import org.eclipse.swt.internal.motif.*;
-import org.eclipse.swt.*;
-
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+import org.eclipse.swt.internal.*;
+import org.eclipse.swt.internal.motif.*;
+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
@@ -25,18 +25,18 @@ import org.eclipse.swt.*;
*
* @see org.eclipse.swt.events.PaintEvent
*/
-public final class GC {
+public final class GC {
/**
* the handle to the OS device context
* (Warning: This field is platform dependent)
*/
- public int handle;
-
- Drawable drawable;
- GCData data;
-
-GC() {
-}
+ public int handle;
+
+ Drawable drawable;
+ GCData data;
+
+GC() {
+}
/**
* Constructs a new instance of this class which has been
* configured to draw on the specified drawable. Sets the
@@ -58,18 +58,18 @@ GC() {
* <li>ERROR_NO_HANDLES if a handle could not be obtained for gc creation</li>
* </ul>
*/
-public GC (Drawable drawable) {
- if (drawable == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
- GCData data = new GCData();
- int xGC = 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, xGC);
- if (device.tracking) device.new_Object(this);
-}
-
+public GC (Drawable drawable) {
+ if (drawable == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ GCData data = new GCData();
+ int xGC = 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, xGC);
+ if (device.tracking) device.new_Object(this);
+}
+
/**
* Copies a rectangular area of the receiver at the source
* position onto the receiver at the destination position.
@@ -85,33 +85,33 @@ public GC (Drawable drawable) {
* <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
* </ul>
*/
-public void copyArea(int x, int y, int width, int height, int destX, int destY) {
- if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- 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);
- if (data.image != null) return;
- boolean disjoint = (destX + width < x) || (x + width < destX) || (destY + height < y) || (y + height < destY);
- 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(int x, int y, int width, int height, int destX, int destY) {
+ if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ 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);
+ if (data.image != null) return;
+ boolean disjoint = (destX + width < x) || (x + width < destX) || (destY + height < y) || (y + height < destY);
+ 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);
+ }
+ }
+}
/**
* Copies a rectangular area of the receiver at the specified
* position into the image, which must be of type <code>SWT.BITMAP</code>.
@@ -127,53 +127,53 @@ public void copyArea(int x, int y, int width, int height, int destX, int destY)
* <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
* </ul>
*/
-public void copyArea(Image image, int x, int y) {
- if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- if (image == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
- if (image.type != SWT.BITMAP || image.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
- Rectangle rect = image.getBounds();
- int 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 copyArea(Image image, int x, int y) {
+ if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ if (image == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ if (image.type != SWT.BITMAP || image.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+ Rectangle rect = image.getBounds();
+ int 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);
+}
/**
* Disposes of the operating system resources associated with
* the graphics context. Applications must dispose of all GCs
* which they allocate.
*/
-public void dispose () {
+public void dispose () {
if (handle == 0) return;
- if (data.device.isDisposed()) return;
-
- /* Free resources */
- int clipRgn = data.clipRgn;
- if (clipRgn != 0) OS.XDestroyRegion(clipRgn);
- Image image = data.image;
- if (image != null) {
- image.memGC = null;
- if (image.transparentPixel != -1) image.createMask();
- }
-
- int renderTable = data.renderTable;
- if (renderTable != 0) OS.XmRenderTableFree(renderTable);
-
- /* Dispose the GC */
- Device device = data.device;
- drawable.internal_dispose_GC(handle, data);
-
- data.display = data.drawable = data.colormap = data.fontList =
- data.clipRgn = data.renderTable = 0;
- drawable = null;
- handle = 0;
- data.image = null;
- data.codePage = null;
- if (device.tracking) device.dispose_Object(this);
- data.device = null;
- data = null;
-}
+ if (data.device.isDisposed()) return;
+
+ /* Free resources */
+ int clipRgn = data.clipRgn;
+ if (clipRgn != 0) OS.XDestroyRegion(clipRgn);
+ Image image = data.image;
+ if (image != null) {
+ image.memGC = null;
+ if (image.transparentPixel != -1) image.createMask();
+ }
+
+ int renderTable = data.renderTable;
+ if (renderTable != 0) OS.XmRenderTableFree(renderTable);
+
+ /* Dispose the GC */
+ Device device = data.device;
+ drawable.internal_dispose_GC(handle, data);
+
+ data.display = data.drawable = data.colormap = data.fontList =
+ data.clipRgn = data.renderTable = 0;
+ drawable = null;
+ handle = 0;
+ data.image = null;
+ data.codePage = 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.
@@ -206,21 +206,21 @@ public void dispose () {
* <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
* </ul>
*/
-public void drawArc(int x, int y, int width, int height, int startAngle, int endAngle) {
- if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- if (width < 0) {
- x = x + width;
- width = -width;
- }
- if (height < 0) {
- y = y + height;
- height = -height;
- }
- 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 drawArc(int x, int y, int width, int height, int startAngle, int endAngle) {
+ if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ if (width < 0) {
+ x = x + width;
+ width = -width;
+ }
+ if (height < 0) {
+ y = y + height;
+ height = -height;
+ }
+ 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);
+}
/**
* Draws a rectangle, based on the specified arguments, which has
* the appearance of the platform's <em>focus rectangle</em> if the
@@ -238,37 +238,37 @@ public void drawArc(int x, int y, int width, int height, int startAngle, int end
*
* @see #drawRectangle
*/
-public void drawFocus (int x, int y, int width, int height) {
- if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- /*
- * 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 drawFocus (int x, int y, int width, int height) {
+ if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ /*
+ * 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);
+}
/**
* Draws the given image in the receiver at the specified
* coordinates.
@@ -288,329 +288,329 @@ public void drawFocus (int x, int y, int width, int height) {
* <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
* </ul>
*/
-public void drawImage(Image image, int x, int y) {
- if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- if (image == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
- if (image.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
- drawImage(image, 0, 0, -1, -1, x, y, -1, -1, true);
-}
-
-/**
- * Copies a rectangular area from the source image into a (potentially
- * different sized) rectangular area in the receiver. If the source
- * and destination areas are of differing sizes, then the source
- * area will be stretched or shrunk to fit the destination area
- * as it is copied. The copy fails if any part of the source rectangle
- * lies outside the bounds of the source image, or if any of the width
- * or height arguments are negative.
- *
- * @param image the source image
- * @param srcX the x coordinate in the source image to copy from
- * @param srcY the y coordinate in the source image to copy from
- * @param srcWidth the width in pixels to copy from the source
- * @param srcHeight the height in pixels to copy from the source
- * @param destX the x coordinate in the destination to copy to
- * @param destY the y coordinate in the destination to copy to
- * @param destWidth the width in pixels of the destination rectangle
- * @param destHeight the height in pixels of the destination rectangle
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the image is null</li>
- * <li>ERROR_INVALID_ARGUMENT - if the image has been disposed</li>
- * <li>ERROR_INVALID_ARGUMENT - if any of the width or height arguments are negative.
- * <li>ERROR_INVALID_ARGUMENT - if the source rectangle is not contained within the bounds of the source image</li>
- * </ul>
- * @exception SWTError <ul>
- * <li>ERROR_NO_HANDLES - if no handles are available to perform the operation</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
- * </ul>
+public void drawImage(Image image, int x, int y) {
+ if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ if (image == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ if (image.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+ drawImage(image, 0, 0, -1, -1, x, y, -1, -1, true);
+}
+
+/**
+ * Copies a rectangular area from the source image into a (potentially
+ * different sized) rectangular area in the receiver. If the source
+ * and destination areas are of differing sizes, then the source
+ * area will be stretched or shrunk to fit the destination area
+ * as it is copied. The copy fails if any part of the source rectangle
+ * lies outside the bounds of the source image, or if any of the width
+ * or height arguments are negative.
+ *
+ * @param image the source image
+ * @param srcX the x coordinate in the source image to copy from
+ * @param srcY the y coordinate in the source image to copy from
+ * @param srcWidth the width in pixels to copy from the source
+ * @param srcHeight the height in pixels to copy from the source
+ * @param destX the x coordinate in the destination to copy to
+ * @param destY the y coordinate in the destination to copy to
+ * @param destWidth the width in pixels of the destination rectangle
+ * @param destHeight the height in pixels of the destination rectangle
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if the image is null</li>
+ * <li>ERROR_INVALID_ARGUMENT - if the image has been disposed</li>
+ * <li>ERROR_INVALID_ARGUMENT - if any of the width or height arguments are negative.
+ * <li>ERROR_INVALID_ARGUMENT - if the source rectangle is not contained within the bounds of the source image</li>
+ * </ul>
+ * @exception SWTError <ul>
+ * <li>ERROR_NO_HANDLES - if no handles are available to perform the operation</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
*/
-public void drawImage(Image image, int srcX, int srcY, int srcWidth, int srcHeight, int destX, int destY, int destWidth, int destHeight) {
- if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- if (srcWidth == 0 || srcHeight == 0 || destWidth == 0 || destHeight == 0) return;
- if (srcX < 0 || srcY < 0 || srcWidth < 0 || srcHeight < 0 || destWidth < 0 || destHeight < 0) {
- SWT.error (SWT.ERROR_INVALID_ARGUMENT);
- }
- if (image == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
- if (image.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
- drawImage(image, srcX, srcY, srcWidth, srcHeight, destX, destY, destWidth, destHeight, false);
-}
-void drawImage(Image srcImage, int srcX, int srcY, int srcWidth, int srcHeight, int destX, int destY, int destWidth, int destHeight, boolean simple) {
- int[] width = new int[1];
- int[] height = new int[1];
- 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.
- */
- 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 = Math.max(1, sx2 - sx1);
- srcHeight = Math.max(1, 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 */
- 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, xSrcImage.byte_order, 0, 0, srcWidth, srcHeight, reds, greens, blues,
- srcImage.alpha, srcImage.alphaData, imgWidth, srcX, srcY,
- destData, xDestImage.bits_per_pixel, xDestImage.bytes_per_line, xDestImage.byte_order, 0, 0, destWidth, destHeight, reds, greens, blues,
- false, false);
- } else {
- int srcRedMask = xSrcImage.red_mask;
- int srcGreenMask = xSrcImage.green_mask;
- int srcBlueMask = xSrcImage.blue_mask;
- int destRedMask = xDestImage.red_mask;
- int destGreenMask = xDestImage.green_mask;
- int destBlueMask = xDestImage.blue_mask;
-
- /*
- * Feature in X. XGetImage does not retrieve the RGB masks if the drawable
- * is a Pixmap. The fix is to detect that the masks are not valid and use
- * the default visual masks instead.
- *
- * NOTE: It is safe to use the default Visual masks, since we always
- * create images with these masks.
- */
- int visual = OS.XDefaultVisual(xDisplay, OS.XDefaultScreen(xDisplay));
- Visual xVisual = new Visual();
- OS.memmove(xVisual, visual, Visual.sizeof);
- if (srcRedMask == 0 && srcGreenMask == 0 && srcBlueMask == 0) {
- srcRedMask = xVisual.red_mask;
- srcGreenMask = xVisual.green_mask;
- srcBlueMask = xVisual.blue_mask;
- }
- if (destRedMask == 0 && destGreenMask == 0 && destBlueMask == 0) {
- destRedMask = xVisual.red_mask;
- destGreenMask = xVisual.green_mask;
- destBlueMask = xVisual.blue_mask;
- }
-
- ImageData.blit(ImageData.BLIT_ALPHA,
- srcData, xSrcImage.bits_per_pixel, xSrcImage.bytes_per_line, xSrcImage.byte_order, 0, 0, srcWidth, srcHeight, srcRedMask, srcGreenMask, srcBlueMask,
- srcImage.alpha, srcImage.alphaData, imgWidth, srcX, srcY,
- destData, xDestImage.bits_per_pixel, xDestImage.bytes_per_line, xDestImage.byte_order, 0, 0, destWidth, destHeight, destRedMask, destGreenMask, destBlueMask,
- 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:
- case 4:
- case 8: {
- int format = xSrcImage.bits_per_pixel == 1 ? OS.XYBitmap : OS.ZPixmap;
- xImagePtr = OS.XCreateImage(display, visual, xSrcImage.depth, format, 0, 0, destWidth, destHeight, xSrcImage.bitmap_pad, 0);
- if (xImagePtr == 0) break;
- XImage xImage = new XImage();
- OS.memmove(xImage, xImagePtr, XImage.sizeof);
- int bufSize = xImage.bytes_per_line * xImage.height;
- int bufPtr = OS.XtMalloc(bufSize);
- xImage.data = bufPtr;
- OS.memmove(xImagePtr, xImage, XImage.sizeof);
- byte[] buf = new byte[bufSize];
- int srcOrder = xSrcImage.bits_per_pixel == 1 ? xSrcImage.bitmap_bit_order : xSrcImage.byte_order;
- int destOrder = xImage.bits_per_pixel == 1 ? xImage.bitmap_bit_order : xImage.byte_order;
- ImageData.blit(ImageData.BLIT_SRC,
- srcData, xSrcImage.bits_per_pixel, xSrcImage.bytes_per_line, srcOrder, 0, 0, srcWidth, srcHeight, null, null, null,
- ImageData.ALPHA_OPAQUE, null, 0, 0, 0,
- buf, xImage.bits_per_pixel, xImage.bytes_per_line, destOrder, 0, 0, destWidth, destHeight, null, null, null,
- flipX, flipY);
- OS.memmove(bufPtr, buf, bufSize);
- break;
- }
- case 16:
- case 24:
- case 32: {
- xImagePtr = OS.XCreateImage(display, visual, xSrcImage.depth, OS.ZPixmap, 0, 0, destWidth, destHeight, xSrcImage.bitmap_pad, 0);
- if (xImagePtr == 0) break;
- XImage xImage = new XImage();
- OS.memmove(xImage, xImagePtr, XImage.sizeof);
- int bufSize = xImage.bytes_per_line * xImage.height;
- int bufPtr = OS.XtMalloc(bufSize);
- xImage.data = bufPtr;
- OS.memmove(xImagePtr, xImage, XImage.sizeof);
- byte[] buf = new byte[bufSize];
- ImageData.blit(ImageData.BLIT_SRC,
- srcData, xSrcImage.bits_per_pixel, xSrcImage.bytes_per_line, xSrcImage.byte_order, 0, 0, srcWidth, srcHeight, 0, 0, 0,
- ImageData.ALPHA_OPAQUE, null, 0, 0, 0,
- buf, xImage.bits_per_pixel, xImage.bytes_per_line, xImage.byte_order, 0, 0, destWidth, destHeight, 0, 0, 0,
- flipX, flipY);
- OS.memmove(bufPtr, buf, bufSize);
- 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 drawImage(Image image, int srcX, int srcY, int srcWidth, int srcHeight, int destX, int destY, int destWidth, int destHeight) {
+ if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ if (srcWidth == 0 || srcHeight == 0 || destWidth == 0 || destHeight == 0) return;
+ if (srcX < 0 || srcY < 0 || srcWidth < 0 || srcHeight < 0 || destWidth < 0 || destHeight < 0) {
+ SWT.error (SWT.ERROR_INVALID_ARGUMENT);
+ }
+ if (image == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ if (image.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+ drawImage(image, srcX, srcY, srcWidth, srcHeight, destX, destY, destWidth, destHeight, false);
+}
+void drawImage(Image srcImage, int srcX, int srcY, int srcWidth, int srcHeight, int destX, int destY, int destWidth, int destHeight, boolean simple) {
+ int[] width = new int[1];
+ int[] height = new int[1];
+ 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.
+ */
+ 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 = Math.max(1, sx2 - sx1);
+ srcHeight = Math.max(1, 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 */
+ 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, xSrcImage.byte_order, 0, 0, srcWidth, srcHeight, reds, greens, blues,
+ srcImage.alpha, srcImage.alphaData, imgWidth, srcX, srcY,
+ destData, xDestImage.bits_per_pixel, xDestImage.bytes_per_line, xDestImage.byte_order, 0, 0, destWidth, destHeight, reds, greens, blues,
+ false, false);
+ } else {
+ int srcRedMask = xSrcImage.red_mask;
+ int srcGreenMask = xSrcImage.green_mask;
+ int srcBlueMask = xSrcImage.blue_mask;
+ int destRedMask = xDestImage.red_mask;
+ int destGreenMask = xDestImage.green_mask;
+ int destBlueMask = xDestImage.blue_mask;
+
+ /*
+ * Feature in X. XGetImage does not retrieve the RGB masks if the drawable
+ * is a Pixmap. The fix is to detect that the masks are not valid and use
+ * the default visual masks instead.
+ *
+ * NOTE: It is safe to use the default Visual masks, since we always
+ * create images with these masks.
+ */
+ int visual = OS.XDefaultVisual(xDisplay, OS.XDefaultScreen(xDisplay));
+ Visual xVisual = new Visual();
+ OS.memmove(xVisual, visual, Visual.sizeof);
+ if (srcRedMask == 0 && srcGreenMask == 0 && srcBlueMask == 0) {
+ srcRedMask = xVisual.red_mask;
+ srcGreenMask = xVisual.green_mask;
+ srcBlueMask = xVisual.blue_mask;
+ }
+ if (destRedMask == 0 && destGreenMask == 0 && destBlueMask == 0) {
+ destRedMask = xVisual.red_mask;
+ destGreenMask = xVisual.green_mask;
+ destBlueMask = xVisual.blue_mask;
+ }
+
+ ImageData.blit(ImageData.BLIT_ALPHA,
+ srcData, xSrcImage.bits_per_pixel, xSrcImage.bytes_per_line, xSrcImage.byte_order, 0, 0, srcWidth, srcHeight, srcRedMask, srcGreenMask, srcBlueMask,
+ srcImage.alpha, srcImage.alphaData, imgWidth, srcX, srcY,
+ destData, xDestImage.bits_per_pixel, xDestImage.bytes_per_line, xDestImage.byte_order, 0, 0, destWidth, destHeight, destRedMask, destGreenMask, destBlueMask,
+ 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:
+ case 4:
+ case 8: {
+ int format = xSrcImage.bits_per_pixel == 1 ? OS.XYBitmap : OS.ZPixmap;
+ xImagePtr = OS.XCreateImage(display, visual, xSrcImage.depth, format, 0, 0, destWidth, destHeight, xSrcImage.bitmap_pad, 0);
+ if (xImagePtr == 0) break;
+ XImage xImage = new XImage();
+ OS.memmove(xImage, xImagePtr, XImage.sizeof);
+ int bufSize = xImage.bytes_per_line * xImage.height;
+ int bufPtr = OS.XtMalloc(bufSize);
+ xImage.data = bufPtr;
+ OS.memmove(xImagePtr, xImage, XImage.sizeof);
+ byte[] buf = new byte[bufSize];
+ int srcOrder = xSrcImage.bits_per_pixel == 1 ? xSrcImage.bitmap_bit_order : xSrcImage.byte_order;
+ int destOrder = xImage.bits_per_pixel == 1 ? xImage.bitmap_bit_order : xImage.byte_order;
+ ImageData.blit(ImageData.BLIT_SRC,
+ srcData, xSrcImage.bits_per_pixel, xSrcImage.bytes_per_line, srcOrder, 0, 0, srcWidth, srcHeight, null, null, null,
+ ImageData.ALPHA_OPAQUE, null, 0, 0, 0,
+ buf, xImage.bits_per_pixel, xImage.bytes_per_line, destOrder, 0, 0, destWidth, destHeight, null, null, null,
+ flipX, flipY);
+ OS.memmove(bufPtr, buf, bufSize);
+ break;
+ }
+ case 16:
+ case 24:
+ case 32: {
+ xImagePtr = OS.XCreateImage(display, visual, xSrcImage.depth, OS.ZPixmap, 0, 0, destWidth, destHeight, xSrcImage.bitmap_pad, 0);
+ if (xImagePtr == 0) break;
+ XImage xImage = new XImage();
+ OS.memmove(xImage, xImagePtr, XImage.sizeof);
+ int bufSize = xImage.bytes_per_line * xImage.height;
+ int bufPtr = OS.XtMalloc(bufSize);
+ xImage.data = bufPtr;
+ OS.memmove(xImagePtr, xImage, XImage.sizeof);
+ byte[] buf = new byte[bufSize];
+ ImageData.blit(ImageData.BLIT_SRC,
+ srcData, xSrcImage.bits_per_pixel, xSrcImage.bytes_per_line, xSrcImage.byte_order, 0, 0, srcWidth, srcHeight, 0, 0, 0,
+ ImageData.ALPHA_OPAQUE, null, 0, 0, 0,
+ buf, xImage.bits_per_pixel, xImage.bytes_per_line, xImage.byte_order, 0, 0, destWidth, destHeight, 0, 0, 0,
+ flipX, flipY);
+ OS.memmove(bufPtr, buf, bufSize);
+ 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;
+}
/**
* Draws a line, using the foreground color, between the points
* (<code>x1</code>, <code>y1</code>) and (<code>x2</code>, <code>y2</code>).
@@ -624,10 +624,10 @@ static int scalePixmap(int display, int pixmap, int srcX, int srcY, int srcWidth
* <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
* </ul>
*/
-public void drawLine (int x1, int y1, int x2, int y2) {
- if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- OS.XDrawLine (data.display, data.drawable, handle, x1, y1, x2, y2);
-}
+public void drawLine (int x1, int y1, int x2, int y2) {
+ if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ OS.XDrawLine (data.display, data.drawable, handle, x1, y1, x2, y2);
+}
/**
* Draws the outline of an oval, using the foreground color,
* within the specified rectangular area.
@@ -649,18 +649,18 @@ public void drawLine (int x1, int y1, int x2, int y2) {
* <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
* </ul>
*/
-public void drawOval(int x, int y, int width, int height) {
- if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- 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 drawOval(int x, int y, int width, int height) {
+ if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ if (width < 0) {
+ x = x + width;
+ width = -width;
+ }
+ if (height < 0) {
+ y = y + height;
+ height = -height;
+ }
+ OS.XDrawArc(data.display, data.drawable, handle, x, y, width, height, 0, 23040);
+}
/**
* Draws the closed polygon which is defined by the specified array
* of integer coordinates, using the receiver's foreground color. The array
@@ -678,48 +678,48 @@ public void drawOval(int x, int y, int width, int height) {
* <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
* </ul>
*/
-public void drawPolygon(int[] pointArray) {
- if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- if (pointArray == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
-
- // 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 drawPolygon(int[] pointArray) {
+ if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ 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);
+}
/**
* Draws the polyline which is defined by the specified array
* of integer coordinates, using the receiver's foreground color. The array
@@ -737,15 +737,15 @@ public void drawPolygon(int[] pointArray) {
* <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
* </ul>
*/
-public void drawPolyline(int[] pointArray) {
- if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- if (pointArray == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
- 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 drawPolyline(int[] pointArray) {
+ if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ 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);
+}
/**
* Draws the outline of the rectangle specified by the arguments,
* using the receiver's foreground color. The left and right edges
@@ -761,18 +761,18 @@ public void drawPolyline(int[] pointArray) {
* <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
* </ul>
*/
-public void drawRectangle (int x, int y, int width, int height) {
- if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- 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 (int x, int y, int width, int height) {
+ if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ if (width < 0) {
+ x = x + width;
+ width = -width;
+ }
+ if (height < 0) {
+ y = y + height;
+ height = -height;
+ }
+ OS.XDrawRectangle (data.display, data.drawable, handle, x, y, width, height);
+}
/**
* Draws the outline of the specified rectangle, using the receiver's
* foreground color. The left and right edges of the rectangle are at
@@ -789,10 +789,10 @@ public void drawRectangle (int x, int y, int width, int height) {
* <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
* </ul>
*/
-public void drawRectangle (Rectangle rect) {
- if (rect == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
- drawRectangle (rect.x, rect.y, rect.width, rect.height);
-}
+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
@@ -812,65 +812,65 @@ public void drawRectangle (Rectangle rect) {
* <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
* </ul>
*/
-public void drawRoundRectangle (int x, int y, int width, int height, int arcWidth, int arcHeight) {
- if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
-
- // 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;
-
- if (nw > naw) {
- if (nh > nah) {
- OS.XDrawArc(xDisplay, xDrawable, handle, nx, ny, naw, nah, 5760, 5760);
- OS.XDrawLine(xDisplay, xDrawable, handle, nx + naw2, ny, nx + nw - naw2, ny);
- OS.XDrawArc(xDisplay, xDrawable, handle, nx + nw - naw, ny, naw, nah, 0, 5760);
- OS.XDrawLine(xDisplay, xDrawable, handle, nx + nw, ny + nah2, nx + nw, ny + nh - nah2);
- OS.XDrawArc(xDisplay, xDrawable, handle, nx + nw - naw, ny + nh - nah, naw, nah, 17280, 5760);
- OS.XDrawLine(xDisplay,xDrawable,handle, nx + naw2, ny + nh, nx + nw - naw2, ny + nh);
- OS.XDrawArc(xDisplay, xDrawable, handle, nx, ny + nh - nah, naw, nah, 11520, 5760);
- OS.XDrawLine(xDisplay, xDrawable, handle, nx, ny + nah2, nx, ny + nh - nah2);
- } else {
- OS.XDrawArc(xDisplay, xDrawable, handle, nx, ny, naw, nh, 5760, 11520);
- OS.XDrawLine(xDisplay, xDrawable, handle, nx + naw2, ny, nx + nw - naw2, ny);
- OS.XDrawArc(xDisplay, xDrawable, handle, nx + nw - naw, ny, naw, nh, 17280, 11520);
- OS.XDrawLine(xDisplay,xDrawable,handle, nx + naw2, ny + nh, nx + nw - naw2, ny + nh);
- }
- } else {
- if (nh > nah) {
- OS.XDrawArc(xDisplay, xDrawable, handle, nx, ny, nw, nah, 0, 11520);
- OS.XDrawLine(xDisplay, xDrawable, handle, nx + nw, ny + nah2, nx + nw, ny + nh - nah2);
- OS.XDrawArc(xDisplay, xDrawable, handle, nx, ny + nh - nah, nw, nah, 11520, 11520);
- OS.XDrawLine(xDisplay,xDrawable,handle, nx, ny + nah2, nx, ny + nh - nah2);
- } else {
- OS.XDrawArc(xDisplay, xDrawable, handle, nx, ny, nw, nh, 0, 23040);
- }
- }
-}
+public void drawRoundRectangle (int x, int y, int width, int height, int arcWidth, int arcHeight) {
+ if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+
+ // 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;
+
+ if (nw > naw) {
+ if (nh > nah) {
+ OS.XDrawArc(xDisplay, xDrawable, handle, nx, ny, naw, nah, 5760, 5760);
+ OS.XDrawLine(xDisplay, xDrawable, handle, nx + naw2, ny, nx + nw - naw2, ny);
+ OS.XDrawArc(xDisplay, xDrawable, handle, nx + nw - naw, ny, naw, nah, 0, 5760);
+ OS.XDrawLine(xDisplay, xDrawable, handle, nx + nw, ny + nah2, nx + nw, ny + nh - nah2);
+ OS.XDrawArc(xDisplay, xDrawable, handle, nx + nw - naw, ny + nh - nah, naw, nah, 17280, 5760);
+ OS.XDrawLine(xDisplay,xDrawable,handle, nx + naw2, ny + nh, nx + nw - naw2, ny + nh);
+ OS.XDrawArc(xDisplay, xDrawable, handle, nx, ny + nh - nah, naw, nah, 11520, 5760);
+ OS.XDrawLine(xDisplay, xDrawable, handle, nx, ny + nah2, nx, ny + nh - nah2);
+ } else {
+ OS.XDrawArc(xDisplay, xDrawable, handle, nx, ny, naw, nh, 5760, 11520);
+ OS.XDrawLine(xDisplay, xDrawable, handle, nx + naw2, ny, nx + nw - naw2, ny);
+ OS.XDrawArc(xDisplay, xDrawable, handle, nx + nw - naw, ny, naw, nh, 17280, 11520);
+ OS.XDrawLine(xDisplay,xDrawable,handle, nx + naw2, ny + nh, nx + nw - naw2, ny + nh);
+ }
+ } else {
+ if (nh > nah) {
+ OS.XDrawArc(xDisplay, xDrawable, handle, nx, ny, nw, nah, 0, 11520);
+ OS.XDrawLine(xDisplay, xDrawable, handle, nx + nw, ny + nah2, nx + nw, ny + nh - nah2);
+ OS.XDrawArc(xDisplay, xDrawable, handle, nx, ny + nh - nah, nw, nah, 11520, 11520);
+ OS.XDrawLine(xDisplay,xDrawable,handle, nx, ny + nah2, nx, ny + nh - nah2);
+ } else {
+ OS.XDrawArc(xDisplay, xDrawable, handle, nx, ny, nw, nh, 0, 23040);
+ }
+ }
+}
/**
* Draws the given string, using the receiver's current font and
* foreground color. No tab expansion or carriage return processing
@@ -889,9 +889,9 @@ public void drawRoundRectangle (int x, int y, int width, int height, int arcWidt
* <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
* </ul>
*/
-public void drawString (String string, int x, int y) {
- drawString(string, x, y, false);
-}
+public void drawString (String string, int x, int y) {
+ drawString(string, x, y, false);
+}
/**
* Draws the given string, using the receiver's current font and
* foreground color. No tab expansion or carriage return processing
@@ -912,71 +912,71 @@ public void drawString (String string, int x, int y) {
* <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
* </ul>
*/
-public void drawString (String string, int x, int y, boolean isTransparent) {
- if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- if (string == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
- byte [] buffer = Converter.wcsToMbcs (getCodePage (), 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, OS.XmFONTLIST_DEFAULT_TAG, 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 drawString (String string, int x, int y, boolean isTransparent) {
+ if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ if (string == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ byte [] buffer = Converter.wcsToMbcs (getCodePage (), 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, OS.XmFONTLIST_DEFAULT_TAG, 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]);
+}
/**
* Draws the given string, using the receiver's current font and
* foreground color. Tab expansion and carriage return processing
@@ -995,9 +995,9 @@ void createRenderTable() {
* <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
* </ul>
*/
-public void drawText (String string, int x, int y) {
- drawText(string, x, y, SWT.DRAW_DELIMITER | SWT.DRAW_TAB);
-}
+public void drawText (String string, int x, int y) {
+ drawText(string, x, y, SWT.DRAW_DELIMITER | SWT.DRAW_TAB);
+}
/**
* Draws the given string, using the receiver's current font and
* foreground color. Tab expansion and carriage return processing
@@ -1018,78 +1018,78 @@ public void drawText (String string, int x, int y) {
* <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
* </ul>
*/
-public void drawText (String string, int x, int y, boolean isTransparent) {
- int flags = SWT.DRAW_DELIMITER | SWT.DRAW_TAB;
- if (isTransparent) flags |= SWT.DRAW_TRANSPARENT;
- drawText(string, x, y, flags);
-}
-/**
- * Draws the given string, using the receiver's current font and
- * foreground color. Tab expansion, line delimiter and mnemonic
- * processing are performed according to the specified flags. If
- * <code>flags</code> includes <code>DRAW_TRANSPARENT</code>,
- * then the background of the rectangular area where the text is being
- * drawn will not be modified, otherwise it will be filled with the
- * receiver's background color.
- * <p>
- * The parameter <code>flags</code> may be a combination of:
- * <dl>
- * <dt><b>DRAW_DELIMITER</b></dt>
- * <dd>draw multiple lines</dd>
- * <dt><b>DRAW_TAB</b></dt>
- * <dd>expand tabs</dd>
- * <dt><b>DRAW_MNEMONIC</b></dt>
- * <dd>underline the mnemonic character</dd>
- * <dt><b>DRAW_TRANSPARENT</b></dt>
- * <dd>transparent background</dd>
- * </dl>
- * </p>
- *
- * @param string the string to be drawn
- * @param x the x coordinate of the top left corner of the rectangular area where the text is to be drawn
- * @param y the y coordinate of the top left corner of the rectangular area where the text is to be drawn
- * @param flags the flags specifing how to process the text
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the string is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
- * </ul>
+public void drawText (String string, int x, int y, boolean isTransparent) {
+ int flags = SWT.DRAW_DELIMITER | SWT.DRAW_TAB;
+ if (isTransparent) flags |= SWT.DRAW_TRANSPARENT;
+ drawText(string, x, y, flags);
+}
+/**
+ * Draws the given string, using the receiver's current font and
+ * foreground color. Tab expansion, line delimiter and mnemonic
+ * processing are performed according to the specified flags. If
+ * <code>flags</code> includes <code>DRAW_TRANSPARENT</code>,
+ * then the background of the rectangular area where the text is being
+ * drawn will not be modified, otherwise it will be filled with the
+ * receiver's background color.
+ * <p>
+ * The parameter <code>flags</code> may be a combination of:
+ * <dl>
+ * <dt><b>DRAW_DELIMITER</b></dt>
+ * <dd>draw multiple lines</dd>
+ * <dt><b>DRAW_TAB</b></dt>
+ * <dd>expand tabs</dd>
+ * <dt><b>DRAW_MNEMONIC</b></dt>
+ * <dd>underline the mnemonic character</dd>
+ * <dt><b>DRAW_TRANSPARENT</b></dt>
+ * <dd>transparent background</dd>
+ * </dl>
+ * </p>
+ *
+ * @param string the string to be drawn
+ * @param x the x coordinate of the top left corner of the rectangular area where the text is to be drawn
+ * @param y the y coordinate of the top left corner of the rectangular area where the text is to be drawn
+ * @param flags the flags specifing how to process the text
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if the string is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
*/
-public void drawText (String string, int x, int y, int flags) {
- if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- if (string == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
- if (data.renderTable == 0) createRenderTable();
- int renderTable = data.renderTable;
-
- char mnemonic=0;
- int tableLength = 0;
- Device device = data.device;
- int[] parseTable = new int[2];
- char[] text = new char[string.length()];
- string.getChars(0, text.length, text, 0);
- if ((flags & SWT.DRAW_DELIMITER) != 0) parseTable[tableLength++] = device.crMapping;
- if ((flags & SWT.DRAW_TAB) != 0) parseTable[tableLength++] = device.tabMapping;
- if ((flags & SWT.DRAW_MNEMONIC) != 0) mnemonic = stripMnemonic(text);
-
- String codePage = getCodePage();
- byte[] buffer = Converter.wcsToMbcs(codePage, text, true);
- int xmString = OS.XmStringParseText(buffer, 0, OS.XmFONTLIST_DEFAULT_TAG, OS.XmCHARSET_TEXT, parseTable, tableLength, 0);
- if (mnemonic != 0) {
- byte [] buffer1 = Converter.wcsToMbcs(codePage, new char[]{mnemonic}, true);
- int xmStringUnderline = OS.XmStringCreate (buffer1, OS.XmFONTLIST_DEFAULT_TAG);
- OS.XmStringDrawUnderline(data.display, data.drawable, renderTable, xmString, handle, x, y, 0x7FFFFFFF, OS.XmALIGNMENT_BEGINNING, 0, null, xmStringUnderline);
- OS.XmStringFree(xmStringUnderline);
- } else {
- if ((flags & SWT.DRAW_TRANSPARENT) != 0) {
- 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.XmStringFree(xmString);
-}
+public void drawText (String string, int x, int y, int flags) {
+ if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ if (string == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ if (data.renderTable == 0) createRenderTable();
+ int renderTable = data.renderTable;
+
+ char mnemonic=0;
+ int tableLength = 0;
+ Device device = data.device;
+ int[] parseTable = new int[2];
+ char[] text = new char[string.length()];
+ string.getChars(0, text.length, text, 0);
+ if ((flags & SWT.DRAW_DELIMITER) != 0) parseTable[tableLength++] = device.crMapping;
+ if ((flags & SWT.DRAW_TAB) != 0) parseTable[tableLength++] = device.tabMapping;
+ if ((flags & SWT.DRAW_MNEMONIC) != 0) mnemonic = stripMnemonic(text);
+
+ String codePage = getCodePage();
+ byte[] buffer = Converter.wcsToMbcs(codePage, text, true);
+ int xmString = OS.XmStringParseText(buffer, 0, OS.XmFONTLIST_DEFAULT_TAG, OS.XmCHARSET_TEXT, parseTable, tableLength, 0);
+ if (mnemonic != 0) {
+ byte [] buffer1 = Converter.wcsToMbcs(codePage, new char[]{mnemonic}, true);
+ int xmStringUnderline = OS.XmStringCreate (buffer1, OS.XmFONTLIST_DEFAULT_TAG);
+ OS.XmStringDrawUnderline(data.display, data.drawable, renderTable, xmString, handle, x, y, 0x7FFFFFFF, OS.XmALIGNMENT_BEGINNING, 0, null, xmStringUnderline);
+ OS.XmStringFree(xmStringUnderline);
+ } else {
+ if ((flags & SWT.DRAW_TRANSPARENT) != 0) {
+ 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.XmStringFree(xmString);
+}
/**
* Compares the argument to the receiver, and returns true
* if they represent the <em>same</em> object using a class
@@ -1100,11 +1100,11 @@ public void drawText (String string, int x, int y, int flags) {
*
* @see #hashCode
*/
-public boolean equals (Object object) {
- if (object == this) return true;
- if (!(object instanceof GC)) return false;
- return handle == ((GC)object).handle;
-}
+public boolean equals (Object object) {
+ if (object == this) return true;
+ if (!(object instanceof GC)) return false;
+ return handle == ((GC)object).handle;
+}
/**
* Fills the interior of a circular or elliptical arc within
* the specified rectangular area, with the receiver's background
@@ -1140,125 +1140,125 @@ public boolean equals (Object object) {
*
* @see #drawArc
*/
-public void fillArc(int x, int y, int width, int height, int startAngle, int endAngle) {
- if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- if (width < 0) {
- x = x + width;
- width = -width;
- }
- if (height < 0) {
- y = y + height;
- height = -height;
- }
- 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);
-}
-
-/**
- * Fills the interior of the specified rectangle with a gradient
- * sweeping from left to right or top to bottom progressing
- * from the receiver's foreground color to its background color.
- *
- * @param x the x coordinate of the rectangle to be filled
- * @param y the y coordinate of the rectangle to be filled
- * @param width the width of the rectangle to be filled, may be negative
- * (inverts direction of gradient if horizontal)
- * @param height the height of the rectangle to be filled, may be negative
- * (inverts direction of gradient if vertical)
- * @param vertical if true sweeps from top to bottom, else
- * sweeps from left to right
- *
- * @exception SWTException <ul>
- * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
- * </ul>
- *
- * @see #drawRectangle
+public void fillArc(int x, int y, int width, int height, int startAngle, int endAngle) {
+ if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ if (width < 0) {
+ x = x + width;
+ width = -width;
+ }
+ if (height < 0) {
+ y = y + height;
+ height = -height;
+ }
+ 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);
+}
+
+/**
+ * Fills the interior of the specified rectangle with a gradient
+ * sweeping from left to right or top to bottom progressing
+ * from the receiver's foreground color to its background color.
+ *
+ * @param x the x coordinate of the rectangle to be filled
+ * @param y the y coordinate of the rectangle to be filled
+ * @param width the width of the rectangle to be filled, may be negative
+ * (inverts direction of gradient if horizontal)
+ * @param height the height of the rectangle to be filled, may be negative
+ * (inverts direction of gradient if vertical)
+ * @param vertical if true sweeps from top to bottom, else
+ * sweeps from left to right
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ *
+ * @see #drawRectangle
*/
-public void fillGradientRectangle(int x, int y, int width, int height, boolean vertical) {
- if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- if ((width == 0) || (height == 0)) return;
- int xDisplay = data.display;
- int xScreenNum = OS.XDefaultScreen(xDisplay);
- XGCValues values = new XGCValues();
- int fromColor, toColor;
- OS.XGetGCValues(xDisplay, handle, OS.GCForeground | OS.GCBackground, values);
- fromColor = values.foreground;
- toColor = values.background;
- boolean swapColors = false;
- if (width < 0) {
- x += width; width = -width;
- if (! vertical) swapColors = true;
- }
- if (height < 0) {
- y += height; height = -height;
- if (vertical) swapColors = true;
- }
- if (swapColors) {
- final int t = fromColor;
- fromColor = toColor;
- toColor = t;
- }
- if (fromColor == toColor) {
- OS.XFillRectangle(xDisplay, data.drawable, handle, x, y, width, height);
- return;
- }
- /* X Window deals with a virtually limitless array of color formats
- * but we only distinguish between paletted and direct modes
- */
- final int xScreen = OS.XDefaultScreenOfDisplay(xDisplay);
- final int xVisual = OS.XDefaultVisual(xDisplay, xScreenNum);
- Visual visual = new Visual();
- OS.memmove(visual, xVisual, Visual.sizeof);
- final int depth = OS.XDefaultDepthOfScreen(xScreen);
- final boolean directColor = (depth > 8);
-
- // This code is intentionally commented since elsewhere in SWT we
- // assume that depth <= 8 means we are in a paletted mode though
- // this is not always the case.
- //final boolean directColor = (visual.c_class == OS.TrueColor) || (visual.c_class == OS.DirectColor);
-
- XColor xColor = new XColor();
- xColor.pixel = fromColor;
- OS.XQueryColor(xDisplay, data.colormap, xColor);
- final RGB fromRGB = new RGB((xColor.red & 0xffff) >>> 8, (xColor.green & 0xffff) >>> 8, (xColor.blue & 0xffff) >>> 8);
- xColor.pixel = toColor;
- OS.XQueryColor(xDisplay, data.colormap, xColor);
- final RGB toRGB = new RGB((xColor.red & 0xffff) >>> 8, (xColor.green & 0xffff) >>> 8, (xColor.blue & 0xffff) >>> 8);
-
- final int redBits, greenBits, blueBits;
- if (directColor) {
- // RGB mapped display
- redBits = getChannelWidth(visual.red_mask);
- greenBits = getChannelWidth(visual.green_mask);
- blueBits = getChannelWidth(visual.blue_mask);
- } else {
- // Index display
- redBits = greenBits = blueBits = 0;
- }
- ImageData.fillGradientRectangle(this, data.device,
- x, y, width, height, vertical, fromRGB, toRGB,
- redBits, greenBits, blueBits);
-}
-
-/**
- * Computes the required channel width (depth) from a mask.
+public void fillGradientRectangle(int x, int y, int width, int height, boolean vertical) {
+ if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ if ((width == 0) || (height == 0)) return;
+ int xDisplay = data.display;
+ int xScreenNum = OS.XDefaultScreen(xDisplay);
+ XGCValues values = new XGCValues();
+ int fromColor, toColor;
+ OS.XGetGCValues(xDisplay, handle, OS.GCForeground | OS.GCBackground, values);
+ fromColor = values.foreground;
+ toColor = values.background;
+ boolean swapColors = false;
+ if (width < 0) {
+ x += width; width = -width;
+ if (! vertical) swapColors = true;
+ }
+ if (height < 0) {
+ y += height; height = -height;
+ if (vertical) swapColors = true;
+ }
+ if (swapColors) {
+ final int t = fromColor;
+ fromColor = toColor;
+ toColor = t;
+ }
+ if (fromColor == toColor) {
+ OS.XFillRectangle(xDisplay, data.drawable, handle, x, y, width, height);
+ return;
+ }
+ /* X Window deals with a virtually limitless array of color formats
+ * but we only distinguish between paletted and direct modes
+ */
+ final int xScreen = OS.XDefaultScreenOfDisplay(xDisplay);
+ final int xVisual = OS.XDefaultVisual(xDisplay, xScreenNum);
+ Visual visual = new Visual();
+ OS.memmove(visual, xVisual, Visual.sizeof);
+ final int depth = OS.XDefaultDepthOfScreen(xScreen);
+ final boolean directColor = (depth > 8);
+
+ // This code is intentionally commented since elsewhere in SWT we
+ // assume that depth <= 8 means we are in a paletted mode though
+ // this is not always the case.
+ //final boolean directColor = (visual.c_class == OS.TrueColor) || (visual.c_class == OS.DirectColor);
+
+ XColor xColor = new XColor();
+ xColor.pixel = fromColor;
+ OS.XQueryColor(xDisplay, data.colormap, xColor);
+ final RGB fromRGB = new RGB((xColor.red & 0xffff) >>> 8, (xColor.green & 0xffff) >>> 8, (xColor.blue & 0xffff) >>> 8);
+ xColor.pixel = toColor;
+ OS.XQueryColor(xDisplay, data.colormap, xColor);
+ final RGB toRGB = new RGB((xColor.red & 0xffff) >>> 8, (xColor.green & 0xffff) >>> 8, (xColor.blue & 0xffff) >>> 8);
+
+ final int redBits, greenBits, blueBits;
+ if (directColor) {
+ // RGB mapped display
+ redBits = getChannelWidth(visual.red_mask);
+ greenBits = getChannelWidth(visual.green_mask);
+ blueBits = getChannelWidth(visual.blue_mask);
+ } else {
+ // Index display
+ redBits = greenBits = blueBits = 0;
+ }
+ ImageData.fillGradientRectangle(this, data.device,
+ x, y, width, height, vertical, fromRGB, toRGB,
+ redBits, greenBits, blueBits);
+}
+
+/**
+ * Computes the required channel width (depth) from a mask.
*/
-static int getChannelWidth(int mask) {
- int width = 0;
- while (mask != 0) {
- width += (mask & 1);
- mask >>>= 1;
- }
- return width;
-}
-
+static int getChannelWidth(int mask) {
+ int width = 0;
+ while (mask != 0) {
+ width += (mask & 1);
+ mask >>>= 1;
+ }
+ return width;
+}
+
/**
* Fills the interior of an oval, within the specified
* rectangular area, with the receiver's background
@@ -1275,23 +1275,23 @@ static int getChannelWidth(int mask) {
*
* @see #drawOval
*/
-public void fillOval (int x, int y, int width, int height) {
- if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- if (width < 0) {
- x = x + width;
- width = -width;
- }
- if (height < 0) {
- y = y + height;
- height = -height;
- }
- 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 fillOval (int x, int y, int width, int height) {
+ if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ if (width < 0) {
+ x = x + width;
+ width = -width;
+ }
+ if (height < 0) {
+ y = y + height;
+ height = -height;
+ }
+ 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);
+}
/**
* Fills the interior of the closed polygon which is defined by the
* specified array of integer coordinates, using the receiver's
@@ -1311,20 +1311,20 @@ public void fillOval (int x, int y, int width, int height) {
*
* @see #drawPolygon
*/
-public void fillPolygon(int[] pointArray) {
- if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- if (pointArray == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
- 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.Complex, OS.CoordModeOrigin);
- OS.XSetForeground (xDisplay, handle, values.foreground);
-}
+public void fillPolygon(int[] pointArray) {
+ if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ 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.Complex, OS.CoordModeOrigin);
+ OS.XSetForeground (xDisplay, handle, values.foreground);
+}
/**
* Fills the interior of the rectangle specified by the arguments,
* using the receiver's background color.
@@ -1340,23 +1340,23 @@ public void fillPolygon(int[] pointArray) {
*
* @see #drawRectangle
*/
-public void fillRectangle (int x, int y, int width, int height) {
- if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- if (width < 0) {
- x = x + width;
- width = -width;
- }
- if (height < 0) {
- y = y + height;
- height = -height;
- }
- 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 (int x, int y, int width, int height) {
+ if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ if (width < 0) {
+ x = x + width;
+ width = -width;
+ }
+ if (height < 0) {
+ y = y + height;
+ height = -height;
+ }
+ 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);
+}
/**
* Fills the interior of the specified rectangle, using the receiver's
* background color.
@@ -1372,10 +1372,10 @@ public void fillRectangle (int x, int y, int width, int height) {
*
* @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);
-}
+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.
@@ -1393,62 +1393,62 @@ public void fillRectangle (Rectangle rect) {
*
* @see #drawRoundRectangle
*/
-public void fillRoundRectangle (int x, int y, int width, int height, int arcWidth, int arcHeight) {
- if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- 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;
- XGCValues values = new XGCValues ();
- OS.XGetGCValues(xDisplay, handle, OS.GCForeground | OS.GCBackground, values);
- OS.XSetForeground(xDisplay, handle, values.background);
-
- if (nw > naw) {
- if (nh > nah) {
- OS.XFillArc(xDisplay, xDrawable, handle, nx, ny, naw, nah, 5760, 5760);
- OS.XFillRectangle(xDisplay, xDrawable, handle, nx + naw2, ny, nw - naw, nah2);
- OS.XFillArc(xDisplay, xDrawable, handle, nx + nw - naw, ny, naw, nah, 0, 5760);
- OS.XFillRectangle(xDisplay, xDrawable, handle, nx, ny + nah2, nw, nh - nah);
- OS.XFillArc(xDisplay, xDrawable, handle, nx + nw - naw, ny + nh - nah, naw, nah, 17280, 5760);
- OS.XFillRectangle(xDisplay, xDrawable, handle, nx + naw2, ny + nh - nah2, nw - naw, nah2);
- OS.XFillArc(xDisplay, xDrawable, handle, nx, ny + nh - nah, naw, nah, 11520, 5760);
- } else {
- OS.XFillArc(xDisplay, xDrawable, handle, nx, ny, naw, nh, 5760, 11520);
- OS.XFillRectangle(xDisplay, xDrawable, handle, nx + naw2, ny, nw - naw, nh);
- OS.XFillArc(xDisplay, xDrawable, handle, nx + nw - naw, ny, naw, nh, 17280, 11520);
- }
- } else {
- if (nh > nah) {
- OS.XFillArc(xDisplay, xDrawable, handle, nx, ny, nw, nah, 0, 11520);
- OS.XFillRectangle(xDisplay, xDrawable, handle, nx, ny + nah2, nw, nh - nah);
- OS.XFillArc(xDisplay, xDrawable, handle, nx, ny + nh - nah, nw, nah, 11520, 11520);
- } else {
- OS.XFillArc(xDisplay, xDrawable, handle, nx, ny, nw, nh, 0, 23040);
- }
- }
- OS.XSetForeground(xDisplay, handle, values.foreground);
-}
+public void fillRoundRectangle (int x, int y, int width, int height, int arcWidth, int arcHeight) {
+ if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ 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;
+ XGCValues values = new XGCValues ();
+ OS.XGetGCValues(xDisplay, handle, OS.GCForeground | OS.GCBackground, values);
+ OS.XSetForeground(xDisplay, handle, values.background);
+
+ if (nw > naw) {
+ if (nh > nah) {
+ OS.XFillArc(xDisplay, xDrawable, handle, nx, ny, naw, nah, 5760, 5760);
+ OS.XFillRectangle(xDisplay, xDrawable, handle, nx + naw2, ny, nw - naw, nah2);
+ OS.XFillArc(xDisplay, xDrawable, handle, nx + nw - naw, ny, naw, nah, 0, 5760);
+ OS.XFillRectangle(xDisplay, xDrawable, handle, nx, ny + nah2, nw, nh - nah);
+ OS.XFillArc(xDisplay, xDrawable, handle, nx + nw - naw, ny + nh - nah, naw, nah, 17280, 5760);
+ OS.XFillRectangle(xDisplay, xDrawable, handle, nx + naw2, ny + nh - nah2, nw - naw, nah2);
+ OS.XFillArc(xDisplay, xDrawable, handle, nx, ny + nh - nah, naw, nah, 11520, 5760);
+ } else {
+ OS.XFillArc(xDisplay, xDrawable, handle, nx, ny, naw, nh, 5760, 11520);
+ OS.XFillRectangle(xDisplay, xDrawable, handle, nx + naw2, ny, nw - naw, nh);
+ OS.XFillArc(xDisplay, xDrawable, handle, nx + nw - naw, ny, naw, nh, 17280, 11520);
+ }
+ } else {
+ if (nh > nah) {
+ OS.XFillArc(xDisplay, xDrawable, handle, nx, ny, nw, nah, 0, 11520);
+ OS.XFillRectangle(xDisplay, xDrawable, handle, nx, ny + nah2, nw, nh - nah);
+ OS.XFillArc(xDisplay, xDrawable, handle, nx, ny + nh - nah, nw, nah, 11520, 11520);
+ } else {
+ OS.XFillArc(xDisplay, xDrawable, handle, nx, ny, nw, nh, 0, 23040);
+ }
+ }
+ OS.XSetForeground(xDisplay, handle, values.foreground);
+}
/**
* Returns the <em>advance width</em> of the specified character in
* the font which is currently selected into the receiver.
@@ -1464,94 +1464,94 @@ public void fillRoundRectangle (int x, int y, int width, int height, int arcWidt
* <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
* </ul>
*/
-public int getAdvanceWidth(char ch) {
- if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- int fontList = data.fontList;
- byte[] charBuffer = Converter.wcsToMbcs(getCodePage (), 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 int getAdvanceWidth(char ch) {
+ if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ int fontList = data.fontList;
+ byte[] charBuffer = Converter.wcsToMbcs(getCodePage (), 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;
+}
/**
* Returns the background color.
*
@@ -1561,17 +1561,17 @@ public int getAdvanceWidth(char ch) {
* <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
* </ul>
*/
-public Color getBackground() {
- if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- int xDisplay = data.display;
- XGCValues values = new XGCValues();
- OS.XGetGCValues(xDisplay, handle, OS.GCBackground, values);
- XColor xColor = new XColor();
- xColor.pixel = values.background;
- OS.XQueryColor(xDisplay,data.colormap,xColor);
- return Color.motif_new(data.device, xColor);
-
-}
+public Color getBackground() {
+ if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ int xDisplay = data.display;
+ XGCValues values = new XGCValues();
+ OS.XGetGCValues(xDisplay, handle, OS.GCBackground, values);
+ XColor xColor = new XColor();
+ xColor.pixel = values.background;
+ OS.XQueryColor(xDisplay,data.colormap,xColor);
+ return Color.motif_new(data.device, xColor);
+
+}
/**
* Returns the width of the specified character in the font
* selected into the receiver.
@@ -1588,94 +1588,94 @@ public Color getBackground() {
* <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
* </ul>
*/
-public int getCharWidth(char ch) {
- if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- int fontList = data.fontList;
- byte[] charBuffer = Converter.wcsToMbcs(getCodePage (), 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 int getCharWidth(char ch) {
+ if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ int fontList = data.fontList;
+ byte[] charBuffer = Converter.wcsToMbcs(getCodePage (), 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;
+}
/**
* Returns the bounding rectangle of the receiver's clipping
* region. If no clipping region is set, the return value
@@ -1688,19 +1688,19 @@ public int getCharWidth(char ch) {
* <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
* </ul>
*/
-public Rectangle getClipping() {
- if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- 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 Rectangle getClipping() {
+ if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ 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);
+}
/**
* Sets the region managed by the argument to the current
* clipping region of the receiver.
@@ -1714,28 +1714,28 @@ public Rectangle getClipping() {
* <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
* </ul>
*/
-public void getClipping(Region region) {
- if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- if (region == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
- 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);
-}
-String getCodePage () {
- return data.codePage;
-}
+public void getClipping(Region region) {
+ if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ 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);
+}
+String getCodePage () {
+ return data.codePage;
+}
/**
* Returns the font currently being used by the receiver
* to draw and measure text.
@@ -1746,52 +1746,52 @@ String getCodePage () {
* <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
* </ul>
*/
-public Font getFont () {
- if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- return 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 Font getFont () {
+ if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ 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;
+}
/**
* Returns a FontMetrics which contains information
* about the font currently being used by the receiver
@@ -1803,158 +1803,158 @@ int getFontHeight () {
* <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
* </ul>
*/
-public FontMetrics getFontMetrics() {
- if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- 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.
+public FontMetrics getFontMetrics() {
+ if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ 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;
+ }
+ }
+ 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);
-}
+ 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);
+}
/**
* Returns the receiver's foreground color.
*
@@ -1964,17 +1964,17 @@ public FontMetrics getFontMetrics() {
* <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
* </ul>
*/
-public Color getForeground() {
- if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- int xDisplay = data.display;
- XGCValues values = new XGCValues();
- OS.XGetGCValues(xDisplay, handle, OS.GCForeground, values);
- XColor xColor = new XColor();
- xColor.pixel = values.foreground;
- OS.XQueryColor(xDisplay,data.colormap,xColor);
- return Color.motif_new(data.device, xColor);
-
-}
+public Color getForeground() {
+ if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ int xDisplay = data.display;
+ XGCValues values = new XGCValues();
+ OS.XGetGCValues(xDisplay, handle, OS.GCForeground, values);
+ XColor xColor = new XColor();
+ xColor.pixel = values.foreground;
+ OS.XQueryColor(xDisplay,data.colormap,xColor);
+ return Color.motif_new(data.device, xColor);
+
+}
/**
* Returns the receiver's line style, which will be one
* of the constants <code>SWT.LINE_SOLID</code>, <code>SWT.LINE_DASH</code>,
@@ -1987,10 +1987,10 @@ public Color getForeground() {
* <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
* </ul>
*/
-public int getLineStyle() {
- if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- return data.lineStyle;
-}
+public int getLineStyle() {
+ if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ return data.lineStyle;
+}
/**
* Returns the width that will be used when drawing lines
* for all of the figure drawing operations (that is,
@@ -2003,12 +2003,12 @@ public int getLineStyle() {
* <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
* </ul>
*/
-public int getLineWidth() {
- if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- XGCValues values = new XGCValues();
- OS.XGetGCValues(data.display, handle, OS.GCLineWidth, values);
- return values.line_width;
-}
+public int getLineWidth() {
+ if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ XGCValues values = new XGCValues();
+ OS.XGetGCValues(data.display, handle, OS.GCLineWidth, values);
+ return values.line_width;
+}
/**
* Returns <code>true</code> if this GC is drawing in the mode
* where the resulting color in the destination is the
@@ -2023,12 +2023,12 @@ public int getLineWidth() {
* <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
* </ul>
*/
-public boolean getXORMode() {
- if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- XGCValues values = new XGCValues ();
- OS.XGetGCValues (data.display, handle, OS.GCFunction, values);
- return values.function == OS.GXxor;
-}
+public boolean getXORMode() {
+ if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ XGCValues values = new XGCValues ();
+ OS.XGetGCValues (data.display, handle, OS.GCFunction, values);
+ return values.function == OS.GXxor;
+}
/**
* Returns an integer hash code for the receiver. Any two
* objects which return <code>true</code> when passed to
@@ -2043,29 +2043,29 @@ public boolean getXORMode() {
*
* @see #equals
*/
-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 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;
+}
/**
* Returns <code>true</code> if the receiver has a clipping
* region set into it, and <code>false</code> otherwise.
@@ -2080,10 +2080,10 @@ void init(Drawable drawable, GCData data, int xGC) {
* <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
* </ul>
*/
-public boolean isClipped() {
- if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- return data.clipRgn != 0;
-}
+public boolean isClipped() {
+ if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ return data.clipRgn != 0;
+}
/**
* Returns <code>true</code> if the GC has been disposed,
* and <code>false</code> otherwise.
@@ -2094,15 +2094,15 @@ public boolean isClipped() {
*
* @return <code>true</code> when the GC is disposed and <code>false</code> otherwise
*/
-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 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;
+}
/**
* Sets the background color. The background color is used
* for fill operations and as the background color when text
@@ -2118,12 +2118,12 @@ public static GC motif_new(Drawable drawable, GCData data) {
* <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
* </ul>
*/
-public void setBackground (Color color) {
- if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- if (color == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
- if (color.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
- OS.XSetBackground(data.display, handle, color.handle.pixel);
-}
+public void setBackground (Color color) {
+ if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ if (color == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ if (color.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+ OS.XSetBackground(data.display, handle, color.handle.pixel);
+}
/**
* Sets the area of the receiver which can be changed
* by drawing operations to the rectangular area specified
@@ -2138,20 +2138,20 @@ public void setBackground (Color color) {
* <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
* </ul>
*/
-public void setClipping (int x, int y, int width, int height) {
- if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- int clipRgn = data.clipRgn;
- if (clipRgn == 0) {
- data.clipRgn = 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 (int x, int y, int width, int height) {
+ if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ int clipRgn = data.clipRgn;
+ if (clipRgn == 0) {
+ data.clipRgn = 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);
+}
/**
* Sets the area of the receiver which can be changed
* by drawing operations to the rectangular area specified
@@ -2163,19 +2163,19 @@ public void setClipping (int x, int y, int width, int height) {
* <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
* </ul>
*/
-public void setClipping (Rectangle rect) {
- if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- if (rect == null) {
- OS.XSetClipMask (data.display, handle, OS.None);
- int clipRgn = data.clipRgn;
- if (clipRgn != 0) {
- OS.XDestroyRegion (clipRgn);
- data.clipRgn = 0;
- }
- return;
- }
- setClipping (rect.x, rect.y, rect.width, rect.height);
-}
+public void setClipping (Rectangle rect) {
+ if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ if (rect == null) {
+ OS.XSetClipMask (data.display, handle, OS.None);
+ int clipRgn = data.clipRgn;
+ if (clipRgn != 0) {
+ OS.XDestroyRegion (clipRgn);
+ data.clipRgn = 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
@@ -2187,25 +2187,25 @@ public void setClipping (Rectangle rect) {
* <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
* </ul>
*/
-public void setClipping (Region region) {
- if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- int clipRgn = data.clipRgn;
- if (region == null) {
- OS.XSetClipMask (data.display, handle, OS.None);
- if (clipRgn != 0) {
- OS.XDestroyRegion (clipRgn);
- data.clipRgn = 0;
- }
- } else {
- if (clipRgn == 0) {
- data.clipRgn = clipRgn = OS.XCreateRegion ();
- } else {
- OS.XSubtractRegion (clipRgn, clipRgn, clipRgn);
- }
- OS.XUnionRegion (region.handle, clipRgn, clipRgn);
- OS.XSetRegion (data.display, handle, region.handle);
- }
-}
+public void setClipping (Region region) {
+ if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ int clipRgn = data.clipRgn;
+ if (region == null) {
+ OS.XSetClipMask (data.display, handle, OS.None);
+ if (clipRgn != 0) {
+ OS.XDestroyRegion (clipRgn);
+ data.clipRgn = 0;
+ }
+ } else {
+ if (clipRgn == 0) {
+ data.clipRgn = clipRgn = OS.XCreateRegion ();
+ } else {
+ OS.XSubtractRegion (clipRgn, clipRgn, clipRgn);
+ }
+ OS.XUnionRegion (region.handle, clipRgn, clipRgn);
+ OS.XSetRegion (data.display, handle, region.handle);
+ }
+}
/**
* Sets the font which will be used by the receiver
* to draw and measure text to the argument. If the
@@ -2222,14 +2222,14 @@ public void setClipping (Region region) {
* </ul>
*/
public void setFont (Font font) {
- if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
if (font == null) font = data.device.systemFont;
- if (font.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
- data.fontList = font.handle;
- data.codePage = font.codePage;
- if (data.renderTable != 0) OS.XmRenderTableFree(data.renderTable);
- data.renderTable = 0;
-}
+ if (font.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+ data.fontList = font.handle;
+ data.codePage = font.codePage;
+ if (data.renderTable != 0) OS.XmRenderTableFree(data.renderTable);
+ data.renderTable = 0;
+}
/**
* Sets the foreground color. The foreground color is used
* for drawing operations including when text is drawn.
@@ -2244,12 +2244,12 @@ public void setFont (Font font) {
* <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
* </ul>
*/
-public void setForeground (Color color) {
- if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- if (color == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
- if (color.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
- OS.XSetForeground(data.display, handle, color.handle.pixel);
-}
+public void setForeground (Color color) {
+ if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ if (color == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ if (color.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+ OS.XSetForeground(data.display, handle, color.handle.pixel);
+}
/**
* 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>,
@@ -2262,33 +2262,33 @@ public void setForeground (Color color) {
* <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
* </ul>
*/
-public void setLineStyle(int lineStyle) {
- if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- 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.LineOnOffDash, OS.CapButt, OS.JoinMiter);
-
-}
+public void setLineStyle(int lineStyle) {
+ if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ 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.LineOnOffDash, OS.CapButt, OS.JoinMiter);
+
+}
/**
* Sets the width that will be used when drawing lines
* for all of the figure drawing operations (that is,
@@ -2301,14 +2301,14 @@ public void setLineStyle(int lineStyle) {
* <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
* </ul>
*/
-public void setLineWidth(int width) {
- if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- 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 setLineWidth(int width) {
+ if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ 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);
+ }
+}
/**
* If the argument is <code>true</code>, puts the receiver
* in a drawing mode where the resulting color in the destination
@@ -2323,13 +2323,13 @@ public void setLineWidth(int width) {
* <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
* </ul>
*/
-public void setXORMode(boolean xor) {
- if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- if (xor)
- OS.XSetFunction(data.display, handle, OS.GXxor);
- else
- OS.XSetFunction(data.display, handle, OS.GXcopy);
-}
+public void setXORMode(boolean xor) {
+ if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ if (xor)
+ OS.XSetFunction(data.display, handle, OS.GXxor);
+ else
+ OS.XSetFunction(data.display, handle, OS.GXcopy);
+}
/**
* Returns the extent of the given string. No tab
* expansion or carriage return processing will be performed.
@@ -2349,32 +2349,32 @@ public void setXORMode(boolean xor) {
* <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
* </ul>
*/
-public Point stringExtent(String string) {
- if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- if (string == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
- if (string.length () == 0) return new Point(0, getFontHeight());
- byte[] buffer = Converter.wcsToMbcs(getCodePage (), 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);
-}
-char stripMnemonic(char[] text) {
- char mnemonic=0;
- int i=0, j=0;
- while (i < text.length) {
- if ((text [j++] = text [i++]) == '&') {
- if (i == text.length) {continue;}
- if (text [i] == '&') {i++; continue;}
- if (mnemonic == 0) mnemonic = text [i];
- j--;
- }
- }
- while (j < text.length) text [j++] = 0;
- return mnemonic;
-}
+public Point stringExtent(String string) {
+ if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ if (string == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ if (string.length () == 0) return new Point(0, getFontHeight());
+ byte[] buffer = Converter.wcsToMbcs(getCodePage (), 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);
+}
+char stripMnemonic(char[] text) {
+ char mnemonic=0;
+ int i=0, j=0;
+ while (i < text.length) {
+ if ((text [j++] = text [i++]) == '&') {
+ if (i == text.length) {continue;}
+ if (text [i] == '&') {i++; continue;}
+ if (mnemonic == 0) mnemonic = text [i];
+ j--;
+ }
+ }
+ while (j < text.length) text [j++] = 0;
+ return mnemonic;
+}
/**
* Returns the extent of the given string. Tab expansion and
* carriage return processing are performed.
@@ -2394,71 +2394,71 @@ char stripMnemonic(char[] text) {
* <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
* </ul>
*/
-public Point textExtent(String string) {
- return textExtent(string, SWT.DRAW_DELIMITER | SWT.DRAW_TAB);
-}
-/**
- * Returns the extent of the given string. Tab expansion, line
- * delimiter and mnemonic processing are performed according to
- * the specified flags, which can be a combination of:
- * <dl>
- * <dt><b>DRAW_DELIMITER</b></dt>
- * <dd>draw multiple lines</dd>
- * <dt><b>DRAW_TAB</b></dt>
- * <dd>expand tabs</dd>
- * <dt><b>DRAW_MNEMONIC</b></dt>
- * <dd>underline the mnemonic character</dd>
- * <dt><b>DRAW_TRANSPARENT</b></dt>
- * <dd>transparent background</dd>
- * </dl>
- * <p>
- * The <em>extent</em> of a string is the width and height of
- * the rectangular area it would cover if drawn in a particular
- * font (in this case, the current font in the receiver).
- * </p>
- *
- * @param string the string to measure
- * @param flags the flags specifing how to process the text
- * @return a point containing the extent of the string
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the string is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
- * </ul>
+public Point textExtent(String string) {
+ return textExtent(string, SWT.DRAW_DELIMITER | SWT.DRAW_TAB);
+}
+/**
+ * Returns the extent of the given string. Tab expansion, line
+ * delimiter and mnemonic processing are performed according to
+ * the specified flags, which can be a combination of:
+ * <dl>
+ * <dt><b>DRAW_DELIMITER</b></dt>
+ * <dd>draw multiple lines</dd>
+ * <dt><b>DRAW_TAB</b></dt>
+ * <dd>expand tabs</dd>
+ * <dt><b>DRAW_MNEMONIC</b></dt>
+ * <dd>underline the mnemonic character</dd>
+ * <dt><b>DRAW_TRANSPARENT</b></dt>
+ * <dd>transparent background</dd>
+ * </dl>
+ * <p>
+ * The <em>extent</em> of a string is the width and height of
+ * the rectangular area it would cover if drawn in a particular
+ * font (in this case, the current font in the receiver).
+ * </p>
+ *
+ * @param string the string to measure
+ * @param flags the flags specifing how to process the text
+ * @return a point containing the extent of the string
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if the string is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
*/
-public Point textExtent(String string, int flags) {
- if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- if (string == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
- if (string.length () == 0) return new Point(0, getFontHeight());
- if (data.renderTable == 0) createRenderTable();
- int renderTable = data.renderTable;
-
- int tableLength = 0;
- Device device = data.device;
- int[] parseTable = new int[2];
- char[] text = new char[string.length()];
- string.getChars(0, text.length, text, 0);
- if ((flags & SWT.DRAW_DELIMITER) != 0) parseTable[tableLength++] = device.crMapping;
- if ((flags & SWT.DRAW_TAB) != 0) parseTable[tableLength++] = device.tabMapping;
- if ((flags & SWT.DRAW_MNEMONIC) != 0) stripMnemonic(text);
-
- byte[] buffer = Converter.wcsToMbcs(getCodePage(), text, true);
- int xmString = OS.XmStringParseText(buffer, 0, OS.XmFONTLIST_DEFAULT_TAG, OS.XmCHARSET_TEXT, parseTable, tableLength, 0);
- int width = OS.XmStringWidth(renderTable, xmString);
- int height = OS.XmStringHeight(renderTable, xmString);
- OS.XmStringFree(xmString);
- return new Point(width, height);
-}
-/**
- * Returns a string containing a concise, human-readable
- * description of the receiver.
- *
- * @return a string representation of the receiver
+public Point textExtent(String string, int flags) {
+ if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ if (string == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ if (string.length () == 0) return new Point(0, getFontHeight());
+ if (data.renderTable == 0) createRenderTable();
+ int renderTable = data.renderTable;
+
+ int tableLength = 0;
+ Device device = data.device;
+ int[] parseTable = new int[2];
+ char[] text = new char[string.length()];
+ string.getChars(0, text.length, text, 0);
+ if ((flags & SWT.DRAW_DELIMITER) != 0) parseTable[tableLength++] = device.crMapping;
+ if ((flags & SWT.DRAW_TAB) != 0) parseTable[tableLength++] = device.tabMapping;
+ if ((flags & SWT.DRAW_MNEMONIC) != 0) stripMnemonic(text);
+
+ byte[] buffer = Converter.wcsToMbcs(getCodePage(), text, true);
+ int xmString = OS.XmStringParseText(buffer, 0, OS.XmFONTLIST_DEFAULT_TAG, OS.XmCHARSET_TEXT, parseTable, tableLength, 0);
+ int width = OS.XmStringWidth(renderTable, xmString);
+ int height = OS.XmStringHeight(renderTable, xmString);
+ OS.XmStringFree(xmString);
+ return new Point(width, height);
+}
+/**
+ * Returns a string containing a concise, human-readable
+ * description of the receiver.
+ *
+ * @return a string representation of the receiver
*/
-public String toString () {
- if (isDisposed()) return "GC {*DISPOSED*}";
- return "GC {" + handle + "}";
-}
-}
+public String toString () {
+ if (isDisposed()) return "GC {*DISPOSED*}";
+ return "GC {" + handle + "}";
+}
+}
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
index 4fb1992908..24a3018664 100755
--- 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
@@ -1,14 +1,14 @@
-package org.eclipse.swt.graphics;
-
-/*
+package org.eclipse.swt.graphics;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-import org.eclipse.swt.*;
-
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+import org.eclipse.swt.*;
+
/**
* Instances of this class are descriptions of GCs in terms
* of unallocated platform-specific data fields.
@@ -21,17 +21,17 @@ import org.eclipse.swt.*;
*
* @private
*/
-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 String codePage;
- public int colormap;
- public int clipRgn;
- public int lineStyle = SWT.LINE_SOLID;
- public int renderTable;
+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 String codePage;
+ public int colormap;
+ public int clipRgn;
+ public int lineStyle = SWT.LINE_SOLID;
+ public int renderTable;
}
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
index 351184f934..3016d74a47 100755
--- 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
@@ -1,16 +1,16 @@
-package org.eclipse.swt.graphics;
-
-/*
+package org.eclipse.swt.graphics;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-import org.eclipse.swt.internal.motif.*;
-import org.eclipse.swt.*;
-import java.io.*;
-
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+import org.eclipse.swt.internal.motif.*;
+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
@@ -58,62 +58,62 @@ import java.io.*;
* @see ImageData
* @see ImageLoader
*/
-public final class Image implements Drawable {
+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 handle to the OS pixmap resource.
- * Warning: This field is platform dependent.
+ 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 pixmap;
+
+ /**
+ * The handle to the OS mask resource.
+ * Warning: This field is platform dependent.
*/
- public int mask;
-
- /**
- * The device where this image was created.
+ public int mask;
+
+ /**
+ * The device where this image was created.
*/
- Device device;
-
- /**
- * specifies the transparent pixel
- * (Warning: This field is platform dependent)
+ 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.
+ 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.
+ 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.
+ 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.
+ int alpha = -1;
+
+ /**
+ * Specifies the default scanline padding.
+ * Warning: This field is platform dependent.
*/
- static final int DEFAULT_SCANLINE_PAD = 4;
-
-Image() {
-}
+ static final int DEFAULT_SCANLINE_PAD = 4;
+
+Image() {
+}
/**
* Constructs an empty instance of this class with the
* specified width and height. The result may be drawn upon
@@ -144,12 +144,12 @@ Image() {
* <li>ERROR_NO_HANDLES if a handle could not be obtained for image creation</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);
-}
+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
@@ -181,280 +181,280 @@ public Image(Device device, int width, int height) {
* <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);
- if (srcImage.isDisposed()) SWT.error(SWT.ERROR_INVALID_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 || srcImage.transparentPixel != -1)) {
- /* 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);
- }
- if (device.tracking) device.new_Object(this);
- 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.
+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);
+ if (srcImage.isDisposed()) SWT.error(SWT.ERROR_INVALID_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 || srcImage.transparentPixel != -1)) {
+ /* 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);
+ }
+ if (device.tracking) device.new_Object(this);
+ 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;
- if (device.tracking) device.new_Object(this);
- 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);
- }
- if (device.tracking) device.new_Object(this);
-}
+ 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;
+ if (device.tracking) device.new_Object(this);
+ 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);
+ }
+ if (device.tracking) device.new_Object(this);
+}
/**
* Constructs an empty instance of this class with the
* width and height of the specified rectangle. The result
@@ -485,13 +485,13 @@ public Image(Device device, Image srcImage, int flag) {
* <li>ERROR_NO_HANDLES if a handle could not be obtained for image creation</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);
-}
+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>.
@@ -507,12 +507,12 @@ public Image(Device device, Rectangle bounds) {
* <li>ERROR_NO_HANDLES if a handle could not be obtained for image creation</li>
* </ul>
*/
-public Image(Device device, ImageData image) {
- if (device == null) device = Device.getDevice();
- if (device == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
- init(device, image);
- if (device.tracking) device.new_Object(this);
-}
+public Image(Device device, ImageData image) {
+ if (device == null) device = Device.getDevice();
+ if (device == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ init(device, image);
+ 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>
@@ -542,21 +542,21 @@ public Image(Device device, ImageData image) {
* <li>ERROR_NO_HANDLES if a handle could not be obtained for image creation</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) 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, 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);
+}
/**
* Constructs an instance of this class by loading its representation
* from the specified input stream. Throws an error if an error
@@ -589,12 +589,12 @@ public Image(Device device, ImageData source, ImageData mask) {
* <li>ERROR_NO_HANDLES if a handle could not be obtained for image creation</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);
-}
+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
@@ -620,53 +620,53 @@ public Image(Device device, InputStream stream) {
* <li>ERROR_NO_HANDLES if a handle could not be obtained for image creation</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);
-}
-/**
- * Create the receiver's mask if necessary.
+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);
+}
+/**
+ * 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);
- Image.putImage(maskImage, 0, 0, maskImage.width, maskImage.height, 0, 0, maskImage.width, maskImage.height, xDisplay, visual, screenDepth, xcolors, null, true, maskPixmap, gc);
- OS.XFreeGC(xDisplay, gc);
- this.mask = maskPixmap;
-}
+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);
+ Image.putImage(maskImage, 0, 0, maskImage.width, maskImage.height, 0, 0, maskImage.width, maskImage.height, xDisplay, visual, screenDepth, xcolors, null, true, maskPixmap, gc);
+ OS.XFreeGC(xDisplay, gc);
+ this.mask = maskPixmap;
+}
/**
* Disposes of the operating system resources associated with
* the image. Applications must dispose of all images which
* they allocate.
*/
-public void dispose () {
- if (pixmap == 0) return;
+public void dispose () {
+ if (pixmap == 0) return;
if (device.isDisposed()) return;
- int xDisplay = device.xDisplay;
- if (pixmap != 0) OS.XFreePixmap (xDisplay, pixmap);
- if (mask != 0) OS.XFreePixmap (xDisplay, mask);
- memGC = null;
- pixmap = mask = 0;
- if (device.tracking) device.dispose_Object(this);
- device = null;
-}
-/**
- * Destroy the receiver's mask if it exists.
+ int xDisplay = device.xDisplay;
+ if (pixmap != 0) OS.XFreePixmap (xDisplay, pixmap);
+ if (mask != 0) OS.XFreePixmap (xDisplay, mask);
+ memGC = null;
+ pixmap = mask = 0;
+ if (device.tracking) device.dispose_Object(this);
+ device = null;
+}
+/**
+ * Destroy the receiver's mask if it exists.
*/
-void destroyMask() {
- if (mask == 0) return;
- OS.XFreePixmap (device.xDisplay, mask);
- mask = 0;
-}
+void destroyMask() {
+ if (mask == 0) return;
+ OS.XFreePixmap (device.xDisplay, mask);
+ mask = 0;
+}
/**
* Compares the argument to the receiver, and returns true
* if they represent the <em>same</em> object using a class
@@ -677,12 +677,12 @@ void destroyMask() {
*
* @see #hashCode
*/
-public boolean equals (Object object) {
- if (object == this) return true;
- if (!(object instanceof Image)) return false;
- Image image = (Image)object;
- return device == image.device && pixmap == image.pixmap;
-}
+public boolean equals (Object object) {
+ if (object == this) return true;
+ if (!(object instanceof Image)) return false;
+ Image image = (Image)object;
+ return device == image.device && pixmap == image.pixmap;
+}
/**
* Returns the color to which to map the transparent pixel, or null if
* the receiver has no transparent pixel.
@@ -701,16 +701,16 @@ public boolean equals (Object object) {
* <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
* </ul>
*/
-public Color getBackground() {
- if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- if (transparentPixel == -1) return null;
- 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 Color getBackground() {
+ if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ 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);
+}
/**
* Returns the bounds of the receiver. The rectangle will always
* have x and y values of 0, and the width and height of the
@@ -723,12 +723,12 @@ public Color getBackground() {
* <li>ERROR_INVALID_IMAGE - if the image is not a bitmap or an icon</li>
* </ul>
*/
-public Rectangle getBounds () {
- if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- 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 Rectangle getBounds () {
+ if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ 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]);
+}
/**
* Returns an <code>ImageData</code> based on the receiver
* Modifications made to this <code>ImageData</code> will not
@@ -743,205 +743,205 @@ public Rectangle getBounds () {
*
* @see ImageData
*/
-public ImageData getImageData() {
- if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- 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);
-
- /* Get the data and palette of the source image. */
- PaletteData palette = null;
- int length = xSrcImage.bytes_per_line * xSrcImage.height;
- byte[] srcData = new byte[length];
- OS.memmove(srcData, xSrcImage.data, length);
- switch (xSrcImage.bits_per_pixel) {
- 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:
- /* Normalize the pixels in the source image data (by making the
- * pixel values sequential starting at pixel 0). Reserve normalized
- * pixel 0 so that it maps to real pixel 0. This assumes pixel 0 is
- * always used in the image.
- */
- byte[] normPixel = new byte[256];
- for (int index = 0; index < normPixel.length; index++) {
- normPixel[index] = 0;
- }
- int numPixels = 1;
- int index = 0;
- for (int y = 0; y < xSrcImage.height; y++) {
- for (int x = 0; x < xSrcImage.bytes_per_line; x++) {
- int srcPixel = srcData[index + x] & 0xFF;
- if (srcPixel != 0 && normPixel[srcPixel] == 0) {
- normPixel[srcPixel] = (byte)numPixels++;
- }
- srcData[index + x] = normPixel[srcPixel];
- }
- index += xSrcImage.bytes_per_line;
- }
-
- /* Create a palette with only the RGB values used in the image. */
- int colormap = OS.XDefaultColormap(xDisplay, OS.XDefaultScreen(xDisplay));
- RGB[] rgbs = new RGB[numPixels];
- XColor color = new XColor();
- for (int srcPixel = 0; srcPixel < normPixel.length; srcPixel++) {
- /* If the pixel value was used in the image, get its RGB values. */
- if (srcPixel == 0 || normPixel[srcPixel] != 0) {
- color.pixel = srcPixel;
- OS.XQueryColor(xDisplay, colormap, color);
- int rgbIndex = normPixel[srcPixel] & 0xFF;
- rgbs[rgbIndex] = new RGB((color.red >> 8) & 0xFF, (color.green >> 8) & 0xFF, (color.blue >> 8) & 0xFF);
- }
- }
- palette = new PaletteData(rgbs);
- break;
- case 16:
- /* Byte swap the data if necessary */
- if (xSrcImage.byte_order == OS.MSBFirst) {
- for (int i = 0; i < srcData.length; i += 2) {
- byte b = srcData[i];
- srcData[i] = srcData[i+1];
- srcData[i+1] = b;
- }
- }
- break;
- case 24:
- break;
- case 32:
- /* Byte swap the data if necessary */
- if (xSrcImage.byte_order == OS.LSBFirst) {
- for (int i = 0; i < srcData.length; i += 4) {
- byte b = srcData[i];
- srcData[i] = srcData[i+3];
- srcData[i+3] = b;
- b = srcData[i+1];
- srcData[i+1] = srcData[i+2];
- srcData[i+2] = b;
- }
- }
- break;
- default:
- SWT.error(SWT.ERROR_UNSUPPORTED_DEPTH);
- }
- if (palette == null) {
- /*
- * For some reason, the XImage does not have the mask information.
- * We must get it from the defualt 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);
- }
- ImageData data = new ImageData(width, height, xSrcImage.bits_per_pixel, palette);
- data.data = srcData;
- if (transparentPixel == -1 && type == SWT.ICON && mask != 0) {
- /* Get the icon mask data */
- 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);
- byte[] maskData = data.maskData = new byte[xMask.bytes_per_line * xMask.height];
- data.maskPad = xMask.bitmap_pad / 8;
- OS.memmove(maskData, xMask.data, maskData.length);
- OS.XDestroyImage(xMaskPtr);
- /* Bit swap the mask data if necessary */
- if (xMask.bitmap_bit_order == OS.LSBFirst) {
- 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.
+public ImageData getImageData() {
+ if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ 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);
+
+ /* Get the data and palette of the source image. */
+ PaletteData palette = null;
+ int length = xSrcImage.bytes_per_line * xSrcImage.height;
+ byte[] srcData = new byte[length];
+ OS.memmove(srcData, xSrcImage.data, length);
+ switch (xSrcImage.bits_per_pixel) {
+ 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:
+ /* Normalize the pixels in the source image data (by making the
+ * pixel values sequential starting at pixel 0). Reserve normalized
+ * pixel 0 so that it maps to real pixel 0. This assumes pixel 0 is
+ * always used in the image.
+ */
+ byte[] normPixel = new byte[256];
+ for (int index = 0; index < normPixel.length; index++) {
+ normPixel[index] = 0;
+ }
+ int numPixels = 1;
+ int index = 0;
+ for (int y = 0; y < xSrcImage.height; y++) {
+ for (int x = 0; x < xSrcImage.bytes_per_line; x++) {
+ int srcPixel = srcData[index + x] & 0xFF;
+ if (srcPixel != 0 && normPixel[srcPixel] == 0) {
+ normPixel[srcPixel] = (byte)numPixels++;
+ }
+ srcData[index + x] = normPixel[srcPixel];
+ }
+ index += xSrcImage.bytes_per_line;
+ }
+
+ /* Create a palette with only the RGB values used in the image. */
+ int colormap = OS.XDefaultColormap(xDisplay, OS.XDefaultScreen(xDisplay));
+ RGB[] rgbs = new RGB[numPixels];
+ XColor color = new XColor();
+ for (int srcPixel = 0; srcPixel < normPixel.length; srcPixel++) {
+ /* If the pixel value was used in the image, get its RGB values. */
+ if (srcPixel == 0 || normPixel[srcPixel] != 0) {
+ color.pixel = srcPixel;
+ OS.XQueryColor(xDisplay, colormap, color);
+ int rgbIndex = normPixel[srcPixel] & 0xFF;
+ rgbs[rgbIndex] = new RGB((color.red >> 8) & 0xFF, (color.green >> 8) & 0xFF, (color.blue >> 8) & 0xFF);
+ }
+ }
+ palette = new PaletteData(rgbs);
+ break;
+ case 16:
+ /* Byte swap the data if necessary */
+ if (xSrcImage.byte_order == OS.MSBFirst) {
+ for (int i = 0; i < srcData.length; i += 2) {
+ byte b = srcData[i];
+ srcData[i] = srcData[i+1];
+ srcData[i+1] = b;
+ }
+ }
+ break;
+ case 24:
+ break;
+ case 32:
+ /* Byte swap the data if necessary */
+ if (xSrcImage.byte_order == OS.LSBFirst) {
+ for (int i = 0; i < srcData.length; i += 4) {
+ byte b = srcData[i];
+ srcData[i] = srcData[i+3];
+ srcData[i+3] = b;
+ b = srcData[i+1];
+ srcData[i+1] = srcData[i+2];
+ srcData[i+2] = b;
+ }
+ }
+ break;
+ default:
+ SWT.error(SWT.ERROR_UNSUPPORTED_DEPTH);
+ }
+ if (palette == null) {
+ /*
+ * For some reason, the XImage does not have the mask information.
+ * We must get it from the defualt 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);
+ }
+ ImageData data = new ImageData(width, height, xSrcImage.bits_per_pixel, palette);
+ data.data = srcData;
+ if (transparentPixel == -1 && type == SWT.ICON && mask != 0) {
+ /* Get the icon mask data */
+ 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);
+ byte[] maskData = data.maskData = new byte[xMask.bytes_per_line * xMask.height];
+ data.maskPad = xMask.bitmap_pad / 8;
+ OS.memmove(maskData, xMask.data, maskData.length);
+ OS.XDestroyImage(xMaskPtr);
+ /* Bit swap the mask data if necessary */
+ if (xMask.bitmap_bit_order == OS.LSBFirst) {
+ 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;
-}
+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;
+}
/**
* Returns an integer hash code for the receiver. Any two
* objects which return <code>true</code> when passed to
@@ -952,78 +952,78 @@ static boolean getOffsetForMask(int bitspp, int mask, int byteOrder, int[] poff)
*
* @see #equals
*/
-public int hashCode () {
- return pixmap;
-}
-void init(Device device, int width, int height) {
- this.device = device;
- if (width <= 0 | height <= 0) {
- SWT.error(SWT.ERROR_INVALID_ARGUMENT);
- }
-
- /* Create the pixmap */
- 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 pixmap = OS.XCreatePixmap(xDisplay, drawable, width, height, depth);
- if (pixmap == 0) SWT.error(SWT.ERROR_NO_HANDLES);
- /* Fill the bitmap with white */
- int xGC = OS.XCreateGC(xDisplay, drawable, 0, null);
- OS.XSetForeground(xDisplay, xGC, OS.XWhitePixel(xDisplay, screenNum));
- OS.XFillRectangle(xDisplay, pixmap, xGC, 0, 0, width, height);
- OS.XFreeGC(xDisplay, xGC);
- this.pixmap = pixmap;
-}
-void init(Device device, ImageData image) {
- 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);
- if (pixmap == 0) SWT.error(SWT.ERROR_NO_HANDLES);
- 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, false, 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, true, 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 hashCode () {
+ return pixmap;
+}
+void init(Device device, int width, int height) {
+ this.device = device;
+ if (width <= 0 | height <= 0) {
+ SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+ }
+
+ /* Create the pixmap */
+ 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 pixmap = OS.XCreatePixmap(xDisplay, drawable, width, height, depth);
+ if (pixmap == 0) SWT.error(SWT.ERROR_NO_HANDLES);
+ /* Fill the bitmap with white */
+ int xGC = OS.XCreateGC(xDisplay, drawable, 0, null);
+ OS.XSetForeground(xDisplay, xGC, OS.XWhitePixel(xDisplay, screenNum));
+ OS.XFillRectangle(xDisplay, pixmap, xGC, 0, 0, width, height);
+ OS.XFreeGC(xDisplay, xGC);
+ this.pixmap = pixmap;
+}
+void init(Device device, ImageData image) {
+ 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);
+ if (pixmap == 0) SWT.error(SWT.ERROR_NO_HANDLES);
+ 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, false, 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, true, 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;
+}
/**
* Invokes platform specific functionality to allocate a new GC handle.
* <p>
@@ -1039,25 +1039,25 @@ void init(Device device, ImageData image) {
*
* @private
*/
-public int internal_new_GC (GCData data) {
- if (pixmap == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- if (type != SWT.BITMAP || memGC != null) {
- SWT.error(SWT.ERROR_INVALID_ARGUMENT);
- }
- int 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.systemFont.handle;
- data.codePage = device.systemFont.codePage;
- data.colormap = OS.XDefaultColormap (xDisplay, OS.XDefaultScreen (xDisplay));
- data.image = this;
- }
- return xGC;
-}
+public int internal_new_GC (GCData data) {
+ if (pixmap == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ if (type != SWT.BITMAP || memGC != null) {
+ SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+ }
+ int 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.systemFont.handle;
+ data.codePage = device.systemFont.codePage;
+ data.colormap = OS.XDefaultColormap (xDisplay, OS.XDefaultScreen (xDisplay));
+ data.image = this;
+ }
+ return xGC;
+}
/**
* Invokes platform specific functionality to dispose a GC handle.
* <p>
@@ -1073,13 +1073,13 @@ public int internal_new_GC (GCData data) {
*
* @private
*/
-public void internal_dispose_GC (int gc, GCData data) {
+public void internal_dispose_GC (int gc, GCData data) {
int xDisplay = 0;
if (data != null) xDisplay = data.display;
if (xDisplay == 0 && device != null) xDisplay = device.xDisplay;
- if (xDisplay == 0) SWT.error (SWT.ERROR_NO_HANDLES);;
- OS.XFreeGC(xDisplay, gc);
-}
+ if (xDisplay == 0) SWT.error (SWT.ERROR_NO_HANDLES);;
+ OS.XFreeGC(xDisplay, gc);
+}
/**
* Returns <code>true</code> if the image has been disposed,
* and <code>false</code> otherwise.
@@ -1090,250 +1090,250 @@ public void internal_dispose_GC (int gc, GCData data) {
*
* @return <code>true</code> when the image is disposed and <code>false</code> otherwise
*/
-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.
+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, boolean isMask, 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 == 8) || (image.depth == 16 || image.depth == 24 || image.depth == 32) && 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 (!palette.isDirect) {
- RGB[] rgbs = palette.getRGBs();
- int length = rgbs.length;
- srcReds = new byte[length];
- srcGreens = new byte[length];
- srcBlues = new byte[length];
- for (int i = 0; i < rgbs.length; i++) {
- RGB rgb = rgbs[i];
- if (rgb == null) continue;
- srcReds[i] = (byte)rgb.red;
- srcGreens[i] = (byte)rgb.green;
- srcBlues[i] = (byte)rgb.blue;
- }
- }
- byte[] destReds = null, destGreens = null, destBlues = null;
- int destRedMask = 0, destGreenMask = 0, destBlueMask = 0;
- final boolean screenDirect;
- 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);
- }
- screenDirect = false;
- } else {
- Visual xVisual = new Visual();
- OS.memmove(xVisual, visual, Visual.sizeof);
- destRedMask = xVisual.red_mask;
- destGreenMask = xVisual.green_mask;
- destBlueMask = xVisual.blue_mask;
- screenDirect = true;
- }
- if (transparentPixel != null) {
- int transRed = 0, transGreen = 0, transBlue = 0;
- if (palette.isDirect) {
- RGB rgb = palette.getRGB(transparentPixel[0]);
- transRed = rgb.red;
- transGreen = rgb.green;
- transBlue = rgb.blue;
- } else {
- RGB[] rgbs = palette.getRGBs();
- if (transparentPixel[0] < rgbs.length) {
- RGB rgb = rgbs[transparentPixel[0]];
- transRed = rgb.red;
- transGreen = rgb.green;
- transBlue = rgb.blue;
- }
- }
- transparentPixel[0] = ImageData.closestMatch(screenDepth, (byte)transRed, (byte)transGreen, (byte)transBlue,
- destRedMask, destGreenMask, destBlueMask, destReds, destGreens, destBlues);
- }
-
- /* Depth 1 */
- if (image.depth == 1) {
- int xImagePtr = OS.XCreateImage(display, visual, 1, OS.XYBitmap, 0, 0, destWidth, destHeight, image.scanlinePad * 8, 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 * xImage.height;
- int bufPtr = OS.XtMalloc(bufSize);
- xImage.data = bufPtr;
- OS.memmove(xImagePtr, xImage, XImage.sizeof);
- byte[] buf = new byte[bufSize];
- ImageData.blit(ImageData.BLIT_SRC,
- image.data, image.depth, image.bytesPerLine, image.getByteOrder(), srcX, srcY, srcWidth, srcHeight, null, null, null,
- ImageData.ALPHA_OPAQUE, null, 0, srcX, srcY,
- buf, xImage.bits_per_pixel, xImage.bytes_per_line, xImage.bitmap_bit_order, 0, 0, destWidth, destHeight, null, null, null,
- flipX, flipY);
- OS.memmove(xImage.data, buf, bufSize);
-
- int foreground = 1, background = 0;
- if (!isMask) {
- foreground = 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);
- }
- }
- 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, image.scanlinePad * 8, 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 * xImage.height;
- int bufPtr = OS.XtMalloc(bufSize);
- xImage.data = bufPtr;
- OS.memmove(xImagePtr, xImage, XImage.sizeof);
- byte[] buf = new byte[bufSize];
- if (palette.isDirect) {
- if (screenDirect) {
- ImageData.blit(ImageData.BLIT_SRC,
- image.data, image.depth, image.bytesPerLine, image.getByteOrder(), srcX, srcY, srcWidth, srcHeight, palette.redMask, palette.greenMask, palette.blueMask,
- ImageData.ALPHA_OPAQUE, null, 0, srcX, srcY,
- buf, xImage.bits_per_pixel, xImage.bytes_per_line, xImage.byte_order, 0, 0, destWidth, destHeight, xImage.red_mask, xImage.green_mask, xImage.blue_mask,
- flipX, flipY);
- } else {
- ImageData.blit(ImageData.BLIT_SRC,
- image.data, image.depth, image.bytesPerLine, image.getByteOrder(), srcX, srcY, srcWidth, srcHeight, palette.redMask, palette.greenMask, palette.blueMask,
- ImageData.ALPHA_OPAQUE, null, 0, srcX, srcY,
- buf, xImage.bits_per_pixel, xImage.bytes_per_line, xImage.byte_order, 0, 0, destWidth, destHeight, destReds, destGreens, destBlues,
- flipX, flipY);
- }
- } else {
- if (screenDirect) {
- ImageData.blit(ImageData.BLIT_SRC,
- image.data, image.depth, image.bytesPerLine, image.getByteOrder(), srcX, srcY, srcWidth, srcHeight, srcReds, srcGreens, srcBlues,
- ImageData.ALPHA_OPAQUE, null, 0, srcX, srcY,
- buf, xImage.bits_per_pixel, xImage.bytes_per_line, xImage.byte_order, 0, 0, destWidth, destHeight, xImage.red_mask, xImage.green_mask, xImage.blue_mask,
- flipX, flipY);
- } else {
- ImageData.blit(ImageData.BLIT_SRC,
- image.data, image.depth, image.bytesPerLine, image.getByteOrder(), srcX, srcY, srcWidth, srcHeight, srcReds, srcGreens, srcBlues,
- ImageData.ALPHA_OPAQUE, null, 0, srcX, srcY,
- buf, xImage.bits_per_pixel, xImage.bytes_per_line, xImage.byte_order, 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;
-}
-/**
- * Sets the color to which to map the transparent pixel.
- * <p>
- * There are certain uses of <code>Images</code> that do not support
- * transparency (for example, setting an image into a button or label).
- * In these cases, it may be desired to simulate transparency by using
- * the background color of the widget to paint the transparent pixels
- * of the image. This method specifies the color that will be used in
- * these cases. For example:
- * <pre>
- * Button b = new Button();
- * image.setBackground(b.getBackground());>
- * b.setImage(image);
- * </pre>
- * </p><p>
- * The image may be modified by this operation (in effect, the
- * transparent regions may be filled with the supplied color). Hence
- * this operation is not reversible and it is not legal to call
- * this function twice or with a null argument.
- * </p><p>
- * This method has no effect if the receiver does not have a transparent
- * pixel value.
- * </p>
- *
- * @param color the color to use when a transparent pixel is specified
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the color is null</li>
- * <li>ERROR_INVALID_ARGUMENT - if the color has been disposed</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
- * </ul>
+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, boolean isMask, 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 == 8) || (image.depth == 16 || image.depth == 24 || image.depth == 32) && 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 (!palette.isDirect) {
+ RGB[] rgbs = palette.getRGBs();
+ int length = rgbs.length;
+ srcReds = new byte[length];
+ srcGreens = new byte[length];
+ srcBlues = new byte[length];
+ for (int i = 0; i < rgbs.length; i++) {
+ RGB rgb = rgbs[i];
+ if (rgb == null) continue;
+ srcReds[i] = (byte)rgb.red;
+ srcGreens[i] = (byte)rgb.green;
+ srcBlues[i] = (byte)rgb.blue;
+ }
+ }
+ byte[] destReds = null, destGreens = null, destBlues = null;
+ int destRedMask = 0, destGreenMask = 0, destBlueMask = 0;
+ final boolean screenDirect;
+ 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);
+ }
+ screenDirect = false;
+ } else {
+ Visual xVisual = new Visual();
+ OS.memmove(xVisual, visual, Visual.sizeof);
+ destRedMask = xVisual.red_mask;
+ destGreenMask = xVisual.green_mask;
+ destBlueMask = xVisual.blue_mask;
+ screenDirect = true;
+ }
+ if (transparentPixel != null) {
+ int transRed = 0, transGreen = 0, transBlue = 0;
+ if (palette.isDirect) {
+ RGB rgb = palette.getRGB(transparentPixel[0]);
+ transRed = rgb.red;
+ transGreen = rgb.green;
+ transBlue = rgb.blue;
+ } else {
+ RGB[] rgbs = palette.getRGBs();
+ if (transparentPixel[0] < rgbs.length) {
+ RGB rgb = rgbs[transparentPixel[0]];
+ transRed = rgb.red;
+ transGreen = rgb.green;
+ transBlue = rgb.blue;
+ }
+ }
+ transparentPixel[0] = ImageData.closestMatch(screenDepth, (byte)transRed, (byte)transGreen, (byte)transBlue,
+ destRedMask, destGreenMask, destBlueMask, destReds, destGreens, destBlues);
+ }
+
+ /* Depth 1 */
+ if (image.depth == 1) {
+ int xImagePtr = OS.XCreateImage(display, visual, 1, OS.XYBitmap, 0, 0, destWidth, destHeight, image.scanlinePad * 8, 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 * xImage.height;
+ int bufPtr = OS.XtMalloc(bufSize);
+ xImage.data = bufPtr;
+ OS.memmove(xImagePtr, xImage, XImage.sizeof);
+ byte[] buf = new byte[bufSize];
+ ImageData.blit(ImageData.BLIT_SRC,
+ image.data, image.depth, image.bytesPerLine, image.getByteOrder(), srcX, srcY, srcWidth, srcHeight, null, null, null,
+ ImageData.ALPHA_OPAQUE, null, 0, srcX, srcY,
+ buf, xImage.bits_per_pixel, xImage.bytes_per_line, xImage.bitmap_bit_order, 0, 0, destWidth, destHeight, null, null, null,
+ flipX, flipY);
+ OS.memmove(xImage.data, buf, bufSize);
+
+ int foreground = 1, background = 0;
+ if (!isMask) {
+ foreground = 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);
+ }
+ }
+ 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, image.scanlinePad * 8, 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 * xImage.height;
+ int bufPtr = OS.XtMalloc(bufSize);
+ xImage.data = bufPtr;
+ OS.memmove(xImagePtr, xImage, XImage.sizeof);
+ byte[] buf = new byte[bufSize];
+ if (palette.isDirect) {
+ if (screenDirect) {
+ ImageData.blit(ImageData.BLIT_SRC,
+ image.data, image.depth, image.bytesPerLine, image.getByteOrder(), srcX, srcY, srcWidth, srcHeight, palette.redMask, palette.greenMask, palette.blueMask,
+ ImageData.ALPHA_OPAQUE, null, 0, srcX, srcY,
+ buf, xImage.bits_per_pixel, xImage.bytes_per_line, xImage.byte_order, 0, 0, destWidth, destHeight, xImage.red_mask, xImage.green_mask, xImage.blue_mask,
+ flipX, flipY);
+ } else {
+ ImageData.blit(ImageData.BLIT_SRC,
+ image.data, image.depth, image.bytesPerLine, image.getByteOrder(), srcX, srcY, srcWidth, srcHeight, palette.redMask, palette.greenMask, palette.blueMask,
+ ImageData.ALPHA_OPAQUE, null, 0, srcX, srcY,
+ buf, xImage.bits_per_pixel, xImage.bytes_per_line, xImage.byte_order, 0, 0, destWidth, destHeight, destReds, destGreens, destBlues,
+ flipX, flipY);
+ }
+ } else {
+ if (screenDirect) {
+ ImageData.blit(ImageData.BLIT_SRC,
+ image.data, image.depth, image.bytesPerLine, image.getByteOrder(), srcX, srcY, srcWidth, srcHeight, srcReds, srcGreens, srcBlues,
+ ImageData.ALPHA_OPAQUE, null, 0, srcX, srcY,
+ buf, xImage.bits_per_pixel, xImage.bytes_per_line, xImage.byte_order, 0, 0, destWidth, destHeight, xImage.red_mask, xImage.green_mask, xImage.blue_mask,
+ flipX, flipY);
+ } else {
+ ImageData.blit(ImageData.BLIT_SRC,
+ image.data, image.depth, image.bytesPerLine, image.getByteOrder(), srcX, srcY, srcWidth, srcHeight, srcReds, srcGreens, srcBlues,
+ ImageData.ALPHA_OPAQUE, null, 0, srcX, srcY,
+ buf, xImage.bits_per_pixel, xImage.bytes_per_line, xImage.byte_order, 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;
+}
+/**
+ * Sets the color to which to map the transparent pixel.
+ * <p>
+ * There are certain uses of <code>Images</code> that do not support
+ * transparency (for example, setting an image into a button or label).
+ * In these cases, it may be desired to simulate transparency by using
+ * the background color of the widget to paint the transparent pixels
+ * of the image. This method specifies the color that will be used in
+ * these cases. For example:
+ * <pre>
+ * Button b = new Button();
+ * image.setBackground(b.getBackground());>
+ * b.setImage(image);
+ * </pre>
+ * </p><p>
+ * The image may be modified by this operation (in effect, the
+ * transparent regions may be filled with the supplied color). Hence
+ * this operation is not reversible and it is not legal to call
+ * this function twice or with a null argument.
+ * </p><p>
+ * This method has no effect if the receiver does not have a transparent
+ * pixel value.
+ * </p>
+ *
+ * @param color the color to use when a transparent pixel is specified
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if the color is null</li>
+ * <li>ERROR_INVALID_ARGUMENT - if the color has been disposed</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
*/
-public void setBackground(Color color) {
- if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- if (color == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
- if (color.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
- if (transparentPixel == -1) return;
- /* 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();
-}
-/**
- * Returns a string containing a concise, human-readable
- * description of the receiver.
- *
- * @return a string representation of the receiver
+public void setBackground(Color color) {
+ if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ if (color == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ if (color.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+ if (transparentPixel == -1) return;
+ /* 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();
+}
+/**
+ * Returns a string containing a concise, human-readable
+ * description of the receiver.
+ *
+ * @return a string representation of the receiver
*/
-public String toString () {
- if (isDisposed()) return "Image {*DISPOSED*}";
- return "Image {" + pixmap + "}";
-}
-}
+public String toString () {
+ if (isDisposed()) return "Image {*DISPOSED*}";
+ return "Image {" + pixmap + "}";
+}
+}
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
index 09ed1152da..e96a080d69 100755
--- 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
@@ -1,15 +1,15 @@
-package org.eclipse.swt.graphics;
-
-/*
+package org.eclipse.swt.graphics;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-import org.eclipse.swt.internal.motif.*;
-import org.eclipse.swt.*;
-
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+import org.eclipse.swt.internal.motif.*;
+import org.eclipse.swt.*;
+
/**
* Instances of this class represent areas of an x-y coordinate
* system that are aggregates of the areas covered by a number
@@ -20,12 +20,12 @@ import org.eclipse.swt.*;
* when those instances are no longer required.
* </p>
*/
-public final class Region {
+public final class Region {
/**
* the OS resource for the region
* (Warning: This field is platform dependent)
*/
- public int handle;
+ public int handle;
/**
* Constructs a new empty region.
*
@@ -33,12 +33,12 @@ public final class Region {
* <li>ERROR_NO_HANDLES if a handle could not be obtained for region creation</li>
* </ul>
*/
-public Region () {
- handle = OS.XCreateRegion ();
-}
-Region (int handle) {
- this.handle = handle;
-}
+public Region () {
+ handle = OS.XCreateRegion ();
+}
+Region (int handle) {
+ this.handle = handle;
+}
/**
* Adds the given rectangle to the collection of rectangles
* the receiver maintains to describe its area.
@@ -53,18 +53,18 @@ Region (int handle) {
* <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
* </ul>
*/
-public void add (Rectangle rect) {
- if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- if (rect == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
- if (rect.width < 0 || rect.height < 0) SWT.error(SWT.ERROR_INVALID_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 (Rectangle rect) {
+ if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ if (rect == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ if (rect.width < 0 || rect.height < 0) SWT.error(SWT.ERROR_INVALID_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);
+}
/**
* Adds all of the rectangles which make up the area covered
* by the argument to the collection of rectangles the receiver
@@ -80,12 +80,12 @@ public void add (Rectangle rect) {
* <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
* </ul>
*/
-public void add (Region region) {
- if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- if (region == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
- if (region.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
- OS.XUnionRegion(handle, region.handle, handle);
-}
+public void add (Region region) {
+ if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ if (region == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ if (region.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+ OS.XUnionRegion(handle, region.handle, handle);
+}
/**
* Returns <code>true</code> if the point specified by the
* arguments is inside the area specified by the receiver,
@@ -99,10 +99,10 @@ public void add (Region region) {
* <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
* </ul>
*/
-public boolean contains (int x, int y) {
- if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- return OS.XPointInRegion(handle, x, y);
-}
+public boolean contains (int x, int y) {
+ if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ return OS.XPointInRegion(handle, x, y);
+}
/**
* Returns <code>true</code> if the given point is inside the
* area specified by the receiver, and <code>false</code>
@@ -118,19 +118,19 @@ public boolean contains (int x, int y) {
* <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
* </ul>
*/
-public boolean contains (Point pt) {
- if (pt == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
- return contains(pt.x, pt.y);
-}
+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.XDestroyRegion(handle);
- handle = 0;
-}
+public void dispose () {
+ if (handle != 0) OS.XDestroyRegion(handle);
+ handle = 0;
+}
/**
* Compares the argument to the receiver, and returns true
* if they represent the <em>same</em> object using a class
@@ -141,12 +141,12 @@ public void dispose () {
*
* @see #hashCode
*/
-public boolean equals (Object object) {
- if (this == object) return true;
- if (!(object instanceof Region)) return false;
- Region region = (Region)object;
- return handle == region.handle;
-}
+public boolean equals (Object object) {
+ if (this == object) return true;
+ if (!(object instanceof Region)) return false;
+ Region region = (Region)object;
+ return handle == region.handle;
+}
/**
* Returns a rectangle which represents the rectangular
* union of the collection of rectangles the receiver
@@ -160,12 +160,12 @@ public boolean equals (Object object) {
*
* @see Rectangle#union
*/
-public Rectangle getBounds() {
- if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- XRectangle rect = new XRectangle();
- OS.XClipBox(handle, rect);
- return new Rectangle(rect.x, rect.y, rect.width, rect.height);
-}
+public Rectangle getBounds() {
+ if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ XRectangle rect = new XRectangle();
+ OS.XClipBox(handle, rect);
+ return new Rectangle(rect.x, rect.y, rect.width, rect.height);
+}
/**
* Returns an integer hash code for the receiver. Any two
* objects which return <code>true</code> when passed to
@@ -176,9 +176,9 @@ public Rectangle getBounds() {
*
* @see #equals
*/
-public int hashCode () {
- return handle;
-}
+public int hashCode () {
+ return handle;
+}
/**
* Returns <code>true</code> if the rectangle described by the
* arguments intersects with any of the rectangles the receiver
@@ -196,10 +196,10 @@ public int hashCode () {
*
* @see Rectangle#intersects
*/
-public boolean intersects (int x, int y, int width, int height) {
- if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- return OS.XRectInRegion (handle, x, y, width, height) != OS.RectangleOut;
-}
+public boolean intersects (int x, int y, int width, int height) {
+ if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ return OS.XRectInRegion (handle, x, y, width, height) != OS.RectangleOut;
+}
/**
* Returns <code>true</code> if the given rectangle intersects
* with any of the rectangles the receiver mainains to describe
@@ -217,10 +217,10 @@ public boolean intersects (int x, int y, int width, int height) {
*
* @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);
-}
+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.
@@ -231,9 +231,9 @@ public boolean intersects (Rectangle rect) {
*
* @return <code>true</code> when the region is disposed, and <code>false</code> otherwise
*/
-public boolean isDisposed() {
- return handle == 0;
-}
+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
@@ -245,21 +245,21 @@ public boolean isDisposed() {
* <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
* </ul>
*/
-public boolean isEmpty () {
- if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- return OS.XEmptyRegion(handle);
-}
-public static Region motif_new(int handle) {
- return new Region(handle);
-}
-/**
- * Returns a string containing a concise, human-readable
- * description of the receiver.
- *
- * @return a string representation of the receiver
+public boolean isEmpty () {
+ if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ return OS.XEmptyRegion(handle);
+}
+public static Region motif_new(int handle) {
+ return new Region(handle);
+}
+/**
+ * Returns a string containing a concise, human-readable
+ * description of the receiver.
+ *
+ * @return a string representation of the receiver
*/
-public String toString () {
- if (isDisposed()) return "Region {*DISPOSED*}";
- return "Region {" + handle + "}";
-}
-}
+public String toString () {
+ if (isDisposed()) return "Region {*DISPOSED*}";
+ return "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
index 49dd363819..8d48870665 100755
--- 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
@@ -1,14 +1,14 @@
-package org.eclipse.swt.internal;
-
-/*
+package org.eclipse.swt.internal;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-import org.eclipse.swt.internal.motif.*;
-
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+import org.eclipse.swt.internal.motif.*;
+
/**
* This class implements the conversions between unicode characters
* and the <em>platform supported</em> representation for characters.
@@ -16,300 +16,300 @@ import org.eclipse.swt.internal.motif.*;
* 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 String CodePage;
- static byte[] Unicode;
-
- static final Object LOCK = new Object ();
-
- /* Converter cache */
- static String LastMBToWCCodePage;
- static String LastWCToMBCodePage;
- static int LastWCToMB;
- static int LastMBToWC;
-
- /* Buffers cache */
- static int BufferSize;
- static int BufferTimes2;
- static int BufferTimes4;
-
- static {
- Unicode = getAsciiBytes("UCS-2");
-
- int length, item = OS.nl_langinfo (OS.CODESET);
- if (item != 0 && (length = OS.strlen (item)) > 0) {
- byte [] buffer = new byte [length];
- OS.memmove (buffer, item, length);
- CodePage = new String (buffer);
- if (OS.IsSunOS) {
- if (length > 3 && CodePage.indexOf ("ISO") == 0) {
- CodePage = CodePage.substring (3, length);
- }
- }
- } else {
- if (OS.IsLinux) CodePage = "ISO-8859-1";
- else if (OS.IsAIX) CodePage = "ISO8859-1";
- else if (OS.IsSunOS) CodePage = "8859-1";
- else CodePage = "iso8859_1";
- }
-
- BufferSize = 512;
- BufferTimes2 = OS.XtMalloc (BufferSize * 2);
- BufferTimes4 = OS.XtMalloc (BufferSize * 4);
- }
-
-/**
- * Returns the default code page for the platform where the
- * application is currently running.
- *
- * @return the default code page
- */
-public static String defaultCodePage () {
- return CodePage;
-}
-
-static byte[] getAsciiBytes (String str) {
- int length = str.length ();
- byte [] buffer = new byte [length + 1];
- for (int i=0; i<length; i++) {
- buffer [i] = (byte)str.charAt (i);
- }
- return buffer;
-}
-
-static String getAsciiString (byte [] buffer) {
- int length = buffer.length;
- char [] chars = new char [length];
- for (int i=0; i<length; i++) {
- chars [i] = (char)buffer [i];
- }
- return new String (chars);
-}
-
-/**
- * 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 (String codePage, byte [] buffer) {
-
- /* Check for the simple cases */
- if (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 [] wideCharStr = new char [length];
- for (int i=0; i<length; i++) {
- if ((buffer [i] & 0xFF) <= 0x7F) {
- wideCharStr [i] = (char) buffer [i]; // all bytes <= 0x7F, so no ((char) (buffer[i]&0xFF)) needed
- } else {
- synchronized (LOCK) {
- String cp = codePage != null ? codePage : CodePage;
- if (LastMBToWC != 0 && !cp.equals (LastMBToWCCodePage)) {
- OS.iconv_close (LastMBToWC);
- LastMBToWC = 0;
- }
- if (LastMBToWC == 0) {
- LastMBToWCCodePage = cp;
- LastMBToWC = OS.iconv_open (Unicode, getAsciiBytes (cp));
- if (LastMBToWC == -1) LastMBToWC = 0;
- }
- int cd = LastMBToWC;
- if (cd == 0) return EMPTY_CHAR_ARRAY;
- int inBytes = length;
- int outBytes = length * 2;
- int ptr1, ptr2;
- if (length <= BufferSize * 2) {
- ptr1 = BufferTimes2;
- ptr2 = BufferTimes4;
- } else {
- ptr1 = OS.XtMalloc (inBytes);
- ptr2 = OS.XtMalloc (outBytes);
- }
- int [] inBuf = {ptr1};
- int [] inBytesLeft = {inBytes};
- int [] outBuf = {ptr2};
- int [] outBytesLeft = {outBytes};
- OS.memmove (ptr1, buffer, inBytes);
- OS.iconv (cd, inBuf, inBytesLeft, outBuf, outBytesLeft);
- outBytes = outBuf [0] - ptr2;
- wideCharStr = new char [outBytes / 2];
- OS.memmove (wideCharStr, ptr2, outBytes);
- if (ptr1 != BufferTimes2) OS.XtFree (ptr1);
- if (ptr2 != BufferTimes4) OS.XtFree (ptr2);
- }
- return wideCharStr;
- }
- }
- return wideCharStr;
-}
-
-/**
- * Free any cached resources.
- */
-public static void release () {
- synchronized (LOCK) {
- if (BufferTimes2 != 0) OS.XtFree (BufferTimes2);
- if (BufferTimes4 != 0) OS.XtFree (BufferTimes4);
- if (LastWCToMB != 0) OS.iconv_close (LastWCToMB);
- if (LastMBToWC != 0) OS.iconv_close (LastMBToWC);
- LastMBToWC = LastWCToMB = BufferTimes4 = BufferTimes2 = 0;
- }
-}
-
-/**
- * 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 (String codePage, char [] buffer) {
- return wcsToMbcs (codePage, 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 (String codePage, char [] buffer, boolean terminate) {
-
- /* Check for the simple cases */
- if (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] & 0xFFFF) <= 0x7F) {
- mbcs [i] = (byte) buffer [i];
- } else {
- synchronized (LOCK) {
- String cp = codePage != null ? codePage : CodePage;
- if (LastWCToMB != 0 && !cp.equals (LastWCToMBCodePage)) {
- OS.iconv_close (LastWCToMB);
- LastWCToMB = 0;
- }
- if (LastWCToMB == 0) {
- LastWCToMBCodePage = cp;
- LastWCToMB = OS.iconv_open (getAsciiBytes (cp), Unicode);
- if (LastWCToMB == -1) LastWCToMB = 0;
- }
- int cd = LastWCToMB;
- if (cd == 0) return (terminate) ? NULL_BYTE_ARRAY : EMPTY_BYTE_ARRAY;
- int inBytes = length * 2;
- int outBytes = length * 4;
- int ptr1, ptr2;
- if (length <= BufferSize) {
- ptr1 = BufferTimes2;
- ptr2 = BufferTimes4;
- } else {
- ptr1 = OS.XtMalloc (inBytes);
- ptr2 = OS.XtMalloc (outBytes);
- }
- int [] inBuf = {ptr1};
- int [] inBytesLeft = {inBytes};
- int [] outBuf = {ptr2};
- int [] outBytesLeft = {outBytes};
- OS.memmove (ptr1, buffer, inBytes);
- while (inBytesLeft [0] > 0) {
- OS.iconv (cd, inBuf, inBytesLeft, outBuf, outBytesLeft);
- if (inBytesLeft [0] != 0) {
- inBuf [0] += 2;
- inBytesLeft [0] -= 2;
- }
- }
- outBytes = outBuf [0] - ptr2;
- mbcs = new byte [terminate ? outBytes + 1 : outBytes];
- OS.memmove (mbcs, ptr2, outBytes);
- if (ptr1 != BufferTimes2) OS.XtFree (ptr1);
- if (ptr2 != BufferTimes4) OS.XtFree (ptr2);
- }
- return mbcs;
- }
- }
- 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 (String codePage, String string) {
- return wcsToMbcs (codePage, 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 (String 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);
- }
-}
-
-}
+ */
+
+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 String CodePage;
+ static byte[] Unicode;
+
+ static final Object LOCK = new Object ();
+
+ /* Converter cache */
+ static String LastMBToWCCodePage;
+ static String LastWCToMBCodePage;
+ static int LastWCToMB;
+ static int LastMBToWC;
+
+ /* Buffers cache */
+ static int BufferSize;
+ static int BufferTimes2;
+ static int BufferTimes4;
+
+ static {
+ Unicode = getAsciiBytes("UCS-2");
+
+ int length, item = OS.nl_langinfo (OS.CODESET);
+ if (item != 0 && (length = OS.strlen (item)) > 0) {
+ byte [] buffer = new byte [length];
+ OS.memmove (buffer, item, length);
+ CodePage = new String (buffer);
+ if (OS.IsSunOS) {
+ if (length > 3 && CodePage.indexOf ("ISO") == 0) {
+ CodePage = CodePage.substring (3, length);
+ }
+ }
+ } else {
+ if (OS.IsLinux) CodePage = "ISO-8859-1";
+ else if (OS.IsAIX) CodePage = "ISO8859-1";
+ else if (OS.IsSunOS) CodePage = "8859-1";
+ else CodePage = "iso8859_1";
+ }
+
+ BufferSize = 512;
+ BufferTimes2 = OS.XtMalloc (BufferSize * 2);
+ BufferTimes4 = OS.XtMalloc (BufferSize * 4);
+ }
+
+/**
+ * Returns the default code page for the platform where the
+ * application is currently running.
+ *
+ * @return the default code page
+ */
+public static String defaultCodePage () {
+ return CodePage;
+}
+
+static byte[] getAsciiBytes (String str) {
+ int length = str.length ();
+ byte [] buffer = new byte [length + 1];
+ for (int i=0; i<length; i++) {
+ buffer [i] = (byte)str.charAt (i);
+ }
+ return buffer;
+}
+
+static String getAsciiString (byte [] buffer) {
+ int length = buffer.length;
+ char [] chars = new char [length];
+ for (int i=0; i<length; i++) {
+ chars [i] = (char)buffer [i];
+ }
+ return new String (chars);
+}
+
+/**
+ * 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 (String codePage, byte [] buffer) {
+
+ /* Check for the simple cases */
+ if (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 [] wideCharStr = new char [length];
+ for (int i=0; i<length; i++) {
+ if ((buffer [i] & 0xFF) <= 0x7F) {
+ wideCharStr [i] = (char) buffer [i]; // all bytes <= 0x7F, so no ((char) (buffer[i]&0xFF)) needed
+ } else {
+ synchronized (LOCK) {
+ String cp = codePage != null ? codePage : CodePage;
+ if (LastMBToWC != 0 && !cp.equals (LastMBToWCCodePage)) {
+ OS.iconv_close (LastMBToWC);
+ LastMBToWC = 0;
+ }
+ if (LastMBToWC == 0) {
+ LastMBToWCCodePage = cp;
+ LastMBToWC = OS.iconv_open (Unicode, getAsciiBytes (cp));
+ if (LastMBToWC == -1) LastMBToWC = 0;
+ }
+ int cd = LastMBToWC;
+ if (cd == 0) return EMPTY_CHAR_ARRAY;
+ int inBytes = length;
+ int outBytes = length * 2;
+ int ptr1, ptr2;
+ if (length <= BufferSize * 2) {
+ ptr1 = BufferTimes2;
+ ptr2 = BufferTimes4;
+ } else {
+ ptr1 = OS.XtMalloc (inBytes);
+ ptr2 = OS.XtMalloc (outBytes);
+ }
+ int [] inBuf = {ptr1};
+ int [] inBytesLeft = {inBytes};
+ int [] outBuf = {ptr2};
+ int [] outBytesLeft = {outBytes};
+ OS.memmove (ptr1, buffer, inBytes);
+ OS.iconv (cd, inBuf, inBytesLeft, outBuf, outBytesLeft);
+ outBytes = outBuf [0] - ptr2;
+ wideCharStr = new char [outBytes / 2];
+ OS.memmove (wideCharStr, ptr2, outBytes);
+ if (ptr1 != BufferTimes2) OS.XtFree (ptr1);
+ if (ptr2 != BufferTimes4) OS.XtFree (ptr2);
+ }
+ return wideCharStr;
+ }
+ }
+ return wideCharStr;
+}
+
+/**
+ * Free any cached resources.
+ */
+public static void release () {
+ synchronized (LOCK) {
+ if (BufferTimes2 != 0) OS.XtFree (BufferTimes2);
+ if (BufferTimes4 != 0) OS.XtFree (BufferTimes4);
+ if (LastWCToMB != 0) OS.iconv_close (LastWCToMB);
+ if (LastMBToWC != 0) OS.iconv_close (LastMBToWC);
+ LastMBToWC = LastWCToMB = BufferTimes4 = BufferTimes2 = 0;
+ }
+}
+
+/**
+ * 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 (String codePage, char [] buffer) {
+ return wcsToMbcs (codePage, 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 (String codePage, char [] buffer, boolean terminate) {
+
+ /* Check for the simple cases */
+ if (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] & 0xFFFF) <= 0x7F) {
+ mbcs [i] = (byte) buffer [i];
+ } else {
+ synchronized (LOCK) {
+ String cp = codePage != null ? codePage : CodePage;
+ if (LastWCToMB != 0 && !cp.equals (LastWCToMBCodePage)) {
+ OS.iconv_close (LastWCToMB);
+ LastWCToMB = 0;
+ }
+ if (LastWCToMB == 0) {
+ LastWCToMBCodePage = cp;
+ LastWCToMB = OS.iconv_open (getAsciiBytes (cp), Unicode);
+ if (LastWCToMB == -1) LastWCToMB = 0;
+ }
+ int cd = LastWCToMB;
+ if (cd == 0) return (terminate) ? NULL_BYTE_ARRAY : EMPTY_BYTE_ARRAY;
+ int inBytes = length * 2;
+ int outBytes = length * 4;
+ int ptr1, ptr2;
+ if (length <= BufferSize) {
+ ptr1 = BufferTimes2;
+ ptr2 = BufferTimes4;
+ } else {
+ ptr1 = OS.XtMalloc (inBytes);
+ ptr2 = OS.XtMalloc (outBytes);
+ }
+ int [] inBuf = {ptr1};
+ int [] inBytesLeft = {inBytes};
+ int [] outBuf = {ptr2};
+ int [] outBytesLeft = {outBytes};
+ OS.memmove (ptr1, buffer, inBytes);
+ while (inBytesLeft [0] > 0) {
+ OS.iconv (cd, inBuf, inBytesLeft, outBuf, outBytesLeft);
+ if (inBytesLeft [0] != 0) {
+ inBuf [0] += 2;
+ inBytesLeft [0] -= 2;
+ }
+ }
+ outBytes = outBuf [0] - ptr2;
+ mbcs = new byte [terminate ? outBytes + 1 : outBytes];
+ OS.memmove (mbcs, ptr2, outBytes);
+ if (ptr1 != BufferTimes2) OS.XtFree (ptr1);
+ if (ptr2 != BufferTimes4) OS.XtFree (ptr2);
+ }
+ return mbcs;
+ }
+ }
+ 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 (String codePage, String string) {
+ return wcsToMbcs (codePage, 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 (String 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/motif/org/eclipse/swt/widgets/Button.java b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Button.java
index b79ce639ca..8fe272413f 100755
--- 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
@@ -1,18 +1,18 @@
-package org.eclipse.swt.widgets;
-
-/*
+package org.eclipse.swt.widgets;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-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.*;
-
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+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.*;
+
/**
* Instances of this class represent a selectable user interface object that
* issues notification when pressed and released.
@@ -36,20 +36,20 @@ import org.eclipse.swt.events.*;
* within the SWT implementation.
* </p>
*/
-public 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;
- }
+public 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;
+ }
/**
* Constructs a new instance of this class given its parent
* and a style value describing its behavior and appearance.
@@ -86,234 +86,234 @@ public class Button extends Control {
* @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.
- * <p>
- * <code>widgetSelected</code> is called when the control is selected.
- * <code>widgetDefaultSelected</code> is not called.
- * </p>
- *
- * @param listener the listener which should be notified
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see SelectionListener
- * @see #removeSelectionListener
- * @see SelectionEvent
+public 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.
+ * <p>
+ * <code>widgetSelected</code> is called when the control is selected.
+ * <code>widgetDefaultSelected</code> is not called.
+ * </p>
+ *
+ * @param listener the listener which should be notified
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see SelectionListener
+ * @see #removeSelectionListener
+ * @see SelectionEvent
*/
-public void addSelectionListener(SelectionListener listener) {
- checkWidget();
- if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
- TypedListener typedListener = new TypedListener(listener);
- addListener(SWT.Selection,typedListener);
- addListener(SWT.DefaultSelection,typedListener);
-}
-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);
-}
-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) {
- Display display = getDisplay ();
- width += display.scrolledMarginX;
- height += display.scrolledMarginY;
- 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.
+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) {
+ 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);
+}
+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) {
+ Display display = getDisplay ();
+ width += display.scrolledMarginX;
+ height += display.scrolledMarginY;
+ 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 ();
- if (xmString != 0) OS.XmStringFree (xmString);
- }
- 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;
- int parentHandle = parent.handle;
-
- /* 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,
- OS.XmNancestorSensitive, 1,
- };
- handle = OS.XmCreateArrowButton (parentHandle, null, argList, argList.length / 2);
- if (handle == 0) error (SWT.ERROR_NO_HANDLES);
- if ((style & SWT.FLAT) != 0) {
- int [] argList1 = {OS.XmNbottomShadowColor, 0};
- OS.XtGetValues (handle, argList1, argList1.length / 2);
- int [] argList2 = {
- OS.XmNshadowThickness, 1,
- OS.XmNtopShadowColor, argList1 [1],
- };
- OS.XtSetValues (handle, argList2, argList2.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.
- */
- Display display = getDisplay ();
- int thickness = display.buttonShadowThickness;
- int [] argList = {
- OS.XmNancestorSensitive, 1,
- OS.XmNrecomputeSize, 0,
- OS.XmNindicatorOn, 0,
- OS.XmNshadowThickness, (style & SWT.FLAT) != 0 ? 1 : thickness,
- OS.XmNalignment, alignment,
- OS.XmNborderWidth, borderWidth,
- };
- handle = OS.XmCreateToggleButton (parentHandle, null, argList, argList.length / 2);
- if (handle == 0) error (SWT.ERROR_NO_HANDLES);
- if ((style & SWT.FLAT) != 0) {
- int [] argList1 = {OS.XmNbottomShadowColor, 0};
- OS.XtGetValues (handle, argList1, argList1.length / 2);
- int [] argList2 = {OS.XmNtopShadowColor, argList1 [1]};
- OS.XtSetValues (handle, argList2, argList2.length / 2);
- }
- 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.XmNancestorSensitive, 1,
- OS.XmNrecomputeSize, 0,
- OS.XmNindicatorType, indicatorType,
- OS.XmNalignment, alignment,
- OS.XmNborderWidth, borderWidth,
- };
- handle = OS.XmCreateToggleButton (parentHandle, null, argList, argList.length / 2);
- if (handle == 0) error (SWT.ERROR_NO_HANDLES);
- return;
- }
-
- /* PUSH button */
- int [] argList = {
- OS.XmNancestorSensitive, 1,
- OS.XmNrecomputeSize, 0,
- OS.XmNalignment, alignment,
- OS.XmNborderWidth, borderWidth,
- /*
- * This code is intentionally commented. On some
- * platforms, the standard behavior is that push
- * buttons are tab groups, traversed with the tab
- * key. On Motif, push buttons are tab items,
- * that are traversed with the arrow keys. This
- * behavior is unspecifed so the line remains
- * commented.
- */
-// OS.XmNnavigationType, OS.XmTAB_GROUP,
- };
- handle = OS.XmCreatePushButton (parentHandle, null, argList, argList.length / 2);
- if (handle == 0) error (SWT.ERROR_NO_HANDLES);
- if ((style & SWT.FLAT) != 0) {
- int [] argList1 = {OS.XmNbottomShadowColor, 0};
- OS.XtGetValues (handle, argList1, argList1.length / 2);
- int [] argList2 = {
- OS.XmNshadowThickness, 1,
- OS.XmNtopShadowColor, argList1 [1],
- };
- OS.XtSetValues (handle, argList2, argList2.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;
-}
-Font defaultFont () {
- return getDisplay ().buttonFont;
-}
-int defaultForeground () {
- return getDisplay ().buttonForeground;
-}
+ 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 (xmString != 0) OS.XmStringFree (xmString);
+ }
+ 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;
+ int parentHandle = parent.handle;
+
+ /* 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,
+ OS.XmNancestorSensitive, 1,
+ };
+ handle = OS.XmCreateArrowButton (parentHandle, null, argList, argList.length / 2);
+ if (handle == 0) error (SWT.ERROR_NO_HANDLES);
+ if ((style & SWT.FLAT) != 0) {
+ int [] argList1 = {OS.XmNbottomShadowColor, 0};
+ OS.XtGetValues (handle, argList1, argList1.length / 2);
+ int [] argList2 = {
+ OS.XmNshadowThickness, 1,
+ OS.XmNtopShadowColor, argList1 [1],
+ };
+ OS.XtSetValues (handle, argList2, argList2.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.
+ */
+ Display display = getDisplay ();
+ int thickness = display.buttonShadowThickness;
+ int [] argList = {
+ OS.XmNancestorSensitive, 1,
+ OS.XmNrecomputeSize, 0,
+ OS.XmNindicatorOn, 0,
+ OS.XmNshadowThickness, (style & SWT.FLAT) != 0 ? 1 : thickness,
+ OS.XmNalignment, alignment,
+ OS.XmNborderWidth, borderWidth,
+ };
+ handle = OS.XmCreateToggleButton (parentHandle, null, argList, argList.length / 2);
+ if (handle == 0) error (SWT.ERROR_NO_HANDLES);
+ if ((style & SWT.FLAT) != 0) {
+ int [] argList1 = {OS.XmNbottomShadowColor, 0};
+ OS.XtGetValues (handle, argList1, argList1.length / 2);
+ int [] argList2 = {OS.XmNtopShadowColor, argList1 [1]};
+ OS.XtSetValues (handle, argList2, argList2.length / 2);
+ }
+ 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.XmNancestorSensitive, 1,
+ OS.XmNrecomputeSize, 0,
+ OS.XmNindicatorType, indicatorType,
+ OS.XmNalignment, alignment,
+ OS.XmNborderWidth, borderWidth,
+ };
+ handle = OS.XmCreateToggleButton (parentHandle, null, argList, argList.length / 2);
+ if (handle == 0) error (SWT.ERROR_NO_HANDLES);
+ return;
+ }
+
+ /* PUSH button */
+ int [] argList = {
+ OS.XmNancestorSensitive, 1,
+ OS.XmNrecomputeSize, 0,
+ OS.XmNalignment, alignment,
+ OS.XmNborderWidth, borderWidth,
+ /*
+ * This code is intentionally commented. On some
+ * platforms, the standard behavior is that push
+ * buttons are tab groups, traversed with the tab
+ * key. On Motif, push buttons are tab items,
+ * that are traversed with the arrow keys. This
+ * behavior is unspecifed so the line remains
+ * commented.
+ */
+// OS.XmNnavigationType, OS.XmTAB_GROUP,
+ };
+ handle = OS.XmCreatePushButton (parentHandle, null, argList, argList.length / 2);
+ if (handle == 0) error (SWT.ERROR_NO_HANDLES);
+ if ((style & SWT.FLAT) != 0) {
+ int [] argList1 = {OS.XmNbottomShadowColor, 0};
+ OS.XtGetValues (handle, argList1, argList1.length / 2);
+ int [] argList2 = {
+ OS.XmNshadowThickness, 1,
+ OS.XmNtopShadowColor, argList1 [1],
+ };
+ OS.XtSetValues (handle, argList2, argList2.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;
+}
+Font defaultFont () {
+ return getDisplay ().buttonFont;
+}
+int defaultForeground () {
+ return getDisplay ().buttonForeground;
+}
/**
* Returns a value which describes the position of the
* text or image in the receiver. The value will be one of
@@ -330,50 +330,50 @@ int defaultForeground () {
* <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) {
- 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;
-}
-/**
- * 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 int getAlignment () {
+ checkWidget();
+ 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;
+}
+/**
+ * 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 ();
-}
+public Image getImage () {
+ checkWidget();
+ return image;
+}
+String getNameText () {
+ return getText ();
+}
/**
* Returns <code>true</code> if the receiver is selected,
* and false otherwise.
@@ -390,148 +390,148 @@ String getNameText () {
* <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 [] argList = {OS.XmNset, 0};
- OS.XtGetValues (handle, argList, argList.length / 2);
- return argList [1] != OS.XmUNSET;
-}
-/**
- * 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 boolean getSelection () {
+ checkWidget();
+ 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] != OS.XmUNSET;
+}
+/**
+ * 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();
- 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];
- int mnemonic = argList [3];
- if (mnemonic == OS.XK_VoidSymbol) mnemonic = 0;
- 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 (getCodePage (), buffer);
- }
- 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 windowProc = getDisplay ().windowProc;
- if ((style & (SWT.CHECK | SWT.RADIO | SWT.TOGGLE)) != 0) {
- OS.XtAddCallback (handle, OS.XmNvalueChangedCallback, windowProc, VALUE_CHANGED_CALLBACK);
- } else {
- OS.XtAddCallback (handle, OS.XmNactivateCallback, windowProc, ACTIVATE_CALLBACK);
- }
-
-}
-boolean mnemonicHit (char key) {
- 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);
-}
-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 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 String getText () {
+ checkWidget();
+ 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];
+ int mnemonic = argList [3];
+ if (mnemonic == OS.XK_VoidSymbol) mnemonic = 0;
+ 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 (getCodePage (), buffer);
+ }
+ 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 windowProc = getDisplay ().windowProc;
+ if ((style & (SWT.CHECK | SWT.RADIO | SWT.TOGGLE)) != 0) {
+ OS.XtAddCallback (handle, OS.XmNvalueChangedCallback, windowProc, VALUE_CHANGED_CALLBACK);
+ } else {
+ OS.XtAddCallback (handle, OS.XmNactivateCallback, windowProc, ACTIVATE_CALLBACK);
+ }
+
+}
+boolean mnemonicHit (char key) {
+ 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);
+}
+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 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 () {
- /*
- * This code is intentionally commented. When two groups
- * of radio buttons with the same parent are separated by
- * another control, the correct behavior should be that
- * the two groups act independently. This is consistent
- * with radio tool and menu items. The commented code
- * implements this behavior.
- */
-// int index = 0;
-// Control [] children = parent._getChildren ();
-// while (index < children.length && children [index] != this) index++;
-// int i = index - 1;
-// while (i >= 0 && children [i].setRadioSelection (false)) --i;
-// int j = index + 1;
-// while (j < children.length && children [j].setRadioSelection (false)) j++;
-// setSelection (true);
- Control [] children = parent._getChildren ();
- for (int i=0; i<children.length; i++) {
- Control child = children [i];
- if (this != child) child.setRadioSelection (false);
- }
- setSelection (true);
-}
+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 () {
+ /*
+ * This code is intentionally commented. When two groups
+ * of radio buttons with the same parent are separated by
+ * another control, the correct behavior should be that
+ * the two groups act independently. This is consistent
+ * with radio tool and menu items. The commented code
+ * implements this behavior.
+ */
+// int index = 0;
+// Control [] children = parent._getChildren ();
+// while (index < children.length && children [index] != this) index++;
+// int i = index - 1;
+// while (i >= 0 && children [i].setRadioSelection (false)) --i;
+// int j = index + 1;
+// while (j < children.length && children [j].setRadioSelection (false)) j++;
+// setSelection (true);
+ Control [] children = parent._getChildren ();
+ for (int i=0; i<children.length; i++) {
+ Control child = children [i];
+ if (this != child) child.setRadioSelection (false);
+ }
+ setSelection (true);
+}
/**
* Controls how text, images and arrows will be displayed
* in the receiver. The argument should be one of
@@ -548,99 +548,99 @@ void selectRadio () {
* <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) {
- 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) {
- if (image.isDisposed()) error(SWT.ERROR_INVALID_ARGUMENT);
- 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 receiver's image to the argument, which may be
- * null indicating that no image should be displayed.
- *
- * @param image the image to display on the receiver (may be null)
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_INVALID_ARGUMENT - if the image has been disposed</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
+public void setAlignment (int alignment) {
+ checkWidget();
+ 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) {
+ if (image.isDisposed()) error(SWT.ERROR_INVALID_ARGUMENT);
+ 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 receiver's image to the argument, which may be
+ * null indicating that no image should be displayed.
+ *
+ * @param image the image to display on the receiver (may be null)
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_INVALID_ARGUMENT - if the image has been disposed</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
*/
-public void setImage (Image image) {
- checkWidget();
- setBitmap (this.image = image);
-}
-boolean setRadioSelection (boolean value) {
- if ((style & SWT.RADIO) == 0) return false;
- if (getSelection () != value) {
- setSelection (value);
- postEvent (SWT.Selection);
- }
- return true;
-}
+public void setImage (Image image) {
+ checkWidget();
+ setBitmap (this.image = image);
+}
+boolean setRadioSelection (boolean value) {
+ if ((style & SWT.RADIO) == 0) return false;
+ if (getSelection () != value) {
+ setSelection (value);
+ postEvent (SWT.Selection);
+ }
+ return true;
+}
/**
* Sets the selection state of the receiver, if it is of type <code>CHECK</code>,
* <code>RADIO</code>, or <code>TOGGLE</code>.
@@ -657,108 +657,108 @@ boolean setRadioSelection (boolean value) {
* <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 [] argList = {OS.XmNset, selected ? OS.XmSET : OS.XmUNSET};
- OS.XtSetValues (handle, argList, argList.length / 2);
- updateShadows ();
-}
-/**
- * Sets the receiver's text.
- * <p>
- * This method sets the button label. The label may include
- * the mnemonic character but must not contain line delimiters.
- * </p>
- *
- * @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 setSelection (boolean selected) {
+ checkWidget();
+ if ((style & (SWT.CHECK | SWT.RADIO | SWT.TOGGLE)) == 0) return;
+ int [] argList = {OS.XmNset, selected ? OS.XmSET : OS.XmUNSET};
+ OS.XtSetValues (handle, argList, argList.length / 2);
+ updateShadows ();
+}
+/**
+ * Sets the receiver's text.
+ * <p>
+ * This method sets the button label. The label may include
+ * the mnemonic character but must not contain line delimiters.
+ * </p>
+ *
+ * @param string the new text
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if the text is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
*/
-public void setText (String string) {
- checkWidget();
- if (string == null) error (SWT.ERROR_NULL_ARGUMENT);
- if ((style & SWT.ARROW) != 0) return;
- 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 (getCodePage (), 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);
- if (mnemonic == 0) mnemonic = OS.XK_VoidSymbol;
- 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);
-}
-int traversalCode (int key, XKeyEvent xEvent) {
- return super.traversalCode (key, xEvent) | SWT.TRAVERSE_MNEMONIC;
-}
-void updateShadows () {
- if ((style & SWT.FLAT) != 0 && (style & SWT.TOGGLE) != 0) {
- int [] argList1 = {OS.XmNset, 0};
- OS.XtGetValues (handle, argList1, argList1.length / 2);
- Display display = getDisplay ();
- int pixel = argList1 [1] == OS.XmUNSET ? display.compositeBottomShadow : display.compositeTopShadow;
- int [] argList2 = {OS.XmNtopShadowColor, pixel};
- OS.XtSetValues (handle, argList2, argList2.length / 2);
- }
-}
-int xFocusIn () {
- super.xFocusIn ();
- // widget could be disposed at this point
- if (handle == 0) return 0;
- if ((style & SWT.PUSH) != 0) {
- menuShell ().setDefaultButton (this, false);
- }
- return 0;
-}
-int xFocusOut () {
- super.xFocusOut ();
- // widget could be disposed at this point
- if (handle == 0) return 0;
- if ((style & SWT.PUSH) != 0 && getDefault ()) {
- menuShell ().setDefaultButton (null, false);
- }
- return 0;
-}
-int XmNactivateCallback (int w, int client_data, int call_data) {
- postEvent (SWT.Selection);
- return 0;
-}
-int XmNvalueChangedCallback (int w, int client_data, int call_data) {
- if ((style & SWT.RADIO) != 0) {
- if ((parent.getStyle () & SWT.NO_RADIO_GROUP) == 0) {
- selectRadio ();
- }
- }
- updateShadows ();
- postEvent (SWT.Selection);
- return 0;
-}
+public void setText (String string) {
+ checkWidget();
+ 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 (getCodePage (), 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);
+ if (mnemonic == 0) mnemonic = OS.XK_VoidSymbol;
+ 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);
+}
+int traversalCode (int key, XKeyEvent xEvent) {
+ return super.traversalCode (key, xEvent) | SWT.TRAVERSE_MNEMONIC;
+}
+void updateShadows () {
+ if ((style & SWT.FLAT) != 0 && (style & SWT.TOGGLE) != 0) {
+ int [] argList1 = {OS.XmNset, 0};
+ OS.XtGetValues (handle, argList1, argList1.length / 2);
+ Display display = getDisplay ();
+ int pixel = argList1 [1] == OS.XmUNSET ? display.compositeBottomShadow : display.compositeTopShadow;
+ int [] argList2 = {OS.XmNtopShadowColor, pixel};
+ OS.XtSetValues (handle, argList2, argList2.length / 2);
+ }
+}
+int xFocusIn () {
+ super.xFocusIn ();
+ // widget could be disposed at this point
+ if (handle == 0) return 0;
+ if ((style & SWT.PUSH) != 0) {
+ menuShell ().setDefaultButton (this, false);
+ }
+ return 0;
+}
+int xFocusOut () {
+ super.xFocusOut ();
+ // widget could be disposed at this point
+ if (handle == 0) return 0;
+ if ((style & SWT.PUSH) != 0 && getDefault ()) {
+ menuShell ().setDefaultButton (null, false);
+ }
+ return 0;
+}
+int XmNactivateCallback (int w, int client_data, int call_data) {
+ postEvent (SWT.Selection);
+ return 0;
+}
+int XmNvalueChangedCallback (int w, int client_data, int call_data) {
+ if ((style & SWT.RADIO) != 0) {
+ if ((parent.getStyle () & SWT.NO_RADIO_GROUP) == 0) {
+ selectRadio ();
+ }
+ }
+ updateShadows ();
+ postEvent (SWT.Selection);
+ return 0;
+}
} \ No newline at end of file
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
index 3bb6190123..04a8f715d1 100755
--- 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
@@ -1,41 +1,41 @@
-package org.eclipse.swt.widgets;
-
-/*
+package org.eclipse.swt.widgets;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-import org.eclipse.swt.internal.motif.*;
-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 aggregates of other controls. That is, they are either
- * painted using SWT graphics calls or are handled by native
- * methods.
- * </p>
- *
- * @see Composite
+ * http://www.eclipse.org/legal/cpl-v10.html
*/
-public class Canvas extends Composite {
- Caret caret;
-
-Canvas () {
- /* Do nothing */
-}
+
+import org.eclipse.swt.internal.motif.*;
+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 aggregates 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;
+
+Canvas () {
+ /* Do nothing */
+}
/**
* Constructs a new instance of this class given its parent
* and a style value describing its behavior and appearance.
@@ -64,188 +64,188 @@ Canvas () {
* @see Widget#checkSubclass
* @see Widget#getStyle
*/
-public Canvas (Composite parent, int style) {
- super (parent, style);
-}
-/**
- * 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 Canvas (Composite parent, int style) {
+ super (parent, style);
+}
+/**
+ * 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;
-}
-
-short [] getIMCaretPos () {
- if (caret == null) return super.getIMCaretPos ();
- int width = caret.width;
- if (width <= 0) width = 2;
- return new short[]{(short) (caret.x + width), (short) (caret.y + caret.height)};
-}
-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.releaseResources ();
- 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 Caret getCaret () {
+ checkWidget();
+ return caret;
+}
+
+short [] getIMCaretPos () {
+ if (caret == null) return super.getIMCaretPos ();
+ int width = caret.width;
+ if (width <= 0) width = 2;
+ return new short[]{(short) (caret.x + width), (short) (caret.y + caret.height)};
+}
+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.releaseResources ();
+ 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();
- 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 ();
-}
-/**
- * Sets the receiver's caret.
- * <p>
- * The caret for the control is automatically hidden
- * and shown when the control is painted or resized,
- * when focus is gained or lost and when an the control
- * is scrolled. To avoid drawing on top of the caret,
- * the programmer must hide and show the caret when
- * drawing in the window any other time.
- * </p>
- * @param caret the new caret for the receiver, may be null
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_INVALID_ARGUMENT - if the caret has been disposed</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
+public void scroll (int destX, int destY, int x, int y, int width, int height, boolean all) {
+ checkWidget();
+ 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 ();
+}
+/**
+ * Sets the receiver's caret.
+ * <p>
+ * The caret for the control is automatically hidden
+ * and shown when the control is painted or resized,
+ * when focus is gained or lost and when an the control
+ * is scrolled. To avoid drawing on top of the caret,
+ * the programmer must hide and show the caret when
+ * drawing in the window any other time.
+ * </p>
+ * @param caret the new caret for the receiver, may be null
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_INVALID_ARGUMENT - if the caret has been disposed</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
*/
-public void setCaret (Caret caret) {
- checkWidget();
- Caret newCaret = caret;
- Caret oldCaret = this.caret;
- this.caret = newCaret;
- if (hasFocus ()) {
- if (oldCaret != null) oldCaret.killFocus ();
- if (newCaret != null) {
- if (newCaret.isDisposed()) error(SWT.ERROR_INVALID_ARGUMENT);
- newCaret.setFocus ();
- }
- }
-}
-boolean setBounds (int x, int y, int width, int height, boolean move, boolean resize) {
- boolean isFocus = caret != null && caret.isFocusCaret ();
- if (isFocus) caret.killFocus ();
- boolean changed = super.setBounds (x, y, width, height, move, resize);
- if (isFocus) caret.setFocus ();
- return changed;
-}
-public void setFont (Font font) {
- checkWidget();
- super.setFont (font);
- if (caret != null) caret.setFont (font);
-}
-void updateCaret () {
- if (caret == null) return;
- if (!OS.IsDBLocale) return;
- short [] point = getIMCaretPos ();
- int ptr = OS.XtMalloc (4);
- OS.memmove (ptr, point, 4);
- int[] argList = {OS.XmNspotLocation, ptr};
- OS.XmImSetValues (handle, argList, argList.length / 2);
- if (ptr != 0) OS.XtFree (ptr);
-}
-int XExposure (int w, int client_data, int call_data, int continue_to_dispatch) {
- boolean isFocus = caret != null && caret.isFocusCaret ();
- if (isFocus) caret.killFocus ();
- int result = super.XExposure (w, client_data, call_data, continue_to_dispatch);
- if (isFocus) caret.setFocus ();
- return result;
-}
-int xFocusIn () {
- int result = super.xFocusIn ();
- if (caret != null) caret.setFocus ();
- return result;
-}
-int xFocusOut () {
- int result = super.xFocusOut ();
- if (caret != null) caret.killFocus ();
- return result;
-}
-}
+public void setCaret (Caret caret) {
+ checkWidget();
+ Caret newCaret = caret;
+ Caret oldCaret = this.caret;
+ this.caret = newCaret;
+ if (hasFocus ()) {
+ if (oldCaret != null) oldCaret.killFocus ();
+ if (newCaret != null) {
+ if (newCaret.isDisposed()) error(SWT.ERROR_INVALID_ARGUMENT);
+ newCaret.setFocus ();
+ }
+ }
+}
+boolean setBounds (int x, int y, int width, int height, boolean move, boolean resize) {
+ boolean isFocus = caret != null && caret.isFocusCaret ();
+ if (isFocus) caret.killFocus ();
+ boolean changed = super.setBounds (x, y, width, height, move, resize);
+ if (isFocus) caret.setFocus ();
+ return changed;
+}
+public void setFont (Font font) {
+ checkWidget();
+ super.setFont (font);
+ if (caret != null) caret.setFont (font);
+}
+void updateCaret () {
+ if (caret == null) return;
+ if (!OS.IsDBLocale) return;
+ short [] point = getIMCaretPos ();
+ int ptr = OS.XtMalloc (4);
+ OS.memmove (ptr, point, 4);
+ int[] argList = {OS.XmNspotLocation, ptr};
+ OS.XmImSetValues (handle, argList, argList.length / 2);
+ if (ptr != 0) OS.XtFree (ptr);
+}
+int XExposure (int w, int client_data, int call_data, int continue_to_dispatch) {
+ boolean isFocus = caret != null && caret.isFocusCaret ();
+ if (isFocus) caret.killFocus ();
+ int result = super.XExposure (w, client_data, call_data, continue_to_dispatch);
+ if (isFocus) caret.setFocus ();
+ return result;
+}
+int xFocusIn () {
+ int result = super.xFocusIn ();
+ if (caret != null) caret.setFocus ();
+ return result;
+}
+int xFocusOut () {
+ int result = super.xFocusOut ();
+ if (caret != null) caret.killFocus ();
+ return result;
+}
+}
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
index bf3179bf36..cfd6c68efd 100755
--- 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
@@ -1,37 +1,37 @@
-package org.eclipse.swt.widgets;
-
-/*
+package org.eclipse.swt.widgets;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-import org.eclipse.swt.internal.motif.*;
-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>
+ * http://www.eclipse.org/legal/cpl-v10.html
*/
-public class Caret extends Widget {
- Canvas parent;
- int x, y, width, height;
- boolean isVisible, isShowing;
- int blinkRate = 500;
- Image image;
- Font font;
+
+import org.eclipse.swt.internal.motif.*;
+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 isVisible, isShowing;
+ int blinkRate = 500;
+ Image image;
+ Font font;
/**
* Constructs a new instance of this class given its parent
* and a style value describing its behavior and appearance.
@@ -60,424 +60,424 @@ public class Caret extends Widget {
* @see Widget#checkSubclass
* @see Widget#getStyle
*/
-public Caret (Canvas parent, int style) {
- super (parent, style);
- this.parent = parent;
- createWidget (0);
-}
-boolean blinkCaret () {
- if (!isVisible) return true;
- if (!isShowing) return showCaret ();
- if (blinkRate == 0) return true;
- return hideCaret ();
-}
-void createWidget (int index) {
- super.createWidget (index);
- 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 color;
- if (OS.IsSunOS) {
- int [] argList = {OS.XmNforeground, 0, OS.XmNbackground, 0};
- OS.XtGetValues (handle, argList, argList.length / 2);
- int foreground = argList [1];
- int background = argList [3];
- color = foreground ^ background;
- } else {
- int screenNum = OS.XDefaultScreen (xDisplay);
- color = OS.XWhitePixel(xDisplay, screenNum);
- }
- OS.XSetForeground (xDisplay, gc, color);
- OS.XSetFunction (xDisplay, gc, OS.GXxor);
- int nWidth = width, nHeight = height;
- if (image != null) {
- Rectangle rect = image.getBounds ();
- nWidth = rect.width;
- nHeight = rect.height;
- }
- if (nWidth <= 0) nWidth = 2;
- OS.XFillRectangle (xDisplay, window, gc, x, y, nWidth, nHeight);
- OS.XFreeGC (xDisplay, gc);
- return true;
-}
-/**
- * Returns a rectangle describing the receiver's size and location
- * relative to its parent (or its display if its parent is null).
- *
- * @return the receiver's bounding rectangle
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
+public 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 color;
+ if (OS.IsSunOS) {
+ int [] argList = {OS.XmNforeground, 0, OS.XmNbackground, 0};
+ OS.XtGetValues (handle, argList, argList.length / 2);
+ int foreground = argList [1];
+ int background = argList [3];
+ color = foreground ^ background;
+ } else {
+ int screenNum = OS.XDefaultScreen (xDisplay);
+ color = OS.XWhitePixel(xDisplay, screenNum);
+ }
+ OS.XSetForeground (xDisplay, gc, color);
+ OS.XSetFunction (xDisplay, gc, OS.GXxor);
+ int nWidth = width, nHeight = height;
+ if (image != null) {
+ Rectangle rect = image.getBounds ();
+ nWidth = rect.width;
+ nHeight = rect.height;
+ }
+ if (nWidth <= 0) nWidth = 2;
+ OS.XFillRectangle (xDisplay, window, gc, x, y, nWidth, nHeight);
+ OS.XFreeGC (xDisplay, gc);
+ return true;
+}
+/**
+ * Returns a rectangle describing the receiver's size and location
+ * relative to its parent (or its display if its parent is null).
+ *
+ * @return the receiver's bounding rectangle
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
*/
-public Rectangle getBounds () {
- checkWidget();
- if (image != null) {
- Rectangle rect = image.getBounds ();
- return new Rectangle (x, y, rect.width, rect.height);
- }
- 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 Rectangle getBounds () {
+ checkWidget();
+ if (image != null) {
+ Rectangle rect = image.getBounds ();
+ return new Rectangle (x, y, rect.width, rect.height);
+ }
+ 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;
- return parent.getFont ();
-}
-/**
- * Returns the image that the receiver will use to paint the caret.
- *
- * @return the receiver's image
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
+public Font getFont () {
+ checkWidget();
+ if (font != null) return font;
+ return parent.getFont ();
+}
+/**
+ * Returns the image that the receiver will use to paint the caret.
+ *
+ * @return the receiver's image
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
*/
-public Image getImage () {
- checkWidget();
- return image;
-}
-/**
- * Returns a point describing the receiver's location relative
- * to its parent (or its display if its parent is null).
- *
- * @return the receiver's location
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
+public Image getImage () {
+ checkWidget();
+ return image;
+}
+/**
+ * Returns a point describing the receiver's location relative
+ * to its parent (or its display if its parent is null).
+ *
+ * @return the receiver's location
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
*/
-public Point getLocation () {
- checkWidget();
- return new Point (x, y);
-}
-/**
- * Returns the receiver's parent, which must be a <code>Canvas</code>.
- *
- * @return the receiver's parent
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
+public 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 Canvas getParent () {
+ checkWidget();
+ return parent;
+}
+/**
+ * Returns a point describing the receiver's size.
+ *
+ * @return the receiver's size
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
*/
-public Point getSize () {
- checkWidget();
- if (image != null) {
- Rectangle rect = image.getBounds ();
- return new Point (rect.width, rect.height);
- }
- 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 Point getSize () {
+ checkWidget();
+ if (image != null) {
+ Rectangle rect = image.getBounds ();
+ return new Point (rect.width, rect.height);
+ }
+ return new Point (width, height);
+}
+/**
+ * Returns <code>true</code> if the receiver is visible, and
+ * <code>false</code> otherwise.
+ * <p>
+ * If one of the receiver's ancestors is not visible or some
+ * other condition makes the receiver not visible, this method
+ * may still indicate that it is considered visible even though
+ * it may not actually be showing.
+ * </p>
+ *
+ * @return the receiver's visibility state
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
*/
-public boolean getVisible () {
- checkWidget();
- return isVisible;
-}
-boolean hideCaret () {
- if (!isShowing) return true;
- isShowing = false;
- return drawCaret ();
-}
-/**
- * Returns <code>true</code> if the receiver is visible and all
- * of the receiver's ancestors are visible and <code>false</code>
- * otherwise.
- *
- * @return the receiver's visibility state
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see #getVisible
+public boolean getVisible () {
+ checkWidget();
+ return isVisible;
+}
+boolean hideCaret () {
+ if (!isShowing) return true;
+ isShowing = false;
+ return drawCaret ();
+}
+/**
+ * Returns <code>true</code> if the receiver is visible and all
+ * of the receiver's ancestors are visible and <code>false</code>
+ * otherwise.
+ *
+ * @return the receiver's visibility state
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see #getVisible
*/
-public boolean isVisible () {
- checkWidget();
- return isVisible && parent.isVisible () && parent.hasFocus ();
-}
-boolean isFocusCaret () {
- Display display = getDisplay ();
- return this == display.currentCaret;
-}
-void killFocus () {
- Display display = getDisplay ();
- if (display.currentCaret != this) return;
- display.setCurrentCaret (null);
- if (isVisible) hideCaret ();
-}
-void releaseChild () {
- super.releaseChild ();
- if (this == parent.getCaret ()) parent.setCaret (null);
-}
-void releaseWidget () {
- super.releaseWidget ();
- Display display = getDisplay ();
- if (display.currentCaret == this) {
- hideCaret ();
- display.setCurrentCaret (null);
- }
- parent = null;
- image = null;
-}
-/**
- * Sets the receiver's size and location to the rectangular
- * area specified by the arguments. The <code>x</code> and
- * <code>y</code> arguments are relative to the receiver's
- * parent (or its display if its parent is null).
- *
- * @param x the new x coordinate for the receiver
- * @param y the new y coordinate for the receiver
- * @param width the new width for the receiver
- * @param height the new height for the receiver
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
+public boolean isVisible () {
+ checkWidget();
+ 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;
+ display.setCurrentCaret (null);
+ if (isVisible) hideCaret ();
+}
+void releaseChild () {
+ super.releaseChild ();
+ if (this == parent.getCaret ()) parent.setCaret (null);
+}
+void releaseWidget () {
+ super.releaseWidget ();
+ Display display = getDisplay ();
+ if (display.currentCaret == this) {
+ hideCaret ();
+ display.setCurrentCaret (null);
+ }
+ parent = null;
+ image = null;
+}
+/**
+ * Sets the receiver's size and location to the rectangular
+ * area specified by the arguments. The <code>x</code> and
+ * <code>y</code> arguments are relative to the receiver's
+ * parent (or its display if its parent is null).
+ *
+ * @param x the new x coordinate for the receiver
+ * @param y the new y coordinate for the receiver
+ * @param width the new width for the receiver
+ * @param height the new height for the receiver
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
*/
-public void setBounds (int x, int y, int width, int height) {
- checkWidget();
- if (this.x == x && this.y == y && this.width == width && this.height == height) return;
- boolean isFocus = isFocusCaret ();
- if (isFocus) hideCaret ();
- this.x = x; this.y = y;
- this.width = width; this.height = height;
- parent.updateCaret ();
- if (isFocus) showCaret ();
-}
-/**
- * Sets the receiver's size and location to the rectangular
- * area specified by the argument. The <code>x</code> and
- * <code>y</code> fields of the rectangle are relative to
- * the receiver's parent (or its display if its parent is null).
- *
- * @param rect the new bounds for the receiver
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
+public void setBounds (int x, int y, int width, int height) {
+ checkWidget();
+ if (this.x == x && this.y == y && this.width == width && this.height == height) return;
+ boolean isFocus = isFocusCaret ();
+ if (isFocus) hideCaret ();
+ this.x = x; this.y = y;
+ this.width = width; this.height = height;
+ parent.updateCaret ();
+ if (isFocus) showCaret ();
+}
+/**
+ * Sets the receiver's size and location to the rectangular
+ * area specified by the argument. The <code>x</code> and
+ * <code>y</code> fields of the rectangle are relative to
+ * the receiver's parent (or its display if its parent is null).
+ *
+ * @param rect the new bounds for the receiver
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
*/
-public void setBounds (Rectangle rect) {
- checkWidget();
- if (rect == null) error (SWT.ERROR_NULL_ARGUMENT);
- setBounds (rect.x, rect.y, rect.width, rect.height);
-}
-void setFocus () {
- Display display = getDisplay ();
- if (display.currentCaret == this) return;
- display.setCurrentCaret (this);
- if (isVisible) showCaret ();
-}
-/**
- * Sets the font that the receiver will use to paint textual information
- * to the font specified by the argument, or to the default font for that
- * kind of control if the argument is null.
- *
- * @param font the new font (or null)
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_INVALID_ARGUMENT - if the font has been disposed</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
+public void setBounds (Rectangle rect) {
+ checkWidget();
+ 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 font that the receiver will use to paint textual information
+ * to the font specified by the argument, or to the default font for that
+ * kind of control if the argument is null.
+ *
+ * @param font the new font (or null)
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_INVALID_ARGUMENT - if the font has been disposed</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
*/
-public void setFont (Font font) {
- checkWidget();
- if (font != null && font.isDisposed ()) {
- error (SWT.ERROR_INVALID_ARGUMENT);
- }
- this.font = font;
- if (isVisible && parent.hasFocus()) {
- int handle = parent.handle;
- int [] argList = {OS.XmNfontList, font.handle};
- OS.XmImSetValues (handle, argList, argList.length / 2);
- }
-}
-/**
- * Sets the image that the receiver will use to paint the caret
- * to the image specified by the argument, or to the default
- * which is a filled rectangle if the argument is null
- *
- * @param font the new font (or null)
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_INVALID_ARGUMENT - if the image has been disposed</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
+public void setFont (Font font) {
+ checkWidget();
+ if (font != null && font.isDisposed ()) {
+ error (SWT.ERROR_INVALID_ARGUMENT);
+ }
+ this.font = font;
+ if (isVisible && parent.hasFocus()) {
+ int handle = parent.handle;
+ int [] argList = {OS.XmNfontList, font.handle};
+ OS.XmImSetValues (handle, argList, argList.length / 2);
+ }
+}
+/**
+ * Sets the image that the receiver will use to paint the caret
+ * to the image specified by the argument, or to the default
+ * which is a filled rectangle if the argument is null
+ *
+ * @param font the new font (or null)
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_INVALID_ARGUMENT - if the image has been disposed</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
*/
-public void setImage (Image image) {
- checkWidget();
- if (image != null && image.isDisposed ()) {
- error (SWT.ERROR_INVALID_ARGUMENT);
- }
- boolean isFocus = isFocusCaret ();
- if (isFocus) hideCaret ();
- this.image = image;
- if (isFocus) showCaret ();
-}
-/**
- * Sets the receiver's location to the point specified by
- * the arguments which are relative to the receiver's
- * parent (or its display if its parent is null).
- *
- * @param x the new x coordinate for the receiver
- * @param y the new y coordinate for the receiver
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
+public void setImage (Image image) {
+ checkWidget();
+ if (image != null && image.isDisposed ()) {
+ error (SWT.ERROR_INVALID_ARGUMENT);
+ }
+ boolean isFocus = isFocusCaret ();
+ if (isFocus) hideCaret ();
+ this.image = image;
+ if (isFocus) showCaret ();
+}
+/**
+ * Sets the receiver's location to the point specified by
+ * the arguments which are relative to the receiver's
+ * parent (or its display if its parent is null).
+ *
+ * @param x the new x coordinate for the receiver
+ * @param y the new y coordinate for the receiver
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
*/
-public void setLocation (int x, int y) {
- checkWidget();
- setBounds (x, y, width, height);
-}
-/**
- * Sets the receiver's location to the point specified by
- * the argument which is relative to the receiver's
- * parent (or its display if its parent is null).
- *
- * @param location the new location for the receiver
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
+public void setLocation (int x, int y) {
+ checkWidget();
+ setBounds (x, y, width, height);
+}
+/**
+ * Sets the receiver's location to the point specified by
+ * the argument which is relative to the receiver's
+ * parent (or its display if its parent is null).
+ *
+ * @param location the new location for the receiver
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
*/
-public void setLocation (Point location) {
- checkWidget();
- if (location == null) error (SWT.ERROR_NULL_ARGUMENT);
- setLocation (location.x, location.y);
-}
-/**
- * Sets the receiver's size to the point specified by the arguments.
- *
- * @param width the new width for the receiver
- * @param height the new height for the receiver
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
+public void setLocation (Point location) {
+ checkWidget();
+ if (location == null) error (SWT.ERROR_NULL_ARGUMENT);
+ setLocation (location.x, location.y);
+}
+/**
+ * Sets the receiver's size to the point specified by the arguments.
+ *
+ * @param width the new width for the receiver
+ * @param height the new height for the receiver
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
*/
-public void setSize (int width, int height) {
- checkWidget();
- setBounds (x, y, width, height);
-}
-/**
- * Sets the receiver's size to the point specified by the argument.
- *
- * @param size the new extent for the receiver
- * @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 (int width, int height) {
+ checkWidget();
+ setBounds (x, y, width, height);
+}
+/**
+ * Sets the receiver's size to the point specified by the argument.
+ *
+ * @param size the new extent for the receiver
+ * @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 setSize (Point size) {
+ checkWidget();
+ if (size == null) error (SWT.ERROR_NULL_ARGUMENT);
+ setSize (size.x, size.y);
+}
+/**
+ * Marks the receiver as visible if the argument is <code>true</code>,
+ * and marks it invisible otherwise.
+ * <p>
+ * If one of the receiver's ancestors is not visible or some
+ * other condition makes the receiver not visible, marking
+ * it visible may not actually cause it to be displayed.
+ * </p>
+ *
+ * @param visible the new visibility state
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
*/
-public void setVisible (boolean visible) {
- checkWidget();
- if (visible == isVisible) return;
- isVisible = visible;
- if (!isFocusCaret ()) return;
- if (isVisible) {
- showCaret ();
- } else {
- hideCaret ();
- }
-}
-boolean showCaret () {
- if (isShowing) return true;
- isShowing = true;
- return drawCaret ();
-}
-}
+public void setVisible (boolean visible) {
+ checkWidget();
+ if (visible == isVisible) return;
+ isVisible = visible;
+ if (!isFocusCaret ()) return;
+ if (isVisible) {
+ showCaret ();
+ } else {
+ hideCaret ();
+ }
+}
+boolean showCaret () {
+ if (isShowing) return true;
+ isShowing = true;
+ return drawCaret ();
+}
+}
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
index 3661875923..0c9ec0e7a3 100755
--- 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
@@ -1,68 +1,68 @@
-package org.eclipse.swt.widgets;
-
-/*
+package org.eclipse.swt.widgets;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-import org.eclipse.swt.*;
-import org.eclipse.swt.graphics.*;
-import org.eclipse.swt.layout.*;
-
-/**
- * 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>
+ * http://www.eclipse.org/legal/cpl-v10.html
*/
-public class ColorDialog extends Dialog {
- private static final int COLORSWATCH_SIZE_DEPTH4 = 40;
- private static final int COLORSWATCH_SIZE_DEPTH8 = 15;
- private static final int COLORSWATCH_SIZE_DEPTH16 = 10;
- private static final int COLORSWATCH_BORDER = 1; // border between each color pad
-
- private Shell shell; // the dialog shell
- private Canvas colorsCanvas;
- private Label sampleLabel, selectionLabel;
- private Canvas sampleCanvas, selectionCanvas;
- private Button okButton, cancelButton;
-
- private boolean okSelected;
- private RGB rgb;
- private int colorDepth; // color depth of the display
- private int colorSwatchExtent; // the size of each color square
- private Color colorGrid[][]; // the colors displayed in the dialog
-
-/**
- * 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
+
+import org.eclipse.swt.*;
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.layout.*;
+
+/**
+ * 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 {
+ private static final int COLORSWATCH_SIZE_DEPTH4 = 40;
+ private static final int COLORSWATCH_SIZE_DEPTH8 = 15;
+ private static final int COLORSWATCH_SIZE_DEPTH16 = 10;
+ private static final int COLORSWATCH_BORDER = 1; // border between each color pad
+
+ private Shell shell; // the dialog shell
+ private Canvas colorsCanvas;
+ private Label sampleLabel, selectionLabel;
+ private Canvas sampleCanvas, selectionCanvas;
+ private Button okButton, cancelButton;
+
+ private boolean okSelected;
+ private RGB rgb;
+ private int colorDepth; // color depth of the display
+ private int colorSwatchExtent; // the size of each color square
+ private Color colorGrid[][]; // the colors displayed in the dialog
+
+/**
+ * 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);
-}
+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.
@@ -91,357 +91,357 @@ public ColorDialog(Shell parent) {
* @see Widget#checkSubclass
* @see Widget#getStyle
*/
-public ColorDialog(Shell parent, int style) {
- super(parent, style | SWT.TITLE | SWT.BORDER | SWT.APPLICATION_MODAL);
- checkSubclass ();
-}
-void createChildren() {
- Shell dialog = shell;
- GridLayout layout = new GridLayout (2, false);
- dialog.setLayout(layout);
-
- int colorChooserWidth = colorSwatchExtent * colorGrid.length;
- int colorChooserHeight = colorSwatchExtent * colorGrid[0].length;
- colorsCanvas = new Canvas(dialog, SWT.BORDER);
- GridData data = new GridData ();
- data.widthHint = colorChooserWidth;
- data.heightHint = colorChooserHeight;
- colorsCanvas.setLayoutData(data);
-
- Composite buttonsGroup = new Composite (dialog, SWT.NONE);
- buttonsGroup.setLayout(new GridLayout());
- buttonsGroup.setLayoutData(new GridData(GridData.BEGINNING));
- createOkCancel(buttonsGroup);
-
- Composite bottomGroup = new Composite (dialog,SWT.NONE);
- layout = new GridLayout(2, true);
- layout.marginHeight = 0;
- layout.marginWidth = 0;
- bottomGroup.setLayout(layout);
- bottomGroup.setLayoutData(new GridData(GridData.FILL_BOTH));
-
- createSampleGroup(bottomGroup);
- createSelectionGroup(bottomGroup);
-}
-void createOkCancel(Composite parent) {
- okButton = new Button(parent, SWT.PUSH);
- okButton.setText(SWT.getMessage("SWT_OK"));
- shell.setDefaultButton(okButton);
- GridData data = new GridData(GridData.FILL_HORIZONTAL);
- okButton.setLayoutData(data);
-
- cancelButton = new Button(parent, SWT.PUSH);
- cancelButton.setText(SWT.getMessage("SWT_Cancel"));
- data = new GridData(GridData.FILL_HORIZONTAL);
- cancelButton.setLayoutData(data);
-}
-void createSampleGroup(Composite parent) {
- Group sampleGroup = new Group(parent, SWT.NULL);
- GridData data = new GridData(GridData.FILL_BOTH);
- data.grabExcessHorizontalSpace = true;
- sampleGroup.setLayout(new GridLayout());
- sampleGroup.setLayoutData(data);
- sampleGroup.setText(SWT.getMessage("SWT_Sample"));
-
- sampleLabel = new Label(sampleGroup, SWT.CENTER | SWT.BORDER);
- sampleLabel.setAlignment(SWT.CENTER);
- sampleLabel.setText(SWT.getMessage("SWT_A_Sample_Text"));
- data = new GridData(GridData.FILL_HORIZONTAL);
- sampleLabel.setLayoutData(data);
-
- sampleCanvas = new Canvas(sampleGroup, SWT.BORDER);
- data = new GridData(GridData.FILL_HORIZONTAL);
- data.heightHint = 15;
- sampleCanvas.setLayoutData(data);
-}
-void createSelectionGroup(Composite parent) {
- Group selectionGroup = new Group(parent, SWT.NULL);
- GridData data = new GridData(GridData.FILL_BOTH);
- data.grabExcessHorizontalSpace = true;
- selectionGroup.setLayout(new GridLayout());
- selectionGroup.setLayoutData(data);
- selectionGroup.setText(SWT.getMessage("SWT_Selection"));
-
- selectionLabel = new Label(selectionGroup, SWT.CENTER | SWT.BORDER);
- selectionLabel.setAlignment(SWT.CENTER);
- selectionLabel.setText(SWT.getMessage("SWT_Current_Selection"));
- data = new GridData(GridData.FILL_HORIZONTAL);
- data.grabExcessHorizontalSpace = true;
- selectionLabel.setLayoutData(data);
-
- selectionCanvas = new Canvas(selectionGroup, SWT.BORDER);
- data = new GridData(GridData.FILL_HORIZONTAL);
- data.grabExcessHorizontalSpace = true;
- data.heightHint = 15;
- selectionCanvas.setLayoutData(data);
-}
-void disposeColors() {
- for (int row = 0; row < colorGrid.length; row++) {
- for (int column = 0; column < colorGrid[row].length; column++) {
- colorGrid[row][column].dispose();
- }
- }
-}
-void drawColor(int xIndex, int yIndex, Color color, GC gc) {
- int colorExtent = colorSwatchExtent - COLORSWATCH_BORDER;
- gc.setBackground(color);
- gc.fillRectangle(
- xIndex * colorSwatchExtent,
- yIndex * colorSwatchExtent,
- colorExtent, colorExtent);
-}
-/**
- * Returns the currently selected color in the receiver.
- *
- * @return the RGB value for the selected color, may be null
- * @see PaletteData#getRGBs
+public ColorDialog(Shell parent, int style) {
+ super(parent, style | SWT.TITLE | SWT.BORDER | SWT.APPLICATION_MODAL);
+ checkSubclass ();
+}
+void createChildren() {
+ Shell dialog = shell;
+ GridLayout layout = new GridLayout (2, false);
+ dialog.setLayout(layout);
+
+ int colorChooserWidth = colorSwatchExtent * colorGrid.length;
+ int colorChooserHeight = colorSwatchExtent * colorGrid[0].length;
+ colorsCanvas = new Canvas(dialog, SWT.BORDER);
+ GridData data = new GridData ();
+ data.widthHint = colorChooserWidth;
+ data.heightHint = colorChooserHeight;
+ colorsCanvas.setLayoutData(data);
+
+ Composite buttonsGroup = new Composite (dialog, SWT.NONE);
+ buttonsGroup.setLayout(new GridLayout());
+ buttonsGroup.setLayoutData(new GridData(GridData.BEGINNING));
+ createOkCancel(buttonsGroup);
+
+ Composite bottomGroup = new Composite (dialog,SWT.NONE);
+ layout = new GridLayout(2, true);
+ layout.marginHeight = 0;
+ layout.marginWidth = 0;
+ bottomGroup.setLayout(layout);
+ bottomGroup.setLayoutData(new GridData(GridData.FILL_BOTH));
+
+ createSampleGroup(bottomGroup);
+ createSelectionGroup(bottomGroup);
+}
+void createOkCancel(Composite parent) {
+ okButton = new Button(parent, SWT.PUSH);
+ okButton.setText(SWT.getMessage("SWT_OK"));
+ shell.setDefaultButton(okButton);
+ GridData data = new GridData(GridData.FILL_HORIZONTAL);
+ okButton.setLayoutData(data);
+
+ cancelButton = new Button(parent, SWT.PUSH);
+ cancelButton.setText(SWT.getMessage("SWT_Cancel"));
+ data = new GridData(GridData.FILL_HORIZONTAL);
+ cancelButton.setLayoutData(data);
+}
+void createSampleGroup(Composite parent) {
+ Group sampleGroup = new Group(parent, SWT.NULL);
+ GridData data = new GridData(GridData.FILL_BOTH);
+ data.grabExcessHorizontalSpace = true;
+ sampleGroup.setLayout(new GridLayout());
+ sampleGroup.setLayoutData(data);
+ sampleGroup.setText(SWT.getMessage("SWT_Sample"));
+
+ sampleLabel = new Label(sampleGroup, SWT.CENTER | SWT.BORDER);
+ sampleLabel.setAlignment(SWT.CENTER);
+ sampleLabel.setText(SWT.getMessage("SWT_A_Sample_Text"));
+ data = new GridData(GridData.FILL_HORIZONTAL);
+ sampleLabel.setLayoutData(data);
+
+ sampleCanvas = new Canvas(sampleGroup, SWT.BORDER);
+ data = new GridData(GridData.FILL_HORIZONTAL);
+ data.heightHint = 15;
+ sampleCanvas.setLayoutData(data);
+}
+void createSelectionGroup(Composite parent) {
+ Group selectionGroup = new Group(parent, SWT.NULL);
+ GridData data = new GridData(GridData.FILL_BOTH);
+ data.grabExcessHorizontalSpace = true;
+ selectionGroup.setLayout(new GridLayout());
+ selectionGroup.setLayoutData(data);
+ selectionGroup.setText(SWT.getMessage("SWT_Selection"));
+
+ selectionLabel = new Label(selectionGroup, SWT.CENTER | SWT.BORDER);
+ selectionLabel.setAlignment(SWT.CENTER);
+ selectionLabel.setText(SWT.getMessage("SWT_Current_Selection"));
+ data = new GridData(GridData.FILL_HORIZONTAL);
+ data.grabExcessHorizontalSpace = true;
+ selectionLabel.setLayoutData(data);
+
+ selectionCanvas = new Canvas(selectionGroup, SWT.BORDER);
+ data = new GridData(GridData.FILL_HORIZONTAL);
+ data.grabExcessHorizontalSpace = true;
+ data.heightHint = 15;
+ selectionCanvas.setLayoutData(data);
+}
+void disposeColors() {
+ for (int row = 0; row < colorGrid.length; row++) {
+ for (int column = 0; column < colorGrid[row].length; column++) {
+ colorGrid[row][column].dispose();
+ }
+ }
+}
+void drawColor(int xIndex, int yIndex, Color color, GC gc) {
+ int colorExtent = colorSwatchExtent - COLORSWATCH_BORDER;
+ gc.setBackground(color);
+ gc.fillRectangle(
+ xIndex * colorSwatchExtent,
+ yIndex * colorSwatchExtent,
+ colorExtent, colorExtent);
+}
+/**
+ * Returns the currently selected color in the receiver.
+ *
+ * @return the RGB value for the selected color, may be null
+ * @see PaletteData#getRGBs
*/
-public RGB getRGB() {
- return rgb;
-}
-void handleEvents(Event event) {
- 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 == okButton) {
- okSelected = true;
- shell.setVisible(false);
- }
- else
- if (event.widget == cancelButton) {
- okSelected = false;
- shell.setVisible(false);
- }
- }
-}
-void initialize4BitColors() {
- Display display = shell.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);
-}
-void initialize8BitColors() {
- Display display = shell.getDisplay();
- int numRows = colorGrid[0].length;
- int iterationStep = 64;
- int row = 0, column = 0;
- int red, green, blue;
- // run the loops from 0 to 256 inclusive since this is easiest for the step
- // size, then adjust the 256 case to the proper 255 value when needed
- for (red = 0; red <= 256; red += iterationStep) {
- for (blue = 0; blue <= 256; blue += iterationStep) {
- for (green = 0; green <= 256; green += iterationStep) {
- if (row == numRows) {
- row = 0;
- column++;
- }
- if (red == 256) red = 255;
- if (blue == 256) blue = 255;
- if (green == 256) green = 255;
- colorGrid[column][row++] = new Color(display, red, green, blue);
- }
- }
- }
-}
-void initialize16BitColors() {
- Display display = shell.getDisplay();
- int numRows = colorGrid[0].length;
- int iterationStep = 51;
- int row = 0, column = 0;
- int red, green, 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 = shell.getDisplay();
- if (rgb != null) {
- Color selectionColor = new Color(display, rgb);
- selectionCanvas.setBackground(selectionColor);
- selectionLabel.setBackground(selectionColor);
- selectionColor.dispose();
- }
-}
-void installListeners() {
- Listener listener = new Listener() {
- public void handleEvent(Event event) {handleEvents(event);}
- };
- okButton.addListener(SWT.Selection, listener);
- cancelButton.addListener(SWT.Selection, listener);
- colorsCanvas.addListener(SWT.Paint, listener);
- colorsCanvas.addListener(SWT.MouseDown, listener);
- colorsCanvas.addListener(SWT.MouseMove, listener);
-}
-void mouseDown(Event event) {
- int swatchExtent = colorSwatchExtent;
- Color color = colorGrid[event.x / swatchExtent][event.y / swatchExtent];
- selectionCanvas.setBackground(color);
- selectionLabel.setBackground(color);
-}
-void mouseMove(Event event) {
- int swatchExtent = colorSwatchExtent;
- // adjust for events received from moving over the Canvas' border
- int xgrid = Math.min(colorGrid.length - 1, event.x / swatchExtent);
- int ygrid = Math.min(colorGrid[0].length - 1, event.y / swatchExtent);
- Color color = colorGrid[xgrid][ygrid];
- sampleCanvas.setBackground(color);
- sampleLabel.setBackground(color);
-}
-/**
- * Makes the receiver visible and brings it to the front
- * of the display.
- *
- * @return the selected color, or null if the dialog was
- * cancelled, no color was selected, or an error
- * occurred
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
+public RGB getRGB() {
+ return rgb;
+}
+void handleEvents(Event event) {
+ 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 == okButton) {
+ okSelected = true;
+ shell.setVisible(false);
+ }
+ else
+ if (event.widget == cancelButton) {
+ okSelected = false;
+ shell.setVisible(false);
+ }
+ }
+}
+void initialize4BitColors() {
+ Display display = shell.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);
+}
+void initialize8BitColors() {
+ Display display = shell.getDisplay();
+ int numRows = colorGrid[0].length;
+ int iterationStep = 64;
+ int row = 0, column = 0;
+ int red, green, blue;
+ // run the loops from 0 to 256 inclusive since this is easiest for the step
+ // size, then adjust the 256 case to the proper 255 value when needed
+ for (red = 0; red <= 256; red += iterationStep) {
+ for (blue = 0; blue <= 256; blue += iterationStep) {
+ for (green = 0; green <= 256; green += iterationStep) {
+ if (row == numRows) {
+ row = 0;
+ column++;
+ }
+ if (red == 256) red = 255;
+ if (blue == 256) blue = 255;
+ if (green == 256) green = 255;
+ colorGrid[column][row++] = new Color(display, red, green, blue);
+ }
+ }
+ }
+}
+void initialize16BitColors() {
+ Display display = shell.getDisplay();
+ int numRows = colorGrid[0].length;
+ int iterationStep = 51;
+ int row = 0, column = 0;
+ int red, green, 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 = shell.getDisplay();
+ if (rgb != null) {
+ Color selectionColor = new Color(display, rgb);
+ selectionCanvas.setBackground(selectionColor);
+ selectionLabel.setBackground(selectionColor);
+ selectionColor.dispose();
+ }
+}
+void installListeners() {
+ Listener listener = new Listener() {
+ public void handleEvent(Event event) {handleEvents(event);}
+ };
+ okButton.addListener(SWT.Selection, listener);
+ cancelButton.addListener(SWT.Selection, listener);
+ colorsCanvas.addListener(SWT.Paint, listener);
+ colorsCanvas.addListener(SWT.MouseDown, listener);
+ colorsCanvas.addListener(SWT.MouseMove, listener);
+}
+void mouseDown(Event event) {
+ int swatchExtent = colorSwatchExtent;
+ Color color = colorGrid[event.x / swatchExtent][event.y / swatchExtent];
+ selectionCanvas.setBackground(color);
+ selectionLabel.setBackground(color);
+}
+void mouseMove(Event event) {
+ int swatchExtent = colorSwatchExtent;
+ // adjust for events received from moving over the Canvas' border
+ int xgrid = Math.min(colorGrid.length - 1, event.x / swatchExtent);
+ int ygrid = Math.min(colorGrid[0].length - 1, event.y / swatchExtent);
+ Color color = colorGrid[xgrid][ygrid];
+ sampleCanvas.setBackground(color);
+ sampleLabel.setBackground(color);
+}
+/**
+ * Makes the receiver visible and brings it to the front
+ * of the display.
+ *
+ * @return the selected color, or null if the dialog was
+ * cancelled, no color was selected, or an error
+ * occurred
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
*/
-public RGB open() {
- shell = new Shell(parent, getStyle() | SWT.TITLE | SWT.BORDER | SWT.APPLICATION_MODAL);
- setColorDepth(shell.getDisplay().getDepth());
- createChildren();
- installListeners();
- openModal();
- if (okSelected) {
- Color selectionColor = selectionCanvas.getBackground();
- rgb = new RGB(
- selectionColor.getRed(),
- selectionColor.getGreen(),
- selectionColor.getBlue());
- }
- disposeColors();
- if (shell.isDisposed() == false) {
- shell.dispose();
- }
- if (!okSelected) return null;
- return rgb;
-}
-/**
- * Open the receiver and set its size to the size calculated by
- * the layout manager.
- */
-void openDialog() {
- Shell dialog = shell;
-
- // Start everything off by setting the shell size to its computed size.
- Point pt = dialog.computeSize(-1, -1, false);
-
- // Ensure that the width of the shell fits the display.
- Rectangle displayRect = dialog.getDisplay().getBounds();
- int widthLimit = displayRect.width * 7 / 8;
- int heightLimit = displayRect.height * 7 / 8;
- if (pt.x > widthLimit) {
- pt = dialog.computeSize (widthLimit, -1, false);
- }
-
- // centre the dialog on its parent, and ensure that the
- // whole dialog appears within the screen bounds
- Rectangle parentBounds = getParent ().getBounds ();
- int originX = (parentBounds.width - pt.x) / 2 + parentBounds.x;
- originX = Math.max (originX, 0);
- originX = Math.min (originX, widthLimit - pt.x);
- int originY = (parentBounds.height - pt.y) / 2 + parentBounds.y;
- originY = Math.max (originY, 0);
- originY = Math.min (originY, heightLimit - pt.y);
- dialog.setBounds (originX, originY, pt.x, pt.y);
-
- String title = getText ();
- if (title.length () == 0) title = SWT.getMessage ("SWT_ColorDialog_Title");
- shell.setText(title);
-
- dialog.open();
-}
-void openModal() {
- Display display = shell.getDisplay();
- initializeWidgets();
- openDialog();
- while (shell.isDisposed() == false && shell.getVisible() == true) {
- if (display.readAndDispatch() == false) {
- display.sleep();
- }
- }
-}
-void paint(Event event) {
- 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);
- }
- }
-}
-void setColorDepth(int bits) {
- colorDepth = bits;
- if (bits == 4) {
- colorSwatchExtent = COLORSWATCH_SIZE_DEPTH4;
- colorGrid = new Color[8][2];
- initialize4BitColors();
- return;
- }
- if (bits == 8) {
- colorSwatchExtent = COLORSWATCH_SIZE_DEPTH8;
- colorGrid = new Color[25][5];
- initialize8BitColors();
- return;
- }
- // default case: 16, 24 or 32 bits
- colorSwatchExtent = COLORSWATCH_SIZE_DEPTH16;
- colorGrid = new Color[32][8];
- initialize16BitColors();
-}
-/**
- * Sets the receiver's selected color to be the argument.
- *
- * @param rgb the new RGB value for the selected color, may be
- * null to let the platform to select a default when
- * open() is called
- * @see PaletteData#getRGBs
+public RGB open() {
+ shell = new Shell(parent, getStyle() | SWT.TITLE | SWT.BORDER | SWT.APPLICATION_MODAL);
+ setColorDepth(shell.getDisplay().getDepth());
+ createChildren();
+ installListeners();
+ openModal();
+ if (okSelected) {
+ Color selectionColor = selectionCanvas.getBackground();
+ rgb = new RGB(
+ selectionColor.getRed(),
+ selectionColor.getGreen(),
+ selectionColor.getBlue());
+ }
+ disposeColors();
+ if (shell.isDisposed() == false) {
+ shell.dispose();
+ }
+ if (!okSelected) return null;
+ return rgb;
+}
+/**
+ * Open the receiver and set its size to the size calculated by
+ * the layout manager.
+ */
+void openDialog() {
+ Shell dialog = shell;
+
+ // Start everything off by setting the shell size to its computed size.
+ Point pt = dialog.computeSize(-1, -1, false);
+
+ // Ensure that the width of the shell fits the display.
+ Rectangle displayRect = dialog.getDisplay().getBounds();
+ int widthLimit = displayRect.width * 7 / 8;
+ int heightLimit = displayRect.height * 7 / 8;
+ if (pt.x > widthLimit) {
+ pt = dialog.computeSize (widthLimit, -1, false);
+ }
+
+ // centre the dialog on its parent, and ensure that the
+ // whole dialog appears within the screen bounds
+ Rectangle parentBounds = getParent ().getBounds ();
+ int originX = (parentBounds.width - pt.x) / 2 + parentBounds.x;
+ originX = Math.max (originX, 0);
+ originX = Math.min (originX, widthLimit - pt.x);
+ int originY = (parentBounds.height - pt.y) / 2 + parentBounds.y;
+ originY = Math.max (originY, 0);
+ originY = Math.min (originY, heightLimit - pt.y);
+ dialog.setBounds (originX, originY, pt.x, pt.y);
+
+ String title = getText ();
+ if (title.length () == 0) title = SWT.getMessage ("SWT_ColorDialog_Title");
+ shell.setText(title);
+
+ dialog.open();
+}
+void openModal() {
+ Display display = shell.getDisplay();
+ initializeWidgets();
+ openDialog();
+ while (shell.isDisposed() == false && shell.getVisible() == true) {
+ if (display.readAndDispatch() == false) {
+ display.sleep();
+ }
+ }
+}
+void paint(Event event) {
+ 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);
+ }
+ }
+}
+void setColorDepth(int bits) {
+ colorDepth = bits;
+ if (bits == 4) {
+ colorSwatchExtent = COLORSWATCH_SIZE_DEPTH4;
+ colorGrid = new Color[8][2];
+ initialize4BitColors();
+ return;
+ }
+ if (bits == 8) {
+ colorSwatchExtent = COLORSWATCH_SIZE_DEPTH8;
+ colorGrid = new Color[25][5];
+ initialize8BitColors();
+ return;
+ }
+ // default case: 16, 24 or 32 bits
+ colorSwatchExtent = COLORSWATCH_SIZE_DEPTH16;
+ colorGrid = new Color[32][8];
+ initialize16BitColors();
+}
+/**
+ * Sets the receiver's selected color to be the argument.
+ *
+ * @param rgb the new RGB value for the selected color, may be
+ * null to let the platform to select a default when
+ * open() is called
+ * @see PaletteData#getRGBs
*/
-public void setRGB(RGB rgb) {
- this.rgb = rgb;
-}
-}
+public void setRGB(RGB rgb) {
+ this.rgb = rgb;
+}
+}
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
index 5c681bcfda..f8a799d641 100755
--- 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
@@ -1,71 +1,71 @@
-package org.eclipse.swt.widgets;
-
-/*
+package org.eclipse.swt.widgets;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-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.*;
-
-/**
- * Instances of this class are controls that allow the user
- * to choose an item from a list of items, or optionally
- * enter a new value by typing it into an editable text
- * field. Often, <code>Combo</code>s are used in the same place
- * where a single selection <code>List</code> widget could
- * be used but space is limited. A <code>Combo</code> takes
- * less space than a <code>List</code> widget and shows
- * similar information.
- * <p>
- * Note: Since <code>Combo</code>s can contain both a list
- * and an editable text field, it is possible to confuse methods
- * which access one versus the other (compare for example,
- * <code>clearSelection()</code> and <code>deselectAll()</code>).
- * The API documentation is careful to indicate either "the
- * receiver's list" or the "the receiver's text field" to
- * distinguish between the two cases.
- * </p><p>
- * Note that although this class is a subclass of <code>Composite</code>,
- * it does not make sense to add children to it, or set a layout on it.
- * </p>
- * <dl>
- * <dt><b>Styles:</b></dt>
- * <dd>DROP_DOWN, READ_ONLY, SIMPLE</dd>
- * <dt><b>Events:</b></dt>
- * <dd>DefaultSelection, Modify, Selection</dd>
- * </dl>
- * <p>
- * Note: Only one of the styles DROP_DOWN and SIMPLE
- * may be specified.
- * </p><p>
- * IMPORTANT: This class is <em>not</em> intended to be subclassed.
- * </p>
- *
- * @see List
+ * http://www.eclipse.org/legal/cpl-v10.html
*/
-public class Combo extends Composite {
- /**
- * the operating system limit for the number of characters
- * that the text field in an instance of this class can hold
+
+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.*;
+
+/**
+ * Instances of this class are controls that allow the user
+ * to choose an item from a list of items, or optionally
+ * enter a new value by typing it into an editable text
+ * field. Often, <code>Combo</code>s are used in the same place
+ * where a single selection <code>List</code> widget could
+ * be used but space is limited. A <code>Combo</code> takes
+ * less space than a <code>List</code> widget and shows
+ * similar information.
+ * <p>
+ * Note: Since <code>Combo</code>s can contain both a list
+ * and an editable text field, it is possible to confuse methods
+ * which access one versus the other (compare for example,
+ * <code>clearSelection()</code> and <code>deselectAll()</code>).
+ * The API documentation is careful to indicate either "the
+ * receiver's list" or the "the receiver's text field" to
+ * distinguish between the two cases.
+ * </p><p>
+ * Note that although this class is a subclass of <code>Composite</code>,
+ * it does not make sense to add children to it, or set a layout on it.
+ * </p>
+ * <dl>
+ * <dt><b>Styles:</b></dt>
+ * <dd>DROP_DOWN, READ_ONLY, SIMPLE</dd>
+ * <dt><b>Events:</b></dt>
+ * <dd>DefaultSelection, Modify, Selection</dd>
+ * </dl>
+ * <p>
+ * Note: Only one of the styles DROP_DOWN and SIMPLE
+ * may be specified.
+ * </p><p>
+ * IMPORTANT: This class is <em>not</em> intended to be subclassed.
+ * </p>
+ *
+ * @see List
+ */
+public class Combo extends Composite {
+ /**
+ * 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 = 0x7FFFFFFF;
- }
-
- boolean ignoreSelect;
+ 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 = 0x7FFFFFFF;
+ }
+
+ boolean ignoreSelect;
/**
* Constructs a new instance of this class given its parent
* and a style value describing its behavior and appearance.
@@ -96,1345 +96,1345 @@ public class Combo extends Composite {
* @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 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 (getCodePage (), 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 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) {
+ checkWidget();
+ if (string == null) error (SWT.ERROR_NULL_ARGUMENT);
+
+ byte [] buffer = Converter.wcsToMbcs (getCodePage (), 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 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);
-
- /*
- * 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 (getCodePage (), 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 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 add (String string, int index) {
+ checkWidget();
+ 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 (getCodePage (), 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 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.
- * <p>
- * <code>widgetSelected</code> is called when the combo's list selection changes.
- * <code>widgetDefaultSelected</code> is typically called when ENTER is pressed the combo's text area.
- * </p>
- *
- * @param listener the listener which should be notified
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see SelectionListener
- * @see #removeSelectionListener
- * @see SelectionEvent
+public void 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.
+ * <p>
+ * <code>widgetSelected</code> is called when the combo's list selection changes.
+ * <code>widgetDefaultSelected</code> is typically called when ENTER is pressed the combo's text area.
+ * </p>
+ *
+ * @param listener the listener which should be notified
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see SelectionListener
+ * @see #removeSelectionListener
+ * @see SelectionEvent
*/
-public void addSelectionListener(SelectionListener listener) {
- checkWidget();
- if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
- TypedListener typedListener = new TypedListener (listener);
- addListener (SWT.Selection,typedListener);
- addListener (SWT.DefaultSelection,typedListener);
-}
-static int checkStyle (int style) {
- /*
- * Feature in Windows. It is not possible to create
- * a combo box that has a border using Windows style
- * bits. All combo boxes draw their own border and
- * do not use the standard Windows border styles.
- * Therefore, no matter what style bits are specified,
- * clear the BORDER bits so that the SWT style will
- * match the Windows widget.
- *
- * The Windows behavior is currently implemented on
- * all platforms.
- */
- style &= ~SWT.BORDER;
-
- /*
- * Even though it is legal to create this widget
- * with scroll bars, they serve no useful purpose
- * because they do not automatically scroll the
- * widget's client area. The fix is to clear
- * the SWT style.
- */
- style &= ~(SWT.H_SCROLL | SWT.V_SCROLL);
- style = checkBits (style, SWT.DROP_DOWN, SWT.SIMPLE, 0, 0, 0, 0);
- if ((style & SWT.SIMPLE) != 0) return style & ~SWT.READ_ONLY;
- return style;
-}
-protected void checkSubclass () {
- if (!isValidSubclass ()) error (SWT.ERROR_INVALID_SUBCLASS);
-}
-/**
- * Sets the selection in the receiver's text field to an empty
- * selection starting just before the first character. If the
- * text field is editable, this has the effect of placing the
- * i-beam at the start of the text.
- * <p>
- * Note: To clear the selected items in the receiver's list,
- * use <code>deselectAll()</code>.
- * </p>
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see #deselectAll
+public void 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) {
+ /*
+ * Feature in Windows. It is not possible to create
+ * a combo box that has a border using Windows style
+ * bits. All combo boxes draw their own border and
+ * do not use the standard Windows border styles.
+ * Therefore, no matter what style bits are specified,
+ * clear the BORDER bits so that the SWT style will
+ * match the Windows widget.
+ *
+ * The Windows behavior is currently implemented on
+ * all platforms.
+ */
+ style &= ~SWT.BORDER;
+
+ /*
+ * Even though it is legal to create this widget
+ * with scroll bars, they serve no useful purpose
+ * because they do not automatically scroll the
+ * widget's client area. The fix is to clear
+ * the SWT style.
+ */
+ style &= ~(SWT.H_SCROLL | SWT.V_SCROLL);
+ style = checkBits (style, SWT.DROP_DOWN, SWT.SIMPLE, 0, 0, 0, 0);
+ if ((style & SWT.SIMPLE) != 0) return style & ~SWT.READ_ONLY;
+ return style;
+}
+protected void checkSubclass () {
+ if (!isValidSubclass ()) error (SWT.ERROR_INVALID_SUBCLASS);
+}
+/**
+ * Sets the selection in the receiver's text field to an empty
+ * selection starting just before the first character. If the
+ * text field is editable, this has the effect of placing the
+ * i-beam at the start of the text.
+ * <p>
+ * Note: To clear the selected items in the receiver's list,
+ * use <code>deselectAll()</code>.
+ * </p>
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see #deselectAll
*/
-public void clearSelection () {
- checkWidget();
- 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) {
- checkWidget();
- 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);
-}
-/**
- * Copies the selected text.
- * <p>
- * The current selection is copied to the clipboard.
- * </p>
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @since 2.1
- */
-public void copy () {
- checkWidget();
- int xDisplay = OS.XtDisplay (handle);
- if (xDisplay == 0) return;
- int [] argList = {OS.XmNtextField, 0};
- OS.XtGetValues (handle, argList, argList.length / 2);
- OS.XmTextCopy (argList [1], OS.XtLastTimestampProcessed (xDisplay));
-}
-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.
- */
- int parentHandle = parent.handle;
- int [] argList1 = {OS.XmNancestorSensitive, 1};
- formHandle = OS.XmCreateForm (parentHandle, null, argList1, argList1.length / 2);
- 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 [] argList2 = {
- 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, argList2, argList2.length / 2);
- if (handle == 0) error (SWT.ERROR_NO_HANDLES);
-}
-/**
- * Cuts the selected text.
- * <p>
- * The current selection is first copied to the
- * clipboard and then deleted from the widget.
- * </p>
- *
- * @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>
- *
- * @since 2.1
- */
-public void cut () {
- checkWidget();
- int xDisplay = OS.XtDisplay (handle);
- if (xDisplay == 0) return;
- int [] argList = {OS.XmNtextField, 0};
- OS.XtGetValues (handle, argList, argList.length / 2);
- OS.XmTextCut (argList [1], OS.XtLastTimestampProcessed (xDisplay));
-}
-/**
- * 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 clearSelection () {
+ checkWidget();
+ 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) {
+ checkWidget();
+ 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);
+}
+/**
+ * Copies the selected text.
+ * <p>
+ * The current selection is copied to the clipboard.
+ * </p>
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @since 2.1
*/
-public void deselect (int index) {
- checkWidget();
- 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]);
- display.setWarnings (warnings);
- OS.XmListDeselectAllItems (argList[3]);
- }
-}
-/**
- * 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 copy () {
+ checkWidget();
+ int xDisplay = OS.XtDisplay (handle);
+ if (xDisplay == 0) return;
+ int [] argList = {OS.XmNtextField, 0};
+ OS.XtGetValues (handle, argList, argList.length / 2);
+ OS.XmTextCopy (argList [1], OS.XtLastTimestampProcessed (xDisplay));
+}
+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.
+ */
+ int parentHandle = parent.handle;
+ int [] argList1 = {OS.XmNancestorSensitive, 1};
+ formHandle = OS.XmCreateForm (parentHandle, null, argList1, argList1.length / 2);
+ 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 [] argList2 = {
+ 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, argList2, argList2.length / 2);
+ if (handle == 0) error (SWT.ERROR_NO_HANDLES);
+}
+/**
+ * Cuts the selected text.
+ * <p>
+ * The current selection is first copied to the
+ * clipboard and then deleted from the widget.
+ * </p>
+ *
+ * @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>
+ *
+ * @since 2.1
+ */
+public void cut () {
+ checkWidget();
+ int xDisplay = OS.XtDisplay (handle);
+ if (xDisplay == 0) return;
+ int [] argList = {OS.XmNtextField, 0};
+ OS.XtGetValues (handle, argList, argList.length / 2);
+ OS.XmTextCut (argList [1], OS.XtLastTimestampProcessed (xDisplay));
+}
+/**
+ * Deselects the item at the given zero-relative index in the receiver's
+ * list. If the item at the index was already deselected, it remains
+ * deselected. Indices that are out of range are ignored.
+ *
+ * @param index the index of the item to deselect
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void deselect (int index) {
+ checkWidget();
+ if (index == -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]);
+ display.setWarnings (warnings);
+ OS.XmListDeselectAllItems (argList[3]);
+ }
+}
+/**
+ * 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();
- 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]);
- display.setWarnings(warnings);
- OS.XmListDeselectAllItems (argList[3]);
-}
-
-
-/**
- * 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 void deselectAll () {
+ checkWidget();
+ 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]);
+ display.setWarnings(warnings);
+ OS.XmListDeselectAllItems (argList[3]);
+}
+
+
+/**
+ * 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 [] 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 (getCodePage (), buffer)));
+}
+/**
+ * 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 String getItem (int index) {
- checkWidget();
- 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 (getCodePage (), buffer)));
-}
-/**
- * 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 [] argList = {OS.XmNitemCount, 0};
+ OS.XtGetValues (handle, argList, argList.length / 2);
+ return argList [1];
+}
+/**
+ * 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 getItemCount () {
- checkWidget();
- int [] argList = {OS.XmNitemCount, 0};
- OS.XtGetValues (handle, argList, argList.length / 2);
- return argList [1];
-}
-/**
- * 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 [] 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);
+}
+/**
+ * Returns an array of <code>String</code>s which are the items
+ * in the receiver's list.
+ * <p>
+ * Note: This is not the actual structure used by the receiver
+ * to maintain its list of items, so modifying the array will
+ * not affect the receiver.
+ * </p>
+ *
+ * @return the items in the receiver's list
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * @exception SWTError <ul>
+ * <li>ERROR_CANNOT_GET_ITEM - if the operation fails because of an operating system failure</li>
+ * </ul>
*/
-public int getItemHeight () {
- checkWidget();
- 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);
-}
-/**
- * Returns an array of <code>String</code>s which are the items
- * in the receiver's list.
- * <p>
- * Note: This is not the actual structure used by the receiver
- * to maintain its list of items, so modifying the array will
- * not affect the receiver.
- * </p>
- *
- * @return the items in the receiver's list
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- * @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 [] 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];
+ String codePage = getCodePage ();
+ 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 (codePage, buffer)));
+ items += 4;
+ }
+ 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 String [] getItems () {
- checkWidget();
- 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];
- String codePage = getCodePage ();
- 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 (codePage, buffer)));
- items += 4;
- }
- 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();
+ 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]);
+}
+/**
+ * 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 Point getSelection () {
- checkWidget();
- 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]);
-}
-/**
- * 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();
+ 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;
+}
+/**
+ * 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 int getSelectionIndex () {
- checkWidget();
- 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;
-}
-/**
- * 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 [] 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 (getCodePage (), buffer)));
+}
+/**
+ * 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 String getText () {
- checkWidget();
- 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 (getCodePage (), buffer)));
-}
-/**
- * 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();
+ 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;
+ }
+}
+/**
+ * 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 getTextHeight () {
- checkWidget();
- 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;
- }
-}
-/**
- * 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 [] 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, SELECTION_CALLBACK);
+ int [] argList = {OS.XmNtextField, 0};
+ OS.XtGetValues (handle, argList, argList.length / 2);
+ OS.XtAddCallback (argList[1], OS.XmNactivateCallback, windowProc, ACTIVATE_CALLBACK);
+ OS.XtAddCallback (argList[1], OS.XmNvalueChangedCallback, windowProc, VALUE_CHANGED_CALLBACK);
+ OS.XtAddEventHandler (argList[1], OS.KeyPressMask, false, windowProc, KEY_PRESS);
+ OS.XtAddEventHandler (argList[1], OS.KeyReleaseMask, false, windowProc, KEY_RELEASE);
+ OS.XtInsertEventHandler (argList[1], OS.FocusChangeMask, false, windowProc, FOCUS_CHANGE, OS.XtListTail);
+}
+/**
+ * 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 getTextLimit () {
- checkWidget();
- 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, SELECTION_CALLBACK);
- int [] argList = {OS.XmNtextField, 0};
- OS.XtGetValues (handle, argList, argList.length / 2);
- OS.XtAddCallback (argList[1], OS.XmNactivateCallback, windowProc, ACTIVATE_CALLBACK);
- OS.XtAddCallback (argList[1], OS.XmNvalueChangedCallback, windowProc, VALUE_CHANGED_CALLBACK);
- OS.XtAddEventHandler (argList[1], OS.KeyPressMask, false, windowProc, KEY_PRESS);
- OS.XtAddEventHandler (argList[1], OS.KeyReleaseMask, false, windowProc, KEY_RELEASE);
- OS.XtInsertEventHandler (argList[1], OS.FocusChangeMask, false, windowProc, FOCUS_CHANGE, OS.XtListTail);
-}
-/**
- * Searches the receiver's list starting at the first item
- * (index 0) until an item is found that is equal to the
- * argument, and returns the index of that item. If no item
- * is found, returns -1.
- *
- * @param string the search item
- * @return the index of the item
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the string is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
+public int indexOf (String string) {
+ checkWidget();
+ if (string == null) error (SWT.ERROR_NULL_ARGUMENT);
+
+ byte [] buffer = Converter.wcsToMbcs (getCodePage (), 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;
+}
+/**
+ * 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) {
- checkWidget();
- if (string == null) error (SWT.ERROR_NULL_ARGUMENT);
-
- byte [] buffer = Converter.wcsToMbcs (getCodePage (), 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;
-}
-/**
- * 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 [] 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 (getCodePage (), 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;
+}
+/**
+ * Pastes text from clipboard.
+ * <p>
+ * The selected text is deleted from the widget
+ * and new text inserted from the clipboard.
+ * </p>
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @since 2.1
*/
-public int indexOf (String string, int start) {
- checkWidget();
- 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 (getCodePage (), 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;
-}
-/**
- * Pastes text from clipboard.
- * <p>
- * The selected text is deleted from the widget
- * and new text inserted from the clipboard.
- * </p>
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @since 2.1
- */
-public void paste () {
- checkWidget();
- Display display = getDisplay ();
- boolean warnings = display.getWarnings ();
- display.setWarnings (false);
- int [] argList = {OS.XmNtextField, 0};
- OS.XtGetValues (handle, argList, argList.length / 2);
- OS.XmTextFieldPaste (argList [1]);
- display.setWarnings (warnings);
-}
-/**
- * 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 paste () {
+ checkWidget();
+ Display display = getDisplay ();
+ boolean warnings = display.getWarnings ();
+ display.setWarnings (false);
+ int [] argList = {OS.XmNtextField, 0};
+ OS.XtGetValues (handle, argList, argList.length / 2);
+ OS.XmTextFieldPaste (argList [1]);
+ display.setWarnings (warnings);
+}
+/**
+ * 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();
- 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 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 index) {
+ checkWidget();
+ 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 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;
- /*
- * 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);
-}
-/**
- * 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 (int start, int end) {
+ checkWidget();
+ 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);
+}
+/**
+ * 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();
- if (string == null) error (SWT.ERROR_NULL_ARGUMENT);
-
- byte [] buffer = Converter.wcsToMbcs (getCodePage (), 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 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 remove (String string) {
+ checkWidget();
+ if (string == null) error (SWT.ERROR_NULL_ARGUMENT);
+
+ byte [] buffer = Converter.wcsToMbcs (getCodePage (), 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 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();
- 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]);
- display.setWarnings(warnings);
- OS.XmListDeselectAllItems (argList[3]);
-
- for (int i = 0; i < argList[5]; i++) {
- OS.XmComboBoxDeletePos(handle, 1);
- }
-}
-/**
- * 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 removeAll () {
+ checkWidget();
+ 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]);
+ display.setWarnings(warnings);
+ OS.XmListDeselectAllItems (argList[3]);
+
+ for (int i = 0; i < argList[5]; i++) {
+ OS.XmComboBoxDeletePos(handle, 1);
+ }
+}
+/**
+ * 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 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 removeSelectionListener (SelectionListener listener) {
+ checkWidget();
+ if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+ if (eventTable == null) return;
+ eventTable.unhook (SWT.Selection, listener);
+ eventTable.unhook (SWT.DefaultSelection,listener);
+}
+/**
+ * Selects the item at the given zero-relative index in the receiver's
+ * list. If the item at the index was already selected, it remains
+ * selected. Indices that are out of range are ignored.
+ *
+ * @param index the index of the item to select
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
*/
-public void select (int index) {
- checkWidget();
- if (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]);
- 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])) return;
- int [] argList2 = {OS.XmNselectedPosition, index};
- ignoreSelect = true;
- OS.XtSetValues(handle, argList2, argList2.length / 2);
- ignoreSelect = false;
- }
-}
-byte [] sendIMKeyEvent (int type, XKeyEvent xEvent) {
- /*
- * Bug in Motif. On Solaris and Linux, XmImMbLookupString() clears
- * the characters from the IME. This causes the characters to be
- * stolen from the text widget. The fix is to detect that the IME
- * has been cleared and use XmTextInsert() to insert the stolen
- * characters. This problem does not happen on AIX.
- */
- byte [] mbcs = super.sendIMKeyEvent (type, xEvent);
- if (mbcs == null || xEvent.keycode != 0) return null;
- int [] argList = {OS.XmNtextField, 0};
- OS.XtGetValues (handle, argList, argList.length / 2);
- int textHandle = argList[1];
- int [] unused = new int [1];
- byte [] buffer = new byte [2];
- int length = OS.XmImMbLookupString (textHandle, xEvent, buffer, buffer.length, unused, unused);
- if (length != 0) return null;
- int [] start = new int [1], end = new int [1];
- OS.XmTextGetSelectionPosition (textHandle, start, end);
- if (start [0] == end [0]) {
- start [0] = end [0] = OS.XmTextGetInsertionPosition (textHandle);
- }
- Display display = getDisplay ();
- boolean warnings = display.getWarnings ();
- display.setWarnings (false);
- OS.XmTextReplace (textHandle, start [0], end [0], mbcs);
- int position = start [0] + mbcs.length - 1;
- OS.XmTextSetInsertionPosition (textHandle, position);
- display.setWarnings (warnings);
- return mbcs;
-}
-void setBackgroundPixel (int pixel) {
- super.setBackgroundPixel (pixel);
- int [] argList1 = {OS.XmNtextField, 0, OS.XmNlist, 0};
- OS.XtGetValues (handle, argList1, argList1.length / 2);
- int text = argList1 [1], list = argList1 [3];
- int [] argList2 = {OS.XmNforeground, 0, OS.XmNhighlightColor, 0};
- OS.XtGetValues (text, argList2, argList2.length / 2);
- OS.XmChangeColor (text, pixel);
- OS.XtSetValues (text, argList2, argList2.length / 2);
- int [] argList3 = {OS.XmNforeground, 0, OS.XmNhighlightColor, 0};
- OS.XtGetValues (list, argList3, argList3.length / 2);
- OS.XmChangeColor (list, pixel);
- OS.XtSetValues (list, argList3, argList3.length / 2);
-}
-boolean setBounds (int x, int y, int width, int height, boolean move, boolean resize) {
- checkWidget();
- int newHeight = (resize && (style & SWT.DROP_DOWN) != 0) ? getTextHeight() : height;
- return super.setBounds (x, y, width, newHeight, move, resize);
-}
-public void setFont (Font font) {
- checkWidget();
- super.setFont (font);
-
- /*
- * Bug in Motif. When a font is set in a combo box after the widget
- * is realized, the combo box does not lay out properly. For example,
- * the drop down arrow may be positioned in the middle of the text
- * field or may be invisible, positioned outside the bounds of the
- * widget. The fix is to detect these cases and force the combo box
- * to be layed out properly by temporarily growing and then shrinking
- * the widget.
- *
- * NOTE: This problem also occurs for simple combo boxes.
- */
- if (OS.XtIsRealized (handle)) {
- int [] argList = {OS.XmNwidth, 0, OS.XmNheight, 0, OS.XmNborderWidth, 0};
- OS.XtGetValues (handle, argList, argList.length / 2);
- OS.XtResizeWidget (handle, argList [1], argList [3] + 1, argList [5]);
- OS.XtResizeWidget (handle, argList [1], argList [3], argList [5]);
- }
-}
-void setForegroundPixel (int pixel) {
- int [] argList1 = {OS.XmNtextField, 0, OS.XmNlist, 0};
- OS.XtGetValues (handle, argList1, argList1.length / 2);
- int [] argList2 = {OS.XmNforeground, pixel};
- OS.XtSetValues (argList1 [1], argList2, argList2.length / 2);
- OS.XtSetValues (argList1 [3], argList2, argList2.length / 2);
- super.setForegroundPixel (pixel);
-}
-/**
- * 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 select (int index) {
+ checkWidget();
+ 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]);
+ 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])) return;
+ int [] argList2 = {OS.XmNselectedPosition, index};
+ ignoreSelect = true;
+ OS.XtSetValues(handle, argList2, argList2.length / 2);
+ ignoreSelect = false;
+ }
+}
+byte [] sendIMKeyEvent (int type, XKeyEvent xEvent) {
+ /*
+ * Bug in Motif. On Solaris and Linux, XmImMbLookupString() clears
+ * the characters from the IME. This causes the characters to be
+ * stolen from the text widget. The fix is to detect that the IME
+ * has been cleared and use XmTextInsert() to insert the stolen
+ * characters. This problem does not happen on AIX.
+ */
+ byte [] mbcs = super.sendIMKeyEvent (type, xEvent);
+ if (mbcs == null || xEvent.keycode != 0) return null;
+ int [] argList = {OS.XmNtextField, 0};
+ OS.XtGetValues (handle, argList, argList.length / 2);
+ int textHandle = argList[1];
+ int [] unused = new int [1];
+ byte [] buffer = new byte [2];
+ int length = OS.XmImMbLookupString (textHandle, xEvent, buffer, buffer.length, unused, unused);
+ if (length != 0) return null;
+ int [] start = new int [1], end = new int [1];
+ OS.XmTextGetSelectionPosition (textHandle, start, end);
+ if (start [0] == end [0]) {
+ start [0] = end [0] = OS.XmTextGetInsertionPosition (textHandle);
+ }
+ Display display = getDisplay ();
+ boolean warnings = display.getWarnings ();
+ display.setWarnings (false);
+ OS.XmTextReplace (textHandle, start [0], end [0], mbcs);
+ int position = start [0] + mbcs.length - 1;
+ OS.XmTextSetInsertionPosition (textHandle, position);
+ display.setWarnings (warnings);
+ return mbcs;
+}
+void setBackgroundPixel (int pixel) {
+ super.setBackgroundPixel (pixel);
+ int [] argList1 = {OS.XmNtextField, 0, OS.XmNlist, 0};
+ OS.XtGetValues (handle, argList1, argList1.length / 2);
+ int text = argList1 [1], list = argList1 [3];
+ int [] argList2 = {OS.XmNforeground, 0, OS.XmNhighlightColor, 0};
+ OS.XtGetValues (text, argList2, argList2.length / 2);
+ OS.XmChangeColor (text, pixel);
+ OS.XtSetValues (text, argList2, argList2.length / 2);
+ int [] argList3 = {OS.XmNforeground, 0, OS.XmNhighlightColor, 0};
+ OS.XtGetValues (list, argList3, argList3.length / 2);
+ OS.XmChangeColor (list, pixel);
+ OS.XtSetValues (list, argList3, argList3.length / 2);
+}
+boolean setBounds (int x, int y, int width, int height, boolean move, boolean resize) {
+ checkWidget();
+ int newHeight = (resize && (style & SWT.DROP_DOWN) != 0) ? getTextHeight() : height;
+ return super.setBounds (x, y, width, newHeight, move, resize);
+}
+public void setFont (Font font) {
+ checkWidget();
+ super.setFont (font);
+
+ /*
+ * Bug in Motif. When a font is set in a combo box after the widget
+ * is realized, the combo box does not lay out properly. For example,
+ * the drop down arrow may be positioned in the middle of the text
+ * field or may be invisible, positioned outside the bounds of the
+ * widget. The fix is to detect these cases and force the combo box
+ * to be layed out properly by temporarily growing and then shrinking
+ * the widget.
+ *
+ * NOTE: This problem also occurs for simple combo boxes.
+ */
+ if (OS.XtIsRealized (handle)) {
+ int [] argList = {OS.XmNwidth, 0, OS.XmNheight, 0, OS.XmNborderWidth, 0};
+ OS.XtGetValues (handle, argList, argList.length / 2);
+ OS.XtResizeWidget (handle, argList [1], argList [3] + 1, argList [5]);
+ OS.XtResizeWidget (handle, argList [1], argList [3], argList [5]);
+ }
+}
+void setForegroundPixel (int pixel) {
+ int [] argList1 = {OS.XmNtextField, 0, OS.XmNlist, 0};
+ OS.XtGetValues (handle, argList1, argList1.length / 2);
+ int [] argList2 = {OS.XmNforeground, pixel};
+ OS.XtSetValues (argList1 [1], argList2, argList2.length / 2);
+ OS.XtSetValues (argList1 [3], argList2, argList2.length / 2);
+ super.setForegroundPixel (pixel);
+}
+/**
+ * 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);
- 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 (getCodePage (), 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 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 setItem (int index, String string) {
+ checkWidget();
+ 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 (getCodePage (), 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 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);
-
- if (items.length == 0) {
- removeAll();
- return;
- }
-
- int index = 0;
- int [] table = new int [items.length];
- String codePage = getCodePage ();
- while (index < items.length) {
- String string = items [index];
- if (string == null) break;
- byte [] buffer = Converter.wcsToMbcs (codePage, 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 [] argList1 = {OS.XmNitems, ptr, OS.XmNitemCount, index};
- OS.XtSetValues (handle, argList1, argList1.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);
-
- int [] argList2 = {OS.XmNtextField, 0};
- OS.XtGetValues (handle, argList2, argList2.length / 2);
- Display display = getDisplay ();
- boolean warnings = display.getWarnings ();
- display.setWarnings (false);
- OS.XmTextSetString (argList2[1], new byte[1]);
- display.setWarnings(warnings);
- int [] argList3 = {OS.XmNlist, 0};
- OS.XtGetValues (handle, argList3, argList3.length / 2);
- int [] argList4 = {OS.XmNselectedItemCount, 0, OS.XmNselectedItems, 0};
- OS.XtSetValues (argList3 [1], argList4, argList4.length / 2);
-}
-/**
- * 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 setItems (String [] items) {
+ checkWidget();
+ if (items == null) error (SWT.ERROR_NULL_ARGUMENT);
+
+ if (items.length == 0) {
+ removeAll();
+ return;
+ }
+
+ int index = 0;
+ int [] table = new int [items.length];
+ String codePage = getCodePage ();
+ while (index < items.length) {
+ String string = items [index];
+ if (string == null) break;
+ byte [] buffer = Converter.wcsToMbcs (codePage, 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 [] argList1 = {OS.XmNitems, ptr, OS.XmNitemCount, index};
+ OS.XtSetValues (handle, argList1, argList1.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);
+
+ int [] argList2 = {OS.XmNtextField, 0};
+ OS.XtGetValues (handle, argList2, argList2.length / 2);
+ Display display = getDisplay ();
+ boolean warnings = display.getWarnings ();
+ display.setWarnings (false);
+ OS.XmTextSetString (argList2[1], new byte[1]);
+ display.setWarnings(warnings);
+ int [] argList3 = {OS.XmNlist, 0};
+ OS.XtGetValues (handle, argList3, argList3.length / 2);
+ int [] argList4 = {OS.XmNselectedItemCount, 0, OS.XmNselectedItems, 0};
+ OS.XtSetValues (argList3 [1], argList4, argList4.length / 2);
+}
+/**
+ * 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();
-
- 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 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 setSelection (Point selection) {
+ checkWidget();
+
+ 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 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);
-
- /*
- * The read-only and non-read-only cases must be handled
- * separately here because the platform will allow the
- * text of a read-only combo to be set to any value,
- * regardless of whether it appears in the combo's item
- * list or not.
- */
- if ((style & SWT.READ_ONLY) != 0) {
- int index = indexOf (string);
- if (index != -1) select (index);
- } else {
- byte [] buffer = Converter.wcsToMbcs (getCodePage (), 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);
- }
-}
-/**
- * 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 setText (String string) {
+ checkWidget();
+ if (string == null) error (SWT.ERROR_NULL_ARGUMENT);
+
+ /*
+ * The read-only and non-read-only cases must be handled
+ * separately here because the platform will allow the
+ * text of a read-only combo to be set to any value,
+ * regardless of whether it appears in the combo's item
+ * list or not.
+ */
+ if ((style & SWT.READ_ONLY) != 0) {
+ int index = indexOf (string);
+ if (index != -1) select (index);
+ } else {
+ byte [] buffer = Converter.wcsToMbcs (getCodePage (), 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);
+ }
+}
+/**
+ * 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);
- 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]);
-}
-void enableWidget (boolean enabled) {
- super.enableWidget (enabled);
- int [] argList = {
- OS.XmNlist, 0,
- OS.XmNtextField, 0,
- };
- OS.XtGetValues (handle, argList, argList.length / 2);
- enableHandle (enabled, argList [1]);
- enableHandle (enabled, argList [3]);
-}
-/**
- * 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.
+public void setTextLimit (int limit) {
+ checkWidget();
+ 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]);
+}
+void enableWidget (boolean enabled) {
+ super.enableWidget (enabled);
+ int [] argList = {
+ OS.XmNlist, 0,
+ OS.XmNtextField, 0,
+ };
+ OS.XtGetValues (handle, argList, argList.length / 2);
+ enableHandle (enabled, argList [1]);
+ enableHandle (enabled, argList [3]);
+}
+/**
+ * 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 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);
-}
-int XmNactivateCallback (int w, int client_data, int call_data) {
- postEvent (SWT.DefaultSelection);
- return 0;
-}
-int XmNselectionCallback (int w, int client_data, int call_data) {
- /*
- * Bug in MOTIF. If items have been added and removed from a
- * combo then users are able to select an empty drop-down item
- * in the combo once and force a resulting callback. In such
- * cases we want to eat this callback so that listeners are not
- * notified.
- */
- if (ignoreSelect || getSelectionIndex() == -1) return 0;
- postEvent (SWT.Selection);
- return 0;
-}
-int XmNvalueChangedCallback (int w, int client_data, int call_data) {
- sendEvent (SWT.Modify);
- return 0;
-}
-}
+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);
+}
+int XmNactivateCallback (int w, int client_data, int call_data) {
+ postEvent (SWT.DefaultSelection);
+ return 0;
+}
+int XmNselectionCallback (int w, int client_data, int call_data) {
+ /*
+ * Bug in MOTIF. If items have been added and removed from a
+ * combo then users are able to select an empty drop-down item
+ * in the combo once and force a resulting callback. In such
+ * cases we want to eat this callback so that listeners are not
+ * notified.
+ */
+ if (ignoreSelect || getSelectionIndex() == -1) return 0;
+ postEvent (SWT.Selection);
+ return 0;
+}
+int XmNvalueChangedCallback (int w, int client_data, int call_data) {
+ sendEvent (SWT.Modify);
+ return 0;
+}
+}
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
index 05c80050d1..9c03f3471b 100755
--- 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
@@ -1,16 +1,16 @@
-package org.eclipse.swt.widgets;
-
-/*
+package org.eclipse.swt.widgets;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-import org.eclipse.swt.internal.motif.*;
-import org.eclipse.swt.*;
-import org.eclipse.swt.graphics.*;
-
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+import org.eclipse.swt.internal.motif.*;
+import org.eclipse.swt.*;
+import org.eclipse.swt.graphics.*;
+
/**
* Instances of this class are controls which are capable
* of containing other controls.
@@ -34,14 +34,14 @@ import org.eclipse.swt.graphics.*;
*
* @see Canvas
*/
-public class Composite extends Scrollable {
- Layout layout;
- int damagedRegion;
- Control [] tabList;
-
-Composite () {
- /* Do nothing */
-}
+public class Composite extends Scrollable {
+ Layout layout;
+ int damagedRegion;
+ Control [] tabList;
+
+Composite () {
+ /* Do nothing */
+}
/**
* Constructs a new instance of this class given its parent
* and a style value describing its behavior and appearance.
@@ -72,232 +72,232 @@ Composite () {
* @see SWT#NO_RADIO_GROUP
* @see Widget#getStyle
*/
-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;
-}
-Control [] _getTabList () {
- if (tabList == null) return tabList;
- int count = 0;
- for (int i=0; i<tabList.length; i++) {
- if (!tabList [i].isDisposed ()) count++;
- }
- if (count == tabList.length) return tabList;
- Control [] newList = new Control [count];
- int index = 0;
- for (int i=0; i<tabList.length; i++) {
- if (!tabList [i].isDisposed ()) {
- newList [index++] = tabList [i];
- }
- }
- tabList = newList;
- return tabList;
-}
-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);
-}
-Control [] computeTabList () {
- Control result [] = super.computeTabList ();
- if (result.length == 0) return result;
- Control [] list = tabList != null ? _getTabList () : _getChildren ();
- for (int i=0; i<list.length; i++) {
- Control child = list [i];
- Control [] childList = child.computeTabList ();
- if (childList.length != 0) {
- Control [] newResult = new Control [result.length + childList.length];
- System.arraycopy (result, 0, newResult, 0, result.length);
- System.arraycopy (childList, 0, newResult, result.length, childList.length);
- result = newResult;
- }
- }
- return result;
-}
-protected void checkSubclass () {
- /* Do nothing - Subclassing is allowed */
-}
-void createHandle (int index) {
- state |= HANDLE | CANVAS;
- int parentHandle = parent.handle;
- if ((style & (SWT.H_SCROLL | SWT.V_SCROLL)) == 0) {
- int border = (style & SWT.BORDER) != 0 ? 1 : 0;
- int [] argList = {
- OS.XmNancestorSensitive, 1,
- 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 (parentHandle, null, argList, argList.length / 2);
- if (handle == 0) error (SWT.ERROR_NO_HANDLES);
- } else {
- createScrolledHandle (parentHandle);
- }
-}
-void createScrolledHandle (int topHandle) {
- int [] argList = {OS.XmNancestorSensitive, 1};
- scrolledHandle = OS.XmCreateMainWindow (topHandle, null, argList, argList.length / 2);
- if (scrolledHandle == 0) error (SWT.ERROR_NO_HANDLES);
- if ((style & (SWT.H_SCROLL | SWT.V_SCROLL)) != 0) {
- Display display = getDisplay ();
- int thickness = display.buttonShadowThickness;
- int [] argList1 = {
- OS.XmNmarginWidth, 3,
- OS.XmNmarginHeight, 3,
- OS.XmNresizePolicy, OS.XmRESIZE_NONE,
- OS.XmNshadowType, OS.XmSHADOW_IN,
- OS.XmNshadowThickness, thickness,
- };
- formHandle = OS.XmCreateForm (scrolledHandle, null, argList1, argList1.length / 2);
- if (formHandle == 0) error (SWT.ERROR_NO_HANDLES);
- int [] argList2 = {
- OS.XmNtopAttachment, OS.XmATTACH_FORM,
- OS.XmNbottomAttachment, OS.XmATTACH_FORM,
- OS.XmNleftAttachment, OS.XmATTACH_FORM,
- OS.XmNrightAttachment, OS.XmATTACH_FORM,
- OS.XmNresizable, 0,
- OS.XmNmarginWidth, 0,
- OS.XmNmarginHeight, 0,
- OS.XmNresizePolicy, OS.XmRESIZE_NONE,
- };
- handle = OS.XmCreateDrawingArea (formHandle, null, argList2, argList2.length / 2);
- } else {
- int [] argList3 = {
- 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, argList3, argList3.length / 2);
- }
- if (handle == 0) error (SWT.ERROR_NO_HANDLES);
-}
-int defaultBackground () {
- return getDisplay ().compositeBackground;
-}
-int defaultForeground () {
- return getDisplay ().compositeForeground;
-}
-public boolean forceFocus () {
- checkWidget();
- /*
- * Bug in Motif. When XtDestroyWidget() is called from
- * within a FocusOut event handler, Motif GP's. The fix
- * is to post focus events and run them when the handler
- * has returned.
- */
- Display display = getDisplay ();
- boolean oldFocusOut = display.postFocusOut;
- Control [] children = _getChildren ();
- int [] traversals = new int [children.length];
- int [] argList = new int [] {OS.XmNtraversalOn, 0};
- for (int i=0; i<children.length; i++) {
- int childHandle = children [i].topHandle ();
- OS.XtGetValues (childHandle, argList, argList.length / 2);
- if ((traversals [i] = argList [1]) != 0) {
- argList [1] = 0;
- display.postFocusOut = true;
- OS.XtSetValues (childHandle, argList, argList.length / 2);
- }
- }
- boolean result = super.forceFocus ();
- for (int i=0; i<children.length; i++) {
- argList [1] = traversals [i];
- Control control = children [i];
- if (!control.isDisposed ()) {
- int childHandle = control.topHandle ();
- OS.XtSetValues (childHandle, argList, argList.length / 2);
- if (argList [1] != 0) control.overrideTranslations ();
- }
- }
- display.postFocusOut = oldFocusOut;
- if (!display.postFocusOut) display.runFocusOutEvents ();
- return result;
-}
-/**
- * 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 affect 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 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;
+}
+Control [] _getTabList () {
+ if (tabList == null) return tabList;
+ int count = 0;
+ for (int i=0; i<tabList.length; i++) {
+ if (!tabList [i].isDisposed ()) count++;
+ }
+ if (count == tabList.length) return tabList;
+ Control [] newList = new Control [count];
+ int index = 0;
+ for (int i=0; i<tabList.length; i++) {
+ if (!tabList [i].isDisposed ()) {
+ newList [index++] = tabList [i];
+ }
+ }
+ tabList = newList;
+ return tabList;
+}
+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);
+}
+Control [] computeTabList () {
+ Control result [] = super.computeTabList ();
+ if (result.length == 0) return result;
+ Control [] list = tabList != null ? _getTabList () : _getChildren ();
+ for (int i=0; i<list.length; i++) {
+ Control child = list [i];
+ Control [] childList = child.computeTabList ();
+ if (childList.length != 0) {
+ Control [] newResult = new Control [result.length + childList.length];
+ System.arraycopy (result, 0, newResult, 0, result.length);
+ System.arraycopy (childList, 0, newResult, result.length, childList.length);
+ result = newResult;
+ }
+ }
+ return result;
+}
+protected void checkSubclass () {
+ /* Do nothing - Subclassing is allowed */
+}
+void createHandle (int index) {
+ state |= HANDLE | CANVAS;
+ int parentHandle = parent.handle;
+ if ((style & (SWT.H_SCROLL | SWT.V_SCROLL)) == 0) {
+ int border = (style & SWT.BORDER) != 0 ? 1 : 0;
+ int [] argList = {
+ OS.XmNancestorSensitive, 1,
+ 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 (parentHandle, null, argList, argList.length / 2);
+ if (handle == 0) error (SWT.ERROR_NO_HANDLES);
+ } else {
+ createScrolledHandle (parentHandle);
+ }
+}
+void createScrolledHandle (int topHandle) {
+ int [] argList = {OS.XmNancestorSensitive, 1};
+ scrolledHandle = OS.XmCreateMainWindow (topHandle, null, argList, argList.length / 2);
+ if (scrolledHandle == 0) error (SWT.ERROR_NO_HANDLES);
+ if ((style & (SWT.H_SCROLL | SWT.V_SCROLL)) != 0) {
+ Display display = getDisplay ();
+ int thickness = display.buttonShadowThickness;
+ int [] argList1 = {
+ OS.XmNmarginWidth, 3,
+ OS.XmNmarginHeight, 3,
+ OS.XmNresizePolicy, OS.XmRESIZE_NONE,
+ OS.XmNshadowType, OS.XmSHADOW_IN,
+ OS.XmNshadowThickness, thickness,
+ };
+ formHandle = OS.XmCreateForm (scrolledHandle, null, argList1, argList1.length / 2);
+ if (formHandle == 0) error (SWT.ERROR_NO_HANDLES);
+ int [] argList2 = {
+ OS.XmNtopAttachment, OS.XmATTACH_FORM,
+ OS.XmNbottomAttachment, OS.XmATTACH_FORM,
+ OS.XmNleftAttachment, OS.XmATTACH_FORM,
+ OS.XmNrightAttachment, OS.XmATTACH_FORM,
+ OS.XmNresizable, 0,
+ OS.XmNmarginWidth, 0,
+ OS.XmNmarginHeight, 0,
+ OS.XmNresizePolicy, OS.XmRESIZE_NONE,
+ };
+ handle = OS.XmCreateDrawingArea (formHandle, null, argList2, argList2.length / 2);
+ } else {
+ int [] argList3 = {
+ 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, argList3, argList3.length / 2);
+ }
+ if (handle == 0) error (SWT.ERROR_NO_HANDLES);
+}
+int defaultBackground () {
+ return getDisplay ().compositeBackground;
+}
+int defaultForeground () {
+ return getDisplay ().compositeForeground;
+}
+public boolean forceFocus () {
+ checkWidget();
+ /*
+ * Bug in Motif. When XtDestroyWidget() is called from
+ * within a FocusOut event handler, Motif GP's. The fix
+ * is to post focus events and run them when the handler
+ * has returned.
+ */
+ Display display = getDisplay ();
+ boolean oldFocusOut = display.postFocusOut;
+ Control [] children = _getChildren ();
+ int [] traversals = new int [children.length];
+ int [] argList = new int [] {OS.XmNtraversalOn, 0};
+ for (int i=0; i<children.length; i++) {
+ int childHandle = children [i].topHandle ();
+ OS.XtGetValues (childHandle, argList, argList.length / 2);
+ if ((traversals [i] = argList [1]) != 0) {
+ argList [1] = 0;
+ display.postFocusOut = true;
+ OS.XtSetValues (childHandle, argList, argList.length / 2);
+ }
+ }
+ boolean result = super.forceFocus ();
+ for (int i=0; i<children.length; i++) {
+ argList [1] = traversals [i];
+ Control control = children [i];
+ if (!control.isDisposed ()) {
+ int childHandle = control.topHandle ();
+ OS.XtSetValues (childHandle, argList, argList.length / 2);
+ if (argList [1] != 0) control.overrideTranslations ();
+ }
+ }
+ display.postFocusOut = oldFocusOut;
+ if (!display.postFocusOut) display.runFocusOutEvents ();
+ return result;
+}
+/**
+ * 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 affect 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 [] argList = {OS.XmNnumChildren, 0};
- OS.XtGetValues (handle, argList, argList.length / 2);
- return argList [1];
-}
-/**
- * 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 Control [] getChildren () {
+ checkWidget();
+ return _getChildren ();
+}
+int getChildrenCount () {
+ /*
+ * NOTE: The current implementation will count
+ * non-registered children.
+ * */
+ int [] argList = {OS.XmNnumChildren, 0};
+ OS.XtGetValues (handle, argList, argList.length / 2);
+ return argList [1];
+}
+/**
+ * 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;
-}
+public Layout getLayout () {
+ checkWidget();
+ return layout;
+}
/**
* Gets the last specified tabbing order for the control.
*
@@ -310,235 +310,235 @@ public Layout getLayout () {
*
* @see #setTabList
*/
-public Control [] getTabList () {
- checkWidget ();
- Control [] tabList = _getTabList ();
- if (tabList == null) {
- int count = 0;
- Control [] list =_getChildren ();
- for (int i=0; i<list.length; i++) {
- if (list [i].isTabGroup ()) count++;
- }
- tabList = new Control [count];
- int index = 0;
- for (int i=0; i<list.length; i++) {
- if (list [i].isTabGroup ()) {
- tabList [index++] = list [i];
- }
- }
- }
- return tabList;
-}
-void hookEvents () {
- super.hookEvents ();
- if ((state & CANVAS) != 0) {
- int windowProc = getDisplay ().windowProc;
- OS.XtInsertEventHandler (handle, 0, true, windowProc, NON_MASKABLE, OS.XtListTail);
- }
-}
-
-boolean hooksKeys () {
- return hooks (SWT.KeyDown) || hooks (SWT.KeyUp);
-}
-
-/**
- * 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 Control [] getTabList () {
+ checkWidget ();
+ Control [] tabList = _getTabList ();
+ if (tabList == null) {
+ int count = 0;
+ Control [] list =_getChildren ();
+ for (int i=0; i<list.length; i++) {
+ if (list [i].isTabGroup ()) count++;
+ }
+ tabList = new Control [count];
+ int index = 0;
+ for (int i=0; i<list.length; i++) {
+ if (list [i].isTabGroup ()) {
+ tabList [index++] = list [i];
+ }
+ }
+ }
+ return tabList;
+}
+void hookEvents () {
+ super.hookEvents ();
+ if ((state & CANVAS) != 0) {
+ int windowProc = getDisplay ().windowProc;
+ OS.XtInsertEventHandler (handle, 0, true, windowProc, NON_MASKABLE, OS.XtListTail);
+ }
+}
+
+boolean hooksKeys () {
+ return hooks (SWT.KeyDown) || hooks (SWT.KeyUp);
+}
+
+/**
+ * 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 () {
+ 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;
- 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);
-}
-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.releaseResources ();
- }
-}
-void releaseWidget () {
- releaseChildren ();
- super.releaseWidget ();
- layout = null;
- tabList = 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);
- }
- }
-}
-boolean setBounds (int x, int y, int width, int height, boolean move, boolean resize) {
- boolean changed = super.setBounds (x, y, width, height, move, resize);
- if (changed && resize && layout != null) layout.layout (this, false);
- return changed;
-}
-public boolean setFocus () {
- checkWidget ();
- 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.setFocus ()) return true;
- }
- return forceFocus ();
-}
+public void layout (boolean changed) {
+ checkWidget();
+ 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);
+}
+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.releaseResources ();
+ }
+}
+void releaseWidget () {
+ releaseChildren ();
+ super.releaseWidget ();
+ layout = null;
+ tabList = 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);
+ }
+ }
+}
+boolean setBounds (int x, int y, int width, int height, boolean move, boolean resize) {
+ boolean changed = super.setBounds (x, y, width, height, move, resize);
+ if (changed && resize && layout != null) layout.layout (this, false);
+ return changed;
+}
+public boolean setFocus () {
+ checkWidget ();
+ 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.setFocus ()) return true;
+ }
+ return forceFocus ();
+}
/**
* Sets the layout which is associated with the receiver to be
* the argument which may be null.
@@ -550,182 +550,182 @@ public boolean setFocus () {
* <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;
-}
-/**
- * Sets the tabbing order for the specified controls to
- * match the order that they occur in the argument list.
- *
- * @param tabList the ordered list of controls representing the tab order or null
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_INVALID_ARGUMENT - if a widget in the tabList is null or has been disposed</li>
- * <li>ERROR_INVALID_PARENT - if widget in the tabList is not in the same widget tree</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
+public void setLayout (Layout layout) {
+ checkWidget();
+ this.layout = layout;
+}
+/**
+ * Sets the tabbing order for the specified controls to
+ * match the order that they occur in the argument list.
+ *
+ * @param tabList the ordered list of controls representing the tab order or null
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_INVALID_ARGUMENT - if a widget in the tabList is null or has been disposed</li>
+ * <li>ERROR_INVALID_PARENT - if widget in the tabList is not in the same widget tree</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
*/
-public void setTabList (Control [] tabList) {
- checkWidget ();
- if (tabList != null) {
- for (int i=0; i<tabList.length; i++) {
- Control control = tabList [i];
- if (control == null) error (SWT.ERROR_INVALID_ARGUMENT);
- if (control.isDisposed ()) error (SWT.ERROR_INVALID_ARGUMENT);
- /*
- * This code is intentionally commented.
- * Tab lists are currently only supported
- * for the direct children of a composite.
- */
-// Shell shell = control.getShell ();
-// while (control != shell && control != this) {
-// control = control.parent;
-// }
-// if (control != this) error (SWT.ERROR_INVALID_PARENT);
- if (control.parent != this) error (SWT.ERROR_INVALID_PARENT);
- }
- Control [] newList = new Control [tabList.length];
- System.arraycopy (tabList, 0, newList, 0, tabList.length);
- tabList = newList;
- }
- this.tabList = tabList;
-}
-boolean setTabGroupFocus () {
- if (isTabItem ()) return setTabItemFocus ();
- if ((style & SWT.NO_FOCUS) == 0) {
- boolean takeFocus = true;
- if ((state & CANVAS) != 0) takeFocus = hooksKeys ();
- if (takeFocus && setTabItemFocus ()) return true;
- }
- Control [] children = _getChildren ();
- for (int i=0; i<children.length; i++) {
- Control child = children [i];
- if (child.isTabItem () && child.setTabItemFocus ()) return true;
- }
- return false;
-}
-boolean setTabItemFocus () {
- if ((style & SWT.NO_FOCUS) == 0) {
- boolean takeFocus = true;
- if ((state & CANVAS) != 0) takeFocus = hooksKeys ();
- if (takeFocus) {
- if (!isShowing ()) return false;
- if (forceFocus ()) return true;
- }
- }
- return super.setTabItemFocus ();
-}
-void setScrollbarVisible (int barHandle, boolean visible) {
- /*
- * Bug in Motif. When XtDestroyWidget() is called from
- * within a FocusOut event handler, Motif GP's. The fix
- * is to post focus events and run them when the handler
- * has returned.
- */
- Display display = getDisplay ();
- boolean oldFocusOut = display.postFocusOut;
- Control [] children = _getChildren ();
- int [] traversals = new int [children.length];
- int [] argList = new int [] {OS.XmNtraversalOn, 0};
- for (int i=0; i<children.length; i++) {
- int childHandle = children [i].topHandle ();
- OS.XtGetValues (childHandle, argList, argList.length / 2);
- if ((traversals [i] = argList [1]) != 0) {
- argList [1] = 0;
- display.postFocusOut = true;
- OS.XtSetValues (children [i].handle, argList, argList.length / 2);
- }
- }
- super.setScrollbarVisible(barHandle, visible);
- for (int i=0; i<children.length; i++) {
- argList [1] = traversals [i];
- Control control = children [i];
- if (!control.isDisposed ()) {
- int childHandle = control.topHandle ();
- OS.XtSetValues (childHandle, argList, argList.length / 2);
- if (argList [1] != 0) control.overrideTranslations ();
- }
- }
- display.postFocusOut = oldFocusOut;
- if (!display.postFocusOut) display.runFocusOutEvents ();
-}
-int traversalCode (int key, XKeyEvent xEvent) {
- if ((state & CANVAS) != 0) {
- if ((style & SWT.NO_FOCUS) != 0) return 0;
- if (hooksKeys ()) return 0;
- }
- return super.traversalCode (key, xEvent);
-}
-boolean translateMnemonic (char key, XKeyEvent xEvent) {
- if (super.translateMnemonic (key, xEvent)) return true;
- Control [] children = _getChildren ();
- for (int i=0; i<children.length; i++) {
- Control child = children [i];
- if (child.translateMnemonic (key, xEvent)) return true;
- }
- return false;
-}
-int XExposure (int w, int client_data, int call_data, int continue_to_dispatch) {
- if ((state & CANVAS) == 0) {
- return super.XExposure (w, client_data, call_data, continue_to_dispatch);
- }
- if (!hooks (SWT.Paint) && !filters (SWT.Paint)) return 0;
- if ((style & SWT.NO_MERGE_PAINTS) != 0) {
- return super.XExposure (w, client_data, call_data, continue_to_dispatch);
- }
- XExposeEvent xEvent = new XExposeEvent ();
- OS.memmove (xEvent, call_data, XExposeEvent.sizeof);
- int exposeCount = xEvent.count;
- if (exposeCount == 0) {
- if (OS.XEventsQueued (xEvent.display, OS.QueuedAfterReading) != 0) {
- XAnyEvent xAnyEvent = new XAnyEvent ();
- Display display = getDisplay ();
- display.exposeCount = display.lastExpose = 0;
- int checkExposeProc = display.checkExposeProc;
- OS.XCheckIfEvent (xEvent.display, xAnyEvent, checkExposeProc, xEvent.window);
- exposeCount = display.exposeCount;
- int lastExpose = display.lastExpose;
- if (exposeCount != 0 && lastExpose != 0) {
- XExposeEvent xExposeEvent = display.xExposeEvent;
- OS.memmove (xExposeEvent, lastExpose, XExposeEvent.sizeof);
- xExposeEvent.count = 0;
- OS.memmove (lastExpose, xExposeEvent, XExposeEvent.sizeof);
- }
- }
- }
- if (exposeCount == 0 && damagedRegion == 0) {
- return super.XExposure (w, client_data, call_data, continue_to_dispatch);
- }
- if (damagedRegion == 0) damagedRegion = OS.XCreateRegion ();
- OS.XtAddExposureToRegion (call_data, 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);
- Region region = Region.motif_new (damagedRegion);
- gc.setClipping (region);
- XRectangle rect = new XRectangle ();
- OS.XClipBox (damagedRegion, rect);
- 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;
- OS.XDestroyRegion (damagedRegion);
- damagedRegion = 0;
- return 0;
-}
-int XNonMaskable (int w, int client_data, int call_data, int continue_to_dispatch) {
- if ((state & CANVAS) != 0) {
- XExposeEvent xEvent = new XExposeEvent ();
- OS.memmove (xEvent, call_data, XExposeEvent.sizeof);
- if (xEvent.type == OS.GraphicsExpose) return XExposure (w, client_data, call_data, continue_to_dispatch);
- }
- return 0;
-}
-}
+public void setTabList (Control [] tabList) {
+ checkWidget ();
+ if (tabList != null) {
+ for (int i=0; i<tabList.length; i++) {
+ Control control = tabList [i];
+ if (control == null) error (SWT.ERROR_INVALID_ARGUMENT);
+ if (control.isDisposed ()) error (SWT.ERROR_INVALID_ARGUMENT);
+ /*
+ * This code is intentionally commented.
+ * Tab lists are currently only supported
+ * for the direct children of a composite.
+ */
+// Shell shell = control.getShell ();
+// while (control != shell && control != this) {
+// control = control.parent;
+// }
+// if (control != this) error (SWT.ERROR_INVALID_PARENT);
+ if (control.parent != this) error (SWT.ERROR_INVALID_PARENT);
+ }
+ Control [] newList = new Control [tabList.length];
+ System.arraycopy (tabList, 0, newList, 0, tabList.length);
+ tabList = newList;
+ }
+ this.tabList = tabList;
+}
+boolean setTabGroupFocus () {
+ if (isTabItem ()) return setTabItemFocus ();
+ if ((style & SWT.NO_FOCUS) == 0) {
+ boolean takeFocus = true;
+ if ((state & CANVAS) != 0) takeFocus = hooksKeys ();
+ if (takeFocus && setTabItemFocus ()) return true;
+ }
+ Control [] children = _getChildren ();
+ for (int i=0; i<children.length; i++) {
+ Control child = children [i];
+ if (child.isTabItem () && child.setTabItemFocus ()) return true;
+ }
+ return false;
+}
+boolean setTabItemFocus () {
+ if ((style & SWT.NO_FOCUS) == 0) {
+ boolean takeFocus = true;
+ if ((state & CANVAS) != 0) takeFocus = hooksKeys ();
+ if (takeFocus) {
+ if (!isShowing ()) return false;
+ if (forceFocus ()) return true;
+ }
+ }
+ return super.setTabItemFocus ();
+}
+void setScrollbarVisible (int barHandle, boolean visible) {
+ /*
+ * Bug in Motif. When XtDestroyWidget() is called from
+ * within a FocusOut event handler, Motif GP's. The fix
+ * is to post focus events and run them when the handler
+ * has returned.
+ */
+ Display display = getDisplay ();
+ boolean oldFocusOut = display.postFocusOut;
+ Control [] children = _getChildren ();
+ int [] traversals = new int [children.length];
+ int [] argList = new int [] {OS.XmNtraversalOn, 0};
+ for (int i=0; i<children.length; i++) {
+ int childHandle = children [i].topHandle ();
+ OS.XtGetValues (childHandle, argList, argList.length / 2);
+ if ((traversals [i] = argList [1]) != 0) {
+ argList [1] = 0;
+ display.postFocusOut = true;
+ OS.XtSetValues (children [i].handle, argList, argList.length / 2);
+ }
+ }
+ super.setScrollbarVisible(barHandle, visible);
+ for (int i=0; i<children.length; i++) {
+ argList [1] = traversals [i];
+ Control control = children [i];
+ if (!control.isDisposed ()) {
+ int childHandle = control.topHandle ();
+ OS.XtSetValues (childHandle, argList, argList.length / 2);
+ if (argList [1] != 0) control.overrideTranslations ();
+ }
+ }
+ display.postFocusOut = oldFocusOut;
+ if (!display.postFocusOut) display.runFocusOutEvents ();
+}
+int traversalCode (int key, XKeyEvent xEvent) {
+ if ((state & CANVAS) != 0) {
+ if ((style & SWT.NO_FOCUS) != 0) return 0;
+ if (hooksKeys ()) return 0;
+ }
+ return super.traversalCode (key, xEvent);
+}
+boolean translateMnemonic (char key, XKeyEvent xEvent) {
+ if (super.translateMnemonic (key, xEvent)) return true;
+ Control [] children = _getChildren ();
+ for (int i=0; i<children.length; i++) {
+ Control child = children [i];
+ if (child.translateMnemonic (key, xEvent)) return true;
+ }
+ return false;
+}
+int XExposure (int w, int client_data, int call_data, int continue_to_dispatch) {
+ if ((state & CANVAS) == 0) {
+ return super.XExposure (w, client_data, call_data, continue_to_dispatch);
+ }
+ if (!hooks (SWT.Paint) && !filters (SWT.Paint)) return 0;
+ if ((style & SWT.NO_MERGE_PAINTS) != 0) {
+ return super.XExposure (w, client_data, call_data, continue_to_dispatch);
+ }
+ XExposeEvent xEvent = new XExposeEvent ();
+ OS.memmove (xEvent, call_data, XExposeEvent.sizeof);
+ int exposeCount = xEvent.count;
+ if (exposeCount == 0) {
+ if (OS.XEventsQueued (xEvent.display, OS.QueuedAfterReading) != 0) {
+ XAnyEvent xAnyEvent = new XAnyEvent ();
+ Display display = getDisplay ();
+ display.exposeCount = display.lastExpose = 0;
+ int checkExposeProc = display.checkExposeProc;
+ OS.XCheckIfEvent (xEvent.display, xAnyEvent, checkExposeProc, xEvent.window);
+ exposeCount = display.exposeCount;
+ int lastExpose = display.lastExpose;
+ if (exposeCount != 0 && lastExpose != 0) {
+ XExposeEvent xExposeEvent = display.xExposeEvent;
+ OS.memmove (xExposeEvent, lastExpose, XExposeEvent.sizeof);
+ xExposeEvent.count = 0;
+ OS.memmove (lastExpose, xExposeEvent, XExposeEvent.sizeof);
+ }
+ }
+ }
+ if (exposeCount == 0 && damagedRegion == 0) {
+ return super.XExposure (w, client_data, call_data, continue_to_dispatch);
+ }
+ if (damagedRegion == 0) damagedRegion = OS.XCreateRegion ();
+ OS.XtAddExposureToRegion (call_data, 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);
+ Region region = Region.motif_new (damagedRegion);
+ gc.setClipping (region);
+ XRectangle rect = new XRectangle ();
+ OS.XClipBox (damagedRegion, rect);
+ 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;
+ OS.XDestroyRegion (damagedRegion);
+ damagedRegion = 0;
+ return 0;
+}
+int XNonMaskable (int w, int client_data, int call_data, int continue_to_dispatch) {
+ if ((state & CANVAS) != 0) {
+ XExposeEvent xEvent = new XExposeEvent ();
+ OS.memmove (xEvent, call_data, XExposeEvent.sizeof);
+ if (xEvent.type == OS.GraphicsExpose) return XExposure (w, client_data, call_data, continue_to_dispatch);
+ }
+ return 0;
+}
+}
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
index 34ec2e8925..818fa23e41 100755
--- 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
@@ -1,45 +1,45 @@
-package org.eclipse.swt.widgets;
-
-/*
+package org.eclipse.swt.widgets;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-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.*;
-import org.eclipse.swt.accessibility.*;
-
-/**
- * Control is the abstract superclass of all windowed user interface classes.
- * <p>
- * <dl>
- * <dt><b>Styles:</b>
- * <dd>BORDER</dd>
- * <dt><b>Events:</b>
- * <dd>FocusIn, FocusOut, Help, KeyDown, KeyUp, MouseDoubleClick, 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 {
- Composite parent;
- Font font;
- Menu menu;
- String toolTipText;
- Object layoutData;
- Accessible accessible;
-
-Control () {
- /* Do nothing */
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+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.*;
+import org.eclipse.swt.accessibility.*;
+
+/**
+ * Control is the abstract superclass of all windowed user interface classes.
+ * <p>
+ * <dl>
+ * <dt><b>Styles:</b>
+ * <dd>BORDER</dd>
+ * <dt><b>Events:</b>
+ * <dd>FocusIn, FocusOut, Help, KeyDown, KeyUp, MouseDoubleClick, 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 {
+ Composite parent;
+ Font font;
+ Menu menu;
+ String toolTipText;
+ Object layoutData;
+ Accessible accessible;
+
+Control () {
+ /* Do nothing */
+}
/**
* Constructs a new instance of this class given its parent
* and a style value describing its behavior and appearance.
@@ -68,63 +68,63 @@ Control () {
* @see Widget#checkSubclass
* @see Widget#getStyle
*/
-public Control (Composite parent, int style) {
- super (parent, style);
- this.parent = parent;
- createWidget (0);
-}
-/**
- * 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);
-}
+public Control (Composite parent, int style) {
+ super (parent, style);
+ this.parent = parent;
+ createWidget (0);
+}
+/**
+ * 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 help events are generated for the control,
@@ -144,167 +144,167 @@ public void addFocusListener(FocusListener listener) {
* @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);
-}
+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);
+}
/**
* Returns the preferred size of the receiver.
* <p>
@@ -332,9 +332,9 @@ public void addTraverseListener (TraverseListener listener) {
* @see #pack
* @see "computeTrim, getClientArea for controls that implement them"
*/
-public Point computeSize (int wHint, int hHint) {
- return computeSize (wHint, hHint, true);
-}
+public Point computeSize (int wHint, int hHint) {
+ return computeSize (wHint, hHint, true);
+}
/**
* Returns the preferred size of the receiver.
* <p>
@@ -369,165 +369,165 @@ public Point computeSize (int wHint, int hHint) {
* @see #pack
* @see "computeTrim, getClientArea for controls that implement them"
*/
-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);
-}
-
-Control computeTabGroup () {
- if (isTabGroup ()) return this;
- return parent.computeTabGroup ();
-}
-
-Control computeTabRoot () {
- Control [] tabList = parent._getTabList ();
- if (tabList != null) {
- int index = 0;
- while (index < tabList.length) {
- if (tabList [index] == this) break;
- index++;
- }
- if (index == tabList.length) {
- if (isTabGroup ()) return this;
- }
- }
- return parent.computeTabRoot ();
-}
-
-Control [] computeTabList () {
- if (isTabGroup ()) {
- if (getVisible () && getEnabled ()) {
- return new Control [] {this};
- }
- }
- return new Control [0];
-}
-
-void createWidget (int index) {
- checkOrientation (parent);
- super.createWidget (index);
- setParentTraversal ();
-
- /*
- * Register for the IME. This is necessary on single byte
- * platforms as well as double byte platforms in order to
- * get composed characters. For example, accented characters
- * on a German locale.
- */
- if (!hasIMSupport()) {
- OS.XmImRegister (handle, 0);
- }
-
- /*
- * 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 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);
- }
- /*
- * Make that the widget has been properly realized
- * because the widget was created after the parent
- * has been realized. This is not part of the fix
- * for Z-order in the code above.
- */
- realizeChildren ();
- }
-
- /*
- * Bug in Motif. Under certain circumstances, when a
- * text widget is created as a child of another control
- * that has drag and drop, starting a drag in the text
- * widget causes a protection fault. The fix is to
- * disable the built in drag and drop for all widgets
- * by overriding the drag start traslation.
- */
- Display display = getDisplay ();
- OS.XtOverrideTranslations (handle, display.dragTranslations);
-
- /*
- * Feature in Motif. When the XmNfontList resource is set for
- * a widget, Motif creates a copy of the fontList and disposes
- * the copy when the widget is disposed. This means that when
- * the programmer queries the font, not only will the handle be
- * different but the font will be unexpectedly disposed when
- * the widget is disposed. This can cause GP's when the font
- * is set in another widget. The fix is to cache the font that
- * the programmer provides. The initial value of the cache is
- * the default font for the widget.
- */
- font = defaultFont ();
-}
-int defaultBackground () {
- return getDisplay ().defaultBackground;
-}
-Font defaultFont () {
- return getDisplay ().defaultFont;
-}
-int defaultForeground () {
- return getDisplay ().defaultForeground;
-}
-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';
-}
-void fixFocus () {
- Shell shell = getShell ();
- Control control = this;
- while ((control = control.parent) != null) {
- if (control.setFocus () || control == shell) return;
- }
-}
-int fontHandle () {
- return handle;
-}
-/**
- * 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);
- shell.bringToTop (false);
- return XmProcessTraversal (handle, OS.XmTRAVERSE_CURRENT);
-}
-
+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);
+}
+
+Control computeTabGroup () {
+ if (isTabGroup ()) return this;
+ return parent.computeTabGroup ();
+}
+
+Control computeTabRoot () {
+ Control [] tabList = parent._getTabList ();
+ if (tabList != null) {
+ int index = 0;
+ while (index < tabList.length) {
+ if (tabList [index] == this) break;
+ index++;
+ }
+ if (index == tabList.length) {
+ if (isTabGroup ()) return this;
+ }
+ }
+ return parent.computeTabRoot ();
+}
+
+Control [] computeTabList () {
+ if (isTabGroup ()) {
+ if (getVisible () && getEnabled ()) {
+ return new Control [] {this};
+ }
+ }
+ return new Control [0];
+}
+
+void createWidget (int index) {
+ checkOrientation (parent);
+ super.createWidget (index);
+ setParentTraversal ();
+
+ /*
+ * Register for the IME. This is necessary on single byte
+ * platforms as well as double byte platforms in order to
+ * get composed characters. For example, accented characters
+ * on a German locale.
+ */
+ if (!hasIMSupport()) {
+ OS.XmImRegister (handle, 0);
+ }
+
+ /*
+ * 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 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);
+ }
+ /*
+ * Make that the widget has been properly realized
+ * because the widget was created after the parent
+ * has been realized. This is not part of the fix
+ * for Z-order in the code above.
+ */
+ realizeChildren ();
+ }
+
+ /*
+ * Bug in Motif. Under certain circumstances, when a
+ * text widget is created as a child of another control
+ * that has drag and drop, starting a drag in the text
+ * widget causes a protection fault. The fix is to
+ * disable the built in drag and drop for all widgets
+ * by overriding the drag start traslation.
+ */
+ Display display = getDisplay ();
+ OS.XtOverrideTranslations (handle, display.dragTranslations);
+
+ /*
+ * Feature in Motif. When the XmNfontList resource is set for
+ * a widget, Motif creates a copy of the fontList and disposes
+ * the copy when the widget is disposed. This means that when
+ * the programmer queries the font, not only will the handle be
+ * different but the font will be unexpectedly disposed when
+ * the widget is disposed. This can cause GP's when the font
+ * is set in another widget. The fix is to cache the font that
+ * the programmer provides. The initial value of the cache is
+ * the default font for the widget.
+ */
+ font = defaultFont ();
+}
+int defaultBackground () {
+ return getDisplay ().defaultBackground;
+}
+Font defaultFont () {
+ return getDisplay ().defaultFont;
+}
+int defaultForeground () {
+ return getDisplay ().defaultForeground;
+}
+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';
+}
+void fixFocus () {
+ Shell shell = getShell ();
+ Control control = this;
+ while ((control = control.parent) != null) {
+ if (control.setFocus () || control == shell) return;
+ }
+}
+int fontHandle () {
+ return handle;
+}
+/**
+ * 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);
+ shell.bringToTop (false);
+ return XmProcessTraversal (handle, OS.XmTRAVERSE_CURRENT);
+}
+
/**
* Returns the accessible object for the receiver.
* If this is the first time this object is requested,
@@ -545,2310 +545,2310 @@ public boolean forceFocus () {
*
* @since 2.0
*/
-public Accessible getAccessible () {
- checkWidget ();
- if (accessible == null) {
- accessible = Accessible.internal_new_Accessible (this);
- }
- return accessible;
-}
-
-/**
- * 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.motif_new (getDisplay (), getXColor (getBackgroundPixel ()));
-}
-int getBackgroundPixel () {
- int [] argList = {OS.XmNbackground, 0};
- OS.XtGetValues (handle, argList, argList.length / 2);
- return argList [1];
-}
-/**
- * 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 topHandle = topHandle ();
- int [] argList = {OS.XmNborderWidth, 0};
- OS.XtGetValues (topHandle, argList, argList.length / 2);
- return argList [1];
-}
-/**
- * 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 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]);
-}
-String getCodePage () {
- return font.codePage;
-}
-/**
- * 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();
- int [] argList = {OS.XmNsensitive, 0};
- OS.XtGetValues (topHandle (), argList, argList.length / 2);
- return argList [1] != 0;
-}
-/**
- * Returns the font that the receiver will use to paint textual information.
- *
- * @return the receiver's font
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public Font getFont () {
- checkWidget();
- return font;
-}
-
-int getFontAscent () {
-
- /* Create a font context to iterate over each element in the font list */
- int [] buffer = new int [1];
- if (!OS.XmFontListInitFontContext (buffer, font.handle)) {
- 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 () {
-
- /* Create a font context to iterate over each element in the font list */
- int [] buffer = new int [1];
- if (!OS.XmFontListInitFontContext (buffer, font.handle)) {
- 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;
-//}
-/**
- * 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.motif_new (getDisplay (), getXColor (getForegroundPixel ()));
-}
-int getForegroundPixel () {
- int [] argList = {OS.XmNforeground, 0};
- OS.XtGetValues (handle, argList, argList.length / 2);
- return argList [1];
-}
-short [] getIMCaretPos () {
- return new short[]{0, 0};
-}
-/**
- * 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 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]);
-}
-/**
- * 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;
-}
-int getNavigationType () {
- int [] argList = {OS.XmNnavigationType, 0};
- OS.XtGetValues (handle, argList, argList.length / 2);
- return argList [1];
-}
-/**
- * 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();
- 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);
-}
-/**
- * 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 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 ();
-}
-/**
- * Returns true if the widget has native IM support
- */
-boolean hasIMSupport() {
- return false;
-}
-void hookEvents () {
- int windowProc = getDisplay ().windowProc;
- OS.XtAddEventHandler (handle, OS.KeyPressMask, false, windowProc, KEY_PRESS);
- OS.XtAddEventHandler (handle, OS.KeyReleaseMask, false, windowProc, KEY_RELEASE);
- OS.XtAddEventHandler (handle, OS.ButtonPressMask, false, windowProc, BUTTON_PRESS);
- OS.XtAddEventHandler (handle, OS.ButtonReleaseMask, false, windowProc, BUTTON_RELEASE);
- OS.XtAddEventHandler (handle, OS.PointerMotionMask, false, windowProc, POINTER_MOTION);
- OS.XtAddEventHandler (handle, OS.EnterWindowMask, false, windowProc, ENTER_WINDOW);
- OS.XtAddEventHandler (handle, OS.LeaveWindowMask, false, windowProc, LEAVE_WINDOW);
- OS.XtInsertEventHandler (handle, OS.ExposureMask, false, windowProc, EXPOSURE, OS.XtListTail);
- OS.XtInsertEventHandler (handle, OS.FocusChangeMask, false, windowProc, FOCUS_CHANGE, OS.XtListTail);
- OS.XtAddCallback (handle, OS.XmNhelpCallback, windowProc, HELP_CALLBACK);
-}
-int hoverProc (int id) {
- return hoverProc (id, true);
-}
-int hoverProc (int id, boolean showTip) {
- Display display = getDisplay ();
- if (showTip) display.showToolTip (handle, toolTipText);
- sendMouseEvent (SWT.MouseHover, 0);
- return 0;
-}
-/**
- * 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) {
- checkWidget();
- if (!OS.XtIsRealized (handle)) {
- Shell shell = getShell ();
- shell.realizeWidget ();
- }
- 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 = font.handle;
- data.codePage = font.codePage;
- data.colormap = argList [5];
- }
- return xGC;
-}
-/**
- * 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 xGC, GCData data) {
- checkWidget ();
- int xDisplay = 0;
- if (data != null) xDisplay = data.display;
- if (xDisplay == 0 && handle != 0) xDisplay = OS.XtDisplay (handle);
- if (xDisplay == 0) SWT.error(SWT.ERROR_NO_HANDLES);
- OS.XFreeGC (xDisplay, xGC);
-}
-/**
- * Returns <code>true</code> if the receiver is enabled and all
- * of the receiver's ancestors are enabled, and <code>false</code>
- * otherwise. A disabled control is typically not selectable from the
- * user interface and draws with an inactive or "grayed" look.
- *
- * @return the receiver's enabled state
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see #getEnabled
- */
-public boolean isEnabled () {
- checkWidget();
- return getEnabled () && parent.isEnabled ();
-}
-boolean isFocusAncestor () {
- Display display = getDisplay ();
- Control control = display.getFocusControl ();
- while (control != null && control != this) {
- control = control.parent;
- }
- return control == this;
-}
-/**
- * Returns <code>true</code> if the receiver has the user-interface
- * focus, and <code>false</code> otherwise.
- *
- * @return the receiver's focus state
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public boolean isFocusControl () {
- checkWidget();
- 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 false;
-}
-boolean isShowing () {
- /*
- * This is not complete. Need to check if the
- * widget is obscurred by a parent or sibling.
- */
- if (!isVisible ()) return false;
- Control control = this;
- while (control != null) {
- Point size = control.getSize ();
- if (size.x == 1 || size.y == 1) {
- return false;
- }
- control = control.parent;
- }
- return true;
-}
-boolean isTabGroup () {
- Control [] tabList = parent._getTabList ();
- if (tabList != null) {
- for (int i=0; i<tabList.length; i++) {
- if (tabList [i] == this) return true;
- }
- }
- int code = traversalCode (0, null);
- if ((code & (SWT.TRAVERSE_ARROW_PREVIOUS | SWT.TRAVERSE_ARROW_NEXT)) != 0) return false;
- return (code & (SWT.TRAVERSE_TAB_PREVIOUS | SWT.TRAVERSE_TAB_NEXT)) != 0;
-}
-boolean isTabItem () {
- Control [] tabList = parent._getTabList ();
- if (tabList != null) {
- for (int i=0; i<tabList.length; i++) {
- if (tabList [i] == this) return false;
- }
- }
- int code = traversalCode (0, null);
- return (code & (SWT.TRAVERSE_ARROW_PREVIOUS | SWT.TRAVERSE_ARROW_NEXT)) != 0;
-}
-/**
- * Returns <code>true</code> if the receiver is visible and all
- * of the receiver's ancestors are visible and <code>false</code>
- * otherwise.
- *
- * @return the receiver's visibility state
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see #getVisible
- */
-public boolean isVisible () {
- checkWidget();
- return getVisible () && parent.isVisible ();
-}
-void manageChildren () {
- OS.XtSetMappedWhenManaged (handle, false);
- /*
- * Feature in Motif. When a widget is managed and an
- * ancestor in the widget hierarchy has focus, Motif
- * assigns focus to another widget in the shell. This
- * happens because Motif does not expect a non-leaf
- * widget to have the focus. The fix is to save the
- * current value of XmNtraversalOn, set the new value
- * to false, then manage the widget and restore the
- * value. This relies on the fact that Motif will
- * not reassign focus when the new widget is not
- * traversable.
- *
- * NOTE: This code currently does not work when a
- * sibling will take focus.
- */
- int topHandle = topHandle ();
- int [] argList1 = {OS.XmNtraversalOn, 0};
- OS.XtGetValues (topHandle, argList1, argList1.length / 2);
- if (argList1 [1] != 0) {
- int [] argList2 = {OS.XmNtraversalOn, 0};
- OS.XtSetValues (topHandle, argList2, argList2.length / 2);
- }
- OS.XtManageChild (handle);
- if (argList1 [1] != 0) {
- OS.XtSetValues (topHandle, argList1, argList1.length / 2);
- }
- overrideTranslations ();
- int [] argList3 = {OS.XmNborderWidth, 0};
- OS.XtGetValues (handle, argList3, argList3.length / 2);
- OS.XtResizeWidget (handle, 1, 1, argList3 [1]);
- OS.XtSetMappedWhenManaged (handle, true);
-}
-Decorations menuShell () {
- return parent.menuShell ();
-}
-boolean mnemonicHit (char key) {
- 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 IllegalArgumentException <ul>
- * <li>ERROR_INVALID_ARGUMENT - if the control has been disposed</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public void moveAbove (Control control) {
- checkWidget();
- if (control != null) {
- if (control.isDisposed ()) error(SWT.ERROR_INVALID_ARGUMENT);
- if (parent != control.parent) return;
- }
- setZOrder (control, true);
-}
-/**
- * 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 IllegalArgumentException <ul>
- * <li>ERROR_INVALID_ARGUMENT - if the control has been disposed</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public void moveBelow (Control control) {
- checkWidget();
- if (control != null) {
- if (control.isDisposed ()) error(SWT.ERROR_INVALID_ARGUMENT);
- if (parent != control.parent) return;
- }
- setZOrder (control, false);
-}
-void overrideTranslations () {
- Display display = getDisplay ();
- OS.XtOverrideTranslations (handle, display.tabTranslations);
- OS.XtOverrideTranslations (handle, display.arrowTranslations);
-}
-/**
- * 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));
-}
-void propagateChildren (boolean enabled) {
- propagateWidget (enabled);
-}
-void propagateWidget (boolean enabled) {
- propagateHandle (enabled, handle);
-}
-void realizeChildren () {
- if (!isEnabled ()) propagateWidget (false);
-}
-/**
- * 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();
- redrawWidget (0, 0, 0, 0, false);
-}
-/**
- * Causes the rectangular area of the receiver specified by
- * the arguments to be marked as needing to be redrawn.
- * The next time a paint request is processed, that area of
- * the receiver will be painted. If the <code>all</code> flag
- * is <code>true</code>, any children of the receiver which
- * intersect with the specified area will also paint their
- * intersecting areas. If the <code>all</code> flag is
- * <code>false</code>, the children will not be painted.
- *
- * @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 (width <= 0 || height <= 0) return;
- redrawWidget (x, y, width, height, all);
-}
-void redrawWidget (int x, int y, int width, int height, boolean all) {
- redrawHandle (x, y, width, height, handle);
-}
-void releaseWidget () {
- /*
- * Restore the default font for the widget in case the
- * application disposes the widget font in the dispose
- * callback. If a font is disposed while it is still
- * in use in the widget, Motif GP's.
- */
- int fontList = defaultFont ().handle;
- if (font.handle != fontList) {
- int fontHandle = fontHandle ();
- int [] argList2 = {OS.XmNfontList, fontList};
- OS.XtSetValues (fontHandle, argList2, argList2.length / 2);
- }
- super.releaseWidget ();
- Display display = getDisplay ();
- display.releaseToolTipHandle (handle);
- toolTipText = null;
- if (menu != null && !menu.isDisposed ()) {
- menu.dispose ();
- }
- menu = null;
- if (!hasIMSupport()) {
- OS.XmImUnregister (handle);
- }
- 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 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 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 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);
-}
-void sendHelpEvent (int callData) {
- Control control = this;
- while (control != null) {
- if (control.hooks (SWT.Help)) {
- control.postEvent (SWT.Help);
- return;
- }
- control = control.parent;
- }
-}
-byte [] sendIMKeyEvent (int type, XKeyEvent xEvent) {
- /*
- * Bug in Motif. On Linux only, XmImMbLookupString () does not return
- * XBufferOverflow as the status if the buffer is too small. The fix
- * is to pass a large buffer.
- */
- byte [] buffer = new byte [512];
- int [] status = new int [1], unused = new int [1];
- int length = OS.XmImMbLookupString (handle, xEvent, buffer, buffer.length, unused, status);
- if (status [0] == OS.XBufferOverflow) {
- buffer = new byte [length];
- length = OS.XmImMbLookupString (handle, xEvent, buffer, length, unused, status);
- }
- if (length == 0) return null;
-
- /* Convert from MBCS to UNICODE and send the event */
- /* Use the character encoding for the default locale */
- char [] result = Converter.mbcsToWcs (null, buffer);
- int index = 0;
- while (index < result.length) {
- if (result [index] == 0) break;
- Event event = new Event ();
- event.time = xEvent.time;
- event.character = result [index];
- setInputState (event, xEvent);
- postEvent (type, event);
- index++;
- }
- return buffer;
-}
-void sendKeyEvent (int type, XKeyEvent xEvent) {
- Event event = new Event ();
- event.time = xEvent.time;
- setKeyState (event, xEvent);
- Control control = this;
- if ((state & CANVAS) != 0) {
- if ((style & SWT.NO_FOCUS) != 0) {
- Display display = getDisplay ();
- control = display.getFocusControl ();
- }
- }
- if (control != null) {
- control.postEvent (type, event);
- }
-}
-void sendMouseEvent (int type, int button) {
- int xDisplay = OS.XtDisplay (handle);
- int xWindow = OS.XtWindow (handle);
- int [] windowX = new int [1], windowY = new int [1], mask = new int [1], unused = new int [1];
- OS.XQueryPointer (xDisplay, xWindow, unused, unused, unused, unused, windowX, windowY, mask);
- Event event = new Event ();
- event.x = windowX [0];
- event.y = windowY [0];
- setInputState (event, mask [0]);
- postEvent (type, event);
-}
-void sendMouseEvent (int type, int button, XCrossingEvent xEvent) {
- Event event = new Event ();
- event.time = xEvent.time;
- event.button = button;
- event.x = xEvent.x;
- event.y = xEvent.y;
- int [] unused = new int [1], mask = new int [1];
- OS.XQueryPointer (xEvent.display, xEvent.window, unused, unused, unused, unused, unused, unused, mask);
- setInputState (event, mask [0]);
- postEvent (type, event);
-}
-void sendMouseEvent (int type, int button, XInputEvent xEvent) {
- Event event = new Event ();
- event.time = xEvent.time;
- event.button = button;
- event.x = xEvent.x;
- event.y = xEvent.y;
- setInputState (event, xEvent);
- postEvent (type, event);
-}
-/**
- * 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 IllegalArgumentException <ul>
- * <li>ERROR_INVALID_ARGUMENT - if the argument has been disposed</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public void setBackground (Color color) {
- checkWidget();
- if (color == null) {
- setBackgroundPixel (defaultBackground ());
- } else {
- if (color.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
- 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);
-}
-boolean setBounds (int x, int y, int width, int height, boolean move, boolean resize) {
- int topHandle = topHandle ();
- if (move && resize) {
- 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);
- /*
- * 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.
- */
- width = Math.max (width - (argList [9] * 2), 1);
- height = Math.max (height - (argList [9] * 2), 1);
- boolean sameOrigin = (x == (short) argList [1]) && (y == (short) argList [3]);
- boolean sameExtent = (width == argList [5]) && (height == argList [7]);
- if (sameOrigin && sameExtent) return false;
- OS.XtConfigureWidget (topHandle, x, y, width, height, argList [9]);
- if (!sameOrigin) sendEvent (SWT.Move);
- if (!sameExtent) sendEvent (SWT.Resize);
- return true;
- }
- if (move) {
- int [] argList = {OS.XmNx, 0, OS.XmNy, 0};
- OS.XtGetValues (topHandle, argList, argList.length / 2);
- if (x == (short) argList [1] && y == (short) argList [3]) return false;
- OS.XtMoveWidget (topHandle, x, y);
- sendEvent (SWT.Move);
- return true;
- }
- if (resize) {
- int [] argList = {OS.XmNwidth, 0, OS.XmNheight, 0, OS.XmNborderWidth, 0};
- OS.XtGetValues (topHandle, argList, argList.length / 2);
- /*
- * 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.
- */
- width = Math.max (width - (argList [5] * 2), 1);
- height = Math.max (height - (argList [5] * 2), 1);
- if (width == argList [1] && height == argList [3]) return false;
- OS.XtResizeWidget (topHandle, width, height, argList [5]);
- sendEvent (SWT.Resize);
- return true;
- }
- return false;
-}
-/**
- * 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, width, height, true, true);
-}
-/**
- * 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, true, true);
-}
-/**
- * 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();
- 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);
- }
-}
-/**
- * Sets the receiver's cursor to the cursor specified by the
- * argument, or to the default cursor for that kind of control
- * if the argument is null.
- * <p>
- * When the mouse pointer passes over a control its appearance
- * is changed to match the control's cursor.
- * </p>
- *
- * @param cursor the new cursor (or null)
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_INVALID_ARGUMENT - if the argument has been disposed</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public void setCursor (Cursor cursor) {
- checkWidget();
- int display = OS.XtDisplay (handle);
- if (display == 0) return;
- int window = OS.XtWindow (handle);
- if (window == 0) {
- if (!OS.XtIsRealized (handle)) getShell ().realizeWidget ();
- window = OS.XtWindow (handle);
- if (window == 0) return;
- }
- if (cursor == null) {
- OS.XUndefineCursor (display, window);
- } else {
- if (cursor.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
- int xCursor = cursor.handle;
- OS.XDefineCursor (display, window, xCursor);
- OS.XFlush (display);
- }
-}
-/**
- * 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();
- boolean fixFocus = false;
- if (!enabled) fixFocus = isFocusAncestor ();
- enableWidget (enabled);
- if (fixFocus) fixFocus ();
- if (!enabled || (isEnabled () && enabled)) {
- propagateChildren (enabled);
- }
-}
-/**
- * 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();
- Decorations shell = menuShell ();
- shell.setSavedFocus (this);
- shell.bringToTop (false);
- return XmProcessTraversal (handle, OS.XmTRAVERSE_CURRENT);
-}
-/**
- * Sets the font that the receiver will use to paint textual information
- * to the font specified by the argument, or to the default font for that
- * kind of control if the argument is null.
- *
- * @param font the new font (or null)
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_INVALID_ARGUMENT - if the argument has been disposed</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public void setFont (Font font) {
- checkWidget();
- if (font == null) font = defaultFont ();
- if (font.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
- this.font = font;
-
- /*
- * 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, font.handle};
- OS.XtSetValues (fontHandle, argList2, argList2.length / 2);
- if (!hasIMSupport()) {
- OS.XmImSetValues (handle, argList2, argList2.length / 2);
- }
-
- /* Restore the widget size */
- OS.XtSetValues (handle, argList1, argList1.length / 2);
-}
-/**
- * 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 IllegalArgumentException <ul>
- * <li>ERROR_INVALID_ARGUMENT - if the argument has been disposed</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public void setForeground (Color color) {
- checkWidget();
- if (color == null) {
- setForegroundPixel (defaultForeground ());
- } else {
- if (color.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
- 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);
-}
-/**
- * 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, true, false);
-}
-/**
- * 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);
- setBounds (location.x, location.y, 0, 0, true, false);
-}
-/**
- * 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>
- * <li>ERROR_INVALID_ARGUMENT - if the menu has been disposed</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public void setMenu (Menu menu) {
- checkWidget();
- if (menu != null) {
- if (menu.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
- 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 <code>true</code> if the parent is successfully changed.
- *
- * @param parent the new parent for the control.
- * @return <code>true</code> if the parent is changed and <code>false</code> otherwise.
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_INVALID_ARGUMENT - if the argument has been disposed</li>
- * </ul>
- * @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.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
- return false;
-}
-void setParentTraversal () {
- /*
- * When the parent was created with NO_FOCUS, XmNtraversalOn was
- * set to false disallowing focus in the parent and all children.
- * In order to allow the new child to take focus like other platforms,
- * set XmNtraversalOn to true in the parent.
- */
- if ((parent.style & SWT.NO_FOCUS) != 0) {
- int parentHandle = parent.handle;
- int [] argList = {OS.XmNtraversalOn, 0};
- OS.XtGetValues (parentHandle, argList, argList.length / 2);
- if (argList [1] == 0) {
- argList [1] = 1;
- OS.XtSetValues (parentHandle, argList, argList.length / 2);
- parent.overrideTranslations ();
- }
- }
-}
-boolean setRadioSelection (boolean value) {
- return false;
-}
-/**
- * If the argument is <code>false</code>, causes subsequent drawing
- * operations in the receiver to be ignored. No drawing of any kind
- * can occur in the receiver until the flag is set to true.
- * Graphics operations that occurred while the flag was
- * <code>false</code> are lost. When the flag is set to <code>true</code>,
- * the entire widget is marked as needing to be redrawn.
- * <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();
-}
-boolean setTabGroupFocus () {
- return setTabItemFocus ();
-}
-boolean setTabItemFocus () {
- if (!isShowing ()) return false;
- return setFocus ();
-}
-/**
- * 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, width, height, false, true);
-}
-/**
- * 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);
- setBounds (0, 0, size.x, size.y, false, true);
-}
-/**
- * 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();
- Display display = getDisplay ();
- display.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 topHandle = topHandle ();
- int [] argList = {OS.XmNmappedWhenManaged, 0};
- OS.XtGetValues (topHandle, argList, argList.length / 2);
- if ((argList [1] != 0) == visible) return;
- boolean fixFocus = false;
- if (!visible) fixFocus = isFocusAncestor ();
- OS.XtSetMappedWhenManaged (topHandle, visible);
- if (fixFocus) fixFocus ();
- sendEvent (visible ? SWT.Show : SWT.Hide);
-}
-void setZOrder (Control control, boolean above) {
- setZOrder (control, above, true);
-}
-void setZOrder (Control control, boolean above, boolean fixChildren) {
- /*
- * 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 (fixChildren) parent.moveAbove (topHandle1, 0);
- } else {
- OS.XLowerWindow (display, window1);
- if (fixChildren) 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 (fixChildren) parent.moveAbove (topHandle1, topHandle2);
- } else {
- if (fixChildren) parent.moveBelow (topHandle1, topHandle2);
- }
-}
-public Point toControl (int x, int y) {
- checkWidget();
- 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 (x - root_x [0], y - root_y [0]);
-}
-/**
- * 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);
- return toControl (point.x, point.y);
-}
-public Point toDisplay (int x, int y) {
- checkWidget();
- short [] root_x = new short [1], root_y = new short [1];
- OS.XtTranslateCoords (handle, (short) x, (short) y, root_x, root_y);
- return new Point (root_x [0], root_y [0]);
-}
-/**
- * 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);
- return toDisplay (point.x, point.y);
-}
-boolean translateAccelerator (int key, int keysym, XKeyEvent xEvent) {
- return menuShell ().translateAccelerator (key, keysym, xEvent);
-}
-boolean translateMnemonic (char key, XKeyEvent xEvent) {
- if (!isVisible () || !isEnabled ()) return false;
- Event event = new Event();
- event.doit = mnemonicMatch (key);
- event.detail = SWT.TRAVERSE_MNEMONIC;
- event.time = xEvent.time;
- setKeyState (event, xEvent);
- return traverse (event);
-}
-boolean translateMnemonic (int key, XKeyEvent xEvent) {
- if (xEvent.state == 0) {
- int code = traversalCode (key, xEvent);
- if ((code & SWT.TRAVERSE_MNEMONIC) == 0) return false;
- } else {
- if (xEvent.state != OS.Mod1Mask) return false;
- }
- Decorations shell = menuShell ();
- if (shell.isVisible () && shell.isEnabled ()) {
- char ch = mbcsToWcs (key);
- return ch >= 0x20 && shell.translateMnemonic (ch, xEvent);
- }
- return false;
-}
-boolean translateTraversal (int key, XKeyEvent xEvent) {
- int detail = SWT.TRAVERSE_NONE;
- int code = traversalCode (key, xEvent);
- boolean all = false;
- switch (key) {
- case OS.XK_Escape:
- case OS.XK_Cancel: {
- all = true;
- detail = SWT.TRAVERSE_ESCAPE;
- break;
- }
- case OS.XK_KP_Enter:
- case OS.XK_Return: {
- all = true;
- detail = SWT.TRAVERSE_RETURN;
- break;
- }
- case OS.XK_Tab: {
- boolean next = (xEvent.state & OS.ShiftMask) == 0;
- /*
- * NOTE: This code causes Shift+Tab and Ctrl+Tab to
- * always attempt traversal which is not correct.
- * The default should be the same as a plain Tab key.
- * This behavior is currently relied on by StyledText.
- *
- * The correct behavior is to give every key to any
- * control that wants to see every key. The default
- * behavior for a Canvas should be to see every key.
- */
- switch (xEvent.state) {
- case OS.ControlMask:
- case OS.ShiftMask:
- code |= SWT.TRAVERSE_TAB_PREVIOUS | SWT.TRAVERSE_TAB_NEXT;
- }
- detail = next ? SWT.TRAVERSE_TAB_NEXT : SWT.TRAVERSE_TAB_PREVIOUS;
- break;
- }
- case OS.XK_Up:
- case OS.XK_Left:
- case OS.XK_Down:
- case OS.XK_Right: {
- boolean next = key == OS.XK_Down || key == OS.XK_Right;
- detail = next ? SWT.TRAVERSE_ARROW_NEXT : SWT.TRAVERSE_ARROW_PREVIOUS;
- break;
- }
- case OS.XK_Page_Up:
- case OS.XK_Page_Down: {
- all = true;
- if ((xEvent.state & OS.ControlMask) == 0) return false;
- /*
- * NOTE: This code causes Ctrl+PgUp and Ctrl+PgDn to always
- * attempt traversal which is not correct. This behavior is
- * currently relied on by StyledText.
- *
- * The correct behavior is to give every key to any
- * control that wants to see every key. The default
- * behavior for a Canvas should be to see every key.
- */
- code |= SWT.TRAVERSE_PAGE_NEXT | SWT.TRAVERSE_PAGE_PREVIOUS;
- detail = key == OS.XK_Page_Down ? SWT.TRAVERSE_PAGE_NEXT : SWT.TRAVERSE_PAGE_PREVIOUS;
- break;
- }
- default:
- return false;
- }
- Event event = new Event ();
- event.doit = (code & detail) != 0;
- event.detail = detail;
- event.time = xEvent.time;
- setKeyState (event, xEvent);
- Shell shell = getShell ();
- Control control = this;
- do {
- if (control.traverse (event)) return true;
- if (!event.doit && control.hooks (SWT.Traverse)) {
- return false;
- }
- if (control == shell) return false;
- control = control.parent;
- } while (all && control != null);
- return false;
-}
-int traversalCode (int key, XKeyEvent xEvent) {
- int [] argList = new int [] {OS.XmNtraversalOn, 0};
- OS.XtGetValues (handle, argList, argList.length / 2);
- if (argList [1] == 0) return 0;
- int code = SWT.TRAVERSE_RETURN | SWT.TRAVERSE_TAB_NEXT | SWT.TRAVERSE_TAB_PREVIOUS;
- Shell shell = getShell ();
- if (shell.parent != null) code |= SWT.TRAVERSE_ESCAPE;
- if (getNavigationType () == OS.XmNONE) {
- code |= SWT.TRAVERSE_ARROW_NEXT | SWT.TRAVERSE_ARROW_PREVIOUS;
- }
- return code;
-}
-boolean traverse (Event event) {
- sendEvent (SWT.Traverse, event);
- if (isDisposed ()) return false;
- if (!event.doit) return false;
- switch (event.detail) {
- case SWT.TRAVERSE_NONE: return true;
- case SWT.TRAVERSE_ESCAPE: return traverseEscape ();
- case SWT.TRAVERSE_RETURN: return traverseReturn ();
- case SWT.TRAVERSE_TAB_NEXT: return traverseGroup (true);
- case SWT.TRAVERSE_TAB_PREVIOUS: return traverseGroup (false);
- case SWT.TRAVERSE_ARROW_NEXT: return traverseItem (true);
- case SWT.TRAVERSE_ARROW_PREVIOUS: return traverseItem (false);
- case SWT.TRAVERSE_MNEMONIC: return traverseMnemonic (event.character);
- case SWT.TRAVERSE_PAGE_NEXT: return traversePage (true);
- case SWT.TRAVERSE_PAGE_PREVIOUS: return traversePage (false);
- }
- return false;
-}
-/**
- * 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;
- Event event = new Event ();
- event.doit = true;
- event.detail = traversal;
- return traverse (event);
-}
-boolean traverseEscape () {
- return false;
-}
-boolean traverseGroup (boolean next) {
- Control root = computeTabRoot ();
- Control group = computeTabGroup ();
- Control [] list = root.computeTabList ();
- int length = list.length;
- int index = 0;
- while (index < length) {
- if (list [index] == group) break;
- index++;
- }
- /*
- * It is possible (but unlikely), that application
- * code could have disposed the widget in focus in
- * or out events. Ensure that a disposed widget is
- * not accessed.
- */
- if (index == length) return false;
- int start = index, offset = (next) ? 1 : -1;
- while ((index = ((index + offset + length) % length)) != start) {
- Control control = list [index];
- if (!control.isDisposed () && control.setTabGroupFocus ()) {
- if (!isDisposed () && !isFocusControl ()) return true;
- }
- }
- if (group.isDisposed ()) return false;
- 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++;
- }
- /*
- * It is possible (but unlikely), that application
- * code could have disposed the widget in focus in
- * or out events. Ensure that a disposed widget is
- * not accessed.
- */
- int start = index, offset = (next) ? 1 : -1;
- while ((index = (index + offset + length) % length) != start) {
- Control child = children [index];
- if (!child.isDisposed () && child.isTabItem ()) {
- if (child.setTabItemFocus ()) return true;
- }
- }
- return false;
-}
-boolean traversePage (boolean next) {
- return false;
-}
-boolean traverseMnemonic (char key) {
- return mnemonicHit (key);
-}
-boolean traverseReturn () {
- return false;
-}
-/**
- * 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();
- update (false);
-}
-void update (boolean all) {
-// checkWidget();
- if (all) {
- Display display = getDisplay ();
- display.update ();
- } else {
- 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 XButtonPress (int w, int client_data, int call_data, int continue_to_dispatch) {
- Display display = getDisplay ();
- Shell shell = getShell ();
- display.hideToolTip ();
- XButtonEvent xEvent = new XButtonEvent ();
- OS.memmove (xEvent, call_data, XButtonEvent.sizeof);
- sendMouseEvent (SWT.MouseDown, xEvent.button, xEvent);
- if (xEvent.button == 2 && hooks (SWT.DragDetect)) {
- postEvent (SWT.DragDetect);
- }
- if (xEvent.button == 3 && menu != null) {
- setFocus ();
-// menu.setLocation (xEvent.x_root, xEvent.y_root);
- menu.setVisible (true);
- }
- int clickTime = display.getDoubleClickTime ();
- 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);
- }
- display.lastTime = eventTime == 0 ? 1 : eventTime;
- display.lastButton = eventButton;
-
- /*
- * It is possible that the shell may be
- * disposed at this point. If this happens
- * don't send the activate and deactivate
- * events.
- */
- if (!shell.isDisposed ()) {
- shell.setActiveControl (this);
- }
- return 0;
-}
-int XButtonRelease (int w, int client_data, int call_data, int continue_to_dispatch) {
- Display display = getDisplay ();
- display.hideToolTip ();
- XButtonEvent xEvent = new XButtonEvent ();
- OS.memmove (xEvent, call_data, XButtonEvent.sizeof);
- sendMouseEvent (SWT.MouseUp, xEvent.button, xEvent);
- return 0;
-}
-int XEnterWindow (int w, int client_data, int call_data, int continue_to_dispatch) {
- XCrossingEvent xEvent = new XCrossingEvent ();
- OS.memmove (xEvent, call_data, XCrossingEvent.sizeof);
- if (xEvent.mode != OS.NotifyNormal) return 0;
- if (xEvent.subwindow != 0) return 0;
- sendMouseEvent (SWT.MouseEnter, 0, xEvent);
- return 0;
-}
-int XExposure (int w, int client_data, int call_data, int continue_to_dispatch) {
- if (!hooks (SWT.Paint) && !filters (SWT.Paint)) return 0;
- XExposeEvent xEvent = new XExposeEvent ();
- OS.memmove (xEvent, call_data, XExposeEvent.sizeof);
- int xDisplay = OS.XtDisplay (handle);
- if (xDisplay == 0) return 0;
- Event event = new Event ();
- event.count = xEvent.count;
- event.x = xEvent.x; event.y = xEvent.y;
- event.width = xEvent.width; event.height = xEvent.height;
- GC gc = event.gc = new GC (this);
- gc.setClipping (event.x, event.y, event.width, event.height);
- sendEvent (SWT.Paint, event);
- if (!gc.isDisposed ()) gc.dispose ();
- event.gc = null;
- return 0;
-}
-int XFocusChange (int w, int client_data, int call_data, int continue_to_dispatch) {
-
- /* Get the focus change event */
- XFocusChangeEvent xEvent = new XFocusChangeEvent ();
- OS.memmove (xEvent, call_data, 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 */
- switch (xEvent.type) {
- case OS.FocusIn: {
- Shell shell = getShell ();
- xFocusIn ();
- // widget could be disposed at this point
-
- /*
- * It is possible that the shell may be
- * disposed at this point. If this happens
- * don't send the activate and deactivate
- * events.
- */
- if (!shell.isDisposed ()) {
- shell.setActiveControl (this);
- }
- break;
- }
- case OS.FocusOut: {
- Shell shell = getShell ();
- Display display = getDisplay ();
-
- xFocusOut ();
- // widget could be disposed at this point
-
- /*
- * It is possible that the shell may be
- * disposed at this point. If this happens
- * don't send the activate and deactivate
- * events.
- */
- if (!shell.isDisposed ()) {
- Control control = display.getFocusControl ();
- if (control == null || shell != control.getShell () ) {
- shell.setActiveControl (null);
- }
- }
- break;
- }
- }
- return 0;
-}
-int xFocusIn () {
- sendEvent (SWT.FocusIn);
- // widget could be disposed at this point
- if (handle == 0) return 0;
- if (!hasIMSupport()) {
- if (hooks (SWT.KeyDown) || hooks (SWT.KeyUp)) {
- short [] point = getIMCaretPos ();
- int ptr = OS.XtMalloc (4);
- OS.memmove (ptr, point, 4);
- /*
- * Bug in Motif. On Linux Japanese only, XmImSetFocusValues() causes
- * a GP when the XmNfontList resources does not containt a FontSet.
- * The fix is to call XmImSetValues() to set the values and then call
- * XmImSetFocusValues() with no parameters to set the IME focus.
- */
- int[] argList = {
-// OS.XmNforeground, getForegroundPixel(),
-// OS.XmNbackground, getBackgroundPixel(),
- OS.XmNspotLocation, ptr,
- OS.XmNfontList, font.handle,
- };
- OS.XmImSetValues (handle, argList, argList.length / 2);
- OS.XmImSetFocusValues (handle, null, 0);
- if (ptr != 0) OS.XtFree (ptr);
- }
- }
- return 0;
-}
-int xFocusOut () {
- Display display = getDisplay ();
- if (display.postFocusOut) {
- postEvent (SWT.FocusOut);
- } else {
- sendEvent (SWT.FocusOut);
- // widget could be disposed at this point
- if (handle == 0) return 0;
- }
- if (!hasIMSupport()) {
- if (hooks (SWT.KeyDown) || hooks (SWT.KeyUp)) {
- OS.XmImUnsetFocus (handle);
- }
- }
- return 0;
-}
-int XKeyPress (int w, int client_data, int call_data, int continue_to_dispatch) {
- XKeyEvent xEvent = new XKeyEvent ();
- OS.memmove (xEvent, call_data, XKeyEvent.sizeof);
- if (xEvent.keycode != 0) {
- sendKeyEvent (SWT.KeyDown, xEvent);
- } else {
- sendIMKeyEvent (SWT.KeyDown, xEvent);
- }
- return 0;
-}
-int XKeyRelease (int w, int client_data, int call_data, int continue_to_dispatch) {
- XKeyEvent xEvent = new XKeyEvent ();
- OS.memmove (xEvent, call_data, XKeyEvent.sizeof);
- if (menu != null && xEvent.state == OS.ShiftMask) {
- byte [] buffer = new byte [1];
- int [] keysym = new int [1];
- OS.XLookupString (xEvent, buffer, buffer.length, keysym, null);
- if (keysym [0] == OS.XK_F10) {
- menu.setVisible (true);
- return 0;
- }
- }
- sendKeyEvent (SWT.KeyUp, xEvent);
- return 0;
-}
-int XLeaveWindow (int w, int client_data, int call_data, int continue_to_dispatch) {
- Display display = getDisplay ();
- display.removeMouseHoverTimeOut ();
- display.hideToolTip ();
- XCrossingEvent xEvent = new XCrossingEvent ();
- OS.memmove (xEvent, call_data, XCrossingEvent.sizeof);
- if (xEvent.mode != OS.NotifyNormal) return 0;
- if (xEvent.subwindow != 0) return 0;
- sendMouseEvent (SWT.MouseExit, 0, xEvent);
- return 0;
-}
-int XmNhelpCallback (int w, int client_data, int call_data) {
- sendHelpEvent (call_data);
- return 0;
-}
-int XPointerMotion (int w, int client_data, int call_data, int continue_to_dispatch) {
- Display display = getDisplay ();
- display.addMouseHoverTimeOut (handle);
- XMotionEvent xEvent = new XMotionEvent ();
- OS.memmove (xEvent, call_data, XMotionEvent.sizeof);
- sendMouseEvent (SWT.MouseMove, 0, xEvent);
- return 0;
-}
+public Accessible getAccessible () {
+ checkWidget ();
+ if (accessible == null) {
+ accessible = Accessible.internal_new_Accessible (this);
+ }
+ return accessible;
+}
+
+/**
+ * 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.motif_new (getDisplay (), getXColor (getBackgroundPixel ()));
+}
+int getBackgroundPixel () {
+ int [] argList = {OS.XmNbackground, 0};
+ OS.XtGetValues (handle, argList, argList.length / 2);
+ return argList [1];
+}
+/**
+ * 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 topHandle = topHandle ();
+ int [] argList = {OS.XmNborderWidth, 0};
+ OS.XtGetValues (topHandle, argList, argList.length / 2);
+ return argList [1];
+}
+/**
+ * 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 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]);
+}
+String getCodePage () {
+ return font.codePage;
+}
+/**
+ * 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();
+ int [] argList = {OS.XmNsensitive, 0};
+ OS.XtGetValues (topHandle (), argList, argList.length / 2);
+ return argList [1] != 0;
+}
+/**
+ * Returns the font that the receiver will use to paint textual information.
+ *
+ * @return the receiver's font
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public Font getFont () {
+ checkWidget();
+ return font;
+}
+
+int getFontAscent () {
+
+ /* Create a font context to iterate over each element in the font list */
+ int [] buffer = new int [1];
+ if (!OS.XmFontListInitFontContext (buffer, font.handle)) {
+ 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 () {
+
+ /* Create a font context to iterate over each element in the font list */
+ int [] buffer = new int [1];
+ if (!OS.XmFontListInitFontContext (buffer, font.handle)) {
+ 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;
+//}
+/**
+ * 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.motif_new (getDisplay (), getXColor (getForegroundPixel ()));
+}
+int getForegroundPixel () {
+ int [] argList = {OS.XmNforeground, 0};
+ OS.XtGetValues (handle, argList, argList.length / 2);
+ return argList [1];
+}
+short [] getIMCaretPos () {
+ return new short[]{0, 0};
+}
+/**
+ * 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 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]);
+}
+/**
+ * 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;
+}
+int getNavigationType () {
+ int [] argList = {OS.XmNnavigationType, 0};
+ OS.XtGetValues (handle, argList, argList.length / 2);
+ return argList [1];
+}
+/**
+ * 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();
+ 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);
+}
+/**
+ * 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 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 ();
+}
+/**
+ * Returns true if the widget has native IM support
+ */
+boolean hasIMSupport() {
+ return false;
+}
+void hookEvents () {
+ int windowProc = getDisplay ().windowProc;
+ OS.XtAddEventHandler (handle, OS.KeyPressMask, false, windowProc, KEY_PRESS);
+ OS.XtAddEventHandler (handle, OS.KeyReleaseMask, false, windowProc, KEY_RELEASE);
+ OS.XtAddEventHandler (handle, OS.ButtonPressMask, false, windowProc, BUTTON_PRESS);
+ OS.XtAddEventHandler (handle, OS.ButtonReleaseMask, false, windowProc, BUTTON_RELEASE);
+ OS.XtAddEventHandler (handle, OS.PointerMotionMask, false, windowProc, POINTER_MOTION);
+ OS.XtAddEventHandler (handle, OS.EnterWindowMask, false, windowProc, ENTER_WINDOW);
+ OS.XtAddEventHandler (handle, OS.LeaveWindowMask, false, windowProc, LEAVE_WINDOW);
+ OS.XtInsertEventHandler (handle, OS.ExposureMask, false, windowProc, EXPOSURE, OS.XtListTail);
+ OS.XtInsertEventHandler (handle, OS.FocusChangeMask, false, windowProc, FOCUS_CHANGE, OS.XtListTail);
+ OS.XtAddCallback (handle, OS.XmNhelpCallback, windowProc, HELP_CALLBACK);
+}
+int hoverProc (int id) {
+ return hoverProc (id, true);
+}
+int hoverProc (int id, boolean showTip) {
+ Display display = getDisplay ();
+ if (showTip) display.showToolTip (handle, toolTipText);
+ sendMouseEvent (SWT.MouseHover, 0);
+ return 0;
+}
+/**
+ * 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) {
+ checkWidget();
+ if (!OS.XtIsRealized (handle)) {
+ Shell shell = getShell ();
+ shell.realizeWidget ();
+ }
+ 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 = font.handle;
+ data.codePage = font.codePage;
+ data.colormap = argList [5];
+ }
+ return xGC;
+}
+/**
+ * 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 xGC, GCData data) {
+ checkWidget ();
+ int xDisplay = 0;
+ if (data != null) xDisplay = data.display;
+ if (xDisplay == 0 && handle != 0) xDisplay = OS.XtDisplay (handle);
+ if (xDisplay == 0) SWT.error(SWT.ERROR_NO_HANDLES);
+ OS.XFreeGC (xDisplay, xGC);
+}
+/**
+ * Returns <code>true</code> if the receiver is enabled and all
+ * of the receiver's ancestors are enabled, and <code>false</code>
+ * otherwise. A disabled control is typically not selectable from the
+ * user interface and draws with an inactive or "grayed" look.
+ *
+ * @return the receiver's enabled state
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see #getEnabled
+ */
+public boolean isEnabled () {
+ checkWidget();
+ return getEnabled () && parent.isEnabled ();
+}
+boolean isFocusAncestor () {
+ Display display = getDisplay ();
+ Control control = display.getFocusControl ();
+ while (control != null && control != this) {
+ control = control.parent;
+ }
+ return control == this;
+}
+/**
+ * Returns <code>true</code> if the receiver has the user-interface
+ * focus, and <code>false</code> otherwise.
+ *
+ * @return the receiver's focus state
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public boolean isFocusControl () {
+ checkWidget();
+ 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 false;
+}
+boolean isShowing () {
+ /*
+ * This is not complete. Need to check if the
+ * widget is obscurred by a parent or sibling.
+ */
+ if (!isVisible ()) return false;
+ Control control = this;
+ while (control != null) {
+ Point size = control.getSize ();
+ if (size.x == 1 || size.y == 1) {
+ return false;
+ }
+ control = control.parent;
+ }
+ return true;
+}
+boolean isTabGroup () {
+ Control [] tabList = parent._getTabList ();
+ if (tabList != null) {
+ for (int i=0; i<tabList.length; i++) {
+ if (tabList [i] == this) return true;
+ }
+ }
+ int code = traversalCode (0, null);
+ if ((code & (SWT.TRAVERSE_ARROW_PREVIOUS | SWT.TRAVERSE_ARROW_NEXT)) != 0) return false;
+ return (code & (SWT.TRAVERSE_TAB_PREVIOUS | SWT.TRAVERSE_TAB_NEXT)) != 0;
+}
+boolean isTabItem () {
+ Control [] tabList = parent._getTabList ();
+ if (tabList != null) {
+ for (int i=0; i<tabList.length; i++) {
+ if (tabList [i] == this) return false;
+ }
+ }
+ int code = traversalCode (0, null);
+ return (code & (SWT.TRAVERSE_ARROW_PREVIOUS | SWT.TRAVERSE_ARROW_NEXT)) != 0;
+}
+/**
+ * Returns <code>true</code> if the receiver is visible and all
+ * of the receiver's ancestors are visible and <code>false</code>
+ * otherwise.
+ *
+ * @return the receiver's visibility state
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see #getVisible
+ */
+public boolean isVisible () {
+ checkWidget();
+ return getVisible () && parent.isVisible ();
+}
+void manageChildren () {
+ OS.XtSetMappedWhenManaged (handle, false);
+ /*
+ * Feature in Motif. When a widget is managed and an
+ * ancestor in the widget hierarchy has focus, Motif
+ * assigns focus to another widget in the shell. This
+ * happens because Motif does not expect a non-leaf
+ * widget to have the focus. The fix is to save the
+ * current value of XmNtraversalOn, set the new value
+ * to false, then manage the widget and restore the
+ * value. This relies on the fact that Motif will
+ * not reassign focus when the new widget is not
+ * traversable.
+ *
+ * NOTE: This code currently does not work when a
+ * sibling will take focus.
+ */
+ int topHandle = topHandle ();
+ int [] argList1 = {OS.XmNtraversalOn, 0};
+ OS.XtGetValues (topHandle, argList1, argList1.length / 2);
+ if (argList1 [1] != 0) {
+ int [] argList2 = {OS.XmNtraversalOn, 0};
+ OS.XtSetValues (topHandle, argList2, argList2.length / 2);
+ }
+ OS.XtManageChild (handle);
+ if (argList1 [1] != 0) {
+ OS.XtSetValues (topHandle, argList1, argList1.length / 2);
+ }
+ overrideTranslations ();
+ int [] argList3 = {OS.XmNborderWidth, 0};
+ OS.XtGetValues (handle, argList3, argList3.length / 2);
+ OS.XtResizeWidget (handle, 1, 1, argList3 [1]);
+ OS.XtSetMappedWhenManaged (handle, true);
+}
+Decorations menuShell () {
+ return parent.menuShell ();
+}
+boolean mnemonicHit (char key) {
+ 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 IllegalArgumentException <ul>
+ * <li>ERROR_INVALID_ARGUMENT - if the control has been disposed</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void moveAbove (Control control) {
+ checkWidget();
+ if (control != null) {
+ if (control.isDisposed ()) error(SWT.ERROR_INVALID_ARGUMENT);
+ if (parent != control.parent) return;
+ }
+ setZOrder (control, true);
+}
+/**
+ * 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 IllegalArgumentException <ul>
+ * <li>ERROR_INVALID_ARGUMENT - if the control has been disposed</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void moveBelow (Control control) {
+ checkWidget();
+ if (control != null) {
+ if (control.isDisposed ()) error(SWT.ERROR_INVALID_ARGUMENT);
+ if (parent != control.parent) return;
+ }
+ setZOrder (control, false);
+}
+void overrideTranslations () {
+ Display display = getDisplay ();
+ OS.XtOverrideTranslations (handle, display.tabTranslations);
+ OS.XtOverrideTranslations (handle, display.arrowTranslations);
+}
+/**
+ * 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));
+}
+void propagateChildren (boolean enabled) {
+ propagateWidget (enabled);
+}
+void propagateWidget (boolean enabled) {
+ propagateHandle (enabled, handle);
+}
+void realizeChildren () {
+ if (!isEnabled ()) propagateWidget (false);
+}
+/**
+ * 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();
+ redrawWidget (0, 0, 0, 0, false);
+}
+/**
+ * Causes the rectangular area of the receiver specified by
+ * the arguments to be marked as needing to be redrawn.
+ * The next time a paint request is processed, that area of
+ * the receiver will be painted. If the <code>all</code> flag
+ * is <code>true</code>, any children of the receiver which
+ * intersect with the specified area will also paint their
+ * intersecting areas. If the <code>all</code> flag is
+ * <code>false</code>, the children will not be painted.
+ *
+ * @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 (width <= 0 || height <= 0) return;
+ redrawWidget (x, y, width, height, all);
+}
+void redrawWidget (int x, int y, int width, int height, boolean all) {
+ redrawHandle (x, y, width, height, handle);
+}
+void releaseWidget () {
+ /*
+ * Restore the default font for the widget in case the
+ * application disposes the widget font in the dispose
+ * callback. If a font is disposed while it is still
+ * in use in the widget, Motif GP's.
+ */
+ int fontList = defaultFont ().handle;
+ if (font.handle != fontList) {
+ int fontHandle = fontHandle ();
+ int [] argList2 = {OS.XmNfontList, fontList};
+ OS.XtSetValues (fontHandle, argList2, argList2.length / 2);
+ }
+ super.releaseWidget ();
+ Display display = getDisplay ();
+ display.releaseToolTipHandle (handle);
+ toolTipText = null;
+ if (menu != null && !menu.isDisposed ()) {
+ menu.dispose ();
+ }
+ menu = null;
+ if (!hasIMSupport()) {
+ OS.XmImUnregister (handle);
+ }
+ 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 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 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 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);
+}
+void sendHelpEvent (int callData) {
+ Control control = this;
+ while (control != null) {
+ if (control.hooks (SWT.Help)) {
+ control.postEvent (SWT.Help);
+ return;
+ }
+ control = control.parent;
+ }
+}
+byte [] sendIMKeyEvent (int type, XKeyEvent xEvent) {
+ /*
+ * Bug in Motif. On Linux only, XmImMbLookupString () does not return
+ * XBufferOverflow as the status if the buffer is too small. The fix
+ * is to pass a large buffer.
+ */
+ byte [] buffer = new byte [512];
+ int [] status = new int [1], unused = new int [1];
+ int length = OS.XmImMbLookupString (handle, xEvent, buffer, buffer.length, unused, status);
+ if (status [0] == OS.XBufferOverflow) {
+ buffer = new byte [length];
+ length = OS.XmImMbLookupString (handle, xEvent, buffer, length, unused, status);
+ }
+ if (length == 0) return null;
+
+ /* Convert from MBCS to UNICODE and send the event */
+ /* Use the character encoding for the default locale */
+ char [] result = Converter.mbcsToWcs (null, buffer);
+ int index = 0;
+ while (index < result.length) {
+ if (result [index] == 0) break;
+ Event event = new Event ();
+ event.time = xEvent.time;
+ event.character = result [index];
+ setInputState (event, xEvent);
+ postEvent (type, event);
+ index++;
+ }
+ return buffer;
+}
+void sendKeyEvent (int type, XKeyEvent xEvent) {
+ Event event = new Event ();
+ event.time = xEvent.time;
+ setKeyState (event, xEvent);
+ Control control = this;
+ if ((state & CANVAS) != 0) {
+ if ((style & SWT.NO_FOCUS) != 0) {
+ Display display = getDisplay ();
+ control = display.getFocusControl ();
+ }
+ }
+ if (control != null) {
+ control.postEvent (type, event);
+ }
+}
+void sendMouseEvent (int type, int button) {
+ int xDisplay = OS.XtDisplay (handle);
+ int xWindow = OS.XtWindow (handle);
+ int [] windowX = new int [1], windowY = new int [1], mask = new int [1], unused = new int [1];
+ OS.XQueryPointer (xDisplay, xWindow, unused, unused, unused, unused, windowX, windowY, mask);
+ Event event = new Event ();
+ event.x = windowX [0];
+ event.y = windowY [0];
+ setInputState (event, mask [0]);
+ postEvent (type, event);
+}
+void sendMouseEvent (int type, int button, XCrossingEvent xEvent) {
+ Event event = new Event ();
+ event.time = xEvent.time;
+ event.button = button;
+ event.x = xEvent.x;
+ event.y = xEvent.y;
+ int [] unused = new int [1], mask = new int [1];
+ OS.XQueryPointer (xEvent.display, xEvent.window, unused, unused, unused, unused, unused, unused, mask);
+ setInputState (event, mask [0]);
+ postEvent (type, event);
+}
+void sendMouseEvent (int type, int button, XInputEvent xEvent) {
+ Event event = new Event ();
+ event.time = xEvent.time;
+ event.button = button;
+ event.x = xEvent.x;
+ event.y = xEvent.y;
+ setInputState (event, xEvent);
+ postEvent (type, event);
+}
+/**
+ * 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 IllegalArgumentException <ul>
+ * <li>ERROR_INVALID_ARGUMENT - if the argument has been disposed</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setBackground (Color color) {
+ checkWidget();
+ if (color == null) {
+ setBackgroundPixel (defaultBackground ());
+ } else {
+ if (color.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+ 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);
+}
+boolean setBounds (int x, int y, int width, int height, boolean move, boolean resize) {
+ int topHandle = topHandle ();
+ if (move && resize) {
+ 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);
+ /*
+ * 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.
+ */
+ width = Math.max (width - (argList [9] * 2), 1);
+ height = Math.max (height - (argList [9] * 2), 1);
+ boolean sameOrigin = (x == (short) argList [1]) && (y == (short) argList [3]);
+ boolean sameExtent = (width == argList [5]) && (height == argList [7]);
+ if (sameOrigin && sameExtent) return false;
+ OS.XtConfigureWidget (topHandle, x, y, width, height, argList [9]);
+ if (!sameOrigin) sendEvent (SWT.Move);
+ if (!sameExtent) sendEvent (SWT.Resize);
+ return true;
+ }
+ if (move) {
+ int [] argList = {OS.XmNx, 0, OS.XmNy, 0};
+ OS.XtGetValues (topHandle, argList, argList.length / 2);
+ if (x == (short) argList [1] && y == (short) argList [3]) return false;
+ OS.XtMoveWidget (topHandle, x, y);
+ sendEvent (SWT.Move);
+ return true;
+ }
+ if (resize) {
+ int [] argList = {OS.XmNwidth, 0, OS.XmNheight, 0, OS.XmNborderWidth, 0};
+ OS.XtGetValues (topHandle, argList, argList.length / 2);
+ /*
+ * 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.
+ */
+ width = Math.max (width - (argList [5] * 2), 1);
+ height = Math.max (height - (argList [5] * 2), 1);
+ if (width == argList [1] && height == argList [3]) return false;
+ OS.XtResizeWidget (topHandle, width, height, argList [5]);
+ sendEvent (SWT.Resize);
+ return true;
+ }
+ return false;
+}
+/**
+ * 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, width, height, true, true);
+}
+/**
+ * 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, true, true);
+}
+/**
+ * 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();
+ 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);
+ }
+}
+/**
+ * Sets the receiver's cursor to the cursor specified by the
+ * argument, or to the default cursor for that kind of control
+ * if the argument is null.
+ * <p>
+ * When the mouse pointer passes over a control its appearance
+ * is changed to match the control's cursor.
+ * </p>
+ *
+ * @param cursor the new cursor (or null)
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_INVALID_ARGUMENT - if the argument has been disposed</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setCursor (Cursor cursor) {
+ checkWidget();
+ int display = OS.XtDisplay (handle);
+ if (display == 0) return;
+ int window = OS.XtWindow (handle);
+ if (window == 0) {
+ if (!OS.XtIsRealized (handle)) getShell ().realizeWidget ();
+ window = OS.XtWindow (handle);
+ if (window == 0) return;
+ }
+ if (cursor == null) {
+ OS.XUndefineCursor (display, window);
+ } else {
+ if (cursor.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+ int xCursor = cursor.handle;
+ OS.XDefineCursor (display, window, xCursor);
+ OS.XFlush (display);
+ }
+}
+/**
+ * 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();
+ boolean fixFocus = false;
+ if (!enabled) fixFocus = isFocusAncestor ();
+ enableWidget (enabled);
+ if (fixFocus) fixFocus ();
+ if (!enabled || (isEnabled () && enabled)) {
+ propagateChildren (enabled);
+ }
+}
+/**
+ * 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();
+ Decorations shell = menuShell ();
+ shell.setSavedFocus (this);
+ shell.bringToTop (false);
+ return XmProcessTraversal (handle, OS.XmTRAVERSE_CURRENT);
+}
+/**
+ * Sets the font that the receiver will use to paint textual information
+ * to the font specified by the argument, or to the default font for that
+ * kind of control if the argument is null.
+ *
+ * @param font the new font (or null)
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_INVALID_ARGUMENT - if the argument has been disposed</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setFont (Font font) {
+ checkWidget();
+ if (font == null) font = defaultFont ();
+ if (font.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+ this.font = font;
+
+ /*
+ * 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, font.handle};
+ OS.XtSetValues (fontHandle, argList2, argList2.length / 2);
+ if (!hasIMSupport()) {
+ OS.XmImSetValues (handle, argList2, argList2.length / 2);
+ }
+
+ /* Restore the widget size */
+ OS.XtSetValues (handle, argList1, argList1.length / 2);
+}
+/**
+ * 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 IllegalArgumentException <ul>
+ * <li>ERROR_INVALID_ARGUMENT - if the argument has been disposed</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setForeground (Color color) {
+ checkWidget();
+ if (color == null) {
+ setForegroundPixel (defaultForeground ());
+ } else {
+ if (color.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+ 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);
+}
+/**
+ * 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, true, false);
+}
+/**
+ * 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);
+ setBounds (location.x, location.y, 0, 0, true, false);
+}
+/**
+ * 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>
+ * <li>ERROR_INVALID_ARGUMENT - if the menu has been disposed</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setMenu (Menu menu) {
+ checkWidget();
+ if (menu != null) {
+ if (menu.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+ 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 <code>true</code> if the parent is successfully changed.
+ *
+ * @param parent the new parent for the control.
+ * @return <code>true</code> if the parent is changed and <code>false</code> otherwise.
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_INVALID_ARGUMENT - if the argument has been disposed</li>
+ * </ul>
+ * @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.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+ return false;
+}
+void setParentTraversal () {
+ /*
+ * When the parent was created with NO_FOCUS, XmNtraversalOn was
+ * set to false disallowing focus in the parent and all children.
+ * In order to allow the new child to take focus like other platforms,
+ * set XmNtraversalOn to true in the parent.
+ */
+ if ((parent.style & SWT.NO_FOCUS) != 0) {
+ int parentHandle = parent.handle;
+ int [] argList = {OS.XmNtraversalOn, 0};
+ OS.XtGetValues (parentHandle, argList, argList.length / 2);
+ if (argList [1] == 0) {
+ argList [1] = 1;
+ OS.XtSetValues (parentHandle, argList, argList.length / 2);
+ parent.overrideTranslations ();
+ }
+ }
+}
+boolean setRadioSelection (boolean value) {
+ return false;
+}
+/**
+ * If the argument is <code>false</code>, causes subsequent drawing
+ * operations in the receiver to be ignored. No drawing of any kind
+ * can occur in the receiver until the flag is set to true.
+ * Graphics operations that occurred while the flag was
+ * <code>false</code> are lost. When the flag is set to <code>true</code>,
+ * the entire widget is marked as needing to be redrawn.
+ * <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();
+}
+boolean setTabGroupFocus () {
+ return setTabItemFocus ();
+}
+boolean setTabItemFocus () {
+ if (!isShowing ()) return false;
+ return setFocus ();
+}
+/**
+ * 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, width, height, false, true);
+}
+/**
+ * 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);
+ setBounds (0, 0, size.x, size.y, false, true);
+}
+/**
+ * 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();
+ Display display = getDisplay ();
+ display.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 topHandle = topHandle ();
+ int [] argList = {OS.XmNmappedWhenManaged, 0};
+ OS.XtGetValues (topHandle, argList, argList.length / 2);
+ if ((argList [1] != 0) == visible) return;
+ boolean fixFocus = false;
+ if (!visible) fixFocus = isFocusAncestor ();
+ OS.XtSetMappedWhenManaged (topHandle, visible);
+ if (fixFocus) fixFocus ();
+ sendEvent (visible ? SWT.Show : SWT.Hide);
+}
+void setZOrder (Control control, boolean above) {
+ setZOrder (control, above, true);
+}
+void setZOrder (Control control, boolean above, boolean fixChildren) {
+ /*
+ * 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 (fixChildren) parent.moveAbove (topHandle1, 0);
+ } else {
+ OS.XLowerWindow (display, window1);
+ if (fixChildren) 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 (fixChildren) parent.moveAbove (topHandle1, topHandle2);
+ } else {
+ if (fixChildren) parent.moveBelow (topHandle1, topHandle2);
+ }
+}
+public Point toControl (int x, int y) {
+ checkWidget();
+ 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 (x - root_x [0], y - root_y [0]);
+}
+/**
+ * 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);
+ return toControl (point.x, point.y);
+}
+public Point toDisplay (int x, int y) {
+ checkWidget();
+ short [] root_x = new short [1], root_y = new short [1];
+ OS.XtTranslateCoords (handle, (short) x, (short) y, root_x, root_y);
+ return new Point (root_x [0], root_y [0]);
+}
+/**
+ * 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);
+ return toDisplay (point.x, point.y);
+}
+boolean translateAccelerator (int key, int keysym, XKeyEvent xEvent) {
+ return menuShell ().translateAccelerator (key, keysym, xEvent);
+}
+boolean translateMnemonic (char key, XKeyEvent xEvent) {
+ if (!isVisible () || !isEnabled ()) return false;
+ Event event = new Event();
+ event.doit = mnemonicMatch (key);
+ event.detail = SWT.TRAVERSE_MNEMONIC;
+ event.time = xEvent.time;
+ setKeyState (event, xEvent);
+ return traverse (event);
+}
+boolean translateMnemonic (int key, XKeyEvent xEvent) {
+ if (xEvent.state == 0) {
+ int code = traversalCode (key, xEvent);
+ if ((code & SWT.TRAVERSE_MNEMONIC) == 0) return false;
+ } else {
+ if (xEvent.state != OS.Mod1Mask) return false;
+ }
+ Decorations shell = menuShell ();
+ if (shell.isVisible () && shell.isEnabled ()) {
+ char ch = mbcsToWcs (key);
+ return ch >= 0x20 && shell.translateMnemonic (ch, xEvent);
+ }
+ return false;
+}
+boolean translateTraversal (int key, XKeyEvent xEvent) {
+ int detail = SWT.TRAVERSE_NONE;
+ int code = traversalCode (key, xEvent);
+ boolean all = false;
+ switch (key) {
+ case OS.XK_Escape:
+ case OS.XK_Cancel: {
+ all = true;
+ detail = SWT.TRAVERSE_ESCAPE;
+ break;
+ }
+ case OS.XK_KP_Enter:
+ case OS.XK_Return: {
+ all = true;
+ detail = SWT.TRAVERSE_RETURN;
+ break;
+ }
+ case OS.XK_Tab: {
+ boolean next = (xEvent.state & OS.ShiftMask) == 0;
+ /*
+ * NOTE: This code causes Shift+Tab and Ctrl+Tab to
+ * always attempt traversal which is not correct.
+ * The default should be the same as a plain Tab key.
+ * This behavior is currently relied on by StyledText.
+ *
+ * The correct behavior is to give every key to any
+ * control that wants to see every key. The default
+ * behavior for a Canvas should be to see every key.
+ */
+ switch (xEvent.state) {
+ case OS.ControlMask:
+ case OS.ShiftMask:
+ code |= SWT.TRAVERSE_TAB_PREVIOUS | SWT.TRAVERSE_TAB_NEXT;
+ }
+ detail = next ? SWT.TRAVERSE_TAB_NEXT : SWT.TRAVERSE_TAB_PREVIOUS;
+ break;
+ }
+ case OS.XK_Up:
+ case OS.XK_Left:
+ case OS.XK_Down:
+ case OS.XK_Right: {
+ boolean next = key == OS.XK_Down || key == OS.XK_Right;
+ detail = next ? SWT.TRAVERSE_ARROW_NEXT : SWT.TRAVERSE_ARROW_PREVIOUS;
+ break;
+ }
+ case OS.XK_Page_Up:
+ case OS.XK_Page_Down: {
+ all = true;
+ if ((xEvent.state & OS.ControlMask) == 0) return false;
+ /*
+ * NOTE: This code causes Ctrl+PgUp and Ctrl+PgDn to always
+ * attempt traversal which is not correct. This behavior is
+ * currently relied on by StyledText.
+ *
+ * The correct behavior is to give every key to any
+ * control that wants to see every key. The default
+ * behavior for a Canvas should be to see every key.
+ */
+ code |= SWT.TRAVERSE_PAGE_NEXT | SWT.TRAVERSE_PAGE_PREVIOUS;
+ detail = key == OS.XK_Page_Down ? SWT.TRAVERSE_PAGE_NEXT : SWT.TRAVERSE_PAGE_PREVIOUS;
+ break;
+ }
+ default:
+ return false;
+ }
+ Event event = new Event ();
+ event.doit = (code & detail) != 0;
+ event.detail = detail;
+ event.time = xEvent.time;
+ setKeyState (event, xEvent);
+ Shell shell = getShell ();
+ Control control = this;
+ do {
+ if (control.traverse (event)) return true;
+ if (!event.doit && control.hooks (SWT.Traverse)) {
+ return false;
+ }
+ if (control == shell) return false;
+ control = control.parent;
+ } while (all && control != null);
+ return false;
+}
+int traversalCode (int key, XKeyEvent xEvent) {
+ int [] argList = new int [] {OS.XmNtraversalOn, 0};
+ OS.XtGetValues (handle, argList, argList.length / 2);
+ if (argList [1] == 0) return 0;
+ int code = SWT.TRAVERSE_RETURN | SWT.TRAVERSE_TAB_NEXT | SWT.TRAVERSE_TAB_PREVIOUS;
+ Shell shell = getShell ();
+ if (shell.parent != null) code |= SWT.TRAVERSE_ESCAPE;
+ if (getNavigationType () == OS.XmNONE) {
+ code |= SWT.TRAVERSE_ARROW_NEXT | SWT.TRAVERSE_ARROW_PREVIOUS;
+ }
+ return code;
+}
+boolean traverse (Event event) {
+ sendEvent (SWT.Traverse, event);
+ if (isDisposed ()) return false;
+ if (!event.doit) return false;
+ switch (event.detail) {
+ case SWT.TRAVERSE_NONE: return true;
+ case SWT.TRAVERSE_ESCAPE: return traverseEscape ();
+ case SWT.TRAVERSE_RETURN: return traverseReturn ();
+ case SWT.TRAVERSE_TAB_NEXT: return traverseGroup (true);
+ case SWT.TRAVERSE_TAB_PREVIOUS: return traverseGroup (false);
+ case SWT.TRAVERSE_ARROW_NEXT: return traverseItem (true);
+ case SWT.TRAVERSE_ARROW_PREVIOUS: return traverseItem (false);
+ case SWT.TRAVERSE_MNEMONIC: return traverseMnemonic (event.character);
+ case SWT.TRAVERSE_PAGE_NEXT: return traversePage (true);
+ case SWT.TRAVERSE_PAGE_PREVIOUS: return traversePage (false);
+ }
+ return false;
+}
+/**
+ * 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;
+ Event event = new Event ();
+ event.doit = true;
+ event.detail = traversal;
+ return traverse (event);
+}
+boolean traverseEscape () {
+ return false;
+}
+boolean traverseGroup (boolean next) {
+ Control root = computeTabRoot ();
+ Control group = computeTabGroup ();
+ Control [] list = root.computeTabList ();
+ int length = list.length;
+ int index = 0;
+ while (index < length) {
+ if (list [index] == group) break;
+ index++;
+ }
+ /*
+ * It is possible (but unlikely), that application
+ * code could have disposed the widget in focus in
+ * or out events. Ensure that a disposed widget is
+ * not accessed.
+ */
+ if (index == length) return false;
+ int start = index, offset = (next) ? 1 : -1;
+ while ((index = ((index + offset + length) % length)) != start) {
+ Control control = list [index];
+ if (!control.isDisposed () && control.setTabGroupFocus ()) {
+ if (!isDisposed () && !isFocusControl ()) return true;
+ }
+ }
+ if (group.isDisposed ()) return false;
+ 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++;
+ }
+ /*
+ * It is possible (but unlikely), that application
+ * code could have disposed the widget in focus in
+ * or out events. Ensure that a disposed widget is
+ * not accessed.
+ */
+ int start = index, offset = (next) ? 1 : -1;
+ while ((index = (index + offset + length) % length) != start) {
+ Control child = children [index];
+ if (!child.isDisposed () && child.isTabItem ()) {
+ if (child.setTabItemFocus ()) return true;
+ }
+ }
+ return false;
+}
+boolean traversePage (boolean next) {
+ return false;
+}
+boolean traverseMnemonic (char key) {
+ return mnemonicHit (key);
+}
+boolean traverseReturn () {
+ return false;
+}
+/**
+ * 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();
+ update (false);
+}
+void update (boolean all) {
+// checkWidget();
+ if (all) {
+ Display display = getDisplay ();
+ display.update ();
+ } else {
+ 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 XButtonPress (int w, int client_data, int call_data, int continue_to_dispatch) {
+ Display display = getDisplay ();
+ Shell shell = getShell ();
+ display.hideToolTip ();
+ XButtonEvent xEvent = new XButtonEvent ();
+ OS.memmove (xEvent, call_data, XButtonEvent.sizeof);
+ sendMouseEvent (SWT.MouseDown, xEvent.button, xEvent);
+ if (xEvent.button == 2 && hooks (SWT.DragDetect)) {
+ postEvent (SWT.DragDetect);
+ }
+ if (xEvent.button == 3 && menu != null) {
+ setFocus ();
+// menu.setLocation (xEvent.x_root, xEvent.y_root);
+ menu.setVisible (true);
+ }
+ int clickTime = display.getDoubleClickTime ();
+ 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);
+ }
+ display.lastTime = eventTime == 0 ? 1 : eventTime;
+ display.lastButton = eventButton;
+
+ /*
+ * It is possible that the shell may be
+ * disposed at this point. If this happens
+ * don't send the activate and deactivate
+ * events.
+ */
+ if (!shell.isDisposed ()) {
+ shell.setActiveControl (this);
+ }
+ return 0;
+}
+int XButtonRelease (int w, int client_data, int call_data, int continue_to_dispatch) {
+ Display display = getDisplay ();
+ display.hideToolTip ();
+ XButtonEvent xEvent = new XButtonEvent ();
+ OS.memmove (xEvent, call_data, XButtonEvent.sizeof);
+ sendMouseEvent (SWT.MouseUp, xEvent.button, xEvent);
+ return 0;
+}
+int XEnterWindow (int w, int client_data, int call_data, int continue_to_dispatch) {
+ XCrossingEvent xEvent = new XCrossingEvent ();
+ OS.memmove (xEvent, call_data, XCrossingEvent.sizeof);
+ if (xEvent.mode != OS.NotifyNormal) return 0;
+ if (xEvent.subwindow != 0) return 0;
+ sendMouseEvent (SWT.MouseEnter, 0, xEvent);
+ return 0;
+}
+int XExposure (int w, int client_data, int call_data, int continue_to_dispatch) {
+ if (!hooks (SWT.Paint) && !filters (SWT.Paint)) return 0;
+ XExposeEvent xEvent = new XExposeEvent ();
+ OS.memmove (xEvent, call_data, XExposeEvent.sizeof);
+ int xDisplay = OS.XtDisplay (handle);
+ if (xDisplay == 0) return 0;
+ Event event = new Event ();
+ event.count = xEvent.count;
+ event.x = xEvent.x; event.y = xEvent.y;
+ event.width = xEvent.width; event.height = xEvent.height;
+ GC gc = event.gc = new GC (this);
+ gc.setClipping (event.x, event.y, event.width, event.height);
+ sendEvent (SWT.Paint, event);
+ if (!gc.isDisposed ()) gc.dispose ();
+ event.gc = null;
+ return 0;
+}
+int XFocusChange (int w, int client_data, int call_data, int continue_to_dispatch) {
+
+ /* Get the focus change event */
+ XFocusChangeEvent xEvent = new XFocusChangeEvent ();
+ OS.memmove (xEvent, call_data, 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 */
+ switch (xEvent.type) {
+ case OS.FocusIn: {
+ Shell shell = getShell ();
+ xFocusIn ();
+ // widget could be disposed at this point
+
+ /*
+ * It is possible that the shell may be
+ * disposed at this point. If this happens
+ * don't send the activate and deactivate
+ * events.
+ */
+ if (!shell.isDisposed ()) {
+ shell.setActiveControl (this);
+ }
+ break;
+ }
+ case OS.FocusOut: {
+ Shell shell = getShell ();
+ Display display = getDisplay ();
+
+ xFocusOut ();
+ // widget could be disposed at this point
+
+ /*
+ * It is possible that the shell may be
+ * disposed at this point. If this happens
+ * don't send the activate and deactivate
+ * events.
+ */
+ if (!shell.isDisposed ()) {
+ Control control = display.getFocusControl ();
+ if (control == null || shell != control.getShell () ) {
+ shell.setActiveControl (null);
+ }
+ }
+ break;
+ }
+ }
+ return 0;
+}
+int xFocusIn () {
+ sendEvent (SWT.FocusIn);
+ // widget could be disposed at this point
+ if (handle == 0) return 0;
+ if (!hasIMSupport()) {
+ if (hooks (SWT.KeyDown) || hooks (SWT.KeyUp)) {
+ short [] point = getIMCaretPos ();
+ int ptr = OS.XtMalloc (4);
+ OS.memmove (ptr, point, 4);
+ /*
+ * Bug in Motif. On Linux Japanese only, XmImSetFocusValues() causes
+ * a GP when the XmNfontList resources does not containt a FontSet.
+ * The fix is to call XmImSetValues() to set the values and then call
+ * XmImSetFocusValues() with no parameters to set the IME focus.
+ */
+ int[] argList = {
+// OS.XmNforeground, getForegroundPixel(),
+// OS.XmNbackground, getBackgroundPixel(),
+ OS.XmNspotLocation, ptr,
+ OS.XmNfontList, font.handle,
+ };
+ OS.XmImSetValues (handle, argList, argList.length / 2);
+ OS.XmImSetFocusValues (handle, null, 0);
+ if (ptr != 0) OS.XtFree (ptr);
+ }
+ }
+ return 0;
+}
+int xFocusOut () {
+ Display display = getDisplay ();
+ if (display.postFocusOut) {
+ postEvent (SWT.FocusOut);
+ } else {
+ sendEvent (SWT.FocusOut);
+ // widget could be disposed at this point
+ if (handle == 0) return 0;
+ }
+ if (!hasIMSupport()) {
+ if (hooks (SWT.KeyDown) || hooks (SWT.KeyUp)) {
+ OS.XmImUnsetFocus (handle);
+ }
+ }
+ return 0;
+}
+int XKeyPress (int w, int client_data, int call_data, int continue_to_dispatch) {
+ XKeyEvent xEvent = new XKeyEvent ();
+ OS.memmove (xEvent, call_data, XKeyEvent.sizeof);
+ if (xEvent.keycode != 0) {
+ sendKeyEvent (SWT.KeyDown, xEvent);
+ } else {
+ sendIMKeyEvent (SWT.KeyDown, xEvent);
+ }
+ return 0;
+}
+int XKeyRelease (int w, int client_data, int call_data, int continue_to_dispatch) {
+ XKeyEvent xEvent = new XKeyEvent ();
+ OS.memmove (xEvent, call_data, XKeyEvent.sizeof);
+ if (menu != null && xEvent.state == OS.ShiftMask) {
+ byte [] buffer = new byte [1];
+ int [] keysym = new int [1];
+ OS.XLookupString (xEvent, buffer, buffer.length, keysym, null);
+ if (keysym [0] == OS.XK_F10) {
+ menu.setVisible (true);
+ return 0;
+ }
+ }
+ sendKeyEvent (SWT.KeyUp, xEvent);
+ return 0;
+}
+int XLeaveWindow (int w, int client_data, int call_data, int continue_to_dispatch) {
+ Display display = getDisplay ();
+ display.removeMouseHoverTimeOut ();
+ display.hideToolTip ();
+ XCrossingEvent xEvent = new XCrossingEvent ();
+ OS.memmove (xEvent, call_data, XCrossingEvent.sizeof);
+ if (xEvent.mode != OS.NotifyNormal) return 0;
+ if (xEvent.subwindow != 0) return 0;
+ sendMouseEvent (SWT.MouseExit, 0, xEvent);
+ return 0;
+}
+int XmNhelpCallback (int w, int client_data, int call_data) {
+ sendHelpEvent (call_data);
+ return 0;
+}
+int XPointerMotion (int w, int client_data, int call_data, int continue_to_dispatch) {
+ Display display = getDisplay ();
+ display.addMouseHoverTimeOut (handle);
+ XMotionEvent xEvent = new XMotionEvent ();
+ OS.memmove (xEvent, call_data, XMotionEvent.sizeof);
+ sendMouseEvent (SWT.MouseMove, 0, xEvent);
+ return 0;
+}
} \ No newline at end of file
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
index 74a4f6e6df..820b62cbe8 100755
--- 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
@@ -1,16 +1,16 @@
-package org.eclipse.swt.widgets;
-
-/*
+package org.eclipse.swt.widgets;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-import org.eclipse.swt.internal.motif.*;
-import org.eclipse.swt.*;
-import org.eclipse.swt.graphics.*;
-
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+import org.eclipse.swt.internal.motif.*;
+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
@@ -83,18 +83,18 @@ import org.eclipse.swt.graphics.*;
* @see Shell
* @see SWT
*/
-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 */
-}
+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 */
+}
/**
* Constructs a new instance of this class given its parent
* and a style value describing its behavior and appearance.
@@ -133,352 +133,352 @@ Decorations () {
* @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 bringToTop (boolean force) {
- moveAbove (null);
-}
-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);
-}
-
-Control computeTabGroup () {
- return this;
-}
-
-Control computeTabRoot () {
- return this;
-}
-
-public Rectangle computeTrim (int x, int y, int width, int height) {
- checkWidget();
- 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);
-}
-/**
- * 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 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 (boolean force) {
+ moveAbove (null);
+}
+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);
+}
+
+Control computeTabGroup () {
+ return this;
+}
+
+Control computeTabRoot () {
+ return this;
+}
+
+public Rectangle computeTrim (int x, int y, int width, int height) {
+ checkWidget();
+ 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);
+}
+/**
+ * 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 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;
-}
-/**
- * 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 Image getImage () {
+ checkWidget();
+ return image;
+}
+/**
+ * Returns <code>true</code> if the receiver is currently
+ * maximized, and false otherwise.
+ * <p>
+ *
+ * @return the maximized state
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see #setMaximized
*/
-public boolean getMaximized () {
- checkWidget();
- return maximized;
-}
-/**
- * Returns the receiver's menu bar if one had previously
- * been set, otherwise returns null.
- *
- * @return the menu bar or null
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
+public boolean getMaximized () {
+ checkWidget();
+ return maximized;
+}
+/**
+ * Returns the receiver's menu bar if one had previously
+ * been set, otherwise returns null.
+ *
+ * @return the menu bar or null
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
*/
-public Menu getMenuBar () {
- checkWidget();
- return menuBar;
-}
-/**
- * Returns <code>true</code> if the receiver is currently
- * minimized, and false otherwise.
- * <p>
- *
- * @return the minimized state
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see #setMinimized
+public Menu getMenuBar () {
+ checkWidget();
+ return menuBar;
+}
+/**
+ * Returns <code>true</code> if the receiver is currently
+ * minimized, and false otherwise.
+ * <p>
+ *
+ * @return the minimized state
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see #setMinimized
*/
-public boolean getMinimized () {
- checkWidget();
- return minimized;
-}
-String getNameText () {
- return getText ();
-}
-/**
- * Returns the receiver's text, which is the string that the
- * window manager will typically display as the receiver's
- * <em>title</em>. If the text has not previously been set,
- * returns an empty string.
- *
- * @return the text
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
+public boolean getMinimized () {
+ checkWidget();
+ return minimized;
+}
+String getNameText () {
+ return getText ();
+}
+/**
+ * Returns the receiver's text, which is the string that the
+ * window manager will typically display as the receiver's
+ * <em>title</em>. If the text has not previously been set,
+ * returns an empty string.
+ *
+ * @return the text
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
*/
-public String getText () {
- checkWidget();
- return label;
-}
-boolean isTabGroup () {
- return true;
-}
-boolean isTabItem () {
- return false;
-}
-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.releaseResources ();
- }
- }
- menuBar = null;
- menus = null;
- super.releaseWidget ();
- defaultButton = saveDefault = null;
- label = null;
-}
-boolean restoreFocus () {
- if (savedFocus != null && savedFocus.isDisposed ()) savedFocus = null;
- boolean restored = savedFocus != null && savedFocus.setFocus ();
- savedFocus = null;
- /*
- * This code is intentionally commented. When no widget
- * has been given focus, some platforms give focus to the
- * default button. Motif doesn't do this.
- */
-// if (restored) return true;
-// if (defaultButton != null && !defaultButton.isDisposed ()) {
-// if (defaultButton.setFocus ()) return true;
-// }
-// return false;
- return restored;
-}
-void remove (Menu menu) {
- if (menus == null) return;
- for (int i=0; i<menus.length; i++) {
- if (menus [i] == menu) {
- menus [i] = null;
- return;
- }
- }
-}
-/**
- * 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 IllegalArgumentException <ul>
- * <li>ERROR_INVALID_ARGUMENT - if the button has been disposed</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
+public String getText () {
+ checkWidget();
+ return label;
+}
+boolean isTabGroup () {
+ return true;
+}
+boolean isTabItem () {
+ return false;
+}
+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.releaseResources ();
+ }
+ }
+ menuBar = null;
+ menus = null;
+ super.releaseWidget ();
+ defaultButton = saveDefault = null;
+ label = null;
+}
+boolean restoreFocus () {
+ if (savedFocus != null && savedFocus.isDisposed ()) savedFocus = null;
+ boolean restored = savedFocus != null && savedFocus.setFocus ();
+ savedFocus = null;
+ /*
+ * This code is intentionally commented. When no widget
+ * has been given focus, some platforms give focus to the
+ * default button. Motif doesn't do this.
+ */
+// if (restored) return true;
+// if (defaultButton != null && !defaultButton.isDisposed ()) {
+// if (defaultButton.setFocus ()) return true;
+// }
+// return false;
+ return restored;
+}
+void remove (Menu menu) {
+ if (menus == null) return;
+ for (int i=0; i<menus.length; i++) {
+ if (menus [i] == menu) {
+ menus [i] = null;
+ return;
+ }
+ }
+}
+/**
+ * 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 IllegalArgumentException <ul>
+ * <li>ERROR_INVALID_ARGUMENT - if the button has been disposed</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
*/
-public void setDefaultButton (Button button) {
- checkWidget();
- setDefaultButton (button, true);
-}
-void setDefaultButton (Button button, boolean save) {
- if (button == null) {
- if (defaultButton == saveDefault) {
- if (save) saveDefault = null;
- return;
- }
- } else {
- if (button.isDisposed()) error(SWT.ERROR_INVALID_ARGUMENT);
- 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 = defaultButton;
- if (saveDefault != null && saveDefault.isDisposed ()) saveDefault = null;
-}
-/**
- * Sets the receiver's image to the argument, which may
- * be null. The image is typically displayed by the window
- * manager when the instance is marked as iconified, and
- * may also be displayed somewhere in the trim when the
- * instance is in normal or maximized states.
- *
- * @param image the new image (or null)
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_INVALID_ARGUMENT - if the image has been disposed</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
+public void setDefaultButton (Button button) {
+ checkWidget();
+ setDefaultButton (button, true);
+}
+void setDefaultButton (Button button, boolean save) {
+ if (button == null) {
+ if (defaultButton == saveDefault) {
+ if (save) saveDefault = null;
+ return;
+ }
+ } else {
+ if (button.isDisposed()) error(SWT.ERROR_INVALID_ARGUMENT);
+ 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 = defaultButton;
+ if (saveDefault != null && saveDefault.isDisposed ()) saveDefault = null;
+}
+/**
+ * Sets the receiver's image to the argument, which may
+ * be null. The image is typically displayed by the window
+ * manager when the instance is marked as iconified, and
+ * may also be displayed somewhere in the trim when the
+ * instance is in normal or maximized states.
+ *
+ * @param image the new image (or null)
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_INVALID_ARGUMENT - if the image has been disposed</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
*/
-public void setImage (Image image) {
- checkWidget();
- int pixmap = 0, mask = 0;
- if (image != null) {
- if (image.isDisposed()) error(SWT.ERROR_INVALID_ARGUMENT);
- 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);
-}
-/**
- * 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 setImage (Image image) {
+ checkWidget();
+ int pixmap = 0, mask = 0;
+ if (image != null) {
+ if (image.isDisposed()) error(SWT.ERROR_INVALID_ARGUMENT);
+ 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);
+}
+/**
+ * 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();
- this.maximized = maximized;
-}
+public void setMaximized (boolean maximized) {
+ checkWidget();
+ this.maximized = maximized;
+}
/**
* Sets the receiver's menu bar to the argument, which
* may be null.
@@ -494,207 +494,207 @@ public void setMaximized (boolean maximized) {
* <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.isDisposed()) error(SWT.ERROR_INVALID_ARGUMENT);
- 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);
- }
- menuBar.removeAccelerators ();
- }
- if (menu != null) {
- if (!isEnabled ()) {
- propagateHandle (false, menu.handle);
- }
- menu.addAccelerators ();
- }
-
- /* Save the old client area */
- int [] argList1 = {OS.XmNwidth, 0, OS.XmNheight, 0};
- OS.XtGetValues (handle, argList1, argList1.length / 2);
-
- /*
- * 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]);
- }
-
- /*
- * Compare the old client area with the new client area.
- * If the client area has changed, send a resize event
- * and layout.
- */
- int [] argList2 = {OS.XmNwidth, 0, OS.XmNheight, 0};
- OS.XtGetValues (handle, argList2, argList2.length / 2);
- if (argList1 [1] != argList2 [1] || argList1 [3] != argList2 [3]) {
- sendEvent (SWT.Resize);
- if (layout != null) layout (false);
- }
-}
-/**
- * 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 setMenuBar (Menu menu) {
+ checkWidget();
+ if (menuBar == menu) return;
+ if (menu != null) {
+ if (menu.isDisposed()) error(SWT.ERROR_INVALID_ARGUMENT);
+ 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);
+ }
+ menuBar.removeAccelerators ();
+ }
+ if (menu != null) {
+ if (!isEnabled ()) {
+ propagateHandle (false, menu.handle);
+ }
+ menu.addAccelerators ();
+ }
+
+ /* Save the old client area */
+ int [] argList1 = {OS.XmNwidth, 0, OS.XmNheight, 0};
+ OS.XtGetValues (handle, argList1, argList1.length / 2);
+
+ /*
+ * 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]);
+ }
+
+ /*
+ * Compare the old client area with the new client area.
+ * If the client area has changed, send a resize event
+ * and layout.
+ */
+ int [] argList2 = {OS.XmNwidth, 0, OS.XmNheight, 0};
+ OS.XtGetValues (handle, argList2, argList2.length / 2);
+ if (argList1 [1] != argList2 [1] || argList1 [3] != argList2 [3]) {
+ sendEvent (SWT.Resize);
+ if (layout != null) layout (false);
+ }
+}
+/**
+ * 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();
- this.minimized = minimized;
-}
-void setSavedFocus (Control control) {
- if (this == control) return;
- savedFocus = control;
-}
-/**
- * Sets the receiver's text, which is the string that the
- * window manager will typically display as the receiver's
- * <em>title</em>, to the argument, which 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 setMinimized (boolean minimized) {
+ checkWidget();
+ this.minimized = minimized;
+}
+void setSavedFocus (Control control) {
+ if (this == control) return;
+ savedFocus = control;
+}
+/**
+ * Sets the receiver's text, which is the string that the
+ * window manager will typically display as the receiver's
+ * <em>title</em>, to the argument, which 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);
- label = string;
-}
-boolean translateAccelerator (int key, int keysym, XKeyEvent xEvent) {
- /*
- * Bug in Solaris. When accelerators are set more
- * than once in the same menu bar, the time it takes
- * to set the accelerator increases exponentially.
- * The fix is to implement our own accelerator table
- * on Solaris.
- */
- if (OS.IsSunOS) {
- if (menuBar != null && menuBar.getEnabled ()) {
- /* Ignore modifiers. */
- switch (keysym) {
- case OS.XK_Control_L:
- case OS.XK_Control_R:
- case OS.XK_Alt_L:
- case OS.XK_Alt_R:
- case OS.XK_Shift_L:
- case OS.XK_Shift_R:
- return false;
- }
-
- /*
- * 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 (keysym != 0) {
- switch (keysym) {
- case 0x1005FF10:
- keysym = OS.XK_F11;
- key = 0;
- break;
- case 0x1005FF11:
- keysym = OS.XK_F12;
- key = 0;
- break;
- }
- /*
- * Bug in MOTIF. On Solaris only, there 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 &= 0xFFFF;
- }
-
- /*
- * Bug in Motif. There are some keycodes for which
- * XLookupString() does not translate the character.
- * Some of examples are Shift+Tab and Ctrl+Space.
- */
- switch (keysym) {
- case OS.XK_ISO_Left_Tab: key = '\t'; break;
- case OS.XK_space: key = ' '; break;
- }
-
- int accelerator = Display.translateKey (keysym);
- if (accelerator == 0) accelerator = key;
- if (accelerator == 0) return false;
- if ((xEvent.state & OS.Mod1Mask) != 0) accelerator |= SWT.ALT;
- if ((xEvent.state & OS.ShiftMask) != 0) accelerator |= SWT.SHIFT;
- if ((xEvent.state & OS.ControlMask) != 0) accelerator |= SWT.CONTROL;
- return menuBar.translateAccelerator (accelerator);
- }
- }
- return false;
-}
-boolean traverseItem (boolean next) {
- return false;
-}
-boolean traverseReturn () {
- if (defaultButton == null || defaultButton.isDisposed ()) return false;
- if (!defaultButton.isVisible () || !defaultButton.isEnabled ()) return false;
- defaultButton.click ();
- return true;
-}
-}
+public void setText (String string) {
+ checkWidget();
+ if (string == null) error (SWT.ERROR_NULL_ARGUMENT);
+ label = string;
+}
+boolean translateAccelerator (int key, int keysym, XKeyEvent xEvent) {
+ /*
+ * Bug in Solaris. When accelerators are set more
+ * than once in the same menu bar, the time it takes
+ * to set the accelerator increases exponentially.
+ * The fix is to implement our own accelerator table
+ * on Solaris.
+ */
+ if (OS.IsSunOS) {
+ if (menuBar != null && menuBar.getEnabled ()) {
+ /* Ignore modifiers. */
+ switch (keysym) {
+ case OS.XK_Control_L:
+ case OS.XK_Control_R:
+ case OS.XK_Alt_L:
+ case OS.XK_Alt_R:
+ case OS.XK_Shift_L:
+ case OS.XK_Shift_R:
+ return false;
+ }
+
+ /*
+ * 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 (keysym != 0) {
+ switch (keysym) {
+ case 0x1005FF10:
+ keysym = OS.XK_F11;
+ key = 0;
+ break;
+ case 0x1005FF11:
+ keysym = OS.XK_F12;
+ key = 0;
+ break;
+ }
+ /*
+ * Bug in MOTIF. On Solaris only, there 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 &= 0xFFFF;
+ }
+
+ /*
+ * Bug in Motif. There are some keycodes for which
+ * XLookupString() does not translate the character.
+ * Some of examples are Shift+Tab and Ctrl+Space.
+ */
+ switch (keysym) {
+ case OS.XK_ISO_Left_Tab: key = '\t'; break;
+ case OS.XK_space: key = ' '; break;
+ }
+
+ int accelerator = Display.translateKey (keysym);
+ if (accelerator == 0) accelerator = key;
+ if (accelerator == 0) return false;
+ if ((xEvent.state & OS.Mod1Mask) != 0) accelerator |= SWT.ALT;
+ if ((xEvent.state & OS.ShiftMask) != 0) accelerator |= SWT.SHIFT;
+ if ((xEvent.state & OS.ControlMask) != 0) accelerator |= SWT.CONTROL;
+ return menuBar.translateAccelerator (accelerator);
+ }
+ }
+ return false;
+}
+boolean traverseItem (boolean next) {
+ return false;
+}
+boolean traverseReturn () {
+ if (defaultButton == null || defaultButton.isDisposed ()) return false;
+ if (!defaultButton.isVisible () || !defaultButton.isEnabled ()) return false;
+ defaultButton.click ();
+ return true;
+}
+}
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
index 2ce65c05c3..d83c444350 100755
--- 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
@@ -1,53 +1,53 @@
-package org.eclipse.swt.widgets;
-
-/*
+package org.eclipse.swt.widgets;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-import org.eclipse.swt.internal.*;
-import org.eclipse.swt.internal.motif.*;
-import org.eclipse.swt.*;
-
-/**
- * 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>
+ * http://www.eclipse.org/legal/cpl-v10.html
*/
-public class DirectoryDialog extends Dialog {
- String filterPath = "";
- boolean cancel = true;
- String message = "";
-/**
- * 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>
+
+import org.eclipse.swt.internal.*;
+import org.eclipse.swt.internal.motif.*;
+import org.eclipse.swt.*;
+
+/**
+ * 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 filterPath = "";
+ boolean cancel = true;
+ String message = "";
+/**
+ * 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);
-}
+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.
@@ -78,241 +78,241 @@ public DirectoryDialog (Shell parent) {
* <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
* </ul>
*/
-public DirectoryDialog (Shell parent, int style) {
- super (parent, style);
- checkSubclass ();
-}
-int activate (int widget, int client, int call) {
- cancel = client == OS.XmDIALOG_CANCEL_BUTTON;
- OS.XtUnmanageChild (widget);
- return 0;
-}
-/**
- * Returns the path which the dialog will use to filter
- * the directories it shows.
- *
- * @return the filter path
+public DirectoryDialog (Shell parent, int style) {
+ super (parent, style);
+ checkSubclass ();
+}
+int activate (int widget, int client, int call) {
+ cancel = client == OS.XmDIALOG_CANCEL_BUTTON;
+ OS.XtUnmanageChild (widget);
+ return 0;
+}
+/**
+ * Returns the path which the dialog will use to filter
+ * the directories it shows.
+ *
+ * @return the filter path
*/
-public String getFilterPath () {
- return filterPath;
-}
-/**
- * Returns the dialog's message, which is a description of
- * the purpose for which it was opened. This message will be
- * visible on the dialog while it is open.
- *
- * @return the message
+public String getFilterPath () {
+ return filterPath;
+}
+/**
+ * Returns the dialog's message, which is a description of
+ * the purpose for which it was opened. This message will be
+ * visible on the dialog while it is open.
+ *
+ * @return the message
*/
-public String getMessage () {
- return message;
-}
-/**
- * Makes the dialog visible and brings it to the front
- * of the display.
- *
- * @return a string describing the absolute path of the selected directory,
- * or null if the dialog was cancelled or an error occurred
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the dialog has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the dialog</li>
- * </ul>
+public String getMessage () {
+ return message;
+}
+/**
+ * Makes the dialog visible and brings it to the front
+ * of the display.
+ *
+ * @return a string describing the absolute path of the selected directory,
+ * or null if the dialog was cancelled or an error occurred
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the dialog has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the dialog</li>
+ * </ul>
*/
-public String open () {
-
- /* 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)) {
- if (OS.IsAIX) parent.realizeWidget (); /* Fix for bug 17507 */
- 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 = " ";
-
- /* Use the character encoding for the default locale */
- 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 */
- /* Use the character encoding for the default locale */
- 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 = "";
- /* Use the character encoding for the default locale */
- byte [] buffer3 = Converter.wcsToMbcs (null, filterPath, true);
- int xmStringPtr3 = OS.XmStringParseText (
- buffer3,
- 0,
- OS.XmFONTLIST_DEFAULT_TAG,
- OS.XmCHARSET_TEXT,
- null,
- 0,
- 0);
-
- /* Use the character encoding for the default locale */
- 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.XmNpathMode, OS.XmPATH_MODE_FULL,
- 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.
- /* Use the character encoding for the default locale */
- byte [] buffer4 = Converter.wcsToMbcs (null, message, true);
- int xmString1 = OS.XmStringGenerate(buffer4, null, OS.XmCHARSET_TEXT, null);
- int [] argList = {
- OS.XmNlabelType, OS.XmSTRING,
- OS.XmNlabelString, xmString1
- };
- int textArea = OS.XmCreateLabel(dialog, name, argList, argList.length/2);
- OS.XtManageChild(textArea);
- OS.XmStringFree (xmString1);
-
- /* 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);
-
- // 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);
- /* Use the character encoding for the default locale */
- 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);
- }
- }
- }
- filterPath = directoryPath;
- }
-
- /* Destroy the dialog and update the display. */
- if (OS.XtIsRealized (dialog)) OS.XtDestroyWidget (dialog);
- if (destroyContext) appContext.dispose ();
- callback.dispose ();
-
- if (cancel) return null;
- return directoryPath;
-}
-/**
- * Sets the path which the dialog will use to filter
- * the directories it shows to the argument, which may be
- * null.
- *
- * @param string the filter path
+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)) {
+ if (OS.IsAIX) parent.realizeWidget (); /* Fix for bug 17507 */
+ 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 = " ";
+
+ /* Use the character encoding for the default locale */
+ 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 */
+ /* Use the character encoding for the default locale */
+ 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 = "";
+ /* Use the character encoding for the default locale */
+ byte [] buffer3 = Converter.wcsToMbcs (null, filterPath, true);
+ int xmStringPtr3 = OS.XmStringParseText (
+ buffer3,
+ 0,
+ OS.XmFONTLIST_DEFAULT_TAG,
+ OS.XmCHARSET_TEXT,
+ null,
+ 0,
+ 0);
+
+ /* Use the character encoding for the default locale */
+ 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.XmNpathMode, OS.XmPATH_MODE_FULL,
+ 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.
+ /* Use the character encoding for the default locale */
+ byte [] buffer4 = Converter.wcsToMbcs (null, message, true);
+ int xmString1 = OS.XmStringGenerate(buffer4, null, OS.XmCHARSET_TEXT, null);
+ int [] argList = {
+ OS.XmNlabelType, OS.XmSTRING,
+ OS.XmNlabelString, xmString1
+ };
+ int textArea = OS.XmCreateLabel(dialog, name, argList, argList.length/2);
+ OS.XtManageChild(textArea);
+ OS.XmStringFree (xmString1);
+
+ /* 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);
+
+ // 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);
+ /* Use the character encoding for the default locale */
+ 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);
+ }
+ }
+ }
+ filterPath = directoryPath;
+ }
+
+ /* Destroy the dialog and update the display. */
+ if (OS.XtIsRealized (dialog)) OS.XtDestroyWidget (dialog);
+ if (destroyContext) appContext.dispose ();
+ callback.dispose ();
+
+ if (cancel) return null;
+ return directoryPath;
+}
+/**
+ * Sets the path which the dialog 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 dialog's message, which is a description of
- * the purpose for which it was opened. This message will be
- * visible on the dialog while it is open.
- *
- * @param string the message
+public void setFilterPath (String string) {
+ filterPath = string;
+}
+/**
+ * Sets the dialog's message, which is a description of
+ * the purpose for which it was opened. This message will be
+ * visible on the dialog while it is open.
+ *
+ * @param string the message
*/
-public void setMessage (String string) {
- message = 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
index fba8edb639..389bbf0213 100755
--- 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
@@ -1,17 +1,17 @@
-package org.eclipse.swt.widgets;
-
-/*
+package org.eclipse.swt.widgets;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-import org.eclipse.swt.internal.*;
-import org.eclipse.swt.internal.motif.*;
-import org.eclipse.swt.*;
-import org.eclipse.swt.graphics.*;
-
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+import org.eclipse.swt.internal.*;
+import org.eclipse.swt.internal.motif.*;
+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
@@ -87,2266 +87,2266 @@ import org.eclipse.swt.graphics.*;
* @see #sleep
* @see #dispose
*/
-public class Display extends Device {
-
- /* Motif Only Public Fields */
- public XAnyEvent xEvent = new XAnyEvent ();
- int lastSerial;
-
- /* Windows, Events and Callbacks */
- Callback windowCallback;
- int windowProc, shellHandle;
- static boolean XtInitialized;
- static Object XInitLock = new Object ();
- static String APP_NAME = "SWT";
- byte [] displayName, appName, appClass;
- Event [] eventQueue;
- XKeyEvent keyEvent = new XKeyEvent ();
- EventTable eventTable, filterTable;
- boolean postFocusOut;
-
- /* Default Fonts, Colors, Insets, Widths and Heights. */
- Font defaultFont;
- Font listFont, textFont, buttonFont, labelFont;
- int dialogBackground, dialogForeground;
- int buttonBackground, buttonForeground, buttonShadowThickness;
- int compositeBackground, compositeForeground;
- int compositeTopShadow, compositeBottomShadow, compositeBorder;
- int listBackground, listForeground, listSelect, 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_FOREGROUND, 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 leftBorderWidth = 2, rightBorderWidth = 2;
- int topBorderHeight = 2, bottomBorderHeight = 2;
- int leftResizeWidth = 3, rightResizeWidth = 3;
- int topResizeHeight = 3, bottomResizeHeight = 3;
- int leftTitleBorderWidth = 3, rightTitleBorderWidth = 2;
- int topTitleBorderHeight = 26, bottomTitleBorderHeight = 2;
- int leftTitleResizeWidth = 3, rightTitleResizeWidth = 3;
- int topTitleResizeHeight = 26, bottomTitleResizeHeight = 3;
- int leftTitleWidth = 0, rightTitleWidth = 0;
- int topTitleHeight = 23, bottomTitleHeight = 0;
-
- /* Sync/Async Widget Communication */
- Synchronizer synchronizer = new Synchronizer (this);
- Thread thread;
-
- /* Display Shutdown */
- Runnable [] disposeList;
-
- /* Timers */
- int [] timerIds;
- Runnable [] timerList;
- Callback timerCallback;
- int timerProc;
-
- /* Widget Timers */
- Callback windowTimerCallback;
- int windowTimerProc;
-
- /* 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 Keys */
- {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},
-
- /* Virtual and Ascii Keys */
- {OS.XK_BackSpace, SWT.BS},
- {OS.XK_Return, SWT.CR},
- {OS.XK_KP_Enter, SWT.CR},
- {OS.XK_Delete, SWT.DEL},
- {OS.XK_Escape, SWT.ESC},
- {OS.XK_Cancel, SWT.ESC},
- {OS.XK_Linefeed, SWT.LF},
- {OS.XK_Tab, SWT.TAB},
- {OS.XK_ISO_Left_Tab,SWT.TAB},
-
- /* 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_PREFIX = "org.eclipse.swt.widgets.";
- /*
- * This code is intentionally commented. In order
- * to support CLDC, .class cannot be used because
- * it does not compile on some Java compilers when
- * they are targeted for CLDC.
- */
-// static {
-// String name = Display.class.getName ();
-// int index = name.lastIndexOf ('.');
-// PACKAGE_PREFIX = name.substring (0, index + 1);
-// }
-
- /* Mouse Hover */
- Callback mouseHoverCallback;
- int mouseHoverID, mouseHoverProc;
- int mouseHoverHandle, toolTipHandle;
-
- /* Xt Translations */
- int dragTranslations;
- int arrowTranslations, tabTranslations;
-
- /* Check Expose Proc */
- Callback checkExposeCallback;
- int checkExposeProc, exposeCount, lastExpose;
- XExposeEvent xExposeEvent = new XExposeEvent ();
-
- /* Check Resize Proc */
- Callback checkResizeCallback;
- int checkResizeProc, resizeWidth, resizeHeight, resizeCount, resizeWindow;
- XConfigureEvent xConfigureEvent = new XConfigureEvent ();
-
- /* Wake and Sleep */
- Callback wakeCallback;
- int wakeProc, read_fd, write_fd, inputID;
- byte [] wake_buffer = new byte [1];
- int [] timeout = new int [2];
- byte [] fd_set;
-
- /* Display Data */
- Object data;
- String [] keys;
- Object [] values;
-
- /*
- * TEMPORARY CODE. Install the runnable that
- * gets the current display. This code will
- * be removed in the future.
- */
- static {
- DeviceFinder = new Runnable () {
- public void run () {
- Device device = getCurrent ();
- if (device == null) {
- device = getDefault ();
- }
- setDevice (device);
- }
- };
- }
-
-/*
-* TEMPORARY CODE.
-*/
-static void setDevice (Device device) {
- CurrentDevice = device;
-}
-
-/**
- * Constructs a new instance of this class.
- * <p>
- * Note: The resulting display is marked as the <em>current</em>
- * display. If this is the first display which has been
- * constructed since the application started, it is also
- * marked as the <em>default</em> display.
- * </p>
- *
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS - if 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 class Display extends Device {
+
+ /* Motif Only Public Fields */
+ public XAnyEvent xEvent = new XAnyEvent ();
+ int lastSerial;
+
+ /* Windows, Events and Callbacks */
+ Callback windowCallback;
+ int windowProc, shellHandle;
+ static boolean XtInitialized;
+ static Object XInitLock = new Object ();
+ static String APP_NAME = "SWT";
+ byte [] displayName, appName, appClass;
+ Event [] eventQueue;
+ XKeyEvent keyEvent = new XKeyEvent ();
+ EventTable eventTable, filterTable;
+ boolean postFocusOut;
+
+ /* Default Fonts, Colors, Insets, Widths and Heights. */
+ Font defaultFont;
+ Font listFont, textFont, buttonFont, labelFont;
+ int dialogBackground, dialogForeground;
+ int buttonBackground, buttonForeground, buttonShadowThickness;
+ int compositeBackground, compositeForeground;
+ int compositeTopShadow, compositeBottomShadow, compositeBorder;
+ int listBackground, listForeground, listSelect, 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_FOREGROUND, 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 leftBorderWidth = 2, rightBorderWidth = 2;
+ int topBorderHeight = 2, bottomBorderHeight = 2;
+ int leftResizeWidth = 3, rightResizeWidth = 3;
+ int topResizeHeight = 3, bottomResizeHeight = 3;
+ int leftTitleBorderWidth = 3, rightTitleBorderWidth = 2;
+ int topTitleBorderHeight = 26, bottomTitleBorderHeight = 2;
+ int leftTitleResizeWidth = 3, rightTitleResizeWidth = 3;
+ int topTitleResizeHeight = 26, bottomTitleResizeHeight = 3;
+ int leftTitleWidth = 0, rightTitleWidth = 0;
+ int topTitleHeight = 23, bottomTitleHeight = 0;
+
+ /* Sync/Async Widget Communication */
+ Synchronizer synchronizer = new Synchronizer (this);
+ Thread thread;
+
+ /* Display Shutdown */
+ Runnable [] disposeList;
+
+ /* Timers */
+ int [] timerIds;
+ Runnable [] timerList;
+ Callback timerCallback;
+ int timerProc;
+
+ /* Widget Timers */
+ Callback windowTimerCallback;
+ int windowTimerProc;
+
+ /* 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 Keys */
+ {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},
+
+ /* Virtual and Ascii Keys */
+ {OS.XK_BackSpace, SWT.BS},
+ {OS.XK_Return, SWT.CR},
+ {OS.XK_KP_Enter, SWT.CR},
+ {OS.XK_Delete, SWT.DEL},
+ {OS.XK_Escape, SWT.ESC},
+ {OS.XK_Cancel, SWT.ESC},
+ {OS.XK_Linefeed, SWT.LF},
+ {OS.XK_Tab, SWT.TAB},
+ {OS.XK_ISO_Left_Tab,SWT.TAB},
+
+ /* 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_PREFIX = "org.eclipse.swt.widgets.";
+ /*
+ * This code is intentionally commented. In order
+ * to support CLDC, .class cannot be used because
+ * it does not compile on some Java compilers when
+ * they are targeted for CLDC.
+ */
+// static {
+// String name = Display.class.getName ();
+// int index = name.lastIndexOf ('.');
+// PACKAGE_PREFIX = name.substring (0, index + 1);
+// }
+
+ /* Mouse Hover */
+ Callback mouseHoverCallback;
+ int mouseHoverID, mouseHoverProc;
+ int mouseHoverHandle, toolTipHandle;
+
+ /* Xt Translations */
+ int dragTranslations;
+ int arrowTranslations, tabTranslations;
+
+ /* Check Expose Proc */
+ Callback checkExposeCallback;
+ int checkExposeProc, exposeCount, lastExpose;
+ XExposeEvent xExposeEvent = new XExposeEvent ();
+
+ /* Check Resize Proc */
+ Callback checkResizeCallback;
+ int checkResizeProc, resizeWidth, resizeHeight, resizeCount, resizeWindow;
+ XConfigureEvent xConfigureEvent = new XConfigureEvent ();
+
+ /* Wake and Sleep */
+ Callback wakeCallback;
+ int wakeProc, read_fd, write_fd, inputID;
+ byte [] wake_buffer = new byte [1];
+ int [] timeout = new int [2];
+ byte [] fd_set;
+
+ /* Display Data */
+ Object data;
+ String [] keys;
+ Object [] values;
+
+ /*
+ * TEMPORARY CODE. Install the runnable that
+ * gets the current display. This code will
+ * be removed in the future.
+ */
+ static {
+ DeviceFinder = new Runnable () {
+ public void run () {
+ Device device = getCurrent ();
+ if (device == null) {
+ device = getDefault ();
+ }
+ setDevice (device);
+ }
+ };
+ }
+
+/*
+* TEMPORARY CODE.
+*/
+static void setDevice (Device device) {
+ CurrentDevice = device;
+}
+
+/**
+ * Constructs a new instance of this class.
+ * <p>
+ * Note: The resulting display is marked as the <em>current</em>
+ * display. If this is the first display which has been
+ * constructed since the application started, it is also
+ * marked as the <em>default</em> display.
+ * </p>
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if 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 (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;
-}
-/**
- * Adds the listener to the collection of listeners who will
- * be notifed when an event of the given type occurs anywhere
- * in SWT. When the event does occur, the listener is notified
- * by sending it the <code>handleEvent()</code> message.
- *
- * @param eventType the type of event to listen for
- * @param listener the listener which should be notified when the event occurs
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see Listener
- * @see #removeFilter
- * @see #removeListener
- *
- * @since 2.1
- */
-void addFilter (int eventType, Listener listener) {
- checkDevice ();
- if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
- if (filterTable == null) filterTable = new EventTable ();
- filterTable.hook (eventType, listener);
-}
-/**
- * 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 display, the listener is notified by
- * sending it the <code>handleEvent()</code> message.
- *
- * @param eventType the type of event to listen for
- * @param listener the listener which should be notified when the event occurs
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see Listener
- * @see #removeListener
- *
- * @since 2.0
+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;
+}
+/**
+ * Adds the listener to the collection of listeners who will
+ * be notifed when an event of the given type occurs anywhere
+ * in SWT. When the event does occur, the listener is notified
+ * by sending it the <code>handleEvent()</code> message.
+ *
+ * @param eventType the type of event to listen for
+ * @param listener the listener which should be notified when the event occurs
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see Listener
+ * @see #removeFilter
+ * @see #removeListener
+ *
+ * @since 2.1
*/
-public void addListener (int eventType, Listener listener) {
- checkDevice ();
- if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
- if (eventTable == null) eventTable = new EventTable ();
- eventTable.hook (eventType, listener);
-}
-/**
- * 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
+void addFilter (int eventType, Listener listener) {
+ checkDevice ();
+ if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+ if (filterTable == null) filterTable = new EventTable ();
+ filterTable.hook (eventType, listener);
+}
+/**
+ * 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 display, the listener is notified by
+ * sending it the <code>handleEvent()</code> message.
+ *
+ * @param eventType the type of event to listen for
+ * @param listener the listener which should be notified when the event occurs
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see Listener
+ * @see #removeListener
+ *
+ * @since 2.0
*/
-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 addListener (int eventType, Listener listener) {
+ checkDevice ();
+ if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+ if (eventTable == null) eventTable = new EventTable ();
+ eventTable.hook (eventType, listener);
+}
+/**
+ * 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 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) {
- OS.memmove (xExposeEvent, event, XExposeEvent.sizeof);
- if (xExposeEvent.window != window) return 0;
- switch (xExposeEvent.type) {
- case OS.Expose:
- case OS.GraphicsExpose:
- exposeCount++;
- lastExpose = event;
- xExposeEvent.count = 1;
- OS.memmove (event, xExposeEvent, XExposeEvent.sizeof);
- break;
- }
- return 0;
-}
-int checkResizeProc (int display, int event, int arg) {
- OS.memmove (xConfigureEvent, event, XConfigureEvent.sizeof);
- if (xConfigureEvent.window != resizeWindow) return 0;
- switch (xConfigureEvent.type) {
- case OS.ConfigureNotify:
- int width = xConfigureEvent.width;
- int height = xConfigureEvent.height;
- if (width != resizeWidth || height != resizeHeight) {
- resizeCount++;
- }
- break;
- }
- return 0;
-}
-static synchronized void checkDisplay (Thread thread) {
- for (int i=0; i<Displays.length; i++) {
- if (Displays [i] != null && Displays [i].thread == thread) {
- SWT.error (SWT.ERROR_THREAD_INVALID_ACCESS);
- }
- }
-}
-protected void checkSubclass () {
- if (!Display.isValidClass (getClass ())) {
- error (SWT.ERROR_INVALID_SUBCLASS);
- }
-}
-/**
- * Requests that the connection between SWT and the underlying
- * operating system be closed.
- *
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see #dispose
- *
- * @since 2.0
+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 close () {
- checkDevice ();
- Event event = new Event ();
- sendEvent (SWT.Close, event);
- if (event.doit) dispose ();
-}
-String convertToLf(String text) {
- char Cr = '\r';
- char Lf = '\n';
- int length = text.length ();
- if (length == 0) return text;
-
- /* Check for an LF or CR/LF. Assume the rest of the string
- * is formated that way. This will not work if the string
- * contains mixed delimiters. */
- int i = text.indexOf (Lf, 0);
- if (i == -1 || i == 0) return text;
- if (text.charAt (i - 1) != Cr) return text;
-
- /* The string is formatted with CR/LF.
- * Create a new string with the LF line delimiter. */
- i = 0;
- StringBuffer result = new StringBuffer ();
- while (i < length) {
- int j = text.indexOf (Cr, i);
- if (j == -1) j = length;
- String s = text.substring (i, j);
- result.append (s);
- i = j + 2;
- result.append (Lf);
- }
- return result.toString ();
-}
-protected void create (DeviceData data) {
- checkSubclass ();
- checkDisplay (thread = Thread.currentThread ());
- createDisplay (data);
- register (this);
- if (Default == null) Default = this;
-}
-void createDisplay (DeviceData data) {
-
- /* Initialize X and Xt */
- synchronized (XInitLock) {
- if (!XtInitialized) {
- /*
- * This code is intentionally commented.
- */
-// OS.XInitThreads ();
-// OS.XtToolkitThreadInitialize ();
- OS.XtToolkitInitialize ();
- }
- XtInitialized = true;
- }
-
- /* Create the AppContext */
- int [] argc = new int [] {0};
- int xtContext = OS.XtCreateApplicationContext ();
- OS.XtSetLanguageProc (xtContext, 0, 0);
-
- /*
- * Feature in Linux. On some DBCS Linux platforms, the default
- * font is not be properly initialized to contain a font set.
- * This causes the IME to fail. The fix is to set a fallback
- * resource with an appropriated font to ensure a font set is
- * found. */
- int ptr1 = 0, ptr2 = 0;
- if (OS.IsLinux && OS.IsDBLocale) {
- String resource = "*fontList: -*-*-medium-r-*-*-*-120-*-*-*-*-*-*:";
- byte [] buffer = Converter.wcsToMbcs (null, resource, true);
- ptr1 = OS.XtMalloc (buffer.length);
- if (ptr1 != 0) OS.memmove (ptr1, buffer, buffer.length);
- int [] spec = new int[]{ptr1, 0};
- ptr2 = OS.XtMalloc (spec.length * 4);
- if (ptr2 != 0)OS.memmove (ptr2, spec, spec.length * 4);
- OS.XtAppSetFallbackResources(xtContext, ptr2);
- }
-
- /* 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;
- }
- /* Use the character encoding for the default locale */
- 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;
-
- if (ptr2 != 0) {
- OS.XtAppSetFallbackResources (xtContext, 0);
- OS.XtFree (ptr2);
- }
- if (ptr1 != 0) OS.XtFree (ptr1);
-}
-synchronized static void deregister (Display display) {
- for (int i=0; i<Displays.length; i++) {
- if (display == Displays [i]) Displays [i] = null;
- }
-}
-protected void destroy () {
- if (this == Default) Default = null;
- deregister (this);
- destroyDisplay ();
-}
-void destroyDisplay () {
- /*
- * Bug in Motif. For some reason, XtAppCreateShell GP's when called
- * after an application context has been destroyed. The fix is to
- * destroy the default XmDisplay associated with the X Display for
- * the application context. The following code fragment GP's without
- * this work around:
- *
- * int xContext = OS.XtCreateApplicationContext();
- * int xDisplay = OS.XtOpenDisplay(xContext, null, null, null, null, 0, new int[1], null);
- * OS.XtAppCreateShell(null, null, OS.topLevelShellWidgetClass(), xDisplay, null, 0);
- * OS.XtDestroyApplicationContext(xContext);
- * xContext = OS.XtCreateApplicationContext();
- * xDisplay = OS.XtOpenDisplay(xContext, null, null, null, null, 0, new int[1], null);
- * OS.XtAppCreateShell(null, null, OS.topLevelShellWidgetClass(), xDisplay, null, 0);
- * OS.XtDestroyApplicationContext(xContext);
- */
- OS.XtDestroyWidget (OS.XmGetXmDisplay (xDisplay));
-
- /*
- * Destroy AppContext (this destroys the display)
- */
- int xtContext = OS.XtDisplayToApplicationContext (xDisplay);
- OS.XtDestroyApplicationContext (xtContext);
- DisplayDisposed = true;
-}
-/**
- * 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 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) {
+ OS.memmove (xExposeEvent, event, XExposeEvent.sizeof);
+ if (xExposeEvent.window != window) return 0;
+ switch (xExposeEvent.type) {
+ case OS.Expose:
+ case OS.GraphicsExpose:
+ exposeCount++;
+ lastExpose = event;
+ xExposeEvent.count = 1;
+ OS.memmove (event, xExposeEvent, XExposeEvent.sizeof);
+ break;
+ }
+ return 0;
+}
+int checkResizeProc (int display, int event, int arg) {
+ OS.memmove (xConfigureEvent, event, XConfigureEvent.sizeof);
+ if (xConfigureEvent.window != resizeWindow) return 0;
+ switch (xConfigureEvent.type) {
+ case OS.ConfigureNotify:
+ int width = xConfigureEvent.width;
+ int height = xConfigureEvent.height;
+ if (width != resizeWidth || height != resizeHeight) {
+ resizeCount++;
+ }
+ break;
+ }
+ return 0;
+}
+static synchronized void checkDisplay (Thread thread) {
+ for (int i=0; i<Displays.length; i++) {
+ if (Displays [i] != null && Displays [i].thread == thread) {
+ SWT.error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ }
+ }
+}
+protected void checkSubclass () {
+ if (!Display.isValidClass (getClass ())) {
+ error (SWT.ERROR_INVALID_SUBCLASS);
+ }
+}
+/**
+ * Requests that the connection between SWT and the underlying
+ * operating system be closed.
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see #dispose
+ *
+ * @since 2.0
*/
-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 (Event event) {
- if (filterTable != null) filterTable.sendEvent (event);
- return false;
-}
-boolean filters (int eventType) {
- if (filterTable == null) return false;
- return filterTable.hooks (eventType);
-}
-boolean filterEvent (XAnyEvent event) {
-
- /* Check the event and find the widget */
- if (event.type != OS.KeyPress) return false;
- OS.memmove (keyEvent, event, XKeyEvent.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;
-
- /* 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;
-
- /*
- * Bug in AIX. If XFilterEvent() is called for every key event, accelerators
- * do not work. XFilterEvent() is needed on AIX to invoke the default button.
- * The fix is to call XFilterEvent() only for return keys. This means that an
- * accelerator that is only a return key will not work.
- */
- if (keysym == OS.XK_Return || keysym == OS.XK_KP_Enter) {
- /*
- * Bug in Linux. If XFilter() is called more than once for the same
- * event, it causes an infinite loop. The fix to remember the serial
- * number and never call XFilterEvent() twice for the same event.
- */
- if (event.serial != lastSerial) {
- if (OS.XFilterEvent (event, OS.XtWindow (handle))) return true;
- lastSerial = event.serial;
- }
- }
-
- /* Check for an accelerator key */
- if (widget.translateAccelerator (key, keysym, keyEvent)) return true;
-
- /* Check for a mnemonic key */
- if (key != 0) {
- if (widget.translateMnemonic (key, keyEvent)) return true;
- }
-
- /* Check for a traversal key */
- if (keysym == 0) return false;
- switch (keysym) {
- case OS.XK_Escape:
- case OS.XK_Cancel:
- case OS.XK_Tab:
- case OS.XK_KP_Enter:
- case OS.XK_Return:
- case OS.XK_Up:
- case OS.XK_Down:
- case OS.XK_Left:
- case OS.XK_Right:
- case OS.XK_Page_Up:
- case OS.XK_Page_Down:
- if (widget.translateTraversal (keysym, keyEvent)) return true;
- }
-
- /* Answer false because the event was not processed */
- 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 void close () {
+ checkDevice ();
+ Event event = new Event ();
+ sendEvent (SWT.Close, event);
+ if (event.doit) dispose ();
+}
+String convertToLf(String text) {
+ char Cr = '\r';
+ char Lf = '\n';
+ int length = text.length ();
+ if (length == 0) return text;
+
+ /* Check for an LF or CR/LF. Assume the rest of the string
+ * is formated that way. This will not work if the string
+ * contains mixed delimiters. */
+ int i = text.indexOf (Lf, 0);
+ if (i == -1 || i == 0) return text;
+ if (text.charAt (i - 1) != Cr) return text;
+
+ /* The string is formatted with CR/LF.
+ * Create a new string with the LF line delimiter. */
+ i = 0;
+ StringBuffer result = new StringBuffer ();
+ while (i < length) {
+ int j = text.indexOf (Cr, i);
+ if (j == -1) j = length;
+ String s = text.substring (i, j);
+ result.append (s);
+ i = j + 2;
+ result.append (Lf);
+ }
+ return result.toString ();
+}
+protected void create (DeviceData data) {
+ checkSubclass ();
+ checkDisplay (thread = Thread.currentThread ());
+ createDisplay (data);
+ register (this);
+ if (Default == null) Default = this;
+}
+void createDisplay (DeviceData data) {
+
+ /* Initialize X and Xt */
+ synchronized (XInitLock) {
+ if (!XtInitialized) {
+ /*
+ * This code is intentionally commented.
+ */
+// OS.XInitThreads ();
+// OS.XtToolkitThreadInitialize ();
+ OS.XtToolkitInitialize ();
+ }
+ XtInitialized = true;
+ }
+
+ /* Create the AppContext */
+ int [] argc = new int [] {0};
+ int xtContext = OS.XtCreateApplicationContext ();
+ OS.XtSetLanguageProc (xtContext, 0, 0);
+
+ /*
+ * Feature in Linux. On some DBCS Linux platforms, the default
+ * font is not be properly initialized to contain a font set.
+ * This causes the IME to fail. The fix is to set a fallback
+ * resource with an appropriated font to ensure a font set is
+ * found. */
+ int ptr1 = 0, ptr2 = 0;
+ if (OS.IsLinux && OS.IsDBLocale) {
+ String resource = "*fontList: -*-*-medium-r-*-*-*-120-*-*-*-*-*-*:";
+ byte [] buffer = Converter.wcsToMbcs (null, resource, true);
+ ptr1 = OS.XtMalloc (buffer.length);
+ if (ptr1 != 0) OS.memmove (ptr1, buffer, buffer.length);
+ int [] spec = new int[]{ptr1, 0};
+ ptr2 = OS.XtMalloc (spec.length * 4);
+ if (ptr2 != 0)OS.memmove (ptr2, spec, spec.length * 4);
+ OS.XtAppSetFallbackResources(xtContext, ptr2);
+ }
+
+ /* 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;
+ }
+ /* Use the character encoding for the default locale */
+ 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;
+
+ if (ptr2 != 0) {
+ OS.XtAppSetFallbackResources (xtContext, 0);
+ OS.XtFree (ptr2);
+ }
+ if (ptr1 != 0) OS.XtFree (ptr1);
+}
+synchronized static void deregister (Display display) {
+ for (int i=0; i<Displays.length; i++) {
+ if (display == Displays [i]) Displays [i] = null;
+ }
+}
+protected void destroy () {
+ if (this == Default) Default = null;
+ deregister (this);
+ destroyDisplay ();
+}
+void destroyDisplay () {
+ /*
+ * Bug in Motif. For some reason, XtAppCreateShell GP's when called
+ * after an application context has been destroyed. The fix is to
+ * destroy the default XmDisplay associated with the X Display for
+ * the application context. The following code fragment GP's without
+ * this work around:
+ *
+ * int xContext = OS.XtCreateApplicationContext();
+ * int xDisplay = OS.XtOpenDisplay(xContext, null, null, null, null, 0, new int[1], null);
+ * OS.XtAppCreateShell(null, null, OS.topLevelShellWidgetClass(), xDisplay, null, 0);
+ * OS.XtDestroyApplicationContext(xContext);
+ * xContext = OS.XtCreateApplicationContext();
+ * xDisplay = OS.XtOpenDisplay(xContext, null, null, null, null, 0, new int[1], null);
+ * OS.XtAppCreateShell(null, null, OS.topLevelShellWidgetClass(), xDisplay, null, 0);
+ * OS.XtDestroyApplicationContext(xContext);
+ */
+ OS.XtDestroyWidget (OS.XmGetXmDisplay (xDisplay));
+
+ /*
+ * Destroy AppContext (this destroys the display)
+ */
+ int xtContext = OS.XtDisplayToApplicationContext (xDisplay);
+ OS.XtDestroyApplicationContext (xtContext);
+ DisplayDisposed = true;
+}
+/**
+ * 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 Widget findWidget (int handle) {
- checkDevice ();
- return WidgetTable.get (handle);
-}
-/**
- * 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 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 (Event event) {
+ if (filterTable != null) filterTable.sendEvent (event);
+ return false;
+}
+boolean filters (int eventType) {
+ if (filterTable == null) return false;
+ return filterTable.hooks (eventType);
+}
+boolean filterEvent (XAnyEvent event) {
+
+ /* Check the event and find the widget */
+ if (event.type != OS.KeyPress) return false;
+ OS.memmove (keyEvent, event, XKeyEvent.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;
+
+ /* 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;
+
+ /*
+ * Bug in AIX. If XFilterEvent() is called for every key event, accelerators
+ * do not work. XFilterEvent() is needed on AIX to invoke the default button.
+ * The fix is to call XFilterEvent() only for return keys. This means that an
+ * accelerator that is only a return key will not work.
+ */
+ if (keysym == OS.XK_Return || keysym == OS.XK_KP_Enter) {
+ /*
+ * Bug in Linux. If XFilter() is called more than once for the same
+ * event, it causes an infinite loop. The fix to remember the serial
+ * number and never call XFilterEvent() twice for the same event.
+ */
+ if (event.serial != lastSerial) {
+ if (OS.XFilterEvent (event, OS.XtWindow (handle))) return true;
+ lastSerial = event.serial;
+ }
+ }
+
+ /* Check for an accelerator key */
+ if (widget.translateAccelerator (key, keysym, keyEvent)) return true;
+
+ /* Check for a mnemonic key */
+ if (key != 0) {
+ if (widget.translateMnemonic (key, keyEvent)) return true;
+ }
+
+ /* Check for a traversal key */
+ if (keysym == 0) return false;
+ switch (keysym) {
+ case OS.XK_Escape:
+ case OS.XK_Cancel:
+ case OS.XK_Tab:
+ case OS.XK_KP_Enter:
+ case OS.XK_Return:
+ case OS.XK_Up:
+ case OS.XK_Down:
+ case OS.XK_Left:
+ case OS.XK_Right:
+ case OS.XK_Page_Up:
+ case OS.XK_Page_Down:
+ if (widget.translateTraversal (keysym, keyEvent)) return true;
+ }
+
+ /* Answer false because the event was not processed */
+ 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 Shell getActiveShell () {
- 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;
- do {
- if (OS.XtIsSubclass (handle, OS.ShellWidgetClass ())) {
- Widget widget = WidgetTable.get (handle);
- if (widget instanceof Shell) return (Shell) widget;
- return null;
- }
- } while ((handle = OS.XtParent (handle)) != 0);
- return null;
-}
-/**
- * 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 Widget findWidget (int handle) {
+ checkDevice ();
+ return WidgetTable.get (handle);
+}
+/**
+ * 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 static synchronized Display getCurrent () {
- return findDisplay (Thread.currentThread ());
-}
-/**
- * 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 Shell getActiveShell () {
+ 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;
+ do {
+ if (OS.XtIsSubclass (handle, OS.ShellWidgetClass ())) {
+ Widget widget = WidgetTable.get (handle);
+ if (widget instanceof Shell) return (Shell) widget;
+ return null;
+ }
+ } while ((handle = OS.XtParent (handle)) != 0);
+ return null;
+}
+/**
+ * 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 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 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 static synchronized Display getCurrent () {
+ return findDisplay (Thread.currentThread ());
+}
+/**
+ * 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 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;
-}
-/**
- * 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 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 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 Point getCursorLocation () {
- checkDevice ();
- int window = OS.XDefaultRootWindow (xDisplay);
- int [] rootX = new int [1], rootY = new int [1], unused = new int [1];
- OS.XQueryPointer (xDisplay, window, unused, unused, rootX, rootY, unused, unused, unused);
- return new Point (rootX [0], rootY [0]);
-}
-/**
- * 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 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;
+}
+/**
+ * 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 static synchronized Display getDefault () {
- if (Default == null) Default = new Display ();
- return Default;
-}
-/**
- * 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 Point getCursorLocation () {
+ checkDevice ();
+ int window = OS.XDefaultRootWindow (xDisplay);
+ int [] rootX = new int [1], rootY = new int [1], unused = new int [1];
+ OS.XQueryPointer (xDisplay, window, unused, unused, rootX, rootY, unused, unused, unused);
+ return new Point (rootX [0], rootY [0]);
+}
+/**
+ * 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 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 static synchronized Display getDefault () {
+ if (Default == null) Default = new Display ();
+ return Default;
+}
+/**
+ * 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 () {
- checkDevice ();
- return data;
-}
-public int getDismissalAlignment () {
- checkDevice ();
- return SWT.LEFT;
-}
-/**
- * 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 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 int getDoubleClickTime () {
- checkDevice ();
- return OS.XtGetMultiClickTime (xDisplay);
-}
-/**
- * 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 Object getData () {
+ checkDevice ();
+ return data;
+}
+public int getDismissalAlignment () {
+ checkDevice ();
+ return SWT.LEFT;
+}
+/**
+ * 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 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;
-}
-/**
- * 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 getDoubleClickTime () {
+ checkDevice ();
+ return OS.XtGetMultiClickTime (xDisplay);
+}
+/**
+ * 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 int getIconDepth () {
- return getDepth ();
-}
-int getLastEventTime () {
- return OS.XtLastTimestampProcessed (xDisplay);
-}
-/**
- * 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 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;
+}
+/**
+ * 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 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 int getIconDepth () {
+ return getDepth ();
+}
+int getLastEventTime () {
+ return OS.XtLastTimestampProcessed (xDisplay);
+}
+/**
+ * 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 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 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 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: xColor = COLOR_WIDGET_FOREGROUND; break;
- 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);
-}
-/**
- * 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 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 ();
+ 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: xColor = COLOR_WIDGET_FOREGROUND; break;
+ 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);
+}
+/**
+ * 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 ();
- return defaultFont;
-}
-/**
- * Returns the user-interface thread for the receiver.
- *
- * @return the receiver's user-interface thread
+public Font getSystemFont () {
+ checkDevice ();
+ return defaultFont;
+}
+/**
+ * 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;
-}
-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 ();
- 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.
+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 ();
+ 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 = Font.motif_new (this, 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 () {
- defaultFont = labelFont;
- defaultForeground = compositeForeground;
- defaultBackground = compositeBackground;
-}
-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);
- windowTimerCallback = new Callback (this, "windowTimerProc", 2);
- windowTimerProc = windowTimerCallback.getAddress ();
- if (windowTimerProc == 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);
- checkResizeCallback = new Callback (this, "checkResizeProc", 3);
- checkResizeProc = checkResizeCallback.getAddress ();
- if (checkResizeProc == 0) error (SWT.ERROR_NO_MORE_CALLBACKS);
- wakeCallback = new Callback (this, "wakeProc", 3);
- wakeProc = wakeCallback.getAddress ();
- if (wakeProc == 0) error (SWT.ERROR_NO_MORE_CALLBACKS);
-
- /* Create and install the pipe used to wake up from sleep */
- int [] filedes = new int [2];
- if (OS.pipe (filedes) != 0) error (SWT.ERROR_NO_HANDLES);
- read_fd = filedes [0]; write_fd = filedes [1];
- int xtContext = OS.XtDisplayToApplicationContext (xDisplay);
- inputID = OS.XtAppAddInput (xtContext, read_fd, OS.XtInputReadMask, wakeProc, 0);
- fd_set = new byte [OS.fd_set_sizeof ()];
-
- /*
- * Use dynamic Drag and Drop Protocol styles.
- * Preregistered protocol is not supported.
- */
- int xmDisplay = OS.XmGetXmDisplay (xDisplay);
- int [] args = new int [] {
- OS.XmNenableThinThickness, 1,
- 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);
-
- /*
- * Bug in Motif. When running on UTF-8, Motif becomes unstable and
- * GP's some time later when a label widget is created with empty
- * text. The fix is to create the label with a non-empty string.
- */
- byte [] buffer = Converter.wcsToMbcs(null, "string", true);
- widgetHandle = OS.XmCreateLabel (shellHandle, buffer, null, 0);
- OS.XtManageChild (widgetHandle);
- OS.XtSetMappedWhenManaged (shellHandle, false);
- OS.XtRealizeWidget (shellHandle);
- int [] argList2 = {OS.XmNforeground, 0, OS.XmNbackground, 0, OS.XmNfontList, 0};
- OS.XtGetValues (widgetHandle, argList2, argList2.length / 2);
- labelForeground = argList2 [1]; labelBackground = argList2 [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.
+
+ buttonFont = Font.motif_new (this, 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 () {
+ defaultFont = labelFont;
+ defaultForeground = compositeForeground;
+ defaultBackground = compositeBackground;
+}
+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);
+ windowTimerCallback = new Callback (this, "windowTimerProc", 2);
+ windowTimerProc = windowTimerCallback.getAddress ();
+ if (windowTimerProc == 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);
+ checkResizeCallback = new Callback (this, "checkResizeProc", 3);
+ checkResizeProc = checkResizeCallback.getAddress ();
+ if (checkResizeProc == 0) error (SWT.ERROR_NO_MORE_CALLBACKS);
+ wakeCallback = new Callback (this, "wakeProc", 3);
+ wakeProc = wakeCallback.getAddress ();
+ if (wakeProc == 0) error (SWT.ERROR_NO_MORE_CALLBACKS);
+
+ /* Create and install the pipe used to wake up from sleep */
+ int [] filedes = new int [2];
+ if (OS.pipe (filedes) != 0) error (SWT.ERROR_NO_HANDLES);
+ read_fd = filedes [0]; write_fd = filedes [1];
+ int xtContext = OS.XtDisplayToApplicationContext (xDisplay);
+ inputID = OS.XtAppAddInput (xtContext, read_fd, OS.XtInputReadMask, wakeProc, 0);
+ fd_set = new byte [OS.fd_set_sizeof ()];
+
+ /*
+ * Use dynamic Drag and Drop Protocol styles.
+ * Preregistered protocol is not supported.
+ */
+ int xmDisplay = OS.XmGetXmDisplay (xDisplay);
+ int [] args = new int [] {
+ OS.XmNenableThinThickness, 1,
+ 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);
+
+ /*
+ * Bug in Motif. When running on UTF-8, Motif becomes unstable and
+ * GP's some time later when a label widget is created with empty
+ * text. The fix is to create the label with a non-empty string.
+ */
+ byte [] buffer = Converter.wcsToMbcs(null, "string", true);
+ widgetHandle = OS.XmCreateLabel (shellHandle, buffer, null, 0);
+ OS.XtManageChild (widgetHandle);
+ OS.XtSetMappedWhenManaged (shellHandle, false);
+ OS.XtRealizeWidget (shellHandle);
+ int [] argList2 = {OS.XmNforeground, 0, OS.XmNbackground, 0, OS.XmNfontList, 0};
+ OS.XtGetValues (widgetHandle, argList2, argList2.length / 2);
+ labelForeground = argList2 [1]; labelBackground = argList2 [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 = Font.motif_new (this, OS.XmFontListCopy (argList2 [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, new byte [0], null, 0);
- OS.XtManageChild (widgetHandle);
- OS.XtSetMappedWhenManaged (shellHandle, false);
- OS.XtRealizeWidget (shellHandle);
- int [] argList = {OS.XmNforeground, 0, OS.XmNbackground, 0, OS.XmNfontList, 0, OS.XmNselectColor, 0, OS.XmNhighlightColor, 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.
+
+ labelFont = Font.motif_new (this, OS.XmFontListCopy (argList2 [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, new byte [0], null, 0);
+ OS.XtManageChild (widgetHandle);
+ OS.XtSetMappedWhenManaged (shellHandle, false);
+ OS.XtRealizeWidget (shellHandle);
+ int [] argList = {OS.XmNforeground, 0, OS.XmNbackground, 0, OS.XmNfontList, 0, OS.XmNselectColor, 0, OS.XmNhighlightColor, 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 = Font.motif_new (this, OS.XmFontListCopy (argList [5]));
-
- /*
- * Feature in Motif. If the value of resource XmNselectColor is
- * XmDEFAULT_SELECT_COLOR then querying for this resource gives
- * the value of the selection color to use, which is between the
- * background and bottom shadow colors. If the resource value
- * that is returned is XmDEFAULT_SELECT_COLOR, and not the color,
- * since there is no API to query the color, use the list foreground
- * color.
- */
+
+ listFont = Font.motif_new (this, OS.XmFontListCopy (argList [5]));
+
+ /*
+ * Feature in Motif. If the value of resource XmNselectColor is
+ * XmDEFAULT_SELECT_COLOR then querying for this resource gives
+ * the value of the selection color to use, which is between the
+ * background and bottom shadow colors. If the resource value
+ * that is returned is XmDEFAULT_SELECT_COLOR, and not the color,
+ * since there is no API to query the color, use the list foreground
+ * color.
+ */
int selectColor = (byte) argList [7];
- switch (selectColor) {
- case OS.XmDEFAULT_SELECT_COLOR:
- case OS.XmREVERSED_GROUND_COLORS:
- listSelect = listForeground;
- break;
- case OS.XmHIGHLIGHT_COLOR:
- listSelect = argList [9];
- break;
- default:
- listSelect = argList [7]; // the middle color to use
- }
- OS.XtDestroyWidget (shellHandle);
-}
-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_FOREGROUND = new XColor();
- COLOR_WIDGET_FOREGROUND.pixel = textForeground;
- OS.XQueryColor (xDisplay, colormap, COLOR_WIDGET_FOREGROUND);
-
- 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 = listSelect;
- 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, new byte [0], 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.
+ switch (selectColor) {
+ case OS.XmDEFAULT_SELECT_COLOR:
+ case OS.XmREVERSED_GROUND_COLORS:
+ listSelect = listForeground;
+ break;
+ case OS.XmHIGHLIGHT_COLOR:
+ listSelect = argList [9];
+ break;
+ default:
+ listSelect = argList [7]; // the middle color to use
+ }
+ OS.XtDestroyWidget (shellHandle);
+}
+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_FOREGROUND = new XColor();
+ COLOR_WIDGET_FOREGROUND.pixel = textForeground;
+ OS.XQueryColor (xDisplay, colormap, COLOR_WIDGET_FOREGROUND);
+
+ 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 = listSelect;
+ 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, new byte [0], 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 = Font.motif_new (this, 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");
- dragTranslations = OS.XtParseTranslationTable (buffer3);
-}
-/**
- * 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
+
+ textFont = Font.motif_new (this, 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");
+ dragTranslations = OS.XtParseTranslationTable (buffer3);
+}
+/**
+ * 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) {
- if (isDisposed()) SWT.error(SWT.ERROR_DEVICE_DISPOSED);
- 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 = defaultFont.handle;
- data.codePage = defaultFont.codePage;
- data.colormap = OS.XDefaultColormap (xDisplay, OS.XDefaultScreen (xDisplay));
- }
- return xGC;
-}
-/**
- * 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 int internal_new_GC (GCData data) {
+ if (isDisposed()) SWT.error(SWT.ERROR_DEVICE_DISPOSED);
+ 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 = defaultFont.handle;
+ data.codePage = defaultFont.codePage;
+ data.colormap = OS.XDefaultColormap (xDisplay, OS.XDefaultScreen (xDisplay));
+ }
+ return xGC;
+}
+/**
+ * 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 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_PREFIX);
-}
-int mouseHoverProc (int handle, int id) {
- mouseHoverID = mouseHoverHandle = 0;
- Widget widget = WidgetTable.get (handle);
- if (widget == null) return 0;
- return widget.hoverProc (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;
-}
-/**
- * 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 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_PREFIX);
+}
+int mouseHoverProc (int handle, int id) {
+ mouseHoverID = mouseHoverHandle = 0;
+ Widget widget = WidgetTable.get (handle);
+ if (widget == null) return 0;
+ return widget.hoverProc (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;
+}
+/**
+ * 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 ();
- int xtContext = OS.XtDisplayToApplicationContext (xDisplay);
- int status = OS.XtAppPending (xtContext);
- if (status == 0) {
- OS.XtAppAddTimeOut (xtContext, 1, 0, 0);
- OS.XtAppProcessEvent (xtContext, OS.XtIMTimer);
- } else {
- if ((status & OS.XtIMTimer) != 0) {
- OS.XtAppProcessEvent (xtContext, OS.XtIMTimer);
- status = OS.XtAppPending (xtContext);
- }
- if ((status & OS.XtIMAlternateInput) != 0) {
- OS.XtAppProcessEvent (xtContext, OS.XtIMAlternateInput);
- status = OS.XtAppPending (xtContext);
- }
- if ((status & OS.XtIMXEvent) != 0) {
- OS.XtAppNextEvent (xtContext, xEvent);
- if (!filterEvent (xEvent)) OS.XtDispatchEvent (xEvent);
- }
- runDeferredEvents ();
- return true;
- }
- return runAsyncMessages ();
-}
-static synchronized void register (Display display) {
- for (int i=0; i<Displays.length; i++) {
- if (Displays [i] == null) {
- Displays [i] = display;
- return;
- }
- }
- Display [] newDisplays = new Display [Displays.length + 4];
- System.arraycopy (Displays, 0, newDisplays, 0, Displays.length);
- newDisplays [Displays.length] = display;
- Displays = newDisplays;
-}
-protected void release () {
- sendEvent (SWT.Dispose, new Event ());
- 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 ()) {};
- if (disposeList != null) {
- for (int i=0; i<disposeList.length; i++) {
- if (disposeList [i] != null) disposeList [i].run ();
- }
- }
- disposeList = null;
- synchronizer.releaseSynchronizer ();
- synchronizer = null;
- releaseDisplay ();
- super.release ();
-}
-void releaseDisplay () {
-
- /* Destroy the hidden Override shell parent */
- if (shellHandle != 0) OS.XtDestroyWidget (shellHandle);
- shellHandle = 0;
-
- /* 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++) {
- if (timerIds [i] != 0) OS.XtRemoveTimeOut (timerIds [i]);
- }
- }
- timerIds = null;
- timerList = null;
- timerProc = 0;
- timerCallback.dispose ();
- timerCallback = null;
-
- /* Dispose the window timer callback */
- windowTimerProc = 0;
- windowTimerCallback.dispose ();
- windowTimerCallback = null;
-
- /* Dispose the mouse hover callback */
- if (mouseHoverID != 0) OS.XtRemoveTimeOut (mouseHoverID);
- mouseHoverID = mouseHoverProc = mouseHoverHandle = toolTipHandle = 0;
- mouseHoverCallback.dispose ();
- mouseHoverCallback = null;
-
- /* Dispose window, expose and resize callbacks */
- windowCallback.dispose (); windowCallback = null;
- checkExposeCallback.dispose (); checkExposeCallback = null;
- checkExposeProc = 0;
- checkResizeCallback.dispose (); checkResizeCallback = null;
- checkResizeProc = 0;
-
- /* Dispose the wake callback, id and pipe */
- if (inputID != 0) OS.XtRemoveInput (inputID);
- wakeCallback.dispose (); wakeCallback = null;
- wakeProc = 0;
- OS.close (read_fd);
- OS.close (write_fd);
-
- /* Free the font lists */
- if (buttonFont != null) {
- OS.XmFontListFree (buttonFont.handle);
- buttonFont.handle = 0;
- }
- if (labelFont != null) {
- OS.XmFontListFree (labelFont.handle);
- labelFont.handle = 0;
- }
- if (textFont != null) {
- OS.XmFontListFree (textFont.handle);
- textFont.handle = 0;
- }
- if (listFont != null) {
- OS.XmFontListFree (listFont.handle);
- listFont.handle = 0;
- }
- listFont = textFont = labelFont = buttonFont = null;
- defaultFont = null;
-
- /* Free the translations (no documentation describes how to do this) */
- //OS.XtFree (arrowTranslations);
- //OS.XtFree (tabTranslations);
- //OS.XtFree (dragTranslations);
-
- /* 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_FOREGROUND = 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;
-}
-/**
- * Removes the listener from the collection of listeners who will
- * be notifed when an event of the given type occurs anywhere in SWT.
- *
- * @param eventType the type of event to listen for
- * @param listener the listener which should no longer be notified when the event occurs
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see Listener
- * @see #addFilter
- * @see #addListener
- *
- * @since 2.1
- */
-void removeFilter (int eventType, Listener listener) {
- checkDevice ();
- if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
- if (filterTable == null) return;
- filterTable.unhook (eventType, listener);
- if (filterTable.size () == 0) filterTable = null;
-}
-/**
- * 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_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see Listener
- * @see #addListener
- *
- * @since 2.0
+public boolean readAndDispatch () {
+ checkDevice ();
+ int xtContext = OS.XtDisplayToApplicationContext (xDisplay);
+ int status = OS.XtAppPending (xtContext);
+ if (status == 0) {
+ OS.XtAppAddTimeOut (xtContext, 1, 0, 0);
+ OS.XtAppProcessEvent (xtContext, OS.XtIMTimer);
+ } else {
+ if ((status & OS.XtIMTimer) != 0) {
+ OS.XtAppProcessEvent (xtContext, OS.XtIMTimer);
+ status = OS.XtAppPending (xtContext);
+ }
+ if ((status & OS.XtIMAlternateInput) != 0) {
+ OS.XtAppProcessEvent (xtContext, OS.XtIMAlternateInput);
+ status = OS.XtAppPending (xtContext);
+ }
+ if ((status & OS.XtIMXEvent) != 0) {
+ OS.XtAppNextEvent (xtContext, xEvent);
+ if (!filterEvent (xEvent)) OS.XtDispatchEvent (xEvent);
+ }
+ runDeferredEvents ();
+ return true;
+ }
+ return runAsyncMessages ();
+}
+static synchronized void register (Display display) {
+ for (int i=0; i<Displays.length; i++) {
+ if (Displays [i] == null) {
+ Displays [i] = display;
+ return;
+ }
+ }
+ Display [] newDisplays = new Display [Displays.length + 4];
+ System.arraycopy (Displays, 0, newDisplays, 0, Displays.length);
+ newDisplays [Displays.length] = display;
+ Displays = newDisplays;
+}
+protected void release () {
+ sendEvent (SWT.Dispose, new Event ());
+ 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 ()) {};
+ if (disposeList != null) {
+ for (int i=0; i<disposeList.length; i++) {
+ if (disposeList [i] != null) disposeList [i].run ();
+ }
+ }
+ disposeList = null;
+ synchronizer.releaseSynchronizer ();
+ synchronizer = null;
+ releaseDisplay ();
+ super.release ();
+}
+void releaseDisplay () {
+
+ /* Destroy the hidden Override shell parent */
+ if (shellHandle != 0) OS.XtDestroyWidget (shellHandle);
+ shellHandle = 0;
+
+ /* 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++) {
+ if (timerIds [i] != 0) OS.XtRemoveTimeOut (timerIds [i]);
+ }
+ }
+ timerIds = null;
+ timerList = null;
+ timerProc = 0;
+ timerCallback.dispose ();
+ timerCallback = null;
+
+ /* Dispose the window timer callback */
+ windowTimerProc = 0;
+ windowTimerCallback.dispose ();
+ windowTimerCallback = null;
+
+ /* Dispose the mouse hover callback */
+ if (mouseHoverID != 0) OS.XtRemoveTimeOut (mouseHoverID);
+ mouseHoverID = mouseHoverProc = mouseHoverHandle = toolTipHandle = 0;
+ mouseHoverCallback.dispose ();
+ mouseHoverCallback = null;
+
+ /* Dispose window, expose and resize callbacks */
+ windowCallback.dispose (); windowCallback = null;
+ checkExposeCallback.dispose (); checkExposeCallback = null;
+ checkExposeProc = 0;
+ checkResizeCallback.dispose (); checkResizeCallback = null;
+ checkResizeProc = 0;
+
+ /* Dispose the wake callback, id and pipe */
+ if (inputID != 0) OS.XtRemoveInput (inputID);
+ wakeCallback.dispose (); wakeCallback = null;
+ wakeProc = 0;
+ OS.close (read_fd);
+ OS.close (write_fd);
+
+ /* Free the font lists */
+ if (buttonFont != null) {
+ OS.XmFontListFree (buttonFont.handle);
+ buttonFont.handle = 0;
+ }
+ if (labelFont != null) {
+ OS.XmFontListFree (labelFont.handle);
+ labelFont.handle = 0;
+ }
+ if (textFont != null) {
+ OS.XmFontListFree (textFont.handle);
+ textFont.handle = 0;
+ }
+ if (listFont != null) {
+ OS.XmFontListFree (listFont.handle);
+ listFont.handle = 0;
+ }
+ listFont = textFont = labelFont = buttonFont = null;
+ defaultFont = null;
+
+ /* Free the translations (no documentation describes how to do this) */
+ //OS.XtFree (arrowTranslations);
+ //OS.XtFree (tabTranslations);
+ //OS.XtFree (dragTranslations);
+
+ /* 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_FOREGROUND = 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;
+}
+/**
+ * Removes the listener from the collection of listeners who will
+ * be notifed when an event of the given type occurs anywhere in SWT.
+ *
+ * @param eventType the type of event to listen for
+ * @param listener the listener which should no longer be notified when the event occurs
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see Listener
+ * @see #addFilter
+ * @see #addListener
+ *
+ * @since 2.1
*/
-public void removeListener (int eventType, Listener listener) {
- checkDevice ();
- if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
- if (eventTable == null) return;
- eventTable.unhook (eventType, listener);
-}
-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 but need not be synchronized.
- */
- while (eventQueue != null) {
-
- /* Take an event off the queue */
- Event event = eventQueue [0];
- if (event == null) break;
- int length = eventQueue.length;
- System.arraycopy (eventQueue, 1, eventQueue, 0, --length);
- eventQueue [length] = null;
-
- /* Run the event */
- Widget widget = event.widget;
- if (widget != null && !widget.isDisposed ()) {
- Widget item = event.item;
- if (item == null || !item.isDisposed ()) {
- widget.sendEvent (event);
- }
- }
-
- /*
- * At this point, the event queue could
- * be null due to a recursive invokation
- * when running the event.
- */
- }
-
- /* Clear the queue */
- eventQueue = null;
- return true;
-}
-boolean runFocusOutEvents () {
- if (eventQueue == null) return false;
- Event [] focusQueue = null;
- int index = 0, count = 0, length = eventQueue.length;
- while (index < length) {
- Event event = eventQueue [index];
- if (event != null && event.type == SWT.FocusOut) {
- if (focusQueue == null) focusQueue = new Event [length];
- focusQueue [count++] = event;
- System.arraycopy (eventQueue, index + 1, eventQueue, index, --length - index);
- eventQueue [length] = null;
- } else {
- index++;
- }
- }
- if (focusQueue == null) return false;
- for (int i=0; i<count; i++) {
- Event event = focusQueue [i];
- Widget widget = event.widget;
- if (widget != null && !widget.isDisposed ()) {
- Widget item = event.item;
- if (item == null || !item.isDisposed ()) {
- widget.sendEvent (event);
- }
- }
- }
- return true;
-}
-void sendEvent (int eventType, Event event) {
- if (eventTable == null && filterTable == null) {
- return;
- }
- if (event == null) event = new Event ();
- event.display = this;
- event.type = eventType;
- if (event.time == 0) event.time = getLastEventTime ();
- if (!filterEvent (event)) {
- if (eventTable != null) eventTable.sendEvent (event);
- }
-}
-public void setCursorLocation (int x, int y) {
- checkDevice ();
- int xWindow = OS.XDefaultRootWindow (xDisplay);
- OS.XWarpPointer (xDisplay, OS.None, xWindow, 0, 0, 0, 0, x, y);
-}
-/**
- * Sets the location of the on-screen pointer relative to the top left corner
- * of the screen. <b>Note: It is typically considered bad practice for a
- * program to move the on-screen pointer location.</b>
- *
- * @param point new position
- * @since 2.0
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * <li>ERROR_NULL_ARGUMENT - if the point is null
- * </ul>
+void removeFilter (int eventType, Listener listener) {
+ checkDevice ();
+ if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+ if (filterTable == null) return;
+ filterTable.unhook (eventType, listener);
+ if (filterTable.size () == 0) filterTable = null;
+}
+/**
+ * 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_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see Listener
+ * @see #addListener
+ *
+ * @since 2.0
*/
-public void setCursorLocation (Point point) {
- checkDevice ();
- if (point == null) error (SWT.ERROR_NULL_ARGUMENT);
- setCursorLocation (point.x, point.y);
-}
-/**
- * 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 void removeListener (int eventType, Listener listener) {
+ checkDevice ();
+ if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+ if (eventTable == null) return;
+ eventTable.unhook (eventType, listener);
+}
+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 but need not be synchronized.
+ */
+ while (eventQueue != null) {
+
+ /* Take an event off the queue */
+ Event event = eventQueue [0];
+ if (event == null) break;
+ int length = eventQueue.length;
+ System.arraycopy (eventQueue, 1, eventQueue, 0, --length);
+ eventQueue [length] = null;
+
+ /* Run the event */
+ Widget widget = event.widget;
+ if (widget != null && !widget.isDisposed ()) {
+ Widget item = event.item;
+ if (item == null || !item.isDisposed ()) {
+ widget.sendEvent (event);
+ }
+ }
+
+ /*
+ * At this point, the event queue could
+ * be null due to a recursive invokation
+ * when running the event.
+ */
+ }
+
+ /* Clear the queue */
+ eventQueue = null;
+ return true;
+}
+boolean runFocusOutEvents () {
+ if (eventQueue == null) return false;
+ Event [] focusQueue = null;
+ int index = 0, count = 0, length = eventQueue.length;
+ while (index < length) {
+ Event event = eventQueue [index];
+ if (event != null && event.type == SWT.FocusOut) {
+ if (focusQueue == null) focusQueue = new Event [length];
+ focusQueue [count++] = event;
+ System.arraycopy (eventQueue, index + 1, eventQueue, index, --length - index);
+ eventQueue [length] = null;
+ } else {
+ index++;
+ }
+ }
+ if (focusQueue == null) return false;
+ for (int i=0; i<count; i++) {
+ Event event = focusQueue [i];
+ Widget widget = event.widget;
+ if (widget != null && !widget.isDisposed ()) {
+ Widget item = event.item;
+ if (item == null || !item.isDisposed ()) {
+ widget.sendEvent (event);
+ }
+ }
+ }
+ return true;
+}
+void sendEvent (int eventType, Event event) {
+ if (eventTable == null && filterTable == null) {
+ return;
+ }
+ if (event == null) event = new Event ();
+ event.display = this;
+ event.type = eventType;
+ if (event.time == 0) event.time = getLastEventTime ();
+ if (!filterEvent (event)) {
+ if (eventTable != null) eventTable.sendEvent (event);
+ }
+}
+public void setCursorLocation (int x, int y) {
+ checkDevice ();
+ int xWindow = OS.XDefaultRootWindow (xDisplay);
+ OS.XWarpPointer (xDisplay, OS.None, xWindow, 0, 0, 0, 0, x, y);
+}
+/**
+ * Sets the location of the on-screen pointer relative to the top left corner
+ * of the screen. <b>Note: It is typically considered bad practice for a
+ * program to move the on-screen pointer location.</b>
+ *
+ * @param point new position
+ * @since 2.0
+ * @exception SWTException <ul>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * <li>ERROR_NULL_ARGUMENT - if the point is null
+ * </ul>
*/
-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);
- }
-}
-/**
- * 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 setCursorLocation (Point point) {
+ checkDevice ();
+ if (point == null) error (SWT.ERROR_NULL_ARGUMENT);
+ setCursorLocation (point.x, point.y);
+}
+/**
+ * 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 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 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);
+ }
+}
+/**
+ * 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;
-}
-/**
- * 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 setData (Object data) {
+ checkDevice ();
+ this.data = data;
+}
+/**
+ * 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;
-}
-void setToolTipText (int handle, String toolTipText) {
- if (toolTipHandle == 0) return;
- int shellHandle = OS.XtParent (toolTipHandle);
- int shellParent = OS.XtParent (shellHandle);
- if (handle != shellParent) return;
- showToolTip (handle, toolTipText);
-}
-void showToolTip (int handle, String toolTipText) {
- int shellHandle = 0;
- /* Use the character encoding for the default locale */
- byte [] buffer = Converter.wcsToMbcs (null, toolTipText, true);
- if (toolTipHandle != 0) {
- shellHandle = OS.XtParent (toolTipHandle);
- int shellParent = OS.XtParent (shellHandle);
- if (handle != shellParent) return;
- int xmString = OS.XmStringGenerate (buffer, null, OS.XmCHARSET_TEXT, null);
- int [] argList = {OS.XmNlabelString, xmString};
- OS.XtSetValues (toolTipHandle, argList, argList.length / 2);
- if (xmString != 0) OS.XmStringFree (xmString);
- } else {
- int widgetClass = OS.OverrideShellWidgetClass ();
- int [] argList1 = {
- OS.XmNmwmDecorations, 0,
- OS.XmNborderWidth, 1,
- OS.XmNallowShellResize, 1,
- };
- shellHandle = OS.XtCreatePopupShell (null, widgetClass, handle, argList1, argList1.length / 2);
- Color infoForeground = getSystemColor (SWT.COLOR_INFO_FOREGROUND);
- Color infoBackground = getSystemColor (SWT.COLOR_INFO_BACKGROUND);
- int foregroundPixel = infoForeground.handle.pixel;
- int backgroundPixel = infoBackground.handle.pixel;
- int [] argList2 = {
- OS.XmNforeground, foregroundPixel,
- OS.XmNbackground, backgroundPixel,
- OS.XmNalignment, OS.XmALIGNMENT_BEGINNING,
- };
- toolTipHandle = OS.XmCreateLabel (shellHandle, buffer, argList2, argList2.length / 2);
- OS.XtManageChild (toolTipHandle);
- }
- if (toolTipText == null || toolTipText.length () == 0) {
- OS.XtPopdown (shellHandle);
- } else {
- /*
- * 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 xWindow = OS.XDefaultRootWindow (xDisplay);
- int [] rootX = new int [1], rootY = new int [1], unused = new int [1], mask = new int [1];
- OS.XQueryPointer (xDisplay, xWindow, unused, unused, rootX, rootY, unused, unused, mask);
- int x = rootX [0] + 16, y = rootY [0] + 16;
-
- /*
- * Ensure that the tool tip is on the screen.
- */
- int screen = OS.XDefaultScreen (xDisplay);
- int width = OS.XDisplayWidth (xDisplay, screen);
- int height = OS.XDisplayHeight (xDisplay, screen);
- int [] argList4 = {OS.XmNwidth, 0, OS.XmNheight, 0};
- OS.XtGetValues (toolTipHandle, argList4, argList4.length / 2);
- x = Math.max (0, Math.min (x, width - argList4 [1]));
- y = Math.max (0, Math.min (y, height - argList4 [3]));
- OS.XtMoveWidget (shellHandle, x, y);
- int flags = OS.Button1Mask | OS.Button2Mask | OS.Button3Mask;
- if ((mask [0] & flags) == 0) OS.XtPopup (shellHandle, OS.XtGrabNone);
- }
-}
-/**
- * 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 void setSynchronizer (Synchronizer synchronizer) {
+ checkDevice ();
+ if (synchronizer == null) error (SWT.ERROR_NULL_ARGUMENT);
+ if (this.synchronizer != null) {
+ this.synchronizer.runAsyncMessages();
+ }
+ this.synchronizer = synchronizer;
+}
+void setToolTipText (int handle, String toolTipText) {
+ if (toolTipHandle == 0) return;
+ int shellHandle = OS.XtParent (toolTipHandle);
+ int shellParent = OS.XtParent (shellHandle);
+ if (handle != shellParent) return;
+ showToolTip (handle, toolTipText);
+}
+void showToolTip (int handle, String toolTipText) {
+ int shellHandle = 0;
+ /* Use the character encoding for the default locale */
+ byte [] buffer = Converter.wcsToMbcs (null, toolTipText, true);
+ if (toolTipHandle != 0) {
+ shellHandle = OS.XtParent (toolTipHandle);
+ int shellParent = OS.XtParent (shellHandle);
+ if (handle != shellParent) return;
+ int xmString = OS.XmStringGenerate (buffer, null, OS.XmCHARSET_TEXT, null);
+ int [] argList = {OS.XmNlabelString, xmString};
+ OS.XtSetValues (toolTipHandle, argList, argList.length / 2);
+ if (xmString != 0) OS.XmStringFree (xmString);
+ } else {
+ int widgetClass = OS.OverrideShellWidgetClass ();
+ int [] argList1 = {
+ OS.XmNmwmDecorations, 0,
+ OS.XmNborderWidth, 1,
+ OS.XmNallowShellResize, 1,
+ };
+ shellHandle = OS.XtCreatePopupShell (null, widgetClass, handle, argList1, argList1.length / 2);
+ Color infoForeground = getSystemColor (SWT.COLOR_INFO_FOREGROUND);
+ Color infoBackground = getSystemColor (SWT.COLOR_INFO_BACKGROUND);
+ int foregroundPixel = infoForeground.handle.pixel;
+ int backgroundPixel = infoBackground.handle.pixel;
+ int [] argList2 = {
+ OS.XmNforeground, foregroundPixel,
+ OS.XmNbackground, backgroundPixel,
+ OS.XmNalignment, OS.XmALIGNMENT_BEGINNING,
+ };
+ toolTipHandle = OS.XmCreateLabel (shellHandle, buffer, argList2, argList2.length / 2);
+ OS.XtManageChild (toolTipHandle);
+ }
+ if (toolTipText == null || toolTipText.length () == 0) {
+ OS.XtPopdown (shellHandle);
+ } else {
+ /*
+ * 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 xWindow = OS.XDefaultRootWindow (xDisplay);
+ int [] rootX = new int [1], rootY = new int [1], unused = new int [1], mask = new int [1];
+ OS.XQueryPointer (xDisplay, xWindow, unused, unused, rootX, rootY, unused, unused, mask);
+ int x = rootX [0] + 16, y = rootY [0] + 16;
+
+ /*
+ * Ensure that the tool tip is on the screen.
+ */
+ int screen = OS.XDefaultScreen (xDisplay);
+ int width = OS.XDisplayWidth (xDisplay, screen);
+ int height = OS.XDisplayHeight (xDisplay, screen);
+ int [] argList4 = {OS.XmNwidth, 0, OS.XmNheight, 0};
+ OS.XtGetValues (toolTipHandle, argList4, argList4.length / 2);
+ x = Math.max (0, Math.min (x, width - argList4 [1]));
+ y = Math.max (0, Math.min (y, height - argList4 [3]));
+ OS.XtMoveWidget (shellHandle, x, y);
+ int flags = OS.Button1Mask | OS.Button2Mask | OS.Button3Mask;
+ if ((mask [0] & flags) == 0) OS.XtPopup (shellHandle, OS.XtGrabNone);
+ }
+}
+/**
+ * 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 ();
- /*
- * This code is intentionally commented.
- */
-// int xtContext = OS.XtDisplayToApplicationContext (xDisplay);
-// /*
-// * Bug in Xt. Under certain circumstances Xt waits
-// * forever looking for X events, ignoring alternate
-// * inputs. The fix is to never sleep forever.
-// */
-// int sleepID = OS.XtAppAddTimeOut (xtContext, 100, 0, 0);
-// boolean result = OS.XtAppPeekEvent (xtContext, xEvent);
-// if (sleepID != 0) OS.XtRemoveTimeOut (sleepID);
-// return result;
-
- int display_fd = OS.ConnectionNumber (xDisplay);
- int max_fd = display_fd > read_fd ? display_fd : read_fd;
- OS.FD_ZERO (fd_set);
- OS.FD_SET (display_fd, fd_set);
- OS.FD_SET (read_fd, fd_set);
- timeout [0] = 0;
- timeout [1] = 100000;
- OS.select (max_fd + 1, fd_set, null, null, timeout);
- return OS.FD_ISSET (display_fd, fd_set);
-}
-/**
- * Causes the <code>run()</code> method of the runnable to
- * be invoked by the user-interface thread at the next
- * reasonable opportunity. The thread which calls this method
- * is suspended until the runnable completes.
- *
- * @param runnable code to run on the user-interface thread.
- *
- * @exception SWTException <ul>
- * <li>ERROR_FAILED_EXEC - if an exception occured when executing the runnable</li>
- * </ul>
- *
- * @see #asyncExec
+public boolean sleep () {
+ checkDevice ();
+ /*
+ * This code is intentionally commented.
+ */
+// int xtContext = OS.XtDisplayToApplicationContext (xDisplay);
+// /*
+// * Bug in Xt. Under certain circumstances Xt waits
+// * forever looking for X events, ignoring alternate
+// * inputs. The fix is to never sleep forever.
+// */
+// int sleepID = OS.XtAppAddTimeOut (xtContext, 100, 0, 0);
+// boolean result = OS.XtAppPeekEvent (xtContext, xEvent);
+// if (sleepID != 0) OS.XtRemoveTimeOut (sleepID);
+// return result;
+
+ int display_fd = OS.ConnectionNumber (xDisplay);
+ int max_fd = display_fd > read_fd ? display_fd : read_fd;
+ OS.FD_ZERO (fd_set);
+ OS.FD_SET (display_fd, fd_set);
+ OS.FD_SET (read_fd, fd_set);
+ timeout [0] = 0;
+ timeout [1] = 100000;
+ OS.select (max_fd + 1, fd_set, null, null, timeout);
+ return OS.FD_ISSET (display_fd, fd_set);
+}
+/**
+ * Causes the <code>run()</code> method of the runnable to
+ * be invoked by the user-interface thread at the next
+ * reasonable opportunity. The thread which calls this method
+ * is suspended until the runnable completes.
+ *
+ * @param runnable code to run on the user-interface thread.
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_FAILED_EXEC - if an exception occured when executing the runnable</li>
+ * </ul>
+ *
+ * @see #asyncExec
*/
-public void syncExec (Runnable runnable) {
- if (isDisposed ()) error (SWT.ERROR_DEVICE_DISPOSED);
- synchronizer.syncExec (runnable);
-}
-int textWidth (String string, Font font) {
- if (string.length () == 0) return 0;
- int fontList = font.handle;
- String codePage = font.codePage;
- byte [] textBuffer = Converter.wcsToMbcs (codePage, string, true);
- int xmString = OS.XmStringGenerate (textBuffer, null, OS.XmCHARSET_TEXT, null);
- int width = OS.XmStringWidth (fontList, xmString);
- OS.XmStringFree (xmString);
- return width;
-}
-/**
- * Causes the <code>run()</code> method of the runnable to
- * be invoked by the user-interface thread after the specified
- * number of milliseconds have elapsed. If milliseconds is less
- * than zero, the runnable is not executed.
- *
- * @param milliseconds the delay before running the runnable
- * @param runnable code to run on the user-interface thread
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the runnable is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see #asyncExec
+public void syncExec (Runnable runnable) {
+ if (isDisposed ()) error (SWT.ERROR_DEVICE_DISPOSED);
+ synchronizer.syncExec (runnable);
+}
+int textWidth (String string, Font font) {
+ if (string.length () == 0) return 0;
+ int fontList = font.handle;
+ String codePage = font.codePage;
+ byte [] textBuffer = Converter.wcsToMbcs (codePage, string, true);
+ int xmString = OS.XmStringGenerate (textBuffer, null, OS.XmCHARSET_TEXT, null);
+ int width = OS.XmStringWidth (fontList, xmString);
+ OS.XmStringFree (xmString);
+ return width;
+}
+/**
+ * Causes the <code>run()</code> method of the runnable to
+ * be invoked by the user-interface thread after the specified
+ * number of milliseconds have elapsed. If milliseconds is less
+ * than zero, the runnable is not executed.
+ *
+ * @param milliseconds the delay before running the runnable
+ * @param runnable code to run on the user-interface thread
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if the runnable is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see #asyncExec
*/
-public void timerExec (int milliseconds, Runnable runnable) {
- checkDevice ();
- if (runnable == null) error (SWT.ERROR_NULL_ARGUMENT);
- if (timerList == null) timerList = new Runnable [4];
- if (timerIds == null) timerIds = new int [4];
- int index = 0;
- while (index < timerList.length) {
- if (timerList [index] == runnable) break;
- index++;
- }
- if (index != timerList.length) {
- OS.XtRemoveTimeOut (timerIds [index]);
- timerList [index] = null;
- timerIds [index] = 0;
- if (milliseconds < 0) return;
- } else {
- if (milliseconds < 0) return;
- index = 0;
- while (index < timerList.length) {
- if (timerList [index] == null) break;
- index++;
- }
- if (index == timerList.length) {
- Runnable [] newTimerList = new Runnable [timerList.length + 4];
- System.arraycopy (timerList, 0, newTimerList, 0, timerList.length);
- timerList = newTimerList;
- int [] newTimerIds = new int [timerIds.length + 4];
- System.arraycopy (timerIds, 0, newTimerIds, 0, timerIds.length);
- timerIds = newTimerIds;
- }
- }
- int 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 timerExec (int milliseconds, Runnable runnable) {
+ checkDevice ();
+ if (runnable == null) error (SWT.ERROR_NULL_ARGUMENT);
+ if (timerList == null) timerList = new Runnable [4];
+ if (timerIds == null) timerIds = new int [4];
+ int index = 0;
+ while (index < timerList.length) {
+ if (timerList [index] == runnable) break;
+ index++;
+ }
+ if (index != timerList.length) {
+ OS.XtRemoveTimeOut (timerIds [index]);
+ timerList [index] = null;
+ timerIds [index] = 0;
+ if (milliseconds < 0) return;
+ } else {
+ if (milliseconds < 0) return;
+ index = 0;
+ while (index < timerList.length) {
+ if (timerList [index] == null) break;
+ index++;
+ }
+ if (index == timerList.length) {
+ Runnable [] newTimerList = new Runnable [timerList.length + 4];
+ System.arraycopy (timerList, 0, newTimerList, 0, timerList.length);
+ timerList = newTimerList;
+ int [] newTimerIds = new int [timerIds.length + 4];
+ System.arraycopy (timerIds, 0, newTimerIds, 0, timerIds.length);
+ timerIds = newTimerIds;
+ }
+ }
+ int 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;
+}
/**
* Forces all outstanding paint requests for the display
* to be processed before this method returns.
*
* @see Control#update
*/
-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);
-}
-/**
- * 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 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);
+}
+/**
+ * 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);
- if (thread == Thread.currentThread ()) return;
- /* Write a single byte to the wake up pipe */
- while (OS.write (write_fd, wake_buffer, 1) != 1);
-}
-int wakeProc (int closure, int source, int id) {
- /* Read a single byte from the wake up pipe */
- while (OS.read (read_fd, wake_buffer, 1) != 1);
- return 0;
-}
-int windowTimerProc (int handle, int id) {
- Widget widget = WidgetTable.get (handle);
- if (widget == null) return 0;
- return widget.timerProc (id);
-}
-int windowProc (int w, int client_data, int call_data, int continue_to_dispatch) {
- Widget widget = WidgetTable.get (w);
- if (widget == null) return 0;
- return widget.windowProc (w, client_data, call_data, continue_to_dispatch);
-}
-String wrapText (String text, Font font, int width) {
- String Lf = "\n";
- text = convertToLf (text);
- int length = text.length ();
- if (width <= 0 || length == 0 || length == 1) return text;
- StringBuffer result = new StringBuffer ();
- int lineStart = 0, lineEnd = 0;
- while (lineStart < length) {
- lineEnd = text.indexOf (Lf, lineStart);
- boolean noLf = lineEnd == -1;
- if (noLf) lineEnd = length;
- int nextStart = lineEnd + Lf.length ();
- while (lineEnd > lineStart + 1 && Compatibility.isWhitespace (text.charAt (lineEnd - 1))) {
- lineEnd--;
- }
- int wordStart = lineStart, wordEnd = lineStart;
- int i = lineStart;
- while (i < lineEnd) {
- int lastStart = wordStart, lastEnd = wordEnd;
- wordStart = i;
- while (i < lineEnd && !Compatibility.isWhitespace (text.charAt (i))) {
- i++;
- }
- wordEnd = i - 1;
- String line = text.substring (lineStart, wordEnd + 1);
- int lineWidth = textWidth (line, font);
- while (i < lineEnd && Compatibility.isWhitespace (text.charAt (i))) {
- i++;
- }
- if (lineWidth > width) {
- if (lastStart == wordStart) {
- while (wordStart < wordEnd) {
- line = text.substring (lineStart, wordStart + 1);
- lineWidth = textWidth (line, font);
- if (lineWidth >= width) break;
- wordStart++;
- }
- if (wordStart == lastStart) wordStart++;
- lastEnd = wordStart - 1;
- }
- line = text.substring (lineStart, lastEnd + 1);
- result.append (line); result.append (Lf);
- i = wordStart; lineStart = wordStart; wordEnd = wordStart;
- }
- }
- if (lineStart < lineEnd) {
- result.append (text.substring (lineStart, lineEnd));
- }
- if (!noLf) {
- result.append (Lf);
- }
- lineStart = nextStart;
- }
- return result.toString ();
-}
-}
+public void wake () {
+ if (isDisposed ()) error (SWT.ERROR_DEVICE_DISPOSED);
+ if (thread == Thread.currentThread ()) return;
+ /* Write a single byte to the wake up pipe */
+ while (OS.write (write_fd, wake_buffer, 1) != 1);
+}
+int wakeProc (int closure, int source, int id) {
+ /* Read a single byte from the wake up pipe */
+ while (OS.read (read_fd, wake_buffer, 1) != 1);
+ return 0;
+}
+int windowTimerProc (int handle, int id) {
+ Widget widget = WidgetTable.get (handle);
+ if (widget == null) return 0;
+ return widget.timerProc (id);
+}
+int windowProc (int w, int client_data, int call_data, int continue_to_dispatch) {
+ Widget widget = WidgetTable.get (w);
+ if (widget == null) return 0;
+ return widget.windowProc (w, client_data, call_data, continue_to_dispatch);
+}
+String wrapText (String text, Font font, int width) {
+ String Lf = "\n";
+ text = convertToLf (text);
+ int length = text.length ();
+ if (width <= 0 || length == 0 || length == 1) return text;
+ StringBuffer result = new StringBuffer ();
+ int lineStart = 0, lineEnd = 0;
+ while (lineStart < length) {
+ lineEnd = text.indexOf (Lf, lineStart);
+ boolean noLf = lineEnd == -1;
+ if (noLf) lineEnd = length;
+ int nextStart = lineEnd + Lf.length ();
+ while (lineEnd > lineStart + 1 && Compatibility.isWhitespace (text.charAt (lineEnd - 1))) {
+ lineEnd--;
+ }
+ int wordStart = lineStart, wordEnd = lineStart;
+ int i = lineStart;
+ while (i < lineEnd) {
+ int lastStart = wordStart, lastEnd = wordEnd;
+ wordStart = i;
+ while (i < lineEnd && !Compatibility.isWhitespace (text.charAt (i))) {
+ i++;
+ }
+ wordEnd = i - 1;
+ String line = text.substring (lineStart, wordEnd + 1);
+ int lineWidth = textWidth (line, font);
+ while (i < lineEnd && Compatibility.isWhitespace (text.charAt (i))) {
+ i++;
+ }
+ if (lineWidth > width) {
+ if (lastStart == wordStart) {
+ while (wordStart < wordEnd) {
+ line = text.substring (lineStart, wordStart + 1);
+ lineWidth = textWidth (line, font);
+ if (lineWidth >= width) break;
+ wordStart++;
+ }
+ if (wordStart == lastStart) wordStart++;
+ lastEnd = wordStart - 1;
+ }
+ line = text.substring (lineStart, lastEnd + 1);
+ result.append (line); result.append (Lf);
+ i = wordStart; lineStart = wordStart; wordEnd = wordStart;
+ }
+ }
+ if (lineStart < lineEnd) {
+ result.append (text.substring (lineStart, lineEnd));
+ }
+ if (!noLf) {
+ result.append (Lf);
+ }
+ lineStart = nextStart;
+ }
+ return result.toString ();
+}
+}
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
index 753c673000..c41a948d6e 100755
--- 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
@@ -1,68 +1,68 @@
-package org.eclipse.swt.widgets;
-
-/*
+package org.eclipse.swt.widgets;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-import java.io.*;
-import org.eclipse.swt.internal.*;
-import org.eclipse.swt.internal.motif.*;
-import org.eclipse.swt.*;
-
-/**
- * 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>
+ * http://www.eclipse.org/legal/cpl-v10.html
*/
-public class FileDialog extends Dialog {
- int dialog;
- String [] filterNames = new String [0];
- String [] filterExtensions = new String [0];
- String [] fileNames;
- String fileName = "";
- String filterPath = "";
- String fullPath;
- boolean cancel = false;
- static final String FILTER = "*";
-
-/**
- * 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>
+
+import java.io.*;
+import org.eclipse.swt.internal.*;
+import org.eclipse.swt.internal.motif.*;
+import org.eclipse.swt.*;
+
+/**
+ * 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 {
+ int dialog;
+ String [] filterNames = new String [0];
+ String [] filterExtensions = new String [0];
+ String [] fileNames;
+ String fileName = "";
+ String filterPath = "";
+ String fullPath;
+ boolean cancel = false;
+ static final String FILTER = "*";
+
+/**
+ * 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 FileDialog (Shell parent) {
- this (parent, SWT.PRIMARY_MODAL);
-}
-
+public FileDialog (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.
@@ -93,57 +93,57 @@ public FileDialog (Shell parent) {
* <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
* </ul>
*/
-public FileDialog (Shell parent, int style) {
- super (parent, style);
- checkSubclass ();
-}
-
-int cancelPressed (int widget, int client, int call) {
- cancel = true;
- OS.XtUnmanageChild (widget);
- return 0;
-}
+public FileDialog (Shell parent, int style) {
+ super (parent, style);
+ checkSubclass ();
+}
+
+int cancelPressed (int widget, int client, int call) {
+ cancel = true;
+ OS.XtUnmanageChild (widget);
+ return 0;
+}
/**
* Returns the path of the first file that was
* selected in the dialog relative to the filter path
*
* @return the relative path of the file
*/
-public String getFileName () {
- return fileName;
-}
-
-/**
- * Returns the paths of all files that were selected
- * in the dialog relative to the filter path, or null
- * if none are available.
- *
- * @return the relative paths of the files
+public String getFileName () {
+ return fileName;
+}
+
+/**
+ * Returns the paths of all files that were selected
+ * in the dialog relative to the filter path, or null
+ * if none are available.
+ *
+ * @return the relative paths of the files
*/
-public String [] getFileNames () {
- return fileNames;
-}
-
-/**
- * Returns the file extensions which the dialog will
- * use to filter the files it shows.
- *
- * @return the file extensions filter
+public String [] getFileNames () {
+ return fileNames;
+}
+
+/**
+ * Returns the file extensions which the dialog will
+ * use to filter the files it shows.
+ *
+ * @return the file extensions filter
*/
-public String [] getFilterExtensions () {
- return filterExtensions;
-}
-
-/**
- * Returns the file names which the dialog will
- * use to filter the files it shows.
- *
- * @return the file name filter
+public String [] getFilterExtensions () {
+ return filterExtensions;
+}
+
+/**
+ * Returns the file names which the dialog will
+ * use to filter the files it shows.
+ *
+ * @return the file name filter
*/
-public String [] getFilterNames () {
- return filterNames;
-}
-
+public String [] getFilterNames () {
+ return filterNames;
+}
+
/**
* Returns the directory path that the dialog will use.
* File names in this path will appear in the dialog,
@@ -153,347 +153,347 @@ public String [] getFilterNames () {
*
* @see #setFilterExtensions
*/
-public String getFilterPath () {
- return filterPath;
-}
-
-int itemSelected (int widget, int client, int call) {
- /* this callback will only be hooked if the dialog style is MULTI */
- int fileList = OS.XmFileSelectionBoxGetChild (dialog, OS.XmDIALOG_LIST);
- if (fileList == 0) return 0;
- int selectionText = OS.XmFileSelectionBoxGetChild (dialog, OS.XmDIALOG_TEXT);
- if (selectionText == 0) return 0;
-
- int [] argList = {OS.XmNselectedItems, 0, OS.XmNselectedItemCount, 0};
- OS.XtGetValues (fileList, argList, argList.length / 2);
- int items = argList [1], itemCount = argList [3];
- int ptr = 0;
- if (itemCount == 0) {
- int [] argList2 = {OS.XmNdirectory, 0};
- OS.XtGetValues (dialog, argList2, argList2.length / 2);
- ptr = argList2 [1];
- } else {
- int [] buffer = new int [1];
- OS.memmove (buffer, items, 4);
- ptr = buffer [0];
- }
- if (ptr == 0) return 0;
- int address = OS.XmStringUnparse (
- ptr,
- null,
- OS.XmCHARSET_TEXT,
- OS.XmCHARSET_TEXT,
- null,
- 0,
- OS.XmOUTPUT_ALL);
- if (itemCount == 0) OS.XmStringFree (ptr);
- if (address == 0) return 0;
- int length = OS.strlen (address);
- byte [] buffer = new byte [length + 1];
- OS.memmove (buffer, address, length);
- OS.XtFree (address);
-
- OS.XmTextSetString (selectionText, buffer);
- OS.XmTextSetInsertionPosition (selectionText, OS.XmTextGetLastPosition (selectionText));
- return 0;
-}
-
-int okPressed (int widget, int client, int call) {
- String fullPath = null, fileName = null;
- String [] fileNames = null;
-
- int [] argList = {OS.XmNdirSpec, 0, OS.XmNdirectory, 0};
- OS.XtGetValues (dialog, argList, argList.length / 2);
-
- int xmString1 = argList [1];
- int ptr = OS.XmStringUnparse (
- xmString1,
- 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);
- /* Use the character encoding for the default locale */
- fullPath = new String (Converter.mbcsToWcs (null, buffer)).trim();
- }
- OS.XmStringFree (xmString1);
-
- if ((style & SWT.MULTI) != 0) {
- int fileList = OS.XmFileSelectionBoxGetChild (dialog, OS.XmDIALOG_LIST);
- if (fileList == 0) return 0;
- int [] argList2 = {OS.XmNselectedItems, 0, OS.XmNselectedItemCount, 0};
- OS.XtGetValues (fileList, argList2, argList2.length / 2);
- int items = argList2 [1], itemCount = argList2 [3];
- int [] buffer1 = new int [1];
- fileNames = new String [itemCount];
- boolean match = false;
- for (int i = 0; i < itemCount; i++) {
- OS.memmove (buffer1, items, 4);
- ptr = buffer1 [0];
- int address = OS.XmStringUnparse (
- ptr,
- 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);
- /* Use the character encoding for the default locale */
- String fullFilename = new String (Converter.mbcsToWcs (null, buffer));
- int index = fullFilename.lastIndexOf ('/');
- fileNames [i] = fullFilename.substring (index + 1, fullFilename.length ());
- if (fullFilename.equals (fullPath)) match = true;
- }
- items += 4;
- }
- if (match) {
- fileName = fileNames [0];
- } else {
- /* The user has modified the text field such that it doesn't match any
- * of the selected files, so use this value instead
- */
- int index = fullPath.lastIndexOf ('/');
- fileName = fullPath.substring (index + 1, fullPath.length ());
- fileNames = new String [] {fileName};
- }
- } else {
- int index = fullPath.lastIndexOf ('/');
- fileName = fullPath.substring (index + 1, fullPath.length ());
- fileNames = new String [] {fileName};
- }
-
- // if no file selected then go into the current directory
- if (fileName.equals("")) {
- int [] argList1 = {OS.XmNdirMask, 0};
- OS.XtGetValues (dialog, argList1, argList1.length / 2);
- int directoryHandle = argList1[1];
- int [] argList2 = {OS.XmNpattern,directoryHandle};
- OS.XtSetValues (dialog, argList2, argList2.length / 2);
- OS.XmStringFree (directoryHandle);
- return 0;
- }
-
- int xmString2 = argList [3];
- ptr = OS.XmStringUnparse (
- xmString2,
- 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);
- /* Use the character encoding for the default locale */
- filterPath = new String (Converter.mbcsToWcs (null, buffer));
- }
- OS.XmStringFree (xmString2);
- if (filterPath.endsWith("/")) {
- filterPath = filterPath.substring (0, filterPath.length() - 1);
- }
-
- this.fullPath = fullPath;
- this.fileName = fileName;
- this.fileNames = fileNames;
- OS.XtUnmanageChild (widget);
- return 0;
-}
-
-/**
- * Makes the dialog visible and brings it to the front
- * of the display.
- *
- * @return a string describing the absolute path of the first selected file,
- * or null if the dialog was cancelled or an error occurred
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the dialog has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the dialog</li>
- * </ul>
+public String getFilterPath () {
+ return filterPath;
+}
+
+int itemSelected (int widget, int client, int call) {
+ /* this callback will only be hooked if the dialog style is MULTI */
+ int fileList = OS.XmFileSelectionBoxGetChild (dialog, OS.XmDIALOG_LIST);
+ if (fileList == 0) return 0;
+ int selectionText = OS.XmFileSelectionBoxGetChild (dialog, OS.XmDIALOG_TEXT);
+ if (selectionText == 0) return 0;
+
+ int [] argList = {OS.XmNselectedItems, 0, OS.XmNselectedItemCount, 0};
+ OS.XtGetValues (fileList, argList, argList.length / 2);
+ int items = argList [1], itemCount = argList [3];
+ int ptr = 0;
+ if (itemCount == 0) {
+ int [] argList2 = {OS.XmNdirectory, 0};
+ OS.XtGetValues (dialog, argList2, argList2.length / 2);
+ ptr = argList2 [1];
+ } else {
+ int [] buffer = new int [1];
+ OS.memmove (buffer, items, 4);
+ ptr = buffer [0];
+ }
+ if (ptr == 0) return 0;
+ int address = OS.XmStringUnparse (
+ ptr,
+ null,
+ OS.XmCHARSET_TEXT,
+ OS.XmCHARSET_TEXT,
+ null,
+ 0,
+ OS.XmOUTPUT_ALL);
+ if (itemCount == 0) OS.XmStringFree (ptr);
+ if (address == 0) return 0;
+ int length = OS.strlen (address);
+ byte [] buffer = new byte [length + 1];
+ OS.memmove (buffer, address, length);
+ OS.XtFree (address);
+
+ OS.XmTextSetString (selectionText, buffer);
+ OS.XmTextSetInsertionPosition (selectionText, OS.XmTextGetLastPosition (selectionText));
+ return 0;
+}
+
+int okPressed (int widget, int client, int call) {
+ String fullPath = null, fileName = null;
+ String [] fileNames = null;
+
+ int [] argList = {OS.XmNdirSpec, 0, OS.XmNdirectory, 0};
+ OS.XtGetValues (dialog, argList, argList.length / 2);
+
+ int xmString1 = argList [1];
+ int ptr = OS.XmStringUnparse (
+ xmString1,
+ 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);
+ /* Use the character encoding for the default locale */
+ fullPath = new String (Converter.mbcsToWcs (null, buffer)).trim();
+ }
+ OS.XmStringFree (xmString1);
+
+ if ((style & SWT.MULTI) != 0) {
+ int fileList = OS.XmFileSelectionBoxGetChild (dialog, OS.XmDIALOG_LIST);
+ if (fileList == 0) return 0;
+ int [] argList2 = {OS.XmNselectedItems, 0, OS.XmNselectedItemCount, 0};
+ OS.XtGetValues (fileList, argList2, argList2.length / 2);
+ int items = argList2 [1], itemCount = argList2 [3];
+ int [] buffer1 = new int [1];
+ fileNames = new String [itemCount];
+ boolean match = false;
+ for (int i = 0; i < itemCount; i++) {
+ OS.memmove (buffer1, items, 4);
+ ptr = buffer1 [0];
+ int address = OS.XmStringUnparse (
+ ptr,
+ 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);
+ /* Use the character encoding for the default locale */
+ String fullFilename = new String (Converter.mbcsToWcs (null, buffer));
+ int index = fullFilename.lastIndexOf ('/');
+ fileNames [i] = fullFilename.substring (index + 1, fullFilename.length ());
+ if (fullFilename.equals (fullPath)) match = true;
+ }
+ items += 4;
+ }
+ if (match) {
+ fileName = fileNames [0];
+ } else {
+ /* The user has modified the text field such that it doesn't match any
+ * of the selected files, so use this value instead
+ */
+ int index = fullPath.lastIndexOf ('/');
+ fileName = fullPath.substring (index + 1, fullPath.length ());
+ fileNames = new String [] {fileName};
+ }
+ } else {
+ int index = fullPath.lastIndexOf ('/');
+ fileName = fullPath.substring (index + 1, fullPath.length ());
+ fileNames = new String [] {fileName};
+ }
+
+ // if no file selected then go into the current directory
+ if (fileName.equals("")) {
+ int [] argList1 = {OS.XmNdirMask, 0};
+ OS.XtGetValues (dialog, argList1, argList1.length / 2);
+ int directoryHandle = argList1[1];
+ int [] argList2 = {OS.XmNpattern,directoryHandle};
+ OS.XtSetValues (dialog, argList2, argList2.length / 2);
+ OS.XmStringFree (directoryHandle);
+ return 0;
+ }
+
+ int xmString2 = argList [3];
+ ptr = OS.XmStringUnparse (
+ xmString2,
+ 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);
+ /* Use the character encoding for the default locale */
+ filterPath = new String (Converter.mbcsToWcs (null, buffer));
+ }
+ OS.XmStringFree (xmString2);
+ if (filterPath.endsWith("/")) {
+ filterPath = filterPath.substring (0, filterPath.length() - 1);
+ }
+
+ this.fullPath = fullPath;
+ this.fileName = fileName;
+ this.fileNames = fileNames;
+ OS.XtUnmanageChild (widget);
+ return 0;
+}
+
+/**
+ * Makes the dialog visible and brings it to the front
+ * of the display.
+ *
+ * @return a string describing the absolute path of the first selected file,
+ * or null if the dialog was cancelled or an error occurred
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the dialog has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the dialog</li>
+ * </ul>
*/
-public String open () {
-
- /* 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)) {
- if (OS.IsAIX) parent.realizeWidget (); /* Fix for bug 17507 */
- 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 = " ";
- /* Use the character encoding for the default locale */
- byte [] buffer1 = Converter.wcsToMbcs (null, string, true);
- int xmStringPtr1 = OS.XmStringParseText (
- buffer1,
- 0,
- OS.XmFONTLIST_DEFAULT_TAG,
- OS.XmCHARSET_TEXT,
- null,
- 0,
- 0);
-
- fullPath = null;
- fileNames = null;
-
- /* 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;
- }
- }
- /* Use the character encoding for the default locale */
- 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 = "";
- if (!filterPath.endsWith ("/")) {
- File dir = new File (filterPath);
- if (dir.exists () && dir.isDirectory ()) filterPath += '/';
- }
- /* Use the character encoding for the default locale */
- 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.XmNpathMode, OS.XmPATH_MODE_FULL,
- OS.XmNdialogTitle, xmStringPtr1,
- OS.XmNpattern, xmStringPtr2,
- OS.XmNdirMask, 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};
- 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);
-
- /* Hook the callbacks. */
- Callback cancelCallback = new Callback (this, "cancelPressed", 3);
- int cancelAddress = cancelCallback.getAddress ();
- OS.XtAddCallback (dialog, OS.XmNcancelCallback, cancelAddress, 0);
- Callback okCallback = new Callback (this, "okPressed", 3);
- int okAddress = okCallback.getAddress ();
- OS.XtAddCallback (dialog, OS.XmNokCallback, okAddress, 0);
- Callback selectCallback = null;
- if ((style & SWT.MULTI) != 0) {
- child = OS.XmFileSelectionBoxGetChild (dialog, OS.XmDIALOG_LIST);
- if (child != 0) {
- int [] argList2 = {OS.XmNselectionPolicy, OS.XmEXTENDED_SELECT};
- OS.XtSetValues(child, argList2, argList2.length / 2);
- selectCallback = new Callback (this, "itemSelected", 3);
- int selectAddress = selectCallback.getAddress ();
- if (selectAddress == 0) error (SWT.ERROR_NO_MORE_CALLBACKS);
- OS.XtAddCallback (child, OS.XmNextendedSelectionCallback, selectAddress, 0);
- }
- }
-
- OS.XtManageChild (dialog);
-
- // 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 ();
- okCallback.dispose ();
- cancelCallback.dispose ();
- if (selectCallback != null) selectCallback.dispose ();
- return fullPath;
-}
-
-/**
- * Set the initial filename which the dialog will
- * select by default when opened to the argument,
- * which may be null. The name will be prefixed with
- * the filter path when one is supplied.
- *
- * @param string the file name
+public 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)) {
+ if (OS.IsAIX) parent.realizeWidget (); /* Fix for bug 17507 */
+ 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 = " ";
+ /* Use the character encoding for the default locale */
+ byte [] buffer1 = Converter.wcsToMbcs (null, string, true);
+ int xmStringPtr1 = OS.XmStringParseText (
+ buffer1,
+ 0,
+ OS.XmFONTLIST_DEFAULT_TAG,
+ OS.XmCHARSET_TEXT,
+ null,
+ 0,
+ 0);
+
+ fullPath = null;
+ fileNames = null;
+
+ /* 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;
+ }
+ }
+ /* Use the character encoding for the default locale */
+ 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 = "";
+ if (!filterPath.endsWith ("/")) {
+ File dir = new File (filterPath);
+ if (dir.exists () && dir.isDirectory ()) filterPath += '/';
+ }
+ /* Use the character encoding for the default locale */
+ 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.XmNpathMode, OS.XmPATH_MODE_FULL,
+ OS.XmNdialogTitle, xmStringPtr1,
+ OS.XmNpattern, xmStringPtr2,
+ OS.XmNdirMask, 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};
+ 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);
+
+ /* Hook the callbacks. */
+ Callback cancelCallback = new Callback (this, "cancelPressed", 3);
+ int cancelAddress = cancelCallback.getAddress ();
+ OS.XtAddCallback (dialog, OS.XmNcancelCallback, cancelAddress, 0);
+ Callback okCallback = new Callback (this, "okPressed", 3);
+ int okAddress = okCallback.getAddress ();
+ OS.XtAddCallback (dialog, OS.XmNokCallback, okAddress, 0);
+ Callback selectCallback = null;
+ if ((style & SWT.MULTI) != 0) {
+ child = OS.XmFileSelectionBoxGetChild (dialog, OS.XmDIALOG_LIST);
+ if (child != 0) {
+ int [] argList2 = {OS.XmNselectionPolicy, OS.XmEXTENDED_SELECT};
+ OS.XtSetValues(child, argList2, argList2.length / 2);
+ selectCallback = new Callback (this, "itemSelected", 3);
+ int selectAddress = selectCallback.getAddress ();
+ if (selectAddress == 0) error (SWT.ERROR_NO_MORE_CALLBACKS);
+ OS.XtAddCallback (child, OS.XmNextendedSelectionCallback, selectAddress, 0);
+ }
+ }
+
+ OS.XtManageChild (dialog);
+
+ // 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 ();
+ okCallback.dispose ();
+ cancelCallback.dispose ();
+ if (selectCallback != null) selectCallback.dispose ();
+ return fullPath;
+}
+
+/**
+ * Set the initial filename which the dialog will
+ * select by default when opened to the argument,
+ * which may be null. The name will be prefixed with
+ * the filter path when one is supplied.
+ *
+ * @param string the file name
*/
-public void setFileName (String string) {
- fileName = string;
-}
-
-/**
- * Set the file extensions which the dialog will
- * use to filter the files it shows to the argument,
- * which may be null.
- *
- * @param extensions the file extension filter
+public void setFileName (String string) {
+ fileName = string;
+}
+
+/**
+ * Set the file extensions which the dialog will
+ * use to filter the files it shows to the argument,
+ * which may be null.
+ *
+ * @param extensions the file extension filter
*/
-public void setFilterExtensions (String [] extensions) {
- filterExtensions = extensions;
-}
-
-/**
- * Sets the file names which the dialog will
- * use to filter the files it shows to the argument,
- * which may be null.
- *
- * @param names the file name filter
+public void setFilterExtensions (String [] extensions) {
+ filterExtensions = extensions;
+}
+
+/**
+ * Sets the file names which the dialog will
+ * use to filter the files it shows to the argument,
+ * which may be null.
+ *
+ * @param names the file name filter
*/
-public void setFilterNames (String [] names) {
- filterNames = names;
-}
-
+public void setFilterNames (String [] names) {
+ filterNames = names;
+}
+
/**
* Sets the directory path that the dialog will use
* to the argument, which may be null. File names in this
@@ -504,7 +504,7 @@ public void setFilterNames (String [] names) {
*
* @see #setFilterExtensions
*/
-public void setFilterPath (String string) {
- filterPath = string;
-}
-}
+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
index 6ecb04481c..cb8df954fc 100755
--- 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
@@ -1,118 +1,118 @@
-package org.eclipse.swt.widgets;
-
-/*
+package org.eclipse.swt.widgets;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-import org.eclipse.swt.*;
-import org.eclipse.swt.graphics.*;
-import org.eclipse.swt.layout.*;
-
-import java.util.*;
-
-/**
- * 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>
+ * http://www.eclipse.org/legal/cpl-v10.html
*/
-public class FontDialog extends Dialog {
-
- private FontData fontData;
- private Font sampleFont; // the current displayed sample font
- private RGB rgb;
- private Color sampleColor; // the current displayed sample color
-
- /*
- * Table containing all available fonts as FontData objects.
- * The table is structured as a series of embedded Hashtables as follows:
- * <br>characterRegistryName -> faceName -> extendedStyle -> size -> style
- */
- private Hashtable characterSets = new Hashtable ();
-
- private boolean okSelected = false;
- private boolean ignoreEvents = false;
-
- // widgets
- private Shell shell;
- private Combo charSetCombo;
- private Combo faceNameCombo;
- private Combo fontSizeCombo;
- private Combo fontStyleCombo;
- private Combo extStyleCombo;
- private Label sampleLabel;
- private Button okButton;
- private Button cancelButton;
- private Button colorButton;
-
- // constants
- private static final String TEXT_SAMPLE = "AaBbYyZz";
- private static final String SCALABLE_SIZES[] = new String[] {"8", "10", "11", "12", "14", "16", "18", "22", "24", "26"};
- private static final int DEFAULT_SIZE = 14;
- private static final String DEFAULT_STYLE = "medium";
- private static final Integer SCALABLE_KEY = new Integer (0);
- private static final Integer NO_SELECTION = new Integer (-1);
- private static final int COLUMN1_WIDTH = 200;
- private static final int COLUMN2_WIDTH = 150;
- private static final int COLUMN3_WIDTH = 100;
- private static final String PREFIX_ISO8859 = "iso8859";
- private static final String PREFIX_ISO646 = "iso646";
- private static final String PREFIX_UNICODE = "ucs";
- private static final String PREFIX_JAPANESE = "jis";
- private static final String PREFIX_SIMPLIFIEDCHINESE = "gb";
- private static final String PREFIX_TRADITIONALCHINESE = "cns";
- private static final String PREFIX_KOREAN = "ks";
- private static final String [] ISO_CHARSETS = new String [] {
- "", // 0 undefined
- SWT.getMessage ("SWT_Charset_Western"),
- SWT.getMessage ("SWT_Charset_EastEuropean"),
- SWT.getMessage ("SWT_Charset_SouthEuropean"),
- SWT.getMessage ("SWT_Charset_NorthEuropean"),
- SWT.getMessage ("SWT_Charset_Cyrillic"),
- SWT.getMessage ("SWT_Charset_Arabic"),
- SWT.getMessage ("SWT_Charset_Greek"),
- SWT.getMessage ("SWT_Charset_Hebrew"),
- SWT.getMessage ("SWT_Charset_Turkish"),
- SWT.getMessage ("SWT_Charset_Nordic"),
- SWT.getMessage ("SWT_Charset_Thai"),
- "", // 12 undefined
- SWT.getMessage ("SWT_Charset_BalticRim"),
- SWT.getMessage ("SWT_Charset_Celtic"),
- SWT.getMessage ("SWT_Charset_Euro"),
- SWT.getMessage ("SWT_Charset_Romanian")
- };
-
-/**
- * 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>
+
+import org.eclipse.swt.*;
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.layout.*;
+
+import java.util.*;
+
+/**
+ * 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 {
+
+ private FontData fontData;
+ private Font sampleFont; // the current displayed sample font
+ private RGB rgb;
+ private Color sampleColor; // the current displayed sample color
+
+ /*
+ * Table containing all available fonts as FontData objects.
+ * The table is structured as a series of embedded Hashtables as follows:
+ * <br>characterRegistryName -> faceName -> extendedStyle -> size -> style
+ */
+ private Hashtable characterSets = new Hashtable ();
+
+ private boolean okSelected = false;
+ private boolean ignoreEvents = false;
+
+ // widgets
+ private Shell shell;
+ private Combo charSetCombo;
+ private Combo faceNameCombo;
+ private Combo fontSizeCombo;
+ private Combo fontStyleCombo;
+ private Combo extStyleCombo;
+ private Label sampleLabel;
+ private Button okButton;
+ private Button cancelButton;
+ private Button colorButton;
+
+ // constants
+ private static final String TEXT_SAMPLE = "AaBbYyZz";
+ private static final String SCALABLE_SIZES[] = new String[] {"8", "10", "11", "12", "14", "16", "18", "22", "24", "26"};
+ private static final int DEFAULT_SIZE = 14;
+ private static final String DEFAULT_STYLE = "medium";
+ private static final Integer SCALABLE_KEY = new Integer (0);
+ private static final Integer NO_SELECTION = new Integer (-1);
+ private static final int COLUMN1_WIDTH = 200;
+ private static final int COLUMN2_WIDTH = 150;
+ private static final int COLUMN3_WIDTH = 100;
+ private static final String PREFIX_ISO8859 = "iso8859";
+ private static final String PREFIX_ISO646 = "iso646";
+ private static final String PREFIX_UNICODE = "ucs";
+ private static final String PREFIX_JAPANESE = "jis";
+ private static final String PREFIX_SIMPLIFIEDCHINESE = "gb";
+ private static final String PREFIX_TRADITIONALCHINESE = "cns";
+ private static final String PREFIX_KOREAN = "ks";
+ private static final String [] ISO_CHARSETS = new String [] {
+ "", // 0 undefined
+ SWT.getMessage ("SWT_Charset_Western"),
+ SWT.getMessage ("SWT_Charset_EastEuropean"),
+ SWT.getMessage ("SWT_Charset_SouthEuropean"),
+ SWT.getMessage ("SWT_Charset_NorthEuropean"),
+ SWT.getMessage ("SWT_Charset_Cyrillic"),
+ SWT.getMessage ("SWT_Charset_Arabic"),
+ SWT.getMessage ("SWT_Charset_Greek"),
+ SWT.getMessage ("SWT_Charset_Hebrew"),
+ SWT.getMessage ("SWT_Charset_Turkish"),
+ SWT.getMessage ("SWT_Charset_Nordic"),
+ SWT.getMessage ("SWT_Charset_Thai"),
+ "", // 12 undefined
+ SWT.getMessage ("SWT_Charset_BalticRim"),
+ SWT.getMessage ("SWT_Charset_Celtic"),
+ SWT.getMessage ("SWT_Charset_Euro"),
+ SWT.getMessage ("SWT_Charset_Romanian")
+ };
+
+/**
+ * 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 FontDialog (Shell parent) {
- this (parent, SWT.NONE);
-}
-
+public FontDialog (Shell parent) {
+ this (parent, SWT.NONE);
+}
+
/**
* Constructs a new instance of this class given its parent
* and a style value describing its behavior and appearance.
@@ -143,845 +143,845 @@ public FontDialog (Shell parent) {
* <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
* </ul>
*/
-public FontDialog (Shell parent, int style) {
- super (parent, style | SWT.TITLE | SWT.BORDER | SWT.APPLICATION_MODAL);
- checkSubclass ();
-}
-
-/**
- * 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.
+public FontDialog (Shell parent, int style) {
+ super (parent, style | SWT.TITLE | SWT.BORDER | SWT.APPLICATION_MODAL);
+ checkSubclass ();
+}
+
+/**
+ * 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[]) {
+
+ for (int i = 0; i < fonts.length; i++) {
+ FontData font = fonts [i];
+
+ String charSetName = getTranslatedCharSet (font);
+ Hashtable charSet = (Hashtable) characterSets.get (charSetName);
+ if (charSet == null) {
+ charSet = new Hashtable (9);
+ characterSets.put (charSetName, charSet);
+ }
+
+ String faceName = getTranslatedFaceName (font);
+ Hashtable faceSet = (Hashtable) charSet.get (faceName);
+ if (faceSet == null) {
+ faceSet = new Hashtable (9);
+ charSet.put (faceName, faceSet);
+ }
+
+ String extStyleName = font.addStyle;
+ Hashtable extStyleSet = (Hashtable) faceSet.get (extStyleName);
+ if (extStyleSet == null) {
+ extStyleSet = new Hashtable (9);
+ faceSet.put (extStyleName, extStyleSet);
+ }
+
+ Integer sizeValue = new Integer (font.getHeight ());
+ Hashtable sizeSet = (Hashtable) extStyleSet.get (sizeValue);
+ if (sizeSet == null) {
+ sizeSet = new Hashtable (9);
+ extStyleSet.put (sizeValue, sizeSet);
+ }
+
+ String style = font.weight;
+ sizeSet.put (style,font);
+ }
+}
+
+/**
+ * Create the widgets of the dialog.
*/
-void addFonts (FontData fonts[]) {
-
- for (int i = 0; i < fonts.length; i++) {
- FontData font = fonts [i];
-
- String charSetName = getTranslatedCharSet (font);
- Hashtable charSet = (Hashtable) characterSets.get (charSetName);
- if (charSet == null) {
- charSet = new Hashtable (9);
- characterSets.put (charSetName, charSet);
- }
-
- String faceName = getTranslatedFaceName (font);
- Hashtable faceSet = (Hashtable) charSet.get (faceName);
- if (faceSet == null) {
- faceSet = new Hashtable (9);
- charSet.put (faceName, faceSet);
- }
-
- String extStyleName = font.addStyle;
- Hashtable extStyleSet = (Hashtable) faceSet.get (extStyleName);
- if (extStyleSet == null) {
- extStyleSet = new Hashtable (9);
- faceSet.put (extStyleName, extStyleSet);
- }
-
- Integer sizeValue = new Integer (font.getHeight ());
- Hashtable sizeSet = (Hashtable) extStyleSet.get (sizeValue);
- if (sizeSet == null) {
- sizeSet = new Hashtable (9);
- extStyleSet.put (sizeValue, sizeSet);
- }
-
- String style = font.weight;
- sizeSet.put (style,font);
- }
-}
-
-/**
- * Create the widgets of the dialog.
+void createChildren () {
+ Label characterSetLabel = new Label (shell, SWT.NONE);
+ Label faceNameLabel = new Label (shell, SWT.NONE);
+ Label extendedStyleLabel = new Label (shell, SWT.NONE);
+ GridLayout layout = new GridLayout ();
+
+ layout.numColumns = 4;
+ layout.marginWidth = 15;
+ layout.marginHeight = 15;
+ layout.horizontalSpacing = 10;
+ layout.verticalSpacing = 2;
+ shell.setLayout (layout);
+
+ // row one
+ characterSetLabel.setText (SWT.getMessage ("SWT_Character_set") + ":");
+ faceNameLabel.setText (SWT.getMessage ("SWT_Font") + ":");
+ extendedStyleLabel.setText (SWT.getMessage ("SWT_Extended_style") + ":");
+
+ new Label (shell, SWT.NONE);
+
+ // row two
+ charSetCombo = new Combo (shell, SWT.SIMPLE | SWT.V_SCROLL);
+ GridData gridData = new GridData ();
+ gridData.widthHint = COLUMN1_WIDTH;
+ gridData.heightHint = 150;
+ gridData.verticalSpan = 3;
+ charSetCombo.setLayoutData (gridData);
+ charSetCombo.setData (NO_SELECTION);
+
+ faceNameCombo = new Combo (shell, SWT.SIMPLE | SWT.V_SCROLL);
+ gridData = new GridData ();
+ gridData.widthHint = COLUMN2_WIDTH;
+ gridData.heightHint = 150;
+ gridData.verticalSpan = 3;
+ gridData.verticalAlignment = GridData.FILL;
+ faceNameCombo.setLayoutData (gridData);
+ faceNameCombo.setData (NO_SELECTION);
+
+ extStyleCombo = new Combo (shell, SWT.SIMPLE | SWT.V_SCROLL);
+ gridData = new GridData ();
+ gridData.widthHint = COLUMN3_WIDTH;
+ gridData.heightHint = 150;
+ gridData.verticalSpan = 3;
+ gridData.verticalAlignment = GridData.FILL;
+ extStyleCombo.setLayoutData (gridData);
+ extStyleCombo.setData (NO_SELECTION);
+
+ // create ok, cancel, and color buttons (row two, three, and four)
+ createButtons ();
+
+ // row four
+ createEmptyRow ();
+
+ // row five
+ Label fontSizeLabel = new Label (shell, SWT.NONE);
+ fontSizeLabel.setText (SWT.getMessage ("SWT_Size") + ":");
+ Label fontStyleLabel = new Label (shell, SWT.NONE);
+ fontStyleLabel.setText (SWT.getMessage ("SWT_Style") + ":");
+
+ Label fillLabel = new Label (shell, SWT.NONE);
+ gridData = new GridData ();
+ gridData.horizontalSpan = 2;
+ fillLabel.setLayoutData (gridData);
+
+ // row six
+ fontSizeCombo = new Combo (shell, SWT.SIMPLE | SWT.V_SCROLL);
+ gridData = new GridData ();
+ gridData.horizontalAlignment = GridData.FILL;
+ gridData.verticalAlignment = GridData.FILL;
+ gridData.heightHint = 110;
+ fontSizeCombo.setLayoutData (gridData);
+ fontSizeCombo.setData (NO_SELECTION);
+
+ fontStyleCombo = new Combo (shell, SWT.SIMPLE | SWT.V_SCROLL);
+ gridData = new GridData ();
+ gridData.horizontalAlignment = GridData.FILL;
+ gridData.verticalAlignment = GridData.FILL;
+ fontStyleCombo.setLayoutData (gridData);
+ fontStyleCombo.setData (NO_SELECTION);
+
+ fillLabel = new Label (shell, SWT.NONE);
+ gridData = new GridData ();
+ gridData.horizontalSpan = 2;
+ fillLabel.setLayoutData (gridData);
+
+ // row seven
+ createEmptyRow ();
+
+ // row eight
+ Group sampleGroup = new Group (shell, SWT.NONE);
+ sampleGroup.setText (SWT.getMessage ("SWT_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);
+ shell.setSize (445, 410);
+}
+
+/**
+ * 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 createChildren () {
- Label characterSetLabel = new Label (shell, SWT.NONE);
- Label faceNameLabel = new Label (shell, SWT.NONE);
- Label extendedStyleLabel = new Label (shell, SWT.NONE);
- GridLayout layout = new GridLayout ();
-
- layout.numColumns = 4;
- layout.marginWidth = 15;
- layout.marginHeight = 15;
- layout.horizontalSpacing = 10;
- layout.verticalSpacing = 2;
- shell.setLayout (layout);
-
- // row one
- characterSetLabel.setText (SWT.getMessage ("SWT_Character_set") + ":");
- faceNameLabel.setText (SWT.getMessage ("SWT_Font") + ":");
- extendedStyleLabel.setText (SWT.getMessage ("SWT_Extended_style") + ":");
-
- new Label (shell, SWT.NONE);
-
- // row two
- charSetCombo = new Combo (shell, SWT.SIMPLE | SWT.V_SCROLL);
- GridData gridData = new GridData ();
- gridData.widthHint = COLUMN1_WIDTH;
- gridData.heightHint = 150;
- gridData.verticalSpan = 3;
- charSetCombo.setLayoutData (gridData);
- charSetCombo.setData (NO_SELECTION);
-
- faceNameCombo = new Combo (shell, SWT.SIMPLE | SWT.V_SCROLL);
- gridData = new GridData ();
- gridData.widthHint = COLUMN2_WIDTH;
- gridData.heightHint = 150;
- gridData.verticalSpan = 3;
- gridData.verticalAlignment = GridData.FILL;
- faceNameCombo.setLayoutData (gridData);
- faceNameCombo.setData (NO_SELECTION);
-
- extStyleCombo = new Combo (shell, SWT.SIMPLE | SWT.V_SCROLL);
- gridData = new GridData ();
- gridData.widthHint = COLUMN3_WIDTH;
- gridData.heightHint = 150;
- gridData.verticalSpan = 3;
- gridData.verticalAlignment = GridData.FILL;
- extStyleCombo.setLayoutData (gridData);
- extStyleCombo.setData (NO_SELECTION);
-
- // create ok, cancel, and color buttons (row two, three, and four)
- createButtons ();
-
- // row four
- createEmptyRow ();
-
- // row five
- Label fontSizeLabel = new Label (shell, SWT.NONE);
- fontSizeLabel.setText (SWT.getMessage ("SWT_Size") + ":");
- Label fontStyleLabel = new Label (shell, SWT.NONE);
- fontStyleLabel.setText (SWT.getMessage ("SWT_Style") + ":");
-
- Label fillLabel = new Label (shell, SWT.NONE);
- gridData = new GridData ();
- gridData.horizontalSpan = 2;
- fillLabel.setLayoutData (gridData);
-
- // row six
- fontSizeCombo = new Combo (shell, SWT.SIMPLE | SWT.V_SCROLL);
- gridData = new GridData ();
- gridData.horizontalAlignment = GridData.FILL;
- gridData.verticalAlignment = GridData.FILL;
- gridData.heightHint = 110;
- fontSizeCombo.setLayoutData (gridData);
- fontSizeCombo.setData (NO_SELECTION);
-
- fontStyleCombo = new Combo (shell, SWT.SIMPLE | SWT.V_SCROLL);
- gridData = new GridData ();
- gridData.horizontalAlignment = GridData.FILL;
- gridData.verticalAlignment = GridData.FILL;
- fontStyleCombo.setLayoutData (gridData);
- fontStyleCombo.setData (NO_SELECTION);
-
- fillLabel = new Label (shell, SWT.NONE);
- gridData = new GridData ();
- gridData.horizontalSpan = 2;
- fillLabel.setLayoutData (gridData);
-
- // row seven
- createEmptyRow ();
-
- // row eight
- Group sampleGroup = new Group (shell, SWT.NONE);
- sampleGroup.setText (SWT.getMessage ("SWT_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);
- shell.setSize (445, 410);
-}
-
-/**
- * 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 () {
+ Label fillLabel = new Label (shell, SWT.NONE);
+ GridData gridData = new GridData ();
+
+ gridData.heightHint = 5;
+ gridData.horizontalSpan = ((GridLayout) shell.getLayout ()).numColumns;
+ fillLabel.setLayoutData (gridData);
+}
+
+/**
+ * Create the widgets of the dialog.
+ */
+void createButtons () {
+ okButton = new Button (shell, SWT.PUSH);
+ okButton.setText (SWT.getMessage ("SWT_OK"));
+ shell.setDefaultButton (okButton);
+ GridData gridData = new GridData ();
+ gridData.horizontalAlignment = GridData.FILL;
+ gridData.widthHint = 70;
+ okButton.setLayoutData (gridData);
+
+ cancelButton = new Button (shell, SWT.PUSH);
+ cancelButton.setText (SWT.getMessage ("SWT_Cancel"));
+ gridData = new GridData ();
+ gridData.horizontalAlignment = GridData.FILL;
+ gridData.verticalAlignment = GridData.BEGINNING;
+ cancelButton.setLayoutData (gridData);
+
+ colorButton = new Button (shell, SWT.PUSH);
+ colorButton.setText (SWT.getMessage ("SWT_Color"));
+ gridData = new GridData ();
+ gridData.horizontalAlignment = GridData.FILL;
+ gridData.verticalAlignment = GridData.BEGINNING;
+ colorButton.setLayoutData (gridData);
+}
+
+Hashtable getExtStyles (String charsetName, String faceName) {
+ Hashtable faces = getFaces (charsetName);
+ if (faces == null) return null;
+ return (Hashtable) faces.get (faceName);
+}
+
+Hashtable getFaces (String charsetName) {
+ return (Hashtable) getFonts ().get (charsetName);
+}
+
+/**
+ * Returns a FontData object describing the font that was
+ * selected in the dialog, or null if none is available.
+ *
+ * @return the FontData for the selected font, or null
*/
-void createEmptyRow () {
- Label fillLabel = new Label (shell, SWT.NONE);
- GridData gridData = new GridData ();
-
- gridData.heightHint = 5;
- gridData.horizontalSpan = ((GridLayout) shell.getLayout ()).numColumns;
- fillLabel.setLayoutData (gridData);
-}
-
-/**
- * Create the widgets of the dialog.
+public FontData getFontData () {
+ return fontData;
+}
+
+FontData getFontData (String charsetName, String faceName, String extStyle, int size, String style) {
+ Hashtable styles = getStyles (charsetName, faceName, extStyle, size);
+ if (styles == null) return null;
+ return (FontData) styles.get (style);
+}
+
+/**
+ * Returns the collection of fonts that are displayed by the
+ * receiver.
+ * See the class definition for an explanation of the structure
+ * of the returned Hashtable.
*/
-void createButtons () {
- okButton = new Button (shell, SWT.PUSH);
- okButton.setText (SWT.getMessage ("SWT_OK"));
- shell.setDefaultButton (okButton);
- GridData gridData = new GridData ();
- gridData.horizontalAlignment = GridData.FILL;
- gridData.widthHint = 70;
- okButton.setLayoutData (gridData);
-
- cancelButton = new Button (shell, SWT.PUSH);
- cancelButton.setText (SWT.getMessage ("SWT_Cancel"));
- gridData = new GridData ();
- gridData.horizontalAlignment = GridData.FILL;
- gridData.verticalAlignment = GridData.BEGINNING;
- cancelButton.setLayoutData (gridData);
-
- colorButton = new Button (shell, SWT.PUSH);
- colorButton.setText (SWT.getMessage ("SWT_Color"));
- gridData = new GridData ();
- gridData.horizontalAlignment = GridData.FILL;
- gridData.verticalAlignment = GridData.BEGINNING;
- colorButton.setLayoutData (gridData);
-}
-
-Hashtable getExtStyles (String charsetName, String faceName) {
- Hashtable faces = getFaces (charsetName);
- if (faces == null) return null;
- return (Hashtable) faces.get (faceName);
-}
-
-Hashtable getFaces (String charsetName) {
- return (Hashtable) getFonts ().get (charsetName);
-}
-
-/**
- * Returns a FontData object describing the font that was
- * selected in the dialog, or null if none is available.
- *
- * @return the FontData for the selected font, or null
+Hashtable getFonts () {
+ return characterSets;
+}
+
+/**
+ * Returns the currently selected color in the receiver.
+ *
+ * @return the RGB value for the selected color, may be null
+ *
+ * @see PaletteData#getRGBs
*/
-public FontData getFontData () {
- return fontData;
-}
-
-FontData getFontData (String charsetName, String faceName, String extStyle, int size, String style) {
- Hashtable styles = getStyles (charsetName, faceName, extStyle, size);
- if (styles == null) return null;
- return (FontData) styles.get (style);
-}
-
-/**
- * Returns the collection of fonts that are displayed by the
- * receiver.
- * See the class definition for an explanation of the structure
- * of the returned Hashtable.
+public RGB getRGB () {
+ return rgb;
+}
+
+/**
+ * Returns a FontData object that can be used to load the selected
+ * font.
*/
-Hashtable getFonts () {
- return characterSets;
-}
-
-/**
- * Returns the currently selected color in the receiver.
- *
- * @return the RGB value for the selected color, may be null
- *
- * @see PaletteData#getRGBs
- */
-public RGB getRGB () {
- return rgb;
-}
-
-/**
- * Returns a FontData object that can be used to load the selected
- * font.
+FontData getSelectionFontData () {
+ String charSetName = charSetCombo.getText ();
+ String faceName = faceNameCombo.getText ();
+ String extStyle = extStyleCombo.getText ();
+ int size = DEFAULT_SIZE;
+ try {
+ size = Integer.valueOf (fontSizeCombo.getText ()).intValue ();
+ if (size < 1) size = DEFAULT_SIZE;
+ } catch (NumberFormatException e) {
+ /*
+ * This block is purposely left empty since a default
+ * value is already specified above.
+ */
+ }
+ String style = fontStyleCombo.getText ();
+ FontData result = getFontData (charSetName, faceName, extStyle, size, style);
+
+ if (result == null) {
+ /*
+ * One or more of the dialog's widgets contain custom typed values.
+ * Create a FontData that mirrors these values so that the Font created
+ * below will try to find the best match.
+ */
+ result = new FontData ();
+ result.characterSetRegistry = charSetName;
+ result.setName(faceName);
+ result.addStyle = extStyle;
+ result.weight = style;
+ }
+ result.setHeight (size);
+ return result;
+}
+
+Hashtable getSizes (String charsetName, String faceName, String extStyle) {
+ Hashtable extStyles = getExtStyles (charsetName, faceName);
+ if (extStyles == null) return null;
+ return (Hashtable) extStyles.get (extStyle);
+}
+
+Hashtable getStyles (String charsetName, String faceName, String extStyle, int size) {
+ Hashtable sizes = getSizes (charsetName, faceName, extStyle);
+ if (sizes == null) return null;
+ Hashtable result = (Hashtable) sizes.get (new Integer (size));
+ if (result == null)
+ result = (Hashtable) sizes.get (SCALABLE_KEY);
+ return result;
+}
+
+/**
+ * Returns the character set found in 'fontData' prefixed
+ * with a string explaining the character set.
*/
-FontData getSelectionFontData () {
- String charSetName = charSetCombo.getText ();
- String faceName = faceNameCombo.getText ();
- String extStyle = extStyleCombo.getText ();
- int size = DEFAULT_SIZE;
- try {
- size = Integer.valueOf (fontSizeCombo.getText ()).intValue ();
- if (size < 1) size = DEFAULT_SIZE;
- } catch (NumberFormatException e) {
- /*
- * This block is purposely left empty since a default
- * value is already specified above.
- */
- }
- String style = fontStyleCombo.getText ();
- FontData result = getFontData (charSetName, faceName, extStyle, size, style);
-
- if (result == null) {
- /*
- * One or more of the dialog's widgets contain custom typed values.
- * Create a FontData that mirrors these values so that the Font created
- * below will try to find the best match.
- */
- result = new FontData ();
- result.characterSetRegistry = charSetName;
- result.setName(faceName);
- result.addStyle = extStyle;
- result.weight = style;
- }
- result.setHeight (size);
- return result;
-}
-
-Hashtable getSizes (String charsetName, String faceName, String extStyle) {
- Hashtable extStyles = getExtStyles (charsetName, faceName);
- if (extStyles == null) return null;
- return (Hashtable) extStyles.get (extStyle);
-}
-
-Hashtable getStyles (String charsetName, String faceName, String extStyle, int size) {
- Hashtable sizes = getSizes (charsetName, faceName, extStyle);
- if (sizes == null) return null;
- Hashtable result = (Hashtable) sizes.get (new Integer (size));
- if (result == null)
- result = (Hashtable) sizes.get (SCALABLE_KEY);
- return result;
-}
-
-/**
- * Returns 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 (PREFIX_ISO8859)) {
+ int charSetName = 1;
+ try {
+ charSetName = Integer.valueOf (fontData.characterSetName).intValue ();
+ } catch (NumberFormatException e) {
+ /*
+ * This block is purposely left empty since a default
+ * value is already specified above.
+ */
+ }
+ characterSet += "-" + charSetName;
+ if (charSetName < ISO_CHARSETS.length) {
+ translatedCharSet = ISO_CHARSETS [charSetName];
+ }
+ }
+ else
+ if (characterSet.startsWith (PREFIX_ISO646)) {
+ translatedCharSet = SWT.getMessage("SWT_Charset_ASCII");
+ }
+ else
+ if (characterSet.startsWith (PREFIX_UNICODE)) {
+ translatedCharSet = SWT.getMessage("SWT_Charset_Unicode");
+ }
+ else
+ if (characterSet.startsWith (PREFIX_JAPANESE)) {
+ translatedCharSet = SWT.getMessage("SWT_Charset_Japanese");
+ }
+ else
+ if (characterSet.startsWith (PREFIX_SIMPLIFIEDCHINESE)) {
+ translatedCharSet = SWT.getMessage("SWT_Charset_SimplifiedChinese");
+ }
+ else
+ if (characterSet.startsWith (PREFIX_TRADITIONALCHINESE)) {
+ translatedCharSet = SWT.getMessage("SWT_Charset_TraditionalChinese");
+ }
+ else
+ if (characterSet.startsWith (PREFIX_KOREAN)) {
+ translatedCharSet = SWT.getMessage("SWT_Charset_Korean");
+ }
+ if (translatedCharSet != null) {
+ translatedCharSet += " (" + characterSet + ')';
+ }
+ else {
+ translatedCharSet = characterSet;
+ }
+ return translatedCharSet;
+}
+
+/**
+ * Returns 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 getTranslatedCharSet (FontData fontData) {
- String characterSet = fontData.characterSetRegistry;
- String translatedCharSet = null;
-
- if (characterSet.startsWith (PREFIX_ISO8859)) {
- int charSetName = 1;
- try {
- charSetName = Integer.valueOf (fontData.characterSetName).intValue ();
- } catch (NumberFormatException e) {
- /*
- * This block is purposely left empty since a default
- * value is already specified above.
- */
- }
- characterSet += "-" + charSetName;
- if (charSetName < ISO_CHARSETS.length) {
- translatedCharSet = ISO_CHARSETS [charSetName];
- }
- }
- else
- if (characterSet.startsWith (PREFIX_ISO646)) {
- translatedCharSet = SWT.getMessage("SWT_Charset_ASCII");
- }
- else
- if (characterSet.startsWith (PREFIX_UNICODE)) {
- translatedCharSet = SWT.getMessage("SWT_Charset_Unicode");
- }
- else
- if (characterSet.startsWith (PREFIX_JAPANESE)) {
- translatedCharSet = SWT.getMessage("SWT_Charset_Japanese");
- }
- else
- if (characterSet.startsWith (PREFIX_SIMPLIFIEDCHINESE)) {
- translatedCharSet = SWT.getMessage("SWT_Charset_SimplifiedChinese");
- }
- else
- if (characterSet.startsWith (PREFIX_TRADITIONALCHINESE)) {
- translatedCharSet = SWT.getMessage("SWT_Charset_TraditionalChinese");
- }
- else
- if (characterSet.startsWith (PREFIX_KOREAN)) {
- translatedCharSet = SWT.getMessage("SWT_Charset_Korean");
- }
- if (translatedCharSet != null) {
- translatedCharSet += " (" + characterSet + ')';
- }
- else {
- translatedCharSet = characterSet;
- }
- return translatedCharSet;
-}
-
-/**
- * Returns 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.
*/
-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 handleEvent (Event event) {
+ if (ignoreEvents) return;
+ if (event.widget instanceof Combo) {
+ Combo combo = (Combo) event.widget;
+ int prevSelectIndex = ((Integer) combo.getData ()).intValue ();
+ String text = combo.getText ();
+ int newSelectIndex = combo.indexOf (text);
+ if (prevSelectIndex != newSelectIndex || newSelectIndex == -1) {
+ ignoreEvents = true;
+ combo.setData (new Integer (newSelectIndex));
+ if (combo == charSetCombo) initFaceNameCombo ();
+ else if (combo == faceNameCombo) initExtStyleCombo ();
+ else if (combo == extStyleCombo) initSizeCombo ();
+ else if (combo == fontSizeCombo) initStyleCombo ();
+ updateSampleFont ();
+ if (newSelectIndex != -1) {
+ // in case it came by typing the name
+ combo.select (newSelectIndex);
+ }
+ ignoreEvents = false;
+ }
+ }
+ else
+ if (event.widget == okButton) {
+ okSelected = true;
+ shell.close ();
+ }
+ else
+ if (event.widget == cancelButton) {
+ okSelected = false;
+ shell.close ();
+ }
+ else
+ if (event.widget == colorButton) {
+ ColorDialog colorDialog = new ColorDialog (shell, SWT.NONE);
+ colorDialog.setRGB (rgb);
+ RGB newRgb = colorDialog.open ();
+ if (newRgb != null) {
+ rgb = newRgb;
+ updateSampleColor ();
+ }
+ }
+}
+
+/**
+ * Initialize the extended styles combo with the extended styles
+ * available for the selected font.
+ * Downstream combos are initialized as well (style and size).
*/
-void handleEvent (Event event) {
- if (ignoreEvents) return;
- if (event.widget instanceof Combo) {
- Combo combo = (Combo) event.widget;
- int prevSelectIndex = ((Integer) combo.getData ()).intValue ();
- String text = combo.getText ();
- int newSelectIndex = combo.indexOf (text);
- if (prevSelectIndex != newSelectIndex || newSelectIndex == -1) {
- ignoreEvents = true;
- combo.setData (new Integer (newSelectIndex));
- if (combo == charSetCombo) initFaceNameCombo ();
- else if (combo == faceNameCombo) initExtStyleCombo ();
- else if (combo == extStyleCombo) initSizeCombo ();
- else if (combo == fontSizeCombo) initStyleCombo ();
- updateSampleFont ();
- if (newSelectIndex != -1) {
- // in case it came by typing the name
- combo.select (newSelectIndex);
- }
- ignoreEvents = false;
- }
- }
- else
- if (event.widget == okButton) {
- okSelected = true;
- shell.close ();
- }
- else
- if (event.widget == cancelButton) {
- okSelected = false;
- shell.close ();
- }
- else
- if (event.widget == colorButton) {
- ColorDialog colorDialog = new ColorDialog (shell, SWT.NONE);
- colorDialog.setRGB (rgb);
- RGB newRgb = colorDialog.open ();
- if (newRgb != null) {
- rgb = newRgb;
- updateSampleColor ();
- }
- }
-}
-
-/**
- * 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 oldSelect = extStyleCombo.getText ();
+ extStyleCombo.removeAll ();
+
+ String characterSet = charSetCombo.getText ();
+ String faceName = faceNameCombo.getText ();
+ Hashtable extStyles = getExtStyles (characterSet, faceName);
+ setItemsSorted (extStyleCombo, extStyles);
+
+ int selectIndex = extStyleCombo.indexOf (oldSelect);
+ selectIndex = Math.max (0, selectIndex);
+ extStyleCombo.select (selectIndex);
+ extStyleCombo.setData (new Integer (selectIndex));
+ initSizeCombo ();
+}
+
+/**
+ * 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 initExtStyleCombo () {
- String oldSelect = extStyleCombo.getText ();
- extStyleCombo.removeAll ();
-
- String characterSet = charSetCombo.getText ();
- String faceName = faceNameCombo.getText ();
- Hashtable extStyles = getExtStyles (characterSet, faceName);
- setItemsSorted (extStyleCombo, extStyles);
-
- int selectIndex = extStyleCombo.indexOf (oldSelect);
- selectIndex = Math.max (0, selectIndex);
- extStyleCombo.select (selectIndex);
- extStyleCombo.setData (new Integer (selectIndex));
- initSizeCombo ();
-}
-
-/**
- * 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 () {
+ String oldSelect = faceNameCombo.getText ();
+ faceNameCombo.removeAll ();
+ String charSetText = charSetCombo.getText ();
+ if (charSetText.length () == 0) return;
+
+ Hashtable faceNames = getFaces (charSetText);
+ setItemsSorted (faceNameCombo, faceNames);
+
+ int selectIndex = faceNameCombo.indexOf (oldSelect);
+ selectIndex = Math.max (0, selectIndex);
+ faceNameCombo.select (selectIndex);
+ faceNameCombo.setData (new Integer (selectIndex));
+ initExtStyleCombo ();
+}
+
+/**
+ * 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 initFaceNameCombo () {
- String oldSelect = faceNameCombo.getText ();
- faceNameCombo.removeAll ();
- String charSetText = charSetCombo.getText ();
- if (charSetText.length () == 0) return;
-
- Hashtable faceNames = getFaces (charSetText);
- setItemsSorted (faceNameCombo, faceNames);
-
- int selectIndex = faceNameCombo.indexOf (oldSelect);
- selectIndex = Math.max (0, selectIndex);
- faceNameCombo.select (selectIndex);
- faceNameCombo.setData (new Integer (selectIndex));
- initExtStyleCombo ();
-}
-
-/**
- * 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 () {
+ Display display = shell.getDisplay ();
+ addFonts (display.getFontList (null, false)); // get all fonts availabe on the current display
+ addFonts (display.getFontList (null, true));
+ setItemsSorted (charSetCombo, getFonts ());
+ if (fontData != null) {
+ Font font = new Font (display, fontData); // verify that the initial font data is a valid font
+ ignoreEvents = true;
+ setFontCombos (font.getFontData ()[0]);
+ ignoreEvents = false;
+ font.dispose ();
+ }
+ updateSampleFont ();
+ updateSampleColor ();
+}
+
+/**
+ * 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 initializeWidgets () {
- Display display = shell.getDisplay ();
- addFonts (display.getFontList (null, false)); // get all fonts availabe on the current display
- addFonts (display.getFontList (null, true));
- setItemsSorted (charSetCombo, getFonts ());
- if (fontData != null) {
- Font font = new Font (display, fontData); // verify that the initial font data is a valid font
- ignoreEvents = true;
- setFontCombos (font.getFontData ()[0]);
- ignoreEvents = false;
- font.dispose ();
- }
- updateSampleFont ();
- updateSampleColor ();
-}
-
-/**
- * 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 () {
+ String oldSelect = fontSizeCombo.getText ();
+ fontSizeCombo.removeAll ();
+
+ String characterSet = charSetCombo.getText ();
+ String faceName = faceNameCombo.getText ();
+ String extStyle = extStyleCombo.getText ();
+ Hashtable sizes = getSizes (characterSet, faceName, extStyle);
+ if (sizes != null) {
+ if (sizes.get (SCALABLE_KEY) == null) {
+ /*
+ * Font is not scalable so just present the provided sizes.
+ */
+ setSizeItemsSorted (sizes.keys ());
+ } else {
+ /*
+ * Font is scalable so present the provided sizes and scalable
+ * sizes for selection.
+ */
+ Vector allSizes = new Vector ();
+ /*
+ * Add the scalable sizes.
+ */
+ for (int i = 0; i < SCALABLE_SIZES.length; i++) {
+ allSizes.addElement (Integer.valueOf (SCALABLE_SIZES [i]));
+ }
+ /*
+ * Add the provided sizes.
+ */
+ Enumeration providedSizes = sizes.keys ();
+ while (providedSizes.hasMoreElements ()) {
+ Integer size = (Integer) providedSizes.nextElement ();
+ if (!size.equals (SCALABLE_KEY) && !allSizes.contains (size)) {
+ allSizes.addElement (size);
+ }
+ }
+ setSizeItemsSorted (allSizes.elements ());
+ }
+ }
+
+ int selectIndex = fontSizeCombo.indexOf (oldSelect);
+ if (selectIndex == -1) {
+ selectIndex = fontSizeCombo.indexOf (String.valueOf (DEFAULT_SIZE));
+ }
+ selectIndex = Math.max (0, selectIndex);
+ fontSizeCombo.select (selectIndex);
+ fontSizeCombo.setData (new Integer (selectIndex));
+ initStyleCombo ();
+}
+
+/**
+ * Initialize the styles combo with the styles the selected font
+ * is available in.
*/
-void initSizeCombo () {
- String oldSelect = fontSizeCombo.getText ();
- fontSizeCombo.removeAll ();
-
- String characterSet = charSetCombo.getText ();
- String faceName = faceNameCombo.getText ();
- String extStyle = extStyleCombo.getText ();
- Hashtable sizes = getSizes (characterSet, faceName, extStyle);
- if (sizes != null) {
- if (sizes.get (SCALABLE_KEY) == null) {
- /*
- * Font is not scalable so just present the provided sizes.
- */
- setSizeItemsSorted (sizes.keys ());
- } else {
- /*
- * Font is scalable so present the provided sizes and scalable
- * sizes for selection.
- */
- Vector allSizes = new Vector ();
- /*
- * Add the scalable sizes.
- */
- for (int i = 0; i < SCALABLE_SIZES.length; i++) {
- allSizes.addElement (Integer.valueOf (SCALABLE_SIZES [i]));
- }
- /*
- * Add the provided sizes.
- */
- Enumeration providedSizes = sizes.keys ();
- while (providedSizes.hasMoreElements ()) {
- Integer size = (Integer) providedSizes.nextElement ();
- if (!size.equals (SCALABLE_KEY) && !allSizes.contains (size)) {
- allSizes.addElement (size);
- }
- }
- setSizeItemsSorted (allSizes.elements ());
- }
- }
-
- int selectIndex = fontSizeCombo.indexOf (oldSelect);
- if (selectIndex == -1) {
- selectIndex = fontSizeCombo.indexOf (String.valueOf (DEFAULT_SIZE));
- }
- selectIndex = Math.max (0, selectIndex);
- fontSizeCombo.select (selectIndex);
- fontSizeCombo.setData (new Integer (selectIndex));
- initStyleCombo ();
-}
-
-/**
- * Initialize the styles combo with the styles the selected font
- * is available in.
+void initStyleCombo () {
+ String oldSelect = fontStyleCombo.getText ();
+ fontStyleCombo.removeAll ();
+
+ String characterSet = charSetCombo.getText ();
+ String faceName = faceNameCombo.getText ();
+ String extStyle = extStyleCombo.getText ();
+ try {
+ int size = Integer.valueOf (fontSizeCombo.getText ()).intValue ();
+ if (size > 0) {
+ Hashtable styles = getStyles (characterSet, faceName, extStyle, size);
+ setItemsSorted (fontStyleCombo, styles);
+ }
+ } catch (NumberFormatException e) {
+ // fall through
+ }
+
+ int selectIndex = fontStyleCombo.indexOf (oldSelect);
+ if (selectIndex == -1) {
+ selectIndex = fontStyleCombo.indexOf (String.valueOf (DEFAULT_STYLE));
+ }
+ selectIndex = Math.max (0, selectIndex);
+ fontStyleCombo.select (selectIndex);
+ fontStyleCombo.setData (new Integer (selectIndex));
+ fontStyleCombo.select (Math.max (0, selectIndex));
+}
+
+/**
+ * Register the receiver to receive events.
*/
-void initStyleCombo () {
- String oldSelect = fontStyleCombo.getText ();
- fontStyleCombo.removeAll ();
-
- String characterSet = charSetCombo.getText ();
- String faceName = faceNameCombo.getText ();
- String extStyle = extStyleCombo.getText ();
- try {
- int size = Integer.valueOf (fontSizeCombo.getText ()).intValue ();
- if (size > 0) {
- Hashtable styles = getStyles (characterSet, faceName, extStyle, size);
- setItemsSorted (fontStyleCombo, styles);
- }
- } catch (NumberFormatException e) {
- // fall through
- }
-
- int selectIndex = fontStyleCombo.indexOf (oldSelect);
- if (selectIndex == -1) {
- selectIndex = fontStyleCombo.indexOf (String.valueOf (DEFAULT_STYLE));
- }
- selectIndex = Math.max (0, selectIndex);
- fontStyleCombo.select (selectIndex);
- fontStyleCombo.setData (new Integer (selectIndex));
- fontStyleCombo.select (Math.max (0, selectIndex));
-}
-
-/**
- * Register the receiver to receive events.
+void installListeners () {
+ Listener listener = new Listener () {
+ public void handleEvent (Event event) {
+ FontDialog.this.handleEvent (event);
+ }
+ };
+ okButton.addListener (SWT.Selection, listener);
+ cancelButton.addListener (SWT.Selection, listener);
+ colorButton.addListener (SWT.Selection, listener);
+ charSetCombo.addListener (SWT.Selection, listener);
+ charSetCombo.addListener (SWT.Modify, listener);
+ faceNameCombo.addListener (SWT.Modify, listener);
+ fontStyleCombo.addListener (SWT.Modify, listener);
+ extStyleCombo.addListener (SWT.Modify, listener);
+ fontSizeCombo.addListener (SWT.Modify, listener);
+}
+
+/**
+ * Makes the dialog visible and brings it to the front
+ * of the display.
+ *
+ * @return a FontData object describing the font that was selected,
+ * or null if the dialog was cancelled or an error occurred
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the dialog has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the dialog</li>
+ * </ul>
*/
-void installListeners () {
- Listener listener = new Listener () {
- public void handleEvent (Event event) {
- FontDialog.this.handleEvent (event);
- }
- };
- okButton.addListener (SWT.Selection, listener);
- cancelButton.addListener (SWT.Selection, listener);
- colorButton.addListener (SWT.Selection, listener);
- charSetCombo.addListener (SWT.Selection, listener);
- charSetCombo.addListener (SWT.Modify, listener);
- faceNameCombo.addListener (SWT.Modify, listener);
- fontStyleCombo.addListener (SWT.Modify, listener);
- extStyleCombo.addListener (SWT.Modify, listener);
- fontSizeCombo.addListener (SWT.Modify, listener);
-}
-
-/**
- * Makes the dialog visible and brings it to the front
- * of the display.
- *
- * @return a FontData object describing the font that was selected,
- * or null if the dialog was cancelled or an error occurred
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the dialog has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the dialog</li>
- * </ul>
+public FontData open () {
+ shell = new Shell (getParent (), getStyle () | SWT.TITLE | SWT.BORDER | SWT.APPLICATION_MODAL);
+ createChildren ();
+ installListeners ();
+
+ FontData originalFontData = fontData;
+ RGB originalRGB = rgb;
+ initializeWidgets ();
+ openDialog ();
+ Display display = shell.getDisplay ();
+ while (!shell.isDisposed ()) {
+ if (!display.readAndDispatch ()) display.sleep ();
+ }
+
+ FontData result = null;
+ if (okSelected) {
+ result = fontData;
+ } else {
+ fontData = originalFontData;
+ rgb = originalRGB;
+ }
+ if (sampleFont != null) sampleFont.dispose ();
+ sampleFont = null;
+ if (sampleColor != null) sampleColor.dispose ();
+ sampleColor = null;
+ return result;
+}
+
+/**
+ * Open the receiver and set its size to the size calculated by
+ * the layout manager.
*/
-public FontData open () {
- shell = new Shell (getParent (), getStyle () | SWT.TITLE | SWT.BORDER | SWT.APPLICATION_MODAL);
- createChildren ();
- installListeners ();
-
- FontData originalFontData = fontData;
- RGB originalRGB = rgb;
- initializeWidgets ();
- openDialog ();
- Display display = shell.getDisplay ();
- while (!shell.isDisposed ()) {
- if (!display.readAndDispatch ()) display.sleep ();
- }
-
- FontData result = null;
- if (okSelected) {
- result = fontData;
- } else {
- fontData = originalFontData;
- rgb = originalRGB;
- }
- if (sampleFont != null) sampleFont.dispose ();
- sampleFont = null;
- if (sampleColor != null) sampleColor.dispose ();
- sampleColor = null;
- return result;
-}
-
-/**
- * Open the receiver and set its size to the size calculated by
- * the layout manager.
+void openDialog () {
+ // Start everything off by setting the shell size to its computed size.
+ Point pt = shell.computeSize(SWT.DEFAULT, SWT.DEFAULT, false);
+
+ // Ensure that the width of the shell fits the display.
+ Rectangle displayRect = shell.getDisplay().getBounds();
+ int widthLimit = displayRect.width * 7 / 8;
+ int heightLimit = displayRect.height * 7 / 8;
+ if (pt.x > widthLimit) {
+ pt = shell.computeSize (widthLimit, SWT.DEFAULT, false);
+ }
+
+ // centre the dialog on its parent, and ensure that the
+ // whole dialog appears within the screen bounds
+ Rectangle parentBounds = getParent ().getBounds ();
+ int originX = (parentBounds.width - pt.x) / 2 + parentBounds.x;
+ originX = Math.max (originX, 0);
+ originX = Math.min (originX, widthLimit - pt.x);
+ int originY = (parentBounds.height - pt.y) / 2 + parentBounds.y;
+ originY = Math.max (originY, 0);
+ originY = Math.min (originY, heightLimit - pt.y);
+ shell.setBounds (originX, originY, pt.x, pt.y);
+
+ String title = getText ();
+ if (title.length () == 0) title = SWT.getMessage ("SWT_FontDialog_Title");
+ shell.setText(title);
+
+ // Open the window.
+ shell.open();
+}
+
+/**
+ * Initialize the combo boxes with the data of the preselected
+ * font specified by the user.
*/
-void openDialog () {
- // Start everything off by setting the shell size to its computed size.
- Point pt = shell.computeSize(SWT.DEFAULT, SWT.DEFAULT, false);
-
- // Ensure that the width of the shell fits the display.
- Rectangle displayRect = shell.getDisplay().getBounds();
- int widthLimit = displayRect.width * 7 / 8;
- int heightLimit = displayRect.height * 7 / 8;
- if (pt.x > widthLimit) {
- pt = shell.computeSize (widthLimit, SWT.DEFAULT, false);
- }
-
- // centre the dialog on its parent, and ensure that the
- // whole dialog appears within the screen bounds
- Rectangle parentBounds = getParent ().getBounds ();
- int originX = (parentBounds.width - pt.x) / 2 + parentBounds.x;
- originX = Math.max (originX, 0);
- originX = Math.min (originX, widthLimit - pt.x);
- int originY = (parentBounds.height - pt.y) / 2 + parentBounds.y;
- originY = Math.max (originY, 0);
- originY = Math.min (originY, heightLimit - pt.y);
- shell.setBounds (originX, originY, pt.x, pt.y);
-
- String title = getText ();
- if (title.length () == 0) title = SWT.getMessage ("SWT_FontDialog_Title");
- shell.setText(title);
-
- // Open the window.
- shell.open();
-}
-
-/**
- * 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);
+ charSetCombo.setText (characterSet);
+ charSetCombo.setData (new Integer (charSetCombo.indexOf (characterSet)));
+
+ initFaceNameCombo ();
+ faceNameCombo.setText (faceName);
+ faceNameCombo.setData (new Integer (faceNameCombo.indexOf (faceName)));
+
+ initExtStyleCombo ();
+ extStyleCombo.setText (fontData.addStyle);
+ extStyleCombo.setData (new Integer (extStyleCombo.indexOf (fontData.addStyle)));
+
+ initSizeCombo ();
+ String value = String.valueOf (fontData.getHeight ());
+ fontSizeCombo.setText (value);
+ fontSizeCombo.setData (new Integer (fontSizeCombo.indexOf (value)));
+
+ initStyleCombo ();
+ fontStyleCombo.setText (fontData.weight);
+ fontStyleCombo.setData (new Integer (fontStyleCombo.indexOf (fontData.weight)));
+}
+
+/**
+ * Sets a FontData object describing the font to be
+ * selected by default in the dialog, or null to let
+ * the platform choose one.
+ *
+ * @param fontData the FontData to use initially, or null
*/
-void setFontCombos (FontData fontData) {
- String characterSet = getTranslatedCharSet (fontData);
- String faceName = getTranslatedFaceName (fontData);
- charSetCombo.setText (characterSet);
- charSetCombo.setData (new Integer (charSetCombo.indexOf (characterSet)));
-
- initFaceNameCombo ();
- faceNameCombo.setText (faceName);
- faceNameCombo.setData (new Integer (faceNameCombo.indexOf (faceName)));
-
- initExtStyleCombo ();
- extStyleCombo.setText (fontData.addStyle);
- extStyleCombo.setData (new Integer (extStyleCombo.indexOf (fontData.addStyle)));
-
- initSizeCombo ();
- String value = String.valueOf (fontData.getHeight ());
- fontSizeCombo.setText (value);
- fontSizeCombo.setData (new Integer (fontSizeCombo.indexOf (value)));
-
- initStyleCombo ();
- fontStyleCombo.setText (fontData.weight);
- fontStyleCombo.setData (new Integer (fontStyleCombo.indexOf (fontData.weight)));
-}
-
-/**
- * Sets a FontData object describing the font to be
- * selected by default in the dialog, or null to let
- * the platform choose one.
- *
- * @param fontData the FontData to use initially, or null
+public void setFontData (FontData fontData) {
+ this.fontData = fontData;
+}
+
+/**
+ * Returns the receiver's selected color to be the argument.
+ *
+ * @param rgb the new RGB value for the selected color, may be
+ * null to let the platform to select a default when
+ * open() is called
+ *
+ * @see PaletteData#getRGBs
*/
-public void setFontData (FontData fontData) {
- this.fontData = fontData;
-}
-
-/**
- * Returns the receiver's selected color to be the argument.
- *
- * @param rgb the new RGB value for the selected color, may be
- * null to let the platform to select a default when
- * open() is called
- *
- * @see PaletteData#getRGBs
- */
-public void setRGB (RGB rgb) {
- this.rgb = rgb;
-}
-
-/**
- * Set the contents of 'combo' to the keys of 'items'.
- * Keys are sorted in ascending order first and have to be Strings.
+public void setRGB (RGB rgb) {
+ this.rgb = rgb;
+}
+
+/**
+ * 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) {
- if (items == null) return;
- Enumeration itemKeys = items.keys ();
- String [] sortedItems = new String[items.size ()];
- int index = 0;
- while (itemKeys.hasMoreElements ()) {
- String item = (String) itemKeys.nextElement ();
- if (item.length () != 0) sortedItems[index++] = item;
- }
- if (index != sortedItems.length) {
- String [] newItems = new String[index];
- System.arraycopy (sortedItems, 0, newItems, 0, index);
- sortedItems = newItems;
- }
- sort (sortedItems);
- combo.setItems (sortedItems);
-}
-
-/**
- * Set the contents of the size combo to the keys of 'items'.
- * Keys are sorted in ascending order first and have to be Integers.
+void setItemsSorted (Combo combo, Hashtable items) {
+ if (items == null) return;
+ Enumeration itemKeys = items.keys ();
+ String [] sortedItems = new String[items.size ()];
+ int index = 0;
+ while (itemKeys.hasMoreElements ()) {
+ String item = (String) itemKeys.nextElement ();
+ if (item.length () != 0) sortedItems[index++] = item;
+ }
+ if (index != sortedItems.length) {
+ String [] newItems = new String[index];
+ System.arraycopy (sortedItems, 0, newItems, 0, index);
+ sortedItems = newItems;
+ }
+ sort (sortedItems);
+ combo.setItems (sortedItems);
+}
+
+/**
+ * Set the contents of the size combo to the keys of 'items'.
+ * Keys are sorted in ascending order first and have to be Integers.
*/
-void setSizeItemsSorted (Enumeration itemsEnum) {
- Vector items = new Vector ();
- while (itemsEnum.hasMoreElements ()) {
- items.addElement (itemsEnum.nextElement ());
- }
- Integer[] sortedItems = new Integer [items.size ()];
- items.copyInto (sortedItems);
- sort (sortedItems);
- String[] sortedItemStrings = new String [items.size ()];
- for (int i = 0; i < sortedItemStrings.length; i++) {
- sortedItemStrings [i] = String.valueOf (sortedItems [i].intValue ());
- }
- fontSizeCombo.setItems (sortedItemStrings);
-}
-
-/**
- * Sort 'items' in ascending order.
+void setSizeItemsSorted (Enumeration itemsEnum) {
+ Vector items = new Vector ();
+ while (itemsEnum.hasMoreElements ()) {
+ items.addElement (itemsEnum.nextElement ());
+ }
+ Integer[] sortedItems = new Integer [items.size ()];
+ items.copyInto (sortedItems);
+ sort (sortedItems);
+ String[] sortedItemStrings = new String [items.size ()];
+ for (int i = 0; i < sortedItemStrings.length; i++) {
+ sortedItemStrings [i] = String.valueOf (sortedItems [i].intValue ());
+ }
+ fontSizeCombo.setItems (sortedItemStrings);
+}
+
+/**
+ * Sort 'items' in ascending order.
*/
-void sort (Integer[] 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].intValue () > items [j + gap].intValue ()) {
- Integer swap = items [j];
- items[j] = items [j + gap];
- items[j + gap] = swap;
- }
- }
- }
- }
-}
-
-/**
- * Sort 'items' in ascending order.
+void sort (Integer[] 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].intValue () > items [j + gap].intValue ()) {
+ Integer swap = items [j];
+ items[j] = items [j + gap];
+ items[j + gap] = swap;
+ }
+ }
+ }
+ }
+}
+
+/**
+ * Sort 'items' in ascending order.
*/
-void sort (String 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].compareTo (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 sort (String 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].compareTo (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 updateSampleFont () {
- FontData selectionFontData = getSelectionFontData ();
- /*
- * sampleFont may not be the same as the one specified in selectionFontData.
- * This happens when selectionFontData specifies a font alias.
- */
- if (sampleFont != null) sampleFont.dispose ();
- sampleFont = new Font (shell.getDisplay (), selectionFontData);
- fontData = selectionFontData;
- sampleLabel.setFont (sampleFont);
-}
-
-void updateSampleColor() {
- if (rgb == null) {
- rgb = new RGB(0, 0, 0);
- }
- if (sampleColor != null) {
- if (sampleColor.getRGB ().equals (rgb)) return;
- sampleColor.dispose();
- }
- sampleColor = new Color (getParent ().getDisplay (), rgb);
- sampleLabel.setForeground (sampleColor);
-}
+void updateSampleFont () {
+ FontData selectionFontData = getSelectionFontData ();
+ /*
+ * sampleFont may not be the same as the one specified in selectionFontData.
+ * This happens when selectionFontData specifies a font alias.
+ */
+ if (sampleFont != null) sampleFont.dispose ();
+ sampleFont = new Font (shell.getDisplay (), selectionFontData);
+ fontData = selectionFontData;
+ sampleLabel.setFont (sampleFont);
+}
+
+void updateSampleColor() {
+ if (rgb == null) {
+ rgb = new RGB(0, 0, 0);
+ }
+ if (sampleColor != null) {
+ if (sampleColor.getRGB ().equals (rgb)) return;
+ sampleColor.dispose();
+ }
+ sampleColor = new Color (getParent ().getDisplay (), rgb);
+ sampleLabel.setForeground (sampleColor);
+}
} \ No newline at end of file
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
index 5f11b7872e..61eaa1672a 100755
--- 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
@@ -1,40 +1,40 @@
-package org.eclipse.swt.widgets;
-
-/*
+package org.eclipse.swt.widgets;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-import org.eclipse.swt.internal.*;
-import org.eclipse.swt.internal.motif.*;
-import org.eclipse.swt.graphics.*;
-import org.eclipse.swt.*;
-
-/**
- * Instances of this class provide an etched border
- * with an optional title.
- * <p>
- * Shadow styles are hints and may not be honoured
- * by the platform. To create a group with the
- * default shadow style for the platform, do not
- * specify a shadow style.
- * <dl>
- * <dt><b>Styles:</b></dt>
- * <dd>SHADOW_ETCHED_IN, SHADOW_ETCHED_OUT, SHADOW_IN, SHADOW_OUT, SHADOW_NONE</dd>
- * <dt><b>Events:</b></dt>
- * <dd>(none)</dd>
- * </dl>
- * <p>
- * Note: Only one of the above styles may be specified.
- * </p><p>
- * IMPORTANT: This class is <em>not</em> intended to be subclassed.
- * </p>
+ * http://www.eclipse.org/legal/cpl-v10.html
*/
-public class Group extends Composite {
- int labelHandle;
-
+
+import org.eclipse.swt.internal.*;
+import org.eclipse.swt.internal.motif.*;
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.*;
+
+/**
+ * Instances of this class provide an etched border
+ * with an optional title.
+ * <p>
+ * Shadow styles are hints and may not be honoured
+ * by the platform. To create a group with the
+ * default shadow style for the platform, do not
+ * specify a shadow style.
+ * <dl>
+ * <dt><b>Styles:</b></dt>
+ * <dd>SHADOW_ETCHED_IN, SHADOW_ETCHED_OUT, SHADOW_IN, SHADOW_OUT, SHADOW_NONE</dd>
+ * <dt><b>Events:</b></dt>
+ * <dd>(none)</dd>
+ * </dl>
+ * <p>
+ * Note: Only one of the above styles may be specified.
+ * </p><p>
+ * IMPORTANT: This class is <em>not</em> intended to be subclassed.
+ * </p>
+ */
+public class Group extends Composite {
+ int labelHandle;
+
/**
* Constructs a new instance of this class given its parent
* and a style value describing its behavior and appearance.
@@ -67,242 +67,242 @@ public class Group extends Composite {
* @see Widget#checkSubclass
* @see Widget#getStyle
*/
-public Group (Composite parent, int style) {
- super (parent, checkStyle (style));
-}
-static int checkStyle (int style) {
- style |= SWT.NO_FOCUS;
- /*
- * Even though it is legal to create this widget
- * with scroll bars, they serve no useful purpose
- * because they do not automatically scroll the
- * widget's client area. The fix is to clear
- * the SWT style.
- */
- return style & ~(SWT.H_SCROLL | SWT.V_SCROLL);
-}
-protected void checkSubclass () {
- if (!isValidSubclass ()) error (SWT.ERROR_INVALID_SUBCLASS);
-}
-public Rectangle computeTrim (int x, int y, int width, int height) {
- checkWidget();
- int trimX, trimY, trimWidth, trimHeight;
- int [] argList = {
- OS.XmNshadowThickness, 0,
- OS.XmNmarginWidth, 0,
- OS.XmNmarginHeight, 0
- };
- OS.XtGetValues (handle, argList, argList.length / 2);
- int thickness = argList [1];
- int marginWidth = argList [3];
- int marginHeight = argList [5];
- int borderWidth = getBorderWidth ();
- trimX = x - marginWidth + thickness - borderWidth;
- trimY = y - marginHeight + thickness - borderWidth;
- trimWidth = width + ((marginWidth + thickness + borderWidth) * 2);
- trimHeight = height + ((marginHeight + thickness + borderWidth) * 2);
- if (OS.XtIsManaged (labelHandle)) {
- int [] argList2 = {OS.XmNy, 0, OS.XmNheight, 0, OS.XmNchildHorizontalSpacing, 0};
- OS.XtGetValues (labelHandle, argList2, argList2.length / 2);
- int titleHeight = ((short) argList2 [1]) + argList2 [3];
- trimY = y - titleHeight;
- trimHeight = height + titleHeight + (marginHeight + thickness + borderWidth);
- XtWidgetGeometry result = new XtWidgetGeometry ();
- OS.XtQueryGeometry (labelHandle, null, result);
- int titleWidth = result.width + 2 * (argList2 [5] + marginWidth + thickness + borderWidth);
- trimWidth = Math.max (trimWidth, titleWidth);
- }
- 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.XmNancestorSensitive, 1,
- OS.XmNborderWidth, border,
- };
- int parentHandle = parent.handle;
- formHandle = OS.XmCreateForm (parentHandle, 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.XmNframeChildType, 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;
-}
-public Rectangle getClientArea () {
- checkWidget();
- 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);
-}
-/**
- * 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 Group (Composite parent, int style) {
+ super (parent, checkStyle (style));
+}
+static int checkStyle (int style) {
+ style |= SWT.NO_FOCUS;
+ /*
+ * Even though it is legal to create this widget
+ * with scroll bars, they serve no useful purpose
+ * because they do not automatically scroll the
+ * widget's client area. The fix is to clear
+ * the SWT style.
+ */
+ return style & ~(SWT.H_SCROLL | SWT.V_SCROLL);
+}
+protected void checkSubclass () {
+ if (!isValidSubclass ()) error (SWT.ERROR_INVALID_SUBCLASS);
+}
+public Rectangle computeTrim (int x, int y, int width, int height) {
+ checkWidget();
+ int trimX, trimY, trimWidth, trimHeight;
+ int [] argList = {
+ OS.XmNshadowThickness, 0,
+ OS.XmNmarginWidth, 0,
+ OS.XmNmarginHeight, 0
+ };
+ OS.XtGetValues (handle, argList, argList.length / 2);
+ int thickness = argList [1];
+ int marginWidth = argList [3];
+ int marginHeight = argList [5];
+ int borderWidth = getBorderWidth ();
+ trimX = x - marginWidth + thickness - borderWidth;
+ trimY = y - marginHeight + thickness - borderWidth;
+ trimWidth = width + ((marginWidth + thickness + borderWidth) * 2);
+ trimHeight = height + ((marginHeight + thickness + borderWidth) * 2);
+ if (OS.XtIsManaged (labelHandle)) {
+ int [] argList2 = {OS.XmNy, 0, OS.XmNheight, 0, OS.XmNchildHorizontalSpacing, 0};
+ OS.XtGetValues (labelHandle, argList2, argList2.length / 2);
+ int titleHeight = ((short) argList2 [1]) + argList2 [3];
+ trimY = y - titleHeight;
+ trimHeight = height + titleHeight + (marginHeight + thickness + borderWidth);
+ XtWidgetGeometry result = new XtWidgetGeometry ();
+ OS.XtQueryGeometry (labelHandle, null, result);
+ int titleWidth = result.width + 2 * (argList2 [5] + marginWidth + thickness + borderWidth);
+ trimWidth = Math.max (trimWidth, titleWidth);
+ }
+ 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.XmNancestorSensitive, 1,
+ OS.XmNborderWidth, border,
+ };
+ int parentHandle = parent.handle;
+ formHandle = OS.XmCreateForm (parentHandle, 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.XmNframeChildType, 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;
+}
+public Rectangle getClientArea () {
+ checkWidget();
+ 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);
+}
+/**
+ * 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 [] 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 (getCodePage (), buffer));
-}
-boolean mnemonicHit (char key) {
- 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 receiver's text, which is the string that will
- * be displayed as the receiver's <em>title</em>, to the argument,
- * which may not be null.
- *
- * @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 String getText () {
+ checkWidget();
+ 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 (getCodePage (), buffer));
+}
+boolean mnemonicHit (char key) {
+ 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 receiver's text, which is the string that will
+ * be displayed as the receiver's <em>title</em>, to the argument,
+ * which may not be null.
+ *
+ * @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);
- 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 (getCodePage (), 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);
- if (mnemonic == 0) mnemonic = OS.XK_VoidSymbol;
- int [] argList = {
- OS.XmNlabelType, OS.XmSTRING,
- OS.XmNlabelString, xmString,
- OS.XmNmnemonic, mnemonic,
- };
- OS.XtSetValues (labelHandle, argList, argList.length / 2);
- if (xmString != 0) 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;
-}
-}
+public void setText (String string) {
+ checkWidget();
+ if (string == null) error (SWT.ERROR_NULL_ARGUMENT);
+ 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 (getCodePage (), 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);
+ if (mnemonic == 0) mnemonic = OS.XK_VoidSymbol;
+ int [] argList = {
+ OS.XmNlabelType, OS.XmSTRING,
+ OS.XmNlabelString, xmString,
+ OS.XmNmnemonic, mnemonic,
+ };
+ OS.XtSetValues (labelHandle, argList, argList.length / 2);
+ if (xmString != 0) 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/Label.java b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Label.java
index 69a29cf108..a9628ee464 100755
--- 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
@@ -1,18 +1,18 @@
-package org.eclipse.swt.widgets;
-
-/*
+package org.eclipse.swt.widgets;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-import org.eclipse.swt.internal.*;
-import org.eclipse.swt.internal.motif.*;
-
-import org.eclipse.swt.*;
-import org.eclipse.swt.graphics.*;
-
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+import org.eclipse.swt.internal.*;
+import org.eclipse.swt.internal.motif.*;
+
+import org.eclipse.swt.*;
+import org.eclipse.swt.graphics.*;
+
/**
* Instances of this class represent a non-selectable
* user interface object that displays a string or image.
@@ -35,10 +35,10 @@ import org.eclipse.swt.graphics.*;
* within the SWT implementation.
* </p>
*/
-public class Label extends Control {
- String text = "";
- Image image, bitmap, disabled;
-
+public class Label extends Control {
+ String text = "";
+ Image image, bitmap, disabled;
+
/**
* Constructs a new instance of this class given its parent
* and a style value describing its behavior and appearance.
@@ -76,402 +76,402 @@ public class Label extends Control {
* @see Widget#checkSubclass
* @see Widget#getStyle
*/
-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) {
- checkWidget();
- 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);
- }
- int [] argList = {OS.XmNlabelType, 0};
- OS.XtGetValues (handle, argList, argList.length / 2);
- int labelType = argList [1];
- if (labelType == OS.XmSTRING && (style & SWT.WRAP) != 0 && wHint != SWT.DEFAULT) {
- /* If we are wrapping text, calculate the height based on wHint. */
- int [] argList4 = {
- OS.XmNmarginTop, 0, /* 1 */
- OS.XmNmarginBottom, 0, /* 3 */
- OS.XmNmarginHeight, 0, /* 5 */
- OS.XmNmarginWidth, 0, /* 7 */
- };
- OS.XtGetValues (handle, argList4, argList4.length / 2);
- int unavailable = 2 * (argList4 [7] + getBorderWidth());
- Display display = getDisplay ();
- String string = display.wrapText (text, font, wHint - unavailable);
- GC gc = new GC(this);
- Point extent = gc.textExtent(string);
- gc.dispose();
- height = extent.y + argList4 [1] + argList4 [3] + argList4 [5] * 2 + border * 2;
- } else {
- /* If we are not wrapping, ask the widget for its geometry. */
- 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 label'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.
- */
- if (labelType == OS.XmSTRING && text.length () == 0) {
- 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 parentHandle = parent.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.XmNancestorSensitive, 1,
- OS.XmNborderWidth, borderWidth,
- OS.XmNorientation, orientation,
- OS.XmNseparatorType, separatorType,
- };
- handle = OS.XmCreateSeparator (parentHandle, 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.XmNancestorSensitive, 1,
- OS.XmNrecomputeSize, 0,
- OS.XmNalignment, alignment,
- OS.XmNborderWidth, borderWidth,
- };
- handle = OS.XmCreateLabel (parentHandle, null, argList, argList.length / 2);
- if (handle == 0) error (SWT.ERROR_NO_HANDLES);
-}
-int defaultBackground () {
- return getDisplay ().labelBackground;
-}
-Font defaultFont () {
- return getDisplay ().labelFont;
-}
-int defaultForeground () {
- return getDisplay ().labelForeground;
-}
-public boolean forceFocus () {
- checkWidget();
- int [] argList = new int [] {OS.XmNtraversalOn, 1};
- OS.XtSetValues (handle, argList, argList.length / 2);
- overrideTranslations ();
- if (super.forceFocus ()) return true;
- argList [1] = 0;
- OS.XtSetValues (handle, argList, argList.length / 2);
- return false;
-}
-/**
- * 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 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) {
+ checkWidget();
+ 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);
+ }
+ int [] argList = {OS.XmNlabelType, 0};
+ OS.XtGetValues (handle, argList, argList.length / 2);
+ int labelType = argList [1];
+ if (labelType == OS.XmSTRING && (style & SWT.WRAP) != 0 && wHint != SWT.DEFAULT) {
+ /* If we are wrapping text, calculate the height based on wHint. */
+ int [] argList4 = {
+ OS.XmNmarginTop, 0, /* 1 */
+ OS.XmNmarginBottom, 0, /* 3 */
+ OS.XmNmarginHeight, 0, /* 5 */
+ OS.XmNmarginWidth, 0, /* 7 */
+ };
+ OS.XtGetValues (handle, argList4, argList4.length / 2);
+ int unavailable = 2 * (argList4 [7] + getBorderWidth());
+ Display display = getDisplay ();
+ String string = display.wrapText (text, font, wHint - unavailable);
+ GC gc = new GC(this);
+ Point extent = gc.textExtent(string);
+ gc.dispose();
+ height = extent.y + argList4 [1] + argList4 [3] + argList4 [5] * 2 + border * 2;
+ } else {
+ /* If we are not wrapping, ask the widget for its geometry. */
+ 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 label'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.
+ */
+ if (labelType == OS.XmSTRING && text.length () == 0) {
+ 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 parentHandle = parent.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.XmNancestorSensitive, 1,
+ OS.XmNborderWidth, borderWidth,
+ OS.XmNorientation, orientation,
+ OS.XmNseparatorType, separatorType,
+ };
+ handle = OS.XmCreateSeparator (parentHandle, 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.XmNancestorSensitive, 1,
+ OS.XmNrecomputeSize, 0,
+ OS.XmNalignment, alignment,
+ OS.XmNborderWidth, borderWidth,
+ };
+ handle = OS.XmCreateLabel (parentHandle, null, argList, argList.length / 2);
+ if (handle == 0) error (SWT.ERROR_NO_HANDLES);
+}
+int defaultBackground () {
+ return getDisplay ().labelBackground;
+}
+Font defaultFont () {
+ return getDisplay ().labelFont;
+}
+int defaultForeground () {
+ return getDisplay ().labelForeground;
+}
+public boolean forceFocus () {
+ checkWidget();
+ int [] argList = new int [] {OS.XmNtraversalOn, 1};
+ OS.XtSetValues (handle, argList, argList.length / 2);
+ overrideTranslations ();
+ if (super.forceFocus ()) return true;
+ argList [1] = 0;
+ OS.XtSetValues (handle, argList, argList.length / 2);
+ return false;
+}
+/**
+ * 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 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;
-}
-/**
- * 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 int getAlignment () {
+ checkWidget();
+ 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;
+}
+/**
+ * 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 Image getImage () {
+ checkWidget();
+ return image;
+}
+String getNameText () {
+ return getText ();
+}
+/**
+ * Returns the receiver's text, which will be an empty
+ * string if it has never been set or if the receiver is
+ * a <code>SEPARATOR</code> label.
+ *
+ * @return the receiver's text
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
*/
-public String getText () {
- checkWidget();
- if ((style & SWT.SEPARATOR) != 0) return "";
- return text;
-}
-boolean mnemonicHit (char key) {
- 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 ();
- 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;
-}
-/**
- * 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 String getText () {
+ checkWidget();
+ if ((style & SWT.SEPARATOR) != 0) return "";
+ return text;
+}
+boolean mnemonicHit (char key) {
+ 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 ();
+ 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;
+}
+/**
+ * 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;
- 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) {
- if (image.isDisposed()) error(SWT.ERROR_INVALID_ARGUMENT);
- 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);
-}
-boolean setBounds (int x, int y, int width, int height, boolean move, boolean resize) {
- boolean changed = super.setBounds (x, y, width, height, move, resize);
- if (changed && resize && (style & SWT.WRAP) != 0) setText (text);
- return changed;
-}
-public void setFont (Font font) {
- super.setFont (font);
- if ((style & SWT.WRAP) != 0) setText (text);
-}
-/**
- * Sets the receiver's image to the argument, which may be
- * null indicating that no image should be displayed.
- *
- * @param image the image to display on the receiver (may be null)
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_INVALID_ARGUMENT - if the image has been disposed</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
+public void setAlignment (int alignment) {
+ checkWidget();
+ 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) {
+ if (image.isDisposed()) error(SWT.ERROR_INVALID_ARGUMENT);
+ 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);
+}
+boolean setBounds (int x, int y, int width, int height, boolean move, boolean resize) {
+ boolean changed = super.setBounds (x, y, width, height, move, resize);
+ if (changed && resize && (style & SWT.WRAP) != 0) setText (text);
+ return changed;
+}
+public void setFont (Font font) {
+ super.setFont (font);
+ if ((style & SWT.WRAP) != 0) setText (text);
+}
+/**
+ * Sets the receiver's image to the argument, which may be
+ * null indicating that no image should be displayed.
+ *
+ * @param image the image to display on the receiver (may be null)
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_INVALID_ARGUMENT - if the image has been disposed</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
*/
-public void setImage (Image image) {
- checkWidget();
- if ((style & SWT.SEPARATOR) != 0) return;
- setBitmap (this.image = image);
-}
-/**
- * Sets the receiver's text.
- * <p>
- * This method sets the widget label. The label may include
- * the mnemonic characters and line delimiters.
- * </p>
- *
- * @param string the new text
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the text is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
+public void setImage (Image image) {
+ checkWidget();
+ if ((style & SWT.SEPARATOR) != 0) return;
+ setBitmap (this.image = image);
+}
+/**
+ * Sets the receiver's text.
+ * <p>
+ * This method sets the widget label. The label may include
+ * the mnemonic characters and line delimiters.
+ * </p>
+ *
+ * @param string the new text
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if the text is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
*/
-public void setText (String string) {
- checkWidget();
- if (string == null) error (SWT.ERROR_NULL_ARGUMENT);
- if ((style & SWT.SEPARATOR) != 0) return;
- text = string;
-
- /* Strip out mnemonic marker symbols, and remember the mnemonic. */
- char [] unicode = new char [string.length ()];
- string.getChars (0, unicode.length, unicode, 0);
- int i=0, j=0, mnemonic=0;
- while (i < unicode.length) {
- if ((unicode [j++] = unicode [i++]) == Mnemonic) {
- if (i == unicode.length) {continue;}
- if (unicode [i] == Mnemonic) {i++; continue;}
- if (mnemonic == 0) mnemonic = unicode [i];
- j--;
- }
- }
- while (j < unicode.length) unicode [j++] = 0;
-
- /* Wrap the text if necessary, and convert to mbcs. */
- byte [] buffer;
- if ((style & SWT.WRAP) != 0) {
- int [] argList = {
- OS.XmNwidth, 0, /* 1 */
- OS.XmNmarginLeft, 0, /* 3 */
- OS.XmNmarginRight, 0, /* 5 */
- OS.XmNborderWidth, 0, /* 7 */
- OS.XmNmarginWidth, 0, /* 9 */
- };
- OS.XtGetValues (handle, argList, argList.length / 2);
- int width = argList [1] - argList [3] - argList [5] - argList [7] * 2 - argList [9] * 2;
- Display display = getDisplay ();
- if (mnemonic != 0) string = new String (unicode);
- string = display.wrapText (string, font, width);
- buffer = Converter.wcsToMbcs (getCodePage (), string, true);
- } else {
- buffer = Converter.wcsToMbcs (getCodePage (), unicode, true);
- }
-
- int xmString = OS.XmStringGenerate(buffer, null, OS.XmCHARSET_TEXT, null);
- if (xmString == 0) error (SWT.ERROR_CANNOT_SET_TEXT);
-
- /*
- * Bug in Solaris. If a mnemonic is defined to be a character
- * that appears in a string in a position that follows a '\n',
- * Solaris segment faults. For example, a label with text
- * "Hello\nthe&re" would GP since "r" appears after '\n'.
- *
- * The fix is to remove mnemonics from labels that contain
- * '\n', which is fine since such labels generally just act
- * as descriptive texts anyways.
- */
- if (mnemonic == 0 || string.indexOf ('\n') != -1) {
- mnemonic = OS.XK_VoidSymbol;
- }
- 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);
-}
-int xFocusOut () {
- int result = super.xFocusOut ();
- if (handle == 0) return result;
- int [] argList = new int [] {OS.XmNtraversalOn, 0};
- OS.XtGetValues (handle, argList, argList.length / 2);
- if (argList [1] != 0) {
- argList [1] = 0;
- OS.XtSetValues (handle, argList, argList.length / 2);
- }
- return result;
-}
-}
+public void setText (String string) {
+ checkWidget();
+ if (string == null) error (SWT.ERROR_NULL_ARGUMENT);
+ if ((style & SWT.SEPARATOR) != 0) return;
+ text = string;
+
+ /* Strip out mnemonic marker symbols, and remember the mnemonic. */
+ char [] unicode = new char [string.length ()];
+ string.getChars (0, unicode.length, unicode, 0);
+ int i=0, j=0, mnemonic=0;
+ while (i < unicode.length) {
+ if ((unicode [j++] = unicode [i++]) == Mnemonic) {
+ if (i == unicode.length) {continue;}
+ if (unicode [i] == Mnemonic) {i++; continue;}
+ if (mnemonic == 0) mnemonic = unicode [i];
+ j--;
+ }
+ }
+ while (j < unicode.length) unicode [j++] = 0;
+
+ /* Wrap the text if necessary, and convert to mbcs. */
+ byte [] buffer;
+ if ((style & SWT.WRAP) != 0) {
+ int [] argList = {
+ OS.XmNwidth, 0, /* 1 */
+ OS.XmNmarginLeft, 0, /* 3 */
+ OS.XmNmarginRight, 0, /* 5 */
+ OS.XmNborderWidth, 0, /* 7 */
+ OS.XmNmarginWidth, 0, /* 9 */
+ };
+ OS.XtGetValues (handle, argList, argList.length / 2);
+ int width = argList [1] - argList [3] - argList [5] - argList [7] * 2 - argList [9] * 2;
+ Display display = getDisplay ();
+ if (mnemonic != 0) string = new String (unicode);
+ string = display.wrapText (string, font, width);
+ buffer = Converter.wcsToMbcs (getCodePage (), string, true);
+ } else {
+ buffer = Converter.wcsToMbcs (getCodePage (), unicode, true);
+ }
+
+ int xmString = OS.XmStringGenerate(buffer, null, OS.XmCHARSET_TEXT, null);
+ if (xmString == 0) error (SWT.ERROR_CANNOT_SET_TEXT);
+
+ /*
+ * Bug in Solaris. If a mnemonic is defined to be a character
+ * that appears in a string in a position that follows a '\n',
+ * Solaris segment faults. For example, a label with text
+ * "Hello\nthe&re" would GP since "r" appears after '\n'.
+ *
+ * The fix is to remove mnemonics from labels that contain
+ * '\n', which is fine since such labels generally just act
+ * as descriptive texts anyways.
+ */
+ if (mnemonic == 0 || string.indexOf ('\n') != -1) {
+ mnemonic = OS.XK_VoidSymbol;
+ }
+ 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);
+}
+int xFocusOut () {
+ int result = super.xFocusOut ();
+ if (handle == 0) return result;
+ int [] argList = new int [] {OS.XmNtraversalOn, 0};
+ OS.XtGetValues (handle, argList, argList.length / 2);
+ if (argList [1] != 0) {
+ argList [1] = 0;
+ OS.XtSetValues (handle, argList, argList.length / 2);
+ }
+ return result;
+}
+}
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
index 628edf905a..c7a8f56b54 100755
--- 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
@@ -1,37 +1,37 @@
-package org.eclipse.swt.widgets;
-
-/*
+package org.eclipse.swt.widgets;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-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.*;
-
-
-/**
- * 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>
- * Note: Only one of SINGLE and MULTI may be specified.
- * </p><p>
- * IMPORTANT: This class is <em>not</em> intended to be subclassed.
- * </p>
+ * http://www.eclipse.org/legal/cpl-v10.html
*/
-public class List extends Scrollable {
+
+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.*;
+
+
+/**
+ * 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>
+ * Note: Only one of SINGLE and MULTI may be specified.
+ * </p><p>
+ * IMPORTANT: This class is <em>not</em> intended to be subclassed.
+ * </p>
+ */
+public class List extends Scrollable {
/**
* Constructs a new instance of this class given its parent
* and a style value describing its behavior and appearance.
@@ -61,1296 +61,1296 @@ public class List extends Scrollable {
* @see Widget#checkSubclass
* @see Widget#getStyle
*/
-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.
+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 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)
+ super (parent, checkStyle (style | SWT.V_SCROLL));
+}
+/**
+ * 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 (getCodePage (), 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 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) {
+ checkWidget();
+ if (string == null) error (SWT.ERROR_NULL_ARGUMENT);
+ byte [] buffer = Converter.wcsToMbcs (getCodePage (), 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 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);
- /*
- * 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 (getCodePage (), 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 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.
- * <p>
- * <code>widgetSelected</code> is called when the selection changes.
- * <code>widgetDefaultSelected</code> is typically called when an item is double-clicked.
- * </p>
- *
- * @param listener the listener which should be notified
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see SelectionListener
- * @see #removeSelectionListener
- * @see SelectionEvent
+public void add (String string, int index) {
+ checkWidget();
+ 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 (getCodePage (), 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 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.
+ * <p>
+ * <code>widgetSelected</code> is called when the selection changes.
+ * <code>widgetDefaultSelected</code> is typically called when an item is double-clicked.
+ * </p>
+ *
+ * @param listener the listener which should be notified
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see SelectionListener
+ * @see #removeSelectionListener
+ * @see SelectionEvent
*/
-public void addSelectionListener(SelectionListener listener) {
- checkWidget();
- if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
- TypedListener typedListener = new TypedListener(listener);
- addListener(SWT.Selection,typedListener);
- addListener(SWT.DefaultSelection,typedListener);
-}
-static int checkStyle (int style) {
- return checkBits (style, SWT.SINGLE, SWT.MULTI, 0, 0, 0, 0);
-}
-public Point computeSize (int wHint, int hHint, boolean changed) {
- checkWidget();
- 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 [] argList = {OS.XmNitemCount, 0};
- OS.XtGetValues (handle, argList, argList.length / 2);
- int 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);
-}
-public Rectangle computeTrim (int x, int y, int width, int height) {
- checkWidget();
- 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.
+public void addSelectionListener(SelectionListener listener) {
+ checkWidget();
+ if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+ TypedListener typedListener = new TypedListener(listener);
+ addListener(SWT.Selection,typedListener);
+ addListener(SWT.DefaultSelection,typedListener);
+}
+static int checkStyle (int style) {
+ return checkBits (style, SWT.SINGLE, SWT.MULTI, 0, 0, 0, 0);
+}
+public Point computeSize (int wHint, int hHint, boolean changed) {
+ checkWidget();
+ 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 [] argList = {OS.XmNitemCount, 0};
+ OS.XtGetValues (handle, argList, argList.length / 2);
+ int 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);
+}
+public Rectangle computeTrim (int x, int y, int width, int height) {
+ checkWidget();
+ 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.
- */
- int parentHandle = parent.handle;
- int [] argList1 = {OS.XmNancestorSensitive, 1};
- formHandle = OS.XmCreateForm (parentHandle, null, argList1, argList1.length / 2);
- 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 [] argList2 = {
- 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, argList2, argList2.length / 2);
- if (handle == 0) error (SWT.ERROR_NO_HANDLES);
- } else {
- handle = OS.XmCreateScrolledList (formHandle, new byte [0], argList2, argList2.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;
-}
-Font defaultFont () {
- return getDisplay ().listFont;
-}
-int defaultForeground () {
- return getDisplay ().listForeground;
-}
-/**
- * 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>
+ 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.
+ */
+ int parentHandle = parent.handle;
+ int [] argList1 = {OS.XmNancestorSensitive, 1};
+ formHandle = OS.XmCreateForm (parentHandle, null, argList1, argList1.length / 2);
+ 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 [] argList2 = {
+ 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, argList2, argList2.length / 2);
+ if (handle == 0) error (SWT.ERROR_NO_HANDLES);
+ } else {
+ handle = OS.XmCreateScrolledList (formHandle, new byte [0], argList2, argList2.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;
+}
+Font defaultFont () {
+ return getDisplay ().listFont;
+}
+int defaultForeground () {
+ return getDisplay ().listForeground;
+}
+/**
+ * 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();
- /*
- * 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 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 index) {
+ checkWidget();
+ /*
+ * 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 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;
- /*
- * 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 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 start, int end) {
+ checkWidget();
+ 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 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);
- /*
- * 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 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 deselect (int [] indices) {
+ checkWidget();
+ 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 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();
- OS.XmListDeselectAllItems (handle);
-}
-/**
- * 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 void deselectAll () {
+ checkWidget();
+ OS.XmListDeselectAllItems (handle);
+}
+/**
+ * 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.XmListGetKbdItemPos (handle) - 1;
-}
-/**
- * Returns the item at the given, zero-relative index in the
- * receiver. Throws an exception if the index is out of range.
- *
- * @param index the index of the item to return
- * @return the item at the given index
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_INVALID_RANGE - if the index is not between 0 and the number of elements in the list minus 1 (inclusive)</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- * @exception SWTError <ul>
- * <li>ERROR_CANNOT_GET_ITEM - if the operation fails because of an operating system failure</li>
- * </ul>
+public int getFocusIndex () {
+ checkWidget();
+ return OS.XmListGetKbdItemPos (handle) - 1;
+}
+/**
+ * Returns the item at the given, zero-relative index in the
+ * receiver. Throws an exception if the index is out of range.
+ *
+ * @param index the index of the item to return
+ * @return the item at the given index
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_INVALID_RANGE - if the index is not between 0 and the number of elements in the list minus 1 (inclusive)</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * @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 [] 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 (getCodePage (), buffer));
-}
-/**
- * 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 String getItem (int index) {
+ checkWidget();
+ 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 (getCodePage (), buffer));
+}
+/**
+ * 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();
- int [] argList = {OS.XmNitemCount, 0};
- OS.XtGetValues (handle, argList, argList.length / 2);
- return argList [1];
-}
-/**
- * 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>
- * @exception SWTError <ul>
- * <li>ERROR_CANNOT_GET_ITEM_HEIGHT - if the operation fails because of an operating system failure</li>
- * </ul>
+public int getItemCount () {
+ checkWidget();
+ int [] argList = {OS.XmNitemCount, 0};
+ OS.XtGetValues (handle, argList, argList.length / 2);
+ return argList [1];
+}
+/**
+ * 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>
+ * @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 [] 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;
-}
-/**
- * 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 affect the receiver.
- * </p>
- *
- * @return the items in the receiver's list
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- * @exception SWTError <ul>
- * <li>ERROR_CANNOT_GET_ITEM - if the operation fails because of an operating system failure while getting an item</li>
- * <li>ERROR_CANNOT_GET_COUNT - if the operation fails because of an operating system failure while getting the item count</li>
- * </ul>
+public int getItemHeight () {
+ checkWidget();
+ 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;
+}
+/**
+ * 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 affect the receiver.
+ * </p>
+ *
+ * @return the items in the receiver's list
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * @exception SWTError <ul>
+ * <li>ERROR_CANNOT_GET_ITEM - if the operation fails because of an operating system failure while getting an item</li>
+ * <li>ERROR_CANNOT_GET_COUNT - if the operation fails because of an operating system failure while getting the item count</li>
+ * </ul>
*/
-public String [] getItems () {
- checkWidget();
- 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];
- String codePage = getCodePage ();
- 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 (codePage, buffer));
- items += 4;
- }
- 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 affect the receiver.
- * </p>
- * @return an array representing the selection
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- * @exception SWTError <ul>
- * <li>ERROR_CANNOT_GET_SELECTION - if the operation fails because of an operating system failure while getting the selection</li>
- * <li>ERROR_CANNOT_GET_ITEM - if the operation fails because of an operating system failure while getting an item</li>
- * </ul>
+public String [] getItems () {
+ checkWidget();
+ 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];
+ String codePage = getCodePage ();
+ 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 (codePage, buffer));
+ items += 4;
+ }
+ 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 affect the receiver.
+ * </p>
+ * @return an array representing the selection
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * @exception SWTError <ul>
+ * <li>ERROR_CANNOT_GET_SELECTION - if the operation fails because of an operating system failure while getting the selection</li>
+ * <li>ERROR_CANNOT_GET_ITEM - if the operation fails because of an operating system failure while getting an item</li>
+ * </ul>
*/
-public String [] getSelection () {
- checkWidget();
- 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];
- String codePage = getCodePage ();
- 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 (codePage, buffer));
- items += 4;
- }
- 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>
- * @exception SWTError <ul>
- * <li>ERROR_CANNOT_GET_COUNT - if the operation fails because of an operating system failure</li>
- * </ul>
+public String [] getSelection () {
+ checkWidget();
+ 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];
+ String codePage = getCodePage ();
+ 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 (codePage, buffer));
+ items += 4;
+ }
+ 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>
+ * @exception SWTError <ul>
+ * <li>ERROR_CANNOT_GET_COUNT - if the operation fails because of an operating system failure</li>
+ * </ul>
*/
-public int getSelectionCount () {
- checkWidget();
- int [] argList = {OS.XmNselectedItemCount, 0};
- OS.XtGetValues (handle, argList, argList.length / 2);
- return argList [1];
-}
-/**
- * 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>
- * @exception SWTError <ul>
- * <li>ERROR_CANNOT_GET_SELECTION - if the operation fails because of an operating system failure</li>
- * </ul>
+public int getSelectionCount () {
+ checkWidget();
+ int [] argList = {OS.XmNselectedItemCount, 0};
+ OS.XtGetValues (handle, argList, argList.length / 2);
+ return argList [1];
+}
+/**
+ * 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>
+ * @exception SWTError <ul>
+ * <li>ERROR_CANNOT_GET_SELECTION - if the operation fails because of an operating system failure</li>
+ * </ul>
*/
-public int getSelectionIndex () {
- checkWidget();
- 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;
-}
-/**
- * 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 affect the receiver.
- * </p>
- * @return the array of indices of the selected items
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- * @exception SWTError <ul>
- * <li>ERROR_CANNOT_GET_SELECTION - if the operation fails because of an operating system failure</li>
- * </ul>
+public int getSelectionIndex () {
+ checkWidget();
+ 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;
+}
+/**
+ * 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 affect the receiver.
+ * </p>
+ * @return the array of indices of the selected items
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * @exception SWTError <ul>
+ * <li>ERROR_CANNOT_GET_SELECTION - if the operation fails because of an operating system failure</li>
+ * </ul>
*/
-public int [] getSelectionIndices () {
- checkWidget();
- 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;
-}
-/**
- * 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 [] getSelectionIndices () {
+ checkWidget();
+ 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;
+}
+/**
+ * Returns the zero-relative index of the item which is currently
+ * at the top of the receiver. This index can change when items are
+ * scrolled or new items are added or removed.
+ *
+ * @return the index of the top item
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
*/
-public int getTopIndex () {
- checkWidget();
- int [] 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, BROWSE_SELECTION_CALLBACK);
- OS.XtAddCallback (handle, OS.XmNextendedSelectionCallback, windowProc, EXTENDED_SELECTION_CALLBACK);
- OS.XtAddCallback (handle, OS.XmNdefaultActionCallback, windowProc, DEFAULT_ACTION_CALLBACK);
-}
-/**
- * Gets the index of an item.
- * <p>
- * The list is searched starting at 0 until an
- * item is found that is equal to the search item.
- * If no item is found, -1 is returned. Indexing
- * is zero based.
- *
- * @param string the search item
- * @return the index of the item
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the string is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
+public int getTopIndex () {
+ checkWidget();
+ 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, BROWSE_SELECTION_CALLBACK);
+ OS.XtAddCallback (handle, OS.XmNextendedSelectionCallback, windowProc, EXTENDED_SELECTION_CALLBACK);
+ OS.XtAddCallback (handle, OS.XmNdefaultActionCallback, windowProc, DEFAULT_ACTION_CALLBACK);
+}
+/**
+ * Gets the index of an item.
+ * <p>
+ * The list is searched starting at 0 until an
+ * item is found that is equal to the search item.
+ * If no item is found, -1 is returned. Indexing
+ * is zero based.
+ *
+ * @param string the search item
+ * @return the index of the item
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if the string is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
*/
-public int indexOf (String string) {
- checkWidget();
- if (string == null) error (SWT.ERROR_NULL_ARGUMENT);
- byte [] buffer = Converter.wcsToMbcs (getCodePage (), string, true);
- int xmString = OS.XmStringCreateLocalized (buffer);
- if (xmString == 0) return -1;
- int index = OS.XmListItemPos (handle, xmString);
- OS.XmStringFree (xmString);
- return index - 1;
-}
-/**
- * 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>
- * @exception SWTError <ul>
- * <li>ERROR_CANNOT_GET_COUNT - if the operation fails because of an operating system failure while getting the item count</li>
- * <li>ERROR_CANNOT_GET_ITEM - if the operation fails because of an operating system failure while getting an item</li>
- * </ul>
+public int indexOf (String string) {
+ checkWidget();
+ if (string == null) error (SWT.ERROR_NULL_ARGUMENT);
+ byte [] buffer = Converter.wcsToMbcs (getCodePage (), string, true);
+ int xmString = OS.XmStringCreateLocalized (buffer);
+ if (xmString == 0) return -1;
+ int index = OS.XmListItemPos (handle, xmString);
+ OS.XmStringFree (xmString);
+ return index - 1;
+}
+/**
+ * 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>
+ * @exception SWTError <ul>
+ * <li>ERROR_CANNOT_GET_COUNT - if the operation fails because of an operating system failure while getting the item count</li>
+ * <li>ERROR_CANNOT_GET_ITEM - if the operation fails because of an operating system failure while getting an item</li>
+ * </ul>
*/
-public int indexOf (String string, int start) {
- checkWidget();
- 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 (getCodePage (), 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;
-}
-/**
- * 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 int indexOf (String string, int start) {
+ checkWidget();
+ 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 (getCodePage (), 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;
+}
+/**
+ * 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();
- if (index == -1) return false;
- return OS.XmListPosSelected (handle, index + 1);
-}
-void overrideTranslations () {
- Display display = getDisplay ();
- OS.XtOverrideTranslations (handle, display.tabTranslations);
-}
-/**
- * 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 boolean isSelected (int index) {
+ checkWidget();
+ if (index == -1) return false;
+ return OS.XmListPosSelected (handle, index + 1);
+}
+void overrideTranslations () {
+ Display display = getDisplay ();
+ OS.XtOverrideTranslations (handle, display.tabTranslations);
+}
+/**
+ * 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();
- 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 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 index) {
+ checkWidget();
+ 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 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 count = end - start + 1;
- /*
- * Feature in Motif. An index out of range is 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);
-}
-/**
- * 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 (int start, int end) {
+ checkWidget();
+ if (start > end) return;
+ int count = end - start + 1;
+ /*
+ * Feature in Motif. An index out of range is 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);
+}
+/**
+ * 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();
- if (string == null) error (SWT.ERROR_NULL_ARGUMENT);
- byte [] buffer = Converter.wcsToMbcs (getCodePage (), 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 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 (String string) {
+ checkWidget();
+ if (string == null) error (SWT.ERROR_NULL_ARGUMENT);
+ byte [] buffer = Converter.wcsToMbcs (getCodePage (), 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 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);
- /*
- * 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 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 remove (int [] indices) {
+ checkWidget();
+ 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 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.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 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 removeAll () {
+ checkWidget();
+ 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 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 removeSelectionListener(SelectionListener listener) {
+ checkWidget();
+ if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+ if (eventTable == null) return;
+ eventTable.unhook(SWT.Selection, listener);
+ eventTable.unhook(SWT.DefaultSelection,listener);
+}
+/**
+ * Selects the item at the given zero-relative index in the receiver's
+ * list. If the item at the index was already selected, it remains
+ * selected. Indices that are out of range are ignored.
+ *
+ * @param index the index of the item to select
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
*/
-public void select (int index) {
- checkWidget();
- if (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 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 index) {
+ checkWidget();
+ 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 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 [] 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 + 1) 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 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 start, int end) {
+ checkWidget();
+ 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 + 1) 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 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 [] 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) {
- checkWidget();
- int [] table = new int [items.length];
- String codePage = getCodePage ();
- for (int i=0; i<items.length; i++) {
- String string = items [i];
- byte [] buffer = Converter.wcsToMbcs (codePage, 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 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 select (int [] indices) {
+ checkWidget();
+ 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) {
+ checkWidget();
+ int [] table = new int [items.length];
+ String codePage = getCodePage ();
+ for (int i=0; i<items.length; i++) {
+ String string = items [i];
+ byte [] buffer = Converter.wcsToMbcs (codePage, 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 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;
- /*
- * 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);
- }
-}
-boolean setBounds (int x, int y, int width, int height, boolean move, boolean resize) {
- boolean changed = super.setBounds (x, y, width, height, move, resize);
- /*
- * 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.
- */
-
- /* Grow and shrink the scrolled window by one pixel */
- if (changed && scrolledHandle != 0) {
- 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]);
- }
- return changed;
-}
-void setFocusIndex (int index) {
- OS.XmListSetKbdItemPos (handle, index + 1);
-}
-/**
- * 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 selectAll () {
+ checkWidget();
+ 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);
+ }
+}
+boolean setBounds (int x, int y, int width, int height, boolean move, boolean resize) {
+ boolean changed = super.setBounds (x, y, width, height, move, resize);
+ /*
+ * 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.
+ */
+
+ /* Grow and shrink the scrolled window by one pixel */
+ if (changed && scrolledHandle != 0) {
+ 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]);
+ }
+ return changed;
+}
+void setFocusIndex (int index) {
+ OS.XmListSetKbdItemPos (handle, index + 1);
+}
+/**
+ * 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);
- 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 (getCodePage (), 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 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 setItem (int index, String string) {
+ checkWidget();
+ 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 (getCodePage (), 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 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);
- /*
- * 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];
- String codePage = getCodePage ();
- while (index < items.length) {
- String string = items [index];
- if (string == null) break;
- byte [] buffer = Converter.wcsToMbcs (codePage, 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);
-}
-/**
- * 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 setItems (String [] items) {
+ checkWidget();
+ 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];
+ String codePage = getCodePage ();
+ while (index < items.length) {
+ String string = items [index];
+ if (string == null) break;
+ byte [] buffer = Converter.wcsToMbcs (codePage, 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);
+}
+/**
+ * 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) {
- checkWidget();
- if ((style & SWT.MULTI) != 0) deselectAll ();
- select (index);
- showSelection ();
-}
-/**
- * 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 index) {
+ checkWidget();
+ if ((style & SWT.MULTI) != 0) deselectAll ();
+ select (index);
+ showSelection ();
+}
+/**
+ * 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) {
- checkWidget();
- if ((style & SWT.MULTI) != 0) deselectAll ();
- select (start, end);
- showSelection ();
-}
+public void setSelection (int start, int end) {
+ checkWidget();
+ if ((style & SWT.MULTI) != 0) deselectAll ();
+ select (start, end);
+ showSelection ();
+}
/**
* Selects the items at the given zero-relative indices in the receiver.
* The current selection is first cleared, then the new items are selected.
@@ -1368,153 +1368,153 @@ public void setSelection (int start, int end) {
* @see List#deselectAll()
* @see List#select(int[])
*/
-public void setSelection(int[] indices) {
- checkWidget();
- if (indices == null) error (SWT.ERROR_NULL_ARGUMENT);
- deselectAll ();
- select (indices);
- showSelection ();
-}
-/**
- * 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(int[] indices) {
+ checkWidget();
+ if (indices == null) error (SWT.ERROR_NULL_ARGUMENT);
+ deselectAll ();
+ select (indices);
+ showSelection ();
+}
+/**
+ * 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);
- String codePage = getCodePage ();
- 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 (codePage, 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)) {
- showSelection ();
- 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 (codePage, 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);
- showSelection ();
-}
-/**
- * Sets the zero-relative index of the item which is currently
- * at the top of the receiver. This index can change when items
- * are scrolled or new items are added and removed.
- *
- * @param index the index of the top item
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
+public void setSelection (String [] items) {
+ checkWidget();
+ if (items == null) error (SWT.ERROR_NULL_ARGUMENT);
+ String codePage = getCodePage ();
+ 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 (codePage, 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)) {
+ showSelection ();
+ 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 (codePage, 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);
+ showSelection ();
+}
+/**
+ * Sets the zero-relative index of the item which is currently
+ * at the top of the receiver. This index can change when items
+ * are scrolled or new items are added and removed.
+ *
+ * @param index the index of the top item
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
*/
-public void setTopIndex (int index) {
- checkWidget();
- 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. 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 setTopIndex (int index) {
+ checkWidget();
+ 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. 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 [] 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;
-}
-int XmNbrowseSelectionCallback (int w, int client_data, int call_data) {
- postEvent (SWT.Selection);
- return 0;
-}
-int XmNdefaultActionCallback (int w, int client_data, int call_data) {
- postEvent (SWT.DefaultSelection);
- return 0;
-}
-int XmNextendedSelectionCallback (int w, int client_data, int call_data) {
- postEvent (SWT.Selection);
- return 0;
-}
-}
+public void showSelection () {
+ checkWidget();
+ 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;
+}
+int XmNbrowseSelectionCallback (int w, int client_data, int call_data) {
+ postEvent (SWT.Selection);
+ return 0;
+}
+int XmNdefaultActionCallback (int w, int client_data, int call_data) {
+ postEvent (SWT.DefaultSelection);
+ return 0;
+}
+int XmNextendedSelectionCallback (int w, int client_data, int call_data) {
+ postEvent (SWT.Selection);
+ return 0;
+}
+}
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
index 6936e67c53..e46db0de49 100755
--- 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
@@ -1,36 +1,36 @@
-package org.eclipse.swt.widgets;
-
-/*
+package org.eclipse.swt.widgets;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-import org.eclipse.swt.internal.motif.*;
-import org.eclipse.swt.*;
-import org.eclipse.swt.events.*;
-import org.eclipse.swt.graphics.*;
-
-/**
- * Instances of this class are user interface objects that contain
- * menu items.
- * <dl>
- * <dt><b>Styles:</b></dt>
- * <dd>BAR, DROP_DOWN, POP_UP</dd>
- * <dt><b>Events:</b></dt>
- * <dd>Help, Hide, Show </dd>
- * </dl>
- * <p>
- * Note: Only one of BAR, DROP_DOWN and POP_UP may be specified.
- * </p><p>
- * IMPORTANT: This class is <em>not</em> intended to be subclassed.
- * </p>
+ * http://www.eclipse.org/legal/cpl-v10.html
*/
-public class Menu extends Widget {
- boolean hasLocation;
- MenuItem cascade, defaultItem;
- Decorations parent;
+
+import org.eclipse.swt.internal.motif.*;
+import org.eclipse.swt.*;
+import org.eclipse.swt.events.*;
+import org.eclipse.swt.graphics.*;
+
+/**
+ * Instances of this class are user interface objects that contain
+ * menu items.
+ * <dl>
+ * <dt><b>Styles:</b></dt>
+ * <dd>BAR, DROP_DOWN, POP_UP</dd>
+ * <dt><b>Events:</b></dt>
+ * <dd>Help, Hide, Show </dd>
+ * </dl>
+ * <p>
+ * Note: Only one of BAR, DROP_DOWN and POP_UP may be specified.
+ * </p><p>
+ * IMPORTANT: This class is <em>not</em> intended to be subclassed.
+ * </p>
+ */
+public class Menu extends Widget {
+ boolean hasLocation;
+ MenuItem cascade, defaultItem;
+ Decorations parent;
/**
* Constructs a new instance of this class given its parent,
* and sets the style for the instance so that the instance
@@ -50,9 +50,9 @@ public class Menu extends Widget {
* @see Widget#checkSubclass
* @see Widget#getStyle
*/
-public Menu (Control parent) {
- this (checkNull(parent).getShell (), SWT.POP_UP);
-}
+public Menu (Control parent) {
+ this (checkNull(parent).getShell (), SWT.POP_UP);
+}
/**
* Constructs a new instance of this class given its parent
* (which must be a <code>Decorations</code>) and a style value
@@ -84,11 +84,11 @@ public Menu (Control parent) {
* @see Widget#checkSubclass
* @see Widget#getStyle
*/
-public Menu (Decorations parent, int style) {
- super (parent, checkStyle (style));
- this.parent = parent;
- createWidget (0);
-}
+public Menu (Decorations parent, int style) {
+ super (parent, checkStyle (style));
+ this.parent = parent;
+ createWidget (0);
+}
/**
* Constructs a new instance of this class given its parent
* (which must be a <code>Menu</code>) and sets the style
@@ -109,9 +109,9 @@ public Menu (Decorations parent, int style) {
* @see Widget#checkSubclass
* @see Widget#getStyle
*/
-public Menu (Menu parentMenu) {
- this (checkNull(parentMenu).parent, SWT.DROP_DOWN);
-}
+public Menu (Menu parentMenu) {
+ this (checkNull(parentMenu).parent, SWT.DROP_DOWN);
+}
/**
* Constructs a new instance of this class given its parent
* (which must be a <code>MenuItem</code>) and sets the style
@@ -132,16 +132,16 @@ public Menu (Menu parentMenu) {
* @see Widget#checkSubclass
* @see Widget#getStyle
*/
-public Menu (MenuItem parentItem) {
- this (checkNull(parentItem).parent);
-}
-void addAccelerators () {
- MenuItem [] items = getItems ();
- for (int i = 0; i < items.length; i++) {
- MenuItem item = items[i];
- item.addAccelerators ();
- }
-}
+public Menu (MenuItem parentItem) {
+ this (checkNull(parentItem).parent);
+}
+void addAccelerators () {
+ MenuItem [] items = getItems ();
+ for (int i = 0; i < items.length; i++) {
+ MenuItem item = items[i];
+ item.addAccelerators ();
+ }
+}
/**
* Adds the listener to the collection of listeners who will
* be notified when help events are generated for the control,
@@ -161,12 +161,12 @@ void addAccelerators () {
* @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);
-}
+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 menus are hidden or shown, by sending it
@@ -186,656 +186,656 @@ public void addHelpListener (HelpListener listener) {
* @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 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;
- int [] argList = {OS.XmNancestorSensitive, 1};
- handle = OS.XmCreateMenuBar (parentHandle, null, argList, argList.length / 2);
- 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.
- */
- byte [] buffer = new byte [1];
- int [] argList = {OS.XmNancestorSensitive, 1};
- if ((style & SWT.POP_UP) != 0) {
- int parentHandle = parent.dialogHandle ();
- handle = OS.XmCreatePopupMenu (parentHandle, buffer, argList, argList.length / 2);
- } 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, buffer, argList, argList.length / 2);
- }
- 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) {
- checkOrientation (parent);
- super.createWidget (index);
- parent.add (this);
-}
-/**
- * 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 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 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;
+ int [] argList = {OS.XmNancestorSensitive, 1};
+ handle = OS.XmCreateMenuBar (parentHandle, null, argList, argList.length / 2);
+ 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.
+ */
+ byte [] buffer = new byte [1];
+ int [] argList = {OS.XmNancestorSensitive, 1};
+ if ((style & SWT.POP_UP) != 0) {
+ int parentHandle = parent.dialogHandle ();
+ handle = OS.XmCreatePopupMenu (parentHandle, buffer, argList, argList.length / 2);
+ } 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, buffer, argList, argList.length / 2);
+ }
+ 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) {
+ checkOrientation (parent);
+ super.createWidget (index);
+ parent.add (this);
+}
+/**
+ * Returns the default menu item or null if none has
+ * been previously set.
+ *
+ * @return the default menu item.
+ *
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
*/
-public MenuItem getDefaultItem () {
- checkWidget();
- return defaultItem;
-}
-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 MenuItem getDefaultItem () {
+ checkWidget();
+ return defaultItem;
+}
+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();
- int [] argList = {OS.XmNsensitive, 0};
- OS.XtGetValues (handle, argList, argList.length / 2);
- return argList [1] != 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 boolean getEnabled () {
+ checkWidget();
+ int [] argList = {OS.XmNsensitive, 0};
+ OS.XtGetValues (handle, argList, argList.length / 2);
+ return argList [1] != 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();
- 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;
-}
-/**
- * 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 MenuItem getItem (int index) {
+ checkWidget();
+ 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;
+}
+/**
+ * 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 [] 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;
-}
-/**
- * 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 affect the receiver.
- * </p>
- *
- * @return the items in the receiver
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
+public int getItemCount () {
+ checkWidget();
+ 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;
+}
+/**
+ * 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 affect the receiver.
+ * </p>
+ *
+ * @return the items in the receiver
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
*/
-public MenuItem [] getItems () {
- checkWidget();
- int [] 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;
-}
-/**
- * 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 MenuItem [] getItems () {
+ checkWidget();
+ 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;
+}
+/**
+ * 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 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 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 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 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 OS.XtIsManaged (handle);
-}
-void hookEvents () {
- int windowProc = getDisplay ().windowProc;
- OS.XtAddCallback (handle, OS.XmNhelpCallback, windowProc, HELP_CALLBACK);
- OS.XtAddCallback (handle, OS.XmNmapCallback, windowProc, MAP_CALLBACK);
- OS.XtAddCallback (handle, OS.XmNunmapCallback, windowProc, UNMAP_CALLBACK);
-}
-/**
- * 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 boolean getVisible () {
+ checkWidget();
+ return OS.XtIsManaged (handle);
+}
+void hookEvents () {
+ int windowProc = getDisplay ().windowProc;
+ OS.XtAddCallback (handle, OS.XmNhelpCallback, windowProc, HELP_CALLBACK);
+ OS.XtAddCallback (handle, OS.XmNmapCallback, windowProc, MAP_CALLBACK);
+ OS.XtAddCallback (handle, OS.XmNunmapCallback, windowProc, UNMAP_CALLBACK);
+}
+/**
+ * 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();
- 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;
-}
-/**
- * Returns <code>true</code> if the receiver is enabled and all
- * of the receiver's ancestors are enabled, and <code>false</code>
- * otherwise. A disabled control is typically not selectable from the
- * user interface and draws with an inactive or "grayed" look.
- *
- * @return the receiver's enabled state
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see #getEnabled
+public int indexOf (MenuItem item) {
+ checkWidget();
+ 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;
+}
+/**
+ * Returns <code>true</code> if the receiver is enabled and all
+ * of the receiver's ancestors are enabled, and <code>false</code>
+ * otherwise. A disabled control is typically not selectable from the
+ * user interface and draws with an inactive or "grayed" look.
+ *
+ * @return the receiver's enabled state
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see #getEnabled
*/
-public boolean isEnabled () {
- checkWidget();
- Menu parentMenu = getParentMenu ();
- if (parentMenu == null) return getEnabled ();
- return getEnabled () && parentMenu.isEnabled ();
-}
-/**
- * Returns <code>true</code> if the receiver is visible and all
- * of the receiver's ancestors are visible and <code>false</code>
- * otherwise.
- *
- * @return the receiver's visibility state
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see #getVisible
+public boolean isEnabled () {
+ checkWidget();
+ Menu parentMenu = getParentMenu ();
+ if (parentMenu == null) return getEnabled ();
+ return getEnabled () && parentMenu.isEnabled ();
+}
+/**
+ * Returns <code>true</code> if the receiver is visible and all
+ * of the receiver's ancestors are visible and <code>false</code>
+ * otherwise.
+ *
+ * @return the receiver's visibility state
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see #getVisible
*/
-public boolean isVisible () {
- checkWidget();
- return getVisible ();
-}
-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.releaseResources ();
- }
- super.releaseWidget ();
- if (parent != null) parent.remove (this);
- parent = null;
- cascade = defaultItem = null;
-}
-void removeAccelerators () {
- MenuItem [] items = getItems ();
- for (int i = 0; i < items.length; i++) {
- MenuItem item = items[i];
- item.removeAccelerators ();
- }
-}
-/**
- * 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 boolean isVisible () {
+ checkWidget();
+ return getVisible ();
+}
+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.releaseResources ();
+ }
+ super.releaseWidget ();
+ if (parent != null) parent.remove (this);
+ parent = null;
+ cascade = defaultItem = null;
+}
+void removeAccelerators () {
+ MenuItem [] items = getItems ();
+ for (int i = 0; i < items.length; i++) {
+ MenuItem item = items[i];
+ item.removeAccelerators ();
+ }
+}
+/**
+ * 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 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);
-}
-void sendHelpEvent (int callData) {
- if (hooks (SWT.Help)) {
- postEvent (SWT.Help);
- return;
- }
- parent.sendHelpEvent (callData);
-}
-/**
- * Sets the default menu item to the argument or removes
- * the default emphasis when the argument is <code>null</code>.
- *
- * @param item the default menu item or null
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_INVALID_ARGUMENT - if the menu item has been disposed</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
+public void removeMenuListener(MenuListener listener) {
+ checkWidget();
+ if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+ if (eventTable == null) return;
+ eventTable.unhook(SWT.Hide, listener);
+ eventTable.unhook(SWT.Show, listener);
+}
+void sendHelpEvent (int callData) {
+ if (hooks (SWT.Help)) {
+ postEvent (SWT.Help);
+ return;
+ }
+ parent.sendHelpEvent (callData);
+}
+/**
+ * Sets the default menu item to the argument or removes
+ * the default emphasis when the argument is <code>null</code>.
+ *
+ * @param item the default menu item or null
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_INVALID_ARGUMENT - if the menu item has been disposed</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
*/
-public void setDefaultItem (MenuItem item) {
- checkWidget();
- if (item != null && item.isDisposed()) error(SWT.ERROR_INVALID_ARGUMENT);
- defaultItem = item;
-}
-/**
- * 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 setDefaultItem (MenuItem item) {
+ checkWidget();
+ if (item != null && item.isDisposed()) error(SWT.ERROR_INVALID_ARGUMENT);
+ defaultItem = item;
+}
+/**
+ * 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 [] argList = {OS.XmNsensitive, enabled ? 1 : 0};
- OS.XtSetValues (handle, argList, argList.length / 2);
-}
-/**
- * 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 setEnabled (boolean enabled) {
+ checkWidget();
+ int [] argList = {OS.XmNsensitive, enabled ? 1 : 0};
+ OS.XtSetValues (handle, argList, argList.length / 2);
+}
+/**
+ * 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();
- 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;
-}
-public void setLocation (Point location) {
- checkWidget();
- if (location == null) error (SWT.ERROR_NULL_ARGUMENT);
- setLocation (location.x, location.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 setLocation (int x, int y) {
+ checkWidget();
+ 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;
+}
+public void setLocation (Point location) {
+ checkWidget();
+ if (location == null) error (SWT.ERROR_NULL_ARGUMENT);
+ setLocation (location.x, location.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 ((style & (SWT.BAR | SWT.DROP_DOWN)) != 0) return;
- if (visible) {
- sendEvent (SWT.Show);
- if (getItemCount () != 0) {
- int xDisplay = OS.XtDisplay (handle);
- if (xDisplay == 0) return;
- int xWindow = OS.XDefaultRootWindow (xDisplay);
- if (xWindow == 0) return;
- int [] rootX = new int [1], rootY = new int [1], unused = new int [1], mask = new int [1];
- if (OS.XQueryPointer (xDisplay, xWindow, unused, unused, rootX, rootY, unused, unused, mask) == 0) {
- return;
- }
- if (!hasLocation) {
- /*
- * Bug in Motif. For some reason, when a menu is popped up
- * under the mouse, the menu will not highlight until the
- * mouse exits and then enters the menu again. The fix is
- * to pop the menu up outside the current mouse position
- * causing highlighting to work properly when the user
- * waits for the menu to appear.
- */
- rootX[0] += 1; rootY[0] += 1;
- int [] argList = {OS.XmNx, rootX [0], OS.XmNy, rootY [0]};
- OS.XtSetValues (handle, argList, argList.length / 2);
- }
- /*
- * Feature in Motif. If an X grab is active, then
- * the menu pops us but issues and error message an
- * fails to grab the pointer. The fix is to ensure
- * that no grab is active before showing the menu.
- */
- OS.XUngrabPointer (xDisplay, OS.CurrentTime);
- OS.XtManageChild (handle);
- /*
- * Feature in Motif. There is no API to force the menu
- * to accept keyboard traversal when popped up using
- * XtManageChild. The fix is to call undocumented API
- * to do this.
- */
- int flags = OS.Button1Mask | OS.Button2Mask | OS.Button3Mask;
- if ((mask [0] & flags) == 0) OS._XmSetMenuTraversal (handle, true);
- } else {
- sendEvent (SWT.Hide);
- }
- } else {
- OS.XtUnmanageChild (handle);
- }
-}
-boolean translateAccelerator (int accel) {
- if (!getEnabled ()) return false;
- MenuItem [] items = getItems ();
- for (int i = 0; i < items.length; i++) {
- MenuItem item = items [i];
- if (item.translateAccelerator (accel)) return true;
- }
- return false;
-}
-int XmNhelpCallback (int w, int client_data, int call_data) {
- sendHelpEvent (call_data);
- return 0;
-}
-int XmNmapCallback (int w, int client_data, int call_data) {
- if ((style & SWT.POP_UP) != 0) return 0;
- /*
- * 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;
-}
-int XmNunmapCallback (int w, int client_data, int call_data) {
- sendEvent (SWT.Hide);
- return 0;
-}
-}
+public void setVisible (boolean visible) {
+ checkWidget();
+ if ((style & (SWT.BAR | SWT.DROP_DOWN)) != 0) return;
+ if (visible) {
+ sendEvent (SWT.Show);
+ if (getItemCount () != 0) {
+ int xDisplay = OS.XtDisplay (handle);
+ if (xDisplay == 0) return;
+ int xWindow = OS.XDefaultRootWindow (xDisplay);
+ if (xWindow == 0) return;
+ int [] rootX = new int [1], rootY = new int [1], unused = new int [1], mask = new int [1];
+ if (OS.XQueryPointer (xDisplay, xWindow, unused, unused, rootX, rootY, unused, unused, mask) == 0) {
+ return;
+ }
+ if (!hasLocation) {
+ /*
+ * Bug in Motif. For some reason, when a menu is popped up
+ * under the mouse, the menu will not highlight until the
+ * mouse exits and then enters the menu again. The fix is
+ * to pop the menu up outside the current mouse position
+ * causing highlighting to work properly when the user
+ * waits for the menu to appear.
+ */
+ rootX[0] += 1; rootY[0] += 1;
+ int [] argList = {OS.XmNx, rootX [0], OS.XmNy, rootY [0]};
+ OS.XtSetValues (handle, argList, argList.length / 2);
+ }
+ /*
+ * Feature in Motif. If an X grab is active, then
+ * the menu pops us but issues and error message an
+ * fails to grab the pointer. The fix is to ensure
+ * that no grab is active before showing the menu.
+ */
+ OS.XUngrabPointer (xDisplay, OS.CurrentTime);
+ OS.XtManageChild (handle);
+ /*
+ * Feature in Motif. There is no API to force the menu
+ * to accept keyboard traversal when popped up using
+ * XtManageChild. The fix is to call undocumented API
+ * to do this.
+ */
+ int flags = OS.Button1Mask | OS.Button2Mask | OS.Button3Mask;
+ if ((mask [0] & flags) == 0) OS._XmSetMenuTraversal (handle, true);
+ } else {
+ sendEvent (SWT.Hide);
+ }
+ } else {
+ OS.XtUnmanageChild (handle);
+ }
+}
+boolean translateAccelerator (int accel) {
+ if (!getEnabled ()) return false;
+ MenuItem [] items = getItems ();
+ for (int i = 0; i < items.length; i++) {
+ MenuItem item = items [i];
+ if (item.translateAccelerator (accel)) return true;
+ }
+ return false;
+}
+int XmNhelpCallback (int w, int client_data, int call_data) {
+ sendHelpEvent (call_data);
+ return 0;
+}
+int XmNmapCallback (int w, int client_data, int call_data) {
+ if ((style & SWT.POP_UP) != 0) return 0;
+ /*
+ * 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;
+}
+int XmNunmapCallback (int w, int client_data, int call_data) {
+ sendEvent (SWT.Hide);
+ return 0;
+}
+}
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
index fd62d8e11c..dd232c3970 100755
--- 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
@@ -1,17 +1,17 @@
-package org.eclipse.swt.widgets;
-
-/*
+package org.eclipse.swt.widgets;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-import org.eclipse.swt.internal.*;
-import org.eclipse.swt.internal.motif.*;
-import org.eclipse.swt.*;
-import org.eclipse.swt.events.*;
-
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+import org.eclipse.swt.internal.*;
+import org.eclipse.swt.internal.motif.*;
+import org.eclipse.swt.*;
+import org.eclipse.swt.events.*;
+
/**
* Instances of this class represent a selectable user interface object
* that issues notification when pressed and released.
@@ -28,10 +28,10 @@ import org.eclipse.swt.events.*;
* IMPORTANT: This class is <em>not</em> intended to be subclassed.
* </p>
*/
-public class MenuItem extends Item {
- int accelerator;
- Menu parent, menu;
-
+public class MenuItem extends Item {
+ int accelerator;
+ Menu parent, menu;
+
/**
* Constructs a new instance of this class given its parent
* (which must be a <code>Menu</code>) and a style value
@@ -66,12 +66,12 @@ public class MenuItem extends Item {
* @see Widget#checkSubclass
* @see Widget#getStyle
*/
-public MenuItem (Menu parent, int style) {
- super (parent, checkStyle (style));
- this.parent = parent;
- createWidget (OS.XmLAST_POSITION);
-}
-
+public MenuItem (Menu parent, int style) {
+ super (parent, checkStyle (style));
+ this.parent = parent;
+ createWidget (OS.XmLAST_POSITION);
+}
+
/**
* Constructs a new instance of this class given its parent
* (which must be a <code>Menu</code>), a style value
@@ -107,538 +107,538 @@ public MenuItem (Menu parent, int style) {
* @see Widget#checkSubclass
* @see Widget#getStyle
*/
-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);
-}
-void addAccelerator () {
- if (accelerator == 0) return;
- /*
- * Bug in Solaris. When accelerators are set more
- * than once in the same menu bar, the time it takes
- * to set the accelerator increases exponentially.
- * The fix is to implement our own accelerator table
- * on Solaris.
- */
- if (OS.IsSunOS) return;
- String ctrl, alt, shift;
- ctrl = alt = shift = "";
- if ((accelerator & SWT.ALT) != 0) alt = "Meta ";
- if ((accelerator & SWT.SHIFT) != 0) shift = "Shift ";
- if ((accelerator & SWT.CONTROL) != 0) ctrl = "Ctrl ";
- int keysym = accelerator & SWT.KEY_MASK;
- int newKey = Display.untranslateKey (keysym);
- if (newKey != 0) {
- keysym = newKey;
- } else {
- keysym = wcsToMbcs ((char) keysym);
- }
- /*
- * Feature in Motif. Motif does not activate an accelerator
- * when the CapsLoc, NumLoc and NumLock+CapsLoc keys are pressed.
- * In order to activate accelerators when these keys are pressed,
- * it is necessary to look for all of these key sequences.
- */
- String key = ctrl + alt + shift + "<Key>" + keysymName (keysym);
- String allKeys = key + ",Lock " + key + ",Mod2 " + key + ",Lock Mod2 " + key;
- /* Use the character encoding for the default locale */
- byte [] buffer = Converter.wcsToMbcs (null, allKeys, true);
- int 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);
-}
-void addAccelerators () {
- addAccelerator ();
- if (menu != null) menu.addAccelerators ();
-}
-/**
- * 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 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);
+}
+void addAccelerator () {
+ if (accelerator == 0) return;
+ /*
+ * Bug in Solaris. When accelerators are set more
+ * than once in the same menu bar, the time it takes
+ * to set the accelerator increases exponentially.
+ * The fix is to implement our own accelerator table
+ * on Solaris.
+ */
+ if (OS.IsSunOS) return;
+ String ctrl, alt, shift;
+ ctrl = alt = shift = "";
+ if ((accelerator & SWT.ALT) != 0) alt = "Meta ";
+ if ((accelerator & SWT.SHIFT) != 0) shift = "Shift ";
+ if ((accelerator & SWT.CONTROL) != 0) ctrl = "Ctrl ";
+ int keysym = accelerator & SWT.KEY_MASK;
+ int newKey = Display.untranslateKey (keysym);
+ if (newKey != 0) {
+ keysym = newKey;
+ } else {
+ keysym = wcsToMbcs ((char) keysym);
+ }
+ /*
+ * Feature in Motif. Motif does not activate an accelerator
+ * when the CapsLoc, NumLoc and NumLock+CapsLoc keys are pressed.
+ * In order to activate accelerators when these keys are pressed,
+ * it is necessary to look for all of these key sequences.
+ */
+ String key = ctrl + alt + shift + "<Key>" + keysymName (keysym);
+ String allKeys = key + ",Lock " + key + ",Mod2 " + key + ",Lock Mod2 " + key;
+ /* Use the character encoding for the default locale */
+ byte [] buffer = Converter.wcsToMbcs (null, allKeys, true);
+ int 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);
+}
+void addAccelerators () {
+ addAccelerator ();
+ if (menu != null) menu.addAccelerators ();
+}
+/**
+ * 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 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.
- * <p>
- * When <code>widgetSelected</code> is called, the stateMask field of the event object is valid.
- * <code>widgetDefaultSelected</code> is not called.
- * </p>
- *
- * @param listener the listener which should be notified
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see SelectionListener
- * @see #removeSelectionListener
- * @see SelectionEvent
+public void 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.
+ * <p>
+ * When <code>widgetSelected</code> is called, the stateMask field of the event object is valid.
+ * <code>widgetDefaultSelected</code> is not called.
+ * </p>
+ *
+ * @param listener the listener which should be notified
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see SelectionListener
+ * @see #removeSelectionListener
+ * @see SelectionEvent
*/
-public void addSelectionListener(SelectionListener listener) {
- checkWidget();
- if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
- TypedListener typedListener = new TypedListener(listener);
- addListener(SWT.Selection,typedListener);
- addListener(SWT.DefaultSelection,typedListener);
-}
-static int checkStyle (int style) {
- return checkBits (style, SWT.PUSH, SWT.CHECK, SWT.RADIO, SWT.SEPARATOR, SWT.CASCADE, 0);
-}
-protected void checkSubclass () {
- if (!isValidSubclass ()) error (SWT.ERROR_INVALID_SUBCLASS);
-}
-void createHandle (int index) {
- state |= HANDLE;
- 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.XmNancestorSensitive, 1,
- 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.XmNancestorSensitive, 1,
- 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);
- int indicatorType = OS.XmONE_OF_MANY;
- if ((style & SWT.CHECK) != 0) indicatorType = OS.XmN_OF_MANY;
- int [] argList2 = {OS.XmNindicatorType, indicatorType};
- OS.XtSetValues (handle, argList2, argList2.length / 2);
- 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 ();
-}
-/**
- * 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 void addSelectionListener(SelectionListener listener) {
+ checkWidget();
+ if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+ TypedListener typedListener = new TypedListener(listener);
+ addListener(SWT.Selection,typedListener);
+ addListener(SWT.DefaultSelection,typedListener);
+}
+static int checkStyle (int style) {
+ return checkBits (style, SWT.PUSH, SWT.CHECK, SWT.RADIO, SWT.SEPARATOR, SWT.CASCADE, 0);
+}
+protected void checkSubclass () {
+ if (!isValidSubclass ()) error (SWT.ERROR_INVALID_SUBCLASS);
+}
+void createHandle (int index) {
+ state |= HANDLE;
+ 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.XmNancestorSensitive, 1,
+ 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.XmNancestorSensitive, 1,
+ 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);
+ int indicatorType = OS.XmONE_OF_MANY;
+ if ((style & SWT.CHECK) != 0) indicatorType = OS.XmN_OF_MANY;
+ int [] argList2 = {OS.XmNindicatorType, indicatorType};
+ OS.XtSetValues (handle, argList2, argList2.length / 2);
+ 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 ();
+}
+/**
+ * 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 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 [] argList = {OS.XmNsensitive, 0};
- OS.XtGetValues (handle, argList, argList.length / 2);
- return argList [1] != 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 boolean getEnabled () {
+ checkWidget();
+ int [] argList = {OS.XmNsensitive, 0};
+ OS.XtGetValues (handle, argList, argList.length / 2);
+ return argList [1] != 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 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 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 [] argList = {OS.XmNset, 0};
- OS.XtGetValues (handle, argList, argList.length / 2);
- return argList [1] != OS.XmUNSET;
-}
-void hookEvents () {
- if ((style & SWT.SEPARATOR) != 0) return;
- int windowProc = getDisplay ().windowProc;
- OS.XtAddCallback (handle, OS.XmNhelpCallback, windowProc, HELP_CALLBACK);
- if ((style & SWT.CASCADE) != 0) {
- OS.XtAddCallback (handle, OS.XmNactivateCallback, windowProc, ACTIVATE_CALLBACK);
- OS.XtAddCallback (handle, OS.XmNcascadingCallback, windowProc, CASCADING_CALLBACK);
- } else {
- OS.XtAddCallback (handle, OS.XmNarmCallback, windowProc, ARM_CALLBACK);
- if ((style & (SWT.CHECK | SWT.RADIO)) != 0) {
- OS.XtAddCallback (handle, OS.XmNvalueChangedCallback, windowProc, VALUE_CHANGED_CALLBACK);
- } else {
- OS.XtAddCallback (handle, OS.XmNactivateCallback, windowProc, ACTIVATE_CALLBACK);
- }
- }
-}
-boolean isAccelActive () {
- Menu menu = parent;
- while (menu != null && menu.cascade != null) {
- menu = menu.cascade.parent;
- }
- Decorations shell = menu.parent;
- return shell.menuBar == menu;
-}
-/**
- * Returns <code>true</code> if the receiver is enabled and all
- * of the receiver's ancestors are enabled, and <code>false</code>
- * otherwise. A disabled control is typically not selectable from the
- * user interface and draws with an inactive or "grayed" look.
- *
- * @return the receiver's enabled state
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see #getEnabled
+public boolean getSelection () {
+ checkWidget();
+ if ((style & (SWT.CHECK | SWT.RADIO)) == 0) return false;
+ int [] argList = {OS.XmNset, 0};
+ OS.XtGetValues (handle, argList, argList.length / 2);
+ return argList [1] != OS.XmUNSET;
+}
+void hookEvents () {
+ if ((style & SWT.SEPARATOR) != 0) return;
+ int windowProc = getDisplay ().windowProc;
+ OS.XtAddCallback (handle, OS.XmNhelpCallback, windowProc, HELP_CALLBACK);
+ if ((style & SWT.CASCADE) != 0) {
+ OS.XtAddCallback (handle, OS.XmNactivateCallback, windowProc, ACTIVATE_CALLBACK);
+ OS.XtAddCallback (handle, OS.XmNcascadingCallback, windowProc, CASCADING_CALLBACK);
+ } else {
+ OS.XtAddCallback (handle, OS.XmNarmCallback, windowProc, ARM_CALLBACK);
+ if ((style & (SWT.CHECK | SWT.RADIO)) != 0) {
+ OS.XtAddCallback (handle, OS.XmNvalueChangedCallback, windowProc, VALUE_CHANGED_CALLBACK);
+ } else {
+ OS.XtAddCallback (handle, OS.XmNactivateCallback, windowProc, ACTIVATE_CALLBACK);
+ }
+ }
+}
+boolean isAccelActive () {
+ Menu menu = parent;
+ while (menu != null && menu.cascade != null) {
+ menu = menu.cascade.parent;
+ }
+ Decorations shell = menu.parent;
+ return shell.menuBar == menu;
+}
+/**
+ * Returns <code>true</code> if the receiver is enabled and all
+ * of the receiver's ancestors are enabled, and <code>false</code>
+ * otherwise. A disabled control is typically not selectable from the
+ * user interface and draws with an inactive or "grayed" look.
+ *
+ * @return the receiver's enabled state
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see #getEnabled
*/
-public boolean isEnabled () {
- return getEnabled () && parent.isEnabled ();
-}
-String keysymName (int keysym) {
- switch (keysym) {
- case 8: return "BackSpace";
- case 9: return "Tab";
- /*
- * Bug in Motif. For some reason, the XmNaccelerator
- * resource will not accept XK_Linefeed and prints Xt
- * warnings. The fix is to use XK_Return instead.
- */
-// case 10:
-// case OS.XK_Linefeed: return "Linefeed";
- case 10:
- case OS.XK_Linefeed:
- case 13: return "Return";
- case 27: return "Escape";
- case 127: return "Delete";
- }
- if (('0' <= keysym && keysym <= '9') ||
- ('a' <= keysym && keysym <= 'z') ||
- ('A' <= keysym && keysym <= 'Z')) {
- return new String (new char [] {(char) keysym});
- }
- /*
- * Note that XKeysymToString returns a value in a static
- * area which must not be modified or freed.
+public boolean isEnabled () {
+ return getEnabled () && parent.isEnabled ();
+}
+String keysymName (int keysym) {
+ switch (keysym) {
+ case 8: return "BackSpace";
+ case 9: return "Tab";
+ /*
+ * Bug in Motif. For some reason, the XmNaccelerator
+ * resource will not accept XK_Linefeed and prints Xt
+ * warnings. The fix is to use XK_Return instead.
+ */
+// case 10:
+// case OS.XK_Linefeed: return "Linefeed";
+ case 10:
+ case OS.XK_Linefeed:
+ case 13: return "Return";
+ case 27: return "Escape";
+ case 127: return "Delete";
+ }
+ if (('0' <= keysym && keysym <= '9') ||
+ ('a' <= keysym && keysym <= 'z') ||
+ ('A' <= keysym && keysym <= 'Z')) {
+ 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);
- /* Use the character encoding for the default locale */
- return new String (Converter.mbcsToWcs (null, buffer));
-}
-void manageChildren () {
- OS.XtManageChild (handle);
-}
-void releaseChild () {
- super.releaseChild ();
- if (menu != null) menu.dispose ();
- menu = null;
-}
-void releaseWidget () {
- if (menu != null && !menu.isDisposed ()) menu.releaseResources ();
- menu = null;
- super.releaseWidget ();
- accelerator = 0;
- if (this == parent.defaultItem) {
- parent.defaultItem = null;
- }
- parent = null;
-}
-void removeAccelerator () {
- if (accelerator == 0) return;
- /*
- * Bug in Solaris. When accelerators are set more
- * than once in the same menu bar, the time it takes
- * to set the accelerator increases exponentially.
- * The fix is to implement our own accelerator table
- * on Solaris.
- */
- if (OS.IsSunOS) return;
- int [] argList = {OS.XmNaccelerator, 0};
- OS.XtSetValues (handle, argList, argList.length / 2);
-}
-void removeAccelerators () {
- removeAccelerator ();
- if (menu != null) menu.removeAccelerators ();
-}
-/**
- * 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
+ 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);
+ /* Use the character encoding for the default locale */
+ return new String (Converter.mbcsToWcs (null, buffer));
+}
+void manageChildren () {
+ OS.XtManageChild (handle);
+}
+void releaseChild () {
+ super.releaseChild ();
+ if (menu != null) menu.dispose ();
+ menu = null;
+}
+void releaseWidget () {
+ if (menu != null && !menu.isDisposed ()) menu.releaseResources ();
+ menu = null;
+ super.releaseWidget ();
+ accelerator = 0;
+ if (this == parent.defaultItem) {
+ parent.defaultItem = null;
+ }
+ parent = null;
+}
+void removeAccelerator () {
+ if (accelerator == 0) return;
+ /*
+ * Bug in Solaris. When accelerators are set more
+ * than once in the same menu bar, the time it takes
+ * to set the accelerator increases exponentially.
+ * The fix is to implement our own accelerator table
+ * on Solaris.
+ */
+ if (OS.IsSunOS) return;
+ int [] argList = {OS.XmNaccelerator, 0};
+ OS.XtSetValues (handle, argList, argList.length / 2);
+}
+void removeAccelerators () {
+ removeAccelerator ();
+ if (menu != null) menu.removeAccelerators ();
+}
+/**
+ * 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 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 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);
-}
-void selectRadio () {
- int index = 0;
- MenuItem [] items = parent.getItems ();
- while (index < items.length && items [index] != this) index++;
- int i = index - 1;
- while (i >= 0 && items [i].setRadioSelection (false)) --i;
- int j = index + 1;
- while (j < items.length && items [j].setRadioSelection (false)) j++;
- setSelection (true);
-}
-/**
- * Sets the widget accelerator. An accelerator is the bit-wise
- * OR of zero or more modifier masks and a key. Examples:
- * <code>SWT.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 removeSelectionListener(SelectionListener listener) {
+ checkWidget();
+ if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+ if (eventTable == null) return;
+ eventTable.unhook(SWT.Selection, listener);
+ eventTable.unhook(SWT.DefaultSelection,listener);
+}
+void selectRadio () {
+ int index = 0;
+ MenuItem [] items = parent.getItems ();
+ while (index < items.length && items [index] != this) index++;
+ int i = index - 1;
+ while (i >= 0 && items [i].setRadioSelection (false)) --i;
+ int j = index + 1;
+ while (j < items.length && items [j].setRadioSelection (false)) j++;
+ setSelection (true);
+}
+/**
+ * Sets the widget accelerator. An accelerator is the bit-wise
+ * OR of zero or more modifier masks and a key. Examples:
+ * <code>SWT.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();
- if (this.accelerator == accelerator) return;
- this.accelerator = accelerator;
- if (isAccelActive ()) {
- if (accelerator != 0) {
- addAccelerator ();
- } else {
- removeAccelerator ();
- }
- }
-}
-/**
- * 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 setAccelerator (int accelerator) {
+ checkWidget();
+ if (this.accelerator == accelerator) return;
+ this.accelerator = accelerator;
+ if (isAccelActive ()) {
+ if (accelerator != 0) {
+ addAccelerator ();
+ } else {
+ removeAccelerator ();
+ }
+ }
+}
+/**
+ * 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 [] argList = {OS.XmNsensitive, enabled ? 1 : 0};
- OS.XtSetValues (handle, argList, argList.length / 2);
-}
+public void setEnabled (boolean enabled) {
+ checkWidget();
+ int [] argList = {OS.XmNsensitive, enabled ? 1 : 0};
+ OS.XtSetValues (handle, argList, argList.length / 2);
+}
/**
* Sets the receiver's pull down menu to the argument.
* Only <code>CASCADE</code> menu items can have a
@@ -659,236 +659,236 @@ public void setEnabled (boolean enabled) {
* <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.isDisposed()) error(SWT.ERROR_INVALID_ARGUMENT);
- 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;
-
+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.isDisposed()) error(SWT.ERROR_INVALID_ARGUMENT);
+ 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;
+
/*
* Bug in Motif. When XmNsubMenuId is set and the
* previous menu has accelerators, the time it takes
* to add any new accelerators increases exponentially.
* The fix is to remove the accelerators from the previous
* menu before setting the new one.
- */
- boolean isActive = isAccelActive ();
+ */
+ boolean isActive = isAccelActive ();
if (isActive) removeAccelerators ();
-
- if (oldMenu != null) oldMenu.cascade = null;
- this.menu = menu;
-
- /* Set the new menu in the OS */
- int menuHandle = 0;
- if (menu != null) {
- menu.cascade = this;
- menuHandle = menu.handle;
- }
- int [] argList = {OS.XmNsubMenuId, menuHandle};
+
+ if (oldMenu != null) oldMenu.cascade = null;
+ this.menu = menu;
+
+ /* Set the new menu in the OS */
+ int menuHandle = 0;
+ if (menu != null) {
+ menu.cascade = this;
+ menuHandle = menu.handle;
+ }
+ int [] argList = {OS.XmNsubMenuId, menuHandle};
OS.XtSetValues (handle, argList, argList.length / 2);
-
- if (isActive) addAccelerators ();
-}
-boolean setRadioSelection (boolean value) {
- if ((style & SWT.RADIO) == 0) return false;
- if (getSelection () != value) {
- setSelection (value);
- postEvent (SWT.Selection);
- }
- return true;
-}
-/**
- * Sets the selection state of the receiver.
- * <p>
- * When the receiver is of type <code>CHECK</code> or <code>RADIO</code>,
- * it is selected when it is checked.
- *
- * @param selected the new selection state
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
+
+ if (isActive) addAccelerators ();
+}
+boolean setRadioSelection (boolean value) {
+ if ((style & SWT.RADIO) == 0) return false;
+ if (getSelection () != value) {
+ setSelection (value);
+ postEvent (SWT.Selection);
+ }
+ return true;
+}
+/**
+ * Sets the selection state of the receiver.
+ * <p>
+ * When the receiver is of type <code>CHECK</code> or <code>RADIO</code>,
+ * it is selected when it is checked.
+ *
+ * @param selected the new selection state
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
*/
-public void setSelection (boolean selected) {
- checkWidget();
- if ((style & (SWT.CHECK | SWT.RADIO)) == 0) return;
- int [] argList = {OS.XmNset, selected ? OS.XmSET : OS.XmUNSET};
- OS.XtSetValues (handle, argList, argList.length / 2);
-}
-public void setText (String string) {
- checkWidget();
- if (string == null) error (SWT.ERROR_NULL_ARGUMENT);
- /*
- * Feature in Motif. Motif does not optimize the case
- * when the same text is set into a menu item causing
- * it to flash. The fix is to test for equality and
- * do nothing.
- */
- if (text.equals (string)) return;
- super.setText (string);
- if ((style & (SWT.ARROW | SWT.SEPARATOR)) != 0) return;
-
- /*
- * Bug in Linux. In certain contexts setting the label of a
- * CHECK or RADIO menu item to the empty string can cause a
- * GP. The fix is to set the menu label to a space in such
- * cases since it displays equivalently.
- */
- if (OS.IsLinux && (style & (SWT.CHECK | SWT.RADIO)) != 0) {
- if (string.length () == 0) string = " ";
- }
- 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);
- /* Use the character encoding for the default locale */
- 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;
- /* Use the character encoding for the default locale */
- 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);
- if (mnemonic == 0) mnemonic = OS.XK_VoidSymbol;
- 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);
-}
-boolean translateAccelerator (int accel) {
- if (!getEnabled ()) return false;
- if (menu != null) return menu.translateAccelerator (accel);
- int accelerator = this.accelerator;
- if ((accelerator & SWT.KEYCODE_BIT) == 0) {
- int key = accelerator & SWT.KEY_MASK;
- if ('A' <= key && key <= 'Z') {
- key += 'a' - 'A';
- }
- int mods = accelerator & SWT.MODIFIER_MASK;
- accelerator = mods | key;
- }
- if (accelerator == accel) {
- postEvent (SWT.Selection);
- return true;
- }
- return false;
-}
-int XmNactivateCallback (int w, int client_data, int call_data) {
- if ((style & SWT.CASCADE) != 0) {
- postEvent (SWT.Arm);
- }
- if (!isEnabled ()) return 0;
- XmAnyCallbackStruct struct = new XmAnyCallbackStruct ();
- OS.memmove (struct, call_data, XmAnyCallbackStruct.sizeof);
- Event event = new Event ();
- if (struct.event != 0) {
- XButtonEvent xEvent = new XButtonEvent ();
- OS.memmove (xEvent, struct.event, XAnyEvent.sizeof);
- event.time = xEvent.time;
- switch (xEvent.type) {
- case OS.ButtonPress:
- case OS.ButtonRelease:
- case OS.KeyPress:
- case OS.KeyRelease:
- setInputState (event, xEvent);
- break;
- }
- }
- postEvent (SWT.Selection, event);
- return 0;
-}
-int XmNarmCallback (int w, int client_data, int call_data) {
- postEvent (SWT.Arm);
- return 0;
-}
-int XmNcascadingCallback (int w, int client_data, int call_data) {
- postEvent (SWT.Arm);
- return 0;
-}
-int XmNhelpCallback (int w, int client_data, int call_data) {
- if (hooks (SWT.Help)) {
- postEvent (SWT.Help);
- return 0;
- }
- parent.sendHelpEvent (call_data);
- return 0;
-}
-int XmNvalueChangedCallback (int w, int client_data, int call_data) {
- if (!isEnabled ()) return 0;
- XmAnyCallbackStruct struct = new XmAnyCallbackStruct ();
- OS.memmove (struct, call_data, XmAnyCallbackStruct.sizeof);
- Event event = new Event ();
- if (struct.event != 0) {
- XButtonEvent xEvent = new XButtonEvent ();
- OS.memmove (xEvent, struct.event, XAnyEvent.sizeof);
- event.time = xEvent.time;
- switch (xEvent.type) {
- case OS.ButtonPress:
- case OS.ButtonRelease:
- case OS.KeyPress:
- case OS.KeyRelease:
- setInputState (event, xEvent);
- break;
- }
- }
- if ((style & SWT.RADIO) != 0) {
- if ((parent.getStyle () & SWT.NO_RADIO_GROUP) == 0) {
- selectRadio ();
- }
- }
- postEvent (SWT.Selection, event);
- return 0;
-}
-
-}
+public void setSelection (boolean selected) {
+ checkWidget();
+ if ((style & (SWT.CHECK | SWT.RADIO)) == 0) return;
+ int [] argList = {OS.XmNset, selected ? OS.XmSET : OS.XmUNSET};
+ OS.XtSetValues (handle, argList, argList.length / 2);
+}
+public void setText (String string) {
+ checkWidget();
+ if (string == null) error (SWT.ERROR_NULL_ARGUMENT);
+ /*
+ * Feature in Motif. Motif does not optimize the case
+ * when the same text is set into a menu item causing
+ * it to flash. The fix is to test for equality and
+ * do nothing.
+ */
+ if (text.equals (string)) return;
+ super.setText (string);
+ if ((style & (SWT.ARROW | SWT.SEPARATOR)) != 0) return;
+
+ /*
+ * Bug in Linux. In certain contexts setting the label of a
+ * CHECK or RADIO menu item to the empty string can cause a
+ * GP. The fix is to set the menu label to a space in such
+ * cases since it displays equivalently.
+ */
+ if (OS.IsLinux && (style & (SWT.CHECK | SWT.RADIO)) != 0) {
+ if (string.length () == 0) string = " ";
+ }
+ 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);
+ /* Use the character encoding for the default locale */
+ 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;
+ /* Use the character encoding for the default locale */
+ 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);
+ if (mnemonic == 0) mnemonic = OS.XK_VoidSymbol;
+ 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);
+}
+boolean translateAccelerator (int accel) {
+ if (!getEnabled ()) return false;
+ if (menu != null) return menu.translateAccelerator (accel);
+ int accelerator = this.accelerator;
+ if ((accelerator & SWT.KEYCODE_BIT) == 0) {
+ int key = accelerator & SWT.KEY_MASK;
+ if ('A' <= key && key <= 'Z') {
+ key += 'a' - 'A';
+ }
+ int mods = accelerator & SWT.MODIFIER_MASK;
+ accelerator = mods | key;
+ }
+ if (accelerator == accel) {
+ postEvent (SWT.Selection);
+ return true;
+ }
+ return false;
+}
+int XmNactivateCallback (int w, int client_data, int call_data) {
+ if ((style & SWT.CASCADE) != 0) {
+ postEvent (SWT.Arm);
+ }
+ if (!isEnabled ()) return 0;
+ XmAnyCallbackStruct struct = new XmAnyCallbackStruct ();
+ OS.memmove (struct, call_data, XmAnyCallbackStruct.sizeof);
+ Event event = new Event ();
+ if (struct.event != 0) {
+ XButtonEvent xEvent = new XButtonEvent ();
+ OS.memmove (xEvent, struct.event, XAnyEvent.sizeof);
+ event.time = xEvent.time;
+ switch (xEvent.type) {
+ case OS.ButtonPress:
+ case OS.ButtonRelease:
+ case OS.KeyPress:
+ case OS.KeyRelease:
+ setInputState (event, xEvent);
+ break;
+ }
+ }
+ postEvent (SWT.Selection, event);
+ return 0;
+}
+int XmNarmCallback (int w, int client_data, int call_data) {
+ postEvent (SWT.Arm);
+ return 0;
+}
+int XmNcascadingCallback (int w, int client_data, int call_data) {
+ postEvent (SWT.Arm);
+ return 0;
+}
+int XmNhelpCallback (int w, int client_data, int call_data) {
+ if (hooks (SWT.Help)) {
+ postEvent (SWT.Help);
+ return 0;
+ }
+ parent.sendHelpEvent (call_data);
+ return 0;
+}
+int XmNvalueChangedCallback (int w, int client_data, int call_data) {
+ if (!isEnabled ()) return 0;
+ XmAnyCallbackStruct struct = new XmAnyCallbackStruct ();
+ OS.memmove (struct, call_data, XmAnyCallbackStruct.sizeof);
+ Event event = new Event ();
+ if (struct.event != 0) {
+ XButtonEvent xEvent = new XButtonEvent ();
+ OS.memmove (xEvent, struct.event, XAnyEvent.sizeof);
+ event.time = xEvent.time;
+ switch (xEvent.type) {
+ case OS.ButtonPress:
+ case OS.ButtonRelease:
+ case OS.KeyPress:
+ case OS.KeyRelease:
+ setInputState (event, xEvent);
+ break;
+ }
+ }
+ if ((style & SWT.RADIO) != 0) {
+ if ((parent.getStyle () & SWT.NO_RADIO_GROUP) == 0) {
+ selectRadio ();
+ }
+ }
+ postEvent (SWT.Selection, event);
+ return 0;
+}
+
+}
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
index d9609a1cfa..b2a2b8d0ab 100755
--- 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
@@ -1,67 +1,67 @@
-package org.eclipse.swt.widgets;
-
-/*
+package org.eclipse.swt.widgets;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-import org.eclipse.swt.internal.*;
-import org.eclipse.swt.internal.motif.*;
-import org.eclipse.swt.*;
-import org.eclipse.swt.graphics.*;
-
-/**
- * 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>
- * Note: Only one of the styles ICON_ERROR, ICON_INFORMATION, ICON_QUESTION,
- * ICON_WARNING and ICON_WORKING may be specified.
- * </p><p>
- * IMPORTANT: This class is intended to be subclassed <em>only</em>
- * within the SWT implementation.
- * </p>
+ * http://www.eclipse.org/legal/cpl-v10.html
*/
-public class MessageBox extends Dialog {
- int button;
- String message = "";
-
-/**
- * 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>
+
+import org.eclipse.swt.internal.*;
+import org.eclipse.swt.internal.motif.*;
+import org.eclipse.swt.*;
+import org.eclipse.swt.graphics.*;
+
+/**
+ * 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>
+ * Note: Only one of the styles ICON_ERROR, ICON_INFORMATION, ICON_QUESTION,
+ * ICON_WARNING and ICON_WORKING may be specified.
+ * </p><p>
+ * IMPORTANT: This class is intended to be subclassed <em>only</em>
+ * within the SWT implementation.
+ * </p>
+ */
+public class MessageBox extends Dialog {
+ int button;
+ String message = "";
+
+/**
+ * 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 MessageBox (Shell parent) {
- this (parent, SWT.OK | SWT.ICON_INFORMATION | SWT.APPLICATION_MODAL);
-}
-
+public MessageBox (Shell parent) {
+ this (parent, SWT.OK | SWT.ICON_INFORMATION | SWT.APPLICATION_MODAL);
+}
+
/**
* Constructs a new instance of this class given its parent
* and a style value describing its behavior and appearance.
@@ -92,322 +92,322 @@ public MessageBox (Shell parent) {
* <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
* </ul>
*/
-public MessageBox (Shell parent, int style) {
- super (parent, checkStyle (style));
- checkSubclass ();
-}
-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);
-}
-
-/**
- * Returns the dialog's message, which is a description of
- * the purpose for which it was opened. This message will be
- * visible on the dialog while it is open.
- *
- * @return the message
+public MessageBox (Shell parent, int style) {
+ super (parent, checkStyle (style));
+ checkSubclass ();
+}
+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);
+}
+
+/**
+ * Returns the dialog's message, which is a description of
+ * the purpose for which it was opened. This message will be
+ * visible on the dialog while it is open.
+ *
+ * @return the message
*/
-public String getMessage () {
- return message;
-}
-
-/**
- * Makes the dialog visible and brings it to the front
- * of the display.
- *
- * @return the ID of the button that was selected to dismiss the
- * message box (e.g. SWT.OK, SWT.CANCEL, etc...)
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the dialog has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the dialog</li>
- * </ul>
+public String getMessage () {
+ return message;
+}
+
+/**
+ * Makes the dialog visible and brings it to the front
+ * of the display.
+ *
+ * @return the ID of the button that was selected to dismiss the
+ * message box (e.g. SWT.OK, SWT.CANCEL, etc...)
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the dialog has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the dialog</li>
+ * </ul>
*/
-public int open () {
-
- /* Create the dialog.*/
- boolean destroyContext;
- Display appContext = Display.getCurrent ();
- if (destroyContext = (appContext == null)) appContext = new Display ();
- 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 = " ";
- /* Use the character encoding for the default locale */
- 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. */
- OS.XtManageChild (dialog);
-
- // 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 ();
-
- 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 */
- 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);
- /* Use the character encoding for the default locale */
- byte [] buffer1 = Converter.wcsToMbcs (null, SWT.getMessage("SWT_Yes"), true);
- int xmString1 = OS.XmStringParseText (
- buffer1,
- 0,
- OS.XmFONTLIST_DEFAULT_TAG,
- OS.XmCHARSET_TEXT,
- null,
- 0,
- 0);
- /* Use the character encoding for the default locale */
- byte [] buffer2 = Converter.wcsToMbcs (null, SWT.getMessage("SWT_No"), true);
- int xmString2 = OS.XmStringParseText (
- buffer2,
- 0,
- OS.XmFONTLIST_DEFAULT_TAG,
- OS.XmCHARSET_TEXT,
- null,
- 0,
- 0);
- /* Use the character encoding for the default locale */
- byte [] buffer3 = Converter.wcsToMbcs (null, SWT.getMessage("SWT_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)) {
- /* Use the character encoding for the default locale */
- byte [] buffer1 = Converter.wcsToMbcs (null, SWT.getMessage("SWT_Yes"), true);
- int xmString1 = OS.XmStringParseText (
- buffer1,
- 0,
- OS.XmFONTLIST_DEFAULT_TAG,
- OS.XmCHARSET_TEXT,
- null,
- 0,
- 0);
- /* Use the character encoding for the default locale */
- byte [] buffer2 = Converter.wcsToMbcs (null, SWT.getMessage("SWT_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)) {
- /* Use the character encoding for the default locale */
- byte [] buffer1 = Converter.wcsToMbcs (null, SWT.getMessage("SWT_Retry"), true);
- int xmString1 = OS.XmStringParseText (
- buffer1,
- 0,
- OS.XmFONTLIST_DEFAULT_TAG,
- OS.XmCHARSET_TEXT,
- null,
- 0,
- 0);
- /* Use the character encoding for the default locale */
- byte [] buffer2 = Converter.wcsToMbcs (null, SWT.getMessage("SWT_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);
- /* Use the character encoding for the default locale */
- byte [] buffer1 = Converter.wcsToMbcs (null, SWT.getMessage("SWT_Abort"), true);
- int xmString1 = OS.XmStringParseText (
- buffer1,
- 0,
- OS.XmFONTLIST_DEFAULT_TAG,
- OS.XmCHARSET_TEXT,
- null,
- 0,
- 0);
- /* Use the character encoding for the default locale */
- byte [] buffer2 = Converter.wcsToMbcs (null, SWT.getMessage("SWT_Retry"), true);
- int xmString2 = OS.XmStringParseText (
- buffer2,
- 0,
- OS.XmFONTLIST_DEFAULT_TAG,
- OS.XmCHARSET_TEXT,
- null,
- 0,
- 0);
- /* Use the character encoding for the default locale */
- byte [] buffer3 = Converter.wcsToMbcs (null, SWT.getMessage("SWT_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) {
- int [] argList = {OS.XmNfontList, 0};
- OS.XtGetValues (label, argList, argList.length / 2);
- int fontList = argList [1];
- if (fontList != 0) {
- Display display = parent.getDisplay ();
- int xDisplay = display.xDisplay;
- int screen = OS.XDefaultScreen (xDisplay);
- int width = OS.XDisplayWidth (xDisplay, screen);
- Font font = Font.motif_new (display, fontList);
- text = display.wrapText (message, font, width * 3 / 5);
- }
- }
- /* Use the character encoding for the default locale */
- byte [] buffer = Converter.wcsToMbcs (null, text, true);
- int xmString = OS.XmStringGenerate(buffer, null, OS.XmCHARSET_TEXT, null);
- int [] argList = {OS.XmNmessageString, xmString};
- OS.XtSetValues (dialogHandle, argList, argList.length / 2);
- OS.XmStringFree (xmString);
-}
-
-/**
- * Sets the dialog's message, which is a description of
- * the purpose for which it was opened. This message will be
- * visible on the dialog while it is open.
- *
- * @param string the message
+public int open () {
+
+ /* Create the dialog.*/
+ boolean destroyContext;
+ Display appContext = Display.getCurrent ();
+ if (destroyContext = (appContext == null)) appContext = new Display ();
+ 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 = " ";
+ /* Use the character encoding for the default locale */
+ 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. */
+ OS.XtManageChild (dialog);
+
+ // 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 ();
+
+ 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 */
+ 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);
+ /* Use the character encoding for the default locale */
+ byte [] buffer1 = Converter.wcsToMbcs (null, SWT.getMessage("SWT_Yes"), true);
+ int xmString1 = OS.XmStringParseText (
+ buffer1,
+ 0,
+ OS.XmFONTLIST_DEFAULT_TAG,
+ OS.XmCHARSET_TEXT,
+ null,
+ 0,
+ 0);
+ /* Use the character encoding for the default locale */
+ byte [] buffer2 = Converter.wcsToMbcs (null, SWT.getMessage("SWT_No"), true);
+ int xmString2 = OS.XmStringParseText (
+ buffer2,
+ 0,
+ OS.XmFONTLIST_DEFAULT_TAG,
+ OS.XmCHARSET_TEXT,
+ null,
+ 0,
+ 0);
+ /* Use the character encoding for the default locale */
+ byte [] buffer3 = Converter.wcsToMbcs (null, SWT.getMessage("SWT_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)) {
+ /* Use the character encoding for the default locale */
+ byte [] buffer1 = Converter.wcsToMbcs (null, SWT.getMessage("SWT_Yes"), true);
+ int xmString1 = OS.XmStringParseText (
+ buffer1,
+ 0,
+ OS.XmFONTLIST_DEFAULT_TAG,
+ OS.XmCHARSET_TEXT,
+ null,
+ 0,
+ 0);
+ /* Use the character encoding for the default locale */
+ byte [] buffer2 = Converter.wcsToMbcs (null, SWT.getMessage("SWT_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)) {
+ /* Use the character encoding for the default locale */
+ byte [] buffer1 = Converter.wcsToMbcs (null, SWT.getMessage("SWT_Retry"), true);
+ int xmString1 = OS.XmStringParseText (
+ buffer1,
+ 0,
+ OS.XmFONTLIST_DEFAULT_TAG,
+ OS.XmCHARSET_TEXT,
+ null,
+ 0,
+ 0);
+ /* Use the character encoding for the default locale */
+ byte [] buffer2 = Converter.wcsToMbcs (null, SWT.getMessage("SWT_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);
+ /* Use the character encoding for the default locale */
+ byte [] buffer1 = Converter.wcsToMbcs (null, SWT.getMessage("SWT_Abort"), true);
+ int xmString1 = OS.XmStringParseText (
+ buffer1,
+ 0,
+ OS.XmFONTLIST_DEFAULT_TAG,
+ OS.XmCHARSET_TEXT,
+ null,
+ 0,
+ 0);
+ /* Use the character encoding for the default locale */
+ byte [] buffer2 = Converter.wcsToMbcs (null, SWT.getMessage("SWT_Retry"), true);
+ int xmString2 = OS.XmStringParseText (
+ buffer2,
+ 0,
+ OS.XmFONTLIST_DEFAULT_TAG,
+ OS.XmCHARSET_TEXT,
+ null,
+ 0,
+ 0);
+ /* Use the character encoding for the default locale */
+ byte [] buffer3 = Converter.wcsToMbcs (null, SWT.getMessage("SWT_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) {
+ int [] argList = {OS.XmNfontList, 0};
+ OS.XtGetValues (label, argList, argList.length / 2);
+ int fontList = argList [1];
+ if (fontList != 0) {
+ Display display = parent.getDisplay ();
+ int xDisplay = display.xDisplay;
+ int screen = OS.XDefaultScreen (xDisplay);
+ int width = OS.XDisplayWidth (xDisplay, screen);
+ Font font = Font.motif_new (display, fontList);
+ text = display.wrapText (message, font, width * 3 / 5);
+ }
+ }
+ /* Use the character encoding for the default locale */
+ byte [] buffer = Converter.wcsToMbcs (null, text, true);
+ int xmString = OS.XmStringGenerate(buffer, null, OS.XmCHARSET_TEXT, null);
+ int [] argList = {OS.XmNmessageString, xmString};
+ OS.XtSetValues (dialogHandle, argList, argList.length / 2);
+ OS.XmStringFree (xmString);
+}
+
+/**
+ * Sets the dialog's message, which is a description of
+ * the purpose for which it was opened. This message will be
+ * visible on the dialog while it is open.
+ *
+ * @param string the message
*/
-public void setMessage (String string) {
- message = string;
-}
-}
+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
index a49debf6f5..d1a5fca885 100755
--- 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
@@ -1,38 +1,38 @@
-package org.eclipse.swt.widgets;
-
-/*
+package org.eclipse.swt.widgets;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-import org.eclipse.swt.internal.motif.*;
-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,
- * typically 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>
- * Note: Only one of the styles HORIZONTAL and VERTICAL may be specified.
- * </p><p>
- * IMPORTANT: This class is intended to be subclassed <em>only</em>
- * within the SWT implementation.
- * </p>
+ * http://www.eclipse.org/legal/cpl-v10.html
*/
-public class ProgressBar extends Control {
- int timerId;
- static final int DELAY = 100;
- int lastForeground = defaultForeground ();
-
+
+import org.eclipse.swt.internal.motif.*;
+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,
+ * typically 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>
+ * Note: Only one of the styles HORIZONTAL and VERTICAL may be specified.
+ * </p><p>
+ * IMPORTANT: This class is intended to be subclassed <em>only</em>
+ * within the SWT implementation.
+ * </p>
+ */
+public class ProgressBar extends Control {
+ int timerId;
+ static final int DELAY = 100;
+ int lastForeground = defaultForeground ();
+
/**
* Constructs a new instance of this class given its parent
* and a style value describing its behavior and appearance.
@@ -63,329 +63,329 @@ public class ProgressBar extends Control {
* @see Widget#checkSubclass
* @see Widget#getStyle
*/
-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);
-}
-public Point computeSize (int wHint, int hHint, boolean changed) {
- checkWidget();
- 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 background = defaultBackground ();
- int parentHandle = parent.handle;
- int [] argList = {
- OS.XmNshowArrows, 0,
- OS.XmNsliderSize, 1,
- OS.XmNtraversalOn, 0,
- OS.XmNtroughColor, background,
- OS.XmNtopShadowColor, background,
- OS.XmNbottomShadowColor, background,
- OS.XmNforeground, background,
- 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,
- OS.XmNancestorSensitive, 1,
- OS.XmNsliderVisual, OS.XmFOREGROUND_COLOR,
- };
- handle = OS.XmCreateScrollBar (parentHandle, null, argList, argList.length / 2);
- if (handle == 0) error (SWT.ERROR_NO_HANDLES);
- if ((style & SWT.INDETERMINATE) != 0) createTimer ();
-}
-void createTimer () {
- Display display = getDisplay ();
- int xDisplay = display.xDisplay;
- int windowTimerProc = display.windowTimerProc;
- int xtContext = OS.XtDisplayToApplicationContext (xDisplay);
- timerId = OS.XtAppAddTimeOut (xtContext, DELAY, windowTimerProc, handle);
-}
-void destroyTimer () {
- if (timerId != 0) OS.XtRemoveTimeOut (timerId);
- timerId = 0;
-}
-void disableButtonPress () {
- 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);
-}
-int getForegroundPixel () {
- boolean invisible = lastForeground != -1;
- if (invisible) return lastForeground;
- return super.getForegroundPixel ();
-}
-/**
- * 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 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);
+}
+public Point computeSize (int wHint, int hHint, boolean changed) {
+ checkWidget();
+ 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 background = defaultBackground ();
+ int parentHandle = parent.handle;
+ int [] argList = {
+ OS.XmNshowArrows, 0,
+ OS.XmNsliderSize, 1,
+ OS.XmNtraversalOn, 0,
+ OS.XmNtroughColor, background,
+ OS.XmNtopShadowColor, background,
+ OS.XmNbottomShadowColor, background,
+ OS.XmNforeground, background,
+ 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,
+ OS.XmNancestorSensitive, 1,
+ OS.XmNsliderVisual, OS.XmFOREGROUND_COLOR,
+ };
+ handle = OS.XmCreateScrollBar (parentHandle, null, argList, argList.length / 2);
+ if (handle == 0) error (SWT.ERROR_NO_HANDLES);
+ if ((style & SWT.INDETERMINATE) != 0) createTimer ();
+}
+void createTimer () {
+ Display display = getDisplay ();
+ int xDisplay = display.xDisplay;
+ int windowTimerProc = display.windowTimerProc;
+ int xtContext = OS.XtDisplayToApplicationContext (xDisplay);
+ timerId = OS.XtAppAddTimeOut (xtContext, DELAY, windowTimerProc, handle);
+}
+void destroyTimer () {
+ if (timerId != 0) OS.XtRemoveTimeOut (timerId);
+ timerId = 0;
+}
+void disableButtonPress () {
+ 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);
+}
+int getForegroundPixel () {
+ boolean invisible = lastForeground != -1;
+ if (invisible) return lastForeground;
+ return super.getForegroundPixel ();
+}
+/**
+ * Returns the maximum value which the receiver will allow.
+ *
+ * @return the maximum
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
*/
-public int getMaximum () {
- checkWidget();
- int [] argList = {OS.XmNmaximum, 0};
- OS.XtGetValues (handle, argList, argList.length / 2);
- return argList [1];
-}
-/**
- * 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 getMaximum () {
+ checkWidget();
+ int [] argList = {OS.XmNmaximum, 0};
+ OS.XtGetValues (handle, argList, argList.length / 2);
+ return argList [1];
+}
+/**
+ * Returns the minimum value which the receiver will allow.
+ *
+ * @return the minimum
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public int getMinimum () {
+ checkWidget();
+ int [] argList = {OS.XmNminimum, 0};
+ OS.XtGetValues (handle, argList, argList.length / 2);
+ return argList [1];
+}
+/**
+ * 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();
+ int [] argList = {
+ OS.XmNminimum, 0,
+ OS.XmNsliderSize, 0,
+ };
+ OS.XtGetValues (handle, argList, argList.length / 2);
+ int minimum = argList [1], sliderSize = argList [3];
+ boolean invisible = lastForeground != -1;
+ if (invisible) sliderSize = 0;
+ return minimum + sliderSize;
+}
+void propagateWidget (boolean enabled) {
+ super.propagateWidget (enabled);
+ if (enabled) disableButtonPress ();
+}
+void realizeChildren () {
+ super.realizeChildren ();
+ disableButtonPress ();
+}
+void releaseWidget () {
+ super.releaseWidget ();
+ destroyTimer ();
+}
+/**
+ * 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 IllegalArgumentException <ul>
+ * <li>ERROR_INVALID_ARGUMENT - if the argument has been disposed</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
*/
-public int getMinimum () {
- checkWidget();
- int [] argList = {OS.XmNminimum, 0};
- OS.XtGetValues (handle, argList, argList.length / 2);
- return argList [1];
-}
-/**
- * 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 void setBackground (Color color) {
+ checkWidget();
+ super.setBackground (color);
+ boolean invisible = lastForeground != -1;
+ if (invisible) {
+ int [] argList = {
+ OS.XmNtroughColor, 0
+ };
+ OS.XtGetValues (handle, argList, argList.length / 2);
+ setForegroundPixel (argList [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 IllegalArgumentException <ul>
+ * <li>ERROR_INVALID_ARGUMENT - if the argument has been disposed</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
*/
-public int getSelection () {
- checkWidget();
- int [] argList = {
- OS.XmNminimum, 0,
- OS.XmNsliderSize, 0,
- };
- OS.XtGetValues (handle, argList, argList.length / 2);
- int minimum = argList [1], sliderSize = argList [3];
- boolean invisible = lastForeground != -1;
- if (invisible) sliderSize = 0;
- return minimum + sliderSize;
-}
-void propagateWidget (boolean enabled) {
- super.propagateWidget (enabled);
- if (enabled) disableButtonPress ();
-}
-void realizeChildren () {
- super.realizeChildren ();
- disableButtonPress ();
-}
-void releaseWidget () {
- super.releaseWidget ();
- destroyTimer ();
-}
-/**
- * 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 IllegalArgumentException <ul>
- * <li>ERROR_INVALID_ARGUMENT - if the argument has been disposed</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public void setBackground (Color color) {
- checkWidget();
- super.setBackground (color);
- boolean invisible = lastForeground != -1;
- if (invisible) {
- int [] argList = {
- OS.XmNtroughColor, 0
- };
- OS.XtGetValues (handle, argList, argList.length / 2);
- setForegroundPixel (argList [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 IllegalArgumentException <ul>
- * <li>ERROR_INVALID_ARGUMENT - if the argument has been disposed</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public void setForeground (Color color) {
- checkWidget();
- boolean invisible = lastForeground != -1;
- if (invisible) {
- lastForeground = color.handle.pixel;
- } else {
- super.setForeground (color);
- }
-}
-/**
- * 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 setForeground (Color color) {
+ checkWidget();
+ boolean invisible = lastForeground != -1;
+ if (invisible) {
+ lastForeground = color.handle.pixel;
+ } else {
+ super.setForeground (color);
+ }
+}
+/**
+ * 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;
- 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 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 setMaximum (int value) {
+ checkWidget();
+ 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 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;
- 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 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 setMinimum (int value) {
+ checkWidget();
+ 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 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();
- 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) {
- int [] argList1 = new int [] {
- OS.XmNtroughColor, 0,
- OS.XmNminimum, 0,
- };
- OS.XtGetValues (handle, argList1, argList1.length / 2);
- int troughColor = argList1 [1];
-
- boolean invisible = lastForeground != -1;
- if (sliderSize == 0) {
- if (!invisible) {
- lastForeground = getForegroundPixel ();
- setForegroundPixel (troughColor);
- }
- } else {
- if (invisible) {
- setForegroundPixel (lastForeground);
- lastForeground = -1;
- }
- }
- int [] argList2 = new int [] {
- OS.XmNsliderSize, (sliderSize == 0) ? 1 : sliderSize,
- OS.XmNvalue, argList1 [3]
- };
-
- Display display = getDisplay ();
- boolean warnings = display.getWarnings ();
- display.setWarnings (false);
- OS.XtSetValues (handle, argList2, argList2.length / 2);
- display.setWarnings (warnings);
-}
-int timerProc (int id) {
- int minimum = getMinimum ();
- int range = getMaximum () - minimum + 1;
- int value = getSelection () - minimum + 1;
- setSelection (minimum + (value % range));
- createTimer ();
- return 0;
-}
-}
+public void setSelection (int value) {
+ checkWidget();
+ 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) {
+ int [] argList1 = new int [] {
+ OS.XmNtroughColor, 0,
+ OS.XmNminimum, 0,
+ };
+ OS.XtGetValues (handle, argList1, argList1.length / 2);
+ int troughColor = argList1 [1];
+
+ boolean invisible = lastForeground != -1;
+ if (sliderSize == 0) {
+ if (!invisible) {
+ lastForeground = getForegroundPixel ();
+ setForegroundPixel (troughColor);
+ }
+ } else {
+ if (invisible) {
+ setForegroundPixel (lastForeground);
+ lastForeground = -1;
+ }
+ }
+ int [] argList2 = new int [] {
+ OS.XmNsliderSize, (sliderSize == 0) ? 1 : sliderSize,
+ OS.XmNvalue, argList1 [3]
+ };
+
+ Display display = getDisplay ();
+ boolean warnings = display.getWarnings ();
+ display.setWarnings (false);
+ OS.XtSetValues (handle, argList2, argList2.length / 2);
+ display.setWarnings (warnings);
+}
+int timerProc (int id) {
+ int minimum = getMinimum ();
+ int range = getMaximum () - minimum + 1;
+ int value = getSelection () - minimum + 1;
+ setSelection (minimum + (value % range));
+ createTimer ();
+ return 0;
+}
+}
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
index a6974f77c4..198d9fbbbe 100755
--- 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
@@ -1,17 +1,17 @@
-package org.eclipse.swt.widgets;
-
-/*
+package org.eclipse.swt.widgets;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-import org.eclipse.swt.internal.motif.*;
-import org.eclipse.swt.*;
-import org.eclipse.swt.graphics.*;
-import org.eclipse.swt.events.*;
-
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+import org.eclipse.swt.internal.motif.*;
+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
@@ -29,15 +29,15 @@ import org.eclipse.swt.events.*;
* within the SWT implementation.
* </p>
*/
-public class Sash extends Control {
- boolean dragging;
- int startX, startY, lastX, lastY;
- int cursor;
-
- // constants
- private final static int INCREMENT = 1;
- private final static int PAGE_INCREMENT = 9;
-
+public class Sash extends Control {
+ boolean dragging;
+ int startX, startY, lastX, lastY;
+ int cursor;
+
+ // constants
+ private final static int INCREMENT = 1;
+ private final static int PAGE_INCREMENT = 9;
+
/**
* Constructs a new instance of this class given its parent
* and a style value describing its behavior and appearance.
@@ -67,344 +67,344 @@ public class Sash extends Control {
* @see Widget#checkSubclass
* @see Widget#getStyle
*/
-public Sash (Composite parent, int style) {
- super (parent, checkStyle (style));
-}
-
-/**
- * Adds the listener to the collection of listeners who will
- * be notified when the control is selected, by sending
- * it one of the messages defined in the <code>SelectionListener</code>
- * interface.
- * <p>
- * When <code>widgetSelected</code> is called, the x, y, width, and height fields of the event object are valid.
- * If the reciever is being dragged, the event object detail field contains the value <code>SWT.DRAG</code>.
- * <code>widgetDefaultSelected</code> is not called.
- * </p>
- *
- * @param listener the listener which should be notified
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see SelectionListener
- * @see #removeSelectionListener
- * @see SelectionEvent
+public 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.
+ * <p>
+ * When <code>widgetSelected</code> is called, the x, y, width, and height fields of the event object are valid.
+ * If the reciever is being dragged, the event object detail field contains the value <code>SWT.DRAG</code>.
+ * <code>widgetDefaultSelected</code> is not called.
+ * </p>
+ *
+ * @param listener the listener which should be notified
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see SelectionListener
+ * @see #removeSelectionListener
+ * @see SelectionEvent
*/
-public void addSelectionListener(SelectionListener listener) {
- checkWidget();
- if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
- TypedListener typedListener = new TypedListener(listener);
- addListener(SWT.Selection,typedListener);
- addListener(SWT.DefaultSelection,typedListener);
-}
-static int checkStyle (int style) {
- return checkBits (style, SWT.HORIZONTAL, SWT.VERTICAL, 0, 0, 0, 0);
-}
-public Point computeSize (int wHint, int hHint, boolean changed) {
- checkWidget();
- 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,
- OS.XmNancestorSensitive, 1,
- OS.XmNtraversalOn, 0,
- };
- int parentHandle = parent.handle;
- handle = OS.XmCreateDrawingArea (parentHandle, 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, 85, -86, 85, -86, 85, -86, 85};
- 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);
-}
-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 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 addSelectionListener(SelectionListener listener) {
+ checkWidget();
+ if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+ TypedListener typedListener = new TypedListener(listener);
+ addListener(SWT.Selection,typedListener);
+ addListener(SWT.DefaultSelection,typedListener);
+}
+static int checkStyle (int style) {
+ return checkBits (style, SWT.HORIZONTAL, SWT.VERTICAL, 0, 0, 0, 0);
+}
+public Point computeSize (int wHint, int hHint, boolean changed) {
+ checkWidget();
+ 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,
+ OS.XmNancestorSensitive, 1,
+ OS.XmNtraversalOn, 0,
+ };
+ int parentHandle = parent.handle;
+ handle = OS.XmCreateDrawingArea (parentHandle, 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, 85, -86, 85, -86, 85, -86, 85};
+ 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);
+}
+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 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);
-}
-public boolean setFocus () {
- checkWidget();
- int [] argList = new int [] {OS.XmNtraversalOn, 1};
- OS.XtSetValues (handle, argList, argList.length / 2);
- overrideTranslations ();
- if (super.setFocus ()) return true;
- argList [1] = 0;
- OS.XtSetValues (handle, argList, argList.length / 2);
- return false;
-}
-int XButtonPress (int w, int client_data, int call_data, int continue_to_dispatch) {
- int result = super.XButtonPress (w, client_data, call_data, continue_to_dispatch);
- if (result != 0) return result;
- XButtonEvent xEvent = new XButtonEvent ();
- OS.memmove (xEvent, call_data, XButtonEvent.sizeof);
- if (xEvent.button != 1) return result;
- 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;
- /* The event must be sent because its doit flag is used. */
- Event event = new Event ();
- event.detail = SWT.DRAG;
- event.time = xEvent.time;
- event.x = lastX; event.y = lastY;
- event.width = width; event.height = height;
- /*
- * It is possible (but unlikely) that client code could have disposed
- * the widget in the selection event. If this happens end the processing
- * of this message by returning.
- */
- sendEvent (SWT.Selection, event);
- if (isDisposed ()) return result;
- if (event.doit) {
- dragging = true;
- OS.XmUpdateDisplay (handle);
- drawBand (lastX = event.x, lastY = event.y, width, height);
- }
- return result;
-}
-int XButtonRelease (int w, int client_data, int call_data, int continue_to_dispatch) {
- int result = super.XButtonRelease (w, client_data, call_data, continue_to_dispatch);
- if (result != 0) return result;
- XButtonEvent xEvent = new XButtonEvent ();
- OS.memmove (xEvent, call_data, XButtonEvent.sizeof);
- if (xEvent.button != 1) return result;
- if (!dragging) return result;
- 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);
- /* The event must be sent because its doit flag is used. */
- 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);
- /* widget could be disposed here */
- return result;
-}
-int xFocusIn () {
- int result = super.xFocusIn ();
- if (handle == 0) return result;
- int [] argList = {OS.XmNx, 0, OS.XmNy, 0};
- OS.XtGetValues (handle, argList, argList.length / 2);
- lastX = argList [1];
- lastY = argList [3];
- return result;
-}
-
-int xFocusOut () {
- int result = super.xFocusOut ();
- if (handle == 0) return result;
- int [] argList = new int [] {OS.XmNtraversalOn, 0};
- OS.XtSetValues (handle, argList, argList.length / 2);
- return result;
-}
-int XKeyPress (int w, int client_data, int call_data, int continue_to_dispatch) {
- int result = super.XKeyPress (w, client_data, call_data, continue_to_dispatch);
- if (result != 0) return result;
- XKeyEvent xEvent = new XKeyEvent ();
- OS.memmove (xEvent, call_data, XKeyEvent.sizeof);
- byte [] buffer = new byte [1];
- int [] keysym = new int [1];
- OS.XLookupString (xEvent, buffer, buffer.length, keysym, null);
-
- switch (keysym [0]) {
- case OS.XK_Left:
- case OS.XK_Right:
- case OS.XK_Up:
- case OS.XK_Down:
- int xChange = 0, yChange = 0;
- int stepSize = PAGE_INCREMENT;
- if ((xEvent.state & OS.ControlMask) != 0) stepSize = INCREMENT;
- if ((style & SWT.VERTICAL) != 0) {
- if (keysym [0] == OS.XK_Up || keysym [0] == OS.XK_Down) break;
- xChange = keysym [0] == OS.XK_Left ? -stepSize : stepSize;
- } else {
- if (keysym [0] == OS.XK_Left || keysym [0] == OS.XK_Right) break;
- yChange = keysym [0] == OS.XK_Up ? -stepSize : stepSize;
- }
-
- int [] argList1 = {OS.XmNwidth, 0, OS.XmNheight, 0, OS.XmNborderWidth, 0};
- OS.XtGetValues (handle, argList1, argList1.length / 2);
- int border = argList1 [5];
- int width = argList1 [1] + (border * 2), height = argList1 [3] + (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, lastX + xChange - parentBorder - startX), parentWidth - width);
- } else {
- newY = Math.min (Math.max (0, lastY + yChange - parentBorder - startY), parentHeight - height);
- }
- if (newX == lastX && newY == lastY) return result;
-
- /* Ensure that the pointer image does not change */
- int xDisplay = getDisplay().xDisplay;
- int xWindow = OS.XtWindow (parent.handle);
- int ptrGrabResult = OS.XGrabPointer (
- xDisplay,
- xWindow,
- 1,
- OS.None,
- OS.GrabModeAsync,
- OS.GrabModeAsync,
- OS.None,
- cursor,
- OS.CurrentTime);
-
- /* The event must be sent because its doit flag is used. */
- Event event = new Event ();
- event.time = xEvent.time;
- event.x = newX; event.y = newY;
- event.width = width; event.height = height;
- sendEvent (SWT.Selection, event);
- if (ptrGrabResult == OS.GrabSuccess) OS.XUngrabPointer (xDisplay, OS.CurrentTime);
-
- /*
- * It is possible (but unlikely) that client code could have disposed
- * the widget in the selection event. If this happens end the processing
- * of this message by returning.
- */
- if (isDisposed ()) break;
- if (event.doit) {
- lastX = event.x; lastY = event.y;
- /* Adjust the pointer position */
- int cursorX = newX; int cursorY = newY;
- if ((style & SWT.VERTICAL) != 0) {
- cursorY += height / 2;
- } else {
- cursorX += width / 2;
- }
- OS.XWarpPointer (xDisplay, OS.None, xWindow, 0, 0, 0, 0, cursorX, cursorY);
- }
- break;
- }
-
- return result;
-}
-int XPointerMotion (int w, int client_data, int call_data, int continue_to_dispatch) {
- int result = super.XPointerMotion (w, client_data, call_data, continue_to_dispatch);
- if (result != 0) return result;
- XMotionEvent xEvent = new XMotionEvent ();
- OS.memmove (xEvent, call_data, XMotionEvent.sizeof);
- if (!dragging || (xEvent.state & OS.Button1Mask) == 0) return result;
- 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 result;
- drawBand (lastX, lastY, width, height);
- /* The event must be sent because its doit flag is used. */
- Event event = new Event ();
- event.detail = SWT.DRAG;
- event.time = xEvent.time;
- event.x = newX; event.y = newY;
- event.width = width; event.height = height;
- /*
- * It is possible (but unlikely) that client code could have disposed
- * the widget in the selection event. If this happens end the processing
- * of this message by returning.
- */
- sendEvent (SWT.Selection, event);
- if (isDisposed ()) return result;
- if (event.doit) {
- lastX = event.x; lastY = event.y;
- OS.XmUpdateDisplay (handle);
- drawBand (lastX, lastY, width, height);
- }
- return result;
-}
-}
+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);
+}
+public boolean setFocus () {
+ checkWidget();
+ int [] argList = new int [] {OS.XmNtraversalOn, 1};
+ OS.XtSetValues (handle, argList, argList.length / 2);
+ overrideTranslations ();
+ if (super.setFocus ()) return true;
+ argList [1] = 0;
+ OS.XtSetValues (handle, argList, argList.length / 2);
+ return false;
+}
+int XButtonPress (int w, int client_data, int call_data, int continue_to_dispatch) {
+ int result = super.XButtonPress (w, client_data, call_data, continue_to_dispatch);
+ if (result != 0) return result;
+ XButtonEvent xEvent = new XButtonEvent ();
+ OS.memmove (xEvent, call_data, XButtonEvent.sizeof);
+ if (xEvent.button != 1) return result;
+ 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;
+ /* The event must be sent because its doit flag is used. */
+ Event event = new Event ();
+ event.detail = SWT.DRAG;
+ event.time = xEvent.time;
+ event.x = lastX; event.y = lastY;
+ event.width = width; event.height = height;
+ /*
+ * It is possible (but unlikely) that client code could have disposed
+ * the widget in the selection event. If this happens end the processing
+ * of this message by returning.
+ */
+ sendEvent (SWT.Selection, event);
+ if (isDisposed ()) return result;
+ if (event.doit) {
+ dragging = true;
+ OS.XmUpdateDisplay (handle);
+ drawBand (lastX = event.x, lastY = event.y, width, height);
+ }
+ return result;
+}
+int XButtonRelease (int w, int client_data, int call_data, int continue_to_dispatch) {
+ int result = super.XButtonRelease (w, client_data, call_data, continue_to_dispatch);
+ if (result != 0) return result;
+ XButtonEvent xEvent = new XButtonEvent ();
+ OS.memmove (xEvent, call_data, XButtonEvent.sizeof);
+ if (xEvent.button != 1) return result;
+ if (!dragging) return result;
+ 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);
+ /* The event must be sent because its doit flag is used. */
+ 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);
+ /* widget could be disposed here */
+ return result;
+}
+int xFocusIn () {
+ int result = super.xFocusIn ();
+ if (handle == 0) return result;
+ int [] argList = {OS.XmNx, 0, OS.XmNy, 0};
+ OS.XtGetValues (handle, argList, argList.length / 2);
+ lastX = argList [1];
+ lastY = argList [3];
+ return result;
+}
+
+int xFocusOut () {
+ int result = super.xFocusOut ();
+ if (handle == 0) return result;
+ int [] argList = new int [] {OS.XmNtraversalOn, 0};
+ OS.XtSetValues (handle, argList, argList.length / 2);
+ return result;
+}
+int XKeyPress (int w, int client_data, int call_data, int continue_to_dispatch) {
+ int result = super.XKeyPress (w, client_data, call_data, continue_to_dispatch);
+ if (result != 0) return result;
+ XKeyEvent xEvent = new XKeyEvent ();
+ OS.memmove (xEvent, call_data, XKeyEvent.sizeof);
+ byte [] buffer = new byte [1];
+ int [] keysym = new int [1];
+ OS.XLookupString (xEvent, buffer, buffer.length, keysym, null);
+
+ switch (keysym [0]) {
+ case OS.XK_Left:
+ case OS.XK_Right:
+ case OS.XK_Up:
+ case OS.XK_Down:
+ int xChange = 0, yChange = 0;
+ int stepSize = PAGE_INCREMENT;
+ if ((xEvent.state & OS.ControlMask) != 0) stepSize = INCREMENT;
+ if ((style & SWT.VERTICAL) != 0) {
+ if (keysym [0] == OS.XK_Up || keysym [0] == OS.XK_Down) break;
+ xChange = keysym [0] == OS.XK_Left ? -stepSize : stepSize;
+ } else {
+ if (keysym [0] == OS.XK_Left || keysym [0] == OS.XK_Right) break;
+ yChange = keysym [0] == OS.XK_Up ? -stepSize : stepSize;
+ }
+
+ int [] argList1 = {OS.XmNwidth, 0, OS.XmNheight, 0, OS.XmNborderWidth, 0};
+ OS.XtGetValues (handle, argList1, argList1.length / 2);
+ int border = argList1 [5];
+ int width = argList1 [1] + (border * 2), height = argList1 [3] + (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, lastX + xChange - parentBorder - startX), parentWidth - width);
+ } else {
+ newY = Math.min (Math.max (0, lastY + yChange - parentBorder - startY), parentHeight - height);
+ }
+ if (newX == lastX && newY == lastY) return result;
+
+ /* Ensure that the pointer image does not change */
+ int xDisplay = getDisplay().xDisplay;
+ int xWindow = OS.XtWindow (parent.handle);
+ int ptrGrabResult = OS.XGrabPointer (
+ xDisplay,
+ xWindow,
+ 1,
+ OS.None,
+ OS.GrabModeAsync,
+ OS.GrabModeAsync,
+ OS.None,
+ cursor,
+ OS.CurrentTime);
+
+ /* The event must be sent because its doit flag is used. */
+ Event event = new Event ();
+ event.time = xEvent.time;
+ event.x = newX; event.y = newY;
+ event.width = width; event.height = height;
+ sendEvent (SWT.Selection, event);
+ if (ptrGrabResult == OS.GrabSuccess) OS.XUngrabPointer (xDisplay, OS.CurrentTime);
+
+ /*
+ * It is possible (but unlikely) that client code could have disposed
+ * the widget in the selection event. If this happens end the processing
+ * of this message by returning.
+ */
+ if (isDisposed ()) break;
+ if (event.doit) {
+ lastX = event.x; lastY = event.y;
+ /* Adjust the pointer position */
+ int cursorX = newX; int cursorY = newY;
+ if ((style & SWT.VERTICAL) != 0) {
+ cursorY += height / 2;
+ } else {
+ cursorX += width / 2;
+ }
+ OS.XWarpPointer (xDisplay, OS.None, xWindow, 0, 0, 0, 0, cursorX, cursorY);
+ }
+ break;
+ }
+
+ return result;
+}
+int XPointerMotion (int w, int client_data, int call_data, int continue_to_dispatch) {
+ int result = super.XPointerMotion (w, client_data, call_data, continue_to_dispatch);
+ if (result != 0) return result;
+ XMotionEvent xEvent = new XMotionEvent ();
+ OS.memmove (xEvent, call_data, XMotionEvent.sizeof);
+ if (!dragging || (xEvent.state & OS.Button1Mask) == 0) return result;
+ 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 result;
+ drawBand (lastX, lastY, width, height);
+ /* The event must be sent because its doit flag is used. */
+ Event event = new Event ();
+ event.detail = SWT.DRAG;
+ event.time = xEvent.time;
+ event.x = newX; event.y = newY;
+ event.width = width; event.height = height;
+ /*
+ * It is possible (but unlikely) that client code could have disposed
+ * the widget in the selection event. If this happens end the processing
+ * of this message by returning.
+ */
+ sendEvent (SWT.Selection, event);
+ if (isDisposed ()) return result;
+ if (event.doit) {
+ lastX = event.x; lastY = event.y;
+ OS.XmUpdateDisplay (handle);
+ drawBand (lastX, lastY, width, height);
+ }
+ return result;
+}
+}
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
index 2c8baea84f..b346ac3429 100755
--- 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
@@ -1,17 +1,17 @@
-package org.eclipse.swt.widgets;
-
-/*
+package org.eclipse.swt.widgets;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-import org.eclipse.swt.internal.motif.*;
-import org.eclipse.swt.*;
-import org.eclipse.swt.events.*;
-import org.eclipse.swt.graphics.*;
-
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+import org.eclipse.swt.internal.motif.*;
+import org.eclipse.swt.*;
+import org.eclipse.swt.events.*;
+import org.eclipse.swt.graphics.*;
+
/**
* Instances of the receiver represent a selectable user
* interface object that present a range of continuous
@@ -30,7 +30,7 @@ import org.eclipse.swt.graphics.*;
* within the SWT implementation.
* </p>
*/
-public class Scale extends Control {
+public class Scale extends Control {
/**
* Constructs a new instance of this class given its parent
* and a style value describing its behavior and appearance.
@@ -60,296 +60,296 @@ public class Scale extends Control {
* @see Widget#checkSubclass
* @see Widget#getStyle
*/
-public Scale (Composite parent, int style) {
- super (parent, checkStyle (style));
-}
-
-/**
- * Adds the listener to the collection of listeners who will
- * be notified when the 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 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);
-}
-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;
- 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,
- OS.XmNancestorSensitive, 1,
- };
- int parentHandle = parent.handle;
- handle = OS.XmCreateScale (parentHandle, null, argList, argList.length / 2);
- if (handle == 0) error (SWT.ERROR_NO_HANDLES);
-}
-/**
- * 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 void addSelectionListener(SelectionListener listener) {
+ checkWidget();
+ if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+ TypedListener typedListener = new TypedListener(listener);
+ addListener(SWT.Selection,typedListener);
+ addListener(SWT.DefaultSelection,typedListener);
+}
+static int checkStyle (int style) {
+ return checkBits (style, SWT.HORIZONTAL, SWT.VERTICAL, 0, 0, 0, 0);
+}
+public Point computeSize (int wHint, int hHint, boolean changed) {
+ checkWidget();
+ 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,
+ OS.XmNancestorSensitive, 1,
+ };
+ int parentHandle = parent.handle;
+ handle = OS.XmCreateScale (parentHandle, null, argList, argList.length / 2);
+ if (handle == 0) error (SWT.ERROR_NO_HANDLES);
+}
+/**
+ * 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 1;
-}
-/**
- * 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 getIncrement () {
+ checkWidget();
+ return 1;
+}
+/**
+ * Returns the maximum value which the receiver will allow.
+ *
+ * @return the maximum
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
*/
-public int getMaximum () {
- checkWidget();
- int [] argList = {OS.XmNmaximum, 0};
- OS.XtGetValues (handle, argList, argList.length / 2);
- return argList [1];
-}
-/**
- * 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 getMaximum () {
+ checkWidget();
+ int [] argList = {OS.XmNmaximum, 0};
+ OS.XtGetValues (handle, argList, argList.length / 2);
+ return argList [1];
+}
+/**
+ * Returns the minimum value which the receiver will allow.
+ *
+ * @return the minimum
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
*/
-public int getMinimum () {
- checkWidget();
- int [] argList = {OS.XmNminimum, 0};
- OS.XtGetValues (handle, argList, argList.length / 2);
- return argList [1];
-}
-/**
- * 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 getMinimum () {
+ checkWidget();
+ int [] argList = {OS.XmNminimum, 0};
+ OS.XtGetValues (handle, argList, argList.length / 2);
+ return argList [1];
+}
+/**
+ * Returns the amount that the receiver's value will be
+ * modified by when the page increment/decrement areas
+ * are selected.
+ *
+ * @return the page increment
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
*/
-public int getPageIncrement () {
- checkWidget();
- int [] argList = {OS.XmNscaleMultiple, 0};
- OS.XtGetValues (handle, argList, argList.length / 2);
- return argList [1];
-}
-/**
- * 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 getPageIncrement () {
+ checkWidget();
+ int [] argList = {OS.XmNscaleMultiple, 0};
+ OS.XtGetValues (handle, argList, argList.length / 2);
+ return argList [1];
+}
+/**
+ * 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();
- 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, VALUE_CHANGED_CALLBACK);
- OS.XtAddCallback (handle, OS.XmNdragCallback, windowProc, DRAG_CALLBACK);
-}
-void overrideTranslations () {
- Display display = getDisplay ();
- OS.XtOverrideTranslations (handle, display.tabTranslations);
-}
-/**
- * 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 int getSelection () {
+ checkWidget();
+ 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, VALUE_CHANGED_CALLBACK);
+ OS.XtAddCallback (handle, OS.XmNdragCallback, windowProc, DRAG_CALLBACK);
+}
+void overrideTranslations () {
+ Display display = getDisplay ();
+ OS.XtOverrideTranslations (handle, display.tabTranslations);
+}
+/**
+ * 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 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();
-}
-/**
- * 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 setIncrement (int increment) {
+ checkWidget();
+}
+/**
+ * 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;
- 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 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 setMaximum (int value) {
+ checkWidget();
+ 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 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;
- 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 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 setMinimum (int value) {
+ checkWidget();
+ 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 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 [] 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 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 setPageIncrement (int pageIncrement) {
+ checkWidget();
+ 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 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) {
- checkWidget();
- 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);
-}
-int XmNdragCallback (int w, int client_data, int call_data) {
- postEvent (SWT.Selection);
- return 0;
-}
-int XmNvalueChangedCallback (int w, int client_data, int call_data) {
- postEvent (SWT.Selection);
- return 0;
-}
-}
+public void setSelection (int selection) {
+ checkWidget();
+ 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);
+}
+int XmNdragCallback (int w, int client_data, int call_data) {
+ postEvent (SWT.Selection);
+ return 0;
+}
+int XmNvalueChangedCallback (int w, int client_data, int call_data) {
+ postEvent (SWT.Selection);
+ return 0;
+}
+}
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
index aa747274b5..8887ae6463 100755
--- 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
@@ -1,17 +1,17 @@
-package org.eclipse.swt.widgets;
-
-/*
+package org.eclipse.swt.widgets;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-import org.eclipse.swt.internal.motif.*;
-import org.eclipse.swt.*;
-import org.eclipse.swt.graphics.*;
-import org.eclipse.swt.events.*;
-
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+import org.eclipse.swt.internal.motif.*;
+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.
@@ -75,608 +75,608 @@ import org.eclipse.swt.events.*;
* @see Scrollable#getHorizontalBar
* @see Scrollable#getVerticalBar
*/
-public 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 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.
- * <p>
- * When <code>widgetSelected</code> is called, the event object detail field contains one of the following values:
- * <code>0</code> - for the end of a drag.
- * <code>SWT.DRAG</code>.
- * <code>SWT.HOME</code>.
- * <code>SWT.END</code>.
- * <code>SWT.ARROW_DOWN</code>.
- * <code>SWT.ARROW_UP</code>.
- * <code>SWT.PAGE_DOWN</code>.
- * <code>SWT.PAGE_UP</code>.
- * <code>widgetDefaultSelected</code> is not called.
- * </p>
- *
- * @param listener the listener which should be notified
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see SelectionListener
- * @see #removeSelectionListener
- * @see SelectionEvent
+public 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 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.
+ * <p>
+ * When <code>widgetSelected</code> is called, the event object detail field contains one of the following values:
+ * <code>0</code> - for the end of a drag.
+ * <code>SWT.DRAG</code>.
+ * <code>SWT.HOME</code>.
+ * <code>SWT.END</code>.
+ * <code>SWT.ARROW_DOWN</code>.
+ * <code>SWT.ARROW_UP</code>.
+ * <code>SWT.PAGE_DOWN</code>.
+ * <code>SWT.PAGE_UP</code>.
+ * <code>widgetDefaultSelected</code> is not called.
+ * </p>
+ *
+ * @param listener the listener which should be notified
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see SelectionListener
+ * @see #removeSelectionListener
+ * @see SelectionEvent
*/
-public void addSelectionListener(SelectionListener listener) {
- checkWidget();
- if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
- TypedListener typedListener = new TypedListener(listener);
- addListener(SWT.Selection,typedListener);
- addListener(SWT.DefaultSelection,typedListener);
-}
-static int checkStyle (int style) {
- return checkBits (style, SWT.HORIZONTAL, SWT.VERTICAL, 0, 0, 0, 0);
-}
-void createHandle (int index) {
- state |= HANDLE;
- int [] argList = {
- OS.XmNancestorSensitive, 1,
- OS.XmNborderWidth, (style & SWT.BORDER) != 0 ? 1 : 0,
- OS.XmNorientation, ((style & SWT.H_SCROLL) != 0) ? OS.XmHORIZONTAL : OS.XmVERTICAL,
- OS.XmNtraversalOn, 0,
- };
- int parentHandle = parent.scrolledHandle;
- handle = OS.XmCreateScrollBar (parentHandle, null, argList, argList.length / 2);
- if (handle == 0) error (SWT.ERROR_NO_HANDLES);
-}
-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 void addSelectionListener(SelectionListener listener) {
+ checkWidget();
+ if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+ TypedListener typedListener = new TypedListener(listener);
+ addListener(SWT.Selection,typedListener);
+ addListener(SWT.DefaultSelection,typedListener);
+}
+static int checkStyle (int style) {
+ return checkBits (style, SWT.HORIZONTAL, SWT.VERTICAL, 0, 0, 0, 0);
+}
+void createHandle (int index) {
+ state |= HANDLE;
+ int [] argList = {
+ OS.XmNancestorSensitive, 1,
+ OS.XmNborderWidth, (style & SWT.BORDER) != 0 ? 1 : 0,
+ OS.XmNorientation, ((style & SWT.H_SCROLL) != 0) ? OS.XmHORIZONTAL : OS.XmVERTICAL,
+ OS.XmNtraversalOn, 0,
+ };
+ int parentHandle = parent.scrolledHandle;
+ handle = OS.XmCreateScrollBar (parentHandle, null, argList, argList.length / 2);
+ if (handle == 0) error (SWT.ERROR_NO_HANDLES);
+}
+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 () {
- checkWidget();
- int [] argList = {OS.XmNsensitive, 0};
- OS.XtGetValues (handle, argList, argList.length / 2);
- return argList [1] != 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 boolean getEnabled () {
+ checkWidget();
+ int [] argList = {OS.XmNsensitive, 0};
+ OS.XtGetValues (handle, argList, argList.length / 2);
+ return argList [1] != 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();
- int [] argList = {OS.XmNincrement, 0};
- OS.XtGetValues (handle, argList, argList.length / 2);
- return argList [1];
-}
-/**
- * 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 getIncrement () {
+ checkWidget();
+ int [] argList = {OS.XmNincrement, 0};
+ OS.XtGetValues (handle, argList, argList.length / 2);
+ return argList [1];
+}
+/**
+ * Returns the maximum value which the receiver will allow.
+ *
+ * @return the maximum
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
*/
-public int getMaximum () {
- checkWidget();
- int [] argList = {OS.XmNmaximum, 0};
- OS.XtGetValues (handle, argList, argList.length / 2);
- return argList [1];
-}
-/**
- * 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 getMaximum () {
+ checkWidget();
+ int [] argList = {OS.XmNmaximum, 0};
+ OS.XtGetValues (handle, argList, argList.length / 2);
+ return argList [1];
+}
+/**
+ * Returns the minimum value which the receiver will allow.
+ *
+ * @return the minimum
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
*/
-public int getMinimum () {
- checkWidget();
- int [] argList = {OS.XmNminimum, 0};
- OS.XtGetValues (handle, argList, argList.length / 2);
- return argList [1];
-}
-/**
- * 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 getMinimum () {
+ checkWidget();
+ int [] argList = {OS.XmNminimum, 0};
+ OS.XtGetValues (handle, argList, argList.length / 2);
+ return argList [1];
+}
+/**
+ * Returns the amount that the receiver's value will be
+ * modified by when the page increment/decrement areas
+ * are selected.
+ *
+ * @return the page increment
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
*/
-public int getPageIncrement () {
- checkWidget();
- int [] argList = {OS.XmNpageIncrement, 0};
- OS.XtGetValues (handle, argList, argList.length / 2);
- return argList [1];
-}
-/**
- * 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 int getPageIncrement () {
+ checkWidget();
+ int [] argList = {OS.XmNpageIncrement, 0};
+ OS.XtGetValues (handle, argList, argList.length / 2);
+ return argList [1];
+}
+/**
+ * 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 () {
- checkWidget();
- 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 Scrollable getParent () {
+ checkWidget();
+ 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 () {
- checkWidget();
- int [] argList = {OS.XmNvalue, 0};
- OS.XtGetValues (handle, argList, argList.length / 2);
- return argList [1];
-}
-/**
- * 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 int getSelection () {
+ checkWidget();
+ int [] argList = {OS.XmNvalue, 0};
+ OS.XtGetValues (handle, argList, argList.length / 2);
+ return argList [1];
+}
+/**
+ * Returns a point describing the receiver's size. The
+ * x coordinate of the result is the width of the receiver.
+ * The y coordinate of the result is the height of the
+ * receiver.
+ *
+ * @return the receiver's size
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
*/
-public Point getSize () {
- checkWidget();
- int [] 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);
-}
-/**
- * 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 Point getSize () {
+ checkWidget();
+ 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);
+}
+/**
+ * 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 () {
- checkWidget();
- int [] argList = {OS.XmNsliderSize, 0};
- OS.XtGetValues (handle, argList, argList.length / 2);
- return argList [1];
-}
-/**
- * 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 int getThumb () {
+ checkWidget();
+ int [] argList = {OS.XmNsliderSize, 0};
+ OS.XtGetValues (handle, argList, argList.length / 2);
+ return argList [1];
+}
+/**
+ * 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 OS.XtIsManaged (handle);
-}
-void hookEvents () {
- int windowProc = getDisplay ().windowProc;
- OS.XtAddCallback (handle, OS.XmNvalueChangedCallback, windowProc, VALUE_CHANGED_CALLBACK);
- OS.XtAddCallback (handle, OS.XmNdragCallback, windowProc, DRAG_CALLBACK);
- OS.XtAddCallback (handle, OS.XmNtoBottomCallback, windowProc, TO_BOTTOM_CALLBACK);
- OS.XtAddCallback (handle, OS.XmNtoTopCallback, windowProc, TO_TOP_CALLBACK);
- OS.XtAddCallback (handle, OS.XmNincrementCallback, windowProc, INCREMENT_CALLBACK);
- OS.XtAddCallback (handle, OS.XmNdecrementCallback, windowProc, DECREMENT_CALLBACK);
- OS.XtAddCallback (handle, OS.XmNpageIncrementCallback, windowProc, PAGE_INCREMENT_CALLBACK);
- OS.XtAddCallback (handle, OS.XmNpageDecrementCallback, windowProc, PAGE_DECREMENT_CALLBACK);
-}
-/**
- * Returns <code>true</code> if the receiver is enabled and all
- * of the receiver's ancestors are enabled, and <code>false</code>
- * otherwise. A disabled control is typically not selectable from the
- * user interface and draws with an inactive or "grayed" look.
- *
- * @return the receiver's enabled state
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see #getEnabled
+public boolean getVisible () {
+ checkWidget();
+ return OS.XtIsManaged (handle);
+}
+void hookEvents () {
+ int windowProc = getDisplay ().windowProc;
+ OS.XtAddCallback (handle, OS.XmNvalueChangedCallback, windowProc, VALUE_CHANGED_CALLBACK);
+ OS.XtAddCallback (handle, OS.XmNdragCallback, windowProc, DRAG_CALLBACK);
+ OS.XtAddCallback (handle, OS.XmNtoBottomCallback, windowProc, TO_BOTTOM_CALLBACK);
+ OS.XtAddCallback (handle, OS.XmNtoTopCallback, windowProc, TO_TOP_CALLBACK);
+ OS.XtAddCallback (handle, OS.XmNincrementCallback, windowProc, INCREMENT_CALLBACK);
+ OS.XtAddCallback (handle, OS.XmNdecrementCallback, windowProc, DECREMENT_CALLBACK);
+ OS.XtAddCallback (handle, OS.XmNpageIncrementCallback, windowProc, PAGE_INCREMENT_CALLBACK);
+ OS.XtAddCallback (handle, OS.XmNpageDecrementCallback, windowProc, PAGE_DECREMENT_CALLBACK);
+}
+/**
+ * Returns <code>true</code> if the receiver is enabled and all
+ * of the receiver's ancestors are enabled, and <code>false</code>
+ * otherwise. A disabled control is typically not selectable from the
+ * user interface and draws with an inactive or "grayed" look.
+ *
+ * @return the receiver's enabled state
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see #getEnabled
*/
-public boolean isEnabled () {
- checkWidget();
- return getEnabled () && parent.isEnabled ();
-}
-/**
- * Returns <code>true</code> if the receiver is visible and all
- * of the receiver's ancestors are visible and <code>false</code>
- * otherwise.
- *
- * @return the receiver's visibility state
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see #getVisible
+public boolean isEnabled () {
+ checkWidget();
+ return getEnabled () && parent.isEnabled ();
+}
+/**
+ * Returns <code>true</code> if the receiver is visible and all
+ * of the receiver's ancestors are visible and <code>false</code>
+ * otherwise.
+ *
+ * @return the receiver's visibility state
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see #getVisible
*/
-public boolean isVisible () {
- checkWidget();
- return getVisible () && parent.isVisible ();
-}
-void manageChildren () {
- OS.XtManageChild (handle);
-}
-void propagateWidget (boolean enabled) {
- propagateHandle (enabled, handle);
-}
-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 boolean isVisible () {
+ checkWidget();
+ return getVisible () && parent.isVisible ();
+}
+void manageChildren () {
+ OS.XtManageChild (handle);
+}
+void propagateWidget (boolean enabled) {
+ propagateHandle (enabled, handle);
+}
+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) {
- checkWidget();
- if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
- if (eventTable == null) return;
- eventTable.unhook(SWT.Selection, listener);
- eventTable.unhook(SWT.DefaultSelection,listener);
-}
-void sendScrollEvent (int detail) {
- Event event = new Event ();
- event.detail = detail;
- sendEvent (SWT.Selection, event);
- /*
- * Feature in Motif. When a scroll bar is selected,
- * it does not make the shell active. The fix is to
- * make the shell active.
- */
- Shell shell = parent.getShell ();
- shell.bringToTop (true);
-}
-/**
- * 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 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 sendScrollEvent (int detail) {
+ Event event = new Event ();
+ event.detail = detail;
+ sendEvent (SWT.Selection, event);
+ /*
+ * Feature in Motif. When a scroll bar is selected,
+ * it does not make the shell active. The fix is to
+ * make the shell active.
+ */
+ Shell shell = parent.getShell ();
+ shell.bringToTop (true);
+}
+/**
+ * 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 [] argList = {OS.XmNsensitive, enabled ? 1 : 0};
- OS.XtSetValues (handle, argList, argList.length / 2);
-}
-/**
- * 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 setEnabled (boolean enabled) {
+ checkWidget();
+ int [] argList = {OS.XmNsensitive, enabled ? 1 : 0};
+ OS.XtSetValues (handle, argList, argList.length / 2);
+}
+/**
+ * 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;
- int [] argList = {OS.XmNincrement, value};
- OS.XtSetValues (handle, argList, argList.length / 2);
-}
-/**
- * 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 setIncrement (int value) {
+ checkWidget();
+ if (value < 1) return;
+ int [] argList = {OS.XmNincrement, value};
+ OS.XtSetValues (handle, argList, argList.length / 2);
+}
+/**
+ * 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;
- 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 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 setMaximum (int value) {
+ checkWidget();
+ 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 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;
- 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 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 setMinimum (int value) {
+ checkWidget();
+ 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 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;
- int [] argList = {OS.XmNpageIncrement, value};
- OS.XtSetValues (handle, argList, argList.length / 2);
-}
-/**
- * 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 setPageIncrement (int value) {
+ checkWidget();
+ if (value < 1) return;
+ int [] argList = {OS.XmNpageIncrement, value};
+ OS.XtSetValues (handle, argList, argList.length / 2);
+}
+/**
+ * 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) {
- checkWidget();
- 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 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 setSelection (int selection) {
+ checkWidget();
+ 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 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();
- 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);
-}
-/**
- * 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 setThumb (int value) {
+ checkWidget();
+ 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);
+}
+/**
+ * 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 (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);
-}
-/**
- * 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 setValues (int selection, int minimum, int maximum, int thumb, int increment, int pageIncrement) {
+ checkWidget();
+ if (minimum < 0) return;
+ if (maximum < 0) return;
+ if (thumb < 1) return;
+ if (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);
+}
+/**
+ * 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();
- parent.setScrollbarVisible (handle, visible);
-}
-int XmNdecrementCallback (int w, int client_data, int call_data) {
- sendScrollEvent (SWT.ARROW_UP);
- return 0;
-}
-int XmNdragCallback (int w, int client_data, int call_data) {
- sendScrollEvent (SWT.DRAG);
- return 0;
-}
-int XmNincrementCallback (int w, int client_data, int call_data) {
- sendScrollEvent (SWT.ARROW_DOWN);
- return 0;
-}
-int XmNpageDecrementCallback (int w, int client_data, int call_data) {
- sendScrollEvent (SWT.PAGE_UP);
- return 0;
-}
-int XmNpageIncrementCallback (int w, int client_data, int call_data) {
- sendScrollEvent (SWT.PAGE_DOWN);
- return 0;
-}
-int XmNtoBottomCallback (int w, int client_data, int call_data) {
- sendScrollEvent (SWT.END);
- return 0;
-}
-int XmNtoTopCallback (int w, int client_data, int call_data) {
- sendScrollEvent (SWT.HOME);
- return 0;
-}
-int XmNvalueChangedCallback (int w, int client_data, int call_data) {
- sendScrollEvent (SWT.NONE);
- return 0;
-}
+public void setVisible (boolean visible) {
+ checkWidget();
+ parent.setScrollbarVisible (handle, visible);
+}
+int XmNdecrementCallback (int w, int client_data, int call_data) {
+ sendScrollEvent (SWT.ARROW_UP);
+ return 0;
+}
+int XmNdragCallback (int w, int client_data, int call_data) {
+ sendScrollEvent (SWT.DRAG);
+ return 0;
+}
+int XmNincrementCallback (int w, int client_data, int call_data) {
+ sendScrollEvent (SWT.ARROW_DOWN);
+ return 0;
+}
+int XmNpageDecrementCallback (int w, int client_data, int call_data) {
+ sendScrollEvent (SWT.PAGE_UP);
+ return 0;
+}
+int XmNpageIncrementCallback (int w, int client_data, int call_data) {
+ sendScrollEvent (SWT.PAGE_DOWN);
+ return 0;
+}
+int XmNtoBottomCallback (int w, int client_data, int call_data) {
+ sendScrollEvent (SWT.END);
+ return 0;
+}
+int XmNtoTopCallback (int w, int client_data, int call_data) {
+ sendScrollEvent (SWT.HOME);
+ return 0;
+}
+int XmNvalueChangedCallback (int w, int client_data, int call_data) {
+ sendScrollEvent (SWT.NONE);
+ return 0;
+}
} \ No newline at end of file
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
index 7aa4a6a2a2..68f489b465 100755
--- 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
@@ -1,36 +1,36 @@
-package org.eclipse.swt.widgets;
-
-/*
+package org.eclipse.swt.widgets;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-import org.eclipse.swt.internal.motif.*;
-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>
+ * http://www.eclipse.org/legal/cpl-v10.html
*/
-public abstract class Scrollable extends Control {
- int scrolledHandle, formHandle;
- ScrollBar horizontalBar, verticalBar;
-Scrollable () {
- /* Do nothing */
-}
+
+import org.eclipse.swt.internal.motif.*;
+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 {
+ int scrolledHandle, formHandle;
+ ScrollBar horizontalBar, verticalBar;
+Scrollable () {
+ /* Do nothing */
+}
/**
* Constructs a new instance of this class given its parent
* and a style value describing its behavior and appearance.
@@ -60,268 +60,268 @@ Scrollable () {
* @see Widget#checkSubclass
* @see Widget#getStyle
*/
-public Scrollable (Composite parent, int style) {
- super (parent, style);
-}
-/**
- * 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 Scrollable (Composite parent, int style) {
+ super (parent, style);
+}
+/**
+ * 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();
- int border = getBorderWidth ();
- int trimX = x - border, trimY = y - border;
- int trimWidth = width + (border * 2), trimHeight = height + (border * 2);
- if (horizontalBar != null) {
- Display display = getDisplay ();
- trimY -= display.scrolledInsetY;
- trimHeight += display.scrolledInsetY + display.scrolledMarginY;
- if (verticalBar == null) {
- trimX -= display.scrolledInsetX;
- trimWidth += display.scrolledInsetX * 2;
- trimHeight -= display.scrolledInsetY * 2;
- }
- }
- if (verticalBar != null) {
- Display display = getDisplay ();
- trimX -= display.scrolledInsetX;
- trimWidth += display.scrolledInsetX + display.scrolledMarginX;
- if (horizontalBar == null) {
- 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]);
- }
-}
-/**
- * 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 computeTrim (int x, int y, int width, int height) {
+ checkWidget();
+ int border = getBorderWidth ();
+ int trimX = x - border, trimY = y - border;
+ int trimWidth = width + (border * 2), trimHeight = height + (border * 2);
+ if (horizontalBar != null) {
+ Display display = getDisplay ();
+ trimY -= display.scrolledInsetY;
+ trimHeight += display.scrolledInsetY + display.scrolledMarginY;
+ if (verticalBar == null) {
+ trimX -= display.scrolledInsetX;
+ trimWidth += display.scrolledInsetX * 2;
+ trimHeight -= display.scrolledInsetY * 2;
+ }
+ }
+ if (verticalBar != null) {
+ Display display = getDisplay ();
+ trimX -= display.scrolledInsetX;
+ trimWidth += display.scrolledInsetX + display.scrolledMarginX;
+ if (horizontalBar == null) {
+ 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]);
+ }
+}
+/**
+ * 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();
- int [] argList = {OS.XmNwidth, 0, OS.XmNheight, 0};
- OS.XtGetValues (handle, argList, argList.length / 2);
- return new Rectangle (0, 0, argList [1], argList [3]);
-}
-/**
- * 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 Rectangle getClientArea () {
+ checkWidget();
+ int [] argList = {OS.XmNwidth, 0, OS.XmNheight, 0};
+ OS.XtGetValues (handle, argList, argList.length / 2);
+ return new Rectangle (0, 0, argList [1], argList [3]);
+}
+/**
+ * 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 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;
-}
-boolean isTabGroup () {
- if ((state & CANVAS) != 0) return true;
- return super.isTabGroup ();
-}
-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);
- if (horizontalBar != null) horizontalBar.propagateWidget (enabled);
- if (verticalBar != null) verticalBar.propagateWidget (enabled);
- }
-}
-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.releaseResources ();
- if (verticalBar != null) verticalBar.releaseResources ();
- 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);
- }
-}
-void setScrollbarVisible (int barHandle, boolean visible) {
- if (scrolledHandle == 0) return;
- /*
- * 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 [] argList = {OS.XmNwidth, 0, OS.XmNheight, 0};
- OS.XtGetValues (scrolledHandle, argList, argList.length / 2);
-
- /* Hide or show the scroll bar */
- if (visible) {
- OS.XtManageChild (barHandle);
- } else {
- OS.XtUnmanageChild (barHandle);
- }
-
- /* Restore the size */
- OS.XtSetValues (scrolledHandle, argList, argList.length / 2);
-}
-int topHandle () {
- if (scrolledHandle != 0) return scrolledHandle;
- if (formHandle != 0) return formHandle;
- return handle;
-}
-}
+public ScrollBar getVerticalBar () {
+ checkWidget();
+ return verticalBar;
+}
+boolean isTabGroup () {
+ if ((state & CANVAS) != 0) return true;
+ return super.isTabGroup ();
+}
+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);
+ if (horizontalBar != null) horizontalBar.propagateWidget (enabled);
+ if (verticalBar != null) verticalBar.propagateWidget (enabled);
+ }
+}
+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.releaseResources ();
+ if (verticalBar != null) verticalBar.releaseResources ();
+ 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);
+ }
+}
+void setScrollbarVisible (int barHandle, boolean visible) {
+ if (scrolledHandle == 0) return;
+ /*
+ * 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 [] argList = {OS.XmNwidth, 0, OS.XmNheight, 0};
+ OS.XtGetValues (scrolledHandle, argList, argList.length / 2);
+
+ /* Hide or show the scroll bar */
+ if (visible) {
+ OS.XtManageChild (barHandle);
+ } else {
+ OS.XtUnmanageChild (barHandle);
+ }
+
+ /* Restore the size */
+ OS.XtSetValues (scrolledHandle, argList, argList.length / 2);
+}
+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/Shell.java b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Shell.java
index a1acacf8bc..d98b21a6c2 100755
--- 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
@@ -1,120 +1,120 @@
-package org.eclipse.swt.widgets;
-
-/*
+package org.eclipse.swt.widgets;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-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.*;
-
-/**
- * Instances of this class represent the "windows"
- * which the desktop or "window manager" is managing.
- * Instances that do not have a parent (that is, they
- * are built using the constructor, which takes a
- * <code>Display</code> as the argument) are described
- * as <em>top level</em> shells. Instances that do have
- * a parent are described as <em>secondary</em> or
- * <em>dialog</em> shells.
- * <p>
- * Instances are always displayed in one of the maximized,
- * minimized or normal states:
- * <ul>
- * <li>
- * When an instance is marked as <em>maximized</em>, the
- * window manager will typically resize it to fill the
- * entire visible area of the display, and the instance
- * is usually put in a state where it can not be resized
- * (even if it has style <code>RESIZE</code>) until it is
- * no longer maximized.
- * </li><li>
- * When an instance is in the <em>normal</em> state (neither
- * maximized or minimized), its appearance is controlled by
- * the style constants which were specified when it was created
- * and the restrictions of the window manager (see below).
- * </li><li>
- * When an instance has been marked as <em>minimized</em>,
- * its contents (client area) will usually not be visible,
- * and depending on the window manager, it may be
- * "iconified" (that is, replaced on the desktop by a small
- * simplified representation of itself), relocated to a
- * distinguished area of the screen, or hidden. Combinations
- * of these changes are also possible.
- * </li>
- * </ul>
- * </p>
- * <p>
- * 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
- * and modality. For example, some window managers only
- * support resizable windows and will always assume the
- * RESIZE style, even if it is not set. In addition, if a
- * modality style is not supported, it is "upgraded" to a
- * more restrictive modality style that is supported. For
- * example, if <code>PRIMARY_MODAL</code> is not supported,
- * it would be upgraded to <code>APPLICATION_MODAL</code>.
- * <dl>
- * <dt><b>Styles:</b></dt>
- * <dd>BORDER, CLOSE, MIN, MAX, NO_TRIM, RESIZE, TITLE</dd>
- * <dd>APPLICATION_MODAL, MODELESS, PRIMARY_MODAL, SYSTEM_MODAL</dd>
- * <dt><b>Events:</b></dt>
- * <dd>Activate, Close, Deactivate, Deiconify, Iconify</dd>
- * </dl>
- * Class <code>SWT</code> provides two "convenience constants"
- * for the most commonly required style combinations:
- * <dl>
- * <dt><code>SHELL_TRIM</code></dt>
- * <dd>
- * the result of combining the constants which are required
- * to produce a typical application top level shell: (that
- * is, <code>CLOSE | TITLE | MIN | MAX | RESIZE</code>)
- * </dd>
- * <dt><code>DIALOG_TRIM</code></dt>
- * <dd>
- * the result of combining the constants which are required
- * to produce a typical application dialog shell: (that
- * is, <code>TITLE | CLOSE | BORDER</code>)
- * </dd>
- * </dl>
- * </p>
- * <p>
- * Note: Only one of the styles APPLICATION_MODAL, MODELESS,
- * PRIMARY_MODAL and SYSTEM_MODAL may be specified.
- * </p><p>
- * IMPORTANT: This class is not intended to be subclassed.
- * </p>
- *
- * @see Decorations
- * @see SWT
+ * http://www.eclipse.org/legal/cpl-v10.html
*/
-public class Shell extends Decorations {
- Display display;
- int shellHandle;
- boolean reparented, realized, configured;
- int oldX, oldY, oldWidth, oldHeight;
- Control lastActive;
-
- static final byte [] WM_DELETE_WINDOW = Converter.wcsToMbcs(null, "WM_DELETE_WINDOW\0");
-/**
- * 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>
+
+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.*;
+
+/**
+ * Instances of this class represent the "windows"
+ * which the desktop or "window manager" is managing.
+ * Instances that do not have a parent (that is, they
+ * are built using the constructor, which takes a
+ * <code>Display</code> as the argument) are described
+ * as <em>top level</em> shells. Instances that do have
+ * a parent are described as <em>secondary</em> or
+ * <em>dialog</em> shells.
+ * <p>
+ * Instances are always displayed in one of the maximized,
+ * minimized or normal states:
+ * <ul>
+ * <li>
+ * When an instance is marked as <em>maximized</em>, the
+ * window manager will typically resize it to fill the
+ * entire visible area of the display, and the instance
+ * is usually put in a state where it can not be resized
+ * (even if it has style <code>RESIZE</code>) until it is
+ * no longer maximized.
+ * </li><li>
+ * When an instance is in the <em>normal</em> state (neither
+ * maximized or minimized), its appearance is controlled by
+ * the style constants which were specified when it was created
+ * and the restrictions of the window manager (see below).
+ * </li><li>
+ * When an instance has been marked as <em>minimized</em>,
+ * its contents (client area) will usually not be visible,
+ * and depending on the window manager, it may be
+ * "iconified" (that is, replaced on the desktop by a small
+ * simplified representation of itself), relocated to a
+ * distinguished area of the screen, or hidden. Combinations
+ * of these changes are also possible.
+ * </li>
+ * </ul>
+ * </p>
+ * <p>
+ * 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
+ * and modality. For example, some window managers only
+ * support resizable windows and will always assume the
+ * RESIZE style, even if it is not set. In addition, if a
+ * modality style is not supported, it is "upgraded" to a
+ * more restrictive modality style that is supported. For
+ * example, if <code>PRIMARY_MODAL</code> is not supported,
+ * it would be upgraded to <code>APPLICATION_MODAL</code>.
+ * <dl>
+ * <dt><b>Styles:</b></dt>
+ * <dd>BORDER, CLOSE, MIN, MAX, NO_TRIM, RESIZE, TITLE</dd>
+ * <dd>APPLICATION_MODAL, MODELESS, PRIMARY_MODAL, SYSTEM_MODAL</dd>
+ * <dt><b>Events:</b></dt>
+ * <dd>Activate, Close, Deactivate, Deiconify, Iconify</dd>
+ * </dl>
+ * Class <code>SWT</code> provides two "convenience constants"
+ * for the most commonly required style combinations:
+ * <dl>
+ * <dt><code>SHELL_TRIM</code></dt>
+ * <dd>
+ * the result of combining the constants which are required
+ * to produce a typical application top level shell: (that
+ * is, <code>CLOSE | TITLE | MIN | MAX | RESIZE</code>)
+ * </dd>
+ * <dt><code>DIALOG_TRIM</code></dt>
+ * <dd>
+ * the result of combining the constants which are required
+ * to produce a typical application dialog shell: (that
+ * is, <code>TITLE | CLOSE | BORDER</code>)
+ * </dd>
+ * </dl>
+ * </p>
+ * <p>
+ * Note: Only one of the styles APPLICATION_MODAL, MODELESS,
+ * PRIMARY_MODAL and SYSTEM_MODAL may be specified.
+ * </p><p>
+ * IMPORTANT: This class is not intended to be subclassed.
+ * </p>
+ *
+ * @see Decorations
+ * @see SWT
+ */
+public class Shell extends Decorations {
+ Display display;
+ int shellHandle;
+ boolean reparented, realized, configured;
+ int oldX, oldY, oldWidth, oldHeight;
+ Control lastActive;
+
+ static final byte [] WM_DELETE_WINDOW = Converter.wcsToMbcs(null, "WM_DELETE_WINDOW\0");
+/**
+ * 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);
-}
+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
@@ -150,31 +150,31 @@ public Shell () {
* @see SWT#APPLICATION_MODAL
* @see SWT#SYSTEM_MODAL
*/
-public Shell (int style) {
- this ((Display) null, style);
-}
-/**
- * Constructs a new instance of this class given only the display
- * to create it on. It is created with style <code>SWT.SHELL_TRIM</code>.
- * <p>
- * Note: Currently, null can be passed in for the display argument.
- * This has the effect of creating the shell on the currently active
- * display if there is one. If there is no current display, the
- * shell is created on a "default" display. <b>Passing in null as
- * the display argument is not considered to be good coding style,
- * and may not be supported in a future release of SWT.</b>
- * </p>
- *
- * @param display the display to create the shell on
- *
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
- * <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
- * </ul>
+public Shell (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);
-}
+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
@@ -218,48 +218,48 @@ public Shell (Display display) {
* @see SWT#APPLICATION_MODAL
* @see SWT#SYSTEM_MODAL
*/
-public Shell (Display display, int style) {
- this (display, null, style, 0);
-}
-Shell (Display display, Shell parent, int style, int handle) {
- super ();
- checkSubclass ();
- 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);
-}
-/**
- * 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 (Display display, int style) {
+ this (display, null, style, 0);
+}
+Shell (Display display, Shell parent, int style, int handle) {
+ super ();
+ checkSubclass ();
+ 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);
+}
+/**
+ * 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);
-}
+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.
@@ -302,180 +302,180 @@ public Shell (Shell parent) {
* @see SWT#APPLICATION_MODAL
* @see SWT#SYSTEM_MODAL
*/
-public Shell (Shell parent, int style) {
- this (parent != null ? parent.getDisplay () : null, parent, style, 0);
-}
-
-static int checkStyle (int style) {
- style = Decorations.checkStyle (style);
- if ((style & SWT.ON_TOP) != 0) style &= ~SWT.SHELL_TRIM;
- int mask = SWT.SYSTEM_MODAL | SWT.APPLICATION_MODAL | SWT.PRIMARY_MODAL;
- int bits = style & ~mask;
- if ((style & SWT.SYSTEM_MODAL) != 0) return bits | SWT.SYSTEM_MODAL;
- if ((style & SWT.APPLICATION_MODAL) != 0) return bits | SWT.APPLICATION_MODAL;
- if ((style & SWT.PRIMARY_MODAL) != 0) return bits | SWT.PRIMARY_MODAL;
- return bits;
-}
-
-public static Shell motif_new (Display display, int handle) {
- return new Shell (display, null, SWT.NO_TRIM, handle);
-}
-
-/**
- * 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 Shell (Shell parent, int style) {
+ this (parent != null ? parent.getDisplay () : null, parent, style, 0);
+}
+
+static int checkStyle (int style) {
+ style = Decorations.checkStyle (style);
+ if ((style & SWT.ON_TOP) != 0) style &= ~SWT.SHELL_TRIM;
+ int mask = SWT.SYSTEM_MODAL | SWT.APPLICATION_MODAL | SWT.PRIMARY_MODAL;
+ int bits = style & ~mask;
+ if ((style & SWT.SYSTEM_MODAL) != 0) return bits | SWT.SYSTEM_MODAL;
+ if ((style & SWT.APPLICATION_MODAL) != 0) return bits | SWT.APPLICATION_MODAL;
+ if ((style & SWT.PRIMARY_MODAL) != 0) return bits | SWT.PRIMARY_MODAL;
+ return bits;
+}
+
+public static Shell motif_new (Display display, int handle) {
+ return new Shell (display, null, SWT.NO_TRIM, handle);
+}
+
+/**
+ * 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.Activate,typedListener);
- addListener(SWT.Close,typedListener);
- addListener(SWT.Deactivate,typedListener);
- addListener(SWT.Iconify,typedListener);
- addListener(SWT.Deiconify,typedListener);
-}
-void adjustTrim () {
- if (OS.XtIsSubclass (shellHandle, OS.OverrideShellWidgetClass ())) {
- return;
- }
- int [] argList = {OS.XmNoverrideRedirect, 0};
- OS.XtGetValues (shellHandle, argList, argList.length / 2);
- if (argList [1] != 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
+public void addShellListener(ShellListener listener) {
+ checkWidget();
+ 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 (OS.XtIsSubclass (shellHandle, OS.OverrideShellWidgetClass ())) {
+ return;
+ }
+ int [] argList = {OS.XmNoverrideRedirect, 0};
+ OS.XtGetValues (shellHandle, argList, argList.length / 2);
+ if (argList [1] != 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];
- int [] trimX = new int [1];
- int [] trimY = new int [1];
- OS.XGetGeometry (xDisplay, trimWindow, unused, trimX, trimY, 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);
-
- /* Query the trim-adjusted position of the inner window */
- short [] inner_x = new short [1], inner_y = new short [1];
- OS.XtTranslateCoords (shellHandle, (short) 0, (short) 0, inner_x, inner_y);
-
- /* 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));
- int leftInset = inner_x [0] - trimX [0];
- int topInset = inner_y [0] - trimY [0];
-
- /* 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.leftTitleResizeWidth = leftInset;
- display.rightTitleResizeWidth = width - leftInset;
- display.topTitleResizeHeight = topInset;
- display.bottomTitleResizeHeight = height - topInset;
- return;
- }
- if (hasBorder) {
- display.leftTitleBorderWidth = leftInset;
- display.rightTitleBorderWidth = width - leftInset;
- display.topTitleBorderHeight = topInset;
- display.bottomTitleBorderHeight = height - topInset;
- return;
- }
- display.leftTitleWidth = leftInset;
- display.rightTitleWidth = width - leftInset;
- display.topTitleHeight = topInset;
- display.bottomTitleHeight = height - topInset;
- return;
- }
- if (hasResize) {
- display.leftResizeWidth = leftInset;
- display.rightResizeWidth = width - leftInset;
- display.topResizeHeight = topInset;
- display.bottomResizeHeight = height - topInset;
- return;
- }
- if (hasBorder) {
- display.leftBorderWidth = leftInset;
- display.rightBorderWidth = width - leftInset;
- display.topBorderHeight = topInset;
- display.bottomBorderHeight = height - topInset;
- return;
- }
-}
-void bringToTop (boolean force) {
- /*
- * 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 ((style & SWT.ON_TOP) != 0) return;
- if (minimized) return;
- if (!isVisible ()) return;
- int xDisplay = OS.XtDisplay (shellHandle);
- if (xDisplay == 0) return;
- int xWindow = OS.XtWindow (shellHandle);
- if (xWindow == 0) return;
- if (!force) {
- int [] buffer1 = new int [1], buffer2 = new int [1];
- OS.XGetInputFocus (xDisplay, buffer1, buffer2);
- if (buffer1 [0] == 0) return;
- int handle = OS.XtWindowToWidget (xDisplay, buffer1 [0]);
- if (handle == 0) return;
- }
- OS.XSetInputFocus (xDisplay, xWindow, OS.RevertToParent, OS.CurrentTime);
-}
+ 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];
+ int [] trimX = new int [1];
+ int [] trimY = new int [1];
+ OS.XGetGeometry (xDisplay, trimWindow, unused, trimX, trimY, 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);
+
+ /* Query the trim-adjusted position of the inner window */
+ short [] inner_x = new short [1], inner_y = new short [1];
+ OS.XtTranslateCoords (shellHandle, (short) 0, (short) 0, inner_x, inner_y);
+
+ /* 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));
+ int leftInset = inner_x [0] - trimX [0];
+ int topInset = inner_y [0] - trimY [0];
+
+ /* 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.leftTitleResizeWidth = leftInset;
+ display.rightTitleResizeWidth = width - leftInset;
+ display.topTitleResizeHeight = topInset;
+ display.bottomTitleResizeHeight = height - topInset;
+ return;
+ }
+ if (hasBorder) {
+ display.leftTitleBorderWidth = leftInset;
+ display.rightTitleBorderWidth = width - leftInset;
+ display.topTitleBorderHeight = topInset;
+ display.bottomTitleBorderHeight = height - topInset;
+ return;
+ }
+ display.leftTitleWidth = leftInset;
+ display.rightTitleWidth = width - leftInset;
+ display.topTitleHeight = topInset;
+ display.bottomTitleHeight = height - topInset;
+ return;
+ }
+ if (hasResize) {
+ display.leftResizeWidth = leftInset;
+ display.rightResizeWidth = width - leftInset;
+ display.topResizeHeight = topInset;
+ display.bottomResizeHeight = height - topInset;
+ return;
+ }
+ if (hasBorder) {
+ display.leftBorderWidth = leftInset;
+ display.rightBorderWidth = width - leftInset;
+ display.topBorderHeight = topInset;
+ display.bottomBorderHeight = height - topInset;
+ return;
+ }
+}
+void bringToTop (boolean force) {
+ /*
+ * 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 ((style & SWT.ON_TOP) != 0) return;
+ if (minimized) return;
+ if (!isVisible ()) return;
+ int xDisplay = OS.XtDisplay (shellHandle);
+ if (xDisplay == 0) return;
+ int xWindow = OS.XtWindow (shellHandle);
+ if (xWindow == 0) return;
+ if (!force) {
+ int [] buffer1 = new int [1], buffer2 = new int [1];
+ OS.XGetInputFocus (xDisplay, buffer1, buffer2);
+ if (buffer1 [0] == 0) return;
+ int handle = OS.XtWindowToWidget (xDisplay, buffer1 [0]);
+ if (handle == 0) return;
+ }
+ OS.XSetInputFocus (xDisplay, xWindow, OS.RevertToParent, OS.CurrentTime);
+}
/**
* Requests that the window manager close the receiver in
* the same way it would be closed when the user clicks on
@@ -490,914 +490,914 @@ void bringToTop (boolean force) {
*
* @see #dispose
*/
-public void close () {
- checkWidget();
- 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 (false);
- 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) {
- checkWidget();
- Rectangle trim = super.computeTrim (x, y, width, height);
- /*
- * Feature in Motif. There is no way to get the single pixel border
- * surrounding a TopLevelShell or a TransientShell. 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. Therefore, the
- * border must be added back into the trim.
- */
- int border = 0;
- if ((style & (SWT.NO_TRIM | SWT.BORDER | SWT.RESIZE)) == 0) {
- int [] argList = {OS.XmNborderWidth, 0};
- OS.XtGetValues (handle, argList, argList.length / 2);
- border = argList [1];
- }
- trim.x -= trimLeft ();
- trim.y -= trimTop ();
- trim.width += trimWidth () + (border * 2);
- trim.height += trimHeight () + imeHeight () + (border * 2);
- 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 [] argList1 = {
- OS.XmNmwmInputMode, inputMode,
- OS.XmNmwmDecorations, decorations,
- OS.XmNoverrideRedirect, (style & SWT.ON_TOP) != 0 ? 1 : 0,
- OS.XmNtitle, ptr,
- };
-
- /*
- * Feature in Motif. On some Window Managers, when a top level
- * shell is created with no decorations, the Window Manager does
- * not reparent the window regardless of the XmNoverrideRedirect
- * resource. The fix is to treat the window as if it has been
- * reparented by the Window Manager despite the fact that this
- * has not really happened.
- */
- int orientations = SWT.LEFT_TO_RIGHT | SWT.RIGHT_TO_LEFT;
- if ((style & ~orientations) == SWT.NONE || (style & (SWT.NO_TRIM | SWT.ON_TOP)) != 0) {
- reparented = true;
- }
-
- /*
- * Feature in Motif. When a top level shell has no parent and is
- * application modal, Motif does not honour the modality. The fix
- * is to create the shell as a child of a hidden shell handle, the
- * same way that XmNoverrideRedirect shells without parents are
- * created.
- */
- byte [] appClass = display.appClass;
- if (parent == null && (style & SWT.ON_TOP) == 0 && inputMode != OS.MWM_INPUT_FULL_APPLICATION_MODAL) {
- int xDisplay = display.xDisplay;
- int widgetClass = OS.TopLevelShellWidgetClass ();
- shellHandle = OS.XtAppCreateShell (display.appName, appClass, widgetClass, xDisplay, argList1, argList1.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, argList1, argList1.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.
- * 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 [] argList2 = {OS.XmNborderWidth, 1};
- OS.XtSetValues (handle, argList2, argList2.length / 2);
- }
-
- /*
- * Feature in Motif. There is no Motif API to negociate for the
- * status line. The fix is to force the status line to appear
- * by creating a hidden text widget. This is much safer than
- * using X API because this may conflict with Motif.
- *
- * Note that XmNtraversalOn must be set to FALSE or the shell
- * will not take focus when the user clicks on it.
- */
- if ((style & SWT.ON_TOP) == 0) {
- int [] argList3 = {OS.XmNtraversalOn, 0};
- int textHandle = OS.XmCreateTextField (handle, null, argList3, argList3.length / 2);
- if (textHandle == 0) error (SWT.ERROR_NO_HANDLES);
- }
-}
-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 () {
- /*
- * Note: It is valid to attempt to dispose a widget
- * more than once. If this happens, fail silently.
- */
- if (isDisposed()) return;
-
- /*
- * 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.
- */
-// if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
-// Display oldDisplay = display;
-
- /*
- * Feature in Motif. When an override-redirected shell
- * is disposed, Motif does not assign a new active top
- * level shell. The parent shell appears to be active,
- * but XGetInputFocus returns the root window, not the
- * parent. The fix is to make the parent be the active
- * top level shell when the child shell is disposed.
- *
- * Feature in Motif. When the active shell is disposed,
- * Motif assigns focus temporarily to the root window
- * unless it has previously been told to do otherwise.
- * The fix is to make the parent be the active top level
- * shell when the child shell is disposed.
- */
- if (parent != null) {
- int [] argList = {OS.XmNoverrideRedirect, 0};
- OS.XtGetValues (shellHandle, argList, argList.length / 2);
- Shell activeShell = display.getActiveShell ();
- if (argList [1] != 0 || activeShell == this) {
- Shell shell = parent.getShell ();
- shell.bringToTop (false);
- }
- }
- super.dispose ();
-
- /*
- * This code intentionally commented.
- */
-// if (oldDisplay != null) oldDisplay.update ();
-}
-void enableWidget (boolean enabled) {
- super.enableWidget (enabled);
- enableHandle (enabled, shellHandle);
-}
-/**
- * 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) and forces the window
- * manager to make the shell active.
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @since 2.0
- * @see Control#moveAbove
- * @see Control#setFocus
- * @see Control#setVisible
- * @see Display#getActiveShell
- * @see Decorations#setDefaultButton
- * @see Shell#open
- * @see Shell#setActive
+public void close () {
+ checkWidget();
+ 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 (false);
+ 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) {
+ checkWidget();
+ Rectangle trim = super.computeTrim (x, y, width, height);
+ /*
+ * Feature in Motif. There is no way to get the single pixel border
+ * surrounding a TopLevelShell or a TransientShell. 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. Therefore, the
+ * border must be added back into the trim.
+ */
+ int border = 0;
+ if ((style & (SWT.NO_TRIM | SWT.BORDER | SWT.RESIZE)) == 0) {
+ int [] argList = {OS.XmNborderWidth, 0};
+ OS.XtGetValues (handle, argList, argList.length / 2);
+ border = argList [1];
+ }
+ trim.x -= trimLeft ();
+ trim.y -= trimTop ();
+ trim.width += trimWidth () + (border * 2);
+ trim.height += trimHeight () + imeHeight () + (border * 2);
+ 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 [] argList1 = {
+ OS.XmNmwmInputMode, inputMode,
+ OS.XmNmwmDecorations, decorations,
+ OS.XmNoverrideRedirect, (style & SWT.ON_TOP) != 0 ? 1 : 0,
+ OS.XmNtitle, ptr,
+ };
+
+ /*
+ * Feature in Motif. On some Window Managers, when a top level
+ * shell is created with no decorations, the Window Manager does
+ * not reparent the window regardless of the XmNoverrideRedirect
+ * resource. The fix is to treat the window as if it has been
+ * reparented by the Window Manager despite the fact that this
+ * has not really happened.
+ */
+ int orientations = SWT.LEFT_TO_RIGHT | SWT.RIGHT_TO_LEFT;
+ if ((style & ~orientations) == SWT.NONE || (style & (SWT.NO_TRIM | SWT.ON_TOP)) != 0) {
+ reparented = true;
+ }
+
+ /*
+ * Feature in Motif. When a top level shell has no parent and is
+ * application modal, Motif does not honour the modality. The fix
+ * is to create the shell as a child of a hidden shell handle, the
+ * same way that XmNoverrideRedirect shells without parents are
+ * created.
+ */
+ byte [] appClass = display.appClass;
+ if (parent == null && (style & SWT.ON_TOP) == 0 && inputMode != OS.MWM_INPUT_FULL_APPLICATION_MODAL) {
+ int xDisplay = display.xDisplay;
+ int widgetClass = OS.TopLevelShellWidgetClass ();
+ shellHandle = OS.XtAppCreateShell (display.appName, appClass, widgetClass, xDisplay, argList1, argList1.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, argList1, argList1.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.
+ * 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 [] argList2 = {OS.XmNborderWidth, 1};
+ OS.XtSetValues (handle, argList2, argList2.length / 2);
+ }
+
+ /*
+ * Feature in Motif. There is no Motif API to negociate for the
+ * status line. The fix is to force the status line to appear
+ * by creating a hidden text widget. This is much safer than
+ * using X API because this may conflict with Motif.
+ *
+ * Note that XmNtraversalOn must be set to FALSE or the shell
+ * will not take focus when the user clicks on it.
+ */
+ if ((style & SWT.ON_TOP) == 0) {
+ int [] argList3 = {OS.XmNtraversalOn, 0};
+ int textHandle = OS.XmCreateTextField (handle, null, argList3, argList3.length / 2);
+ if (textHandle == 0) error (SWT.ERROR_NO_HANDLES);
+ }
+}
+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 () {
+ /*
+ * Note: It is valid to attempt to dispose a widget
+ * more than once. If this happens, fail silently.
+ */
+ if (isDisposed()) return;
+
+ /*
+ * 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.
+ */
+// if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+// Display oldDisplay = display;
+
+ /*
+ * Feature in Motif. When an override-redirected shell
+ * is disposed, Motif does not assign a new active top
+ * level shell. The parent shell appears to be active,
+ * but XGetInputFocus returns the root window, not the
+ * parent. The fix is to make the parent be the active
+ * top level shell when the child shell is disposed.
+ *
+ * Feature in Motif. When the active shell is disposed,
+ * Motif assigns focus temporarily to the root window
+ * unless it has previously been told to do otherwise.
+ * The fix is to make the parent be the active top level
+ * shell when the child shell is disposed.
+ */
+ if (parent != null) {
+ int [] argList = {OS.XmNoverrideRedirect, 0};
+ OS.XtGetValues (shellHandle, argList, argList.length / 2);
+ Shell activeShell = display.getActiveShell ();
+ if (argList [1] != 0 || activeShell == this) {
+ Shell shell = parent.getShell ();
+ shell.bringToTop (false);
+ }
+ }
+ super.dispose ();
+
+ /*
+ * This code intentionally commented.
+ */
+// if (oldDisplay != null) oldDisplay.update ();
+}
+void enableWidget (boolean enabled) {
+ super.enableWidget (enabled);
+ enableHandle (enabled, shellHandle);
+}
+/**
+ * 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) and forces the window
+ * manager to make the shell active.
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @since 2.0
+ * @see Control#moveAbove
+ * @see Control#setFocus
+ * @see Control#setVisible
+ * @see Display#getActiveShell
+ * @see Decorations#setDefaultButton
+ * @see Shell#open
+ * @see Shell#setActive
*/
-public void forceActive () {
- checkWidget ();
- bringToTop (true);
-}
-public int getBorderWidth () {
- checkWidget();
- int [] argList = {OS.XmNborderWidth, 0};
- OS.XtGetValues (scrolledHandle, argList, argList.length / 2);
- return argList [1];
-}
-public Rectangle getBounds () {
- checkWidget();
- short [] root_x = new short [1], root_y = new short [1];
- OS.XtTranslateCoords (shellHandle, (short) 0, (short) 0, root_x, root_y);
- if (reparented) {
- root_x [0] -= trimLeft ();
- root_y [0] -= trimTop ();
- }
- int [] argList = {OS.XmNwidth, 0, OS.XmNheight, 0, OS.XmNborderWidth, 0};
- OS.XtGetValues (shellHandle, 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);
-}
-public Display getDisplay () {
- if (display == null) error (SWT.ERROR_WIDGET_DISPOSED);
- return display;
-}
-/**
- * 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 void forceActive () {
+ checkWidget ();
+ bringToTop (true);
+}
+public int getBorderWidth () {
+ checkWidget();
+ int [] argList = {OS.XmNborderWidth, 0};
+ OS.XtGetValues (scrolledHandle, argList, argList.length / 2);
+ return argList [1];
+}
+public Rectangle getBounds () {
+ checkWidget();
+ short [] root_x = new short [1], root_y = new short [1];
+ OS.XtTranslateCoords (shellHandle, (short) 0, (short) 0, root_x, root_y);
+ if (reparented) {
+ root_x [0] -= trimLeft ();
+ root_y [0] -= trimTop ();
+ }
+ int [] argList = {OS.XmNwidth, 0, OS.XmNheight, 0, OS.XmNborderWidth, 0};
+ OS.XtGetValues (shellHandle, 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);
+}
+public Display getDisplay () {
+ if (display == null) error (SWT.ERROR_WIDGET_DISPOSED);
+ return display;
+}
+/**
+ * Returns the receiver's input method editor mode. This
+ * will be the result of bitwise OR'ing together one or
+ * more of the following constants defined in class
+ * <code>SWT</code>:
+ * <code>NONE</code>, <code>ROMAN</code>, <code>DBCS</code>,
+ * <code>PHONETIC</code>, <code>NATIVE</code>, <code>ALPHA</code>.
+ *
+ * @return the IME mode
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see SWT
*/
-public int getImeInputMode () {
- checkWidget();
- return SWT.NONE;
-}
-public Point getLocation () {
- checkWidget();
- short [] root_x = new short [1], root_y = new short [1];
- OS.XtTranslateCoords (shellHandle, (short) 0, (short) 0, root_x, root_y);
- if (reparented) {
- root_x [0] -= trimLeft ();
- root_y [0] -= trimTop ();
- }
- return new Point (root_x [0], root_y [0]);
-}
-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 int getImeInputMode () {
+ checkWidget();
+ return SWT.NONE;
+}
+public Point getLocation () {
+ checkWidget();
+ short [] root_x = new short [1], root_y = new short [1];
+ OS.XtTranslateCoords (shellHandle, (short) 0, (short) 0, root_x, root_y);
+ if (reparented) {
+ root_x [0] -= trimLeft ();
+ root_y [0] -= trimTop ();
+ }
+ return new Point (root_x [0], root_y [0]);
+}
+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 Point getSize () {
- checkWidget();
- int [] argList = {OS.XmNwidth, 0, OS.XmNheight, 0, OS.XmNborderWidth, 0};
- OS.XtGetValues (shellHandle, 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 () {
- checkWidget();
- 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 && reparented) 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.XtInsertEventHandler (shellHandle, OS.StructureNotifyMask, false, windowProc, STRUCTURE_NOTIFY, OS.XtListTail);
- if (OS.XtIsSubclass (shellHandle, OS.OverrideShellWidgetClass ())) return;
- OS.XtInsertEventHandler (shellHandle, OS.FocusChangeMask, false, windowProc, FOCUS_CHANGE, OS.XtListTail);
- int [] argList = {OS.XmNdeleteResponse, OS.XmDO_NOTHING};
- OS.XtSetValues (shellHandle, argList, argList.length / 2);
- int xDisplay = OS.XtDisplay (shellHandle);
- if (xDisplay != 0) {
- int atom = OS.XmInternAtom (xDisplay, WM_DELETE_WINDOW, false);
- OS.XmAddWMProtocolCallback (shellHandle, atom, windowProc, DELETE_WINDOW);
- }
-}
-int imeHeight () {
- if (!OS.IsDBLocale) return 0;
- int [] argList1 = {OS.XmNheight, 0};
- OS.XtGetValues (shellHandle, argList1, argList1.length / 2);
- int [] argList2 = {OS.XmNheight, 0};
- OS.XtGetValues (scrolledHandle, argList2, argList2.length / 2);
- return argList1 [1] - argList2 [1];
-}
-public boolean isEnabled () {
- checkWidget();
- return getEnabled ();
-}
-boolean isModal () {
- checkWidget();
- 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 () {
- checkWidget();
- 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);
-}
-/**
- * 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)
- * and asks the window manager to make the shell active.
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see Control#moveAbove
- * @see Control#setFocus
- * @see Control#setVisible
- * @see Display#getActiveShell
- * @see Decorations#setDefaultButton
- * @see Shell#setActive
- * @see Shell#forceActive
+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 Point getSize () {
+ checkWidget();
+ int [] argList = {OS.XmNwidth, 0, OS.XmNheight, 0, OS.XmNborderWidth, 0};
+ OS.XtGetValues (shellHandle, 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 () {
+ checkWidget();
+ 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 && reparented) 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.XtInsertEventHandler (shellHandle, OS.StructureNotifyMask, false, windowProc, STRUCTURE_NOTIFY, OS.XtListTail);
+ if (OS.XtIsSubclass (shellHandle, OS.OverrideShellWidgetClass ())) return;
+ OS.XtInsertEventHandler (shellHandle, OS.FocusChangeMask, false, windowProc, FOCUS_CHANGE, OS.XtListTail);
+ int [] argList = {OS.XmNdeleteResponse, OS.XmDO_NOTHING};
+ OS.XtSetValues (shellHandle, argList, argList.length / 2);
+ int xDisplay = OS.XtDisplay (shellHandle);
+ if (xDisplay != 0) {
+ int atom = OS.XmInternAtom (xDisplay, WM_DELETE_WINDOW, false);
+ OS.XmAddWMProtocolCallback (shellHandle, atom, windowProc, DELETE_WINDOW);
+ }
+}
+int imeHeight () {
+ if (!OS.IsDBLocale) return 0;
+ int [] argList1 = {OS.XmNheight, 0};
+ OS.XtGetValues (shellHandle, argList1, argList1.length / 2);
+ int [] argList2 = {OS.XmNheight, 0};
+ OS.XtGetValues (scrolledHandle, argList2, argList2.length / 2);
+ return argList1 [1] - argList2 [1];
+}
+public boolean isEnabled () {
+ checkWidget();
+ return getEnabled ();
+}
+boolean isModal () {
+ checkWidget();
+ 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 () {
+ checkWidget();
+ 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);
+}
+/**
+ * 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)
+ * and asks the window manager to make the shell active.
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see Control#moveAbove
+ * @see Control#setFocus
+ * @see Control#setVisible
+ * @see Display#getActiveShell
+ * @see Decorations#setDefaultButton
+ * @see Shell#setActive
+ * @see Shell#forceActive
*/
-public void open () {
- checkWidget();
- setVisible (true);
- if (!restoreFocus ()) traverseGroup (true);
-}
-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.releaseResources ();
- }
-}
-void releaseWidget () {
- releaseShells ();
- super.releaseWidget ();
- display = null;
- lastActive = 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 open () {
+ checkWidget();
+ setVisible (true);
+ if (!restoreFocus ()) traverseGroup (true);
+}
+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.releaseResources ();
+ }
+}
+void releaseWidget () {
+ releaseShells ();
+ super.releaseWidget ();
+ display = null;
+ lastActive = 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.Activate, listener);
- eventTable.unhook(SWT.Close, listener);
- eventTable.unhook(SWT.Deactivate, listener);
- eventTable.unhook(SWT.Iconify,listener);
- eventTable.unhook(SWT.Deiconify,listener);
-}
-void saveBounds () {
- short [] root_x = new short [1], root_y = new short [1];
- OS.XtTranslateCoords (shellHandle, (short) 0, (short) 0, root_x, root_y);
- int [] argList = {OS.XmNwidth, 0, OS.XmNheight, 0};
- OS.XtGetValues (shellHandle, argList, argList.length / 2);
- oldX = root_x [0];
- oldY = root_y [0];
- oldWidth = argList [1];
- oldHeight = argList [3];
-}
-
-/**
- * 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) and asks the window
- * manager to make the shell active.
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @since 2.0
- * @see Control#moveAbove
- * @see Control#setFocus
- * @see Control#setVisible
- * @see Display#getActiveShell
- * @see Decorations#setDefaultButton
- * @see Shell#open
- * @see Shell#setActive
+public void removeShellListener(ShellListener listener) {
+ checkWidget();
+ 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 () {
+ short [] root_x = new short [1], root_y = new short [1];
+ OS.XtTranslateCoords (shellHandle, (short) 0, (short) 0, root_x, root_y);
+ int [] argList = {OS.XmNwidth, 0, OS.XmNheight, 0};
+ OS.XtGetValues (shellHandle, argList, argList.length / 2);
+ oldX = root_x [0];
+ oldY = root_y [0];
+ oldWidth = argList [1];
+ oldHeight = argList [3];
+}
+
+/**
+ * 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) and asks the window
+ * manager to make the shell active.
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @since 2.0
+ * @see Control#moveAbove
+ * @see Control#setFocus
+ * @see Control#setVisible
+ * @see Display#getActiveShell
+ * @see Decorations#setDefaultButton
+ * @see Shell#open
+ * @see Shell#setActive
*/
-public void setActive () {
- checkWidget ();
- bringToTop (false);
-}
-
-void setActiveControl (Control control) {
- if (control != null && control.isDisposed ()) control = null;
- if (lastActive != null && lastActive.isDisposed ()) lastActive = null;
- if (lastActive == control) return;
-
- /*
- * Compute the list of controls to be activated and
- * deactivated by finding the first common parent
- * control.
- */
- Control [] activate = (control == null) ? new Control[0] : control.getPath ();
- Control [] deactivate = (lastActive == null) ? new Control[0] : lastActive.getPath ();
- lastActive = control;
- int index = 0, length = Math.min (activate.length, deactivate.length);
- while (index < length) {
- if (activate [index] != deactivate [index]) break;
- index++;
- }
-
- /*
- * It is possible (but unlikely), that application
- * code could have destroyed some of the widgets. If
- * this happens, keep processing those widgets that
- * are not disposed.
- */
- for (int i=deactivate.length-1; i>=index; --i) {
- if (!deactivate [i].isDisposed ()) {
- if (display.postFocusOut) {
- deactivate [i].postEvent (SWT.Deactivate);
- } else {
- deactivate [i].sendEvent (SWT.Deactivate);
- }
- }
- }
- for (int i=activate.length-1; i>=index; --i) {
- if (!activate [i].isDisposed ()) {
- activate [i].sendEvent (SWT.Activate);
- }
- }
-}
-/**
- * Sets the 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 setActive () {
+ checkWidget ();
+ bringToTop (false);
+}
+
+void setActiveControl (Control control) {
+ if (control != null && control.isDisposed ()) control = null;
+ if (lastActive != null && lastActive.isDisposed ()) lastActive = null;
+ if (lastActive == control) return;
+
+ /*
+ * Compute the list of controls to be activated and
+ * deactivated by finding the first common parent
+ * control.
+ */
+ Control [] activate = (control == null) ? new Control[0] : control.getPath ();
+ Control [] deactivate = (lastActive == null) ? new Control[0] : lastActive.getPath ();
+ lastActive = control;
+ int index = 0, length = Math.min (activate.length, deactivate.length);
+ while (index < length) {
+ if (activate [index] != deactivate [index]) break;
+ index++;
+ }
+
+ /*
+ * It is possible (but unlikely), that application
+ * code could have destroyed some of the widgets. If
+ * this happens, keep processing those widgets that
+ * are not disposed.
+ */
+ for (int i=deactivate.length-1; i>=index; --i) {
+ if (!deactivate [i].isDisposed ()) {
+ if (display.postFocusOut) {
+ deactivate [i].postEvent (SWT.Deactivate);
+ } else {
+ deactivate [i].sendEvent (SWT.Deactivate);
+ }
+ }
+ }
+ for (int i=activate.length-1; i>=index; --i) {
+ if (!activate [i].isDisposed ()) {
+ activate [i].sendEvent (SWT.Activate);
+ }
+ }
+}
+/**
+ * Sets the 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();
-}
-boolean setBounds (int x, int y, int width, int height, boolean move, boolean resize) {
- if (resize) {
- /*
- * 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.
- */
- width = Math.max (width - trimWidth (), 1);
- height = Math.max (height - trimHeight (), 1);
- }
- if (!reparented || !OS.XtIsRealized (shellHandle)) {
- return super.setBounds (x, y, width, height, move, resize);
- }
- if (move) {
- x += trimLeft ();
- y += trimTop ();
- }
- if (!configured) saveBounds ();
- configured = true;
- boolean isFocus = caret != null && caret.isFocusCaret ();
- if (isFocus) caret.killFocus ();
- if (move && resize) {
- OS.XtConfigureWidget (shellHandle, x, y, width, height, 0);
- } else {
- if (move) OS.XtMoveWidget (shellHandle, x, y);
- if (resize) OS.XtResizeWidget (shellHandle, width, height, 0);
- }
- if (isFocus) caret.setFocus ();
- return move || resize;
-}
-public void setMinimized (boolean minimized) {
- checkWidget();
-
- /*
- * 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);
-}
-void setParentTraversal () {
- /* Do nothing - Child shells do not affect the traversal of their parent shell */
-}
-public void setText (String string) {
- checkWidget();
- 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.
- */
- /* Use the character encoding for the default locale */
- 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) {
- checkWidget();
- 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 ();
-
- 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);
-}
-void setZOrder (Control control, boolean above) {
- setZOrder (control, above, false);
-}
-int topHandle () {
- return shellHandle;
-}
-boolean traverseEscape () {
- if (parent == null) return false;
- if (!isVisible () || !isEnabled ()) return false;
- close ();
- return true;
-}
-int trimHeight () {
- if ((style & SWT.NO_TRIM) != 0) return 0;
- 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.topTitleResizeHeight + display.bottomTitleResizeHeight;
- }
- if (hasBorder) {
- return display.topTitleBorderHeight + display.bottomTitleBorderHeight;
- }
- return display.topTitleHeight + display.bottomTitleHeight;
- }
- if (hasResize) {
- return display.topResizeHeight + display.bottomResizeHeight;
- }
- if (hasBorder) {
- return display.topBorderHeight + display.bottomBorderHeight;
- }
- return 0;
-}
-int trimLeft () {
- 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.leftTitleResizeWidth;
- if (hasBorder) return display.leftTitleBorderWidth;
- return display.leftTitleWidth;
- }
- if (hasResize) return display.leftResizeWidth;
- if (hasBorder) return display.leftBorderWidth;
- return 0;
-}
-int trimTop () {
- 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.topTitleResizeHeight;
- if (hasBorder) return display.topTitleBorderHeight;
- return display.topTitleHeight;
- }
- if (hasResize) return display.topResizeHeight;
- if (hasBorder) return display.topBorderHeight;
- 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.leftTitleResizeWidth + display.rightTitleResizeWidth;
- }
- if (hasBorder) {
- return display.leftTitleBorderWidth + display.rightTitleBorderWidth;
- }
- return display.leftTitleWidth + display.rightTitleWidth;
- }
- if (hasResize) {
- return display.leftResizeWidth + display.rightResizeWidth;
- }
- if (hasBorder) {
- return display.leftBorderWidth + display.rightBorderWidth;
- }
- return 0;
-}
-int WM_DELETE_WINDOW (int w, int client_data, int call_data) {
- closeWidget ();
- return 0;
-}
-int XFocusChange (int w, int client_data, int call_data, int continue_to_dispatch) {
- XFocusChangeEvent xEvent = new XFocusChangeEvent ();
- OS.memmove (xEvent, call_data, XFocusChangeEvent.sizeof);
- int handle = OS.XtWindowToWidget (xEvent.display, xEvent.window);
- if (handle != shellHandle) return super.XFocusChange (w, client_data, call_data, continue_to_dispatch);
- if (xEvent.mode != OS.NotifyNormal) return 0;
- switch (xEvent.detail) {
- case OS.NotifyNonlinear:
- case OS.NotifyNonlinearVirtual: {
- switch (xEvent.type) {
- case OS.FocusIn:
- postEvent (SWT.Activate);
- break;
- case OS.FocusOut:
- postEvent (SWT.Deactivate);
- break;
- }
- }
- }
- return 0;
-}
-int XStructureNotify (int w, int client_data, int call_data, int continue_to_dispatch) {
- XConfigureEvent xEvent = new XConfigureEvent ();
- OS.memmove (xEvent, call_data, 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 (shellHandle, (short) 0, (short) 0, root_x, root_y);
- int [] argList = {OS.XmNwidth, 0, OS.XmNheight, 0};
- OS.XtGetValues (shellHandle, 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;
- configured = false;
- if (oldX != xEvent.x || oldY != xEvent.y) sendEvent (SWT.Move);
- if (oldWidth != xEvent.width || oldHeight != xEvent.height) {
- XAnyEvent event = new XAnyEvent ();
- display.resizeWindow = xEvent.window;
- display.resizeWidth = xEvent.width;
- display.resizeHeight = xEvent.height;
- display.resizeCount = 0;
- int checkResizeProc = display.checkResizeProc;
- OS.XCheckIfEvent (xEvent.display, event, checkResizeProc, 0);
- if (display.resizeCount == 0) {
- 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;
-}
+public void setImeInputMode (int mode) {
+ checkWidget();
+}
+boolean setBounds (int x, int y, int width, int height, boolean move, boolean resize) {
+ if (resize) {
+ /*
+ * 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.
+ */
+ width = Math.max (width - trimWidth (), 1);
+ height = Math.max (height - trimHeight (), 1);
+ }
+ if (!reparented || !OS.XtIsRealized (shellHandle)) {
+ return super.setBounds (x, y, width, height, move, resize);
+ }
+ if (move) {
+ x += trimLeft ();
+ y += trimTop ();
+ }
+ if (!configured) saveBounds ();
+ configured = true;
+ boolean isFocus = caret != null && caret.isFocusCaret ();
+ if (isFocus) caret.killFocus ();
+ if (move && resize) {
+ OS.XtConfigureWidget (shellHandle, x, y, width, height, 0);
+ } else {
+ if (move) OS.XtMoveWidget (shellHandle, x, y);
+ if (resize) OS.XtResizeWidget (shellHandle, width, height, 0);
+ }
+ if (isFocus) caret.setFocus ();
+ return move || resize;
+}
+public void setMinimized (boolean minimized) {
+ checkWidget();
+
+ /*
+ * 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);
+}
+void setParentTraversal () {
+ /* Do nothing - Child shells do not affect the traversal of their parent shell */
+}
+public void setText (String string) {
+ checkWidget();
+ 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.
+ */
+ /* Use the character encoding for the default locale */
+ 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) {
+ checkWidget();
+ 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 ();
+
+ 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);
+}
+void setZOrder (Control control, boolean above) {
+ setZOrder (control, above, false);
+}
+int topHandle () {
+ return shellHandle;
+}
+boolean traverseEscape () {
+ if (parent == null) return false;
+ if (!isVisible () || !isEnabled ()) return false;
+ close ();
+ return true;
+}
+int trimHeight () {
+ if ((style & SWT.NO_TRIM) != 0) return 0;
+ 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.topTitleResizeHeight + display.bottomTitleResizeHeight;
+ }
+ if (hasBorder) {
+ return display.topTitleBorderHeight + display.bottomTitleBorderHeight;
+ }
+ return display.topTitleHeight + display.bottomTitleHeight;
+ }
+ if (hasResize) {
+ return display.topResizeHeight + display.bottomResizeHeight;
+ }
+ if (hasBorder) {
+ return display.topBorderHeight + display.bottomBorderHeight;
+ }
+ return 0;
+}
+int trimLeft () {
+ 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.leftTitleResizeWidth;
+ if (hasBorder) return display.leftTitleBorderWidth;
+ return display.leftTitleWidth;
+ }
+ if (hasResize) return display.leftResizeWidth;
+ if (hasBorder) return display.leftBorderWidth;
+ return 0;
+}
+int trimTop () {
+ 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.topTitleResizeHeight;
+ if (hasBorder) return display.topTitleBorderHeight;
+ return display.topTitleHeight;
+ }
+ if (hasResize) return display.topResizeHeight;
+ if (hasBorder) return display.topBorderHeight;
+ 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.leftTitleResizeWidth + display.rightTitleResizeWidth;
+ }
+ if (hasBorder) {
+ return display.leftTitleBorderWidth + display.rightTitleBorderWidth;
+ }
+ return display.leftTitleWidth + display.rightTitleWidth;
+ }
+ if (hasResize) {
+ return display.leftResizeWidth + display.rightResizeWidth;
+ }
+ if (hasBorder) {
+ return display.leftBorderWidth + display.rightBorderWidth;
+ }
+ return 0;
+}
+int WM_DELETE_WINDOW (int w, int client_data, int call_data) {
+ closeWidget ();
+ return 0;
+}
+int XFocusChange (int w, int client_data, int call_data, int continue_to_dispatch) {
+ XFocusChangeEvent xEvent = new XFocusChangeEvent ();
+ OS.memmove (xEvent, call_data, XFocusChangeEvent.sizeof);
+ int handle = OS.XtWindowToWidget (xEvent.display, xEvent.window);
+ if (handle != shellHandle) return super.XFocusChange (w, client_data, call_data, continue_to_dispatch);
+ if (xEvent.mode != OS.NotifyNormal) return 0;
+ switch (xEvent.detail) {
+ case OS.NotifyNonlinear:
+ case OS.NotifyNonlinearVirtual: {
+ switch (xEvent.type) {
+ case OS.FocusIn:
+ postEvent (SWT.Activate);
+ break;
+ case OS.FocusOut:
+ postEvent (SWT.Deactivate);
+ break;
+ }
+ }
+ }
+ return 0;
+}
+int XStructureNotify (int w, int client_data, int call_data, int continue_to_dispatch) {
+ XConfigureEvent xEvent = new XConfigureEvent ();
+ OS.memmove (xEvent, call_data, 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 (shellHandle, (short) 0, (short) 0, root_x, root_y);
+ int [] argList = {OS.XmNwidth, 0, OS.XmNheight, 0};
+ OS.XtGetValues (shellHandle, 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;
+ configured = false;
+ if (oldX != xEvent.x || oldY != xEvent.y) sendEvent (SWT.Move);
+ if (oldWidth != xEvent.width || oldHeight != xEvent.height) {
+ XAnyEvent event = new XAnyEvent ();
+ display.resizeWindow = xEvent.window;
+ display.resizeWidth = xEvent.width;
+ display.resizeHeight = xEvent.height;
+ display.resizeCount = 0;
+ int checkResizeProc = display.checkResizeProc;
+ OS.XCheckIfEvent (xEvent.display, event, checkResizeProc, 0);
+ if (display.resizeCount == 0) {
+ 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;
+}
} \ No newline at end of file
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
index 97170862f0..b5fdfb91c7 100755
--- 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
@@ -1,66 +1,66 @@
-package org.eclipse.swt.widgets;
-
-/*
+package org.eclipse.swt.widgets;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-import org.eclipse.swt.internal.motif.*;
-import org.eclipse.swt.*;
-import org.eclipse.swt.events.*;
-import org.eclipse.swt.graphics.*;
-
-/**
- * Instances of this class are selectable user interface
- * objects that represent 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 a left facing button for decrementing the value and a
- * right facing button for incrementing it) or <code>VERTICAL</code>
- * (which have an upward facing button for decrementing the value
- * and a downward facing buttons for incrementing it).
- * </p><p>
- * On some platforms, the size of the slider's thumb can be
- * varied relative to the magnitude of the range of values it
- * represents (that is, relative to the difference between its
- * maximum and minimum values). Typically, this is used to
- * indicate some proportional value such as the ratio of the
- * visible area of a document to the total amount of space that
- * it would take to display it. SWT supports setting the thumb
- * size even if the underlying platform does not, but in this
- * case the appearance of the slider will not change.
- * </p>
- * <dl>
- * <dt><b>Styles:</b></dt>
- * <dd>HORIZONTAL, VERTICAL</dd>
- * <dt><b>Events:</b></dt>
- * <dd>Selection</dd>
- * </dl>
- * <p>
- * Note: Only one of the styles HORIZONTAL and VERTICAL may be specified.
- * </p><p>
- * IMPORTANT: This class is <em>not</em> intended to be subclassed.
- * </p>
- *
- * @see ScrollBar
+ * http://www.eclipse.org/legal/cpl-v10.html
*/
-public class Slider extends Control {
+
+import org.eclipse.swt.internal.motif.*;
+import org.eclipse.swt.*;
+import org.eclipse.swt.events.*;
+import org.eclipse.swt.graphics.*;
+
+/**
+ * Instances of this class are selectable user interface
+ * objects that represent 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 a left facing button for decrementing the value and a
+ * right facing button for incrementing it) or <code>VERTICAL</code>
+ * (which have an upward facing button for decrementing the value
+ * and a downward facing buttons for incrementing it).
+ * </p><p>
+ * On some platforms, the size of the slider's thumb can be
+ * varied relative to the magnitude of the range of values it
+ * represents (that is, relative to the difference between its
+ * maximum and minimum values). Typically, this is used to
+ * indicate some proportional value such as the ratio of the
+ * visible area of a document to the total amount of space that
+ * it would take to display it. SWT supports setting the thumb
+ * size even if the underlying platform does not, but in this
+ * case the appearance of the slider will not change.
+ * </p>
+ * <dl>
+ * <dt><b>Styles:</b></dt>
+ * <dd>HORIZONTAL, VERTICAL</dd>
+ * <dt><b>Events:</b></dt>
+ * <dd>Selection</dd>
+ * </dl>
+ * <p>
+ * Note: Only one of the styles HORIZONTAL and VERTICAL may be specified.
+ * </p><p>
+ * IMPORTANT: This class is <em>not</em> intended to be subclassed.
+ * </p>
+ *
+ * @see ScrollBar
+ */
+public class Slider extends Control {
/**
* Constructs a new instance of this class given its parent
* and a style value describing its behavior and appearance.
@@ -90,447 +90,447 @@ public class Slider extends Control {
* @see Widget#checkSubclass
* @see Widget#getStyle
*/
-public Slider (Composite parent, int style) {
- super (parent, checkStyle (style));
-}
-/**
- * Adds the listener to the collection of listeners who will
- * be notified when the receiver's value changes, by sending
- * it one of the messages defined in the <code>SelectionListener</code>
- * interface.
- * <p>
- * When <code>widgetSelected</code> is called, the event object detail field contains one of the following values:
- * <code>0</code> - for the end of a drag.
- * <code>SWT.DRAG</code>.
- * <code>SWT.HOME</code>.
- * <code>SWT.END</code>.
- * <code>SWT.ARROW_DOWN</code>.
- * <code>SWT.ARROW_UP</code>.
- * <code>SWT.PAGE_DOWN</code>.
- * <code>SWT.PAGE_UP</code>.
- * <code>widgetDefaultSelected</code> is not called.
- * </p>
- *
- * @param listener the listener which should be notified
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see SelectionListener
- * @see #removeSelectionListener
- * @see SelectionEvent
+public 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.
+ * <p>
+ * When <code>widgetSelected</code> is called, the event object detail field contains one of the following values:
+ * <code>0</code> - for the end of a drag.
+ * <code>SWT.DRAG</code>.
+ * <code>SWT.HOME</code>.
+ * <code>SWT.END</code>.
+ * <code>SWT.ARROW_DOWN</code>.
+ * <code>SWT.ARROW_UP</code>.
+ * <code>SWT.PAGE_DOWN</code>.
+ * <code>SWT.PAGE_UP</code>.
+ * <code>widgetDefaultSelected</code> is not called.
+ * </p>
+ *
+ * @param listener the listener which should be notified
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see SelectionListener
+ * @see #removeSelectionListener
+ * @see SelectionEvent
*/
-public void addSelectionListener(SelectionListener listener) {
- checkWidget();
- if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
- TypedListener typedListener = new TypedListener(listener);
- addListener(SWT.Selection,typedListener);
- addListener(SWT.DefaultSelection,typedListener);
-}
-static int checkStyle (int style) {
- return checkBits (style, SWT.HORIZONTAL, SWT.VERTICAL, 0, 0, 0, 0);
-}
-public Point computeSize (int wHint, int hHint, boolean changed) {
- checkWidget();
- 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;
- Display display = getDisplay ();
- int [] argList = {
- OS.XmNancestorSensitive, 1,
- OS.XmNhighlightThickness, display.textHighlightThickness,
- OS.XmNborderWidth, (style & SWT.BORDER) != 0 ? 1 : 0,
- OS.XmNorientation, ((style & SWT.H_SCROLL) != 0) ? OS.XmHORIZONTAL : OS.XmVERTICAL,
- };
- int parentHandle = parent.handle;
- handle = OS.XmCreateScrollBar (parentHandle, null, argList, argList.length / 2);
- if (handle == 0) error (SWT.ERROR_NO_HANDLES);
-}
-/**
- * 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 void addSelectionListener(SelectionListener listener) {
+ checkWidget();
+ if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+ TypedListener typedListener = new TypedListener(listener);
+ addListener(SWT.Selection,typedListener);
+ addListener(SWT.DefaultSelection,typedListener);
+}
+static int checkStyle (int style) {
+ return checkBits (style, SWT.HORIZONTAL, SWT.VERTICAL, 0, 0, 0, 0);
+}
+public Point computeSize (int wHint, int hHint, boolean changed) {
+ checkWidget();
+ 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;
+ Display display = getDisplay ();
+ int [] argList = {
+ OS.XmNancestorSensitive, 1,
+ OS.XmNhighlightThickness, display.textHighlightThickness,
+ OS.XmNborderWidth, (style & SWT.BORDER) != 0 ? 1 : 0,
+ OS.XmNorientation, ((style & SWT.H_SCROLL) != 0) ? OS.XmHORIZONTAL : OS.XmVERTICAL,
+ };
+ int parentHandle = parent.handle;
+ handle = OS.XmCreateScrollBar (parentHandle, null, argList, argList.length / 2);
+ if (handle == 0) error (SWT.ERROR_NO_HANDLES);
+}
+/**
+ * Returns the amount that the receiver's value will be
+ * modified by when the up/down (or right/left) arrows
+ * are pressed.
+ *
+ * @return the increment
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
*/
-public int getIncrement () {
- checkWidget();
- int [] argList = {OS.XmNincrement, 0};
- OS.XtGetValues (handle, argList, argList.length / 2);
- return argList [1];
-}
-/**
- * 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 getIncrement () {
+ checkWidget();
+ int [] argList = {OS.XmNincrement, 0};
+ OS.XtGetValues (handle, argList, argList.length / 2);
+ return argList [1];
+}
+/**
+ * Returns the maximum value which the receiver will allow.
+ *
+ * @return the maximum
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
*/
-public int getMaximum () {
- checkWidget();
- int [] argList = {OS.XmNmaximum, 0};
- OS.XtGetValues (handle, argList, argList.length / 2);
- return argList [1];
-}
-/**
- * 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 getMaximum () {
+ checkWidget();
+ int [] argList = {OS.XmNmaximum, 0};
+ OS.XtGetValues (handle, argList, argList.length / 2);
+ return argList [1];
+}
+/**
+ * Returns the minimum value which the receiver will allow.
+ *
+ * @return the minimum
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
*/
-public int getMinimum () {
- checkWidget();
- int [] argList = {OS.XmNminimum, 0};
- OS.XtGetValues (handle, argList, argList.length / 2);
- return argList [1];
-}
-/**
- * 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 getMinimum () {
+ checkWidget();
+ int [] argList = {OS.XmNminimum, 0};
+ OS.XtGetValues (handle, argList, argList.length / 2);
+ return argList [1];
+}
+/**
+ * Returns the amount that the receiver's value will be
+ * modified by when the page increment/decrement areas
+ * are selected.
+ *
+ * @return the page increment
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
*/
-public int getPageIncrement () {
- checkWidget();
- int [] argList = {OS.XmNpageIncrement, 0};
- OS.XtGetValues (handle, argList, argList.length / 2);
- return argList [1];
-}
-/**
- * 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 getPageIncrement () {
+ checkWidget();
+ int [] argList = {OS.XmNpageIncrement, 0};
+ OS.XtGetValues (handle, argList, argList.length / 2);
+ return argList [1];
+}
+/**
+ * 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();
- int [] argList = {OS.XmNvalue, 0};
- OS.XtGetValues (handle, argList, argList.length / 2);
- return argList [1];
-}
-/**
- * Returns the size of the receiver's thumb relative to the
- * difference between its maximum and minimum values.
- *
- * @return the thumb value
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
+public int getSelection () {
+ checkWidget();
+ int [] argList = {OS.XmNvalue, 0};
+ OS.XtGetValues (handle, argList, argList.length / 2);
+ return argList [1];
+}
+/**
+ * Returns the size of the receiver's thumb relative to the
+ * difference between its maximum and minimum values.
+ *
+ * @return the thumb value
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
*/
-public int getThumb () {
- checkWidget();
- int [] 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, VALUE_CHANGED_CALLBACK);
- OS.XtAddCallback (handle, OS.XmNdragCallback, windowProc, DRAG_CALLBACK);
- OS.XtAddCallback (handle, OS.XmNtoBottomCallback, windowProc, TO_BOTTOM_CALLBACK);
- OS.XtAddCallback (handle, OS.XmNtoTopCallback, windowProc, TO_TOP_CALLBACK);
- OS.XtAddCallback (handle, OS.XmNincrementCallback, windowProc, INCREMENT_CALLBACK);
- OS.XtAddCallback (handle, OS.XmNdecrementCallback, windowProc, DECREMENT_CALLBACK);
- OS.XtAddCallback (handle, OS.XmNpageIncrementCallback, windowProc, PAGE_INCREMENT_CALLBACK);
- OS.XtAddCallback (handle, OS.XmNpageDecrementCallback, windowProc, PAGE_DECREMENT_CALLBACK);
-}
-void overrideTranslations () {
- Display display = getDisplay ();
- OS.XtOverrideTranslations (handle, display.tabTranslations);
-}
-/**
- * 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 int getThumb () {
+ checkWidget();
+ 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, VALUE_CHANGED_CALLBACK);
+ OS.XtAddCallback (handle, OS.XmNdragCallback, windowProc, DRAG_CALLBACK);
+ OS.XtAddCallback (handle, OS.XmNtoBottomCallback, windowProc, TO_BOTTOM_CALLBACK);
+ OS.XtAddCallback (handle, OS.XmNtoTopCallback, windowProc, TO_TOP_CALLBACK);
+ OS.XtAddCallback (handle, OS.XmNincrementCallback, windowProc, INCREMENT_CALLBACK);
+ OS.XtAddCallback (handle, OS.XmNdecrementCallback, windowProc, DECREMENT_CALLBACK);
+ OS.XtAddCallback (handle, OS.XmNpageIncrementCallback, windowProc, PAGE_INCREMENT_CALLBACK);
+ OS.XtAddCallback (handle, OS.XmNpageDecrementCallback, windowProc, PAGE_DECREMENT_CALLBACK);
+}
+void overrideTranslations () {
+ Display display = getDisplay ();
+ OS.XtOverrideTranslations (handle, display.tabTranslations);
+}
+/**
+ * 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 sendScrollEvent (int detail) {
- Event event = new Event ();
- event.detail = detail;
- sendEvent (SWT.Selection, event);
-}
-/**
- * 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 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 sendScrollEvent (int detail) {
+ Event event = new Event ();
+ event.detail = detail;
+ sendEvent (SWT.Selection, event);
+}
+/**
+ * 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;
- int [] argList = {OS.XmNincrement, value};
- OS.XtSetValues (handle, argList, argList.length / 2);
-}
-/**
- * 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 setIncrement (int value) {
+ checkWidget();
+ if (value < 1) return;
+ int [] argList = {OS.XmNincrement, value};
+ OS.XtSetValues (handle, argList, argList.length / 2);
+}
+/**
+ * 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;
- 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 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 setMaximum (int value) {
+ checkWidget();
+ 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 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;
- 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 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 setMinimum (int value) {
+ checkWidget();
+ 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 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;
- int [] argList = {OS.XmNpageIncrement, value};
- OS.XtSetValues (handle, argList, argList.length / 2);
-}
-/**
- * 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 setPageIncrement (int value) {
+ checkWidget();
+ if (value < 1) return;
+ int [] argList = {OS.XmNpageIncrement, value};
+ OS.XtSetValues (handle, argList, argList.length / 2);
+}
+/**
+ * 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();
- 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 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 setSelection (int value) {
+ checkWidget();
+ 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 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();
- 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);
-}
-/**
- * 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 setThumb (int value) {
+ checkWidget();
+ 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);
+}
+/**
+ * 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 (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);
-}
-int XmNdecrementCallback (int w, int client_data, int call_data) {
- sendScrollEvent (SWT.ARROW_UP);
- return 0;
-}
-int XmNdragCallback (int w, int client_data, int call_data) {
- sendScrollEvent (SWT.DRAG);
- return 0;
-}
-int XmNincrementCallback (int w, int client_data, int call_data) {
- sendScrollEvent (SWT.ARROW_DOWN);
- return 0;
-}
-int XmNpageDecrementCallback (int w, int client_data, int call_data) {
- sendScrollEvent (SWT.PAGE_UP);
- return 0;
-}
-int XmNpageIncrementCallback (int w, int client_data, int call_data) {
- sendScrollEvent (SWT.PAGE_DOWN);
- return 0;
-}
-int XmNtoBottomCallback (int w, int client_data, int call_data) {
- sendScrollEvent (SWT.END);
- return 0;
-}
-int XmNtoTopCallback (int w, int client_data, int call_data) {
- sendScrollEvent (SWT.HOME);
- return 0;
-}
-int XmNvalueChangedCallback (int w, int client_data, int call_data) {
- sendScrollEvent (SWT.NONE);
- return 0;
-}
-}
+public void setValues (int selection, int minimum, int maximum, int thumb, int increment, int pageIncrement) {
+ checkWidget();
+ if (minimum < 0) return;
+ if (maximum < 0) return;
+ if (thumb < 1) return;
+ if (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);
+}
+int XmNdecrementCallback (int w, int client_data, int call_data) {
+ sendScrollEvent (SWT.ARROW_UP);
+ return 0;
+}
+int XmNdragCallback (int w, int client_data, int call_data) {
+ sendScrollEvent (SWT.DRAG);
+ return 0;
+}
+int XmNincrementCallback (int w, int client_data, int call_data) {
+ sendScrollEvent (SWT.ARROW_DOWN);
+ return 0;
+}
+int XmNpageDecrementCallback (int w, int client_data, int call_data) {
+ sendScrollEvent (SWT.PAGE_UP);
+ return 0;
+}
+int XmNpageIncrementCallback (int w, int client_data, int call_data) {
+ sendScrollEvent (SWT.PAGE_DOWN);
+ return 0;
+}
+int XmNtoBottomCallback (int w, int client_data, int call_data) {
+ sendScrollEvent (SWT.END);
+ return 0;
+}
+int XmNtoTopCallback (int w, int client_data, int call_data) {
+ sendScrollEvent (SWT.HOME);
+ return 0;
+}
+int XmNvalueChangedCallback (int w, int client_data, int call_data) {
+ sendScrollEvent (SWT.NONE);
+ return 0;
+}
+}
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
index 2c4cbb150d..6f07fdc41d 100755
--- 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
@@ -1,18 +1,18 @@
-package org.eclipse.swt.widgets;
-
-/*
+package org.eclipse.swt.widgets;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-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.*;
-
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+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.*;
+
/**
* Instances of this class are selectable user interface
* objects that allow the user to enter and modify text.
@@ -29,28 +29,28 @@ import org.eclipse.swt.events.*;
* IMPORTANT: This class is <em>not</em> intended to be subclassed.
* </p>
*/
-public class Text extends Scrollable {
- char echoCharacter;
- boolean ignoreChange;
- String hiddenText;
- XmTextVerifyCallbackStruct textVerify;
- int drawCount;
-
- static final boolean IsGB18030;
- 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";
- IsGB18030 = Converter.defaultCodePage ().endsWith ("18030");
- }
-
+public class Text extends Scrollable {
+ char echoCharacter;
+ boolean ignoreChange;
+ String hiddenText;
+ XmTextVerifyCallbackStruct textVerify;
+ int drawCount;
+
+ static final boolean IsGB18030;
+ 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";
+ IsGB18030 = Converter.defaultCodePage ().endsWith ("18030");
+ }
+
/**
* Constructs a new instance of this class given its parent
* and a style value describing its behavior and appearance.
@@ -82,1030 +82,1030 @@ public class Text extends Scrollable {
* @see Widget#checkSubclass
* @see Widget#getStyle
*/
-public Text (Composite parent, int style) {
- super (parent, checkStyle (style));
-}
-
-/**
- * Adds the listener to the collection of listeners who will
- * be notified when the receiver's text is modified, by sending
- * it one of the messages defined in the <code>ModifyListener</code>
- * interface.
- *
- * @param listener the listener which should be notified
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see ModifyListener
- * @see #removeModifyListener
+public Text (Composite parent, int style) {
+ super (parent, checkStyle (style));
+}
+
+/**
+ * Adds the listener to the collection of listeners who will
+ * be notified when the receiver's text is modified, by sending
+ * it one of the messages defined in the <code>ModifyListener</code>
+ * interface.
+ *
+ * @param listener the listener which should be notified
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see ModifyListener
+ * @see #removeModifyListener
*/
-public void addModifyListener (ModifyListener listener) {
- checkWidget();
- if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
- TypedListener typedListener = new TypedListener (listener);
- addListener (SWT.Modify, typedListener);
-}
-/**
- * Adds the listener to the collection of listeners who will
- * be notified when the control is selected, by sending
- * it one of the messages defined in the <code>SelectionListener</code>
- * interface.
- * <p>
- * <code>widgetSelected</code> is not called for texts.
- * <code>widgetDefaultSelected</code> is typically called when ENTER is pressed in a single-line text.
- * </p>
- *
- * @param listener the listener which should be notified
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see SelectionListener
- * @see #removeSelectionListener
- * @see SelectionEvent
+public void 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.
+ * <p>
+ * <code>widgetSelected</code> is not called for texts.
+ * <code>widgetDefaultSelected</code> is typically called when ENTER is pressed in a single-line text.
+ * </p>
+ *
+ * @param listener the listener which should be notified
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see SelectionListener
+ * @see #removeSelectionListener
+ * @see SelectionEvent
*/
-public void addSelectionListener(SelectionListener listener) {
- checkWidget();
- if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
- TypedListener typedListener = new TypedListener(listener);
- addListener(SWT.Selection,typedListener);
- addListener(SWT.DefaultSelection,typedListener);
-}
-/**
- * Adds the listener to the collection of listeners who will
- * be notified when the receiver's text is verified, by sending
- * it one of the messages defined in the <code>VerifyListener</code>
- * interface.
- *
- * @param listener the listener which should be notified
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see VerifyListener
- * @see #removeVerifyListener
+public void addSelectionListener(SelectionListener listener) {
+ checkWidget();
+ if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+ TypedListener typedListener = new TypedListener(listener);
+ addListener(SWT.Selection,typedListener);
+ addListener(SWT.DefaultSelection,typedListener);
+}
+/**
+ * Adds the listener to the collection of listeners who will
+ * be notified when the receiver's text is verified, by sending
+ * it one of the messages defined in the <code>VerifyListener</code>
+ * interface.
+ *
+ * @param listener the listener which should be notified
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see VerifyListener
+ * @see #removeVerifyListener
*/
-public void addVerifyListener (VerifyListener listener) {
- checkWidget();
- if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
- TypedListener typedListener = new TypedListener (listener);
- addListener (SWT.Verify, typedListener);
-}
-/**
- * Appends a string.
- * <p>
- * The new text is appended to the text at
- * the end of the widget.
- * </p>
- *
- * @param string the string to be appended
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the 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 addVerifyListener (VerifyListener listener) {
+ checkWidget();
+ if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+ TypedListener typedListener = new TypedListener (listener);
+ addListener (SWT.Verify, typedListener);
+}
+/**
+ * Appends a string.
+ * <p>
+ * The new text is appended to the text at
+ * the end of the widget.
+ * </p>
+ *
+ * @param string the string to be appended
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if the 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);
- int position = OS.XmTextGetLastPosition (handle);
- byte [] buffer = Converter.wcsToMbcs (getCodePage (), 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) {
- style = checkBits (style, SWT.LEFT, SWT.CENTER, SWT.RIGHT, 0, 0, 0);
- if ((style & SWT.SINGLE) != 0) style &= ~(SWT.H_SCROLL | SWT.V_SCROLL | SWT.WRAP);
- if ((style & SWT.WRAP) != 0) style |= SWT.MULTI;
- 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.
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the 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);
+ int position = OS.XmTextGetLastPosition (handle);
+ byte [] buffer = Converter.wcsToMbcs (getCodePage (), 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) {
+ style = checkBits (style, SWT.LEFT, SWT.CENTER, SWT.RIGHT, 0, 0, 0);
+ if ((style & SWT.SINGLE) != 0) style &= ~(SWT.H_SCROLL | SWT.V_SCROLL | SWT.WRAP);
+ if ((style & SWT.WRAP) != 0) style |= SWT.MULTI;
+ 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.
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the 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();
- int xDisplay = OS.XtDisplay (handle);
- if (xDisplay == 0) return;
- OS.XmTextClearSelection (handle, OS.XtLastTimestampProcessed (xDisplay));
-}
-public Point computeSize (int wHint, int hHint, boolean changed) {
- checkWidget();
- int width = wHint;
- int height = hHint;
- if (wHint == SWT.DEFAULT || hHint == SWT.DEFAULT) {
- 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;
- if ((style & SWT.SINGLE) != 0) {
- xmString = OS.XmStringParseText (
- buffer,
- 0,
- OS.XmFONTLIST_DEFAULT_TAG,
- OS.XmCHARSET_TEXT,
- null,
- 0,
- 0);
- } else {
- xmString = OS.XmStringGenerate (
- buffer,
- OS.XmFONTLIST_DEFAULT_TAG,
- OS.XmCHARSET_TEXT,
- null);
- }
- int fontList = font.handle;
- if (hHint == SWT.DEFAULT) {
- if ((style & SWT.SINGLE) != 0) {
- height = getLineHeight ();
- } else {
- height = OS.XmStringHeight (fontList, xmString);
- }
- }
- if (wHint == SWT.DEFAULT) width = OS.XmStringWidth(fontList, 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) {
- checkWidget();
- 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.
- * <p>
- * The current selection is copied to the clipboard.
- * </p>
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
+public void clearSelection () {
+ checkWidget();
+ int xDisplay = OS.XtDisplay (handle);
+ if (xDisplay == 0) return;
+ OS.XmTextClearSelection (handle, OS.XtLastTimestampProcessed (xDisplay));
+}
+public Point computeSize (int wHint, int hHint, boolean changed) {
+ checkWidget();
+ int width = wHint;
+ int height = hHint;
+ if (wHint == SWT.DEFAULT || hHint == SWT.DEFAULT) {
+ 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;
+ if ((style & SWT.SINGLE) != 0) {
+ xmString = OS.XmStringParseText (
+ buffer,
+ 0,
+ OS.XmFONTLIST_DEFAULT_TAG,
+ OS.XmCHARSET_TEXT,
+ null,
+ 0,
+ 0);
+ } else {
+ xmString = OS.XmStringGenerate (
+ buffer,
+ OS.XmFONTLIST_DEFAULT_TAG,
+ OS.XmCHARSET_TEXT,
+ null);
+ }
+ int fontList = font.handle;
+ if (hHint == SWT.DEFAULT) {
+ if ((style & SWT.SINGLE) != 0) {
+ height = getLineHeight ();
+ } else {
+ height = OS.XmStringHeight (fontList, xmString);
+ }
+ }
+ if (wHint == SWT.DEFAULT) width = OS.XmStringWidth(fontList, 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) {
+ checkWidget();
+ 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.
+ * <p>
+ * The current selection is copied to the clipboard.
+ * </p>
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
*/
-public void copy () {
- checkWidget();
- 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, !IsGB18030 && (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,
- OS.XmNancestorSensitive, 1,
- };
- int parentHandle = parent.handle;
- if ((style & SWT.SINGLE) != 0) {
- handle = OS.XmCreateTextField (parentHandle, 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 [] {
- /*
- * Bug in Motif. Setting the margin width to zero for
- * a single line text field causes the field to draw
- * garbage when the caret is placed at the start of
- * the widget. The fix is to not set the margin width.
- */
-// OS.XmNmarginWidth, 0,
- OS.XmNmarginHeight, 0,
- OS.XmNshadowThickness, 0,
- };
- OS.XtSetValues (handle, argList3, argList3.length / 2);
- }
- } else {
- handle = OS.XmCreateScrolledText (parentHandle, new byte [0], argList1, argList1.length / 2);
- if (handle == 0) error (SWT.ERROR_NO_HANDLES);
- scrolledHandle = OS.XtParent (handle);
- }
-}
-ScrollBar createScrollBar (int type) {
- return createStandardBar (type);
-}
-/**
- * Cuts the selected text.
- * <p>
- * The current selection is first copied to the
- * clipboard and then deleted from the widget.
- * </p>
- *
- * @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 copy () {
+ checkWidget();
+ 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, !IsGB18030 && (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,
+ OS.XmNancestorSensitive, 1,
+ };
+ int parentHandle = parent.handle;
+ if ((style & SWT.SINGLE) != 0) {
+ handle = OS.XmCreateTextField (parentHandle, 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 [] {
+ /*
+ * Bug in Motif. Setting the margin width to zero for
+ * a single line text field causes the field to draw
+ * garbage when the caret is placed at the start of
+ * the widget. The fix is to not set the margin width.
+ */
+// OS.XmNmarginWidth, 0,
+ OS.XmNmarginHeight, 0,
+ OS.XmNshadowThickness, 0,
+ };
+ OS.XtSetValues (handle, argList3, argList3.length / 2);
+ }
+ } else {
+ handle = OS.XmCreateScrolledText (parentHandle, new byte [0], argList1, argList1.length / 2);
+ if (handle == 0) error (SWT.ERROR_NO_HANDLES);
+ scrolledHandle = OS.XtParent (handle);
+ }
+}
+ScrollBar createScrollBar (int type) {
+ return createStandardBar (type);
+}
+/**
+ * Cuts the selected text.
+ * <p>
+ * The current selection is first copied to the
+ * clipboard and then deleted from the widget.
+ * </p>
+ *
+ * @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();
- int xDisplay = OS.XtDisplay (handle);
- if (xDisplay == 0) return;
- OS.XmTextCut (handle, OS.XtLastTimestampProcessed (xDisplay));
-}
-int defaultBackground () {
- return getDisplay ().textBackground;
-}
-Font 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.
- * </p>
- *
- * @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 void cut () {
+ checkWidget();
+ int xDisplay = OS.XtDisplay (handle);
+ if (xDisplay == 0) return;
+ OS.XmTextCut (handle, OS.XtLastTimestampProcessed (xDisplay));
+}
+int defaultBackground () {
+ return getDisplay ().textBackground;
+}
+Font 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.
+ * </p>
+ *
+ * @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 getLineNumber (OS.XmTextGetInsertionPosition (handle));
-}
-/**
- * Gets the location of the caret.
- * <p>
- * The location of the caret is returned.
- * </p>
- *
- * @return a point, the location of the caret
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
+public int getCaretLineNumber () {
+ checkWidget();
+ return getLineNumber (OS.XmTextGetInsertionPosition (handle));
+}
+/**
+ * Gets the location of the caret.
+ * <p>
+ * The location of the caret is returned.
+ * </p>
+ *
+ * @return a point, the location of the caret
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
*/
-public Point getCaretLocation () {
- checkWidget();
- 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.
- * </p>
- *
- * @return the position of the caret
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
+public Point getCaretLocation () {
+ checkWidget();
+ 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.
+ * </p>
+ *
+ * @return the position of the caret
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
*/
-public int getCaretPosition () {
- checkWidget();
- return OS.XmTextGetInsertionPosition (handle);
-}
-/**
- * Gets the number of characters.
- *
- * @return number of characters in the widget
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
+public int getCaretPosition () {
+ checkWidget();
+ return OS.XmTextGetInsertionPosition (handle);
+}
+/**
+ * Gets the number of characters.
+ *
+ * @return number of characters in the widget
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
*/
-public int getCharCount () {
- checkWidget();
- return OS.XmTextGetLastPosition (handle);
-}
-/**
- * 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.
- * </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 getCharCount () {
+ checkWidget();
+ return OS.XmTextGetLastPosition (handle);
+}
+/**
+ * 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.
+ * </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 getDoubleClickEnabled () {
- checkWidget();
- int [] argList = {OS.XmNselectionArrayCount, 0};
- OS.XtGetValues (handle, argList, argList.length / 2);
- return argList [1] != 1;
-}
-/**
- * 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.
- * </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 getDoubleClickEnabled () {
+ checkWidget();
+ int [] argList = {OS.XmNselectionArrayCount, 0};
+ OS.XtGetValues (handle, argList, argList.length / 2);
+ return argList [1] != 1;
+}
+/**
+ * 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.
+ * </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 char getEchoChar () {
- checkWidget();
- return echoCharacter;
-}
-/**
- * Gets the 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 char getEchoChar () {
+ checkWidget();
+ return echoCharacter;
+}
+/**
+ * Gets the 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 boolean getEditable () {
- checkWidget();
- /*
- * 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.
- *
- * @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 boolean getEditable () {
+ checkWidget();
+ /*
+ * 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.
+ *
+ * @return the number of lines in the widget
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
*/
-public int getLineCount () {
- checkWidget();
- if ((style & SWT.SINGLE) != 0) return 1;
- int lastChar = echoCharacter != '\0' ? hiddenText.length () : OS.XmTextGetLastPosition (handle);
- return getLineNumber (lastChar) + 1;
-}
-/**
- * Gets the line delimiter.
- *
- * @return a string that is the line delimiter
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
+public int getLineCount () {
+ checkWidget();
+ if ((style & SWT.SINGLE) != 0) return 1;
+ int lastChar = echoCharacter != '\0' ? hiddenText.length () : OS.XmTextGetLastPosition (handle);
+ return getLineNumber (lastChar) + 1;
+}
+/**
+ * Gets the line delimiter.
+ *
+ * @return a string that is the line delimiter
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
*/
-public String getLineDelimiter () {
- checkWidget();
- return "\n";
-}
-/**
- * Gets the height of a line.
- *
- * @return the height of a row of text
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
+public String getLineDelimiter () {
+ checkWidget();
+ return "\n";
+}
+/**
+ * Gets the height of a line.
+ *
+ * @return the height of a row of text
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
*/
-public int getLineHeight () {
- checkWidget();
- return 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 (OS.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 (OS.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;
-}
-int getNavigationType () {
- /*
- * Bug in Motif. On Solaris only, the implementation
- * of XtGetValues for XmText does not check for a zero
- * pointer in the arg list and GP's. The fix is to
- * allocate and free memory for the arg list value.
- */
- if ((style & SWT.SINGLE) != 0) {
- return super.getNavigationType ();
- }
- int ptr = OS.XtMalloc (4);
- if (ptr == 0) return OS.XmNONE;
- int [] argList = {OS.XmNnavigationType, ptr};
- OS.XtGetValues (handle, argList, argList.length / 2);
- int [] buffer = new int [1];
- OS.memmove (buffer, ptr, 4);
- OS.XtFree (ptr);
- return buffer [0];
-}
-/**
- * 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.
- * </p>
- *
- * @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 int getLineHeight () {
+ checkWidget();
+ 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 (OS.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 (OS.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;
+}
+int getNavigationType () {
+ /*
+ * Bug in Motif. On Solaris only, the implementation
+ * of XtGetValues for XmText does not check for a zero
+ * pointer in the arg list and GP's. The fix is to
+ * allocate and free memory for the arg list value.
+ */
+ if ((style & SWT.SINGLE) != 0) {
+ return super.getNavigationType ();
+ }
+ int ptr = OS.XtMalloc (4);
+ if (ptr == 0) return OS.XmNONE;
+ int [] argList = {OS.XmNnavigationType, ptr};
+ OS.XtGetValues (handle, argList, argList.length / 2);
+ int [] buffer = new int [1];
+ OS.memmove (buffer, ptr, 4);
+ OS.XtFree (ptr);
+ return buffer [0];
+}
+/**
+ * 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.
+ * </p>
+ *
+ * @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();
- 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.
- *
- * @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 Point getSelection () {
+ checkWidget();
+ 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.
+ *
+ * @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();
- 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.
- *
- * @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 int getSelectionCount () {
+ checkWidget();
+ 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.
+ *
+ * @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();
- 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 (getCodePage (), buffer));
-}
-/**
- * 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.
- * </p>
- *
- * @return the number of tab characters
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
+public String getSelectionText () {
+ checkWidget();
+ 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 (getCodePage (), buffer));
+}
+/**
+ * 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.
+ * </p>
+ *
+ * @return the number of tab characters
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
*/
-public int getTabs () {
- checkWidget();
- /* Tabs are not supported in MOTIF. */
- return 8;
-}
-/**
- * Gets the widget text.
- * <p>
- * The text for a text widget is the characters in the widget.
- * </p>
- *
- * @return the widget text
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
+public int getTabs () {
+ checkWidget();
+ /* Tabs are not supported in MOTIF. */
+ return 8;
+}
+/**
+ * Gets the widget text.
+ * <p>
+ * The text for a text widget is the characters in the widget.
+ * </p>
+ *
+ * @return the widget text
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
*/
-public String getText () {
- checkWidget();
- 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 (getCodePage (), buffer));
-}
-/**
- * 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.
- * </p>
- *
- * @param start the start of the range
- * @param end the end of the range
- * @return the range of text
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
+public String getText () {
+ checkWidget();
+ 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 (getCodePage (), buffer));
+}
+/**
+ * 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.
+ * </p>
+ *
+ * @param start the start of the range
+ * @param end the end of the range
+ * @return the range of text
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
*/
-public String getText (int start, int end) {
- checkWidget();
- 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 (getCodePage (), buffer);
- if (code == OS.XmCOPY_TRUNCATED) {
- numChars = OS.XmTextGetLastPosition (handle) - start;
- }
- return new String (unicode, 0, numChars);
-}
-/**
- * Returns the maximum number of characters that the receiver is capable of holding.
- * <p>
- * If this has not been changed by <code>setTextLimit()</code>,
- * it will be the constant <code>Text.LIMIT</code>.
- * </p>
- *
- * @return the text limit
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
+public String getText (int start, int end) {
+ checkWidget();
+ 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 (getCodePage (), buffer);
+ if (code == OS.XmCOPY_TRUNCATED) {
+ numChars = OS.XmTextGetLastPosition (handle) - start;
+ }
+ return new String (unicode, 0, numChars);
+}
+/**
+ * Returns the maximum number of characters that the receiver is capable of holding.
+ * <p>
+ * If this has not been changed by <code>setTextLimit()</code>,
+ * it will be the constant <code>Text.LIMIT</code>.
+ * </p>
+ *
+ * @return the text limit
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
*/
-public int getTextLimit () {
- checkWidget();
- return OS.XmTextGetMaxLength (handle);
-}
-/**
- * Returns the zero-relative index of the line which is currently
- * at the top of the receiver.
- * <p>
- * This index can change when lines are scrolled or new lines are added or removed.
- * </p>
- *
- * @return the index of the top line
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
+public int getTextLimit () {
+ checkWidget();
+ return OS.XmTextGetMaxLength (handle);
+}
+/**
+ * Returns the zero-relative index of the line which is currently
+ * at the top of the receiver.
+ * <p>
+ * This index can change when lines are scrolled or new lines are added or removed.
+ * </p>
+ *
+ * @return the index of the top line
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
*/
-public int getTopIndex () {
- checkWidget();
- if ((style & SWT.SINGLE) != 0) return 0;
- 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><p>
- * The top pixel changes when the widget is scrolled.
- * The top pixel does not include the widget trimming.
- * </p>
- *
- * @return the pixel position of the top line
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
+public int getTopIndex () {
+ checkWidget();
+ 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><p>
+ * The top pixel changes when the widget is scrolled.
+ * The top pixel does not include the widget trimming.
+ * </p>
+ *
+ * @return the pixel position of the top line
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
*/
-public int getTopPixel () {
- checkWidget();
- return getTopIndex () * getLineHeight ();
-}
-boolean hasIMSupport() {
- return true;
-}
-void hookEvents () {
- super.hookEvents ();
- int windowProc = getDisplay ().windowProc;
- OS.XtAddCallback (handle, OS.XmNactivateCallback, windowProc, ACTIVATE_CALLBACK);
- OS.XtAddCallback (handle, OS.XmNvalueChangedCallback, windowProc, VALUE_CHANGED_CALLBACK);
- OS.XtAddCallback (handle, OS.XmNmodifyVerifyCallback, windowProc, MODIFY_VERIFY_CALLBACK);
-}
-int inputContext () {
- /* Answer zero. The text widget uses the default MOTIF input context. */
- return 0;
-}
-/**
- * Inserts a string.
- * <p>
- * The old selection is replaced with the new text.
- * </p>
- *
- * @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 int getTopPixel () {
+ checkWidget();
+ return getTopIndex () * getLineHeight ();
+}
+boolean hasIMSupport() {
+ return true;
+}
+void hookEvents () {
+ super.hookEvents ();
+ int windowProc = getDisplay ().windowProc;
+ OS.XtAddCallback (handle, OS.XmNactivateCallback, windowProc, ACTIVATE_CALLBACK);
+ OS.XtAddCallback (handle, OS.XmNvalueChangedCallback, windowProc, VALUE_CHANGED_CALLBACK);
+ OS.XtAddCallback (handle, OS.XmNmodifyVerifyCallback, windowProc, MODIFY_VERIFY_CALLBACK);
+}
+int inputContext () {
+ /* Answer zero. The text widget uses the default MOTIF input context. */
+ return 0;
+}
+/**
+ * Inserts a string.
+ * <p>
+ * The old selection is replaced with the new text.
+ * </p>
+ *
+ * @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);
- 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 (getCodePage (), 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);
-}
-void overrideTranslations () {
- if ((style & SWT.SINGLE) != 0) {
- Display display = getDisplay ();
- OS.XtOverrideTranslations (handle, display.tabTranslations);
- }
-}
-/**
- * Pastes text from clipboard.
- * <p>
- * The selected text is deleted from the widget
- * and new text inserted from the clipboard.
- * </p>
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
+public void insert (String string) {
+ checkWidget();
+ 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 (getCodePage (), 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);
+}
+void overrideTranslations () {
+ if ((style & SWT.SINGLE) != 0) {
+ Display display = getDisplay ();
+ OS.XtOverrideTranslations (handle, display.tabTranslations);
+ }
+}
+/**
+ * Pastes text from clipboard.
+ * <p>
+ * The selected text is deleted from the widget
+ * and new text inserted from the clipboard.
+ * </p>
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
*/
-public void paste () {
- checkWidget();
- 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);
-}
-void releaseWidget () {
- super.releaseWidget ();
- hiddenText = null;
- textVerify = null;
-}
-/**
- * Removes the listener from the collection of listeners who will
- * be notified when the receiver's text is modified.
- *
- * @param listener the listener which should no longer be notified
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see ModifyListener
- * @see #addModifyListener
+public void paste () {
+ checkWidget();
+ 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);
+}
+void releaseWidget () {
+ super.releaseWidget ();
+ hiddenText = null;
+ textVerify = null;
+}
+/**
+ * Removes the listener from the collection of listeners who will
+ * be notified when the receiver's text is modified.
+ *
+ * @param listener the listener which should no longer be notified
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see ModifyListener
+ * @see #addModifyListener
*/
-public void removeModifyListener (ModifyListener listener) {
- checkWidget();
- if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
- if (eventTable == null) return;
- eventTable.unhook (SWT.Modify, listener);
-}
-/**
- * Removes the listener from the collection of listeners who will
- * be notified when the control is selected.
- *
- * @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 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 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);
-}
-byte [] sendIMKeyEvent (int type, XKeyEvent xEvent) {
- /*
- * Bug in Motif. On Solaris and Linux, XmImMbLookupString() clears
- * the characters from the IME. This causes the characters to be
- * stolen from the text widget. The fix is to detect that the IME
- * has been cleared and use XmTextInsert() to insert the stolen
- * characters. This problem does not happen on AIX.
- */
- byte [] mbcs = super.sendIMKeyEvent (type, xEvent);
- if (mbcs == null || xEvent.keycode != 0) return null;
- int [] unused = new int [1];
- byte [] buffer = new byte [2];
- int length = OS.XmImMbLookupString (handle, xEvent, buffer, buffer.length, unused, unused);
- if (length != 0) return null;
- 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);
- }
- Display display = getDisplay ();
- boolean warnings = display.getWarnings ();
- display.setWarnings (false);
- OS.XmTextReplace (handle, start [0], end [0], mbcs);
- int position = start [0] + mbcs.length - 1;
- OS.XmTextSetInsertionPosition (handle, position);
- display.setWarnings (warnings);
- return mbcs;
-}
-/**
- * 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 removeVerifyListener (VerifyListener listener) {
+ checkWidget();
+ if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+ if (eventTable == null) return;
+ eventTable.unhook (SWT.Verify, listener);
+}
+byte [] sendIMKeyEvent (int type, XKeyEvent xEvent) {
+ /*
+ * Bug in Motif. On Solaris and Linux, XmImMbLookupString() clears
+ * the characters from the IME. This causes the characters to be
+ * stolen from the text widget. The fix is to detect that the IME
+ * has been cleared and use XmTextInsert() to insert the stolen
+ * characters. This problem does not happen on AIX.
+ */
+ byte [] mbcs = super.sendIMKeyEvent (type, xEvent);
+ if (mbcs == null || xEvent.keycode != 0) return null;
+ int [] unused = new int [1];
+ byte [] buffer = new byte [2];
+ int length = OS.XmImMbLookupString (handle, xEvent, buffer, buffer.length, unused, unused);
+ if (length != 0) return null;
+ 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);
+ }
+ Display display = getDisplay ();
+ boolean warnings = display.getWarnings ();
+ display.setWarnings (false);
+ OS.XmTextReplace (handle, start [0], end [0], mbcs);
+ int position = start [0] + mbcs.length - 1;
+ OS.XmTextSetInsertionPosition (handle, position);
+ display.setWarnings (warnings);
+ return mbcs;
+}
+/**
+ * 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();
- /* 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);
-}
-boolean setBounds (int x, int y, int width, int height, boolean move, boolean resize) {
- /*
- * Bug in Motif. For some reason an Xm warning is
- * output whenever a Text widget's caret is beyond
- * the visible region during a resize. The fix is
- * to temporarily turn off warnings below.
- */
- Display display = getDisplay ();
- boolean warnings = display.getWarnings ();
- display.setWarnings (false);
- boolean changed = super.setBounds (x, y, width, height, move, resize);
- display.setWarnings(warnings);
-
- /*
- * 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
- return changed;
-}
-/**
- * Sets the double click enabled flag.
- * <p>
- * The double click flag enables or disables the
- * default action of the text widget when the user
- * double clicks.
- * </p>
- *
- * @param doubleClick the new double click flag
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
+public void selectAll () {
+ checkWidget();
+ /* 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);
+}
+boolean setBounds (int x, int y, int width, int height, boolean move, boolean resize) {
+ /*
+ * Bug in Motif. For some reason an Xm warning is
+ * output whenever a Text widget's caret is beyond
+ * the visible region during a resize. The fix is
+ * to temporarily turn off warnings below.
+ */
+ Display display = getDisplay ();
+ boolean warnings = display.getWarnings ();
+ display.setWarnings (false);
+ boolean changed = super.setBounds (x, y, width, height, move, resize);
+ display.setWarnings(warnings);
+
+ /*
+ * 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
+ return changed;
+}
+/**
+ * Sets the double click enabled flag.
+ * <p>
+ * The double click flag enables or disables the
+ * default action of the text widget when the user
+ * double clicks.
+ * </p>
+ *
+ * @param doubleClick the new double click flag
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
*/
-public void setDoubleClickEnabled (boolean doubleClick) {
- checkWidget();
- int [] argList = {OS.XmNselectionArrayCount, doubleClick ? 4 : 1};
- OS.XtSetValues (handle, argList, argList.length / 2);
-}
+public void setDoubleClickEnabled (boolean doubleClick) {
+ checkWidget();
+ int [] argList = {OS.XmNselectionArrayCount, doubleClick ? 4 : 1};
+ OS.XtSetValues (handle, argList, argList.length / 2);
+}
/**
* Sets the echo character.
* <p>
@@ -1126,52 +1126,52 @@ public void setDoubleClickEnabled (boolean doubleClick) {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public void setEchoChar (char echo) {
- checkWidget();
- 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;
-}
-/**
- * Sets the editable state.
- *
- * @param editable the new editable state
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
+public void setEchoChar (char echo) {
+ checkWidget();
+ 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;
+}
+/**
+ * Sets the editable state.
+ *
+ * @param editable the new editable state
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
*/
-public void setEditable (boolean editable) {
- checkWidget();
- 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);
-}
-public void setRedraw (boolean redraw) {
- checkWidget();
- if ((style & SWT.SINGLE) != 0) return;
- if (redraw) {
- if (--drawCount == 0) OS.XmTextEnableRedisplay(handle);
- } else {
- if (drawCount++ == 0) OS.XmTextDisableRedisplay(handle);
- }
-}
+public void setEditable (boolean editable) {
+ checkWidget();
+ 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);
+}
+public void setRedraw (boolean redraw) {
+ checkWidget();
+ 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>
@@ -1195,23 +1195,23 @@ public void setRedraw (boolean redraw) {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public void setSelection (int start) {
- checkWidget();
- /* 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);
-}
+public void setSelection (int start) {
+ checkWidget();
+ /* 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>
@@ -1236,36 +1236,36 @@ public void setSelection (int start) {
* <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();
- /* 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);
-}
+public void setSelection (int start, int end) {
+ checkWidget();
+ /* 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>
@@ -1292,31 +1292,31 @@ public void setSelection (int start, int end) {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public void setSelection (Point selection) {
- checkWidget();
- if (selection == null) error (SWT.ERROR_NULL_ARGUMENT);
- setSelection (selection.x, selection.y);
-}
-/**
- * Sets the number of tabs.
- * <p>
- * Tab stop spacing is specified in terms of the
- * space (' ') character. The width of a single
- * tab stop is the pixel width of the spaces.
- * </p>
- *
- * @param tabs the number of tabs
- *
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
+public void setSelection (Point selection) {
+ checkWidget();
+ if (selection == null) error (SWT.ERROR_NULL_ARGUMENT);
+ setSelection (selection.x, selection.y);
+}
+/**
+ * Sets the number of tabs.
+ * <p>
+ * Tab stop spacing is specified in terms of the
+ * space (' ') character. The width of a single
+ * tab stop is the pixel width of the spaces.
+ * </p>
+ *
+ * @param tabs the number of tabs
+ *
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
*/
-public void setTabs (int tabs) {
- checkWidget();
- /* Do nothing. Tabs are not supported in MOTIF. */
-}
+public void setTabs (int tabs) {
+ checkWidget();
+ /* Do nothing. Tabs are not supported in MOTIF. */
+}
/**
* Sets the contents of the receiver to the given string. If the receiver has style
* SINGLE and the argument contains multiple lines of text, the result of this
@@ -1332,23 +1332,23 @@ public void setTabs (int tabs) {
* <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 (getCodePage (), 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 (OS.IsLinux && (style & SWT.MULTI) != 0) sendEvent (SWT.Modify);
-}
+public void setText (String string) {
+ checkWidget();
+ if (string == null) error (SWT.ERROR_NULL_ARGUMENT);
+ byte [] buffer = Converter.wcsToMbcs (getCodePage (), 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 (OS.IsLinux && (style & SWT.MULTI) != 0) sendEvent (SWT.Modify);
+}
/**
* Sets the maximum number of characters that the receiver
* is capable of holding to be the argument.
@@ -1369,153 +1369,153 @@ public void setText (String string) {
* <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.XmTextSetMaxLength (handle, limit);
-}
-/**
- * Sets the zero-relative index of the line which is currently
- * at the top of the receiver. This index can change when lines
- * are scrolled or new lines are added and removed.
- *
- * @param index the index of the top item
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
+public void setTextLimit (int limit) {
+ checkWidget();
+ if (limit == 0) error (SWT.ERROR_CANNOT_BE_ZERO);
+ OS.XmTextSetMaxLength (handle, limit);
+}
+/**
+ * Sets the zero-relative index of the line which is currently
+ * at the top of the receiver. This index can change when lines
+ * are scrolled or new lines are added and removed.
+ *
+ * @param index the index of the top item
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
*/
-public void setTopIndex (int index) {
- checkWidget();
- if ((style & SWT.SINGLE) != 0) return;
- 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]);
-}
-/**
- * Shows the selection.
- * <p>
- * If the selection is already showing
- * in the receiver, this method simply returns. Otherwise,
- * lines are scrolled until the selection is visible.
- * </p>
- *
- * @exception 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 setTopIndex (int index) {
+ checkWidget();
+ 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]);
+}
+/**
+ * Shows the selection.
+ * <p>
+ * If the selection is already showing
+ * in the receiver, this method simply returns. Otherwise,
+ * lines are scrolled until the selection is visible.
+ * </p>
+ *
+ * @exception 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();
- Display display = getDisplay ();
- boolean warnings = display.getWarnings ();
- display.setWarnings (false);
- int position = OS.XmTextGetInsertionPosition (handle);
- OS.XmTextShowPosition (handle, position);
- display.setWarnings (warnings);
-}
-int traversalCode (int key, XKeyEvent xEvent) {
- int bits = super.traversalCode (key, xEvent);
- if ((style & SWT.READ_ONLY) != 0) return bits;
- if ((style & SWT.MULTI) != 0) {
- bits &= ~SWT.TRAVERSE_RETURN;
- if (key == OS.XK_Tab && xEvent != null) {
- boolean next = (xEvent.state & OS.ShiftMask) == 0;
- if (next && (xEvent.state & OS.ControlMask) == 0) {
- bits &= ~(SWT.TRAVERSE_TAB_NEXT | SWT.TRAVERSE_TAB_PREVIOUS);
- }
- }
- }
- return bits;
-}
-int xFocusIn () {
- super.xFocusIn ();
- // widget could be disposed at this point
- if (handle == 0) return 0;
- 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 xFocusOut () {
- super.xFocusOut ();
- // widget could be disposed at this point
- if (handle == 0) return 0;
- 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 XmNactivateCallback (int w, int client_data, int call_data) {
- postEvent (SWT.DefaultSelection);
- return 0;
-}
-int XmNmodifyVerifyCallback (int w, int client_data, int call_data) {
- int result = super.XmNmodifyVerifyCallback (w, client_data, call_data);
- if (result != 0) return result;
- if (echoCharacter == '\0' && !hooks (SWT.Verify) && !filters (SWT.Verify)) return result;
- XmTextVerifyCallbackStruct textVerify = new XmTextVerifyCallbackStruct ();
- OS.memmove (textVerify, call_data, 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 codePage = getCodePage ();
- String text = new String (Converter.mbcsToWcs (codePage, 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);
- event.time = xEvent.time;
- 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 (codePage, 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 (call_data, textVerify, XmTextVerifyCallbackStruct.sizeof);
- textVerify = null;
- return result;
-}
-int XmNvalueChangedCallback (int w, int client_data, int call_data) {
- if (!ignoreChange) sendEvent (SWT.Modify);
- return 0;
-}
-}
+public void showSelection () {
+ checkWidget();
+ Display display = getDisplay ();
+ boolean warnings = display.getWarnings ();
+ display.setWarnings (false);
+ int position = OS.XmTextGetInsertionPosition (handle);
+ OS.XmTextShowPosition (handle, position);
+ display.setWarnings (warnings);
+}
+int traversalCode (int key, XKeyEvent xEvent) {
+ int bits = super.traversalCode (key, xEvent);
+ if ((style & SWT.READ_ONLY) != 0) return bits;
+ if ((style & SWT.MULTI) != 0) {
+ bits &= ~SWT.TRAVERSE_RETURN;
+ if (key == OS.XK_Tab && xEvent != null) {
+ boolean next = (xEvent.state & OS.ShiftMask) == 0;
+ if (next && (xEvent.state & OS.ControlMask) == 0) {
+ bits &= ~(SWT.TRAVERSE_TAB_NEXT | SWT.TRAVERSE_TAB_PREVIOUS);
+ }
+ }
+ }
+ return bits;
+}
+int xFocusIn () {
+ super.xFocusIn ();
+ // widget could be disposed at this point
+ if (handle == 0) return 0;
+ 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 xFocusOut () {
+ super.xFocusOut ();
+ // widget could be disposed at this point
+ if (handle == 0) return 0;
+ 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 XmNactivateCallback (int w, int client_data, int call_data) {
+ postEvent (SWT.DefaultSelection);
+ return 0;
+}
+int XmNmodifyVerifyCallback (int w, int client_data, int call_data) {
+ int result = super.XmNmodifyVerifyCallback (w, client_data, call_data);
+ if (result != 0) return result;
+ if (echoCharacter == '\0' && !hooks (SWT.Verify) && !filters (SWT.Verify)) return result;
+ XmTextVerifyCallbackStruct textVerify = new XmTextVerifyCallbackStruct ();
+ OS.memmove (textVerify, call_data, 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 codePage = getCodePage ();
+ String text = new String (Converter.mbcsToWcs (codePage, 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);
+ event.time = xEvent.time;
+ 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 (codePage, 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 (call_data, textVerify, XmTextVerifyCallbackStruct.sizeof);
+ textVerify = null;
+ return result;
+}
+int XmNvalueChangedCallback (int w, int client_data, int call_data) {
+ if (!ignoreChange) sendEvent (SWT.Modify);
+ return 0;
+}
+}
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
index bf9b6d4938..92ded275b6 100755
--- 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
@@ -1,16 +1,16 @@
-package org.eclipse.swt.widgets;
-
-/*
+package org.eclipse.swt.widgets;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-import org.eclipse.swt.internal.motif.*;
-import org.eclipse.swt.*;
-import org.eclipse.swt.graphics.*;
-
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+import org.eclipse.swt.internal.motif.*;
+import org.eclipse.swt.*;
+import org.eclipse.swt.graphics.*;
+
/**
* Instances of this class support the layout of selectable
* tool bar items.
@@ -34,9 +34,9 @@ import org.eclipse.swt.graphics.*;
* IMPORTANT: This class is <em>not</em> intended to be subclassed.
* </p>
*/
-public class ToolBar extends Composite {
- int drawCount, itemCount;
- ToolItem [] items;
+public class ToolBar extends Composite {
+ int drawCount, itemCount;
+ ToolItem [] items;
/**
* Constructs a new instance of this class given its parent
* and a style value describing its behavior and appearance.
@@ -69,380 +69,380 @@ public class ToolBar extends Composite {
* @see Widget#checkSubclass
* @see Widget#getStyle
*/
-public ToolBar (Composite parent, int style) {
- super (parent, checkStyle (style));
-
- /*
- * Ensure that either of HORIZONTAL or VERTICAL is set.
- * NOTE: HORIZONTAL and VERTICAL have the same values
- * as H_SCROLL and V_SCROLL so it is necessary to first
- * clear these bits to avoid scroll bars and then reset
- * the bits using the original style supplied by the
- * programmer.
- */
- if ((style & SWT.VERTICAL) != 0) {
- this.style |= SWT.VERTICAL;
- } else {
- this.style |= SWT.HORIZONTAL;
- }
-}
-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 = 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 createHandle (int index) {
- super.createHandle (index);
- state &= ~CANVAS;
-}
-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;
-}
-/**
- * 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 ToolBar (Composite parent, int style) {
+ super (parent, checkStyle (style));
+
+ /*
+ * Ensure that either of HORIZONTAL or VERTICAL is set.
+ * NOTE: HORIZONTAL and VERTICAL have the same values
+ * as H_SCROLL and V_SCROLL so it is necessary to first
+ * clear these bits to avoid scroll bars and then reset
+ * the bits using the original style supplied by the
+ * programmer.
+ */
+ if ((style & SWT.VERTICAL) != 0) {
+ this.style |= SWT.VERTICAL;
+ } else {
+ this.style |= SWT.HORIZONTAL;
+ }
+}
+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 = 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 createHandle (int index) {
+ super.createHandle (index);
+ state &= ~CANVAS;
+}
+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;
+}
+/**
+ * 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();
- ToolItem [] items = getItems ();
- if (0 <= index && index < items.length) return items [index];
- error (SWT.ERROR_INVALID_RANGE);
- return null;
-}
-
-/**
- * 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 (int index) {
+ checkWidget();
+ ToolItem [] items = getItems ();
+ if (0 <= index && index < items.length) return items [index];
+ error (SWT.ERROR_INVALID_RANGE);
+ return null;
+}
+
+/**
+ * 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 pt) {
- checkWidget();
- 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;
-}
-
-/**
- * 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 ToolItem getItem (Point pt) {
+ checkWidget();
+ 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;
+}
+
+/**
+ * Returns the number of items contained in the receiver.
+ *
+ * @return the number of items
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
*/
-public int getItemCount () {
- checkWidget();
- return itemCount;
-}
-/**
- * Returns an array of <code>TabItem</code>s which are the items
- * in the receiver.
- * <p>
- * Note: This is not the actual structure used by the receiver
- * to maintain its list of items, so modifying the array will
- * not affect the receiver.
- * </p>
- *
- * @return the items in the receiver
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
+public int getItemCount () {
+ checkWidget();
+ return itemCount;
+}
+/**
+ * Returns an array of <code>TabItem</code>s which are the items
+ * in the receiver.
+ * <p>
+ * Note: This is not the actual structure used by the receiver
+ * to maintain its list of items, so modifying the array will
+ * not affect the receiver.
+ * </p>
+ *
+ * @return the items in the receiver
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
*/
-public ToolItem [] getItems () {
- checkWidget();
- ToolItem [] result = new ToolItem [itemCount];
- System.arraycopy (items, 0, result, 0, itemCount);
- 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 ToolItem [] getItems () {
+ checkWidget();
+ ToolItem [] result = new ToolItem [itemCount];
+ System.arraycopy (items, 0, result, 0, itemCount);
+ 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();
- Rectangle rect = getClientArea ();
- return layout (rect.width, rect.height, false) [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 tool item is null</li>
- * <li>ERROR_INVALID_ARGUMENT - if the tool item has been disposed</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
+public int getRowCount () {
+ checkWidget();
+ Rectangle rect = getClientArea ();
+ return layout (rect.width, rect.height, false) [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 tool item is null</li>
+ * <li>ERROR_INVALID_ARGUMENT - if the tool item has been disposed</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
*/
-public int indexOf (ToolItem item) {
- checkWidget();
- if (item == null) error (SWT.ERROR_NULL_ARGUMENT);
- if (item.isDisposed()) error(SWT.ERROR_INVALID_ARGUMENT);
- ToolItem [] items = getItems ();
- for (int i=0; i<items.length; i++) {
- if (items [i] == item) return i;
- }
- return -1;
-}
-int [] layoutHorizontal (int nWidth, int nHeight, boolean resize) {
- int xSpacing = 0, ySpacing = (style & SWT.NO_FOCUS) != 0 ? 4 : 2;
- 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};
-}
-int [] layoutVertical (int nWidth, int nHeight, boolean resize) {
- int xSpacing = (style & SWT.NO_FOCUS) != 0 ? 4 : 2, ySpacing = 0;
- int marginWidth = 0, marginHeight = 0;
- ToolItem [] children = getItems ();
- int length = children.length;
- int x = marginWidth, y = marginHeight;
- int maxWidth = 0, maxY = 0, cols = 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 && y + rect.height > nHeight) {
- cols++;
- x += xSpacing + maxWidth; y = marginHeight;
- maxWidth = 0;
- }
- maxWidth = Math.max (maxWidth, rect.width);
- if (resize) {
- child.setBounds (x, y, rect.width, rect.height);
- }
- y += ySpacing + rect.height;
- maxY = Math.max (maxY, y);
- }
- return new int [] {cols, x + maxWidth, maxY};
-}
-int [] layout (int nWidth, int nHeight, boolean resize) {
- if ((style & SWT.VERTICAL) != 0) {
- return layoutVertical (nWidth, nHeight, resize);
- } else {
- return layoutHorizontal (nWidth, nHeight, resize);
- }
-}
-boolean mnemonicHit (char key) {
- for (int i = 0; i < items.length; i++) {
- ToolItem item = items [i];
- if (item != null) {
- char mnemonic = findMnemonic (item.getText ());
- if (mnemonic != '\0') {
- if (Character.toUpperCase (key) == Character.toUpperCase (mnemonic)) {
- XmProcessTraversal (item.handle, OS.XmTRAVERSE_CURRENT);
- item.click (false, null);
- return true;
- }
- }
- }
- }
- return false;
-}
-boolean mnemonicMatch (char key) {
- for (int i = 0; i < items.length; i++) {
- ToolItem item = items [i];
- if (item != null && item.getEnabled ()) {
- char mnemonic = findMnemonic (item.getText ());
- if (mnemonic != '\0') {
- if (Character.toUpperCase (key) == Character.toUpperCase (mnemonic)) {
- return true;
- }
- }
- }
- }
- return false;
-}
-void propagateWidget (boolean enabled) {
- super.propagateWidget (enabled);
- for (int i=0; i<itemCount; i++) {
- items [i].propagateWidget (enabled);
- }
-}
-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.releaseResources ();
- }
- items = null;
- super.releaseWidget ();
-}
-void setBackgroundPixel (int pixel) {
- super.setBackgroundPixel (pixel);
- for (int i = 0; i < items.length; i++) {
- if (items[i] != null) {
- items[i].setBackgroundPixel (pixel);
- }
- }
-}
-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 setFont (Font font) {
- checkWidget();
- super.setFont (font);
- for (int i=0; i<items.length; i++) {
- ToolItem item = items [i];
- if (item != null) {
- Point size = item.computeSize ();
- item.setSize (size.x, size.y, false);
- }
- }
- relayout ();
-}
-void setForegroundPixel (int pixel) {
- super.setForegroundPixel (pixel);
- for (int i = 0; i < items.length; i++) {
- if (items[i] != null) {
- items[i].setForegroundPixel (pixel);
- }
- }
-}
-public void setRedraw (boolean redraw) {
- checkWidget();
- 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);
-}
-boolean setTabItemFocus () {
- int index = 0;
- while (index < items.length) {
- ToolItem item = items [index];
- if (item != null && (item.style & SWT.SEPARATOR) == 0) {
- if (item.getEnabled ()) break;
- }
- index++;
- }
- if (index == items.length) return false;
- return super.setTabItemFocus ();
-}
-int traversalCode (int key, XKeyEvent xEvent) {
- return super.traversalCode (key, xEvent) | SWT.TRAVERSE_MNEMONIC;
-}
-}
+public int indexOf (ToolItem item) {
+ checkWidget();
+ if (item == null) error (SWT.ERROR_NULL_ARGUMENT);
+ if (item.isDisposed()) error(SWT.ERROR_INVALID_ARGUMENT);
+ ToolItem [] items = getItems ();
+ for (int i=0; i<items.length; i++) {
+ if (items [i] == item) return i;
+ }
+ return -1;
+}
+int [] layoutHorizontal (int nWidth, int nHeight, boolean resize) {
+ int xSpacing = 0, ySpacing = (style & SWT.NO_FOCUS) != 0 ? 4 : 2;
+ 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};
+}
+int [] layoutVertical (int nWidth, int nHeight, boolean resize) {
+ int xSpacing = (style & SWT.NO_FOCUS) != 0 ? 4 : 2, ySpacing = 0;
+ int marginWidth = 0, marginHeight = 0;
+ ToolItem [] children = getItems ();
+ int length = children.length;
+ int x = marginWidth, y = marginHeight;
+ int maxWidth = 0, maxY = 0, cols = 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 && y + rect.height > nHeight) {
+ cols++;
+ x += xSpacing + maxWidth; y = marginHeight;
+ maxWidth = 0;
+ }
+ maxWidth = Math.max (maxWidth, rect.width);
+ if (resize) {
+ child.setBounds (x, y, rect.width, rect.height);
+ }
+ y += ySpacing + rect.height;
+ maxY = Math.max (maxY, y);
+ }
+ return new int [] {cols, x + maxWidth, maxY};
+}
+int [] layout (int nWidth, int nHeight, boolean resize) {
+ if ((style & SWT.VERTICAL) != 0) {
+ return layoutVertical (nWidth, nHeight, resize);
+ } else {
+ return layoutHorizontal (nWidth, nHeight, resize);
+ }
+}
+boolean mnemonicHit (char key) {
+ for (int i = 0; i < items.length; i++) {
+ ToolItem item = items [i];
+ if (item != null) {
+ char mnemonic = findMnemonic (item.getText ());
+ if (mnemonic != '\0') {
+ if (Character.toUpperCase (key) == Character.toUpperCase (mnemonic)) {
+ XmProcessTraversal (item.handle, OS.XmTRAVERSE_CURRENT);
+ item.click (false, null);
+ return true;
+ }
+ }
+ }
+ }
+ return false;
+}
+boolean mnemonicMatch (char key) {
+ for (int i = 0; i < items.length; i++) {
+ ToolItem item = items [i];
+ if (item != null && item.getEnabled ()) {
+ char mnemonic = findMnemonic (item.getText ());
+ if (mnemonic != '\0') {
+ if (Character.toUpperCase (key) == Character.toUpperCase (mnemonic)) {
+ return true;
+ }
+ }
+ }
+ }
+ return false;
+}
+void propagateWidget (boolean enabled) {
+ super.propagateWidget (enabled);
+ for (int i=0; i<itemCount; i++) {
+ items [i].propagateWidget (enabled);
+ }
+}
+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.releaseResources ();
+ }
+ items = null;
+ super.releaseWidget ();
+}
+void setBackgroundPixel (int pixel) {
+ super.setBackgroundPixel (pixel);
+ for (int i = 0; i < items.length; i++) {
+ if (items[i] != null) {
+ items[i].setBackgroundPixel (pixel);
+ }
+ }
+}
+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 setFont (Font font) {
+ checkWidget();
+ super.setFont (font);
+ for (int i=0; i<items.length; i++) {
+ ToolItem item = items [i];
+ if (item != null) {
+ Point size = item.computeSize ();
+ item.setSize (size.x, size.y, false);
+ }
+ }
+ relayout ();
+}
+void setForegroundPixel (int pixel) {
+ super.setForegroundPixel (pixel);
+ for (int i = 0; i < items.length; i++) {
+ if (items[i] != null) {
+ items[i].setForegroundPixel (pixel);
+ }
+ }
+}
+public void setRedraw (boolean redraw) {
+ checkWidget();
+ 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);
+}
+boolean setTabItemFocus () {
+ int index = 0;
+ while (index < items.length) {
+ ToolItem item = items [index];
+ if (item != null && (item.style & SWT.SEPARATOR) == 0) {
+ if (item.getEnabled ()) break;
+ }
+ index++;
+ }
+ if (index == items.length) return false;
+ return super.setTabItemFocus ();
+}
+int traversalCode (int key, XKeyEvent xEvent) {
+ return super.traversalCode (key, xEvent) | SWT.TRAVERSE_MNEMONIC;
+}
+}
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
index 519806e5eb..0315c71630 100755
--- 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
@@ -1,39 +1,39 @@
-package org.eclipse.swt.widgets;
-
-/*
+package org.eclipse.swt.widgets;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-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;
- Font font;
- 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 = font.handle;
- data.codePage = font.codePage;
- data.colormap = colormap;
- }
- return xGC;
-}
-
-public void internal_dispose_GC (int xGC, GCData data) {
- OS.XFreeGC (display, xGC);
-}
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+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;
+ Font font;
+ 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 = font.handle;
+ data.codePage = font.codePage;
+ data.colormap = colormap;
+ }
+ return xGC;
+}
+
+public void internal_dispose_GC (int xGC, GCData data) {
+ OS.XFreeGC (display, xGC);
+}
+}
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
index 66cde49cf1..3b29933977 100755
--- 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
@@ -1,44 +1,44 @@
-package org.eclipse.swt.widgets;
-
-/*
+package org.eclipse.swt.widgets;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-import org.eclipse.swt.internal.motif.*;
-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>
- * Note: Only one of the styles CHECK, PUSH, RADIO, SEPARATOR and DROP_DOWN
- * may be specified.
- * </p><p>
- * IMPORTANT: This class is <em>not</em> intended to be subclassed.
- * </p>
+ * http://www.eclipse.org/legal/cpl-v10.html
*/
-public class ToolItem extends Item {
- ToolBar parent;
- Image hotImage, disabledImage;
- String toolTipText;
- Control control;
- boolean set;
-
- static final int DEFAULT_WIDTH = 24;
- static final int DEFAULT_HEIGHT = 22;
- static final int DEFAULT_SEPARATOR_WIDTH = 8;
-
+
+import org.eclipse.swt.internal.motif.*;
+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>
+ * Note: Only one of the styles CHECK, PUSH, RADIO, SEPARATOR and DROP_DOWN
+ * may be specified.
+ * </p><p>
+ * IMPORTANT: This class is <em>not</em> intended to be subclassed.
+ * </p>
+ */
+public class ToolItem extends Item {
+ ToolBar parent;
+ Image hotImage, disabledImage;
+ String toolTipText;
+ Control control;
+ boolean set;
+
+ static final int DEFAULT_WIDTH = 24;
+ static final int DEFAULT_HEIGHT = 22;
+ static final int DEFAULT_SEPARATOR_WIDTH = 8;
+
/**
* Constructs a new instance of this class given its parent
* (which must be a <code>ToolBar</code>) and a style value
@@ -73,13 +73,13 @@ public class ToolItem extends Item {
* @see Widget#checkSubclass
* @see Widget#getStyle
*/
-public ToolItem (ToolBar parent, int style) {
- super (parent, checkStyle (style));
- this.parent = parent;
- parent.createItem (this, parent.getItemCount ());
- parent.relayout ();
-}
-
+public ToolItem (ToolBar parent, int style) {
+ super (parent, checkStyle (style));
+ this.parent = parent;
+ parent.createItem (this, parent.getItemCount ());
+ parent.relayout ();
+}
+
/**
* Constructs a new instance of this class given its parent
* (which must be a <code>ToolBar</code>), a style value
@@ -115,209 +115,209 @@ public ToolItem (ToolBar parent, int style) {
* @see Widget#checkSubclass
* @see Widget#getStyle
*/
-public ToolItem (ToolBar parent, int style, int index) {
- super (parent, checkStyle (style));
- this.parent = parent;
- parent.createItem (this, index);
- parent.relayout ();
-}
-
-/**
- * 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.
- * <p>
- * When <code>widgetSelected</code> is called when the mouse is over the arrow portion of a drop-down tool,
- * the event object detail field contains the value <code>SWT.ARROW</code>.
- * <code>widgetDefaultSelected</code> is not called.
- * </p>
- *
- * @param listener the listener which should be notified
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see SelectionListener
- * @see #removeSelectionListener
- * @see SelectionEvent
+public ToolItem (ToolBar parent, int style, int index) {
+ super (parent, checkStyle (style));
+ this.parent = parent;
+ parent.createItem (this, index);
+ parent.relayout ();
+}
+
+/**
+ * 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.
+ * <p>
+ * When <code>widgetSelected</code> is called when the mouse is over the arrow portion of a drop-down tool,
+ * the event object detail field contains the value <code>SWT.ARROW</code>.
+ * <code>widgetDefaultSelected</code> is not called.
+ * </p>
+ *
+ * @param listener the listener which should be notified
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see SelectionListener
+ * @see #removeSelectionListener
+ * @see SelectionEvent
*/
-public void addSelectionListener(SelectionListener listener) {
- checkWidget();
- if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
- TypedListener typedListener = new TypedListener(listener);
- addListener(SWT.Selection,typedListener);
- addListener(SWT.DefaultSelection,typedListener);
-}
-static int checkStyle (int style) {
- return checkBits (style, SWT.PUSH, SWT.CHECK, SWT.RADIO, SWT.SEPARATOR, SWT.DROP_DOWN, 0);
-}
-protected void checkSubclass () {
- if (!isValidSubclass ()) error (SWT.ERROR_INVALID_SUBCLASS);
-}
-void createHandle (int index) {
- state |= HANDLE;
- int parentHandle = parent.handle;
- if ((style & SWT.SEPARATOR) != 0) {
- int orientation = (parent.style & SWT.HORIZONTAL) != 0 ? OS.XmVERTICAL : OS.XmHORIZONTAL;
- int [] argList = {
- OS.XmNheight, orientation == OS.XmVERTICAL ? DEFAULT_HEIGHT : DEFAULT_SEPARATOR_WIDTH,
- OS.XmNwidth, orientation == OS.XmHORIZONTAL ? DEFAULT_WIDTH : DEFAULT_SEPARATOR_WIDTH,
- OS.XmNancestorSensitive, 1,
- OS.XmNpositionIndex, index,
- OS.XmNorientation, orientation,
- OS.XmNseparatorType, (parent.style & SWT.FLAT) != 0 ? OS.XmSHADOW_ETCHED_IN : OS.XmSHADOW_ETCHED_OUT,
- };
- handle = OS.XmCreateSeparator (parentHandle, null, argList, argList.length / 2);
- if (handle == 0) error (SWT.ERROR_NO_HANDLES);
- return;
- }
- int [] argList = {
- OS.XmNwidth, DEFAULT_WIDTH,
- OS.XmNheight, DEFAULT_HEIGHT,
- OS.XmNrecomputeSize, 0,
- OS.XmNhighlightThickness, (parent.style & SWT.NO_FOCUS) != 0 ? 0 : 1,
- OS.XmNmarginWidth, 2,
- OS.XmNmarginHeight, 1,
- OS.XmNtraversalOn, (parent.style & SWT.NO_FOCUS) != 0 ? 0 : 1,
- OS.XmNpositionIndex, index,
- OS.XmNshadowType, OS.XmSHADOW_OUT,
- OS.XmNancestorSensitive, 1,
- };
- handle = OS.XmCreateDrawnButton (parentHandle, null, argList, argList.length / 2);
- if (handle == 0) error (SWT.ERROR_NO_HANDLES);
- int pixel = parent.getBackgroundPixel ();
- setBackgroundPixel (pixel);
-}
-
-void click (boolean dropDown, XInputEvent xEvent) {
- if ((style & SWT.RADIO) != 0) {
- selectRadio ();
- } else {
- if ((style & SWT.CHECK) != 0) setSelection(!set);
- }
- Event event = new Event ();
- if ((style & SWT.DROP_DOWN) != 0) {
- if (dropDown) {
- event.detail = SWT.ARROW;
- int [] argList = {OS.XmNx, 0, OS.XmNy, 0, OS.XmNheight, 0};
- OS.XtGetValues (handle, argList, argList.length / 2);
- event.x = (short) argList [1];
- event.y = (short) argList [3] + (short) argList [5];
- }
- }
- if (xEvent != null) setInputState (event, xEvent);
- postEvent (SWT.Selection, event);
-}
-
-Point computeSize () {
- if ((style & SWT.SEPARATOR) != 0) {
- int [] argList = {
- OS.XmNwidth, 0,
- OS.XmNheight, 0,
- };
- OS.XtGetValues (handle, argList, argList.length / 2);
- int width = argList [1], height = argList [3];
- return new Point(width, height);
- }
- int [] argList = {
- OS.XmNmarginHeight, 0,
- OS.XmNmarginWidth, 0,
- OS.XmNshadowThickness, 0,
- };
- OS.XtGetValues (handle, argList, argList.length / 2);
- int marginHeight = argList [1], marginWidth = argList [3];
- int shadowThickness = argList [5];
- if ((parent.style & SWT.FLAT) != 0) {
- Display display = getDisplay ();
- shadowThickness = Math.min (2, display.buttonShadowThickness);
- }
- int textWidth = 0, textHeight = 0;
- if (text.length () != 0) {
- GC gc = new GC (parent);
- int flags = SWT.DRAW_DELIMITER | SWT.DRAW_TAB | SWT.DRAW_MNEMONIC;
- Point textExtent = gc.textExtent (text, flags);
- 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 width = 0, height = 0;
- if ((parent.style & SWT.RIGHT) != 0) {
- width = imageWidth + textWidth;
- height = Math.max (imageHeight, textHeight);
- if (imageWidth != 0 && textWidth != 0) width += 2;
- } else {
- height = imageHeight + textHeight;
- if (imageHeight != 0 && textHeight != 0) height += 2;
- width = Math.max (imageWidth, textWidth);
- }
- if ((style & SWT.DROP_DOWN) != 0) width += 12;
-
- if (width != 0) {
- width += (marginWidth + shadowThickness) * 2 + 2;
- } else {
- width = DEFAULT_WIDTH;
- }
- if (height != 0) {
- height += (marginHeight + shadowThickness) * 2 + 2;
- } else {
- height = DEFAULT_HEIGHT;
- }
- return new Point (width, height);
-}
-void createWidget (int index) {
- super.createWidget (index);
- parent.relayout ();
-}
-public void dispose () {
- if (isDisposed()) return;
- ToolBar parent = this.parent;
- super.dispose ();
- parent.relayout ();
-}
-/**
- * Returns a rectangle describing the receiver's size and location
- * relative to its parent.
- *
- * @return the receiver's bounding rectangle
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
+public void addSelectionListener(SelectionListener listener) {
+ checkWidget();
+ if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+ TypedListener typedListener = new TypedListener(listener);
+ addListener(SWT.Selection,typedListener);
+ addListener(SWT.DefaultSelection,typedListener);
+}
+static int checkStyle (int style) {
+ return checkBits (style, SWT.PUSH, SWT.CHECK, SWT.RADIO, SWT.SEPARATOR, SWT.DROP_DOWN, 0);
+}
+protected void checkSubclass () {
+ if (!isValidSubclass ()) error (SWT.ERROR_INVALID_SUBCLASS);
+}
+void createHandle (int index) {
+ state |= HANDLE;
+ int parentHandle = parent.handle;
+ if ((style & SWT.SEPARATOR) != 0) {
+ int orientation = (parent.style & SWT.HORIZONTAL) != 0 ? OS.XmVERTICAL : OS.XmHORIZONTAL;
+ int [] argList = {
+ OS.XmNheight, orientation == OS.XmVERTICAL ? DEFAULT_HEIGHT : DEFAULT_SEPARATOR_WIDTH,
+ OS.XmNwidth, orientation == OS.XmHORIZONTAL ? DEFAULT_WIDTH : DEFAULT_SEPARATOR_WIDTH,
+ OS.XmNancestorSensitive, 1,
+ OS.XmNpositionIndex, index,
+ OS.XmNorientation, orientation,
+ OS.XmNseparatorType, (parent.style & SWT.FLAT) != 0 ? OS.XmSHADOW_ETCHED_IN : OS.XmSHADOW_ETCHED_OUT,
+ };
+ handle = OS.XmCreateSeparator (parentHandle, null, argList, argList.length / 2);
+ if (handle == 0) error (SWT.ERROR_NO_HANDLES);
+ return;
+ }
+ int [] argList = {
+ OS.XmNwidth, DEFAULT_WIDTH,
+ OS.XmNheight, DEFAULT_HEIGHT,
+ OS.XmNrecomputeSize, 0,
+ OS.XmNhighlightThickness, (parent.style & SWT.NO_FOCUS) != 0 ? 0 : 1,
+ OS.XmNmarginWidth, 2,
+ OS.XmNmarginHeight, 1,
+ OS.XmNtraversalOn, (parent.style & SWT.NO_FOCUS) != 0 ? 0 : 1,
+ OS.XmNpositionIndex, index,
+ OS.XmNshadowType, OS.XmSHADOW_OUT,
+ OS.XmNancestorSensitive, 1,
+ };
+ handle = OS.XmCreateDrawnButton (parentHandle, null, argList, argList.length / 2);
+ if (handle == 0) error (SWT.ERROR_NO_HANDLES);
+ int pixel = parent.getBackgroundPixel ();
+ setBackgroundPixel (pixel);
+}
+
+void click (boolean dropDown, XInputEvent xEvent) {
+ if ((style & SWT.RADIO) != 0) {
+ selectRadio ();
+ } else {
+ if ((style & SWT.CHECK) != 0) setSelection(!set);
+ }
+ Event event = new Event ();
+ if ((style & SWT.DROP_DOWN) != 0) {
+ if (dropDown) {
+ event.detail = SWT.ARROW;
+ int [] argList = {OS.XmNx, 0, OS.XmNy, 0, OS.XmNheight, 0};
+ OS.XtGetValues (handle, argList, argList.length / 2);
+ event.x = (short) argList [1];
+ event.y = (short) argList [3] + (short) argList [5];
+ }
+ }
+ if (xEvent != null) setInputState (event, xEvent);
+ postEvent (SWT.Selection, event);
+}
+
+Point computeSize () {
+ if ((style & SWT.SEPARATOR) != 0) {
+ int [] argList = {
+ OS.XmNwidth, 0,
+ OS.XmNheight, 0,
+ };
+ OS.XtGetValues (handle, argList, argList.length / 2);
+ int width = argList [1], height = argList [3];
+ return new Point(width, height);
+ }
+ int [] argList = {
+ OS.XmNmarginHeight, 0,
+ OS.XmNmarginWidth, 0,
+ OS.XmNshadowThickness, 0,
+ };
+ OS.XtGetValues (handle, argList, argList.length / 2);
+ int marginHeight = argList [1], marginWidth = argList [3];
+ int shadowThickness = argList [5];
+ if ((parent.style & SWT.FLAT) != 0) {
+ Display display = getDisplay ();
+ shadowThickness = Math.min (2, display.buttonShadowThickness);
+ }
+ int textWidth = 0, textHeight = 0;
+ if (text.length () != 0) {
+ GC gc = new GC (parent);
+ int flags = SWT.DRAW_DELIMITER | SWT.DRAW_TAB | SWT.DRAW_MNEMONIC;
+ Point textExtent = gc.textExtent (text, flags);
+ 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 width = 0, height = 0;
+ if ((parent.style & SWT.RIGHT) != 0) {
+ width = imageWidth + textWidth;
+ height = Math.max (imageHeight, textHeight);
+ if (imageWidth != 0 && textWidth != 0) width += 2;
+ } else {
+ height = imageHeight + textHeight;
+ if (imageHeight != 0 && textHeight != 0) height += 2;
+ width = Math.max (imageWidth, textWidth);
+ }
+ if ((style & SWT.DROP_DOWN) != 0) width += 12;
+
+ if (width != 0) {
+ width += (marginWidth + shadowThickness) * 2 + 2;
+ } else {
+ width = DEFAULT_WIDTH;
+ }
+ if (height != 0) {
+ height += (marginHeight + shadowThickness) * 2 + 2;
+ } else {
+ height = DEFAULT_HEIGHT;
+ }
+ return new Point (width, height);
+}
+void createWidget (int index) {
+ super.createWidget (index);
+ parent.relayout ();
+}
+public void dispose () {
+ if (isDisposed()) return;
+ ToolBar parent = this.parent;
+ super.dispose ();
+ parent.relayout ();
+}
+/**
+ * Returns a rectangle describing the receiver's size and location
+ * relative to its parent.
+ *
+ * @return the receiver's bounding rectangle
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
*/
-public Rectangle getBounds () {
- checkWidget();
- 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]);
-}
-/**
- * Returns the control that is used to fill the bounds of
- * the item when the items is a <code>SEPARATOR</code>.
- *
- * @return the control
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
+public Rectangle getBounds () {
+ checkWidget();
+ 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]);
+}
+/**
+ * Returns the control that is used to fill the bounds of
+ * the item when the items is a <code>SEPARATOR</code>.
+ *
+ * @return the control
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
*/
-public Control getControl () {
- checkWidget();
- return control;
-}
+public Control getControl () {
+ checkWidget();
+ return control;
+}
/**
* Returns the receiver's disabled image if it has one, or null
* if it does not.
@@ -332,68 +332,68 @@ public Control getControl () {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public Image getDisabledImage () {
- checkWidget();
- return disabledImage;
-}
-/**
- * Returns <code>true</code> if the receiver is enabled, and
- * <code>false</code> otherwise.
- * <p>
- * A disabled control is typically not selectable from the
- * user interface and draws with an inactive or "grayed" look.
- * </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 Image getDisabledImage () {
+ checkWidget();
+ return disabledImage;
+}
+/**
+ * Returns <code>true</code> if the receiver is enabled, and
+ * <code>false</code> otherwise.
+ * <p>
+ * A disabled control is typically not selectable from the
+ * user interface and draws with an inactive or "grayed" look.
+ * </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 getEnabled () {
- checkWidget();
- int [] argList = {OS.XmNsensitive, 0};
- OS.XtGetValues (handle, argList, argList.length / 2);
- return argList [1] != 0;
-}
-public Display getDisplay () {
- Composite parent = this.parent;
- if (parent == null) error (SWT.ERROR_WIDGET_DISPOSED);
- return parent.getDisplay ();
-}
-/**
- * Returns the receiver's hot image if it has one, or null
- * if it does not.
- * <p>
- * The hot image is displayed when the mouse enters the receiver.
- * </p>
- *
- * @return the receiver's hot image
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
+public boolean getEnabled () {
+ checkWidget();
+ int [] argList = {OS.XmNsensitive, 0};
+ OS.XtGetValues (handle, argList, argList.length / 2);
+ return argList [1] != 0;
+}
+public Display getDisplay () {
+ Composite parent = this.parent;
+ if (parent == null) error (SWT.ERROR_WIDGET_DISPOSED);
+ return parent.getDisplay ();
+}
+/**
+ * Returns the receiver's hot image if it has one, or null
+ * if it does not.
+ * <p>
+ * The hot image is displayed when the mouse enters the receiver.
+ * </p>
+ *
+ * @return the receiver's hot image
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
*/
-public Image getHotImage () {
- checkWidget();
- return hotImage;
-}
-/**
- * Returns the receiver's parent, which must be a <code>ToolBar</code>.
- *
- * @return the receiver's parent
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
+public 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;
-}
+public ToolBar getParent () {
+ checkWidget();
+ return parent;
+}
/**
* Returns <code>true</code> if the receiver is selected,
* and false otherwise.
@@ -411,317 +411,317 @@ public ToolBar getParent () {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public boolean getSelection () {
- checkWidget();
- if ((style & (SWT.CHECK | SWT.RADIO)) == 0) return false;
- return set;
-}
-/**
- * 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 boolean getSelection () {
+ checkWidget();
+ if ((style & (SWT.CHECK | SWT.RADIO)) == 0) return false;
+ return set;
+}
+/**
+ * Returns the receiver's tool tip text, or null if it has not been set.
+ *
+ * @return the receiver's tool tip text
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
*/
-public String getToolTipText () {
- checkWidget();
- return toolTipText;
-}
-/**
- * Gets the width of the receiver.
- *
- * @return the width
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
+public String getToolTipText () {
+ checkWidget();
+ return toolTipText;
+}
+/**
+ * Gets the width of the receiver.
+ *
+ * @return the width
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
*/
-public int getWidth () {
- checkWidget();
- int [] argList = {OS.XmNwidth, 0};
- OS.XtGetValues (handle, argList, argList.length / 2);
- return argList [1];
-}
-boolean hasCursor () {
- int [] unused = new int [1], buffer = new int [1];
- int xDisplay = OS.XtDisplay (handle);
- int xWindow, xParent = OS.XDefaultRootWindow (xDisplay);
- do {
- if (OS.XQueryPointer (
- xDisplay, xParent, unused, buffer,
- unused, unused, unused, unused, unused) == 0) return false;
- if ((xWindow = buffer [0]) != 0) xParent = xWindow;
- } while (xWindow != 0);
- return handle == OS.XtWindowToWidget (xDisplay, xParent);
-}
-void hookEvents () {
- super.hookEvents ();
- if ((style & SWT.SEPARATOR) != 0) return;
- int windowProc = getDisplay ().windowProc;
- OS.XtAddEventHandler (handle, OS.KeyPressMask, false, windowProc, KEY_PRESS);
- OS.XtAddEventHandler (handle, OS.KeyReleaseMask, false, windowProc, KEY_RELEASE);
- OS.XtAddEventHandler (handle, OS.ButtonPressMask, false, windowProc, BUTTON_PRESS);
- OS.XtAddEventHandler (handle, OS.ButtonReleaseMask, false, windowProc, BUTTON_RELEASE);
- OS.XtAddEventHandler (handle, OS.PointerMotionMask, false, windowProc, POINTER_MOTION);
- OS.XtAddEventHandler (handle, OS.EnterWindowMask, false, windowProc, ENTER_WINDOW);
- OS.XtAddEventHandler (handle, OS.LeaveWindowMask, false, windowProc, LEAVE_WINDOW);
- OS.XtAddCallback (handle, OS.XmNexposeCallback, windowProc, EXPOSURE_CALLBACK);
- OS.XtInsertEventHandler (handle, OS.FocusChangeMask, false, windowProc, FOCUS_CHANGE, OS.XtListTail);
-}
-int hoverProc (int id) {
- boolean showTip = toolTipText != null;
- parent.hoverProc (id, !showTip);
- if (showTip) {
- Display display = getDisplay ();
- display.showToolTip (handle, toolTipText);
- }
- return 0;
-}
-/**
- * Returns <code>true</code> if the receiver is enabled and all
- * of the receiver's ancestors are enabled, and <code>false</code>
- * otherwise. A disabled control is typically not selectable from the
- * user interface and draws with an inactive or "grayed" look.
- *
- * @return the receiver's enabled state
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see #getEnabled
+public int getWidth () {
+ checkWidget();
+ int [] argList = {OS.XmNwidth, 0};
+ OS.XtGetValues (handle, argList, argList.length / 2);
+ return argList [1];
+}
+boolean hasCursor () {
+ int [] unused = new int [1], buffer = new int [1];
+ int xDisplay = OS.XtDisplay (handle);
+ int xWindow, xParent = OS.XDefaultRootWindow (xDisplay);
+ do {
+ if (OS.XQueryPointer (
+ xDisplay, xParent, unused, buffer,
+ unused, unused, unused, unused, unused) == 0) return false;
+ if ((xWindow = buffer [0]) != 0) xParent = xWindow;
+ } while (xWindow != 0);
+ return handle == OS.XtWindowToWidget (xDisplay, xParent);
+}
+void hookEvents () {
+ super.hookEvents ();
+ if ((style & SWT.SEPARATOR) != 0) return;
+ int windowProc = getDisplay ().windowProc;
+ OS.XtAddEventHandler (handle, OS.KeyPressMask, false, windowProc, KEY_PRESS);
+ OS.XtAddEventHandler (handle, OS.KeyReleaseMask, false, windowProc, KEY_RELEASE);
+ OS.XtAddEventHandler (handle, OS.ButtonPressMask, false, windowProc, BUTTON_PRESS);
+ OS.XtAddEventHandler (handle, OS.ButtonReleaseMask, false, windowProc, BUTTON_RELEASE);
+ OS.XtAddEventHandler (handle, OS.PointerMotionMask, false, windowProc, POINTER_MOTION);
+ OS.XtAddEventHandler (handle, OS.EnterWindowMask, false, windowProc, ENTER_WINDOW);
+ OS.XtAddEventHandler (handle, OS.LeaveWindowMask, false, windowProc, LEAVE_WINDOW);
+ OS.XtAddCallback (handle, OS.XmNexposeCallback, windowProc, EXPOSURE_CALLBACK);
+ OS.XtInsertEventHandler (handle, OS.FocusChangeMask, false, windowProc, FOCUS_CHANGE, OS.XtListTail);
+}
+int hoverProc (int id) {
+ boolean showTip = toolTipText != null;
+ parent.hoverProc (id, !showTip);
+ if (showTip) {
+ Display display = getDisplay ();
+ display.showToolTip (handle, toolTipText);
+ }
+ return 0;
+}
+/**
+ * Returns <code>true</code> if the receiver is enabled and all
+ * of the receiver's ancestors are enabled, and <code>false</code>
+ * otherwise. A disabled control is typically not selectable from the
+ * user interface and draws with an inactive or "grayed" look.
+ *
+ * @return the receiver's enabled state
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see #getEnabled
*/
-public boolean isEnabled () {
- checkWidget();
- return getEnabled () && parent.isEnabled ();
-}
-void manageChildren () {
- OS.XtManageChild (handle);
-}
-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 releaseChild () {
- super.releaseChild ();
- parent.destroyItem (this);
-}
-void releaseWidget () {
- Display display = getDisplay ();
- display.releaseToolTipHandle (handle);
- super.releaseWidget ();
- parent = null;
- control = null;
- toolTipText = null;
- image = disabledImage = hotImage = 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 boolean isEnabled () {
+ checkWidget();
+ return getEnabled () && parent.isEnabled ();
+}
+void manageChildren () {
+ OS.XtManageChild (handle);
+}
+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 releaseChild () {
+ super.releaseChild ();
+ parent.destroyItem (this);
+}
+void releaseWidget () {
+ Display display = getDisplay ();
+ display.releaseToolTipHandle (handle);
+ super.releaseWidget ();
+ parent = null;
+ control = null;
+ toolTipText = null;
+ image = disabledImage = hotImage = 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 () {
- int index = 0;
- ToolItem [] items = parent.getItems ();
- while (index < items.length && items [index] != this) index++;
- int i = index - 1;
- while (i >= 0 && items [i].setRadioSelection (false)) --i;
- int j = index + 1;
- while (j < items.length && items [j].setRadioSelection (false)) j++;
- setSelection (true);
-}
-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);
-}
-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 that is used to fill the bounds of
- * the item when the items is a <code>SEPARATOR</code>.
- *
- * @param control the new control
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_INVALID_ARGUMENT - if the control has been disposed</li>
- * <li>ERROR_INVALID_PARENT - if the control is not in the same widget tree</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
+public void removeSelectionListener(SelectionListener listener) {
+ checkWidget();
+ if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+ if (eventTable == null) return;
+ eventTable.unhook(SWT.Selection, listener);
+ eventTable.unhook(SWT.DefaultSelection,listener);
+}
+void selectRadio () {
+ int index = 0;
+ ToolItem [] items = parent.getItems ();
+ while (index < items.length && items [index] != this) index++;
+ int i = index - 1;
+ while (i >= 0 && items [i].setRadioSelection (false)) --i;
+ int j = index + 1;
+ while (j < items.length && items [j].setRadioSelection (false)) j++;
+ setSelection (true);
+}
+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);
+}
+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 that is used to fill the bounds of
+ * the item when the items is a <code>SEPARATOR</code>.
+ *
+ * @param control the new control
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_INVALID_ARGUMENT - if the control has been disposed</li>
+ * <li>ERROR_INVALID_PARENT - if the control is not in the same widget tree</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
*/
-public void setControl (Control control) {
- checkWidget();
- if (control != null) {
- if (control.isDisposed()) error (SWT.ERROR_INVALID_ARGUMENT);
- if (control.parent != parent) error (SWT.ERROR_INVALID_PARENT);
- }
- if ((style & SWT.SEPARATOR) == 0) return;
- this.control = control;
- if (control != null && !control.isDisposed ()) {
- control.setBounds (getBounds ());
- /*
- * It is possible that the control was created with a
- * z-order below that of the current tool item. In this
- * case, the control is not visible because it is
- * obscured by the tool item. The fix is to move the
- * control above this tool item in the z-order.
- * The code below is similar to the code found in
- * setZOrder.
- */
- int xDisplay = OS.XtDisplay (handle);
- if (xDisplay == 0) return;
- if (!OS.XtIsRealized (handle)) {
- Shell shell = parent.getShell ();
- shell.realizeWidget ();
- }
- int topHandle1 = control.topHandle ();
- int window1 = OS.XtWindow (topHandle1);
- if (window1 == 0) return;
- int topHandle2 = this.topHandle ();
- int window2 = OS.XtWindow (topHandle2);
- if (window2 == 0) return;
- XWindowChanges struct = new XWindowChanges ();
- struct.sibling = window2;
- struct.stack_mode = OS.Above;
- int screen = OS.XDefaultScreen (xDisplay);
- int flags = OS.CWStackMode | OS.CWSibling;
- OS.XReconfigureWMWindow (xDisplay, window1, screen, flags, struct);
- }
-}
-/**
- * Enables the receiver if the argument is <code>true</code>,
- * and disables it otherwise.
- * <p>
- * A disabled control is typically
- * not selectable from the user interface and draws with an
- * inactive or "grayed" look.
- * </p>
- *
- * @param enabled the new enabled state
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
+public void setControl (Control control) {
+ checkWidget();
+ if (control != null) {
+ if (control.isDisposed()) error (SWT.ERROR_INVALID_ARGUMENT);
+ if (control.parent != parent) error (SWT.ERROR_INVALID_PARENT);
+ }
+ if ((style & SWT.SEPARATOR) == 0) return;
+ this.control = control;
+ if (control != null && !control.isDisposed ()) {
+ control.setBounds (getBounds ());
+ /*
+ * It is possible that the control was created with a
+ * z-order below that of the current tool item. In this
+ * case, the control is not visible because it is
+ * obscured by the tool item. The fix is to move the
+ * control above this tool item in the z-order.
+ * The code below is similar to the code found in
+ * setZOrder.
+ */
+ int xDisplay = OS.XtDisplay (handle);
+ if (xDisplay == 0) return;
+ if (!OS.XtIsRealized (handle)) {
+ Shell shell = parent.getShell ();
+ shell.realizeWidget ();
+ }
+ int topHandle1 = control.topHandle ();
+ int window1 = OS.XtWindow (topHandle1);
+ if (window1 == 0) return;
+ int topHandle2 = this.topHandle ();
+ int window2 = OS.XtWindow (topHandle2);
+ if (window2 == 0) return;
+ XWindowChanges struct = new XWindowChanges ();
+ struct.sibling = window2;
+ struct.stack_mode = OS.Above;
+ int screen = OS.XDefaultScreen (xDisplay);
+ int flags = OS.CWStackMode | OS.CWSibling;
+ OS.XReconfigureWMWindow (xDisplay, window1, screen, flags, struct);
+ }
+}
+/**
+ * Enables the receiver if the argument is <code>true</code>,
+ * and disables it otherwise.
+ * <p>
+ * A disabled control is typically
+ * not selectable from the user interface and draws with an
+ * inactive or "grayed" look.
+ * </p>
+ *
+ * @param enabled the new enabled state
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
*/
-public void setEnabled (boolean enabled) {
- checkWidget();
- int [] argList = {OS.XmNsensitive, enabled ? 1 : 0};
- OS.XtSetValues (handle, argList, argList.length / 2);
-}
-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);
-}
-/**
- * Sets the receiver's disabled image to the argument, which may be
- * null indicating that no disabled image should be displayed.
- * <p>
- * The disbled image is displayed when the receiver is disabled.
- * </p>
- *
- * @param image the disabled image to display on the receiver (may be null)
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_INVALID_ARGUMENT - if the image has been disposed</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
+public void setEnabled (boolean enabled) {
+ checkWidget();
+ int [] argList = {OS.XmNsensitive, enabled ? 1 : 0};
+ OS.XtSetValues (handle, argList, argList.length / 2);
+}
+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);
+}
+/**
+ * Sets the receiver's disabled image to the argument, which may be
+ * null indicating that no disabled image should be displayed.
+ * <p>
+ * The disbled image is displayed when the receiver is disabled.
+ * </p>
+ *
+ * @param image the disabled image to display on the receiver (may be null)
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_INVALID_ARGUMENT - if the image has been disposed</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
*/
-public void setDisabledImage (Image image) {
- checkWidget();
- if (image != null && image.isDisposed()) error(SWT.ERROR_INVALID_ARGUMENT);
- if ((style & SWT.SEPARATOR) != 0) return;
- disabledImage = image;
- if (!getEnabled ()) redraw ();
-}
-/**
- * Sets the receiver's hot image to the argument, which may be
- * null indicating that no hot image should be displayed.
- * <p>
- * The hot image is displayed when the mouse enters the receiver.
- * </p>
- *
- * @param image the hot image to display on the receiver (may be null)
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_INVALID_ARGUMENT - if the image has been disposed</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
+public void setDisabledImage (Image image) {
+ checkWidget();
+ if (image != null && image.isDisposed()) error(SWT.ERROR_INVALID_ARGUMENT);
+ if ((style & SWT.SEPARATOR) != 0) return;
+ disabledImage = image;
+ if (!getEnabled ()) redraw ();
+}
+/**
+ * Sets the receiver's hot image to the argument, which may be
+ * null indicating that no hot image should be displayed.
+ * <p>
+ * The hot image is displayed when the mouse enters the receiver.
+ * </p>
+ *
+ * @param image the hot image to display on the receiver (may be null)
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_INVALID_ARGUMENT - if the image has been disposed</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
*/
-public void setHotImage (Image image) {
- checkWidget();
- if (image != null && image.isDisposed()) error(SWT.ERROR_INVALID_ARGUMENT);
- if ((style & SWT.SEPARATOR) != 0) return;
- hotImage = image;
- if ((parent.style & SWT.FLAT) != 0) redraw ();
-}
-public void setImage (Image image) {
- checkWidget();
- if (image != null && image.isDisposed()) error(SWT.ERROR_INVALID_ARGUMENT);
- if ((style & SWT.SEPARATOR) != 0) return;
- super.setImage (image);
- Point size = computeSize ();
- setSize (size.x, size.y, true);
- redraw ();
-}
-boolean setRadioSelection (boolean value) {
- if ((style & SWT.RADIO) == 0) return false;
- if (getSelection () != value) {
- setSelection (value);
- postEvent (SWT.Selection);
- }
- return true;
-}
+public void setHotImage (Image image) {
+ checkWidget();
+ if (image != null && image.isDisposed()) error(SWT.ERROR_INVALID_ARGUMENT);
+ if ((style & SWT.SEPARATOR) != 0) return;
+ hotImage = image;
+ if ((parent.style & SWT.FLAT) != 0) redraw ();
+}
+public void setImage (Image image) {
+ checkWidget();
+ if (image != null && image.isDisposed()) error(SWT.ERROR_INVALID_ARGUMENT);
+ if ((style & SWT.SEPARATOR) != 0) return;
+ super.setImage (image);
+ Point size = computeSize ();
+ setSize (size.x, size.y, true);
+ redraw ();
+}
+boolean setRadioSelection (boolean value) {
+ if ((style & SWT.RADIO) == 0) return false;
+ if (getSelection () != value) {
+ setSelection (value);
+ postEvent (SWT.Selection);
+ }
+ return true;
+}
/**
* Sets the selection state of the receiver.
* <p>
@@ -737,387 +737,387 @@ boolean setRadioSelection (boolean value) {
* <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;
- if (selected == set) return;
- set = selected;
- setDrawPressed (set);
-}
-
-void setSize (int width, int height, boolean layout) {
- int [] argList = {OS.XmNwidth, 0, OS.XmNheight, 0};
- OS.XtGetValues (handle, argList, argList.length / 2);
- if (argList [1] != width || argList [3] != height) {
- OS.XtResizeWidget (handle, width, height, 0);
- if (layout) parent.relayout ();
- }
-}
-public void setText (String string) {
- checkWidget();
- if (string == null) error (SWT.ERROR_NULL_ARGUMENT);
- if ((style & SWT.SEPARATOR) != 0) return;
- super.setText (string);
- Point size = computeSize ();
- setSize (size.x, size.y, true);
- redraw ();
-}
-
-/**
- * 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 setSelection (boolean selected) {
+ checkWidget();
+ if ((style & (SWT.CHECK | SWT.RADIO)) == 0) return;
+ if (selected == set) return;
+ set = selected;
+ setDrawPressed (set);
+}
+
+void setSize (int width, int height, boolean layout) {
+ int [] argList = {OS.XmNwidth, 0, OS.XmNheight, 0};
+ OS.XtGetValues (handle, argList, argList.length / 2);
+ if (argList [1] != width || argList [3] != height) {
+ OS.XtResizeWidget (handle, width, height, 0);
+ if (layout) parent.relayout ();
+ }
+}
+public void setText (String string) {
+ checkWidget();
+ if (string == null) error (SWT.ERROR_NULL_ARGUMENT);
+ if ((style & SWT.SEPARATOR) != 0) return;
+ super.setText (string);
+ Point size = computeSize ();
+ setSize (size.x, size.y, true);
+ redraw ();
+}
+
+/**
+ * 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.
- *
- * @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 setToolTipText (String string) {
+ checkWidget();
+ toolTipText = string;
+}
+/**
+ * Sets the width of the receiver.
+ *
+ * @param width the new width
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
*/
-public void setWidth (int width) {
- checkWidget();
- if ((style & SWT.SEPARATOR) == 0) return;
- if (width < 0) return;
- int [] argList = {OS.XmNheight, 0};
- OS.XtGetValues (handle, argList, argList.length / 2);
- setSize (width, argList [1], true);
- 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);
-}
-boolean translateAccelerator (int key, int keysym, XKeyEvent xEvent) {
- return parent.translateAccelerator (key, keysym, xEvent);
-}
-boolean translateMnemonic (int key, XKeyEvent xEvent) {
- return parent.translateMnemonic (key, xEvent);
-}
-boolean translateTraversal (int key, XKeyEvent xEvent) {
- return parent.translateTraversal (key, xEvent);
-}
-void propagateWidget (boolean enabled) {
- propagateHandle (enabled, handle);
-}
-int XButtonPress (int w, int client_data, int call_data, int continue_to_dispatch) {
- Display display = getDisplay ();
-// Shell shell = parent.getShell ();
- display.hideToolTip ();
- XButtonEvent xEvent = new XButtonEvent ();
- OS.memmove (xEvent, call_data, XButtonEvent.sizeof);
- if (xEvent.button == 1) {
- if (!set && (style & SWT.RADIO) == 0) {
- setDrawPressed (!set);
- }
- }
-
- /*
- * Forward the mouse event to the parent.
- * This is necessary so that mouse listeners
- * in the parent will be called, despite the
- * fact that the event did not really occur
- * in X in the parent. This is done to be
- * compatible with Windows.
- */
- int [] argList = {OS.XmNx, 0, OS.XmNy, 0};
- OS.XtGetValues (handle, argList, argList.length / 2);
- xEvent.window = OS.XtWindow (parent.handle);
- xEvent.x += argList [1]; xEvent.y += argList [3];
- OS.memmove (call_data, xEvent, XButtonEvent.sizeof);
- parent.XButtonPress (w, client_data, call_data, continue_to_dispatch);
-
- /*
- * It is possible that the shell may be
- * disposed at this point. If this happens
- * don't send the activate and deactivate
- * events.
- */
-// if (!shell.isDisposed()) {
-// shell.setActiveControl (parent);
-// }
- return 0;
-}
-int XButtonRelease (int w, int client_data, int call_data, int continue_to_dispatch) {
- Display display = getDisplay ();
- display.hideToolTip();
- XButtonEvent xEvent = new XButtonEvent ();
- OS.memmove (xEvent, call_data, XButtonEvent.sizeof);
- if (xEvent.button == 1) {
- int [] argList = {OS.XmNwidth, 0, OS.XmNheight, 0};
- OS.XtGetValues (handle, argList, argList.length / 2);
- int width = argList [1], height = argList [3];
- if (0 <= xEvent.x && xEvent.x < width && 0 <= xEvent.y && xEvent.y < height) {
- click (xEvent.x > width - 12, xEvent);
- }
- setDrawPressed(set);
- }
-
- /*
- * Forward the mouse event to the parent.
- * This is necessary so that mouse listeners
- * in the parent will be called, despite the
- * fact that the event did not really occur
- * in X in the parent. This is done to be
- * compatible with Windows.
- */
- int [] argList = {OS.XmNx, 0, OS.XmNy, 0};
- OS.XtGetValues (handle, argList, argList.length / 2);
- xEvent.window = OS.XtWindow (parent.handle);
- xEvent.x += argList [1]; xEvent.y += argList [3];
- OS.memmove (call_data, xEvent, XButtonEvent.sizeof);
- parent.XButtonRelease (w, client_data, call_data, continue_to_dispatch);
-
- return 0;
-}
-int XEnterWindow (int w, int client_data, int call_data, int continue_to_dispatch) {
- XCrossingEvent xEvent = new XCrossingEvent ();
- OS.memmove (xEvent, call_data, XCrossingEvent.sizeof);
- if ((xEvent.state & OS.Button1Mask) != 0) {
- setDrawPressed (!set);
- } else {
- if ((parent.style & SWT.FLAT) != 0) redraw ();
- }
- return 0;
-}
-int XFocusChange (int w, int client_data, int call_data, int continue_to_dispatch) {
- /*
- * Forward the focus event to the parent.
- * This is necessary so that focus listeners
- * in the parent will be called, despite the
- * fact that the event did not really occur
- * in X in the parent. This is done to be
- * compatible with Windows.
- */
- XFocusChangeEvent xEvent = new XFocusChangeEvent ();
- OS.memmove (xEvent, call_data, XFocusChangeEvent.sizeof);
- xEvent.window = OS.XtWindow (parent.handle);
-// TEMPORARY CODE - need to fix the window field in xEvent
-// OS.memmove (callData, xEvent, XFocusChangeEvent.sizeof);
-
- /*
- * This code is intentionally commented.
- */
-// parent.processSetFocus (callData);
- return 0;
-}
-int XKeyPress (int w, int client_data, int call_data, int continue_to_dispatch) {
- XKeyEvent xEvent = new XKeyEvent ();
- OS.memmove (xEvent, call_data, XKeyEvent.sizeof);
- int [] keysym = new int [1];
- OS.XLookupString (xEvent, null, 0, keysym, null);
- keysym [0] &= 0xFFFF;
- switch (keysym [0]) {
- case OS.XK_space:
- click (false, xEvent);
- break;
- case OS.XK_KP_Enter:
- case OS.XK_Return:
- click (true, xEvent);
- break;
- }
- /*
- * Forward the key event to the parent.
- * This is necessary so that key listeners
- * in the parent will be called, despite the
- * fact that the event did not really occur
- * in X in the parent. This is done to be
- * compatible with Windows.
- */
- xEvent.window = OS.XtWindow (parent.handle);
-// OS.memmove (callData, xEvent, XKeyEvent.sizeof);
- parent.XKeyPress (w, client_data, call_data, continue_to_dispatch);
- return 0;
-}
-int XKeyRelease (int w, int client_data, int call_data, int continue_to_dispatch) {
- XKeyEvent xEvent = new XKeyEvent ();
- OS.memmove (xEvent, call_data, XKeyEvent.sizeof);
-
- /*
- * Forward the key event to the parent.
- * This is necessary so that key listeners
- * in the parent will be called, despite the
- * fact that the event did not really occur
- * in X in the parent. This is done to be
- * compatible with Windows.
- */
- xEvent.window = OS.XtWindow (parent.handle);
-// OS.memmove (callData, xEvent, XKeyEvent.sizeof);
- parent.XKeyRelease (w, client_data, call_data, continue_to_dispatch);
- return 0;
-}
-int XLeaveWindow (int w, int client_data, int call_data, int continue_to_dispatch) {
- Display display = getDisplay ();
- display.removeMouseHoverTimeOut ();
- display.hideToolTip ();
- XCrossingEvent xEvent = new XCrossingEvent ();
- OS.memmove (xEvent, call_data, XCrossingEvent.sizeof);
- if ((xEvent.state & OS.Button1Mask) != 0) {
- setDrawPressed (set);
- } else {
- if ((parent.style & SWT.FLAT) != 0) redraw ();
- }
- return 0;
-}
-int XmNexposureCallback (int w, int client_data, int call_data) {
- 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.XtGetValues (handle, argList, argList.length / 2);
- int width = argList [3], height = argList [5];
-
- Image currentImage = image;
- boolean enabled = getEnabled();
-
- if ((parent.style & SWT.FLAT) != 0) {
- Display display = getDisplay ();
- boolean hasCursor = hasCursor ();
-
- /* Set the shadow thickness */
- int thickness = 0;
- if (set || (hasCursor && enabled)) {
- thickness = Math.min (2, display.buttonShadowThickness);
- }
- argList = new int [] {OS.XmNshadowThickness, thickness};
- OS.XtSetValues (handle, argList, argList.length / 2);
-
- /* Determine if hot image should be used */
- if (enabled && hasCursor && hotImage != null) {
- currentImage = hotImage;
- }
- }
-
- ToolDrawable wrapper = new ToolDrawable ();
- wrapper.device = getDisplay ();
- wrapper.display = xDisplay;
- wrapper.drawable = xWindow;
- wrapper.font = parent.font;
- wrapper.colormap = argList [1];
- GC gc = new GC (wrapper);
-
- XmAnyCallbackStruct cb = new XmAnyCallbackStruct ();
- OS.memmove (cb, call_data, 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);
- }
-
- if (!enabled) {
- Display display = getDisplay ();
- currentImage = disabledImage;
- if (currentImage == null && image != 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.length () != 0) {
- int flags = SWT.DRAW_DELIMITER | SWT.DRAW_TAB | SWT.DRAW_MNEMONIC;
- Point textExtent = gc.textExtent (text, flags);
- 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;
- }
-
- int spacing = 0;
- if (textWidth != 0 && imageWidth != 0) spacing = 2;
- if ((parent.style & SWT.RIGHT) != 0) {
- imageX = (width - imageWidth - textWidth - spacing) / 2;
- imageY = (height - imageHeight) / 2;
- textX = spacing + imageX + imageWidth;
- textY = (height - textHeight) / 2;
- } else {
- imageX = (width - imageWidth) / 2;
- imageY = (height - imageHeight - textHeight - spacing) / 2;
- textX = (width - textWidth) / 2;
- textY = spacing + imageY + imageHeight;
- }
-
- if ((style & SWT.DROP_DOWN) != 0) {
- textX -= 6; imageX -=6;
- }
- if (textWidth > 0) {
- int flags = SWT.DRAW_DELIMITER | SWT.DRAW_TAB | SWT.DRAW_MNEMONIC;
- gc.drawText(text, textX, textY, flags);
- }
- if (imageWidth > 0) gc.drawImage(currentImage, imageX, imageY);
- if ((style & SWT.DROP_DOWN) != 0) {
- int startX = width - 12, startY = (height - 2) / 2;
- int [] arrow = {startX, startY, startX + 3, startY + 3, startX + 6, startY};
- gc.setBackground (parent.getForeground ());
- gc.fillPolygon (arrow);
- gc.drawPolygon (arrow);
- }
- gc.dispose ();
-
- if (!enabled && disabledImage == null) {
- if (currentImage != null) currentImage.dispose ();
- }
- return 0;
-}
-int XPointerMotion (int w, int client_data, int call_data, int continue_to_dispatch) {
- Display display = getDisplay ();
- display.addMouseHoverTimeOut (handle);
-
- /*
- * Forward the mouse event to the parent.
- * This is necessary so that mouse listeners
- * in the parent will be called, despite the
- * fact that the event did not really occur
- * in X in the parent. This is done to be
- * compatible with Windows.
- */
- XButtonEvent xEvent = new XButtonEvent ();
- OS.memmove (xEvent, call_data, XButtonEvent.sizeof);
- int [] argList = {OS.XmNx, 0, OS.XmNy, 0};
- OS.XtGetValues (handle, argList, argList.length / 2);
- xEvent.window = OS.XtWindow (parent.handle);
- xEvent.x += argList [1]; xEvent.y += argList [3];
- /*
- * This code is intentionally commented.
- * Currently, the implementation of the
- * mouse move code in the parent interferes
- * with tool tips for tool items.
- */
-// OS.memmove (callData, xEvent, XButtonEvent.sizeof);
-// parent.XPointerMotion (w, client_data, call_data, continue_to_dispatch);
- parent.sendMouseEvent (SWT.MouseMove, 0, xEvent);
-
- return 0;
-}
-}
+public void setWidth (int width) {
+ checkWidget();
+ if ((style & SWT.SEPARATOR) == 0) return;
+ if (width < 0) return;
+ int [] argList = {OS.XmNheight, 0};
+ OS.XtGetValues (handle, argList, argList.length / 2);
+ setSize (width, argList [1], true);
+ 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);
+}
+boolean translateAccelerator (int key, int keysym, XKeyEvent xEvent) {
+ return parent.translateAccelerator (key, keysym, xEvent);
+}
+boolean translateMnemonic (int key, XKeyEvent xEvent) {
+ return parent.translateMnemonic (key, xEvent);
+}
+boolean translateTraversal (int key, XKeyEvent xEvent) {
+ return parent.translateTraversal (key, xEvent);
+}
+void propagateWidget (boolean enabled) {
+ propagateHandle (enabled, handle);
+}
+int XButtonPress (int w, int client_data, int call_data, int continue_to_dispatch) {
+ Display display = getDisplay ();
+// Shell shell = parent.getShell ();
+ display.hideToolTip ();
+ XButtonEvent xEvent = new XButtonEvent ();
+ OS.memmove (xEvent, call_data, XButtonEvent.sizeof);
+ if (xEvent.button == 1) {
+ if (!set && (style & SWT.RADIO) == 0) {
+ setDrawPressed (!set);
+ }
+ }
+
+ /*
+ * Forward the mouse event to the parent.
+ * This is necessary so that mouse listeners
+ * in the parent will be called, despite the
+ * fact that the event did not really occur
+ * in X in the parent. This is done to be
+ * compatible with Windows.
+ */
+ int [] argList = {OS.XmNx, 0, OS.XmNy, 0};
+ OS.XtGetValues (handle, argList, argList.length / 2);
+ xEvent.window = OS.XtWindow (parent.handle);
+ xEvent.x += argList [1]; xEvent.y += argList [3];
+ OS.memmove (call_data, xEvent, XButtonEvent.sizeof);
+ parent.XButtonPress (w, client_data, call_data, continue_to_dispatch);
+
+ /*
+ * It is possible that the shell may be
+ * disposed at this point. If this happens
+ * don't send the activate and deactivate
+ * events.
+ */
+// if (!shell.isDisposed()) {
+// shell.setActiveControl (parent);
+// }
+ return 0;
+}
+int XButtonRelease (int w, int client_data, int call_data, int continue_to_dispatch) {
+ Display display = getDisplay ();
+ display.hideToolTip();
+ XButtonEvent xEvent = new XButtonEvent ();
+ OS.memmove (xEvent, call_data, XButtonEvent.sizeof);
+ if (xEvent.button == 1) {
+ int [] argList = {OS.XmNwidth, 0, OS.XmNheight, 0};
+ OS.XtGetValues (handle, argList, argList.length / 2);
+ int width = argList [1], height = argList [3];
+ if (0 <= xEvent.x && xEvent.x < width && 0 <= xEvent.y && xEvent.y < height) {
+ click (xEvent.x > width - 12, xEvent);
+ }
+ setDrawPressed(set);
+ }
+
+ /*
+ * Forward the mouse event to the parent.
+ * This is necessary so that mouse listeners
+ * in the parent will be called, despite the
+ * fact that the event did not really occur
+ * in X in the parent. This is done to be
+ * compatible with Windows.
+ */
+ int [] argList = {OS.XmNx, 0, OS.XmNy, 0};
+ OS.XtGetValues (handle, argList, argList.length / 2);
+ xEvent.window = OS.XtWindow (parent.handle);
+ xEvent.x += argList [1]; xEvent.y += argList [3];
+ OS.memmove (call_data, xEvent, XButtonEvent.sizeof);
+ parent.XButtonRelease (w, client_data, call_data, continue_to_dispatch);
+
+ return 0;
+}
+int XEnterWindow (int w, int client_data, int call_data, int continue_to_dispatch) {
+ XCrossingEvent xEvent = new XCrossingEvent ();
+ OS.memmove (xEvent, call_data, XCrossingEvent.sizeof);
+ if ((xEvent.state & OS.Button1Mask) != 0) {
+ setDrawPressed (!set);
+ } else {
+ if ((parent.style & SWT.FLAT) != 0) redraw ();
+ }
+ return 0;
+}
+int XFocusChange (int w, int client_data, int call_data, int continue_to_dispatch) {
+ /*
+ * Forward the focus event to the parent.
+ * This is necessary so that focus listeners
+ * in the parent will be called, despite the
+ * fact that the event did not really occur
+ * in X in the parent. This is done to be
+ * compatible with Windows.
+ */
+ XFocusChangeEvent xEvent = new XFocusChangeEvent ();
+ OS.memmove (xEvent, call_data, XFocusChangeEvent.sizeof);
+ xEvent.window = OS.XtWindow (parent.handle);
+// TEMPORARY CODE - need to fix the window field in xEvent
+// OS.memmove (callData, xEvent, XFocusChangeEvent.sizeof);
+
+ /*
+ * This code is intentionally commented.
+ */
+// parent.processSetFocus (callData);
+ return 0;
+}
+int XKeyPress (int w, int client_data, int call_data, int continue_to_dispatch) {
+ XKeyEvent xEvent = new XKeyEvent ();
+ OS.memmove (xEvent, call_data, XKeyEvent.sizeof);
+ int [] keysym = new int [1];
+ OS.XLookupString (xEvent, null, 0, keysym, null);
+ keysym [0] &= 0xFFFF;
+ switch (keysym [0]) {
+ case OS.XK_space:
+ click (false, xEvent);
+ break;
+ case OS.XK_KP_Enter:
+ case OS.XK_Return:
+ click (true, xEvent);
+ break;
+ }
+ /*
+ * Forward the key event to the parent.
+ * This is necessary so that key listeners
+ * in the parent will be called, despite the
+ * fact that the event did not really occur
+ * in X in the parent. This is done to be
+ * compatible with Windows.
+ */
+ xEvent.window = OS.XtWindow (parent.handle);
+// OS.memmove (callData, xEvent, XKeyEvent.sizeof);
+ parent.XKeyPress (w, client_data, call_data, continue_to_dispatch);
+ return 0;
+}
+int XKeyRelease (int w, int client_data, int call_data, int continue_to_dispatch) {
+ XKeyEvent xEvent = new XKeyEvent ();
+ OS.memmove (xEvent, call_data, XKeyEvent.sizeof);
+
+ /*
+ * Forward the key event to the parent.
+ * This is necessary so that key listeners
+ * in the parent will be called, despite the
+ * fact that the event did not really occur
+ * in X in the parent. This is done to be
+ * compatible with Windows.
+ */
+ xEvent.window = OS.XtWindow (parent.handle);
+// OS.memmove (callData, xEvent, XKeyEvent.sizeof);
+ parent.XKeyRelease (w, client_data, call_data, continue_to_dispatch);
+ return 0;
+}
+int XLeaveWindow (int w, int client_data, int call_data, int continue_to_dispatch) {
+ Display display = getDisplay ();
+ display.removeMouseHoverTimeOut ();
+ display.hideToolTip ();
+ XCrossingEvent xEvent = new XCrossingEvent ();
+ OS.memmove (xEvent, call_data, XCrossingEvent.sizeof);
+ if ((xEvent.state & OS.Button1Mask) != 0) {
+ setDrawPressed (set);
+ } else {
+ if ((parent.style & SWT.FLAT) != 0) redraw ();
+ }
+ return 0;
+}
+int XmNexposureCallback (int w, int client_data, int call_data) {
+ 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.XtGetValues (handle, argList, argList.length / 2);
+ int width = argList [3], height = argList [5];
+
+ Image currentImage = image;
+ boolean enabled = getEnabled();
+
+ if ((parent.style & SWT.FLAT) != 0) {
+ Display display = getDisplay ();
+ boolean hasCursor = hasCursor ();
+
+ /* Set the shadow thickness */
+ int thickness = 0;
+ if (set || (hasCursor && enabled)) {
+ thickness = Math.min (2, display.buttonShadowThickness);
+ }
+ argList = new int [] {OS.XmNshadowThickness, thickness};
+ OS.XtSetValues (handle, argList, argList.length / 2);
+
+ /* Determine if hot image should be used */
+ if (enabled && hasCursor && hotImage != null) {
+ currentImage = hotImage;
+ }
+ }
+
+ ToolDrawable wrapper = new ToolDrawable ();
+ wrapper.device = getDisplay ();
+ wrapper.display = xDisplay;
+ wrapper.drawable = xWindow;
+ wrapper.font = parent.font;
+ wrapper.colormap = argList [1];
+ GC gc = new GC (wrapper);
+
+ XmAnyCallbackStruct cb = new XmAnyCallbackStruct ();
+ OS.memmove (cb, call_data, 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);
+ }
+
+ if (!enabled) {
+ Display display = getDisplay ();
+ currentImage = disabledImage;
+ if (currentImage == null && image != 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.length () != 0) {
+ int flags = SWT.DRAW_DELIMITER | SWT.DRAW_TAB | SWT.DRAW_MNEMONIC;
+ Point textExtent = gc.textExtent (text, flags);
+ 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;
+ }
+
+ int spacing = 0;
+ if (textWidth != 0 && imageWidth != 0) spacing = 2;
+ if ((parent.style & SWT.RIGHT) != 0) {
+ imageX = (width - imageWidth - textWidth - spacing) / 2;
+ imageY = (height - imageHeight) / 2;
+ textX = spacing + imageX + imageWidth;
+ textY = (height - textHeight) / 2;
+ } else {
+ imageX = (width - imageWidth) / 2;
+ imageY = (height - imageHeight - textHeight - spacing) / 2;
+ textX = (width - textWidth) / 2;
+ textY = spacing + imageY + imageHeight;
+ }
+
+ if ((style & SWT.DROP_DOWN) != 0) {
+ textX -= 6; imageX -=6;
+ }
+ if (textWidth > 0) {
+ int flags = SWT.DRAW_DELIMITER | SWT.DRAW_TAB | SWT.DRAW_MNEMONIC;
+ gc.drawText(text, textX, textY, flags);
+ }
+ if (imageWidth > 0) gc.drawImage(currentImage, imageX, imageY);
+ if ((style & SWT.DROP_DOWN) != 0) {
+ int startX = width - 12, startY = (height - 2) / 2;
+ int [] arrow = {startX, startY, startX + 3, startY + 3, startX + 6, startY};
+ gc.setBackground (parent.getForeground ());
+ gc.fillPolygon (arrow);
+ gc.drawPolygon (arrow);
+ }
+ gc.dispose ();
+
+ if (!enabled && disabledImage == null) {
+ if (currentImage != null) currentImage.dispose ();
+ }
+ return 0;
+}
+int XPointerMotion (int w, int client_data, int call_data, int continue_to_dispatch) {
+ Display display = getDisplay ();
+ display.addMouseHoverTimeOut (handle);
+
+ /*
+ * Forward the mouse event to the parent.
+ * This is necessary so that mouse listeners
+ * in the parent will be called, despite the
+ * fact that the event did not really occur
+ * in X in the parent. This is done to be
+ * compatible with Windows.
+ */
+ XButtonEvent xEvent = new XButtonEvent ();
+ OS.memmove (xEvent, call_data, XButtonEvent.sizeof);
+ int [] argList = {OS.XmNx, 0, OS.XmNy, 0};
+ OS.XtGetValues (handle, argList, argList.length / 2);
+ xEvent.window = OS.XtWindow (parent.handle);
+ xEvent.x += argList [1]; xEvent.y += argList [3];
+ /*
+ * This code is intentionally commented.
+ * Currently, the implementation of the
+ * mouse move code in the parent interferes
+ * with tool tips for tool items.
+ */
+// OS.memmove (callData, xEvent, XButtonEvent.sizeof);
+// parent.XPointerMotion (w, client_data, call_data, continue_to_dispatch);
+ parent.sendMouseEvent (SWT.MouseMove, 0, xEvent);
+
+ 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
index 60161f6cdc..446340ebe4 100755
--- 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
@@ -1,46 +1,46 @@
-package org.eclipse.swt.widgets;
-
-/*
+package org.eclipse.swt.widgets;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-import org.eclipse.swt.internal.motif.*;
-import org.eclipse.swt.graphics.*;
-import org.eclipse.swt.*;
-import org.eclipse.swt.events.*;
-
-/**
- * Instances of this class implement rubber banding rectangles that are
- * drawn onto a parent <code>Composite</code> or <code>Display</code>.
- * These rectangles can be specified to respond to mouse and key events
- * by either moving or resizing themselves accordingly. Trackers are
- * typically used to represent window geometries in a lightweight manner.
- *
- * <dl>
- * <dt><b>Styles:</b></dt>
- * <dd>LEFT, RIGHT, UP, DOWN, RESIZE</dd>
- * <dt><b>Events:</b></dt>
- * <dd>Move, Resize</dd>
- * </dl>
- * <p>
- * Note: Rectangle move behavior is assumed unless RESIZE is specified.
- * </p><p>
- * IMPORTANT: This class is <em>not</em> intended to be subclassed.
- * </p>
- */
-public class Tracker extends Widget {
- Composite parent;
- Display display;
- boolean tracking, stippled;
- Rectangle [] rectangles, proportions;
- int cursorOrientation = SWT.NONE;
- int cursor;
- final static int STEPSIZE_SMALL = 1;
- final static int STEPSIZE_LARGE = 9;
-
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+import org.eclipse.swt.internal.motif.*;
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.*;
+import org.eclipse.swt.events.*;
+
+/**
+ * Instances of this class implement rubber banding rectangles that are
+ * drawn onto a parent <code>Composite</code> or <code>Display</code>.
+ * These rectangles can be specified to respond to mouse and key events
+ * by either moving or resizing themselves accordingly. Trackers are
+ * typically used to represent window geometries in a lightweight manner.
+ *
+ * <dl>
+ * <dt><b>Styles:</b></dt>
+ * <dd>LEFT, RIGHT, UP, DOWN, RESIZE</dd>
+ * <dt><b>Events:</b></dt>
+ * <dd>Move, Resize</dd>
+ * </dl>
+ * <p>
+ * Note: Rectangle move behavior is assumed unless RESIZE is specified.
+ * </p><p>
+ * IMPORTANT: This class is <em>not</em> intended to be subclassed.
+ * </p>
+ */
+public class Tracker extends Widget {
+ Composite parent;
+ Display display;
+ boolean tracking, stippled;
+ Rectangle [] rectangles, proportions;
+ int cursorOrientation = SWT.NONE;
+ int cursor;
+ final static int STEPSIZE_SMALL = 1;
+ final static int STEPSIZE_LARGE = 9;
+
/**
* Constructs a new instance of this class given its parent
* and a style value describing its behavior and appearance.
@@ -73,12 +73,12 @@ public class Tracker extends Widget {
* @see Widget#checkSubclass
* @see Widget#getStyle
*/
-public Tracker (Composite parent, int style) {
- super (parent, checkStyle (style));
- this.parent = parent;
- display = parent.getDisplay ();
-}
-
+public Tracker (Composite parent, int style) {
+ super (parent, checkStyle (style));
+ this.parent = parent;
+ display = parent.getDisplay ();
+}
+
/**
* Constructs a new instance of this class given the display
* to create it on and a style value describing its behavior
@@ -113,530 +113,530 @@ public Tracker (Composite parent, int style) {
* @see SWT#UP
* @see SWT#DOWN
*/
-public Tracker (Display display, int style) {
- if (display == null) display = Display.getCurrent ();
- if (display == null) display = Display.getDefault ();
- if (!display.isValidThread ()) {
- error (SWT.ERROR_THREAD_INVALID_ACCESS);
- }
- this.style = checkStyle (style);
- this.display = display;
-}
-
-/**
- * Adds the listener to the collection of listeners who will
- * be notified when the control is moved or resized, by sending
- * it one of the messages defined in the <code>ControlListener</code>
- * interface.
- *
- * @param listener the listener which should be notified
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see ControlListener
- * @see #removeControlListener
+public Tracker (Display display, int style) {
+ if (display == null) display = Display.getCurrent ();
+ if (display == null) display = Display.getDefault ();
+ if (!display.isValidThread ()) {
+ error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ }
+ this.style = checkStyle (style);
+ this.display = display;
+}
+
+/**
+ * Adds the listener to the collection of listeners who will
+ * be notified when the control is moved or resized, by sending
+ * it one of the messages defined in the <code>ControlListener</code>
+ * interface.
+ *
+ * @param listener the listener which should be notified
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see ControlListener
+ * @see #removeControlListener
*/
-public void addControlListener (ControlListener listener) {
- checkWidget ();
- if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
- TypedListener typedListener = new TypedListener (listener);
- addListener (SWT.Move,typedListener);
-}
-
-Point adjustMoveCursor (int xDisplay, int xWindow) {
- final int unused[] = new int[1];
- int actualX[] = new int[1];
- int actualY[] = new int[1];
-
- Rectangle bounds = computeBounds ();
- int newX = bounds.x + bounds.width / 2;
- int newY = bounds.y;
-
- OS.XWarpPointer (xDisplay, OS.None, xWindow, 0, 0, 0, 0, newX, newY);
- /*
- * The call to XWarpPointer does not always place the pointer on the
- * exact location that is specified, so do a query (below) to get the
- * actual location of the pointer after it has been moved.
- */
- OS.XQueryPointer (xDisplay, xWindow, unused, unused, actualX, actualY, unused, unused, unused);
- return new Point (actualX[0], actualY[0]);
-}
-Point adjustResizeCursor (int xDisplay, int xWindow) {
- int newX, newY;
- Rectangle bounds = computeBounds ();
-
- if ((cursorOrientation & SWT.LEFT) != 0) {
- newX = bounds.x;
- } else if ((cursorOrientation & SWT.RIGHT) != 0) {
- newX = bounds.x + bounds.width;
- } else {
- newX = bounds.x + bounds.width / 2;
- }
-
- if ((cursorOrientation & SWT.UP) != 0) {
- newY = bounds.y;
- } else if ((cursorOrientation & SWT.DOWN) != 0) {
- newY = bounds.y + bounds.height;
- } else {
- newY = bounds.y + bounds.height / 2;
- }
-
- final int unused[] = new int[1];
- int actualX[] = new int[1];
- int actualY[] = new int[1];
- OS.XWarpPointer (xDisplay, 0, xWindow, 0, 0, 0, 0, newX, newY);
- /*
- * The call to XWarpPointer does not always place the pointer on the
- * exact location that is specified, so do a query (below) to get the
- * actual location of the pointer after it has been moved.
- */
- OS.XQueryPointer (xDisplay, xWindow, unused, unused, actualX, actualY, unused, unused, unused);
- return new Point (actualX[0], actualY[0]);
-}
-static int checkStyle (int style) {
- if ((style & (SWT.LEFT | SWT.RIGHT | SWT.UP | SWT.DOWN)) == 0) {
- style |= SWT.LEFT | SWT.RIGHT | SWT.UP | SWT.DOWN;
- }
- return style;
-}
-/**
- * Stops displaying the tracker rectangles. Note that this is not considered
- * to be a cancelation by the user.
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public void close () {
- checkWidget ();
- tracking = false;
-}
-Rectangle computeBounds () {
- int xMin = rectangles [0].x;
- int yMin = rectangles [0].y;
- int xMax = rectangles [0].x + rectangles [0].width;
- int yMax = rectangles [0].y + rectangles [0].height;
-
- for (int i = 1; i < rectangles.length; i++) {
- if (rectangles [i].x < xMin) xMin = rectangles [i].x;
- if (rectangles [i].y < yMin) yMin = rectangles [i].y;
- int rectRight = rectangles [i].x + rectangles [i].width;
- if (rectRight > xMax) xMax = rectRight;
- int rectBottom = rectangles [i].y + rectangles [i].height;
- if (rectBottom > yMax) yMax = rectBottom;
- }
-
- return new Rectangle (xMin, yMin, xMax - xMin, yMax - yMin);
-}
-
-Rectangle [] computeProportions (Rectangle [] rects) {
- Rectangle [] result = new Rectangle [rects.length];
- Rectangle bounds = computeBounds ();
- for (int i = 0; i < rects.length; i++) {
- result[i] = new Rectangle (
- (rects[i].x - bounds.x) * 100 / bounds.width,
- (rects[i].y - bounds.y) * 100 / bounds.height,
- rects[i].width * 100 / bounds.width,
- rects[i].height * 100 / bounds.height);
- }
- return result;
-}
-
-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;
-}
-/**
- * Returns the bounds that are being drawn, expressed relative to the parent
- * widget. If the parent is a <code>Display</code> then these are screen
- * coordinates.
- *
- * @return the bounds of the Rectangles being drawn
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
+public void addControlListener (ControlListener listener) {
+ checkWidget ();
+ if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+ TypedListener typedListener = new TypedListener (listener);
+ addListener (SWT.Move,typedListener);
+}
+
+Point adjustMoveCursor (int xDisplay, int xWindow) {
+ final int unused[] = new int[1];
+ int actualX[] = new int[1];
+ int actualY[] = new int[1];
+
+ Rectangle bounds = computeBounds ();
+ int newX = bounds.x + bounds.width / 2;
+ int newY = bounds.y;
+
+ OS.XWarpPointer (xDisplay, OS.None, xWindow, 0, 0, 0, 0, newX, newY);
+ /*
+ * The call to XWarpPointer does not always place the pointer on the
+ * exact location that is specified, so do a query (below) to get the
+ * actual location of the pointer after it has been moved.
+ */
+ OS.XQueryPointer (xDisplay, xWindow, unused, unused, actualX, actualY, unused, unused, unused);
+ return new Point (actualX[0], actualY[0]);
+}
+Point adjustResizeCursor (int xDisplay, int xWindow) {
+ int newX, newY;
+ Rectangle bounds = computeBounds ();
+
+ if ((cursorOrientation & SWT.LEFT) != 0) {
+ newX = bounds.x;
+ } else if ((cursorOrientation & SWT.RIGHT) != 0) {
+ newX = bounds.x + bounds.width;
+ } else {
+ newX = bounds.x + bounds.width / 2;
+ }
+
+ if ((cursorOrientation & SWT.UP) != 0) {
+ newY = bounds.y;
+ } else if ((cursorOrientation & SWT.DOWN) != 0) {
+ newY = bounds.y + bounds.height;
+ } else {
+ newY = bounds.y + bounds.height / 2;
+ }
+
+ final int unused[] = new int[1];
+ int actualX[] = new int[1];
+ int actualY[] = new int[1];
+ OS.XWarpPointer (xDisplay, 0, xWindow, 0, 0, 0, 0, newX, newY);
+ /*
+ * The call to XWarpPointer does not always place the pointer on the
+ * exact location that is specified, so do a query (below) to get the
+ * actual location of the pointer after it has been moved.
+ */
+ OS.XQueryPointer (xDisplay, xWindow, unused, unused, actualX, actualY, unused, unused, unused);
+ return new Point (actualX[0], actualY[0]);
+}
+static int checkStyle (int style) {
+ if ((style & (SWT.LEFT | SWT.RIGHT | SWT.UP | SWT.DOWN)) == 0) {
+ style |= SWT.LEFT | SWT.RIGHT | SWT.UP | SWT.DOWN;
+ }
+ return style;
+}
+/**
+ * Stops displaying the tracker rectangles. Note that this is not considered
+ * to be a cancelation by the user.
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
*/
-public 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 void close () {
+ checkWidget ();
+ tracking = false;
+}
+Rectangle computeBounds () {
+ int xMin = rectangles [0].x;
+ int yMin = rectangles [0].y;
+ int xMax = rectangles [0].x + rectangles [0].width;
+ int yMax = rectangles [0].y + rectangles [0].height;
+
+ for (int i = 1; i < rectangles.length; i++) {
+ if (rectangles [i].x < xMin) xMin = rectangles [i].x;
+ if (rectangles [i].y < yMin) yMin = rectangles [i].y;
+ int rectRight = rectangles [i].x + rectangles [i].width;
+ if (rectRight > xMax) xMax = rectRight;
+ int rectBottom = rectangles [i].y + rectangles [i].height;
+ if (rectBottom > yMax) yMax = rectBottom;
+ }
+
+ return new Rectangle (xMin, yMin, xMax - xMin, yMax - yMin);
+}
+
+Rectangle [] computeProportions (Rectangle [] rects) {
+ Rectangle [] result = new Rectangle [rects.length];
+ Rectangle bounds = computeBounds ();
+ for (int i = 0; i < rects.length; i++) {
+ result[i] = new Rectangle (
+ (rects[i].x - bounds.x) * 100 / bounds.width,
+ (rects[i].y - bounds.y) * 100 / bounds.height,
+ rects[i].width * 100 / bounds.width,
+ rects[i].height * 100 / bounds.height);
+ }
+ return result;
+}
+
+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;
+}
+/**
+ * Returns the bounds that are being drawn, expressed relative to the parent
+ * widget. If the parent is a <code>Display</code> then these are screen
+ * coordinates.
+ *
+ * @return the bounds of the Rectangles being drawn
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
*/
-public boolean getStippled () {
- checkWidget ();
- return stippled;
-}
-
-void moveRectangles (int xChange, int yChange) {
- if (xChange < 0 && ((style & SWT.LEFT) == 0)) return;
- if (xChange > 0 && ((style & SWT.RIGHT) == 0)) return;
- if (yChange < 0 && ((style & SWT.UP) == 0)) return;
- if (yChange > 0 && ((style & SWT.DOWN) == 0)) return;
- for (int i = 0; i < rectangles.length; i++) {
- rectangles [i].x += xChange;
- rectangles [i].y += yChange;
- }
-}
-
-/**
- * Displays the Tracker rectangles for manipulation by the user. Returns when
- * the user has either finished manipulating the rectangles or has cancelled the
- * Tracker.
- *
- * @return <code>true</code> if the user did not cancel the Tracker, <code>false</code> otherwise
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public boolean open () {
- checkWidget ();
- if (rectangles == null) return false;
- int xDisplay = display.xDisplay;
- int xWindow = OS.XDefaultRootWindow (xDisplay);
- if (parent != null) {
- xWindow = OS.XtWindow (parent.handle);
- if (xWindow == 0) return false;
- }
- boolean cancelled = false;
- tracking = true;
- drawRectangles ();
- int [] oldX = new int [1], oldY = new int [1];
- int [] unused = new int [1], mask = new int [1];
- OS.XQueryPointer (xDisplay, xWindow, unused, unused, oldX, oldY, unused, unused, mask);
- Point cursorPos;
- int mouseMasks = OS.Button1Mask | OS.Button2Mask | OS.Button3Mask;
- boolean mouseDown = (mask [0] & mouseMasks) != 0;
- if (!mouseDown) {
- if ((style & SWT.RESIZE) != 0) {
- cursorPos = adjustResizeCursor (xDisplay, xWindow);
- } else {
- cursorPos = adjustMoveCursor (xDisplay, xWindow);
- }
- oldX [0] = cursorPos.x; oldY [0] = cursorPos.y;
- }
-
- XAnyEvent xEvent = new XAnyEvent ();
- int [] newX = new int [1], newY = new int [1];
- int xtContext = OS.XtDisplayToApplicationContext (xDisplay);
-
- int ptrGrabResult = OS.XGrabPointer (
- xDisplay,
- xWindow,
- 0,
- OS.ButtonPressMask | OS.ButtonReleaseMask | OS.PointerMotionMask,
- OS.GrabModeAsync,
- OS.GrabModeAsync,
- OS.None,
- OS.None,
- OS.CurrentTime);
- int kbdGrabResult = OS.XGrabKeyboard (
- xDisplay,
- xWindow,
- 0,
- OS.GrabModeAsync,
- OS.GrabModeAsync,
- OS.CurrentTime);
-
- /*
- * Tracker behaves like a Dialog with its own OS event loop.
- */
- while (tracking) {
- if (parent != null && parent.isDisposed ()) break;
- OS.XtAppNextEvent (xtContext, xEvent);
- switch (xEvent.type) {
- case OS.MotionNotify:
- if (cursor != 0) {
- OS.XChangeActivePointerGrab (
- xDisplay,
- OS.ButtonPressMask | OS.ButtonReleaseMask | OS.PointerMotionMask,
- cursor,
- OS.CurrentTime);
- }
- // fall through
- case OS.ButtonRelease:
- OS.XQueryPointer (xDisplay, xWindow, unused, unused, newX, newY, unused, unused, unused);
- if (oldX [0] != newX [0] || oldY [0] != newY [0]) {
- drawRectangles ();
- Event event = new Event ();
- event.x = newX [0];
- event.y = newY [0];
- if ((style & SWT.RESIZE) != 0) {
- resizeRectangles (newX [0] - oldX [0], newY [0] - oldY [0]);
- sendEvent (SWT.Resize, event);
- cursorPos = adjustResizeCursor (xDisplay, xWindow);
- newX [0] = cursorPos.x; newY [0] = cursorPos.y;
- } else {
- moveRectangles (newX [0] - oldX [0], newY [0] - oldY [0]);
- sendEvent (SWT.Move, event);
- }
- /*
- * It is possible (but unlikely) that application code
- * could have disposed the widget in the move event.
- * If this happens then return false to indicate that
- * the move failed.
- */
- if (isDisposed ()) {
- if (ptrGrabResult == OS.GrabSuccess) OS.XUngrabPointer (xDisplay, OS.CurrentTime);
- if (kbdGrabResult == OS.GrabSuccess) OS.XUngrabKeyboard (xDisplay, OS.CurrentTime);
- return false;
- }
- 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, null);
- keysym [0] &= 0xFFFF;
- int xChange = 0, yChange = 0;
- int stepSize = ((keyEvent.state & OS.ControlMask) != 0) ? STEPSIZE_SMALL : STEPSIZE_LARGE;
- switch (keysym [0]) {
- case OS.XK_KP_Enter:
- case OS.XK_Return:
- tracking = false;
- /*
- * Eat the subsequent KeyRelease event
- */
- OS.XtAppNextEvent (xtContext, xEvent);
- break;
- case OS.XK_Escape:
- case OS.XK_Cancel:
- tracking = false;
- cancelled = true;
- /*
- * Eat the subsequent KeyRelease event
- */
- OS.XtAppNextEvent (xtContext, xEvent);
- break;
- case OS.XK_Left:
- xChange = -stepSize;
- break;
- case OS.XK_Right:
- xChange = stepSize;
- break;
- case OS.XK_Up:
- yChange = -stepSize;
- break;
- case OS.XK_Down:
- yChange = stepSize;
- break;
- }
- if (xChange != 0 || yChange != 0) {
- drawRectangles ();
- Event event = new Event ();
- event.x = oldX[0] + xChange;
- event.y = oldY[0] + yChange;
- if ((style & SWT.RESIZE) != 0) {
- resizeRectangles (xChange, yChange);
- sendEvent (SWT.Resize, event);
- cursorPos = adjustResizeCursor (xDisplay, xWindow);
- } else {
- moveRectangles (xChange, yChange);
- sendEvent (SWT.Move, event);
- cursorPos = adjustMoveCursor (xDisplay, xWindow);
- }
- /*
- * It is possible (but unlikely) that application code
- * could have disposed the widget in the move event.
- * If this happens then return false to indicate that
- * the move failed.
- */
- if (isDisposed ()) {
- if (ptrGrabResult == OS.GrabSuccess) OS.XUngrabPointer (xDisplay, OS.CurrentTime);
- if (kbdGrabResult == OS.GrabSuccess) OS.XUngrabKeyboard (xDisplay, OS.CurrentTime);
- return false;
- }
- drawRectangles ();
- oldX[0] = cursorPos.x; oldY[0] = cursorPos.y;
- }
- }
- break;
- case OS.EnterNotify:
- case OS.LeaveNotify:
- /*
- * Do not dispatch these
- */
- break;
- default:
- OS.XtDispatchEvent (xEvent);
- }
- }
- drawRectangles ();
- if (ptrGrabResult == OS.GrabSuccess) OS.XUngrabPointer (xDisplay, OS.CurrentTime);
- if (kbdGrabResult == OS.GrabSuccess) OS.XUngrabKeyboard (xDisplay, OS.CurrentTime);
- 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 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 void removeControlListener (ControlListener listener) {
- checkWidget ();
- if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
- if (eventTable == null) return;
- eventTable.unhook (SWT.Move, listener);
-}
-void resizeRectangles (int xChange, int yChange) {
- /*
- * If the cursor orientation has not been set in the orientation of
- * this change then try to set it here.
- */
- if (xChange < 0 && ((style & SWT.LEFT) != 0) && ((cursorOrientation & SWT.RIGHT) == 0)) {
- cursorOrientation |= SWT.LEFT;
- } else if (xChange > 0 && ((style & SWT.RIGHT) != 0) && ((cursorOrientation & SWT.LEFT) == 0)) {
- cursorOrientation |= SWT.RIGHT;
- } else if (yChange < 0 && ((style & SWT.UP) != 0) && ((cursorOrientation & SWT.DOWN) == 0)) {
- cursorOrientation |= SWT.UP;
- } else if (yChange > 0 && ((style & SWT.DOWN) != 0) && ((cursorOrientation & SWT.UP) == 0)) {
- cursorOrientation |= SWT.DOWN;
- }
- Rectangle bounds = computeBounds ();
- if ((cursorOrientation & SWT.LEFT) != 0) {
- bounds.x += xChange;
- bounds.width -= xChange;
- } else if ((cursorOrientation & SWT.RIGHT) != 0) {
- bounds.width += xChange;
- }
- if ((cursorOrientation & SWT.UP) != 0) {
- bounds.y += yChange;
- bounds.height -= yChange;
- } else if ((cursorOrientation & SWT.DOWN) != 0) {
- bounds.height += yChange;
- }
- /*
- * The following are conditions under which the resize should not be applied
- */
- if (bounds.width < 0 || bounds.height < 0) return;
-
- Rectangle [] newRects = new Rectangle [rectangles.length];
- for (int i = 0; i < rectangles.length; i++) {
- Rectangle proportion = proportions[i];
- newRects[i] = new Rectangle (
- proportion.x * bounds.width / 100 + bounds.x,
- proportion.y * bounds.height / 100 + bounds.y,
- proportion.width * bounds.width / 100,
- proportion.height * bounds.height / 100);
- }
- rectangles = newRects;
-}
-
-/**
- * Sets the <code>Cursor</code> of the Tracker. If this cursor is <code>null</code>
- * then the cursor reverts to the default.
- *
- * @param newCursor the new <code>Cursor</code> to display
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public void setCursor (Cursor value) {
- checkWidget ();
- cursor = 0;
- if (value != null) cursor = value.handle;
-}
-/**
- * Specifies the rectangles that should be drawn, expressed relative to the parent
- * widget. If the parent is a Display then these are screen coordinates.
- *
- * @param rectangles the bounds of the rectangles to be drawn
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if 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;
+}
+
+void moveRectangles (int xChange, int yChange) {
+ if (xChange < 0 && ((style & SWT.LEFT) == 0)) return;
+ if (xChange > 0 && ((style & SWT.RIGHT) == 0)) return;
+ if (yChange < 0 && ((style & SWT.UP) == 0)) return;
+ if (yChange > 0 && ((style & SWT.DOWN) == 0)) return;
+ for (int i = 0; i < rectangles.length; i++) {
+ rectangles [i].x += xChange;
+ rectangles [i].y += yChange;
+ }
+}
+
+/**
+ * Displays the Tracker rectangles for manipulation by the user. Returns when
+ * the user has either finished manipulating the rectangles or has cancelled the
+ * Tracker.
+ *
+ * @return <code>true</code> if the user did not cancel the Tracker, <code>false</code> otherwise
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
*/
-public void setRectangles (Rectangle [] rectangles) {
- checkWidget ();
- this.rectangles = rectangles;
- proportions = computeProportions (rectangles);
-}
-/**
- * Changes the appearance of the line used to draw the rectangles.
- *
- * @param stippled <code>true</code> if rectangle should appear stippled
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
+public boolean open () {
+ checkWidget ();
+ if (rectangles == null) return false;
+ int xDisplay = display.xDisplay;
+ int xWindow = OS.XDefaultRootWindow (xDisplay);
+ if (parent != null) {
+ xWindow = OS.XtWindow (parent.handle);
+ if (xWindow == 0) return false;
+ }
+ boolean cancelled = false;
+ tracking = true;
+ drawRectangles ();
+ int [] oldX = new int [1], oldY = new int [1];
+ int [] unused = new int [1], mask = new int [1];
+ OS.XQueryPointer (xDisplay, xWindow, unused, unused, oldX, oldY, unused, unused, mask);
+ Point cursorPos;
+ int mouseMasks = OS.Button1Mask | OS.Button2Mask | OS.Button3Mask;
+ boolean mouseDown = (mask [0] & mouseMasks) != 0;
+ if (!mouseDown) {
+ if ((style & SWT.RESIZE) != 0) {
+ cursorPos = adjustResizeCursor (xDisplay, xWindow);
+ } else {
+ cursorPos = adjustMoveCursor (xDisplay, xWindow);
+ }
+ oldX [0] = cursorPos.x; oldY [0] = cursorPos.y;
+ }
+
+ XAnyEvent xEvent = new XAnyEvent ();
+ int [] newX = new int [1], newY = new int [1];
+ int xtContext = OS.XtDisplayToApplicationContext (xDisplay);
+
+ int ptrGrabResult = OS.XGrabPointer (
+ xDisplay,
+ xWindow,
+ 0,
+ OS.ButtonPressMask | OS.ButtonReleaseMask | OS.PointerMotionMask,
+ OS.GrabModeAsync,
+ OS.GrabModeAsync,
+ OS.None,
+ OS.None,
+ OS.CurrentTime);
+ int kbdGrabResult = OS.XGrabKeyboard (
+ xDisplay,
+ xWindow,
+ 0,
+ OS.GrabModeAsync,
+ OS.GrabModeAsync,
+ OS.CurrentTime);
+
+ /*
+ * Tracker behaves like a Dialog with its own OS event loop.
+ */
+ while (tracking) {
+ if (parent != null && parent.isDisposed ()) break;
+ OS.XtAppNextEvent (xtContext, xEvent);
+ switch (xEvent.type) {
+ case OS.MotionNotify:
+ if (cursor != 0) {
+ OS.XChangeActivePointerGrab (
+ xDisplay,
+ OS.ButtonPressMask | OS.ButtonReleaseMask | OS.PointerMotionMask,
+ cursor,
+ OS.CurrentTime);
+ }
+ // fall through
+ case OS.ButtonRelease:
+ OS.XQueryPointer (xDisplay, xWindow, unused, unused, newX, newY, unused, unused, unused);
+ if (oldX [0] != newX [0] || oldY [0] != newY [0]) {
+ drawRectangles ();
+ Event event = new Event ();
+ event.x = newX [0];
+ event.y = newY [0];
+ if ((style & SWT.RESIZE) != 0) {
+ resizeRectangles (newX [0] - oldX [0], newY [0] - oldY [0]);
+ sendEvent (SWT.Resize, event);
+ cursorPos = adjustResizeCursor (xDisplay, xWindow);
+ newX [0] = cursorPos.x; newY [0] = cursorPos.y;
+ } else {
+ moveRectangles (newX [0] - oldX [0], newY [0] - oldY [0]);
+ sendEvent (SWT.Move, event);
+ }
+ /*
+ * It is possible (but unlikely) that application code
+ * could have disposed the widget in the move event.
+ * If this happens then return false to indicate that
+ * the move failed.
+ */
+ if (isDisposed ()) {
+ if (ptrGrabResult == OS.GrabSuccess) OS.XUngrabPointer (xDisplay, OS.CurrentTime);
+ if (kbdGrabResult == OS.GrabSuccess) OS.XUngrabKeyboard (xDisplay, OS.CurrentTime);
+ return false;
+ }
+ 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, null);
+ keysym [0] &= 0xFFFF;
+ int xChange = 0, yChange = 0;
+ int stepSize = ((keyEvent.state & OS.ControlMask) != 0) ? STEPSIZE_SMALL : STEPSIZE_LARGE;
+ switch (keysym [0]) {
+ case OS.XK_KP_Enter:
+ case OS.XK_Return:
+ tracking = false;
+ /*
+ * Eat the subsequent KeyRelease event
+ */
+ OS.XtAppNextEvent (xtContext, xEvent);
+ break;
+ case OS.XK_Escape:
+ case OS.XK_Cancel:
+ tracking = false;
+ cancelled = true;
+ /*
+ * Eat the subsequent KeyRelease event
+ */
+ OS.XtAppNextEvent (xtContext, xEvent);
+ break;
+ case OS.XK_Left:
+ xChange = -stepSize;
+ break;
+ case OS.XK_Right:
+ xChange = stepSize;
+ break;
+ case OS.XK_Up:
+ yChange = -stepSize;
+ break;
+ case OS.XK_Down:
+ yChange = stepSize;
+ break;
+ }
+ if (xChange != 0 || yChange != 0) {
+ drawRectangles ();
+ Event event = new Event ();
+ event.x = oldX[0] + xChange;
+ event.y = oldY[0] + yChange;
+ if ((style & SWT.RESIZE) != 0) {
+ resizeRectangles (xChange, yChange);
+ sendEvent (SWT.Resize, event);
+ cursorPos = adjustResizeCursor (xDisplay, xWindow);
+ } else {
+ moveRectangles (xChange, yChange);
+ sendEvent (SWT.Move, event);
+ cursorPos = adjustMoveCursor (xDisplay, xWindow);
+ }
+ /*
+ * It is possible (but unlikely) that application code
+ * could have disposed the widget in the move event.
+ * If this happens then return false to indicate that
+ * the move failed.
+ */
+ if (isDisposed ()) {
+ if (ptrGrabResult == OS.GrabSuccess) OS.XUngrabPointer (xDisplay, OS.CurrentTime);
+ if (kbdGrabResult == OS.GrabSuccess) OS.XUngrabKeyboard (xDisplay, OS.CurrentTime);
+ return false;
+ }
+ drawRectangles ();
+ oldX[0] = cursorPos.x; oldY[0] = cursorPos.y;
+ }
+ }
+ break;
+ case OS.EnterNotify:
+ case OS.LeaveNotify:
+ /*
+ * Do not dispatch these
+ */
+ break;
+ default:
+ OS.XtDispatchEvent (xEvent);
+ }
+ }
+ drawRectangles ();
+ if (ptrGrabResult == OS.GrabSuccess) OS.XUngrabPointer (xDisplay, OS.CurrentTime);
+ if (kbdGrabResult == OS.GrabSuccess) OS.XUngrabKeyboard (xDisplay, OS.CurrentTime);
+ 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);
+}
+void resizeRectangles (int xChange, int yChange) {
+ /*
+ * If the cursor orientation has not been set in the orientation of
+ * this change then try to set it here.
+ */
+ if (xChange < 0 && ((style & SWT.LEFT) != 0) && ((cursorOrientation & SWT.RIGHT) == 0)) {
+ cursorOrientation |= SWT.LEFT;
+ } else if (xChange > 0 && ((style & SWT.RIGHT) != 0) && ((cursorOrientation & SWT.LEFT) == 0)) {
+ cursorOrientation |= SWT.RIGHT;
+ } else if (yChange < 0 && ((style & SWT.UP) != 0) && ((cursorOrientation & SWT.DOWN) == 0)) {
+ cursorOrientation |= SWT.UP;
+ } else if (yChange > 0 && ((style & SWT.DOWN) != 0) && ((cursorOrientation & SWT.UP) == 0)) {
+ cursorOrientation |= SWT.DOWN;
+ }
+ Rectangle bounds = computeBounds ();
+ if ((cursorOrientation & SWT.LEFT) != 0) {
+ bounds.x += xChange;
+ bounds.width -= xChange;
+ } else if ((cursorOrientation & SWT.RIGHT) != 0) {
+ bounds.width += xChange;
+ }
+ if ((cursorOrientation & SWT.UP) != 0) {
+ bounds.y += yChange;
+ bounds.height -= yChange;
+ } else if ((cursorOrientation & SWT.DOWN) != 0) {
+ bounds.height += yChange;
+ }
+ /*
+ * The following are conditions under which the resize should not be applied
+ */
+ if (bounds.width < 0 || bounds.height < 0) return;
+
+ Rectangle [] newRects = new Rectangle [rectangles.length];
+ for (int i = 0; i < rectangles.length; i++) {
+ Rectangle proportion = proportions[i];
+ newRects[i] = new Rectangle (
+ proportion.x * bounds.width / 100 + bounds.x,
+ proportion.y * bounds.height / 100 + bounds.y,
+ proportion.width * bounds.width / 100,
+ proportion.height * bounds.height / 100);
+ }
+ rectangles = newRects;
+}
+
+/**
+ * Sets the <code>Cursor</code> of the Tracker. If this cursor is <code>null</code>
+ * then the cursor reverts to the default.
+ *
+ * @param newCursor the new <code>Cursor</code> to display
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setCursor (Cursor value) {
+ checkWidget ();
+ cursor = 0;
+ if (value != null) cursor = value.handle;
+}
+/**
+ * Specifies the rectangles that should be drawn, expressed relative to the parent
+ * widget. If the parent is a Display then these are screen coordinates.
+ *
+ * @param rectangles the bounds of the rectangles to be drawn
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the 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 ();
+ this.rectangles = rectangles;
+ proportions = computeProportions (rectangles);
+}
+/**
+ * Changes the appearance of the line used to draw the rectangles.
+ *
+ * @param stippled <code>true</code> if rectangle should appear stippled
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
*/
-public void setStippled (boolean stippled) {
- checkWidget ();
- this.stippled = stippled;
-}
-}
+public void setStippled (boolean stippled) {
+ checkWidget ();
+ this.stippled = stippled;
+}
+}
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
index 5feb526856..b4a0452721 100755
--- 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
@@ -1,109 +1,109 @@
-package org.eclipse.swt.widgets;
-
-/*
+package org.eclipse.swt.widgets;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-import org.eclipse.swt.internal.*;
-import org.eclipse.swt.internal.motif.*;
-import org.eclipse.swt.*;
-import org.eclipse.swt.events.*;
-
-/**
- * This class is the abstract superclass of all user interface objects.
- * Widgets are created, disposed and issue notification to listeners
- * when events occur which affect them.
- * <dl>
- * <dt><b>Styles:</b></dt>
- * <dd>(none)</dd>
- * <dt><b>Events:</b></dt>
- * <dd>Dispose</dd>
- * </dl>
- * <p>
- * IMPORTANT: This class is intended to be subclassed <em>only</em>
- * within the SWT implementation. However, it has not been marked
- * final to allow those outside of the SWT development team to implement
- * patched versions of the class in order to get around specific
- * limitations in advance of when those limitations can be addressed
- * by the team. Any class built using subclassing to access the internals
- * of this class will likely fail to compile or run between releases and
- * may be strongly platform specific. Subclassing should not be attempted
- * without an intimate and detailed understanding of the workings of the
- * hierarchy. No support is provided for user-written classes which are
- * implemented as subclasses of this class.
- * </p>
- *
- * @see #checkSubclass
+ * http://www.eclipse.org/legal/cpl-v10.html
*/
-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 = '&';
-
- /* Events and Callback constants */
- static final int BUTTON_PRESS = 1;
- static final int BUTTON_RELEASE = 2;
- static final int EXPOSURE = 3;
- static final int ENTER_WINDOW = 4;
- static final int FOCUS_CHANGE = 5;
- static final int KEY_PRESS = 6;
- static final int KEY_RELEASE = 7;
- static final int LEAVE_WINDOW = 8;
- static final int ACTIVATE_CALLBACK = 9;
- static final int ARM_CALLBACK = 10;
- static final int BROWSE_SELECTION_CALLBACK = 11;
- static final int CASCADING_CALLBACK = 12;
- static final int DECREMENT_CALLBACK = 13;
- static final int DEFAULT_ACTION_CALLBACK = 14;
- static final int DRAG_CALLBACK = 15;
- static final int EXTENDED_SELECTION_CALLBACK = 16;
- static final int HELP_CALLBACK = 17;
- static final int INCREMENT_CALLBACK = 18;
- static final int MODIFY_VERIFY_CALLBACK = 19;
- static final int PAGE_DECREMENT_CALLBACK = 20;
- static final int PAGE_INCREMENT_CALLBACK = 21;
- static final int SELECTION_CALLBACK = 22;
- static final int TO_BOTTOM_CALLBACK = 23;
- static final int TO_TOP_CALLBACK = 24;
- static final int VALUE_CHANGED_CALLBACK = 25;
- static final int NON_MASKABLE = 26;
- static final int POINTER_MOTION = 27;
- static final int STRUCTURE_NOTIFY = 28;
- static final int MAP_CALLBACK = 29;
- static final int UNMAP_CALLBACK = 30;
- static final int DELETE_WINDOW = 31;
- static final int EXPOSURE_CALLBACK = 32;
-
-Widget () {
- /* Do nothing */
-}
+
+import org.eclipse.swt.internal.*;
+import org.eclipse.swt.internal.motif.*;
+import org.eclipse.swt.*;
+import org.eclipse.swt.events.*;
+
+/**
+ * This class is the abstract superclass of all user interface objects.
+ * Widgets are created, disposed and issue notification to listeners
+ * when events occur which affect them.
+ * <dl>
+ * <dt><b>Styles:</b></dt>
+ * <dd>(none)</dd>
+ * <dt><b>Events:</b></dt>
+ * <dd>Dispose</dd>
+ * </dl>
+ * <p>
+ * IMPORTANT: This class is intended to be subclassed <em>only</em>
+ * within the SWT implementation. However, it has not been marked
+ * final to allow those outside of the SWT development team to implement
+ * patched versions of the class in order to get around specific
+ * limitations in advance of when those limitations can be addressed
+ * by the team. Any class built using subclassing to access the internals
+ * of this class will likely fail to compile or run between releases and
+ * may be strongly platform specific. Subclassing should not be attempted
+ * without an intimate and detailed understanding of the workings of the
+ * hierarchy. No support is provided for user-written classes which are
+ * implemented as subclasses of this class.
+ * </p>
+ *
+ * @see #checkSubclass
+ */
+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 = '&';
+
+ /* Events and Callback constants */
+ static final int BUTTON_PRESS = 1;
+ static final int BUTTON_RELEASE = 2;
+ static final int EXPOSURE = 3;
+ static final int ENTER_WINDOW = 4;
+ static final int FOCUS_CHANGE = 5;
+ static final int KEY_PRESS = 6;
+ static final int KEY_RELEASE = 7;
+ static final int LEAVE_WINDOW = 8;
+ static final int ACTIVATE_CALLBACK = 9;
+ static final int ARM_CALLBACK = 10;
+ static final int BROWSE_SELECTION_CALLBACK = 11;
+ static final int CASCADING_CALLBACK = 12;
+ static final int DECREMENT_CALLBACK = 13;
+ static final int DEFAULT_ACTION_CALLBACK = 14;
+ static final int DRAG_CALLBACK = 15;
+ static final int EXTENDED_SELECTION_CALLBACK = 16;
+ static final int HELP_CALLBACK = 17;
+ static final int INCREMENT_CALLBACK = 18;
+ static final int MODIFY_VERIFY_CALLBACK = 19;
+ static final int PAGE_DECREMENT_CALLBACK = 20;
+ static final int PAGE_INCREMENT_CALLBACK = 21;
+ static final int SELECTION_CALLBACK = 22;
+ static final int TO_BOTTOM_CALLBACK = 23;
+ static final int TO_TOP_CALLBACK = 24;
+ static final int VALUE_CHANGED_CALLBACK = 25;
+ static final int NON_MASKABLE = 26;
+ static final int POINTER_MOTION = 27;
+ static final int STRUCTURE_NOTIFY = 28;
+ static final int MAP_CALLBACK = 29;
+ static final int UNMAP_CALLBACK = 30;
+ static final int DELETE_WINDOW = 31;
+ static final int EXPOSURE_CALLBACK = 32;
+
+Widget () {
+ /* Do nothing */
+}
/**
* Constructs a new instance of this class given its parent
* and a style value describing its behavior and appearance.
@@ -132,538 +132,538 @@ Widget () {
* @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 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 handler) {
- checkWidget();
- if (handler == null) error (SWT.ERROR_NULL_ARGUMENT);
- if (eventTable == null) eventTable = new EventTable ();
- eventTable.hook (eventType, handler);
-}
-/**
- * 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 addListener (int eventType, Listener handler) {
+ checkWidget();
+ if (handler == null) error (SWT.ERROR_NULL_ARGUMENT);
+ if (eventTable == null) eventTable = new EventTable ();
+ eventTable.hook (eventType, handler);
+}
+/**
+ * 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);
-}
-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 checkOrientation (Widget parent) {
- style &= ~SWT.MIRRORED;
- if ((style & (SWT.LEFT_TO_RIGHT | SWT.RIGHT_TO_LEFT)) == 0) {
- if (parent != null) {
- if ((parent.style & SWT.LEFT_TO_RIGHT) != 0) style |= SWT.LEFT_TO_RIGHT;
- if ((parent.style & SWT.RIGHT_TO_LEFT) != 0) style |= SWT.RIGHT_TO_LEFT;
- }
- }
- style = checkBits (style, SWT.LEFT_TO_RIGHT, SWT.RIGHT_TO_LEFT, 0, 0, 0, 0);
-}
-void checkParent (Widget parent) {
- if (parent == null) error (SWT.ERROR_NULL_ARGUMENT);
- if (!parent.isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
- if (parent.isDisposed()) error (SWT.ERROR_INVALID_ARGUMENT);
-}
-/**
- * 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 (isDisposed ()) 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 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 addDisposeListener (DisposeListener listener) {
+ checkWidget();
+ 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 checkOrientation (Widget parent) {
+ style &= ~SWT.MIRRORED;
+ if ((style & (SWT.LEFT_TO_RIGHT | SWT.RIGHT_TO_LEFT)) == 0) {
+ if (parent != null) {
+ if ((parent.style & SWT.LEFT_TO_RIGHT) != 0) style |= SWT.LEFT_TO_RIGHT;
+ if ((parent.style & SWT.RIGHT_TO_LEFT) != 0) style |= SWT.RIGHT_TO_LEFT;
+ }
+ }
+ style = checkBits (style, SWT.LEFT_TO_RIGHT, SWT.RIGHT_TO_LEFT, 0, 0, 0, 0);
+}
+void checkParent (Widget parent) {
+ if (parent == null) error (SWT.ERROR_NULL_ARGUMENT);
+ if (!parent.isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (parent.isDisposed()) error (SWT.ERROR_INVALID_ARGUMENT);
+}
+/**
+ * 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>
*/
-public void dispose () {
- /*
- * Note: It is valid to attempt to dispose a widget
- * more than once. If this happens, fail silently.
- */
- if (isDisposed()) return;
- if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
- releaseChild ();
- releaseWidget ();
- destroyWidget ();
-}
-void enableHandle (boolean enabled, int widgetHandle) {
- int [] argList = {OS.XmNsensitive, enabled ? 1 : 0};
- OS.XtSetValues (widgetHandle, argList, argList.length / 2);
-}
-void error (int code) {
- SWT.error(code);
-}
-boolean filters (int eventType) {
- Display display = getDisplay ();
- return display.filters (eventType);
-}
-/**
- * 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
+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 (isDisposed ()) 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 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 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 void dispose () {
+ /*
+ * Note: It is valid to attempt to dispose a widget
+ * more than once. If this happens, fail silently.
+ */
+ if (isDisposed()) return;
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ releaseChild ();
+ releaseWidget ();
+ destroyWidget ();
+}
+void enableHandle (boolean enabled, int widgetHandle) {
+ int [] argList = {OS.XmNsensitive, enabled ? 1 : 0};
+ OS.XtSetValues (widgetHandle, argList, argList.length / 2);
+}
+void error (int code) {
+ SWT.error(code);
+}
+boolean filters (int eventType) {
+ Display display = getDisplay ();
+ return display.filters (eventType);
+}
+/**
+ * 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.
+ * </p>
+ *
+ * @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 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.
- * </p>
- *
- * @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 ();
+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 "";
+}
+/**
+ * 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 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 "";
-}
-/**
- * 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;
+}
+void hookEvents () {
+ /* Do nothing */
+}
+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.
+ * </p>
+ *
+ * @return <code>true</code> when the widget is disposed and <code>false</code> otherwise
*/
-public int getStyle () {
- checkWidget();
- return style;
-}
-void hookEvents () {
- /* Do nothing */
-}
-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.
- * </p>
- *
- * @return <code>true</code> when the widget is disposed and <code>false</code> otherwise
+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>
*/
-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) {
+ checkWidget();
+ return hooks (eventType);
+}
+boolean isValidSubclass () {
+ return Display.isValidClass (getClass ());
+}
+boolean isValidThread () {
+ return getDisplay ().isValidThread ();
+}
+void manageChildren () {
+ /* Do nothing */
+}
+char mbcsToWcs (int ch) {
+ return mbcsToWcs (ch, null);
+}
+char mbcsToWcs (int ch, String codePage) {
+ int key = ch & 0xFFFF;
+ if (key <= 0x7F) return (char) 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 (codePage, 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>
*/
-protected boolean isListening (int eventType) {
- checkWidget();
- return hooks (eventType);
-}
-boolean isValidSubclass () {
- return Display.isValidClass (getClass ());
-}
-boolean isValidThread () {
- return getDisplay ().isValidThread ();
-}
-void manageChildren () {
- /* Do nothing */
-}
-char mbcsToWcs (int ch) {
- return mbcsToWcs (ch, null);
-}
-char mbcsToWcs (int ch, String codePage) {
- int key = ch & 0xFFFF;
- if (key <= 0x7F) return (char) 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 (codePage, 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);
+ sendEvent (eventType, event);
+}
+void postEvent (int eventType) {
+ sendEvent (eventType, null, false);
+}
+void postEvent (int eventType, Event event) {
+ sendEvent (eventType, event, false);
+}
+void propagateHandle (boolean enabled, int widgetHandle) {
+ int xDisplay = OS.XtDisplay (widgetHandle);
+ if (xDisplay == 0) return;
+ int xWindow = OS.XtWindow (widgetHandle);
+ if (xWindow == 0) return;
+ /*
+ * Get the event mask from the widget. The event mask
+ * returned by XtBuildEventMask () includes the masks
+ * associated with all callbacks and event handlers
+ * that have been hooked on the widget.
+ */
+ int event_mask = OS.XtBuildEventMask (widgetHandle);
+ int do_not_propagate_mask =
+ OS.KeyPressMask | OS.KeyReleaseMask | OS.ButtonPressMask |
+ OS.ButtonReleaseMask | OS.PointerMotionMask;
+ if (!enabled) {
+ /*
+ * Attempting to propogate EnterWindowMask and LeaveWindowMask
+ * causes an X error so these must be specially cleared out from
+ * the event mask, not included in the propogate mask.
+ */
+ event_mask &= ~(do_not_propagate_mask | OS.EnterWindowMask | OS.LeaveWindowMask);
+ 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);
+}
+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 register () {
+ if (handle == 0) return;
+ WidgetTable.put (handle, this);
+}
+void releaseChild () {
+ /* Do nothing */
+}
+void releaseHandle () {
+ handle = 0;
+ state |= DISPOSED;
+}
+void releaseResources () {
+ releaseWidget ();
+ releaseHandle ();
+}
+void releaseWidget () {
+ sendEvent (SWT.Dispose);
+ deregister ();
+ 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 notifyListeners (int eventType, Event event) {
- checkWidget();
- if (event == null) error (SWT.ERROR_NULL_ARGUMENT);
- sendEvent (eventType, event);
-}
-void postEvent (int eventType) {
- sendEvent (eventType, null, false);
-}
-void postEvent (int eventType, Event event) {
- sendEvent (eventType, event, false);
-}
-void propagateHandle (boolean enabled, int widgetHandle) {
- int xDisplay = OS.XtDisplay (widgetHandle);
- if (xDisplay == 0) return;
- int xWindow = OS.XtWindow (widgetHandle);
- if (xWindow == 0) return;
- /*
- * Get the event mask from the widget. The event mask
- * returned by XtBuildEventMask () includes the masks
- * associated with all callbacks and event handlers
- * that have been hooked on the widget.
- */
- int event_mask = OS.XtBuildEventMask (widgetHandle);
- int do_not_propagate_mask =
- OS.KeyPressMask | OS.KeyReleaseMask | OS.ButtonPressMask |
- OS.ButtonReleaseMask | OS.PointerMotionMask;
- if (!enabled) {
- /*
- * Attempting to propogate EnterWindowMask and LeaveWindowMask
- * causes an X error so these must be specially cleared out from
- * the event mask, not included in the propogate mask.
- */
- event_mask &= ~(do_not_propagate_mask | OS.EnterWindowMask | OS.LeaveWindowMask);
- 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);
-}
-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 register () {
- if (handle == 0) return;
- WidgetTable.put (handle, this);
-}
-void releaseChild () {
- /* Do nothing */
-}
-void releaseHandle () {
- handle = 0;
- state |= DISPOSED;
-}
-void releaseResources () {
- releaseWidget ();
- releaseHandle ();
-}
-void releaseWidget () {
- sendEvent (SWT.Dispose);
- deregister ();
- 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 handler) {
+ checkWidget();
+ if (handler == null) error (SWT.ERROR_NULL_ARGUMENT);
+ if (eventTable == null) return;
+ eventTable.unhook (eventType, handler);
+}
+/**
+ * Removes the listener from the collection of listeners who will
+ * be 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
*/
-public void removeListener (int eventType, Listener handler) {
- checkWidget();
- if (handler == null) error (SWT.ERROR_NULL_ARGUMENT);
- if (eventTable == null) return;
- eventTable.unhook (eventType, handler);
-}
-/**
- * Removes the listener from the collection of listeners who will
- * be 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, SWTEventListener handler) {
- checkWidget();
- if (handler == null) error (SWT.ERROR_NULL_ARGUMENT);
- if (eventTable == null) return;
- eventTable.unhook (eventType, handler);
-}
+protected void removeListener (int eventType, SWTEventListener handler) {
+ checkWidget();
+ if (handler == null) error (SWT.ERROR_NULL_ARGUMENT);
+ if (eventTable == null) return;
+ eventTable.unhook (eventType, handler);
+}
/**
* Removes the listener from the collection of listeners who will
* be notifed when the widget is disposed.
@@ -681,443 +681,443 @@ protected void removeListener (int eventType, SWTEventListener handler) {
* @see DisposeListener
* @see #addDisposeListener
*/
-public void removeDisposeListener (DisposeListener listener) {
- checkWidget();
- if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
- if (eventTable == null) return;
- eventTable.unhook (SWT.Dispose, listener);
-}
-void setInputState (Event event, int state) {
- if ((state & OS.Mod1Mask) != 0) event.stateMask |= SWT.ALT;
- if ((state & OS.ShiftMask) != 0) event.stateMask |= SWT.SHIFT;
- if ((state & OS.ControlMask) != 0) event.stateMask |= SWT.CONTROL;
- if ((state & OS.Button1Mask) != 0) event.stateMask |= SWT.BUTTON1;
- if ((state & OS.Button2Mask) != 0) event.stateMask |= SWT.BUTTON2;
- if ((state & OS.Button3Mask) != 0) event.stateMask |= SWT.BUTTON3;
-}
-void setInputState (Event event, XInputEvent xEvent) {
- setInputState (event, xEvent.state);
-}
-void setKeyState (Event event, XKeyEvent xEvent) {
- if (xEvent.keycode != 0) {
- byte [] buffer = new byte [1];
- int [] keysym = new int [1];
- OS.XLookupString (xEvent, buffer, buffer.length, keysym, null);
-
- /*
- * 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 (OS.IsSunOS && keysym [0] != 0) {
- switch (keysym [0]) {
- case 0x1005FF10:
- keysym [0] = OS.XK_F11;
- buffer [0] = 0;
- break;
- case 0x1005FF11:
- keysym [0] = OS.XK_F12;
- buffer [0] = 0;
- break;
- }
- /*
- * Bug in MOTIF. On Solaris only, there 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;
- }
-
- /*
- * Feature in MOTIF. For some reason, XLookupString() fails
- * to translate both the keysym and the character when the
- * control key is down. For example, Ctrl+2 has the correct
- * keysym value (50) but no character value, while Ctrl+/ has
- * the keysym value (2F) but an invalid character value
- * (1F). It seems that Motif is applying the algorithm to
- * convert a character to a control character for characters
- * that are not valid control characters. The fix is to test
- * for 7-bit ASCII keysym values that fall outside of the
- * the valid control character range and use the keysym value
- * as the character, not the incorrect value that XLookupString()
- * returns. Even though lower case values are not strictly
- * valid control characters, they are included in the range.
- *
- * Some other cases include Ctrl+3..Ctr+8, Ctrl+[.
- */
- if ((xEvent.state & OS.ControlMask) != 0) {
- int key = keysym [0];
- if (0 <= key && key <= 0x7F) {
- if ('a' <= key && key <= 'z') {
- key -= 'a' - 'A';
- }
- if (!(64 <= key && key <= 95)) {
- buffer [0] = (byte) key;
- }
- }
- }
-
- /*
- * Bug in Motif. On HP-UX only, Shift+F9, Shift+F10, Shift+F11
- * and Shift+F12 are not translated correctly by XLookupString.
- * The fix is to look for these values explicitly and correct them. */
- if (OS.IsHPUX && keysym [0] != 0) {
- switch (keysym [0]) {
- case 0xFF91:
- keysym [0] = OS.XK_F9;
- break;
- case 0xFF92:
- keysym [0] = OS.XK_F10;
- break;
- case 0xFF93:
- keysym [0] = OS.XK_F11;
- break;
- case 0xFF94:
- keysym [0] = OS.XK_F12;
- break;
- }
- }
-
- /*
- * Bug in Motif. There are some keycodes for which
- * XLookupString() does not translate the character.
- * Some of examples are Shift+Tab and Ctrl+Space.
- */
- switch (keysym [0]) {
- case OS.XK_ISO_Left_Tab: buffer [0] = '\t'; break;
- case OS.XK_space: buffer [0] = ' '; break;
- }
-
- /* Fill in the event keyCode or character */
- if (keysym [0] != 0) {
- event.keyCode = Display.translateKey (keysym [0]);
- }
- if (buffer [0] != 0) {
- event.character = mbcsToWcs (buffer [0] & 0xFF);
- }
- }
- setInputState (event, xEvent);
-}
-void sendEvent (Event event) {
- Display display = event.display;
- if (!display.filterEvent (event)) {
- if (eventTable != null) eventTable.sendEvent (event);
- }
-}
-void sendEvent (int eventType) {
- sendEvent (eventType, null, true);
-}
-void sendEvent (int eventType, Event event) {
- sendEvent (eventType, event, true);
-}
-void sendEvent (int eventType, Event event, boolean send) {
- Display display = getDisplay ();
- if (eventTable == null && !display.filters (eventType)) {
- return;
- }
- if (event == null) event = new Event ();
- event.type = eventType;
- event.display = display;
- event.widget = this;
- if (event.time == 0) {
- event.time = display.getLastEventTime ();
- }
- if (send) {
- sendEvent (event);
- } else {
- display.postEvent (event);
- }
-}
-/**
- * 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 removeDisposeListener (DisposeListener listener) {
+ checkWidget();
+ if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+ if (eventTable == null) return;
+ eventTable.unhook (SWT.Dispose, listener);
+}
+void setInputState (Event event, int state) {
+ if ((state & OS.Mod1Mask) != 0) event.stateMask |= SWT.ALT;
+ if ((state & OS.ShiftMask) != 0) event.stateMask |= SWT.SHIFT;
+ if ((state & OS.ControlMask) != 0) event.stateMask |= SWT.CONTROL;
+ if ((state & OS.Button1Mask) != 0) event.stateMask |= SWT.BUTTON1;
+ if ((state & OS.Button2Mask) != 0) event.stateMask |= SWT.BUTTON2;
+ if ((state & OS.Button3Mask) != 0) event.stateMask |= SWT.BUTTON3;
+}
+void setInputState (Event event, XInputEvent xEvent) {
+ setInputState (event, xEvent.state);
+}
+void setKeyState (Event event, XKeyEvent xEvent) {
+ if (xEvent.keycode != 0) {
+ byte [] buffer = new byte [1];
+ int [] keysym = new int [1];
+ OS.XLookupString (xEvent, buffer, buffer.length, keysym, null);
+
+ /*
+ * 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 (OS.IsSunOS && keysym [0] != 0) {
+ switch (keysym [0]) {
+ case 0x1005FF10:
+ keysym [0] = OS.XK_F11;
+ buffer [0] = 0;
+ break;
+ case 0x1005FF11:
+ keysym [0] = OS.XK_F12;
+ buffer [0] = 0;
+ break;
+ }
+ /*
+ * Bug in MOTIF. On Solaris only, there 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;
+ }
+
+ /*
+ * Feature in MOTIF. For some reason, XLookupString() fails
+ * to translate both the keysym and the character when the
+ * control key is down. For example, Ctrl+2 has the correct
+ * keysym value (50) but no character value, while Ctrl+/ has
+ * the keysym value (2F) but an invalid character value
+ * (1F). It seems that Motif is applying the algorithm to
+ * convert a character to a control character for characters
+ * that are not valid control characters. The fix is to test
+ * for 7-bit ASCII keysym values that fall outside of the
+ * the valid control character range and use the keysym value
+ * as the character, not the incorrect value that XLookupString()
+ * returns. Even though lower case values are not strictly
+ * valid control characters, they are included in the range.
+ *
+ * Some other cases include Ctrl+3..Ctr+8, Ctrl+[.
+ */
+ if ((xEvent.state & OS.ControlMask) != 0) {
+ int key = keysym [0];
+ if (0 <= key && key <= 0x7F) {
+ if ('a' <= key && key <= 'z') {
+ key -= 'a' - 'A';
+ }
+ if (!(64 <= key && key <= 95)) {
+ buffer [0] = (byte) key;
+ }
+ }
+ }
+
+ /*
+ * Bug in Motif. On HP-UX only, Shift+F9, Shift+F10, Shift+F11
+ * and Shift+F12 are not translated correctly by XLookupString.
+ * The fix is to look for these values explicitly and correct them. */
+ if (OS.IsHPUX && keysym [0] != 0) {
+ switch (keysym [0]) {
+ case 0xFF91:
+ keysym [0] = OS.XK_F9;
+ break;
+ case 0xFF92:
+ keysym [0] = OS.XK_F10;
+ break;
+ case 0xFF93:
+ keysym [0] = OS.XK_F11;
+ break;
+ case 0xFF94:
+ keysym [0] = OS.XK_F12;
+ break;
+ }
+ }
+
+ /*
+ * Bug in Motif. There are some keycodes for which
+ * XLookupString() does not translate the character.
+ * Some of examples are Shift+Tab and Ctrl+Space.
+ */
+ switch (keysym [0]) {
+ case OS.XK_ISO_Left_Tab: buffer [0] = '\t'; break;
+ case OS.XK_space: buffer [0] = ' '; break;
+ }
+
+ /* Fill in the event keyCode or character */
+ if (keysym [0] != 0) {
+ event.keyCode = Display.translateKey (keysym [0]);
+ }
+ if (buffer [0] != 0) {
+ event.character = mbcsToWcs (buffer [0] & 0xFF);
+ }
+ }
+ setInputState (event, xEvent);
+}
+void sendEvent (Event event) {
+ Display display = event.display;
+ if (!display.filterEvent (event)) {
+ if (eventTable != null) eventTable.sendEvent (event);
+ }
+}
+void sendEvent (int eventType) {
+ sendEvent (eventType, null, true);
+}
+void sendEvent (int eventType, Event event) {
+ sendEvent (eventType, event, true);
+}
+void sendEvent (int eventType, Event event, boolean send) {
+ Display display = getDisplay ();
+ if (eventTable == null && !display.filters (eventType)) {
+ return;
+ }
+ if (event == null) event = new Event ();
+ event.type = eventType;
+ event.display = display;
+ event.widget = this;
+ if (event.time == 0) {
+ event.time = display.getLastEventTime ();
+ }
+ if (send) {
+ sendEvent (event);
+ } else {
+ display.postEvent (event);
+ }
+}
+/**
+ * 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 (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 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 + "}";
-}
-int topHandle () {
- return handle;
-}
-boolean translateAccelerator (int key, int keysym, XKeyEvent xEvent) {
- return false;
-}
-boolean translateMnemonic (int key, XKeyEvent xEvent) {
- return false;
-}
-boolean translateTraversal (int key, XKeyEvent xEvent) {
- return false;
-}
-boolean XmProcessTraversal (int widget, int direction) {
- /*
- * Bug in Motif. When XtDestroyWidget() is called from
- * within a FocusOut event handler, Motif GP's. The fix
- * is to post focus events and run them when the handler
- * has returned.
- */
- Display display = getDisplay ();
- boolean oldFocusOut = display.postFocusOut;
- display.postFocusOut = true;
- boolean result = OS.XmProcessTraversal (widget, direction);
- display.postFocusOut = oldFocusOut;
- if (!display.postFocusOut) display.runFocusOutEvents ();
- return result;
-}
-int wcsToMbcs (char ch) {
- return wcsToMbcs (ch, null);
-}
-int wcsToMbcs (char ch, String codePage) {
- int key = ch & 0xFFFF;
- if (key <= 0x7F) return ch;
- byte [] buffer = Converter.wcsToMbcs (codePage, new char [] {ch}, false);
- if (buffer.length == 1) return (char) buffer [0];
- if (buffer.length == 2) {
- return (char) (((buffer [0] & 0xFF) << 8) | (buffer [1] & 0xFF));
- }
- return 0;
-}
-int hoverProc (int widget) {
- return 0;
-}
-int timerProc (int id) {
- return 0;
-}
-int windowProc (int w, int client_data, int call_data, int continue_to_dispatch) {
- switch (client_data) {
- case BUTTON_PRESS: return XButtonPress (w, client_data, call_data, continue_to_dispatch);
- case BUTTON_RELEASE: return XButtonRelease (w, client_data, call_data, continue_to_dispatch);
- case ENTER_WINDOW: return XEnterWindow (w, client_data, call_data, continue_to_dispatch);
- case EXPOSURE: return XExposure (w, client_data, call_data, continue_to_dispatch);
- case FOCUS_CHANGE: return XFocusChange (w, client_data, call_data, continue_to_dispatch);
- case KEY_PRESS: return XKeyPress (w, client_data, call_data, continue_to_dispatch);
- case KEY_RELEASE: return XKeyRelease (w, client_data, call_data, continue_to_dispatch);
- case LEAVE_WINDOW: return XLeaveWindow (w, client_data, call_data, continue_to_dispatch);
- case ACTIVATE_CALLBACK: return XmNactivateCallback (w, client_data, call_data);
- case ARM_CALLBACK: return XmNarmCallback (w, client_data, call_data);
- case BROWSE_SELECTION_CALLBACK: return XmNbrowseSelectionCallback (w, client_data, call_data);
- case CASCADING_CALLBACK: return XmNcascadingCallback (w, client_data, call_data);
- case DECREMENT_CALLBACK: return XmNdecrementCallback (w, client_data, call_data);
- case DEFAULT_ACTION_CALLBACK: return XmNdefaultActionCallback (w, client_data, call_data);
- case DRAG_CALLBACK: return XmNdragCallback (w, client_data, call_data);
- case EXTENDED_SELECTION_CALLBACK: return XmNextendedSelectionCallback (w, client_data, call_data);
- case HELP_CALLBACK: return XmNhelpCallback (w, client_data, call_data);
- case INCREMENT_CALLBACK: return XmNincrementCallback (w, client_data, call_data);
- case MODIFY_VERIFY_CALLBACK: return XmNmodifyVerifyCallback (w, client_data, call_data);
- case PAGE_DECREMENT_CALLBACK: return XmNpageDecrementCallback (w, client_data, call_data);
- case PAGE_INCREMENT_CALLBACK: return XmNpageIncrementCallback (w, client_data, call_data);
- case SELECTION_CALLBACK: return XmNselectionCallback (w, client_data, call_data);
- case TO_BOTTOM_CALLBACK: return XmNtoBottomCallback (w, client_data, call_data);
- case TO_TOP_CALLBACK: return XmNtoTopCallback (w, client_data, call_data);
- case VALUE_CHANGED_CALLBACK: return XmNvalueChangedCallback (w, client_data, call_data);
- case NON_MASKABLE: return XNonMaskable (w, client_data, call_data, continue_to_dispatch);
- case POINTER_MOTION : return XPointerMotion (w, client_data, call_data, continue_to_dispatch);
- case STRUCTURE_NOTIFY: return XStructureNotify (w, client_data, call_data, continue_to_dispatch);
- case MAP_CALLBACK: return XmNmapCallback (w, client_data, call_data);
- case UNMAP_CALLBACK: return XmNunmapCallback (w, client_data, call_data);
- case DELETE_WINDOW: return WM_DELETE_WINDOW (w, client_data, call_data);
- case EXPOSURE_CALLBACK: return XmNexposureCallback (w, client_data, call_data);
- }
- return 0;
-}
-int WM_DELETE_WINDOW (int w, int client_data, int call_data) {
- return 0;
-}
-int XButtonPress (int w, int client_data, int call_data, int continue_to_dispatch) {
- return 0;
-}
-int XButtonRelease (int w, int client_data, int call_data, int continue_to_dispatch) {
- return 0;
-}
-int XEnterWindow (int w, int client_data, int call_data, int continue_to_dispatch) {
- return 0;
-}
-int XExposure (int w, int client_data, int call_data, int continue_to_dispatch) {
- return 0;
-}
-int XFocusChange (int w, int client_data, int call_data, int continue_to_dispatch) {
- return 0;
-}
-int XKeyPress (int w, int client_data, int call_data, int continue_to_dispatch) {
- return 0;
-}
-int XKeyRelease (int w, int client_data, int call_data, int continue_to_dispatch) {
- return 0;
-}
-int XLeaveWindow (int w, int client_data, int call_data, int continue_to_dispatch) {
- return 0;
-}
-int XPointerMotion (int w, int client_data, int call_data, int continue_to_dispatch) {
- return 0;
-}
-int XmNactivateCallback (int w, int client_data, int call_data) {
- return 0;
-}
-int XmNarmCallback (int w, int client_data, int call_data) {
- return 0;
-}
-int XmNbrowseSelectionCallback (int w, int client_data, int call_data) {
- return 0;
-}
-int XmNcascadingCallback (int w, int client_data, int call_data) {
- return 0;
-}
-int XmNdecrementCallback (int w, int client_data, int call_data) {
- return 0;
-}
-int XmNdefaultActionCallback (int w, int client_data, int call_data) {
- return 0;
-}
-int XmNdragCallback (int w, int client_data, int call_data) {
- return 0;
-}
-int XmNexposureCallback (int w, int client_data, int call_data) {
- return 0;
-}
-int XmNextendedSelectionCallback (int w, int client_data, int call_data) {
- return 0;
-}
-int XmNhelpCallback (int w, int client_data, int call_data) {
- return 0;
-}
-int XmNincrementCallback (int w, int client_data, int call_data) {
- return 0;
-}
-int XmNmapCallback (int w, int client_data, int call_data) {
- return 0;
-}
-int XmNmodifyVerifyCallback (int w, int client_data, int call_data) {
- return 0;
-}
-int XmNpageDecrementCallback (int w, int client_data, int call_data) {
- return 0;
-}
-int XmNpageIncrementCallback (int w, int client_data, int call_data) {
- return 0;
-}
-int XmNselectionCallback (int w, int client_data, int call_data) {
- return 0;
-}
-int XmNtoBottomCallback (int w, int client_data, int call_data) {
- return 0;
-}
-int XmNtoTopCallback (int w, int client_data, int call_data) {
- return 0;
-}
-int XmNunmapCallback (int w, int client_data, int call_data) {
- return 0;
-}
-int XmNvalueChangedCallback (int w, int client_data, int call_data) {
- return 0;
-}
-int XNonMaskable (int w, int client_data, int call_data, int continue_to_dispatch) {
- return 0;
-}
-int XStructureNotify (int w, int client_data, int call_data, int continue_to_dispatch) {
- return 0;
-}
-}
+public String toString () {
+ String string = "*Disposed*";
+ if (!isDisposed ()) {
+ string = "*Wrong Thread*";
+ if (isValidThread ()) string = getNameText ();
+ }
+ return getName () + " {" + string + "}";
+}
+int topHandle () {
+ return handle;
+}
+boolean translateAccelerator (int key, int keysym, XKeyEvent xEvent) {
+ return false;
+}
+boolean translateMnemonic (int key, XKeyEvent xEvent) {
+ return false;
+}
+boolean translateTraversal (int key, XKeyEvent xEvent) {
+ return false;
+}
+boolean XmProcessTraversal (int widget, int direction) {
+ /*
+ * Bug in Motif. When XtDestroyWidget() is called from
+ * within a FocusOut event handler, Motif GP's. The fix
+ * is to post focus events and run them when the handler
+ * has returned.
+ */
+ Display display = getDisplay ();
+ boolean oldFocusOut = display.postFocusOut;
+ display.postFocusOut = true;
+ boolean result = OS.XmProcessTraversal (widget, direction);
+ display.postFocusOut = oldFocusOut;
+ if (!display.postFocusOut) display.runFocusOutEvents ();
+ return result;
+}
+int wcsToMbcs (char ch) {
+ return wcsToMbcs (ch, null);
+}
+int wcsToMbcs (char ch, String codePage) {
+ int key = ch & 0xFFFF;
+ if (key <= 0x7F) return ch;
+ byte [] buffer = Converter.wcsToMbcs (codePage, new char [] {ch}, false);
+ if (buffer.length == 1) return (char) buffer [0];
+ if (buffer.length == 2) {
+ return (char) (((buffer [0] & 0xFF) << 8) | (buffer [1] & 0xFF));
+ }
+ return 0;
+}
+int hoverProc (int widget) {
+ return 0;
+}
+int timerProc (int id) {
+ return 0;
+}
+int windowProc (int w, int client_data, int call_data, int continue_to_dispatch) {
+ switch (client_data) {
+ case BUTTON_PRESS: return XButtonPress (w, client_data, call_data, continue_to_dispatch);
+ case BUTTON_RELEASE: return XButtonRelease (w, client_data, call_data, continue_to_dispatch);
+ case ENTER_WINDOW: return XEnterWindow (w, client_data, call_data, continue_to_dispatch);
+ case EXPOSURE: return XExposure (w, client_data, call_data, continue_to_dispatch);
+ case FOCUS_CHANGE: return XFocusChange (w, client_data, call_data, continue_to_dispatch);
+ case KEY_PRESS: return XKeyPress (w, client_data, call_data, continue_to_dispatch);
+ case KEY_RELEASE: return XKeyRelease (w, client_data, call_data, continue_to_dispatch);
+ case LEAVE_WINDOW: return XLeaveWindow (w, client_data, call_data, continue_to_dispatch);
+ case ACTIVATE_CALLBACK: return XmNactivateCallback (w, client_data, call_data);
+ case ARM_CALLBACK: return XmNarmCallback (w, client_data, call_data);
+ case BROWSE_SELECTION_CALLBACK: return XmNbrowseSelectionCallback (w, client_data, call_data);
+ case CASCADING_CALLBACK: return XmNcascadingCallback (w, client_data, call_data);
+ case DECREMENT_CALLBACK: return XmNdecrementCallback (w, client_data, call_data);
+ case DEFAULT_ACTION_CALLBACK: return XmNdefaultActionCallback (w, client_data, call_data);
+ case DRAG_CALLBACK: return XmNdragCallback (w, client_data, call_data);
+ case EXTENDED_SELECTION_CALLBACK: return XmNextendedSelectionCallback (w, client_data, call_data);
+ case HELP_CALLBACK: return XmNhelpCallback (w, client_data, call_data);
+ case INCREMENT_CALLBACK: return XmNincrementCallback (w, client_data, call_data);
+ case MODIFY_VERIFY_CALLBACK: return XmNmodifyVerifyCallback (w, client_data, call_data);
+ case PAGE_DECREMENT_CALLBACK: return XmNpageDecrementCallback (w, client_data, call_data);
+ case PAGE_INCREMENT_CALLBACK: return XmNpageIncrementCallback (w, client_data, call_data);
+ case SELECTION_CALLBACK: return XmNselectionCallback (w, client_data, call_data);
+ case TO_BOTTOM_CALLBACK: return XmNtoBottomCallback (w, client_data, call_data);
+ case TO_TOP_CALLBACK: return XmNtoTopCallback (w, client_data, call_data);
+ case VALUE_CHANGED_CALLBACK: return XmNvalueChangedCallback (w, client_data, call_data);
+ case NON_MASKABLE: return XNonMaskable (w, client_data, call_data, continue_to_dispatch);
+ case POINTER_MOTION : return XPointerMotion (w, client_data, call_data, continue_to_dispatch);
+ case STRUCTURE_NOTIFY: return XStructureNotify (w, client_data, call_data, continue_to_dispatch);
+ case MAP_CALLBACK: return XmNmapCallback (w, client_data, call_data);
+ case UNMAP_CALLBACK: return XmNunmapCallback (w, client_data, call_data);
+ case DELETE_WINDOW: return WM_DELETE_WINDOW (w, client_data, call_data);
+ case EXPOSURE_CALLBACK: return XmNexposureCallback (w, client_data, call_data);
+ }
+ return 0;
+}
+int WM_DELETE_WINDOW (int w, int client_data, int call_data) {
+ return 0;
+}
+int XButtonPress (int w, int client_data, int call_data, int continue_to_dispatch) {
+ return 0;
+}
+int XButtonRelease (int w, int client_data, int call_data, int continue_to_dispatch) {
+ return 0;
+}
+int XEnterWindow (int w, int client_data, int call_data, int continue_to_dispatch) {
+ return 0;
+}
+int XExposure (int w, int client_data, int call_data, int continue_to_dispatch) {
+ return 0;
+}
+int XFocusChange (int w, int client_data, int call_data, int continue_to_dispatch) {
+ return 0;
+}
+int XKeyPress (int w, int client_data, int call_data, int continue_to_dispatch) {
+ return 0;
+}
+int XKeyRelease (int w, int client_data, int call_data, int continue_to_dispatch) {
+ return 0;
+}
+int XLeaveWindow (int w, int client_data, int call_data, int continue_to_dispatch) {
+ return 0;
+}
+int XPointerMotion (int w, int client_data, int call_data, int continue_to_dispatch) {
+ return 0;
+}
+int XmNactivateCallback (int w, int client_data, int call_data) {
+ return 0;
+}
+int XmNarmCallback (int w, int client_data, int call_data) {
+ return 0;
+}
+int XmNbrowseSelectionCallback (int w, int client_data, int call_data) {
+ return 0;
+}
+int XmNcascadingCallback (int w, int client_data, int call_data) {
+ return 0;
+}
+int XmNdecrementCallback (int w, int client_data, int call_data) {
+ return 0;
+}
+int XmNdefaultActionCallback (int w, int client_data, int call_data) {
+ return 0;
+}
+int XmNdragCallback (int w, int client_data, int call_data) {
+ return 0;
+}
+int XmNexposureCallback (int w, int client_data, int call_data) {
+ return 0;
+}
+int XmNextendedSelectionCallback (int w, int client_data, int call_data) {
+ return 0;
+}
+int XmNhelpCallback (int w, int client_data, int call_data) {
+ return 0;
+}
+int XmNincrementCallback (int w, int client_data, int call_data) {
+ return 0;
+}
+int XmNmapCallback (int w, int client_data, int call_data) {
+ return 0;
+}
+int XmNmodifyVerifyCallback (int w, int client_data, int call_data) {
+ return 0;
+}
+int XmNpageDecrementCallback (int w, int client_data, int call_data) {
+ return 0;
+}
+int XmNpageIncrementCallback (int w, int client_data, int call_data) {
+ return 0;
+}
+int XmNselectionCallback (int w, int client_data, int call_data) {
+ return 0;
+}
+int XmNtoBottomCallback (int w, int client_data, int call_data) {
+ return 0;
+}
+int XmNtoTopCallback (int w, int client_data, int call_data) {
+ return 0;
+}
+int XmNunmapCallback (int w, int client_data, int call_data) {
+ return 0;
+}
+int XmNvalueChangedCallback (int w, int client_data, int call_data) {
+ return 0;
+}
+int XNonMaskable (int w, int client_data, int call_data, int continue_to_dispatch) {
+ return 0;
+}
+int XStructureNotify (int w, int client_data, int call_data, int continue_to_dispatch) {
+ 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
index ce5ac52d44..fec0c7d19e 100755
--- 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
@@ -1,123 +1,123 @@
-package org.eclipse.swt.widgets;
-
-/*
+package org.eclipse.swt.widgets;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-import org.eclipse.swt.internal.motif.*;
-
-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;
-}
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+import org.eclipse.swt.internal.motif.*;
+
+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/org/eclipse/swt/graphics/Color.java b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/graphics/Color.java
index e2c0de95a9..cf558e9838 100755
--- 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
@@ -1,14 +1,14 @@
-package org.eclipse.swt.graphics;
-
-/*
+package org.eclipse.swt.graphics;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-import org.eclipse.swt.*;
-
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+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
@@ -22,22 +22,22 @@ import org.eclipse.swt.*;
*
* @see RGB
*/
-public final class Color {
-
- /**
- * the handle to the OS color resource
- * (Warning: This field is platform dependent)
+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
+ public int handle;
+
+ /**
+ * the device where this color was created
*/
- Device device;
-
-Color() {
-}
-
+ Device device;
+
+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
@@ -62,13 +62,13 @@ Color() {
*
* @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);
-}
-
+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.
@@ -91,28 +91,28 @@ public Color (Device device, int red, int green, int blue) {
*
* @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);
-}
-
+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 (device.isDisposed()) return;
-
- handle = -1;
- if (device.tracking) device.dispose_Object(this);
- device = null;
-}
-
+public void dispose() {
+ if (handle == -1) return;
+ if (device.isDisposed()) return;
+
+ 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
@@ -123,13 +123,13 @@ public void dispose() {
*
* @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);
-}
-
+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.
*
@@ -139,11 +139,11 @@ public boolean equals (Object object) {
* <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
* </ul>
*/
-public int getBlue () {
- if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- return handle & 0xFF;
-}
-
+public int getBlue () {
+ if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ return handle & 0xFF;
+}
+
/**
* Returns the amount of green in the color, from 0 to 255.
*
@@ -153,11 +153,11 @@ public int getBlue () {
* <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
* </ul>
*/
-public int getGreen () {
- if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- return (handle & 0xFF00) >> 8;
-}
-
+public int getGreen () {
+ if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ return (handle & 0xFF00) >> 8;
+}
+
/**
* Returns the amount of red in the color, from 0 to 255.
*
@@ -167,11 +167,11 @@ public int getGreen () {
* <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
* </ul>
*/
-public int getRed () {
- if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- return (handle & 0xFF0000) >> 16;
-}
-
+public int getRed () {
+ if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ return (handle & 0xFF0000) >> 16;
+}
+
/**
* Returns an <code>RGB</code> representing the receiver.
*
@@ -179,11 +179,11 @@ public int getRed () {
* <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
* </ul>
*/
-public RGB getRGB () {
- if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- return new RGB((handle & 0xFF0000) >> 16, (handle & 0xFF00) >> 8, handle & 0xFF);
-}
-
+public RGB getRGB () {
+ if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ return new RGB((handle & 0xFF0000) >> 16, (handle & 0xFF00) >> 8, handle & 0xFF);
+}
+
/**
* Returns an integer hash code for the receiver. Any two
* objects which return <code>true</code> when passed to
@@ -194,18 +194,18 @@ public RGB getRGB () {
*
* @see #equals
*/
-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 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);
+}
+
/**
* Returns <code>true</code> if the color has been disposed,
* and <code>false</code> otherwise.
@@ -216,26 +216,26 @@ void init(Device device, int red, int green, int blue) {
*
* @return <code>true</code> when the color is disposed and <code>false</code> otherwise
*/
-public boolean isDisposed() {
- return handle == -1;
-}
-
+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 () {
- if (isDisposed()) return "Color {*DISPOSED*}";
- 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;
-}
+public String toString () {
+ if (isDisposed()) return "Color {*DISPOSED*}";
+ 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;
+}
}
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
index f03104f83c..870119152a 100755
--- 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
@@ -1,15 +1,15 @@
-package org.eclipse.swt.graphics;
-
-/*
+package org.eclipse.swt.graphics;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-import org.eclipse.swt.internal.photon.*;
-import org.eclipse.swt.*;
-
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+import org.eclipse.swt.internal.photon.*;
+import org.eclipse.swt.*;
+
/**
* Instances of this class manage operating system resources that
* specify the appearance of the on-screen pointer. To create a
@@ -34,28 +34,28 @@ import org.eclipse.swt.*;
* Note: Only one of the above styles may be specified.
* </p>
*/
-public final class Cursor {
-
- /**
- * the type to the OS cursor resource
- * (Warning: This field is platform dependent)
+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 type;
+
+ /**
+ * the handle to the OS cursor resource
+ * (Warning: This field is platform dependent)
*/
- public int bitmap;
-
- /**
- * the device where this cursor was created
+ public int bitmap;
+
+ /**
+ * the device where this cursor was created
*/
- Device device;
-
-Cursor() {
-}
-
+ Device device;
+
+Cursor() {
+}
+
/**
* Constructs a new cursor given a device and a style
* constant describing the desired cursor appearance.
@@ -97,40 +97,40 @@ Cursor() {
* @see SWT#CURSOR_NO
* @see SWT#CURSOR_HAND
*/
-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);
- }
- if (type == 0) SWT.error(SWT.ERROR_NO_HANDLES);
- if (device.tracking) device.new_Object(this);
-}
-
+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);
+ }
+ if (type == 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
@@ -163,105 +163,105 @@ public Cursor(Device device, int style) {
* <li>ERROR_NO_HANDLES - if a handle could not be obtained for cursor creation</li>
* </ul>
*/
-public Cursor(Device device, ImageData source, ImageData mask, int hotspotX, int hotspotY) {
- 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);
- }
- type = OS.Ph_CURSOR_BITMAP;
-
- short w = (short)source.width;
- short h = (short)source.height;
- ImageData mask1 = new ImageData(w, h, 1, source.palette);
- ImageData mask2 = new ImageData(w, h, 1, mask.palette);
- for (int y=0; y<h; y++) {
- for (int x=0; x<w; x++) {
- int mask1_pixel, src_pixel = source.getPixel(x, y);
- int mask2_pixel, mask_pixel = mask.getPixel(x, y);
- if (src_pixel == 0 && mask_pixel == 0) {
- // BLACK
- mask1_pixel = 0;
- mask2_pixel = 1;
- } else if (src_pixel == 0 && mask_pixel == 1) {
- // WHITE - cursor color
- mask1_pixel = 1;
- mask2_pixel = 0;
- } else if (src_pixel == 1 && mask_pixel == 0) {
- // SCREEN
- mask1_pixel = 0;
- mask2_pixel = 0;
- } else {
- /*
- * Feature in Photon. It is not possible to have
- * the reverse screen case using the Photon support.
- * Reverse screen will be the same as screen.
- */
- // REVERSE SCREEN -> SCREEN
- mask1_pixel = 0;
- mask2_pixel = 0;
- }
- mask1.setPixel(x, y, mask1_pixel);
- mask2.setPixel(x, y, mask2_pixel);
- }
- }
-
- PhCursorDef_t cursor = new PhCursorDef_t();
- cursor.size1_x = w;
- cursor.size1_y = h;
- cursor.offset1_x = (short)-hotspotX;
- cursor.offset1_y = (short)-hotspotY;
- cursor.bytesperline1 = (byte)mask1.bytesPerLine;
- cursor.color1 = OS.Ph_CURSOR_DEFAULT_COLOR;
- cursor.size2_x = w;
- cursor.size2_y = h;
- cursor.offset2_x = (short)-hotspotX;
- cursor.offset2_y = (short)-hotspotY;
- cursor.bytesperline2 = (byte)mask2.bytesPerLine;
- cursor.color2 = 0x000000;
- int mask1Size = cursor.bytesperline1 * cursor.size1_y;
- int mask2Size = cursor.bytesperline2 * cursor.size2_y;
- bitmap = OS.malloc(PhCursorDef_t.sizeof + mask1Size + mask2Size);
- if (bitmap == 0) SWT.error(SWT.ERROR_NO_HANDLES);
- OS.memmove(bitmap, cursor, PhCursorDef_t.sizeof);
- OS.memmove(bitmap + PhCursorDef_t.sizeof, mask1.data, mask1Size);
- OS.memmove(bitmap + PhCursorDef_t.sizeof + mask1Size, mask2.data, mask2Size);
- 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;
+ 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);
+ }
+ type = OS.Ph_CURSOR_BITMAP;
+
+ short w = (short)source.width;
+ short h = (short)source.height;
+ ImageData mask1 = new ImageData(w, h, 1, source.palette);
+ ImageData mask2 = new ImageData(w, h, 1, mask.palette);
+ for (int y=0; y<h; y++) {
+ for (int x=0; x<w; x++) {
+ int mask1_pixel, src_pixel = source.getPixel(x, y);
+ int mask2_pixel, mask_pixel = mask.getPixel(x, y);
+ if (src_pixel == 0 && mask_pixel == 0) {
+ // BLACK
+ mask1_pixel = 0;
+ mask2_pixel = 1;
+ } else if (src_pixel == 0 && mask_pixel == 1) {
+ // WHITE - cursor color
+ mask1_pixel = 1;
+ mask2_pixel = 0;
+ } else if (src_pixel == 1 && mask_pixel == 0) {
+ // SCREEN
+ mask1_pixel = 0;
+ mask2_pixel = 0;
+ } else {
+ /*
+ * Feature in Photon. It is not possible to have
+ * the reverse screen case using the Photon support.
+ * Reverse screen will be the same as screen.
+ */
+ // REVERSE SCREEN -> SCREEN
+ mask1_pixel = 0;
+ mask2_pixel = 0;
+ }
+ mask1.setPixel(x, y, mask1_pixel);
+ mask2.setPixel(x, y, mask2_pixel);
+ }
+ }
+
+ PhCursorDef_t cursor = new PhCursorDef_t();
+ cursor.size1_x = w;
+ cursor.size1_y = h;
+ cursor.offset1_x = (short)-hotspotX;
+ cursor.offset1_y = (short)-hotspotY;
+ cursor.bytesperline1 = (byte)mask1.bytesPerLine;
+ cursor.color1 = OS.Ph_CURSOR_DEFAULT_COLOR;
+ cursor.size2_x = w;
+ cursor.size2_y = h;
+ cursor.offset2_x = (short)-hotspotX;
+ cursor.offset2_y = (short)-hotspotY;
+ cursor.bytesperline2 = (byte)mask2.bytesPerLine;
+ cursor.color2 = 0x000000;
+ int mask1Size = cursor.bytesperline1 * cursor.size1_y;
+ int mask2Size = cursor.bytesperline2 * cursor.size2_y;
+ bitmap = OS.malloc(PhCursorDef_t.sizeof + mask1Size + mask2Size);
+ if (bitmap == 0) SWT.error(SWT.ERROR_NO_HANDLES);
+ OS.memmove(bitmap, cursor, PhCursorDef_t.sizeof);
+ OS.memmove(bitmap + PhCursorDef_t.sizeof, mask1.data, mask1Size);
+ OS.memmove(bitmap + PhCursorDef_t.sizeof + mask1Size, mask2.data, mask2Size);
+ 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 (type == 0) return;
- if (device.isDisposed()) return;
- if (type == OS.Ph_CURSOR_BITMAP && bitmap != 0) {
- OS.free(bitmap);
- }
- type = bitmap = 0;
- if (device.tracking) device.dispose_Object(this);
- device = null;
-}
-
+public void dispose () {
+ if (type == 0) return;
+ if (device.isDisposed()) return;
+ if (type == OS.Ph_CURSOR_BITMAP && bitmap != 0) {
+ OS.free(bitmap);
+ }
+ type = bitmap = 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
@@ -272,14 +272,14 @@ public void dispose () {
*
* @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 && type == cursor.type &&
- bitmap == cursor.bitmap;
-}
-
+public boolean equals (Object object) {
+ if (object == this) return true;
+ if (!(object instanceof Cursor)) return false;
+ Cursor cursor = (Cursor) object;
+ return device == cursor.device && type == cursor.type &&
+ bitmap == cursor.bitmap;
+}
+
/**
* Returns an integer hash code for the receiver. Any two
* objects which return <code>true</code> when passed to
@@ -290,10 +290,10 @@ public boolean equals (Object object) {
*
* @see #equals
*/
-public int hashCode () {
- return bitmap ^ type;
-}
-
+public int hashCode () {
+ return bitmap ^ type;
+}
+
/**
* Returns <code>true</code> if the cursor has been disposed,
* and <code>false</code> otherwise.
@@ -304,28 +304,28 @@ public int hashCode () {
*
* @return <code>true</code> when the cursor is disposed and <code>false</code> otherwise
*/
-public boolean isDisposed() {
- return type == 0;
-}
-
-public static Cursor photon_new(Device device, int type, int bitmap) {
- if (device == null) device = Device.getDevice();
- Cursor cursor = new Cursor();
- cursor.type = type;
- cursor.bitmap = bitmap;
- cursor.device = device;
- return cursor;
-}
-
+public boolean isDisposed() {
+ return type == 0;
+}
+
+public static Cursor photon_new(Device device, int type, int bitmap) {
+ if (device == null) device = Device.getDevice();
+ Cursor cursor = new Cursor();
+ cursor.type = type;
+ cursor.bitmap = bitmap;
+ cursor.device = device;
+ return cursor;
+}
+
/**
* Returns a string containing a concise, human-readable
* description of the receiver.
*
* @return a string representation of the receiver
*/
-public String toString () {
- if (isDisposed()) return "Cursor {*DISPOSED*}";
- return "Cursor {" + type + "," + bitmap + "}";
-}
-
+public String toString () {
+ if (isDisposed()) return "Cursor {*DISPOSED*}";
+ return "Cursor {" + type + "," + bitmap + "}";
+}
+
}
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
index f1b87c1626..45deeb28af 100755
--- 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
@@ -1,62 +1,62 @@
-package org.eclipse.swt.graphics;
-
-/*
+package org.eclipse.swt.graphics;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-import org.eclipse.swt.*;
-import org.eclipse.swt.internal.*;
-import org.eclipse.swt.internal.photon.*;
-
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+import org.eclipse.swt.*;
+import org.eclipse.swt.internal.*;
+import org.eclipse.swt.internal.photon.*;
+
/**
* This class is the abstract superclass of all device objects,
* such as the Display device and the Printer device. Devices
* can have a graphics context (GC) created for them, and they
* can be drawn on by sending messages to the associated GC.
*/
-public abstract class Device implements Drawable {
-
- /* Debugging */
- public static boolean DEBUG;
- boolean debug = DEBUG;
- boolean tracking = DEBUG;
- Error [] errors;
- Object [] objects;
-
- boolean disposed;
-
- byte[] systemFont;
-
- /*
- * TEMPORARY CODE. When a graphics object is
- * created and the device parameter is null,
- * the current Display is used. This presents
- * a problem because SWT graphics does not
- * reference classes in SWT widgets. The correct
- * fix is to remove this feature. Unfortunately,
- * too many application programs rely on this
- * feature.
- *
- * This code will be removed in the future.
- */
- protected static Device CurrentDevice;
- protected static Runnable DeviceFinder;
- static {
- try {
- Class.forName ("org.eclipse.swt.widgets.Display");
- } catch (Throwable e) {}
- }
-
-static Device getDevice () {
- if (DeviceFinder != null) DeviceFinder.run();
- Device device = CurrentDevice;
- CurrentDevice = null;
- return device;
-}
-
+public abstract class Device implements Drawable {
+
+ /* Debugging */
+ public static boolean DEBUG;
+ boolean debug = DEBUG;
+ boolean tracking = DEBUG;
+ Error [] errors;
+ Object [] objects;
+
+ boolean disposed;
+
+ byte[] systemFont;
+
+ /*
+ * TEMPORARY CODE. When a graphics object is
+ * created and the device parameter is null,
+ * the current Display is used. This presents
+ * a problem because SWT graphics does not
+ * reference classes in SWT widgets. The correct
+ * fix is to remove this feature. Unfortunately,
+ * too many application programs rely on this
+ * feature.
+ *
+ * This code will be removed in the future.
+ */
+ protected static Device CurrentDevice;
+ protected static Runnable DeviceFinder;
+ static {
+ try {
+ Class.forName ("org.eclipse.swt.widgets.Display");
+ } catch (Throwable e) {}
+ }
+
+static Device getDevice () {
+ if (DeviceFinder != null) DeviceFinder.run();
+ Device device = CurrentDevice;
+ CurrentDevice = null;
+ return device;
+}
+
/**
* Constructs a new instance of this class.
* <p>
@@ -69,32 +69,32 @@ static Device getDevice () {
* @see #init
* @see DeviceData
*/
-public Device(DeviceData data) {
- if (data != null) {
- debug = data.debug;
- tracking = data.tracking;
- }
- create (data);
- init ();
- if (tracking) {
- errors = new Error [128];
- objects = new Object [128];
- }
-
- /* Initialize the system font slot */
- systemFont = getSystemFont ().handle;
-}
-
-protected void checkDevice () {
- if (disposed) SWT.error(SWT.ERROR_DEVICE_DISPOSED);
-}
-
-protected void create (DeviceData data) {
-}
-
-protected void destroy () {
-}
-
+public Device(DeviceData data) {
+ if (data != null) {
+ debug = data.debug;
+ tracking = data.tracking;
+ }
+ create (data);
+ init ();
+ if (tracking) {
+ errors = new Error [128];
+ objects = new Object [128];
+ }
+
+ /* Initialize the system font slot */
+ systemFont = getSystemFont ().handle;
+}
+
+protected void checkDevice () {
+ if (disposed) SWT.error(SWT.ERROR_DEVICE_DISPOSED);
+}
+
+protected void create (DeviceData data) {
+}
+
+protected void destroy () {
+}
+
/**
* Disposes of the operating system resources associated with
* the receiver. After this method has been invoked, the receiver
@@ -105,28 +105,28 @@ protected void destroy () {
* @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;
- }
- }
-}
-
+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;
+ }
+ }
+}
+
/**
* Returns a rectangle describing the receiver's size and location.
*
@@ -136,15 +136,15 @@ void dispose_Object (Object object) {
* <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
* </ul>
*/
-public Rectangle getBounds () {
- checkDevice ();
- PhRect_t rect = new PhRect_t ();
- OS.PhWindowQueryVisible (OS.Ph_QUERY_CONSOLE, 0, OS.PhInputGroup (0), 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 getBounds () {
+ checkDevice ();
+ PhRect_t rect = new PhRect_t ();
+ OS.PhWindowQueryVisible (OS.Ph_QUERY_CONSOLE, 0, OS.PhInputGroup (0), 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);
+}
+
/**
* Returns a rectangle which describes the area of the
* receiver which is capable of displaying data.
@@ -157,15 +157,15 @@ public Rectangle getBounds () {
*
* @see #getBounds
*/
-public Rectangle getClientArea () {
- checkDevice ();
- PhRect_t rect = new PhRect_t ();
- OS.PhWindowQueryVisible (OS.Ph_QUERY_WORKSPACE, 0, OS.PhInputGroup (0), 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 () {
+ checkDevice ();
+ PhRect_t rect = new PhRect_t ();
+ OS.PhWindowQueryVisible (OS.Ph_QUERY_WORKSPACE, 0, OS.PhInputGroup (0), 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);
+}
+
/**
* Returns the bit depth of the screen, which is the number of
* bits it takes to represent the number of unique colors that
@@ -178,15 +178,15 @@ public Rectangle getClientArea () {
* <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
* </ul>
*/
-public int getDepth () {
- checkDevice ();
- PgDisplaySettings_t settings = new PgDisplaySettings_t ();
- OS.PgGetVideoMode (settings);
- PgVideoModeInfo_t mode_info = new PgVideoModeInfo_t ();
- OS.PgGetVideoModeInfo ((short) settings.mode, mode_info);
- return mode_info.bits_per_pixel;
-}
-
+public int getDepth () {
+ checkDevice ();
+ PgDisplaySettings_t settings = new PgDisplaySettings_t ();
+ OS.PgGetVideoMode (settings);
+ PgVideoModeInfo_t mode_info = new PgVideoModeInfo_t ();
+ OS.PgGetVideoModeInfo ((short) settings.mode, mode_info);
+ return mode_info.bits_per_pixel;
+}
+
/**
* Returns a <code>DeviceData</code> based on the receiver.
* Modifications made to this <code>DeviceData</code> will not
@@ -200,29 +200,29 @@ public int getDepth () {
*
* @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;
-}
-
+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 point whose x coordinate is the horizontal
* dots per inch of the display, and whose y coordinate
@@ -234,12 +234,12 @@ public DeviceData getDeviceData () {
* <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
* </ul>
*/
-public Point getDPI () {
- checkDevice ();
- //NOT DONE
- return new Point (96, 96);
-}
-
+public Point getDPI () {
+ checkDevice ();
+ //NOT DONE
+ return new Point (96, 96);
+}
+
/**
* Returns <code>FontData</code> objects which describe
* the fonts that match the given arguments. If the
@@ -253,66 +253,66 @@ public Point getDPI () {
* <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
* </ul>
*/
-public FontData [] getFontList (String faceName, boolean scalable) {
- checkDevice ();
- int flags = OS.PHFONT_FIXED | OS.PHFONT_PROP | OS.PHFONT_DONT_SHOW_LEGACY;
- flags |= scalable ? OS.PHFONT_SCALABLE : OS.PHFONT_BITMAP;
- int nfonts = OS.PfQueryFonts(OS.PHFONT_ALL_SYMBOLS, flags, 0, 0);
- if (nfonts <= 0) return new FontData[0];
- int list_ptr = OS.malloc(nfonts * FontDetails.sizeof);
- nfonts = OS.PfQueryFonts(OS.PHFONT_ALL_SYMBOLS, 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);
- char[] chars = Converter.mbcsToWcs(null, details.desc);
- int index = 0;
- while (index < chars.length) {
- if (chars[index] == 0) break;
- index++;
- }
- String name = new String(chars, 0, index);
- if (faceName == null || Compatibility.equalsIgnoreCase(faceName, 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 FontData [] getFontList (String faceName, boolean scalable) {
+ checkDevice ();
+ int flags = OS.PHFONT_FIXED | OS.PHFONT_PROP | OS.PHFONT_DONT_SHOW_LEGACY;
+ flags |= scalable ? OS.PHFONT_SCALABLE : OS.PHFONT_BITMAP;
+ int nfonts = OS.PfQueryFonts(OS.PHFONT_ALL_SYMBOLS, flags, 0, 0);
+ if (nfonts <= 0) return new FontData[0];
+ int list_ptr = OS.malloc(nfonts * FontDetails.sizeof);
+ nfonts = OS.PfQueryFonts(OS.PHFONT_ALL_SYMBOLS, 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);
+ char[] chars = Converter.mbcsToWcs(null, details.desc);
+ int index = 0;
+ while (index < chars.length) {
+ if (chars[index] == 0) break;
+ index++;
+ }
+ String name = new String(chars, 0, index);
+ if (faceName == null || Compatibility.equalsIgnoreCase(faceName, 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;
+}
+
/**
* Returns the matching standard color for the given
* constant, which should be one of the color constants
@@ -331,30 +331,30 @@ public FontData [] getFontList (String faceName, boolean scalable) {
*
* @see SWT
*/
-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 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);
+}
+
/**
* Returns a reasonable font for applications to use.
* On some platforms, this will match the "default font"
@@ -375,11 +375,11 @@ public Color getSystemColor (int id) {
* <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
* </ul>
*/
-public Font getSystemFont () {
- checkDevice ();
- return Font.photon_new (this, systemFont);
-}
-
+public Font getSystemFont () {
+ checkDevice ();
+ return Font.photon_new (this, systemFont);
+}
+
/**
* Returns <code>true</code> if the underlying window system prints out
* warning messages on the console, and <code>setWarnings</code>
@@ -391,14 +391,14 @@ public Font getSystemFont () {
* <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
* </ul>
*/
-public boolean getWarnings () {
- checkDevice ();
- return false;
-}
-
-protected void init () {
-}
-
+public boolean getWarnings () {
+ checkDevice ();
+ return false;
+}
+
+protected void init () {
+}
+
/**
* Invokes platform specific functionality to allocate a new GC handle.
* <p>
@@ -414,8 +414,8 @@ protected void init () {
*
* @private
*/
-public abstract int internal_new_GC (GCData data);
-
+public abstract int internal_new_GC (GCData data);
+
/**
* Invokes platform specific functionality to dispose a GC handle.
* <p>
@@ -431,8 +431,8 @@ public abstract int internal_new_GC (GCData data);
*
* @private
*/
-public abstract void internal_dispose_GC (int handle, GCData data);
-
+public abstract void internal_dispose_GC (int handle, GCData data);
+
/**
* Returns <code>true</code> if the device has been disposed,
* and <code>false</code> otherwise.
@@ -443,31 +443,31 @@ public abstract void internal_dispose_GC (int handle, GCData data);
*
* @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;
-}
-
-protected void release () {
-}
-
+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 () {
+}
+
/**
* If the underlying window system supports printing warning messages
* to the console, setting warnings to <code>true</code> prevents these
@@ -480,8 +480,8 @@ protected void release () {
* <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
* </ul>
*/
-public void setWarnings (boolean warnings) {
- checkDevice ();
-}
-
+public void setWarnings (boolean warnings) {
+ checkDevice ();
+}
+
}
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
index 06e99bb30c..d36b10ff4a 100755
--- 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
@@ -1,19 +1,19 @@
-package org.eclipse.swt.graphics;
-
-/*
+package org.eclipse.swt.graphics;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-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;
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+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;
}
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
index c5923cca91..c2ce18ab7c 100755
--- 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
@@ -1,16 +1,16 @@
-package org.eclipse.swt.graphics;
-
-/*
+package org.eclipse.swt.graphics;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-import org.eclipse.swt.internal.*;
-import org.eclipse.swt.internal.photon.*;
-import org.eclipse.swt.*;
-
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+import org.eclipse.swt.internal.*;
+import org.eclipse.swt.internal.photon.*;
+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
@@ -24,22 +24,22 @@ import org.eclipse.swt.*;
*
* @see FontData
*/
-public final class Font {
-
- /**
- * the handle to the OS font resource
- * (Warning: This field is platform dependent)
+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
+ public byte[] handle;
+
+ /**
+ * the device where this font was created
*/
- Device device;
-
-Font() {
-}
-
+ Device device;
+
+Font() {
+}
+
/**
* Constructs a new font given a device and font data
* which describes the desired font's appearance.
@@ -58,44 +58,44 @@ Font() {
* <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);
- 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);
-}
-
-/**
- * Constructs a new font given a device and font datas
- * which describes the desired font's appearance.
- * <p>
- * You must dispose the font when it is no longer required.
- * </p>
- *
- * @param device the device to create the font on
- * @param fds the array of FontData that describes the desired font (must not be null)
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if device is null and there is no current device</li>
- * <li>ERROR_NULL_ARGUMENT - if the fds argument is null</li>
- * <li>ERROR_INVALID_ARGUMENT - if the length of fds is zero</li>
- * <li>ERROR_NULL_ARGUMENT - if any fd in the array is null</li>
- * </ul>
- * @exception SWTError <ul>
- * <li>ERROR_NO_HANDLES - if a font could not be created from the given font data</li>
- * </ul>
- */
-public Font(Device device, FontData[] fds) {
- if (device == null) device = Device.getDevice();
- if (device == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
- if (fds == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
- if (fds.length == 0) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
- FontData fd = fds[0];
- 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, 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);
+}
+
+/**
+ * Constructs a new font given a device and font datas
+ * which describes the desired font's appearance.
+ * <p>
+ * You must dispose the font when it is no longer required.
+ * </p>
+ *
+ * @param device the device to create the font on
+ * @param fds the array of FontData that describes the desired font (must not be null)
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if device is null and there is no current device</li>
+ * <li>ERROR_NULL_ARGUMENT - if the fds argument is null</li>
+ * <li>ERROR_INVALID_ARGUMENT - if the length of fds is zero</li>
+ * <li>ERROR_NULL_ARGUMENT - if any fd in the array is null</li>
+ * </ul>
+ * @exception SWTError <ul>
+ * <li>ERROR_NO_HANDLES - if a font could not be created from the given font data</li>
+ * </ul>
+ */
+public Font(Device device, FontData[] fds) {
+ if (device == null) device = Device.getDevice();
+ if (device == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ if (fds == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ if (fds.length == 0) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+ FontData fd = fds[0];
+ 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);
+}
/**
* Constructs a new font given a device, a font name,
* the height of the desired font in points, and a font
@@ -118,28 +118,28 @@ public Font(Device device, FontData[] fds) {
* <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, name, height, style, null);
- 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);
+}
+
/**
* Disposes of the operating system resources associated with
* the font. Applications must dispose of all fonts which
* they allocate.
*/
-public void dispose() {
- if (handle == null) return;
- if (device.isDisposed()) return;
-
- handle = null;
- if (device.tracking) device.dispose_Object(this);
- device = null;
-}
-
+public void dispose() {
+ if (handle == null) return;
+ if (device.isDisposed()) return;
+
+ handle = 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
@@ -150,20 +150,20 @@ public void dispose() {
*
* @see #hashCode
*/
-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<h.length; i++) {
- if (handle[i] != h[i]) return false;
- if (handle[i] == 0) break;
- }
- return true;
-}
-
+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<h.length; i++) {
+ if (handle[i] != h[i]) return false;
+ if (handle[i] == 0) break;
+ }
+ return true;
+}
+
/**
* Returns an array of <code>FontData</code>s representing the receiver.
* On Windows, only one FontData will be returned per font. On X however,
@@ -176,11 +176,11 @@ public boolean equals(Object object) {
* <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
* </ul>
*/
-public FontData[] getFontData() {
- if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- return new FontData[]{new FontData(handle)};
-}
-
+public FontData[] getFontData() {
+ if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ return new FontData[]{new FontData(handle)};
+}
+
/**
* Returns an integer hash code for the receiver. Any two
* objects which return <code>true</code> when passed to
@@ -191,11 +191,11 @@ public FontData[] getFontData() {
*
* @see #equals
*/
-public int hashCode () {
- if (handle == null) return 0;
- return handle.hashCode();
-}
-
+public int hashCode () {
+ if (handle == null) return 0;
+ return handle.hashCode();
+}
+
/**
* Returns <code>true</code> if the font has been disposed,
* and <code>false</code> otherwise.
@@ -206,61 +206,61 @@ public int hashCode () {
*
* @return <code>true</code> when the font is disposed and <code>false</code> otherwise
*/
-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_INVALID_ARGUMENT);
- this.device = device;
- if (stem != null) {
- handle = stem;
- } else {
- byte[] description = 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) {
- byte[] defaultFont = device.systemFont;
- int fontID = OS.PfDecomposeStemToID(defaultFont);
- if (fontID != 0) {
- int desc = OS.PfFontDescription(fontID);
- int length = OS.strlen(desc);
- byte[] defaultFontName = new byte[length + 1];
- OS.memmove(defaultFontName, desc, length);
- OS.PfFreeFont(fontID);
- handle = OS.PfGenerateFontName(defaultFontName, osStyle, height, buffer);
- }
- if (handle == null) handle = defaultFont;
- }
- }
- if (handle == null)SWT.error(SWT.ERROR_NO_HANDLES);
-}
-
-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;
-}
-
+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_INVALID_ARGUMENT);
+ this.device = device;
+ if (stem != null) {
+ handle = stem;
+ } else {
+ byte[] description = 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) {
+ byte[] defaultFont = device.systemFont;
+ int fontID = OS.PfDecomposeStemToID(defaultFont);
+ if (fontID != 0) {
+ int desc = OS.PfFontDescription(fontID);
+ int length = OS.strlen(desc);
+ byte[] defaultFontName = new byte[length + 1];
+ OS.memmove(defaultFontName, desc, length);
+ OS.PfFreeFont(fontID);
+ handle = OS.PfGenerateFontName(defaultFontName, osStyle, height, buffer);
+ }
+ if (handle == null) handle = defaultFont;
+ }
+ }
+ if (handle == null)SWT.error(SWT.ERROR_NO_HANDLES);
+}
+
+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;
+}
+
/**
* Returns a string containing a concise, human-readable
* description of the receiver.
*
* @return a string representation of the receiver
*/
-public String toString () {
- if (isDisposed()) return "Font {*DISPOSED*}";
- int index = 0;
- while (index < handle.length) {
- if (handle[index] == 0) break;
- index++;
- }
- String text = new String(handle, 0, index);
- return "Font {" + text + "}";
-}
-
+public String toString () {
+ if (isDisposed()) return "Font {*DISPOSED*}";
+ int index = 0;
+ while (index < handle.length) {
+ if (handle[index] == 0) break;
+ index++;
+ }
+ String text = new String(handle, 0, index);
+ return "Font {" + text + "}";
+}
+
}
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
index 70731d5e22..807a35987f 100755
--- 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
@@ -1,16 +1,16 @@
-package org.eclipse.swt.graphics;
-
-/*
+package org.eclipse.swt.graphics;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-import org.eclipse.swt.internal.*;
-import org.eclipse.swt.internal.photon.*;
-import org.eclipse.swt.*;
-
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+import org.eclipse.swt.internal.*;
+import org.eclipse.swt.internal.photon.*;
+import org.eclipse.swt.*;
+
/**
* Instances of this class describe operating system fonts.
* Only the public API of this type is platform independent.
@@ -36,64 +36,64 @@ import org.eclipse.swt.*;
*
* @see Font
*/
-public final class FontData {
-
- /**
- * the font name
- * (Warning: This field is platform dependent)
+public final class FontData {
+
+ /**
+ * the font name
+ * (Warning: This field is platform dependent)
*/
- public String name;
-
+ public String name;
+
/**
* The height of the font data in points
* (Warning: This field is platform dependent)
*/
- public int height;
-
- /**
- * the font style
- * (Warning: This field is platform dependent)
+ public int height;
+
+ /**
+ * the font style
+ * (Warning: This field is platform dependent)
*/
- public int style;
-
- /**
- * A Photon stem
- * (Warning: This field is platform dependent)
+ public int style;
+
+ /**
+ * A Photon stem
+ * (Warning: This field is platform dependent)
*/
- public byte[] stem;
-
- /**
- * The locales of the font
- * (Warning: These fields are platform dependent)
+ public byte[] stem;
+
+ /**
+ * The locales of the font
+ * (Warning: These fields are platform dependent)
*/
- String lang, country, variant;
-
-FontData(byte[] stem) {
- this.stem = stem;
- int fontID = OS.PfDecomposeStemToID(stem);
- if (fontID != 0) {
- int desc = OS.PfFontDescription(fontID);
- int size = OS.PfFontSize(fontID);
- int flags = OS.PfFontFlags(fontID);
- int length = OS.strlen(desc);
- byte[] buffer = new byte[length];
- OS.memmove(buffer, desc, length);
- name = new String(Converter.mbcsToWcs(null, buffer));
- height = size;
- style = SWT.NORMAL;
- if ((flags & OS.PF_STYLE_BOLD) != 0) style |= SWT.BOLD;
- if ((flags & OS.PF_STYLE_ITALIC) != 0) style |= SWT.ITALIC;
- OS.PfFreeFont(fontID);
- }
-}
-
+ String lang, country, variant;
+
+FontData(byte[] stem) {
+ this.stem = stem;
+ int fontID = OS.PfDecomposeStemToID(stem);
+ if (fontID != 0) {
+ int desc = OS.PfFontDescription(fontID);
+ int size = OS.PfFontSize(fontID);
+ int flags = OS.PfFontFlags(fontID);
+ int length = OS.strlen(desc);
+ byte[] buffer = new byte[length];
+ OS.memmove(buffer, desc, length);
+ name = new String(Converter.mbcsToWcs(null, buffer));
+ height = size;
+ style = SWT.NORMAL;
+ if ((flags & OS.PF_STYLE_BOLD) != 0) style |= SWT.BOLD;
+ if ((flags & OS.PF_STYLE_ITALIC) != 0) style |= SWT.ITALIC;
+ OS.PfFreeFont(fontID);
+ }
+}
+
/**
* Constructs a new un-initialized font data.
*/
-public FontData() {
- this("", 12, SWT.NORMAL);
-}
-
+public FontData() {
+ this("", 12, SWT.NORMAL);
+}
+
/**
* Constructs a new FontData given a string representation
* in the form generated by the <code>FontData.toString</code>
@@ -113,61 +113,61 @@ public FontData() {
*
* @see #toString
*/
-public FontData(String string) {
- if (string == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
- int start = 0;
- int end = string.indexOf('|');
- if (end == -1) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
- String version1 = string.substring(start, end);
- try {
- if (Integer.parseInt(version1) != 1) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
- } catch (NumberFormatException e) {
- SWT.error(SWT.ERROR_INVALID_ARGUMENT);
- }
-
- start = end + 1;
- end = string.indexOf('|', start);
- if (end == -1) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
- String name = string.substring(start, end);
-
- start = end + 1;
- end = string.indexOf('|', start);
- if (end == -1) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
- 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 string) {
+ if (string == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ int start = 0;
+ int end = string.indexOf('|');
+ if (end == -1) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+ String version1 = string.substring(start, end);
+ try {
+ if (Integer.parseInt(version1) != 1) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+ } catch (NumberFormatException e) {
+ SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+ }
+
+ start = end + 1;
+ end = string.indexOf('|', start);
+ if (end == -1) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+ String name = string.substring(start, end);
+
+ start = end + 1;
+ end = string.indexOf('|', start);
+ if (end == -1) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+ 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;
+ }
+}
+
/**
* Constructs a new font data given a font name,
* the height of the desired font in points,
@@ -182,12 +182,12 @@ public FontData(String string) {
* <li>ERROR_INVALID_ARGUMENT - if the height is negative</li>
* </ul>
*/
-public FontData(String name, int height, int style) {
- setName(name);
- setHeight(height);
- setStyle(style);
-}
-
+public FontData(String name, int height, int style) {
+ setName(name);
+ setHeight(height);
+ setStyle(style);
+}
+
/**
* Compares the argument to the receiver, and returns true
* if they represent the <em>same</em> object using a class
@@ -198,13 +198,13 @@ public FontData(String name, int height, int style) {
*
* @see #hashCode
*/
-public boolean equals (Object object) {
- if (object == this) return true;
- if (!(object instanceof FontData)) return false;
- FontData data = (FontData)object;
- return name.equals(data.name) && height == data.height && style == data.style;
-}
-
+public boolean equals (Object object) {
+ if (object == this) return true;
+ if (!(object instanceof FontData)) return false;
+ FontData data = (FontData)object;
+ return name.equals(data.name) && height == data.height && style == data.style;
+}
+
/**
* Returns the height of the receiver in points.
*
@@ -212,10 +212,10 @@ public boolean equals (Object object) {
*
* @see #setHeight
*/
-public int getHeight() {
- return height;
-}
-
+public int getHeight() {
+ return height;
+}
+
/**
* Returns the name of the receiver.
* On platforms that support font foundries, the return value will
@@ -225,10 +225,10 @@ public int getHeight() {
*
* @see #setName
*/
-public String getName() {
- return name;
-}
-
+public String getName() {
+ return name;
+}
+
/**
* Returns the style of the receiver which is a bitwise OR of
* one or more of the <code>SWT</code> constants NORMAL, BOLD
@@ -238,10 +238,10 @@ public String getName() {
*
* @see #setStyle
*/
-public int getStyle() {
- return style;
-}
-
+public int getStyle() {
+ return style;
+}
+
/**
* Returns an integer hash code for the receiver. Any two
* objects which return <code>true</code> when passed to
@@ -252,10 +252,10 @@ public int getStyle() {
*
* @see #equals
*/
-public int hashCode () {
- return name.hashCode() ^ height ^ style;
-}
-
+public int hashCode () {
+ return name.hashCode() ^ height ^ style;
+}
+
/**
* Sets the height of the receiver. The parameter is
* specified in terms of points, where a point is one
@@ -269,12 +269,12 @@ public int hashCode () {
*
* @see #getHeight
*/
-public void setHeight(int height) {
- if (height < 0) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
- this.height = height;
- this.stem = null;
-}
-
+public void setHeight(int height) {
+ if (height < 0) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+ this.height = height;
+ this.stem = null;
+}
+
/**
* Sets the name of the receiver.
* <p>
@@ -300,49 +300,49 @@ public void setHeight(int height) {
*
* @see #getName
*/
-public void setName(String name) {
- if (name == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
- this.name = name;
- this.stem = null;
-}
-
-/**
- * Sets the locale of the receiver.
- * <p>
- * The locale determines which platform character set this
- * font is going to use. Widgets and graphics operations that
- * use this font will convert UNICODE strings to the platform
- * character set of the specified locale.
- * </p>
- * <p>
- * On platforms which there are multiple character sets for a
- * given language/country locale, the variant portion of the
- * locale will determine the character set.
- * </p>
- *
- * @param locale the <code>String</code> representing a Locale object
- * @see java.util.Locale#toString
+public void setName(String name) {
+ if (name == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ this.name = name;
+ this.stem = null;
+}
+
+/**
+ * Sets the locale of the receiver.
+ * <p>
+ * The locale determines which platform character set this
+ * font is going to use. Widgets and graphics operations that
+ * use this font will convert UNICODE strings to the platform
+ * character set of the specified locale.
+ * </p>
+ * <p>
+ * On platforms which there are multiple character sets for a
+ * given language/country locale, the variant portion of the
+ * locale will determine the character set.
+ * </p>
+ *
+ * @param locale the <code>String</code> representing a Locale object
+ * @see java.util.Locale#toString
*/
-public void setLocale(String locale) {
- lang = country = variant = null;
- if (locale != null) {
- char sep = '_';
- int length = locale.length();
- int firstSep, secondSep;
-
- firstSep = locale.indexOf(sep);
- if (firstSep == -1) {
- firstSep = secondSep = length;
- } else {
- secondSep = locale.indexOf(sep, firstSep + 1);
- if (secondSep == -1) secondSep = length;
- }
- if (firstSep > 0) lang = locale.substring(0, firstSep);
- if (secondSep > firstSep + 1) country = locale.substring(firstSep + 1, secondSep);
- if (length > secondSep + 1) variant = locale.substring(secondSep + 1);
- }
-}
-
+public void setLocale(String locale) {
+ lang = country = variant = null;
+ if (locale != null) {
+ char sep = '_';
+ int length = locale.length();
+ int firstSep, secondSep;
+
+ firstSep = locale.indexOf(sep);
+ if (firstSep == -1) {
+ firstSep = secondSep = length;
+ } else {
+ secondSep = locale.indexOf(sep, firstSep + 1);
+ if (secondSep == -1) secondSep = length;
+ }
+ if (firstSep > 0) lang = locale.substring(0, firstSep);
+ if (secondSep > firstSep + 1) country = locale.substring(firstSep + 1, secondSep);
+ if (length > secondSep + 1) variant = locale.substring(secondSep + 1);
+ }
+}
+
/**
* Sets the style of the receiver to the argument which must
* be a bitwise OR of one or more of the <code>SWT</code>
@@ -352,11 +352,11 @@ public void setLocale(String locale) {
*
* @see #getStyle
*/
-public void setStyle(int style) {
- this.style = style;
- this.stem = null;
-}
-
+public void setStyle(int style) {
+ this.style = style;
+ this.stem = null;
+}
+
/**
* Returns a string representation of the receiver which is suitable
* for constructing an equivalent instance using the
@@ -366,21 +366,21 @@ public void setStyle(int style) {
*
* @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("PHOTON|1|");
- return buffer.toString();
-}
-
-public static FontData photon_new(byte[] stem) {
- return new FontData(stem);
-}
-
+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);
+}
+
}
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
index e51fb26cca..2f031d852a 100755
--- 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
@@ -1,14 +1,14 @@
-package org.eclipse.swt.graphics;
-
-/*
+package org.eclipse.swt.graphics;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-import org.eclipse.swt.internal.photon.*;
-
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+import org.eclipse.swt.internal.photon.*;
+
/**
* Instances of this class provide measurement information
* about fonts including ascent, descent, height, leading
@@ -18,18 +18,18 @@ import org.eclipse.swt.internal.photon.*;
*
* @see GC#getFontMetrics
*/
-public final class FontMetrics {
-
+public final class FontMetrics {
+
/**
* On Windows, handle is a Win32 TEXTMETRIC struct
* On Photon, handle is a Photon FontQueryInfo struct
* (Warning: This field is platform dependent)
*/
- public FontQueryInfo handle;
-
-FontMetrics() {
-}
-
+ public FontQueryInfo handle;
+
+FontMetrics() {
+}
+
/**
* Compares the argument to the receiver, and returns true
* if they represent the <em>same</em> object using a class
@@ -40,33 +40,33 @@ FontMetrics() {
*
* @see #hashCode
*/
-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.desc.length - 1; i >= 0; i--) {
- if (handle.desc[i] != info.desc[i]) return false;
- }
- for (int i = handle.font.length - 1; i >= 0; i--) {
- if (handle.font[i] != info.font[i]) return false;
- }
- return true;
- }
- return false;
-}
-
+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.desc.length - 1; i >= 0; i--) {
+ if (handle.desc[i] != info.desc[i]) return false;
+ }
+ for (int i = handle.font.length - 1; i >= 0; i--) {
+ if (handle.font[i] != info.font[i]) return false;
+ }
+ return true;
+ }
+ return false;
+}
+
/**
* Returns the ascent of the font described by the receiver. A
* font's <em>ascent</em> is the distance from the baseline to the
@@ -75,21 +75,21 @@ public boolean equals (Object object) {
*
* @return the ascent of the font
*/
-public int getAscent() {
- return -handle.ascender;
-}
-
+public int getAscent() {
+ return -handle.ascender;
+}
+
/**
* 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() {
- if ((handle.style & OS.PHFONT_INFO_FIXED) != 0) return handle.width;
- return handle.width / 3;
-}
-
+public int getAverageCharWidth() {
+ if ((handle.style & OS.PHFONT_INFO_FIXED) != 0) return handle.width;
+ return handle.width / 3;
+}
+
/**
* Returns the descent of the font described by the receiver. A
* font's <em>descent</em> is the distance from the baseline to the
@@ -98,10 +98,10 @@ public int getAverageCharWidth() {
*
* @return the descent of the font
*/
-public int getDescent() {
- return handle.descender;
-}
-
+public int getDescent() {
+ return handle.descender;
+}
+
/**
* Returns the height of the font described by the receiver,
* measured in pixels. A font's <em>height</em> is the sum of
@@ -113,10 +113,10 @@ public int getDescent() {
* @see #getDescent
* @see #getLeading
*/
-public int getHeight() {
- return -handle.ascender + handle.descender;
-}
-
+public int getHeight() {
+ return -handle.ascender + handle.descender;
+}
+
/**
* Returns the leading area of the font described by the
* receiver. A font's <em>leading area</em> is the space
@@ -124,10 +124,10 @@ public int getHeight() {
*
* @return the leading space of the font
*/
-public int getLeading() {
- return 0;
-}
-
+public int getLeading() {
+ return 0;
+}
+
/**
* Returns an integer hash code for the receiver. Any two
* objects which return <code>true</code> when passed to
@@ -138,17 +138,17 @@ public int getLeading() {
*
* @see #equals
*/
-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;
-}
+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;
+}
}
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
index f49d994520..50b6168d27 100755
--- 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
@@ -1,16 +1,16 @@
-package org.eclipse.swt.graphics;
-
-/*
+package org.eclipse.swt.graphics;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-import org.eclipse.swt.internal.*;
-import org.eclipse.swt.internal.photon.*;
-import org.eclipse.swt.*;
-
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+import org.eclipse.swt.internal.*;
+import org.eclipse.swt.internal.photon.*;
+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
@@ -25,41 +25,41 @@ import org.eclipse.swt.*;
*
* @see org.eclipse.swt.events.PaintEvent
*/
-public final class GC {
+public final class GC {
/**
* the handle to the OS device context
* (Warning: This field is platform dependent)
*/
- public int handle;
-
- Drawable drawable;
- GCData data;
-
- int dirtyBits;
-
- 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;
-
- static final int DIRTY_BACKGROUND = 1 << 0;
- static final int DIRTY_FOREGROUND = 1 << 1;
- static final int DIRTY_CLIPPING = 1 << 2;
- static final int DIRTY_FONT = 1 << 3;
- static final int DIRTY_LINESTYLE = 1 << 4;
- static final int DIRTY_LINEWIDTH = 1 << 5;
- static final int DIRTY_XORMODE = 1 << 6;
-
-GC() {
-}
-
+ public int handle;
+
+ Drawable drawable;
+ GCData data;
+
+ int dirtyBits;
+
+ 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;
+
+ static final int DIRTY_BACKGROUND = 1 << 0;
+ static final int DIRTY_FOREGROUND = 1 << 1;
+ static final int DIRTY_CLIPPING = 1 << 2;
+ static final int DIRTY_FONT = 1 << 3;
+ static final int DIRTY_LINESTYLE = 1 << 4;
+ static final int DIRTY_LINEWIDTH = 1 << 5;
+ static final int DIRTY_XORMODE = 1 << 6;
+
+GC() {
+}
+
/**
* Constructs a new instance of this class which has been
* configured to draw on the specified drawable. Sets the
@@ -81,23 +81,23 @@ GC() {
* <li>ERROR_NO_HANDLES if a handle could not be obtained for gc creation</li>
* </ul>
*/
-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 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);
+ }
+}
+
/**
* Copies a rectangular area of the receiver at the specified
* position into the image, which must be of type <code>SWT.BITMAP</code>.
@@ -113,67 +113,67 @@ public GC(Drawable drawable) {
* <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
* </ul>
*/
-public void copyArea(Image image, int x, int y) {
- if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- if (image == null) SWT.error (SWT.ERROR_NULL_ARGUMENT);
- if (image.type != SWT.BITMAP || image.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
- 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);
- int prevContext = 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);
- OS.PhDCSetCurrent(prevContext);
- 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(Image image, int x, int y) {
+ if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ if (image == null) SWT.error (SWT.ERROR_NULL_ARGUMENT);
+ if (image.type != SWT.BITMAP || image.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+ 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);
+ int prevContext = 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);
+ OS.PhDCSetCurrent(prevContext);
+ 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);
+ }
+}
+
/**
* Copies a rectangular area of the receiver at the source
* position onto the receiver at the destination position.
@@ -189,165 +189,165 @@ public void copyArea(Image image, int x, int y) {
* <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
* </ul>
*/
-public void copyArea(int x, int y, int width, int height, int destX, int destY) {
- if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- 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);
- int prevContext = 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);
- OS.PhDCSetCurrent(prevContext);
- 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) {
- 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;
- int child_clip = getClipping(widget, data.topWidget, true, true, null);
- if (clipRects == 0 && child_clip == 0) {
- OS.PtBlit(widget, rect, delta);
- } else {
- int srcTile = OS.PhGetTile();
- OS.memmove(srcTile, rect, PhRect_t.sizeof);
- int clip = child_clip;
- if (clipRects != 0) {
- clip = OS.PhRectsToTiles(clipRects, data.clipRectsCount);
- if (child_clip != 0) {
- short[] unused = new short[1];
- int newClip = OS.PhIntersectTilings(clip, child_clip, unused);
- OS.PhFreeTiles(child_clip);
- OS.PhFreeTiles(clip);
- clip = newClip;
- }
- }
- OS.PtClippedBlit(widget, srcTile, delta, clip);
- OS.PhFreeTiles(clip);
- }
- }
- } finally {
- if (flags >= 0) OS.PtLeave(flags);
- }
-}
-
+public void copyArea(int x, int y, int width, int height, int destX, int destY) {
+ if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ 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);
+ int prevContext = 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);
+ OS.PhDCSetCurrent(prevContext);
+ 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) {
+ 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;
+ int child_clip = getClipping(widget, data.topWidget, true, true, null);
+ if (clipRects == 0 && child_clip == 0) {
+ OS.PtBlit(widget, rect, delta);
+ } else {
+ int srcTile = OS.PhGetTile();
+ OS.memmove(srcTile, rect, PhRect_t.sizeof);
+ int clip = child_clip;
+ if (clipRects != 0) {
+ clip = OS.PhRectsToTiles(clipRects, data.clipRectsCount);
+ if (child_clip != 0) {
+ short[] unused = new short[1];
+ int newClip = OS.PhIntersectTilings(clip, child_clip, unused);
+ OS.PhFreeTiles(child_clip);
+ OS.PhFreeTiles(clip);
+ clip = newClip;
+ }
+ }
+ OS.PtClippedBlit(widget, srcTile, delta, clip);
+ OS.PhFreeTiles(clip);
+ }
+ }
+ } finally {
+ if (flags >= 0) OS.PtLeave(flags);
+ }
+}
+
/**
* Disposes of the operating system resources associated with
* the graphics context. Applications must dispose of all GCs
* which they allocate.
*/
-public void dispose() {
- int flags = OS.PtEnter(0);
- try {
- if (handle == 0) return;
- if (data.device.isDisposed()) return;
-
- int clipRects = data.clipRects;
- if (clipRects != 0) {
- OS.free(clipRects);
- data.clipRects = data.clipRectsCount = 0;
- }
- Image image = data.image;
- if (image != null) {
- flushImage();
- /* Regenerate the mask if necessary */
- if (image.transparentPixel != -1) {
- PhImage_t phImage = new PhImage_t ();
- OS.memmove(phImage, image.handle, PhImage_t.sizeof);
- if (phImage.mask_bm == 0) {
- createMask(image.handle, phImage.type, image.transparentPixel);
- }
- }
- 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 dispose() {
+ int flags = OS.PtEnter(0);
+ try {
+ if (handle == 0) return;
+ if (data.device.isDisposed()) return;
+
+ int clipRects = data.clipRects;
+ if (clipRects != 0) {
+ OS.free(clipRects);
+ data.clipRects = data.clipRectsCount = 0;
+ }
+ Image image = data.image;
+ if (image != null) {
+ flushImage();
+ /* Regenerate the mask if necessary */
+ if (image.transparentPixel != -1) {
+ PhImage_t phImage = new PhImage_t ();
+ OS.memmove(phImage, image.handle, PhImage_t.sizeof);
+ if (phImage.mask_bm == 0) {
+ createMask(image.handle, phImage.type, image.transparentPixel);
+ }
+ }
+ 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);
+ }
+}
+
/**
* Draws the outline of a circular or elliptical arc
* within the specified rectangular area.
@@ -380,65 +380,65 @@ public void dispose() {
* <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
* </ul>
*/
-public void drawArc (int x, int y, int width, int height, int startAngle, int endAngle) {
- if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- if (width < 0) {
- x = x + width;
- width = -width;
- }
- if (height < 0) {
- y = y + height;
- height = -height;
- }
- if (width == 0 || height == 0 || endAngle == 0) {
- SWT.error(SWT.ERROR_INVALID_ARGUMENT);
- }
- 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);
-
- 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 drawArc (int x, int y, int width, int height, int startAngle, int endAngle) {
+ if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ if (width < 0) {
+ x = x + width;
+ width = -width;
+ }
+ if (height < 0) {
+ y = y + height;
+ height = -height;
+ }
+ if (width == 0 || height == 0 || endAngle == 0) {
+ SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+ }
+ 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);
+
+ 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);
+ }
+}
+
/**
* Draws a rectangle, based on the specified arguments, which has
* the appearance of the platform's <em>focus rectangle</em> if the
@@ -456,23 +456,23 @@ public void drawArc (int x, int y, int width, int height, int startAngle, int en
*
* @see #drawRectangle
*/
-public void drawFocus (int x, int y, int width, int height) {
- if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- int flags = OS.PtEnter(0);
- try {
- int prevContext = setGC();
- setGCClipping();
- if (width < 0) width -= width;
- if (height < 0) height -= height;
- OS.PgSetStrokeColor(0x9098F8);
- OS.PgDrawIRect(x, y, x + width - 1, y + height - 1, OS.Pg_DRAW_STROKE);
- OS.PgSetStrokeColor(data.foreground);
- unsetGC(prevContext);
- } finally {
- if (flags >= 0) OS.PtLeave(flags);
- }
-}
-
+public void drawFocus (int x, int y, int width, int height) {
+ if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ int flags = OS.PtEnter(0);
+ try {
+ int prevContext = setGC();
+ setGCClipping();
+ if (width < 0) width -= width;
+ if (height < 0) height -= height;
+ OS.PgSetStrokeColor(0x9098F8);
+ OS.PgDrawIRect(x, y, x + width - 1, y + height - 1, OS.Pg_DRAW_STROKE);
+ OS.PgSetStrokeColor(data.foreground);
+ unsetGC(prevContext);
+ } finally {
+ if (flags >= 0) OS.PtLeave(flags);
+ }
+}
+
/**
* Draws the given image in the receiver at the specified
* coordinates.
@@ -492,379 +492,379 @@ public void drawFocus (int x, int y, int width, int height) {
* <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
* </ul>
*/
-public void drawImage(Image image, int x, int y) {
- if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- if (image == null) SWT.error (SWT.ERROR_NULL_ARGUMENT);
- if (image.isDisposed()) SWT.error (SWT.ERROR_INVALID_ARGUMENT);
- drawImage(image, 0, 0, -1, -1, x, y, -1, -1, true);
-}
-
-/**
- * Copies a rectangular area from the source image into a (potentially
- * different sized) rectangular area in the receiver. If the source
- * and destination areas are of differing sizes, then the source
- * area will be stretched or shrunk to fit the destination area
- * as it is copied. The copy fails if any part of the source rectangle
- * lies outside the bounds of the source image, or if any of the width
- * or height arguments are negative.
- *
- * @param image the source image
- * @param srcX the x coordinate in the source image to copy from
- * @param srcY the y coordinate in the source image to copy from
- * @param srcWidth the width in pixels to copy from the source
- * @param srcHeight the height in pixels to copy from the source
- * @param destX the x coordinate in the destination to copy to
- * @param destY the y coordinate in the destination to copy to
- * @param destWidth the width in pixels of the destination rectangle
- * @param destHeight the height in pixels of the destination rectangle
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the image is null</li>
- * <li>ERROR_INVALID_ARGUMENT - if the image has been disposed</li>
- * <li>ERROR_INVALID_ARGUMENT - if any of the width or height arguments are negative.
- * <li>ERROR_INVALID_ARGUMENT - if the source rectangle is not contained within the bounds of the source image</li>
- * </ul>
- * @exception SWTError <ul>
- * <li>ERROR_NO_HANDLES - if no handles are available to perform the operation</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
- * </ul>
+public void drawImage(Image image, int x, int y) {
+ if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ if (image == null) SWT.error (SWT.ERROR_NULL_ARGUMENT);
+ if (image.isDisposed()) SWT.error (SWT.ERROR_INVALID_ARGUMENT);
+ drawImage(image, 0, 0, -1, -1, x, y, -1, -1, true);
+}
+
+/**
+ * Copies a rectangular area from the source image into a (potentially
+ * different sized) rectangular area in the receiver. If the source
+ * and destination areas are of differing sizes, then the source
+ * area will be stretched or shrunk to fit the destination area
+ * as it is copied. The copy fails if any part of the source rectangle
+ * lies outside the bounds of the source image, or if any of the width
+ * or height arguments are negative.
+ *
+ * @param image the source image
+ * @param srcX the x coordinate in the source image to copy from
+ * @param srcY the y coordinate in the source image to copy from
+ * @param srcWidth the width in pixels to copy from the source
+ * @param srcHeight the height in pixels to copy from the source
+ * @param destX the x coordinate in the destination to copy to
+ * @param destY the y coordinate in the destination to copy to
+ * @param destWidth the width in pixels of the destination rectangle
+ * @param destHeight the height in pixels of the destination rectangle
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if the image is null</li>
+ * <li>ERROR_INVALID_ARGUMENT - if the image has been disposed</li>
+ * <li>ERROR_INVALID_ARGUMENT - if any of the width or height arguments are negative.
+ * <li>ERROR_INVALID_ARGUMENT - if the source rectangle is not contained within the bounds of the source image</li>
+ * </ul>
+ * @exception SWTError <ul>
+ * <li>ERROR_NO_HANDLES - if no handles are available to perform the operation</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
*/
-public void drawImage(Image image, int srcX, int srcY, int srcWidth, int srcHeight, int destX, int destY, int destWidth, int destHeight) {
- if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- if (srcWidth == 0 || srcHeight == 0 || destWidth == 0 || destHeight == 0) return;
- if (srcX < 0 || srcY < 0 || srcWidth < 0 || srcHeight < 0 || destWidth < 0 || destHeight < 0) {
- SWT.error (SWT.ERROR_INVALID_ARGUMENT);
- }
- if (image == null) SWT.error (SWT.ERROR_NULL_ARGUMENT);
- if (image.isDisposed()) SWT.error (SWT.ERROR_INVALID_ARGUMENT);
- drawImage(image, srcX, srcY, srcWidth, srcHeight, destX, destY, destWidth, destHeight, false);
-}
-void drawImage(Image 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 {
- if (image.memGC != null) image.memGC.flushImage();
- int drawImage = image.handle;
- 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);
- }
- int prevContext = 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);
- OS.PhDCSetCurrent(prevContext);
-
- 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);
- }
- prevContext = 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.PhDCSetCurrent(prevContext);
- 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) {
- OS.free(palettePtr);
- OS.free(alphaPtr);
- Image.destroyImage(memImage);
- SWT.error(SWT.ERROR_NO_HANDLES);
- }
- mc = OS.PmMemCreateMC(alphaImage, scale, trans);
- if (mc == 0) {
- OS.free(palettePtr);
- OS.free(alphaPtr);
- Image.destroyImage(alphaImage);
- Image.destroyImage(memImage);
- SWT.error(SWT.ERROR_NO_HANDLES);
- }
- prevContext = 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.PhDCSetCurrent(prevContext);
- 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_bpl = (short)phAlphaImage.bpl;
- 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);
- }
-
- OS.memmove(alphaPtr, alpha, PgAlpha_t.sizeof);
- phMemImage.alpha = alphaPtr;
- OS.memmove(memImage, phMemImage, PhImage_t.sizeof);
- }
- return memImage;
-}
-
+public void drawImage(Image image, int srcX, int srcY, int srcWidth, int srcHeight, int destX, int destY, int destWidth, int destHeight) {
+ if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ if (srcWidth == 0 || srcHeight == 0 || destWidth == 0 || destHeight == 0) return;
+ if (srcX < 0 || srcY < 0 || srcWidth < 0 || srcHeight < 0 || destWidth < 0 || destHeight < 0) {
+ SWT.error (SWT.ERROR_INVALID_ARGUMENT);
+ }
+ if (image == null) SWT.error (SWT.ERROR_NULL_ARGUMENT);
+ if (image.isDisposed()) SWT.error (SWT.ERROR_INVALID_ARGUMENT);
+ drawImage(image, srcX, srcY, srcWidth, srcHeight, destX, destY, destWidth, destHeight, false);
+}
+void drawImage(Image 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 {
+ if (image.memGC != null) image.memGC.flushImage();
+ int drawImage = image.handle;
+ 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);
+ }
+ int prevContext = 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);
+ OS.PhDCSetCurrent(prevContext);
+
+ 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);
+ }
+ prevContext = 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.PhDCSetCurrent(prevContext);
+ 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) {
+ OS.free(palettePtr);
+ OS.free(alphaPtr);
+ Image.destroyImage(memImage);
+ SWT.error(SWT.ERROR_NO_HANDLES);
+ }
+ mc = OS.PmMemCreateMC(alphaImage, scale, trans);
+ if (mc == 0) {
+ OS.free(palettePtr);
+ OS.free(alphaPtr);
+ Image.destroyImage(alphaImage);
+ Image.destroyImage(memImage);
+ SWT.error(SWT.ERROR_NO_HANDLES);
+ }
+ prevContext = 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.PhDCSetCurrent(prevContext);
+ 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_bpl = (short)phAlphaImage.bpl;
+ 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);
+ }
+
+ OS.memmove(alphaPtr, alpha, PgAlpha_t.sizeof);
+ phMemImage.alpha = alphaPtr;
+ OS.memmove(memImage, phMemImage, PhImage_t.sizeof);
+ }
+ return memImage;
+}
+
/**
* Draws a line, using the foreground color, between the points
* (<code>x1</code>, <code>y1</code>) and (<code>x2</code>, <code>y2</code>).
@@ -878,19 +878,19 @@ static int scaleImage(Image image, PhImage_t phImage, int srcX, int srcY, int sr
* <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
* </ul>
*/
-public void drawLine (int x1, int y1, int x2, int y2) {
- if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- 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 drawLine (int x1, int y1, int x2, int y2) {
+ if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ 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);
+ }
+}
+
/**
* Draws the outline of an oval, using the foreground color,
* within the specified rectangular area.
@@ -912,25 +912,25 @@ public void drawLine (int x1, int y1, int x2, int y2) {
* <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
* </ul>
*/
-public void drawOval (int x, int y, int width, int height) {
- if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- 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 drawOval (int x, int y, int width, int height) {
+ if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ 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);
+ }
+}
+
/**
* Draws the closed polygon which is defined by the specified array
* of integer coordinates, using the receiver's foreground color. The array
@@ -948,26 +948,26 @@ public void drawOval (int x, int y, int width, int height) {
* <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
* </ul>
*/
-public void drawPolygon(int[] pointArray) {
- if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- if (pointArray == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
-
- 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 drawPolygon(int[] pointArray) {
+ if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ 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);
+ }
+}
+
/**
* Draws the polyline which is defined by the specified array
* of integer coordinates, using the receiver's foreground color. The array
@@ -985,26 +985,26 @@ public void drawPolygon(int[] pointArray) {
* <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
* </ul>
*/
-public void drawPolyline(int[] pointArray) {
- if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- if (pointArray == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
-
- 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);
- unsetGC(prevContext);
- } finally {
- if (flags >= 0) OS.PtLeave(flags);
- }
-}
-
+public void drawPolyline(int[] pointArray) {
+ if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ 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);
+ unsetGC(prevContext);
+ } finally {
+ if (flags >= 0) OS.PtLeave(flags);
+ }
+}
+
/**
* Draws the outline of the rectangle specified by the arguments,
* using the receiver's foreground color. The left and right edges
@@ -1020,20 +1020,20 @@ public void drawPolyline(int[] pointArray) {
* <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
* </ul>
*/
-public void drawRectangle (int x, int y, int width, int height) {
- if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- 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 (int x, int y, int width, int height) {
+ if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ 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);
+ }
+}
+
/**
* Draws the outline of the specified rectangle, using the receiver's
* foreground color. The left and right edges of the rectangle are at
@@ -1050,11 +1050,11 @@ public void drawRectangle (int x, int y, int width, int height) {
* <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
* </ul>
*/
-public void drawRectangle (Rectangle rect) {
- if (rect == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
- drawRectangle (rect.x, rect.y, rect.width, rect.height);
-}
-
+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
@@ -1074,26 +1074,26 @@ public void drawRectangle (Rectangle rect) {
* <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
* </ul>
*/
-public void drawRoundRectangle (int x, int y, int width, int height, int arcWidth, int arcHeight) {
- if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- 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 drawRoundRectangle (int x, int y, int width, int height, int arcWidth, int arcHeight) {
+ if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ 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);
+ }
+}
+
/**
* Draws the given string, using the receiver's current font and
* foreground color. No tab expansion or carriage return processing
@@ -1112,10 +1112,10 @@ public void drawRoundRectangle (int x, int y, int width, int height, int arcWidt
* <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
* </ul>
*/
-public void drawString (String string, int x, int y) {
- drawString(string, x, y, false);
-}
-
+public void drawString (String string, int x, int y) {
+ drawString(string, x, y, false);
+}
+
/**
* Draws the given string, using the receiver's current font and
* foreground color. No tab expansion or carriage return processing
@@ -1136,25 +1136,25 @@ public void drawString (String string, int x, int y) {
* <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
* </ul>
*/
-public void drawString (String string, int x, int y, boolean isTransparent) {
- if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- 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 drawString (String string, int x, int y, boolean isTransparent) {
+ if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ 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);
+ }
+}
+
/**
* Draws the given string, using the receiver's current font and
* foreground color. Tab expansion and carriage return processing
@@ -1173,10 +1173,10 @@ public void drawString (String string, int x, int y, boolean isTransparent) {
* <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
* </ul>
*/
-public void drawText (String string, int x, int y) {
- drawText(string, x, y, SWT.DRAW_DELIMITER | SWT.DRAW_TAB);
-}
-
+public void drawText (String string, int x, int y) {
+ drawText(string, x, y, SWT.DRAW_DELIMITER | SWT.DRAW_TAB);
+}
+
/**
* Draws the given string, using the receiver's current font and
* foreground color. Tab expansion and carriage return processing
@@ -1197,136 +1197,136 @@ public void drawText (String string, int x, int y) {
* <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
* </ul>
*/
-public void drawText (String string, int x, int y, boolean isTransparent) {
- int flags = SWT.DRAW_DELIMITER | SWT.DRAW_TAB;
- if (isTransparent) flags |= SWT.DRAW_TRANSPARENT;
- drawText(string, x, y, flags);
-}
-
-/**
- * Draws the given string, using the receiver's current font and
- * foreground color. Tab expansion, line delimiter and mnemonic
- * processing are performed according to the specified flags. If
- * <code>flags</code> includes <code>DRAW_TRANSPARENT</code>,
- * then the background of the rectangular area where the text is being
- * drawn will not be modified, otherwise it will be filled with the
- * receiver's background color.
- * <p>
- * The parameter <code>flags</code> may be a combination of:
- * <dl>
- * <dt><b>DRAW_DELIMITER</b></dt>
- * <dd>draw multiple lines</dd>
- * <dt><b>DRAW_TAB</b></dt>
- * <dd>expand tabs</dd>
- * <dt><b>DRAW_MNEMONIC</b></dt>
- * <dd>underline the mnemonic character</dd>
- * <dt><b>DRAW_TRANSPARENT</b></dt>
- * <dd>transparent background</dd>
- * </dl>
- * </p>
- *
- * @param string the string to be drawn
- * @param x the x coordinate of the top left corner of the rectangular area where the text is to be drawn
- * @param y the y coordinate of the top left corner of the rectangular area where the text is to be drawn
- * @param flags the flags specifing how to process the text
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the string is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
- * </ul>
+public void drawText (String string, int x, int y, boolean isTransparent) {
+ int flags = SWT.DRAW_DELIMITER | SWT.DRAW_TAB;
+ if (isTransparent) flags |= SWT.DRAW_TRANSPARENT;
+ drawText(string, x, y, flags);
+}
+
+/**
+ * Draws the given string, using the receiver's current font and
+ * foreground color. Tab expansion, line delimiter and mnemonic
+ * processing are performed according to the specified flags. If
+ * <code>flags</code> includes <code>DRAW_TRANSPARENT</code>,
+ * then the background of the rectangular area where the text is being
+ * drawn will not be modified, otherwise it will be filled with the
+ * receiver's background color.
+ * <p>
+ * The parameter <code>flags</code> may be a combination of:
+ * <dl>
+ * <dt><b>DRAW_DELIMITER</b></dt>
+ * <dd>draw multiple lines</dd>
+ * <dt><b>DRAW_TAB</b></dt>
+ * <dd>expand tabs</dd>
+ * <dt><b>DRAW_MNEMONIC</b></dt>
+ * <dd>underline the mnemonic character</dd>
+ * <dt><b>DRAW_TRANSPARENT</b></dt>
+ * <dd>transparent background</dd>
+ * </dl>
+ * </p>
+ *
+ * @param string the string to be drawn
+ * @param x the x coordinate of the top left corner of the rectangular area where the text is to be drawn
+ * @param y the y coordinate of the top left corner of the rectangular area where the text is to be drawn
+ * @param flags the flags specifing how to process the text
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if the string is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
*/
-public void drawText (String string, int x, int y, int flags) {
- if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- if (string == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
- if ((flags & ~SWT.DRAW_TRANSPARENT) == 0) {
- drawString(string, x, y, (flags & SWT.DRAW_TRANSPARENT) != 0);
- } else {
- drawText(string, x, y, flags, true);
- }
-}
-
-Point drawText(String text, int x, int y, int flags, boolean draw) {
- /* NOT DONE - inline code for performance */
-
- int length = text.length();
- char[] buffer = new char[length];
- text.getChars(0, length, buffer, 0);
-
- /* NOT DONE - tabstops */
- int spaceWidth = stringExtent(" ").x;
- int tabWidth = spaceWidth *8 + 1;
-
- boolean transparent = (flags & SWT.DRAW_TRANSPARENT) != 0;
- int mnemonic = -1;
- int start = 0, i = 0, j = 0;
- int initialX = x, initialY = y;
- int maxX = x, maxY = y;
- while (i < length) {
- char c = buffer[j] = buffer[i];
- switch (c) {
- case '\t': {
- if ((flags & SWT.DRAW_TAB) == 0) break;
- String string = new String(buffer, start, j - start);
- if (draw) drawString(string, x, y, transparent);
- Point extent = stringExtent(string);
- x += extent.x + tabWidth;
- maxX = Math.max(x, maxX);
- maxY = Math.max(y + extent.y, maxY);
- start = j + 1;
- break;
- }
- case '\n': {
- if ((flags & SWT.DRAW_DELIMITER) == 0) break;
- String string = new String(buffer, start, j - start);
- if (draw) drawString(string, x, y, transparent);
- Point extent = stringExtent(string);
- maxX = Math.max(x + extent.x, maxX);
- x = initialX;
- y += extent.y;
- maxY = Math.max(y, maxY);
- start = j + 1;
- break;
- }
- case '&': {
- if ((flags & SWT.DRAW_MNEMONIC) == 0) break;
- if (i + 1 == length) break;
- if (buffer[i + 1] == '&') {i++; break;}
- if (mnemonic == -1) {
- mnemonic = i + 1;
- String string = new String(buffer, start, j - start);
- if (draw) drawString(string, x, y, transparent);
- Point extent = stringExtent(string);
- x += extent.x;
- start = mnemonic;
- string = new String(buffer, start, 1);
- if (draw) drawString(string, x, y, transparent);
- extent = stringExtent(string);
- int underlineY = y + extent.y - 1;
- if (draw) drawLine(x, underlineY, x + extent.x, underlineY);
- x += extent.x;
- maxX = Math.max(x, maxX);
- maxY = Math.max(y + extent.y, maxY);
- start = j + 1;
- }
- j--;
- break;
- }
- }
- j++;
- i++;
- }
- if (start != j) {
- String string = new String(buffer, start, j - start);
- if (draw) drawString(string, x, y, transparent);
- Point extent = stringExtent(string);
- maxX = Math.max(x + extent.x, maxX);
- maxY = Math.max(y + extent.y, maxY);
- }
- return new Point(maxX - initialX, maxY - initialY);
-}
-
+public void drawText (String string, int x, int y, int flags) {
+ if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ if (string == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ if ((flags & ~SWT.DRAW_TRANSPARENT) == 0) {
+ drawString(string, x, y, (flags & SWT.DRAW_TRANSPARENT) != 0);
+ } else {
+ drawText(string, x, y, flags, true);
+ }
+}
+
+Point drawText(String text, int x, int y, int flags, boolean draw) {
+ /* NOT DONE - inline code for performance */
+
+ int length = text.length();
+ char[] buffer = new char[length];
+ text.getChars(0, length, buffer, 0);
+
+ /* NOT DONE - tabstops */
+ int spaceWidth = stringExtent(" ").x;
+ int tabWidth = spaceWidth *8 + 1;
+
+ boolean transparent = (flags & SWT.DRAW_TRANSPARENT) != 0;
+ int mnemonic = -1;
+ int start = 0, i = 0, j = 0;
+ int initialX = x, initialY = y;
+ int maxX = x, maxY = y;
+ while (i < length) {
+ char c = buffer[j] = buffer[i];
+ switch (c) {
+ case '\t': {
+ if ((flags & SWT.DRAW_TAB) == 0) break;
+ String string = new String(buffer, start, j - start);
+ if (draw) drawString(string, x, y, transparent);
+ Point extent = stringExtent(string);
+ x += extent.x + tabWidth;
+ maxX = Math.max(x, maxX);
+ maxY = Math.max(y + extent.y, maxY);
+ start = j + 1;
+ break;
+ }
+ case '\n': {
+ if ((flags & SWT.DRAW_DELIMITER) == 0) break;
+ String string = new String(buffer, start, j - start);
+ if (draw) drawString(string, x, y, transparent);
+ Point extent = stringExtent(string);
+ maxX = Math.max(x + extent.x, maxX);
+ x = initialX;
+ y += extent.y;
+ maxY = Math.max(y, maxY);
+ start = j + 1;
+ break;
+ }
+ case '&': {
+ if ((flags & SWT.DRAW_MNEMONIC) == 0) break;
+ if (i + 1 == length) break;
+ if (buffer[i + 1] == '&') {i++; break;}
+ if (mnemonic == -1) {
+ mnemonic = i + 1;
+ String string = new String(buffer, start, j - start);
+ if (draw) drawString(string, x, y, transparent);
+ Point extent = stringExtent(string);
+ x += extent.x;
+ start = mnemonic;
+ string = new String(buffer, start, 1);
+ if (draw) drawString(string, x, y, transparent);
+ extent = stringExtent(string);
+ int underlineY = y + extent.y - 1;
+ if (draw) drawLine(x, underlineY, x + extent.x, underlineY);
+ x += extent.x;
+ maxX = Math.max(x, maxX);
+ maxY = Math.max(y + extent.y, maxY);
+ start = j + 1;
+ }
+ j--;
+ break;
+ }
+ }
+ j++;
+ i++;
+ }
+ if (start != j) {
+ String string = new String(buffer, start, j - start);
+ if (draw) drawString(string, x, y, transparent);
+ Point extent = stringExtent(string);
+ maxX = Math.max(x + extent.x, maxX);
+ maxY = Math.max(y + extent.y, maxY);
+ }
+ return new Point(maxX - initialX, maxY - initialY);
+}
+
/**
* Compares the argument to the receiver, and returns true
* if they represent the <em>same</em> object using a class
@@ -1337,10 +1337,10 @@ Point drawText(String text, int x, int y, int flags, boolean draw) {
*
* @see #hashCode
*/
-public boolean equals (Object object) {
- return (object == this) || ((object instanceof GC) && (handle == ((GC)object).handle));
-}
-
+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
@@ -1376,123 +1376,123 @@ public boolean equals (Object object) {
*
* @see #drawArc
*/
-public void fillArc (int x, int y, int width, int height, int startAngle, int endAngle) {
- if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- if (width < 0) {
- x = x + width;
- width = -width;
- }
- if (height < 0) {
- y = y + height;
- height = -height;
- }
- if (width == 0 || height == 0 || endAngle == 0) {
- SWT.error(SWT.ERROR_INVALID_ARGUMENT);
- }
- 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);
-
- 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);
- }
-}
-
-/**
- * Fills the interior of the specified rectangle with a gradient
- * sweeping from left to right or top to bottom progressing
- * from the receiver's foreground color to its background color.
- *
- * @param x the x coordinate of the rectangle to be filled
- * @param y the y coordinate of the rectangle to be filled
- * @param width the width of the rectangle to be filled, may be negative
- * (inverts direction of gradient if horizontal)
- * @param height the height of the rectangle to be filled, may be negative
- * (inverts direction of gradient if vertical)
- * @param vertical if true sweeps from top to bottom, else
- * sweeps from left to right
- *
- * @exception SWTException <ul>
- * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
- * </ul>
- *
- * @see #drawRectangle
+public void fillArc (int x, int y, int width, int height, int startAngle, int endAngle) {
+ if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ if (width < 0) {
+ x = x + width;
+ width = -width;
+ }
+ if (height < 0) {
+ y = y + height;
+ height = -height;
+ }
+ if (width == 0 || height == 0 || endAngle == 0) {
+ SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+ }
+ 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);
+
+ 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);
+ }
+}
+
+/**
+ * Fills the interior of the specified rectangle with a gradient
+ * sweeping from left to right or top to bottom progressing
+ * from the receiver's foreground color to its background color.
+ *
+ * @param x the x coordinate of the rectangle to be filled
+ * @param y the y coordinate of the rectangle to be filled
+ * @param width the width of the rectangle to be filled, may be negative
+ * (inverts direction of gradient if horizontal)
+ * @param height the height of the rectangle to be filled, may be negative
+ * (inverts direction of gradient if vertical)
+ * @param vertical if true sweeps from top to bottom, else
+ * sweeps from left to right
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ *
+ * @see #drawRectangle
*/
-public void fillGradientRectangle(int x, int y, int width, int height, boolean vertical) {
- if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- if ((width == 0) || (height == 0)) return;
- int fromColor = data.foreground;
- int toColor = data.background;
- boolean swapColors = false;
- if (width < 0) {
- x += width; width = -width;
- if (! vertical) swapColors = true;
- }
- if (height < 0) {
- y += height; height = -height;
- if (vertical) swapColors = true;
- }
- if (swapColors) {
- final int t = toColor;
- toColor = fromColor;
- fromColor = t;
- }
- PhPoint_t upperLeft = new PhPoint_t();
- upperLeft.x = (short)x;
- upperLeft.y = (short)y;
- PhPoint_t lowerRight = new PhPoint_t();
- lowerRight.x = (short)(x + width - 1);
- lowerRight.y = (short)(y + height - 1);
- int flags = OS.PtEnter(0);
- try {
- int prevContext = setGC();
- setGCClipping();
- OS.PgDrawGradient(upperLeft, lowerRight,
- vertical ? OS.Pg_GRAD_VERTICAL : OS.Pg_GRAD_HORIZONTAL, OS.Pg_GRAD_LINEAR,
- vertical ? height : width, fromColor, toColor, 0, 0, 0, null);
- unsetGC(prevContext);
- } finally {
- if (flags >= 0) OS.PtLeave(flags);
- }
-}
-
+public void fillGradientRectangle(int x, int y, int width, int height, boolean vertical) {
+ if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ if ((width == 0) || (height == 0)) return;
+ int fromColor = data.foreground;
+ int toColor = data.background;
+ boolean swapColors = false;
+ if (width < 0) {
+ x += width; width = -width;
+ if (! vertical) swapColors = true;
+ }
+ if (height < 0) {
+ y += height; height = -height;
+ if (vertical) swapColors = true;
+ }
+ if (swapColors) {
+ final int t = toColor;
+ toColor = fromColor;
+ fromColor = t;
+ }
+ PhPoint_t upperLeft = new PhPoint_t();
+ upperLeft.x = (short)x;
+ upperLeft.y = (short)y;
+ PhPoint_t lowerRight = new PhPoint_t();
+ lowerRight.x = (short)(x + width - 1);
+ lowerRight.y = (short)(y + height - 1);
+ int flags = OS.PtEnter(0);
+ try {
+ int prevContext = setGC();
+ setGCClipping();
+ OS.PgDrawGradient(upperLeft, lowerRight,
+ vertical ? OS.Pg_GRAD_VERTICAL : OS.Pg_GRAD_HORIZONTAL, OS.Pg_GRAD_LINEAR,
+ vertical ? height : width, fromColor, toColor, 0, 0, 0, null);
+ unsetGC(prevContext);
+ } finally {
+ if (flags >= 0) OS.PtLeave(flags);
+ }
+}
+
/**
* Fills the interior of an oval, within the specified
* rectangular area, with the receiver's background
@@ -1509,25 +1509,25 @@ public void fillGradientRectangle(int x, int y, int width, int height, boolean v
*
* @see #drawOval
*/
-public void fillOval (int x, int y, int width, int height) {
- if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- 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);
- radii.y = (short)(y + height);
-
- 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 fillOval (int x, int y, int width, int height) {
+ if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ 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);
+ radii.y = (short)(y + height);
+
+ 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);
+ }
+}
+
/**
* Fills the interior of the closed polygon which is defined by the
* specified array of integer coordinates, using the receiver's
@@ -1547,26 +1547,26 @@ public void fillOval (int x, int y, int width, int height) {
*
* @see #drawPolygon
*/
-public void fillPolygon(int[] pointArray) {
- if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- if (pointArray == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
-
- 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 fillPolygon(int[] pointArray) {
+ if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ 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);
+ }
+}
+
/**
* Fills the interior of the rectangle specified by the arguments,
* using the receiver's background color.
@@ -1582,20 +1582,20 @@ public void fillPolygon(int[] pointArray) {
*
* @see #drawRectangle
*/
-public void fillRectangle (int x, int y, int width, int height) {
- if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- 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 (int x, int y, int width, int height) {
+ if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ 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);
+ }
+}
+
/**
* Fills the interior of the specified rectangle, using the receiver's
* background color.
@@ -1611,11 +1611,11 @@ public void fillRectangle (int x, int y, int width, int height) {
*
* @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);
-}
-
+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.
@@ -1633,37 +1633,37 @@ public void fillRectangle (Rectangle rect) {
*
* @see #drawRoundRectangle
*/
-public void fillRoundRectangle (int x, int y, int width, int height, int arcWidth, int arcHeight) {
- if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- 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);
- }
-}
-
-/**
- * Force outstanding drawing commands to be processed.
+public void fillRoundRectangle (int x, int y, int width, int height, int arcWidth, int arcHeight) {
+ if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_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);
+ 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);
+ }
+}
+
+/**
+ * Force outstanding drawing commands to be processed.
*/
-void flushImage () {
- Image image = data.image;
- if (image == null) return;
- int prevContext = OS.PmMemStart(handle);
- OS.PmMemFlush(handle, image.handle);
- OS.PmMemStop(handle);
- OS.PhDCSetCurrent(prevContext);
-}
-
+void flushImage () {
+ Image image = data.image;
+ if (image == null) return;
+ int prevContext = OS.PmMemStart(handle);
+ OS.PmMemFlush(handle, image.handle);
+ OS.PmMemStop(handle);
+ OS.PhDCSetCurrent(prevContext);
+}
+
/**
* Returns the <em>advance width</em> of the specified character in
* the font which is currently selected into the receiver.
@@ -1679,10 +1679,10 @@ void flushImage () {
* <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
* </ul>
*/
-public int getAdvanceWidth(char ch) {
- return getCharWidth(ch);
-}
-
+public int getAdvanceWidth(char ch) {
+ return getCharWidth(ch);
+}
+
/**
* Returns the background color.
*
@@ -1692,11 +1692,11 @@ public int getAdvanceWidth(char ch) {
* <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
* </ul>
*/
-public Color getBackground() {
- if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- return Color.photon_new(data.device, data.background);
-}
-
+public Color getBackground() {
+ if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ return Color.photon_new(data.device, data.background);
+}
+
/**
* Returns the width of the specified character in the font
* selected into the receiver.
@@ -1713,13 +1713,13 @@ public Color getBackground() {
* <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
* </ul>
*/
-public int getCharWidth(char ch) {
- if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- String string = new String(new char[] {ch});
- Point point = stringExtent(string);
- return point.x;
-}
-
+public int getCharWidth(char ch) {
+ if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ String string = new String(new char[] {ch});
+ Point point = stringExtent(string);
+ return point.x;
+}
+
/**
* Returns the bounding rectangle of the receiver's clipping
* region. If no clipping region is set, the return value
@@ -1732,48 +1732,48 @@ public int getCharWidth(char ch) {
* <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
* </ul>
*/
-public Rectangle getClipping() {
- if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- 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 * PhRect_t.sizeof));
- }
- 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 Rectangle getClipping() {
+ if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ 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 * PhRect_t.sizeof));
+ }
+ 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);
+ }
+}
+
/**
* Sets the region managed by the argument to the current
* clipping region of the receiver.
@@ -1787,40 +1787,40 @@ public Rectangle getClipping() {
* <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
* </ul>
*/
-public void getClipping (Region region) {
- if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- if (region == null) SWT.error (SWT.ERROR_NULL_ARGUMENT);
- 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 void getClipping (Region region) {
+ if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ 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);
+ }
+}
+
/**
* Returns the font currently being used by the receiver
* to draw and measure text.
@@ -1831,11 +1831,11 @@ public void getClipping (Region region) {
* <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
* </ul>
*/
-public Font getFont () {
- if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- return Font.photon_new(data.device, data.font);
-}
-
+public Font getFont () {
+ if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ return Font.photon_new(data.device, data.font);
+}
+
/**
* Returns a FontMetrics which contains information
* about the font currently being used by the receiver
@@ -1847,13 +1847,13 @@ public Font getFont () {
* <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
* </ul>
*/
-public FontMetrics getFontMetrics() {
- if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- FontQueryInfo info = new FontQueryInfo();
- OS.PfQueryFontInfo(data.font, info);
- return FontMetrics.photon_new(info);
-}
-
+public FontMetrics getFontMetrics() {
+ if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ FontQueryInfo info = new FontQueryInfo();
+ OS.PfQueryFontInfo(data.font, info);
+ return FontMetrics.photon_new(info);
+}
+
/**
* Returns the receiver's foreground color.
*
@@ -1863,11 +1863,11 @@ public FontMetrics getFontMetrics() {
* <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
* </ul>
*/
-public Color getForeground() {
- if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- return Color.photon_new(data.device, data.foreground);
-}
-
+public Color getForeground() {
+ if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ return Color.photon_new(data.device, data.foreground);
+}
+
/**
* Returns the receiver's line style, which will be one
* of the constants <code>SWT.LINE_SOLID</code>, <code>SWT.LINE_DASH</code>,
@@ -1880,11 +1880,11 @@ public Color getForeground() {
* <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
* </ul>
*/
-public int getLineStyle() {
- if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- return data.lineStyle;
-}
-
+public int getLineStyle() {
+ if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ return data.lineStyle;
+}
+
/**
* Returns the width that will be used when drawing lines
* for all of the figure drawing operations (that is,
@@ -1897,11 +1897,11 @@ public int getLineStyle() {
* <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
* </ul>
*/
-public int getLineWidth() {
- if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- return data.lineWidth;
-}
-
+public int getLineWidth() {
+ if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ return data.lineWidth;
+}
+
/**
* Returns <code>true</code> if this GC is drawing in the mode
* where the resulting color in the destination is the
@@ -1916,11 +1916,11 @@ public int getLineWidth() {
* <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
* </ul>
*/
-public boolean getXORMode() {
- if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- return data.xorMode;
-}
-
+public boolean getXORMode() {
+ if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ return data.xorMode;
+}
+
/**
* Returns an integer hash code for the receiver. Any two
* objects which return <code>true</code> when passed to
@@ -1935,44 +1935,44 @@ public boolean getXORMode() {
*
* @see #equals
*/
-public int hashCode () {
- return handle;
-}
-
-void init(Drawable drawable, GCData data, int context) {
- if (data.foreground == -1) data.foreground = DefaultFore;
- if (data.background == -1) data.background = DefaultBack;
- if (data.font == null) data.font = data.device.systemFont;
- dirtyBits = DIRTY_FOREGROUND | DIRTY_BACKGROUND | DIRTY_FONT;
-
- Image image = data.image;
- if (image != null) {
- image.memGC = this;
- int prevContext = OS.PmMemStart(context);
- OS.PgSetDrawBufferSize(DrawBufferSize);
- OS.PmMemStop(context);
- OS.PhDCSetCurrent(prevContext);
-
- /*
- * 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 int hashCode () {
+ return handle;
+}
+
+void init(Drawable drawable, GCData data, int context) {
+ if (data.foreground == -1) data.foreground = DefaultFore;
+ if (data.background == -1) data.background = DefaultBack;
+ if (data.font == null) data.font = data.device.systemFont;
+ dirtyBits = DIRTY_FOREGROUND | DIRTY_BACKGROUND | DIRTY_FONT;
+
+ Image image = data.image;
+ if (image != null) {
+ image.memGC = this;
+ int prevContext = OS.PmMemStart(context);
+ OS.PgSetDrawBufferSize(DrawBufferSize);
+ OS.PmMemStop(context);
+ OS.PhDCSetCurrent(prevContext);
+
+ /*
+ * 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;
+}
+
/**
* Returns <code>true</code> if the receiver has a clipping
* region set into it, and <code>false</code> otherwise.
@@ -1987,11 +1987,11 @@ void init(Drawable drawable, GCData data, int context) {
* <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
* </ul>
*/
-public boolean isClipped() {
- if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- return data.clipRects != 0;
-}
-
+public boolean isClipped() {
+ if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ return data.clipRects != 0;
+}
+
/**
* Returns <code>true</code> if the GC has been disposed,
* and <code>false</code> otherwise.
@@ -2002,10 +2002,10 @@ public boolean isClipped() {
*
* @return <code>true</code> when the GC is disposed and <code>false</code> otherwise
*/
-public boolean isDisposed() {
- return handle == 0;
-}
-
+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
@@ -2021,14 +2021,14 @@ public boolean isDisposed() {
* <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
* </ul>
*/
-public void setBackground (Color color) {
- if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- if (color == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
- if (color.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
- data.background = color.handle;
- dirtyBits |= DIRTY_BACKGROUND;
-}
-
+public void setBackground (Color color) {
+ if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ if (color == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ if (color.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+ data.background = color.handle;
+ dirtyBits |= DIRTY_BACKGROUND;
+}
+
/**
* Sets the area of the receiver which can be changed
* by drawing operations to the rectangular area specified
@@ -2043,32 +2043,32 @@ public void setBackground (Color color) {
* <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
* </ul>
*/
-public void setClipping (int x, int y, int width, int height) {
- if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- if (width < 0) {
- x = x + width;
- width = -width;
- }
- if (height < 0) {
- y = y + height;
- height = -height;
- }
- 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);
- data.clipRects = clipRects;
- data.clipRectsCount = clipRectsCount;
- dirtyBits |= DIRTY_CLIPPING;
-}
-
+public void setClipping (int x, int y, int width, int height) {
+ if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ if (width < 0) {
+ x = x + width;
+ width = -width;
+ }
+ if (height < 0) {
+ y = y + height;
+ height = -height;
+ }
+ 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);
+ data.clipRects = clipRects;
+ data.clipRectsCount = clipRectsCount;
+ dirtyBits |= DIRTY_CLIPPING;
+}
+
/**
* Sets the area of the receiver which can be changed
* by drawing operations to the rectangular area specified
@@ -2080,19 +2080,19 @@ public void setClipping (int x, int y, int width, int height) {
* <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
* </ul>
*/
-public void setClipping (Rectangle rect) {
- if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- if (rect == null) {
- int clipRects = data.clipRects;
- if (clipRects != 0)
- OS.free(clipRects);
- data.clipRects = data.clipRectsCount = 0;
- dirtyBits |= DIRTY_CLIPPING;
- } else {
- setClipping (rect.x, rect.y, rect.width, rect.height);
- }
-}
-
+public void setClipping (Rectangle rect) {
+ if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ if (rect == null) {
+ int clipRects = data.clipRects;
+ if (clipRects != 0)
+ OS.free(clipRects);
+ data.clipRects = data.clipRectsCount = 0;
+ dirtyBits |= DIRTY_CLIPPING;
+ } else {
+ setClipping (rect.x, rect.y, rect.width, rect.height);
+ }
+}
+
/**
* Sets the area of the receiver which can be changed
* by drawing operations to the region specified
@@ -2104,27 +2104,27 @@ public void setClipping (Rectangle rect) {
* <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
* </ul>
*/
-public void setClipping (Region region) {
- if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- 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];
- }
- data.clipRects = clipRects;
- data.clipRectsCount = clipRectsCount;
- dirtyBits |= DIRTY_CLIPPING;
-}
-
+public void setClipping (Region region) {
+ if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ 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];
+ }
+ data.clipRects = clipRects;
+ data.clipRectsCount = clipRectsCount;
+ dirtyBits |= DIRTY_CLIPPING;
+}
+
/**
* Sets the font which will be used by the receiver
* to draw and measure text to the argument. If the
@@ -2140,13 +2140,13 @@ public void setClipping (Region region) {
* <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
* </ul>
*/
-public void setFont (Font font) {
- if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- if (font != null && font.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
- data.font = font == null ? data.device.systemFont : font.handle;
- dirtyBits |= DIRTY_FONT;
-}
-
+public void setFont (Font font) {
+ if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ if (font != null && font.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+ data.font = font == null ? data.device.systemFont : font.handle;
+ dirtyBits |= DIRTY_FONT;
+}
+
/**
* Sets the foreground color. The foreground color is used
* for drawing operations including when text is drawn.
@@ -2161,14 +2161,14 @@ public void setFont (Font font) {
* <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
* </ul>
*/
-public void setForeground (Color color) {
- if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- if (color == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
- if (color.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
- data.foreground = color.handle;
- dirtyBits |= DIRTY_FOREGROUND;
-}
-
+public void setForeground (Color color) {
+ if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ if (color == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ if (color.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+ data.foreground = color.handle;
+ dirtyBits |= DIRTY_FOREGROUND;
+}
+
/**
* 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>,
@@ -2181,23 +2181,23 @@ public void setForeground (Color color) {
* <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
* </ul>
*/
-public void setLineStyle(int lineStyle) {
- if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- switch (lineStyle) {
- case SWT.LINE_SOLID:
- case SWT.LINE_DASH:
- case SWT.LINE_DOT:
- case SWT.LINE_DASHDOT:
- case SWT.LINE_DASHDOTDOT:
- break;
- default:
- SWT.error (SWT.ERROR_INVALID_ARGUMENT);
- return;
- }
- data.lineStyle = lineStyle;
- dirtyBits |= DIRTY_LINESTYLE;
-}
-
+public void setLineStyle(int lineStyle) {
+ if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ switch (lineStyle) {
+ case SWT.LINE_SOLID:
+ case SWT.LINE_DASH:
+ case SWT.LINE_DOT:
+ case SWT.LINE_DASHDOT:
+ case SWT.LINE_DASHDOTDOT:
+ break;
+ default:
+ SWT.error (SWT.ERROR_INVALID_ARGUMENT);
+ return;
+ }
+ data.lineStyle = lineStyle;
+ dirtyBits |= DIRTY_LINESTYLE;
+}
+
/**
* Sets the width that will be used when drawing lines
* for all of the figure drawing operations (that is,
@@ -2210,158 +2210,158 @@ public void setLineStyle(int lineStyle) {
* <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
* </ul>
*/
-public void setLineWidth(int lineWidth) {
- if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- data.lineWidth = lineWidth;
- dirtyBits |= DIRTY_LINEWIDTH;
-}
-
-int setGC() {
- int result = 0;
- if (data.image != null) result = OS.PmMemStart(handle);
- else if (data.rid == OS.Ph_DEV_RID || data.widget != 0) result = OS.PgSetGC(handle);
- else return result;
-
- if (dirtyBits != 0) {
- if ((dirtyBits & DIRTY_BACKGROUND) != 0) {
- OS.PgSetFillColor(data.background);
- }
- if ((dirtyBits & DIRTY_FOREGROUND) != 0) {
- int foreColor = data.foreground;
- OS.PgSetStrokeColor(foreColor);
- OS.PgSetTextColor(foreColor);
- }
- if ((dirtyBits & DIRTY_FONT) != 0) {
- OS.PfLoadMetrics(data.font);
- OS.PgSetFont(data.font);
- }
- if ((dirtyBits & DIRTY_CLIPPING) != 0) {
- OS.PgSetMultiClip(data.clipRectsCount, data.clipRects);
- }
- if ((dirtyBits & DIRTY_LINESTYLE) != 0) {
- byte[] dashList = null;
- switch (data.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;
- }
- OS.PgSetStrokeDash(dashList, dashList.length, 0x10000);
- }
- if ((dirtyBits & DIRTY_LINEWIDTH) != 0) {
- OS.PgSetStrokeWidth(data.lineWidth);
- }
- if ((dirtyBits & DIRTY_XORMODE) != 0) {
- if (data.xorMode) OS.PgSetDrawMode(OS.Pg_DRAWMODE_XOR);
- else OS.PgSetDrawMode(OS.Pg_DRAWMODE_OPAQUE);
- }
- dirtyBits = 0;
- }
- return result;
-}
-
-void setGCClipping() {
- int rid = data.rid;
- int widget = data.widget;
- 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 */
- OS.PgSetMultiClip(data.clipRectsCount, data.clipRects);
-
- if (widget == 0) return;
-
- int clip_tile = getClipping(widget, data.topWidget, true, true, null);
- int[] clip_rects_count = new int[1];
- int clip_rects = OS.PhTilesToRects(clip_tile, clip_rects_count);
- OS.PhFreeTiles(clip_tile);
- 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);
-}
-
-int getClipping(int widget, int topWidget, boolean clipChildren, boolean clipSiblings, int[] child_tiles) {
- int child_tile = 0;
- int widget_tile = OS.PhGetTile(); // NOTE: PhGetTile native initializes the tile
-
- PhRect_t rect = new PhRect_t ();
- int args [] = {OS.Pt_ARG_FLAGS, 0, 0, OS.Pt_ARG_BASIC_FLAGS, 0, 0};
-
- /* Get the rectangle of all siblings in front of the widget */
- if (clipSiblings && OS.PtWidgetClass(topWidget) != OS.PtWindow()) {
- 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
- args [1] = args [4] = 0;
- OS.PtGetResources(temp_widget, args.length / 3, args);
- if ((args [1] & OS.Pt_HIGHLIGHTED) != 0) {
- int basic_flags = args [4];
- OS.memmove(rect, tile, PhRect_t.sizeof);
- if ((basic_flags & OS.Pt_TOP_ETCH) != 0) rect.ul_y++;
- if ((basic_flags & OS.Pt_BOTTOM_ETCH) != 0) rect.lr_y--;
- if ((basic_flags & OS.Pt_RIGHT_ETCH) != 0) rect.ul_x++;
- if ((basic_flags & OS.Pt_LEFT_ETCH) != 0) rect.lr_x--;
- OS.memmove(tile, rect, PhRect_t.sizeof);
- }
- }
- }
- /* 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 */
- if (clipChildren) {
- int 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
- args [1] = args [4] = 0;
- OS.PtGetResources(temp_widget, args.length / 3, args);
- if ((args [1] & OS.Pt_HIGHLIGHTED) != 0) {
- int basic_flags = args [4];
- OS.memmove(rect, tile, PhRect_t.sizeof);
- if ((basic_flags & OS.Pt_TOP_ETCH) != 0) rect.ul_y++;
- if ((basic_flags & OS.Pt_BOTTOM_ETCH) != 0) rect.lr_y--;
- if ((basic_flags & OS.Pt_RIGHT_ETCH) != 0) rect.ul_x++;
- if ((basic_flags & OS.Pt_LEFT_ETCH) != 0) rect.lr_x--;
- OS.memmove(tile, rect, PhRect_t.sizeof);
- }
- }
- 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 */
- if (child_tile != 0) {
- if (child_tiles != null) {
- child_tiles[0] = OS.PhIntersectTilings(widget_tile, child_tile, new short[1]);
- }
- int clip_tile = OS.PhClipTilings(widget_tile, child_tile, null);
- OS.PhFreeTiles(child_tile);
- return clip_tile;
- }
- return widget_tile;
-}
-
+public void setLineWidth(int lineWidth) {
+ if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ data.lineWidth = lineWidth;
+ dirtyBits |= DIRTY_LINEWIDTH;
+}
+
+int setGC() {
+ int result = 0;
+ if (data.image != null) result = OS.PmMemStart(handle);
+ else if (data.rid == OS.Ph_DEV_RID || data.widget != 0) result = OS.PgSetGC(handle);
+ else return result;
+
+ if (dirtyBits != 0) {
+ if ((dirtyBits & DIRTY_BACKGROUND) != 0) {
+ OS.PgSetFillColor(data.background);
+ }
+ if ((dirtyBits & DIRTY_FOREGROUND) != 0) {
+ int foreColor = data.foreground;
+ OS.PgSetStrokeColor(foreColor);
+ OS.PgSetTextColor(foreColor);
+ }
+ if ((dirtyBits & DIRTY_FONT) != 0) {
+ OS.PfLoadMetrics(data.font);
+ OS.PgSetFont(data.font);
+ }
+ if ((dirtyBits & DIRTY_CLIPPING) != 0) {
+ OS.PgSetMultiClip(data.clipRectsCount, data.clipRects);
+ }
+ if ((dirtyBits & DIRTY_LINESTYLE) != 0) {
+ byte[] dashList = null;
+ switch (data.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;
+ }
+ OS.PgSetStrokeDash(dashList, dashList.length, 0x10000);
+ }
+ if ((dirtyBits & DIRTY_LINEWIDTH) != 0) {
+ OS.PgSetStrokeWidth(data.lineWidth);
+ }
+ if ((dirtyBits & DIRTY_XORMODE) != 0) {
+ if (data.xorMode) OS.PgSetDrawMode(OS.Pg_DRAWMODE_XOR);
+ else OS.PgSetDrawMode(OS.Pg_DRAWMODE_OPAQUE);
+ }
+ dirtyBits = 0;
+ }
+ return result;
+}
+
+void setGCClipping() {
+ int rid = data.rid;
+ int widget = data.widget;
+ 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 */
+ OS.PgSetMultiClip(data.clipRectsCount, data.clipRects);
+
+ if (widget == 0) return;
+
+ int clip_tile = getClipping(widget, data.topWidget, true, true, null);
+ int[] clip_rects_count = new int[1];
+ int clip_rects = OS.PhTilesToRects(clip_tile, clip_rects_count);
+ OS.PhFreeTiles(clip_tile);
+ 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);
+}
+
+int getClipping(int widget, int topWidget, boolean clipChildren, boolean clipSiblings, int[] child_tiles) {
+ int child_tile = 0;
+ int widget_tile = OS.PhGetTile(); // NOTE: PhGetTile native initializes the tile
+
+ PhRect_t rect = new PhRect_t ();
+ int args [] = {OS.Pt_ARG_FLAGS, 0, 0, OS.Pt_ARG_BASIC_FLAGS, 0, 0};
+
+ /* Get the rectangle of all siblings in front of the widget */
+ if (clipSiblings && OS.PtWidgetClass(topWidget) != OS.PtWindow()) {
+ 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
+ args [1] = args [4] = 0;
+ OS.PtGetResources(temp_widget, args.length / 3, args);
+ if ((args [1] & OS.Pt_HIGHLIGHTED) != 0) {
+ int basic_flags = args [4];
+ OS.memmove(rect, tile, PhRect_t.sizeof);
+ if ((basic_flags & OS.Pt_TOP_ETCH) != 0) rect.ul_y++;
+ if ((basic_flags & OS.Pt_BOTTOM_ETCH) != 0) rect.lr_y--;
+ if ((basic_flags & OS.Pt_RIGHT_ETCH) != 0) rect.ul_x++;
+ if ((basic_flags & OS.Pt_LEFT_ETCH) != 0) rect.lr_x--;
+ OS.memmove(tile, rect, PhRect_t.sizeof);
+ }
+ }
+ }
+ /* 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 */
+ if (clipChildren) {
+ int 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
+ args [1] = args [4] = 0;
+ OS.PtGetResources(temp_widget, args.length / 3, args);
+ if ((args [1] & OS.Pt_HIGHLIGHTED) != 0) {
+ int basic_flags = args [4];
+ OS.memmove(rect, tile, PhRect_t.sizeof);
+ if ((basic_flags & OS.Pt_TOP_ETCH) != 0) rect.ul_y++;
+ if ((basic_flags & OS.Pt_BOTTOM_ETCH) != 0) rect.lr_y--;
+ if ((basic_flags & OS.Pt_RIGHT_ETCH) != 0) rect.ul_x++;
+ if ((basic_flags & OS.Pt_LEFT_ETCH) != 0) rect.lr_x--;
+ OS.memmove(tile, rect, PhRect_t.sizeof);
+ }
+ }
+ 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 */
+ if (child_tile != 0) {
+ if (child_tiles != null) {
+ child_tiles[0] = OS.PhIntersectTilings(widget_tile, child_tile, new short[1]);
+ }
+ int clip_tile = OS.PhClipTilings(widget_tile, child_tile, null);
+ OS.PhFreeTiles(child_tile);
+ return clip_tile;
+ }
+ return widget_tile;
+}
+
/**
* If the argument is <code>true</code>, puts the receiver
* in a drawing mode where the resulting color in the destination
@@ -2376,12 +2376,12 @@ int getClipping(int widget, int topWidget, boolean clipChildren, boolean clipSib
* <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
* </ul>
*/
-public void setXORMode(boolean xor) {
- if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- data.xorMode = xor;
- dirtyBits |= DIRTY_XORMODE;
-}
-
+public void setXORMode(boolean xor) {
+ if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ data.xorMode = xor;
+ dirtyBits |= DIRTY_XORMODE;
+}
+
/**
* Returns the extent of the given string. No tab
* expansion or carriage return processing will be performed.
@@ -2401,28 +2401,28 @@ public void setXORMode(boolean xor) {
* <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
* </ul>
*/
-public Point stringExtent(String string) {
- if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- 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;
- if (size == 0) width = 0;
- else width = rect.lr_x - (rect.ul_x < 0 ? rect.ul_x : 0) + 1;
- int height = rect.lr_y - rect.ul_y + 1;
- return new Point(width, height);
-}
-
+public Point stringExtent(String string) {
+ if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ 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;
+ if (size == 0) width = 0;
+ else width = rect.lr_x - (rect.ul_x < 0 ? rect.ul_x : 0) + 1;
+ int height = rect.lr_y - rect.ul_y + 1;
+ return new Point(width, height);
+}
+
/**
* Returns the extent of the given string. Tab expansion and
* carriage return processing are performed.
@@ -2442,79 +2442,79 @@ public Point stringExtent(String string) {
* <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
* </ul>
*/
-public Point textExtent(String string) {
- return textExtent(string, SWT.DRAW_DELIMITER | SWT.DRAW_TAB);
-}
-
-/**
- * Returns the extent of the given string. Tab expansion, line
- * delimiter and mnemonic processing are performed according to
- * the specified flags, which can be a combination of:
- * <dl>
- * <dt><b>DRAW_DELIMITER</b></dt>
- * <dd>draw multiple lines</dd>
- * <dt><b>DRAW_TAB</b></dt>
- * <dd>expand tabs</dd>
- * <dt><b>DRAW_MNEMONIC</b></dt>
- * <dd>underline the mnemonic character</dd>
- * <dt><b>DRAW_TRANSPARENT</b></dt>
- * <dd>transparent background</dd>
- * </dl>
- * <p>
- * The <em>extent</em> of a string is the width and height of
- * the rectangular area it would cover if drawn in a particular
- * font (in this case, the current font in the receiver).
- * </p>
- *
- * @param string the string to measure
- * @param flags the flags specifing how to process the text
- * @return a point containing the extent of the string
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the string is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
- * </ul>
+public Point textExtent(String string) {
+ return textExtent(string, SWT.DRAW_DELIMITER | SWT.DRAW_TAB);
+}
+
+/**
+ * Returns the extent of the given string. Tab expansion, line
+ * delimiter and mnemonic processing are performed according to
+ * the specified flags, which can be a combination of:
+ * <dl>
+ * <dt><b>DRAW_DELIMITER</b></dt>
+ * <dd>draw multiple lines</dd>
+ * <dt><b>DRAW_TAB</b></dt>
+ * <dd>expand tabs</dd>
+ * <dt><b>DRAW_MNEMONIC</b></dt>
+ * <dd>underline the mnemonic character</dd>
+ * <dt><b>DRAW_TRANSPARENT</b></dt>
+ * <dd>transparent background</dd>
+ * </dl>
+ * <p>
+ * The <em>extent</em> of a string is the width and height of
+ * the rectangular area it would cover if drawn in a particular
+ * font (in this case, the current font in the receiver).
+ * </p>
+ *
+ * @param string the string to measure
+ * @param flags the flags specifing how to process the text
+ * @return a point containing the extent of the string
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if the string is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
*/
-public Point textExtent(String string, int flags) {
- if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- if (string == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
- if ((flags & ~SWT.DRAW_TRANSPARENT) == 0) {
- return stringExtent(string);
- } else {
- return drawText(string, 0, 0, flags, false);
- }
-}
-
+public Point textExtent(String string, int flags) {
+ if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ if (string == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ if ((flags & ~SWT.DRAW_TRANSPARENT) == 0) {
+ return stringExtent(string);
+ } else {
+ return drawText(string, 0, 0, flags, false);
+ }
+}
+
/**
* Returns a string containing a concise, human-readable
* description of the receiver.
*
* @return a string representation of the receiver
*/
-public String toString () {
- if (isDisposed()) return "GC {*DISPOSED*}";
- return "GC {" + handle + "}";
-}
-
-void unsetGC(int prevContext) {
- Image image = data.image;
- if (image != null) {
-// OS.PmMemFlush(handle, image.handle);
- OS.PmMemStop(handle);
- OS.PhDCSetCurrent(prevContext);
- } 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;
-}
-
+public String toString () {
+ if (isDisposed()) return "GC {*DISPOSED*}";
+ return "GC {" + handle + "}";
+}
+
+void unsetGC(int prevContext) {
+ Image image = data.image;
+ if (image != null) {
+// OS.PmMemFlush(handle, image.handle);
+ OS.PmMemStop(handle);
+ OS.PhDCSetCurrent(prevContext);
+ } 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;
+}
+
}
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
index 30fb1135fd..0073e5acb8 100755
--- 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
@@ -1,14 +1,14 @@
-package org.eclipse.swt.graphics;
-
-/*
+package org.eclipse.swt.graphics;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-import org.eclipse.swt.*;
-
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+import org.eclipse.swt.*;
+
/**
* Instances of this class are descriptions of GCs in terms
* of unallocated platform-specific data fields.
@@ -21,17 +21,17 @@ import org.eclipse.swt.*;
*
* @private
*/
-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;
+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;
}
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
index fceee38aa1..6e0e7d5b5e 100755
--- 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
@@ -1,16 +1,16 @@
-package org.eclipse.swt.graphics;
-
-/*
+package org.eclipse.swt.graphics;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-import org.eclipse.swt.internal.photon.*;
-import org.eclipse.swt.*;
-import java.io.*;
-
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+import org.eclipse.swt.internal.photon.*;
+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
@@ -58,46 +58,46 @@ import java.io.*;
* @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 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 type;
+
+ /**
+ * the OS resource of the image
+ * (Warning: This field is platform dependent)
*/
- public int handle;
-
- /**
- * the device where this image was created
+ public int handle;
+
+ /**
+ * the device where this image was created
*/
- Device device;
-
- /**
- * specifies the transparent pixel
- * (Warning: This field is platform dependent)
+ 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)
+ 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)
+ GC memGC;
+
+ /**
+ * specifies the default scanline padding
+ * (Warning: This field is platform dependent)
*/
- static final int DEFAULT_SCANLINE_PAD = 4;
-
-Image () {
-}
-
+ static final int DEFAULT_SCANLINE_PAD = 4;
+
+Image () {
+}
+
/**
* Constructs an empty instance of this class with the
* specified width and height. The result may be drawn upon
@@ -128,13 +128,13 @@ Image () {
* <li>ERROR_NO_HANDLES if a handle could not be obtained for image creation</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);
-}
-
+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
@@ -166,125 +166,125 @@ public Image(Device device, int width, int height) {
* <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);
- if (srcImage.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
- switch (flag) {
- case SWT.IMAGE_COPY:
- case SWT.IMAGE_DISABLE:
- this.type = srcImage.type;
- int srcHandle = srcImage.handle;
- int newHandle = OS.PiDuplicateImage (srcHandle, 0);
- if (newHandle == 0) SWT.error(SWT.ERROR_NO_HANDLES);
- if (flag == SWT.IMAGE_COPY) {
- /*
- * Bug in Photon. The image returned by PiDuplicateImage might
- * have the same mask_bm/alpha as the original image. The fix
- * is to detect this case and copy mask_bm/alpha if necessary.
- */
- PhImage_t phImage = new PhImage_t();
- OS.memmove (phImage, srcHandle, PhImage_t.sizeof);
- PhImage_t newPhImage = new PhImage_t();
- OS.memmove(newPhImage, newHandle, PhImage_t.sizeof);
- if (newPhImage.mask_bm != 0 && phImage.mask_bm == newPhImage.mask_bm) {
- int length = newPhImage.mask_bpl * newPhImage.size_h;
- int ptr = OS.malloc(length);
- OS.memmove(ptr, newPhImage.mask_bm, length);
- newPhImage.mask_bm = ptr;
- }
- if (newPhImage.alpha != 0 && phImage.alpha == newPhImage.alpha) {
- 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_bpl * alpha.src_alpha_map_dim_h;
- int ptr = OS.malloc(length);
- OS.memmove(ptr, alpha.src_alpha_map_map, length);
- alpha.src_alpha_map_map = ptr;
- }
- int ptr = OS.malloc(PgAlpha_t.sizeof);
- OS.memmove(ptr, alpha, PgAlpha_t.sizeof);
- newPhImage.alpha = ptr;
- }
- OS.memmove(newHandle, newPhImage, PhImage_t.sizeof);
- transparentPixel = srcImage.transparentPixel;
- } else {
- PhImage_t phImage = new PhImage_t();
- OS.PhMakeGhostBitmap(newHandle);
- OS.memmove (phImage, newHandle, 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 (newHandle, phImage, PhImage_t.sizeof);
- }
- handle = newHandle;
- 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, 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);
+ if (srcImage.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+ switch (flag) {
+ case SWT.IMAGE_COPY:
+ case SWT.IMAGE_DISABLE:
+ this.type = srcImage.type;
+ int srcHandle = srcImage.handle;
+ int newHandle = OS.PiDuplicateImage (srcHandle, 0);
+ if (newHandle == 0) SWT.error(SWT.ERROR_NO_HANDLES);
+ if (flag == SWT.IMAGE_COPY) {
+ /*
+ * Bug in Photon. The image returned by PiDuplicateImage might
+ * have the same mask_bm/alpha as the original image. The fix
+ * is to detect this case and copy mask_bm/alpha if necessary.
+ */
+ PhImage_t phImage = new PhImage_t();
+ OS.memmove (phImage, srcHandle, PhImage_t.sizeof);
+ PhImage_t newPhImage = new PhImage_t();
+ OS.memmove(newPhImage, newHandle, PhImage_t.sizeof);
+ if (newPhImage.mask_bm != 0 && phImage.mask_bm == newPhImage.mask_bm) {
+ int length = newPhImage.mask_bpl * newPhImage.size_h;
+ int ptr = OS.malloc(length);
+ OS.memmove(ptr, newPhImage.mask_bm, length);
+ newPhImage.mask_bm = ptr;
+ }
+ if (newPhImage.alpha != 0 && phImage.alpha == newPhImage.alpha) {
+ 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_bpl * alpha.src_alpha_map_dim_h;
+ int ptr = OS.malloc(length);
+ OS.memmove(ptr, alpha.src_alpha_map_map, length);
+ alpha.src_alpha_map_map = ptr;
+ }
+ int ptr = OS.malloc(PgAlpha_t.sizeof);
+ OS.memmove(ptr, alpha, PgAlpha_t.sizeof);
+ newPhImage.alpha = ptr;
+ }
+ OS.memmove(newHandle, newPhImage, PhImage_t.sizeof);
+ transparentPixel = srcImage.transparentPixel;
+ } else {
+ PhImage_t phImage = new PhImage_t();
+ OS.PhMakeGhostBitmap(newHandle);
+ OS.memmove (phImage, newHandle, 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 (newHandle, phImage, PhImage_t.sizeof);
+ }
+ handle = newHandle;
+ 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
@@ -315,14 +315,14 @@ public Image(Device device, Image srcImage, int flag) {
* <li>ERROR_NO_HANDLES if a handle could not be obtained for image creation</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);
-}
-
+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>.
@@ -338,13 +338,13 @@ public Image(Device device, Rectangle bounds) {
* <li>ERROR_NO_HANDLES if a handle could not be obtained for image creation</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);
-}
-
+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>
@@ -374,22 +374,22 @@ public Image(Device device, ImageData data) {
* <li>ERROR_NO_HANDLES if a handle could not be obtained for image creation</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) 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, 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);
+}
+
/**
* Constructs an instance of this class by loading its representation
* from the specified input stream. Throws an error if an error
@@ -422,13 +422,13 @@ public Image(Device device, ImageData source, ImageData mask) {
* <li>ERROR_NO_HANDLES if a handle could not be obtained for image creation</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);
-}
-
+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
@@ -454,28 +454,28 @@ public Image (Device device, InputStream stream) {
* <li>ERROR_NO_HANDLES if a handle could not be obtained for image creation</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);
-}
-
+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 (device.isDisposed()) return;
- destroyImage(handle);
- handle = 0;
- memGC = null;
- if (device.tracking) device.dispose_Object(this);
- device = null;
-}
-
+public void dispose () {
+ if (handle == 0) return;
+ if (device.isDisposed()) return;
+ destroyImage(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
@@ -486,13 +486,13 @@ public void dispose () {
*
* @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;
-}
-
+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.
@@ -511,43 +511,43 @@ public boolean equals (Object object) {
* <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
* </ul>
*/
-public Color getBackground() {
- if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- if (transparentPixel == -1) return null;
-
- 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 Color getBackground() {
+ if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ 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);
+}
+
/**
* Returns the bounds of the receiver. The rectangle will always
* have x and y values of 0, and the width and height of the
@@ -560,13 +560,13 @@ public Color getBackground() {
* <li>ERROR_INVALID_IMAGE - if the image is not a bitmap or an icon</li>
* </ul>
*/
-public Rectangle getBounds() {
- if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- 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 Rectangle getBounds() {
+ if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ PhImage_t image = new PhImage_t();
+ OS.memmove(image, handle, PhImage_t.sizeof);
+ return new Rectangle(0, 0, image.size_w, image.size_h);
+}
+
/**
* Returns an <code>ImageData</code> based on the receiver
* Modifications made to this <code>ImageData</code> will not
@@ -581,85 +581,85 @@ public Rectangle getBounds() {
*
* @see ImageData
*/
-public ImageData getImageData() {
- if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- 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 ImageData getImageData() {
+ if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ 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;
+}
+
/**
* Returns an integer hash code for the receiver. Any two
* objects which return <code>true</code> when passed to
@@ -670,211 +670,211 @@ public ImageData getImageData() {
*
* @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;
- 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;
-
- /*
- * Feature in Photon. Photon does not support 2-bit depth images and
- * memory contexts can not be created on 1 & 4-bit depth images. The
- * fix is to create 8-bit depth images instead.
- */
- if (i.depth == 1 || i.depth == 2 || i.depth == 4) {
- ImageData img = new ImageData(i.width, i.height, 8, i.palette);
- ImageData.blit(ImageData.BLIT_SRC,
- i.data, i.depth, i.bytesPerLine, img.getByteOrder(), 0, 0, i.width, i.height, null, null, null,
- ImageData.ALPHA_OPAQUE, null, 0, 0, 0,
- img.data, img.depth, img.bytesPerLine, img.getByteOrder(), 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 {
- final PaletteData palette = i.palette;
- final int redMask = palette.redMask;
- final int greenMask = palette.greenMask;
- final int blueMask = palette.blueMask;
- int newDepth = i.depth;
- int newOrder = ImageData.MSB_FIRST;
- PaletteData newPalette = null;
-
- switch (i.depth) {
- case 8:
- newDepth = 16;
- newOrder = ImageData.LSB_FIRST;
- newPalette = new PaletteData(0xF800, 0x7E0, 0x1F);
- type = OS.Pg_IMAGE_DIRECT_565;
- break;
- case 16:
- newOrder = 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, newDepth, newPalette);
- ImageData.blit(ImageData.BLIT_SRC,
- i.data, i.depth, i.bytesPerLine, i.getByteOrder(), 0, 0, i.width, i.height, redMask, greenMask, blueMask,
- ImageData.ALPHA_OPAQUE, null, 0, 0, 0,
- img.data, img.depth, img.bytesPerLine, newOrder, 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_bpl = (short)i.width;
- 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 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;
+
+ /*
+ * Feature in Photon. Photon does not support 2-bit depth images and
+ * memory contexts can not be created on 1 & 4-bit depth images. The
+ * fix is to create 8-bit depth images instead.
+ */
+ if (i.depth == 1 || i.depth == 2 || i.depth == 4) {
+ ImageData img = new ImageData(i.width, i.height, 8, i.palette);
+ ImageData.blit(ImageData.BLIT_SRC,
+ i.data, i.depth, i.bytesPerLine, img.getByteOrder(), 0, 0, i.width, i.height, null, null, null,
+ ImageData.ALPHA_OPAQUE, null, 0, 0, 0,
+ img.data, img.depth, img.bytesPerLine, img.getByteOrder(), 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 {
+ final PaletteData palette = i.palette;
+ final int redMask = palette.redMask;
+ final int greenMask = palette.greenMask;
+ final int blueMask = palette.blueMask;
+ int newDepth = i.depth;
+ int newOrder = ImageData.MSB_FIRST;
+ PaletteData newPalette = null;
+
+ switch (i.depth) {
+ case 8:
+ newDepth = 16;
+ newOrder = ImageData.LSB_FIRST;
+ newPalette = new PaletteData(0xF800, 0x7E0, 0x1F);
+ type = OS.Pg_IMAGE_DIRECT_565;
+ break;
+ case 16:
+ newOrder = 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, newDepth, newPalette);
+ ImageData.blit(ImageData.BLIT_SRC,
+ i.data, i.depth, i.bytesPerLine, i.getByteOrder(), 0, 0, i.width, i.height, redMask, greenMask, blueMask,
+ ImageData.ALPHA_OPAQUE, null, 0, 0, 0,
+ img.data, img.depth, img.bytesPerLine, newOrder, 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_bpl = (short)i.width;
+ 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;
+}
+
/**
* Invokes platform specific functionality to allocate a new GC handle.
* <p>
@@ -890,30 +890,30 @@ void init(Device device, ImageData i) {
*
* @private
*/
-public int internal_new_GC (GCData data) {
- if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- /*
- * 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 int internal_new_GC (GCData data) {
+ if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ /*
+ * 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;
+}
+
/**
* Invokes platform specific functionality to dispose a GC handle.
* <p>
@@ -929,10 +929,10 @@ public int internal_new_GC (GCData data) {
*
* @private
*/
-public void internal_dispose_GC (int pmMC, GCData data) {
- OS.PmMemReleaseMC(pmMC);
-}
-
+public void internal_dispose_GC (int pmMC, GCData data) {
+ OS.PmMemReleaseMC(pmMC);
+}
+
/**
* Returns <code>true</code> if the image has been disposed,
* and <code>false</code> otherwise.
@@ -943,86 +943,86 @@ public void internal_dispose_GC (int pmMC, GCData data) {
*
* @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>
- * </p><p>
- * The image may be modified by this operation (in effect, the
- * transparent regions may be filled with the supplied color). Hence
- * this operation is not reversible and it is not legal to call
- * this function twice or with a null argument.
- * </p><p>
- * This method has no effect if the receiver does not have a transparent
- * pixel value.
- * </p>
- *
- * @param color the color to use when a transparent pixel is specified
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the color is null</li>
- * <li>ERROR_INVALID_ARGUMENT - if the color has been disposed</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
- * </ul>
+public 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>
+ * </p><p>
+ * The image may be modified by this operation (in effect, the
+ * transparent regions may be filled with the supplied color). Hence
+ * this operation is not reversible and it is not legal to call
+ * this function twice or with a null argument.
+ * </p><p>
+ * This method has no effect if the receiver does not have a transparent
+ * pixel value.
+ * </p>
+ *
+ * @param color the color to use when a transparent pixel is specified
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if the color is null</li>
+ * <li>ERROR_INVALID_ARGUMENT - if the color has been disposed</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
*/
-public void setBackground(Color color) {
- if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- if (color == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
- if (color.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
- if (transparentPixel == -1) return;
-
- 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;
-}
-
+public void setBackground(Color color) {
+ if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ if (color == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ if (color.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+ if (transparentPixel == -1) return;
+
+ 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;
+}
+
/**
* Returns a string containing a concise, human-readable
* description of the receiver.
*
* @return a string representation of the receiver
*/
-public String toString () {
- if (isDisposed()) return "Image {*DISPOSED*}";
- return "Image {" + handle + "}";
-}
-
+public String toString () {
+ if (isDisposed()) return "Image {*DISPOSED*}";
+ return "Image {" + handle + "}";
+}
+
}
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
index e0a506ba93..8b95059741 100755
--- 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
@@ -1,15 +1,15 @@
-package org.eclipse.swt.graphics;
-
-/*
+package org.eclipse.swt.graphics;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-import org.eclipse.swt.internal.photon.*;
-import org.eclipse.swt.*;
-
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+import org.eclipse.swt.internal.photon.*;
+import org.eclipse.swt.*;
+
/**
* Instances of this class represent areas of an x-y coordinate
* system that are aggregates of the areas covered by a number
@@ -20,16 +20,16 @@ import org.eclipse.swt.*;
* 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 final class Region {
+
+ /**
+ * the OS resource for the region
+ * (Warning: This field is platform dependent)
*/
- public int handle;
-
- static int EMPTY_REGION = -1;
-
+ public int handle;
+
+ static int EMPTY_REGION = -1;
+
/**
* Constructs a new empty region.
*
@@ -37,14 +37,14 @@ public final class Region {
* <li>ERROR_NO_HANDLES if a handle could not be obtained for region creation</li>
* </ul>
*/
-public Region () {
- handle = EMPTY_REGION;
-}
-Region(int handle) {
- this.handle = handle;
-}
-
-
+public Region () {
+ handle = EMPTY_REGION;
+}
+Region(int handle) {
+ this.handle = handle;
+}
+
+
/**
* Adds the given rectangle to the collection of rectangles
* the receiver maintains to describe its area.
@@ -59,22 +59,22 @@ Region(int handle) {
* <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
* </ul>
*/
-public void add (Rectangle rect) {
- if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- if (rect == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
- if (rect.width < 0 || rect.height < 0) SWT.error(SWT.ERROR_INVALID_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 (Rectangle rect) {
+ if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ if (rect == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ if (rect.width < 0 || rect.height < 0) SWT.error(SWT.ERROR_INVALID_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);
+}
+
/**
* Adds all of the rectangles which make up the area covered
* by the argument to the collection of rectangles the receiver
@@ -90,17 +90,17 @@ public void add (Rectangle rect) {
* <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
* </ul>
*/
-public void add (Region region) {
- if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- if (region == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
- if (region.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
- if (handle == 0) return;
- if (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 void add (Region region) {
+ if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ if (region == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ if (region.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+ if (handle == 0) return;
+ if (region.handle == EMPTY_REGION) return;
+ int copy = OS.PhCopyTiles(region.handle);
+ if (handle == EMPTY_REGION) handle = copy;
+ else handle = OS.PhAddMergeTiles (handle, copy, null);
+}
+
/**
* Returns <code>true</code> if the point specified by the
* arguments is inside the area specified by the receiver,
@@ -114,21 +114,21 @@ public void add (Region region) {
* <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
* </ul>
*/
-public boolean contains (int x, int y) {
- if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- 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 (int x, int y) {
+ if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ 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;
+}
+
/**
* Returns <code>true</code> if the given point is inside the
* area specified by the receiver, and <code>false</code>
@@ -144,22 +144,22 @@ public boolean contains (int x, int y) {
* <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
* </ul>
*/
-public boolean contains (Point pt) {
- if (pt == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
- return contains(pt.x, pt.y);
-}
-
+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) return;
- if (handle != EMPTY_REGION) OS.PhFreeTiles (handle);
- handle = 0;
-}
-
+public void dispose () {
+ if (handle == 0) return;
+ if (handle != EMPTY_REGION) OS.PhFreeTiles (handle);
+ handle = 0;
+}
+
/**
* Compares the argument to the receiver, and returns true
* if they represent the <em>same</em> object using a class
@@ -170,13 +170,13 @@ public void dispose () {
*
* @see #hashCode
*/
-public boolean equals (Object object) {
- if (this == object) return true;
- if (!(object instanceof Region)) return false;
- Region region = (Region)object;
- return handle == region.handle;
-}
-
+public boolean equals (Object object) {
+ if (this == object) return true;
+ if (!(object instanceof Region)) return false;
+ Region region = (Region)object;
+ return handle == region.handle;
+}
+
/**
* Returns a rectangle which represents the rectangular
* union of the collection of rectangles the receiver
@@ -190,26 +190,26 @@ public boolean equals (Object object) {
*
* @see Rectangle#union
*/
-public Rectangle getBounds() {
- if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- 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 Rectangle getBounds() {
+ if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ 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);
+}
+
/**
* Returns an integer hash code for the receiver. Any two
* objects which return <code>true</code> when passed to
@@ -220,10 +220,10 @@ public Rectangle getBounds() {
*
* @see #equals
*/
-public int hashCode () {
- return handle;
-}
-
+public int hashCode () {
+ return handle;
+}
+
/**
* Returns <code>true</code> if the rectangle described by the
* arguments intersects with any of the rectangles the receiver
@@ -241,23 +241,23 @@ public int hashCode () {
*
* @see Rectangle#intersects
*/
-public boolean intersects (int x, int y, int width, int height) {
- if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- 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 (int x, int y, int width, int height) {
+ if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ 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;
+}
+
/**
* Returns <code>true</code> if the given rectangle intersects
* with any of the rectangles the receiver mainains to describe
@@ -275,11 +275,11 @@ public boolean intersects (int x, int y, int width, int height) {
*
* @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);
-}
-
+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.
@@ -290,10 +290,10 @@ public boolean intersects (Rectangle rect) {
*
* @return <code>true</code> when the region is disposed, and <code>false</code> otherwise
*/
-public boolean isDisposed() {
- return handle == 0;
-}
-
+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
@@ -305,23 +305,23 @@ public boolean isDisposed() {
* <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
* </ul>
*/
-public boolean isEmpty () {
- return getBounds().isEmpty();
-
-}
-
-public static Region photon_new(int handle) {
- return new Region(handle);
-}
-
+public boolean isEmpty () {
+ return getBounds().isEmpty();
+
+}
+
+public static Region photon_new(int handle) {
+ return new Region(handle);
+}
+
/**
* Returns a string containing a concise, human-readable
* description of the receiver.
*
* @return a string representation of the receiver
*/
-public String toString () {
- if (isDisposed()) return "Region {*DISPOSED*}";
- return "Region {" + handle + "}";
-}
+public String toString () {
+ if (isDisposed()) return "Region {*DISPOSED*}";
+ return "Region {" + handle + "}";
+}
}
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
index aa6c11ddd1..920f0849d8 100755
--- 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
@@ -1,14 +1,14 @@
-package org.eclipse.swt.internal;
-
-import java.io.UnsupportedEncodingException;
-
-/*
+package org.eclipse.swt.internal;
+
+import java.io.UnsupportedEncodingException;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
/**
* This class implements the conversions between unicode characters
* and the <em>platform supported</em> representation for characters.
@@ -17,47 +17,47 @@ import java.io.UnsupportedEncodingException;
* encoding will be converted to an arbitrary platform specific character.
* </p>
*/
-
-public final class Converter {
- public static final byte [] NullByteArray = new byte [1];
- public static final byte [] EmptyByteArray = new byte [0];
- public static final char [] EmptyCharArray = new char [0];
+
+public final class Converter {
+ public static final byte [] NullByteArray = new byte [1];
+ public static final byte [] EmptyByteArray = new byte [0];
+ public static final char [] EmptyCharArray = new char [0];
/**
* Returns the default code page for the platform where the
* application is currently running.
*
* @return the default code page
*/
-public static String defaultCodePage () {
- return "UTF8";
-}
-public static char [] mbcsToWcs (String codePage, byte [] buffer) {
- try {
- return new String (buffer, defaultCodePage ()).toCharArray ();
- } catch (UnsupportedEncodingException e) {
- return EmptyCharArray;
- }
-}
-public static byte [] wcsToMbcs (String codePage, String string, boolean terminate) {
- try {
- if (!terminate) return string.getBytes (defaultCodePage ());
- byte [] buffer1 = string.getBytes (defaultCodePage ());
- byte [] buffer2 = new byte [buffer1.length + 1];
- System.arraycopy (buffer1, 0, buffer2, 0, buffer1.length);
- return buffer2;
- } catch (UnsupportedEncodingException e) {
- return terminate ? NullByteArray : EmptyByteArray;
- }
-}
-public static byte [] wcsToMbcs (String codePage, char [] buffer, boolean terminate) {
- try {
- if (!terminate) return new String (buffer).getBytes (defaultCodePage ());
- byte [] buffer1 = new String (buffer).getBytes (defaultCodePage ());
- byte [] buffer2 = new byte [buffer1.length + 1];
- System.arraycopy (buffer1, 0, buffer2, 0, buffer1.length);
- return buffer2;
- } catch (UnsupportedEncodingException e) {
- return terminate ? NullByteArray : EmptyByteArray;
- }
-}
-}
+public static String defaultCodePage () {
+ return "UTF8";
+}
+public static char [] mbcsToWcs (String codePage, byte [] buffer) {
+ try {
+ return new String (buffer, defaultCodePage ()).toCharArray ();
+ } catch (UnsupportedEncodingException e) {
+ return EmptyCharArray;
+ }
+}
+public static byte [] wcsToMbcs (String codePage, String string, boolean terminate) {
+ try {
+ if (!terminate) return string.getBytes (defaultCodePage ());
+ byte [] buffer1 = string.getBytes (defaultCodePage ());
+ byte [] buffer2 = new byte [buffer1.length + 1];
+ System.arraycopy (buffer1, 0, buffer2, 0, buffer1.length);
+ return buffer2;
+ } catch (UnsupportedEncodingException e) {
+ return terminate ? NullByteArray : EmptyByteArray;
+ }
+}
+public static byte [] wcsToMbcs (String codePage, char [] buffer, boolean terminate) {
+ try {
+ if (!terminate) return new String (buffer).getBytes (defaultCodePage ());
+ byte [] buffer1 = new String (buffer).getBytes (defaultCodePage ());
+ byte [] buffer2 = new byte [buffer1.length + 1];
+ System.arraycopy (buffer1, 0, buffer2, 0, buffer1.length);
+ return buffer2;
+ } catch (UnsupportedEncodingException e) {
+ return terminate ? NullByteArray : EmptyByteArray;
+ }
+}
+}
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
index 9cce3f3ad4..2497daa884 100755
--- 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
@@ -1,18 +1,18 @@
-package org.eclipse.swt.widgets;
-
-/*
+package org.eclipse.swt.widgets;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-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.*;
-
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+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.*;
+
/**
* Instances of this class represent a selectable user interface object that
* issues notification when pressed and released.
@@ -36,9 +36,9 @@ import org.eclipse.swt.events.*;
* within the SWT implementation.
* </p>
*/
-public class Button extends Control {
- Image image;
-
+public class Button extends Control {
+ Image image;
+
/**
* Constructs a new instance of this class given its parent
* and a style value describing its behavior and appearance.
@@ -75,24 +75,24 @@ public class Button extends Control {
* @see Widget#checkSubclass
* @see Widget#getStyle
*/
-public Button (Composite parent, int style) {
- super (parent, checkStyle (style));
-}
-
-static int checkStyle (int style) {
- style = checkBits (style, SWT.PUSH, SWT.ARROW, SWT.CHECK, SWT.RADIO, SWT.TOGGLE, 0);
- if ((style & SWT.PUSH) != 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 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;
+}
+
/**
* Adds the listener to the collection of listeners who will
* be notified when the control is selected, by sending
@@ -117,151 +117,151 @@ static int checkStyle (int style) {
* @see #removeSelectionListener
* @see SelectionEvent
*/
-public void addSelectionListener (SelectionListener listener) {
- checkWidget();
- if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
- TypedListener typedListener = new TypedListener (listener);
- addListener (SWT.Selection,typedListener);
- addListener (SWT.DefaultSelection,typedListener);
-}
-
-void click () {
- int rid = OS.PtWidgetRid (handle);
- if (rid == 0) return;
- PhEvent_t event = new PhEvent_t ();
- event.emitter_rid = rid;
- event.emitter_handle = handle;
- event.collector_rid = rid;
- event.collector_handle = handle;
- event.flags = OS.Ph_EVENT_DIRECT;
- event.processing_flags = OS.Ph_FAKE_EVENT;
- event.type = OS.Ph_EV_BUT_PRESS;
- event.num_rects = 1;
- PhPointerEvent_t pe = new PhPointerEvent_t ();
- pe.click_count = 1;
- pe.buttons = OS.Ph_BUTTON_SELECT;
- PhRect_t rect = new PhRect_t ();
- int ptr = OS.malloc (PhEvent_t.sizeof + PhPointerEvent_t.sizeof + PhRect_t.sizeof);
- OS.memmove (ptr, event, PhEvent_t.sizeof);
- OS.memmove (ptr + PhEvent_t.sizeof, rect, PhRect_t.sizeof);
- OS.memmove (ptr + PhEvent_t.sizeof + PhRect_t.sizeof, pe, PhPointerEvent_t.sizeof);
- OS.PtSendEventToWidget (handle, ptr);
- OS.PtFlush ();
- event.type = OS.Ph_EV_BUT_RELEASE;
- event.subtype = OS.Ph_EV_RELEASE_REAL;
- OS.memmove (ptr, event, PhEvent_t.sizeof);
- OS.memmove (ptr + PhEvent_t.sizeof, rect, PhRect_t.sizeof);
- OS.memmove (ptr + PhEvent_t.sizeof + PhRect_t.sizeof, pe, PhPointerEvent_t.sizeof);
- OS.PtSendEventToWidget (handle, ptr);
- OS.free (ptr);
-}
-
-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 (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) {
- int [] args = {
- OS.Pt_ARG_MARGIN_LEFT, 0, 0, // 1
- OS.Pt_ARG_MARGIN_RIGHT, 0, 0, // 4
- OS.Pt_ARG_MARGIN_TOP, 0, 0, // 7
- OS.Pt_ARG_MARGIN_BOTTOM, 0, 0, // 10
-// OS.Pt_ARG_MARGIN_WIDTH, 0, 0, // 13
-// OS.Pt_ARG_MARGIN_HEIGHT, 0, 0, // 16
- };
- OS.PtGetResources (handle, args.length / 3, args);
- PhArea_t area = new PhArea_t ();
- area.size_w = (short) wHint;
- area.size_h = (short) hHint;
-
- /*
- * This code is intentionally commented. Bug compatible with Windows.
- */
-// PhRect_t rect = new PhRect_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 + /*(args [13] * 2)*/ + args [1] + args [4];
- }
- if (hHint != SWT.DEFAULT) {
- height = area.size_h + /*(args [16] * 2)*/ + args [7] + args [10];
- }
- }
- return new Point (width, height);
-}
-
-void createHandle (int index) {
- state |= HANDLE;
- Display display = getDisplay ();
- int parentHandle = parent.parentingHandle ();
-
- /* ARROW button */
- if ((style & SWT.ARROW) != 0) {
- int [] args = {
- OS.Pt_ARG_FLAGS, 0, OS.Pt_GETS_FOCUS,
- 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_FILL_COLOR, display.WIDGET_BACKGROUND, 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);
-}
-
-void drawWidget (int widget, int damage) {
- super.drawWidget (widget, damage);
- if ((style & SWT.ARROW) != 0) {
- 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);
- }
-}
-
+public void addSelectionListener (SelectionListener listener) {
+ checkWidget();
+ if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+ TypedListener typedListener = new TypedListener (listener);
+ addListener (SWT.Selection,typedListener);
+ addListener (SWT.DefaultSelection,typedListener);
+}
+
+void click () {
+ int rid = OS.PtWidgetRid (handle);
+ if (rid == 0) return;
+ PhEvent_t event = new PhEvent_t ();
+ event.emitter_rid = rid;
+ event.emitter_handle = handle;
+ event.collector_rid = rid;
+ event.collector_handle = handle;
+ event.flags = OS.Ph_EVENT_DIRECT;
+ event.processing_flags = OS.Ph_FAKE_EVENT;
+ event.type = OS.Ph_EV_BUT_PRESS;
+ event.num_rects = 1;
+ PhPointerEvent_t pe = new PhPointerEvent_t ();
+ pe.click_count = 1;
+ pe.buttons = OS.Ph_BUTTON_SELECT;
+ PhRect_t rect = new PhRect_t ();
+ int ptr = OS.malloc (PhEvent_t.sizeof + PhPointerEvent_t.sizeof + PhRect_t.sizeof);
+ OS.memmove (ptr, event, PhEvent_t.sizeof);
+ OS.memmove (ptr + PhEvent_t.sizeof, rect, PhRect_t.sizeof);
+ OS.memmove (ptr + PhEvent_t.sizeof + PhRect_t.sizeof, pe, PhPointerEvent_t.sizeof);
+ OS.PtSendEventToWidget (handle, ptr);
+ OS.PtFlush ();
+ event.type = OS.Ph_EV_BUT_RELEASE;
+ event.subtype = OS.Ph_EV_RELEASE_REAL;
+ OS.memmove (ptr, event, PhEvent_t.sizeof);
+ OS.memmove (ptr + PhEvent_t.sizeof, rect, PhRect_t.sizeof);
+ OS.memmove (ptr + PhEvent_t.sizeof + PhRect_t.sizeof, pe, PhPointerEvent_t.sizeof);
+ OS.PtSendEventToWidget (handle, ptr);
+ OS.free (ptr);
+}
+
+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 (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) {
+ int [] args = {
+ OS.Pt_ARG_MARGIN_LEFT, 0, 0, // 1
+ OS.Pt_ARG_MARGIN_RIGHT, 0, 0, // 4
+ OS.Pt_ARG_MARGIN_TOP, 0, 0, // 7
+ OS.Pt_ARG_MARGIN_BOTTOM, 0, 0, // 10
+// OS.Pt_ARG_MARGIN_WIDTH, 0, 0, // 13
+// OS.Pt_ARG_MARGIN_HEIGHT, 0, 0, // 16
+ };
+ OS.PtGetResources (handle, args.length / 3, args);
+ PhArea_t area = new PhArea_t ();
+ area.size_w = (short) wHint;
+ area.size_h = (short) hHint;
+
+ /*
+ * This code is intentionally commented. Bug compatible with Windows.
+ */
+// PhRect_t rect = new PhRect_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 + /*(args [13] * 2)*/ + args [1] + args [4];
+ }
+ if (hHint != SWT.DEFAULT) {
+ height = area.size_h + /*(args [16] * 2)*/ + args [7] + args [10];
+ }
+ }
+ return new Point (width, height);
+}
+
+void createHandle (int index) {
+ state |= HANDLE;
+ Display display = getDisplay ();
+ int parentHandle = parent.parentingHandle ();
+
+ /* ARROW button */
+ if ((style & SWT.ARROW) != 0) {
+ int [] args = {
+ OS.Pt_ARG_FLAGS, 0, OS.Pt_GETS_FOCUS,
+ 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_FILL_COLOR, display.WIDGET_BACKGROUND, 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);
+}
+
+void drawWidget (int widget, int damage) {
+ super.drawWidget (widget, damage);
+ if ((style & SWT.ARROW) != 0) {
+ 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);
+ }
+}
+
/**
* Returns a value which describes the position of the
* text or image in the receiver. The value will be one of
@@ -278,28 +278,28 @@ void drawWidget (int widget, int damage) {
* <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 [] args = {OS.Pt_ARG_BEVEL_CONTRAST, 0, 0};
- OS.PtGetResources (handle, args.length / 3, args);
- return args [1] == 100;
-}
-
+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 [] args = {OS.Pt_ARG_BEVEL_CONTRAST, 0, 0};
+ OS.PtGetResources (handle, args.length / 3, args);
+ return args [1] == 100;
+}
+
/**
* Returns the receiver's image if it has one, or null
* if it does not.
@@ -311,11 +311,11 @@ boolean getDefault () {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public Image getImage () {
- checkWidget();
- return image;
-}
-
+public Image getImage () {
+ checkWidget();
+ return image;
+}
+
/**
* Returns <code>true</code> if the receiver is selected,
* and false otherwise.
@@ -332,16 +332,16 @@ public Image getImage () {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public boolean getSelection () {
- checkWidget();
- if ((style & (SWT.CHECK | SWT.RADIO | SWT.TOGGLE)) == 0) return false;
- return (OS.PtWidgetFlags (handle) & OS.Pt_SET) != 0;
-}
-
-String getNameText () {
- return getText ();
-}
-
+public boolean getSelection () {
+ checkWidget();
+ if ((style & (SWT.CHECK | SWT.RADIO | SWT.TOGGLE)) == 0) return false;
+ return (OS.PtWidgetFlags (handle) & OS.Pt_SET) != 0;
+}
+
+String getNameText () {
+ return getText ();
+}
+
/**
* Returns the receiver's text, which will be an empty
* string if it has never been set.
@@ -353,95 +353,95 @@ String getNameText () {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public String getText () {
- checkWidget();
- if ((style & SWT.ARROW) != 0) return "";
- 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, OS.Pt_CB_ACTIVATE);
-}
-
-int hotkeyProc (int widget, int data, int info) {
- if (setFocus ()) click ();
- return OS.Pt_CONTINUE;
-}
-
-int Pt_CB_ACTIVATE (int widget, int info) {
- if ((style & SWT.RADIO) != 0) {
- if ((parent.getStyle () & SWT.NO_RADIO_GROUP) == 0) {
- selectRadio ();
- }
- }
- postEvent (SWT.Selection);
- return OS.Pt_CONTINUE;
-}
-
-int Pt_CB_GOT_FOCUS (int widget, int info) {
- int result = super.Pt_CB_GOT_FOCUS (widget, info);
- // widget could be disposed at this point
- if (handle == 0) return result;
- if ((style & SWT.PUSH) == 0) return result;
- getShell ().setDefaultButton (this, false);
- return result;
-}
-
-int Pt_CB_LOST_FOCUS (int widget, int info) {
- int result = super.Pt_CB_LOST_FOCUS (widget, info);
- // widget could be disposed at this point
- if (handle == 0) return result;
- if ((style & SWT.PUSH) == 0) return result;
- if (getDefault ()) {
- getShell ().setDefaultButton (null, false);
- }
- return result;
-}
-
-void releaseWidget () {
- super.releaseWidget ();
- image = null;
-}
-
+public String getText () {
+ checkWidget();
+ 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, OS.Pt_CB_ACTIVATE);
+}
+
+int hotkeyProc (int widget, int data, int info) {
+ if (setFocus ()) click ();
+ return OS.Pt_CONTINUE;
+}
+
+int Pt_CB_ACTIVATE (int widget, int info) {
+ if ((style & SWT.RADIO) != 0) {
+ if ((parent.getStyle () & SWT.NO_RADIO_GROUP) == 0) {
+ selectRadio ();
+ }
+ }
+ postEvent (SWT.Selection);
+ return OS.Pt_CONTINUE;
+}
+
+int Pt_CB_GOT_FOCUS (int widget, int info) {
+ int result = super.Pt_CB_GOT_FOCUS (widget, info);
+ // widget could be disposed at this point
+ if (handle == 0) return result;
+ if ((style & SWT.PUSH) == 0) return result;
+ getShell ().setDefaultButton (this, false);
+ return result;
+}
+
+int Pt_CB_LOST_FOCUS (int widget, int info) {
+ int result = super.Pt_CB_LOST_FOCUS (widget, info);
+ // widget could be disposed at this point
+ if (handle == 0) return result;
+ if ((style & SWT.PUSH) == 0) return result;
+ if (getDefault ()) {
+ getShell ().setDefaultButton (null, false);
+ }
+ return result;
+}
+
+void releaseWidget () {
+ super.releaseWidget ();
+ image = null;
+}
+
/**
* Removes the listener from the collection of listeners who will
* be notified when the control is selected.
@@ -459,39 +459,39 @@ void releaseWidget () {
* @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 () {
- /*
- * This code is intentionally commented. When two groups
- * of radio buttons with the same parent are separated by
- * another control, the correct behavior should be that
- * the two groups act independently. This is consistent
- * with radio tool and menu items. The commented code
- * implements this behavior.
- */
-// int index = 0;
-// Control [] children = parent._getChildren ();
-// while (index < children.length && children [index] != this) index++;
-// int i = index - 1;
-// while (i >= 0 && children [i].setRadioSelection (false)) --i;
-// int j = index + 1;
-// while (j < children.length && children [j].setRadioSelection (false)) j++;
-// setSelection (true);
- Control [] children = parent._getChildren ();
- for (int i=0; i<children.length; i++) {
- Control child = children [i];
- if (this != child) child.setRadioSelection (false);
- }
- setSelection (true);
-}
-
+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 () {
+ /*
+ * This code is intentionally commented. When two groups
+ * of radio buttons with the same parent are separated by
+ * another control, the correct behavior should be that
+ * the two groups act independently. This is consistent
+ * with radio tool and menu items. The commented code
+ * implements this behavior.
+ */
+// int index = 0;
+// Control [] children = parent._getChildren ();
+// while (index < children.length && children [index] != this) index++;
+// int i = index - 1;
+// while (i >= 0 && children [i].setRadioSelection (false)) --i;
+// int j = index + 1;
+// while (j < children.length && children [j].setRadioSelection (false)) j++;
+// setSelection (true);
+ Control [] children = parent._getChildren ();
+ for (int i=0; i<children.length; i++) {
+ Control child = children [i];
+ if (this != child) child.setRadioSelection (false);
+ }
+ setSelection (true);
+}
+
/**
* Controls how text, images and arrows will be displayed
* in the receiver. The argument should be one of
@@ -508,39 +508,39 @@ void selectRadio () {
* <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.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 align = OS.Pt_LEFT;
- if ((style & SWT.CENTER) != 0) align = OS.Pt_CENTER;
- if ((style & SWT.RIGHT) != 0) align = OS.Pt_RIGHT;
- OS.PtSetResource (handle, OS.Pt_ARG_HORIZONTAL_ALIGNMENT, align, 0);
-}
-
-void setDefault (boolean value) {
- if ((style & SWT.PUSH) == 0) return;
- if (getShell ().parent == null) return;
- OS.PtSetResource (handle, OS.Pt_ARG_BEVEL_CONTRAST, value ? 100 : 20, 0);
-}
-
-boolean setRadioSelection (boolean value) {
- if ((style & SWT.RADIO) == 0) return false;
- if (getSelection () != value) {
- setSelection (value);
- postEvent (SWT.Selection);
- }
- return true;
-}
-
+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.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 align = OS.Pt_LEFT;
+ if ((style & SWT.CENTER) != 0) align = OS.Pt_CENTER;
+ if ((style & SWT.RIGHT) != 0) align = OS.Pt_RIGHT;
+ OS.PtSetResource (handle, OS.Pt_ARG_HORIZONTAL_ALIGNMENT, align, 0);
+}
+
+void setDefault (boolean value) {
+ if ((style & SWT.PUSH) == 0) return;
+ if (getShell ().parent == null) return;
+ OS.PtSetResource (handle, OS.Pt_ARG_BEVEL_CONTRAST, value ? 100 : 20, 0);
+}
+
+boolean setRadioSelection (boolean value) {
+ if ((style & SWT.RADIO) == 0) return false;
+ if (getSelection () != value) {
+ setSelection (value);
+ postEvent (SWT.Selection);
+ }
+ return true;
+}
+
/**
* Sets the selection state of the receiver, if it is of type <code>CHECK</code>,
* <code>RADIO</code>, or <code>TOGGLE</code>.
@@ -557,12 +557,12 @@ boolean setRadioSelection (boolean value) {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public void setSelection (boolean selected) {
- checkWidget();
- if ((style & (SWT.CHECK | SWT.RADIO | SWT.TOGGLE)) == 0) return;
- OS.PtSetResource (handle, OS.Pt_ARG_FLAGS, selected ? OS.Pt_SET : 0, OS.Pt_SET);
-}
-
+public void setSelection (boolean selected) {
+ checkWidget();
+ if ((style & (SWT.CHECK | SWT.RADIO | SWT.TOGGLE)) == 0) return;
+ OS.PtSetResource (handle, OS.Pt_ARG_FLAGS, selected ? OS.Pt_SET : 0, OS.Pt_SET);
+}
+
/**
* Sets the receiver's image to the argument, which may be
* null indicating that no image should be displayed.
@@ -577,23 +577,23 @@ public void setSelection (boolean selected) {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public void setImage (Image image) {
- checkWidget();
- if ((style & SWT.ARROW) != 0) return;
- this.image = image;
- int imageHandle = 0;
- if (image != null) {
- if (image.isDisposed()) error(SWT.ERROR_INVALID_ARGUMENT);
- 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 setImage (Image image) {
+ checkWidget();
+ if ((style & SWT.ARROW) != 0) return;
+ this.image = image;
+ int imageHandle = 0;
+ if (image != null) {
+ if (image.isDisposed()) error(SWT.ERROR_INVALID_ARGUMENT);
+ 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);
+}
+
/**
* Sets the receiver's text.
* <p>
@@ -611,52 +611,52 @@ public void setImage (Image image) {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public void setText (String string) {
- checkWidget();
- if (string == null) error (SWT.ERROR_NULL_ARGUMENT);
- if ((style & SWT.ARROW) != 0) return;
- 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);
- }
- replaceMnemonic (mnemonic, true, true);
- 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);
-}
-
-int traversalCode (int key_sym, PhKeyEvent_t ke) {
- int code = super.traversalCode (key_sym , ke);
- code |= SWT.TRAVERSE_ARROW_NEXT | SWT.TRAVERSE_ARROW_PREVIOUS | SWT.TRAVERSE_MNEMONIC;
- return code;
-}
-
-int widgetClass () {
- if ((style & (SWT.CHECK | SWT.RADIO)) != 0) return OS.PtToggleButton ();
- return OS.PtButton ();
-}
-
-}
+public void setText (String string) {
+ checkWidget();
+ 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);
+ }
+ replaceMnemonic (mnemonic, true, true);
+ 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);
+}
+
+int traversalCode (int key_sym, PhKeyEvent_t ke) {
+ int code = super.traversalCode (key_sym , ke);
+ code |= SWT.TRAVERSE_ARROW_NEXT | SWT.TRAVERSE_ARROW_PREVIOUS | SWT.TRAVERSE_MNEMONIC;
+ return code;
+}
+
+int widgetClass () {
+ if ((style & (SWT.CHECK | SWT.RADIO)) != 0) return OS.PtToggleButton ();
+ return OS.PtButton ();
+}
+
+}
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
index a79a25705e..faecdea2b4 100755
--- 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
@@ -1,15 +1,15 @@
-package org.eclipse.swt.widgets;
-
-/*
+package org.eclipse.swt.widgets;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-import org.eclipse.swt.*;
-import org.eclipse.swt.graphics.*;
-
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+import org.eclipse.swt.*;
+import org.eclipse.swt.graphics.*;
+
/**
* Instances of this class provide a surface for drawing
* arbitrary graphics.
@@ -29,13 +29,13 @@ import org.eclipse.swt.graphics.*;
*
* @see Composite
*/
-public class Canvas extends Composite {
- Caret caret;
-
-Canvas () {
- /* Do nothing */
-}
-
+public class Canvas extends Composite {
+ Caret caret;
+
+Canvas () {
+ /* Do nothing */
+}
+
/**
* Constructs a new instance of this class given its parent
* and a style value describing its behavior and appearance.
@@ -64,10 +64,10 @@ Canvas () {
* @see Widget#checkSubclass
* @see Widget#getStyle
*/
-public Canvas (Composite parent, int style) {
- super (parent, style);
-}
-
+public Canvas (Composite parent, int style) {
+ super (parent, style);
+}
+
/**
* Returns the caret.
* <p>
@@ -86,53 +86,53 @@ public Canvas (Composite parent, int style) {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public Caret getCaret () {
- checkWidget();
- return caret;
-}
-
-int Pt_CB_GOT_FOCUS (int widget, int info) {
- int result = super.Pt_CB_GOT_FOCUS (widget, info);
- if (caret != null) caret.setFocus ();
- return result;
-}
-
-int Pt_CB_LOST_FOCUS (int widget, int info) {
- int result = super.Pt_CB_LOST_FOCUS (widget, info);
- if (caret != null) caret.killFocus ();
- return result;
-}
-
-int drawProc (int widget, int damage) {
- boolean isFocus = caret != null && caret.isFocusCaret ();
- if (isFocus) caret.killFocus ();
- int result = super.drawProc (widget, damage);
- if (isFocus) caret.setFocus ();
- return result;
-}
-
-public void redraw () {
- checkWidget();
- boolean isFocus = caret != null && caret.isFocusCaret ();
- if (isFocus) caret.killFocus ();
- super.redraw ();
- if (isFocus) caret.setFocus ();
-}
-
-public void redraw (int x, int y, int width, int height, boolean all) {
- checkWidget();
- boolean isFocus = caret != null && caret.isFocusCaret ();
- if (isFocus) caret.killFocus ();
- super.redraw (x, y, width, height, all);
- if (isFocus) caret.setFocus ();
-}
-
-void releaseWidget () {
- if (caret != null) caret.releaseResources ();
- caret = null;
- super.releaseWidget();
-}
-
+public Caret getCaret () {
+ checkWidget();
+ return caret;
+}
+
+int Pt_CB_GOT_FOCUS (int widget, int info) {
+ int result = super.Pt_CB_GOT_FOCUS (widget, info);
+ if (caret != null) caret.setFocus ();
+ return result;
+}
+
+int Pt_CB_LOST_FOCUS (int widget, int info) {
+ int result = super.Pt_CB_LOST_FOCUS (widget, info);
+ if (caret != null) caret.killFocus ();
+ return result;
+}
+
+int drawProc (int widget, int damage) {
+ boolean isFocus = caret != null && caret.isFocusCaret ();
+ if (isFocus) caret.killFocus ();
+ int result = super.drawProc (widget, damage);
+ if (isFocus) caret.setFocus ();
+ return result;
+}
+
+public void redraw () {
+ checkWidget();
+ boolean isFocus = caret != null && caret.isFocusCaret ();
+ if (isFocus) caret.killFocus ();
+ super.redraw ();
+ if (isFocus) caret.setFocus ();
+}
+
+public void redraw (int x, int y, int width, int height, boolean all) {
+ checkWidget();
+ boolean isFocus = caret != null && caret.isFocusCaret ();
+ if (isFocus) caret.killFocus ();
+ super.redraw (x, y, width, height, all);
+ if (isFocus) caret.setFocus ();
+}
+
+void releaseWidget () {
+ if (caret != null) caret.releaseResources ();
+ 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
@@ -155,29 +155,29 @@ void releaseWidget () {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public void scroll (int destX, int destY, int x, int y, int width, int height, boolean all) {
- checkWidget();
- if (width <= 0 || height <= 0) return;
- int deltaX = destX - x, deltaY = destY - y;
- if (deltaX == 0 && deltaY == 0) return;
- if (!isVisible ()) return;
- boolean isFocus = caret != null && caret.isFocusCaret ();
- if (isFocus) caret.killFocus ();
- GC gc = new GC (this);
- gc.copyArea (x, y, width, height, destX, destY);
- gc.dispose ();
- if (isFocus) caret.setFocus ();
-}
-
-int setBounds (int x, int y, int width, int height, boolean move, boolean resize, boolean events) {
- checkWidget();
- boolean isFocus = caret != null && caret.isFocusCaret ();
- if (isFocus) caret.killFocus ();
- int result = super.setBounds (x, y, width, height, move, resize, events);
- if (isFocus) caret.setFocus ();
- return result;
-}
-
+public void scroll (int destX, int destY, int x, int y, int width, int height, boolean all) {
+ checkWidget();
+ if (width <= 0 || height <= 0) return;
+ int deltaX = destX - x, deltaY = destY - y;
+ if (deltaX == 0 && deltaY == 0) return;
+ if (!isVisible ()) return;
+ boolean isFocus = caret != null && caret.isFocusCaret ();
+ if (isFocus) caret.killFocus ();
+ GC gc = new GC (this);
+ gc.copyArea (x, y, width, height, destX, destY);
+ gc.dispose ();
+ if (isFocus) caret.setFocus ();
+}
+
+int setBounds (int x, int y, int width, int height, boolean move, boolean resize, boolean events) {
+ checkWidget();
+ boolean isFocus = caret != null && caret.isFocusCaret ();
+ if (isFocus) caret.killFocus ();
+ int result = super.setBounds (x, y, width, height, move, resize, events);
+ if (isFocus) caret.setFocus ();
+ return result;
+}
+
/**
* Sets the receiver's caret.
* <p>
@@ -198,23 +198,23 @@ int setBounds (int x, int y, int width, int height, boolean move, boolean resize
* <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) {
- if (newCaret.isDisposed()) error(SWT.ERROR_INVALID_ARGUMENT);
- newCaret.setFocus ();
- }
- }
-}
-
-public void setFont (Font font) {
- checkWidget();
- super.setFont (font);
- if (caret != null) caret.setFont (font);
-}
-}
+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) {
+ if (newCaret.isDisposed()) error(SWT.ERROR_INVALID_ARGUMENT);
+ newCaret.setFocus ();
+ }
+ }
+}
+
+public void setFont (Font font) {
+ checkWidget();
+ super.setFont (font);
+ if (caret != null) caret.setFont (font);
+}
+}
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
index 25d5a1a2f1..42bb7fdd31 100755
--- 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
@@ -1,16 +1,16 @@
-package org.eclipse.swt.widgets;
-
-/*
+package org.eclipse.swt.widgets;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-import org.eclipse.swt.internal.photon.*;
-import org.eclipse.swt.*;
-import org.eclipse.swt.graphics.*;
-
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+import org.eclipse.swt.internal.photon.*;
+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.
@@ -25,14 +25,14 @@ import org.eclipse.swt.graphics.*;
* within the SWT implementation.
* </p>
*/
-public class Caret extends Widget {
- Canvas parent;
- int x, y, width, height;
- boolean isVisible, isShowing;
- int blinkRate = 0;
- Image image;
- Font font;
-
+public class Caret extends Widget {
+ Canvas parent;
+ int x, y, width, height;
+ boolean isVisible, isShowing;
+ int blinkRate = 0;
+ Image image;
+ Font font;
+
/**
* Constructs a new instance of this class given its parent
* and a style value describing its behavior and appearance.
@@ -61,53 +61,53 @@ public class Caret extends Widget {
* @see Widget#checkSubclass
* @see Widget#getStyle
*/
-// 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 prevContext = OS.PgSetGC (phGC);
- OS.PgSetRegion (OS.PtWidgetRid (handle));
- OS.PgSetDrawMode (OS.Pg_DRAWMODE_XOR);
- OS.PgSetFillColor (0xFFFFFF);
- int nWidth = width, nHeight = height;
- if (image != null) {
- Rectangle rect = image.getBounds ();
- nWidth = rect.width;
- nHeight = rect.height;
- }
- if (nWidth <= 0) nWidth = 2;
- OS.PgDrawIRect (x, y, x + nWidth - 1, y + nHeight - 1, OS.Pg_DRAW_FILL);
- OS.PgSetGC (prevContext);
- OS.PgDestroyGC (phGC);
- return true;
-}
-
+// 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 prevContext = OS.PgSetGC (phGC);
+ OS.PgSetRegion (OS.PtWidgetRid (handle));
+ OS.PgSetDrawMode (OS.Pg_DRAWMODE_XOR);
+ OS.PgSetFillColor (0xFFFFFF);
+ int nWidth = width, nHeight = height;
+ if (image != null) {
+ Rectangle rect = image.getBounds ();
+ nWidth = rect.width;
+ nHeight = rect.height;
+ }
+ if (nWidth <= 0) nWidth = 2;
+ OS.PgDrawIRect (x, y, x + nWidth - 1, y + nHeight - 1, OS.Pg_DRAW_FILL);
+ OS.PgSetGC (prevContext);
+ OS.PgDestroyGC (phGC);
+ return true;
+}
+
/**
* Returns a rectangle describing the receiver's size and location
* relative to its parent (or its display if its parent is null).
@@ -119,21 +119,21 @@ boolean drawCaret () {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public Rectangle getBounds () {
- checkWidget();
- if (image != null) {
- Rectangle rect = image.getBounds ();
- return new Rectangle (x, y, rect.width, rect.height);
- }
- 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 Rectangle getBounds () {
+ checkWidget();
+ if (image != null) {
+ Rectangle rect = image.getBounds ();
+ return new Rectangle (x, y, rect.width, rect.height);
+ }
+ 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.
*
@@ -144,12 +144,12 @@ public Display getDisplay () {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public Font getFont () {
- checkWidget();
- if (font != null) return font;
- return parent.getFont ();
-}
-
+public Font getFont () {
+ checkWidget();
+ if (font != null) return font;
+ return parent.getFont ();
+}
+
/**
* Returns the image that the receiver will use to paint the caret.
*
@@ -160,11 +160,11 @@ public Font getFont () {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public Image getImage () {
- checkWidget();
- return image;
-}
-
+public Image getImage () {
+ checkWidget();
+ return image;
+}
+
/**
* Returns a point describing the receiver's location relative
* to its parent (or its display if its parent is null).
@@ -176,11 +176,11 @@ public Image getImage () {
* <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);
-}
-
+public Point getLocation () {
+ checkWidget();
+ return new Point (x, y);
+}
+
/**
* Returns the receiver's parent, which must be a <code>Canvas</code>.
*
@@ -191,11 +191,11 @@ public Point getLocation () {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public Canvas getParent () {
- checkWidget();
- return parent;
-}
-
+public Canvas getParent () {
+ checkWidget();
+ return parent;
+}
+
/**
* Returns a point describing the receiver's size.
*
@@ -206,15 +206,15 @@ public Canvas getParent () {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public Point getSize () {
- checkWidget();
- if (image != null) {
- Rectangle rect = image.getBounds ();
- return new Point (rect.width, rect.height);
- }
- return new Point (width, height);
-}
-
+public Point getSize () {
+ checkWidget();
+ if (image != null) {
+ Rectangle rect = image.getBounds ();
+ return new Point (rect.width, rect.height);
+ }
+ return new Point (width, height);
+}
+
/**
* Returns <code>true</code> if the receiver is visible, and
* <code>false</code> otherwise.
@@ -232,65 +232,65 @@ public Point getSize () {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public boolean getVisible () {
- checkWidget();
- return isVisible;
-}
-
-boolean hideCaret () {
- if (!isShowing) return true;
- isShowing = false;
- return drawCaret ();
-}
-
-/**
- * Returns <code>true</code> if the receiver is visible and all
- * of the receiver's ancestors are visible and <code>false</code>
- * otherwise.
- *
- * @return the receiver's visibility state
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see #getVisible
+public boolean getVisible () {
+ checkWidget();
+ return isVisible;
+}
+
+boolean hideCaret () {
+ if (!isShowing) return true;
+ isShowing = false;
+ return drawCaret ();
+}
+
+/**
+ * Returns <code>true</code> if the receiver is visible and all
+ * of the receiver's ancestors are visible and <code>false</code>
+ * otherwise.
+ *
+ * @return the receiver's visibility state
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see #getVisible
*/
-public boolean isVisible () {
- checkWidget();
- return isVisible && parent.isVisible () && parent.hasFocus ();
-}
-
-boolean isFocusCaret () {
-// Display display = getDisplay ();
-// return this == display.currentCaret;
- return parent.hasFocus ();
-}
-
-void killFocus () {
-// Display display = getDisplay ();
-// if (display.currentCaret != this) return;
-// display.setCurrentCaret (null);
- if (isVisible) hideCaret ();
-}
-
-void releaseChild () {
- super.releaseChild ();
- if (this == parent.getCaret ()) parent.setCaret (null);
-}
-
-void releaseWidget () {
- super.releaseWidget ();
-// Display display = getDisplay ();
-// if (display.currentCaret == this) {
- hideCaret ();
-// display.setCurrentCaret (null);
-// }
- parent = null;
- image = null;
-}
-
+public boolean isVisible () {
+ checkWidget();
+ return isVisible && parent.isVisible () && parent.hasFocus ();
+}
+
+boolean isFocusCaret () {
+// Display display = getDisplay ();
+// return this == display.currentCaret;
+ return parent.hasFocus ();
+}
+
+void killFocus () {
+// Display display = getDisplay ();
+// if (display.currentCaret != this) return;
+// display.setCurrentCaret (null);
+ if (isVisible) hideCaret ();
+}
+
+void releaseChild () {
+ super.releaseChild ();
+ if (this == parent.getCaret ()) parent.setCaret (null);
+}
+
+void releaseWidget () {
+ super.releaseWidget ();
+// Display display = getDisplay ();
+// if (display.currentCaret == this) {
+ hideCaret ();
+// display.setCurrentCaret (null);
+// }
+ parent = null;
+ image = null;
+}
+
/**
* Sets the receiver's size and location to the rectangular
* area specified by the arguments. The <code>x</code> and
@@ -307,42 +307,42 @@ void releaseWidget () {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public void setBounds (int x, int y, int width, int height) {
- checkWidget();
- if (this.x == x && this.y == y && this.width == width && this.height == height) return;
- boolean isFocus = isFocusCaret ();
- if (isFocus) hideCaret ();
- this.x = x; this.y = y;
- this.width = width; this.height = height;
- if (isFocus) showCaret ();
-}
-
-/**
- * Sets the receiver's size and location to the rectangular
- * area specified by the argument. The <code>x</code> and
- * <code>y</code> fields of the rectangle are relative to
- * the receiver's parent (or its display if its parent is null).
- *
- * @param rect the new bounds for the receiver
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public void setBounds (Rectangle rect) {
- checkWidget();
- if (rect == null) error (SWT.ERROR_NULL_ARGUMENT);
- setBounds (rect.x, rect.y, rect.width, rect.height);
-}
-
-void setFocus () {
-// Display display = getDisplay ();
-// if (display.currentCaret == this) return;
-// display.setCurrentCaret (this);
- if (isVisible) showCaret ();
-}
-
+public void setBounds (int x, int y, int width, int height) {
+ checkWidget();
+ if (this.x == x && this.y == y && this.width == width && this.height == height) return;
+ boolean isFocus = isFocusCaret ();
+ if (isFocus) hideCaret ();
+ this.x = x; this.y = y;
+ this.width = width; this.height = height;
+ if (isFocus) showCaret ();
+}
+
+/**
+ * Sets the receiver's size and location to the rectangular
+ * area specified by the argument. The <code>x</code> and
+ * <code>y</code> fields of the rectangle are relative to
+ * the receiver's parent (or its display if its parent is null).
+ *
+ * @param rect the new bounds for the receiver
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setBounds (Rectangle rect) {
+ checkWidget();
+ if (rect == null) error (SWT.ERROR_NULL_ARGUMENT);
+ setBounds (rect.x, rect.y, rect.width, rect.height);
+}
+
+void setFocus () {
+// Display display = getDisplay ();
+// if (display.currentCaret == this) return;
+// display.setCurrentCaret (this);
+ if (isVisible) showCaret ();
+}
+
/**
* Sets the font that the receiver will use to paint textual information
* to the font specified by the argument, or to the default font for that
@@ -358,14 +358,14 @@ void setFocus () {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public void setFont (Font font) {
- checkWidget();
- if (font != null && font.isDisposed ()) {
- error (SWT.ERROR_INVALID_ARGUMENT);
- }
- this.font = font;
-}
-
+public void setFont (Font font) {
+ checkWidget();
+ if (font != null && font.isDisposed ()) {
+ error (SWT.ERROR_INVALID_ARGUMENT);
+ }
+ this.font = font;
+}
+
/**
* Sets the image that the receiver will use to paint the caret
* to the image specified by the argument, or to the default
@@ -381,17 +381,17 @@ public void setFont (Font font) {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public void setImage (Image image) {
- checkWidget();
- if (image != null && image.isDisposed ()) {
- error (SWT.ERROR_INVALID_ARGUMENT);
- }
- boolean isFocus = isFocusCaret ();
- if (isFocus) hideCaret ();
- this.image = image;
- if (isFocus) showCaret ();
-}
-
+public void setImage (Image image) {
+ checkWidget();
+ if (image != null && image.isDisposed ()) {
+ error (SWT.ERROR_INVALID_ARGUMENT);
+ }
+ boolean isFocus = isFocusCaret ();
+ if (isFocus) hideCaret ();
+ this.image = image;
+ if (isFocus) showCaret ();
+}
+
/**
* Sets the receiver's location to the point specified by
* the arguments which are relative to the receiver's
@@ -405,11 +405,11 @@ public void setImage (Image image) {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public void setLocation (int x, int y) {
- checkWidget();
- setBounds (x, y, width, height);
-}
-
+public void setLocation (int x, int y) {
+ checkWidget();
+ setBounds (x, y, width, height);
+}
+
/**
* Sets the receiver's location to the point specified by
* the argument which is relative to the receiver's
@@ -422,12 +422,12 @@ public void setLocation (int x, int y) {
* <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);
-}
-
+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.
*
@@ -439,11 +439,11 @@ public void setLocation (Point location) {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public void setSize (int width, int height) {
- checkWidget();
- setBounds (x, y, width, height);
-}
-
+public void setSize (int width, int height) {
+ checkWidget();
+ setBounds (x, y, width, height);
+}
+
/**
* Sets the receiver's size to the point specified by the argument.
*
@@ -458,12 +458,12 @@ public void setSize (int width, int height) {
* <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);
-}
-
+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.
@@ -480,21 +480,21 @@ public void setSize (Point size) {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public void setVisible (boolean visible) {
- checkWidget();
- if (visible == isVisible) return;
- isVisible = visible;
- if (!isFocusCaret ()) return;
- if (isVisible) {
- showCaret ();
- } else {
- hideCaret ();
- }
-}
-
-boolean showCaret () {
- if (isShowing) return true;
- isShowing = true;
- return drawCaret ();
-}
-}
+public void setVisible (boolean visible) {
+ checkWidget();
+ if (visible == isVisible) return;
+ isVisible = visible;
+ if (!isFocusCaret ()) return;
+ if (isVisible) {
+ showCaret ();
+ } else {
+ hideCaret ();
+ }
+}
+
+boolean showCaret () {
+ if (isShowing) return true;
+ isShowing = true;
+ return drawCaret ();
+}
+}
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
index 948990b97a..53812e51b8 100755
--- 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
@@ -1,17 +1,17 @@
-package org.eclipse.swt.widgets;
-
-/*
+package org.eclipse.swt.widgets;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-import org.eclipse.swt.internal.*;
-import org.eclipse.swt.internal.photon.*;
-import org.eclipse.swt.*;
-import org.eclipse.swt.graphics.*;
-
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+import org.eclipse.swt.internal.*;
+import org.eclipse.swt.internal.photon.*;
+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.
@@ -26,9 +26,9 @@ import org.eclipse.swt.graphics.*;
* within the SWT implementation.
* </p>
*/
-public class ColorDialog extends Dialog {
- RGB rgb;
-
+public class ColorDialog extends Dialog {
+ RGB rgb;
+
/**
* Constructs a new instance of this class given only its parent.
*
@@ -46,10 +46,10 @@ public class ColorDialog extends Dialog {
* @see Widget#checkSubclass
* @see Widget#getStyle
*/
-public ColorDialog (Shell parent) {
- this (parent, SWT.PRIMARY_MODAL);
-}
-
+public ColorDialog (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.
@@ -78,11 +78,11 @@ public ColorDialog (Shell parent) {
* @see Widget#checkSubclass
* @see Widget#getStyle
*/
-public ColorDialog (Shell parent, int style) {
- super (parent, style);
- checkSubclass ();
-}
-
+public ColorDialog (Shell parent, int style) {
+ super (parent, style);
+ checkSubclass ();
+}
+
/**
* Returns the currently selected color in the receiver.
*
@@ -90,10 +90,10 @@ public ColorDialog (Shell parent, int style) {
*
* @see PaletteData#getRGBs
*/
-public RGB getRGB () {
- return rgb;
-}
-
+public RGB getRGB () {
+ return rgb;
+}
+
/**
* Makes the receiver visible and brings it to the front
* of the display.
@@ -107,27 +107,27 @@ public RGB getRGB () {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public RGB open () {
- int parentHandle = 0;
- if (parent != null && OS.PtWidgetIsRealized(parent.shellHandle)) {
- 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 RGB open () {
+ int parentHandle = 0;
+ if (parent != null && OS.PtWidgetIsRealized(parent.shellHandle)) {
+ 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;
+}
+
/**
* Returns the receiver's selected color to be the argument.
*
@@ -137,8 +137,8 @@ public RGB open () {
*
* @see PaletteData#getRGBs
*/
-public void setRGB (RGB rgb) {
- this.rgb = rgb;
-}
-
-}
+public void setRGB (RGB rgb) {
+ this.rgb = rgb;
+}
+
+}
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
index b2d0abd4b1..3cc13465d0 100755
--- 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
@@ -1,18 +1,18 @@
-package org.eclipse.swt.widgets;
-
-/*
+package org.eclipse.swt.widgets;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-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.*;
-
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+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.*;
+
/**
* Instances of this class are controls that allow the user
* to choose an item from a list of items, or optionally
@@ -49,22 +49,22 @@ import org.eclipse.swt.events.*;
*
* @see List
*/
-public class Combo extends Composite {
- /**
- * 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 = 0x7FFFFFFF;
- }
-
+public class Combo extends Composite {
+ /**
+ * 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 = 0x7FFFFFFF;
+ }
+
/**
* Constructs a new instance of this class given its parent
* and a style value describing its behavior and appearance.
@@ -95,124 +95,124 @@ public class Combo extends Composite {
* @see Widget#checkSubclass
* @see Widget#getStyle
*/
-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) {
- checkWidget();
- //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 textWidget = OS.PtWidgetChildBack(handle);
- OS.PtWidgetPreferredSize(textWidget, dim);
- height += dim.h;
- PhRect_t rect = new PhRect_t ();
- PhArea_t area = new PhArea_t ();
- OS.PtSetAreaFromWidgetCanvas (textWidget, rect, area);
- width += area.size_w;
-
- /* Calculate maximum text width */
- int [] args = new int [] {
- OS.Pt_ARG_LIST_ITEM_COUNT, 0, 0, // 1
- OS.Pt_ARG_ITEMS, 0, 0, // 4
- OS.Pt_ARG_TEXT_FONT, 0, 0, // 7
- OS.Pt_ARG_TEXT_STRING, 0, 0, // 10
- };
- OS.PtGetResources (handle, args.length / 3, args);
- int maxWidth = 0;
- rect = new PhRect_t();
- int str = args [10];
- int font = args [7];
- if (str != 0) {
- int length = OS.strlen (str);
- if (length > 0) {
- OS.PfExtentText(rect, null, font, str, length);
- maxWidth = Math.max(maxWidth, rect.lr_x - rect.ul_x + 1);
- }
- }
- int count = args [1];
- int [] buffer = new int [1];
- for (int i = 0; i < count; i++) {
- OS.memmove (buffer, args [4] + (i * 4), 4);
- str = buffer [0];
- int length = OS.strlen (str);
- if (length > 0) {
- OS.PfExtentText(rect, null, font, str, length);
- maxWidth = Math.max(maxWidth, rect.lr_x - rect.ul_x + 1);
- }
- }
- if (maxWidth == 0) maxWidth = DEFAULT_WIDTH;
- int [] args1 = new int [] {
- OS.Pt_ARG_MARGIN_WIDTH, 0, 0, // 1
- OS.Pt_ARG_MARGIN_LEFT, 0, 0, // 4
- OS.Pt_ARG_MARGIN_RIGHT, 0, 0, // 7
- };
- OS.PtGetResources (textWidget, args1.length / 3, args1);
- maxWidth += args1 [1] + args1 [4] + args1 [7];
-
- 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) {
- state |= HANDLE;
- Display display = getDisplay ();
- int clazz = display.PtComboBox;
- int parentHandle = parent.parentingHandle ();
- 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 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) {
+ checkWidget();
+ //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 textWidget = OS.PtWidgetChildBack(handle);
+ OS.PtWidgetPreferredSize(textWidget, dim);
+ height += dim.h;
+ PhRect_t rect = new PhRect_t ();
+ PhArea_t area = new PhArea_t ();
+ OS.PtSetAreaFromWidgetCanvas (textWidget, rect, area);
+ width += area.size_w;
+
+ /* Calculate maximum text width */
+ int [] args = new int [] {
+ OS.Pt_ARG_LIST_ITEM_COUNT, 0, 0, // 1
+ OS.Pt_ARG_ITEMS, 0, 0, // 4
+ OS.Pt_ARG_TEXT_FONT, 0, 0, // 7
+ OS.Pt_ARG_TEXT_STRING, 0, 0, // 10
+ };
+ OS.PtGetResources (handle, args.length / 3, args);
+ int maxWidth = 0;
+ rect = new PhRect_t();
+ int str = args [10];
+ int font = args [7];
+ if (str != 0) {
+ int length = OS.strlen (str);
+ if (length > 0) {
+ OS.PfExtentText(rect, null, font, str, length);
+ maxWidth = Math.max(maxWidth, rect.lr_x - rect.ul_x + 1);
+ }
+ }
+ int count = args [1];
+ int [] buffer = new int [1];
+ for (int i = 0; i < count; i++) {
+ OS.memmove (buffer, args [4] + (i * 4), 4);
+ str = buffer [0];
+ int length = OS.strlen (str);
+ if (length > 0) {
+ OS.PfExtentText(rect, null, font, str, length);
+ maxWidth = Math.max(maxWidth, rect.lr_x - rect.ul_x + 1);
+ }
+ }
+ if (maxWidth == 0) maxWidth = DEFAULT_WIDTH;
+ int [] args1 = new int [] {
+ OS.Pt_ARG_MARGIN_WIDTH, 0, 0, // 1
+ OS.Pt_ARG_MARGIN_LEFT, 0, 0, // 4
+ OS.Pt_ARG_MARGIN_RIGHT, 0, 0, // 7
+ };
+ OS.PtGetResources (textWidget, args1.length / 3, args1);
+ maxWidth += args1 [1] + args1 [4] + args1 [7];
+
+ 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) {
+ state |= HANDLE;
+ Display display = getDisplay ();
+ int clazz = display.PtComboBox;
+ int parentHandle = parent.parentingHandle ();
+ 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);
+}
+
/**
* 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
@@ -225,19 +225,19 @@ void createHandle (int index) {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public void deselect (int index) {
- checkWidget();
- 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 deselect (int index) {
+ checkWidget();
+ 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);
+ }
+}
+
/**
* Deselects all selected items in the receiver's list.
* <p>
@@ -252,15 +252,15 @@ public void deselect (int index) {
*
* @see #clearSelection
*/
-public void deselectAll () {
- checkWidget();
- 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 deselectAll () {
+ checkWidget();
+ 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);
+}
+
/**
* Adds the argument to the end of the receiver's list.
*
@@ -279,16 +279,16 @@ public void deselectAll () {
*
* @see #add(String,int)
*/
-public void add (String string) {
- checkWidget();
- if (string == null) error (SWT.ERROR_NULL_ARGUMENT);
- byte [] buffer = Converter.wcsToMbcs (null, string, true);
- int 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) {
+ checkWidget();
+ 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);
+}
+
/**
* Adds the argument to the receiver's list at the given
* zero-relative index.
@@ -315,23 +315,23 @@ public void add (String string) {
*
* @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 (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 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 (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);
+ }
+}
+
/**
* Adds the listener to the collection of listeners who will
* be notified when the receiver's text is modified, by sending
@@ -351,13 +351,13 @@ public void add (String string, int index) {
* @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);
-}
-
+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
@@ -382,18 +382,18 @@ public void addModifyListener (ModifyListener listener) {
* @see #removeSelectionListener
* @see SelectionEvent
*/
-public void addSelectionListener(SelectionListener listener) {
- checkWidget();
- if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
- TypedListener typedListener = new TypedListener (listener);
- addListener (SWT.Selection,typedListener);
- addListener (SWT.DefaultSelection,typedListener);
-}
-
-protected void checkSubclass () {
- if (!isValidSubclass ()) error (SWT.ERROR_INVALID_SUBCLASS);
-}
-
+public 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);
+}
+
/**
* Sets the selection in the receiver's text field to an empty
* selection starting just before the first character. If the
@@ -411,92 +411,92 @@ protected void checkSubclass () {
*
* @see #deselectAll
*/
-public void clearSelection () {
- checkWidget();
- OS.PtTextSetSelection (handle, new int [] {0}, new int [] {0});
-}
-
-
-/**
- * Copies the selected text.
- * <p>
- * The current selection is copied to the clipboard.
- * </p>
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @since 2.1
- */
-public void copy () {
- checkWidget();
- 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);
-}
-
-/**
- * Cuts the selected text.
- * <p>
- * The current selection is first copied to the
- * clipboard and then deleted from the widget.
- * </p>
- *
- * @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>
- *
- * @since 2.1
- */
-public void cut () {
- checkWidget();
- 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);
-}
-
-byte [] defaultFont () {
- Display display = getDisplay ();
- return display.TEXT_FONT;
-}
-
-void deregister () {
- super.deregister ();
- int child = OS.PtWidgetChildBack (handle);
- WidgetTable.remove (child);
-}
-
-int focusHandle () {
-
- /*
- * Fetuare in Photon. The combo box does not receive
- * Pt_CB_GOT_FOCUS and Pt_CB_LOST_FOCUS callbacks itself.
- * Only the internal PtText receives them. The fix is to
- * add these callbacks in the internal PtText.
- */
- return OS.PtWidgetChildBack (handle);
-}
-
+public void clearSelection () {
+ checkWidget();
+ OS.PtTextSetSelection (handle, new int [] {0}, new int [] {0});
+}
+
+
+/**
+ * Copies the selected text.
+ * <p>
+ * The current selection is copied to the clipboard.
+ * </p>
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @since 2.1
+ */
+public void copy () {
+ checkWidget();
+ 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);
+}
+
+/**
+ * Cuts the selected text.
+ * <p>
+ * The current selection is first copied to the
+ * clipboard and then deleted from the widget.
+ * </p>
+ *
+ * @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>
+ *
+ * @since 2.1
+ */
+public void cut () {
+ checkWidget();
+ 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);
+}
+
+byte [] defaultFont () {
+ Display display = getDisplay ();
+ return display.TEXT_FONT;
+}
+
+void deregister () {
+ super.deregister ();
+ int child = OS.PtWidgetChildBack (handle);
+ WidgetTable.remove (child);
+}
+
+int focusHandle () {
+
+ /*
+ * Fetuare in Photon. The combo box does not receive
+ * Pt_CB_GOT_FOCUS and Pt_CB_LOST_FOCUS callbacks itself.
+ * Only the internal PtText receives them. The fix is to
+ * add these callbacks in the internal PtText.
+ */
+ return OS.PtWidgetChildBack (handle);
+}
+
/**
* Returns the item at the given, zero-relative index in the
* receiver's list. Throws an exception if the index is out
@@ -516,25 +516,25 @@ int focusHandle () {
* <li>ERROR_CANNOT_GET_ITEM - if the operation fails because of an operating system failure</li>
* </ul>
*/
-public String getItem (int index) {
- checkWidget();
- 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 String getItem (int index) {
+ checkWidget();
+ 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);
+}
+
/**
* Returns the number of items contained in the receiver's list.
*
@@ -548,13 +548,13 @@ public String getItem (int index) {
* <li>ERROR_CANNOT_GET_COUNT - if the operation fails because of an operating system failure</li>
* </ul>
*/
-public int getItemCount () {
- checkWidget();
- int [] args = new int [] {OS.Pt_ARG_LIST_ITEM_COUNT, 0, 0};
- OS.PtGetResources (handle, args.length / 3, args);
- return args [1];
-}
-
+public int getItemCount () {
+ checkWidget();
+ int [] args = new int [] {OS.Pt_ARG_LIST_ITEM_COUNT, 0, 0};
+ OS.PtGetResources (handle, args.length / 3, args);
+ return args [1];
+}
+
/**
* Returns the height of the area which would be used to
* display <em>one</em> of the items in the receiver's list.
@@ -569,12 +569,12 @@ public int getItemCount () {
* <li>ERROR_CANNOT_GET_ITEM_HEIGHT - if the operation fails because of an operating system failure</li>
* </ul>
*/
-public int getItemHeight () {
- checkWidget();
- //NOT DONE - NOT NEEDED
- return 0;
-}
-
+public int getItemHeight () {
+ checkWidget();
+ //NOT DONE - NOT NEEDED
+ return 0;
+}
+
/**
* Returns an array of <code>String</code>s which are the items
* in the receiver's list.
@@ -594,30 +594,30 @@ public int getItemHeight () {
* <li>ERROR_CANNOT_GET_ITEM - if the operation fails because of an operating system failure</li>
* </ul>
*/
-public String [] getItems () {
- checkWidget();
- 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;
-}
-
-String getNameText () {
- return getText ();
-}
-
+public String [] getItems () {
+ checkWidget();
+ 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;
+}
+
+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
@@ -632,28 +632,28 @@ String getNameText () {
* <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)) {
- 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 Point getSelection () {
+ checkWidget();
+ 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]);
+}
+
/**
* Returns the zero-relative index of the item which is currently
* selected in the receiver's list, or -1 if no item is selected.
@@ -665,19 +665,19 @@ public Point getSelection () {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public int getSelectionIndex () {
- checkWidget();
- 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 getSelectionIndex () {
+ checkWidget();
+ 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;
+}
+
/**
* Returns a string containing a copy of the contents of the
* receiver's text field.
@@ -689,18 +689,18 @@ public int getSelectionIndex () {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public String getText () {
- checkWidget();
- 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 String getText () {
+ checkWidget();
+ 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);
+}
+
/**
* Returns the height of the receivers's text field.
*
@@ -714,19 +714,19 @@ public String getText () {
* <li>ERROR_CANNOT_GET_ITEM_HEIGHT - if the operation fails because of an operating system failure</li>
* </ul>
*/
-public int getTextHeight () {
- checkWidget();
- //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 getTextHeight () {
+ checkWidget();
+ //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;
+}
+
/**
* Returns the maximum number of characters that the receiver's
* text field is capable of holding. If this has not been changed
@@ -740,24 +740,24 @@ public int getTextHeight () {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public int getTextLimit () {
- checkWidget();
- int [] args = new int [] {OS.Pt_ARG_MAX_LENGTH, 0, 0};
- OS.PtGetResources (handle, args.length / 3, args);
- return args [1];
-}
-
-boolean hasFocus () {
- return OS.PtIsFocused (handle) != 0;
-}
-
-void hookEvents () {
- super.hookEvents ();
- int windowProc = getDisplay ().windowProc;
- OS.PtAddCallback (handle, OS.Pt_CB_SELECTION, windowProc, OS.Pt_CB_SELECTION);
- OS.PtAddCallback (handle, OS.Pt_CB_TEXT_CHANGED, windowProc, OS.Pt_CB_TEXT_CHANGED);
-}
-
+public int getTextLimit () {
+ checkWidget();
+ int [] args = new int [] {OS.Pt_ARG_MAX_LENGTH, 0, 0};
+ OS.PtGetResources (handle, args.length / 3, args);
+ return args [1];
+}
+
+boolean hasFocus () {
+ return OS.PtIsFocused (handle) != 0;
+}
+
+void hookEvents () {
+ super.hookEvents ();
+ int windowProc = getDisplay ().windowProc;
+ OS.PtAddCallback (handle, OS.Pt_CB_SELECTION, windowProc, OS.Pt_CB_SELECTION);
+ OS.PtAddCallback (handle, OS.Pt_CB_TEXT_CHANGED, windowProc, OS.Pt_CB_TEXT_CHANGED);
+}
+
/**
* Searches the receiver's list starting at the first item
* (index 0) until an item is found that is equal to the
@@ -775,12 +775,12 @@ void hookEvents () {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public int indexOf (String string) {
- checkWidget();
- byte [] buffer = Converter.wcsToMbcs (null, string, true);
- return OS.PtListItemPos (handle, buffer) - 1;
-}
-
+public int indexOf (String string) {
+ checkWidget();
+ byte [] buffer = Converter.wcsToMbcs (null, string, true);
+ return OS.PtListItemPos (handle, buffer) - 1;
+}
+
/**
* Searches the receiver's list starting at the given,
* zero-relative index until an item is found that is equal
@@ -799,80 +799,80 @@ public int indexOf (String string) {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public int indexOf (String string, int start) {
- checkWidget();
- if (string == null) error (SWT.ERROR_NULL_ARGUMENT);
- if (start == 0) return indexOf(string);
- 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 count = args [1];
- if (!(0 <= start && start < count)) return -1;
- int [] item = new int [1];
- for (int index=start; index<count; index++) {
- OS.memmove (item, args [4] + (index * 4), 4);
- int length = OS.strlen (item [0]);
- byte [] buffer = new byte [length];
- OS.memmove (buffer, item [0], length);
- if (string.equals(new String (Converter.mbcsToWcs (null, buffer)))) return index;
- }
- return -1;
-}
-
-/**
- * Pastes text from clipboard.
- * <p>
- * The selected text is deleted from the widget
- * and new text inserted from the clipboard.
- * </p>
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @since 2.1
- */
-public void paste () {
- checkWidget();
- 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 Pt_CB_SELECTION (int widget, 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;
-}
-
-int Pt_CB_TEXT_CHANGED (int widget, int info) {
- sendEvent (SWT.Modify);
- return OS.Pt_CONTINUE;
-}
-
-void register () {
- super.register ();
- int child = OS.PtWidgetChildBack (handle);
- WidgetTable.put (child, this);
-}
-
+public int indexOf (String string, int start) {
+ checkWidget();
+ if (string == null) error (SWT.ERROR_NULL_ARGUMENT);
+ if (start == 0) return indexOf(string);
+ 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 count = args [1];
+ if (!(0 <= start && start < count)) return -1;
+ int [] item = new int [1];
+ for (int index=start; index<count; index++) {
+ OS.memmove (item, args [4] + (index * 4), 4);
+ int length = OS.strlen (item [0]);
+ byte [] buffer = new byte [length];
+ OS.memmove (buffer, item [0], length);
+ if (string.equals(new String (Converter.mbcsToWcs (null, buffer)))) return index;
+ }
+ return -1;
+}
+
+/**
+ * Pastes text from clipboard.
+ * <p>
+ * The selected text is deleted from the widget
+ * and new text inserted from the clipboard.
+ * </p>
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @since 2.1
+ */
+public void paste () {
+ checkWidget();
+ 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 Pt_CB_SELECTION (int widget, 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;
+}
+
+int Pt_CB_TEXT_CHANGED (int widget, int info) {
+ sendEvent (SWT.Modify);
+ return OS.Pt_CONTINUE;
+}
+
+void register () {
+ super.register ();
+ int child = OS.PtWidgetChildBack (handle);
+ WidgetTable.put (child, this);
+}
+
/**
* Removes the items from the receiver's list which are
* between the given zero-relative start and end
@@ -892,21 +892,21 @@ void register () {
* <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 [] 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);
- if ((style & SWT.READ_ONLY) !=0) {
- if (args [1] == count) OS.PtSetResource (handle, OS.Pt_ARG_TEXT_STRING, 0, 0);
- }
-}
-
+public void remove (int start, int end) {
+ checkWidget();
+ 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);
+ if ((style & SWT.READ_ONLY) !=0) {
+ if (args [1] == count) OS.PtSetResource (handle, OS.Pt_ARG_TEXT_STRING, 0, 0);
+ }
+}
+
/**
* Removes the item from the receiver's list at the given
* zero-relative index.
@@ -924,18 +924,18 @@ public void remove (int start, int end) {
* <li>ERROR_ITEM_NOT_REMOVED - if the operation fails because of an operating system failure</li>
* </ul>
*/
-public void remove (int index) {
- checkWidget();
- 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);
- if ((style & SWT.READ_ONLY) !=0) {
- if (args [1] == 1) OS.PtSetResource (handle, OS.Pt_ARG_TEXT_STRING, 0, 0);
- }
-}
-
+public void remove (int index) {
+ checkWidget();
+ 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);
+ if ((style & SWT.READ_ONLY) !=0) {
+ if (args [1] == 1) OS.PtSetResource (handle, OS.Pt_ARG_TEXT_STRING, 0, 0);
+ }
+}
+
/**
* Searches the receiver's list starting at the first item
* until an item is found that is equal to the argument,
@@ -955,13 +955,13 @@ public void remove (int index) {
* <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_ITEM_NOT_REMOVED);
- remove (index);
-}
-
+public void remove (String string) {
+ checkWidget();
+ int index = indexOf (string, 0);
+ if (index == -1) error (SWT.ERROR_ITEM_NOT_REMOVED);
+ remove (index);
+}
+
/**
* Removes all of the items from the receiver's list.
* <p>
@@ -970,13 +970,13 @@ public void remove (String string) {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public void removeAll () {
- checkWidget();
- OS.PtListDeleteAllItems (handle);
- OS.PtSetResource (handle, OS.Pt_ARG_TEXT_STRING, 0, 0);
- sendEvent (SWT.Modify);
-}
-
+public void removeAll () {
+ checkWidget();
+ OS.PtListDeleteAllItems (handle);
+ OS.PtSetResource (handle, OS.Pt_ARG_TEXT_STRING, 0, 0);
+ sendEvent (SWT.Modify);
+}
+
/**
* Removes the listener from the collection of listeners who will
* be notified when the receiver's text is modified.
@@ -994,13 +994,13 @@ public void removeAll () {
* @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);
-}
-
+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.
@@ -1018,14 +1018,14 @@ public void removeModifyListener (ModifyListener listener) {
* @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);
-}
-
+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
@@ -1038,18 +1038,18 @@ public void removeSelectionListener (SelectionListener listener) {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public void select (int index) {
- checkWidget();
- if (index < 0) return;
- OS.PtSetResource (handle, OS.Pt_ARG_CBOX_SELECTION_ITEM, index + 1, 0);
-}
-
-int setBounds (int x, int y, int width, int height, boolean move, boolean resize, boolean events) {
- checkWidget();
- int newHeight = (resize && (style & SWT.DROP_DOWN) != 0) ? getTextHeight() : height;
- return super.setBounds (x, y, width, newHeight, move, resize, events);
-}
-
+public void select (int index) {
+ checkWidget();
+ if (index < 0) return;
+ OS.PtSetResource (handle, OS.Pt_ARG_CBOX_SELECTION_ITEM, index + 1, 0);
+}
+
+int setBounds (int x, int y, int width, int height, boolean move, boolean resize, boolean events) {
+ checkWidget();
+ int newHeight = (resize && (style & SWT.DROP_DOWN) != 0) ? getTextHeight() : height;
+ return super.setBounds (x, y, width, newHeight, move, resize, events);
+}
+
/**
* Sets the text of the item in the receiver's list at the given
* zero-relative index to the string argument. This is equivalent
@@ -1071,21 +1071,21 @@ int setBounds (int x, int y, int width, int height, boolean move, boolean resize
* <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 [] 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 setItem (int index, String string) {
+ checkWidget();
+ 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);
+}
+
/**
* Sets the receiver's list to be the given array of items.
*
@@ -1099,25 +1099,25 @@ public void setItem (int index, String string) {
* <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.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]);
- }
- OS.PtSetResource (handle, OS.Pt_ARG_TEXT_STRING, 0, 0);
- sendEvent (SWT.Modify);
-}
-
+public void setItems (String [] items) {
+ checkWidget();
+ 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]);
+ }
+ OS.PtSetResource (handle, OS.Pt_ARG_TEXT_STRING, 0, 0);
+ sendEvent (SWT.Modify);
+}
+
/**
* Sets the selection in the receiver's text field to the
* range specified by the argument whose x coordinate is the
@@ -1134,12 +1134,12 @@ public void setItems (String [] items) {
* <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);
- OS.PtTextSetSelection (handle, new int [] {selection.x}, new int [] {selection.y});
-}
-
+public void setSelection (Point selection) {
+ checkWidget();
+ if (selection == null) error (SWT.ERROR_NULL_ARGUMENT);
+ OS.PtTextSetSelection (handle, new int [] {selection.x}, new int [] {selection.y});
+}
+
/**
* Sets the contents of the receiver's text field to the
* given string.
@@ -1161,25 +1161,25 @@ public void setSelection (Point selection) {
* <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 (null, string, true);
- if ((style & SWT.READ_ONLY) != 0) {
- int index = OS.PtListItemPos(handle, buffer);
- if (index > 0) {
- OS.PtSetResource (handle, OS.Pt_ARG_CBOX_SELECTION_ITEM, index, 0);
- sendEvent (SWT.Modify);
- }
- return;
- }
- int ptr = OS.malloc (buffer.length);
- OS.memmove (ptr, buffer, buffer.length);
- OS.PtSetResource (handle, OS.Pt_ARG_TEXT_STRING, ptr, 0);
- OS.free (ptr);
- sendEvent (SWT.Modify);
-}
-
+public void setText (String string) {
+ checkWidget();
+ 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) {
+ OS.PtSetResource (handle, OS.Pt_ARG_CBOX_SELECTION_ITEM, index, 0);
+ sendEvent (SWT.Modify);
+ }
+ return;
+ }
+ int ptr = OS.malloc (buffer.length);
+ OS.memmove (ptr, buffer, buffer.length);
+ OS.PtSetResource (handle, OS.Pt_ARG_TEXT_STRING, ptr, 0);
+ OS.free (ptr);
+ sendEvent (SWT.Modify);
+}
+
/**
* Sets the maximum number of characters that the receiver's
* text field is capable of holding to be the argument.
@@ -1194,36 +1194,36 @@ public void setText (String string) {
* <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.PtSetResource (handle, OS.Pt_ARG_MAX_LENGTH, limit, 0);
-}
-
-int traversalCode (int key_sym, PhKeyEvent_t ke) {
- int code = super.traversalCode (key_sym, ke);
- if (key_sym == OS.Pk_Up || key_sym == OS.Pk_Down) {
- code &= ~(SWT.TRAVERSE_ARROW_NEXT | SWT.TRAVERSE_ARROW_PREVIOUS);
- }
- if ((style & SWT.READ_ONLY) == 0) {
- if (key_sym == OS.Pk_Up || key_sym == OS.Pk_Down) {
- code &= ~(SWT.TRAVERSE_ARROW_NEXT | SWT.TRAVERSE_ARROW_PREVIOUS);
- }
- }
- return code;
-}
-
-boolean translateTraversal (int key_sym, PhKeyEvent_t phEvent) {
- boolean translated = super.translateTraversal (key_sym, phEvent);
- if (!translated && key_sym == OS.Pk_Return) {
- postEvent (SWT.DefaultSelection);
- return false;
- }
- return translated;
-}
-
-int widgetClass () {
- return OS.PtComboBox ();
-}
-
-}
+public void setTextLimit (int limit) {
+ checkWidget();
+ if (limit == 0) error (SWT.ERROR_CANNOT_BE_ZERO);
+ OS.PtSetResource (handle, OS.Pt_ARG_MAX_LENGTH, limit, 0);
+}
+
+int traversalCode (int key_sym, PhKeyEvent_t ke) {
+ int code = super.traversalCode (key_sym, ke);
+ if (key_sym == OS.Pk_Up || key_sym == OS.Pk_Down) {
+ code &= ~(SWT.TRAVERSE_ARROW_NEXT | SWT.TRAVERSE_ARROW_PREVIOUS);
+ }
+ if ((style & SWT.READ_ONLY) == 0) {
+ if (key_sym == OS.Pk_Up || key_sym == OS.Pk_Down) {
+ code &= ~(SWT.TRAVERSE_ARROW_NEXT | SWT.TRAVERSE_ARROW_PREVIOUS);
+ }
+ }
+ return code;
+}
+
+boolean translateTraversal (int key_sym, PhKeyEvent_t phEvent) {
+ boolean translated = super.translateTraversal (key_sym, phEvent);
+ if (!translated && key_sym == OS.Pk_Return) {
+ postEvent (SWT.DefaultSelection);
+ return false;
+ }
+ return translated;
+}
+
+int widgetClass () {
+ return OS.PtComboBox ();
+}
+
+}
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
index b6cb8bd11b..ab5bec1586 100755
--- 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
@@ -1,16 +1,16 @@
-package org.eclipse.swt.widgets;
-
-/*
+package org.eclipse.swt.widgets;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-import org.eclipse.swt.internal.photon.*;
-import org.eclipse.swt.*;
-import org.eclipse.swt.graphics.*;
-
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+import org.eclipse.swt.internal.photon.*;
+import org.eclipse.swt.*;
+import org.eclipse.swt.graphics.*;
+
/**
* Instances of this class are controls which are capable
* of containing other controls.
@@ -34,15 +34,15 @@ import org.eclipse.swt.graphics.*;
*
* @see Canvas
*/
-public class Composite extends Scrollable {
- Layout layout;
- Control [] tabList;
- int cornerHandle;
-
-Composite () {
- /* Do nothing */
-}
-
+public class Composite extends Scrollable {
+ Layout layout;
+ Control [] tabList;
+ int cornerHandle;
+
+Composite () {
+ /* Do nothing */
+}
+
/**
* Constructs a new instance of this class given its parent
* and a style value describing its behavior and appearance.
@@ -73,288 +73,288 @@ Composite () {
* @see SWT#NO_RADIO_GROUP
* @see Widget#getStyle
*/
-public Composite (Composite parent, int style) {
- super (parent, style);
-}
-
-Control [] _getChildren () {
- int count = 0;
- int parentHandle = parentingHandle ();
- int child = OS.PtWidgetChildFront (parentHandle);
- while (child != 0) {
- child = OS.PtWidgetBrotherBehind (child);
- count++;
- }
- Control [] children = new Control [count];
- int i = 0, j = 0;
- child = OS.PtWidgetChildFront (parentHandle);
- 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;
-}
-
-Control [] _getTabList () {
- if (tabList == null) return tabList;
- int count = 0;
- for (int i=0; i<tabList.length; i++) {
- if (!tabList [i].isDisposed ()) count++;
- }
- if (count == tabList.length) return tabList;
- Control [] newList = new Control [count];
- int index = 0;
- for (int i=0; i<tabList.length; i++) {
- if (!tabList [i].isDisposed ()) {
- newList [index++] = tabList [i];
- }
- }
- tabList = newList;
- return tabList;
-}
-
-protected void checkSubclass () {
- /* Do nothing - Subclassing is allowed */
-}
-
-Control [] computeTabList () {
- Control result [] = super.computeTabList ();
- if (result.length == 0) return result;
- Control [] list = tabList != null ? _getTabList () : _getChildren ();
- for (int i=0; i<list.length; i++) {
- Control child = list [i];
- Control [] childList = child.computeTabList ();
- if (childList.length != 0) {
- Control [] newResult = new Control [result.length + childList.length];
- System.arraycopy (result, 0, newResult, 0, result.length);
- System.arraycopy (childList, 0, newResult, result.length, childList.length);
- result = newResult;
- }
- }
- return result;
-}
-
-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 (int index) {
- state |= HANDLE | GRAB | CANVAS;
- int parentHandle = parent.parentingHandle ();
- 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);
- }
-}
-
-byte [] defaultFont () {
- Display display = getDisplay ();
- return display.TITLE_FONT;
-}
-
-void createScrolledHandle (int parentHandle) {
- int etches = OS.Pt_ALL_ETCHES | OS.Pt_ALL_OUTLINES;
- int [] args = new int [] {
- OS.Pt_ARG_FLAGS, hasBorder () ? OS.Pt_HIGHLIGHTED : 0, OS.Pt_HIGHLIGHTED,
- OS.Pt_ARG_BASIC_FLAGS, hasBorder () ? etches : 0, etches,
- OS.Pt_ARG_CONTAINER_FLAGS, 0, OS.Pt_ENABLE_CUA | OS.Pt_ENABLE_CUA_ARROWS,
- OS.Pt_ARG_FILL_COLOR, OS.Pg_TRANSPARENT, 0,
- 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 ();
- if ((style & SWT.H_SCROLL) != 0 && (style & SWT.V_SCROLL) != 0) {
- etches = OS.Pt_TOP_OUTLINE | OS.Pt_LEFT_OUTLINE;
- args = new int [] {
- OS.Pt_ARG_FLAGS, OS.Pt_HIGHLIGHTED, OS.Pt_HIGHLIGHTED,
- OS.Pt_ARG_BASIC_FLAGS, etches, etches,
- OS.Pt_ARG_WIDTH, display.SCROLLBAR_WIDTH, 0,
- OS.Pt_ARG_HEIGHT, display.SCROLLBAR_HEIGHT, 0,
- OS.Pt_ARG_RESIZE_FLAGS, 0, OS.Pt_RESIZE_XY_BITS,
- };
- cornerHandle = OS.PtCreateWidget (OS.PtContainer (), scrolledHandle, args.length / 3, args);
- }
- int clazz = display.PtContainer;
- args = new int [] {
- OS.Pt_ARG_FLAGS, OS.Pt_SELECTABLE | OS.Pt_SELECT_NOREDRAW, OS.Pt_SELECTABLE | OS.Pt_SELECT_NOREDRAW,
- OS.Pt_ARG_CONTAINER_FLAGS, 0, OS.Pt_ENABLE_CUA | OS.Pt_ENABLE_CUA_ARROWS,
- 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 ();
-}
-
-void drawWidget (int widget, int damage) {
- if ((state & CANVAS) != 0) {
- if ((style & SWT.NO_BACKGROUND) == 0) {
-
- /* Get the clipping tiles for children and siblings */
- int clip_tile = getClipping (handle, topHandle (), true, true);
-
- /* Translate the clipping to the current GC coordinates */
- short [] abs_x = new short [1], abs_y = new short [1];
- OS.PtGetAbsPosition (handle, abs_x, abs_y);
- short [] dis_abs_x = new short [1], dis_abs_y = new short [1];
- OS.PtGetAbsPosition (OS.PtFindDisjoint (handle), dis_abs_x, dis_abs_y);
- PhPoint_t delta = new PhPoint_t ();
- delta.x = (short) (abs_x [0] - dis_abs_x [0]);
- delta.y = (short) (abs_y [0] - dis_abs_y [0]);
- OS.PhTranslateTiles(clip_tile, delta);
-
- /* Set the clipping */
- int[] clip_rects_count = new int [1];
- int clip_rects = OS.PhTilesToRects (clip_tile, clip_rects_count);
- OS.PhFreeTiles (clip_tile);
- if (clip_rects_count [0] == 0) {
- clip_rects_count [0] = 1;
- OS.free (clip_rects);
- clip_rects = OS.malloc (PhRect_t.sizeof);
- }
- OS.PgSetMultiClip (clip_rects_count[0], clip_rects);
- OS.free (clip_rects);
-
- /* Draw the widget */
- super.drawWidget (widget, damage);
-
- /* Reset the clipping */
- OS.PgSetMultiClip (0, 0);
- }
- } else {
- super.drawWidget (widget, damage);
- }
-}
-
-
-public boolean forceFocus () {
- checkWidget();
- if ((state & CANVAS) == 0) return super.forceFocus ();
- /*
- * Bug in Photon. PtContainerGiveFocus() is supposed to give
- * focus to the widget even if the widget's Pt_GET_FOCUS flag
- * is not set. This does not happen when the widget is a
- * PtContainer. The fix is to set the flag before calling it.
- */
- int flags = OS.PtWidgetFlags (handle);
- OS.PtSetResource (handle, OS.Pt_ARG_FLAGS, OS.Pt_GETS_FOCUS, OS.Pt_GETS_FOCUS);
- boolean result = super.forceFocus ();
- OS.PtSetResource (handle, OS.Pt_ARG_FLAGS, flags, OS.Pt_GETS_FOCUS);
- return result;
-}
-
-public Rectangle getClientArea () {
- checkWidget();
- if (scrolledHandle == 0) return super.getClientArea ();
- 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);
-}
-
-int getClipping(int widget, int topWidget, boolean clipChildren, boolean clipSiblings) {
- int child_tile = 0;
- int widget_tile = OS.PhGetTile(); // NOTE: PhGetTile native initializes the tile
-
- PhRect_t rect = new PhRect_t ();
- int args [] = {OS.Pt_ARG_FLAGS, 0, 0, OS.Pt_ARG_BASIC_FLAGS, 0, 0};
-
- /* Get the rectangle of all siblings in front of the widget */
- if (clipSiblings && OS.PtWidgetClass(topWidget) != OS.PtWindow()) {
- 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
- args [1] = args [4] = 0;
- OS.PtGetResources(temp_widget, args.length / 3, args);
- if ((args [1] & OS.Pt_HIGHLIGHTED) != 0) {
- int basic_flags = args [4];
- OS.memmove(rect, tile, PhRect_t.sizeof);
- if ((basic_flags & OS.Pt_TOP_ETCH) != 0) rect.ul_y++;
- if ((basic_flags & OS.Pt_BOTTOM_ETCH) != 0) rect.lr_y--;
- if ((basic_flags & OS.Pt_RIGHT_ETCH) != 0) rect.ul_x++;
- if ((basic_flags & OS.Pt_LEFT_ETCH) != 0) rect.lr_x--;
- OS.memmove(tile, rect, PhRect_t.sizeof);
- }
- }
- }
- /* 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 */
- if (clipChildren) {
- int 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
- args [1] = args [4] = 0;
- OS.PtGetResources(temp_widget, args.length / 3, args);
- if ((args [1] & OS.Pt_HIGHLIGHTED) != 0) {
- int basic_flags = args [4];
- OS.memmove(rect, tile, PhRect_t.sizeof);
- if ((basic_flags & OS.Pt_TOP_ETCH) != 0) rect.ul_y++;
- if ((basic_flags & OS.Pt_BOTTOM_ETCH) != 0) rect.lr_y--;
- if ((basic_flags & OS.Pt_RIGHT_ETCH) != 0) rect.ul_x++;
- if ((basic_flags & OS.Pt_LEFT_ETCH) != 0) rect.lr_x--;
- OS.memmove(tile, rect, PhRect_t.sizeof);
- }
- }
- 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 */
- if (child_tile != 0) {
- int clip_tile = OS.PhClipTilings(widget_tile, child_tile, null);
- OS.PhFreeTiles(child_tile);
- return clip_tile;
- }
- return widget_tile;
-}
-
+public Composite (Composite parent, int style) {
+ super (parent, style);
+}
+
+Control [] _getChildren () {
+ int count = 0;
+ int parentHandle = parentingHandle ();
+ int child = OS.PtWidgetChildFront (parentHandle);
+ while (child != 0) {
+ child = OS.PtWidgetBrotherBehind (child);
+ count++;
+ }
+ Control [] children = new Control [count];
+ int i = 0, j = 0;
+ child = OS.PtWidgetChildFront (parentHandle);
+ 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;
+}
+
+Control [] _getTabList () {
+ if (tabList == null) return tabList;
+ int count = 0;
+ for (int i=0; i<tabList.length; i++) {
+ if (!tabList [i].isDisposed ()) count++;
+ }
+ if (count == tabList.length) return tabList;
+ Control [] newList = new Control [count];
+ int index = 0;
+ for (int i=0; i<tabList.length; i++) {
+ if (!tabList [i].isDisposed ()) {
+ newList [index++] = tabList [i];
+ }
+ }
+ tabList = newList;
+ return tabList;
+}
+
+protected void checkSubclass () {
+ /* Do nothing - Subclassing is allowed */
+}
+
+Control [] computeTabList () {
+ Control result [] = super.computeTabList ();
+ if (result.length == 0) return result;
+ Control [] list = tabList != null ? _getTabList () : _getChildren ();
+ for (int i=0; i<list.length; i++) {
+ Control child = list [i];
+ Control [] childList = child.computeTabList ();
+ if (childList.length != 0) {
+ Control [] newResult = new Control [result.length + childList.length];
+ System.arraycopy (result, 0, newResult, 0, result.length);
+ System.arraycopy (childList, 0, newResult, result.length, childList.length);
+ result = newResult;
+ }
+ }
+ return result;
+}
+
+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 (int index) {
+ state |= HANDLE | GRAB | CANVAS;
+ int parentHandle = parent.parentingHandle ();
+ 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);
+ }
+}
+
+byte [] defaultFont () {
+ Display display = getDisplay ();
+ return display.TITLE_FONT;
+}
+
+void createScrolledHandle (int parentHandle) {
+ int etches = OS.Pt_ALL_ETCHES | OS.Pt_ALL_OUTLINES;
+ int [] args = new int [] {
+ OS.Pt_ARG_FLAGS, hasBorder () ? OS.Pt_HIGHLIGHTED : 0, OS.Pt_HIGHLIGHTED,
+ OS.Pt_ARG_BASIC_FLAGS, hasBorder () ? etches : 0, etches,
+ OS.Pt_ARG_CONTAINER_FLAGS, 0, OS.Pt_ENABLE_CUA | OS.Pt_ENABLE_CUA_ARROWS,
+ OS.Pt_ARG_FILL_COLOR, OS.Pg_TRANSPARENT, 0,
+ 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 ();
+ if ((style & SWT.H_SCROLL) != 0 && (style & SWT.V_SCROLL) != 0) {
+ etches = OS.Pt_TOP_OUTLINE | OS.Pt_LEFT_OUTLINE;
+ args = new int [] {
+ OS.Pt_ARG_FLAGS, OS.Pt_HIGHLIGHTED, OS.Pt_HIGHLIGHTED,
+ OS.Pt_ARG_BASIC_FLAGS, etches, etches,
+ OS.Pt_ARG_WIDTH, display.SCROLLBAR_WIDTH, 0,
+ OS.Pt_ARG_HEIGHT, display.SCROLLBAR_HEIGHT, 0,
+ OS.Pt_ARG_RESIZE_FLAGS, 0, OS.Pt_RESIZE_XY_BITS,
+ };
+ cornerHandle = OS.PtCreateWidget (OS.PtContainer (), scrolledHandle, args.length / 3, args);
+ }
+ int clazz = display.PtContainer;
+ args = new int [] {
+ OS.Pt_ARG_FLAGS, OS.Pt_SELECTABLE | OS.Pt_SELECT_NOREDRAW, OS.Pt_SELECTABLE | OS.Pt_SELECT_NOREDRAW,
+ OS.Pt_ARG_CONTAINER_FLAGS, 0, OS.Pt_ENABLE_CUA | OS.Pt_ENABLE_CUA_ARROWS,
+ 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 ();
+}
+
+void drawWidget (int widget, int damage) {
+ if ((state & CANVAS) != 0) {
+ if ((style & SWT.NO_BACKGROUND) == 0) {
+
+ /* Get the clipping tiles for children and siblings */
+ int clip_tile = getClipping (handle, topHandle (), true, true);
+
+ /* Translate the clipping to the current GC coordinates */
+ short [] abs_x = new short [1], abs_y = new short [1];
+ OS.PtGetAbsPosition (handle, abs_x, abs_y);
+ short [] dis_abs_x = new short [1], dis_abs_y = new short [1];
+ OS.PtGetAbsPosition (OS.PtFindDisjoint (handle), dis_abs_x, dis_abs_y);
+ PhPoint_t delta = new PhPoint_t ();
+ delta.x = (short) (abs_x [0] - dis_abs_x [0]);
+ delta.y = (short) (abs_y [0] - dis_abs_y [0]);
+ OS.PhTranslateTiles(clip_tile, delta);
+
+ /* Set the clipping */
+ int[] clip_rects_count = new int [1];
+ int clip_rects = OS.PhTilesToRects (clip_tile, clip_rects_count);
+ OS.PhFreeTiles (clip_tile);
+ if (clip_rects_count [0] == 0) {
+ clip_rects_count [0] = 1;
+ OS.free (clip_rects);
+ clip_rects = OS.malloc (PhRect_t.sizeof);
+ }
+ OS.PgSetMultiClip (clip_rects_count[0], clip_rects);
+ OS.free (clip_rects);
+
+ /* Draw the widget */
+ super.drawWidget (widget, damage);
+
+ /* Reset the clipping */
+ OS.PgSetMultiClip (0, 0);
+ }
+ } else {
+ super.drawWidget (widget, damage);
+ }
+}
+
+
+public boolean forceFocus () {
+ checkWidget();
+ if ((state & CANVAS) == 0) return super.forceFocus ();
+ /*
+ * Bug in Photon. PtContainerGiveFocus() is supposed to give
+ * focus to the widget even if the widget's Pt_GET_FOCUS flag
+ * is not set. This does not happen when the widget is a
+ * PtContainer. The fix is to set the flag before calling it.
+ */
+ int flags = OS.PtWidgetFlags (handle);
+ OS.PtSetResource (handle, OS.Pt_ARG_FLAGS, OS.Pt_GETS_FOCUS, OS.Pt_GETS_FOCUS);
+ boolean result = super.forceFocus ();
+ OS.PtSetResource (handle, OS.Pt_ARG_FLAGS, flags, OS.Pt_GETS_FOCUS);
+ return result;
+}
+
+public Rectangle getClientArea () {
+ checkWidget();
+ if (scrolledHandle == 0) return super.getClientArea ();
+ 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);
+}
+
+int getClipping(int widget, int topWidget, boolean clipChildren, boolean clipSiblings) {
+ int child_tile = 0;
+ int widget_tile = OS.PhGetTile(); // NOTE: PhGetTile native initializes the tile
+
+ PhRect_t rect = new PhRect_t ();
+ int args [] = {OS.Pt_ARG_FLAGS, 0, 0, OS.Pt_ARG_BASIC_FLAGS, 0, 0};
+
+ /* Get the rectangle of all siblings in front of the widget */
+ if (clipSiblings && OS.PtWidgetClass(topWidget) != OS.PtWindow()) {
+ 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
+ args [1] = args [4] = 0;
+ OS.PtGetResources(temp_widget, args.length / 3, args);
+ if ((args [1] & OS.Pt_HIGHLIGHTED) != 0) {
+ int basic_flags = args [4];
+ OS.memmove(rect, tile, PhRect_t.sizeof);
+ if ((basic_flags & OS.Pt_TOP_ETCH) != 0) rect.ul_y++;
+ if ((basic_flags & OS.Pt_BOTTOM_ETCH) != 0) rect.lr_y--;
+ if ((basic_flags & OS.Pt_RIGHT_ETCH) != 0) rect.ul_x++;
+ if ((basic_flags & OS.Pt_LEFT_ETCH) != 0) rect.lr_x--;
+ OS.memmove(tile, rect, PhRect_t.sizeof);
+ }
+ }
+ }
+ /* 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 */
+ if (clipChildren) {
+ int 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
+ args [1] = args [4] = 0;
+ OS.PtGetResources(temp_widget, args.length / 3, args);
+ if ((args [1] & OS.Pt_HIGHLIGHTED) != 0) {
+ int basic_flags = args [4];
+ OS.memmove(rect, tile, PhRect_t.sizeof);
+ if ((basic_flags & OS.Pt_TOP_ETCH) != 0) rect.ul_y++;
+ if ((basic_flags & OS.Pt_BOTTOM_ETCH) != 0) rect.lr_y--;
+ if ((basic_flags & OS.Pt_RIGHT_ETCH) != 0) rect.ul_x++;
+ if ((basic_flags & OS.Pt_LEFT_ETCH) != 0) rect.lr_x--;
+ OS.memmove(tile, rect, PhRect_t.sizeof);
+ }
+ }
+ 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 */
+ if (child_tile != 0) {
+ int clip_tile = OS.PhClipTilings(widget_tile, child_tile, null);
+ OS.PhFreeTiles(child_tile);
+ return clip_tile;
+ }
+ return widget_tile;
+}
+
/**
* Returns an array containing the receiver's children.
* <p>
@@ -370,22 +370,22 @@ int getClipping(int widget, int topWidget, boolean clipChildren, boolean clipSib
* <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 () {
- int count = 0;
- int parentHandle = parentingHandle ();
- int child = OS.PtWidgetChildFront (parentHandle);
- while (child != 0) {
- child = OS.PtWidgetBrotherBehind (child);
- count++;
- }
- return count;
-}
-
+public Control [] getChildren () {
+ checkWidget();
+ return _getChildren ();
+}
+
+int getChildrenCount () {
+ int count = 0;
+ int parentHandle = parentingHandle ();
+ int child = OS.PtWidgetChildFront (parentHandle);
+ while (child != 0) {
+ child = OS.PtWidgetBrotherBehind (child);
+ count++;
+ }
+ return count;
+}
+
/**
* Returns layout which is associated with the receiver, or
* null if one has not been set.
@@ -397,55 +397,55 @@ int getChildrenCount () {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public Layout getLayout () {
- checkWidget();
- return layout;
-}
-
-boolean hasBorder () {
- return (style & SWT.BORDER) != 0;
-}
-
-boolean hasFocus () {
- return OS.PtIsFocused (handle) == 2;
-}
-
-boolean hooksKeys () {
- return hooks (SWT.KeyDown) || hooks (SWT.KeyUp);
-}
-
-/**
- * Gets the last specified tabbing order for the control.
- *
- * @return tabList the ordered list of controls representing the tab order
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see #setTabList
+public Layout getLayout () {
+ checkWidget();
+ return layout;
+}
+
+boolean hasBorder () {
+ return (style & SWT.BORDER) != 0;
+}
+
+boolean hasFocus () {
+ return OS.PtIsFocused (handle) == 2;
+}
+
+boolean hooksKeys () {
+ return hooks (SWT.KeyDown) || hooks (SWT.KeyUp);
+}
+
+/**
+ * Gets the last specified tabbing order for the control.
+ *
+ * @return tabList the ordered list of controls representing the tab order
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see #setTabList
*/
-public Control [] getTabList () {
- checkWidget ();
- Control [] tabList = _getTabList ();
- if (tabList == null) {
- int count = 0;
- Control [] list =_getChildren ();
- for (int i=0; i<list.length; i++) {
- if (list [i].isTabGroup ()) count++;
- }
- tabList = new Control [count];
- int index = 0;
- for (int i=0; i<list.length; i++) {
- if (list [i].isTabGroup ()) {
- tabList [index++] = list [i];
- }
- }
- }
- return tabList;
-}
-
+public Control [] getTabList () {
+ checkWidget ();
+ Control [] tabList = _getTabList ();
+ if (tabList == null) {
+ int count = 0;
+ Control [] list =_getChildren ();
+ for (int i=0; i<list.length; i++) {
+ if (list [i].isTabGroup ()) count++;
+ }
+ tabList = new Control [count];
+ int index = 0;
+ for (int i=0; i<list.length; i++) {
+ if (list [i].isTabGroup ()) {
+ tabList [index++] = list [i];
+ }
+ }
+ }
+ return tabList;
+}
+
/**
* 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.
@@ -459,26 +459,26 @@ public Control [] getTabList () {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public void layout () {
- checkWidget();
- 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);
-}
-
-void moveToBack (int child) {
- OS.PtWidgetToBack (child);
-}
-
+public void layout () {
+ checkWidget();
+ 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);
+}
+
+void moveToBack (int child) {
+ OS.PtWidgetToBack (child);
+}
+
/**
* 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.
@@ -496,187 +496,187 @@ void moveToBack (int child) {
* <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;
- layout.layout (this, changed);
-}
-
-int parentingHandle () {
- return handle;
-}
-
-int Ph_EV_BUT_PRESS (int widget, int info) {
- int result = super.Ph_EV_BUT_PRESS (widget, info);
- if (result != OS.Pt_CONTINUE)return result;
- if ((state & CANVAS) != 0) {
- /* Set focus for a CANVAS with no children */
- if ((style & SWT.NO_FOCUS) == 0 && OS.PtWidgetChildFront (handle) == 0) {
- 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) setFocus ();
- }
- }
- return result;
-}
-
-int Pt_CB_OUTBOUND (int widget, int info) {
- if ((state & CANVAS) != 0) {
- 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);
-
- /* Grab pointer */
- 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 (0);
- int flags = OS.Ph_DRAG_KEY_MOTION | OS.Ph_DRAG_TRACK | OS.Ph_TRACK_DRAG;
- OS.PhInitDrag (rid, flags, rect, null, input_group, null, null, null, pos, null);
-
- /* Post drag detect event */
- postEvent (SWT.DragDetect);
- }
- return OS.Pt_CONTINUE;
-}
-
-void releaseChildren () {
- Control [] children = _getChildren ();
- for (int i=0; i<children.length; i++) {
- Control child = children [i];
- if (!child.isDisposed ()) child.releaseResources ();
- }
-}
-
-void releaseHandle () {
- super.releaseHandle ();
- cornerHandle = 0;
-}
-
-void releaseWidget () {
- releaseChildren ();
- super.releaseWidget ();
- layout = null;
- tabList = null;
-}
-
-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]);
-}
-
-void resizeClientArea (int width, int height) {
- if (scrolledHandle == 0) return;
-
- /* Calculate the insets */
- int [] args = {
- OS.Pt_ARG_BASIC_FLAGS, 0, 0,
- OS.Pt_ARG_BEVEL_WIDTH, 0, 0,
- };
- OS.PtGetResources (scrolledHandle, args.length / 3, args);
- int flags = args [1];
- int bevel = args [4];
- int top = 0, left = 0, right = 0, bottom = 0;
- if ((flags & OS.Pt_TOP_ETCH) != 0) top++;
- if ((flags & OS.Pt_TOP_OUTLINE) != 0) top++;
- if ((flags & OS.Pt_TOP_INLINE) != 0) top++;
- if ((flags & OS.Pt_TOP_BEVEL) != 0) top += bevel;
- if ((flags & OS.Pt_BOTTOM_ETCH) != 0) bottom++;
- if ((flags & OS.Pt_BOTTOM_OUTLINE) != 0) bottom++;
- if ((flags & OS.Pt_BOTTOM_INLINE) != 0) bottom++;
- if ((flags & OS.Pt_BOTTOM_BEVEL) != 0) bottom += bevel;
- if ((flags & OS.Pt_RIGHT_ETCH) != 0) right++;
- if ((flags & OS.Pt_RIGHT_OUTLINE) != 0) right++;
- if ((flags & OS.Pt_RIGHT_INLINE) != 0) right++;
- if ((flags & OS.Pt_RIGHT_BEVEL) != 0) right += bevel;
- if ((flags & OS.Pt_LEFT_ETCH) != 0) left++;
- if ((flags & OS.Pt_LEFT_OUTLINE) != 0) left++;
- if ((flags & OS.Pt_LEFT_INLINE) != 0) left++;
- if ((flags & OS.Pt_LEFT_BEVEL) != 0) left += bevel;
-
- int clientWidth = width - (left + right);
- int clientHeight = height - (top + bottom);
-
- int vBarWidth = 0, hBarHeight = 0;
- boolean isVisibleHBar = horizontalBar != null && horizontalBar.getVisible ();
- boolean isVisibleVBar = verticalBar != null && verticalBar.getVisible ();
- if (isVisibleHBar) {
- args = new int [] {OS.Pt_ARG_HEIGHT, 0, 0};
- OS.PtGetResources (horizontalBar.handle, args.length / 3, args);
- clientHeight -= (hBarHeight = args [1]);
- }
- if (isVisibleVBar) {
- args = new int [] {OS.Pt_ARG_WIDTH, 0, 0};
- OS.PtGetResources (verticalBar.handle, args.length / 3, args);
- clientWidth -= (vBarWidth = args [1]);
- }
- if (isVisibleHBar) {
- horizontalBar.setBounds (0, clientHeight, clientWidth, hBarHeight);
- }
- if (isVisibleVBar) {
- verticalBar.setBounds (clientWidth, 0, vBarWidth, clientHeight);
- }
- args = new int [] {
- OS.Pt_ARG_WIDTH, Math.max (clientWidth, 0), 0,
- OS.Pt_ARG_HEIGHT, Math.max (clientHeight, 0), 0,
- };
- OS.PtSetResources (handle, args.length / 3, args);
- if (cornerHandle != 0) {
- PhPoint_t pt = new PhPoint_t ();
- pt.x = (short) clientWidth;
- pt.y = (short) clientHeight;
- int ptr = OS.malloc (PhPoint_t.sizeof);
- OS.memmove (ptr, pt, PhPoint_t.sizeof);
- OS.PtSetResource (cornerHandle, OS.Pt_ARG_POS, ptr, 0);
- OS.free (ptr);
- }
-}
-
-int setBounds (int x, int y, int width, int height, boolean move, boolean resize, boolean events) {
- int result = super.setBounds (x, y, width, height, move, resize, false);
- if ((result & MOVED) != 0) {
- if (events) sendEvent (SWT.Move);
- }
- if ((result & RESIZED) != 0) {
- resizeClientArea (width, height);
- if (events) sendEvent (SWT.Resize);
- if (layout != null) layout (false);
- }
- return result;
-}
-
-public boolean setFocus () {
- checkWidget();
- Control [] children = _getChildren ();
- for (int i=0; i<children.length; i++) {
- Control child = children [i];
- if (child.getVisible () && child.setFocus ()) return true;
- }
- return super.setFocus ();
-}
-
+public void layout (boolean changed) {
+ checkWidget();
+ if (layout == null) return;
+ int count = getChildrenCount ();
+ if (count == 0) return;
+ layout.layout (this, changed);
+}
+
+int parentingHandle () {
+ return handle;
+}
+
+int Ph_EV_BUT_PRESS (int widget, int info) {
+ int result = super.Ph_EV_BUT_PRESS (widget, info);
+ if (result != OS.Pt_CONTINUE)return result;
+ if ((state & CANVAS) != 0) {
+ /* Set focus for a CANVAS with no children */
+ if ((style & SWT.NO_FOCUS) == 0 && OS.PtWidgetChildFront (handle) == 0) {
+ 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) setFocus ();
+ }
+ }
+ return result;
+}
+
+int Pt_CB_OUTBOUND (int widget, int info) {
+ if ((state & CANVAS) != 0) {
+ 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);
+
+ /* Grab pointer */
+ 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 (0);
+ int flags = OS.Ph_DRAG_KEY_MOTION | OS.Ph_DRAG_TRACK | OS.Ph_TRACK_DRAG;
+ OS.PhInitDrag (rid, flags, rect, null, input_group, null, null, null, pos, null);
+
+ /* Post drag detect event */
+ postEvent (SWT.DragDetect);
+ }
+ return OS.Pt_CONTINUE;
+}
+
+void releaseChildren () {
+ Control [] children = _getChildren ();
+ for (int i=0; i<children.length; i++) {
+ Control child = children [i];
+ if (!child.isDisposed ()) child.releaseResources ();
+ }
+}
+
+void releaseHandle () {
+ super.releaseHandle ();
+ cornerHandle = 0;
+}
+
+void releaseWidget () {
+ releaseChildren ();
+ super.releaseWidget ();
+ layout = null;
+ tabList = null;
+}
+
+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]);
+}
+
+void resizeClientArea (int width, int height) {
+ if (scrolledHandle == 0) return;
+
+ /* Calculate the insets */
+ int [] args = {
+ OS.Pt_ARG_BASIC_FLAGS, 0, 0,
+ OS.Pt_ARG_BEVEL_WIDTH, 0, 0,
+ };
+ OS.PtGetResources (scrolledHandle, args.length / 3, args);
+ int flags = args [1];
+ int bevel = args [4];
+ int top = 0, left = 0, right = 0, bottom = 0;
+ if ((flags & OS.Pt_TOP_ETCH) != 0) top++;
+ if ((flags & OS.Pt_TOP_OUTLINE) != 0) top++;
+ if ((flags & OS.Pt_TOP_INLINE) != 0) top++;
+ if ((flags & OS.Pt_TOP_BEVEL) != 0) top += bevel;
+ if ((flags & OS.Pt_BOTTOM_ETCH) != 0) bottom++;
+ if ((flags & OS.Pt_BOTTOM_OUTLINE) != 0) bottom++;
+ if ((flags & OS.Pt_BOTTOM_INLINE) != 0) bottom++;
+ if ((flags & OS.Pt_BOTTOM_BEVEL) != 0) bottom += bevel;
+ if ((flags & OS.Pt_RIGHT_ETCH) != 0) right++;
+ if ((flags & OS.Pt_RIGHT_OUTLINE) != 0) right++;
+ if ((flags & OS.Pt_RIGHT_INLINE) != 0) right++;
+ if ((flags & OS.Pt_RIGHT_BEVEL) != 0) right += bevel;
+ if ((flags & OS.Pt_LEFT_ETCH) != 0) left++;
+ if ((flags & OS.Pt_LEFT_OUTLINE) != 0) left++;
+ if ((flags & OS.Pt_LEFT_INLINE) != 0) left++;
+ if ((flags & OS.Pt_LEFT_BEVEL) != 0) left += bevel;
+
+ int clientWidth = width - (left + right);
+ int clientHeight = height - (top + bottom);
+
+ int vBarWidth = 0, hBarHeight = 0;
+ boolean isVisibleHBar = horizontalBar != null && horizontalBar.getVisible ();
+ boolean isVisibleVBar = verticalBar != null && verticalBar.getVisible ();
+ if (isVisibleHBar) {
+ args = new int [] {OS.Pt_ARG_HEIGHT, 0, 0};
+ OS.PtGetResources (horizontalBar.handle, args.length / 3, args);
+ clientHeight -= (hBarHeight = args [1]);
+ }
+ if (isVisibleVBar) {
+ args = new int [] {OS.Pt_ARG_WIDTH, 0, 0};
+ OS.PtGetResources (verticalBar.handle, args.length / 3, args);
+ clientWidth -= (vBarWidth = args [1]);
+ }
+ if (isVisibleHBar) {
+ horizontalBar.setBounds (0, clientHeight, clientWidth, hBarHeight);
+ }
+ if (isVisibleVBar) {
+ verticalBar.setBounds (clientWidth, 0, vBarWidth, clientHeight);
+ }
+ args = new int [] {
+ OS.Pt_ARG_WIDTH, Math.max (clientWidth, 0), 0,
+ OS.Pt_ARG_HEIGHT, Math.max (clientHeight, 0), 0,
+ };
+ OS.PtSetResources (handle, args.length / 3, args);
+ if (cornerHandle != 0) {
+ PhPoint_t pt = new PhPoint_t ();
+ pt.x = (short) clientWidth;
+ pt.y = (short) clientHeight;
+ int ptr = OS.malloc (PhPoint_t.sizeof);
+ OS.memmove (ptr, pt, PhPoint_t.sizeof);
+ OS.PtSetResource (cornerHandle, OS.Pt_ARG_POS, ptr, 0);
+ OS.free (ptr);
+ }
+}
+
+int setBounds (int x, int y, int width, int height, boolean move, boolean resize, boolean events) {
+ int result = super.setBounds (x, y, width, height, move, resize, false);
+ if ((result & MOVED) != 0) {
+ if (events) sendEvent (SWT.Move);
+ }
+ if ((result & RESIZED) != 0) {
+ resizeClientArea (width, height);
+ if (events) sendEvent (SWT.Resize);
+ if (layout != null) layout (false);
+ }
+ return result;
+}
+
+public boolean setFocus () {
+ checkWidget();
+ Control [] children = _getChildren ();
+ for (int i=0; i<children.length; i++) {
+ Control child = children [i];
+ if (child.getVisible () && child.setFocus ()) return true;
+ }
+ return super.setFocus ();
+}
+
/**
* Sets the layout which is associated with the receiver to be
* the argument which may be null.
@@ -688,38 +688,38 @@ public boolean setFocus () {
* <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 (isTabItem ()) return setTabItemFocus ();
- if ((style & SWT.NO_FOCUS) == 0) {
- boolean takeFocus = true;
- if ((state & CANVAS) != 0) takeFocus = hooksKeys ();
- if (takeFocus && setTabItemFocus ()) return true;
- }
- Control [] children = _getChildren ();
- for (int i=0; i<children.length; i++) {
- Control child = children [i];
- if (child.isTabItem () && child.setTabItemFocus ()) return true;
- }
- return false;
-}
-
-boolean setTabItemFocus () {
- if ((style & SWT.NO_FOCUS) == 0) {
- boolean takeFocus = true;
- if ((state & CANVAS) != 0) takeFocus = hooksKeys ();
- if (takeFocus) {
- if (!isShowing ()) return false;
- if (forceFocus ()) return true;
- }
- }
- return super.setTabItemFocus ();
-}
-
+public void setLayout (Layout layout) {
+ checkWidget();
+ this.layout = layout;
+}
+
+boolean setTabGroupFocus () {
+ if (isTabItem ()) return setTabItemFocus ();
+ if ((style & SWT.NO_FOCUS) == 0) {
+ boolean takeFocus = true;
+ if ((state & CANVAS) != 0) takeFocus = hooksKeys ();
+ if (takeFocus && setTabItemFocus ()) return true;
+ }
+ Control [] children = _getChildren ();
+ for (int i=0; i<children.length; i++) {
+ Control child = children [i];
+ if (child.isTabItem () && child.setTabItemFocus ()) return true;
+ }
+ return false;
+}
+
+boolean setTabItemFocus () {
+ if ((style & SWT.NO_FOCUS) == 0) {
+ boolean takeFocus = true;
+ if ((state & CANVAS) != 0) takeFocus = hooksKeys ();
+ if (takeFocus) {
+ if (!isShowing ()) return false;
+ if (forceFocus ()) return true;
+ }
+ }
+ return super.setTabItemFocus ();
+}
+
/**
* Sets the tabbing order for the specified controls to
* match the order that they occur in the argument list.
@@ -735,29 +735,29 @@ boolean setTabItemFocus () {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public void setTabList (Control [] tabList) {
- checkWidget ();
- if (tabList == null) error (SWT.ERROR_NULL_ARGUMENT);
- for (int i=0; i<tabList.length; i++) {
- Control control = tabList [i];
- if (control == null) error (SWT.ERROR_INVALID_ARGUMENT);
- if (control.isDisposed ()) error (SWT.ERROR_INVALID_ARGUMENT);
- if (control.parent != this) error (SWT.ERROR_INVALID_PARENT);
- }
- this.tabList = tabList;
-}
-
-int traversalCode (int key_sym, PhKeyEvent_t ke) {
- if ((state & CANVAS) != 0) {
- if ((style & SWT.NO_FOCUS) != 0) return 0;
- if (hooksKeys ()) return 0;
- }
- return super.traversalCode (key_sym, ke);
-}
-
-int widgetClass () {
- if ((state & CANVAS) != 0) return OS.PtContainer ();
- return super.widgetClass ();
-}
-
-}
+public void setTabList (Control [] tabList) {
+ checkWidget ();
+ if (tabList == null) error (SWT.ERROR_NULL_ARGUMENT);
+ for (int i=0; i<tabList.length; i++) {
+ Control control = tabList [i];
+ if (control == null) error (SWT.ERROR_INVALID_ARGUMENT);
+ if (control.isDisposed ()) error (SWT.ERROR_INVALID_ARGUMENT);
+ if (control.parent != this) error (SWT.ERROR_INVALID_PARENT);
+ }
+ this.tabList = tabList;
+}
+
+int traversalCode (int key_sym, PhKeyEvent_t ke) {
+ if ((state & CANVAS) != 0) {
+ if ((style & SWT.NO_FOCUS) != 0) return 0;
+ if (hooksKeys ()) return 0;
+ }
+ return super.traversalCode (key_sym, ke);
+}
+
+int widgetClass () {
+ if ((state & CANVAS) != 0) return OS.PtContainer ();
+ return super.widgetClass ();
+}
+
+}
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
index 0b5a13bdda..fc43a091c5 100755
--- 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
@@ -1,18 +1,18 @@
-package org.eclipse.swt.widgets;
-
-/*
+package org.eclipse.swt.widgets;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-import org.eclipse.swt.internal.photon.*;
-import org.eclipse.swt.graphics.*;
-import org.eclipse.swt.events.*;
-import org.eclipse.swt.*;
-import org.eclipse.swt.accessibility.*;
-
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+import org.eclipse.swt.internal.photon.*;
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.events.*;
+import org.eclipse.swt.*;
+import org.eclipse.swt.accessibility.*;
+
/**
* Control is the abstract superclass of all windowed user interface classes.
* <p>
@@ -28,18 +28,18 @@ import org.eclipse.swt.accessibility.*;
* within the SWT implementation.
* </p>
*/
-public abstract class Control extends Widget implements Drawable {
- Composite parent;
- Menu menu;
- Object layoutData;
- String toolTipText;
- int toolTipHandle;
- Accessible accessible;
-
-Control () {
- /* Do nothing */
-}
-
+public abstract class Control extends Widget implements Drawable {
+ Composite parent;
+ Menu menu;
+ Object layoutData;
+ String toolTipText;
+ int toolTipHandle;
+ Accessible accessible;
+
+Control () {
+ /* Do nothing */
+}
+
/**
* Constructs a new instance of this class given its parent
* and a style value describing its behavior and appearance.
@@ -68,12 +68,12 @@ Control () {
* @see Widget#checkSubclass
* @see Widget#getStyle
*/
-public Control (Composite parent, int style) {
- super (parent, style);
- this.parent = parent;
- createWidget (0);
-}
-
+public Control (Composite parent, int style) {
+ super (parent, style);
+ this.parent = parent;
+ createWidget (0);
+}
+
/**
* Adds the listener to the collection of listeners who will
* be notified when the control is moved or resized, by sending
@@ -93,14 +93,14 @@ public Control (Composite parent, int style) {
* @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);
-}
-
+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
@@ -120,14 +120,14 @@ public void addControlListener(ControlListener listener) {
* @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);
-}
-
+public void addFocusListener (FocusListener listener) {
+ checkWidget();
+ if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+ TypedListener typedListener = new TypedListener (listener);
+ addListener (SWT.FocusIn,typedListener);
+ addListener (SWT.FocusOut,typedListener);
+}
+
/**
* Adds the listener to the collection of listeners who will
* be notified when help events are generated for the control,
@@ -147,13 +147,13 @@ public void addFocusListener (FocusListener listener) {
* @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);
-}
-
+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
@@ -173,14 +173,14 @@ public void addHelpListener (HelpListener listener) {
* @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);
-}
-
+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
@@ -200,15 +200,15 @@ public void addKeyListener (KeyListener listener) {
* @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);
-}
-
+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
@@ -228,15 +228,15 @@ public void addMouseListener (MouseListener listener) {
* @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);
-}
-
+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
@@ -256,13 +256,13 @@ public void addMouseTrackListener (MouseTrackListener listener) {
* @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);
-}
-
+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
@@ -282,13 +282,13 @@ public void addMouseMoveListener (MouseMoveListener listener) {
* @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);
-}
-
+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
@@ -308,13 +308,13 @@ public void addPaintListener (PaintListener listener) {
* @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);
-}
-
+public void addTraverseListener (TraverseListener listener) {
+ checkWidget();
+ if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+ TypedListener typedListener = new TypedListener (listener);
+ addListener (SWT.Traverse,typedListener);
+}
+
/**
* Forces the receiver to have the <em>keyboard focus</em>, causing
* all keyboard events to be delivered to it.
@@ -328,23 +328,23 @@ public void addTraverseListener (TraverseListener listener) {
*
* @see #setFocus
*/
-public boolean forceFocus () {
- checkWidget();
- /*
- * Bug in Photon. Photon will stop sending key
- * events, if a menu is up and focus is given to
- * a widget by calling PtContainerGiveFocus(). The
- * fix is to detect when a menu is up and avoid
- * calling this function.
- */
- Shell shell = getShell ();
- if (shell.activeMenu != null) return false;
- int shellHandle = shell.shellHandle;
- OS.PtWindowToFront (shellHandle);
- OS.PtContainerGiveFocus (handle, null);
- return hasFocus ();
-}
-
+public boolean forceFocus () {
+ checkWidget();
+ /*
+ * Bug in Photon. Photon will stop sending key
+ * events, if a menu is up and focus is given to
+ * a widget by calling PtContainerGiveFocus(). The
+ * fix is to detect when a menu is up and avoid
+ * calling this function.
+ */
+ Shell shell = getShell ();
+ if (shell.activeMenu != null) return false;
+ int shellHandle = shell.shellHandle;
+ OS.PtWindowToFront (shellHandle);
+ OS.PtContainerGiveFocus (handle, null);
+ return hasFocus ();
+}
+
/**
* Returns the preferred size of the receiver.
* <p>
@@ -372,10 +372,10 @@ public boolean forceFocus () {
* @see #pack
* @see "computeTrim, getClientArea for controls that implement them"
*/
-public Point computeSize (int wHint, int hHint) {
- return computeSize (wHint, hHint, true);
-}
-
+public Point computeSize (int wHint, int hHint) {
+ return computeSize (wHint, hHint, true);
+}
+
/**
* Returns the preferred size of the receiver.
* <p>
@@ -410,133 +410,133 @@ public Point computeSize (int wHint, int hHint) {
* @see #pack
* @see "computeTrim, getClientArea for controls that implement them"
*/
-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);
-}
-
-Control computeTabGroup () {
- if (isTabGroup ()) return this;
- return parent.computeTabGroup ();
-}
-
-Control computeTabRoot () {
- Control [] tabList = parent._getTabList ();
- if (tabList != null) {
- int index = 0;
- while (index < tabList.length) {
- if (tabList [index] == this) break;
- index++;
- }
- if (index == tabList.length) {
- if (isTabGroup ()) return this;
- }
- }
- return parent.computeTabRoot ();
-}
-
-Control [] computeTabList () {
- if (isTabGroup ()) {
- if (getVisible () && getEnabled ()) {
- return new Control [] {this};
- }
- }
- return new Control [0];
-}
-
-void createWidget (int index) {
- checkOrientation (parent);
- super.createWidget (index);
- setZOrder ();
- realizeWidget ();
- setDefaultFont ();
-}
-
-int defaultBackground () {
- Display display = getDisplay ();
- return display.WIDGET_BACKGROUND;
-}
-
-byte [] defaultFont () {
- Display display = getDisplay ();
- return display.TEXT_FONT;
-}
-
-int defaultForeground () {
- Display display = getDisplay ();
- return display.WIDGET_FOREGROUND;
-}
-
-int drawProc (int widget, int damage) {
- drawWidget (widget, damage);
- if (!hooks(SWT.Paint) && !filters (SWT.Paint)) return OS.Pt_CONTINUE;
-
- /* 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);
- boolean noMerge = (style & SWT.NO_MERGE_PAINTS) != 0 && (state & CANVAS) != 0;
- if (tile.next != 0 && noMerge) {
- while (tile.next != 0) {
- OS.memmove (tile, tile.next, PhTile_t.sizeof);
- if (tile.rect_ul_x != tile.rect_lr_x || tile.rect_ul_y != tile.rect_lr_y) {
- 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;
- GC gc = event.gc = new GC (this);
- gc.setClipping (event.x, event.y, event.width, event.height);
- sendEvent (SWT.Paint, event);
- if (isDisposed ()) break;
- gc.dispose ();
- event.gc = null;
- }
- }
- } else {
- if (tile.rect_ul_x != tile.rect_lr_x || tile.rect_ul_y != tile.rect_lr_y) {
- 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 ();
- event.gc = null;
- }
- }
- OS.PhFreeTiles (damage);
- return OS.Pt_CONTINUE;
-}
-
-void drawWidget (int widget, int damage) {
- int widgetClass = widgetClass ();
- if (widgetClass != 0) OS.PtSuperClassDraw (widgetClass, handle, damage);
-}
-
+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);
+}
+
+Control computeTabGroup () {
+ if (isTabGroup ()) return this;
+ return parent.computeTabGroup ();
+}
+
+Control computeTabRoot () {
+ Control [] tabList = parent._getTabList ();
+ if (tabList != null) {
+ int index = 0;
+ while (index < tabList.length) {
+ if (tabList [index] == this) break;
+ index++;
+ }
+ if (index == tabList.length) {
+ if (isTabGroup ()) return this;
+ }
+ }
+ return parent.computeTabRoot ();
+}
+
+Control [] computeTabList () {
+ if (isTabGroup ()) {
+ if (getVisible () && getEnabled ()) {
+ return new Control [] {this};
+ }
+ }
+ return new Control [0];
+}
+
+void createWidget (int index) {
+ checkOrientation (parent);
+ super.createWidget (index);
+ setZOrder ();
+ realizeWidget ();
+ setDefaultFont ();
+}
+
+int defaultBackground () {
+ Display display = getDisplay ();
+ return display.WIDGET_BACKGROUND;
+}
+
+byte [] defaultFont () {
+ Display display = getDisplay ();
+ return display.TEXT_FONT;
+}
+
+int defaultForeground () {
+ Display display = getDisplay ();
+ return display.WIDGET_FOREGROUND;
+}
+
+int drawProc (int widget, int damage) {
+ drawWidget (widget, damage);
+ if (!hooks(SWT.Paint) && !filters (SWT.Paint)) return OS.Pt_CONTINUE;
+
+ /* 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);
+ boolean noMerge = (style & SWT.NO_MERGE_PAINTS) != 0 && (state & CANVAS) != 0;
+ if (tile.next != 0 && noMerge) {
+ while (tile.next != 0) {
+ OS.memmove (tile, tile.next, PhTile_t.sizeof);
+ if (tile.rect_ul_x != tile.rect_lr_x || tile.rect_ul_y != tile.rect_lr_y) {
+ 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;
+ GC gc = event.gc = new GC (this);
+ gc.setClipping (event.x, event.y, event.width, event.height);
+ sendEvent (SWT.Paint, event);
+ if (isDisposed ()) break;
+ gc.dispose ();
+ event.gc = null;
+ }
+ }
+ } else {
+ if (tile.rect_ul_x != tile.rect_lr_x || tile.rect_ul_y != tile.rect_lr_y) {
+ 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 ();
+ event.gc = null;
+ }
+ }
+ OS.PhFreeTiles (damage);
+ return OS.Pt_CONTINUE;
+}
+
+void drawWidget (int widget, int damage) {
+ int widgetClass = widgetClass ();
+ if (widgetClass != 0) OS.PtSuperClassDraw (widgetClass, handle, damage);
+}
+
/**
* Returns the accessible object for the receiver.
* If this is the first time this object is requested,
@@ -554,14 +554,14 @@ void drawWidget (int widget, int damage) {
*
* @since 2.0
*/
-public Accessible getAccessible () {
- checkWidget ();
- if (accessible == null) {
- accessible = Accessible.internal_new_Accessible (this);
- }
- return accessible;
-}
-
+public Accessible getAccessible () {
+ checkWidget ();
+ if (accessible == null) {
+ accessible = Accessible.internal_new_Accessible (this);
+ }
+ return accessible;
+}
+
/**
* Returns the receiver's background color.
*
@@ -572,13 +572,13 @@ public Accessible getAccessible () {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public Color getBackground () {
- checkWidget();
- int [] args = {OS.Pt_ARG_FILL_COLOR, 0, 0};
- OS.PtGetResources (handle, args.length / 3, args);
- return Color.photon_new (getDisplay (), args [1]);
-}
-
+public Color getBackground () {
+ checkWidget();
+ int [] args = {OS.Pt_ARG_FILL_COLOR, 0, 0};
+ OS.PtGetResources (handle, args.length / 3, args);
+ return Color.photon_new (getDisplay (), args [1]);
+}
+
/**
* Returns the font that the receiver will use to paint textual information.
*
@@ -589,30 +589,30 @@ public Color getBackground () {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public Font getFont () {
- checkWidget();
- int [] args = {
- OS.Pt_ARG_TEXT_FONT, 0, 0,
- OS.Pt_ARG_LIST_FONT, 0, 0,
- OS.Pt_ARG_TITLE_FONT, 0, 0,
- OS.Pt_ARG_GAUGE_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) ptr = args [11];
- 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 Font getFont () {
+ checkWidget();
+ int [] args = {
+ OS.Pt_ARG_TEXT_FONT, 0, 0,
+ OS.Pt_ARG_LIST_FONT, 0, 0,
+ OS.Pt_ARG_TITLE_FONT, 0, 0,
+ OS.Pt_ARG_GAUGE_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) ptr = args [11];
+ 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);
+}
+
/**
* Returns the foreground color that the receiver will use to draw.
*
@@ -623,13 +623,13 @@ public Font getFont () {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public Color getForeground () {
- checkWidget();
- int [] args = {OS.Pt_ARG_COLOR, 0, 0};
- OS.PtGetResources (handle, args.length / 3, args);
- return Color.photon_new (getDisplay (), args [1]);
-}
-
+public Color getForeground () {
+ checkWidget();
+ int [] args = {OS.Pt_ARG_COLOR, 0, 0};
+ OS.PtGetResources (handle, args.length / 3, args);
+ return Color.photon_new (getDisplay (), args [1]);
+}
+
/**
* Returns the receiver's border width.
*
@@ -640,25 +640,25 @@ public Color getForeground () {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public int getBorderWidth () {
- checkWidget();
- int topHandle = topHandle ();
- int [] args = {
- OS.Pt_ARG_BASIC_FLAGS, 0, 0,
- OS.Pt_ARG_FLAGS, 0, 0,
-// OS.Pt_ARG_BEVEL_WIDTH, 0, 0,
- };
- OS.PtGetResources (topHandle, args.length / 3, args);
- if ((args [4] & OS.Pt_HIGHLIGHTED) == 0) return 0;
- 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 [7];
- return border;
-}
-
+public int getBorderWidth () {
+ checkWidget();
+ int topHandle = topHandle ();
+ int [] args = {
+ OS.Pt_ARG_BASIC_FLAGS, 0, 0,
+ OS.Pt_ARG_FLAGS, 0, 0,
+// OS.Pt_ARG_BEVEL_WIDTH, 0, 0,
+ };
+ OS.PtGetResources (topHandle, args.length / 3, args);
+ if ((args [4] & OS.Pt_HIGHLIGHTED) == 0) return 0;
+ 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 [7];
+ return border;
+}
+
/**
* Returns a rectangle describing the receiver's size and location
* relative to its parent (or its display if its parent is null).
@@ -670,14 +670,14 @@ public int getBorderWidth () {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public Rectangle getBounds () {
- checkWidget();
- 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 Rectangle getBounds () {
+ checkWidget();
+ 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);
+}
+
/**
* Returns the display that the receiver was created on.
*
@@ -688,12 +688,12 @@ public Rectangle getBounds () {
* <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 ();
-}
-
+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
@@ -707,12 +707,12 @@ public Display getDisplay () {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public boolean getEnabled () {
- checkWidget ();
- int topHandle = topHandle ();
- return (OS.PtWidgetFlags (topHandle) & OS.Pt_BLOCKED) == 0;
-}
-
+public boolean getEnabled () {
+ checkWidget ();
+ int topHandle = topHandle ();
+ return (OS.PtWidgetFlags (topHandle) & OS.Pt_BLOCKED) == 0;
+}
+
/**
* Returns layout data which is associated with the receiver.
*
@@ -723,11 +723,11 @@ public boolean getEnabled () {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public Object getLayoutData () {
- checkWidget();
- return layoutData;
-}
-
+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).
@@ -739,14 +739,14 @@ public Object getLayoutData () {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public Point getLocation () {
- checkWidget();
- int topHandle = topHandle ();
- PhArea_t area = new PhArea_t ();
- OS.PtWidgetArea (topHandle, area);
- return new Point (area.pos_x, area.pos_y);
-}
-
+public Point getLocation () {
+ checkWidget();
+ int topHandle = topHandle ();
+ PhArea_t area = new PhArea_t ();
+ OS.PtWidgetArea (topHandle, area);
+ return new Point (area.pos_x, area.pos_y);
+}
+
/**
* 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
@@ -762,11 +762,11 @@ public Point getLocation () {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public Menu getMenu () {
- checkWidget();
- return menu;
-}
-
+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
@@ -779,28 +779,28 @@ public Menu getMenu () {
* <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;
-}
-
+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 a point describing the receiver's size. The
* x coordinate of the result is the width of the receiver.
@@ -814,14 +814,14 @@ Control [] getPath () {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public Point getSize () {
- checkWidget();
- int topHandle = topHandle ();
- PhArea_t area = new PhArea_t ();
- OS.PtWidgetArea (topHandle, area);
- return new Point (area.size_w, area.size_h);
-}
-
+public Point getSize () {
+ checkWidget();
+ int topHandle = topHandle ();
+ PhArea_t area = new PhArea_t ();
+ OS.PtWidgetArea (topHandle, area);
+ return new Point (area.size_w, area.size_h);
+}
+
/**
* Returns the receiver's tool tip text, or null if it has
* not been set.
@@ -833,11 +833,11 @@ public Point getSize () {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public String getToolTipText () {
- checkWidget();
- return toolTipText;
-}
-
+public String getToolTipText () {
+ checkWidget();
+ return toolTipText;
+}
+
/**
* Returns the receiver's shell. For all controls other than
* shells, this simply returns the control's nearest ancestor
@@ -853,11 +853,11 @@ public String getToolTipText () {
*
* @see #getParent
*/
-public Shell getShell () {
- checkWidget();
- return parent.getShell ();
-}
-
+public Shell getShell () {
+ checkWidget();
+ return parent.getShell ();
+}
+
/**
* Returns <code>true</code> if the receiver is visible, and
* <code>false</code> otherwise.
@@ -875,36 +875,36 @@ public Shell getShell () {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public boolean getVisible () {
- checkWidget ();
- int topHandle = topHandle ();
- return (OS.PtWidgetFlags (topHandle) & OS.Pt_DELAY_REALIZE) == 0;
-}
-
-boolean hasFocus () {
- return OS.PtIsFocused (handle) != 0;
-}
-
-void hookEvents () {
- int windowProc = getDisplay ().windowProc;
- int focusHandle = focusHandle ();
- OS.PtAddFilterCallback (handle, OS.Ph_EV_KEY, windowProc, OS.Ph_EV_KEY);
- OS.PtAddEventHandler (handle, OS.Ph_EV_BUT_PRESS, windowProc, OS.Ph_EV_BUT_PRESS);
- OS.PtAddEventHandler (handle, OS.Ph_EV_BUT_RELEASE, windowProc, OS.Ph_EV_BUT_RELEASE);
- OS.PtAddEventHandler (handle, OS.Ph_EV_PTR_MOTION, windowProc, OS.Ph_EV_PTR_MOTION);
- OS.PtAddEventHandler (handle, OS.Ph_EV_BOUNDARY, windowProc, OS.Ph_EV_BOUNDARY);
- if ((state & GRAB) != 0) {
- OS.PtAddEventHandler (handle, OS.Ph_EV_DRAG, windowProc, OS.Ph_EV_DRAG);
- OS.PtAddCallback (handle, OS.Pt_CB_OUTBOUND, windowProc, OS.Pt_CB_OUTBOUND);
- }
- OS.PtAddCallback (focusHandle, OS.Pt_CB_GOT_FOCUS, windowProc, OS.Pt_CB_GOT_FOCUS);
- OS.PtAddCallback (focusHandle, OS.Pt_CB_LOST_FOCUS, windowProc, OS.Pt_CB_LOST_FOCUS);
-}
-
-int focusHandle () {
- return handle;
-}
-
+public boolean getVisible () {
+ checkWidget ();
+ int topHandle = topHandle ();
+ return (OS.PtWidgetFlags (topHandle) & OS.Pt_DELAY_REALIZE) == 0;
+}
+
+boolean hasFocus () {
+ return OS.PtIsFocused (handle) != 0;
+}
+
+void hookEvents () {
+ int windowProc = getDisplay ().windowProc;
+ int focusHandle = focusHandle ();
+ OS.PtAddFilterCallback (handle, OS.Ph_EV_KEY, windowProc, OS.Ph_EV_KEY);
+ OS.PtAddEventHandler (handle, OS.Ph_EV_BUT_PRESS, windowProc, OS.Ph_EV_BUT_PRESS);
+ OS.PtAddEventHandler (handle, OS.Ph_EV_BUT_RELEASE, windowProc, OS.Ph_EV_BUT_RELEASE);
+ OS.PtAddEventHandler (handle, OS.Ph_EV_PTR_MOTION, windowProc, OS.Ph_EV_PTR_MOTION);
+ OS.PtAddEventHandler (handle, OS.Ph_EV_BOUNDARY, windowProc, OS.Ph_EV_BOUNDARY);
+ if ((state & GRAB) != 0) {
+ OS.PtAddEventHandler (handle, OS.Ph_EV_DRAG, windowProc, OS.Ph_EV_DRAG);
+ OS.PtAddCallback (handle, OS.Pt_CB_OUTBOUND, windowProc, OS.Pt_CB_OUTBOUND);
+ }
+ OS.PtAddCallback (focusHandle, OS.Pt_CB_GOT_FOCUS, windowProc, OS.Pt_CB_GOT_FOCUS);
+ OS.PtAddCallback (focusHandle, OS.Pt_CB_LOST_FOCUS, windowProc, OS.Pt_CB_LOST_FOCUS);
+}
+
+int focusHandle () {
+ return handle;
+}
+
/**
* Invokes platform specific functionality to allocate a new GC handle.
* <p>
@@ -920,22 +920,22 @@ int focusHandle () {
*
* @private
*/
-public int internal_new_GC (GCData data) {
- checkWidget();
- 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 int internal_new_GC (GCData data) {
+ checkWidget();
+ 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;
+}
+
/**
* Invokes platform specific functionality to dispose a GC handle.
* <p>
@@ -951,40 +951,40 @@ public int internal_new_GC (GCData data) {
*
* @private
*/
-public void internal_dispose_GC (int phGC, GCData data) {
- checkWidget ();
- OS.PgDestroyGC(phGC);
-}
-
-/**
- * Returns <code>true</code> if the receiver is enabled and all
- * of the receiver's ancestors are enabled, and <code>false</code>
- * otherwise. A disabled control is typically not selectable from the
- * user interface and draws with an inactive or "grayed" look.
- *
- * @return the receiver's enabled state
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see #getEnabled
- */
-public boolean isEnabled () {
- checkWidget();
- return getEnabled () && parent.isEnabled ();
-}
-
-public boolean isFocusAncestor () {
- Display display = getDisplay ();
- Control control = display.getFocusControl ();
- while (control != null && control != this) {
- control = control.parent;
- }
- return control == this;
-}
-
+public void internal_dispose_GC (int phGC, GCData data) {
+ checkWidget ();
+ OS.PgDestroyGC(phGC);
+}
+
+/**
+ * Returns <code>true</code> if the receiver is enabled and all
+ * of the receiver's ancestors are enabled, and <code>false</code>
+ * otherwise. A disabled control is typically not selectable from the
+ * user interface and draws with an inactive or "grayed" look.
+ *
+ * @return the receiver's enabled state
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see #getEnabled
+ */
+public boolean isEnabled () {
+ checkWidget();
+ return getEnabled () && parent.isEnabled ();
+}
+
+public boolean isFocusAncestor () {
+ Display display = getDisplay ();
+ Control control = display.getFocusControl ();
+ while (control != null && control != this) {
+ control = control.parent;
+ }
+ return control == this;
+}
+
/**
* Returns <code>true</code> if the receiver has the user-interface
* focus, and <code>false</code> otherwise.
@@ -996,11 +996,11 @@ public boolean isFocusAncestor () {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public boolean isFocusControl () {
- checkWidget();
- return hasFocus ();
-}
-
+public boolean isFocusControl () {
+ checkWidget();
+ return hasFocus ();
+}
+
/**
* Returns <code>true</code> if the underlying operating
* system supports this reparenting, otherwise <code>false</code>
@@ -1012,83 +1012,83 @@ public boolean isFocusControl () {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public boolean isReparentable () {
- checkWidget();
- return false;
-}
-
-boolean isShowing () {
- /*
- * This is not complete. Need to check if the
- * widget is obscurred by a parent or sibling.
- */
- if (!isVisible ()) return false;
- Control control = this;
- while (control != null) {
- Point size = control.getSize ();
- if (size.x == 0 || size.y == 0) {
- return false;
- }
- control = control.parent;
- }
- return true;
- /*
- * Check to see if current damage is included.
- */
-// if (!OS.IsWindowVisible (handle)) return false;
-// int flags = OS.DCX_CACHE | OS.DCX_CLIPCHILDREN | OS.DCX_CLIPSIBLINGS;
-// int hDC = OS.GetDCEx (handle, 0, flags);
-// int result = OS.GetClipBox (hDC, new RECT ());
-// OS.ReleaseDC (handle, hDC);
-// return result != OS.NULLREGION;
-}
-
-boolean isTabGroup () {
- Control [] tabList = parent._getTabList ();
- if (tabList != null) {
- for (int i=0; i<tabList.length; i++) {
- if (tabList [i] == this) return true;
- }
- }
- int code = traversalCode (0, null);
- if ((code & (SWT.TRAVERSE_ARROW_PREVIOUS | SWT.TRAVERSE_ARROW_NEXT)) != 0) return false;
- return (code & (SWT.TRAVERSE_TAB_PREVIOUS | SWT.TRAVERSE_TAB_NEXT)) != 0;
-}
-
-boolean isTabItem () {
- Control [] tabList = parent._getTabList ();
- if (tabList != null) {
- for (int i=0; i<tabList.length; i++) {
- if (tabList [i] == this) return false;
- }
- }
- int code = traversalCode (0, null);
- return (code & (SWT.TRAVERSE_ARROW_PREVIOUS | SWT.TRAVERSE_ARROW_NEXT)) != 0;
-}
-
-/**
- * Returns <code>true</code> if the receiver is visible and all
- * of the receiver's ancestors are visible and <code>false</code>
- * otherwise.
- *
- * @return the receiver's visibility state
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see #getVisible
- */
-public boolean isVisible () {
- checkWidget();
- return OS.PtWidgetIsRealized (handle);
-}
-
-Decorations menuShell () {
- return parent.menuShell ();
-}
-
+public boolean isReparentable () {
+ checkWidget();
+ return false;
+}
+
+boolean isShowing () {
+ /*
+ * This is not complete. Need to check if the
+ * widget is obscurred by a parent or sibling.
+ */
+ if (!isVisible ()) return false;
+ Control control = this;
+ while (control != null) {
+ Point size = control.getSize ();
+ if (size.x == 0 || size.y == 0) {
+ return false;
+ }
+ control = control.parent;
+ }
+ return true;
+ /*
+ * Check to see if current damage is included.
+ */
+// if (!OS.IsWindowVisible (handle)) return false;
+// int flags = OS.DCX_CACHE | OS.DCX_CLIPCHILDREN | OS.DCX_CLIPSIBLINGS;
+// int hDC = OS.GetDCEx (handle, 0, flags);
+// int result = OS.GetClipBox (hDC, new RECT ());
+// OS.ReleaseDC (handle, hDC);
+// return result != OS.NULLREGION;
+}
+
+boolean isTabGroup () {
+ Control [] tabList = parent._getTabList ();
+ if (tabList != null) {
+ for (int i=0; i<tabList.length; i++) {
+ if (tabList [i] == this) return true;
+ }
+ }
+ int code = traversalCode (0, null);
+ if ((code & (SWT.TRAVERSE_ARROW_PREVIOUS | SWT.TRAVERSE_ARROW_NEXT)) != 0) return false;
+ return (code & (SWT.TRAVERSE_TAB_PREVIOUS | SWT.TRAVERSE_TAB_NEXT)) != 0;
+}
+
+boolean isTabItem () {
+ Control [] tabList = parent._getTabList ();
+ if (tabList != null) {
+ for (int i=0; i<tabList.length; i++) {
+ if (tabList [i] == this) return false;
+ }
+ }
+ int code = traversalCode (0, null);
+ return (code & (SWT.TRAVERSE_ARROW_PREVIOUS | SWT.TRAVERSE_ARROW_NEXT)) != 0;
+}
+
+/**
+ * Returns <code>true</code> if the receiver is visible and all
+ * of the receiver's ancestors are visible and <code>false</code>
+ * otherwise.
+ *
+ * @return the receiver's visibility state
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see #getVisible
+ */
+public boolean isVisible () {
+ checkWidget();
+ return OS.PtWidgetIsRealized (handle);
+}
+
+Decorations menuShell () {
+ return parent.menuShell ();
+}
+
/**
* Moves the receiver above the specified control in the
* drawing order. If the argument is null, then the receiver
@@ -1106,20 +1106,20 @@ Decorations menuShell () {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public void moveAbove (Control control) {
- checkWidget();
- int topHandle1 = topHandle ();
- if (control == null) {
- OS.PtWidgetToFront (topHandle1);
- OS.PtWindowToFront (topHandle1);
- return;
- }
- if (control.isDisposed()) error(SWT.ERROR_INVALID_ARGUMENT);
- if (parent != control.parent) return;
- int topHandle2 = control.topHandle ();
- OS.PtWidgetInsert (topHandle1, topHandle2, 0);
-}
-
+public void moveAbove (Control control) {
+ checkWidget();
+ int topHandle1 = topHandle ();
+ if (control == null) {
+ OS.PtWidgetToFront (topHandle1);
+ OS.PtWindowToFront (topHandle1);
+ return;
+ }
+ if (control.isDisposed()) error(SWT.ERROR_INVALID_ARGUMENT);
+ if (parent != control.parent) return;
+ int topHandle2 = control.topHandle ();
+ OS.PtWidgetInsert (topHandle1, topHandle2, 0);
+}
+
/**
* Moves the receiver below the specified control in the
* drawing order. If the argument is null, then the receiver
@@ -1137,20 +1137,20 @@ public void moveAbove (Control control) {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public void moveBelow (Control control) {
- checkWidget();
- int topHandle1 = topHandle ();
- if (control == null) {
- if (parent != null) parent.moveToBack (topHandle1);
- OS.PtWindowToBack (topHandle1);
- return;
- }
- if (control.isDisposed()) error(SWT.ERROR_INVALID_ARGUMENT);
- if (parent != control.parent) return;
- int topHandle2 = control.topHandle ();
- OS.PtWidgetInsert (topHandle1, topHandle2, 1);
-}
-
+public void moveBelow (Control control) {
+ checkWidget();
+ int topHandle1 = topHandle ();
+ if (control == null) {
+ if (parent != null) parent.moveToBack (topHandle1);
+ OS.PtWindowToBack (topHandle1);
+ return;
+ }
+ if (control.isDisposed()) error(SWT.ERROR_INVALID_ARGUMENT);
+ if (parent != control.parent) return;
+ int topHandle2 = control.topHandle ();
+ OS.PtWidgetInsert (topHandle1, topHandle2, 1);
+}
+
/**
* Causes the receiver to be resized to its preferred size.
* For a composite, this involves computing the preferred size
@@ -1163,11 +1163,11 @@ public void moveBelow (Control control) {
*
* @see #computeSize
*/
-public void pack () {
- checkWidget();
- pack (true);
-}
-
+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
@@ -1187,346 +1187,346 @@ public void pack () {
*
* @see #computeSize
*/
-public void pack (boolean changed) {
- checkWidget();
- setSize (computeSize (SWT.DEFAULT, SWT.DEFAULT, changed));
-}
-
-int Ph_EV_BOUNDARY (int widget, 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;
- PhPointerEvent_t pe = new PhPointerEvent_t ();
- OS.memmove (pe, data, PhPointerEvent_t.sizeof);
- Event event = new Event ();
- event.time = ev.timestamp;
- setMouseState (event, pe, ev);
- switch ((int) 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;
- case OS.Ph_EV_PTR_STEADY:
- postEvent (SWT.MouseHover, event);
- destroyToolTip (toolTipHandle);
- toolTipHandle = createToolTip (toolTipText, handle, getFont ().handle);
- break;
- case OS.Ph_EV_PTR_UNSTEADY:
- destroyToolTip (toolTipHandle);
- toolTipHandle = 0;
- break;
- }
- return OS.Pt_END;
-}
-
-int Ph_EV_BUT_PRESS (int widget, 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);
- if ((ev.processing_flags & OS.Ph_FAKE_EVENT) != 0) {
- return OS.Pt_CONTINUE;
- }
- ev.processing_flags |= OS.Ph_CONSUMED;
- OS.memmove (cbinfo.event, ev, 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);
- Event event = new Event ();
- event.time = ev.timestamp;
- setMouseState (event, pe, ev);
- postEvent (SWT.MouseDown, event);
- if (pe.click_count == 2) {
- Event clickEvent = new Event ();
- clickEvent.time = event.time;
- clickEvent.x = event.x;
- clickEvent.y = event.y;
- clickEvent.button = event.button;
- clickEvent.stateMask = event.stateMask;
- postEvent (SWT.MouseDoubleClick, clickEvent);
- }
- if (event.button == 3) {
- if (menu != null && !menu.isDisposed ()) {
- Display display = getDisplay ();
- display.runDeferredEvents ();
- menu.setVisible (true);
- }
- }
- /*
- * It is possible that the shell may be
- * disposed at this point. If this happens
- * don't send the activate and deactivate
- * events.
- */
- Shell shell = getShell ();
- if (!shell.isDisposed ()) {
- shell.setActiveControl (this);
- }
- return OS.Pt_CONTINUE;
-}
-
-int Ph_EV_BUT_RELEASE (int widget, 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);
- if ((ev.processing_flags & OS.Ph_FAKE_EVENT) != 0) {
- return OS.Pt_CONTINUE;
- }
- ev.processing_flags |= OS.Ph_CONSUMED;
- OS.memmove (cbinfo.event, ev, PhEvent_t.sizeof);
- if (ev.subtype != OS.Ph_EV_RELEASE_PHANTOM) {
- return OS.Pt_CONTINUE;
- }
- 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 event = new Event ();
- event.time = ev.timestamp;
- setMouseState (event, pe, ev);
- postEvent (SWT.MouseUp, event);
- return OS.Pt_CONTINUE;
-}
-
-int Ph_EV_DRAG (int widget, 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);
- if ((ev.processing_flags & OS.Ph_FAKE_EVENT) != 0) {
- return OS.Pt_CONTINUE;
- }
- if (ev.subtype != OS.Ph_EV_DRAG_MOTION_EVENT) {
- return OS.Pt_CONTINUE;
- }
- 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 event = new Event ();
- event.time = ev.timestamp;
- setMouseState (event, pe, ev);
- postEvent (SWT.MouseMove, event);
- return OS.Pt_CONTINUE;
-}
-
-int Ph_EV_KEY (int widget, int info) {
- if (!hasFocus ()) return OS.Pt_PROCESS;
- if (info == 0) return OS.Pt_PROCESS;
- PtCallbackInfo_t cbinfo = new PtCallbackInfo_t ();
- OS.memmove (cbinfo, info, PtCallbackInfo_t.sizeof);
- if (cbinfo.event == 0) return OS.Pt_PROCESS;
- PhEvent_t ev = new PhEvent_t ();
- OS.memmove (ev, cbinfo.event, PhEvent_t.sizeof);
- if ((ev.processing_flags & OS.Ph_FAKE_EVENT) != 0) {
- return OS.Pt_PROCESS;
- }
- int data = OS.PhGetData (cbinfo.event);
- if (data == 0) return OS.Pt_PROCESS;
- PhKeyEvent_t ke = new PhKeyEvent_t ();
- OS.memmove (ke, data, PhKeyEvent_t.sizeof);
-
- /*
- * 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 OS.Pt_PROCESS;
- }
-
- /* Ignore repeating modifier keys */
- 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:
- return OS.Pt_PROCESS;
- }
- }
- }
-
- /* Determine event type */
- int type = SWT.KeyUp;
- if ((ke.key_flags & (OS.Pk_KF_Key_Down | OS.Pk_KF_Key_Repeat)) != 0) {
- type = SWT.KeyDown;
- }
-
- /* Determine if this is a traverse event */
- if (type == SWT.KeyDown) {
- /*
- * Fetuare in Photon. The key_sym value is not valid when Ctrl
- * or Alt is pressed. The fix is to detect this case and try to
- * use the key_cap value.
- */
- int key = ke.key_sym;
- if ((ke.key_flags & OS.Pk_KF_Sym_Valid) == 0) {
- key = 0;
- if ((ke.key_flags & OS.Pk_KF_Cap_Valid) != 0) {
- if (ke.key_cap == OS.Pk_Tab && (ke.key_mods & OS.Pk_KM_Ctrl) != 0) {
- key = OS.Pk_Tab;
- }
- }
- }
-
- switch (key) {
- case OS.Pk_Escape:
- case OS.Pk_Return:
- case OS.Pk_KP_Tab:
- case OS.Pk_Tab:
- case OS.Pk_Up:
- case OS.Pk_Down:
- case OS.Pk_Left:
- case OS.Pk_Right:
- case OS.Pk_Pg_Up:
- case OS.Pk_Pg_Down: {
- if (key != OS.Pk_Return) {
- ev.processing_flags |= OS.Ph_NOT_CUAKEY;
- OS.memmove (cbinfo.event, ev, PhEvent_t.sizeof);
- }
- if (translateTraversal (key, ke)) {
- ev.processing_flags |= OS.Ph_CONSUMED;
- OS.memmove (cbinfo.event, ev, PhEvent_t.sizeof);
- return OS.Pt_PROCESS;
- }
- // widget could be disposed at this point
- if (isDisposed ()) return OS.Pt_PROCESS;
- }
- }
- }
-
- Event event = new Event ();
- event.time = ev.timestamp;
- setKeyState (event, ke);
- Display display = getDisplay ();
- if (type == SWT.KeyDown) {
- display.lastKey = event.keyCode;
- display.lastAscii = event.character;
- } else {
- if (event.keyCode == 0) event.keyCode = display.lastKey;
- if (event.character == 0) event.character = (char) display.lastAscii;
- }
- postEvent (type, event);
- return OS.Pt_PROCESS;
-}
-
-int Ph_EV_PTR_MOTION (int widget, 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);
- if ((ev.processing_flags & OS.Ph_FAKE_EVENT) != 0) {
- return OS.Pt_CONTINUE;
- }
- ev.processing_flags |= OS.Ph_CONSUMED;
- OS.memmove (cbinfo.event, ev, PhEvent_t.sizeof);
- if (ev.type == OS.Ph_EV_PTR_MOTION_BUTTON) {
- if ((state & CANVAS) != 0) return OS.Pt_CONTINUE;
- }
- 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 event = new Event ();
- event.time = ev.timestamp;
- setMouseState (event, pe, ev);
- postEvent (SWT.MouseMove, event);
- return OS.Pt_CONTINUE;
-}
-
-int Pt_CB_GOT_FOCUS (int widget, int info) {
- Shell shell = getShell ();
- sendEvent (SWT.FocusIn);
- if (isDisposed ()) return OS.Pt_CONTINUE;
-
- /*
- * It is possible that the shell may be
- * disposed at this point. If this happens
- * don't send the activate and deactivate
- * events.
- */
- if (!shell.isDisposed ()) {
- shell.setActiveControl (this);
- }
-
- /*
- * Feature in Photon. Cannot return Pt_END
- * or the text widget will not take focus.
- */
- return OS.Pt_CONTINUE;
-}
-
-int Pt_CB_LOST_FOCUS (int widget, int info) {
- Shell shell = getShell ();
- sendEvent (SWT.FocusOut);
- if (isDisposed ()) return OS.Pt_CONTINUE;
-
- /*
- * It is possible that the shell may be
- * disposed at this point. If this happens
- * don't send the activate and deactivate
- * events.
- */
- if (!shell.isDisposed ()) {
- Display display = shell.getDisplay ();
- Control control = display.getFocusControl ();
- if (control == null || shell != control.getShell () ) {
- shell.setActiveControl (null);
- }
- }
-
- /*
- * Feature in Photon. Cannot return Pt_END
- * or the text widget will not take focus.
- */
- return OS.Pt_CONTINUE;
-}
-
-void realizeWidget() {
- int parentHandle = parent.handle;
- if (OS.PtWidgetIsRealized (parentHandle)) {
- OS.PtRealizeWidget (topHandle ());
- }
-}
-
-void releaseWidget () {
- super.releaseWidget ();
- if (toolTipHandle != 0) destroyToolTip (toolTipHandle);
- toolTipHandle = 0;
- if (menu != null && !menu.isDisposed ()) {
- menu.dispose ();
- }
- menu = null;
- parent = null;
- layoutData = null;
-}
-
+public void pack (boolean changed) {
+ checkWidget();
+ setSize (computeSize (SWT.DEFAULT, SWT.DEFAULT, changed));
+}
+
+int Ph_EV_BOUNDARY (int widget, 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;
+ PhPointerEvent_t pe = new PhPointerEvent_t ();
+ OS.memmove (pe, data, PhPointerEvent_t.sizeof);
+ Event event = new Event ();
+ event.time = ev.timestamp;
+ setMouseState (event, pe, ev);
+ switch ((int) 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;
+ case OS.Ph_EV_PTR_STEADY:
+ postEvent (SWT.MouseHover, event);
+ destroyToolTip (toolTipHandle);
+ toolTipHandle = createToolTip (toolTipText, handle, getFont ().handle);
+ break;
+ case OS.Ph_EV_PTR_UNSTEADY:
+ destroyToolTip (toolTipHandle);
+ toolTipHandle = 0;
+ break;
+ }
+ return OS.Pt_END;
+}
+
+int Ph_EV_BUT_PRESS (int widget, 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);
+ if ((ev.processing_flags & OS.Ph_FAKE_EVENT) != 0) {
+ return OS.Pt_CONTINUE;
+ }
+ ev.processing_flags |= OS.Ph_CONSUMED;
+ OS.memmove (cbinfo.event, ev, 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);
+ Event event = new Event ();
+ event.time = ev.timestamp;
+ setMouseState (event, pe, ev);
+ postEvent (SWT.MouseDown, event);
+ if (pe.click_count == 2) {
+ Event clickEvent = new Event ();
+ clickEvent.time = event.time;
+ clickEvent.x = event.x;
+ clickEvent.y = event.y;
+ clickEvent.button = event.button;
+ clickEvent.stateMask = event.stateMask;
+ postEvent (SWT.MouseDoubleClick, clickEvent);
+ }
+ if (event.button == 3) {
+ if (menu != null && !menu.isDisposed ()) {
+ Display display = getDisplay ();
+ display.runDeferredEvents ();
+ menu.setVisible (true);
+ }
+ }
+ /*
+ * It is possible that the shell may be
+ * disposed at this point. If this happens
+ * don't send the activate and deactivate
+ * events.
+ */
+ Shell shell = getShell ();
+ if (!shell.isDisposed ()) {
+ shell.setActiveControl (this);
+ }
+ return OS.Pt_CONTINUE;
+}
+
+int Ph_EV_BUT_RELEASE (int widget, 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);
+ if ((ev.processing_flags & OS.Ph_FAKE_EVENT) != 0) {
+ return OS.Pt_CONTINUE;
+ }
+ ev.processing_flags |= OS.Ph_CONSUMED;
+ OS.memmove (cbinfo.event, ev, PhEvent_t.sizeof);
+ if (ev.subtype != OS.Ph_EV_RELEASE_PHANTOM) {
+ return OS.Pt_CONTINUE;
+ }
+ 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 event = new Event ();
+ event.time = ev.timestamp;
+ setMouseState (event, pe, ev);
+ postEvent (SWT.MouseUp, event);
+ return OS.Pt_CONTINUE;
+}
+
+int Ph_EV_DRAG (int widget, 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);
+ if ((ev.processing_flags & OS.Ph_FAKE_EVENT) != 0) {
+ return OS.Pt_CONTINUE;
+ }
+ if (ev.subtype != OS.Ph_EV_DRAG_MOTION_EVENT) {
+ return OS.Pt_CONTINUE;
+ }
+ 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 event = new Event ();
+ event.time = ev.timestamp;
+ setMouseState (event, pe, ev);
+ postEvent (SWT.MouseMove, event);
+ return OS.Pt_CONTINUE;
+}
+
+int Ph_EV_KEY (int widget, int info) {
+ if (!hasFocus ()) return OS.Pt_PROCESS;
+ if (info == 0) return OS.Pt_PROCESS;
+ PtCallbackInfo_t cbinfo = new PtCallbackInfo_t ();
+ OS.memmove (cbinfo, info, PtCallbackInfo_t.sizeof);
+ if (cbinfo.event == 0) return OS.Pt_PROCESS;
+ PhEvent_t ev = new PhEvent_t ();
+ OS.memmove (ev, cbinfo.event, PhEvent_t.sizeof);
+ if ((ev.processing_flags & OS.Ph_FAKE_EVENT) != 0) {
+ return OS.Pt_PROCESS;
+ }
+ int data = OS.PhGetData (cbinfo.event);
+ if (data == 0) return OS.Pt_PROCESS;
+ PhKeyEvent_t ke = new PhKeyEvent_t ();
+ OS.memmove (ke, data, PhKeyEvent_t.sizeof);
+
+ /*
+ * 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 OS.Pt_PROCESS;
+ }
+
+ /* Ignore repeating modifier keys */
+ 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:
+ return OS.Pt_PROCESS;
+ }
+ }
+ }
+
+ /* Determine event type */
+ int type = SWT.KeyUp;
+ if ((ke.key_flags & (OS.Pk_KF_Key_Down | OS.Pk_KF_Key_Repeat)) != 0) {
+ type = SWT.KeyDown;
+ }
+
+ /* Determine if this is a traverse event */
+ if (type == SWT.KeyDown) {
+ /*
+ * Fetuare in Photon. The key_sym value is not valid when Ctrl
+ * or Alt is pressed. The fix is to detect this case and try to
+ * use the key_cap value.
+ */
+ int key = ke.key_sym;
+ if ((ke.key_flags & OS.Pk_KF_Sym_Valid) == 0) {
+ key = 0;
+ if ((ke.key_flags & OS.Pk_KF_Cap_Valid) != 0) {
+ if (ke.key_cap == OS.Pk_Tab && (ke.key_mods & OS.Pk_KM_Ctrl) != 0) {
+ key = OS.Pk_Tab;
+ }
+ }
+ }
+
+ switch (key) {
+ case OS.Pk_Escape:
+ case OS.Pk_Return:
+ case OS.Pk_KP_Tab:
+ case OS.Pk_Tab:
+ case OS.Pk_Up:
+ case OS.Pk_Down:
+ case OS.Pk_Left:
+ case OS.Pk_Right:
+ case OS.Pk_Pg_Up:
+ case OS.Pk_Pg_Down: {
+ if (key != OS.Pk_Return) {
+ ev.processing_flags |= OS.Ph_NOT_CUAKEY;
+ OS.memmove (cbinfo.event, ev, PhEvent_t.sizeof);
+ }
+ if (translateTraversal (key, ke)) {
+ ev.processing_flags |= OS.Ph_CONSUMED;
+ OS.memmove (cbinfo.event, ev, PhEvent_t.sizeof);
+ return OS.Pt_PROCESS;
+ }
+ // widget could be disposed at this point
+ if (isDisposed ()) return OS.Pt_PROCESS;
+ }
+ }
+ }
+
+ Event event = new Event ();
+ event.time = ev.timestamp;
+ setKeyState (event, ke);
+ Display display = getDisplay ();
+ if (type == SWT.KeyDown) {
+ display.lastKey = event.keyCode;
+ display.lastAscii = event.character;
+ } else {
+ if (event.keyCode == 0) event.keyCode = display.lastKey;
+ if (event.character == 0) event.character = (char) display.lastAscii;
+ }
+ postEvent (type, event);
+ return OS.Pt_PROCESS;
+}
+
+int Ph_EV_PTR_MOTION (int widget, 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);
+ if ((ev.processing_flags & OS.Ph_FAKE_EVENT) != 0) {
+ return OS.Pt_CONTINUE;
+ }
+ ev.processing_flags |= OS.Ph_CONSUMED;
+ OS.memmove (cbinfo.event, ev, PhEvent_t.sizeof);
+ if (ev.type == OS.Ph_EV_PTR_MOTION_BUTTON) {
+ if ((state & CANVAS) != 0) return OS.Pt_CONTINUE;
+ }
+ 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 event = new Event ();
+ event.time = ev.timestamp;
+ setMouseState (event, pe, ev);
+ postEvent (SWT.MouseMove, event);
+ return OS.Pt_CONTINUE;
+}
+
+int Pt_CB_GOT_FOCUS (int widget, int info) {
+ Shell shell = getShell ();
+ sendEvent (SWT.FocusIn);
+ if (isDisposed ()) return OS.Pt_CONTINUE;
+
+ /*
+ * It is possible that the shell may be
+ * disposed at this point. If this happens
+ * don't send the activate and deactivate
+ * events.
+ */
+ if (!shell.isDisposed ()) {
+ shell.setActiveControl (this);
+ }
+
+ /*
+ * Feature in Photon. Cannot return Pt_END
+ * or the text widget will not take focus.
+ */
+ return OS.Pt_CONTINUE;
+}
+
+int Pt_CB_LOST_FOCUS (int widget, int info) {
+ Shell shell = getShell ();
+ sendEvent (SWT.FocusOut);
+ if (isDisposed ()) return OS.Pt_CONTINUE;
+
+ /*
+ * It is possible that the shell may be
+ * disposed at this point. If this happens
+ * don't send the activate and deactivate
+ * events.
+ */
+ if (!shell.isDisposed ()) {
+ Display display = shell.getDisplay ();
+ Control control = display.getFocusControl ();
+ if (control == null || shell != control.getShell () ) {
+ shell.setActiveControl (null);
+ }
+ }
+
+ /*
+ * Feature in Photon. Cannot return Pt_END
+ * or the text widget will not take focus.
+ */
+ return OS.Pt_CONTINUE;
+}
+
+void realizeWidget() {
+ int parentHandle = parent.handle;
+ if (OS.PtWidgetIsRealized (parentHandle)) {
+ OS.PtRealizeWidget (topHandle ());
+ }
+}
+
+void releaseWidget () {
+ super.releaseWidget ();
+ if (toolTipHandle != 0) destroyToolTip (toolTipHandle);
+ toolTipHandle = 0;
+ if (menu != null && !menu.isDisposed ()) {
+ menu.dispose ();
+ }
+ menu = null;
+ parent = null;
+ layoutData = null;
+}
+
/**
* Causes the entire bounds of the receiver to be marked
* as needing to be redrawn. The next time a paint request
@@ -1539,11 +1539,11 @@ void releaseWidget () {
*
* @see #update
*/
-public void redraw () {
- checkWidget();
- OS.PtDamageWidget (handle);
-}
-
+public void redraw () {
+ checkWidget();
+ OS.PtDamageWidget (handle);
+}
+
/**
* Causes the rectangular area of the receiver specified by
* the arguments to be marked as needing to be redrawn.
@@ -1567,17 +1567,17 @@ public void redraw () {
*
* @see #update
*/
-public void redraw (int x, int y, int width, int height, boolean allChildren) {
- checkWidget ();
- if (width <= 0 || height <= 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);
- OS.PtDamageExtent (handle, rect);
-}
-
+public void redraw (int x, int y, int width, int height, boolean allChildren) {
+ checkWidget ();
+ if (width <= 0 || height <= 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);
+ OS.PtDamageExtent (handle, rect);
+}
+
/**
* Removes the listener from the collection of listeners who will
* be notified when the control is moved or resized.
@@ -1595,14 +1595,14 @@ public void redraw (int x, int y, int width, int height, boolean allChildren) {
* @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);
-}
-
+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.
@@ -1620,14 +1620,14 @@ public void removeControlListener (ControlListener listener) {
* @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);
-}
-
+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.
@@ -1645,13 +1645,13 @@ public void removeFocusListener(FocusListener listener) {
* @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);
-}
-
+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.
@@ -1669,14 +1669,14 @@ public void removeHelpListener (HelpListener listener) {
* @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);
-}
-
+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.
@@ -1694,15 +1694,15 @@ public void removeKeyListener(KeyListener listener) {
* @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);
-}
-
+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.
@@ -1720,15 +1720,15 @@ public void removeMouseTrackListener(MouseTrackListener listener) {
* @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);
-}
-
+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.
@@ -1746,13 +1746,13 @@ public void removeMouseListener (MouseListener listener) {
* @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);
-}
-
+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.
@@ -1770,13 +1770,13 @@ public void removeMouseMoveListener(MouseMoveListener listener) {
* @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);
-}
-
+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.
@@ -1794,65 +1794,65 @@ public void removePaintListener(PaintListener listener) {
* @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);
-}
-
-int setBounds (int x, int y, int width, int height, boolean move, boolean resize, boolean events) {
- int topHandle = topHandle ();
- PhArea_t area = new PhArea_t ();
- OS.PtWidgetArea (topHandle, area);
- width = Math.max (width, 0);
- height = Math.max (height, 0);
- boolean sameOrigin = x == area.pos_x && y == area.pos_y;
- boolean sameExtent = width == area.size_w && height == area.size_h;
- if (move && resize) {
- if (sameOrigin && sameExtent) return 0;
- area.pos_x = (short) x;
- area.pos_y = (short) y;
- area.size_w = (short) width;
- area.size_h = (short) height;
- int ptr = OS.malloc (PhArea_t.sizeof);
- OS.memmove (ptr, area, PhArea_t.sizeof);
- OS.PtSetResource (topHandle, OS.Pt_ARG_AREA, ptr, 0);
- OS.free (ptr);
- } else {
- if (move) {
- if (sameOrigin) return 0;
- 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);
- OS.PtSetResource (topHandle, OS.Pt_ARG_POS, ptr, 0);
- OS.free (ptr);
- } else if (resize) {
- if (sameExtent) return 0;
- int [] args = {
- OS.Pt_ARG_WIDTH, width, 0,
- OS.Pt_ARG_HEIGHT, height, 0,
- };
- OS.PtSetResources (topHandle, args.length / 3, args);
- }
- }
- if (!OS.PtWidgetIsRealized (topHandle)) {
- OS.PtExtentWidgetFamily (topHandle);
- }
- int result = 0;
- if (move && !sameOrigin) {
- sendEvent (SWT.Move);
- result |= MOVED;
- }
- if (resize && !sameExtent) {
- sendEvent (SWT.Resize);
- result |= RESIZED;
- }
- return result;
-}
-
+public void removeTraverseListener(TraverseListener listener) {
+ checkWidget();
+ if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+ if (eventTable == null) return;
+ eventTable.unhook (SWT.Traverse, listener);
+}
+
+int setBounds (int x, int y, int width, int height, boolean move, boolean resize, boolean events) {
+ int topHandle = topHandle ();
+ PhArea_t area = new PhArea_t ();
+ OS.PtWidgetArea (topHandle, area);
+ width = Math.max (width, 0);
+ height = Math.max (height, 0);
+ boolean sameOrigin = x == area.pos_x && y == area.pos_y;
+ boolean sameExtent = width == area.size_w && height == area.size_h;
+ if (move && resize) {
+ if (sameOrigin && sameExtent) return 0;
+ area.pos_x = (short) x;
+ area.pos_y = (short) y;
+ area.size_w = (short) width;
+ area.size_h = (short) height;
+ int ptr = OS.malloc (PhArea_t.sizeof);
+ OS.memmove (ptr, area, PhArea_t.sizeof);
+ OS.PtSetResource (topHandle, OS.Pt_ARG_AREA, ptr, 0);
+ OS.free (ptr);
+ } else {
+ if (move) {
+ if (sameOrigin) return 0;
+ 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);
+ OS.PtSetResource (topHandle, OS.Pt_ARG_POS, ptr, 0);
+ OS.free (ptr);
+ } else if (resize) {
+ if (sameExtent) return 0;
+ int [] args = {
+ OS.Pt_ARG_WIDTH, width, 0,
+ OS.Pt_ARG_HEIGHT, height, 0,
+ };
+ OS.PtSetResources (topHandle, args.length / 3, args);
+ }
+ }
+ if (!OS.PtWidgetIsRealized (topHandle)) {
+ OS.PtExtentWidgetFamily (topHandle);
+ }
+ int result = 0;
+ if (move && !sameOrigin) {
+ sendEvent (SWT.Move);
+ result |= MOVED;
+ }
+ if (resize && !sameExtent) {
+ sendEvent (SWT.Resize);
+ result |= RESIZED;
+ }
+ return result;
+}
+
/**
* Sets the receiver's size and location to the rectangular
* area specified by the arguments. The <code>x</code> and
@@ -1874,11 +1874,11 @@ int setBounds (int x, int y, int width, int height, boolean move, boolean resize
* <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, width, height, true, true, true);
-}
-
+public void setBounds (int x, int y, int width, int height) {
+ checkWidget();
+ setBounds (x, y, width, height, true, true, true);
+}
+
/**
* Sets the receiver's size and location to the rectangular
* area specified by the argument. The <code>x</code> and
@@ -1897,11 +1897,11 @@ public void setBounds (int x, int y, int width, int height) {
* <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);
-}
-
+public void setBounds (Rectangle rect) {
+ 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
@@ -1914,10 +1914,10 @@ public void setBounds (Rectangle rect) {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public void setCapture (boolean capture) {
- checkWidget();
-}
-
+public void setCapture (boolean capture) {
+ checkWidget();
+}
+
/**
* Sets the receiver's cursor to the cursor specified by the
* argument, or to the default cursor for that kind of control
@@ -1937,33 +1937,33 @@ public void setCapture (boolean capture) {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public void setCursor (Cursor cursor) {
- checkWidget();
- int type = OS.Ph_CURSOR_INHERIT;
- int bitmap = 0;
- if (cursor != null) {
- if (cursor.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
- type = cursor.type;
- bitmap = cursor.bitmap;
- }
- int [] args = new int []{
- OS.Pt_ARG_CURSOR_TYPE, type, 0,
- OS.Pt_ARG_BITMAP_CURSOR, bitmap, 0,
- };
- OS.PtSetResources (handle, args.length / 3, args);
-
- /*
- * Bug in Photon. For some reason, the widget cursor will
- * not change, when the new cursor is a bitmap cursor, if
- * the flag Ph_CURSOR_NO_INHERIT is reset. The fix is to reset
- * this flag after changing the cursor type to Ph_CURSOR_BITMAP.
- */
- if (type == OS.Ph_CURSOR_BITMAP) {
- type &= ~OS.Ph_CURSOR_NO_INHERIT;
- OS.PtSetResource (handle, OS.Pt_ARG_CURSOR_TYPE, type, 0);
- }
-}
-
+public void setCursor (Cursor cursor) {
+ checkWidget();
+ int type = OS.Ph_CURSOR_INHERIT;
+ int bitmap = 0;
+ if (cursor != null) {
+ if (cursor.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+ type = cursor.type;
+ bitmap = cursor.bitmap;
+ }
+ int [] args = new int []{
+ OS.Pt_ARG_CURSOR_TYPE, type, 0,
+ OS.Pt_ARG_BITMAP_CURSOR, bitmap, 0,
+ };
+ OS.PtSetResources (handle, args.length / 3, args);
+
+ /*
+ * Bug in Photon. For some reason, the widget cursor will
+ * not change, when the new cursor is a bitmap cursor, if
+ * the flag Ph_CURSOR_NO_INHERIT is reset. The fix is to reset
+ * this flag after changing the cursor type to Ph_CURSOR_BITMAP.
+ */
+ if (type == OS.Ph_CURSOR_BITMAP) {
+ type &= ~OS.Ph_CURSOR_NO_INHERIT;
+ OS.PtSetResource (handle, OS.Pt_ARG_CURSOR_TYPE, type, 0);
+ }
+}
+
/**
* Enables the receiver if the argument is <code>true</code>,
* and disables it otherwise. A disabled control is typically
@@ -1977,13 +1977,13 @@ public void setCursor (Cursor cursor) {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public void setEnabled (boolean enabled) {
- checkWidget ();
- int topHandle = topHandle ();
- int flags = enabled ? 0 : OS.Pt_BLOCKED | OS.Pt_GHOST;
- OS.PtSetResource (topHandle, OS.Pt_ARG_FLAGS, flags, OS.Pt_BLOCKED | OS.Pt_GHOST);
-}
-
+public void setEnabled (boolean enabled) {
+ checkWidget ();
+ int topHandle = topHandle ();
+ int flags = enabled ? 0 : OS.Pt_BLOCKED | OS.Pt_GHOST;
+ OS.PtSetResource (topHandle, OS.Pt_ARG_FLAGS, flags, OS.Pt_BLOCKED | OS.Pt_GHOST);
+}
+
/**
* Causes the receiver to have the <em>keyboard focus</em>,
* such that all keyboard events will be delivered to it.
@@ -1997,11 +1997,11 @@ public void setEnabled (boolean enabled) {
*
* @see #forceFocus
*/
-public boolean setFocus () {
- checkWidget();
- return forceFocus ();
-}
-
+public boolean setFocus () {
+ checkWidget();
+ return forceFocus ();
+}
+
/**
* Sets the receiver's background color to the color specified
* by the argument, or to the default system color for the control
@@ -2017,27 +2017,27 @@ public boolean setFocus () {
* <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;
- if (color == null) {
- pixel = defaultBackground ();
- } else {
- if (color.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
- pixel = color.handle;
- }
- setBackgroundPixel (pixel);
-}
-
-void setBackgroundPixel (int pixel) {
- OS.PtSetResource (handle, OS.Pt_ARG_FILL_COLOR, pixel, 0);
-}
-
-void setDefaultFont () {
- Display display = getDisplay ();
- if (display.defaultFont != null) setFont (defaultFont ());
-}
-
+public void setBackground (Color color) {
+ checkWidget();
+ int pixel;
+ if (color == null) {
+ pixel = defaultBackground ();
+ } else {
+ if (color.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+ pixel = color.handle;
+ }
+ setBackgroundPixel (pixel);
+}
+
+void setBackgroundPixel (int pixel) {
+ OS.PtSetResource (handle, OS.Pt_ARG_FILL_COLOR, pixel, 0);
+}
+
+void setDefaultFont () {
+ Display display = getDisplay ();
+ if (display.defaultFont != null) setFont (defaultFont ());
+}
+
/**
* 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
@@ -2053,35 +2053,35 @@ void setDefaultFont () {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public void setFont (Font font) {
- checkWidget();
- byte[] buffer;
- if (font != null) {
- if (font.isDisposed ()) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
- buffer = font.handle;
- } else {
- buffer = defaultFont ();
- }
- setFont (buffer);
-}
-
-void setFont (byte [] font) {
- int ptr = OS.malloc (font.length);
- OS.memmove (ptr, font, font.length);
- setFont (ptr);
- OS.free (ptr);
-}
-
-void setFont (int font) {
- int [] args = {
- OS.Pt_ARG_TEXT_FONT, font, 0,
- OS.Pt_ARG_LIST_FONT, font, 0,
- OS.Pt_ARG_TITLE_FONT, font, 0,
- OS.Pt_ARG_GAUGE_FONT, font, 0,
- };
- OS.PtSetResources (handle, args.length / 3, args);
-}
-
+public void setFont (Font font) {
+ checkWidget();
+ byte[] buffer;
+ if (font != null) {
+ if (font.isDisposed ()) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+ buffer = font.handle;
+ } else {
+ buffer = defaultFont ();
+ }
+ setFont (buffer);
+}
+
+void setFont (byte [] font) {
+ int ptr = OS.malloc (font.length);
+ OS.memmove (ptr, font, font.length);
+ setFont (ptr);
+ OS.free (ptr);
+}
+
+void setFont (int font) {
+ int [] args = {
+ OS.Pt_ARG_TEXT_FONT, font, 0,
+ OS.Pt_ARG_LIST_FONT, font, 0,
+ OS.Pt_ARG_TITLE_FONT, font, 0,
+ OS.Pt_ARG_GAUGE_FONT, font, 0,
+ };
+ OS.PtSetResources (handle, args.length / 3, args);
+}
+
/**
* Sets the receiver's foreground color to the color specified
* by the argument, or to the default system color for the control
@@ -2097,22 +2097,22 @@ void setFont (int font) {
* <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;
- if (color == null) {
- pixel = defaultForeground ();
- } else {
- if (color.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
- pixel = color.handle;
- }
- setForegroundPixel (pixel);
-}
-
-void setForegroundPixel (int pixel) {
- OS.PtSetResource (handle, OS.Pt_ARG_COLOR, pixel, 0);
-}
-
+public void setForeground (Color color) {
+ checkWidget();
+ int pixel;
+ if (color == null) {
+ pixel = defaultForeground ();
+ } else {
+ if (color.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+ pixel = color.handle;
+ }
+ setForegroundPixel (pixel);
+}
+
+void setForegroundPixel (int pixel) {
+ OS.PtSetResource (handle, OS.Pt_ARG_COLOR, pixel, 0);
+}
+
/**
* Sets the layout data associated with the receiver to the argument.
*
@@ -2123,11 +2123,11 @@ void setForegroundPixel (int pixel) {
* <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;
-}
-
+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
@@ -2141,11 +2141,11 @@ public void setLayoutData (Object layoutData) {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public void setLocation (int x, int y) {
- checkWidget();
- setBounds (x, y, 0, 0, true, false, true);
-}
-
+public void setLocation (int x, int y) {
+ checkWidget();
+ setBounds (x, y, 0, 0, true, false, true);
+}
+
/**
* Sets the receiver's location to the point specified by
* the argument which is relative to the receiver's
@@ -2158,12 +2158,12 @@ public void setLocation (int x, int y) {
* <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);
-}
-
+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
@@ -2184,17 +2184,17 @@ public void setLocation (Point location) {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public void setMenu (Menu menu) {
- checkWidget();
- int flags = 0;
- if (menu != null) {
- if (menu.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
- flags = OS.Pt_MENUABLE;
- }
- OS.PtSetResource (handle, OS.Pt_ARG_FLAGS, flags, OS.Pt_ALL_BUTTONS | OS.Pt_MENUABLE);
- this.menu = menu;
-}
-
+public void setMenu (Menu menu) {
+ checkWidget();
+ int flags = 0;
+ if (menu != null) {
+ if (menu.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+ flags = OS.Pt_MENUABLE;
+ }
+ OS.PtSetResource (handle, OS.Pt_ARG_FLAGS, flags, OS.Pt_ALL_BUTTONS | OS.Pt_MENUABLE);
+ this.menu = menu;
+}
+
/**
* Changes the parent of the widget to be the one provided if
* the underlying operating system supports this feature.
@@ -2211,12 +2211,12 @@ public void setMenu (Menu menu) {
* <li>ERROR_WIDGET_DISPOSED when the widget has been disposed</li>
* </ul>
*/
-public boolean setParent (Composite parent) {
- checkWidget();
- if (parent.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
- return false;
-}
-
+public boolean setParent (Composite parent) {
+ checkWidget();
+ if (parent.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+ return false;
+}
+
/**
* Sets the receiver's size to the point specified by the argument.
* <p>
@@ -2236,25 +2236,25 @@ public boolean setParent (Composite parent) {
* <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 () {
- if (!isShowing ()) return false;
- return setFocus ();
-}
-
-boolean setRadioSelection (boolean value) {
- return false;
-}
-
+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 () {
+ if (!isShowing ()) return false;
+ return setFocus ();
+}
+
+boolean setRadioSelection (boolean value) {
+ return false;
+}
+
/**
* If the argument is <code>false</code>, causes subsequent drawing
* operations in the receiver to be ignored. No drawing of any kind
@@ -2277,14 +2277,14 @@ boolean setRadioSelection (boolean value) {
* @see #redraw
* @see #update
*/
-public void setRedraw (boolean redraw) {
- checkWidget();
- if (redraw) {
- OS.PtContainerRelease (handle);
- } else {
- OS.PtContainerHold (handle);
- }
-}
+public void setRedraw (boolean redraw) {
+ checkWidget();
+ if (redraw) {
+ OS.PtContainerRelease (handle);
+ } else {
+ OS.PtContainerHold (handle);
+ }
+}
/**
* Sets the receiver's size to the point specified by the arguments.
* <p>
@@ -2301,11 +2301,11 @@ public void setRedraw (boolean redraw) {
* <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, width, height, false, true, true);
-}
-
+public void setSize (int width, int height) {
+ checkWidget();
+ setBounds (0, 0, width, height, false, true, true);
+}
+
/**
* Marks the receiver as visible if the argument is <code>true</code>,
* and marks it invisible otherwise.
@@ -2322,22 +2322,22 @@ public void setSize (int width, int height) {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public void setVisible (boolean visible) {
- checkWidget ();
- int topHandle = topHandle ();
- int flags = visible ? 0 : OS.Pt_DELAY_REALIZE;
- OS.PtSetResource (topHandle, OS.Pt_ARG_FLAGS, flags, OS.Pt_DELAY_REALIZE);
- if (parent != null && !OS.PtWidgetIsRealized (parent.handle)) return;
- if (visible == OS.PtWidgetIsRealized (topHandle)) return;
- if (visible) {
- sendEvent (SWT.Show);
- OS.PtRealizeWidget (topHandle);
- } else {
- OS.PtUnrealizeWidget (topHandle);
- sendEvent(SWT.Hide);
- }
-}
-
+public void setVisible (boolean visible) {
+ checkWidget ();
+ int topHandle = topHandle ();
+ int flags = visible ? 0 : OS.Pt_DELAY_REALIZE;
+ OS.PtSetResource (topHandle, OS.Pt_ARG_FLAGS, flags, OS.Pt_DELAY_REALIZE);
+ if (parent != null && !OS.PtWidgetIsRealized (parent.handle)) return;
+ if (visible == OS.PtWidgetIsRealized (topHandle)) return;
+ if (visible) {
+ sendEvent (SWT.Show);
+ OS.PtRealizeWidget (topHandle);
+ } else {
+ OS.PtUnrealizeWidget (topHandle);
+ sendEvent(SWT.Hide);
+ }
+}
+
/**
* Sets the receiver's tool tip text to the argument, which
* may be null indicating that no tool tip text should be shown.
@@ -2349,38 +2349,38 @@ public void setVisible (boolean visible) {
* <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;
-}
-
-void setZOrder() {
- if (parent != null) parent.moveToBack (topHandle ());
-}
-
-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;
- }
- }
- }
- }
-}
-
-public Point toControl (int x, int y) {
- checkWidget();
- short [] position_x = new short [1], position_y = new short [1];
- OS.PtGetAbsPosition (handle, position_x, position_y);
- return new Point (x - position_x [0], y - position_y [0]);
-}
-
+public void setToolTipText (String string) {
+ checkWidget();
+ toolTipText = string;
+}
+
+void setZOrder() {
+ if (parent != null) parent.moveToBack (topHandle ());
+}
+
+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;
+ }
+ }
+ }
+ }
+}
+
+public Point toControl (int x, int y) {
+ checkWidget();
+ short [] position_x = new short [1], position_y = new short [1];
+ OS.PtGetAbsPosition (handle, position_x, position_y);
+ return new Point (x - position_x [0], y - position_y [0]);
+}
+
/**
* Returns a point which is the result of converting the
* argument, which is specified in display relative coordinates,
@@ -2396,19 +2396,19 @@ public Point toControl (int x, int y) {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public Point toControl (Point point) {
- checkWidget();
- if (point == null) error (SWT.ERROR_NULL_ARGUMENT);
- return toControl (point.x, point.y);
-}
-
-public Point toDisplay (int x, int y) {
- checkWidget();
- short [] position_x = new short [1], position_y = new short [1];
- OS.PtGetAbsPosition (handle, position_x, position_y);
- return new Point (x + position_x [0], y + position_y [0]);
-}
-
+public Point toControl (Point point) {
+ checkWidget();
+ if (point == null) error (SWT.ERROR_NULL_ARGUMENT);
+ return toControl (point.x, point.y);
+}
+
+public Point toDisplay (int x, int y) {
+ checkWidget();
+ short [] position_x = new short [1], position_y = new short [1];
+ OS.PtGetAbsPosition (handle, position_x, position_y);
+ return new Point (x + position_x [0], y + position_y [0]);
+}
+
/**
* Returns a point which is the result of converting the
* argument, which is specified in coordinates relative to
@@ -2424,103 +2424,103 @@ public Point toDisplay (int x, int y) {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public Point toDisplay (Point point) {
- checkWidget();
- if (point == null) error (SWT.ERROR_NULL_ARGUMENT);
- return toDisplay (point.x, point.y);
-}
-
-boolean translateTraversal (int key_sym, PhKeyEvent_t phEvent) {
- int detail = SWT.TRAVERSE_NONE;
- int code = traversalCode (key_sym, phEvent);
- boolean all = false;
- switch (key_sym) {
- case OS.Pk_Escape: {
- all = true;
- detail = SWT.TRAVERSE_ESCAPE;
- break;
- }
- case OS.Pk_Return: {
- all = true;
- detail = SWT.TRAVERSE_RETURN;
- break;
- }
- case OS.Pk_Tab:
- case OS.Pk_KP_Tab: {
- boolean next = (phEvent.key_mods & OS.Pk_KM_Shift) == 0;
- detail = next ? SWT.TRAVERSE_TAB_NEXT : SWT.TRAVERSE_TAB_PREVIOUS;
- break;
- }
- case OS.Pk_Up:
- case OS.Pk_Left: {
- detail = SWT.TRAVERSE_ARROW_PREVIOUS;
- break;
- }
- case OS.Pk_Down:
- case OS.Pk_Right: {
- detail = SWT.TRAVERSE_ARROW_NEXT;
- break;
- }
- case OS.Pk_Pg_Down:
- case OS.Pk_Pg_Up: {
- all = true;
- if ((phEvent.key_mods & OS.Pk_KM_Ctrl) == 0) return false;
- detail = key_sym == OS.Pk_Pg_Down ? SWT.TRAVERSE_PAGE_NEXT : SWT.TRAVERSE_PAGE_PREVIOUS;
- break;
- }
- default:
- return false;
- }
- Event event = new Event ();
- event.doit = (code & detail) != 0 || (phEvent.key_mods & OS.Pk_KM_Ctrl) != 0;
- event.detail = detail;
- setKeyState (event, phEvent);
- Shell shell = getShell ();
- Control control = this;
- do {
- if (control.traverse (event)) return true;
- if (!event.doit && control.hooks (SWT.Traverse)) {
- return false;
- }
- if (control == shell) return false;
- control = control.parent;
- } while (all && control != null);
- return false;
-}
-
-int traversalCode (int key_sym, PhKeyEvent_t ke) {
-// if ((OS.PtWidgetFlags (handle) & OS.Pt_GETS_FOCUS) == 0) return 0;
- int code = SWT.TRAVERSE_RETURN | SWT.TRAVERSE_TAB_NEXT | SWT.TRAVERSE_TAB_PREVIOUS;
- Shell shell = getShell ();
- if (shell.parent != null) code |= SWT.TRAVERSE_ESCAPE;
- return code;
-}
-
-boolean traverse (Event event) {
- /*
- * It is possible (but unlikely), that application
- * code could have disposed the widget in the traverse
- * event. If this happens, return true to stop further
- * event processing.
- */
- sendEvent (SWT.Traverse, event);
- if (isDisposed ()) return false;
- if (!event.doit) return false;
- switch (event.detail) {
- case SWT.TRAVERSE_NONE: return true;
- case SWT.TRAVERSE_ESCAPE: return traverseEscape ();
- case SWT.TRAVERSE_RETURN: return traverseReturn ();
- case SWT.TRAVERSE_TAB_NEXT: return traverseGroup (true);
- case SWT.TRAVERSE_TAB_PREVIOUS: return traverseGroup (false);
- case SWT.TRAVERSE_ARROW_NEXT: return traverseItem (true);
- case SWT.TRAVERSE_ARROW_PREVIOUS: return traverseItem (false);
- case SWT.TRAVERSE_MNEMONIC: return traverseMnemonic (event.character);
- case SWT.TRAVERSE_PAGE_NEXT: return traversePage (true);
- case SWT.TRAVERSE_PAGE_PREVIOUS: return traversePage (false);
- }
- return false;
-}
-
+public Point toDisplay (Point point) {
+ checkWidget();
+ if (point == null) error (SWT.ERROR_NULL_ARGUMENT);
+ return toDisplay (point.x, point.y);
+}
+
+boolean translateTraversal (int key_sym, PhKeyEvent_t phEvent) {
+ int detail = SWT.TRAVERSE_NONE;
+ int code = traversalCode (key_sym, phEvent);
+ boolean all = false;
+ switch (key_sym) {
+ case OS.Pk_Escape: {
+ all = true;
+ detail = SWT.TRAVERSE_ESCAPE;
+ break;
+ }
+ case OS.Pk_Return: {
+ all = true;
+ detail = SWT.TRAVERSE_RETURN;
+ break;
+ }
+ case OS.Pk_Tab:
+ case OS.Pk_KP_Tab: {
+ boolean next = (phEvent.key_mods & OS.Pk_KM_Shift) == 0;
+ detail = next ? SWT.TRAVERSE_TAB_NEXT : SWT.TRAVERSE_TAB_PREVIOUS;
+ break;
+ }
+ case OS.Pk_Up:
+ case OS.Pk_Left: {
+ detail = SWT.TRAVERSE_ARROW_PREVIOUS;
+ break;
+ }
+ case OS.Pk_Down:
+ case OS.Pk_Right: {
+ detail = SWT.TRAVERSE_ARROW_NEXT;
+ break;
+ }
+ case OS.Pk_Pg_Down:
+ case OS.Pk_Pg_Up: {
+ all = true;
+ if ((phEvent.key_mods & OS.Pk_KM_Ctrl) == 0) return false;
+ detail = key_sym == OS.Pk_Pg_Down ? SWT.TRAVERSE_PAGE_NEXT : SWT.TRAVERSE_PAGE_PREVIOUS;
+ break;
+ }
+ default:
+ return false;
+ }
+ Event event = new Event ();
+ event.doit = (code & detail) != 0 || (phEvent.key_mods & OS.Pk_KM_Ctrl) != 0;
+ event.detail = detail;
+ setKeyState (event, phEvent);
+ Shell shell = getShell ();
+ Control control = this;
+ do {
+ if (control.traverse (event)) return true;
+ if (!event.doit && control.hooks (SWT.Traverse)) {
+ return false;
+ }
+ if (control == shell) return false;
+ control = control.parent;
+ } while (all && control != null);
+ return false;
+}
+
+int traversalCode (int key_sym, PhKeyEvent_t ke) {
+// if ((OS.PtWidgetFlags (handle) & OS.Pt_GETS_FOCUS) == 0) return 0;
+ int code = SWT.TRAVERSE_RETURN | SWT.TRAVERSE_TAB_NEXT | SWT.TRAVERSE_TAB_PREVIOUS;
+ Shell shell = getShell ();
+ if (shell.parent != null) code |= SWT.TRAVERSE_ESCAPE;
+ return code;
+}
+
+boolean traverse (Event event) {
+ /*
+ * It is possible (but unlikely), that application
+ * code could have disposed the widget in the traverse
+ * event. If this happens, return true to stop further
+ * event processing.
+ */
+ sendEvent (SWT.Traverse, event);
+ if (isDisposed ()) return false;
+ if (!event.doit) return false;
+ switch (event.detail) {
+ case SWT.TRAVERSE_NONE: return true;
+ case SWT.TRAVERSE_ESCAPE: return traverseEscape ();
+ case SWT.TRAVERSE_RETURN: return traverseReturn ();
+ case SWT.TRAVERSE_TAB_NEXT: return traverseGroup (true);
+ case SWT.TRAVERSE_TAB_PREVIOUS: return traverseGroup (false);
+ case SWT.TRAVERSE_ARROW_NEXT: return traverseItem (true);
+ case SWT.TRAVERSE_ARROW_PREVIOUS: return traverseItem (false);
+ case SWT.TRAVERSE_MNEMONIC: return traverseMnemonic (event.character);
+ case SWT.TRAVERSE_PAGE_NEXT: return traversePage (true);
+ case SWT.TRAVERSE_PAGE_PREVIOUS: return traversePage (false);
+ }
+ return false;
+}
+
/**
* Based on the argument, perform one of the expected platform
* traversal action. The argument should be one of the constants:
@@ -2536,84 +2536,84 @@ boolean traverse (Event event) {
* <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;
- Event event = new Event ();
- event.doit = true;
- event.detail = traversal;
- return traverse (event);
-}
-
-boolean traverseEscape () {
- return false;
-}
-
-boolean traverseGroup (boolean next) {
- Control root = computeTabRoot ();
- Control group = computeTabGroup ();
- Control [] list = root.computeTabList ();
- int length = list.length;
- int index = 0;
- while (index < length) {
- if (list [index] == group) break;
- index++;
- }
- /*
- * It is possible (but unlikely), that application
- * code could have disposed the widget in focus in
- * or out events. Ensure that a disposed widget is
- * not accessed.
- */
- if (index == length) return false;
- int start = index, offset = (next) ? 1 : -1;
- while ((index = ((index + offset + length) % length)) != start) {
- Control control = list [index];
- if (!control.isDisposed () && control.setTabGroupFocus ()) {
- if (!isDisposed () && !isFocusControl ()) return true;
- }
- }
- if (group.isDisposed ()) return false;
- 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++;
- }
- /*
- * It is possible (but unlikely), that application
- * code could have disposed the widget in focus in
- * or out events. Ensure that a disposed widget is
- * not accessed.
- */
- int start = index, offset = (next) ? 1 : -1;
- while ((index = (index + offset + length) % length) != start) {
- Control child = children [index];
- if (!child.isDisposed () && child.isTabItem ()) {
- if (child.setTabItemFocus ()) return true;
- }
- }
- return false;
-}
-
-boolean traversePage (boolean next) {
- return false;
-}
-
-boolean traverseMnemonic (char key) {
-// return mnemonicHit (key);
- return false;
-}
-
-boolean traverseReturn () {
- return false;
-}
-
+public boolean traverse (int traversal) {
+ checkWidget ();
+ if (!isFocusControl () && !setFocus ()) return false;
+ Event event = new Event ();
+ event.doit = true;
+ event.detail = traversal;
+ return traverse (event);
+}
+
+boolean traverseEscape () {
+ return false;
+}
+
+boolean traverseGroup (boolean next) {
+ Control root = computeTabRoot ();
+ Control group = computeTabGroup ();
+ Control [] list = root.computeTabList ();
+ int length = list.length;
+ int index = 0;
+ while (index < length) {
+ if (list [index] == group) break;
+ index++;
+ }
+ /*
+ * It is possible (but unlikely), that application
+ * code could have disposed the widget in focus in
+ * or out events. Ensure that a disposed widget is
+ * not accessed.
+ */
+ if (index == length) return false;
+ int start = index, offset = (next) ? 1 : -1;
+ while ((index = ((index + offset + length) % length)) != start) {
+ Control control = list [index];
+ if (!control.isDisposed () && control.setTabGroupFocus ()) {
+ if (!isDisposed () && !isFocusControl ()) return true;
+ }
+ }
+ if (group.isDisposed ()) return false;
+ 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++;
+ }
+ /*
+ * It is possible (but unlikely), that application
+ * code could have disposed the widget in focus in
+ * or out events. Ensure that a disposed widget is
+ * not accessed.
+ */
+ int start = index, offset = (next) ? 1 : -1;
+ while ((index = (index + offset + length) % length) != start) {
+ Control child = children [index];
+ if (!child.isDisposed () && child.isTabItem ()) {
+ if (child.setTabItemFocus ()) return true;
+ }
+ }
+ return false;
+}
+
+boolean traversePage (boolean next) {
+ return false;
+}
+
+boolean traverseMnemonic (char key) {
+// return mnemonicHit (key);
+ return false;
+}
+
+boolean traverseReturn () {
+ return false;
+}
+
/**
* Forces all outstanding paint requests for the widget tree
* to be processed before this method returns.
@@ -2625,13 +2625,13 @@ boolean traverseReturn () {
*
* @see #redraw
*/
-public void update () {
- checkWidget();
- OS.PtFlush ();
-}
-
-int widgetClass () {
- return 0;
-}
-
-}
+public void update () {
+ checkWidget();
+ OS.PtFlush ();
+}
+
+int widgetClass () {
+ return 0;
+}
+
+}
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
index 2f20d0b075..ad0f29dac4 100755
--- 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
@@ -1,16 +1,16 @@
-package org.eclipse.swt.widgets;
-
-/*
+package org.eclipse.swt.widgets;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-import org.eclipse.swt.internal.photon.*;
-import org.eclipse.swt.*;
-import org.eclipse.swt.graphics.*;
-
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+import org.eclipse.swt.internal.photon.*;
+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
@@ -83,17 +83,17 @@ import org.eclipse.swt.graphics.*;
* @see Shell
* @see SWT
*/
-public class Decorations extends Canvas {
- Menu menuBar;
- Menu [] menus;
- String text = "";
- Image image;
- Button defaultButton, saveDefault;
-
-Decorations () {
- /* Do nothing */
-}
-
+public class Decorations extends Canvas {
+ Menu menuBar;
+ Menu [] menus;
+ String text = "";
+ Image image;
+ Button defaultButton, saveDefault;
+
+Decorations () {
+ /* Do nothing */
+}
+
/**
* Constructs a new instance of this class given its parent
* and a style value describing its behavior and appearance.
@@ -132,46 +132,46 @@ Decorations () {
* @see Widget#checkSubclass
* @see Widget#getStyle
*/
-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);
-}
-
-Control computeTabGroup () {
- return this;
-}
-
-Control computeTabRoot () {
- return this;
-}
-
+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);
+}
+
+Control computeTabGroup () {
+ return this;
+}
+
+Control computeTabRoot () {
+ return this;
+}
+
/**
* Returns the receiver's default button if one had
* previously been set, otherwise returns null.
@@ -185,11 +185,11 @@ Control computeTabRoot () {
*
* @see #setDefaultButton
*/
-public Button getDefaultButton () {
- checkWidget();
- return defaultButton;
-}
-
+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
@@ -211,11 +211,11 @@ public Button getDefaultButton () {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public Image getImage () {
- checkWidget();
- return image;
-}
-
+public Image getImage () {
+ checkWidget();
+ return image;
+}
+
/**
* Returns <code>true</code> if the receiver is currently
* maximized, and false otherwise.
@@ -230,11 +230,11 @@ public Image getImage () {
*
* @see #setMaximized
*/
-public boolean getMaximized () {
- checkWidget();
- return false;
-}
-
+public boolean getMaximized () {
+ checkWidget();
+ return false;
+}
+
/**
* Returns <code>true</code> if the receiver is currently
* minimized, and false otherwise.
@@ -249,11 +249,11 @@ public boolean getMaximized () {
*
* @see #setMinimized
*/
-public boolean getMinimized () {
- checkWidget();
- return false;
-}
-
+public boolean getMinimized () {
+ checkWidget();
+ return false;
+}
+
/**
* Returns the receiver's menu bar if one had previously
* been set, otherwise returns null.
@@ -265,15 +265,15 @@ public boolean getMinimized () {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public Menu getMenuBar () {
- checkWidget();
- return menuBar;
-}
-
-String getNameText () {
- return getText ();
-}
-
+public Menu getMenuBar () {
+ checkWidget();
+ return menuBar;
+}
+
+String getNameText () {
+ return getText ();
+}
+
/**
* Returns the receiver's text, which is the string that the
* window manager will typically display as the receiver's
@@ -287,76 +287,76 @@ String getNameText () {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public String getText () {
- checkWidget();
- return text;
-}
-
-boolean hasBorder () {
- return false;
-}
-
-boolean isTabGroup () {
- return true;
-}
-
-boolean isTabItem () {
- 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.releaseResources ();
- }
- }
- menuBar = null;
- menus = null;
- image = null;
- super.releaseWidget ();
- defaultButton = saveDefault = null;
- text = 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;
- }
- }
-}
-
-void resizeBounds (int width, int height) {
- int menuHeight = 0;
- if (menuBar != null) {
- PhDim_t dim = new PhDim_t ();
- int menuHandle = menuBar.handle;
- if (!OS.PtWidgetIsRealized (menuHandle)) {
- OS.PtExtentWidgetFamily (menuHandle);
- }
- OS.PtWidgetPreferredSize (menuHandle, dim);
- menuHeight = dim.h;
- OS.PtSetResource (menuHandle, OS.Pt_ARG_HEIGHT, menuHeight, 0);
- height = height - menuHeight;
- }
- PhArea_t area = new PhArea_t ();
- area.pos_y = (short) menuHeight;
- 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);
- OS.PtSetResource (scrolledHandle, OS.Pt_ARG_AREA, ptr, 0);
- OS.free (ptr);
- resizeClientArea (width, height);
-}
-
+public String getText () {
+ checkWidget();
+ return text;
+}
+
+boolean hasBorder () {
+ return false;
+}
+
+boolean isTabGroup () {
+ return true;
+}
+
+boolean isTabItem () {
+ 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.releaseResources ();
+ }
+ }
+ menuBar = null;
+ menus = null;
+ image = null;
+ super.releaseWidget ();
+ defaultButton = saveDefault = null;
+ text = 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;
+ }
+ }
+}
+
+void resizeBounds (int width, int height) {
+ int menuHeight = 0;
+ if (menuBar != null) {
+ PhDim_t dim = new PhDim_t ();
+ int menuHandle = menuBar.handle;
+ if (!OS.PtWidgetIsRealized (menuHandle)) {
+ OS.PtExtentWidgetFamily (menuHandle);
+ }
+ OS.PtWidgetPreferredSize (menuHandle, dim);
+ menuHeight = dim.h;
+ OS.PtSetResource (menuHandle, OS.Pt_ARG_HEIGHT, menuHeight, 0);
+ height = height - menuHeight;
+ }
+ PhArea_t area = new PhArea_t ();
+ area.pos_y = (short) menuHeight;
+ 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);
+ OS.PtSetResource (scrolledHandle, OS.Pt_ARG_AREA, ptr, 0);
+ OS.free (ptr);
+ resizeClientArea (width, height);
+}
+
/**
* If the argument is not null, sets the receiver's default
* button to the argument, and if the argument is null, sets
@@ -377,32 +377,32 @@ void resizeBounds (int width, int height) {
* <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) {
- if (save) saveDefault = null;
- return;
- }
- } else {
- if (button.isDisposed()) error(SWT.ERROR_INVALID_ARGUMENT);
- 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 = defaultButton;
- if (saveDefault != null && saveDefault.isDisposed ()) saveDefault = null;
-}
-
+public void setDefaultButton (Button button) {
+ checkWidget();
+ setDefaultButton (button, true);
+}
+void setDefaultButton (Button button, boolean save) {
+ if (button == null) {
+ if (defaultButton == saveDefault) {
+ if (save) saveDefault = null;
+ return;
+ }
+ } else {
+ if (button.isDisposed()) error(SWT.ERROR_INVALID_ARGUMENT);
+ 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 = defaultButton;
+ if (saveDefault != null && saveDefault.isDisposed ()) saveDefault = null;
+}
+
/**
* Sets the receiver's image to the argument, which may
* be null. The image is typically displayed by the window
@@ -420,12 +420,12 @@ void setDefaultButton (Button button, boolean save) {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public void setImage (Image image) {
- checkWidget();
- if (image != null && image.isDisposed()) error(SWT.ERROR_INVALID_ARGUMENT);
- this.image = image;
-}
-
+public void setImage (Image image) {
+ checkWidget();
+ if (image != null && image.isDisposed()) error(SWT.ERROR_INVALID_ARGUMENT);
+ this.image = image;
+}
+
/**
* Sets the maximized state of the receiver.
* If the argument is <code>true</code> causes the receiver
@@ -449,10 +449,10 @@ public void setImage (Image image) {
*
* @see #setMinimized
*/
-public void setMaximized (boolean maximized) {
- checkWidget();
-}
-
+public void setMaximized (boolean maximized) {
+ checkWidget();
+}
+
/**
* Sets the receiver's menu bar to the argument, which
* may be null.
@@ -468,12 +468,12 @@ public void setMaximized (boolean maximized) {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public void setMenuBar (Menu menu) {
- checkWidget();
- if (menu != null && menu.isDisposed()) error(SWT.ERROR_INVALID_ARGUMENT);
- //NOT DONE
-}
-
+public void setMenuBar (Menu menu) {
+ checkWidget();
+ if (menu != null && menu.isDisposed()) error(SWT.ERROR_INVALID_ARGUMENT);
+ //NOT DONE
+}
+
/**
* Sets the minimized stated of the receiver.
* If the argument is <code>true</code> causes the receiver
@@ -497,10 +497,10 @@ public void setMenuBar (Menu menu) {
*
* @see #setMaximized
*/
-public void setMinimized (boolean minimized) {
- checkWidget();
-}
-
+public void setMinimized (boolean minimized) {
+ checkWidget();
+}
+
/**
* Sets the receiver's text, which is the string that the
* window manager will typically display as the receiver's
@@ -516,17 +516,17 @@ public void setMinimized (boolean minimized) {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public void setText (String string) {
- checkWidget();
- if (string == null) error (SWT.ERROR_NULL_ARGUMENT);
- text = string;
-}
-
-boolean traverseReturn () {
- if (defaultButton == null || defaultButton.isDisposed ()) return false;
- if (!defaultButton.isVisible () || !defaultButton.isEnabled ()) return false;
- defaultButton.click ();
- return true;
-}
-
-}
+public void setText (String string) {
+ checkWidget();
+ if (string == null) error (SWT.ERROR_NULL_ARGUMENT);
+ text = string;
+}
+
+boolean traverseReturn () {
+ if (defaultButton == null || defaultButton.isDisposed ()) return false;
+ if (!defaultButton.isVisible () || !defaultButton.isEnabled ()) return false;
+ defaultButton.click ();
+ return true;
+}
+
+}
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
index 5f085a4e02..0b38ff26e8 100755
--- 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
@@ -1,16 +1,16 @@
-package org.eclipse.swt.widgets;
-
-/*
+package org.eclipse.swt.widgets;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-import org.eclipse.swt.internal.*;
-import org.eclipse.swt.internal.photon.*;
-import org.eclipse.swt.*;
-
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+import org.eclipse.swt.internal.*;
+import org.eclipse.swt.internal.photon.*;
+import org.eclipse.swt.*;
+
/**
* Instances of this class allow the user to navigate
* the file system and select a directory.
@@ -19,9 +19,9 @@ import org.eclipse.swt.*;
* within the SWT implementation.
* </p>
*/
-public class DirectoryDialog extends Dialog {
- String message = "", filterPath = "";
-
+public class DirectoryDialog extends Dialog {
+ String message = "", filterPath = "";
+
/**
* Constructs a new instance of this class given only its
* parent.
@@ -44,10 +44,10 @@ public class DirectoryDialog extends Dialog {
* <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
* </ul>
*/
-public DirectoryDialog (Shell parent) {
- this (parent, SWT.PRIMARY_MODAL);
-}
-
+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.
@@ -78,21 +78,21 @@ public DirectoryDialog (Shell parent) {
* <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
* </ul>
*/
-public DirectoryDialog (Shell parent, int style) {
- super (parent, style);
- checkSubclass ();
-}
-
+public DirectoryDialog (Shell parent, int style) {
+ super (parent, style);
+ checkSubclass ();
+}
+
/**
* Returns the path which the dialog will use to filter
* the directories it shows.
*
* @return the filter path
*/
-public String getFilterPath () {
- return filterPath;
-}
-
+public String getFilterPath () {
+ return filterPath;
+}
+
/**
* Returns the dialog's message, which is a description of
* the purpose for which it was opened. This message will be
@@ -100,10 +100,10 @@ public String getFilterPath () {
*
* @return the message
*/
-public String getMessage () {
- return message;
-}
-
+public String getMessage () {
+ return message;
+}
+
/**
* Makes the dialog visible and brings it to the front
* of the display.
@@ -116,29 +116,29 @@ public String getMessage () {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the dialog</li>
* </ul>
*/
-public String open () {
- int parentHandle = 0;
- if (parent != null && OS.PtWidgetIsRealized(parent.shellHandle)) {
- 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 String open () {
+ int parentHandle = 0;
+ if (parent != null && OS.PtWidgetIsRealized(parent.shellHandle)) {
+ 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));
+}
+
/**
* Sets the path which the dialog will use to filter
* the directories it shows to the argument, which may be
@@ -146,10 +146,10 @@ public String open () {
*
* @param string the filter path
*/
-public void setFilterPath (String string) {
- filterPath = string;
-}
-
+public void setFilterPath (String string) {
+ filterPath = string;
+}
+
/**
* Sets the dialog's message, which is a description of
* the purpose for which it was opened. This message will be
@@ -157,8 +157,8 @@ public void setFilterPath (String string) {
*
* @param string the message
*/
-public void setMessage (String string) {
- message = string;
-}
-
+public void setMessage (String string) {
+ message = string;
+}
+
}
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
index 84f07e30f6..9dfa89d378 100755
--- 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
@@ -1,17 +1,17 @@
-package org.eclipse.swt.widgets;
-
-/*
+package org.eclipse.swt.widgets;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-import org.eclipse.swt.internal.*;
-import org.eclipse.swt.internal.photon.*;
-import org.eclipse.swt.*;
-import org.eclipse.swt.graphics.*;
-
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+import org.eclipse.swt.internal.*;
+import org.eclipse.swt.internal.photon.*;
+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
@@ -87,200 +87,200 @@ import org.eclipse.swt.graphics.*;
* @see #sleep
* @see #dispose
*/
-public class Display extends Device {
-
+public class Display extends Device {
+
/* TEMPORARY CODE FOR EMULATED TABLE */
- 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;
- EventTable eventTable, filterTable;
-
- /* Events Dispatching and Callback */
- Callback windowCallback, drawCallback, workCallback, inputCallback, hotkeyCallback;
- int windowProc, drawProc, workProc, inputProc, hotkeyProc, input, pulse;
- boolean idle;
-
- /* Sync/Async Widget Communication */
- Synchronizer synchronizer = new Synchronizer (this);
- Thread thread;
-
- /* Display Shutdown */
- Runnable [] disposeList;
-
- /* Timers */
- int [] timerIds;
- 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 Keys */
- {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},
-
- /* Virtual and Ascii Keys */
- {OS.Pk_BackSpace, SWT.BS},
- {OS.Pk_Return, SWT.CR},
- {OS.Pk_Delete, SWT.DEL},
- {OS.Pk_Escape, SWT.ESC},
- {OS.Pk_Cancel, SWT.ESC},
- {OS.Pk_Linefeed, SWT.LF},
- {OS.Pk_Tab, SWT.TAB},
- {OS.Pk_KP_Tab, SWT.TAB},
-
- /* 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 Keys */
- /*
- {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 */
- int ClassesPtr;
- int PtButton;
- int PtList;
- int PtLabel;
- int PtWindow;
- int PtToggleButton;
- int PtComboBox;
- int PtText;
- int PtMultiText;
- int PtScrollbar;
- int PtScrollContainer;
- int PtScrollArea;
- int PtContainer;
- int PtProgress;
- int PtPanelGroup;
- int PtPane;
- int PtSlider;
- int PtSeparator;
- int PtToolbar;
-
- /* 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;
- int INFO_FOREGROUND, INFO_BACKGROUND, TEXT_FOREGROUND, TEXT_BACKGROUND;
-
- /* Fonts */
- byte [] defaultFont;
- byte [] TEXT_FONT, LIST_FONT, TITLE_FONT, GAUGE_FONT, GROUP_FONT;
-
- /* Images */
- int nullImage;
-
- /* ScrollBars */
- int SCROLLBAR_WIDTH;
- int SCROLLBAR_HEIGHT;
- int SCROLLBAR_VERTICAL_BASIC_FLAGS;
- int SCROLLBAR_HORIZONTAL_BASIC_FLAGS;
-
- /* 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;
-
- /*
- * TEMPORARY CODE. Install the runnable that
- * gets the current display. This code will
- * be removed in the future.
- */
- static {
- DeviceFinder = new Runnable () {
- public void run () {
- Device device = getCurrent ();
- if (device == null) {
- device = getDefault ();
- }
- setDevice (device);
- }
- };
- }
-
-/*
-* TEMPORARY CODE.
-*/
-static void setDevice (Device device) {
- CurrentDevice = device;
-}
-
+ 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;
+ EventTable eventTable, filterTable;
+
+ /* Events Dispatching and Callback */
+ Callback windowCallback, drawCallback, workCallback, inputCallback, hotkeyCallback;
+ int windowProc, drawProc, workProc, inputProc, hotkeyProc, input, pulse;
+ boolean idle;
+
+ /* Sync/Async Widget Communication */
+ Synchronizer synchronizer = new Synchronizer (this);
+ Thread thread;
+
+ /* Display Shutdown */
+ Runnable [] disposeList;
+
+ /* Timers */
+ int [] timerIds;
+ 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 Keys */
+ {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},
+
+ /* Virtual and Ascii Keys */
+ {OS.Pk_BackSpace, SWT.BS},
+ {OS.Pk_Return, SWT.CR},
+ {OS.Pk_Delete, SWT.DEL},
+ {OS.Pk_Escape, SWT.ESC},
+ {OS.Pk_Cancel, SWT.ESC},
+ {OS.Pk_Linefeed, SWT.LF},
+ {OS.Pk_Tab, SWT.TAB},
+ {OS.Pk_KP_Tab, SWT.TAB},
+
+ /* 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 Keys */
+ /*
+ {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 */
+ int ClassesPtr;
+ int PtButton;
+ int PtList;
+ int PtLabel;
+ int PtWindow;
+ int PtToggleButton;
+ int PtComboBox;
+ int PtText;
+ int PtMultiText;
+ int PtScrollbar;
+ int PtScrollContainer;
+ int PtScrollArea;
+ int PtContainer;
+ int PtProgress;
+ int PtPanelGroup;
+ int PtPane;
+ int PtSlider;
+ int PtSeparator;
+ int PtToolbar;
+
+ /* 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;
+ int INFO_FOREGROUND, INFO_BACKGROUND, TEXT_FOREGROUND, TEXT_BACKGROUND;
+
+ /* Fonts */
+ byte [] defaultFont;
+ byte [] TEXT_FONT, LIST_FONT, TITLE_FONT, GAUGE_FONT, GROUP_FONT;
+
+ /* Images */
+ int nullImage;
+
+ /* ScrollBars */
+ int SCROLLBAR_WIDTH;
+ int SCROLLBAR_HEIGHT;
+ int SCROLLBAR_VERTICAL_BASIC_FLAGS;
+ int SCROLLBAR_HORIZONTAL_BASIC_FLAGS;
+
+ /* 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;
+
+ /*
+ * TEMPORARY CODE. Install the runnable that
+ * gets the current display. This code will
+ * be removed in the future.
+ */
+ static {
+ DeviceFinder = new Runnable () {
+ public void run () {
+ Device device = getCurrent ();
+ if (device == null) {
+ device = getDefault ();
+ }
+ setDevice (device);
+ }
+ };
+ }
+
+/*
+* TEMPORARY CODE.
+*/
+static void setDevice (Device device) {
+ CurrentDevice = device;
+}
+
/**
* Constructs a new instance of this class.
* <p>
@@ -300,71 +300,71 @@ static void setDevice (Device device) {
* @see Widget#checkSubclass
* @see Shell
*/
-public Display () {
- this (null);
-}
-
-public Display (DeviceData data) {
- super (data);
-}
-
-/**
- * Adds the listener to the collection of listeners who will
- * be notifed when an event of the given type occurs anywhere
- * in SWT. When the event does occur, the listener is notified
- * by sending it the <code>handleEvent()</code> message.
- *
- * @param eventType the type of event to listen for
- * @param listener the listener which should be notified when the event occurs
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see Listener
- * @see #removeFilter
- * @see #removeListener
- *
- * @since 2.1
- */
-void addFilter (int eventType, Listener listener) {
- checkDevice ();
- if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
- if (filterTable == null) filterTable = new EventTable ();
- filterTable.hook (eventType, listener);
-}
-
-/**
- * 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 display, the listener is notified by
- * sending it the <code>handleEvent()</code> message.
- *
- * @param eventType the type of event to listen for
- * @param listener the listener which should be notified when the event occurs
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see Listener
- * @see #removeListener
- *
- * @since 2.0
+public Display () {
+ this (null);
+}
+
+public Display (DeviceData data) {
+ super (data);
+}
+
+/**
+ * Adds the listener to the collection of listeners who will
+ * be notifed when an event of the given type occurs anywhere
+ * in SWT. When the event does occur, the listener is notified
+ * by sending it the <code>handleEvent()</code> message.
+ *
+ * @param eventType the type of event to listen for
+ * @param listener the listener which should be notified when the event occurs
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see Listener
+ * @see #removeFilter
+ * @see #removeListener
+ *
+ * @since 2.1
+ */
+void addFilter (int eventType, Listener listener) {
+ checkDevice ();
+ if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+ if (filterTable == null) filterTable = new EventTable ();
+ filterTable.hook (eventType, listener);
+}
+
+/**
+ * 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 display, the listener is notified by
+ * sending it the <code>handleEvent()</code> message.
+ *
+ * @param eventType the type of event to listen for
+ * @param listener the listener which should be notified when the event occurs
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see Listener
+ * @see #removeListener
+ *
+ * @since 2.0
*/
-public void addListener (int eventType, Listener listener) {
- checkDevice ();
- if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
- if (eventTable == null) eventTable = new EventTable ();
- eventTable.hook (eventType, listener);
-}
-
+public void addListener (int eventType, Listener listener) {
+ checkDevice ();
+ if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+ if (eventTable == null) eventTable = new EventTable ();
+ eventTable.hook (eventType, listener);
+}
+
/**
* Causes the <code>run()</code> method of the runnable to
* be invoked by the user-interface thread at the next
@@ -376,112 +376,112 @@ public void addListener (int eventType, Listener listener) {
*
* @see #syncExec
*/
-public void asyncExec (Runnable runnable) {
- if (isDisposed ()) error (SWT.ERROR_DEVICE_DISPOSED);
- synchronizer.asyncExec (runnable);
-}
-
+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.PtBeep ();
-}
-
-protected void checkDevice () {
- if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
- if (isDisposed ()) error (SWT.ERROR_DEVICE_DISPOSED);
-}
-
-static synchronized void checkDisplay (Thread thread) {
- for (int i=0; i<Displays.length; i++) {
- if (Displays [i] != null && Displays [i].thread == thread) {
- SWT.error (SWT.ERROR_THREAD_INVALID_ACCESS);
- }
- }
-}
-
-protected void checkSubclass () {
- if (!isValidClass (getClass ())) error (SWT.ERROR_INVALID_SUBCLASS);
-}
-
-/**
- * Requests that the connection between SWT and the underlying
- * operating system be closed.
- *
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see #dispose
- *
- * @since 2.0
+public void beep () {
+ checkDevice ();
+ OS.PtBeep ();
+}
+
+protected void checkDevice () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (isDisposed ()) error (SWT.ERROR_DEVICE_DISPOSED);
+}
+
+static synchronized void checkDisplay (Thread thread) {
+ for (int i=0; i<Displays.length; i++) {
+ if (Displays [i] != null && Displays [i].thread == thread) {
+ SWT.error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ }
+ }
+}
+
+protected void checkSubclass () {
+ if (!isValidClass (getClass ())) error (SWT.ERROR_INVALID_SUBCLASS);
+}
+
+/**
+ * Requests that the connection between SWT and the underlying
+ * operating system be closed.
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see #dispose
+ *
+ * @since 2.0
*/
-public void close () {
- checkDevice ();
- Event event = new Event ();
- sendEvent (SWT.Close, event);
- if (event.doit) dispose ();
-}
-
-String convertToLf (String text) {
- int length = text.length ();
- if (length == 0) return text;
-
- /* Check for an LF or CR/LF. Assume the rest of the string
- * is formated that way. This will not work if the string
- * contains mixed delimiters. */
- int i = text.indexOf ('\n', 0);
- if (i == -1 || i == 0) return text;
- if (text.charAt (i - 1) != '\r') return text;
-
- /* The string is formatted with CR/LF.
- * Create a new string with the LF line delimiter. */
- i = 0;
- StringBuffer result = new StringBuffer ();
- while (i < length) {
- int j = text.indexOf ('\r', i);
- if (j == -1) j = length;
- String s = text.substring (i, j);
- result.append (s);
- i = j + 2;
- result.append ('\n');
- }
- return result.toString ();
-}
-
-protected void create (DeviceData data) {
- checkSubclass ();
- checkDisplay (thread = Thread.currentThread ());
- 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 close () {
+ checkDevice ();
+ Event event = new Event ();
+ sendEvent (SWT.Close, event);
+ if (event.doit) dispose ();
+}
+
+String convertToLf (String text) {
+ int length = text.length ();
+ if (length == 0) return text;
+
+ /* Check for an LF or CR/LF. Assume the rest of the string
+ * is formated that way. This will not work if the string
+ * contains mixed delimiters. */
+ int i = text.indexOf ('\n', 0);
+ if (i == -1 || i == 0) return text;
+ if (text.charAt (i - 1) != '\r') return text;
+
+ /* The string is formatted with CR/LF.
+ * Create a new string with the LF line delimiter. */
+ i = 0;
+ StringBuffer result = new StringBuffer ();
+ while (i < length) {
+ int j = text.indexOf ('\r', i);
+ if (j == -1) j = length;
+ String s = text.substring (i, j);
+ result.append (s);
+ i = j + 2;
+ result.append ('\n');
+ }
+ return result.toString ();
+}
+
+protected void create (DeviceData data) {
+ checkSubclass ();
+ checkDisplay (thread = Thread.currentThread ());
+ 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 ???
+}
+
/**
* Causes the <code>run()</code> method of the runnable to
* be invoked by the user-interface thread just before the
@@ -489,40 +489,40 @@ void destroyDisplay () {
*
* @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;
-}
-
-int drawProc (int handle, int damage) {
- /*
- * Feature in Photon. On QNX 6.2, if a widget is damaged, PtBlit() will
- * call its draw function before blitting pixels. This is not wrong
- * but it is unwanted, since the callback might happen in a thread other
- * than the display thread. The fix is to detect that the callback happened
- * in the wrong thread and return right away.
- */
- //TEMPORARY CODE
- if (thread != Thread.currentThread()) return 0;
- Widget widget = WidgetTable.get (handle);
- if (widget == null) return 0;
- return widget.drawProc (handle, damage);
-}
-
-void error (int code) {
- SWT.error(code);
-}
-
+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) {
+ /*
+ * Feature in Photon. On QNX 6.2, if a widget is damaged, PtBlit() will
+ * call its draw function before blitting pixels. This is not wrong
+ * but it is unwanted, since the callback might happen in a thread other
+ * than the display thread. The fix is to detect that the callback happened
+ * in the wrong thread and return right away.
+ */
+ //TEMPORARY CODE
+ if (thread != Thread.currentThread()) return 0;
+ Widget widget = WidgetTable.get (handle);
+ if (widget == null) return 0;
+ return widget.drawProc (handle, damage);
+}
+
+void error (int code) {
+ SWT.error(code);
+}
+
/**
* Returns the display which the given thread is the
* user-interface thread for, or null if the given thread
@@ -531,26 +531,26 @@ void error (int code) {
* @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;
-}
-
-boolean filterEvent (Event event) {
- if (filterTable != null) filterTable.sendEvent (event);
- return false;
-}
-
-boolean filters (int eventType) {
- if (filterTable == null) return false;
- return filterTable.hooks (eventType);
-}
-
+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;
+}
+
+boolean filterEvent (Event event) {
+ if (filterTable != null) filterTable.sendEvent (event);
+ return false;
+}
+
+boolean filters (int eventType) {
+ if (filterTable == null) return false;
+ return filterTable.hooks (eventType);
+}
+
/**
* Given the operating system handle for a widget, returns
* the instance of the <code>Widget</code> subclass which
@@ -564,11 +564,11 @@ boolean filters (int eventType) {
* <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);
-}
-
+public Widget findWidget (int handle) {
+ checkDevice ();
+ return WidgetTable.get (handle);
+}
+
/**
* Returns the currently active <code>Shell</code>, or null
* if no shell belonging to the currently running application
@@ -580,19 +580,19 @@ public Widget findWidget (int handle) {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-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 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;
+}
+
/**
* Returns the control which the on-screen pointer is currently
* over top of, or null if it is not currently over one of the
@@ -604,41 +604,41 @@ public Shell getActiveShell () {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-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 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;
+}
+
/**
* Returns the location of the on-screen pointer relative
* to the top left corner of the screen.
@@ -649,14 +649,14 @@ public Control getCursorControl () {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-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 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);
+}
+
/**
* Returns the display which the currently running thread is
* the user-interface thread for, or null if the currently
@@ -664,15 +664,15 @@ public Point getCursorLocation () {
*
* @return the current display
*/
-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 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;
+}
+
/**
* Returns the default display. One is created (making the
* thread that invokes this method its user-interface thread)
@@ -680,11 +680,11 @@ public static synchronized Display getCurrent () {
*
* @return the default display
*/
-public static synchronized Display getDefault () {
- if (Default == null) Default = new Display ();
- return Default;
-}
-
+public static synchronized Display getDefault () {
+ if (Default == null) Default = new Display ();
+ return Default;
+}
+
/**
* On platforms which support it, sets the application name
* to be the argument. On Motif, for example, this can be used
@@ -692,15 +692,15 @@ public static synchronized Display getDefault () {
*
* @param name the new app name
*/
-public static void setAppName (String name) {
- /* Do nothing */
-}
-
-public int getDismissalAlignment () {
- checkDevice ();
- return SWT.RIGHT;
-}
-
+public static void setAppName (String name) {
+ /* Do nothing */
+}
+
+public int getDismissalAlignment () {
+ checkDevice ();
+ return SWT.RIGHT;
+}
+
/**
* Returns the longest duration, in milliseconds, between
* two mouse button clicks that will be considered a
@@ -712,12 +712,12 @@ public int getDismissalAlignment () {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public int getDoubleClickTime () {
- checkDevice ();
- //NOT DONE
- return 250;
-}
-
+public int getDoubleClickTime () {
+ checkDevice ();
+ //NOT DONE
+ return 250;
+}
+
/**
* Returns the control which currently has keyboard focus,
* or null if keyboard events are not currently going to
@@ -730,27 +730,27 @@ public int getDoubleClickTime () {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-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;
-}
-
-int getLastEventTime () {
- return (int) System.currentTimeMillis ();
-}
-
+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;
+}
+
+int getLastEventTime () {
+ return (int) System.currentTimeMillis ();
+}
+
/**
* Returns the maximum allowed depth of icons on this display.
* On some platforms, this may be different than the actual
@@ -762,10 +762,10 @@ int getLastEventTime () {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public int getIconDepth () {
- return getDepth ();
-}
-
+public int getIconDepth () {
+ return getDepth ();
+}
+
/**
* Returns an array containing all shells which have not been
* disposed and have the receiver as their display.
@@ -776,34 +776,34 @@ public int getIconDepth () {
* <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;
-}
-
+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 matching standard color for the given
* constant, which should be one of the color constants
@@ -822,35 +822,35 @@ public Shell [] getShells () {
*
* @see SWT
*/
-public Color getSystemColor (int id) {
- checkDevice ();
- int color = 0x000000;
- switch (id) {
- case SWT.COLOR_INFO_FOREGROUND: color = INFO_FOREGROUND; break;
- case SWT.COLOR_INFO_BACKGROUND: color = INFO_BACKGROUND; break;
- case SWT.COLOR_TITLE_FOREGROUND: color = 0xFFFFFF; break;
- case SWT.COLOR_TITLE_BACKGROUND: color = 0x5281D5; break;
- case SWT.COLOR_TITLE_BACKGROUND_GRADIENT: color = 0x74A3FF; 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 = 0xCDDDFF; 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 Color getSystemColor (int id) {
+ checkDevice ();
+ int color = 0x000000;
+ switch (id) {
+ case SWT.COLOR_INFO_FOREGROUND: color = INFO_FOREGROUND; break;
+ case SWT.COLOR_INFO_BACKGROUND: color = INFO_BACKGROUND; break;
+ case SWT.COLOR_TITLE_FOREGROUND: color = 0xFFFFFF; break;
+ case SWT.COLOR_TITLE_BACKGROUND: color = 0x5281D5; break;
+ case SWT.COLOR_TITLE_BACKGROUND_GRADIENT: color = 0x74A3FF; 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 = 0xCDDDFF; 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);
+}
+
/**
* Returns a reasonable font for applications to use.
* On some platforms, this will match the "default font"
@@ -871,12 +871,12 @@ public Color getSystemColor (int id) {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public Font getSystemFont () {
- checkDevice ();
- byte [] font = defaultFont != null ? defaultFont : TEXT_FONT;
- return Font.photon_new (this, font);
-}
-
+public Font getSystemFont () {
+ checkDevice ();
+ byte [] font = defaultFont != null ? defaultFont : TEXT_FONT;
+ return Font.photon_new (this, font);
+}
+
/**
* Returns the thread that has invoked <code>syncExec</code>
* or null if no such runnable is currently being invoked by
@@ -888,263 +888,263 @@ public Font getSystemFont () {
*
* @return the receiver's sync-interface thread
*/
-public Thread getSyncThread () {
- if (isDisposed ()) error (SWT.ERROR_DEVICE_DISPOSED);
- return synchronizer.syncThread;
-}
-
+public Thread getSyncThread () {
+ if (isDisposed ()) error (SWT.ERROR_DEVICE_DISPOSED);
+ return synchronizer.syncThread;
+}
+
/**
* 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;
-}
-
-int hotkeyProc (int handle, int data, int info) {
- Widget widget = WidgetTable.get (handle);
- if (widget == null) return OS.Pt_CONTINUE;
- return widget.hotkeyProc (handle, data, info);
-}
-
-protected void init () {
- super.init ();
- initializeDisplay ();
- initializeWidgetClasses ();
- initializeWidgetColors ();
- initializeWidgetFonts ();
- initializeScrollbars ();
- initializeImages ();
-}
-
-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);
- hotkeyCallback = new Callback (this, "hotkeyProc", 3);
- hotkeyProc = hotkeyCallback.getAddress ();
- if (hotkeyProc == 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 initializeScrollbars () {
- OS.PtSetParentWidget (0);
- int shellHandle = OS.PtCreateWidget (OS.PtWindow (), 0, 0, null);
- int textHandle = OS.PtCreateWidget (OS.PtMultiText (), shellHandle, 0, null);
- int child = OS.PtWidgetChildFront (textHandle);
- while (child != 0) {
- if (OS.PtWidgetClass (child) == OS.PtScrollbar ()) {
- int [] args = new int [] {
- OS.Pt_ARG_ORIENTATION, 0, 0,
- OS.Pt_ARG_WIDTH, 0, 0,
- OS.Pt_ARG_HEIGHT, 0, 0,
- OS.Pt_ARG_BASIC_FLAGS, 0, 0,
- };
- OS.PtGetResources (child, args.length / 3, args);
- switch (args [1]) {
- case OS.Pt_HORIZONTAL:
- SCROLLBAR_HEIGHT = args [7];
- SCROLLBAR_HORIZONTAL_BASIC_FLAGS = args [10];
- break;
- case OS.Pt_VERTICAL:
- SCROLLBAR_WIDTH = args [4];
- SCROLLBAR_VERTICAL_BASIC_FLAGS = args [10];
- break;
- }
- }
- child = OS.PtWidgetBrotherBehind (child);
- }
- OS.PtDestroyWidget (shellHandle);
-}
-
-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.PtSlider (), 0, args.length / 3, args), 0, 0,
- OS.PtCreateWidgetClass (OS.PtSeparator (), 0, args.length / 3, args), 0, 0,
- OS.PtCreateWidgetClass (OS.PtToolbar (), 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;
- PtSlider = ClassesPtr + 180;
- PtSeparator = ClassesPtr + 192;
- PtToolbar = ClassesPtr + 204;
-}
-
-void initializeWidgetColors () {
- OS.PtSetParentWidget (0);
- int [] args = {
- OS.Pt_ARG_WINDOW_STATE, OS.Ph_WM_STATE_ISHIDDEN, ~0,
- };
- int shellHandle = OS.PtCreateWidget (OS.PtWindow (), 0, args.length / 3, args);
- args = new int [] {
- 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 listHandle = 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.PtGetResources (listHandle, args.length / 3, args);
- LIST_FOREGROUND = args [1];
- LIST_BACKGROUND = args [4];
- LIST_SELECTION = args [7];
- LIST_SELECTION_TEXT = args [10];
-
- int textHandle = OS.PtCreateWidget (OS.PtText (), shellHandle, 0, null);
- args = new int [] {
- OS.Pt_ARG_COLOR, 0, 0,
- OS.Pt_ARG_FILL_COLOR, 0, 0,
- };
- OS.PtGetResources (textHandle, args.length / 3, args);
- TEXT_FOREGROUND = args [1];
- TEXT_BACKGROUND = args [4];
-
- /*
- * Feature in Photon. The values of Pt_ARG_DARK_BEVEL_COLOR and
- * Pt_ARG_LIGHT_BEVEL_COLOR are not initialized until the widget
- * is realized. The fix is to realize the shell without displaying
- * it.
- */
- int buttonHandle = OS.PtCreateWidget (OS.PtButton (), shellHandle, 0, null);
- OS.PtRealizeWidget(shellHandle);
- args = new int [] {
- OS.Pt_ARG_OUTLINE_COLOR, 0, 0,
- OS.Pt_ARG_OUTLINE_COLOR, 0, 0,
- OS.Pt_ARG_DARK_BEVEL_COLOR, 0, 0,
- OS.Pt_ARG_BEVEL_COLOR, 0, 0,
- OS.Pt_ARG_LIGHT_BEVEL_COLOR, 0, 0,
- OS.Pt_ARG_BALLOON_COLOR, 0, 0,
- OS.Pt_ARG_BALLOON_FILL_COLOR, 0, 0,
- };
- OS.PtGetResources (buttonHandle, args.length / 3, args);
- WIDGET_BORDER = args [1];
- WIDGET_DARK_SHADOW = args [4];
- WIDGET_NORMAL_SHADOW = args [7];
- WIDGET_LIGHT_SHADOW = args [10];
- WIDGET_HIGHLIGHT_SHADOW = args [13];
- INFO_FOREGROUND = args [16];
- INFO_BACKGROUND = args [19];
-
- OS.PtDestroyWidget (shellHandle);
-}
-
-void initializeWidgetFonts () {
- String property = System.getProperty ("swt.system.font");
- if (property != null) {
- defaultFont = Converter.wcsToMbcs (null, property, true);
- TEXT_FONT = LIST_FONT = GAUGE_FONT = TITLE_FONT = defaultFont;
- GROUP_FONT = Converter.wcsToMbcs (null, property + "b", true);
- return;
- }
- OS.PtSetParentWidget (0);
-
- int shellHandle = OS.PtCreateWidget (OS.PtWindow (), 0, 0, null);
- int [] args = new int [] {OS.Pt_ARG_TITLE_FONT, 0, 0};
- OS.PtGetResources (shellHandle, args.length / 3, args);
- int length = OS.strlen (args [1]);
- GROUP_FONT = TITLE_FONT = new byte [length + 1];
- OS.memmove (TITLE_FONT, args [1], length);
-
- int listHandle = OS.PtCreateWidget (OS.PtList (), shellHandle, 0, null);
- args = new int [] {OS.Pt_ARG_LIST_FONT, 0, 0};
- OS.PtGetResources (listHandle, args.length / 3, args);
- length = OS.strlen (args [1]);
- LIST_FONT = new byte [length + 1];
- OS.memmove (LIST_FONT, args [1], length);
-
- 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);
- length = OS.strlen (args [1]);
- TEXT_FONT = new byte [length + 1];
- OS.memmove (TEXT_FONT, args [1], length);
-
- int scrollHandle = OS.PtCreateWidget (OS.PtScrollbar (), shellHandle, 0, null);
- args = new int [] {OS.Pt_ARG_GAUGE_FONT, 0, 0};
- OS.PtGetResources (scrollHandle, args.length / 3, args);
- length = OS.strlen (args [1]);
- GAUGE_FONT = new byte [length + 1];
- OS.memmove (GAUGE_FONT, args [1], length);
-
- OS.PtDestroyWidget (shellHandle);
-}
-
-void initializeImages () {
- nullImage = OS.PhCreateImage (null, (short) 1, (short) 1, OS.Pg_IMAGE_DIRECT_888, 0, 0, 0);
- if (nullImage == 0) SWT.error (SWT.ERROR_NO_HANDLES);
-}
-
-int inputProc (int data, int rcvid, int message, int size) {
- if (embedded) {
- runDeferredEvents ();
- runAsyncMessages ();
- }
- return OS.Pt_CONTINUE;
-}
-
+public Thread getThread () {
+ if (isDisposed ()) error (SWT.ERROR_DEVICE_DISPOSED);
+ return thread;
+}
+
+int hotkeyProc (int handle, int data, int info) {
+ Widget widget = WidgetTable.get (handle);
+ if (widget == null) return OS.Pt_CONTINUE;
+ return widget.hotkeyProc (handle, data, info);
+}
+
+protected void init () {
+ super.init ();
+ initializeDisplay ();
+ initializeWidgetClasses ();
+ initializeWidgetColors ();
+ initializeWidgetFonts ();
+ initializeScrollbars ();
+ initializeImages ();
+}
+
+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);
+ hotkeyCallback = new Callback (this, "hotkeyProc", 3);
+ hotkeyProc = hotkeyCallback.getAddress ();
+ if (hotkeyProc == 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 initializeScrollbars () {
+ OS.PtSetParentWidget (0);
+ int shellHandle = OS.PtCreateWidget (OS.PtWindow (), 0, 0, null);
+ int textHandle = OS.PtCreateWidget (OS.PtMultiText (), shellHandle, 0, null);
+ int child = OS.PtWidgetChildFront (textHandle);
+ while (child != 0) {
+ if (OS.PtWidgetClass (child) == OS.PtScrollbar ()) {
+ int [] args = new int [] {
+ OS.Pt_ARG_ORIENTATION, 0, 0,
+ OS.Pt_ARG_WIDTH, 0, 0,
+ OS.Pt_ARG_HEIGHT, 0, 0,
+ OS.Pt_ARG_BASIC_FLAGS, 0, 0,
+ };
+ OS.PtGetResources (child, args.length / 3, args);
+ switch (args [1]) {
+ case OS.Pt_HORIZONTAL:
+ SCROLLBAR_HEIGHT = args [7];
+ SCROLLBAR_HORIZONTAL_BASIC_FLAGS = args [10];
+ break;
+ case OS.Pt_VERTICAL:
+ SCROLLBAR_WIDTH = args [4];
+ SCROLLBAR_VERTICAL_BASIC_FLAGS = args [10];
+ break;
+ }
+ }
+ child = OS.PtWidgetBrotherBehind (child);
+ }
+ OS.PtDestroyWidget (shellHandle);
+}
+
+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.PtSlider (), 0, args.length / 3, args), 0, 0,
+ OS.PtCreateWidgetClass (OS.PtSeparator (), 0, args.length / 3, args), 0, 0,
+ OS.PtCreateWidgetClass (OS.PtToolbar (), 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;
+ PtSlider = ClassesPtr + 180;
+ PtSeparator = ClassesPtr + 192;
+ PtToolbar = ClassesPtr + 204;
+}
+
+void initializeWidgetColors () {
+ OS.PtSetParentWidget (0);
+ int [] args = {
+ OS.Pt_ARG_WINDOW_STATE, OS.Ph_WM_STATE_ISHIDDEN, ~0,
+ };
+ int shellHandle = OS.PtCreateWidget (OS.PtWindow (), 0, args.length / 3, args);
+ args = new int [] {
+ 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 listHandle = 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.PtGetResources (listHandle, args.length / 3, args);
+ LIST_FOREGROUND = args [1];
+ LIST_BACKGROUND = args [4];
+ LIST_SELECTION = args [7];
+ LIST_SELECTION_TEXT = args [10];
+
+ int textHandle = OS.PtCreateWidget (OS.PtText (), shellHandle, 0, null);
+ args = new int [] {
+ OS.Pt_ARG_COLOR, 0, 0,
+ OS.Pt_ARG_FILL_COLOR, 0, 0,
+ };
+ OS.PtGetResources (textHandle, args.length / 3, args);
+ TEXT_FOREGROUND = args [1];
+ TEXT_BACKGROUND = args [4];
+
+ /*
+ * Feature in Photon. The values of Pt_ARG_DARK_BEVEL_COLOR and
+ * Pt_ARG_LIGHT_BEVEL_COLOR are not initialized until the widget
+ * is realized. The fix is to realize the shell without displaying
+ * it.
+ */
+ int buttonHandle = OS.PtCreateWidget (OS.PtButton (), shellHandle, 0, null);
+ OS.PtRealizeWidget(shellHandle);
+ args = new int [] {
+ OS.Pt_ARG_OUTLINE_COLOR, 0, 0,
+ OS.Pt_ARG_OUTLINE_COLOR, 0, 0,
+ OS.Pt_ARG_DARK_BEVEL_COLOR, 0, 0,
+ OS.Pt_ARG_BEVEL_COLOR, 0, 0,
+ OS.Pt_ARG_LIGHT_BEVEL_COLOR, 0, 0,
+ OS.Pt_ARG_BALLOON_COLOR, 0, 0,
+ OS.Pt_ARG_BALLOON_FILL_COLOR, 0, 0,
+ };
+ OS.PtGetResources (buttonHandle, args.length / 3, args);
+ WIDGET_BORDER = args [1];
+ WIDGET_DARK_SHADOW = args [4];
+ WIDGET_NORMAL_SHADOW = args [7];
+ WIDGET_LIGHT_SHADOW = args [10];
+ WIDGET_HIGHLIGHT_SHADOW = args [13];
+ INFO_FOREGROUND = args [16];
+ INFO_BACKGROUND = args [19];
+
+ OS.PtDestroyWidget (shellHandle);
+}
+
+void initializeWidgetFonts () {
+ String property = System.getProperty ("swt.system.font");
+ if (property != null) {
+ defaultFont = Converter.wcsToMbcs (null, property, true);
+ TEXT_FONT = LIST_FONT = GAUGE_FONT = TITLE_FONT = defaultFont;
+ GROUP_FONT = Converter.wcsToMbcs (null, property + "b", true);
+ return;
+ }
+ OS.PtSetParentWidget (0);
+
+ int shellHandle = OS.PtCreateWidget (OS.PtWindow (), 0, 0, null);
+ int [] args = new int [] {OS.Pt_ARG_TITLE_FONT, 0, 0};
+ OS.PtGetResources (shellHandle, args.length / 3, args);
+ int length = OS.strlen (args [1]);
+ GROUP_FONT = TITLE_FONT = new byte [length + 1];
+ OS.memmove (TITLE_FONT, args [1], length);
+
+ int listHandle = OS.PtCreateWidget (OS.PtList (), shellHandle, 0, null);
+ args = new int [] {OS.Pt_ARG_LIST_FONT, 0, 0};
+ OS.PtGetResources (listHandle, args.length / 3, args);
+ length = OS.strlen (args [1]);
+ LIST_FONT = new byte [length + 1];
+ OS.memmove (LIST_FONT, args [1], length);
+
+ 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);
+ length = OS.strlen (args [1]);
+ TEXT_FONT = new byte [length + 1];
+ OS.memmove (TEXT_FONT, args [1], length);
+
+ int scrollHandle = OS.PtCreateWidget (OS.PtScrollbar (), shellHandle, 0, null);
+ args = new int [] {OS.Pt_ARG_GAUGE_FONT, 0, 0};
+ OS.PtGetResources (scrollHandle, args.length / 3, args);
+ length = OS.strlen (args [1]);
+ GAUGE_FONT = new byte [length + 1];
+ OS.memmove (GAUGE_FONT, args [1], length);
+
+ OS.PtDestroyWidget (shellHandle);
+}
+
+void initializeImages () {
+ nullImage = OS.PhCreateImage (null, (short) 1, (short) 1, OS.Pg_IMAGE_DIRECT_888, 0, 0, 0);
+ if (nullImage == 0) SWT.error (SWT.ERROR_NO_HANDLES);
+}
+
+int inputProc (int data, int rcvid, int message, int size) {
+ if (embedded) {
+ runDeferredEvents ();
+ runAsyncMessages ();
+ }
+ return OS.Pt_CONTINUE;
+}
+
/**
* Invokes platform specific functionality to allocate a new GC handle.
* <p>
@@ -1160,16 +1160,16 @@ int inputProc (int data, int rcvid, int message, int size) {
*
* @private
*/
-public int internal_new_GC (GCData data) {
- if (isDisposed()) SWT.error(SWT.ERROR_DEVICE_DISPOSED);
- 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 int internal_new_GC (GCData data) {
+ if (isDisposed()) SWT.error(SWT.ERROR_DEVICE_DISPOSED);
+ 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;
+}
+
/**
* Invokes platform specific functionality to dispose a GC handle.
* <p>
@@ -1185,14 +1185,14 @@ public int internal_new_GC (GCData data) {
*
* @private
*/
-public void internal_dispose_GC (int phGC, GCData data) {
- OS.PgDestroyGC(phGC);
-}
-
-boolean isValidThread () {
- return thread == Thread.currentThread ();
-}
-
+public void internal_dispose_GC (int phGC, GCData data) {
+ OS.PgDestroyGC(phGC);
+}
+
+boolean isValidThread () {
+ return thread == Thread.currentThread ();
+}
+
/**
* Returns the application defined property of the receiver
* with the specified name, or null if it has not been set.
@@ -1217,16 +1217,16 @@ boolean isValidThread () {
* @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;
-}
-
+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
@@ -1249,39 +1249,39 @@ public Object getData (String key) {
* @see #setData
* @see #disposeExec
*/
-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 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 ();
+}
+
/**
* Reads an event from the operating system's event queue,
* dispatches it appropriately, and returns <code>true</code>
@@ -1304,244 +1304,244 @@ void postEvent (Event event) {
* @see #sleep
* @see #wake
*/
-public boolean readAndDispatch () {
- checkDevice ();
- idle = false;
- OS.PtRelease ();
- OS.PtHold ();
- int id = OS.PtAppAddWorkProc (app_context, workProc, 0);
- OS.PtAppProcessEvent (app_context);
- OS.PtAppRemoveWorkProc (app_context, id);
- boolean result = true;
- if (idle) {
- result = runAsyncMessages ();
- } else {
- runDeferredEvents ();
- }
- OS.PtRelease ();
- OS.PtHold ();
- return result;
-}
-
-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 () {
- sendEvent (SWT.Dispose, new Event ());
- 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 ()) {};
- if (disposeList != null) {
- for (int i=0; i<disposeList.length; i++) {
- if (disposeList [i] != null) disposeList [i].run ();
- }
- }
- disposeList = null;
- synchronizer.releaseSynchronizer ();
- synchronizer = null;
- releaseDisplay ();
- super.release ();
-}
-
-void releaseDisplay () {
-
- 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 timers */
- if (timerIds != null) {
- for (int i=0; i<timerIds.length; i++) {
- if (timerIds [i] != 0) OS.PtDestroyWidget (timerIds [i]);
- }
- }
- timerIds = null;
- timerList = null;
- timerProc = 0;
- timerCallback.dispose ();
- timerCallback = null;
-
- /* Free the window proc */
- windowCallback.dispose ();
- windowCallback = null;
-
- /* Free callbacks */
- drawCallback.dispose();
- drawCallback = null;
- workCallback.dispose();
- workCallback = null;
- inputCallback.dispose();
- inputCallback = null;
- hotkeyCallback.dispose();
- hotkeyCallback = null;
-
- if (nullImage != 0) {
- PhImage_t phImage = new PhImage_t();
- OS.memmove(phImage, nullImage, PhImage_t.sizeof);
- phImage.flags = OS.Ph_RELEASE_IMAGE_ALL;
- OS.memmove(nullImage, phImage, PhImage_t.sizeof);
- OS.PhReleaseImage(nullImage);
- OS.free(nullImage);
- nullImage = 0;
- }
-
- /* Release references */
- thread = 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 anywhere in SWT.
- *
- * @param eventType the type of event to listen for
- * @param listener the listener which should no longer be notified when the event occurs
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see Listener
- * @see #addFilter
- * @see #addListener
- *
- * @since 2.1
- */
-void removeFilter (int eventType, Listener listener) {
- checkDevice ();
- if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
- if (filterTable == null) return;
- filterTable.unhook (eventType, listener);
- if (filterTable.size () == 0) filterTable = null;
-}
-
-/**
- * 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_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see Listener
- * @see #addListener
- *
- * @since 2.0
+public boolean readAndDispatch () {
+ checkDevice ();
+ idle = false;
+ OS.PtRelease ();
+ OS.PtHold ();
+ int id = OS.PtAppAddWorkProc (app_context, workProc, 0);
+ OS.PtAppProcessEvent (app_context);
+ OS.PtAppRemoveWorkProc (app_context, id);
+ boolean result = true;
+ if (idle) {
+ result = runAsyncMessages ();
+ } else {
+ runDeferredEvents ();
+ }
+ OS.PtRelease ();
+ OS.PtHold ();
+ return result;
+}
+
+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 () {
+ sendEvent (SWT.Dispose, new Event ());
+ 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 ()) {};
+ if (disposeList != null) {
+ for (int i=0; i<disposeList.length; i++) {
+ if (disposeList [i] != null) disposeList [i].run ();
+ }
+ }
+ disposeList = null;
+ synchronizer.releaseSynchronizer ();
+ synchronizer = null;
+ releaseDisplay ();
+ super.release ();
+}
+
+void releaseDisplay () {
+
+ 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 timers */
+ if (timerIds != null) {
+ for (int i=0; i<timerIds.length; i++) {
+ if (timerIds [i] != 0) OS.PtDestroyWidget (timerIds [i]);
+ }
+ }
+ timerIds = null;
+ timerList = null;
+ timerProc = 0;
+ timerCallback.dispose ();
+ timerCallback = null;
+
+ /* Free the window proc */
+ windowCallback.dispose ();
+ windowCallback = null;
+
+ /* Free callbacks */
+ drawCallback.dispose();
+ drawCallback = null;
+ workCallback.dispose();
+ workCallback = null;
+ inputCallback.dispose();
+ inputCallback = null;
+ hotkeyCallback.dispose();
+ hotkeyCallback = null;
+
+ if (nullImage != 0) {
+ PhImage_t phImage = new PhImage_t();
+ OS.memmove(phImage, nullImage, PhImage_t.sizeof);
+ phImage.flags = OS.Ph_RELEASE_IMAGE_ALL;
+ OS.memmove(nullImage, phImage, PhImage_t.sizeof);
+ OS.PhReleaseImage(nullImage);
+ OS.free(nullImage);
+ nullImage = 0;
+ }
+
+ /* Release references */
+ thread = 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 anywhere in SWT.
+ *
+ * @param eventType the type of event to listen for
+ * @param listener the listener which should no longer be notified when the event occurs
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see Listener
+ * @see #addFilter
+ * @see #addListener
+ *
+ * @since 2.1
*/
-public void removeListener (int eventType, Listener listener) {
- checkDevice ();
- if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
- if (eventTable == null) return;
- eventTable.unhook (eventType, listener);
-}
-
-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 but need not be synchronized.
- */
- while (eventQueue != null) {
-
- /* Take an event off the queue */
- Event event = eventQueue [0];
- if (event == null) break;
- int length = eventQueue.length;
- System.arraycopy (eventQueue, 1, eventQueue, 0, --length);
- eventQueue [length] = null;
-
- /* Run the event */
- Widget widget = event.widget;
- if (widget != null && !widget.isDisposed ()) {
- Widget item = event.item;
- if (item == null || !item.isDisposed ()) {
- widget.sendEvent (event);
- }
- }
-
- /*
- * At this point, the event queue could
- * be null due to a recursive invokation
- * when running the event.
- */
- }
-
- /* Clear the queue */
- eventQueue = null;
- return true;
-}
-
-void sendEvent (int eventType, Event event) {
- if (eventTable == null && filterTable == null) {
- return;
- }
- if (event == null) event = new Event ();
- event.display = this;
- event.type = eventType;
- if (event.time == 0) event.time = getLastEventTime ();
- if (!filterEvent (event)) {
- if (eventTable != null) eventTable.sendEvent (event);
- }
-}
-
-public void setCursorLocation (int x, int y) {
- checkDevice ();
- OS.PhMoveCursorAbs (OS.PhInputGroup (0), x, y);
-}
-
-/**
- * Sets the location of the on-screen pointer relative to the top left corner
- * of the screen. <b>Note: It is typically considered bad practice for a
- * program to move the on-screen pointer location.</b>
- *
- * @param point new position
- * @since 2.0
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * <li>ERROR_NULL_ARGUMENT - if the point is null
- * </ul>
+void removeFilter (int eventType, Listener listener) {
+ checkDevice ();
+ if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+ if (filterTable == null) return;
+ filterTable.unhook (eventType, listener);
+ if (filterTable.size () == 0) filterTable = null;
+}
+
+/**
+ * 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_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see Listener
+ * @see #addListener
+ *
+ * @since 2.0
+ */
+public void removeListener (int eventType, Listener listener) {
+ checkDevice ();
+ if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+ if (eventTable == null) return;
+ eventTable.unhook (eventType, listener);
+}
+
+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 but need not be synchronized.
+ */
+ while (eventQueue != null) {
+
+ /* Take an event off the queue */
+ Event event = eventQueue [0];
+ if (event == null) break;
+ int length = eventQueue.length;
+ System.arraycopy (eventQueue, 1, eventQueue, 0, --length);
+ eventQueue [length] = null;
+
+ /* Run the event */
+ Widget widget = event.widget;
+ if (widget != null && !widget.isDisposed ()) {
+ Widget item = event.item;
+ if (item == null || !item.isDisposed ()) {
+ widget.sendEvent (event);
+ }
+ }
+
+ /*
+ * At this point, the event queue could
+ * be null due to a recursive invokation
+ * when running the event.
+ */
+ }
+
+ /* Clear the queue */
+ eventQueue = null;
+ return true;
+}
+
+void sendEvent (int eventType, Event event) {
+ if (eventTable == null && filterTable == null) {
+ return;
+ }
+ if (event == null) event = new Event ();
+ event.display = this;
+ event.type = eventType;
+ if (event.time == 0) event.time = getLastEventTime ();
+ if (!filterEvent (event)) {
+ if (eventTable != null) eventTable.sendEvent (event);
+ }
+}
+
+public void setCursorLocation (int x, int y) {
+ checkDevice ();
+ OS.PhMoveCursorAbs (OS.PhInputGroup (0), x, y);
+}
+
+/**
+ * Sets the location of the on-screen pointer relative to the top left corner
+ * of the screen. <b>Note: It is typically considered bad practice for a
+ * program to move the on-screen pointer location.</b>
+ *
+ * @param point new position
+ * @since 2.0
+ * @exception SWTException <ul>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * <li>ERROR_NULL_ARGUMENT - if the point is null
+ * </ul>
*/
-public void setCursorLocation (Point point) {
- checkDevice ();
- if (point == null) error (SWT.ERROR_NULL_ARGUMENT);
- setCursorLocation (point.x, point.y);
-}
-
+public void setCursorLocation (Point point) {
+ checkDevice ();
+ if (point == null) error (SWT.ERROR_NULL_ARGUMENT);
+ setCursorLocation (point.x, point.y);
+}
+
/**
* Sets the application defined property of the receiver
* with the specified name to the given argument.
@@ -1566,54 +1566,54 @@ public void setCursorLocation (Point point) {
* @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;
-}
-
+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.
@@ -1636,11 +1636,11 @@ public void setData (String key, Object value) {
* @see #getData
* @see #disposeExec
*/
-public void setData (Object data) {
- checkDevice ();
- this.data = data;
-}
-
+public void setData (Object data) {
+ checkDevice ();
+ this.data = data;
+}
+
/**
* Sets the synchronizer used by the display to be
* the argument, which can not be null.
@@ -1654,15 +1654,15 @@ public void setData (Object data) {
* <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;
-}
-
+public void setSynchronizer (Synchronizer synchronizer) {
+ checkDevice ();
+ if (synchronizer == null) error (SWT.ERROR_NULL_ARGUMENT);
+ if (this.synchronizer != null) {
+ this.synchronizer.runAsyncMessages();
+ }
+ this.synchronizer = synchronizer;
+}
+
/**
* Causes the user-interface thread to <em>sleep</em> (that is,
* to be put in a state where it does not consume CPU cycles)
@@ -1676,15 +1676,15 @@ public void setSynchronizer (Synchronizer synchronizer) {
*
* @see #wake
*/
-public boolean sleep () {
- checkDevice ();
- OS.PtHold ();
- OS.PtAppProcessEvent (app_context);
- runDeferredEvents ();
- OS.PtRelease ();
- return true;
-}
-
+public boolean sleep () {
+ checkDevice ();
+ OS.PtHold ();
+ OS.PtAppProcessEvent (app_context);
+ runDeferredEvents ();
+ OS.PtRelease ();
+ return true;
+}
+
/**
* Causes the <code>run()</code> method of the runnable to
* be invoked by the user-interface thread at the next
@@ -1699,20 +1699,20 @@ public boolean sleep () {
*
* @see #asyncExec
*/
-public void syncExec (Runnable runnable) {
- if (isDisposed ()) error (SWT.ERROR_DEVICE_DISPOSED);
- synchronizer.syncExec (runnable);
-}
-
-int textWidth (String string, byte[] font) {
- if (string.length () == 0) return 0;
- byte [] textBuffer = Converter.wcsToMbcs (null, string, false);
- PhRect_t rect = new PhRect_t ();
- OS.PfExtentText(rect, null, font, textBuffer, textBuffer.length);
- if (rect.lr_x == rect.ul_x) return 0;
- return rect.lr_x - rect.ul_x + 1;
-}
-
+public void syncExec (Runnable runnable) {
+ if (isDisposed ()) error (SWT.ERROR_DEVICE_DISPOSED);
+ synchronizer.syncExec (runnable);
+}
+
+int textWidth (String string, byte[] font) {
+ if (string.length () == 0) return 0;
+ byte [] textBuffer = Converter.wcsToMbcs (null, string, false);
+ PhRect_t rect = new PhRect_t ();
+ OS.PfExtentText(rect, null, font, textBuffer, textBuffer.length);
+ if (rect.lr_x == rect.ul_x) return 0;
+ return rect.lr_x - rect.ul_x + 1;
+}
+
/**
* Causes the <code>run()</code> method of the runnable to
* be invoked by the user-interface thread after the specified
@@ -1731,91 +1731,91 @@ int textWidth (String string, byte[] font) {
*
* @see #asyncExec
*/
-public void timerExec (int milliseconds, Runnable runnable) {
- checkDevice ();
- if (runnable == null) error (SWT.ERROR_NULL_ARGUMENT);
- if (timerList == null) timerList = new Runnable [4];
- if (timerIds == null) timerIds = new int [4];
- int index = 0;
- while (index < timerList.length) {
- if (timerList [index] == runnable) break;
- index++;
- }
- if (index != timerList.length) {
- OS.PtDestroyWidget (timerIds [index]);
- timerList [index] = null;
- timerIds [index] = 0;
- if (milliseconds < 0) return;
- } else {
- if (milliseconds < 0) return;
- index = 0;
- while (index < timerList.length) {
- if (timerList [index] == null) break;
- index++;
- }
- if (index == timerList.length) {
- Runnable [] newTimerList = new Runnable [timerList.length + 4];
- System.arraycopy (timerList, 0, newTimerList, 0, timerList.length);
- timerList = newTimerList;
- int [] newTimerIds = new int [timerIds.length + 4];
- System.arraycopy (timerIds, 0, newTimerIds, 0, timerIds.length);
- timerIds = newTimerIds;
- }
- }
- int [] args = {OS.Pt_ARG_TIMER_INITIAL, milliseconds, 0};
- int timerId = OS.PtCreateWidget (OS.PtTimer (), timerHandle, args.length / 3, args);
- if (timerId != 0) {
- OS.PtRealizeWidget (timerId);
- OS.PtAddCallback (timerId, OS.Pt_CB_TIMER_ACTIVATE, timerProc, index);
- timerIds [index] = timerId;
- timerList [index] = runnable;
- }
-}
-
-int timerProc (int handle, int index, int info) {
- if (timerList == null) return 0;
- if (0 <= index && index < timerList.length) {
- int timerId = timerIds [index];
- Runnable runnable = timerList [index];
- timerList [index] = null;
- timerIds [index] = 0;
- if (runnable != null) runnable.run ();
- OS.PtDestroyWidget (timerId);
- }
- 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 timerExec (int milliseconds, Runnable runnable) {
+ checkDevice ();
+ if (runnable == null) error (SWT.ERROR_NULL_ARGUMENT);
+ if (timerList == null) timerList = new Runnable [4];
+ if (timerIds == null) timerIds = new int [4];
+ int index = 0;
+ while (index < timerList.length) {
+ if (timerList [index] == runnable) break;
+ index++;
+ }
+ if (index != timerList.length) {
+ OS.PtDestroyWidget (timerIds [index]);
+ timerList [index] = null;
+ timerIds [index] = 0;
+ if (milliseconds < 0) return;
+ } else {
+ if (milliseconds < 0) return;
+ index = 0;
+ while (index < timerList.length) {
+ if (timerList [index] == null) break;
+ index++;
+ }
+ if (index == timerList.length) {
+ Runnable [] newTimerList = new Runnable [timerList.length + 4];
+ System.arraycopy (timerList, 0, newTimerList, 0, timerList.length);
+ timerList = newTimerList;
+ int [] newTimerIds = new int [timerIds.length + 4];
+ System.arraycopy (timerIds, 0, newTimerIds, 0, timerIds.length);
+ timerIds = newTimerIds;
+ }
+ }
+ int [] args = {OS.Pt_ARG_TIMER_INITIAL, milliseconds, 0};
+ int timerId = OS.PtCreateWidget (OS.PtTimer (), timerHandle, args.length / 3, args);
+ if (timerId != 0) {
+ OS.PtRealizeWidget (timerId);
+ OS.PtAddCallback (timerId, OS.Pt_CB_TIMER_ACTIVATE, timerProc, index);
+ timerIds [index] = timerId;
+ timerList [index] = runnable;
+ }
+}
+
+int timerProc (int handle, int index, int info) {
+ if (timerList == null) return 0;
+ if (0 <= index && index < timerList.length) {
+ int timerId = timerIds [index];
+ Runnable runnable = timerList [index];
+ timerList [index] = null;
+ timerIds [index] = 0;
+ if (runnable != null) runnable.run ();
+ OS.PtDestroyWidget (timerId);
+ }
+ 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;
+}
+
/**
* Forces all outstanding paint requests for the display
* to be processed before this method returns.
*
* @see Control#update
*/
-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 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
@@ -1823,78 +1823,78 @@ public void update() {
*
* @see #sleep
*/
-public void wake () {
- if (isDisposed ()) error (SWT.ERROR_DEVICE_DISPOSED);
- if (!embedded && thread == Thread.currentThread ()) return;
-// 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.windowProc (handle, data, info);
-}
-
-int workProc (int data) {
- idle = true;
- return OS.Pt_CONTINUE;
-}
-
-String wrapText (String text, byte[] font, int width) {
- text = convertToLf (text);
- int length = text.length ();
- if (width <= 0 || length == 0 || length == 1) return text;
- StringBuffer result = new StringBuffer ();
- int lineStart = 0, lineEnd = 0;
- while (lineStart < length) {
- lineEnd = text.indexOf ('\n', lineStart);
- boolean noLf = lineEnd == -1;
- if (noLf) lineEnd = length;
- int nextStart = lineEnd + 1;
- while (lineEnd > lineStart + 1 && Compatibility.isWhitespace (text.charAt (lineEnd - 1))) {
- lineEnd--;
- }
- int wordStart = lineStart, wordEnd = lineStart;
- int i = lineStart;
- while (i < lineEnd) {
- int lastStart = wordStart, lastEnd = wordEnd;
- wordStart = i;
- while (i < lineEnd && !Compatibility.isWhitespace (text.charAt (i))) {
- i++;
- }
- wordEnd = i - 1;
- String line = text.substring (lineStart, wordEnd + 1);
- int lineWidth = textWidth (line, font);
- while (i < lineEnd && Compatibility.isWhitespace (text.charAt (i))) {
- i++;
- }
- if (lineWidth > width) {
- if (lastStart == wordStart) {
- while (wordStart < wordEnd) {
- line = text.substring (lineStart, wordStart + 1);
- lineWidth = textWidth (line, font);
- if (lineWidth >= width) break;
- wordStart++;
- }
- if (wordStart == lastStart) wordStart++;
- lastEnd = wordStart - 1;
- }
- line = text.substring (lineStart, lastEnd + 1);
- result.append (line); result.append ('\n');
- i = wordStart; lineStart = wordStart; wordEnd = wordStart;
- }
- }
- if (lineStart < lineEnd) {
- result.append (text.substring (lineStart, lineEnd));
- }
- if (!noLf) {
- result.append ('\n');
- }
- lineStart = nextStart;
- }
- return result.toString ();
-}
-
-}
+public void wake () {
+ if (isDisposed ()) error (SWT.ERROR_DEVICE_DISPOSED);
+ if (!embedded && thread == Thread.currentThread ()) return;
+// 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.windowProc (handle, data, info);
+}
+
+int workProc (int data) {
+ idle = true;
+ return OS.Pt_CONTINUE;
+}
+
+String wrapText (String text, byte[] font, int width) {
+ text = convertToLf (text);
+ int length = text.length ();
+ if (width <= 0 || length == 0 || length == 1) return text;
+ StringBuffer result = new StringBuffer ();
+ int lineStart = 0, lineEnd = 0;
+ while (lineStart < length) {
+ lineEnd = text.indexOf ('\n', lineStart);
+ boolean noLf = lineEnd == -1;
+ if (noLf) lineEnd = length;
+ int nextStart = lineEnd + 1;
+ while (lineEnd > lineStart + 1 && Compatibility.isWhitespace (text.charAt (lineEnd - 1))) {
+ lineEnd--;
+ }
+ int wordStart = lineStart, wordEnd = lineStart;
+ int i = lineStart;
+ while (i < lineEnd) {
+ int lastStart = wordStart, lastEnd = wordEnd;
+ wordStart = i;
+ while (i < lineEnd && !Compatibility.isWhitespace (text.charAt (i))) {
+ i++;
+ }
+ wordEnd = i - 1;
+ String line = text.substring (lineStart, wordEnd + 1);
+ int lineWidth = textWidth (line, font);
+ while (i < lineEnd && Compatibility.isWhitespace (text.charAt (i))) {
+ i++;
+ }
+ if (lineWidth > width) {
+ if (lastStart == wordStart) {
+ while (wordStart < wordEnd) {
+ line = text.substring (lineStart, wordStart + 1);
+ lineWidth = textWidth (line, font);
+ if (lineWidth >= width) break;
+ wordStart++;
+ }
+ if (wordStart == lastStart) wordStart++;
+ lastEnd = wordStart - 1;
+ }
+ line = text.substring (lineStart, lastEnd + 1);
+ result.append (line); result.append ('\n');
+ i = wordStart; lineStart = wordStart; wordEnd = wordStart;
+ }
+ }
+ if (lineStart < lineEnd) {
+ result.append (text.substring (lineStart, lineEnd));
+ }
+ if (!noLf) {
+ result.append ('\n');
+ }
+ lineStart = nextStart;
+ }
+ return result.toString ();
+}
+
+}
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
index 6aed157fae..9fa6ff6c4c 100755
--- 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
@@ -1,16 +1,16 @@
-package org.eclipse.swt.widgets;
-
-/*
+package org.eclipse.swt.widgets;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-import org.eclipse.swt.internal.*;
-import org.eclipse.swt.internal.photon.*;
-import org.eclipse.swt.*;
-
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+import org.eclipse.swt.internal.*;
+import org.eclipse.swt.internal.photon.*;
+import org.eclipse.swt.*;
+
/**
* Instances of this class allow the user to navigate
* the file system and select or enter a file name.
@@ -25,12 +25,12 @@ import org.eclipse.swt.*;
* within the SWT implementation.
* </p>
*/
-public class FileDialog extends Dialog {
- String [] filterNames = new String [0];
- String [] filterExtensions = new String [0];
- String filterPath = "", fileName = "";
- static final String FILTER = "*";
-
+public class FileDialog extends Dialog {
+ String [] filterNames = new String [0];
+ String [] filterExtensions = new String [0];
+ String filterPath = "", fileName = "";
+ static final String FILTER = "*";
+
/**
* Constructs a new instance of this class given only its
* parent.
@@ -53,10 +53,10 @@ public class FileDialog extends Dialog {
* <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
* </ul>
*/
-public FileDialog (Shell parent) {
- this (parent, SWT.PRIMARY_MODAL);
-}
-
+public FileDialog (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.
@@ -87,11 +87,11 @@ public FileDialog (Shell parent) {
* <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
* </ul>
*/
-public FileDialog (Shell parent, int style) {
- super (parent, style);
- checkSubclass ();
-}
-
+public FileDialog (Shell parent, int style) {
+ super (parent, style);
+ checkSubclass ();
+}
+
/**
* Returns the path of the first file that was
* selected in the dialog relative to the filter path,
@@ -99,10 +99,10 @@ public FileDialog (Shell parent, int style) {
*
* @return the relative path of the file
*/
-public String getFileName () {
- return fileName;
-}
-
+public String getFileName () {
+ return fileName;
+}
+
/**
* Returns the paths of all files that were selected
* in the dialog relative to the filter path, or null
@@ -110,30 +110,30 @@ public String getFileName () {
*
* @return the relative paths of the files
*/
-public String [] getFileNames () {
- return new String [] {fileName};
-}
-
+public String [] getFileNames () {
+ return new String [] {fileName};
+}
+
/**
* Returns the file extensions which the dialog will
* use to filter the files it shows.
*
* @return the file extensions filter
*/
-public String [] getFilterExtensions () {
- return filterExtensions;
-}
-
+public String [] getFilterExtensions () {
+ return filterExtensions;
+}
+
/**
* Returns the file names which the dialog will
* use to filter the files it shows.
*
* @return the file name filter
*/
-public String [] getFilterNames () {
- return filterNames;
-}
-
+public String [] getFilterNames () {
+ return filterNames;
+}
+
/**
* Returns the directory path that the dialog will use.
* File names in this path will appear in the dialog,
@@ -143,10 +143,10 @@ public String [] getFilterNames () {
*
* @see #setFilterExtensions
*/
-public String getFilterPath () {
- return filterPath;
-}
-
+public String getFilterPath () {
+ return filterPath;
+}
+
/**
* Makes the dialog visible and brings it to the front
* of the display.
@@ -159,73 +159,73 @@ public String getFilterPath () {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the dialog</li>
* </ul>
*/
-public String open () {
- int parentHandle = 0;
- if (parent != null && OS.PtWidgetIsRealized(parent.shellHandle)) {
- 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 {
- 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);
- byte [] btn1_text = null;
- if ((style & SWT.SAVE) != 0) {
- btn1_text = Converter.wcsToMbcs(null, SWT.getMessage("SWT_Save"), true);
- }
- int flags = OS.Pt_FSR_NO_FCHECK;
- PtFileSelectionInfo_t info = new PtFileSelectionInfo_t ();
- OS.PtFileSelection (parentHandle, null, title, root_dir, file_spec, btn1_text, 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 String open () {
+ int parentHandle = 0;
+ if (parent != null && OS.PtWidgetIsRealized(parent.shellHandle)) {
+ 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 {
+ 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);
+ byte [] btn1_text = null;
+ if ((style & SWT.SAVE) != 0) {
+ btn1_text = Converter.wcsToMbcs(null, SWT.getMessage("SWT_Save"), true);
+ }
+ int flags = OS.Pt_FSR_NO_FCHECK;
+ PtFileSelectionInfo_t info = new PtFileSelectionInfo_t ();
+ OS.PtFileSelection (parentHandle, null, title, root_dir, file_spec, btn1_text, 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;
+}
+
/**
* Set the initial filename which the dialog will
* select by default when opened to the argument,
@@ -234,10 +234,10 @@ public String open () {
*
* @param string the file name
*/
-public void setFileName (String string) {
- fileName = string;
-}
-
+public void setFileName (String string) {
+ fileName = string;
+}
+
/**
* Set the file extensions which the dialog will
* use to filter the files it shows to the argument,
@@ -245,10 +245,10 @@ public void setFileName (String string) {
*
* @param extensions the file extension filter
*/
-public void setFilterExtensions (String [] extensions) {
- filterExtensions = extensions;
-}
-
+public void setFilterExtensions (String [] extensions) {
+ filterExtensions = extensions;
+}
+
/**
* Sets the file names which the dialog will
* use to filter the files it shows to the argument,
@@ -256,10 +256,10 @@ public void setFilterExtensions (String [] extensions) {
*
* @param names the file name filter
*/
-public void setFilterNames (String [] names) {
- filterNames = names;
-}
-
+public void setFilterNames (String [] names) {
+ filterNames = names;
+}
+
/**
* Sets the directory path that the dialog will use
* to the argument, which may be null. File names in this
@@ -270,8 +270,8 @@ public void setFilterNames (String [] names) {
*
* @see #setFilterExtensions
*/
-public void setFilterPath (String string) {
- filterPath = string;
-}
-
-}
+public void setFilterPath (String string) {
+ filterPath = string;
+}
+
+}
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
index 71325916e7..91cc77e697 100755
--- 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
@@ -1,17 +1,17 @@
-package org.eclipse.swt.widgets;
-
-/*
+package org.eclipse.swt.widgets;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-import org.eclipse.swt.internal.*;
-import org.eclipse.swt.internal.photon.*;
-import org.eclipse.swt.*;
-import org.eclipse.swt.graphics.*;
-
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+import org.eclipse.swt.internal.*;
+import org.eclipse.swt.internal.photon.*;
+import org.eclipse.swt.*;
+import org.eclipse.swt.graphics.*;
+
/**
* Instances of this class allow the user to select a font
* from all available fonts in the system.
@@ -20,9 +20,9 @@ import org.eclipse.swt.graphics.*;
* within the SWT implementation.
* </p>
*/
-public class FontDialog extends Dialog {
- FontData fontData;
- RGB rgb;
+public class FontDialog extends Dialog {
+ FontData fontData;
+ RGB rgb;
/**
* Constructs a new instance of this class given only its
* parent.
@@ -45,9 +45,9 @@ public class FontDialog extends Dialog {
* <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
* </ul>
*/
-public FontDialog (Shell parent) {
- this (parent, SWT.PRIMARY_MODAL);
-}
+public FontDialog (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.
@@ -78,29 +78,29 @@ public FontDialog (Shell parent) {
* <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
* </ul>
*/
-public FontDialog (Shell parent, int style) {
- super (parent, style);
- checkSubclass ();
-}
+public FontDialog (Shell parent, int style) {
+ super (parent, style);
+ checkSubclass ();
+}
/**
* Returns a FontData object describing the font that was
* selected in the dialog, or null if none is available.
*
* @return the FontData for the selected font, or null
*/
-public FontData getFontData() {
- return fontData;
-}
-/**
- * Returns the currently selected color in the receiver.
- *
- * @return the RGB value for the selected color, may be null
- *
- * @see PaletteData#getRGBs
- */
-public RGB getRGB () {
- return rgb;
-}
+public FontData getFontData() {
+ return fontData;
+}
+/**
+ * Returns the currently selected color in the receiver.
+ *
+ * @return the RGB value for the selected color, may be null
+ *
+ * @see PaletteData#getRGBs
+ */
+public RGB getRGB () {
+ return rgb;
+}
/**
* Makes the dialog visible and brings it to the front
* of the display.
@@ -113,40 +113,40 @@ public RGB getRGB () {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the dialog</li>
* </ul>
*/
-public FontData open () {
- int parentHandle = 0;
- if (parent != null && OS.PtWidgetIsRealized(parent.shellHandle)) {
- 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 flags = OS.PHFONT_ALL_FONTS | OS.PHFONT_DONT_SHOW_LEGACY;
- int fontPtr = OS.PtFontSelection (parentHandle, null, title, font, OS.PHFONT_ALL_SYMBOLS, flags, null);
-
- if (fontPtr != 0) {
- int length = OS.strlen (fontPtr);
- font = new byte [length + 1];
- OS.memmove (font, fontPtr, length);
- fontData = FontData.photon_new (font);
- }
- return fontData;
-}
+public FontData open () {
+ int parentHandle = 0;
+ if (parent != null && OS.PtWidgetIsRealized(parent.shellHandle)) {
+ 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 flags = OS.PHFONT_ALL_FONTS | OS.PHFONT_DONT_SHOW_LEGACY;
+ int fontPtr = OS.PtFontSelection (parentHandle, null, title, font, OS.PHFONT_ALL_SYMBOLS, flags, null);
+
+ if (fontPtr != 0) {
+ int length = OS.strlen (fontPtr);
+ font = new byte [length + 1];
+ OS.memmove (font, fontPtr, length);
+ fontData = FontData.photon_new (font);
+ }
+ return fontData;
+}
/**
* Sets a FontData object describing the font to be
* selected by default in the dialog, or null to let
@@ -154,19 +154,19 @@ public FontData open () {
*
* @param fontData the FontData to use initially, or null
*/
-public void setFontData (FontData fontData) {
- this.fontData = fontData;
-}
-/**
- * Returns the receiver's selected color to be the argument.
- *
- * @param rgb the new RGB value for the selected color, may be
- * null to let the platform to select a default when
- * open() is called
- *
- * @see PaletteData#getRGBs
- */
-public void setRGB (RGB rgb) {
- this.rgb = rgb;
-}
-}
+public void setFontData (FontData fontData) {
+ this.fontData = fontData;
+}
+/**
+ * Returns the receiver's selected color to be the argument.
+ *
+ * @param rgb the new RGB value for the selected color, may be
+ * null to let the platform to select a default when
+ * open() is called
+ *
+ * @see PaletteData#getRGBs
+ */
+public void setRGB (RGB rgb) {
+ this.rgb = rgb;
+}
+}
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
index 30b0acaeb4..034847dbf3 100755
--- 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
@@ -1,17 +1,17 @@
-package org.eclipse.swt.widgets;
-
-/*
+package org.eclipse.swt.widgets;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-import org.eclipse.swt.internal.*;
-import org.eclipse.swt.internal.photon.*;
-import org.eclipse.swt.*;
-import org.eclipse.swt.graphics.*;
-
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+import org.eclipse.swt.internal.*;
+import org.eclipse.swt.internal.photon.*;
+import org.eclipse.swt.*;
+import org.eclipse.swt.graphics.*;
+
/**
* Instances of this class provide an etched border
* with an optional title.
@@ -32,8 +32,8 @@ import org.eclipse.swt.graphics.*;
* IMPORTANT: This class is <em>not</em> intended to be subclassed.
* </p>
*/
-public class Group extends Composite {
-
+public class Group extends Composite {
+
/**
* Constructs a new instance of this class given its parent
* and a style value describing its behavior and appearance.
@@ -66,63 +66,63 @@ public class Group extends Composite {
* @see Widget#checkSubclass
* @see Widget#getStyle
*/
-public Group (Composite parent, int style) {
- super (parent, checkStyle (style));
-}
-
-static int checkStyle (int style) {
- style |= SWT.NO_FOCUS;
- /*
- * Even though it is legal to create this widget
- * with scroll bars, they serve no useful purpose
- * because they do not automatically scroll the
- * widget's client area. The fix is to clear
- * the SWT style.
- */
- return style & ~(SWT.H_SCROLL | SWT.V_SCROLL);
-}
-
-public Point computeSize (int wHint, int hHint, boolean changed) {
- checkWidget();
- 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) {
- state |= HANDLE;
- Display display = getDisplay ();
- int clazz = display.PtContainer;
- int parentHandle = parent.parentingHandle ();
- 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);
-}
-
-byte [] defaultFont () {
- Display display = getDisplay ();
- return display.GROUP_FONT;
-}
-
+public Group (Composite parent, int style) {
+ super (parent, checkStyle (style));
+}
+
+static int checkStyle (int style) {
+ style |= SWT.NO_FOCUS;
+ /*
+ * Even though it is legal to create this widget
+ * with scroll bars, they serve no useful purpose
+ * because they do not automatically scroll the
+ * widget's client area. The fix is to clear
+ * the SWT style.
+ */
+ return style & ~(SWT.H_SCROLL | SWT.V_SCROLL);
+}
+
+public Point computeSize (int wHint, int hHint, boolean changed) {
+ checkWidget();
+ 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) {
+ state |= HANDLE;
+ Display display = getDisplay ();
+ int clazz = display.PtContainer;
+ int parentHandle = parent.parentingHandle ();
+ 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);
+}
+
+byte [] defaultFont () {
+ Display display = getDisplay ();
+ return display.GROUP_FONT;
+}
+
/**
* Returns the receiver's text, which is the string that the
* is used as the <em>title</em>. If the text has not previously
@@ -135,42 +135,42 @@ byte [] defaultFont () {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public String getText () {
- checkWidget();
- 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();
- int str = args [1];
- if (str != 0) {
- int length = OS.strlen (str);
- if (length > 0) {
- OS.PfExtentText(rect, null, args [4], str, 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);
-}
-
+public String getText () {
+ checkWidget();
+ 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();
+ int str = args [1];
+ if (str != 0) {
+ int length = OS.strlen (str);
+ if (length > 0) {
+ OS.PfExtentText(rect, null, args [4], str, 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);
+}
+
/**
* Sets the receiver's text, which is the string that will
* be displayed as the receiver's <em>title</em>, to the argument,
@@ -186,23 +186,23 @@ Point getTitleSize() {
* <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 flags = OS.Pt_SHOW_TITLE | OS.Pt_ETCH_TITLE_AREA;
- byte [] buffer = Converter.wcsToMbcs (null, stripMnemonics (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);
-}
-
-int widgetClass () {
- return OS.PtContainer ();
-}
-
-}
+public void setText (String string) {
+ checkWidget();
+ if (string == null) error (SWT.ERROR_NULL_ARGUMENT);
+ int flags = OS.Pt_SHOW_TITLE | OS.Pt_ETCH_TITLE_AREA;
+ byte [] buffer = Converter.wcsToMbcs (null, stripMnemonics (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);
+}
+
+int widgetClass () {
+ return OS.PtContainer ();
+}
+
+}
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
index 8967808c6c..18c43dc3f9 100755
--- 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
@@ -1,17 +1,17 @@
-package org.eclipse.swt.widgets;
-
-/*
+package org.eclipse.swt.widgets;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-import org.eclipse.swt.internal.*;
-import org.eclipse.swt.internal.photon.*;
-import org.eclipse.swt.*;
-import org.eclipse.swt.graphics.*;
-
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+import org.eclipse.swt.internal.*;
+import org.eclipse.swt.internal.photon.*;
+import org.eclipse.swt.*;
+import org.eclipse.swt.graphics.*;
+
/**
* Instances of this class represent a non-selectable
* user interface object that displays a string or image.
@@ -34,10 +34,10 @@ import org.eclipse.swt.graphics.*;
* within the SWT implementation.
* </p>
*/
-public class Label extends Control {
- String text = "";
- Image image;
-
+public class Label extends Control {
+ String text = "";
+ Image image;
+
/**
* Constructs a new instance of this class given its parent
* and a style value describing its behavior and appearance.
@@ -75,136 +75,136 @@ public class Label extends Control {
* @see Widget#checkSubclass
* @see Widget#getStyle
*/
-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) {
- checkWidget();
- if ((style & SWT.SEPARATOR) != 0) {
- int border = getBorderWidth ();
- int width = border * 2, height = border * 2;
- if ((style & SWT.HORIZONTAL) != 0) {
- width += DEFAULT_WIDTH; height += 3;
- } else {
- width += 3; height += DEFAULT_HEIGHT;
- }
- if (wHint != SWT.DEFAULT) width = wHint + (border * 2);
- if (hHint != SWT.DEFAULT) height = hHint + (border * 2);
- return new Point (width, height);
- }
-
- if ((style & SWT.WRAP) != 0) {
- int [] args = {
- OS.Pt_ARG_LABEL_TYPE, 0, 0, // 1
- OS.Pt_ARG_TEXT_FONT, 0, 0, // 4
- OS.Pt_ARG_LINE_SPACING, 0, 0, // 7
- OS.Pt_ARG_MARGIN_WIDTH, 0, 0, // 10
- OS.Pt_ARG_MARGIN_HEIGHT, 0, 0, // 13
- OS.Pt_ARG_MARGIN_LEFT, 0, 0, // 16
- OS.Pt_ARG_MARGIN_RIGHT, 0, 0, // 19
- OS.Pt_ARG_MARGIN_TOP, 0, 0, // 22
- OS.Pt_ARG_MARGIN_BOTTOM, 0, 0, // 25
- };
- OS.PtGetResources (handle, args.length / 3, args);
- /* If we are wrapping text, calculate the height based on wHint. */
- if (args [1] == OS.Pt_Z_STRING) {
- int width = wHint, height = hHint;
- if (wHint == SWT.DEFAULT || hHint == SWT.DEFAULT) {
- int length = OS.strlen (args [4]);
- byte [] font = new byte [length + 1];
- OS.memmove (font, args [4], length);
- String string = text;
- if (wHint != SWT.DEFAULT) {
- Display display = getDisplay ();
- string = display.wrapText (text, font, wHint);
- }
- byte [] buffer = Converter.wcsToMbcs (null, string, false);
- PhRect_t rect = new PhRect_t ();
- OS.PgExtentMultiText (rect, null, font, buffer, buffer.length, args [7]);
- if (wHint == SWT.DEFAULT) width = rect.lr_x - rect.ul_x + 1;
- if (hHint == SWT.DEFAULT) height = rect.lr_y - rect.ul_y + 1;
- }
- PhArea_t area = new PhArea_t ();
+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) {
+ checkWidget();
+ if ((style & SWT.SEPARATOR) != 0) {
+ int border = getBorderWidth ();
+ int width = border * 2, height = border * 2;
+ if ((style & SWT.HORIZONTAL) != 0) {
+ width += DEFAULT_WIDTH; height += 3;
+ } else {
+ width += 3; height += DEFAULT_HEIGHT;
+ }
+ if (wHint != SWT.DEFAULT) width = wHint + (border * 2);
+ if (hHint != SWT.DEFAULT) height = hHint + (border * 2);
+ return new Point (width, height);
+ }
+
+ if ((style & SWT.WRAP) != 0) {
+ int [] args = {
+ OS.Pt_ARG_LABEL_TYPE, 0, 0, // 1
+ OS.Pt_ARG_TEXT_FONT, 0, 0, // 4
+ OS.Pt_ARG_LINE_SPACING, 0, 0, // 7
+ OS.Pt_ARG_MARGIN_WIDTH, 0, 0, // 10
+ OS.Pt_ARG_MARGIN_HEIGHT, 0, 0, // 13
+ OS.Pt_ARG_MARGIN_LEFT, 0, 0, // 16
+ OS.Pt_ARG_MARGIN_RIGHT, 0, 0, // 19
+ OS.Pt_ARG_MARGIN_TOP, 0, 0, // 22
+ OS.Pt_ARG_MARGIN_BOTTOM, 0, 0, // 25
+ };
+ OS.PtGetResources (handle, args.length / 3, args);
+ /* If we are wrapping text, calculate the height based on wHint. */
+ if (args [1] == OS.Pt_Z_STRING) {
+ int width = wHint, height = hHint;
+ if (wHint == SWT.DEFAULT || hHint == SWT.DEFAULT) {
+ int length = OS.strlen (args [4]);
+ byte [] font = new byte [length + 1];
+ OS.memmove (font, args [4], length);
+ String string = text;
+ if (wHint != SWT.DEFAULT) {
+ Display display = getDisplay ();
+ string = display.wrapText (text, font, wHint);
+ }
+ byte [] buffer = Converter.wcsToMbcs (null, string, false);
+ PhRect_t rect = new PhRect_t ();
+ OS.PgExtentMultiText (rect, null, font, buffer, buffer.length, args [7]);
+ if (wHint == SWT.DEFAULT) width = rect.lr_x - rect.ul_x + 1;
+ if (hHint == SWT.DEFAULT) height = rect.lr_y - rect.ul_y + 1;
+ }
+ PhArea_t area = new PhArea_t ();
PhRect_t rect = new PhRect_t ();
- OS.PtSetAreaFromWidgetCanvas (handle, rect, area);
- width += (area.size_w - 1) + (args [10] * 2) + args [16] + args [19];
- height += (area.size_h - 1) + (args [13] * 2) + args [22] + args [25];
- return new Point (width, height);
- }
- }
-
- PhDim_t dim = new PhDim_t();
- if (!OS.PtWidgetIsRealized (handle)) OS.PtExtentWidget (handle);
- OS.PtWidgetPreferredSize(handle, dim);
- int width = dim.w, height = dim.h;
- if (wHint != SWT.DEFAULT || hHint != SWT.DEFAULT) {
- int [] args = {
- OS.Pt_ARG_MARGIN_WIDTH, 0, 0, // 1
- OS.Pt_ARG_MARGIN_HEIGHT, 0, 0, // 4
- OS.Pt_ARG_MARGIN_LEFT, 0, 0, // 7
- OS.Pt_ARG_MARGIN_RIGHT, 0, 0, // 10
- OS.Pt_ARG_MARGIN_TOP, 0, 0, // 13
- OS.Pt_ARG_MARGIN_BOTTOM, 0, 0, // 16
- };
- OS.PtGetResources (handle, args.length / 3, args);
- 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 + (args [1] * 2) + args [7] + args [10];
- }
- if (hHint != SWT.DEFAULT) {
- height = area.size_h + (args [4] * 2) + args [13] + args [16];
- }
- }
- return new Point (width, height);
-}
-
-void createHandle (int index) {
- state |= HANDLE;
- Display display = getDisplay ();
- int parentHandle = parent.parentingHandle ();
-
- 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_FILL_COLOR, display.WIDGET_BACKGROUND, 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 verticalAlign = (style & SWT.WRAP) != 0 ? OS.Pt_TOP : OS.Pt_CENTER;
- boolean hasBorder = (style & SWT.BORDER) != 0;
- int [] args = {
- OS.Pt_ARG_FLAGS, hasBorder ? OS.Pt_HIGHLIGHTED : 0, OS.Pt_HIGHLIGHTED,
- OS.Pt_ARG_HORIZONTAL_ALIGNMENT, alignment, 0,
- OS.Pt_ARG_VERTICAL_ALIGNMENT, verticalAlign, 0,
- OS.Pt_ARG_FILL_COLOR, display.WIDGET_BACKGROUND, 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);
-}
-
+ OS.PtSetAreaFromWidgetCanvas (handle, rect, area);
+ width += (area.size_w - 1) + (args [10] * 2) + args [16] + args [19];
+ height += (area.size_h - 1) + (args [13] * 2) + args [22] + args [25];
+ return new Point (width, height);
+ }
+ }
+
+ PhDim_t dim = new PhDim_t();
+ if (!OS.PtWidgetIsRealized (handle)) OS.PtExtentWidget (handle);
+ OS.PtWidgetPreferredSize(handle, dim);
+ int width = dim.w, height = dim.h;
+ if (wHint != SWT.DEFAULT || hHint != SWT.DEFAULT) {
+ int [] args = {
+ OS.Pt_ARG_MARGIN_WIDTH, 0, 0, // 1
+ OS.Pt_ARG_MARGIN_HEIGHT, 0, 0, // 4
+ OS.Pt_ARG_MARGIN_LEFT, 0, 0, // 7
+ OS.Pt_ARG_MARGIN_RIGHT, 0, 0, // 10
+ OS.Pt_ARG_MARGIN_TOP, 0, 0, // 13
+ OS.Pt_ARG_MARGIN_BOTTOM, 0, 0, // 16
+ };
+ OS.PtGetResources (handle, args.length / 3, args);
+ 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 + (args [1] * 2) + args [7] + args [10];
+ }
+ if (hHint != SWT.DEFAULT) {
+ height = area.size_h + (args [4] * 2) + args [13] + args [16];
+ }
+ }
+ return new Point (width, height);
+}
+
+void createHandle (int index) {
+ state |= HANDLE;
+ Display display = getDisplay ();
+ int parentHandle = parent.parentingHandle ();
+
+ 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_FILL_COLOR, display.WIDGET_BACKGROUND, 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 verticalAlign = (style & SWT.WRAP) != 0 ? OS.Pt_TOP : OS.Pt_CENTER;
+ boolean hasBorder = (style & SWT.BORDER) != 0;
+ int [] args = {
+ OS.Pt_ARG_FLAGS, hasBorder ? OS.Pt_HIGHLIGHTED : 0, OS.Pt_HIGHLIGHTED,
+ OS.Pt_ARG_HORIZONTAL_ALIGNMENT, alignment, 0,
+ OS.Pt_ARG_VERTICAL_ALIGNMENT, verticalAlign, 0,
+ OS.Pt_ARG_FILL_COLOR, display.WIDGET_BACKGROUND, 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);
+}
+
/**
* Returns a value which describes the position of the
* text or image in the receiver. The value will be one of
@@ -219,15 +219,15 @@ void createHandle (int index) {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public int getAlignment () {
- checkWidget();
- if ((style & SWT.SEPARATOR) != 0) return 0;
- if ((style & SWT.LEFT) != 0) return SWT.LEFT;
- if ((style & SWT.CENTER) != 0) return SWT.CENTER;
- if ((style & SWT.RIGHT) != 0) return SWT.RIGHT;
- return SWT.LEFT;
-}
-
+public int 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.
@@ -239,15 +239,15 @@ public int getAlignment () {
* <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 ();
-}
-
+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
@@ -260,36 +260,36 @@ String getNameText () {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public String getText () {
- checkWidget();
- if ((style & SWT.SEPARATOR) != 0) return "";
- return text;
-}
-
-int hotkeyProc (int widget, int data, int info) {
- 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 OS.Pt_CONTINUE;
- }
- control = control.parent;
- }
- return OS.Pt_CONTINUE;
-}
-
-void releaseWidget () {
- super.releaseWidget ();
- image = null;
- text = null;
-}
-
+public String getText () {
+ checkWidget();
+ if ((style & SWT.SEPARATOR) != 0) return "";
+ return text;
+}
+
+int hotkeyProc (int widget, int data, int info) {
+ 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 OS.Pt_CONTINUE;
+ }
+ control = control.parent;
+ }
+ return OS.Pt_CONTINUE;
+}
+
+void releaseWidget () {
+ super.releaseWidget ();
+ image = null;
+ text = null;
+}
+
/**
* Controls how text and images will be displayed in the receiver.
* The argument should be one of <code>LEFT</code>, <code>RIGHT</code>
@@ -303,34 +303,34 @@ void releaseWidget () {
* <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 align = OS.Pt_LEFT;
- if ((style & SWT.CENTER) != 0) align = OS.Pt_CENTER;
- if ((style & SWT.RIGHT) != 0) align = OS.Pt_RIGHT;
- OS.PtSetResource (handle, OS.Pt_ARG_HORIZONTAL_ALIGNMENT, align, 0);
-}
-
-int setBounds (int x, int y, int width, int height, boolean move, boolean resize, boolean events) {
- int result = super.setBounds (x, y, width, height, move, resize, events);
- if ((result & RESIZED) != 0 && (style & SWT.WRAP) != 0) setText (text);
- return result;
-}
-
-public boolean setFocus () {
- checkWidget();
- return false;
-}
-
-public void setFont (Font font) {
- super.setFont (font);
- if ((style & SWT.WRAP) != 0) setText (text);
-}
-
+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 align = OS.Pt_LEFT;
+ if ((style & SWT.CENTER) != 0) align = OS.Pt_CENTER;
+ if ((style & SWT.RIGHT) != 0) align = OS.Pt_RIGHT;
+ OS.PtSetResource (handle, OS.Pt_ARG_HORIZONTAL_ALIGNMENT, align, 0);
+}
+
+int setBounds (int x, int y, int width, int height, boolean move, boolean resize, boolean events) {
+ int result = super.setBounds (x, y, width, height, move, resize, events);
+ if ((result & RESIZED) != 0 && (style & SWT.WRAP) != 0) setText (text);
+ return result;
+}
+
+public boolean setFocus () {
+ checkWidget();
+ return false;
+}
+
+public void setFont (Font font) {
+ super.setFont (font);
+ if ((style & SWT.WRAP) != 0) setText (text);
+}
+
/**
* Sets the receiver's image to the argument, which may be
* null indicating that no image should be displayed.
@@ -345,23 +345,23 @@ public void setFont (Font font) {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public void setImage (Image image) {
- checkWidget();
- if ((style & SWT.SEPARATOR) != 0) return;
- this.image = image;
- int imageHandle = 0;
- if (image != null) {
- if (image.isDisposed()) error(SWT.ERROR_INVALID_ARGUMENT);
- 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 setImage (Image image) {
+ checkWidget();
+ if ((style & SWT.SEPARATOR) != 0) return;
+ this.image = image;
+ int imageHandle = 0;
+ if (image != null) {
+ if (image.isDisposed()) error(SWT.ERROR_INVALID_ARGUMENT);
+ 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);
+}
+
/**
* Sets the receiver's text.
* <p>
@@ -379,71 +379,71 @@ public void setImage (Image image) {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public void setText (String string) {
- checkWidget();
- if (string == null) error (SWT.ERROR_NULL_ARGUMENT);
- if ((style & SWT.SEPARATOR) != 0) return;
- text = string;
- char [] unicode = new char [string.length ()];
- string.getChars (0, unicode.length, unicode, 0);
- int i=0, j=0;
- char mnemonic=0;
- while (i < unicode.length) {
- if ((unicode [j++] = unicode [i++]) == Mnemonic) {
- if (i == unicode.length) {continue;}
- if (unicode [i] == Mnemonic) {i++; continue;}
- if (mnemonic == 0) mnemonic = unicode [i];
- j--;
- }
- }
- while (j < unicode.length) unicode [j++] = 0;
- /* Wrap the text if necessary, and convert to mbcs. */
- byte [] buffer;
- if ((style & SWT.WRAP) != 0) {
- int [] args = {
- OS.Pt_ARG_TEXT_FONT, 0, 0, // 1
- OS.Pt_ARG_WIDTH, 0, 0, // 4
- OS.Pt_ARG_MARGIN_WIDTH, 0, 0, // 7
- OS.Pt_ARG_MARGIN_LEFT, 0, 0, // 10
- OS.Pt_ARG_MARGIN_RIGHT, 0, 0, // 13
- };
- OS.PtGetResources (handle, args.length / 3, args);
- int length = OS.strlen (args [1]);
- byte [] font = new byte [length + 1];
- OS.memmove (font, args [1], length);
- int border = 0;
- if ((style & SWT.BORDER) != 0) border = 2;
- int width = args [4];
- width -= (args [7] * 2) + args [10] + args [13] + border * 2;
- Display display = getDisplay ();
- if (mnemonic != '\0') string = new String (unicode);
- string = display.wrapText (string, font, width);
- buffer = Converter.wcsToMbcs (null, string, true);
- } else {
- buffer = Converter.wcsToMbcs (null, unicode, 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);
- }
- replaceMnemonic (mnemonic, true, true);
- 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);
-}
-
-int widgetClass () {
- if ((style & SWT.SEPARATOR) != 0) return OS.PtSeparator ();
- return OS.PtLabel ();
-}
-
-}
+public void setText (String string) {
+ checkWidget();
+ if (string == null) error (SWT.ERROR_NULL_ARGUMENT);
+ if ((style & SWT.SEPARATOR) != 0) return;
+ text = string;
+ char [] unicode = new char [string.length ()];
+ string.getChars (0, unicode.length, unicode, 0);
+ int i=0, j=0;
+ char mnemonic=0;
+ while (i < unicode.length) {
+ if ((unicode [j++] = unicode [i++]) == Mnemonic) {
+ if (i == unicode.length) {continue;}
+ if (unicode [i] == Mnemonic) {i++; continue;}
+ if (mnemonic == 0) mnemonic = unicode [i];
+ j--;
+ }
+ }
+ while (j < unicode.length) unicode [j++] = 0;
+ /* Wrap the text if necessary, and convert to mbcs. */
+ byte [] buffer;
+ if ((style & SWT.WRAP) != 0) {
+ int [] args = {
+ OS.Pt_ARG_TEXT_FONT, 0, 0, // 1
+ OS.Pt_ARG_WIDTH, 0, 0, // 4
+ OS.Pt_ARG_MARGIN_WIDTH, 0, 0, // 7
+ OS.Pt_ARG_MARGIN_LEFT, 0, 0, // 10
+ OS.Pt_ARG_MARGIN_RIGHT, 0, 0, // 13
+ };
+ OS.PtGetResources (handle, args.length / 3, args);
+ int length = OS.strlen (args [1]);
+ byte [] font = new byte [length + 1];
+ OS.memmove (font, args [1], length);
+ int border = 0;
+ if ((style & SWT.BORDER) != 0) border = 2;
+ int width = args [4];
+ width -= (args [7] * 2) + args [10] + args [13] + border * 2;
+ Display display = getDisplay ();
+ if (mnemonic != '\0') string = new String (unicode);
+ string = display.wrapText (string, font, width);
+ buffer = Converter.wcsToMbcs (null, string, true);
+ } else {
+ buffer = Converter.wcsToMbcs (null, unicode, 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);
+ }
+ replaceMnemonic (mnemonic, true, true);
+ 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);
+}
+
+int widgetClass () {
+ if ((style & SWT.SEPARATOR) != 0) return OS.PtSeparator ();
+ return OS.PtLabel ();
+}
+
+}
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
index f0a4ad9438..a47e159cfe 100755
--- 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
@@ -1,18 +1,18 @@
-package org.eclipse.swt.widgets;
-
-/*
+package org.eclipse.swt.widgets;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-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.*;
-
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+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.*;
+
/**
* Instances of this class represent a selectable user interface
* object that displays a list of strings and issues notificiation
@@ -30,8 +30,8 @@ import org.eclipse.swt.events.*;
* IMPORTANT: This class is <em>not</em> intended to be subclassed.
* </p>
*/
-public class List extends Scrollable {
-
+public class List extends Scrollable {
+
/**
* Constructs a new instance of this class given its parent
* and a style value describing its behavior and appearance.
@@ -61,14 +61,14 @@ public class List extends Scrollable {
* @see Widget#checkSubclass
* @see Widget#getStyle
*/
-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 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);
+}
+
/**
* Adds the argument to the end of the receiver's list.
*
@@ -87,16 +87,16 @@ static int checkStyle (int style) {
*
* @see #add(String,int)
*/
-public void add (String string) {
- checkWidget();
- if (string == null) error (SWT.ERROR_NULL_ARGUMENT);
- byte [] buffer = Converter.wcsToMbcs (null, string, true);
- int 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) {
+ checkWidget();
+ 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);
+}
+
/**
* Adds the listener to the collection of listeners who will
* be notified when the receiver's selection changes, by sending
@@ -121,14 +121,14 @@ public void add (String string) {
* @see #removeSelectionListener
* @see SelectionEvent
*/
-public void addSelectionListener(SelectionListener listener) {
- checkWidget();
- if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
- TypedListener typedListener = new TypedListener (listener);
- addListener (SWT.Selection,typedListener);
- addListener (SWT.DefaultSelection,typedListener);
-}
-
+public 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 argument to the receiver's list at the given
* zero-relative index.
@@ -155,108 +155,108 @@ public void addSelectionListener(SelectionListener listener) {
*
* @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 (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) {
- checkWidget();
-
- int [] args = new int [] {
- OS.Pt_ARG_WIDTH, 0, 0,
- OS.Pt_ARG_HEIGHT, 0, 0,
- OS.Pt_ARG_LIST_ITEM_COUNT, 0, 0,
- };
- OS.PtGetResources (handle, args.length / 3, args);
- int resizeFlags = OS.Pt_RESIZE_X_ALWAYS | OS.Pt_RESIZE_Y_ALWAYS;
- OS.PtSetResource (handle, OS.Pt_ARG_RESIZE_FLAGS, resizeFlags, OS.Pt_RESIZE_XY_BITS);
- if (!OS.PtWidgetIsRealized (handle)) OS.PtExtentWidgetFamily (handle);
- PhDim_t dim = new PhDim_t ();
- OS.PtWidgetPreferredSize (handle, dim);
- int width = dim.w, height = dim.h;
- OS.PtSetResource (handle, OS.Pt_ARG_RESIZE_FLAGS, 0, OS.Pt_RESIZE_XY_BITS);
- OS.PtSetResources (handle, args.length / 3, args);
- if (args [7] <= 0) {
- width += DEFAULT_WIDTH;
- height += DEFAULT_HEIGHT;
- }
+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 (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) {
+ checkWidget();
+
+ int [] args = new int [] {
+ OS.Pt_ARG_WIDTH, 0, 0,
+ OS.Pt_ARG_HEIGHT, 0, 0,
+ OS.Pt_ARG_LIST_ITEM_COUNT, 0, 0,
+ };
+ OS.PtGetResources (handle, args.length / 3, args);
+ int resizeFlags = OS.Pt_RESIZE_X_ALWAYS | OS.Pt_RESIZE_Y_ALWAYS;
+ OS.PtSetResource (handle, OS.Pt_ARG_RESIZE_FLAGS, resizeFlags, OS.Pt_RESIZE_XY_BITS);
+ if (!OS.PtWidgetIsRealized (handle)) OS.PtExtentWidgetFamily (handle);
+ PhDim_t dim = new PhDim_t ();
+ OS.PtWidgetPreferredSize (handle, dim);
+ int width = dim.w, height = dim.h;
+ OS.PtSetResource (handle, OS.Pt_ARG_RESIZE_FLAGS, 0, OS.Pt_RESIZE_XY_BITS);
+ OS.PtSetResources (handle, args.length / 3, args);
+ if (args [7] <= 0) {
+ width += DEFAULT_WIDTH;
+ height += DEFAULT_HEIGHT;
+ }
- 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);
-}
-
-void createHandle (int index) {
- state |= HANDLE;
- Display display = getDisplay ();
- int clazz = display.PtList;
- int parentHandle = parent.parentingHandle ();
- 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;
- boolean hasBorder = (style & SWT.BORDER) != 0;
- int listFlags = OS.Pt_LIST_SCROLLBAR_ALWAYS | OS.Pt_LIST_SCROLLBAR_AS_REQUIRED;
- int [] args = {
- OS.Pt_ARG_FLAGS, hasBorder ? OS.Pt_HIGHLIGHTED : 0, OS.Pt_HIGHLIGHTED,
- 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_LIST_FLAGS, (style & SWT.V_SCROLL) != 0 ? OS.Pt_LIST_SCROLLBAR_AS_REQUIRED : 0, listFlags,
- 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);
- createStandardScrollBars ();
-}
-
-int defaultBackground () {
- Display display = getDisplay ();
- return display.LIST_BACKGROUND;
-}
-
-byte [] defaultFont () {
- Display display = getDisplay ();
- return display.LIST_FONT;
-}
-
-int defaultForeground () {
- Display display = getDisplay ();
- return display.LIST_FOREGROUND;
-}
-
+ 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);
+}
+
+void createHandle (int index) {
+ state |= HANDLE;
+ Display display = getDisplay ();
+ int clazz = display.PtList;
+ int parentHandle = parent.parentingHandle ();
+ 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;
+ boolean hasBorder = (style & SWT.BORDER) != 0;
+ int listFlags = OS.Pt_LIST_SCROLLBAR_ALWAYS | OS.Pt_LIST_SCROLLBAR_AS_REQUIRED;
+ int [] args = {
+ OS.Pt_ARG_FLAGS, hasBorder ? OS.Pt_HIGHLIGHTED : 0, OS.Pt_HIGHLIGHTED,
+ 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_LIST_FLAGS, (style & SWT.V_SCROLL) != 0 ? OS.Pt_LIST_SCROLLBAR_AS_REQUIRED : 0, listFlags,
+ 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);
+ createStandardScrollBars ();
+}
+
+int defaultBackground () {
+ Display display = getDisplay ();
+ return display.LIST_BACKGROUND;
+}
+
+byte [] defaultFont () {
+ Display display = getDisplay ();
+ return display.LIST_FONT;
+}
+
+int defaultForeground () {
+ Display display = getDisplay ();
+ return display.LIST_FOREGROUND;
+}
+
/**
* Deselects the item at the given zero-relative index in the receiver.
* If the item at the index was already deselected, it remains
@@ -269,12 +269,12 @@ int defaultForeground () {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public void deselect (int index) {
- checkWidget();
- if (index < 0) return;
- OS.PtListUnselectPos (handle, index + 1);
-}
-
+public void deselect (int index) {
+ checkWidget();
+ if (index < 0) return;
+ OS.PtListUnselectPos (handle, index + 1);
+}
+
/**
* Deselects the items at the given zero-relative indices in the receiver.
* If the item at the given zero-relative index in the receiver
@@ -290,22 +290,22 @@ public void deselect (int index) {
* <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 [] args = new int [] {OS.Pt_ARG_LIST_ITEM_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 start, int end) {
+ checkWidget();
+ if (start > end) return;
+ if ((style & SWT.SINGLE) != 0) {
+ int [] args = new int [] {OS.Pt_ARG_LIST_ITEM_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);
+ }
+}
+
/**
* Deselects the items at the given zero-relative indices in the receiver.
* If the item at the given zero-relative index in the receiver
@@ -323,18 +323,18 @@ public void deselect (int start, int end) {
* <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;
- for (int i=0; i<indices.length; i++) {
- int index = indices [i];
- if (index != -1) {
- OS.PtListUnselectPos (handle, index + 1);
- }
- }
-}
-
+public void deselect (int [] indices) {
+ checkWidget();
+ 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);
+ }
+ }
+}
+
/**
* Deselects all selected items in the receiver.
*
@@ -343,16 +343,16 @@ public void deselect (int [] indices) {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public void deselectAll () {
- checkWidget();
- 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 void deselectAll () {
+ checkWidget();
+ 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);
+ }
+}
+
/**
* 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.
@@ -364,10 +364,10 @@ public void deselectAll () {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public int getFocusIndex () {
- return getSelectionIndex ();
-}
-
+public int getFocusIndex () {
+ return getSelectionIndex ();
+}
+
/**
* Returns the item at the given, zero-relative index in the
* receiver. Throws an exception if the index is out of range.
@@ -386,25 +386,25 @@ public int getFocusIndex () {
* <li>ERROR_CANNOT_GET_ITEM - if the operation fails because of an operating system failure</li>
* </ul>
*/
-public String getItem (int index) {
- checkWidget();
- 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 String getItem (int index) {
+ checkWidget();
+ 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);
+}
+
/**
* Returns the number of items contained in the receiver.
*
@@ -418,13 +418,13 @@ public String getItem (int index) {
* <li>ERROR_CANNOT_GET_COUNT - if the operation fails because of an operating system failure</li>
* </ul>
*/
-public int getItemCount () {
- checkWidget();
- int [] args = new int [] {OS.Pt_ARG_LIST_ITEM_COUNT, 0, 0};
- OS.PtGetResources (handle, args.length / 3, args);
- return args [1];
-}
-
+public int getItemCount () {
+ checkWidget();
+ int [] args = new int [] {OS.Pt_ARG_LIST_ITEM_COUNT, 0, 0};
+ OS.PtGetResources (handle, args.length / 3, args);
+ return args [1];
+}
+
/**
* Returns the height of the area which would be used to
* display <em>one</em> of the items in the tree.
@@ -439,25 +439,25 @@ public int getItemCount () {
* <li>ERROR_CANNOT_GET_ITEM_HEIGHT - if the operation fails because of an operating system failure</li>
* </ul>
*/
-public int getItemHeight () {
- checkWidget();
- 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 int getItemHeight () {
+ checkWidget();
+ 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];
+}
+
/**
* Returns an array of <code>String</code>s which are the items
* in the receiver.
@@ -478,27 +478,27 @@ public int getItemHeight () {
* <li>ERROR_CANNOT_GET_COUNT - if the operation fails because of an operating system failure while getting the item count</li>
* </ul>
*/
-public String [] getItems () {
- checkWidget();
- 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 [] getItems () {
+ checkWidget();
+ 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;
+
+}
+
/**
* Returns an array of <code>String</code>s that are currently
* selected in the receiver. An empty array indicates that no
@@ -519,16 +519,16 @@ public String [] getItems () {
* <li>ERROR_CANNOT_GET_ITEM - if the operation fails because of an operating system failure while getting an item</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;
-}
-
+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.
*
@@ -542,13 +542,13 @@ public String [] getSelection () {
* <li>ERROR_CANNOT_GET_COUNT - if the operation fails because of an operating system failure</li>
* </ul>
*/
-public int getSelectionCount () {
- checkWidget();
- int [] args = new int [] {OS.Pt_ARG_LIST_SEL_COUNT, 0, 0};
- OS.PtGetResources (handle, args.length / 3, args);
- return args [1];
-}
-
+public int getSelectionCount () {
+ checkWidget();
+ int [] args = new int [] {OS.Pt_ARG_LIST_SEL_COUNT, 0, 0};
+ OS.PtGetResources (handle, args.length / 3, args);
+ return args [1];
+}
+
/**
* Returns the zero-relative index of the item which is currently
* selected in the receiver, or -1 if no item is selected.
@@ -563,19 +563,19 @@ public int getSelectionCount () {
* <li>ERROR_CANNOT_GET_SELECTION - if the operation fails because of an operating system failure</li>
* </ul>
*/
-public int getSelectionIndex () {
- checkWidget();
- 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 getSelectionIndex () {
+ checkWidget();
+ 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;
+}
+
/**
* Returns the zero-relative indices of the items which are currently
* selected in the receiver. The array is empty if no items are selected.
@@ -594,22 +594,22 @@ public int getSelectionIndex () {
* <li>ERROR_CANNOT_GET_SELECTION - if the operation fails because of an operating system failure</li>
* </ul>
*/
-public int [] getSelectionIndices () {
- checkWidget();
- 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 [] getSelectionIndices () {
+ checkWidget();
+ 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;
+}
+
/**
* Returns the zero-relative index of the item which is currently
* at the top of the receiver. This index can change when items are
@@ -622,20 +622,20 @@ public int [] getSelectionIndices () {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public int getTopIndex () {
- checkWidget();
- int [] args = new int [] {OS.Pt_ARG_TOP_ITEM_POS, 0, 0};
- OS.PtGetResources (handle, args.length / 3, args);
- return args [1] - 1;
-}
-
-void hookEvents () {
- super.hookEvents ();
- int windowProc = getDisplay ().windowProc;
- OS.PtAddCallback (handle, OS.Pt_CB_SELECTION, windowProc, OS.Pt_CB_SELECTION);
- OS.PtAddCallback (handle, OS.Pt_CB_ACTIVATE, windowProc, OS.Pt_CB_ACTIVATE);
-}
-
+public int getTopIndex () {
+ checkWidget();
+ int [] args = new int [] {OS.Pt_ARG_TOP_ITEM_POS, 0, 0};
+ OS.PtGetResources (handle, args.length / 3, args);
+ return args [1] - 1;
+}
+
+void hookEvents () {
+ super.hookEvents ();
+ int windowProc = getDisplay ().windowProc;
+ OS.PtAddCallback (handle, OS.Pt_CB_SELECTION, windowProc, OS.Pt_CB_SELECTION);
+ OS.PtAddCallback (handle, OS.Pt_CB_ACTIVATE, windowProc, OS.Pt_CB_ACTIVATE);
+}
+
/**
* Gets the index of an item.
* <p>
@@ -655,12 +655,12 @@ void hookEvents () {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public int indexOf (String string) {
- checkWidget();
- byte [] buffer = Converter.wcsToMbcs (null, string, true);
- return OS.PtListItemPos (handle, buffer) - 1;
-}
-
+public int indexOf (String string) {
+ checkWidget();
+ byte [] buffer = Converter.wcsToMbcs (null, string, true);
+ return OS.PtListItemPos (handle, buffer) - 1;
+}
+
/**
* Searches the receiver's list starting at the given,
* zero-relative index until an item is found that is equal
@@ -683,28 +683,28 @@ public int indexOf (String string) {
* <li>ERROR_CANNOT_GET_ITEM - if the operation fails because of an operating system failure while getting an item</li>
* </ul>
*/
-public int indexOf (String string, int start) {
- checkWidget();
- if (string == null) error (SWT.ERROR_NULL_ARGUMENT);
- if (start == 0) return indexOf(string);
- 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 count = args [1];
- if (!(0 <= start && start < count)) return -1;
- int [] item = new int [1];
- for (int index=start; index<count; index++) {
- OS.memmove (item, args [4] + (index * 4), 4);
- int length = OS.strlen (item [0]);
- byte [] buffer = new byte [length];
- OS.memmove (buffer, item [0], length);
- if (string.equals(new String (Converter.mbcsToWcs (null, buffer)))) return index;
- }
- return -1;
-}
-
+public int indexOf (String string, int start) {
+ checkWidget();
+ if (string == null) error (SWT.ERROR_NULL_ARGUMENT);
+ if (start == 0) return indexOf(string);
+ 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 count = args [1];
+ if (!(0 <= start && start < count)) return -1;
+ int [] item = new int [1];
+ for (int index=start; index<count; index++) {
+ OS.memmove (item, args [4] + (index * 4), 4);
+ int length = OS.strlen (item [0]);
+ byte [] buffer = new byte [length];
+ OS.memmove (buffer, item [0], length);
+ if (string.equals(new String (Converter.mbcsToWcs (null, buffer)))) return index;
+ }
+ return -1;
+}
+
/**
* Returns <code>true</code> if the item is selected,
* and <code>false</code> otherwise. Indices out of
@@ -718,37 +718,37 @@ public int indexOf (String string, int start) {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public boolean isSelected (int index) {
- checkWidget();
- 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 Pt_CB_ACTIVATE (int widget, 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 Pt_CB_SELECTION (int widget, int info) {
- postEvent (SWT.Selection);
- return OS.Pt_CONTINUE;
-}
-
+public boolean isSelected (int index) {
+ checkWidget();
+ 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 Pt_CB_ACTIVATE (int widget, 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 Pt_CB_SELECTION (int widget, int info) {
+ postEvent (SWT.Selection);
+ return OS.Pt_CONTINUE;
+}
+
/**
* Removes the item from the receiver at the given
* zero-relative index.
@@ -766,15 +766,15 @@ int Pt_CB_SELECTION (int widget, int info) {
* <li>ERROR_ITEM_NOT_REMOVED - if the operation fails because of an operating system failure</li>
* </ul>
*/
-public void remove (int index) {
- checkWidget();
- 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 (int index) {
+ checkWidget();
+ 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);
+}
+
/**
* Searches the receiver's list starting at the first item
* until an item is found that is equal to the argument,
@@ -794,13 +794,13 @@ public void remove (int index) {
* <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_ITEM_NOT_REMOVED);
- remove (index);
-}
-
+public void remove (String string) {
+ checkWidget();
+ int index = indexOf (string, 0);
+ if (index == -1) error (SWT.ERROR_ITEM_NOT_REMOVED);
+ remove (index);
+}
+
/**
* Removes the items from the receiver at the given
* zero-relative indices.
@@ -818,23 +818,23 @@ public void remove (String string) {
* <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 [] 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<newIndices.length; i++ ) {
- int index = newIndices [i];
- if (!(0 <= index && index < count)) 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 (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 [] 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<newIndices.length; i++ ) {
+ int index = newIndices [i];
+ if (!(0 <= index && index < count)) error (SWT.ERROR_INVALID_RANGE);
+ int result = OS.PtListDeleteItemPos (handle, 1, index + 1);
+ if (result != 0) error (SWT.ERROR_ITEM_NOT_REMOVED);
+ }
+}
+
/**
* Removes the items from the receiver which are
* between the given zero-relative start and end
@@ -854,18 +854,18 @@ public void remove (int [] indices) {
* <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 [] 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 start, int end) {
+ checkWidget();
+ 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);
+}
+
/**
* Removes all of the items from the receiver.
* <p>
@@ -874,11 +874,11 @@ public void remove (int start, int end) {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public void removeAll () {
- checkWidget();
- OS.PtListDeleteAllItems (handle);
-}
-
+public void removeAll () {
+ checkWidget();
+ OS.PtListDeleteAllItems (handle);
+}
+
/**
* Removes the listener from the collection of listeners who will
* be notified when the receiver's selection changes.
@@ -896,14 +896,14 @@ public void removeAll () {
* @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);
-}
-
+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 index was already selected, it remains
@@ -918,27 +918,27 @@ public void removeSelectionListener(SelectionListener listener) {
* <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;
- int [] args = new int [] {OS.Pt_ARG_LIST_ITEM_COUNT, 0, 0};
- OS.PtGetResources (handle, args.length / 3, args);
- int count = args [1];
- if ((style & SWT.SINGLE) != 0) {
- int index = Math.min (count - 1, end);
- if (index >= start) select (index);
- return;
- }
- int gotoIndex = -1;
- for (int index=end; index>=start; index--) {
- if (0 <= index && index < count) {
- gotoIndex = index;
- OS.PtListSelectPos (handle, index + 1);
- }
- }
- if (gotoIndex != -1) OS.PtListGotoPos (handle, gotoIndex + 1);
-}
-
+public void select (int start, int end) {
+ checkWidget();
+ if (start > end) return;
+ int [] args = new int [] {OS.Pt_ARG_LIST_ITEM_COUNT, 0, 0};
+ OS.PtGetResources (handle, args.length / 3, args);
+ int count = args [1];
+ if ((style & SWT.SINGLE) != 0) {
+ int index = Math.min (count - 1, end);
+ if (index >= start) select (index);
+ return;
+ }
+ int gotoIndex = -1;
+ for (int index=end; index>=start; index--) {
+ if (0 <= index && index < count) {
+ gotoIndex = index;
+ OS.PtListSelectPos (handle, index + 1);
+ }
+ }
+ if (gotoIndex != -1) OS.PtListGotoPos (handle, gotoIndex + 1);
+}
+
/**
* Selects the items at the given zero-relative indices in the receiver.
* If the item at the given zero-relative index in the receiver
@@ -956,24 +956,24 @@ public void select (int start, int end) {
* <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 (indices.length == 0) return;
- int [] args = new int [] {OS.Pt_ARG_LIST_ITEM_COUNT, 0, 0};
- OS.PtGetResources (handle, args.length / 3, args);
- int count = args [1];
- int gotoIndex = -1;
- for (int i=0; i<indices.length; i++) {
- int index = indices [i];
- if (0 <= index && index < count) {
- gotoIndex = index;
- OS.PtListSelectPos (handle, index + 1);
- }
- }
- if (gotoIndex != -1) OS.PtListGotoPos (handle, gotoIndex + 1);
-}
-
+public void select (int [] indices) {
+ checkWidget();
+ if (indices == null) error (SWT.ERROR_NULL_ARGUMENT);
+ if (indices.length == 0) return;
+ int [] args = new int [] {OS.Pt_ARG_LIST_ITEM_COUNT, 0, 0};
+ OS.PtGetResources (handle, args.length / 3, args);
+ int count = args [1];
+ int gotoIndex = -1;
+ for (int i=0; i<indices.length; i++) {
+ int index = indices [i];
+ if (0 <= index && index < count) {
+ gotoIndex = index;
+ OS.PtListSelectPos (handle, index + 1);
+ }
+ }
+ if (gotoIndex != -1) OS.PtListGotoPos (handle, gotoIndex + 1);
+}
+
/**
* 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
@@ -986,17 +986,17 @@ public void select (int [] indices) {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public void select (int index) {
- checkWidget();
- if (index < 0) return;
- int [] args = new int [] {OS.Pt_ARG_LIST_ITEM_COUNT, 0, 0};
- OS.PtGetResources (handle, args.length / 3, args);
- if (index < args [1]) {
- OS.PtListSelectPos (handle, index + 1);
- OS.PtListGotoPos (handle, index + 1);
- }
-}
-
+public void select (int index) {
+ checkWidget();
+ if (index < 0) return;
+ int [] args = new int [] {OS.Pt_ARG_LIST_ITEM_COUNT, 0, 0};
+ OS.PtGetResources (handle, args.length / 3, args);
+ if (index < args [1]) {
+ OS.PtListSelectPos (handle, index + 1);
+ OS.PtListGotoPos (handle, index + 1);
+ }
+}
+
/**
* Selects all the items in the receiver.
*
@@ -1005,17 +1005,17 @@ public void select (int index) {
* <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 [] 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.PtListSelectPos (handle, i + 1);
- }
-}
-
+public void selectAll () {
+ checkWidget();
+ if ((style & SWT.SINGLE) != 0) return;
+ 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.PtListSelectPos (handle, i + 1);
+ }
+}
+
/**
* Sets the text of the item in the receiver's list at the given
* zero-relative index to the string argument. This is equivalent
@@ -1037,21 +1037,21 @@ public void selectAll () {
* <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 [] 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 setItem (int index, String string) {
+ checkWidget();
+ 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);
+}
+
/**
* Sets the receiver's items to be the given array of items.
*
@@ -1065,23 +1065,23 @@ public void setItem (int index, String string) {
* <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.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 setItems (String [] items) {
+ checkWidget();
+ 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]);
+ }
+}
+
/**
* Selects the items at the given zero-relative indices in the receiver.
* The current selected if first cleared, then the new items are selected.
@@ -1097,11 +1097,11 @@ public void setItems (String [] items) {
* @see Table#deselectAll()
* @see Table#select(int,int)
*/
-public void setSelection (int start, int end) {
- if ((style & SWT.MULTI) != 0) deselectAll ();
- select (start, end);
-}
-
+public void setSelection (int start, int end) {
+ if ((style & SWT.MULTI) != 0) deselectAll ();
+ select (start, end);
+}
+
/**
* Selects the item at the given zero-relative index in the receiver.
* If the item at the index was already selected, it remains selected.
@@ -1117,11 +1117,11 @@ public void setSelection (int start, int end) {
* @see List#deselectAll()
* @see List#select(int)
*/
-public void setSelection (int index) {
- if ((style & SWT.MULTI) != 0) deselectAll ();
- select (index);
-}
-
+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 selection is first cleared, then the new items are selected.
@@ -1139,11 +1139,11 @@ public void setSelection (int index) {
* @see List#deselectAll()
* @see List#select(int[])
*/
-public void setSelection(int[] indices) {
- deselectAll ();
- select (indices);
-}
-
+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
@@ -1162,24 +1162,24 @@ public void setSelection(int[] indices) {
* @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 ();
-}
-
+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 ();
+}
+
/**
* Sets the zero-relative index of the item which is currently
* at the top of the receiver. This index can change when items
@@ -1192,11 +1192,11 @@ public void setSelection (String [] items) {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public void setTopIndex (int index) {
- checkWidget();
- OS.PtSetResource (handle, OS.Pt_ARG_TOP_ITEM_POS, index + 1, 0);
-}
-
+public void setTopIndex (int index) {
+ checkWidget();
+ OS.PtSetResource (handle, OS.Pt_ARG_TOP_ITEM_POS, index + 1, 0);
+}
+
/**
* Shows the selection. If the selection is already showing in the receiver,
* this method simply returns. Otherwise, the items are scrolled until
@@ -1210,30 +1210,30 @@ public void setTopIndex (int index) {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public void showSelection () {
- checkWidget();
- 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);
- OS.PtSetResource (handle, OS.Pt_ARG_TOP_ITEM_POS, newTop, 0);
-}
-
-int widgetClass () {
- return OS.PtList ();
-}
-
-}
+public void showSelection () {
+ checkWidget();
+ 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);
+ OS.PtSetResource (handle, OS.Pt_ARG_TOP_ITEM_POS, newTop, 0);
+}
+
+int widgetClass () {
+ return OS.PtList ();
+}
+
+}
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
index 9cb2a5ed01..64d93e7739 100755
--- 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
@@ -1,17 +1,17 @@
-package org.eclipse.swt.widgets;
-
-/*
+package org.eclipse.swt.widgets;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-import org.eclipse.swt.internal.photon.*;
-import org.eclipse.swt.*;
-import org.eclipse.swt.events.*;
-import org.eclipse.swt.graphics.*;
-
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+import org.eclipse.swt.internal.photon.*;
+import org.eclipse.swt.*;
+import org.eclipse.swt.events.*;
+import org.eclipse.swt.graphics.*;
+
/**
* Instances of this class are user interface objects that contain
* menu items.
@@ -27,12 +27,12 @@ import org.eclipse.swt.graphics.*;
* IMPORTANT: This class is <em>not</em> intended to be subclassed.
* </p>
*/
-public class Menu extends Widget {
- int x, y;
- boolean hasLocation;
- Decorations parent;
- MenuItem cascade, defaultItem;
-
+public class Menu extends Widget {
+ int x, y;
+ boolean hasLocation;
+ Decorations parent;
+ MenuItem cascade, defaultItem;
+
/**
* Constructs a new instance of this class given its parent,
* and sets the style for the instance so that the instance
@@ -52,10 +52,10 @@ public class Menu extends Widget {
* @see Widget#checkSubclass
* @see Widget#getStyle
*/
-public Menu (Control parent) {
- this (checkNull (parent).getShell (), SWT.POP_UP);
-}
-
+public Menu (Control parent) {
+ this (checkNull (parent).getShell (), SWT.POP_UP);
+}
+
/**
* Constructs a new instance of this class given its parent
* (which must be a <code>Decorations</code>) and a style value
@@ -87,12 +87,12 @@ public Menu (Control parent) {
* @see Widget#checkSubclass
* @see Widget#getStyle
*/
-public Menu (Decorations parent, int style) {
- super (parent, checkStyle (style));
- this.parent = parent;
- createWidget (0);
-}
-
+public Menu (Decorations parent, int style) {
+ super (parent, checkStyle (style));
+ this.parent = parent;
+ createWidget (0);
+}
+
/**
* Constructs a new instance of this class given its parent
* (which must be a <code>Menu</code>) and sets the style
@@ -113,10 +113,10 @@ public Menu (Decorations parent, int style) {
* @see Widget#checkSubclass
* @see Widget#getStyle
*/
-public Menu (Menu parentMenu) {
- this (checkNull (parentMenu).parent, SWT.DROP_DOWN);
-}
-
+public Menu (Menu parentMenu) {
+ this (checkNull (parentMenu).parent, SWT.DROP_DOWN);
+}
+
/**
* Constructs a new instance of this class given its parent
* (which must be a <code>MenuItem</code>) and sets the style
@@ -137,29 +137,29 @@ public Menu (Menu parentMenu) {
* @see Widget#checkSubclass
* @see Widget#getStyle
*/
-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 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);
+}
+
/**
* Adds the listener to the collection of listeners who will
* be notified when help events are generated for the control,
@@ -179,13 +179,13 @@ static int checkStyle (int style) {
* @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);
-}
-
+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 menus are hidden or shown, by sending it
@@ -205,35 +205,35 @@ public void addHelpListener (HelpListener listener) {
* @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);
-}
-
-void createHandle (int index) {
- state |= HANDLE;
- 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) {
- checkOrientation (parent);
- super.createWidget (index);
- parent.add (this);
-}
-
+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);
+}
+
+void createHandle (int index) {
+ state |= HANDLE;
+ 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) {
+ checkOrientation (parent);
+ super.createWidget (index);
+ parent.add (this);
+}
+
/**
* Returns the default menu item or null if none has
* been previously set.
@@ -246,17 +246,17 @@ void createWidget (int index) {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public MenuItem getDefaultItem () {
- checkWidget();
- return defaultItem;
-}
-
-public Display getDisplay () {
- Decorations parent = this.parent;
- if (parent == null) error (SWT.ERROR_WIDGET_DISPOSED);
- return parent.getDisplay ();
-}
-
+public MenuItem getDefaultItem () {
+ checkWidget();
+ return defaultItem;
+}
+
+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
@@ -270,12 +270,12 @@ public Display getDisplay () {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public boolean getEnabled () {
- checkWidget ();
- int topHandle = topHandle ();
- return (OS.PtWidgetFlags (topHandle) & OS.Pt_BLOCKED) == 0;
-}
-
+public boolean getEnabled () {
+ checkWidget ();
+ int topHandle = topHandle ();
+ return (OS.PtWidgetFlags (topHandle) & OS.Pt_BLOCKED) == 0;
+}
+
/**
* Returns the number of items contained in the receiver.
*
@@ -286,18 +286,18 @@ public boolean getEnabled () {
* <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 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 int getItemCount () {
+ checkWidget();
+ 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;
+}
+
/**
* Returns the item at the given, zero-relative index in the
* receiver. Throws an exception if the index is out of range.
@@ -313,23 +313,23 @@ public int getItemCount () {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public MenuItem getItem (int index) {
- checkWidget();
- if (index < 0) error (SWT.ERROR_INVALID_RANGE);
- int i = 0;
- int child = OS.PtWidgetChildBack (handle);
- if (child != 0 && (style & SWT.BAR) != 0) child = OS.PtWidgetChildBack (child);
- while (child != 0) {
- Widget widget = WidgetTable.get (child);
- if (widget != null && widget instanceof MenuItem) {
- if (i++ == index) return (MenuItem) widget;
- }
- child = OS.PtWidgetBrotherInFront (child);
- }
- error (SWT.ERROR_INVALID_RANGE);
- return null;
-}
-
+public MenuItem getItem (int index) {
+ checkWidget();
+ if (index < 0) error (SWT.ERROR_INVALID_RANGE);
+ int i = 0;
+ int child = OS.PtWidgetChildBack (handle);
+ if (child != 0 && (style & SWT.BAR) != 0) child = OS.PtWidgetChildBack (child);
+ while (child != 0) {
+ Widget widget = WidgetTable.get (child);
+ if (widget != null && widget instanceof MenuItem) {
+ if (i++ == index) return (MenuItem) widget;
+ }
+ child = OS.PtWidgetBrotherInFront (child);
+ }
+ error (SWT.ERROR_INVALID_RANGE);
+ return null;
+}
+
/**
* Returns an array of <code>MenuItem</code>s which are the items
* in the receiver.
@@ -346,46 +346,46 @@ public MenuItem getItem (int index) {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public MenuItem [] getItems () {
- checkWidget();
- 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 MenuItem [] getItems () {
+ checkWidget();
+ 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;
+}
+
/**
* Returns the receiver's parent, which must be a <code>Decorations</code>.
*
@@ -396,11 +396,11 @@ String getNameText () {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public Decorations getParent () {
- checkWidget();
- return parent;
-}
-
+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
@@ -413,11 +413,11 @@ public Decorations getParent () {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public MenuItem getParentItem () {
- checkWidget();
- return cascade;
-}
-
+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
@@ -430,12 +430,12 @@ public MenuItem getParentItem () {
* <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;
-}
-
+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
@@ -451,11 +451,11 @@ public Menu getParentMenu () {
*
* @see #getParent
*/
-public Shell getShell () {
- checkWidget();
- return parent.getShell ();
-}
-
+public Shell getShell () {
+ checkWidget();
+ return parent.getShell ();
+}
+
/**
* Returns <code>true</code> if the receiver is visible, and
* <code>false</code> otherwise.
@@ -473,17 +473,17 @@ public Shell getShell () {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public boolean getVisible () {
- checkWidget();
- return OS.PtWidgetIsRealized (handle);
-}
-
-void hookEvents () {
- int windowProc = getDisplay ().windowProc;
- OS.PtAddCallback (handle, OS.Pt_CB_REALIZED, windowProc, OS.Pt_CB_REALIZED);
- OS.PtAddCallback (handle, OS.Pt_CB_UNREALIZED, windowProc, OS.Pt_CB_UNREALIZED);
-}
-
+public boolean getVisible () {
+ checkWidget();
+ return OS.PtWidgetIsRealized (handle);
+}
+
+void hookEvents () {
+ int windowProc = getDisplay ().windowProc;
+ OS.PtAddCallback (handle, OS.Pt_CB_REALIZED, windowProc, OS.Pt_CB_REALIZED);
+ OS.PtAddCallback (handle, OS.Pt_CB_UNREALIZED, windowProc, OS.Pt_CB_UNREALIZED);
+}
+
/**
* Searches the receiver's list starting at the first item
* (index 0) until an item is found that is equal to the
@@ -501,112 +501,112 @@ void hookEvents () {
* <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 i = 0;
- int child = OS.PtWidgetChildBack (handle);
- if (child != 0 && (style & SWT.BAR) != 0) child = OS.PtWidgetChildBack (child);
- while (child != 0) {
- Widget widget = WidgetTable.get (child);
- if (item == widget) return i;
- if (widget != null && widget instanceof MenuItem) i++;
- child = OS.PtWidgetBrotherInFront (child);
- }
- return -1;
-}
-
-/**
- * Returns <code>true</code> if the receiver is enabled and all
- * of the receiver's ancestors are enabled, and <code>false</code>
- * otherwise. A disabled control is typically not selectable from the
- * user interface and draws with an inactive or "grayed" look.
- *
- * @return the receiver's enabled state
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see #getEnabled
+public int indexOf (MenuItem item) {
+ checkWidget();
+ if (item == null) error (SWT.ERROR_NULL_ARGUMENT);
+ int i = 0;
+ int child = OS.PtWidgetChildBack (handle);
+ if (child != 0 && (style & SWT.BAR) != 0) child = OS.PtWidgetChildBack (child);
+ while (child != 0) {
+ Widget widget = WidgetTable.get (child);
+ if (item == widget) return i;
+ if (widget != null && widget instanceof MenuItem) i++;
+ child = OS.PtWidgetBrotherInFront (child);
+ }
+ return -1;
+}
+
+/**
+ * Returns <code>true</code> if the receiver is enabled and all
+ * of the receiver's ancestors are enabled, and <code>false</code>
+ * otherwise. A disabled control is typically not selectable from the
+ * user interface and draws with an inactive or "grayed" look.
+ *
+ * @return the receiver's enabled state
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see #getEnabled
*/
-public boolean isEnabled () {
- checkWidget();
- Menu parentMenu = getParentMenu ();
- if (parentMenu == null) return getEnabled ();
- return getEnabled () && parentMenu.isEnabled ();
-}
-
-/**
- * Returns <code>true</code> if the receiver is visible and all
- * of the receiver's ancestors are visible and <code>false</code>
- * otherwise.
- *
- * @return the receiver's visibility state
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see #getVisible
+public boolean isEnabled () {
+ checkWidget();
+ Menu parentMenu = getParentMenu ();
+ if (parentMenu == null) return getEnabled ();
+ return getEnabled () && parentMenu.isEnabled ();
+}
+
+/**
+ * Returns <code>true</code> if the receiver is visible and all
+ * of the receiver's ancestors are visible and <code>false</code>
+ * otherwise.
+ *
+ * @return the receiver's visibility state
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see #getVisible
*/
-public boolean isVisible () {
- checkWidget();
- return getVisible ();
-}
-
-int Pt_CB_REALIZED (int widget, int info) {
- if ((style & SWT.BAR) == 0) {
- Shell shell = getShell ();
- shell.activeMenu = this;
- }
- return OS.Pt_CONTINUE;
-}
-
-int Pt_CB_UNREALIZED (int widget, int info) {
- if (cascade != null) {
- OS.PtSetResource (handle, OS.Pt_ARG_MENU_FLAGS, 0, OS.Pt_MENU_CHILD);
- int shellHandle = parent.topHandle ();
- OS.PtReParentWidget (handle, shellHandle);
- }
- sendEvent (SWT.Hide);
- Shell shell = getShell ();
- if (shell.activeMenu == this) {
- shell.activeMenu = null;
- if (cascade != null) {
- Menu parent = cascade.parent;
- if (parent != null && (parent.style & SWT.BAR) == 0) {
- if (OS.PtWidgetIsRealized (parent.handle)) {
- shell.activeMenu = parent;
- }
- }
- }
- }
- 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.releaseResources ();
- }
- super.releaseWidget ();
- if (parent != null) parent.remove (this);
- parent = null;
- cascade = null;
-}
-
+public boolean isVisible () {
+ checkWidget();
+ return getVisible ();
+}
+
+int Pt_CB_REALIZED (int widget, int info) {
+ if ((style & SWT.BAR) == 0) {
+ Shell shell = getShell ();
+ shell.activeMenu = this;
+ }
+ return OS.Pt_CONTINUE;
+}
+
+int Pt_CB_UNREALIZED (int widget, int info) {
+ if (cascade != null) {
+ OS.PtSetResource (handle, OS.Pt_ARG_MENU_FLAGS, 0, OS.Pt_MENU_CHILD);
+ int shellHandle = parent.topHandle ();
+ OS.PtReParentWidget (handle, shellHandle);
+ }
+ sendEvent (SWT.Hide);
+ Shell shell = getShell ();
+ if (shell.activeMenu == this) {
+ shell.activeMenu = null;
+ if (cascade != null) {
+ Menu parent = cascade.parent;
+ if (parent != null && (parent.style & SWT.BAR) == 0) {
+ if (OS.PtWidgetIsRealized (parent.handle)) {
+ shell.activeMenu = parent;
+ }
+ }
+ }
+ }
+ 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.releaseResources ();
+ }
+ 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.
@@ -624,13 +624,13 @@ void releaseWidget () {
* @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);
-}
-
+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.
@@ -648,14 +648,14 @@ public void removeHelpListener (HelpListener listener) {
* @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);
-}
-
+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>.
@@ -670,12 +670,12 @@ public void removeMenuListener (MenuListener listener) {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public void setDefaultItem (MenuItem item) {
- checkWidget();
- if (item != null && item.isDisposed()) error(SWT.ERROR_INVALID_ARGUMENT);
- defaultItem = item;
-}
-
+public void setDefaultItem (MenuItem item) {
+ checkWidget();
+ if (item != null && item.isDisposed()) error(SWT.ERROR_INVALID_ARGUMENT);
+ defaultItem = item;
+}
+
/**
* Enables the receiver if the argument is <code>true</code>,
* and disables it otherwise. A disabled control is typically
@@ -689,13 +689,13 @@ public void setDefaultItem (MenuItem item) {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public void setEnabled (boolean enabled) {
- checkWidget ();
- int topHandle = topHandle ();
- int flags = enabled ? 0 : OS.Pt_BLOCKED | OS.Pt_GHOST;
- OS.PtSetResource (topHandle, OS.Pt_ARG_FLAGS, flags, OS.Pt_BLOCKED | OS.Pt_GHOST);
-}
-
+public void setEnabled (boolean enabled) {
+ checkWidget ();
+ int topHandle = topHandle ();
+ int flags = enabled ? 0 : OS.Pt_BLOCKED | OS.Pt_GHOST;
+ OS.PtSetResource (topHandle, OS.Pt_ARG_FLAGS, flags, OS.Pt_BLOCKED | OS.Pt_GHOST);
+}
+
/**
* Sets the receiver's location to the point specified by
* the arguments which are relative to the display.
@@ -712,19 +712,19 @@ public void setEnabled (boolean enabled) {
* <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;
-}
-
-public void setLocation (Point location) {
- checkWidget();
- if (location == null) error (SWT.ERROR_NULL_ARGUMENT);
- setLocation (location.x, location.y);
-}
-
+public void setLocation (int x, int y) {
+ checkWidget();
+ this.x = x;
+ this.y = y;
+ hasLocation = true;
+}
+
+public void setLocation (Point location) {
+ checkWidget();
+ if (location == null) error (SWT.ERROR_NULL_ARGUMENT);
+ setLocation (location.x, location.y);
+}
+
/**
* Marks the receiver as visible if the argument is <code>true</code>,
* and marks it invisible otherwise.
@@ -741,34 +741,34 @@ public void setLocation (Point location) {
* <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.POP_UP) == 0) return;
- if (visible == OS.PtWidgetIsRealized (handle)) return;
- if (visible) {
- sendEvent (SWT.Show);
- if (getItemCount () != 0) {
- 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);
- OS.PtSetResource (handle, OS.Pt_ARG_POS, ptr, 0);
- OS.free (ptr);
- OS.PtRealizeWidget (handle);
- } else {
- sendEvent (SWT.Hide);
- }
- } else {
- OS.PtUnrealizeWidget(handle);
- }
-}
-
-}
+public void setVisible (boolean visible) {
+ checkWidget();
+ if ((style & SWT.POP_UP) == 0) return;
+ if (visible == OS.PtWidgetIsRealized (handle)) return;
+ if (visible) {
+ sendEvent (SWT.Show);
+ if (getItemCount () != 0) {
+ 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);
+ OS.PtSetResource (handle, OS.Pt_ARG_POS, ptr, 0);
+ OS.free (ptr);
+ OS.PtRealizeWidget (handle);
+ } else {
+ sendEvent (SWT.Hide);
+ }
+ } else {
+ OS.PtUnrealizeWidget(handle);
+ }
+}
+
+}
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
index b7dbf19f85..51b27d12c5 100755
--- 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
@@ -1,18 +1,18 @@
-package org.eclipse.swt.widgets;
-
-/*
+package org.eclipse.swt.widgets;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-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.*;
-
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+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.*;
+
/**
* Instances of this class represent a selectable user interface object
* that issues notification when pressed and released.
@@ -29,10 +29,10 @@ import org.eclipse.swt.events.*;
* IMPORTANT: This class is <em>not</em> intended to be subclassed.
* </p>
*/
-public class MenuItem extends Item {
- Menu parent, menu;
- int accelerator;
-
+public class MenuItem extends Item {
+ Menu parent, menu;
+ int accelerator;
+
/**
* Constructs a new instance of this class given its parent
* (which must be a <code>Menu</code>) and a style value
@@ -67,10 +67,10 @@ public class MenuItem extends Item {
* @see Widget#checkSubclass
* @see Widget#getStyle
*/
-public MenuItem (Menu parent, int style) {
- this (parent, style, parent.getItemCount());
-}
-
+public MenuItem (Menu parent, int style) {
+ this (parent, style, parent.getItemCount());
+}
+
/**
* Constructs a new instance of this class given its parent
* (which must be a <code>Menu</code>), a style value
@@ -106,27 +106,27 @@ public MenuItem (Menu parent, int style) {
* @see Widget#checkSubclass
* @see Widget#getStyle
*/
-public MenuItem (Menu parent, int style, int index) {
- super (parent, checkStyle (style));
- this.parent = parent;
- createWidget (index);
-}
-
-void addAccelerator () {
- if (accelerator == 0) return;
- 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));
- Display display = getDisplay ();
- int keyCode = Display.untranslateKey (key);
- if (keyCode != 0) key = keyCode;
- else key = Character.toLowerCase ((char)key);
- Shell shell = parent.getShell ();
- OS.PtAddHotkeyHandler(shell.shellHandle, key, keyMods, (short)0, handle, display.hotkeyProc);
-}
-
+public MenuItem (Menu parent, int style, int index) {
+ super (parent, checkStyle (style));
+ this.parent = parent;
+ createWidget (index);
+}
+
+void addAccelerator () {
+ if (accelerator == 0) return;
+ 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));
+ Display display = getDisplay ();
+ int keyCode = Display.untranslateKey (key);
+ if (keyCode != 0) key = keyCode;
+ else key = Character.toLowerCase ((char)key);
+ Shell shell = parent.getShell ();
+ OS.PtAddHotkeyHandler(shell.shellHandle, key, keyMods, (short)0, handle, display.hotkeyProc);
+}
+
/**
* Adds the listener to the collection of listeners who will
* be notified when the arm events are generated for the control, by sending
@@ -146,13 +146,13 @@ void addAccelerator () {
* @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);
-}
-
+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
@@ -172,13 +172,13 @@ public void addArmListener (ArmListener listener) {
* @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);
-}
-
+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
@@ -203,58 +203,58 @@ public void addHelpListener (HelpListener listener) {
* @see #removeSelectionListener
* @see SelectionEvent
*/
-public void addSelectionListener (SelectionListener listener) {
- checkWidget();
- if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
- TypedListener typedListener = new TypedListener(listener);
- addListener (SWT.Selection,typedListener);
- addListener (SWT.DefaultSelection,typedListener);
-}
-
-protected void checkSubclass () {
- if (!isValidSubclass ()) error (SWT.ERROR_INVALID_SUBCLASS);
-}
-
-static int checkStyle (int style) {
- return checkBits (style, SWT.PUSH, SWT.CHECK, SWT.RADIO, SWT.SEPARATOR, SWT.CASCADE, 0);
-}
-
-void createHandle (int index) {
- state |= HANDLE;
- 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_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 ());
- }
-}
-
+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 createHandle (int index) {
+ state |= HANDLE;
+ 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_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 ());
+ }
+}
+
/**
* Return the widget accelerator. An accelerator is the bit-wise
* OR of zero or more modifier masks and a key. Examples:
@@ -268,17 +268,17 @@ void createHandle (int index) {
* <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 ();
-}
-
+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
@@ -292,19 +292,19 @@ public Display getDisplay () {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public boolean getEnabled () {
- checkWidget ();
- /*
- * Bug in Photon. The Pt_BLOCKED flag of a menu item is cleared
- * when its parent menu is realized. The fix is to remember
- * the menu item state and reset it when the menu item is
- * realized.
- */
-// int topHandle = topHandle ();
-// return (OS.PtWidgetFlags (topHandle) & OS.Pt_BLOCKED) == 0;
- return (state & DISABLED) == 0;
-}
-
+public boolean getEnabled () {
+ checkWidget ();
+ /*
+ * Bug in Photon. The Pt_BLOCKED flag of a menu item is cleared
+ * when its parent menu is realized. The fix is to remember
+ * the menu item state and reset it when the menu item is
+ * realized.
+ */
+// int topHandle = topHandle ();
+// return (OS.PtWidgetFlags (topHandle) & OS.Pt_BLOCKED) == 0;
+ return (state & DISABLED) == 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
@@ -319,16 +319,16 @@ public boolean getEnabled () {
* <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 ();
-}
-
+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>.
*
@@ -339,11 +339,11 @@ String getNameText () {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public Menu getParent () {
- checkWidget();
- return parent;
-}
-
+public Menu getParent () {
+ checkWidget();
+ return parent;
+}
+
/**
* Returns <code>true</code> if the receiver is selected,
* and false otherwise.
@@ -358,120 +358,120 @@ public Menu getParent () {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public boolean getSelection () {
- checkWidget();
- if ((style & (SWT.CHECK | SWT.RADIO | SWT.TOGGLE)) == 0) return false;
- return (OS.PtWidgetFlags (handle) & 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, OS.Pt_CB_ARM);
- }
- OS.PtAddCallback (handle, OS.Pt_CB_ACTIVATE, windowProc, OS.Pt_CB_ACTIVATE);
- if ((parent.style & SWT.BAR) == 0) {
- OS.PtAddCallback (handle, OS.Pt_CB_REALIZED, windowProc, OS.Pt_CB_REALIZED);
- }
-}
-
-int hotkeyProc (int widget, int data, int info) {
- showMenu ();
- return OS.Pt_CONTINUE;
-}
-
-/**
- * Returns <code>true</code> if the receiver is enabled and all
- * of the receiver's ancestors are enabled, and <code>false</code>
- * otherwise. A disabled control is typically not selectable from the
- * user interface and draws with an inactive or "grayed" look.
- *
- * @return the receiver's enabled state
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see #getEnabled
+public boolean getSelection () {
+ checkWidget();
+ if ((style & (SWT.CHECK | SWT.RADIO | SWT.TOGGLE)) == 0) return false;
+ return (OS.PtWidgetFlags (handle) & 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, OS.Pt_CB_ARM);
+ }
+ OS.PtAddCallback (handle, OS.Pt_CB_ACTIVATE, windowProc, OS.Pt_CB_ACTIVATE);
+ if ((parent.style & SWT.BAR) == 0) {
+ OS.PtAddCallback (handle, OS.Pt_CB_REALIZED, windowProc, OS.Pt_CB_REALIZED);
+ }
+}
+
+int hotkeyProc (int widget, int data, int info) {
+ showMenu ();
+ return OS.Pt_CONTINUE;
+}
+
+/**
+ * Returns <code>true</code> if the receiver is enabled and all
+ * of the receiver's ancestors are enabled, and <code>false</code>
+ * otherwise. A disabled control is typically not selectable from the
+ * user interface and draws with an inactive or "grayed" look.
+ *
+ * @return the receiver's enabled state
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see #getEnabled
*/
-public boolean isEnabled () {
- return getEnabled () && parent.isEnabled ();
-}
-
-int Pt_CB_ACTIVATE (int widget, int info) {
- if ((style & SWT.CASCADE) != 0 && menu != null) {
- return OS.Pt_CONTINUE;
- }
- Event event = new Event ();
- if (info != 0) {
- PtCallbackInfo_t cbinfo = new PtCallbackInfo_t ();
- OS.memmove (cbinfo, info, PtCallbackInfo_t.sizeof);
- if (cbinfo.event != 0) {
- PhEvent_t ev = new PhEvent_t ();
- OS.memmove (ev, cbinfo.event, PhEvent_t.sizeof);
- int data = OS.PhGetData (cbinfo.event);
- if (data != 0) {
- switch (ev.type) {
- case OS.Ph_EV_KEY:
- PhKeyEvent_t ke = new PhKeyEvent_t ();
- OS.memmove (ke, data, PhKeyEvent_t.sizeof);
- setKeyState (event, ke);
- break;
- case OS.Ph_EV_BUT_PRESS:
- case OS.Ph_EV_BUT_RELEASE:
- PhPointerEvent_t pe = new PhPointerEvent_t ();
- OS.memmove (pe, data, PhPointerEvent_t.sizeof);
- setMouseState (event, pe, ev);
- break;
- }
- }
- }
- }
- if ((style & SWT.RADIO) != 0) {
- if ((parent.getStyle () & SWT.NO_RADIO_GROUP) == 0) {
- selectRadio ();
- }
- }
- postEvent (SWT.Selection, event);
- return OS.Pt_CONTINUE;
-}
-
-int Pt_CB_ARM (int widget, int info) {
- postEvent (SWT.Arm);
- showMenu ();
- return OS.Pt_CONTINUE;
-}
-
-int Pt_CB_REALIZED (int widget, int info) {
- /*
- * Bug in Photon. The Pt_BLOCKED flag of a menu item is cleared
- * when its parent menu is realized. The fix is to remember
- * the menu item state and reset it when the menu item is
- * realized.
- */
- int topHandle = topHandle ();
- int flags = (state & DISABLED) != 0 ? OS.Pt_BLOCKED | OS.Pt_GHOST : 0;
- OS.PtSetResource (handle, OS.Pt_ARG_FLAGS, flags, OS.Pt_BLOCKED | OS.Pt_GHOST);
- return OS.Pt_CONTINUE;
-}
-
-void releaseChild () {
- super.releaseChild ();
- if (menu != null) menu.dispose ();
- menu = null;
-}
-
-void releaseWidget () {
- if (menu != null && !menu.isDisposed ()) menu.releaseResources ();
- menu = null;
- super.releaseWidget ();
- if (accelerator != 0) removeAccelerator ();
- accelerator = 0;
- parent = null;
-}
-
+public boolean isEnabled () {
+ return getEnabled () && parent.isEnabled ();
+}
+
+int Pt_CB_ACTIVATE (int widget, int info) {
+ if ((style & SWT.CASCADE) != 0 && menu != null) {
+ return OS.Pt_CONTINUE;
+ }
+ Event event = new Event ();
+ if (info != 0) {
+ PtCallbackInfo_t cbinfo = new PtCallbackInfo_t ();
+ OS.memmove (cbinfo, info, PtCallbackInfo_t.sizeof);
+ if (cbinfo.event != 0) {
+ PhEvent_t ev = new PhEvent_t ();
+ OS.memmove (ev, cbinfo.event, PhEvent_t.sizeof);
+ int data = OS.PhGetData (cbinfo.event);
+ if (data != 0) {
+ switch (ev.type) {
+ case OS.Ph_EV_KEY:
+ PhKeyEvent_t ke = new PhKeyEvent_t ();
+ OS.memmove (ke, data, PhKeyEvent_t.sizeof);
+ setKeyState (event, ke);
+ break;
+ case OS.Ph_EV_BUT_PRESS:
+ case OS.Ph_EV_BUT_RELEASE:
+ PhPointerEvent_t pe = new PhPointerEvent_t ();
+ OS.memmove (pe, data, PhPointerEvent_t.sizeof);
+ setMouseState (event, pe, ev);
+ break;
+ }
+ }
+ }
+ }
+ if ((style & SWT.RADIO) != 0) {
+ if ((parent.getStyle () & SWT.NO_RADIO_GROUP) == 0) {
+ selectRadio ();
+ }
+ }
+ postEvent (SWT.Selection, event);
+ return OS.Pt_CONTINUE;
+}
+
+int Pt_CB_ARM (int widget, int info) {
+ postEvent (SWT.Arm);
+ showMenu ();
+ return OS.Pt_CONTINUE;
+}
+
+int Pt_CB_REALIZED (int widget, int info) {
+ /*
+ * Bug in Photon. The Pt_BLOCKED flag of a menu item is cleared
+ * when its parent menu is realized. The fix is to remember
+ * the menu item state and reset it when the menu item is
+ * realized.
+ */
+ int topHandle = topHandle ();
+ int flags = (state & DISABLED) != 0 ? OS.Pt_BLOCKED | OS.Pt_GHOST : 0;
+ OS.PtSetResource (handle, OS.Pt_ARG_FLAGS, flags, OS.Pt_BLOCKED | OS.Pt_GHOST);
+ return OS.Pt_CONTINUE;
+}
+
+void releaseChild () {
+ super.releaseChild ();
+ if (menu != null) menu.dispose ();
+ menu = null;
+}
+
+void releaseWidget () {
+ if (menu != null && !menu.isDisposed ()) menu.releaseResources ();
+ menu = null;
+ super.releaseWidget ();
+ if (accelerator != 0) removeAccelerator ();
+ accelerator = 0;
+ parent = null;
+}
+
/**
* Removes the listener from the collection of listeners who will
* be notified when the arm events are generated for the control.
@@ -489,13 +489,13 @@ void releaseWidget () {
* @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);
-}
-
+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.
@@ -513,28 +513,28 @@ public void removeArmListener (ArmListener listener) {
* @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);
-}
-
-void removeAccelerator () {
- if (accelerator == 0) return;
- 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));
- Display display = getDisplay ();
- int keyCode = Display.untranslateKey (key);
- if (keyCode != 0) key = keyCode;
- else key = Character.toLowerCase ((char)key);
- Shell shell = parent.getShell ();
- OS.PtRemoveHotkeyHandler(shell.shellHandle, key, keyMods, (short)0, handle, display.hotkeyProc);
-}
-
+public void removeHelpListener (HelpListener listener) {
+ checkWidget();
+ if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+ if (eventTable == null) return;
+ eventTable.unhook (SWT.Help, listener);
+}
+
+void removeAccelerator () {
+ if (accelerator == 0) return;
+ 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));
+ Display display = getDisplay ();
+ int keyCode = Display.untranslateKey (key);
+ if (keyCode != 0) key = keyCode;
+ else key = Character.toLowerCase ((char)key);
+ Shell shell = parent.getShell ();
+ OS.PtRemoveHotkeyHandler(shell.shellHandle, key, keyMods, (short)0, handle, display.hotkeyProc);
+}
+
/**
* Removes the listener from the collection of listeners who will
* be notified when the control is selected.
@@ -552,25 +552,25 @@ void removeAccelerator () {
* @see SelectionListener
* @see #addSelectionListener
*/
-public void removeSelectionListener (SelectionListener listener) {
- checkWidget();
- if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
- if (eventTable == null) return;
- eventTable.unhook (SWT.Selection, listener);
- eventTable.unhook (SWT.DefaultSelection,listener);
-}
-
-void selectRadio () {
- int index = 0;
- MenuItem [] items = parent.getItems ();
- while (index < items.length && items [index] != this) index++;
- int i = index - 1;
- while (i >= 0 && items [i].setRadioSelection (false)) --i;
- int j = index + 1;
- while (j < items.length && items [j].setRadioSelection (false)) j++;
- setSelection (true);
-}
-
+public void removeSelectionListener (SelectionListener listener) {
+ checkWidget();
+ if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+ if (eventTable == null) return;
+ eventTable.unhook (SWT.Selection, listener);
+ eventTable.unhook (SWT.DefaultSelection,listener);
+}
+
+void selectRadio () {
+ int index = 0;
+ MenuItem [] items = parent.getItems ();
+ while (index < items.length && items [index] != this) index++;
+ int i = index - 1;
+ while (i >= 0 && items [i].setRadioSelection (false)) --i;
+ int j = index + 1;
+ while (j < items.length && items [j].setRadioSelection (false)) j++;
+ setSelection (true);
+}
+
/**
* Sets the widget accelerator. An accelerator is the bit-wise
* OR of zero or more modifier masks and a key. Examples:
@@ -584,14 +584,14 @@ void selectRadio () {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public void setAccelerator (int accelerator) {
- checkWidget();
- if (this.accelerator == accelerator) return;
- removeAccelerator ();
- this.accelerator = accelerator;
- addAccelerator ();
-}
-
+public void setAccelerator (int accelerator) {
+ checkWidget();
+ if (this.accelerator == accelerator) return;
+ removeAccelerator ();
+ this.accelerator = accelerator;
+ addAccelerator ();
+}
+
/**
* Enables the receiver if the argument is <code>true</code>,
* and disables it otherwise. A disabled control is typically
@@ -605,18 +605,18 @@ public void setAccelerator (int accelerator) {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public void setEnabled (boolean enabled) {
- checkWidget ();
- if (enabled) {
- state &= ~DISABLED;
- } else {
- state |= DISABLED;
- }
- int topHandle = topHandle ();
- int flags = (state & DISABLED) != 0 ? OS.Pt_BLOCKED | OS.Pt_GHOST : 0;
- OS.PtSetResource (topHandle, OS.Pt_ARG_FLAGS, flags, OS.Pt_BLOCKED | OS.Pt_GHOST);
-}
-
+public void setEnabled (boolean enabled) {
+ checkWidget ();
+ if (enabled) {
+ state &= ~DISABLED;
+ } else {
+ state |= DISABLED;
+ }
+ int topHandle = topHandle ();
+ int flags = (state & DISABLED) != 0 ? OS.Pt_BLOCKED | OS.Pt_GHOST : 0;
+ OS.PtSetResource (topHandle, OS.Pt_ARG_FLAGS, flags, OS.Pt_BLOCKED | OS.Pt_GHOST);
+}
+
/**
* Sets the image the receiver will display to the argument.
* <p>
@@ -630,43 +630,43 @@ public void setEnabled (boolean enabled) {
* <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;
- if (this.image == image) return;
- super.setImage (image);
- if ((style & (SWT.CHECK | SWT.RADIO)) != 0) return;
- int imageHandle = 0;
- int type = OS.Pt_Z_STRING;
- if (image != null) {
- imageHandle = copyPhImage (image.handle);
- if (text.length () != 0) type = OS.Pt_TEXT_IMAGE;
- else type = OS.Pt_IMAGE;
- } else {
- /*
- * Bug in Photon. Photon will segment fault, if Pt_ARG_LABEL_IMAGE
- * is set to NULL. This means that after setting an image into a
- * PtMenuButton, it can never be removed. The fix is to set it to
- * a small blank image.
- */
- Display display = getDisplay ();
- imageHandle = copyPhImage (display.nullImage);
- }
- 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);
- /*
- * 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.PtExtentWidgetFamily (parent.handle);
-}
-
+public void setImage (Image image) {
+ checkWidget();
+ if ((style & SWT.SEPARATOR) != 0) return;
+ if (this.image == image) return;
+ super.setImage (image);
+ if ((style & (SWT.CHECK | SWT.RADIO)) != 0) return;
+ int imageHandle = 0;
+ int type = OS.Pt_Z_STRING;
+ if (image != null) {
+ imageHandle = copyPhImage (image.handle);
+ if (text.length () != 0) type = OS.Pt_TEXT_IMAGE;
+ else type = OS.Pt_IMAGE;
+ } else {
+ /*
+ * Bug in Photon. Photon will segment fault, if Pt_ARG_LABEL_IMAGE
+ * is set to NULL. This means that after setting an image into a
+ * PtMenuButton, it can never be removed. The fix is to set it to
+ * a small blank image.
+ */
+ Display display = getDisplay ();
+ imageHandle = copyPhImage (display.nullImage);
+ }
+ 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);
+ /*
+ * 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.PtExtentWidgetFamily (parent.handle);
+}
+
/**
* Sets the receiver's pull down menu to the argument.
* Only <code>CASCADE</code> menu items can have a
@@ -687,45 +687,45 @@ public void setImage (Image image) {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public void setMenu (Menu menu) {
- checkWidget();
- if ((style & SWT.CASCADE) == 0) {
- error (SWT.ERROR_MENUITEM_NOT_CASCADE);
- }
- if (menu != null) {
- if (menu.isDisposed()) error(SWT.ERROR_INVALID_ARGUMENT);
- 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;
- if ((parent.style & SWT.BAR) == 0) {
- OS.PtSetResource (handle, OS.Pt_ARG_BUTTON_TYPE, OS.Pt_MENU_TEXT, 0);
- }
- }
- if (menu != null) {
- menu.cascade = this;
- if ((parent.style & SWT.BAR) == 0) {
- OS.PtSetResource (handle, OS.Pt_ARG_BUTTON_TYPE, OS.Pt_MENU_RIGHT, 0);
- }
- }
-}
-
-boolean setRadioSelection (boolean value) {
- if ((style & SWT.RADIO) == 0) return false;
- if (getSelection () != value) {
- setSelection (value);
- postEvent (SWT.Selection);
- }
- return true;
-}
+public void setMenu (Menu menu) {
+ checkWidget();
+ if ((style & SWT.CASCADE) == 0) {
+ error (SWT.ERROR_MENUITEM_NOT_CASCADE);
+ }
+ if (menu != null) {
+ if (menu.isDisposed()) error(SWT.ERROR_INVALID_ARGUMENT);
+ 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;
+ if ((parent.style & SWT.BAR) == 0) {
+ OS.PtSetResource (handle, OS.Pt_ARG_BUTTON_TYPE, OS.Pt_MENU_TEXT, 0);
+ }
+ }
+ if (menu != null) {
+ menu.cascade = this;
+ if ((parent.style & SWT.BAR) == 0) {
+ OS.PtSetResource (handle, OS.Pt_ARG_BUTTON_TYPE, OS.Pt_MENU_RIGHT, 0);
+ }
+ }
+}
+
+boolean setRadioSelection (boolean value) {
+ if ((style & SWT.RADIO) == 0) return false;
+ if (getSelection () != value) {
+ setSelection (value);
+ postEvent (SWT.Selection);
+ }
+ return true;
+}
/**
* Sets the selection state of the receiver.
* <p>
@@ -739,123 +739,123 @@ boolean setRadioSelection (boolean value) {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public void setSelection (boolean selected) {
- checkWidget();
- if ((style & (SWT.CHECK | SWT.RADIO | SWT.TOGGLE)) == 0) return;
- OS.PtSetResource (handle, OS.Pt_ARG_FLAGS, selected ? OS.Pt_SET : 0, OS.Pt_SET);
-}
-
-public void setText (String string) {
- checkWidget();
- 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--;
- }
- }
- int keyMods = 0;
- byte [] buffer2 = new byte [1];
- if (accel && ++i < text.length) {
- int start = i;
-// while (i < text.length) {
-// if (text [i] == '+') {
-// String str = new String (text, start, i - start);
-// if (str.equals ("Ctrl")) keyMods |= OS.Pk_KM_Ctrl;
-// if (str.equals ("Shift")) keyMods |= OS.Pk_KM_Shift;
-// if (str.equals ("Alt")) keyMods |= OS.Pk_KM_Alt;
-// start = i + 1;
-// }
-// i++;
-// }
- if (start < text.length) {
- char [] accelText = new char [text.length - start];
- System.arraycopy (text, start, accelText, 0, accelText.length);
- buffer2 = Converter.wcsToMbcs (null, accelText, true);
- }
- }
- while (j < text.length) text [j++] = 0;
- byte [] buffer1 = Converter.wcsToMbcs (null, text, true);
- int ptr1 = OS.malloc (buffer1.length);
- OS.memmove (ptr1, buffer1, buffer1.length);
- int ptr2 = OS.malloc (buffer2.length);
- OS.memmove (ptr2, buffer2, buffer2.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);
- }
- if ((parent.style & SWT.BAR) != 0) {
- replaceMnemonic (mnemonic, false, true);
- }
- int type = OS.Pt_Z_STRING;
- if ((style & SWT.PUSH) != 0) {
- if (image != null) type = OS.Pt_TEXT_IMAGE;
- }
- int [] args = {
- OS.Pt_ARG_TEXT_STRING, ptr1, 0,
- OS.Pt_ARG_ACCEL_TEXT, ptr2, 0,
- OS.Pt_ARG_MODIFIER_KEYS, keyMods, keyMods,
- OS.Pt_ARG_ACCEL_KEY, ptr3, 0,
- OS.Pt_ARG_LABEL_TYPE, type, 0,
- };
- OS.PtSetResources (handle, args.length / 3, args);
- OS.free (ptr1);
- OS.free (ptr2);
- 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.PtExtentWidgetFamily (parent.handle);
-}
-
-void showMenu() {
- if (menu == null) return;
- int menuHandle = menu.handle;
- if (!OS.PtWidgetIsRealized (menuHandle)) {
- if ((parent.style & SWT.BAR) == 0) {
- OS.PtSetResource (menuHandle, OS.Pt_ARG_MENU_FLAGS, OS.Pt_MENU_CHILD, OS.Pt_MENU_CHILD);
- }
- OS.PtReParentWidget (menuHandle, handle);
-
- /*
- * Bug in Photon. PtPositionMenu does not position the menu
- * properly when the menu is a direct child a menu bar item.
- * The fix is to position the menu ourselfs.
- */
- if ((parent.style & SWT.BAR) != 0) {
- PhPoint_t pt = new PhPoint_t ();
- short [] x = new short [1], y = new short [1];
- OS.PtGetAbsPosition (handle, x, y);
- pt.x = x [0];
- pt.y = y [0];
- int [] args = {OS.Pt_ARG_HEIGHT, 0, 0};
- OS.PtGetResources (handle, args.length / 3, args);
- pt.y += args [1];
- int ptr = OS.malloc (PhPoint_t.sizeof);
- OS.memmove (ptr, pt, PhPoint_t.sizeof);
- OS.PtSetResource (menuHandle, OS.Pt_ARG_POS, ptr, 0);
- OS.free (ptr);
- } else {
- OS.PtPositionMenu (menuHandle, null);
- }
-
- menu.sendEvent (SWT.Show);
- OS.PtRealizeWidget (menuHandle);
- }
-}
-
-}
+public void setSelection (boolean selected) {
+ checkWidget();
+ if ((style & (SWT.CHECK | SWT.RADIO | SWT.TOGGLE)) == 0) return;
+ OS.PtSetResource (handle, OS.Pt_ARG_FLAGS, selected ? OS.Pt_SET : 0, OS.Pt_SET);
+}
+
+public void setText (String string) {
+ checkWidget();
+ 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--;
+ }
+ }
+ int keyMods = 0;
+ byte [] buffer2 = new byte [1];
+ if (accel && ++i < text.length) {
+ int start = i;
+// while (i < text.length) {
+// if (text [i] == '+') {
+// String str = new String (text, start, i - start);
+// if (str.equals ("Ctrl")) keyMods |= OS.Pk_KM_Ctrl;
+// if (str.equals ("Shift")) keyMods |= OS.Pk_KM_Shift;
+// if (str.equals ("Alt")) keyMods |= OS.Pk_KM_Alt;
+// start = i + 1;
+// }
+// i++;
+// }
+ if (start < text.length) {
+ char [] accelText = new char [text.length - start];
+ System.arraycopy (text, start, accelText, 0, accelText.length);
+ buffer2 = Converter.wcsToMbcs (null, accelText, true);
+ }
+ }
+ while (j < text.length) text [j++] = 0;
+ byte [] buffer1 = Converter.wcsToMbcs (null, text, true);
+ int ptr1 = OS.malloc (buffer1.length);
+ OS.memmove (ptr1, buffer1, buffer1.length);
+ int ptr2 = OS.malloc (buffer2.length);
+ OS.memmove (ptr2, buffer2, buffer2.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);
+ }
+ if ((parent.style & SWT.BAR) != 0) {
+ replaceMnemonic (mnemonic, false, true);
+ }
+ int type = OS.Pt_Z_STRING;
+ if ((style & SWT.PUSH) != 0) {
+ if (image != null) type = OS.Pt_TEXT_IMAGE;
+ }
+ int [] args = {
+ OS.Pt_ARG_TEXT_STRING, ptr1, 0,
+ OS.Pt_ARG_ACCEL_TEXT, ptr2, 0,
+ OS.Pt_ARG_MODIFIER_KEYS, keyMods, keyMods,
+ OS.Pt_ARG_ACCEL_KEY, ptr3, 0,
+ OS.Pt_ARG_LABEL_TYPE, type, 0,
+ };
+ OS.PtSetResources (handle, args.length / 3, args);
+ OS.free (ptr1);
+ OS.free (ptr2);
+ 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.PtExtentWidgetFamily (parent.handle);
+}
+
+void showMenu() {
+ if (menu == null) return;
+ int menuHandle = menu.handle;
+ if (!OS.PtWidgetIsRealized (menuHandle)) {
+ if ((parent.style & SWT.BAR) == 0) {
+ OS.PtSetResource (menuHandle, OS.Pt_ARG_MENU_FLAGS, OS.Pt_MENU_CHILD, OS.Pt_MENU_CHILD);
+ }
+ OS.PtReParentWidget (menuHandle, handle);
+
+ /*
+ * Bug in Photon. PtPositionMenu does not position the menu
+ * properly when the menu is a direct child a menu bar item.
+ * The fix is to position the menu ourselfs.
+ */
+ if ((parent.style & SWT.BAR) != 0) {
+ PhPoint_t pt = new PhPoint_t ();
+ short [] x = new short [1], y = new short [1];
+ OS.PtGetAbsPosition (handle, x, y);
+ pt.x = x [0];
+ pt.y = y [0];
+ int [] args = {OS.Pt_ARG_HEIGHT, 0, 0};
+ OS.PtGetResources (handle, args.length / 3, args);
+ pt.y += args [1];
+ int ptr = OS.malloc (PhPoint_t.sizeof);
+ OS.memmove (ptr, pt, PhPoint_t.sizeof);
+ OS.PtSetResource (menuHandle, OS.Pt_ARG_POS, ptr, 0);
+ OS.free (ptr);
+ } else {
+ OS.PtPositionMenu (menuHandle, null);
+ }
+
+ menu.sendEvent (SWT.Show);
+ OS.PtRealizeWidget (menuHandle);
+ }
+}
+
+}
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
index f4ab7480ec..08d09fadbd 100755
--- 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
@@ -1,16 +1,16 @@
-package org.eclipse.swt.widgets;
-
-/*
+package org.eclipse.swt.widgets;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-import org.eclipse.swt.internal.*;
-import org.eclipse.swt.internal.photon.*;
-import org.eclipse.swt.*;
-
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+import org.eclipse.swt.internal.*;
+import org.eclipse.swt.internal.photon.*;
+import org.eclipse.swt.*;
+
/**
* Instances of this class are used used to inform or warn the user.
* <dl>
@@ -31,8 +31,8 @@ import org.eclipse.swt.*;
* within the SWT implementation.
* </p>
*/
-public class MessageBox extends Dialog {
- String message = "";
+public class MessageBox extends Dialog {
+ String message = "";
/**
* Constructs a new instance of this class given only its
* parent.
@@ -55,9 +55,9 @@ public class MessageBox extends Dialog {
* <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
* </ul>
*/
-public MessageBox (Shell parent) {
- this (parent, SWT.OK | SWT.ICON_INFORMATION | SWT.APPLICATION_MODAL);
-}
+public MessageBox (Shell parent) {
+ this (parent, SWT.OK | SWT.ICON_INFORMATION | SWT.APPLICATION_MODAL);
+}
/**
* Constructs a new instance of this class given its parent
* and a style value describing its behavior and appearance.
@@ -88,20 +88,20 @@ public MessageBox (Shell parent) {
* <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
* </ul>
*/
-public MessageBox (Shell parent, int style) {
- super (parent, checkStyle (style));
- checkSubclass ();
-}
-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 MessageBox (Shell parent, int style) {
+ super (parent, checkStyle (style));
+ checkSubclass ();
+}
+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;
+}
/**
* Returns the dialog's message, which is a description of
* the purpose for which it was opened. This message will be
@@ -109,9 +109,9 @@ static int checkStyle (int style) {
*
* @return the message
*/
-public String getMessage () {
- return message;
-}
+public String getMessage () {
+ return message;
+}
/**
* Makes the dialog visible and brings it to the front
* of the display.
@@ -124,81 +124,81 @@ public String getMessage () {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the dialog</li>
* </ul>
*/
-public int open () {
- String[] buttons = null;
- if ((style & SWT.OK) == SWT.OK) {
- buttons = new String[]{SWT.getMessage ("SWT_OK")};
- }
- if ((style & (SWT.OK | SWT.CANCEL)) == (SWT.OK | SWT.CANCEL)) {
- buttons = new String[]{SWT.getMessage ("SWT_OK"), SWT.getMessage ("SWT_Cancel")};
- }
- if ((style & (SWT.YES | SWT.NO)) == (SWT.YES | SWT.NO)) {
- buttons = new String[]{SWT.getMessage ("SWT_Yes"), SWT.getMessage ("SWT_No")};
- }
- if ((style & (SWT.YES | SWT.NO | SWT.CANCEL)) == (SWT.YES | SWT.NO | SWT.CANCEL)){
- buttons = new String[]{SWT.getMessage ("SWT_Yes"), SWT.getMessage ("SWT_No"), SWT.getMessage ("SWT_Cancel")};
- }
- if ((style & (SWT.RETRY | SWT.CANCEL)) == (SWT.RETRY | SWT.CANCEL)) {
- buttons = new String[]{SWT.getMessage ("SWT_Retry"), SWT.getMessage ("SWT_Cancel")};
- }
- if ((style & (SWT.ABORT | SWT.RETRY | SWT.IGNORE)) == (SWT.ABORT | SWT.RETRY | SWT.IGNORE)) {
- buttons = new String[]{SWT.getMessage ("SWT_Abort"), SWT.getMessage ("SWT_Retry"), SWT.getMessage ("SWT_Cancel")};
- }
- if (buttons == null) buttons = new String[]{SWT.getMessage ("SWT_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 && OS.PtWidgetIsRealized(parent.shellHandle)) {
- 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 int open () {
+ String[] buttons = null;
+ if ((style & SWT.OK) == SWT.OK) {
+ buttons = new String[]{SWT.getMessage ("SWT_OK")};
+ }
+ if ((style & (SWT.OK | SWT.CANCEL)) == (SWT.OK | SWT.CANCEL)) {
+ buttons = new String[]{SWT.getMessage ("SWT_OK"), SWT.getMessage ("SWT_Cancel")};
+ }
+ if ((style & (SWT.YES | SWT.NO)) == (SWT.YES | SWT.NO)) {
+ buttons = new String[]{SWT.getMessage ("SWT_Yes"), SWT.getMessage ("SWT_No")};
+ }
+ if ((style & (SWT.YES | SWT.NO | SWT.CANCEL)) == (SWT.YES | SWT.NO | SWT.CANCEL)){
+ buttons = new String[]{SWT.getMessage ("SWT_Yes"), SWT.getMessage ("SWT_No"), SWT.getMessage ("SWT_Cancel")};
+ }
+ if ((style & (SWT.RETRY | SWT.CANCEL)) == (SWT.RETRY | SWT.CANCEL)) {
+ buttons = new String[]{SWT.getMessage ("SWT_Retry"), SWT.getMessage ("SWT_Cancel")};
+ }
+ if ((style & (SWT.ABORT | SWT.RETRY | SWT.IGNORE)) == (SWT.ABORT | SWT.RETRY | SWT.IGNORE)) {
+ buttons = new String[]{SWT.getMessage ("SWT_Abort"), SWT.getMessage ("SWT_Retry"), SWT.getMessage ("SWT_Cancel")};
+ }
+ if (buttons == null) buttons = new String[]{SWT.getMessage ("SWT_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 && OS.PtWidgetIsRealized(parent.shellHandle)) {
+ 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;
+}
/**
* Sets the dialog's message, which is a description of
* the purpose for which it was opened. This message will be
@@ -206,7 +206,7 @@ public int open () {
*
* @param string the message
*/
-public void setMessage (String string) {
- message = string;
-}
-}
+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
index f551480d3a..7cdfb3ca94 100755
--- 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
@@ -1,16 +1,16 @@
-package org.eclipse.swt.widgets;
-
-/*
+package org.eclipse.swt.widgets;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-import org.eclipse.swt.internal.photon.*;
-import org.eclipse.swt.*;
-import org.eclipse.swt.graphics.*;
-
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+import org.eclipse.swt.internal.photon.*;
+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,
@@ -28,8 +28,8 @@ import org.eclipse.swt.graphics.*;
* within the SWT implementation.
* </p>
*/
-public class ProgressBar extends Control {
-
+public class ProgressBar extends Control {
+
/**
* Constructs a new instance of this class given its parent
* and a style value describing its behavior and appearance.
@@ -60,64 +60,64 @@ public class ProgressBar extends Control {
* @see Widget#checkSubclass
* @see Widget#getStyle
*/
-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) {
- checkWidget();
- 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) {
- state |= HANDLE;
- Display display = getDisplay ();
- int clazz = display.PtProgress;
- int parentHandle = parent.parentingHandle ();
- int gaugeFlags = (style & SWT.INDETERMINATE) != 0 ? OS.Pt_GAUGE_INDETERMINATE : 0;
- int [] args = {
- OS.Pt_ARG_FLAGS, 0, OS.Pt_GETS_FOCUS,
- OS.Pt_ARG_GAUGE_FLAGS, gaugeFlags, OS.Pt_GAUGE_INDETERMINATE,
- 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);
-}
-
-byte [] defaultFont () {
- Display display = getDisplay ();
- return display.GAUGE_FONT;
-}
-
+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) {
+ checkWidget();
+ 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) {
+ state |= HANDLE;
+ Display display = getDisplay ();
+ int clazz = display.PtProgress;
+ int parentHandle = parent.parentingHandle ();
+ int gaugeFlags = (style & SWT.INDETERMINATE) != 0 ? OS.Pt_GAUGE_INDETERMINATE : 0;
+ int [] args = {
+ OS.Pt_ARG_FLAGS, 0, OS.Pt_GETS_FOCUS,
+ OS.Pt_ARG_GAUGE_FLAGS, gaugeFlags, OS.Pt_GAUGE_INDETERMINATE,
+ 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);
+}
+
+byte [] defaultFont () {
+ Display display = getDisplay ();
+ return display.GAUGE_FONT;
+}
+
/**
* Returns the maximum value which the receiver will allow.
*
@@ -128,13 +128,13 @@ byte [] defaultFont () {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public int getMaximum () {
- checkWidget();
- int [] args = {OS.Pt_ARG_MAXIMUM, 0, 0};
- OS.PtGetResources (handle, args.length / 3, args);
- return args [1];
-}
-
+public int getMaximum () {
+ checkWidget();
+ int [] args = {OS.Pt_ARG_MAXIMUM, 0, 0};
+ OS.PtGetResources (handle, args.length / 3, args);
+ return args [1];
+}
+
/**
* Returns the minimum value which the receiver will allow.
*
@@ -145,13 +145,13 @@ public int getMaximum () {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public int getMinimum () {
- checkWidget();
- int [] args = {OS.Pt_ARG_MINIMUM, 0, 0};
- OS.PtGetResources (handle, args.length / 3, args);
- return args [1];
-}
-
+public int getMinimum () {
+ checkWidget();
+ int [] args = {OS.Pt_ARG_MINIMUM, 0, 0};
+ OS.PtGetResources (handle, args.length / 3, args);
+ return args [1];
+}
+
/**
* Returns the single <em>selection</em> that is the receiver's position.
*
@@ -162,13 +162,13 @@ public int getMinimum () {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public int getSelection () {
- checkWidget();
- int [] args = {OS.Pt_ARG_GAUGE_VALUE, 0, 0};
- OS.PtGetResources (handle, args.length / 3, args);
- return args [1];
-}
-
+public int getSelection () {
+ checkWidget();
+ int [] args = {OS.Pt_ARG_GAUGE_VALUE, 0, 0};
+ OS.PtGetResources (handle, args.length / 3, args);
+ return args [1];
+}
+
/**
* Sets the maximum value which the receiver will allow
* to be the argument which must be greater than or
@@ -181,14 +181,14 @@ public int getSelection () {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public void setMaximum (int value) {
- checkWidget();
- int minimum = getMinimum();
- if (0 <= minimum && minimum < value) {
- OS.PtSetResource (handle, OS.Pt_ARG_MAXIMUM, value, 0);
- }
-}
-
+public void setMaximum (int value) {
+ checkWidget();
+ int minimum = getMinimum();
+ if (0 <= minimum && minimum < value) {
+ OS.PtSetResource (handle, OS.Pt_ARG_MAXIMUM, value, 0);
+ }
+}
+
/**
* Sets the minimum value which the receiver will allow
* to be the argument which must be greater than or
@@ -201,14 +201,14 @@ public void setMaximum (int value) {
* <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 = getMaximum();
- if (0 <= value && value < maximum) {
- OS.PtSetResource (handle, OS.Pt_ARG_MINIMUM, value, 0);
- }
-}
-
+public void setMinimum (int value) {
+ checkWidget();
+ int maximum = getMaximum();
+ if (0 <= value && value < maximum) {
+ OS.PtSetResource (handle, OS.Pt_ARG_MINIMUM, value, 0);
+ }
+}
+
/**
* Sets the single <em>selection</em> that is the receiver's
* position to the argument which must be greater than or equal
@@ -221,17 +221,17 @@ public void setMinimum (int value) {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public void setSelection (int value) {
- checkWidget();
- OS.PtSetResource (handle, OS.Pt_ARG_GAUGE_VALUE, value, 0);
-}
-
-int traversalCode (int key_sym, PhKeyEvent_t ke) {
- return 0;
-}
-
-int widgetClass () {
- return OS.PtProgress ();
-}
-
-}
+public void setSelection (int value) {
+ checkWidget();
+ OS.PtSetResource (handle, OS.Pt_ARG_GAUGE_VALUE, value, 0);
+}
+
+int traversalCode (int key_sym, PhKeyEvent_t ke) {
+ return 0;
+}
+
+int widgetClass () {
+ return OS.PtProgress ();
+}
+
+}
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
index 3039a4df6d..52be69a650 100755
--- 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
@@ -1,17 +1,17 @@
-package org.eclipse.swt.widgets;
-
-/*
+package org.eclipse.swt.widgets;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-import org.eclipse.swt.internal.photon.*;
-import org.eclipse.swt.*;
-import org.eclipse.swt.graphics.*;
-import org.eclipse.swt.events.*;
-
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+import org.eclipse.swt.internal.photon.*;
+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
@@ -29,12 +29,12 @@ import org.eclipse.swt.events.*;
* within the SWT implementation.
* </p>
*/
-public class Sash extends Control {
- boolean dragging;
- int startX, startY, lastX, lastY;
- final static int INCREMENT = 1;
- final static int PAGE_INCREMENT = 9;
-
+public class Sash extends Control {
+ boolean dragging;
+ int startX, startY, lastX, lastY;
+ final static int INCREMENT = 1;
+ final static int PAGE_INCREMENT = 9;
+
/**
* Constructs a new instance of this class given its parent
* and a style value describing its behavior and appearance.
@@ -64,10 +64,10 @@ public class Sash extends Control {
* @see Widget#checkSubclass
* @see Widget#getStyle
*/
-public Sash (Composite parent, int style) {
- super (parent, checkStyle (style));
-}
-
+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
@@ -93,220 +93,220 @@ public Sash (Composite parent, int style) {
* @see #removeSelectionListener
* @see SelectionEvent
*/
-public void addSelectionListener (SelectionListener listener) {
- checkWidget();
- if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
- TypedListener typedListener = new TypedListener (listener);
- addListener (SWT.Selection,typedListener);
- addListener (SWT.DefaultSelection,typedListener);
-}
-
-static int checkStyle (int style) {
- return checkBits (style, SWT.HORIZONTAL, SWT.VERTICAL, 0, 0, 0, 0);
-}
-
-public Point computeSize (int wHint, int hHint, boolean changed) {
- checkWidget();
- 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 |= GRAB | HANDLE;
- Display display = getDisplay ();
- int clazz = display.PtContainer;
- int parentHandle = parent.parentingHandle ();
- int cursor = ((style & SWT.HORIZONTAL) != 0) ? OS.Ph_CURSOR_DRAG_VERTICAL : OS.Ph_CURSOR_DRAG_HORIZONTAL;
- int [] args = {
- OS.Pt_ARG_FLAGS, 0, OS.Pt_GETS_FOCUS,
- 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);
-}
-
-byte [] defaultFont () {
- Display display = getDisplay ();
- return display.TITLE_FONT;
-}
-
-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 Ph_EV_BUT_PRESS (int widget, int info) {
- int result = super.Ph_EV_BUT_PRESS (widget, info);
- if (result != OS.Pt_CONTINUE)return result;
- processMouse (info);
- return result;
-}
-
-int Ph_EV_BUT_RELEASE (int widget, int info) {
- int result = super.Ph_EV_BUT_RELEASE (widget, info);
- if (result != OS.Pt_CONTINUE)return result;
- processMouse (info);
- return result;
-}
-
-int Ph_EV_DRAG (int widget, int info) {
- int result = super.Ph_EV_DRAG (widget, info);
- if (result != OS.Pt_CONTINUE)return result;
- processMouse (info);
- return result;
-}
-
-int Ph_EV_PTR_MOTION (int widget, int info) {
- int result = super.Ph_EV_PTR_MOTION (widget, info);
- if (result != OS.Pt_CONTINUE)return result;
- processMouse (info);
- return result;
-}
-
-void processMouse (int info) {
- PtCallbackInfo_t cbinfo = new PtCallbackInfo_t ();
- OS.memmove (cbinfo, info, PtCallbackInfo_t.sizeof);
- PhEvent_t ev = new PhEvent_t ();
- OS.memmove (ev, cbinfo.event, PhEvent_t.sizeof);
- int data = OS.PhGetData (cbinfo.event);
- PhPointerEvent_t pe = new PhPointerEvent_t ();
- OS.memmove (pe, data, PhPointerEvent_t.sizeof);
- if (pe.buttons != OS.Ph_BUTTON_SELECT) return;
-
- 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;
-
- /* 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;
- }
- /* Compute the banding rectangle */
- if (!dragging) return;
- 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;
- }
- if (!dragging) return;
-
- /* Compute the banding rectangle */
- x += area.pos_x;
- y += area.pos_y;
- Rectangle r = parent.getClientArea ();
- int clientWidth = r.width;
- int clientHeight = r.height;
- 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;
- 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;
-
- /* Draw the banding rectangle */
- if (event.doit) {
- lastX = event.x; lastY = event.y;
- OS.PtFlush ();
- drawBand (lastX, lastY, width, height);
- }
- break;
- }
-}
-
+public void addSelectionListener (SelectionListener listener) {
+ checkWidget();
+ if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+ TypedListener typedListener = new TypedListener (listener);
+ addListener (SWT.Selection,typedListener);
+ addListener (SWT.DefaultSelection,typedListener);
+}
+
+static int checkStyle (int style) {
+ return checkBits (style, SWT.HORIZONTAL, SWT.VERTICAL, 0, 0, 0, 0);
+}
+
+public Point computeSize (int wHint, int hHint, boolean changed) {
+ checkWidget();
+ 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 |= GRAB | HANDLE;
+ Display display = getDisplay ();
+ int clazz = display.PtContainer;
+ int parentHandle = parent.parentingHandle ();
+ int cursor = ((style & SWT.HORIZONTAL) != 0) ? OS.Ph_CURSOR_DRAG_VERTICAL : OS.Ph_CURSOR_DRAG_HORIZONTAL;
+ int [] args = {
+ OS.Pt_ARG_FLAGS, 0, OS.Pt_GETS_FOCUS,
+ 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);
+}
+
+byte [] defaultFont () {
+ Display display = getDisplay ();
+ return display.TITLE_FONT;
+}
+
+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 Ph_EV_BUT_PRESS (int widget, int info) {
+ int result = super.Ph_EV_BUT_PRESS (widget, info);
+ if (result != OS.Pt_CONTINUE)return result;
+ processMouse (info);
+ return result;
+}
+
+int Ph_EV_BUT_RELEASE (int widget, int info) {
+ int result = super.Ph_EV_BUT_RELEASE (widget, info);
+ if (result != OS.Pt_CONTINUE)return result;
+ processMouse (info);
+ return result;
+}
+
+int Ph_EV_DRAG (int widget, int info) {
+ int result = super.Ph_EV_DRAG (widget, info);
+ if (result != OS.Pt_CONTINUE)return result;
+ processMouse (info);
+ return result;
+}
+
+int Ph_EV_PTR_MOTION (int widget, int info) {
+ int result = super.Ph_EV_PTR_MOTION (widget, info);
+ if (result != OS.Pt_CONTINUE)return result;
+ processMouse (info);
+ return result;
+}
+
+void processMouse (int info) {
+ PtCallbackInfo_t cbinfo = new PtCallbackInfo_t ();
+ OS.memmove (cbinfo, info, PtCallbackInfo_t.sizeof);
+ PhEvent_t ev = new PhEvent_t ();
+ OS.memmove (ev, cbinfo.event, PhEvent_t.sizeof);
+ int data = OS.PhGetData (cbinfo.event);
+ PhPointerEvent_t pe = new PhPointerEvent_t ();
+ OS.memmove (pe, data, PhPointerEvent_t.sizeof);
+ if (pe.buttons != OS.Ph_BUTTON_SELECT) return;
+
+ 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;
+
+ /* 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;
+ }
+ /* Compute the banding rectangle */
+ if (!dragging) return;
+ 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;
+ }
+ if (!dragging) return;
+
+ /* Compute the banding rectangle */
+ x += area.pos_x;
+ y += area.pos_y;
+ Rectangle r = parent.getClientArea ();
+ int clientWidth = r.width;
+ int clientHeight = r.height;
+ 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;
+ 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;
+
+ /* Draw the banding rectangle */
+ if (event.doit) {
+ lastX = event.x; lastY = event.y;
+ OS.PtFlush ();
+ drawBand (lastX, lastY, width, height);
+ }
+ break;
+ }
+}
+
/**
* Removes the listener from the collection of listeners who will
* be notified when the control is selected.
@@ -324,84 +324,84 @@ void processMouse (int info) {
* @see SelectionListener
* @see #addSelectionListener
*/
-public void removeSelectionListener(SelectionListener listener) {
- checkWidget();
- if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
- if (eventTable == null) return;
- eventTable.unhook (SWT.Selection, listener);
- eventTable.unhook (SWT.DefaultSelection,listener);
-}
-
-int traversalCode (int key_sym, PhKeyEvent_t ke) {
- return 0;
-}
-
-boolean translateTraversal (int key_sym, PhKeyEvent_t phEvent) {
- boolean result = super.translateTraversal (key_sym, phEvent);
- if (!result) {
- switch (key_sym) {
- case OS.Pk_Left:
- case OS.Pk_Right:
- case OS.Pk_Up:
- case OS.Pk_Down:
-
- /* Calculate the new x or y position */
- if ((phEvent.button_state & OS.Ph_BUTTON_SELECT) != 0) return result;
- int step = (phEvent.key_mods & OS.Pk_KM_Ctrl) != 0 ? INCREMENT : PAGE_INCREMENT;
- int x = 0, y = 0;
- if ((style & SWT.VERTICAL) != 0) {
- if (key_sym == OS.Pk_Up || key_sym == OS.Pk_Down) break;
- x = key_sym == OS.Pk_Left ? -step : step;
- } else {
- if (key_sym == OS.Pk_Left || key_sym == OS.Pk_Right) break;
- y = key_sym == OS.Pk_Up ? -step : step;
- }
- PhArea_t area = new PhArea_t ();
- OS.PtWidgetArea (handle, area);
- x += area.pos_x;
- y += area.pos_y;
- int width = area.size_w;
- int height = area.size_h;
- Rectangle r = parent.getClientArea ();
- int clientWidth = r.width;
- int clientHeight = r.height;
- 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;
-
- /* 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;
-
- /*
- * 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 true;
- if (event.doit) {
- OS.PtWidgetArea (handle, area);
- int cursorX = area.size_w / 2, cursorY = area.size_h / 2;
- short [] absX = new short [1], absY = new short [1];
- OS.PtGetAbsPosition (handle, absX, absY);
- OS.PhMoveCursorAbs (OS.PhInputGroup (0), cursorX + absX [0], cursorY + absY [0]);
- }
- return result;
- }
- }
- return result;
-}
-
-int widgetClass () {
- return OS.PtContainer ();
-}
-
-}
+public void removeSelectionListener(SelectionListener listener) {
+ checkWidget();
+ if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+ if (eventTable == null) return;
+ eventTable.unhook (SWT.Selection, listener);
+ eventTable.unhook (SWT.DefaultSelection,listener);
+}
+
+int traversalCode (int key_sym, PhKeyEvent_t ke) {
+ return 0;
+}
+
+boolean translateTraversal (int key_sym, PhKeyEvent_t phEvent) {
+ boolean result = super.translateTraversal (key_sym, phEvent);
+ if (!result) {
+ switch (key_sym) {
+ case OS.Pk_Left:
+ case OS.Pk_Right:
+ case OS.Pk_Up:
+ case OS.Pk_Down:
+
+ /* Calculate the new x or y position */
+ if ((phEvent.button_state & OS.Ph_BUTTON_SELECT) != 0) return result;
+ int step = (phEvent.key_mods & OS.Pk_KM_Ctrl) != 0 ? INCREMENT : PAGE_INCREMENT;
+ int x = 0, y = 0;
+ if ((style & SWT.VERTICAL) != 0) {
+ if (key_sym == OS.Pk_Up || key_sym == OS.Pk_Down) break;
+ x = key_sym == OS.Pk_Left ? -step : step;
+ } else {
+ if (key_sym == OS.Pk_Left || key_sym == OS.Pk_Right) break;
+ y = key_sym == OS.Pk_Up ? -step : step;
+ }
+ PhArea_t area = new PhArea_t ();
+ OS.PtWidgetArea (handle, area);
+ x += area.pos_x;
+ y += area.pos_y;
+ int width = area.size_w;
+ int height = area.size_h;
+ Rectangle r = parent.getClientArea ();
+ int clientWidth = r.width;
+ int clientHeight = r.height;
+ 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;
+
+ /* 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;
+
+ /*
+ * 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 true;
+ if (event.doit) {
+ OS.PtWidgetArea (handle, area);
+ int cursorX = area.size_w / 2, cursorY = area.size_h / 2;
+ short [] absX = new short [1], absY = new short [1];
+ OS.PtGetAbsPosition (handle, absX, absY);
+ OS.PhMoveCursorAbs (OS.PhInputGroup (0), cursorX + absX [0], cursorY + absY [0]);
+ }
+ return result;
+ }
+ }
+ return result;
+}
+
+int widgetClass () {
+ return OS.PtContainer ();
+}
+
+}
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
index b9065e6395..8a96ccf0d6 100755
--- 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
@@ -1,17 +1,17 @@
-package org.eclipse.swt.widgets;
-
-/*
+package org.eclipse.swt.widgets;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-import org.eclipse.swt.internal.photon.*;
-import org.eclipse.swt.*;
-import org.eclipse.swt.graphics.*;
-import org.eclipse.swt.events.*;
-
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+import org.eclipse.swt.internal.photon.*;
+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
@@ -30,9 +30,9 @@ import org.eclipse.swt.events.*;
* within the SWT implementation.
* </p>
*/
-public class Scale extends Control {
-
-
+public class Scale extends Control {
+
+
/**
* Constructs a new instance of this class given its parent
* and a style value describing its behavior and appearance.
@@ -62,10 +62,10 @@ public class Scale extends Control {
* @see Widget#checkSubclass
* @see Widget#getStyle
*/
-public Scale (Composite parent, int style) {
- super (parent, checkStyle (style));
-}
-
+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
@@ -85,67 +85,67 @@ public Scale (Composite parent, int style) {
* @see SelectionListener
* @see #removeSelectionListener
*/
-public void addSelectionListener(SelectionListener listener) {
- checkWidget();
- if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
- TypedListener typedListener = new TypedListener (listener);
- addListener (SWT.Selection,typedListener);
- addListener (SWT.DefaultSelection,typedListener);
-}
-
-static int checkStyle (int style) {
- return checkBits (style, SWT.HORIZONTAL, SWT.VERTICAL, 0, 0, 0, 0);
-}
-
-public Point computeSize (int wHint, int hHint, boolean changed) {
- checkWidget();
- PhDim_t dim = new PhDim_t();
- if (!OS.PtWidgetIsRealized (handle)) OS.PtExtentWidget (handle);
- OS.PtWidgetPreferredSize(handle, dim);
- /*
- * Feature in Photon. The preferred size of PtSlider is only the
- * handle size. Add extra space for the rest.
- */
- int width, height;
- if ((style & SWT.HORIZONTAL) != 0) {
- width = dim.w * 7; height = dim.h * 2;
- } else {
- width = dim.w * 2; height = dim.h * 7;
- }
- 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) {
- state |= HANDLE;
- Display display = getDisplay ();
- int clazz = display.PtSlider;
- int parentHandle = parent.parentingHandle ();
- 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_FILL_COLOR, display.WIDGET_BACKGROUND, 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);
-}
-
-byte [] defaultFont () {
- Display display = getDisplay ();
- return display.GAUGE_FONT;
-}
-
+public void addSelectionListener(SelectionListener listener) {
+ checkWidget();
+ if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+ TypedListener typedListener = new TypedListener (listener);
+ addListener (SWT.Selection,typedListener);
+ addListener (SWT.DefaultSelection,typedListener);
+}
+
+static int checkStyle (int style) {
+ return checkBits (style, SWT.HORIZONTAL, SWT.VERTICAL, 0, 0, 0, 0);
+}
+
+public Point computeSize (int wHint, int hHint, boolean changed) {
+ checkWidget();
+ PhDim_t dim = new PhDim_t();
+ if (!OS.PtWidgetIsRealized (handle)) OS.PtExtentWidget (handle);
+ OS.PtWidgetPreferredSize(handle, dim);
+ /*
+ * Feature in Photon. The preferred size of PtSlider is only the
+ * handle size. Add extra space for the rest.
+ */
+ int width, height;
+ if ((style & SWT.HORIZONTAL) != 0) {
+ width = dim.w * 7; height = dim.h * 2;
+ } else {
+ width = dim.w * 2; height = dim.h * 7;
+ }
+ 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) {
+ state |= HANDLE;
+ Display display = getDisplay ();
+ int clazz = display.PtSlider;
+ int parentHandle = parent.parentingHandle ();
+ 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_FILL_COLOR, display.WIDGET_BACKGROUND, 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);
+}
+
+byte [] defaultFont () {
+ Display display = getDisplay ();
+ return display.GAUGE_FONT;
+}
+
/**
* Returns the amount that the receiver's value will be
* modified by when the up/down (or right/left) arrows
@@ -158,13 +158,13 @@ byte [] defaultFont () {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public int getIncrement () {
- checkWidget();
- int [] args = {OS.Pt_ARG_INCREMENT, 0, 0};
- OS.PtGetResources (handle, args.length / 3, args);
- return args [1];
-}
-
+public int getIncrement () {
+ checkWidget();
+ int [] args = {OS.Pt_ARG_INCREMENT, 0, 0};
+ OS.PtGetResources (handle, args.length / 3, args);
+ return args [1];
+}
+
/**
* Returns the maximum value which the receiver will allow.
*
@@ -175,13 +175,13 @@ public int getIncrement () {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public int getMaximum () {
- checkWidget();
- int [] args = {OS.Pt_ARG_MAXIMUM, 0, 0};
- OS.PtGetResources (handle, args.length / 3, args);
- return args [1];
-}
-
+public int getMaximum () {
+ checkWidget();
+ int [] args = {OS.Pt_ARG_MAXIMUM, 0, 0};
+ OS.PtGetResources (handle, args.length / 3, args);
+ return args [1];
+}
+
/**
* Returns the minimum value which the receiver will allow.
*
@@ -192,13 +192,13 @@ public int getMaximum () {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public int getMinimum () {
- checkWidget();
- int [] args = {OS.Pt_ARG_MINIMUM, 0, 0};
- OS.PtGetResources (handle, args.length / 3, args);
- return args [1];
-}
-
+public int getMinimum () {
+ checkWidget();
+ int [] args = {OS.Pt_ARG_MINIMUM, 0, 0};
+ OS.PtGetResources (handle, args.length / 3, args);
+ return args [1];
+}
+
/**
* Returns the amount that the receiver's value will be
* modified by when the page increment/decrement areas
@@ -211,13 +211,13 @@ public int getMinimum () {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public int getPageIncrement () {
- checkWidget();
- int [] args = {OS.Pt_ARG_PAGE_INCREMENT, 0, 0};
- OS.PtGetResources (handle, args.length / 3, args);
- return args [1];
-}
-
+public int getPageIncrement () {
+ checkWidget();
+ int [] args = {OS.Pt_ARG_PAGE_INCREMENT, 0, 0};
+ OS.PtGetResources (handle, args.length / 3, args);
+ return args [1];
+}
+
/**
* Returns the single <em>selection</em> that is the receiver's position.
*
@@ -228,25 +228,25 @@ public int getPageIncrement () {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public int getSelection () {
- checkWidget();
- int [] args = {OS.Pt_ARG_GAUGE_VALUE, 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_SLIDER_MOVE, windowProc, OS.Pt_CB_SLIDER_MOVE);
-}
-
-int Pt_CB_SLIDER_MOVE (int widget, int info) {
- if (info == 0) return OS.Pt_CONTINUE;
- sendEvent(SWT.Selection);
- return OS.Pt_CONTINUE;
-}
-
+public int getSelection () {
+ checkWidget();
+ int [] args = {OS.Pt_ARG_GAUGE_VALUE, 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_SLIDER_MOVE, windowProc, OS.Pt_CB_SLIDER_MOVE);
+}
+
+int Pt_CB_SLIDER_MOVE (int widget, int info) {
+ if (info == 0) return OS.Pt_CONTINUE;
+ sendEvent(SWT.Selection);
+ return OS.Pt_CONTINUE;
+}
+
/**
* Removes the listener from the collection of listeners who will
* be notified when the receiver's value changes.
@@ -264,14 +264,14 @@ int Pt_CB_SLIDER_MOVE (int widget, int info) {
* @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);
-}
-
+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
@@ -285,11 +285,11 @@ public void removeSelectionListener(SelectionListener listener) {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public void setIncrement (int value) {
- checkWidget();
- OS.PtSetResource (handle, OS.Pt_ARG_INCREMENT, value, 0);
-}
-
+public void setIncrement (int value) {
+ checkWidget();
+ OS.PtSetResource (handle, OS.Pt_ARG_INCREMENT, value, 0);
+}
+
/**
* Sets the maximum value which the receiver will allow
* to be the argument which must be greater than or
@@ -302,11 +302,11 @@ public void setIncrement (int value) {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public void setMaximum (int value) {
- checkWidget();
- OS.PtSetResource (handle, OS.Pt_ARG_MAXIMUM, value - 1, 0);
-}
-
+public void setMaximum (int value) {
+ checkWidget();
+ OS.PtSetResource (handle, OS.Pt_ARG_MAXIMUM, value - 1, 0);
+}
+
/**
* Sets the minimum value which the receiver will allow
* to be the argument which must be greater than or
@@ -319,11 +319,11 @@ public void setMaximum (int value) {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public void setMinimum (int value) {
- checkWidget();
- OS.PtSetResource (handle, OS.Pt_ARG_MINIMUM, value, 0);
-}
-
+public void setMinimum (int value) {
+ checkWidget();
+ OS.PtSetResource (handle, OS.Pt_ARG_MINIMUM, value, 0);
+}
+
/**
* Sets the amount that the receiver's value will be
* modified by when the page increment/decrement areas
@@ -337,11 +337,11 @@ public void setMinimum (int value) {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public void setPageIncrement (int value) {
- checkWidget();
- OS.PtSetResource (handle, OS.Pt_ARG_PAGE_INCREMENT, value, 0);
-}
-
+public void setPageIncrement (int value) {
+ checkWidget();
+ OS.PtSetResource (handle, OS.Pt_ARG_PAGE_INCREMENT, value, 0);
+}
+
/**
* Sets the single <em>selection</em> that is the receiver's
* value to the argument which must be greater than or equal
@@ -354,13 +354,13 @@ public void setPageIncrement (int value) {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public void setSelection (int value) {
- checkWidget();
- OS.PtSetResource (handle, OS.Pt_ARG_GAUGE_VALUE, value, 0);
-}
-
-int widgetClass () {
- return OS.PtSlider ();
-}
-
-}
+public void setSelection (int value) {
+ checkWidget();
+ OS.PtSetResource (handle, OS.Pt_ARG_GAUGE_VALUE, value, 0);
+}
+
+int widgetClass () {
+ return OS.PtSlider ();
+}
+
+}
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
index ede7446d6f..9dcd537e80 100755
--- 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
@@ -1,17 +1,17 @@
-package org.eclipse.swt.widgets;
-
-/*
+package org.eclipse.swt.widgets;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-import org.eclipse.swt.internal.photon.*;
-import org.eclipse.swt.*;
-import org.eclipse.swt.graphics.*;
-import org.eclipse.swt.events.*;
-
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+import org.eclipse.swt.internal.photon.*;
+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.
@@ -75,27 +75,27 @@ import org.eclipse.swt.events.*;
* @see Scrollable#getHorizontalBar
* @see Scrollable#getVerticalBar
*/
-public class ScrollBar extends Widget {
- Scrollable parent;
-
-ScrollBar (Scrollable parent, int style, int handle) {
- super (parent, checkStyle (style));
- this.parent = parent;
- this.handle = handle;
- state |= 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 class ScrollBar extends Widget {
+ Scrollable parent;
+
+ScrollBar (Scrollable parent, int style, int handle) {
+ super (parent, checkStyle (style));
+ this.parent = parent;
+ this.handle = handle;
+ state |= 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);
+}
+
/**
* Adds the listener to the collection of listeners who will
* be notified when the receiver's value changes, by sending
@@ -128,51 +128,51 @@ static int checkStyle (int style) {
* @see #removeSelectionListener
* @see SelectionEvent
*/
-public void addSelectionListener (SelectionListener listener) {
- checkWidget();
- if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
- TypedListener typedListener = new TypedListener(listener);
- addListener (SWT.Selection,typedListener);
- addListener (SWT.DefaultSelection,typedListener);
-}
-
-void createHandle (int index) {
- state |= HANDLE;
- if (handle != 0) return;
- Display display = getDisplay ();
- int parentHandle = parent.scrolledHandle;
- int orientation, sizeArg, size, basicFlags;
- if ((style & SWT.HORIZONTAL) != 0) {
- orientation = OS.Pt_HORIZONTAL;
- sizeArg = OS.Pt_ARG_HEIGHT;
- size = display.SCROLLBAR_HEIGHT;
- basicFlags = display.SCROLLBAR_HORIZONTAL_BASIC_FLAGS;
- } else {
- orientation = OS.Pt_VERTICAL;
- sizeArg = OS.Pt_ARG_WIDTH;
- size = display.SCROLLBAR_WIDTH;
- basicFlags = display.SCROLLBAR_VERTICAL_BASIC_FLAGS;
- }
- int [] args = {
- sizeArg, size, 0,
- OS.Pt_ARG_MAXIMUM, 100, 0,
- OS.Pt_ARG_PAGE_INCREMENT, 10, 0,
- OS.Pt_ARG_SLIDER_SIZE, 10, 0,
- OS.Pt_ARG_BASIC_FLAGS, basicFlags, ~0,
- OS.Pt_ARG_ORIENTATION, orientation, 0,
- OS.Pt_ARG_FLAGS, 0, OS.Pt_GETS_FOCUS,
- 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);
-}
-
-public Display getDisplay () {
- Scrollable parent = this.parent;
- if (parent == null) error (SWT.ERROR_WIDGET_DISPOSED);
- return parent.getDisplay ();
-}
-
+public void addSelectionListener (SelectionListener listener) {
+ checkWidget();
+ if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+ TypedListener typedListener = new TypedListener(listener);
+ addListener (SWT.Selection,typedListener);
+ addListener (SWT.DefaultSelection,typedListener);
+}
+
+void createHandle (int index) {
+ state |= HANDLE;
+ if (handle != 0) return;
+ Display display = getDisplay ();
+ int parentHandle = parent.scrolledHandle;
+ int orientation, sizeArg, size, basicFlags;
+ if ((style & SWT.HORIZONTAL) != 0) {
+ orientation = OS.Pt_HORIZONTAL;
+ sizeArg = OS.Pt_ARG_HEIGHT;
+ size = display.SCROLLBAR_HEIGHT;
+ basicFlags = display.SCROLLBAR_HORIZONTAL_BASIC_FLAGS;
+ } else {
+ orientation = OS.Pt_VERTICAL;
+ sizeArg = OS.Pt_ARG_WIDTH;
+ size = display.SCROLLBAR_WIDTH;
+ basicFlags = display.SCROLLBAR_VERTICAL_BASIC_FLAGS;
+ }
+ int [] args = {
+ sizeArg, size, 0,
+ OS.Pt_ARG_MAXIMUM, 100, 0,
+ OS.Pt_ARG_PAGE_INCREMENT, 10, 0,
+ OS.Pt_ARG_SLIDER_SIZE, 10, 0,
+ OS.Pt_ARG_BASIC_FLAGS, basicFlags, ~0,
+ OS.Pt_ARG_ORIENTATION, orientation, 0,
+ OS.Pt_ARG_FLAGS, 0, OS.Pt_GETS_FOCUS,
+ 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);
+}
+
+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
@@ -186,12 +186,12 @@ public Display getDisplay () {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public boolean getEnabled () {
- checkWidget ();
- int topHandle = topHandle ();
- return (OS.PtWidgetFlags (topHandle) & OS.Pt_BLOCKED) == 0;
-}
-
+public boolean getEnabled () {
+ checkWidget ();
+ int topHandle = topHandle ();
+ return (OS.PtWidgetFlags (topHandle) & OS.Pt_BLOCKED) == 0;
+}
+
/**
* Returns the amount that the receiver's value will be
* modified by when the up/down (or right/left) arrows
@@ -204,13 +204,13 @@ public boolean getEnabled () {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public int getIncrement () {
- checkWidget();
- int [] args = {OS.Pt_ARG_INCREMENT, 0, 0};
- OS.PtGetResources (handle, args.length / 3, args);
- return args [1];
-}
-
+public int getIncrement () {
+ checkWidget();
+ int [] args = {OS.Pt_ARG_INCREMENT, 0, 0};
+ OS.PtGetResources (handle, args.length / 3, args);
+ return args [1];
+}
+
/**
* Returns the minimum value which the receiver will allow.
*
@@ -221,13 +221,13 @@ public int getIncrement () {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public int getMinimum () {
- checkWidget();
- int [] args = {OS.Pt_ARG_MINIMUM, 0, 0};
- OS.PtGetResources (handle, args.length / 3, args);
- return args [1];
-}
-
+public int getMinimum () {
+ checkWidget();
+ int [] args = {OS.Pt_ARG_MINIMUM, 0, 0};
+ OS.PtGetResources (handle, args.length / 3, args);
+ return args [1];
+}
+
/**
* Returns the maximum value which the receiver will allow.
*
@@ -238,13 +238,13 @@ public int getMinimum () {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public int getMaximum () {
- checkWidget();
- int [] args = {OS.Pt_ARG_MAXIMUM, 0, 0};
- OS.PtGetResources (handle, args.length / 3, args);
- return args [1];
-}
-
+public int getMaximum () {
+ checkWidget();
+ int [] args = {OS.Pt_ARG_MAXIMUM, 0, 0};
+ OS.PtGetResources (handle, args.length / 3, args);
+ return args [1];
+}
+
/**
* Returns the amount that the receiver's value will be
* modified by when the page increment/decrement areas
@@ -257,13 +257,13 @@ public int getMaximum () {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public int getPageIncrement () {
- checkWidget();
- int [] args = {OS.Pt_ARG_PAGE_INCREMENT, 0, 0};
- OS.PtGetResources (handle, args.length / 3, args);
- return args [1];
-}
-
+public int getPageIncrement () {
+ checkWidget();
+ int [] args = {OS.Pt_ARG_PAGE_INCREMENT, 0, 0};
+ OS.PtGetResources (handle, args.length / 3, args);
+ return args [1];
+}
+
/**
* Returns the receiver's parent, which must be scrollable.
*
@@ -274,11 +274,11 @@ public int getPageIncrement () {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public Scrollable getParent () {
- checkWidget();
- return parent;
-}
-
+public Scrollable getParent () {
+ checkWidget();
+ return parent;
+}
+
/**
* Returns the single <em>selection</em> that is the receiver's value.
*
@@ -289,33 +289,33 @@ public Scrollable getParent () {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public int getSelection () {
- checkWidget();
- int [] args = {OS.Pt_ARG_GAUGE_VALUE, 0, 0};
- OS.PtGetResources (handle, args.length / 3, args);
- return args [1];
-}
-
-/**
- * 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 int getSelection () {
+ checkWidget();
+ int [] args = {OS.Pt_ARG_GAUGE_VALUE, 0, 0};
+ OS.PtGetResources (handle, args.length / 3, args);
+ return args [1];
+}
+
+/**
+ * Returns a point describing the receiver's size. The
+ * x coordinate of the result is the width of the receiver.
+ * The y coordinate of the result is the height of the
+ * receiver.
+ *
+ * @return the receiver's size
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
*/
-public Point getSize () {
- checkWidget();
- int [] 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 Point getSize () {
+ checkWidget();
+ 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]);
+}
+
/**
* Answers the size of the receiver's thumb relative to the
* difference between its maximum and minimum values.
@@ -329,13 +329,13 @@ public Point getSize () {
*
* @see ScrollBar
*/
-public int getThumb () {
- checkWidget();
- int [] args = {OS.Pt_ARG_SLIDER_SIZE, 0, 0};
- OS.PtGetResources (handle, args.length / 3, args);
- return args [1];
-}
-
+public int getThumb () {
+ checkWidget();
+ int [] args = {OS.Pt_ARG_SLIDER_SIZE, 0, 0};
+ OS.PtGetResources (handle, args.length / 3, args);
+ return args [1];
+}
+
/**
* Returns <code>true</code> if the receiver is visible, and
* <code>false</code> otherwise.
@@ -353,91 +353,91 @@ public int getThumb () {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public boolean getVisible () {
- checkWidget ();
- int topHandle = topHandle ();
- return (OS.PtWidgetFlags (topHandle) & OS.Pt_DELAY_REALIZE) == 0;
-}
-
-void hookEvents () {
- int windowProc = getDisplay ().windowProc;
- OS.PtAddCallback (handle, OS.Pt_CB_SCROLL_MOVE, windowProc, OS.Pt_CB_SCROLL_MOVE);
-}
-
-/**
- * Returns <code>true</code> if the receiver is enabled and all
- * of the receiver's ancestors are enabled, and <code>false</code>
- * otherwise. A disabled control is typically not selectable from the
- * user interface and draws with an inactive or "grayed" look.
- *
- * @return the receiver's enabled state
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see #getEnabled
+public boolean getVisible () {
+ checkWidget ();
+ int topHandle = topHandle ();
+ return (OS.PtWidgetFlags (topHandle) & OS.Pt_DELAY_REALIZE) == 0;
+}
+
+void hookEvents () {
+ int windowProc = getDisplay ().windowProc;
+ OS.PtAddCallback (handle, OS.Pt_CB_SCROLL_MOVE, windowProc, OS.Pt_CB_SCROLL_MOVE);
+}
+
+/**
+ * Returns <code>true</code> if the receiver is enabled and all
+ * of the receiver's ancestors are enabled, and <code>false</code>
+ * otherwise. A disabled control is typically not selectable from the
+ * user interface and draws with an inactive or "grayed" look.
+ *
+ * @return the receiver's enabled state
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see #getEnabled
*/
-public boolean isEnabled () {
- checkWidget();
- return getEnabled () && parent.isEnabled ();
-}
-
-/**
- * Returns <code>true</code> if the receiver is visible and all
- * of the receiver's ancestors are visible and <code>false</code>
- * otherwise.
- *
- * @return the receiver's visibility state
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see #getVisible
+public boolean isEnabled () {
+ checkWidget();
+ return getEnabled () && parent.isEnabled ();
+}
+
+/**
+ * Returns <code>true</code> if the receiver is visible and all
+ * of the receiver's ancestors are visible and <code>false</code>
+ * otherwise.
+ *
+ * @return the receiver's visibility state
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see #getVisible
*/
-public boolean isVisible () {
- checkWidget();
- return OS.PtWidgetIsRealized (handle);
-}
-
-int Pt_CB_SCROLL_MOVE (int widget, 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 boolean isVisible () {
+ checkWidget();
+ return OS.PtWidgetIsRealized (handle);
+}
+
+int Pt_CB_SCROLL_MOVE (int widget, 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;
+}
+
/**
* Removes the listener from the collection of listeners who will
* be notified when the receiver's value changes.
@@ -455,26 +455,26 @@ int Pt_CB_SCROLL_MOVE (int widget, int info) {
* @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) {
- 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);
- OS.PtSetResource (handle, OS.Pt_ARG_AREA, ptr, 0);
- OS.free (ptr);
-}
-
+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) {
+ 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);
+ OS.PtSetResource (handle, OS.Pt_ARG_AREA, ptr, 0);
+ OS.free (ptr);
+}
+
/**
* Enables the receiver if the argument is <code>true</code>,
* and disables it otherwise. A disabled control is typically
@@ -488,12 +488,12 @@ void setBounds (int x, int y, int width, int height) {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public void setEnabled (boolean enabled) {
- checkWidget ();
- int topHandle = topHandle ();
- int flags = enabled ? 0 : OS.Pt_BLOCKED | OS.Pt_GHOST;
- OS.PtSetResource (topHandle, OS.Pt_ARG_FLAGS, flags, OS.Pt_BLOCKED | OS.Pt_GHOST);
-}
+public void setEnabled (boolean enabled) {
+ checkWidget ();
+ int topHandle = topHandle ();
+ int flags = enabled ? 0 : OS.Pt_BLOCKED | OS.Pt_GHOST;
+ OS.PtSetResource (topHandle, OS.Pt_ARG_FLAGS, flags, OS.Pt_BLOCKED | OS.Pt_GHOST);
+}
/**
* Sets the amount that the receiver's value will be
* modified by when the up/down (or right/left) arrows
@@ -507,11 +507,11 @@ public void setEnabled (boolean enabled) {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public void setIncrement (int value) {
- checkWidget();
- OS.PtSetResource (handle, OS.Pt_ARG_INCREMENT, value, 0);
-}
-
+public void setIncrement (int value) {
+ checkWidget();
+ OS.PtSetResource (handle, OS.Pt_ARG_INCREMENT, value, 0);
+}
+
/**
* Sets the maximum value which the receiver will allow
* to be the argument which must be greater than or
@@ -524,11 +524,11 @@ public void setIncrement (int value) {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public void setMaximum (int value) {
- checkWidget();
- OS.PtSetResource (handle, OS.Pt_ARG_MAXIMUM, value - 1, 0);
-}
-
+public void setMaximum (int value) {
+ checkWidget();
+ OS.PtSetResource (handle, OS.Pt_ARG_MAXIMUM, value - 1, 0);
+}
+
/**
* Sets the minimum value which the receiver will allow
* to be the argument which must be greater than or
@@ -541,11 +541,11 @@ public void setMaximum (int value) {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public void setMinimum (int value) {
- checkWidget();
- OS.PtSetResource (handle, OS.Pt_ARG_MINIMUM, value, 0);
-}
-
+public void setMinimum (int value) {
+ checkWidget();
+ OS.PtSetResource (handle, OS.Pt_ARG_MINIMUM, value, 0);
+}
+
/**
* Sets the amount that the receiver's value will be
* modified by when the page increment/decrement areas
@@ -559,11 +559,11 @@ public void setMinimum (int value) {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public void setPageIncrement (int value) {
- checkWidget();
- OS.PtSetResource (handle, OS.Pt_ARG_PAGE_INCREMENT, value, 0);
-}
-
+public void setPageIncrement (int value) {
+ checkWidget();
+ OS.PtSetResource (handle, OS.Pt_ARG_PAGE_INCREMENT, value, 0);
+}
+
/**
* Sets the single <em>selection</em> that is the receiver's
* value to the argument which must be greater than or equal
@@ -576,11 +576,11 @@ public void setPageIncrement (int value) {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public void setSelection (int value) {
- checkWidget();
- OS.PtSetResource (handle, OS.Pt_ARG_GAUGE_VALUE, value, 0);
-}
-
+public void setSelection (int value) {
+ checkWidget();
+ OS.PtSetResource (handle, OS.Pt_ARG_GAUGE_VALUE, value, 0);
+}
+
/**
* Sets the size of the receiver's thumb relative to the
* difference between its maximum and minimum values to the
@@ -595,11 +595,11 @@ public void setSelection (int value) {
*
* @see ScrollBar
*/
-public void setThumb (int value) {
- checkWidget();
- OS.PtSetResource (handle, OS.Pt_ARG_SLIDER_SIZE, value, 0);
-}
-
+public void setThumb (int value) {
+ checkWidget();
+ OS.PtSetResource (handle, OS.Pt_ARG_SLIDER_SIZE, value, 0);
+}
+
/**
* Sets the receiver's selection, minimum value, maximum
* value, thumb, increment and page increment all at once.
@@ -621,25 +621,25 @@ public void setThumb (int value) {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public void setValues (int selection, int minimum, int maximum, int thumb, int increment, int pageIncrement) {
- checkWidget();
- if (minimum < 0) return;
- if (maximum < 0) return;
- if (thumb < 1) return;
- if (maximum - minimum - thumb < 0) return;
- if (increment < 1) return;
- if (pageIncrement < 1) return;
- int [] args = {
- OS.Pt_ARG_GAUGE_VALUE, 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 setValues (int selection, int minimum, int maximum, int thumb, int increment, int pageIncrement) {
+ checkWidget();
+ if (minimum < 0) return;
+ if (maximum < 0) return;
+ if (thumb < 1) return;
+ if (maximum - minimum - thumb < 0) return;
+ if (increment < 1) return;
+ if (pageIncrement < 1) return;
+ int [] args = {
+ OS.Pt_ARG_GAUGE_VALUE, 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);
+}
+
/**
* Marks the receiver as visible if the argument is <code>true</code>,
* and marks it invisible otherwise.
@@ -656,23 +656,23 @@ public void setValues (int selection, int minimum, int maximum, int thumb, int i
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public void setVisible (boolean visible) {
- checkWidget ();
- int topHandle = topHandle ();
- int flags = visible ? 0 : OS.Pt_DELAY_REALIZE;
- OS.PtSetResource (topHandle, OS.Pt_ARG_FLAGS, flags, OS.Pt_DELAY_REALIZE);
- if (OS.PtWidgetIsRealized (parent.handle)) {
- if (visible != OS.PtWidgetIsRealized (topHandle)) {
- if (visible) {
- sendEvent (SWT.Show);
- OS.PtRealizeWidget (topHandle);
- } else {
- OS.PtUnrealizeWidget (topHandle);
- sendEvent(SWT.Hide);
- }
- }
- }
- parent.resizeClientArea ();
-}
-
-}
+public void setVisible (boolean visible) {
+ checkWidget ();
+ int topHandle = topHandle ();
+ int flags = visible ? 0 : OS.Pt_DELAY_REALIZE;
+ OS.PtSetResource (topHandle, OS.Pt_ARG_FLAGS, flags, OS.Pt_DELAY_REALIZE);
+ if (OS.PtWidgetIsRealized (parent.handle)) {
+ if (visible != OS.PtWidgetIsRealized (topHandle)) {
+ if (visible) {
+ sendEvent (SWT.Show);
+ OS.PtRealizeWidget (topHandle);
+ } else {
+ OS.PtUnrealizeWidget (topHandle);
+ sendEvent(SWT.Hide);
+ }
+ }
+ }
+ parent.resizeClientArea ();
+}
+
+}
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
index afae5b9b27..f0abe1bf35 100755
--- 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
@@ -1,16 +1,16 @@
-package org.eclipse.swt.widgets;
-
-/*
+package org.eclipse.swt.widgets;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-import org.eclipse.swt.internal.photon.*;
-import org.eclipse.swt.*;
-import org.eclipse.swt.graphics.*;
-
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+import org.eclipse.swt.internal.photon.*;
+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.
@@ -25,14 +25,14 @@ import org.eclipse.swt.graphics.*;
* within the SWT implementation.
* </p>
*/
-public abstract class Scrollable extends Control {
- int scrolledHandle;
- ScrollBar horizontalBar, verticalBar;
-
-Scrollable () {
- /* Do nothing */
-}
-
+public abstract class Scrollable extends Control {
+ int scrolledHandle;
+ ScrollBar horizontalBar, verticalBar;
+
+Scrollable () {
+ /* Do nothing */
+}
+
/**
* Constructs a new instance of this class given its parent
* and a style value describing its behavior and appearance.
@@ -62,39 +62,39 @@ Scrollable () {
* @see Widget#checkSubclass
* @see Widget#getStyle
*/
-public Scrollable (Composite parent, int style) {
- super (parent, style);
-}
-
-void createStandardScrollBars () {
- /* 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:
- if ((style & SWT.H_SCROLL) != 0) {
- horizontalBar = new ScrollBar (this, SWT.HORIZONTAL, child);
- }
- break;
- case OS.Pt_VERTICAL:
- if ((style & SWT.V_SCROLL) != 0) {
- verticalBar = new ScrollBar (this, SWT.VERTICAL, child);
- }
- break;
- }
- }
- child = OS.PtWidgetBrotherBehind (child);
- }
-}
-
-void deregister () {
- super.deregister ();
- if (scrolledHandle != 0) WidgetTable.remove (scrolledHandle);
-}
-
+public Scrollable (Composite parent, int style) {
+ super (parent, style);
+}
+
+void createStandardScrollBars () {
+ /* 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:
+ if ((style & SWT.H_SCROLL) != 0) {
+ horizontalBar = new ScrollBar (this, SWT.HORIZONTAL, child);
+ }
+ break;
+ case OS.Pt_VERTICAL:
+ if ((style & SWT.V_SCROLL) != 0) {
+ verticalBar = new ScrollBar (this, SWT.VERTICAL, child);
+ }
+ break;
+ }
+ }
+ child = OS.PtWidgetBrotherBehind (child);
+ }
+}
+
+void deregister () {
+ super.deregister ();
+ if (scrolledHandle != 0) WidgetTable.remove (scrolledHandle);
+}
+
/**
* Given a desired <em>client area</em> for the receiver
* (as described by the arguments), returns the bounding
@@ -118,26 +118,26 @@ void deregister () {
*
* @see #getClientArea
*/
-public Rectangle computeTrim (int x, int y, int width, int height) {
- checkWidget();
- 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) {
- Point size = horizontalBar.getSize ();
- area.size_h += size.y;
- }
- if (verticalBar != null) {
- 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 computeTrim (int x, int y, int width, int height) {
+ checkWidget();
+ 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) {
+ Point size = horizontalBar.getSize ();
+ area.size_h += size.y;
+ }
+ if (verticalBar != null) {
+ Point size = verticalBar.getSize ();
+ area.size_w += size.x;
+ }
+ return new Rectangle (area.pos_x, area.pos_y, area.size_w, area.size_h);
+}
+
/**
* Returns a rectangle which describes the area of the
* receiver which is capable of displaying data (that is,
@@ -152,17 +152,17 @@ public Rectangle computeTrim (int x, int y, int width, int height) {
*
* @see #computeTrim
*/
-public Rectangle getClientArea () {
- checkWidget();
- PhRect_t rect = new PhRect_t ();
- int validParent = OS.PtValidParent (handle, OS.PtContainer ());
- if (!OS.PtWidgetIsRealized (handle)) OS.PtExtentWidgetFamily (handle);
- OS.PtCalcCanvas (validParent, 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 Rectangle getClientArea () {
+ checkWidget();
+ PhRect_t rect = new PhRect_t ();
+ int validParent = OS.PtValidParent (handle, OS.PtContainer ());
+ if (!OS.PtWidgetIsRealized (handle)) OS.PtExtentWidgetFamily (handle);
+ OS.PtCalcCanvas (validParent, 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);
+}
+
/**
* Returns the receiver's horizontal scroll bar if it has
* one, and null if it does not.
@@ -174,11 +174,11 @@ public Rectangle getClientArea () {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public ScrollBar getHorizontalBar () {
- checkWidget();
- return horizontalBar;
-}
-
+public ScrollBar getHorizontalBar () {
+ checkWidget();
+ return horizontalBar;
+}
+
/**
* Returns the receiver's vertical scroll bar if it has
* one, and null if it does not.
@@ -190,40 +190,40 @@ public ScrollBar getHorizontalBar () {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public ScrollBar getVerticalBar () {
- checkWidget();
- return verticalBar;
-}
-
-boolean isTabGroup () {
- if ((state & CANVAS) != 0) return true;
- return super.isTabGroup ();
-}
-
-void releaseHandle () {
- super.releaseHandle ();
- scrolledHandle = 0;
-}
-
-void resizeClientArea () {
- /* Do nothing */
-}
-
-void releaseWidget () {
- if (horizontalBar != null) horizontalBar.releaseResources ();
- if (verticalBar != null) verticalBar.releaseResources ();
- 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;
-}
-
-}
+public ScrollBar getVerticalBar () {
+ checkWidget();
+ return verticalBar;
+}
+
+boolean isTabGroup () {
+ if ((state & CANVAS) != 0) return true;
+ return super.isTabGroup ();
+}
+
+void releaseHandle () {
+ super.releaseHandle ();
+ scrolledHandle = 0;
+}
+
+void resizeClientArea () {
+ /* Do nothing */
+}
+
+void releaseWidget () {
+ if (horizontalBar != null) horizontalBar.releaseResources ();
+ if (verticalBar != null) verticalBar.releaseResources ();
+ 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/Shell.java b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Shell.java
index 5c880743c9..9c5fa115f1 100755
--- 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
@@ -1,107 +1,107 @@
-package org.eclipse.swt.widgets;
-
-/*
+package org.eclipse.swt.widgets;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-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.*;
-
-/**
- * Instances of this class represent the "windows"
- * which the desktop or "window manager" is managing.
- * Instances that do not have a parent (that is, they
- * are built using the constructor, which takes a
- * <code>Display</code> as the argument) are described
- * as <em>top level</em> shells. Instances that do have
- * a parent are described as <em>secondary</em> or
- * <em>dialog</em> shells.
- * <p>
- * Instances are always displayed in one of the maximized,
- * minimized or normal states:
- * <ul>
- * <li>
- * When an instance is marked as <em>maximized</em>, the
- * window manager will typically resize it to fill the
- * entire visible area of the display, and the instance
- * is usually put in a state where it can not be resized
- * (even if it has style <code>RESIZE</code>) until it is
- * no longer maximized.
- * </li><li>
- * When an instance is in the <em>normal</em> state (neither
- * maximized or minimized), its appearance is controlled by
- * the style constants which were specified when it was created
- * and the restrictions of the window manager (see below).
- * </li><li>
- * When an instance has been marked as <em>minimized</em>,
- * its contents (client area) will usually not be visible,
- * and depending on the window manager, it may be
- * "iconified" (that is, replaced on the desktop by a small
- * simplified representation of itself), relocated to a
- * distinguished area of the screen, or hidden. Combinations
- * of these changes are also possible.
- * </li>
- * </ul>
- * </p>
- * <p>
- * 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
- * and modality. For example, some window managers only
- * support resizable windows and will always assume the
- * RESIZE style, even if it is not set. In addition, if a
- * modality style is not supported, it is "upgraded" to a
- * more restrictive modality style that is supported. For
- * example, if <code>PRIMARY_MODAL</code> is not supported,
- * it would be upgraded to <code>APPLICATION_MODAL</code>.
- * <dl>
- * <dt><b>Styles:</b></dt>
- * <dd>BORDER, CLOSE, MIN, MAX, NO_TRIM, RESIZE, TITLE</dd>
- * <dd>APPLICATION_MODAL, MODELESS, PRIMARY_MODAL, SYSTEM_MODAL</dd>
- * <dt><b>Events:</b></dt>
- * <dd>Activate, Close, Deactivate, Deiconify, Iconify</dd>
- * </dl>
- * Class <code>SWT</code> provides two "convenience constants"
- * for the most commonly required style combinations:
- * <dl>
- * <dt><code>SHELL_TRIM</code></dt>
- * <dd>
- * the result of combining the constants which are required
- * to produce a typical application top level shell: (that
- * is, <code>CLOSE | TITLE | MIN | MAX | RESIZE</code>)
- * </dd>
- * <dt><code>DIALOG_TRIM</code></dt>
- * <dd>
- * the result of combining the constants which are required
- * to produce a typical application dialog shell: (that
- * is, <code>TITLE | CLOSE | BORDER</code>)
- * </dd>
- * </dl>
- * </p>
- * <p>
- * Note: Only one of the styles APPLICATION_MODAL, MODELESS,
- * PRIMARY_MODAL and SYSTEM_MODAL may be specified.
- * </p><p>
- * IMPORTANT: This class is not intended to be subclassed.
- * </p>
- *
- * @see Decorations
- * @see SWT
+ * http://www.eclipse.org/legal/cpl-v10.html
*/
-public class Shell extends Decorations {
- int shellHandle;
- Display display;
- Menu activeMenu;
- int blockedList;
- Control lastActive;
-
+
+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.*;
+
+/**
+ * Instances of this class represent the "windows"
+ * which the desktop or "window manager" is managing.
+ * Instances that do not have a parent (that is, they
+ * are built using the constructor, which takes a
+ * <code>Display</code> as the argument) are described
+ * as <em>top level</em> shells. Instances that do have
+ * a parent are described as <em>secondary</em> or
+ * <em>dialog</em> shells.
+ * <p>
+ * Instances are always displayed in one of the maximized,
+ * minimized or normal states:
+ * <ul>
+ * <li>
+ * When an instance is marked as <em>maximized</em>, the
+ * window manager will typically resize it to fill the
+ * entire visible area of the display, and the instance
+ * is usually put in a state where it can not be resized
+ * (even if it has style <code>RESIZE</code>) until it is
+ * no longer maximized.
+ * </li><li>
+ * When an instance is in the <em>normal</em> state (neither
+ * maximized or minimized), its appearance is controlled by
+ * the style constants which were specified when it was created
+ * and the restrictions of the window manager (see below).
+ * </li><li>
+ * When an instance has been marked as <em>minimized</em>,
+ * its contents (client area) will usually not be visible,
+ * and depending on the window manager, it may be
+ * "iconified" (that is, replaced on the desktop by a small
+ * simplified representation of itself), relocated to a
+ * distinguished area of the screen, or hidden. Combinations
+ * of these changes are also possible.
+ * </li>
+ * </ul>
+ * </p>
+ * <p>
+ * 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
+ * and modality. For example, some window managers only
+ * support resizable windows and will always assume the
+ * RESIZE style, even if it is not set. In addition, if a
+ * modality style is not supported, it is "upgraded" to a
+ * more restrictive modality style that is supported. For
+ * example, if <code>PRIMARY_MODAL</code> is not supported,
+ * it would be upgraded to <code>APPLICATION_MODAL</code>.
+ * <dl>
+ * <dt><b>Styles:</b></dt>
+ * <dd>BORDER, CLOSE, MIN, MAX, NO_TRIM, RESIZE, TITLE</dd>
+ * <dd>APPLICATION_MODAL, MODELESS, PRIMARY_MODAL, SYSTEM_MODAL</dd>
+ * <dt><b>Events:</b></dt>
+ * <dd>Activate, Close, Deactivate, Deiconify, Iconify</dd>
+ * </dl>
+ * Class <code>SWT</code> provides two "convenience constants"
+ * for the most commonly required style combinations:
+ * <dl>
+ * <dt><code>SHELL_TRIM</code></dt>
+ * <dd>
+ * the result of combining the constants which are required
+ * to produce a typical application top level shell: (that
+ * is, <code>CLOSE | TITLE | MIN | MAX | RESIZE</code>)
+ * </dd>
+ * <dt><code>DIALOG_TRIM</code></dt>
+ * <dd>
+ * the result of combining the constants which are required
+ * to produce a typical application dialog shell: (that
+ * is, <code>TITLE | CLOSE | BORDER</code>)
+ * </dd>
+ * </dl>
+ * </p>
+ * <p>
+ * Note: Only one of the styles APPLICATION_MODAL, MODELESS,
+ * PRIMARY_MODAL and SYSTEM_MODAL may be specified.
+ * </p><p>
+ * IMPORTANT: This class is not intended to be subclassed.
+ * </p>
+ *
+ * @see Decorations
+ * @see SWT
+ */
+public class Shell extends Decorations {
+ int shellHandle;
+ Display display;
+ Menu activeMenu;
+ int blockedList;
+ Control lastActive;
+
/**
* Constructs a new instance of this class. This is equivalent
* to calling <code>Shell((Display) null)</code>.
@@ -111,10 +111,10 @@ public class Shell extends Decorations {
* <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
* </ul>
*/
-public Shell () {
- this ((Display) null);
-}
-
+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
@@ -150,10 +150,10 @@ public Shell () {
* @see SWT#APPLICATION_MODAL
* @see SWT#SYSTEM_MODAL
*/
-public Shell (int style) {
- this ((Display) null, style);
-}
-
+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>.
@@ -173,10 +173,10 @@ public Shell (int style) {
* <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
* </ul>
*/
-public Shell (Display display) {
- this (display, SWT.CLOSE | SWT.TITLE | SWT.MIN | SWT.MAX | SWT.RESIZE);
-}
-
+public Shell (Display display) {
+ this (display, SWT.CLOSE | SWT.TITLE | SWT.MIN | SWT.MAX | SWT.RESIZE);
+}
+
/**
* Constructs a new instance of this class given the display
* to create it on and a style value describing its behavior
@@ -220,24 +220,24 @@ public Shell (Display display) {
* @see SWT#APPLICATION_MODAL
* @see SWT#SYSTEM_MODAL
*/
-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 (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);
+}
+
/**
* Constructs a new instance of this class given only its
* parent. It is created with style <code>SWT.DIALOG_TRIM</code>.
@@ -260,10 +260,10 @@ Shell (Display display, Shell parent, int style, int handle) {
* <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
* </ul>
*/
-public Shell (Shell parent) {
- this (parent, SWT.TITLE | SWT.CLOSE | SWT.BORDER);
-}
-
+public Shell (Shell parent) {
+ this (parent, SWT.TITLE | SWT.CLOSE | SWT.BORDER);
+}
+
/**
* Constructs a new instance of this class given its parent
* and a style value describing its behavior and appearance.
@@ -306,14 +306,14 @@ public Shell (Shell parent) {
* @see SWT#APPLICATION_MODAL
* @see SWT#SYSTEM_MODAL
*/
-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 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);
+}
+
/**
* Adds the listener to the collection of listeners who will
* be notified when operations are performed on the receiver,
@@ -333,38 +333,38 @@ public static Shell photon_new (Display display, int handle) {
* @see ShellListener
* @see #removeShellListener
*/
-public void addShellListener (ShellListener listener) {
- checkWidget();
- if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
- TypedListener typedListener = new TypedListener (listener);
- addListener (SWT.Close,typedListener);
- addListener (SWT.Iconify,typedListener);
- addListener (SWT.Deiconify,typedListener);
- addListener (SWT.Activate, typedListener);
- addListener (SWT.Deactivate, typedListener);
-}
-
-void bringToTop () {
- OS.PtWidgetToFront (shellHandle);
-}
-
-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;
-}
-
-void closeWidget () {
- Event event = new Event ();
- event.time = (int) System.currentTimeMillis ();
- sendEvent (SWT.Close, event);
- if (event.doit && !isDisposed ()) dispose ();
-}
-
+public void addShellListener (ShellListener listener) {
+ checkWidget();
+ if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+ TypedListener typedListener = new TypedListener (listener);
+ addListener (SWT.Close,typedListener);
+ addListener (SWT.Iconify,typedListener);
+ addListener (SWT.Deiconify,typedListener);
+ addListener (SWT.Activate, typedListener);
+ addListener (SWT.Deactivate, typedListener);
+}
+
+void bringToTop () {
+ OS.PtWidgetToFront (shellHandle);
+}
+
+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;
+}
+
+void closeWidget () {
+ Event event = new Event ();
+ event.time = (int) System.currentTimeMillis ();
+ sendEvent (SWT.Close, event);
+ if (event.doit && !isDisposed ()) dispose ();
+}
+
/**
* Requests that the window manager close the receiver in
* the same way it would be closed when the user clicks on
@@ -379,158 +379,158 @@ void closeWidget () {
*
* @see #dispose
*/
-public void close () {
- checkWidget();
- closeWidget ();
-}
-
-public Rectangle computeTrim (int x, int y, int width, int height) {
- checkWidget();
- 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) {
- PhDim_t dim = new PhDim_t ();
- int menuHandle = menuBar.handle;
- if (!OS.PtWidgetIsRealized (menuHandle)) {
- OS.PtExtentWidgetFamily (menuHandle);
- }
- OS.PtWidgetPreferredSize (menuHandle, dim);
- trimHeight += dim.h;
- trimY -= dim.h;
- }
- return new Rectangle (trimX, trimY, trimWidth, trimHeight);
-}
-
-void createHandle (int index) {
- state |= HANDLE | GRAB | CANVAS;
- if (handle != 0) {
- int clazz = display.PtContainer;
- int [] args = {
- OS.Pt_ARG_FILL_COLOR, OS.Pg_TRANSPARENT, 0,
- OS.Pt_ARG_CONTAINER_FLAGS, OS.Pt_HOTKEYS_FIRST, OS.Pt_HOTKEYS_FIRST,
- 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, OS.PhInputGroup (0), 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 notifyFlags =
- OS.Ph_WM_ICON | OS.Ph_WM_FOCUS |
- OS.Ph_WM_MOVE | OS.Ph_WM_RESIZE;
- int windowState = OS.Ph_WM_STATE_ISFOCUS;
- if ((style & SWT.ON_TOP) != 0) windowState = OS.Ph_WM_STATE_ISFRONT;
- 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, notifyFlags, notifyFlags,
- OS.Pt_ARG_WINDOW_STATE, windowState, ~0,
- OS.Pt_ARG_FLAGS, OS.Pt_DELAY_REALIZE, OS.Pt_DELAY_REALIZE,
- OS.Pt_ARG_FILL_COLOR, OS.Pg_TRANSPARENT, 0,
- OS.Pt_ARG_CONTAINER_FLAGS, OS.Pt_HOTKEYS_FIRST, OS.Pt_HOTKEYS_FIRST,
- 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);
- if ((style & (SWT.NO_TRIM | SWT.BORDER | SWT.RESIZE)) == 0) {
- int [] args = {
- OS.Pt_ARG_FLAGS, OS.Pt_HIGHLIGHTED, OS.Pt_HIGHLIGHTED,
- OS.Pt_ARG_BASIC_FLAGS, OS.Pt_ALL_OUTLINES, ~0,
- };
- OS.PtSetResources (scrolledHandle, args.length / 3, args);
- }
- 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);
-}
-
-/**
- * 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) and forces the window
- * manager to make the shell active.
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @since 2.0
- * @see Control#moveAbove
- * @see Control#setFocus
- * @see Control#setVisible
- * @see Display#getActiveShell
- * @see Decorations#setDefaultButton
- * @see Shell#open
- * @see Shell#setActive
+public void close () {
+ checkWidget();
+ closeWidget ();
+}
+
+public Rectangle computeTrim (int x, int y, int width, int height) {
+ checkWidget();
+ 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) {
+ PhDim_t dim = new PhDim_t ();
+ int menuHandle = menuBar.handle;
+ if (!OS.PtWidgetIsRealized (menuHandle)) {
+ OS.PtExtentWidgetFamily (menuHandle);
+ }
+ OS.PtWidgetPreferredSize (menuHandle, dim);
+ trimHeight += dim.h;
+ trimY -= dim.h;
+ }
+ return new Rectangle (trimX, trimY, trimWidth, trimHeight);
+}
+
+void createHandle (int index) {
+ state |= HANDLE | GRAB | CANVAS;
+ if (handle != 0) {
+ int clazz = display.PtContainer;
+ int [] args = {
+ OS.Pt_ARG_FILL_COLOR, OS.Pg_TRANSPARENT, 0,
+ OS.Pt_ARG_CONTAINER_FLAGS, OS.Pt_HOTKEYS_FIRST, OS.Pt_HOTKEYS_FIRST,
+ 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, OS.PhInputGroup (0), 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 notifyFlags =
+ OS.Ph_WM_ICON | OS.Ph_WM_FOCUS |
+ OS.Ph_WM_MOVE | OS.Ph_WM_RESIZE;
+ int windowState = OS.Ph_WM_STATE_ISFOCUS;
+ if ((style & SWT.ON_TOP) != 0) windowState = OS.Ph_WM_STATE_ISFRONT;
+ 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, notifyFlags, notifyFlags,
+ OS.Pt_ARG_WINDOW_STATE, windowState, ~0,
+ OS.Pt_ARG_FLAGS, OS.Pt_DELAY_REALIZE, OS.Pt_DELAY_REALIZE,
+ OS.Pt_ARG_FILL_COLOR, OS.Pg_TRANSPARENT, 0,
+ OS.Pt_ARG_CONTAINER_FLAGS, OS.Pt_HOTKEYS_FIRST, OS.Pt_HOTKEYS_FIRST,
+ 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);
+ if ((style & (SWT.NO_TRIM | SWT.BORDER | SWT.RESIZE)) == 0) {
+ int [] args = {
+ OS.Pt_ARG_FLAGS, OS.Pt_HIGHLIGHTED, OS.Pt_HIGHLIGHTED,
+ OS.Pt_ARG_BASIC_FLAGS, OS.Pt_ALL_OUTLINES, ~0,
+ };
+ OS.PtSetResources (scrolledHandle, args.length / 3, args);
+ }
+ 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);
+}
+
+/**
+ * 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) and forces the window
+ * manager to make the shell active.
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @since 2.0
+ * @see Control#moveAbove
+ * @see Control#setFocus
+ * @see Control#setVisible
+ * @see Display#getActiveShell
+ * @see Decorations#setDefaultButton
+ * @see Shell#open
+ * @see Shell#setActive
*/
-public void forceActive () {
- checkWidget ();
- bringToTop ();
-}
-
-public Rectangle getBounds () {
- checkWidget();
- PhArea_t area = new PhArea_t ();
- OS.PtWidgetArea (shellHandle, area);
- int width = area.size_w, height = area.size_h;
- 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);
- width += left [0] + right [0];
- height += top [0] + bottom [0];
- return new Rectangle (area.pos_x, area.pos_y, width, height);
-}
-
-public Display getDisplay () {
- if (display == null) error (SWT.ERROR_WIDGET_DISPOSED);
- return display;
-}
-
+public void forceActive () {
+ checkWidget ();
+ bringToTop ();
+}
+
+public Rectangle getBounds () {
+ checkWidget();
+ PhArea_t area = new PhArea_t ();
+ OS.PtWidgetArea (shellHandle, area);
+ int width = area.size_w, height = area.size_h;
+ 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);
+ width += left [0] + right [0];
+ height += top [0] + bottom [0];
+ return new Rectangle (area.pos_x, area.pos_y, width, height);
+}
+
+public Display getDisplay () {
+ if (display == null) error (SWT.ERROR_WIDGET_DISPOSED);
+ return display;
+}
+
/**
* Returns the receiver's input method editor mode. This
* will be the result of bitwise OR'ing together one or
@@ -548,45 +548,45 @@ public Display getDisplay () {
*
* @see SWT
*/
-public int getImeInputMode () {
- checkWidget();
- return 0;
-}
-
-public boolean isEnabled () {
- checkWidget();
- return getEnabled ();
-}
-
-public Point getLocation () {
- checkWidget();
- //NOT DONE - shell location is 0,0 when queried before event loop
- return super.getLocation ();
-}
-
-public boolean getMaximized () {
- checkWidget();
- int state = OS.PtWindowGetState (shellHandle);
- if (state != -1) return (state & (OS.Ph_WM_STATE_ISMAX | OS.Ph_WM_STATE_ISMAXING)) != 0;
- 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 () {
- checkWidget();
- int state = OS.PtWindowGetState (shellHandle);
- if (state != -1) return (state & OS.Ph_WM_STATE_ISICONIFIED) != 0;
- int [] args = {OS.Pt_ARG_WINDOW_STATE, 0, OS.Ph_WM_STATE_ISICONIFIED};
- OS.PtGetResources (shellHandle, args.length / 3, args);
- return (args [1] & OS.Ph_WM_STATE_ISICONIFIED) != 0;
-}
-
-public Shell getShell () {
- checkWidget();
- return this;
-}
-
+public int getImeInputMode () {
+ checkWidget();
+ return 0;
+}
+
+public boolean isEnabled () {
+ checkWidget();
+ return getEnabled ();
+}
+
+public Point getLocation () {
+ checkWidget();
+ //NOT DONE - shell location is 0,0 when queried before event loop
+ return super.getLocation ();
+}
+
+public boolean getMaximized () {
+ checkWidget();
+ int state = OS.PtWindowGetState (shellHandle);
+ if (state != -1) return (state & (OS.Ph_WM_STATE_ISMAX | OS.Ph_WM_STATE_ISMAXING)) != 0;
+ 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 () {
+ checkWidget();
+ int state = OS.PtWindowGetState (shellHandle);
+ if (state != -1) return (state & OS.Ph_WM_STATE_ISICONIFIED) != 0;
+ int [] args = {OS.Pt_ARG_WINDOW_STATE, 0, OS.Ph_WM_STATE_ISICONIFIED};
+ OS.PtGetResources (shellHandle, args.length / 3, args);
+ return (args [1] & OS.Ph_WM_STATE_ISICONIFIED) != 0;
+}
+
+public Shell getShell () {
+ checkWidget();
+ return this;
+}
+
/**
* Returns an array containing all shells which are
* descendents of the receiver.
@@ -598,182 +598,182 @@ public Shell getShell () {
* <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 Point getSize () {
- checkWidget();
- 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 hookEvents () {
- super.hookEvents ();
- int windowProc = getDisplay ().windowProc;
- OS.PtAddCallback (shellHandle, OS.Pt_CB_WINDOW, windowProc, OS.Pt_CB_WINDOW);
- OS.PtAddCallback (shellHandle, OS.Pt_CB_RESIZE, windowProc, OS.Pt_CB_RESIZE);
-}
-
-int hotkeyProc (int w, int data, int info) {
- if (data != 0) {
- Widget widget = WidgetTable.get (data);
- if (widget instanceof MenuItem) {
- MenuItem item = (MenuItem) widget;
- if (item.isEnabled ()) item.Pt_CB_ACTIVATE (data, info);
- }
- }
- return OS.Pt_CONTINUE;
-}
-
-/**
- * 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)
- * and asks the window manager to make the shell active.
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see Control#moveAbove
- * @see Control#setFocus
- * @see Control#setVisible
- * @see Display#getActiveShell
- * @see Decorations#setDefaultButton
- * @see Shell#setActive
- * @see Shell#forceActive
+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 Point getSize () {
+ checkWidget();
+ 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 hookEvents () {
+ super.hookEvents ();
+ int windowProc = getDisplay ().windowProc;
+ OS.PtAddCallback (shellHandle, OS.Pt_CB_WINDOW, windowProc, OS.Pt_CB_WINDOW);
+ OS.PtAddCallback (shellHandle, OS.Pt_CB_RESIZE, windowProc, OS.Pt_CB_RESIZE);
+}
+
+int hotkeyProc (int w, int data, int info) {
+ if (data != 0) {
+ Widget widget = WidgetTable.get (data);
+ if (widget instanceof MenuItem) {
+ MenuItem item = (MenuItem) widget;
+ if (item.isEnabled ()) item.Pt_CB_ACTIVATE (data, info);
+ }
+ }
+ return OS.Pt_CONTINUE;
+}
+
+/**
+ * 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)
+ * and asks the window manager to make the shell active.
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see Control#moveAbove
+ * @see Control#setFocus
+ * @see Control#setVisible
+ * @see Display#getActiveShell
+ * @see Decorations#setDefaultButton
+ * @see Shell#setActive
+ * @see Shell#forceActive
*/
-public void open () {
- checkWidget();
- bringToTop ();
- setVisible (true);
- traverseGroup (true);
-}
-
-int Pt_CB_RESIZE (int widget, 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]);
- sendEvent(SWT.Resize);
- if (layout != null) layout (false);
- return OS.Pt_CONTINUE;
-}
-
-int Pt_CB_WINDOW (int widget, 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 ((int) 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;
-}
-
-void register () {
- super.register ();
- WidgetTable.put (shellHandle, this);
-}
-
-void realizeWidget() {
- /* Do nothing */
-}
-
-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 ()) {
- /*
- * Feature in Photon. A shell may have child shells that have been
- * temporarily reparented to NULL because they were shown without
- * showing the parent. In this case, Photon will not destroy the
- * child shells because they are not in the widget hierarchy.
- * The fix is to detect this case and destroy the shells.
- */
- if (shell.parent != null && OS.PtWidgetParent (shell.shellHandle) == 0) {
- shell.dispose ();
- } else {
- shell.releaseResources ();
- }
- }
- }
-}
-
-void releaseWidget () {
- releaseShells ();
- super.releaseWidget ();
- if (blockedList != 0) OS.PtUnblockWindows (blockedList);
- blockedList = 0;
- lastActive = null;
- display = null;
-}
-
+public void open () {
+ checkWidget();
+ bringToTop ();
+ setVisible (true);
+ traverseGroup (true);
+}
+
+int Pt_CB_RESIZE (int widget, 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]);
+ sendEvent(SWT.Resize);
+ if (layout != null) layout (false);
+ return OS.Pt_CONTINUE;
+}
+
+int Pt_CB_WINDOW (int widget, 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 ((int) 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;
+}
+
+void register () {
+ super.register ();
+ WidgetTable.put (shellHandle, this);
+}
+
+void realizeWidget() {
+ /* Do nothing */
+}
+
+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 ()) {
+ /*
+ * Feature in Photon. A shell may have child shells that have been
+ * temporarily reparented to NULL because they were shown without
+ * showing the parent. In this case, Photon will not destroy the
+ * child shells because they are not in the widget hierarchy.
+ * The fix is to detect this case and destroy the shells.
+ */
+ if (shell.parent != null && OS.PtWidgetParent (shell.shellHandle) == 0) {
+ shell.dispose ();
+ } else {
+ shell.releaseResources ();
+ }
+ }
+ }
+}
+
+void releaseWidget () {
+ releaseShells ();
+ super.releaseWidget ();
+ if (blockedList != 0) OS.PtUnblockWindows (blockedList);
+ blockedList = 0;
+ lastActive = null;
+ display = null;
+}
+
/**
* Removes the listener from the collection of listeners who will
* be notified when operations are performed on the receiver.
@@ -791,158 +791,158 @@ void releaseWidget () {
* @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);
-}
-
-/**
- * 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) and asks the window
- * manager to make the shell active.
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @since 2.0
- * @see Control#moveAbove
- * @see Control#setFocus
- * @see Control#setVisible
- * @see Display#getActiveShell
- * @see Decorations#setDefaultButton
- * @see Shell#open
- * @see Shell#setActive
+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);
+}
+
+/**
+ * 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) and asks the window
+ * manager to make the shell active.
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @since 2.0
+ * @see Control#moveAbove
+ * @see Control#setFocus
+ * @see Control#setVisible
+ * @see Display#getActiveShell
+ * @see Decorations#setDefaultButton
+ * @see Shell#open
+ * @see Shell#setActive
*/
-public void setActive () {
- checkWidget ();
- bringToTop ();
-}
-
-void setActiveControl (Control control) {
- if (control != null && control.isDisposed ()) control = null;
- if (lastActive != null && lastActive.isDisposed ()) lastActive = null;
- if (lastActive == control) return;
-
- /*
- * Compute the list of controls to be activated and
- * deactivated by finding the first common parent
- * control.
- */
- Control [] activate = (control == null) ? new Control[0] : control.getPath ();
- Control [] deactivate = (lastActive == null) ? new Control[0] : lastActive.getPath ();
- lastActive = control;
- int index = 0, length = Math.min (activate.length, deactivate.length);
- while (index < length) {
- if (activate [index] != deactivate [index]) break;
- index++;
- }
-
- /*
- * It is possible (but unlikely), that application
- * code could have destroyed some of the widgets. If
- * this happens, keep processing those widgets that
- * are not disposed.
- */
- for (int i=deactivate.length-1; i>=index; --i) {
- if (!deactivate [i].isDisposed ()) {
- deactivate [i].sendEvent (SWT.Deactivate);
- }
- }
- for (int i=activate.length-1; i>=index; --i) {
- if (!activate [i].isDisposed ()) {
- activate [i].sendEvent (SWT.Activate);
- }
- }
-}
-
-int setBounds (int x, int y, int width, int height, boolean move, boolean resize, boolean events) {
- checkWidget();
- if (OS.PtWidgetClass (shellHandle) != OS.PtWindow ()) {
- int result = super.setBounds (x, y, width, height, move, resize, events);
- if ((result & RESIZED) != 0) resizeBounds (width, height);
- return result;
- }
-
- boolean isFocus = caret != null && caret.isFocusCaret ();
- if (isFocus) caret.killFocus ();
-
- if (resize) {
- /* Get the trimings */
- 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);
- width = Math.max (width - left [0] - right [0], 0);
- height = Math.max (height - top [0] - bottom [0], 0);
- }
-
- PhArea_t oldArea = new PhArea_t ();
- OS.PtWidgetArea (shellHandle, oldArea);
-
- if (move && resize) {
- PhArea_t area = new PhArea_t ();
- area.pos_x = (short) x;
- area.pos_y = (short) y;
- area.size_w = (short) width;
- area.size_h = (short) height;
- int ptr = OS.malloc (PhArea_t.sizeof);
- OS.memmove (ptr, area, PhArea_t.sizeof);
- OS.PtSetResource (shellHandle, OS.Pt_ARG_AREA, ptr, 0);
- 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);
- OS.PtSetResource (shellHandle, OS.Pt_ARG_POS, ptr, 0);
- OS.free (ptr);
- } else if (resize) {
- int [] args = {
- OS.Pt_ARG_WIDTH, width, 0,
- OS.Pt_ARG_HEIGHT, height, 0,
- };
- OS.PtSetResources (shellHandle, args.length / 3, args);
- }
- }
-
- /*
- * 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)) {
- PhArea_t newArea = new PhArea_t ();
- OS.PtWidgetArea (shellHandle, newArea);
- boolean sameOrigin = oldArea.pos_x == newArea.pos_x && oldArea.pos_y == newArea.pos_y;
- boolean sameExtent = oldArea.size_w == newArea.size_w && oldArea.size_h == newArea.size_h;
- if (!sameOrigin & move) sendEvent (SWT.Move);
- if (!sameExtent & resize) {
- resizeBounds (newArea.size_w, newArea.size_h);
- sendEvent(SWT.Resize);
- if (layout != null) layout (false);
- }
- }
-
- if (isFocus) caret.setFocus ();
-
- /* Always return 0 */
- return 0;
-}
-
+public void setActive () {
+ checkWidget ();
+ bringToTop ();
+}
+
+void setActiveControl (Control control) {
+ if (control != null && control.isDisposed ()) control = null;
+ if (lastActive != null && lastActive.isDisposed ()) lastActive = null;
+ if (lastActive == control) return;
+
+ /*
+ * Compute the list of controls to be activated and
+ * deactivated by finding the first common parent
+ * control.
+ */
+ Control [] activate = (control == null) ? new Control[0] : control.getPath ();
+ Control [] deactivate = (lastActive == null) ? new Control[0] : lastActive.getPath ();
+ lastActive = control;
+ int index = 0, length = Math.min (activate.length, deactivate.length);
+ while (index < length) {
+ if (activate [index] != deactivate [index]) break;
+ index++;
+ }
+
+ /*
+ * It is possible (but unlikely), that application
+ * code could have destroyed some of the widgets. If
+ * this happens, keep processing those widgets that
+ * are not disposed.
+ */
+ for (int i=deactivate.length-1; i>=index; --i) {
+ if (!deactivate [i].isDisposed ()) {
+ deactivate [i].sendEvent (SWT.Deactivate);
+ }
+ }
+ for (int i=activate.length-1; i>=index; --i) {
+ if (!activate [i].isDisposed ()) {
+ activate [i].sendEvent (SWT.Activate);
+ }
+ }
+}
+
+int setBounds (int x, int y, int width, int height, boolean move, boolean resize, boolean events) {
+ checkWidget();
+ if (OS.PtWidgetClass (shellHandle) != OS.PtWindow ()) {
+ int result = super.setBounds (x, y, width, height, move, resize, events);
+ if ((result & RESIZED) != 0) resizeBounds (width, height);
+ return result;
+ }
+
+ boolean isFocus = caret != null && caret.isFocusCaret ();
+ if (isFocus) caret.killFocus ();
+
+ if (resize) {
+ /* Get the trimings */
+ 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);
+ width = Math.max (width - left [0] - right [0], 0);
+ height = Math.max (height - top [0] - bottom [0], 0);
+ }
+
+ PhArea_t oldArea = new PhArea_t ();
+ OS.PtWidgetArea (shellHandle, oldArea);
+
+ if (move && resize) {
+ PhArea_t area = new PhArea_t ();
+ area.pos_x = (short) x;
+ area.pos_y = (short) y;
+ area.size_w = (short) width;
+ area.size_h = (short) height;
+ int ptr = OS.malloc (PhArea_t.sizeof);
+ OS.memmove (ptr, area, PhArea_t.sizeof);
+ OS.PtSetResource (shellHandle, OS.Pt_ARG_AREA, ptr, 0);
+ 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);
+ OS.PtSetResource (shellHandle, OS.Pt_ARG_POS, ptr, 0);
+ OS.free (ptr);
+ } else if (resize) {
+ int [] args = {
+ OS.Pt_ARG_WIDTH, width, 0,
+ OS.Pt_ARG_HEIGHT, height, 0,
+ };
+ OS.PtSetResources (shellHandle, args.length / 3, args);
+ }
+ }
+
+ /*
+ * 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)) {
+ PhArea_t newArea = new PhArea_t ();
+ OS.PtWidgetArea (shellHandle, newArea);
+ boolean sameOrigin = oldArea.pos_x == newArea.pos_x && oldArea.pos_y == newArea.pos_y;
+ boolean sameExtent = oldArea.size_w == newArea.size_w && oldArea.size_h == newArea.size_h;
+ if (!sameOrigin & move) sendEvent (SWT.Move);
+ if (!sameExtent & resize) {
+ resizeBounds (newArea.size_w, newArea.size_h);
+ sendEvent(SWT.Resize);
+ if (layout != null) layout (false);
+ }
+ }
+
+ if (isFocus) caret.setFocus ();
+
+ /* Always return 0 */
+ return 0;
+}
+
/**
* Sets the input method editor mode to the argument which
* should be the result of bitwise OR'ing together one or more
@@ -959,152 +959,152 @@ int setBounds (int x, int y, int width, int height, boolean move, boolean resize
*
* @see SWT
*/
-public void setImeInputMode (int mode) {
- checkWidget();
-}
-
-public void setMaximized (boolean maximized) {
- checkWidget();
- int bits = 0;
- if (maximized) bits = OS.Ph_WM_STATE_ISMAX;
- OS.PtSetResource (shellHandle, OS.Pt_ARG_WINDOW_STATE, bits, OS.Ph_WM_STATE_ISMAX);
- if (OS.PtWidgetIsRealized (shellHandle)) {
- PhWindowEvent_t event = new PhWindowEvent_t ();
- event.rid = OS.PtWidgetRid (shellHandle);
- event.event_f = maximized ? OS.Ph_WM_MAX : OS.Ph_WM_RESTORE;
- OS.PtForwardWindowEvent (event);
- }
-}
-
-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);
- }
- if (menuBar != null) {
- int menuHandle = menuBar.handle;
- OS.PtSetResource (menuHandle, OS.Pt_ARG_FLAGS, OS.Pt_DELAY_REALIZE, OS.Pt_DELAY_REALIZE);
- 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];
- 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);
- OS.PtRealizeWidget (menuHandle);
- }
- resizeBounds (width, height);
-}
-
-public void setMinimized (boolean minimized) {
- checkWidget();
- int bits = 0;
- if (minimized) bits = OS.Ph_WM_STATE_ISICONIFIED;
- OS.PtSetResource (shellHandle, OS.Pt_ARG_WINDOW_STATE, bits, OS.Ph_WM_STATE_ISICONIFIED);
- if (OS.PtWidgetIsRealized (shellHandle)) {
- PhWindowEvent_t event = new PhWindowEvent_t ();
- event.rid = OS.PtWidgetRid (shellHandle);
- event.event_f = OS.Ph_WM_HIDE;
- event.event_state = (short) (minimized ? OS.Ph_WM_EVSTATE_HIDE : OS.Ph_WM_EVSTATE_UNHIDE);
- OS.PtForwardWindowEvent (event);
- }
-}
-
-public void setText (String string) {
- checkWidget();
- 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);
- OS.PtSetResource (shellHandle, OS.Pt_ARG_WINDOW_TITLE, ptr, 0);
- OS.free (ptr);
-}
-
-public void setVisible (boolean visible) {
- checkWidget();
- if (visible == OS.PtWidgetIsRealized (shellHandle)) return;
-
- /*
- * Feature in Photon. It is not possible to show a PtWindow
- * whose parent is not realized. The fix is to temporarily
- * reparent the child shell to NULL and then realize the child
- * shell.
- */
- if (parent != null) {
- Shell shell = parent.getShell ();
- int parentHandle = shell.shellHandle;
- if (!OS.PtWidgetIsRealized (parentHandle)) {
- OS.PtReParentWidget (shellHandle, visible ? OS.Pt_NO_PARENT : parentHandle);
- }
- }
-
- if (visible) {
- int mask = SWT.PRIMARY_MODAL | SWT.APPLICATION_MODAL | SWT.SYSTEM_MODAL;
- switch (style & mask) {
- case SWT.PRIMARY_MODAL:
- if (parent != null) {
- int parentHandle = parent.getShell ().shellHandle;
- blockedList = OS.PtBlockWindow (parentHandle, (short) 0, 0);
- }
- break;
- case SWT.APPLICATION_MODAL:
- case SWT.SYSTEM_MODAL:
- blockedList = OS.PtBlockAllWindows (shellHandle, (short) 0, 0);
- break;
- }
- } else {
- if (blockedList != 0) OS.PtUnblockWindows (blockedList);
- blockedList = 0;
- }
-
- int flags = visible ? 0 : OS.Pt_DELAY_REALIZE;
- OS.PtSetResource (shellHandle, OS.Pt_ARG_FLAGS, flags, OS.Pt_DELAY_REALIZE);
- if (visible) {
- sendEvent (SWT.Show);
- OS.PtRealizeWidget (shellHandle);
- } else {
- OS.PtUnrealizeWidget (shellHandle);
- sendEvent(SWT.Hide);
- }
-
- /*
- * Feature in Photon. When a shell is shown, it may have child
- * shells that have been temporarily reparented to NULL because
- * the child was shown before the parent. The fix is to reparent
- * the child shells back to the correct parent.
- */
- if (visible) {
- Shell [] shells = getShells ();
- for (int i=0; i<shells.length; i++) {
- int childHandle = shells [i].shellHandle;
- if (OS.PtWidgetParent (childHandle) == 0) {
- OS.PtReParentWidget (childHandle, shellHandle);
- }
- }
- }
-
- OS.PtSyncWidget (shellHandle);
- OS.PtFlush ();
-}
-
-int topHandle () {
- return shellHandle;
-}
-
-boolean traverseEscape () {
- if (parent == null) return false;
- if (!isVisible () || !isEnabled ()) return false;
- close ();
- return true;
-}
-
-}
+public void setImeInputMode (int mode) {
+ checkWidget();
+}
+
+public void setMaximized (boolean maximized) {
+ checkWidget();
+ int bits = 0;
+ if (maximized) bits = OS.Ph_WM_STATE_ISMAX;
+ OS.PtSetResource (shellHandle, OS.Pt_ARG_WINDOW_STATE, bits, OS.Ph_WM_STATE_ISMAX);
+ if (OS.PtWidgetIsRealized (shellHandle)) {
+ PhWindowEvent_t event = new PhWindowEvent_t ();
+ event.rid = OS.PtWidgetRid (shellHandle);
+ event.event_f = maximized ? OS.Ph_WM_MAX : OS.Ph_WM_RESTORE;
+ OS.PtForwardWindowEvent (event);
+ }
+}
+
+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);
+ }
+ if (menuBar != null) {
+ int menuHandle = menuBar.handle;
+ OS.PtSetResource (menuHandle, OS.Pt_ARG_FLAGS, OS.Pt_DELAY_REALIZE, OS.Pt_DELAY_REALIZE);
+ 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];
+ 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);
+ OS.PtRealizeWidget (menuHandle);
+ }
+ resizeBounds (width, height);
+}
+
+public void setMinimized (boolean minimized) {
+ checkWidget();
+ int bits = 0;
+ if (minimized) bits = OS.Ph_WM_STATE_ISICONIFIED;
+ OS.PtSetResource (shellHandle, OS.Pt_ARG_WINDOW_STATE, bits, OS.Ph_WM_STATE_ISICONIFIED);
+ if (OS.PtWidgetIsRealized (shellHandle)) {
+ PhWindowEvent_t event = new PhWindowEvent_t ();
+ event.rid = OS.PtWidgetRid (shellHandle);
+ event.event_f = OS.Ph_WM_HIDE;
+ event.event_state = (short) (minimized ? OS.Ph_WM_EVSTATE_HIDE : OS.Ph_WM_EVSTATE_UNHIDE);
+ OS.PtForwardWindowEvent (event);
+ }
+}
+
+public void setText (String string) {
+ checkWidget();
+ 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);
+ OS.PtSetResource (shellHandle, OS.Pt_ARG_WINDOW_TITLE, ptr, 0);
+ OS.free (ptr);
+}
+
+public void setVisible (boolean visible) {
+ checkWidget();
+ if (visible == OS.PtWidgetIsRealized (shellHandle)) return;
+
+ /*
+ * Feature in Photon. It is not possible to show a PtWindow
+ * whose parent is not realized. The fix is to temporarily
+ * reparent the child shell to NULL and then realize the child
+ * shell.
+ */
+ if (parent != null) {
+ Shell shell = parent.getShell ();
+ int parentHandle = shell.shellHandle;
+ if (!OS.PtWidgetIsRealized (parentHandle)) {
+ OS.PtReParentWidget (shellHandle, visible ? OS.Pt_NO_PARENT : parentHandle);
+ }
+ }
+
+ if (visible) {
+ int mask = SWT.PRIMARY_MODAL | SWT.APPLICATION_MODAL | SWT.SYSTEM_MODAL;
+ switch (style & mask) {
+ case SWT.PRIMARY_MODAL:
+ if (parent != null) {
+ int parentHandle = parent.getShell ().shellHandle;
+ blockedList = OS.PtBlockWindow (parentHandle, (short) 0, 0);
+ }
+ break;
+ case SWT.APPLICATION_MODAL:
+ case SWT.SYSTEM_MODAL:
+ blockedList = OS.PtBlockAllWindows (shellHandle, (short) 0, 0);
+ break;
+ }
+ } else {
+ if (blockedList != 0) OS.PtUnblockWindows (blockedList);
+ blockedList = 0;
+ }
+
+ int flags = visible ? 0 : OS.Pt_DELAY_REALIZE;
+ OS.PtSetResource (shellHandle, OS.Pt_ARG_FLAGS, flags, OS.Pt_DELAY_REALIZE);
+ if (visible) {
+ sendEvent (SWT.Show);
+ OS.PtRealizeWidget (shellHandle);
+ } else {
+ OS.PtUnrealizeWidget (shellHandle);
+ sendEvent(SWT.Hide);
+ }
+
+ /*
+ * Feature in Photon. When a shell is shown, it may have child
+ * shells that have been temporarily reparented to NULL because
+ * the child was shown before the parent. The fix is to reparent
+ * the child shells back to the correct parent.
+ */
+ if (visible) {
+ Shell [] shells = getShells ();
+ for (int i=0; i<shells.length; i++) {
+ int childHandle = shells [i].shellHandle;
+ if (OS.PtWidgetParent (childHandle) == 0) {
+ OS.PtReParentWidget (childHandle, shellHandle);
+ }
+ }
+ }
+
+ OS.PtSyncWidget (shellHandle);
+ OS.PtFlush ();
+}
+
+int topHandle () {
+ return shellHandle;
+}
+
+boolean traverseEscape () {
+ if (parent == null) return false;
+ if (!isVisible () || !isEnabled ()) return false;
+ close ();
+ return true;
+}
+
+}
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
index 023179468e..83cb3c16d4 100755
--- 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
@@ -1,17 +1,17 @@
-package org.eclipse.swt.widgets;
-
-/*
+package org.eclipse.swt.widgets;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-import org.eclipse.swt.internal.photon.*;
-import org.eclipse.swt.*;
-import org.eclipse.swt.graphics.*;
-import org.eclipse.swt.events.*;
-
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+import org.eclipse.swt.internal.photon.*;
+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.
@@ -60,8 +60,8 @@ import org.eclipse.swt.events.*;
*
* @see ScrollBar
*/
-public class Slider extends Control {
-
+public class Slider extends Control {
+
/**
* Constructs a new instance of this class given its parent
* and a style value describing its behavior and appearance.
@@ -91,14 +91,14 @@ public class Slider extends Control {
* @see Widget#checkSubclass
* @see Widget#getStyle
*/
-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 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);
+}
+
/**
* Adds the listener to the collection of listeners who will
* be notified when the receiver's value changes, by sending
@@ -131,55 +131,55 @@ static int checkStyle (int style) {
* @see #removeSelectionListener
* @see SelectionEvent
*/
-public void addSelectionListener (SelectionListener listener) {
- checkWidget();
- if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
- TypedListener typedListener = new TypedListener(listener);
- addListener (SWT.Selection,typedListener);
- addListener (SWT.DefaultSelection,typedListener);
-}
-
-public Point computeSize (int wHint, int hHint, boolean changed) {
- checkWidget();
- Display display = getDisplay ();
- int border = getBorderWidth () * 2;
- int width = display.SCROLLBAR_WIDTH + border, height = width * 5;
- if ((style & SWT.HORIZONTAL) != 0) {
- height = display.SCROLLBAR_HEIGHT + border; width = height * 5;
- }
- 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) {
- state |= HANDLE;
- Display display = getDisplay ();
- int clazz = display.PtScrollbar;
- int parentHandle = parent.parentingHandle ();
- 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);
-}
-
-byte [] defaultFont () {
- Display display = getDisplay ();
- return display.GAUGE_FONT;
-}
-
+public void addSelectionListener (SelectionListener listener) {
+ checkWidget();
+ if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+ TypedListener typedListener = new TypedListener(listener);
+ addListener (SWT.Selection,typedListener);
+ addListener (SWT.DefaultSelection,typedListener);
+}
+
+public Point computeSize (int wHint, int hHint, boolean changed) {
+ checkWidget();
+ Display display = getDisplay ();
+ int border = getBorderWidth () * 2;
+ int width = display.SCROLLBAR_WIDTH + border, height = width * 5;
+ if ((style & SWT.HORIZONTAL) != 0) {
+ height = display.SCROLLBAR_HEIGHT + border; width = height * 5;
+ }
+ 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) {
+ state |= HANDLE;
+ Display display = getDisplay ();
+ int clazz = display.PtScrollbar;
+ int parentHandle = parent.parentingHandle ();
+ 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);
+}
+
+byte [] defaultFont () {
+ Display display = getDisplay ();
+ return display.GAUGE_FONT;
+}
+
/**
* Returns the amount that the receiver's value will be
* modified by when the up/down (or right/left) arrows
@@ -192,13 +192,13 @@ byte [] defaultFont () {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public int getIncrement () {
- checkWidget();
- int [] args = {OS.Pt_ARG_INCREMENT, 0, 0};
- OS.PtGetResources (handle, args.length / 3, args);
- return args [1];
-}
-
+public int getIncrement () {
+ checkWidget();
+ int [] args = {OS.Pt_ARG_INCREMENT, 0, 0};
+ OS.PtGetResources (handle, args.length / 3, args);
+ return args [1];
+}
+
/**
* Returns the minimum value which the receiver will allow.
*
@@ -209,13 +209,13 @@ public int getIncrement () {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public int getMinimum () {
- checkWidget();
- int [] args = {OS.Pt_ARG_MINIMUM, 0, 0};
- OS.PtGetResources (handle, args.length / 3, args);
- return args [1];
-}
-
+public int getMinimum () {
+ checkWidget();
+ int [] args = {OS.Pt_ARG_MINIMUM, 0, 0};
+ OS.PtGetResources (handle, args.length / 3, args);
+ return args [1];
+}
+
/**
* Returns the maximum value which the receiver will allow.
*
@@ -226,13 +226,13 @@ public int getMinimum () {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public int getMaximum () {
- checkWidget();
- int [] args = {OS.Pt_ARG_MAXIMUM, 0, 0};
- OS.PtGetResources (handle, args.length / 3, args);
- return args [1];
-}
-
+public int getMaximum () {
+ checkWidget();
+ int [] args = {OS.Pt_ARG_MAXIMUM, 0, 0};
+ OS.PtGetResources (handle, args.length / 3, args);
+ return args [1];
+}
+
/**
* Returns the amount that the receiver's value will be
* modified by when the page increment/decrement areas
@@ -245,13 +245,13 @@ public int getMaximum () {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public int getPageIncrement () {
- checkWidget();
- int [] args = {OS.Pt_ARG_PAGE_INCREMENT, 0, 0};
- OS.PtGetResources (handle, args.length / 3, args);
- return args [1];
-}
-
+public int getPageIncrement () {
+ checkWidget();
+ int [] args = {OS.Pt_ARG_PAGE_INCREMENT, 0, 0};
+ OS.PtGetResources (handle, args.length / 3, args);
+ return args [1];
+}
+
/**
* Returns the single <em>selection</em> that is the receiver's value.
*
@@ -262,20 +262,20 @@ public int getPageIncrement () {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public int getSelection () {
- checkWidget();
- int [] args = {OS.Pt_ARG_GAUGE_VALUE, 0, 0};
- OS.PtGetResources (handle, args.length / 3, args);
- return args [1];
-}
-
-public Point getSize () {
- checkWidget();
- 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 getSelection () {
+ checkWidget();
+ int [] args = {OS.Pt_ARG_GAUGE_VALUE, 0, 0};
+ OS.PtGetResources (handle, args.length / 3, args);
+ return args [1];
+}
+
+public Point getSize () {
+ checkWidget();
+ 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]);
+}
+
/**
* Returns the size of the receiver's thumb relative to the
* difference between its maximum and minimum values.
@@ -287,54 +287,54 @@ public Point getSize () {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public int getThumb () {
- checkWidget();
- int [] args = {OS.Pt_ARG_SLIDER_SIZE, 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_SCROLL_MOVE, windowProc, OS.Pt_CB_SCROLL_MOVE);
-}
-
-int Pt_CB_SCROLL_MOVE (int widget, 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 int getThumb () {
+ checkWidget();
+ int [] args = {OS.Pt_ARG_SLIDER_SIZE, 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_SCROLL_MOVE, windowProc, OS.Pt_CB_SCROLL_MOVE);
+}
+
+int Pt_CB_SCROLL_MOVE (int widget, 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;
+}
+
/**
* Removes the listener from the collection of listeners who will
* be notified when the receiver's value changes.
@@ -352,14 +352,14 @@ int Pt_CB_SCROLL_MOVE (int widget, int info) {
* @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);
-}
-
+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
@@ -373,11 +373,11 @@ public void removeSelectionListener (SelectionListener listener) {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public void setIncrement (int value) {
- checkWidget();
- OS.PtSetResource (handle, OS.Pt_ARG_INCREMENT, value, 0);
-}
-
+public void setIncrement (int value) {
+ checkWidget();
+ OS.PtSetResource (handle, OS.Pt_ARG_INCREMENT, value, 0);
+}
+
/**
* Sets the maximum value which the receiver will allow
* to be the argument which must be greater than or
@@ -390,11 +390,11 @@ public void setIncrement (int value) {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public void setMaximum (int value) {
- checkWidget();
- OS.PtSetResource (handle, OS.Pt_ARG_MAXIMUM, value - 1, 0);
-}
-
+public void setMaximum (int value) {
+ checkWidget();
+ OS.PtSetResource (handle, OS.Pt_ARG_MAXIMUM, value - 1, 0);
+}
+
/**
* Sets the minimum value which the receiver will allow
* to be the argument which must be greater than or
@@ -407,11 +407,11 @@ public void setMaximum (int value) {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public void setMinimum (int value) {
- checkWidget();
- OS.PtSetResource (handle, OS.Pt_ARG_MINIMUM, value, 0);
-}
-
+public void setMinimum (int value) {
+ checkWidget();
+ OS.PtSetResource (handle, OS.Pt_ARG_MINIMUM, value, 0);
+}
+
/**
* Sets the amount that the receiver's value will be
* modified by when the page increment/decrement areas
@@ -425,11 +425,11 @@ public void setMinimum (int value) {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public void setPageIncrement (int value) {
- checkWidget();
- OS.PtSetResource (handle, OS.Pt_ARG_PAGE_INCREMENT, value, 0);
-}
-
+public void setPageIncrement (int value) {
+ checkWidget();
+ OS.PtSetResource (handle, OS.Pt_ARG_PAGE_INCREMENT, value, 0);
+}
+
/**
* Sets the single <em>selection</em> that is the receiver's
* value to the argument which must be greater than or equal
@@ -442,11 +442,11 @@ public void setPageIncrement (int value) {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public void setSelection (int value) {
- checkWidget();
- OS.PtSetResource (handle, OS.Pt_ARG_GAUGE_VALUE, value, 0);
-}
-
+public void setSelection (int value) {
+ checkWidget();
+ OS.PtSetResource (handle, OS.Pt_ARG_GAUGE_VALUE, value, 0);
+}
+
/**
* Sets the size of the receiver's thumb relative to the
* difference between its maximum and minimum values to the
@@ -461,11 +461,11 @@ public void setSelection (int value) {
*
* @see ScrollBar
*/
-public void setThumb (int value) {
- checkWidget();
- OS.PtSetResource (handle, OS.Pt_ARG_SLIDER_SIZE, value, 0);
-}
-
+public void setThumb (int value) {
+ checkWidget();
+ OS.PtSetResource (handle, OS.Pt_ARG_SLIDER_SIZE, value, 0);
+}
+
/**
* Sets the receiver's selection, minimum value, maximum
* value, thumb, increment and page increment all at once.
@@ -487,27 +487,27 @@ public void setThumb (int value) {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public void setValues (int selection, int minimum, int maximum, int thumb, int increment, int pageIncrement) {
- checkWidget();
- if (minimum < 0) return;
- if (maximum < 0) return;
- if (thumb < 1) return;
- if (maximum - minimum - thumb < 0) return;
- if (increment < 1) return;
- if (pageIncrement < 1) return;
- int [] args = {
- OS.Pt_ARG_GAUGE_VALUE, 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);
-}
-
-int widgetClass () {
- return OS.PtScrollbar ();
-}
-
-}
+public void setValues (int selection, int minimum, int maximum, int thumb, int increment, int pageIncrement) {
+ checkWidget();
+ if (minimum < 0) return;
+ if (maximum < 0) return;
+ if (thumb < 1) return;
+ if (maximum - minimum - thumb < 0) return;
+ if (increment < 1) return;
+ if (pageIncrement < 1) return;
+ int [] args = {
+ OS.Pt_ARG_GAUGE_VALUE, 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);
+}
+
+int widgetClass () {
+ return OS.PtScrollbar ();
+}
+
+}
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
index df244433aa..83ff2e9b8f 100755
--- 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
@@ -1,17 +1,17 @@
-package org.eclipse.swt.widgets;
-
-/*
+package org.eclipse.swt.widgets;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-import org.eclipse.swt.internal.photon.*;
-import org.eclipse.swt.*;
-import org.eclipse.swt.graphics.*;
-import org.eclipse.swt.events.*;
-
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+import org.eclipse.swt.internal.photon.*;
+import org.eclipse.swt.*;
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.events.*;
+
/**
* Instances of this class implement the notebook user interface
* metaphor. It allows the user to select a notebook page from
@@ -35,11 +35,11 @@ import org.eclipse.swt.events.*;
* IMPORTANT: This class is <em>not</em> intended to be subclassed.
* </p>
*/
-public class TabFolder extends Composite {
- int parentingHandle;
- TabItem [] items;
- int itemCount, currentIndex = OS.Pt_PG_INVALID;
-
+public class TabFolder extends Composite {
+ int parentingHandle;
+ TabItem [] items;
+ int itemCount, currentIndex = OS.Pt_PG_INVALID;
+
/**
* Constructs a new instance of this class given its parent
* and a style value describing its behavior and appearance.
@@ -68,21 +68,21 @@ public class TabFolder extends Composite {
* @see Widget#checkSubclass
* @see Widget#getStyle
*/
-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 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);
+}
+
/**
* Adds the listener to the collection of listeners who will
* be notified when the receiver's selection changes, by sending
@@ -107,169 +107,169 @@ static int checkStyle (int style) {
* @see #removeSelectionListener
* @see SelectionEvent
*/
-public void addSelectionListener(SelectionListener listener) {
- checkWidget();
- if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
- TypedListener typedListener = new TypedListener(listener);
- addListener(SWT.Selection,typedListener);
- addListener(SWT.DefaultSelection,typedListener);
-}
-
-protected void checkSubclass () {
- if (!isValidSubclass ()) error (SWT.ERROR_INVALID_SUBCLASS);
-}
-
-public Point computeSize (int wHint, int hHint, boolean changed) {
- checkWidget();
- 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 (wHint, hHint, changed);
- }
- if (size.x == 0) size.x = DEFAULT_WIDTH;
- if (size.y == 0) size.y = DEFAULT_HEIGHT;
- if (wHint != SWT.DEFAULT) size.x = wHint;
- if (hHint != SWT.DEFAULT) size.y = hHint;
- 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();
- 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) {
- state |= HANDLE;
- Display display = getDisplay ();
- int parentHandle = parent.parentingHandle ();
- int [] args = {
- OS.Pt_ARG_RESIZE_FLAGS, 0, OS.Pt_RESIZE_XY_BITS,
- };
- parentingHandle = OS.PtCreateWidget (OS.PtContainer (), parentHandle, args.length / 3, args);
- if (parentingHandle == 0) error (SWT.ERROR_NO_HANDLES);
- int clazz = display.PtPanelGroup;
- args = new int []{
- OS.Pt_ARG_RESIZE_FLAGS, 0, OS.Pt_RESIZE_XY_BITS,
- };
- handle = OS.PtCreateWidget (clazz, parentingHandle, 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 count = itemCount;
- 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 [] args = {OS.Pt_ARG_PG_PANEL_TITLES, 0, 0};
- OS.PtGetResources (handle, args.length / 3, args);
- int oldPtr = args [1];
- int newPtr = OS.malloc ((count + 1) * 4);
- if (newPtr == 0) error (SWT.ERROR_ITEM_NOT_ADDED);
- int j = 0;
- int [] str = new int [1];
- int [] address = new int [1];
- for (int i=0; i<=count; i++) {
- if (i == index) {
- str [0] = OS.malloc (1);
- } else {
- OS.memmove (address, oldPtr + (j++ * 4), 4);
- str [0] = OS.strdup (address [0]);
- }
- if (str [0] == 0) error (SWT.ERROR_ITEM_NOT_ADDED);
- OS.memmove (newPtr + (i * 4), str, 4);
- }
- OS.PtSetResource (handle, OS.Pt_ARG_PG_PANEL_TITLES, newPtr, count + 1);
- for (int i=0; i<=count; i++) {
- 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;
- itemCount++;
-}
-
-void deregister () {
- super.deregister ();
- if (parentingHandle != 0) WidgetTable.remove (parentingHandle);
-}
-
-void destroyItem (TabItem item) {
- int count = itemCount;
- int index = 0;
- while (index < count) {
- if (items [index] == item) break;
- index++;
- }
- int [] args = {OS.Pt_ARG_PG_PANEL_TITLES, 0, 0};
- OS.PtGetResources (handle, args.length / 3, args);
- int oldPtr = args [1];
- int newPtr = OS.malloc ((count - 1) * 4);
- if (newPtr == 0) error (SWT.ERROR_ITEM_NOT_ADDED);
- int j = 0;
- int [] str = new int [1];
- int [] address = new int [1];
- for (int i=0; i<count; i++) {
- if (i == index) continue;
- OS.memmove (address, oldPtr + (i * 4), 4);
- str [0] = OS.strdup (address [0]);
- if (str [0] == 0) error (SWT.ERROR_ITEM_NOT_ADDED);
- OS.memmove (newPtr + (j++ * 4), str, 4);
- }
- OS.PtSetResource (handle, OS.Pt_ARG_PG_PANEL_TITLES, newPtr, count - 1);
- for (int i=0; i<count-1; i++) {
- 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;
- itemCount--;
-}
-
-public Rectangle getClientArea () {
- checkWidget();
- PhArea_t area = new PhArea_t ();
- if (!OS.PtWidgetIsRealized (handle)) OS.PtExtentWidgetFamily (handle);
- int clientHandle = OS.PtWidgetChildBack (handle);
- OS.PtWidgetArea (clientHandle, area);
- return new Rectangle (area.pos_x, area.pos_y, area.size_w, area.size_h);
-}
-
+public void addSelectionListener(SelectionListener listener) {
+ checkWidget();
+ if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+ TypedListener typedListener = new TypedListener(listener);
+ addListener(SWT.Selection,typedListener);
+ addListener(SWT.DefaultSelection,typedListener);
+}
+
+protected void checkSubclass () {
+ if (!isValidSubclass ()) error (SWT.ERROR_INVALID_SUBCLASS);
+}
+
+public Point computeSize (int wHint, int hHint, boolean changed) {
+ checkWidget();
+ 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 (wHint, hHint, changed);
+ }
+ if (size.x == 0) size.x = DEFAULT_WIDTH;
+ if (size.y == 0) size.y = DEFAULT_HEIGHT;
+ if (wHint != SWT.DEFAULT) size.x = wHint;
+ if (hHint != SWT.DEFAULT) size.y = hHint;
+ 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();
+ 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) {
+ state |= HANDLE;
+ Display display = getDisplay ();
+ int parentHandle = parent.parentingHandle ();
+ int [] args = {
+ OS.Pt_ARG_RESIZE_FLAGS, 0, OS.Pt_RESIZE_XY_BITS,
+ };
+ parentingHandle = OS.PtCreateWidget (OS.PtContainer (), parentHandle, args.length / 3, args);
+ if (parentingHandle == 0) error (SWT.ERROR_NO_HANDLES);
+ int clazz = display.PtPanelGroup;
+ args = new int []{
+ OS.Pt_ARG_RESIZE_FLAGS, 0, OS.Pt_RESIZE_XY_BITS,
+ };
+ handle = OS.PtCreateWidget (clazz, parentingHandle, 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 count = itemCount;
+ 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 [] args = {OS.Pt_ARG_PG_PANEL_TITLES, 0, 0};
+ OS.PtGetResources (handle, args.length / 3, args);
+ int oldPtr = args [1];
+ int newPtr = OS.malloc ((count + 1) * 4);
+ if (newPtr == 0) error (SWT.ERROR_ITEM_NOT_ADDED);
+ int j = 0;
+ int [] str = new int [1];
+ int [] address = new int [1];
+ for (int i=0; i<=count; i++) {
+ if (i == index) {
+ str [0] = OS.malloc (1);
+ } else {
+ OS.memmove (address, oldPtr + (j++ * 4), 4);
+ str [0] = OS.strdup (address [0]);
+ }
+ if (str [0] == 0) error (SWT.ERROR_ITEM_NOT_ADDED);
+ OS.memmove (newPtr + (i * 4), str, 4);
+ }
+ OS.PtSetResource (handle, OS.Pt_ARG_PG_PANEL_TITLES, newPtr, count + 1);
+ for (int i=0; i<=count; i++) {
+ 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;
+ itemCount++;
+}
+
+void deregister () {
+ super.deregister ();
+ if (parentingHandle != 0) WidgetTable.remove (parentingHandle);
+}
+
+void destroyItem (TabItem item) {
+ int count = itemCount;
+ int index = 0;
+ while (index < count) {
+ if (items [index] == item) break;
+ index++;
+ }
+ int [] args = {OS.Pt_ARG_PG_PANEL_TITLES, 0, 0};
+ OS.PtGetResources (handle, args.length / 3, args);
+ int oldPtr = args [1];
+ int newPtr = OS.malloc ((count - 1) * 4);
+ if (newPtr == 0) error (SWT.ERROR_ITEM_NOT_ADDED);
+ int j = 0;
+ int [] str = new int [1];
+ int [] address = new int [1];
+ for (int i=0; i<count; i++) {
+ if (i == index) continue;
+ OS.memmove (address, oldPtr + (i * 4), 4);
+ str [0] = OS.strdup (address [0]);
+ if (str [0] == 0) error (SWT.ERROR_ITEM_NOT_ADDED);
+ OS.memmove (newPtr + (j++ * 4), str, 4);
+ }
+ OS.PtSetResource (handle, OS.Pt_ARG_PG_PANEL_TITLES, newPtr, count - 1);
+ for (int i=0; i<count-1; i++) {
+ 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;
+ itemCount--;
+}
+
+public Rectangle getClientArea () {
+ checkWidget();
+ PhArea_t area = new PhArea_t ();
+ if (!OS.PtWidgetIsRealized (handle)) OS.PtExtentWidgetFamily (handle);
+ int clientHandle = OS.PtWidgetChildBack (handle);
+ OS.PtWidgetArea (clientHandle, area);
+ return new Rectangle (area.pos_x, area.pos_y, area.size_w, area.size_h);
+}
+
/**
* Returns the item at the given, zero-relative index in the
* receiver. Throws an exception if the index is out of range.
@@ -285,12 +285,12 @@ public Rectangle getClientArea () {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public TabItem getItem (int index) {
- checkWidget();
- if (!(0 <= index && index < itemCount)) error (SWT.ERROR_INVALID_RANGE);
- return items [index];
-}
-
+public TabItem getItem (int index) {
+ checkWidget();
+ if (!(0 <= index && index < itemCount)) error (SWT.ERROR_INVALID_RANGE);
+ return items [index];
+}
+
/**
* Returns an array of <code>TabItem</code>s which are the items
* in the receiver.
@@ -307,13 +307,13 @@ public TabItem getItem (int index) {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public TabItem [] getItems () {
- checkWidget();
- TabItem [] result = new TabItem [itemCount];
- System.arraycopy (items, 0, result, 0, result.length);
- return result;
-}
-
+public TabItem [] getItems () {
+ checkWidget();
+ TabItem [] result = new TabItem [itemCount];
+ System.arraycopy (items, 0, result, 0, result.length);
+ return result;
+}
+
/**
* Returns the number of items contained in the receiver.
*
@@ -324,11 +324,11 @@ public TabItem [] getItems () {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public int getItemCount () {
- checkWidget();
- return itemCount;
-}
-
+public int getItemCount () {
+ checkWidget();
+ return itemCount;
+}
+
/**
* Returns an array of <code>TabItem</code>s that are currently
* selected in the receiver. An empty array indicates that no
@@ -345,13 +345,13 @@ public int getItemCount () {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public TabItem [] getSelection () {
- checkWidget();
- int index = getSelectionIndex ();
- if (index == -1) return new TabItem [0];
- return new TabItem [] {items [index]};
-}
-
+public TabItem [] getSelection () {
+ checkWidget();
+ int index = getSelectionIndex ();
+ 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.
@@ -363,26 +363,26 @@ public TabItem [] getSelection () {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public int getSelectionIndex () {
- checkWidget();
- int index;
- if (currentIndex != OS.Pt_PG_INVALID && !OS.PtWidgetIsRealized (handle)) {
- index = currentIndex;
- } else {
- int [] args = {OS.Pt_ARG_PG_CURRENT_INDEX, 0, 0};
- OS.PtGetResources (handle, args.length / 3, args);
- index = args [1];
- }
- return index == OS.Pt_PG_INVALID ? -1 : index;
-}
-
-void hookEvents () {
- super.hookEvents ();
- int windowProc = getDisplay ().windowProc;
- OS.PtAddCallback (handle, OS.Pt_CB_PG_PANEL_SWITCHING, windowProc, OS.Pt_CB_PG_PANEL_SWITCHING);
- OS.PtAddCallback (handle, OS.Pt_CB_REALIZED, windowProc, OS.Pt_CB_REALIZED);
-}
-
+public int getSelectionIndex () {
+ checkWidget();
+ int index;
+ if (currentIndex != OS.Pt_PG_INVALID && !OS.PtWidgetIsRealized (handle)) {
+ index = currentIndex;
+ } else {
+ int [] args = {OS.Pt_ARG_PG_CURRENT_INDEX, 0, 0};
+ OS.PtGetResources (handle, args.length / 3, args);
+ index = args [1];
+ }
+ return index == OS.Pt_PG_INVALID ? -1 : index;
+}
+
+void hookEvents () {
+ super.hookEvents ();
+ int windowProc = getDisplay ().windowProc;
+ OS.PtAddCallback (handle, OS.Pt_CB_PG_PANEL_SWITCHING, windowProc, OS.Pt_CB_PG_PANEL_SWITCHING);
+ OS.PtAddCallback (handle, OS.Pt_CB_REALIZED, windowProc, OS.Pt_CB_REALIZED);
+}
+
/**
* Searches the receiver's list starting at the first item
* (index 0) until an item is found that is equal to the
@@ -400,106 +400,106 @@ void hookEvents () {
* <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);
- for (int i=0; i<itemCount; i++) {
- if (items [i] == item) return i;
- }
- return -1;
-}
-
-Point minimumSize (int wHint, int hHint, boolean flushCache) {
- Control [] children = _getChildren ();
- int width = 0, height = 0;
- for (int i=0; i<children.length; i++) {
- Control child = children [i];
- int index = 0;
- while (index < itemCount) {
- if (items [index].control == child) break;
- index++;
- }
- if (index == itemCount) {
- Rectangle rect = child.getBounds ();
- width = Math.max (width, rect.x + rect.width);
- height = Math.max (height, rect.y + rect.height);
- } else {
- Point size = child.computeSize (wHint, hHint, flushCache);
- width = Math.max (width, size.x);
- height = Math.max (height, size.y);
- }
- }
- return new Point (width, height);
-}
-
-void moveToBack (int child) {
- OS.PtWidgetInsert (child, handle, 0);
-}
-
-int parentingHandle () {
- return parentingHandle;
-}
-
-int Pt_CB_PG_PANEL_SWITCHING (int widget, 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);
- Control oldControl = null;
- int index = oldIndex [0];
- TabItem oldItem = items [index];
- if (0 <= index && index < itemCount) oldControl = oldItem.control;
- Control newControl = null;
- index = newIndex [0];
- TabItem newItem = items [index];
- if (0 <= index && index < itemCount) newControl = newItem.control;
- if (oldControl != null && !oldControl.isDisposed()) oldControl.setVisible (false);
- if (newControl != null && !newControl.isDisposed()) {
- newControl.setBounds (getClientArea ());
- newControl.setVisible (true);
- }
- Event event = new Event ();
- event.item = newItem;
- postEvent (SWT.Selection, event);
- return OS.Pt_CONTINUE;
-}
-
-int Pt_CB_REALIZED (int widget, int info) {
- int result = super.Pt_CB_REALIZED (widget, info);
- if (currentIndex != OS.Pt_PG_INVALID) {
- if (info == 0) return OS.Pt_END;
- PtCallbackInfo_t cbinfo = new PtCallbackInfo_t ();
- OS.memmove (cbinfo, info, PtCallbackInfo_t.sizeof);
- if (cbinfo.reason == OS.Pt_CB_REALIZED) {
- setSelection (currentIndex, false);
- currentIndex = OS.Pt_PG_INVALID;
- }
- }
- return result;
-}
-
-void register () {
- super.register ();
- if (parentingHandle != 0) WidgetTable.put (parentingHandle, this);
-}
-
-void releaseHandle () {
- super.releaseHandle ();
- parentingHandle = 0;
-}
-
-void releaseWidget () {
- for (int i=0; i<itemCount; i++) {
- TabItem item = items [i];
- if (!item.isDisposed ()) item.releaseResources ();
- }
- items = null;
- super.releaseWidget ();
-}
-
+public int indexOf (TabItem item) {
+ checkWidget();
+ if (item == null) error (SWT.ERROR_NULL_ARGUMENT);
+ for (int i=0; i<itemCount; i++) {
+ if (items [i] == item) return i;
+ }
+ return -1;
+}
+
+Point minimumSize (int wHint, int hHint, boolean flushCache) {
+ Control [] children = _getChildren ();
+ int width = 0, height = 0;
+ for (int i=0; i<children.length; i++) {
+ Control child = children [i];
+ int index = 0;
+ while (index < itemCount) {
+ if (items [index].control == child) break;
+ index++;
+ }
+ if (index == itemCount) {
+ Rectangle rect = child.getBounds ();
+ width = Math.max (width, rect.x + rect.width);
+ height = Math.max (height, rect.y + rect.height);
+ } else {
+ Point size = child.computeSize (wHint, hHint, flushCache);
+ width = Math.max (width, size.x);
+ height = Math.max (height, size.y);
+ }
+ }
+ return new Point (width, height);
+}
+
+void moveToBack (int child) {
+ OS.PtWidgetInsert (child, handle, 0);
+}
+
+int parentingHandle () {
+ return parentingHandle;
+}
+
+int Pt_CB_PG_PANEL_SWITCHING (int widget, 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);
+ Control oldControl = null;
+ int index = oldIndex [0];
+ TabItem oldItem = items [index];
+ if (0 <= index && index < itemCount) oldControl = oldItem.control;
+ Control newControl = null;
+ index = newIndex [0];
+ TabItem newItem = items [index];
+ if (0 <= index && index < itemCount) newControl = newItem.control;
+ if (oldControl != null && !oldControl.isDisposed()) oldControl.setVisible (false);
+ if (newControl != null && !newControl.isDisposed()) {
+ newControl.setBounds (getClientArea ());
+ newControl.setVisible (true);
+ }
+ Event event = new Event ();
+ event.item = newItem;
+ postEvent (SWT.Selection, event);
+ return OS.Pt_CONTINUE;
+}
+
+int Pt_CB_REALIZED (int widget, int info) {
+ int result = super.Pt_CB_REALIZED (widget, info);
+ if (currentIndex != OS.Pt_PG_INVALID) {
+ if (info == 0) return OS.Pt_END;
+ PtCallbackInfo_t cbinfo = new PtCallbackInfo_t ();
+ OS.memmove (cbinfo, info, PtCallbackInfo_t.sizeof);
+ if (cbinfo.reason == OS.Pt_CB_REALIZED) {
+ setSelection (currentIndex, false);
+ currentIndex = OS.Pt_PG_INVALID;
+ }
+ }
+ return result;
+}
+
+void register () {
+ super.register ();
+ if (parentingHandle != 0) WidgetTable.put (parentingHandle, this);
+}
+
+void releaseHandle () {
+ super.releaseHandle ();
+ parentingHandle = 0;
+}
+
+void releaseWidget () {
+ for (int i=0; i<itemCount; i++) {
+ TabItem item = items [i];
+ if (!item.isDisposed ()) item.releaseResources ();
+ }
+ items = null;
+ super.releaseWidget ();
+}
+
/**
* Removes the listener from the collection of listeners who will
* be notified when the receiver's selection changes.
@@ -517,32 +517,32 @@ void releaseWidget () {
* @see SelectionListener
* @see #addSelectionListener
*/
-public void removeSelectionListener (SelectionListener listener) {
- checkWidget();
- if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
- if (eventTable == null) return;
- eventTable.unhook (SWT.Selection, listener);
- eventTable.unhook (SWT.DefaultSelection,listener);
-}
-
-int setBounds (int x, int y, int width, int height, boolean move, boolean resize, boolean events) {
- int result = super.setBounds (x, y, width, height, move, resize, events);
- if ((result & RESIZED) != 0) {
- int [] args = {OS.Pt_ARG_WIDTH, 0, 0, OS.Pt_ARG_HEIGHT, 0, 0};
- OS.PtGetResources (parentingHandle, args.length / 3, args);
- OS.PtSetResources (handle, args.length / 3, args);
- int index = getSelectionIndex ();
- if (index != -1) {
- TabItem item = items [index];
- Control control = item.control;
- if (control != null && !control.isDisposed ()) {
- control.setBounds (getClientArea ());
- }
- }
- }
- return result;
-}
-
+public void removeSelectionListener (SelectionListener listener) {
+ checkWidget();
+ if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+ if (eventTable == null) return;
+ eventTable.unhook (SWT.Selection, listener);
+ eventTable.unhook (SWT.DefaultSelection,listener);
+}
+
+int setBounds (int x, int y, int width, int height, boolean move, boolean resize, boolean events) {
+ int result = super.setBounds (x, y, width, height, move, resize, events);
+ if ((result & RESIZED) != 0) {
+ int [] args = {OS.Pt_ARG_WIDTH, 0, 0, OS.Pt_ARG_HEIGHT, 0, 0};
+ OS.PtGetResources (parentingHandle, args.length / 3, args);
+ OS.PtSetResources (handle, args.length / 3, args);
+ int index = getSelectionIndex ();
+ if (index != -1) {
+ TabItem item = items [index];
+ Control control = item.control;
+ if (control != null && !control.isDisposed ()) {
+ control.setBounds (getClientArea ());
+ }
+ }
+ }
+ return result;
+}
+
/**
* Selects the item at the given zero-relative index in the receiver.
* If the item at the index was already selected, it remains selected.
@@ -556,50 +556,50 @@ int setBounds (int x, int y, int width, int height, boolean move, boolean resize
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public void setSelection (int index) {
- checkWidget();
- setSelection (index, false);
-}
-
-void setSelection (int index, boolean notify) {
- 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);
- }
- }
- if (index == -1) index = OS.Pt_PG_INVALID;
- OS.PtSetResource (handle, OS.Pt_ARG_PG_CURRENT_INDEX, index, 0);
- args [1] = 0;
- OS.PtGetResources (handle, args.length / 3, args);
- int newIndex = args [1];
- /*
- * Bug in Photon. Pt_ARG_PG_CURRENT_INDEX cannot be set if
- * the widget is not realized. The fix is to remember the current
- * index and reset it when the widget is realized.
- */
- if (!OS.PtWidgetIsRealized (handle)) {
- newIndex = currentIndex = index;
- }
- if (newIndex != OS.Pt_PG_INVALID) {
- TabItem item = items [newIndex];
- Control control = item.control;
- if (control != null && !control.isDisposed ()) {
- control.setBounds (getClientArea ());
- control.setVisible (true);
- }
- if (notify) {
- Event event = new Event ();
- event.item = item;
- postEvent (SWT.Selection, event);
- }
- }
-}
-
+public void setSelection (int index) {
+ checkWidget();
+ setSelection (index, false);
+}
+
+void setSelection (int index, boolean notify) {
+ 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);
+ }
+ }
+ if (index == -1) index = OS.Pt_PG_INVALID;
+ OS.PtSetResource (handle, OS.Pt_ARG_PG_CURRENT_INDEX, index, 0);
+ args [1] = 0;
+ OS.PtGetResources (handle, args.length / 3, args);
+ int newIndex = args [1];
+ /*
+ * Bug in Photon. Pt_ARG_PG_CURRENT_INDEX cannot be set if
+ * the widget is not realized. The fix is to remember the current
+ * index and reset it when the widget is realized.
+ */
+ if (!OS.PtWidgetIsRealized (handle)) {
+ newIndex = currentIndex = index;
+ }
+ if (newIndex != OS.Pt_PG_INVALID) {
+ TabItem item = items [newIndex];
+ Control control = item.control;
+ if (control != null && !control.isDisposed ()) {
+ control.setBounds (getClientArea ());
+ control.setVisible (true);
+ }
+ if (notify) {
+ Event event = new Event ();
+ event.item = item;
+ postEvent (SWT.Selection, event);
+ }
+ }
+}
+
/**
* Sets the receiver's selection to be the given array of items.
* The current selected is first cleared, then the new items are
@@ -612,39 +612,39 @@ void setSelection (int index, boolean notify) {
* <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);
- }
-}
-
-boolean traversePage (boolean next) {
- int count = getItemCount ();
- if (count == 0) return false;
- int index = getSelectionIndex ();
- if (index == -1) {
- index = 0;
- } else {
- int offset = next ? 1 : -1;
- index = (index + offset + count) % count;
- }
- setSelection (index, true);
- return true;
-}
-
-int topHandle () {
- return parentingHandle;
-}
-
-int widgetClass () {
- return OS.PtPanelGroup ();
-}
-
-}
+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);
+ }
+}
+
+boolean traversePage (boolean next) {
+ int count = getItemCount ();
+ if (count == 0) return false;
+ int index = getSelectionIndex ();
+ if (index == -1) {
+ index = 0;
+ } else {
+ int offset = next ? 1 : -1;
+ index = (index + offset + count) % count;
+ }
+ setSelection (index, true);
+ return true;
+}
+
+int topHandle () {
+ return parentingHandle;
+}
+
+int widgetClass () {
+ return OS.PtPanelGroup ();
+}
+
+}
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
index 3b4e125e97..0a9ffda9d3 100755
--- 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
@@ -1,17 +1,17 @@
-package org.eclipse.swt.widgets;
-
-/*
+package org.eclipse.swt.widgets;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-import org.eclipse.swt.internal.*;
-import org.eclipse.swt.internal.photon.*;
-import org.eclipse.swt.*;
-import org.eclipse.swt.graphics.*;
-
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+import org.eclipse.swt.internal.*;
+import org.eclipse.swt.internal.photon.*;
+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.
@@ -25,11 +25,11 @@ import org.eclipse.swt.graphics.*;
* IMPORTANT: This class is <em>not</em> intended to be subclassed.
* </p>
*/
-public class TabItem extends Item {
- TabFolder parent;
- Control control;
- String toolTipText;
-
+public class TabItem extends Item {
+ TabFolder parent;
+ Control control;
+ String toolTipText;
+
/**
* Constructs a new instance of this class given its parent
* (which must be a <code>TabFolder</code>) and a style value
@@ -60,10 +60,10 @@ public class TabItem extends Item {
* @see Widget#checkSubclass
* @see Widget#getStyle
*/
-public TabItem (TabFolder parent, int style) {
- this(parent, style, parent.getItemCount ());
-}
-
+public TabItem (TabFolder parent, int style) {
+ this(parent, style, parent.getItemCount ());
+}
+
/**
* Constructs a new instance of this class given its parent
* (which must be a <code>TabFolder</code>), a style value
@@ -95,16 +95,16 @@ public TabItem (TabFolder parent, int style) {
* @see Widget#checkSubclass
* @see Widget#getStyle
*/
-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 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
@@ -117,17 +117,17 @@ protected void checkSubclass () {
* <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 ();
-}
-
+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>.
*
@@ -138,11 +138,11 @@ public Display getDisplay () {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public TabFolder getParent () {
- checkWidget();
- return parent;
-}
-
+public TabFolder getParent () {
+ checkWidget();
+ return parent;
+}
+
/**
* Returns the receiver's tool tip text, or null if it has
* not been set.
@@ -154,27 +154,27 @@ public TabFolder getParent () {
* <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;
- toolTipText = null;
-}
-
+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;
+ toolTipText = null;
+}
+
/**
* Sets the control that is used to fill the client area of
* the tab folder when the user selects the tab item.
@@ -190,65 +190,65 @@ void releaseWidget () {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public void setControl (Control control) {
- checkWidget();
- if (control != null) {
- if (control.isDisposed()) error (SWT.ERROR_INVALID_ARGUMENT);
- if (control.parent != parent) error (SWT.ERROR_INVALID_PARENT);
- }
- if (this.control != null && this.control.isDisposed ()) {
- this.control = null;
- }
- 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();
- //NOT SUPPORTED
-}
-
-public void setText (String string) {
- checkWidget();
- if (string == null) error (SWT.ERROR_NULL_ARGUMENT);
- super.setText (string);
- 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);
- int [] str = new int [1];
- int [] address = new int [1];
- byte [] buffer = Converter.wcsToMbcs (null, stripMnemonics (string), true);
- for (int i=0; i<count; i++) {
- if (i == index) {
- str [0] = OS.malloc (buffer.length);
- OS.memmove (str [0], buffer, buffer.length);
- } else {
- OS.memmove (address, oldPtr + (i * 4), 4);
- str [0] = OS.strdup (address [0]);
- }
- OS.memmove (newPtr + (i * 4), str, 4);
- }
- OS.PtSetResource (parent.handle, OS.Pt_ARG_PG_PANEL_TITLES, newPtr, count);
- for (int i=0; i<count; i++) {
- OS.memmove (address, newPtr + (i * 4), 4);
- OS.free (address [0]);
- }
- OS.free (newPtr);
-}
-
+public void setControl (Control control) {
+ checkWidget();
+ if (control != null) {
+ if (control.isDisposed()) error (SWT.ERROR_INVALID_ARGUMENT);
+ if (control.parent != parent) error (SWT.ERROR_INVALID_PARENT);
+ }
+ if (this.control != null && this.control.isDisposed ()) {
+ this.control = null;
+ }
+ 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();
+ //NOT SUPPORTED
+}
+
+public void setText (String string) {
+ checkWidget();
+ if (string == null) error (SWT.ERROR_NULL_ARGUMENT);
+ super.setText (string);
+ 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);
+ int [] str = new int [1];
+ int [] address = new int [1];
+ byte [] buffer = Converter.wcsToMbcs (null, stripMnemonics (string), true);
+ for (int i=0; i<count; i++) {
+ if (i == index) {
+ str [0] = OS.malloc (buffer.length);
+ OS.memmove (str [0], buffer, buffer.length);
+ } else {
+ OS.memmove (address, oldPtr + (i * 4), 4);
+ str [0] = OS.strdup (address [0]);
+ }
+ OS.memmove (newPtr + (i * 4), str, 4);
+ }
+ OS.PtSetResource (parent.handle, OS.Pt_ARG_PG_PANEL_TITLES, newPtr, count);
+ for (int i=0; i<count; i++) {
+ OS.memmove (address, newPtr + (i * 4), 4);
+ OS.free (address [0]);
+ }
+ OS.free (newPtr);
+}
+
/**
* Sets the receiver's tool tip text to the argument, which
* may be null indicating that no tool tip text should be shown.
@@ -260,9 +260,9 @@ public void setText (String string) {
* <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;
-}
-
-}
+public void setToolTipText (String string) {
+ checkWidget();
+ toolTipText = string;
+}
+
+}
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
index e2d67ff41d..af858421d7 100755
--- 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
@@ -1,18 +1,18 @@
-package org.eclipse.swt.widgets;
-
-/*
+package org.eclipse.swt.widgets;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-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.*;
-
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+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.*;
+
/**
* Instances of this class are selectable user interface
* objects that allow the user to enter and modify text.
@@ -29,25 +29,25 @@ import org.eclipse.swt.events.*;
* IMPORTANT: This class is <em>not</em> intended to be subclassed.
* </p>
*/
-public class Text extends Scrollable {
- char echoCharacter;
- boolean ignoreChange;
- String hiddenText;
- int tabs, 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 class Text extends Scrollable {
+ char echoCharacter;
+ boolean ignoreChange;
+ String hiddenText;
+ int tabs, 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";
+ }
+
/**
* Constructs a new instance of this class given its parent
* and a style value describing its behavior and appearance.
@@ -79,65 +79,65 @@ public class Text extends Scrollable {
* @see Widget#checkSubclass
* @see Widget#getStyle
*/
-public Text (Composite parent, int style) {
- super (parent, checkStyle (style));
-}
-
-static int checkStyle (int style) {
- style = checkBits (style, SWT.LEFT, SWT.CENTER, SWT.RIGHT, 0, 0, 0);
- if ((style & SWT.SINGLE) != 0) style &= ~(SWT.H_SCROLL | SWT.V_SCROLL | SWT.WRAP);
- if ((style & SWT.WRAP) != 0) style |= SWT.MULTI;
- 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) {
- checkWidget();
-
- int [] args = new int [] {OS.Pt_ARG_WIDTH, 0, 0, OS.Pt_ARG_HEIGHT, 0, 0};
- OS.PtGetResources (handle, args.length / 3, args);
- boolean wrap = (style & SWT.WRAP) != 0;
- if (wrap) {
- if (wHint == SWT.DEFAULT) {
- OS.PtSetResource (handle, OS.Pt_ARG_MULTITEXT_WRAP_FLAGS, OS.Pt_EMT_NEWLINE, ~0);
- } else {
- OS.PtSetResource (handle, OS.Pt_ARG_WIDTH, wHint, 0);
- }
- }
- int resizeFlags = OS.Pt_RESIZE_X_ALWAYS | OS.Pt_RESIZE_Y_ALWAYS;
- OS.PtSetResource (handle, OS.Pt_ARG_RESIZE_FLAGS, resizeFlags, OS.Pt_RESIZE_XY_BITS);
- if ((style & SWT.MULTI) != 0 || !OS.PtWidgetIsRealized (handle)) OS.PtExtentWidgetFamily (handle);
- PhDim_t dim = new PhDim_t ();
- OS.PtWidgetPreferredSize (handle, dim);
- int width = dim.w, height = dim.h;
- OS.PtSetResource (handle, OS.Pt_ARG_RESIZE_FLAGS, 0, OS.Pt_RESIZE_XY_BITS);
- if (wrap) {
- if (wHint == SWT.DEFAULT) {
- int wrapFlags = OS.Pt_EMT_WORD | OS.Pt_EMT_CHAR | OS.Pt_EMT_NEWLINE;
- OS.PtSetResource (handle, OS.Pt_ARG_MULTITEXT_WRAP_FLAGS, wrapFlags, ~0);
- }
- }
- OS.PtSetResources (handle, args.length / 3, args);
-
- ScrollBar scroll;
- int scrollWidth = (scroll = getVerticalBar ()) != null ? scroll.getSize ().x : 0;
- int scrollHeight = (scroll = getHorizontalBar ()) != null ? scroll.getSize ().y : 0;
- width += scrollWidth;
- if (!wrap) height += scrollHeight;
-
- 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 + scrollWidth;
- if (hHint != SWT.DEFAULT) height = area.size_h + scrollHeight;
- }
- return new Point(width, height);
-}
+public Text (Composite parent, int style) {
+ super (parent, checkStyle (style));
+}
+
+static int checkStyle (int style) {
+ style = checkBits (style, SWT.LEFT, SWT.CENTER, SWT.RIGHT, 0, 0, 0);
+ if ((style & SWT.SINGLE) != 0) style &= ~(SWT.H_SCROLL | SWT.V_SCROLL | SWT.WRAP);
+ if ((style & SWT.WRAP) != 0) style |= SWT.MULTI;
+ 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) {
+ checkWidget();
+
+ int [] args = new int [] {OS.Pt_ARG_WIDTH, 0, 0, OS.Pt_ARG_HEIGHT, 0, 0};
+ OS.PtGetResources (handle, args.length / 3, args);
+ boolean wrap = (style & SWT.WRAP) != 0;
+ if (wrap) {
+ if (wHint == SWT.DEFAULT) {
+ OS.PtSetResource (handle, OS.Pt_ARG_MULTITEXT_WRAP_FLAGS, OS.Pt_EMT_NEWLINE, ~0);
+ } else {
+ OS.PtSetResource (handle, OS.Pt_ARG_WIDTH, wHint, 0);
+ }
+ }
+ int resizeFlags = OS.Pt_RESIZE_X_ALWAYS | OS.Pt_RESIZE_Y_ALWAYS;
+ OS.PtSetResource (handle, OS.Pt_ARG_RESIZE_FLAGS, resizeFlags, OS.Pt_RESIZE_XY_BITS);
+ if ((style & SWT.MULTI) != 0 || !OS.PtWidgetIsRealized (handle)) OS.PtExtentWidgetFamily (handle);
+ PhDim_t dim = new PhDim_t ();
+ OS.PtWidgetPreferredSize (handle, dim);
+ int width = dim.w, height = dim.h;
+ OS.PtSetResource (handle, OS.Pt_ARG_RESIZE_FLAGS, 0, OS.Pt_RESIZE_XY_BITS);
+ if (wrap) {
+ if (wHint == SWT.DEFAULT) {
+ int wrapFlags = OS.Pt_EMT_WORD | OS.Pt_EMT_CHAR | OS.Pt_EMT_NEWLINE;
+ OS.PtSetResource (handle, OS.Pt_ARG_MULTITEXT_WRAP_FLAGS, wrapFlags, ~0);
+ }
+ }
+ OS.PtSetResources (handle, args.length / 3, args);
+
+ ScrollBar scroll;
+ int scrollWidth = (scroll = getVerticalBar ()) != null ? scroll.getSize ().x : 0;
+ int scrollHeight = (scroll = getHorizontalBar ()) != null ? scroll.getSize ().y : 0;
+ width += scrollWidth;
+ if (!wrap) height += scrollHeight;
+
+ 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 + scrollWidth;
+ if (hHint != SWT.DEFAULT) height = area.size_h + scrollHeight;
+ }
+ return new Point(width, height);
+}
/**
* Clears the selection.
*
@@ -146,56 +146,56 @@ public Point computeSize (int wHint, int hHint, boolean changed) {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public void clearSelection () {
- checkWidget();
- int [] position = {0};
- if ((style & SWT.SINGLE) != 0) {
- int [] args = {OS.Pt_ARG_CURSOR_POSITION, 0, 0};
- OS.PtGetResources (handle, args.length / 3, args);
- position [0] = args [1];
- }
- OS.PtTextSetSelection (handle, position, position);
-}
-void createHandle (int index) {
- state |= HANDLE;
- Display display = getDisplay ();
- int parentHandle = parent.parentingHandle ();
- boolean hasBorder = (style & SWT.BORDER) != 0;
- 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, hasBorder ? OS.Pt_HIGHLIGHTED : 0, OS.Pt_HIGHLIGHTED,
- 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, hasBorder ? OS.Pt_HIGHLIGHTED : 0, OS.Pt_HIGHLIGHTED,
- 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);
- createStandardScrollBars ();
-}
-
-void createWidget (int index) {
- super.createWidget (index);
-// doubleClick = true;
- setTabStops (tabs = 8);
-}
-
+public void clearSelection () {
+ checkWidget();
+ int [] position = {0};
+ if ((style & SWT.SINGLE) != 0) {
+ int [] args = {OS.Pt_ARG_CURSOR_POSITION, 0, 0};
+ OS.PtGetResources (handle, args.length / 3, args);
+ position [0] = args [1];
+ }
+ OS.PtTextSetSelection (handle, position, position);
+}
+void createHandle (int index) {
+ state |= HANDLE;
+ Display display = getDisplay ();
+ int parentHandle = parent.parentingHandle ();
+ boolean hasBorder = (style & SWT.BORDER) != 0;
+ 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, hasBorder ? OS.Pt_HIGHLIGHTED : 0, OS.Pt_HIGHLIGHTED,
+ 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, hasBorder ? OS.Pt_HIGHLIGHTED : 0, OS.Pt_HIGHLIGHTED,
+ 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);
+ createStandardScrollBars ();
+}
+
+void createWidget (int index) {
+ super.createWidget (index);
+// doubleClick = true;
+ setTabStops (tabs = 8);
+}
+
/**
* Adds the listener to the collection of listeners who will
* be notified when the receiver's text is modified, by sending
@@ -215,13 +215,13 @@ void createWidget (int index) {
* @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);
-}
-
+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
@@ -246,14 +246,14 @@ public void addModifyListener (ModifyListener listener) {
* @see #removeSelectionListener
* @see SelectionEvent
*/
-public void addSelectionListener (SelectionListener listener) {
- checkWidget();
- if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
- TypedListener typedListener = new TypedListener (listener);
- addListener (SWT.Selection,typedListener);
- addListener (SWT.DefaultSelection,typedListener);
-}
-
+public 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
@@ -273,13 +273,13 @@ public void addSelectionListener (SelectionListener listener) {
* @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);
-}
-
+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>
@@ -297,13 +297,13 @@ public void addVerifyListener (VerifyListener listener) {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public void append (String string) {
- checkWidget();
- if (string == null) error (SWT.ERROR_NULL_ARGUMENT);
- byte [] buffer = Converter.wcsToMbcs (null, string, false);
- OS.PtTextModifyText (handle, 0, 0, -1, buffer, buffer.length);
-}
-
+public void append (String string) {
+ checkWidget();
+ if (string == null) error (SWT.ERROR_NULL_ARGUMENT);
+ byte [] buffer = Converter.wcsToMbcs (null, string, false);
+ OS.PtTextModifyText (handle, 0, 0, -1, buffer, buffer.length);
+}
+
/**
* Copies the selected text.
* <p>
@@ -315,19 +315,19 @@ public void append (String string) {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public void copy () {
- checkWidget();
- 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 copy () {
+ checkWidget();
+ 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);
+}
+
/**
* Cuts the selected text.
* <p>
@@ -343,46 +343,46 @@ public void copy () {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public void cut () {
- checkWidget();
- 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);
-}
-
-void deregister () {
- super.deregister ();
-
- /*
- * Bug in Photon. Even though the Pt_CB_GOT_FOCUS callback
- * is added to the multi-line text, the widget parameter
- * in the callback is a child of the multi-line text. The fix
- * is to register that child so that the lookup in the widget
- * table will find the muti-line text.
- */
- if ((style & SWT.MULTI) == 0) return;
- int child = OS.PtWidgetChildBack (handle);
- WidgetTable.remove (child);
-}
-
-int defaultBackground () {
- Display display = getDisplay ();
- return display.TEXT_BACKGROUND;
-}
-
-int defaultForeground () {
- Display display = getDisplay ();
- return display.TEXT_FOREGROUND;
-}
-
+public void cut () {
+ checkWidget();
+ 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);
+}
+
+void deregister () {
+ super.deregister ();
+
+ /*
+ * Bug in Photon. Even though the Pt_CB_GOT_FOCUS callback
+ * is added to the multi-line text, the widget parameter
+ * in the callback is a child of the multi-line text. The fix
+ * is to register that child so that the lookup in the widget
+ * table will find the muti-line text.
+ */
+ if ((style & SWT.MULTI) == 0) return;
+ int child = OS.PtWidgetChildBack (handle);
+ WidgetTable.remove (child);
+}
+
+int defaultBackground () {
+ Display display = getDisplay ();
+ return display.TEXT_BACKGROUND;
+}
+
+int defaultForeground () {
+ Display display = getDisplay ();
+ return display.TEXT_FOREGROUND;
+}
+
/**
* Gets the line number of the caret.
* <p>
@@ -399,12 +399,12 @@ int defaultForeground () {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public int getCaretLineNumber () {
- checkWidget();
- //NOT DONE - NOT NEEDED
- return 0;
-}
-
+public int getCaretLineNumber () {
+ checkWidget();
+ //NOT DONE - NOT NEEDED
+ return 0;
+}
+
/**
* Gets the location the caret.
* <p>
@@ -418,12 +418,12 @@ public int getCaretLineNumber () {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public Point getCaretLocation () {
- checkWidget();
- //NOT DONE - NOT NEEDED
- return null;
-}
-
+public Point getCaretLocation () {
+ checkWidget();
+ //NOT DONE - NOT NEEDED
+ return null;
+}
+
/**
* Gets the position of the caret.
* <p>
@@ -437,13 +437,13 @@ public Point getCaretLocation () {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public int getCaretPosition () {
- checkWidget();
- int [] args = {OS.Pt_ARG_CURSOR_POSITION, 0, 0};
- OS.PtGetResources (handle, args.length / 3, args);
- return args [1];
-}
-
+public int getCaretPosition () {
+ checkWidget();
+ int [] args = {OS.Pt_ARG_CURSOR_POSITION, 0, 0};
+ OS.PtGetResources (handle, args.length / 3, args);
+ return args [1];
+}
+
/**
* Gets the number of characters.
*
@@ -454,14 +454,14 @@ public int getCaretPosition () {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public int getCharCount () {
- checkWidget();
- 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 int getCharCount () {
+ checkWidget();
+ 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]);
+}
+
/**
* Gets the double click enabled flag.
* <p>
@@ -475,12 +475,12 @@ public int getCharCount () {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public boolean getDoubleClickEnabled () {
- checkWidget();
- //NOT DONE - NOT NEEDED
- return false;
-}
-
+public boolean getDoubleClickEnabled () {
+ checkWidget();
+ //NOT DONE - NOT NEEDED
+ return false;
+}
+
/**
* Gets the echo character.
* <p>
@@ -494,11 +494,11 @@ public boolean getDoubleClickEnabled () {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public char getEchoChar () {
- checkWidget();
- return echoCharacter;
-}
-
+public char getEchoChar () {
+ checkWidget();
+ return echoCharacter;
+}
+
/**
* Gets the editable state.
*
@@ -507,13 +507,13 @@ public char getEchoChar () {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public boolean getEditable () {
- checkWidget();
- int [] args = {OS.Pt_ARG_TEXT_FLAGS, 0, 0};
- OS.PtGetResources(handle, args.length / 3, args);
- return (args [1] & OS.Pt_EDITABLE) != 0;
-}
-
+public boolean getEditable () {
+ checkWidget();
+ int [] args = {OS.Pt_ARG_TEXT_FLAGS, 0, 0};
+ OS.PtGetResources(handle, args.length / 3, args);
+ return (args [1] & OS.Pt_EDITABLE) != 0;
+}
+
/**
* Gets the number of lines.
*
@@ -524,14 +524,14 @@ public boolean getEditable () {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public int getLineCount () {
- checkWidget();
- if ((style & SWT.SINGLE) != 0) return 1;
- int [] args = {OS.Pt_ARG_MULTITEXT_NUM_LINES, 0, 0};
- OS.PtGetResources(handle, args.length / 3, args);
- return args [1];
-}
-
+public int getLineCount () {
+ checkWidget();
+ 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];
+}
+
/**
* Gets the line delimiter.
*
@@ -542,11 +542,11 @@ public int getLineCount () {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public String getLineDelimiter () {
- checkWidget();
- return "\n";
-}
-
+public String getLineDelimiter () {
+ checkWidget();
+ return "\n";
+}
+
/**
* Gets the height of a line.
*
@@ -557,39 +557,39 @@ public String getLineDelimiter () {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public int getLineHeight () {
- checkWidget();
- 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];
-}
-
-String getNameText () {
- if ((style & SWT.SINGLE) != 0) return getText ();
- return getText (0, Math.min(getCharCount () - 1, 10));
-}
-
+public int getLineHeight () {
+ checkWidget();
+ 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];
+}
+
+String getNameText () {
+ if ((style & SWT.SINGLE) != 0) return getText ();
+ return getText (0, Math.min(getCharCount () - 1, 10));
+}
+
/**
* Gets the position of the selected text.
* <p>
@@ -605,21 +605,21 @@ String getNameText () {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public Point getSelection () {
- checkWidget();
- 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 Point getSelection () {
+ checkWidget();
+ 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]);
+}
+
/**
* Gets the number of selected characters.
*
@@ -630,12 +630,12 @@ public Point getSelection () {
* <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;
-}
-
+public int getSelectionCount () {
+ checkWidget();
+ Point selection = getSelection ();
+ return selection.y - selection.x;
+}
+
/**
* Gets the selected text.
*
@@ -646,17 +646,17 @@ public int getSelectionCount () {
* <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);
-}
-
+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>
@@ -672,23 +672,23 @@ public String getSelectionText () {
* <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 [] args = new int [] {OS.Pt_ARG_TEXT_FONT, 0, 0};
- OS.PtGetResources (handle, args.length / 3, args);
- PhRect_t rect = new PhRect_t ();
- int ptr = OS.malloc (1);
- OS.memmove (ptr, new byte [] {' '}, 1);
- OS.PfExtentText(rect, null, args [1], ptr, 1);
- OS.free (ptr);
- int width = rect.lr_x - rect.ul_x + 1;
- return width * tabs;
-}
-
+public int getTabs () {
+ checkWidget();
+ return tabs;
+}
+
+int getTabWidth (int tabs) {
+ int [] args = new int [] {OS.Pt_ARG_TEXT_FONT, 0, 0};
+ OS.PtGetResources (handle, args.length / 3, args);
+ PhRect_t rect = new PhRect_t ();
+ int ptr = OS.malloc (1);
+ OS.memmove (ptr, new byte [] {' '}, 1);
+ OS.PfExtentText(rect, null, args [1], ptr, 1);
+ OS.free (ptr);
+ int width = rect.lr_x - rect.ul_x + 1;
+ return width * tabs;
+}
+
/**
* Gets a range of text.
* <p>
@@ -706,17 +706,17 @@ int getTabWidth (int tabs) {
* <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.
- */
- //NOT DONE - use OS in SINGLE text
- return getText ().substring (start, end + 1);
-}
-
+public String getText (int start, int end) {
+ checkWidget();
+ /*
+ * 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);
+}
+
/**
* Gets the widget text.
* <p>
@@ -730,19 +730,19 @@ public String getText (int start, int end) {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public String getText () {
- checkWidget();
- 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 String getText () {
+ checkWidget();
+ 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);
+}
+
/**
* Returns the maximum number of characters that the receiver is capable of holding.
* <p>
@@ -757,13 +757,13 @@ public String getText () {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public int getTextLimit () {
- checkWidget();
- int [] args = new int [] {OS.Pt_ARG_MAX_LENGTH, 0, 0};
- OS.PtGetResources (handle, args.length / 3, args);
- return args [1];
-}
-
+public int getTextLimit () {
+ checkWidget();
+ int [] args = new int [] {OS.Pt_ARG_MAX_LENGTH, 0, 0};
+ OS.PtGetResources (handle, args.length / 3, args);
+ return args [1];
+}
+
/**
* Returns the zero-relative index of the line which is currently
* at the top of the receiver.
@@ -778,14 +778,14 @@ public int getTextLimit () {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public int getTopIndex () {
- checkWidget();
- if ((style & SWT.SINGLE) != 0) return 0;
- int [] args = {OS.Pt_ARG_MULTITEXT_TOP_LINE, 0, 0};
- OS.PtGetResources(handle, args.length / 3, args);
- return args [1] - 1;
-}
-
+public int getTopIndex () {
+ checkWidget();
+ 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] - 1;
+}
+
/**
* Gets the top pixel.
* <p>
@@ -806,19 +806,19 @@ public int getTopIndex () {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public int getTopPixel () {
- checkWidget();
- //NOT DONE - NOT NEEDED
- return 0;
-}
-
-void hookEvents () {
- super.hookEvents ();
- int windowProc = getDisplay ().windowProc;
- OS.PtAddCallback (handle, OS.Pt_CB_MODIFY_VERIFY, windowProc, OS.Pt_CB_MODIFY_VERIFY);
- OS.PtAddCallback (handle, OS.Pt_CB_TEXT_CHANGED, windowProc, OS.Pt_CB_TEXT_CHANGED);
-}
-
+public int getTopPixel () {
+ checkWidget();
+ //NOT DONE - NOT NEEDED
+ return 0;
+}
+
+void hookEvents () {
+ super.hookEvents ();
+ int windowProc = getDisplay ().windowProc;
+ OS.PtAddCallback (handle, OS.Pt_CB_MODIFY_VERIFY, windowProc, OS.Pt_CB_MODIFY_VERIFY);
+ OS.PtAddCallback (handle, OS.Pt_CB_TEXT_CHANGED, windowProc, OS.Pt_CB_TEXT_CHANGED);
+}
+
/**
* Inserts a string.
* <p>
@@ -832,20 +832,20 @@ void hookEvents () {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public void insert (String string) {
- checkWidget();
- if (string == null) error (SWT.ERROR_NULL_ARGUMENT);
- byte [] buffer = Converter.wcsToMbcs (null, string, false);
- 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 insert (String string) {
+ checkWidget();
+ 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);
+}
+
/**
* Pastes text from clipboard.
* <p>
@@ -858,136 +858,136 @@ public void insert (String string) {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public void paste () {
- checkWidget();
- 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 Pt_CB_GOT_FOCUS (int widget, int info) {
-
- /*
- * Bug in Photon. Even though the Pt_CB_GOT_FOCUS callback
- * is added to the multi-line text, the widget parameter
- * in the callback is a child of the multi-line text. The fix
- * is to register that child so that the lookup in the widget
- * table will find the muti-line text and avoid multiple
- * Pt_CB_LOST_FOCUS callbacks.
- */
- if ((style & SWT.MULTI) != 0) {
- if (widget != handle) return OS.Pt_CONTINUE;
- }
- return super.Pt_CB_GOT_FOCUS (widget, info);
-}
-
-int Pt_CB_MODIFY_VERIFY (int widget, int info) {
- if (lastModifiedText != 0) {
- OS.free (lastModifiedText);
- lastModifiedText = 0;
- }
- if (echoCharacter == '\0' && !hooks (SWT.Verify) && !filters (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;
- if (cbinfo.event != 0) {
- int data = OS.PhGetData (cbinfo.event);
- if (data != 0) {
- PhKeyEvent_t ke = new PhKeyEvent_t ();
- OS.memmove (ke, data, PhKeyEvent_t.sizeof);
- if ((ke.key_flags & (OS.Pk_KF_Key_Down | OS.Pk_KF_Key_Repeat)) != 0) {
- setKeyState (event, ke);
- }
- }
- }
- 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 OS.Pt_CONTINUE;
-}
-
-int Pt_CB_TEXT_CHANGED (int widget, int info) {
- if (lastModifiedText != 0) {
- OS.free (lastModifiedText);
- lastModifiedText = 0;
- }
- if (!ignoreChange) sendEvent (SWT.Modify);
- return OS.Pt_CONTINUE;
-}
-
-void register () {
- super.register ();
-
- /*
- * Bug in Photon. Even though the Pt_CB_GOT_FOCUS callback
- * is added to the multi-line text, the widget parameter
- * in the callback is a child of the multi-line text. The fix
- * is to register that child so that the lookup in the widget
- * table will find the muti-line text.
- */
- if ((style & SWT.MULTI) == 0) return;
- int child = OS.PtWidgetChildBack (handle);
- WidgetTable.put (child, this);
-}
-
-void releaseWidget () {
- super.releaseWidget ();
- if (lastModifiedText != 0) OS.free (lastModifiedText);
- lastModifiedText = 0;
- hiddenText = null;
- textVerify = null;
-}
-
+public void paste () {
+ checkWidget();
+ 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 Pt_CB_GOT_FOCUS (int widget, int info) {
+
+ /*
+ * Bug in Photon. Even though the Pt_CB_GOT_FOCUS callback
+ * is added to the multi-line text, the widget parameter
+ * in the callback is a child of the multi-line text. The fix
+ * is to register that child so that the lookup in the widget
+ * table will find the muti-line text and avoid multiple
+ * Pt_CB_LOST_FOCUS callbacks.
+ */
+ if ((style & SWT.MULTI) != 0) {
+ if (widget != handle) return OS.Pt_CONTINUE;
+ }
+ return super.Pt_CB_GOT_FOCUS (widget, info);
+}
+
+int Pt_CB_MODIFY_VERIFY (int widget, int info) {
+ if (lastModifiedText != 0) {
+ OS.free (lastModifiedText);
+ lastModifiedText = 0;
+ }
+ if (echoCharacter == '\0' && !hooks (SWT.Verify) && !filters (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;
+ if (cbinfo.event != 0) {
+ int data = OS.PhGetData (cbinfo.event);
+ if (data != 0) {
+ PhKeyEvent_t ke = new PhKeyEvent_t ();
+ OS.memmove (ke, data, PhKeyEvent_t.sizeof);
+ if ((ke.key_flags & (OS.Pk_KF_Key_Down | OS.Pk_KF_Key_Repeat)) != 0) {
+ setKeyState (event, ke);
+ }
+ }
+ }
+ 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 OS.Pt_CONTINUE;
+}
+
+int Pt_CB_TEXT_CHANGED (int widget, int info) {
+ if (lastModifiedText != 0) {
+ OS.free (lastModifiedText);
+ lastModifiedText = 0;
+ }
+ if (!ignoreChange) sendEvent (SWT.Modify);
+ return OS.Pt_CONTINUE;
+}
+
+void register () {
+ super.register ();
+
+ /*
+ * Bug in Photon. Even though the Pt_CB_GOT_FOCUS callback
+ * is added to the multi-line text, the widget parameter
+ * in the callback is a child of the multi-line text. The fix
+ * is to register that child so that the lookup in the widget
+ * table will find the muti-line text.
+ */
+ if ((style & SWT.MULTI) == 0) return;
+ int child = OS.PtWidgetChildBack (handle);
+ WidgetTable.put (child, this);
+}
+
+void releaseWidget () {
+ super.releaseWidget ();
+ if (lastModifiedText != 0) OS.free (lastModifiedText);
+ lastModifiedText = 0;
+ hiddenText = null;
+ textVerify = null;
+}
+
/**
* Removes the listener from the collection of listeners who will
* be notified when the receiver's text is modified.
@@ -1005,13 +1005,13 @@ void releaseWidget () {
* @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);
-}
-
+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.
@@ -1029,14 +1029,14 @@ public void removeModifyListener (ModifyListener listener) {
* @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);
-}
-
+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.
@@ -1054,13 +1054,13 @@ public void removeSelectionListener (SelectionListener listener) {
* @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);
-}
-
+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.
*
@@ -1069,11 +1069,11 @@ public void removeVerifyListener (VerifyListener listener) {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public void selectAll () {
- checkWidget();
- OS.PtTextSetSelection (handle, new int [] {0}, new int [] {0x7FFFFFFF});
-}
-
+public void selectAll () {
+ checkWidget();
+ OS.PtTextSetSelection (handle, new int [] {0}, new int [] {0x7FFFFFFF});
+}
+
/**
* Sets the echo character.
* <p>
@@ -1094,25 +1094,25 @@ public void selectAll () {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public void setEchoChar (char echo) {
- checkWidget();
- 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 setEchoChar (char echo) {
+ checkWidget();
+ 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;
+}
+
/**
* Sets the double click enabled flag.
* <p>
@@ -1128,11 +1128,11 @@ public void setEchoChar (char echo) {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public void setDoubleClickEnabled (boolean doubleClick) {
- checkWidget();
- //NOT DONE - NOT NEEDED
-}
-
+public void setDoubleClickEnabled (boolean doubleClick) {
+ checkWidget();
+ //NOT DONE - NOT NEEDED
+}
+
/**
* Sets the editable state.
*
@@ -1143,19 +1143,19 @@ public void setDoubleClickEnabled (boolean doubleClick) {
* <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;
- int flags = editable ? OS.Pt_EDITABLE : 0;
- OS.PtSetResource (handle, OS.Pt_ARG_TEXT_FLAGS, flags, OS.Pt_EDITABLE);
-}
-
-public void setFont (Font font) {
- super.setFont (font);
- setTabStops (tabs);
-}
-
+public void setEditable (boolean editable) {
+ checkWidget();
+ style &= ~SWT.READ_ONLY;
+ if (!editable) style |= SWT.READ_ONLY;
+ int flags = editable ? OS.Pt_EDITABLE : 0;
+ OS.PtSetResource (handle, OS.Pt_ARG_TEXT_FLAGS, flags, OS.Pt_EDITABLE);
+}
+
+public void setFont (Font font) {
+ super.setFont (font);
+ setTabStops (tabs);
+}
+
/**
* Sets the selection.
* <p>
@@ -1179,22 +1179,22 @@ public void setFont (Font font) {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public void setSelection (int position) {
- checkWidget();
- OS.PtSetResource (handle, OS.Pt_ARG_CURSOR_POSITION, position, 0);
-
- /*
- * Feature in Photon. On a single-line text, the selection is
- * not cleared when setting the cursor position. The fix is to
- * set the selection start and end values to the specified
- * position.
- */
- if ((style & SWT.SINGLE) != 0) {
- int [] selection = {position};
- OS.PtTextSetSelection (handle, selection, selection);
- }
-}
-
+public void setSelection (int position) {
+ checkWidget();
+ OS.PtSetResource (handle, OS.Pt_ARG_CURSOR_POSITION, position, 0);
+
+ /*
+ * Feature in Photon. On a single-line text, the selection is
+ * not cleared when setting the cursor position. The fix is to
+ * set the selection start and end values to the specified
+ * position.
+ */
+ if ((style & SWT.SINGLE) != 0) {
+ int [] selection = {position};
+ OS.PtTextSetSelection (handle, selection, selection);
+ }
+}
+
/**
* Sets the selection.
* <p>
@@ -1221,12 +1221,12 @@ public void setSelection (int position) {
* <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);
-}
-
+public void setSelection (Point selection) {
+ checkWidget();
+ if (selection == null) error (SWT.ERROR_NULL_ARGUMENT);
+ setSelection (selection.x, selection.y);
+}
+
/**
* Sets the selection.
* <p>
@@ -1251,21 +1251,21 @@ public void setSelection (Point selection) {
* <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();
- OS.PtTextSetSelection (handle, new int [] {start}, new int [] {end});
-
- /*
- * Feature in Photon. On a multi-line text, the caret position
- * is not changed with the selection start and end values are
- * the same. The fix is to detect this case and change the
- * cursor position.
- */
- if ((style & SWT.MULTI) != 0 && start == end) {
- OS.PtSetResource (handle, OS.Pt_ARG_CURSOR_POSITION, start, 0);
- }
-}
-
+public void setSelection (int start, int end) {
+ checkWidget();
+ OS.PtTextSetSelection (handle, new int [] {start}, new int [] {end});
+
+ /*
+ * Feature in Photon. On a multi-line text, the caret position
+ * is not changed with the selection start and end values are
+ * the same. The fix is to detect this case and change the
+ * cursor position.
+ */
+ if ((style & SWT.MULTI) != 0 && start == end) {
+ OS.PtSetResource (handle, OS.Pt_ARG_CURSOR_POSITION, start, 0);
+ }
+}
+
/**
* Sets the number of tabs.
* <p>
@@ -1282,21 +1282,21 @@ public void setSelection (int start, int end) {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public void setTabs (int tabs) {
- checkWidget();
- if (tabs < 0) return;
- setTabStops (this.tabs = tabs);
-}
-
-void setTabStops (int tabs) {
- if ((style & SWT.SINGLE) != 0) return;
- int tabsWidth = getTabWidth (tabs);
- int ptr = OS.malloc (4);
- OS.memmove (ptr, new int [] {tabsWidth}, 4);
- OS.PtSetResource (handle, OS.Pt_ARG_MULTITEXT_TABS, ptr, 1);
- OS.free (ptr);
-}
-
+public void setTabs (int tabs) {
+ checkWidget();
+ if (tabs < 0) return;
+ setTabStops (this.tabs = tabs);
+}
+
+void setTabStops (int tabs) {
+ if ((style & SWT.SINGLE) != 0) return;
+ int tabsWidth = getTabWidth (tabs);
+ int ptr = OS.malloc (4);
+ OS.memmove (ptr, new int [] {tabsWidth}, 4);
+ OS.PtSetResource (handle, OS.Pt_ARG_MULTITEXT_TABS, ptr, 1);
+ OS.free (ptr);
+}
+
/**
* Sets the contents of the receiver to the given string. If the receiver has style
* SINGLE and the argument contains multiple lines of text, the result of this
@@ -1312,16 +1312,16 @@ void setTabStops (int tabs) {
* <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 (null, string, true);
- int ptr = OS.malloc (buffer.length);
- OS.memmove (ptr, buffer, buffer.length);
- OS.PtSetResource (handle, OS.Pt_ARG_TEXT_STRING, ptr, 0);
- OS.free (ptr);
-}
-
+public void setText (String string) {
+ checkWidget();
+ 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.PtSetResource (handle, OS.Pt_ARG_TEXT_STRING, ptr, 0);
+ OS.free (ptr);
+}
+
/**
* Sets the maximum number of characters that the receiver
* is capable of holding to be the argument.
@@ -1342,12 +1342,12 @@ public void setText (String string) {
* <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.PtSetResource (handle, OS.Pt_ARG_MAX_LENGTH, limit, 0);
-}
-
+public void setTextLimit (int limit) {
+ checkWidget();
+ if (limit == 0) error (SWT.ERROR_CANNOT_BE_ZERO);
+ OS.PtSetResource (handle, OS.Pt_ARG_MAX_LENGTH, 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
@@ -1360,12 +1360,12 @@ public void setTextLimit (int limit) {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public void setTopIndex (int index) {
- checkWidget();
- if ((style & SWT.SINGLE) != 0) return;
- OS.PtSetResource (handle, OS.Pt_ARG_MULTITEXT_TOP_LINE, index + 1, 0);
-}
-
+public void setTopIndex (int index) {
+ checkWidget();
+ if ((style & SWT.SINGLE) != 0) return;
+ OS.PtSetResource (handle, OS.Pt_ARG_MULTITEXT_TOP_LINE, index + 1, 0);
+}
+
/**
* Shows the selection.
* <p>
@@ -1382,37 +1382,37 @@ public void setTopIndex (int index) {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public void showSelection () {
- checkWidget();
- //NOT DONE - NOT NEEDED
-}
-
-int traversalCode (int key_sym, PhKeyEvent_t ke) {
- int code = super.traversalCode (key_sym, ke);
- if ((style & SWT.READ_ONLY) != 0) return code;
- if ((style & SWT.MULTI) != 0) {
- code &= ~SWT.TRAVERSE_RETURN;
- if (key_sym == OS.Pk_Tab && ke != null) {
- if ((ke.key_mods & OS.Pk_KM_Ctrl) == 0) {
- code &= ~(SWT.TRAVERSE_TAB_NEXT | SWT.TRAVERSE_TAB_PREVIOUS);
- }
- }
- }
- return code;
-}
-
-boolean translateTraversal (int key_sym, PhKeyEvent_t phEvent) {
- boolean translated = super.translateTraversal (key_sym, phEvent);
- if ((style & SWT.SINGLE) != 0 && !translated && key_sym == OS.Pk_Return) {
- postEvent (SWT.DefaultSelection);
- return false;
- }
- return translated;
-}
-
-int widgetClass () {
- if ((style & SWT.SINGLE) != 0) return OS.PtText ();
- return OS.PtMultiText ();
-}
-
-}
+public void showSelection () {
+ checkWidget();
+ //NOT DONE - NOT NEEDED
+}
+
+int traversalCode (int key_sym, PhKeyEvent_t ke) {
+ int code = super.traversalCode (key_sym, ke);
+ if ((style & SWT.READ_ONLY) != 0) return code;
+ if ((style & SWT.MULTI) != 0) {
+ code &= ~SWT.TRAVERSE_RETURN;
+ if (key_sym == OS.Pk_Tab && ke != null) {
+ if ((ke.key_mods & OS.Pk_KM_Ctrl) == 0) {
+ code &= ~(SWT.TRAVERSE_TAB_NEXT | SWT.TRAVERSE_TAB_PREVIOUS);
+ }
+ }
+ }
+ return code;
+}
+
+boolean translateTraversal (int key_sym, PhKeyEvent_t phEvent) {
+ boolean translated = super.translateTraversal (key_sym, phEvent);
+ if ((style & SWT.SINGLE) != 0 && !translated && key_sym == OS.Pk_Return) {
+ postEvent (SWT.DefaultSelection);
+ return false;
+ }
+ return translated;
+}
+
+int widgetClass () {
+ if ((style & SWT.SINGLE) != 0) return OS.PtText ();
+ return OS.PtMultiText ();
+}
+
+}
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
index 5ca0f9ee5a..9e2df2bba7 100755
--- 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
@@ -1,16 +1,16 @@
-package org.eclipse.swt.widgets;
-
-/*
+package org.eclipse.swt.widgets;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-import org.eclipse.swt.internal.photon.*;
-import org.eclipse.swt.*;
-import org.eclipse.swt.graphics.*;
-
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+import org.eclipse.swt.internal.photon.*;
+import org.eclipse.swt.*;
+import org.eclipse.swt.graphics.*;
+
/**
* Instances of this class support the layout of selectable
* tool bar items.
@@ -34,12 +34,12 @@ import org.eclipse.swt.graphics.*;
* IMPORTANT: This class is <em>not</em> intended to be subclassed.
* </p>
*/
-public class ToolBar extends Composite {
- int parentingHandle;
- int itemCount;
- ToolItem [] items;
- ToolItem lastFocus;
-
+public class ToolBar extends Composite {
+ int parentingHandle;
+ int itemCount;
+ ToolItem [] items;
+ ToolItem lastFocus;
+
/**
* Constructs a new instance of this class given its parent
* and a style value describing its behavior and appearance.
@@ -72,128 +72,128 @@ public class ToolBar extends Composite {
* @see Widget#checkSubclass
* @see Widget#getStyle
*/
-public ToolBar (Composite parent, int style) {
- super (parent, checkStyle (style));
-
- /*
- * Ensure that either of HORIZONTAL or VERTICAL is set.
- * NOTE: HORIZONTAL and VERTICAL have the same values
- * as H_SCROLL and V_SCROLL so it is necessary to first
- * clear these bits to avoid scroll bars and then reset
- * the bits using the original style supplied by the
- * programmer.
- */
- if ((style & SWT.VERTICAL) != 0) {
- this.style |= SWT.VERTICAL;
- } else {
- this.style |= SWT.HORIZONTAL;
- }
- int orientation = (style & SWT.VERTICAL) == 0 ? OS.Pt_HORIZONTAL : OS.Pt_VERTICAL;
- OS.PtSetResource (handle, OS.Pt_ARG_ORIENTATION, orientation, 0);
-}
-
-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);
- }
- 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) {
- state |= HANDLE;
- Display display = getDisplay ();
- int parentHandle = parent.parentingHandle ();
- int [] args = {
- OS.Pt_ARG_RESIZE_FLAGS, 0, OS.Pt_RESIZE_XY_BITS,
- };
- parentingHandle = OS.PtCreateWidget (OS.PtContainer (), parentHandle, args.length / 3, args);
- if (parentingHandle == 0) error (SWT.ERROR_NO_HANDLES);
- args = new int [] {
- OS.Pt_ARG_FLAGS, (style & SWT.NO_FOCUS) != 0 ? 0 : OS.Pt_GETS_FOCUS, OS.Pt_GETS_FOCUS,
- OS.Pt_ARG_FLAGS, hasBorder () ? OS.Pt_HIGHLIGHTED : 0, OS.Pt_HIGHLIGHTED,
- OS.Pt_ARG_TOOLBAR_FLAGS, 0, OS.Pt_TOOLBAR_DRAGGABLE | OS.Pt_TOOLBAR_END_SEPARATOR,
- OS.Pt_ARG_RESIZE_FLAGS, 0, OS.Pt_RESIZE_XY_BITS,
- };
- handle = OS.PtCreateWidget (display.PtToolbar, parentingHandle, args.length / 3, args);
- if ((style & SWT.FLAT) != 0) {
- OS.PtSetResource (handle, OS.Pt_ARG_BASIC_FLAGS, OS.Pt_FLAT_FILL, OS.Pt_FLAT_FILL);
- }
- 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 deregister () {
- super.deregister ();
- if (parentingHandle != 0) WidgetTable.remove (parentingHandle);
-}
-
-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 boolean forceFocus () {
- checkWidget();
- if (lastFocus != null && lastFocus.setFocus ()) return true;
- for (int i = 0; i < itemCount; i++) {
- ToolItem item = items [i];
- if (item.setFocus ()) return true;
- }
- return super.forceFocus ();
-}
-
+public ToolBar (Composite parent, int style) {
+ super (parent, checkStyle (style));
+
+ /*
+ * Ensure that either of HORIZONTAL or VERTICAL is set.
+ * NOTE: HORIZONTAL and VERTICAL have the same values
+ * as H_SCROLL and V_SCROLL so it is necessary to first
+ * clear these bits to avoid scroll bars and then reset
+ * the bits using the original style supplied by the
+ * programmer.
+ */
+ if ((style & SWT.VERTICAL) != 0) {
+ this.style |= SWT.VERTICAL;
+ } else {
+ this.style |= SWT.HORIZONTAL;
+ }
+ int orientation = (style & SWT.VERTICAL) == 0 ? OS.Pt_HORIZONTAL : OS.Pt_VERTICAL;
+ OS.PtSetResource (handle, OS.Pt_ARG_ORIENTATION, orientation, 0);
+}
+
+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);
+ }
+ 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) {
+ state |= HANDLE;
+ Display display = getDisplay ();
+ int parentHandle = parent.parentingHandle ();
+ int [] args = {
+ OS.Pt_ARG_RESIZE_FLAGS, 0, OS.Pt_RESIZE_XY_BITS,
+ };
+ parentingHandle = OS.PtCreateWidget (OS.PtContainer (), parentHandle, args.length / 3, args);
+ if (parentingHandle == 0) error (SWT.ERROR_NO_HANDLES);
+ args = new int [] {
+ OS.Pt_ARG_FLAGS, (style & SWT.NO_FOCUS) != 0 ? 0 : OS.Pt_GETS_FOCUS, OS.Pt_GETS_FOCUS,
+ OS.Pt_ARG_FLAGS, hasBorder () ? OS.Pt_HIGHLIGHTED : 0, OS.Pt_HIGHLIGHTED,
+ OS.Pt_ARG_TOOLBAR_FLAGS, 0, OS.Pt_TOOLBAR_DRAGGABLE | OS.Pt_TOOLBAR_END_SEPARATOR,
+ OS.Pt_ARG_RESIZE_FLAGS, 0, OS.Pt_RESIZE_XY_BITS,
+ };
+ handle = OS.PtCreateWidget (display.PtToolbar, parentingHandle, args.length / 3, args);
+ if ((style & SWT.FLAT) != 0) {
+ OS.PtSetResource (handle, OS.Pt_ARG_BASIC_FLAGS, OS.Pt_FLAT_FILL, OS.Pt_FLAT_FILL);
+ }
+ 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 deregister () {
+ super.deregister ();
+ if (parentingHandle != 0) WidgetTable.remove (parentingHandle);
+}
+
+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 boolean forceFocus () {
+ checkWidget();
+ if (lastFocus != null && lastFocus.setFocus ()) return true;
+ for (int i = 0; i < itemCount; i++) {
+ ToolItem item = items [i];
+ if (item.setFocus ()) return true;
+ }
+ return super.forceFocus ();
+}
+
/**
* Returns the number of items contained in the receiver.
*
@@ -204,11 +204,11 @@ public boolean forceFocus () {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public int getItemCount () {
- checkWidget();
- return itemCount;
-}
-
+public int getItemCount () {
+ checkWidget();
+ return itemCount;
+}
+
/**
* Returns an array of <code>TabItem</code>s which are the items
* in the receiver.
@@ -225,13 +225,13 @@ public int getItemCount () {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public ToolItem [] getItems () {
- checkWidget();
- ToolItem [] result = new ToolItem [itemCount];
- System.arraycopy (items, 0, result, 0, itemCount);
- return result;
-}
-
+public ToolItem [] getItems () {
+ checkWidget();
+ ToolItem [] result = new ToolItem [itemCount];
+ System.arraycopy (items, 0, result, 0, itemCount);
+ return result;
+}
+
/**
* Returns the item at the given, zero-relative index in the
* receiver. Throws an exception if the index is out of range.
@@ -247,13 +247,13 @@ public ToolItem [] getItems () {
* <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 = itemCount;
- if (!(0 <= index && index < count)) error (SWT.ERROR_INVALID_RANGE);
- return items [index];
-}
-
+public ToolItem getItem (int index) {
+ checkWidget();
+ int count = itemCount;
+ 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
@@ -270,15 +270,15 @@ public ToolItem getItem (int index) {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public ToolItem getItem (Point pt) {
- checkWidget();
- for (int i=0; i<itemCount; i++) {
- Rectangle rect = items [i].getBounds ();
- if (rect.contains (pt)) return items [i];
- }
- return null;
-}
-
+public ToolItem getItem (Point pt) {
+ checkWidget();
+ for (int i=0; i<itemCount; i++) {
+ Rectangle rect = items [i].getBounds ();
+ if (rect.contains (pt)) return items [i];
+ }
+ return null;
+}
+
/**
* Returns the number of rows in the receiver. When
* the receiver has the <code>WRAP</code> style, the
@@ -292,19 +292,19 @@ public ToolItem getItem (Point pt) {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public int getRowCount () {
- checkWidget();
- return 1;
-}
-
-boolean hasFocus () {
- for (int i=0; i<itemCount; i++) {
- ToolItem item = items [i];
- if (item.hasFocus ()) return true;
- }
- return super.hasFocus();
-}
-
+public int getRowCount () {
+ checkWidget();
+ return 1;
+}
+
+boolean hasFocus () {
+ for (int i=0; i<itemCount; i++) {
+ ToolItem item = items [i];
+ if (item.hasFocus ()) return true;
+ }
+ return super.hasFocus();
+}
+
/**
* Searches the receiver's list starting at the first item
* (index 0) until an item is found that is equal to the
@@ -323,130 +323,130 @@ boolean hasFocus () {
* <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);
- if (item.isDisposed()) error(SWT.ERROR_INVALID_ARGUMENT);
- int count = itemCount;
- for (int i=0; i<count; i++) {
- if (items [i] == item) return i;
- }
- return -1;
-}
-
-void moveToBack (int child) {
- OS.PtWidgetInsert (child, handle, 0);
-}
-
-int parentingHandle () {
- return parentingHandle;
-}
-
-int Ph_EV_BOUNDARY (int widget, 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);
- switch ((int) ev.subtype) {
- case OS.Ph_EV_PTR_ENTER_FROM_CHILD:
- case OS.Ph_EV_PTR_LEAVE_TO_CHILD:
- return OS.Pt_CONTINUE;
- }
- return super.Ph_EV_BOUNDARY (widget, info);
-}
-
-void register () {
- super.register ();
- if (parentingHandle != 0) WidgetTable.put (parentingHandle, this);
-}
-
-void releaseHandle () {
- super.releaseHandle ();
- parentingHandle = 0;
-}
-
-void releaseWidget () {
- for (int i=0; i<items.length; i++) {
- ToolItem item = items [i];
- if (item != null && !item.isDisposed ()) item.releaseResources ();
- }
- items = null;
- super.releaseWidget ();
-}
-
-void setBackgroundPixel (int pixel) {
- super.setBackgroundPixel (pixel);
- for (int i = 0; i < itemCount; i++) {
- ToolItem item = items[i];
- item.setBackgroundPixel (pixel);
- }
-}
-
-int setBounds (int x, int y, int width, int height, boolean move, boolean resize, boolean events) {
- int result = super.setBounds (x, y, width, height, move, resize, events);
- if ((result & RESIZED) != 0) {
- int [] args = {OS.Pt_ARG_WIDTH, 0, 0, OS.Pt_ARG_HEIGHT, 0, 0};
- OS.PtGetResources (parentingHandle, args.length / 3, args);
- OS.PtSetResources (handle, args.length / 3, args);
- }
- return result;
-}
-
-void setFont (int font) {
- super.setFont (font);
- for (int i = 0; i < itemCount; i++) {
- ToolItem item = items[i];
- item.setFont (font);
- }
-}
-
-void setForegroundPixel (int pixel) {
- super.setForegroundPixel (pixel);
+public int indexOf (ToolItem item) {
+ checkWidget();
+ if (item == null) error (SWT.ERROR_NULL_ARGUMENT);
+ if (item.isDisposed()) error(SWT.ERROR_INVALID_ARGUMENT);
+ int count = itemCount;
+ for (int i=0; i<count; i++) {
+ if (items [i] == item) return i;
+ }
+ return -1;
+}
+
+void moveToBack (int child) {
+ OS.PtWidgetInsert (child, handle, 0);
+}
+
+int parentingHandle () {
+ return parentingHandle;
+}
+
+int Ph_EV_BOUNDARY (int widget, 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);
+ switch ((int) ev.subtype) {
+ case OS.Ph_EV_PTR_ENTER_FROM_CHILD:
+ case OS.Ph_EV_PTR_LEAVE_TO_CHILD:
+ return OS.Pt_CONTINUE;
+ }
+ return super.Ph_EV_BOUNDARY (widget, info);
+}
+
+void register () {
+ super.register ();
+ if (parentingHandle != 0) WidgetTable.put (parentingHandle, this);
+}
+
+void releaseHandle () {
+ super.releaseHandle ();
+ parentingHandle = 0;
+}
+
+void releaseWidget () {
+ for (int i=0; i<items.length; i++) {
+ ToolItem item = items [i];
+ if (item != null && !item.isDisposed ()) item.releaseResources ();
+ }
+ items = null;
+ super.releaseWidget ();
+}
+
+void setBackgroundPixel (int pixel) {
+ super.setBackgroundPixel (pixel);
+ for (int i = 0; i < itemCount; i++) {
+ ToolItem item = items[i];
+ item.setBackgroundPixel (pixel);
+ }
+}
+
+int setBounds (int x, int y, int width, int height, boolean move, boolean resize, boolean events) {
+ int result = super.setBounds (x, y, width, height, move, resize, events);
+ if ((result & RESIZED) != 0) {
+ int [] args = {OS.Pt_ARG_WIDTH, 0, 0, OS.Pt_ARG_HEIGHT, 0, 0};
+ OS.PtGetResources (parentingHandle, args.length / 3, args);
+ OS.PtSetResources (handle, args.length / 3, args);
+ }
+ return result;
+}
+
+void setFont (int font) {
+ super.setFont (font);
+ for (int i = 0; i < itemCount; i++) {
+ ToolItem item = items[i];
+ item.setFont (font);
+ }
+}
+
+void setForegroundPixel (int pixel) {
+ super.setForegroundPixel (pixel);
for (int i = 0; i < itemCount; i++) {
ToolItem item = items[i];
item.setForegroundPixel (pixel);
- }
-}
-
-int topHandle () {
- return parentingHandle;
-}
-
-boolean translateTraversal (int key_sym, PhKeyEvent_t phEvent) {
- boolean result = super.translateTraversal (key_sym, phEvent);
- if (result) return result;
- boolean next = false;
- switch (key_sym) {
- case OS.Pk_Up:
- case OS.Pk_Left: next = false; break;
- case OS.Pk_Down:
- case OS.Pk_Right: next = true; break;
- default: return false;
- }
- int length = itemCount;
- int index = 0;
- while (index < length) {
- if (items [index].hasFocus ()) break;
- index++;
- }
- /*
- * It is possible (but unlikely), that application
- * code could have disposed the widget in focus in
- * or out events. Ensure that a disposed widget is
- * not accessed.
- */
- int start = index, offset = (next) ? 1 : -1;
- while ((index = (index + offset + length) % length) != start) {
- ToolItem item = items [index];
- if (item.setFocus ()) return false;
- }
- return false;
-}
-
-int widgetClass () {
- return OS.PtToolbar ();
-}
-
-}
+ }
+}
+
+int topHandle () {
+ return parentingHandle;
+}
+
+boolean translateTraversal (int key_sym, PhKeyEvent_t phEvent) {
+ boolean result = super.translateTraversal (key_sym, phEvent);
+ if (result) return result;
+ boolean next = false;
+ switch (key_sym) {
+ case OS.Pk_Up:
+ case OS.Pk_Left: next = false; break;
+ case OS.Pk_Down:
+ case OS.Pk_Right: next = true; break;
+ default: return false;
+ }
+ int length = itemCount;
+ int index = 0;
+ while (index < length) {
+ if (items [index].hasFocus ()) break;
+ index++;
+ }
+ /*
+ * It is possible (but unlikely), that application
+ * code could have disposed the widget in focus in
+ * or out events. Ensure that a disposed widget is
+ * not accessed.
+ */
+ int start = index, offset = (next) ? 1 : -1;
+ while ((index = (index + offset + length) % length) != start) {
+ ToolItem item = items [index];
+ if (item.setFocus ()) return false;
+ }
+ return false;
+}
+
+int widgetClass () {
+ return OS.PtToolbar ();
+}
+
+}
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
index f5bbacca2a..0d204e2885 100755
--- 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
@@ -1,18 +1,18 @@
-package org.eclipse.swt.widgets;
-
-/*
+package org.eclipse.swt.widgets;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-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.*;
-
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+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.*;
+
/**
* Instances of this class represent a selectable user interface object
* that represents a button in a tool bar.
@@ -29,14 +29,14 @@ import org.eclipse.swt.events.*;
* IMPORTANT: This class is <em>not</em> intended to be subclassed.
* </p>
*/
-public class ToolItem extends Item {
- ToolBar parent;
- Control control;
- String toolTipText;
- int toolTipHandle;
- Image hotImage, disabledImage;
- int button, arrow;
-
+public class ToolItem extends Item {
+ ToolBar parent;
+ Control control;
+ String toolTipText;
+ int toolTipHandle;
+ Image hotImage, disabledImage;
+ int button, arrow;
+
/**
* Constructs a new instance of this class given its parent
* (which must be a <code>ToolBar</code>) and a style value
@@ -71,10 +71,10 @@ public class ToolItem extends Item {
* @see Widget#checkSubclass
* @see Widget#getStyle
*/
-public ToolItem (ToolBar parent, int style) {
- this(parent, style, parent.getItemCount ());
-}
-
+public ToolItem (ToolBar parent, int style) {
+ this(parent, style, parent.getItemCount ());
+}
+
/**
* Constructs a new instance of this class given its parent
* (which must be a <code>ToolBar</code>), a style value
@@ -110,12 +110,12 @@ public ToolItem (ToolBar parent, int style) {
* @see Widget#checkSubclass
* @see Widget#getStyle
*/
-public ToolItem (ToolBar parent, int style, int index) {
- super (parent, checkStyle (style));
- this.parent = parent;
- parent.createItem (this, index);
-}
-
+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
@@ -141,134 +141,134 @@ public ToolItem (ToolBar parent, int style, int index) {
* @see #removeSelectionListener
* @see SelectionEvent
*/
-public void addSelectionListener(SelectionListener listener) {
- checkWidget();
- if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
- TypedListener typedListener = new TypedListener (listener);
- addListener (SWT.Selection,typedListener);
- addListener (SWT.DefaultSelection,typedListener);
-}
-
-static int checkStyle (int style) {
- return checkBits (style, SWT.PUSH, SWT.CHECK, SWT.RADIO, SWT.SEPARATOR, SWT.DROP_DOWN, 0);
-}
-
-protected void checkSubclass () {
- if (!isValidSubclass ()) error (SWT.ERROR_INVALID_SUBCLASS);
-}
-
-int createArrowImage () {
- short width = 5;
- short height = 4;
- int image = OS.PhCreateImage(null, width, height, OS.Pg_IMAGE_DIRECT_888, 0, 0, 0);
- if (image == 0) SWT.error(SWT.ERROR_NO_HANDLES);
- PhDim_t dim = new PhDim_t();
- dim.w = width;
- dim.h = height;
- int mc = OS.PmMemCreateMC(image, dim, new PhPoint_t());
- if (mc == 0) SWT.error(SWT.ERROR_NO_HANDLES);
- int prevContext = OS.PmMemStart(mc);
- OS.PgSetFillColor(0xFFFFFF);
- OS.PgDrawIRect(0, 0, width, height, OS.Pg_DRAW_FILL);
- OS.PgSetStrokeColor(0x000000);
- OS.PgSetFillColor(0x000000);
- short [] points = {(short)0, (short)1, (short)2, (short)3, (short)4, (short)1};
- OS.PgDrawPolygon(points, points.length / 2, new PhPoint_t(), OS.Pg_DRAW_FILL | OS.Pg_DRAW_STROKE | OS.Pg_CLOSED);
- OS.PmMemFlush(mc, image);
- OS.PmMemStop(mc);
- OS.PmMemReleaseMC(mc);
- OS.PhDCSetCurrent(prevContext);
- OS.PhMakeTransBitmap(image, 0xFFFFFF);
- return image;
-}
-
-void createHandle (int index) {
- state |= HANDLE;
- 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);
- if (handle == 0) error (SWT.ERROR_NO_HANDLES);
- } else if ((style & SWT.DROP_DOWN) != 0) {
- int [] args = {
- OS.Pt_ARG_GROUP_ORIENTATION, OS.Pt_GROUP_HORIZONTAL, 0,
- OS.Pt_ARG_GROUP_FLAGS, OS.Pt_GROUP_EQUAL_SIZE_VERTICAL, OS.Pt_GROUP_EQUAL_SIZE_VERTICAL,
- };
- handle = OS.PtCreateWidget (OS.PtGroup (), parentHandle, args.length / 3, args);
- if (handle == 0) error (SWT.ERROR_NO_HANDLES);
- boolean rightAligned = (parent.style & SWT.RIGHT) != 0;
- args = new int [] {
- OS.Pt_ARG_LABEL_TYPE, 0, 0,
- OS.Pt_ARG_FLAGS, 0, OS.Pt_GETS_FOCUS,
- OS.Pt_ARG_BALLOON_POSITION, rightAligned ? OS.Pt_BALLOON_RIGHT : OS.Pt_BALLOON_BOTTOM, 0,
- OS.Pt_ARG_BASIC_FLAGS, 0, OS.Pt_RIGHT_ETCH | OS.Pt_RIGHT_OUTLINE,
- };
- button = OS.PtCreateWidget (OS.PtButton (), handle, args.length / 3, args);
- if (button == 0) error (SWT.ERROR_NO_HANDLES);
- int arrowImage = createArrowImage ();
- args = new int [] {
- OS.Pt_ARG_FLAGS, 0, OS.Pt_GETS_FOCUS,
- OS.Pt_ARG_LABEL_IMAGE, arrowImage, 0,
- OS.Pt_ARG_LABEL_TYPE, OS.Pt_IMAGE, 0,
- OS.Pt_ARG_MARGIN_WIDTH, 1, 0,
- OS.Pt_ARG_BASIC_FLAGS, 0, OS.Pt_LEFT_ETCH | OS.Pt_LEFT_OUTLINE,
- };
- arrow = OS.PtCreateWidget (OS.PtButton (), handle, args.length / 3, args);
- OS.free (arrowImage);
- if (arrow == 0) error (SWT.ERROR_NO_HANDLES);
- } else {
- boolean rightAligned = (parent.style & SWT.RIGHT) != 0;
- boolean toggle = (style & (SWT.CHECK | SWT.RADIO)) != 0;
- int [] args = {
- OS.Pt_ARG_LABEL_TYPE, 0, 0,
- OS.Pt_ARG_FLAGS, 0, OS.Pt_GETS_FOCUS,
- 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 = button = 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 ());
- }
-}
-
-void createWidget (int index) {
- super.createWidget (index);
- setDefaultFont ();
-}
-
-void deregister () {
- super.deregister ();
- if ((style & SWT.DROP_DOWN) != 0) {
- WidgetTable.remove (button);
- WidgetTable.remove (arrow);
- }
-}
-
+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);
+}
+
+int createArrowImage () {
+ short width = 5;
+ short height = 4;
+ int image = OS.PhCreateImage(null, width, height, OS.Pg_IMAGE_DIRECT_888, 0, 0, 0);
+ if (image == 0) SWT.error(SWT.ERROR_NO_HANDLES);
+ PhDim_t dim = new PhDim_t();
+ dim.w = width;
+ dim.h = height;
+ int mc = OS.PmMemCreateMC(image, dim, new PhPoint_t());
+ if (mc == 0) SWT.error(SWT.ERROR_NO_HANDLES);
+ int prevContext = OS.PmMemStart(mc);
+ OS.PgSetFillColor(0xFFFFFF);
+ OS.PgDrawIRect(0, 0, width, height, OS.Pg_DRAW_FILL);
+ OS.PgSetStrokeColor(0x000000);
+ OS.PgSetFillColor(0x000000);
+ short [] points = {(short)0, (short)1, (short)2, (short)3, (short)4, (short)1};
+ OS.PgDrawPolygon(points, points.length / 2, new PhPoint_t(), OS.Pg_DRAW_FILL | OS.Pg_DRAW_STROKE | OS.Pg_CLOSED);
+ OS.PmMemFlush(mc, image);
+ OS.PmMemStop(mc);
+ OS.PmMemReleaseMC(mc);
+ OS.PhDCSetCurrent(prevContext);
+ OS.PhMakeTransBitmap(image, 0xFFFFFF);
+ return image;
+}
+
+void createHandle (int index) {
+ state |= HANDLE;
+ 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);
+ if (handle == 0) error (SWT.ERROR_NO_HANDLES);
+ } else if ((style & SWT.DROP_DOWN) != 0) {
+ int [] args = {
+ OS.Pt_ARG_GROUP_ORIENTATION, OS.Pt_GROUP_HORIZONTAL, 0,
+ OS.Pt_ARG_GROUP_FLAGS, OS.Pt_GROUP_EQUAL_SIZE_VERTICAL, OS.Pt_GROUP_EQUAL_SIZE_VERTICAL,
+ };
+ handle = OS.PtCreateWidget (OS.PtGroup (), parentHandle, args.length / 3, args);
+ if (handle == 0) error (SWT.ERROR_NO_HANDLES);
+ boolean rightAligned = (parent.style & SWT.RIGHT) != 0;
+ args = new int [] {
+ OS.Pt_ARG_LABEL_TYPE, 0, 0,
+ OS.Pt_ARG_FLAGS, 0, OS.Pt_GETS_FOCUS,
+ OS.Pt_ARG_BALLOON_POSITION, rightAligned ? OS.Pt_BALLOON_RIGHT : OS.Pt_BALLOON_BOTTOM, 0,
+ OS.Pt_ARG_BASIC_FLAGS, 0, OS.Pt_RIGHT_ETCH | OS.Pt_RIGHT_OUTLINE,
+ };
+ button = OS.PtCreateWidget (OS.PtButton (), handle, args.length / 3, args);
+ if (button == 0) error (SWT.ERROR_NO_HANDLES);
+ int arrowImage = createArrowImage ();
+ args = new int [] {
+ OS.Pt_ARG_FLAGS, 0, OS.Pt_GETS_FOCUS,
+ OS.Pt_ARG_LABEL_IMAGE, arrowImage, 0,
+ OS.Pt_ARG_LABEL_TYPE, OS.Pt_IMAGE, 0,
+ OS.Pt_ARG_MARGIN_WIDTH, 1, 0,
+ OS.Pt_ARG_BASIC_FLAGS, 0, OS.Pt_LEFT_ETCH | OS.Pt_LEFT_OUTLINE,
+ };
+ arrow = OS.PtCreateWidget (OS.PtButton (), handle, args.length / 3, args);
+ OS.free (arrowImage);
+ if (arrow == 0) error (SWT.ERROR_NO_HANDLES);
+ } else {
+ boolean rightAligned = (parent.style & SWT.RIGHT) != 0;
+ boolean toggle = (style & (SWT.CHECK | SWT.RADIO)) != 0;
+ int [] args = {
+ OS.Pt_ARG_LABEL_TYPE, 0, 0,
+ OS.Pt_ARG_FLAGS, 0, OS.Pt_GETS_FOCUS,
+ 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 = button = 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 ());
+ }
+}
+
+void createWidget (int index) {
+ super.createWidget (index);
+ setDefaultFont ();
+}
+
+void deregister () {
+ super.deregister ();
+ if ((style & SWT.DROP_DOWN) != 0) {
+ WidgetTable.remove (button);
+ WidgetTable.remove (arrow);
+ }
+}
+
/**
* Returns a rectangle describing the receiver's size and location
* relative to its parent.
@@ -280,14 +280,14 @@ void deregister () {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public Rectangle getBounds () {
- checkWidget();
- 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 Rectangle getBounds () {
+ checkWidget();
+ 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);
+}
+
/**
* Returns the control that is used to fill the bounds of
* the item when the items is a <code>SEPARATOR</code>.
@@ -299,11 +299,11 @@ public Rectangle getBounds () {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public Control getControl () {
- checkWidget();
- return control;
-}
-
+public Control getControl () {
+ checkWidget();
+ return control;
+}
+
/**
* Returns the receiver's disabled image if it has one, or null
* if it does not.
@@ -318,17 +318,17 @@ public Control getControl () {
* <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 ();
-}
-
+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.
@@ -344,12 +344,12 @@ public Display getDisplay () {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public boolean getEnabled () {
- checkWidget ();
- int topHandle = topHandle ();
- return (OS.PtWidgetFlags (topHandle) & OS.Pt_BLOCKED) == 0;
-}
-
+public boolean getEnabled () {
+ checkWidget ();
+ int topHandle = topHandle ();
+ return (OS.PtWidgetFlags (topHandle) & OS.Pt_BLOCKED) == 0;
+}
+
/**
* Returns the receiver's hot image if it has one, or null
* if it does not.
@@ -364,11 +364,11 @@ public boolean getEnabled () {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public Image getHotImage () {
- checkWidget();
- return hotImage;
-}
-
+public Image getHotImage () {
+ checkWidget();
+ return hotImage;
+}
+
/**
* Returns the receiver's parent, which must be a <code>ToolBar</code>.
*
@@ -379,11 +379,11 @@ public Image getHotImage () {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public ToolBar getParent () {
- checkWidget();
- return parent;
-}
-
+public ToolBar getParent () {
+ checkWidget();
+ return parent;
+}
+
/**
* Returns <code>true</code> if the receiver is selected,
* and false otherwise.
@@ -401,12 +401,12 @@ public ToolBar getParent () {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public boolean getSelection () {
- checkWidget();
- if ((style & (SWT.CHECK | SWT.RADIO | SWT.TOGGLE)) == 0) return false;
- return (OS.PtWidgetFlags (handle) & OS.Pt_SET) != 0;
-}
-
+public boolean getSelection () {
+ checkWidget();
+ if ((style & (SWT.CHECK | SWT.RADIO | SWT.TOGGLE)) == 0) return false;
+ return (OS.PtWidgetFlags (handle) & OS.Pt_SET) != 0;
+}
+
/**
* Returns the receiver's tool tip text, or null if it has not been set.
*
@@ -417,11 +417,11 @@ public boolean getSelection () {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public String getToolTipText () {
- checkWidget();
- return toolTipText;
-}
-
+public String getToolTipText () {
+ checkWidget();
+ return toolTipText;
+}
+
/**
* Gets the width of the receiver.
*
@@ -432,130 +432,130 @@ public String getToolTipText () {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public int getWidth () {
- checkWidget();
- int topHandle = topHandle ();
- int [] args = {OS.Pt_ARG_WIDTH, 0, 0};
- OS.PtGetResources (topHandle, args.length / 3, args);
- return args [1];
-}
-
-boolean hasFocus () {
- return OS.PtIsFocused (handle) != 0;
-}
-
-void hookEvents () {
- super.hookEvents ();
- if ((style & SWT.SEPARATOR) != 0) return;
- int windowProc = getDisplay ().windowProc;
- OS.PtAddEventHandler (handle, OS.Ph_EV_BOUNDARY, windowProc, OS.Ph_EV_BOUNDARY);
- OS.PtAddCallback (button, OS.Pt_CB_ACTIVATE, windowProc, OS.Pt_CB_ACTIVATE);
- if ((style & SWT.DROP_DOWN) != 0) {
- OS.PtAddCallback (arrow, OS.Pt_CB_ACTIVATE, windowProc, OS.Pt_CB_ACTIVATE);
- }
- OS.PtAddCallback (handle, OS.Pt_CB_LOST_FOCUS, windowProc, OS.Pt_CB_LOST_FOCUS);
-}
-
-/**
- * Returns <code>true</code> if the receiver is enabled and all
- * of the receiver's ancestors are enabled, and <code>false</code>
- * otherwise. A disabled control is typically not selectable from the
- * user interface and draws with an inactive or "grayed" look.
- *
- * @return the receiver's enabled state
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see #getEnabled
+public int getWidth () {
+ checkWidget();
+ int topHandle = topHandle ();
+ int [] args = {OS.Pt_ARG_WIDTH, 0, 0};
+ OS.PtGetResources (topHandle, args.length / 3, args);
+ return args [1];
+}
+
+boolean hasFocus () {
+ return OS.PtIsFocused (handle) != 0;
+}
+
+void hookEvents () {
+ super.hookEvents ();
+ if ((style & SWT.SEPARATOR) != 0) return;
+ int windowProc = getDisplay ().windowProc;
+ OS.PtAddEventHandler (handle, OS.Ph_EV_BOUNDARY, windowProc, OS.Ph_EV_BOUNDARY);
+ OS.PtAddCallback (button, OS.Pt_CB_ACTIVATE, windowProc, OS.Pt_CB_ACTIVATE);
+ if ((style & SWT.DROP_DOWN) != 0) {
+ OS.PtAddCallback (arrow, OS.Pt_CB_ACTIVATE, windowProc, OS.Pt_CB_ACTIVATE);
+ }
+ OS.PtAddCallback (handle, OS.Pt_CB_LOST_FOCUS, windowProc, OS.Pt_CB_LOST_FOCUS);
+}
+
+/**
+ * Returns <code>true</code> if the receiver is enabled and all
+ * of the receiver's ancestors are enabled, and <code>false</code>
+ * otherwise. A disabled control is typically not selectable from the
+ * user interface and draws with an inactive or "grayed" look.
+ *
+ * @return the receiver's enabled state
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see #getEnabled
*/
-public boolean isEnabled () {
- checkWidget();
- return getEnabled () && parent.isEnabled ();
-}
-
-int Ph_EV_BOUNDARY (int widget, 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);
- switch ((int) ev.subtype) {
- case OS.Ph_EV_PTR_STEADY:
- int [] args = {OS.Pt_ARG_TEXT_FONT, 0, 0};
- OS.PtGetResources (button, args.length / 3, args);
- int length = OS.strlen (args [1]);
- byte [] font = new byte [length + 1];
- OS.memmove (font, args [1], length);
- destroyToolTip (toolTipHandle);
- toolTipHandle = createToolTip (toolTipText, button, font);
- break;
- case OS.Ph_EV_PTR_UNSTEADY:
- destroyToolTip (toolTipHandle);
- toolTipHandle = 0;
- break;
- }
- return OS.Pt_END;
-}
-
-int Pt_CB_ACTIVATE (int widget, int info) {
- Event event = new Event ();
- if (widget == arrow) {
- event.detail = SWT.ARROW;
- int topHandle = topHandle ();
- PhArea_t area = new PhArea_t ();
- OS.PtWidgetArea (topHandle, area);
- event.x = area.pos_x;
- event.y = area.pos_y + area.size_h;
- } else {
- if ((style & SWT.RADIO) != 0) {
- if ((parent.getStyle () & SWT.NO_RADIO_GROUP) == 0) {
- selectRadio ();
- }
- }
- }
- postEvent (SWT.Selection, event);
- return OS.Pt_CONTINUE;
-}
-
-int Pt_CB_LOST_FOCUS (int widget, int info) {
- parent.lastFocus = this;
- return OS.Pt_CONTINUE;
-}
-
-void register () {
- super.register ();
- if ((style & SWT.DROP_DOWN) != 0) {
- WidgetTable.put (button, this);
- WidgetTable.put (arrow, this);
- }
-}
-
-void releaseChild () {
- super.releaseChild ();
- parent.destroyItem (this);
-}
-
-void releaseHandle () {
- super.releaseHandle ();
- arrow = button = 0;
-}
-
-void releaseWidget () {
- super.releaseWidget ();
- if (toolTipHandle != 0) destroyToolTip (toolTipHandle);
- if (parent.lastFocus == this) parent.lastFocus = null;
- toolTipHandle = 0;
- parent = null;
- control = null;
- hotImage = null;
- disabledImage = null;
- toolTipText = null;
-}
-
+public boolean isEnabled () {
+ checkWidget();
+ return getEnabled () && parent.isEnabled ();
+}
+
+int Ph_EV_BOUNDARY (int widget, 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);
+ switch ((int) ev.subtype) {
+ case OS.Ph_EV_PTR_STEADY:
+ int [] args = {OS.Pt_ARG_TEXT_FONT, 0, 0};
+ OS.PtGetResources (button, args.length / 3, args);
+ int length = OS.strlen (args [1]);
+ byte [] font = new byte [length + 1];
+ OS.memmove (font, args [1], length);
+ destroyToolTip (toolTipHandle);
+ toolTipHandle = createToolTip (toolTipText, button, font);
+ break;
+ case OS.Ph_EV_PTR_UNSTEADY:
+ destroyToolTip (toolTipHandle);
+ toolTipHandle = 0;
+ break;
+ }
+ return OS.Pt_END;
+}
+
+int Pt_CB_ACTIVATE (int widget, int info) {
+ Event event = new Event ();
+ if (widget == arrow) {
+ event.detail = SWT.ARROW;
+ int topHandle = topHandle ();
+ PhArea_t area = new PhArea_t ();
+ OS.PtWidgetArea (topHandle, area);
+ event.x = area.pos_x;
+ event.y = area.pos_y + area.size_h;
+ } else {
+ if ((style & SWT.RADIO) != 0) {
+ if ((parent.getStyle () & SWT.NO_RADIO_GROUP) == 0) {
+ selectRadio ();
+ }
+ }
+ }
+ postEvent (SWT.Selection, event);
+ return OS.Pt_CONTINUE;
+}
+
+int Pt_CB_LOST_FOCUS (int widget, int info) {
+ parent.lastFocus = this;
+ return OS.Pt_CONTINUE;
+}
+
+void register () {
+ super.register ();
+ if ((style & SWT.DROP_DOWN) != 0) {
+ WidgetTable.put (button, this);
+ WidgetTable.put (arrow, this);
+ }
+}
+
+void releaseChild () {
+ super.releaseChild ();
+ parent.destroyItem (this);
+}
+
+void releaseHandle () {
+ super.releaseHandle ();
+ arrow = button = 0;
+}
+
+void releaseWidget () {
+ super.releaseWidget ();
+ if (toolTipHandle != 0) destroyToolTip (toolTipHandle);
+ if (parent.lastFocus == this) parent.lastFocus = null;
+ toolTipHandle = 0;
+ parent = null;
+ control = null;
+ hotImage = null;
+ disabledImage = null;
+ toolTipText = null;
+}
+
/**
* Removes the listener from the collection of listeners who will
* be notified when the control is selected.
@@ -573,33 +573,33 @@ void releaseWidget () {
* @see SelectionListener
* @see #addSelectionListener
*/
-public void removeSelectionListener(SelectionListener listener) {
- checkWidget();
- if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
- if (eventTable == null) return;
- eventTable.unhook (SWT.Selection, listener);
- eventTable.unhook (SWT.DefaultSelection,listener);
-}
-
-void selectRadio () {
- int index = 0;
- ToolItem [] items = parent.getItems ();
- while (index < items.length && items [index] != this) index++;
- int i = index - 1;
- while (i >= 0 && items [i].setRadioSelection (false)) --i;
- int j = index + 1;
- while (j < items.length && items [j].setRadioSelection (false)) j++;
- setSelection (true);
-}
-
-void setBackgroundPixel (int pixel) {
- OS.PtSetResource (handle, OS.Pt_ARG_FILL_COLOR, pixel, 0);
- if ((style & SWT.DROP_DOWN) != 0) {
- OS.PtSetResource (button, OS.Pt_ARG_FILL_COLOR, pixel, 0);
- OS.PtSetResource (arrow, OS.Pt_ARG_FILL_COLOR, pixel, 0);
- }
-}
-
+public void removeSelectionListener(SelectionListener listener) {
+ checkWidget();
+ if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+ if (eventTable == null) return;
+ eventTable.unhook (SWT.Selection, listener);
+ eventTable.unhook (SWT.DefaultSelection,listener);
+}
+
+void selectRadio () {
+ int index = 0;
+ ToolItem [] items = parent.getItems ();
+ while (index < items.length && items [index] != this) index++;
+ int i = index - 1;
+ while (i >= 0 && items [i].setRadioSelection (false)) --i;
+ int j = index + 1;
+ while (j < items.length && items [j].setRadioSelection (false)) j++;
+ setSelection (true);
+}
+
+void setBackgroundPixel (int pixel) {
+ OS.PtSetResource (handle, OS.Pt_ARG_FILL_COLOR, pixel, 0);
+ if ((style & SWT.DROP_DOWN) != 0) {
+ OS.PtSetResource (button, OS.Pt_ARG_FILL_COLOR, pixel, 0);
+ OS.PtSetResource (arrow, OS.Pt_ARG_FILL_COLOR, pixel, 0);
+ }
+}
+
/**
* Sets the control that is used to fill the bounds of
* the item when the items is a <code>SEPARATOR</code>.
@@ -615,29 +615,29 @@ void setBackgroundPixel (int pixel) {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public void setControl (Control control) {
- checkWidget();
- if (control != null) {
- if (control.isDisposed()) error (SWT.ERROR_INVALID_ARGUMENT);
- if (control.parent != parent) error (SWT.ERROR_INVALID_PARENT);
- }
- if ((style & SWT.SEPARATOR) == 0) return;
- Control oldControl = this.control;
- this.control = control;
- if (oldControl != null) {
- OS.PtReParentWidget(oldControl.handle, parent.parentingHandle ());
- }
- if (control != null && !control.isDisposed ()) {
- OS.PtReParentWidget(control.handle, handle);
- control.setBounds (getBounds ());
- }
-}
-
-void setDefaultFont () {
- Display display = getDisplay ();
- if (display.defaultFont != null) setFont (parent.defaultFont ());
-}
-
+public void setControl (Control control) {
+ checkWidget();
+ if (control != null) {
+ if (control.isDisposed()) error (SWT.ERROR_INVALID_ARGUMENT);
+ if (control.parent != parent) error (SWT.ERROR_INVALID_PARENT);
+ }
+ if ((style & SWT.SEPARATOR) == 0) return;
+ Control oldControl = this.control;
+ this.control = control;
+ if (oldControl != null) {
+ OS.PtReParentWidget(oldControl.handle, parent.parentingHandle ());
+ }
+ if (control != null && !control.isDisposed ()) {
+ OS.PtReParentWidget(control.handle, handle);
+ control.setBounds (getBounds ());
+ }
+}
+
+void setDefaultFont () {
+ Display display = getDisplay ();
+ if (display.defaultFont != null) setFont (parent.defaultFont ());
+}
+
/**
* Sets the receiver's disabled image to the argument, which may be
* null indicating that no disabled image should be displayed.
@@ -655,13 +655,13 @@ void setDefaultFont () {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public void setDisabledImage (Image image) {
- checkWidget();
- if (image != null && image.isDisposed()) error(SWT.ERROR_INVALID_ARGUMENT);
- if ((style & SWT.SEPARATOR) != 0) return;
- disabledImage = image;
-}
-
+public void setDisabledImage (Image image) {
+ checkWidget();
+ if (image != null && image.isDisposed()) error(SWT.ERROR_INVALID_ARGUMENT);
+ if ((style & SWT.SEPARATOR) != 0) return;
+ disabledImage = image;
+}
+
/**
* Enables the receiver if the argument is <code>true</code>,
* and disables it otherwise.
@@ -678,62 +678,62 @@ public void setDisabledImage (Image image) {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public void setEnabled (boolean enabled) {
- checkWidget ();
- int topHandle = topHandle ();
- int flags = enabled ? 0 : OS.Pt_BLOCKED | OS.Pt_GHOST;
- OS.PtSetResource (topHandle, OS.Pt_ARG_FLAGS, flags, OS.Pt_BLOCKED | OS.Pt_GHOST);
- if ((style & SWT.DROP_DOWN) != 0) {
- OS.PtSetResource (button, OS.Pt_ARG_FLAGS, flags, OS.Pt_BLOCKED | OS.Pt_GHOST);
- OS.PtSetResource (arrow, OS.Pt_ARG_FLAGS, flags, OS.Pt_BLOCKED | OS.Pt_GHOST);
- }
-}
-
-boolean setFocus () {
- if ((style & SWT.SEPARATOR) != 0) return false;
- int focusHandle = (style & SWT.DROP_DOWN) != 0 ? button : handle;
- /*
- * Bug in Photon. Photon will stop sending key
- * events, if a menu is up and focus is given to
- * a widget by calling PtContainerGiveFocus(). The
- * fix is to detect when a menu is up and avoid
- * calling this function.
- */
- Shell shell = parent.getShell ();
- if (shell.activeMenu != null) return false;
- OS.PtContainerGiveFocus (focusHandle, null);
- return OS.PtIsFocused(focusHandle) != 0;
-}
-
-void setFont (byte [] font) {
- int ptr = OS.malloc (font.length);
- OS.memmove (ptr, font, font.length);
- setFont (ptr);
- OS.free (ptr);
-}
-
-void setFont (int font) {
- int [] args = {
- OS.Pt_ARG_TEXT_FONT, font, 0,
- OS.Pt_ARG_LIST_FONT, font, 0,
- OS.Pt_ARG_TITLE_FONT, font, 0,
- OS.Pt_ARG_GAUGE_FONT, font, 0,
- };
- OS.PtSetResources (handle, args.length / 3, args);
- if ((style & SWT.DROP_DOWN) != 0) {
- OS.PtSetResources (button, args.length / 3, args);
- OS.PtSetResources (arrow, args.length / 3, args);
- }
-}
-
-void setForegroundPixel (int pixel) {
- OS.PtSetResource (handle, OS.Pt_ARG_COLOR, pixel, 0);
- if ((style & SWT.DROP_DOWN) != 0) {
- OS.PtSetResource (button, OS.Pt_ARG_COLOR, pixel, 0);
- OS.PtSetResource (arrow, OS.Pt_ARG_COLOR, pixel, 0);
- }
-}
-
+public void setEnabled (boolean enabled) {
+ checkWidget ();
+ int topHandle = topHandle ();
+ int flags = enabled ? 0 : OS.Pt_BLOCKED | OS.Pt_GHOST;
+ OS.PtSetResource (topHandle, OS.Pt_ARG_FLAGS, flags, OS.Pt_BLOCKED | OS.Pt_GHOST);
+ if ((style & SWT.DROP_DOWN) != 0) {
+ OS.PtSetResource (button, OS.Pt_ARG_FLAGS, flags, OS.Pt_BLOCKED | OS.Pt_GHOST);
+ OS.PtSetResource (arrow, OS.Pt_ARG_FLAGS, flags, OS.Pt_BLOCKED | OS.Pt_GHOST);
+ }
+}
+
+boolean setFocus () {
+ if ((style & SWT.SEPARATOR) != 0) return false;
+ int focusHandle = (style & SWT.DROP_DOWN) != 0 ? button : handle;
+ /*
+ * Bug in Photon. Photon will stop sending key
+ * events, if a menu is up and focus is given to
+ * a widget by calling PtContainerGiveFocus(). The
+ * fix is to detect when a menu is up and avoid
+ * calling this function.
+ */
+ Shell shell = parent.getShell ();
+ if (shell.activeMenu != null) return false;
+ OS.PtContainerGiveFocus (focusHandle, null);
+ return OS.PtIsFocused(focusHandle) != 0;
+}
+
+void setFont (byte [] font) {
+ int ptr = OS.malloc (font.length);
+ OS.memmove (ptr, font, font.length);
+ setFont (ptr);
+ OS.free (ptr);
+}
+
+void setFont (int font) {
+ int [] args = {
+ OS.Pt_ARG_TEXT_FONT, font, 0,
+ OS.Pt_ARG_LIST_FONT, font, 0,
+ OS.Pt_ARG_TITLE_FONT, font, 0,
+ OS.Pt_ARG_GAUGE_FONT, font, 0,
+ };
+ OS.PtSetResources (handle, args.length / 3, args);
+ if ((style & SWT.DROP_DOWN) != 0) {
+ OS.PtSetResources (button, args.length / 3, args);
+ OS.PtSetResources (arrow, args.length / 3, args);
+ }
+}
+
+void setForegroundPixel (int pixel) {
+ OS.PtSetResource (handle, OS.Pt_ARG_COLOR, pixel, 0);
+ if ((style & SWT.DROP_DOWN) != 0) {
+ OS.PtSetResource (button, OS.Pt_ARG_COLOR, pixel, 0);
+ OS.PtSetResource (arrow, OS.Pt_ARG_COLOR, pixel, 0);
+ }
+}
+
/**
* Sets the receiver's hot image to the argument, which may be
* null indicating that no hot image should be displayed.
@@ -751,62 +751,62 @@ void setForegroundPixel (int pixel) {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public void setHotImage (Image image) {
- checkWidget();
- if (image != null && image.isDisposed()) error(SWT.ERROR_INVALID_ARGUMENT);
- if ((style & SWT.SEPARATOR) != 0) return;
-
- /* TEMPORARY CODE: remove when when FLAT tool bars are implemented */
- if ((parent.style & SWT.FLAT) != 0) setImage (image);
-
- hotImage = image;
-}
-
-public void setImage (Image image) {
- checkWidget();
- if (image != null && image.isDisposed()) error(SWT.ERROR_INVALID_ARGUMENT);
- if ((style & SWT.SEPARATOR) != 0) return;
- super.setImage (image);
-
- /* TEMPORARY CODE: remove when when FLAT tool bars are implemented */
- if ((parent.style & SWT.FLAT) != 0 && hotImage != null) return;
-
- int imageHandle = 0;
- int type = OS.Pt_Z_STRING;
- if (image != null) {
- imageHandle = copyPhImage (image.handle);
- if(text.length() != 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 (button, args.length / 3, args);
- if (imageHandle != 0) OS.free (imageHandle);
-
- /*
- * Bug on Photon. When a the text/image is set on a
- * DROP_DOWN item that is realized, the item does not resize
- * to show the new text/image. The fix is to force the item
- * to recalculate the size.
- */
- if ((style & SWT.DROP_DOWN) != 0) {
- if (OS.PtWidgetIsRealized (handle)) {
- OS.PtExtentWidget (handle);
- }
- }
-}
-
-boolean setRadioSelection (boolean value) {
- if ((style & SWT.RADIO) == 0) return false;
- if (getSelection () != value) {
- setSelection (value);
- postEvent (SWT.Selection);
- }
- return true;
-}
-
+public void setHotImage (Image image) {
+ checkWidget();
+ if (image != null && image.isDisposed()) error(SWT.ERROR_INVALID_ARGUMENT);
+ if ((style & SWT.SEPARATOR) != 0) return;
+
+ /* TEMPORARY CODE: remove when when FLAT tool bars are implemented */
+ if ((parent.style & SWT.FLAT) != 0) setImage (image);
+
+ hotImage = image;
+}
+
+public void setImage (Image image) {
+ checkWidget();
+ if (image != null && image.isDisposed()) error(SWT.ERROR_INVALID_ARGUMENT);
+ if ((style & SWT.SEPARATOR) != 0) return;
+ super.setImage (image);
+
+ /* TEMPORARY CODE: remove when when FLAT tool bars are implemented */
+ if ((parent.style & SWT.FLAT) != 0 && hotImage != null) return;
+
+ int imageHandle = 0;
+ int type = OS.Pt_Z_STRING;
+ if (image != null) {
+ imageHandle = copyPhImage (image.handle);
+ if(text.length() != 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 (button, args.length / 3, args);
+ if (imageHandle != 0) OS.free (imageHandle);
+
+ /*
+ * Bug on Photon. When a the text/image is set on a
+ * DROP_DOWN item that is realized, the item does not resize
+ * to show the new text/image. The fix is to force the item
+ * to recalculate the size.
+ */
+ if ((style & SWT.DROP_DOWN) != 0) {
+ if (OS.PtWidgetIsRealized (handle)) {
+ OS.PtExtentWidget (handle);
+ }
+ }
+}
+
+boolean setRadioSelection (boolean value) {
+ if ((style & SWT.RADIO) == 0) return false;
+ if (getSelection () != value) {
+ setSelection (value);
+ postEvent (SWT.Selection);
+ }
+ return true;
+}
+
/**
* Sets the selection state of the receiver.
* <p>
@@ -822,42 +822,42 @@ boolean setRadioSelection (boolean value) {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public void setSelection (boolean selected) {
- checkWidget();
- if ((style & (SWT.CHECK | SWT.RADIO | SWT.TOGGLE)) == 0) return;
- OS.PtSetResource (handle, OS.Pt_ARG_FLAGS, selected ? OS.Pt_SET : 0, OS.Pt_SET);
-}
-
-public void setText (String string) {
- checkWidget();
- if (string == null) error (SWT.ERROR_NULL_ARGUMENT);
- if ((style & SWT.SEPARATOR) != 0) return;
- super.setText (string);
- byte [] buffer = Converter.wcsToMbcs (null, string, true);
- int ptr = OS.malloc (buffer.length);
- OS.memmove (ptr, buffer, buffer.length);
- int type = OS.Pt_Z_STRING;
- if (image != null) type = OS.Pt_TEXT_IMAGE;
- int [] args = {
- OS.Pt_ARG_TEXT_STRING, ptr, 0,
- OS.Pt_ARG_LABEL_TYPE, type, 0,
- };
- OS.PtSetResources (button, args.length / 3, args);
- if (ptr != 0) OS.free (ptr);
-
- /*
- * Bug on Photon. When a the text/image is set on a
- * DROP_DOWN item that is realized, the item does not resize
- * to show the new text/image. The fix is to force the item
- * to recalculate the size.
- */
- if ((style & SWT.DROP_DOWN) != 0) {
- if (OS.PtWidgetIsRealized (handle)) {
- OS.PtExtentWidget (handle);
- }
- }
-}
-
+public void setSelection (boolean selected) {
+ checkWidget();
+ if ((style & (SWT.CHECK | SWT.RADIO | SWT.TOGGLE)) == 0) return;
+ OS.PtSetResource (handle, OS.Pt_ARG_FLAGS, selected ? OS.Pt_SET : 0, OS.Pt_SET);
+}
+
+public void setText (String string) {
+ checkWidget();
+ if (string == null) error (SWT.ERROR_NULL_ARGUMENT);
+ if ((style & SWT.SEPARATOR) != 0) return;
+ super.setText (string);
+ byte [] buffer = Converter.wcsToMbcs (null, string, true);
+ int ptr = OS.malloc (buffer.length);
+ OS.memmove (ptr, buffer, buffer.length);
+ int type = OS.Pt_Z_STRING;
+ if (image != null) type = OS.Pt_TEXT_IMAGE;
+ int [] args = {
+ OS.Pt_ARG_TEXT_STRING, ptr, 0,
+ OS.Pt_ARG_LABEL_TYPE, type, 0,
+ };
+ OS.PtSetResources (button, args.length / 3, args);
+ if (ptr != 0) OS.free (ptr);
+
+ /*
+ * Bug on Photon. When a the text/image is set on a
+ * DROP_DOWN item that is realized, the item does not resize
+ * to show the new text/image. The fix is to force the item
+ * to recalculate the size.
+ */
+ if ((style & SWT.DROP_DOWN) != 0) {
+ if (OS.PtWidgetIsRealized (handle)) {
+ OS.PtExtentWidget (handle);
+ }
+ }
+}
+
/**
* Sets the receiver's tool tip text to the argument, which
* may be null indicating that no tool tip text should be shown.
@@ -869,11 +869,11 @@ public void setText (String string) {
* <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;
-}
-
+public void setToolTipText (String string) {
+ checkWidget();
+ toolTipText = string;
+}
+
/**
* Sets the width of the receiver.
*
@@ -884,14 +884,14 @@ public void setToolTipText (String string) {
* <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 topHandle = topHandle ();
- OS.PtSetResource (topHandle, OS.Pt_ARG_WIDTH, width, 0);
- if (control != null && !control.isDisposed ()) {
- control.setBounds (getBounds ());
- }
-}
-}
+public void setWidth (int width) {
+ checkWidget();
+ if ((style & SWT.SEPARATOR) == 0) return;
+ if (width < 0) return;
+ int topHandle = topHandle ();
+ OS.PtSetResource (topHandle, OS.Pt_ARG_WIDTH, width, 0);
+ if (control != null && !control.isDisposed ()) {
+ control.setBounds (getBounds ());
+ }
+}
+}
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
index c9d24acbf3..5778890e61 100755
--- 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
@@ -1,50 +1,50 @@
-package org.eclipse.swt.widgets;
-
-/*
+package org.eclipse.swt.widgets;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-import org.eclipse.swt.internal.photon.*;
-import org.eclipse.swt.graphics.*;
-import org.eclipse.swt.*;
-import org.eclipse.swt.events.*;
-
-/**
- * Instances of this class implement rubber banding rectangles that are
- * drawn onto a parent <code>Composite</code> or <code>Display</code>.
- * These rectangles can be specified to respond to mouse and key events
- * by either moving or resizing themselves accordingly. Trackers are
- * typically used to represent window geometries in a lightweight manner.
- *
- * <dl>
- * <dt><b>Styles:</b></dt>
- * <dd>LEFT, RIGHT, UP, DOWN, RESIZE</dd>
- * <dt><b>Events:</b></dt>
- * <dd>Move, Resize</dd>
- * </dl>
- * <p>
- * Note: Rectangle move behavior is assumed unless RESIZE is specified.
- * </p><p>
- * IMPORTANT: This class is <em>not</em> intended to be subclassed.
- * </p>
- */
-public class Tracker extends Widget {
- Composite parent;
- Display display;
- boolean tracking, stippled;
- Rectangle [] rectangles, proportions;
- int resizeCursor, clientCursor, clientBitmap;
- int cursorOrientation = SWT.NONE;
-
- /*
- * The following values mirror step sizes on Windows
- */
- final static int STEPSIZE_SMALL = 1;
- final static int STEPSIZE_LARGE = 9;
-
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+import org.eclipse.swt.internal.photon.*;
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.*;
+import org.eclipse.swt.events.*;
+
+/**
+ * Instances of this class implement rubber banding rectangles that are
+ * drawn onto a parent <code>Composite</code> or <code>Display</code>.
+ * These rectangles can be specified to respond to mouse and key events
+ * by either moving or resizing themselves accordingly. Trackers are
+ * typically used to represent window geometries in a lightweight manner.
+ *
+ * <dl>
+ * <dt><b>Styles:</b></dt>
+ * <dd>LEFT, RIGHT, UP, DOWN, RESIZE</dd>
+ * <dt><b>Events:</b></dt>
+ * <dd>Move, Resize</dd>
+ * </dl>
+ * <p>
+ * Note: Rectangle move behavior is assumed unless RESIZE is specified.
+ * </p><p>
+ * IMPORTANT: This class is <em>not</em> intended to be subclassed.
+ * </p>
+ */
+public class Tracker extends Widget {
+ Composite parent;
+ Display display;
+ boolean tracking, stippled;
+ Rectangle [] rectangles, proportions;
+ int resizeCursor, clientCursor, clientBitmap;
+ int cursorOrientation = SWT.NONE;
+
+ /*
+ * The following values mirror step sizes on Windows
+ */
+ final static int STEPSIZE_SMALL = 1;
+ final static int STEPSIZE_LARGE = 9;
+
/**
* Constructs a new instance of this class given the display
* to create it on and a style value describing its behavior
@@ -79,16 +79,16 @@ public class Tracker extends Widget {
* @see SWT#UP
* @see SWT#DOWN
*/
-public Tracker (Display display, int style) {
- if (display == null) display = Display.getCurrent ();
- if (display == null) display = Display.getDefault ();
- if (!display.isValidThread ()) {
- error (SWT.ERROR_THREAD_INVALID_ACCESS);
- }
- this.style = checkStyle (style);
- this.display = display;
-}
-
+public Tracker (Display display, int style) {
+ if (display == null) display = Display.getCurrent ();
+ if (display == null) display = Display.getDefault ();
+ if (!display.isValidThread ()) {
+ error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ }
+ this.style = checkStyle (style);
+ this.display = display;
+}
+
/**
* Constructs a new instance of this class given its parent
* and a style value describing its behavior and appearance.
@@ -121,12 +121,12 @@ public Tracker (Display display, int style) {
* @see Widget#checkSubclass
* @see Widget#getStyle
*/
-public Tracker (Composite parent, int style) {
- super (parent, checkStyle (style));
- this.parent = parent;
- display = parent.getDisplay ();
-}
-
+public Tracker (Composite parent, int style) {
+ super (parent, checkStyle (style));
+ this.parent = parent;
+ display = parent.getDisplay ();
+}
+
/**
* Adds the listener to the collection of listeners who will
* be notified when the control is moved or resized, by sending
@@ -146,212 +146,212 @@ public Tracker (Composite parent, int style) {
* @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);
-}
-
-Point adjustMoveCursor () {
- Rectangle bounds = computeBounds ();
- int newX = bounds.x + bounds.width / 2;
- int newY = bounds.y;
- /*
- * Convert to screen coordinates iff needed
- */
- if (parent != null) {
- short [] x = new short [1], y = new short [1];
- OS.PtGetAbsPosition (parent.handle, x, y);
- newX += x [0];
- newY += y [0];
- }
- OS.PhMoveCursorAbs(OS.PhInputGroup (0), newX, newY);
- return new Point (newX, newY);
-}
-
-Point adjustResizeCursor () {
- int newX, newY;
- Rectangle bounds = computeBounds ();
-
- if ((cursorOrientation & SWT.LEFT) != 0) {
- newX = bounds.x;
- } else if ((cursorOrientation & SWT.RIGHT) != 0) {
- newX = bounds.x + bounds.width;
- } else {
- newX = bounds.x + bounds.width / 2;
- }
-
- if ((cursorOrientation & SWT.UP) != 0) {
- newY = bounds.y;
- } else if ((cursorOrientation & SWT.DOWN) != 0) {
- newY = bounds.y + bounds.height;
- } else {
- newY = bounds.y + bounds.height / 2;
- }
-
- /*
- * Convert to screen coordinates iff needed
- */
- if (parent != null) {
- short [] x = new short [1], y = new short [1];
- OS.PtGetAbsPosition (parent.handle, x, y);
- newX += x [0];
- newY += y [0];
- }
- OS.PhMoveCursorAbs(OS.PhInputGroup (0), newX, newY);
-
- /*
- * If the client has not provided a custom cursor then determine
- * the appropriate resize cursor.
- */
- if (clientCursor == 0) {
- int newCursor = 0;
- switch (cursorOrientation) {
- case SWT.UP:
- newCursor = OS.Ph_CURSOR_DRAG_TOP;
- break;
- case SWT.DOWN:
- newCursor = OS.Ph_CURSOR_DRAG_BOTTOM;
- break;
- case SWT.LEFT:
- newCursor = OS.Ph_CURSOR_DRAG_LEFT;
- break;
- case SWT.RIGHT:
- newCursor = OS.Ph_CURSOR_DRAG_RIGHT;
- break;
- case SWT.LEFT | SWT.UP:
- newCursor = OS.Ph_CURSOR_DRAG_TL;
- break;
- case SWT.RIGHT | SWT.DOWN:
- newCursor = OS.Ph_CURSOR_DRAG_BR;
- break;
- case SWT.LEFT | SWT.DOWN:
- newCursor = OS.Ph_CURSOR_DRAG_BL;
- break;
- case SWT.RIGHT | SWT.UP:
- newCursor = OS.Ph_CURSOR_DRAG_TR;
- break;
- default:
- newCursor = OS.Ph_CURSOR_MOVE;
- break;
- }
- resizeCursor = newCursor;
- }
-
- return new Point (newX, newY);
-}
-
-static int checkStyle (int style) {
- if ((style & (SWT.LEFT | SWT.RIGHT | SWT.UP | SWT.DOWN)) == 0) {
- style |= SWT.LEFT | SWT.RIGHT | SWT.UP | SWT.DOWN;
- }
- return style;
-}
-
-/**
- * Stops displaying the tracker rectangles. Note that this is not considered
- * to be a cancelation by the user.
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public void close () {
- checkWidget();
- tracking = false;
-}
-
-Rectangle computeBounds () {
- int xMin = rectangles [0].x;
- int yMin = rectangles [0].y;
- int xMax = rectangles [0].x + rectangles [0].width;
- int yMax = rectangles [0].y + rectangles [0].height;
-
- for (int i = 1; i < rectangles.length; i++) {
- if (rectangles [i].x < xMin) xMin = rectangles [i].x;
- if (rectangles [i].y < yMin) yMin = rectangles [i].y;
- int rectRight = rectangles [i].x + rectangles [i].width;
- if (rectRight > xMax) xMax = rectRight;
- int rectBottom = rectangles [i].y + rectangles [i].height;
- if (rectBottom > yMax) yMax = rectBottom;
- }
-
- return new Rectangle (xMin, yMin, xMax - xMin, yMax - yMin);
-}
-
-Rectangle [] computeProportions (Rectangle [] rects) {
- Rectangle [] result = new Rectangle [rects.length];
- Rectangle bounds = computeBounds ();
- for (int i = 0; i < rects.length; i++) {
- result[i] = new Rectangle (
- (rects[i].x - bounds.x) * 100 / bounds.width,
- (rects[i].y - bounds.y) * 100 / bounds.height,
- rects[i].width * 100 / bounds.width,
- rects[i].height * 100 / bounds.height);
- }
- return result;
-}
-
-void drawRectangles (Rectangle [] rects) {
- if (parent != null) {
- if (parent.isDisposed ()) return;
- parent.getShell ().update ();
- } else {
- display.update ();
- }
- int rid = OS.Ph_DEV_RID;
- if (parent != null) rid = OS.PtWidgetRid (parent.handle);
-
- int phGC = OS.PgCreateGC (0);
- if (phGC == 0) return;
- int prevContext = OS.PgSetGC (phGC);
- OS.PgSetRegion (rid);
- OS.PgSetDrawMode (OS.Pg_DRAWMODE_XOR);
- OS.PgSetFillColor (0xffffff);
-
- int bandWidth = 0;
- if (stippled) {
- bandWidth = 2;
- OS.PgSetFillTransPat (OS.Pg_PAT_HALF);
- }
- for (int i=0; i<rects.length; i++) {
- Rectangle r = rects [i];
- int x1 = r.x;
- int y1 = r.y;
- int x2 = r.x + r.width;
- int y2 = r.y + r.height;
- OS.PgDrawIRect(x1, y1, x2, y1 + bandWidth, OS.Pg_DRAW_FILL);
- OS.PgDrawIRect(x1, y1 + bandWidth + 1, x1 + bandWidth, y2 - bandWidth - 1, OS.Pg_DRAW_FILL);
- OS.PgDrawIRect(x2 - bandWidth, y1 + bandWidth + 1, x2, y2 - bandWidth - 1, OS.Pg_DRAW_FILL);
- OS.PgDrawIRect(x1, y2 - bandWidth, x2, y2, OS.Pg_DRAW_FILL);
- }
- OS.PgSetGC (prevContext);
- OS.PgDestroyGC (phGC);
-}
-
-public Display getDisplay () {
- return display;
-}
-
-/**
- * Returns the bounds that are being drawn, expressed relative to the parent
- * widget. If the parent is a <code>Display</code> then these are screen
- * coordinates.
- *
- * @return the bounds of the Rectangles being drawn
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
+public void addControlListener(ControlListener listener) {
+ checkWidget();
+ if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+ TypedListener typedListener = new TypedListener (listener);
+ addListener (SWT.Move,typedListener);
+}
+
+Point adjustMoveCursor () {
+ Rectangle bounds = computeBounds ();
+ int newX = bounds.x + bounds.width / 2;
+ int newY = bounds.y;
+ /*
+ * Convert to screen coordinates iff needed
+ */
+ if (parent != null) {
+ short [] x = new short [1], y = new short [1];
+ OS.PtGetAbsPosition (parent.handle, x, y);
+ newX += x [0];
+ newY += y [0];
+ }
+ OS.PhMoveCursorAbs(OS.PhInputGroup (0), newX, newY);
+ return new Point (newX, newY);
+}
+
+Point adjustResizeCursor () {
+ int newX, newY;
+ Rectangle bounds = computeBounds ();
+
+ if ((cursorOrientation & SWT.LEFT) != 0) {
+ newX = bounds.x;
+ } else if ((cursorOrientation & SWT.RIGHT) != 0) {
+ newX = bounds.x + bounds.width;
+ } else {
+ newX = bounds.x + bounds.width / 2;
+ }
+
+ if ((cursorOrientation & SWT.UP) != 0) {
+ newY = bounds.y;
+ } else if ((cursorOrientation & SWT.DOWN) != 0) {
+ newY = bounds.y + bounds.height;
+ } else {
+ newY = bounds.y + bounds.height / 2;
+ }
+
+ /*
+ * Convert to screen coordinates iff needed
+ */
+ if (parent != null) {
+ short [] x = new short [1], y = new short [1];
+ OS.PtGetAbsPosition (parent.handle, x, y);
+ newX += x [0];
+ newY += y [0];
+ }
+ OS.PhMoveCursorAbs(OS.PhInputGroup (0), newX, newY);
+
+ /*
+ * If the client has not provided a custom cursor then determine
+ * the appropriate resize cursor.
+ */
+ if (clientCursor == 0) {
+ int newCursor = 0;
+ switch (cursorOrientation) {
+ case SWT.UP:
+ newCursor = OS.Ph_CURSOR_DRAG_TOP;
+ break;
+ case SWT.DOWN:
+ newCursor = OS.Ph_CURSOR_DRAG_BOTTOM;
+ break;
+ case SWT.LEFT:
+ newCursor = OS.Ph_CURSOR_DRAG_LEFT;
+ break;
+ case SWT.RIGHT:
+ newCursor = OS.Ph_CURSOR_DRAG_RIGHT;
+ break;
+ case SWT.LEFT | SWT.UP:
+ newCursor = OS.Ph_CURSOR_DRAG_TL;
+ break;
+ case SWT.RIGHT | SWT.DOWN:
+ newCursor = OS.Ph_CURSOR_DRAG_BR;
+ break;
+ case SWT.LEFT | SWT.DOWN:
+ newCursor = OS.Ph_CURSOR_DRAG_BL;
+ break;
+ case SWT.RIGHT | SWT.UP:
+ newCursor = OS.Ph_CURSOR_DRAG_TR;
+ break;
+ default:
+ newCursor = OS.Ph_CURSOR_MOVE;
+ break;
+ }
+ resizeCursor = newCursor;
+ }
+
+ return new Point (newX, newY);
+}
+
+static int checkStyle (int style) {
+ if ((style & (SWT.LEFT | SWT.RIGHT | SWT.UP | SWT.DOWN)) == 0) {
+ style |= SWT.LEFT | SWT.RIGHT | SWT.UP | SWT.DOWN;
+ }
+ return style;
+}
+
+/**
+ * Stops displaying the tracker rectangles. Note that this is not considered
+ * to be a cancelation by the user.
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void close () {
+ checkWidget();
+ tracking = false;
+}
+
+Rectangle computeBounds () {
+ int xMin = rectangles [0].x;
+ int yMin = rectangles [0].y;
+ int xMax = rectangles [0].x + rectangles [0].width;
+ int yMax = rectangles [0].y + rectangles [0].height;
+
+ for (int i = 1; i < rectangles.length; i++) {
+ if (rectangles [i].x < xMin) xMin = rectangles [i].x;
+ if (rectangles [i].y < yMin) yMin = rectangles [i].y;
+ int rectRight = rectangles [i].x + rectangles [i].width;
+ if (rectRight > xMax) xMax = rectRight;
+ int rectBottom = rectangles [i].y + rectangles [i].height;
+ if (rectBottom > yMax) yMax = rectBottom;
+ }
+
+ return new Rectangle (xMin, yMin, xMax - xMin, yMax - yMin);
+}
+
+Rectangle [] computeProportions (Rectangle [] rects) {
+ Rectangle [] result = new Rectangle [rects.length];
+ Rectangle bounds = computeBounds ();
+ for (int i = 0; i < rects.length; i++) {
+ result[i] = new Rectangle (
+ (rects[i].x - bounds.x) * 100 / bounds.width,
+ (rects[i].y - bounds.y) * 100 / bounds.height,
+ rects[i].width * 100 / bounds.width,
+ rects[i].height * 100 / bounds.height);
+ }
+ return result;
+}
+
+void drawRectangles (Rectangle [] rects) {
+ if (parent != null) {
+ if (parent.isDisposed ()) return;
+ parent.getShell ().update ();
+ } else {
+ display.update ();
+ }
+ int rid = OS.Ph_DEV_RID;
+ if (parent != null) rid = OS.PtWidgetRid (parent.handle);
+
+ int phGC = OS.PgCreateGC (0);
+ if (phGC == 0) return;
+ int prevContext = OS.PgSetGC (phGC);
+ OS.PgSetRegion (rid);
+ OS.PgSetDrawMode (OS.Pg_DRAWMODE_XOR);
+ OS.PgSetFillColor (0xffffff);
+
+ int bandWidth = 0;
+ if (stippled) {
+ bandWidth = 2;
+ OS.PgSetFillTransPat (OS.Pg_PAT_HALF);
+ }
+ for (int i=0; i<rects.length; i++) {
+ Rectangle r = rects [i];
+ int x1 = r.x;
+ int y1 = r.y;
+ int x2 = r.x + r.width;
+ int y2 = r.y + r.height;
+ OS.PgDrawIRect(x1, y1, x2, y1 + bandWidth, OS.Pg_DRAW_FILL);
+ OS.PgDrawIRect(x1, y1 + bandWidth + 1, x1 + bandWidth, y2 - bandWidth - 1, OS.Pg_DRAW_FILL);
+ OS.PgDrawIRect(x2 - bandWidth, y1 + bandWidth + 1, x2, y2 - bandWidth - 1, OS.Pg_DRAW_FILL);
+ OS.PgDrawIRect(x1, y2 - bandWidth, x2, y2, OS.Pg_DRAW_FILL);
+ }
+ OS.PgSetGC (prevContext);
+ OS.PgDestroyGC (phGC);
+}
+
+public Display getDisplay () {
+ return display;
+}
+
+/**
+ * Returns the bounds that are being drawn, expressed relative to the parent
+ * widget. If the parent is a <code>Display</code> then these are screen
+ * coordinates.
+ *
+ * @return the bounds of the Rectangles being drawn
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
*/
-public Rectangle [] getRectangles () {
- checkWidget();
- return rectangles;
-}
-
+public Rectangle [] getRectangles () {
+ checkWidget();
+ return rectangles;
+}
+
/**
* Returns <code>true</code> if the rectangles are drawn with a stippled line, <code>false</code> otherwise.
*
@@ -362,230 +362,230 @@ public Rectangle [] getRectangles () {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public boolean getStippled () {
- checkWidget();
- return stippled;
-}
-
-void moveRectangles (int xChange, int yChange) {
- if (xChange < 0 && ((style & SWT.LEFT) == 0)) return;
- if (xChange > 0 && ((style & SWT.RIGHT) == 0)) return;
- if (yChange < 0 && ((style & SWT.UP) == 0)) return;
- if (yChange > 0 && ((style & SWT.DOWN) == 0)) return;
- Rectangle bounds = computeBounds ();
- bounds.x += xChange; bounds.y += yChange;
- for (int i = 0; i < rectangles.length; i++) {
- rectangles [i].x += xChange;
- rectangles [i].y += yChange;
- }
-}
-
-/**
- * Displays the Tracker rectangles for manipulation by the user. Returns when
- * the user has either finished manipulating the rectangles or has cancelled the
- * Tracker.
- *
- * @return <code>true</code> if the user did not cancel the Tracker, <code>false</code> otherwise
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public boolean open () {
- checkWidget();
- if (rectangles == null) return false;
-
- int input_group = OS.PhInputGroup (0);
- PhCursorInfo_t info = new PhCursorInfo_t ();
- OS.PhQueryCursor ((short)input_group, info);
-
- if ((style & SWT.MENU) == 0) {
- /*
- * This code is intentionally commented. Tracking can happen through
- * the keyboard.
- */
-// if ((info.button_state & OS.Ph_BUTTON_SELECT) == 0) return false;
- }
-
- int region = 0;
- if (info.dragger == 0) {
- PhRect_t rect = new PhRect_t ();
- OS.PhWindowQueryVisible (OS.Ph_QUERY_CONSOLE, 0, OS.PhInputGroup (0), rect);
- int sense = OS.Ph_EV_DRAG | OS.Ph_EV_KEY | OS.Ph_EV_BUT_PRESS |
- OS.Ph_EV_BUT_RELEASE | OS.Ph_EV_PTR_MOTION;
- int [] args = {
- OS.Pt_ARG_WIDTH, rect.lr_x - rect.ul_x + 1, 0,
- OS.Pt_ARG_HEIGHT, rect.lr_y - rect.ul_y + 1, 0,
- OS.Pt_ARG_REGION_OPAQUE, 0, ~0,
- OS.Pt_ARG_REGION_SENSE, sense, ~0,
- OS.Pt_ARG_REGION_FLAGS, OS.Ph_FORCE_BOUNDARY, OS.Ph_FORCE_BOUNDARY,
- OS.Pt_ARG_FILL_COLOR, OS.Pg_TRANSPARENT, 0,
- };
- region = OS.PtCreateWidget (OS.PtRegion (), OS.Pt_NO_PARENT, args.length / 3, args);
- OS.PtRealizeWidget (region);
-
- rect = new PhRect_t ();
- int rid = OS.PtWidgetRid (region);
- OS.PhInitDrag (rid, OS.Ph_DRAG_KEY_MOTION | OS.Ph_TRACK_DRAG, rect, null, input_group, null, null, null, null, null);
- }
-
- int oldX, oldY;
- int size = PhEvent_t.sizeof + 1024;
- int buffer = OS.malloc (size);
- PhEvent_t phEvent = new PhEvent_t ();
- Event event = new Event ();
- Point cursorPos;
-
- drawRectangles (rectangles);
- if ((style & SWT.MENU) == 0) {
- oldX = info.pos_x;
- oldY = info.pos_y;
- } else {
- if ((style & SWT.RESIZE) != 0) {
- cursorPos = adjustResizeCursor ();
- } else {
- cursorPos = adjustMoveCursor ();
- }
- oldX = cursorPos.x;
- oldY = cursorPos.y;
- }
-
- tracking = true;
- boolean cancelled = false;
- while (tracking && !cancelled) {
- if (parent != null && parent.isDisposed ()) break;
- int result = OS.PhEventNext (buffer, size);
- switch (result) {
- case OS.Ph_EVENT_MSG: break;
- case OS.Ph_RESIZE_MSG:
- size = OS.PhGetMsgSize (buffer);
- OS.free (buffer);
- buffer = OS.malloc (size);
- continue;
- }
- OS.memmove (phEvent, buffer, PhEvent_t.sizeof);
- if (phEvent.type == OS.Ph_EV_DRAG) {
- switch (phEvent.subtype) {
- case OS.Ph_EV_DRAG_MOTION_EVENT: {
- int data = OS.PhGetData (buffer);
- if (data == 0) break;
- PhPointerEvent_t pe = new PhPointerEvent_t ();
- OS.memmove (pe, data, PhPointerEvent_t.sizeof);
- int newX = pe.pos_x;
- int newY = pe.pos_y;
- if (newX != oldX || newY != oldY) {
- drawRectangles (rectangles);
- event.x = newX;
- event.y = newY;
- if ((style & SWT.RESIZE) != 0) {
- resizeRectangles (newX - oldX, newY - oldY);
- cursorPos = adjustResizeCursor ();
- newX = cursorPos.x; newY = cursorPos.y;
- sendEvent (SWT.Resize, event);
- } else {
- moveRectangles (newX - oldX, newY - oldY);
- sendEvent (SWT.Move, event);
- }
- /*
- * It is possible (but unlikely), that application
- * code could have disposed the widget in the move
- * event. If this happens, return false to indicate
- * that the tracking has failed.
- */
- if (isDisposed ()) return false;
- drawRectangles (rectangles);
- oldX = newX; oldY = newY;
- }
- break;
- }
- case OS.Ph_EV_DRAG_KEY_EVENT: {
- int data = OS.PhGetData (buffer);
- if (data == 0) break;
- PhKeyEvent_t ke = new PhKeyEvent_t ();
- OS.memmove (ke, data, PhKeyEvent_t.sizeof);
- if ((ke.key_flags & OS.Pk_KF_Sym_Valid) != 0) {
- int stepSize = (ke.key_mods & OS.Pk_KM_Ctrl) != 0 ? STEPSIZE_SMALL : STEPSIZE_LARGE;
- int xChange = 0, yChange = 0;
- switch (ke.key_sym) {
- case OS.Pk_Escape:
- cancelled = true;
- tracking = false;
- break;
- case OS.Pk_Return:
- tracking = false;
- break;
- case OS.Pk_Left:
- xChange = -stepSize;
- break;
- case OS.Pk_Right:
- xChange = stepSize;
- break;
- case OS.Pk_Up:
- yChange = -stepSize;
- break;
- case OS.Pk_Down:
- yChange = stepSize;
- break;
- }
- if (xChange != 0 || yChange != 0) {
- drawRectangles (rectangles);
- int newX = oldX + xChange;
- int newY = oldY + yChange;
- event.x = newX;
- event.y = newY;
- if ((style & SWT.RESIZE) != 0) {
- resizeRectangles (xChange, yChange);
- cursorPos = adjustResizeCursor ();
- sendEvent (SWT.Resize, event);
- } else {
- moveRectangles (xChange, yChange);
- cursorPos = adjustMoveCursor ();
- sendEvent (SWT.Move, event);
- }
- /*
- * It is possible (but unlikely) that application
- * code could have disposed the widget in the move
- * event. If this happens return false to indicate
- * that the tracking has failed.
- */
- if (isDisposed ()) return false;
- drawRectangles (rectangles);
- oldX = cursorPos.x; oldY = cursorPos.y;
- }
- }
- break;
- }
- case OS.Ph_EV_DRAG_COMPLETE: {
- tracking = false;
- break;
- }
- }
- if (phEvent.collector_handle != 0) {
- setCursor (phEvent.collector_handle);
- }
- /*
- * Don't dispatch mouse and key events in general, EXCEPT once this
- * tracker has finished its work.
- */
- if (tracking && !cancelled) continue;
-
- }
- OS.PtEventHandler (buffer);
- }
- drawRectangles (rectangles);
- tracking = false;
- if (region != 0) OS.PtDestroyWidget (region);
- return !cancelled;
-}
-
-void releaseWidget () {
- super.releaseWidget ();
- parent = null;
- display = null;
- rectangles = null;
-}
-
+public boolean getStippled () {
+ checkWidget();
+ return stippled;
+}
+
+void moveRectangles (int xChange, int yChange) {
+ if (xChange < 0 && ((style & SWT.LEFT) == 0)) return;
+ if (xChange > 0 && ((style & SWT.RIGHT) == 0)) return;
+ if (yChange < 0 && ((style & SWT.UP) == 0)) return;
+ if (yChange > 0 && ((style & SWT.DOWN) == 0)) return;
+ Rectangle bounds = computeBounds ();
+ bounds.x += xChange; bounds.y += yChange;
+ for (int i = 0; i < rectangles.length; i++) {
+ rectangles [i].x += xChange;
+ rectangles [i].y += yChange;
+ }
+}
+
+/**
+ * Displays the Tracker rectangles for manipulation by the user. Returns when
+ * the user has either finished manipulating the rectangles or has cancelled the
+ * Tracker.
+ *
+ * @return <code>true</code> if the user did not cancel the Tracker, <code>false</code> otherwise
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public boolean open () {
+ checkWidget();
+ if (rectangles == null) return false;
+
+ int input_group = OS.PhInputGroup (0);
+ PhCursorInfo_t info = new PhCursorInfo_t ();
+ OS.PhQueryCursor ((short)input_group, info);
+
+ if ((style & SWT.MENU) == 0) {
+ /*
+ * This code is intentionally commented. Tracking can happen through
+ * the keyboard.
+ */
+// if ((info.button_state & OS.Ph_BUTTON_SELECT) == 0) return false;
+ }
+
+ int region = 0;
+ if (info.dragger == 0) {
+ PhRect_t rect = new PhRect_t ();
+ OS.PhWindowQueryVisible (OS.Ph_QUERY_CONSOLE, 0, OS.PhInputGroup (0), rect);
+ int sense = OS.Ph_EV_DRAG | OS.Ph_EV_KEY | OS.Ph_EV_BUT_PRESS |
+ OS.Ph_EV_BUT_RELEASE | OS.Ph_EV_PTR_MOTION;
+ int [] args = {
+ OS.Pt_ARG_WIDTH, rect.lr_x - rect.ul_x + 1, 0,
+ OS.Pt_ARG_HEIGHT, rect.lr_y - rect.ul_y + 1, 0,
+ OS.Pt_ARG_REGION_OPAQUE, 0, ~0,
+ OS.Pt_ARG_REGION_SENSE, sense, ~0,
+ OS.Pt_ARG_REGION_FLAGS, OS.Ph_FORCE_BOUNDARY, OS.Ph_FORCE_BOUNDARY,
+ OS.Pt_ARG_FILL_COLOR, OS.Pg_TRANSPARENT, 0,
+ };
+ region = OS.PtCreateWidget (OS.PtRegion (), OS.Pt_NO_PARENT, args.length / 3, args);
+ OS.PtRealizeWidget (region);
+
+ rect = new PhRect_t ();
+ int rid = OS.PtWidgetRid (region);
+ OS.PhInitDrag (rid, OS.Ph_DRAG_KEY_MOTION | OS.Ph_TRACK_DRAG, rect, null, input_group, null, null, null, null, null);
+ }
+
+ int oldX, oldY;
+ int size = PhEvent_t.sizeof + 1024;
+ int buffer = OS.malloc (size);
+ PhEvent_t phEvent = new PhEvent_t ();
+ Event event = new Event ();
+ Point cursorPos;
+
+ drawRectangles (rectangles);
+ if ((style & SWT.MENU) == 0) {
+ oldX = info.pos_x;
+ oldY = info.pos_y;
+ } else {
+ if ((style & SWT.RESIZE) != 0) {
+ cursorPos = adjustResizeCursor ();
+ } else {
+ cursorPos = adjustMoveCursor ();
+ }
+ oldX = cursorPos.x;
+ oldY = cursorPos.y;
+ }
+
+ tracking = true;
+ boolean cancelled = false;
+ while (tracking && !cancelled) {
+ if (parent != null && parent.isDisposed ()) break;
+ int result = OS.PhEventNext (buffer, size);
+ switch (result) {
+ case OS.Ph_EVENT_MSG: break;
+ case OS.Ph_RESIZE_MSG:
+ size = OS.PhGetMsgSize (buffer);
+ OS.free (buffer);
+ buffer = OS.malloc (size);
+ continue;
+ }
+ OS.memmove (phEvent, buffer, PhEvent_t.sizeof);
+ if (phEvent.type == OS.Ph_EV_DRAG) {
+ switch (phEvent.subtype) {
+ case OS.Ph_EV_DRAG_MOTION_EVENT: {
+ int data = OS.PhGetData (buffer);
+ if (data == 0) break;
+ PhPointerEvent_t pe = new PhPointerEvent_t ();
+ OS.memmove (pe, data, PhPointerEvent_t.sizeof);
+ int newX = pe.pos_x;
+ int newY = pe.pos_y;
+ if (newX != oldX || newY != oldY) {
+ drawRectangles (rectangles);
+ event.x = newX;
+ event.y = newY;
+ if ((style & SWT.RESIZE) != 0) {
+ resizeRectangles (newX - oldX, newY - oldY);
+ cursorPos = adjustResizeCursor ();
+ newX = cursorPos.x; newY = cursorPos.y;
+ sendEvent (SWT.Resize, event);
+ } else {
+ moveRectangles (newX - oldX, newY - oldY);
+ sendEvent (SWT.Move, event);
+ }
+ /*
+ * It is possible (but unlikely), that application
+ * code could have disposed the widget in the move
+ * event. If this happens, return false to indicate
+ * that the tracking has failed.
+ */
+ if (isDisposed ()) return false;
+ drawRectangles (rectangles);
+ oldX = newX; oldY = newY;
+ }
+ break;
+ }
+ case OS.Ph_EV_DRAG_KEY_EVENT: {
+ int data = OS.PhGetData (buffer);
+ if (data == 0) break;
+ PhKeyEvent_t ke = new PhKeyEvent_t ();
+ OS.memmove (ke, data, PhKeyEvent_t.sizeof);
+ if ((ke.key_flags & OS.Pk_KF_Sym_Valid) != 0) {
+ int stepSize = (ke.key_mods & OS.Pk_KM_Ctrl) != 0 ? STEPSIZE_SMALL : STEPSIZE_LARGE;
+ int xChange = 0, yChange = 0;
+ switch (ke.key_sym) {
+ case OS.Pk_Escape:
+ cancelled = true;
+ tracking = false;
+ break;
+ case OS.Pk_Return:
+ tracking = false;
+ break;
+ case OS.Pk_Left:
+ xChange = -stepSize;
+ break;
+ case OS.Pk_Right:
+ xChange = stepSize;
+ break;
+ case OS.Pk_Up:
+ yChange = -stepSize;
+ break;
+ case OS.Pk_Down:
+ yChange = stepSize;
+ break;
+ }
+ if (xChange != 0 || yChange != 0) {
+ drawRectangles (rectangles);
+ int newX = oldX + xChange;
+ int newY = oldY + yChange;
+ event.x = newX;
+ event.y = newY;
+ if ((style & SWT.RESIZE) != 0) {
+ resizeRectangles (xChange, yChange);
+ cursorPos = adjustResizeCursor ();
+ sendEvent (SWT.Resize, event);
+ } else {
+ moveRectangles (xChange, yChange);
+ cursorPos = adjustMoveCursor ();
+ sendEvent (SWT.Move, event);
+ }
+ /*
+ * It is possible (but unlikely) that application
+ * code could have disposed the widget in the move
+ * event. If this happens return false to indicate
+ * that the tracking has failed.
+ */
+ if (isDisposed ()) return false;
+ drawRectangles (rectangles);
+ oldX = cursorPos.x; oldY = cursorPos.y;
+ }
+ }
+ break;
+ }
+ case OS.Ph_EV_DRAG_COMPLETE: {
+ tracking = false;
+ break;
+ }
+ }
+ if (phEvent.collector_handle != 0) {
+ setCursor (phEvent.collector_handle);
+ }
+ /*
+ * Don't dispatch mouse and key events in general, EXCEPT once this
+ * tracker has finished its work.
+ */
+ if (tracking && !cancelled) continue;
+
+ }
+ OS.PtEventHandler (buffer);
+ }
+ drawRectangles (rectangles);
+ tracking = false;
+ if (region != 0) OS.PtDestroyWidget (region);
+ return !cancelled;
+}
+
+void releaseWidget () {
+ super.releaseWidget ();
+ parent = null;
+ display = null;
+ rectangles = null;
+}
+
/**
* Removes the listener from the collection of listeners who will
* be notified when the control is moved or resized.
@@ -603,109 +603,109 @@ void releaseWidget () {
* @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);
-}
-
-void resizeRectangles (int xChange, int yChange) {
- /*
- * If the cursor orientation has not been set in the orientation of
- * this change then try to set it here.
- */
- if (xChange < 0 && ((style & SWT.LEFT) != 0) && ((cursorOrientation & SWT.RIGHT) == 0)) {
- cursorOrientation |= SWT.LEFT;
- } else if (xChange > 0 && ((style & SWT.RIGHT) != 0) && ((cursorOrientation & SWT.LEFT) == 0)) {
- cursorOrientation |= SWT.RIGHT;
- } else if (yChange < 0 && ((style & SWT.UP) != 0) && ((cursorOrientation & SWT.DOWN) == 0)) {
- cursorOrientation |= SWT.UP;
- } else if (yChange > 0 && ((style & SWT.DOWN) != 0) && ((cursorOrientation & SWT.UP) == 0)) {
- cursorOrientation |= SWT.DOWN;
- }
- Rectangle bounds = computeBounds ();
- if ((cursorOrientation & SWT.LEFT) != 0) {
- bounds.x += xChange;
- bounds.width -= xChange;
- } else if ((cursorOrientation & SWT.RIGHT) != 0) {
- bounds.width += xChange;
- }
- if ((cursorOrientation & SWT.UP) != 0) {
- bounds.y += yChange;
- bounds.height -= yChange;
- } else if ((cursorOrientation & SWT.DOWN) != 0) {
- bounds.height += yChange;
- }
- /*
- * The following are conditions under which the resize should not be applied
- */
- if (bounds.width < 0 || bounds.height < 0) return;
-
- Rectangle [] newRects = new Rectangle [rectangles.length];
- for (int i = 0; i < rectangles.length; i++) {
- Rectangle proportion = proportions[i];
- newRects[i] = new Rectangle (
- proportion.x * bounds.width / 100 + bounds.x,
- proportion.y * bounds.height / 100 + bounds.y,
- proportion.width * bounds.width / 100,
- proportion.height * bounds.height / 100);
- }
- rectangles = newRects;
-}
-
-/**
- * Sets the <code>Cursor</code> of the Tracker. If this cursor is <code>null</code>
- * then the cursor reverts to the default.
- *
- * @param newCursor the new <code>Cursor</code> to display
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public void setCursor (Cursor cursor) {
- checkWidget();
- int type = 0;
- int bitmap = 0;
- if (cursor != null) {
- if (cursor.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
- type = cursor.type;
- bitmap = cursor.bitmap;
- }
- clientCursor = type;
- clientBitmap = bitmap;
-}
-
-void setCursor (int cursorHandle) {
- if (cursorHandle == 0) return;
- int type = 0;
- int bitmap = 0;
- if (clientCursor != 0) {
- type = clientCursor;
- bitmap = clientBitmap;
- } else if (resizeCursor != 0) {
- type = resizeCursor;
- }
- int [] args = new int []{
- OS.Pt_ARG_CURSOR_TYPE, type, 0,
- OS.Pt_ARG_BITMAP_CURSOR, bitmap, 0,
- };
- OS.PtSetResources (cursorHandle, args.length / 3, args);
-
- /*
- * Bug in Photon. For some reason, the widget cursor will
- * not change, when the new cursor is a bitmap cursor, if
- * the flag Ph_CURSOR_NO_INHERIT is reset. The fix is to reset
- * this flag after changing the cursor type to Ph_CURSOR_BITMAP.
- */
- if (type == OS.Ph_CURSOR_BITMAP) {
- type &= ~OS.Ph_CURSOR_NO_INHERIT;
- OS.PtSetResource (cursorHandle, OS.Pt_ARG_CURSOR_TYPE, type, 0);
- }
-}
-
+public void removeControlListener (ControlListener listener) {
+ checkWidget();
+ if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+ if (eventTable == null) return;
+ eventTable.unhook (SWT.Move, listener);
+}
+
+void resizeRectangles (int xChange, int yChange) {
+ /*
+ * If the cursor orientation has not been set in the orientation of
+ * this change then try to set it here.
+ */
+ if (xChange < 0 && ((style & SWT.LEFT) != 0) && ((cursorOrientation & SWT.RIGHT) == 0)) {
+ cursorOrientation |= SWT.LEFT;
+ } else if (xChange > 0 && ((style & SWT.RIGHT) != 0) && ((cursorOrientation & SWT.LEFT) == 0)) {
+ cursorOrientation |= SWT.RIGHT;
+ } else if (yChange < 0 && ((style & SWT.UP) != 0) && ((cursorOrientation & SWT.DOWN) == 0)) {
+ cursorOrientation |= SWT.UP;
+ } else if (yChange > 0 && ((style & SWT.DOWN) != 0) && ((cursorOrientation & SWT.UP) == 0)) {
+ cursorOrientation |= SWT.DOWN;
+ }
+ Rectangle bounds = computeBounds ();
+ if ((cursorOrientation & SWT.LEFT) != 0) {
+ bounds.x += xChange;
+ bounds.width -= xChange;
+ } else if ((cursorOrientation & SWT.RIGHT) != 0) {
+ bounds.width += xChange;
+ }
+ if ((cursorOrientation & SWT.UP) != 0) {
+ bounds.y += yChange;
+ bounds.height -= yChange;
+ } else if ((cursorOrientation & SWT.DOWN) != 0) {
+ bounds.height += yChange;
+ }
+ /*
+ * The following are conditions under which the resize should not be applied
+ */
+ if (bounds.width < 0 || bounds.height < 0) return;
+
+ Rectangle [] newRects = new Rectangle [rectangles.length];
+ for (int i = 0; i < rectangles.length; i++) {
+ Rectangle proportion = proportions[i];
+ newRects[i] = new Rectangle (
+ proportion.x * bounds.width / 100 + bounds.x,
+ proportion.y * bounds.height / 100 + bounds.y,
+ proportion.width * bounds.width / 100,
+ proportion.height * bounds.height / 100);
+ }
+ rectangles = newRects;
+}
+
+/**
+ * Sets the <code>Cursor</code> of the Tracker. If this cursor is <code>null</code>
+ * then the cursor reverts to the default.
+ *
+ * @param newCursor the new <code>Cursor</code> to display
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setCursor (Cursor cursor) {
+ checkWidget();
+ int type = 0;
+ int bitmap = 0;
+ if (cursor != null) {
+ if (cursor.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+ type = cursor.type;
+ bitmap = cursor.bitmap;
+ }
+ clientCursor = type;
+ clientBitmap = bitmap;
+}
+
+void setCursor (int cursorHandle) {
+ if (cursorHandle == 0) return;
+ int type = 0;
+ int bitmap = 0;
+ if (clientCursor != 0) {
+ type = clientCursor;
+ bitmap = clientBitmap;
+ } else if (resizeCursor != 0) {
+ type = resizeCursor;
+ }
+ int [] args = new int []{
+ OS.Pt_ARG_CURSOR_TYPE, type, 0,
+ OS.Pt_ARG_BITMAP_CURSOR, bitmap, 0,
+ };
+ OS.PtSetResources (cursorHandle, args.length / 3, args);
+
+ /*
+ * Bug in Photon. For some reason, the widget cursor will
+ * not change, when the new cursor is a bitmap cursor, if
+ * the flag Ph_CURSOR_NO_INHERIT is reset. The fix is to reset
+ * this flag after changing the cursor type to Ph_CURSOR_BITMAP.
+ */
+ if (type == OS.Ph_CURSOR_BITMAP) {
+ type &= ~OS.Ph_CURSOR_NO_INHERIT;
+ OS.PtSetResource (cursorHandle, OS.Pt_ARG_CURSOR_TYPE, type, 0);
+ }
+}
+
/**
* Specifies the rectangles that should be drawn, expressed relative to the parent
* widget. If the parent is a Display then these are screen coordinates.
@@ -717,13 +717,13 @@ void setCursor (int cursorHandle) {
* <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;
- proportions = computeProportions (rectangles);
-}
-
+public void setRectangles (Rectangle [] rectangles) {
+ checkWidget();
+ if (rectangles == null) error (SWT.ERROR_NULL_ARGUMENT);
+ this.rectangles = rectangles;
+ proportions = computeProportions (rectangles);
+}
+
/**
* Changes the appearance of the line used to draw the rectangles.
*
@@ -734,9 +734,9 @@ public void setRectangles (Rectangle [] rectangles) {
* <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;
-}
-
-}
+public void setStippled (boolean stippled) {
+ checkWidget();
+ this.stippled = stippled;
+}
+
+}
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
index b880163253..48e196d1d6 100755
--- 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
@@ -1,17 +1,17 @@
-package org.eclipse.swt.widgets;
-
-/*
+package org.eclipse.swt.widgets;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-import org.eclipse.swt.internal.*;
-import org.eclipse.swt.internal.photon.*;
-import org.eclipse.swt.*;
-import org.eclipse.swt.events.*;
-
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+import org.eclipse.swt.internal.*;
+import org.eclipse.swt.internal.photon.*;
+import org.eclipse.swt.*;
+import org.eclipse.swt.events.*;
+
/**
* This class is the abstract superclass of all user interface objects.
* Widgets are created, disposed and issue notification to listeners
@@ -38,40 +38,40 @@ import org.eclipse.swt.events.*;
*
* @see #checkSubclass
*/
-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 = 1 << 0;
-// static final int ACTIVE = 1 << 1;
- static final int GRAB = 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;
- static final int MOVED = 1 << 13;
- static final int RESIZED = 1 << 14;
-
- static final int DEFAULT_WIDTH = 64;
- static final int DEFAULT_HEIGHT = 64;
-
- static final char Mnemonic = '&';
-
-Widget () {
- /* Do nothing */
-}
-
+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 = 1 << 0;
+// static final int ACTIVE = 1 << 1;
+ static final int GRAB = 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;
+ static final int MOVED = 1 << 13;
+ static final int RESIZED = 1 << 14;
+
+ static final int DEFAULT_WIDTH = 64;
+ static final int DEFAULT_HEIGHT = 64;
+
+ static final char Mnemonic = '&';
+
+Widget () {
+ /* Do nothing */
+}
+
/**
* Constructs a new instance of this class given its parent
* and a style value describing its behavior and appearance.
@@ -100,156 +100,156 @@ Widget () {
* @see #checkSubclass
* @see #getStyle
*/
-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;
-}
-
-/**
- * Returns the provided string without mnemonic indicators.
- *
- * @param string the string to demangle
- */
-static String stripMnemonics (String string) {
- char [] text = new char [string.length ()];
- string.getChars (0, text.length, text, 0);
- int j = 0;
- for (int i = 0; i < text.length;) {
- if ((text[j++] = text[i++]) == Mnemonic) {
- if (i != text.length) {
- if (text[i] == Mnemonic) i++; else j--;
- }
- }
- }
- return new String(text, 0, j);
-}
-
-void checkOrientation (Widget parent) {
- style &= ~SWT.MIRRORED;
- if ((style & (SWT.LEFT_TO_RIGHT | SWT.RIGHT_TO_LEFT)) == 0) {
- if (parent != null) {
- if ((parent.style & SWT.LEFT_TO_RIGHT) != 0) style |= SWT.LEFT_TO_RIGHT;
- if ((parent.style & SWT.RIGHT_TO_LEFT) != 0) style |= SWT.RIGHT_TO_LEFT;
- }
- }
- style = checkBits (style, SWT.LEFT_TO_RIGHT, SWT.RIGHT_TO_LEFT, 0, 0, 0, 0);
-}
-
-void checkParent (Widget parent) {
- if (parent == null) error (SWT.ERROR_NULL_ARGUMENT);
- if (!parent.isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
- if (parent.isDisposed()) error (SWT.ERROR_INVALID_ARGUMENT);
-}
-
-/**
- * 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 (isDisposed ()) error (SWT.ERROR_WIDGET_DISPOSED);
-}
-
-int copyPhImage(int image) {
- if (image == 0) return 0;
- int newImage = OS.PiDuplicateImage (image, 0);
-
- /*
- * Bug in Photon. The image returned by PiDuplicateImage might
- * have the same mask_bm/alpha as the original image. The fix
- * is to detect this case and copy mask_bm/alpha if necessary.
- */
- PhImage_t phImage = new PhImage_t();
- OS.memmove (phImage, image, PhImage_t.sizeof);
- PhImage_t newPhImage = new PhImage_t();
- OS.memmove(newPhImage, newImage, PhImage_t.sizeof);
- if (newPhImage.mask_bm != 0 && phImage.mask_bm == newPhImage.mask_bm) {
- int length = newPhImage.mask_bpl * newPhImage.size_h;
- int ptr = OS.malloc(length);
- OS.memmove(ptr, newPhImage.mask_bm, length);
- newPhImage.mask_bm = ptr;
- }
- if (newPhImage.alpha != 0 && phImage.alpha == newPhImage.alpha) {
- 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_bpl * alpha.src_alpha_map_dim_h;
- int ptr = OS.malloc(length);
- OS.memmove(ptr, alpha.src_alpha_map_map, length);
- alpha.src_alpha_map_map = ptr;
- }
- int ptr = OS.malloc(PgAlpha_t.sizeof);
- OS.memmove(ptr, alpha, PgAlpha_t.sizeof);
- newPhImage.alpha = ptr;
- }
- OS.memmove(newImage, newPhImage, PhImage_t.sizeof);
- return newImage;
-}
-
+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;
+}
+
+/**
+ * Returns the provided string without mnemonic indicators.
+ *
+ * @param string the string to demangle
+ */
+static String stripMnemonics (String string) {
+ char [] text = new char [string.length ()];
+ string.getChars (0, text.length, text, 0);
+ int j = 0;
+ for (int i = 0; i < text.length;) {
+ if ((text[j++] = text[i++]) == Mnemonic) {
+ if (i != text.length) {
+ if (text[i] == Mnemonic) i++; else j--;
+ }
+ }
+ }
+ return new String(text, 0, j);
+}
+
+void checkOrientation (Widget parent) {
+ style &= ~SWT.MIRRORED;
+ if ((style & (SWT.LEFT_TO_RIGHT | SWT.RIGHT_TO_LEFT)) == 0) {
+ if (parent != null) {
+ if ((parent.style & SWT.LEFT_TO_RIGHT) != 0) style |= SWT.LEFT_TO_RIGHT;
+ if ((parent.style & SWT.RIGHT_TO_LEFT) != 0) style |= SWT.RIGHT_TO_LEFT;
+ }
+ }
+ style = checkBits (style, SWT.LEFT_TO_RIGHT, SWT.RIGHT_TO_LEFT, 0, 0, 0, 0);
+}
+
+void checkParent (Widget parent) {
+ if (parent == null) error (SWT.ERROR_NULL_ARGUMENT);
+ if (!parent.isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (parent.isDisposed()) error (SWT.ERROR_INVALID_ARGUMENT);
+}
+
+/**
+ * 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 (isDisposed ()) error (SWT.ERROR_WIDGET_DISPOSED);
+}
+
+int copyPhImage(int image) {
+ if (image == 0) return 0;
+ int newImage = OS.PiDuplicateImage (image, 0);
+
+ /*
+ * Bug in Photon. The image returned by PiDuplicateImage might
+ * have the same mask_bm/alpha as the original image. The fix
+ * is to detect this case and copy mask_bm/alpha if necessary.
+ */
+ PhImage_t phImage = new PhImage_t();
+ OS.memmove (phImage, image, PhImage_t.sizeof);
+ PhImage_t newPhImage = new PhImage_t();
+ OS.memmove(newPhImage, newImage, PhImage_t.sizeof);
+ if (newPhImage.mask_bm != 0 && phImage.mask_bm == newPhImage.mask_bm) {
+ int length = newPhImage.mask_bpl * newPhImage.size_h;
+ int ptr = OS.malloc(length);
+ OS.memmove(ptr, newPhImage.mask_bm, length);
+ newPhImage.mask_bm = ptr;
+ }
+ if (newPhImage.alpha != 0 && phImage.alpha == newPhImage.alpha) {
+ 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_bpl * alpha.src_alpha_map_dim_h;
+ int ptr = OS.malloc(length);
+ OS.memmove(ptr, alpha.src_alpha_map_map, length);
+ alpha.src_alpha_map_map = ptr;
+ }
+ int ptr = OS.malloc(PgAlpha_t.sizeof);
+ OS.memmove(ptr, alpha, PgAlpha_t.sizeof);
+ newPhImage.alpha = ptr;
+ }
+ OS.memmove(newImage, newPhImage, PhImage_t.sizeof);
+ return newImage;
+}
+
/**
* Adds the listener to the collection of listeners who will
* be notifed when an event of the given type occurs. When the
@@ -270,13 +270,13 @@ int copyPhImage(int image) {
* @see Listener
* @see #removeListener
*/
-public void addListener (int eventType, Listener handler) {
- checkWidget();
- if (handler == null) error (SWT.ERROR_NULL_ARGUMENT);
- if (eventTable == null) eventTable = new EventTable ();
- eventTable.hook (eventType, handler);
-}
-
+public void addListener (int eventType, Listener handler) {
+ checkWidget();
+ if (handler == null) error (SWT.ERROR_NULL_ARGUMENT);
+ if (eventTable == null) eventTable = new EventTable ();
+ eventTable.hook (eventType, handler);
+}
+
/**
* Adds the listener to the collection of listeners who will
* be notifed when the widget is disposed. When the widget is
@@ -296,81 +296,81 @@ public void addListener (int eventType, Listener handler) {
* @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);
-}
-
-void createHandle (int index) {
- /* Do nothing */
-}
-
-int createToolTip (String string, int handle, byte [] font) {
- if (string == null || string.length () == 0 || handle == 0) {
- return 0;
- }
-
- int shellHandle = OS.PtFindDisjoint (handle);
- byte [] buffer = Converter.wcsToMbcs (null, string, true);
- Display display = getDisplay ();
- int fill = display.INFO_BACKGROUND;
- int text_color = display.INFO_FOREGROUND;
- int toolTipHandle = OS.PtInflateBalloon (shellHandle, handle, OS.Pt_BALLOON_RIGHT, buffer, font, fill, text_color);
-
- /*
- * Feature in Photon. The position of the inflated balloon
- * is relative to the widget position and not to the cursor
- * position. The fix is to re-position the balloon.
- */
- int ig = OS.PhInputGroup (0);
- PhCursorInfo_t info = new PhCursorInfo_t ();
- OS.PhQueryCursor ((short)ig, info);
- short [] absX = new short [1], absY = new short [1];
- OS.PtGetAbsPosition (shellHandle, absX, absY);
- int x = info.pos_x - absX [0] + 16;
- int y = info.pos_y - absY [0] + 16;
- PhArea_t shellArea = new PhArea_t ();
- OS.PtWidgetArea (shellHandle, shellArea);
- PhArea_t toolTipArea = new PhArea_t ();
- OS.PtWidgetArea (toolTipHandle, toolTipArea);
- x = Math.max (0, Math.min (x, shellArea.size_w - toolTipArea.size_w));
- y = Math.max (0, Math.min (y, shellArea.size_h - toolTipArea.size_h));
- 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);
- OS.PtSetResource (toolTipHandle, OS.Pt_ARG_POS, ptr, 0);
- OS.free (ptr);
-
- return toolTipHandle;
-}
-
-void createWidget (int index) {
- createHandle (index);
- hookEvents ();
- register ();
-}
-
-void deregister () {
- if (handle == 0) return;
- WidgetTable.remove (handle);
-}
-
-void destroyToolTip (int toolTipHandle) {
- if (toolTipHandle != 0) OS.PtDestroyWidget (toolTipHandle);
-}
-
-void destroyWidget () {
- int topHandle = topHandle ();
- releaseHandle ();
- if (topHandle != 0) {
- OS.PtDestroyWidget (topHandle);
- }
-}
-
+public void addDisposeListener (DisposeListener listener) {
+ checkWidget();
+ if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+ TypedListener typedListener = new TypedListener (listener);
+ addListener (SWT.Dispose, typedListener);
+}
+
+void createHandle (int index) {
+ /* Do nothing */
+}
+
+int createToolTip (String string, int handle, byte [] font) {
+ if (string == null || string.length () == 0 || handle == 0) {
+ return 0;
+ }
+
+ int shellHandle = OS.PtFindDisjoint (handle);
+ byte [] buffer = Converter.wcsToMbcs (null, string, true);
+ Display display = getDisplay ();
+ int fill = display.INFO_BACKGROUND;
+ int text_color = display.INFO_FOREGROUND;
+ int toolTipHandle = OS.PtInflateBalloon (shellHandle, handle, OS.Pt_BALLOON_RIGHT, buffer, font, fill, text_color);
+
+ /*
+ * Feature in Photon. The position of the inflated balloon
+ * is relative to the widget position and not to the cursor
+ * position. The fix is to re-position the balloon.
+ */
+ int ig = OS.PhInputGroup (0);
+ PhCursorInfo_t info = new PhCursorInfo_t ();
+ OS.PhQueryCursor ((short)ig, info);
+ short [] absX = new short [1], absY = new short [1];
+ OS.PtGetAbsPosition (shellHandle, absX, absY);
+ int x = info.pos_x - absX [0] + 16;
+ int y = info.pos_y - absY [0] + 16;
+ PhArea_t shellArea = new PhArea_t ();
+ OS.PtWidgetArea (shellHandle, shellArea);
+ PhArea_t toolTipArea = new PhArea_t ();
+ OS.PtWidgetArea (toolTipHandle, toolTipArea);
+ x = Math.max (0, Math.min (x, shellArea.size_w - toolTipArea.size_w));
+ y = Math.max (0, Math.min (y, shellArea.size_h - toolTipArea.size_h));
+ 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);
+ OS.PtSetResource (toolTipHandle, OS.Pt_ARG_POS, ptr, 0);
+ OS.free (ptr);
+
+ return toolTipHandle;
+}
+
+void createWidget (int index) {
+ createHandle (index);
+ hookEvents ();
+ register ();
+}
+
+void deregister () {
+ if (handle == 0) return;
+ WidgetTable.remove (handle);
+}
+
+void destroyToolTip (int toolTipHandle) {
+ if (toolTipHandle != 0) OS.PtDestroyWidget (toolTipHandle);
+}
+
+void destroyWidget () {
+ int topHandle = topHandle ();
+ releaseHandle ();
+ if (topHandle != 0) {
+ OS.PtDestroyWidget (topHandle);
+ }
+}
+
/**
* Disposes of the operating system resources associated with
* the receiver and all its descendents. After this method has
@@ -394,31 +394,31 @@ void destroyWidget () {
* @see #removeDisposeListener
* @see #checkWidget
*/
-public void dispose () {
- /*
- * Note: It is valid to attempt to dispose a widget
- * more than once. If this happens, fail silently.
- */
- if (isDisposed()) return;
- if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
- releaseChild ();
- releaseWidget ();
- destroyWidget ();
-}
-
-int drawProc (int widget, int damage) {
- return OS.Pt_CONTINUE;
-}
-
-static void error (int code) {
- SWT.error(code);
-}
-
-boolean filters (int eventType) {
- Display display = getDisplay ();
- return display.filters (eventType);
-}
-
+public void dispose () {
+ /*
+ * Note: It is valid to attempt to dispose a widget
+ * more than once. If this happens, fail silently.
+ */
+ if (isDisposed()) return;
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ releaseChild ();
+ releaseWidget ();
+ destroyWidget ();
+}
+
+int drawProc (int widget, int damage) {
+ return OS.Pt_CONTINUE;
+}
+
+static void error (int code) {
+ SWT.error(code);
+}
+
+boolean filters (int eventType) {
+ Display display = getDisplay ();
+ return display.filters (eventType);
+}
+
/**
* Returns the application defined widget data associated
* with the receiver, or null if it has not been set. The
@@ -441,11 +441,11 @@ boolean filters (int eventType) {
*
* @see #setData
*/
-public Object getData () {
- checkWidget();
- return data;
-}
-
+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.
@@ -470,16 +470,16 @@ public Object getData () {
*
* @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;
-}
-
+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.
@@ -496,19 +496,19 @@ public Object getData (String key) {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-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 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 "";
+}
+
/**
* Returns the receiver's style information.
* <p>
@@ -529,24 +529,24 @@ String getNameText () {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public int getStyle () {
- checkWidget();
- return style;
-}
-
-boolean hooks (int eventType) {
- if (eventTable == null) return false;
- return eventTable.hooks (eventType);
-}
-
-int hotkeyProc (int widget, int data, int info) {
- return OS.Pt_CONTINUE;
-}
-
-void hookEvents () {
- /* Do nothing */
-}
-
+public int getStyle () {
+ checkWidget();
+ return style;
+}
+
+boolean hooks (int eventType) {
+ if (eventTable == null) return false;
+ return eventTable.hooks (eventType);
+}
+
+int hotkeyProc (int widget, int data, int info) {
+ return OS.Pt_CONTINUE;
+}
+
+void hookEvents () {
+ /* Do nothing */
+}
+
/**
* Returns <code>true</code> if the widget has been disposed,
* and <code>false</code> otherwise.
@@ -558,25 +558,25 @@ void hookEvents () {
*
* @return <code>true</code> when the widget is disposed and <code>false</code> otherwise
*/
-public boolean isDisposed () {
- if (handle != 0) return false;
- if ((state & HANDLE) != 0) return true;
- return (state & DISPOSED) != 0;
-}
-
-boolean isValidSubclass () {
- return Display.isValidClass (getClass ());
-}
-
-protected boolean isListening (int eventType) {
- checkWidget();
- return hooks (eventType);
-}
-
-boolean isValidThread () {
- return getDisplay ().isValidThread ();
-}
-
+public boolean isDisposed () {
+ if (handle != 0) return false;
+ if ((state & HANDLE) != 0) return true;
+ return (state & DISPOSED) != 0;
+}
+
+boolean isValidSubclass () {
+ return Display.isValidClass (getClass ());
+}
+
+protected boolean isListening (int eventType) {
+ checkWidget();
+ return hooks (eventType);
+}
+
+boolean isValidThread () {
+ return getDisplay ().isValidThread ();
+}
+
/**
* Notifies all of the receiver's listeners for events
* of the given type that one such event has occurred by
@@ -593,136 +593,136 @@ boolean isValidThread () {
* <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);
- sendEvent (eventType, event);
-}
-
-void postEvent (int eventType) {
- sendEvent (eventType, null, false);
-}
-
-void postEvent (int eventType, Event event) {
- sendEvent (eventType, event, false);
-}
-
-int Ph_EV_BOUNDARY (int widget, int info) {
- return OS.Pt_CONTINUE;
-}
-
-int Ph_EV_BUT_PRESS (int widget, int info) {
- return OS.Pt_CONTINUE;
-}
-
-int Ph_EV_BUT_RELEASE (int widget, int info) {
- return OS.Pt_CONTINUE;
-}
-
-int Ph_EV_DRAG (int widget, int info) {
- return OS.Pt_CONTINUE;
-}
-
-int Ph_EV_KEY (int widget, int info) {
- return OS.Pt_CONTINUE;
-}
-
-int Ph_EV_PTR_MOTION (int widget, int info) {
- return OS.Pt_CONTINUE;
-}
-
-int Pt_CB_ACTIVATE (int widget, int info) {
- return OS.Pt_CONTINUE;
-}
-
-int Pt_CB_ARM (int widget, int info) {
- return OS.Pt_CONTINUE;
-}
-
-int Pt_CB_GOT_FOCUS (int widget, int info) {
- return OS.Pt_CONTINUE;
-}
-
-int Pt_CB_LOST_FOCUS (int widget, int info) {
- return OS.Pt_CONTINUE;
-}
-
-int Pt_CB_MODIFY_VERIFY (int widget, int info) {
- return OS.Pt_CONTINUE;
-}
-
-int Pt_CB_OUTBOUND (int widget, int info) {
- return OS.Pt_CONTINUE;
-}
-
-int Pt_CB_PG_PANEL_SWITCHING (int widget, int info) {
- return OS.Pt_CONTINUE;
-}
-
-int Pt_CB_REALIZED (int widget, int info) {
- return OS.Pt_CONTINUE;
-}
-
-int Pt_CB_RESIZE (int widget, int info) {
- return OS.Pt_CONTINUE;
-}
-
-int Pt_CB_SCROLL_MOVE (int widget, int info) {
- return OS.Pt_CONTINUE;
-}
-
-int Pt_CB_SLIDER_MOVE (int widget, int info) {
- return OS.Pt_CONTINUE;
-}
-
-int Pt_CB_SELECTION (int widget, int info) {
- return OS.Pt_CONTINUE;
-}
-
-int Pt_CB_TEXT_CHANGED (int widget, int info) {
- return OS.Pt_CONTINUE;
-}
-
-int Pt_CB_TIMER_ACTIVATE (int widget, int info) {
- return OS.Pt_CONTINUE;
-}
-
-int Pt_CB_UNREALIZED (int widget, int info) {
- return OS.Pt_CONTINUE;
-}
-
-int Pt_CB_WINDOW (int widget, 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 releaseResources () {
- releaseWidget ();
- releaseHandle ();
-}
-
-void releaseWidget () {
- sendEvent (SWT.Dispose);
- deregister ();
- eventTable = null;
- data = null;
- keys = null;
- values = null;
-}
-
+public void notifyListeners (int eventType, Event event) {
+ checkWidget();
+ if (event == null) error (SWT.ERROR_NULL_ARGUMENT);
+ sendEvent (eventType, event);
+}
+
+void postEvent (int eventType) {
+ sendEvent (eventType, null, false);
+}
+
+void postEvent (int eventType, Event event) {
+ sendEvent (eventType, event, false);
+}
+
+int Ph_EV_BOUNDARY (int widget, int info) {
+ return OS.Pt_CONTINUE;
+}
+
+int Ph_EV_BUT_PRESS (int widget, int info) {
+ return OS.Pt_CONTINUE;
+}
+
+int Ph_EV_BUT_RELEASE (int widget, int info) {
+ return OS.Pt_CONTINUE;
+}
+
+int Ph_EV_DRAG (int widget, int info) {
+ return OS.Pt_CONTINUE;
+}
+
+int Ph_EV_KEY (int widget, int info) {
+ return OS.Pt_CONTINUE;
+}
+
+int Ph_EV_PTR_MOTION (int widget, int info) {
+ return OS.Pt_CONTINUE;
+}
+
+int Pt_CB_ACTIVATE (int widget, int info) {
+ return OS.Pt_CONTINUE;
+}
+
+int Pt_CB_ARM (int widget, int info) {
+ return OS.Pt_CONTINUE;
+}
+
+int Pt_CB_GOT_FOCUS (int widget, int info) {
+ return OS.Pt_CONTINUE;
+}
+
+int Pt_CB_LOST_FOCUS (int widget, int info) {
+ return OS.Pt_CONTINUE;
+}
+
+int Pt_CB_MODIFY_VERIFY (int widget, int info) {
+ return OS.Pt_CONTINUE;
+}
+
+int Pt_CB_OUTBOUND (int widget, int info) {
+ return OS.Pt_CONTINUE;
+}
+
+int Pt_CB_PG_PANEL_SWITCHING (int widget, int info) {
+ return OS.Pt_CONTINUE;
+}
+
+int Pt_CB_REALIZED (int widget, int info) {
+ return OS.Pt_CONTINUE;
+}
+
+int Pt_CB_RESIZE (int widget, int info) {
+ return OS.Pt_CONTINUE;
+}
+
+int Pt_CB_SCROLL_MOVE (int widget, int info) {
+ return OS.Pt_CONTINUE;
+}
+
+int Pt_CB_SLIDER_MOVE (int widget, int info) {
+ return OS.Pt_CONTINUE;
+}
+
+int Pt_CB_SELECTION (int widget, int info) {
+ return OS.Pt_CONTINUE;
+}
+
+int Pt_CB_TEXT_CHANGED (int widget, int info) {
+ return OS.Pt_CONTINUE;
+}
+
+int Pt_CB_TIMER_ACTIVATE (int widget, int info) {
+ return OS.Pt_CONTINUE;
+}
+
+int Pt_CB_UNREALIZED (int widget, int info) {
+ return OS.Pt_CONTINUE;
+}
+
+int Pt_CB_WINDOW (int widget, 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 releaseResources () {
+ releaseWidget ();
+ releaseHandle ();
+}
+
+void releaseWidget () {
+ sendEvent (SWT.Dispose);
+ deregister ();
+ 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.
@@ -741,44 +741,44 @@ void releaseWidget () {
* @see Listener
* @see #addListener
*/
-public void removeListener (int eventType, Listener handler) {
- checkWidget();
- if (handler == null) error (SWT.ERROR_NULL_ARGUMENT);
- if (eventTable == null) return;
- eventTable.unhook (eventType, handler);
-}
-
-/**
- * Removes the listener from the collection of listeners who will
- * be 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, SWTEventListener handler) {
- checkWidget();
- if (handler == null) error (SWT.ERROR_NULL_ARGUMENT);
- if (eventTable == null) return;
- eventTable.unhook (eventType, handler);
-}
-
+public void removeListener (int eventType, Listener handler) {
+ checkWidget();
+ if (handler == null) error (SWT.ERROR_NULL_ARGUMENT);
+ if (eventTable == null) return;
+ eventTable.unhook (eventType, handler);
+}
+
+/**
+ * Removes the listener from the collection of listeners who will
+ * be 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, SWTEventListener handler) {
+ checkWidget();
+ if (handler == null) error (SWT.ERROR_NULL_ARGUMENT);
+ if (eventTable == null) return;
+ eventTable.unhook (eventType, handler);
+}
+
/**
* Removes the listener from the collection of listeners who will
* be notifed when the widget is disposed.
@@ -796,80 +796,80 @@ protected void removeListener (int eventType, SWTEventListener handler) {
* @see DisposeListener
* @see #addDisposeListener
*/
-public void removeDisposeListener (DisposeListener listener) {
- checkWidget();
- if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
- if (eventTable == null) return;
- eventTable.unhook (SWT.Dispose, listener);
-}
-
-void replaceMnemonic (int mnemonic, boolean normal, boolean alt) {
- Display display = getDisplay ();
- int [] args = {OS.Pt_ARG_ACCEL_KEY, 0, 0};
- OS.PtGetResources (handle, args.length / 3, args);
- if (args [1] != 0) {
- int length = OS.strlen (args [1]);
- if (length > 0) {
- byte [] buffer = new byte [length];
- OS.memmove (buffer, args [1], length);
- char [] accelText = Converter.mbcsToWcs (null, buffer);
- if (accelText.length > 0) {
- char key = Character.toLowerCase (accelText [0]);
- if (normal) {
- //TEMPORARY CODE
-// OS.PtRemoveHotkeyHandler (handle, key, 0, (short)0, SWT.Activate, display.windowProc);
- }
- if (alt) {
- OS.PtRemoveHotkeyHandler (handle, key, OS.Pk_KM_Alt, (short)0, handle, display.hotkeyProc);
- }
- }
- }
- }
- if (mnemonic == 0) return;
- char key = Character.toLowerCase ((char)mnemonic);
- if (normal) {
- //TEMPORARY CODE
-// OS.PtAddHotkeyHandler (handle, key, 0, (short)0, SWT.Activate, display.windowProc);
- }
- if (alt) {
- OS.PtAddHotkeyHandler (handle, key, OS.Pk_KM_Alt, (short)0, handle, display.hotkeyProc);
- }
-}
-
-void sendEvent (Event event) {
- Display display = event.display;
- if (!display.filterEvent (event)) {
- if (eventTable != null) eventTable.sendEvent (event);
- }
-}
-
-void sendEvent (int eventType) {
- sendEvent (eventType, null, true);
-}
-
-void sendEvent (int eventType, Event event) {
- sendEvent (eventType, event, true);
-}
-
-void sendEvent (int eventType, Event event, boolean send) {
- Display display = getDisplay ();
- if (eventTable == null && !display.filters (eventType)) {
- return;
- }
- if (event == null) event = new Event ();
- event.type = eventType;
- event.display = display;
- event.widget = this;
- if (event.time == 0) {
- event.time = display.getLastEventTime ();
- }
- if (send) {
- sendEvent (event);
- } else {
- display.postEvent (event);
- }
-}
-
+public void removeDisposeListener (DisposeListener listener) {
+ checkWidget();
+ if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+ if (eventTable == null) return;
+ eventTable.unhook (SWT.Dispose, listener);
+}
+
+void replaceMnemonic (int mnemonic, boolean normal, boolean alt) {
+ Display display = getDisplay ();
+ int [] args = {OS.Pt_ARG_ACCEL_KEY, 0, 0};
+ OS.PtGetResources (handle, args.length / 3, args);
+ if (args [1] != 0) {
+ int length = OS.strlen (args [1]);
+ if (length > 0) {
+ byte [] buffer = new byte [length];
+ OS.memmove (buffer, args [1], length);
+ char [] accelText = Converter.mbcsToWcs (null, buffer);
+ if (accelText.length > 0) {
+ char key = Character.toLowerCase (accelText [0]);
+ if (normal) {
+ //TEMPORARY CODE
+// OS.PtRemoveHotkeyHandler (handle, key, 0, (short)0, SWT.Activate, display.windowProc);
+ }
+ if (alt) {
+ OS.PtRemoveHotkeyHandler (handle, key, OS.Pk_KM_Alt, (short)0, handle, display.hotkeyProc);
+ }
+ }
+ }
+ }
+ if (mnemonic == 0) return;
+ char key = Character.toLowerCase ((char)mnemonic);
+ if (normal) {
+ //TEMPORARY CODE
+// OS.PtAddHotkeyHandler (handle, key, 0, (short)0, SWT.Activate, display.windowProc);
+ }
+ if (alt) {
+ OS.PtAddHotkeyHandler (handle, key, OS.Pk_KM_Alt, (short)0, handle, display.hotkeyProc);
+ }
+}
+
+void sendEvent (Event event) {
+ Display display = event.display;
+ if (!display.filterEvent (event)) {
+ if (eventTable != null) eventTable.sendEvent (event);
+ }
+}
+
+void sendEvent (int eventType) {
+ sendEvent (eventType, null, true);
+}
+
+void sendEvent (int eventType, Event event) {
+ sendEvent (eventType, event, true);
+}
+
+void sendEvent (int eventType, Event event, boolean send) {
+ Display display = getDisplay ();
+ if (eventTable == null && !display.filters (eventType)) {
+ return;
+ }
+ if (event == null) event = new Event ();
+ event.type = eventType;
+ event.display = display;
+ event.widget = this;
+ if (event.time == 0) {
+ event.time = display.getLastEventTime ();
+ }
+ if (send) {
+ sendEvent (event);
+ } else {
+ display.postEvent (event);
+ }
+}
+
/**
* Sets the application defined widget data associated
* with the receiver to be the argument. The <em>widget
@@ -890,11 +890,11 @@ void sendEvent (int eventType, Event event, boolean send) {
* <li>ERROR_THREAD_INVALID_ACCESS - when called from the wrong thread</li>
* </ul>
*/
-public void setData (Object data) {
- checkWidget();
- this.data = data;
-}
-
+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.
@@ -919,185 +919,185 @@ public void setData (Object data) {
*
* @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;
-}
-
-void setInputState(Event event, int key_mods, int button_state) {
- 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;
-}
-
-void setKeyState(Event event, PhKeyEvent_t ke) {
- /*
- * Fetuare in Photon. The key_sym value is not valid when Ctrl
- * or Alt is pressed. The fix is to detect this case and try to
- * use the key_cap value.
- */
- int key = 0;
- if ((ke.key_flags & OS.Pk_KF_Sym_Valid) != 0) {
- key = ke.key_sym;
- } else if ((ke.key_flags & OS.Pk_KF_Cap_Valid) != 0) {
- if ((ke.key_flags & (OS.Pk_KF_Key_Down | OS.Pk_KF_Key_Repeat)) != 0) {
- key = ke.key_cap;
- if ((ke.key_mods & OS.Pk_KM_Ctrl) != 0) {
- if ('a' <= key && key <= 'z') key -= 'a' - 'A';
- if (64 <= key && key <= 95) key -= 64;
- }
- }
- }
- event.keyCode = Display.translateKey (key);
- switch (key) {
- case OS.Pk_BackSpace: event.character = '\b'; break;
- case OS.Pk_Linefeed: event.character = '\n'; break;
- case OS.Pk_Return: event.character = '\r'; break;
- case OS.Pk_Delete: event.character = 0x7F; break;
- case OS.Pk_Cancel:
- case OS.Pk_Escape: event.character = 0x1B; break;
- case OS.Pk_KP_Tab:
- case OS.Pk_Tab: event.character = '\t'; break;
-// case OS.Pk_Clear: event.character = 0xB; break;
-// case OS.Pk_Pause: event.character = 0x13; break;
-// case OS.Pk_Scroll_Lock: event.character = 0x14; break;
- default:
- if (event.keyCode == 0) event.character = (char) key;
- }
- setInputState(event, ke.key_mods, ke.button_state);
- switch (event.type) {
- case SWT.KeyDown:
- case SWT.Traverse:
- 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;
- break;
- case 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;
- break;
- }
-}
-
-void setMouseState(Event event, PhPointerEvent_t pe, PhEvent_t ev) {
- int buttons = pe.buttons;
- event.x = pe.pos_x + ev.translation_x;
- event.y = pe.pos_y + ev.translation_y;
- if (ev.type == OS.Ph_EV_BUT_PRESS || ev.type == OS.Ph_EV_BUT_RELEASE) {
- 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;
- }
- }
- setInputState(event, pe.key_mods, pe.button_state);
- switch (ev.type) {
- case OS.Ph_EV_BUT_PRESS:
- 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;
- break;
- case OS.Ph_EV_BUT_RELEASE:
- case OS.Ph_EV_DRAG:
- 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;
- break;
- }
-}
-
-int topHandle () {
- return handle;
-}
-
+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;
+}
+
+void setInputState(Event event, int key_mods, int button_state) {
+ 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;
+}
+
+void setKeyState(Event event, PhKeyEvent_t ke) {
+ /*
+ * Fetuare in Photon. The key_sym value is not valid when Ctrl
+ * or Alt is pressed. The fix is to detect this case and try to
+ * use the key_cap value.
+ */
+ int key = 0;
+ if ((ke.key_flags & OS.Pk_KF_Sym_Valid) != 0) {
+ key = ke.key_sym;
+ } else if ((ke.key_flags & OS.Pk_KF_Cap_Valid) != 0) {
+ if ((ke.key_flags & (OS.Pk_KF_Key_Down | OS.Pk_KF_Key_Repeat)) != 0) {
+ key = ke.key_cap;
+ if ((ke.key_mods & OS.Pk_KM_Ctrl) != 0) {
+ if ('a' <= key && key <= 'z') key -= 'a' - 'A';
+ if (64 <= key && key <= 95) key -= 64;
+ }
+ }
+ }
+ event.keyCode = Display.translateKey (key);
+ switch (key) {
+ case OS.Pk_BackSpace: event.character = '\b'; break;
+ case OS.Pk_Linefeed: event.character = '\n'; break;
+ case OS.Pk_Return: event.character = '\r'; break;
+ case OS.Pk_Delete: event.character = 0x7F; break;
+ case OS.Pk_Cancel:
+ case OS.Pk_Escape: event.character = 0x1B; break;
+ case OS.Pk_KP_Tab:
+ case OS.Pk_Tab: event.character = '\t'; break;
+// case OS.Pk_Clear: event.character = 0xB; break;
+// case OS.Pk_Pause: event.character = 0x13; break;
+// case OS.Pk_Scroll_Lock: event.character = 0x14; break;
+ default:
+ if (event.keyCode == 0) event.character = (char) key;
+ }
+ setInputState(event, ke.key_mods, ke.button_state);
+ switch (event.type) {
+ case SWT.KeyDown:
+ case SWT.Traverse:
+ 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;
+ break;
+ case 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;
+ break;
+ }
+}
+
+void setMouseState(Event event, PhPointerEvent_t pe, PhEvent_t ev) {
+ int buttons = pe.buttons;
+ event.x = pe.pos_x + ev.translation_x;
+ event.y = pe.pos_y + ev.translation_y;
+ if (ev.type == OS.Ph_EV_BUT_PRESS || ev.type == OS.Ph_EV_BUT_RELEASE) {
+ 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;
+ }
+ }
+ setInputState(event, pe.key_mods, pe.button_state);
+ switch (ev.type) {
+ case OS.Ph_EV_BUT_PRESS:
+ 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;
+ break;
+ case OS.Ph_EV_BUT_RELEASE:
+ case OS.Ph_EV_DRAG:
+ 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;
+ break;
+ }
+}
+
+int topHandle () {
+ return handle;
+}
+
/**
* Returns a string containing a concise, human-readable
* description of the receiver.
*
* @return a string representation of the receiver
*/
-public String toString () {
- String string = "*Disposed*";
- if (!isDisposed ()) {
- string = "*Wrong Thread*";
- if (isValidThread ()) string = getNameText ();
- }
- return getName () + " {" + string + "}";
-}
-
-int windowProc (int handle, int data, int info) {
- switch (data) {
- case OS.Ph_EV_BOUNDARY: return Ph_EV_BOUNDARY (handle, info);
- case OS.Ph_EV_BUT_PRESS: return Ph_EV_BUT_PRESS (handle, info);
- case OS.Ph_EV_BUT_RELEASE: return Ph_EV_BUT_RELEASE (handle, info);
- case OS.Ph_EV_DRAG: return Ph_EV_DRAG (handle, info);
- case OS.Ph_EV_KEY: return Ph_EV_KEY (handle, info);
- case OS.Ph_EV_PTR_MOTION: return Ph_EV_PTR_MOTION (handle, info);
- case OS.Pt_CB_ACTIVATE: return Pt_CB_ACTIVATE (handle, info);
- case OS.Pt_CB_ARM: return Pt_CB_ARM (handle, info);
- case OS.Pt_CB_GOT_FOCUS: return Pt_CB_GOT_FOCUS (handle, info);
- case OS.Pt_CB_LOST_FOCUS: return Pt_CB_LOST_FOCUS (handle, info);
- case OS.Pt_CB_MODIFY_VERIFY: return Pt_CB_MODIFY_VERIFY (handle, info);
- case OS.Pt_CB_OUTBOUND: return Pt_CB_OUTBOUND (handle, info);
- case OS.Pt_CB_PG_PANEL_SWITCHING: return Pt_CB_PG_PANEL_SWITCHING (handle, info);
- case OS.Pt_CB_REALIZED: return Pt_CB_REALIZED (handle, info);
- case OS.Pt_CB_RESIZE: return Pt_CB_RESIZE (handle, info);
- case OS.Pt_CB_SCROLL_MOVE: return Pt_CB_SCROLL_MOVE (handle, info);
- case OS.Pt_CB_SLIDER_MOVE: return Pt_CB_SLIDER_MOVE (handle, info);
- case OS.Pt_CB_SELECTION: return Pt_CB_SELECTION (handle, info);
- case OS.Pt_CB_TEXT_CHANGED: return Pt_CB_TEXT_CHANGED (handle, info);
- case OS.Pt_CB_TIMER_ACTIVATE: return Pt_CB_TIMER_ACTIVATE (handle, info);
- case OS.Pt_CB_UNREALIZED: return Pt_CB_UNREALIZED (handle, info);
- case OS.Pt_CB_WINDOW: return Pt_CB_WINDOW (handle, info);
- }
- return OS.Pt_CONTINUE;
-}
-
-}
+public String toString () {
+ String string = "*Disposed*";
+ if (!isDisposed ()) {
+ string = "*Wrong Thread*";
+ if (isValidThread ()) string = getNameText ();
+ }
+ return getName () + " {" + string + "}";
+}
+
+int windowProc (int handle, int data, int info) {
+ switch (data) {
+ case OS.Ph_EV_BOUNDARY: return Ph_EV_BOUNDARY (handle, info);
+ case OS.Ph_EV_BUT_PRESS: return Ph_EV_BUT_PRESS (handle, info);
+ case OS.Ph_EV_BUT_RELEASE: return Ph_EV_BUT_RELEASE (handle, info);
+ case OS.Ph_EV_DRAG: return Ph_EV_DRAG (handle, info);
+ case OS.Ph_EV_KEY: return Ph_EV_KEY (handle, info);
+ case OS.Ph_EV_PTR_MOTION: return Ph_EV_PTR_MOTION (handle, info);
+ case OS.Pt_CB_ACTIVATE: return Pt_CB_ACTIVATE (handle, info);
+ case OS.Pt_CB_ARM: return Pt_CB_ARM (handle, info);
+ case OS.Pt_CB_GOT_FOCUS: return Pt_CB_GOT_FOCUS (handle, info);
+ case OS.Pt_CB_LOST_FOCUS: return Pt_CB_LOST_FOCUS (handle, info);
+ case OS.Pt_CB_MODIFY_VERIFY: return Pt_CB_MODIFY_VERIFY (handle, info);
+ case OS.Pt_CB_OUTBOUND: return Pt_CB_OUTBOUND (handle, info);
+ case OS.Pt_CB_PG_PANEL_SWITCHING: return Pt_CB_PG_PANEL_SWITCHING (handle, info);
+ case OS.Pt_CB_REALIZED: return Pt_CB_REALIZED (handle, info);
+ case OS.Pt_CB_RESIZE: return Pt_CB_RESIZE (handle, info);
+ case OS.Pt_CB_SCROLL_MOVE: return Pt_CB_SCROLL_MOVE (handle, info);
+ case OS.Pt_CB_SLIDER_MOVE: return Pt_CB_SLIDER_MOVE (handle, info);
+ case OS.Pt_CB_SELECTION: return Pt_CB_SELECTION (handle, info);
+ case OS.Pt_CB_TEXT_CHANGED: return Pt_CB_TEXT_CHANGED (handle, info);
+ case OS.Pt_CB_TIMER_ACTIVATE: return Pt_CB_TIMER_ACTIVATE (handle, info);
+ case OS.Pt_CB_UNREALIZED: return Pt_CB_UNREALIZED (handle, info);
+ case OS.Pt_CB_WINDOW: return Pt_CB_WINDOW (handle, info);
+ }
+ return OS.Pt_CONTINUE;
+}
+
+}
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
index 7fdae475d0..a370d8cbdc 100755
--- 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
@@ -1,109 +1,109 @@
-package org.eclipse.swt.widgets;
-
-/*
+package org.eclipse.swt.widgets;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-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 [] 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.PtSetResource (handle, OS.Pt_ARG_USER_DATA, ArgPtr, 4);
- 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 [0] - 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.PtSetResource (handle, OS.Pt_ARG_USER_DATA, ArgPtr, 4);
- }
- 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) {
- int j = 0;
- while (j < index) {
- if (result [j] == widget) break;
- j++;
- }
- if (j == index) result [index++] = (Shell) widget;
- }
- }
- if (index == length) return result;
- Shell [] newResult = new Shell [index];
- System.arraycopy (result, 0, newResult, 0, index);
- return newResult;
-}
-public static synchronized int size () {
- int size = 0;
- for (int i=0; i<WidgetTable.length; i++) {
- if (WidgetTable [i] != null) size++;
- }
- return size;
-}
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+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 [] 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.PtSetResource (handle, OS.Pt_ARG_USER_DATA, ArgPtr, 4);
+ 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 [0] - 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.PtSetResource (handle, OS.Pt_ARG_USER_DATA, ArgPtr, 4);
+ }
+ 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) {
+ int j = 0;
+ while (j < index) {
+ if (result [j] == widget) break;
+ j++;
+ }
+ if (j == index) result [index++] = (Shell) widget;
+ }
+ }
+ if (index == length) return result;
+ Shell [] newResult = new Shell [index];
+ System.arraycopy (result, 0, newResult, 0, index);
+ return newResult;
+}
+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/org/eclipse/swt/graphics/Color.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/Color.java
index 738893f329..5b3b428410 100755
--- 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
@@ -1,330 +1,330 @@
-package org.eclipse.swt.graphics;
-
-/*
+package org.eclipse.swt.graphics;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-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
- * @see Device#getSystemColor
- */
-
-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_NULL_ARGUMENT - if device is null and there is no current device</li>
- * <li>ERROR_INVALID_ARGUMENT - if the red, green or blue argument is not between 0 and 255</li>
- * </ul>
- *
- * @see #dispose
- */
-public Color (Device device, int red, int green, int blue) {
- 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_NULL_ARGUMENT - if device is null and there is no current device</li>
- * <li>ERROR_NULL_ARGUMENT - if the rgb argument is null</li>
- * <li>ERROR_INVALID_ARGUMENT - if the red, green or blue components of the argument are not between 0 and 255</li>
- * </ul>
- *
- * @see #dispose
- */
-public Color (Device device, RGB rgb) {
- 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 (device.isDisposed()) 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
- *
- * @exception SWTException <ul>
- * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
- * </ul>
- */
-public int getBlue () {
- if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- return (handle & 0xFF0000) >> 16;
-}
-
-/**
- * Returns the amount of green in the color, from 0 to 255.
- *
- * @return the green component of the color
- *
- * @exception SWTException <ul>
- * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
- * </ul>
- */
-public int getGreen () {
- if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- return (handle & 0xFF00) >> 8 ;
-}
-
-/**
- * Returns the amount of red in the color, from 0 to 255.
- *
- * @return the red component of the color
- *
- * @exception SWTException <ul>
- * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
- * </ul>
- */
-public int getRed () {
- if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- return handle & 0xFF;
-}
-
-/**
- * Returns an <code>RGB</code> representing the receiver.
- *
- * @exception SWTException <ul>
- * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
- * </ul>
- */
-public RGB getRGB () {
- if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- return new RGB(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 */
- 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 () {
- if (isDisposed()) return "Color {*DISPOSED*}";
- 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;
-}
-
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+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
+ * @see Device#getSystemColor
+ */
+
+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_NULL_ARGUMENT - if device is null and there is no current device</li>
+ * <li>ERROR_INVALID_ARGUMENT - if the red, green or blue argument is not between 0 and 255</li>
+ * </ul>
+ *
+ * @see #dispose
+ */
+public Color (Device device, int red, int green, int blue) {
+ 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_NULL_ARGUMENT - if device is null and there is no current device</li>
+ * <li>ERROR_NULL_ARGUMENT - if the rgb argument is null</li>
+ * <li>ERROR_INVALID_ARGUMENT - if the red, green or blue components of the argument are not between 0 and 255</li>
+ * </ul>
+ *
+ * @see #dispose
+ */
+public Color (Device device, RGB rgb) {
+ 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 (device.isDisposed()) 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
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ */
+public int getBlue () {
+ if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ return (handle & 0xFF0000) >> 16;
+}
+
+/**
+ * Returns the amount of green in the color, from 0 to 255.
+ *
+ * @return the green component of the color
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ */
+public int getGreen () {
+ if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ return (handle & 0xFF00) >> 8 ;
+}
+
+/**
+ * Returns the amount of red in the color, from 0 to 255.
+ *
+ * @return the red component of the color
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ */
+public int getRed () {
+ if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ return handle & 0xFF;
+}
+
+/**
+ * Returns an <code>RGB</code> representing the receiver.
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ */
+public RGB getRGB () {
+ if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ return new RGB(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 */
+ 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 () {
+ if (isDisposed()) return "Color {*DISPOSED*}";
+ 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
index 945ddbc1aa..00f4435954 100755
--- 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
@@ -1,404 +1,404 @@
-package org.eclipse.swt.graphics;
-
-/*
+package org.eclipse.swt.graphics;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-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>
- * <p>
- * Note: Only one of the above styles may be specified.
- * </p>
- */
-
-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[] HAND_SOURCE = {
- (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[] HAND_MASK = {
- (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_NULL_ARGUMENT - if device is null and there is no current device</li>
- * <li>ERROR_INVALID_ARGUMENT - when an unknown style is specified</li>
- * </ul>
- * @exception SWTError <ul>
- * <li>ERROR_NO_HANDLES - if a handle could not be obtained for cursor creation</li>
- * </ul>
- *
- * @see SWT#CURSOR_ARROW
- * @see SWT#CURSOR_WAIT
- * @see SWT#CURSOR_CROSS
- * @see SWT#CURSOR_APPSTARTING
- * @see SWT#CURSOR_HELP
- * @see SWT#CURSOR_SIZEALL
- * @see SWT#CURSOR_SIZENESW
- * @see SWT#CURSOR_SIZENS
- * @see SWT#CURSOR_SIZENWSE
- * @see SWT#CURSOR_SIZEWE
- * @see SWT#CURSOR_SIZEN
- * @see SWT#CURSOR_SIZES
- * @see SWT#CURSOR_SIZEE
- * @see SWT#CURSOR_SIZEW
- * @see SWT#CURSOR_SIZENE
- * @see SWT#CURSOR_SIZESE
- * @see SWT#CURSOR_SIZESW
- * @see SWT#CURSOR_SIZENW
- * @see SWT#CURSOR_UPARROW
- * @see SWT#CURSOR_IBEAM
- * @see SWT#CURSOR_NO
- * @see SWT#CURSOR_HAND
- */
-public Cursor(Device device, int style) {
- 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);
- if (OS.IsWinCE) SWT.error(SWT.ERROR_NOT_IMPLEMENTED);
- handle = OS.CreateCursor(hInst, 5, 0, 32, 32, HAND_SOURCE, HAND_MASK);
-
- }
- }
- 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 - if device is null and there is no current device</li>
- * <li>ERROR_NULL_ARGUMENT - if the source is null</li>
- * <li>ERROR_NULL_ARGUMENT - if the mask is null and the source does not have a mask</li>
- * <li>ERROR_INVALID_ARGUMENT - if the source and the mask are not the same
- * size, or 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 a handle could not be obtained for cursor creation</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);
- if (OS.IsWinCE) SWT.error (SWT.ERROR_NOT_IMPLEMENTED);
- 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;
- if (device.isDisposed()) return;
-
- /*
- * It is an error in Windows to destroy the current
- * cursor. Check that the cursor that is about to
- * be destroyed is the current cursor. If so, set
- * the current cursor to be IDC_ARROW. Note that
- * Windows shares predefined cursors so the call to
- * LoadCursor() does not leak.
- */
- // TEMPORARY CODE
-// if (OS.GetCursor() == handle) {
-// OS.SetCursor(OS.LoadCursor(0, OS.IDC_ARROW));
-// }
-
- /*
- * 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.
- */
- if (!OS.IsWinCE) 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;
-}
-
-/**
- * Returns a string containing a concise, human-readable
- * description of the receiver.
- *
- * @return a string representation of the receiver
- */
-public String toString () {
- if (isDisposed()) return "Cursor {*DISPOSED*}";
- return "Cursor {" + handle + "}";
-}
-
-/**
- * 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;
-}
-
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+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>
+ * <p>
+ * Note: Only one of the above styles may be specified.
+ * </p>
+ */
+
+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[] HAND_SOURCE = {
+ (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[] HAND_MASK = {
+ (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_NULL_ARGUMENT - if device is null and there is no current device</li>
+ * <li>ERROR_INVALID_ARGUMENT - when an unknown style is specified</li>
+ * </ul>
+ * @exception SWTError <ul>
+ * <li>ERROR_NO_HANDLES - if a handle could not be obtained for cursor creation</li>
+ * </ul>
+ *
+ * @see SWT#CURSOR_ARROW
+ * @see SWT#CURSOR_WAIT
+ * @see SWT#CURSOR_CROSS
+ * @see SWT#CURSOR_APPSTARTING
+ * @see SWT#CURSOR_HELP
+ * @see SWT#CURSOR_SIZEALL
+ * @see SWT#CURSOR_SIZENESW
+ * @see SWT#CURSOR_SIZENS
+ * @see SWT#CURSOR_SIZENWSE
+ * @see SWT#CURSOR_SIZEWE
+ * @see SWT#CURSOR_SIZEN
+ * @see SWT#CURSOR_SIZES
+ * @see SWT#CURSOR_SIZEE
+ * @see SWT#CURSOR_SIZEW
+ * @see SWT#CURSOR_SIZENE
+ * @see SWT#CURSOR_SIZESE
+ * @see SWT#CURSOR_SIZESW
+ * @see SWT#CURSOR_SIZENW
+ * @see SWT#CURSOR_UPARROW
+ * @see SWT#CURSOR_IBEAM
+ * @see SWT#CURSOR_NO
+ * @see SWT#CURSOR_HAND
+ */
+public Cursor(Device device, int style) {
+ 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);
+ if (OS.IsWinCE) SWT.error(SWT.ERROR_NOT_IMPLEMENTED);
+ handle = OS.CreateCursor(hInst, 5, 0, 32, 32, HAND_SOURCE, HAND_MASK);
+
+ }
+ }
+ 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 - if device is null and there is no current device</li>
+ * <li>ERROR_NULL_ARGUMENT - if the source is null</li>
+ * <li>ERROR_NULL_ARGUMENT - if the mask is null and the source does not have a mask</li>
+ * <li>ERROR_INVALID_ARGUMENT - if the source and the mask are not the same
+ * size, or 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 a handle could not be obtained for cursor creation</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);
+ if (OS.IsWinCE) SWT.error (SWT.ERROR_NOT_IMPLEMENTED);
+ 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;
+ if (device.isDisposed()) return;
+
+ /*
+ * It is an error in Windows to destroy the current
+ * cursor. Check that the cursor that is about to
+ * be destroyed is the current cursor. If so, set
+ * the current cursor to be IDC_ARROW. Note that
+ * Windows shares predefined cursors so the call to
+ * LoadCursor() does not leak.
+ */
+ // TEMPORARY CODE
+// if (OS.GetCursor() == handle) {
+// OS.SetCursor(OS.LoadCursor(0, OS.IDC_ARROW));
+// }
+
+ /*
+ * 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.
+ */
+ if (!OS.IsWinCE) 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;
+}
+
+/**
+ * Returns a string containing a concise, human-readable
+ * description of the receiver.
+ *
+ * @return a string representation of the receiver
+ */
+public String toString () {
+ if (isDisposed()) return "Cursor {*DISPOSED*}";
+ return "Cursor {" + handle + "}";
+}
+
+/**
+ * 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
index 81607fc0f4..9b3458c6ae 100755
--- 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
@@ -1,714 +1,714 @@
-package org.eclipse.swt.graphics;
-
-/*
+package org.eclipse.swt.graphics;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-import org.eclipse.swt.internal.*;
-import org.eclipse.swt.internal.win32.*;
-import org.eclipse.swt.*;
-
-/**
- * This class is the abstract superclass of all device objects,
- * such as the Display device and the Printer device. Devices
- * can have a graphics context (GC) created for them, and they
- * can be drawn on by sending messages to the associated GC.
- */
-public abstract class Device implements Drawable {
-
- /* Debugging */
- public static boolean DEBUG;
- boolean debug = DEBUG;
- boolean tracking = DEBUG;
- Error [] errors;
- Object [] objects;
-
- /* Palette
- * (Warning: This field is platform dependent)
- */
- public int hPalette = 0;
- int [] colorRefCount;
-
- /* System Font */
- int systemFont;
-
- /* Font Enumeration */
- int nFonts = 256;
- LOGFONT [] logFonts;
-
- boolean disposed;
-
- /*
- * TEMPORARY CODE. When a graphics object is
- * created and the device parameter is null,
- * the current Display is used. This presents
- * a problem because SWT graphics does not
- * reference classes in SWT widgets. The correct
- * fix is to remove this feature. Unfortunately,
- * too many application programs rely on this
- * feature.
- *
- * This code will be removed in the future.
- */
- protected static Device CurrentDevice;
- protected static Runnable DeviceFinder;
- static {
- try {
- Class.forName ("org.eclipse.swt.widgets.Display");
- } catch (Throwable e) {}
- }
-
-/*
-* TEMPORARY CODE.
-*/
-static Device getDevice () {
- if (DeviceFinder != null) DeviceFinder.run();
- Device device = CurrentDevice;
- CurrentDevice = null;
- return device;
-}
-
-/**
- * Constructs a new instance of this class.
- * <p>
- * You must dispose the device when it is no longer required.
- * </p>
- *
- * @param data the DeviceData which describes the receiver
- *
- * @see #create
- * @see #init
- * @see DeviceData
- */
-public Device(DeviceData data) {
- if (data != null) {
- debug = data.debug;
- tracking = data.tracking;
- }
- create (data);
- init ();
- if (tracking) {
- errors = new Error [128];
- objects = new Object [128];
- }
-
- /* Initialize the system font slot */
- systemFont = getSystemFont().handle;
-}
-
-/**
- * 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);
- int pixels = -Compatibility.round(height * OS.GetDeviceCaps(hDC, OS.LOGPIXELSY), 72);
- 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);
-
- return Compatibility.round(pixels * 72, logPixelsY);
-}
-
-/**
- * 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
- */
-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 that match the given arguments. If the
- * <code>faceName</code> is null, all fonts will be returned.
- *
- * @param faceName the name of the font to look for, or null
- * @param scalable 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.
- */
- char [] buffer = new char [] {
- 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,
- };
- TCHAR lpFaceName = new TCHAR (0, new String(buffer), true);
- OS.EnumFontFamilies (hDC, lpFaceName, lpEnumFontFamProc, scalable ? 1 : 0);
- }
- } else {
- /* Use the character encoding for the default locale */
- TCHAR lpFaceName = new TCHAR (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);
-
- bits *= planes;
- if ((rc & OS.RC_PALETTE) == 0 || bits != 8) {
- internal_dispose_GC (hDC, null);
- return;
- }
-
- int numReserved = OS.GetDeviceCaps (hDC, OS.NUMRESERVED);
- int numEntries = OS.GetDeviceCaps (hDC, OS.SIZEPALETTE);
-
- if (OS.IsWinCE) {
- /*
- * Feature on WinCE. For some reason, certain 8 bit WinCE
- * devices return 0 for the number of reserved entries in
- * the system palette. Their system palette correctly contains
- * the usual 20 system colors. The workaround is to assume
- * there are 20 reserved system colors instead of 0. */
- if (numReserved == 0 && numEntries >= 20) numReserved = 20;
- }
-
- /* Create the palette and reference counter */
- colorRefCount = new int [numEntries];
-
- /* 4 bytes header + 4 bytes per entry * numEntries entries */
- byte [] logPalette = new byte [4 + 4 * numEntries];
-
- /* 2 bytes = special header */
- logPalette [0] = 0x00;
- logPalette [1] = 0x03;
-
- /* 2 bytes = number of colors, LSB first */
- logPalette [2] = 0;
- logPalette [3] = 1;
-
- /*
- * Create a palette which contains the system entries
- * as they are located in the system palette. The
- * MSDN article 'Memory Device Contexts' describes
- * where system entries are located. On an 8 bit
- * display with 20 reserved colors, the system colors
- * will be the first 10 entries and the last 10 ones.
- */
- byte[] lppe = new byte [4 * numEntries];
- OS.GetSystemPaletteEntries (hDC, 0, numEntries, lppe);
- /* Copy all entries from the system palette */
- System.arraycopy (lppe, 0, logPalette, 4, 4 * numEntries);
- /* Lock the indices corresponding to the system entries */
- for (int i = 0; i < numReserved / 2; i++) {
- colorRefCount [i] = 1;
- colorRefCount [numEntries - 1 - i] = 1;
- }
- internal_dispose_GC (hDC, null);
- 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 ();
-}
-
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+import org.eclipse.swt.internal.*;
+import org.eclipse.swt.internal.win32.*;
+import org.eclipse.swt.*;
+
+/**
+ * This class is the abstract superclass of all device objects,
+ * such as the Display device and the Printer device. Devices
+ * can have a graphics context (GC) created for them, and they
+ * can be drawn on by sending messages to the associated GC.
+ */
+public abstract class Device implements Drawable {
+
+ /* Debugging */
+ public static boolean DEBUG;
+ boolean debug = DEBUG;
+ boolean tracking = DEBUG;
+ Error [] errors;
+ Object [] objects;
+
+ /* Palette
+ * (Warning: This field is platform dependent)
+ */
+ public int hPalette = 0;
+ int [] colorRefCount;
+
+ /* System Font */
+ int systemFont;
+
+ /* Font Enumeration */
+ int nFonts = 256;
+ LOGFONT [] logFonts;
+
+ boolean disposed;
+
+ /*
+ * TEMPORARY CODE. When a graphics object is
+ * created and the device parameter is null,
+ * the current Display is used. This presents
+ * a problem because SWT graphics does not
+ * reference classes in SWT widgets. The correct
+ * fix is to remove this feature. Unfortunately,
+ * too many application programs rely on this
+ * feature.
+ *
+ * This code will be removed in the future.
+ */
+ protected static Device CurrentDevice;
+ protected static Runnable DeviceFinder;
+ static {
+ try {
+ Class.forName ("org.eclipse.swt.widgets.Display");
+ } catch (Throwable e) {}
+ }
+
+/*
+* TEMPORARY CODE.
+*/
+static Device getDevice () {
+ if (DeviceFinder != null) DeviceFinder.run();
+ Device device = CurrentDevice;
+ CurrentDevice = null;
+ return device;
+}
+
+/**
+ * Constructs a new instance of this class.
+ * <p>
+ * You must dispose the device when it is no longer required.
+ * </p>
+ *
+ * @param data the DeviceData which describes the receiver
+ *
+ * @see #create
+ * @see #init
+ * @see DeviceData
+ */
+public Device(DeviceData data) {
+ if (data != null) {
+ debug = data.debug;
+ tracking = data.tracking;
+ }
+ create (data);
+ init ();
+ if (tracking) {
+ errors = new Error [128];
+ objects = new Object [128];
+ }
+
+ /* Initialize the system font slot */
+ systemFont = getSystemFont().handle;
+}
+
+/**
+ * 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);
+ int pixels = -Compatibility.round(height * OS.GetDeviceCaps(hDC, OS.LOGPIXELSY), 72);
+ 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);
+
+ return Compatibility.round(pixels * 72, logPixelsY);
+}
+
+/**
+ * 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
+ */
+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 that match the given arguments. If the
+ * <code>faceName</code> is null, all fonts will be returned.
+ *
+ * @param faceName the name of the font to look for, or null
+ * @param scalable 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.
+ */
+ char [] buffer = new char [] {
+ 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,
+ };
+ TCHAR lpFaceName = new TCHAR (0, new String(buffer), true);
+ OS.EnumFontFamilies (hDC, lpFaceName, lpEnumFontFamProc, scalable ? 1 : 0);
+ }
+ } else {
+ /* Use the character encoding for the default locale */
+ TCHAR lpFaceName = new TCHAR (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);
+
+ bits *= planes;
+ if ((rc & OS.RC_PALETTE) == 0 || bits != 8) {
+ internal_dispose_GC (hDC, null);
+ return;
+ }
+
+ int numReserved = OS.GetDeviceCaps (hDC, OS.NUMRESERVED);
+ int numEntries = OS.GetDeviceCaps (hDC, OS.SIZEPALETTE);
+
+ if (OS.IsWinCE) {
+ /*
+ * Feature on WinCE. For some reason, certain 8 bit WinCE
+ * devices return 0 for the number of reserved entries in
+ * the system palette. Their system palette correctly contains
+ * the usual 20 system colors. The workaround is to assume
+ * there are 20 reserved system colors instead of 0. */
+ if (numReserved == 0 && numEntries >= 20) numReserved = 20;
+ }
+
+ /* Create the palette and reference counter */
+ colorRefCount = new int [numEntries];
+
+ /* 4 bytes header + 4 bytes per entry * numEntries entries */
+ byte [] logPalette = new byte [4 + 4 * numEntries];
+
+ /* 2 bytes = special header */
+ logPalette [0] = 0x00;
+ logPalette [1] = 0x03;
+
+ /* 2 bytes = number of colors, LSB first */
+ logPalette [2] = 0;
+ logPalette [3] = 1;
+
+ /*
+ * Create a palette which contains the system entries
+ * as they are located in the system palette. The
+ * MSDN article 'Memory Device Contexts' describes
+ * where system entries are located. On an 8 bit
+ * display with 20 reserved colors, the system colors
+ * will be the first 10 entries and the last 10 ones.
+ */
+ byte[] lppe = new byte [4 * numEntries];
+ OS.GetSystemPaletteEntries (hDC, 0, numEntries, lppe);
+ /* Copy all entries from the system palette */
+ System.arraycopy (lppe, 0, logPalette, 4, 4 * numEntries);
+ /* Lock the indices corresponding to the system entries */
+ for (int i = 0; i < numReserved / 2; i++) {
+ colorRefCount [i] = 1;
+ colorRefCount [numEntries - 1 - i] = 1;
+ }
+ internal_dispose_GC (hDC, null);
+ 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 ();
+}
+
}
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
index 06e99bb30c..d36b10ff4a 100755
--- 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
@@ -1,19 +1,19 @@
-package org.eclipse.swt.graphics;
-
-/*
+package org.eclipse.swt.graphics;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-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;
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+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;
}
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
index 3ce6e79c8a..1a3f410bb8 100755
--- 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
@@ -1,256 +1,256 @@
-package org.eclipse.swt.graphics;
-
-/*
+package org.eclipse.swt.graphics;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-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 device is null and there is no current device</li>
- * <li>ERROR_NULL_ARGUMENT - if the fd argument is null</li>
- * </ul>
- * @exception SWTError <ul>
- * <li>ERROR_NO_HANDLES - if a font could not be created from the given font data</li>
- * </ul>
- */
-public Font(Device device, FontData fd) {
- 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 and an array
- * of font data which describes the desired font's
- * appearance.
- * <p>
- * You must dispose the font when it is no longer required.
- * </p>
- *
- * @param device the device to create the font on
- * @param fds the array of FontData that describes the desired font (must not be null)
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if device is null and there is no current device</li>
- * <li>ERROR_NULL_ARGUMENT - if the fds argument is null</li>
- * <li>ERROR_INVALID_ARGUMENT - if the length of fds is zero</li>
- * <li>ERROR_NULL_ARGUMENT - if any fd in the array is null</li>
- * </ul>
- * @exception SWTError <ul>
- * <li>ERROR_NO_HANDLES - if a font could not be created from the given font data</li>
- * </ul>
- *
- * @since 2.1
- */
-public Font(Device device, FontData[] fds) {
- if (device == null) device = Device.getDevice();
- if (device == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
- if (fds == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
- if (fds.length == 0) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
- init(device, fds[0]);
- 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 device is null and there is no current device</li>
- * <li>ERROR_NULL_ARGUMENT - if the name argument is null</li>
- * <li>ERROR_INVALID_ARGUMENT - if the height is negative</li>
- * </ul>
- * @exception SWTError <ul>
- * <li>ERROR_NO_HANDLES - if a font could not be created from the given arguments</li>
- * </ul>
- */
-public Font(Device device, String name, int height, int style) {
- 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;
- if (device.isDisposed()) 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
- *
- * @exception SWTException <ul>
- * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
- * </ul>
- */
-public FontData[] getFontData() {
- if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- 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;
-}
-
-/**
- * Returns a string containing a concise, human-readable
- * description of the receiver.
- *
- * @return a string representation of the receiver
- */
-public String toString () {
- if (isDisposed()) return "Font {*DISPOSED*}";
- return "Font {" + handle + "}";
-}
-
-/**
- * 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;
-}
-
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+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 device is null and there is no current device</li>
+ * <li>ERROR_NULL_ARGUMENT - if the fd argument is null</li>
+ * </ul>
+ * @exception SWTError <ul>
+ * <li>ERROR_NO_HANDLES - if a font could not be created from the given font data</li>
+ * </ul>
+ */
+public Font(Device device, FontData fd) {
+ 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 and an array
+ * of font data which describes the desired font's
+ * appearance.
+ * <p>
+ * You must dispose the font when it is no longer required.
+ * </p>
+ *
+ * @param device the device to create the font on
+ * @param fds the array of FontData that describes the desired font (must not be null)
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if device is null and there is no current device</li>
+ * <li>ERROR_NULL_ARGUMENT - if the fds argument is null</li>
+ * <li>ERROR_INVALID_ARGUMENT - if the length of fds is zero</li>
+ * <li>ERROR_NULL_ARGUMENT - if any fd in the array is null</li>
+ * </ul>
+ * @exception SWTError <ul>
+ * <li>ERROR_NO_HANDLES - if a font could not be created from the given font data</li>
+ * </ul>
+ *
+ * @since 2.1
+ */
+public Font(Device device, FontData[] fds) {
+ if (device == null) device = Device.getDevice();
+ if (device == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ if (fds == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ if (fds.length == 0) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+ init(device, fds[0]);
+ 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 device is null and there is no current device</li>
+ * <li>ERROR_NULL_ARGUMENT - if the name argument is null</li>
+ * <li>ERROR_INVALID_ARGUMENT - if the height is negative</li>
+ * </ul>
+ * @exception SWTError <ul>
+ * <li>ERROR_NO_HANDLES - if a font could not be created from the given arguments</li>
+ * </ul>
+ */
+public Font(Device device, String name, int height, int style) {
+ 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;
+ if (device.isDisposed()) 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
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ */
+public FontData[] getFontData() {
+ if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ 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;
+}
+
+/**
+ * Returns a string containing a concise, human-readable
+ * description of the receiver.
+ *
+ * @return a string representation of the receiver
+ */
+public String toString () {
+ if (isDisposed()) return "Font {*DISPOSED*}";
+ return "Font {" + handle + "}";
+}
+
+/**
+ * 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
index 1a37985314..12620ee2dc 100755
--- 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
@@ -1,693 +1,693 @@
-package org.eclipse.swt.graphics;
-
-/*
+package org.eclipse.swt.graphics;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-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;
-
- /**
- * The locales of the font
- * (Warning: These fields are platform dependent)
- */
- String lang, country, variant;
-
-/**
- * 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);
- try {
- if (Integer.parseInt(version1) != 1) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
- } catch (NumberFormatException e) {
- SWT.error(SWT.ERROR_INVALID_ARGUMENT);
- }
-
- start = end + 1;
- end = string.indexOf('|', start);
- if (end == -1) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
- String name = string.substring(start, end);
-
- start = end + 1;
- end = string.indexOf('|', start);
- if (end == -1) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
- 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 = lfFaceName[0];
- newData.lfFaceName1 = lfFaceName[1];
- newData.lfFaceName2 = lfFaceName[2];
- newData.lfFaceName3 = lfFaceName[3];
- newData.lfFaceName4 = lfFaceName[4];
- newData.lfFaceName5 = lfFaceName[5];
- newData.lfFaceName6 = lfFaceName[6];
- newData.lfFaceName7 = lfFaceName[7];
- newData.lfFaceName8 = lfFaceName[8];
- newData.lfFaceName9 = lfFaceName[9];
- newData.lfFaceName10 = lfFaceName[10];
- newData.lfFaceName11 = lfFaceName[11];
- newData.lfFaceName12 = lfFaceName[12];
- newData.lfFaceName13 = lfFaceName[13];
- newData.lfFaceName14 = lfFaceName[14];
- newData.lfFaceName15 = lfFaceName[15];
- newData.lfFaceName16 = lfFaceName[16];
- newData.lfFaceName17 = lfFaceName[17];
- newData.lfFaceName18 = lfFaceName[18];
- newData.lfFaceName19 = lfFaceName[19];
- newData.lfFaceName20 = lfFaceName[20];
- newData.lfFaceName21 = lfFaceName[21];
- newData.lfFaceName22 = lfFaceName[22];
- newData.lfFaceName23 = lfFaceName[23];
- newData.lfFaceName24 = lfFaceName[24];
- newData.lfFaceName25 = lfFaceName[25];
- newData.lfFaceName26 = lfFaceName[26];
- newData.lfFaceName27 = lfFaceName[27];
- newData.lfFaceName28 = lfFaceName[28];
- newData.lfFaceName29 = lfFaceName[29];
- newData.lfFaceName30 = lfFaceName[30];
- newData.lfFaceName31 = 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_NULL_ARGUMENT - when the font name is null</li>
- * <li>ERROR_INVALID_ARGUMENT - if the height is negative</li>
- * </ul>
- */
-public FontData(String name, int height, int style) {
- if (name == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
- 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;
- FontData fd = (FontData)object;
- LOGFONT lf = fd.data;
- return data.lfCharSet == lf.lfCharSet &&
- /*
- * This code is intentionally commented. When creating
- * a FontData, lfHeight is not necessarily set. Instead
- * we check the height field which is always set.
- */
-// data.lfHeight == lf.lfHeight &&
- height == fd.height &&
- 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;
-}
-
-int EnumLocalesProc(int lpLocaleString) {
-
- /* Get the locale ID */
- int length = 8;
- TCHAR buffer = new TCHAR(0, length);
- int byteCount = length * TCHAR.sizeof;
- OS.MoveMemory(buffer, lpLocaleString, byteCount);
- int lcid = Integer.parseInt(buffer.toString(0, buffer.strlen ()), 16);
-
- /* Check the language */
- int size = OS.GetLocaleInfo(lcid, OS.LOCALE_SISO639LANGNAME, buffer, length);
- if (size <= 0 || !lang.equals(buffer.toString(0, size - 1))) return 1;
-
- /* Check the country */
- if (country != null) {
- size = OS.GetLocaleInfo(lcid, OS.LOCALE_SISO3166CTRYNAME, buffer, length);
- if (size <= 0 || !country.equals(buffer.toString(0, size - 1))) return 1;
- }
-
- /* Get the charset */
- size = OS.GetLocaleInfo(lcid, OS.LOCALE_IDEFAULTANSICODEPAGE, buffer, length);
- if (size <= 0) return 1;
- int cp = Integer.parseInt(buffer.toString(0, size - 1));
- int [] lpCs = new int[8];
- OS.TranslateCharsetInfo(cp, lpCs, OS.TCI_SRCCODEPAGE);
- data.lfCharSet = (byte)lpCs[0];
-
- return 0;
-}
-
-/**
- * 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() {
- char[] chars = {
- 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 < chars.length) {
- if (chars [index] == 0) break;
- index++;
- }
- return new String (chars, 0, index);
-}
-
-/**
- * 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 ^ height ^ 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 locale of the receiver.
- * <p>
- * The locale determines which platform character set this
- * font is going to use. Widgets and graphics operations that
- * use this font will convert UNICODE strings to the platform
- * character set of the specified locale.
- * </p>
- * <p>
- * On platforms which there are multiple character sets for a
- * given language/country locale, the variant portion of the
- * locale will determine the character set.
- * </p>
- *
- * @param locale the <code>String</code> representing a Locale object
- * @see java.util.Locale#toString
- */
-public void setLocale(String locale) {
- lang = country = variant = null;
- if (locale != null) {
- char sep = '_';
- int length = locale.length();
- int firstSep, secondSep;
-
- firstSep = locale.indexOf(sep);
- if (firstSep == -1) {
- firstSep = secondSep = length;
- } else {
- secondSep = locale.indexOf(sep, firstSep + 1);
- if (secondSep == -1) secondSep = length;
- }
- if (firstSep > 0) lang = locale.substring(0, firstSep);
- if (secondSep > firstSep + 1) country = locale.substring(firstSep + 1, secondSep);
- if (length > secondSep + 1) variant = locale.substring(secondSep + 1);
- }
- if (lang == null) {
- data.lfCharSet = OS.DEFAULT_CHARSET;
- } else {
- Callback callback = new Callback (this, "EnumLocalesProc", 1);
- int lpEnumLocalesProc = callback.getAddress ();
- OS.EnumSystemLocales(lpEnumLocalesProc, OS.LCID_SUPPORTED);
- callback.dispose ();
- }
-}
-
-/**
- * Sets the name of the receiver.
- * <p>
- * Some platforms support font foundries. On these platforms, the name
- * of the font specified in setName() may have one of the following forms:
- * <ol>
- * <li>a face name (for example, "courier")</li>
- * <li>a foundry followed by a dash ("-") followed by a face name (for example, "adobe-courier")</li>
- * </ol>
- * In either case, the name returned from getName() will include the
- * foundry.
- * </p>
- * <p>
- * On platforms that do not support font foundries, only the face name
- * (for example, "courier") is used in <code>setName()</code> and
- * <code>getName()</code>.
- * </p>
- *
- * @param name the name of the font data (must not be null)
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - when the font name is null</li>
- * </ul>
- *
- * @see #getName
- */
-public void setName(String name) {
- if (name == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
- char [] chars = new char [32];
-
- /* The field lfFaceName must be NULL terminated */
- int length = name.length();
- name.getChars (0, length <= 31 ? length : 31, chars, 0);
- data.lfFaceName0 = chars[0];
- data.lfFaceName1 = chars[1];
- data.lfFaceName2 = chars[2];
- data.lfFaceName3 = chars[3];
- data.lfFaceName4 = chars[4];
- data.lfFaceName5 = chars[5];
- data.lfFaceName6 = chars[6];
- data.lfFaceName7 = chars[7];
- data.lfFaceName8 = chars[8];
- data.lfFaceName9 = chars[9];
- data.lfFaceName10 = chars[10];
- data.lfFaceName11 = chars[11];
- data.lfFaceName12 = chars[12];
- data.lfFaceName13 = chars[13];
- data.lfFaceName14 = chars[14];
- data.lfFaceName15 = chars[15];
- data.lfFaceName16 = chars[16];
- data.lfFaceName17 = chars[17];
- data.lfFaceName18 = chars[18];
- data.lfFaceName19 = chars[19];
- data.lfFaceName20 = chars[20];
- data.lfFaceName21 = chars[21];
- data.lfFaceName22 = chars[22];
- data.lfFaceName23 = chars[23];
- data.lfFaceName24 = chars[24];
- data.lfFaceName25 = chars[25];
- data.lfFaceName26 = chars[26];
- data.lfFaceName27 = chars[27];
- data.lfFaceName28 = chars[28];
- data.lfFaceName29 = chars[29];
- data.lfFaceName30 = chars[30];
- data.lfFaceName31 = chars[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("|");
- char[] 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(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);
-}
-
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+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;
+
+ /**
+ * The locales of the font
+ * (Warning: These fields are platform dependent)
+ */
+ String lang, country, variant;
+
+/**
+ * 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);
+ try {
+ if (Integer.parseInt(version1) != 1) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+ } catch (NumberFormatException e) {
+ SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+ }
+
+ start = end + 1;
+ end = string.indexOf('|', start);
+ if (end == -1) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+ String name = string.substring(start, end);
+
+ start = end + 1;
+ end = string.indexOf('|', start);
+ if (end == -1) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+ 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 = lfFaceName[0];
+ newData.lfFaceName1 = lfFaceName[1];
+ newData.lfFaceName2 = lfFaceName[2];
+ newData.lfFaceName3 = lfFaceName[3];
+ newData.lfFaceName4 = lfFaceName[4];
+ newData.lfFaceName5 = lfFaceName[5];
+ newData.lfFaceName6 = lfFaceName[6];
+ newData.lfFaceName7 = lfFaceName[7];
+ newData.lfFaceName8 = lfFaceName[8];
+ newData.lfFaceName9 = lfFaceName[9];
+ newData.lfFaceName10 = lfFaceName[10];
+ newData.lfFaceName11 = lfFaceName[11];
+ newData.lfFaceName12 = lfFaceName[12];
+ newData.lfFaceName13 = lfFaceName[13];
+ newData.lfFaceName14 = lfFaceName[14];
+ newData.lfFaceName15 = lfFaceName[15];
+ newData.lfFaceName16 = lfFaceName[16];
+ newData.lfFaceName17 = lfFaceName[17];
+ newData.lfFaceName18 = lfFaceName[18];
+ newData.lfFaceName19 = lfFaceName[19];
+ newData.lfFaceName20 = lfFaceName[20];
+ newData.lfFaceName21 = lfFaceName[21];
+ newData.lfFaceName22 = lfFaceName[22];
+ newData.lfFaceName23 = lfFaceName[23];
+ newData.lfFaceName24 = lfFaceName[24];
+ newData.lfFaceName25 = lfFaceName[25];
+ newData.lfFaceName26 = lfFaceName[26];
+ newData.lfFaceName27 = lfFaceName[27];
+ newData.lfFaceName28 = lfFaceName[28];
+ newData.lfFaceName29 = lfFaceName[29];
+ newData.lfFaceName30 = lfFaceName[30];
+ newData.lfFaceName31 = 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_NULL_ARGUMENT - when the font name is null</li>
+ * <li>ERROR_INVALID_ARGUMENT - if the height is negative</li>
+ * </ul>
+ */
+public FontData(String name, int height, int style) {
+ if (name == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ 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;
+ FontData fd = (FontData)object;
+ LOGFONT lf = fd.data;
+ return data.lfCharSet == lf.lfCharSet &&
+ /*
+ * This code is intentionally commented. When creating
+ * a FontData, lfHeight is not necessarily set. Instead
+ * we check the height field which is always set.
+ */
+// data.lfHeight == lf.lfHeight &&
+ height == fd.height &&
+ 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;
+}
+
+int EnumLocalesProc(int lpLocaleString) {
+
+ /* Get the locale ID */
+ int length = 8;
+ TCHAR buffer = new TCHAR(0, length);
+ int byteCount = length * TCHAR.sizeof;
+ OS.MoveMemory(buffer, lpLocaleString, byteCount);
+ int lcid = Integer.parseInt(buffer.toString(0, buffer.strlen ()), 16);
+
+ /* Check the language */
+ int size = OS.GetLocaleInfo(lcid, OS.LOCALE_SISO639LANGNAME, buffer, length);
+ if (size <= 0 || !lang.equals(buffer.toString(0, size - 1))) return 1;
+
+ /* Check the country */
+ if (country != null) {
+ size = OS.GetLocaleInfo(lcid, OS.LOCALE_SISO3166CTRYNAME, buffer, length);
+ if (size <= 0 || !country.equals(buffer.toString(0, size - 1))) return 1;
+ }
+
+ /* Get the charset */
+ size = OS.GetLocaleInfo(lcid, OS.LOCALE_IDEFAULTANSICODEPAGE, buffer, length);
+ if (size <= 0) return 1;
+ int cp = Integer.parseInt(buffer.toString(0, size - 1));
+ int [] lpCs = new int[8];
+ OS.TranslateCharsetInfo(cp, lpCs, OS.TCI_SRCCODEPAGE);
+ data.lfCharSet = (byte)lpCs[0];
+
+ return 0;
+}
+
+/**
+ * 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() {
+ char[] chars = {
+ 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 < chars.length) {
+ if (chars [index] == 0) break;
+ index++;
+ }
+ return new String (chars, 0, index);
+}
+
+/**
+ * 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 ^ height ^ 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 locale of the receiver.
+ * <p>
+ * The locale determines which platform character set this
+ * font is going to use. Widgets and graphics operations that
+ * use this font will convert UNICODE strings to the platform
+ * character set of the specified locale.
+ * </p>
+ * <p>
+ * On platforms which there are multiple character sets for a
+ * given language/country locale, the variant portion of the
+ * locale will determine the character set.
+ * </p>
+ *
+ * @param locale the <code>String</code> representing a Locale object
+ * @see java.util.Locale#toString
+ */
+public void setLocale(String locale) {
+ lang = country = variant = null;
+ if (locale != null) {
+ char sep = '_';
+ int length = locale.length();
+ int firstSep, secondSep;
+
+ firstSep = locale.indexOf(sep);
+ if (firstSep == -1) {
+ firstSep = secondSep = length;
+ } else {
+ secondSep = locale.indexOf(sep, firstSep + 1);
+ if (secondSep == -1) secondSep = length;
+ }
+ if (firstSep > 0) lang = locale.substring(0, firstSep);
+ if (secondSep > firstSep + 1) country = locale.substring(firstSep + 1, secondSep);
+ if (length > secondSep + 1) variant = locale.substring(secondSep + 1);
+ }
+ if (lang == null) {
+ data.lfCharSet = OS.DEFAULT_CHARSET;
+ } else {
+ Callback callback = new Callback (this, "EnumLocalesProc", 1);
+ int lpEnumLocalesProc = callback.getAddress ();
+ OS.EnumSystemLocales(lpEnumLocalesProc, OS.LCID_SUPPORTED);
+ callback.dispose ();
+ }
+}
+
+/**
+ * Sets the name of the receiver.
+ * <p>
+ * Some platforms support font foundries. On these platforms, the name
+ * of the font specified in setName() may have one of the following forms:
+ * <ol>
+ * <li>a face name (for example, "courier")</li>
+ * <li>a foundry followed by a dash ("-") followed by a face name (for example, "adobe-courier")</li>
+ * </ol>
+ * In either case, the name returned from getName() will include the
+ * foundry.
+ * </p>
+ * <p>
+ * On platforms that do not support font foundries, only the face name
+ * (for example, "courier") is used in <code>setName()</code> and
+ * <code>getName()</code>.
+ * </p>
+ *
+ * @param name the name of the font data (must not be null)
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - when the font name is null</li>
+ * </ul>
+ *
+ * @see #getName
+ */
+public void setName(String name) {
+ if (name == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ char [] chars = new char [32];
+
+ /* The field lfFaceName must be NULL terminated */
+ int length = name.length();
+ name.getChars (0, length <= 31 ? length : 31, chars, 0);
+ data.lfFaceName0 = chars[0];
+ data.lfFaceName1 = chars[1];
+ data.lfFaceName2 = chars[2];
+ data.lfFaceName3 = chars[3];
+ data.lfFaceName4 = chars[4];
+ data.lfFaceName5 = chars[5];
+ data.lfFaceName6 = chars[6];
+ data.lfFaceName7 = chars[7];
+ data.lfFaceName8 = chars[8];
+ data.lfFaceName9 = chars[9];
+ data.lfFaceName10 = chars[10];
+ data.lfFaceName11 = chars[11];
+ data.lfFaceName12 = chars[12];
+ data.lfFaceName13 = chars[13];
+ data.lfFaceName14 = chars[14];
+ data.lfFaceName15 = chars[15];
+ data.lfFaceName16 = chars[16];
+ data.lfFaceName17 = chars[17];
+ data.lfFaceName18 = chars[18];
+ data.lfFaceName19 = chars[19];
+ data.lfFaceName20 = chars[20];
+ data.lfFaceName21 = chars[21];
+ data.lfFaceName22 = chars[22];
+ data.lfFaceName23 = chars[23];
+ data.lfFaceName24 = chars[24];
+ data.lfFaceName25 = chars[25];
+ data.lfFaceName26 = chars[26];
+ data.lfFaceName27 = chars[27];
+ data.lfFaceName28 = chars[28];
+ data.lfFaceName29 = chars[29];
+ data.lfFaceName30 = chars[30];
+ data.lfFaceName31 = chars[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("|");
+ char[] 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(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
index 83819f050a..6ee56cbe90 100755
--- 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
@@ -1,173 +1,173 @@
-package org.eclipse.swt.graphics;
-
-/*
+package org.eclipse.swt.graphics;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-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 {
-
- /**
- * On Windows, handle is a Win32 TEXTMETRIC struct
- * On Photon, handle is a Photon FontQueryInfo 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;
-}
-
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+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 {
+
+ /**
+ * On Windows, handle is a Win32 TEXTMETRIC struct
+ * On Photon, handle is a Photon FontQueryInfo 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
index f027948a9c..6c75124849 100755
--- 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
@@ -1,2305 +1,2305 @@
-package org.eclipse.swt.graphics;
-
-/*
+package org.eclipse.swt.graphics;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-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 org.eclipse.swt.events.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;
-
-/**
- * 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_NULL_ARGUMENT - if there is no current device</li>
- * <li>ERROR_INVALID_ARGUMENT
- * - if the drawable is an image that is not a bitmap or an icon
- * - if the drawable is an image or printer that is already selected
- * into another graphics context</li>
- * </ul>
- * @exception SWTError <ul>
- * <li>ERROR_NO_HANDLES if a handle could not be obtained for gc creation</li>
- * </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 or has been disposed</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
- * </ul>
- */
-public void copyArea(Image image, int x, int y) {
- if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- if (image == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
- if (image.type != SWT.BITMAP || image.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
-
- /* 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
- *
- * @exception SWTException <ul>
- * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
- * </ul>
- */
-public void copyArea(int srcX, int srcY, int width, int height, int destX, int destY) {
- if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
-
- /*
- * Feature in WinCE. The function WindowFromDC is not part of the
- * WinCE SDK. The fix is to remember the HWND.
- */
- int hwnd = data.hwnd;
- 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);
- int res = OS.ScrollWindowEx(hwnd, destX - srcX, destY - srcY, lprcScroll, lprcClip, 0, null, OS.SW_INVALIDATE | OS.SW_ERASE);
-
- /*
- * Feature in WinCE. ScrollWindowEx does not accept combined
- * vertical and horizontal scrolling. The fix is to do a
- * BitBlt and invalidate the appropriate source area.
- */
- if (res == 0 && OS.IsWinCE) {
- OS.BitBlt(handle, destX, destY, width, height, handle, srcX, srcY, OS.SRCCOPY);
- int deltaX = destX - srcX, deltaY = destY - srcY;
- boolean disjoint = (destX + width < srcX) || (srcX + width < destX) || (destY + height < srcY) || (srcY + height < destY);
- if (disjoint) {
- OS.InvalidateRect(hwnd, lprcScroll, true);
- } else {
- if (deltaX != 0) {
- int newX = destX - deltaX;
- if (deltaX < 0) newX = destX + width;
- OS.SetRect(lprcScroll, newX, srcY, newX + Math.abs(deltaX), srcY + height);
- OS.InvalidateRect(hwnd, lprcScroll, true);
- }
- if (deltaY != 0) {
- int newY = destY - deltaY;
- if (deltaY < 0) newY = destY + height;
- OS.SetRect(lprcScroll, srcX, newY, srcX + width, newY + Math.abs(deltaY));
- OS.InvalidateRect(hwnd, lprcScroll, true);
- }
- }
- }
- }
-}
-
-int createDIB(int width, int height) {
- short depth = 32;
-
- BITMAPINFOHEADER bmiHeader = new BITMAPINFOHEADER();
- bmiHeader.biSize = BITMAPINFOHEADER.sizeof;
- bmiHeader.biWidth = width;
- bmiHeader.biHeight = -height;
- bmiHeader.biPlanes = 1;
- bmiHeader.biBitCount = depth;
- if (OS.IsWinCE) bmiHeader.biCompression = OS.BI_BITFIELDS;
- else bmiHeader.biCompression = OS.BI_RGB;
- byte[] bmi = new byte[BITMAPINFOHEADER.sizeof + (OS.IsWinCE ? 12 : 0)];
- OS.MoveMemory(bmi, bmiHeader, BITMAPINFOHEADER.sizeof);
- /* Set the rgb colors into the bitmap info */
- if (OS.IsWinCE) {
- int redMask = 0xFF00;
- int greenMask = 0xFF0000;
- int blueMask = 0xFF000000;
- /* big endian */
- int offset = BITMAPINFOHEADER.sizeof;
- bmi[offset] = (byte)((redMask & 0xFF000000) >> 24);
- bmi[offset + 1] = (byte)((redMask & 0xFF0000) >> 16);
- bmi[offset + 2] = (byte)((redMask & 0xFF00) >> 8);
- bmi[offset + 3] = (byte)((redMask & 0xFF) >> 0);
- bmi[offset + 4] = (byte)((greenMask & 0xFF000000) >> 24);
- bmi[offset + 5] = (byte)((greenMask & 0xFF0000) >> 16);
- bmi[offset + 6] = (byte)((greenMask & 0xFF00) >> 8);
- bmi[offset + 7] = (byte)((greenMask & 0xFF) >> 0);
- bmi[offset + 8] = (byte)((blueMask & 0xFF000000) >> 24);
- bmi[offset + 9] = (byte)((blueMask & 0xFF0000) >> 16);
- bmi[offset + 10] = (byte)((blueMask & 0xFF00) >> 8);
- bmi[offset + 11] = (byte)((blueMask & 0xFF) >> 0);
- }
-
- 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;
- if (data.device.isDisposed()) 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>
- * @exception SWTException <ul>
- * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
- * </ul>
- */
-public void drawArc (int x, int y, int width, int height, int startAngle, int endAngle) {
- if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- if (width < 0) {
- x = x + width;
- width = -width;
- }
- if (height < 0) {
- y = y + height;
- height = -height;
- }
- if (width == 0 || height == 0 || endAngle == 0) {
- SWT.error(SWT.ERROR_INVALID_ARGUMENT);
- }
- /*
- * Feature in WinCE. The function Arc is not present in the
- * WinCE SDK. The fix is to emulate arc drawing by using
- * Polyline.
- */
- if (OS.IsWinCE) {
- /* compute arc with a simple linear interpolation */
- if (endAngle < 0) {
- startAngle += endAngle;
- endAngle = -endAngle;
- }
- if (endAngle > 360) endAngle = 360;
- int[] points = new int[(endAngle + 1) * 2];
- int cteX = 2 * x + width;
- int cteY = 2 * y + height;
- int index = 0;
- for (int i = 0; i <= endAngle; i++) {
- points[index++] = (Compatibility.cos(startAngle + i, width) + cteX) >> 1;
- points[index++] = (cteY - Compatibility.sin(startAngle + i, height)) >> 1;
- }
- OS.Polyline(handle, points, points.length / 2);
- } else {
- int x1, y1, x2, y2,tmp;
- boolean isNegative;
- 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 = Compatibility.cos(startAngle, width) + x + width/2;
- y1 = -1 * Compatibility.sin(startAngle, height) + y + height/2;
-
- x2 = Compatibility.cos(endAngle, width) + x + width/2;
- y2 = -1 * Compatibility.sin(endAngle, 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 foreground color.
- *
- * @param x the x coordinate of the rectangle
- * @param y the y coordinate of the rectangle
- * @param width the width of the rectangle
- * @param height the height of the rectangle
- *
- * @exception SWTException <ul>
- * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
- * </ul>
- *
- * @see #drawRectangle
- */
-public void drawFocus (int x, int y, int width, int height) {
- if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- 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 image has been disposed</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>
- * @exception SWTException <ul>
- * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
- * </ul>
- */
-public void drawImage(Image image, int x, int y) {
- if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- if (image == null) SWT.error (SWT.ERROR_NULL_ARGUMENT);
- if (image.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
- drawImage(image, 0, 0, -1, -1, x, y, -1, -1, true);
-}
-
-/**
- * Copies a rectangular area from the source image into a (potentially
- * different sized) rectangular area in the receiver. If the source
- * and destination areas are of differing sizes, then the source
- * area will be stretched or shrunk to fit the destination area
- * as it is copied. The copy fails if any part of the source rectangle
- * lies outside the bounds of the source image, or if any of the width
- * or height arguments are negative.
- *
- * @param image the source image
- * @param srcX the x coordinate in the source image to copy from
- * @param srcY the y coordinate in the source image to copy from
- * @param srcWidth the width in pixels to copy from the source
- * @param srcHeight the height in pixels to copy from the source
- * @param destX the x coordinate in the destination to copy to
- * @param destY the y coordinate in the destination to copy to
- * @param destWidth the width in pixels of the destination rectangle
- * @param destHeight the height in pixels of the destination rectangle
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the image is null</li>
- * <li>ERROR_INVALID_ARGUMENT - if the image has been disposed</li>
- * <li>ERROR_INVALID_ARGUMENT - if any of the width or height arguments are negative.
- * <li>ERROR_INVALID_ARGUMENT - if the source rectangle is not contained within the bounds of the source image</li>
- * </ul>
- * @exception SWTError <ul>
- * <li>ERROR_NO_HANDLES - if no handles are available to perform the operation</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
- * </ul>
- */
-public void drawImage(Image image, int srcX, int srcY, int srcWidth, int srcHeight, int destX, int destY, int destWidth, int destHeight) {
- if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- if (srcWidth == 0 || srcHeight == 0 || destWidth == 0 || destHeight == 0) return;
- if (srcX < 0 || srcY < 0 || srcWidth < 0 || srcHeight < 0 || destWidth < 0 || destHeight < 0) {
- SWT.error (SWT.ERROR_INVALID_ARGUMENT);
- }
- if (image == null) SWT.error (SWT.ERROR_NULL_ARGUMENT);
- if (image.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
- drawImage(image, srcX, srcY, srcWidth, srcHeight, destX, destY, destWidth, destHeight, false);
-}
-
-void drawImage(Image srcImage, int srcX, int srcY, int srcWidth, int srcHeight, int destX, int destY, int destWidth, int destHeight, boolean simple) {
- 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();
- if (OS.IsWinCE) {
- Image.GetIconInfo(srcImage, srcIconInfo);
- } else {
- 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);
- if (!OS.IsWinCE) 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.
- */
- 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 = Math.max(1, sx2 - sx1);
- srcHeight = Math.max(1, sy2 - sy1);
-
- /* Create resources */
- int srcHdc = OS.CreateCompatibleDC(handle);
- int oldSrcBitmap = OS.SelectObject(srcHdc, srcImage.handle);
- int memHdc = OS.CreateCompatibleDC(handle);
- int memDib = createDIB(Math.max(srcWidth, destWidth), Math.max(srcHeight, destHeight));
- 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.BitBlt(memHdc, 0, 0, srcWidth, srcHeight, srcHdc, srcX, srcY, OS.SRCCOPY);
- byte[] srcData = new byte[sizeInBytes];
- OS.MoveMemory(srcData, dibBM.bmBits, sizeInBytes);
-
- /* Merge the alpha channel in place */
- int alpha = srcImage.alpha;
- final boolean hasAlphaChannel = (srcImage.alpha == -1);
- if (hasAlphaChannel) {
- final int apinc = imgWidth - srcWidth;
- final int spinc = dibBM.bmWidthBytes - srcWidth * 4;
- int ap = srcY * imgWidth + srcX, sp = 3;
- byte[] alphaData = srcImage.alphaData;
- for (int y = 0; y < srcHeight; ++y) {
- for (int x = 0; x < srcWidth; ++x) {
- srcData[sp] = alphaData[ap++];
- sp += 4;
- }
- ap += apinc;
- sp += spinc;
- }
- }
-
- /* Scale the foreground pixels with alpha */
- if (!OS.IsWinCE) OS.SetStretchBltMode(memHdc, OS.COLORONCOLOR);
- OS.MoveMemory(dibBM.bmBits, srcData, sizeInBytes);
- /*
- * Bug in WinCE and Win98. StretchBlt does not correctly stretch when
- * the source and destination HDCs are the same. The workaround is to
- * stretch to a temporary HDC and blit back into the original HDC.
- * Note that on WinCE StretchBlt correctly compresses the image when the
- * source and destination HDCs are the same.
- */
- if ((OS.IsWinCE && (destWidth > srcWidth || destHeight > srcHeight)) || (!OS.IsWinNT && !OS.IsWinCE)) {
- int tempHdc = OS.CreateCompatibleDC(handle);
- int tempDib = createDIB(destWidth, destHeight);
- int oldTempBitmap = OS.SelectObject(tempHdc, tempDib);
- OS.StretchBlt(tempHdc, 0, 0, destWidth, destHeight, memHdc, 0, 0, srcWidth, srcHeight, OS.SRCCOPY);
- OS.BitBlt(memHdc, 0, 0, destWidth, destHeight, tempHdc, 0, 0, OS.SRCCOPY);
- OS.SelectObject(tempHdc, oldTempBitmap);
- OS.DeleteObject(tempDib);
- OS.DeleteDC(tempHdc);
- } else {
- OS.StretchBlt(memHdc, 0, 0, destWidth, destHeight, memHdc, 0, 0, srcWidth, srcHeight, OS.SRCCOPY);
- }
- OS.MoveMemory(srcData, dibBM.bmBits, sizeInBytes);
-
- /* Compose the pixels */
- final int dpinc = dibBM.bmWidthBytes - destWidth * 4;
- int dp = 0;
- for (int y = 0; y < destHeight; ++y) {
- for (int x = 0; x < destWidth; ++x) {
- if (hasAlphaChannel) alpha = srcData[dp + 3] & 0xff;
- destData[dp] += ((srcData[dp] & 0xff) - (destData[dp] & 0xff)) * alpha / 255;
- destData[dp + 1] += ((srcData[dp + 1] & 0xff) - (destData[dp + 1] & 0xff)) * alpha / 255;
- destData[dp + 2] += ((srcData[dp + 2] & 0xff) - (destData[dp + 2] & 0xff)) * alpha / 255;
- dp += 4;
- }
- dp += dpinc;
- }
-
- /* 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 */
- if (OS.IsWinCE) {
- byte[] pBits = new byte[1];
- OS.MoveMemory(pBits, bm.bmBits, 1);
- byte oldValue = pBits[0];
- int mask = (0xFF << (8 - bm.bmBitsPixel)) & 0x00FF;
- pBits[0] = (byte)((srcImage.transparentPixel << (8 - bm.bmBitsPixel)) | (pBits[0] & ~mask));
- OS.MoveMemory(bm.bmBits, pBits, 1);
- int color = OS.GetPixel(srcHdc, 0, 0);
- pBits[0] = oldValue;
- OS.MoveMemory(bm.bmBits, pBits, 1);
- transBlue = (color & 0xFF0000) >> 16;
- transGreen = (color & 0xFF00) >> 8;
- transRed = color & 0xFF;
- } else {
- int maxColors = 1 << bm.bmBitsPixel;
- byte[] oldColors = new byte[maxColors * 4];
- 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;
- /* Set the few fields necessary to get the RGB data out */
- BITMAPINFOHEADER bmiHeader = new BITMAPINFOHEADER();
- bmiHeader.biSize = BITMAPINFOHEADER.sizeof;
- bmiHeader.biPlanes = bm.bmPlanes;
- bmiHeader.biBitCount = bm.bmBitsPixel;
- byte[] bmi = new byte[BITMAPINFOHEADER.sizeof + numColors * 4];
- OS.MoveMemory(bmi, bmiHeader, BITMAPINFOHEADER.sizeof);
- if (OS.IsWinCE) SWT.error(SWT.ERROR_NOT_IMPLEMENTED);
- OS.GetDIBits(srcHdc, srcImage.handle, 0, 0, 0, bmi, OS.DIB_RGB_COLORS);
- int offset = BITMAPINFOHEADER.sizeof + 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;
- }
- }
-
- if (OS.IsWinCE) {
- /*
- * Note in WinCE. TransparentImage uses the first entry of a palette
- * based image when there are multiple entries that have the same
- * transparent color.
- */
- int transparentColor = transBlue << 16 | transGreen << 8 | transRed;
- OS.TransparentImage(handle, destX, destY, destWidth, destHeight,
- srcHdc, srcX, srcY, srcWidth, srcHeight, transparentColor);
- } else {
- /* Create the mask for the source image */
- int maskHdc = OS.CreateCompatibleDC(hDC);
- int maskBitmap = OS.CreateBitmap(imgWidth, imgHeight, 1, 1, null);
- int oldMaskBitmap = OS.SelectObject(maskHdc, maskBitmap);
- OS.SetBkColor(srcHdc, (transBlue << 16) | (transGreen << 8) | transRed);
- OS.BitBlt(maskHdc, 0, 0, imgWidth, imgHeight, 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);
- if (!OS.IsWinCE) 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 mode = 0, rop2 = 0;
- if (!OS.IsWinCE) {
- rop2 = OS.GetROP2(handle);
- mode = OS.SetStretchBltMode(handle, OS.COLORONCOLOR);
- } else {
- rop2 = OS.SetROP2 (handle, OS.R2_COPYPEN);
- OS.SetROP2 (handle, rop2);
- }
- int dwRop = rop2 == OS.R2_XORPEN ? OS.SRCINVERT : OS.SRCCOPY;
- OS.StretchBlt(handle, destX, destY, destWidth, destHeight, srcHdc, srcX, srcY, srcWidth, srcHeight, dwRop);
- if (!OS.IsWinCE) {
- OS.SetStretchBltMode(handle, mode);
- }
- 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
- *
- * @exception SWTException <ul>
- * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
- * </ul>
- */
-public void drawLine (int x1, int y1, int x2, int y2) {
- if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- if (OS.IsWinCE) {
- int [] points = new int [] {x1, y1, x2, y2};
- OS.Polyline (handle, points, points.length / 2);
- } else {
- 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
- *
- * @exception SWTException <ul>
- * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
- * </ul>
- */
-public void drawOval (int x, int y, int width, int height) {
- if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- // 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+1,y+height+1);
- 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>
- * @exception SWTException <ul>
- * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
- * </ul>
- */
-public void drawPolygon(int[] pointArray) {
- if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- if (pointArray == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
- 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>
- * @exception SWTException <ul>
- * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
- * </ul>
- */
-public void drawPolyline(int[] pointArray) {
- if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- if (pointArray == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
- 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
- *
- * @exception SWTException <ul>
- * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
- * </ul>
- */
-public void drawRectangle (int x, int y, int width, int height) {
- if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- 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>
- * @exception SWTException <ul>
- * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
- * </ul>
- */
-public void drawRectangle (Rectangle rect) {
- if (rect == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
- drawRectangle (rect.x, rect.y, rect.width, rect.height);
-}
-
-/**
- * Draws the outline of the round-cornered rectangle specified by
- * the arguments, using the receiver's foreground color. The left and
- * right edges of the rectangle are at <code>x</code> and <code>x + width</code>.
- * The top and bottom edges are at <code>y</code> and <code>y + height</code>.
- * The <em>roundness</em> of the corners is specified by the
- * <code>arcWidth</code> and <code>arcHeight</code> arguments.
- *
- * @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
- *
- * @exception SWTException <ul>
- * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
- * </ul>
- */
-public void drawRoundRectangle (int x, int y, int width, int height, int arcWidth, int arcHeight) {
- if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- if (OS.IsWinCE) {
- /*
- * Bug in WinCE PPC. On certain devices, RoundRect does not draw
- * all the pixels. The workaround is to draw a round rectangle
- * using lines and arcs.
- */
- if (width == 0 || height == 0) return;
- if (arcWidth == 0 || arcHeight == 0) {
- drawRectangle(x, y, width, height);
- return;
- }
- if (width < 0) {
- x += width;
- width = -width;
- }
- if (height < 0) {
- y += height;
- height = -height;
- };
- if (arcWidth < 0) arcWidth = -arcWidth;
- if (arcHeight < 0) arcHeight = -arcHeight;
- if (arcWidth > width) arcWidth = width;
- if (arcHeight > height) arcHeight = height;
-
- if (arcWidth < width) {
- drawLine(x+arcWidth/2, y, x+width-arcWidth/2, y);
- drawLine(x+arcWidth/2, y+height-1, x+width-arcWidth/2, y+height-1);
- }
- if (arcHeight < height) {
- drawLine(x, y+arcHeight/2, x, y+height-arcHeight/2);
- drawLine(x+width-1, y+arcHeight/2, x+width-1, y+height-arcHeight/2);
- }
- if (arcWidth != 0 && arcHeight != 0) {
- drawArc(x, y, arcWidth, arcHeight, 90, 90);
- drawArc(x+width-arcWidth-1, y, arcWidth, arcHeight, 0, 90);
- drawArc(x+width-arcWidth-1, y+height-arcHeight-1, arcWidth, arcHeight, 0, -90);
- drawArc(x, y+height-arcHeight-1, arcWidth, arcHeight, 180, 90);
- }
- } else {
- 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>
- * @exception SWTException <ul>
- * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
- * </ul>
- */
-public void drawString (String string, int x, int y) {
- drawString(string, x, y, false);
-}
-
-/**
- * Draws the given string, using the receiver's current font and
- * foreground color. No tab expansion or carriage return processing
- * will be performed. If <code>isTransparent</code> is <code>true</code>,
- * then the background of the rectangular area where the string is being
- * drawn will not be modified, otherwise it will be filled with the
- * receiver's background color.
- *
- * @param string the string to be drawn
- * @param x the x coordinate of the top left corner of the rectangular area where the string is to be drawn
- * @param y the y coordinate of the top left corner of the rectangular area where the string is to be drawn
- * @param isTransparent if <code>true</code> the background will be transparent, otherwise it will be opaque
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the string is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
- * </ul>
- */
-public void drawString (String string, int x, int y, boolean isTransparent) {
- if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- if (string == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
-// TCHAR buffer = new TCHAR (getCodePage(), string, false);
- int length = string.length();
- char[] buffer = new char [length];
- string.getChars(0, length, buffer, 0);
- int oldBkMode = OS.SetBkMode(handle, isTransparent ? OS.TRANSPARENT : OS.OPAQUE);
- OS.ExtTextOutW(handle, x, y, 0, null, buffer, length, null);
- OS.SetBkMode(handle, oldBkMode);
-}
-
-/**
- * Draws the given string, using the receiver's current font and
- * foreground color. Tab expansion and carriage return processing
- * are performed. The background of the rectangular area where
- * the text is being drawn will be filled with the receiver's
- * background color.
- *
- * @param string the string to be drawn
- * @param x the x coordinate of the top left corner of the rectangular area where the text is to be drawn
- * @param y the y coordinate of the top left corner of the rectangular area where the text is to be drawn
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the string is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
- * </ul>
- */
-public void drawText (String string, int x, int y) {
- drawText(string, x, y, SWT.DRAW_DELIMITER | SWT.DRAW_TAB);
-}
-
-/**
- * Draws the given string, using the receiver's current font and
- * foreground color. Tab expansion and carriage return processing
- * are performed. If <code>isTransparent</code> is <code>true</code>,
- * then the background of the rectangular area where the text is being
- * drawn will not be modified, otherwise it will be filled with the
- * receiver's background color.
- *
- * @param string the string to be drawn
- * @param x the x coordinate of the top left corner of the rectangular area where the text is to be drawn
- * @param y the y coordinate of the top left corner of the rectangular area where the text is to be drawn
- * @param isTransparent if <code>true</code> the background will be transparent, otherwise it will be opaque
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the string is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
- * </ul>
- */
-public void drawText (String string, int x, int y, boolean isTransparent) {
- int flags = SWT.DRAW_DELIMITER | SWT.DRAW_TAB;
- if (isTransparent) flags |= SWT.DRAW_TRANSPARENT;
- drawText(string, x, y, flags);
-}
-
-/**
- * Draws the given string, using the receiver's current font and
- * foreground color. Tab expansion, line delimiter and mnemonic
- * processing are performed according to the specified flags. If
- * <code>flags</code> includes <code>DRAW_TRANSPARENT</code>,
- * then the background of the rectangular area where the text is being
- * drawn will not be modified, otherwise it will be filled with the
- * receiver's background color.
- * <p>
- * The parameter <code>flags</code> may be a combination of:
- * <dl>
- * <dt><b>DRAW_DELIMITER</b></dt>
- * <dd>draw multiple lines</dd>
- * <dt><b>DRAW_TAB</b></dt>
- * <dd>expand tabs</dd>
- * <dt><b>DRAW_MNEMONIC</b></dt>
- * <dd>underline the mnemonic character</dd>
- * <dt><b>DRAW_TRANSPARENT</b></dt>
- * <dd>transparent background</dd>
- * </dl>
- * </p>
- *
- * @param string the string to be drawn
- * @param x the x coordinate of the top left corner of the rectangular area where the text is to be drawn
- * @param y the y coordinate of the top left corner of the rectangular area where the text is to be drawn
- * @param flags the flags specifing how to process the text
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the string is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
- * </ul>
- */
-public void drawText (String string, int x, int y, int flags) {
- if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- if (string == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
- RECT rect = new RECT();
- OS.SetRect(rect, x, y, 0x7FFF, 0x7FFF);
- TCHAR buffer = new TCHAR(getCodePage(), string, false);
- int uFormat = OS.DT_LEFT;
- if ((flags & SWT.DRAW_DELIMITER) == 0) uFormat |= OS.DT_SINGLELINE;
- if ((flags & SWT.DRAW_TAB) != 0) uFormat |= OS.DT_EXPANDTABS;
- if ((flags & SWT.DRAW_MNEMONIC) == 0) uFormat |= OS.DT_NOPREFIX;
- int oldBkMode = OS.SetBkMode(handle, (flags & SWT.DRAW_TRANSPARENT) != 0 ? OS.TRANSPARENT : OS.OPAQUE);
- OS.DrawText(handle, buffer, buffer.length(), rect, uFormat);
- OS.SetBkMode(handle, oldBkMode);
-}
-
-/**
- * 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>
- * @exception SWTException <ul>
- * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
- * </ul>
- *
- * @see #drawArc
- */
-public void fillArc (int x, int y, int width, int height, int startAngle, int endAngle) {
- if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
-
- if (width < 0) {
- x = x + width;
- width = -width;
- }
- if (height < 0) {
- y = y + height;
- height = -height;
- }
-
- if (width == 0 || height == 0 || endAngle == 0) {
- SWT.error (SWT.ERROR_INVALID_ARGUMENT);
- }
-
- /*
- * Feature in WinCE. The function Pie is not present in the
- * WinCE SDK. The fix is to emulate it by using Polygon.
- */
- if (OS.IsWinCE) {
- /* compute arc with a simple linear interpolation */
- if (endAngle < 0) {
- startAngle += endAngle;
- endAngle = -endAngle;
- }
- boolean drawSegments = true;
- if (endAngle >= 360) {
- endAngle = 360;
- drawSegments = false;
- }
- int[] points = new int[(endAngle + 1) * 2 + (drawSegments ? 4 : 0)];
- int cteX = 2 * x + width;
- int cteY = 2 * y + height;
- int index = (drawSegments ? 2 : 0);
- for (int i = 0; i <= endAngle; i++) {
- points[index++] = (Compatibility.cos(startAngle + i, width) + cteX) >> 1;
- points[index++] = (cteY - Compatibility.sin(startAngle + i, height)) >> 1;
- }
- if (drawSegments) {
- points[0] = points[points.length - 2] = cteX >> 1;
- points[1] = points[points.length - 1] = cteY >> 1;
- }
- int nullPen = OS.GetStockObject(OS.NULL_PEN);
- int oldPen = OS.SelectObject(handle, nullPen);
- OS.Polygon(handle, points, points.length / 2);
- OS.SelectObject(handle, oldPen);
- } else {
- int x1, y1, x2, y2,tmp;
- boolean isNegative;
- 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 = Compatibility.cos(startAngle, width) + x + width/2;
- y1 = -1 * Compatibility.sin(startAngle, height) + y + height/2;
-
- x2 = Compatibility.cos(endAngle, width) + x + width/2;
- y2 = -1 * Compatibility.sin(endAngle, 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 the specified rectangle with a gradient
- * sweeping from left to right or top to bottom progressing
- * from the receiver's foreground color to its background color.
- *
- * @param x the x coordinate of the rectangle to be filled
- * @param y the y coordinate of the rectangle to be filled
- * @param width the width of the rectangle to be filled, may be negative
- * (inverts direction of gradient if horizontal)
- * @param height the height of the rectangle to be filled, may be negative
- * (inverts direction of gradient if vertical)
- * @param vertical if true sweeps from top to bottom, else
- * sweeps from left to right
- *
- * @exception SWTException <ul>
- * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
- * </ul>
- *
- * @see #drawRectangle
- */
-public void fillGradientRectangle(int x, int y, int width, int height, boolean vertical) {
- if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- if (width == 0 || height == 0) return;
- int fromColor = OS.GetTextColor(handle);
- if (fromColor == OS.CLR_INVALID) {
- fromColor = OS.GetSysColor(OS.COLOR_WINDOWTEXT);
- }
- int toColor = OS.GetBkColor(handle);
- if (toColor == OS.CLR_INVALID) {
- toColor = OS.GetSysColor(OS.COLOR_WINDOW);
- }
- boolean swapColors = false;
- if (width < 0) {
- x += width; width = -width;
- if (! vertical) swapColors = true;
- }
- if (height < 0) {
- y += height; height = -height;
- if (vertical) swapColors = true;
- }
- if (swapColors) {
- final int t = fromColor;
- fromColor = toColor;
- toColor = t;
- }
- final RGB fromRGB = new RGB(fromColor & 0xff, (fromColor >>> 8) & 0xff, (fromColor >>> 16) & 0xff);
- final RGB toRGB = new RGB(toColor & 0xff, (toColor >>> 8) & 0xff, (toColor >>> 16) & 0xff);
- if ((fromRGB.red == toRGB.red) && (fromRGB.green == toRGB.green) && (fromRGB.blue == toRGB.blue)) {
- OS.PatBlt(handle, x, y, width, height, OS.PATCOPY);
- return;
- }
-
- /* Use GradientFill if supported, only on Windows 98, 2000 and newer */
- if (!OS.IsWinCE) {
- final int hHeap = OS.GetProcessHeap();
- final int pMesh = OS.HeapAlloc(hHeap, OS.HEAP_ZERO_MEMORY,
- GRADIENT_RECT.sizeof + TRIVERTEX.sizeof * 2);
- final int pVertex = pMesh + GRADIENT_RECT.sizeof;
-
- GRADIENT_RECT gradientRect = new GRADIENT_RECT();
- gradientRect.UpperLeft = 0;
- gradientRect.LowerRight = 1;
- OS.MoveMemory(pMesh, gradientRect, GRADIENT_RECT.sizeof);
-
- TRIVERTEX trivertex = new TRIVERTEX();
- trivertex.x = x;
- trivertex.y = y;
- trivertex.Red = (short)((fromRGB.red << 8) | fromRGB.red);
- trivertex.Green = (short)((fromRGB.green << 8) | fromRGB.green);
- trivertex.Blue = (short)((fromRGB.blue << 8) | fromRGB.blue);
- trivertex.Alpha = -1;
- OS.MoveMemory(pVertex, trivertex, TRIVERTEX.sizeof);
-
- trivertex.x = x + width;
- trivertex.y = y + height;
- trivertex.Red = (short)((toRGB.red << 8) | toRGB.red);
- trivertex.Green = (short)((toRGB.green << 8) | toRGB.green);
- trivertex.Blue = (short)((toRGB.blue << 8) | toRGB.blue);
- trivertex.Alpha = -1;
- OS.MoveMemory(pVertex + TRIVERTEX.sizeof, trivertex, TRIVERTEX.sizeof);
-
- boolean success = OS.GradientFill(handle, pVertex, 2, pMesh, 1,
- vertical ? OS.GRADIENT_FILL_RECT_V : OS.GRADIENT_FILL_RECT_H);
- OS.HeapFree(hHeap, 0, pMesh);
- if (success) return;
- }
-
- final int depth = OS.GetDeviceCaps(handle, OS.BITSPIXEL);
- final int bitResolution = (depth >= 24) ? 8 : (depth >= 15) ? 5 : 0;
- ImageData.fillGradientRectangle(this, data.device,
- x, y, width, height, vertical, fromRGB, toRGB,
- bitResolution, bitResolution, bitResolution);
-}
-
-/**
- * Fills the interior of an oval, within the specified
- * rectangular area, with the receiver's background
- * color.
- *
- * @param x the x coordinate of the upper left corner of the oval to be filled
- * @param y the y coordinate of the upper left corner of the oval to be filled
- * @param width the width of the oval to be filled
- * @param height the height of the oval to be filled
- *
- * @exception SWTException <ul>
- * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
- * </ul>
- *
- * @see #drawOval
- */
-public void fillOval (int x, int y, int width, int height) {
- if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
-
- /* 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+1,y+height+1);
- 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>
- * @exception SWTException <ul>
- * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
- * </ul>
- *
- * @see #drawPolygon
- */
-public void fillPolygon(int[] pointArray) {
- if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- 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
- *
- * @exception SWTException <ul>
- * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
- * </ul>
- *
- * @see #drawRectangle
- */
-public void fillRectangle (int x, int y, int width, int height) {
- if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- int rop2 = 0;
- if (OS.IsWinCE) {
- rop2 = OS.SetROP2(handle, OS.R2_COPYPEN);
- OS.SetROP2(handle, rop2);
- } else {
- rop2 = OS.GetROP2(handle);
- }
- int dwRop = rop2 == OS.R2_XORPEN ? OS.PATINVERT : OS.PATCOPY;
- OS.PatBlt(handle, x, y, width, height, dwRop);
-}
-
-/**
- * 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>
- * @exception SWTException <ul>
- * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</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
- *
- * @exception SWTException <ul>
- * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
- * </ul>
- *
- * @see #drawRoundRectangle
- */
-public void fillRoundRectangle (int x, int y, int width, int height, int arcWidth, int arcHeight) {
- if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- 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
- *
- * @exception SWTException <ul>
- * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
- * </ul>
- */
-public int getAdvanceWidth(char ch) {
- if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- if (OS.IsWinCE) {
- SIZE size = new SIZE();
- OS.GetTextExtentPoint32W(handle, new char[]{ch}, 1, size);
- return size.cx;
- }
- int tch = ch;
- if (ch > 0x7F) {
- TCHAR buffer = new TCHAR(getCodePage(), ch, false);
- tch = buffer.tcharAt(0);
- }
- int[] width = new int[1];
- OS.GetCharWidth(handle, tch, tch, width);
- return width[0];
-}
-
-/**
- * Returns the background color.
- *
- * @return the receiver's background color
- *
- * @exception SWTException <ul>
- * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
- * </ul>
- */
-public Color getBackground() {
- if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- 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
- *
- * @exception SWTException <ul>
- * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
- * </ul>
- */
-public int getCharWidth(char ch) {
- if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
-
- /* GetCharABCWidths only succeeds on truetype fonts */
- if (!OS.IsWinCE) {
- int tch = ch;
- if (ch > 0x7F) {
- TCHAR buffer = new TCHAR(getCodePage(), ch, false);
- tch = buffer.tcharAt (0);
- }
- int[] width = new int[3];
- if (OS.GetCharABCWidths(handle, tch, tch, width)) {
- return width[1];
- }
- }
-
- /* It wasn't a truetype font */
- TEXTMETRIC tm = new TEXTMETRIC();
- OS.GetTextMetricsW(handle, tm);
- SIZE size = new SIZE();
- OS.GetTextExtentPoint32W(handle, new char[]{ch}, 1, 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
- *
- * @exception SWTException <ul>
- * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
- * </ul>
- */
-public Rectangle getClipping() {
- if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- 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>
- * @exception SWTException <ul>
- * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
- * </ul>
- */
-public void getClipping (Region region) {
- if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- if (region == null) SWT.error (SWT.ERROR_NULL_ARGUMENT);
- 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);
-}
-
-int getCodePage () {
- if (OS.IsWinCE) return OS.GetACP();
- int[] lpCs = new int[8];
- int cs = OS.GetTextCharset(handle);
- OS.TranslateCharsetInfo(cs, lpCs, OS.TCI_SRCCHARSET);
- return lpCs[1];
-}
-
-/**
- * Returns the font currently being used by the receiver
- * to draw and measure text.
- *
- * @return the receiver's font
- *
- * @exception SWTException <ul>
- * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
- * </ul>
- */
-public Font getFont () {
- if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- 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
- *
- * @exception SWTException <ul>
- * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
- * </ul>
- */
-public FontMetrics getFontMetrics() {
- if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- 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
- *
- * @exception SWTException <ul>
- * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
- * </ul>
- */
-public Color getForeground() {
- if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- 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
- *
- * @exception SWTException <ul>
- * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
- * </ul>
- */
-public int getLineStyle() {
- if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- 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
- *
- * @exception SWTException <ul>
- * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
- * </ul>
- */
-public int getLineWidth() {
- if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- 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
- *
- * @exception SWTException <ul>
- * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
- * </ul>
- */
-public boolean getXORMode() {
- if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- int rop2 = 0;
- if (OS.IsWinCE) {
- rop2 = OS.SetROP2 (handle, OS.R2_COPYPEN);
- OS.SetROP2 (handle, rop2);
- } else {
- rop2 = OS.GetROP2(handle);
- }
- return rop2 == 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
- *
- * @exception SWTException <ul>
- * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
- * </ul>
- *
- * @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
- *
- * @exception SWTException <ul>
- * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
- * </ul>
- */
-public boolean isClipped() {
- if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- 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>
- * <li>ERROR_INVALID_ARGUMENT - if the color has been disposed</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
- * </ul>
- */
-public void setBackground (Color color) {
- if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- if (color == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
- if (color.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
- 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
- *
- * @exception SWTException <ul>
- * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
- * </ul>
- */
-public void setClipping (int x, int y, int width, int height) {
- if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- 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 SWTException <ul>
- * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
- * </ul>
- */
-public void setClipping (Rectangle rect) {
- if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- if (rect == null) {
- 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.
- *
- * @exception SWTException <ul>
- * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
- * </ul>
- */
-public void setClipping (Region region) {
- if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- 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
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_INVALID_ARGUMENT - if the font has been disposed</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
- * </ul>
- */
-
-public void setFont (Font font) {
- if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- if (font == null) {
- OS.SelectObject(handle, data.device.systemFont);
- } else {
- if (font.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
- 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
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the color is null</li>
- * <li>ERROR_INVALID_ARGUMENT - if the color has been disposed</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
- * </ul>
- */
-public void setForeground (Color color) {
- if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- if (color == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
- if (color.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
- 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
- *
- * @exception SWTException <ul>
- * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
- * </ul>
- */
-public void setLineStyle(int lineStyle) {
- if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- 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;
- OS.SetBkMode (handle, style == OS.PS_SOLID ? OS.OPAQUE : OS.TRANSPARENT);
- 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
- *
- * @exception SWTException <ul>
- * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
- * </ul>
- */
-public void setLineWidth(int lineWidth) {
- if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- 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
- *
- * @exception SWTException <ul>
- * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
- * </ul>
- */
-public void setXORMode(boolean xor) {
- if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- 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
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the string is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
- * </ul>
- */
-public Point stringExtent(String string) {
- if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- if (string == null) SWT.error (SWT.ERROR_NULL_ARGUMENT);
- SIZE size = new SIZE();
- int length = string.length();
- if (length == 0) {
-// OS.GetTextExtentPoint32(handle, SPACE, SPACE.length(), size);
- OS.GetTextExtentPoint32W(handle, new char[]{' '}, 1, size);
- return new Point(0, size.cy);
- } else {
-// TCHAR buffer = new TCHAR (getCodePage(), string, false);
- char[] buffer = new char [length];
- string.getChars(0, length, buffer, 0);
- OS.GetTextExtentPoint32W(handle, 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
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the string is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
- * </ul>
- */
-public Point textExtent(String string) {
- return textExtent(string, SWT.DRAW_DELIMITER | SWT.DRAW_TAB);
-}
-
-/**
- * Returns the extent of the given string. Tab expansion, line
- * delimiter and mnemonic processing are performed according to
- * the specified flags, which can be a combination of:
- * <dl>
- * <dt><b>DRAW_DELIMITER</b></dt>
- * <dd>draw multiple lines</dd>
- * <dt><b>DRAW_TAB</b></dt>
- * <dd>expand tabs</dd>
- * <dt><b>DRAW_MNEMONIC</b></dt>
- * <dd>underline the mnemonic character</dd>
- * <dt><b>DRAW_TRANSPARENT</b></dt>
- * <dd>transparent background</dd>
- * </dl>
- * <p>
- * The <em>extent</em> of a string is the width and height of
- * the rectangular area it would cover if drawn in a particular
- * font (in this case, the current font in the receiver).
- * </p>
- *
- * @param string the string to measure
- * @param flags the flags specifing how to process the text
- * @return a point containing the extent of the string
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the string is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
- * </ul>
- */
-public Point textExtent(String string, int flags) {
- if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- if (string == null) SWT.error (SWT.ERROR_NULL_ARGUMENT);
- if (string.length () == 0) {
- SIZE size = new SIZE();
-// OS.GetTextExtentPoint32(handle, SPACE, SPACE.length(), size);
- OS.GetTextExtentPoint32W(handle, new char [] {' '}, 1, size);
- return new Point(0, size.cy);
- }
- RECT rect = new RECT();
- TCHAR buffer = new TCHAR(getCodePage(), string, false);
- int uFormat = OS.DT_LEFT | OS.DT_CALCRECT;
- if ((flags & SWT.DRAW_DELIMITER) == 0) uFormat |= OS.DT_SINGLELINE;
- if ((flags & SWT.DRAW_TAB) != 0) uFormat |= OS.DT_EXPANDTABS;
- if ((flags & SWT.DRAW_MNEMONIC) == 0) uFormat |= OS.DT_NOPREFIX;
- OS.DrawText(handle, buffer, buffer.length(), rect, uFormat);
- return new Point(rect.right, rect.bottom);
-}
-
-/**
- * Returns a string containing a concise, human-readable
- * description of the receiver.
- *
- * @return a string representation of the receiver
- */
-public String toString () {
- if (isDisposed()) return "GC {*DISPOSED*}";
- return "GC {" + handle + "}";
-}
-
-/**
- * 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;
-}
-
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+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 org.eclipse.swt.events.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;
+
+/**
+ * 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_NULL_ARGUMENT - if there is no current device</li>
+ * <li>ERROR_INVALID_ARGUMENT
+ * - if the drawable is an image that is not a bitmap or an icon
+ * - if the drawable is an image or printer that is already selected
+ * into another graphics context</li>
+ * </ul>
+ * @exception SWTError <ul>
+ * <li>ERROR_NO_HANDLES if a handle could not be obtained for gc creation</li>
+ * </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 or has been disposed</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ */
+public void copyArea(Image image, int x, int y) {
+ if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ if (image == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ if (image.type != SWT.BITMAP || image.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+
+ /* 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
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ */
+public void copyArea(int srcX, int srcY, int width, int height, int destX, int destY) {
+ if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+
+ /*
+ * Feature in WinCE. The function WindowFromDC is not part of the
+ * WinCE SDK. The fix is to remember the HWND.
+ */
+ int hwnd = data.hwnd;
+ 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);
+ int res = OS.ScrollWindowEx(hwnd, destX - srcX, destY - srcY, lprcScroll, lprcClip, 0, null, OS.SW_INVALIDATE | OS.SW_ERASE);
+
+ /*
+ * Feature in WinCE. ScrollWindowEx does not accept combined
+ * vertical and horizontal scrolling. The fix is to do a
+ * BitBlt and invalidate the appropriate source area.
+ */
+ if (res == 0 && OS.IsWinCE) {
+ OS.BitBlt(handle, destX, destY, width, height, handle, srcX, srcY, OS.SRCCOPY);
+ int deltaX = destX - srcX, deltaY = destY - srcY;
+ boolean disjoint = (destX + width < srcX) || (srcX + width < destX) || (destY + height < srcY) || (srcY + height < destY);
+ if (disjoint) {
+ OS.InvalidateRect(hwnd, lprcScroll, true);
+ } else {
+ if (deltaX != 0) {
+ int newX = destX - deltaX;
+ if (deltaX < 0) newX = destX + width;
+ OS.SetRect(lprcScroll, newX, srcY, newX + Math.abs(deltaX), srcY + height);
+ OS.InvalidateRect(hwnd, lprcScroll, true);
+ }
+ if (deltaY != 0) {
+ int newY = destY - deltaY;
+ if (deltaY < 0) newY = destY + height;
+ OS.SetRect(lprcScroll, srcX, newY, srcX + width, newY + Math.abs(deltaY));
+ OS.InvalidateRect(hwnd, lprcScroll, true);
+ }
+ }
+ }
+ }
+}
+
+int createDIB(int width, int height) {
+ short depth = 32;
+
+ BITMAPINFOHEADER bmiHeader = new BITMAPINFOHEADER();
+ bmiHeader.biSize = BITMAPINFOHEADER.sizeof;
+ bmiHeader.biWidth = width;
+ bmiHeader.biHeight = -height;
+ bmiHeader.biPlanes = 1;
+ bmiHeader.biBitCount = depth;
+ if (OS.IsWinCE) bmiHeader.biCompression = OS.BI_BITFIELDS;
+ else bmiHeader.biCompression = OS.BI_RGB;
+ byte[] bmi = new byte[BITMAPINFOHEADER.sizeof + (OS.IsWinCE ? 12 : 0)];
+ OS.MoveMemory(bmi, bmiHeader, BITMAPINFOHEADER.sizeof);
+ /* Set the rgb colors into the bitmap info */
+ if (OS.IsWinCE) {
+ int redMask = 0xFF00;
+ int greenMask = 0xFF0000;
+ int blueMask = 0xFF000000;
+ /* big endian */
+ int offset = BITMAPINFOHEADER.sizeof;
+ bmi[offset] = (byte)((redMask & 0xFF000000) >> 24);
+ bmi[offset + 1] = (byte)((redMask & 0xFF0000) >> 16);
+ bmi[offset + 2] = (byte)((redMask & 0xFF00) >> 8);
+ bmi[offset + 3] = (byte)((redMask & 0xFF) >> 0);
+ bmi[offset + 4] = (byte)((greenMask & 0xFF000000) >> 24);
+ bmi[offset + 5] = (byte)((greenMask & 0xFF0000) >> 16);
+ bmi[offset + 6] = (byte)((greenMask & 0xFF00) >> 8);
+ bmi[offset + 7] = (byte)((greenMask & 0xFF) >> 0);
+ bmi[offset + 8] = (byte)((blueMask & 0xFF000000) >> 24);
+ bmi[offset + 9] = (byte)((blueMask & 0xFF0000) >> 16);
+ bmi[offset + 10] = (byte)((blueMask & 0xFF00) >> 8);
+ bmi[offset + 11] = (byte)((blueMask & 0xFF) >> 0);
+ }
+
+ 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;
+ if (data.device.isDisposed()) 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>
+ * @exception SWTException <ul>
+ * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ */
+public void drawArc (int x, int y, int width, int height, int startAngle, int endAngle) {
+ if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ if (width < 0) {
+ x = x + width;
+ width = -width;
+ }
+ if (height < 0) {
+ y = y + height;
+ height = -height;
+ }
+ if (width == 0 || height == 0 || endAngle == 0) {
+ SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+ }
+ /*
+ * Feature in WinCE. The function Arc is not present in the
+ * WinCE SDK. The fix is to emulate arc drawing by using
+ * Polyline.
+ */
+ if (OS.IsWinCE) {
+ /* compute arc with a simple linear interpolation */
+ if (endAngle < 0) {
+ startAngle += endAngle;
+ endAngle = -endAngle;
+ }
+ if (endAngle > 360) endAngle = 360;
+ int[] points = new int[(endAngle + 1) * 2];
+ int cteX = 2 * x + width;
+ int cteY = 2 * y + height;
+ int index = 0;
+ for (int i = 0; i <= endAngle; i++) {
+ points[index++] = (Compatibility.cos(startAngle + i, width) + cteX) >> 1;
+ points[index++] = (cteY - Compatibility.sin(startAngle + i, height)) >> 1;
+ }
+ OS.Polyline(handle, points, points.length / 2);
+ } else {
+ int x1, y1, x2, y2,tmp;
+ boolean isNegative;
+ 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 = Compatibility.cos(startAngle, width) + x + width/2;
+ y1 = -1 * Compatibility.sin(startAngle, height) + y + height/2;
+
+ x2 = Compatibility.cos(endAngle, width) + x + width/2;
+ y2 = -1 * Compatibility.sin(endAngle, 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 foreground color.
+ *
+ * @param x the x coordinate of the rectangle
+ * @param y the y coordinate of the rectangle
+ * @param width the width of the rectangle
+ * @param height the height of the rectangle
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ *
+ * @see #drawRectangle
+ */
+public void drawFocus (int x, int y, int width, int height) {
+ if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ 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 image has been disposed</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>
+ * @exception SWTException <ul>
+ * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ */
+public void drawImage(Image image, int x, int y) {
+ if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ if (image == null) SWT.error (SWT.ERROR_NULL_ARGUMENT);
+ if (image.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+ drawImage(image, 0, 0, -1, -1, x, y, -1, -1, true);
+}
+
+/**
+ * Copies a rectangular area from the source image into a (potentially
+ * different sized) rectangular area in the receiver. If the source
+ * and destination areas are of differing sizes, then the source
+ * area will be stretched or shrunk to fit the destination area
+ * as it is copied. The copy fails if any part of the source rectangle
+ * lies outside the bounds of the source image, or if any of the width
+ * or height arguments are negative.
+ *
+ * @param image the source image
+ * @param srcX the x coordinate in the source image to copy from
+ * @param srcY the y coordinate in the source image to copy from
+ * @param srcWidth the width in pixels to copy from the source
+ * @param srcHeight the height in pixels to copy from the source
+ * @param destX the x coordinate in the destination to copy to
+ * @param destY the y coordinate in the destination to copy to
+ * @param destWidth the width in pixels of the destination rectangle
+ * @param destHeight the height in pixels of the destination rectangle
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if the image is null</li>
+ * <li>ERROR_INVALID_ARGUMENT - if the image has been disposed</li>
+ * <li>ERROR_INVALID_ARGUMENT - if any of the width or height arguments are negative.
+ * <li>ERROR_INVALID_ARGUMENT - if the source rectangle is not contained within the bounds of the source image</li>
+ * </ul>
+ * @exception SWTError <ul>
+ * <li>ERROR_NO_HANDLES - if no handles are available to perform the operation</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ */
+public void drawImage(Image image, int srcX, int srcY, int srcWidth, int srcHeight, int destX, int destY, int destWidth, int destHeight) {
+ if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ if (srcWidth == 0 || srcHeight == 0 || destWidth == 0 || destHeight == 0) return;
+ if (srcX < 0 || srcY < 0 || srcWidth < 0 || srcHeight < 0 || destWidth < 0 || destHeight < 0) {
+ SWT.error (SWT.ERROR_INVALID_ARGUMENT);
+ }
+ if (image == null) SWT.error (SWT.ERROR_NULL_ARGUMENT);
+ if (image.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+ drawImage(image, srcX, srcY, srcWidth, srcHeight, destX, destY, destWidth, destHeight, false);
+}
+
+void drawImage(Image srcImage, int srcX, int srcY, int srcWidth, int srcHeight, int destX, int destY, int destWidth, int destHeight, boolean simple) {
+ 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();
+ if (OS.IsWinCE) {
+ Image.GetIconInfo(srcImage, srcIconInfo);
+ } else {
+ 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);
+ if (!OS.IsWinCE) 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.
+ */
+ 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 = Math.max(1, sx2 - sx1);
+ srcHeight = Math.max(1, sy2 - sy1);
+
+ /* Create resources */
+ int srcHdc = OS.CreateCompatibleDC(handle);
+ int oldSrcBitmap = OS.SelectObject(srcHdc, srcImage.handle);
+ int memHdc = OS.CreateCompatibleDC(handle);
+ int memDib = createDIB(Math.max(srcWidth, destWidth), Math.max(srcHeight, destHeight));
+ 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.BitBlt(memHdc, 0, 0, srcWidth, srcHeight, srcHdc, srcX, srcY, OS.SRCCOPY);
+ byte[] srcData = new byte[sizeInBytes];
+ OS.MoveMemory(srcData, dibBM.bmBits, sizeInBytes);
+
+ /* Merge the alpha channel in place */
+ int alpha = srcImage.alpha;
+ final boolean hasAlphaChannel = (srcImage.alpha == -1);
+ if (hasAlphaChannel) {
+ final int apinc = imgWidth - srcWidth;
+ final int spinc = dibBM.bmWidthBytes - srcWidth * 4;
+ int ap = srcY * imgWidth + srcX, sp = 3;
+ byte[] alphaData = srcImage.alphaData;
+ for (int y = 0; y < srcHeight; ++y) {
+ for (int x = 0; x < srcWidth; ++x) {
+ srcData[sp] = alphaData[ap++];
+ sp += 4;
+ }
+ ap += apinc;
+ sp += spinc;
+ }
+ }
+
+ /* Scale the foreground pixels with alpha */
+ if (!OS.IsWinCE) OS.SetStretchBltMode(memHdc, OS.COLORONCOLOR);
+ OS.MoveMemory(dibBM.bmBits, srcData, sizeInBytes);
+ /*
+ * Bug in WinCE and Win98. StretchBlt does not correctly stretch when
+ * the source and destination HDCs are the same. The workaround is to
+ * stretch to a temporary HDC and blit back into the original HDC.
+ * Note that on WinCE StretchBlt correctly compresses the image when the
+ * source and destination HDCs are the same.
+ */
+ if ((OS.IsWinCE && (destWidth > srcWidth || destHeight > srcHeight)) || (!OS.IsWinNT && !OS.IsWinCE)) {
+ int tempHdc = OS.CreateCompatibleDC(handle);
+ int tempDib = createDIB(destWidth, destHeight);
+ int oldTempBitmap = OS.SelectObject(tempHdc, tempDib);
+ OS.StretchBlt(tempHdc, 0, 0, destWidth, destHeight, memHdc, 0, 0, srcWidth, srcHeight, OS.SRCCOPY);
+ OS.BitBlt(memHdc, 0, 0, destWidth, destHeight, tempHdc, 0, 0, OS.SRCCOPY);
+ OS.SelectObject(tempHdc, oldTempBitmap);
+ OS.DeleteObject(tempDib);
+ OS.DeleteDC(tempHdc);
+ } else {
+ OS.StretchBlt(memHdc, 0, 0, destWidth, destHeight, memHdc, 0, 0, srcWidth, srcHeight, OS.SRCCOPY);
+ }
+ OS.MoveMemory(srcData, dibBM.bmBits, sizeInBytes);
+
+ /* Compose the pixels */
+ final int dpinc = dibBM.bmWidthBytes - destWidth * 4;
+ int dp = 0;
+ for (int y = 0; y < destHeight; ++y) {
+ for (int x = 0; x < destWidth; ++x) {
+ if (hasAlphaChannel) alpha = srcData[dp + 3] & 0xff;
+ destData[dp] += ((srcData[dp] & 0xff) - (destData[dp] & 0xff)) * alpha / 255;
+ destData[dp + 1] += ((srcData[dp + 1] & 0xff) - (destData[dp + 1] & 0xff)) * alpha / 255;
+ destData[dp + 2] += ((srcData[dp + 2] & 0xff) - (destData[dp + 2] & 0xff)) * alpha / 255;
+ dp += 4;
+ }
+ dp += dpinc;
+ }
+
+ /* 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 */
+ if (OS.IsWinCE) {
+ byte[] pBits = new byte[1];
+ OS.MoveMemory(pBits, bm.bmBits, 1);
+ byte oldValue = pBits[0];
+ int mask = (0xFF << (8 - bm.bmBitsPixel)) & 0x00FF;
+ pBits[0] = (byte)((srcImage.transparentPixel << (8 - bm.bmBitsPixel)) | (pBits[0] & ~mask));
+ OS.MoveMemory(bm.bmBits, pBits, 1);
+ int color = OS.GetPixel(srcHdc, 0, 0);
+ pBits[0] = oldValue;
+ OS.MoveMemory(bm.bmBits, pBits, 1);
+ transBlue = (color & 0xFF0000) >> 16;
+ transGreen = (color & 0xFF00) >> 8;
+ transRed = color & 0xFF;
+ } else {
+ int maxColors = 1 << bm.bmBitsPixel;
+ byte[] oldColors = new byte[maxColors * 4];
+ 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;
+ /* Set the few fields necessary to get the RGB data out */
+ BITMAPINFOHEADER bmiHeader = new BITMAPINFOHEADER();
+ bmiHeader.biSize = BITMAPINFOHEADER.sizeof;
+ bmiHeader.biPlanes = bm.bmPlanes;
+ bmiHeader.biBitCount = bm.bmBitsPixel;
+ byte[] bmi = new byte[BITMAPINFOHEADER.sizeof + numColors * 4];
+ OS.MoveMemory(bmi, bmiHeader, BITMAPINFOHEADER.sizeof);
+ if (OS.IsWinCE) SWT.error(SWT.ERROR_NOT_IMPLEMENTED);
+ OS.GetDIBits(srcHdc, srcImage.handle, 0, 0, 0, bmi, OS.DIB_RGB_COLORS);
+ int offset = BITMAPINFOHEADER.sizeof + 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;
+ }
+ }
+
+ if (OS.IsWinCE) {
+ /*
+ * Note in WinCE. TransparentImage uses the first entry of a palette
+ * based image when there are multiple entries that have the same
+ * transparent color.
+ */
+ int transparentColor = transBlue << 16 | transGreen << 8 | transRed;
+ OS.TransparentImage(handle, destX, destY, destWidth, destHeight,
+ srcHdc, srcX, srcY, srcWidth, srcHeight, transparentColor);
+ } else {
+ /* Create the mask for the source image */
+ int maskHdc = OS.CreateCompatibleDC(hDC);
+ int maskBitmap = OS.CreateBitmap(imgWidth, imgHeight, 1, 1, null);
+ int oldMaskBitmap = OS.SelectObject(maskHdc, maskBitmap);
+ OS.SetBkColor(srcHdc, (transBlue << 16) | (transGreen << 8) | transRed);
+ OS.BitBlt(maskHdc, 0, 0, imgWidth, imgHeight, 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);
+ if (!OS.IsWinCE) 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 mode = 0, rop2 = 0;
+ if (!OS.IsWinCE) {
+ rop2 = OS.GetROP2(handle);
+ mode = OS.SetStretchBltMode(handle, OS.COLORONCOLOR);
+ } else {
+ rop2 = OS.SetROP2 (handle, OS.R2_COPYPEN);
+ OS.SetROP2 (handle, rop2);
+ }
+ int dwRop = rop2 == OS.R2_XORPEN ? OS.SRCINVERT : OS.SRCCOPY;
+ OS.StretchBlt(handle, destX, destY, destWidth, destHeight, srcHdc, srcX, srcY, srcWidth, srcHeight, dwRop);
+ if (!OS.IsWinCE) {
+ OS.SetStretchBltMode(handle, mode);
+ }
+ 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
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ */
+public void drawLine (int x1, int y1, int x2, int y2) {
+ if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ if (OS.IsWinCE) {
+ int [] points = new int [] {x1, y1, x2, y2};
+ OS.Polyline (handle, points, points.length / 2);
+ } else {
+ 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
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ */
+public void drawOval (int x, int y, int width, int height) {
+ if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ // 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+1,y+height+1);
+ 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>
+ * @exception SWTException <ul>
+ * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ */
+public void drawPolygon(int[] pointArray) {
+ if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ if (pointArray == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ 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>
+ * @exception SWTException <ul>
+ * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ */
+public void drawPolyline(int[] pointArray) {
+ if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ if (pointArray == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ 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
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ */
+public void drawRectangle (int x, int y, int width, int height) {
+ if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ 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>
+ * @exception SWTException <ul>
+ * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ */
+public void drawRectangle (Rectangle rect) {
+ if (rect == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ drawRectangle (rect.x, rect.y, rect.width, rect.height);
+}
+
+/**
+ * Draws the outline of the round-cornered rectangle specified by
+ * the arguments, using the receiver's foreground color. The left and
+ * right edges of the rectangle are at <code>x</code> and <code>x + width</code>.
+ * The top and bottom edges are at <code>y</code> and <code>y + height</code>.
+ * The <em>roundness</em> of the corners is specified by the
+ * <code>arcWidth</code> and <code>arcHeight</code> arguments.
+ *
+ * @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
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ */
+public void drawRoundRectangle (int x, int y, int width, int height, int arcWidth, int arcHeight) {
+ if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ if (OS.IsWinCE) {
+ /*
+ * Bug in WinCE PPC. On certain devices, RoundRect does not draw
+ * all the pixels. The workaround is to draw a round rectangle
+ * using lines and arcs.
+ */
+ if (width == 0 || height == 0) return;
+ if (arcWidth == 0 || arcHeight == 0) {
+ drawRectangle(x, y, width, height);
+ return;
+ }
+ if (width < 0) {
+ x += width;
+ width = -width;
+ }
+ if (height < 0) {
+ y += height;
+ height = -height;
+ };
+ if (arcWidth < 0) arcWidth = -arcWidth;
+ if (arcHeight < 0) arcHeight = -arcHeight;
+ if (arcWidth > width) arcWidth = width;
+ if (arcHeight > height) arcHeight = height;
+
+ if (arcWidth < width) {
+ drawLine(x+arcWidth/2, y, x+width-arcWidth/2, y);
+ drawLine(x+arcWidth/2, y+height-1, x+width-arcWidth/2, y+height-1);
+ }
+ if (arcHeight < height) {
+ drawLine(x, y+arcHeight/2, x, y+height-arcHeight/2);
+ drawLine(x+width-1, y+arcHeight/2, x+width-1, y+height-arcHeight/2);
+ }
+ if (arcWidth != 0 && arcHeight != 0) {
+ drawArc(x, y, arcWidth, arcHeight, 90, 90);
+ drawArc(x+width-arcWidth-1, y, arcWidth, arcHeight, 0, 90);
+ drawArc(x+width-arcWidth-1, y+height-arcHeight-1, arcWidth, arcHeight, 0, -90);
+ drawArc(x, y+height-arcHeight-1, arcWidth, arcHeight, 180, 90);
+ }
+ } else {
+ 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>
+ * @exception SWTException <ul>
+ * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ */
+public void drawString (String string, int x, int y) {
+ drawString(string, x, y, false);
+}
+
+/**
+ * Draws the given string, using the receiver's current font and
+ * foreground color. No tab expansion or carriage return processing
+ * will be performed. If <code>isTransparent</code> is <code>true</code>,
+ * then the background of the rectangular area where the string is being
+ * drawn will not be modified, otherwise it will be filled with the
+ * receiver's background color.
+ *
+ * @param string the string to be drawn
+ * @param x the x coordinate of the top left corner of the rectangular area where the string is to be drawn
+ * @param y the y coordinate of the top left corner of the rectangular area where the string is to be drawn
+ * @param isTransparent if <code>true</code> the background will be transparent, otherwise it will be opaque
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if the string is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ */
+public void drawString (String string, int x, int y, boolean isTransparent) {
+ if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ if (string == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+// TCHAR buffer = new TCHAR (getCodePage(), string, false);
+ int length = string.length();
+ char[] buffer = new char [length];
+ string.getChars(0, length, buffer, 0);
+ int oldBkMode = OS.SetBkMode(handle, isTransparent ? OS.TRANSPARENT : OS.OPAQUE);
+ OS.ExtTextOutW(handle, x, y, 0, null, buffer, length, null);
+ OS.SetBkMode(handle, oldBkMode);
+}
+
+/**
+ * Draws the given string, using the receiver's current font and
+ * foreground color. Tab expansion and carriage return processing
+ * are performed. The background of the rectangular area where
+ * the text is being drawn will be filled with the receiver's
+ * background color.
+ *
+ * @param string the string to be drawn
+ * @param x the x coordinate of the top left corner of the rectangular area where the text is to be drawn
+ * @param y the y coordinate of the top left corner of the rectangular area where the text is to be drawn
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if the string is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ */
+public void drawText (String string, int x, int y) {
+ drawText(string, x, y, SWT.DRAW_DELIMITER | SWT.DRAW_TAB);
+}
+
+/**
+ * Draws the given string, using the receiver's current font and
+ * foreground color. Tab expansion and carriage return processing
+ * are performed. If <code>isTransparent</code> is <code>true</code>,
+ * then the background of the rectangular area where the text is being
+ * drawn will not be modified, otherwise it will be filled with the
+ * receiver's background color.
+ *
+ * @param string the string to be drawn
+ * @param x the x coordinate of the top left corner of the rectangular area where the text is to be drawn
+ * @param y the y coordinate of the top left corner of the rectangular area where the text is to be drawn
+ * @param isTransparent if <code>true</code> the background will be transparent, otherwise it will be opaque
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if the string is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ */
+public void drawText (String string, int x, int y, boolean isTransparent) {
+ int flags = SWT.DRAW_DELIMITER | SWT.DRAW_TAB;
+ if (isTransparent) flags |= SWT.DRAW_TRANSPARENT;
+ drawText(string, x, y, flags);
+}
+
+/**
+ * Draws the given string, using the receiver's current font and
+ * foreground color. Tab expansion, line delimiter and mnemonic
+ * processing are performed according to the specified flags. If
+ * <code>flags</code> includes <code>DRAW_TRANSPARENT</code>,
+ * then the background of the rectangular area where the text is being
+ * drawn will not be modified, otherwise it will be filled with the
+ * receiver's background color.
+ * <p>
+ * The parameter <code>flags</code> may be a combination of:
+ * <dl>
+ * <dt><b>DRAW_DELIMITER</b></dt>
+ * <dd>draw multiple lines</dd>
+ * <dt><b>DRAW_TAB</b></dt>
+ * <dd>expand tabs</dd>
+ * <dt><b>DRAW_MNEMONIC</b></dt>
+ * <dd>underline the mnemonic character</dd>
+ * <dt><b>DRAW_TRANSPARENT</b></dt>
+ * <dd>transparent background</dd>
+ * </dl>
+ * </p>
+ *
+ * @param string the string to be drawn
+ * @param x the x coordinate of the top left corner of the rectangular area where the text is to be drawn
+ * @param y the y coordinate of the top left corner of the rectangular area where the text is to be drawn
+ * @param flags the flags specifing how to process the text
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if the string is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ */
+public void drawText (String string, int x, int y, int flags) {
+ if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ if (string == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ RECT rect = new RECT();
+ OS.SetRect(rect, x, y, 0x7FFF, 0x7FFF);
+ TCHAR buffer = new TCHAR(getCodePage(), string, false);
+ int uFormat = OS.DT_LEFT;
+ if ((flags & SWT.DRAW_DELIMITER) == 0) uFormat |= OS.DT_SINGLELINE;
+ if ((flags & SWT.DRAW_TAB) != 0) uFormat |= OS.DT_EXPANDTABS;
+ if ((flags & SWT.DRAW_MNEMONIC) == 0) uFormat |= OS.DT_NOPREFIX;
+ int oldBkMode = OS.SetBkMode(handle, (flags & SWT.DRAW_TRANSPARENT) != 0 ? OS.TRANSPARENT : OS.OPAQUE);
+ OS.DrawText(handle, buffer, buffer.length(), rect, uFormat);
+ OS.SetBkMode(handle, oldBkMode);
+}
+
+/**
+ * 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>
+ * @exception SWTException <ul>
+ * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ *
+ * @see #drawArc
+ */
+public void fillArc (int x, int y, int width, int height, int startAngle, int endAngle) {
+ if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+
+ if (width < 0) {
+ x = x + width;
+ width = -width;
+ }
+ if (height < 0) {
+ y = y + height;
+ height = -height;
+ }
+
+ if (width == 0 || height == 0 || endAngle == 0) {
+ SWT.error (SWT.ERROR_INVALID_ARGUMENT);
+ }
+
+ /*
+ * Feature in WinCE. The function Pie is not present in the
+ * WinCE SDK. The fix is to emulate it by using Polygon.
+ */
+ if (OS.IsWinCE) {
+ /* compute arc with a simple linear interpolation */
+ if (endAngle < 0) {
+ startAngle += endAngle;
+ endAngle = -endAngle;
+ }
+ boolean drawSegments = true;
+ if (endAngle >= 360) {
+ endAngle = 360;
+ drawSegments = false;
+ }
+ int[] points = new int[(endAngle + 1) * 2 + (drawSegments ? 4 : 0)];
+ int cteX = 2 * x + width;
+ int cteY = 2 * y + height;
+ int index = (drawSegments ? 2 : 0);
+ for (int i = 0; i <= endAngle; i++) {
+ points[index++] = (Compatibility.cos(startAngle + i, width) + cteX) >> 1;
+ points[index++] = (cteY - Compatibility.sin(startAngle + i, height)) >> 1;
+ }
+ if (drawSegments) {
+ points[0] = points[points.length - 2] = cteX >> 1;
+ points[1] = points[points.length - 1] = cteY >> 1;
+ }
+ int nullPen = OS.GetStockObject(OS.NULL_PEN);
+ int oldPen = OS.SelectObject(handle, nullPen);
+ OS.Polygon(handle, points, points.length / 2);
+ OS.SelectObject(handle, oldPen);
+ } else {
+ int x1, y1, x2, y2,tmp;
+ boolean isNegative;
+ 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 = Compatibility.cos(startAngle, width) + x + width/2;
+ y1 = -1 * Compatibility.sin(startAngle, height) + y + height/2;
+
+ x2 = Compatibility.cos(endAngle, width) + x + width/2;
+ y2 = -1 * Compatibility.sin(endAngle, 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 the specified rectangle with a gradient
+ * sweeping from left to right or top to bottom progressing
+ * from the receiver's foreground color to its background color.
+ *
+ * @param x the x coordinate of the rectangle to be filled
+ * @param y the y coordinate of the rectangle to be filled
+ * @param width the width of the rectangle to be filled, may be negative
+ * (inverts direction of gradient if horizontal)
+ * @param height the height of the rectangle to be filled, may be negative
+ * (inverts direction of gradient if vertical)
+ * @param vertical if true sweeps from top to bottom, else
+ * sweeps from left to right
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ *
+ * @see #drawRectangle
+ */
+public void fillGradientRectangle(int x, int y, int width, int height, boolean vertical) {
+ if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ if (width == 0 || height == 0) return;
+ int fromColor = OS.GetTextColor(handle);
+ if (fromColor == OS.CLR_INVALID) {
+ fromColor = OS.GetSysColor(OS.COLOR_WINDOWTEXT);
+ }
+ int toColor = OS.GetBkColor(handle);
+ if (toColor == OS.CLR_INVALID) {
+ toColor = OS.GetSysColor(OS.COLOR_WINDOW);
+ }
+ boolean swapColors = false;
+ if (width < 0) {
+ x += width; width = -width;
+ if (! vertical) swapColors = true;
+ }
+ if (height < 0) {
+ y += height; height = -height;
+ if (vertical) swapColors = true;
+ }
+ if (swapColors) {
+ final int t = fromColor;
+ fromColor = toColor;
+ toColor = t;
+ }
+ final RGB fromRGB = new RGB(fromColor & 0xff, (fromColor >>> 8) & 0xff, (fromColor >>> 16) & 0xff);
+ final RGB toRGB = new RGB(toColor & 0xff, (toColor >>> 8) & 0xff, (toColor >>> 16) & 0xff);
+ if ((fromRGB.red == toRGB.red) && (fromRGB.green == toRGB.green) && (fromRGB.blue == toRGB.blue)) {
+ OS.PatBlt(handle, x, y, width, height, OS.PATCOPY);
+ return;
+ }
+
+ /* Use GradientFill if supported, only on Windows 98, 2000 and newer */
+ if (!OS.IsWinCE) {
+ final int hHeap = OS.GetProcessHeap();
+ final int pMesh = OS.HeapAlloc(hHeap, OS.HEAP_ZERO_MEMORY,
+ GRADIENT_RECT.sizeof + TRIVERTEX.sizeof * 2);
+ final int pVertex = pMesh + GRADIENT_RECT.sizeof;
+
+ GRADIENT_RECT gradientRect = new GRADIENT_RECT();
+ gradientRect.UpperLeft = 0;
+ gradientRect.LowerRight = 1;
+ OS.MoveMemory(pMesh, gradientRect, GRADIENT_RECT.sizeof);
+
+ TRIVERTEX trivertex = new TRIVERTEX();
+ trivertex.x = x;
+ trivertex.y = y;
+ trivertex.Red = (short)((fromRGB.red << 8) | fromRGB.red);
+ trivertex.Green = (short)((fromRGB.green << 8) | fromRGB.green);
+ trivertex.Blue = (short)((fromRGB.blue << 8) | fromRGB.blue);
+ trivertex.Alpha = -1;
+ OS.MoveMemory(pVertex, trivertex, TRIVERTEX.sizeof);
+
+ trivertex.x = x + width;
+ trivertex.y = y + height;
+ trivertex.Red = (short)((toRGB.red << 8) | toRGB.red);
+ trivertex.Green = (short)((toRGB.green << 8) | toRGB.green);
+ trivertex.Blue = (short)((toRGB.blue << 8) | toRGB.blue);
+ trivertex.Alpha = -1;
+ OS.MoveMemory(pVertex + TRIVERTEX.sizeof, trivertex, TRIVERTEX.sizeof);
+
+ boolean success = OS.GradientFill(handle, pVertex, 2, pMesh, 1,
+ vertical ? OS.GRADIENT_FILL_RECT_V : OS.GRADIENT_FILL_RECT_H);
+ OS.HeapFree(hHeap, 0, pMesh);
+ if (success) return;
+ }
+
+ final int depth = OS.GetDeviceCaps(handle, OS.BITSPIXEL);
+ final int bitResolution = (depth >= 24) ? 8 : (depth >= 15) ? 5 : 0;
+ ImageData.fillGradientRectangle(this, data.device,
+ x, y, width, height, vertical, fromRGB, toRGB,
+ bitResolution, bitResolution, bitResolution);
+}
+
+/**
+ * Fills the interior of an oval, within the specified
+ * rectangular area, with the receiver's background
+ * color.
+ *
+ * @param x the x coordinate of the upper left corner of the oval to be filled
+ * @param y the y coordinate of the upper left corner of the oval to be filled
+ * @param width the width of the oval to be filled
+ * @param height the height of the oval to be filled
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ *
+ * @see #drawOval
+ */
+public void fillOval (int x, int y, int width, int height) {
+ if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+
+ /* 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+1,y+height+1);
+ 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>
+ * @exception SWTException <ul>
+ * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ *
+ * @see #drawPolygon
+ */
+public void fillPolygon(int[] pointArray) {
+ if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ 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
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ *
+ * @see #drawRectangle
+ */
+public void fillRectangle (int x, int y, int width, int height) {
+ if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ int rop2 = 0;
+ if (OS.IsWinCE) {
+ rop2 = OS.SetROP2(handle, OS.R2_COPYPEN);
+ OS.SetROP2(handle, rop2);
+ } else {
+ rop2 = OS.GetROP2(handle);
+ }
+ int dwRop = rop2 == OS.R2_XORPEN ? OS.PATINVERT : OS.PATCOPY;
+ OS.PatBlt(handle, x, y, width, height, dwRop);
+}
+
+/**
+ * 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>
+ * @exception SWTException <ul>
+ * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</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
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ *
+ * @see #drawRoundRectangle
+ */
+public void fillRoundRectangle (int x, int y, int width, int height, int arcWidth, int arcHeight) {
+ if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ 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
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ */
+public int getAdvanceWidth(char ch) {
+ if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ if (OS.IsWinCE) {
+ SIZE size = new SIZE();
+ OS.GetTextExtentPoint32W(handle, new char[]{ch}, 1, size);
+ return size.cx;
+ }
+ int tch = ch;
+ if (ch > 0x7F) {
+ TCHAR buffer = new TCHAR(getCodePage(), ch, false);
+ tch = buffer.tcharAt(0);
+ }
+ int[] width = new int[1];
+ OS.GetCharWidth(handle, tch, tch, width);
+ return width[0];
+}
+
+/**
+ * Returns the background color.
+ *
+ * @return the receiver's background color
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ */
+public Color getBackground() {
+ if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ 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
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ */
+public int getCharWidth(char ch) {
+ if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+
+ /* GetCharABCWidths only succeeds on truetype fonts */
+ if (!OS.IsWinCE) {
+ int tch = ch;
+ if (ch > 0x7F) {
+ TCHAR buffer = new TCHAR(getCodePage(), ch, false);
+ tch = buffer.tcharAt (0);
+ }
+ int[] width = new int[3];
+ if (OS.GetCharABCWidths(handle, tch, tch, width)) {
+ return width[1];
+ }
+ }
+
+ /* It wasn't a truetype font */
+ TEXTMETRIC tm = new TEXTMETRIC();
+ OS.GetTextMetricsW(handle, tm);
+ SIZE size = new SIZE();
+ OS.GetTextExtentPoint32W(handle, new char[]{ch}, 1, 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
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ */
+public Rectangle getClipping() {
+ if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ 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>
+ * @exception SWTException <ul>
+ * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ */
+public void getClipping (Region region) {
+ if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ if (region == null) SWT.error (SWT.ERROR_NULL_ARGUMENT);
+ 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);
+}
+
+int getCodePage () {
+ if (OS.IsWinCE) return OS.GetACP();
+ int[] lpCs = new int[8];
+ int cs = OS.GetTextCharset(handle);
+ OS.TranslateCharsetInfo(cs, lpCs, OS.TCI_SRCCHARSET);
+ return lpCs[1];
+}
+
+/**
+ * Returns the font currently being used by the receiver
+ * to draw and measure text.
+ *
+ * @return the receiver's font
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ */
+public Font getFont () {
+ if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ 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
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ */
+public FontMetrics getFontMetrics() {
+ if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ 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
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ */
+public Color getForeground() {
+ if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ 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
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ */
+public int getLineStyle() {
+ if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ 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
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ */
+public int getLineWidth() {
+ if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ 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
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ */
+public boolean getXORMode() {
+ if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ int rop2 = 0;
+ if (OS.IsWinCE) {
+ rop2 = OS.SetROP2 (handle, OS.R2_COPYPEN);
+ OS.SetROP2 (handle, rop2);
+ } else {
+ rop2 = OS.GetROP2(handle);
+ }
+ return rop2 == 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
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ *
+ * @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
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ */
+public boolean isClipped() {
+ if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ 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>
+ * <li>ERROR_INVALID_ARGUMENT - if the color has been disposed</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ */
+public void setBackground (Color color) {
+ if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ if (color == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ if (color.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+ 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
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ */
+public void setClipping (int x, int y, int width, int height) {
+ if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ 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 SWTException <ul>
+ * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ */
+public void setClipping (Rectangle rect) {
+ if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ if (rect == null) {
+ 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.
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ */
+public void setClipping (Region region) {
+ if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ 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
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_INVALID_ARGUMENT - if the font has been disposed</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ */
+
+public void setFont (Font font) {
+ if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ if (font == null) {
+ OS.SelectObject(handle, data.device.systemFont);
+ } else {
+ if (font.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+ 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
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if the color is null</li>
+ * <li>ERROR_INVALID_ARGUMENT - if the color has been disposed</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ */
+public void setForeground (Color color) {
+ if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ if (color == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ if (color.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+ 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
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ */
+public void setLineStyle(int lineStyle) {
+ if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ 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;
+ OS.SetBkMode (handle, style == OS.PS_SOLID ? OS.OPAQUE : OS.TRANSPARENT);
+ 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
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ */
+public void setLineWidth(int lineWidth) {
+ if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ 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
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ */
+public void setXORMode(boolean xor) {
+ if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ 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
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if the string is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ */
+public Point stringExtent(String string) {
+ if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ if (string == null) SWT.error (SWT.ERROR_NULL_ARGUMENT);
+ SIZE size = new SIZE();
+ int length = string.length();
+ if (length == 0) {
+// OS.GetTextExtentPoint32(handle, SPACE, SPACE.length(), size);
+ OS.GetTextExtentPoint32W(handle, new char[]{' '}, 1, size);
+ return new Point(0, size.cy);
+ } else {
+// TCHAR buffer = new TCHAR (getCodePage(), string, false);
+ char[] buffer = new char [length];
+ string.getChars(0, length, buffer, 0);
+ OS.GetTextExtentPoint32W(handle, 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
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if the string is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ */
+public Point textExtent(String string) {
+ return textExtent(string, SWT.DRAW_DELIMITER | SWT.DRAW_TAB);
+}
+
+/**
+ * Returns the extent of the given string. Tab expansion, line
+ * delimiter and mnemonic processing are performed according to
+ * the specified flags, which can be a combination of:
+ * <dl>
+ * <dt><b>DRAW_DELIMITER</b></dt>
+ * <dd>draw multiple lines</dd>
+ * <dt><b>DRAW_TAB</b></dt>
+ * <dd>expand tabs</dd>
+ * <dt><b>DRAW_MNEMONIC</b></dt>
+ * <dd>underline the mnemonic character</dd>
+ * <dt><b>DRAW_TRANSPARENT</b></dt>
+ * <dd>transparent background</dd>
+ * </dl>
+ * <p>
+ * The <em>extent</em> of a string is the width and height of
+ * the rectangular area it would cover if drawn in a particular
+ * font (in this case, the current font in the receiver).
+ * </p>
+ *
+ * @param string the string to measure
+ * @param flags the flags specifing how to process the text
+ * @return a point containing the extent of the string
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if the string is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ */
+public Point textExtent(String string, int flags) {
+ if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ if (string == null) SWT.error (SWT.ERROR_NULL_ARGUMENT);
+ if (string.length () == 0) {
+ SIZE size = new SIZE();
+// OS.GetTextExtentPoint32(handle, SPACE, SPACE.length(), size);
+ OS.GetTextExtentPoint32W(handle, new char [] {' '}, 1, size);
+ return new Point(0, size.cy);
+ }
+ RECT rect = new RECT();
+ TCHAR buffer = new TCHAR(getCodePage(), string, false);
+ int uFormat = OS.DT_LEFT | OS.DT_CALCRECT;
+ if ((flags & SWT.DRAW_DELIMITER) == 0) uFormat |= OS.DT_SINGLELINE;
+ if ((flags & SWT.DRAW_TAB) != 0) uFormat |= OS.DT_EXPANDTABS;
+ if ((flags & SWT.DRAW_MNEMONIC) == 0) uFormat |= OS.DT_NOPREFIX;
+ OS.DrawText(handle, buffer, buffer.length(), rect, uFormat);
+ return new Point(rect.right, rect.bottom);
+}
+
+/**
+ * Returns a string containing a concise, human-readable
+ * description of the receiver.
+ *
+ * @return a string representation of the receiver
+ */
+public String toString () {
+ if (isDisposed()) return "GC {*DISPOSED*}";
+ return "GC {" + handle + "}";
+}
+
+/**
+ * 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
index 82c2b4913b..2783b746d6 100755
--- 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
@@ -1,34 +1,34 @@
-package org.eclipse.swt.graphics;
-
-/*
+package org.eclipse.swt.graphics;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-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 int hwnd;
- public PAINTSTRUCT ps;
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+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 int hwnd;
+ public PAINTSTRUCT ps;
}
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
index d21dcd7a46..10e16f4dfc 100755
--- 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
@@ -1,1902 +1,1902 @@
-package org.eclipse.swt.graphics;
-
-/*
+package org.eclipse.swt.graphics;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-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);
- * </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;
-
- /**
- * the image data used to create this image if it is a
- * icon. Used only in WinCE
- * (Warning: This field is platform dependent)
- */
- ImageData data;
-
- /**
- * 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>
- * <p>
- * Note: Some platforms may have a limitation on the size
- * of image that can be created (size depends on width, height,
- * and depth). For example, Windows 95, 98, and ME do not allow
- * images larger than 16M.
- * </p>
- *
- * @param device the device on which to create the image
- * @param width the width of the new image
- * @param height the height of the new image
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if device is null and there is no current device</li>
- * <li>ERROR_INVALID_ARGUMENT - if either the width or height is negative or zero</li>
- * </ul>
- * @exception SWTError <ul>
- * <li>ERROR_NO_HANDLES if a handle could not be obtained for image creation</li>
- * </ul>
- */
-public Image(Device device, int width, int height) {
- 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 device is null and there is no current device</li>
- * <li>ERROR_NULL_ARGUMENT - if srcImage is null</li>
- * <li>ERROR_INVALID_ARGUMENT - if the flag is not one of <code>IMAGE_COPY</code>, <code>IMAGE_DISABLE</code> or <code>IMAGE_GRAY</code></li>
- * <li>ERROR_INVALID_ARGUMENT - if the image has been disposed</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_INVALID_IMAGE - if the image is not a bitmap or an icon, or
- * is otherwise in an invalid state</li>
- * </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);
- if (srcImage.isDisposed()) SWT.error(SWT.ERROR_INVALID_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:
- if (OS.IsWinCE) {
- init(device, srcImage.data);
- } else {
- 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.IsWinCE) {
- GetIconInfo(srcImage, iconInfo);
- } else {
- 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>
- * <p>
- * Note: Some platforms may have a limitation on the size
- * of image that can be created (size depends on width, height,
- * and depth). For example, Windows 95, 98, and ME do not allow
- * images larger than 16M.
- * </p>
- *
- * @param device the device on which to create the image
- * @param bounds a rectangle specifying the image's width and height (must not be null)
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if device is null and there is no current device</li>
- * <li>ERROR_NULL_ARGUMENT - if the bounds rectangle is null</li>
- * <li>ERROR_INVALID_ARGUMENT - if either the rectangle's width or height is negative</li>
- * </ul>
- * @exception SWTError <ul>
- * <li>ERROR_NO_HANDLES if a handle could not be obtained for image creation</li>
- * </ul>
- */
-public Image(Device device, Rectangle bounds) {
- 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 device is null and there is no current device</li>
- * <li>ERROR_NULL_ARGUMENT - if the image data is null</li>
- * </ul>
- * @exception SWTError <ul>
- * <li>ERROR_NO_HANDLES if a handle could not be obtained for image creation</li>
- * </ul>
- */
-public Image(Device device, ImageData data) {
- 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 device is null and there is no current device</li>
- * <li>ERROR_NULL_ARGUMENT - if either the source or mask is null </li>
- * <li>ERROR_INVALID_ARGUMENT - if source and mask are different sizes or
- * if the mask is not monochrome, or if either the source or mask
- * is already an icon</li>
- * </ul>
- * @exception SWTError <ul>
- * <li>ERROR_NO_HANDLES if a handle could not be obtained for image creation</li>
- * </ul>
- */
-public Image(Device device, ImageData source, ImageData mask) {
- 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 IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if device is null and there is no current device</li>
- * <li>ERROR_NULL_ARGUMENT - if the stream is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_INVALID_IMAGE - if the image file contains invalid data </li>
- * <li>ERROR_IO - if an IO error occurs while reading data</li>
- * </ul>
- * @exception SWTError <ul>
- * <li>ERROR_NO_HANDLES if a handle could not be obtained for image creation</li>
- * </ul>
- */
-public Image (Device device, InputStream stream) {
- 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 IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if device is null and there is no current device</li>
- * <li>ERROR_NULL_ARGUMENT - if the file name is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_INVALID_IMAGE - if the image file contains invalid data </li>
- * <li>ERROR_IO - if an IO error occurs while reading data</li>
- * </ul>
- * @exception SWTError <ul>
- * <li>ERROR_NO_HANDLES if a handle could not be obtained for image creation</li>
- * </ul>
- */
-public Image (Device device, String filename) {
- 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);
-}
-
-/**
- * Create a DIB from a DDB without using GetDIBits. Note that
- * the DDB should not be selected into a HDC.
- */
-int createDIBFromDDB(int hDC, int hBitmap, int width, int height) {
-
- /* Determine the DDB depth */
- int bits = OS.GetDeviceCaps (hDC, OS.BITSPIXEL);
- int planes = OS.GetDeviceCaps (hDC, OS.PLANES);
- int depth = bits * planes;
-
- /* Determine the DIB palette */
- boolean isDirect = depth > 8;
- RGB[] rgbs = null;
- if (!isDirect) {
- int numColors = 1 << depth;
- byte[] logPalette = new byte[4 * numColors];
- OS.GetPaletteEntries(device.hPalette, 0, numColors, logPalette);
- rgbs = new RGB[numColors];
- for (int i = 0; i < numColors; i++) {
- rgbs[i] = new RGB(logPalette[i] & 0xFF, logPalette[i + 1] & 0xFF, logPalette[i + 2] & 0xFF);
- }
- }
-
- boolean useBitfields = OS.IsWinCE && (depth == 16 || depth == 32);
- BITMAPINFOHEADER bmiHeader = new BITMAPINFOHEADER();
- bmiHeader.biSize = BITMAPINFOHEADER.sizeof;
- bmiHeader.biWidth = width;
- bmiHeader.biHeight = -height;
- bmiHeader.biPlanes = 1;
- bmiHeader.biBitCount = (short)depth;
- if (useBitfields) bmiHeader.biCompression = OS.BI_BITFIELDS;
- else bmiHeader.biCompression = OS.BI_RGB;
- byte[] bmi;
- if (isDirect) bmi = new byte[BITMAPINFOHEADER.sizeof + (useBitfields ? 12 : 0)];
- else bmi = new byte[BITMAPINFOHEADER.sizeof + rgbs.length * 4];
- OS.MoveMemory(bmi, bmiHeader, BITMAPINFOHEADER.sizeof);
-
- /* Set the rgb colors into the bitmap info */
- int offset = BITMAPINFOHEADER.sizeof;
- if (isDirect) {
- if (useBitfields) {
- int redMask = 0;
- int greenMask = 0;
- int blueMask = 0;
- switch (depth) {
- case 16:
- redMask = 0x7C00;
- greenMask = 0x3E0;
- blueMask = 0x1F;
- /* little endian */
- bmi[offset] = (byte)((redMask & 0xFF) >> 0);
- bmi[offset + 1] = (byte)((redMask & 0xFF00) >> 8);
- bmi[offset + 2] = (byte)((redMask & 0xFF0000) >> 16);
- bmi[offset + 3] = (byte)((redMask & 0xFF000000) >> 24);
- bmi[offset + 4] = (byte)((greenMask & 0xFF) >> 0);
- bmi[offset + 5] = (byte)((greenMask & 0xFF00) >> 8);
- bmi[offset + 6] = (byte)((greenMask & 0xFF0000) >> 16);
- bmi[offset + 7] = (byte)((greenMask & 0xFF000000) >> 24);
- bmi[offset + 8] = (byte)((blueMask & 0xFF) >> 0);
- bmi[offset + 9] = (byte)((blueMask & 0xFF00) >> 8);
- bmi[offset + 10] = (byte)((blueMask & 0xFF0000) >> 16);
- bmi[offset + 11] = (byte)((blueMask & 0xFF000000) >> 24);
- break;
- case 32:
- redMask = 0xFF00;
- greenMask = 0xFF0000;
- blueMask = 0xFF000000;
- /* big endian */
- bmi[offset] = (byte)((redMask & 0xFF000000) >> 24);
- bmi[offset + 1] = (byte)((redMask & 0xFF0000) >> 16);
- bmi[offset + 2] = (byte)((redMask & 0xFF00) >> 8);
- bmi[offset + 3] = (byte)((redMask & 0xFF) >> 0);
- bmi[offset + 4] = (byte)((greenMask & 0xFF000000) >> 24);
- bmi[offset + 5] = (byte)((greenMask & 0xFF0000) >> 16);
- bmi[offset + 6] = (byte)((greenMask & 0xFF00) >> 8);
- bmi[offset + 7] = (byte)((greenMask & 0xFF) >> 0);
- bmi[offset + 8] = (byte)((blueMask & 0xFF000000) >> 24);
- bmi[offset + 9] = (byte)((blueMask & 0xFF0000) >> 16);
- bmi[offset + 10] = (byte)((blueMask & 0xFF00) >> 8);
- bmi[offset + 11] = (byte)((blueMask & 0xFF) >> 0);
- break;
- default:
- SWT.error(SWT.ERROR_UNSUPPORTED_DEPTH);
- }
- }
- } else {
- 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);
-
- /* Bitblt DDB into DIB */
- int hdcSource = OS.CreateCompatibleDC(hDC);
- int hdcDest = OS.CreateCompatibleDC(hDC);
- int hOldSrc = OS.SelectObject(hdcSource, hBitmap);
- int hOldDest = OS.SelectObject(hdcDest, hDib);
- OS.BitBlt(hdcDest, 0, 0, width, height, hdcSource, 0, 0, OS.SRCCOPY);
- OS.SelectObject(hdcSource, hOldSrc);
- OS.SelectObject(hdcDest, hOldDest);
- OS.DeleteDC(hdcSource);
- OS.DeleteDC(hdcDest);
-
- return hDib;
-}
-
-/**
- * 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 (device.isDisposed()) return;
- if (type == SWT.ICON) {
- if (OS.IsWinCE) data = null;
- 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
- *
- * @exception SWTException <ul>
- * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
- * </ul>
- */
-public Color getBackground() {
- if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- if (transparentPixel == -1) return null;
-
- /* 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) {
- if (OS.IsWinCE) {
- byte[] pBits = new byte[1];
- OS.MoveMemory(pBits, bm.bmBits, 1);
- byte oldValue = pBits[0];
- int mask = (0xFF << (8 - bm.bmBitsPixel)) & 0x00FF;
- pBits[0] = (byte)((transparentPixel << (8 - bm.bmBitsPixel)) | (pBits[0] & ~mask));
- OS.MoveMemory(bm.bmBits, pBits, 1);
- int color = OS.GetPixel(hdcMem, 0, 0);
- pBits[0] = oldValue;
- OS.MoveMemory(bm.bmBits, pBits, 1);
- blue = (color & 0xFF0000) >> 16;
- green = (color & 0xFF00) >> 8;
- red = color & 0xFF;
- } else {
- byte[] color = new byte[4];
- 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_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_INVALID_IMAGE - if the image is not a bitmap or an icon</li>
- * </ul>
- */
-public Rectangle getBounds() {
- if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- 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:
- if (OS.IsWinCE) {
- return new Rectangle(0, 0, data.width, data.height);
- } else {
- 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_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_INVALID_IMAGE - if the image is not a bitmap or an icon</li>
- * </ul>
- *
- * @see ImageData
- */
-public ImageData getImageData() {
- if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- BITMAP bm;
- int depth, width, height;
- switch (type) {
- case SWT.ICON: {
- if (OS.IsWinCE) return data;
- ICONINFO info = new ICONINFO();
- if (OS.IsWinCE) SWT.error(SWT.ERROR_NOT_IMPLEMENTED);
- 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 */
- BITMAPINFOHEADER bmiHeader = new BITMAPINFOHEADER();
- bmiHeader.biSize = BITMAPINFOHEADER.sizeof;
- bmiHeader.biWidth = width;
- bmiHeader.biHeight = -height;
- bmiHeader.biPlanes = 1;
- bmiHeader.biBitCount = (short)depth;
- bmiHeader.biCompression = OS.BI_RGB;
- byte[] bmi = new byte[BITMAPINFOHEADER.sizeof + numColors * 4];
- OS.MoveMemory(bmi, bmiHeader, BITMAPINFOHEADER.sizeof);
-
- /* 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 */
- if (OS.IsWinCE) SWT.error(SWT.ERROR_NOT_IMPLEMENTED);
- OS.GetDIBits(hBitmapDC, hBitmap, 0, height, 0, bmi, OS.DIB_RGB_COLORS);
- OS.MoveMemory(bmiHeader, bmi, BITMAPINFOHEADER.sizeof);
- imageSize = bmiHeader.biSizeImage;
- byte[] data = new byte[imageSize];
- /* Get the bitmap data */
- int hHeap = OS.GetProcessHeap();
- int lpvBits = OS.HeapAlloc(hHeap, OS.HEAP_ZERO_MEMORY, imageSize);
- if (OS.IsWinCE) SWT.error(SWT.ERROR_NOT_IMPLEMENTED);
- 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];
- if (OS.IsWinCE) SWT.error(SWT.ERROR_NOT_IMPLEMENTED);
- 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 */
- bmiHeader = new BITMAPINFOHEADER();
- bmiHeader.biSize = BITMAPINFOHEADER.sizeof;
- bmiHeader.biWidth = width;
- bmiHeader.biHeight = -height;
- bmiHeader.biPlanes = 1;
- bmiHeader.biBitCount = 1;
- bmiHeader.biCompression = OS.BI_RGB;
- bmi = new byte[BITMAPINFOHEADER.sizeof + 8];
- OS.MoveMemory(bmi, bmiHeader, BITMAPINFOHEADER.sizeof);
-
- /* First color black, second color white */
- int offset = BITMAPINFOHEADER.sizeof;
- bmi[offset + 4] = bmi[offset + 5] = bmi[offset + 6] = (byte)0xFF;
- bmi[offset + 7] = 0;
- OS.SelectObject(hBitmapDC, info.hbmMask);
- /* Call with null lpBits to get the image size */
- if (OS.IsWinCE) SWT.error(SWT.ERROR_NOT_IMPLEMENTED);
- OS.GetDIBits(hBitmapDC, info.hbmMask, 0, height, 0, bmi, OS.DIB_RGB_COLORS);
- OS.MoveMemory(bmiHeader, bmi, BITMAPINFOHEADER.sizeof);
- imageSize = bmiHeader.biSizeImage;
- maskData = new byte[imageSize];
- int lpvMaskBits = OS.HeapAlloc(hHeap, OS.HEAP_ZERO_MEMORY, imageSize);
- if (OS.IsWinCE) SWT.error(SWT.ERROR_NOT_IMPLEMENTED);
- 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);
- /* Get the HDC for the device */
- int hDC = device.internal_new_GC(null);
-
- /*
- * Feature in WinCE. GetDIBits is not available in WinCE. The
- * workaround is to create a temporary DIB from the DDB and use
- * the bmBits field of DIBSECTION to retrieve the image data.
- */
- int handle = this.handle;
- if (OS.IsWinCE) {
- if (!isDib) {
- boolean mustRestore = false;
- if (memGC != null && !memGC.isDisposed()) {
- mustRestore = true;
- GCData data = memGC.data;
- if (data.hNullBitmap != 0) {
- OS.SelectObject(memGC.handle, data.hNullBitmap);
- data.hNullBitmap = 0;
- }
- }
- handle = createDIBFromDDB(hDC, this.handle, width, height);
- if (mustRestore) {
- int hOldBitmap = OS.SelectObject(memGC.handle, this.handle);
- memGC.data.hNullBitmap = hOldBitmap;
- }
- isDib = true;
- }
- }
- 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;
- BITMAPINFOHEADER bmiHeader = null;
- if (!isDib) {
- bmiHeader = new BITMAPINFOHEADER();
- bmiHeader.biSize = BITMAPINFOHEADER.sizeof;
- bmiHeader.biWidth = width;
- bmiHeader.biHeight = -height;
- bmiHeader.biPlanes = 1;
- bmiHeader.biBitCount = (short)depth;
- bmiHeader.biCompression = OS.BI_RGB;
- bmi = new byte[BITMAPINFOHEADER.sizeof + numColors * 4];
- OS.MoveMemory(bmi, bmiHeader, BITMAPINFOHEADER.sizeof);
- }
-
- /* 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 */
- if (OS.IsWinCE) SWT.error(SWT.ERROR_NOT_IMPLEMENTED);
- OS.GetDIBits(hBitmapDC, handle, 0, height, 0, bmi, OS.DIB_RGB_COLORS);
- OS.MoveMemory(bmiHeader, bmi, BITMAPINFOHEADER.sizeof);
- imageSize = bmiHeader.biSizeImage;
- }
- byte[] data = new byte[imageSize];
- /* Get the bitmap data */
- if (isDib) {
- if (OS.IsWinCE && this.handle != handle) {
- /* get image data from the temporary DIB */
- OS.MoveMemory(data, dib.bmBits, imageSize);
- } else {
- OS.MoveMemory(data, bm.bmBits, imageSize);
- }
- } else {
- int hHeap = OS.GetProcessHeap();
- int lpvBits = OS.HeapAlloc(hHeap, OS.HEAP_ZERO_MEMORY, imageSize);
- if (OS.IsWinCE) SWT.error(SWT.ERROR_NOT_IMPLEMENTED);
- 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 (depth <= 8) {
- RGB[] rgbs = new RGB[numColors];
- if (isDib) {
- if (OS.IsWinCE) {
- /*
- * Feature on WinCE. GetDIBColorTable is not supported.
- * The workaround is to set a pixel to the desired
- * palette index and use getPixel to get the corresponding
- * RGB value.
- */
- int red = 0, green = 0, blue = 0;
- byte[] pBits = new byte[1];
- OS.MoveMemory(pBits, bm.bmBits, 1);
- byte oldValue = pBits[0];
- int mask = (0xFF << (8 - bm.bmBitsPixel)) & 0x00FF;
- for (int i = 0; i < numColors; i++) {
- pBits[0] = (byte)((i << (8 - bm.bmBitsPixel)) | (pBits[0] & ~mask));
- OS.MoveMemory(bm.bmBits, pBits, 1);
- int color = OS.GetPixel(hBitmapDC, 0, 0);
- blue = (color & 0xFF0000) >> 16;
- green = (color & 0xFF00) >> 8;
- red = color & 0xFF;
- rgbs[i] = new RGB(red, green, blue);
- }
- pBits[0] = oldValue;
- OS.MoveMemory(bm.bmBits, pBits, 1);
- } else {
- byte[] colors = new byte[numColors * 4];
- OS.GetDIBColorTable(hBitmapDC, 0, numColors, colors);
- 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;
- }
- }
- } else {
- int srcIndex = BITMAPINFOHEADER.sizeof;
- 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);
- }
- if (OS.IsWinCE) {
- if (handle != this.handle) {
- /* free temporary DIB */
- OS.DeleteObject (handle);
- }
- }
- 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);
- if (handle == 0) SWT.error(SWT.ERROR_NO_HANDLES);
- 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);
-}
-
-/**
- * Feature in WinCE. GetIconInfo is not available in WinCE.
- * The workaround is to cache the object ImageData for images
- * of type SWT.ICON. The bitmaps hbmMask and hbmColor can then
- * be reconstructed by using our version of getIconInfo.
- * This function takes an ICONINFO object and sets the fields
- * hbmMask and hbmColor with the corresponding bitmaps it has
- * created.
- * Note. These bitmaps must be freed - as they would have to be
- * if the regular GetIconInfo had been used.
- */
-static void GetIconInfo(Image image, ICONINFO info) {
- int[] result = init(image.device, null, image.data);
- info.hbmColor = result[0];
- info.hbmMask = result[1];
-}
-
-static int[] init(Device device, Image image, ImageData i) {
- if (image != null) image.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, i.getByteOrder(), 0, 0, i.width, i.height, null, null, null,
- ImageData.ALPHA_OPAQUE, null, 0, 0, 0,
- img.data, img.depth, img.bytesPerLine, i.getByteOrder(), 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
- * (0x00FF0000, 0x0000FF00, 0x000000FF) as documented in
- * MSDN BITMAPINFOHEADER. Make sure the image is
- * Windows-supported.
- */
- /*
- * Note on WinCE. CreateDIBSection requires the biCompression
- * field of the BITMAPINFOHEADER to be set to BI_BITFIELDS for
- * 16 and 32 bit direct images (see MSDN for CreateDIBSection).
- * In this case, the color mask can be set to any value. For
- * consistency, it is set to the same mask used by non WinCE
- * platforms in BI_RGB mode.
- */
- if (i.palette.isDirect) {
- final PaletteData palette = i.palette;
- final int redMask = palette.redMask;
- final int greenMask = palette.greenMask;
- final int blueMask = palette.blueMask;
- int newDepth = i.depth;
- int newOrder = ImageData.MSB_FIRST;
- PaletteData newPalette = null;
-
- switch (i.depth) {
- case 8:
- newDepth = 16;
- newOrder = ImageData.LSB_FIRST;
- newPalette = new PaletteData(0x7C00, 0x3E0, 0x1F);
- break;
- case 16:
- newOrder = 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 == 0xFF00 && greenMask == 0xFF0000 && blueMask == 0xFF000000)) {
- 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, newDepth, newPalette);
- ImageData.blit(ImageData.BLIT_SRC,
- i.data, i.depth, i.bytesPerLine, i.getByteOrder(), 0, 0, i.width, i.height, redMask, greenMask, blueMask,
- ImageData.ALPHA_OPAQUE, null, 0, 0, 0,
- img.data, img.depth, img.bytesPerLine, newOrder, 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();
- boolean useBitfields = OS.IsWinCE && (i.depth == 16 || i.depth == 32);
- BITMAPINFOHEADER bmiHeader = new BITMAPINFOHEADER();
- bmiHeader.biSize = BITMAPINFOHEADER.sizeof;
- bmiHeader.biWidth = i.width;
- bmiHeader.biHeight = -i.height;
- bmiHeader.biPlanes = 1;
- bmiHeader.biBitCount = (short)i.depth;
- if (useBitfields) bmiHeader.biCompression = OS.BI_BITFIELDS;
- else bmiHeader.biCompression = OS.BI_RGB;
- bmiHeader.biClrUsed = rgbs == null ? 0 : rgbs.length;
- byte[] bmi;
- if (i.palette.isDirect)
- bmi = new byte[BITMAPINFOHEADER.sizeof + (useBitfields ? 12 : 0)];
- else
- bmi = new byte[BITMAPINFOHEADER.sizeof + rgbs.length * 4];
- OS.MoveMemory(bmi, bmiHeader, BITMAPINFOHEADER.sizeof);
- /* Set the rgb colors into the bitmap info */
- int offset = BITMAPINFOHEADER.sizeof;
- if (i.palette.isDirect) {
- if (useBitfields) {
- PaletteData palette = i.palette;
- int redMask = palette.redMask;
- int greenMask = palette.greenMask;
- int blueMask = palette.blueMask;
- /*
- * The color masks must be written based on the
- * endianness of the ImageData. */
- if (i.getByteOrder() == ImageData.LSB_FIRST) {
- bmi[offset] = (byte)((redMask & 0xFF) >> 0);
- bmi[offset + 1] = (byte)((redMask & 0xFF00) >> 8);
- bmi[offset + 2] = (byte)((redMask & 0xFF0000) >> 16);
- bmi[offset + 3] = (byte)((redMask & 0xFF000000) >> 24);
- bmi[offset + 4] = (byte)((greenMask & 0xFF) >> 0);
- bmi[offset + 5] = (byte)((greenMask & 0xFF00) >> 8);
- bmi[offset + 6] = (byte)((greenMask & 0xFF0000) >> 16);
- bmi[offset + 7] = (byte)((greenMask & 0xFF000000) >> 24);
- bmi[offset + 8] = (byte)((blueMask & 0xFF) >> 0);
- bmi[offset + 9] = (byte)((blueMask & 0xFF00) >> 8);
- bmi[offset + 10] = (byte)((blueMask & 0xFF0000) >> 16);
- bmi[offset + 11] = (byte)((blueMask & 0xFF000000) >> 24);
- } else {
- bmi[offset] = (byte)((redMask & 0xFF000000) >> 24);
- bmi[offset + 1] = (byte)((redMask & 0xFF0000) >> 16);
- bmi[offset + 2] = (byte)((redMask & 0xFF00) >> 8);
- bmi[offset + 3] = (byte)((redMask & 0xFF) >> 0);
- bmi[offset + 4] = (byte)((greenMask & 0xFF000000) >> 24);
- bmi[offset + 5] = (byte)((greenMask & 0xFF0000) >> 16);
- bmi[offset + 6] = (byte)((greenMask & 0xFF00) >> 8);
- bmi[offset + 7] = (byte)((greenMask & 0xFF) >> 0);
- bmi[offset + 8] = (byte)((blueMask & 0xFF000000) >> 24);
- bmi[offset + 9] = (byte)((blueMask & 0xFF0000) >> 16);
- bmi[offset + 10] = (byte)((blueMask & 0xFF00) >> 8);
- bmi[offset + 11] = (byte)((blueMask & 0xFF) >> 0);
- }
- }
- } else {
- 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);
-
- int[] result = null;
- 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);
- OS.DeleteObject(hDib);
-
- if (image == null) {
- result = new int[]{hBitmap, hMask};
- } else {
- /* 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);
- image.handle = hIcon;
- image.type = SWT.ICON;
- if (OS.IsWinCE) image.data = i;
- }
- } else {
- if (image == null) {
- result = new int[]{hDib};
- } else {
- image.handle = hDib;
- image.type = SWT.BITMAP;
- image.transparentPixel = i.transparentPixel;
- if (image.transparentPixel == -1) {
- image.alpha = i.alpha;
- if (i.alpha == -1 && i.alphaData != null) {
- int length = i.alphaData.length;
- image.alphaData = new byte[length];
- System.arraycopy(i.alphaData, 0, image.alphaData, 0, length);
- }
- }
- }
- }
- return result;
-}
-
-void init(Device device, ImageData i) {
- if (i == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
- init(device, this, i);
-}
-
-/**
- * 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) {
- if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- /*
- * 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.systemFont;
- }
- 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>
- * </p><p>
- * The image may be modified by this operation (in effect, the
- * transparent regions may be filled with the supplied color). Hence
- * this operation is not reversible and it is not legal to call
- * this function twice or with a null argument.
- * </p><p>
- * This method has no effect if the receiver does not have a transparent
- * pixel value.
- * </p>
- *
- * @param color the color to use when a transparent pixel is specified
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the color is null</li>
- * <li>ERROR_INVALID_ARGUMENT - if the color has been disposed</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
- * </ul>
- */
-public void setBackground(Color color) {
- /*
- * Note. Not implemented on WinCE.
- */
- if (OS.IsWinCE) return;
- if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- if (color == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
- if (color.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
- if (transparentPixel == -1) return;
-
- /* 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];
- if (OS.IsWinCE) SWT.error(SWT.ERROR_NOT_IMPLEMENTED);
- 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();
- if (OS.IsWinCE) SWT.error(SWT.ERROR_NOT_IMPLEMENTED);
- OS.SetDIBColorTable(hdcMem, 0, numColors, colors);
- OS.DeleteDC(hdcMem);
-
- /* Release the HDC for the device */
- device.internal_dispose_GC(hDC, null);
-}
-
-/**
- * Returns a string containing a concise, human-readable
- * description of the receiver.
- *
- * @return a string representation of the receiver
- */
-public String toString () {
- if (isDisposed()) return "Image {*DISPOSED*}";
- return "Image {" + handle + "}";
-}
-
-/**
- * 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;
-}
-
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+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);
+ * </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;
+
+ /**
+ * the image data used to create this image if it is a
+ * icon. Used only in WinCE
+ * (Warning: This field is platform dependent)
+ */
+ ImageData data;
+
+ /**
+ * 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>
+ * <p>
+ * Note: Some platforms may have a limitation on the size
+ * of image that can be created (size depends on width, height,
+ * and depth). For example, Windows 95, 98, and ME do not allow
+ * images larger than 16M.
+ * </p>
+ *
+ * @param device the device on which to create the image
+ * @param width the width of the new image
+ * @param height the height of the new image
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if device is null and there is no current device</li>
+ * <li>ERROR_INVALID_ARGUMENT - if either the width or height is negative or zero</li>
+ * </ul>
+ * @exception SWTError <ul>
+ * <li>ERROR_NO_HANDLES if a handle could not be obtained for image creation</li>
+ * </ul>
+ */
+public Image(Device device, int width, int height) {
+ 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 device is null and there is no current device</li>
+ * <li>ERROR_NULL_ARGUMENT - if srcImage is null</li>
+ * <li>ERROR_INVALID_ARGUMENT - if the flag is not one of <code>IMAGE_COPY</code>, <code>IMAGE_DISABLE</code> or <code>IMAGE_GRAY</code></li>
+ * <li>ERROR_INVALID_ARGUMENT - if the image has been disposed</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_INVALID_IMAGE - if the image is not a bitmap or an icon, or
+ * is otherwise in an invalid state</li>
+ * </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);
+ if (srcImage.isDisposed()) SWT.error(SWT.ERROR_INVALID_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:
+ if (OS.IsWinCE) {
+ init(device, srcImage.data);
+ } else {
+ 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.IsWinCE) {
+ GetIconInfo(srcImage, iconInfo);
+ } else {
+ 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>
+ * <p>
+ * Note: Some platforms may have a limitation on the size
+ * of image that can be created (size depends on width, height,
+ * and depth). For example, Windows 95, 98, and ME do not allow
+ * images larger than 16M.
+ * </p>
+ *
+ * @param device the device on which to create the image
+ * @param bounds a rectangle specifying the image's width and height (must not be null)
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if device is null and there is no current device</li>
+ * <li>ERROR_NULL_ARGUMENT - if the bounds rectangle is null</li>
+ * <li>ERROR_INVALID_ARGUMENT - if either the rectangle's width or height is negative</li>
+ * </ul>
+ * @exception SWTError <ul>
+ * <li>ERROR_NO_HANDLES if a handle could not be obtained for image creation</li>
+ * </ul>
+ */
+public Image(Device device, Rectangle bounds) {
+ 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 device is null and there is no current device</li>
+ * <li>ERROR_NULL_ARGUMENT - if the image data is null</li>
+ * </ul>
+ * @exception SWTError <ul>
+ * <li>ERROR_NO_HANDLES if a handle could not be obtained for image creation</li>
+ * </ul>
+ */
+public Image(Device device, ImageData data) {
+ 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 device is null and there is no current device</li>
+ * <li>ERROR_NULL_ARGUMENT - if either the source or mask is null </li>
+ * <li>ERROR_INVALID_ARGUMENT - if source and mask are different sizes or
+ * if the mask is not monochrome, or if either the source or mask
+ * is already an icon</li>
+ * </ul>
+ * @exception SWTError <ul>
+ * <li>ERROR_NO_HANDLES if a handle could not be obtained for image creation</li>
+ * </ul>
+ */
+public Image(Device device, ImageData source, ImageData mask) {
+ 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 IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if device is null and there is no current device</li>
+ * <li>ERROR_NULL_ARGUMENT - if the stream is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_INVALID_IMAGE - if the image file contains invalid data </li>
+ * <li>ERROR_IO - if an IO error occurs while reading data</li>
+ * </ul>
+ * @exception SWTError <ul>
+ * <li>ERROR_NO_HANDLES if a handle could not be obtained for image creation</li>
+ * </ul>
+ */
+public Image (Device device, InputStream stream) {
+ 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 IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if device is null and there is no current device</li>
+ * <li>ERROR_NULL_ARGUMENT - if the file name is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_INVALID_IMAGE - if the image file contains invalid data </li>
+ * <li>ERROR_IO - if an IO error occurs while reading data</li>
+ * </ul>
+ * @exception SWTError <ul>
+ * <li>ERROR_NO_HANDLES if a handle could not be obtained for image creation</li>
+ * </ul>
+ */
+public Image (Device device, String filename) {
+ 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);
+}
+
+/**
+ * Create a DIB from a DDB without using GetDIBits. Note that
+ * the DDB should not be selected into a HDC.
+ */
+int createDIBFromDDB(int hDC, int hBitmap, int width, int height) {
+
+ /* Determine the DDB depth */
+ int bits = OS.GetDeviceCaps (hDC, OS.BITSPIXEL);
+ int planes = OS.GetDeviceCaps (hDC, OS.PLANES);
+ int depth = bits * planes;
+
+ /* Determine the DIB palette */
+ boolean isDirect = depth > 8;
+ RGB[] rgbs = null;
+ if (!isDirect) {
+ int numColors = 1 << depth;
+ byte[] logPalette = new byte[4 * numColors];
+ OS.GetPaletteEntries(device.hPalette, 0, numColors, logPalette);
+ rgbs = new RGB[numColors];
+ for (int i = 0; i < numColors; i++) {
+ rgbs[i] = new RGB(logPalette[i] & 0xFF, logPalette[i + 1] & 0xFF, logPalette[i + 2] & 0xFF);
+ }
+ }
+
+ boolean useBitfields = OS.IsWinCE && (depth == 16 || depth == 32);
+ BITMAPINFOHEADER bmiHeader = new BITMAPINFOHEADER();
+ bmiHeader.biSize = BITMAPINFOHEADER.sizeof;
+ bmiHeader.biWidth = width;
+ bmiHeader.biHeight = -height;
+ bmiHeader.biPlanes = 1;
+ bmiHeader.biBitCount = (short)depth;
+ if (useBitfields) bmiHeader.biCompression = OS.BI_BITFIELDS;
+ else bmiHeader.biCompression = OS.BI_RGB;
+ byte[] bmi;
+ if (isDirect) bmi = new byte[BITMAPINFOHEADER.sizeof + (useBitfields ? 12 : 0)];
+ else bmi = new byte[BITMAPINFOHEADER.sizeof + rgbs.length * 4];
+ OS.MoveMemory(bmi, bmiHeader, BITMAPINFOHEADER.sizeof);
+
+ /* Set the rgb colors into the bitmap info */
+ int offset = BITMAPINFOHEADER.sizeof;
+ if (isDirect) {
+ if (useBitfields) {
+ int redMask = 0;
+ int greenMask = 0;
+ int blueMask = 0;
+ switch (depth) {
+ case 16:
+ redMask = 0x7C00;
+ greenMask = 0x3E0;
+ blueMask = 0x1F;
+ /* little endian */
+ bmi[offset] = (byte)((redMask & 0xFF) >> 0);
+ bmi[offset + 1] = (byte)((redMask & 0xFF00) >> 8);
+ bmi[offset + 2] = (byte)((redMask & 0xFF0000) >> 16);
+ bmi[offset + 3] = (byte)((redMask & 0xFF000000) >> 24);
+ bmi[offset + 4] = (byte)((greenMask & 0xFF) >> 0);
+ bmi[offset + 5] = (byte)((greenMask & 0xFF00) >> 8);
+ bmi[offset + 6] = (byte)((greenMask & 0xFF0000) >> 16);
+ bmi[offset + 7] = (byte)((greenMask & 0xFF000000) >> 24);
+ bmi[offset + 8] = (byte)((blueMask & 0xFF) >> 0);
+ bmi[offset + 9] = (byte)((blueMask & 0xFF00) >> 8);
+ bmi[offset + 10] = (byte)((blueMask & 0xFF0000) >> 16);
+ bmi[offset + 11] = (byte)((blueMask & 0xFF000000) >> 24);
+ break;
+ case 32:
+ redMask = 0xFF00;
+ greenMask = 0xFF0000;
+ blueMask = 0xFF000000;
+ /* big endian */
+ bmi[offset] = (byte)((redMask & 0xFF000000) >> 24);
+ bmi[offset + 1] = (byte)((redMask & 0xFF0000) >> 16);
+ bmi[offset + 2] = (byte)((redMask & 0xFF00) >> 8);
+ bmi[offset + 3] = (byte)((redMask & 0xFF) >> 0);
+ bmi[offset + 4] = (byte)((greenMask & 0xFF000000) >> 24);
+ bmi[offset + 5] = (byte)((greenMask & 0xFF0000) >> 16);
+ bmi[offset + 6] = (byte)((greenMask & 0xFF00) >> 8);
+ bmi[offset + 7] = (byte)((greenMask & 0xFF) >> 0);
+ bmi[offset + 8] = (byte)((blueMask & 0xFF000000) >> 24);
+ bmi[offset + 9] = (byte)((blueMask & 0xFF0000) >> 16);
+ bmi[offset + 10] = (byte)((blueMask & 0xFF00) >> 8);
+ bmi[offset + 11] = (byte)((blueMask & 0xFF) >> 0);
+ break;
+ default:
+ SWT.error(SWT.ERROR_UNSUPPORTED_DEPTH);
+ }
+ }
+ } else {
+ 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);
+
+ /* Bitblt DDB into DIB */
+ int hdcSource = OS.CreateCompatibleDC(hDC);
+ int hdcDest = OS.CreateCompatibleDC(hDC);
+ int hOldSrc = OS.SelectObject(hdcSource, hBitmap);
+ int hOldDest = OS.SelectObject(hdcDest, hDib);
+ OS.BitBlt(hdcDest, 0, 0, width, height, hdcSource, 0, 0, OS.SRCCOPY);
+ OS.SelectObject(hdcSource, hOldSrc);
+ OS.SelectObject(hdcDest, hOldDest);
+ OS.DeleteDC(hdcSource);
+ OS.DeleteDC(hdcDest);
+
+ return hDib;
+}
+
+/**
+ * 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 (device.isDisposed()) return;
+ if (type == SWT.ICON) {
+ if (OS.IsWinCE) data = null;
+ 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
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ */
+public Color getBackground() {
+ if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ if (transparentPixel == -1) return null;
+
+ /* 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) {
+ if (OS.IsWinCE) {
+ byte[] pBits = new byte[1];
+ OS.MoveMemory(pBits, bm.bmBits, 1);
+ byte oldValue = pBits[0];
+ int mask = (0xFF << (8 - bm.bmBitsPixel)) & 0x00FF;
+ pBits[0] = (byte)((transparentPixel << (8 - bm.bmBitsPixel)) | (pBits[0] & ~mask));
+ OS.MoveMemory(bm.bmBits, pBits, 1);
+ int color = OS.GetPixel(hdcMem, 0, 0);
+ pBits[0] = oldValue;
+ OS.MoveMemory(bm.bmBits, pBits, 1);
+ blue = (color & 0xFF0000) >> 16;
+ green = (color & 0xFF00) >> 8;
+ red = color & 0xFF;
+ } else {
+ byte[] color = new byte[4];
+ 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_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_INVALID_IMAGE - if the image is not a bitmap or an icon</li>
+ * </ul>
+ */
+public Rectangle getBounds() {
+ if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ 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:
+ if (OS.IsWinCE) {
+ return new Rectangle(0, 0, data.width, data.height);
+ } else {
+ 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_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_INVALID_IMAGE - if the image is not a bitmap or an icon</li>
+ * </ul>
+ *
+ * @see ImageData
+ */
+public ImageData getImageData() {
+ if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ BITMAP bm;
+ int depth, width, height;
+ switch (type) {
+ case SWT.ICON: {
+ if (OS.IsWinCE) return data;
+ ICONINFO info = new ICONINFO();
+ if (OS.IsWinCE) SWT.error(SWT.ERROR_NOT_IMPLEMENTED);
+ 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 */
+ BITMAPINFOHEADER bmiHeader = new BITMAPINFOHEADER();
+ bmiHeader.biSize = BITMAPINFOHEADER.sizeof;
+ bmiHeader.biWidth = width;
+ bmiHeader.biHeight = -height;
+ bmiHeader.biPlanes = 1;
+ bmiHeader.biBitCount = (short)depth;
+ bmiHeader.biCompression = OS.BI_RGB;
+ byte[] bmi = new byte[BITMAPINFOHEADER.sizeof + numColors * 4];
+ OS.MoveMemory(bmi, bmiHeader, BITMAPINFOHEADER.sizeof);
+
+ /* 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 */
+ if (OS.IsWinCE) SWT.error(SWT.ERROR_NOT_IMPLEMENTED);
+ OS.GetDIBits(hBitmapDC, hBitmap, 0, height, 0, bmi, OS.DIB_RGB_COLORS);
+ OS.MoveMemory(bmiHeader, bmi, BITMAPINFOHEADER.sizeof);
+ imageSize = bmiHeader.biSizeImage;
+ byte[] data = new byte[imageSize];
+ /* Get the bitmap data */
+ int hHeap = OS.GetProcessHeap();
+ int lpvBits = OS.HeapAlloc(hHeap, OS.HEAP_ZERO_MEMORY, imageSize);
+ if (OS.IsWinCE) SWT.error(SWT.ERROR_NOT_IMPLEMENTED);
+ 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];
+ if (OS.IsWinCE) SWT.error(SWT.ERROR_NOT_IMPLEMENTED);
+ 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 */
+ bmiHeader = new BITMAPINFOHEADER();
+ bmiHeader.biSize = BITMAPINFOHEADER.sizeof;
+ bmiHeader.biWidth = width;
+ bmiHeader.biHeight = -height;
+ bmiHeader.biPlanes = 1;
+ bmiHeader.biBitCount = 1;
+ bmiHeader.biCompression = OS.BI_RGB;
+ bmi = new byte[BITMAPINFOHEADER.sizeof + 8];
+ OS.MoveMemory(bmi, bmiHeader, BITMAPINFOHEADER.sizeof);
+
+ /* First color black, second color white */
+ int offset = BITMAPINFOHEADER.sizeof;
+ bmi[offset + 4] = bmi[offset + 5] = bmi[offset + 6] = (byte)0xFF;
+ bmi[offset + 7] = 0;
+ OS.SelectObject(hBitmapDC, info.hbmMask);
+ /* Call with null lpBits to get the image size */
+ if (OS.IsWinCE) SWT.error(SWT.ERROR_NOT_IMPLEMENTED);
+ OS.GetDIBits(hBitmapDC, info.hbmMask, 0, height, 0, bmi, OS.DIB_RGB_COLORS);
+ OS.MoveMemory(bmiHeader, bmi, BITMAPINFOHEADER.sizeof);
+ imageSize = bmiHeader.biSizeImage;
+ maskData = new byte[imageSize];
+ int lpvMaskBits = OS.HeapAlloc(hHeap, OS.HEAP_ZERO_MEMORY, imageSize);
+ if (OS.IsWinCE) SWT.error(SWT.ERROR_NOT_IMPLEMENTED);
+ 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);
+ /* Get the HDC for the device */
+ int hDC = device.internal_new_GC(null);
+
+ /*
+ * Feature in WinCE. GetDIBits is not available in WinCE. The
+ * workaround is to create a temporary DIB from the DDB and use
+ * the bmBits field of DIBSECTION to retrieve the image data.
+ */
+ int handle = this.handle;
+ if (OS.IsWinCE) {
+ if (!isDib) {
+ boolean mustRestore = false;
+ if (memGC != null && !memGC.isDisposed()) {
+ mustRestore = true;
+ GCData data = memGC.data;
+ if (data.hNullBitmap != 0) {
+ OS.SelectObject(memGC.handle, data.hNullBitmap);
+ data.hNullBitmap = 0;
+ }
+ }
+ handle = createDIBFromDDB(hDC, this.handle, width, height);
+ if (mustRestore) {
+ int hOldBitmap = OS.SelectObject(memGC.handle, this.handle);
+ memGC.data.hNullBitmap = hOldBitmap;
+ }
+ isDib = true;
+ }
+ }
+ 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;
+ BITMAPINFOHEADER bmiHeader = null;
+ if (!isDib) {
+ bmiHeader = new BITMAPINFOHEADER();
+ bmiHeader.biSize = BITMAPINFOHEADER.sizeof;
+ bmiHeader.biWidth = width;
+ bmiHeader.biHeight = -height;
+ bmiHeader.biPlanes = 1;
+ bmiHeader.biBitCount = (short)depth;
+ bmiHeader.biCompression = OS.BI_RGB;
+ bmi = new byte[BITMAPINFOHEADER.sizeof + numColors * 4];
+ OS.MoveMemory(bmi, bmiHeader, BITMAPINFOHEADER.sizeof);
+ }
+
+ /* 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 */
+ if (OS.IsWinCE) SWT.error(SWT.ERROR_NOT_IMPLEMENTED);
+ OS.GetDIBits(hBitmapDC, handle, 0, height, 0, bmi, OS.DIB_RGB_COLORS);
+ OS.MoveMemory(bmiHeader, bmi, BITMAPINFOHEADER.sizeof);
+ imageSize = bmiHeader.biSizeImage;
+ }
+ byte[] data = new byte[imageSize];
+ /* Get the bitmap data */
+ if (isDib) {
+ if (OS.IsWinCE && this.handle != handle) {
+ /* get image data from the temporary DIB */
+ OS.MoveMemory(data, dib.bmBits, imageSize);
+ } else {
+ OS.MoveMemory(data, bm.bmBits, imageSize);
+ }
+ } else {
+ int hHeap = OS.GetProcessHeap();
+ int lpvBits = OS.HeapAlloc(hHeap, OS.HEAP_ZERO_MEMORY, imageSize);
+ if (OS.IsWinCE) SWT.error(SWT.ERROR_NOT_IMPLEMENTED);
+ 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 (depth <= 8) {
+ RGB[] rgbs = new RGB[numColors];
+ if (isDib) {
+ if (OS.IsWinCE) {
+ /*
+ * Feature on WinCE. GetDIBColorTable is not supported.
+ * The workaround is to set a pixel to the desired
+ * palette index and use getPixel to get the corresponding
+ * RGB value.
+ */
+ int red = 0, green = 0, blue = 0;
+ byte[] pBits = new byte[1];
+ OS.MoveMemory(pBits, bm.bmBits, 1);
+ byte oldValue = pBits[0];
+ int mask = (0xFF << (8 - bm.bmBitsPixel)) & 0x00FF;
+ for (int i = 0; i < numColors; i++) {
+ pBits[0] = (byte)((i << (8 - bm.bmBitsPixel)) | (pBits[0] & ~mask));
+ OS.MoveMemory(bm.bmBits, pBits, 1);
+ int color = OS.GetPixel(hBitmapDC, 0, 0);
+ blue = (color & 0xFF0000) >> 16;
+ green = (color & 0xFF00) >> 8;
+ red = color & 0xFF;
+ rgbs[i] = new RGB(red, green, blue);
+ }
+ pBits[0] = oldValue;
+ OS.MoveMemory(bm.bmBits, pBits, 1);
+ } else {
+ byte[] colors = new byte[numColors * 4];
+ OS.GetDIBColorTable(hBitmapDC, 0, numColors, colors);
+ 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;
+ }
+ }
+ } else {
+ int srcIndex = BITMAPINFOHEADER.sizeof;
+ 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);
+ }
+ if (OS.IsWinCE) {
+ if (handle != this.handle) {
+ /* free temporary DIB */
+ OS.DeleteObject (handle);
+ }
+ }
+ 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);
+ if (handle == 0) SWT.error(SWT.ERROR_NO_HANDLES);
+ 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);
+}
+
+/**
+ * Feature in WinCE. GetIconInfo is not available in WinCE.
+ * The workaround is to cache the object ImageData for images
+ * of type SWT.ICON. The bitmaps hbmMask and hbmColor can then
+ * be reconstructed by using our version of getIconInfo.
+ * This function takes an ICONINFO object and sets the fields
+ * hbmMask and hbmColor with the corresponding bitmaps it has
+ * created.
+ * Note. These bitmaps must be freed - as they would have to be
+ * if the regular GetIconInfo had been used.
+ */
+static void GetIconInfo(Image image, ICONINFO info) {
+ int[] result = init(image.device, null, image.data);
+ info.hbmColor = result[0];
+ info.hbmMask = result[1];
+}
+
+static int[] init(Device device, Image image, ImageData i) {
+ if (image != null) image.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, i.getByteOrder(), 0, 0, i.width, i.height, null, null, null,
+ ImageData.ALPHA_OPAQUE, null, 0, 0, 0,
+ img.data, img.depth, img.bytesPerLine, i.getByteOrder(), 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
+ * (0x00FF0000, 0x0000FF00, 0x000000FF) as documented in
+ * MSDN BITMAPINFOHEADER. Make sure the image is
+ * Windows-supported.
+ */
+ /*
+ * Note on WinCE. CreateDIBSection requires the biCompression
+ * field of the BITMAPINFOHEADER to be set to BI_BITFIELDS for
+ * 16 and 32 bit direct images (see MSDN for CreateDIBSection).
+ * In this case, the color mask can be set to any value. For
+ * consistency, it is set to the same mask used by non WinCE
+ * platforms in BI_RGB mode.
+ */
+ if (i.palette.isDirect) {
+ final PaletteData palette = i.palette;
+ final int redMask = palette.redMask;
+ final int greenMask = palette.greenMask;
+ final int blueMask = palette.blueMask;
+ int newDepth = i.depth;
+ int newOrder = ImageData.MSB_FIRST;
+ PaletteData newPalette = null;
+
+ switch (i.depth) {
+ case 8:
+ newDepth = 16;
+ newOrder = ImageData.LSB_FIRST;
+ newPalette = new PaletteData(0x7C00, 0x3E0, 0x1F);
+ break;
+ case 16:
+ newOrder = 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 == 0xFF00 && greenMask == 0xFF0000 && blueMask == 0xFF000000)) {
+ 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, newDepth, newPalette);
+ ImageData.blit(ImageData.BLIT_SRC,
+ i.data, i.depth, i.bytesPerLine, i.getByteOrder(), 0, 0, i.width, i.height, redMask, greenMask, blueMask,
+ ImageData.ALPHA_OPAQUE, null, 0, 0, 0,
+ img.data, img.depth, img.bytesPerLine, newOrder, 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();
+ boolean useBitfields = OS.IsWinCE && (i.depth == 16 || i.depth == 32);
+ BITMAPINFOHEADER bmiHeader = new BITMAPINFOHEADER();
+ bmiHeader.biSize = BITMAPINFOHEADER.sizeof;
+ bmiHeader.biWidth = i.width;
+ bmiHeader.biHeight = -i.height;
+ bmiHeader.biPlanes = 1;
+ bmiHeader.biBitCount = (short)i.depth;
+ if (useBitfields) bmiHeader.biCompression = OS.BI_BITFIELDS;
+ else bmiHeader.biCompression = OS.BI_RGB;
+ bmiHeader.biClrUsed = rgbs == null ? 0 : rgbs.length;
+ byte[] bmi;
+ if (i.palette.isDirect)
+ bmi = new byte[BITMAPINFOHEADER.sizeof + (useBitfields ? 12 : 0)];
+ else
+ bmi = new byte[BITMAPINFOHEADER.sizeof + rgbs.length * 4];
+ OS.MoveMemory(bmi, bmiHeader, BITMAPINFOHEADER.sizeof);
+ /* Set the rgb colors into the bitmap info */
+ int offset = BITMAPINFOHEADER.sizeof;
+ if (i.palette.isDirect) {
+ if (useBitfields) {
+ PaletteData palette = i.palette;
+ int redMask = palette.redMask;
+ int greenMask = palette.greenMask;
+ int blueMask = palette.blueMask;
+ /*
+ * The color masks must be written based on the
+ * endianness of the ImageData. */
+ if (i.getByteOrder() == ImageData.LSB_FIRST) {
+ bmi[offset] = (byte)((redMask & 0xFF) >> 0);
+ bmi[offset + 1] = (byte)((redMask & 0xFF00) >> 8);
+ bmi[offset + 2] = (byte)((redMask & 0xFF0000) >> 16);
+ bmi[offset + 3] = (byte)((redMask & 0xFF000000) >> 24);
+ bmi[offset + 4] = (byte)((greenMask & 0xFF) >> 0);
+ bmi[offset + 5] = (byte)((greenMask & 0xFF00) >> 8);
+ bmi[offset + 6] = (byte)((greenMask & 0xFF0000) >> 16);
+ bmi[offset + 7] = (byte)((greenMask & 0xFF000000) >> 24);
+ bmi[offset + 8] = (byte)((blueMask & 0xFF) >> 0);
+ bmi[offset + 9] = (byte)((blueMask & 0xFF00) >> 8);
+ bmi[offset + 10] = (byte)((blueMask & 0xFF0000) >> 16);
+ bmi[offset + 11] = (byte)((blueMask & 0xFF000000) >> 24);
+ } else {
+ bmi[offset] = (byte)((redMask & 0xFF000000) >> 24);
+ bmi[offset + 1] = (byte)((redMask & 0xFF0000) >> 16);
+ bmi[offset + 2] = (byte)((redMask & 0xFF00) >> 8);
+ bmi[offset + 3] = (byte)((redMask & 0xFF) >> 0);
+ bmi[offset + 4] = (byte)((greenMask & 0xFF000000) >> 24);
+ bmi[offset + 5] = (byte)((greenMask & 0xFF0000) >> 16);
+ bmi[offset + 6] = (byte)((greenMask & 0xFF00) >> 8);
+ bmi[offset + 7] = (byte)((greenMask & 0xFF) >> 0);
+ bmi[offset + 8] = (byte)((blueMask & 0xFF000000) >> 24);
+ bmi[offset + 9] = (byte)((blueMask & 0xFF0000) >> 16);
+ bmi[offset + 10] = (byte)((blueMask & 0xFF00) >> 8);
+ bmi[offset + 11] = (byte)((blueMask & 0xFF) >> 0);
+ }
+ }
+ } else {
+ 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);
+
+ int[] result = null;
+ 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);
+ OS.DeleteObject(hDib);
+
+ if (image == null) {
+ result = new int[]{hBitmap, hMask};
+ } else {
+ /* 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);
+ image.handle = hIcon;
+ image.type = SWT.ICON;
+ if (OS.IsWinCE) image.data = i;
+ }
+ } else {
+ if (image == null) {
+ result = new int[]{hDib};
+ } else {
+ image.handle = hDib;
+ image.type = SWT.BITMAP;
+ image.transparentPixel = i.transparentPixel;
+ if (image.transparentPixel == -1) {
+ image.alpha = i.alpha;
+ if (i.alpha == -1 && i.alphaData != null) {
+ int length = i.alphaData.length;
+ image.alphaData = new byte[length];
+ System.arraycopy(i.alphaData, 0, image.alphaData, 0, length);
+ }
+ }
+ }
+ }
+ return result;
+}
+
+void init(Device device, ImageData i) {
+ if (i == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ init(device, this, i);
+}
+
+/**
+ * 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) {
+ if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ /*
+ * 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.systemFont;
+ }
+ 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>
+ * </p><p>
+ * The image may be modified by this operation (in effect, the
+ * transparent regions may be filled with the supplied color). Hence
+ * this operation is not reversible and it is not legal to call
+ * this function twice or with a null argument.
+ * </p><p>
+ * This method has no effect if the receiver does not have a transparent
+ * pixel value.
+ * </p>
+ *
+ * @param color the color to use when a transparent pixel is specified
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if the color is null</li>
+ * <li>ERROR_INVALID_ARGUMENT - if the color has been disposed</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ */
+public void setBackground(Color color) {
+ /*
+ * Note. Not implemented on WinCE.
+ */
+ if (OS.IsWinCE) return;
+ if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ if (color == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ if (color.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+ if (transparentPixel == -1) return;
+
+ /* 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];
+ if (OS.IsWinCE) SWT.error(SWT.ERROR_NOT_IMPLEMENTED);
+ 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();
+ if (OS.IsWinCE) SWT.error(SWT.ERROR_NOT_IMPLEMENTED);
+ OS.SetDIBColorTable(hdcMem, 0, numColors, colors);
+ OS.DeleteDC(hdcMem);
+
+ /* Release the HDC for the device */
+ device.internal_dispose_GC(hDC, null);
+}
+
+/**
+ * Returns a string containing a concise, human-readable
+ * description of the receiver.
+ *
+ * @return a string representation of the receiver
+ */
+public String toString () {
+ if (isDisposed()) return "Image {*DISPOSED*}";
+ return "Image {" + handle + "}";
+}
+
+/**
+ * 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
index 620983418b..a08b88d065 100755
--- 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
@@ -1,307 +1,307 @@
-package org.eclipse.swt.graphics;
-
-/*
+package org.eclipse.swt.graphics;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-import org.eclipse.swt.internal.win32.*;
-import org.eclipse.swt.*;
-
-/**
- * Instances of this class represent areas of an x-y coordinate
- * system that are aggregates of the areas covered by a number
- * of 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.
- *
- * @exception SWTError <ul>
- * <li>ERROR_NO_HANDLES if a handle could not be obtained for region creation</li>
- * </ul>
- */
-public Region () {
- handle = OS.CreateRectRgn (0, 0, 0, 0);
- if (handle == 0) SWT.error(SWT.ERROR_NO_HANDLES);
-}
-
-/**
- * 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>
- * <li>ERROR_INVALID_ARGUMENT - if the rectangle's width or height is negative</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
- * </ul>
- */
-public void add (Rectangle rect) {
- if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- if (rect == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
- if (rect.width < 0 || rect.height < 0) SWT.error(SWT.ERROR_INVALID_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>
- * <li>ERROR_INVALID_ARGUMENT - if the argument has been disposed</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
- * </ul>
- */
-public void add (Region region) {
- if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- if (region == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
- if (region.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
- OS.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
- *
- * @exception SWTException <ul>
- * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
- * </ul>
- */
-public boolean contains (int x, int y) {
- if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- return OS.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>
- * @exception SWTException <ul>
- * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
- * </ul>
- */
-public boolean contains (Point pt) {
- if (pt == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
- return contains(pt.x, pt.y);
-}
-
-/**
- * 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;
- Region rgn = (Region)object;
- return handle == rgn.handle;
-}
-
-/**
- * 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
- *
- * @exception SWTException <ul>
- * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
- * </ul>
- *
- * @see Rectangle#union
- */
-public Rectangle getBounds() {
- if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- 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
- *
- * @exception SWTException <ul>
- * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
- * </ul>
- *
- * @see Rectangle#intersects
- */
-public boolean intersects (int x, int y, int width, int height) {
- if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- 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>
- * @exception SWTException <ul>
- * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</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
- *
- * @exception SWTException <ul>
- * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
- * </ul>
- */
-public boolean isEmpty () {
- if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- 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);
-}
-
-/**
- * Returns a string containing a concise, human-readable
- * description of the receiver.
- *
- * @return a string representation of the receiver
- */
-public String toString () {
- if (isDisposed()) return "Region {*DISPOSED*}";
- return "Region {" + handle + "}";
-}
-
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+import org.eclipse.swt.internal.win32.*;
+import org.eclipse.swt.*;
+
+/**
+ * Instances of this class represent areas of an x-y coordinate
+ * system that are aggregates of the areas covered by a number
+ * of 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.
+ *
+ * @exception SWTError <ul>
+ * <li>ERROR_NO_HANDLES if a handle could not be obtained for region creation</li>
+ * </ul>
+ */
+public Region () {
+ handle = OS.CreateRectRgn (0, 0, 0, 0);
+ if (handle == 0) SWT.error(SWT.ERROR_NO_HANDLES);
+}
+
+/**
+ * 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>
+ * <li>ERROR_INVALID_ARGUMENT - if the rectangle's width or height is negative</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ */
+public void add (Rectangle rect) {
+ if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ if (rect == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ if (rect.width < 0 || rect.height < 0) SWT.error(SWT.ERROR_INVALID_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>
+ * <li>ERROR_INVALID_ARGUMENT - if the argument has been disposed</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ */
+public void add (Region region) {
+ if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ if (region == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ if (region.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+ OS.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
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ */
+public boolean contains (int x, int y) {
+ if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ return OS.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>
+ * @exception SWTException <ul>
+ * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ */
+public boolean contains (Point pt) {
+ if (pt == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ return contains(pt.x, pt.y);
+}
+
+/**
+ * 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;
+ Region rgn = (Region)object;
+ return handle == rgn.handle;
+}
+
+/**
+ * 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
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ *
+ * @see Rectangle#union
+ */
+public Rectangle getBounds() {
+ if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ 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
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ *
+ * @see Rectangle#intersects
+ */
+public boolean intersects (int x, int y, int width, int height) {
+ if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ 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>
+ * @exception SWTException <ul>
+ * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</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
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ */
+public boolean isEmpty () {
+ if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ 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);
+}
+
+/**
+ * Returns a string containing a concise, human-readable
+ * description of the receiver.
+ *
+ * @return a string representation of the receiver
+ */
+public String toString () {
+ if (isDisposed()) return "Region {*DISPOSED*}";
+ return "Region {" + handle + "}";
+}
+
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/BidiUtil.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/BidiUtil.java
index 1b39904fbd..73c1d4cd57 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/BidiUtil.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/BidiUtil.java
@@ -1,532 +1,532 @@
-package org.eclipse.swt.internal;
-
-/*
+package org.eclipse.swt.internal;
+
+/*
* Copyright (c) 2001, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.graphics.GC;
-import org.eclipse.swt.internal.win32.GCP_RESULTS;
-import org.eclipse.swt.internal.win32.OS;
-import org.eclipse.swt.internal.win32.RECT;
-import org.eclipse.swt.internal.win32.TCHAR;
-import java.util.Hashtable;
-/*
- * Wraps Win32 API used to bidi enable the StyledText widget.
- */
-public class BidiUtil {
-
- // Keyboard language ids
- public static final int KEYBOARD_NON_BIDI = 0;
- public static final int KEYBOARD_BIDI = 1;
-
- // bidi flag
- static int isBidiPlatform = -1;
-
- // getRenderInfo flag values
- public static final int CLASSIN = 1;
- public static final int LINKBEFORE = 2;
- public static final int LINKAFTER = 4;
-
- // variables used for providing a listener mechanism for keyboard language
- // switching
- static Hashtable map = new Hashtable ();
- static Hashtable oldProcMap = new Hashtable ();
- /*
- * This code is intentionally commented. In order
- * to support CLDC, .class cannot be used because
- * it does not compile on some Java compilers when
- * they are targeted for CLDC.
- */
- // static Callback callback = new Callback (BidiUtil.class, "windowProc", 4);
- static final String CLASS_NAME = "org.eclipse.swt.internal.BidiUtil";
- static Callback callback;
- static {
- try {
- callback = new Callback (Class.forName (CLASS_NAME), "windowProc", 4);
- } catch (ClassNotFoundException e) {}
- }
-
- // GetCharacterPlacement constants
- static final int GCP_REORDER = 0x0002;
- static final int GCP_GLYPHSHAPE = 0x0010;
- static final int GCP_LIGATE = 0x0020;
- static final int GCP_CLASSIN = 0x00080000;
- static final byte GCPCLASS_ARABIC = 2;
- static final byte GCPCLASS_HEBREW = 2;
- static final byte GCPCLASS_LOCALNUMBER = 4;
- static final int GCPGLYPH_LINKBEFORE = 0x8000;
- static final int GCPGLYPH_LINKAFTER = 0x4000;
- // ExtTextOut constants
- static final int ETO_GLYPH_INDEX = 0x0010;
- // Windows primary language identifiers
- static final int LANG_ARABIC = 0x01;
- static final int LANG_HEBREW = 0x0d;
- // code page identifiers
- static final String CD_PG_HEBREW = "1255";
- static final String CD_PG_ARABIC = "1256";
- // ActivateKeyboard constants
- static final int HKL_NEXT = 1;
- static final int HKL_PREV = 0;
-
- /*
- * Public character class constants are the same as Windows
- * platform constants.
- * Saves conversion of class array in getRenderInfo to arbitrary
- * constants for now.
- */
- public static final int CLASS_HEBREW = GCPCLASS_ARABIC;
- public static final int CLASS_ARABIC = GCPCLASS_HEBREW;
- public static final int CLASS_LOCALNUMBER = GCPCLASS_LOCALNUMBER;
- public static final int REORDER = GCP_REORDER;
- public static final int LIGATE = GCP_LIGATE;
- public static final int GLYPHSHAPE = GCP_GLYPHSHAPE;
-
-/**
- * Adds a language listener. The listener will get notified when the language of
- * the keyboard changes (via Alt-Shift on Win platforms). Do this by creating a
- * window proc for the Control so that the window messages for the Control can be
- * monitored.
- * <p>
- *
- * @param int the handle of the Control that is listening for keyboard language
- * changes
- * @param runnable the code that should be executed when a keyboard language change
- * occurs
- */
-public static void addLanguageListener (int hwnd, Runnable runnable) {
- map.put (new Integer (hwnd), runnable);
- int oldProc = OS.GetWindowLong (hwnd, OS.GWL_WNDPROC);
- oldProcMap.put (new Integer(hwnd), new Integer(oldProc));
- OS.SetWindowLong (hwnd, OS.GWL_WNDPROC, callback.getAddress ());
-}
-/**
- * Proc used for OS.EnumSystemLanguageGroups call during isBidiPlatform test.
- */
-static int EnumSystemLanguageGroupsProc(int lpLangGrpId, int lpLangGrpIdString, int lpLangGrpName, int options, int lParam) {
- if (lpLangGrpId == OS.LGRPID_HEBREW) {
- isBidiPlatform = 1;
- return 0;
- }
- if (lpLangGrpId == OS.LGRPID_ARABIC) {
- isBidiPlatform = 1;
- return 0;
- }
- return 1;
-}
-/**
- * Wraps the ExtTextOut function.
- * <p>
- *
- * @param gc the gc to use for rendering
- * @param renderBuffer the glyphs to render as an array of characters
- * @param renderDx the width of each glyph in renderBuffer
- * @param x x position to start rendering
- * @param y y position to start rendering
- */
-public static void drawGlyphs(GC gc, char[] renderBuffer, int[] renderDx, int x, int y) {
- RECT rect = null;
- OS.ExtTextOutW(gc.handle, x, y, ETO_GLYPH_INDEX, rect, renderBuffer, renderBuffer.length, renderDx);
-}
-/**
- * Return ordering and rendering information for the given text. Wraps the GetFontLanguageInfo
- * and GetCharacterPlacement functions.
- * <p>
- *
- * @param gc the GC to use for measuring of this line, input parameter
- * @param text text that bidi data should be calculated for, input parameter
- * @param order an array of integers representing the visual position of each character in
- * the text array, output parameter
- * @param classBuffer an array of integers representing the type (e.g., ARABIC, HEBREW,
- * LOCALNUMBER) of each character in the text array, input/output parameter
- * @param dx an array of integers representing the pixel width of each glyph in the returned
- * glyph buffer, output paramteter
- * @param flags an integer representing rendering flag information, input parameter
- * @param offsets text segments that should be measured and reordered separately, input
- * parameter. See org.eclipse.swt.custom.BidiSegmentEvent for details.
- * @return buffer with the glyphs that should be rendered for the given text
- */
-public static char[] getRenderInfo(GC gc, String text, int[] order, byte[] classBuffer, int[] dx, int flags, int [] offsets) {
- int fontLanguageInfo = OS.GetFontLanguageInfo(gc.handle);
- int hHeap = OS.GetProcessHeap();
- int[] lpCs = new int[8];
- int cs = OS.GetTextCharset(gc.handle);
- OS.TranslateCharsetInfo(cs, lpCs, OS.TCI_SRCCHARSET);
- TCHAR textBuffer = new TCHAR(lpCs[1], text, false);
- int byteCount = textBuffer.length();
- boolean linkBefore = (flags & LINKBEFORE) == LINKBEFORE;
- boolean linkAfter = (flags & LINKAFTER) == LINKAFTER;
-
- GCP_RESULTS result = new GCP_RESULTS();
- result.lStructSize = GCP_RESULTS.sizeof;
- result.nGlyphs = byteCount;
- int lpOrder = result.lpOrder = OS.HeapAlloc(hHeap, OS.HEAP_ZERO_MEMORY, byteCount * 4);
- int lpDx = result.lpDx = OS.HeapAlloc(hHeap, OS.HEAP_ZERO_MEMORY, byteCount * 4);
- int lpClass = result.lpClass = OS.HeapAlloc(hHeap, OS.HEAP_ZERO_MEMORY, byteCount);
- int lpGlyphs = result.lpGlyphs = OS.HeapAlloc(hHeap, OS.HEAP_ZERO_MEMORY, byteCount * 2);
-
- // set required dwFlags
- int dwFlags = 0;
- int glyphFlags = 0;
- // Always reorder. We assume that if we are calling this function we're
- // on a platform that supports bidi. Fixes 20690.
- dwFlags |= GCP_REORDER;
- if ((fontLanguageInfo & GCP_LIGATE) == GCP_LIGATE) {
- dwFlags |= GCP_LIGATE;
- glyphFlags |= 0;
- }
- if ((fontLanguageInfo & GCP_GLYPHSHAPE) == GCP_GLYPHSHAPE) {
- dwFlags |= GCP_GLYPHSHAPE;
- if (linkBefore) {
- glyphFlags |= GCPGLYPH_LINKBEFORE;
- }
- if (linkAfter) {
- glyphFlags |= GCPGLYPH_LINKAFTER;
- }
- }
- byte[] lpGlyphs2;
- if (linkBefore || linkAfter) {
- lpGlyphs2 = new byte[2];
- lpGlyphs2[0]=(byte)glyphFlags;
- lpGlyphs2[1]=(byte)(glyphFlags >> 8);
- }
- else {
- lpGlyphs2 = new byte[] {(byte) glyphFlags};
- }
- OS.MoveMemory(result.lpGlyphs, lpGlyphs2, lpGlyphs2.length);
-
- if ((flags & CLASSIN) == CLASSIN) {
- // set classification values for the substring
- dwFlags |= GCP_CLASSIN;
- OS.MoveMemory(result.lpClass, classBuffer, classBuffer.length);
- }
-
- char[] glyphBuffer = new char[result.nGlyphs];
- int glyphCount = 0;
- for (int i=0; i<offsets.length-1; i++) {
- int offset = offsets [i];
- int length = offsets [i+1] - offsets [i];
-
- // The number of glyphs expected is <= length (segment length);
- // the actual number returned may be less in case of Arabic ligatures.
- result.nGlyphs = length;
- TCHAR textBuffer2 = new TCHAR(lpCs[1], text.substring(offset, offset + length), false);
- OS.GetCharacterPlacement(gc.handle, textBuffer2, textBuffer2.length(), 0, result, dwFlags);
-
- if (dx != null) {
- int [] dx2 = new int [result.nGlyphs];
- OS.MoveMemory(dx2, result.lpDx, dx2.length * 4);
- System.arraycopy (dx2, 0, dx, glyphCount, dx2.length);
- }
- if (order != null) {
- int [] order2 = new int [length];
- OS.MoveMemory(order2, result.lpOrder, order2.length * 4);
- for (int j=0; j<length; j++) {
- order2 [j] += glyphCount;
- }
- System.arraycopy (order2, 0, order, offset, length);
- }
- if (classBuffer != null) {
- byte [] classBuffer2 = new byte [length];
- OS.MoveMemory(classBuffer2, result.lpClass, classBuffer2.length);
- System.arraycopy (classBuffer2, 0, classBuffer, offset, length);
- }
- char[] glyphBuffer2 = new char[result.nGlyphs];
- OS.MoveMemory(glyphBuffer2, result.lpGlyphs, glyphBuffer2.length * 2);
- System.arraycopy (glyphBuffer2, 0, glyphBuffer, glyphCount, glyphBuffer2.length);
- glyphCount += glyphBuffer2.length;
-
- // We concatenate successive results of calls to GCP.
- // For Arabic, it is the only good method since the number of output
- // glyphs might be less than the number of input characters.
- // This assumes that the whole line is built by successive adjacent
- // segments without overlapping.
- result.lpOrder += length * 4;
- result.lpDx += length * 4;
- result.lpClass += length;
- result.lpGlyphs += glyphBuffer2.length * 2;
- }
-
- /* Free the memory that was allocated. */
- OS.HeapFree(hHeap, 0, lpGlyphs);
- OS.HeapFree(hHeap, 0, lpClass);
- OS.HeapFree(hHeap, 0, lpDx);
- OS.HeapFree(hHeap, 0, lpOrder);
- return glyphBuffer;
-}
-/**
- * Return bidi ordering information for the given text. Does not return rendering
- * information (e.g., glyphs, glyph distances). Use this method when you only need
- * ordering information. Doing so will improve performance. Wraps the
- * GetFontLanguageInfo and GetCharacterPlacement functions.
- * <p>
- *
- * @param gc the GC to use for measuring of this line, input parameter
- * @param text text that bidi data should be calculated for, input parameter
- * @param order an array of integers representing the visual position of each character in
- * the text array, output parameter
- * @param classBuffer an array of integers representing the type (e.g., ARABIC, HEBREW,
- * LOCALNUMBER) of each character in the text array, input/output parameter
- * @param flags an integer representing rendering flag information, input parameter
- * @param offsets text segments that should be measured and reordered separately, input
- * parameter. See org.eclipse.swt.custom.BidiSegmentEvent for details.
- */
-public static void getOrderInfo(GC gc, String text, int[] order, byte[] classBuffer, int flags, int [] offsets) {
- int fontLanguageInfo = OS.GetFontLanguageInfo(gc.handle);
- int hHeap = OS.GetProcessHeap();
- int[] lpCs = new int[8];
- int cs = OS.GetTextCharset(gc.handle);
- OS.TranslateCharsetInfo(cs, lpCs, OS.TCI_SRCCHARSET);
- TCHAR textBuffer = new TCHAR(lpCs[1], text, false);
- int byteCount = textBuffer.length();
-
- GCP_RESULTS result = new GCP_RESULTS();
- result.lStructSize = GCP_RESULTS.sizeof;
- result.nGlyphs = byteCount;
- int lpOrder = result.lpOrder = OS.HeapAlloc(hHeap, OS.HEAP_ZERO_MEMORY, byteCount * 4);
- int lpClass = result.lpClass = OS.HeapAlloc(hHeap, OS.HEAP_ZERO_MEMORY, byteCount);
-
- // set required dwFlags, these values will affect how the text gets rendered and
- // ordered
- int dwFlags = 0;
- // Always reorder. We assume that if we are calling this function we're
- // on a platform that supports bidi. Fixes 20690.
- dwFlags |= GCP_REORDER;
- if ((fontLanguageInfo & GCP_LIGATE) == GCP_LIGATE) {
- dwFlags |= GCP_LIGATE;
- }
- if ((fontLanguageInfo & GCP_GLYPHSHAPE) == GCP_GLYPHSHAPE) {
- dwFlags |= GCP_GLYPHSHAPE;
- }
- if ((flags & CLASSIN) == CLASSIN) {
- // set classification values for the substring, classification values
- // can be specified on input
- dwFlags |= GCP_CLASSIN;
- OS.MoveMemory(result.lpClass, classBuffer, classBuffer.length);
- }
-
- int glyphCount = 0;
- for (int i=0; i<offsets.length-1; i++) {
- int offset = offsets [i];
- int length = offsets [i+1] - offsets [i];
- // The number of glyphs expected is <= length (segment length);
- // the actual number returned may be less in case of Arabic ligatures.
- result.nGlyphs = length;
- TCHAR textBuffer2 = new TCHAR(lpCs[1], text.substring(offset, offset + length), false);
- OS.GetCharacterPlacement(gc.handle, textBuffer2, textBuffer2.length(), 0, result, dwFlags);
-
- if (order != null) {
- int [] order2 = new int [length];
- OS.MoveMemory(order2, result.lpOrder, order2.length * 4);
- for (int j=0; j<length; j++) {
- order2 [j] += glyphCount;
- }
- System.arraycopy (order2, 0, order, offset, length);
- }
- if (classBuffer != null) {
- byte [] classBuffer2 = new byte [length];
- OS.MoveMemory(classBuffer2, result.lpClass, classBuffer2.length);
- System.arraycopy (classBuffer2, 0, classBuffer, offset, length);
- }
- glyphCount += result.nGlyphs;
-
- // We concatenate successive results of calls to GCP.
- // For Arabic, it is the only good method since the number of output
- // glyphs might be less than the number of input characters.
- // This assumes that the whole line is built by successive adjacent
- // segments without overlapping.
- result.lpOrder += length * 4;
- result.lpClass += length;
- }
-
- /* Free the memory that was allocated. */
- OS.HeapFree(hHeap, 0, lpClass);
- OS.HeapFree(hHeap, 0, lpOrder);
-}
-/**
- * Return bidi attribute information for the font in the specified gc.
- * <p>
- *
- * @param gc the gc to query
- * @return bitwise OR of the REORDER, LIGATE and GLYPHSHAPE flags
- * defined by this class.
- */
-public static int getFontBidiAttributes(GC gc) {
- int fontStyle = 0;
- int fontLanguageInfo = OS.GetFontLanguageInfo(gc.handle);
- if (((fontLanguageInfo & GCP_REORDER) != 0)) {
- fontStyle |= REORDER;
- }
- if (((fontLanguageInfo & GCP_LIGATE) != 0)) {
- fontStyle |= LIGATE;
- }
- if (((fontLanguageInfo & GCP_GLYPHSHAPE) != 0)) {
- fontStyle |= GLYPHSHAPE;
- }
- return fontStyle;
-}
-/**
- * Return the active keyboard language type.
- * <p>
- *
- * @return an integer representing the active keyboard language (KEYBOARD_BIDI,
- * KEYBOARD_NON_BIDI)
- */
-public static int getKeyboardLanguage() {
- int layout = OS.GetKeyboardLayout(0);
- // only interested in low 2 bytes, which is the primary
- // language identifier
- layout = layout & 0x000000FF;
- if (layout == LANG_HEBREW) return KEYBOARD_BIDI;
- if (layout == LANG_ARABIC) return KEYBOARD_BIDI;
- // return non-bidi for all other languages
- return KEYBOARD_NON_BIDI;
-}
-/**
- * Return the languages that are installed for the keyboard.
- * <p>
- *
- * @return integer array with an entry for each installed language
- */
-public static int[] getKeyboardLanguageList() {
- int maxSize = 10;
- int[] tempList = new int[maxSize];
- int size = OS.GetKeyboardLayoutList(maxSize, tempList);
- int[] list = new int[size];
- System.arraycopy(tempList, 0, list, 0, size);
- return list;
-}
-/**
- * Return whether or not the platform supports a bidi language. Determine this
- * by looking at the languages that are installed.
- * <p>
- *
- * @return true if bidi is supported, false otherwise. Always
- * false on Windows CE.
- */
-public static boolean isBidiPlatform() {
- if (OS.IsWinCE) return false;
- if (isBidiPlatform != -1) return isBidiPlatform == 1; // already set
-
- isBidiPlatform = 0;
-
- // The following test is a workaround for bug report 27629. On WinXP,
- // both bidi and complex script (e.g., Thai) languages must be installed
- // at the same time. Since the bidi platform calls do not support
- // double byte characters, there is no way to run Eclipse using the
- // complex script languages on XP, so constrain this test to answer true
- // only if a bidi input language is defined. Doing so will allow complex
- // script languages to work (e.g., one can install bidi and complex script
- // languages, but only install the Thai keyboard).
- if (!isKeyboardBidi()) return false;
-
- Callback callback = null;
- try {
- callback = new Callback (Class.forName (CLASS_NAME), "EnumSystemLanguageGroupsProc", 5);
- int lpEnumSystemLanguageGroupsProc = callback.getAddress ();
- if (lpEnumSystemLanguageGroupsProc == 0) SWT.error(SWT.ERROR_NO_MORE_CALLBACKS);
- OS.EnumSystemLanguageGroups(lpEnumSystemLanguageGroupsProc, OS.LGRPID_INSTALLED, 0);
- callback.dispose ();
- } catch (ClassNotFoundException e) {
- if (callback != null) callback.dispose();
- }
- if (isBidiPlatform == 1) return true;
- // need to look at system code page for NT & 98 platforms since EnumSystemLanguageGroups is
- // not supported for these platforms
- String codePage = String.valueOf(OS.GetACP());
- if (CD_PG_ARABIC.equals(codePage) || CD_PG_HEBREW.equals(codePage)) {
- isBidiPlatform = 1;
- }
- return isBidiPlatform == 1;
-}
-/**
- * Return whether or not the keyboard supports input of a bidi language. Determine this
- * by looking at the languages that are installed for the keyboard.
- * <p>
- *
- * @return true if bidi is supported, false otherwise.
- */
-public static boolean isKeyboardBidi() {
- int[] list = getKeyboardLanguageList();
- for (int i=0; i<list.length; i++) {
- int id = list[i] & 0x000000FF;
- if ((id == LANG_ARABIC) || (id == LANG_HEBREW)) {
- return true;
- }
- }
- return false;
-}
-/**
- * Removes the specified language listener.
- * <p>
- *
- * @param hwnd the handle of the Control that is listening for keyboard language changes
- */
-public static void removeLanguageListener (int hwnd) {
- map.remove (new Integer (hwnd));
- Integer proc = (Integer)oldProcMap.remove (new Integer (hwnd));
- if (proc == null) return;
- OS.SetWindowLong (hwnd, OS.GWL_WNDPROC, proc.intValue());
-}
-/**
- * Switch the keyboard language to the specified language type. We do
- * not distinguish between mulitple bidi or multiple non-bidi languages, so
- * set the keyboard to the first language of the given type.
- * <p>
- *
- * @param language integer representing language. One of
- * KEYBOARD_BIDI, KEYBOARD_NON_BIDI.
- */
-public static void setKeyboardLanguage(int language) {
- // don't switch the keyboard if it doesn't need to be
- if (language == getKeyboardLanguage()) return;
-
- if (language == KEYBOARD_BIDI) {
- // get the list of active languages
- int[] list = getKeyboardLanguageList();
- // set to first bidi language
- for (int i=0; i<list.length; i++) {
- int id = list[i] & 0x000000FF;
- if ((id == LANG_ARABIC) || (id == LANG_HEBREW)) {
- OS.ActivateKeyboardLayout(list[i], 0);
- return;
- }
- }
- } else {
- // get the list of active languages
- int[] list = getKeyboardLanguageList();
- // set to the first non-bidi language (anything not
- // hebrew or arabic)
- for (int i=0; i<list.length; i++) {
- int id = list[i] & 0x000000FF;
- if ((id != LANG_HEBREW) && (id != LANG_ARABIC)) {
- OS.ActivateKeyboardLayout(list[i], 0);
- return;
- }
- }
- }
-
-}
-/**
- * Window proc to intercept keyboard language switch event (WS_INPUTLANGCHANGE).
- * Run the Control's registered runnable when the keyboard language is switched.
- *
- * @param hwnd handle of the control that is listening for the keyboard language
- * change event
- * @param msg window message
- */
-static int windowProc (int hwnd, int msg, int wParam, int lParam) {
- switch (msg) {
- case 0x51 /*OS.WM_INPUTLANGCHANGE*/:
- Runnable runnable = (Runnable) map.get (new Integer (hwnd));
- if (runnable != null) runnable.run ();
- break;
- }
- Integer oldProc = (Integer)oldProcMap.get(new Integer(hwnd));
- return OS.CallWindowProc (oldProc.intValue(), hwnd, msg, wParam, lParam);
-}
-
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.GC;
+import org.eclipse.swt.internal.win32.GCP_RESULTS;
+import org.eclipse.swt.internal.win32.OS;
+import org.eclipse.swt.internal.win32.RECT;
+import org.eclipse.swt.internal.win32.TCHAR;
+import java.util.Hashtable;
+/*
+ * Wraps Win32 API used to bidi enable the StyledText widget.
+ */
+public class BidiUtil {
+
+ // Keyboard language ids
+ public static final int KEYBOARD_NON_BIDI = 0;
+ public static final int KEYBOARD_BIDI = 1;
+
+ // bidi flag
+ static int isBidiPlatform = -1;
+
+ // getRenderInfo flag values
+ public static final int CLASSIN = 1;
+ public static final int LINKBEFORE = 2;
+ public static final int LINKAFTER = 4;
+
+ // variables used for providing a listener mechanism for keyboard language
+ // switching
+ static Hashtable map = new Hashtable ();
+ static Hashtable oldProcMap = new Hashtable ();
+ /*
+ * This code is intentionally commented. In order
+ * to support CLDC, .class cannot be used because
+ * it does not compile on some Java compilers when
+ * they are targeted for CLDC.
+ */
+ // static Callback callback = new Callback (BidiUtil.class, "windowProc", 4);
+ static final String CLASS_NAME = "org.eclipse.swt.internal.BidiUtil";
+ static Callback callback;
+ static {
+ try {
+ callback = new Callback (Class.forName (CLASS_NAME), "windowProc", 4);
+ } catch (ClassNotFoundException e) {}
+ }
+
+ // GetCharacterPlacement constants
+ static final int GCP_REORDER = 0x0002;
+ static final int GCP_GLYPHSHAPE = 0x0010;
+ static final int GCP_LIGATE = 0x0020;
+ static final int GCP_CLASSIN = 0x00080000;
+ static final byte GCPCLASS_ARABIC = 2;
+ static final byte GCPCLASS_HEBREW = 2;
+ static final byte GCPCLASS_LOCALNUMBER = 4;
+ static final int GCPGLYPH_LINKBEFORE = 0x8000;
+ static final int GCPGLYPH_LINKAFTER = 0x4000;
+ // ExtTextOut constants
+ static final int ETO_GLYPH_INDEX = 0x0010;
+ // Windows primary language identifiers
+ static final int LANG_ARABIC = 0x01;
+ static final int LANG_HEBREW = 0x0d;
+ // code page identifiers
+ static final String CD_PG_HEBREW = "1255";
+ static final String CD_PG_ARABIC = "1256";
+ // ActivateKeyboard constants
+ static final int HKL_NEXT = 1;
+ static final int HKL_PREV = 0;
+
+ /*
+ * Public character class constants are the same as Windows
+ * platform constants.
+ * Saves conversion of class array in getRenderInfo to arbitrary
+ * constants for now.
+ */
+ public static final int CLASS_HEBREW = GCPCLASS_ARABIC;
+ public static final int CLASS_ARABIC = GCPCLASS_HEBREW;
+ public static final int CLASS_LOCALNUMBER = GCPCLASS_LOCALNUMBER;
+ public static final int REORDER = GCP_REORDER;
+ public static final int LIGATE = GCP_LIGATE;
+ public static final int GLYPHSHAPE = GCP_GLYPHSHAPE;
+
+/**
+ * Adds a language listener. The listener will get notified when the language of
+ * the keyboard changes (via Alt-Shift on Win platforms). Do this by creating a
+ * window proc for the Control so that the window messages for the Control can be
+ * monitored.
+ * <p>
+ *
+ * @param int the handle of the Control that is listening for keyboard language
+ * changes
+ * @param runnable the code that should be executed when a keyboard language change
+ * occurs
+ */
+public static void addLanguageListener (int hwnd, Runnable runnable) {
+ map.put (new Integer (hwnd), runnable);
+ int oldProc = OS.GetWindowLong (hwnd, OS.GWL_WNDPROC);
+ oldProcMap.put (new Integer(hwnd), new Integer(oldProc));
+ OS.SetWindowLong (hwnd, OS.GWL_WNDPROC, callback.getAddress ());
+}
+/**
+ * Proc used for OS.EnumSystemLanguageGroups call during isBidiPlatform test.
+ */
+static int EnumSystemLanguageGroupsProc(int lpLangGrpId, int lpLangGrpIdString, int lpLangGrpName, int options, int lParam) {
+ if (lpLangGrpId == OS.LGRPID_HEBREW) {
+ isBidiPlatform = 1;
+ return 0;
+ }
+ if (lpLangGrpId == OS.LGRPID_ARABIC) {
+ isBidiPlatform = 1;
+ return 0;
+ }
+ return 1;
+}
+/**
+ * Wraps the ExtTextOut function.
+ * <p>
+ *
+ * @param gc the gc to use for rendering
+ * @param renderBuffer the glyphs to render as an array of characters
+ * @param renderDx the width of each glyph in renderBuffer
+ * @param x x position to start rendering
+ * @param y y position to start rendering
+ */
+public static void drawGlyphs(GC gc, char[] renderBuffer, int[] renderDx, int x, int y) {
+ RECT rect = null;
+ OS.ExtTextOutW(gc.handle, x, y, ETO_GLYPH_INDEX, rect, renderBuffer, renderBuffer.length, renderDx);
+}
+/**
+ * Return ordering and rendering information for the given text. Wraps the GetFontLanguageInfo
+ * and GetCharacterPlacement functions.
+ * <p>
+ *
+ * @param gc the GC to use for measuring of this line, input parameter
+ * @param text text that bidi data should be calculated for, input parameter
+ * @param order an array of integers representing the visual position of each character in
+ * the text array, output parameter
+ * @param classBuffer an array of integers representing the type (e.g., ARABIC, HEBREW,
+ * LOCALNUMBER) of each character in the text array, input/output parameter
+ * @param dx an array of integers representing the pixel width of each glyph in the returned
+ * glyph buffer, output paramteter
+ * @param flags an integer representing rendering flag information, input parameter
+ * @param offsets text segments that should be measured and reordered separately, input
+ * parameter. See org.eclipse.swt.custom.BidiSegmentEvent for details.
+ * @return buffer with the glyphs that should be rendered for the given text
+ */
+public static char[] getRenderInfo(GC gc, String text, int[] order, byte[] classBuffer, int[] dx, int flags, int [] offsets) {
+ int fontLanguageInfo = OS.GetFontLanguageInfo(gc.handle);
+ int hHeap = OS.GetProcessHeap();
+ int[] lpCs = new int[8];
+ int cs = OS.GetTextCharset(gc.handle);
+ OS.TranslateCharsetInfo(cs, lpCs, OS.TCI_SRCCHARSET);
+ TCHAR textBuffer = new TCHAR(lpCs[1], text, false);
+ int byteCount = textBuffer.length();
+ boolean linkBefore = (flags & LINKBEFORE) == LINKBEFORE;
+ boolean linkAfter = (flags & LINKAFTER) == LINKAFTER;
+
+ GCP_RESULTS result = new GCP_RESULTS();
+ result.lStructSize = GCP_RESULTS.sizeof;
+ result.nGlyphs = byteCount;
+ int lpOrder = result.lpOrder = OS.HeapAlloc(hHeap, OS.HEAP_ZERO_MEMORY, byteCount * 4);
+ int lpDx = result.lpDx = OS.HeapAlloc(hHeap, OS.HEAP_ZERO_MEMORY, byteCount * 4);
+ int lpClass = result.lpClass = OS.HeapAlloc(hHeap, OS.HEAP_ZERO_MEMORY, byteCount);
+ int lpGlyphs = result.lpGlyphs = OS.HeapAlloc(hHeap, OS.HEAP_ZERO_MEMORY, byteCount * 2);
+
+ // set required dwFlags
+ int dwFlags = 0;
+ int glyphFlags = 0;
+ // Always reorder. We assume that if we are calling this function we're
+ // on a platform that supports bidi. Fixes 20690.
+ dwFlags |= GCP_REORDER;
+ if ((fontLanguageInfo & GCP_LIGATE) == GCP_LIGATE) {
+ dwFlags |= GCP_LIGATE;
+ glyphFlags |= 0;
+ }
+ if ((fontLanguageInfo & GCP_GLYPHSHAPE) == GCP_GLYPHSHAPE) {
+ dwFlags |= GCP_GLYPHSHAPE;
+ if (linkBefore) {
+ glyphFlags |= GCPGLYPH_LINKBEFORE;
+ }
+ if (linkAfter) {
+ glyphFlags |= GCPGLYPH_LINKAFTER;
+ }
+ }
+ byte[] lpGlyphs2;
+ if (linkBefore || linkAfter) {
+ lpGlyphs2 = new byte[2];
+ lpGlyphs2[0]=(byte)glyphFlags;
+ lpGlyphs2[1]=(byte)(glyphFlags >> 8);
+ }
+ else {
+ lpGlyphs2 = new byte[] {(byte) glyphFlags};
+ }
+ OS.MoveMemory(result.lpGlyphs, lpGlyphs2, lpGlyphs2.length);
+
+ if ((flags & CLASSIN) == CLASSIN) {
+ // set classification values for the substring
+ dwFlags |= GCP_CLASSIN;
+ OS.MoveMemory(result.lpClass, classBuffer, classBuffer.length);
+ }
+
+ char[] glyphBuffer = new char[result.nGlyphs];
+ int glyphCount = 0;
+ for (int i=0; i<offsets.length-1; i++) {
+ int offset = offsets [i];
+ int length = offsets [i+1] - offsets [i];
+
+ // The number of glyphs expected is <= length (segment length);
+ // the actual number returned may be less in case of Arabic ligatures.
+ result.nGlyphs = length;
+ TCHAR textBuffer2 = new TCHAR(lpCs[1], text.substring(offset, offset + length), false);
+ OS.GetCharacterPlacement(gc.handle, textBuffer2, textBuffer2.length(), 0, result, dwFlags);
+
+ if (dx != null) {
+ int [] dx2 = new int [result.nGlyphs];
+ OS.MoveMemory(dx2, result.lpDx, dx2.length * 4);
+ System.arraycopy (dx2, 0, dx, glyphCount, dx2.length);
+ }
+ if (order != null) {
+ int [] order2 = new int [length];
+ OS.MoveMemory(order2, result.lpOrder, order2.length * 4);
+ for (int j=0; j<length; j++) {
+ order2 [j] += glyphCount;
+ }
+ System.arraycopy (order2, 0, order, offset, length);
+ }
+ if (classBuffer != null) {
+ byte [] classBuffer2 = new byte [length];
+ OS.MoveMemory(classBuffer2, result.lpClass, classBuffer2.length);
+ System.arraycopy (classBuffer2, 0, classBuffer, offset, length);
+ }
+ char[] glyphBuffer2 = new char[result.nGlyphs];
+ OS.MoveMemory(glyphBuffer2, result.lpGlyphs, glyphBuffer2.length * 2);
+ System.arraycopy (glyphBuffer2, 0, glyphBuffer, glyphCount, glyphBuffer2.length);
+ glyphCount += glyphBuffer2.length;
+
+ // We concatenate successive results of calls to GCP.
+ // For Arabic, it is the only good method since the number of output
+ // glyphs might be less than the number of input characters.
+ // This assumes that the whole line is built by successive adjacent
+ // segments without overlapping.
+ result.lpOrder += length * 4;
+ result.lpDx += length * 4;
+ result.lpClass += length;
+ result.lpGlyphs += glyphBuffer2.length * 2;
+ }
+
+ /* Free the memory that was allocated. */
+ OS.HeapFree(hHeap, 0, lpGlyphs);
+ OS.HeapFree(hHeap, 0, lpClass);
+ OS.HeapFree(hHeap, 0, lpDx);
+ OS.HeapFree(hHeap, 0, lpOrder);
+ return glyphBuffer;
+}
+/**
+ * Return bidi ordering information for the given text. Does not return rendering
+ * information (e.g., glyphs, glyph distances). Use this method when you only need
+ * ordering information. Doing so will improve performance. Wraps the
+ * GetFontLanguageInfo and GetCharacterPlacement functions.
+ * <p>
+ *
+ * @param gc the GC to use for measuring of this line, input parameter
+ * @param text text that bidi data should be calculated for, input parameter
+ * @param order an array of integers representing the visual position of each character in
+ * the text array, output parameter
+ * @param classBuffer an array of integers representing the type (e.g., ARABIC, HEBREW,
+ * LOCALNUMBER) of each character in the text array, input/output parameter
+ * @param flags an integer representing rendering flag information, input parameter
+ * @param offsets text segments that should be measured and reordered separately, input
+ * parameter. See org.eclipse.swt.custom.BidiSegmentEvent for details.
+ */
+public static void getOrderInfo(GC gc, String text, int[] order, byte[] classBuffer, int flags, int [] offsets) {
+ int fontLanguageInfo = OS.GetFontLanguageInfo(gc.handle);
+ int hHeap = OS.GetProcessHeap();
+ int[] lpCs = new int[8];
+ int cs = OS.GetTextCharset(gc.handle);
+ OS.TranslateCharsetInfo(cs, lpCs, OS.TCI_SRCCHARSET);
+ TCHAR textBuffer = new TCHAR(lpCs[1], text, false);
+ int byteCount = textBuffer.length();
+
+ GCP_RESULTS result = new GCP_RESULTS();
+ result.lStructSize = GCP_RESULTS.sizeof;
+ result.nGlyphs = byteCount;
+ int lpOrder = result.lpOrder = OS.HeapAlloc(hHeap, OS.HEAP_ZERO_MEMORY, byteCount * 4);
+ int lpClass = result.lpClass = OS.HeapAlloc(hHeap, OS.HEAP_ZERO_MEMORY, byteCount);
+
+ // set required dwFlags, these values will affect how the text gets rendered and
+ // ordered
+ int dwFlags = 0;
+ // Always reorder. We assume that if we are calling this function we're
+ // on a platform that supports bidi. Fixes 20690.
+ dwFlags |= GCP_REORDER;
+ if ((fontLanguageInfo & GCP_LIGATE) == GCP_LIGATE) {
+ dwFlags |= GCP_LIGATE;
+ }
+ if ((fontLanguageInfo & GCP_GLYPHSHAPE) == GCP_GLYPHSHAPE) {
+ dwFlags |= GCP_GLYPHSHAPE;
+ }
+ if ((flags & CLASSIN) == CLASSIN) {
+ // set classification values for the substring, classification values
+ // can be specified on input
+ dwFlags |= GCP_CLASSIN;
+ OS.MoveMemory(result.lpClass, classBuffer, classBuffer.length);
+ }
+
+ int glyphCount = 0;
+ for (int i=0; i<offsets.length-1; i++) {
+ int offset = offsets [i];
+ int length = offsets [i+1] - offsets [i];
+ // The number of glyphs expected is <= length (segment length);
+ // the actual number returned may be less in case of Arabic ligatures.
+ result.nGlyphs = length;
+ TCHAR textBuffer2 = new TCHAR(lpCs[1], text.substring(offset, offset + length), false);
+ OS.GetCharacterPlacement(gc.handle, textBuffer2, textBuffer2.length(), 0, result, dwFlags);
+
+ if (order != null) {
+ int [] order2 = new int [length];
+ OS.MoveMemory(order2, result.lpOrder, order2.length * 4);
+ for (int j=0; j<length; j++) {
+ order2 [j] += glyphCount;
+ }
+ System.arraycopy (order2, 0, order, offset, length);
+ }
+ if (classBuffer != null) {
+ byte [] classBuffer2 = new byte [length];
+ OS.MoveMemory(classBuffer2, result.lpClass, classBuffer2.length);
+ System.arraycopy (classBuffer2, 0, classBuffer, offset, length);
+ }
+ glyphCount += result.nGlyphs;
+
+ // We concatenate successive results of calls to GCP.
+ // For Arabic, it is the only good method since the number of output
+ // glyphs might be less than the number of input characters.
+ // This assumes that the whole line is built by successive adjacent
+ // segments without overlapping.
+ result.lpOrder += length * 4;
+ result.lpClass += length;
+ }
+
+ /* Free the memory that was allocated. */
+ OS.HeapFree(hHeap, 0, lpClass);
+ OS.HeapFree(hHeap, 0, lpOrder);
+}
+/**
+ * Return bidi attribute information for the font in the specified gc.
+ * <p>
+ *
+ * @param gc the gc to query
+ * @return bitwise OR of the REORDER, LIGATE and GLYPHSHAPE flags
+ * defined by this class.
+ */
+public static int getFontBidiAttributes(GC gc) {
+ int fontStyle = 0;
+ int fontLanguageInfo = OS.GetFontLanguageInfo(gc.handle);
+ if (((fontLanguageInfo & GCP_REORDER) != 0)) {
+ fontStyle |= REORDER;
+ }
+ if (((fontLanguageInfo & GCP_LIGATE) != 0)) {
+ fontStyle |= LIGATE;
+ }
+ if (((fontLanguageInfo & GCP_GLYPHSHAPE) != 0)) {
+ fontStyle |= GLYPHSHAPE;
+ }
+ return fontStyle;
+}
+/**
+ * Return the active keyboard language type.
+ * <p>
+ *
+ * @return an integer representing the active keyboard language (KEYBOARD_BIDI,
+ * KEYBOARD_NON_BIDI)
+ */
+public static int getKeyboardLanguage() {
+ int layout = OS.GetKeyboardLayout(0);
+ // only interested in low 2 bytes, which is the primary
+ // language identifier
+ layout = layout & 0x000000FF;
+ if (layout == LANG_HEBREW) return KEYBOARD_BIDI;
+ if (layout == LANG_ARABIC) return KEYBOARD_BIDI;
+ // return non-bidi for all other languages
+ return KEYBOARD_NON_BIDI;
+}
+/**
+ * Return the languages that are installed for the keyboard.
+ * <p>
+ *
+ * @return integer array with an entry for each installed language
+ */
+public static int[] getKeyboardLanguageList() {
+ int maxSize = 10;
+ int[] tempList = new int[maxSize];
+ int size = OS.GetKeyboardLayoutList(maxSize, tempList);
+ int[] list = new int[size];
+ System.arraycopy(tempList, 0, list, 0, size);
+ return list;
+}
+/**
+ * Return whether or not the platform supports a bidi language. Determine this
+ * by looking at the languages that are installed.
+ * <p>
+ *
+ * @return true if bidi is supported, false otherwise. Always
+ * false on Windows CE.
+ */
+public static boolean isBidiPlatform() {
+ if (OS.IsWinCE) return false;
+ if (isBidiPlatform != -1) return isBidiPlatform == 1; // already set
+
+ isBidiPlatform = 0;
+
+ // The following test is a workaround for bug report 27629. On WinXP,
+ // both bidi and complex script (e.g., Thai) languages must be installed
+ // at the same time. Since the bidi platform calls do not support
+ // double byte characters, there is no way to run Eclipse using the
+ // complex script languages on XP, so constrain this test to answer true
+ // only if a bidi input language is defined. Doing so will allow complex
+ // script languages to work (e.g., one can install bidi and complex script
+ // languages, but only install the Thai keyboard).
+ if (!isKeyboardBidi()) return false;
+
+ Callback callback = null;
+ try {
+ callback = new Callback (Class.forName (CLASS_NAME), "EnumSystemLanguageGroupsProc", 5);
+ int lpEnumSystemLanguageGroupsProc = callback.getAddress ();
+ if (lpEnumSystemLanguageGroupsProc == 0) SWT.error(SWT.ERROR_NO_MORE_CALLBACKS);
+ OS.EnumSystemLanguageGroups(lpEnumSystemLanguageGroupsProc, OS.LGRPID_INSTALLED, 0);
+ callback.dispose ();
+ } catch (ClassNotFoundException e) {
+ if (callback != null) callback.dispose();
+ }
+ if (isBidiPlatform == 1) return true;
+ // need to look at system code page for NT & 98 platforms since EnumSystemLanguageGroups is
+ // not supported for these platforms
+ String codePage = String.valueOf(OS.GetACP());
+ if (CD_PG_ARABIC.equals(codePage) || CD_PG_HEBREW.equals(codePage)) {
+ isBidiPlatform = 1;
+ }
+ return isBidiPlatform == 1;
+}
+/**
+ * Return whether or not the keyboard supports input of a bidi language. Determine this
+ * by looking at the languages that are installed for the keyboard.
+ * <p>
+ *
+ * @return true if bidi is supported, false otherwise.
+ */
+public static boolean isKeyboardBidi() {
+ int[] list = getKeyboardLanguageList();
+ for (int i=0; i<list.length; i++) {
+ int id = list[i] & 0x000000FF;
+ if ((id == LANG_ARABIC) || (id == LANG_HEBREW)) {
+ return true;
+ }
+ }
+ return false;
+}
+/**
+ * Removes the specified language listener.
+ * <p>
+ *
+ * @param hwnd the handle of the Control that is listening for keyboard language changes
+ */
+public static void removeLanguageListener (int hwnd) {
+ map.remove (new Integer (hwnd));
+ Integer proc = (Integer)oldProcMap.remove (new Integer (hwnd));
+ if (proc == null) return;
+ OS.SetWindowLong (hwnd, OS.GWL_WNDPROC, proc.intValue());
+}
+/**
+ * Switch the keyboard language to the specified language type. We do
+ * not distinguish between mulitple bidi or multiple non-bidi languages, so
+ * set the keyboard to the first language of the given type.
+ * <p>
+ *
+ * @param language integer representing language. One of
+ * KEYBOARD_BIDI, KEYBOARD_NON_BIDI.
+ */
+public static void setKeyboardLanguage(int language) {
+ // don't switch the keyboard if it doesn't need to be
+ if (language == getKeyboardLanguage()) return;
+
+ if (language == KEYBOARD_BIDI) {
+ // get the list of active languages
+ int[] list = getKeyboardLanguageList();
+ // set to first bidi language
+ for (int i=0; i<list.length; i++) {
+ int id = list[i] & 0x000000FF;
+ if ((id == LANG_ARABIC) || (id == LANG_HEBREW)) {
+ OS.ActivateKeyboardLayout(list[i], 0);
+ return;
+ }
+ }
+ } else {
+ // get the list of active languages
+ int[] list = getKeyboardLanguageList();
+ // set to the first non-bidi language (anything not
+ // hebrew or arabic)
+ for (int i=0; i<list.length; i++) {
+ int id = list[i] & 0x000000FF;
+ if ((id != LANG_HEBREW) && (id != LANG_ARABIC)) {
+ OS.ActivateKeyboardLayout(list[i], 0);
+ return;
+ }
+ }
+ }
+
+}
+/**
+ * Window proc to intercept keyboard language switch event (WS_INPUTLANGCHANGE).
+ * Run the Control's registered runnable when the keyboard language is switched.
+ *
+ * @param hwnd handle of the control that is listening for the keyboard language
+ * change event
+ * @param msg window message
+ */
+static int windowProc (int hwnd, int msg, int wParam, int lParam) {
+ switch (msg) {
+ case 0x51 /*OS.WM_INPUTLANGCHANGE*/:
+ Runnable runnable = (Runnable) map.get (new Integer (hwnd));
+ if (runnable != null) runnable.run ();
+ break;
+ }
+ Integer oldProc = (Integer)oldProcMap.get(new Integer(hwnd));
+ return OS.CallWindowProc (oldProc.intValue(), hwnd, msg, wParam, lParam);
+}
+
} \ No newline at end of file
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
index 1a5c388a2b..7699a2a0b0 100755
--- 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
@@ -1,186 +1,186 @@
-package org.eclipse.swt.internal;
-
-/*
+package org.eclipse.swt.internal;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-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>
- *
- * @deprecated
- */
-
-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;
- }
- }
- 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] & 0xFFFF) <= 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);
- }
-}
-
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+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>
+ *
+ * @deprecated
+ */
+
+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;
+ }
+ }
+ 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] & 0xFFFF) <= 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/widgets/Button.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Button.java
index f3038052a8..f2a42c585e 100755
--- 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
@@ -1,712 +1,712 @@
-package org.eclipse.swt.widgets;
-
-/*
+package org.eclipse.swt.widgets;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-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 notification when pressed and released.
- * <dl>
- * <dt><b>Styles:</b></dt>
- * <dd>ARROW, CHECK, PUSH, RADIO, TOGGLE, FLAT</dd>
- * <dd>UP, DOWN, LEFT, RIGHT, CENTER</dd>
- * <dt><b>Events:</b></dt>
- * <dd>Selection</dd>
- * </dl>
- * <p>
- * Note: Only one of the styles ARROW, CHECK, PUSH, RADIO, and TOGGLE
- * may be specified.
- * </p><p>
- * Note: Only one of the styles LEFT, RIGHT, and CENTER may be specified.
- * </p><p>
- * Note: Only one of the styles UP, DOWN, LEFT, and RIGHT may be specified
- * when the ARROW style is specified.
- * </p><p>
- * IMPORTANT: This class is intended to be subclassed <em>only</em>
- * within the SWT implementation.
- * </p>
- */
-
-public class Button extends Control {
- Image image;
- static final int ButtonProc;
- static final TCHAR ButtonClass = new TCHAR (0,"BUTTON", true);
- static final int CheckWidth, CheckHeight;
- static {
- int hBitmap = OS.LoadBitmap (0, OS.OBM_CHECKBOXES);
- if (hBitmap == 0) {
- CheckWidth = OS.GetSystemMetrics (OS.IsWinCE ? OS.SM_CXSMICON : OS.SM_CXVSCROLL);
- CheckHeight = OS.GetSystemMetrics (OS.IsWinCE ? OS.SM_CYSMICON : 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;
- }
- WNDCLASS lpWndClass = new WNDCLASS ();
- OS.GetClassInfo (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
- * lists the style constants that are applicable to the class.
- * Style bits are also inherited from superclasses.
- * </p>
- *
- * @param parent a composite control which will be the parent of the new instance (cannot be null)
- * @param style the style of control to construct
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
- * <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
- * </ul>
- *
- * @see SWT#ARROW
- * @see SWT#CHECK
- * @see SWT#PUSH
- * @see SWT#RADIO
- * @see SWT#TOGGLE
- * @see SWT#FLAT
- * @see SWT#LEFT
- * @see SWT#RIGHT
- * @see SWT#CENTER
- * @see Widget#checkSubclass
- * @see Widget#getStyle
- */
-public Button (Composite parent, int style) {
- super (parent, checkStyle (style));
-}
-
-/**
- * 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.
- * <p>
- * <code>widgetSelected</code> is called when the control is selected.
- * <code>widgetDefaultSelected</code> is not called.
- * </p>
- *
- * @param listener the listener which should be notified
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see SelectionListener
- * @see #removeSelectionListener
- * @see SelectionEvent
- */
-public void addSelectionListener (SelectionListener listener) {
- checkWidget ();
- if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
- TypedListener typedListener = new TypedListener (listener);
- addListener (SWT.Selection,typedListener);
- addListener (SWT.DefaultSelection,typedListener);
-}
-
-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 () {
- /*
- * Note: BM_CLICK sends WM_LBUTTONDOWN and WM_LBUTTONUP.
- */
- 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);
- TCHAR buffer = new TCHAR (getCodePage (), 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) {
- Rectangle rect = image.getBounds ();
- width = rect.width;
- height = rect.height;
- extra = 8;
- }
- }
- if ((style & (SWT.CHECK | SWT.RADIO)) != 0) {
- width += CheckWidth + extra;
- height = Math.max (height, CheckHeight + 3);
- }
- if ((style & (SWT.PUSH | SWT.TOGGLE)) != 0) {
- width += 12; height += 10;
- }
- if (wHint != SWT.DEFAULT) width = wHint + (border * 2);
- if (hHint != SWT.DEFAULT) height = hHint + (border * 2);
- return new Point (width, height);
-}
-
-int defaultBackground () {
- if ((style & (SWT.PUSH | SWT.TOGGLE)) != 0) {
- return OS.GetSysColor (OS.COLOR_BTNFACE);
- }
- return super.defaultBackground ();
-}
-
-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 in. If the receiver is of any other type,
- * this method returns false.
- *
- * @return the selection state
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public boolean getSelection () {
- checkWidget ();
- if ((style & (SWT.CHECK | SWT.RADIO | SWT.TOGGLE)) == 0) return false;
- 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 "";
- TCHAR buffer = new TCHAR (getCodePage (), length + 1);
- OS.GetWindowText (handle, buffer, length + 1);
- return buffer.toString (0, length);
-}
-
-boolean isTabItem () {
- //TEMPORARY CODE
- //if ((style & SWT.PUSH) != 0) return true;
- return super.isTabItem ();
-}
-
-boolean mnemonicHit (char ch) {
- 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 () {
- /*
- * This code is intentionally commented. When two groups
- * of radio buttons with the same parent are separated by
- * another control, the correct behavior should be that
- * the two groups act independently. This is consistent
- * with radio tool and menu items. The commented code
- * implements this behavior.
- */
-// int index = 0;
-// Control [] children = parent._getChildren ();
-// while (index < children.length && children [index] != this) index++;
-// int i = index - 1;
-// while (i >= 0 && children [i].setRadioSelection (false)) --i;
-// int j = index + 1;
-// while (j < children.length && children [j].setRadioSelection (false)) j++;
-// setSelection (true);
- Control [] children = parent._getChildren ();
- for (int i=0; i<children.length; i++) {
- Control child = children [i];
- if (this != child) child.setRadioSelection (false);
- }
- setSelection (true);
-}
-
-/**
- * Controls how text, images and arrows will be displayed
- * in the receiver. The argument should be one of
- * <code>LEFT</code>, <code>RIGHT</code> or <code>CENTER</code>
- * unless the receiver is an <code>ARROW</code> button, in
- * which case, the argument indicates the direction of
- * the arrow (one of <code>LEFT</code>, <code>RIGHT</code>,
- * <code>UP</code> or <code>DOWN</code>).
- *
- * @param alignment the new alignment
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public void setAlignment (int alignment) {
- checkWidget ();
- 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 hwndShell = menuShell ().handle;
- int bits = OS.GetWindowLong (handle, OS.GWL_STYLE);
- if (value) {
- bits |= OS.BS_DEFPUSHBUTTON;
- OS.SendMessage (hwndShell, OS.DM_SETDEFID, handle, 0);
- } else {
- bits &= ~OS.BS_DEFPUSHBUTTON;
- OS.SendMessage (hwndShell, OS.DM_SETDEFID, 0, 0);
- }
- OS.SendMessage (handle, OS.BM_SETSTYLE, bits, 1);
-}
-
-public boolean setFocus () {
- checkWidget();
- if ((style & SWT.ARROW) != 0) return false;
- return super.setFocus ();
-}
-
-/**
- * Sets the receiver's image to the argument, which may be
- * null indicating that no image should be displayed.
- *
- * @param image the image to display on the receiver (may be null)
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_INVALID_ARGUMENT - if the image has been disposed</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public void setImage (Image image) {
- checkWidget ();
- int hImage = 0, imageBits = 0, fImageType = 0;
- if (image != null) {
- if (image.isDisposed()) error(SWT.ERROR_INVALID_ARGUMENT);
- 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 ();
-}
-
-boolean setRadioSelection (boolean value) {
- if ((style & SWT.RADIO) == 0) return false;
- if (getSelection () != value) {
- setSelection (value);
- postEvent (SWT.Selection);
- }
- return true;
-}
-
-boolean setSavedFocus () {
- /*
- * 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 disallow focus to be restored to radio button that is
- * not selected.
- */
- if ((style & SWT.RADIO) != 0 && !getSelection ()) return false;
- return super.setSavedFocus ();
-}
-
-/**
- * Sets the selection state of the receiver, if it is of type <code>CHECK</code>,
- * <code>RADIO</code>, or <code>TOGGLE</code>.
- *
- * <p>
- * When the receiver is of type <code>CHECK</code> or <code>RADIO</code>,
- * it is selected when it is checked. When it is of type <code>TOGGLE</code>,
- * it is selected when it is pushed in.
- *
- * @param selected the new selection state
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public void setSelection (boolean selected) {
- checkWidget ();
- if ((style & (SWT.CHECK | SWT.RADIO | SWT.TOGGLE)) == 0) return;
- int flags = selected ? OS.BST_CHECKED : OS.BST_UNCHECKED;
-
- /*
- * Feature in Windows. When BM_SETCHECK is used
- * to set the checked state of a radio or check
- * button, it sets the WM_TABSTOP style. This
- * is undocumented and unwanted. The fix is
- * to save and restore the window style bits.
- */
- int bits = OS.GetWindowLong (handle, OS.GWL_STYLE);
- OS.SendMessage (handle, OS.BM_SETCHECK, flags, 0);
- OS.SetWindowLong (handle, OS.GWL_STYLE, bits);
-}
-
-/**
- * Sets the receiver's text.
- * <p>
- * This method sets the button label. The label may include
- * the mnemonic character but must not contain line delimiters.
- * </p>
- * <p>
- * Mnemonics are indicated by an '&amp' that causes the next
- * character to be the mnemonic. When the user presses a
- * key sequence that matches the mnemonic, a selection
- * event occurs. On most platforms, the mnemonic appears
- * underlined but may be emphasised in a platform specific
- * manner. The mnemonic indicator character '&amp' can be
- * escaped by doubling it in the string, causing a single
- *'&amp' to be displayed.
- * </p>
- *
- * @param string the new text
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the text is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public void setText (String string) {
- checkWidget ();
- if (string == null) error (SWT.ERROR_NULL_ARGUMENT);
- 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);
- }
- TCHAR buffer = new TCHAR (getCodePage (), 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 | OS.WS_TABSTOP;
- if ((style & SWT.CHECK) != 0) return bits | OS.BS_CHECKBOX | OS.WS_TABSTOP;
- 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 | OS.WS_TABSTOP;
-}
-
-TCHAR 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_KILLFOCUS (int wParam, int lParam) {
- LRESULT result = super.WM_KILLFOCUS (wParam, lParam);
- if ((style & SWT.PUSH) != 0 && getDefault ()) {
- menuShell ().setDefaultButton (null, false);
- }
- return result;
-}
-
-LRESULT WM_SETFOCUS (int wParam, int lParam) {
- /*
- * 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 save and restore the window style bits.
- */
- int bits = 0;
- if ((style & SWT.RADIO) != 0) {
- bits = OS.GetWindowLong (handle, OS.GWL_STYLE);
- }
- LRESULT result = super.WM_SETFOCUS (wParam, lParam);
- if ((style & SWT.RADIO) != 0) {
- OS.SetWindowLong (handle, OS.GWL_STYLE, bits);
- }
- if ((style & SWT.PUSH) != 0) {
- menuShell ().setDefaultButton (this, false);
- }
- return result;
-}
-
-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) {
- setSelection (!getSelection ());
- } else {
- selectRadio ();
- }
- }
- }
- 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 (!getEnabled ()) uState |= OS.DFCS_INACTIVE;
- if ((style & SWT.FLAT) == SWT.FLAT) uState |= OS.DFCS_FLAT;
- 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;
-}
-
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+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 notification when pressed and released.
+ * <dl>
+ * <dt><b>Styles:</b></dt>
+ * <dd>ARROW, CHECK, PUSH, RADIO, TOGGLE, FLAT</dd>
+ * <dd>UP, DOWN, LEFT, RIGHT, CENTER</dd>
+ * <dt><b>Events:</b></dt>
+ * <dd>Selection</dd>
+ * </dl>
+ * <p>
+ * Note: Only one of the styles ARROW, CHECK, PUSH, RADIO, and TOGGLE
+ * may be specified.
+ * </p><p>
+ * Note: Only one of the styles LEFT, RIGHT, and CENTER may be specified.
+ * </p><p>
+ * Note: Only one of the styles UP, DOWN, LEFT, and RIGHT may be specified
+ * when the ARROW style is specified.
+ * </p><p>
+ * IMPORTANT: This class is intended to be subclassed <em>only</em>
+ * within the SWT implementation.
+ * </p>
+ */
+
+public class Button extends Control {
+ Image image;
+ static final int ButtonProc;
+ static final TCHAR ButtonClass = new TCHAR (0,"BUTTON", true);
+ static final int CheckWidth, CheckHeight;
+ static {
+ int hBitmap = OS.LoadBitmap (0, OS.OBM_CHECKBOXES);
+ if (hBitmap == 0) {
+ CheckWidth = OS.GetSystemMetrics (OS.IsWinCE ? OS.SM_CXSMICON : OS.SM_CXVSCROLL);
+ CheckHeight = OS.GetSystemMetrics (OS.IsWinCE ? OS.SM_CYSMICON : 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;
+ }
+ WNDCLASS lpWndClass = new WNDCLASS ();
+ OS.GetClassInfo (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
+ * lists the style constants that are applicable to the class.
+ * Style bits are also inherited from superclasses.
+ * </p>
+ *
+ * @param parent a composite control which will be the parent of the new instance (cannot be null)
+ * @param style the style of control to construct
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
+ * <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
+ * </ul>
+ *
+ * @see SWT#ARROW
+ * @see SWT#CHECK
+ * @see SWT#PUSH
+ * @see SWT#RADIO
+ * @see SWT#TOGGLE
+ * @see SWT#FLAT
+ * @see SWT#LEFT
+ * @see SWT#RIGHT
+ * @see SWT#CENTER
+ * @see Widget#checkSubclass
+ * @see Widget#getStyle
+ */
+public Button (Composite parent, int style) {
+ super (parent, checkStyle (style));
+}
+
+/**
+ * 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.
+ * <p>
+ * <code>widgetSelected</code> is called when the control is selected.
+ * <code>widgetDefaultSelected</code> is not called.
+ * </p>
+ *
+ * @param listener the listener which should be notified
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see SelectionListener
+ * @see #removeSelectionListener
+ * @see SelectionEvent
+ */
+public void addSelectionListener (SelectionListener listener) {
+ checkWidget ();
+ if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+ TypedListener typedListener = new TypedListener (listener);
+ addListener (SWT.Selection,typedListener);
+ addListener (SWT.DefaultSelection,typedListener);
+}
+
+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 () {
+ /*
+ * Note: BM_CLICK sends WM_LBUTTONDOWN and WM_LBUTTONUP.
+ */
+ 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);
+ TCHAR buffer = new TCHAR (getCodePage (), 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) {
+ Rectangle rect = image.getBounds ();
+ width = rect.width;
+ height = rect.height;
+ extra = 8;
+ }
+ }
+ if ((style & (SWT.CHECK | SWT.RADIO)) != 0) {
+ width += CheckWidth + extra;
+ height = Math.max (height, CheckHeight + 3);
+ }
+ if ((style & (SWT.PUSH | SWT.TOGGLE)) != 0) {
+ width += 12; height += 10;
+ }
+ if (wHint != SWT.DEFAULT) width = wHint + (border * 2);
+ if (hHint != SWT.DEFAULT) height = hHint + (border * 2);
+ return new Point (width, height);
+}
+
+int defaultBackground () {
+ if ((style & (SWT.PUSH | SWT.TOGGLE)) != 0) {
+ return OS.GetSysColor (OS.COLOR_BTNFACE);
+ }
+ return super.defaultBackground ();
+}
+
+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 in. If the receiver is of any other type,
+ * this method returns false.
+ *
+ * @return the selection state
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public boolean getSelection () {
+ checkWidget ();
+ if ((style & (SWT.CHECK | SWT.RADIO | SWT.TOGGLE)) == 0) return false;
+ 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 "";
+ TCHAR buffer = new TCHAR (getCodePage (), length + 1);
+ OS.GetWindowText (handle, buffer, length + 1);
+ return buffer.toString (0, length);
+}
+
+boolean isTabItem () {
+ //TEMPORARY CODE
+ //if ((style & SWT.PUSH) != 0) return true;
+ return super.isTabItem ();
+}
+
+boolean mnemonicHit (char ch) {
+ 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 () {
+ /*
+ * This code is intentionally commented. When two groups
+ * of radio buttons with the same parent are separated by
+ * another control, the correct behavior should be that
+ * the two groups act independently. This is consistent
+ * with radio tool and menu items. The commented code
+ * implements this behavior.
+ */
+// int index = 0;
+// Control [] children = parent._getChildren ();
+// while (index < children.length && children [index] != this) index++;
+// int i = index - 1;
+// while (i >= 0 && children [i].setRadioSelection (false)) --i;
+// int j = index + 1;
+// while (j < children.length && children [j].setRadioSelection (false)) j++;
+// setSelection (true);
+ Control [] children = parent._getChildren ();
+ for (int i=0; i<children.length; i++) {
+ Control child = children [i];
+ if (this != child) child.setRadioSelection (false);
+ }
+ setSelection (true);
+}
+
+/**
+ * Controls how text, images and arrows will be displayed
+ * in the receiver. The argument should be one of
+ * <code>LEFT</code>, <code>RIGHT</code> or <code>CENTER</code>
+ * unless the receiver is an <code>ARROW</code> button, in
+ * which case, the argument indicates the direction of
+ * the arrow (one of <code>LEFT</code>, <code>RIGHT</code>,
+ * <code>UP</code> or <code>DOWN</code>).
+ *
+ * @param alignment the new alignment
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setAlignment (int alignment) {
+ checkWidget ();
+ 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 hwndShell = menuShell ().handle;
+ int bits = OS.GetWindowLong (handle, OS.GWL_STYLE);
+ if (value) {
+ bits |= OS.BS_DEFPUSHBUTTON;
+ OS.SendMessage (hwndShell, OS.DM_SETDEFID, handle, 0);
+ } else {
+ bits &= ~OS.BS_DEFPUSHBUTTON;
+ OS.SendMessage (hwndShell, OS.DM_SETDEFID, 0, 0);
+ }
+ OS.SendMessage (handle, OS.BM_SETSTYLE, bits, 1);
+}
+
+public boolean setFocus () {
+ checkWidget();
+ if ((style & SWT.ARROW) != 0) return false;
+ return super.setFocus ();
+}
+
+/**
+ * Sets the receiver's image to the argument, which may be
+ * null indicating that no image should be displayed.
+ *
+ * @param image the image to display on the receiver (may be null)
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_INVALID_ARGUMENT - if the image has been disposed</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setImage (Image image) {
+ checkWidget ();
+ int hImage = 0, imageBits = 0, fImageType = 0;
+ if (image != null) {
+ if (image.isDisposed()) error(SWT.ERROR_INVALID_ARGUMENT);
+ 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 ();
+}
+
+boolean setRadioSelection (boolean value) {
+ if ((style & SWT.RADIO) == 0) return false;
+ if (getSelection () != value) {
+ setSelection (value);
+ postEvent (SWT.Selection);
+ }
+ return true;
+}
+
+boolean setSavedFocus () {
+ /*
+ * 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 disallow focus to be restored to radio button that is
+ * not selected.
+ */
+ if ((style & SWT.RADIO) != 0 && !getSelection ()) return false;
+ return super.setSavedFocus ();
+}
+
+/**
+ * Sets the selection state of the receiver, if it is of type <code>CHECK</code>,
+ * <code>RADIO</code>, or <code>TOGGLE</code>.
+ *
+ * <p>
+ * When the receiver is of type <code>CHECK</code> or <code>RADIO</code>,
+ * it is selected when it is checked. When it is of type <code>TOGGLE</code>,
+ * it is selected when it is pushed in.
+ *
+ * @param selected the new selection state
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setSelection (boolean selected) {
+ checkWidget ();
+ if ((style & (SWT.CHECK | SWT.RADIO | SWT.TOGGLE)) == 0) return;
+ int flags = selected ? OS.BST_CHECKED : OS.BST_UNCHECKED;
+
+ /*
+ * Feature in Windows. When BM_SETCHECK is used
+ * to set the checked state of a radio or check
+ * button, it sets the WM_TABSTOP style. This
+ * is undocumented and unwanted. The fix is
+ * to save and restore the window style bits.
+ */
+ int bits = OS.GetWindowLong (handle, OS.GWL_STYLE);
+ OS.SendMessage (handle, OS.BM_SETCHECK, flags, 0);
+ OS.SetWindowLong (handle, OS.GWL_STYLE, bits);
+}
+
+/**
+ * Sets the receiver's text.
+ * <p>
+ * This method sets the button label. The label may include
+ * the mnemonic character but must not contain line delimiters.
+ * </p>
+ * <p>
+ * Mnemonics are indicated by an '&amp' that causes the next
+ * character to be the mnemonic. When the user presses a
+ * key sequence that matches the mnemonic, a selection
+ * event occurs. On most platforms, the mnemonic appears
+ * underlined but may be emphasised in a platform specific
+ * manner. The mnemonic indicator character '&amp' can be
+ * escaped by doubling it in the string, causing a single
+ *'&amp' to be displayed.
+ * </p>
+ *
+ * @param string the new text
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if the text is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setText (String string) {
+ checkWidget ();
+ if (string == null) error (SWT.ERROR_NULL_ARGUMENT);
+ 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);
+ }
+ TCHAR buffer = new TCHAR (getCodePage (), 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 | OS.WS_TABSTOP;
+ if ((style & SWT.CHECK) != 0) return bits | OS.BS_CHECKBOX | OS.WS_TABSTOP;
+ 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 | OS.WS_TABSTOP;
+}
+
+TCHAR 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_KILLFOCUS (int wParam, int lParam) {
+ LRESULT result = super.WM_KILLFOCUS (wParam, lParam);
+ if ((style & SWT.PUSH) != 0 && getDefault ()) {
+ menuShell ().setDefaultButton (null, false);
+ }
+ return result;
+}
+
+LRESULT WM_SETFOCUS (int wParam, int lParam) {
+ /*
+ * 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 save and restore the window style bits.
+ */
+ int bits = 0;
+ if ((style & SWT.RADIO) != 0) {
+ bits = OS.GetWindowLong (handle, OS.GWL_STYLE);
+ }
+ LRESULT result = super.WM_SETFOCUS (wParam, lParam);
+ if ((style & SWT.RADIO) != 0) {
+ OS.SetWindowLong (handle, OS.GWL_STYLE, bits);
+ }
+ if ((style & SWT.PUSH) != 0) {
+ menuShell ().setDefaultButton (this, false);
+ }
+ return result;
+}
+
+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) {
+ setSelection (!getSelection ());
+ } else {
+ selectRadio ();
+ }
+ }
+ }
+ 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 (!getEnabled ()) uState |= OS.DFCS_INACTIVE;
+ if ((style & SWT.FLAT) == SWT.FLAT) uState |= OS.DFCS_FLAT;
+ 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
index 8de1e053c6..cf1a9c1ac3 100755
--- 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
@@ -1,216 +1,216 @@
-package org.eclipse.swt.widgets;
-
-/*
+package org.eclipse.swt.widgets;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-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 aggregates 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
- * lists the style constants that are applicable to the class.
- * Style bits are also inherited from superclasses.
- * </p>
- *
- * @param parent a composite control which will be the parent of the new instance (cannot be null)
- * @param style the style of control to construct
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
- * <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
- * </ul>
- *
- * @see SWT
- * @see Widget#checkSubclass
- * @see Widget#getStyle
- */
-public 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.releaseResources ();
- 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 */
- if (OS.IsWinCE) {
- OS.UpdateWindow (handle);
- } else {
- int flags = OS.RDW_UPDATENOW | OS.RDW_ALLCHILDREN;
- OS.RedrawWindow (handle, null, 0, flags);
- }
- 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, may be null
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_INVALID_ARGUMENT - if the caret has been disposed</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public void setCaret (Caret caret) {
- checkWidget ();
- Caret newCaret = caret;
- Caret oldCaret = this.caret;
- this.caret = newCaret;
- if (isFocusControl ()) {
- if (oldCaret != null) oldCaret.killFocus ();
- if (newCaret != null) {
- if (newCaret.isDisposed()) error(SWT.ERROR_INVALID_ARGUMENT);
- 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 (caret != null) caret.killFocus ();
- return result;
-}
-
-LRESULT WM_SETFOCUS (int wParam, int lParam) {
- LRESULT result = super.WM_SETFOCUS (wParam, lParam);
- if (caret != null) caret.setFocus ();
- return result;
-}
-
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+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 aggregates 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
+ * lists the style constants that are applicable to the class.
+ * Style bits are also inherited from superclasses.
+ * </p>
+ *
+ * @param parent a composite control which will be the parent of the new instance (cannot be null)
+ * @param style the style of control to construct
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
+ * <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
+ * </ul>
+ *
+ * @see SWT
+ * @see Widget#checkSubclass
+ * @see Widget#getStyle
+ */
+public 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.releaseResources ();
+ 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 */
+ if (OS.IsWinCE) {
+ OS.UpdateWindow (handle);
+ } else {
+ int flags = OS.RDW_UPDATENOW | OS.RDW_ALLCHILDREN;
+ OS.RedrawWindow (handle, null, 0, flags);
+ }
+ 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, may be null
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_INVALID_ARGUMENT - if the caret has been disposed</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setCaret (Caret caret) {
+ checkWidget ();
+ Caret newCaret = caret;
+ Caret oldCaret = this.caret;
+ this.caret = newCaret;
+ if (isFocusControl ()) {
+ if (oldCaret != null) oldCaret.killFocus ();
+ if (newCaret != null) {
+ if (newCaret.isDisposed()) error(SWT.ERROR_INVALID_ARGUMENT);
+ 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 (caret != null) caret.killFocus ();
+ return result;
+}
+
+LRESULT WM_SETFOCUS (int wParam, int lParam) {
+ LRESULT result = super.WM_SETFOCUS (wParam, lParam);
+ 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
index a10aee3686..3f979d3b10 100755
--- 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
@@ -1,555 +1,555 @@
-package org.eclipse.swt.widgets;
-
-/*
+package org.eclipse.swt.widgets;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-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;
- Image image;
- 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
- * lists the style constants that are applicable to the class.
- * Style bits are also inherited from superclasses.
- * </p>
- *
- * @param parent a composite control which will be the parent of the new instance (cannot be null)
- * @param style the style of control to construct
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
- * <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
- * </ul>
- *
- * @see SWT
- * @see Widget#checkSubclass
- * @see Widget#getStyle
- */
-public Caret (Canvas parent, int style) {
- super (parent, style);
- this.parent = parent;
- createWidget ();
-}
-
-void createWidget () {
- isVisible = true;
- if (parent.getCaret () == null) {
- parent.setCaret (this);
- }
-}
-
-int defaultFont () {
- int hwnd = parent.handle;
- int hwndIME = OS.ImmGetDefaultIMEWnd (hwnd);
- if (hwndIME == 0) return parent.defaultFont ();
- int hFont = OS.SendMessage (hwndIME, OS.WM_GETFONT, 0, 0);
- if (hFont == 0) return parent.defaultFont ();
- 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();
- if (image != null) {
- Rectangle rect = image.getBounds ();
- return new Rectangle (x, y, rect.width, rect.height);
- }
- 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) {
- int hFont = defaultFont ();
- return Font.win32_new (getDisplay (), hFont);
- }
- return font;
-}
-
-/**
- * Returns the image that the receiver will use to paint the caret.
- *
- * @return the receiver's image
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public Image getImage () {
- checkWidget();
- return image;
-}
-
-/**
- * Returns a point describing the receiver's location relative
- * to its parent (or its display if its parent is null).
- *
- * @return the receiver's location
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public Point getLocation () {
- checkWidget();
- return new Point (x, y);
-}
-
-/**
- * Returns the receiver's parent, which must be a <code>Canvas</code>.
- *
- * @return the receiver's parent
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public Canvas getParent () {
- checkWidget();
- return parent;
-}
-
-/**
- * Returns a point describing the receiver's size.
- *
- * @return the receiver's size
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public Point getSize () {
- checkWidget();
- if (image != null) {
- Rectangle rect = image.getBounds ();
- return new Point (rect.width, rect.height);
- }
- 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 hasFocus () {
- return parent.handle == OS.GetFocus ();
-}
-
-boolean isFocusCaret () {
- return parent.caret == this && hasFocus ();
-}
-
-/**
- * Returns <code>true</code> if the receiver is visible and all
- * of the receiver's ancestors are visible and <code>false</code>
- * otherwise.
- *
- * @return the receiver's visibility state
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see #getVisible
- */
-public boolean isVisible () {
- checkWidget();
- return isVisible && parent.isVisible () && hasFocus ();
-}
-
-void killFocus () {
- OS.DestroyCaret ();
- if (font != null) restoreIMEFont ();
-}
-
-void move () {
- moved = false;
- if (!OS.SetCaretPos (x, y)) return;
- if (OS.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;
- image = null;
- font = null;
- oldFont = null;
-}
-
-void resize () {
- resized = false;
- int hwnd = parent.handle;
- OS.DestroyCaret ();
- int hBitmap = 0;
- if (image != null) hBitmap = image.handle;
- OS.CreateCaret (hwnd, hBitmap, width, height);
- OS.SetCaretPos (x, y);
- OS.ShowCaret (hwnd);
- move ();
-}
-
-void restoreIMEFont () {
- if (!OS.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 (!OS.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 && hasFocus ()) move ();
- } else {
- resized = true;
- if (isVisible && 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;
- int hBitmap = 0;
- if (image != null) hBitmap = image.handle;
- OS.CreateCaret (hwnd, hBitmap, 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 IllegalArgumentException <ul>
- * <li>ERROR_INVALID_ARGUMENT - if the font has been disposed</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public void setFont (Font font) {
- checkWidget();
- if (font != null && font.isDisposed ()) {
- error (SWT.ERROR_INVALID_ARGUMENT);
- }
- this.font = font;
- if (isVisible && hasFocus ()) {
- int hFont = 0;
- if (font != null) hFont = font.handle;
- if (hFont == 0) hFont = defaultFont ();
- saveIMEFont ();
- setIMEFont (hFont);
- }
-}
-
-/**
- * Sets the image that the receiver will use to paint the caret
- * to the image specified by the argument, or to the default
- * which is a filled rectangle if the argument is null
- *
- * @param font the new font (or null)
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_INVALID_ARGUMENT - if the image has been disposed</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public void setImage (Image image) {
- checkWidget();
- if (image != null && image.isDisposed ()) {
- error (SWT.ERROR_INVALID_ARGUMENT);
- }
- this.image = image;
- if (isVisible && hasFocus ()) resize ();
-}
-
-void setIMEFont (int hFont) {
- if (!OS.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 && 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 && 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);
- }
-}
-
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+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;
+ Image image;
+ 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
+ * lists the style constants that are applicable to the class.
+ * Style bits are also inherited from superclasses.
+ * </p>
+ *
+ * @param parent a composite control which will be the parent of the new instance (cannot be null)
+ * @param style the style of control to construct
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
+ * <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
+ * </ul>
+ *
+ * @see SWT
+ * @see Widget#checkSubclass
+ * @see Widget#getStyle
+ */
+public Caret (Canvas parent, int style) {
+ super (parent, style);
+ this.parent = parent;
+ createWidget ();
+}
+
+void createWidget () {
+ isVisible = true;
+ if (parent.getCaret () == null) {
+ parent.setCaret (this);
+ }
+}
+
+int defaultFont () {
+ int hwnd = parent.handle;
+ int hwndIME = OS.ImmGetDefaultIMEWnd (hwnd);
+ if (hwndIME == 0) return parent.defaultFont ();
+ int hFont = OS.SendMessage (hwndIME, OS.WM_GETFONT, 0, 0);
+ if (hFont == 0) return parent.defaultFont ();
+ 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();
+ if (image != null) {
+ Rectangle rect = image.getBounds ();
+ return new Rectangle (x, y, rect.width, rect.height);
+ }
+ 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) {
+ int hFont = defaultFont ();
+ return Font.win32_new (getDisplay (), hFont);
+ }
+ return font;
+}
+
+/**
+ * Returns the image that the receiver will use to paint the caret.
+ *
+ * @return the receiver's image
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public Image getImage () {
+ checkWidget();
+ return image;
+}
+
+/**
+ * Returns a point describing the receiver's location relative
+ * to its parent (or its display if its parent is null).
+ *
+ * @return the receiver's location
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public Point getLocation () {
+ checkWidget();
+ return new Point (x, y);
+}
+
+/**
+ * Returns the receiver's parent, which must be a <code>Canvas</code>.
+ *
+ * @return the receiver's parent
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public Canvas getParent () {
+ checkWidget();
+ return parent;
+}
+
+/**
+ * Returns a point describing the receiver's size.
+ *
+ * @return the receiver's size
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public Point getSize () {
+ checkWidget();
+ if (image != null) {
+ Rectangle rect = image.getBounds ();
+ return new Point (rect.width, rect.height);
+ }
+ 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 hasFocus () {
+ return parent.handle == OS.GetFocus ();
+}
+
+boolean isFocusCaret () {
+ return parent.caret == this && hasFocus ();
+}
+
+/**
+ * Returns <code>true</code> if the receiver is visible and all
+ * of the receiver's ancestors are visible and <code>false</code>
+ * otherwise.
+ *
+ * @return the receiver's visibility state
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see #getVisible
+ */
+public boolean isVisible () {
+ checkWidget();
+ return isVisible && parent.isVisible () && hasFocus ();
+}
+
+void killFocus () {
+ OS.DestroyCaret ();
+ if (font != null) restoreIMEFont ();
+}
+
+void move () {
+ moved = false;
+ if (!OS.SetCaretPos (x, y)) return;
+ if (OS.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;
+ image = null;
+ font = null;
+ oldFont = null;
+}
+
+void resize () {
+ resized = false;
+ int hwnd = parent.handle;
+ OS.DestroyCaret ();
+ int hBitmap = 0;
+ if (image != null) hBitmap = image.handle;
+ OS.CreateCaret (hwnd, hBitmap, width, height);
+ OS.SetCaretPos (x, y);
+ OS.ShowCaret (hwnd);
+ move ();
+}
+
+void restoreIMEFont () {
+ if (!OS.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 (!OS.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 && hasFocus ()) move ();
+ } else {
+ resized = true;
+ if (isVisible && 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;
+ int hBitmap = 0;
+ if (image != null) hBitmap = image.handle;
+ OS.CreateCaret (hwnd, hBitmap, 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 IllegalArgumentException <ul>
+ * <li>ERROR_INVALID_ARGUMENT - if the font has been disposed</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setFont (Font font) {
+ checkWidget();
+ if (font != null && font.isDisposed ()) {
+ error (SWT.ERROR_INVALID_ARGUMENT);
+ }
+ this.font = font;
+ if (isVisible && hasFocus ()) {
+ int hFont = 0;
+ if (font != null) hFont = font.handle;
+ if (hFont == 0) hFont = defaultFont ();
+ saveIMEFont ();
+ setIMEFont (hFont);
+ }
+}
+
+/**
+ * Sets the image that the receiver will use to paint the caret
+ * to the image specified by the argument, or to the default
+ * which is a filled rectangle if the argument is null
+ *
+ * @param font the new font (or null)
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_INVALID_ARGUMENT - if the image has been disposed</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setImage (Image image) {
+ checkWidget();
+ if (image != null && image.isDisposed ()) {
+ error (SWT.ERROR_INVALID_ARGUMENT);
+ }
+ this.image = image;
+ if (isVisible && hasFocus ()) resize ();
+}
+
+void setIMEFont (int hFont) {
+ if (!OS.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 && 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 && 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
index 6a5a3ea76e..8366153109 100755
--- 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
@@ -1,198 +1,198 @@
-package org.eclipse.swt.widgets;
-
-/*
+package org.eclipse.swt.widgets;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-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
- * lists the style constants that are applicable to the class.
- * Style bits are also inherited from superclasses.
- * </p>
- *
- * @param parent a composite control which will be the parent of the new instance (cannot be null)
- * @param style the style of control to construct
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
- * <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
- * </ul>
- *
- * @see SWT
- * @see Widget#checkSubclass
- * @see Widget#getStyle
- */
-public ColorDialog (Shell parent, int style) {
- super (parent, style);
- checkSubclass ();
-}
-
-int CCHookProc (int hdlg, int uiMsg, int lParam, int lpData) {
- switch (uiMsg) {
- case OS.WM_INITDIALOG:
- if (title != null && title.length () != 0) {
- /* Use the character encoding for the default locale */
- TCHAR buffer = new TCHAR (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, may be null
- *
- * @see PaletteData#getRGBs
- */
-public RGB getRGB () {
- return rgb;
-}
-
-/**
- * Makes the receiver visible and brings it to the front
- * of the display.
- *
- * @return the selected color, or null if the dialog was
- * cancelled, no color was selected, or an error
- * occurred
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public RGB open () {
-
- /* Get the owner HWND for the dialog */
- int hwndOwner = parent.handle;
-
- /* Create the CCHookProc */
- Callback callback = new Callback (this, "CCHookProc", 4);
- int lpfnHook = callback.getAddress ();
-
- /* Allocate the Custom Colors */
- Display display = parent.getDisplay ();
- if (display.lpCustColors == 0) {
- int hHeap = OS.GetProcessHeap ();
- display.lpCustColors = OS.HeapAlloc (hHeap, OS.HEAP_ZERO_MEMORY, 16 * 4);
- }
-
- /* Open the dialog */
- CHOOSECOLOR lpcc = new CHOOSECOLOR ();
- lpcc.lStructSize = CHOOSECOLOR.sizeof;
- lpcc.Flags = OS.CC_ANYCOLOR | OS.CC_ENABLEHOOK;
- lpcc.lpfnHook = lpfnHook;
- lpcc.hwndOwner = hwndOwner;
- lpcc.lpCustColors = display.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;
- }
- boolean success = OS.ChooseColor (lpcc);
- if (success) {
- 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 Custom Colors */
- /*
- * This code is intentionally commented. Currently,
- * there is exactly one set of custom colors per display.
- * The memory associated with these colors is released
- * when the display is disposed.
- */
-// 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);
-
- if (!success) return null;
- return rgb;
-}
-
-/**
- * Sets the receiver's selected color to be the argument.
- *
- * @param rgb the new RGB value for the selected color, may be
- * null to let the platform to select a default when
- * open() is called
- * @see PaletteData#getRGBs
- */
-public void setRGB (RGB rgb) {
- this.rgb = rgb;
-}
-
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+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
+ * lists the style constants that are applicable to the class.
+ * Style bits are also inherited from superclasses.
+ * </p>
+ *
+ * @param parent a composite control which will be the parent of the new instance (cannot be null)
+ * @param style the style of control to construct
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
+ * <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
+ * </ul>
+ *
+ * @see SWT
+ * @see Widget#checkSubclass
+ * @see Widget#getStyle
+ */
+public ColorDialog (Shell parent, int style) {
+ super (parent, style);
+ checkSubclass ();
+}
+
+int CCHookProc (int hdlg, int uiMsg, int lParam, int lpData) {
+ switch (uiMsg) {
+ case OS.WM_INITDIALOG:
+ if (title != null && title.length () != 0) {
+ /* Use the character encoding for the default locale */
+ TCHAR buffer = new TCHAR (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, may be null
+ *
+ * @see PaletteData#getRGBs
+ */
+public RGB getRGB () {
+ return rgb;
+}
+
+/**
+ * Makes the receiver visible and brings it to the front
+ * of the display.
+ *
+ * @return the selected color, or null if the dialog was
+ * cancelled, no color was selected, or an error
+ * occurred
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public RGB open () {
+
+ /* Get the owner HWND for the dialog */
+ int hwndOwner = parent.handle;
+
+ /* Create the CCHookProc */
+ Callback callback = new Callback (this, "CCHookProc", 4);
+ int lpfnHook = callback.getAddress ();
+
+ /* Allocate the Custom Colors */
+ Display display = parent.getDisplay ();
+ if (display.lpCustColors == 0) {
+ int hHeap = OS.GetProcessHeap ();
+ display.lpCustColors = OS.HeapAlloc (hHeap, OS.HEAP_ZERO_MEMORY, 16 * 4);
+ }
+
+ /* Open the dialog */
+ CHOOSECOLOR lpcc = new CHOOSECOLOR ();
+ lpcc.lStructSize = CHOOSECOLOR.sizeof;
+ lpcc.Flags = OS.CC_ANYCOLOR | OS.CC_ENABLEHOOK;
+ lpcc.lpfnHook = lpfnHook;
+ lpcc.hwndOwner = hwndOwner;
+ lpcc.lpCustColors = display.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;
+ }
+ boolean success = OS.ChooseColor (lpcc);
+ if (success) {
+ 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 Custom Colors */
+ /*
+ * This code is intentionally commented. Currently,
+ * there is exactly one set of custom colors per display.
+ * The memory associated with these colors is released
+ * when the display is disposed.
+ */
+// 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);
+
+ if (!success) return null;
+ return rgb;
+}
+
+/**
+ * Sets the receiver's selected color to be the argument.
+ *
+ * @param rgb the new RGB value for the selected color, may be
+ * null to let the platform to select a default when
+ * open() is called
+ * @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
index 5e1cfa4b2b..1d9ce8dcae 100755
--- 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
@@ -1,1461 +1,1461 @@
-package org.eclipse.swt.widgets;
-
-/*
+package org.eclipse.swt.widgets;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-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><p>
- * Note that although this class is a subclass of <code>Composite</code>,
- * it does not make sense to add children to it, or set a layout on it.
- * </p>
- * <dl>
- * <dt><b>Styles:</b></dt>
- * <dd>DROP_DOWN, READ_ONLY, SIMPLE</dd>
- * <dt><b>Events:</b></dt>
- * <dd>DefaultSelection, Modify, Selection</dd>
- * </dl>
- * <p>
- * Note: Only one of the styles DROP_DOWN and SIMPLE
- * may be specified.
- * </p><p>
- * IMPORTANT: This class is <em>not</em> intended to be subclassed.
- * </p>
- *
- * @see List
- */
-
-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 = OS.IsWinNT ? 0x7FFFFFFF : 0x7FFF;
- }
-
- static final int ComboProc;
- static final TCHAR ComboClass = new TCHAR (0,"COMBOBOX", true);
- /*
- * 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 {
- WNDCLASS lpWndClass = new WNDCLASS ();
- OS.GetClassInfo (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
- * lists the style constants that are applicable to the class.
- * Style bits are also inherited from superclasses.
- * </p>
- *
- * @param parent a composite control which will be the parent of the new instance (cannot be null)
- * @param style the style of control to construct
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
- * <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
- * </ul>
- *
- * @see SWT#DROP_DOWN
- * @see SWT#READ_ONLY
- * @see SWT#SIMPLE
- * @see Widget#checkSubclass
- * @see Widget#getStyle
- */
-public Combo (Composite parent, int style) {
- super (parent, checkStyle (style));
-}
-
-/**
- * Adds the argument to the end of the receiver's list.
- *
- * @param string the new item
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the string is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- * @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);
- TCHAR buffer = new TCHAR (getCodePage (), 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);
- TCHAR buffer = new TCHAR (getCodePage (), 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.
- * <p>
- * <code>widgetSelected</code> is called when the combo's list selection changes.
- * <code>widgetDefaultSelected</code> is typically called when ENTER is pressed the combo's text area.
- * </p>
- *
- * @param listener the listener which should be notified
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see SelectionListener
- * @see #removeSelectionListener
- * @see SelectionEvent
- */
-public void addSelectionListener(SelectionListener listener) {
- checkWidget ();
- if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
- TypedListener typedListener = new TypedListener (listener);
- addListener (SWT.Selection,typedListener);
- addListener (SWT.DefaultSelection,typedListener);
-}
-
-int 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);
- int cp = getCodePage ();
- TCHAR buffer = new TCHAR (cp, length + 1);
- OS.GetWindowText (handle, buffer, length + 1);
- 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 TCHAR (cp, 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);
- }
- }
- }
- TEXTMETRIC tm = new TEXTMETRIC ();
- OS.GetTextMetrics (hDC, tm);
- 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 = OS.GetSystemMetrics (OS.SM_CXEDGE);
- width += OS.GetSystemMetrics (OS.SM_CXVSCROLL) + (tm.tmInternalLeading + border) * 2;
- int textHeight = OS.SendMessage (handle, OS.CB_GETITEMHEIGHT, -1, 0);
- if ((style & SWT.DROP_DOWN) != 0) {
- height = textHeight + 6;
- } else {
- height += textHeight + 10;
- }
- return new Point (width, height);
-}
-
-/**
- * Copies the selected text.
- * <p>
- * The current selection is copied to the clipboard.
- * </p>
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @since 2.1
- */
-public void copy () {
- checkWidget ();
- OS.SendMessage (handle, OS.WM_COPY, 0, 0);
-}
-
-void createHandle () {
- super.createHandle ();
- state &= ~CANVAS;
-}
-
-/**
- * Cuts the selected text.
- * <p>
- * The current selection is first copied to the
- * clipboard and then deleted from the widget.
- * </p>
- *
- * @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>
- *
- * @since 2.1
- */
-public void cut () {
- checkWidget ();
- OS.SendMessage (handle, OS.WM_CUT, 0, 0);
-}
-
-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) {
- TCHAR buffer = new TCHAR (getCodePage (), length + 1);
- int result = OS.SendMessage (handle, OS.CB_GETLBTEXT, index, buffer);
- if (result != OS.CB_ERR) return buffer.toString (0, length);
- }
- 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 affect the receiver.
- * </p>
- *
- * @return the items in the receiver's list
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- * @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 "";
- TCHAR buffer = new TCHAR (getCodePage (), length + 1);
- OS.GetWindowText (handle, buffer, length + 1);
- return buffer.toString (0, length);
-}
-
-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);
-}
-
-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) {
- 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, CB_FINDSTRINGEXACT
- * will not find empty strings even though it is legal
- * to insert an empty string into a combo. The fix is
- * to search the combo, 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 CB_FINDSTRINGEXACT to search for the item */
- int count = OS.SendMessage (handle, OS.CB_GETCOUNT, 0, 0);
- if (!(0 <= start && start < count)) return -1;
- int index = start - 1, last = 0;
- TCHAR buffer = new TCHAR (getCodePage (), 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;
-}
-
-/**
- * Pastes text from clipboard.
- * <p>
- * The selected text is deleted from the widget
- * and new text inserted from the clipboard.
- * </p>
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @since 2.1
- */
-public void paste () {
- checkWidget ();
- OS.SendMessage (handle, OS.WM_PASTE, 0, 0);
-}
-
-/**
- * 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) {
- 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 selection = OS.SendMessage (handle, OS.CB_GETCURSEL, 0, 0);
- int code = OS.SendMessage (handle, OS.CB_SETCURSEL, index, 0);
- if (code != OS.CB_ERR && code != selection) {
- sendEvent (SWT.Modify);
- // widget could be disposed at this point
- }
- }
-}
-
-void setBackgroundPixel (int pixel) {
- if (background == pixel) return;
- super.setBackgroundPixel (pixel);
- int hwndText = OS.GetDlgItem (handle, CBID_EDIT);
- if (hwndText != 0) OS.InvalidateRect (hwndText, null, true);
- int hwndList = OS.GetDlgItem (handle, CBID_LIST);
- if (hwndList != 0) OS.InvalidateRect (hwndList, null, true);
-}
-
-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);
- height = textHeight + 6 + (itemHeight * 5) + 2;
- /*
- * Feature in Windows. When a drop down combo box is resized,
- * the combo box resizes the height of the text field and uses
- * the height provided in SetWindowPos () to determine the height
- * of the drop down list. For some reason, the combo box redraws
- * the whole area, not just the text field. The fix is to set the
- * SWP_NOSIZE bits when the height of text field and the drop down
- * list is the same as the requested height.
- *
- * NOTE: Setting the width of a combo box to zero does not update
- * the width of the drop down control rect. If the width of the
- * combo box is zero, then do not set SWP_NOSIZE.
- */
- RECT rect = new RECT ();
- OS.GetWindowRect (handle, rect);
- if (rect.right - rect.left != 0) {
- if (OS.SendMessage (handle, OS.CB_GETDROPPEDCONTROLRECT, 0, rect) != 0) {
- int oldWidth = rect.right - rect.left, oldHeight = rect.bottom - rect.top;
- if (oldWidth == width && oldHeight == height) flags |= OS.SWP_NOSIZE;
- }
- }
- OS.SetWindowPos (handle, 0, x, y, width, height, 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.lpwp != null || (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);
- int oldWidth = rect.right - rect.left, oldHeight = rect.bottom - rect.top;
- if (oldWidth != width || oldHeight != height) {
- if (OS.IsWinCE) {
- int hwndText = OS.GetDlgItem (handle, CBID_EDIT);
- if (hwndText != 0) OS.InvalidateRect (hwndText, null, true);
- int hwndList = OS.GetDlgItem (handle, CBID_LIST);
- if (hwndList != 0) OS.InvalidateRect (hwndList, null, true);
- } else {
- int uFlags = OS.RDW_ERASE | OS.RDW_INVALIDATE | OS.RDW_ALLCHILDREN;
- OS.RedrawWindow (handle, null, 0, uFlags);
- }
- }
-}
-
-void setEditable (boolean editable) {
- error (SWT.ERROR_NOT_IMPLEMENTED);
-}
-
-void setForegroundPixel (int pixel) {
- if (foreground == pixel) return;
- super.setForegroundPixel (pixel);
- int hwndText = OS.GetDlgItem (handle, CBID_EDIT);
- if (hwndText != 0) OS.InvalidateRect (hwndText, null, true);
- int hwndList = OS.GetDlgItem (handle, CBID_LIST);
- if (hwndList != 0) OS.InvalidateRect (hwndList, null, true);
-}
-
-/**
- * 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);
- int codePage = getCodePage ();
- for (int i=0; i<items.length; i++) {
- String string = items [i];
- TCHAR buffer = new TCHAR (codePage, 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);
- }
- // widget could be disposed at this point
- sendEvent (SWT.Modify);
-}
-
-/**
- * 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);
-}
-
-/**
- * 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);
- if ((style & SWT.READ_ONLY) != 0) {
- int index = indexOf (string);
- if (index != -1) select (index);
- return;
- }
- TCHAR buffer = new TCHAR (getCodePage (), string, true);
- 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) {
- if (super.translateAccelerator (msg)) return true;
-
- /*
- * 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. Note that we must call TranslateMessage
- * in order to process accented keys properly.
- */
- int hwndText = OS.GetDlgItem (handle, CBID_EDIT);
- if (hwndText != 0 && msg.hwnd == hwndText) {
- switch (msg.message) {
- case OS.WM_CHAR:
- case OS.WM_SYSCHAR:
- case OS.WM_KEYDOWN: {
- Display display = getDisplay ();
- if (msg.message == OS.WM_KEYDOWN) {
- if (display.translateTraversal (msg, this)) return true;
- } else {
- if (display.translateMnemonic (msg, this)) return true;
- }
- }
- }
- OS.TranslateMessage (msg);
- switch (msg.message) {
- case OS.WM_CHAR: WM_CHAR (msg.wParam, msg.lParam); break;
- case OS.WM_IME_CHAR: WM_IME_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;
- }
- OS.DispatchMessage (msg);
- return true;
- }
- return false;
-}
-
-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.
- */
- int hwndText = OS.GetDlgItem (handle, CBID_EDIT);
- if (hwndText != 0 && msg.hwnd == hwndText) {
- 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) {
- if (sendKeyEvent (SWT.KeyDown, msg.message, msg.wParam, msg.lParam)) {
- if (msg.wParam == OS.VK_RETURN) {
- sendEvent (SWT.DefaultSelection);
- // widget could be disposed at this point
- }
- }
- }
- return true;
- }
- }
- return super.translateTraversal (msg);
-}
-
-boolean traverseEscape () {
- if (OS.SendMessage (handle, OS.CB_GETDROPPEDSTATE, 0, 0) != 0) {
- OS.SendMessage (handle, OS.CB_SHOWDROPDOWN, 0, 0);
- return true;
- }
- return super.traverseEscape ();
-}
-
-int widgetExtStyle () {
- return super.widgetExtStyle () & ~OS.WS_EX_NOINHERITLAYOUT;
-}
-
-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;
-}
-
-TCHAR 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 WM_SIZE (int wParam, int lParam) {
- /*
- * Feature in Windows. When an editable drop down combo box
- * contains text that does not correspond to an item in the
- * list, when the widget is resized, it selects the closest
- * match from the list. The fix is to remember the original
- * text and reset it after the widget is resized.
- */
- if ((style & SWT.READ_ONLY) != 0 || (style & SWT.DROP_DOWN) == 0) {
- return super.WM_SIZE (wParam, lParam);
- }
- int index = OS.SendMessage (handle, OS.CB_GETCURSEL, 0, 0);
- boolean redraw = false;
- TCHAR buffer = null;
- int [] start = null, end = null;
- if (index == OS.CB_ERR) {
- int length = OS.GetWindowTextLength (handle);
- if (length != 0) {
- buffer = new TCHAR (getCodePage (), length + 1);
- OS.GetWindowText (handle, buffer, length + 1);
- start = new int [1]; end = new int [1];
- OS.SendMessage (handle, OS.CB_GETEDITSEL, start, end);
- redraw = drawCount == 0 && OS.IsWindowVisible (handle);
- if (redraw) setRedraw (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;
- if (buffer != null) {
- OS.SetWindowText (handle, buffer);
- int bits = start [0] | (end [0] << 16);
- OS.SendMessage (handle, OS.CB_SETEDITSEL, 0, bits);
- if (redraw) setRedraw (true);
- }
- return result;
-}
-
-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 an 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);
-}
-
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+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><p>
+ * Note that although this class is a subclass of <code>Composite</code>,
+ * it does not make sense to add children to it, or set a layout on it.
+ * </p>
+ * <dl>
+ * <dt><b>Styles:</b></dt>
+ * <dd>DROP_DOWN, READ_ONLY, SIMPLE</dd>
+ * <dt><b>Events:</b></dt>
+ * <dd>DefaultSelection, Modify, Selection</dd>
+ * </dl>
+ * <p>
+ * Note: Only one of the styles DROP_DOWN and SIMPLE
+ * may be specified.
+ * </p><p>
+ * IMPORTANT: This class is <em>not</em> intended to be subclassed.
+ * </p>
+ *
+ * @see List
+ */
+
+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 = OS.IsWinNT ? 0x7FFFFFFF : 0x7FFF;
+ }
+
+ static final int ComboProc;
+ static final TCHAR ComboClass = new TCHAR (0,"COMBOBOX", true);
+ /*
+ * 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 {
+ WNDCLASS lpWndClass = new WNDCLASS ();
+ OS.GetClassInfo (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
+ * lists the style constants that are applicable to the class.
+ * Style bits are also inherited from superclasses.
+ * </p>
+ *
+ * @param parent a composite control which will be the parent of the new instance (cannot be null)
+ * @param style the style of control to construct
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
+ * <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
+ * </ul>
+ *
+ * @see SWT#DROP_DOWN
+ * @see SWT#READ_ONLY
+ * @see SWT#SIMPLE
+ * @see Widget#checkSubclass
+ * @see Widget#getStyle
+ */
+public Combo (Composite parent, int style) {
+ super (parent, checkStyle (style));
+}
+
+/**
+ * Adds the argument to the end of the receiver's list.
+ *
+ * @param string the new item
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if the string is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * @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);
+ TCHAR buffer = new TCHAR (getCodePage (), 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);
+ TCHAR buffer = new TCHAR (getCodePage (), 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.
+ * <p>
+ * <code>widgetSelected</code> is called when the combo's list selection changes.
+ * <code>widgetDefaultSelected</code> is typically called when ENTER is pressed the combo's text area.
+ * </p>
+ *
+ * @param listener the listener which should be notified
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see SelectionListener
+ * @see #removeSelectionListener
+ * @see SelectionEvent
+ */
+public void addSelectionListener(SelectionListener listener) {
+ checkWidget ();
+ if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+ TypedListener typedListener = new TypedListener (listener);
+ addListener (SWT.Selection,typedListener);
+ addListener (SWT.DefaultSelection,typedListener);
+}
+
+int 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);
+ int cp = getCodePage ();
+ TCHAR buffer = new TCHAR (cp, length + 1);
+ OS.GetWindowText (handle, buffer, length + 1);
+ 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 TCHAR (cp, 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);
+ }
+ }
+ }
+ TEXTMETRIC tm = new TEXTMETRIC ();
+ OS.GetTextMetrics (hDC, tm);
+ 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 = OS.GetSystemMetrics (OS.SM_CXEDGE);
+ width += OS.GetSystemMetrics (OS.SM_CXVSCROLL) + (tm.tmInternalLeading + border) * 2;
+ int textHeight = OS.SendMessage (handle, OS.CB_GETITEMHEIGHT, -1, 0);
+ if ((style & SWT.DROP_DOWN) != 0) {
+ height = textHeight + 6;
+ } else {
+ height += textHeight + 10;
+ }
+ return new Point (width, height);
+}
+
+/**
+ * Copies the selected text.
+ * <p>
+ * The current selection is copied to the clipboard.
+ * </p>
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @since 2.1
+ */
+public void copy () {
+ checkWidget ();
+ OS.SendMessage (handle, OS.WM_COPY, 0, 0);
+}
+
+void createHandle () {
+ super.createHandle ();
+ state &= ~CANVAS;
+}
+
+/**
+ * Cuts the selected text.
+ * <p>
+ * The current selection is first copied to the
+ * clipboard and then deleted from the widget.
+ * </p>
+ *
+ * @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>
+ *
+ * @since 2.1
+ */
+public void cut () {
+ checkWidget ();
+ OS.SendMessage (handle, OS.WM_CUT, 0, 0);
+}
+
+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) {
+ TCHAR buffer = new TCHAR (getCodePage (), length + 1);
+ int result = OS.SendMessage (handle, OS.CB_GETLBTEXT, index, buffer);
+ if (result != OS.CB_ERR) return buffer.toString (0, length);
+ }
+ 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 affect the receiver.
+ * </p>
+ *
+ * @return the items in the receiver's list
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * @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 "";
+ TCHAR buffer = new TCHAR (getCodePage (), length + 1);
+ OS.GetWindowText (handle, buffer, length + 1);
+ return buffer.toString (0, length);
+}
+
+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);
+}
+
+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) {
+ 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, CB_FINDSTRINGEXACT
+ * will not find empty strings even though it is legal
+ * to insert an empty string into a combo. The fix is
+ * to search the combo, 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 CB_FINDSTRINGEXACT to search for the item */
+ int count = OS.SendMessage (handle, OS.CB_GETCOUNT, 0, 0);
+ if (!(0 <= start && start < count)) return -1;
+ int index = start - 1, last = 0;
+ TCHAR buffer = new TCHAR (getCodePage (), 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;
+}
+
+/**
+ * Pastes text from clipboard.
+ * <p>
+ * The selected text is deleted from the widget
+ * and new text inserted from the clipboard.
+ * </p>
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @since 2.1
+ */
+public void paste () {
+ checkWidget ();
+ OS.SendMessage (handle, OS.WM_PASTE, 0, 0);
+}
+
+/**
+ * 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) {
+ 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 selection = OS.SendMessage (handle, OS.CB_GETCURSEL, 0, 0);
+ int code = OS.SendMessage (handle, OS.CB_SETCURSEL, index, 0);
+ if (code != OS.CB_ERR && code != selection) {
+ sendEvent (SWT.Modify);
+ // widget could be disposed at this point
+ }
+ }
+}
+
+void setBackgroundPixel (int pixel) {
+ if (background == pixel) return;
+ super.setBackgroundPixel (pixel);
+ int hwndText = OS.GetDlgItem (handle, CBID_EDIT);
+ if (hwndText != 0) OS.InvalidateRect (hwndText, null, true);
+ int hwndList = OS.GetDlgItem (handle, CBID_LIST);
+ if (hwndList != 0) OS.InvalidateRect (hwndList, null, true);
+}
+
+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);
+ height = textHeight + 6 + (itemHeight * 5) + 2;
+ /*
+ * Feature in Windows. When a drop down combo box is resized,
+ * the combo box resizes the height of the text field and uses
+ * the height provided in SetWindowPos () to determine the height
+ * of the drop down list. For some reason, the combo box redraws
+ * the whole area, not just the text field. The fix is to set the
+ * SWP_NOSIZE bits when the height of text field and the drop down
+ * list is the same as the requested height.
+ *
+ * NOTE: Setting the width of a combo box to zero does not update
+ * the width of the drop down control rect. If the width of the
+ * combo box is zero, then do not set SWP_NOSIZE.
+ */
+ RECT rect = new RECT ();
+ OS.GetWindowRect (handle, rect);
+ if (rect.right - rect.left != 0) {
+ if (OS.SendMessage (handle, OS.CB_GETDROPPEDCONTROLRECT, 0, rect) != 0) {
+ int oldWidth = rect.right - rect.left, oldHeight = rect.bottom - rect.top;
+ if (oldWidth == width && oldHeight == height) flags |= OS.SWP_NOSIZE;
+ }
+ }
+ OS.SetWindowPos (handle, 0, x, y, width, height, 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.lpwp != null || (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);
+ int oldWidth = rect.right - rect.left, oldHeight = rect.bottom - rect.top;
+ if (oldWidth != width || oldHeight != height) {
+ if (OS.IsWinCE) {
+ int hwndText = OS.GetDlgItem (handle, CBID_EDIT);
+ if (hwndText != 0) OS.InvalidateRect (hwndText, null, true);
+ int hwndList = OS.GetDlgItem (handle, CBID_LIST);
+ if (hwndList != 0) OS.InvalidateRect (hwndList, null, true);
+ } else {
+ int uFlags = OS.RDW_ERASE | OS.RDW_INVALIDATE | OS.RDW_ALLCHILDREN;
+ OS.RedrawWindow (handle, null, 0, uFlags);
+ }
+ }
+}
+
+void setEditable (boolean editable) {
+ error (SWT.ERROR_NOT_IMPLEMENTED);
+}
+
+void setForegroundPixel (int pixel) {
+ if (foreground == pixel) return;
+ super.setForegroundPixel (pixel);
+ int hwndText = OS.GetDlgItem (handle, CBID_EDIT);
+ if (hwndText != 0) OS.InvalidateRect (hwndText, null, true);
+ int hwndList = OS.GetDlgItem (handle, CBID_LIST);
+ if (hwndList != 0) OS.InvalidateRect (hwndList, null, true);
+}
+
+/**
+ * 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);
+ int codePage = getCodePage ();
+ for (int i=0; i<items.length; i++) {
+ String string = items [i];
+ TCHAR buffer = new TCHAR (codePage, 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);
+ }
+ // widget could be disposed at this point
+ sendEvent (SWT.Modify);
+}
+
+/**
+ * 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);
+}
+
+/**
+ * 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);
+ if ((style & SWT.READ_ONLY) != 0) {
+ int index = indexOf (string);
+ if (index != -1) select (index);
+ return;
+ }
+ TCHAR buffer = new TCHAR (getCodePage (), string, true);
+ 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) {
+ if (super.translateAccelerator (msg)) return true;
+
+ /*
+ * 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. Note that we must call TranslateMessage
+ * in order to process accented keys properly.
+ */
+ int hwndText = OS.GetDlgItem (handle, CBID_EDIT);
+ if (hwndText != 0 && msg.hwnd == hwndText) {
+ switch (msg.message) {
+ case OS.WM_CHAR:
+ case OS.WM_SYSCHAR:
+ case OS.WM_KEYDOWN: {
+ Display display = getDisplay ();
+ if (msg.message == OS.WM_KEYDOWN) {
+ if (display.translateTraversal (msg, this)) return true;
+ } else {
+ if (display.translateMnemonic (msg, this)) return true;
+ }
+ }
+ }
+ OS.TranslateMessage (msg);
+ switch (msg.message) {
+ case OS.WM_CHAR: WM_CHAR (msg.wParam, msg.lParam); break;
+ case OS.WM_IME_CHAR: WM_IME_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;
+ }
+ OS.DispatchMessage (msg);
+ return true;
+ }
+ return false;
+}
+
+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.
+ */
+ int hwndText = OS.GetDlgItem (handle, CBID_EDIT);
+ if (hwndText != 0 && msg.hwnd == hwndText) {
+ 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) {
+ if (sendKeyEvent (SWT.KeyDown, msg.message, msg.wParam, msg.lParam)) {
+ if (msg.wParam == OS.VK_RETURN) {
+ sendEvent (SWT.DefaultSelection);
+ // widget could be disposed at this point
+ }
+ }
+ }
+ return true;
+ }
+ }
+ return super.translateTraversal (msg);
+}
+
+boolean traverseEscape () {
+ if (OS.SendMessage (handle, OS.CB_GETDROPPEDSTATE, 0, 0) != 0) {
+ OS.SendMessage (handle, OS.CB_SHOWDROPDOWN, 0, 0);
+ return true;
+ }
+ return super.traverseEscape ();
+}
+
+int widgetExtStyle () {
+ return super.widgetExtStyle () & ~OS.WS_EX_NOINHERITLAYOUT;
+}
+
+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;
+}
+
+TCHAR 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 WM_SIZE (int wParam, int lParam) {
+ /*
+ * Feature in Windows. When an editable drop down combo box
+ * contains text that does not correspond to an item in the
+ * list, when the widget is resized, it selects the closest
+ * match from the list. The fix is to remember the original
+ * text and reset it after the widget is resized.
+ */
+ if ((style & SWT.READ_ONLY) != 0 || (style & SWT.DROP_DOWN) == 0) {
+ return super.WM_SIZE (wParam, lParam);
+ }
+ int index = OS.SendMessage (handle, OS.CB_GETCURSEL, 0, 0);
+ boolean redraw = false;
+ TCHAR buffer = null;
+ int [] start = null, end = null;
+ if (index == OS.CB_ERR) {
+ int length = OS.GetWindowTextLength (handle);
+ if (length != 0) {
+ buffer = new TCHAR (getCodePage (), length + 1);
+ OS.GetWindowText (handle, buffer, length + 1);
+ start = new int [1]; end = new int [1];
+ OS.SendMessage (handle, OS.CB_GETEDITSEL, start, end);
+ redraw = drawCount == 0 && OS.IsWindowVisible (handle);
+ if (redraw) setRedraw (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;
+ if (buffer != null) {
+ OS.SetWindowText (handle, buffer);
+ int bits = start [0] | (end [0] << 16);
+ OS.SendMessage (handle, OS.CB_SETEDITSEL, 0, bits);
+ if (redraw) setRedraw (true);
+ }
+ return result;
+}
+
+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 an 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
index 96548af04a..770516cbd0 100755
--- 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
@@ -1,830 +1,830 @@
-package org.eclipse.swt.widgets;
-
-/*
+package org.eclipse.swt.widgets;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-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, NO_RADIO_GROUP</dd>
- * <dt><b>Events:</b></dt>
- * <dd>(none)</dd>
- * </dl>
- * <p>
- * Note: The <code>NO_BACKGROUND</code>, <code>NO_FOCUS</code>, <code>NO_MERGE_PAINTS</code>,
- * and <code>NO_REDRAW_RESIZE</code> styles are intended for use with <code>Canvas</code>.
- * They can be used with <code>Composite</code> if you are drawing your own, but their
- * behavior is undefined if they are used with subclasses of <code>Composite</code> other
- * than <code>Canvas</code>.
- * </p><p>
- * This class may be subclassed by custom control implementors
- * who are building controls that are constructed from aggregates
- * of other controls.
- * </p>
- *
- * @see Canvas
- */
-
-public class Composite extends Scrollable {
- Layout layout;
- int font;
- WINDOWPOS [] lpwp;
- Control [] tabList;
-
-/**
- * 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
- * lists the style constants that are applicable to the class.
- * Style bits are also inherited from superclasses.
- * </p>
- *
- * @param parent a widget which will be the parent of the new instance (cannot be null)
- * @param style the style of widget to construct
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
- * </ul>
- *
- * @see SWT#NO_BACKGROUND
- * @see SWT#NO_FOCUS
- * @see SWT#NO_MERGE_PAINTS
- * @see SWT#NO_REDRAW_RESIZE
- * @see SWT#NO_RADIO_GROUP
- * @see Widget#getStyle
- */
-public Composite (Composite parent, int style) {
- super (parent, 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;
-}
-
-Control [] _getTabList () {
- if (tabList == null) return tabList;
- int count = 0;
- for (int i=0; i<tabList.length; i++) {
- if (!tabList [i].isDisposed ()) count++;
- }
- if (count == tabList.length) return tabList;
- Control [] newList = new Control [count];
- int index = 0;
- for (int i=0; i<tabList.length; i++) {
- if (!tabList [i].isDisposed ()) {
- newList [index++] = tabList [i];
- }
- }
- tabList = newList;
- return tabList;
-}
-
-protected void checkSubclass () {
- /* Do nothing - Subclassing is allowed */
-}
-
-Control [] computeTabList () {
- Control result [] = super.computeTabList ();
- if (result.length == 0) return result;
- Control [] list = tabList != null ? _getTabList () : _getChildren ();
- for (int i=0; i<list.length; i++) {
- Control child = list [i];
- Control [] childList = child.computeTabList ();
- if (childList.length != 0) {
- Control [] newResult = new Control [result.length + childList.length];
- System.arraycopy (result, 0, newResult, 0, result.length);
- System.arraycopy (childList, 0, newResult, result.length, childList.length);
- result = newResult;
- }
- }
- return result;
-}
-
-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;
-}
-
-/**
- * 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 affect 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;
-}
-
-/**
- * Gets the last specified tabbing order for the control.
- *
- * @return tabList the ordered list of controls representing the tab order
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see #setTabList
- */
-public Control [] getTabList () {
- checkWidget ();
- Control [] tabList = _getTabList ();
- if (tabList == null) {
- int count = 0;
- Control [] list =_getChildren ();
- for (int i=0; i<list.length; i++) {
- if (list [i].isTabGroup ()) count++;
- }
- tabList = new Control [count];
- int index = 0;
- for (int i=0; i<list.length; i++) {
- if (list [i].isTabGroup ()) {
- tabList [index++] = list [i];
- }
- }
- }
- return tabList;
-}
-
-boolean hooksKeys () {
- return hooks (SWT.KeyDown) || hooks (SWT.KeyUp);
-}
-
-/**
- * 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;
- setResizeChildren (false);
- layout.layout (this, changed);
- setResizeChildren (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);
-}
-
-void releaseChildren () {
- Control [] children = _getChildren ();
- for (int i=0; i<children.length; i++) {
- Control child = children [i];
- if (!child.isDisposed ()) child.releaseResources ();
- }
-}
-
-void resizeChildren () {
- if (lpwp == null) return;
- do {
- WINDOWPOS [] currentLpwp = lpwp;
- lpwp = null;
- if (!resizeChildren (true, currentLpwp)) {
- resizeChildren (false, currentLpwp);
- }
- } while (lpwp != null);
-}
-
-boolean resizeChildren (boolean defer, WINDOWPOS [] pwp) {
- if (pwp == null) return true;
- int hdwp = 0;
- if (defer) {
- hdwp = OS.BeginDeferWindowPos (pwp.length);
- if (hdwp == 0) return false;
- }
- for (int i=0; i<pwp.length; i++) {
- WINDOWPOS wp = pwp [i];
- if (wp != null) {
- /*
- * This code is intentionally commented. All widgets that
- * are created by SWT have WS_CLIPSIBLINGS to ensure that
- * application code does not draw outside of the control.
- */
-// int count = parent.getChildrenCount ();
-// if (count > 1) {
-// int bits = OS.GetWindowLong (handle, OS.GWL_STYLE);
-// if ((bits & OS.WS_CLIPSIBLINGS) == 0) wp.flags |= OS.SWP_NOCOPYBITS;
-// }
- if (defer) {
- hdwp = OS.DeferWindowPos (hdwp, wp.hwnd, 0, wp.x, wp.y, wp.cx, wp.cy, wp.flags);
- if (hdwp == 0) return false;
- } else {
- OS.SetWindowPos (wp.hwnd, 0, wp.x, wp.y, wp.cx, wp.cy, wp.flags);
- }
- }
- }
- if (defer) return OS.EndDeferWindowPos (hdwp);
- return true;
-}
-
-void releaseWidget () {
- releaseChildren ();
- super.releaseWidget ();
- layout = null;
- tabList = null;
- lpwp = null;
-}
-
-public boolean setFocus () {
- checkWidget ();
- 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 layout the receiver's new layout or null
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public void setLayout (Layout layout) {
- checkWidget ();
- this.layout = layout;
-}
-
-/**
- * Sets the tabbing order for the specified controls to
- * match the order that they occur in the argument list.
- *
- * @param tabList the ordered list of controls representing the tab order or null
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_INVALID_ARGUMENT - if a widget in the tabList is null or has been disposed</li>
- * <li>ERROR_INVALID_PARENT - if widget in the tabList is not in the same widget tree</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public void setTabList (Control [] tabList) {
- checkWidget ();
- if (tabList != null) {
- for (int i=0; i<tabList.length; i++) {
- Control control = tabList [i];
- if (control == null) error (SWT.ERROR_INVALID_ARGUMENT);
- if (control.isDisposed ()) error (SWT.ERROR_INVALID_ARGUMENT);
- /*
- * This code is intentionally commented.
- * Tab lists are currently only supported
- * for the direct children of a composite.
- */
-// Shell shell = control.getShell ();
-// while (control != shell && control != this) {
-// control = control.parent;
-// }
-// if (control != this) error (SWT.ERROR_INVALID_PARENT);
- if (control.parent != this) error (SWT.ERROR_INVALID_PARENT);
- }
- Control [] newList = new Control [tabList.length];
- System.arraycopy (tabList, 0, newList, 0, tabList.length);
- tabList = newList;
- }
- this.tabList = tabList;
-}
-
-void setResizeChildren (boolean resize) {
- if (resize) {
- resizeChildren ();
- } else {
- int count = getChildrenCount ();
- if (count > 1 && lpwp == null) {
- lpwp = new WINDOWPOS [count];
- }
- }
-}
-
-boolean setTabGroupFocus () {
- if (isTabItem ()) return setTabItemFocus ();
- if ((style & SWT.NO_FOCUS) == 0) {
- boolean takeFocus = true;
- if ((state & CANVAS) != 0) takeFocus = hooksKeys ();
- if (takeFocus && setTabItemFocus ()) return true;
- }
- Control [] children = _getChildren ();
- for (int i=0; i<children.length; i++) {
- Control child = children [i];
- if (child.isTabItem () && child.setRadioFocus ()) return true;
- }
- for (int i=0; i<children.length; i++) {
- Control child = children [i];
- if (child.isTabItem () && child.setTabItemFocus ()) return true;
- }
- return false;
-}
-
-boolean setTabItemFocus () {
- if ((style & SWT.NO_FOCUS) == 0) {
- boolean takeFocus = true;
- if ((state & CANVAS) != 0) takeFocus = hooksKeys ();
- if (takeFocus) {
- if (!isShowing ()) return false;
- if (forceFocus ()) return true;
- }
- }
- return super.setTabItemFocus ();
-}
-
-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 translateMnemonic (char key) {
- if (super.translateMnemonic (key)) return true;
- Control [] children = _getChildren ();
- for (int i=0; i<children.length; i++) {
- Control child = children [i];
- if (child.translateMnemonic (key)) return true;
- }
- return false;
-}
-
-void updateFont (Font oldFont, Font newFont) {
- Control [] children = _getChildren ();
- for (int i=0; i<children.length; i++) {
- Control control = children [i];
- if (!control.isDisposed ()) {
- control.updateFont (oldFont, newFont);
- }
- }
- super.updateFont (oldFont, newFont);
- layout (true);
-}
-
-int widgetStyle () {
- /* Force clipping of children by setting WS_CLIPCHILDREN */
- return super.widgetStyle () | OS.WS_CLIPCHILDREN;
-}
-
-LRESULT WM_ERASEBKGND (int wParam, int lParam) {
- LRESULT result = super.WM_ERASEBKGND (wParam, lParam);
- if (result != null) return result;
- if ((state & CANVAS) != 0) {
- if ((style & SWT.NO_BACKGROUND) != 0) return LRESULT.ONE;
- }
- return result;
-}
-
-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 (hooksKeys ()) {
- 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) {
- if (!OS.IsWinCE) {
- NMHDR hdr = new NMHDR ();
- OS.MoveMemory (hdr, lParam, NMHDR.sizeof);
- switch (hdr.code) {
- /*
- * Feature in Windows. When the tool tip control is
- * created, the parent of the tool tip is the shell.
- * If SetParent () is used to reparent the tool bar
- * into a new shell, the tool tip is not reparented
- * and pops up underneath the new shell. The fix is
- * to make sure the tool tip is a topmost window.
- */
- case OS.TTN_SHOW:
- case OS.TTN_POP: {
- /*
- * Bug in Windows 98 and NT. Setting the tool tip to be the
- * top most window using HWND_TOPMOST can result in a parent
- * dialog shell being moved behind its parent if the dialog
- * has a sibling that is currently on top. The fix is to lock
- * the z-order of the active window.
- */
- Display display = getDisplay ();
- display.lockActiveWindow = true;
- int flags = OS.SWP_NOACTIVATE | OS.SWP_NOMOVE | OS.SWP_NOSIZE;
- int hwndInsertAfter = hdr.code == OS.TTN_SHOW ? OS.HWND_TOPMOST : OS.HWND_NOTOPMOST;
- OS.SetWindowPos (hdr.hwndFrom, hwndInsertAfter, 0, 0, 0, 0, flags);
- display.lockActiveWindow = false;
- break;
- }
- /*
- * Bug in Windows 98. For some reason, the tool bar control
- * sends both TTN_GETDISPINFOW and TTN_GETDISPINFOA to get
- * the tool tip text and the tab folder control sends only
- * TTN_GETDISPINFOW. The fix is to handle only TTN_GETDISPINFOW,
- * even though it should never be sent on Windows 98.
- *
- * NOTE: Because the size of NMTTDISPINFO differs between
- * Windows 98 and NT, guard against the case where the wrong
- * kind of message occurs by inlining the memory moves and
- * the UNICODE conversion code.
- */
- case OS.TTN_GETDISPINFOA:
- case OS.TTN_GETDISPINFOW: {
- NMTTDISPINFO lpnmtdi = new NMTTDISPINFO ();
- if (hdr.code == OS.TTN_GETDISPINFOA) {
- OS.MoveMemoryA (lpnmtdi, lParam, NMTTDISPINFO.sizeofA);
- } else {
- OS.MoveMemoryW (lpnmtdi, lParam, NMTTDISPINFO.sizeofW);
- }
- String string = toolTipText (lpnmtdi);
- if (string != null) {
- Shell shell = getShell ();
- string = Display.withCrLf (string);
- int length = string.length ();
- char [] chars = new char [length + 1];
- string.getChars (0, length, chars, 0);
- if (hdr.code == OS.TTN_GETDISPINFOA) {
- byte [] bytes = new byte [chars.length * 2];
- OS.WideCharToMultiByte (OS.CP_ACP, 0, chars, chars.length, bytes, bytes.length, null, null);
- shell.setToolTipText (lpnmtdi, bytes);
- OS.MoveMemoryA (lParam, lpnmtdi, NMTTDISPINFO.sizeofA);
- } else {
- shell.setToolTipText (lpnmtdi, chars);
- OS.MoveMemoryW (lParam, lpnmtdi, NMTTDISPINFO.sizeofW);
- }
- return LRESULT.ZERO;
- }
- break;
- }
- }
- }
- 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 = 0;
- if (!OS.IsWinCE) {
- 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 count = lpRgnData [2];
- for (int i=0; i<count; i++) {
- OS.SetRect (rect,
- lpRgnData [8 + (i << 2)],
- lpRgnData [8 + (i << 2) + 1],
- lpRgnData [8 + (i << 2) + 2],
- lpRgnData [8 + (i << 2) + 3]);
- if ((style & SWT.NO_BACKGROUND) == 0) {
- 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 = count - 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 {
- if ((style & SWT.NO_BACKGROUND) == 0) {
- 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 ();
-
- if (!OS.IsWinCE) {
- /*
- * 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 */
- setResizeChildren (false);
-
- /* Resize and Layout */
- 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 (layout != null) layout.layout (this, false);
-
- /* End deferred window positioning */
- setResizeChildren (true);
-
- /* 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.
- */
- if (!OS.IsWinCE) {
- 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;
-}
-
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+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, NO_RADIO_GROUP</dd>
+ * <dt><b>Events:</b></dt>
+ * <dd>(none)</dd>
+ * </dl>
+ * <p>
+ * Note: The <code>NO_BACKGROUND</code>, <code>NO_FOCUS</code>, <code>NO_MERGE_PAINTS</code>,
+ * and <code>NO_REDRAW_RESIZE</code> styles are intended for use with <code>Canvas</code>.
+ * They can be used with <code>Composite</code> if you are drawing your own, but their
+ * behavior is undefined if they are used with subclasses of <code>Composite</code> other
+ * than <code>Canvas</code>.
+ * </p><p>
+ * This class may be subclassed by custom control implementors
+ * who are building controls that are constructed from aggregates
+ * of other controls.
+ * </p>
+ *
+ * @see Canvas
+ */
+
+public class Composite extends Scrollable {
+ Layout layout;
+ int font;
+ WINDOWPOS [] lpwp;
+ Control [] tabList;
+
+/**
+ * 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
+ * lists the style constants that are applicable to the class.
+ * Style bits are also inherited from superclasses.
+ * </p>
+ *
+ * @param parent a widget which will be the parent of the new instance (cannot be null)
+ * @param style the style of widget to construct
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
+ * </ul>
+ *
+ * @see SWT#NO_BACKGROUND
+ * @see SWT#NO_FOCUS
+ * @see SWT#NO_MERGE_PAINTS
+ * @see SWT#NO_REDRAW_RESIZE
+ * @see SWT#NO_RADIO_GROUP
+ * @see Widget#getStyle
+ */
+public Composite (Composite parent, int style) {
+ super (parent, 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;
+}
+
+Control [] _getTabList () {
+ if (tabList == null) return tabList;
+ int count = 0;
+ for (int i=0; i<tabList.length; i++) {
+ if (!tabList [i].isDisposed ()) count++;
+ }
+ if (count == tabList.length) return tabList;
+ Control [] newList = new Control [count];
+ int index = 0;
+ for (int i=0; i<tabList.length; i++) {
+ if (!tabList [i].isDisposed ()) {
+ newList [index++] = tabList [i];
+ }
+ }
+ tabList = newList;
+ return tabList;
+}
+
+protected void checkSubclass () {
+ /* Do nothing - Subclassing is allowed */
+}
+
+Control [] computeTabList () {
+ Control result [] = super.computeTabList ();
+ if (result.length == 0) return result;
+ Control [] list = tabList != null ? _getTabList () : _getChildren ();
+ for (int i=0; i<list.length; i++) {
+ Control child = list [i];
+ Control [] childList = child.computeTabList ();
+ if (childList.length != 0) {
+ Control [] newResult = new Control [result.length + childList.length];
+ System.arraycopy (result, 0, newResult, 0, result.length);
+ System.arraycopy (childList, 0, newResult, result.length, childList.length);
+ result = newResult;
+ }
+ }
+ return result;
+}
+
+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;
+}
+
+/**
+ * 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 affect 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;
+}
+
+/**
+ * Gets the last specified tabbing order for the control.
+ *
+ * @return tabList the ordered list of controls representing the tab order
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see #setTabList
+ */
+public Control [] getTabList () {
+ checkWidget ();
+ Control [] tabList = _getTabList ();
+ if (tabList == null) {
+ int count = 0;
+ Control [] list =_getChildren ();
+ for (int i=0; i<list.length; i++) {
+ if (list [i].isTabGroup ()) count++;
+ }
+ tabList = new Control [count];
+ int index = 0;
+ for (int i=0; i<list.length; i++) {
+ if (list [i].isTabGroup ()) {
+ tabList [index++] = list [i];
+ }
+ }
+ }
+ return tabList;
+}
+
+boolean hooksKeys () {
+ return hooks (SWT.KeyDown) || hooks (SWT.KeyUp);
+}
+
+/**
+ * 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;
+ setResizeChildren (false);
+ layout.layout (this, changed);
+ setResizeChildren (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);
+}
+
+void releaseChildren () {
+ Control [] children = _getChildren ();
+ for (int i=0; i<children.length; i++) {
+ Control child = children [i];
+ if (!child.isDisposed ()) child.releaseResources ();
+ }
+}
+
+void resizeChildren () {
+ if (lpwp == null) return;
+ do {
+ WINDOWPOS [] currentLpwp = lpwp;
+ lpwp = null;
+ if (!resizeChildren (true, currentLpwp)) {
+ resizeChildren (false, currentLpwp);
+ }
+ } while (lpwp != null);
+}
+
+boolean resizeChildren (boolean defer, WINDOWPOS [] pwp) {
+ if (pwp == null) return true;
+ int hdwp = 0;
+ if (defer) {
+ hdwp = OS.BeginDeferWindowPos (pwp.length);
+ if (hdwp == 0) return false;
+ }
+ for (int i=0; i<pwp.length; i++) {
+ WINDOWPOS wp = pwp [i];
+ if (wp != null) {
+ /*
+ * This code is intentionally commented. All widgets that
+ * are created by SWT have WS_CLIPSIBLINGS to ensure that
+ * application code does not draw outside of the control.
+ */
+// int count = parent.getChildrenCount ();
+// if (count > 1) {
+// int bits = OS.GetWindowLong (handle, OS.GWL_STYLE);
+// if ((bits & OS.WS_CLIPSIBLINGS) == 0) wp.flags |= OS.SWP_NOCOPYBITS;
+// }
+ if (defer) {
+ hdwp = OS.DeferWindowPos (hdwp, wp.hwnd, 0, wp.x, wp.y, wp.cx, wp.cy, wp.flags);
+ if (hdwp == 0) return false;
+ } else {
+ OS.SetWindowPos (wp.hwnd, 0, wp.x, wp.y, wp.cx, wp.cy, wp.flags);
+ }
+ }
+ }
+ if (defer) return OS.EndDeferWindowPos (hdwp);
+ return true;
+}
+
+void releaseWidget () {
+ releaseChildren ();
+ super.releaseWidget ();
+ layout = null;
+ tabList = null;
+ lpwp = null;
+}
+
+public boolean setFocus () {
+ checkWidget ();
+ 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 layout the receiver's new layout or null
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setLayout (Layout layout) {
+ checkWidget ();
+ this.layout = layout;
+}
+
+/**
+ * Sets the tabbing order for the specified controls to
+ * match the order that they occur in the argument list.
+ *
+ * @param tabList the ordered list of controls representing the tab order or null
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_INVALID_ARGUMENT - if a widget in the tabList is null or has been disposed</li>
+ * <li>ERROR_INVALID_PARENT - if widget in the tabList is not in the same widget tree</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setTabList (Control [] tabList) {
+ checkWidget ();
+ if (tabList != null) {
+ for (int i=0; i<tabList.length; i++) {
+ Control control = tabList [i];
+ if (control == null) error (SWT.ERROR_INVALID_ARGUMENT);
+ if (control.isDisposed ()) error (SWT.ERROR_INVALID_ARGUMENT);
+ /*
+ * This code is intentionally commented.
+ * Tab lists are currently only supported
+ * for the direct children of a composite.
+ */
+// Shell shell = control.getShell ();
+// while (control != shell && control != this) {
+// control = control.parent;
+// }
+// if (control != this) error (SWT.ERROR_INVALID_PARENT);
+ if (control.parent != this) error (SWT.ERROR_INVALID_PARENT);
+ }
+ Control [] newList = new Control [tabList.length];
+ System.arraycopy (tabList, 0, newList, 0, tabList.length);
+ tabList = newList;
+ }
+ this.tabList = tabList;
+}
+
+void setResizeChildren (boolean resize) {
+ if (resize) {
+ resizeChildren ();
+ } else {
+ int count = getChildrenCount ();
+ if (count > 1 && lpwp == null) {
+ lpwp = new WINDOWPOS [count];
+ }
+ }
+}
+
+boolean setTabGroupFocus () {
+ if (isTabItem ()) return setTabItemFocus ();
+ if ((style & SWT.NO_FOCUS) == 0) {
+ boolean takeFocus = true;
+ if ((state & CANVAS) != 0) takeFocus = hooksKeys ();
+ if (takeFocus && setTabItemFocus ()) return true;
+ }
+ Control [] children = _getChildren ();
+ for (int i=0; i<children.length; i++) {
+ Control child = children [i];
+ if (child.isTabItem () && child.setRadioFocus ()) return true;
+ }
+ for (int i=0; i<children.length; i++) {
+ Control child = children [i];
+ if (child.isTabItem () && child.setTabItemFocus ()) return true;
+ }
+ return false;
+}
+
+boolean setTabItemFocus () {
+ if ((style & SWT.NO_FOCUS) == 0) {
+ boolean takeFocus = true;
+ if ((state & CANVAS) != 0) takeFocus = hooksKeys ();
+ if (takeFocus) {
+ if (!isShowing ()) return false;
+ if (forceFocus ()) return true;
+ }
+ }
+ return super.setTabItemFocus ();
+}
+
+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 translateMnemonic (char key) {
+ if (super.translateMnemonic (key)) return true;
+ Control [] children = _getChildren ();
+ for (int i=0; i<children.length; i++) {
+ Control child = children [i];
+ if (child.translateMnemonic (key)) return true;
+ }
+ return false;
+}
+
+void updateFont (Font oldFont, Font newFont) {
+ Control [] children = _getChildren ();
+ for (int i=0; i<children.length; i++) {
+ Control control = children [i];
+ if (!control.isDisposed ()) {
+ control.updateFont (oldFont, newFont);
+ }
+ }
+ super.updateFont (oldFont, newFont);
+ layout (true);
+}
+
+int widgetStyle () {
+ /* Force clipping of children by setting WS_CLIPCHILDREN */
+ return super.widgetStyle () | OS.WS_CLIPCHILDREN;
+}
+
+LRESULT WM_ERASEBKGND (int wParam, int lParam) {
+ LRESULT result = super.WM_ERASEBKGND (wParam, lParam);
+ if (result != null) return result;
+ if ((state & CANVAS) != 0) {
+ if ((style & SWT.NO_BACKGROUND) != 0) return LRESULT.ONE;
+ }
+ return result;
+}
+
+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 (hooksKeys ()) {
+ 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) {
+ if (!OS.IsWinCE) {
+ NMHDR hdr = new NMHDR ();
+ OS.MoveMemory (hdr, lParam, NMHDR.sizeof);
+ switch (hdr.code) {
+ /*
+ * Feature in Windows. When the tool tip control is
+ * created, the parent of the tool tip is the shell.
+ * If SetParent () is used to reparent the tool bar
+ * into a new shell, the tool tip is not reparented
+ * and pops up underneath the new shell. The fix is
+ * to make sure the tool tip is a topmost window.
+ */
+ case OS.TTN_SHOW:
+ case OS.TTN_POP: {
+ /*
+ * Bug in Windows 98 and NT. Setting the tool tip to be the
+ * top most window using HWND_TOPMOST can result in a parent
+ * dialog shell being moved behind its parent if the dialog
+ * has a sibling that is currently on top. The fix is to lock
+ * the z-order of the active window.
+ */
+ Display display = getDisplay ();
+ display.lockActiveWindow = true;
+ int flags = OS.SWP_NOACTIVATE | OS.SWP_NOMOVE | OS.SWP_NOSIZE;
+ int hwndInsertAfter = hdr.code == OS.TTN_SHOW ? OS.HWND_TOPMOST : OS.HWND_NOTOPMOST;
+ OS.SetWindowPos (hdr.hwndFrom, hwndInsertAfter, 0, 0, 0, 0, flags);
+ display.lockActiveWindow = false;
+ break;
+ }
+ /*
+ * Bug in Windows 98. For some reason, the tool bar control
+ * sends both TTN_GETDISPINFOW and TTN_GETDISPINFOA to get
+ * the tool tip text and the tab folder control sends only
+ * TTN_GETDISPINFOW. The fix is to handle only TTN_GETDISPINFOW,
+ * even though it should never be sent on Windows 98.
+ *
+ * NOTE: Because the size of NMTTDISPINFO differs between
+ * Windows 98 and NT, guard against the case where the wrong
+ * kind of message occurs by inlining the memory moves and
+ * the UNICODE conversion code.
+ */
+ case OS.TTN_GETDISPINFOA:
+ case OS.TTN_GETDISPINFOW: {
+ NMTTDISPINFO lpnmtdi = new NMTTDISPINFO ();
+ if (hdr.code == OS.TTN_GETDISPINFOA) {
+ OS.MoveMemoryA (lpnmtdi, lParam, NMTTDISPINFO.sizeofA);
+ } else {
+ OS.MoveMemoryW (lpnmtdi, lParam, NMTTDISPINFO.sizeofW);
+ }
+ String string = toolTipText (lpnmtdi);
+ if (string != null) {
+ Shell shell = getShell ();
+ string = Display.withCrLf (string);
+ int length = string.length ();
+ char [] chars = new char [length + 1];
+ string.getChars (0, length, chars, 0);
+ if (hdr.code == OS.TTN_GETDISPINFOA) {
+ byte [] bytes = new byte [chars.length * 2];
+ OS.WideCharToMultiByte (OS.CP_ACP, 0, chars, chars.length, bytes, bytes.length, null, null);
+ shell.setToolTipText (lpnmtdi, bytes);
+ OS.MoveMemoryA (lParam, lpnmtdi, NMTTDISPINFO.sizeofA);
+ } else {
+ shell.setToolTipText (lpnmtdi, chars);
+ OS.MoveMemoryW (lParam, lpnmtdi, NMTTDISPINFO.sizeofW);
+ }
+ return LRESULT.ZERO;
+ }
+ break;
+ }
+ }
+ }
+ 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 = 0;
+ if (!OS.IsWinCE) {
+ 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 count = lpRgnData [2];
+ for (int i=0; i<count; i++) {
+ OS.SetRect (rect,
+ lpRgnData [8 + (i << 2)],
+ lpRgnData [8 + (i << 2) + 1],
+ lpRgnData [8 + (i << 2) + 2],
+ lpRgnData [8 + (i << 2) + 3]);
+ if ((style & SWT.NO_BACKGROUND) == 0) {
+ 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 = count - 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 {
+ if ((style & SWT.NO_BACKGROUND) == 0) {
+ 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 ();
+
+ if (!OS.IsWinCE) {
+ /*
+ * 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 */
+ setResizeChildren (false);
+
+ /* Resize and Layout */
+ 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 (layout != null) layout.layout (this, false);
+
+ /* End deferred window positioning */
+ setResizeChildren (true);
+
+ /* 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.
+ */
+ if (!OS.IsWinCE) {
+ 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
index 12d66dd630..c601004f37 100755
--- 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
@@ -1,4224 +1,4224 @@
-package org.eclipse.swt.widgets;
-
-/*
+package org.eclipse.swt.widgets;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-import org.eclipse.swt.internal.win32.*;
-import org.eclipse.swt.graphics.*;
-import org.eclipse.swt.*;
-import org.eclipse.swt.events.*;
-import org.eclipse.swt.accessibility.*;
-
-/**
- * Control is the abstract superclass of all windowed user interface classes.
- * <p>
- * <dl>
- * <dt><b>Styles:</b>
- * <dd>BORDER</dd>
- * <dd>LEFT_TO_RIGHT, RIGHT_TO_LEFT</dd>
- * <dt><b>Events:</b>
- * <dd>FocusIn, FocusOut, Help, KeyDown, KeyUp, MouseDoubleClick, MouseDown, MouseEnter,
- * MouseExit, MouseHover, MouseUp, MouseMove, Move, Paint, Resize</dd>
- * </dl>
- * <p>
- * Only one of LEFT_TO_RIGHT or RIGHT_TO_LEFT may be specified.
- * </p><p>
- * IMPORTANT: This class is intended to be subclassed <em>only</em>
- * within the SWT implementation.
- * </p>
- *
- * Note: Only one of LEFT_TO_RIGHT and RIGHT_TO_LEFT may be specified.
- */
-
-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;
- Accessible accessible;
-
- static final short [] ACCENTS = new short [] {'~', '`', '\'', '^', '"'};
-
-/**
- * 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
- * lists the style constants that are applicable to the class.
- * Style bits are also inherited from superclasses.
- * </p>
- *
- * @param parent a composite control which will be the parent of the new instance (cannot be null)
- * @param style the style of control to construct
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
- * <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
- * </ul>
- *
- * @see SWT#BORDER
- * @see Widget#checkSubclass
- * @see Widget#getStyle
- */
-public Control (Composite parent, int style) {
- super (parent, style);
- this.parent = parent;
- createWidget ();
-}
-
-/**
- * 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 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);
-
-void checkOrientation (Widget parent) {
- super.checkOrientation (parent);
- if ((style & SWT.RIGHT_TO_LEFT) != 0) style |= SWT.MIRRORED;
-}
-
-/**
- * Returns the preferred size of the receiver.
- * <p>
- * The <em>preferred size</em> of a control is the size that it would
- * best be displayed at. The width hint and height hint arguments
- * allow the caller to ask a control questions such as "Given a particular
- * width, how high does the control need to be to show all of the contents?"
- * To indicate that the caller does not wish to constrain a particular
- * dimension, the constant <code>SWT.DEFAULT</code> is passed for the hint.
- * </p>
- *
- * @param wHint the width hint (can be <code>SWT.DEFAULT</code>)
- * @param hHint the height hint (can be <code>SWT.DEFAULT</code>)
- * @return the preferred size of the control
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see Layout
- * @see #getBorderWidth
- * @see #getBounds
- * @see #getSize
- * @see #pack
- * @see "computeTrim, getClientArea for controls that implement them"
- */
-public Point computeSize (int wHint, int hHint) {
- return computeSize (wHint, hHint, true);
-}
-
-/**
- * Returns the preferred size of the receiver.
- * <p>
- * The <em>preferred size</em> of a control is the size that it would
- * best be displayed at. The width hint and height hint arguments
- * allow the caller to ask a control questions such as "Given a particular
- * width, how high does the control need to be to show all of the contents?"
- * To indicate that the caller does not wish to constrain a particular
- * dimension, the constant <code>SWT.DEFAULT</code> is passed for the hint.
- * </p><p>
- * If the changed flag is <code>true</code>, it indicates that the receiver's
- * <em>contents</em> have changed, therefore any caches that a layout manager
- * containing the control may have been keeping need to be flushed. When the
- * control is resized, the changed flag will be <code>false</code>, so layout
- * manager caches can be retained.
- * </p>
- *
- * @param wHint the width hint (can be <code>SWT.DEFAULT</code>)
- * @param hHint the height hint (can be <code>SWT.DEFAULT</code>)
- * @param changed <code>true</code> if the control's contents have changed, and <code>false</code> otherwise
- * @return the preferred size of the control.
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see Layout
- * @see #getBorderWidth
- * @see #getBounds
- * @see #getSize
- * @see #pack
- * @see "computeTrim, getClientArea for controls that implement them"
- */
-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);
-}
-
-Control computeTabGroup () {
- if (isTabGroup ()) return this;
- return parent.computeTabGroup ();
-}
-
-Control computeTabRoot () {
- Control [] tabList = parent._getTabList ();
- if (tabList != null) {
- int index = 0;
- while (index < tabList.length) {
- if (tabList [index] == this) break;
- index++;
- }
- if (index == tabList.length) {
- if (isTabGroup ()) return this;
- }
- }
- return parent.computeTabRoot ();
-}
-
-Control [] computeTabList () {
- if (isTabGroup ()) {
- if (getVisible () && getEnabled ()) {
- return new Control [] {this};
- }
- }
- return new Control [0];
-}
-
-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);
- int bits = OS.GetWindowLong (handle, OS.GWL_STYLE);
- if ((bits & OS.WS_CHILD) != 0) {
- OS.SetWindowLong (handle, OS.GWL_ID, handle);
- }
- if (OS.IsDBLocale && parent != null) {
- int hIMC = OS.ImmGetContext (hwndParent);
- OS.ImmAssociateContext (handle, hIMC);
- OS.ImmReleaseContext (hwndParent, hIMC);
- }
-}
-
-void createWidget () {
- foreground = background = -1;
- checkOrientation (parent);
- createHandle ();
- register ();
- subclass ();
- setDefaultFont ();
-}
-
-int defaultBackground () {
- if (OS.IsWinCE) return OS.GetSysColor (OS.COLOR_WINDOW);
- return OS.GetSysColor (OS.COLOR_BTNFACE);
-}
-
-int defaultFont () {
- Display display = getDisplay ();
- return display.systemFont ();
-}
-
-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);
- }
-}
-
-void drawBackground (int hDC) {
- RECT rect = new RECT ();
- OS.GetClientRect (handle, rect);
- drawBackground (hDC, rect);
-}
-
-void drawBackground (int hDC, RECT rect) {
- Display display = getDisplay ();
- int hPalette = display.hPalette;
- if (hPalette != 0) {
- OS.SelectPalette (hDC, hPalette, false);
- OS.RealizePalette (hDC);
- }
- int pixel = getBackgroundPixel ();
- int hBrush = findBrush (pixel);
- OS.FillRect (hDC, rect, hBrush);
-}
-
-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';
-}
-
-void fixFocus () {
- Shell shell = getShell ();
- Control control = this;
- while ((control = control.parent) != null) {
- if (control.setFocus () || control == shell) return;
- }
- OS.SetFocus (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 ();
- /*
- * This code is intentionally commented.
- *
- * When setting focus to a control, it is
- * possible that application code can set
- * the focus to another control inside of
- * WM_SETFOCUS. In this case, the original
- * control will no longer have the focus
- * and the call to setFocus() will return
- * false indicating failure.
- *
- * We are still working on a solution at
- * this time.
- */
-// if (OS.GetFocus () != OS.SetFocus (handle)) return false;
- OS.SetFocus (handle);
- return isFocusControl ();
-}
-
-void forceResize () {
- if (parent == null) return;
- WINDOWPOS [] lpwp = parent.lpwp;
- if (lpwp == null) return;
- for (int i=0; i<lpwp.length; i++) {
- WINDOWPOS wp = lpwp [i];
- if (wp != null && wp.hwnd == handle) {
- /*
- * This code is intentionally commented. All widgets that
- * are created by SWT have WS_CLIPSIBLINGS to ensure that
- * application code does not draw outside of the control.
- */
-// int count = parent.getChildrenCount ();
-// if (count > 1) {
-// int bits = OS.GetWindowLong (handle, OS.GWL_STYLE);
-// if ((bits & OS.WS_CLIPSIBLINGS) == 0) wp.flags |= OS.SWP_NOCOPYBITS;
-// }
- OS.SetWindowPos (wp.hwnd, 0, wp.x, wp.y, wp.cx, wp.cy, wp.flags);
- lpwp [i] = null;
- return;
- }
- }
-}
-
-/**
- * Returns the accessible object for the receiver.
- * If this is the first time this object is requested,
- * then the object is created and returned.
- *
- * @return the accessible object
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see Accessible#addAccessibleListener
- * @see Accessible#addAccessibleControlListener
- *
- * @since 2.0
- */
-public Accessible getAccessible () {
- checkWidget ();
- if (accessible == null) accessible = new_Accessible (this);
- return accessible;
-}
-
-/**
- * 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 ();
- forceResize ();
- RECT rect = new RECT ();
- OS.GetWindowRect (handle, rect);
- int hwndParent = parent == null ? 0 : parent.handle;
- 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);
-}
-
-int getCodePage () {
- int hFont = OS.SendMessage (handle, OS.WM_GETFONT, 0, 0);
- LOGFONT logFont = new LOGFONT ();
- OS.GetObject (hFont, LOGFONT.sizeof, logFont);
- int cs = logFont.lfCharSet & 0xFF;
- int [] lpCs = new int [8];
- if (OS.TranslateCharsetInfo (cs, lpCs, OS.TCI_SRCCHARSET)) {
- return lpCs [1];
- }
- return OS.GetACP ();
-}
-
-/**
- * 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>
- *
- * @see #isEnabled
- */
-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 ();
- forceResize ();
- RECT rect = new RECT ();
- OS.GetWindowRect (handle, rect);
- int hwndParent = parent == null ? 0 : parent.handle;
- 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 ();
- forceResize ();
- 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 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 () {
- /*
- * If a non-SWT child of the control has focus,
- * then this control is considered to have focus
- * even though it does not have focus in Windows.
- */
- int hwndFocus = OS.GetFocus ();
- while (hwndFocus != 0) {
- if (hwndFocus == handle) return true;
- if (WidgetTable.get (hwndFocus) != null) {
- return false;
- }
- 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) {
- checkWidget();
- 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);
- data.hwnd = handle;
- }
- 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) {
- checkWidget ();
- 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 all
- * of the receiver's ancestors are enabled, and <code>false</code>
- * otherwise. A disabled control is typically not selectable from the
- * user interface and draws with an inactive or "grayed" look.
- *
- * @return the receiver's enabled state
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see #getEnabled
- */
-public boolean isEnabled () {
- checkWidget ();
- return getEnabled () && parent.isEnabled ();
-}
-
-/**
- * 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 ();
-}
-
-boolean isFocusAncestor () {
- Display display = getDisplay ();
- Control control = display.getFocusControl ();
- while (control != null && control != this) {
- control = control.parent;
- }
- return control == this;
-}
-
-/**
- * Returns <code>true</code> if the underlying operating
- * system supports this reparenting, otherwise <code>false</code>
- *
- * @return <code>true</code> if the widget can be reparented, otherwise <code>false</code>
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public boolean isReparentable () {
- checkWidget ();
- return true;
-}
-
-boolean isShowing () {
- /*
- * This is not complete. Need to check if the
- * widget is obscurred by a parent or sibling.
- */
- if (!isVisible ()) return false;
- Control control = this;
- while (control != null) {
- Point size = control.getSize ();
- if (size.x == 0 || size.y == 0) {
- return false;
- }
- control = control.parent;
- }
- return true;
- /*
- * Check to see if current damage is included.
- */
-// if (!OS.IsWindowVisible (handle)) return false;
-// int flags = OS.DCX_CACHE | OS.DCX_CLIPCHILDREN | OS.DCX_CLIPSIBLINGS;
-// int hDC = OS.GetDCEx (handle, 0, flags);
-// int result = OS.GetClipBox (hDC, new RECT ());
-// OS.ReleaseDC (handle, hDC);
-// return result != OS.NULLREGION;
-}
-
-boolean isTabGroup () {
- Control [] tabList = parent._getTabList ();
- if (tabList != null) {
- for (int i=0; i<tabList.length; i++) {
- if (tabList [i] == this) return true;
- }
- }
- int bits = OS.GetWindowLong (handle, OS.GWL_STYLE);
- return (bits & OS.WS_TABSTOP) != 0;
-}
-
-boolean isTabItem () {
- Control [] tabList = parent._getTabList ();
- if (tabList != null) {
- for (int i=0; i<tabList.length; i++) {
- if (tabList [i] == this) return false;
- }
- }
- int 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;
-}
-
-/**
- * Returns <code>true</code> if the receiver is visible and all
- * of the receiver's ancestors are visible and <code>false</code>
- * otherwise.
- *
- * @return the receiver's visibility state
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see #getVisible
- */
-public boolean isVisible () {
- checkWidget ();
- return OS.IsWindowVisible (handle);
-}
-
-Decorations menuShell () {
- return parent.menuShell ();
-}
-
-boolean mnemonicHit (char key) {
- 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 IllegalArgumentException <ul>
- * <li>ERROR_INVALID_ARGUMENT - if the control has been disposed</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public void moveAbove (Control control) {
- checkWidget ();
- int hwndAbove = OS.HWND_TOP;
- if (control != null) {
- if (control.isDisposed ()) error(SWT.ERROR_INVALID_ARGUMENT);
- if (parent != control.parent) return;
- int hwnd = control.handle;
- if (hwnd == 0 || hwnd == handle) return;
- hwndAbove = OS.GetWindow (hwnd, OS.GW_HWNDPREV);
- /*
- * Bug in Windows. For some reason, when GetWindow ()
- * with GW_HWNDPREV is used to query the previous window
- * in the z-order with the first child, Windows returns
- * the first child instead of NULL. The fix is to detect
- * this case and move the control to the top.
- */
- if (hwndAbove == 0 || hwndAbove == hwnd) {
- hwndAbove = OS.HWND_TOP;
- }
- }
- int flags = OS.SWP_NOSIZE | OS.SWP_NOMOVE | OS.SWP_NOACTIVATE;
- OS.SetWindowPos (handle, hwndAbove, 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 IllegalArgumentException <ul>
- * <li>ERROR_INVALID_ARGUMENT - if the control has been disposed</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public void moveBelow (Control control) {
- checkWidget ();
- int hwndAbove = OS.HWND_BOTTOM;
- if (control != null) {
- if (control.isDisposed ()) error(SWT.ERROR_INVALID_ARGUMENT);
- if (parent != control.parent) return;
- hwndAbove = control.handle;
- }
- if (hwndAbove == 0 || hwndAbove == handle) return;
- int flags = OS.SWP_NOSIZE | OS.SWP_NOMOVE | OS.SWP_NOACTIVATE;
- OS.SetWindowPos (handle, hwndAbove, 0, 0, 0, 0, flags);
-}
-
-Accessible new_Accessible (Control control) {
- return Accessible.internal_new_Accessible (this);
-}
-
-/**
- * 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;
- if (OS.IsWinCE) {
- OS.InvalidateRect (handle, null, true);
- } else {
- 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 (width <= 0 || height <= 0) return;
- if (!OS.IsWindowVisible (handle)) return;
- RECT rect = new RECT ();
- OS.SetRect (rect, x, y, x + width, y + height);
- if (OS.IsWinCE) {
- OS.InvalidateRect (handle, rect, true);
- } else {
- int flags = OS.RDW_ERASE | OS.RDW_FRAME | OS.RDW_INVALIDATE;
- if (all) flags |= OS.RDW_ALLCHILDREN;
- OS.RedrawWindow (handle, rect, 0, flags);
- }
-}
-
-void register () {
- WidgetTable.put (handle, this);
-}
-
-void releaseHandle () {
- super.releaseHandle ();
- handle = 0;
-}
-
-void releaseWidget () {
- super.releaseWidget ();
- if (OS.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;
- if (accessible != null) {
- accessible.internal_dispose_Accessible ();
- }
- accessible = 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);
- setInputState (event, type);
- 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 IllegalArgumentException <ul>
- * <li>ERROR_INVALID_ARGUMENT - if the argument has been disposed</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public void setBackground (Color color) {
- checkWidget ();
- int pixel = -1;
- if (color != null) {
- if (color.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
- 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 ();
- int flags = OS.SWP_NOZORDER | OS.SWP_DRAWFRAME | OS.SWP_NOACTIVATE;
- setBounds (x, y, Math.max (0, width), Math.max (0, height), flags);
-}
-
-void setBounds (int x, int y, int width, int height, int flags) {
- if (parent == null) {
- OS.SetWindowPos (handle, 0, x, y, width, height, flags);
- return;
- }
- if (parent.lpwp == null) {
- /*
- * This code is intentionally commented. All widgets that
- * are created by SWT have WS_CLIPSIBLINGS to ensure that
- * application code does not draw outside of the control.
- */
-// int count = parent.getChildrenCount ();
-// 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;
- }
- forceResize ();
- WINDOWPOS [] lpwp = parent.lpwp;
- int index = 0;
- while (index < lpwp.length) {
- if (lpwp [index] == null) break;
- index ++;
- }
- if (index == lpwp.length) {
- WINDOWPOS [] newLpwp = new WINDOWPOS [lpwp.length + 4];
- System.arraycopy (lpwp, 0, newLpwp, 0, lpwp.length);
- parent.lpwp = lpwp = newLpwp;
- }
- WINDOWPOS wp = new WINDOWPOS ();
- wp.hwnd = handle;
- wp.x = x;
- wp.y = y;
- wp.cx = width;
- wp.cy = height;
- wp.flags = flags;
- lpwp [index] = wp;
-}
-
-/**
- * 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 IllegalArgumentException <ul>
- * <li>ERROR_INVALID_ARGUMENT - if the argument has been disposed</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public void setCursor (Cursor cursor) {
- checkWidget ();
- hCursor = 0;
- if (cursor != null) {
- if (cursor.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
- hCursor = cursor.handle;
- }
- if (OS.IsWinCE) {
- OS.SetCursor (hCursor);
- return;
- }
- 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 () {
- Display display = getDisplay ();
- int hFont = display.systemFont ();
- 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 ();
-
- /*
- * 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.
- */
- boolean fixFocus = false;
- if (!enabled) fixFocus = isFocusAncestor ();
- OS.EnableWindow (handle, enabled);
- if (fixFocus) fixFocus ();
-}
-
-/**
- * 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 IllegalArgumentException <ul>
- * <li>ERROR_INVALID_ARGUMENT - if the argument has been disposed</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public void setFont (Font font) {
- checkWidget ();
- int hFont = 0;
- if (font != null) {
- if (font.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
- 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 IllegalArgumentException <ul>
- * <li>ERROR_INVALID_ARGUMENT - if the argument has been disposed</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public void setForeground (Color color) {
- checkWidget ();
- int pixel = -1;
- if (color != null) {
- if (color.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
- pixel = color.handle;
- }
- setForegroundPixel (pixel);
-}
-
-void setForegroundPixel (int pixel) {
- if (foreground == pixel) return;
- foreground = pixel;
- OS.InvalidateRect (handle, null, 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 ();
- int flags = OS.SWP_NOSIZE | OS.SWP_NOZORDER | OS.SWP_NOACTIVATE;
- /*
- * Feature in WinCE. The SWP_DRAWFRAME flag for SetWindowPos()
- * causes a WM_SIZE message to be sent even when the SWP_NOSIZE
- * flag is specified. The fix is to set SWP_DRAWFRAME only when
- * not running on WinCE.
- */
- if (!OS.IsWinCE) flags |= OS.SWP_DRAWFRAME;
- setBounds (x, y, 0, 0, flags);
-}
-
-/**
- * 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>
- * <li>ERROR_INVALID_ARGUMENT - if the menu has been disposed</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public void setMenu (Menu menu) {
- checkWidget ();
- if (menu != null) {
- if (menu.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
- 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;
-}
-
-boolean setRadioSelection (boolean value) {
- return false;
-}
-
-/**
- * If the argument is <code>false</code>, causes subsequent drawing
- * operations in the receiver to be ignored. No drawing of any kind
- * can occur in the receiver until the flag is set to true.
- * Graphics operations that occurred while the flag was
- * <code>false</code> are lost. When the flag is set to <code>true</code>,
- * the entire widget is marked as needing to be redrawn.
- * <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);
- if (OS.IsWinCE) {
- OS.InvalidateRect (handle, null, true);
- } else {
- 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);
- }
- }
-}
-
-boolean setSavedFocus () {
- return forceFocus ();
-}
-
-/**
- * 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 ();
- int flags = OS.SWP_NOMOVE | OS.SWP_NOZORDER | OS.SWP_DRAWFRAME | OS.SWP_NOACTIVATE;
- setBounds (0, 0, Math.max (0, width), Math.max (0, height), flags);
-}
-
-/**
- * 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 () {
- if (!isShowing ()) return false;
- 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;
- }
-
- /*
- * Feature in Windows. If the receiver has focus, hiding
- * 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.
- */
- boolean fixFocus = false;
- if (!visible) fixFocus = isFocusAncestor ();
- OS.ShowWindow (handle, visible ? OS.SW_SHOW : OS.SW_HIDE);
- 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.Hide);
- if (isDisposed ()) return;
- }
- if (fixFocus) fixFocus ();
-}
-
-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 x the x coordinate to be translated
- * @param y the y coordinate to be translated
- * @return the translated coordinates
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @since 2.1
- */
-public Point toControl (int x, int y) {
- checkWidget ();
- POINT pt = new POINT ();
- pt.x = x; pt.y = 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 display relative coordinates,
- * to coordinates relative to the receiver.
- * <p>
- * @param point the point to be translated (must not be null)
- * @return the translated coordinates
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the point is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public Point toControl (Point point) {
- checkWidget ();
- if (point == null) error (SWT.ERROR_NULL_ARGUMENT);
- return toControl (point.x, point.y);
-}
-
-/**
- * Returns a point which is the result of converting the
- * argument, which is specified in coordinates relative to
- * the receiver, to display relative coordinates.
- * <p>
- * @param x the x coordinate to be translated
- * @param y the y coordinate to be translated
- * @return the translated coordinates
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @since 2.1
- */
-public Point toDisplay (int x, int y) {
- checkWidget ();
- POINT pt = new POINT ();
- pt.x = x; pt.y = y;
- OS.ClientToScreen (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)
- * @return the translated coordinates
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the point is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public Point toDisplay (Point point) {
- checkWidget ();
- if (point == null) error (SWT.ERROR_NULL_ARGUMENT);
- return toDisplay (point.x, point.y);
-}
-
-boolean translateAccelerator (MSG msg) {
- return menuShell ().translateAccelerator (msg);
-}
-
-boolean translateMnemonic (char key) {
- if (!isVisible () || !isEnabled ()) return false;
- Event event = new Event ();
- event.doit = mnemonicMatch (key);
- event.detail = SWT.TRAVERSE_MNEMONIC;
- Display display = getDisplay ();
- display.lastKey = 0;
- display.lastAscii = key;
- display.lastVirtual = display.lastNull = false;
- if (!setKeyState (event, SWT.Traverse)) {
- return false;
- }
- return traverse (event);
-}
-
-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 ()) {
- char ch = mbcsToWcs ((char) msg.wParam);
- return ch != 0 && shell.translateMnemonic (ch);
- }
- return false;
-}
-
-boolean translateTraversal (MSG msg) {
- int key = msg.wParam;
- if (key == OS.VK_MENU) {
- Shell shell = getShell ();
- int hwndShell = shell.handle;
- OS.SendMessage (hwndShell, OS.WM_CHANGEUISTATE, OS.UIS_INITIALIZE, 0);
- return false;
- }
- int hwnd = msg.hwnd;
- int detail = SWT.TRAVERSE_NONE;
- boolean doit = true, all = false;
- boolean lastVirtual = false;
- int lastKey = key, lastAscii = 0;
- switch (key) {
- case OS.VK_ESCAPE: {
- all = true;
- lastAscii = 27;
- int code = OS.SendMessage (hwnd, OS.WM_GETDLGCODE, 0, 0);
- if ((code & OS.DLGC_WANTALLKEYS) != 0) {
- /*
- * Use DLGC_HASSETSEL to determine that the control
- * is a text widget. A text widget normally wants
- * all keys except VK_ESCAPE. If this bit is not
- * set, then assume the control wants all keys,
- * including VK_ESCAPE.
- */
- if ((code & OS.DLGC_HASSETSEL) == 0) doit = false;
- }
- detail = SWT.TRAVERSE_ESCAPE;
- break;
- }
- case OS.VK_RETURN: {
- all = true;
- lastAscii = '\r';
- 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: {
- /*
- * NOTE: This code causes Shift+Tab and Ctrl+Tab to
- * always attempt traversal which is not correct.
- * The default should be the same as a plain Tab key.
- * This behavior is currently relied on by StyledText.
- *
- * The correct behavior is to give every key to a
- * control that answers DLGC_WANTALLKEYS.
- */
- 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 = next ? SWT.TRAVERSE_TAB_NEXT : SWT.TRAVERSE_TAB_PREVIOUS;
- break;
- }
- case OS.VK_UP:
- case OS.VK_LEFT:
- case OS.VK_DOWN:
- case OS.VK_RIGHT: {
- /*
- * On WinCE SP there is no tab key. Focus is assigned
- * using only the VK_UP and VK_DOWN keys, not with VK_LEFT
- * or VK_RIGHT. */
- if (OS.IsSP) {
- if (key == OS.VK_LEFT || key == OS.VK_RIGHT) return false;
- }
- lastVirtual = true;
- int code = OS.SendMessage (hwnd, OS.WM_GETDLGCODE, 0, 0);
- if ((code & (OS.DLGC_WANTARROWS /*| OS.DLGC_WANTALLKEYS*/)) != 0) doit = false;
- boolean next = key == OS.VK_DOWN || key == OS.VK_RIGHT;
- detail = next ? SWT.TRAVERSE_ARROW_NEXT : SWT.TRAVERSE_ARROW_PREVIOUS;
- break;
- }
- case OS.VK_PRIOR:
- case OS.VK_NEXT: {
- all = true;
- lastVirtual = true;
- if (OS.GetKeyState (OS.VK_CONTROL) >= 0) return false;
- /*
- * The fact that this code is commented causes Ctrl+PgUp
- * and Ctrl+PgDn to always attempt traversal which is not
- * correct. This behavior is relied on by StyledText.
- *
- * The correct behavior is to give every key to a control
- * that answers DLGC_WANTALLKEYS.
- */
-// int code = OS.SendMessage (hwnd, OS., 0, 0);
-// if ((code & OS.DLGC_WANTALLKEYS) != 0) doit = false;
- detail = key == OS.VK_PRIOR ? SWT.TRAVERSE_PAGE_PREVIOUS : SWT.TRAVERSE_PAGE_NEXT;
- break;
- }
- default:
- return false;
- }
- Event event = new Event ();
- event.doit = doit;
- event.detail = detail;
- Display display = getDisplay ();
- display.lastKey = lastKey;
- display.lastAscii = lastAscii;
- display.lastVirtual = lastVirtual;
- display.lastNull = false;
- if (!setKeyState (event, SWT.Traverse)) {
- return false;
- }
- Shell shell = getShell ();
- Control control = this;
- do {
- if (control.traverse (event)) {
- int hwndShell = shell.handle;
- OS.SendMessage (hwndShell, OS.WM_CHANGEUISTATE, OS.UIS_INITIALIZE, 0);
- return true;
- }
- if (!event.doit && control.hooks (SWT.Traverse)) {
- return false;
- }
- if (control == shell) return false;
- control = control.parent;
- } while (all && control != null);
- return false;
-}
-
-boolean traverse (Event event) {
- /*
- * It is possible (but unlikely), that application
- * code could have disposed the widget in the traverse
- * event. If this happens, return true to stop further
- * event processing.
- */
- sendEvent (SWT.Traverse, event);
- if (isDisposed ()) return false;
- if (!event.doit) return false;
- switch (event.detail) {
- case SWT.TRAVERSE_NONE: return true;
- case SWT.TRAVERSE_ESCAPE: return traverseEscape ();
- case SWT.TRAVERSE_RETURN: return traverseReturn ();
- case SWT.TRAVERSE_TAB_NEXT: return traverseGroup (true);
- case SWT.TRAVERSE_TAB_PREVIOUS: return traverseGroup (false);
- case SWT.TRAVERSE_ARROW_NEXT: return traverseItem (true);
- case SWT.TRAVERSE_ARROW_PREVIOUS: return traverseItem (false);
- case SWT.TRAVERSE_MNEMONIC: return traverseMnemonic (event.character);
- case SWT.TRAVERSE_PAGE_NEXT: return traversePage (true);
- case SWT.TRAVERSE_PAGE_PREVIOUS: return traversePage (false);
- }
- return false;
-}
-
-/**
- * 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;
- Event event = new Event ();
- event.doit = true;
- event.detail = traversal;
- return traverse (event);
-}
-
-boolean traverseEscape () {
- return false;
-}
-
-boolean traverseGroup (boolean next) {
- Control root = computeTabRoot ();
- Control group = computeTabGroup ();
- Control [] list = root.computeTabList ();
- int length = list.length;
- int index = 0;
- while (index < length) {
- if (list [index] == group) break;
- index++;
- }
- /*
- * It is possible (but unlikely), that application
- * code could have disposed the widget in focus in
- * or out events. Ensure that a disposed widget is
- * not accessed.
- */
- if (index == length) return false;
- int start = index, offset = (next) ? 1 : -1;
- while ((index = ((index + offset + length) % length)) != start) {
- Control control = list [index];
- if (!control.isDisposed () && control.setTabGroupFocus ()) {
- if (!isDisposed () && !isFocusControl ()) return true;
- }
- }
- if (group.isDisposed ()) return false;
- 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++;
- }
- /*
- * It is possible (but unlikely), that application
- * code could have disposed the widget in focus in
- * or out events. Ensure that a disposed widget is
- * not accessed.
- */
- int start = index, offset = (next) ? 1 : -1;
- while ((index = (index + offset + length) % length) != start) {
- Control child = children [index];
- if (!child.isDisposed () && child.isTabItem ()) {
- if (child.setTabItemFocus ()) return true;
- }
- }
- return false;
-}
-
-boolean traverseMnemonic (char key) {
- return mnemonicHit (key);
-}
-
-boolean traversePage (boolean next) {
- return false;
-}
-
-boolean traverseReturn () {
- return false;
-}
-
-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
- * 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 ();
- update (false);
-}
-
-void update (boolean all) {
-// checkWidget ();
- if (OS.IsWinCE) {
- OS.UpdateWindow (handle);
- } else {
- int flags = OS.RDW_UPDATENOW;
- if (all) flags |= OS.RDW_ALLCHILDREN;
- OS.RedrawWindow (handle, null, 0, flags);
- }
-}
-
-void updateFont (Font oldFont, Font newFont) {
- Font font = getFont ();
- if (font.equals (oldFont)) setFont (newFont);
-}
-
-int widgetExtStyle () {
- int bits = 0;
- if ((style & SWT.BORDER) != 0) bits |= OS.WS_EX_CLIENTEDGE;
- /*
- * Feature in Windows NT. When CreateWindowEx() is called with
- * WS_EX_LAYOUTRTL or WS_EX_NOINHERITLAYOUT, CreateWindowEx()
- * fails to create the HWND. The fix is to not use these bits.
- */
- if ((OS.WIN32_MAJOR << 16 | OS.WIN32_MINOR) < (4 << 16 | 10)) {
- return bits;
- }
- bits |= OS.WS_EX_NOINHERITLAYOUT;
- if ((style & SWT.RIGHT_TO_LEFT) != 0) bits |= OS.WS_EX_LAYOUTRTL;
- return bits;
-}
-
-int widgetStyle () {
- /* Force clipping of siblings by setting WS_CLIPSIBLINGS */
- return OS.WS_CHILD | OS.WS_VISIBLE | OS.WS_CLIPSIBLINGS;
-
- /*
- * This code is intentionally commented. When clipping
- * of both siblings and children is not enforced, it is
- * possible for application code to 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 IllegalArgumentException <ul>
- * <li>ERROR_INVALID_ARGUMENT - if the argument has been disposed</li>
- * </ul>
- * @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 (parent.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
- if (OS.SetParent (handle, parent.handle) == 0) {
- return false;
- }
- this.parent = parent;
- return true;
-}
-
-abstract TCHAR 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_ENDSESSION: result = WM_ENDSESSION (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_GETOBJECT: result = WM_GETOBJECT (wParam, lParam); break;
- case OS.WM_HOTKEY: result = WM_HOTKEY (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_MOUSEWHEEL: result = WM_MOUSEWHEEL (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_PRINTCLIENT: result = WM_PRINTCLIENT (wParam, lParam); break;
- case OS.WM_QUERYENDSESSION: result = WM_QUERYENDSESSION (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_SETTINGCHANGE: result = WM_SETTINGCHANGE (wParam, lParam); break;
- case OS.WM_SETREDRAW: result = WM_SETREDRAW (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 (!OS.IsUnicode && OS.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;
- display.lastNull = false;
- if (display.lastKey == 0) {
- display.lastKey = wParam;
- display.lastVirtual = display.isVirtualKey (wParam);
- } else {
- int result = OS.IsWinCE ? 0 : OS.VkKeyScan ((short) wParam);
- if (!OS.IsWinCE && (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 ()) {
- int id = wParam & 0xFFFF;
- MenuItem item = shell.findMenuItem (id);
- 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) {
- if (wParam != handle) return null;
-
- /*
- * Feature in Windows. When the user presses WM_NCRBUTTONUP,
- * a WM_CONTEXTMENU message is generated. This happens when
- * the user releases the mouse over a scroll bar. Normally,
- * window displays the default scrolling menu but applications
- * can process WM_CONTEXTMENU to display a different menu.
- * Typically, an application does not want to supply a special
- * scroll menu. The fix is to look for a WM_CONTEXTMENU that
- * originated from a mouse event and display the menu when the
- * mouse was released in the client area.
- */
- POINT pt = new POINT ();
- pt.x = (short) (lParam & 0xFFFF);
- pt.y = (short) (lParam >> 16);
- if (pt.x != -1 || pt.y != -1) {
- RECT rect = new RECT ();
- OS.GetClientRect (handle, rect);
- OS.ScreenToClient (handle, pt);
- if (!OS.PtInRect (rect, pt)) return null;
- }
-
- /*
- * Because context menus can be shared between controls
- * and the parent of all menus is the shell, the menu may
- * have been destroyed.
- */
- if (menu != null && !menu.isDisposed ()) {
-// menu.setLocation (x, y);
- menu.setVisible (true);
- return LRESULT.ZERO;
- }
- return null;
-}
-
-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_ENDSESSION (int wParam, int lParam) {
- return null;
-}
-
-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_GETOBJECT (int wParam, int lParam) {
- if (accessible != null) {
- int result = accessible.internal_WM_GETOBJECT (wParam, lParam);
- if (result != 0) return new LRESULT (result);
- }
- return null;
-}
-
-LRESULT WM_HOTKEY (int wParam, int lParam) {
- return null;
-}
-
-LRESULT WM_HELP (int wParam, int lParam) {
- if (OS.IsWinCE) return null;
- 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 = display.lastNull = 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) {
-
- /* Ignore repeating modifier keys by testing key down state */
- switch (wParam) {
- case OS.VK_SHIFT:
- case OS.VK_MENU:
- case OS.VK_CONTROL:
- case OS.VK_CAPITAL:
- case OS.VK_NUMLOCK:
- case OS.VK_SCROLL:
- if ((lParam & 0x40000000) != 0) return null;
- }
-
- /* Clear last key and last ascii because a new key has been typed */
- Display display = getDisplay ();
- display.lastAscii = display.lastKey = 0;
- display.lastVirtual = display.lastNull = false;
-
- /*
- * Do not report a lead byte as a key pressed.
- */
- if (!OS.IsUnicode && OS.IsDBLocale) {
- byte lead = (byte) (wParam & 0xFF);
- if (OS.IsDBCSLeadByte (lead)) return null;
- }
-
- /* Map the virtual key */
- /*
- * Bug on WinCE. MapVirtualKey() returns incorrect values.
- * The fix is to rely on a key mappings table to determine
- * whether the key event must be sent now or if a WM_CHAR
- * event will follow.
- */
- int mapKey = OS.IsWinCE ? 0 : 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.
- *
- * NOTE: This code is used to avoid a call to ToAscii ().
- */
- if (OS.IsWinNT) {
- if ((mapKey & 0x80000000) != 0) return null;
- } else {
- if ((mapKey & 0x8000) != 0) return null;
- }
-
- /*
- * Bug in Windows. When the accent key is generated on an international
- * keyboard using Ctrl+Alt or the special key, MapVirtualKey () does not
- * have the high bit set indicating that this is an accent key stroke.
- * The fix is to iterate through all known accent, mapping them back to
- * their corresponding virtual key and key state. If the virtual key
- * and key state match the current key, then this is an accent that has
- * been generated using an international keyboard and calling ToAscii ()
- * will clear the accent state.
- *
- * NOTE: This code is used to avoid a call to ToAscii ().
- */
- if (!OS.IsWinCE) {
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+import org.eclipse.swt.internal.win32.*;
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.*;
+import org.eclipse.swt.events.*;
+import org.eclipse.swt.accessibility.*;
+
+/**
+ * Control is the abstract superclass of all windowed user interface classes.
+ * <p>
+ * <dl>
+ * <dt><b>Styles:</b>
+ * <dd>BORDER</dd>
+ * <dd>LEFT_TO_RIGHT, RIGHT_TO_LEFT</dd>
+ * <dt><b>Events:</b>
+ * <dd>FocusIn, FocusOut, Help, KeyDown, KeyUp, MouseDoubleClick, MouseDown, MouseEnter,
+ * MouseExit, MouseHover, MouseUp, MouseMove, Move, Paint, Resize</dd>
+ * </dl>
+ * <p>
+ * Only one of LEFT_TO_RIGHT or RIGHT_TO_LEFT may be specified.
+ * </p><p>
+ * IMPORTANT: This class is intended to be subclassed <em>only</em>
+ * within the SWT implementation.
+ * </p>
+ *
+ * Note: Only one of LEFT_TO_RIGHT and RIGHT_TO_LEFT may be specified.
+ */
+
+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;
+ Accessible accessible;
+
+ static final short [] ACCENTS = new short [] {'~', '`', '\'', '^', '"'};
+
+/**
+ * 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
+ * lists the style constants that are applicable to the class.
+ * Style bits are also inherited from superclasses.
+ * </p>
+ *
+ * @param parent a composite control which will be the parent of the new instance (cannot be null)
+ * @param style the style of control to construct
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
+ * <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
+ * </ul>
+ *
+ * @see SWT#BORDER
+ * @see Widget#checkSubclass
+ * @see Widget#getStyle
+ */
+public Control (Composite parent, int style) {
+ super (parent, style);
+ this.parent = parent;
+ createWidget ();
+}
+
+/**
+ * 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 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);
+
+void checkOrientation (Widget parent) {
+ super.checkOrientation (parent);
+ if ((style & SWT.RIGHT_TO_LEFT) != 0) style |= SWT.MIRRORED;
+}
+
+/**
+ * Returns the preferred size of the receiver.
+ * <p>
+ * The <em>preferred size</em> of a control is the size that it would
+ * best be displayed at. The width hint and height hint arguments
+ * allow the caller to ask a control questions such as "Given a particular
+ * width, how high does the control need to be to show all of the contents?"
+ * To indicate that the caller does not wish to constrain a particular
+ * dimension, the constant <code>SWT.DEFAULT</code> is passed for the hint.
+ * </p>
+ *
+ * @param wHint the width hint (can be <code>SWT.DEFAULT</code>)
+ * @param hHint the height hint (can be <code>SWT.DEFAULT</code>)
+ * @return the preferred size of the control
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see Layout
+ * @see #getBorderWidth
+ * @see #getBounds
+ * @see #getSize
+ * @see #pack
+ * @see "computeTrim, getClientArea for controls that implement them"
+ */
+public Point computeSize (int wHint, int hHint) {
+ return computeSize (wHint, hHint, true);
+}
+
+/**
+ * Returns the preferred size of the receiver.
+ * <p>
+ * The <em>preferred size</em> of a control is the size that it would
+ * best be displayed at. The width hint and height hint arguments
+ * allow the caller to ask a control questions such as "Given a particular
+ * width, how high does the control need to be to show all of the contents?"
+ * To indicate that the caller does not wish to constrain a particular
+ * dimension, the constant <code>SWT.DEFAULT</code> is passed for the hint.
+ * </p><p>
+ * If the changed flag is <code>true</code>, it indicates that the receiver's
+ * <em>contents</em> have changed, therefore any caches that a layout manager
+ * containing the control may have been keeping need to be flushed. When the
+ * control is resized, the changed flag will be <code>false</code>, so layout
+ * manager caches can be retained.
+ * </p>
+ *
+ * @param wHint the width hint (can be <code>SWT.DEFAULT</code>)
+ * @param hHint the height hint (can be <code>SWT.DEFAULT</code>)
+ * @param changed <code>true</code> if the control's contents have changed, and <code>false</code> otherwise
+ * @return the preferred size of the control.
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see Layout
+ * @see #getBorderWidth
+ * @see #getBounds
+ * @see #getSize
+ * @see #pack
+ * @see "computeTrim, getClientArea for controls that implement them"
+ */
+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);
+}
+
+Control computeTabGroup () {
+ if (isTabGroup ()) return this;
+ return parent.computeTabGroup ();
+}
+
+Control computeTabRoot () {
+ Control [] tabList = parent._getTabList ();
+ if (tabList != null) {
+ int index = 0;
+ while (index < tabList.length) {
+ if (tabList [index] == this) break;
+ index++;
+ }
+ if (index == tabList.length) {
+ if (isTabGroup ()) return this;
+ }
+ }
+ return parent.computeTabRoot ();
+}
+
+Control [] computeTabList () {
+ if (isTabGroup ()) {
+ if (getVisible () && getEnabled ()) {
+ return new Control [] {this};
+ }
+ }
+ return new Control [0];
+}
+
+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);
+ int bits = OS.GetWindowLong (handle, OS.GWL_STYLE);
+ if ((bits & OS.WS_CHILD) != 0) {
+ OS.SetWindowLong (handle, OS.GWL_ID, handle);
+ }
+ if (OS.IsDBLocale && parent != null) {
+ int hIMC = OS.ImmGetContext (hwndParent);
+ OS.ImmAssociateContext (handle, hIMC);
+ OS.ImmReleaseContext (hwndParent, hIMC);
+ }
+}
+
+void createWidget () {
+ foreground = background = -1;
+ checkOrientation (parent);
+ createHandle ();
+ register ();
+ subclass ();
+ setDefaultFont ();
+}
+
+int defaultBackground () {
+ if (OS.IsWinCE) return OS.GetSysColor (OS.COLOR_WINDOW);
+ return OS.GetSysColor (OS.COLOR_BTNFACE);
+}
+
+int defaultFont () {
+ Display display = getDisplay ();
+ return display.systemFont ();
+}
+
+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);
+ }
+}
+
+void drawBackground (int hDC) {
+ RECT rect = new RECT ();
+ OS.GetClientRect (handle, rect);
+ drawBackground (hDC, rect);
+}
+
+void drawBackground (int hDC, RECT rect) {
+ Display display = getDisplay ();
+ int hPalette = display.hPalette;
+ if (hPalette != 0) {
+ OS.SelectPalette (hDC, hPalette, false);
+ OS.RealizePalette (hDC);
+ }
+ int pixel = getBackgroundPixel ();
+ int hBrush = findBrush (pixel);
+ OS.FillRect (hDC, rect, hBrush);
+}
+
+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';
+}
+
+void fixFocus () {
+ Shell shell = getShell ();
+ Control control = this;
+ while ((control = control.parent) != null) {
+ if (control.setFocus () || control == shell) return;
+ }
+ OS.SetFocus (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 ();
+ /*
+ * This code is intentionally commented.
+ *
+ * When setting focus to a control, it is
+ * possible that application code can set
+ * the focus to another control inside of
+ * WM_SETFOCUS. In this case, the original
+ * control will no longer have the focus
+ * and the call to setFocus() will return
+ * false indicating failure.
+ *
+ * We are still working on a solution at
+ * this time.
+ */
+// if (OS.GetFocus () != OS.SetFocus (handle)) return false;
+ OS.SetFocus (handle);
+ return isFocusControl ();
+}
+
+void forceResize () {
+ if (parent == null) return;
+ WINDOWPOS [] lpwp = parent.lpwp;
+ if (lpwp == null) return;
+ for (int i=0; i<lpwp.length; i++) {
+ WINDOWPOS wp = lpwp [i];
+ if (wp != null && wp.hwnd == handle) {
+ /*
+ * This code is intentionally commented. All widgets that
+ * are created by SWT have WS_CLIPSIBLINGS to ensure that
+ * application code does not draw outside of the control.
+ */
+// int count = parent.getChildrenCount ();
+// if (count > 1) {
+// int bits = OS.GetWindowLong (handle, OS.GWL_STYLE);
+// if ((bits & OS.WS_CLIPSIBLINGS) == 0) wp.flags |= OS.SWP_NOCOPYBITS;
+// }
+ OS.SetWindowPos (wp.hwnd, 0, wp.x, wp.y, wp.cx, wp.cy, wp.flags);
+ lpwp [i] = null;
+ return;
+ }
+ }
+}
+
+/**
+ * Returns the accessible object for the receiver.
+ * If this is the first time this object is requested,
+ * then the object is created and returned.
+ *
+ * @return the accessible object
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see Accessible#addAccessibleListener
+ * @see Accessible#addAccessibleControlListener
+ *
+ * @since 2.0
+ */
+public Accessible getAccessible () {
+ checkWidget ();
+ if (accessible == null) accessible = new_Accessible (this);
+ return accessible;
+}
+
+/**
+ * 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 ();
+ forceResize ();
+ RECT rect = new RECT ();
+ OS.GetWindowRect (handle, rect);
+ int hwndParent = parent == null ? 0 : parent.handle;
+ 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);
+}
+
+int getCodePage () {
+ int hFont = OS.SendMessage (handle, OS.WM_GETFONT, 0, 0);
+ LOGFONT logFont = new LOGFONT ();
+ OS.GetObject (hFont, LOGFONT.sizeof, logFont);
+ int cs = logFont.lfCharSet & 0xFF;
+ int [] lpCs = new int [8];
+ if (OS.TranslateCharsetInfo (cs, lpCs, OS.TCI_SRCCHARSET)) {
+ return lpCs [1];
+ }
+ return OS.GetACP ();
+}
+
+/**
+ * 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>
+ *
+ * @see #isEnabled
+ */
+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 ();
+ forceResize ();
+ RECT rect = new RECT ();
+ OS.GetWindowRect (handle, rect);
+ int hwndParent = parent == null ? 0 : parent.handle;
+ 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 ();
+ forceResize ();
+ 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 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 () {
+ /*
+ * If a non-SWT child of the control has focus,
+ * then this control is considered to have focus
+ * even though it does not have focus in Windows.
+ */
+ int hwndFocus = OS.GetFocus ();
+ while (hwndFocus != 0) {
+ if (hwndFocus == handle) return true;
+ if (WidgetTable.get (hwndFocus) != null) {
+ return false;
+ }
+ 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) {
+ checkWidget();
+ 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);
+ data.hwnd = handle;
+ }
+ 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) {
+ checkWidget ();
+ 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 all
+ * of the receiver's ancestors are enabled, and <code>false</code>
+ * otherwise. A disabled control is typically not selectable from the
+ * user interface and draws with an inactive or "grayed" look.
+ *
+ * @return the receiver's enabled state
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see #getEnabled
+ */
+public boolean isEnabled () {
+ checkWidget ();
+ return getEnabled () && parent.isEnabled ();
+}
+
+/**
+ * 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 ();
+}
+
+boolean isFocusAncestor () {
+ Display display = getDisplay ();
+ Control control = display.getFocusControl ();
+ while (control != null && control != this) {
+ control = control.parent;
+ }
+ return control == this;
+}
+
+/**
+ * Returns <code>true</code> if the underlying operating
+ * system supports this reparenting, otherwise <code>false</code>
+ *
+ * @return <code>true</code> if the widget can be reparented, otherwise <code>false</code>
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public boolean isReparentable () {
+ checkWidget ();
+ return true;
+}
+
+boolean isShowing () {
+ /*
+ * This is not complete. Need to check if the
+ * widget is obscurred by a parent or sibling.
+ */
+ if (!isVisible ()) return false;
+ Control control = this;
+ while (control != null) {
+ Point size = control.getSize ();
+ if (size.x == 0 || size.y == 0) {
+ return false;
+ }
+ control = control.parent;
+ }
+ return true;
+ /*
+ * Check to see if current damage is included.
+ */
+// if (!OS.IsWindowVisible (handle)) return false;
+// int flags = OS.DCX_CACHE | OS.DCX_CLIPCHILDREN | OS.DCX_CLIPSIBLINGS;
+// int hDC = OS.GetDCEx (handle, 0, flags);
+// int result = OS.GetClipBox (hDC, new RECT ());
+// OS.ReleaseDC (handle, hDC);
+// return result != OS.NULLREGION;
+}
+
+boolean isTabGroup () {
+ Control [] tabList = parent._getTabList ();
+ if (tabList != null) {
+ for (int i=0; i<tabList.length; i++) {
+ if (tabList [i] == this) return true;
+ }
+ }
+ int bits = OS.GetWindowLong (handle, OS.GWL_STYLE);
+ return (bits & OS.WS_TABSTOP) != 0;
+}
+
+boolean isTabItem () {
+ Control [] tabList = parent._getTabList ();
+ if (tabList != null) {
+ for (int i=0; i<tabList.length; i++) {
+ if (tabList [i] == this) return false;
+ }
+ }
+ int 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;
+}
+
+/**
+ * Returns <code>true</code> if the receiver is visible and all
+ * of the receiver's ancestors are visible and <code>false</code>
+ * otherwise.
+ *
+ * @return the receiver's visibility state
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see #getVisible
+ */
+public boolean isVisible () {
+ checkWidget ();
+ return OS.IsWindowVisible (handle);
+}
+
+Decorations menuShell () {
+ return parent.menuShell ();
+}
+
+boolean mnemonicHit (char key) {
+ 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 IllegalArgumentException <ul>
+ * <li>ERROR_INVALID_ARGUMENT - if the control has been disposed</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void moveAbove (Control control) {
+ checkWidget ();
+ int hwndAbove = OS.HWND_TOP;
+ if (control != null) {
+ if (control.isDisposed ()) error(SWT.ERROR_INVALID_ARGUMENT);
+ if (parent != control.parent) return;
+ int hwnd = control.handle;
+ if (hwnd == 0 || hwnd == handle) return;
+ hwndAbove = OS.GetWindow (hwnd, OS.GW_HWNDPREV);
+ /*
+ * Bug in Windows. For some reason, when GetWindow ()
+ * with GW_HWNDPREV is used to query the previous window
+ * in the z-order with the first child, Windows returns
+ * the first child instead of NULL. The fix is to detect
+ * this case and move the control to the top.
+ */
+ if (hwndAbove == 0 || hwndAbove == hwnd) {
+ hwndAbove = OS.HWND_TOP;
+ }
+ }
+ int flags = OS.SWP_NOSIZE | OS.SWP_NOMOVE | OS.SWP_NOACTIVATE;
+ OS.SetWindowPos (handle, hwndAbove, 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 IllegalArgumentException <ul>
+ * <li>ERROR_INVALID_ARGUMENT - if the control has been disposed</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void moveBelow (Control control) {
+ checkWidget ();
+ int hwndAbove = OS.HWND_BOTTOM;
+ if (control != null) {
+ if (control.isDisposed ()) error(SWT.ERROR_INVALID_ARGUMENT);
+ if (parent != control.parent) return;
+ hwndAbove = control.handle;
+ }
+ if (hwndAbove == 0 || hwndAbove == handle) return;
+ int flags = OS.SWP_NOSIZE | OS.SWP_NOMOVE | OS.SWP_NOACTIVATE;
+ OS.SetWindowPos (handle, hwndAbove, 0, 0, 0, 0, flags);
+}
+
+Accessible new_Accessible (Control control) {
+ return Accessible.internal_new_Accessible (this);
+}
+
+/**
+ * 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;
+ if (OS.IsWinCE) {
+ OS.InvalidateRect (handle, null, true);
+ } else {
+ 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 (width <= 0 || height <= 0) return;
+ if (!OS.IsWindowVisible (handle)) return;
+ RECT rect = new RECT ();
+ OS.SetRect (rect, x, y, x + width, y + height);
+ if (OS.IsWinCE) {
+ OS.InvalidateRect (handle, rect, true);
+ } else {
+ int flags = OS.RDW_ERASE | OS.RDW_FRAME | OS.RDW_INVALIDATE;
+ if (all) flags |= OS.RDW_ALLCHILDREN;
+ OS.RedrawWindow (handle, rect, 0, flags);
+ }
+}
+
+void register () {
+ WidgetTable.put (handle, this);
+}
+
+void releaseHandle () {
+ super.releaseHandle ();
+ handle = 0;
+}
+
+void releaseWidget () {
+ super.releaseWidget ();
+ if (OS.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;
+ if (accessible != null) {
+ accessible.internal_dispose_Accessible ();
+ }
+ accessible = 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);
+ setInputState (event, type);
+ 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 IllegalArgumentException <ul>
+ * <li>ERROR_INVALID_ARGUMENT - if the argument has been disposed</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setBackground (Color color) {
+ checkWidget ();
+ int pixel = -1;
+ if (color != null) {
+ if (color.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+ 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 ();
+ int flags = OS.SWP_NOZORDER | OS.SWP_DRAWFRAME | OS.SWP_NOACTIVATE;
+ setBounds (x, y, Math.max (0, width), Math.max (0, height), flags);
+}
+
+void setBounds (int x, int y, int width, int height, int flags) {
+ if (parent == null) {
+ OS.SetWindowPos (handle, 0, x, y, width, height, flags);
+ return;
+ }
+ if (parent.lpwp == null) {
+ /*
+ * This code is intentionally commented. All widgets that
+ * are created by SWT have WS_CLIPSIBLINGS to ensure that
+ * application code does not draw outside of the control.
+ */
+// int count = parent.getChildrenCount ();
+// 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;
+ }
+ forceResize ();
+ WINDOWPOS [] lpwp = parent.lpwp;
+ int index = 0;
+ while (index < lpwp.length) {
+ if (lpwp [index] == null) break;
+ index ++;
+ }
+ if (index == lpwp.length) {
+ WINDOWPOS [] newLpwp = new WINDOWPOS [lpwp.length + 4];
+ System.arraycopy (lpwp, 0, newLpwp, 0, lpwp.length);
+ parent.lpwp = lpwp = newLpwp;
+ }
+ WINDOWPOS wp = new WINDOWPOS ();
+ wp.hwnd = handle;
+ wp.x = x;
+ wp.y = y;
+ wp.cx = width;
+ wp.cy = height;
+ wp.flags = flags;
+ lpwp [index] = wp;
+}
+
+/**
+ * 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 IllegalArgumentException <ul>
+ * <li>ERROR_INVALID_ARGUMENT - if the argument has been disposed</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setCursor (Cursor cursor) {
+ checkWidget ();
+ hCursor = 0;
+ if (cursor != null) {
+ if (cursor.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+ hCursor = cursor.handle;
+ }
+ if (OS.IsWinCE) {
+ OS.SetCursor (hCursor);
+ return;
+ }
+ 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 () {
+ Display display = getDisplay ();
+ int hFont = display.systemFont ();
+ 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 ();
+
+ /*
+ * 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.
+ */
+ boolean fixFocus = false;
+ if (!enabled) fixFocus = isFocusAncestor ();
+ OS.EnableWindow (handle, enabled);
+ if (fixFocus) fixFocus ();
+}
+
+/**
+ * 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 IllegalArgumentException <ul>
+ * <li>ERROR_INVALID_ARGUMENT - if the argument has been disposed</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setFont (Font font) {
+ checkWidget ();
+ int hFont = 0;
+ if (font != null) {
+ if (font.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+ 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 IllegalArgumentException <ul>
+ * <li>ERROR_INVALID_ARGUMENT - if the argument has been disposed</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setForeground (Color color) {
+ checkWidget ();
+ int pixel = -1;
+ if (color != null) {
+ if (color.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+ pixel = color.handle;
+ }
+ setForegroundPixel (pixel);
+}
+
+void setForegroundPixel (int pixel) {
+ if (foreground == pixel) return;
+ foreground = pixel;
+ OS.InvalidateRect (handle, null, 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 ();
+ int flags = OS.SWP_NOSIZE | OS.SWP_NOZORDER | OS.SWP_NOACTIVATE;
+ /*
+ * Feature in WinCE. The SWP_DRAWFRAME flag for SetWindowPos()
+ * causes a WM_SIZE message to be sent even when the SWP_NOSIZE
+ * flag is specified. The fix is to set SWP_DRAWFRAME only when
+ * not running on WinCE.
+ */
+ if (!OS.IsWinCE) flags |= OS.SWP_DRAWFRAME;
+ setBounds (x, y, 0, 0, flags);
+}
+
+/**
+ * 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>
+ * <li>ERROR_INVALID_ARGUMENT - if the menu has been disposed</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setMenu (Menu menu) {
+ checkWidget ();
+ if (menu != null) {
+ if (menu.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+ 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;
+}
+
+boolean setRadioSelection (boolean value) {
+ return false;
+}
+
+/**
+ * If the argument is <code>false</code>, causes subsequent drawing
+ * operations in the receiver to be ignored. No drawing of any kind
+ * can occur in the receiver until the flag is set to true.
+ * Graphics operations that occurred while the flag was
+ * <code>false</code> are lost. When the flag is set to <code>true</code>,
+ * the entire widget is marked as needing to be redrawn.
+ * <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);
+ if (OS.IsWinCE) {
+ OS.InvalidateRect (handle, null, true);
+ } else {
+ 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);
+ }
+ }
+}
+
+boolean setSavedFocus () {
+ return forceFocus ();
+}
+
+/**
+ * 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 ();
+ int flags = OS.SWP_NOMOVE | OS.SWP_NOZORDER | OS.SWP_DRAWFRAME | OS.SWP_NOACTIVATE;
+ setBounds (0, 0, Math.max (0, width), Math.max (0, height), flags);
+}
+
+/**
+ * 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 () {
+ if (!isShowing ()) return false;
+ 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;
+ }
+
+ /*
+ * Feature in Windows. If the receiver has focus, hiding
+ * 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.
+ */
+ boolean fixFocus = false;
+ if (!visible) fixFocus = isFocusAncestor ();
+ OS.ShowWindow (handle, visible ? OS.SW_SHOW : OS.SW_HIDE);
+ 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.Hide);
+ if (isDisposed ()) return;
+ }
+ if (fixFocus) fixFocus ();
+}
+
+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 x the x coordinate to be translated
+ * @param y the y coordinate to be translated
+ * @return the translated coordinates
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @since 2.1
+ */
+public Point toControl (int x, int y) {
+ checkWidget ();
+ POINT pt = new POINT ();
+ pt.x = x; pt.y = 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 display relative coordinates,
+ * to coordinates relative to the receiver.
+ * <p>
+ * @param point the point to be translated (must not be null)
+ * @return the translated coordinates
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if the point is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public Point toControl (Point point) {
+ checkWidget ();
+ if (point == null) error (SWT.ERROR_NULL_ARGUMENT);
+ return toControl (point.x, point.y);
+}
+
+/**
+ * Returns a point which is the result of converting the
+ * argument, which is specified in coordinates relative to
+ * the receiver, to display relative coordinates.
+ * <p>
+ * @param x the x coordinate to be translated
+ * @param y the y coordinate to be translated
+ * @return the translated coordinates
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @since 2.1
+ */
+public Point toDisplay (int x, int y) {
+ checkWidget ();
+ POINT pt = new POINT ();
+ pt.x = x; pt.y = y;
+ OS.ClientToScreen (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)
+ * @return the translated coordinates
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if the point is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public Point toDisplay (Point point) {
+ checkWidget ();
+ if (point == null) error (SWT.ERROR_NULL_ARGUMENT);
+ return toDisplay (point.x, point.y);
+}
+
+boolean translateAccelerator (MSG msg) {
+ return menuShell ().translateAccelerator (msg);
+}
+
+boolean translateMnemonic (char key) {
+ if (!isVisible () || !isEnabled ()) return false;
+ Event event = new Event ();
+ event.doit = mnemonicMatch (key);
+ event.detail = SWT.TRAVERSE_MNEMONIC;
+ Display display = getDisplay ();
+ display.lastKey = 0;
+ display.lastAscii = key;
+ display.lastVirtual = display.lastNull = false;
+ if (!setKeyState (event, SWT.Traverse)) {
+ return false;
+ }
+ return traverse (event);
+}
+
+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 ()) {
+ char ch = mbcsToWcs ((char) msg.wParam);
+ return ch != 0 && shell.translateMnemonic (ch);
+ }
+ return false;
+}
+
+boolean translateTraversal (MSG msg) {
+ int key = msg.wParam;
+ if (key == OS.VK_MENU) {
+ Shell shell = getShell ();
+ int hwndShell = shell.handle;
+ OS.SendMessage (hwndShell, OS.WM_CHANGEUISTATE, OS.UIS_INITIALIZE, 0);
+ return false;
+ }
+ int hwnd = msg.hwnd;
+ int detail = SWT.TRAVERSE_NONE;
+ boolean doit = true, all = false;
+ boolean lastVirtual = false;
+ int lastKey = key, lastAscii = 0;
+ switch (key) {
+ case OS.VK_ESCAPE: {
+ all = true;
+ lastAscii = 27;
+ int code = OS.SendMessage (hwnd, OS.WM_GETDLGCODE, 0, 0);
+ if ((code & OS.DLGC_WANTALLKEYS) != 0) {
+ /*
+ * Use DLGC_HASSETSEL to determine that the control
+ * is a text widget. A text widget normally wants
+ * all keys except VK_ESCAPE. If this bit is not
+ * set, then assume the control wants all keys,
+ * including VK_ESCAPE.
+ */
+ if ((code & OS.DLGC_HASSETSEL) == 0) doit = false;
+ }
+ detail = SWT.TRAVERSE_ESCAPE;
+ break;
+ }
+ case OS.VK_RETURN: {
+ all = true;
+ lastAscii = '\r';
+ 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: {
+ /*
+ * NOTE: This code causes Shift+Tab and Ctrl+Tab to
+ * always attempt traversal which is not correct.
+ * The default should be the same as a plain Tab key.
+ * This behavior is currently relied on by StyledText.
+ *
+ * The correct behavior is to give every key to a
+ * control that answers DLGC_WANTALLKEYS.
+ */
+ 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 = next ? SWT.TRAVERSE_TAB_NEXT : SWT.TRAVERSE_TAB_PREVIOUS;
+ break;
+ }
+ case OS.VK_UP:
+ case OS.VK_LEFT:
+ case OS.VK_DOWN:
+ case OS.VK_RIGHT: {
+ /*
+ * On WinCE SP there is no tab key. Focus is assigned
+ * using only the VK_UP and VK_DOWN keys, not with VK_LEFT
+ * or VK_RIGHT. */
+ if (OS.IsSP) {
+ if (key == OS.VK_LEFT || key == OS.VK_RIGHT) return false;
+ }
+ lastVirtual = true;
+ int code = OS.SendMessage (hwnd, OS.WM_GETDLGCODE, 0, 0);
+ if ((code & (OS.DLGC_WANTARROWS /*| OS.DLGC_WANTALLKEYS*/)) != 0) doit = false;
+ boolean next = key == OS.VK_DOWN || key == OS.VK_RIGHT;
+ detail = next ? SWT.TRAVERSE_ARROW_NEXT : SWT.TRAVERSE_ARROW_PREVIOUS;
+ break;
+ }
+ case OS.VK_PRIOR:
+ case OS.VK_NEXT: {
+ all = true;
+ lastVirtual = true;
+ if (OS.GetKeyState (OS.VK_CONTROL) >= 0) return false;
+ /*
+ * The fact that this code is commented causes Ctrl+PgUp
+ * and Ctrl+PgDn to always attempt traversal which is not
+ * correct. This behavior is relied on by StyledText.
+ *
+ * The correct behavior is to give every key to a control
+ * that answers DLGC_WANTALLKEYS.
+ */
+// int code = OS.SendMessage (hwnd, OS., 0, 0);
+// if ((code & OS.DLGC_WANTALLKEYS) != 0) doit = false;
+ detail = key == OS.VK_PRIOR ? SWT.TRAVERSE_PAGE_PREVIOUS : SWT.TRAVERSE_PAGE_NEXT;
+ break;
+ }
+ default:
+ return false;
+ }
+ Event event = new Event ();
+ event.doit = doit;
+ event.detail = detail;
+ Display display = getDisplay ();
+ display.lastKey = lastKey;
+ display.lastAscii = lastAscii;
+ display.lastVirtual = lastVirtual;
+ display.lastNull = false;
+ if (!setKeyState (event, SWT.Traverse)) {
+ return false;
+ }
+ Shell shell = getShell ();
+ Control control = this;
+ do {
+ if (control.traverse (event)) {
+ int hwndShell = shell.handle;
+ OS.SendMessage (hwndShell, OS.WM_CHANGEUISTATE, OS.UIS_INITIALIZE, 0);
+ return true;
+ }
+ if (!event.doit && control.hooks (SWT.Traverse)) {
+ return false;
+ }
+ if (control == shell) return false;
+ control = control.parent;
+ } while (all && control != null);
+ return false;
+}
+
+boolean traverse (Event event) {
+ /*
+ * It is possible (but unlikely), that application
+ * code could have disposed the widget in the traverse
+ * event. If this happens, return true to stop further
+ * event processing.
+ */
+ sendEvent (SWT.Traverse, event);
+ if (isDisposed ()) return false;
+ if (!event.doit) return false;
+ switch (event.detail) {
+ case SWT.TRAVERSE_NONE: return true;
+ case SWT.TRAVERSE_ESCAPE: return traverseEscape ();
+ case SWT.TRAVERSE_RETURN: return traverseReturn ();
+ case SWT.TRAVERSE_TAB_NEXT: return traverseGroup (true);
+ case SWT.TRAVERSE_TAB_PREVIOUS: return traverseGroup (false);
+ case SWT.TRAVERSE_ARROW_NEXT: return traverseItem (true);
+ case SWT.TRAVERSE_ARROW_PREVIOUS: return traverseItem (false);
+ case SWT.TRAVERSE_MNEMONIC: return traverseMnemonic (event.character);
+ case SWT.TRAVERSE_PAGE_NEXT: return traversePage (true);
+ case SWT.TRAVERSE_PAGE_PREVIOUS: return traversePage (false);
+ }
+ return false;
+}
+
+/**
+ * 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;
+ Event event = new Event ();
+ event.doit = true;
+ event.detail = traversal;
+ return traverse (event);
+}
+
+boolean traverseEscape () {
+ return false;
+}
+
+boolean traverseGroup (boolean next) {
+ Control root = computeTabRoot ();
+ Control group = computeTabGroup ();
+ Control [] list = root.computeTabList ();
+ int length = list.length;
+ int index = 0;
+ while (index < length) {
+ if (list [index] == group) break;
+ index++;
+ }
+ /*
+ * It is possible (but unlikely), that application
+ * code could have disposed the widget in focus in
+ * or out events. Ensure that a disposed widget is
+ * not accessed.
+ */
+ if (index == length) return false;
+ int start = index, offset = (next) ? 1 : -1;
+ while ((index = ((index + offset + length) % length)) != start) {
+ Control control = list [index];
+ if (!control.isDisposed () && control.setTabGroupFocus ()) {
+ if (!isDisposed () && !isFocusControl ()) return true;
+ }
+ }
+ if (group.isDisposed ()) return false;
+ 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++;
+ }
+ /*
+ * It is possible (but unlikely), that application
+ * code could have disposed the widget in focus in
+ * or out events. Ensure that a disposed widget is
+ * not accessed.
+ */
+ int start = index, offset = (next) ? 1 : -1;
+ while ((index = (index + offset + length) % length) != start) {
+ Control child = children [index];
+ if (!child.isDisposed () && child.isTabItem ()) {
+ if (child.setTabItemFocus ()) return true;
+ }
+ }
+ return false;
+}
+
+boolean traverseMnemonic (char key) {
+ return mnemonicHit (key);
+}
+
+boolean traversePage (boolean next) {
+ return false;
+}
+
+boolean traverseReturn () {
+ return false;
+}
+
+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
+ * 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 ();
+ update (false);
+}
+
+void update (boolean all) {
+// checkWidget ();
+ if (OS.IsWinCE) {
+ OS.UpdateWindow (handle);
+ } else {
+ int flags = OS.RDW_UPDATENOW;
+ if (all) flags |= OS.RDW_ALLCHILDREN;
+ OS.RedrawWindow (handle, null, 0, flags);
+ }
+}
+
+void updateFont (Font oldFont, Font newFont) {
+ Font font = getFont ();
+ if (font.equals (oldFont)) setFont (newFont);
+}
+
+int widgetExtStyle () {
+ int bits = 0;
+ if ((style & SWT.BORDER) != 0) bits |= OS.WS_EX_CLIENTEDGE;
+ /*
+ * Feature in Windows NT. When CreateWindowEx() is called with
+ * WS_EX_LAYOUTRTL or WS_EX_NOINHERITLAYOUT, CreateWindowEx()
+ * fails to create the HWND. The fix is to not use these bits.
+ */
+ if ((OS.WIN32_MAJOR << 16 | OS.WIN32_MINOR) < (4 << 16 | 10)) {
+ return bits;
+ }
+ bits |= OS.WS_EX_NOINHERITLAYOUT;
+ if ((style & SWT.RIGHT_TO_LEFT) != 0) bits |= OS.WS_EX_LAYOUTRTL;
+ return bits;
+}
+
+int widgetStyle () {
+ /* Force clipping of siblings by setting WS_CLIPSIBLINGS */
+ return OS.WS_CHILD | OS.WS_VISIBLE | OS.WS_CLIPSIBLINGS;
+
+ /*
+ * This code is intentionally commented. When clipping
+ * of both siblings and children is not enforced, it is
+ * possible for application code to 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 IllegalArgumentException <ul>
+ * <li>ERROR_INVALID_ARGUMENT - if the argument has been disposed</li>
+ * </ul>
+ * @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 (parent.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+ if (OS.SetParent (handle, parent.handle) == 0) {
+ return false;
+ }
+ this.parent = parent;
+ return true;
+}
+
+abstract TCHAR 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_ENDSESSION: result = WM_ENDSESSION (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_GETOBJECT: result = WM_GETOBJECT (wParam, lParam); break;
+ case OS.WM_HOTKEY: result = WM_HOTKEY (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_MOUSEWHEEL: result = WM_MOUSEWHEEL (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_PRINTCLIENT: result = WM_PRINTCLIENT (wParam, lParam); break;
+ case OS.WM_QUERYENDSESSION: result = WM_QUERYENDSESSION (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_SETTINGCHANGE: result = WM_SETTINGCHANGE (wParam, lParam); break;
+ case OS.WM_SETREDRAW: result = WM_SETREDRAW (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 (!OS.IsUnicode && OS.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;
+ display.lastNull = false;
+ if (display.lastKey == 0) {
+ display.lastKey = wParam;
+ display.lastVirtual = display.isVirtualKey (wParam);
+ } else {
+ int result = OS.IsWinCE ? 0 : OS.VkKeyScan ((short) wParam);
+ if (!OS.IsWinCE && (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 ()) {
+ int id = wParam & 0xFFFF;
+ MenuItem item = shell.findMenuItem (id);
+ 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) {
+ if (wParam != handle) return null;
+
+ /*
+ * Feature in Windows. When the user presses WM_NCRBUTTONUP,
+ * a WM_CONTEXTMENU message is generated. This happens when
+ * the user releases the mouse over a scroll bar. Normally,
+ * window displays the default scrolling menu but applications
+ * can process WM_CONTEXTMENU to display a different menu.
+ * Typically, an application does not want to supply a special
+ * scroll menu. The fix is to look for a WM_CONTEXTMENU that
+ * originated from a mouse event and display the menu when the
+ * mouse was released in the client area.
+ */
+ POINT pt = new POINT ();
+ pt.x = (short) (lParam & 0xFFFF);
+ pt.y = (short) (lParam >> 16);
+ if (pt.x != -1 || pt.y != -1) {
+ RECT rect = new RECT ();
+ OS.GetClientRect (handle, rect);
+ OS.ScreenToClient (handle, pt);
+ if (!OS.PtInRect (rect, pt)) return null;
+ }
+
+ /*
+ * Because context menus can be shared between controls
+ * and the parent of all menus is the shell, the menu may
+ * have been destroyed.
+ */
+ if (menu != null && !menu.isDisposed ()) {
+// menu.setLocation (x, y);
+ menu.setVisible (true);
+ return LRESULT.ZERO;
+ }
+ return null;
+}
+
+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_ENDSESSION (int wParam, int lParam) {
+ return null;
+}
+
+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_GETOBJECT (int wParam, int lParam) {
+ if (accessible != null) {
+ int result = accessible.internal_WM_GETOBJECT (wParam, lParam);
+ if (result != 0) return new LRESULT (result);
+ }
+ return null;
+}
+
+LRESULT WM_HOTKEY (int wParam, int lParam) {
+ return null;
+}
+
+LRESULT WM_HELP (int wParam, int lParam) {
+ if (OS.IsWinCE) return null;
+ 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 = display.lastNull = 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) {
+
+ /* Ignore repeating modifier keys by testing key down state */
+ switch (wParam) {
+ case OS.VK_SHIFT:
+ case OS.VK_MENU:
+ case OS.VK_CONTROL:
+ case OS.VK_CAPITAL:
+ case OS.VK_NUMLOCK:
+ case OS.VK_SCROLL:
+ if ((lParam & 0x40000000) != 0) return null;
+ }
+
+ /* Clear last key and last ascii because a new key has been typed */
+ Display display = getDisplay ();
+ display.lastAscii = display.lastKey = 0;
+ display.lastVirtual = display.lastNull = false;
+
+ /*
+ * Do not report a lead byte as a key pressed.
+ */
+ if (!OS.IsUnicode && OS.IsDBLocale) {
+ byte lead = (byte) (wParam & 0xFF);
+ if (OS.IsDBCSLeadByte (lead)) return null;
+ }
+
+ /* Map the virtual key */
+ /*
+ * Bug on WinCE. MapVirtualKey() returns incorrect values.
+ * The fix is to rely on a key mappings table to determine
+ * whether the key event must be sent now or if a WM_CHAR
+ * event will follow.
+ */
+ int mapKey = OS.IsWinCE ? 0 : 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.
+ *
+ * NOTE: This code is used to avoid a call to ToAscii ().
+ */
+ if (OS.IsWinNT) {
+ if ((mapKey & 0x80000000) != 0) return null;
+ } else {
+ if ((mapKey & 0x8000) != 0) return null;
+ }
+
+ /*
+ * Bug in Windows. When the accent key is generated on an international
+ * keyboard using Ctrl+Alt or the special key, MapVirtualKey () does not
+ * have the high bit set indicating that this is an accent key stroke.
+ * The fix is to iterate through all known accent, mapping them back to
+ * their corresponding virtual key and key state. If the virtual key
+ * and key state match the current key, then this is an accent that has
+ * been generated using an international keyboard and calling ToAscii ()
+ * will clear the accent state.
+ *
+ * NOTE: This code is used to avoid a call to ToAscii ().
+ */
+ if (!OS.IsWinCE) {
for (int i=0; i<ACCENTS.length; i++) {
- int value = OS.VkKeyScan (ACCENTS [i]);
- if ((value & 0xFF) == wParam && (value & 0x600) == 0x600) {
- return null;
- }
- }
- }
-
- /*
- * If we 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.lastKey = wParam;
- 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 0x7F).
- */
- if (display.lastKey == OS.VK_DELETE) display.lastAscii = 0x7F;
- /*
- * 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;
- display.lastAscii = display.numpadKey (display.lastKey);
- }
- } 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 asciiKey = display.asciiKey (wParam);
- if (asciiKey != 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 SWT.KeyDown, look for VK_SPACE and
- * issue the event from WM_CHAR.
- */
- if (asciiKey == OS.VK_SPACE) {
- display.lastVirtual = true;
- return null;
- }
- if (asciiKey != 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 (wParam);
- display.lastAscii = display.controlKey (display.lastKey);
- display.lastNull = display.lastAscii == 0 && display.lastKey == '@';
- }
- if (!sendKeyEvent (SWT.KeyDown, OS.WM_KEYDOWN, wParam, lParam)) {
- return LRESULT.ZERO;
- }
- return null;
-}
-
-LRESULT WM_KEYUP (int wParam, int lParam) {
- Display display = getDisplay ();
-
- /* Check for hardware keys */
- if (OS.IsWinCE) {
- if (OS.VK_APP1 <= wParam && wParam <= OS.VK_APP6) {
- display.lastKey = display.lastAscii = 0;
- display.lastVirtual = display.lastNull = false;
- Event event = new Event ();
- event.detail = wParam - OS.VK_APP1 + 1;
- /* Check the bit 30 to get the key state */
- int type = (lParam & 0x40000000) != 0 ? SWT.HardKeyUp : SWT.HardKeyDown;
- if (setInputState (event, type)) sendEvent (type, event);
- return null;
- }
- }
-
- /*
- * If the key up is not hooked, reset last key
- * and last ascii in case the key down is hooked.
- */
- if (!hooks (SWT.KeyUp) && !display.filters (SWT.KeyUp)) {
- display.lastKey = display.lastAscii = 0;
- display.lastVirtual = display.lastNull = false;
- return null;
- }
-
- /* Map the virtual key. */
- /*
- * Bug on WinCE. MapVirtualKey() returns incorrect values.
- * The fix is to rely on a key mappings table to determine
- * whether the key event must be sent now or if a WM_CHAR
- * event will follow.
- */
- int mapKey = OS.IsWinCE ? 0 : 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.
- *
- * NOTE: This code is used to avoid a call to ToAscii ().
- *
- */
- if (OS.IsWinNT) {
- if ((mapKey & 0x80000000) != 0) return null;
- } else {
- if ((mapKey & 0x8000) != 0) return null;
- }
-
- /*
- * Bug in Windows. When the accent key is generated on an international
- * keyboard using Ctrl+Alt or the special key, MapVirtualKey () does not
- * have the high bit set indicating that this is an accent key stroke.
- * The fix is to iterate through all known accent, mapping them back to
- * their corresponding virtual key and key state. If the virtual key
- * and key state match the current key, then this is an accent that has
- * been generated using an international keyboard.
- *
- * NOTE: This code is used to avoid a call to ToAscii ().
- */
- if (!OS.IsWinCE) {
- for (int i=0; i<ACCENTS.length; i++) {
- int value = OS.VkKeyScan (ACCENTS [i]);
- if ((value & 0xFF) == wParam && (value & 0x600) == 0x600) {
- display.lastKey = display.lastAscii = 0;
- display.lastVirtual = display.lastNull = false;
- return null;
- }
- }
- }
-
- display.lastVirtual = (mapKey == 0);
- if (display.lastVirtual) {
- display.lastKey = wParam;
- } else {
- if (display.lastKey == 0) {
- display.lastAscii = 0;
- display.lastNull = false;
- return null;
- }
- display.lastVirtual = display.isVirtualKey (display.lastKey);
- }
-
- LRESULT result = null;
- if (!sendKeyEvent (SWT.KeyUp, OS.WM_KEYUP, wParam, lParam)) {
- result = LRESULT.ZERO;
- }
- display.lastKey = display.lastAscii = 0;
- display.lastVirtual = display.lastNull = false;
- return result;
-}
-
-LRESULT WM_KILLFOCUS (int wParam, int lParam) {
- int code = callWindowProc (OS.WM_KILLFOCUS, wParam, lParam);
- Display display = getDisplay ();
- Shell shell = getShell ();
-
- /*
- * 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 that the shell may be
- * disposed at this point. If this happens
- * don't send the activate and deactivate
- * events.
- */
- if (!shell.isDisposed ()) {
- Control control = display.findControl (wParam);
- if (control == null || shell != control.getShell ()) {
- shell.setActiveControl (null);
- }
- }
-
- /*
- * 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;
- if (code == 0) return LRESULT.ZERO;
- return new LRESULT (code);
-}
-
-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) {
- boolean dragging = false, mouseDown = true;
- boolean dragDetect = hooks (SWT.DragDetect);
- if (dragDetect) {
- if (!OS.IsWinCE) {
- /*
- * Feature in Windows. It's possible that the drag
- * operation will not be started while the mouse is
- * down, meaning that the mouse should be captured.
- * This can happen when the user types the ESC key
- * to cancel the drag. The fix is to query the state
- * of the mouse and capture the mouse accordingly.
- */
- POINT pt = new POINT ();
- pt.x = (short) (lParam & 0xFFFF);
- pt.y = (short) (lParam >> 16);
- OS.ClientToScreen(handle, pt);
- dragging = OS.DragDetect (handle, pt);
- mouseDown = OS.GetKeyState (OS.VK_LBUTTON) < 0;
- }
- }
- sendMouseEvent (SWT.MouseDown, 1, OS.WM_LBUTTONDOWN, wParam, lParam);
- int result = callWindowProc (OS.WM_LBUTTONDOWN, wParam, lParam);
- if (OS.IsPPC) {
- if (menu != null && !menu.isDisposed ()) {
- int x = (short) (lParam & 0xFFFF);
- int y = (short) (lParam >> 16);
- SHRGINFO shrg = new SHRGINFO ();
- shrg.cbSize = SHRGINFO.sizeof;
- shrg.hwndClient = handle;
- shrg.ptDown_x = x;
- shrg.ptDown_y = y;
- shrg.dwFlags = OS.SHRG_RETURNCMD;
- int type = OS.SHRecognizeGesture (shrg);
- if (type == OS.GN_CONTEXTMENU) {
- menu.setVisible (true);
- }
- }
- }
- if (mouseDown) {
- if (OS.GetCapture () != handle) OS.SetCapture (handle);
- }
- if (dragging) {
- postEvent (SWT.DragDetect);
- } else {
- if (dragDetect) {
- /*
- * Feature in Windows. DragDetect() captures the mouse
- * and tracks its movement until the user releases the
- * left mouse button, presses the ESC key, or moves the
- * mouse outside the drag rectangle. If the user moves
- * the mouse outside of the drag rectangle, DragDetect()
- * returns true and a drag and drop operation can be
- * started. When the left mouse button is released or
- * the ESC key is pressed, these events are consumed by
- * DragDetect() so that application code that matches
- * mouse down/up pairs or looks for the ESC key will not
- * function properly. The fix is to send these events
- * when the drag has not started.
- *
- * NOTE: For now, don't send a fake WM_KEYDOWN/WM_KEYUP
- * events for the ESC key. This would require computing
- * wParam (the key) and lParam (the repeat count, scan code,
- * extended-key flag, context code, previous key-state flag,
- * and transition-state flag) which is non-trivial.
- */
- if (OS.GetKeyState (OS.VK_ESCAPE) >= 0) {
- OS.SendMessage (handle, OS.WM_LBUTTONUP, wParam, lParam);
- }
- }
- }
- 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) {
- /*
- * 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) {
- Display display = getDisplay ();
- display.mnemonicKeyHit = false;
- 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) {
- Display display = getDisplay ();
- display.mnemonicKeyHit = true;
- 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) {
- sendMouseEvent (SWT.MouseHover, 0, OS.WM_MOUSEHOVER, wParam, lParam);
- return null;
-}
-
-LRESULT WM_MOUSELEAVE (int wParam, int lParam) {
- int pos = OS.GetMessagePos ();
- POINT pt = new POINT ();
- pt.x = (short) (pos & 0xFFFF);
- pt.y = (short) (pos >> 16);
- OS.ScreenToClient (handle, pt);
- lParam = pt.x | (pt.y << 16);
- sendMouseEvent (SWT.MouseExit, 0, OS.WM_MOUSELEAVE, wParam, lParam);
- return null;
-}
-
-LRESULT WM_MOUSEMOVE (int wParam, int lParam) {
- if (!OS.IsWinCE) {
- Display display = getDisplay ();
- boolean mouseEnter = hooks (SWT.MouseEnter) || display.filters (SWT.MouseEnter);
- boolean mouseExit = hooks (SWT.MouseExit) || display.filters (SWT.MouseExit);
- boolean mouseHover = hooks (SWT.MouseHover) || display.filters (SWT.MouseHover);
- if (mouseEnter || mouseExit || 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 (mouseEnter) {
- sendMouseEvent (SWT.MouseEnter, 0, OS.WM_MOUSEMOVE, wParam, lParam);
- }
- } 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_MOUSEWHEEL (int wParam, int 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 (!OS.IsWindowEnabled (handle)) return null;
- 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) && !filters (SWT.Paint)) {
- return null;
- }
-
- /* Get the damage */
- int result = 0;
- if (OS.IsWinCE) {
- RECT rect = new RECT ();
- OS.GetUpdateRect (handle, rect, false);
- result = callWindowProc (OS.WM_PAINT, wParam, lParam);
- OS.InvalidateRect (handle, rect, false);
- } else {
- int rgn = OS.CreateRectRgn (0, 0, 0, 0);
- OS.GetUpdateRgn (handle, rgn, false);
- 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_PRINTCLIENT (int wParam, int lParam) {
- return null;
-}
-
-LRESULT WM_QUERYENDSESSION (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) {
- int code = callWindowProc (OS.WM_SETFOCUS, wParam, lParam);
- Shell shell = getShell ();
-
- /*
- * 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 that the shell may be
- * disposed at this point. If this happens
- * don't send the activate and deactivate
- * events.
- */
- if (!shell.isDisposed ()) {
- shell.setActiveControl (this);
- }
-
- /*
- * 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;
- if (code == 0) return LRESULT.ZERO;
- return new LRESULT (code);
-}
-
-LRESULT WM_SETTINGCHANGE (int wParam, int lParam) {
- return null;
-}
-
-LRESULT WM_SETFONT (int wParam, int lParam) {
- return null;
-}
-
-LRESULT WM_SETREDRAW (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 (wParam);
- display.lastNull = false;
-
- /* Do not issue a key down if a menu bar mnemonic was invoked */
- if (!hooks (SWT.KeyDown) && !display.filters (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:
- if (hooks (SWT.KeyDown) || hooks (SWT.KeyUp)) {
- Decorations shell = menuShell ();
- Menu menu = shell.getMenuBar ();
- if (menu != null) {
- char key = mbcsToWcs (lParam);
- if (key != 0) {
- key = Character.toUpperCase (key);
- MenuItem [] items = menu.getItems ();
- for (int i=0; i<items.length; i++) {
- MenuItem item = items [i];
- String text = item.getText ();
- char mnemonic = findMnemonic (text);
- if (text.length () > 0 && mnemonic == 0) {
- char ch = text.charAt (0);
- if (Character.toUpperCase (ch) == key) {
- Display display = getDisplay ();
- display.mnemonicKeyHit = false;
- return LRESULT.ZERO;
- }
- }
- }
- }
- }
- }
- // FALL THROUGH
- 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.
- */
- Decorations shell = menuShell ();
- if (!shell.isEnabled () || !shell.isActive ()) {
- 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) {
- /*
- * 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;
- }
-
- /* Ignore repeating modifier keys by testing key down state */
- switch (wParam) {
- case OS.VK_SHIFT:
- case OS.VK_MENU:
- case OS.VK_CONTROL:
- case OS.VK_CAPITAL:
- case OS.VK_NUMLOCK:
- case OS.VK_SCROLL:
- if ((lParam & 0x40000000) != 0) return null;
- }
-
- /* Clear last key and last ascii because a new key has been typed */
- Display display = getDisplay ();
- display.lastAscii = display.lastKey = 0;
- display.lastVirtual = display.lastNull = false;
-
- /* If are going to get a WM_SYSCHAR, ignore this message. */
- /*
- * Bug on WinCE. MapVirtualKey() returns incorrect values.
- * The fix is to rely on a key mappings table to determine
- * whether the key event must be sent now or if a WM_SYSCHAR
- * event will follow.
- */
- if (!OS.IsWinCE) {
- if (OS.MapVirtualKey (wParam, 2) != 0) {
- /*
- * Feature in Windows. MapVirtualKey() indicates that
- * a WM_SYSCHAR message will occur for Alt+Enter but
- * this message never happens. The fix is to issue the
- * event from WM_SYSKEYDOWN and map VK_RETURN to '\r'.
- */
- if (wParam != OS.VK_RETURN) return null;
- display.lastAscii = '\r';
- }
- }
- display.lastKey = wParam;
- display.lastVirtual = true;
-
- /*
- * 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 0x7F).
- */
- if (display.lastKey == OS.VK_DELETE) display.lastAscii = 0x7F;
-
- /*
- * 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;
- }
-
- 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;
-}
-
-}
-
+ int value = OS.VkKeyScan (ACCENTS [i]);
+ if ((value & 0xFF) == wParam && (value & 0x600) == 0x600) {
+ return null;
+ }
+ }
+ }
+
+ /*
+ * If we 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.lastKey = wParam;
+ 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 0x7F).
+ */
+ if (display.lastKey == OS.VK_DELETE) display.lastAscii = 0x7F;
+ /*
+ * 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;
+ display.lastAscii = display.numpadKey (display.lastKey);
+ }
+ } 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 asciiKey = display.asciiKey (wParam);
+ if (asciiKey != 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 SWT.KeyDown, look for VK_SPACE and
+ * issue the event from WM_CHAR.
+ */
+ if (asciiKey == OS.VK_SPACE) {
+ display.lastVirtual = true;
+ return null;
+ }
+ if (asciiKey != 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 (wParam);
+ display.lastAscii = display.controlKey (display.lastKey);
+ display.lastNull = display.lastAscii == 0 && display.lastKey == '@';
+ }
+ if (!sendKeyEvent (SWT.KeyDown, OS.WM_KEYDOWN, wParam, lParam)) {
+ return LRESULT.ZERO;
+ }
+ return null;
+}
+
+LRESULT WM_KEYUP (int wParam, int lParam) {
+ Display display = getDisplay ();
+
+ /* Check for hardware keys */
+ if (OS.IsWinCE) {
+ if (OS.VK_APP1 <= wParam && wParam <= OS.VK_APP6) {
+ display.lastKey = display.lastAscii = 0;
+ display.lastVirtual = display.lastNull = false;
+ Event event = new Event ();
+ event.detail = wParam - OS.VK_APP1 + 1;
+ /* Check the bit 30 to get the key state */
+ int type = (lParam & 0x40000000) != 0 ? SWT.HardKeyUp : SWT.HardKeyDown;
+ if (setInputState (event, type)) sendEvent (type, event);
+ return null;
+ }
+ }
+
+ /*
+ * If the key up is not hooked, reset last key
+ * and last ascii in case the key down is hooked.
+ */
+ if (!hooks (SWT.KeyUp) && !display.filters (SWT.KeyUp)) {
+ display.lastKey = display.lastAscii = 0;
+ display.lastVirtual = display.lastNull = false;
+ return null;
+ }
+
+ /* Map the virtual key. */
+ /*
+ * Bug on WinCE. MapVirtualKey() returns incorrect values.
+ * The fix is to rely on a key mappings table to determine
+ * whether the key event must be sent now or if a WM_CHAR
+ * event will follow.
+ */
+ int mapKey = OS.IsWinCE ? 0 : 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.
+ *
+ * NOTE: This code is used to avoid a call to ToAscii ().
+ *
+ */
+ if (OS.IsWinNT) {
+ if ((mapKey & 0x80000000) != 0) return null;
+ } else {
+ if ((mapKey & 0x8000) != 0) return null;
+ }
+
+ /*
+ * Bug in Windows. When the accent key is generated on an international
+ * keyboard using Ctrl+Alt or the special key, MapVirtualKey () does not
+ * have the high bit set indicating that this is an accent key stroke.
+ * The fix is to iterate through all known accent, mapping them back to
+ * their corresponding virtual key and key state. If the virtual key
+ * and key state match the current key, then this is an accent that has
+ * been generated using an international keyboard.
+ *
+ * NOTE: This code is used to avoid a call to ToAscii ().
+ */
+ if (!OS.IsWinCE) {
+ for (int i=0; i<ACCENTS.length; i++) {
+ int value = OS.VkKeyScan (ACCENTS [i]);
+ if ((value & 0xFF) == wParam && (value & 0x600) == 0x600) {
+ display.lastKey = display.lastAscii = 0;
+ display.lastVirtual = display.lastNull = false;
+ return null;
+ }
+ }
+ }
+
+ display.lastVirtual = (mapKey == 0);
+ if (display.lastVirtual) {
+ display.lastKey = wParam;
+ } else {
+ if (display.lastKey == 0) {
+ display.lastAscii = 0;
+ display.lastNull = false;
+ return null;
+ }
+ display.lastVirtual = display.isVirtualKey (display.lastKey);
+ }
+
+ LRESULT result = null;
+ if (!sendKeyEvent (SWT.KeyUp, OS.WM_KEYUP, wParam, lParam)) {
+ result = LRESULT.ZERO;
+ }
+ display.lastKey = display.lastAscii = 0;
+ display.lastVirtual = display.lastNull = false;
+ return result;
+}
+
+LRESULT WM_KILLFOCUS (int wParam, int lParam) {
+ int code = callWindowProc (OS.WM_KILLFOCUS, wParam, lParam);
+ Display display = getDisplay ();
+ Shell shell = getShell ();
+
+ /*
+ * 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 that the shell may be
+ * disposed at this point. If this happens
+ * don't send the activate and deactivate
+ * events.
+ */
+ if (!shell.isDisposed ()) {
+ Control control = display.findControl (wParam);
+ if (control == null || shell != control.getShell ()) {
+ shell.setActiveControl (null);
+ }
+ }
+
+ /*
+ * 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;
+ if (code == 0) return LRESULT.ZERO;
+ return new LRESULT (code);
+}
+
+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) {
+ boolean dragging = false, mouseDown = true;
+ boolean dragDetect = hooks (SWT.DragDetect);
+ if (dragDetect) {
+ if (!OS.IsWinCE) {
+ /*
+ * Feature in Windows. It's possible that the drag
+ * operation will not be started while the mouse is
+ * down, meaning that the mouse should be captured.
+ * This can happen when the user types the ESC key
+ * to cancel the drag. The fix is to query the state
+ * of the mouse and capture the mouse accordingly.
+ */
+ POINT pt = new POINT ();
+ pt.x = (short) (lParam & 0xFFFF);
+ pt.y = (short) (lParam >> 16);
+ OS.ClientToScreen(handle, pt);
+ dragging = OS.DragDetect (handle, pt);
+ mouseDown = OS.GetKeyState (OS.VK_LBUTTON) < 0;
+ }
+ }
+ sendMouseEvent (SWT.MouseDown, 1, OS.WM_LBUTTONDOWN, wParam, lParam);
+ int result = callWindowProc (OS.WM_LBUTTONDOWN, wParam, lParam);
+ if (OS.IsPPC) {
+ if (menu != null && !menu.isDisposed ()) {
+ int x = (short) (lParam & 0xFFFF);
+ int y = (short) (lParam >> 16);
+ SHRGINFO shrg = new SHRGINFO ();
+ shrg.cbSize = SHRGINFO.sizeof;
+ shrg.hwndClient = handle;
+ shrg.ptDown_x = x;
+ shrg.ptDown_y = y;
+ shrg.dwFlags = OS.SHRG_RETURNCMD;
+ int type = OS.SHRecognizeGesture (shrg);
+ if (type == OS.GN_CONTEXTMENU) {
+ menu.setVisible (true);
+ }
+ }
+ }
+ if (mouseDown) {
+ if (OS.GetCapture () != handle) OS.SetCapture (handle);
+ }
+ if (dragging) {
+ postEvent (SWT.DragDetect);
+ } else {
+ if (dragDetect) {
+ /*
+ * Feature in Windows. DragDetect() captures the mouse
+ * and tracks its movement until the user releases the
+ * left mouse button, presses the ESC key, or moves the
+ * mouse outside the drag rectangle. If the user moves
+ * the mouse outside of the drag rectangle, DragDetect()
+ * returns true and a drag and drop operation can be
+ * started. When the left mouse button is released or
+ * the ESC key is pressed, these events are consumed by
+ * DragDetect() so that application code that matches
+ * mouse down/up pairs or looks for the ESC key will not
+ * function properly. The fix is to send these events
+ * when the drag has not started.
+ *
+ * NOTE: For now, don't send a fake WM_KEYDOWN/WM_KEYUP
+ * events for the ESC key. This would require computing
+ * wParam (the key) and lParam (the repeat count, scan code,
+ * extended-key flag, context code, previous key-state flag,
+ * and transition-state flag) which is non-trivial.
+ */
+ if (OS.GetKeyState (OS.VK_ESCAPE) >= 0) {
+ OS.SendMessage (handle, OS.WM_LBUTTONUP, wParam, lParam);
+ }
+ }
+ }
+ 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) {
+ /*
+ * 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) {
+ Display display = getDisplay ();
+ display.mnemonicKeyHit = false;
+ 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) {
+ Display display = getDisplay ();
+ display.mnemonicKeyHit = true;
+ 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) {
+ sendMouseEvent (SWT.MouseHover, 0, OS.WM_MOUSEHOVER, wParam, lParam);
+ return null;
+}
+
+LRESULT WM_MOUSELEAVE (int wParam, int lParam) {
+ int pos = OS.GetMessagePos ();
+ POINT pt = new POINT ();
+ pt.x = (short) (pos & 0xFFFF);
+ pt.y = (short) (pos >> 16);
+ OS.ScreenToClient (handle, pt);
+ lParam = pt.x | (pt.y << 16);
+ sendMouseEvent (SWT.MouseExit, 0, OS.WM_MOUSELEAVE, wParam, lParam);
+ return null;
+}
+
+LRESULT WM_MOUSEMOVE (int wParam, int lParam) {
+ if (!OS.IsWinCE) {
+ Display display = getDisplay ();
+ boolean mouseEnter = hooks (SWT.MouseEnter) || display.filters (SWT.MouseEnter);
+ boolean mouseExit = hooks (SWT.MouseExit) || display.filters (SWT.MouseExit);
+ boolean mouseHover = hooks (SWT.MouseHover) || display.filters (SWT.MouseHover);
+ if (mouseEnter || mouseExit || 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 (mouseEnter) {
+ sendMouseEvent (SWT.MouseEnter, 0, OS.WM_MOUSEMOVE, wParam, lParam);
+ }
+ } 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_MOUSEWHEEL (int wParam, int 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 (!OS.IsWindowEnabled (handle)) return null;
+ 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) && !filters (SWT.Paint)) {
+ return null;
+ }
+
+ /* Get the damage */
+ int result = 0;
+ if (OS.IsWinCE) {
+ RECT rect = new RECT ();
+ OS.GetUpdateRect (handle, rect, false);
+ result = callWindowProc (OS.WM_PAINT, wParam, lParam);
+ OS.InvalidateRect (handle, rect, false);
+ } else {
+ int rgn = OS.CreateRectRgn (0, 0, 0, 0);
+ OS.GetUpdateRgn (handle, rgn, false);
+ 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_PRINTCLIENT (int wParam, int lParam) {
+ return null;
+}
+
+LRESULT WM_QUERYENDSESSION (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) {
+ int code = callWindowProc (OS.WM_SETFOCUS, wParam, lParam);
+ Shell shell = getShell ();
+
+ /*
+ * 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 that the shell may be
+ * disposed at this point. If this happens
+ * don't send the activate and deactivate
+ * events.
+ */
+ if (!shell.isDisposed ()) {
+ shell.setActiveControl (this);
+ }
+
+ /*
+ * 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;
+ if (code == 0) return LRESULT.ZERO;
+ return new LRESULT (code);
+}
+
+LRESULT WM_SETTINGCHANGE (int wParam, int lParam) {
+ return null;
+}
+
+LRESULT WM_SETFONT (int wParam, int lParam) {
+ return null;
+}
+
+LRESULT WM_SETREDRAW (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 (wParam);
+ display.lastNull = false;
+
+ /* Do not issue a key down if a menu bar mnemonic was invoked */
+ if (!hooks (SWT.KeyDown) && !display.filters (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:
+ if (hooks (SWT.KeyDown) || hooks (SWT.KeyUp)) {
+ Decorations shell = menuShell ();
+ Menu menu = shell.getMenuBar ();
+ if (menu != null) {
+ char key = mbcsToWcs (lParam);
+ if (key != 0) {
+ key = Character.toUpperCase (key);
+ MenuItem [] items = menu.getItems ();
+ for (int i=0; i<items.length; i++) {
+ MenuItem item = items [i];
+ String text = item.getText ();
+ char mnemonic = findMnemonic (text);
+ if (text.length () > 0 && mnemonic == 0) {
+ char ch = text.charAt (0);
+ if (Character.toUpperCase (ch) == key) {
+ Display display = getDisplay ();
+ display.mnemonicKeyHit = false;
+ return LRESULT.ZERO;
+ }
+ }
+ }
+ }
+ }
+ }
+ // FALL THROUGH
+ 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.
+ */
+ Decorations shell = menuShell ();
+ if (!shell.isEnabled () || !shell.isActive ()) {
+ 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) {
+ /*
+ * 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;
+ }
+
+ /* Ignore repeating modifier keys by testing key down state */
+ switch (wParam) {
+ case OS.VK_SHIFT:
+ case OS.VK_MENU:
+ case OS.VK_CONTROL:
+ case OS.VK_CAPITAL:
+ case OS.VK_NUMLOCK:
+ case OS.VK_SCROLL:
+ if ((lParam & 0x40000000) != 0) return null;
+ }
+
+ /* Clear last key and last ascii because a new key has been typed */
+ Display display = getDisplay ();
+ display.lastAscii = display.lastKey = 0;
+ display.lastVirtual = display.lastNull = false;
+
+ /* If are going to get a WM_SYSCHAR, ignore this message. */
+ /*
+ * Bug on WinCE. MapVirtualKey() returns incorrect values.
+ * The fix is to rely on a key mappings table to determine
+ * whether the key event must be sent now or if a WM_SYSCHAR
+ * event will follow.
+ */
+ if (!OS.IsWinCE) {
+ if (OS.MapVirtualKey (wParam, 2) != 0) {
+ /*
+ * Feature in Windows. MapVirtualKey() indicates that
+ * a WM_SYSCHAR message will occur for Alt+Enter but
+ * this message never happens. The fix is to issue the
+ * event from WM_SYSKEYDOWN and map VK_RETURN to '\r'.
+ */
+ if (wParam != OS.VK_RETURN) return null;
+ display.lastAscii = '\r';
+ }
+ }
+ display.lastKey = wParam;
+ display.lastVirtual = true;
+
+ /*
+ * 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 0x7F).
+ */
+ if (display.lastKey == OS.VK_DELETE) display.lastAscii = 0x7F;
+
+ /*
+ * 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;
+ }
+
+ 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
index c9b8985e70..c194db22df 100755
--- 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
@@ -1,1001 +1,1001 @@
-package org.eclipse.swt.widgets;
-
-/*
+package org.eclipse.swt.widgets;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-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.
- * <p>
- * The item children that may be added to instances of this class
- * must be of type <code>CoolItem</code>.
- * </p><p>
- * Note that although this class is a subclass of <code>Composite</code>,
- * it does not make sense to add <code>Control</code> children to it,
- * or set a layout on it.
- * </p><p>
- * <dl>
- * <dt><b>Styles:</b></dt>
- * <dd>(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;
- CoolItem [] originalItems;
- boolean locked;
- boolean ignoreResize;
- static final int ReBarProc;
- static final TCHAR ReBarClass = new TCHAR (0, OS.REBARCLASSNAME, true);
- static {
- INITCOMMONCONTROLSEX icex = new INITCOMMONCONTROLSEX ();
- icex.dwSize = INITCOMMONCONTROLSEX.sizeof;
- icex.dwICC = OS.ICC_COOL_CLASSES;
- OS.InitCommonControlsEx (icex);
- WNDCLASS lpWndClass = new WNDCLASS ();
- OS.GetClassInfo (0, ReBarClass, lpWndClass);
- ReBarProc = lpWndClass.lpfnWndProc;
- }
- static final int MAX_WIDTH = 0x7FFF;
-
-/**
- * Constructs a new instance of this class given its parent
- * and a style value describing its behavior and appearance.
- * <p>
- * The style value is either one of the style constants defined in
- * class <code>SWT</code> which is applicable to instances of this
- * class, or must be built by <em>bitwise OR</em>'ing together
- * (that is, using the <code>int</code> "|" operator) two or more
- * of those <code>SWT</code> style constants. The class description
- * lists the style constants that are applicable to the class.
- * Style bits are also inherited from superclasses.
- * </p>
- *
- * @param parent a composite control which will be the parent of the new instance (cannot be null)
- * @param style the style of control to construct
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
- * <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
- * </ul>
- *
- * @see SWT
- * @see Widget#checkSubclass
- * @see Widget#getStyle
- */
-public CoolBar (Composite parent, int style) {
- super (parent, checkStyle (style));
-}
-
-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) {
- style |= SWT.NO_FOCUS;
- /*
- * Even though it is legal to create this widget
- * with scroll bars, they serve no useful purpose
- * because they do not automatically scroll the
- * widget's client area. The fix is to clear
- * the SWT style.
- */
- return style & ~(SWT.H_SCROLL | SWT.V_SCROLL);
-}
-
-protected void checkSubclass () {
- if (!isValidSubclass ()) error (SWT.ERROR_INVALID_SUBCLASS);
-}
-
-public Point computeSize (int wHint, int hHint, boolean changed) {
- checkWidget ();
- int width = 0, height = 0;
- int border = getBorderWidth ();
- int newWidth = wHint == SWT.DEFAULT ? 0x3FFF : wHint + (border * 2);
- int newHeight = hHint == SWT.DEFAULT ? 0x3FFF : hHint + (border * 2);
- int count = OS.SendMessage (handle, OS.RB_GETBANDCOUNT, 0, 0);
- if (count != 0) {
- ignoreResize = true;
- boolean redraw = false;
- if (OS.IsWindowVisible (handle)) {
- if (COMCTL32_MAJOR >= 6) {
- redraw = true;
- OS.UpdateWindow (handle);
- OS.DefWindowProc (handle, OS.WM_SETREDRAW, 0, 0);
- } else {
- redraw = drawCount == 0;
- if (redraw) {
- OS.UpdateWindow (handle);
- OS.SendMessage (handle, OS.WM_SETREDRAW, 0, 0);
- }
- }
- }
- RECT oldRect = new RECT ();
- OS.GetWindowRect (handle, oldRect);
- int oldWidth = oldRect.right - oldRect.left;
- int oldHeight = oldRect.bottom - oldRect.top;
- int flags = OS.SWP_NOACTIVATE | OS.SWP_NOMOVE | OS.SWP_NOREDRAW | OS.SWP_NOZORDER;
- OS.SetWindowPos (handle, 0, 0, 0, newWidth, newHeight, flags);
- RECT rect = new RECT ();
- OS.SendMessage (handle, OS.RB_GETRECT, count - 1, rect);
- height = Math.max (height, rect.bottom);
- OS.SetWindowPos (handle, 0, 0, 0, oldWidth, oldHeight, flags);
- REBARBANDINFO rbBand = new REBARBANDINFO ();
- rbBand.cbSize = REBARBANDINFO.sizeof;
- rbBand.fMask = OS.RBBIM_IDEALSIZE | OS.RBBIM_STYLE;
- int rowWidth = 0;
- for (int i = 0; i < count; i++) {
- OS.SendMessage(handle, OS.RB_GETBANDINFO, i, rbBand);
- OS.SendMessage(handle, OS.RB_GETBANDBORDERS, i, rect);
- if ((rbBand.fStyle & OS.RBBS_BREAK) != 0) {
- width = Math.max(width, rowWidth);
- rowWidth = 0;
- }
- rowWidth += rbBand.cxIdeal + rect.left + rect.right + 2;
- }
- width = Math.max(width, rowWidth);
- if (redraw) {
- if (COMCTL32_MAJOR >= 6) {
- OS.DefWindowProc (handle, OS.WM_SETREDRAW, 1, 0);
- } else {
- OS.SendMessage (handle, OS.WM_SETREDRAW, 1, 0);
- }
- }
- ignoreResize = false;
- }
- if (width == 0) width = DEFAULT_WIDTH;
- if (height == 0) height = DEFAULT_HEIGHT;
- if (wHint != SWT.DEFAULT) width = wHint;
- if (hHint != SWT.DEFAULT) height = hHint;
- height += border * 2;
- width += 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, TCHAR.sizeof);
- 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;
- if ((item.style & SWT.DROP_DOWN) != 0) {
- rbBand.fStyle |= OS.RBBS_USECHEVRON;
- }
- rbBand.lpText = lpText;
- rbBand.wID = id;
-
- /*
- * Feature in Windows. When inserting an item at end of a row,
- * sometimes, Windows will begin to place the item on the right
- * side of the cool bar. The fix is to resize the new items to
- * the maximum size and then resize the next to last item to the
- * ideal size.
- */
- int lastIndex = getLastIndexOfRow (index - 1);
- boolean fixLast = index == lastIndex + 1;
- if (fixLast) {
- rbBand.fMask |= OS.RBBIM_SIZE;
- rbBand.cx = MAX_WIDTH;
- }
-
- /*
- * Feature in Windows. Is possible that the item at index zero
- * has the RBBS_BREAK flag set. When a new item is inserted at
- * position zero, the previous item at position zero moves to
- * a new line. The fix is to detect this case and clear the
- * RBBS_BREAK flag on the previous item before inserting the
- * new item.
- */
- if (index == 0 && count > 0) {
- getItem (0).setWrap (false);
- }
-
- /* Insert the item */
- if (OS.SendMessage (handle, OS.RB_INSERTBAND, index, rbBand) == 0) {
- error (SWT.ERROR_ITEM_NOT_ADDED);
- }
-
- /* Resize the next to last item to the ideal size */
- if (fixLast) {
- resizeToPreferredWidth (lastIndex);
- }
-
- OS.HeapFree (hHeap, 0, lpText);
- items [item.id = id] = item;
- int length = originalItems.length;
- CoolItem [] newOriginals = new CoolItem [length + 1];
- System.arraycopy (originalItems, 0, newOriginals, 0, index);
- System.arraycopy (originalItems, index, newOriginals, index + 1, length - index);
- newOriginals [index] = item;
- originalItems = newOriginals;
-}
-
-void createWidget () {
- super.createWidget ();
- items = new CoolItem [4];
- originalItems = new CoolItem [0];
-}
-
-void destroyItem (CoolItem item) {
- int index = OS.SendMessage (handle, OS.RB_IDTOINDEX, item.id, 0);
- int count = OS.SendMessage (handle, OS.RB_GETBANDCOUNT, 0, 0);
- if (count != 0) {
- int lastIndex = getLastIndexOfRow (index);
- if (index == lastIndex) {
- /*
- * Feature in Windows. If the last item in a row is
- * given its ideal size, it will be placed at the far
- * right hand edge of the coolbar. It is preferred
- * that the last item appear next to the second last
- * item. The fix is to size the last item of each row
- * so that it occupies all the available space to the
- * right in the row.
- */
- resizeToMaximumWidth (lastIndex - 1);
- }
- }
-
- /*
- * 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.isDisposed() && control.getVisible ();
-
- /*
- * When a wrapped item is being deleted, make the next
- * item in the row wrapped in order to preserve the row.
- * In order to avoid an unnecessary layout, temporarily
- * ignore WM_SIZE. If the next item is wrapped then a
- * row will be deleted and the WM_SIZE is necessary.
- */
- CoolItem nextItem = null;
- if (item.getWrap ()) {
- if (index + 1 < count) {
- nextItem = getItem (index + 1);
- ignoreResize = !nextItem.getWrap ();
- }
- }
- if (OS.SendMessage (handle, OS.RB_DELETEBAND, index, 0) == 0) {
- error (SWT.ERROR_ITEM_NOT_REMOVED);
- }
- items [item.id] = null;
- item.id = -1;
- if (ignoreResize) {
- nextItem.setWrap (true);
- ignoreResize = false;
- }
-
- /* Restore the visible state tof the control */
- if (wasVisible) control.setVisible (true);
-
- index = 0;
- while (index < originalItems.length) {
- if (originalItems [index] == item) break;
- index++;
- }
- int length = originalItems.length - 1;
- CoolItem [] newOriginals = new CoolItem [length];
- System.arraycopy (originalItems, 0, newOriginals, 0, index);
- System.arraycopy (originalItems, index + 1, newOriginals, index, length - index);
- originalItems = newOriginals;
-}
-
-/**
- * Returns the item that is currently displayed at the given,
- * zero-relative index. Throws an exception if the index is
- * out of range.
- *
- * @param index the visual index of the item to return
- * @return the item at the given visual index
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_INVALID_RANGE - if the index is not between 0 and the number of elements in the list minus 1 (inclusive)</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- * @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 zero-relative ints that map
- * the creation order of the receiver's items to the
- * order in which they are currently being displayed.
- * <p>
- * Specifically, the indices of the returned array represent
- * the current visual order of the items, and the contents
- * of the array represent the creation order of the items.
- * </p><p>
- * Note: This is not the actual structure used by the receiver
- * to maintain its list of items, so modifying the array will
- * not affect the receiver.
- * </p>
- *
- * @return the current visual order of the receiver's items
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- * @exception SWTError <ul>
- * <li>ERROR_CANNOT_GET_ITEM - if the operation fails because of an operating system failure</li>
- * </ul>
- */
-public int [] getItemOrder () {
- checkWidget ();
- int count = OS.SendMessage (handle, OS.RB_GETBANDCOUNT, 0, 0);
- int [] indices = new int [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);
- CoolItem item = items [rbBand.wID];
- int index = 0;
- while (index<originalItems.length) {
- if (originalItems [index] == item) break;
- index++;
- }
- if (index == originalItems.length) error (SWT.ERROR_CANNOT_GET_ITEM);
- indices [i] = index;
- }
- return indices;
-}
-
-/**
- * Returns an array of <code>CoolItem</code>s in the order
- * in which they are currently being displayed.
- * <p>
- * Note: This is not the actual structure used by the receiver
- * to maintain its list of items, so modifying the array will
- * not affect the receiver.
- * </p>
- *
- * @return the receiver's items in their current visual order
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- * @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;
-}
-
-/**
- * Returns an array of points whose x and y coordinates describe
- * the widths and heights (respectively) of the items in the receiver
- * in the order in which they are currently being displayed.
- *
- * @return the receiver's item sizes in their current visual order
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public Point [] getItemSizes () {
- checkWidget ();
- int count = OS.SendMessage (handle, OS.RB_GETBANDCOUNT, 0, 0);
- Point [] sizes = new Point [count];
- REBARBANDINFO rbBand = new REBARBANDINFO ();
- rbBand.cbSize = REBARBANDINFO.sizeof;
- rbBand.fMask = OS.RBBIM_CHILDSIZE;
- for (int i=0; i<count; i++) {
- RECT rect = new RECT ();
- OS.SendMessage (handle, OS.RB_GETRECT, i, rect);
- OS.SendMessage (handle, OS.RB_GETBANDINFO, i, rbBand);
- sizes [i] = new Point (rect.right - rect.left + 2, rbBand.cyChild);
- }
- return sizes;
-}
-
-int getLastIndexOfRow (int index) {
- int count = OS.SendMessage (handle, OS.RB_GETBANDCOUNT, 0, 0);
- if (count == 0) return -1;
- REBARBANDINFO rbBand = new REBARBANDINFO ();
- rbBand.cbSize = REBARBANDINFO.sizeof;
- rbBand.fMask = OS.RBBIM_STYLE;
- for (int i=index + 1; i<count; i++) {
- OS.SendMessage (handle, OS.RB_GETBANDINFO, i, rbBand);
- if ((rbBand.fStyle & OS.RBBS_BREAK) != 0) {
- return i - 1;
- }
- }
- return count - 1;
-}
-
-/**
- * Returns whether or not the receiver is 'locked'. When a coolbar
- * is locked, its items cannot be repositioned.
- *
- * @return true if the coolbar is locked, false otherwise
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @since 2.0
- */
-public boolean getLocked () {
- checkWidget ();
- return locked;
-}
-
-/**
- * Returns an array of ints that describe the zero-relative
- * indices of any item(s) in the receiver that will begin on
- * a new row. The 0th visible item always begins the first row,
- * therefore it does not count as a wrap index.
- *
- * @return an array containing the receiver's wrap indices, or an empty array if all items are in one row
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public int [] getWrapIndices () {
- checkWidget ();
- 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;
- }
- int [] result = new int [count];
- System.arraycopy (indices, 0, result, 0, count);
- return result;
-}
-
-/**
- * Searches the receiver's items in the order they are currently
- * being displayed, starting at the first item (index 0), until
- * an item is found that is equal to the argument, and returns
- * the index of that item. If no item is found, returns -1.
- *
- * @param item the search item
- * @return the visual order index of the search item, or -1 if the item is not found
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the item is null</li>
- * <li>ERROR_INVALID_ARGUMENT - if the item is disposed</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public int indexOf (CoolItem item) {
- checkWidget ();
- if (item == null) error (SWT.ERROR_NULL_ARGUMENT);
- if (item.isDisposed()) error (SWT.ERROR_INVALID_ARGUMENT);
- return OS.SendMessage (handle, OS.RB_IDTOINDEX, item.id, 0);
-}
-
-void resizeToPreferredWidth (int index) {
- /*
- * Bug in Windows. When RB_GETBANDBORDERS is sent
- * with an index out of range, Windows GP's. The
- * fix is to ensure the index is in range.
- */
- int count = OS.SendMessage(handle, OS.RB_GETBANDCOUNT, 0, 0);
- if (0 <= index && index < count) {
- REBARBANDINFO rbBand = new REBARBANDINFO();
- rbBand.cbSize = REBARBANDINFO.sizeof;
- rbBand.fMask = OS.RBBIM_IDEALSIZE;
- OS.SendMessage (handle, OS.RB_GETBANDINFO, index, rbBand);
- RECT rect = new RECT ();
- OS.SendMessage (handle, OS.RB_GETBANDBORDERS, index, rect);
- rbBand.cx = rbBand.cxIdeal + rect.left + rect.right;
- rbBand.fMask = OS.RBBIM_SIZE;
- OS.SendMessage (handle, OS.RB_SETBANDINFO, index, rbBand);
- }
-}
-
-void resizeToMaximumWidth (int index) {
- REBARBANDINFO rbBand = new REBARBANDINFO();
- rbBand.cbSize = REBARBANDINFO.sizeof;
- rbBand.fMask = OS.RBBIM_SIZE;
- rbBand.cx = MAX_WIDTH;
- OS.SendMessage (handle, OS.RB_SETBANDINFO, index, rbBand);
-}
-
-void releaseWidget () {
- for (int i=0; i<items.length; i++) {
- CoolItem item = items [i];
- if (item != null && !item.isDisposed ()) {
- item.releaseResources ();
- }
- }
- items = null;
- super.releaseWidget();
-}
-
-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);
- }
-}
-
-/**
- * Sets the receiver's item order, wrap indices, and item sizes
- * all at once. This method is typically used to restore the
- * displayed state of the receiver to a previously stored state.
- * <p>
- * The item order is the order in which the items in the receiver
- * should be displayed, given in terms of the zero-relative ordering
- * of when the items were added.
- * </p><p>
- * The wrap indices are the indices of all item(s) in the receiver
- * that will begin on a new row. The indices are given in the order
- * specified by the item order. The 0th item always begins the first
- * row, therefore it does not count as a wrap index. If wrap indices
- * is null or empty, the items will be placed on one line.
- * </p><p>
- * The sizes are specified in an array of points whose x and y
- * coordinates describe the new widths and heights (respectively)
- * of the receiver's items in the order specified by the item order.
- * </p>
- *
- * @param itemOrder an array of indices that describe the new order to display the items in
- * @param wrapIndices an array of wrap indices, or null
- * @param sizes an array containing the new sizes for each of the receiver's items in visual order
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if item order or sizes is null</li>
- * <li>ERROR_INVALID_ARGUMENT - if item order or sizes is not the same length as the number of items</li>
- * </ul>
- * @exception SWTError <ul>
- * <li>ERROR_CANNOT_GET_ITEM - if the operation fails because of an operating system failure</li>
- * </ul>
- */
-public void setItemLayout (int [] itemOrder, int [] wrapIndices, Point [] sizes) {
- checkWidget ();
- setRedraw (false);
- setItemOrder (itemOrder);
- setWrapIndices (wrapIndices);
- setItemSizes (sizes);
- setRedraw (true);
-}
-
-/*
- * Sets the order that the items in the receiver should
- * be displayed in to the given argument which is described
- * in terms of the zero-relative ordering of when the items
- * were added.
- *
- * @param itemOrder the new order to display the items in
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the item order is null</li>
- * <li>ERROR_INVALID_ARGUMENT - if the item order is not the same length as the number of items</li>
- * </ul>
- * @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);
-
- /* Ensure that itemOrder does not contain any duplicates. */
- boolean [] set = new boolean [itemCount];
- for (int i=0; i<itemOrder.length; i++) {
- int index = itemOrder [i];
- if (index < 0 || index >= itemCount) error (SWT.ERROR_INVALID_RANGE);
- if (set [index]) error (SWT.ERROR_INVALID_ARGUMENT);
- set [index] = true;
- }
-
- REBARBANDINFO rbBand = new REBARBANDINFO ();
- rbBand.cbSize = REBARBANDINFO.sizeof;
- for (int i=0; i<itemOrder.length; i++) {
- int id = originalItems [itemOrder [i]].id;
- int index = OS.SendMessage (handle, OS.RB_IDTOINDEX, id, 0);
- if (index != i) {
- int lastItemSrcRow = getLastIndexOfRow (index);
- int lastItemDstRow = getLastIndexOfRow (i);
- if (index == lastItemSrcRow) {
- resizeToPreferredWidth (index);
- }
- if (i == lastItemDstRow) {
- resizeToPreferredWidth (i);
- }
-
- /* Move the item */
- OS.SendMessage (handle, OS.RB_MOVEBAND, index, i);
-
- if (index == lastItemSrcRow && index - 1 >= 0) {
- resizeToMaximumWidth (index - 1);
- }
- if (i == lastItemDstRow) {
- resizeToMaximumWidth (i);
- }
- }
- }
-}
-
-/*
- * Sets the width and height of the receiver's 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 in which the items are currently being displayed.
- *
- * @param sizes an array containing the new sizes for each of the receiver's items in visual order
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the array of sizes is null</li>
- * <li>ERROR_INVALID_ARGUMENT - if the array of sizes is not the same length as the number of items</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - 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);
- int count = OS.SendMessage (handle, OS.RB_GETBANDCOUNT, 0, 0);
- if (sizes.length != count) error (SWT.ERROR_INVALID_ARGUMENT);
- 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);
- items [rbBand.wID].setSize (sizes [i].x, sizes [i].y);
- }
-}
-
-/**
- * Sets whether or not the receiver is 'locked'. When a coolbar
- * is locked, its items cannot be repositioned.
- *
- * @param locked lock the coolbar if true, otherwise unlock the coolbar
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @since 2.0
- */
-public void setLocked (boolean locked) {
- checkWidget ();
- this.locked = locked;
- int count = OS.SendMessage (handle, OS.RB_GETBANDCOUNT, 0, 0);
- REBARBANDINFO rbBand = new REBARBANDINFO ();
- rbBand.cbSize = REBARBANDINFO.sizeof;
- rbBand.fMask = OS.RBBIM_STYLE;
- for (int i=0; i<count; i++) {
- OS.SendMessage (handle, OS.RB_GETBANDINFO, i, rbBand);
- if (locked) {
- rbBand.fStyle |= OS.RBBS_NOGRIPPER;
- } else {
- rbBand.fStyle &= ~OS.RBBS_NOGRIPPER;
- }
- OS.SendMessage (handle, OS.RB_SETBANDINFO, i, rbBand);
- }
-}
-
-/**
- * Sets the indices of all item(s) in the receiver that will
- * begin on a new row. The indices are given in the order in
- * which they are currently being displayed. The 0th item
- * always begins the first row, therefore it does not count
- * as a wrap index. If indices is null or empty, the items
- * will be placed on one line.
- *
- * @param indices an array of wrap indices, or null
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public void setWrapIndices (int [] indices) {
- checkWidget ();
- if (indices == null) indices = new int [0];
- int count = getItemCount ();
- for (int i=0; i<indices.length; i++) {
- if (indices [i] < 0 || indices [i] >= count) {
- error (SWT.ERROR_INVALID_RANGE);
- }
- }
- setRedraw (false);
- CoolItem [] items = getItems ();
- for (int i=0; i<items.length; i++) {
- CoolItem item = items [i];
- if (item.getWrap ()) {
- resizeToPreferredWidth (i - 1);
- item.setWrap (false);
- }
- }
- resizeToMaximumWidth (count - 1);
- for (int i=0; i<indices.length; i++) {
- int index = indices [i];
- if (0 <= index && index < items.length) {
- CoolItem item = items [index];
- item.setWrap (true);
- resizeToMaximumWidth (index - 1);
- }
- }
- setRedraw (true);
-}
-
-int widgetStyle () {
- int bits = super.widgetStyle () | OS.CCS_NODIVIDER | OS.CCS_NORESIZE;
- bits |= OS.RBS_VARHEIGHT | OS.RBS_BANDBORDERS | OS.RBS_DBLCLKTOGGLE;
- return bits;
-}
-
-TCHAR 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 its parent. This is done so that
- * children of this control that send this message
- * type to their parent will notify not only
- * this control but also the parent of this control,
- * which is typically the application window and
- * the window that is looking for the message.
- * If the control did not forward the message,
- * applications would have to subclass the control
- * window to see the message. Because the control
- * window is subclassed by SWT, the message
- * is delivered twice, once by SWT and once when
- * the message is forwarded by the window proc.
- * The fix is to avoid calling the window proc
- * for this control.
- */
- LRESULT result = super.WM_COMMAND (wParam, lParam);
- if (result != null) return result;
- return LRESULT.ZERO;
-}
-
-LRESULT WM_ERASEBKGND (int wParam, int lParam) {
- LRESULT result = super.WM_ERASEBKGND (wParam, lParam);
- if (result != null) return result;
-
- /*
- * 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 is larger
- * than the space occupied by the cool bar items.
- * The fix is to erase the cool bar background.
- */
- drawBackground (wParam);
-
- /*
- * NOTE: The cool bar draws separators in WM_ERASEBKGND
- * so it is essential to run the cool bar window proc
- * after the background has been erased.
- */
- return null;
-}
-
-LRESULT WM_NOTIFY (int wParam, int lParam) {
- /*
- * Feature in Windows. When the cool bar window
- * proc processes WM_NOTIFY, it forwards this
- * message to its parent. This is done so that
- * children of this control that send this message
- * type to their parent will notify not only
- * this control but also the parent of this control,
- * which is typically the application window and
- * the window that is looking for the message.
- * If the control did not forward the message,
- * applications would have to subclass the control
- * window to see the message. Because the control
- * window is subclassed by SWT, the message
- * is delivered twice, once by SWT and once when
- * the message is forwarded by the window proc.
- * The fix is to avoid calling the window proc
- * for this control.
- */
- LRESULT result = super.WM_NOTIFY (wParam, lParam);
- if (result != null) return result;
- return LRESULT.ZERO;
-}
-
-LRESULT WM_SETREDRAW (int wParam, int lParam) {
- LRESULT result = super.WM_SETREDRAW (wParam, lParam);
- if (result != null) return result;
- /*
- * Feature in Windows. When redraw is turned off, the rebar
- * control does not call the default window proc. This means
- * that the rebar will redraw and children of the rebar will
- * also redraw. The fix is to call both the rebar window proc
- * and the default window proc.
- *
- * NOTE: The rebar control can resize itself in WM_SETREDRAW.
- * When redraw is turned off by the default window proc, this
- * can leave pixel corruption in the parent. The fix is to
- * detect the size change and damage the previous area in the
- * parent.
- *
- * NOTE: In version 6.00 of COMCTL32.DLL, when WM_SETREDRAW
- * is off, we cannot detect that the size has changed causing
- * pixel corruption. The fix is to disallow WM_SETREDRAW by
- * by not running the default window proc or the rebar window
- * proc.
- */
- if (COMCTL32_MAJOR >= 6) return LRESULT.ZERO;
- Rectangle rect = getBounds ();
- int code = callWindowProc (OS.WM_SETREDRAW, wParam, lParam);
- OS.DefWindowProc (handle, OS.WM_SETREDRAW, wParam, lParam);
- if (!rect.equals (getBounds ())) {
- parent.redraw (rect.x, rect.y, rect.width, rect.height, true);
- }
- return new LRESULT (code);
-}
-
-LRESULT WM_SIZE(int wParam, int lParam) {
- if (ignoreResize) {
- int code = callWindowProc (OS.WM_SIZE, wParam, lParam);
- if (code == 0) return LRESULT.ZERO;
- return new LRESULT (code);
- }
- return super.WM_SIZE(wParam, lParam);
-}
-
-LRESULT wmNotifyChild (int wParam, int lParam) {
- NMHDR hdr = new NMHDR ();
- OS.MoveMemory (hdr, lParam, NMHDR.sizeof);
- switch (hdr.code) {
- case OS.RBN_HEIGHTCHANGE:
- if (!ignoreResize) {
- Point size = getSize ();
- int border = getBorderWidth ();
- int height = OS.SendMessage (handle, OS.RB_GETBARHEIGHT, 0, 0);
- setSize (size.x, height + (border * 2));
- }
- break;
- case OS.RBN_CHEVRONPUSHED:
- NMREBARCHEVRON lpnm = new NMREBARCHEVRON ();
- OS.MoveMemory (lpnm, lParam, NMREBARCHEVRON.sizeof);
- CoolItem child = items [lpnm.wID];
- if (child != null) {
- Event event = new Event();
- event.detail = SWT.ARROW;
- event.x = lpnm.left;
- event.y = lpnm.bottom;
- child.postEvent (SWT.Selection, event);
- }
- break;
- }
- return super.wmNotifyChild (wParam, lParam);
-}
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+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.
+ * <p>
+ * The item children that may be added to instances of this class
+ * must be of type <code>CoolItem</code>.
+ * </p><p>
+ * Note that although this class is a subclass of <code>Composite</code>,
+ * it does not make sense to add <code>Control</code> children to it,
+ * or set a layout on it.
+ * </p><p>
+ * <dl>
+ * <dt><b>Styles:</b></dt>
+ * <dd>(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;
+ CoolItem [] originalItems;
+ boolean locked;
+ boolean ignoreResize;
+ static final int ReBarProc;
+ static final TCHAR ReBarClass = new TCHAR (0, OS.REBARCLASSNAME, true);
+ static {
+ INITCOMMONCONTROLSEX icex = new INITCOMMONCONTROLSEX ();
+ icex.dwSize = INITCOMMONCONTROLSEX.sizeof;
+ icex.dwICC = OS.ICC_COOL_CLASSES;
+ OS.InitCommonControlsEx (icex);
+ WNDCLASS lpWndClass = new WNDCLASS ();
+ OS.GetClassInfo (0, ReBarClass, lpWndClass);
+ ReBarProc = lpWndClass.lpfnWndProc;
+ }
+ static final int MAX_WIDTH = 0x7FFF;
+
+/**
+ * Constructs a new instance of this class given its parent
+ * and a style value describing its behavior and appearance.
+ * <p>
+ * The style value is either one of the style constants defined in
+ * class <code>SWT</code> which is applicable to instances of this
+ * class, or must be built by <em>bitwise OR</em>'ing together
+ * (that is, using the <code>int</code> "|" operator) two or more
+ * of those <code>SWT</code> style constants. The class description
+ * lists the style constants that are applicable to the class.
+ * Style bits are also inherited from superclasses.
+ * </p>
+ *
+ * @param parent a composite control which will be the parent of the new instance (cannot be null)
+ * @param style the style of control to construct
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
+ * <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
+ * </ul>
+ *
+ * @see SWT
+ * @see Widget#checkSubclass
+ * @see Widget#getStyle
+ */
+public CoolBar (Composite parent, int style) {
+ super (parent, checkStyle (style));
+}
+
+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) {
+ style |= SWT.NO_FOCUS;
+ /*
+ * Even though it is legal to create this widget
+ * with scroll bars, they serve no useful purpose
+ * because they do not automatically scroll the
+ * widget's client area. The fix is to clear
+ * the SWT style.
+ */
+ return style & ~(SWT.H_SCROLL | SWT.V_SCROLL);
+}
+
+protected void checkSubclass () {
+ if (!isValidSubclass ()) error (SWT.ERROR_INVALID_SUBCLASS);
+}
+
+public Point computeSize (int wHint, int hHint, boolean changed) {
+ checkWidget ();
+ int width = 0, height = 0;
+ int border = getBorderWidth ();
+ int newWidth = wHint == SWT.DEFAULT ? 0x3FFF : wHint + (border * 2);
+ int newHeight = hHint == SWT.DEFAULT ? 0x3FFF : hHint + (border * 2);
+ int count = OS.SendMessage (handle, OS.RB_GETBANDCOUNT, 0, 0);
+ if (count != 0) {
+ ignoreResize = true;
+ boolean redraw = false;
+ if (OS.IsWindowVisible (handle)) {
+ if (COMCTL32_MAJOR >= 6) {
+ redraw = true;
+ OS.UpdateWindow (handle);
+ OS.DefWindowProc (handle, OS.WM_SETREDRAW, 0, 0);
+ } else {
+ redraw = drawCount == 0;
+ if (redraw) {
+ OS.UpdateWindow (handle);
+ OS.SendMessage (handle, OS.WM_SETREDRAW, 0, 0);
+ }
+ }
+ }
+ RECT oldRect = new RECT ();
+ OS.GetWindowRect (handle, oldRect);
+ int oldWidth = oldRect.right - oldRect.left;
+ int oldHeight = oldRect.bottom - oldRect.top;
+ int flags = OS.SWP_NOACTIVATE | OS.SWP_NOMOVE | OS.SWP_NOREDRAW | OS.SWP_NOZORDER;
+ OS.SetWindowPos (handle, 0, 0, 0, newWidth, newHeight, flags);
+ RECT rect = new RECT ();
+ OS.SendMessage (handle, OS.RB_GETRECT, count - 1, rect);
+ height = Math.max (height, rect.bottom);
+ OS.SetWindowPos (handle, 0, 0, 0, oldWidth, oldHeight, flags);
+ REBARBANDINFO rbBand = new REBARBANDINFO ();
+ rbBand.cbSize = REBARBANDINFO.sizeof;
+ rbBand.fMask = OS.RBBIM_IDEALSIZE | OS.RBBIM_STYLE;
+ int rowWidth = 0;
+ for (int i = 0; i < count; i++) {
+ OS.SendMessage(handle, OS.RB_GETBANDINFO, i, rbBand);
+ OS.SendMessage(handle, OS.RB_GETBANDBORDERS, i, rect);
+ if ((rbBand.fStyle & OS.RBBS_BREAK) != 0) {
+ width = Math.max(width, rowWidth);
+ rowWidth = 0;
+ }
+ rowWidth += rbBand.cxIdeal + rect.left + rect.right + 2;
+ }
+ width = Math.max(width, rowWidth);
+ if (redraw) {
+ if (COMCTL32_MAJOR >= 6) {
+ OS.DefWindowProc (handle, OS.WM_SETREDRAW, 1, 0);
+ } else {
+ OS.SendMessage (handle, OS.WM_SETREDRAW, 1, 0);
+ }
+ }
+ ignoreResize = false;
+ }
+ if (width == 0) width = DEFAULT_WIDTH;
+ if (height == 0) height = DEFAULT_HEIGHT;
+ if (wHint != SWT.DEFAULT) width = wHint;
+ if (hHint != SWT.DEFAULT) height = hHint;
+ height += border * 2;
+ width += 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, TCHAR.sizeof);
+ 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;
+ if ((item.style & SWT.DROP_DOWN) != 0) {
+ rbBand.fStyle |= OS.RBBS_USECHEVRON;
+ }
+ rbBand.lpText = lpText;
+ rbBand.wID = id;
+
+ /*
+ * Feature in Windows. When inserting an item at end of a row,
+ * sometimes, Windows will begin to place the item on the right
+ * side of the cool bar. The fix is to resize the new items to
+ * the maximum size and then resize the next to last item to the
+ * ideal size.
+ */
+ int lastIndex = getLastIndexOfRow (index - 1);
+ boolean fixLast = index == lastIndex + 1;
+ if (fixLast) {
+ rbBand.fMask |= OS.RBBIM_SIZE;
+ rbBand.cx = MAX_WIDTH;
+ }
+
+ /*
+ * Feature in Windows. Is possible that the item at index zero
+ * has the RBBS_BREAK flag set. When a new item is inserted at
+ * position zero, the previous item at position zero moves to
+ * a new line. The fix is to detect this case and clear the
+ * RBBS_BREAK flag on the previous item before inserting the
+ * new item.
+ */
+ if (index == 0 && count > 0) {
+ getItem (0).setWrap (false);
+ }
+
+ /* Insert the item */
+ if (OS.SendMessage (handle, OS.RB_INSERTBAND, index, rbBand) == 0) {
+ error (SWT.ERROR_ITEM_NOT_ADDED);
+ }
+
+ /* Resize the next to last item to the ideal size */
+ if (fixLast) {
+ resizeToPreferredWidth (lastIndex);
+ }
+
+ OS.HeapFree (hHeap, 0, lpText);
+ items [item.id = id] = item;
+ int length = originalItems.length;
+ CoolItem [] newOriginals = new CoolItem [length + 1];
+ System.arraycopy (originalItems, 0, newOriginals, 0, index);
+ System.arraycopy (originalItems, index, newOriginals, index + 1, length - index);
+ newOriginals [index] = item;
+ originalItems = newOriginals;
+}
+
+void createWidget () {
+ super.createWidget ();
+ items = new CoolItem [4];
+ originalItems = new CoolItem [0];
+}
+
+void destroyItem (CoolItem item) {
+ int index = OS.SendMessage (handle, OS.RB_IDTOINDEX, item.id, 0);
+ int count = OS.SendMessage (handle, OS.RB_GETBANDCOUNT, 0, 0);
+ if (count != 0) {
+ int lastIndex = getLastIndexOfRow (index);
+ if (index == lastIndex) {
+ /*
+ * Feature in Windows. If the last item in a row is
+ * given its ideal size, it will be placed at the far
+ * right hand edge of the coolbar. It is preferred
+ * that the last item appear next to the second last
+ * item. The fix is to size the last item of each row
+ * so that it occupies all the available space to the
+ * right in the row.
+ */
+ resizeToMaximumWidth (lastIndex - 1);
+ }
+ }
+
+ /*
+ * 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.isDisposed() && control.getVisible ();
+
+ /*
+ * When a wrapped item is being deleted, make the next
+ * item in the row wrapped in order to preserve the row.
+ * In order to avoid an unnecessary layout, temporarily
+ * ignore WM_SIZE. If the next item is wrapped then a
+ * row will be deleted and the WM_SIZE is necessary.
+ */
+ CoolItem nextItem = null;
+ if (item.getWrap ()) {
+ if (index + 1 < count) {
+ nextItem = getItem (index + 1);
+ ignoreResize = !nextItem.getWrap ();
+ }
+ }
+ if (OS.SendMessage (handle, OS.RB_DELETEBAND, index, 0) == 0) {
+ error (SWT.ERROR_ITEM_NOT_REMOVED);
+ }
+ items [item.id] = null;
+ item.id = -1;
+ if (ignoreResize) {
+ nextItem.setWrap (true);
+ ignoreResize = false;
+ }
+
+ /* Restore the visible state tof the control */
+ if (wasVisible) control.setVisible (true);
+
+ index = 0;
+ while (index < originalItems.length) {
+ if (originalItems [index] == item) break;
+ index++;
+ }
+ int length = originalItems.length - 1;
+ CoolItem [] newOriginals = new CoolItem [length];
+ System.arraycopy (originalItems, 0, newOriginals, 0, index);
+ System.arraycopy (originalItems, index + 1, newOriginals, index, length - index);
+ originalItems = newOriginals;
+}
+
+/**
+ * Returns the item that is currently displayed at the given,
+ * zero-relative index. Throws an exception if the index is
+ * out of range.
+ *
+ * @param index the visual index of the item to return
+ * @return the item at the given visual index
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_INVALID_RANGE - if the index is not between 0 and the number of elements in the list minus 1 (inclusive)</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * @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 zero-relative ints that map
+ * the creation order of the receiver's items to the
+ * order in which they are currently being displayed.
+ * <p>
+ * Specifically, the indices of the returned array represent
+ * the current visual order of the items, and the contents
+ * of the array represent the creation order of the items.
+ * </p><p>
+ * Note: This is not the actual structure used by the receiver
+ * to maintain its list of items, so modifying the array will
+ * not affect the receiver.
+ * </p>
+ *
+ * @return the current visual order of the receiver's items
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * @exception SWTError <ul>
+ * <li>ERROR_CANNOT_GET_ITEM - if the operation fails because of an operating system failure</li>
+ * </ul>
+ */
+public int [] getItemOrder () {
+ checkWidget ();
+ int count = OS.SendMessage (handle, OS.RB_GETBANDCOUNT, 0, 0);
+ int [] indices = new int [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);
+ CoolItem item = items [rbBand.wID];
+ int index = 0;
+ while (index<originalItems.length) {
+ if (originalItems [index] == item) break;
+ index++;
+ }
+ if (index == originalItems.length) error (SWT.ERROR_CANNOT_GET_ITEM);
+ indices [i] = index;
+ }
+ return indices;
+}
+
+/**
+ * Returns an array of <code>CoolItem</code>s in the order
+ * in which they are currently being displayed.
+ * <p>
+ * Note: This is not the actual structure used by the receiver
+ * to maintain its list of items, so modifying the array will
+ * not affect the receiver.
+ * </p>
+ *
+ * @return the receiver's items in their current visual order
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * @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;
+}
+
+/**
+ * Returns an array of points whose x and y coordinates describe
+ * the widths and heights (respectively) of the items in the receiver
+ * in the order in which they are currently being displayed.
+ *
+ * @return the receiver's item sizes in their current visual order
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public Point [] getItemSizes () {
+ checkWidget ();
+ int count = OS.SendMessage (handle, OS.RB_GETBANDCOUNT, 0, 0);
+ Point [] sizes = new Point [count];
+ REBARBANDINFO rbBand = new REBARBANDINFO ();
+ rbBand.cbSize = REBARBANDINFO.sizeof;
+ rbBand.fMask = OS.RBBIM_CHILDSIZE;
+ for (int i=0; i<count; i++) {
+ RECT rect = new RECT ();
+ OS.SendMessage (handle, OS.RB_GETRECT, i, rect);
+ OS.SendMessage (handle, OS.RB_GETBANDINFO, i, rbBand);
+ sizes [i] = new Point (rect.right - rect.left + 2, rbBand.cyChild);
+ }
+ return sizes;
+}
+
+int getLastIndexOfRow (int index) {
+ int count = OS.SendMessage (handle, OS.RB_GETBANDCOUNT, 0, 0);
+ if (count == 0) return -1;
+ REBARBANDINFO rbBand = new REBARBANDINFO ();
+ rbBand.cbSize = REBARBANDINFO.sizeof;
+ rbBand.fMask = OS.RBBIM_STYLE;
+ for (int i=index + 1; i<count; i++) {
+ OS.SendMessage (handle, OS.RB_GETBANDINFO, i, rbBand);
+ if ((rbBand.fStyle & OS.RBBS_BREAK) != 0) {
+ return i - 1;
+ }
+ }
+ return count - 1;
+}
+
+/**
+ * Returns whether or not the receiver is 'locked'. When a coolbar
+ * is locked, its items cannot be repositioned.
+ *
+ * @return true if the coolbar is locked, false otherwise
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @since 2.0
+ */
+public boolean getLocked () {
+ checkWidget ();
+ return locked;
+}
+
+/**
+ * Returns an array of ints that describe the zero-relative
+ * indices of any item(s) in the receiver that will begin on
+ * a new row. The 0th visible item always begins the first row,
+ * therefore it does not count as a wrap index.
+ *
+ * @return an array containing the receiver's wrap indices, or an empty array if all items are in one row
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public int [] getWrapIndices () {
+ checkWidget ();
+ 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;
+ }
+ int [] result = new int [count];
+ System.arraycopy (indices, 0, result, 0, count);
+ return result;
+}
+
+/**
+ * Searches the receiver's items in the order they are currently
+ * being displayed, starting at the first item (index 0), until
+ * an item is found that is equal to the argument, and returns
+ * the index of that item. If no item is found, returns -1.
+ *
+ * @param item the search item
+ * @return the visual order index of the search item, or -1 if the item is not found
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if the item is null</li>
+ * <li>ERROR_INVALID_ARGUMENT - if the item is disposed</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public int indexOf (CoolItem item) {
+ checkWidget ();
+ if (item == null) error (SWT.ERROR_NULL_ARGUMENT);
+ if (item.isDisposed()) error (SWT.ERROR_INVALID_ARGUMENT);
+ return OS.SendMessage (handle, OS.RB_IDTOINDEX, item.id, 0);
+}
+
+void resizeToPreferredWidth (int index) {
+ /*
+ * Bug in Windows. When RB_GETBANDBORDERS is sent
+ * with an index out of range, Windows GP's. The
+ * fix is to ensure the index is in range.
+ */
+ int count = OS.SendMessage(handle, OS.RB_GETBANDCOUNT, 0, 0);
+ if (0 <= index && index < count) {
+ REBARBANDINFO rbBand = new REBARBANDINFO();
+ rbBand.cbSize = REBARBANDINFO.sizeof;
+ rbBand.fMask = OS.RBBIM_IDEALSIZE;
+ OS.SendMessage (handle, OS.RB_GETBANDINFO, index, rbBand);
+ RECT rect = new RECT ();
+ OS.SendMessage (handle, OS.RB_GETBANDBORDERS, index, rect);
+ rbBand.cx = rbBand.cxIdeal + rect.left + rect.right;
+ rbBand.fMask = OS.RBBIM_SIZE;
+ OS.SendMessage (handle, OS.RB_SETBANDINFO, index, rbBand);
+ }
+}
+
+void resizeToMaximumWidth (int index) {
+ REBARBANDINFO rbBand = new REBARBANDINFO();
+ rbBand.cbSize = REBARBANDINFO.sizeof;
+ rbBand.fMask = OS.RBBIM_SIZE;
+ rbBand.cx = MAX_WIDTH;
+ OS.SendMessage (handle, OS.RB_SETBANDINFO, index, rbBand);
+}
+
+void releaseWidget () {
+ for (int i=0; i<items.length; i++) {
+ CoolItem item = items [i];
+ if (item != null && !item.isDisposed ()) {
+ item.releaseResources ();
+ }
+ }
+ items = null;
+ super.releaseWidget();
+}
+
+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);
+ }
+}
+
+/**
+ * Sets the receiver's item order, wrap indices, and item sizes
+ * all at once. This method is typically used to restore the
+ * displayed state of the receiver to a previously stored state.
+ * <p>
+ * The item order is the order in which the items in the receiver
+ * should be displayed, given in terms of the zero-relative ordering
+ * of when the items were added.
+ * </p><p>
+ * The wrap indices are the indices of all item(s) in the receiver
+ * that will begin on a new row. The indices are given in the order
+ * specified by the item order. The 0th item always begins the first
+ * row, therefore it does not count as a wrap index. If wrap indices
+ * is null or empty, the items will be placed on one line.
+ * </p><p>
+ * The sizes are specified in an array of points whose x and y
+ * coordinates describe the new widths and heights (respectively)
+ * of the receiver's items in the order specified by the item order.
+ * </p>
+ *
+ * @param itemOrder an array of indices that describe the new order to display the items in
+ * @param wrapIndices an array of wrap indices, or null
+ * @param sizes an array containing the new sizes for each of the receiver's items in visual order
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if item order or sizes is null</li>
+ * <li>ERROR_INVALID_ARGUMENT - if item order or sizes is not the same length as the number of items</li>
+ * </ul>
+ * @exception SWTError <ul>
+ * <li>ERROR_CANNOT_GET_ITEM - if the operation fails because of an operating system failure</li>
+ * </ul>
+ */
+public void setItemLayout (int [] itemOrder, int [] wrapIndices, Point [] sizes) {
+ checkWidget ();
+ setRedraw (false);
+ setItemOrder (itemOrder);
+ setWrapIndices (wrapIndices);
+ setItemSizes (sizes);
+ setRedraw (true);
+}
+
+/*
+ * Sets the order that the items in the receiver should
+ * be displayed in to the given argument which is described
+ * in terms of the zero-relative ordering of when the items
+ * were added.
+ *
+ * @param itemOrder the new order to display the items in
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if the item order is null</li>
+ * <li>ERROR_INVALID_ARGUMENT - if the item order is not the same length as the number of items</li>
+ * </ul>
+ * @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);
+
+ /* Ensure that itemOrder does not contain any duplicates. */
+ boolean [] set = new boolean [itemCount];
+ for (int i=0; i<itemOrder.length; i++) {
+ int index = itemOrder [i];
+ if (index < 0 || index >= itemCount) error (SWT.ERROR_INVALID_RANGE);
+ if (set [index]) error (SWT.ERROR_INVALID_ARGUMENT);
+ set [index] = true;
+ }
+
+ REBARBANDINFO rbBand = new REBARBANDINFO ();
+ rbBand.cbSize = REBARBANDINFO.sizeof;
+ for (int i=0; i<itemOrder.length; i++) {
+ int id = originalItems [itemOrder [i]].id;
+ int index = OS.SendMessage (handle, OS.RB_IDTOINDEX, id, 0);
+ if (index != i) {
+ int lastItemSrcRow = getLastIndexOfRow (index);
+ int lastItemDstRow = getLastIndexOfRow (i);
+ if (index == lastItemSrcRow) {
+ resizeToPreferredWidth (index);
+ }
+ if (i == lastItemDstRow) {
+ resizeToPreferredWidth (i);
+ }
+
+ /* Move the item */
+ OS.SendMessage (handle, OS.RB_MOVEBAND, index, i);
+
+ if (index == lastItemSrcRow && index - 1 >= 0) {
+ resizeToMaximumWidth (index - 1);
+ }
+ if (i == lastItemDstRow) {
+ resizeToMaximumWidth (i);
+ }
+ }
+ }
+}
+
+/*
+ * Sets the width and height of the receiver's 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 in which the items are currently being displayed.
+ *
+ * @param sizes an array containing the new sizes for each of the receiver's items in visual order
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if the array of sizes is null</li>
+ * <li>ERROR_INVALID_ARGUMENT - if the array of sizes is not the same length as the number of items</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - 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);
+ int count = OS.SendMessage (handle, OS.RB_GETBANDCOUNT, 0, 0);
+ if (sizes.length != count) error (SWT.ERROR_INVALID_ARGUMENT);
+ 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);
+ items [rbBand.wID].setSize (sizes [i].x, sizes [i].y);
+ }
+}
+
+/**
+ * Sets whether or not the receiver is 'locked'. When a coolbar
+ * is locked, its items cannot be repositioned.
+ *
+ * @param locked lock the coolbar if true, otherwise unlock the coolbar
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @since 2.0
+ */
+public void setLocked (boolean locked) {
+ checkWidget ();
+ this.locked = locked;
+ int count = OS.SendMessage (handle, OS.RB_GETBANDCOUNT, 0, 0);
+ REBARBANDINFO rbBand = new REBARBANDINFO ();
+ rbBand.cbSize = REBARBANDINFO.sizeof;
+ rbBand.fMask = OS.RBBIM_STYLE;
+ for (int i=0; i<count; i++) {
+ OS.SendMessage (handle, OS.RB_GETBANDINFO, i, rbBand);
+ if (locked) {
+ rbBand.fStyle |= OS.RBBS_NOGRIPPER;
+ } else {
+ rbBand.fStyle &= ~OS.RBBS_NOGRIPPER;
+ }
+ OS.SendMessage (handle, OS.RB_SETBANDINFO, i, rbBand);
+ }
+}
+
+/**
+ * Sets the indices of all item(s) in the receiver that will
+ * begin on a new row. The indices are given in the order in
+ * which they are currently being displayed. The 0th item
+ * always begins the first row, therefore it does not count
+ * as a wrap index. If indices is null or empty, the items
+ * will be placed on one line.
+ *
+ * @param indices an array of wrap indices, or null
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setWrapIndices (int [] indices) {
+ checkWidget ();
+ if (indices == null) indices = new int [0];
+ int count = getItemCount ();
+ for (int i=0; i<indices.length; i++) {
+ if (indices [i] < 0 || indices [i] >= count) {
+ error (SWT.ERROR_INVALID_RANGE);
+ }
+ }
+ setRedraw (false);
+ CoolItem [] items = getItems ();
+ for (int i=0; i<items.length; i++) {
+ CoolItem item = items [i];
+ if (item.getWrap ()) {
+ resizeToPreferredWidth (i - 1);
+ item.setWrap (false);
+ }
+ }
+ resizeToMaximumWidth (count - 1);
+ for (int i=0; i<indices.length; i++) {
+ int index = indices [i];
+ if (0 <= index && index < items.length) {
+ CoolItem item = items [index];
+ item.setWrap (true);
+ resizeToMaximumWidth (index - 1);
+ }
+ }
+ setRedraw (true);
+}
+
+int widgetStyle () {
+ int bits = super.widgetStyle () | OS.CCS_NODIVIDER | OS.CCS_NORESIZE;
+ bits |= OS.RBS_VARHEIGHT | OS.RBS_BANDBORDERS | OS.RBS_DBLCLKTOGGLE;
+ return bits;
+}
+
+TCHAR 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 its parent. This is done so that
+ * children of this control that send this message
+ * type to their parent will notify not only
+ * this control but also the parent of this control,
+ * which is typically the application window and
+ * the window that is looking for the message.
+ * If the control did not forward the message,
+ * applications would have to subclass the control
+ * window to see the message. Because the control
+ * window is subclassed by SWT, the message
+ * is delivered twice, once by SWT and once when
+ * the message is forwarded by the window proc.
+ * The fix is to avoid calling the window proc
+ * for this control.
+ */
+ LRESULT result = super.WM_COMMAND (wParam, lParam);
+ if (result != null) return result;
+ return LRESULT.ZERO;
+}
+
+LRESULT WM_ERASEBKGND (int wParam, int lParam) {
+ LRESULT result = super.WM_ERASEBKGND (wParam, lParam);
+ if (result != null) return result;
+
+ /*
+ * 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 is larger
+ * than the space occupied by the cool bar items.
+ * The fix is to erase the cool bar background.
+ */
+ drawBackground (wParam);
+
+ /*
+ * NOTE: The cool bar draws separators in WM_ERASEBKGND
+ * so it is essential to run the cool bar window proc
+ * after the background has been erased.
+ */
+ return null;
+}
+
+LRESULT WM_NOTIFY (int wParam, int lParam) {
+ /*
+ * Feature in Windows. When the cool bar window
+ * proc processes WM_NOTIFY, it forwards this
+ * message to its parent. This is done so that
+ * children of this control that send this message
+ * type to their parent will notify not only
+ * this control but also the parent of this control,
+ * which is typically the application window and
+ * the window that is looking for the message.
+ * If the control did not forward the message,
+ * applications would have to subclass the control
+ * window to see the message. Because the control
+ * window is subclassed by SWT, the message
+ * is delivered twice, once by SWT and once when
+ * the message is forwarded by the window proc.
+ * The fix is to avoid calling the window proc
+ * for this control.
+ */
+ LRESULT result = super.WM_NOTIFY (wParam, lParam);
+ if (result != null) return result;
+ return LRESULT.ZERO;
+}
+
+LRESULT WM_SETREDRAW (int wParam, int lParam) {
+ LRESULT result = super.WM_SETREDRAW (wParam, lParam);
+ if (result != null) return result;
+ /*
+ * Feature in Windows. When redraw is turned off, the rebar
+ * control does not call the default window proc. This means
+ * that the rebar will redraw and children of the rebar will
+ * also redraw. The fix is to call both the rebar window proc
+ * and the default window proc.
+ *
+ * NOTE: The rebar control can resize itself in WM_SETREDRAW.
+ * When redraw is turned off by the default window proc, this
+ * can leave pixel corruption in the parent. The fix is to
+ * detect the size change and damage the previous area in the
+ * parent.
+ *
+ * NOTE: In version 6.00 of COMCTL32.DLL, when WM_SETREDRAW
+ * is off, we cannot detect that the size has changed causing
+ * pixel corruption. The fix is to disallow WM_SETREDRAW by
+ * by not running the default window proc or the rebar window
+ * proc.
+ */
+ if (COMCTL32_MAJOR >= 6) return LRESULT.ZERO;
+ Rectangle rect = getBounds ();
+ int code = callWindowProc (OS.WM_SETREDRAW, wParam, lParam);
+ OS.DefWindowProc (handle, OS.WM_SETREDRAW, wParam, lParam);
+ if (!rect.equals (getBounds ())) {
+ parent.redraw (rect.x, rect.y, rect.width, rect.height, true);
+ }
+ return new LRESULT (code);
+}
+
+LRESULT WM_SIZE(int wParam, int lParam) {
+ if (ignoreResize) {
+ int code = callWindowProc (OS.WM_SIZE, wParam, lParam);
+ if (code == 0) return LRESULT.ZERO;
+ return new LRESULT (code);
+ }
+ return super.WM_SIZE(wParam, lParam);
+}
+
+LRESULT wmNotifyChild (int wParam, int lParam) {
+ NMHDR hdr = new NMHDR ();
+ OS.MoveMemory (hdr, lParam, NMHDR.sizeof);
+ switch (hdr.code) {
+ case OS.RBN_HEIGHTCHANGE:
+ if (!ignoreResize) {
+ Point size = getSize ();
+ int border = getBorderWidth ();
+ int height = OS.SendMessage (handle, OS.RB_GETBARHEIGHT, 0, 0);
+ setSize (size.x, height + (border * 2));
+ }
+ break;
+ case OS.RBN_CHEVRONPUSHED:
+ NMREBARCHEVRON lpnm = new NMREBARCHEVRON ();
+ OS.MoveMemory (lpnm, lParam, NMREBARCHEVRON.sizeof);
+ CoolItem child = items [lpnm.wID];
+ if (child != null) {
+ Event event = new Event();
+ event.detail = SWT.ARROW;
+ event.x = lpnm.left;
+ event.y = lpnm.bottom;
+ child.postEvent (SWT.Selection, event);
+ }
+ break;
+ }
+ return super.wmNotifyChild (wParam, lParam);
+}
+}
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
index 46445eb1bf..867f632234 100755
--- 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
@@ -1,665 +1,665 @@
-package org.eclipse.swt.widgets;
-
-/*
+package org.eclipse.swt.widgets;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-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>DROP_DOWN</dd>
- * <dt><b>Events:</b></dt>
- * <dd>Selection</dd>
- * </dl>
- * <p>
- * IMPORTANT: This class is <em>not</em> intended to be subclassed.
- * </p>
- */
-
-public class CoolItem extends Item {
- CoolBar parent;
- Control control;
- int id;
- boolean ideal, minimum;
-
-/**
- * Constructs a new instance of this class given its parent
- * (which must be a <code>CoolBar</code>) and a style value
- * describing its behavior and appearance. The item is added
- * to the end of the items maintained by its parent.
- * <p>
- * The style value is either one of the style constants defined in
- * class <code>SWT</code> which is applicable to instances of this
- * class, or must be built by <em>bitwise OR</em>'ing together
- * (that is, using the <code>int</code> "|" operator) two or more
- * of those <code>SWT</code> style constants. The class description
- * lists the style constants that are applicable to the class.
- * Style bits are also inherited from superclasses.
- * </p>
- *
- * @param parent a composite control which will be the parent of the new instance (cannot be null)
- * @param style the style of control to construct
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
- * <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
- * </ul>
- *
- * @see SWT#DROP_DOWN
- * @see Widget#checkSubclass
- * @see Widget#getStyle
- */
-public CoolItem (CoolBar parent, int style) {
- super (parent, style);
- this.parent = parent;
- parent.createItem (this, parent.getItemCount ());
-}
-
-/**
- * Constructs a new instance of this class given its parent
- * (which must be a <code>CoolBar</code>), a style value
- * describing its behavior and appearance, and the index
- * at which to place it in the items maintained by its parent.
- * <p>
- * The style value is either one of the style constants defined in
- * class <code>SWT</code> which is applicable to instances of this
- * class, or must be built by <em>bitwise OR</em>'ing together
- * (that is, using the <code>int</code> "|" operator) two or more
- * of those <code>SWT</code> style constants. The class description
- * lists the style constants that are applicable to the class.
- * Style bits are also inherited from superclasses.
- * </p>
- *
- * @param parent a composite control which will be the parent of the new instance (cannot be null)
- * @param style the style of control to construct
- * @param index the index at which 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#DROP_DOWN
- * @see Widget#checkSubclass
- * @see Widget#getStyle
- */
-public CoolItem (CoolBar parent, int style, int index) {
- super (parent, style);
- this.parent = parent;
- parent.createItem (this, index);
-}
-
-/**
- * Adds the listener to the collection of listeners that will
- * be notified when the control is selected, by sending it one
- * of the messages defined in the <code>SelectionListener</code>
- * interface.
- * <p>
- * If <code>widgetSelected</code> is called when the mouse is over
- * the drop-down arrow (or 'chevron') portion of the cool item,
- * the event object detail field contains the value <code>SWT.ARROW</code>,
- * and the x and y fields in the event object represent the point at
- * the bottom left of the chevron, where the menu should be popped up.
- * <code>widgetDefaultSelected</code> is not called.
- * </p>
- *
- * @param listener the listener which should be notified
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see SelectionListener
- * @see #removeSelectionListener
- * @see SelectionEvent
- *
- * @since 2.0
- */
-public void addSelectionListener(SelectionListener listener) {
- checkWidget();
- if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
- TypedListener typedListener = new TypedListener (listener);
- addListener (SWT.Selection,typedListener);
- addListener (SWT.DefaultSelection,typedListener);
-}
-
-protected void checkSubclass () {
- if (!isValidSubclass ()) error (SWT.ERROR_INVALID_SUBCLASS);
-}
-
-/**
- * Returns the preferred size of the receiver.
- * <p>
- * The <em>preferred size</em> of a <code>CoolItem</code> is the size that
- * it would best be displayed at. The width hint and height hint arguments
- * allow the caller to ask the instance questions such as "Given a particular
- * width, how high does it need to be to show all of the contents?"
- * To indicate that the caller does not wish to constrain a particular
- * dimension, the constant <code>SWT.DEFAULT</code> is passed for the hint.
- * </p>
- *
- * @param wHint the width hint (can be <code>SWT.DEFAULT</code>)
- * @param hHint the height hint (can be <code>SWT.DEFAULT</code>)
- * @return the preferred size
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see Layout
- * @see #getBounds
- * @see #getSize
- * @see CoolBar#getBorderWidth
- * @see CoolBar#computeTrim
- * @see CoolBar#getClientArea
- */
-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 + 2;
- 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 + 2;
- 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);
-}
-
-/**
- * Returns the control that is associated with the receiver.
- *
- * @return the control that is contained by the receiver
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public Control getControl () {
- checkWidget ();
- return control;
-}
-
-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 that is associated with the receiver
- * to the argument.
- *
- * @param control the new control that will be contained by the receiver
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_INVALID_ARGUMENT - if the control has been disposed</li>
- * <li>ERROR_INVALID_PARENT - if the control is not in the same widget tree</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public void setControl (Control control) {
- checkWidget ();
- if (control != null) {
- if (control.isDisposed()) error (SWT.ERROR_INVALID_ARGUMENT);
- if (control.parent != parent) error (SWT.ERROR_INVALID_PARENT);
- }
- int index = parent.indexOf (this);
- if (index == -1) return;
- if (this.control != null && this.control.isDisposed ()) {
- this.control = null;
- }
- Control oldControl = this.control, newControl = 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 and
- * moves the new child to the top of the Z-order. The fix is
- * to save and restore the visibility and Z-order.
- */
- int hwndAbove = 0;
- if (newControl != null) {
- hwndAbove = OS.GetWindow (hwndChild, OS.GW_HWNDPREV);
- }
- 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);
- if (hwndAbove != 0 && hwndAbove != hwndChild) {
- int flags = OS.SWP_NOSIZE | OS.SWP_NOMOVE | OS.SWP_NOACTIVATE;
- OS.SetWindowPos (hwndChild, hwndAbove, 0, 0, 0, 0, flags);
- }
-}
-
-/**
- * Returns a point describing the receiver's ideal size.
- * The x coordinate of the result is the ideal width of the receiver.
- * The y coordinate of the result is the ideal height of the receiver.
- *
- * @return the receiver's ideal size
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public Point getPreferredSize () {
- checkWidget ();
- int index = parent.indexOf (this);
- if (index == -1) return new Point (0, 0);
- 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);
- RECT rect = new RECT ();
- OS.SendMessage (hwnd, OS.RB_GETBANDBORDERS, index, rect);
- int width = rbBand.cxIdeal + rect.left + rect.right + 2;
- return new Point (width, rbBand.cyMinChild);
-}
-
-/**
- * Sets the receiver's ideal size to the point specified by the arguments.
- *
- * @param width the new ideal width for the receiver
- * @param height the new ideal height for the receiver
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public void setPreferredSize (int width, int height) {
- checkWidget ();
- int index = parent.indexOf (this);
- if (index == -1) return;
- ideal = true;
- int hwnd = parent.handle;
- RECT rect = new RECT ();
- OS.SendMessage (hwnd, OS.RB_GETBANDBORDERS, index, rect);
- REBARBANDINFO rbBand = new REBARBANDINFO ();
- rbBand.cbSize = REBARBANDINFO.sizeof;
-
- /* Get the child size fields first so we don't overwrite them. */
- rbBand.fMask = OS.RBBIM_CHILDSIZE;
- OS.SendMessage (hwnd, OS.RB_GETBANDINFO, index, rbBand);
-
- /* Set the size fields we are currently modifying. */
- rbBand.fMask = OS.RBBIM_CHILDSIZE | OS.RBBIM_IDEALSIZE;
- rbBand.cxIdeal = width - rect.left - rect.right - 2;
- rbBand.cyMaxChild = height;
- if (!minimum) rbBand.cyMinChild = height;
- OS.SendMessage (hwnd, OS.RB_SETBANDINFO, index, rbBand);
-}
-
-/**
- * Sets the receiver's ideal size to the point specified by the argument.
- *
- * @param size the new ideal size for the receiver
- * @param height the new ideal 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 setPreferredSize (Point size) {
- checkWidget ();
- if (size == null) error(SWT.ERROR_NULL_ARGUMENT);
- setPreferredSize (size.x, size.y);
-}
-
-/**
- * Returns a point describing the receiver's size. The
- * x coordinate of the result is the width of the receiver.
- * The y coordinate of the result is the height of the
- * receiver.
- *
- * @return the receiver's size
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public Point getSize() {
- checkWidget ();
- int index = parent.indexOf (this);
- if (index == -1) new Point (0, 0);
- int hwnd = parent.handle;
- RECT rect = new RECT ();
- OS.SendMessage (hwnd, OS.RB_GETRECT, index, rect);
- int width = rect.right - rect.left + 2;
- int height = rect.bottom - rect.top;
- return new Point (width, height);
-}
-
-/**
- * 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 ();
- int index = parent.indexOf (this);
- if (index == -1) return;
- int hwnd = parent.handle;
- REBARBANDINFO rbBand = new REBARBANDINFO ();
- rbBand.cbSize = REBARBANDINFO.sizeof;
-
- /*
- * Do not set the size for the last item on the row.
- */
- int count = OS.SendMessage (hwnd, OS.RB_GETBANDCOUNT, 0, 0);
- boolean isLastItem;
- if (index + 1 == count) {
- isLastItem = true;
- } else {
- rbBand.fMask = OS.RBBIM_STYLE;
- OS.SendMessage (hwnd, OS.RB_GETBANDINFO, index + 1, rbBand);
- isLastItem = (rbBand.fStyle & OS.RBBS_BREAK) != 0;
- rbBand.fMask = 0;
- }
-
- /* Get the child size fields first so we don't overwrite them. */
- rbBand.fMask = OS.RBBIM_CHILDSIZE | OS.RBBIM_IDEALSIZE;
- OS.SendMessage (hwnd, OS.RB_GETBANDINFO, index, rbBand);
-
- /* Set the size fields we are currently modifying. */
- rbBand.fMask = OS.RBBIM_CHILDSIZE | OS.RBBIM_IDEALSIZE;
- if (!ideal) {
- RECT rect = new RECT ();
- OS.SendMessage (hwnd, OS.RB_GETBANDBORDERS, index, rect);
- rbBand.cxIdeal = width - rect.left - rect.right - 2;
- }
- if (!minimum) rbBand.cyMinChild = height;
- rbBand.cyChild = rbBand.cyMaxChild = height;
- if (!isLastItem) {
- rbBand.cx = width - 2;
- rbBand.fMask |= OS.RBBIM_SIZE;
- }
- OS.SendMessage (hwnd, OS.RB_SETBANDINFO, index, rbBand);
-}
-
-/**
- * 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) {
- if (size == null) error(SWT.ERROR_NULL_ARGUMENT);
- setSize (size.x, size.y);
-}
-
-/**
- * Returns the minimum size that the cool item can
- * be resized to using the cool item's gripper.
- *
- * @return a point containing the minimum width and height of the cool item, in pixels
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @since 2.0
- */
-public Point getMinimumSize () {
- checkWidget ();
- int index = parent.indexOf (this);
- if (index == -1) return new Point (0, 0);
- int hwnd = parent.handle;
- REBARBANDINFO rbBand = new REBARBANDINFO ();
- rbBand.cbSize = REBARBANDINFO.sizeof;
- rbBand.fMask = OS.RBBIM_CHILDSIZE;
- OS.SendMessage (hwnd, OS.RB_GETBANDINFO, index, rbBand);
- return new Point (rbBand.cxMinChild, rbBand.cyMinChild);
-}
-
-/**
- * Sets the minimum size that the cool item can be resized to
- * using the cool item's gripper, to the point specified by the arguments.
- *
- * @param width the minimum width of the cool item, in pixels
- * @param height the minimum height of the cool item, in pixels
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @since 2.0
- */
-public void setMinimumSize (int width, int height) {
- checkWidget ();
- int index = parent.indexOf (this);
- if (index == -1) return;
- minimum = true;
- int hwnd = parent.handle;
- REBARBANDINFO rbBand = new REBARBANDINFO ();
- rbBand.cbSize = REBARBANDINFO.sizeof;
-
- /* Get the child size fields first so we don't overwrite them. */
- rbBand.fMask = OS.RBBIM_CHILDSIZE;
- OS.SendMessage (hwnd, OS.RB_GETBANDINFO, index, rbBand);
-
- /* Set the size fields we are currently modifying. */
- rbBand.cxMinChild = width;
- rbBand.cyMinChild = height;
- OS.SendMessage (hwnd, OS.RB_SETBANDINFO, index, rbBand);
-}
-
-/**
- * Sets the minimum size that the cool item can be resized to
- * using the cool item's gripper, to the point specified by the argument.
- *
- * @param size a point representing the minimum width and height of the cool item, in pixels
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the point is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @since 2.0
- */
-public void setMinimumSize (Point size) {
- checkWidget ();
- if (size == null) error (SWT.ERROR_NULL_ARGUMENT);
- setMinimumSize (size.x, size.y);
-}
-
-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;
- OS.SendMessage (hwnd, OS.RB_GETBANDINFO, index, rbBand);
- if (wrap) {
- rbBand.fStyle |= OS.RBBS_BREAK;
- } else {
- rbBand.fStyle &= ~OS.RBBS_BREAK;
- }
- OS.SendMessage (hwnd, OS.RB_SETBANDINFO, index, rbBand);
-}
-
-/**
- * Removes the listener from the collection of listeners that
- * 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
- *
- * @since 2.0
- */
-public void removeSelectionListener(SelectionListener listener) {
- checkWidget();
- if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
- if (eventTable == null) return;
- eventTable.unhook (SWT.Selection, listener);
- eventTable.unhook (SWT.DefaultSelection,listener);
-}
-
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+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>DROP_DOWN</dd>
+ * <dt><b>Events:</b></dt>
+ * <dd>Selection</dd>
+ * </dl>
+ * <p>
+ * IMPORTANT: This class is <em>not</em> intended to be subclassed.
+ * </p>
+ */
+
+public class CoolItem extends Item {
+ CoolBar parent;
+ Control control;
+ int id;
+ boolean ideal, minimum;
+
+/**
+ * Constructs a new instance of this class given its parent
+ * (which must be a <code>CoolBar</code>) and a style value
+ * describing its behavior and appearance. The item is added
+ * to the end of the items maintained by its parent.
+ * <p>
+ * The style value is either one of the style constants defined in
+ * class <code>SWT</code> which is applicable to instances of this
+ * class, or must be built by <em>bitwise OR</em>'ing together
+ * (that is, using the <code>int</code> "|" operator) two or more
+ * of those <code>SWT</code> style constants. The class description
+ * lists the style constants that are applicable to the class.
+ * Style bits are also inherited from superclasses.
+ * </p>
+ *
+ * @param parent a composite control which will be the parent of the new instance (cannot be null)
+ * @param style the style of control to construct
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
+ * <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
+ * </ul>
+ *
+ * @see SWT#DROP_DOWN
+ * @see Widget#checkSubclass
+ * @see Widget#getStyle
+ */
+public CoolItem (CoolBar parent, int style) {
+ super (parent, style);
+ this.parent = parent;
+ parent.createItem (this, parent.getItemCount ());
+}
+
+/**
+ * Constructs a new instance of this class given its parent
+ * (which must be a <code>CoolBar</code>), a style value
+ * describing its behavior and appearance, and the index
+ * at which to place it in the items maintained by its parent.
+ * <p>
+ * The style value is either one of the style constants defined in
+ * class <code>SWT</code> which is applicable to instances of this
+ * class, or must be built by <em>bitwise OR</em>'ing together
+ * (that is, using the <code>int</code> "|" operator) two or more
+ * of those <code>SWT</code> style constants. The class description
+ * lists the style constants that are applicable to the class.
+ * Style bits are also inherited from superclasses.
+ * </p>
+ *
+ * @param parent a composite control which will be the parent of the new instance (cannot be null)
+ * @param style the style of control to construct
+ * @param index the index at which 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#DROP_DOWN
+ * @see Widget#checkSubclass
+ * @see Widget#getStyle
+ */
+public CoolItem (CoolBar parent, int style, int index) {
+ super (parent, style);
+ this.parent = parent;
+ parent.createItem (this, index);
+}
+
+/**
+ * Adds the listener to the collection of listeners that will
+ * be notified when the control is selected, by sending it one
+ * of the messages defined in the <code>SelectionListener</code>
+ * interface.
+ * <p>
+ * If <code>widgetSelected</code> is called when the mouse is over
+ * the drop-down arrow (or 'chevron') portion of the cool item,
+ * the event object detail field contains the value <code>SWT.ARROW</code>,
+ * and the x and y fields in the event object represent the point at
+ * the bottom left of the chevron, where the menu should be popped up.
+ * <code>widgetDefaultSelected</code> is not called.
+ * </p>
+ *
+ * @param listener the listener which should be notified
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see SelectionListener
+ * @see #removeSelectionListener
+ * @see SelectionEvent
+ *
+ * @since 2.0
+ */
+public void addSelectionListener(SelectionListener listener) {
+ checkWidget();
+ if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+ TypedListener typedListener = new TypedListener (listener);
+ addListener (SWT.Selection,typedListener);
+ addListener (SWT.DefaultSelection,typedListener);
+}
+
+protected void checkSubclass () {
+ if (!isValidSubclass ()) error (SWT.ERROR_INVALID_SUBCLASS);
+}
+
+/**
+ * Returns the preferred size of the receiver.
+ * <p>
+ * The <em>preferred size</em> of a <code>CoolItem</code> is the size that
+ * it would best be displayed at. The width hint and height hint arguments
+ * allow the caller to ask the instance questions such as "Given a particular
+ * width, how high does it need to be to show all of the contents?"
+ * To indicate that the caller does not wish to constrain a particular
+ * dimension, the constant <code>SWT.DEFAULT</code> is passed for the hint.
+ * </p>
+ *
+ * @param wHint the width hint (can be <code>SWT.DEFAULT</code>)
+ * @param hHint the height hint (can be <code>SWT.DEFAULT</code>)
+ * @return the preferred size
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see Layout
+ * @see #getBounds
+ * @see #getSize
+ * @see CoolBar#getBorderWidth
+ * @see CoolBar#computeTrim
+ * @see CoolBar#getClientArea
+ */
+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 + 2;
+ 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 + 2;
+ 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);
+}
+
+/**
+ * Returns the control that is associated with the receiver.
+ *
+ * @return the control that is contained by the receiver
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public Control getControl () {
+ checkWidget ();
+ return control;
+}
+
+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 that is associated with the receiver
+ * to the argument.
+ *
+ * @param control the new control that will be contained by the receiver
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_INVALID_ARGUMENT - if the control has been disposed</li>
+ * <li>ERROR_INVALID_PARENT - if the control is not in the same widget tree</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setControl (Control control) {
+ checkWidget ();
+ if (control != null) {
+ if (control.isDisposed()) error (SWT.ERROR_INVALID_ARGUMENT);
+ if (control.parent != parent) error (SWT.ERROR_INVALID_PARENT);
+ }
+ int index = parent.indexOf (this);
+ if (index == -1) return;
+ if (this.control != null && this.control.isDisposed ()) {
+ this.control = null;
+ }
+ Control oldControl = this.control, newControl = 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 and
+ * moves the new child to the top of the Z-order. The fix is
+ * to save and restore the visibility and Z-order.
+ */
+ int hwndAbove = 0;
+ if (newControl != null) {
+ hwndAbove = OS.GetWindow (hwndChild, OS.GW_HWNDPREV);
+ }
+ 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);
+ if (hwndAbove != 0 && hwndAbove != hwndChild) {
+ int flags = OS.SWP_NOSIZE | OS.SWP_NOMOVE | OS.SWP_NOACTIVATE;
+ OS.SetWindowPos (hwndChild, hwndAbove, 0, 0, 0, 0, flags);
+ }
+}
+
+/**
+ * Returns a point describing the receiver's ideal size.
+ * The x coordinate of the result is the ideal width of the receiver.
+ * The y coordinate of the result is the ideal height of the receiver.
+ *
+ * @return the receiver's ideal size
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public Point getPreferredSize () {
+ checkWidget ();
+ int index = parent.indexOf (this);
+ if (index == -1) return new Point (0, 0);
+ 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);
+ RECT rect = new RECT ();
+ OS.SendMessage (hwnd, OS.RB_GETBANDBORDERS, index, rect);
+ int width = rbBand.cxIdeal + rect.left + rect.right + 2;
+ return new Point (width, rbBand.cyMinChild);
+}
+
+/**
+ * Sets the receiver's ideal size to the point specified by the arguments.
+ *
+ * @param width the new ideal width for the receiver
+ * @param height the new ideal height for the receiver
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setPreferredSize (int width, int height) {
+ checkWidget ();
+ int index = parent.indexOf (this);
+ if (index == -1) return;
+ ideal = true;
+ int hwnd = parent.handle;
+ RECT rect = new RECT ();
+ OS.SendMessage (hwnd, OS.RB_GETBANDBORDERS, index, rect);
+ REBARBANDINFO rbBand = new REBARBANDINFO ();
+ rbBand.cbSize = REBARBANDINFO.sizeof;
+
+ /* Get the child size fields first so we don't overwrite them. */
+ rbBand.fMask = OS.RBBIM_CHILDSIZE;
+ OS.SendMessage (hwnd, OS.RB_GETBANDINFO, index, rbBand);
+
+ /* Set the size fields we are currently modifying. */
+ rbBand.fMask = OS.RBBIM_CHILDSIZE | OS.RBBIM_IDEALSIZE;
+ rbBand.cxIdeal = width - rect.left - rect.right - 2;
+ rbBand.cyMaxChild = height;
+ if (!minimum) rbBand.cyMinChild = height;
+ OS.SendMessage (hwnd, OS.RB_SETBANDINFO, index, rbBand);
+}
+
+/**
+ * Sets the receiver's ideal size to the point specified by the argument.
+ *
+ * @param size the new ideal size for the receiver
+ * @param height the new ideal 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 setPreferredSize (Point size) {
+ checkWidget ();
+ if (size == null) error(SWT.ERROR_NULL_ARGUMENT);
+ setPreferredSize (size.x, size.y);
+}
+
+/**
+ * Returns a point describing the receiver's size. The
+ * x coordinate of the result is the width of the receiver.
+ * The y coordinate of the result is the height of the
+ * receiver.
+ *
+ * @return the receiver's size
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public Point getSize() {
+ checkWidget ();
+ int index = parent.indexOf (this);
+ if (index == -1) new Point (0, 0);
+ int hwnd = parent.handle;
+ RECT rect = new RECT ();
+ OS.SendMessage (hwnd, OS.RB_GETRECT, index, rect);
+ int width = rect.right - rect.left + 2;
+ int height = rect.bottom - rect.top;
+ return new Point (width, height);
+}
+
+/**
+ * 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 ();
+ int index = parent.indexOf (this);
+ if (index == -1) return;
+ int hwnd = parent.handle;
+ REBARBANDINFO rbBand = new REBARBANDINFO ();
+ rbBand.cbSize = REBARBANDINFO.sizeof;
+
+ /*
+ * Do not set the size for the last item on the row.
+ */
+ int count = OS.SendMessage (hwnd, OS.RB_GETBANDCOUNT, 0, 0);
+ boolean isLastItem;
+ if (index + 1 == count) {
+ isLastItem = true;
+ } else {
+ rbBand.fMask = OS.RBBIM_STYLE;
+ OS.SendMessage (hwnd, OS.RB_GETBANDINFO, index + 1, rbBand);
+ isLastItem = (rbBand.fStyle & OS.RBBS_BREAK) != 0;
+ rbBand.fMask = 0;
+ }
+
+ /* Get the child size fields first so we don't overwrite them. */
+ rbBand.fMask = OS.RBBIM_CHILDSIZE | OS.RBBIM_IDEALSIZE;
+ OS.SendMessage (hwnd, OS.RB_GETBANDINFO, index, rbBand);
+
+ /* Set the size fields we are currently modifying. */
+ rbBand.fMask = OS.RBBIM_CHILDSIZE | OS.RBBIM_IDEALSIZE;
+ if (!ideal) {
+ RECT rect = new RECT ();
+ OS.SendMessage (hwnd, OS.RB_GETBANDBORDERS, index, rect);
+ rbBand.cxIdeal = width - rect.left - rect.right - 2;
+ }
+ if (!minimum) rbBand.cyMinChild = height;
+ rbBand.cyChild = rbBand.cyMaxChild = height;
+ if (!isLastItem) {
+ rbBand.cx = width - 2;
+ rbBand.fMask |= OS.RBBIM_SIZE;
+ }
+ OS.SendMessage (hwnd, OS.RB_SETBANDINFO, index, rbBand);
+}
+
+/**
+ * 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) {
+ if (size == null) error(SWT.ERROR_NULL_ARGUMENT);
+ setSize (size.x, size.y);
+}
+
+/**
+ * Returns the minimum size that the cool item can
+ * be resized to using the cool item's gripper.
+ *
+ * @return a point containing the minimum width and height of the cool item, in pixels
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @since 2.0
+ */
+public Point getMinimumSize () {
+ checkWidget ();
+ int index = parent.indexOf (this);
+ if (index == -1) return new Point (0, 0);
+ int hwnd = parent.handle;
+ REBARBANDINFO rbBand = new REBARBANDINFO ();
+ rbBand.cbSize = REBARBANDINFO.sizeof;
+ rbBand.fMask = OS.RBBIM_CHILDSIZE;
+ OS.SendMessage (hwnd, OS.RB_GETBANDINFO, index, rbBand);
+ return new Point (rbBand.cxMinChild, rbBand.cyMinChild);
+}
+
+/**
+ * Sets the minimum size that the cool item can be resized to
+ * using the cool item's gripper, to the point specified by the arguments.
+ *
+ * @param width the minimum width of the cool item, in pixels
+ * @param height the minimum height of the cool item, in pixels
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @since 2.0
+ */
+public void setMinimumSize (int width, int height) {
+ checkWidget ();
+ int index = parent.indexOf (this);
+ if (index == -1) return;
+ minimum = true;
+ int hwnd = parent.handle;
+ REBARBANDINFO rbBand = new REBARBANDINFO ();
+ rbBand.cbSize = REBARBANDINFO.sizeof;
+
+ /* Get the child size fields first so we don't overwrite them. */
+ rbBand.fMask = OS.RBBIM_CHILDSIZE;
+ OS.SendMessage (hwnd, OS.RB_GETBANDINFO, index, rbBand);
+
+ /* Set the size fields we are currently modifying. */
+ rbBand.cxMinChild = width;
+ rbBand.cyMinChild = height;
+ OS.SendMessage (hwnd, OS.RB_SETBANDINFO, index, rbBand);
+}
+
+/**
+ * Sets the minimum size that the cool item can be resized to
+ * using the cool item's gripper, to the point specified by the argument.
+ *
+ * @param size a point representing the minimum width and height of the cool item, in pixels
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if the point is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @since 2.0
+ */
+public void setMinimumSize (Point size) {
+ checkWidget ();
+ if (size == null) error (SWT.ERROR_NULL_ARGUMENT);
+ setMinimumSize (size.x, size.y);
+}
+
+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;
+ OS.SendMessage (hwnd, OS.RB_GETBANDINFO, index, rbBand);
+ if (wrap) {
+ rbBand.fStyle |= OS.RBBS_BREAK;
+ } else {
+ rbBand.fStyle &= ~OS.RBBS_BREAK;
+ }
+ OS.SendMessage (hwnd, OS.RB_SETBANDINFO, index, rbBand);
+}
+
+/**
+ * Removes the listener from the collection of listeners that
+ * 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
+ *
+ * @since 2.0
+ */
+public void removeSelectionListener(SelectionListener listener) {
+ checkWidget();
+ if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+ if (eventTable == null) return;
+ eventTable.unhook (SWT.Selection, listener);
+ eventTable.unhook (SWT.DefaultSelection,listener);
+}
+
+}
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
index 0e05b7bf9a..b634682a12 100755
--- 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
@@ -1,1364 +1,1364 @@
-package org.eclipse.swt.widgets;
-
-/*
+package org.eclipse.swt.widgets;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-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), its appearance is controlled by
- * the style constants which were specified when it was created
- * and the restrictions of the window manager (see below).
- * </li><li>
- * When an instance has been marked as <em>minimized</em>,
- * its contents (client area) will usually not be visible,
- * and depending on the window manager, it may be
- * "iconified" (that is, replaced on the desktop by a small
- * simplified representation of itself), relocated to a
- * distinguished area of the screen, or hidden. Combinations
- * of these changes are also possible.
- * </li>
- * </ul>
- * </p>
- * Note: The styles supported by this class must be treated
- * as <em>HINT</em>s, since the window manager for the
- * desktop on which the instance is visible has ultimate
- * control over the appearance and behavior of decorations.
- * For example, some window managers only support resizable
- * windows and will always assume the RESIZE style, even if
- * it is not set.
- * <dl>
- * <dt><b>Styles:</b></dt>
- * <dd>BORDER, CLOSE, MIN, MAX, NO_TRIM, RESIZE, TITLE, ON_TOP, TOOL</dd>
- * <dt><b>Events:</b></dt>
- * <dd>(none)</dd>
- * </dl>
- * Class <code>SWT</code> provides two "convenience constants"
- * for the most commonly required style combinations:
- * <dl>
- * <dt><code>SHELL_TRIM</code></dt>
- * <dd>
- * the result of combining the constants which are required
- * to produce a typical application top level shell: (that
- * is, <code>CLOSE | TITLE | MIN | MAX | RESIZE</code>)
- * </dd>
- * <dt><code>DIALOG_TRIM</code></dt>
- * <dd>
- * the result of combining the constants which are required
- * to produce a typical application dialog shell: (that
- * is, <code>TITLE | CLOSE | BORDER</code>)
- * </dd>
- * </dl>
- * <p>
- * IMPORTANT: This class is intended to be subclassed <em>only</em>
- * within the SWT implementation.
- * </p>
- *
- * @see #getMinimized
- * @see #getMaximized
- * @see Shell
- * @see SWT
- */
-
-public class Decorations extends Canvas {
- Image image;
- Menu menuBar;
- Menu [] menus;
- MenuItem [] items;
- Control savedFocus;
- Button defaultButton, saveDefault;
- int swFlags, hAccel, nAccel, hIcon;
-
- /*
- * The start value for WM_COMMAND id's.
- * Windows reserves the values 0..100.
- *
- * The SmartPhone SWT resource file reserves
- * the values 101..107.
- */
- static final int ID_START = 108;
-
-/**
- * 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
- * lists the style constants that are applicable to the class.
- * Style bits are also inherited from superclasses.
- * </p>
- *
- * @param parent a composite control which will be the parent of the new instance (cannot be null)
- * @param style the style of control to construct
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
- * <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
- * </ul>
- *
- * @see SWT#BORDER
- * @see SWT#CLOSE
- * @see SWT#MIN
- * @see SWT#MAX
- * @see SWT#RESIZE
- * @see SWT#TITLE
- * @see SWT#NO_TRIM
- * @see SWT#SHELL_TRIM
- * @see SWT#DIALOG_TRIM
- * @see SWT#ON_TOP
- * @see SWT#TOOL
- * @see Widget#checkSubclass
- * @see Widget#getStyle
- */
-public Decorations (Composite parent, int style) {
- super (parent, checkStyle (style));
-}
-
-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) {
- item.id = i + ID_START;
- items [i] = item;
- return;
- }
- }
- item.id = items.length + ID_START;
- MenuItem [] newItems = new MenuItem [items.length + 12];
- newItems [items.length] = item;
- System.arraycopy (items, 0, newItems, 0, items.length);
- items = newItems;
-}
-
-void bringToTop () {
- /*
- * This code is intentionally commented. On some platforms,
- * the ON_TOP 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.ON_TOP) != 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 (OS.IsWinCE) {
- /*
- * Feature in WinCE PPC. WS_MINIMIZEBOX or WS_MAXIMIZEBOX
- * are not supposed to be used. If they are, the result
- * is a button which does not repaint correctly. The fix
- * is to remove this style.
- */
- if ((style & SWT.MIN) != 0) style &= ~SWT.MIN;
- if ((style & SWT.MAX) != 0) style &= ~SWT.MAX;
- return style;
- }
-
- /*
- * If either 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;
-
- /*
- * Both WS_SYSMENU and WS_CAPTION must be set in order
- * to for the system menu to appear.
- */
- if ((style & SWT.CLOSE) != 0) style |= SWT.TITLE;
-
- /*
- * Bug in Windows. The WS_CAPTION style must be
- * set when the window is resizable or it does not
- * draw properly.
- */
- /*
- * This code is intentionally commented. It seems
- * that this problem originally in Windows 3.11,
- * has been fixed in later versions. Because the
- * exact nature of the drawing problem is unknown,
- * keep the commented code around in case it comes
- * back.
- */
-// if ((style & SWT.RESIZE) != 0) style |= SWT.TITLE;
-
- return style;
-}
-
-protected void checkSubclass () {
- if (!isValidSubclass ()) error (SWT.ERROR_INVALID_SUBCLASS);
-}
-
-Control computeTabGroup () {
- return this;
-}
-
-Control computeTabRoot () {
- return this;
-}
-
-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 = OS.IsWinCE ? false : 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) rect.bottom += OS.GetSystemMetrics (OS.SM_CYHSCROLL);
- if (verticalBar != null) 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);
-}
-
-void createAccelerators () {
- hAccel = nAccel = 0;
- int maxAccel = 0;
- if (menuBar == null || items == null) {
- if (!OS.IsPPC) return;
- maxAccel = 1;
- } else {
- maxAccel = OS.IsPPC ? items.length + 1 : items.length;
- }
- int size = ACCEL.sizeof;
- ACCEL accel = new ACCEL ();
- byte [] buffer1 = new byte [size];
- byte [] buffer2 = new byte [maxAccel * size];
- if (menuBar != null && items != null) {
- 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 (OS.IsPPC) {
- /*
- * Note on WinCE PPC. Close the shell when user taps CTRL-Q.
- * IDOK represents the "Done Button" which also closes the shell.
- */
- accel.fVirt = OS.FVIRTKEY | OS.FCONTROL;
- accel.key = 'Q';
- accel.cmd = OS.IDOK;
- 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 () {
- super.createWidget ();
- swFlags = OS.IsWinCE ? OS.SW_SHOWMAXIMIZED : OS.SW_SHOWNOACTIVATE;
- hAccel = -1;
-}
-
-void destroyAccelerators () {
- 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;
- id = id - ID_START;
- if (0 <= id && id < items.length) return items [id];
- return null;
-}
-
-public Rectangle getBounds () {
- checkWidget ();
- if (!OS.IsWinCE) {
- 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 ();
- /*
- * Note: The CommandBar is part of the client area,
- * not the trim. Applications don't expect this so
- * subtract the height of the CommandBar.
- */
- if (OS.IsHPC) {
- Rectangle rect = super.getClientArea ();
- if (menuBar != null) {
- int hwndCB = menuBar.hwndCB;
- int height = OS.CommandBar_Height (hwndCB);
- rect.y += height;
- rect.height -= height;
- }
- return rect;
- }
- if (!OS.IsWinCE) {
- if (OS.IsIconic (handle)) {
- RECT rect = new RECT ();
- 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.IsWinCE) {
- 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.IsWinCE) return swFlags == OS.SW_SHOWMAXIMIZED;
- 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.IsWinCE) return false;
- if (OS.IsWindowVisible (handle)) return OS.IsIconic (handle);
- return swFlags == OS.SW_SHOWMINNOACTIVE;
-}
-
-String getNameText () {
- return getText ();
-}
-
-public Point getSize () {
- checkWidget ();
- if (!OS.IsWinCE) {
- 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 "";
- /* Use the character encoding for the default locale */
- TCHAR buffer = new TCHAR (0, length + 1);
- OS.GetWindowText (handle, buffer, length + 1);
- return buffer.toString (0, length);
-}
-
-boolean isTabGroup () {
- /*
- * Can't test WS_TAB bits because they are the same as WS_MAXIMIZEBOX.
- */
- return true;
-}
-
-boolean isTabItem () {
- /*
- * Can't test WS_TAB bits because they are the same as WS_MAXIMIZEBOX.
- */
- return false;
-}
-
-Decorations menuShell () {
- return this;
-}
-
-void releaseWidget () {
- if (menuBar != null) menuBar.releaseResources ();
- menuBar = null;
- if (menus != null) {
- do {
- int index = 0;
- while (index < menus.length) {
- Menu menu = menus [index];
- if (menu != null && !menu.isDisposed ()) {
- while (menu.getParentMenu () != null) {
- menu = menu.getParentMenu ();
- }
- menu.dispose ();
- break;
- }
- index++;
- }
- if (index == menus.length) break;
- } while (true);
- }
- menus = null;
- super.releaseWidget ();
- if (hIcon != 0) OS.DestroyIcon (hIcon);
- hIcon = 0;
- 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 - ID_START] = null;
- item.id = -1;
-}
-
-boolean restoreFocus () {
- if (savedFocus != null && savedFocus.isDisposed ()) savedFocus = null;
- if (savedFocus != null && savedFocus.setSavedFocus ()) return true;
- /*
- * This code is intentionally commented. When no widget
- * has been given focus, some platforms give focus to the
- * default button. Windows doesn't do this.
- */
-// if (defaultButton != null && !defaultButton.isDisposed ()) {
-// if (defaultButton.setFocus ()) return true;
-// }
- return false;
-}
-
-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.IsWinCE) {
- super.setBounds (x, y, width, height, flags);
- }
- if (OS.IsIconic (handle) || OS.IsZoomed (handle)) {
- setPlacement (x, y, width, height, flags);
- 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 IllegalArgumentException <ul>
- * <li>ERROR_INVALID_ARGUMENT - if the button has been disposed</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public void setDefaultButton (Button button) {
- checkWidget ();
- setDefaultButton (button, true);
-}
-
-void setDefaultButton (Button button, boolean save) {
- if (button == null) {
- if (defaultButton == saveDefault) {
- if (save) saveDefault = null;
- return;
- }
- } else {
- if (button.isDisposed()) error(SWT.ERROR_INVALID_ARGUMENT);
- 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 = 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 IllegalArgumentException <ul>
- * <li>ERROR_INVALID_ARGUMENT - if the image has been disposed</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public void setImage (Image image) {
- checkWidget ();
- if (image != null && image.isDisposed ()) error (SWT.ERROR_INVALID_ARGUMENT);
- /*
- * Feature in WinCE. WM_SETICON and WM_GETICON set the icon
- * for the window class, not the window instance. This means
- * that it is possible to set an icon into a window and then
- * later free the icon, thus freeing the icon for every window.
- * The fix is to avoid the API.
- *
- * On WinCE PPC, icons in windows are not displayed anyways.
- */
- if (OS.IsWinCE) {
- this.image = image;
- return;
- }
- int hImage = 0;
- if (image != null) {
- if (hIcon != 0) OS.DestroyIcon (hIcon);
- hIcon = 0;
- switch (image.type) {
- case SWT.BITMAP:
- /* 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;
- hImage = hIcon = OS.CreateIconIndirect (info);
- OS.DeleteObject (hMask);
- OS.DeleteObject(hColor);
- OS.DeleteDC (hdcBmp);
- OS.DeleteDC (hdcMem);
- OS.ReleaseDC (handle, hDC);
- break;
- case SWT.ICON:
- hImage = image.handle;
- break;
- default:
- return;
- }
- }
- this.image = image;
- OS.SendMessage (handle, OS.WM_SETICON, OS.ICON_BIG, hImage);
-
- /*
- * 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 (!OS.IsWinCE) {
- if (hIcon == 0 && (style & SWT.BORDER) != 0) {
- int flags = OS.RDW_FRAME | OS.RDW_INVALIDATE;
- OS.RedrawWindow (handle, null, 0, flags);
- }
- }
-}
-
-/**
- * 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 = maximized ? OS.SW_SHOWMAXIMIZED : OS.SW_RESTORE;
- if (OS.IsWinCE) {
- /*
- * Note: WinCE does not support SW_SHOWMAXIMIZED and SW_RESTORE. The
- * workaround is to resize the window to fit the parent client area.
- * PocketPC windows typically don't have a caption when they are
- * maximized. They usually have one when they are not occupying all the
- * space. We implement this behavior by default - it can be overriden by
- * setting SWT.TITLE or SWT.NO_TRIM.
- */
- if (maximized) {
- if ((style & SWT.TITLE) == 0) {
- /* Remove caption when maximized */
- int bits = OS.GetWindowLong (handle, OS.GWL_STYLE);
- bits &= ~OS.WS_CAPTION;
- OS.SetWindowLong (handle, OS.GWL_STYLE, bits);
- }
- RECT rect = new RECT ();
- OS.SystemParametersInfo (OS.SPI_GETWORKAREA, 0, rect, 0);
- int width = rect.right - rect.left, height = rect.bottom - rect.top;
- if (OS.IsPPC) {
- /* Leave space for the menu bar */
- if (menuBar != null) {
- int hwndCB = menuBar.hwndCB;
- RECT rectCB = new RECT ();
- OS.GetWindowRect (hwndCB, rectCB);
- height -= rectCB.bottom - rectCB.top;
- }
- }
- int flags = OS.SWP_NOZORDER | OS.SWP_DRAWFRAME | OS.SWP_NOACTIVATE;
- OS.SetWindowPos (handle, 0, rect.left, rect.top, width, height, flags);
- } else {
- if ((style & SWT.NO_TRIM) == 0) {
- /* Insert caption when no longer maximized */
- int bits = OS.GetWindowLong (handle, OS.GWL_STYLE);
- bits |= OS.WS_CAPTION;
- OS.SetWindowLong (handle, OS.GWL_STYLE, bits);
- int flags = OS.SWP_NOMOVE | OS.SWP_NOSIZE | OS.SWP_NOZORDER | OS.SWP_DRAWFRAME;
- OS.SetWindowPos (handle, 0, 0, 0, 0, 0, flags);
- }
- }
- } else {
- 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 IllegalArgumentException <ul>
- * <li>ERROR_INVALID_ARGUMENT - if the menu has been disposed</li>
- * <li>ERROR_INVALID_PARENT - if the menu is not in the same widget tree</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public void setMenuBar (Menu menu) {
- checkWidget ();
- if (menuBar == menu) return;
- if (menu != null) {
- if (menu.isDisposed()) error(SWT.ERROR_INVALID_ARGUMENT);
- if ((menu.style & SWT.BAR) == 0) error (SWT.ERROR_MENU_NOT_BAR);
- if (menu.parent != this) error (SWT.ERROR_INVALID_PARENT);
- }
- if (OS.IsWinCE) {
- if (OS.IsHPC) {
- boolean resize = menuBar != menu;
- if (menuBar != null) OS.CommandBar_Show (menuBar.hwndCB, false);
- menuBar = menu;
- if (menuBar != null) OS.CommandBar_Show (menuBar.hwndCB, true);
- if (resize) {
- sendEvent (SWT.Resize);
- layout (false);
- }
- } else {
- if (OS.IsPPC) {
- /*
- * Note in WinCE PPC. The menu bar is a separate popup window.
- * If the shell is full screen, resize its window to leave
- * space for the menu bar.
- */
- boolean resize = getMaximized () && menuBar != menu;
- if (menuBar != null) OS.ShowWindow (menuBar.hwndCB, OS.SW_HIDE);
- menuBar = menu;
- if (menuBar != null) OS.ShowWindow (menuBar.hwndCB, OS.SW_SHOW);
- if (resize) setMaximized (true);
- }
- if (OS.IsSP) {
- if (menuBar != null) OS.ShowWindow (menuBar.hwndCB, OS.SW_HIDE);
- menuBar = menu;
- if (menuBar != null) OS.ShowWindow (menuBar.hwndCB, OS.SW_SHOW);
- }
- }
- } else {
- if (menu != null) {
- Display display = getDisplay ();
- display.removeBar (menu);
- }
- menuBar = menu;
- int hMenu = menuBar != null ? menuBar.handle: 0;
- OS.SetMenu (handle, hMenu);
- }
- destroyAccelerators ();
-}
-
-/**
- * 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 ();
- if (OS.IsWinCE) return;
- 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 possibly 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 setPlacement (int x, int y, int width, int height, int flags) {
- WINDOWPLACEMENT lpwndpl = new WINDOWPLACEMENT ();
- lpwndpl.length = WINDOWPLACEMENT.sizeof;
- OS.GetWindowPlacement (handle, lpwndpl);
- lpwndpl.showCmd = OS.SW_SHOWNA;
- if (OS.IsIconic (handle)) {
- lpwndpl.showCmd = OS.SW_SHOWMINNOACTIVE;
- } else {
- if (OS.IsZoomed (handle)) {
- lpwndpl.showCmd = OS.SW_SHOWMAXIMIZED;
- }
- }
- 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);
-}
-
-void setSavedFocus (Control control) {
- if (this == control) {
- savedFocus = null;
- return;
- }
- if (this != control.menuShell ()) return;
- savedFocus = control;
-}
-
-void setSystemMenu () {
- if (OS.IsWinCE) return;
- 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);
- /* Use the character encoding for the default locale */
- TCHAR buffer = new TCHAR (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;
- if (OS.IsHPC) {
- if (menuBar != null) {
- int hwndCB = menuBar.hwndCB;
- OS.CommandBar_DrawMenuBar (hwndCB, 0);
- }
- }
- if (OS.IsWinCE) {
- OS.ShowWindow (handle, OS.SW_SHOW);
- } else {
- if (menuBar != null) {
- Display display = getDisplay ();
- display.removeBar (menuBar);
- OS.DrawMenuBar (handle);
- }
- OS.ShowWindow (handle, swFlags);
- }
- OS.UpdateWindow (handle);
- } else {
- if (!OS.IsWinCE) {
- 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 () || !isActive ()) return false;
- if (menuBar != null && !menuBar.isEnabled ()) return false;
- if (hAccel == -1) createAccelerators ();
- if (hAccel == 0) return false;
- return OS.TranslateAccelerator (handle, hAccel, msg) != 0;
-}
-
-boolean traverseItem (boolean next) {
- return false;
-}
-
-boolean traverseReturn () {
- if (defaultButton == null || defaultButton.isDisposed ()) return false;
- if (!defaultButton.isVisible () || !defaultButton.isEnabled ()) return false;
- defaultButton.click ();
- return true;
-}
-
-int widgetExtStyle () {
- int bits = super.widgetExtStyle () & ~OS.WS_EX_CLIENTEDGE;
- if ((style & SWT.NO_TRIM) != 0) return bits;
- if (OS.IsPPC) {
- if ((style & SWT.CLOSE) != 0) bits |= OS.WS_EX_CAPTIONOKBTN;
- }
- 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.
- * NOTE: WS_TABSTOP is the same as WS_MAXIMIZEBOX so
- * it cannot be used to do tabbing with decorations.
- */
- 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;
-
- /* Set the resize, dialog border or border bits */
- if ((style & SWT.RESIZE) != 0) {
- /*
- * Note on WinCE PPC. SWT.RESIZE is used to resize
- * the Shell according to the state of the IME.
- * It does not set the WS_THICKFRAME style. */
- if (!OS.IsPPC) bits |= OS.WS_THICKFRAME;
- } else {
- if ((style & SWT.BORDER) == 0) bits |= OS.WS_BORDER;
- }
-
- /* Set the system menu and close box bits */
- if (!OS.IsPPC && !OS.IsSP) {
- if ((style & SWT.CLOSE) != 0) bits |= OS.WS_SYSMENU;
- }
-
- return bits;
-}
-
-int windowProc (int msg, int wParam, int lParam) {
- switch (msg) {
- case OS.WM_APP:
- case OS.WM_APP+1:
- if (hAccel == -1) createAccelerators ();
- return msg == OS.WM_APP ? nAccel : hAccel;
- }
- return super.windowProc (msg, wParam, lParam);
-}
-
-LRESULT WM_ACTIVATE (int wParam, int lParam) {
- LRESULT result = super.WM_ACTIVATE (wParam, lParam);
- if (result != null) return result;
- if ((wParam & 0xFFFF) != 0) {
- /*
- * When the high word of wParam is non-zero, the activation
- * state of the window is being changed while the window is
- * minimized. If this is the case, do not report activation
- * events or restore the focus.
- */
- if ((wParam >> 16) != 0) return result;
- /*
- * 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;
- if (traverseGroup (true)) return LRESULT.ZERO;
-
- } else {
- /*
- * 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.
- */
- Shell shell = getShell ();
- shell.setActiveControl (null);
- if (isDisposed ()) return LRESULT.ZERO;
- sendEvent (SWT.Deactivate);
- if (isDisposed ()) return LRESULT.ZERO;
- saveFocus ();
- }
- 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_HOTKEY (int wParam, int lParam) {
- LRESULT result = super.WM_HOTKEY (wParam, lParam);
- if (result != null) return result;
- if (OS.IsSP) {
- /*
- * Feature on WinCE SP. The Back key is either used to close
- * the foreground Dialog or used as a regular Back key in an EDIT
- * control. The article 'Back Key' in MSDN for Smartphone
- * describes how an application should handle it. The
- * workaround is to override the Back key when creating
- * the menubar and handle it based on the style of the Shell.
- * If the Shell has the SWT.CLOSE style, close the Shell.
- * Otherwise, send the Back key to the window with focus.
- */
- if (((lParam >> 16) & 0xFFFF) == OS.VK_ESCAPE) {
- if ((style & SWT.CLOSE) != 0) {
- OS.PostMessage (handle, OS.WM_CLOSE, 0, 0);
- } else {
- OS.SHSendBackToFocusWindow (OS.WM_HOTKEY, wParam, lParam);
- }
- return LRESULT.ZERO;
- }
- }
- return result;
-}
-
-LRESULT WM_KILLFOCUS (int wParam, int lParam) {
- LRESULT result = super.WM_KILLFOCUS (wParam, lParam);
- 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 (!restoreFocus ()) traverseGroup (true);
- 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;
-}
-
-LRESULT WM_WINDOWPOSCHANGING (int wParam, int lParam) {
- LRESULT result = super.WM_WINDOWPOSCHANGING (wParam,lParam);
- if (result != null) return result;
- Display display = getDisplay ();
- if (display.lockActiveWindow) {
- WINDOWPOS lpwp = new WINDOWPOS ();
- OS.MoveMemory (lpwp, lParam, WINDOWPOS.sizeof);
- lpwp.flags |= OS.SWP_NOZORDER;
- OS.MoveMemory (lParam, lpwp, WINDOWPOS.sizeof);
- }
- return result;
-}
-
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+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), its appearance is controlled by
+ * the style constants which were specified when it was created
+ * and the restrictions of the window manager (see below).
+ * </li><li>
+ * When an instance has been marked as <em>minimized</em>,
+ * its contents (client area) will usually not be visible,
+ * and depending on the window manager, it may be
+ * "iconified" (that is, replaced on the desktop by a small
+ * simplified representation of itself), relocated to a
+ * distinguished area of the screen, or hidden. Combinations
+ * of these changes are also possible.
+ * </li>
+ * </ul>
+ * </p>
+ * Note: The styles supported by this class must be treated
+ * as <em>HINT</em>s, since the window manager for the
+ * desktop on which the instance is visible has ultimate
+ * control over the appearance and behavior of decorations.
+ * For example, some window managers only support resizable
+ * windows and will always assume the RESIZE style, even if
+ * it is not set.
+ * <dl>
+ * <dt><b>Styles:</b></dt>
+ * <dd>BORDER, CLOSE, MIN, MAX, NO_TRIM, RESIZE, TITLE, ON_TOP, TOOL</dd>
+ * <dt><b>Events:</b></dt>
+ * <dd>(none)</dd>
+ * </dl>
+ * Class <code>SWT</code> provides two "convenience constants"
+ * for the most commonly required style combinations:
+ * <dl>
+ * <dt><code>SHELL_TRIM</code></dt>
+ * <dd>
+ * the result of combining the constants which are required
+ * to produce a typical application top level shell: (that
+ * is, <code>CLOSE | TITLE | MIN | MAX | RESIZE</code>)
+ * </dd>
+ * <dt><code>DIALOG_TRIM</code></dt>
+ * <dd>
+ * the result of combining the constants which are required
+ * to produce a typical application dialog shell: (that
+ * is, <code>TITLE | CLOSE | BORDER</code>)
+ * </dd>
+ * </dl>
+ * <p>
+ * IMPORTANT: This class is intended to be subclassed <em>only</em>
+ * within the SWT implementation.
+ * </p>
+ *
+ * @see #getMinimized
+ * @see #getMaximized
+ * @see Shell
+ * @see SWT
+ */
+
+public class Decorations extends Canvas {
+ Image image;
+ Menu menuBar;
+ Menu [] menus;
+ MenuItem [] items;
+ Control savedFocus;
+ Button defaultButton, saveDefault;
+ int swFlags, hAccel, nAccel, hIcon;
+
+ /*
+ * The start value for WM_COMMAND id's.
+ * Windows reserves the values 0..100.
+ *
+ * The SmartPhone SWT resource file reserves
+ * the values 101..107.
+ */
+ static final int ID_START = 108;
+
+/**
+ * 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
+ * lists the style constants that are applicable to the class.
+ * Style bits are also inherited from superclasses.
+ * </p>
+ *
+ * @param parent a composite control which will be the parent of the new instance (cannot be null)
+ * @param style the style of control to construct
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
+ * <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
+ * </ul>
+ *
+ * @see SWT#BORDER
+ * @see SWT#CLOSE
+ * @see SWT#MIN
+ * @see SWT#MAX
+ * @see SWT#RESIZE
+ * @see SWT#TITLE
+ * @see SWT#NO_TRIM
+ * @see SWT#SHELL_TRIM
+ * @see SWT#DIALOG_TRIM
+ * @see SWT#ON_TOP
+ * @see SWT#TOOL
+ * @see Widget#checkSubclass
+ * @see Widget#getStyle
+ */
+public Decorations (Composite parent, int style) {
+ super (parent, checkStyle (style));
+}
+
+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) {
+ item.id = i + ID_START;
+ items [i] = item;
+ return;
+ }
+ }
+ item.id = items.length + ID_START;
+ MenuItem [] newItems = new MenuItem [items.length + 12];
+ newItems [items.length] = item;
+ System.arraycopy (items, 0, newItems, 0, items.length);
+ items = newItems;
+}
+
+void bringToTop () {
+ /*
+ * This code is intentionally commented. On some platforms,
+ * the ON_TOP 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.ON_TOP) != 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 (OS.IsWinCE) {
+ /*
+ * Feature in WinCE PPC. WS_MINIMIZEBOX or WS_MAXIMIZEBOX
+ * are not supposed to be used. If they are, the result
+ * is a button which does not repaint correctly. The fix
+ * is to remove this style.
+ */
+ if ((style & SWT.MIN) != 0) style &= ~SWT.MIN;
+ if ((style & SWT.MAX) != 0) style &= ~SWT.MAX;
+ return style;
+ }
+
+ /*
+ * If either 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;
+
+ /*
+ * Both WS_SYSMENU and WS_CAPTION must be set in order
+ * to for the system menu to appear.
+ */
+ if ((style & SWT.CLOSE) != 0) style |= SWT.TITLE;
+
+ /*
+ * Bug in Windows. The WS_CAPTION style must be
+ * set when the window is resizable or it does not
+ * draw properly.
+ */
+ /*
+ * This code is intentionally commented. It seems
+ * that this problem originally in Windows 3.11,
+ * has been fixed in later versions. Because the
+ * exact nature of the drawing problem is unknown,
+ * keep the commented code around in case it comes
+ * back.
+ */
+// if ((style & SWT.RESIZE) != 0) style |= SWT.TITLE;
+
+ return style;
+}
+
+protected void checkSubclass () {
+ if (!isValidSubclass ()) error (SWT.ERROR_INVALID_SUBCLASS);
+}
+
+Control computeTabGroup () {
+ return this;
+}
+
+Control computeTabRoot () {
+ return this;
+}
+
+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 = OS.IsWinCE ? false : 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) rect.bottom += OS.GetSystemMetrics (OS.SM_CYHSCROLL);
+ if (verticalBar != null) 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);
+}
+
+void createAccelerators () {
+ hAccel = nAccel = 0;
+ int maxAccel = 0;
+ if (menuBar == null || items == null) {
+ if (!OS.IsPPC) return;
+ maxAccel = 1;
+ } else {
+ maxAccel = OS.IsPPC ? items.length + 1 : items.length;
+ }
+ int size = ACCEL.sizeof;
+ ACCEL accel = new ACCEL ();
+ byte [] buffer1 = new byte [size];
+ byte [] buffer2 = new byte [maxAccel * size];
+ if (menuBar != null && items != null) {
+ 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 (OS.IsPPC) {
+ /*
+ * Note on WinCE PPC. Close the shell when user taps CTRL-Q.
+ * IDOK represents the "Done Button" which also closes the shell.
+ */
+ accel.fVirt = OS.FVIRTKEY | OS.FCONTROL;
+ accel.key = 'Q';
+ accel.cmd = OS.IDOK;
+ 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 () {
+ super.createWidget ();
+ swFlags = OS.IsWinCE ? OS.SW_SHOWMAXIMIZED : OS.SW_SHOWNOACTIVATE;
+ hAccel = -1;
+}
+
+void destroyAccelerators () {
+ 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;
+ id = id - ID_START;
+ if (0 <= id && id < items.length) return items [id];
+ return null;
+}
+
+public Rectangle getBounds () {
+ checkWidget ();
+ if (!OS.IsWinCE) {
+ 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 ();
+ /*
+ * Note: The CommandBar is part of the client area,
+ * not the trim. Applications don't expect this so
+ * subtract the height of the CommandBar.
+ */
+ if (OS.IsHPC) {
+ Rectangle rect = super.getClientArea ();
+ if (menuBar != null) {
+ int hwndCB = menuBar.hwndCB;
+ int height = OS.CommandBar_Height (hwndCB);
+ rect.y += height;
+ rect.height -= height;
+ }
+ return rect;
+ }
+ if (!OS.IsWinCE) {
+ if (OS.IsIconic (handle)) {
+ RECT rect = new RECT ();
+ 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.IsWinCE) {
+ 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.IsWinCE) return swFlags == OS.SW_SHOWMAXIMIZED;
+ 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.IsWinCE) return false;
+ if (OS.IsWindowVisible (handle)) return OS.IsIconic (handle);
+ return swFlags == OS.SW_SHOWMINNOACTIVE;
+}
+
+String getNameText () {
+ return getText ();
+}
+
+public Point getSize () {
+ checkWidget ();
+ if (!OS.IsWinCE) {
+ 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 "";
+ /* Use the character encoding for the default locale */
+ TCHAR buffer = new TCHAR (0, length + 1);
+ OS.GetWindowText (handle, buffer, length + 1);
+ return buffer.toString (0, length);
+}
+
+boolean isTabGroup () {
+ /*
+ * Can't test WS_TAB bits because they are the same as WS_MAXIMIZEBOX.
+ */
+ return true;
+}
+
+boolean isTabItem () {
+ /*
+ * Can't test WS_TAB bits because they are the same as WS_MAXIMIZEBOX.
+ */
+ return false;
+}
+
+Decorations menuShell () {
+ return this;
+}
+
+void releaseWidget () {
+ if (menuBar != null) menuBar.releaseResources ();
+ menuBar = null;
+ if (menus != null) {
+ do {
+ int index = 0;
+ while (index < menus.length) {
+ Menu menu = menus [index];
+ if (menu != null && !menu.isDisposed ()) {
+ while (menu.getParentMenu () != null) {
+ menu = menu.getParentMenu ();
+ }
+ menu.dispose ();
+ break;
+ }
+ index++;
+ }
+ if (index == menus.length) break;
+ } while (true);
+ }
+ menus = null;
+ super.releaseWidget ();
+ if (hIcon != 0) OS.DestroyIcon (hIcon);
+ hIcon = 0;
+ 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 - ID_START] = null;
+ item.id = -1;
+}
+
+boolean restoreFocus () {
+ if (savedFocus != null && savedFocus.isDisposed ()) savedFocus = null;
+ if (savedFocus != null && savedFocus.setSavedFocus ()) return true;
+ /*
+ * This code is intentionally commented. When no widget
+ * has been given focus, some platforms give focus to the
+ * default button. Windows doesn't do this.
+ */
+// if (defaultButton != null && !defaultButton.isDisposed ()) {
+// if (defaultButton.setFocus ()) return true;
+// }
+ return false;
+}
+
+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.IsWinCE) {
+ super.setBounds (x, y, width, height, flags);
+ }
+ if (OS.IsIconic (handle) || OS.IsZoomed (handle)) {
+ setPlacement (x, y, width, height, flags);
+ 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 IllegalArgumentException <ul>
+ * <li>ERROR_INVALID_ARGUMENT - if the button has been disposed</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setDefaultButton (Button button) {
+ checkWidget ();
+ setDefaultButton (button, true);
+}
+
+void setDefaultButton (Button button, boolean save) {
+ if (button == null) {
+ if (defaultButton == saveDefault) {
+ if (save) saveDefault = null;
+ return;
+ }
+ } else {
+ if (button.isDisposed()) error(SWT.ERROR_INVALID_ARGUMENT);
+ 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 = 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 IllegalArgumentException <ul>
+ * <li>ERROR_INVALID_ARGUMENT - if the image has been disposed</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setImage (Image image) {
+ checkWidget ();
+ if (image != null && image.isDisposed ()) error (SWT.ERROR_INVALID_ARGUMENT);
+ /*
+ * Feature in WinCE. WM_SETICON and WM_GETICON set the icon
+ * for the window class, not the window instance. This means
+ * that it is possible to set an icon into a window and then
+ * later free the icon, thus freeing the icon for every window.
+ * The fix is to avoid the API.
+ *
+ * On WinCE PPC, icons in windows are not displayed anyways.
+ */
+ if (OS.IsWinCE) {
+ this.image = image;
+ return;
+ }
+ int hImage = 0;
+ if (image != null) {
+ if (hIcon != 0) OS.DestroyIcon (hIcon);
+ hIcon = 0;
+ switch (image.type) {
+ case SWT.BITMAP:
+ /* 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;
+ hImage = hIcon = OS.CreateIconIndirect (info);
+ OS.DeleteObject (hMask);
+ OS.DeleteObject(hColor);
+ OS.DeleteDC (hdcBmp);
+ OS.DeleteDC (hdcMem);
+ OS.ReleaseDC (handle, hDC);
+ break;
+ case SWT.ICON:
+ hImage = image.handle;
+ break;
+ default:
+ return;
+ }
+ }
+ this.image = image;
+ OS.SendMessage (handle, OS.WM_SETICON, OS.ICON_BIG, hImage);
+
+ /*
+ * 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 (!OS.IsWinCE) {
+ if (hIcon == 0 && (style & SWT.BORDER) != 0) {
+ int flags = OS.RDW_FRAME | OS.RDW_INVALIDATE;
+ OS.RedrawWindow (handle, null, 0, flags);
+ }
+ }
+}
+
+/**
+ * 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 = maximized ? OS.SW_SHOWMAXIMIZED : OS.SW_RESTORE;
+ if (OS.IsWinCE) {
+ /*
+ * Note: WinCE does not support SW_SHOWMAXIMIZED and SW_RESTORE. The
+ * workaround is to resize the window to fit the parent client area.
+ * PocketPC windows typically don't have a caption when they are
+ * maximized. They usually have one when they are not occupying all the
+ * space. We implement this behavior by default - it can be overriden by
+ * setting SWT.TITLE or SWT.NO_TRIM.
+ */
+ if (maximized) {
+ if ((style & SWT.TITLE) == 0) {
+ /* Remove caption when maximized */
+ int bits = OS.GetWindowLong (handle, OS.GWL_STYLE);
+ bits &= ~OS.WS_CAPTION;
+ OS.SetWindowLong (handle, OS.GWL_STYLE, bits);
+ }
+ RECT rect = new RECT ();
+ OS.SystemParametersInfo (OS.SPI_GETWORKAREA, 0, rect, 0);
+ int width = rect.right - rect.left, height = rect.bottom - rect.top;
+ if (OS.IsPPC) {
+ /* Leave space for the menu bar */
+ if (menuBar != null) {
+ int hwndCB = menuBar.hwndCB;
+ RECT rectCB = new RECT ();
+ OS.GetWindowRect (hwndCB, rectCB);
+ height -= rectCB.bottom - rectCB.top;
+ }
+ }
+ int flags = OS.SWP_NOZORDER | OS.SWP_DRAWFRAME | OS.SWP_NOACTIVATE;
+ OS.SetWindowPos (handle, 0, rect.left, rect.top, width, height, flags);
+ } else {
+ if ((style & SWT.NO_TRIM) == 0) {
+ /* Insert caption when no longer maximized */
+ int bits = OS.GetWindowLong (handle, OS.GWL_STYLE);
+ bits |= OS.WS_CAPTION;
+ OS.SetWindowLong (handle, OS.GWL_STYLE, bits);
+ int flags = OS.SWP_NOMOVE | OS.SWP_NOSIZE | OS.SWP_NOZORDER | OS.SWP_DRAWFRAME;
+ OS.SetWindowPos (handle, 0, 0, 0, 0, 0, flags);
+ }
+ }
+ } else {
+ 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 IllegalArgumentException <ul>
+ * <li>ERROR_INVALID_ARGUMENT - if the menu has been disposed</li>
+ * <li>ERROR_INVALID_PARENT - if the menu is not in the same widget tree</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setMenuBar (Menu menu) {
+ checkWidget ();
+ if (menuBar == menu) return;
+ if (menu != null) {
+ if (menu.isDisposed()) error(SWT.ERROR_INVALID_ARGUMENT);
+ if ((menu.style & SWT.BAR) == 0) error (SWT.ERROR_MENU_NOT_BAR);
+ if (menu.parent != this) error (SWT.ERROR_INVALID_PARENT);
+ }
+ if (OS.IsWinCE) {
+ if (OS.IsHPC) {
+ boolean resize = menuBar != menu;
+ if (menuBar != null) OS.CommandBar_Show (menuBar.hwndCB, false);
+ menuBar = menu;
+ if (menuBar != null) OS.CommandBar_Show (menuBar.hwndCB, true);
+ if (resize) {
+ sendEvent (SWT.Resize);
+ layout (false);
+ }
+ } else {
+ if (OS.IsPPC) {
+ /*
+ * Note in WinCE PPC. The menu bar is a separate popup window.
+ * If the shell is full screen, resize its window to leave
+ * space for the menu bar.
+ */
+ boolean resize = getMaximized () && menuBar != menu;
+ if (menuBar != null) OS.ShowWindow (menuBar.hwndCB, OS.SW_HIDE);
+ menuBar = menu;
+ if (menuBar != null) OS.ShowWindow (menuBar.hwndCB, OS.SW_SHOW);
+ if (resize) setMaximized (true);
+ }
+ if (OS.IsSP) {
+ if (menuBar != null) OS.ShowWindow (menuBar.hwndCB, OS.SW_HIDE);
+ menuBar = menu;
+ if (menuBar != null) OS.ShowWindow (menuBar.hwndCB, OS.SW_SHOW);
+ }
+ }
+ } else {
+ if (menu != null) {
+ Display display = getDisplay ();
+ display.removeBar (menu);
+ }
+ menuBar = menu;
+ int hMenu = menuBar != null ? menuBar.handle: 0;
+ OS.SetMenu (handle, hMenu);
+ }
+ destroyAccelerators ();
+}
+
+/**
+ * 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 ();
+ if (OS.IsWinCE) return;
+ 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 possibly 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 setPlacement (int x, int y, int width, int height, int flags) {
+ WINDOWPLACEMENT lpwndpl = new WINDOWPLACEMENT ();
+ lpwndpl.length = WINDOWPLACEMENT.sizeof;
+ OS.GetWindowPlacement (handle, lpwndpl);
+ lpwndpl.showCmd = OS.SW_SHOWNA;
+ if (OS.IsIconic (handle)) {
+ lpwndpl.showCmd = OS.SW_SHOWMINNOACTIVE;
+ } else {
+ if (OS.IsZoomed (handle)) {
+ lpwndpl.showCmd = OS.SW_SHOWMAXIMIZED;
+ }
+ }
+ 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);
+}
+
+void setSavedFocus (Control control) {
+ if (this == control) {
+ savedFocus = null;
+ return;
+ }
+ if (this != control.menuShell ()) return;
+ savedFocus = control;
+}
+
+void setSystemMenu () {
+ if (OS.IsWinCE) return;
+ 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);
+ /* Use the character encoding for the default locale */
+ TCHAR buffer = new TCHAR (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;
+ if (OS.IsHPC) {
+ if (menuBar != null) {
+ int hwndCB = menuBar.hwndCB;
+ OS.CommandBar_DrawMenuBar (hwndCB, 0);
+ }
+ }
+ if (OS.IsWinCE) {
+ OS.ShowWindow (handle, OS.SW_SHOW);
+ } else {
+ if (menuBar != null) {
+ Display display = getDisplay ();
+ display.removeBar (menuBar);
+ OS.DrawMenuBar (handle);
+ }
+ OS.ShowWindow (handle, swFlags);
+ }
+ OS.UpdateWindow (handle);
+ } else {
+ if (!OS.IsWinCE) {
+ 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 () || !isActive ()) return false;
+ if (menuBar != null && !menuBar.isEnabled ()) return false;
+ if (hAccel == -1) createAccelerators ();
+ if (hAccel == 0) return false;
+ return OS.TranslateAccelerator (handle, hAccel, msg) != 0;
+}
+
+boolean traverseItem (boolean next) {
+ return false;
+}
+
+boolean traverseReturn () {
+ if (defaultButton == null || defaultButton.isDisposed ()) return false;
+ if (!defaultButton.isVisible () || !defaultButton.isEnabled ()) return false;
+ defaultButton.click ();
+ return true;
+}
+
+int widgetExtStyle () {
+ int bits = super.widgetExtStyle () & ~OS.WS_EX_CLIENTEDGE;
+ if ((style & SWT.NO_TRIM) != 0) return bits;
+ if (OS.IsPPC) {
+ if ((style & SWT.CLOSE) != 0) bits |= OS.WS_EX_CAPTIONOKBTN;
+ }
+ 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.
+ * NOTE: WS_TABSTOP is the same as WS_MAXIMIZEBOX so
+ * it cannot be used to do tabbing with decorations.
+ */
+ 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;
+
+ /* Set the resize, dialog border or border bits */
+ if ((style & SWT.RESIZE) != 0) {
+ /*
+ * Note on WinCE PPC. SWT.RESIZE is used to resize
+ * the Shell according to the state of the IME.
+ * It does not set the WS_THICKFRAME style. */
+ if (!OS.IsPPC) bits |= OS.WS_THICKFRAME;
+ } else {
+ if ((style & SWT.BORDER) == 0) bits |= OS.WS_BORDER;
+ }
+
+ /* Set the system menu and close box bits */
+ if (!OS.IsPPC && !OS.IsSP) {
+ if ((style & SWT.CLOSE) != 0) bits |= OS.WS_SYSMENU;
+ }
+
+ return bits;
+}
+
+int windowProc (int msg, int wParam, int lParam) {
+ switch (msg) {
+ case OS.WM_APP:
+ case OS.WM_APP+1:
+ if (hAccel == -1) createAccelerators ();
+ return msg == OS.WM_APP ? nAccel : hAccel;
+ }
+ return super.windowProc (msg, wParam, lParam);
+}
+
+LRESULT WM_ACTIVATE (int wParam, int lParam) {
+ LRESULT result = super.WM_ACTIVATE (wParam, lParam);
+ if (result != null) return result;
+ if ((wParam & 0xFFFF) != 0) {
+ /*
+ * When the high word of wParam is non-zero, the activation
+ * state of the window is being changed while the window is
+ * minimized. If this is the case, do not report activation
+ * events or restore the focus.
+ */
+ if ((wParam >> 16) != 0) return result;
+ /*
+ * 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;
+ if (traverseGroup (true)) return LRESULT.ZERO;
+
+ } else {
+ /*
+ * 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.
+ */
+ Shell shell = getShell ();
+ shell.setActiveControl (null);
+ if (isDisposed ()) return LRESULT.ZERO;
+ sendEvent (SWT.Deactivate);
+ if (isDisposed ()) return LRESULT.ZERO;
+ saveFocus ();
+ }
+ 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_HOTKEY (int wParam, int lParam) {
+ LRESULT result = super.WM_HOTKEY (wParam, lParam);
+ if (result != null) return result;
+ if (OS.IsSP) {
+ /*
+ * Feature on WinCE SP. The Back key is either used to close
+ * the foreground Dialog or used as a regular Back key in an EDIT
+ * control. The article 'Back Key' in MSDN for Smartphone
+ * describes how an application should handle it. The
+ * workaround is to override the Back key when creating
+ * the menubar and handle it based on the style of the Shell.
+ * If the Shell has the SWT.CLOSE style, close the Shell.
+ * Otherwise, send the Back key to the window with focus.
+ */
+ if (((lParam >> 16) & 0xFFFF) == OS.VK_ESCAPE) {
+ if ((style & SWT.CLOSE) != 0) {
+ OS.PostMessage (handle, OS.WM_CLOSE, 0, 0);
+ } else {
+ OS.SHSendBackToFocusWindow (OS.WM_HOTKEY, wParam, lParam);
+ }
+ return LRESULT.ZERO;
+ }
+ }
+ return result;
+}
+
+LRESULT WM_KILLFOCUS (int wParam, int lParam) {
+ LRESULT result = super.WM_KILLFOCUS (wParam, lParam);
+ 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 (!restoreFocus ()) traverseGroup (true);
+ 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;
+}
+
+LRESULT WM_WINDOWPOSCHANGING (int wParam, int lParam) {
+ LRESULT result = super.WM_WINDOWPOSCHANGING (wParam,lParam);
+ if (result != null) return result;
+ Display display = getDisplay ();
+ if (display.lockActiveWindow) {
+ WINDOWPOS lpwp = new WINDOWPOS ();
+ OS.MoveMemory (lpwp, lParam, WINDOWPOS.sizeof);
+ lpwp.flags |= OS.SWP_NOZORDER;
+ OS.MoveMemory (lParam, lpwp, WINDOWPOS.sizeof);
+ }
+ 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
index b97e76ef34..f4fdc01bf0 100755
--- 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
@@ -1,242 +1,242 @@
-package org.eclipse.swt.widgets;
-
-/*
+package org.eclipse.swt.widgets;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-import org.eclipse.swt.internal.*;
-import org.eclipse.swt.internal.win32.*;
-import org.eclipse.swt.*;
-
-/**
- * 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
- * lists the style constants that are applicable to the class.
- * Style bits are also inherited from superclasses.
- * </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);
- checkSubclass ();
-}
-
-int BrowseCallbackProc (int hwnd, int uMsg, int lParam, int lpData) {
- switch (uMsg) {
- case OS.BFFM_INITIALIZED:
- if (filterPath != null && filterPath.length () != 0) {
- /* Use the character encoding for the default locale */
- TCHAR buffer = new TCHAR (0, filterPath.replace ('/', '\\'), true);
- OS.SendMessage (hwnd, OS.BFFM_SETSELECTION, 1, buffer);
- }
- if (title != null && title.length () != 0) {
- /* Use the character encoding for the default locale */
- TCHAR buffer = new TCHAR (0, title, true);
- OS.SetWindowText (hwnd, buffer);
- }
- break;
- case OS.BFFM_VALIDATEFAILEDA:
- case OS.BFFM_VALIDATEFAILEDW:
- /* Use the character encoding for the default locale */
- TCHAR buffer = new TCHAR (0, 256);
- int byteCount = buffer.length () * TCHAR.sizeof;
- OS.MoveMemory (buffer, lParam, byteCount);
- directoryPath = buffer.toString (0, buffer.strlen ());
- break;
- }
- return 0;
-}
-
-/**
- * Returns the path which the dialog will use to filter
- * the directories it shows.
- *
- * @return the filter path
- */
-public String getFilterPath () {
- return filterPath;
-}
-
-/**
- * Returns the dialog's message, which is a description of
- * the purpose for which it was opened. This message will be
- * visible on the dialog while it is open.
- *
- * @return the message
- */
-public String getMessage () {
- return message;
-}
-
-/**
- * Makes the dialog visible and brings it to the front
- * of the display.
- *
- * @return a string describing the absolute path of the selected directory,
- * or null if the dialog was cancelled or an error occurred
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the dialog has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the dialog</li>
- * </ul>
- */
-public String open () {
- if (OS.IsWinCE) SWT.error (SWT.ERROR_NOT_IMPLEMENTED);
-
- /* 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) {
- /* Use the character encoding for the default locale */
- TCHAR buffer = new TCHAR (0, message, true);
- int byteCount = buffer.length () * TCHAR.sizeof;
- lpszTitle = OS.HeapAlloc (hHeap, OS.HEAP_ZERO_MEMORY, byteCount);
- OS.MoveMemory (lpszTitle, buffer, byteCount);
- }
-
- /* 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_NEWDIALOGSTYLE | OS.BIF_RETURNONLYFSDIRS | OS.BIF_EDITBOX | OS.BIF_VALIDATE;
- lpbi.lpfn = address;
- int lpItemIdList = OS.SHBrowseForFolder (lpbi);
- boolean success = lpItemIdList != 0;
- if (success) {
- /* Use the character encoding for the default locale */
- TCHAR buffer = new TCHAR (0, 256);
- if (OS.SHGetPathFromIDList (lpItemIdList, buffer)) {
- directoryPath = buffer.toString (0, buffer.strlen ());
- filterPath = directoryPath;
- }
- }
-
- /* 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 */
- if (!success) return null;
- return directoryPath;
-}
-
-/**
- * Sets the path which the dialog 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 dialog's message, which is a description of
- * the purpose for which it was opened. This message will be
- * visible on the dialog while it is open.
- *
- * @param string the message
- */
-public void setMessage (String string) {
- message = string;
-}
-
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+import org.eclipse.swt.internal.*;
+import org.eclipse.swt.internal.win32.*;
+import org.eclipse.swt.*;
+
+/**
+ * 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
+ * lists the style constants that are applicable to the class.
+ * Style bits are also inherited from superclasses.
+ * </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);
+ checkSubclass ();
+}
+
+int BrowseCallbackProc (int hwnd, int uMsg, int lParam, int lpData) {
+ switch (uMsg) {
+ case OS.BFFM_INITIALIZED:
+ if (filterPath != null && filterPath.length () != 0) {
+ /* Use the character encoding for the default locale */
+ TCHAR buffer = new TCHAR (0, filterPath.replace ('/', '\\'), true);
+ OS.SendMessage (hwnd, OS.BFFM_SETSELECTION, 1, buffer);
+ }
+ if (title != null && title.length () != 0) {
+ /* Use the character encoding for the default locale */
+ TCHAR buffer = new TCHAR (0, title, true);
+ OS.SetWindowText (hwnd, buffer);
+ }
+ break;
+ case OS.BFFM_VALIDATEFAILEDA:
+ case OS.BFFM_VALIDATEFAILEDW:
+ /* Use the character encoding for the default locale */
+ TCHAR buffer = new TCHAR (0, 256);
+ int byteCount = buffer.length () * TCHAR.sizeof;
+ OS.MoveMemory (buffer, lParam, byteCount);
+ directoryPath = buffer.toString (0, buffer.strlen ());
+ break;
+ }
+ return 0;
+}
+
+/**
+ * Returns the path which the dialog will use to filter
+ * the directories it shows.
+ *
+ * @return the filter path
+ */
+public String getFilterPath () {
+ return filterPath;
+}
+
+/**
+ * Returns the dialog's message, which is a description of
+ * the purpose for which it was opened. This message will be
+ * visible on the dialog while it is open.
+ *
+ * @return the message
+ */
+public String getMessage () {
+ return message;
+}
+
+/**
+ * Makes the dialog visible and brings it to the front
+ * of the display.
+ *
+ * @return a string describing the absolute path of the selected directory,
+ * or null if the dialog was cancelled or an error occurred
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the dialog has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the dialog</li>
+ * </ul>
+ */
+public String open () {
+ if (OS.IsWinCE) SWT.error (SWT.ERROR_NOT_IMPLEMENTED);
+
+ /* 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) {
+ /* Use the character encoding for the default locale */
+ TCHAR buffer = new TCHAR (0, message, true);
+ int byteCount = buffer.length () * TCHAR.sizeof;
+ lpszTitle = OS.HeapAlloc (hHeap, OS.HEAP_ZERO_MEMORY, byteCount);
+ OS.MoveMemory (lpszTitle, buffer, byteCount);
+ }
+
+ /* 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_NEWDIALOGSTYLE | OS.BIF_RETURNONLYFSDIRS | OS.BIF_EDITBOX | OS.BIF_VALIDATE;
+ lpbi.lpfn = address;
+ int lpItemIdList = OS.SHBrowseForFolder (lpbi);
+ boolean success = lpItemIdList != 0;
+ if (success) {
+ /* Use the character encoding for the default locale */
+ TCHAR buffer = new TCHAR (0, 256);
+ if (OS.SHGetPathFromIDList (lpItemIdList, buffer)) {
+ directoryPath = buffer.toString (0, buffer.strlen ());
+ filterPath = directoryPath;
+ }
+ }
+
+ /* 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 */
+ if (!success) return null;
+ return directoryPath;
+}
+
+/**
+ * Sets the path which the dialog 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 dialog's message, which is a description of
+ * the purpose for which it was opened. This message will be
+ * visible on the dialog while it is open.
+ *
+ * @param string the message
+ */
+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
index 322fce35d9..37b27ba529 100755
--- 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
@@ -1,2333 +1,2333 @@
-package org.eclipse.swt.widgets;
-
-/*
+package org.eclipse.swt.widgets;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-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>
- * <dl>
- * <dt><b>Styles:</b></dt>
- * <dd>(none)</dd>
- * <dt><b>Events:</b></dt>
- * <dd>Close, Dispose</dd>
- * </dl>
- * <p>
- * IMPORTANT: This class is <em>not</em> intended to be subclassed.
- * </p>
- * @see #syncExec
- * @see #asyncExec
- * @see #wake
- * @see #readAndDispatch
- * @see #sleep
- * @see #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 and Events */
- Event [] eventQueue;
- Callback windowCallback;
- int windowProc, threadId, processId;
- TCHAR windowClass;
- static int WindowClassCount = 0;
- static final String WindowName = "SWT_Window";
- EventTable eventTable, filterTable;
-
- /* Message Filter */
- Callback msgFilterCallback;
- int msgFilterProc, hHook;
- MSG hookMsg = new MSG ();
-
- /* Sync/Async Widget Communication */
- Synchronizer synchronizer = new Synchronizer (this);
- Thread thread;
-
- /* Display Shutdown */
- Runnable [] disposeList;
-
- /* Timers */
- int timerCount;
- int [] timerIds;
- Runnable [] timerList;
-
- /* Keyboard and Mouse State */
- boolean lockActiveWindow;
- boolean lastVirtual, lastNull;
- int lastKey, lastAscii, lastMouse;
- byte [] keyboard = new byte [256];
- boolean accelKeyHit, mnemonicKeyHit;
-
- /* Message Only Window */
- int hwndMessage, messageProc;
- Callback messageCallback;
- int [] systemFonts;
-
- /* Image list cache */
- ImageList[] imageList, toolImageList, toolHotImageList, toolDisabledImageList;
-
- /* Custom Colors for ChooseColor */
- int lpCustColors;
-
- /* Display Data */
- Object data;
- String [] keys;
- Object [] values;
-
- /* Bar and Popup Menus */
- Menu [] bars, popups;
-
- /* 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 Keys */
- {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},
-
- /* Virtual and Ascii Keys */
- {OS.VK_BACK, SWT.BS},
- {OS.VK_RETURN, SWT.CR},
- {OS.VK_DELETE, SWT.DEL},
- {OS.VK_ESCAPE, SWT.ESC},
- {OS.VK_RETURN, SWT.LF},
- {OS.VK_TAB, SWT.TAB},
-
- /* 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 Keys */
-// {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_DECIMAL},
-// {OS.VK_RETURN, SWT.KP_CR},
-// {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_PREFIX = "org.eclipse.swt.widgets.";
- /*
- * This code is intentionally commented. In order
- * to support CLDC, .class cannot be used because
- * it does not compile on some Java compilers when
- * they are targeted for CLDC.
- */
-// static {
-// String name = Display.class.getName ();
-// int index = name.lastIndexOf ('.');
-// PACKAGE_PREFIX = name.substring (0, index + 1);
-// }
-
- /*
- * TEMPORARY CODE. Install the runnable that
- * gets the current display. This code will
- * be removed in the future.
- */
- static {
- DeviceFinder = new Runnable () {
- public void run () {
- Device device = getCurrent ();
- if (device == null) {
- device = getDefault ();
- }
- setDevice (device);
- }
- };
- }
-
-/*
-* TEMPORARY CODE.
-*/
-static void setDevice (Device device) {
- CurrentDevice = device;
-}
-
-/**
- * Constructs a new instance of this class.
- * <p>
- * Note: The resulting display is marked as the <em>current</em>
- * display. If this is the first display which has been
- * constructed since the application started, it is also
- * marked as the <em>default</em> display.
- * </p>
- *
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS - if 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) {
- if (OS.IsWinCE) return 0;
-
- /* 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 or UNICODE using the virtual keyboard */
- if (OS.IsUnicode) {
- char [] result = new char [1];
- if (OS.ToUnicode (key, key, keyboard, result, 1, 0) == 1) return result [0];
- } else {
- short [] result = new short [1];
- if (OS.ToAscii (key, key, keyboard, result, 0) == 1) return result [0];
- }
- return 0;
-}
-
-/**
- * Adds the listener to the collection of listeners who will
- * be notifed when an event of the given type occurs anywhere
- * in SWT. When the event does occur, the listener is notified
- * by sending it the <code>handleEvent()</code> message.
- *
- * @param eventType the type of event to listen for
- * @param listener the listener which should be notified when the event occurs
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see Listener
- * @see #removeFilter
- * @see #removeListener
- *
- * @since 2.1
- */
-void addFilter (int eventType, Listener listener) {
- checkDevice ();
- if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
- if (filterTable == null) filterTable = new EventTable ();
- filterTable.hook (eventType, listener);
-}
-
-/**
- * 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 display, the listener is notified by
- * sending it the <code>handleEvent()</code> message.
- *
- * @param eventType the type of event to listen for
- * @param listener the listener which should be notified when the event occurs
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see Listener
- * @see #removeListener
- *
- * @since 2.0
- */
-public void addListener (int eventType, Listener listener) {
- checkDevice ();
- if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
- if (eventTable == null) eventTable = new EventTable ();
- eventTable.hook (eventType, listener);
-}
-
-void addBar (Menu menu) {
- if (bars == null) bars = new Menu [4];
- int length = bars.length;
- for (int i=0; i<length; i++) {
- if (bars [i] == menu) return;
- }
- int index = 0;
- while (index < length) {
- if (bars [index] == null) break;
- index++;
- }
- if (index == length) {
- Menu [] newBars = new Menu [length + 4];
- System.arraycopy (bars, 0, newBars, 0, length);
- bars = newBars;
- }
- bars [index] = menu;
-}
-
-void addPopup (Menu menu) {
- if (popups == null) popups = new Menu [4];
- int length = popups.length;
- for (int i=0; i<length; i++) {
- if (popups [i] == menu) return;
- }
- int index = 0;
- while (index < length) {
- if (popups [index] == null) break;
- index++;
- }
- if (index == length) {
- Menu [] newPopups = new Menu [length + 4];
- System.arraycopy (popups, 0, newPopups, 0, length);
- popups = newPopups;
- }
- popups [index] = menu;
-}
-
-/**
- * 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);
-}
-
-static synchronized void checkDisplay (Thread thread) {
- for (int i=0; i<Displays.length; i++) {
- if (Displays [i] != null && Displays [i].thread == thread) {
- SWT.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;
- 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;
-}
-
-/**
- * Requests that the connection between SWT and the underlying
- * operating system be closed.
- *
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see #dispose
- *
- * @since 2.0
- */
-public void close () {
- checkDevice ();
- Event event = new Event ();
- sendEvent (SWT.Close, event);
- if (event.doit) dispose ();
-}
-
-/**
- * Creates the device in the operating system. If the device
- * does not have a handle, this method may do nothing depending
- * on the device.
- * <p>
- * This method is called before <code>init</code>.
- * </p>
- *
- * @param data the DeviceData which describes the receiver
- *
- * @see #init
- */
-protected void create (DeviceData data) {
- checkSubclass ();
- checkDisplay (thread = Thread.currentThread ());
- createDisplay (data);
- register (this);
- if (Default == null) Default = this;
-}
-
-void createDisplay (DeviceData data) {
-}
-
-static synchronized void deregister (Display display) {
- for (int i=0; i<Displays.length; i++) {
- if (display == Displays [i]) Displays [i] = null;
- }
-}
-
-/**
- * Destroys the device in the operating system and releases
- * the device's handle. If the device does not have a handle,
- * this method may do nothing depending on the device.
- * <p>
- * This method is called after <code>release</code>.
- * </p>
- * @see #dispose
- * @see #release
- */
-protected void destroy () {
- if (this == Default) Default = null;
- deregister (this);
- 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;
-}
-
-void drawMenuBars () {
- if (bars == null) return;
- for (int i=0; i<bars.length; i++) {
- Menu menu = bars [i];
- if (menu != null && !menu.isDisposed ()) menu.update ();
- }
- bars = null;
-}
-
-/**
- * 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 filterEvent (Event event) {
- if (filterTable != null) filterTable.sendEvent (event);
- return false;
-}
-
-boolean filters (int eventType) {
- if (filterTable == null) return false;
- return filterTable.hooks (eventType);
-}
-
-boolean filterMessage (MSG msg) {
- int message = msg.message;
- if (OS.WM_KEYFIRST <= message && message <= OS.WM_KEYLAST) {
- Control control = findControl (msg.hwnd);
- if (control != null) {
- if (translateAccelerator (msg, control) || translateMnemonic (msg, control) || translateTraversal (msg, control)) {
- lastAscii = lastKey = 0;
- lastVirtual = lastNull = false;
- 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 ();
- if (OS.GetSystemMetrics (OS.SM_CMONITORS) < 2) {
- int width = OS.GetSystemMetrics (OS.SM_CXSCREEN);
- int height = OS.GetSystemMetrics (OS.SM_CYSCREEN);
- return new Rectangle (0, 0, width, height);
- }
- int x = OS.GetSystemMetrics (OS.SM_XVIRTUALSCREEN);
- int y = OS.GetSystemMetrics (OS.SM_YVIRTUALSCREEN);
- int width = OS.GetSystemMetrics (OS.SM_CXVIRTUALSCREEN);
- int height = OS.GetSystemMetrics (OS.SM_CYVIRTUALSCREEN);
- return new Rectangle (x, y, 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 ());
-}
-
-public Rectangle getClientArea () {
- checkDevice ();
- if (OS.GetSystemMetrics (OS.SM_CMONITORS) < 2) {
- RECT rect = new RECT ();
- OS.SystemParametersInfo (OS.SPI_GETWORKAREA, 0, rect, 0);
- int width = rect.right - rect.left;
- int height = rect.bottom - rect.top;
- return new Rectangle (rect.left, rect.top, width, height);
- }
- int x = OS.GetSystemMetrics (OS.SM_XVIRTUALSCREEN);
- int y = OS.GetSystemMetrics (OS.SM_YVIRTUALSCREEN);
- int width = OS.GetSystemMetrics (OS.SM_CXVIRTUALSCREEN);
- int height = OS.GetSystemMetrics (OS.SM_CYVIRTUALSCREEN);
- return new Rectangle (x, y, width, height);
-}
-
-/**
- * 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 ();
- if (!OS.GetCursorPos (pt)) return null;
- 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_PREFIX);
-}
-
-/**
- * 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 button dismissal alignment, one of <code>LEFT</code> or <code>RIGHT</code>.
- * The button dismissal alignment is the ordering that should be used when positioning the
- * default dismissal button for a dialog. For example, in a dialog that contains an OK and
- * CANCEL button, on platforms where the button dismissal alignment is <code>LEFT</code>, the
- * button ordering should be OK/CANCEL. When button dismissal alignment is <code>RIGHT</code>,
- * the button ordering should be CANCEL/OK.
- *
- * @return the button dismissal order
- *
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @since 2.1
- */
-public int getDismissalAlignment () {
- checkDevice ();
- return SWT.LEFT;
-}
-
-
-/**
- * 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 ();
-
- /* Use the character encoding for the default locale */
- TCHAR buffer1 = new TCHAR (0, "Control Panel\\Desktop\\WindowMetrics", true);
-
- int [] phkResult = new int [1];
- 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};
-
- /* Use the character encoding for the default locale */
- TCHAR lpData = new TCHAR (0, lpcbData [0]);
- TCHAR buffer2 = new TCHAR (0, "Shell Icon BPP", true);
-
- result = OS.RegQueryValueEx (phkResult [0], buffer2, 0, null, lpData, lpcbData);
- if (result == 0) {
- try {
- depth = Integer.parseInt (lpData.toString (0, lpData.strlen ()));
- } catch (NumberFormatException e) {};
- }
- OS.RegCloseKey (phkResult [0]);
- return depth;
-}
-
-ImageList getImageList (Point size) {
- if (imageList == null) imageList = new ImageList [4];
-
- int i = 0;
- int length = imageList.length;
- while (i < length) {
- ImageList list = imageList [i];
- if (list == null) break;
- if (list.getImageSize().equals(size)) {
- list.addRef();
- return list;
- }
- i++;
- }
-
- if (i == length) {
- ImageList [] newList = new ImageList [length + 4];
- System.arraycopy (imageList, 0, newList, 0, length);
- imageList = newList;
- }
-
- ImageList list = new ImageList();
- imageList [i] = list;
- list.addRef();
- return list;
-}
-
-ImageList getToolImageList (Point size) {
- if (toolImageList == null) toolImageList = new ImageList [4];
-
- int i = 0;
- int length = toolImageList.length;
- while (i < length) {
- ImageList list = toolImageList [i];
- if (list == null) break;
- if (list.getImageSize().equals(size)) {
- list.addRef();
- return list;
- }
- i++;
- }
-
- if (i == length) {
- ImageList [] newList = new ImageList [length + 4];
- System.arraycopy (toolImageList, 0, newList, 0, length);
- toolImageList = newList;
- }
-
- ImageList list = new ImageList();
- toolImageList [i] = list;
- list.addRef();
- return list;
-}
-
-ImageList getToolHotImageList (Point size) {
- if (toolHotImageList == null) toolHotImageList = new ImageList [4];
-
- int i = 0;
- int length = toolHotImageList.length;
- while (i < length) {
- ImageList list = toolHotImageList [i];
- if (list == null) break;
- if (list.getImageSize().equals(size)) {
- list.addRef();
- return list;
- }
- i++;
- }
-
- if (i == length) {
- ImageList [] newList = new ImageList [length + 4];
- System.arraycopy (toolHotImageList, 0, newList, 0, length);
- toolHotImageList = newList;
- }
-
- ImageList list = new ImageList();
- toolHotImageList [i] = list;
- list.addRef();
- return list;
-}
-
-ImageList getToolDisabledImageList (Point size) {
- if (toolDisabledImageList == null) toolDisabledImageList = new ImageList [4];
-
- int i = 0;
- int length = toolDisabledImageList.length;
- while (i < length) {
- ImageList list = toolDisabledImageList [i];
- if (list == null) break;
- if (list.getImageSize().equals(size)) {
- list.addRef();
- return list;
- }
- i++;
- }
-
- if (i == length) {
- ImageList [] newList = new ImageList [length + 4];
- System.arraycopy (toolDisabledImageList, 0, newList, 0, length);
- toolDisabledImageList = newList;
- }
-
- ImageList list = new ImageList();
- toolDisabledImageList [i] = list;
- list.addRef();
- return list;
-}
-
-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;
-}
-
-int getLastEventTime () {
- return OS.IsWinCE ? OS.GetTickCount () : OS.GetMessageTime ();
-}
-
-/**
- * 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);
- if (pixel == 0) pixel = OS.GetSysColor (OS.COLOR_ACTIVECAPTION);
- 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);
- if (pixel == 0) pixel = OS.GetSysColor (OS.COLOR_INACTIVECAPTION);
- 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 = systemFont ();
- 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) {
- if (isDisposed()) SWT.error(SWT.ERROR_DEVICE_DISPOSED);
- int hDC = OS.GetDC (0);
- if (hDC == 0) SWT.error (SWT.ERROR_NO_HANDLES);
- if (data != null) {
- data.device = this;
- data.hFont = systemFont ();
- }
- 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 ();
-
- /* Use the character encoding for the default locale */
- windowClass = new TCHAR (0, WindowName + WindowClassCount++, true);
-
- /* Register the SWT window class */
- int hHeap = OS.GetProcessHeap ();
- int hInstance = OS.GetModuleHandle (null);
- WNDCLASS lpWndClass = new WNDCLASS ();
- lpWndClass.hInstance = hInstance;
- lpWndClass.lpfnWndProc = windowProc;
- lpWndClass.style = OS.CS_BYTEALIGNWINDOW | OS.CS_DBLCLKS;
- lpWndClass.hCursor = OS.LoadCursor (0, OS.IDC_ARROW);
- int byteCount = windowClass.length () * TCHAR.sizeof;
- int lpszClassName = OS.HeapAlloc (hHeap, OS.HEAP_ZERO_MEMORY, byteCount);
- lpWndClass.lpszClassName = lpszClassName;
- OS.MoveMemory (lpszClassName, windowClass, byteCount);
- OS.RegisterClass (lpWndClass);
-
- /* Initialize the system font */
- int systemFont = 0;
- if (!OS.IsWinCE) {
- NONCLIENTMETRICS info = new NONCLIENTMETRICS ();
- info.cbSize = NONCLIENTMETRICS.sizeof;
- if (OS.SystemParametersInfo (OS.SPI_GETNONCLIENTMETRICS, 0, info, 0)) {
- systemFont = OS.CreateFontIndirect (info.lfMessageFont);
- }
- }
- if (systemFont == 0) systemFont = OS.GetStockObject (OS.DEFAULT_GUI_FONT);
- if (systemFont == 0) systemFont = OS.GetStockObject (OS.SYSTEM_FONT);
- if (systemFont != 0) systemFonts = new int [] {systemFont};
-
- /* Create the message only HWND */
- hwndMessage = OS.CreateWindowEx (0,
- windowClass,
- null,
- OS.WS_OVERLAPPED,
- 0, 0, 0, 0,
- 0,
- 0,
- hInstance,
- null);
- messageCallback = new Callback (this, "messageProc", 4);
- messageProc = messageCallback.getAddress ();
- if (messageProc == 0) error (SWT.ERROR_NO_MORE_CALLBACKS);
- OS.SetWindowLong (hwndMessage, OS.GWL_WNDPROC, messageProc);
-
- /* Create the message filter hook */
- if (!OS.IsWinCE) {
- msgFilterCallback = new Callback (this, "msgFilterProc", 3);
- msgFilterProc = msgFilterCallback.getAddress ();
- if (msgFilterProc == 0) error (SWT.ERROR_NO_MORE_CALLBACKS);
- hHook = OS.SetWindowsHookEx (OS.WH_MSGFILTER, msgFilterProc, 0, threadId);
- }
-}
-
-/**
- * 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 isWakeMessage (MSG msg) {
- return msg.hwnd == hwndMessage && msg.message == OS.WM_NULL;
-}
-
-boolean isValidThread () {
- return thread == Thread.currentThread ();
-}
-
-boolean isVirtualKey (int key) {
- switch (key) {
- case OS.VK_TAB:
- case OS.VK_RETURN:
- case OS.VK_BACK:
- case OS.VK_ESCAPE:
-// case OS.VK_DELETE:
- case OS.VK_SPACE:
- case OS.VK_MENU:
- case OS.VK_SHIFT:
- case OS.VK_CONTROL: return true;
- }
- return false;
-}
-
-int messageProc (int hwnd, int msg, int wParam, int lParam) {
- switch (msg) {
- case OS.WM_ACTIVATEAPP:
- /*
- * Feature in Windows. When multiple shells are
- * disabled and one of the shells has an enabled
- * dialog child and the user selects a disabled
- * shell that does not have the enabled dialog
- * child using the Task bar, Windows brings the
- * disabled shell to the front. As soon as the
- * user clicks on the disabled shell, the enabled
- * dialog child comes to the front. This behavior
- * is unspecified and seems strange. Normally, a
- * disabled shell is frozen on the screen and the
- * user cannot change the z-order by clicking with
- * the mouse. The fix is to look for WM_ACTIVATEAPP
- * and force the enabled dialog child to the front.
- * This is typically what the user is expecting.
- */
- if (wParam != 0) {
- Shell shell = getModalShell ();
- if (shell != null) shell.bringToTop ();
- }
- break;
- case OS.WM_ENDSESSION:
- if (wParam != 0) dispose ();
- break;
- case OS.WM_NULL:
- runAsyncMessages ();
- break;
- case OS.WM_QUERYENDSESSION:
- Event event = new Event ();
- sendEvent (SWT.Close, event);
- if (!event.doit) return 0;
- break;
- case OS.WM_SETTINGCHANGE:
- updateFont ();
- break;
- case OS.WM_TIMER:
- runTimer (wParam);
- break;
- }
- return OS.DefWindowProc (hwnd, msg, wParam, lParam);
-}
-
-int msgFilterProc (int code, int wParam, int lParam) {
- if (code >= 0) {
- OS.MoveMemory (hookMsg, lParam, MSG.sizeof);
- if (hookMsg.message == OS.WM_NULL) runAsyncMessages ();
- }
- return OS.CallNextHookEx (hHook, code, wParam, lParam);
-}
-
-int numpadKey (int key) {
- switch (key) {
- case OS.VK_NUMPAD0: return '0';
- case OS.VK_NUMPAD1: return '1';
- case OS.VK_NUMPAD2: return '2';
- case OS.VK_NUMPAD3: return '3';
- case OS.VK_NUMPAD4: return '4';
- case OS.VK_NUMPAD5: return '5';
- case OS.VK_NUMPAD6: return '6';
- case OS.VK_NUMPAD7: return '7';
- case OS.VK_NUMPAD8: return '8';
- case OS.VK_NUMPAD9: return '9';
- case OS.VK_MULTIPLY: return '*';
- case OS.VK_ADD: return '+';
- case OS.VK_SEPARATOR: return '\0';
- case OS.VK_SUBTRACT: return '-';
- case OS.VK_DECIMAL: return '.';
- case OS.VK_DIVIDE: return '/';
- }
- return 0;
-}
-
-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 ();
- drawMenuBars ();
- runPopups ();
- if (OS.PeekMessage (msg, 0, 0, 0, OS.PM_REMOVE)) {
- if (!isWakeMessage (msg)) {
- if (!filterMessage (msg)) {
- OS.TranslateMessage (msg);
- OS.DispatchMessage (msg);
- }
- runDeferredEvents ();
- return true;
- }
- }
- return runAsyncMessages ();
-}
-
-static synchronized void register (Display display) {
- for (int i=0; i<Displays.length; i++) {
- if (Displays [i] == null) {
- Displays [i] = display;
- return;
- }
- }
- Display [] newDisplays = new Display [Displays.length + 4];
- System.arraycopy (Displays, 0, newDisplays, 0, Displays.length);
- newDisplays [Displays.length] = display;
- Displays = newDisplays;
-}
-
-/**
- * Releases any internal resources back to the operating
- * system and clears all fields except the device handle.
- * <p>
- * Disposes all shells which are currently open on the display.
- * After this method has been invoked, all related related shells
- * will answer <code>true</code> when sent the message
- * <code>isDisposed()</code>.
- * </p><p>
- * When a device is destroyed, resources that were acquired
- * on behalf of the programmer need to be returned to the
- * operating system. For example, if the device allocated a
- * font to be used as the system font, this font would be
- * freed in <code>release</code>. Also,to assist the garbage
- * collector and minimize the amount of memory that is not
- * reclaimed when the programmer keeps a reference to a
- * disposed device, all fields except the handle are zero'd.
- * The handle is needed by <code>destroy</code>.
- * </p>
- * This method is called before <code>destroy</code>.
- *
- * @see #dispose
- * @see #destroy
- */
-protected void release () {
- sendEvent (SWT.Dispose, new Event ());
- 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 ()) {};
- if (disposeList != null) {
- for (int i=0; i<disposeList.length; i++) {
- if (disposeList [i] != null) disposeList [i].run ();
- }
- }
- disposeList = null;
- synchronizer.releaseSynchronizer ();
- synchronizer = null;
- releaseDisplay ();
- super.release ();
-}
-
-void releaseDisplay () {
-
- /* Unhook the message hook */
- if (!OS.IsWinCE) {
- if (hHook != 0) OS.UnhookWindowsHookEx (hHook);
- hHook = 0;
- msgFilterCallback.dispose ();
- msgFilterCallback = null;
- msgFilterProc = 0;
- }
-
- /* Destroy the message only HWND */
- if (hwndMessage != 0) OS.DestroyWindow (hwndMessage);
- hwndMessage = 0;
- messageCallback.dispose ();
- messageCallback = null;
- messageProc = 0;
-
- /* Unregister the SWT Window class */
- int hHeap = OS.GetProcessHeap ();
- int hInstance = OS.GetModuleHandle (null);
- WNDCLASS lpWndClass = new WNDCLASS ();
- OS.GetClassInfo (0, windowClass, lpWndClass);
- OS.UnregisterClass (windowClass, hInstance);
- OS.HeapFree (hHeap, 0, lpWndClass.lpszClassName);
- windowClass = null;
- windowCallback.dispose ();
- windowCallback = null;
- windowProc = 0;
-
- /* Release the system fonts */
- if (systemFonts != null) {
- for (int i=0; i<systemFonts.length; i++) {
- if (systemFonts [i] != 0) OS.DeleteObject (systemFonts [i]);
- }
- }
- systemFonts = null;
-
- /* Release Custom Colors for ChooseColor */
- if (lpCustColors != 0) OS.HeapFree (hHeap, 0, lpCustColors);
- lpCustColors = 0;
-
- /* Release references */
- thread = null;
- msg = null;
- keyboard = null;
- modalWidgets = null;
- data = null;
- keys = null;
- values = null;
-}
-
-void releaseImageList (ImageList list) {
- int i = 0;
- int length = imageList.length;
- while (i < length) {
- if (imageList [i] == list) {
- if (list.removeRef () > 0) return;
- list.dispose ();
- System.arraycopy (imageList, i + 1, imageList, i, --length - i);
- imageList [length] = null;
- for (int j=0; j<length; j++) {
- if (imageList [j] != null) return;
- }
- imageList = null;
- return;
- }
- i++;
- }
-}
-
-void releaseToolImageList (ImageList list) {
- int i = 0;
- int length = toolImageList.length;
- while (i < length) {
- if (toolImageList [i] == list) {
- if (list.removeRef () > 0) return;
- list.dispose ();
- System.arraycopy (toolImageList, i + 1, toolImageList, i, --length - i);
- toolImageList [length] = null;
- for (int j=0; j<length; j++) {
- if (toolImageList [j] != null) return;
- }
- toolImageList = null;
- return;
- }
- i++;
- }
-}
-
-void releaseToolHotImageList (ImageList list) {
- int i = 0;
- int length = toolHotImageList.length;
- while (i < length) {
- if (toolHotImageList [i] == list) {
- if (list.removeRef () > 0) return;
- list.dispose ();
- System.arraycopy (toolHotImageList, i + 1, toolHotImageList, i, --length - i);
- toolHotImageList [length] = null;
- for (int j=0; j<length; j++) {
- if (toolHotImageList [j] != null) return;
- }
- toolHotImageList = null;
- return;
- }
- i++;
- }
-}
-
-void releaseToolDisabledImageList (ImageList list) {
- int i = 0;
- int length = toolDisabledImageList.length;
- while (i < length) {
- if (toolDisabledImageList [i] == list) {
- if (list.removeRef () > 0) return;
- list.dispose ();
- System.arraycopy (toolDisabledImageList, i + 1, toolDisabledImageList, i, --length - i);
- toolDisabledImageList [length] = null;
- for (int j=0; j<length; j++) {
- if (toolDisabledImageList [j] != null) return;
- }
- toolDisabledImageList = null;
- return;
- }
- i++;
- }
-}
-
-/**
- * Removes the listener from the collection of listeners who will
- * be notifed when an event of the given type occurs anywhere in SWT.
- *
- * @param eventType the type of event to listen for
- * @param listener the listener which should no longer be notified when the event occurs
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see Listener
- * @see #addFilter
- * @see #addListener
- *
- * @since 2.1
- */
-void removeFilter (int eventType, Listener listener) {
- checkDevice ();
- if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
- if (filterTable == null) return;
- filterTable.unhook (eventType, listener);
- if (filterTable.size () == 0) filterTable = null;
-}
-
-/**
- * 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_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see Listener
- * @see #addListener
- *
- * @since 2.0
- */
-public void removeListener (int eventType, Listener listener) {
- checkDevice ();
- if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
- if (eventTable == null) return;
- eventTable.unhook (eventType, listener);
-}
-
-void removeBar (Menu menu) {
- if (bars == null) return;
- for (int i=0; i<bars.length; i++) {
- if (bars [i] == menu) {
- bars [i] = null;
- return;
- }
- }
-}
-
-void removePopup (Menu menu) {
- if (popups == null) return;
- for (int i=0; i<popups.length; i++) {
- if (popups [i] == menu) {
- popups [i] = null;
- return;
- }
- }
-}
-
-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 but need not be synchronized.
- */
- while (eventQueue != null) {
-
- /* Take an event off the queue */
- Event event = eventQueue [0];
- if (event == null) break;
- int length = eventQueue.length;
- System.arraycopy (eventQueue, 1, eventQueue, 0, --length);
- eventQueue [length] = null;
-
- /* Run the event */
- Widget widget = event.widget;
- if (widget != null && !widget.isDisposed ()) {
- Widget item = event.item;
- if (item == null || !item.isDisposed ()) {
- widget.sendEvent (event);
- }
- }
-
- /*
- * At this point, the event queue could
- * be null due to a recursive invokation
- * when running the event.
- */
- }
-
- /* Clear the queue */
- eventQueue = null;
- return true;
-}
-
-boolean runPopups () {
- if (popups == null) return false;
- boolean result = false;
- while (popups != null) {
- Menu menu = popups [0];
- if (menu == null) break;
- int length = popups.length;
- System.arraycopy (popups, 1, popups, 0, --length);
- popups [length] = null;
- menu._setVisible (true);
- result = true;
- }
- popups = null;
- return result;
-}
-
-boolean runTimer (int id) {
- if (timerList != null && timerIds != null) {
- int index = 0;
- while (index <timerIds.length) {
- if (timerIds [index] == id) {
- OS.KillTimer (hwndMessage, timerIds [index]);
- timerIds [index] = 0;
- Runnable runnable = timerList [index];
- timerList [index] = null;
- if (runnable != null) runnable.run ();
- return true;
- }
- index++;
- }
- }
- return false;
-}
-
-void sendEvent (int eventType, Event event) {
- if (eventTable == null && filterTable == null) {
- return;
- }
- if (event == null) event = new Event ();
- event.display = this;
- event.type = eventType;
- if (event.time == 0) event.time = getLastEventTime ();
- if (!filterEvent (event)) {
- if (eventTable != null) eventTable.sendEvent (event);
- }
-}
-
-/**
- * Sets the location of the on-screen pointer relative to the top left corner
- * of the screen. <b>Note: It is typically considered bad practice for a
- * program to move the on-screen pointer location.</b>
- *
- * @param x the new x coordinate for the cursor
- * @param y the new y coordinate for the cursor
- *
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @since 2.1
- */
-public void setCursorLocation (int x, int y) {
- checkDevice ();
- OS.SetCursorPos (x, y);
-}
-
-/**
- * Sets the location of the on-screen pointer relative to the top left corner
- * of the screen. <b>Note: It is typically considered bad practice for a
- * program to move the on-screen pointer location.</b>
- *
- * @param point new position
- *
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * <li>ERROR_NULL_ARGUMENT - if the point is null
- * </ul>
- *
- * @since 2.0
- */
-public void setCursorLocation (Point point) {
- checkDevice ();
- if (point == null) error (SWT.ERROR_NULL_ARGUMENT);
- setCursorLocation (point.x, point.y);
-}
-
-/**
- * Sets the application defined property of the receiver
- * with the specified name to the given argument.
- * <p>
- * Applications may have associated arbitrary objects with the
- * receiver in this fashion. If the objects stored in the
- * properties need to be notified when the display is disposed
- * of, it is the application's responsibility provide a
- * <code>disposeExec()</code> handler which does so.
- * </p>
- *
- * @param key the name of the property
- * @param value the new value for the property
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the key is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </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 setModalShell (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;
- 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) {
- if (OS.IsWinCE) return 0;
-
- /* 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 the key to ASCII or UNICODE using the virtual keyboard */
- if (OS.IsUnicode) {
- char [] result = new char [1];
- if (OS.ToUnicode (key, key, keyboard, result, 1, 0) == 1) return result [0];
- } else {
- 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 ();
- if (OS.IsWinCE) {
- OS.MsgWaitForMultipleObjectsEx (0, 0, OS.INFINITE, OS.QS_ALLINPUT, OS.MWMO_INPUTAVAILABLE);
- return true;
- }
- 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.
- *
- * @exception SWTException <ul>
- * <li>ERROR_FAILED_EXEC - if an exception occured when executing the runnable</li>
- * </ul>
- *
- * @see #asyncExec
- */
-public void syncExec (Runnable runnable) {
- if (isDisposed ()) error (SWT.ERROR_DEVICE_DISPOSED);
- synchronizer.syncExec (runnable);
-}
-
-int systemFont () {
- int hFont = 0;
- if (systemFonts != null) {
- int length = systemFonts.length;
- if (length != 0) hFont = systemFonts [length - 1];
- }
- if (hFont == 0) hFont = OS.GetStockObject (OS.DEFAULT_GUI_FONT);
- if (hFont == 0) hFont = OS.GetStockObject (OS.SYSTEM_FONT);
- return hFont;
-}
-
-/**
- * Causes the <code>run()</code> method of the runnable to
- * be invoked by the user-interface thread after the specified
- * number of milliseconds have elapsed. If milliseconds is less
- * than zero, the runnable is not executed.
- *
- * @param milliseconds the delay before running the runnable
- * @param runnable code to run on the user-interface thread
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the runnable is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see #asyncExec
- */
-public void timerExec (int milliseconds, Runnable runnable) {
- checkDevice ();
- if (runnable == null) error (SWT.ERROR_NULL_ARGUMENT);
- if (timerList == null) timerList = new Runnable [4];
- if (timerIds == null) timerIds = new int [4];
- int index = 0;
- while (index < timerList.length) {
- if (timerList [index] == runnable) break;
- index++;
- }
- int timerId = 0;
- if (index != timerList.length) {
- timerId = timerIds [index];
- if (milliseconds < 0) {
- OS.KillTimer (hwndMessage, timerId);
- timerList [index] = null;
- timerIds [index] = 0;
- return;
- }
- } else {
- if (milliseconds < 0) return;
- index = 0;
- while (index < timerList.length) {
- if (timerList [index] == null) break;
- index++;
- }
- timerCount++;
- timerId = timerCount;
- 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 newTimerID = OS.SetTimer (hwndMessage, timerId, milliseconds, 0);
- if (newTimerID != 0) {
- timerList [index] = runnable;
- timerIds [index] = newTimerID;
- }
-}
-
-boolean translateAccelerator (MSG msg, Control control) {
- 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, Control control) {
- switch (msg.message) {
- case OS.WM_CHAR:
- case OS.WM_SYSCHAR:
- return control.translateMnemonic (msg);
- }
- return false;
-}
-
-boolean translateTraversal (MSG msg, Control control) {
- switch (msg.message) {
- case 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:
- case OS.VK_PRIOR:
- case OS.VK_NEXT:
- return control.translateTraversal (msg);
- }
- break;
- case OS.WM_SYSKEYDOWN:
- switch (msg.wParam) {
- case OS.VK_MENU:
- return control.translateTraversal (msg);
- }
- break;
- }
- 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;
-}
-
-/**
- * Forces all outstanding paint requests for the display
- * to be processed before this method returns.
- *
- * @see Control#update
- */
-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 (true);
- }
- }
-}
-
-void updateFont () {
- if (OS.IsWinCE) return;
- Font oldFont = getSystemFont ();
- int systemFont = 0;
- NONCLIENTMETRICS info = new NONCLIENTMETRICS ();
- info.cbSize = NONCLIENTMETRICS.sizeof;
- if (OS.SystemParametersInfo (OS.SPI_GETNONCLIENTMETRICS, 0, info, 0)) {
- systemFont = OS.CreateFontIndirect (info.lfMessageFont);
- }
- if (systemFont == 0) systemFont = OS.GetStockObject (OS.DEFAULT_GUI_FONT);
- if (systemFont == 0) systemFont = OS.GetStockObject (OS.SYSTEM_FONT);
- if (systemFont == 0) return;
- int length = systemFonts == null ? 0 : systemFonts.length;
- int [] newFonts = new int [length + 1];
- if (systemFonts != null) {
- System.arraycopy (systemFonts, 0, newFonts, 0, length);
- }
- newFonts [length] = systemFont;
- systemFonts = newFonts;
- Font newFont = getSystemFont ();
- Shell [] shells = getShells ();
- for (int i=0; i<shells.length; i++) {
- Shell shell = shells [i];
- if (!shell.isDisposed ()) {
- shell.updateFont (oldFont, newFont);
- }
- }
-}
-
-/**
- * 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);
- if (thread == Thread.currentThread ()) return;
- if (OS.IsWinCE) {
- OS.PostMessage (hwndMessage, OS.WM_NULL, 0, 0);
- } else {
- 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 ();
-}
-
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+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>
+ * <dl>
+ * <dt><b>Styles:</b></dt>
+ * <dd>(none)</dd>
+ * <dt><b>Events:</b></dt>
+ * <dd>Close, Dispose</dd>
+ * </dl>
+ * <p>
+ * IMPORTANT: This class is <em>not</em> intended to be subclassed.
+ * </p>
+ * @see #syncExec
+ * @see #asyncExec
+ * @see #wake
+ * @see #readAndDispatch
+ * @see #sleep
+ * @see #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 and Events */
+ Event [] eventQueue;
+ Callback windowCallback;
+ int windowProc, threadId, processId;
+ TCHAR windowClass;
+ static int WindowClassCount = 0;
+ static final String WindowName = "SWT_Window";
+ EventTable eventTable, filterTable;
+
+ /* Message Filter */
+ Callback msgFilterCallback;
+ int msgFilterProc, hHook;
+ MSG hookMsg = new MSG ();
+
+ /* Sync/Async Widget Communication */
+ Synchronizer synchronizer = new Synchronizer (this);
+ Thread thread;
+
+ /* Display Shutdown */
+ Runnable [] disposeList;
+
+ /* Timers */
+ int timerCount;
+ int [] timerIds;
+ Runnable [] timerList;
+
+ /* Keyboard and Mouse State */
+ boolean lockActiveWindow;
+ boolean lastVirtual, lastNull;
+ int lastKey, lastAscii, lastMouse;
+ byte [] keyboard = new byte [256];
+ boolean accelKeyHit, mnemonicKeyHit;
+
+ /* Message Only Window */
+ int hwndMessage, messageProc;
+ Callback messageCallback;
+ int [] systemFonts;
+
+ /* Image list cache */
+ ImageList[] imageList, toolImageList, toolHotImageList, toolDisabledImageList;
+
+ /* Custom Colors for ChooseColor */
+ int lpCustColors;
+
+ /* Display Data */
+ Object data;
+ String [] keys;
+ Object [] values;
+
+ /* Bar and Popup Menus */
+ Menu [] bars, popups;
+
+ /* 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 Keys */
+ {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},
+
+ /* Virtual and Ascii Keys */
+ {OS.VK_BACK, SWT.BS},
+ {OS.VK_RETURN, SWT.CR},
+ {OS.VK_DELETE, SWT.DEL},
+ {OS.VK_ESCAPE, SWT.ESC},
+ {OS.VK_RETURN, SWT.LF},
+ {OS.VK_TAB, SWT.TAB},
+
+ /* 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 Keys */
+// {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_DECIMAL},
+// {OS.VK_RETURN, SWT.KP_CR},
+// {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_PREFIX = "org.eclipse.swt.widgets.";
+ /*
+ * This code is intentionally commented. In order
+ * to support CLDC, .class cannot be used because
+ * it does not compile on some Java compilers when
+ * they are targeted for CLDC.
+ */
+// static {
+// String name = Display.class.getName ();
+// int index = name.lastIndexOf ('.');
+// PACKAGE_PREFIX = name.substring (0, index + 1);
+// }
+
+ /*
+ * TEMPORARY CODE. Install the runnable that
+ * gets the current display. This code will
+ * be removed in the future.
+ */
+ static {
+ DeviceFinder = new Runnable () {
+ public void run () {
+ Device device = getCurrent ();
+ if (device == null) {
+ device = getDefault ();
+ }
+ setDevice (device);
+ }
+ };
+ }
+
+/*
+* TEMPORARY CODE.
+*/
+static void setDevice (Device device) {
+ CurrentDevice = device;
+}
+
+/**
+ * Constructs a new instance of this class.
+ * <p>
+ * Note: The resulting display is marked as the <em>current</em>
+ * display. If this is the first display which has been
+ * constructed since the application started, it is also
+ * marked as the <em>default</em> display.
+ * </p>
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if 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) {
+ if (OS.IsWinCE) return 0;
+
+ /* 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 or UNICODE using the virtual keyboard */
+ if (OS.IsUnicode) {
+ char [] result = new char [1];
+ if (OS.ToUnicode (key, key, keyboard, result, 1, 0) == 1) return result [0];
+ } else {
+ short [] result = new short [1];
+ if (OS.ToAscii (key, key, keyboard, result, 0) == 1) return result [0];
+ }
+ return 0;
+}
+
+/**
+ * Adds the listener to the collection of listeners who will
+ * be notifed when an event of the given type occurs anywhere
+ * in SWT. When the event does occur, the listener is notified
+ * by sending it the <code>handleEvent()</code> message.
+ *
+ * @param eventType the type of event to listen for
+ * @param listener the listener which should be notified when the event occurs
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see Listener
+ * @see #removeFilter
+ * @see #removeListener
+ *
+ * @since 2.1
+ */
+void addFilter (int eventType, Listener listener) {
+ checkDevice ();
+ if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+ if (filterTable == null) filterTable = new EventTable ();
+ filterTable.hook (eventType, listener);
+}
+
+/**
+ * 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 display, the listener is notified by
+ * sending it the <code>handleEvent()</code> message.
+ *
+ * @param eventType the type of event to listen for
+ * @param listener the listener which should be notified when the event occurs
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see Listener
+ * @see #removeListener
+ *
+ * @since 2.0
+ */
+public void addListener (int eventType, Listener listener) {
+ checkDevice ();
+ if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+ if (eventTable == null) eventTable = new EventTable ();
+ eventTable.hook (eventType, listener);
+}
+
+void addBar (Menu menu) {
+ if (bars == null) bars = new Menu [4];
+ int length = bars.length;
+ for (int i=0; i<length; i++) {
+ if (bars [i] == menu) return;
+ }
+ int index = 0;
+ while (index < length) {
+ if (bars [index] == null) break;
+ index++;
+ }
+ if (index == length) {
+ Menu [] newBars = new Menu [length + 4];
+ System.arraycopy (bars, 0, newBars, 0, length);
+ bars = newBars;
+ }
+ bars [index] = menu;
+}
+
+void addPopup (Menu menu) {
+ if (popups == null) popups = new Menu [4];
+ int length = popups.length;
+ for (int i=0; i<length; i++) {
+ if (popups [i] == menu) return;
+ }
+ int index = 0;
+ while (index < length) {
+ if (popups [index] == null) break;
+ index++;
+ }
+ if (index == length) {
+ Menu [] newPopups = new Menu [length + 4];
+ System.arraycopy (popups, 0, newPopups, 0, length);
+ popups = newPopups;
+ }
+ popups [index] = menu;
+}
+
+/**
+ * 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);
+}
+
+static synchronized void checkDisplay (Thread thread) {
+ for (int i=0; i<Displays.length; i++) {
+ if (Displays [i] != null && Displays [i].thread == thread) {
+ SWT.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;
+ 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;
+}
+
+/**
+ * Requests that the connection between SWT and the underlying
+ * operating system be closed.
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see #dispose
+ *
+ * @since 2.0
+ */
+public void close () {
+ checkDevice ();
+ Event event = new Event ();
+ sendEvent (SWT.Close, event);
+ if (event.doit) dispose ();
+}
+
+/**
+ * Creates the device in the operating system. If the device
+ * does not have a handle, this method may do nothing depending
+ * on the device.
+ * <p>
+ * This method is called before <code>init</code>.
+ * </p>
+ *
+ * @param data the DeviceData which describes the receiver
+ *
+ * @see #init
+ */
+protected void create (DeviceData data) {
+ checkSubclass ();
+ checkDisplay (thread = Thread.currentThread ());
+ createDisplay (data);
+ register (this);
+ if (Default == null) Default = this;
+}
+
+void createDisplay (DeviceData data) {
+}
+
+static synchronized void deregister (Display display) {
+ for (int i=0; i<Displays.length; i++) {
+ if (display == Displays [i]) Displays [i] = null;
+ }
+}
+
+/**
+ * Destroys the device in the operating system and releases
+ * the device's handle. If the device does not have a handle,
+ * this method may do nothing depending on the device.
+ * <p>
+ * This method is called after <code>release</code>.
+ * </p>
+ * @see #dispose
+ * @see #release
+ */
+protected void destroy () {
+ if (this == Default) Default = null;
+ deregister (this);
+ 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;
+}
+
+void drawMenuBars () {
+ if (bars == null) return;
+ for (int i=0; i<bars.length; i++) {
+ Menu menu = bars [i];
+ if (menu != null && !menu.isDisposed ()) menu.update ();
+ }
+ bars = null;
+}
+
+/**
+ * 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 filterEvent (Event event) {
+ if (filterTable != null) filterTable.sendEvent (event);
+ return false;
+}
+
+boolean filters (int eventType) {
+ if (filterTable == null) return false;
+ return filterTable.hooks (eventType);
+}
+
+boolean filterMessage (MSG msg) {
+ int message = msg.message;
+ if (OS.WM_KEYFIRST <= message && message <= OS.WM_KEYLAST) {
+ Control control = findControl (msg.hwnd);
+ if (control != null) {
+ if (translateAccelerator (msg, control) || translateMnemonic (msg, control) || translateTraversal (msg, control)) {
+ lastAscii = lastKey = 0;
+ lastVirtual = lastNull = false;
+ 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 ();
+ if (OS.GetSystemMetrics (OS.SM_CMONITORS) < 2) {
+ int width = OS.GetSystemMetrics (OS.SM_CXSCREEN);
+ int height = OS.GetSystemMetrics (OS.SM_CYSCREEN);
+ return new Rectangle (0, 0, width, height);
+ }
+ int x = OS.GetSystemMetrics (OS.SM_XVIRTUALSCREEN);
+ int y = OS.GetSystemMetrics (OS.SM_YVIRTUALSCREEN);
+ int width = OS.GetSystemMetrics (OS.SM_CXVIRTUALSCREEN);
+ int height = OS.GetSystemMetrics (OS.SM_CYVIRTUALSCREEN);
+ return new Rectangle (x, y, 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 ());
+}
+
+public Rectangle getClientArea () {
+ checkDevice ();
+ if (OS.GetSystemMetrics (OS.SM_CMONITORS) < 2) {
+ RECT rect = new RECT ();
+ OS.SystemParametersInfo (OS.SPI_GETWORKAREA, 0, rect, 0);
+ int width = rect.right - rect.left;
+ int height = rect.bottom - rect.top;
+ return new Rectangle (rect.left, rect.top, width, height);
+ }
+ int x = OS.GetSystemMetrics (OS.SM_XVIRTUALSCREEN);
+ int y = OS.GetSystemMetrics (OS.SM_YVIRTUALSCREEN);
+ int width = OS.GetSystemMetrics (OS.SM_CXVIRTUALSCREEN);
+ int height = OS.GetSystemMetrics (OS.SM_CYVIRTUALSCREEN);
+ return new Rectangle (x, y, width, height);
+}
+
+/**
+ * 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 ();
+ if (!OS.GetCursorPos (pt)) return null;
+ 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_PREFIX);
+}
+
+/**
+ * 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 button dismissal alignment, one of <code>LEFT</code> or <code>RIGHT</code>.
+ * The button dismissal alignment is the ordering that should be used when positioning the
+ * default dismissal button for a dialog. For example, in a dialog that contains an OK and
+ * CANCEL button, on platforms where the button dismissal alignment is <code>LEFT</code>, the
+ * button ordering should be OK/CANCEL. When button dismissal alignment is <code>RIGHT</code>,
+ * the button ordering should be CANCEL/OK.
+ *
+ * @return the button dismissal order
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @since 2.1
+ */
+public int getDismissalAlignment () {
+ checkDevice ();
+ return SWT.LEFT;
+}
+
+
+/**
+ * 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 ();
+
+ /* Use the character encoding for the default locale */
+ TCHAR buffer1 = new TCHAR (0, "Control Panel\\Desktop\\WindowMetrics", true);
+
+ int [] phkResult = new int [1];
+ 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};
+
+ /* Use the character encoding for the default locale */
+ TCHAR lpData = new TCHAR (0, lpcbData [0]);
+ TCHAR buffer2 = new TCHAR (0, "Shell Icon BPP", true);
+
+ result = OS.RegQueryValueEx (phkResult [0], buffer2, 0, null, lpData, lpcbData);
+ if (result == 0) {
+ try {
+ depth = Integer.parseInt (lpData.toString (0, lpData.strlen ()));
+ } catch (NumberFormatException e) {};
+ }
+ OS.RegCloseKey (phkResult [0]);
+ return depth;
+}
+
+ImageList getImageList (Point size) {
+ if (imageList == null) imageList = new ImageList [4];
+
+ int i = 0;
+ int length = imageList.length;
+ while (i < length) {
+ ImageList list = imageList [i];
+ if (list == null) break;
+ if (list.getImageSize().equals(size)) {
+ list.addRef();
+ return list;
+ }
+ i++;
+ }
+
+ if (i == length) {
+ ImageList [] newList = new ImageList [length + 4];
+ System.arraycopy (imageList, 0, newList, 0, length);
+ imageList = newList;
+ }
+
+ ImageList list = new ImageList();
+ imageList [i] = list;
+ list.addRef();
+ return list;
+}
+
+ImageList getToolImageList (Point size) {
+ if (toolImageList == null) toolImageList = new ImageList [4];
+
+ int i = 0;
+ int length = toolImageList.length;
+ while (i < length) {
+ ImageList list = toolImageList [i];
+ if (list == null) break;
+ if (list.getImageSize().equals(size)) {
+ list.addRef();
+ return list;
+ }
+ i++;
+ }
+
+ if (i == length) {
+ ImageList [] newList = new ImageList [length + 4];
+ System.arraycopy (toolImageList, 0, newList, 0, length);
+ toolImageList = newList;
+ }
+
+ ImageList list = new ImageList();
+ toolImageList [i] = list;
+ list.addRef();
+ return list;
+}
+
+ImageList getToolHotImageList (Point size) {
+ if (toolHotImageList == null) toolHotImageList = new ImageList [4];
+
+ int i = 0;
+ int length = toolHotImageList.length;
+ while (i < length) {
+ ImageList list = toolHotImageList [i];
+ if (list == null) break;
+ if (list.getImageSize().equals(size)) {
+ list.addRef();
+ return list;
+ }
+ i++;
+ }
+
+ if (i == length) {
+ ImageList [] newList = new ImageList [length + 4];
+ System.arraycopy (toolHotImageList, 0, newList, 0, length);
+ toolHotImageList = newList;
+ }
+
+ ImageList list = new ImageList();
+ toolHotImageList [i] = list;
+ list.addRef();
+ return list;
+}
+
+ImageList getToolDisabledImageList (Point size) {
+ if (toolDisabledImageList == null) toolDisabledImageList = new ImageList [4];
+
+ int i = 0;
+ int length = toolDisabledImageList.length;
+ while (i < length) {
+ ImageList list = toolDisabledImageList [i];
+ if (list == null) break;
+ if (list.getImageSize().equals(size)) {
+ list.addRef();
+ return list;
+ }
+ i++;
+ }
+
+ if (i == length) {
+ ImageList [] newList = new ImageList [length + 4];
+ System.arraycopy (toolDisabledImageList, 0, newList, 0, length);
+ toolDisabledImageList = newList;
+ }
+
+ ImageList list = new ImageList();
+ toolDisabledImageList [i] = list;
+ list.addRef();
+ return list;
+}
+
+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;
+}
+
+int getLastEventTime () {
+ return OS.IsWinCE ? OS.GetTickCount () : OS.GetMessageTime ();
+}
+
+/**
+ * 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);
+ if (pixel == 0) pixel = OS.GetSysColor (OS.COLOR_ACTIVECAPTION);
+ 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);
+ if (pixel == 0) pixel = OS.GetSysColor (OS.COLOR_INACTIVECAPTION);
+ 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 = systemFont ();
+ 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) {
+ if (isDisposed()) SWT.error(SWT.ERROR_DEVICE_DISPOSED);
+ int hDC = OS.GetDC (0);
+ if (hDC == 0) SWT.error (SWT.ERROR_NO_HANDLES);
+ if (data != null) {
+ data.device = this;
+ data.hFont = systemFont ();
+ }
+ 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 ();
+
+ /* Use the character encoding for the default locale */
+ windowClass = new TCHAR (0, WindowName + WindowClassCount++, true);
+
+ /* Register the SWT window class */
+ int hHeap = OS.GetProcessHeap ();
+ int hInstance = OS.GetModuleHandle (null);
+ WNDCLASS lpWndClass = new WNDCLASS ();
+ lpWndClass.hInstance = hInstance;
+ lpWndClass.lpfnWndProc = windowProc;
+ lpWndClass.style = OS.CS_BYTEALIGNWINDOW | OS.CS_DBLCLKS;
+ lpWndClass.hCursor = OS.LoadCursor (0, OS.IDC_ARROW);
+ int byteCount = windowClass.length () * TCHAR.sizeof;
+ int lpszClassName = OS.HeapAlloc (hHeap, OS.HEAP_ZERO_MEMORY, byteCount);
+ lpWndClass.lpszClassName = lpszClassName;
+ OS.MoveMemory (lpszClassName, windowClass, byteCount);
+ OS.RegisterClass (lpWndClass);
+
+ /* Initialize the system font */
+ int systemFont = 0;
+ if (!OS.IsWinCE) {
+ NONCLIENTMETRICS info = new NONCLIENTMETRICS ();
+ info.cbSize = NONCLIENTMETRICS.sizeof;
+ if (OS.SystemParametersInfo (OS.SPI_GETNONCLIENTMETRICS, 0, info, 0)) {
+ systemFont = OS.CreateFontIndirect (info.lfMessageFont);
+ }
+ }
+ if (systemFont == 0) systemFont = OS.GetStockObject (OS.DEFAULT_GUI_FONT);
+ if (systemFont == 0) systemFont = OS.GetStockObject (OS.SYSTEM_FONT);
+ if (systemFont != 0) systemFonts = new int [] {systemFont};
+
+ /* Create the message only HWND */
+ hwndMessage = OS.CreateWindowEx (0,
+ windowClass,
+ null,
+ OS.WS_OVERLAPPED,
+ 0, 0, 0, 0,
+ 0,
+ 0,
+ hInstance,
+ null);
+ messageCallback = new Callback (this, "messageProc", 4);
+ messageProc = messageCallback.getAddress ();
+ if (messageProc == 0) error (SWT.ERROR_NO_MORE_CALLBACKS);
+ OS.SetWindowLong (hwndMessage, OS.GWL_WNDPROC, messageProc);
+
+ /* Create the message filter hook */
+ if (!OS.IsWinCE) {
+ msgFilterCallback = new Callback (this, "msgFilterProc", 3);
+ msgFilterProc = msgFilterCallback.getAddress ();
+ if (msgFilterProc == 0) error (SWT.ERROR_NO_MORE_CALLBACKS);
+ hHook = OS.SetWindowsHookEx (OS.WH_MSGFILTER, msgFilterProc, 0, threadId);
+ }
+}
+
+/**
+ * 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 isWakeMessage (MSG msg) {
+ return msg.hwnd == hwndMessage && msg.message == OS.WM_NULL;
+}
+
+boolean isValidThread () {
+ return thread == Thread.currentThread ();
+}
+
+boolean isVirtualKey (int key) {
+ switch (key) {
+ case OS.VK_TAB:
+ case OS.VK_RETURN:
+ case OS.VK_BACK:
+ case OS.VK_ESCAPE:
+// case OS.VK_DELETE:
+ case OS.VK_SPACE:
+ case OS.VK_MENU:
+ case OS.VK_SHIFT:
+ case OS.VK_CONTROL: return true;
+ }
+ return false;
+}
+
+int messageProc (int hwnd, int msg, int wParam, int lParam) {
+ switch (msg) {
+ case OS.WM_ACTIVATEAPP:
+ /*
+ * Feature in Windows. When multiple shells are
+ * disabled and one of the shells has an enabled
+ * dialog child and the user selects a disabled
+ * shell that does not have the enabled dialog
+ * child using the Task bar, Windows brings the
+ * disabled shell to the front. As soon as the
+ * user clicks on the disabled shell, the enabled
+ * dialog child comes to the front. This behavior
+ * is unspecified and seems strange. Normally, a
+ * disabled shell is frozen on the screen and the
+ * user cannot change the z-order by clicking with
+ * the mouse. The fix is to look for WM_ACTIVATEAPP
+ * and force the enabled dialog child to the front.
+ * This is typically what the user is expecting.
+ */
+ if (wParam != 0) {
+ Shell shell = getModalShell ();
+ if (shell != null) shell.bringToTop ();
+ }
+ break;
+ case OS.WM_ENDSESSION:
+ if (wParam != 0) dispose ();
+ break;
+ case OS.WM_NULL:
+ runAsyncMessages ();
+ break;
+ case OS.WM_QUERYENDSESSION:
+ Event event = new Event ();
+ sendEvent (SWT.Close, event);
+ if (!event.doit) return 0;
+ break;
+ case OS.WM_SETTINGCHANGE:
+ updateFont ();
+ break;
+ case OS.WM_TIMER:
+ runTimer (wParam);
+ break;
+ }
+ return OS.DefWindowProc (hwnd, msg, wParam, lParam);
+}
+
+int msgFilterProc (int code, int wParam, int lParam) {
+ if (code >= 0) {
+ OS.MoveMemory (hookMsg, lParam, MSG.sizeof);
+ if (hookMsg.message == OS.WM_NULL) runAsyncMessages ();
+ }
+ return OS.CallNextHookEx (hHook, code, wParam, lParam);
+}
+
+int numpadKey (int key) {
+ switch (key) {
+ case OS.VK_NUMPAD0: return '0';
+ case OS.VK_NUMPAD1: return '1';
+ case OS.VK_NUMPAD2: return '2';
+ case OS.VK_NUMPAD3: return '3';
+ case OS.VK_NUMPAD4: return '4';
+ case OS.VK_NUMPAD5: return '5';
+ case OS.VK_NUMPAD6: return '6';
+ case OS.VK_NUMPAD7: return '7';
+ case OS.VK_NUMPAD8: return '8';
+ case OS.VK_NUMPAD9: return '9';
+ case OS.VK_MULTIPLY: return '*';
+ case OS.VK_ADD: return '+';
+ case OS.VK_SEPARATOR: return '\0';
+ case OS.VK_SUBTRACT: return '-';
+ case OS.VK_DECIMAL: return '.';
+ case OS.VK_DIVIDE: return '/';
+ }
+ return 0;
+}
+
+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 ();
+ drawMenuBars ();
+ runPopups ();
+ if (OS.PeekMessage (msg, 0, 0, 0, OS.PM_REMOVE)) {
+ if (!isWakeMessage (msg)) {
+ if (!filterMessage (msg)) {
+ OS.TranslateMessage (msg);
+ OS.DispatchMessage (msg);
+ }
+ runDeferredEvents ();
+ return true;
+ }
+ }
+ return runAsyncMessages ();
+}
+
+static synchronized void register (Display display) {
+ for (int i=0; i<Displays.length; i++) {
+ if (Displays [i] == null) {
+ Displays [i] = display;
+ return;
+ }
+ }
+ Display [] newDisplays = new Display [Displays.length + 4];
+ System.arraycopy (Displays, 0, newDisplays, 0, Displays.length);
+ newDisplays [Displays.length] = display;
+ Displays = newDisplays;
+}
+
+/**
+ * Releases any internal resources back to the operating
+ * system and clears all fields except the device handle.
+ * <p>
+ * Disposes all shells which are currently open on the display.
+ * After this method has been invoked, all related related shells
+ * will answer <code>true</code> when sent the message
+ * <code>isDisposed()</code>.
+ * </p><p>
+ * When a device is destroyed, resources that were acquired
+ * on behalf of the programmer need to be returned to the
+ * operating system. For example, if the device allocated a
+ * font to be used as the system font, this font would be
+ * freed in <code>release</code>. Also,to assist the garbage
+ * collector and minimize the amount of memory that is not
+ * reclaimed when the programmer keeps a reference to a
+ * disposed device, all fields except the handle are zero'd.
+ * The handle is needed by <code>destroy</code>.
+ * </p>
+ * This method is called before <code>destroy</code>.
+ *
+ * @see #dispose
+ * @see #destroy
+ */
+protected void release () {
+ sendEvent (SWT.Dispose, new Event ());
+ 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 ()) {};
+ if (disposeList != null) {
+ for (int i=0; i<disposeList.length; i++) {
+ if (disposeList [i] != null) disposeList [i].run ();
+ }
+ }
+ disposeList = null;
+ synchronizer.releaseSynchronizer ();
+ synchronizer = null;
+ releaseDisplay ();
+ super.release ();
+}
+
+void releaseDisplay () {
+
+ /* Unhook the message hook */
+ if (!OS.IsWinCE) {
+ if (hHook != 0) OS.UnhookWindowsHookEx (hHook);
+ hHook = 0;
+ msgFilterCallback.dispose ();
+ msgFilterCallback = null;
+ msgFilterProc = 0;
+ }
+
+ /* Destroy the message only HWND */
+ if (hwndMessage != 0) OS.DestroyWindow (hwndMessage);
+ hwndMessage = 0;
+ messageCallback.dispose ();
+ messageCallback = null;
+ messageProc = 0;
+
+ /* Unregister the SWT Window class */
+ int hHeap = OS.GetProcessHeap ();
+ int hInstance = OS.GetModuleHandle (null);
+ WNDCLASS lpWndClass = new WNDCLASS ();
+ OS.GetClassInfo (0, windowClass, lpWndClass);
+ OS.UnregisterClass (windowClass, hInstance);
+ OS.HeapFree (hHeap, 0, lpWndClass.lpszClassName);
+ windowClass = null;
+ windowCallback.dispose ();
+ windowCallback = null;
+ windowProc = 0;
+
+ /* Release the system fonts */
+ if (systemFonts != null) {
+ for (int i=0; i<systemFonts.length; i++) {
+ if (systemFonts [i] != 0) OS.DeleteObject (systemFonts [i]);
+ }
+ }
+ systemFonts = null;
+
+ /* Release Custom Colors for ChooseColor */
+ if (lpCustColors != 0) OS.HeapFree (hHeap, 0, lpCustColors);
+ lpCustColors = 0;
+
+ /* Release references */
+ thread = null;
+ msg = null;
+ keyboard = null;
+ modalWidgets = null;
+ data = null;
+ keys = null;
+ values = null;
+}
+
+void releaseImageList (ImageList list) {
+ int i = 0;
+ int length = imageList.length;
+ while (i < length) {
+ if (imageList [i] == list) {
+ if (list.removeRef () > 0) return;
+ list.dispose ();
+ System.arraycopy (imageList, i + 1, imageList, i, --length - i);
+ imageList [length] = null;
+ for (int j=0; j<length; j++) {
+ if (imageList [j] != null) return;
+ }
+ imageList = null;
+ return;
+ }
+ i++;
+ }
+}
+
+void releaseToolImageList (ImageList list) {
+ int i = 0;
+ int length = toolImageList.length;
+ while (i < length) {
+ if (toolImageList [i] == list) {
+ if (list.removeRef () > 0) return;
+ list.dispose ();
+ System.arraycopy (toolImageList, i + 1, toolImageList, i, --length - i);
+ toolImageList [length] = null;
+ for (int j=0; j<length; j++) {
+ if (toolImageList [j] != null) return;
+ }
+ toolImageList = null;
+ return;
+ }
+ i++;
+ }
+}
+
+void releaseToolHotImageList (ImageList list) {
+ int i = 0;
+ int length = toolHotImageList.length;
+ while (i < length) {
+ if (toolHotImageList [i] == list) {
+ if (list.removeRef () > 0) return;
+ list.dispose ();
+ System.arraycopy (toolHotImageList, i + 1, toolHotImageList, i, --length - i);
+ toolHotImageList [length] = null;
+ for (int j=0; j<length; j++) {
+ if (toolHotImageList [j] != null) return;
+ }
+ toolHotImageList = null;
+ return;
+ }
+ i++;
+ }
+}
+
+void releaseToolDisabledImageList (ImageList list) {
+ int i = 0;
+ int length = toolDisabledImageList.length;
+ while (i < length) {
+ if (toolDisabledImageList [i] == list) {
+ if (list.removeRef () > 0) return;
+ list.dispose ();
+ System.arraycopy (toolDisabledImageList, i + 1, toolDisabledImageList, i, --length - i);
+ toolDisabledImageList [length] = null;
+ for (int j=0; j<length; j++) {
+ if (toolDisabledImageList [j] != null) return;
+ }
+ toolDisabledImageList = null;
+ return;
+ }
+ i++;
+ }
+}
+
+/**
+ * Removes the listener from the collection of listeners who will
+ * be notifed when an event of the given type occurs anywhere in SWT.
+ *
+ * @param eventType the type of event to listen for
+ * @param listener the listener which should no longer be notified when the event occurs
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see Listener
+ * @see #addFilter
+ * @see #addListener
+ *
+ * @since 2.1
+ */
+void removeFilter (int eventType, Listener listener) {
+ checkDevice ();
+ if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+ if (filterTable == null) return;
+ filterTable.unhook (eventType, listener);
+ if (filterTable.size () == 0) filterTable = null;
+}
+
+/**
+ * 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_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see Listener
+ * @see #addListener
+ *
+ * @since 2.0
+ */
+public void removeListener (int eventType, Listener listener) {
+ checkDevice ();
+ if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+ if (eventTable == null) return;
+ eventTable.unhook (eventType, listener);
+}
+
+void removeBar (Menu menu) {
+ if (bars == null) return;
+ for (int i=0; i<bars.length; i++) {
+ if (bars [i] == menu) {
+ bars [i] = null;
+ return;
+ }
+ }
+}
+
+void removePopup (Menu menu) {
+ if (popups == null) return;
+ for (int i=0; i<popups.length; i++) {
+ if (popups [i] == menu) {
+ popups [i] = null;
+ return;
+ }
+ }
+}
+
+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 but need not be synchronized.
+ */
+ while (eventQueue != null) {
+
+ /* Take an event off the queue */
+ Event event = eventQueue [0];
+ if (event == null) break;
+ int length = eventQueue.length;
+ System.arraycopy (eventQueue, 1, eventQueue, 0, --length);
+ eventQueue [length] = null;
+
+ /* Run the event */
+ Widget widget = event.widget;
+ if (widget != null && !widget.isDisposed ()) {
+ Widget item = event.item;
+ if (item == null || !item.isDisposed ()) {
+ widget.sendEvent (event);
+ }
+ }
+
+ /*
+ * At this point, the event queue could
+ * be null due to a recursive invokation
+ * when running the event.
+ */
+ }
+
+ /* Clear the queue */
+ eventQueue = null;
+ return true;
+}
+
+boolean runPopups () {
+ if (popups == null) return false;
+ boolean result = false;
+ while (popups != null) {
+ Menu menu = popups [0];
+ if (menu == null) break;
+ int length = popups.length;
+ System.arraycopy (popups, 1, popups, 0, --length);
+ popups [length] = null;
+ menu._setVisible (true);
+ result = true;
+ }
+ popups = null;
+ return result;
+}
+
+boolean runTimer (int id) {
+ if (timerList != null && timerIds != null) {
+ int index = 0;
+ while (index <timerIds.length) {
+ if (timerIds [index] == id) {
+ OS.KillTimer (hwndMessage, timerIds [index]);
+ timerIds [index] = 0;
+ Runnable runnable = timerList [index];
+ timerList [index] = null;
+ if (runnable != null) runnable.run ();
+ return true;
+ }
+ index++;
+ }
+ }
+ return false;
+}
+
+void sendEvent (int eventType, Event event) {
+ if (eventTable == null && filterTable == null) {
+ return;
+ }
+ if (event == null) event = new Event ();
+ event.display = this;
+ event.type = eventType;
+ if (event.time == 0) event.time = getLastEventTime ();
+ if (!filterEvent (event)) {
+ if (eventTable != null) eventTable.sendEvent (event);
+ }
+}
+
+/**
+ * Sets the location of the on-screen pointer relative to the top left corner
+ * of the screen. <b>Note: It is typically considered bad practice for a
+ * program to move the on-screen pointer location.</b>
+ *
+ * @param x the new x coordinate for the cursor
+ * @param y the new y coordinate for the cursor
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @since 2.1
+ */
+public void setCursorLocation (int x, int y) {
+ checkDevice ();
+ OS.SetCursorPos (x, y);
+}
+
+/**
+ * Sets the location of the on-screen pointer relative to the top left corner
+ * of the screen. <b>Note: It is typically considered bad practice for a
+ * program to move the on-screen pointer location.</b>
+ *
+ * @param point new position
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * <li>ERROR_NULL_ARGUMENT - if the point is null
+ * </ul>
+ *
+ * @since 2.0
+ */
+public void setCursorLocation (Point point) {
+ checkDevice ();
+ if (point == null) error (SWT.ERROR_NULL_ARGUMENT);
+ setCursorLocation (point.x, point.y);
+}
+
+/**
+ * Sets the application defined property of the receiver
+ * with the specified name to the given argument.
+ * <p>
+ * Applications may have associated arbitrary objects with the
+ * receiver in this fashion. If the objects stored in the
+ * properties need to be notified when the display is disposed
+ * of, it is the application's responsibility provide a
+ * <code>disposeExec()</code> handler which does so.
+ * </p>
+ *
+ * @param key the name of the property
+ * @param value the new value for the property
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if the key is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </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 setModalShell (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;
+ 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) {
+ if (OS.IsWinCE) return 0;
+
+ /* 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 the key to ASCII or UNICODE using the virtual keyboard */
+ if (OS.IsUnicode) {
+ char [] result = new char [1];
+ if (OS.ToUnicode (key, key, keyboard, result, 1, 0) == 1) return result [0];
+ } else {
+ 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 ();
+ if (OS.IsWinCE) {
+ OS.MsgWaitForMultipleObjectsEx (0, 0, OS.INFINITE, OS.QS_ALLINPUT, OS.MWMO_INPUTAVAILABLE);
+ return true;
+ }
+ 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.
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_FAILED_EXEC - if an exception occured when executing the runnable</li>
+ * </ul>
+ *
+ * @see #asyncExec
+ */
+public void syncExec (Runnable runnable) {
+ if (isDisposed ()) error (SWT.ERROR_DEVICE_DISPOSED);
+ synchronizer.syncExec (runnable);
+}
+
+int systemFont () {
+ int hFont = 0;
+ if (systemFonts != null) {
+ int length = systemFonts.length;
+ if (length != 0) hFont = systemFonts [length - 1];
+ }
+ if (hFont == 0) hFont = OS.GetStockObject (OS.DEFAULT_GUI_FONT);
+ if (hFont == 0) hFont = OS.GetStockObject (OS.SYSTEM_FONT);
+ return hFont;
+}
+
+/**
+ * Causes the <code>run()</code> method of the runnable to
+ * be invoked by the user-interface thread after the specified
+ * number of milliseconds have elapsed. If milliseconds is less
+ * than zero, the runnable is not executed.
+ *
+ * @param milliseconds the delay before running the runnable
+ * @param runnable code to run on the user-interface thread
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if the runnable is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see #asyncExec
+ */
+public void timerExec (int milliseconds, Runnable runnable) {
+ checkDevice ();
+ if (runnable == null) error (SWT.ERROR_NULL_ARGUMENT);
+ if (timerList == null) timerList = new Runnable [4];
+ if (timerIds == null) timerIds = new int [4];
+ int index = 0;
+ while (index < timerList.length) {
+ if (timerList [index] == runnable) break;
+ index++;
+ }
+ int timerId = 0;
+ if (index != timerList.length) {
+ timerId = timerIds [index];
+ if (milliseconds < 0) {
+ OS.KillTimer (hwndMessage, timerId);
+ timerList [index] = null;
+ timerIds [index] = 0;
+ return;
+ }
+ } else {
+ if (milliseconds < 0) return;
+ index = 0;
+ while (index < timerList.length) {
+ if (timerList [index] == null) break;
+ index++;
+ }
+ timerCount++;
+ timerId = timerCount;
+ 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 newTimerID = OS.SetTimer (hwndMessage, timerId, milliseconds, 0);
+ if (newTimerID != 0) {
+ timerList [index] = runnable;
+ timerIds [index] = newTimerID;
+ }
+}
+
+boolean translateAccelerator (MSG msg, Control control) {
+ 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, Control control) {
+ switch (msg.message) {
+ case OS.WM_CHAR:
+ case OS.WM_SYSCHAR:
+ return control.translateMnemonic (msg);
+ }
+ return false;
+}
+
+boolean translateTraversal (MSG msg, Control control) {
+ switch (msg.message) {
+ case 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:
+ case OS.VK_PRIOR:
+ case OS.VK_NEXT:
+ return control.translateTraversal (msg);
+ }
+ break;
+ case OS.WM_SYSKEYDOWN:
+ switch (msg.wParam) {
+ case OS.VK_MENU:
+ return control.translateTraversal (msg);
+ }
+ break;
+ }
+ 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;
+}
+
+/**
+ * Forces all outstanding paint requests for the display
+ * to be processed before this method returns.
+ *
+ * @see Control#update
+ */
+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 (true);
+ }
+ }
+}
+
+void updateFont () {
+ if (OS.IsWinCE) return;
+ Font oldFont = getSystemFont ();
+ int systemFont = 0;
+ NONCLIENTMETRICS info = new NONCLIENTMETRICS ();
+ info.cbSize = NONCLIENTMETRICS.sizeof;
+ if (OS.SystemParametersInfo (OS.SPI_GETNONCLIENTMETRICS, 0, info, 0)) {
+ systemFont = OS.CreateFontIndirect (info.lfMessageFont);
+ }
+ if (systemFont == 0) systemFont = OS.GetStockObject (OS.DEFAULT_GUI_FONT);
+ if (systemFont == 0) systemFont = OS.GetStockObject (OS.SYSTEM_FONT);
+ if (systemFont == 0) return;
+ int length = systemFonts == null ? 0 : systemFonts.length;
+ int [] newFonts = new int [length + 1];
+ if (systemFonts != null) {
+ System.arraycopy (systemFonts, 0, newFonts, 0, length);
+ }
+ newFonts [length] = systemFont;
+ systemFonts = newFonts;
+ Font newFont = getSystemFont ();
+ Shell [] shells = getShells ();
+ for (int i=0; i<shells.length; i++) {
+ Shell shell = shells [i];
+ if (!shell.isDisposed ()) {
+ shell.updateFont (oldFont, newFont);
+ }
+ }
+}
+
+/**
+ * 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);
+ if (thread == Thread.currentThread ()) return;
+ if (OS.IsWinCE) {
+ OS.PostMessage (hwndMessage, OS.WM_NULL, 0, 0);
+ } else {
+ 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
index 1a299ff7ca..9cb6dfa5d5 100755
--- 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
@@ -1,411 +1,411 @@
-package org.eclipse.swt.widgets;
-
-/*
+package org.eclipse.swt.widgets;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-import org.eclipse.swt.internal.win32.*;
-import org.eclipse.swt.*;
-
-/**
- * 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 = "";
- static final String FILTER = "*.*";
- static int BUFFER_SIZE = 1024 * 10;
-
-/**
- * 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 FileDialog (Shell parent) {
- this (parent, SWT.PRIMARY_MODAL);
-}
-
-/**
- * Constructs a new instance of this class given its parent
- * and a style value describing its behavior and appearance.
- * <p>
- * The style value is either one of the style constants defined in
- * class <code>SWT</code> which is applicable to instances of this
- * class, or must be built by <em>bitwise OR</em>'ing together
- * (that is, using the <code>int</code> "|" operator) two or more
- * of those <code>SWT</code> style constants. The class description
- * lists the style constants that are applicable to the class.
- * Style bits are also inherited from superclasses.
- * </p>
- * 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 FileDialog (Shell parent, int style) {
- super (parent, style);
- checkSubclass ();
-}
-
-/**
- * Returns the path of the first file that was
- * selected in the dialog relative to the filter path
- *
- * @return the relative path of the file
- */
-public String getFileName () {
- return fileName;
-}
-
-/**
- * Returns the paths of all files that were selected
- * in the dialog relative to the filter path, or null
- * if none are available.
- *
- * @return the relative paths of the files
- */
-public String [] getFileNames () {
- return fileNames;
-}
-
-/**
- * Returns the file extensions which the dialog will
- * use to filter the files it shows.
- *
- * @return the file extensions filter
- */
-public String [] getFilterExtensions () {
- return filterExtensions;
-}
-
-/**
- * Returns the file names which the dialog will
- * use to filter the files it shows.
- *
- * @return the file name filter
- */
-public String [] getFilterNames () {
- return filterNames;
-}
-
-/**
- * Returns the directory path that the dialog will use.
- * File names in this path will appear in the dialog,
- * filtered according to the filter extensions.
- *
- * @return the directory path string
- *
- * @see #setFilterExtensions
- */
-public String getFilterPath () {
- return filterPath;
-}
-
-/**
- * Makes the dialog visible and brings it to the front
- * of the display.
- *
- * @return a string describing the absolute path of the first selected file,
- * or null if the dialog was cancelled or an error occurred
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the dialog has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the dialog</li>
- * </ul>
- */
-public String open () {
- 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 = "";
- /* Use the character encoding for the default locale */
- TCHAR buffer3 = new TCHAR (0, title, true);
- int byteCount3 = buffer3.length () * TCHAR.sizeof;
- int lpstrTitle = OS.HeapAlloc (hHeap, OS.HEAP_ZERO_MEMORY, byteCount3);
- OS.MoveMemory (lpstrTitle, buffer3, byteCount3);
-
- /* 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';
- }
- /* Use the character encoding for the default locale */
- TCHAR buffer4 = new TCHAR (0, strFilter, true);
- int byteCount4 = buffer4.length () * TCHAR.sizeof;
- int lpstrFilter = OS.HeapAlloc (hHeap, OS.HEAP_ZERO_MEMORY, byteCount4);
- OS.MoveMemory (lpstrFilter, buffer4, byteCount4);
-
- /* Convert the fileName and filterName to C strings */
- if (fileName == null) fileName = "";
- /* Use the character encoding for the default locale */
- TCHAR name = new TCHAR (0, fileName, true);
-
- /*
- * 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 nMaxFile = 256;
- if ((style & SWT.MULTI) != 0) nMaxFile = Math.max (nMaxFile, BUFFER_SIZE);
- int byteCount = nMaxFile * TCHAR.sizeof;
- int lpstrFile = OS.HeapAlloc (hHeap, OS.HEAP_ZERO_MEMORY, byteCount);
- int byteCountFile = Math.min (name.length () * TCHAR.sizeof, byteCount - TCHAR.sizeof);
- OS.MoveMemory (lpstrFile, name, byteCountFile);
-
- /*
- * Copy the path into lpstrInitialDir and ensure that
- * the last byte is NULL and the buffer does not overrun.
- */
- if (filterPath == null) filterPath = "";
- /* Use the character encoding for the default locale */
- TCHAR path = new TCHAR (0, filterPath.replace ('/', '\\'), true);
- int lpstrInitialDir = OS.HeapAlloc (hHeap, OS.HEAP_ZERO_MEMORY, byteCount);
- int byteCountDir = Math.min (path.length () * TCHAR.sizeof, byteCount - TCHAR.sizeof);
- OS.MoveMemory (lpstrInitialDir, path, byteCountDir);
-
- /* 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 = nMaxFile;
- 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 TCHAR (0, "", true), TCHAR.sizeof);
- success = (save) ? OS.GetSaveFileName (struct) : OS.GetOpenFileName (struct);
- }
-
- /* Set the new path, file name and filter */
- fileNames = null;
- String fullPath = null;
- if (success) {
-
- /* Use the character encoding for the default locale */
- TCHAR buffer = new TCHAR (0, struct.nMaxFile);
- int byteCount1 = buffer.length () * TCHAR.sizeof;
- OS.MoveMemory (buffer, lpstrFile, byteCount1);
-
- /*
- * Bug in WinCE. For some reason, nFileOffset and nFileExtension
- * are always zero on WinCE HPC. nFileOffset is always zero on
- * WinCE PPC when using GetSaveFileName. nFileOffset is correctly
- * set on WinCE PPC when using OpenFileName. The fix is to parse
- * lpstrFile to calculate nFileOffset.
- *
- * Note: WinCE does not support multi-select file dialogs.
- */
- int nFileOffset = struct.nFileOffset;
- if (OS.IsWinCE && nFileOffset == 0) {
- int index = 0;
- while (index < buffer.length ()) {
- int ch = buffer.tcharAt (index);
- if (ch == 0) break;
- if (ch == '\\') nFileOffset = index + 1;
- index++;
- }
- }
- if (nFileOffset > 0) {
-
- /* Use the character encoding for the default locale */
- TCHAR prefix = new TCHAR (0, nFileOffset - 1);
- int byteCount2 = prefix.length () * TCHAR.sizeof;
- OS.MoveMemory (prefix, lpstrFile, byteCount2);
- filterPath = prefix.toString (0, prefix.length ());
-
- /*
- * Get each file from the buffer. Files are delimited
- * by a NULL character with 2 NULL characters at the end.
- */
- int count = 0;
- fileNames = new String [(style & SWT.MULTI) != 0 ? 4 : 1];
- int start = nFileOffset;
- do {
- int end = start;
- while (end < buffer.length () && buffer.tcharAt (end) != 0) end++;
- String string = buffer.toString (start, end - start);
- start = end;
- 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.tcharAt (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;
-}
-
-/**
- * Set the initial filename which the dialog will
- * select by default when opened to the argument,
- * which may be null. The name will be prefixed with
- * the filter path when one is supplied.
- *
- * @param string the file name
- */
-public void setFileName (String string) {
- fileName = string;
-}
-
-/**
- * Set the file extensions which the dialog will
- * use to filter the files it shows to the argument,
- * which may be null.
- *
- * @param extensions the file extension filter
- */
-public void setFilterExtensions (String [] extensions) {
- filterExtensions = extensions;
-}
-
-/**
- * Sets the file names which the dialog will
- * use to filter the files it shows to the argument,
- * which may be null.
- *
- * @param names the file name filter
- */
-public void setFilterNames (String [] names) {
- filterNames = names;
-}
-
-/**
- * Sets the directory path that the dialog will use
- * to the argument, which may be null. File names in this
- * path will appear in the dialog, filtered according
- * to the filter extensions.
- *
- * @param string the directory path
- *
- * @see #setFilterExtensions
- */
-public void setFilterPath (String string) {
- filterPath = string;
-}
-
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+import org.eclipse.swt.internal.win32.*;
+import org.eclipse.swt.*;
+
+/**
+ * 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 = "";
+ static final String FILTER = "*.*";
+ static int BUFFER_SIZE = 1024 * 10;
+
+/**
+ * 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 FileDialog (Shell parent) {
+ this (parent, SWT.PRIMARY_MODAL);
+}
+
+/**
+ * Constructs a new instance of this class given its parent
+ * and a style value describing its behavior and appearance.
+ * <p>
+ * The style value is either one of the style constants defined in
+ * class <code>SWT</code> which is applicable to instances of this
+ * class, or must be built by <em>bitwise OR</em>'ing together
+ * (that is, using the <code>int</code> "|" operator) two or more
+ * of those <code>SWT</code> style constants. The class description
+ * lists the style constants that are applicable to the class.
+ * Style bits are also inherited from superclasses.
+ * </p>
+ * 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 FileDialog (Shell parent, int style) {
+ super (parent, style);
+ checkSubclass ();
+}
+
+/**
+ * Returns the path of the first file that was
+ * selected in the dialog relative to the filter path
+ *
+ * @return the relative path of the file
+ */
+public String getFileName () {
+ return fileName;
+}
+
+/**
+ * Returns the paths of all files that were selected
+ * in the dialog relative to the filter path, or null
+ * if none are available.
+ *
+ * @return the relative paths of the files
+ */
+public String [] getFileNames () {
+ return fileNames;
+}
+
+/**
+ * Returns the file extensions which the dialog will
+ * use to filter the files it shows.
+ *
+ * @return the file extensions filter
+ */
+public String [] getFilterExtensions () {
+ return filterExtensions;
+}
+
+/**
+ * Returns the file names which the dialog will
+ * use to filter the files it shows.
+ *
+ * @return the file name filter
+ */
+public String [] getFilterNames () {
+ return filterNames;
+}
+
+/**
+ * Returns the directory path that the dialog will use.
+ * File names in this path will appear in the dialog,
+ * filtered according to the filter extensions.
+ *
+ * @return the directory path string
+ *
+ * @see #setFilterExtensions
+ */
+public String getFilterPath () {
+ return filterPath;
+}
+
+/**
+ * Makes the dialog visible and brings it to the front
+ * of the display.
+ *
+ * @return a string describing the absolute path of the first selected file,
+ * or null if the dialog was cancelled or an error occurred
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the dialog has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the dialog</li>
+ * </ul>
+ */
+public String open () {
+ 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 = "";
+ /* Use the character encoding for the default locale */
+ TCHAR buffer3 = new TCHAR (0, title, true);
+ int byteCount3 = buffer3.length () * TCHAR.sizeof;
+ int lpstrTitle = OS.HeapAlloc (hHeap, OS.HEAP_ZERO_MEMORY, byteCount3);
+ OS.MoveMemory (lpstrTitle, buffer3, byteCount3);
+
+ /* 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';
+ }
+ /* Use the character encoding for the default locale */
+ TCHAR buffer4 = new TCHAR (0, strFilter, true);
+ int byteCount4 = buffer4.length () * TCHAR.sizeof;
+ int lpstrFilter = OS.HeapAlloc (hHeap, OS.HEAP_ZERO_MEMORY, byteCount4);
+ OS.MoveMemory (lpstrFilter, buffer4, byteCount4);
+
+ /* Convert the fileName and filterName to C strings */
+ if (fileName == null) fileName = "";
+ /* Use the character encoding for the default locale */
+ TCHAR name = new TCHAR (0, fileName, true);
+
+ /*
+ * 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 nMaxFile = 256;
+ if ((style & SWT.MULTI) != 0) nMaxFile = Math.max (nMaxFile, BUFFER_SIZE);
+ int byteCount = nMaxFile * TCHAR.sizeof;
+ int lpstrFile = OS.HeapAlloc (hHeap, OS.HEAP_ZERO_MEMORY, byteCount);
+ int byteCountFile = Math.min (name.length () * TCHAR.sizeof, byteCount - TCHAR.sizeof);
+ OS.MoveMemory (lpstrFile, name, byteCountFile);
+
+ /*
+ * Copy the path into lpstrInitialDir and ensure that
+ * the last byte is NULL and the buffer does not overrun.
+ */
+ if (filterPath == null) filterPath = "";
+ /* Use the character encoding for the default locale */
+ TCHAR path = new TCHAR (0, filterPath.replace ('/', '\\'), true);
+ int lpstrInitialDir = OS.HeapAlloc (hHeap, OS.HEAP_ZERO_MEMORY, byteCount);
+ int byteCountDir = Math.min (path.length () * TCHAR.sizeof, byteCount - TCHAR.sizeof);
+ OS.MoveMemory (lpstrInitialDir, path, byteCountDir);
+
+ /* 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 = nMaxFile;
+ 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 TCHAR (0, "", true), TCHAR.sizeof);
+ success = (save) ? OS.GetSaveFileName (struct) : OS.GetOpenFileName (struct);
+ }
+
+ /* Set the new path, file name and filter */
+ fileNames = null;
+ String fullPath = null;
+ if (success) {
+
+ /* Use the character encoding for the default locale */
+ TCHAR buffer = new TCHAR (0, struct.nMaxFile);
+ int byteCount1 = buffer.length () * TCHAR.sizeof;
+ OS.MoveMemory (buffer, lpstrFile, byteCount1);
+
+ /*
+ * Bug in WinCE. For some reason, nFileOffset and nFileExtension
+ * are always zero on WinCE HPC. nFileOffset is always zero on
+ * WinCE PPC when using GetSaveFileName. nFileOffset is correctly
+ * set on WinCE PPC when using OpenFileName. The fix is to parse
+ * lpstrFile to calculate nFileOffset.
+ *
+ * Note: WinCE does not support multi-select file dialogs.
+ */
+ int nFileOffset = struct.nFileOffset;
+ if (OS.IsWinCE && nFileOffset == 0) {
+ int index = 0;
+ while (index < buffer.length ()) {
+ int ch = buffer.tcharAt (index);
+ if (ch == 0) break;
+ if (ch == '\\') nFileOffset = index + 1;
+ index++;
+ }
+ }
+ if (nFileOffset > 0) {
+
+ /* Use the character encoding for the default locale */
+ TCHAR prefix = new TCHAR (0, nFileOffset - 1);
+ int byteCount2 = prefix.length () * TCHAR.sizeof;
+ OS.MoveMemory (prefix, lpstrFile, byteCount2);
+ filterPath = prefix.toString (0, prefix.length ());
+
+ /*
+ * Get each file from the buffer. Files are delimited
+ * by a NULL character with 2 NULL characters at the end.
+ */
+ int count = 0;
+ fileNames = new String [(style & SWT.MULTI) != 0 ? 4 : 1];
+ int start = nFileOffset;
+ do {
+ int end = start;
+ while (end < buffer.length () && buffer.tcharAt (end) != 0) end++;
+ String string = buffer.toString (start, end - start);
+ start = end;
+ 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.tcharAt (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;
+}
+
+/**
+ * Set the initial filename which the dialog will
+ * select by default when opened to the argument,
+ * which may be null. The name will be prefixed with
+ * the filter path when one is supplied.
+ *
+ * @param string the file name
+ */
+public void setFileName (String string) {
+ fileName = string;
+}
+
+/**
+ * Set the file extensions which the dialog will
+ * use to filter the files it shows to the argument,
+ * which may be null.
+ *
+ * @param extensions the file extension filter
+ */
+public void setFilterExtensions (String [] extensions) {
+ filterExtensions = extensions;
+}
+
+/**
+ * Sets the file names which the dialog will
+ * use to filter the files it shows to the argument,
+ * which may be null.
+ *
+ * @param names the file name filter
+ */
+public void setFilterNames (String [] names) {
+ filterNames = names;
+}
+
+/**
+ * Sets the directory path that the dialog will use
+ * to the argument, which may be null. File names in this
+ * path will appear in the dialog, filtered according
+ * to the filter extensions.
+ *
+ * @param string the directory path
+ *
+ * @see #setFilterExtensions
+ */
+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
index 494dc309ee..229cb2442e 100755
--- 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
@@ -1,237 +1,237 @@
-package org.eclipse.swt.widgets;
-
-/*
+package org.eclipse.swt.widgets;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-import org.eclipse.swt.internal.win32.*;
-import org.eclipse.swt.*;
-import org.eclipse.swt.graphics.*;
-import org.eclipse.swt.internal.Compatibility;
-
-/**
- * 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;
- RGB rgb;
-
-/**
- * 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 FontDialog (Shell parent) {
- this (parent, SWT.PRIMARY_MODAL);
-}
-
-/**
- * Constructs a new instance of this class given its parent
- * and a style value describing its behavior and appearance.
- * <p>
- * The style value is either one of the style constants defined in
- * class <code>SWT</code> which is applicable to instances of this
- * class, or must be built by <em>bitwise OR</em>'ing together
- * (that is, using the <code>int</code> "|" operator) two or more
- * of those <code>SWT</code> style constants. The class description
- * lists the style constants that are applicable to the class.
- * Style bits are also inherited from superclasses.
- * </p>
- * 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 FontDialog (Shell parent, int style) {
- super (parent, style);
- checkSubclass ();
-}
-
-/**
- * Returns a FontData object describing the font that was
- * selected in the dialog, or null if none is available.
- *
- * @return the FontData for the selected font, or null
- */
-public FontData getFontData() {
- return fontData;
-}
-
-/**
- * Returns the currently selected color in the receiver.
- *
- * @return the RGB value for the selected color, may be null
- *
- * @see PaletteData#getRGBs
- *
- * @since 2.1
- */
-public RGB getRGB () {
- return rgb;
-}
-
-/**
- * Makes the dialog visible and brings it to the front
- * of the display.
- *
- * @return a FontData object describing the font that was selected,
- * or null if the dialog was cancelled or an error occurred
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the dialog has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the dialog</li>
- * </ul>
- */
-public FontData open () {
- if (OS.IsWinCE) SWT.error (SWT.ERROR_NOT_IMPLEMENTED);
-
- /* 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) {
- LOGFONT logFont = fontData.data;
- int lfHeight = logFont.lfHeight;
- int hDC = OS.GetDC (0);
- int pixels = -Compatibility.round (fontData.height * OS.GetDeviceCaps(hDC, OS.LOGPIXELSY), 72);
- OS.ReleaseDC (0, hDC);
- logFont.lfHeight = pixels;
- lpcf.Flags |= OS.CF_INITTOLOGFONTSTRUCT;
- OS.MoveMemory (lpLogFont, logFont, LOGFONT.sizeof);
- logFont.lfHeight = lfHeight;
- }
- lpcf.lpLogFont = lpLogFont;
- if (rgb != null) {
- int red = rgb.red & 0xFF;
- int green = (rgb.green << 8) & 0xFF00;
- int blue = (rgb.blue << 16) & 0xFF0000;
- lpcf.rgbColors = red | green | blue;
- }
- boolean success = OS.ChooseFont (lpcf);
- if (success) {
- 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);
-
- int points = Compatibility.round(pixels * 72, logPixelsY);
- fontData = FontData.win32_new (logFont, points);
- int red = lpcf.rgbColors & 0xFF;
- int green = (lpcf.rgbColors >> 8) & 0xFF;
- int blue = (lpcf.rgbColors >> 16) & 0xFF;
- rgb = new RGB (red, green, blue);
- }
-
- /* 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);
-
- if (!success) return null;
- return fontData;
-}
-
-/**
- * Sets a FontData object describing the font to be
- * selected by default in the dialog, or null to let
- * the platform choose one.
- *
- * @param fontData the FontData to use initially, or null
- */
-public void setFontData (FontData fontData) {
- this.fontData = fontData;
-}
-
-/**
- * Sets the receiver's selected color to be the argument.
- *
- * @param rgb the new RGB value for the selected color, may be
- * null to let the platform to select a default when
- * open() is called
- *
- * @see PaletteData#getRGBs
- *
- * @since 2.1
- */
-public void setRGB (RGB rgb) {
- this.rgb = rgb;
-}
-
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+import org.eclipse.swt.internal.win32.*;
+import org.eclipse.swt.*;
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.internal.Compatibility;
+
+/**
+ * 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;
+ RGB rgb;
+
+/**
+ * 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 FontDialog (Shell parent) {
+ this (parent, SWT.PRIMARY_MODAL);
+}
+
+/**
+ * Constructs a new instance of this class given its parent
+ * and a style value describing its behavior and appearance.
+ * <p>
+ * The style value is either one of the style constants defined in
+ * class <code>SWT</code> which is applicable to instances of this
+ * class, or must be built by <em>bitwise OR</em>'ing together
+ * (that is, using the <code>int</code> "|" operator) two or more
+ * of those <code>SWT</code> style constants. The class description
+ * lists the style constants that are applicable to the class.
+ * Style bits are also inherited from superclasses.
+ * </p>
+ * 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 FontDialog (Shell parent, int style) {
+ super (parent, style);
+ checkSubclass ();
+}
+
+/**
+ * Returns a FontData object describing the font that was
+ * selected in the dialog, or null if none is available.
+ *
+ * @return the FontData for the selected font, or null
+ */
+public FontData getFontData() {
+ return fontData;
+}
+
+/**
+ * Returns the currently selected color in the receiver.
+ *
+ * @return the RGB value for the selected color, may be null
+ *
+ * @see PaletteData#getRGBs
+ *
+ * @since 2.1
+ */
+public RGB getRGB () {
+ return rgb;
+}
+
+/**
+ * Makes the dialog visible and brings it to the front
+ * of the display.
+ *
+ * @return a FontData object describing the font that was selected,
+ * or null if the dialog was cancelled or an error occurred
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the dialog has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the dialog</li>
+ * </ul>
+ */
+public FontData open () {
+ if (OS.IsWinCE) SWT.error (SWT.ERROR_NOT_IMPLEMENTED);
+
+ /* 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) {
+ LOGFONT logFont = fontData.data;
+ int lfHeight = logFont.lfHeight;
+ int hDC = OS.GetDC (0);
+ int pixels = -Compatibility.round (fontData.height * OS.GetDeviceCaps(hDC, OS.LOGPIXELSY), 72);
+ OS.ReleaseDC (0, hDC);
+ logFont.lfHeight = pixels;
+ lpcf.Flags |= OS.CF_INITTOLOGFONTSTRUCT;
+ OS.MoveMemory (lpLogFont, logFont, LOGFONT.sizeof);
+ logFont.lfHeight = lfHeight;
+ }
+ lpcf.lpLogFont = lpLogFont;
+ if (rgb != null) {
+ int red = rgb.red & 0xFF;
+ int green = (rgb.green << 8) & 0xFF00;
+ int blue = (rgb.blue << 16) & 0xFF0000;
+ lpcf.rgbColors = red | green | blue;
+ }
+ boolean success = OS.ChooseFont (lpcf);
+ if (success) {
+ 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);
+
+ int points = Compatibility.round(pixels * 72, logPixelsY);
+ fontData = FontData.win32_new (logFont, points);
+ int red = lpcf.rgbColors & 0xFF;
+ int green = (lpcf.rgbColors >> 8) & 0xFF;
+ int blue = (lpcf.rgbColors >> 16) & 0xFF;
+ rgb = new RGB (red, green, blue);
+ }
+
+ /* 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);
+
+ if (!success) return null;
+ return fontData;
+}
+
+/**
+ * Sets a FontData object describing the font to be
+ * selected by default in the dialog, or null to let
+ * the platform choose one.
+ *
+ * @param fontData the FontData to use initially, or null
+ */
+public void setFontData (FontData fontData) {
+ this.fontData = fontData;
+}
+
+/**
+ * Sets the receiver's selected color to be the argument.
+ *
+ * @param rgb the new RGB value for the selected color, may be
+ * null to let the platform to select a default when
+ * open() is called
+ *
+ * @see PaletteData#getRGBs
+ *
+ * @since 2.1
+ */
+public void setRGB (RGB rgb) {
+ this.rgb = rgb;
+}
+
+}
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
index a82ca8070c..89c1e85d23 100755
--- 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
@@ -1,373 +1,373 @@
-package org.eclipse.swt.widgets;
-
-/*
+package org.eclipse.swt.widgets;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-import org.eclipse.swt.internal.win32.*;
-import org.eclipse.swt.*;
-import org.eclipse.swt.graphics.*;
-
-/**
- * Instances of this class provide an etched border
- * with an optional title.
- * <p>
- * Shadow styles are hints and may not be honoured
- * by the platform. To create a group with the
- * default shadow style for the platform, do not
- * specify a shadow style.
- * <dl>
- * <dt><b>Styles:</b></dt>
- * <dd>SHADOW_ETCHED_IN, SHADOW_ETCHED_OUT, SHADOW_IN, SHADOW_OUT, SHADOW_NONE</dd>
- * <dt><b>Events:</b></dt>
- * <dd>(none)</dd>
- * </dl>
- * <p>
- * Note: Only one of the above styles may be specified.
- * </p><p>
- * IMPORTANT: This class is <em>not</em> intended to be subclassed.
- * </p>
- */
-
-public class Group extends Composite {
- static final int GroupProc;
- static final TCHAR GroupClass = new TCHAR (0, OS.IsWinCE ? "BUTTON" : "SWT_GROUP", true);
- static {
- /*
- * Feature in Windows. The group box 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.
- *
- * Feature in WinCE. On certain devices, defining
- * a new window class which looks like BUTTON causes
- * CreateWindowEx() to crash. The workaround is to use
- * the class Button directly.
- */
- WNDCLASS lpWndClass = new WNDCLASS ();
- if (OS.IsWinCE) {
- OS.GetClassInfo (0, GroupClass, lpWndClass);
- GroupProc = lpWndClass.lpfnWndProc;
- } else {
- TCHAR WC_BUTTON = new TCHAR (0, "BUTTON", true);
- OS.GetClassInfo (0, WC_BUTTON, lpWndClass);
- GroupProc = lpWndClass.lpfnWndProc;
- int hInstance = OS.GetModuleHandle (null);
- if (!OS.GetClassInfo (hInstance, GroupClass, lpWndClass)) {
- int hHeap = OS.GetProcessHeap ();
- lpWndClass.hInstance = hInstance;
- lpWndClass.style &= ~(OS.CS_HREDRAW | OS.CS_VREDRAW);
- int byteCount = GroupClass.length () * TCHAR.sizeof;
- int lpszClassName = OS.HeapAlloc (hHeap, OS.HEAP_ZERO_MEMORY, byteCount);
- OS.MoveMemory (lpszClassName, GroupClass, byteCount);
- lpWndClass.lpszClassName = lpszClassName;
- OS.RegisterClass (lpWndClass);
- // OS.HeapFree (hHeap, 0, lpszClassName);
- }
- }
- }
-
-/**
- * Constructs a new instance of this class given its parent
- * and a style value describing its behavior and appearance.
- * <p>
- * The style value is either one of the style constants defined in
- * class <code>SWT</code> which is applicable to instances of this
- * class, or must be built by <em>bitwise OR</em>'ing together
- * (that is, using the <code>int</code> "|" operator) two or more
- * of those <code>SWT</code> style constants. The class description
- * lists the style constants that are applicable to the class.
- * Style bits are also inherited from superclasses.
- * </p>
- *
- * @param parent a composite control which will be the parent of the new instance (cannot be null)
- * @param style the style of control to construct
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
- * <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
- * </ul>
- *
- * @see SWT#SHADOW_ETCHED_IN
- * @see SWT#SHADOW_ETCHED_OUT
- * @see SWT#SHADOW_IN
- * @see SWT#SHADOW_OUT
- * @see SWT#SHADOW_NONE
- * @see Widget#checkSubclass
- * @see Widget#getStyle
- */
-public Group (Composite parent, int style) {
- super (parent, checkStyle (style));
-}
-
-int callWindowProc (int msg, int wParam, int lParam) {
- if (handle == 0) return 0;
- /*
- * 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.
- */
- switch (msg) {
- case OS.WM_LBUTTONDOWN:
- case OS.WM_LBUTTONDBLCLK:
- return OS.DefWindowProc (handle, msg, wParam, lParam);
- }
- return OS.CallWindowProc (GroupProc, handle, msg, wParam, lParam);
-}
-
-static int checkStyle (int style) {
- style |= SWT.NO_FOCUS;
- /*
- * Even though it is legal to create this widget
- * with scroll bars, they serve no useful purpose
- * because they do not automatically scroll the
- * widget's client area. The fix is to clear
- * the SWT style.
- */
- return style & ~(SWT.H_SCROLL | SWT.V_SCROLL);
-}
-
-protected void checkSubclass () {
- if (!isValidSubclass ()) error (SWT.ERROR_INVALID_SUBCLASS);
-}
-
-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);
- TCHAR buffer1 = new TCHAR (getCodePage (), 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 ();
- forceResize ();
- 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 "";
- TCHAR buffer = new TCHAR (getCodePage (), length + 1);
- OS.GetWindowText (handle, buffer, length + 1);
- return buffer.toString (0, length);
-}
-
-boolean mnemonicHit (char key) {
- 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 displayed as the receiver's <em>title</em>, to the argument,
- * which may not be null. The string may include the mnemonic character.
- * </p>
- * Mnemonics are indicated by an '&amp' that causes the next
- * character to be the mnemonic. When the user presses a
- * key sequence that matches the mnemonic, focus is assgned
- * to the first child of the group. On most platforms, the
- * mnemonic appears underlined but may be emphasised in a
- * platform specific manner. The mnemonic indicator character
- *'&amp' can be escaped by doubling it in the string, causing
- * a single '&amp' to be displayed.
- * </p>
- * @param 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);
- TCHAR buffer = new TCHAR (getCodePage (), 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;
-}
-
-TCHAR windowClass () {
- return GroupClass;
-}
-
-int windowProc () {
- return GroupProc;
-}
-
-LRESULT WM_ERASEBKGND (int wParam, int lParam) {
- LRESULT result = super.WM_ERASEBKGND (wParam, lParam);
- if (result != null) return result;
- /*
- * Feaure in Windows. Group boxes do not erase
- * the background before drawing. The fix is to
- * fill the background.
- */
- drawBackground (wParam);
- return LRESULT.ONE;
-}
-
-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 HTTRANSPARENT 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.
- */
- int code = callWindowProc (OS.WM_NCHITTEST, wParam, lParam);
- if (code == OS.HTTRANSPARENT) code = OS.HTCLIENT;
- return new LRESULT (code);
-}
-
-LRESULT WM_MOUSEMOVE (int wParam, int lParam) {
- LRESULT result = super.WM_MOUSEMOVE (wParam, lParam);
- if (result != null) return result;
- /*
- * Feature in Windows. In version 6.00 of COMCTL32.DLL,
- * every time the mouse moves, the group title redraws.
- * This only happens when WM_NCHITTEST returns HTCLIENT.
- * The fix is to avoid calling the group window proc.
- */
- return LRESULT.ZERO;
-}
-
-LRESULT WM_PRINTCLIENT (int wParam, int lParam) {
- LRESULT result = super.WM_PRINTCLIENT (wParam, lParam);
- if (result != null) return result;
- /*
- * Feature in Windows. In version 6.00 of COMCTL32.DLL,
- * when WM_PRINTCLIENT is sent from a child BS_GROUP
- * control to a parent BS_GROUP, the parent BS_GROUP
- * clears the font from the HDC. Normally, group boxes
- * in Windows do not have children so this behavior is
- * undefined. When the parent of a BS_GROUP is not a
- * BS_GROUP, there is no problem. The fix is to save
- * and restore the current font.
- */
- if (COMCTL32_MAJOR >= 6) {
- int hFont = OS.GetCurrentObject (wParam, OS.OBJ_FONT);
- int code = callWindowProc (OS.WM_PRINTCLIENT, wParam, lParam);
- OS.SelectObject (wParam, hFont);
- return new LRESULT (code);
- }
- return result;
-}
-
-LRESULT WM_SIZE (int wParam, int lParam) {
- LRESULT result = super.WM_SIZE (wParam, lParam);
- if (OS.IsWinCE) return result;
- OS.InvalidateRect (handle, null, true);
- return result;
-}
-
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+import org.eclipse.swt.internal.win32.*;
+import org.eclipse.swt.*;
+import org.eclipse.swt.graphics.*;
+
+/**
+ * Instances of this class provide an etched border
+ * with an optional title.
+ * <p>
+ * Shadow styles are hints and may not be honoured
+ * by the platform. To create a group with the
+ * default shadow style for the platform, do not
+ * specify a shadow style.
+ * <dl>
+ * <dt><b>Styles:</b></dt>
+ * <dd>SHADOW_ETCHED_IN, SHADOW_ETCHED_OUT, SHADOW_IN, SHADOW_OUT, SHADOW_NONE</dd>
+ * <dt><b>Events:</b></dt>
+ * <dd>(none)</dd>
+ * </dl>
+ * <p>
+ * Note: Only one of the above styles may be specified.
+ * </p><p>
+ * IMPORTANT: This class is <em>not</em> intended to be subclassed.
+ * </p>
+ */
+
+public class Group extends Composite {
+ static final int GroupProc;
+ static final TCHAR GroupClass = new TCHAR (0, OS.IsWinCE ? "BUTTON" : "SWT_GROUP", true);
+ static {
+ /*
+ * Feature in Windows. The group box 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.
+ *
+ * Feature in WinCE. On certain devices, defining
+ * a new window class which looks like BUTTON causes
+ * CreateWindowEx() to crash. The workaround is to use
+ * the class Button directly.
+ */
+ WNDCLASS lpWndClass = new WNDCLASS ();
+ if (OS.IsWinCE) {
+ OS.GetClassInfo (0, GroupClass, lpWndClass);
+ GroupProc = lpWndClass.lpfnWndProc;
+ } else {
+ TCHAR WC_BUTTON = new TCHAR (0, "BUTTON", true);
+ OS.GetClassInfo (0, WC_BUTTON, lpWndClass);
+ GroupProc = lpWndClass.lpfnWndProc;
+ int hInstance = OS.GetModuleHandle (null);
+ if (!OS.GetClassInfo (hInstance, GroupClass, lpWndClass)) {
+ int hHeap = OS.GetProcessHeap ();
+ lpWndClass.hInstance = hInstance;
+ lpWndClass.style &= ~(OS.CS_HREDRAW | OS.CS_VREDRAW);
+ int byteCount = GroupClass.length () * TCHAR.sizeof;
+ int lpszClassName = OS.HeapAlloc (hHeap, OS.HEAP_ZERO_MEMORY, byteCount);
+ OS.MoveMemory (lpszClassName, GroupClass, byteCount);
+ lpWndClass.lpszClassName = lpszClassName;
+ OS.RegisterClass (lpWndClass);
+ // OS.HeapFree (hHeap, 0, lpszClassName);
+ }
+ }
+ }
+
+/**
+ * Constructs a new instance of this class given its parent
+ * and a style value describing its behavior and appearance.
+ * <p>
+ * The style value is either one of the style constants defined in
+ * class <code>SWT</code> which is applicable to instances of this
+ * class, or must be built by <em>bitwise OR</em>'ing together
+ * (that is, using the <code>int</code> "|" operator) two or more
+ * of those <code>SWT</code> style constants. The class description
+ * lists the style constants that are applicable to the class.
+ * Style bits are also inherited from superclasses.
+ * </p>
+ *
+ * @param parent a composite control which will be the parent of the new instance (cannot be null)
+ * @param style the style of control to construct
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
+ * <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
+ * </ul>
+ *
+ * @see SWT#SHADOW_ETCHED_IN
+ * @see SWT#SHADOW_ETCHED_OUT
+ * @see SWT#SHADOW_IN
+ * @see SWT#SHADOW_OUT
+ * @see SWT#SHADOW_NONE
+ * @see Widget#checkSubclass
+ * @see Widget#getStyle
+ */
+public Group (Composite parent, int style) {
+ super (parent, checkStyle (style));
+}
+
+int callWindowProc (int msg, int wParam, int lParam) {
+ if (handle == 0) return 0;
+ /*
+ * 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.
+ */
+ switch (msg) {
+ case OS.WM_LBUTTONDOWN:
+ case OS.WM_LBUTTONDBLCLK:
+ return OS.DefWindowProc (handle, msg, wParam, lParam);
+ }
+ return OS.CallWindowProc (GroupProc, handle, msg, wParam, lParam);
+}
+
+static int checkStyle (int style) {
+ style |= SWT.NO_FOCUS;
+ /*
+ * Even though it is legal to create this widget
+ * with scroll bars, they serve no useful purpose
+ * because they do not automatically scroll the
+ * widget's client area. The fix is to clear
+ * the SWT style.
+ */
+ return style & ~(SWT.H_SCROLL | SWT.V_SCROLL);
+}
+
+protected void checkSubclass () {
+ if (!isValidSubclass ()) error (SWT.ERROR_INVALID_SUBCLASS);
+}
+
+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);
+ TCHAR buffer1 = new TCHAR (getCodePage (), 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 ();
+ forceResize ();
+ 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 "";
+ TCHAR buffer = new TCHAR (getCodePage (), length + 1);
+ OS.GetWindowText (handle, buffer, length + 1);
+ return buffer.toString (0, length);
+}
+
+boolean mnemonicHit (char key) {
+ 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 displayed as the receiver's <em>title</em>, to the argument,
+ * which may not be null. The string may include the mnemonic character.
+ * </p>
+ * Mnemonics are indicated by an '&amp' that causes the next
+ * character to be the mnemonic. When the user presses a
+ * key sequence that matches the mnemonic, focus is assgned
+ * to the first child of the group. On most platforms, the
+ * mnemonic appears underlined but may be emphasised in a
+ * platform specific manner. The mnemonic indicator character
+ *'&amp' can be escaped by doubling it in the string, causing
+ * a single '&amp' to be displayed.
+ * </p>
+ * @param 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);
+ TCHAR buffer = new TCHAR (getCodePage (), 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;
+}
+
+TCHAR windowClass () {
+ return GroupClass;
+}
+
+int windowProc () {
+ return GroupProc;
+}
+
+LRESULT WM_ERASEBKGND (int wParam, int lParam) {
+ LRESULT result = super.WM_ERASEBKGND (wParam, lParam);
+ if (result != null) return result;
+ /*
+ * Feaure in Windows. Group boxes do not erase
+ * the background before drawing. The fix is to
+ * fill the background.
+ */
+ drawBackground (wParam);
+ return LRESULT.ONE;
+}
+
+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 HTTRANSPARENT 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.
+ */
+ int code = callWindowProc (OS.WM_NCHITTEST, wParam, lParam);
+ if (code == OS.HTTRANSPARENT) code = OS.HTCLIENT;
+ return new LRESULT (code);
+}
+
+LRESULT WM_MOUSEMOVE (int wParam, int lParam) {
+ LRESULT result = super.WM_MOUSEMOVE (wParam, lParam);
+ if (result != null) return result;
+ /*
+ * Feature in Windows. In version 6.00 of COMCTL32.DLL,
+ * every time the mouse moves, the group title redraws.
+ * This only happens when WM_NCHITTEST returns HTCLIENT.
+ * The fix is to avoid calling the group window proc.
+ */
+ return LRESULT.ZERO;
+}
+
+LRESULT WM_PRINTCLIENT (int wParam, int lParam) {
+ LRESULT result = super.WM_PRINTCLIENT (wParam, lParam);
+ if (result != null) return result;
+ /*
+ * Feature in Windows. In version 6.00 of COMCTL32.DLL,
+ * when WM_PRINTCLIENT is sent from a child BS_GROUP
+ * control to a parent BS_GROUP, the parent BS_GROUP
+ * clears the font from the HDC. Normally, group boxes
+ * in Windows do not have children so this behavior is
+ * undefined. When the parent of a BS_GROUP is not a
+ * BS_GROUP, there is no problem. The fix is to save
+ * and restore the current font.
+ */
+ if (COMCTL32_MAJOR >= 6) {
+ int hFont = OS.GetCurrentObject (wParam, OS.OBJ_FONT);
+ int code = callWindowProc (OS.WM_PRINTCLIENT, wParam, lParam);
+ OS.SelectObject (wParam, hFont);
+ return new LRESULT (code);
+ }
+ return result;
+}
+
+LRESULT WM_SIZE (int wParam, int lParam) {
+ LRESULT result = super.WM_SIZE (wParam, lParam);
+ if (OS.IsWinCE) return result;
+ OS.InvalidateRect (handle, null, true);
+ return result;
+}
+
+}
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
index e5c1275f7d..1cac1c7058 100755
--- 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
@@ -1,254 +1,254 @@
-package org.eclipse.swt.widgets;
-
-/*
+package org.eclipse.swt.widgets;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-import org.eclipse.swt.internal.win32.*;
-import org.eclipse.swt.*;
-import org.eclipse.swt.graphics.*;
-
-class ImageList {
- int handle, refCount;
- Image [] images;
- static final int CREATE_FLAGS;
- static {
- if (OS.IsWinCE) {
- CREATE_FLAGS = OS.ILC_MASK | OS.ILC_COLOR;
- } else {
- 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];
-}
-
-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 [] cx = new int [1], cy = new int [1];
- if (count == 0) {
- Rectangle rect = image.getBounds();
- cx [0] = rect.width;
- cy [0] = rect.height;
- OS.ImageList_SetIconSize (handle, cx [0], cy [0]);
- }
- int hImage = image.handle;
- OS.ImageList_GetIconSize (handle, cx, cy);
- switch (image.type) {
- case SWT.BITMAP: {
- int hBitmap = copyBitmap (hImage, cx [0], cy [0]);
- int background = -1;
- Color color = image.getBackground ();
- if (color != null) background = color.handle;
- if (index == count) {
- if (background != -1) {
- OS.ImageList_AddMasked (handle, hBitmap, background);
- } else {
- int hMask = createMask (hBitmap, cx [0], cy [0], background);
- OS.ImageList_Add (handle, hBitmap, hMask);
- OS.DeleteObject (hMask);
- }
- } else {
- int hMask = createMask (hBitmap, cx [0], cy [0], background);
- OS.ImageList_Replace (handle, index, hBitmap, hMask);
- OS.DeleteObject (hMask);
- }
- OS.DeleteObject (hBitmap);
- break;
- }
- case SWT.ICON: {
- if (OS.IsWinCE) {
- OS.ImageList_ReplaceIcon (handle, index == count ? -1 : index, hImage);
- } else {
- 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 addRef() {
- return ++refCount;
-}
-
-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);
- if (!OS.IsWinCE) 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) {
- if (OS.IsWinCE) SWT.error(SWT.ERROR_NOT_IMPLEMENTED);
- int hIcon = OS.CopyImage (hImage, OS.IMAGE_ICON, width, height, OS.LR_DEFAULTCOLOR);
- return hIcon != 0 ? hIcon : hImage;
-}
-
-int createMask (int hBitmap, int width, int height, int background) {
- int hMask = OS.CreateBitmap (width, height, 1, 1, null);
- int hDC = OS.GetDC (0);
- int hdc1 = OS.CreateCompatibleDC (hDC);
- if (background != -1) {
- OS.SelectObject (hdc1, hBitmap);
- int hdc2 = OS.CreateCompatibleDC (hDC);
- OS.SelectObject (hdc2, hMask);
- OS.SetBkColor (hdc1, background);
- OS.BitBlt (hdc2, 0, 0, width, height, hdc1, 0, 0, OS.SRCCOPY);
- OS.DeleteDC (hdc2);
- } else {
- int hOldBitmap = OS.SelectObject (hdc1, hMask);
- OS.PatBlt (hdc1, 0, 0, width, height, OS.BLACKNESS);
- OS.SelectObject (hdc1, hOldBitmap);
- }
- OS.ReleaseDC (0, hDC);
- OS.DeleteDC (hdc1);
- 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 getHandle () {
- return handle;
-}
-
-public Point getImageSize() {
- int [] cx = new int [1], cy = new int [1];
- OS.ImageList_GetIconSize (handle, cx, cy);
- return new Point (cx [0], cy [0]);
-}
-
-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 background = -1;
- Color color = image.getBackground ();
- if (color != null) background = color.handle;
- int hBitmap = copyBitmap (hImage, cx [0], cy [0]);
- int hMask = createMask (hBitmap, cx [0], cy [0], background);
- OS.ImageList_Replace (handle, index, hBitmap, hMask);
- OS.DeleteObject (hBitmap);
- OS.DeleteObject (hMask);
- break;
- }
- case SWT.ICON: {
- if (OS.IsWinCE) {
- OS.ImageList_ReplaceIcon (handle, index, hImage);
- } else {
- 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;
-}
-
-int removeRef() {
- return --refCount;
-}
-
-public int size () {
- int result = 0;
- 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) result++;
- }
- }
- return result;
-}
-
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+import org.eclipse.swt.internal.win32.*;
+import org.eclipse.swt.*;
+import org.eclipse.swt.graphics.*;
+
+class ImageList {
+ int handle, refCount;
+ Image [] images;
+ static final int CREATE_FLAGS;
+ static {
+ if (OS.IsWinCE) {
+ CREATE_FLAGS = OS.ILC_MASK | OS.ILC_COLOR;
+ } else {
+ 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];
+}
+
+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 [] cx = new int [1], cy = new int [1];
+ if (count == 0) {
+ Rectangle rect = image.getBounds();
+ cx [0] = rect.width;
+ cy [0] = rect.height;
+ OS.ImageList_SetIconSize (handle, cx [0], cy [0]);
+ }
+ int hImage = image.handle;
+ OS.ImageList_GetIconSize (handle, cx, cy);
+ switch (image.type) {
+ case SWT.BITMAP: {
+ int hBitmap = copyBitmap (hImage, cx [0], cy [0]);
+ int background = -1;
+ Color color = image.getBackground ();
+ if (color != null) background = color.handle;
+ if (index == count) {
+ if (background != -1) {
+ OS.ImageList_AddMasked (handle, hBitmap, background);
+ } else {
+ int hMask = createMask (hBitmap, cx [0], cy [0], background);
+ OS.ImageList_Add (handle, hBitmap, hMask);
+ OS.DeleteObject (hMask);
+ }
+ } else {
+ int hMask = createMask (hBitmap, cx [0], cy [0], background);
+ OS.ImageList_Replace (handle, index, hBitmap, hMask);
+ OS.DeleteObject (hMask);
+ }
+ OS.DeleteObject (hBitmap);
+ break;
+ }
+ case SWT.ICON: {
+ if (OS.IsWinCE) {
+ OS.ImageList_ReplaceIcon (handle, index == count ? -1 : index, hImage);
+ } else {
+ 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 addRef() {
+ return ++refCount;
+}
+
+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);
+ if (!OS.IsWinCE) 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) {
+ if (OS.IsWinCE) SWT.error(SWT.ERROR_NOT_IMPLEMENTED);
+ int hIcon = OS.CopyImage (hImage, OS.IMAGE_ICON, width, height, OS.LR_DEFAULTCOLOR);
+ return hIcon != 0 ? hIcon : hImage;
+}
+
+int createMask (int hBitmap, int width, int height, int background) {
+ int hMask = OS.CreateBitmap (width, height, 1, 1, null);
+ int hDC = OS.GetDC (0);
+ int hdc1 = OS.CreateCompatibleDC (hDC);
+ if (background != -1) {
+ OS.SelectObject (hdc1, hBitmap);
+ int hdc2 = OS.CreateCompatibleDC (hDC);
+ OS.SelectObject (hdc2, hMask);
+ OS.SetBkColor (hdc1, background);
+ OS.BitBlt (hdc2, 0, 0, width, height, hdc1, 0, 0, OS.SRCCOPY);
+ OS.DeleteDC (hdc2);
+ } else {
+ int hOldBitmap = OS.SelectObject (hdc1, hMask);
+ OS.PatBlt (hdc1, 0, 0, width, height, OS.BLACKNESS);
+ OS.SelectObject (hdc1, hOldBitmap);
+ }
+ OS.ReleaseDC (0, hDC);
+ OS.DeleteDC (hdc1);
+ 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 getHandle () {
+ return handle;
+}
+
+public Point getImageSize() {
+ int [] cx = new int [1], cy = new int [1];
+ OS.ImageList_GetIconSize (handle, cx, cy);
+ return new Point (cx [0], cy [0]);
+}
+
+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 background = -1;
+ Color color = image.getBackground ();
+ if (color != null) background = color.handle;
+ int hBitmap = copyBitmap (hImage, cx [0], cy [0]);
+ int hMask = createMask (hBitmap, cx [0], cy [0], background);
+ OS.ImageList_Replace (handle, index, hBitmap, hMask);
+ OS.DeleteObject (hBitmap);
+ OS.DeleteObject (hMask);
+ break;
+ }
+ case SWT.ICON: {
+ if (OS.IsWinCE) {
+ OS.ImageList_ReplaceIcon (handle, index, hImage);
+ } else {
+ 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;
+}
+
+int removeRef() {
+ return --refCount;
+}
+
+public int size () {
+ int result = 0;
+ 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) result++;
+ }
+ }
+ return result;
+}
+
+}
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
index e8efcd2b0d..8be690c27c 100755
--- 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
@@ -1,583 +1,583 @@
-package org.eclipse.swt.widgets;
-
-/*
+package org.eclipse.swt.widgets;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-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 that displays a string or image.
- * When SEPARATOR is specified, displays a single
- * vertical or horizontal line.
- * <dl>
- * <dt><b>Styles:</b></dt>
- * <dd>SEPARATOR, HORIZONTAL, VERTICAL</dd>
- * <dd>SHADOW_IN, SHADOW_OUT, SHADOW_NONE</dd>
- * <dd>CENTER, LEFT, RIGHT, WRAP</dd>
- * <dt><b>Events:</b></dt>
- * <dd>(none)</dd>
- * </dl>
- * <p>
- * Note: Only one of SHADOW_IN, SHADOW_OUT and SHADOW_NONE may be specified.
- * SHADOW_NONE is a HINT. Only one of HORIZONTAL and VERTICAL may be specified.
- * Only one of CENTER, LEFT and RIGHT may be specified.
- * </p><p>
- * IMPORTANT: This class is intended to be subclassed <em>only</em>
- * within the SWT implementation.
- * </p>
- */
-public class Label extends Control {
- Image image;
- int font;
- static final int LabelProc;
- static final TCHAR LabelClass = new TCHAR (0, "STATIC", true);
- static {
- WNDCLASS lpWndClass = new WNDCLASS ();
- OS.GetClassInfo (0, LabelClass, lpWndClass);
- LabelProc = 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
- * lists the style constants that are applicable to the class.
- * Style bits are also inherited from superclasses.
- * </p>
- *
- * @param parent a composite control which will be the parent of the new instance (cannot be null)
- * @param style the style of control to construct
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
- * <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
- * </ul>
- *
- * @see SWT#SEPARATOR
- * @see SWT#HORIZONTAL
- * @see SWT#VERTICAL
- * @see SWT#SHADOW_IN
- * @see SWT#SHADOW_OUT
- * @see SWT#SHADOW_NONE
- * @see SWT#CENTER
- * @see SWT#LEFT
- * @see SWT#RIGHT
- * @see SWT#WRAP
- * @see Widget#checkSubclass
- * @see Widget#getStyle
- */
-public Label (Composite parent, int style) {
- super (parent, checkStyle (style));
-}
-
-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) {
- Rectangle rect = image.getBounds();
- width = rect.width;
- height = rect.height;
- }
- } 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 | OS.DT_EDITCONTROL | OS.DT_EXPANDTABS;
- if ((style & SWT.WRAP) != 0 && wHint != SWT.DEFAULT) {
- flags |= OS.DT_WORDBREAK;
- rect.right = wHint;
- }
- int length = OS.GetWindowTextLength (handle);
- TCHAR buffer = new TCHAR (getCodePage (), 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;
- /*
- * Feature in WinCE PPC. Text labels have a trim
- * of one pixel wide on the right and left side.
- * The fix is to increase the size.
- */
- if (OS.IsWinCE) {
- if (!isBitmap && !isIcon) width += 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 "";
- TCHAR buffer = new TCHAR (getCodePage (), length + 1);
- OS.GetWindowText (handle, buffer, length + 1);
- return buffer.toString (0, length);
-}
-
-/*
-* 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 (char key) {
- 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 () {
- checkWidget();
- 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 IllegalArgumentException <ul>
- * <li>ERROR_INVALID_ARGUMENT - if the image has been disposed</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public void setImage (Image image) {
- checkWidget ();
- if ((style & SWT.SEPARATOR) != 0) return;
- int hImage = 0, imageBits = 0, fImageType = 0;
- if (image != null) {
- if (image.isDisposed()) error(SWT.ERROR_INVALID_ARGUMENT);
- 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.
- * <p>
- * This method sets the widget label. The label may include
- * the mnemonic character and line delimiters.
- * </p>
- * <p>
- * Mnemonics are indicated by an '&amp' that causes the next
- * character to be the mnemonic. When the user presses a
- * key sequence that matches the mnemonic, focus is assigned
- * to the control that follows the label. On most platforms,
- * the mnemonic appears underlined but may be emphasised in a
- * platform specific manner. The mnemonic indicator character
- *'&amp' can be escaped by doubling it in the string, causing
- * a single '&amp' to be displayed.
- * </p>
- *
- * @param string the new text
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the text is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public void setText (String string) {
- checkWidget ();
- if (string == null) error (SWT.ERROR_NULL_ARGUMENT);
- if ((style & SWT.SEPARATOR) != 0) return;
- 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);
- TCHAR buffer = new TCHAR (getCodePage (), 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 () {
- int bits = super.widgetExtStyle () & ~OS.WS_EX_CLIENTEDGE;
- if ((style & SWT.BORDER) != 0) return bits | OS.WS_EX_STATICEDGE;
- return bits;
-}
-
-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;
-}
-
-TCHAR 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) return LRESULT.ONE;
- /*
- * 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);
- boolean isBitmap = (bits & OS.SS_BITMAP) == OS.SS_BITMAP;
- boolean isIcon = (bits & OS.SS_ICON) == OS.SS_ICON;
- if (isBitmap || isIcon) {
- drawBackground (wParam);
- return LRESULT.ONE;
- }
- return result;
-}
-
-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;
- if ((style & SWT.SEPARATOR) != 0) {
- OS.InvalidateRect (handle, null, true);
- return result;
- }
-
- /*
- * Bug in Windows. For some reason, a label with
- * SS_BITMAP or SS_ICON and SS_CENTER does not redraw
- * properly when resized. Only the new area is drawn
- * and the old area is not cleared. The fix is to
- * force the redraw.
- *
- * 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) {
- OS.InvalidateRect (handle, null, true);
- 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 not have the
- * problem. The fix is to force the redraw.
- */
- if ((style & (SWT.WRAP | SWT.CENTER | SWT.RIGHT)) != 0) {
- OS.InvalidateRect (handle, null, true);
- return result;
- }
-
- return result;
-}
-
-LRESULT wmDrawChild (int wParam, int lParam) {
- DRAWITEMSTRUCT struct = new DRAWITEMSTRUCT ();
- OS.MoveMemory (struct, lParam, DRAWITEMSTRUCT.sizeof);
- drawBackground (struct.hDC);
- if ((style & SWT.SHADOW_NONE) != 0) return null;
- 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);
- } else {
- 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;
-}
-
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+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 that displays a string or image.
+ * When SEPARATOR is specified, displays a single
+ * vertical or horizontal line.
+ * <dl>
+ * <dt><b>Styles:</b></dt>
+ * <dd>SEPARATOR, HORIZONTAL, VERTICAL</dd>
+ * <dd>SHADOW_IN, SHADOW_OUT, SHADOW_NONE</dd>
+ * <dd>CENTER, LEFT, RIGHT, WRAP</dd>
+ * <dt><b>Events:</b></dt>
+ * <dd>(none)</dd>
+ * </dl>
+ * <p>
+ * Note: Only one of SHADOW_IN, SHADOW_OUT and SHADOW_NONE may be specified.
+ * SHADOW_NONE is a HINT. Only one of HORIZONTAL and VERTICAL may be specified.
+ * Only one of CENTER, LEFT and RIGHT may be specified.
+ * </p><p>
+ * IMPORTANT: This class is intended to be subclassed <em>only</em>
+ * within the SWT implementation.
+ * </p>
+ */
+public class Label extends Control {
+ Image image;
+ int font;
+ static final int LabelProc;
+ static final TCHAR LabelClass = new TCHAR (0, "STATIC", true);
+ static {
+ WNDCLASS lpWndClass = new WNDCLASS ();
+ OS.GetClassInfo (0, LabelClass, lpWndClass);
+ LabelProc = 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
+ * lists the style constants that are applicable to the class.
+ * Style bits are also inherited from superclasses.
+ * </p>
+ *
+ * @param parent a composite control which will be the parent of the new instance (cannot be null)
+ * @param style the style of control to construct
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
+ * <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
+ * </ul>
+ *
+ * @see SWT#SEPARATOR
+ * @see SWT#HORIZONTAL
+ * @see SWT#VERTICAL
+ * @see SWT#SHADOW_IN
+ * @see SWT#SHADOW_OUT
+ * @see SWT#SHADOW_NONE
+ * @see SWT#CENTER
+ * @see SWT#LEFT
+ * @see SWT#RIGHT
+ * @see SWT#WRAP
+ * @see Widget#checkSubclass
+ * @see Widget#getStyle
+ */
+public Label (Composite parent, int style) {
+ super (parent, checkStyle (style));
+}
+
+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) {
+ Rectangle rect = image.getBounds();
+ width = rect.width;
+ height = rect.height;
+ }
+ } 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 | OS.DT_EDITCONTROL | OS.DT_EXPANDTABS;
+ if ((style & SWT.WRAP) != 0 && wHint != SWT.DEFAULT) {
+ flags |= OS.DT_WORDBREAK;
+ rect.right = wHint;
+ }
+ int length = OS.GetWindowTextLength (handle);
+ TCHAR buffer = new TCHAR (getCodePage (), 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;
+ /*
+ * Feature in WinCE PPC. Text labels have a trim
+ * of one pixel wide on the right and left side.
+ * The fix is to increase the size.
+ */
+ if (OS.IsWinCE) {
+ if (!isBitmap && !isIcon) width += 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 "";
+ TCHAR buffer = new TCHAR (getCodePage (), length + 1);
+ OS.GetWindowText (handle, buffer, length + 1);
+ return buffer.toString (0, length);
+}
+
+/*
+* 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 (char key) {
+ 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 () {
+ checkWidget();
+ 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 IllegalArgumentException <ul>
+ * <li>ERROR_INVALID_ARGUMENT - if the image has been disposed</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setImage (Image image) {
+ checkWidget ();
+ if ((style & SWT.SEPARATOR) != 0) return;
+ int hImage = 0, imageBits = 0, fImageType = 0;
+ if (image != null) {
+ if (image.isDisposed()) error(SWT.ERROR_INVALID_ARGUMENT);
+ 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.
+ * <p>
+ * This method sets the widget label. The label may include
+ * the mnemonic character and line delimiters.
+ * </p>
+ * <p>
+ * Mnemonics are indicated by an '&amp' that causes the next
+ * character to be the mnemonic. When the user presses a
+ * key sequence that matches the mnemonic, focus is assigned
+ * to the control that follows the label. On most platforms,
+ * the mnemonic appears underlined but may be emphasised in a
+ * platform specific manner. The mnemonic indicator character
+ *'&amp' can be escaped by doubling it in the string, causing
+ * a single '&amp' to be displayed.
+ * </p>
+ *
+ * @param string the new text
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if the text is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setText (String string) {
+ checkWidget ();
+ if (string == null) error (SWT.ERROR_NULL_ARGUMENT);
+ if ((style & SWT.SEPARATOR) != 0) return;
+ 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);
+ TCHAR buffer = new TCHAR (getCodePage (), 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 () {
+ int bits = super.widgetExtStyle () & ~OS.WS_EX_CLIENTEDGE;
+ if ((style & SWT.BORDER) != 0) return bits | OS.WS_EX_STATICEDGE;
+ return bits;
+}
+
+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;
+}
+
+TCHAR 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) return LRESULT.ONE;
+ /*
+ * 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);
+ boolean isBitmap = (bits & OS.SS_BITMAP) == OS.SS_BITMAP;
+ boolean isIcon = (bits & OS.SS_ICON) == OS.SS_ICON;
+ if (isBitmap || isIcon) {
+ drawBackground (wParam);
+ return LRESULT.ONE;
+ }
+ return result;
+}
+
+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;
+ if ((style & SWT.SEPARATOR) != 0) {
+ OS.InvalidateRect (handle, null, true);
+ return result;
+ }
+
+ /*
+ * Bug in Windows. For some reason, a label with
+ * SS_BITMAP or SS_ICON and SS_CENTER does not redraw
+ * properly when resized. Only the new area is drawn
+ * and the old area is not cleared. The fix is to
+ * force the redraw.
+ *
+ * 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) {
+ OS.InvalidateRect (handle, null, true);
+ 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 not have the
+ * problem. The fix is to force the redraw.
+ */
+ if ((style & (SWT.WRAP | SWT.CENTER | SWT.RIGHT)) != 0) {
+ OS.InvalidateRect (handle, null, true);
+ return result;
+ }
+
+ return result;
+}
+
+LRESULT wmDrawChild (int wParam, int lParam) {
+ DRAWITEMSTRUCT struct = new DRAWITEMSTRUCT ();
+ OS.MoveMemory (struct, lParam, DRAWITEMSTRUCT.sizeof);
+ drawBackground (struct.hDC);
+ if ((style & SWT.SHADOW_NONE) != 0) return null;
+ 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);
+ } else {
+ 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
index 7414305ee5..77b53091d6 100755
--- 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
@@ -1,1540 +1,1540 @@
-package org.eclipse.swt.widgets;
-
-/*
+package org.eclipse.swt.widgets;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-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>
- * Note: Only one of SINGLE and MULTI may be specified.
- * </p><p>
- * IMPORTANT: This class is <em>not</em> intended to be subclassed.
- * </p>
- */
-
-public class List extends Scrollable {
- static final int ListProc;
- static final TCHAR ListClass = new TCHAR (0, "LISTBOX", true);
- static {
- WNDCLASS lpWndClass = new WNDCLASS ();
- OS.GetClassInfo (0, ListClass, lpWndClass);
- ListProc = 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
- * lists the style constants that are applicable to the class.
- * Style bits are also inherited from superclasses.
- * </p>
- *
- * @param parent a composite control which will be the parent of the new instance (cannot be null)
- * @param style the style of control to construct
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
- * <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
- * </ul>
- *
- * @see SWT#SINGLE
- * @see SWT#MULTI
- * @see Widget#checkSubclass
- * @see Widget#getStyle
- */
-public List (Composite parent, int style) {
- super (parent, checkStyle (style));
-}
-/**
- * Adds the argument to the end of the receiver's list.
- *
- * @param string the new item
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the string is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- * @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);
- TCHAR buffer = new TCHAR (getCodePage (), 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);
- TCHAR buffer = new TCHAR (getCodePage (), 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.
- * <p>
- * <code>widgetSelected</code> is called when the selection changes.
- * <code>widgetDefaultSelected</code> is typically called when an item is double-clicked.
- * </p>
- *
- * @param listener the listener which should be notified
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see SelectionListener
- * @see #removeSelectionListener
- * @see SelectionEvent
- */
-public void addSelectionListener(SelectionListener listener) {
- checkWidget ();
- if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
- TypedListener typedListener = new TypedListener (listener);
- addListener (SWT.Selection,typedListener);
- addListener (SWT.DefaultSelection,typedListener);
-}
-
-int 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);
-}
-
-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;
- int cp = getCodePage ();
- TCHAR buffer = new TCHAR (cp, 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 TCHAR (cp, 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);
-}
-
-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);
- } else {
- 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) {
- TCHAR buffer = new TCHAR (getCodePage (), length + 1);
- int result = OS.SendMessage (handle, OS.LB_GETTEXT, index, buffer);
- if (result != OS.LB_ERR) return buffer.toString (0, length);
- }
- 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>
- * @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 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>
- * @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.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 affect the receiver.
- * </p>
- *
- * @return the items in the receiver's list
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- * @exception SWTError <ul>
- * <li>ERROR_CANNOT_GET_ITEM - if the operation fails because of an operating system failure while getting an item</li>
- * <li>ERROR_CANNOT_GET_COUNT - if the operation fails because of an operating system failure while getting the item count</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 affect the receiver.
- * </p>
- * @return an array representing the selection
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- * @exception SWTError <ul>
- * <li>ERROR_CANNOT_GET_SELECTION - if the operation fails because of an operating system failure while getting the selection</li>
- * <li>ERROR_CANNOT_GET_ITEM - if the operation fails because of an operating system failure while getting an item</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>
- * @exception SWTError <ul>
- * <li>ERROR_CANNOT_GET_COUNT - if the operation fails because of an operating system failure</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>
- * @exception SWTError <ul>
- * <li>ERROR_CANNOT_GET_SELECTION - if the operation fails because of an operating system failure</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 affect the receiver.
- * </p>
- * @return the array of indices of the selected items
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- * @exception SWTError <ul>
- * <li>ERROR_CANNOT_GET_SELECTION - if the operation fails because of an operating system failure</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 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) {
- 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>
- * @exception SWTError <ul>
- * <li>ERROR_CANNOT_GET_COUNT - if the operation fails because of an operating system failure while getting the item count</li>
- * <li>ERROR_CANNOT_GET_ITEM - if the operation fails because of an operating system failure while getting an item</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;
- TCHAR buffer = new TCHAR (getCodePage (), 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>
- * <li>ERROR_NULL_ARGUMENT - if the indices array is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- * @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 count = OS.SendMessage (handle, OS.LB_GETCOUNT, 0, 0);
- 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 cp = getCodePage ();
- int i = 0, topCount = 0, last = -1;
- while (i < newIndices.length) {
- int index = newIndices [i];
- if (index != last || i == 0) {
- TCHAR buffer = null;
- if ((style & SWT.H_SCROLL) != 0) {
- int length = OS.SendMessage (handle, OS.LB_GETTEXTLEN, index, 0);
- if (length == OS.LB_ERR) break;
- buffer = new TCHAR (cp, 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) topCount++;
- last = index;
- }
- i++;
- }
- if ((style & SWT.H_SCROLL) != 0) {
- if (newFont != 0) OS.SelectObject (hDC, oldFont);
- OS.ReleaseDC (handle, hDC);
- setScrollWidth (newWidth, false);
- }
- if (topCount > 0) {
- topIndex -= topCount;
- OS.SendMessage (handle, OS.LB_SETTOPINDEX, topIndex, 0);
- }
- if (i < newIndices.length) {
- int index = newIndices [i];
- if (0 <= index && index < count) error (SWT.ERROR_ITEM_NOT_REMOVED);
- error (SWT.ERROR_INVALID_RANGE);
- }
-}
-
-/**
- * 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 ();
- TCHAR 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 TCHAR (getCodePage (), 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 count = OS.SendMessage (handle, OS.LB_GETCOUNT, 0, 0);
- 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 cp = getCodePage ();
- int index = start;
- int flags = OS.DT_CALCRECT | OS.DT_SINGLELINE | OS.DT_NOPREFIX;
- while (index <= end) {
- TCHAR buffer = null;
- if ((style & SWT.H_SCROLL) != 0) {
- int length = OS.SendMessage (handle, OS.LB_GETTEXTLEN, start, 0);
- if (length == OS.LB_ERR) break;
- buffer = new TCHAR (cp, 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) {
- if (0 <= index && index < count) error (SWT.ERROR_ITEM_NOT_REMOVED);
- error (SWT.ERROR_INVALID_RANGE);
- }
-}
-
-/**
- * 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);
- select (indices, false);
-}
-
-void select (int [] indices, boolean scroll) {
- int i = 0;
- while (i < indices.length) {
- int index = indices [i];
- if (index != -1) {
- select (index, false);
- if ((style & SWT.SINGLE) != 0) {
- int count = getItemCount ();
- if (0 <= index && index < count) {
- break;
- }
- }
- }
- i++;
- }
- if (scroll) showSelection ();
-}
-
-/**
- * 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 ();
- select (index, false);
-}
-
-void select (int index, boolean scroll) {
- if (index == -1) return;
- if (scroll) {
- if ((style & SWT.SINGLE) != 0) {
- OS.SendMessage (handle, OS.LB_SETCURSEL, index, 0);
- } else {
- int focusIndex = OS.SendMessage (handle, OS.LB_GETCARETINDEX, 0, 0);
- OS.SendMessage (handle, OS.LB_SETSEL, 1, index);
- if (focusIndex != -1) {
- OS.SendMessage (handle, OS.LB_SETCARETINDEX, index, 0);
- }
- }
- 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);
- }
- int focusIndex = -1;
- 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 {
- focusIndex = OS.SendMessage (handle, OS.LB_GETCARETINDEX, 0, 0);
- OS.SendMessage (handle, OS.LB_SETSEL, 1, index);
- }
- if ((style & SWT.MULTI) != 0) {
- if (focusIndex != -1) {
- OS.SendMessage (handle, OS.LB_SETCARETINDEX, index, 0);
- }
- }
- 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 and no items will be selected if start is
- * greater than end.
- *
- * @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 ();
- select (start, end, false);
-}
-
-void select (int start, int end, boolean scroll) {
- 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, scroll);
- 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, scroll);
- return;
- }
- OS.SendMessage (handle, OS.LB_SELITEMRANGEEX, start, end);
- if (scroll) showSelection ();
-}
-
-/**
- * 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 control when resizing is not deferred and
- * the new size is different from the previous size.
- */
- if (parent.lpwp != null || (flags & OS.SWP_NOSIZE) != 0) {
- super.setBounds (x, y, width, height, flags);
- return;
- }
- RECT rect = new RECT ();
- OS.GetWindowRect (handle, rect);
- int oldWidth = rect.right - rect.left;
- int oldHeight = rect.bottom - rect.top;
- super.setBounds (x, y, width, height, flags);
- if (oldWidth == width && oldHeight == 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>
- * <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_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, false);
- setTopIndex (topIndex);
-}
-
-/**
- * Sets the receiver's items to be the given array of items.
- *
- * @param items the array of items
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the items array is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - 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;
- 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;
- OS.SendMessage (handle, OS.LB_RESETCONTENT, 0, 0);
- OS.SendMessage (handle, OS.LB_INITSTORAGE, length, length * 32);
- int index = 0;
- int cp = getCodePage ();
- while (index < length) {
- String string = items [index];
- if (string == null) break;
- TCHAR buffer = new TCHAR (cp, string, true);
- int result = OS.SendMessage (handle, OS.LB_ADDSTRING, 0, buffer);
- 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, buffer, buffer.length (), 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 cp = getCodePage ();
- 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) {
- TCHAR buffer = new TCHAR (cp, 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 (TCHAR 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 selection 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 List#deselectAll()
- * @see List#select(int[])
- */
-public void setSelection(int [] indices) {
- checkWidget ();
- if (indices == null) error (SWT.ERROR_NULL_ARGUMENT);
- deselectAll ();
- select (indices, true);
- if ((style & SWT.MULTI) != 0) {
- if (indices.length != 0) {
- int focusIndex = indices [0];
- if (focusIndex != -1) setFocusIndex (focusIndex);
- }
- }
-}
-
-/**
- * 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 ();
- int focusIndex = -1;
- for (int i=items.length-1; i>=0; --i) {
- String string = items [i];
- int index = 0;
- if (string != null) {
- int localFocus = -1;
- while ((index = indexOf (string, index)) != -1) {
- if (localFocus == -1) localFocus = index;
- select (index, false);
- if ((style & SWT.SINGLE) != 0 && isSelected (index)) {
- /*
- * Return and rely on the fact that select ()
- * for single-select lists clears the previous
- * selection.
- */
- showSelection ();
- return;
- }
- index++;
- }
- if (localFocus != -1) focusIndex = localFocus;
- }
- }
- if ((style & SWT.SINGLE) != 0) deselectAll ();
- if ((style & SWT.MULTI) != 0) {
- if (focusIndex != -1) setFocusIndex (focusIndex);
- }
-}
-
-/**
- * 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) {
- checkWidget ();
- if ((style & SWT.MULTI) != 0) deselectAll ();
- select (index, true);
- if ((style & SWT.MULTI) != 0) {
- if (index != -1) setFocusIndex (index);
- }
-}
-
-/**
- * Selects the items at the given zero-relative indices in the receiver.
- * The current selection is first cleared, then the new items are selected.
- * Indices that are out of range are ignored and no items will be selected
- * if start is greater than end.
- *
- * @param start the start index of the items to select
- * @param end the end index of the items to select
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see Table#deselectAll()
- * @see Table#select(int,int)
- */
-public void setSelection (int start, int end) {
- checkWidget ();
- if ((style & SWT.MULTI) != 0) deselectAll ();
- select (start, end, true);
- if ((style & SWT.MULTI) != 0) {
- if (start != -1) setFocusIndex (start);
- }
-}
-
-/**
- * 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 SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the 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.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;
-}
-
-TCHAR 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);
-}
-
-
-
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+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>
+ * Note: Only one of SINGLE and MULTI may be specified.
+ * </p><p>
+ * IMPORTANT: This class is <em>not</em> intended to be subclassed.
+ * </p>
+ */
+
+public class List extends Scrollable {
+ static final int ListProc;
+ static final TCHAR ListClass = new TCHAR (0, "LISTBOX", true);
+ static {
+ WNDCLASS lpWndClass = new WNDCLASS ();
+ OS.GetClassInfo (0, ListClass, lpWndClass);
+ ListProc = 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
+ * lists the style constants that are applicable to the class.
+ * Style bits are also inherited from superclasses.
+ * </p>
+ *
+ * @param parent a composite control which will be the parent of the new instance (cannot be null)
+ * @param style the style of control to construct
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
+ * <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
+ * </ul>
+ *
+ * @see SWT#SINGLE
+ * @see SWT#MULTI
+ * @see Widget#checkSubclass
+ * @see Widget#getStyle
+ */
+public List (Composite parent, int style) {
+ super (parent, checkStyle (style));
+}
+/**
+ * Adds the argument to the end of the receiver's list.
+ *
+ * @param string the new item
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if the string is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * @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);
+ TCHAR buffer = new TCHAR (getCodePage (), 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);
+ TCHAR buffer = new TCHAR (getCodePage (), 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.
+ * <p>
+ * <code>widgetSelected</code> is called when the selection changes.
+ * <code>widgetDefaultSelected</code> is typically called when an item is double-clicked.
+ * </p>
+ *
+ * @param listener the listener which should be notified
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see SelectionListener
+ * @see #removeSelectionListener
+ * @see SelectionEvent
+ */
+public void addSelectionListener(SelectionListener listener) {
+ checkWidget ();
+ if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+ TypedListener typedListener = new TypedListener (listener);
+ addListener (SWT.Selection,typedListener);
+ addListener (SWT.DefaultSelection,typedListener);
+}
+
+int 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);
+}
+
+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;
+ int cp = getCodePage ();
+ TCHAR buffer = new TCHAR (cp, 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 TCHAR (cp, 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);
+}
+
+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);
+ } else {
+ 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) {
+ TCHAR buffer = new TCHAR (getCodePage (), length + 1);
+ int result = OS.SendMessage (handle, OS.LB_GETTEXT, index, buffer);
+ if (result != OS.LB_ERR) return buffer.toString (0, length);
+ }
+ 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>
+ * @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 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>
+ * @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.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 affect the receiver.
+ * </p>
+ *
+ * @return the items in the receiver's list
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * @exception SWTError <ul>
+ * <li>ERROR_CANNOT_GET_ITEM - if the operation fails because of an operating system failure while getting an item</li>
+ * <li>ERROR_CANNOT_GET_COUNT - if the operation fails because of an operating system failure while getting the item count</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 affect the receiver.
+ * </p>
+ * @return an array representing the selection
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * @exception SWTError <ul>
+ * <li>ERROR_CANNOT_GET_SELECTION - if the operation fails because of an operating system failure while getting the selection</li>
+ * <li>ERROR_CANNOT_GET_ITEM - if the operation fails because of an operating system failure while getting an item</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>
+ * @exception SWTError <ul>
+ * <li>ERROR_CANNOT_GET_COUNT - if the operation fails because of an operating system failure</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>
+ * @exception SWTError <ul>
+ * <li>ERROR_CANNOT_GET_SELECTION - if the operation fails because of an operating system failure</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 affect the receiver.
+ * </p>
+ * @return the array of indices of the selected items
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * @exception SWTError <ul>
+ * <li>ERROR_CANNOT_GET_SELECTION - if the operation fails because of an operating system failure</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 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) {
+ 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>
+ * @exception SWTError <ul>
+ * <li>ERROR_CANNOT_GET_COUNT - if the operation fails because of an operating system failure while getting the item count</li>
+ * <li>ERROR_CANNOT_GET_ITEM - if the operation fails because of an operating system failure while getting an item</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;
+ TCHAR buffer = new TCHAR (getCodePage (), 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>
+ * <li>ERROR_NULL_ARGUMENT - if the indices array is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * @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 count = OS.SendMessage (handle, OS.LB_GETCOUNT, 0, 0);
+ 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 cp = getCodePage ();
+ int i = 0, topCount = 0, last = -1;
+ while (i < newIndices.length) {
+ int index = newIndices [i];
+ if (index != last || i == 0) {
+ TCHAR buffer = null;
+ if ((style & SWT.H_SCROLL) != 0) {
+ int length = OS.SendMessage (handle, OS.LB_GETTEXTLEN, index, 0);
+ if (length == OS.LB_ERR) break;
+ buffer = new TCHAR (cp, 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) topCount++;
+ last = index;
+ }
+ i++;
+ }
+ if ((style & SWT.H_SCROLL) != 0) {
+ if (newFont != 0) OS.SelectObject (hDC, oldFont);
+ OS.ReleaseDC (handle, hDC);
+ setScrollWidth (newWidth, false);
+ }
+ if (topCount > 0) {
+ topIndex -= topCount;
+ OS.SendMessage (handle, OS.LB_SETTOPINDEX, topIndex, 0);
+ }
+ if (i < newIndices.length) {
+ int index = newIndices [i];
+ if (0 <= index && index < count) error (SWT.ERROR_ITEM_NOT_REMOVED);
+ error (SWT.ERROR_INVALID_RANGE);
+ }
+}
+
+/**
+ * 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 ();
+ TCHAR 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 TCHAR (getCodePage (), 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 count = OS.SendMessage (handle, OS.LB_GETCOUNT, 0, 0);
+ 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 cp = getCodePage ();
+ int index = start;
+ int flags = OS.DT_CALCRECT | OS.DT_SINGLELINE | OS.DT_NOPREFIX;
+ while (index <= end) {
+ TCHAR buffer = null;
+ if ((style & SWT.H_SCROLL) != 0) {
+ int length = OS.SendMessage (handle, OS.LB_GETTEXTLEN, start, 0);
+ if (length == OS.LB_ERR) break;
+ buffer = new TCHAR (cp, 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) {
+ if (0 <= index && index < count) error (SWT.ERROR_ITEM_NOT_REMOVED);
+ error (SWT.ERROR_INVALID_RANGE);
+ }
+}
+
+/**
+ * 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);
+ select (indices, false);
+}
+
+void select (int [] indices, boolean scroll) {
+ int i = 0;
+ while (i < indices.length) {
+ int index = indices [i];
+ if (index != -1) {
+ select (index, false);
+ if ((style & SWT.SINGLE) != 0) {
+ int count = getItemCount ();
+ if (0 <= index && index < count) {
+ break;
+ }
+ }
+ }
+ i++;
+ }
+ if (scroll) showSelection ();
+}
+
+/**
+ * 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 ();
+ select (index, false);
+}
+
+void select (int index, boolean scroll) {
+ if (index == -1) return;
+ if (scroll) {
+ if ((style & SWT.SINGLE) != 0) {
+ OS.SendMessage (handle, OS.LB_SETCURSEL, index, 0);
+ } else {
+ int focusIndex = OS.SendMessage (handle, OS.LB_GETCARETINDEX, 0, 0);
+ OS.SendMessage (handle, OS.LB_SETSEL, 1, index);
+ if (focusIndex != -1) {
+ OS.SendMessage (handle, OS.LB_SETCARETINDEX, index, 0);
+ }
+ }
+ 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);
+ }
+ int focusIndex = -1;
+ 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 {
+ focusIndex = OS.SendMessage (handle, OS.LB_GETCARETINDEX, 0, 0);
+ OS.SendMessage (handle, OS.LB_SETSEL, 1, index);
+ }
+ if ((style & SWT.MULTI) != 0) {
+ if (focusIndex != -1) {
+ OS.SendMessage (handle, OS.LB_SETCARETINDEX, index, 0);
+ }
+ }
+ 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 and no items will be selected if start is
+ * greater than end.
+ *
+ * @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 ();
+ select (start, end, false);
+}
+
+void select (int start, int end, boolean scroll) {
+ 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, scroll);
+ 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, scroll);
+ return;
+ }
+ OS.SendMessage (handle, OS.LB_SELITEMRANGEEX, start, end);
+ if (scroll) showSelection ();
+}
+
+/**
+ * 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 control when resizing is not deferred and
+ * the new size is different from the previous size.
+ */
+ if (parent.lpwp != null || (flags & OS.SWP_NOSIZE) != 0) {
+ super.setBounds (x, y, width, height, flags);
+ return;
+ }
+ RECT rect = new RECT ();
+ OS.GetWindowRect (handle, rect);
+ int oldWidth = rect.right - rect.left;
+ int oldHeight = rect.bottom - rect.top;
+ super.setBounds (x, y, width, height, flags);
+ if (oldWidth == width && oldHeight == 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>
+ * <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_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, false);
+ setTopIndex (topIndex);
+}
+
+/**
+ * Sets the receiver's items to be the given array of items.
+ *
+ * @param items the array of items
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if the items array is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - 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;
+ 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;
+ OS.SendMessage (handle, OS.LB_RESETCONTENT, 0, 0);
+ OS.SendMessage (handle, OS.LB_INITSTORAGE, length, length * 32);
+ int index = 0;
+ int cp = getCodePage ();
+ while (index < length) {
+ String string = items [index];
+ if (string == null) break;
+ TCHAR buffer = new TCHAR (cp, string, true);
+ int result = OS.SendMessage (handle, OS.LB_ADDSTRING, 0, buffer);
+ 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, buffer, buffer.length (), 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 cp = getCodePage ();
+ 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) {
+ TCHAR buffer = new TCHAR (cp, 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 (TCHAR 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 selection 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 List#deselectAll()
+ * @see List#select(int[])
+ */
+public void setSelection(int [] indices) {
+ checkWidget ();
+ if (indices == null) error (SWT.ERROR_NULL_ARGUMENT);
+ deselectAll ();
+ select (indices, true);
+ if ((style & SWT.MULTI) != 0) {
+ if (indices.length != 0) {
+ int focusIndex = indices [0];
+ if (focusIndex != -1) setFocusIndex (focusIndex);
+ }
+ }
+}
+
+/**
+ * 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 ();
+ int focusIndex = -1;
+ for (int i=items.length-1; i>=0; --i) {
+ String string = items [i];
+ int index = 0;
+ if (string != null) {
+ int localFocus = -1;
+ while ((index = indexOf (string, index)) != -1) {
+ if (localFocus == -1) localFocus = index;
+ select (index, false);
+ if ((style & SWT.SINGLE) != 0 && isSelected (index)) {
+ /*
+ * Return and rely on the fact that select ()
+ * for single-select lists clears the previous
+ * selection.
+ */
+ showSelection ();
+ return;
+ }
+ index++;
+ }
+ if (localFocus != -1) focusIndex = localFocus;
+ }
+ }
+ if ((style & SWT.SINGLE) != 0) deselectAll ();
+ if ((style & SWT.MULTI) != 0) {
+ if (focusIndex != -1) setFocusIndex (focusIndex);
+ }
+}
+
+/**
+ * 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) {
+ checkWidget ();
+ if ((style & SWT.MULTI) != 0) deselectAll ();
+ select (index, true);
+ if ((style & SWT.MULTI) != 0) {
+ if (index != -1) setFocusIndex (index);
+ }
+}
+
+/**
+ * Selects the items at the given zero-relative indices in the receiver.
+ * The current selection is first cleared, then the new items are selected.
+ * Indices that are out of range are ignored and no items will be selected
+ * if start is greater than end.
+ *
+ * @param start the start index of the items to select
+ * @param end the end index of the items to select
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see Table#deselectAll()
+ * @see Table#select(int,int)
+ */
+public void setSelection (int start, int end) {
+ checkWidget ();
+ if ((style & SWT.MULTI) != 0) deselectAll ();
+ select (start, end, true);
+ if ((style & SWT.MULTI) != 0) {
+ if (start != -1) setFocusIndex (start);
+ }
+}
+
+/**
+ * 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 SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the 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.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;
+}
+
+TCHAR 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);
+}
+
+
+
+}
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
index 21339f817a..c0c411558a 100755
--- 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
@@ -1,1200 +1,1200 @@
-package org.eclipse.swt.widgets;
-
-/*
+package org.eclipse.swt.widgets;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-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 user interface objects that contain
- * menu items.
- * <dl>
- * <dt><b>Styles:</b></dt>
- * <dd>BAR, DROP_DOWN, POP_UP, NO_RADIO_GROUP</dd>
- * <dd>LEFT_TO_RIGHT, RIGHT_TO_LEFT</dd>
- * <dt><b>Events:</b></dt>
- * <dd>Help, Hide, Show </dd>
- * </dl>
- * <p>
- * Note: Only one of BAR, DROP_DOWN and POP_UP may be specified.
- * Only one of LEFT_TO_RIGHT or RIGHT_TO_LEFT may be specified.
- * </p><p>
- * IMPORTANT: This class is <em>not</em> intended to be subclassed.
- * </p>
- */
-
-public class Menu extends Widget {
- /**
- * the handle to the OS resource
- * (Warning: This field is platform dependent)
- */
- public int handle;
-
- int x, y, hwndCB, id0, id1;
- boolean hasLocation;
- MenuItem cascade;
- Decorations parent;
- static final int ID_PPC = 100;
-
- /* SmartPhone SoftKeyBar resource ids */
- static final int ID_SPMM = 102;
- static final int ID_SPBM = 103;
- static final int ID_SPMB = 104;
- static final int ID_SPBB = 105;
- static final int ID_SPSOFTKEY0 = 106;
- static final int ID_SPSOFTKEY1 = 107;
-
-/**
- * Constructs a new instance of this class given its parent,
- * and sets the style for the instance so that the instance
- * will be a popup menu on the given parent's shell.
- *
- * @param parent a control which will be the parent of the new instance (cannot be null)
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
- * <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
- * </ul>
- *
- * @see SWT#POP_UP
- * @see Widget#checkSubclass
- * @see Widget#getStyle
- */
-public Menu (Control parent) {
- this (checkNull (parent).getShell (), SWT.POP_UP);
-}
-
-/**
- * Constructs a new instance of this class given its parent
- * (which must be a <code>Decorations</code>) and a style value
- * describing its behavior and appearance.
- * <p>
- * The style value is either one of the style constants defined in
- * class <code>SWT</code> which is applicable to instances of this
- * class, or must be built by <em>bitwise OR</em>'ing together
- * (that is, using the <code>int</code> "|" operator) two or more
- * of those <code>SWT</code> style constants. The class description
- * lists the style constants that are applicable to the class.
- * Style bits are also inherited from superclasses.
- * </p>
- *
- * @param parent a decorations control which will be the parent of the new instance (cannot be null)
- * @param style the style of menu to construct
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
- * <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
- * </ul>
- *
- * @see SWT#BAR
- * @see SWT#DROP_DOWN
- * @see SWT#POP_UP
- * @see Widget#checkSubclass
- * @see Widget#getStyle
- */
-public Menu (Decorations parent, int style) {
- this (parent, checkStyle (style), 0);
-}
-
-/**
- * Constructs a new instance of this class given its parent
- * (which must be a <code>Menu</code>) and sets the style
- * for the instance so that the instance will be a drop-down
- * menu on the given parent's parent.
- *
- * @param parent a menu which will be the parent of the new instance (cannot be null)
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
- * <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
- * </ul>
- *
- * @see SWT#DROP_DOWN
- * @see Widget#checkSubclass
- * @see Widget#getStyle
- */
-public Menu (Menu parentMenu) {
- this (checkNull (parentMenu).parent, SWT.DROP_DOWN);
-}
-
-/**
- * Constructs a new instance of this class given its parent
- * (which must be a <code>MenuItem</code>) and sets the style
- * for the instance so that the instance will be a drop-down
- * menu on the given parent's parent menu.
- *
- * @param parent a menu item which will be the parent of the new instance (cannot be null)
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
- * <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
- * </ul>
- *
- * @see SWT#DROP_DOWN
- * @see Widget#checkSubclass
- * @see Widget#getStyle
- */
-public Menu (MenuItem parentItem) {
- this (checkNull (parentItem).parent);
-}
-
-Menu (Decorations parent, int style, int handle) {
- super (parent, checkStyle (style));
- this.parent = parent;
- this.handle = handle;
- /*
- * Bug in IBM JVM 1.3.1. For some reason, when the checkOrientation() is
- * called from createWidget(), the JVM issues this error:
- *
- * JVM Exception 0x2 (subcode 0x0) occurred in thread "main" (TID:0x9F19D8)
- *
- * In addition, on Windows XP, a dialog appears with following error message,
- * indicating that the problem may be in the JIT:
- *
- * AppName: java.exe AppVer: 0.0.0.0 ModName: jitc.dll
- * ModVer: 0.0.0.0 Offset: 000b6912
- *
- * The fix is to call checkOrientation() from here.
- */
- checkOrientation (parent);
- createWidget ();
-}
-
-void _setVisible (boolean visible) {
- 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;
- if ((style & SWT.RIGHT_TO_LEFT) != 0) flags |= OS.TPM_RIGHTALIGN;
- if ((parent.style & SWT.MIRRORED) != 0) {
- flags &= ~OS.TPM_RIGHTALIGN;
- if ((style & SWT.LEFT_TO_RIGHT) != 0) flags |= OS.TPM_RIGHTALIGN;
- }
- 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 as 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 && GetMenuItemCount (handle) == 0) {
- OS.SendMessage (hwndParent, OS.WM_MENUSELECT, 0xFFFF0000, 0);
- }
-}
-
-/**
- * Adds the listener to the collection of listeners who will
- * be notified when help events are generated for the control,
- * by sending it one of the messages defined in the
- * <code>HelpListener</code> interface.
- *
- * @param listener the listener which should be notified
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see HelpListener
- * @see #removeHelpListener
- */
-public void addHelpListener (HelpListener listener) {
- checkWidget ();
- if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
- TypedListener typedListener = new TypedListener (listener);
- addListener (SWT.Help, typedListener);
-}
-
-/**
- * Adds the listener to the collection of listeners who will
- * be notified when menus are hidden or shown, by sending it
- * one of the messages defined in the <code>MenuListener</code>
- * interface.
- *
- * @param listener the listener which should be notified
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see MenuListener
- * @see #removeMenuListener
- */
-public void addMenuListener (MenuListener listener) {
- checkWidget ();
- if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
- TypedListener typedListener = new TypedListener (listener);
- addListener (SWT.Hide,typedListener);
- addListener (SWT.Show,typedListener);
-}
-
-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 (handle != 0) return;
- if ((style & SWT.BAR) != 0) {
- if (OS.IsPPC) {
- int hwndShell = parent.handle;
- SHMENUBARINFO mbi = new SHMENUBARINFO ();
- mbi.cbSize = SHMENUBARINFO.sizeof;
- mbi.hwndParent = hwndShell;
- mbi.dwFlags = OS.SHCMBF_HIDDEN;
- mbi.nToolBarId = ID_PPC;
- mbi.hInstRes = OS.GetLibraryHandle ();
- boolean success = OS.SHCreateMenuBar (mbi);
- hwndCB = mbi.hwndMB;
- if (!success) error (SWT.ERROR_NO_HANDLES);
- /* Remove the item from the resource file */
- OS.SendMessage (hwndCB, OS.TB_DELETEBUTTON, 0, 0);
- return;
- }
- /*
- * Note in WinCE SmartPhone. The SoftBar contains only 2 items.
- * An item can either be a menu or a button.
- * SWT.BAR: creates a SoftBar with 2 menus
- * SWT.BAR | SWT.BUTTON1: creates a SoftBar with 1 button
- * for button1, and a menu for button2
- * SWT.BAR | SWT.BUTTON1 | SWT.BUTTON2: creates a SoftBar with
- * 2 buttons
- */
- if (OS.IsSP) {
- /* Determine type of menubar */
- int nToolBarId;
- if ((style & SWT.BUTTON1) != 0) {
- nToolBarId = ((style & SWT.BUTTON2) != 0) ? ID_SPBB : ID_SPBM;
- } else {
- nToolBarId = ((style & SWT.BUTTON2) != 0) ? ID_SPMB : ID_SPMM;
- }
-
- /* Create SHMENUBAR */
- SHMENUBARINFO mbi = new SHMENUBARINFO ();
- mbi.cbSize = SHMENUBARINFO.sizeof;
- mbi.hwndParent = parent.handle;
- mbi.dwFlags = OS.SHCMBF_HIDDEN;
- mbi.nToolBarId = nToolBarId; /* as defined in .rc file */
- mbi.hInstRes = OS.GetLibraryHandle ();
- if (!OS.SHCreateMenuBar (mbi)) error (SWT.ERROR_NO_HANDLES);
- hwndCB = mbi.hwndMB;
-
- /*
- * Feature on WinCE SmartPhone. The SHCMBF_HIDDEN flag causes the
- * SHMENUBAR to not be drawn. However the keyboard events still go
- * through it. The workaround is to also hide the SHMENUBAR with
- * ShowWindow ().
- */
- OS.ShowWindow (hwndCB, OS.SW_HIDE);
-
- TBBUTTONINFO info = new TBBUTTONINFO ();
- info.cbSize = TBBUTTONINFO.sizeof;
- info.dwMask = OS.TBIF_COMMAND;
- MenuItem item;
-
- /* Set first item */
- if (nToolBarId == ID_SPMM || nToolBarId == ID_SPMB) {
- int hMenu = OS.SendMessage (hwndCB, OS.SHCMBM_GETSUBMENU, 0, ID_SPSOFTKEY0);
- /* Remove the item from the resource file */
- OS.RemoveMenu (hMenu, 0, OS.MF_BYPOSITION);
- Menu menu = new Menu (parent, SWT.DROP_DOWN, hMenu);
- item = new MenuItem (this, menu, SWT.CASCADE, 0);
- } else {
- item = new MenuItem (this, null, SWT.PUSH, 0);
- }
- info.idCommand = id0 = item.id;
- OS.SendMessage (hwndCB, OS.TB_SETBUTTONINFO, ID_SPSOFTKEY0, info);
-
- /* Set second item */
- if (nToolBarId == ID_SPMM || nToolBarId == ID_SPBM) {
- int hMenu = OS.SendMessage (hwndCB, OS.SHCMBM_GETSUBMENU, 0, ID_SPSOFTKEY1);
- OS.RemoveMenu (hMenu, 0, OS.MF_BYPOSITION);
- Menu menu = new Menu (parent, SWT.DROP_DOWN, hMenu);
- item = new MenuItem (this, menu, SWT.CASCADE, 1);
- } else {
- item = new MenuItem (this, null, SWT.PUSH, 1);
- }
- info.idCommand = id1 = item.id;
- OS.SendMessage (hwndCB, OS.TB_SETBUTTONINFO, ID_SPSOFTKEY1, info);
-
- /*
- * Override the Back key. For some reason, the owner of the menubar
- * must be a Dialog or it won't receive the WM_HOTKEY message. As
- * a result, Shell on WinCE SP must use the class Dialog.
- */
- int dwMask = OS.SHMBOF_NODEFAULT | OS.SHMBOF_NOTIFY;
- int lParam = dwMask << 16 | dwMask;
- OS.SendMessage (hwndCB, OS.SHCMBM_OVERRIDEKEY, OS.VK_ESCAPE, lParam);
- return;
- }
- handle = OS.CreateMenu ();
- if (handle == 0) error (SWT.ERROR_NO_HANDLES);
- if (OS.IsHPC) {
- int hwndShell = parent.handle;
- hwndCB = OS.CommandBar_Create (OS.GetModuleHandle (null), hwndShell, 1);
- if (hwndCB == 0) error (SWT.ERROR_NO_HANDLES);
- OS.CommandBar_Show (hwndCB, false);
- OS.CommandBar_InsertMenubarEx (hwndCB, 0, handle, 0);
- /*
- * The command bar hosts the 'close' button when the window does not
- * have a caption.
- */
- if ((parent.style & SWT.CLOSE) != 0 && (parent.style & SWT.TITLE) == 0) {
- OS.CommandBar_AddAdornments (hwndCB, 0, 0);
- }
- }
- } else {
- handle = OS.CreatePopupMenu ();
- if (handle == 0) error (SWT.ERROR_NO_HANDLES);
- }
-}
-
-void createItem (MenuItem item, int index) {
- int count = GetMenuItemCount (handle);
- if (!(0 <= index && index <= count)) error (SWT.ERROR_INVALID_RANGE);
- parent.add (item);
- boolean success = false;
- if ((OS.IsPPC || OS.IsSP) && hwndCB != 0) {
- if (OS.IsSP) return;
- TBBUTTON lpButton = new TBBUTTON ();
- lpButton.idCommand = item.id;
- lpButton.fsStyle = (byte) (OS.TBSTYLE_DROPDOWN | OS.TBSTYLE_AUTOSIZE | 0x80);
- lpButton.fsState = (byte) OS.TBSTATE_ENABLED;
- lpButton.iBitmap = OS.I_IMAGENONE;
- if ((item.style & SWT.SEPARATOR) != 0) lpButton.fsStyle = (byte) OS.BTNS_SEP;
- success = OS.SendMessage (hwndCB, OS.TB_INSERTBUTTON, index, lpButton) != 0;
- } else {
- if (OS.IsWinCE) {
- int uFlags = OS.MF_BYPOSITION;
- TCHAR lpNewItem = null;
- if ((item.style & SWT.SEPARATOR) != 0) {
- uFlags |= OS.MF_SEPARATOR;
- } else {
- lpNewItem = new TCHAR (0, "", true);
- }
- success = OS.InsertMenu (handle, index, uFlags, item.id, lpNewItem);
- if (success) {
- MENUITEMINFO info = new MENUITEMINFO ();
- info.cbSize = MENUITEMINFO.sizeof;
- info.fMask = OS.MIIM_DATA;
- info.dwItemData = item.id;
- success = OS.SetMenuItemInfo (handle, index, true, info);
- }
- } else {
- /*
- * 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, TCHAR.sizeof);
- MENUITEMINFO info = new MENUITEMINFO ();
- info.cbSize = MENUITEMINFO.sizeof;
- info.fMask = OS.MIIM_ID | OS.MIIM_TYPE | OS.MIIM_DATA;
- info.wID = info.dwItemData = item.id;
- info.fType = item.widgetStyle ();
- info.dwTypeData = pszText;
- 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 () {
- /*
- * Bug in IBM JVM 1.3.1. For some reason, when the following code is called
- * from this method, the JVM issues this error:
- *
- * JVM Exception 0x2 (subcode 0x0) occurred in thread "main" (TID:0x9F19D8)
- *
- * In addition, on Windows XP, a dialog appears with following error message,
- * indicating that the problem may be in the JIT:
- *
- * AppName: java.exe AppVer: 0.0.0.0 ModName: jitc.dll
- * ModVer: 0.0.0.0 Offset: 000b6912
- *
- * The fix is to move the code to the caller of this method.
- */
-// checkOrientation (parent);
- 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 destroyAccelerators () {
- parent.destroyAccelerators ();
-}
-
-void destroyItem (MenuItem item) {
- if (OS.IsWinCE) {
- if ((OS.IsPPC || OS.IsSP) && hwndCB != 0) {
- if (OS.IsSP) {
- redraw();
- return;
- }
- int index = OS.SendMessage (hwndCB, OS.TB_COMMANDTOINDEX, item.id, 0);
- if (OS.SendMessage (hwndCB, OS.TB_DELETEBUTTON, index, 0) == 0) {
- error (SWT.ERROR_ITEM_NOT_REMOVED);
- }
- } else {
- int index = 0;
- MENUITEMINFO info = new MENUITEMINFO ();
- info.cbSize = MENUITEMINFO.sizeof;
- info.fMask = OS.MIIM_DATA;
- while (OS.GetMenuItemInfo (handle, index, true, info)) {
- if (info.dwItemData == item.id) break;
- index++;
- }
- if (info.dwItemData != item.id) {
- error (SWT.ERROR_ITEM_NOT_REMOVED);
- }
- if (!OS.RemoveMenu (handle, index, OS.MF_BYPOSITION)) {
- error (SWT.ERROR_ITEM_NOT_REMOVED);
- }
- }
- } else {
- if (!OS.RemoveMenu (handle, item.id, OS.MF_BYCOMMAND)) {
- error (SWT.ERROR_ITEM_NOT_REMOVED);
- }
- }
- redraw ();
-}
-
-void destroyWidget () {
- int hMenu = handle, hCB = hwndCB;
- releaseHandle ();
- if (OS.IsWinCE && hCB != 0) {
- OS.CommandBar_Destroy (hCB);
- } else {
- 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 ();
- if (OS.IsWinCE) return null;
- 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>
- *
- * @see #isEnabled
- */
-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 ();
- int id = 0;
- if ((OS.IsPPC || OS.IsSP) && hwndCB != 0) {
- if (OS.IsPPC) {
- TBBUTTON lpButton = new TBBUTTON ();
- int result = OS.SendMessage (hwndCB, OS.TB_GETBUTTON, index, lpButton);
- if (result == 0) error (SWT.ERROR_CANNOT_GET_ITEM);
- id = lpButton.idCommand;
- }
- if (OS.IsSP) {
- if (!(0 <= index && index <= 1)) error (SWT.ERROR_CANNOT_GET_ITEM);
- id = index == 0 ? id0 : id1;
- }
- } else {
- MENUITEMINFO info = new MENUITEMINFO ();
- info.cbSize = MENUITEMINFO.sizeof;
- info.fMask = OS.MIIM_DATA;
- if (!OS.GetMenuItemInfo (handle, index, true, info)) {
- error (SWT.ERROR_INVALID_RANGE);
- }
- id = info.dwItemData;
- }
- return parent.findMenuItem (id);
-}
-
-/**
- * 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 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 affect the receiver.
- * </p>
- *
- * @return the items in the receiver
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public MenuItem [] getItems () {
- checkWidget ();
- if ((OS.IsPPC || OS.IsSP) && hwndCB != 0) {
- if (OS.IsSP) {
- MenuItem [] result = new MenuItem [2];
- result[0] = parent.findMenuItem (id0);
- result[1] = parent.findMenuItem (id1);
- return result;
- }
- int count = OS.SendMessage (hwndCB, OS.TB_BUTTONCOUNT, 0, 0);
- TBBUTTON lpButton = new TBBUTTON ();
- MenuItem [] result = new MenuItem [count];
- for (int i=0; i<count; i++) {
- OS.SendMessage (hwndCB, OS.TB_GETBUTTON, i, lpButton);
- result [i] = parent.findMenuItem (lpButton.idCommand);
- }
- return result;
- }
- int index = 0;
- int length = OS.IsWinCE ? 4 : OS.GetMenuItemCount (handle);
- MenuItem [] items = new MenuItem [length];
- MENUITEMINFO info = new MENUITEMINFO ();
- info.cbSize = MENUITEMINFO.sizeof;
- info.fMask = OS.MIIM_DATA;
- while (OS.GetMenuItemInfo (handle, index, true, info)) {
- if (index == items.length) {
- MenuItem [] newItems = new MenuItem [index + 4];
- System.arraycopy (items, 0, newItems, 0, index);
- items = newItems;
- }
- items [index++] = parent.findMenuItem (info.dwItemData);
- }
- if (index == items.length) return items;
- MenuItem [] result = new MenuItem [index];
- System.arraycopy (items, 0, result, 0, index);
- return result;
-}
-
-int GetMenuItemCount (int handle) {
- checkWidget ();
- if (OS.IsWinCE) {
- if ((OS.IsPPC || OS.IsSP) && hwndCB != 0) {
- return OS.IsSP ? 2 : OS.SendMessage (hwndCB, OS.TB_BUTTONCOUNT, 0, 0);
- }
- int count = 0;
- MENUITEMINFO info = new MENUITEMINFO ();
- info.cbSize = MENUITEMINFO.sizeof;
- while (OS.GetMenuItemInfo (handle, count, true, info)) count++;
- return count;
- }
- return OS.GetMenuItemCount (handle);
-}
-
-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 ();
- if ((style & SWT.BAR) != 0) {
- return this == parent.menuShell ().menuBar;
- }
- if ((style & SWT.POP_UP) != 0) {
- Display display = getDisplay ();
- Menu [] popups = display.popups;
- if (popups == null) return false;
- for (int i=0; i<popups.length; i++) {
- if (popups [i] == this) return true;
- }
- }
- return this == getShell ().activeMenu;
-}
-
-/**
- * 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);
- if (item.isDisposed()) error(SWT.ERROR_INVALID_ARGUMENT);
- if (item.parent != this) return -1;
- if ((OS.IsPPC || OS.IsSP) && hwndCB != 0) {
- if (OS.IsPPC) {
- return OS.SendMessage (hwndCB, OS.TB_COMMANDTOINDEX, item.id, 0);
- }
- if (OS.IsSP) {
- if (item.id == id0) return 0;
- if (item.id == id1) return 1;
- return -1;
- }
- }
- int index = 0;
- MENUITEMINFO info = new MENUITEMINFO ();
- info.cbSize = MENUITEMINFO.sizeof;
- info.fMask = OS.MIIM_DATA;
- while (OS.GetMenuItemInfo (handle, index, true, info)) {
- if (info.dwItemData == item.id) return index;
- index++;
- }
- return -1;
-}
-
-/**
- * Returns <code>true</code> if the receiver is enabled and all
- * of the receiver's ancestors are enabled, and <code>false</code>
- * otherwise. A disabled control is typically not selectable from the
- * user interface and draws with an inactive or "grayed" look.
- *
- * @return the receiver's enabled state
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see #getEnabled
- */
-public boolean isEnabled () {
- checkWidget ();
- Menu parentMenu = getParentMenu ();
- if (parentMenu == null) return getEnabled ();
- return getEnabled () && parentMenu.isEnabled ();
-}
-
-/**
- * Returns <code>true</code> if the receiver is visible and all
- * of the receiver's ancestors are visible and <code>false</code>
- * otherwise.
- *
- * @return the receiver's visibility state
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see #getVisible
- */
-public boolean isVisible () {
- checkWidget ();
- return getVisible ();
-}
-
-void redraw () {
- if ((style & SWT.BAR) != 0) {
- Display display = getDisplay ();
- display.addBar (this);
- } else {
- update ();
- }
-}
-
-void releaseChild () {
- super.releaseChild ();
- if (cascade != null) cascade.releaseMenu ();
- if ((style & SWT.BAR) != 0) {
- Display display = getDisplay ();
- display.removeBar (this);
- if (this == parent.menuBar) {
- parent.setMenuBar (null);
- }
- } else {
- if ((style & SWT.POP_UP) != 0) {
- Display display = getDisplay ();
- display.removePopup (this);
- }
- }
-}
-
-void releaseHandle () {
- super.releaseHandle ();
- handle = hwndCB = 0;
-}
-
-void releaseWidget () {
- MenuItem [] items = getItems ();
- for (int i=0; i<items.length; i++) {
- MenuItem item = items [i];
- if (!item.isDisposed ()) {
- if (OS.IsPPC && hwndCB != 0) {
- item.dispose ();
- } else {
- item.releaseResources ();
- }
- }
- }
- 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 IllegalArgumentException <ul>
- * <li>ERROR_INVALID_ARGUMENT - if the menu item has been disposed</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public void setDefaultItem (MenuItem item) {
- checkWidget ();
- int newID = -1;
- if (item != null) {
- if (item.isDisposed()) error(SWT.ERROR_INVALID_ARGUMENT);
- if (item.parent != this) return;
- newID = item.id;
- }
- if (OS.IsWinCE) return;
- int oldID = OS.GetMenuDefaultItem (handle, OS.MF_BYCOMMAND, OS.GMDI_USEDISABLED);
- if (newID == oldID) return;
- OS.SetMenuDefaultItem (handle, newID, 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 ();
- if ((style & (SWT.BAR | SWT.DROP_DOWN)) != 0) return;
- this.x = x;
- this.y = y;
- hasLocation = true;
-}
-
-/**
- * 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 location the new location for the receiver
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the point is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @since 2.1
- */
-public void setLocation (Point location) {
- checkWidget ();
- if (location == null) SWT.error (SWT.ERROR_NULL_ARGUMENT);
- setLocation (location.x, location.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 ((style & (SWT.BAR | SWT.DROP_DOWN)) != 0) return;
- Display display = getDisplay ();
- if (visible) {
- display.addPopup (this);
- } else {
- display.removePopup (this);
- _setVisible (false);
- }
-}
-
-void update () {
- if (OS.IsPPC || OS.IsSP) return;
- if (OS.IsHPC) {
- /*
- * Each time a menu has been modified, the command menu bar
- * must be redrawn or it won't update properly. For example,
- * a submenu will not drop down.
- */
- Menu menuBar = parent.menuBar;
- if (menuBar != null) {
- Menu menu = this;
- while (menu != null && menu != menuBar) {
- menu = menu.getParentMenu ();
- }
- if (menu == menuBar) {
- OS.CommandBar_DrawMenuBar (menuBar.hwndCB, 0);
- OS.CommandBar_Show (menuBar.hwndCB, true);
- }
- }
- return;
- }
- if ((style & SWT.BAR) != 0) {
- if (this == parent.menuBar) OS.DrawMenuBar (parent.handle);
- return;
- }
- if ((OS.WIN32_MAJOR << 16 | OS.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);
-}
-
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+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 user interface objects that contain
+ * menu items.
+ * <dl>
+ * <dt><b>Styles:</b></dt>
+ * <dd>BAR, DROP_DOWN, POP_UP, NO_RADIO_GROUP</dd>
+ * <dd>LEFT_TO_RIGHT, RIGHT_TO_LEFT</dd>
+ * <dt><b>Events:</b></dt>
+ * <dd>Help, Hide, Show </dd>
+ * </dl>
+ * <p>
+ * Note: Only one of BAR, DROP_DOWN and POP_UP may be specified.
+ * Only one of LEFT_TO_RIGHT or RIGHT_TO_LEFT may be specified.
+ * </p><p>
+ * IMPORTANT: This class is <em>not</em> intended to be subclassed.
+ * </p>
+ */
+
+public class Menu extends Widget {
+ /**
+ * the handle to the OS resource
+ * (Warning: This field is platform dependent)
+ */
+ public int handle;
+
+ int x, y, hwndCB, id0, id1;
+ boolean hasLocation;
+ MenuItem cascade;
+ Decorations parent;
+ static final int ID_PPC = 100;
+
+ /* SmartPhone SoftKeyBar resource ids */
+ static final int ID_SPMM = 102;
+ static final int ID_SPBM = 103;
+ static final int ID_SPMB = 104;
+ static final int ID_SPBB = 105;
+ static final int ID_SPSOFTKEY0 = 106;
+ static final int ID_SPSOFTKEY1 = 107;
+
+/**
+ * Constructs a new instance of this class given its parent,
+ * and sets the style for the instance so that the instance
+ * will be a popup menu on the given parent's shell.
+ *
+ * @param parent a control which will be the parent of the new instance (cannot be null)
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
+ * <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
+ * </ul>
+ *
+ * @see SWT#POP_UP
+ * @see Widget#checkSubclass
+ * @see Widget#getStyle
+ */
+public Menu (Control parent) {
+ this (checkNull (parent).getShell (), SWT.POP_UP);
+}
+
+/**
+ * Constructs a new instance of this class given its parent
+ * (which must be a <code>Decorations</code>) and a style value
+ * describing its behavior and appearance.
+ * <p>
+ * The style value is either one of the style constants defined in
+ * class <code>SWT</code> which is applicable to instances of this
+ * class, or must be built by <em>bitwise OR</em>'ing together
+ * (that is, using the <code>int</code> "|" operator) two or more
+ * of those <code>SWT</code> style constants. The class description
+ * lists the style constants that are applicable to the class.
+ * Style bits are also inherited from superclasses.
+ * </p>
+ *
+ * @param parent a decorations control which will be the parent of the new instance (cannot be null)
+ * @param style the style of menu to construct
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
+ * <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
+ * </ul>
+ *
+ * @see SWT#BAR
+ * @see SWT#DROP_DOWN
+ * @see SWT#POP_UP
+ * @see Widget#checkSubclass
+ * @see Widget#getStyle
+ */
+public Menu (Decorations parent, int style) {
+ this (parent, checkStyle (style), 0);
+}
+
+/**
+ * Constructs a new instance of this class given its parent
+ * (which must be a <code>Menu</code>) and sets the style
+ * for the instance so that the instance will be a drop-down
+ * menu on the given parent's parent.
+ *
+ * @param parent a menu which will be the parent of the new instance (cannot be null)
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
+ * <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
+ * </ul>
+ *
+ * @see SWT#DROP_DOWN
+ * @see Widget#checkSubclass
+ * @see Widget#getStyle
+ */
+public Menu (Menu parentMenu) {
+ this (checkNull (parentMenu).parent, SWT.DROP_DOWN);
+}
+
+/**
+ * Constructs a new instance of this class given its parent
+ * (which must be a <code>MenuItem</code>) and sets the style
+ * for the instance so that the instance will be a drop-down
+ * menu on the given parent's parent menu.
+ *
+ * @param parent a menu item which will be the parent of the new instance (cannot be null)
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
+ * <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
+ * </ul>
+ *
+ * @see SWT#DROP_DOWN
+ * @see Widget#checkSubclass
+ * @see Widget#getStyle
+ */
+public Menu (MenuItem parentItem) {
+ this (checkNull (parentItem).parent);
+}
+
+Menu (Decorations parent, int style, int handle) {
+ super (parent, checkStyle (style));
+ this.parent = parent;
+ this.handle = handle;
+ /*
+ * Bug in IBM JVM 1.3.1. For some reason, when the checkOrientation() is
+ * called from createWidget(), the JVM issues this error:
+ *
+ * JVM Exception 0x2 (subcode 0x0) occurred in thread "main" (TID:0x9F19D8)
+ *
+ * In addition, on Windows XP, a dialog appears with following error message,
+ * indicating that the problem may be in the JIT:
+ *
+ * AppName: java.exe AppVer: 0.0.0.0 ModName: jitc.dll
+ * ModVer: 0.0.0.0 Offset: 000b6912
+ *
+ * The fix is to call checkOrientation() from here.
+ */
+ checkOrientation (parent);
+ createWidget ();
+}
+
+void _setVisible (boolean visible) {
+ 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;
+ if ((style & SWT.RIGHT_TO_LEFT) != 0) flags |= OS.TPM_RIGHTALIGN;
+ if ((parent.style & SWT.MIRRORED) != 0) {
+ flags &= ~OS.TPM_RIGHTALIGN;
+ if ((style & SWT.LEFT_TO_RIGHT) != 0) flags |= OS.TPM_RIGHTALIGN;
+ }
+ 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 as 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 && GetMenuItemCount (handle) == 0) {
+ OS.SendMessage (hwndParent, OS.WM_MENUSELECT, 0xFFFF0000, 0);
+ }
+}
+
+/**
+ * Adds the listener to the collection of listeners who will
+ * be notified when help events are generated for the control,
+ * by sending it one of the messages defined in the
+ * <code>HelpListener</code> interface.
+ *
+ * @param listener the listener which should be notified
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see HelpListener
+ * @see #removeHelpListener
+ */
+public void addHelpListener (HelpListener listener) {
+ checkWidget ();
+ if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+ TypedListener typedListener = new TypedListener (listener);
+ addListener (SWT.Help, typedListener);
+}
+
+/**
+ * Adds the listener to the collection of listeners who will
+ * be notified when menus are hidden or shown, by sending it
+ * one of the messages defined in the <code>MenuListener</code>
+ * interface.
+ *
+ * @param listener the listener which should be notified
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see MenuListener
+ * @see #removeMenuListener
+ */
+public void addMenuListener (MenuListener listener) {
+ checkWidget ();
+ if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+ TypedListener typedListener = new TypedListener (listener);
+ addListener (SWT.Hide,typedListener);
+ addListener (SWT.Show,typedListener);
+}
+
+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 (handle != 0) return;
+ if ((style & SWT.BAR) != 0) {
+ if (OS.IsPPC) {
+ int hwndShell = parent.handle;
+ SHMENUBARINFO mbi = new SHMENUBARINFO ();
+ mbi.cbSize = SHMENUBARINFO.sizeof;
+ mbi.hwndParent = hwndShell;
+ mbi.dwFlags = OS.SHCMBF_HIDDEN;
+ mbi.nToolBarId = ID_PPC;
+ mbi.hInstRes = OS.GetLibraryHandle ();
+ boolean success = OS.SHCreateMenuBar (mbi);
+ hwndCB = mbi.hwndMB;
+ if (!success) error (SWT.ERROR_NO_HANDLES);
+ /* Remove the item from the resource file */
+ OS.SendMessage (hwndCB, OS.TB_DELETEBUTTON, 0, 0);
+ return;
+ }
+ /*
+ * Note in WinCE SmartPhone. The SoftBar contains only 2 items.
+ * An item can either be a menu or a button.
+ * SWT.BAR: creates a SoftBar with 2 menus
+ * SWT.BAR | SWT.BUTTON1: creates a SoftBar with 1 button
+ * for button1, and a menu for button2
+ * SWT.BAR | SWT.BUTTON1 | SWT.BUTTON2: creates a SoftBar with
+ * 2 buttons
+ */
+ if (OS.IsSP) {
+ /* Determine type of menubar */
+ int nToolBarId;
+ if ((style & SWT.BUTTON1) != 0) {
+ nToolBarId = ((style & SWT.BUTTON2) != 0) ? ID_SPBB : ID_SPBM;
+ } else {
+ nToolBarId = ((style & SWT.BUTTON2) != 0) ? ID_SPMB : ID_SPMM;
+ }
+
+ /* Create SHMENUBAR */
+ SHMENUBARINFO mbi = new SHMENUBARINFO ();
+ mbi.cbSize = SHMENUBARINFO.sizeof;
+ mbi.hwndParent = parent.handle;
+ mbi.dwFlags = OS.SHCMBF_HIDDEN;
+ mbi.nToolBarId = nToolBarId; /* as defined in .rc file */
+ mbi.hInstRes = OS.GetLibraryHandle ();
+ if (!OS.SHCreateMenuBar (mbi)) error (SWT.ERROR_NO_HANDLES);
+ hwndCB = mbi.hwndMB;
+
+ /*
+ * Feature on WinCE SmartPhone. The SHCMBF_HIDDEN flag causes the
+ * SHMENUBAR to not be drawn. However the keyboard events still go
+ * through it. The workaround is to also hide the SHMENUBAR with
+ * ShowWindow ().
+ */
+ OS.ShowWindow (hwndCB, OS.SW_HIDE);
+
+ TBBUTTONINFO info = new TBBUTTONINFO ();
+ info.cbSize = TBBUTTONINFO.sizeof;
+ info.dwMask = OS.TBIF_COMMAND;
+ MenuItem item;
+
+ /* Set first item */
+ if (nToolBarId == ID_SPMM || nToolBarId == ID_SPMB) {
+ int hMenu = OS.SendMessage (hwndCB, OS.SHCMBM_GETSUBMENU, 0, ID_SPSOFTKEY0);
+ /* Remove the item from the resource file */
+ OS.RemoveMenu (hMenu, 0, OS.MF_BYPOSITION);
+ Menu menu = new Menu (parent, SWT.DROP_DOWN, hMenu);
+ item = new MenuItem (this, menu, SWT.CASCADE, 0);
+ } else {
+ item = new MenuItem (this, null, SWT.PUSH, 0);
+ }
+ info.idCommand = id0 = item.id;
+ OS.SendMessage (hwndCB, OS.TB_SETBUTTONINFO, ID_SPSOFTKEY0, info);
+
+ /* Set second item */
+ if (nToolBarId == ID_SPMM || nToolBarId == ID_SPBM) {
+ int hMenu = OS.SendMessage (hwndCB, OS.SHCMBM_GETSUBMENU, 0, ID_SPSOFTKEY1);
+ OS.RemoveMenu (hMenu, 0, OS.MF_BYPOSITION);
+ Menu menu = new Menu (parent, SWT.DROP_DOWN, hMenu);
+ item = new MenuItem (this, menu, SWT.CASCADE, 1);
+ } else {
+ item = new MenuItem (this, null, SWT.PUSH, 1);
+ }
+ info.idCommand = id1 = item.id;
+ OS.SendMessage (hwndCB, OS.TB_SETBUTTONINFO, ID_SPSOFTKEY1, info);
+
+ /*
+ * Override the Back key. For some reason, the owner of the menubar
+ * must be a Dialog or it won't receive the WM_HOTKEY message. As
+ * a result, Shell on WinCE SP must use the class Dialog.
+ */
+ int dwMask = OS.SHMBOF_NODEFAULT | OS.SHMBOF_NOTIFY;
+ int lParam = dwMask << 16 | dwMask;
+ OS.SendMessage (hwndCB, OS.SHCMBM_OVERRIDEKEY, OS.VK_ESCAPE, lParam);
+ return;
+ }
+ handle = OS.CreateMenu ();
+ if (handle == 0) error (SWT.ERROR_NO_HANDLES);
+ if (OS.IsHPC) {
+ int hwndShell = parent.handle;
+ hwndCB = OS.CommandBar_Create (OS.GetModuleHandle (null), hwndShell, 1);
+ if (hwndCB == 0) error (SWT.ERROR_NO_HANDLES);
+ OS.CommandBar_Show (hwndCB, false);
+ OS.CommandBar_InsertMenubarEx (hwndCB, 0, handle, 0);
+ /*
+ * The command bar hosts the 'close' button when the window does not
+ * have a caption.
+ */
+ if ((parent.style & SWT.CLOSE) != 0 && (parent.style & SWT.TITLE) == 0) {
+ OS.CommandBar_AddAdornments (hwndCB, 0, 0);
+ }
+ }
+ } else {
+ handle = OS.CreatePopupMenu ();
+ if (handle == 0) error (SWT.ERROR_NO_HANDLES);
+ }
+}
+
+void createItem (MenuItem item, int index) {
+ int count = GetMenuItemCount (handle);
+ if (!(0 <= index && index <= count)) error (SWT.ERROR_INVALID_RANGE);
+ parent.add (item);
+ boolean success = false;
+ if ((OS.IsPPC || OS.IsSP) && hwndCB != 0) {
+ if (OS.IsSP) return;
+ TBBUTTON lpButton = new TBBUTTON ();
+ lpButton.idCommand = item.id;
+ lpButton.fsStyle = (byte) (OS.TBSTYLE_DROPDOWN | OS.TBSTYLE_AUTOSIZE | 0x80);
+ lpButton.fsState = (byte) OS.TBSTATE_ENABLED;
+ lpButton.iBitmap = OS.I_IMAGENONE;
+ if ((item.style & SWT.SEPARATOR) != 0) lpButton.fsStyle = (byte) OS.BTNS_SEP;
+ success = OS.SendMessage (hwndCB, OS.TB_INSERTBUTTON, index, lpButton) != 0;
+ } else {
+ if (OS.IsWinCE) {
+ int uFlags = OS.MF_BYPOSITION;
+ TCHAR lpNewItem = null;
+ if ((item.style & SWT.SEPARATOR) != 0) {
+ uFlags |= OS.MF_SEPARATOR;
+ } else {
+ lpNewItem = new TCHAR (0, "", true);
+ }
+ success = OS.InsertMenu (handle, index, uFlags, item.id, lpNewItem);
+ if (success) {
+ MENUITEMINFO info = new MENUITEMINFO ();
+ info.cbSize = MENUITEMINFO.sizeof;
+ info.fMask = OS.MIIM_DATA;
+ info.dwItemData = item.id;
+ success = OS.SetMenuItemInfo (handle, index, true, info);
+ }
+ } else {
+ /*
+ * 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, TCHAR.sizeof);
+ MENUITEMINFO info = new MENUITEMINFO ();
+ info.cbSize = MENUITEMINFO.sizeof;
+ info.fMask = OS.MIIM_ID | OS.MIIM_TYPE | OS.MIIM_DATA;
+ info.wID = info.dwItemData = item.id;
+ info.fType = item.widgetStyle ();
+ info.dwTypeData = pszText;
+ 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 () {
+ /*
+ * Bug in IBM JVM 1.3.1. For some reason, when the following code is called
+ * from this method, the JVM issues this error:
+ *
+ * JVM Exception 0x2 (subcode 0x0) occurred in thread "main" (TID:0x9F19D8)
+ *
+ * In addition, on Windows XP, a dialog appears with following error message,
+ * indicating that the problem may be in the JIT:
+ *
+ * AppName: java.exe AppVer: 0.0.0.0 ModName: jitc.dll
+ * ModVer: 0.0.0.0 Offset: 000b6912
+ *
+ * The fix is to move the code to the caller of this method.
+ */
+// checkOrientation (parent);
+ 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 destroyAccelerators () {
+ parent.destroyAccelerators ();
+}
+
+void destroyItem (MenuItem item) {
+ if (OS.IsWinCE) {
+ if ((OS.IsPPC || OS.IsSP) && hwndCB != 0) {
+ if (OS.IsSP) {
+ redraw();
+ return;
+ }
+ int index = OS.SendMessage (hwndCB, OS.TB_COMMANDTOINDEX, item.id, 0);
+ if (OS.SendMessage (hwndCB, OS.TB_DELETEBUTTON, index, 0) == 0) {
+ error (SWT.ERROR_ITEM_NOT_REMOVED);
+ }
+ } else {
+ int index = 0;
+ MENUITEMINFO info = new MENUITEMINFO ();
+ info.cbSize = MENUITEMINFO.sizeof;
+ info.fMask = OS.MIIM_DATA;
+ while (OS.GetMenuItemInfo (handle, index, true, info)) {
+ if (info.dwItemData == item.id) break;
+ index++;
+ }
+ if (info.dwItemData != item.id) {
+ error (SWT.ERROR_ITEM_NOT_REMOVED);
+ }
+ if (!OS.RemoveMenu (handle, index, OS.MF_BYPOSITION)) {
+ error (SWT.ERROR_ITEM_NOT_REMOVED);
+ }
+ }
+ } else {
+ if (!OS.RemoveMenu (handle, item.id, OS.MF_BYCOMMAND)) {
+ error (SWT.ERROR_ITEM_NOT_REMOVED);
+ }
+ }
+ redraw ();
+}
+
+void destroyWidget () {
+ int hMenu = handle, hCB = hwndCB;
+ releaseHandle ();
+ if (OS.IsWinCE && hCB != 0) {
+ OS.CommandBar_Destroy (hCB);
+ } else {
+ 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 ();
+ if (OS.IsWinCE) return null;
+ 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>
+ *
+ * @see #isEnabled
+ */
+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 ();
+ int id = 0;
+ if ((OS.IsPPC || OS.IsSP) && hwndCB != 0) {
+ if (OS.IsPPC) {
+ TBBUTTON lpButton = new TBBUTTON ();
+ int result = OS.SendMessage (hwndCB, OS.TB_GETBUTTON, index, lpButton);
+ if (result == 0) error (SWT.ERROR_CANNOT_GET_ITEM);
+ id = lpButton.idCommand;
+ }
+ if (OS.IsSP) {
+ if (!(0 <= index && index <= 1)) error (SWT.ERROR_CANNOT_GET_ITEM);
+ id = index == 0 ? id0 : id1;
+ }
+ } else {
+ MENUITEMINFO info = new MENUITEMINFO ();
+ info.cbSize = MENUITEMINFO.sizeof;
+ info.fMask = OS.MIIM_DATA;
+ if (!OS.GetMenuItemInfo (handle, index, true, info)) {
+ error (SWT.ERROR_INVALID_RANGE);
+ }
+ id = info.dwItemData;
+ }
+ return parent.findMenuItem (id);
+}
+
+/**
+ * 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 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 affect the receiver.
+ * </p>
+ *
+ * @return the items in the receiver
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public MenuItem [] getItems () {
+ checkWidget ();
+ if ((OS.IsPPC || OS.IsSP) && hwndCB != 0) {
+ if (OS.IsSP) {
+ MenuItem [] result = new MenuItem [2];
+ result[0] = parent.findMenuItem (id0);
+ result[1] = parent.findMenuItem (id1);
+ return result;
+ }
+ int count = OS.SendMessage (hwndCB, OS.TB_BUTTONCOUNT, 0, 0);
+ TBBUTTON lpButton = new TBBUTTON ();
+ MenuItem [] result = new MenuItem [count];
+ for (int i=0; i<count; i++) {
+ OS.SendMessage (hwndCB, OS.TB_GETBUTTON, i, lpButton);
+ result [i] = parent.findMenuItem (lpButton.idCommand);
+ }
+ return result;
+ }
+ int index = 0;
+ int length = OS.IsWinCE ? 4 : OS.GetMenuItemCount (handle);
+ MenuItem [] items = new MenuItem [length];
+ MENUITEMINFO info = new MENUITEMINFO ();
+ info.cbSize = MENUITEMINFO.sizeof;
+ info.fMask = OS.MIIM_DATA;
+ while (OS.GetMenuItemInfo (handle, index, true, info)) {
+ if (index == items.length) {
+ MenuItem [] newItems = new MenuItem [index + 4];
+ System.arraycopy (items, 0, newItems, 0, index);
+ items = newItems;
+ }
+ items [index++] = parent.findMenuItem (info.dwItemData);
+ }
+ if (index == items.length) return items;
+ MenuItem [] result = new MenuItem [index];
+ System.arraycopy (items, 0, result, 0, index);
+ return result;
+}
+
+int GetMenuItemCount (int handle) {
+ checkWidget ();
+ if (OS.IsWinCE) {
+ if ((OS.IsPPC || OS.IsSP) && hwndCB != 0) {
+ return OS.IsSP ? 2 : OS.SendMessage (hwndCB, OS.TB_BUTTONCOUNT, 0, 0);
+ }
+ int count = 0;
+ MENUITEMINFO info = new MENUITEMINFO ();
+ info.cbSize = MENUITEMINFO.sizeof;
+ while (OS.GetMenuItemInfo (handle, count, true, info)) count++;
+ return count;
+ }
+ return OS.GetMenuItemCount (handle);
+}
+
+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 ();
+ if ((style & SWT.BAR) != 0) {
+ return this == parent.menuShell ().menuBar;
+ }
+ if ((style & SWT.POP_UP) != 0) {
+ Display display = getDisplay ();
+ Menu [] popups = display.popups;
+ if (popups == null) return false;
+ for (int i=0; i<popups.length; i++) {
+ if (popups [i] == this) return true;
+ }
+ }
+ return this == getShell ().activeMenu;
+}
+
+/**
+ * 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);
+ if (item.isDisposed()) error(SWT.ERROR_INVALID_ARGUMENT);
+ if (item.parent != this) return -1;
+ if ((OS.IsPPC || OS.IsSP) && hwndCB != 0) {
+ if (OS.IsPPC) {
+ return OS.SendMessage (hwndCB, OS.TB_COMMANDTOINDEX, item.id, 0);
+ }
+ if (OS.IsSP) {
+ if (item.id == id0) return 0;
+ if (item.id == id1) return 1;
+ return -1;
+ }
+ }
+ int index = 0;
+ MENUITEMINFO info = new MENUITEMINFO ();
+ info.cbSize = MENUITEMINFO.sizeof;
+ info.fMask = OS.MIIM_DATA;
+ while (OS.GetMenuItemInfo (handle, index, true, info)) {
+ if (info.dwItemData == item.id) return index;
+ index++;
+ }
+ return -1;
+}
+
+/**
+ * Returns <code>true</code> if the receiver is enabled and all
+ * of the receiver's ancestors are enabled, and <code>false</code>
+ * otherwise. A disabled control is typically not selectable from the
+ * user interface and draws with an inactive or "grayed" look.
+ *
+ * @return the receiver's enabled state
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see #getEnabled
+ */
+public boolean isEnabled () {
+ checkWidget ();
+ Menu parentMenu = getParentMenu ();
+ if (parentMenu == null) return getEnabled ();
+ return getEnabled () && parentMenu.isEnabled ();
+}
+
+/**
+ * Returns <code>true</code> if the receiver is visible and all
+ * of the receiver's ancestors are visible and <code>false</code>
+ * otherwise.
+ *
+ * @return the receiver's visibility state
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see #getVisible
+ */
+public boolean isVisible () {
+ checkWidget ();
+ return getVisible ();
+}
+
+void redraw () {
+ if ((style & SWT.BAR) != 0) {
+ Display display = getDisplay ();
+ display.addBar (this);
+ } else {
+ update ();
+ }
+}
+
+void releaseChild () {
+ super.releaseChild ();
+ if (cascade != null) cascade.releaseMenu ();
+ if ((style & SWT.BAR) != 0) {
+ Display display = getDisplay ();
+ display.removeBar (this);
+ if (this == parent.menuBar) {
+ parent.setMenuBar (null);
+ }
+ } else {
+ if ((style & SWT.POP_UP) != 0) {
+ Display display = getDisplay ();
+ display.removePopup (this);
+ }
+ }
+}
+
+void releaseHandle () {
+ super.releaseHandle ();
+ handle = hwndCB = 0;
+}
+
+void releaseWidget () {
+ MenuItem [] items = getItems ();
+ for (int i=0; i<items.length; i++) {
+ MenuItem item = items [i];
+ if (!item.isDisposed ()) {
+ if (OS.IsPPC && hwndCB != 0) {
+ item.dispose ();
+ } else {
+ item.releaseResources ();
+ }
+ }
+ }
+ 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 IllegalArgumentException <ul>
+ * <li>ERROR_INVALID_ARGUMENT - if the menu item has been disposed</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setDefaultItem (MenuItem item) {
+ checkWidget ();
+ int newID = -1;
+ if (item != null) {
+ if (item.isDisposed()) error(SWT.ERROR_INVALID_ARGUMENT);
+ if (item.parent != this) return;
+ newID = item.id;
+ }
+ if (OS.IsWinCE) return;
+ int oldID = OS.GetMenuDefaultItem (handle, OS.MF_BYCOMMAND, OS.GMDI_USEDISABLED);
+ if (newID == oldID) return;
+ OS.SetMenuDefaultItem (handle, newID, 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 ();
+ if ((style & (SWT.BAR | SWT.DROP_DOWN)) != 0) return;
+ this.x = x;
+ this.y = y;
+ hasLocation = true;
+}
+
+/**
+ * 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 location the new location for the receiver
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if the point is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @since 2.1
+ */
+public void setLocation (Point location) {
+ checkWidget ();
+ if (location == null) SWT.error (SWT.ERROR_NULL_ARGUMENT);
+ setLocation (location.x, location.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 ((style & (SWT.BAR | SWT.DROP_DOWN)) != 0) return;
+ Display display = getDisplay ();
+ if (visible) {
+ display.addPopup (this);
+ } else {
+ display.removePopup (this);
+ _setVisible (false);
+ }
+}
+
+void update () {
+ if (OS.IsPPC || OS.IsSP) return;
+ if (OS.IsHPC) {
+ /*
+ * Each time a menu has been modified, the command menu bar
+ * must be redrawn or it won't update properly. For example,
+ * a submenu will not drop down.
+ */
+ Menu menuBar = parent.menuBar;
+ if (menuBar != null) {
+ Menu menu = this;
+ while (menu != null && menu != menuBar) {
+ menu = menu.getParentMenu ();
+ }
+ if (menu == menuBar) {
+ OS.CommandBar_DrawMenuBar (menuBar.hwndCB, 0);
+ OS.CommandBar_Show (menuBar.hwndCB, true);
+ }
+ }
+ return;
+ }
+ if ((style & SWT.BAR) != 0) {
+ if (this == parent.menuBar) OS.DrawMenuBar (parent.handle);
+ return;
+ }
+ if ((OS.WIN32_MAJOR << 16 | OS.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);
+}
+
+}
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
index 6833f5561c..5a59689728 100755
--- 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
@@ -1,976 +1,976 @@
-package org.eclipse.swt.widgets;
-
-/*
+package org.eclipse.swt.widgets;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-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 notification when pressed and released.
- * <dl>
- * <dt><b>Styles:</b></dt>
- * <dd>CHECK, CASCADE, PUSH, RADIO, SEPARATOR</dd>
- * <dt><b>Events:</b></dt>
- * <dd>Arm, Help, Selection</dd>
- * </dl>
- * <p>
- * Note: Only one of the styles CHECK, CASCADE, PUSH, RADIO and SEPARATOR
- * may be specified.
- * </p><p>
- * IMPORTANT: This class is <em>not</em> intended to be subclassed.
- * </p>
- */
-
-public class MenuItem extends Item {
- Menu parent, menu;
- int id, accelerator;
-
-/**
- * Constructs a new instance of this class given its parent
- * (which must be a <code>Menu</code>) and a style value
- * describing its behavior and appearance. The item is added
- * to the end of the items maintained by its parent.
- * <p>
- * The style value is either one of the style constants defined in
- * class <code>SWT</code> which is applicable to instances of this
- * class, or must be built by <em>bitwise OR</em>'ing together
- * (that is, using the <code>int</code> "|" operator) two or more
- * of those <code>SWT</code> style constants. The class description
- * lists the style constants that are applicable to the class.
- * Style bits are also inherited from superclasses.
- * </p>
- *
- * @param parent a menu control which will be the parent of the new instance (cannot be null)
- * @param style the style of control to construct
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
- * <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
- * </ul>
- *
- * @see SWT#CHECK
- * @see SWT#CASCADE
- * @see SWT#PUSH
- * @see SWT#RADIO
- * @see SWT#SEPARATOR
- * @see Widget#checkSubclass
- * @see Widget#getStyle
- */
-public MenuItem (Menu parent, int style) {
- super (parent, checkStyle (style));
- this.parent = parent;
- parent.createItem (this, parent.getItemCount ());
-}
-
-/**
- * Constructs a new instance of this class given its parent
- * (which must be a <code>Menu</code>), a style value
- * describing its behavior and appearance, and the index
- * at which to place it in the items maintained by its parent.
- * <p>
- * The style value is either one of the style constants defined in
- * class <code>SWT</code> which is applicable to instances of this
- * class, or must be built by <em>bitwise OR</em>'ing together
- * (that is, using the <code>int</code> "|" operator) two or more
- * of those <code>SWT</code> style constants. The class description
- * lists the style constants that are applicable to the class.
- * Style bits are also inherited from superclasses.
- * </p>
- *
- * @param parent a menu control which will be the parent of the new instance (cannot be null)
- * @param style the style of control to construct
- * @param index the 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#CHECK
- * @see SWT#CASCADE
- * @see SWT#PUSH
- * @see SWT#RADIO
- * @see SWT#SEPARATOR
- * @see Widget#checkSubclass
- * @see Widget#getStyle
- */
-public MenuItem (Menu parent, int style, int index) {
- super (parent, checkStyle (style));
- this.parent = parent;
- parent.createItem (this, index);
-}
-
-MenuItem (Menu parent, Menu menu, int style, int index) {
- super (parent, checkStyle (style));
- this.parent = parent;
- this.menu = menu;
- if (menu != null) menu.cascade = this;
- Decorations shell = parent.parent;
- shell.add (this);
-}
-
-/**
- * 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.
- * <p>
- * When <code>widgetSelected</code> is called, the stateMask field of the event object is valid.
- * <code>widgetDefaultSelected</code> is not called.
- * </p>
- *
- * @param listener the listener which should be notified
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see SelectionListener
- * @see #removeSelectionListener
- * @see SelectionEvent
- */
-public void addSelectionListener (SelectionListener listener) {
- checkWidget ();
- if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
- TypedListener typedListener = new TypedListener(listener);
- addListener (SWT.Selection,typedListener);
- addListener (SWT.DefaultSelection,typedListener);
-}
-
-protected void checkSubclass () {
- if (!isValidSubclass ()) error (SWT.ERROR_INVALID_SUBCLASS);
-}
-
-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 fVirt = OS.FVIRTKEY;
- int key = accelerator & SWT.KEY_MASK;
- int vKey = Display.untranslateKey (key);
- if (vKey != 0) {
- key = vKey;
- } else {
- switch (key) {
- /*
- * Bug in Windows. For some reason, VkKeyScan
- * fails to map ESC to VK_ESCAPE and DEL to
- * VK_DELETE. The fix is to map these keys
- * as a special case.
- */
- case 27: key = OS.VK_ESCAPE; break;
- case 127: key = OS.VK_DELETE; break;
- default: {
- key = wcsToMbcs ((char) key);
- if (key == 0) return;
- if (OS.IsWinCE) {
- key = OS.CharUpper ((short) key);
- } else {
- vKey = OS.VkKeyScan ((short) key) & 0xFF;
- if (vKey == -1) {
- fVirt = 0;
- } else {
- key = vKey;
- }
- }
- }
- }
- }
- accel.key = (short) key;
- accel.cmd = (short) id;
- accel.fVirt = (byte) fVirt;
- if ((accelerator & SWT.ALT) != 0) accel.fVirt |= OS.FALT;
- if ((accelerator & SWT.SHIFT) != 0) accel.fVirt |= OS.FSHIFT;
- if ((accelerator & SWT.CONTROL) != 0) accel.fVirt |= OS.FCONTROL;
-}
-
-/**
- * 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>
- *
- * @see #isEnabled
- */
-public boolean getEnabled () {
- checkWidget ();
- if ((OS.IsPPC || OS.IsSP) && parent.hwndCB != 0) {
- int hwndCB = parent.hwndCB;
- TBBUTTONINFO info = new TBBUTTONINFO ();
- info.cbSize = TBBUTTONINFO.sizeof;
- info.dwMask = OS.TBIF_STATE;
- OS.SendMessage (hwndCB, OS.TB_GETBUTTONINFO, id, info);
- return (info.fsState & OS.TBSTATE_ENABLED) != 0;
- }
- int hMenu = parent.handle;
- MENUITEMINFO info = new MENUITEMINFO ();
- info.cbSize = MENUITEMINFO.sizeof;
- info.fMask = OS.MIIM_STATE;
- boolean success;
- if (OS.IsWinCE) {
- int index = parent.indexOf (this);
- if (index == -1) error (SWT.ERROR_CANNOT_GET_ENABLED);
- success = OS.GetMenuItemInfo (hMenu, index, true, info);
- } else {
- 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;
- if ((OS.IsPPC || OS.IsSP) && parent.hwndCB != 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 all
- * of the receiver's ancestors are enabled, and <code>false</code>
- * otherwise. A disabled control is typically not selectable from the
- * user interface and draws with an inactive or "grayed" look.
- *
- * @return the receiver's enabled state
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see #getEnabled
- */
-public boolean isEnabled () {
- return getEnabled () && parent.isEnabled ();
-}
-
-void releaseChild () {
- super.releaseChild ();
- if (menu != null) menu.dispose ();
- menu = null;
- parent.destroyItem (this);
-}
-
-void releaseMenu () {
- if (!OS.IsSP) setMenu (null);
- menu = null;
-}
-
-void releaseWidget () {
- if (menu != null) menu.releaseResources ();
- menu = null;
- super.releaseWidget ();
- if (accelerator != 0) {
- parent.destroyAccelerators ();
- }
- 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);
-}
-
-void selectRadio () {
- int index = 0;
- MenuItem [] items = parent.getItems ();
- while (index < items.length && items [index] != this) index++;
- int i = index - 1;
- while (i >= 0 && items [i].setRadioSelection (false)) --i;
- int j = index + 1;
- while (j < items.length && items [j].setRadioSelection (false)) j++;
- setSelection (true);
-}
-
-/**
- * Sets the widget accelerator. An accelerator is the bit-wise
- * OR of zero or more modifier masks and a key. Examples:
- * <code>SWT.MOD1 | SWT.MOD2 | 'T', SWT.MOD3 | SWT.F2</code>.
- * <code>SWT.CONTROL | SWT.SHIFT | 'T', SWT.ALT | SWT.F2</code>.
- *
- * @param accelerator an integer that is the bit-wise OR of masks and a key
- *
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public void setAccelerator (int accelerator) {
- checkWidget ();
- if (this.accelerator == accelerator) return;
- this.accelerator = accelerator;
- parent.destroyAccelerators ();
-}
-
-/**
- * Enables the receiver if the argument is <code>true</code>,
- * and disables it otherwise. A disabled control is typically
- * not selectable from the user interface and draws with an
- * inactive or "grayed" look.
- *
- * @param enabled the new enabled state
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public void setEnabled (boolean enabled) {
- checkWidget ();
- if ((OS.IsPPC || OS.IsSP) && parent.hwndCB != 0) {
- int hwndCB = parent.hwndCB;
- TBBUTTONINFO info = new TBBUTTONINFO ();
- info.cbSize = TBBUTTONINFO.sizeof;
- info.dwMask = OS.TBIF_STATE;
- OS.SendMessage (hwndCB, OS.TB_GETBUTTONINFO, id, info);
- info.fsState &= ~OS.TBSTATE_ENABLED;
- if (enabled) info.fsState |= OS.TBSTATE_ENABLED;
- OS.SendMessage (hwndCB, OS.TB_SETBUTTONINFO, id, info);
- } else {
- int hMenu = parent.handle;
- if (OS.IsWinCE) {
- int index = parent.indexOf (this);
- if (index == -1) return;
- int uEnable = OS.MF_BYPOSITION | (enabled ? OS.MF_ENABLED : OS.MF_GRAYED);
- OS.EnableMenuItem (hMenu, index, uEnable);
- } else {
- 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);
- int bits = OS.MFS_DISABLED | OS.MFS_GRAYED;
- if (enabled) {
- if ((info.fState & bits) == 0) return;
- info.fState &= ~bits;
- } else {
- if ((info.fState & bits) == bits) return;
- info.fState |= bits;
- }
- success = OS.SetMenuItemInfo (hMenu, id, false, info);
- if (!success) error (SWT.ERROR_CANNOT_SET_ENABLED);
- }
- }
- parent.redraw ();
-}
-
-/**
- * Sets the image the receiver will display to the argument.
- * <p>
- * Note: This feature is not available on all window systems (for example, Window NT),
- * in which case, calling this method will silently do nothing.
- *
- * @param menu the image to display
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public void setImage (Image image) {
- checkWidget ();
- if ((style & SWT.SEPARATOR) != 0) return;
- super.setImage (image);
- if (OS.IsWinCE) return;
- if ((OS.WIN32_MAJOR << 16 | OS.WIN32_MINOR) < (4 << 16 | 10)) {
- return;
- }
- int hMenu = parent.handle;
- MENUITEMINFO info = new MENUITEMINFO ();
- info.cbSize = MENUITEMINFO.sizeof;
- info.fMask = OS.MIIM_BITMAP;
- if (image != null) info.hbmpItem = OS.HBMMENU_CALLBACK;
- OS.SetMenuItemInfo (hMenu, id, false, info);
- parent.redraw ();
-}
-
-/**
- * Sets the receiver's pull down menu to the argument.
- * Only <code>CASCADE</code> menu items can have a
- * pull down menu. The sequence of key strokes, button presses
- * and/or button releases that are used to request a pull down
- * menu is platform specific.
- *
- * @param menu the new pull down menu
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_MENU_NOT_DROP_DOWN - if the menu is not a drop down menu</li>
- * <li>ERROR_MENUITEM_NOT_CASCADE - if the menu item is not a <code>CASCADE</code></li>
- * <li>ERROR_INVALID_ARGUMENT - if the menu has been disposed</li>
- * <li>ERROR_INVALID_PARENT - if the menu is not in the same widget tree</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public void setMenu (Menu menu) {
- checkWidget ();
-
- /* Check to make sure the new menu is valid */
- if ((style & SWT.CASCADE) == 0) {
- error (SWT.ERROR_MENUITEM_NOT_CASCADE);
- }
- if (menu != null) {
- if (menu.isDisposed()) error(SWT.ERROR_INVALID_ARGUMENT);
- 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 */
- if ((OS.IsPPC || OS.IsSP) && parent.hwndCB != 0) {
- if (OS.IsPPC) {
- int hwndCB = parent.hwndCB;
- int hMenu = menu == null ? 0 : menu.handle;
- OS.SendMessage (hwndCB, OS.SHCMBM_SETSUBMENU, id, hMenu);
- }
- if (OS.IsSP) error (SWT.ERROR_CANNOT_SET_MENU);
- } else {
- /*
- * 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_DATA;
- int index = 0;
- while (OS.GetMenuItemInfo (hMenu, index, true, info)) {
- if (info.dwItemData == id) break;
- index++;
- }
- if (info.dwItemData != id) return;
- int cch = 128;
- int hHeap = OS.GetProcessHeap ();
- int byteCount = cch * TCHAR.sizeof;
- int pszText = OS.HeapAlloc (hHeap, OS.HEAP_ZERO_MEMORY, byteCount);
- info.fMask = OS.MIIM_STATE | OS.MIIM_ID | OS.MIIM_TYPE | OS.MIIM_DATA;
- info.dwTypeData = pszText;
- info.cch = cch;
- 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);
- if (OS.IsWinCE) {
- /*
- * On WinCE, InsertMenuItem is not available. SetMenuItemInfo
- * does not set the menu item state and submenu use InsertMenu
- * to set these fields and SetMenuItemInfo to set the menu item
- * data. NOTE: SetMenuItemInfo is also used to set the string
- * that was queried from the original menu item.
- */
- int uIDNewItem = id;
- int uFlags = OS.MF_BYPOSITION;
- if (menu != null) {
- uFlags |= OS.MF_POPUP;
- uIDNewItem = menu.handle;
- }
- TCHAR lpNewItem = new TCHAR (0, "", true);
- success = OS.InsertMenu (hMenu, index, uFlags, uIDNewItem, lpNewItem);
- if (success) {
- info.fMask = OS.MIIM_DATA | OS.MIIM_TYPE;
- success = OS.SetMenuItemInfo (hMenu, index, true, info);
- if ((info.fState & (OS.MFS_DISABLED | OS.MFS_GRAYED)) != 0) {
- OS.EnableMenuItem (hMenu, index, OS.MF_BYPOSITION | OS.MF_GRAYED);
- }
- if ((info.fState & OS.MFS_CHECKED) != 0) {
- OS.CheckMenuItem (hMenu, index, OS.MF_BYPOSITION | OS.MF_CHECKED);
- }
- }
- } else {
- success = OS.InsertMenuItem (hMenu, index, true, info);
- }
- if (pszText != 0) OS.HeapFree (hHeap, 0, pszText);
- if (!success) error (SWT.ERROR_CANNOT_SET_MENU);
- }
- parent.destroyAccelerators ();
-}
-
-boolean setRadioSelection (boolean value) {
- if ((style & SWT.RADIO) == 0) return false;
- if (getSelection () != value) {
- setSelection (value);
- postEvent (SWT.Selection);
- }
- return true;
-}
-
-/**
- * Sets the selection state of the receiver.
- * <p>
- * When the receiver is of type <code>CHECK</code> or <code>RADIO</code>,
- * it is selected when it is checked.
- *
- * @param selected the new selection state
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public void setSelection (boolean selected) {
- checkWidget ();
- if ((style & (SWT.CHECK | SWT.RADIO)) == 0) return;
- if ((OS.IsPPC || OS.IsSP) && parent.hwndCB != 0) return;
- int hMenu = parent.handle;
- if (OS.IsWinCE) {
- int index = parent.indexOf (this);
- if (index == -1) return;
- int uCheck = OS.MF_BYPOSITION | (selected ? OS.MF_CHECKED : OS.MF_UNCHECKED);
- OS.CheckMenuItem (hMenu, index, uCheck);
- } else {
- 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 ();
-}
-/**
- * Sets the receiver's text. The string may include
- * the mnemonic character and accelerator text.
- * <p>
- * Mnemonics are indicated by an '&amp' that causes the next
- * character to be the mnemonic. When the user presses a
- * key sequence that matches the mnemonic, a selection
- * event occurs. On most platforms, the mnemonic appears
- * underlined but may be emphasised in a platform specific
- * manner. The mnemonic indicator character '&amp' can be
- * escaped by doubling it in the string, causing a single
- *'&amp' to be displayed.
- * </p>
- * <p>
- * Accelerator text is indicated by the '\t' character.
- * On platforms that support accelerator text, the text
- * that follows the '\t' character is displayed to the user,
- * typically indicating the key stroke that will cause
- * the item to become selected. On most platforms, the
- * accelerator text appears right aligned in the menu.
- * Setting the accelerator text does not install the
- * accelerator key sequence. The accelerator key sequence
- * is installed using #setAccelerator.
- * </p>
- *
- * @param string the new text
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the text is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see #setAccelerator
- */
-public void setText (String string) {
- checkWidget ();
- if (string == null) error (SWT.ERROR_NULL_ARGUMENT);
- if ((style & SWT.SEPARATOR) != 0) return;
- if (text.equals (string)) return;
- super.setText (string);
- int hHeap = OS.GetProcessHeap ();
- int pszText;
- boolean success = false;
- if ((OS.IsPPC || OS.IsSP) && parent.hwndCB != 0) {
- /*
- * Bug in WinCE PPC. Tool items on the menubar don't resize
- * correctly when the character '&' is used (even when it
- * is a sequence '&&'). The fix is to remove all '&' from
- * the string.
- */
- if (string.indexOf ('&') != -1) {
- int length = string.length ();
- char[] text = new char [length];
- string.getChars( 0, length, text, 0);
- int i = 0, j = 0;
- for (i=0; i<length; i++) {
- if (text[i] != '&') text [j++] = text [i];
- }
- if (j < i) string = new String (text, 0, j);
- }
- /* Use the character encoding for the default locale */
- TCHAR buffer = new TCHAR (0, string, true);
- int byteCount = buffer.length () * TCHAR.sizeof;
- pszText = OS.HeapAlloc (hHeap, OS.HEAP_ZERO_MEMORY, byteCount);
- OS.MoveMemory (pszText, buffer, byteCount);
- int hwndCB = parent.hwndCB;
- TBBUTTONINFO info2 = new TBBUTTONINFO ();
- info2.cbSize = TBBUTTONINFO.sizeof;
- info2.dwMask = OS.TBIF_TEXT;
- info2.pszText = pszText;
- success = OS.SendMessage (hwndCB, OS.TB_SETBUTTONINFO, id, info2) != 0;
- } else {
- /* Use the character encoding for the default locale */
- TCHAR buffer = new TCHAR (0, string, true);
- int byteCount = buffer.length () * TCHAR.sizeof;
- pszText = OS.HeapAlloc (hHeap, OS.HEAP_ZERO_MEMORY, byteCount);
- OS.MoveMemory (pszText, buffer, byteCount);
- int hMenu = parent.handle;
- MENUITEMINFO info = new MENUITEMINFO ();
- info.cbSize = MENUITEMINFO.sizeof;
- info.fMask = OS.MIIM_TYPE;
- info.fType = widgetStyle ();
- info.dwTypeData = pszText;
- success = OS.SetMenuItemInfo (hMenu, id, false, info);
- /*
- * Bug in Windows 2000. For some reason, when MIIM_TYPE is set
- * on a menu item that also has MIIM_BITMAP, the MIIM_TYPE clears
- * the MIIM_BITMAP style. The fix is to reset both MIIM_BITMAP.
- * Note, this does not happen on Windows 98.
- */
- if (!OS.IsWinCE) {
- if ((OS.WIN32_MAJOR << 16 | OS.WIN32_MINOR) >= (4 << 16 | 10)) {
- if (image != null) {
- info.fMask = OS.MIIM_BITMAP;
- info.hbmpItem = OS.HBMMENU_CALLBACK;
- 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 () {
- int bits = 0;
- Decorations shell = parent.parent;
- if ((shell.style & SWT.MIRRORED) != 0) {
- if ((parent.style & SWT.LEFT_TO_RIGHT) != 0) {
- bits |= OS.MFT_RIGHTJUSTIFY | OS.MFT_RIGHTORDER;
- }
- } else {
- if ((parent.style & SWT.RIGHT_TO_LEFT) != 0) {
- bits |= OS.MFT_RIGHTJUSTIFY | OS.MFT_RIGHTORDER;
- }
- }
- if ((style & SWT.SEPARATOR) != 0) return bits | OS.MFT_SEPARATOR;
- if ((style & SWT.RADIO) != 0) return bits | OS.MFT_RADIOCHECK;
- return bits | OS.MFT_STRING;
-}
-
-LRESULT wmCommandChild (int wParam, int lParam) {
- if ((style & SWT.CHECK) != 0) {
- setSelection (!getSelection ());
- } else {
- if ((style & SWT.RADIO) != 0) {
- if ((parent.getStyle () & SWT.NO_RADIO_GROUP) != 0) {
- setSelection (!getSelection ());
- } else {
- selectRadio ();
- }
- }
- }
- Event event = new Event ();
- setInputState (event, SWT.Selection);
- postEvent (SWT.Selection, event);
- return null;
-}
-
-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;
-}
-
-LRESULT wmMeasureChild (int wParam, int lParam) {
- MEASUREITEMSTRUCT struct = new MEASUREITEMSTRUCT ();
- OS.MoveMemory (struct, lParam, MEASUREITEMSTRUCT.sizeof);
- if (image != null) {
- /*
- * Feature in Windows. On Windows 98, it is necessary
- * to add 4 pixels to the width of the image or the image
- * and text are too close. On other Windows platforms,
- * this causes the text of the longest item to touch the
- * accelerator text. The fix is to add only 2 pixels in
- * this case.
- */
- Rectangle rect = image.getBounds ();
- struct.itemWidth = rect.width + (OS.IsWin95 ? 4 : 2);
- struct.itemHeight = rect.height + 4;
- }
- OS.MoveMemory (lParam, struct, MEASUREITEMSTRUCT.sizeof);
- return null;
-}
-
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+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 notification when pressed and released.
+ * <dl>
+ * <dt><b>Styles:</b></dt>
+ * <dd>CHECK, CASCADE, PUSH, RADIO, SEPARATOR</dd>
+ * <dt><b>Events:</b></dt>
+ * <dd>Arm, Help, Selection</dd>
+ * </dl>
+ * <p>
+ * Note: Only one of the styles CHECK, CASCADE, PUSH, RADIO and SEPARATOR
+ * may be specified.
+ * </p><p>
+ * IMPORTANT: This class is <em>not</em> intended to be subclassed.
+ * </p>
+ */
+
+public class MenuItem extends Item {
+ Menu parent, menu;
+ int id, accelerator;
+
+/**
+ * Constructs a new instance of this class given its parent
+ * (which must be a <code>Menu</code>) and a style value
+ * describing its behavior and appearance. The item is added
+ * to the end of the items maintained by its parent.
+ * <p>
+ * The style value is either one of the style constants defined in
+ * class <code>SWT</code> which is applicable to instances of this
+ * class, or must be built by <em>bitwise OR</em>'ing together
+ * (that is, using the <code>int</code> "|" operator) two or more
+ * of those <code>SWT</code> style constants. The class description
+ * lists the style constants that are applicable to the class.
+ * Style bits are also inherited from superclasses.
+ * </p>
+ *
+ * @param parent a menu control which will be the parent of the new instance (cannot be null)
+ * @param style the style of control to construct
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
+ * <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
+ * </ul>
+ *
+ * @see SWT#CHECK
+ * @see SWT#CASCADE
+ * @see SWT#PUSH
+ * @see SWT#RADIO
+ * @see SWT#SEPARATOR
+ * @see Widget#checkSubclass
+ * @see Widget#getStyle
+ */
+public MenuItem (Menu parent, int style) {
+ super (parent, checkStyle (style));
+ this.parent = parent;
+ parent.createItem (this, parent.getItemCount ());
+}
+
+/**
+ * Constructs a new instance of this class given its parent
+ * (which must be a <code>Menu</code>), a style value
+ * describing its behavior and appearance, and the index
+ * at which to place it in the items maintained by its parent.
+ * <p>
+ * The style value is either one of the style constants defined in
+ * class <code>SWT</code> which is applicable to instances of this
+ * class, or must be built by <em>bitwise OR</em>'ing together
+ * (that is, using the <code>int</code> "|" operator) two or more
+ * of those <code>SWT</code> style constants. The class description
+ * lists the style constants that are applicable to the class.
+ * Style bits are also inherited from superclasses.
+ * </p>
+ *
+ * @param parent a menu control which will be the parent of the new instance (cannot be null)
+ * @param style the style of control to construct
+ * @param index the 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#CHECK
+ * @see SWT#CASCADE
+ * @see SWT#PUSH
+ * @see SWT#RADIO
+ * @see SWT#SEPARATOR
+ * @see Widget#checkSubclass
+ * @see Widget#getStyle
+ */
+public MenuItem (Menu parent, int style, int index) {
+ super (parent, checkStyle (style));
+ this.parent = parent;
+ parent.createItem (this, index);
+}
+
+MenuItem (Menu parent, Menu menu, int style, int index) {
+ super (parent, checkStyle (style));
+ this.parent = parent;
+ this.menu = menu;
+ if (menu != null) menu.cascade = this;
+ Decorations shell = parent.parent;
+ shell.add (this);
+}
+
+/**
+ * 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.
+ * <p>
+ * When <code>widgetSelected</code> is called, the stateMask field of the event object is valid.
+ * <code>widgetDefaultSelected</code> is not called.
+ * </p>
+ *
+ * @param listener the listener which should be notified
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see SelectionListener
+ * @see #removeSelectionListener
+ * @see SelectionEvent
+ */
+public void addSelectionListener (SelectionListener listener) {
+ checkWidget ();
+ if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+ TypedListener typedListener = new TypedListener(listener);
+ addListener (SWT.Selection,typedListener);
+ addListener (SWT.DefaultSelection,typedListener);
+}
+
+protected void checkSubclass () {
+ if (!isValidSubclass ()) error (SWT.ERROR_INVALID_SUBCLASS);
+}
+
+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 fVirt = OS.FVIRTKEY;
+ int key = accelerator & SWT.KEY_MASK;
+ int vKey = Display.untranslateKey (key);
+ if (vKey != 0) {
+ key = vKey;
+ } else {
+ switch (key) {
+ /*
+ * Bug in Windows. For some reason, VkKeyScan
+ * fails to map ESC to VK_ESCAPE and DEL to
+ * VK_DELETE. The fix is to map these keys
+ * as a special case.
+ */
+ case 27: key = OS.VK_ESCAPE; break;
+ case 127: key = OS.VK_DELETE; break;
+ default: {
+ key = wcsToMbcs ((char) key);
+ if (key == 0) return;
+ if (OS.IsWinCE) {
+ key = OS.CharUpper ((short) key);
+ } else {
+ vKey = OS.VkKeyScan ((short) key) & 0xFF;
+ if (vKey == -1) {
+ fVirt = 0;
+ } else {
+ key = vKey;
+ }
+ }
+ }
+ }
+ }
+ accel.key = (short) key;
+ accel.cmd = (short) id;
+ accel.fVirt = (byte) fVirt;
+ if ((accelerator & SWT.ALT) != 0) accel.fVirt |= OS.FALT;
+ if ((accelerator & SWT.SHIFT) != 0) accel.fVirt |= OS.FSHIFT;
+ if ((accelerator & SWT.CONTROL) != 0) accel.fVirt |= OS.FCONTROL;
+}
+
+/**
+ * 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>
+ *
+ * @see #isEnabled
+ */
+public boolean getEnabled () {
+ checkWidget ();
+ if ((OS.IsPPC || OS.IsSP) && parent.hwndCB != 0) {
+ int hwndCB = parent.hwndCB;
+ TBBUTTONINFO info = new TBBUTTONINFO ();
+ info.cbSize = TBBUTTONINFO.sizeof;
+ info.dwMask = OS.TBIF_STATE;
+ OS.SendMessage (hwndCB, OS.TB_GETBUTTONINFO, id, info);
+ return (info.fsState & OS.TBSTATE_ENABLED) != 0;
+ }
+ int hMenu = parent.handle;
+ MENUITEMINFO info = new MENUITEMINFO ();
+ info.cbSize = MENUITEMINFO.sizeof;
+ info.fMask = OS.MIIM_STATE;
+ boolean success;
+ if (OS.IsWinCE) {
+ int index = parent.indexOf (this);
+ if (index == -1) error (SWT.ERROR_CANNOT_GET_ENABLED);
+ success = OS.GetMenuItemInfo (hMenu, index, true, info);
+ } else {
+ 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;
+ if ((OS.IsPPC || OS.IsSP) && parent.hwndCB != 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 all
+ * of the receiver's ancestors are enabled, and <code>false</code>
+ * otherwise. A disabled control is typically not selectable from the
+ * user interface and draws with an inactive or "grayed" look.
+ *
+ * @return the receiver's enabled state
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see #getEnabled
+ */
+public boolean isEnabled () {
+ return getEnabled () && parent.isEnabled ();
+}
+
+void releaseChild () {
+ super.releaseChild ();
+ if (menu != null) menu.dispose ();
+ menu = null;
+ parent.destroyItem (this);
+}
+
+void releaseMenu () {
+ if (!OS.IsSP) setMenu (null);
+ menu = null;
+}
+
+void releaseWidget () {
+ if (menu != null) menu.releaseResources ();
+ menu = null;
+ super.releaseWidget ();
+ if (accelerator != 0) {
+ parent.destroyAccelerators ();
+ }
+ 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);
+}
+
+void selectRadio () {
+ int index = 0;
+ MenuItem [] items = parent.getItems ();
+ while (index < items.length && items [index] != this) index++;
+ int i = index - 1;
+ while (i >= 0 && items [i].setRadioSelection (false)) --i;
+ int j = index + 1;
+ while (j < items.length && items [j].setRadioSelection (false)) j++;
+ setSelection (true);
+}
+
+/**
+ * Sets the widget accelerator. An accelerator is the bit-wise
+ * OR of zero or more modifier masks and a key. Examples:
+ * <code>SWT.MOD1 | SWT.MOD2 | 'T', SWT.MOD3 | SWT.F2</code>.
+ * <code>SWT.CONTROL | SWT.SHIFT | 'T', SWT.ALT | SWT.F2</code>.
+ *
+ * @param accelerator an integer that is the bit-wise OR of masks and a key
+ *
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setAccelerator (int accelerator) {
+ checkWidget ();
+ if (this.accelerator == accelerator) return;
+ this.accelerator = accelerator;
+ parent.destroyAccelerators ();
+}
+
+/**
+ * Enables the receiver if the argument is <code>true</code>,
+ * and disables it otherwise. A disabled control is typically
+ * not selectable from the user interface and draws with an
+ * inactive or "grayed" look.
+ *
+ * @param enabled the new enabled state
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setEnabled (boolean enabled) {
+ checkWidget ();
+ if ((OS.IsPPC || OS.IsSP) && parent.hwndCB != 0) {
+ int hwndCB = parent.hwndCB;
+ TBBUTTONINFO info = new TBBUTTONINFO ();
+ info.cbSize = TBBUTTONINFO.sizeof;
+ info.dwMask = OS.TBIF_STATE;
+ OS.SendMessage (hwndCB, OS.TB_GETBUTTONINFO, id, info);
+ info.fsState &= ~OS.TBSTATE_ENABLED;
+ if (enabled) info.fsState |= OS.TBSTATE_ENABLED;
+ OS.SendMessage (hwndCB, OS.TB_SETBUTTONINFO, id, info);
+ } else {
+ int hMenu = parent.handle;
+ if (OS.IsWinCE) {
+ int index = parent.indexOf (this);
+ if (index == -1) return;
+ int uEnable = OS.MF_BYPOSITION | (enabled ? OS.MF_ENABLED : OS.MF_GRAYED);
+ OS.EnableMenuItem (hMenu, index, uEnable);
+ } else {
+ 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);
+ int bits = OS.MFS_DISABLED | OS.MFS_GRAYED;
+ if (enabled) {
+ if ((info.fState & bits) == 0) return;
+ info.fState &= ~bits;
+ } else {
+ if ((info.fState & bits) == bits) return;
+ info.fState |= bits;
+ }
+ success = OS.SetMenuItemInfo (hMenu, id, false, info);
+ if (!success) error (SWT.ERROR_CANNOT_SET_ENABLED);
+ }
+ }
+ parent.redraw ();
+}
+
+/**
+ * Sets the image the receiver will display to the argument.
+ * <p>
+ * Note: This feature is not available on all window systems (for example, Window NT),
+ * in which case, calling this method will silently do nothing.
+ *
+ * @param menu the image to display
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setImage (Image image) {
+ checkWidget ();
+ if ((style & SWT.SEPARATOR) != 0) return;
+ super.setImage (image);
+ if (OS.IsWinCE) return;
+ if ((OS.WIN32_MAJOR << 16 | OS.WIN32_MINOR) < (4 << 16 | 10)) {
+ return;
+ }
+ int hMenu = parent.handle;
+ MENUITEMINFO info = new MENUITEMINFO ();
+ info.cbSize = MENUITEMINFO.sizeof;
+ info.fMask = OS.MIIM_BITMAP;
+ if (image != null) info.hbmpItem = OS.HBMMENU_CALLBACK;
+ OS.SetMenuItemInfo (hMenu, id, false, info);
+ parent.redraw ();
+}
+
+/**
+ * Sets the receiver's pull down menu to the argument.
+ * Only <code>CASCADE</code> menu items can have a
+ * pull down menu. The sequence of key strokes, button presses
+ * and/or button releases that are used to request a pull down
+ * menu is platform specific.
+ *
+ * @param menu the new pull down menu
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_MENU_NOT_DROP_DOWN - if the menu is not a drop down menu</li>
+ * <li>ERROR_MENUITEM_NOT_CASCADE - if the menu item is not a <code>CASCADE</code></li>
+ * <li>ERROR_INVALID_ARGUMENT - if the menu has been disposed</li>
+ * <li>ERROR_INVALID_PARENT - if the menu is not in the same widget tree</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setMenu (Menu menu) {
+ checkWidget ();
+
+ /* Check to make sure the new menu is valid */
+ if ((style & SWT.CASCADE) == 0) {
+ error (SWT.ERROR_MENUITEM_NOT_CASCADE);
+ }
+ if (menu != null) {
+ if (menu.isDisposed()) error(SWT.ERROR_INVALID_ARGUMENT);
+ 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 */
+ if ((OS.IsPPC || OS.IsSP) && parent.hwndCB != 0) {
+ if (OS.IsPPC) {
+ int hwndCB = parent.hwndCB;
+ int hMenu = menu == null ? 0 : menu.handle;
+ OS.SendMessage (hwndCB, OS.SHCMBM_SETSUBMENU, id, hMenu);
+ }
+ if (OS.IsSP) error (SWT.ERROR_CANNOT_SET_MENU);
+ } else {
+ /*
+ * 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_DATA;
+ int index = 0;
+ while (OS.GetMenuItemInfo (hMenu, index, true, info)) {
+ if (info.dwItemData == id) break;
+ index++;
+ }
+ if (info.dwItemData != id) return;
+ int cch = 128;
+ int hHeap = OS.GetProcessHeap ();
+ int byteCount = cch * TCHAR.sizeof;
+ int pszText = OS.HeapAlloc (hHeap, OS.HEAP_ZERO_MEMORY, byteCount);
+ info.fMask = OS.MIIM_STATE | OS.MIIM_ID | OS.MIIM_TYPE | OS.MIIM_DATA;
+ info.dwTypeData = pszText;
+ info.cch = cch;
+ 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);
+ if (OS.IsWinCE) {
+ /*
+ * On WinCE, InsertMenuItem is not available. SetMenuItemInfo
+ * does not set the menu item state and submenu use InsertMenu
+ * to set these fields and SetMenuItemInfo to set the menu item
+ * data. NOTE: SetMenuItemInfo is also used to set the string
+ * that was queried from the original menu item.
+ */
+ int uIDNewItem = id;
+ int uFlags = OS.MF_BYPOSITION;
+ if (menu != null) {
+ uFlags |= OS.MF_POPUP;
+ uIDNewItem = menu.handle;
+ }
+ TCHAR lpNewItem = new TCHAR (0, "", true);
+ success = OS.InsertMenu (hMenu, index, uFlags, uIDNewItem, lpNewItem);
+ if (success) {
+ info.fMask = OS.MIIM_DATA | OS.MIIM_TYPE;
+ success = OS.SetMenuItemInfo (hMenu, index, true, info);
+ if ((info.fState & (OS.MFS_DISABLED | OS.MFS_GRAYED)) != 0) {
+ OS.EnableMenuItem (hMenu, index, OS.MF_BYPOSITION | OS.MF_GRAYED);
+ }
+ if ((info.fState & OS.MFS_CHECKED) != 0) {
+ OS.CheckMenuItem (hMenu, index, OS.MF_BYPOSITION | OS.MF_CHECKED);
+ }
+ }
+ } else {
+ success = OS.InsertMenuItem (hMenu, index, true, info);
+ }
+ if (pszText != 0) OS.HeapFree (hHeap, 0, pszText);
+ if (!success) error (SWT.ERROR_CANNOT_SET_MENU);
+ }
+ parent.destroyAccelerators ();
+}
+
+boolean setRadioSelection (boolean value) {
+ if ((style & SWT.RADIO) == 0) return false;
+ if (getSelection () != value) {
+ setSelection (value);
+ postEvent (SWT.Selection);
+ }
+ return true;
+}
+
+/**
+ * Sets the selection state of the receiver.
+ * <p>
+ * When the receiver is of type <code>CHECK</code> or <code>RADIO</code>,
+ * it is selected when it is checked.
+ *
+ * @param selected the new selection state
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setSelection (boolean selected) {
+ checkWidget ();
+ if ((style & (SWT.CHECK | SWT.RADIO)) == 0) return;
+ if ((OS.IsPPC || OS.IsSP) && parent.hwndCB != 0) return;
+ int hMenu = parent.handle;
+ if (OS.IsWinCE) {
+ int index = parent.indexOf (this);
+ if (index == -1) return;
+ int uCheck = OS.MF_BYPOSITION | (selected ? OS.MF_CHECKED : OS.MF_UNCHECKED);
+ OS.CheckMenuItem (hMenu, index, uCheck);
+ } else {
+ 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 ();
+}
+/**
+ * Sets the receiver's text. The string may include
+ * the mnemonic character and accelerator text.
+ * <p>
+ * Mnemonics are indicated by an '&amp' that causes the next
+ * character to be the mnemonic. When the user presses a
+ * key sequence that matches the mnemonic, a selection
+ * event occurs. On most platforms, the mnemonic appears
+ * underlined but may be emphasised in a platform specific
+ * manner. The mnemonic indicator character '&amp' can be
+ * escaped by doubling it in the string, causing a single
+ *'&amp' to be displayed.
+ * </p>
+ * <p>
+ * Accelerator text is indicated by the '\t' character.
+ * On platforms that support accelerator text, the text
+ * that follows the '\t' character is displayed to the user,
+ * typically indicating the key stroke that will cause
+ * the item to become selected. On most platforms, the
+ * accelerator text appears right aligned in the menu.
+ * Setting the accelerator text does not install the
+ * accelerator key sequence. The accelerator key sequence
+ * is installed using #setAccelerator.
+ * </p>
+ *
+ * @param string the new text
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if the text is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see #setAccelerator
+ */
+public void setText (String string) {
+ checkWidget ();
+ if (string == null) error (SWT.ERROR_NULL_ARGUMENT);
+ if ((style & SWT.SEPARATOR) != 0) return;
+ if (text.equals (string)) return;
+ super.setText (string);
+ int hHeap = OS.GetProcessHeap ();
+ int pszText;
+ boolean success = false;
+ if ((OS.IsPPC || OS.IsSP) && parent.hwndCB != 0) {
+ /*
+ * Bug in WinCE PPC. Tool items on the menubar don't resize
+ * correctly when the character '&' is used (even when it
+ * is a sequence '&&'). The fix is to remove all '&' from
+ * the string.
+ */
+ if (string.indexOf ('&') != -1) {
+ int length = string.length ();
+ char[] text = new char [length];
+ string.getChars( 0, length, text, 0);
+ int i = 0, j = 0;
+ for (i=0; i<length; i++) {
+ if (text[i] != '&') text [j++] = text [i];
+ }
+ if (j < i) string = new String (text, 0, j);
+ }
+ /* Use the character encoding for the default locale */
+ TCHAR buffer = new TCHAR (0, string, true);
+ int byteCount = buffer.length () * TCHAR.sizeof;
+ pszText = OS.HeapAlloc (hHeap, OS.HEAP_ZERO_MEMORY, byteCount);
+ OS.MoveMemory (pszText, buffer, byteCount);
+ int hwndCB = parent.hwndCB;
+ TBBUTTONINFO info2 = new TBBUTTONINFO ();
+ info2.cbSize = TBBUTTONINFO.sizeof;
+ info2.dwMask = OS.TBIF_TEXT;
+ info2.pszText = pszText;
+ success = OS.SendMessage (hwndCB, OS.TB_SETBUTTONINFO, id, info2) != 0;
+ } else {
+ /* Use the character encoding for the default locale */
+ TCHAR buffer = new TCHAR (0, string, true);
+ int byteCount = buffer.length () * TCHAR.sizeof;
+ pszText = OS.HeapAlloc (hHeap, OS.HEAP_ZERO_MEMORY, byteCount);
+ OS.MoveMemory (pszText, buffer, byteCount);
+ int hMenu = parent.handle;
+ MENUITEMINFO info = new MENUITEMINFO ();
+ info.cbSize = MENUITEMINFO.sizeof;
+ info.fMask = OS.MIIM_TYPE;
+ info.fType = widgetStyle ();
+ info.dwTypeData = pszText;
+ success = OS.SetMenuItemInfo (hMenu, id, false, info);
+ /*
+ * Bug in Windows 2000. For some reason, when MIIM_TYPE is set
+ * on a menu item that also has MIIM_BITMAP, the MIIM_TYPE clears
+ * the MIIM_BITMAP style. The fix is to reset both MIIM_BITMAP.
+ * Note, this does not happen on Windows 98.
+ */
+ if (!OS.IsWinCE) {
+ if ((OS.WIN32_MAJOR << 16 | OS.WIN32_MINOR) >= (4 << 16 | 10)) {
+ if (image != null) {
+ info.fMask = OS.MIIM_BITMAP;
+ info.hbmpItem = OS.HBMMENU_CALLBACK;
+ 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 () {
+ int bits = 0;
+ Decorations shell = parent.parent;
+ if ((shell.style & SWT.MIRRORED) != 0) {
+ if ((parent.style & SWT.LEFT_TO_RIGHT) != 0) {
+ bits |= OS.MFT_RIGHTJUSTIFY | OS.MFT_RIGHTORDER;
+ }
+ } else {
+ if ((parent.style & SWT.RIGHT_TO_LEFT) != 0) {
+ bits |= OS.MFT_RIGHTJUSTIFY | OS.MFT_RIGHTORDER;
+ }
+ }
+ if ((style & SWT.SEPARATOR) != 0) return bits | OS.MFT_SEPARATOR;
+ if ((style & SWT.RADIO) != 0) return bits | OS.MFT_RADIOCHECK;
+ return bits | OS.MFT_STRING;
+}
+
+LRESULT wmCommandChild (int wParam, int lParam) {
+ if ((style & SWT.CHECK) != 0) {
+ setSelection (!getSelection ());
+ } else {
+ if ((style & SWT.RADIO) != 0) {
+ if ((parent.getStyle () & SWT.NO_RADIO_GROUP) != 0) {
+ setSelection (!getSelection ());
+ } else {
+ selectRadio ();
+ }
+ }
+ }
+ Event event = new Event ();
+ setInputState (event, SWT.Selection);
+ postEvent (SWT.Selection, event);
+ return null;
+}
+
+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;
+}
+
+LRESULT wmMeasureChild (int wParam, int lParam) {
+ MEASUREITEMSTRUCT struct = new MEASUREITEMSTRUCT ();
+ OS.MoveMemory (struct, lParam, MEASUREITEMSTRUCT.sizeof);
+ if (image != null) {
+ /*
+ * Feature in Windows. On Windows 98, it is necessary
+ * to add 4 pixels to the width of the image or the image
+ * and text are too close. On other Windows platforms,
+ * this causes the text of the longest item to touch the
+ * accelerator text. The fix is to add only 2 pixels in
+ * this case.
+ */
+ Rectangle rect = image.getBounds ();
+ struct.itemWidth = rect.width + (OS.IsWin95 ? 4 : 2);
+ struct.itemHeight = rect.height + 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
index e1716155e8..0b8b1e180e 100755
--- 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
@@ -1,252 +1,252 @@
-package org.eclipse.swt.widgets;
-
-/*
+package org.eclipse.swt.widgets;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-import org.eclipse.swt.internal.win32.*;
-import org.eclipse.swt.*;
-
-/**
- * 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>
- * Note: Only one of the styles ICON_ERROR, ICON_INFORMATION, ICON_QUESTION,
- * ICON_WARNING and ICON_WORKING may be specified.
- * </p><p>
- * IMPORTANT: This class is intended to be subclassed <em>only</em>
- * within the SWT implementation.
- * </p>
- */
-public class MessageBox extends Dialog {
- String message = "";
-
-/**
- * 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 MessageBox (Shell parent) {
- this (parent, SWT.OK | SWT.ICON_INFORMATION | SWT.APPLICATION_MODAL);
-}
-
-/**
- * Constructs a new instance of this class given its parent
- * and a style value describing its behavior and appearance.
- * <p>
- * The style value is either one of the style constants defined in
- * class <code>SWT</code> which is applicable to instances of this
- * class, or must be built by <em>bitwise OR</em>'ing together
- * (that is, using the <code>int</code> "|" operator) two or more
- * of those <code>SWT</code> style constants. The class description
- * lists the style constants that are applicable to the class.
- * Style bits are also inherited from superclasses.
- * </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 MessageBox (Shell parent, int style) {
- super (parent, checkStyle (style));
- checkSubclass ();
-}
-
-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;
-}
-
-/**
- * Returns the dialog's message, which is a description of
- * the purpose for which it was opened. This message will be
- * visible on the dialog while it is open.
- *
- * @return the message
- */
-public String getMessage () {
- return message;
-}
-
-/**
- * Makes the dialog visible and brings it to the front
- * of the display.
- *
- * @return the ID of the button that was selected to dismiss the
- * message box (e.g. SWT.OK, SWT.CANCEL, etc...)
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the dialog has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the dialog</li>
- * </ul>
- */
-public int open () {
-
- /* 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;
-
- /* Only MB_APPLMODAL is supported on WinCE */
- int modalBits = 0;
- if (OS.IsWinCE) {
- if ((style & (SWT.PRIMARY_MODAL | SWT.APPLICATION_MODAL | SWT.SYSTEM_MODAL)) != 0) {
- modalBits = OS.MB_APPLMODAL;
- }
- } else {
- 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;
- if ((style & SWT.RIGHT_TO_LEFT) != 0) bits |= OS.MB_RTLREADING;
- if (parent != null && (parent.style & SWT.RIGHT_TO_LEFT) != 0) {
- bits |= OS.MB_RTLREADING;
- }
-
- /*
- * 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;
- }
-
- /*
- * Feature in Windows. In order for MB_TASKMODAL to work,
- * the parent HWND of the MessageBox () call must be NULL.
- * If the parent is not NULL, MB_TASKMODAL behaves the
- * same as MB_APPLMODAL. 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 */
- /* Use the character encoding for the default locale */
- TCHAR buffer1 = new TCHAR (0, message, true);
- TCHAR buffer2 = new TCHAR (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;
-}
-
-/**
- * Sets the dialog's message, which is a description of
- * the purpose for which it was opened. This message will be
- * visible on the dialog while it is open.
- *
- * @param string the message
- */
-public void setMessage (String string) {
- message = string;
-}
-
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+import org.eclipse.swt.internal.win32.*;
+import org.eclipse.swt.*;
+
+/**
+ * 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>
+ * Note: Only one of the styles ICON_ERROR, ICON_INFORMATION, ICON_QUESTION,
+ * ICON_WARNING and ICON_WORKING may be specified.
+ * </p><p>
+ * IMPORTANT: This class is intended to be subclassed <em>only</em>
+ * within the SWT implementation.
+ * </p>
+ */
+public class MessageBox extends Dialog {
+ String message = "";
+
+/**
+ * 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 MessageBox (Shell parent) {
+ this (parent, SWT.OK | SWT.ICON_INFORMATION | SWT.APPLICATION_MODAL);
+}
+
+/**
+ * Constructs a new instance of this class given its parent
+ * and a style value describing its behavior and appearance.
+ * <p>
+ * The style value is either one of the style constants defined in
+ * class <code>SWT</code> which is applicable to instances of this
+ * class, or must be built by <em>bitwise OR</em>'ing together
+ * (that is, using the <code>int</code> "|" operator) two or more
+ * of those <code>SWT</code> style constants. The class description
+ * lists the style constants that are applicable to the class.
+ * Style bits are also inherited from superclasses.
+ * </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 MessageBox (Shell parent, int style) {
+ super (parent, checkStyle (style));
+ checkSubclass ();
+}
+
+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;
+}
+
+/**
+ * Returns the dialog's message, which is a description of
+ * the purpose for which it was opened. This message will be
+ * visible on the dialog while it is open.
+ *
+ * @return the message
+ */
+public String getMessage () {
+ return message;
+}
+
+/**
+ * Makes the dialog visible and brings it to the front
+ * of the display.
+ *
+ * @return the ID of the button that was selected to dismiss the
+ * message box (e.g. SWT.OK, SWT.CANCEL, etc...)
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the dialog has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the dialog</li>
+ * </ul>
+ */
+public int open () {
+
+ /* 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;
+
+ /* Only MB_APPLMODAL is supported on WinCE */
+ int modalBits = 0;
+ if (OS.IsWinCE) {
+ if ((style & (SWT.PRIMARY_MODAL | SWT.APPLICATION_MODAL | SWT.SYSTEM_MODAL)) != 0) {
+ modalBits = OS.MB_APPLMODAL;
+ }
+ } else {
+ 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;
+ if ((style & SWT.RIGHT_TO_LEFT) != 0) bits |= OS.MB_RTLREADING;
+ if (parent != null && (parent.style & SWT.RIGHT_TO_LEFT) != 0) {
+ bits |= OS.MB_RTLREADING;
+ }
+
+ /*
+ * 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;
+ }
+
+ /*
+ * Feature in Windows. In order for MB_TASKMODAL to work,
+ * the parent HWND of the MessageBox () call must be NULL.
+ * If the parent is not NULL, MB_TASKMODAL behaves the
+ * same as MB_APPLMODAL. 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 */
+ /* Use the character encoding for the default locale */
+ TCHAR buffer1 = new TCHAR (0, message, true);
+ TCHAR buffer2 = new TCHAR (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;
+}
+
+/**
+ * Sets the dialog's message, which is a description of
+ * the purpose for which it was opened. This message will be
+ * visible on the dialog while it is open.
+ *
+ * @param string the message
+ */
+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
index e2b5996604..14a37795ee 100755
--- 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
@@ -1,279 +1,279 @@
-package org.eclipse.swt.widgets;
-
-/*
+package org.eclipse.swt.widgets;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-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,
- * typically in the form of a bar.
- * <dl>
- * <dt><b>Styles:</b></dt>
- * <dd>SMOOTH, HORIZONTAL, VERTICAL, INDETERMINATE</dd>
- * <dt><b>Events:</b></dt>
- * <dd>(none)</dd>
- * </dl>
- * <p>
- * Note: Only one of the styles HORIZONTAL and VERTICAL may be specified.
- * </p><p>
- * IMPORTANT: This class is intended to be subclassed <em>only</em>
- * within the SWT implementation.
- * </p>
- */
-public class ProgressBar extends Control {
- static final int DELAY = 100;
- static final int TIMER_ID = 100;
- static final int ProgressBarProc;
- static final TCHAR ProgressBarClass = new TCHAR (0, OS.PROGRESS_CLASS, true);
- static {
- WNDCLASS lpWndClass = new WNDCLASS ();
- OS.GetClassInfo (0, ProgressBarClass, lpWndClass);
- ProgressBarProc = 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
- * lists the style constants that are applicable to the class.
- * Style bits are also inherited from superclasses.
- * </p>
- *
- * @param parent a composite control which will be the parent of the new instance (cannot be null)
- * @param style the style of control to construct
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
- * <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
- * </ul>
- *
- * @see SWT#SMOOTH
- * @see SWT#HORIZONTAL
- * @see SWT#VERTICAL
- * @see Widget#checkSubclass
- * @see Widget#getStyle
- */
-public ProgressBar (Composite parent, int style) {
- super (parent, checkStyle (style));
-}
-
-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 ();
- if ((style & SWT.INDETERMINATE) != 0) {
- OS.SetTimer (handle, TIMER_ID, DELAY, 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 releaseWidget () {
- super.releaseWidget ();
- if ((style & SWT.INDETERMINATE) != 0) {
- OS.KillTimer (handle, TIMER_ID);
- }
-}
-
-void setBackgroundPixel (int pixel) {
- if (background == pixel) return;
- background = pixel;
- if (pixel == -1) pixel = OS.CLR_DEFAULT;
- OS.SendMessage (handle, OS.PBM_SETBKCOLOR, 0, pixel);
-}
-
-public boolean setFocus () {
- checkWidget();
- return false;
-}
-
-void setForegroundPixel (int pixel) {
- if (foreground == pixel) return;
- foreground = pixel;
- if (pixel == -1) pixel = OS.CLR_DEFAULT;
- 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 ();
- 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;
-}
-
-TCHAR windowClass () {
- return ProgressBarClass;
-}
-
-int windowProc () {
- return ProgressBarProc;
-}
-
-LRESULT WM_GETDLGCODE (int wParam, int lParam) {
- LRESULT result = super.WM_GETDLGCODE (wParam, lParam);
- if (result != null) return result;
- /*
- * Feature in Windows. The progress bar does
- * not implement WM_GETDLGCODE. As a result,
- * a progress bar takes focus and takes part
- * in tab traversal. This behavior, while
- * unspecified, is unwanted. The fix is to
- * implement WM_GETDLGCODE to behave like a
- * STATIC control.
- */
- return new LRESULT (OS.DLGC_STATIC);
-}
-
-LRESULT WM_TIMER (int wParam, int lParam) {
- LRESULT result = super.WM_TIMER (wParam, lParam);
- if (result != null) return result;
- if (wParam == TIMER_ID) {
- OS.SendMessage (handle, OS.PBM_STEPIT, 0, 0);
- }
- return null;
-}
-
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+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,
+ * typically in the form of a bar.
+ * <dl>
+ * <dt><b>Styles:</b></dt>
+ * <dd>SMOOTH, HORIZONTAL, VERTICAL, INDETERMINATE</dd>
+ * <dt><b>Events:</b></dt>
+ * <dd>(none)</dd>
+ * </dl>
+ * <p>
+ * Note: Only one of the styles HORIZONTAL and VERTICAL may be specified.
+ * </p><p>
+ * IMPORTANT: This class is intended to be subclassed <em>only</em>
+ * within the SWT implementation.
+ * </p>
+ */
+public class ProgressBar extends Control {
+ static final int DELAY = 100;
+ static final int TIMER_ID = 100;
+ static final int ProgressBarProc;
+ static final TCHAR ProgressBarClass = new TCHAR (0, OS.PROGRESS_CLASS, true);
+ static {
+ WNDCLASS lpWndClass = new WNDCLASS ();
+ OS.GetClassInfo (0, ProgressBarClass, lpWndClass);
+ ProgressBarProc = 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
+ * lists the style constants that are applicable to the class.
+ * Style bits are also inherited from superclasses.
+ * </p>
+ *
+ * @param parent a composite control which will be the parent of the new instance (cannot be null)
+ * @param style the style of control to construct
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
+ * <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
+ * </ul>
+ *
+ * @see SWT#SMOOTH
+ * @see SWT#HORIZONTAL
+ * @see SWT#VERTICAL
+ * @see Widget#checkSubclass
+ * @see Widget#getStyle
+ */
+public ProgressBar (Composite parent, int style) {
+ super (parent, checkStyle (style));
+}
+
+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 ();
+ if ((style & SWT.INDETERMINATE) != 0) {
+ OS.SetTimer (handle, TIMER_ID, DELAY, 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 releaseWidget () {
+ super.releaseWidget ();
+ if ((style & SWT.INDETERMINATE) != 0) {
+ OS.KillTimer (handle, TIMER_ID);
+ }
+}
+
+void setBackgroundPixel (int pixel) {
+ if (background == pixel) return;
+ background = pixel;
+ if (pixel == -1) pixel = OS.CLR_DEFAULT;
+ OS.SendMessage (handle, OS.PBM_SETBKCOLOR, 0, pixel);
+}
+
+public boolean setFocus () {
+ checkWidget();
+ return false;
+}
+
+void setForegroundPixel (int pixel) {
+ if (foreground == pixel) return;
+ foreground = pixel;
+ if (pixel == -1) pixel = OS.CLR_DEFAULT;
+ 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 ();
+ 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;
+}
+
+TCHAR windowClass () {
+ return ProgressBarClass;
+}
+
+int windowProc () {
+ return ProgressBarProc;
+}
+
+LRESULT WM_GETDLGCODE (int wParam, int lParam) {
+ LRESULT result = super.WM_GETDLGCODE (wParam, lParam);
+ if (result != null) return result;
+ /*
+ * Feature in Windows. The progress bar does
+ * not implement WM_GETDLGCODE. As a result,
+ * a progress bar takes focus and takes part
+ * in tab traversal. This behavior, while
+ * unspecified, is unwanted. The fix is to
+ * implement WM_GETDLGCODE to behave like a
+ * STATIC control.
+ */
+ return new LRESULT (OS.DLGC_STATIC);
+}
+
+LRESULT WM_TIMER (int wParam, int lParam) {
+ LRESULT result = super.WM_TIMER (wParam, lParam);
+ if (result != null) return result;
+ if (wParam == TIMER_ID) {
+ OS.SendMessage (handle, OS.PBM_STEPIT, 0, 0);
+ }
+ return null;
+}
+
+}
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
index 3d744daf42..ad7f3cd6c8 100755
--- 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
@@ -1,404 +1,404 @@
-package org.eclipse.swt.widgets;
-
-/*
+package org.eclipse.swt.widgets;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-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>
- * Note: Only one of the styles HORIZONTAL and VERTICAL may be specified.
- * </p><p>
- * IMPORTANT: This class is intended to be subclassed <em>only</em>
- * within the SWT implementation.
- * </p>
- */
-public class Sash extends Control {
- boolean dragging;
- int startX, startY, lastX, lastY;
- final static int INCREMENT = 1;
- final static int PAGE_INCREMENT = 9;
-
-/**
- * Constructs a new instance of this class given its parent
- * and a style value describing its behavior and appearance.
- * <p>
- * The style value is either one of the style constants defined in
- * class <code>SWT</code> which is applicable to instances of this
- * class, or must be built by <em>bitwise OR</em>'ing together
- * (that is, using the <code>int</code> "|" operator) two or more
- * of those <code>SWT</code> style constants. The class description
- * lists the style constants that are applicable to the class.
- * Style bits are also inherited from superclasses.
- * </p>
- *
- * @param parent a composite control which will be the parent of the new instance (cannot be null)
- * @param style the style of control to construct
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
- * <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
- * </ul>
- *
- * @see SWT#HORIZONTAL
- * @see SWT#VERTICAL
- * @see Widget#checkSubclass
- * @see Widget#getStyle
- */
-public Sash (Composite parent, int style) {
- super (parent, checkStyle (style));
-}
-
-/**
- * Adds the listener to the collection of listeners who will
- * be notified when the control is selected, by sending
- * it one of the messages defined in the <code>SelectionListener</code>
- * interface.
- * <p>
- * When <code>widgetSelected</code> is called, the x, y, width, and height fields of the event object are valid.
- * If the reciever is being dragged, the event object detail field contains the value <code>SWT.DRAG</code>.
- * <code>widgetDefaultSelected</code> is not called.
- * </p>
- *
- * @param listener the listener which should be notified
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see SelectionListener
- * @see #removeSelectionListener
- * @see SelectionEvent
- */
-public void addSelectionListener (SelectionListener listener) {
- checkWidget ();
- if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
- TypedListener typedListener = new TypedListener (listener);
- addListener (SWT.Selection,typedListener);
- addListener (SWT.DefaultSelection,typedListener);
-}
-
-int 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);
-}
-
-TCHAR 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;
- drawBackground (wParam);
- return LRESULT.ONE;
-}
-
-LRESULT WM_KEYDOWN (int wParam, int lParam) {
- LRESULT result = super.WM_KEYDOWN (wParam, lParam);
- if (result != null) return result;
- switch (wParam) {
- case OS.VK_LEFT:
- case OS.VK_RIGHT:
- case OS.VK_UP:
- case OS.VK_DOWN:
-
- /* Calculate the new x or y position */
- if (OS.GetKeyState (OS.VK_LBUTTON) < 0) return result;
- int step = OS.GetKeyState (OS.VK_CONTROL) < 0 ? INCREMENT : PAGE_INCREMENT;
- POINT pt = new POINT ();
- if ((style & SWT.VERTICAL) != 0) {
- if (wParam == OS.VK_UP || wParam == OS.VK_DOWN) break;
- pt.x = wParam == OS.VK_LEFT ? -step : step;
- } else {
- if (wParam == OS.VK_LEFT || wParam == OS.VK_RIGHT) break;
- pt.y = wParam == OS.VK_UP ? -step : step;
- }
- 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;
-
- /* Update the pointer position */
- POINT cursorPt = new POINT ();
- cursorPt.x = pt.x; cursorPt.y = pt.y;
- OS.ClientToScreen (parent.handle, cursorPt);
- if ((style & SWT.VERTICAL) != 0) {
- cursorPt.y += height / 2;
- }
- else {
- cursorPt.x += width / 2;
- }
- OS.SetCursorPos (cursorPt.x, cursorPt.y);
-
- /* 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;
-
- /*
- * 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;
- return result;
- }
- return result;
-}
-
-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 ();
- if (OS.IsWinCE) {
- OS.UpdateWindow (hwndTrack);
- } else {
- 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 newX = lastX, newY = lastY;
- if ((style & SWT.VERTICAL) != 0) {
- int clientWidth = clientRect.right - clientRect.left;
- newX = Math.min (Math.max (0, pt.x - startX), clientWidth - width);
- } else {
- int clientHeight = clientRect.bottom - clientRect.top;
- 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;
- if (OS.IsWinCE) {
- OS.UpdateWindow (hwndTrack);
- } else {
- 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 = 0;
- 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;
-}
-
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+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>
+ * Note: Only one of the styles HORIZONTAL and VERTICAL may be specified.
+ * </p><p>
+ * IMPORTANT: This class is intended to be subclassed <em>only</em>
+ * within the SWT implementation.
+ * </p>
+ */
+public class Sash extends Control {
+ boolean dragging;
+ int startX, startY, lastX, lastY;
+ final static int INCREMENT = 1;
+ final static int PAGE_INCREMENT = 9;
+
+/**
+ * Constructs a new instance of this class given its parent
+ * and a style value describing its behavior and appearance.
+ * <p>
+ * The style value is either one of the style constants defined in
+ * class <code>SWT</code> which is applicable to instances of this
+ * class, or must be built by <em>bitwise OR</em>'ing together
+ * (that is, using the <code>int</code> "|" operator) two or more
+ * of those <code>SWT</code> style constants. The class description
+ * lists the style constants that are applicable to the class.
+ * Style bits are also inherited from superclasses.
+ * </p>
+ *
+ * @param parent a composite control which will be the parent of the new instance (cannot be null)
+ * @param style the style of control to construct
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
+ * <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
+ * </ul>
+ *
+ * @see SWT#HORIZONTAL
+ * @see SWT#VERTICAL
+ * @see Widget#checkSubclass
+ * @see Widget#getStyle
+ */
+public Sash (Composite parent, int style) {
+ super (parent, checkStyle (style));
+}
+
+/**
+ * Adds the listener to the collection of listeners who will
+ * be notified when the control is selected, by sending
+ * it one of the messages defined in the <code>SelectionListener</code>
+ * interface.
+ * <p>
+ * When <code>widgetSelected</code> is called, the x, y, width, and height fields of the event object are valid.
+ * If the reciever is being dragged, the event object detail field contains the value <code>SWT.DRAG</code>.
+ * <code>widgetDefaultSelected</code> is not called.
+ * </p>
+ *
+ * @param listener the listener which should be notified
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see SelectionListener
+ * @see #removeSelectionListener
+ * @see SelectionEvent
+ */
+public void addSelectionListener (SelectionListener listener) {
+ checkWidget ();
+ if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+ TypedListener typedListener = new TypedListener (listener);
+ addListener (SWT.Selection,typedListener);
+ addListener (SWT.DefaultSelection,typedListener);
+}
+
+int 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);
+}
+
+TCHAR 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;
+ drawBackground (wParam);
+ return LRESULT.ONE;
+}
+
+LRESULT WM_KEYDOWN (int wParam, int lParam) {
+ LRESULT result = super.WM_KEYDOWN (wParam, lParam);
+ if (result != null) return result;
+ switch (wParam) {
+ case OS.VK_LEFT:
+ case OS.VK_RIGHT:
+ case OS.VK_UP:
+ case OS.VK_DOWN:
+
+ /* Calculate the new x or y position */
+ if (OS.GetKeyState (OS.VK_LBUTTON) < 0) return result;
+ int step = OS.GetKeyState (OS.VK_CONTROL) < 0 ? INCREMENT : PAGE_INCREMENT;
+ POINT pt = new POINT ();
+ if ((style & SWT.VERTICAL) != 0) {
+ if (wParam == OS.VK_UP || wParam == OS.VK_DOWN) break;
+ pt.x = wParam == OS.VK_LEFT ? -step : step;
+ } else {
+ if (wParam == OS.VK_LEFT || wParam == OS.VK_RIGHT) break;
+ pt.y = wParam == OS.VK_UP ? -step : step;
+ }
+ 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;
+
+ /* Update the pointer position */
+ POINT cursorPt = new POINT ();
+ cursorPt.x = pt.x; cursorPt.y = pt.y;
+ OS.ClientToScreen (parent.handle, cursorPt);
+ if ((style & SWT.VERTICAL) != 0) {
+ cursorPt.y += height / 2;
+ }
+ else {
+ cursorPt.x += width / 2;
+ }
+ OS.SetCursorPos (cursorPt.x, cursorPt.y);
+
+ /* 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;
+
+ /*
+ * 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;
+ return result;
+ }
+ return result;
+}
+
+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 ();
+ if (OS.IsWinCE) {
+ OS.UpdateWindow (hwndTrack);
+ } else {
+ 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 newX = lastX, newY = lastY;
+ if ((style & SWT.VERTICAL) != 0) {
+ int clientWidth = clientRect.right - clientRect.left;
+ newX = Math.min (Math.max (0, pt.x - startX), clientWidth - width);
+ } else {
+ int clientHeight = clientRect.bottom - clientRect.top;
+ 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;
+ if (OS.IsWinCE) {
+ OS.UpdateWindow (hwndTrack);
+ } else {
+ 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 = 0;
+ 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
index 09b770cead..e3efc29250 100755
--- 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
@@ -1,416 +1,416 @@
-package org.eclipse.swt.widgets;
-
-/*
+package org.eclipse.swt.widgets;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-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>
- * Note: Only one of the styles HORIZONTAL and VERTICAL may be specified.
- * </p><p>
- * <p>
- * IMPORTANT: This class is intended to be subclassed <em>only</em>
- * within the SWT implementation.
- * </p>
- */
-
-public class Scale extends Control {
- static final int TrackBarProc;
- static final TCHAR TrackBarClass = new TCHAR (0, OS.TRACKBAR_CLASS, true);
- static {
- WNDCLASS lpWndClass = new WNDCLASS ();
- OS.GetClassInfo (0, TrackBarClass, lpWndClass);
- TrackBarProc = 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
- * lists the style constants that are applicable to the class.
- * Style bits are also inherited from superclasses.
- * </p>
- *
- * @param parent a composite control which will be the parent of the new instance (cannot be null)
- * @param style the style of control to construct
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
- * <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
- * </ul>
- *
- * @see SWT#HORIZONTAL
- * @see SWT#VERTICAL
- * @see Widget#checkSubclass
- * @see Widget#getStyle
- */
-public Scale (Composite parent, int style) {
- super (parent, checkStyle (style));
-}
-
-/**
- * Adds the listener to the collection of listeners who will
- * be notified when the 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);
-}
-
-void setBackgroundPixel (int pixel) {
- if (background == pixel) return;
- super.setBackgroundPixel (pixel);
- /*
- * Bug in Windows. Changing the background color of the Scale
- * widget and calling InvalidateRect still draws with the old color.
- * The fix is to post a fake WM_SETFOCUS event to cause it to redraw
- * with the new background color.
- *
- * Note. This WM_SETFOCUS message causes recursion when
- * setBackground is called from within the focus event listener.
- */
- OS.PostMessage (handle, OS.WM_SETFOCUS, 0, 0);
-}
-
-/**
- * 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 ();
- 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;
-}
-
-TCHAR 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;
-}
-
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+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>
+ * Note: Only one of the styles HORIZONTAL and VERTICAL may be specified.
+ * </p><p>
+ * <p>
+ * IMPORTANT: This class is intended to be subclassed <em>only</em>
+ * within the SWT implementation.
+ * </p>
+ */
+
+public class Scale extends Control {
+ static final int TrackBarProc;
+ static final TCHAR TrackBarClass = new TCHAR (0, OS.TRACKBAR_CLASS, true);
+ static {
+ WNDCLASS lpWndClass = new WNDCLASS ();
+ OS.GetClassInfo (0, TrackBarClass, lpWndClass);
+ TrackBarProc = 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
+ * lists the style constants that are applicable to the class.
+ * Style bits are also inherited from superclasses.
+ * </p>
+ *
+ * @param parent a composite control which will be the parent of the new instance (cannot be null)
+ * @param style the style of control to construct
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
+ * <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
+ * </ul>
+ *
+ * @see SWT#HORIZONTAL
+ * @see SWT#VERTICAL
+ * @see Widget#checkSubclass
+ * @see Widget#getStyle
+ */
+public Scale (Composite parent, int style) {
+ super (parent, checkStyle (style));
+}
+
+/**
+ * Adds the listener to the collection of listeners who will
+ * be notified when the 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);
+}
+
+void setBackgroundPixel (int pixel) {
+ if (background == pixel) return;
+ super.setBackgroundPixel (pixel);
+ /*
+ * Bug in Windows. Changing the background color of the Scale
+ * widget and calling InvalidateRect still draws with the old color.
+ * The fix is to post a fake WM_SETFOCUS event to cause it to redraw
+ * with the new background color.
+ *
+ * Note. This WM_SETFOCUS message causes recursion when
+ * setBackground is called from within the focus event listener.
+ */
+ OS.PostMessage (handle, OS.WM_SETFOCUS, 0, 0);
+}
+
+/**
+ * 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 ();
+ 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;
+}
+
+TCHAR 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
index a5baa1a81b..aa6e1b0dad 100755
--- 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
@@ -1,1004 +1,1004 @@
-package org.eclipse.swt.widgets;
-
-/*
+package org.eclipse.swt.widgets;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-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 a left facing button for decrementing the value and a
- * right facing button for incrementing it) or <code>VERTICAL</code>
- * (which have an upward facing button for decrementing the value
- * and a downward facing buttons for incrementing it).
- * </p><p>
- * On some platforms, the size of the scroll bar's thumb can be
- * varied relative to the magnitude of the range of values it
- * represents (that is, relative to the difference between its
- * maximum and minimum values). Typically, this is used to
- * indicate some proportional value such as the ratio of the
- * visible area of a document to the total amount of space that
- * it would take to display it. SWT supports setting the thumb
- * size even if the underlying platform does not, but in this
- * case the appearance of the scroll bar will not change.
- * </p><p>
- * Scroll bars are created by specifying either <code>H_SCROLL</code>,
- * <code>V_SCROLL</code> or both when creating a <code>Scrollable</code>.
- * They are accessed from the <code>Scrollable</code> using
- * <code>getHorizontalBar</code> and <code>getVerticalBar</code>.
- * </p><p>
- * Note: Scroll bars are not Controls. On some platforms, scroll bars
- * that appear as part of some standard controls such as a text or list
- * have no operating system resources and are not children of the control.
- * For this reason, scroll bars are treated specially. To create a control
- * that looks like a scroll bar but has operating system resources, use
- * <code>Slider</code>.
- * </p>
- * <dl>
- * <dt><b>Styles:</b></dt>
- * <dd>HORIZONTAL, VERTICAL</dd>
- * <dt><b>Events:</b></dt>
- * <dd>Selection</dd>
- * </dl>
- * <p>
- * Note: Only one of the styles HORIZONTAL and VERTICAL may be specified.
- * </p><p>
- * IMPORTANT: This class is <em>not</em> intended to be subclassed.
- * </p>
- *
- * @see Slider
- * @see Scrollable
- * @see Scrollable#getHorizontalBar
- * @see Scrollable#getVerticalBar
- */
-
-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
- * lists the style constants that are applicable to the class.
- * Style bits are also inherited from superclasses.
- * </p>
- *
- * @param parent a composite control which will be the parent of the new instance (cannot be null)
- * @param style the style of control to construct
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
- * <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
- * </ul>
- *
- * @see SWT#HORIZONTAL
- * @see SWT#VERTICAL
- * @see Widget#checkSubclass
- * @see Widget#getStyle
- */
-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.
- * <p>
- * When <code>widgetSelected</code> is called, the event object detail field contains one of the following values:
- * <code>0</code> - for the end of a drag.
- * <code>SWT.DRAG</code>.
- * <code>SWT.HOME</code>.
- * <code>SWT.END</code>.
- * <code>SWT.ARROW_DOWN</code>.
- * <code>SWT.ARROW_UP</code>.
- * <code>SWT.PAGE_DOWN</code>.
- * <code>SWT.PAGE_UP</code>.
- * <code>widgetDefaultSelected</code> is not called.
- * </p>
- *
- * @param listener the listener which should be notified
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see SelectionListener
- * @see #removeSelectionListener
- * @see SelectionEvent
- */
-public void addSelectionListener (SelectionListener listener) {
- checkWidget();
- if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
- TypedListener typedListener = new TypedListener(listener);
- addListener (SWT.Selection,typedListener);
- addListener (SWT.DefaultSelection,typedListener);
-}
-
-static int checkStyle (int style) {
- return checkBits (style, SWT.HORIZONTAL, SWT.VERTICAL, 0, 0, 0, 0);
-}
-
-void createWidget () {
- increment = 1;
- pageIncrement = 10;
- /*
- * Do not set the intial values of the maximum
- * or the thumb. These values normally default
- * to 100 and 10 but may have been set already
- * by the widget that owns the scroll bar. For
- * example, a scroll bar that is created for a
- * list widget, setting these defaults would
- * override the initial values provided by the
- * list widget.
- */
-}
-
-public void dispose () {
- int hwnd = hwndScrollBar (), type = scrollBarType ();
- super.dispose ();
- if (OS.IsWinCE) {
- SCROLLINFO info = new SCROLLINFO ();
- info.cbSize = SCROLLINFO.sizeof;
- info.fMask = OS.SIF_RANGE | OS.SIF_PAGE;
- info.nPage = 101;
- info.nMax = 100;
- info.nMin = 0;
- OS.SetScrollInfo (hwnd, type, info, true);
- } else {
- 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 receiver's enabled state
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see #isEnabled
- */
-public boolean getEnabled () {
- checkWidget();
- return (state & DISABLED) == 0;
-}
-
-/**
- * Returns the 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;
- 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 () {
- checkWidget();
- 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 () {
- checkWidget();
- 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 () {
- checkWidget();
- 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 () {
- checkWidget();
- 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;
-}
-
-/**
- * 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();
- 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 () {
- checkWidget();
- 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 () {
- checkWidget();
- return (state & HIDDEN) == 0;
-}
-
-int hwndScrollBar () {
- return parent.handle;
-}
-
-/**
- * Returns <code>true</code> if the receiver is enabled and all
- * of the receiver's ancestors are enabled, and <code>false</code>
- * otherwise. A disabled control is typically not selectable from the
- * user interface and draws with an inactive or "grayed" look.
- *
- * @return the receiver's enabled state
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see #getEnabled
- */
-public boolean isEnabled () {
- checkWidget();
- return getEnabled () && parent.isEnabled ();
-}
-
-/**
- * Returns <code>true</code> if the receiver is visible and all
- * of the receiver's ancestors are visible and <code>false</code>
- * otherwise.
- *
- * @return the receiver's visibility state
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see #getVisible
- */
-public boolean isVisible () {
- checkWidget();
- return getVisible () && 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) {
- checkWidget();
- 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) {
- checkWidget();
- /*
- * This line is intentionally commented. Currently
- * always show scrollbar as being enabled and visible.
- */
-// if (OS.IsWinCE) error (SWT.ERROR_NOT_IMPLEMENTED);
- if (!OS.IsWinCE) {
- int hwnd = hwndScrollBar (), type = scrollBarType ();
- int flags = enabled ? OS.ESB_ENABLE_BOTH : OS.ESB_DISABLE_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) {
- 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;
- 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) {
- /*
- * This line is intentionally commented. Currently
- * always show scrollbar as being enabled and visible.
- */
-// if (OS.IsWinCE) error (SWT.ERROR_NOT_IMPLEMENTED);
- if (!OS.IsWinCE) {
- 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) {
- /*
- * This line is intentionally commented. Currently
- * always show scrollbar as being enabled and visible.
- */
-// if (OS.IsWinCE) error (SWT.ERROR_NOT_IMPLEMENTED);
- if (!OS.IsWinCE) {
- 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) {
- checkWidget();
- 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) {
- /*
- * This line is intentionally commented. Currently
- * always show scrollbar as being enabled and visible.
- */
-// if (OS.IsWinCE) error (SWT.ERROR_NOT_IMPLEMENTED);
- if (!OS.IsWinCE) {
- 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) {
- /*
- * This line is intentionally commented. Currently
- * always show scrollbar as being enabled and visible.
- */
-// if (OS.IsWinCE) error (SWT.ERROR_NOT_IMPLEMENTED);
- if (!OS.IsWinCE) {
- 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) {
- 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 selection) {
- checkWidget();
- 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) {
- checkWidget();
-
- /* 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) {
- /*
- * This line is intentionally commented. Currently
- * always show scrollbar as being enabled and visible.
- */
-// if (OS.IsWinCE) error (SWT.ERROR_NOT_IMPLEMENTED);
- if (!OS.IsWinCE) {
- 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) {
- /*
- * This line is intentionally commented. Currently
- * always show scrollbar as being enabled and visible.
- */
-// if (OS.IsWinCE) error (SWT.ERROR_NOT_IMPLEMENTED);
- if (!OS.IsWinCE) {
- 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) {
- checkWidget();
- 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) {
- /*
- * This line is intentionally commented. Currently
- * always show scrollbar as being enabled and visible.
- */
-// if (OS.IsWinCE) error (SWT.ERROR_NOT_IMPLEMENTED);
- if (!OS.IsWinCE) {
- 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) {
- /*
- * This line is intentionally commented. Currently
- * always show scrollbar as being enabled and visible.
- */
-// if (OS.IsWinCE) error (SWT.ERROR_NOT_IMPLEMENTED);
- if (!OS.IsWinCE) {
- 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) {
- checkWidget();
- if (OS.IsWinCE) {
- SCROLLINFO info = new SCROLLINFO ();
- info.cbSize = SCROLLINFO.sizeof;
- int hwnd = hwndScrollBar (), type = scrollBarType ();
- info.fMask = OS.SIF_RANGE | OS.SIF_PAGE;
- if (visible) info.fMask |= OS.SIF_DISABLENOSCROLL;
- OS.GetScrollInfo (hwnd, type, info);
- if (info.nPage == info.nMax - info.nMin + 1) {
- /*
- * Bug in Windows. When the only changed flag to
- * SetScrollInfo () is OS.SIF_DISABLENOSCROLL,
- * Windows does not update the scroll bar state.
- * The fix is to increase and then decrease the
- * maximum, causing Windows to honour the flag.
- */
- int max = info.nMax;
- info.nMax++;
- OS.SetScrollInfo (hwnd, type, info, false);
- info.nMax = max;
- OS.SetScrollInfo (hwnd, type, info, true);
- } else {
- /*
- * This line is intentionally commented. Currently
- * always show scrollbar as being enabled and visible.
- */
-// if (OS.IsWinCE) error (SWT.ERROR_NOT_IMPLEMENTED);
- }
- return;
- }
-
- /*
- * Set the state bits before calling ShowScrollBar ()
- * because hiding and showing the scroll bar can cause
- * WM_SIZE messages when the client area is resized.
- * Setting the state before the call means that code
- * that runs during WM_SIZE that queries the visibility
- * of the scroll bar will get the correct value.
- */
- state &= ~HIDDEN;
- if (!visible) state |= HIDDEN;
- 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 not disabled by the application and the current
- * scroll bar ranges would cause the scroll bar to be
- * enabled had they been set when the scroll bar was
- * visible.
- */
- if ((state & DISABLED) == 0) {
- SCROLLINFO info = new SCROLLINFO ();
- info.cbSize = SCROLLINFO.sizeof;
- info.fMask = OS.SIF_RANGE | OS.SIF_PAGE;
- OS.GetScrollInfo (hwnd, type, info);
- if (info.nMax - info.nMin - info.nPage >= 0) {
- OS.EnableScrollBar (hwnd, type, OS.ESB_ENABLE_BOTH);
- }
- }
- 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;
-}
-
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+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 a left facing button for decrementing the value and a
+ * right facing button for incrementing it) or <code>VERTICAL</code>
+ * (which have an upward facing button for decrementing the value
+ * and a downward facing buttons for incrementing it).
+ * </p><p>
+ * On some platforms, the size of the scroll bar's thumb can be
+ * varied relative to the magnitude of the range of values it
+ * represents (that is, relative to the difference between its
+ * maximum and minimum values). Typically, this is used to
+ * indicate some proportional value such as the ratio of the
+ * visible area of a document to the total amount of space that
+ * it would take to display it. SWT supports setting the thumb
+ * size even if the underlying platform does not, but in this
+ * case the appearance of the scroll bar will not change.
+ * </p><p>
+ * Scroll bars are created by specifying either <code>H_SCROLL</code>,
+ * <code>V_SCROLL</code> or both when creating a <code>Scrollable</code>.
+ * They are accessed from the <code>Scrollable</code> using
+ * <code>getHorizontalBar</code> and <code>getVerticalBar</code>.
+ * </p><p>
+ * Note: Scroll bars are not Controls. On some platforms, scroll bars
+ * that appear as part of some standard controls such as a text or list
+ * have no operating system resources and are not children of the control.
+ * For this reason, scroll bars are treated specially. To create a control
+ * that looks like a scroll bar but has operating system resources, use
+ * <code>Slider</code>.
+ * </p>
+ * <dl>
+ * <dt><b>Styles:</b></dt>
+ * <dd>HORIZONTAL, VERTICAL</dd>
+ * <dt><b>Events:</b></dt>
+ * <dd>Selection</dd>
+ * </dl>
+ * <p>
+ * Note: Only one of the styles HORIZONTAL and VERTICAL may be specified.
+ * </p><p>
+ * IMPORTANT: This class is <em>not</em> intended to be subclassed.
+ * </p>
+ *
+ * @see Slider
+ * @see Scrollable
+ * @see Scrollable#getHorizontalBar
+ * @see Scrollable#getVerticalBar
+ */
+
+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
+ * lists the style constants that are applicable to the class.
+ * Style bits are also inherited from superclasses.
+ * </p>
+ *
+ * @param parent a composite control which will be the parent of the new instance (cannot be null)
+ * @param style the style of control to construct
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
+ * <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
+ * </ul>
+ *
+ * @see SWT#HORIZONTAL
+ * @see SWT#VERTICAL
+ * @see Widget#checkSubclass
+ * @see Widget#getStyle
+ */
+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.
+ * <p>
+ * When <code>widgetSelected</code> is called, the event object detail field contains one of the following values:
+ * <code>0</code> - for the end of a drag.
+ * <code>SWT.DRAG</code>.
+ * <code>SWT.HOME</code>.
+ * <code>SWT.END</code>.
+ * <code>SWT.ARROW_DOWN</code>.
+ * <code>SWT.ARROW_UP</code>.
+ * <code>SWT.PAGE_DOWN</code>.
+ * <code>SWT.PAGE_UP</code>.
+ * <code>widgetDefaultSelected</code> is not called.
+ * </p>
+ *
+ * @param listener the listener which should be notified
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see SelectionListener
+ * @see #removeSelectionListener
+ * @see SelectionEvent
+ */
+public void addSelectionListener (SelectionListener listener) {
+ checkWidget();
+ if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+ TypedListener typedListener = new TypedListener(listener);
+ addListener (SWT.Selection,typedListener);
+ addListener (SWT.DefaultSelection,typedListener);
+}
+
+static int checkStyle (int style) {
+ return checkBits (style, SWT.HORIZONTAL, SWT.VERTICAL, 0, 0, 0, 0);
+}
+
+void createWidget () {
+ increment = 1;
+ pageIncrement = 10;
+ /*
+ * Do not set the intial values of the maximum
+ * or the thumb. These values normally default
+ * to 100 and 10 but may have been set already
+ * by the widget that owns the scroll bar. For
+ * example, a scroll bar that is created for a
+ * list widget, setting these defaults would
+ * override the initial values provided by the
+ * list widget.
+ */
+}
+
+public void dispose () {
+ int hwnd = hwndScrollBar (), type = scrollBarType ();
+ super.dispose ();
+ if (OS.IsWinCE) {
+ SCROLLINFO info = new SCROLLINFO ();
+ info.cbSize = SCROLLINFO.sizeof;
+ info.fMask = OS.SIF_RANGE | OS.SIF_PAGE;
+ info.nPage = 101;
+ info.nMax = 100;
+ info.nMin = 0;
+ OS.SetScrollInfo (hwnd, type, info, true);
+ } else {
+ 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 receiver's enabled state
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see #isEnabled
+ */
+public boolean getEnabled () {
+ checkWidget();
+ return (state & DISABLED) == 0;
+}
+
+/**
+ * Returns the 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;
+ 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 () {
+ checkWidget();
+ 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 () {
+ checkWidget();
+ 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 () {
+ checkWidget();
+ 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 () {
+ checkWidget();
+ 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;
+}
+
+/**
+ * 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();
+ 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 () {
+ checkWidget();
+ 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 () {
+ checkWidget();
+ return (state & HIDDEN) == 0;
+}
+
+int hwndScrollBar () {
+ return parent.handle;
+}
+
+/**
+ * Returns <code>true</code> if the receiver is enabled and all
+ * of the receiver's ancestors are enabled, and <code>false</code>
+ * otherwise. A disabled control is typically not selectable from the
+ * user interface and draws with an inactive or "grayed" look.
+ *
+ * @return the receiver's enabled state
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see #getEnabled
+ */
+public boolean isEnabled () {
+ checkWidget();
+ return getEnabled () && parent.isEnabled ();
+}
+
+/**
+ * Returns <code>true</code> if the receiver is visible and all
+ * of the receiver's ancestors are visible and <code>false</code>
+ * otherwise.
+ *
+ * @return the receiver's visibility state
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see #getVisible
+ */
+public boolean isVisible () {
+ checkWidget();
+ return getVisible () && 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) {
+ checkWidget();
+ 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) {
+ checkWidget();
+ /*
+ * This line is intentionally commented. Currently
+ * always show scrollbar as being enabled and visible.
+ */
+// if (OS.IsWinCE) error (SWT.ERROR_NOT_IMPLEMENTED);
+ if (!OS.IsWinCE) {
+ int hwnd = hwndScrollBar (), type = scrollBarType ();
+ int flags = enabled ? OS.ESB_ENABLE_BOTH : OS.ESB_DISABLE_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) {
+ 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;
+ 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) {
+ /*
+ * This line is intentionally commented. Currently
+ * always show scrollbar as being enabled and visible.
+ */
+// if (OS.IsWinCE) error (SWT.ERROR_NOT_IMPLEMENTED);
+ if (!OS.IsWinCE) {
+ 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) {
+ /*
+ * This line is intentionally commented. Currently
+ * always show scrollbar as being enabled and visible.
+ */
+// if (OS.IsWinCE) error (SWT.ERROR_NOT_IMPLEMENTED);
+ if (!OS.IsWinCE) {
+ 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) {
+ checkWidget();
+ 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) {
+ /*
+ * This line is intentionally commented. Currently
+ * always show scrollbar as being enabled and visible.
+ */
+// if (OS.IsWinCE) error (SWT.ERROR_NOT_IMPLEMENTED);
+ if (!OS.IsWinCE) {
+ 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) {
+ /*
+ * This line is intentionally commented. Currently
+ * always show scrollbar as being enabled and visible.
+ */
+// if (OS.IsWinCE) error (SWT.ERROR_NOT_IMPLEMENTED);
+ if (!OS.IsWinCE) {
+ 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) {
+ 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 selection) {
+ checkWidget();
+ 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) {
+ checkWidget();
+
+ /* 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) {
+ /*
+ * This line is intentionally commented. Currently
+ * always show scrollbar as being enabled and visible.
+ */
+// if (OS.IsWinCE) error (SWT.ERROR_NOT_IMPLEMENTED);
+ if (!OS.IsWinCE) {
+ 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) {
+ /*
+ * This line is intentionally commented. Currently
+ * always show scrollbar as being enabled and visible.
+ */
+// if (OS.IsWinCE) error (SWT.ERROR_NOT_IMPLEMENTED);
+ if (!OS.IsWinCE) {
+ 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) {
+ checkWidget();
+ 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) {
+ /*
+ * This line is intentionally commented. Currently
+ * always show scrollbar as being enabled and visible.
+ */
+// if (OS.IsWinCE) error (SWT.ERROR_NOT_IMPLEMENTED);
+ if (!OS.IsWinCE) {
+ 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) {
+ /*
+ * This line is intentionally commented. Currently
+ * always show scrollbar as being enabled and visible.
+ */
+// if (OS.IsWinCE) error (SWT.ERROR_NOT_IMPLEMENTED);
+ if (!OS.IsWinCE) {
+ 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) {
+ checkWidget();
+ if (OS.IsWinCE) {
+ SCROLLINFO info = new SCROLLINFO ();
+ info.cbSize = SCROLLINFO.sizeof;
+ int hwnd = hwndScrollBar (), type = scrollBarType ();
+ info.fMask = OS.SIF_RANGE | OS.SIF_PAGE;
+ if (visible) info.fMask |= OS.SIF_DISABLENOSCROLL;
+ OS.GetScrollInfo (hwnd, type, info);
+ if (info.nPage == info.nMax - info.nMin + 1) {
+ /*
+ * Bug in Windows. When the only changed flag to
+ * SetScrollInfo () is OS.SIF_DISABLENOSCROLL,
+ * Windows does not update the scroll bar state.
+ * The fix is to increase and then decrease the
+ * maximum, causing Windows to honour the flag.
+ */
+ int max = info.nMax;
+ info.nMax++;
+ OS.SetScrollInfo (hwnd, type, info, false);
+ info.nMax = max;
+ OS.SetScrollInfo (hwnd, type, info, true);
+ } else {
+ /*
+ * This line is intentionally commented. Currently
+ * always show scrollbar as being enabled and visible.
+ */
+// if (OS.IsWinCE) error (SWT.ERROR_NOT_IMPLEMENTED);
+ }
+ return;
+ }
+
+ /*
+ * Set the state bits before calling ShowScrollBar ()
+ * because hiding and showing the scroll bar can cause
+ * WM_SIZE messages when the client area is resized.
+ * Setting the state before the call means that code
+ * that runs during WM_SIZE that queries the visibility
+ * of the scroll bar will get the correct value.
+ */
+ state &= ~HIDDEN;
+ if (!visible) state |= HIDDEN;
+ 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 not disabled by the application and the current
+ * scroll bar ranges would cause the scroll bar to be
+ * enabled had they been set when the scroll bar was
+ * visible.
+ */
+ if ((state & DISABLED) == 0) {
+ SCROLLINFO info = new SCROLLINFO ();
+ info.cbSize = SCROLLINFO.sizeof;
+ info.fMask = OS.SIF_RANGE | OS.SIF_PAGE;
+ OS.GetScrollInfo (hwnd, type, info);
+ if (info.nMax - info.nMin - info.nPage >= 0) {
+ OS.EnableScrollBar (hwnd, type, OS.ESB_ENABLE_BOTH);
+ }
+ }
+ 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
index 00aff6bc5e..b6b542001a 100755
--- 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
@@ -1,379 +1,379 @@
-package org.eclipse.swt.widgets;
-
-/*
+package org.eclipse.swt.widgets;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-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
- * lists the style constants that are applicable to the class.
- * Style bits are also inherited from superclasses.
- * </p>
- *
- * @param parent a composite control which will be the parent of the new instance (cannot be null)
- * @param style the style of control to construct
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
- * <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
- * </ul>
- *
- * @see SWT#H_SCROLL
- * @see SWT#V_SCROLL
- * @see Widget#checkSubclass
- * @see Widget#getStyle
- */
-public Scrollable (Composite parent, int style) {
- super (parent, style);
-}
-
-int 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 ();
- RECT rect = new RECT ();
- OS.SetRect (rect, x, y, x + width, y + height);
- int bits = OS.GetWindowLong (handle, OS.GWL_STYLE);
- OS.AdjustWindowRectEx (rect, bits, false, OS.GetWindowLong (handle, OS.GWL_EXSTYLE));
- if (horizontalBar != null) rect.bottom += OS.GetSystemMetrics (OS.SM_CYHSCROLL);
- if (verticalBar != null) rect.right += OS.GetSystemMetrics (OS.SM_CXVSCROLL);
- int nWidth = rect.right - rect.left, nHeight = rect.bottom - rect.top;
- return new Rectangle (rect.left, rect.top, nWidth, nHeight);
-}
-
-ScrollBar createScrollBar (int type) {
- ScrollBar bar = new ScrollBar (this, type);
- if ((state & CANVAS) != 0) {
- 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 ();
- forceResize ();
- 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.releaseResources ();
- if (verticalBar != null) verticalBar.releaseResources ();
- 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;
-}
-
-TCHAR 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;
-
- /*
- * Bug on WinCE. lParam should be NULL when the message is not sent
- * by a scroll bar control, but it contains the handle to the window.
- * When the message is sent by a scroll bar control, it correctly
- * contains the handle to the scroll bar. The fix is to check for
- * both.
- */
- if ((lParam == 0 || lParam == handle) && horizontalBar != null) {
- return wmScroll (horizontalBar, OS.WM_HSCROLL, wParam, lParam);
- }
- return result;
-}
-
-LRESULT WM_MOUSEWHEEL (int wParam, int lParam) {
- LRESULT result = super.WM_MOUSEWHEEL (wParam, lParam);
- if (result != null) return result;
-
- /*
- * Translate WM_MOUSEWHEEL to WM_VSCROLL or WM_HSCROLL.
- */
- if ((state & CANVAS) != 0) {
- if ((wParam & (OS.MK_SHIFT | OS.MK_CONTROL)) != 0) return result;
- boolean vertical = verticalBar != null && verticalBar.getEnabled ();
- boolean horizontal = horizontalBar != null && horizontalBar.getEnabled ();
- int msg = (vertical) ? OS.WM_VSCROLL : (horizontal) ? OS.WM_HSCROLL : 0;
- if (msg == 0) return result;
- int [] value = new int [1];
- OS.SystemParametersInfo (OS.SPI_GETWHEELSCROLLLINES, 0, value, 0);
- int delta = (short) (wParam >> 16);
- int code = 0, count = 0;
- if (value [0] == OS.WHEEL_PAGESCROLL) {
- code = delta < 0 ? OS.SB_PAGEDOWN : OS.SB_PAGEUP;
- count = 1;
- } else {
- code = delta < 0 ? OS.SB_LINEDOWN : OS.SB_LINEUP;
- delta = Math.abs (delta);
- if (delta < OS.WHEEL_DELTA) return result;
- if (msg == OS.WM_VSCROLL) {
- count = value [0] * delta / OS.WHEEL_DELTA;
- } else {
- count = delta / OS.WHEEL_DELTA;
- }
- }
- for (int i=0; i<count; i++) {
- OS.SendMessage (handle, msg, code, 0);
- }
- return LRESULT.ZERO;
- }
-
- /*
- * When the native widget scrolls inside WM_MOUSEWHEEL, it
- * may or may not send a WM_VSCROLL or WM_HSCROLL to do the
- * actual scrolling. This depends on the implementation of
- * each native widget. In order to ensure that application
- * code is notified when the scroll bar moves, compare the
- * scroll bar position before and after the WM_MOUSEWHEEL.
- * If the native control sends a WM_VSCROLL or WM_HSCROLL,
- * then the application has already been notified. If not
- * explicity send the event.
- */
- int vPosition = verticalBar == null ? 0 : verticalBar.getSelection ();
- int hPosition = horizontalBar == null ? 0 : horizontalBar.getSelection ();
- int code = callWindowProc (OS.WM_MOUSEWHEEL, wParam, lParam);
- if (verticalBar != null) {
- int position = verticalBar.getSelection ();
- if (position != vPosition) {
- Event event = new Event ();
- event.detail = position < vPosition ? SWT.PAGE_UP : SWT.PAGE_DOWN;
- verticalBar.sendEvent (SWT.Selection, event);
- }
- }
- if (horizontalBar != null) {
- int position = horizontalBar.getSelection ();
- if (position != hPosition) {
- Event event = new Event ();
- event.detail = position < hPosition ? SWT.PAGE_UP : SWT.PAGE_DOWN;
- horizontalBar.sendEvent (SWT.Selection, event);
- }
- }
- return new LRESULT (code);
-}
-
-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;
-
- /*
- * Bug on WinCE. lParam should be NULL when the message is not sent
- * by a scroll bar control, but it contains the handle to the window.
- * When the message is sent by a scroll bar control, it correctly
- * contains the handle to the scroll bar. The fix is to check for
- * both.
- */
- if ((lParam == 0 || lParam == handle) && verticalBar != null) {
- return wmScroll (verticalBar, OS.WM_VSCROLL, wParam, lParam);
- }
- return result;
-}
-
-LRESULT wmScroll (ScrollBar bar, int msg, int wParam, int lParam) {
- LRESULT result = null;
- if ((state & CANVAS) != 0) {
- int type = msg == OS.WM_HSCROLL ? OS.SB_HORZ : OS.SB_VERT;
- 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:
- /*
- * Note: On WinCE, the value in SB_THUMBPOSITION is relative to nMin.
- * Same for SB_THUMBPOSITION 'except' for the very first thumb track
- * message which has the actual value of nMin. This is a problem when
- * nMin is not zero.
- */
- 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);
- } else {
- int code = callWindowProc (msg, wParam, lParam);
- result = code == 0 ? LRESULT.ZERO : new LRESULT (code);
- }
- bar.wmScrollChild (wParam, lParam);
- return result;
-}
-
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+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
+ * lists the style constants that are applicable to the class.
+ * Style bits are also inherited from superclasses.
+ * </p>
+ *
+ * @param parent a composite control which will be the parent of the new instance (cannot be null)
+ * @param style the style of control to construct
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
+ * <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
+ * </ul>
+ *
+ * @see SWT#H_SCROLL
+ * @see SWT#V_SCROLL
+ * @see Widget#checkSubclass
+ * @see Widget#getStyle
+ */
+public Scrollable (Composite parent, int style) {
+ super (parent, style);
+}
+
+int 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 ();
+ RECT rect = new RECT ();
+ OS.SetRect (rect, x, y, x + width, y + height);
+ int bits = OS.GetWindowLong (handle, OS.GWL_STYLE);
+ OS.AdjustWindowRectEx (rect, bits, false, OS.GetWindowLong (handle, OS.GWL_EXSTYLE));
+ if (horizontalBar != null) rect.bottom += OS.GetSystemMetrics (OS.SM_CYHSCROLL);
+ if (verticalBar != null) rect.right += OS.GetSystemMetrics (OS.SM_CXVSCROLL);
+ int nWidth = rect.right - rect.left, nHeight = rect.bottom - rect.top;
+ return new Rectangle (rect.left, rect.top, nWidth, nHeight);
+}
+
+ScrollBar createScrollBar (int type) {
+ ScrollBar bar = new ScrollBar (this, type);
+ if ((state & CANVAS) != 0) {
+ 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 ();
+ forceResize ();
+ 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.releaseResources ();
+ if (verticalBar != null) verticalBar.releaseResources ();
+ 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;
+}
+
+TCHAR 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;
+
+ /*
+ * Bug on WinCE. lParam should be NULL when the message is not sent
+ * by a scroll bar control, but it contains the handle to the window.
+ * When the message is sent by a scroll bar control, it correctly
+ * contains the handle to the scroll bar. The fix is to check for
+ * both.
+ */
+ if ((lParam == 0 || lParam == handle) && horizontalBar != null) {
+ return wmScroll (horizontalBar, OS.WM_HSCROLL, wParam, lParam);
+ }
+ return result;
+}
+
+LRESULT WM_MOUSEWHEEL (int wParam, int lParam) {
+ LRESULT result = super.WM_MOUSEWHEEL (wParam, lParam);
+ if (result != null) return result;
+
+ /*
+ * Translate WM_MOUSEWHEEL to WM_VSCROLL or WM_HSCROLL.
+ */
+ if ((state & CANVAS) != 0) {
+ if ((wParam & (OS.MK_SHIFT | OS.MK_CONTROL)) != 0) return result;
+ boolean vertical = verticalBar != null && verticalBar.getEnabled ();
+ boolean horizontal = horizontalBar != null && horizontalBar.getEnabled ();
+ int msg = (vertical) ? OS.WM_VSCROLL : (horizontal) ? OS.WM_HSCROLL : 0;
+ if (msg == 0) return result;
+ int [] value = new int [1];
+ OS.SystemParametersInfo (OS.SPI_GETWHEELSCROLLLINES, 0, value, 0);
+ int delta = (short) (wParam >> 16);
+ int code = 0, count = 0;
+ if (value [0] == OS.WHEEL_PAGESCROLL) {
+ code = delta < 0 ? OS.SB_PAGEDOWN : OS.SB_PAGEUP;
+ count = 1;
+ } else {
+ code = delta < 0 ? OS.SB_LINEDOWN : OS.SB_LINEUP;
+ delta = Math.abs (delta);
+ if (delta < OS.WHEEL_DELTA) return result;
+ if (msg == OS.WM_VSCROLL) {
+ count = value [0] * delta / OS.WHEEL_DELTA;
+ } else {
+ count = delta / OS.WHEEL_DELTA;
+ }
+ }
+ for (int i=0; i<count; i++) {
+ OS.SendMessage (handle, msg, code, 0);
+ }
+ return LRESULT.ZERO;
+ }
+
+ /*
+ * When the native widget scrolls inside WM_MOUSEWHEEL, it
+ * may or may not send a WM_VSCROLL or WM_HSCROLL to do the
+ * actual scrolling. This depends on the implementation of
+ * each native widget. In order to ensure that application
+ * code is notified when the scroll bar moves, compare the
+ * scroll bar position before and after the WM_MOUSEWHEEL.
+ * If the native control sends a WM_VSCROLL or WM_HSCROLL,
+ * then the application has already been notified. If not
+ * explicity send the event.
+ */
+ int vPosition = verticalBar == null ? 0 : verticalBar.getSelection ();
+ int hPosition = horizontalBar == null ? 0 : horizontalBar.getSelection ();
+ int code = callWindowProc (OS.WM_MOUSEWHEEL, wParam, lParam);
+ if (verticalBar != null) {
+ int position = verticalBar.getSelection ();
+ if (position != vPosition) {
+ Event event = new Event ();
+ event.detail = position < vPosition ? SWT.PAGE_UP : SWT.PAGE_DOWN;
+ verticalBar.sendEvent (SWT.Selection, event);
+ }
+ }
+ if (horizontalBar != null) {
+ int position = horizontalBar.getSelection ();
+ if (position != hPosition) {
+ Event event = new Event ();
+ event.detail = position < hPosition ? SWT.PAGE_UP : SWT.PAGE_DOWN;
+ horizontalBar.sendEvent (SWT.Selection, event);
+ }
+ }
+ return new LRESULT (code);
+}
+
+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;
+
+ /*
+ * Bug on WinCE. lParam should be NULL when the message is not sent
+ * by a scroll bar control, but it contains the handle to the window.
+ * When the message is sent by a scroll bar control, it correctly
+ * contains the handle to the scroll bar. The fix is to check for
+ * both.
+ */
+ if ((lParam == 0 || lParam == handle) && verticalBar != null) {
+ return wmScroll (verticalBar, OS.WM_VSCROLL, wParam, lParam);
+ }
+ return result;
+}
+
+LRESULT wmScroll (ScrollBar bar, int msg, int wParam, int lParam) {
+ LRESULT result = null;
+ if ((state & CANVAS) != 0) {
+ int type = msg == OS.WM_HSCROLL ? OS.SB_HORZ : OS.SB_VERT;
+ 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:
+ /*
+ * Note: On WinCE, the value in SB_THUMBPOSITION is relative to nMin.
+ * Same for SB_THUMBPOSITION 'except' for the very first thumb track
+ * message which has the actual value of nMin. This is a problem when
+ * nMin is not zero.
+ */
+ 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);
+ } else {
+ int code = callWindowProc (msg, wParam, lParam);
+ result = code == 0 ? LRESULT.ZERO : new LRESULT (code);
+ }
+ bar.wmScrollChild (wParam, lParam);
+ return result;
+}
+
+}
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
index 358a1e033c..6341d5eeb6 100755
--- 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
@@ -1,1362 +1,1362 @@
-package org.eclipse.swt.widgets;
-
-/*
+package org.eclipse.swt.widgets;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-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 that do not have a parent (that is, they
- * are built using the constructor, which takes a
- * <code>Display</code> as the argument) are described
- * as <em>top level</em> shells. Instances that do have
- * a parent are described as <em>secondary</em> or
- * <em>dialog</em> shells.
- * <p>
- * Instances are always displayed in one of the maximized,
- * minimized or normal states:
- * <ul>
- * <li>
- * When an instance is marked as <em>maximized</em>, the
- * window manager will typically resize it to fill the
- * entire visible area of the display, and the instance
- * is usually put in a state where it can not be resized
- * (even if it has style <code>RESIZE</code>) until it is
- * no longer maximized.
- * </li><li>
- * When an instance is in the <em>normal</em> state (neither
- * maximized or minimized), its appearance is controlled by
- * the style constants which were specified when it was created
- * and the restrictions of the window manager (see below).
- * </li><li>
- * When an instance has been marked as <em>minimized</em>,
- * its contents (client area) will usually not be visible,
- * and depending on the window manager, it may be
- * "iconified" (that is, replaced on the desktop by a small
- * simplified representation of itself), relocated to a
- * distinguished area of the screen, or hidden. Combinations
- * of these changes are also possible.
- * </li>
- * </ul>
- * </p>
- * <p>
- * 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
- * and modality. For example, some window managers only
- * support resizable windows and will always assume the
- * RESIZE style, even if it is not set. In addition, if a
- * modality style is not supported, it is "upgraded" to a
- * more restrictive modality style that is supported. For
- * example, if <code>PRIMARY_MODAL</code> is not supported,
- * it would be upgraded to <code>APPLICATION_MODAL</code>.
- * <dl>
- * <dt><b>Styles:</b></dt>
- * <dd>BORDER, CLOSE, MIN, MAX, NO_TRIM, RESIZE, TITLE</dd>
- * <dd>APPLICATION_MODAL, MODELESS, PRIMARY_MODAL, SYSTEM_MODAL</dd>
- * <dt><b>Events:</b></dt>
- * <dd>Activate, Close, Deactivate, Deiconify, Iconify</dd>
- * </dl>
- * Class <code>SWT</code> provides two "convenience constants"
- * for the most commonly required style combinations:
- * <dl>
- * <dt><code>SHELL_TRIM</code></dt>
- * <dd>
- * the result of combining the constants which are required
- * to produce a typical application top level shell: (that
- * is, <code>CLOSE | TITLE | MIN | MAX | RESIZE</code>)
- * </dd>
- * <dt><code>DIALOG_TRIM</code></dt>
- * <dd>
- * the result of combining the constants which are required
- * to produce a typical application dialog shell: (that
- * is, <code>TITLE | CLOSE | BORDER</code>)
- * </dd>
- * </dl>
- * </p>
- * <p>
- * Note: Only one of the styles APPLICATION_MODAL, MODELESS,
- * PRIMARY_MODAL and SYSTEM_MODAL may be specified.
- * </p><p>
- * IMPORTANT: This class is not intended to be subclassed.
- * </p>
- *
- * @see Decorations
- * @see SWT
- */
-public class Shell extends Decorations {
- Display display;
- Menu activeMenu;
- int hIMC;
- int [] brushes;
- boolean showWithParent;
- int toolTipHandle, lpstrTip;
- Control lastActive;
- SHACTIVATEINFO psai;
- static final int DialogProc;
- static final TCHAR DialogClass = new TCHAR (0, OS.IsWinCE ? "Dialog" : "#32770", true);
- static {
- WNDCLASS lpWndClass = new WNDCLASS ();
- OS.GetClassInfo (0, DialogClass, lpWndClass);
- DialogProc = lpWndClass.lpfnWndProc;
- }
-
-/**
- * Constructs a new instance of this class. This is equivalent
- * to calling <code>Shell((Display) null)</code>.
- *
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
- * <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
- * </ul>
- */
-public Shell () {
- this ((Display) null);
-}
-
-/**
- * Constructs a new instance of this class given only the style
- * value describing its behavior and appearance. This is equivalent
- * to calling <code>Shell((Display) null, style)</code>.
- * <p>
- * The style value is either one of the style constants defined in
- * class <code>SWT</code> which is applicable to instances of this
- * class, or must be built by <em>bitwise OR</em>'ing together
- * (that is, using the <code>int</code> "|" operator) two or more
- * of those <code>SWT</code> style constants. The class description
- * lists the style constants that are applicable to the class.
- * Style bits are also inherited from superclasses.
- * </p>
- *
- * @param style the style of control to construct
- *
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
- * <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
- * </ul>
- *
- * @see SWT#BORDER
- * @see SWT#CLOSE
- * @see SWT#MIN
- * @see SWT#MAX
- * @see SWT#RESIZE
- * @see SWT#TITLE
- * @see SWT#NO_TRIM
- * @see SWT#SHELL_TRIM
- * @see SWT#DIALOG_TRIM
- * @see SWT#MODELESS
- * @see SWT#PRIMARY_MODAL
- * @see SWT#APPLICATION_MODAL
- * @see SWT#SYSTEM_MODAL
- */
-public Shell (int style) {
- this ((Display) null, style);
-}
-
-/**
- * Constructs a new instance of this class given only the display
- * to create it on. It is created with style <code>SWT.SHELL_TRIM</code>.
- * <p>
- * Note: Currently, null can be passed in for the display argument.
- * This has the effect of creating the shell on the currently active
- * display if there is one. If there is no current display, the
- * shell is created on a "default" display. <b>Passing in null as
- * the display argument is not considered to be good coding style,
- * and may not be supported in a future release of SWT.</b>
- * </p>
- *
- * @param display the display to create the shell on
- *
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
- * <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
- * </ul>
- */
-public Shell (Display display) {
- this (display, OS.IsWinCE ? SWT.NONE : SWT.SHELL_TRIM);
-}
-
-/**
- * Constructs a new instance of this class given the display
- * to create it on and a style value describing its behavior
- * and appearance.
- * <p>
- * The style value is either one of the style constants defined in
- * class <code>SWT</code> which is applicable to instances of this
- * class, or must be built by <em>bitwise OR</em>'ing together
- * (that is, using the <code>int</code> "|" operator) two or more
- * of those <code>SWT</code> style constants. The class description
- * lists the style constants that are applicable to the class.
- * Style bits are also inherited from superclasses.
- * </p><p>
- * Note: Currently, null can be passed in for the display argument.
- * This has the effect of creating the shell on the currently active
- * display if there is one. If there is no current display, the
- * shell is created on a "default" display. <b>Passing in null as
- * the display argument is not considered to be good coding style,
- * and may not be supported in a future release of SWT.</b>
- * </p>
- *
- * @param display the display to create the shell on
- * @param style the style of control to construct
- *
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
- * <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
- * </ul>
- *
- * @see SWT#BORDER
- * @see SWT#CLOSE
- * @see SWT#MIN
- * @see SWT#MAX
- * @see SWT#RESIZE
- * @see SWT#TITLE
- * @see SWT#NO_TRIM
- * @see SWT#SHELL_TRIM
- * @see SWT#DIALOG_TRIM
- * @see SWT#MODELESS
- * @see SWT#PRIMARY_MODAL
- * @see SWT#APPLICATION_MODAL
- * @see SWT#SYSTEM_MODAL
- */
-public Shell (Display display, int style) {
- this (display, null, style, 0);
-}
-
-Shell (Display display, Shell parent, int style, int handle) {
- super ();
- checkSubclass ();
- 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, OS.IsWinCE ? SWT.NONE : SWT.DIALOG_TRIM);
-}
-
-/**
- * Constructs a new instance of this class given its parent
- * and a style value describing its behavior and appearance.
- * <p>
- * The style value is either one of the style constants defined in
- * class <code>SWT</code> which is applicable to instances of this
- * class, or must be built by <em>bitwise OR</em>'ing together
- * (that is, using the <code>int</code> "|" operator) two or more
- * of those <code>SWT</code> style constants. The class description
- * lists the style constants that are applicable to the class.
- * Style bits are also inherited from superclasses.
- * </p><p>
- * Note: Currently, null can be passed in for the parent.
- * This has the effect of creating the shell on the currently active
- * display if there is one. If there is no current display, the
- * shell is created on a "default" display. <b>Passing in null as
- * the parent is not considered to be good coding style,
- * and may not be supported in a future release of SWT.</b>
- * </p>
- *
- * @param parent a shell which will be the parent of the new instance
- * @param style the style of control to construct
- *
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
- * <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
- * </ul>
- *
- * @see SWT#BORDER
- * @see SWT#CLOSE
- * @see SWT#MIN
- * @see SWT#MAX
- * @see SWT#RESIZE
- * @see SWT#TITLE
- * @see SWT#NO_TRIM
- * @see SWT#SHELL_TRIM
- * @see SWT#DIALOG_TRIM
- * @see SWT#MODELESS
- * @see SWT#PRIMARY_MODAL
- * @see SWT#APPLICATION_MODAL
- * @see SWT#SYSTEM_MODAL
- */
-public Shell (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);
-}
-
-int callWindowProc (int msg, int wParam, int lParam) {
- if (parent != null) {
- if (handle == 0) return 0;
- switch (msg) {
- case OS.WM_KILLFOCUS:
- case OS.WM_SETFOCUS:
- return OS.DefWindowProc (handle, msg, wParam, lParam);
- }
- return OS.CallWindowProc (DialogProc, handle, msg, wParam, lParam);
- }
- return super.callWindowProc (msg, wParam, lParam);
-}
-
-/**
- * Requests that the window manager close the receiver in
- * the same way it would be closed when the user clicks on
- * the "close box" or performs some other platform specific
- * key or mouse combination that indicates the window
- * should be removed.
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see #dispose
- */
-public void close () {
- checkWidget ();
- OS.PostMessage (handle, OS.WM_CLOSE, 0, 0);
-}
-
-void createHandle () {
- boolean embedded = handle != 0;
-
- /*
- * On Windows 98 and NT, setting a window to be the
- * top most window using HWND_TOPMOST can result in a
- * parent dialog shell being moved behind its parent
- * if the dialog has a sibling that is currently on top
- * This only occurs using SetWindowPos (), not when the
- * handle is created.
- */
- /*
- * The following code is intentionally commented.
- */
-// if ((style & SWT.ON_TOP) != 0) display.lockActiveWindow = true;
- super.createHandle ();
- /*
- * The following code is intentionally commented.
- */
-// if ((style & SWT.ON_TOP) != 0) display.lockActiveWindow = false;
-
- if (!embedded) {
- int bits = OS.GetWindowLong (handle, OS.GWL_STYLE);
- bits &= ~(OS.WS_OVERLAPPED | OS.WS_CAPTION);
- if (!OS.IsWinCE) bits |= OS.WS_POPUP;
- if ((style & SWT.TITLE) != 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 (OS.IsWinCE) setMaximized (true);
- if (OS.IsPPC) {
- psai = new SHACTIVATEINFO ();
- psai.cbSize = SHACTIVATEINFO.sizeof;
- }
- }
- if (OS.IsDBLocale) {
- hIMC = OS.ImmCreateContext ();
- if (hIMC != 0) OS.ImmAssociateContext (handle, hIMC);
- }
-}
-
-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;
-}
-
-/**
- * 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) and forces the window
- * manager to make the shell active.
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @since 2.0
- * @see Control#moveAbove
- * @see Control#setFocus
- * @see Control#setVisible
- * @see Display#getActiveShell
- * @see Decorations#setDefaultButton
- * @see Shell#open
- * @see Shell#setActive
- */
-public void forceActive () {
- checkWidget ();
- OS.SetForegroundWindow (handle);
-}
-
-void forceResize () {
- /* Do nothing */
-}
-
-public Rectangle getBounds () {
- checkWidget ();
- if (!OS.IsWinCE) {
- 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 ();
- 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 (!OS.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.IsWinCE) {
- 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)
- * and asks the window manager to make the shell active.
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see Control#moveAbove
- * @see Control#setFocus
- * @see Control#setVisible
- * @see Display#getActiveShell
- * @see Decorations#setDefaultButton
- * @see Shell#setActive
- * @see Shell#forceActive
- */
-public void open () {
- checkWidget ();
- bringToTop ();
- /*
- * Feature on WinCE PPC. A new application becomes
- * the foreground application only if it has at least
- * one visible window before the event loop is started.
- * The workaround is to explicitely force the shell to
- * be the foreground window.
- */
- if (OS.IsWinCE) OS.SetForegroundWindow (handle);
- OS.SendMessage (handle, OS.WM_CHANGEUISTATE, OS.UIS_INITIALIZE, 0);
- setVisible (true);
- /*
- * Bug in Windows XP. Despite the fact that an icon has been
- * set for a window, the task bar displays the wrong icon the
- * first time the window is made visible with ShowWindow() after
- * a call to BringToTop(), when a long time elapses between the
- * ShowWindow() and the time the event queue is read. The icon
- * in the window trimming is correct but the one in the task
- * bar does not get updated until a new icon is set into the
- * window or the window text is changed. The fix is to call
- * PeekMessage() with the flag PM_NOREMOVE to touch the event
- * queue but not dispatch events.
- */
- MSG msg = new MSG ();
- OS.PeekMessage (msg, 0, 0, 0, OS.PM_NOREMOVE);
- if (!restoreFocus ()) traverseGroup (true);
-}
-
-void releaseShells () {
- Shell [] shells = getShells ();
- for (int i=0; i<shells.length; i++) {
- Shell shell = shells [i];
- if (!shell.isDisposed ()) shell.releaseResources ();
- }
-}
-
-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 (OS.IsDBLocale) {
- if (hIMC != 0) OS.ImmDestroyContext (hIMC);
- }
- lastActive = null;
-}
-
-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;
-}
-
-/**
- * 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) and asks the window
- * manager to make the shell active.
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @since 2.0
- * @see Control#moveAbove
- * @see Control#setFocus
- * @see Control#setVisible
- * @see Display#getActiveShell
- * @see Decorations#setDefaultButton
- * @see Shell#open
- * @see Shell#setActive
- */
-public void setActive () {
- checkWidget ();
- bringToTop ();
-}
-
-void setActiveControl (Control control) {
- if (control != null && control.isDisposed ()) control = null;
- if (lastActive != null && lastActive.isDisposed ()) lastActive = null;
- if (lastActive == control) return;
-
- /*
- * Compute the list of controls to be activated and
- * deactivated by finding the first common parent
- * control.
- */
- Control [] activate = (control == null) ? new Control [0] : control.getPath ();
- Control [] deactivate = (lastActive == null) ? new Control [0] : lastActive.getPath ();
- lastActive = control;
- int index = 0, length = Math.min (activate.length, deactivate.length);
- while (index < length) {
- if (activate [index] != deactivate [index]) break;
- index++;
- }
-
- /*
- * It is possible (but unlikely), that application
- * code could have destroyed some of the widgets. If
- * this happens, keep processing those widgets that
- * are not disposed.
- */
- for (int i=deactivate.length-1; i>=index; --i) {
- if (!deactivate [i].isDisposed ()) {
- deactivate [i].sendEvent (SWT.Deactivate);
- }
- }
- for (int i=activate.length-1; i>=index; --i) {
- if (!activate [i].isDisposed ()) {
- activate [i].sendEvent (SWT.Activate);
- }
- }
-}
-
-void setBounds (int x, int y, int width, int height, int flags) {
- if (OS.IsWinCE) {
- swFlags = OS.SW_RESTORE;
- if ((style & SWT.NO_TRIM) == 0) {
- /* Set the WS_CAPTION bits when no longer maximized */
- int bits = OS.GetWindowLong (handle, OS.GWL_STYLE);
- if ((bits & OS.WS_CAPTION) != OS.WS_CAPTION) {
- bits |= OS.WS_CAPTION;
- OS.SetWindowLong (handle, OS.GWL_STYLE, bits);
- }
- }
- } else {
- if (OS.IsIconic (handle) || OS.IsZoomed (handle)) {
- setPlacement (x, y, width, height, flags);
- return;
- }
- }
- OS.SetWindowPos (handle, 0, x, y, width, height, flags);
-}
-
-public void setEnabled (boolean enabled) {
- checkWidget ();
- state &= ~DISABLED;
- if (!enabled) state |= DISABLED;
- if (!Display.TrimEnabled) {
- super.setEnabled (enabled);
- } else {
- 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 (!OS.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 (OS.IsWinCE) return;
- if (toolTipHandle == 0) {
- toolTipHandle = OS.CreateWindowEx (
- 0,
- new TCHAR (0, OS.TOOLTIPS_CLASS, true),
- 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);
- /*
- * Feature in Windows. Despite the fact that the
- * tool tip text contains \r\n, the tooltip will
- * not honour the new line unless TTM_SETMAXTIPWIDTH
- * is set. The fix is to set TTM_SETMAXTIPWIDTH to
- * a large value.
- */
- OS.SendMessage (toolTipHandle, OS.TTM_SETMAXTIPWIDTH, 0, 0x7FFF);
- }
- 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);
- }
- OS.SendMessage (toolTipHandle, OS.TTM_UPDATE, 0, 0);
-}
-
-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);
- int byteCount = buffer.length;
- lpstrTip = OS.HeapAlloc (hHeap, OS.HEAP_ZERO_MEMORY, byteCount);
- OS.MoveMemory (lpstrTip, buffer, byteCount);
- 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);
- int byteCount = buffer.length * 2;
- lpstrTip = OS.HeapAlloc (hHeap, OS.HEAP_ZERO_MEMORY, byteCount);
- OS.MoveMemory (lpstrTip, buffer, byteCount);
- lpnmtdi.lpszText = lpstrTip;
-}
-
-public void setVisible (boolean visible) {
- checkWidget ();
- super.setVisible (visible);
- if (showWithParent == visible) return;
- showWithParent = visible;
- if (!OS.IsWinCE) OS.ShowOwnedPopups (handle, visible);
- int mask = SWT.PRIMARY_MODAL | SWT.APPLICATION_MODAL | SWT.SYSTEM_MODAL;
- if ((style & mask) != 0) {
- if (visible) {
- display.setModalShell (this);
- Control control = display.getFocusControl ();
- if (control != null && !control.isActive ()) bringToTop ();
- int hwndShell = OS.GetActiveWindow ();
- if (hwndShell == 0) {
- if (parent != null) hwndShell = parent.handle;
- }
- if (hwndShell != 0) {
- OS.SendMessage (hwndShell, OS.WM_CANCELMODE, 0, 0);
- }
- OS.ReleaseCapture ();
- } else {
- display.clearModal (this);
- }
- } else {
- updateModal ();
- }
-}
-
-boolean traverseEscape () {
- if (parent == null) return false;
- if (!isVisible () || !isEnabled ()) return false;
- close ();
- return true;
-}
-
-void updateModal () {
- if (!Display.TrimEnabled) {
- super.setEnabled (isActive ());
- } else {
- setItemEnabled (OS.SC_CLOSE, isActive ());
- }
-}
-
-int widgetExtStyle () {
- int bits = super.widgetExtStyle ();
- /*
- * Bug in Windows 98 and NT. Creating a window with the
- * WS_EX_TOPMOST extendes style can result in a dialog shell
- * being moved behind its parent. The exact case where this
- * happens is a shell with two dialog shell children where
- * each dialog child has another hidden dialog child with
- * the WS_EX_TOPMOST extended style. Clicking on either of
- * the visible dialog causes them to become active but move
- * to the back, behind the parent shell. The fix is to
- * disallow the WS_EX_TOPMOST extended style on Windows 98
- * and NT.
- */
- if (OS.IsWin95) return bits;
- if ((OS.WIN32_MAJOR << 16 | OS.WIN32_MINOR) < (4 << 16 | 10)) {
- return bits;
- }
- if ((style & SWT.ON_TOP) != 0) bits |= OS.WS_EX_TOPMOST;
- return bits;
-}
-
-TCHAR windowClass () {
- if (OS.IsSP) return DialogClass;
- return parent != null ? DialogClass : super.windowClass ();
-}
-
-int windowProc () {
- if (OS.IsSP) return DialogProc;
- return parent != null ? DialogProc : super.windowProc ();
-}
-
-int widgetStyle () {
- int bits = super.widgetStyle () & ~OS.WS_POPUP;
- if (handle != 0) return bits | OS.WS_CHILD;
- bits &= ~OS.WS_CHILD;
- /*
- * Feature in WinCE. Calling CreateWindowEx () with WS_OVERLAPPED
- * and a parent window causes the new window to become a WS_CHILD of
- * the parent instead of a dialog child. The fix is to use WS_POPUP
- * for a window with a parent.
- *
- * Feature in WinCE PPC. A window without a parent with WS_POPUP
- * always shows on top of the Pocket PC 'Today Screen'. The fix
- * is to not set WS_POPUP for a window without a parent on WinCE
- * devices.
- *
- * NOTE: WS_POPUP causes CreateWindowEx () to ignore CW_USEDEFAULT
- * and causes the default window location and size to be zero.
- */
- if (OS.IsWinCE) {
- if (OS.IsSP) return bits | OS.WS_POPUP;
- return parent == null ? bits : bits | OS.WS_POPUP;
- }
-
- /*
- * Use WS_OVERLAPPED for all windows, either dialog or top level
- * so that CreateWindowEx () will respect CW_USEDEFAULT and set
- * the default window location and size.
- *
- * NOTE: When a WS_OVERLAPPED window is created, Windows gives
- * the new window WS_CAPTION style bits. These two constants are
- * as follows:
- *
- * WS_OVERLAPPED = 0
- * WS_CAPTION = WS_BORDER | WS_DLGFRAME
- *
- */
- return bits | OS.WS_OVERLAPPED | OS.WS_CAPTION;
-}
-
-LRESULT WM_ACTIVATE (int wParam, int lParam) {
- if (OS.IsPPC) {
- /*
- * Note: this does not work when we get WM_ACTIVATE prior
- * to adding a listener.
- */
- if (hooks (SWT.HardKeyDown) || hooks (SWT.HardKeyUp)) {
- int fActive = wParam & 0xFFFF;
- int hwnd = fActive != 0 ? handle : 0;
- for (int bVk=OS.VK_APP1; bVk<=OS.VK_APP6; bVk++) {
- OS.SHSetAppKeyWndAssoc ((byte) bVk, hwnd);
- }
- }
- /* Restore SIP state when window is activated */
- if ((wParam & 0xFFFF) != 0) {
- OS.SHSipPreference (handle, psai.fSipUp == 0 ? OS.SIP_DOWN : OS.SIP_UP);
- }
- }
- /*
- * Bug in Windows XP. When a Shell is deactivated, the
- * IME composition window does not go away. This causes
- * repaint issues. The fix is to close the IME ourselves
- * when the Shell is deactivated.
- *
- * Note. When the Shell is reactivated, the text in the
- * composition window has been lost.
- */
- if ((OS.WIN32_MAJOR << 16 | OS.WIN32_MINOR) >= (5 << 16 | 1)) {
- if ((wParam & 0xFFFF) == 0 && OS.IsDBLocale && hIMC != 0) {
- OS.ImmSetOpenStatus (hIMC, false);
- }
- }
-
- LRESULT result = super.WM_ACTIVATE (wParam, lParam);
- if (parent != null) return LRESULT.ZERO;
- return result;
-}
-
-LRESULT WM_CLOSE (int wParam, int lParam) {
- if ((Display.TrimEnabled && !isEnabled ()) || !isActive ()) {
- return LRESULT.ZERO;
- }
- return super.WM_CLOSE (wParam, lParam);
-}
-
-LRESULT WM_COMMAND (int wParam, int lParam) {
- if (OS.IsPPC) {
- /*
- * Note in WinCE PPC: Close the Shell when the "Done Button" has
- * been pressed. lParam is either 0 (PocketPC 2002) or the handle
- * to the Shell (PocketPC).
- */
- int loWord = wParam & 0xFFFF;
- if (loWord == OS.IDOK && (lParam == 0 || lParam == handle)) {
- OS.PostMessage (handle, OS.WM_CLOSE, 0, 0);
- return LRESULT.ZERO;
- }
- }
- /*
- * Note in WinCE PPC. Menu events originate from the command bar.
- */
- if (OS.IsPPC || OS.IsSP) {
- if (menuBar != null) {
- int hwndCB = menuBar.hwndCB;
- if (hwndCB != 0 && lParam == hwndCB) {
- return super.WM_COMMAND (wParam, 0);
- }
- }
- }
- return super.WM_COMMAND (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 ();
- releaseResources ();
- }
- 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;
- /*
- * Get the current location of the cursor,
- * not the location of the cursor when the
- * WM_MOUSEACTIVATE was generated. This is
- * strictly incorrect but is necessary in
- * order to support Activate and Deactivate
- * events for embedded widgets that have
- * their own event loop. In that case, the
- * cursor location reported by GetMessagePos
- * is the one for our event loop, not the
- * embedded widget's event loop.
- */
- POINT pt = new POINT ();
- if (!OS.GetCursorPos (pt)) {
- 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 = display.findControl (hwnd);
- setActiveControl (control);
- /*
- * 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 null;
-}
-
-LRESULT WM_NCHITTEST (int wParam, int lParam) {
- if (!OS.IsWindowEnabled (handle)) return null;
- 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 ()) {
- int hwndModal = modalShell.handle;
- if (OS.IsWindowEnabled (hwndModal)) {
- OS.SetActiveWindow (hwndModal);
- }
- }
- }
- if (!OS.IsWindowEnabled (handle)) {
- if (!OS.IsWinCE) {
- int hwndPopup = OS.GetLastActivePopup (handle);
- if (hwndPopup != 0 && hwndPopup != handle) {
- if (WidgetTable.get (hwndPopup) == null) {
- if (OS.IsWindowEnabled (hwndPopup)) {
- OS.SetActiveWindow (hwndPopup);
- }
- }
- }
- }
- }
- }
- return super.WM_SETCURSOR (wParam, lParam);
-}
-
-LRESULT WM_SETTINGCHANGE (int wParam, int lParam) {
- LRESULT result = super.WM_SETTINGCHANGE (wParam, lParam);
- if (result != null) return result;
- if (OS.IsPPC) {
- if (wParam == OS.SPI_SETSIPINFO) {
- /*
- * The SIP is in a new state. Cache its new value. * Resize the Shell if it has the style SWT.RESIZE.
- * Note that SHHandleWMSettingChange resizes the
- * Shell and also updates the cached state.
- */
- if ((style & SWT.RESIZE) != 0) {
- OS.SHHandleWMSettingChange (handle, wParam, lParam, psai);
- return LRESULT.ZERO;
- } else {
- SIPINFO pSipInfo = new SIPINFO ();
- pSipInfo.cbSize = SIPINFO.sizeof;
- OS.SipGetInfo (pSipInfo);
- psai.fSipUp = pSipInfo.fdwFlags & OS.SIPF_ON;
- }
- }
- }
- return result;
-}
-
-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;
-}
-
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+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 that do not have a parent (that is, they
+ * are built using the constructor, which takes a
+ * <code>Display</code> as the argument) are described
+ * as <em>top level</em> shells. Instances that do have
+ * a parent are described as <em>secondary</em> or
+ * <em>dialog</em> shells.
+ * <p>
+ * Instances are always displayed in one of the maximized,
+ * minimized or normal states:
+ * <ul>
+ * <li>
+ * When an instance is marked as <em>maximized</em>, the
+ * window manager will typically resize it to fill the
+ * entire visible area of the display, and the instance
+ * is usually put in a state where it can not be resized
+ * (even if it has style <code>RESIZE</code>) until it is
+ * no longer maximized.
+ * </li><li>
+ * When an instance is in the <em>normal</em> state (neither
+ * maximized or minimized), its appearance is controlled by
+ * the style constants which were specified when it was created
+ * and the restrictions of the window manager (see below).
+ * </li><li>
+ * When an instance has been marked as <em>minimized</em>,
+ * its contents (client area) will usually not be visible,
+ * and depending on the window manager, it may be
+ * "iconified" (that is, replaced on the desktop by a small
+ * simplified representation of itself), relocated to a
+ * distinguished area of the screen, or hidden. Combinations
+ * of these changes are also possible.
+ * </li>
+ * </ul>
+ * </p>
+ * <p>
+ * 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
+ * and modality. For example, some window managers only
+ * support resizable windows and will always assume the
+ * RESIZE style, even if it is not set. In addition, if a
+ * modality style is not supported, it is "upgraded" to a
+ * more restrictive modality style that is supported. For
+ * example, if <code>PRIMARY_MODAL</code> is not supported,
+ * it would be upgraded to <code>APPLICATION_MODAL</code>.
+ * <dl>
+ * <dt><b>Styles:</b></dt>
+ * <dd>BORDER, CLOSE, MIN, MAX, NO_TRIM, RESIZE, TITLE</dd>
+ * <dd>APPLICATION_MODAL, MODELESS, PRIMARY_MODAL, SYSTEM_MODAL</dd>
+ * <dt><b>Events:</b></dt>
+ * <dd>Activate, Close, Deactivate, Deiconify, Iconify</dd>
+ * </dl>
+ * Class <code>SWT</code> provides two "convenience constants"
+ * for the most commonly required style combinations:
+ * <dl>
+ * <dt><code>SHELL_TRIM</code></dt>
+ * <dd>
+ * the result of combining the constants which are required
+ * to produce a typical application top level shell: (that
+ * is, <code>CLOSE | TITLE | MIN | MAX | RESIZE</code>)
+ * </dd>
+ * <dt><code>DIALOG_TRIM</code></dt>
+ * <dd>
+ * the result of combining the constants which are required
+ * to produce a typical application dialog shell: (that
+ * is, <code>TITLE | CLOSE | BORDER</code>)
+ * </dd>
+ * </dl>
+ * </p>
+ * <p>
+ * Note: Only one of the styles APPLICATION_MODAL, MODELESS,
+ * PRIMARY_MODAL and SYSTEM_MODAL may be specified.
+ * </p><p>
+ * IMPORTANT: This class is not intended to be subclassed.
+ * </p>
+ *
+ * @see Decorations
+ * @see SWT
+ */
+public class Shell extends Decorations {
+ Display display;
+ Menu activeMenu;
+ int hIMC;
+ int [] brushes;
+ boolean showWithParent;
+ int toolTipHandle, lpstrTip;
+ Control lastActive;
+ SHACTIVATEINFO psai;
+ static final int DialogProc;
+ static final TCHAR DialogClass = new TCHAR (0, OS.IsWinCE ? "Dialog" : "#32770", true);
+ static {
+ WNDCLASS lpWndClass = new WNDCLASS ();
+ OS.GetClassInfo (0, DialogClass, lpWndClass);
+ DialogProc = lpWndClass.lpfnWndProc;
+ }
+
+/**
+ * Constructs a new instance of this class. This is equivalent
+ * to calling <code>Shell((Display) null)</code>.
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
+ * <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
+ * </ul>
+ */
+public Shell () {
+ this ((Display) null);
+}
+
+/**
+ * Constructs a new instance of this class given only the style
+ * value describing its behavior and appearance. This is equivalent
+ * to calling <code>Shell((Display) null, style)</code>.
+ * <p>
+ * The style value is either one of the style constants defined in
+ * class <code>SWT</code> which is applicable to instances of this
+ * class, or must be built by <em>bitwise OR</em>'ing together
+ * (that is, using the <code>int</code> "|" operator) two or more
+ * of those <code>SWT</code> style constants. The class description
+ * lists the style constants that are applicable to the class.
+ * Style bits are also inherited from superclasses.
+ * </p>
+ *
+ * @param style the style of control to construct
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
+ * <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
+ * </ul>
+ *
+ * @see SWT#BORDER
+ * @see SWT#CLOSE
+ * @see SWT#MIN
+ * @see SWT#MAX
+ * @see SWT#RESIZE
+ * @see SWT#TITLE
+ * @see SWT#NO_TRIM
+ * @see SWT#SHELL_TRIM
+ * @see SWT#DIALOG_TRIM
+ * @see SWT#MODELESS
+ * @see SWT#PRIMARY_MODAL
+ * @see SWT#APPLICATION_MODAL
+ * @see SWT#SYSTEM_MODAL
+ */
+public Shell (int style) {
+ this ((Display) null, style);
+}
+
+/**
+ * Constructs a new instance of this class given only the display
+ * to create it on. It is created with style <code>SWT.SHELL_TRIM</code>.
+ * <p>
+ * Note: Currently, null can be passed in for the display argument.
+ * This has the effect of creating the shell on the currently active
+ * display if there is one. If there is no current display, the
+ * shell is created on a "default" display. <b>Passing in null as
+ * the display argument is not considered to be good coding style,
+ * and may not be supported in a future release of SWT.</b>
+ * </p>
+ *
+ * @param display the display to create the shell on
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
+ * <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
+ * </ul>
+ */
+public Shell (Display display) {
+ this (display, OS.IsWinCE ? SWT.NONE : SWT.SHELL_TRIM);
+}
+
+/**
+ * Constructs a new instance of this class given the display
+ * to create it on and a style value describing its behavior
+ * and appearance.
+ * <p>
+ * The style value is either one of the style constants defined in
+ * class <code>SWT</code> which is applicable to instances of this
+ * class, or must be built by <em>bitwise OR</em>'ing together
+ * (that is, using the <code>int</code> "|" operator) two or more
+ * of those <code>SWT</code> style constants. The class description
+ * lists the style constants that are applicable to the class.
+ * Style bits are also inherited from superclasses.
+ * </p><p>
+ * Note: Currently, null can be passed in for the display argument.
+ * This has the effect of creating the shell on the currently active
+ * display if there is one. If there is no current display, the
+ * shell is created on a "default" display. <b>Passing in null as
+ * the display argument is not considered to be good coding style,
+ * and may not be supported in a future release of SWT.</b>
+ * </p>
+ *
+ * @param display the display to create the shell on
+ * @param style the style of control to construct
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
+ * <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
+ * </ul>
+ *
+ * @see SWT#BORDER
+ * @see SWT#CLOSE
+ * @see SWT#MIN
+ * @see SWT#MAX
+ * @see SWT#RESIZE
+ * @see SWT#TITLE
+ * @see SWT#NO_TRIM
+ * @see SWT#SHELL_TRIM
+ * @see SWT#DIALOG_TRIM
+ * @see SWT#MODELESS
+ * @see SWT#PRIMARY_MODAL
+ * @see SWT#APPLICATION_MODAL
+ * @see SWT#SYSTEM_MODAL
+ */
+public Shell (Display display, int style) {
+ this (display, null, style, 0);
+}
+
+Shell (Display display, Shell parent, int style, int handle) {
+ super ();
+ checkSubclass ();
+ 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, OS.IsWinCE ? SWT.NONE : SWT.DIALOG_TRIM);
+}
+
+/**
+ * Constructs a new instance of this class given its parent
+ * and a style value describing its behavior and appearance.
+ * <p>
+ * The style value is either one of the style constants defined in
+ * class <code>SWT</code> which is applicable to instances of this
+ * class, or must be built by <em>bitwise OR</em>'ing together
+ * (that is, using the <code>int</code> "|" operator) two or more
+ * of those <code>SWT</code> style constants. The class description
+ * lists the style constants that are applicable to the class.
+ * Style bits are also inherited from superclasses.
+ * </p><p>
+ * Note: Currently, null can be passed in for the parent.
+ * This has the effect of creating the shell on the currently active
+ * display if there is one. If there is no current display, the
+ * shell is created on a "default" display. <b>Passing in null as
+ * the parent is not considered to be good coding style,
+ * and may not be supported in a future release of SWT.</b>
+ * </p>
+ *
+ * @param parent a shell which will be the parent of the new instance
+ * @param style the style of control to construct
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
+ * <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
+ * </ul>
+ *
+ * @see SWT#BORDER
+ * @see SWT#CLOSE
+ * @see SWT#MIN
+ * @see SWT#MAX
+ * @see SWT#RESIZE
+ * @see SWT#TITLE
+ * @see SWT#NO_TRIM
+ * @see SWT#SHELL_TRIM
+ * @see SWT#DIALOG_TRIM
+ * @see SWT#MODELESS
+ * @see SWT#PRIMARY_MODAL
+ * @see SWT#APPLICATION_MODAL
+ * @see SWT#SYSTEM_MODAL
+ */
+public Shell (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);
+}
+
+int callWindowProc (int msg, int wParam, int lParam) {
+ if (parent != null) {
+ if (handle == 0) return 0;
+ switch (msg) {
+ case OS.WM_KILLFOCUS:
+ case OS.WM_SETFOCUS:
+ return OS.DefWindowProc (handle, msg, wParam, lParam);
+ }
+ return OS.CallWindowProc (DialogProc, handle, msg, wParam, lParam);
+ }
+ return super.callWindowProc (msg, wParam, lParam);
+}
+
+/**
+ * Requests that the window manager close the receiver in
+ * the same way it would be closed when the user clicks on
+ * the "close box" or performs some other platform specific
+ * key or mouse combination that indicates the window
+ * should be removed.
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see #dispose
+ */
+public void close () {
+ checkWidget ();
+ OS.PostMessage (handle, OS.WM_CLOSE, 0, 0);
+}
+
+void createHandle () {
+ boolean embedded = handle != 0;
+
+ /*
+ * On Windows 98 and NT, setting a window to be the
+ * top most window using HWND_TOPMOST can result in a
+ * parent dialog shell being moved behind its parent
+ * if the dialog has a sibling that is currently on top
+ * This only occurs using SetWindowPos (), not when the
+ * handle is created.
+ */
+ /*
+ * The following code is intentionally commented.
+ */
+// if ((style & SWT.ON_TOP) != 0) display.lockActiveWindow = true;
+ super.createHandle ();
+ /*
+ * The following code is intentionally commented.
+ */
+// if ((style & SWT.ON_TOP) != 0) display.lockActiveWindow = false;
+
+ if (!embedded) {
+ int bits = OS.GetWindowLong (handle, OS.GWL_STYLE);
+ bits &= ~(OS.WS_OVERLAPPED | OS.WS_CAPTION);
+ if (!OS.IsWinCE) bits |= OS.WS_POPUP;
+ if ((style & SWT.TITLE) != 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 (OS.IsWinCE) setMaximized (true);
+ if (OS.IsPPC) {
+ psai = new SHACTIVATEINFO ();
+ psai.cbSize = SHACTIVATEINFO.sizeof;
+ }
+ }
+ if (OS.IsDBLocale) {
+ hIMC = OS.ImmCreateContext ();
+ if (hIMC != 0) OS.ImmAssociateContext (handle, hIMC);
+ }
+}
+
+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;
+}
+
+/**
+ * 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) and forces the window
+ * manager to make the shell active.
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @since 2.0
+ * @see Control#moveAbove
+ * @see Control#setFocus
+ * @see Control#setVisible
+ * @see Display#getActiveShell
+ * @see Decorations#setDefaultButton
+ * @see Shell#open
+ * @see Shell#setActive
+ */
+public void forceActive () {
+ checkWidget ();
+ OS.SetForegroundWindow (handle);
+}
+
+void forceResize () {
+ /* Do nothing */
+}
+
+public Rectangle getBounds () {
+ checkWidget ();
+ if (!OS.IsWinCE) {
+ 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 ();
+ 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 (!OS.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.IsWinCE) {
+ 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)
+ * and asks the window manager to make the shell active.
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see Control#moveAbove
+ * @see Control#setFocus
+ * @see Control#setVisible
+ * @see Display#getActiveShell
+ * @see Decorations#setDefaultButton
+ * @see Shell#setActive
+ * @see Shell#forceActive
+ */
+public void open () {
+ checkWidget ();
+ bringToTop ();
+ /*
+ * Feature on WinCE PPC. A new application becomes
+ * the foreground application only if it has at least
+ * one visible window before the event loop is started.
+ * The workaround is to explicitely force the shell to
+ * be the foreground window.
+ */
+ if (OS.IsWinCE) OS.SetForegroundWindow (handle);
+ OS.SendMessage (handle, OS.WM_CHANGEUISTATE, OS.UIS_INITIALIZE, 0);
+ setVisible (true);
+ /*
+ * Bug in Windows XP. Despite the fact that an icon has been
+ * set for a window, the task bar displays the wrong icon the
+ * first time the window is made visible with ShowWindow() after
+ * a call to BringToTop(), when a long time elapses between the
+ * ShowWindow() and the time the event queue is read. The icon
+ * in the window trimming is correct but the one in the task
+ * bar does not get updated until a new icon is set into the
+ * window or the window text is changed. The fix is to call
+ * PeekMessage() with the flag PM_NOREMOVE to touch the event
+ * queue but not dispatch events.
+ */
+ MSG msg = new MSG ();
+ OS.PeekMessage (msg, 0, 0, 0, OS.PM_NOREMOVE);
+ if (!restoreFocus ()) traverseGroup (true);
+}
+
+void releaseShells () {
+ Shell [] shells = getShells ();
+ for (int i=0; i<shells.length; i++) {
+ Shell shell = shells [i];
+ if (!shell.isDisposed ()) shell.releaseResources ();
+ }
+}
+
+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 (OS.IsDBLocale) {
+ if (hIMC != 0) OS.ImmDestroyContext (hIMC);
+ }
+ lastActive = null;
+}
+
+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;
+}
+
+/**
+ * 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) and asks the window
+ * manager to make the shell active.
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @since 2.0
+ * @see Control#moveAbove
+ * @see Control#setFocus
+ * @see Control#setVisible
+ * @see Display#getActiveShell
+ * @see Decorations#setDefaultButton
+ * @see Shell#open
+ * @see Shell#setActive
+ */
+public void setActive () {
+ checkWidget ();
+ bringToTop ();
+}
+
+void setActiveControl (Control control) {
+ if (control != null && control.isDisposed ()) control = null;
+ if (lastActive != null && lastActive.isDisposed ()) lastActive = null;
+ if (lastActive == control) return;
+
+ /*
+ * Compute the list of controls to be activated and
+ * deactivated by finding the first common parent
+ * control.
+ */
+ Control [] activate = (control == null) ? new Control [0] : control.getPath ();
+ Control [] deactivate = (lastActive == null) ? new Control [0] : lastActive.getPath ();
+ lastActive = control;
+ int index = 0, length = Math.min (activate.length, deactivate.length);
+ while (index < length) {
+ if (activate [index] != deactivate [index]) break;
+ index++;
+ }
+
+ /*
+ * It is possible (but unlikely), that application
+ * code could have destroyed some of the widgets. If
+ * this happens, keep processing those widgets that
+ * are not disposed.
+ */
+ for (int i=deactivate.length-1; i>=index; --i) {
+ if (!deactivate [i].isDisposed ()) {
+ deactivate [i].sendEvent (SWT.Deactivate);
+ }
+ }
+ for (int i=activate.length-1; i>=index; --i) {
+ if (!activate [i].isDisposed ()) {
+ activate [i].sendEvent (SWT.Activate);
+ }
+ }
+}
+
+void setBounds (int x, int y, int width, int height, int flags) {
+ if (OS.IsWinCE) {
+ swFlags = OS.SW_RESTORE;
+ if ((style & SWT.NO_TRIM) == 0) {
+ /* Set the WS_CAPTION bits when no longer maximized */
+ int bits = OS.GetWindowLong (handle, OS.GWL_STYLE);
+ if ((bits & OS.WS_CAPTION) != OS.WS_CAPTION) {
+ bits |= OS.WS_CAPTION;
+ OS.SetWindowLong (handle, OS.GWL_STYLE, bits);
+ }
+ }
+ } else {
+ if (OS.IsIconic (handle) || OS.IsZoomed (handle)) {
+ setPlacement (x, y, width, height, flags);
+ return;
+ }
+ }
+ OS.SetWindowPos (handle, 0, x, y, width, height, flags);
+}
+
+public void setEnabled (boolean enabled) {
+ checkWidget ();
+ state &= ~DISABLED;
+ if (!enabled) state |= DISABLED;
+ if (!Display.TrimEnabled) {
+ super.setEnabled (enabled);
+ } else {
+ 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 (!OS.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 (OS.IsWinCE) return;
+ if (toolTipHandle == 0) {
+ toolTipHandle = OS.CreateWindowEx (
+ 0,
+ new TCHAR (0, OS.TOOLTIPS_CLASS, true),
+ 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);
+ /*
+ * Feature in Windows. Despite the fact that the
+ * tool tip text contains \r\n, the tooltip will
+ * not honour the new line unless TTM_SETMAXTIPWIDTH
+ * is set. The fix is to set TTM_SETMAXTIPWIDTH to
+ * a large value.
+ */
+ OS.SendMessage (toolTipHandle, OS.TTM_SETMAXTIPWIDTH, 0, 0x7FFF);
+ }
+ 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);
+ }
+ OS.SendMessage (toolTipHandle, OS.TTM_UPDATE, 0, 0);
+}
+
+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);
+ int byteCount = buffer.length;
+ lpstrTip = OS.HeapAlloc (hHeap, OS.HEAP_ZERO_MEMORY, byteCount);
+ OS.MoveMemory (lpstrTip, buffer, byteCount);
+ 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);
+ int byteCount = buffer.length * 2;
+ lpstrTip = OS.HeapAlloc (hHeap, OS.HEAP_ZERO_MEMORY, byteCount);
+ OS.MoveMemory (lpstrTip, buffer, byteCount);
+ lpnmtdi.lpszText = lpstrTip;
+}
+
+public void setVisible (boolean visible) {
+ checkWidget ();
+ super.setVisible (visible);
+ if (showWithParent == visible) return;
+ showWithParent = visible;
+ if (!OS.IsWinCE) OS.ShowOwnedPopups (handle, visible);
+ int mask = SWT.PRIMARY_MODAL | SWT.APPLICATION_MODAL | SWT.SYSTEM_MODAL;
+ if ((style & mask) != 0) {
+ if (visible) {
+ display.setModalShell (this);
+ Control control = display.getFocusControl ();
+ if (control != null && !control.isActive ()) bringToTop ();
+ int hwndShell = OS.GetActiveWindow ();
+ if (hwndShell == 0) {
+ if (parent != null) hwndShell = parent.handle;
+ }
+ if (hwndShell != 0) {
+ OS.SendMessage (hwndShell, OS.WM_CANCELMODE, 0, 0);
+ }
+ OS.ReleaseCapture ();
+ } else {
+ display.clearModal (this);
+ }
+ } else {
+ updateModal ();
+ }
+}
+
+boolean traverseEscape () {
+ if (parent == null) return false;
+ if (!isVisible () || !isEnabled ()) return false;
+ close ();
+ return true;
+}
+
+void updateModal () {
+ if (!Display.TrimEnabled) {
+ super.setEnabled (isActive ());
+ } else {
+ setItemEnabled (OS.SC_CLOSE, isActive ());
+ }
+}
+
+int widgetExtStyle () {
+ int bits = super.widgetExtStyle ();
+ /*
+ * Bug in Windows 98 and NT. Creating a window with the
+ * WS_EX_TOPMOST extendes style can result in a dialog shell
+ * being moved behind its parent. The exact case where this
+ * happens is a shell with two dialog shell children where
+ * each dialog child has another hidden dialog child with
+ * the WS_EX_TOPMOST extended style. Clicking on either of
+ * the visible dialog causes them to become active but move
+ * to the back, behind the parent shell. The fix is to
+ * disallow the WS_EX_TOPMOST extended style on Windows 98
+ * and NT.
+ */
+ if (OS.IsWin95) return bits;
+ if ((OS.WIN32_MAJOR << 16 | OS.WIN32_MINOR) < (4 << 16 | 10)) {
+ return bits;
+ }
+ if ((style & SWT.ON_TOP) != 0) bits |= OS.WS_EX_TOPMOST;
+ return bits;
+}
+
+TCHAR windowClass () {
+ if (OS.IsSP) return DialogClass;
+ return parent != null ? DialogClass : super.windowClass ();
+}
+
+int windowProc () {
+ if (OS.IsSP) return DialogProc;
+ return parent != null ? DialogProc : super.windowProc ();
+}
+
+int widgetStyle () {
+ int bits = super.widgetStyle () & ~OS.WS_POPUP;
+ if (handle != 0) return bits | OS.WS_CHILD;
+ bits &= ~OS.WS_CHILD;
+ /*
+ * Feature in WinCE. Calling CreateWindowEx () with WS_OVERLAPPED
+ * and a parent window causes the new window to become a WS_CHILD of
+ * the parent instead of a dialog child. The fix is to use WS_POPUP
+ * for a window with a parent.
+ *
+ * Feature in WinCE PPC. A window without a parent with WS_POPUP
+ * always shows on top of the Pocket PC 'Today Screen'. The fix
+ * is to not set WS_POPUP for a window without a parent on WinCE
+ * devices.
+ *
+ * NOTE: WS_POPUP causes CreateWindowEx () to ignore CW_USEDEFAULT
+ * and causes the default window location and size to be zero.
+ */
+ if (OS.IsWinCE) {
+ if (OS.IsSP) return bits | OS.WS_POPUP;
+ return parent == null ? bits : bits | OS.WS_POPUP;
+ }
+
+ /*
+ * Use WS_OVERLAPPED for all windows, either dialog or top level
+ * so that CreateWindowEx () will respect CW_USEDEFAULT and set
+ * the default window location and size.
+ *
+ * NOTE: When a WS_OVERLAPPED window is created, Windows gives
+ * the new window WS_CAPTION style bits. These two constants are
+ * as follows:
+ *
+ * WS_OVERLAPPED = 0
+ * WS_CAPTION = WS_BORDER | WS_DLGFRAME
+ *
+ */
+ return bits | OS.WS_OVERLAPPED | OS.WS_CAPTION;
+}
+
+LRESULT WM_ACTIVATE (int wParam, int lParam) {
+ if (OS.IsPPC) {
+ /*
+ * Note: this does not work when we get WM_ACTIVATE prior
+ * to adding a listener.
+ */
+ if (hooks (SWT.HardKeyDown) || hooks (SWT.HardKeyUp)) {
+ int fActive = wParam & 0xFFFF;
+ int hwnd = fActive != 0 ? handle : 0;
+ for (int bVk=OS.VK_APP1; bVk<=OS.VK_APP6; bVk++) {
+ OS.SHSetAppKeyWndAssoc ((byte) bVk, hwnd);
+ }
+ }
+ /* Restore SIP state when window is activated */
+ if ((wParam & 0xFFFF) != 0) {
+ OS.SHSipPreference (handle, psai.fSipUp == 0 ? OS.SIP_DOWN : OS.SIP_UP);
+ }
+ }
+ /*
+ * Bug in Windows XP. When a Shell is deactivated, the
+ * IME composition window does not go away. This causes
+ * repaint issues. The fix is to close the IME ourselves
+ * when the Shell is deactivated.
+ *
+ * Note. When the Shell is reactivated, the text in the
+ * composition window has been lost.
+ */
+ if ((OS.WIN32_MAJOR << 16 | OS.WIN32_MINOR) >= (5 << 16 | 1)) {
+ if ((wParam & 0xFFFF) == 0 && OS.IsDBLocale && hIMC != 0) {
+ OS.ImmSetOpenStatus (hIMC, false);
+ }
+ }
+
+ LRESULT result = super.WM_ACTIVATE (wParam, lParam);
+ if (parent != null) return LRESULT.ZERO;
+ return result;
+}
+
+LRESULT WM_CLOSE (int wParam, int lParam) {
+ if ((Display.TrimEnabled && !isEnabled ()) || !isActive ()) {
+ return LRESULT.ZERO;
+ }
+ return super.WM_CLOSE (wParam, lParam);
+}
+
+LRESULT WM_COMMAND (int wParam, int lParam) {
+ if (OS.IsPPC) {
+ /*
+ * Note in WinCE PPC: Close the Shell when the "Done Button" has
+ * been pressed. lParam is either 0 (PocketPC 2002) or the handle
+ * to the Shell (PocketPC).
+ */
+ int loWord = wParam & 0xFFFF;
+ if (loWord == OS.IDOK && (lParam == 0 || lParam == handle)) {
+ OS.PostMessage (handle, OS.WM_CLOSE, 0, 0);
+ return LRESULT.ZERO;
+ }
+ }
+ /*
+ * Note in WinCE PPC. Menu events originate from the command bar.
+ */
+ if (OS.IsPPC || OS.IsSP) {
+ if (menuBar != null) {
+ int hwndCB = menuBar.hwndCB;
+ if (hwndCB != 0 && lParam == hwndCB) {
+ return super.WM_COMMAND (wParam, 0);
+ }
+ }
+ }
+ return super.WM_COMMAND (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 ();
+ releaseResources ();
+ }
+ 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;
+ /*
+ * Get the current location of the cursor,
+ * not the location of the cursor when the
+ * WM_MOUSEACTIVATE was generated. This is
+ * strictly incorrect but is necessary in
+ * order to support Activate and Deactivate
+ * events for embedded widgets that have
+ * their own event loop. In that case, the
+ * cursor location reported by GetMessagePos
+ * is the one for our event loop, not the
+ * embedded widget's event loop.
+ */
+ POINT pt = new POINT ();
+ if (!OS.GetCursorPos (pt)) {
+ 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 = display.findControl (hwnd);
+ setActiveControl (control);
+ /*
+ * 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 null;
+}
+
+LRESULT WM_NCHITTEST (int wParam, int lParam) {
+ if (!OS.IsWindowEnabled (handle)) return null;
+ 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 ()) {
+ int hwndModal = modalShell.handle;
+ if (OS.IsWindowEnabled (hwndModal)) {
+ OS.SetActiveWindow (hwndModal);
+ }
+ }
+ }
+ if (!OS.IsWindowEnabled (handle)) {
+ if (!OS.IsWinCE) {
+ int hwndPopup = OS.GetLastActivePopup (handle);
+ if (hwndPopup != 0 && hwndPopup != handle) {
+ if (WidgetTable.get (hwndPopup) == null) {
+ if (OS.IsWindowEnabled (hwndPopup)) {
+ OS.SetActiveWindow (hwndPopup);
+ }
+ }
+ }
+ }
+ }
+ }
+ return super.WM_SETCURSOR (wParam, lParam);
+}
+
+LRESULT WM_SETTINGCHANGE (int wParam, int lParam) {
+ LRESULT result = super.WM_SETTINGCHANGE (wParam, lParam);
+ if (result != null) return result;
+ if (OS.IsPPC) {
+ if (wParam == OS.SPI_SETSIPINFO) {
+ /*
+ * The SIP is in a new state. Cache its new value. * Resize the Shell if it has the style SWT.RESIZE.
+ * Note that SHHandleWMSettingChange resizes the
+ * Shell and also updates the cached state.
+ */
+ if ((style & SWT.RESIZE) != 0) {
+ OS.SHHandleWMSettingChange (handle, wParam, lParam, psai);
+ return LRESULT.ZERO;
+ } else {
+ SIPINFO pSipInfo = new SIPINFO ();
+ pSipInfo.cbSize = SIPINFO.sizeof;
+ OS.SipGetInfo (pSipInfo);
+ psai.fSipUp = pSipInfo.fdwFlags & OS.SIPF_ON;
+ }
+ }
+ }
+ return result;
+}
+
+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
index c1c0bf52d2..8406073f3f 100755
--- 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
@@ -1,799 +1,799 @@
-package org.eclipse.swt.widgets;
-
-/*
+package org.eclipse.swt.widgets;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-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 a left facing button for decrementing the value and a
- * right facing button for incrementing it) or <code>VERTICAL</code>
- * (which have an upward facing button for decrementing the value
- * and a downward facing buttons for incrementing it).
- * </p><p>
- * On some platforms, the size of the slider's thumb can be
- * varied relative to the magnitude of the range of values it
- * represents (that is, relative to the difference between its
- * maximum and minimum values). Typically, this is used to
- * indicate some proportional value such as the ratio of the
- * visible area of a document to the total amount of space that
- * it would take to display it. SWT supports setting the thumb
- * size even if the underlying platform does not, but in this
- * case the appearance of the slider will not change.
- * </p>
- * <dl>
- * <dt><b>Styles:</b></dt>
- * <dd>HORIZONTAL, VERTICAL</dd>
- * <dt><b>Events:</b></dt>
- * <dd>Selection</dd>
- * </dl>
- * <p>
- * Note: Only one of the styles HORIZONTAL and VERTICAL may be specified.
- * </p><p>
- * IMPORTANT: This class is <em>not</em> intended to be subclassed.
- * </p>
- *
- * @see ScrollBar
- */
-public class Slider extends Control {
- int increment, pageIncrement;
- static final int ScrollBarProc;
- static final TCHAR ScrollBarClass = new TCHAR (0, "SCROLLBAR", true);
- static {
- WNDCLASS lpWndClass = new WNDCLASS ();
- OS.GetClassInfo (0, ScrollBarClass, lpWndClass);
- ScrollBarProc = 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
- * lists the style constants that are applicable to the class.
- * Style bits are also inherited from superclasses.
- * </p>
- *
- * @param parent a composite control which will be the parent of the new instance (cannot be null)
- * @param style the style of control to construct
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
- * <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
- * </ul>
- *
- * @see SWT#HORIZONTAL
- * @see SWT#VERTICAL
- * @see Widget#checkSubclass
- * @see Widget#getStyle
- */
-public Slider (Composite parent, int style) {
- super (parent, checkStyle (style));
-}
-
-/**
- * Adds the listener to the collection of listeners who will
- * be notified when the receiver's value changes, by sending
- * it one of the messages defined in the <code>SelectionListener</code>
- * interface.
- * <p>
- * When <code>widgetSelected</code> is called, the event object detail field contains one of the following values:
- * <code>0</code> - for the end of a drag.
- * <code>SWT.DRAG</code>.
- * <code>SWT.HOME</code>.
- * <code>SWT.END</code>.
- * <code>SWT.ARROW_DOWN</code>.
- * <code>SWT.ARROW_UP</code>.
- * <code>SWT.PAGE_DOWN</code>.
- * <code>SWT.PAGE_UP</code>.
- * <code>widgetDefaultSelected</code> is not called.
- * </p>
- *
- * @param listener the listener which should be notified
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see SelectionListener
- * @see #removeSelectionListener
- * @see SelectionEvent
- */
-public void addSelectionListener (SelectionListener listener) {
- checkWidget ();
- if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
- TypedListener typedListener = new TypedListener(listener);
- addListener (SWT.Selection,typedListener);
- addListener (SWT.DefaultSelection,typedListener);
-}
-
-int 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;
- /*
- * Set the intial values of the maximum
- * to 100 and the thumb to 10. Note that
- * info.nPage needs to be 11 in order to
- * get a thumb that is 10.
- */
- SCROLLINFO info = new SCROLLINFO ();
- info.cbSize = SCROLLINFO.sizeof;
- info.fMask = OS.SIF_ALL;
- info.nMax = 100;
- info.nPage = 11;
- 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;
-}
-
-/**
- * Returns the size of the receiver's thumb relative to the
- * difference between its maximum and minimum values.
- *
- * @return the thumb value
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public int getThumb () {
- checkWidget ();
- 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 ();
- if (OS.IsWinCE) {
- super.setEnabled (enabled);
- } else {
- int flags = enabled ? OS.ESB_ENABLE_BOTH : OS.ESB_DISABLE_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) {
- if (OS.IsWinCE) {
- OS.EnableWindow (handle, false);
- } else {
- 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) {
- if (OS.IsWinCE) {
- OS.EnableWindow (handle, false);
- } else {
- 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 ();
- 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) {
- if (OS.IsWinCE) {
- OS.EnableWindow (handle, false);
- } else {
- 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 (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) {
- if (OS.IsWinCE) {
- OS.EnableWindow (handle, false);
- } else {
- 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 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;
-}
-
-TCHAR 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;
-}
-
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+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 a left facing button for decrementing the value and a
+ * right facing button for incrementing it) or <code>VERTICAL</code>
+ * (which have an upward facing button for decrementing the value
+ * and a downward facing buttons for incrementing it).
+ * </p><p>
+ * On some platforms, the size of the slider's thumb can be
+ * varied relative to the magnitude of the range of values it
+ * represents (that is, relative to the difference between its
+ * maximum and minimum values). Typically, this is used to
+ * indicate some proportional value such as the ratio of the
+ * visible area of a document to the total amount of space that
+ * it would take to display it. SWT supports setting the thumb
+ * size even if the underlying platform does not, but in this
+ * case the appearance of the slider will not change.
+ * </p>
+ * <dl>
+ * <dt><b>Styles:</b></dt>
+ * <dd>HORIZONTAL, VERTICAL</dd>
+ * <dt><b>Events:</b></dt>
+ * <dd>Selection</dd>
+ * </dl>
+ * <p>
+ * Note: Only one of the styles HORIZONTAL and VERTICAL may be specified.
+ * </p><p>
+ * IMPORTANT: This class is <em>not</em> intended to be subclassed.
+ * </p>
+ *
+ * @see ScrollBar
+ */
+public class Slider extends Control {
+ int increment, pageIncrement;
+ static final int ScrollBarProc;
+ static final TCHAR ScrollBarClass = new TCHAR (0, "SCROLLBAR", true);
+ static {
+ WNDCLASS lpWndClass = new WNDCLASS ();
+ OS.GetClassInfo (0, ScrollBarClass, lpWndClass);
+ ScrollBarProc = 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
+ * lists the style constants that are applicable to the class.
+ * Style bits are also inherited from superclasses.
+ * </p>
+ *
+ * @param parent a composite control which will be the parent of the new instance (cannot be null)
+ * @param style the style of control to construct
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
+ * <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
+ * </ul>
+ *
+ * @see SWT#HORIZONTAL
+ * @see SWT#VERTICAL
+ * @see Widget#checkSubclass
+ * @see Widget#getStyle
+ */
+public Slider (Composite parent, int style) {
+ super (parent, checkStyle (style));
+}
+
+/**
+ * Adds the listener to the collection of listeners who will
+ * be notified when the receiver's value changes, by sending
+ * it one of the messages defined in the <code>SelectionListener</code>
+ * interface.
+ * <p>
+ * When <code>widgetSelected</code> is called, the event object detail field contains one of the following values:
+ * <code>0</code> - for the end of a drag.
+ * <code>SWT.DRAG</code>.
+ * <code>SWT.HOME</code>.
+ * <code>SWT.END</code>.
+ * <code>SWT.ARROW_DOWN</code>.
+ * <code>SWT.ARROW_UP</code>.
+ * <code>SWT.PAGE_DOWN</code>.
+ * <code>SWT.PAGE_UP</code>.
+ * <code>widgetDefaultSelected</code> is not called.
+ * </p>
+ *
+ * @param listener the listener which should be notified
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see SelectionListener
+ * @see #removeSelectionListener
+ * @see SelectionEvent
+ */
+public void addSelectionListener (SelectionListener listener) {
+ checkWidget ();
+ if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+ TypedListener typedListener = new TypedListener(listener);
+ addListener (SWT.Selection,typedListener);
+ addListener (SWT.DefaultSelection,typedListener);
+}
+
+int 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;
+ /*
+ * Set the intial values of the maximum
+ * to 100 and the thumb to 10. Note that
+ * info.nPage needs to be 11 in order to
+ * get a thumb that is 10.
+ */
+ SCROLLINFO info = new SCROLLINFO ();
+ info.cbSize = SCROLLINFO.sizeof;
+ info.fMask = OS.SIF_ALL;
+ info.nMax = 100;
+ info.nPage = 11;
+ 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;
+}
+
+/**
+ * Returns the size of the receiver's thumb relative to the
+ * difference between its maximum and minimum values.
+ *
+ * @return the thumb value
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public int getThumb () {
+ checkWidget ();
+ 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 ();
+ if (OS.IsWinCE) {
+ super.setEnabled (enabled);
+ } else {
+ int flags = enabled ? OS.ESB_ENABLE_BOTH : OS.ESB_DISABLE_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) {
+ if (OS.IsWinCE) {
+ OS.EnableWindow (handle, false);
+ } else {
+ 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) {
+ if (OS.IsWinCE) {
+ OS.EnableWindow (handle, false);
+ } else {
+ 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 ();
+ 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) {
+ if (OS.IsWinCE) {
+ OS.EnableWindow (handle, false);
+ } else {
+ 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 (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) {
+ if (OS.IsWinCE) {
+ OS.EnableWindow (handle, false);
+ } else {
+ 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 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;
+}
+
+TCHAR 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
index 2bc870aabc..976e89f79f 100755
--- 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
@@ -1,792 +1,792 @@
-package org.eclipse.swt.widgets;
-
-/*
+package org.eclipse.swt.widgets;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-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
- * metaphor. It allows the user to select a notebook page from
- * set of pages.
- * <p>
- * The item children that may be added to instances of this class
- * must be of type <code>TabItem</code>.
- * <code>Control</code> children are created and then set into a
- * tab item using <code>TabItem#setControl</code>.
- * </p><p>
- * Note that although this class is a subclass of <code>Composite</code>,
- * it does not make sense to set a layout on it.
- * </p><p>
- * <dl>
- * <dt><b>Styles:</b></dt>
- * <dd>(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 TCHAR TabFolderClass = new TCHAR (0, "SWT_" + OS.WC_TABCONTROL, true);
- static {
- /*
- * 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.
- */
- WNDCLASS lpWndClass = new WNDCLASS ();
- TCHAR WC_TABCONTROL = new TCHAR (0, OS.WC_TABCONTROL, true);
- OS.GetClassInfo (0, WC_TABCONTROL, lpWndClass);
- TabFolderProc = lpWndClass.lpfnWndProc;
- int hInstance = OS.GetModuleHandle (null);
- if (!OS.GetClassInfo (hInstance, TabFolderClass, lpWndClass)) {
- int hHeap = OS.GetProcessHeap ();
- lpWndClass.hInstance = hInstance;
- lpWndClass.style &= ~(OS.CS_HREDRAW | OS.CS_VREDRAW);
- int byteCount = TabFolderClass.length () * TCHAR.sizeof;
- int lpszClassName = OS.HeapAlloc (hHeap, OS.HEAP_ZERO_MEMORY, byteCount);
- OS.MoveMemory (lpszClassName, TabFolderClass, byteCount);
- lpWndClass.lpszClassName = lpszClassName;
- OS.RegisterClass (lpWndClass);
-// OS.HeapFree (hHeap, 0, lpszClassName);
- }
- }
-
-/**
- * Constructs a new instance of this class given its parent
- * and a style value describing its behavior and appearance.
- * <p>
- * The style value is either one of the style constants defined in
- * class <code>SWT</code> which is applicable to instances of this
- * class, or must be built by <em>bitwise OR</em>'ing together
- * (that is, using the <code>int</code> "|" operator) two or more
- * of those <code>SWT</code> style constants. The class description
- * lists the style constants that are applicable to the class.
- * Style bits are also inherited from superclasses.
- * </p>
- *
- * @param parent a composite control which will be the parent of the new instance (cannot be null)
- * @param style the style of control to construct
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
- * <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
- * </ul>
- *
- * @see SWT
- * @see Widget#checkSubclass
- * @see Widget#getStyle
- */
-public TabFolder (Composite parent, int style) {
- super (parent, checkStyle (style));
-}
-
-/**
- * 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.
- * <p>
- * When <code>widgetSelected</code> is called, the item field of the event object is valid.
- * <code>widgetDefaultSelected</code> is not called.
- * </p>
- *
- * @param listener the listener which should be notified
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see SelectionListener
- * @see #removeSelectionListener
- * @see SelectionEvent
- */
-public void addSelectionListener(SelectionListener listener) {
- checkWidget ();
- if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
- TypedListener typedListener = new TypedListener(listener);
- addListener(SWT.Selection,typedListener);
- addListener(SWT.DefaultSelection,typedListener);
-}
-
-int 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 = null;
- if (layout != null) {
- size = layout.computeSize (this, wHint, hHint, changed);
- } else {
- size = minimumSize (wHint, hHint, changed);
- }
- if (size.x == 0) size.x = DEFAULT_WIDTH;
- if (size.y == 0) size.y = DEFAULT_HEIGHT;
- if (wHint != SWT.DEFAULT) size.x = wHint;
- if (hHint != SWT.DEFAULT) size.y = hHint;
- 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;
- /*
- * Feature in Windows. Despite the fact that the
- * tool tip text contains \r\n, the tooltip will
- * not honour the new line unless TTM_SETMAXTIPWIDTH
- * is set. The fix is to set TTM_SETMAXTIPWIDTH to
- * a large value.
- */
- int hwndToolTip = OS.SendMessage (handle, OS.TCM_GETTOOLTIPS, 0, 0);
- OS.SendMessage (hwndToolTip, OS.TTM_SETMAXTIPWIDTH, 0, 0x7FFF);
-}
-
-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);
- Display display = getDisplay ();
- display.releaseImageList (imageList);
- }
- 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 ();
- forceResize ();
- 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 affect the receiver.
- * </p>
- *
- * @return the items in the receiver
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public TabItem [] getItems () {
- checkWidget ();
- int count = 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 affect the receiver.
- * </p>
- * @return an array representing the selection
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public TabItem [] getSelection () {
- checkWidget ();
- int index = OS.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) {
- Rectangle bounds = image.getBounds ();
- imageList = getDisplay ().getImageList (new Point (bounds.width, bounds.height));
- int index = imageList.indexOf (image);
- if (index == -1) index = imageList.add (image);
- int hImageList = imageList.getHandle ();
- OS.SendMessage (handle, OS.TCM_SETIMAGELIST, 0, hImageList);
- return index;
- }
- int index = imageList.indexOf (image);
- if (index != -1) return index;
- return imageList.add (image);
-}
-
-/**
- * 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;
-}
-
-Point minimumSize (int wHint, int hHint, boolean flushCache) {
- Control [] children = _getChildren ();
- int width = 0, height = 0;
- for (int i=0; i<children.length; i++) {
- Control child = children [i];
- int index = 0;
- int count = OS.SendMessage (handle, OS.TCM_GETITEMCOUNT, 0, 0);
- while (index < count) {
- if (items [index].control == child) break;
- index++;
- }
- if (index == count) {
- Rectangle rect = child.getBounds ();
- width = Math.max (width, rect.x + rect.width);
- height = Math.max (height, rect.y + rect.height);
- } else {
- Point size = child.computeSize (wHint, hHint, flushCache);
- width = Math.max (width, size.x);
- height = Math.max (height, size.y);
- }
- }
- return new Point (width, height);
-}
-
-boolean mnemonicHit (char key) {
- for (int i=0; i<items.length; i++) {
- TabItem item = items [i];
- if (item != null) {
- char ch = findMnemonic (item.getText ());
- if (Character.toUpperCase (key) == Character.toUpperCase (ch)) {
- if (setFocus ()) {
- setSelection (i, true);
- return true;
- }
- }
- }
- }
- return false;
-}
-
-boolean mnemonicMatch (char key) {
- for (int i=0; i<items.length; i++) {
- TabItem item = items [i];
- if (item != null) {
- char ch = findMnemonic (item.getText ());
- if (Character.toUpperCase (key) == Character.toUpperCase (ch)) {
- return true;
- }
- }
- }
- return false;
-}
-
-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.releaseResources ();
- }
- items = null;
- if (imageList != null) {
- OS.SendMessage (handle, OS.TCM_SETIMAGELIST, 0, 0);
- Display display = getDisplay ();
- display.releaseImageList (imageList);
- }
- imageList = null;
- super.releaseWidget ();
-}
-
-/**
- * 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 ();
- setSelection (index, false);
-}
-
-void setSelection (int index, boolean notify) {
- 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);
- }
- if (notify) {
- Event event = new Event ();
- event.item = item;
- sendEvent (SWT.Selection, event);
- }
- }
-}
-
-String toolTipText (NMTTDISPINFO hdr) {
- if ((hdr.uFlags & OS.TTF_IDISHWND) != 0) {
- return null;
- }
- int index = hdr.idFrom;
- int hwndToolTip = OS.SendMessage (handle, OS.TCM_GETTOOLTIPS, 0, 0);
- if (hwndToolTip == hdr.hwndFrom) {
- if (toolTipText != null) return "";
- if (0 <= index && index < items.length) {
- TabItem item = items [index];
- if (item != null) return item.toolTipText;
- }
- }
- return super.toolTipText (hdr);
-}
-
-boolean traversePage (boolean next) {
- int count = getItemCount ();
- if (count == 0) return false;
- int index = getSelectionIndex ();
- if (index == -1) {
- index = 0;
- } else {
- int offset = (next) ? 1 : -1;
- index = (index + offset + count) % count;
- }
- setSelection (index, true);
- return index == getSelectionIndex ();
-}
-
-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;
- if ((style & SWT.NO_FOCUS) != 0) bits |= OS.TCS_FOCUSNEVER;
- return bits | OS.TCS_TABS | OS.TCS_TOOLTIPS;
-}
-
-TCHAR windowClass () {
- return TabFolderClass;
-}
-
-int windowProc () {
- return TabFolderProc;
-}
-
-LRESULT WM_GETDLGCODE (int wParam, int lParam) {
- LRESULT result = super.WM_GETDLGCODE (wParam, lParam);
- /*
- * Return DLGC_BUTTON so that mnemonics will be
- * processed without needing to press the ALT key
- * when the widget has focus.
- */
- if (result != null) return result;
- return new LRESULT (OS.DLGC_BUTTON);
-}
-
-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) {
- /*
- * Feature in Windows. When the tab folder window
- * proc processes WM_NOTIFY, it forwards this
- * message to its parent. This is done so that
- * children of this control that send this message
- * type to their parent will notify not only
- * this control but also the parent of this control,
- * which is typically the application window and
- * the window that is looking for the message.
- * If the control did not forward the message,
- * applications would have to subclass the control
- * window to see the message. Because the control
- * window is subclassed by SWT, the message
- * is delivered twice, once by SWT and once when
- * the message is forwarded by the window proc.
- * The fix is to avoid calling the window proc
- * for this control.
- */
- LRESULT result = super.WM_NOTIFY (wParam, lParam);
- if (result != null) return result;
- return LRESULT.ZERO;
-}
-
-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_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);
-}
-
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+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
+ * metaphor. It allows the user to select a notebook page from
+ * set of pages.
+ * <p>
+ * The item children that may be added to instances of this class
+ * must be of type <code>TabItem</code>.
+ * <code>Control</code> children are created and then set into a
+ * tab item using <code>TabItem#setControl</code>.
+ * </p><p>
+ * Note that although this class is a subclass of <code>Composite</code>,
+ * it does not make sense to set a layout on it.
+ * </p><p>
+ * <dl>
+ * <dt><b>Styles:</b></dt>
+ * <dd>(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 TCHAR TabFolderClass = new TCHAR (0, "SWT_" + OS.WC_TABCONTROL, true);
+ static {
+ /*
+ * 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.
+ */
+ WNDCLASS lpWndClass = new WNDCLASS ();
+ TCHAR WC_TABCONTROL = new TCHAR (0, OS.WC_TABCONTROL, true);
+ OS.GetClassInfo (0, WC_TABCONTROL, lpWndClass);
+ TabFolderProc = lpWndClass.lpfnWndProc;
+ int hInstance = OS.GetModuleHandle (null);
+ if (!OS.GetClassInfo (hInstance, TabFolderClass, lpWndClass)) {
+ int hHeap = OS.GetProcessHeap ();
+ lpWndClass.hInstance = hInstance;
+ lpWndClass.style &= ~(OS.CS_HREDRAW | OS.CS_VREDRAW);
+ int byteCount = TabFolderClass.length () * TCHAR.sizeof;
+ int lpszClassName = OS.HeapAlloc (hHeap, OS.HEAP_ZERO_MEMORY, byteCount);
+ OS.MoveMemory (lpszClassName, TabFolderClass, byteCount);
+ lpWndClass.lpszClassName = lpszClassName;
+ OS.RegisterClass (lpWndClass);
+// OS.HeapFree (hHeap, 0, lpszClassName);
+ }
+ }
+
+/**
+ * Constructs a new instance of this class given its parent
+ * and a style value describing its behavior and appearance.
+ * <p>
+ * The style value is either one of the style constants defined in
+ * class <code>SWT</code> which is applicable to instances of this
+ * class, or must be built by <em>bitwise OR</em>'ing together
+ * (that is, using the <code>int</code> "|" operator) two or more
+ * of those <code>SWT</code> style constants. The class description
+ * lists the style constants that are applicable to the class.
+ * Style bits are also inherited from superclasses.
+ * </p>
+ *
+ * @param parent a composite control which will be the parent of the new instance (cannot be null)
+ * @param style the style of control to construct
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
+ * <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
+ * </ul>
+ *
+ * @see SWT
+ * @see Widget#checkSubclass
+ * @see Widget#getStyle
+ */
+public TabFolder (Composite parent, int style) {
+ super (parent, checkStyle (style));
+}
+
+/**
+ * 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.
+ * <p>
+ * When <code>widgetSelected</code> is called, the item field of the event object is valid.
+ * <code>widgetDefaultSelected</code> is not called.
+ * </p>
+ *
+ * @param listener the listener which should be notified
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see SelectionListener
+ * @see #removeSelectionListener
+ * @see SelectionEvent
+ */
+public void addSelectionListener(SelectionListener listener) {
+ checkWidget ();
+ if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+ TypedListener typedListener = new TypedListener(listener);
+ addListener(SWT.Selection,typedListener);
+ addListener(SWT.DefaultSelection,typedListener);
+}
+
+int 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 = null;
+ if (layout != null) {
+ size = layout.computeSize (this, wHint, hHint, changed);
+ } else {
+ size = minimumSize (wHint, hHint, changed);
+ }
+ if (size.x == 0) size.x = DEFAULT_WIDTH;
+ if (size.y == 0) size.y = DEFAULT_HEIGHT;
+ if (wHint != SWT.DEFAULT) size.x = wHint;
+ if (hHint != SWT.DEFAULT) size.y = hHint;
+ 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;
+ /*
+ * Feature in Windows. Despite the fact that the
+ * tool tip text contains \r\n, the tooltip will
+ * not honour the new line unless TTM_SETMAXTIPWIDTH
+ * is set. The fix is to set TTM_SETMAXTIPWIDTH to
+ * a large value.
+ */
+ int hwndToolTip = OS.SendMessage (handle, OS.TCM_GETTOOLTIPS, 0, 0);
+ OS.SendMessage (hwndToolTip, OS.TTM_SETMAXTIPWIDTH, 0, 0x7FFF);
+}
+
+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);
+ Display display = getDisplay ();
+ display.releaseImageList (imageList);
+ }
+ 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 ();
+ forceResize ();
+ 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 affect the receiver.
+ * </p>
+ *
+ * @return the items in the receiver
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public TabItem [] getItems () {
+ checkWidget ();
+ int count = 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 affect the receiver.
+ * </p>
+ * @return an array representing the selection
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public TabItem [] getSelection () {
+ checkWidget ();
+ int index = OS.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) {
+ Rectangle bounds = image.getBounds ();
+ imageList = getDisplay ().getImageList (new Point (bounds.width, bounds.height));
+ int index = imageList.indexOf (image);
+ if (index == -1) index = imageList.add (image);
+ int hImageList = imageList.getHandle ();
+ OS.SendMessage (handle, OS.TCM_SETIMAGELIST, 0, hImageList);
+ return index;
+ }
+ int index = imageList.indexOf (image);
+ if (index != -1) return index;
+ return imageList.add (image);
+}
+
+/**
+ * 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;
+}
+
+Point minimumSize (int wHint, int hHint, boolean flushCache) {
+ Control [] children = _getChildren ();
+ int width = 0, height = 0;
+ for (int i=0; i<children.length; i++) {
+ Control child = children [i];
+ int index = 0;
+ int count = OS.SendMessage (handle, OS.TCM_GETITEMCOUNT, 0, 0);
+ while (index < count) {
+ if (items [index].control == child) break;
+ index++;
+ }
+ if (index == count) {
+ Rectangle rect = child.getBounds ();
+ width = Math.max (width, rect.x + rect.width);
+ height = Math.max (height, rect.y + rect.height);
+ } else {
+ Point size = child.computeSize (wHint, hHint, flushCache);
+ width = Math.max (width, size.x);
+ height = Math.max (height, size.y);
+ }
+ }
+ return new Point (width, height);
+}
+
+boolean mnemonicHit (char key) {
+ for (int i=0; i<items.length; i++) {
+ TabItem item = items [i];
+ if (item != null) {
+ char ch = findMnemonic (item.getText ());
+ if (Character.toUpperCase (key) == Character.toUpperCase (ch)) {
+ if (setFocus ()) {
+ setSelection (i, true);
+ return true;
+ }
+ }
+ }
+ }
+ return false;
+}
+
+boolean mnemonicMatch (char key) {
+ for (int i=0; i<items.length; i++) {
+ TabItem item = items [i];
+ if (item != null) {
+ char ch = findMnemonic (item.getText ());
+ if (Character.toUpperCase (key) == Character.toUpperCase (ch)) {
+ return true;
+ }
+ }
+ }
+ return false;
+}
+
+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.releaseResources ();
+ }
+ items = null;
+ if (imageList != null) {
+ OS.SendMessage (handle, OS.TCM_SETIMAGELIST, 0, 0);
+ Display display = getDisplay ();
+ display.releaseImageList (imageList);
+ }
+ imageList = null;
+ super.releaseWidget ();
+}
+
+/**
+ * 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 ();
+ setSelection (index, false);
+}
+
+void setSelection (int index, boolean notify) {
+ 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);
+ }
+ if (notify) {
+ Event event = new Event ();
+ event.item = item;
+ sendEvent (SWT.Selection, event);
+ }
+ }
+}
+
+String toolTipText (NMTTDISPINFO hdr) {
+ if ((hdr.uFlags & OS.TTF_IDISHWND) != 0) {
+ return null;
+ }
+ int index = hdr.idFrom;
+ int hwndToolTip = OS.SendMessage (handle, OS.TCM_GETTOOLTIPS, 0, 0);
+ if (hwndToolTip == hdr.hwndFrom) {
+ if (toolTipText != null) return "";
+ if (0 <= index && index < items.length) {
+ TabItem item = items [index];
+ if (item != null) return item.toolTipText;
+ }
+ }
+ return super.toolTipText (hdr);
+}
+
+boolean traversePage (boolean next) {
+ int count = getItemCount ();
+ if (count == 0) return false;
+ int index = getSelectionIndex ();
+ if (index == -1) {
+ index = 0;
+ } else {
+ int offset = (next) ? 1 : -1;
+ index = (index + offset + count) % count;
+ }
+ setSelection (index, true);
+ return index == getSelectionIndex ();
+}
+
+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;
+ if ((style & SWT.NO_FOCUS) != 0) bits |= OS.TCS_FOCUSNEVER;
+ return bits | OS.TCS_TABS | OS.TCS_TOOLTIPS;
+}
+
+TCHAR windowClass () {
+ return TabFolderClass;
+}
+
+int windowProc () {
+ return TabFolderProc;
+}
+
+LRESULT WM_GETDLGCODE (int wParam, int lParam) {
+ LRESULT result = super.WM_GETDLGCODE (wParam, lParam);
+ /*
+ * Return DLGC_BUTTON so that mnemonics will be
+ * processed without needing to press the ALT key
+ * when the widget has focus.
+ */
+ if (result != null) return result;
+ return new LRESULT (OS.DLGC_BUTTON);
+}
+
+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) {
+ /*
+ * Feature in Windows. When the tab folder window
+ * proc processes WM_NOTIFY, it forwards this
+ * message to its parent. This is done so that
+ * children of this control that send this message
+ * type to their parent will notify not only
+ * this control but also the parent of this control,
+ * which is typically the application window and
+ * the window that is looking for the message.
+ * If the control did not forward the message,
+ * applications would have to subclass the control
+ * window to see the message. Because the control
+ * window is subclassed by SWT, the message
+ * is delivered twice, once by SWT and once when
+ * the message is forwarded by the window proc.
+ * The fix is to avoid calling the window proc
+ * for this control.
+ */
+ LRESULT result = super.WM_NOTIFY (wParam, lParam);
+ if (result != null) return result;
+ return LRESULT.ZERO;
+}
+
+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_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
index aed5113e03..0897a591e4 100755
--- 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
@@ -1,317 +1,317 @@
-package org.eclipse.swt.widgets;
-
-/*
+package org.eclipse.swt.widgets;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-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;
-
-/**
- * Constructs a new instance of this class given its parent
- * (which must be a <code>TabFolder</code>) and a style value
- * describing its behavior and appearance. The item is added
- * to the end of the items maintained by its parent.
- * <p>
- * The style value is either one of the style constants defined in
- * class <code>SWT</code> which is applicable to instances of this
- * class, or must be built by <em>bitwise OR</em>'ing together
- * (that is, using the <code>int</code> "|" operator) two or more
- * of those <code>SWT</code> style constants. The class description
- * lists the style constants that are applicable to the class.
- * Style bits are also inherited from superclasses.
- * </p>
- *
- * @param parent a composite control which will be the parent of the new instance (cannot be null)
- * @param style the style of control to construct
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
- * <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
- * </ul>
- *
- * @see SWT
- * @see Widget#checkSubclass
- * @see Widget#getStyle
- */
-public TabItem (TabFolder parent, int style) {
- super (parent, style);
- this.parent = parent;
- parent.createItem (this, parent.getItemCount ());
-}
-
-/**
- * Constructs a new instance of this class given its parent
- * (which must be a <code>TabFolder</code>), a style value
- * describing its behavior and appearance, and the index
- * at which to place it in the items maintained by its parent.
- * <p>
- * The style value is either one of the style constants defined in
- * class <code>SWT</code> which is applicable to instances of this
- * class, or must be built by <em>bitwise OR</em>'ing together
- * (that is, using the <code>int</code> "|" operator) two or more
- * of those <code>SWT</code> style constants. The class description
- * lists the style constants that are applicable to the class.
- * Style bits are also inherited from superclasses.
- * </p>
- *
- * @param parent a composite control which will be the parent of the new instance (cannot be null)
- * @param style the style of control to construct
- * @param index the 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 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 IllegalArgumentException <ul>
- * <li>ERROR_INVALID_ARGUMENT - if the control has been disposed</li>
- * <li>ERROR_INVALID_PARENT - if the control is not in the same widget tree</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public void setControl (Control control) {
- checkWidget();
- if (control != null) {
- if (control.isDisposed()) error (SWT.ERROR_INVALID_ARGUMENT);
- if (control.parent != parent) error (SWT.ERROR_INVALID_PARENT);
- }
- if (this.control != null && this.control.isDisposed ()) {
- this.control = null;
- }
- 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);
- /*
- * Bug in Windows. In version 6.00 of COMCTL32.DLL, tab
- * items with an image and a label that includes '&' cause
- * the tab to draw incorrectly (even when doubled '&&').
- * The image overlaps the label. The fix is to remove
- * all '&' characters from the string.
- */
- if (COMCTL32_MAJOR >= 6) {
- if (text.indexOf ('&') != -1) setText (text);
- }
- 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);
-}
-/**
- * Sets the receiver's text. The string may include
- * the mnemonic character.
- * </p>
- * <p>
- * Mnemonics are indicated by an '&amp' that causes the next
- * character to be the mnemonic. When the user presses a
- * key sequence that matches the mnemonic, a selection
- * event occurs. On most platforms, the mnemonic appears
- * underlined but may be emphasised in a platform specific
- * manner. The mnemonic indicator character '&amp' can be
- * escaped by doubling it in the string, causing a single
- *'&amp' to be displayed.
- * </p>
- *
- * @param string the new text
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the text is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- */
-public void setText (String string) {
- checkWidget();
- if (string == null) error (SWT.ERROR_NULL_ARGUMENT);
- int index = parent.indexOf (this);
- if (index == -1) return;
- super.setText (string);
- /*
- * Bug in Windows. In version 6.00 of COMCTL32.DLL, tab
- * items with an image and a label that includes '&' cause
- * the tab to draw incorrectly (even when doubled '&&').
- * The image overlaps the label. The fix is to remove
- * all '&' characters from the string.
- */
- if (COMCTL32_MAJOR >= 6 && image != null) {
- if (text.indexOf ('&') != -1) {
- int length = string.length ();
- char[] text = new char [length];
- string.getChars ( 0, length, text, 0);
- int i = 0, j = 0;
- for (i=0; i<length; i++) {
- if (text[i] != '&') text [j++] = text [i];
- }
- if (j < i) string = new String (text, 0, j);
- }
- }
- int hwnd = parent.handle;
- int hHeap = OS.GetProcessHeap ();
- TCHAR buffer = new TCHAR (parent.getCodePage (), string, true);
- int byteCount = buffer.length () * TCHAR.sizeof;
- int pszText = OS.HeapAlloc (hHeap, OS.HEAP_ZERO_MEMORY, byteCount);
- OS.MoveMemory (pszText, buffer, byteCount);
- TCITEM tcItem = new TCITEM ();
- tcItem.mask = OS.TCIF_TEXT;
- tcItem.pszText = pszText;
- 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;
-}
-
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+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;
+
+/**
+ * Constructs a new instance of this class given its parent
+ * (which must be a <code>TabFolder</code>) and a style value
+ * describing its behavior and appearance. The item is added
+ * to the end of the items maintained by its parent.
+ * <p>
+ * The style value is either one of the style constants defined in
+ * class <code>SWT</code> which is applicable to instances of this
+ * class, or must be built by <em>bitwise OR</em>'ing together
+ * (that is, using the <code>int</code> "|" operator) two or more
+ * of those <code>SWT</code> style constants. The class description
+ * lists the style constants that are applicable to the class.
+ * Style bits are also inherited from superclasses.
+ * </p>
+ *
+ * @param parent a composite control which will be the parent of the new instance (cannot be null)
+ * @param style the style of control to construct
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
+ * <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
+ * </ul>
+ *
+ * @see SWT
+ * @see Widget#checkSubclass
+ * @see Widget#getStyle
+ */
+public TabItem (TabFolder parent, int style) {
+ super (parent, style);
+ this.parent = parent;
+ parent.createItem (this, parent.getItemCount ());
+}
+
+/**
+ * Constructs a new instance of this class given its parent
+ * (which must be a <code>TabFolder</code>), a style value
+ * describing its behavior and appearance, and the index
+ * at which to place it in the items maintained by its parent.
+ * <p>
+ * The style value is either one of the style constants defined in
+ * class <code>SWT</code> which is applicable to instances of this
+ * class, or must be built by <em>bitwise OR</em>'ing together
+ * (that is, using the <code>int</code> "|" operator) two or more
+ * of those <code>SWT</code> style constants. The class description
+ * lists the style constants that are applicable to the class.
+ * Style bits are also inherited from superclasses.
+ * </p>
+ *
+ * @param parent a composite control which will be the parent of the new instance (cannot be null)
+ * @param style the style of control to construct
+ * @param index the 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 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 IllegalArgumentException <ul>
+ * <li>ERROR_INVALID_ARGUMENT - if the control has been disposed</li>
+ * <li>ERROR_INVALID_PARENT - if the control is not in the same widget tree</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setControl (Control control) {
+ checkWidget();
+ if (control != null) {
+ if (control.isDisposed()) error (SWT.ERROR_INVALID_ARGUMENT);
+ if (control.parent != parent) error (SWT.ERROR_INVALID_PARENT);
+ }
+ if (this.control != null && this.control.isDisposed ()) {
+ this.control = null;
+ }
+ 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);
+ /*
+ * Bug in Windows. In version 6.00 of COMCTL32.DLL, tab
+ * items with an image and a label that includes '&' cause
+ * the tab to draw incorrectly (even when doubled '&&').
+ * The image overlaps the label. The fix is to remove
+ * all '&' characters from the string.
+ */
+ if (COMCTL32_MAJOR >= 6) {
+ if (text.indexOf ('&') != -1) setText (text);
+ }
+ 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);
+}
+/**
+ * Sets the receiver's text. The string may include
+ * the mnemonic character.
+ * </p>
+ * <p>
+ * Mnemonics are indicated by an '&amp' that causes the next
+ * character to be the mnemonic. When the user presses a
+ * key sequence that matches the mnemonic, a selection
+ * event occurs. On most platforms, the mnemonic appears
+ * underlined but may be emphasised in a platform specific
+ * manner. The mnemonic indicator character '&amp' can be
+ * escaped by doubling it in the string, causing a single
+ *'&amp' to be displayed.
+ * </p>
+ *
+ * @param string the new text
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if the text is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ */
+public void setText (String string) {
+ checkWidget();
+ if (string == null) error (SWT.ERROR_NULL_ARGUMENT);
+ int index = parent.indexOf (this);
+ if (index == -1) return;
+ super.setText (string);
+ /*
+ * Bug in Windows. In version 6.00 of COMCTL32.DLL, tab
+ * items with an image and a label that includes '&' cause
+ * the tab to draw incorrectly (even when doubled '&&').
+ * The image overlaps the label. The fix is to remove
+ * all '&' characters from the string.
+ */
+ if (COMCTL32_MAJOR >= 6 && image != null) {
+ if (text.indexOf ('&') != -1) {
+ int length = string.length ();
+ char[] text = new char [length];
+ string.getChars ( 0, length, text, 0);
+ int i = 0, j = 0;
+ for (i=0; i<length; i++) {
+ if (text[i] != '&') text [j++] = text [i];
+ }
+ if (j < i) string = new String (text, 0, j);
+ }
+ }
+ int hwnd = parent.handle;
+ int hHeap = OS.GetProcessHeap ();
+ TCHAR buffer = new TCHAR (parent.getCodePage (), string, true);
+ int byteCount = buffer.length () * TCHAR.sizeof;
+ int pszText = OS.HeapAlloc (hHeap, OS.HEAP_ZERO_MEMORY, byteCount);
+ OS.MoveMemory (pszText, buffer, byteCount);
+ TCITEM tcItem = new TCITEM ();
+ tcItem.mask = OS.TCIF_TEXT;
+ tcItem.pszText = pszText;
+ 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
index 2d2672afb6..9107f61958 100755
--- 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
@@ -1,2512 +1,2512 @@
-package org.eclipse.swt.widgets;
-
-/*
+package org.eclipse.swt.widgets;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-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>
- * The item children that may be added to instances of this class
- * must be of type <code>TableItem</code>.
- * </p><p>
- * Note that although this class is a subclass of <code>Composite</code>,
- * it does not make sense to add <code>Control</code> children to it,
- * or set a layout on it.
- * </p><p>
- * <dl>
- * <dt><b>Styles:</b></dt>
- * <dd>SINGLE, MULTI, CHECK, FULL_SELECTION, HIDE_SELECTION</dd>
- * <dt><b>Events:</b></dt>
- * <dd>Selection, DefaultSelection</dd>
- * </dl>
- * <p>
- * Note: Only one of the styles SINGLE, and MULTI may be specified.
- * </p><p>
- * IMPORTANT: This class is <em>not</em> intended to be subclassed.
- * </p>
- */
-
-public class Table extends Composite {
- TableItem [] items;
- TableColumn [] columns;
- ImageList imageList;
- boolean ignoreSelect, dragStarted, ignoreResize, mouseDown, customDraw;
- static final int TableProc;
- static final TCHAR TableClass = new TCHAR (0, OS.WC_LISTVIEW, true);
- static {
- WNDCLASS lpWndClass = new WNDCLASS ();
- OS.GetClassInfo (0, TableClass, lpWndClass);
- TableProc = 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
- * lists the style constants that are applicable to the class.
- * Style bits are also inherited from superclasses.
- * </p>
- *
- * @param parent a composite control which will be the parent of the new instance (cannot be null)
- * @param style the style of control to construct
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
- * <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
- * </ul>
- *
- * @see SWT#SINGLE
- * @see SWT#MULTI
- * @see SWT#CHECK
- * @see SWT#FULL_SELECTION
- * @see SWT#HIDE_SELECTION
- * @see Widget#checkSubclass
- * @see Widget#getStyle
- */
-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.
- * <p>
- * When <code>widgetSelected</code> is called, the item field of the event object is valid.
- * If the reciever has <code>SWT.CHECK</code> style set and the check selection changes,
- * the event object detail field contains the value <code>SWT.CHECK</code>.
- * <code>widgetDefaultSelected</code> is typically called when an item is double-clicked.
- * The item field of the event object is valid for default selection, but the detail field is not used.
- * </p>
- *
- * @param listener the listener which should be notified
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see SelectionListener
- * @see #removeSelectionListener
- * @see SelectionEvent
- */
-public void addSelectionListener (SelectionListener listener) {
- checkWidget ();
- if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
- TypedListener typedListener = new TypedListener (listener);
- addListener (SWT.Selection,typedListener);
- addListener (SWT.DefaultSelection,typedListener);
-}
-
-int 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) {
- int empty = OS.SendMessage (handle, OS.LVM_APPROXIMATEVIEWRECT, 0, 0);
- int oneItem = OS.SendMessage (handle, OS.LVM_APPROXIMATEVIEWRECT, 1, 0);
- int width = (oneItem >> 16) - (empty >> 16), height = width;
- setCheckboxImageList (width, height);
- }
-
- /*
- * 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, TCHAR.sizeof);
- 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);
-
- /*
- * Feature in Windows. Windows does not explicitly set the orientation of
- * the header. Instead, the orientation is inherited when WS_EX_LAYOUTRTL
- * is specified for the table. This means that when both WS_EX_LAYOUTRTL
- * and WS_EX_NOINHERITLAYOUT are specified for the table, the header will
- * not be oriented correctly. The fix is to explicitly set the orientation
- * for the header.
- *
- * NOTE: WS_EX_LAYOUTRTL is not supported on Windows NT.
- */
- if ((OS.WIN32_MAJOR << 16 | OS.WIN32_MINOR) < (4 << 16 | 10)) return;
- if ((style & SWT.RIGHT_TO_LEFT) != 0) {
- int hwndHeader = OS.SendMessage (handle, OS.LVM_GETHEADER, 0, 0);
- int extStyle = OS.GetWindowLong (hwndHeader, OS.GWL_EXSTYLE);
- OS.SetWindowLong (hwndHeader, OS.GWL_EXSTYLE, extStyle | OS.WS_EX_LAYOUTRTL);
- }
-}
-
-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);
- OS.SendMessage (handle, OS.LVM_GETCOLUMN, 1, lvColumn);
- int width = lvColumn.cx;
- int cchTextMax = 1024;
- int hHeap = OS.GetProcessHeap ();
- int byteCount = cchTextMax * TCHAR.sizeof;
- int pszText = OS.HeapAlloc (hHeap, OS.HEAP_ZERO_MEMORY, byteCount);
- 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);
- items [i].text = "";
- items [i].image = null;
- }
- lvColumn.mask = OS.LVCF_TEXT | OS.LVCF_IMAGE | 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);
- lvColumn.fmt = OS.LVCFMT_IMAGE;
- lvColumn.cx = width;
- lvColumn.iImage = OS.I_IMAGENONE;
- lvColumn.pszText = lvColumn.cchTextMax = 0;
- OS.SendMessage (handle, OS.LVM_SETCOLUMN, 0, lvColumn);
- lvColumn.mask = OS.LVCF_FMT;
- lvColumn.fmt = OS.LVCFMT_LEFT;
- OS.SendMessage (handle, OS.LVM_SETCOLUMN, 0, 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) {
- item.foreground = item.background = -1;
- 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;
-}
-
-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 byteCount = cchTextMax * TCHAR.sizeof;
- int pszText = OS.HeapAlloc (hHeap, OS.HEAP_ZERO_MEMORY, byteCount);
- 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);
- TCHAR buffer = new TCHAR (getCodePage (), cchTextMax);
- OS.MoveMemory (buffer, pszText, byteCount);
- items [i].text = buffer.toString (0, buffer.strlen ());
- if (imageList != null) {
- items [i].image = imageList.get (lvItem.iImage);
- }
- }
- if (pszText != 0) OS.HeapFree (hHeap, 0, pszText);
- } else {
- int hHeap = OS.GetProcessHeap ();
- int pszText = OS.HeapAlloc (hHeap, OS.HEAP_ZERO_MEMORY, TCHAR.sizeof);
- 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) {
- 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;
- int i = 0;
- while (i < columnCount) {
- TableColumn column = columns [i];
- if (column.getImage () != null) break;
- i++;
- }
- if (i == columnCount) {
- OS.SendMessage (handle, OS.LVM_SETIMAGELIST, OS.LVSIL_SMALL, 0);
- Display display = getDisplay ();
- display.releaseImageList (imageList);
- imageList = null;
- }
- }
- customDraw = false;
- items = new TableItem [4];
- }
-}
-
-void fixCheckboxImageList () {
- /*
- * Bug in Windows. When the state image list is larger than the
- * image list, Windows incorrectly positions the state images. When
- * the table is scrolled, Windows draws garbage. The fix is to force
- * the state image list to be the same size as the image list.
- */
- if ((style & SWT.CHECK) == 0) return;
- int hImageList = OS.SendMessage (handle, OS.LVM_GETIMAGELIST, OS.LVSIL_SMALL, 0);
- if (hImageList == 0) return;
- int [] cx = new int [1], cy = new int [1];
- OS.ImageList_GetIconSize (hImageList, cx, cy);
- int hOldStateList = OS.SendMessage (handle, OS.LVM_GETIMAGELIST, OS.LVSIL_STATE, 0);
- if (hOldStateList == 0) return;
- int [] stateCx = new int [1], stateCy = new int [1];
- OS.ImageList_GetIconSize (hOldStateList, stateCx, stateCy);
- if (cx [0] == stateCx [0] && cy [0] == stateCy [0]) return;
- setCheckboxImageList (cx [0], cy [0]);
-}
-
-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 affect the receiver.
- * </p>
- *
- * @return the items in the receiver
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public 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 the height of the receiver's header
- *
- * @return the height of the header or zero if the header is not visible
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @since 2.0
- */
-public int getHeaderHeight () {
- checkWidget ();
- int hwndHeader = OS.SendMessage (handle, OS.LVM_GETHEADER, 0, 0);
- if (hwndHeader == 0) return 0;
- RECT rect = new RECT ();
- OS.GetWindowRect (hwndHeader, rect);
- return rect.bottom - rect.top;
-}
-
-/**
- * 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 point is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public TableItem getItem (Point point) {
- checkWidget ();
- if (point == null) error (SWT.ERROR_NULL_ARGUMENT);
- 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 affect the receiver.
- * </p>
- *
- * @return the items in the receiver
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public TableItem [] getItems () {
- checkWidget ();
- 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 affect the receiver.
- * </p>
- * @return an array representing the selection
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public TableItem [] getSelection () {
- checkWidget ();
- int 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 affect the receiver.
- * </p>
- * @return the array of indices of the selected items
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public int [] getSelectionIndices () {
- checkWidget ();
- int 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) {
- Rectangle bounds = image.getBounds ();
- imageList = getDisplay ().getImageList (new Point (bounds.width, bounds.height));
- int index = imageList.indexOf (image);
- if (index == -1) index = imageList.add (image);
- int hImageList = imageList.getHandle ();
- OS.SendMessage (handle, OS.LVM_SETIMAGELIST, OS.LVSIL_SMALL, hImageList);
- return index;
- }
- int index = imageList.indexOf (image);
- if (index != -1) return index;
- return imageList.add (image);
-}
-
-/**
- * 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.releaseResources ();
- }
- columns = null;
- int itemCount = OS.SendMessage (handle, OS.LVM_GETITEMCOUNT, 0, 0);
-
- /*
- * Feature in Windows. When there are a large number
- * of columns and items in a table (>1000) where each
- * of the subitems in the table has a string, it is much
- * faster to delete each item with LVM_DELETEITEM rather
- * than using LVM_DELETEALLITEMS. The fix is to detect
- * this case and delete the items, one by one.
- *
- * NOTE: LVM_DELETEALLITEMS is also sent by the table
- * when the table is destroyed.
- */
- if (columnCount > 1) {
- /* Turn off redraw and leave it off */
- OS.SendMessage (handle, OS.WM_SETREDRAW, 0, 0);
- for (int i=itemCount-1; i>=0; --i) {
- ignoreSelect = true;
- OS.SendMessage (handle, OS.LVM_DELETEITEM, i, 0);
- ignoreSelect = false;
- TableItem item = items [i];
- if (!item.isDisposed ()) item.releaseResources ();
- }
- } else {
- for (int i=0; i<itemCount; i++) {
- TableItem item = items [i];
- if (!item.isDisposed ()) item.releaseResources ();
- }
- }
- customDraw = false;
- items = null;
- if (imageList != null) {
- OS.SendMessage (handle, OS.LVM_SETIMAGELIST, OS.LVSIL_SMALL, 0);
- Display display = getDisplay ();
- display.releaseImageList (imageList);
- }
- 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);
- super.releaseWidget ();
-}
-
-/**
- * Removes the items from the receiver's list at the given
- * zero-relative indices.
- *
- * @param indices the array of indices of the items
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_INVALID_RANGE - if the index is not between 0 and the number of elements in the list minus 1 (inclusive)</li>
- * <li>ERROR_NULL_ARGUMENT - if the indices array is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- * @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].releaseResources ();
- 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.releaseResources ();
-}
-
-/**
- * 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 = start;
- while (index <= end) {
- ignoreSelect = true;
- int code = OS.SendMessage (handle, OS.LVM_DELETEITEM, start, 0);
- ignoreSelect = false;
- if (code == 0) break;
-
- // BUG - disposed callback could remove an item
- items [index].releaseResources ();
- index++;
- }
- System.arraycopy (items, index, items, start, count - index);
- for (int i=count-(index-start); i<count; i++) items [i] = null;
- if (index <= end) {
- if (0 <= index && index < count) {
- error (SWT.ERROR_ITEM_NOT_REMOVED);
- } else {
- error (SWT.ERROR_INVALID_RANGE);
- }
- }
-}
-
-/**
- * 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 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;
- int itemCount = OS.SendMessage (handle, OS.LVM_GETITEMCOUNT, 0, 0);
-
- /*
- * Feature in Windows. When there are a large number
- * of columns and items in a table (>1000) where each
- * of the subitems in the table has a string, it is much
- * faster to delete each item with LVM_DELETEITEM rather
- * than using LVM_DELETEALLITEMS. The fix is to detect
- * this case and delete the items, one by one.
- *
- * NOTE: LVM_DELETEALLITEMS is also sent by the table
- * when the table is destroyed.
- */
- if (columnCount > 1) {
- boolean redraw = drawCount == 0 && OS.IsWindowVisible (handle);
- if (redraw) OS.SendMessage (handle, OS.WM_SETREDRAW, 0, 0);
- int index = itemCount - 1;
- while (index >= 0) {
- 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].releaseResources ();
- --index;
- }
- if (redraw) {
- 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 so it is not necessary to do this
- * again.
- */
-// int flags = OS.RDW_ERASE | OS.RDW_FRAME | OS.RDW_INVALIDATE;
-// OS.RedrawWindow (handle, null, 0, flags);
- }
- if (index != -1) error (SWT.ERROR_ITEM_NOT_REMOVED);
- } else {
- 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<itemCount; i++) {
- TableItem item = items [i];
- if (!item.isDisposed ()) item.releaseResources ();
- }
- }
-
- if (imageList != null) {
- int i = 0;
- while (i < columnCount) {
- TableColumn column = columns [i];
- if (column.getImage () != null) break;
- i++;
- }
- if (i == columnCount) {
- OS.SendMessage (handle, OS.LVM_SETIMAGELIST, OS.LVSIL_SMALL, 0);
- Display display = getDisplay ();
- display.releaseImageList (imageList);
- imageList = null;
- }
- }
- customDraw = false;
- 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 array of indices is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-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 and no items will be selected if start is
- * greater than end.
- *
- * @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. When a table item is reselected,
- * the table does not issue a WM_NOTIFY when 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.
- */
- boolean wasSelected = false;
- int count = OS.SendMessage (handle, OS.LVM_GETSELECTEDCOUNT, 0, 0);
- if (count == 1 && 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);
- wasSelected = (lvItem.state & OS.LVIS_SELECTED) != 0;
- if (wasSelected) ignoreSelect = true;
- }
- dragStarted = false;
- int code = callWindowProc (msg, wParam, lParam);
- if (wasSelected) {
- ignoreSelect = false;
- 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) {
- mouseDown = false;
- 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 ((style & SWT.CHECK) != 0) setCheckboxImageListColor ();
-
- /*
- * 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 setCheckboxImageListColor () {
- if ((style & SWT.CHECK) == 0) return;
- int hOldStateList = OS.SendMessage (handle, OS.LVM_GETIMAGELIST, OS.LVSIL_STATE, 0);
- if (hOldStateList == 0) return;
- int [] cx = new int [1], cy = new int [1];
- OS.ImageList_GetIconSize (hOldStateList, cx, cy);
- setCheckboxImageList (cx [0], cy [0]);
-}
-
-void setCheckboxImageList (int width, int height) {
- if ((style & SWT.CHECK) == 0) return;
- int count = 4;
- int hStateList = 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 (hStateList, hBitmap, 0);
- OS.DeleteObject (hBitmap);
- int hOldStateList = OS.SendMessage (handle, OS.LVM_GETIMAGELIST, OS.LVSIL_STATE, 0);
- OS.SendMessage (handle, OS.LVM_SETIMAGELIST, OS.LVSIL_STATE, hStateList);
- if (hOldStateList != 0) OS.ImageList_Destroy (hOldStateList);
-}
-
-void setFocusIndex (int index) {
- LVITEM lvItem = new LVITEM ();
- lvItem.mask = OS.LVIF_STATE;
- lvItem.state = OS.LVIS_FOCUSED;
- lvItem.stateMask = OS.LVIS_FOCUSED;
- lvItem.iItem = index;
- ignoreSelect = true;
- OS.SendMessage (handle, OS.LVM_SETITEM, 0, lvItem);
- ignoreSelect = false;
-}
-
-public void setFont (Font font) {
- checkWidget ();
- super.setFont (font);
- setScrollWidth ();
- /*
- * Bug in Windows. Setting the font will cause the
- * table area to be redrawn but not the column headers.
- * Fix is to force a redraw on the column headers.
- */
- int hwndHeader = OS.SendMessage (handle, OS.LVM_GETHEADER, 0, 0);
- OS.InvalidateRect (hwndHeader, null, true);
- 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 ();
-
- /*
- * Bug in Windows. For some reason, when WM_SETREDRAW is used
- * to turn redraw back on this may result in a WM_SIZE. If the
- * table column widths are adjusted in WM_SIZE, blank lines may
- * be inserted at the top of the widget. A call to LVM_GETTOPINDEX
- * will return a negative number (this is an impossible result).
- * The fix is to ignore any resize generated by WM_SETREDRAW and
- * defer the work until the WM_SETREDRAW has returned.
- */
- ignoreResize = true;
- OS.SendMessage (handle, OS.WM_SETREDRAW, 1, 0);
- if (!ignoreResize) {
- setResizeChildren (false);
- sendEvent (SWT.Resize);
- // widget may be disposed at this point
- if (isDisposed ()) return;
- if (layout != null) layout.layout (this, false);
- setResizeChildren (true);
- }
- ignoreResize = false;
-
- /*
- * 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.
- *
- * NOTE: The window proc for the table does not redraw the
- * non-client area (ie. the border and scroll bars). This
- * must be explicitly redrawn. This code can be removed
- * if we stop relying on the undocuemented behavior.
- */
- if (OS.IsWinCE) {
- OS.InvalidateRect (handle, null, false);
- } else {
- OS.RedrawWindow (handle, null, 0, OS.RDW_FRAME | OS.RDW_INVALIDATE);
- }
-// 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 array of indices is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see Table#deselectAll()
- * @see Table#select(int[])
- */
-public void setSelection (int [] indices) {
- checkWidget ();
- if (indices == null) error (SWT.ERROR_NULL_ARGUMENT);
- deselectAll ();
- select (indices);
- if (indices.length != 0) {
- int focusIndex = indices [0];
- if (focusIndex != -1) setFocusIndex (focusIndex);
- }
- showSelection ();
-}
-
-/**
- * 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 array of items is null</li>
- * <li>ERROR_INVALID_ARGUMENT - if one of the item has been disposed</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see 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;
- int focusIndex = -1;
- if ((style & SWT.SINGLE) != 0) length = 1;
- for (int i=length-1; i>=0; --i) {
- int index = indexOf (items [i]);
- if (index != -1) {
- select (focusIndex = index);
- }
- }
- if (focusIndex != -1) setFocusIndex (focusIndex);
- showSelection ();
-}
-
-/**
- * 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) {
- checkWidget ();
- deselectAll ();
- select (index);
- if (index != -1) setFocusIndex (index);
- showSelection ();
-}
-
-/**
- * Selects the items at the given zero-relative indices in the receiver.
- * The current selection is first cleared, then the new items are selected.
- * Indices that are out of range are ignored and no items will be selected
- * if start is greater than end.
- *
- * @param start the start index of the items to select
- * @param end the end index of the items to select
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see Table#deselectAll()
- * @see Table#select(int,int)
- */
-public void setSelection (int start, int end) {
- checkWidget ();
- deselectAll ();
- select (start, end);
- /*
- * NOTE: This code relies on the select (int, int)
- * selecting the last item in the range for a single
- * selection table.
- */
- int focusIndex = (style & SWT.SINGLE) != 0 ? end : start;
- if (focusIndex != -1) setFocusIndex (focusIndex);
- showSelection ();
-}
-
-/**
- * Sets the zero-relative index of the item which is currently
- * at the top of the receiver. This index can change when items
- * are scrolled or new items are added and removed.
- *
- * @param index the index of the top item
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public void setTopIndex (int index) {
- checkWidget ();
- 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);
-}
-
-void showItem (int index) {
- /*
- * Bug in Windows. For some reason, when there is insufficient space
- * to show an item, LVM_ENSUREVISIBLE causes blank lines to be
- * inserted at the top of the widget. A call to LVM_GETTOPINDEX will
- * return a negative number (this is an impossible result). The fix
- * is to use LVM_GETCOUNTPERPAGE to detect the case when the number
- * of visible items is zero and use LVM_ENSUREVISIBLE with the fPartialOK
- * flag to scroll the table.
- */
- 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);
- }
- } else {
- OS.SendMessage (handle, OS.LVM_ENSUREVISIBLE, index, 0);
- }
-}
-
-/**
- * Shows the item. If the item is already showing in the receiver,
- * this method simply returns. Otherwise, the items are scrolled until
- * the item is visible.
- *
- * @param item the item to be shown
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the item is null</li>
- * <li>ERROR_INVALID_ARGUMENT - if the item has been disposed</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see Table#showSelection()
- */
-public void showItem (TableItem item) {
- checkWidget ();
- if (item == null) error (SWT.ERROR_NULL_ARGUMENT);
- if (item.isDisposed()) error(SWT.ERROR_INVALID_ARGUMENT);
- int index = indexOf (item);
- if (index != -1) showItem (index);
-}
-
-/**
- * Shows the selection. If the selection is already showing in the receiver,
- * this method simply returns. Otherwise, the items are scrolled until
- * the selection is visible.
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see Table#showItem(TableItem)
- */
-public void showSelection () {
- checkWidget ();
- int index = OS.SendMessage (handle, OS.LVM_GETNEXTITEM, -1, OS.LVNI_SELECTED);
- if (index != -1) showItem (index);
-}
-
-int widgetStyle () {
- int bits = super.widgetStyle () | 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;
-}
-
-TCHAR windowClass () {
- return TableClass;
-}
-
-int windowProc () {
- return TableProc;
-}
-
-LRESULT WM_GETOBJECT (int wParam, int lParam) {
- /*
- * Ensure that there is an accessible object created for this
- * control because support for checked item accessibility is
- * temporarily implemented in the accessibility package.
- */
- if ((style & SWT.CHECK) != 0) {
- if (accessible == null) accessible = new_Accessible (this);
- }
- return super.WM_GETOBJECT (wParam, lParam);
-}
-
-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) {
- mouseDown = true;
-
- /*
- * 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_LBUTTONUP (int wParam, int lParam) {
- mouseDown = false;
- return super.WM_LBUTTONUP (wParam, lParam);
-}
-
-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_BEGINTRACKA:
- case OS.HDN_DIVIDERDBLCLICKW:
- case OS.HDN_DIVIDERDBLCLICKA:{
- NMHEADER phdn = new NMHEADER ();
- OS.MoveMemory (phdn, lParam, NMHEADER.sizeof);
- TableColumn column = columns [phdn.iItem];
- if (column != null && !column.getResizable ()) {
- return LRESULT.ONE;
- }
- break;
- }
- case OS.HDN_ITEMCHANGEDW:
- case OS.HDN_ITEMCHANGEDA: {
- 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);
- /*
- * 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_SIZE (int wParam, int lParam) {
- if (ignoreResize) {
- ignoreResize = false;
- int code = callWindowProc (OS.WM_SIZE, wParam, lParam);
- return new LRESULT (code);
- }
- return super.WM_SIZE (wParam, lParam);
-}
-
-LRESULT WM_SYSCOLORCHANGE (int wParam, int lParam) {
- LRESULT result = super.WM_SYSCOLORCHANGE (wParam, lParam);
- if (result != null) return result;
- if ((style & SWT.CHECK) != 0) setCheckboxImageListColor ();
- return result;
-}
-
-LRESULT wmNotifyChild (int wParam, int lParam) {
- NMHDR hdr = new NMHDR ();
- OS.MoveMemory (hdr, lParam, NMHDR.sizeof);
- switch (hdr.code) {
- case OS.NM_CUSTOMDRAW: {
- if (!customDraw) break;
- NMLVCUSTOMDRAW nmcd = new NMLVCUSTOMDRAW ();
- OS.MoveMemory (nmcd, lParam, NMLVCUSTOMDRAW.sizeof);
- switch (nmcd.dwDrawStage) {
- case OS.CDDS_PREPAINT: return new LRESULT (OS.CDRF_NOTIFYITEMDRAW);
- case OS.CDDS_ITEMPREPAINT: return new LRESULT (OS.CDRF_NOTIFYSUBITEMDRAW);
- case OS.CDDS_ITEMPREPAINT | OS.CDDS_SUBITEM: {
- TableItem item = items [nmcd.dwItemSpec];
- int clrText = item.foreground, clrTextBk = item.background;
- if (clrText == -1 && clrTextBk == -1) break;
- nmcd.clrText = clrText == -1 ? getForegroundPixel () : clrText;
- nmcd.clrTextBk = clrTextBk == -1 ? getBackgroundPixel () : clrTextBk;
- OS.MoveMemory (lParam, nmcd, NMLVCUSTOMDRAW.sizeof);
- return new LRESULT (OS.CDRF_NEWFONT);
- }
- }
- break;
- }
- case OS.LVN_MARQUEEBEGIN: return LRESULT.ONE;
- case OS.LVN_BEGINDRAG:
- case OS.LVN_BEGINRDRAG: {
- dragStarted = true;
- if (hdr.code == OS.LVN_BEGINDRAG) {
- postEvent (SWT.DragDetect);
- }
- 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 (OS.GetKeyState (OS.VK_CONTROL) < 0) {
- if (!isFocus) {
- if (index == pnmlv.iItem) {
- boolean isSelected = (pnmlv.uNewState & OS.LVIS_SELECTED) != 0;
- boolean wasSelected = (pnmlv.uOldState & OS.LVIS_SELECTED) != 0;
- isFocus = isSelected != wasSelected;
- }
- } else {
- isFocus = mouseDown;
- }
- }
- }
- if (OS.GetKeyState (OS.VK_SPACE) < 0) isFocus = true;
- if (isFocus) {
- Event event = new Event();
- if (index != -1) {
- /*
- * This code is intentionally commented.
- */
-// OS.SendMessage (handle, OS.LVM_ENSUREVISIBLE, index, 0);
- event.item = items [index];
- }
- postEvent (SWT.Selection, event);
- }
- }
- }
- }
- break;
- }
- }
- return super.wmNotifyChild (wParam, lParam);
-}
-
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+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>
+ * The item children that may be added to instances of this class
+ * must be of type <code>TableItem</code>.
+ * </p><p>
+ * Note that although this class is a subclass of <code>Composite</code>,
+ * it does not make sense to add <code>Control</code> children to it,
+ * or set a layout on it.
+ * </p><p>
+ * <dl>
+ * <dt><b>Styles:</b></dt>
+ * <dd>SINGLE, MULTI, CHECK, FULL_SELECTION, HIDE_SELECTION</dd>
+ * <dt><b>Events:</b></dt>
+ * <dd>Selection, DefaultSelection</dd>
+ * </dl>
+ * <p>
+ * Note: Only one of the styles SINGLE, and MULTI may be specified.
+ * </p><p>
+ * IMPORTANT: This class is <em>not</em> intended to be subclassed.
+ * </p>
+ */
+
+public class Table extends Composite {
+ TableItem [] items;
+ TableColumn [] columns;
+ ImageList imageList;
+ boolean ignoreSelect, dragStarted, ignoreResize, mouseDown, customDraw;
+ static final int TableProc;
+ static final TCHAR TableClass = new TCHAR (0, OS.WC_LISTVIEW, true);
+ static {
+ WNDCLASS lpWndClass = new WNDCLASS ();
+ OS.GetClassInfo (0, TableClass, lpWndClass);
+ TableProc = 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
+ * lists the style constants that are applicable to the class.
+ * Style bits are also inherited from superclasses.
+ * </p>
+ *
+ * @param parent a composite control which will be the parent of the new instance (cannot be null)
+ * @param style the style of control to construct
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
+ * <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
+ * </ul>
+ *
+ * @see SWT#SINGLE
+ * @see SWT#MULTI
+ * @see SWT#CHECK
+ * @see SWT#FULL_SELECTION
+ * @see SWT#HIDE_SELECTION
+ * @see Widget#checkSubclass
+ * @see Widget#getStyle
+ */
+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.
+ * <p>
+ * When <code>widgetSelected</code> is called, the item field of the event object is valid.
+ * If the reciever has <code>SWT.CHECK</code> style set and the check selection changes,
+ * the event object detail field contains the value <code>SWT.CHECK</code>.
+ * <code>widgetDefaultSelected</code> is typically called when an item is double-clicked.
+ * The item field of the event object is valid for default selection, but the detail field is not used.
+ * </p>
+ *
+ * @param listener the listener which should be notified
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see SelectionListener
+ * @see #removeSelectionListener
+ * @see SelectionEvent
+ */
+public void addSelectionListener (SelectionListener listener) {
+ checkWidget ();
+ if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+ TypedListener typedListener = new TypedListener (listener);
+ addListener (SWT.Selection,typedListener);
+ addListener (SWT.DefaultSelection,typedListener);
+}
+
+int 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) {
+ int empty = OS.SendMessage (handle, OS.LVM_APPROXIMATEVIEWRECT, 0, 0);
+ int oneItem = OS.SendMessage (handle, OS.LVM_APPROXIMATEVIEWRECT, 1, 0);
+ int width = (oneItem >> 16) - (empty >> 16), height = width;
+ setCheckboxImageList (width, height);
+ }
+
+ /*
+ * 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, TCHAR.sizeof);
+ 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);
+
+ /*
+ * Feature in Windows. Windows does not explicitly set the orientation of
+ * the header. Instead, the orientation is inherited when WS_EX_LAYOUTRTL
+ * is specified for the table. This means that when both WS_EX_LAYOUTRTL
+ * and WS_EX_NOINHERITLAYOUT are specified for the table, the header will
+ * not be oriented correctly. The fix is to explicitly set the orientation
+ * for the header.
+ *
+ * NOTE: WS_EX_LAYOUTRTL is not supported on Windows NT.
+ */
+ if ((OS.WIN32_MAJOR << 16 | OS.WIN32_MINOR) < (4 << 16 | 10)) return;
+ if ((style & SWT.RIGHT_TO_LEFT) != 0) {
+ int hwndHeader = OS.SendMessage (handle, OS.LVM_GETHEADER, 0, 0);
+ int extStyle = OS.GetWindowLong (hwndHeader, OS.GWL_EXSTYLE);
+ OS.SetWindowLong (hwndHeader, OS.GWL_EXSTYLE, extStyle | OS.WS_EX_LAYOUTRTL);
+ }
+}
+
+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);
+ OS.SendMessage (handle, OS.LVM_GETCOLUMN, 1, lvColumn);
+ int width = lvColumn.cx;
+ int cchTextMax = 1024;
+ int hHeap = OS.GetProcessHeap ();
+ int byteCount = cchTextMax * TCHAR.sizeof;
+ int pszText = OS.HeapAlloc (hHeap, OS.HEAP_ZERO_MEMORY, byteCount);
+ 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);
+ items [i].text = "";
+ items [i].image = null;
+ }
+ lvColumn.mask = OS.LVCF_TEXT | OS.LVCF_IMAGE | 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);
+ lvColumn.fmt = OS.LVCFMT_IMAGE;
+ lvColumn.cx = width;
+ lvColumn.iImage = OS.I_IMAGENONE;
+ lvColumn.pszText = lvColumn.cchTextMax = 0;
+ OS.SendMessage (handle, OS.LVM_SETCOLUMN, 0, lvColumn);
+ lvColumn.mask = OS.LVCF_FMT;
+ lvColumn.fmt = OS.LVCFMT_LEFT;
+ OS.SendMessage (handle, OS.LVM_SETCOLUMN, 0, 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) {
+ item.foreground = item.background = -1;
+ 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;
+}
+
+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 byteCount = cchTextMax * TCHAR.sizeof;
+ int pszText = OS.HeapAlloc (hHeap, OS.HEAP_ZERO_MEMORY, byteCount);
+ 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);
+ TCHAR buffer = new TCHAR (getCodePage (), cchTextMax);
+ OS.MoveMemory (buffer, pszText, byteCount);
+ items [i].text = buffer.toString (0, buffer.strlen ());
+ if (imageList != null) {
+ items [i].image = imageList.get (lvItem.iImage);
+ }
+ }
+ if (pszText != 0) OS.HeapFree (hHeap, 0, pszText);
+ } else {
+ int hHeap = OS.GetProcessHeap ();
+ int pszText = OS.HeapAlloc (hHeap, OS.HEAP_ZERO_MEMORY, TCHAR.sizeof);
+ 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) {
+ 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;
+ int i = 0;
+ while (i < columnCount) {
+ TableColumn column = columns [i];
+ if (column.getImage () != null) break;
+ i++;
+ }
+ if (i == columnCount) {
+ OS.SendMessage (handle, OS.LVM_SETIMAGELIST, OS.LVSIL_SMALL, 0);
+ Display display = getDisplay ();
+ display.releaseImageList (imageList);
+ imageList = null;
+ }
+ }
+ customDraw = false;
+ items = new TableItem [4];
+ }
+}
+
+void fixCheckboxImageList () {
+ /*
+ * Bug in Windows. When the state image list is larger than the
+ * image list, Windows incorrectly positions the state images. When
+ * the table is scrolled, Windows draws garbage. The fix is to force
+ * the state image list to be the same size as the image list.
+ */
+ if ((style & SWT.CHECK) == 0) return;
+ int hImageList = OS.SendMessage (handle, OS.LVM_GETIMAGELIST, OS.LVSIL_SMALL, 0);
+ if (hImageList == 0) return;
+ int [] cx = new int [1], cy = new int [1];
+ OS.ImageList_GetIconSize (hImageList, cx, cy);
+ int hOldStateList = OS.SendMessage (handle, OS.LVM_GETIMAGELIST, OS.LVSIL_STATE, 0);
+ if (hOldStateList == 0) return;
+ int [] stateCx = new int [1], stateCy = new int [1];
+ OS.ImageList_GetIconSize (hOldStateList, stateCx, stateCy);
+ if (cx [0] == stateCx [0] && cy [0] == stateCy [0]) return;
+ setCheckboxImageList (cx [0], cy [0]);
+}
+
+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 affect the receiver.
+ * </p>
+ *
+ * @return the items in the receiver
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public 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 the height of the receiver's header
+ *
+ * @return the height of the header or zero if the header is not visible
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @since 2.0
+ */
+public int getHeaderHeight () {
+ checkWidget ();
+ int hwndHeader = OS.SendMessage (handle, OS.LVM_GETHEADER, 0, 0);
+ if (hwndHeader == 0) return 0;
+ RECT rect = new RECT ();
+ OS.GetWindowRect (hwndHeader, rect);
+ return rect.bottom - rect.top;
+}
+
+/**
+ * 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 point is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public TableItem getItem (Point point) {
+ checkWidget ();
+ if (point == null) error (SWT.ERROR_NULL_ARGUMENT);
+ 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 affect the receiver.
+ * </p>
+ *
+ * @return the items in the receiver
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public TableItem [] getItems () {
+ checkWidget ();
+ 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 affect the receiver.
+ * </p>
+ * @return an array representing the selection
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public TableItem [] getSelection () {
+ checkWidget ();
+ int 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 affect the receiver.
+ * </p>
+ * @return the array of indices of the selected items
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public int [] getSelectionIndices () {
+ checkWidget ();
+ int 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) {
+ Rectangle bounds = image.getBounds ();
+ imageList = getDisplay ().getImageList (new Point (bounds.width, bounds.height));
+ int index = imageList.indexOf (image);
+ if (index == -1) index = imageList.add (image);
+ int hImageList = imageList.getHandle ();
+ OS.SendMessage (handle, OS.LVM_SETIMAGELIST, OS.LVSIL_SMALL, hImageList);
+ return index;
+ }
+ int index = imageList.indexOf (image);
+ if (index != -1) return index;
+ return imageList.add (image);
+}
+
+/**
+ * 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.releaseResources ();
+ }
+ columns = null;
+ int itemCount = OS.SendMessage (handle, OS.LVM_GETITEMCOUNT, 0, 0);
+
+ /*
+ * Feature in Windows. When there are a large number
+ * of columns and items in a table (>1000) where each
+ * of the subitems in the table has a string, it is much
+ * faster to delete each item with LVM_DELETEITEM rather
+ * than using LVM_DELETEALLITEMS. The fix is to detect
+ * this case and delete the items, one by one.
+ *
+ * NOTE: LVM_DELETEALLITEMS is also sent by the table
+ * when the table is destroyed.
+ */
+ if (columnCount > 1) {
+ /* Turn off redraw and leave it off */
+ OS.SendMessage (handle, OS.WM_SETREDRAW, 0, 0);
+ for (int i=itemCount-1; i>=0; --i) {
+ ignoreSelect = true;
+ OS.SendMessage (handle, OS.LVM_DELETEITEM, i, 0);
+ ignoreSelect = false;
+ TableItem item = items [i];
+ if (!item.isDisposed ()) item.releaseResources ();
+ }
+ } else {
+ for (int i=0; i<itemCount; i++) {
+ TableItem item = items [i];
+ if (!item.isDisposed ()) item.releaseResources ();
+ }
+ }
+ customDraw = false;
+ items = null;
+ if (imageList != null) {
+ OS.SendMessage (handle, OS.LVM_SETIMAGELIST, OS.LVSIL_SMALL, 0);
+ Display display = getDisplay ();
+ display.releaseImageList (imageList);
+ }
+ 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);
+ super.releaseWidget ();
+}
+
+/**
+ * Removes the items from the receiver's list at the given
+ * zero-relative indices.
+ *
+ * @param indices the array of indices of the items
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_INVALID_RANGE - if the index is not between 0 and the number of elements in the list minus 1 (inclusive)</li>
+ * <li>ERROR_NULL_ARGUMENT - if the indices array is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * @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].releaseResources ();
+ 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.releaseResources ();
+}
+
+/**
+ * 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 = start;
+ while (index <= end) {
+ ignoreSelect = true;
+ int code = OS.SendMessage (handle, OS.LVM_DELETEITEM, start, 0);
+ ignoreSelect = false;
+ if (code == 0) break;
+
+ // BUG - disposed callback could remove an item
+ items [index].releaseResources ();
+ index++;
+ }
+ System.arraycopy (items, index, items, start, count - index);
+ for (int i=count-(index-start); i<count; i++) items [i] = null;
+ if (index <= end) {
+ if (0 <= index && index < count) {
+ error (SWT.ERROR_ITEM_NOT_REMOVED);
+ } else {
+ error (SWT.ERROR_INVALID_RANGE);
+ }
+ }
+}
+
+/**
+ * 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 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;
+ int itemCount = OS.SendMessage (handle, OS.LVM_GETITEMCOUNT, 0, 0);
+
+ /*
+ * Feature in Windows. When there are a large number
+ * of columns and items in a table (>1000) where each
+ * of the subitems in the table has a string, it is much
+ * faster to delete each item with LVM_DELETEITEM rather
+ * than using LVM_DELETEALLITEMS. The fix is to detect
+ * this case and delete the items, one by one.
+ *
+ * NOTE: LVM_DELETEALLITEMS is also sent by the table
+ * when the table is destroyed.
+ */
+ if (columnCount > 1) {
+ boolean redraw = drawCount == 0 && OS.IsWindowVisible (handle);
+ if (redraw) OS.SendMessage (handle, OS.WM_SETREDRAW, 0, 0);
+ int index = itemCount - 1;
+ while (index >= 0) {
+ 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].releaseResources ();
+ --index;
+ }
+ if (redraw) {
+ 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 so it is not necessary to do this
+ * again.
+ */
+// int flags = OS.RDW_ERASE | OS.RDW_FRAME | OS.RDW_INVALIDATE;
+// OS.RedrawWindow (handle, null, 0, flags);
+ }
+ if (index != -1) error (SWT.ERROR_ITEM_NOT_REMOVED);
+ } else {
+ 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<itemCount; i++) {
+ TableItem item = items [i];
+ if (!item.isDisposed ()) item.releaseResources ();
+ }
+ }
+
+ if (imageList != null) {
+ int i = 0;
+ while (i < columnCount) {
+ TableColumn column = columns [i];
+ if (column.getImage () != null) break;
+ i++;
+ }
+ if (i == columnCount) {
+ OS.SendMessage (handle, OS.LVM_SETIMAGELIST, OS.LVSIL_SMALL, 0);
+ Display display = getDisplay ();
+ display.releaseImageList (imageList);
+ imageList = null;
+ }
+ }
+ customDraw = false;
+ 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 array of indices is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+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 and no items will be selected if start is
+ * greater than end.
+ *
+ * @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. When a table item is reselected,
+ * the table does not issue a WM_NOTIFY when 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.
+ */
+ boolean wasSelected = false;
+ int count = OS.SendMessage (handle, OS.LVM_GETSELECTEDCOUNT, 0, 0);
+ if (count == 1 && 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);
+ wasSelected = (lvItem.state & OS.LVIS_SELECTED) != 0;
+ if (wasSelected) ignoreSelect = true;
+ }
+ dragStarted = false;
+ int code = callWindowProc (msg, wParam, lParam);
+ if (wasSelected) {
+ ignoreSelect = false;
+ 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) {
+ mouseDown = false;
+ 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 ((style & SWT.CHECK) != 0) setCheckboxImageListColor ();
+
+ /*
+ * 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 setCheckboxImageListColor () {
+ if ((style & SWT.CHECK) == 0) return;
+ int hOldStateList = OS.SendMessage (handle, OS.LVM_GETIMAGELIST, OS.LVSIL_STATE, 0);
+ if (hOldStateList == 0) return;
+ int [] cx = new int [1], cy = new int [1];
+ OS.ImageList_GetIconSize (hOldStateList, cx, cy);
+ setCheckboxImageList (cx [0], cy [0]);
+}
+
+void setCheckboxImageList (int width, int height) {
+ if ((style & SWT.CHECK) == 0) return;
+ int count = 4;
+ int hStateList = 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 (hStateList, hBitmap, 0);
+ OS.DeleteObject (hBitmap);
+ int hOldStateList = OS.SendMessage (handle, OS.LVM_GETIMAGELIST, OS.LVSIL_STATE, 0);
+ OS.SendMessage (handle, OS.LVM_SETIMAGELIST, OS.LVSIL_STATE, hStateList);
+ if (hOldStateList != 0) OS.ImageList_Destroy (hOldStateList);
+}
+
+void setFocusIndex (int index) {
+ LVITEM lvItem = new LVITEM ();
+ lvItem.mask = OS.LVIF_STATE;
+ lvItem.state = OS.LVIS_FOCUSED;
+ lvItem.stateMask = OS.LVIS_FOCUSED;
+ lvItem.iItem = index;
+ ignoreSelect = true;
+ OS.SendMessage (handle, OS.LVM_SETITEM, 0, lvItem);
+ ignoreSelect = false;
+}
+
+public void setFont (Font font) {
+ checkWidget ();
+ super.setFont (font);
+ setScrollWidth ();
+ /*
+ * Bug in Windows. Setting the font will cause the
+ * table area to be redrawn but not the column headers.
+ * Fix is to force a redraw on the column headers.
+ */
+ int hwndHeader = OS.SendMessage (handle, OS.LVM_GETHEADER, 0, 0);
+ OS.InvalidateRect (hwndHeader, null, true);
+ 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 ();
+
+ /*
+ * Bug in Windows. For some reason, when WM_SETREDRAW is used
+ * to turn redraw back on this may result in a WM_SIZE. If the
+ * table column widths are adjusted in WM_SIZE, blank lines may
+ * be inserted at the top of the widget. A call to LVM_GETTOPINDEX
+ * will return a negative number (this is an impossible result).
+ * The fix is to ignore any resize generated by WM_SETREDRAW and
+ * defer the work until the WM_SETREDRAW has returned.
+ */
+ ignoreResize = true;
+ OS.SendMessage (handle, OS.WM_SETREDRAW, 1, 0);
+ if (!ignoreResize) {
+ setResizeChildren (false);
+ sendEvent (SWT.Resize);
+ // widget may be disposed at this point
+ if (isDisposed ()) return;
+ if (layout != null) layout.layout (this, false);
+ setResizeChildren (true);
+ }
+ ignoreResize = false;
+
+ /*
+ * 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.
+ *
+ * NOTE: The window proc for the table does not redraw the
+ * non-client area (ie. the border and scroll bars). This
+ * must be explicitly redrawn. This code can be removed
+ * if we stop relying on the undocuemented behavior.
+ */
+ if (OS.IsWinCE) {
+ OS.InvalidateRect (handle, null, false);
+ } else {
+ OS.RedrawWindow (handle, null, 0, OS.RDW_FRAME | OS.RDW_INVALIDATE);
+ }
+// 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 array of indices is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see Table#deselectAll()
+ * @see Table#select(int[])
+ */
+public void setSelection (int [] indices) {
+ checkWidget ();
+ if (indices == null) error (SWT.ERROR_NULL_ARGUMENT);
+ deselectAll ();
+ select (indices);
+ if (indices.length != 0) {
+ int focusIndex = indices [0];
+ if (focusIndex != -1) setFocusIndex (focusIndex);
+ }
+ showSelection ();
+}
+
+/**
+ * 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 array of items is null</li>
+ * <li>ERROR_INVALID_ARGUMENT - if one of the item has been disposed</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see 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;
+ int focusIndex = -1;
+ if ((style & SWT.SINGLE) != 0) length = 1;
+ for (int i=length-1; i>=0; --i) {
+ int index = indexOf (items [i]);
+ if (index != -1) {
+ select (focusIndex = index);
+ }
+ }
+ if (focusIndex != -1) setFocusIndex (focusIndex);
+ showSelection ();
+}
+
+/**
+ * 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) {
+ checkWidget ();
+ deselectAll ();
+ select (index);
+ if (index != -1) setFocusIndex (index);
+ showSelection ();
+}
+
+/**
+ * Selects the items at the given zero-relative indices in the receiver.
+ * The current selection is first cleared, then the new items are selected.
+ * Indices that are out of range are ignored and no items will be selected
+ * if start is greater than end.
+ *
+ * @param start the start index of the items to select
+ * @param end the end index of the items to select
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see Table#deselectAll()
+ * @see Table#select(int,int)
+ */
+public void setSelection (int start, int end) {
+ checkWidget ();
+ deselectAll ();
+ select (start, end);
+ /*
+ * NOTE: This code relies on the select (int, int)
+ * selecting the last item in the range for a single
+ * selection table.
+ */
+ int focusIndex = (style & SWT.SINGLE) != 0 ? end : start;
+ if (focusIndex != -1) setFocusIndex (focusIndex);
+ showSelection ();
+}
+
+/**
+ * Sets the zero-relative index of the item which is currently
+ * at the top of the receiver. This index can change when items
+ * are scrolled or new items are added and removed.
+ *
+ * @param index the index of the top item
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setTopIndex (int index) {
+ checkWidget ();
+ 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);
+}
+
+void showItem (int index) {
+ /*
+ * Bug in Windows. For some reason, when there is insufficient space
+ * to show an item, LVM_ENSUREVISIBLE causes blank lines to be
+ * inserted at the top of the widget. A call to LVM_GETTOPINDEX will
+ * return a negative number (this is an impossible result). The fix
+ * is to use LVM_GETCOUNTPERPAGE to detect the case when the number
+ * of visible items is zero and use LVM_ENSUREVISIBLE with the fPartialOK
+ * flag to scroll the table.
+ */
+ 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);
+ }
+ } else {
+ OS.SendMessage (handle, OS.LVM_ENSUREVISIBLE, index, 0);
+ }
+}
+
+/**
+ * Shows the item. If the item is already showing in the receiver,
+ * this method simply returns. Otherwise, the items are scrolled until
+ * the item is visible.
+ *
+ * @param item the item to be shown
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if the item is null</li>
+ * <li>ERROR_INVALID_ARGUMENT - if the item has been disposed</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see Table#showSelection()
+ */
+public void showItem (TableItem item) {
+ checkWidget ();
+ if (item == null) error (SWT.ERROR_NULL_ARGUMENT);
+ if (item.isDisposed()) error(SWT.ERROR_INVALID_ARGUMENT);
+ int index = indexOf (item);
+ if (index != -1) showItem (index);
+}
+
+/**
+ * Shows the selection. If the selection is already showing in the receiver,
+ * this method simply returns. Otherwise, the items are scrolled until
+ * the selection is visible.
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see Table#showItem(TableItem)
+ */
+public void showSelection () {
+ checkWidget ();
+ int index = OS.SendMessage (handle, OS.LVM_GETNEXTITEM, -1, OS.LVNI_SELECTED);
+ if (index != -1) showItem (index);
+}
+
+int widgetStyle () {
+ int bits = super.widgetStyle () | 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;
+}
+
+TCHAR windowClass () {
+ return TableClass;
+}
+
+int windowProc () {
+ return TableProc;
+}
+
+LRESULT WM_GETOBJECT (int wParam, int lParam) {
+ /*
+ * Ensure that there is an accessible object created for this
+ * control because support for checked item accessibility is
+ * temporarily implemented in the accessibility package.
+ */
+ if ((style & SWT.CHECK) != 0) {
+ if (accessible == null) accessible = new_Accessible (this);
+ }
+ return super.WM_GETOBJECT (wParam, lParam);
+}
+
+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) {
+ mouseDown = true;
+
+ /*
+ * 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_LBUTTONUP (int wParam, int lParam) {
+ mouseDown = false;
+ return super.WM_LBUTTONUP (wParam, lParam);
+}
+
+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_BEGINTRACKA:
+ case OS.HDN_DIVIDERDBLCLICKW:
+ case OS.HDN_DIVIDERDBLCLICKA:{
+ NMHEADER phdn = new NMHEADER ();
+ OS.MoveMemory (phdn, lParam, NMHEADER.sizeof);
+ TableColumn column = columns [phdn.iItem];
+ if (column != null && !column.getResizable ()) {
+ return LRESULT.ONE;
+ }
+ break;
+ }
+ case OS.HDN_ITEMCHANGEDW:
+ case OS.HDN_ITEMCHANGEDA: {
+ 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);
+ /*
+ * 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_SIZE (int wParam, int lParam) {
+ if (ignoreResize) {
+ ignoreResize = false;
+ int code = callWindowProc (OS.WM_SIZE, wParam, lParam);
+ return new LRESULT (code);
+ }
+ return super.WM_SIZE (wParam, lParam);
+}
+
+LRESULT WM_SYSCOLORCHANGE (int wParam, int lParam) {
+ LRESULT result = super.WM_SYSCOLORCHANGE (wParam, lParam);
+ if (result != null) return result;
+ if ((style & SWT.CHECK) != 0) setCheckboxImageListColor ();
+ return result;
+}
+
+LRESULT wmNotifyChild (int wParam, int lParam) {
+ NMHDR hdr = new NMHDR ();
+ OS.MoveMemory (hdr, lParam, NMHDR.sizeof);
+ switch (hdr.code) {
+ case OS.NM_CUSTOMDRAW: {
+ if (!customDraw) break;
+ NMLVCUSTOMDRAW nmcd = new NMLVCUSTOMDRAW ();
+ OS.MoveMemory (nmcd, lParam, NMLVCUSTOMDRAW.sizeof);
+ switch (nmcd.dwDrawStage) {
+ case OS.CDDS_PREPAINT: return new LRESULT (OS.CDRF_NOTIFYITEMDRAW);
+ case OS.CDDS_ITEMPREPAINT: return new LRESULT (OS.CDRF_NOTIFYSUBITEMDRAW);
+ case OS.CDDS_ITEMPREPAINT | OS.CDDS_SUBITEM: {
+ TableItem item = items [nmcd.dwItemSpec];
+ int clrText = item.foreground, clrTextBk = item.background;
+ if (clrText == -1 && clrTextBk == -1) break;
+ nmcd.clrText = clrText == -1 ? getForegroundPixel () : clrText;
+ nmcd.clrTextBk = clrTextBk == -1 ? getBackgroundPixel () : clrTextBk;
+ OS.MoveMemory (lParam, nmcd, NMLVCUSTOMDRAW.sizeof);
+ return new LRESULT (OS.CDRF_NEWFONT);
+ }
+ }
+ break;
+ }
+ case OS.LVN_MARQUEEBEGIN: return LRESULT.ONE;
+ case OS.LVN_BEGINDRAG:
+ case OS.LVN_BEGINRDRAG: {
+ dragStarted = true;
+ if (hdr.code == OS.LVN_BEGINDRAG) {
+ postEvent (SWT.DragDetect);
+ }
+ 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 (OS.GetKeyState (OS.VK_CONTROL) < 0) {
+ if (!isFocus) {
+ if (index == pnmlv.iItem) {
+ boolean isSelected = (pnmlv.uNewState & OS.LVIS_SELECTED) != 0;
+ boolean wasSelected = (pnmlv.uOldState & OS.LVIS_SELECTED) != 0;
+ isFocus = isSelected != wasSelected;
+ }
+ } else {
+ isFocus = mouseDown;
+ }
+ }
+ }
+ if (OS.GetKeyState (OS.VK_SPACE) < 0) isFocus = true;
+ if (isFocus) {
+ Event event = new Event();
+ if (index != -1) {
+ /*
+ * This code is intentionally commented.
+ */
+// OS.SendMessage (handle, OS.LVM_ENSUREVISIBLE, index, 0);
+ event.item = items [index];
+ }
+ postEvent (SWT.Selection, event);
+ }
+ }
+ }
+ }
+ break;
+ }
+ }
+ return super.wmNotifyChild (wParam, lParam);
+}
+
+}
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
index 1d3f175d5c..f040329484 100755
--- 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
@@ -1,479 +1,479 @@
-package org.eclipse.swt.widgets;
-
-/*
+package org.eclipse.swt.widgets;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-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>
- * Note: Only one of the styles LEFT, RIGHT and CENTER may be specified.
- * </p><p>
- * IMPORTANT: This class is <em>not</em> intended to be subclassed.
- * </p>
- */
-public class TableColumn extends Item {
- Table parent;
- boolean resizable;
-
-/**
- * Constructs a new instance of this class given its parent
- * (which must be a <code>Table</code>) and a style value
- * describing its behavior and appearance. The item is added
- * to the end of the items maintained by its parent.
- * <p>
- * The style value is either one of the style constants defined in
- * class <code>SWT</code> which is applicable to instances of this
- * class, or must be built by <em>bitwise OR</em>'ing together
- * (that is, using the <code>int</code> "|" operator) two or more
- * of those <code>SWT</code> style constants. The class description
- * lists the style constants that are applicable to the class.
- * Style bits are also inherited from superclasses.
- * </p>
- *
- * @param parent a composite control which will be the parent of the new instance (cannot be null)
- * @param style the style of control to construct
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
- * <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
- * </ul>
- *
- * @see SWT#LEFT
- * @see SWT#RIGHT
- * @see SWT#CENTER
- * @see Widget#checkSubclass
- * @see Widget#getStyle
- */
-public TableColumn (Table parent, int style) {
- super (parent, checkStyle (style));
- resizable = true;
- this.parent = parent;
- parent.createItem (this, parent.getColumnCount ());
-}
-
-/**
- * Constructs a new instance of this class given its parent
- * (which must be a <code>Table</code>), a style value
- * describing its behavior and appearance, and the index
- * at which to place it in the items maintained by its parent.
- * <p>
- * The style value is either one of the style constants defined in
- * class <code>SWT</code> which is applicable to instances of this
- * class, or must be built by <em>bitwise OR</em>'ing together
- * (that is, using the <code>int</code> "|" operator) two or more
- * of those <code>SWT</code> style constants. The class description
- * lists the style constants that are applicable to the class.
- * Style bits are also inherited from superclasses.
- * </p>
- *
- * @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#LEFT
- * @see SWT#RIGHT
- * @see SWT#CENTER
- * @see Widget#checkSubclass
- * @see Widget#getStyle
- */
-public TableColumn (Table parent, int style, int index) {
- super (parent, checkStyle (style));
- 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.
- * <p>
- * <code>widgetSelected</code> is called when the column header is selected.
- * <code>widgetDefaultSelected</code> is not called.
- * </p>
- *
- * @param listener the listener which should be notified
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see SelectionListener
- * @see #removeSelectionListener
- * @see SelectionEvent
- */
-public void addSelectionListener (SelectionListener listener) {
- checkWidget ();
- if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
- TypedListener typedListener = new TypedListener (listener);
- addListener (SWT.Selection,typedListener);
- addListener (SWT.DefaultSelection,typedListener);
-}
-
-static int checkStyle (int style) {
- return checkBits (style, SWT.LEFT, SWT.CENTER, SWT.RIGHT, 0, 0, 0);
-}
-
-protected void checkSubclass () {
- if (!isValidSubclass ()) error (SWT.ERROR_INVALID_SUBCLASS);
-}
-
-/**
- * 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.
- *
- * @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.
- *
- * @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;
- TCHAR buffer = new TCHAR (parent.getCodePage (), text, true);
- int headerWidth = OS.SendMessage (hwnd, OS.LVM_GETSTRINGWIDTH, 0, buffer) + 10;
- if (image != null) {
- int margin = 0;
- if ((COMCTL32_MAJOR << 16 | COMCTL32_MINOR) >= (5 << 16 | 80)) {
- int hwndHeader = OS.SendMessage (hwnd, OS.LVM_GETHEADER, 0, 0);
- margin = OS.SendMessage (hwndHeader, OS.HDM_GETBITMAPMARGIN, 0, 0);
- } else {
- margin = OS.GetSystemMetrics (OS.SM_CXEDGE) * 3;
- }
- Rectangle rect = image.getBounds ();
- headerWidth += rect.width + margin * 2;
- }
- OS.SendMessage (hwnd, OS.LVM_SETCOLUMNWIDTH, index, OS.LVSCW_AUTOSIZE);
- int columnWidth = OS.SendMessage (hwnd, OS.LVM_GETCOLUMNWIDTH, index, 0);
- if (headerWidth > columnWidth) {
- if (image == null) {
- OS.SendMessage (hwnd, OS.LVM_SETCOLUMNWIDTH, index, OS.LVSCW_AUTOSIZE_USEHEADER);
- } else {
- OS.SendMessage (hwnd, OS.LVM_SETCOLUMNWIDTH, index, headerWidth);
- }
- }
-}
-
-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);
-}
-
-public void setImage (Image image) {
- checkWidget();
- if (image != null && image.isDisposed ()) {
- error (SWT.ERROR_INVALID_ARGUMENT);
- }
- int index = parent.indexOf (this);
- if (index == -1) return;
- super.setImage (image);
- int hwnd = parent.handle;
- LVCOLUMN lvColumn = new LVCOLUMN ();
- lvColumn.mask = OS.LVCF_FMT | OS.LVCF_IMAGE;
- lvColumn.fmt = OS.LVCFMT_IMAGE;
- lvColumn.iImage = parent.imageIndex (image);
- OS.SendMessage (hwnd, OS.LVM_SETCOLUMN, index, lvColumn);
- if (image == null) {
- lvColumn.mask = OS.LVCF_FMT;
- if ((style & SWT.LEFT) == SWT.LEFT) lvColumn.fmt = OS.LVCFMT_LEFT;
- if ((style & SWT.CENTER) == SWT.CENTER) lvColumn.fmt = OS.LVCFMT_CENTER;
- if ((style & SWT.RIGHT) == SWT.RIGHT) lvColumn.fmt = OS.LVCFMT_RIGHT;
- 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.
- *
- * @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 ();
- TCHAR buffer = new TCHAR (parent.getCodePage (), string, true);
- int byteCount = buffer.length () * TCHAR.sizeof;
- int pszText = OS.HeapAlloc (hHeap, OS.HEAP_ZERO_MEMORY, byteCount);
- OS.MoveMemory (pszText, buffer, byteCount);
- 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.
- *
- * @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);
-}
-
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+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>
+ * Note: Only one of the styles LEFT, RIGHT and CENTER may be specified.
+ * </p><p>
+ * IMPORTANT: This class is <em>not</em> intended to be subclassed.
+ * </p>
+ */
+public class TableColumn extends Item {
+ Table parent;
+ boolean resizable;
+
+/**
+ * Constructs a new instance of this class given its parent
+ * (which must be a <code>Table</code>) and a style value
+ * describing its behavior and appearance. The item is added
+ * to the end of the items maintained by its parent.
+ * <p>
+ * The style value is either one of the style constants defined in
+ * class <code>SWT</code> which is applicable to instances of this
+ * class, or must be built by <em>bitwise OR</em>'ing together
+ * (that is, using the <code>int</code> "|" operator) two or more
+ * of those <code>SWT</code> style constants. The class description
+ * lists the style constants that are applicable to the class.
+ * Style bits are also inherited from superclasses.
+ * </p>
+ *
+ * @param parent a composite control which will be the parent of the new instance (cannot be null)
+ * @param style the style of control to construct
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
+ * <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
+ * </ul>
+ *
+ * @see SWT#LEFT
+ * @see SWT#RIGHT
+ * @see SWT#CENTER
+ * @see Widget#checkSubclass
+ * @see Widget#getStyle
+ */
+public TableColumn (Table parent, int style) {
+ super (parent, checkStyle (style));
+ resizable = true;
+ this.parent = parent;
+ parent.createItem (this, parent.getColumnCount ());
+}
+
+/**
+ * Constructs a new instance of this class given its parent
+ * (which must be a <code>Table</code>), a style value
+ * describing its behavior and appearance, and the index
+ * at which to place it in the items maintained by its parent.
+ * <p>
+ * The style value is either one of the style constants defined in
+ * class <code>SWT</code> which is applicable to instances of this
+ * class, or must be built by <em>bitwise OR</em>'ing together
+ * (that is, using the <code>int</code> "|" operator) two or more
+ * of those <code>SWT</code> style constants. The class description
+ * lists the style constants that are applicable to the class.
+ * Style bits are also inherited from superclasses.
+ * </p>
+ *
+ * @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#LEFT
+ * @see SWT#RIGHT
+ * @see SWT#CENTER
+ * @see Widget#checkSubclass
+ * @see Widget#getStyle
+ */
+public TableColumn (Table parent, int style, int index) {
+ super (parent, checkStyle (style));
+ 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.
+ * <p>
+ * <code>widgetSelected</code> is called when the column header is selected.
+ * <code>widgetDefaultSelected</code> is not called.
+ * </p>
+ *
+ * @param listener the listener which should be notified
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see SelectionListener
+ * @see #removeSelectionListener
+ * @see SelectionEvent
+ */
+public void addSelectionListener (SelectionListener listener) {
+ checkWidget ();
+ if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+ TypedListener typedListener = new TypedListener (listener);
+ addListener (SWT.Selection,typedListener);
+ addListener (SWT.DefaultSelection,typedListener);
+}
+
+static int checkStyle (int style) {
+ return checkBits (style, SWT.LEFT, SWT.CENTER, SWT.RIGHT, 0, 0, 0);
+}
+
+protected void checkSubclass () {
+ if (!isValidSubclass ()) error (SWT.ERROR_INVALID_SUBCLASS);
+}
+
+/**
+ * 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.
+ *
+ * @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.
+ *
+ * @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;
+ TCHAR buffer = new TCHAR (parent.getCodePage (), text, true);
+ int headerWidth = OS.SendMessage (hwnd, OS.LVM_GETSTRINGWIDTH, 0, buffer) + 10;
+ if (image != null) {
+ int margin = 0;
+ if ((COMCTL32_MAJOR << 16 | COMCTL32_MINOR) >= (5 << 16 | 80)) {
+ int hwndHeader = OS.SendMessage (hwnd, OS.LVM_GETHEADER, 0, 0);
+ margin = OS.SendMessage (hwndHeader, OS.HDM_GETBITMAPMARGIN, 0, 0);
+ } else {
+ margin = OS.GetSystemMetrics (OS.SM_CXEDGE) * 3;
+ }
+ Rectangle rect = image.getBounds ();
+ headerWidth += rect.width + margin * 2;
+ }
+ OS.SendMessage (hwnd, OS.LVM_SETCOLUMNWIDTH, index, OS.LVSCW_AUTOSIZE);
+ int columnWidth = OS.SendMessage (hwnd, OS.LVM_GETCOLUMNWIDTH, index, 0);
+ if (headerWidth > columnWidth) {
+ if (image == null) {
+ OS.SendMessage (hwnd, OS.LVM_SETCOLUMNWIDTH, index, OS.LVSCW_AUTOSIZE_USEHEADER);
+ } else {
+ OS.SendMessage (hwnd, OS.LVM_SETCOLUMNWIDTH, index, headerWidth);
+ }
+ }
+}
+
+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);
+}
+
+public void setImage (Image image) {
+ checkWidget();
+ if (image != null && image.isDisposed ()) {
+ error (SWT.ERROR_INVALID_ARGUMENT);
+ }
+ int index = parent.indexOf (this);
+ if (index == -1) return;
+ super.setImage (image);
+ int hwnd = parent.handle;
+ LVCOLUMN lvColumn = new LVCOLUMN ();
+ lvColumn.mask = OS.LVCF_FMT | OS.LVCF_IMAGE;
+ lvColumn.fmt = OS.LVCFMT_IMAGE;
+ lvColumn.iImage = parent.imageIndex (image);
+ OS.SendMessage (hwnd, OS.LVM_SETCOLUMN, index, lvColumn);
+ if (image == null) {
+ lvColumn.mask = OS.LVCF_FMT;
+ if ((style & SWT.LEFT) == SWT.LEFT) lvColumn.fmt = OS.LVCFMT_LEFT;
+ if ((style & SWT.CENTER) == SWT.CENTER) lvColumn.fmt = OS.LVCFMT_CENTER;
+ if ((style & SWT.RIGHT) == SWT.RIGHT) lvColumn.fmt = OS.LVCFMT_RIGHT;
+ 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.
+ *
+ * @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 ();
+ TCHAR buffer = new TCHAR (parent.getCodePage (), string, true);
+ int byteCount = buffer.length () * TCHAR.sizeof;
+ int pszText = OS.HeapAlloc (hHeap, OS.HEAP_ZERO_MEMORY, byteCount);
+ OS.MoveMemory (pszText, buffer, byteCount);
+ 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.
+ *
+ * @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
index 517c27465e..310f064d2a 100755
--- 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
@@ -1,711 +1,711 @@
-package org.eclipse.swt.widgets;
-
-/*
+package org.eclipse.swt.widgets;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-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;
- int background, foreground;
-
-/**
- * Constructs a new instance of this class given its parent
- * (which must be a <code>Table</code>) and a style value
- * describing its behavior and appearance. The item is added
- * to the end of the items maintained by its parent.
- * <p>
- * The style value is either one of the style constants defined in
- * class <code>SWT</code> which is applicable to instances of this
- * class, or must be built by <em>bitwise OR</em>'ing together
- * (that is, using the <code>int</code> "|" operator) two or more
- * of those <code>SWT</code> style constants. The class description
- * lists the style constants that are applicable to the class.
- * Style bits are also inherited from superclasses.
- * </p>
- *
- * @param parent a composite control which will be the parent of the new instance (cannot be null)
- * @param style the style of control to construct
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
- * <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
- * </ul>
- *
- * @see SWT
- * @see Widget#checkSubclass
- * @see Widget#getStyle
- */
-public TableItem (Table parent, int style) {
- 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>Table</code>), a style value
- * describing its behavior and appearance, and the index
- * at which to place it in the items maintained by its parent.
- * <p>
- * The style value is either one of the style constants defined in
- * class <code>SWT</code> which is applicable to instances of this
- * class, or must be built by <em>bitwise OR</em>'ing together
- * (that is, using the <code>int</code> "|" operator) two or more
- * of those <code>SWT</code> style constants. The class description
- * lists the style constants that are applicable to the class.
- * Style bits are also inherited from superclasses.
- * </p>
- *
- * @param parent a composite control which will be the parent of the new instance (cannot be null)
- * @param style the style of control to construct
- * @param index the 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 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 the receiver's background color.
- *
- * @return the background color
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @since 2.0
- *
- */
-public Color getBackground () {
- checkWidget ();
- int pixel = (background == -1) ? parent.getBackgroundPixel() : background;
- return Color.win32_new (getDisplay (), pixel);
-}
-
-/**
- * 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
- * the grid width when the grid is visible. The fix is to
- * move the top of the rectangle up by the grid width.
- */
- if ((COMCTL32_MAJOR << 16 | COMCTL32_MINOR) >= (5 << 16 | 80)) {
- rect.top -= gridWidth;
- }
- 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.
- *
- * @return the checked state of the checkbox
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public boolean getChecked () {
- checkWidget();
- if ((parent.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 the foreground color that the receiver will use to draw.
- *
- * @return the receiver's foreground color
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @since 2.0
- *
- */
-public Color getForeground () {
- checkWidget ();
- int pixel = (foreground == -1) ? parent.getForegroundPixel() : foreground;
- return Color.win32_new (getDisplay (), pixel);
-}
-
-/**
- * Returns <code>true</code> if the receiver is grayed,
- * and false otherwise. When the parent does not have
- * the <code>CHECK</code> style, return false.
- *
- * @return the grayed state of the checkbox
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public boolean getGrayed () {
- checkWidget();
- if ((parent.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);
-}
-
-/**
- * Returns the image stored at the given column index in the receiver,
- * or null if the image has not been set or if the column does not exist.
- *
- * @param index the column index
- * @return the image stored at the given column index in the receiver
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public Image getImage (int index) {
- checkWidget();
- if (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) {
- ImageList imageList = parent.imageList;
- if (imageList != null) return 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;
- /*
- * Bug in Windows. In version 5.80 of COMCTL32.DLL, the top
- * of the rectangle returned by LVM_GETSUBITEMRECT is off by
- * the grid width when the grid is visible. The fix is to
- * move the top of the rectangle up by the grid width.
- */
- if ((COMCTL32_MAJOR << 16 | COMCTL32_MINOR) >= (5 << 16 | 80)) {
- rect.top -= gridWidth;
- }
- return new Rectangle (rect.left + gridWidth, rect.top + gridWidth, width, height);
-}
-
-/**
- * Gets the image indent.
- *
- * @return the indent
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public int getImageIndent () {
- checkWidget();
- 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;
-}
-
-/**
- * Returns the text stored at the given column index in the receiver,
- * or empty string if the text has not been set.
- *
- * @param index the column index
- * @return the text stored at the given column index in the receiver
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- * @exception SWTError <ul>
- * <li>ERROR_CANNOT_GET_TEXT - if the column at index does not exist</li>
- * </ul>
- */
-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 byteCount = cchTextMax * TCHAR.sizeof;
- int pszText = OS.HeapAlloc (hHeap, OS.HEAP_ZERO_MEMORY, byteCount);
- 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);
- TCHAR buffer = new TCHAR (parent.getCodePage (), cchTextMax);
- OS.MoveMemory (buffer, pszText, byteCount);
- OS.HeapFree (hHeap, 0, pszText);
- if (result == 0) error (SWT.ERROR_CANNOT_GET_TEXT);
- return buffer.toString (0, buffer.strlen ());
-}
-
-void redraw () {
- if (parent.drawCount > 0) return;
- int hwnd = parent.handle;
- if (!OS.IsWindowVisible (hwnd)) return;
- int index = parent.indexOf (this);
- RECT rect = new RECT ();
- rect.left = OS.LVIR_BOUNDS;
- if (OS.SendMessage (hwnd, OS.LVM_GETITEMRECT, index, rect) != 0) {
- OS.InvalidateRect (hwnd, rect, true);
- }
-}
-
-void releaseChild () {
- super.releaseChild ();
- parent.destroyItem (this);
-}
-
-void releaseWidget () {
- super.releaseWidget ();
- parent = null;
-}
-
-/**
- * Sets the receiver's background color to the color specified
- * by the argument, or to the default system color for the item
- * if the argument is null.
- *
- * @param color the new color (or null)
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_INVALID_ARGUMENT - if the argument has been disposed</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @since 2.0
- *
- */
-public void setBackground (Color color) {
- checkWidget ();
- if (color != null && color.isDisposed ()) {
- SWT.error (SWT.ERROR_INVALID_ARGUMENT);
- }
- int pixel = -1;
- if (color != null) {
- parent.customDraw = true;
- pixel = color.handle;
- }
- background = pixel;
- redraw ();
-}
-
-/**
- * Sets the checked state of the checkbox for this item. This state change
- * only applies if the Table was created with the SWT.CHECK style.
- *
- * @param checked the new checked state of the checkbox
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public void setChecked (boolean checked) {
- checkWidget();
- if ((parent.style & SWT.CHECK) == 0) return;
- 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 receiver's foreground color to the color specified
- * by the argument, or to the default system color for the item
- * if the argument is null.
- *
- * @param color the new color (or null)
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_INVALID_ARGUMENT - if the argument has been disposed</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @since 2.0
- *
- */
-public void setForeground (Color color){
- checkWidget ();
- if (color != null && color.isDisposed ()) {
- SWT.error (SWT.ERROR_INVALID_ARGUMENT);
- }
- int pixel = -1;
- if (color != null) {
- parent.customDraw = true;
- pixel = color.handle;
- }
- foreground = pixel;
- redraw ();
-}
-
-/**
- * Sets the grayed state of the checkbox for this item. This state change
- * only applies if the Table was created with the SWT.CHECK style.
- *
- * @param grayed the new grayed state of the checkbox;
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public void setGrayed (boolean grayed) {
- checkWidget();
- if ((parent.style & SWT.CHECK) == 0) return;
- 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 images the array of new images
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the array of images is null</li>
- * <li>ERROR_INVALID_ARGUMENT - if one of the images has been disposed</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public void setImage (Image [] images) {
- checkWidget();
- if (images == null) error (SWT.ERROR_NULL_ARGUMENT);
- for (int i=0; i<images.length; i++) {
- setImage (i, images [i]);
- }
-}
-
-/**
- * Sets the receiver's image at a column.
- *
- * @param index the column index
- * @param image the new image
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_INVALID_ARGUMENT - if the image has been disposed</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public void setImage (int index, Image image) {
- checkWidget();
- if (image != null && image.isDisposed ()) {
- error(SWT.ERROR_INVALID_ARGUMENT);
- }
- int itemIndex = parent.indexOf (this);
- if (itemIndex == -1) return;
- if (index == 0) {
- super.setImage (image);
- }
- int hwnd = parent.handle;
- LVITEM lvItem = new LVITEM ();
- lvItem.mask = OS.LVIF_IMAGE;
- lvItem.iItem = itemIndex;
- lvItem.iSubItem = index;
- lvItem.iImage = parent.imageIndex (image);
- if (OS.SendMessage (hwnd, OS.LVM_SETITEM, 0, lvItem) != 0) {
- if (index == 0) parent.setScrollWidth ();
- parent.fixCheckboxImageList ();
- }
-}
-
-public void setImage (Image image) {
- checkWidget ();
- setImage (0, image);
-}
-
-/**
- * Sets the image indent.
- *
- * @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);
- int itemIndex = parent.indexOf (this);
- if (itemIndex == -1) return;
- if (index == 0) {
- super.setText (string);
- }
- int hwnd = parent.handle;
- int hHeap = OS.GetProcessHeap ();
- TCHAR buffer = new TCHAR (parent.getCodePage (), string, true);
- int byteCount = buffer.length () * TCHAR.sizeof;
- int pszText = OS.HeapAlloc (hHeap, OS.HEAP_ZERO_MEMORY, byteCount);
- OS.MoveMemory (pszText, buffer, byteCount);
- LVITEM lvItem = new LVITEM ();
- lvItem.mask = OS.LVIF_TEXT;
- lvItem.iItem = itemIndex;
- lvItem.pszText = pszText;
- lvItem.iSubItem = index;
- if (OS.SendMessage (hwnd, OS.LVM_SETITEM, 0, lvItem) != 0) {
- if (index == 0) parent.setScrollWidth ();
- }
- OS.HeapFree (hHeap, 0, pszText);
-}
-
-public void setText (String string) {
- checkWidget();
- setText (0, string);
-}
-
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+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;
+ int background, foreground;
+
+/**
+ * Constructs a new instance of this class given its parent
+ * (which must be a <code>Table</code>) and a style value
+ * describing its behavior and appearance. The item is added
+ * to the end of the items maintained by its parent.
+ * <p>
+ * The style value is either one of the style constants defined in
+ * class <code>SWT</code> which is applicable to instances of this
+ * class, or must be built by <em>bitwise OR</em>'ing together
+ * (that is, using the <code>int</code> "|" operator) two or more
+ * of those <code>SWT</code> style constants. The class description
+ * lists the style constants that are applicable to the class.
+ * Style bits are also inherited from superclasses.
+ * </p>
+ *
+ * @param parent a composite control which will be the parent of the new instance (cannot be null)
+ * @param style the style of control to construct
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
+ * <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
+ * </ul>
+ *
+ * @see SWT
+ * @see Widget#checkSubclass
+ * @see Widget#getStyle
+ */
+public TableItem (Table parent, int style) {
+ 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>Table</code>), a style value
+ * describing its behavior and appearance, and the index
+ * at which to place it in the items maintained by its parent.
+ * <p>
+ * The style value is either one of the style constants defined in
+ * class <code>SWT</code> which is applicable to instances of this
+ * class, or must be built by <em>bitwise OR</em>'ing together
+ * (that is, using the <code>int</code> "|" operator) two or more
+ * of those <code>SWT</code> style constants. The class description
+ * lists the style constants that are applicable to the class.
+ * Style bits are also inherited from superclasses.
+ * </p>
+ *
+ * @param parent a composite control which will be the parent of the new instance (cannot be null)
+ * @param style the style of control to construct
+ * @param index the 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 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 the receiver's background color.
+ *
+ * @return the background color
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @since 2.0
+ *
+ */
+public Color getBackground () {
+ checkWidget ();
+ int pixel = (background == -1) ? parent.getBackgroundPixel() : background;
+ return Color.win32_new (getDisplay (), pixel);
+}
+
+/**
+ * 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
+ * the grid width when the grid is visible. The fix is to
+ * move the top of the rectangle up by the grid width.
+ */
+ if ((COMCTL32_MAJOR << 16 | COMCTL32_MINOR) >= (5 << 16 | 80)) {
+ rect.top -= gridWidth;
+ }
+ 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.
+ *
+ * @return the checked state of the checkbox
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public boolean getChecked () {
+ checkWidget();
+ if ((parent.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 the foreground color that the receiver will use to draw.
+ *
+ * @return the receiver's foreground color
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @since 2.0
+ *
+ */
+public Color getForeground () {
+ checkWidget ();
+ int pixel = (foreground == -1) ? parent.getForegroundPixel() : foreground;
+ return Color.win32_new (getDisplay (), pixel);
+}
+
+/**
+ * Returns <code>true</code> if the receiver is grayed,
+ * and false otherwise. When the parent does not have
+ * the <code>CHECK</code> style, return false.
+ *
+ * @return the grayed state of the checkbox
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public boolean getGrayed () {
+ checkWidget();
+ if ((parent.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);
+}
+
+/**
+ * Returns the image stored at the given column index in the receiver,
+ * or null if the image has not been set or if the column does not exist.
+ *
+ * @param index the column index
+ * @return the image stored at the given column index in the receiver
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public Image getImage (int index) {
+ checkWidget();
+ if (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) {
+ ImageList imageList = parent.imageList;
+ if (imageList != null) return 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;
+ /*
+ * Bug in Windows. In version 5.80 of COMCTL32.DLL, the top
+ * of the rectangle returned by LVM_GETSUBITEMRECT is off by
+ * the grid width when the grid is visible. The fix is to
+ * move the top of the rectangle up by the grid width.
+ */
+ if ((COMCTL32_MAJOR << 16 | COMCTL32_MINOR) >= (5 << 16 | 80)) {
+ rect.top -= gridWidth;
+ }
+ return new Rectangle (rect.left + gridWidth, rect.top + gridWidth, width, height);
+}
+
+/**
+ * Gets the image indent.
+ *
+ * @return the indent
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public int getImageIndent () {
+ checkWidget();
+ 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;
+}
+
+/**
+ * Returns the text stored at the given column index in the receiver,
+ * or empty string if the text has not been set.
+ *
+ * @param index the column index
+ * @return the text stored at the given column index in the receiver
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * @exception SWTError <ul>
+ * <li>ERROR_CANNOT_GET_TEXT - if the column at index does not exist</li>
+ * </ul>
+ */
+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 byteCount = cchTextMax * TCHAR.sizeof;
+ int pszText = OS.HeapAlloc (hHeap, OS.HEAP_ZERO_MEMORY, byteCount);
+ 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);
+ TCHAR buffer = new TCHAR (parent.getCodePage (), cchTextMax);
+ OS.MoveMemory (buffer, pszText, byteCount);
+ OS.HeapFree (hHeap, 0, pszText);
+ if (result == 0) error (SWT.ERROR_CANNOT_GET_TEXT);
+ return buffer.toString (0, buffer.strlen ());
+}
+
+void redraw () {
+ if (parent.drawCount > 0) return;
+ int hwnd = parent.handle;
+ if (!OS.IsWindowVisible (hwnd)) return;
+ int index = parent.indexOf (this);
+ RECT rect = new RECT ();
+ rect.left = OS.LVIR_BOUNDS;
+ if (OS.SendMessage (hwnd, OS.LVM_GETITEMRECT, index, rect) != 0) {
+ OS.InvalidateRect (hwnd, rect, true);
+ }
+}
+
+void releaseChild () {
+ super.releaseChild ();
+ parent.destroyItem (this);
+}
+
+void releaseWidget () {
+ super.releaseWidget ();
+ parent = null;
+}
+
+/**
+ * Sets the receiver's background color to the color specified
+ * by the argument, or to the default system color for the item
+ * if the argument is null.
+ *
+ * @param color the new color (or null)
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_INVALID_ARGUMENT - if the argument has been disposed</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @since 2.0
+ *
+ */
+public void setBackground (Color color) {
+ checkWidget ();
+ if (color != null && color.isDisposed ()) {
+ SWT.error (SWT.ERROR_INVALID_ARGUMENT);
+ }
+ int pixel = -1;
+ if (color != null) {
+ parent.customDraw = true;
+ pixel = color.handle;
+ }
+ background = pixel;
+ redraw ();
+}
+
+/**
+ * Sets the checked state of the checkbox for this item. This state change
+ * only applies if the Table was created with the SWT.CHECK style.
+ *
+ * @param checked the new checked state of the checkbox
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setChecked (boolean checked) {
+ checkWidget();
+ if ((parent.style & SWT.CHECK) == 0) return;
+ 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 receiver's foreground color to the color specified
+ * by the argument, or to the default system color for the item
+ * if the argument is null.
+ *
+ * @param color the new color (or null)
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_INVALID_ARGUMENT - if the argument has been disposed</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @since 2.0
+ *
+ */
+public void setForeground (Color color){
+ checkWidget ();
+ if (color != null && color.isDisposed ()) {
+ SWT.error (SWT.ERROR_INVALID_ARGUMENT);
+ }
+ int pixel = -1;
+ if (color != null) {
+ parent.customDraw = true;
+ pixel = color.handle;
+ }
+ foreground = pixel;
+ redraw ();
+}
+
+/**
+ * Sets the grayed state of the checkbox for this item. This state change
+ * only applies if the Table was created with the SWT.CHECK style.
+ *
+ * @param grayed the new grayed state of the checkbox;
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setGrayed (boolean grayed) {
+ checkWidget();
+ if ((parent.style & SWT.CHECK) == 0) return;
+ 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 images the array of new images
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if the array of images is null</li>
+ * <li>ERROR_INVALID_ARGUMENT - if one of the images has been disposed</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setImage (Image [] images) {
+ checkWidget();
+ if (images == null) error (SWT.ERROR_NULL_ARGUMENT);
+ for (int i=0; i<images.length; i++) {
+ setImage (i, images [i]);
+ }
+}
+
+/**
+ * Sets the receiver's image at a column.
+ *
+ * @param index the column index
+ * @param image the new image
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_INVALID_ARGUMENT - if the image has been disposed</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setImage (int index, Image image) {
+ checkWidget();
+ if (image != null && image.isDisposed ()) {
+ error(SWT.ERROR_INVALID_ARGUMENT);
+ }
+ int itemIndex = parent.indexOf (this);
+ if (itemIndex == -1) return;
+ if (index == 0) {
+ super.setImage (image);
+ }
+ int hwnd = parent.handle;
+ LVITEM lvItem = new LVITEM ();
+ lvItem.mask = OS.LVIF_IMAGE;
+ lvItem.iItem = itemIndex;
+ lvItem.iSubItem = index;
+ lvItem.iImage = parent.imageIndex (image);
+ if (OS.SendMessage (hwnd, OS.LVM_SETITEM, 0, lvItem) != 0) {
+ if (index == 0) parent.setScrollWidth ();
+ parent.fixCheckboxImageList ();
+ }
+}
+
+public void setImage (Image image) {
+ checkWidget ();
+ setImage (0, image);
+}
+
+/**
+ * Sets the image indent.
+ *
+ * @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);
+ int itemIndex = parent.indexOf (this);
+ if (itemIndex == -1) return;
+ if (index == 0) {
+ super.setText (string);
+ }
+ int hwnd = parent.handle;
+ int hHeap = OS.GetProcessHeap ();
+ TCHAR buffer = new TCHAR (parent.getCodePage (), string, true);
+ int byteCount = buffer.length () * TCHAR.sizeof;
+ int pszText = OS.HeapAlloc (hHeap, OS.HEAP_ZERO_MEMORY, byteCount);
+ OS.MoveMemory (pszText, buffer, byteCount);
+ LVITEM lvItem = new LVITEM ();
+ lvItem.mask = OS.LVIF_TEXT;
+ lvItem.iItem = itemIndex;
+ lvItem.pszText = pszText;
+ lvItem.iSubItem = index;
+ if (OS.SendMessage (hwnd, OS.LVM_SETITEM, 0, lvItem) != 0) {
+ if (index == 0) parent.setScrollWidth ();
+ }
+ OS.HeapFree (hHeap, 0, pszText);
+}
+
+public void setText (String string) {
+ checkWidget();
+ setText (0, string);
+}
+
+}
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
index 1583861902..970e070155 100755
--- 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
@@ -1,1755 +1,1755 @@
-package org.eclipse.swt.widgets;
-
-/*
+package org.eclipse.swt.widgets;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-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>CENTER, LEFT, MULTI, SINGLE, RIGHT, READ_ONLY, WRAP</dd>
- * <dt><b>Events:</b></dt>
- * <dd>DefaultSelection, Modify, Verify</dd>
- * </dl>
- * <p>
- * Note: Only one of the styles MULTI and SINGLE may be specified.
- * </p><p>
- * IMPORTANT: This class is <em>not</em> intended to be subclassed.
- * </p>
- */
-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 = OS.IsWinNT ? 0x7FFFFFFF : 0x7FFF;
- DELIMITER = "\r\n";
- }
-
- static final int EditProc;
- static final TCHAR EditClass = new TCHAR (0, "EDIT", true);
- static {
- WNDCLASS lpWndClass = new WNDCLASS ();
- OS.GetClassInfo (0, EditClass, lpWndClass);
- EditProc = 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
- * lists the style constants that are applicable to the class.
- * Style bits are also inherited from superclasses.
- * </p>
- *
- * @param parent a composite control which will be the parent of the new instance (cannot be null)
- * @param style the style of control to construct
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
- * <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
- * </ul>
- *
- * @see SWT#SINGLE
- * @see SWT#MULTI
- * @see SWT#READ_ONLY
- * @see SWT#WRAP
- * @see Widget#checkSubclass
- * @see Widget#getStyle
- */
-public Text (Composite parent, int style) {
- super (parent, checkStyle (style));
-}
-
-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.
- * <p>
- * <code>widgetSelected</code> is not called for texts.
- * <code>widgetDefaultSelected</code> is typically called when ENTER is pressed in a single-line text.
- * </p>
- *
- * @param listener the listener which should be notified
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see SelectionListener
- * @see #removeSelectionListener
- * @see SelectionEvent
- */
-public void addSelectionListener (SelectionListener listener) {
- checkWidget ();
- if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
- TypedListener typedListener = new TypedListener (listener);
- addListener (SWT.Selection,typedListener);
- addListener (SWT.DefaultSelection,typedListener);
-}
-
-/**
- * Adds the listener to the collection of listeners who will
- * be notified when the receiver's text is verified, by sending
- * it one of the messages defined in the <code>VerifyListener</code>
- * interface.
- *
- * @param listener the listener which should be notified
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see VerifyListener
- * @see #removeVerifyListener
- */
-public void addVerifyListener (VerifyListener listener) {
- checkWidget ();
- if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
- TypedListener typedListener = new TypedListener (listener);
- addListener (SWT.Verify, typedListener);
-}
-
-/**
- * Appends a string.
- * <p>
- * The new text is appended to the text at
- * the end of the widget.
- * </p>
- *
- * @param string the string to be appended
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the 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) || filters (SWT.Verify)) {
- string = verifyText (string, length, length);
- if (string == null) return;
- }
- OS.SendMessage (handle, OS.EM_SETSEL, length, length);
- TCHAR buffer = new TCHAR (getCodePage (), string, true);
- OS.SendMessage (handle, OS.EM_REPLACESEL, 0, buffer);
- OS.SendMessage (handle, OS.EM_SCROLLCARET, 0, 0);
-}
-
-static int checkStyle (int style) {
- style = checkBits (style, SWT.LEFT, SWT.CENTER, SWT.RIGHT, 0, 0, 0);
- if ((style & SWT.SINGLE) != 0) style &= ~(SWT.H_SCROLL | SWT.V_SCROLL | SWT.WRAP);
- if ((style & SWT.WRAP) != 0) style |= SWT.MULTI;
- 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.
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public void clearSelection () {
- checkWidget ();
- if (OS.IsWinCE) {
- /*
- * Bug in WinCE. Calling EM_SETSEL with -1 and 0 is equivalent
- * to calling EM_SETSEL with 0 and -1. It causes the entire
- * text to be selected instead of clearing the selection. The
- * fix is to set the start of the selection to the end of the
- * current selection.
- */
- int [] end = new int [1];
- OS.SendMessage (handle, OS.EM_GETSEL, (int []) null, end);
- OS.SendMessage (handle, OS.EM_SETSEL, end [0], end [0]);
- } else {
- 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;
- boolean wrap = (style & SWT.MULTI) != 0 && (style & SWT.WRAP) != 0;
- if (wrap && wHint != SWT.DEFAULT) {
- flags |= OS.DT_WORDBREAK;
- rect.right = wHint;
- }
- String text = getText ();
- TCHAR buffer = new TCHAR (getCodePage (), text, false);
- OS.DrawText (hDC, buffer, buffer.length (), rect, flags);
- width = rect.right - rect.left;
- if (wrap && 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;
-
- /* Calculate the margin width */
- int margins = OS.SendMessage(handle, OS.EM_GETMARGINS, 0, 0);
- int marginWidth = (margins & 0xFFFF) + ((margins >> 16) & 0xFFFF);
- width += marginWidth;
-
- /*
- * The preferred height 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.
- */
- 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) + 3;
- }
- return new Point (width, height);
-}
-
-/**
- * Copies the selected text.
- * <p>
- * The current selection is copied to the clipboard.
- * </p>
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public void copy () {
- checkWidget ();
- OS.SendMessage (handle, OS.WM_COPY, 0, 0);
-}
-
-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.
- * </p>
- *
- * @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.
- * </p>
- *
- * @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.
- * </p>
- *
- * @return a point, the location of the caret
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public Point getCaretLocation () {
- checkWidget ();
- /*
- * 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)) {
- int cp = getCodePage ();
- OS.SendMessage (handle, OS.EM_REPLACESEL, 0, new TCHAR (cp, " ", true));
- 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 TCHAR (cp, "", true));
- }
- }
- return new Point ((short) (pos & 0xFFFF), (short) (pos >> 16));
-}
-
-/**
- * Gets the position of the caret.
- * <p>
- * The character position of the caret is returned.
- * </p>
- *
- * @return the position of the caret
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public int getCaretPosition () {
- checkWidget ();
- 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 (OS.IsDBLocale) caret = mbcsToWcsPos (caret);
- return caret;
-}
-
-/**
- * Gets the number of characters.
- *
- * @return number of characters in the widget
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public int getCharCount () {
- checkWidget ();
- int length = OS.GetWindowTextLength (handle);
- if (OS.IsDBLocale) length = mbcsToWcsPos (length);
- return length;
-}
-
-String getClipboardText () {
- String string = "";
- if (OS.OpenClipboard (0)) {
- int hMem = OS.GetClipboardData (OS.IsUnicode ? OS.CF_UNICODETEXT : OS.CF_TEXT);
- if (hMem != 0) {
- /* Ensure byteCount is a multiple of 2 bytes on UNICODE platforms */
- int byteCount = OS.GlobalSize (hMem) / TCHAR.sizeof * TCHAR.sizeof;
- int ptr = OS.GlobalLock (hMem);
- if (ptr != 0) {
- /* Use the character encoding for the default locale */
- TCHAR buffer = new TCHAR (0, byteCount / TCHAR.sizeof);
- OS.MoveMemory (buffer, ptr, byteCount);
- string = buffer.toString (0, buffer.strlen ());
- OS.GlobalUnlock (hMem);
- }
- }
- OS.CloseClipboard ();
- }
- return string;
-}
-
-/**
- * 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.
- * </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 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.
- * </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 char getEchoChar () {
- checkWidget ();
- char echo = (char) OS.SendMessage (handle, OS.EM_GETPASSWORDCHAR, 0, 0);
- if (echo != 0 && (echo = mbcsToWcs (echo, getCodePage ())) == 0) echo = '*';
- return echo;
-}
-
-/**
- * Gets the 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 boolean getEditable () {
- checkWidget ();
- int bits = OS.GetWindowLong (handle, OS.GWL_STYLE);
- return (bits & OS.ES_READONLY) == 0;
-}
-
-/**
- * Gets the number of lines.
- *
- * @return the number of lines in the widget
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public int getLineCount () {
- checkWidget ();
- return OS.SendMessage (handle, OS.EM_GETLINECOUNT, 0, 0);
-}
-
-/**
- * Gets the line delimiter.
- *
- * @return a string that is the line delimiter
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public String getLineDelimiter () {
- checkWidget ();
- return DELIMITER;
-}
-
-/**
- * Gets the height of a line.
- *
- * @return the height of a row of text
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public int getLineHeight () {
- checkWidget ();
- 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.
- * </p>
- *
- * @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 (OS.IsDBLocale) {
- start [0] = mbcsToWcsPos (start [0]);
- end [0] = mbcsToWcsPos (end [0]);
- }
- return new Point (start [0], end [0]);
-}
-
-/**
- * Gets the number of selected characters.
- *
- * @return the number of selected characters.
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public int getSelectionCount () {
- checkWidget ();
- Point selection = getSelection ();
- return selection.y - selection.x;
-}
-
-/**
- * Gets the selected text.
- *
- * @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.
- * </p>
- *
- * @return the number of tab characters
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public int getTabs () {
- checkWidget ();
- return tabs;
-}
-
-int getTabWidth (int tabs) {
- 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;
- TCHAR SPACE = new TCHAR (getCodePage (), " ", false);
- OS.DrawText (hDC, SPACE, SPACE.length (), 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.
- * </p>
- *
- * @return the widget text
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public String getText () {
- checkWidget ();
- int length = OS.GetWindowTextLength (handle);
- if (length == 0) return "";
- TCHAR buffer = new TCHAR (getCodePage (), length + 1);
- OS.GetWindowText (handle, buffer, length + 1);
- return buffer.toString (0, length);
-}
-
-/**
- * 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.
- * </p>
- *
- * @param start the start of the range
- * @param end the end of the range
- * @return the range of text
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public String getText (int start, int end) {
- checkWidget ();
- /*
- * 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.
- * <p>
- * If this has not been changed by <code>setTextLimit()</code>,
- * it will be the constant <code>Text.LIMIT</code>.
- * </p>
- *
- * @return the text limit
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-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.
- * <p>
- * This index can change when lines are scrolled or new lines are added or removed.
- * </p>
- *
- * @return the index of the top line
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public int getTopIndex () {
- checkWidget ();
- 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><p>
- * The top pixel changes when the widget is scrolled.
- * The top pixel does not include the widget trimming.
- * </p>
- *
- * @return the pixel position of the top line
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public int getTopPixel () {
- checkWidget ();
- /*
- * 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 ();
-}
-
-/**
- * Inserts a string.
- * <p>
- * The old selection is replaced with the new text.
- * </p>
- *
- * @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) || filters (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;
- }
- TCHAR buffer = new TCHAR (getCodePage (), string, true);
- OS.SendMessage (handle, OS.EM_REPLACESEL, 0, buffer);
-}
-
-int mbcsToWcsPos (int mbcsPos) {
- if (mbcsPos == 0) return 0;
- if (OS.IsUnicode) return mbcsPos;
- int cp = getCodePage ();
- int wcsTotal = 0, mbcsTotal = 0;
- byte [] buffer = new byte [128];
- String delimiter = getLineDelimiter();
- int delimiterSize = delimiter.length ();
- int count = OS.SendMessageA (handle, OS.EM_GETLINECOUNT, 0, 0);
- for (int line=0; line<count; line++) {
- int wcsSize = 0;
- int linePos = OS.SendMessageA (handle, OS.EM_LINEINDEX, line, 0);
- int mbcsSize = OS.SendMessageA (handle, OS.EM_LINELENGTH, linePos, 0);
- if (mbcsSize != 0) {
- if (mbcsSize + delimiterSize > buffer.length) {
- buffer = new byte [mbcsSize + delimiterSize];
- }
- buffer [0] = (byte) (mbcsSize & 0xFF);
- buffer [1] = (byte) (mbcsSize >> 8);
- mbcsSize = OS.SendMessageA (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.
- * </p>
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public void paste () {
- checkWidget ();
- OS.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) && !filters (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:
- int modifiers = SWT.ALT | SWT.SHIFT | SWT.CONTROL;
- if ((stateMask & modifiers) != 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 (OS.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 (OS.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);
- TCHAR buffer = new TCHAR (getCodePage (), newText, true);
- OS.SendMessage (handle, OS.EM_SETSEL, start [0], end [0]);
- OS.SendMessage (handle, OS.EM_REPLACESEL, 0, buffer);
- return false;
-}
-
-void setBounds (int x, int y, int width, int height, int flags) {
- /*
- * Feature in Windows. When the caret is moved,
- * the text widget scrolls to show the new location.
- * This means that the text widget may be scrolled
- * to the right in order to show the caret when the
- * widget is not large enough to show both the caret
- * location and all the text. Unfortunately, when
- * the text widget is resized such that all the text
- * and the caret could be visible, Windows does not
- * scroll the widget back. The fix is to resize the
- * text widget, set the selection to the start of the
- * text and then restore the selection. This will
- * cause the text widget compute the correct scroll
- * position.
- */
- if ((flags & OS.SWP_NOSIZE) == 0 && width != 0) {
- RECT rect = new RECT ();
- OS.GetWindowRect (handle, rect);
- if (rect.right - rect.left == 0) {
- int [] start = new int [1], end = new int [1];
- OS.SendMessage (handle, OS.EM_GETSEL, start, end);
- if (start [0] != 0 || end [0] != 0) {
- OS.SetWindowPos (handle, 0, x, y, width, height, flags);
- OS.SendMessage (handle, OS.EM_SETSEL, 0, 0);
- OS.SendMessage (handle, OS.EM_SETSEL, start [0], end [0]);
- return;
- }
- }
- }
- super.setBounds (x, y, width, height, flags);
-}
-
-/**
- * Sets the double click enabled flag.
- * <p>
- * The double click flag enables or disables the
- * default action of the text widget when the user
- * double clicks.
- * </p>
- *
- * @param doubleClick the new double click flag
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public void setDoubleClickEnabled (boolean doubleClick) {
- checkWidget ();
- this.doubleClick = doubleClick;
-}
-
-/**
- * Sets the echo character.
- * <p>
- * The echo character is the character that is
- * displayed when the user enters text or the
- * text is changed by the programmer. Setting
- * the echo character to '\0' clears the echo
- * character and redraws the original text.
- * If for any reason the echo character is invalid,
- * the default echo character for the platform
- * is used.
- * </p>
- *
- * @param echo the new echo character
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public void setEchoChar (char echo) {
- checkWidget ();
- if (echo != 0) {
- if ((echo = (char) wcsToMbcs (echo, getCodePage ())) == 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.
- *
- * @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.
- * </p><p>
- * Text selections are specified in terms of
- * caret positions. In a text widget that
- * contains N characters, there are N+1 caret
- * positions, ranging from 0..N. This differs
- * from other functions that address character
- * position such as getText () that use the
- * regular array indexing rules.
- * </p>
- *
- * @param start new caret position
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public void setSelection (int start) {
- checkWidget ();
- if (OS.IsDBLocale) start = wcsToMbcsPos (start);
- OS.SendMessage (handle, OS.EM_SETSEL, start, start);
- 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.
- * </p><p>
- * Text selections are specified in terms of
- * caret positions. In a text widget that
- * contains N characters, there are N+1 caret
- * positions, ranging from 0..N. This differs
- * from other functions that address character
- * position such as getText () that use the
- * usual array indexing rules.
- * </p>
- *
- * @param start the start of the range
- * @param end the end of the range
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public void setSelection (int start, int end) {
- checkWidget ();
- if (OS.IsDBLocale) {
- start = wcsToMbcsPos (start);
- end = wcsToMbcsPos (end);
- }
- OS.SendMessage (handle, OS.EM_SETSEL, start, end);
- OS.SendMessage (handle, OS.EM_SCROLLCARET, 0, 0);
-}
-
-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.
- * </p><p>
- * Text selections are specified in terms of
- * caret positions. In a text widget that
- * contains N characters, there are N+1 caret
- * positions, ranging from 0..N. This differs
- * from other functions that address character
- * position such as getText () that use the
- * usual array indexing rules.
- * </p>
- *
- * @param selection the point
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the point is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public void setSelection (Point selection) {
- checkWidget ();
- if (selection == null) error (SWT.ERROR_NULL_ARGUMENT);
- setSelection (selection.x, selection.y);
-}
-
-/**
- * Sets the number of tabs.
- * <p>
- * Tab stop spacing is specified in terms of the
- * space (' ') character. The width of a single
- * tab stop is the pixel width of the spaces.
- * </p>
- *
- * @param tabs the number of tabs
- *
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public void setTabs (int tabs) {
- checkWidget ();
- if (tabs < 0) return;
- setTabStops (this.tabs = tabs);
-}
-
-void setTabStops (int tabs) {
- /*
- * 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 int [] {width});
-}
-
-/**
- * Sets the contents of the receiver to the given string. If the receiver has style
- * SINGLE and the argument contains multiple lines of text, the result of this
- * operation is undefined and may vary from platform to platform.
- *
- * @param 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) || filters (SWT.Verify)) {
- int length = OS.GetWindowTextLength (handle);
- string = verifyText (string, 0, length);
- if (string == null) return;
- }
- TCHAR buffer = new TCHAR (getCodePage (), 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.
- * <p>
- * Instead of trying to set the text limit to zero, consider
- * creating a read-only text widget.
- * </p><p>
- * To reset this value to the default, use <code>setTextLimit(Text.LIMIT)</code>.
- * </p>
- *
- * @param limit new text limit
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_CANNOT_BE_ZERO - if the limit is zero</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-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);
-}
-
-/**
- * Shows the selection.
- * <p>
- * If the selection is already showing
- * in the receiver, this method simply returns. Otherwise,
- * lines are scrolled until the selection is visible.
- * </p>
- *
- * @exception 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 (OS.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;
- if (OS.IsUnicode) return wcsPos;
- int cp = getCodePage ();
- int wcsTotal = 0, mbcsTotal = 0;
- byte [] buffer = new byte [128];
- String delimiter = getLineDelimiter ();
- int delimiterSize = delimiter.length ();
- int count = OS.SendMessageA (handle, OS.EM_GETLINECOUNT, 0, 0);
- for (int line=0; line<count; line++) {
- int wcsSize = 0;
- int linePos = OS.SendMessageA (handle, OS.EM_LINEINDEX, line, 0);
- int mbcsSize = OS.SendMessageA (handle, OS.EM_LINELENGTH, linePos, 0);
- if (mbcsSize != 0) {
- if (mbcsSize + delimiterSize > buffer.length) {
- buffer = new byte [mbcsSize + delimiterSize];
- }
- //ENDIAN
- buffer [0] = (byte) (mbcsSize & 0xFF);
- buffer [1] = (byte) (mbcsSize >> 8);
- mbcsSize = OS.SendMessageA (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 ();
- if ((style & SWT.CENTER) != 0) bits |= OS.ES_CENTER;
- if ((style & SWT.RIGHT) != 0) bits |= OS.ES_RIGHT;
- 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;
-}
-
-TCHAR 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) && !filters (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);
- TCHAR buffer = new TCHAR (getCodePage (), 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) && !filters (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);
- TCHAR buffer = new TCHAR (getCodePage (), newText, true);
- OS.SendMessage (handle, OS.EM_REPLACESEL, 0, buffer);
- }
- return result;
-}
-
-LRESULT WM_GETDLGCODE (int wParam, int lParam) {
- LRESULT result = super.WM_GETDLGCODE (wParam, lParam);
- if (result != null) return result;
- /*
- * Feature in Windows. Despite the fact that the
- * text control is read only, it still returns a
- * dialog code indicating that it wants keys. The
- * fix is to detect this case and clear the bits.
- */
- if ((style & SWT.READ_ONLY) != 0) {
- int code = callWindowProc (OS.WM_GETDLGCODE, wParam, lParam);
- code &= ~(OS.DLGC_WANTALLKEYS | OS.DLGC_WANTTAB | OS.DLGC_WANTARROWS);
- return new LRESULT (code);
- }
- return null;
-}
-
-LRESULT WM_IME_CHAR (int wParam, int lParam) {
-
- /* Process a DBCS character */
- Display display = getDisplay ();
- display.lastKey = 0;
- display.lastAscii = wParam;
- display.lastVirtual = display.lastNull = 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) && !filters (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);
- TCHAR buffer = new TCHAR (getCodePage (), 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) && !filters (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);
- TCHAR buffer = new TCHAR (getCodePage (), 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);
-}
-
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+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>CENTER, LEFT, MULTI, SINGLE, RIGHT, READ_ONLY, WRAP</dd>
+ * <dt><b>Events:</b></dt>
+ * <dd>DefaultSelection, Modify, Verify</dd>
+ * </dl>
+ * <p>
+ * Note: Only one of the styles MULTI and SINGLE may be specified.
+ * </p><p>
+ * IMPORTANT: This class is <em>not</em> intended to be subclassed.
+ * </p>
+ */
+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 = OS.IsWinNT ? 0x7FFFFFFF : 0x7FFF;
+ DELIMITER = "\r\n";
+ }
+
+ static final int EditProc;
+ static final TCHAR EditClass = new TCHAR (0, "EDIT", true);
+ static {
+ WNDCLASS lpWndClass = new WNDCLASS ();
+ OS.GetClassInfo (0, EditClass, lpWndClass);
+ EditProc = 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
+ * lists the style constants that are applicable to the class.
+ * Style bits are also inherited from superclasses.
+ * </p>
+ *
+ * @param parent a composite control which will be the parent of the new instance (cannot be null)
+ * @param style the style of control to construct
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
+ * <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
+ * </ul>
+ *
+ * @see SWT#SINGLE
+ * @see SWT#MULTI
+ * @see SWT#READ_ONLY
+ * @see SWT#WRAP
+ * @see Widget#checkSubclass
+ * @see Widget#getStyle
+ */
+public Text (Composite parent, int style) {
+ super (parent, checkStyle (style));
+}
+
+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.
+ * <p>
+ * <code>widgetSelected</code> is not called for texts.
+ * <code>widgetDefaultSelected</code> is typically called when ENTER is pressed in a single-line text.
+ * </p>
+ *
+ * @param listener the listener which should be notified
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see SelectionListener
+ * @see #removeSelectionListener
+ * @see SelectionEvent
+ */
+public void addSelectionListener (SelectionListener listener) {
+ checkWidget ();
+ if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+ TypedListener typedListener = new TypedListener (listener);
+ addListener (SWT.Selection,typedListener);
+ addListener (SWT.DefaultSelection,typedListener);
+}
+
+/**
+ * Adds the listener to the collection of listeners who will
+ * be notified when the receiver's text is verified, by sending
+ * it one of the messages defined in the <code>VerifyListener</code>
+ * interface.
+ *
+ * @param listener the listener which should be notified
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see VerifyListener
+ * @see #removeVerifyListener
+ */
+public void addVerifyListener (VerifyListener listener) {
+ checkWidget ();
+ if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+ TypedListener typedListener = new TypedListener (listener);
+ addListener (SWT.Verify, typedListener);
+}
+
+/**
+ * Appends a string.
+ * <p>
+ * The new text is appended to the text at
+ * the end of the widget.
+ * </p>
+ *
+ * @param string the string to be appended
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if the 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) || filters (SWT.Verify)) {
+ string = verifyText (string, length, length);
+ if (string == null) return;
+ }
+ OS.SendMessage (handle, OS.EM_SETSEL, length, length);
+ TCHAR buffer = new TCHAR (getCodePage (), string, true);
+ OS.SendMessage (handle, OS.EM_REPLACESEL, 0, buffer);
+ OS.SendMessage (handle, OS.EM_SCROLLCARET, 0, 0);
+}
+
+static int checkStyle (int style) {
+ style = checkBits (style, SWT.LEFT, SWT.CENTER, SWT.RIGHT, 0, 0, 0);
+ if ((style & SWT.SINGLE) != 0) style &= ~(SWT.H_SCROLL | SWT.V_SCROLL | SWT.WRAP);
+ if ((style & SWT.WRAP) != 0) style |= SWT.MULTI;
+ 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.
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void clearSelection () {
+ checkWidget ();
+ if (OS.IsWinCE) {
+ /*
+ * Bug in WinCE. Calling EM_SETSEL with -1 and 0 is equivalent
+ * to calling EM_SETSEL with 0 and -1. It causes the entire
+ * text to be selected instead of clearing the selection. The
+ * fix is to set the start of the selection to the end of the
+ * current selection.
+ */
+ int [] end = new int [1];
+ OS.SendMessage (handle, OS.EM_GETSEL, (int []) null, end);
+ OS.SendMessage (handle, OS.EM_SETSEL, end [0], end [0]);
+ } else {
+ 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;
+ boolean wrap = (style & SWT.MULTI) != 0 && (style & SWT.WRAP) != 0;
+ if (wrap && wHint != SWT.DEFAULT) {
+ flags |= OS.DT_WORDBREAK;
+ rect.right = wHint;
+ }
+ String text = getText ();
+ TCHAR buffer = new TCHAR (getCodePage (), text, false);
+ OS.DrawText (hDC, buffer, buffer.length (), rect, flags);
+ width = rect.right - rect.left;
+ if (wrap && 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;
+
+ /* Calculate the margin width */
+ int margins = OS.SendMessage(handle, OS.EM_GETMARGINS, 0, 0);
+ int marginWidth = (margins & 0xFFFF) + ((margins >> 16) & 0xFFFF);
+ width += marginWidth;
+
+ /*
+ * The preferred height 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.
+ */
+ 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) + 3;
+ }
+ return new Point (width, height);
+}
+
+/**
+ * Copies the selected text.
+ * <p>
+ * The current selection is copied to the clipboard.
+ * </p>
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void copy () {
+ checkWidget ();
+ OS.SendMessage (handle, OS.WM_COPY, 0, 0);
+}
+
+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.
+ * </p>
+ *
+ * @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.
+ * </p>
+ *
+ * @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.
+ * </p>
+ *
+ * @return a point, the location of the caret
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public Point getCaretLocation () {
+ checkWidget ();
+ /*
+ * 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)) {
+ int cp = getCodePage ();
+ OS.SendMessage (handle, OS.EM_REPLACESEL, 0, new TCHAR (cp, " ", true));
+ 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 TCHAR (cp, "", true));
+ }
+ }
+ return new Point ((short) (pos & 0xFFFF), (short) (pos >> 16));
+}
+
+/**
+ * Gets the position of the caret.
+ * <p>
+ * The character position of the caret is returned.
+ * </p>
+ *
+ * @return the position of the caret
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public int getCaretPosition () {
+ checkWidget ();
+ 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 (OS.IsDBLocale) caret = mbcsToWcsPos (caret);
+ return caret;
+}
+
+/**
+ * Gets the number of characters.
+ *
+ * @return number of characters in the widget
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public int getCharCount () {
+ checkWidget ();
+ int length = OS.GetWindowTextLength (handle);
+ if (OS.IsDBLocale) length = mbcsToWcsPos (length);
+ return length;
+}
+
+String getClipboardText () {
+ String string = "";
+ if (OS.OpenClipboard (0)) {
+ int hMem = OS.GetClipboardData (OS.IsUnicode ? OS.CF_UNICODETEXT : OS.CF_TEXT);
+ if (hMem != 0) {
+ /* Ensure byteCount is a multiple of 2 bytes on UNICODE platforms */
+ int byteCount = OS.GlobalSize (hMem) / TCHAR.sizeof * TCHAR.sizeof;
+ int ptr = OS.GlobalLock (hMem);
+ if (ptr != 0) {
+ /* Use the character encoding for the default locale */
+ TCHAR buffer = new TCHAR (0, byteCount / TCHAR.sizeof);
+ OS.MoveMemory (buffer, ptr, byteCount);
+ string = buffer.toString (0, buffer.strlen ());
+ OS.GlobalUnlock (hMem);
+ }
+ }
+ OS.CloseClipboard ();
+ }
+ return string;
+}
+
+/**
+ * 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.
+ * </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 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.
+ * </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 char getEchoChar () {
+ checkWidget ();
+ char echo = (char) OS.SendMessage (handle, OS.EM_GETPASSWORDCHAR, 0, 0);
+ if (echo != 0 && (echo = mbcsToWcs (echo, getCodePage ())) == 0) echo = '*';
+ return echo;
+}
+
+/**
+ * Gets the 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 boolean getEditable () {
+ checkWidget ();
+ int bits = OS.GetWindowLong (handle, OS.GWL_STYLE);
+ return (bits & OS.ES_READONLY) == 0;
+}
+
+/**
+ * Gets the number of lines.
+ *
+ * @return the number of lines in the widget
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public int getLineCount () {
+ checkWidget ();
+ return OS.SendMessage (handle, OS.EM_GETLINECOUNT, 0, 0);
+}
+
+/**
+ * Gets the line delimiter.
+ *
+ * @return a string that is the line delimiter
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public String getLineDelimiter () {
+ checkWidget ();
+ return DELIMITER;
+}
+
+/**
+ * Gets the height of a line.
+ *
+ * @return the height of a row of text
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public int getLineHeight () {
+ checkWidget ();
+ 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.
+ * </p>
+ *
+ * @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 (OS.IsDBLocale) {
+ start [0] = mbcsToWcsPos (start [0]);
+ end [0] = mbcsToWcsPos (end [0]);
+ }
+ return new Point (start [0], end [0]);
+}
+
+/**
+ * Gets the number of selected characters.
+ *
+ * @return the number of selected characters.
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public int getSelectionCount () {
+ checkWidget ();
+ Point selection = getSelection ();
+ return selection.y - selection.x;
+}
+
+/**
+ * Gets the selected text.
+ *
+ * @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.
+ * </p>
+ *
+ * @return the number of tab characters
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public int getTabs () {
+ checkWidget ();
+ return tabs;
+}
+
+int getTabWidth (int tabs) {
+ 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;
+ TCHAR SPACE = new TCHAR (getCodePage (), " ", false);
+ OS.DrawText (hDC, SPACE, SPACE.length (), 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.
+ * </p>
+ *
+ * @return the widget text
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public String getText () {
+ checkWidget ();
+ int length = OS.GetWindowTextLength (handle);
+ if (length == 0) return "";
+ TCHAR buffer = new TCHAR (getCodePage (), length + 1);
+ OS.GetWindowText (handle, buffer, length + 1);
+ return buffer.toString (0, length);
+}
+
+/**
+ * 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.
+ * </p>
+ *
+ * @param start the start of the range
+ * @param end the end of the range
+ * @return the range of text
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public String getText (int start, int end) {
+ checkWidget ();
+ /*
+ * 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.
+ * <p>
+ * If this has not been changed by <code>setTextLimit()</code>,
+ * it will be the constant <code>Text.LIMIT</code>.
+ * </p>
+ *
+ * @return the text limit
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+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.
+ * <p>
+ * This index can change when lines are scrolled or new lines are added or removed.
+ * </p>
+ *
+ * @return the index of the top line
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public int getTopIndex () {
+ checkWidget ();
+ 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><p>
+ * The top pixel changes when the widget is scrolled.
+ * The top pixel does not include the widget trimming.
+ * </p>
+ *
+ * @return the pixel position of the top line
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public int getTopPixel () {
+ checkWidget ();
+ /*
+ * 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 ();
+}
+
+/**
+ * Inserts a string.
+ * <p>
+ * The old selection is replaced with the new text.
+ * </p>
+ *
+ * @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) || filters (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;
+ }
+ TCHAR buffer = new TCHAR (getCodePage (), string, true);
+ OS.SendMessage (handle, OS.EM_REPLACESEL, 0, buffer);
+}
+
+int mbcsToWcsPos (int mbcsPos) {
+ if (mbcsPos == 0) return 0;
+ if (OS.IsUnicode) return mbcsPos;
+ int cp = getCodePage ();
+ int wcsTotal = 0, mbcsTotal = 0;
+ byte [] buffer = new byte [128];
+ String delimiter = getLineDelimiter();
+ int delimiterSize = delimiter.length ();
+ int count = OS.SendMessageA (handle, OS.EM_GETLINECOUNT, 0, 0);
+ for (int line=0; line<count; line++) {
+ int wcsSize = 0;
+ int linePos = OS.SendMessageA (handle, OS.EM_LINEINDEX, line, 0);
+ int mbcsSize = OS.SendMessageA (handle, OS.EM_LINELENGTH, linePos, 0);
+ if (mbcsSize != 0) {
+ if (mbcsSize + delimiterSize > buffer.length) {
+ buffer = new byte [mbcsSize + delimiterSize];
+ }
+ buffer [0] = (byte) (mbcsSize & 0xFF);
+ buffer [1] = (byte) (mbcsSize >> 8);
+ mbcsSize = OS.SendMessageA (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.
+ * </p>
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void paste () {
+ checkWidget ();
+ OS.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) && !filters (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:
+ int modifiers = SWT.ALT | SWT.SHIFT | SWT.CONTROL;
+ if ((stateMask & modifiers) != 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 (OS.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 (OS.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);
+ TCHAR buffer = new TCHAR (getCodePage (), newText, true);
+ OS.SendMessage (handle, OS.EM_SETSEL, start [0], end [0]);
+ OS.SendMessage (handle, OS.EM_REPLACESEL, 0, buffer);
+ return false;
+}
+
+void setBounds (int x, int y, int width, int height, int flags) {
+ /*
+ * Feature in Windows. When the caret is moved,
+ * the text widget scrolls to show the new location.
+ * This means that the text widget may be scrolled
+ * to the right in order to show the caret when the
+ * widget is not large enough to show both the caret
+ * location and all the text. Unfortunately, when
+ * the text widget is resized such that all the text
+ * and the caret could be visible, Windows does not
+ * scroll the widget back. The fix is to resize the
+ * text widget, set the selection to the start of the
+ * text and then restore the selection. This will
+ * cause the text widget compute the correct scroll
+ * position.
+ */
+ if ((flags & OS.SWP_NOSIZE) == 0 && width != 0) {
+ RECT rect = new RECT ();
+ OS.GetWindowRect (handle, rect);
+ if (rect.right - rect.left == 0) {
+ int [] start = new int [1], end = new int [1];
+ OS.SendMessage (handle, OS.EM_GETSEL, start, end);
+ if (start [0] != 0 || end [0] != 0) {
+ OS.SetWindowPos (handle, 0, x, y, width, height, flags);
+ OS.SendMessage (handle, OS.EM_SETSEL, 0, 0);
+ OS.SendMessage (handle, OS.EM_SETSEL, start [0], end [0]);
+ return;
+ }
+ }
+ }
+ super.setBounds (x, y, width, height, flags);
+}
+
+/**
+ * Sets the double click enabled flag.
+ * <p>
+ * The double click flag enables or disables the
+ * default action of the text widget when the user
+ * double clicks.
+ * </p>
+ *
+ * @param doubleClick the new double click flag
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setDoubleClickEnabled (boolean doubleClick) {
+ checkWidget ();
+ this.doubleClick = doubleClick;
+}
+
+/**
+ * Sets the echo character.
+ * <p>
+ * The echo character is the character that is
+ * displayed when the user enters text or the
+ * text is changed by the programmer. Setting
+ * the echo character to '\0' clears the echo
+ * character and redraws the original text.
+ * If for any reason the echo character is invalid,
+ * the default echo character for the platform
+ * is used.
+ * </p>
+ *
+ * @param echo the new echo character
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setEchoChar (char echo) {
+ checkWidget ();
+ if (echo != 0) {
+ if ((echo = (char) wcsToMbcs (echo, getCodePage ())) == 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.
+ *
+ * @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.
+ * </p><p>
+ * Text selections are specified in terms of
+ * caret positions. In a text widget that
+ * contains N characters, there are N+1 caret
+ * positions, ranging from 0..N. This differs
+ * from other functions that address character
+ * position such as getText () that use the
+ * regular array indexing rules.
+ * </p>
+ *
+ * @param start new caret position
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setSelection (int start) {
+ checkWidget ();
+ if (OS.IsDBLocale) start = wcsToMbcsPos (start);
+ OS.SendMessage (handle, OS.EM_SETSEL, start, start);
+ 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.
+ * </p><p>
+ * Text selections are specified in terms of
+ * caret positions. In a text widget that
+ * contains N characters, there are N+1 caret
+ * positions, ranging from 0..N. This differs
+ * from other functions that address character
+ * position such as getText () that use the
+ * usual array indexing rules.
+ * </p>
+ *
+ * @param start the start of the range
+ * @param end the end of the range
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setSelection (int start, int end) {
+ checkWidget ();
+ if (OS.IsDBLocale) {
+ start = wcsToMbcsPos (start);
+ end = wcsToMbcsPos (end);
+ }
+ OS.SendMessage (handle, OS.EM_SETSEL, start, end);
+ OS.SendMessage (handle, OS.EM_SCROLLCARET, 0, 0);
+}
+
+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.
+ * </p><p>
+ * Text selections are specified in terms of
+ * caret positions. In a text widget that
+ * contains N characters, there are N+1 caret
+ * positions, ranging from 0..N. This differs
+ * from other functions that address character
+ * position such as getText () that use the
+ * usual array indexing rules.
+ * </p>
+ *
+ * @param selection the point
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if the point is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setSelection (Point selection) {
+ checkWidget ();
+ if (selection == null) error (SWT.ERROR_NULL_ARGUMENT);
+ setSelection (selection.x, selection.y);
+}
+
+/**
+ * Sets the number of tabs.
+ * <p>
+ * Tab stop spacing is specified in terms of the
+ * space (' ') character. The width of a single
+ * tab stop is the pixel width of the spaces.
+ * </p>
+ *
+ * @param tabs the number of tabs
+ *
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setTabs (int tabs) {
+ checkWidget ();
+ if (tabs < 0) return;
+ setTabStops (this.tabs = tabs);
+}
+
+void setTabStops (int tabs) {
+ /*
+ * 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 int [] {width});
+}
+
+/**
+ * Sets the contents of the receiver to the given string. If the receiver has style
+ * SINGLE and the argument contains multiple lines of text, the result of this
+ * operation is undefined and may vary from platform to platform.
+ *
+ * @param 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) || filters (SWT.Verify)) {
+ int length = OS.GetWindowTextLength (handle);
+ string = verifyText (string, 0, length);
+ if (string == null) return;
+ }
+ TCHAR buffer = new TCHAR (getCodePage (), 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.
+ * <p>
+ * Instead of trying to set the text limit to zero, consider
+ * creating a read-only text widget.
+ * </p><p>
+ * To reset this value to the default, use <code>setTextLimit(Text.LIMIT)</code>.
+ * </p>
+ *
+ * @param limit new text limit
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_CANNOT_BE_ZERO - if the limit is zero</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+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);
+}
+
+/**
+ * Shows the selection.
+ * <p>
+ * If the selection is already showing
+ * in the receiver, this method simply returns. Otherwise,
+ * lines are scrolled until the selection is visible.
+ * </p>
+ *
+ * @exception 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 (OS.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;
+ if (OS.IsUnicode) return wcsPos;
+ int cp = getCodePage ();
+ int wcsTotal = 0, mbcsTotal = 0;
+ byte [] buffer = new byte [128];
+ String delimiter = getLineDelimiter ();
+ int delimiterSize = delimiter.length ();
+ int count = OS.SendMessageA (handle, OS.EM_GETLINECOUNT, 0, 0);
+ for (int line=0; line<count; line++) {
+ int wcsSize = 0;
+ int linePos = OS.SendMessageA (handle, OS.EM_LINEINDEX, line, 0);
+ int mbcsSize = OS.SendMessageA (handle, OS.EM_LINELENGTH, linePos, 0);
+ if (mbcsSize != 0) {
+ if (mbcsSize + delimiterSize > buffer.length) {
+ buffer = new byte [mbcsSize + delimiterSize];
+ }
+ //ENDIAN
+ buffer [0] = (byte) (mbcsSize & 0xFF);
+ buffer [1] = (byte) (mbcsSize >> 8);
+ mbcsSize = OS.SendMessageA (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 ();
+ if ((style & SWT.CENTER) != 0) bits |= OS.ES_CENTER;
+ if ((style & SWT.RIGHT) != 0) bits |= OS.ES_RIGHT;
+ 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;
+}
+
+TCHAR 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) && !filters (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);
+ TCHAR buffer = new TCHAR (getCodePage (), 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) && !filters (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);
+ TCHAR buffer = new TCHAR (getCodePage (), newText, true);
+ OS.SendMessage (handle, OS.EM_REPLACESEL, 0, buffer);
+ }
+ return result;
+}
+
+LRESULT WM_GETDLGCODE (int wParam, int lParam) {
+ LRESULT result = super.WM_GETDLGCODE (wParam, lParam);
+ if (result != null) return result;
+ /*
+ * Feature in Windows. Despite the fact that the
+ * text control is read only, it still returns a
+ * dialog code indicating that it wants keys. The
+ * fix is to detect this case and clear the bits.
+ */
+ if ((style & SWT.READ_ONLY) != 0) {
+ int code = callWindowProc (OS.WM_GETDLGCODE, wParam, lParam);
+ code &= ~(OS.DLGC_WANTALLKEYS | OS.DLGC_WANTTAB | OS.DLGC_WANTARROWS);
+ return new LRESULT (code);
+ }
+ return null;
+}
+
+LRESULT WM_IME_CHAR (int wParam, int lParam) {
+
+ /* Process a DBCS character */
+ Display display = getDisplay ();
+ display.lastKey = 0;
+ display.lastAscii = wParam;
+ display.lastVirtual = display.lastNull = 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) && !filters (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);
+ TCHAR buffer = new TCHAR (getCodePage (), 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) && !filters (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);
+ TCHAR buffer = new TCHAR (getCodePage (), 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);
+}
+
+}
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
index 2abda90e58..5d431f6bc0 100755
--- 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
@@ -1,928 +1,928 @@
-package org.eclipse.swt.widgets;
-
-/*
+package org.eclipse.swt.widgets;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-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>
- * The item children that may be added to instances of this class
- * must be of type <code>ToolItem</code>.
- * </p><p>
- * Note that although this class is a subclass of <code>Composite</code>,
- * it does not make sense to add <code>Control</code> children to it,
- * or set a layout on it.
- * </p><p>
- * <dl>
- * <dt><b>Styles:</b></dt>
- * <dd>FLAT, WRAP, RIGHT, HORIZONTAL, VERTICAL, SHADOW_OUT</dd>
- * <dt><b>Events:</b></dt>
- * <dd>(none)</dd>
- * </dl>
- * <p>
- * Note: Only one of the styles HORIZONTAL and VERTICAL may be specified.
- * </p><p>
- * IMPORTANT: This class is <em>not</em> intended to be subclassed.
- * </p>
- */
-public class ToolBar extends Composite {
- int lastFocusId;
- ToolItem [] items;
- boolean ignoreResize;
- ImageList imageList, disabledImageList, hotImageList;
- static final int ToolBarProc;
- static final TCHAR ToolBarClass = new TCHAR (0, OS.TOOLBARCLASSNAME, true);
- static {
- WNDCLASS lpWndClass = new WNDCLASS ();
- OS.GetClassInfo (0, ToolBarClass, lpWndClass);
- ToolBarProc = lpWndClass.lpfnWndProc;
- }
-
- /*
- * 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".
- */
- static final int DEFAULT_WIDTH = 24;
- static final int DEFAULT_HEIGHT = 22;
-
-/**
- * Constructs a new instance of this class given its parent
- * and a style value describing its behavior and appearance.
- * <p>
- * The style value is either one of the style constants defined in
- * class <code>SWT</code> which is applicable to instances of this
- * class, or must be built by <em>bitwise OR</em>'ing together
- * (that is, using the <code>int</code> "|" operator) two or more
- * of those <code>SWT</code> style constants. The class description
- * lists the style constants that are applicable to the class.
- * Style bits are also inherited from superclasses.
- * </p>
- *
- * @param parent a composite control which will be the parent of the new instance (cannot be null)
- * @param style the style of control to construct
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
- * <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
- * </ul>
- *
- * @see SWT#FLAT
- * @see SWT#WRAP
- * @see SWT#RIGHT
- * @see SWT#HORIZONTAL
- * @see SWT#SHADOW_OUT
- * @see SWT#VERTICAL
- * @see Widget#checkSubclass
- * @see Widget#getStyle
- */
-public ToolBar (Composite parent, int style) {
- super (parent, checkStyle (style));
- /*
- * Ensure that either of HORIZONTAL or VERTICAL is set.
- * NOTE: HORIZONTAL and VERTICAL have the same values
- * as H_SCROLL and V_SCROLL so it is necessary to first
- * clear these bits to avoid scroll bars and then reset
- * the bits using the original style supplied by the
- * programmer.
- */
- if ((style & SWT.VERTICAL) != 0) {
- this.style |= SWT.VERTICAL;
- } else {
- this.style |= SWT.HORIZONTAL;
- }
-}
-
-int callWindowProc (int msg, int wParam, int lParam) {
- if (handle == 0) return 0;
- /*
- * Bug in Windows. For some reason, during the processing
- * of WM_SYSCHAR, the tool bar window proc does not call the
- * default window proc causing mnemonics for the menu bar
- * to be ignored. The fix is to always call the default
- * window proc for WM_SYSCHAR.
- */
- if (msg == OS.WM_SYSCHAR) {
- return OS.DefWindowProc (handle, msg, wParam, lParam);
- }
- return OS.CallWindowProc (ToolBarProc, handle, msg, wParam, lParam);
-}
-
-static int checkStyle (int style) {
- /*
- * On Windows, only flat tool bars can be traversed.
- */
- if ((style & SWT.FLAT) == 0) style |= SWT.NO_FOCUS;
-
- /*
- * A vertical tool bar cannot wrap because TB_SETROWS
- * fails when the toobar has TBSTYLE_WRAPABLE.
- */
- /*
- * This code is intentionally commented.
- */
- //if ((style & SWT.VERTICAL) != 0) style &= ~SWT.WRAP;
-
- /*
- * The TB_SETROWS calls are currently commented, so force
- * the wrap style if this bar is vertical.
- */
- if ((style & SWT.VERTICAL) != 0) style |= SWT.WRAP;
-
- /*
- * Even though it is legal to create this widget
- * with scroll bars, they serve no useful purpose
- * because they do not automatically scroll the
- * widget's client area. The fix is to clear
- * the SWT style.
- */
- return style & ~(SWT.H_SCROLL | SWT.V_SCROLL);
-}
-
-protected void checkSubclass () {
- if (!isValidSubclass ()) error (SWT.ERROR_INVALID_SUBCLASS);
-}
-
-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 border = getBorderWidth ();
- int newWidth = wHint == SWT.DEFAULT ? 0x3FFF : wHint + (border * 2);
- int newHeight = hHint == SWT.DEFAULT ? 0x3FFF : hHint + (border * 2);
- boolean redraw = drawCount == 0 && OS.IsWindowVisible (handle);
- ignoreResize = true;
- if (redraw) OS.UpdateWindow (handle);
- 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) OS.ValidateRect (handle, null);
- ignoreResize = false;
-
- /*
- * 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 = 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 = 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 TBSTYLE_FLAT is used to create
- * a flat toolbar, for some reason TBSTYLE_TRANSPARENT is
- * also set. This causes the toolbar to flicker when it is
- * moved or resized. The fix is to clear TBSTYLE_TRANSPARENT.
- *
- * NOTE: This work around is unnecessary on XP. There is no
- * flickering and clearing the TBSTYLE_TRANSPARENT interferes
- * with the XP theme.
- */
- if (COMCTL32_MAJOR < 6) {
- int bits = OS.GetWindowLong (handle, OS.GWL_STYLE);
- bits &= ~OS.TBSTYLE_TRANSPARENT;
- OS.SetWindowLong (handle, OS.GWL_STYLE, bits);
- }
-
- /*
- * Feature in Windows. Despite the fact that the
- * tool tip text contains \r\n, the tooltip will
- * not honour the new line unless TTM_SETMAXTIPWIDTH
- * is set. The fix is to set TTM_SETMAXTIPWIDTH to
- * a large value.
- */
- /*
- * These lines are intentionally commented. The tool
- * bar currently sets this value to 300 so it is not
- * necessary to set TTM_SETMAXTIPWIDTH.
- */
-// int hwndToolTip = OS.SendMessage (handle, OS.TB_GETTOOLTIPS, 0, 0);
-// OS.SendMessage (hwndToolTip, OS.TTM_SETMAXTIPWIDTH, 0, 0x7FFF);
-
- /*
- * 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 */
- OS.SendMessage (handle, OS.TB_SETEXTENDEDSTYLE, 0, OS.TBSTYLE_EX_DRAWDDARROWS);
-}
-
-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;
- /*
- * This code is intentionally commented.
- */
-// if ((style & SWT.VERTICAL) != 0) {
-// OS.SendMessage (handle, OS.TB_SETROWS, count+1, 0);
-// }
- layoutItems ();
-}
-
-void createWidget () {
- super.createWidget ();
- items = new ToolItem [4];
- lastFocusId = -1;
-}
-
-int defaultBackground () {
- if (OS.IsWinCE) return OS.GetSysColor (OS.COLOR_BTNFACE);
- return super.defaultBackground ();
-}
-
-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);
- }
- OS.SendMessage (handle, OS.TB_DELETEBUTTON, index, 0);
- if (item.id == lastFocusId) lastFocusId = -1;
- items [item.id] = null;
- item.id = -1;
- int count = OS.SendMessage (handle, OS.TB_BUTTONCOUNT, 0, 0);
- if (count == 0) {
- Display display = getDisplay ();
- if (imageList != null) {
- OS.SendMessage (handle, OS.TB_SETIMAGELIST, 0, 0);
- display.releaseToolImageList (imageList);
- }
- if (hotImageList != null) {
- OS.SendMessage (handle, OS.TB_SETHOTIMAGELIST, 0, 0);
- display.releaseToolHotImageList (hotImageList);
- }
- if (disabledImageList != null) {
- OS.SendMessage (handle, OS.TB_SETDISABLEDIMAGELIST, 0, 0);
- display.releaseToolDisabledImageList (disabledImageList);
- }
- imageList = hotImageList = disabledImageList = null;
- items = new ToolItem [4];
- }
- /*
- * This code is intentionally commented.
- */
-// if ((style & SWT.VERTICAL) != 0) {
-// OS.SendMessage (handle, OS.TB_SETROWS, count-1, 0);
-// }
- layoutItems ();
-}
-
-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 affect the receiver.
- * </p>
- *
- * @return the items in the receiver
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public ToolItem [] getItems () {
- checkWidget ();
- int 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++) {
- 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 tool item is null</li>
- * <li>ERROR_INVALID_ARGUMENT - if the tool item has been disposed</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public int indexOf (ToolItem item) {
- checkWidget ();
- if (item == null) error (SWT.ERROR_NULL_ARGUMENT);
- if (item.isDisposed()) error(SWT.ERROR_INVALID_ARGUMENT);
- return OS.SendMessage (handle, OS.TB_COMMANDTOINDEX, item.id, 0);
-}
-
-void layoutItems () {
- for (int i=0; i<items.length; i++) {
- ToolItem item = items [i];
- if (item != null) item.resizeControl ();
- }
-}
-
-boolean mnemonicHit (char ch) {
- int key = wcsToMbcs (ch);
- int [] id = new int [1];
- if (OS.SendMessage (handle, OS.TB_MAPACCELERATOR, key, id) == 0) {
- return false;
- }
- if (!setTabGroupFocus ()) return false;
- int index = OS.SendMessage (handle, OS.TB_COMMANDTOINDEX, id [0], 0);
- if (index == -1) return false;
- OS.SendMessage (handle, OS.TB_SETHOTITEM, index, 0);
- items [id [0]].click (false);
- return true;
-}
-
-boolean mnemonicMatch (char ch) {
- int key = wcsToMbcs (ch);
- int [] id = new int [1];
- return OS.SendMessage (handle, OS.TB_MAPACCELERATOR, key, id) != 0;
-}
-
-void releaseWidget () {
- for (int i=0; i<items.length; i++) {
- ToolItem item = items [i];
- if (item != null && !item.isDisposed ()) {
- item.releaseImages ();
- item.releaseResources ();
- }
- }
- items = null;
- Display display = getDisplay ();
- if (imageList != null) {
- OS.SendMessage (handle, OS.TB_SETIMAGELIST, 0, 0);
- display.releaseToolImageList (imageList);
- }
- if (hotImageList != null) {
- OS.SendMessage (handle, OS.TB_SETHOTIMAGELIST, 0, 0);
- display.releaseToolHotImageList (hotImageList);
- }
- if (disabledImageList != null) {
- OS.SendMessage (handle, OS.TB_SETDISABLEDIMAGELIST, 0, 0);
- display.releaseToolDisabledImageList (disabledImageList);
- }
- imageList = hotImageList = disabledImageList = null;
- super.releaseWidget ();
-}
-
-void setBounds (int x, int y, int width, int height, int flags) {
- /*
- * Feature in Windows. For some reason, when a tool bar is
- * repositioned more than once using DeferWindowPos () into
- * the same HDWP, the toolbar redraws more than once, defeating
- * the puropse of DeferWindowPos (). The fix is to end the
- * defered positioning before the next tool bar is added,
- * ensuring that only one tool bar position is deferred at
- * any given time.
- */
- if (parent.lpwp != null) {
- if (drawCount == 0 && OS.IsWindowVisible (handle)) {
- parent.setResizeChildren (false);
- parent.setResizeChildren (true);
- }
- }
- super.setBounds (x, y, width, height, flags);
-}
-
-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 ();
- }
- OS.SendMessage (handle, OS.TB_SETDISABLEDIMAGELIST, 0, hImageList);
-}
-
-void setHotImageList (ImageList imageList) {
- if (hotImageList == imageList) return;
- int hImageList = 0;
- if ((hotImageList = imageList) != null) {
- hImageList = hotImageList.getHandle ();
- }
- 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 ();
- }
- OS.SendMessage (handle, OS.TB_SETIMAGELIST, 0, hImageList);
-}
-
-boolean setTabItemFocus () {
- int index = 0;
- while (index < items.length) {
- ToolItem item = items [index];
- if (item != null && (item.style & SWT.SEPARATOR) == 0) {
- if (item.getEnabled ()) break;
- }
- index++;
- }
- if (index == items.length) return false;
- return super.setTabItemFocus ();
-}
-
-String toolTipText (NMTTDISPINFO hdr) {
- if ((hdr.uFlags & OS.TTF_IDISHWND) != 0) {
- return null;
- }
- int index = hdr.idFrom;
- int hwndToolTip = OS.SendMessage (handle, OS.TB_GETTOOLTIPS, 0, 0);
- if (hwndToolTip == hdr.hwndFrom) {
- if (toolTipText != null) return "";
- 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_NORESIZE | OS.TBSTYLE_TOOLTIPS;
- if ((style & SWT.SHADOW_OUT) == 0) bits |= OS.CCS_NODIVIDER;
- 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;
-}
-
-TCHAR windowClass () {
- return ToolBarClass;
-}
-
-int windowProc () {
- return ToolBarProc;
-}
-
-LRESULT WM_GETDLGCODE (int wParam, int lParam) {
- LRESULT result = super.WM_GETDLGCODE (wParam, lParam);
- /*
- * Return DLGC_BUTTON so that mnemonics will be
- * processed without needing to press the ALT key
- * when the widget has focus.
- */
- if (result != null) return result;
- return new LRESULT (OS.DLGC_BUTTON);
-}
-
-LRESULT WM_COMMAND (int wParam, int lParam) {
- /*
- * Feature in Windows. When the toolbar window
- * proc processes WM_COMMAND, it forwards this
- * message to its parent. This is done so that
- * children of this control that send this message
- * type to their parent will notify not only
- * this control but also the parent of this control,
- * which is typically the application window and
- * the window that is looking for the message.
- * If the control did not forward the message,
- * applications would have to subclass the control
- * window to see the message. Because the control
- * window is subclassed by SWT, the message
- * is delivered twice, once by SWT and once when
- * the message is forwarded by the window proc.
- * The fix is to avoid calling the window proc
- * for this control.
- */
- LRESULT result = super.WM_COMMAND (wParam, lParam);
- if (result != null) return result;
- return LRESULT.ZERO;
-}
-
-LRESULT WM_KEYDOWN (int wParam, int lParam) {
- LRESULT result = super.WM_KEYDOWN (wParam, lParam);
- if (result != null) return result;
- switch (wParam) {
- case OS.VK_RETURN:
- case OS.VK_SPACE:
- int index = OS.SendMessage (handle, OS.TB_GETHOTITEM, 0, 0);
- if (index != -1) {
- TBBUTTON lpButton = new TBBUTTON ();
- int code = OS.SendMessage (handle, OS.TB_GETBUTTON, index, lpButton);
- if (code != 0) {
- items [lpButton.idCommand].click (wParam == OS.VK_RETURN);
- return LRESULT.ZERO;
- }
- }
- }
- return result;
-}
-
-LRESULT WM_KILLFOCUS (int wParam, int lParam) {
- int index = OS.SendMessage (handle, OS.TB_GETHOTITEM, 0, 0);
- TBBUTTON lpButton = new TBBUTTON ();
- int code = OS.SendMessage (handle, OS.TB_GETBUTTON, index, lpButton);
- if (code != 0) lastFocusId = lpButton.idCommand;
- return super.WM_KILLFOCUS (wParam, lParam);
-}
-
-LRESULT WM_NOTIFY (int wParam, int lParam) {
- /*
- * Feature in Windows. When the toolbar window
- * proc processes WM_NOTIFY, it forwards this
- * message to its parent. This is done so that
- * children of this control that send this message
- * type to their parent will notify not only
- * this control but also the parent of this control,
- * which is typically the application window and
- * the window that is looking for the message.
- * If the control did not forward the message,
- * applications would have to subclass the control
- * window to see the message. Because the control
- * window is subclassed by SWT, the message
- * is delivered twice, once by SWT and once when
- * the message is forwarded by the window proc.
- * The fix is to avoid calling the window proc
- * for this control.
- */
- LRESULT result = super.WM_NOTIFY (wParam, lParam);
- if (result != null) return result;
- return LRESULT.ZERO;
-}
-
-LRESULT WM_SETFOCUS (int wParam, int lParam) {
- LRESULT result = super.WM_SETFOCUS (wParam, lParam);
- if (lastFocusId != -1 && handle == OS.GetFocus ()) {
- int index = OS.SendMessage (handle, OS.TB_COMMANDTOINDEX, lastFocusId, 0);
- OS.SendMessage (handle, OS.TB_SETHOTITEM, index, 0);
- }
- return result;
-}
-
-LRESULT WM_SIZE (int wParam, int lParam) {
- if (ignoreResize) {
- int code = callWindowProc (OS.WM_SIZE, wParam, lParam);
- if (code == 0) return LRESULT.ZERO;
- return new LRESULT (code);
- }
- /*
- * Feature in Windows. When a tool bar that contains
- * separators is wrapped, under certain circumstances,
- * Windows redraws the entire tool bar unnecessarily
- * when resized no item is moves. Whether the entire
- * toolbar is damaged or not seems to depend on the
- * size of the tool bar and the position of the separators.
- * The fix is to ensure that the newly exposed areas are
- * always damaged, and avoid the redraw when no tool item
- * moves.
- */
- RECT [] rects = null;
- int rgn = 0, oldCount = 0;
- boolean fixRedraw = drawCount == 0 &&
- (style & SWT.WRAP) != 0 &&
- OS.IsWindowVisible (handle) &&
- OS.SendMessage (handle, OS.TB_GETROWS, 0, 0) != 1;
- if (fixRedraw) {
- rgn = OS.CreateRectRgn (0, 0, 0, 0);
- OS.GetUpdateRgn (handle, rgn, false);
- oldCount = OS.SendMessage (handle, OS.TB_BUTTONCOUNT, 0, 0);
- rects = new RECT [oldCount];
- for (int i=0; i<oldCount; i++) {
- rects [i] = new RECT ();
- OS.SendMessage (handle, OS.TB_GETITEMRECT, i, rects [i]);
- }
- }
-
- 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 (fixRedraw) {
- int newCount = OS.SendMessage (handle, OS.TB_BUTTONCOUNT, 0, 0);
- if (newCount == oldCount) {
- int index = 0;
- RECT rect = new RECT ();
- while (index < newCount) {
- OS.SendMessage (handle, OS.TB_GETITEMRECT, index, rect);
- if (!OS.EqualRect (rects [index], rect)) break;
- index++;
- }
- if (index == newCount) {
- OS.ValidateRect (handle, null);
- OS.InvalidateRgn (handle, rgn, false);
- }
- }
- OS.DeleteObject (rgn);
- }
-
- layoutItems ();
- return result;
-}
-
-LRESULT WM_WINDOWPOSCHANGING (int wParam, int lParam) {
- LRESULT result = super.WM_WINDOWPOSCHANGING (wParam, lParam);
- if (result != null) return result;
- /*
- * Feature in Windows. When a tool bar that contains
- * separators is wrapped, under certain circumstances,
- * Windows redraws the entire tool bar unnecessarily
- * when resized no item is moves. Whether the entire
- * toolbar is damaged or not seems to depend on the
- * size of the tool bar and the position of the separators.
- * The fix is to ensure that the newly exposed areas are
- * always damaged, and avoid the redraw when no tool item
- * moves.
- */
- if (drawCount != 0) return result;
- if ((style & SWT.WRAP) == 0) return result;
- if (!OS.IsWindowVisible (handle)) return result;
- if (OS.SendMessage (handle, OS.TB_GETROWS, 0, 0) == 1) {
- return result;
- }
- WINDOWPOS lpwp = new WINDOWPOS ();
- OS.MoveMemory (lpwp, lParam, WINDOWPOS.sizeof);
- if ((lpwp.flags & (OS.SWP_NOSIZE | OS.SWP_NOREDRAW)) != 0) {
- return result;
- }
- RECT oldRect = new RECT ();
- OS.GetClientRect (handle, oldRect);
- RECT newRect = new RECT ();
- OS.SetRect (newRect, 0, 0, lpwp.cx, lpwp.cy);
- OS.SendMessage (handle, OS.WM_NCCALCSIZE, 0, newRect);
- int oldWidth = oldRect.right - oldRect.left;
- int oldHeight = oldRect.bottom - oldRect.top;
- int newWidth = newRect.right - newRect.left;
- int newHeight = newRect.bottom - newRect.top;
- if (newWidth > oldWidth) {
- /*
- * Bug in Windows. When a flat tool bar is wrapped,
- * Windows draws a horizontal separator between the
- * rows. The tool bar does not draw the first or
- * the last two pixels of this separator. When the
- * toolbar is resized to be bigger, only the new
- * area is drawn and the last two pixels, which are
- * blank are drawn over by separator. This leaves
- * garbage on the screen. The fix is to damage the
- * pixels.
- */
- RECT rect = new RECT ();
- OS.SetRect (rect, oldWidth - 2, 0, oldWidth, newHeight);
- OS.InvalidateRect (handle, rect, false);
- OS.SetRect (rect, oldRect.right, newRect.top, newRect.right, newRect.bottom);
- OS.InvalidateRect (handle, rect, true);
- }
- if (newHeight > oldHeight) {
- RECT rect = new RECT ();
- OS.SetRect (rect, newRect.left, oldRect.bottom, newRect.right, newRect.bottom);
- OS.InvalidateRect (handle, rect, true);
- }
- 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;
- int index = OS.SendMessage (handle, OS.TB_COMMANDTOINDEX, lpnmtb.iItem, 0);
- RECT rect = new RECT ();
- OS.SendMessage (handle, OS.TB_GETITEMRECT, index, rect);
- event.x = rect.left;
- event.y = rect.bottom;
- child.postEvent (SWT.Selection, event);
- return null;
- }
- break;
- }
- return super.wmNotifyChild (wParam, lParam);
-}
-
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+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>
+ * The item children that may be added to instances of this class
+ * must be of type <code>ToolItem</code>.
+ * </p><p>
+ * Note that although this class is a subclass of <code>Composite</code>,
+ * it does not make sense to add <code>Control</code> children to it,
+ * or set a layout on it.
+ * </p><p>
+ * <dl>
+ * <dt><b>Styles:</b></dt>
+ * <dd>FLAT, WRAP, RIGHT, HORIZONTAL, VERTICAL, SHADOW_OUT</dd>
+ * <dt><b>Events:</b></dt>
+ * <dd>(none)</dd>
+ * </dl>
+ * <p>
+ * Note: Only one of the styles HORIZONTAL and VERTICAL may be specified.
+ * </p><p>
+ * IMPORTANT: This class is <em>not</em> intended to be subclassed.
+ * </p>
+ */
+public class ToolBar extends Composite {
+ int lastFocusId;
+ ToolItem [] items;
+ boolean ignoreResize;
+ ImageList imageList, disabledImageList, hotImageList;
+ static final int ToolBarProc;
+ static final TCHAR ToolBarClass = new TCHAR (0, OS.TOOLBARCLASSNAME, true);
+ static {
+ WNDCLASS lpWndClass = new WNDCLASS ();
+ OS.GetClassInfo (0, ToolBarClass, lpWndClass);
+ ToolBarProc = lpWndClass.lpfnWndProc;
+ }
+
+ /*
+ * 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".
+ */
+ static final int DEFAULT_WIDTH = 24;
+ static final int DEFAULT_HEIGHT = 22;
+
+/**
+ * Constructs a new instance of this class given its parent
+ * and a style value describing its behavior and appearance.
+ * <p>
+ * The style value is either one of the style constants defined in
+ * class <code>SWT</code> which is applicable to instances of this
+ * class, or must be built by <em>bitwise OR</em>'ing together
+ * (that is, using the <code>int</code> "|" operator) two or more
+ * of those <code>SWT</code> style constants. The class description
+ * lists the style constants that are applicable to the class.
+ * Style bits are also inherited from superclasses.
+ * </p>
+ *
+ * @param parent a composite control which will be the parent of the new instance (cannot be null)
+ * @param style the style of control to construct
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
+ * <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
+ * </ul>
+ *
+ * @see SWT#FLAT
+ * @see SWT#WRAP
+ * @see SWT#RIGHT
+ * @see SWT#HORIZONTAL
+ * @see SWT#SHADOW_OUT
+ * @see SWT#VERTICAL
+ * @see Widget#checkSubclass
+ * @see Widget#getStyle
+ */
+public ToolBar (Composite parent, int style) {
+ super (parent, checkStyle (style));
+ /*
+ * Ensure that either of HORIZONTAL or VERTICAL is set.
+ * NOTE: HORIZONTAL and VERTICAL have the same values
+ * as H_SCROLL and V_SCROLL so it is necessary to first
+ * clear these bits to avoid scroll bars and then reset
+ * the bits using the original style supplied by the
+ * programmer.
+ */
+ if ((style & SWT.VERTICAL) != 0) {
+ this.style |= SWT.VERTICAL;
+ } else {
+ this.style |= SWT.HORIZONTAL;
+ }
+}
+
+int callWindowProc (int msg, int wParam, int lParam) {
+ if (handle == 0) return 0;
+ /*
+ * Bug in Windows. For some reason, during the processing
+ * of WM_SYSCHAR, the tool bar window proc does not call the
+ * default window proc causing mnemonics for the menu bar
+ * to be ignored. The fix is to always call the default
+ * window proc for WM_SYSCHAR.
+ */
+ if (msg == OS.WM_SYSCHAR) {
+ return OS.DefWindowProc (handle, msg, wParam, lParam);
+ }
+ return OS.CallWindowProc (ToolBarProc, handle, msg, wParam, lParam);
+}
+
+static int checkStyle (int style) {
+ /*
+ * On Windows, only flat tool bars can be traversed.
+ */
+ if ((style & SWT.FLAT) == 0) style |= SWT.NO_FOCUS;
+
+ /*
+ * A vertical tool bar cannot wrap because TB_SETROWS
+ * fails when the toobar has TBSTYLE_WRAPABLE.
+ */
+ /*
+ * This code is intentionally commented.
+ */
+ //if ((style & SWT.VERTICAL) != 0) style &= ~SWT.WRAP;
+
+ /*
+ * The TB_SETROWS calls are currently commented, so force
+ * the wrap style if this bar is vertical.
+ */
+ if ((style & SWT.VERTICAL) != 0) style |= SWT.WRAP;
+
+ /*
+ * Even though it is legal to create this widget
+ * with scroll bars, they serve no useful purpose
+ * because they do not automatically scroll the
+ * widget's client area. The fix is to clear
+ * the SWT style.
+ */
+ return style & ~(SWT.H_SCROLL | SWT.V_SCROLL);
+}
+
+protected void checkSubclass () {
+ if (!isValidSubclass ()) error (SWT.ERROR_INVALID_SUBCLASS);
+}
+
+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 border = getBorderWidth ();
+ int newWidth = wHint == SWT.DEFAULT ? 0x3FFF : wHint + (border * 2);
+ int newHeight = hHint == SWT.DEFAULT ? 0x3FFF : hHint + (border * 2);
+ boolean redraw = drawCount == 0 && OS.IsWindowVisible (handle);
+ ignoreResize = true;
+ if (redraw) OS.UpdateWindow (handle);
+ 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) OS.ValidateRect (handle, null);
+ ignoreResize = false;
+
+ /*
+ * 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 = 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 = 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 TBSTYLE_FLAT is used to create
+ * a flat toolbar, for some reason TBSTYLE_TRANSPARENT is
+ * also set. This causes the toolbar to flicker when it is
+ * moved or resized. The fix is to clear TBSTYLE_TRANSPARENT.
+ *
+ * NOTE: This work around is unnecessary on XP. There is no
+ * flickering and clearing the TBSTYLE_TRANSPARENT interferes
+ * with the XP theme.
+ */
+ if (COMCTL32_MAJOR < 6) {
+ int bits = OS.GetWindowLong (handle, OS.GWL_STYLE);
+ bits &= ~OS.TBSTYLE_TRANSPARENT;
+ OS.SetWindowLong (handle, OS.GWL_STYLE, bits);
+ }
+
+ /*
+ * Feature in Windows. Despite the fact that the
+ * tool tip text contains \r\n, the tooltip will
+ * not honour the new line unless TTM_SETMAXTIPWIDTH
+ * is set. The fix is to set TTM_SETMAXTIPWIDTH to
+ * a large value.
+ */
+ /*
+ * These lines are intentionally commented. The tool
+ * bar currently sets this value to 300 so it is not
+ * necessary to set TTM_SETMAXTIPWIDTH.
+ */
+// int hwndToolTip = OS.SendMessage (handle, OS.TB_GETTOOLTIPS, 0, 0);
+// OS.SendMessage (hwndToolTip, OS.TTM_SETMAXTIPWIDTH, 0, 0x7FFF);
+
+ /*
+ * 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 */
+ OS.SendMessage (handle, OS.TB_SETEXTENDEDSTYLE, 0, OS.TBSTYLE_EX_DRAWDDARROWS);
+}
+
+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;
+ /*
+ * This code is intentionally commented.
+ */
+// if ((style & SWT.VERTICAL) != 0) {
+// OS.SendMessage (handle, OS.TB_SETROWS, count+1, 0);
+// }
+ layoutItems ();
+}
+
+void createWidget () {
+ super.createWidget ();
+ items = new ToolItem [4];
+ lastFocusId = -1;
+}
+
+int defaultBackground () {
+ if (OS.IsWinCE) return OS.GetSysColor (OS.COLOR_BTNFACE);
+ return super.defaultBackground ();
+}
+
+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);
+ }
+ OS.SendMessage (handle, OS.TB_DELETEBUTTON, index, 0);
+ if (item.id == lastFocusId) lastFocusId = -1;
+ items [item.id] = null;
+ item.id = -1;
+ int count = OS.SendMessage (handle, OS.TB_BUTTONCOUNT, 0, 0);
+ if (count == 0) {
+ Display display = getDisplay ();
+ if (imageList != null) {
+ OS.SendMessage (handle, OS.TB_SETIMAGELIST, 0, 0);
+ display.releaseToolImageList (imageList);
+ }
+ if (hotImageList != null) {
+ OS.SendMessage (handle, OS.TB_SETHOTIMAGELIST, 0, 0);
+ display.releaseToolHotImageList (hotImageList);
+ }
+ if (disabledImageList != null) {
+ OS.SendMessage (handle, OS.TB_SETDISABLEDIMAGELIST, 0, 0);
+ display.releaseToolDisabledImageList (disabledImageList);
+ }
+ imageList = hotImageList = disabledImageList = null;
+ items = new ToolItem [4];
+ }
+ /*
+ * This code is intentionally commented.
+ */
+// if ((style & SWT.VERTICAL) != 0) {
+// OS.SendMessage (handle, OS.TB_SETROWS, count-1, 0);
+// }
+ layoutItems ();
+}
+
+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 affect the receiver.
+ * </p>
+ *
+ * @return the items in the receiver
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public ToolItem [] getItems () {
+ checkWidget ();
+ int 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++) {
+ 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 tool item is null</li>
+ * <li>ERROR_INVALID_ARGUMENT - if the tool item has been disposed</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public int indexOf (ToolItem item) {
+ checkWidget ();
+ if (item == null) error (SWT.ERROR_NULL_ARGUMENT);
+ if (item.isDisposed()) error(SWT.ERROR_INVALID_ARGUMENT);
+ return OS.SendMessage (handle, OS.TB_COMMANDTOINDEX, item.id, 0);
+}
+
+void layoutItems () {
+ for (int i=0; i<items.length; i++) {
+ ToolItem item = items [i];
+ if (item != null) item.resizeControl ();
+ }
+}
+
+boolean mnemonicHit (char ch) {
+ int key = wcsToMbcs (ch);
+ int [] id = new int [1];
+ if (OS.SendMessage (handle, OS.TB_MAPACCELERATOR, key, id) == 0) {
+ return false;
+ }
+ if (!setTabGroupFocus ()) return false;
+ int index = OS.SendMessage (handle, OS.TB_COMMANDTOINDEX, id [0], 0);
+ if (index == -1) return false;
+ OS.SendMessage (handle, OS.TB_SETHOTITEM, index, 0);
+ items [id [0]].click (false);
+ return true;
+}
+
+boolean mnemonicMatch (char ch) {
+ int key = wcsToMbcs (ch);
+ int [] id = new int [1];
+ return OS.SendMessage (handle, OS.TB_MAPACCELERATOR, key, id) != 0;
+}
+
+void releaseWidget () {
+ for (int i=0; i<items.length; i++) {
+ ToolItem item = items [i];
+ if (item != null && !item.isDisposed ()) {
+ item.releaseImages ();
+ item.releaseResources ();
+ }
+ }
+ items = null;
+ Display display = getDisplay ();
+ if (imageList != null) {
+ OS.SendMessage (handle, OS.TB_SETIMAGELIST, 0, 0);
+ display.releaseToolImageList (imageList);
+ }
+ if (hotImageList != null) {
+ OS.SendMessage (handle, OS.TB_SETHOTIMAGELIST, 0, 0);
+ display.releaseToolHotImageList (hotImageList);
+ }
+ if (disabledImageList != null) {
+ OS.SendMessage (handle, OS.TB_SETDISABLEDIMAGELIST, 0, 0);
+ display.releaseToolDisabledImageList (disabledImageList);
+ }
+ imageList = hotImageList = disabledImageList = null;
+ super.releaseWidget ();
+}
+
+void setBounds (int x, int y, int width, int height, int flags) {
+ /*
+ * Feature in Windows. For some reason, when a tool bar is
+ * repositioned more than once using DeferWindowPos () into
+ * the same HDWP, the toolbar redraws more than once, defeating
+ * the puropse of DeferWindowPos (). The fix is to end the
+ * defered positioning before the next tool bar is added,
+ * ensuring that only one tool bar position is deferred at
+ * any given time.
+ */
+ if (parent.lpwp != null) {
+ if (drawCount == 0 && OS.IsWindowVisible (handle)) {
+ parent.setResizeChildren (false);
+ parent.setResizeChildren (true);
+ }
+ }
+ super.setBounds (x, y, width, height, flags);
+}
+
+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 ();
+ }
+ OS.SendMessage (handle, OS.TB_SETDISABLEDIMAGELIST, 0, hImageList);
+}
+
+void setHotImageList (ImageList imageList) {
+ if (hotImageList == imageList) return;
+ int hImageList = 0;
+ if ((hotImageList = imageList) != null) {
+ hImageList = hotImageList.getHandle ();
+ }
+ 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 ();
+ }
+ OS.SendMessage (handle, OS.TB_SETIMAGELIST, 0, hImageList);
+}
+
+boolean setTabItemFocus () {
+ int index = 0;
+ while (index < items.length) {
+ ToolItem item = items [index];
+ if (item != null && (item.style & SWT.SEPARATOR) == 0) {
+ if (item.getEnabled ()) break;
+ }
+ index++;
+ }
+ if (index == items.length) return false;
+ return super.setTabItemFocus ();
+}
+
+String toolTipText (NMTTDISPINFO hdr) {
+ if ((hdr.uFlags & OS.TTF_IDISHWND) != 0) {
+ return null;
+ }
+ int index = hdr.idFrom;
+ int hwndToolTip = OS.SendMessage (handle, OS.TB_GETTOOLTIPS, 0, 0);
+ if (hwndToolTip == hdr.hwndFrom) {
+ if (toolTipText != null) return "";
+ 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_NORESIZE | OS.TBSTYLE_TOOLTIPS;
+ if ((style & SWT.SHADOW_OUT) == 0) bits |= OS.CCS_NODIVIDER;
+ 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;
+}
+
+TCHAR windowClass () {
+ return ToolBarClass;
+}
+
+int windowProc () {
+ return ToolBarProc;
+}
+
+LRESULT WM_GETDLGCODE (int wParam, int lParam) {
+ LRESULT result = super.WM_GETDLGCODE (wParam, lParam);
+ /*
+ * Return DLGC_BUTTON so that mnemonics will be
+ * processed without needing to press the ALT key
+ * when the widget has focus.
+ */
+ if (result != null) return result;
+ return new LRESULT (OS.DLGC_BUTTON);
+}
+
+LRESULT WM_COMMAND (int wParam, int lParam) {
+ /*
+ * Feature in Windows. When the toolbar window
+ * proc processes WM_COMMAND, it forwards this
+ * message to its parent. This is done so that
+ * children of this control that send this message
+ * type to their parent will notify not only
+ * this control but also the parent of this control,
+ * which is typically the application window and
+ * the window that is looking for the message.
+ * If the control did not forward the message,
+ * applications would have to subclass the control
+ * window to see the message. Because the control
+ * window is subclassed by SWT, the message
+ * is delivered twice, once by SWT and once when
+ * the message is forwarded by the window proc.
+ * The fix is to avoid calling the window proc
+ * for this control.
+ */
+ LRESULT result = super.WM_COMMAND (wParam, lParam);
+ if (result != null) return result;
+ return LRESULT.ZERO;
+}
+
+LRESULT WM_KEYDOWN (int wParam, int lParam) {
+ LRESULT result = super.WM_KEYDOWN (wParam, lParam);
+ if (result != null) return result;
+ switch (wParam) {
+ case OS.VK_RETURN:
+ case OS.VK_SPACE:
+ int index = OS.SendMessage (handle, OS.TB_GETHOTITEM, 0, 0);
+ if (index != -1) {
+ TBBUTTON lpButton = new TBBUTTON ();
+ int code = OS.SendMessage (handle, OS.TB_GETBUTTON, index, lpButton);
+ if (code != 0) {
+ items [lpButton.idCommand].click (wParam == OS.VK_RETURN);
+ return LRESULT.ZERO;
+ }
+ }
+ }
+ return result;
+}
+
+LRESULT WM_KILLFOCUS (int wParam, int lParam) {
+ int index = OS.SendMessage (handle, OS.TB_GETHOTITEM, 0, 0);
+ TBBUTTON lpButton = new TBBUTTON ();
+ int code = OS.SendMessage (handle, OS.TB_GETBUTTON, index, lpButton);
+ if (code != 0) lastFocusId = lpButton.idCommand;
+ return super.WM_KILLFOCUS (wParam, lParam);
+}
+
+LRESULT WM_NOTIFY (int wParam, int lParam) {
+ /*
+ * Feature in Windows. When the toolbar window
+ * proc processes WM_NOTIFY, it forwards this
+ * message to its parent. This is done so that
+ * children of this control that send this message
+ * type to their parent will notify not only
+ * this control but also the parent of this control,
+ * which is typically the application window and
+ * the window that is looking for the message.
+ * If the control did not forward the message,
+ * applications would have to subclass the control
+ * window to see the message. Because the control
+ * window is subclassed by SWT, the message
+ * is delivered twice, once by SWT and once when
+ * the message is forwarded by the window proc.
+ * The fix is to avoid calling the window proc
+ * for this control.
+ */
+ LRESULT result = super.WM_NOTIFY (wParam, lParam);
+ if (result != null) return result;
+ return LRESULT.ZERO;
+}
+
+LRESULT WM_SETFOCUS (int wParam, int lParam) {
+ LRESULT result = super.WM_SETFOCUS (wParam, lParam);
+ if (lastFocusId != -1 && handle == OS.GetFocus ()) {
+ int index = OS.SendMessage (handle, OS.TB_COMMANDTOINDEX, lastFocusId, 0);
+ OS.SendMessage (handle, OS.TB_SETHOTITEM, index, 0);
+ }
+ return result;
+}
+
+LRESULT WM_SIZE (int wParam, int lParam) {
+ if (ignoreResize) {
+ int code = callWindowProc (OS.WM_SIZE, wParam, lParam);
+ if (code == 0) return LRESULT.ZERO;
+ return new LRESULT (code);
+ }
+ /*
+ * Feature in Windows. When a tool bar that contains
+ * separators is wrapped, under certain circumstances,
+ * Windows redraws the entire tool bar unnecessarily
+ * when resized no item is moves. Whether the entire
+ * toolbar is damaged or not seems to depend on the
+ * size of the tool bar and the position of the separators.
+ * The fix is to ensure that the newly exposed areas are
+ * always damaged, and avoid the redraw when no tool item
+ * moves.
+ */
+ RECT [] rects = null;
+ int rgn = 0, oldCount = 0;
+ boolean fixRedraw = drawCount == 0 &&
+ (style & SWT.WRAP) != 0 &&
+ OS.IsWindowVisible (handle) &&
+ OS.SendMessage (handle, OS.TB_GETROWS, 0, 0) != 1;
+ if (fixRedraw) {
+ rgn = OS.CreateRectRgn (0, 0, 0, 0);
+ OS.GetUpdateRgn (handle, rgn, false);
+ oldCount = OS.SendMessage (handle, OS.TB_BUTTONCOUNT, 0, 0);
+ rects = new RECT [oldCount];
+ for (int i=0; i<oldCount; i++) {
+ rects [i] = new RECT ();
+ OS.SendMessage (handle, OS.TB_GETITEMRECT, i, rects [i]);
+ }
+ }
+
+ 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 (fixRedraw) {
+ int newCount = OS.SendMessage (handle, OS.TB_BUTTONCOUNT, 0, 0);
+ if (newCount == oldCount) {
+ int index = 0;
+ RECT rect = new RECT ();
+ while (index < newCount) {
+ OS.SendMessage (handle, OS.TB_GETITEMRECT, index, rect);
+ if (!OS.EqualRect (rects [index], rect)) break;
+ index++;
+ }
+ if (index == newCount) {
+ OS.ValidateRect (handle, null);
+ OS.InvalidateRgn (handle, rgn, false);
+ }
+ }
+ OS.DeleteObject (rgn);
+ }
+
+ layoutItems ();
+ return result;
+}
+
+LRESULT WM_WINDOWPOSCHANGING (int wParam, int lParam) {
+ LRESULT result = super.WM_WINDOWPOSCHANGING (wParam, lParam);
+ if (result != null) return result;
+ /*
+ * Feature in Windows. When a tool bar that contains
+ * separators is wrapped, under certain circumstances,
+ * Windows redraws the entire tool bar unnecessarily
+ * when resized no item is moves. Whether the entire
+ * toolbar is damaged or not seems to depend on the
+ * size of the tool bar and the position of the separators.
+ * The fix is to ensure that the newly exposed areas are
+ * always damaged, and avoid the redraw when no tool item
+ * moves.
+ */
+ if (drawCount != 0) return result;
+ if ((style & SWT.WRAP) == 0) return result;
+ if (!OS.IsWindowVisible (handle)) return result;
+ if (OS.SendMessage (handle, OS.TB_GETROWS, 0, 0) == 1) {
+ return result;
+ }
+ WINDOWPOS lpwp = new WINDOWPOS ();
+ OS.MoveMemory (lpwp, lParam, WINDOWPOS.sizeof);
+ if ((lpwp.flags & (OS.SWP_NOSIZE | OS.SWP_NOREDRAW)) != 0) {
+ return result;
+ }
+ RECT oldRect = new RECT ();
+ OS.GetClientRect (handle, oldRect);
+ RECT newRect = new RECT ();
+ OS.SetRect (newRect, 0, 0, lpwp.cx, lpwp.cy);
+ OS.SendMessage (handle, OS.WM_NCCALCSIZE, 0, newRect);
+ int oldWidth = oldRect.right - oldRect.left;
+ int oldHeight = oldRect.bottom - oldRect.top;
+ int newWidth = newRect.right - newRect.left;
+ int newHeight = newRect.bottom - newRect.top;
+ if (newWidth > oldWidth) {
+ /*
+ * Bug in Windows. When a flat tool bar is wrapped,
+ * Windows draws a horizontal separator between the
+ * rows. The tool bar does not draw the first or
+ * the last two pixels of this separator. When the
+ * toolbar is resized to be bigger, only the new
+ * area is drawn and the last two pixels, which are
+ * blank are drawn over by separator. This leaves
+ * garbage on the screen. The fix is to damage the
+ * pixels.
+ */
+ RECT rect = new RECT ();
+ OS.SetRect (rect, oldWidth - 2, 0, oldWidth, newHeight);
+ OS.InvalidateRect (handle, rect, false);
+ OS.SetRect (rect, oldRect.right, newRect.top, newRect.right, newRect.bottom);
+ OS.InvalidateRect (handle, rect, true);
+ }
+ if (newHeight > oldHeight) {
+ RECT rect = new RECT ();
+ OS.SetRect (rect, newRect.left, oldRect.bottom, newRect.right, newRect.bottom);
+ OS.InvalidateRect (handle, rect, true);
+ }
+ 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;
+ int index = OS.SendMessage (handle, OS.TB_COMMANDTOINDEX, lpnmtb.iItem, 0);
+ RECT rect = new RECT ();
+ OS.SendMessage (handle, OS.TB_GETITEMRECT, index, rect);
+ event.x = rect.left;
+ event.y = rect.bottom;
+ 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
index 38602b3a35..be3712770d 100755
--- 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
@@ -1,831 +1,831 @@
-package org.eclipse.swt.widgets;
-
-/*
+package org.eclipse.swt.widgets;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-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>
- * Note: Only one of the styles CHECK, PUSH, RADIO, SEPARATOR and DROP_DOWN
- * may be specified.
- * </p><p>
- * IMPORTANT: This class is <em>not</em> intended to be subclassed.
- * </p>
- */
-public class ToolItem extends Item {
- ToolBar parent;
- Control control;
- String toolTipText;
- Image disabledImage, hotImage;
- Image disabledImage2;
- int id;
-
-/**
- * Constructs a new instance of this class given its parent
- * (which must be a <code>ToolBar</code>) and a style value
- * describing its behavior and appearance. The item is added
- * to the end of the items maintained by its parent.
- * <p>
- * The style value is either one of the style constants defined in
- * class <code>SWT</code> which is applicable to instances of this
- * class, or must be built by <em>bitwise OR</em>'ing together
- * (that is, using the <code>int</code> "|" operator) two or more
- * of those <code>SWT</code> style constants. The class description
- * lists the style constants that are applicable to the class.
- * Style bits are also inherited from superclasses.
- * </p>
- *
- * @param parent a composite control which will be the parent of the new instance (cannot be null)
- * @param style the style of control to construct
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
- * <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
- * </ul>
- *
- * @see SWT#PUSH
- * @see SWT#CHECK
- * @see SWT#RADIO
- * @see SWT#SEPARATOR
- * @see SWT#DROP_DOWN
- * @see Widget#checkSubclass
- * @see Widget#getStyle
- */
-public ToolItem (ToolBar parent, int style) {
- super (parent, checkStyle (style));
- this.parent = parent;
- parent.createItem (this, parent.getItemCount ());
-}
-
-/**
- * Constructs a new instance of this class given its parent
- * (which must be a <code>ToolBar</code>), a style value
- * describing its behavior and appearance, and the index
- * at which to place it in the items maintained by its parent.
- * <p>
- * The style value is either one of the style constants defined in
- * class <code>SWT</code> which is applicable to instances of this
- * class, or must be built by <em>bitwise OR</em>'ing together
- * (that is, using the <code>int</code> "|" operator) two or more
- * of those <code>SWT</code> style constants. The class description
- * lists the style constants that are applicable to the class.
- * Style bits are also inherited from superclasses.
- * </p>
- *
- * @param parent a composite control which will be the parent of the new instance (cannot be null)
- * @param style the style of control to construct
- * @param index the 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#PUSH
- * @see SWT#CHECK
- * @see SWT#RADIO
- * @see SWT#SEPARATOR
- * @see SWT#DROP_DOWN
- * @see Widget#checkSubclass
- * @see Widget#getStyle
- */
-public ToolItem (ToolBar parent, int style, int index) {
- super (parent, checkStyle (style));
- this.parent = parent;
- 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.
- * <p>
- * When <code>widgetSelected</code> is called when the mouse is over the arrow portion of a drop-down tool,
- * the event object detail field contains the value <code>SWT.ARROW</code>.
- * <code>widgetDefaultSelected</code> is not called.
- * </p>
- *
- * @param listener the listener which should be notified
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see SelectionListener
- * @see #removeSelectionListener
- * @see SelectionEvent
- */
-public void addSelectionListener(SelectionListener listener) {
- checkWidget();
- if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
- TypedListener typedListener = new TypedListener (listener);
- addListener (SWT.Selection,typedListener);
- addListener (SWT.DefaultSelection,typedListener);
-}
-
-static int checkStyle (int style) {
- return checkBits (style, SWT.PUSH, SWT.CHECK, SWT.RADIO, SWT.SEPARATOR, SWT.DROP_DOWN, 0);
-}
-
-protected void checkSubclass () {
- if (!isValidSubclass ()) error (SWT.ERROR_INVALID_SUBCLASS);
-}
-
-void click (boolean dropDown) {
- /*
- * In order to emulate all the processing that
- * happens when a mnemonic key is pressed, fake
- * a mouse press and release. This will ensure
- * that radio and pull down items are handled
- * properly.
- */
- int hwnd = parent.handle;
- if (OS.GetKeyState (OS.VK_LBUTTON) < 0) return;
- int index = OS.SendMessage (hwnd, OS.TB_COMMANDTOINDEX, id, 0);
- RECT rect = new RECT ();
- OS.SendMessage (hwnd, OS.TB_GETITEMRECT, index, rect);
- int lParam = (dropDown ? rect.right - 1 : rect.left) | (rect.top << 16);
- int hotIndex = OS.SendMessage (hwnd, OS.TB_GETHOTITEM, 0, 0);
- OS.SendMessage (hwnd, OS.WM_LBUTTONDOWN, 0, lParam);
- OS.SendMessage (hwnd, OS.WM_LBUTTONUP, 0, lParam);
- if (hotIndex != -1) {
- OS.SendMessage (hwnd, OS.TB_SETHOTITEM, hotIndex, 0);
- }
-}
-
-Image createDisabledImage (Image image, Color color) {
- Display display = getDisplay ();
- if (OS.IsWinCE) {
- return new Image (display, image, SWT.IMAGE_DISABLE);
- }
- 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>.
- *
- * @return the control
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public Control getControl () {
- checkWidget();
- return control;
-}
-
-/**
- * Returns the receiver's disabled image if it has one, or null
- * if it does not.
- * <p>
- * The disabled image is displayed when the receiver is disabled.
- * </p>
- *
- * @return the receiver's disabled image
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public Image getDisabledImage () {
- checkWidget();
- return disabledImage;
-}
-
-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>
- *
- * @see #isEnabled
- */
-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.
- * <p>
- * The hot image is displayed when the mouse enters the receiver.
- * </p>
- *
- * @return the receiver's hot image
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public Image getHotImage () {
- checkWidget();
- return hotImage;
-}
-
-/**
- * Returns the receiver's parent, which must be a <code>ToolBar</code>.
- *
- * @return the receiver's parent
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public ToolBar getParent () {
- checkWidget();
- return parent;
-}
-
-/**
- * Returns <code>true</code> if the receiver is selected,
- * and false otherwise.
- * <p>
- * When the receiver is of type <code>CHECK</code> or <code>RADIO</code>,
- * it is selected when it is checked (which some platforms draw as a
- * pushed in button). If the receiver is of any other type, this method
- * returns false.
- * </p>
- *
- * @return the selection state
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public boolean getSelection () {
- checkWidget();
- if ((style & (SWT.CHECK | SWT.RADIO)) == 0) return false;
- 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.
- *
- * @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 all
- * of the receiver's ancestors are enabled, and <code>false</code>
- * otherwise. A disabled control is typically not selectable from the
- * user interface and draws with an inactive or "grayed" look.
- *
- * @return the receiver's enabled state
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see #getEnabled
- */
-public boolean isEnabled () {
- checkWidget();
- return getEnabled () && parent.isEnabled ();
-}
-
-void 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;
-}
-
-void releaseImages () {
- TBBUTTONINFO info = new TBBUTTONINFO ();
- info.cbSize = TBBUTTONINFO.sizeof;
- info.dwMask = OS.TBIF_IMAGE | OS.TBIF_STYLE;
- int hwnd = parent.handle;
- OS.SendMessage (hwnd, OS.TB_GETBUTTONINFO, 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) {
- ImageList imageList = parent.getImageList ();
- ImageList hotImageList = parent.getHotImageList ();
- ImageList disabledImageList = parent.getDisabledImageList();
- if (imageList != null) imageList.put (info.iImage, null);
- if (hotImageList != null) hotImageList.put (info.iImage, null);
- if (disabledImageList != null) disabledImageList.put (info.iImage, 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 resizeControl () {
- if (control != null && !control.isDisposed ()) {
- /*
- * Set the size and location of the control
- * separately to minimize flashing in the
- * case where the control does not resize
- * to the size that was requested. This
- * case can occur when the control is a
- * combo box.
- */
- Rectangle itemRect = getBounds ();
- control.setSize (itemRect.width, itemRect.height);
- Rectangle rect = control.getBounds ();
- rect.x = itemRect.x + (itemRect.width - rect.width) / 2;
- rect.y = itemRect.y + (itemRect.height - rect.height) / 2;
- control.setLocation (rect.x, rect.y);
- }
-}
-
-void selectRadio () {
- int index = 0;
- ToolItem [] items = parent.getItems ();
- while (index < items.length && items [index] != this) index++;
- int i = index - 1;
- while (i >= 0 && items [i].setRadioSelection (false)) --i;
- int j = index + 1;
- while (j < items.length && items [j].setRadioSelection (false)) j++;
- setSelection (true);
-}
-
-/**
- * Sets the control that is used to fill the bounds of
- * the item when the items is a <code>SEPARATOR</code>.
- *
- * @param control the new control
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_INVALID_ARGUMENT - if the control has been disposed</li>
- * <li>ERROR_INVALID_PARENT - if the control is not in the same widget tree</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public void setControl (Control control) {
- checkWidget();
- if (control != null) {
- if (control.isDisposed()) error (SWT.ERROR_INVALID_ARGUMENT);
- if (control.parent != parent) error (SWT.ERROR_INVALID_PARENT);
- }
- if ((style & SWT.SEPARATOR) == 0) return;
- this.control = control;
- resizeControl ();
-}
-
-/**
- * Enables the receiver if the argument is <code>true</code>,
- * and disables it otherwise.
- * <p>
- * A disabled control is typically
- * not selectable from the user interface and draws with an
- * inactive or "grayed" look.
- * </p>
- *
- * @param enabled the new enabled state
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public void setEnabled (boolean enabled) {
- checkWidget();
- int 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);
- if (image != null) updateImages ();
-}
-
-/**
- * Sets the receiver's disabled image to the argument, which may be
- * null indicating that no disabled image should be displayed.
- * <p>
- * The disbled image is displayed when the receiver is disabled.
- * </p>
- *
- * @param image the disabled image to display on the receiver (may be null)
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_INVALID_ARGUMENT - if the image has been disposed</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public void setDisabledImage (Image image) {
- checkWidget();
- if ((style & SWT.SEPARATOR) != 0) return;
- if (image != null && image.isDisposed()) error(SWT.ERROR_INVALID_ARGUMENT);
- disabledImage = image;
- updateImages ();
-}
-
-/**
- * Sets the receiver's hot image to the argument, which may be
- * null indicating that no hot image should be displayed.
- * <p>
- * The hot image is displayed when the mouse enters the receiver.
- * </p>
- *
- * @param image the hot image to display on the receiver (may be null)
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_INVALID_ARGUMENT - if the image has been disposed</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public void setHotImage (Image image) {
- checkWidget();
- if ((style & SWT.SEPARATOR) != 0) return;
- if (image != null && image.isDisposed()) error(SWT.ERROR_INVALID_ARGUMENT);
- hotImage = image;
- updateImages ();
-}
-
-public void setImage (Image image) {
- checkWidget();
- if ((style & SWT.SEPARATOR) != 0) return;
- if (image != null && image.isDisposed()) error(SWT.ERROR_INVALID_ARGUMENT);
- super.setImage (image);
- updateImages ();
-}
-
-boolean setRadioSelection (boolean value) {
- if ((style & SWT.RADIO) == 0) return false;
- if (getSelection () != value) {
- setSelection (value);
- postEvent (SWT.Selection);
- }
- return true;
-}
-
-/**
- * Sets the selection state of the receiver.
- * <p>
- * When the receiver is of type <code>CHECK</code> or <code>RADIO</code>,
- * it is selected when it is checked (which some platforms draw as a
- * pushed in button).
- * </p>
- *
- * @param selected the new selection state
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public void setSelection (boolean selected) {
- checkWidget();
- if ((style & (SWT.CHECK | SWT.RADIO)) == 0) return;
- 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);
-}
-/**
- * Sets the receiver's text. The string may include
- * the mnemonic character.
- * </p>
- * <p>
- * Mnemonics are indicated by an '&amp' that causes the next
- * character to be the mnemonic. When the user presses a
- * key sequence that matches the mnemonic, a selection
- * event occurs. On most platforms, the mnemonic appears
- * underlined but may be emphasised in a platform specific
- * manner. The mnemonic indicator character '&amp' can be
- * escaped by doubling it in the string, causing a single
- *'&amp' to be displayed.
- * </p>
- *
- * @param string the new text
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the text is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public void setText (String string) {
- checkWidget();
- if (string == null) error (SWT.ERROR_NULL_ARGUMENT);
- if ((style & SWT.SEPARATOR) != 0) return;
- super.setText (string);
- int hwnd = parent.handle;
- int hHeap = OS.GetProcessHeap ();
- TCHAR buffer = new TCHAR (parent.getCodePage (), string, true);
- int byteCount = buffer.length () * TCHAR.sizeof;
- int pszText = OS.HeapAlloc (hHeap, OS.HEAP_ZERO_MEMORY, byteCount);
- OS.MoveMemory (pszText, buffer, byteCount);
- 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);
- 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);
-
- parent.layoutItems ();
-}
-
-/**
- * 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.
- *
- * @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);
- parent.layoutItems ();
-}
-
-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) {
- Display display = getDisplay ();
- Rectangle bounds = image.getBounds ();
- Point size = new Point (bounds.width, bounds.height);
- if (imageList == null) imageList = display.getToolImageList (size);
- info.iImage = imageList.add (image);
- parent.setImageList (imageList);
- if (disabledImageList == null) disabledImageList = display.getToolDisabledImageList (size);
- Image disabled = disabledImage;
- if (disabledImage == null) {
- if (disabledImage2 != null) disabledImage2.dispose ();
- disabledImage2 = null;
- disabled = image;
- if (!getEnabled ()) {
- 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 = display.getToolHotImageList (size);
- 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) {
- disabled = image;
- if (!getEnabled ()) {
- 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);
-
- parent.layoutItems ();
-}
-
-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;
- /*
- * This code is intentionally commented. In order to
- * consistently support radio tool items across platforms,
- * the platform radio behavior is not used.
- */
-// if ((style & SWT.RADIO) != 0) return OS.BTNS_CHECKGROUP;
- if ((style & SWT.RADIO) != 0) return OS.BTNS_CHECK;
- if ((style & SWT.SEPARATOR) != 0) return OS.BTNS_SEP;
- return OS.BTNS_BUTTON;
-}
-
-LRESULT wmCommandChild (int wParam, int lParam) {
- if ((style & SWT.RADIO) != 0) {
- if ((parent.getStyle () & SWT.NO_RADIO_GROUP) == 0) {
- selectRadio ();
- }
- }
- Event event = new Event ();
- setInputState (event, SWT.Selection);
- postEvent (SWT.Selection, event);
- return null;
-}
-
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+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>
+ * Note: Only one of the styles CHECK, PUSH, RADIO, SEPARATOR and DROP_DOWN
+ * may be specified.
+ * </p><p>
+ * IMPORTANT: This class is <em>not</em> intended to be subclassed.
+ * </p>
+ */
+public class ToolItem extends Item {
+ ToolBar parent;
+ Control control;
+ String toolTipText;
+ Image disabledImage, hotImage;
+ Image disabledImage2;
+ int id;
+
+/**
+ * Constructs a new instance of this class given its parent
+ * (which must be a <code>ToolBar</code>) and a style value
+ * describing its behavior and appearance. The item is added
+ * to the end of the items maintained by its parent.
+ * <p>
+ * The style value is either one of the style constants defined in
+ * class <code>SWT</code> which is applicable to instances of this
+ * class, or must be built by <em>bitwise OR</em>'ing together
+ * (that is, using the <code>int</code> "|" operator) two or more
+ * of those <code>SWT</code> style constants. The class description
+ * lists the style constants that are applicable to the class.
+ * Style bits are also inherited from superclasses.
+ * </p>
+ *
+ * @param parent a composite control which will be the parent of the new instance (cannot be null)
+ * @param style the style of control to construct
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
+ * <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
+ * </ul>
+ *
+ * @see SWT#PUSH
+ * @see SWT#CHECK
+ * @see SWT#RADIO
+ * @see SWT#SEPARATOR
+ * @see SWT#DROP_DOWN
+ * @see Widget#checkSubclass
+ * @see Widget#getStyle
+ */
+public ToolItem (ToolBar parent, int style) {
+ super (parent, checkStyle (style));
+ this.parent = parent;
+ parent.createItem (this, parent.getItemCount ());
+}
+
+/**
+ * Constructs a new instance of this class given its parent
+ * (which must be a <code>ToolBar</code>), a style value
+ * describing its behavior and appearance, and the index
+ * at which to place it in the items maintained by its parent.
+ * <p>
+ * The style value is either one of the style constants defined in
+ * class <code>SWT</code> which is applicable to instances of this
+ * class, or must be built by <em>bitwise OR</em>'ing together
+ * (that is, using the <code>int</code> "|" operator) two or more
+ * of those <code>SWT</code> style constants. The class description
+ * lists the style constants that are applicable to the class.
+ * Style bits are also inherited from superclasses.
+ * </p>
+ *
+ * @param parent a composite control which will be the parent of the new instance (cannot be null)
+ * @param style the style of control to construct
+ * @param index the 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#PUSH
+ * @see SWT#CHECK
+ * @see SWT#RADIO
+ * @see SWT#SEPARATOR
+ * @see SWT#DROP_DOWN
+ * @see Widget#checkSubclass
+ * @see Widget#getStyle
+ */
+public ToolItem (ToolBar parent, int style, int index) {
+ super (parent, checkStyle (style));
+ this.parent = parent;
+ 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.
+ * <p>
+ * When <code>widgetSelected</code> is called when the mouse is over the arrow portion of a drop-down tool,
+ * the event object detail field contains the value <code>SWT.ARROW</code>.
+ * <code>widgetDefaultSelected</code> is not called.
+ * </p>
+ *
+ * @param listener the listener which should be notified
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see SelectionListener
+ * @see #removeSelectionListener
+ * @see SelectionEvent
+ */
+public void addSelectionListener(SelectionListener listener) {
+ checkWidget();
+ if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+ TypedListener typedListener = new TypedListener (listener);
+ addListener (SWT.Selection,typedListener);
+ addListener (SWT.DefaultSelection,typedListener);
+}
+
+static int checkStyle (int style) {
+ return checkBits (style, SWT.PUSH, SWT.CHECK, SWT.RADIO, SWT.SEPARATOR, SWT.DROP_DOWN, 0);
+}
+
+protected void checkSubclass () {
+ if (!isValidSubclass ()) error (SWT.ERROR_INVALID_SUBCLASS);
+}
+
+void click (boolean dropDown) {
+ /*
+ * In order to emulate all the processing that
+ * happens when a mnemonic key is pressed, fake
+ * a mouse press and release. This will ensure
+ * that radio and pull down items are handled
+ * properly.
+ */
+ int hwnd = parent.handle;
+ if (OS.GetKeyState (OS.VK_LBUTTON) < 0) return;
+ int index = OS.SendMessage (hwnd, OS.TB_COMMANDTOINDEX, id, 0);
+ RECT rect = new RECT ();
+ OS.SendMessage (hwnd, OS.TB_GETITEMRECT, index, rect);
+ int lParam = (dropDown ? rect.right - 1 : rect.left) | (rect.top << 16);
+ int hotIndex = OS.SendMessage (hwnd, OS.TB_GETHOTITEM, 0, 0);
+ OS.SendMessage (hwnd, OS.WM_LBUTTONDOWN, 0, lParam);
+ OS.SendMessage (hwnd, OS.WM_LBUTTONUP, 0, lParam);
+ if (hotIndex != -1) {
+ OS.SendMessage (hwnd, OS.TB_SETHOTITEM, hotIndex, 0);
+ }
+}
+
+Image createDisabledImage (Image image, Color color) {
+ Display display = getDisplay ();
+ if (OS.IsWinCE) {
+ return new Image (display, image, SWT.IMAGE_DISABLE);
+ }
+ 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>.
+ *
+ * @return the control
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public Control getControl () {
+ checkWidget();
+ return control;
+}
+
+/**
+ * Returns the receiver's disabled image if it has one, or null
+ * if it does not.
+ * <p>
+ * The disabled image is displayed when the receiver is disabled.
+ * </p>
+ *
+ * @return the receiver's disabled image
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public Image getDisabledImage () {
+ checkWidget();
+ return disabledImage;
+}
+
+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>
+ *
+ * @see #isEnabled
+ */
+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.
+ * <p>
+ * The hot image is displayed when the mouse enters the receiver.
+ * </p>
+ *
+ * @return the receiver's hot image
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public Image getHotImage () {
+ checkWidget();
+ return hotImage;
+}
+
+/**
+ * Returns the receiver's parent, which must be a <code>ToolBar</code>.
+ *
+ * @return the receiver's parent
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public ToolBar getParent () {
+ checkWidget();
+ return parent;
+}
+
+/**
+ * Returns <code>true</code> if the receiver is selected,
+ * and false otherwise.
+ * <p>
+ * When the receiver is of type <code>CHECK</code> or <code>RADIO</code>,
+ * it is selected when it is checked (which some platforms draw as a
+ * pushed in button). If the receiver is of any other type, this method
+ * returns false.
+ * </p>
+ *
+ * @return the selection state
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public boolean getSelection () {
+ checkWidget();
+ if ((style & (SWT.CHECK | SWT.RADIO)) == 0) return false;
+ 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.
+ *
+ * @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 all
+ * of the receiver's ancestors are enabled, and <code>false</code>
+ * otherwise. A disabled control is typically not selectable from the
+ * user interface and draws with an inactive or "grayed" look.
+ *
+ * @return the receiver's enabled state
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see #getEnabled
+ */
+public boolean isEnabled () {
+ checkWidget();
+ return getEnabled () && parent.isEnabled ();
+}
+
+void 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;
+}
+
+void releaseImages () {
+ TBBUTTONINFO info = new TBBUTTONINFO ();
+ info.cbSize = TBBUTTONINFO.sizeof;
+ info.dwMask = OS.TBIF_IMAGE | OS.TBIF_STYLE;
+ int hwnd = parent.handle;
+ OS.SendMessage (hwnd, OS.TB_GETBUTTONINFO, 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) {
+ ImageList imageList = parent.getImageList ();
+ ImageList hotImageList = parent.getHotImageList ();
+ ImageList disabledImageList = parent.getDisabledImageList();
+ if (imageList != null) imageList.put (info.iImage, null);
+ if (hotImageList != null) hotImageList.put (info.iImage, null);
+ if (disabledImageList != null) disabledImageList.put (info.iImage, 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 resizeControl () {
+ if (control != null && !control.isDisposed ()) {
+ /*
+ * Set the size and location of the control
+ * separately to minimize flashing in the
+ * case where the control does not resize
+ * to the size that was requested. This
+ * case can occur when the control is a
+ * combo box.
+ */
+ Rectangle itemRect = getBounds ();
+ control.setSize (itemRect.width, itemRect.height);
+ Rectangle rect = control.getBounds ();
+ rect.x = itemRect.x + (itemRect.width - rect.width) / 2;
+ rect.y = itemRect.y + (itemRect.height - rect.height) / 2;
+ control.setLocation (rect.x, rect.y);
+ }
+}
+
+void selectRadio () {
+ int index = 0;
+ ToolItem [] items = parent.getItems ();
+ while (index < items.length && items [index] != this) index++;
+ int i = index - 1;
+ while (i >= 0 && items [i].setRadioSelection (false)) --i;
+ int j = index + 1;
+ while (j < items.length && items [j].setRadioSelection (false)) j++;
+ setSelection (true);
+}
+
+/**
+ * Sets the control that is used to fill the bounds of
+ * the item when the items is a <code>SEPARATOR</code>.
+ *
+ * @param control the new control
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_INVALID_ARGUMENT - if the control has been disposed</li>
+ * <li>ERROR_INVALID_PARENT - if the control is not in the same widget tree</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setControl (Control control) {
+ checkWidget();
+ if (control != null) {
+ if (control.isDisposed()) error (SWT.ERROR_INVALID_ARGUMENT);
+ if (control.parent != parent) error (SWT.ERROR_INVALID_PARENT);
+ }
+ if ((style & SWT.SEPARATOR) == 0) return;
+ this.control = control;
+ resizeControl ();
+}
+
+/**
+ * Enables the receiver if the argument is <code>true</code>,
+ * and disables it otherwise.
+ * <p>
+ * A disabled control is typically
+ * not selectable from the user interface and draws with an
+ * inactive or "grayed" look.
+ * </p>
+ *
+ * @param enabled the new enabled state
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setEnabled (boolean enabled) {
+ checkWidget();
+ int 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);
+ if (image != null) updateImages ();
+}
+
+/**
+ * Sets the receiver's disabled image to the argument, which may be
+ * null indicating that no disabled image should be displayed.
+ * <p>
+ * The disbled image is displayed when the receiver is disabled.
+ * </p>
+ *
+ * @param image the disabled image to display on the receiver (may be null)
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_INVALID_ARGUMENT - if the image has been disposed</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setDisabledImage (Image image) {
+ checkWidget();
+ if ((style & SWT.SEPARATOR) != 0) return;
+ if (image != null && image.isDisposed()) error(SWT.ERROR_INVALID_ARGUMENT);
+ disabledImage = image;
+ updateImages ();
+}
+
+/**
+ * Sets the receiver's hot image to the argument, which may be
+ * null indicating that no hot image should be displayed.
+ * <p>
+ * The hot image is displayed when the mouse enters the receiver.
+ * </p>
+ *
+ * @param image the hot image to display on the receiver (may be null)
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_INVALID_ARGUMENT - if the image has been disposed</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setHotImage (Image image) {
+ checkWidget();
+ if ((style & SWT.SEPARATOR) != 0) return;
+ if (image != null && image.isDisposed()) error(SWT.ERROR_INVALID_ARGUMENT);
+ hotImage = image;
+ updateImages ();
+}
+
+public void setImage (Image image) {
+ checkWidget();
+ if ((style & SWT.SEPARATOR) != 0) return;
+ if (image != null && image.isDisposed()) error(SWT.ERROR_INVALID_ARGUMENT);
+ super.setImage (image);
+ updateImages ();
+}
+
+boolean setRadioSelection (boolean value) {
+ if ((style & SWT.RADIO) == 0) return false;
+ if (getSelection () != value) {
+ setSelection (value);
+ postEvent (SWT.Selection);
+ }
+ return true;
+}
+
+/**
+ * Sets the selection state of the receiver.
+ * <p>
+ * When the receiver is of type <code>CHECK</code> or <code>RADIO</code>,
+ * it is selected when it is checked (which some platforms draw as a
+ * pushed in button).
+ * </p>
+ *
+ * @param selected the new selection state
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setSelection (boolean selected) {
+ checkWidget();
+ if ((style & (SWT.CHECK | SWT.RADIO)) == 0) return;
+ 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);
+}
+/**
+ * Sets the receiver's text. The string may include
+ * the mnemonic character.
+ * </p>
+ * <p>
+ * Mnemonics are indicated by an '&amp' that causes the next
+ * character to be the mnemonic. When the user presses a
+ * key sequence that matches the mnemonic, a selection
+ * event occurs. On most platforms, the mnemonic appears
+ * underlined but may be emphasised in a platform specific
+ * manner. The mnemonic indicator character '&amp' can be
+ * escaped by doubling it in the string, causing a single
+ *'&amp' to be displayed.
+ * </p>
+ *
+ * @param string the new text
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if the text is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setText (String string) {
+ checkWidget();
+ if (string == null) error (SWT.ERROR_NULL_ARGUMENT);
+ if ((style & SWT.SEPARATOR) != 0) return;
+ super.setText (string);
+ int hwnd = parent.handle;
+ int hHeap = OS.GetProcessHeap ();
+ TCHAR buffer = new TCHAR (parent.getCodePage (), string, true);
+ int byteCount = buffer.length () * TCHAR.sizeof;
+ int pszText = OS.HeapAlloc (hHeap, OS.HEAP_ZERO_MEMORY, byteCount);
+ OS.MoveMemory (pszText, buffer, byteCount);
+ 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);
+ 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);
+
+ parent.layoutItems ();
+}
+
+/**
+ * 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.
+ *
+ * @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);
+ parent.layoutItems ();
+}
+
+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) {
+ Display display = getDisplay ();
+ Rectangle bounds = image.getBounds ();
+ Point size = new Point (bounds.width, bounds.height);
+ if (imageList == null) imageList = display.getToolImageList (size);
+ info.iImage = imageList.add (image);
+ parent.setImageList (imageList);
+ if (disabledImageList == null) disabledImageList = display.getToolDisabledImageList (size);
+ Image disabled = disabledImage;
+ if (disabledImage == null) {
+ if (disabledImage2 != null) disabledImage2.dispose ();
+ disabledImage2 = null;
+ disabled = image;
+ if (!getEnabled ()) {
+ 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 = display.getToolHotImageList (size);
+ 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) {
+ disabled = image;
+ if (!getEnabled ()) {
+ 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);
+
+ parent.layoutItems ();
+}
+
+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;
+ /*
+ * This code is intentionally commented. In order to
+ * consistently support radio tool items across platforms,
+ * the platform radio behavior is not used.
+ */
+// if ((style & SWT.RADIO) != 0) return OS.BTNS_CHECKGROUP;
+ if ((style & SWT.RADIO) != 0) return OS.BTNS_CHECK;
+ if ((style & SWT.SEPARATOR) != 0) return OS.BTNS_SEP;
+ return OS.BTNS_BUTTON;
+}
+
+LRESULT wmCommandChild (int wParam, int lParam) {
+ if ((style & SWT.RADIO) != 0) {
+ if ((parent.getStyle () & SWT.NO_RADIO_GROUP) == 0) {
+ selectRadio ();
+ }
+ }
+ Event event = new Event ();
+ setInputState (event, SWT.Selection);
+ postEvent (SWT.Selection, event);
+ 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
index fec620169c..aab5fef74b 100755
--- 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
@@ -1,726 +1,726 @@
-package org.eclipse.swt.widgets;
-
-/*
+package org.eclipse.swt.widgets;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-import org.eclipse.swt.internal.*;
-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 that are
- * drawn onto a parent <code>Composite</code> or <code>Display</code>.
- * These rectangles can be specified to respond to mouse and key events
- * by either moving or resizing themselves accordingly. Trackers are
- * typically used to represent window geometries in a lightweight manner.
- *
- * <dl>
- * <dt><b>Styles:</b></dt>
- * <dd>LEFT, RIGHT, UP, DOWN, RESIZE</dd>
- * <dt><b>Events:</b></dt>
- * <dd>Move, Resize</dd>
- * </dl>
- * <p>
- * Note: Rectangle move behavior is assumed unless RESIZE is specified.
- * </p><p>
- * IMPORTANT: This class is <em>not</em> intended to be subclassed.
- * </p>
- */
-public class Tracker extends Widget {
- Control parent;
- Display display;
- boolean tracking, stippled;
- Rectangle [] rectangles, proportions;
- int resizeCursor, clientCursor, cursorOrientation = SWT.NONE;
- boolean inEvent = false;
-
- /*
- * The following values mirror step sizes on Windows
- */
- final static int STEPSIZE_SMALL = 1;
- final static int STEPSIZE_LARGE = 9;
-
-/**
- * Constructs a new instance of this class given its parent
- * and a style value describing its behavior and appearance.
- * <p>
- * The style value is either one of the style constants defined in
- * class <code>SWT</code> which is applicable to instances of this
- * class, or must be built by <em>bitwise OR</em>'ing together
- * (that is, using the <code>int</code> "|" operator) two or more
- * of those <code>SWT</code> style constants. The class description
- * lists the style constants that are applicable to the class.
- * Style bits are also inherited from superclasses.
- * </p>
- *
- * @param parent a widget which will be the parent of the new instance (cannot be null)
- * @param style the style of widget to construct
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
- * <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
- * </ul>
- *
- * @see SWT#LEFT
- * @see SWT#RIGHT
- * @see SWT#UP
- * @see SWT#DOWN
- * @see SWT#RESIZE
- * @see Widget#checkSubclass
- * @see Widget#getStyle
- */
-public Tracker (Composite parent, int style) {
- super (parent, checkStyle (style));
- this.parent = parent;
- display = parent.getDisplay ();
-}
-
-/**
- * Constructs a new instance of this class given the display
- * to create it on and a style value describing its behavior
- * and appearance.
- * <p>
- * The style value is either one of the style constants defined in
- * class <code>SWT</code> which is applicable to instances of this
- * class, or must be built by <em>bitwise OR</em>'ing together
- * (that is, using the <code>int</code> "|" operator) two or more
- * of those <code>SWT</code> style constants. The class description
- * lists the style constants that are applicable to the class.
- * Style bits are also inherited from superclasses.
- * </p><p>
- * Note: Currently, null can be passed in for the display argument.
- * This has the effect of creating the tracker on the currently active
- * display if there is one. If there is no current display, the
- * tracker is created on a "default" display. <b>Passing in null as
- * the display argument is not considered to be good coding style,
- * and may not be supported in a future release of SWT.</b>
- * </p>
- *
- * @param display the display to create the tracker on
- * @param style the style of control to construct
- *
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
- * <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
- * </ul>
- *
- * @see SWT#LEFT
- * @see SWT#RIGHT
- * @see SWT#UP
- * @see SWT#DOWN
- */
-public Tracker (Display display, int style) {
- if (display == null) display = Display.getCurrent ();
- if (display == null) display = Display.getDefault ();
- if (!display.isValidThread ()) {
- error (SWT.ERROR_THREAD_INVALID_ACCESS);
- }
- this.style = checkStyle (style);
- this.display = display;
-}
-
-/**
- * Adds the listener to the collection of listeners who will
- * be notified when the control is moved or resized, by sending
- * it one of the messages defined in the <code>ControlListener</code>
- * interface.
- *
- * @param listener the listener which should be notified
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see ControlListener
- * @see #removeControlListener
- */
-public void addControlListener (ControlListener listener) {
- checkWidget ();
- if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
- TypedListener typedListener = new TypedListener (listener);
- addListener (SWT.Move,typedListener);
-}
-
-Point adjustMoveCursor () {
- Rectangle bounds = computeBounds ();
- int newX = bounds.x + bounds.width / 2;
- int newY = bounds.y;
- POINT pt = new POINT ();
- pt.x = newX; pt.y = newY;
- /*
- * Convert to screen coordinates iff needed
- */
- if (parent != null) {
- OS.ClientToScreen (parent.handle, pt);
- }
- OS.SetCursorPos (pt.x, pt.y);
- return new Point (pt.x, pt.y);
-}
-
-Point adjustResizeCursor () {
- int newX, newY;
- Rectangle bounds = computeBounds ();
-
- if ((cursorOrientation & SWT.LEFT) != 0) {
- newX = bounds.x;
- } else if ((cursorOrientation & SWT.RIGHT) != 0) {
- newX = bounds.x + bounds.width;
- } else {
- newX = bounds.x + bounds.width / 2;
- }
-
- if ((cursorOrientation & SWT.UP) != 0) {
- newY = bounds.y;
- } else if ((cursorOrientation & SWT.DOWN) != 0) {
- newY = bounds.y + bounds.height;
- } else {
- newY = bounds.y + bounds.height / 2;
- }
-
- POINT pt = new POINT ();
- pt.x = newX; pt.y = newY;
- /*
- * Convert to screen coordinates iff needed
- */
- if (parent != null) {
- OS.ClientToScreen (parent.handle, pt);
- }
- OS.SetCursorPos (pt.x, pt.y);
-
- /*
- * If the client has not provided a custom cursor then determine
- * the appropriate resize cursor.
- */
- if (clientCursor == 0) {
- int newCursor = 0;
- switch (cursorOrientation) {
- case SWT.UP:
- newCursor = OS.LoadCursor (0, OS.IDC_SIZENS);
- break;
- case SWT.DOWN:
- newCursor = OS.LoadCursor (0, OS.IDC_SIZENS);
- break;
- case SWT.LEFT:
- newCursor = OS.LoadCursor (0, OS.IDC_SIZEWE);
- break;
- case SWT.RIGHT:
- newCursor = OS.LoadCursor (0, OS.IDC_SIZEWE);
- break;
- case SWT.LEFT | SWT.UP:
- newCursor = OS.LoadCursor (0, OS.IDC_SIZENWSE);
- break;
- case SWT.RIGHT | SWT.DOWN:
- newCursor = OS.LoadCursor (0, OS.IDC_SIZENWSE);
- break;
- case SWT.LEFT | SWT.DOWN:
- newCursor = OS.LoadCursor (0, OS.IDC_SIZENESW);
- break;
- case SWT.RIGHT | SWT.UP:
- newCursor = OS.LoadCursor (0, OS.IDC_SIZENESW);
- break;
- default:
- newCursor = OS.LoadCursor (0, OS.IDC_SIZEALL);
- break;
- }
- OS.SetCursor (newCursor);
- if (resizeCursor != 0) {
- OS.DestroyCursor (resizeCursor);
- }
- resizeCursor = newCursor;
- }
-
- return new Point (pt.x, pt.y);
-}
-
-static int checkStyle (int style) {
- if ((style & (SWT.LEFT | SWT.RIGHT | SWT.UP | SWT.DOWN)) == 0) {
- style |= SWT.LEFT | SWT.RIGHT | SWT.UP | SWT.DOWN;
- }
- return style;
-}
-
-/**
- * Stops displaying the tracker rectangles. Note that this is not considered
- * to be a cancelation by the user.
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public void close () {
- checkWidget ();
- tracking = false;
-}
-
-Rectangle computeBounds () {
- int xMin = rectangles [0].x;
- int yMin = rectangles [0].y;
- int xMax = rectangles [0].x + rectangles [0].width;
- int yMax = rectangles [0].y + rectangles [0].height;
-
- for (int i = 1; i < rectangles.length; i++) {
- if (rectangles [i].x < xMin) xMin = rectangles [i].x;
- if (rectangles [i].y < yMin) yMin = rectangles [i].y;
- int rectRight = rectangles [i].x + rectangles [i].width;
- if (rectRight > xMax) xMax = rectRight;
- int rectBottom = rectangles [i].y + rectangles [i].height;
- if (rectBottom > yMax) yMax = rectBottom;
- }
-
- return new Rectangle (xMin, yMin, xMax - xMin, yMax - yMin);
-}
-
-Rectangle [] computeProportions (Rectangle [] rects) {
- Rectangle [] result = new Rectangle [rects.length];
- Rectangle bounds = computeBounds ();
- for (int i = 0; i < rects.length; i++) {
- result[i] = new Rectangle (
- (rects[i].x - bounds.x) * 100 / bounds.width,
- (rects[i].y - bounds.y) * 100 / bounds.height,
- rects[i].width * 100 / bounds.width,
- rects[i].height * 100 / bounds.height);
- }
- return result;
-}
-/**
- * Draw the rectangles displayed by the tracker.
- */
-void drawRectangles (Rectangle [] rects) {
- if (parent != null) {
- if (parent.isDisposed ()) return;
- Shell shell = parent.getShell ();
- shell.update (true);
- } 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<rects.length; i++) {
- Rectangle rect = rects [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 that are being drawn, expressed relative to the parent
- * widget. If the parent is a <code>Display</code> then these are screen
- * coordinates.
- *
- * @return the bounds of the Rectangles being drawn
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public Rectangle [] getRectangles () {
- checkWidget ();
- 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;
-}
-
-void moveRectangles (int xChange, int yChange) {
- if (xChange < 0 && ((style & SWT.LEFT) == 0)) return;
- if (xChange > 0 && ((style & SWT.RIGHT) == 0)) return;
- if (yChange < 0 && ((style & SWT.UP) == 0)) return;
- if (yChange > 0 && ((style & SWT.DOWN) == 0)) return;
- Rectangle bounds = computeBounds ();
- bounds.x += xChange; bounds.y += yChange;
- for (int i = 0; i < rectangles.length; i++) {
- rectangles [i].x += xChange;
- rectangles [i].y += yChange;
- }
-}
-
-/**
- * Displays the Tracker rectangles for manipulation by the user. Returns when
- * the user has either finished manipulating the rectangles or has cancelled the
- * Tracker.
- *
- * @return <code>true</code> if the user did not cancel the Tracker, <code>false</code> otherwise
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public boolean open () {
- checkWidget ();
- if (rectangles == null) return false;
- boolean cancelled = false;
- tracking = true;
- Event event = new Event ();
- MSG msg = new MSG ();
- /*
- * If this tracker is being created without a mouse drag then
- * we need to create a transparent window that fills the screen
- * in order to get all mouse/keyboard events that occur
- * outside of our visible windows (ie.- over the desktop).
- */
- int hwndTransparent = 0;
- Callback newProc = null;
- boolean mouseDown = OS.GetKeyState(OS.VK_LBUTTON) < 0;
- if (!mouseDown) {
- int width = OS.GetSystemMetrics (OS.SM_CXSCREEN);
- int height = OS.GetSystemMetrics (OS.SM_CYSCREEN);
- hwndTransparent = OS.CreateWindowEx (
- OS.WS_EX_TRANSPARENT,
- display.windowClass,
- null,
- OS.WS_POPUP | OS.WS_VISIBLE,
- 0, 0,
- width, height,
- 0,
- 0,
- OS.GetModuleHandle (null),
- null);
- final int oldProc = OS.GetWindowLong (hwndTransparent, OS.GWL_WNDPROC);
- Object windowProc = new Object () {
- public int windowProc (int hwnd, int msg, int wParam, int lParam) {
- switch (msg) {
- /*
- * We typically do not want to answer that the transparent window is
- * transparent to hits since doing so negates the effect of having it
- * to grab events. However, clients of the tracker should not be aware
- * of this transparent window. Therefore if there is a hit query
- * performed as a result of client code then answer that the transparent
- * window is transparent to hits so that its existence will not impact
- * the client.
- */
- case OS.WM_NCHITTEST:
- if (inEvent) return OS.HTTRANSPARENT;
- break;
- case OS.WM_SETCURSOR:
- if (clientCursor != 0) {
- OS.SetCursor(clientCursor);
- return 1;
- }
- if (resizeCursor != 0) {
- OS.SetCursor(resizeCursor);
- return 1;
- }
- }
- return OS.CallWindowProc (oldProc, hwnd, msg, wParam, lParam);
- }
- };
- newProc = new Callback (windowProc, "windowProc", 4);
- OS.SetWindowLong (hwndTransparent, OS.GWL_WNDPROC, newProc.getAddress ());
- }
-
- drawRectangles (rectangles);
- Point cursorPos;
- if (mouseDown) {
- POINT pt = new POINT ();
- OS.GetCursorPos (pt);
- cursorPos = new Point (pt.x, pt.y);
- } else {
- if ((style & SWT.RESIZE) != 0) {
- cursorPos = adjustResizeCursor ();
- } else {
- cursorPos = adjustMoveCursor ();
- }
- }
-
- int oldX = cursorPos.x, oldY = cursorPos.y;
- /*
- * Tracker behaves like a Dialog with its own OS event loop.
- */
- while (tracking && !cancelled) {
- if (parent != null && parent.isDisposed ()) break;
- OS.GetMessage (msg, 0, 0, 0);
- int message = msg.message;
- switch (message) {
- case OS.WM_LBUTTONUP:
- case OS.WM_MOUSEMOVE:
- int newPos = OS.GetMessagePos ();
- int newX = (short) (newPos & 0xFFFF);
- int newY = (short) (newPos >> 16);
- if (newX != oldX || newY != oldY) {
- drawRectangles (rectangles);
- event.x = newX;
- event.y = newY;
- if ((style & SWT.RESIZE) != 0) {
- resizeRectangles (newX - oldX, newY - oldY);
- cursorPos = adjustResizeCursor ();
- newX = cursorPos.x; newY = cursorPos.y;
- inEvent = true;
- sendEvent (SWT.Resize, event);
- } else {
- moveRectangles (newX - oldX, newY - oldY);
- inEvent = true;
- sendEvent (SWT.Move, event);
- }
- inEvent = false;
- /*
- * It is possible (but unlikely), that application
- * code could have disposed the widget in the move
- * event. If this happens, return false to indicate
- * that the tracking has failed.
- */
- if (isDisposed ()) return false;
- drawRectangles (rectangles);
- oldX = newX; oldY = newY;
- }
- tracking = msg.message != OS.WM_LBUTTONUP;
- break;
- case OS.WM_SYSKEYDOWN:
- cancelled = true;
- tracking = false;
- break;
- case OS.WM_KEYDOWN:
- int stepSize = OS.GetKeyState (OS.VK_CONTROL) < 0 ? STEPSIZE_SMALL : STEPSIZE_LARGE;
- int xChange = 0, yChange = 0;
- switch (msg.wParam) {
- case OS.VK_ESCAPE:
- cancelled = true;
- tracking = false;
- break;
- case OS.VK_RETURN:
- tracking = false;
- break;
- case OS.VK_LEFT:
- xChange = -stepSize;
- break;
- case OS.VK_RIGHT:
- xChange = stepSize;
- break;
- case OS.VK_UP:
- yChange = -stepSize;
- break;
- case OS.VK_DOWN:
- yChange = stepSize;
- break;
- }
- if (xChange != 0 || yChange != 0) {
- drawRectangles (rectangles);
- newX = oldX + xChange;
- newY = oldY + yChange;
- event.x = newX;
- event.y = newY;
- if ((style & SWT.RESIZE) != 0) {
- resizeRectangles (xChange, yChange);
- cursorPos = adjustResizeCursor ();
- inEvent = true;
- sendEvent (SWT.Resize, event);
- } else {
- moveRectangles (xChange, yChange);
- cursorPos = adjustMoveCursor ();
- inEvent = true;
- sendEvent (SWT.Move, event);
- }
- inEvent = false;
- /*
- * It is possible (but unlikely) that application
- * code could have disposed the widget in the move
- * event. If this happens return false to indicate
- * that the tracking has failed.
- */
- if (isDisposed ()) return false;
- drawRectangles (rectangles);
- oldX = cursorPos.x; oldY = cursorPos.y;
- }
- break;
- }
- /*
- * Don't dispatch mouse and key events in general, EXCEPT once this
- * tracker has finished its work.
- */
- if (tracking && !cancelled) {
- if (OS.WM_KEYFIRST <= message && message <= OS.WM_KEYLAST) continue;
- if (OS.WM_MOUSEFIRST <= message && message <= OS.WM_MOUSELAST) continue;
- }
- OS.DispatchMessage (msg);
- }
- drawRectangles (rectangles);
- /*
- * Cleanup: If a transparent window was created in order to capture events then
- * destroy it and its callback object now.
- */
- if (hwndTransparent != 0) {
- OS.DestroyWindow (hwndTransparent);
- }
- if (newProc != null) {
- newProc.dispose();
- }
- /*
- * Cleanup: If this tracker was resizing then the last cursor that it created
- * needs to be destroyed.
- */
- if (resizeCursor != 0) {
- OS.DestroyCursor (resizeCursor);
- }
- 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);
-}
-
-void resizeRectangles (int xChange, int yChange) {
- /*
- * If the cursor orientation has not been set in the orientation of
- * this change then try to set it here.
- */
- if (xChange < 0 && ((style & SWT.LEFT) != 0) && ((cursorOrientation & SWT.RIGHT) == 0)) {
- cursorOrientation |= SWT.LEFT;
- } else if (xChange > 0 && ((style & SWT.RIGHT) != 0) && ((cursorOrientation & SWT.LEFT) == 0)) {
- cursorOrientation |= SWT.RIGHT;
- } else if (yChange < 0 && ((style & SWT.UP) != 0) && ((cursorOrientation & SWT.DOWN) == 0)) {
- cursorOrientation |= SWT.UP;
- } else if (yChange > 0 && ((style & SWT.DOWN) != 0) && ((cursorOrientation & SWT.UP) == 0)) {
- cursorOrientation |= SWT.DOWN;
- }
- Rectangle bounds = computeBounds ();
- if ((cursorOrientation & SWT.LEFT) != 0) {
- bounds.x += xChange;
- bounds.width -= xChange;
- } else if ((cursorOrientation & SWT.RIGHT) != 0) {
- bounds.width += xChange;
- }
- if ((cursorOrientation & SWT.UP) != 0) {
- bounds.y += yChange;
- bounds.height -= yChange;
- } else if ((cursorOrientation & SWT.DOWN) != 0) {
- bounds.height += yChange;
- }
- /*
- * The following are conditions under which the resize should not be applied
- */
- if (bounds.width < 0 || bounds.height < 0) return;
-
- Rectangle [] newRects = new Rectangle [rectangles.length];
- for (int i = 0; i < rectangles.length; i++) {
- Rectangle proportion = proportions[i];
- newRects[i] = new Rectangle (
- proportion.x * bounds.width / 100 + bounds.x,
- proportion.y * bounds.height / 100 + bounds.y,
- proportion.width * bounds.width / 100,
- proportion.height * bounds.height / 100);
- }
- rectangles = newRects;
-}
-
-/**
- * Sets the <code>Cursor</code> of the Tracker. If this cursor is <code>null</code>
- * then the cursor reverts to the default.
- *
- * @param newCursor the new <code>Cursor</code> to display
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public void setCursor(Cursor newCursor) {
- checkWidget();
- clientCursor = 0;
- if (newCursor != null) {
- clientCursor = newCursor.handle;
- if (inEvent) OS.SetCursor(clientCursor);
- }
-}
-/**
- * Specifies the rectangles that should be drawn, expressed relative to the parent
- * widget. If the parent is a Display then these are screen coordinates.
- *
- * @param rectangles the bounds of the rectangles to be drawn
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the 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;
- proportions = computeProportions (rectangles);
-}
-
-/**
- * Changes the appearance of the line used to draw the rectangles.
- *
- * @param stippled <code>true</code> if rectangle should appear stippled
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public void setStippled (boolean stippled) {
- checkWidget ();
- this.stippled = stippled;
-}
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+import org.eclipse.swt.internal.*;
+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 that are
+ * drawn onto a parent <code>Composite</code> or <code>Display</code>.
+ * These rectangles can be specified to respond to mouse and key events
+ * by either moving or resizing themselves accordingly. Trackers are
+ * typically used to represent window geometries in a lightweight manner.
+ *
+ * <dl>
+ * <dt><b>Styles:</b></dt>
+ * <dd>LEFT, RIGHT, UP, DOWN, RESIZE</dd>
+ * <dt><b>Events:</b></dt>
+ * <dd>Move, Resize</dd>
+ * </dl>
+ * <p>
+ * Note: Rectangle move behavior is assumed unless RESIZE is specified.
+ * </p><p>
+ * IMPORTANT: This class is <em>not</em> intended to be subclassed.
+ * </p>
+ */
+public class Tracker extends Widget {
+ Control parent;
+ Display display;
+ boolean tracking, stippled;
+ Rectangle [] rectangles, proportions;
+ int resizeCursor, clientCursor, cursorOrientation = SWT.NONE;
+ boolean inEvent = false;
+
+ /*
+ * The following values mirror step sizes on Windows
+ */
+ final static int STEPSIZE_SMALL = 1;
+ final static int STEPSIZE_LARGE = 9;
+
+/**
+ * Constructs a new instance of this class given its parent
+ * and a style value describing its behavior and appearance.
+ * <p>
+ * The style value is either one of the style constants defined in
+ * class <code>SWT</code> which is applicable to instances of this
+ * class, or must be built by <em>bitwise OR</em>'ing together
+ * (that is, using the <code>int</code> "|" operator) two or more
+ * of those <code>SWT</code> style constants. The class description
+ * lists the style constants that are applicable to the class.
+ * Style bits are also inherited from superclasses.
+ * </p>
+ *
+ * @param parent a widget which will be the parent of the new instance (cannot be null)
+ * @param style the style of widget to construct
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
+ * <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
+ * </ul>
+ *
+ * @see SWT#LEFT
+ * @see SWT#RIGHT
+ * @see SWT#UP
+ * @see SWT#DOWN
+ * @see SWT#RESIZE
+ * @see Widget#checkSubclass
+ * @see Widget#getStyle
+ */
+public Tracker (Composite parent, int style) {
+ super (parent, checkStyle (style));
+ this.parent = parent;
+ display = parent.getDisplay ();
+}
+
+/**
+ * Constructs a new instance of this class given the display
+ * to create it on and a style value describing its behavior
+ * and appearance.
+ * <p>
+ * The style value is either one of the style constants defined in
+ * class <code>SWT</code> which is applicable to instances of this
+ * class, or must be built by <em>bitwise OR</em>'ing together
+ * (that is, using the <code>int</code> "|" operator) two or more
+ * of those <code>SWT</code> style constants. The class description
+ * lists the style constants that are applicable to the class.
+ * Style bits are also inherited from superclasses.
+ * </p><p>
+ * Note: Currently, null can be passed in for the display argument.
+ * This has the effect of creating the tracker on the currently active
+ * display if there is one. If there is no current display, the
+ * tracker is created on a "default" display. <b>Passing in null as
+ * the display argument is not considered to be good coding style,
+ * and may not be supported in a future release of SWT.</b>
+ * </p>
+ *
+ * @param display the display to create the tracker on
+ * @param style the style of control to construct
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
+ * <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
+ * </ul>
+ *
+ * @see SWT#LEFT
+ * @see SWT#RIGHT
+ * @see SWT#UP
+ * @see SWT#DOWN
+ */
+public Tracker (Display display, int style) {
+ if (display == null) display = Display.getCurrent ();
+ if (display == null) display = Display.getDefault ();
+ if (!display.isValidThread ()) {
+ error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ }
+ this.style = checkStyle (style);
+ this.display = display;
+}
+
+/**
+ * Adds the listener to the collection of listeners who will
+ * be notified when the control is moved or resized, by sending
+ * it one of the messages defined in the <code>ControlListener</code>
+ * interface.
+ *
+ * @param listener the listener which should be notified
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see ControlListener
+ * @see #removeControlListener
+ */
+public void addControlListener (ControlListener listener) {
+ checkWidget ();
+ if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+ TypedListener typedListener = new TypedListener (listener);
+ addListener (SWT.Move,typedListener);
+}
+
+Point adjustMoveCursor () {
+ Rectangle bounds = computeBounds ();
+ int newX = bounds.x + bounds.width / 2;
+ int newY = bounds.y;
+ POINT pt = new POINT ();
+ pt.x = newX; pt.y = newY;
+ /*
+ * Convert to screen coordinates iff needed
+ */
+ if (parent != null) {
+ OS.ClientToScreen (parent.handle, pt);
+ }
+ OS.SetCursorPos (pt.x, pt.y);
+ return new Point (pt.x, pt.y);
+}
+
+Point adjustResizeCursor () {
+ int newX, newY;
+ Rectangle bounds = computeBounds ();
+
+ if ((cursorOrientation & SWT.LEFT) != 0) {
+ newX = bounds.x;
+ } else if ((cursorOrientation & SWT.RIGHT) != 0) {
+ newX = bounds.x + bounds.width;
+ } else {
+ newX = bounds.x + bounds.width / 2;
+ }
+
+ if ((cursorOrientation & SWT.UP) != 0) {
+ newY = bounds.y;
+ } else if ((cursorOrientation & SWT.DOWN) != 0) {
+ newY = bounds.y + bounds.height;
+ } else {
+ newY = bounds.y + bounds.height / 2;
+ }
+
+ POINT pt = new POINT ();
+ pt.x = newX; pt.y = newY;
+ /*
+ * Convert to screen coordinates iff needed
+ */
+ if (parent != null) {
+ OS.ClientToScreen (parent.handle, pt);
+ }
+ OS.SetCursorPos (pt.x, pt.y);
+
+ /*
+ * If the client has not provided a custom cursor then determine
+ * the appropriate resize cursor.
+ */
+ if (clientCursor == 0) {
+ int newCursor = 0;
+ switch (cursorOrientation) {
+ case SWT.UP:
+ newCursor = OS.LoadCursor (0, OS.IDC_SIZENS);
+ break;
+ case SWT.DOWN:
+ newCursor = OS.LoadCursor (0, OS.IDC_SIZENS);
+ break;
+ case SWT.LEFT:
+ newCursor = OS.LoadCursor (0, OS.IDC_SIZEWE);
+ break;
+ case SWT.RIGHT:
+ newCursor = OS.LoadCursor (0, OS.IDC_SIZEWE);
+ break;
+ case SWT.LEFT | SWT.UP:
+ newCursor = OS.LoadCursor (0, OS.IDC_SIZENWSE);
+ break;
+ case SWT.RIGHT | SWT.DOWN:
+ newCursor = OS.LoadCursor (0, OS.IDC_SIZENWSE);
+ break;
+ case SWT.LEFT | SWT.DOWN:
+ newCursor = OS.LoadCursor (0, OS.IDC_SIZENESW);
+ break;
+ case SWT.RIGHT | SWT.UP:
+ newCursor = OS.LoadCursor (0, OS.IDC_SIZENESW);
+ break;
+ default:
+ newCursor = OS.LoadCursor (0, OS.IDC_SIZEALL);
+ break;
+ }
+ OS.SetCursor (newCursor);
+ if (resizeCursor != 0) {
+ OS.DestroyCursor (resizeCursor);
+ }
+ resizeCursor = newCursor;
+ }
+
+ return new Point (pt.x, pt.y);
+}
+
+static int checkStyle (int style) {
+ if ((style & (SWT.LEFT | SWT.RIGHT | SWT.UP | SWT.DOWN)) == 0) {
+ style |= SWT.LEFT | SWT.RIGHT | SWT.UP | SWT.DOWN;
+ }
+ return style;
+}
+
+/**
+ * Stops displaying the tracker rectangles. Note that this is not considered
+ * to be a cancelation by the user.
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void close () {
+ checkWidget ();
+ tracking = false;
+}
+
+Rectangle computeBounds () {
+ int xMin = rectangles [0].x;
+ int yMin = rectangles [0].y;
+ int xMax = rectangles [0].x + rectangles [0].width;
+ int yMax = rectangles [0].y + rectangles [0].height;
+
+ for (int i = 1; i < rectangles.length; i++) {
+ if (rectangles [i].x < xMin) xMin = rectangles [i].x;
+ if (rectangles [i].y < yMin) yMin = rectangles [i].y;
+ int rectRight = rectangles [i].x + rectangles [i].width;
+ if (rectRight > xMax) xMax = rectRight;
+ int rectBottom = rectangles [i].y + rectangles [i].height;
+ if (rectBottom > yMax) yMax = rectBottom;
+ }
+
+ return new Rectangle (xMin, yMin, xMax - xMin, yMax - yMin);
+}
+
+Rectangle [] computeProportions (Rectangle [] rects) {
+ Rectangle [] result = new Rectangle [rects.length];
+ Rectangle bounds = computeBounds ();
+ for (int i = 0; i < rects.length; i++) {
+ result[i] = new Rectangle (
+ (rects[i].x - bounds.x) * 100 / bounds.width,
+ (rects[i].y - bounds.y) * 100 / bounds.height,
+ rects[i].width * 100 / bounds.width,
+ rects[i].height * 100 / bounds.height);
+ }
+ return result;
+}
+/**
+ * Draw the rectangles displayed by the tracker.
+ */
+void drawRectangles (Rectangle [] rects) {
+ if (parent != null) {
+ if (parent.isDisposed ()) return;
+ Shell shell = parent.getShell ();
+ shell.update (true);
+ } 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<rects.length; i++) {
+ Rectangle rect = rects [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 that are being drawn, expressed relative to the parent
+ * widget. If the parent is a <code>Display</code> then these are screen
+ * coordinates.
+ *
+ * @return the bounds of the Rectangles being drawn
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public Rectangle [] getRectangles () {
+ checkWidget ();
+ 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;
+}
+
+void moveRectangles (int xChange, int yChange) {
+ if (xChange < 0 && ((style & SWT.LEFT) == 0)) return;
+ if (xChange > 0 && ((style & SWT.RIGHT) == 0)) return;
+ if (yChange < 0 && ((style & SWT.UP) == 0)) return;
+ if (yChange > 0 && ((style & SWT.DOWN) == 0)) return;
+ Rectangle bounds = computeBounds ();
+ bounds.x += xChange; bounds.y += yChange;
+ for (int i = 0; i < rectangles.length; i++) {
+ rectangles [i].x += xChange;
+ rectangles [i].y += yChange;
+ }
+}
+
+/**
+ * Displays the Tracker rectangles for manipulation by the user. Returns when
+ * the user has either finished manipulating the rectangles or has cancelled the
+ * Tracker.
+ *
+ * @return <code>true</code> if the user did not cancel the Tracker, <code>false</code> otherwise
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public boolean open () {
+ checkWidget ();
+ if (rectangles == null) return false;
+ boolean cancelled = false;
+ tracking = true;
+ Event event = new Event ();
+ MSG msg = new MSG ();
+ /*
+ * If this tracker is being created without a mouse drag then
+ * we need to create a transparent window that fills the screen
+ * in order to get all mouse/keyboard events that occur
+ * outside of our visible windows (ie.- over the desktop).
+ */
+ int hwndTransparent = 0;
+ Callback newProc = null;
+ boolean mouseDown = OS.GetKeyState(OS.VK_LBUTTON) < 0;
+ if (!mouseDown) {
+ int width = OS.GetSystemMetrics (OS.SM_CXSCREEN);
+ int height = OS.GetSystemMetrics (OS.SM_CYSCREEN);
+ hwndTransparent = OS.CreateWindowEx (
+ OS.WS_EX_TRANSPARENT,
+ display.windowClass,
+ null,
+ OS.WS_POPUP | OS.WS_VISIBLE,
+ 0, 0,
+ width, height,
+ 0,
+ 0,
+ OS.GetModuleHandle (null),
+ null);
+ final int oldProc = OS.GetWindowLong (hwndTransparent, OS.GWL_WNDPROC);
+ Object windowProc = new Object () {
+ public int windowProc (int hwnd, int msg, int wParam, int lParam) {
+ switch (msg) {
+ /*
+ * We typically do not want to answer that the transparent window is
+ * transparent to hits since doing so negates the effect of having it
+ * to grab events. However, clients of the tracker should not be aware
+ * of this transparent window. Therefore if there is a hit query
+ * performed as a result of client code then answer that the transparent
+ * window is transparent to hits so that its existence will not impact
+ * the client.
+ */
+ case OS.WM_NCHITTEST:
+ if (inEvent) return OS.HTTRANSPARENT;
+ break;
+ case OS.WM_SETCURSOR:
+ if (clientCursor != 0) {
+ OS.SetCursor(clientCursor);
+ return 1;
+ }
+ if (resizeCursor != 0) {
+ OS.SetCursor(resizeCursor);
+ return 1;
+ }
+ }
+ return OS.CallWindowProc (oldProc, hwnd, msg, wParam, lParam);
+ }
+ };
+ newProc = new Callback (windowProc, "windowProc", 4);
+ OS.SetWindowLong (hwndTransparent, OS.GWL_WNDPROC, newProc.getAddress ());
+ }
+
+ drawRectangles (rectangles);
+ Point cursorPos;
+ if (mouseDown) {
+ POINT pt = new POINT ();
+ OS.GetCursorPos (pt);
+ cursorPos = new Point (pt.x, pt.y);
+ } else {
+ if ((style & SWT.RESIZE) != 0) {
+ cursorPos = adjustResizeCursor ();
+ } else {
+ cursorPos = adjustMoveCursor ();
+ }
+ }
+
+ int oldX = cursorPos.x, oldY = cursorPos.y;
+ /*
+ * Tracker behaves like a Dialog with its own OS event loop.
+ */
+ while (tracking && !cancelled) {
+ if (parent != null && parent.isDisposed ()) break;
+ OS.GetMessage (msg, 0, 0, 0);
+ int message = msg.message;
+ switch (message) {
+ case OS.WM_LBUTTONUP:
+ case OS.WM_MOUSEMOVE:
+ int newPos = OS.GetMessagePos ();
+ int newX = (short) (newPos & 0xFFFF);
+ int newY = (short) (newPos >> 16);
+ if (newX != oldX || newY != oldY) {
+ drawRectangles (rectangles);
+ event.x = newX;
+ event.y = newY;
+ if ((style & SWT.RESIZE) != 0) {
+ resizeRectangles (newX - oldX, newY - oldY);
+ cursorPos = adjustResizeCursor ();
+ newX = cursorPos.x; newY = cursorPos.y;
+ inEvent = true;
+ sendEvent (SWT.Resize, event);
+ } else {
+ moveRectangles (newX - oldX, newY - oldY);
+ inEvent = true;
+ sendEvent (SWT.Move, event);
+ }
+ inEvent = false;
+ /*
+ * It is possible (but unlikely), that application
+ * code could have disposed the widget in the move
+ * event. If this happens, return false to indicate
+ * that the tracking has failed.
+ */
+ if (isDisposed ()) return false;
+ drawRectangles (rectangles);
+ oldX = newX; oldY = newY;
+ }
+ tracking = msg.message != OS.WM_LBUTTONUP;
+ break;
+ case OS.WM_SYSKEYDOWN:
+ cancelled = true;
+ tracking = false;
+ break;
+ case OS.WM_KEYDOWN:
+ int stepSize = OS.GetKeyState (OS.VK_CONTROL) < 0 ? STEPSIZE_SMALL : STEPSIZE_LARGE;
+ int xChange = 0, yChange = 0;
+ switch (msg.wParam) {
+ case OS.VK_ESCAPE:
+ cancelled = true;
+ tracking = false;
+ break;
+ case OS.VK_RETURN:
+ tracking = false;
+ break;
+ case OS.VK_LEFT:
+ xChange = -stepSize;
+ break;
+ case OS.VK_RIGHT:
+ xChange = stepSize;
+ break;
+ case OS.VK_UP:
+ yChange = -stepSize;
+ break;
+ case OS.VK_DOWN:
+ yChange = stepSize;
+ break;
+ }
+ if (xChange != 0 || yChange != 0) {
+ drawRectangles (rectangles);
+ newX = oldX + xChange;
+ newY = oldY + yChange;
+ event.x = newX;
+ event.y = newY;
+ if ((style & SWT.RESIZE) != 0) {
+ resizeRectangles (xChange, yChange);
+ cursorPos = adjustResizeCursor ();
+ inEvent = true;
+ sendEvent (SWT.Resize, event);
+ } else {
+ moveRectangles (xChange, yChange);
+ cursorPos = adjustMoveCursor ();
+ inEvent = true;
+ sendEvent (SWT.Move, event);
+ }
+ inEvent = false;
+ /*
+ * It is possible (but unlikely) that application
+ * code could have disposed the widget in the move
+ * event. If this happens return false to indicate
+ * that the tracking has failed.
+ */
+ if (isDisposed ()) return false;
+ drawRectangles (rectangles);
+ oldX = cursorPos.x; oldY = cursorPos.y;
+ }
+ break;
+ }
+ /*
+ * Don't dispatch mouse and key events in general, EXCEPT once this
+ * tracker has finished its work.
+ */
+ if (tracking && !cancelled) {
+ if (OS.WM_KEYFIRST <= message && message <= OS.WM_KEYLAST) continue;
+ if (OS.WM_MOUSEFIRST <= message && message <= OS.WM_MOUSELAST) continue;
+ }
+ OS.DispatchMessage (msg);
+ }
+ drawRectangles (rectangles);
+ /*
+ * Cleanup: If a transparent window was created in order to capture events then
+ * destroy it and its callback object now.
+ */
+ if (hwndTransparent != 0) {
+ OS.DestroyWindow (hwndTransparent);
+ }
+ if (newProc != null) {
+ newProc.dispose();
+ }
+ /*
+ * Cleanup: If this tracker was resizing then the last cursor that it created
+ * needs to be destroyed.
+ */
+ if (resizeCursor != 0) {
+ OS.DestroyCursor (resizeCursor);
+ }
+ 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);
+}
+
+void resizeRectangles (int xChange, int yChange) {
+ /*
+ * If the cursor orientation has not been set in the orientation of
+ * this change then try to set it here.
+ */
+ if (xChange < 0 && ((style & SWT.LEFT) != 0) && ((cursorOrientation & SWT.RIGHT) == 0)) {
+ cursorOrientation |= SWT.LEFT;
+ } else if (xChange > 0 && ((style & SWT.RIGHT) != 0) && ((cursorOrientation & SWT.LEFT) == 0)) {
+ cursorOrientation |= SWT.RIGHT;
+ } else if (yChange < 0 && ((style & SWT.UP) != 0) && ((cursorOrientation & SWT.DOWN) == 0)) {
+ cursorOrientation |= SWT.UP;
+ } else if (yChange > 0 && ((style & SWT.DOWN) != 0) && ((cursorOrientation & SWT.UP) == 0)) {
+ cursorOrientation |= SWT.DOWN;
+ }
+ Rectangle bounds = computeBounds ();
+ if ((cursorOrientation & SWT.LEFT) != 0) {
+ bounds.x += xChange;
+ bounds.width -= xChange;
+ } else if ((cursorOrientation & SWT.RIGHT) != 0) {
+ bounds.width += xChange;
+ }
+ if ((cursorOrientation & SWT.UP) != 0) {
+ bounds.y += yChange;
+ bounds.height -= yChange;
+ } else if ((cursorOrientation & SWT.DOWN) != 0) {
+ bounds.height += yChange;
+ }
+ /*
+ * The following are conditions under which the resize should not be applied
+ */
+ if (bounds.width < 0 || bounds.height < 0) return;
+
+ Rectangle [] newRects = new Rectangle [rectangles.length];
+ for (int i = 0; i < rectangles.length; i++) {
+ Rectangle proportion = proportions[i];
+ newRects[i] = new Rectangle (
+ proportion.x * bounds.width / 100 + bounds.x,
+ proportion.y * bounds.height / 100 + bounds.y,
+ proportion.width * bounds.width / 100,
+ proportion.height * bounds.height / 100);
+ }
+ rectangles = newRects;
+}
+
+/**
+ * Sets the <code>Cursor</code> of the Tracker. If this cursor is <code>null</code>
+ * then the cursor reverts to the default.
+ *
+ * @param newCursor the new <code>Cursor</code> to display
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setCursor(Cursor newCursor) {
+ checkWidget();
+ clientCursor = 0;
+ if (newCursor != null) {
+ clientCursor = newCursor.handle;
+ if (inEvent) OS.SetCursor(clientCursor);
+ }
+}
+/**
+ * Specifies the rectangles that should be drawn, expressed relative to the parent
+ * widget. If the parent is a Display then these are screen coordinates.
+ *
+ * @param rectangles the bounds of the rectangles to be drawn
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the 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;
+ proportions = computeProportions (rectangles);
+}
+
+/**
+ * Changes the appearance of the line used to draw the rectangles.
+ *
+ * @param stippled <code>true</code> if rectangle should appear stippled
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setStippled (boolean stippled) {
+ checkWidget ();
+ this.stippled = stippled;
+}
+}
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
index c55e81d651..c08db437da 100755
--- 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
@@ -1,1907 +1,1907 @@
-package org.eclipse.swt.widgets;
-
-/*
+package org.eclipse.swt.widgets;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-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>
- * The item children that may be added to instances of this class
- * must be of type <code>TreeItem</code>.
- * </p><p>
- * Note that although this class is a subclass of <code>Composite</code>,
- * it does not make sense to add <code>Control</code> children to it,
- * or set a layout on it.
- * </p><p>
- * <dl>
- * <dt><b>Styles:</b></dt>
- * <dd>SINGLE, MULTI, CHECK</dd>
- * <dt><b>Events:</b></dt>
- * <dd>Selection, DefaultSelection, Collapse, Expand</dd>
- * </dl>
- * <p>
- * Note: Only one of the styles SINGLE and MULTI may be specified.
- * </p><p>
- * IMPORTANT: This class is <em>not</em> intended to be subclassed.
- * </p>
- */
-public class Tree extends Composite {
- int hAnchor;
- TreeItem [] items;
- ImageList imageList;
- boolean dragStarted;
- boolean ignoreSelect, ignoreExpand, ignoreDeselect;
- boolean customDraw;
- static final int TreeProc;
- static final TCHAR TreeClass = new TCHAR (0, OS.WC_TREEVIEW, true);
- static {
- WNDCLASS lpWndClass = new WNDCLASS ();
- OS.GetClassInfo (0, TreeClass, lpWndClass);
- TreeProc = 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
- * lists the style constants that are applicable to the class.
- * Style bits are also inherited from superclasses.
- * </p>
- *
- * @param parent a composite control which will be the parent of the new instance (cannot be null)
- * @param style the style of control to construct
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
- * <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
- * </ul>
- *
- * @see SWT#SINGLE
- * @see SWT#MULTI
- * @see SWT#CHECK
- * @see Widget#checkSubclass
- * @see Widget#getStyle
- */
-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.
- * <p>
- * When <code>widgetSelected</code> is called, the item field of the event object is valid.
- * If the reciever has <code>SWT.CHECK</code> style set and the check selection changes,
- * the event object detail field contains the value <code>SWT.CHECK</code>.
- * <code>widgetDefaultSelected</code> is typically called when an item is double-clicked.
- * The item field of the event object is valid for default selection, but the detail field is not used.
- * </p>
- *
- * @param listener the listener which should be notified
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see SelectionListener
- * @see #removeSelectionListener
- * @see SelectionEvent
- */
-public void addSelectionListener(SelectionListener listener) {
- checkWidget ();
- if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
- TypedListener typedListener = new TypedListener (listener);
- addListener (SWT.Selection, typedListener);
- addListener (SWT.DefaultSelection, typedListener);
-}
-
-/**
- * Adds the listener to the collection of listeners who will
- * be notified when an item in the receiver is expanded or collapsed
- * by sending it one of the messages defined in the <code>TreeListener</code>
- * interface.
- *
- * @param listener the listener which should be notified
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see TreeListener
- * @see #removeTreeListener
- */
-public void addTreeListener(TreeListener listener) {
- checkWidget ();
- if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
- TypedListener typedListener = new TypedListener (listener);
- addListener (SWT.Expand, typedListener);
- addListener (SWT.Collapse, typedListener);
-}
-
-int 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) {
- item.foreground = item.background = -1;
- 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 is 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);
- }
-}
-
-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;
- 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);
- }
- TVITEM tvItem = new TVITEM ();
- tvItem.mask = OS.TVIF_HANDLE | OS.TVIF_PARAM;
- releaseItems (item.getItems (), tvItem);
- releaseItem (item, tvItem);
- 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);
- Display display = getDisplay ();
- display.releaseImageList (imageList);
- }
- imageList = null;
- customDraw = false;
- items = new TreeItem [4];
- }
-}
-
-int getBackgroundPixel () {
- if (OS.IsWinCE) return OS.GetSysColor (OS.COLOR_WINDOW);
- int pixel = OS.SendMessage (handle, OS.TVM_GETBKCOLOR, 0, 0);
- if (pixel == -1) return OS.GetSysColor (OS.COLOR_WINDOW);
- return pixel;
-}
-
-int getForegroundPixel () {
- if (OS.IsWinCE) return OS.GetSysColor (OS.COLOR_WINDOWTEXT);
- 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 point is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public TreeItem getItem (Point point) {
- checkWidget ();
- if (point == null) error (SWT.ERROR_NULL_ARGUMENT);
- 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 affect 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 affect the receiver.
- * </p>
- * @return an array representing the selection
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public TreeItem [] getSelection () {
- checkWidget ();
- 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;
- TreeItem [] guess = new TreeItem [8];
- 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) {
- if (count < guess.length) guess [count] = item;
- count++;
- }
- }
- }
- OS.SetWindowLong (handle, OS.GWL_WNDPROC, oldProc);
- if (count == 0) return new TreeItem [0];
- if (count == guess.length) return guess;
- TreeItem [] result = new TreeItem [count];
- if (count < guess.length) {
- System.arraycopy (guess, 0, result, 0, count);
- return result;
- }
- OS.SetWindowLong (handle, OS.GWL_WNDPROC, TreeProc);
- 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;
-}
-
-/**
- * Returns the item which is currently at the top of the receiver.
- * This item can change when items are expanded, collapsed, scrolled
- * or new items are added or removed.
- *
- * @return the item at the top of the receiver
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @since 2.1
- */
-public TreeItem getTopItem () {
- checkWidget ();
- int hItem = OS.SendMessage (handle, OS.TVM_GETNEXTITEM, OS.TVGN_FIRSTVISIBLE, 0);
- if (hItem == 0) return null;
- TVITEM tvItem = new TVITEM ();
- tvItem.mask = OS.TVIF_PARAM;
- tvItem.hItem = hItem;
- if (OS.SendMessage (handle, OS.TVM_GETITEM, 0, tvItem) == 0) return null;
- return items [tvItem.lParam];
-}
-
-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);
- Rectangle bounds = image.getBounds ();
- imageList = getDisplay ().getImageList (new Point (bounds.width, bounds.height));
- int index = imageList.indexOf (image);
- if (index == -1) index = imageList.add (image);
- int hImageList = imageList.getHandle ();
- OS.SendMessage (handle, OS.TVM_SETIMAGELIST, OS.TVSIL_NORMAL, hImageList);
- return index;
- }
- int index = imageList.indexOf (image);
- if (index != -1) return index;
- return imageList.add (image);
-}
-
-boolean releaseItem (TreeItem item, TVITEM tvItem) {
- int hItem = item.handle;
- if (hItem == hAnchor) hAnchor = 0;
- if (item.isDisposed ()) return false;
- tvItem.hItem = hItem;
- OS.SendMessage (handle, OS.TVM_GETITEM, 0, tvItem);
- items [tvItem.lParam] = null;
- return true;
-}
-
-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);
- }
- if (releaseItem (item, tvItem)) {
- item.releaseResources ();
- }
- }
-}
-
-void releaseWidget () {
- for (int i=0; i<items.length; i++) {
- TreeItem item = items [i];
- if (item != null && !item.isDisposed ()) {
- item.releaseResources ();
- }
- }
- /*
- * Feature in Windows. For some reason, when
- * TVM_GETIMAGELIST or TVM_SETIMAGELIST is sent,
- * the tree issues NM_CUSTOMDRAW messages. This
- * behavior is unwanted when the tree is being
- * disposed. The fix is to ingore NM_CUSTOMDRAW
- * messages by usnig the custom draw flag.
- *
- * NOTE: This only happens on Windows XP.
- */
- customDraw = false;
- items = null;
- if (imageList != null) {
- OS.SendMessage (handle, OS.TVM_SETIMAGELIST, OS.TVSIL_NORMAL, 0);
- Display display = getDisplay ();
- display.releaseImageList (imageList);
- } 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);
- super.releaseWidget ();
-}
-
-
-/**
- * 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;
- if (drawCount == 0) {
- OS.DefWindowProc (handle, OS.WM_SETREDRAW, 0, 0);
- /*
- * This code is intentionally commented.
- */
-// OS.SendMessage (handle, OS.WM_SETREDRAW, 0, 0);
- }
- int result = OS.SendMessage (handle, OS.TVM_DELETEITEM, 0, OS.TVI_ROOT);
- if (drawCount == 0) {
- OS.DefWindowProc (handle, OS.WM_SETREDRAW, 1, 0);
- /*
- * This code is intentionally commented.
- */
-// OS.SendMessage (handle, OS.WM_SETREDRAW, 1, 0);
- OS.InvalidateRect (handle, null, true);
- }
- 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.releaseResources ();
- }
- }
- if (imageList != null) {
- OS.SendMessage (handle, OS.TVM_SETIMAGELIST, 0, 0);
- Display display = getDisplay ();
- display.releaseImageList (imageList);
- }
- imageList = null;
- customDraw = false;
- 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 IllegalArgumentException <ul>
- * <li>ERROR_INVALID_ARGUMENT - if the item has been disposed</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public void setInsertMark (TreeItem item, boolean before) {
- checkWidget ();
- int hItem = 0;
- if (item != null) {
- if (item.isDisposed()) error(SWT.ERROR_INVALID_ARGUMENT);
- 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;
- }
- }
- 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 ((style & SWT.CHECK) != 0) setCheckboxImageList ();
-}
-
-void setBounds (int x, int y, int width, int height, int flags) {
- /*
- * Ensure that the selection is visible when the tree is resized
- * from a zero size to a size that can show the selection.
- */
- boolean fixSelection = false;
- if ((flags & OS.SWP_NOSIZE) == 0 && (width != 0 || height != 0)) {
- if (OS.SendMessage (handle, OS.TVM_GETVISIBLECOUNT, 0, 0) == 0) {
- fixSelection = true;
- }
- }
- super.setBounds (x, y, width, height, flags);
- if (fixSelection) {
- int hItem = OS.SendMessage (handle, OS.TVM_GETNEXTITEM, OS.TVGN_CARET, 0);
- if (hItem != 0) showItem (hItem);
- }
-}
-
-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);
-}
-
-public void setRedraw (boolean redraw) {
- checkWidget ();
- /*
- * Bug in Windows. For some reason, when WM_SETREDRAW
- * is used to turn redraw on for a tree and the tree
- * contains no items, the last item in the tree does
- * not redraw properly. If the tree has only one item,
- * that item is not drawn. If another window is dragged
- * on top of the item, parts of the item are redrawn
- * and erased at random. The fix is to ensure that this
- * case doesn't happen by inserting and deleting an item
- * when redraw is turned on and there are no items in
- * the tree.
- */
- int hItem = 0;
- if (redraw) {
- int count = OS.SendMessage (handle, OS.TVM_GETCOUNT, 0, 0);
- if (count == 0) {
- TVINSERTSTRUCT tvInsert = new TVINSERTSTRUCT ();
- tvInsert.hInsertAfter = OS.TVI_FIRST;
- hItem = OS.SendMessage (handle, OS.TVM_INSERTITEM, 0, tvInsert);
- }
- }
- super.setRedraw (redraw);
- if (hItem != 0) {
- OS.SendMessage (handle, OS.TVM_DELETEITEM, 0, hItem);
- }
-}
-
-/**
- * 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 array of items is null</li>
- * <li>ERROR_INVALID_ARGUMENT - if one of the item has been disposed</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see Tree#deselectAll()
- */
-public void setSelection (TreeItem [] items) {
- checkWidget ();
- if (items == null) error (SWT.ERROR_NULL_ARGUMENT);
-
- /* Select/deselect the first item */
- int hOldItem = OS.SendMessage (handle, OS.TVM_GETNEXTITEM, OS.TVGN_CARET, 0);
- if (items.length == 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) {
- if (item.isDisposed ()) error (SWT.ERROR_INVALID_ARGUMENT);
- hAnchor = hNewItem = item.handle;
- }
- ignoreSelect = true;
- OS.SendMessage (handle, OS.TVM_SELECTITEM, OS.TVGN_CARET, hNewItem);
- ignoreSelect = false;
- /*
- * Feature in Windows. When the old and new focused item
- * are the same, Windows does not check to make sure that
- * the item is actually selected, not just focused. The
- * fix is to force the item to draw selected by setting
- * the state mask.
- */
- if (hOldItem == hNewItem) {
- TVITEM tvItem = new TVITEM ();
- tvItem.mask = OS.TVIF_STATE;
- tvItem.state = OS.TVIS_SELECTED;
- tvItem.stateMask = OS.TVIS_SELECTED;
- tvItem.hItem = hNewItem;
- OS.SendMessage (handle, OS.TVM_SETITEM, 0, tvItem);
- }
- showItem (hNewItem);
- }
- 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);
-}
-
-/**
- * Sets the item which is currently at the top of the receiver.
- * This item can change when items are expanded, collapsed, scrolled
- * or new items are added or removed.
- *
- * @param item the item to be shown
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the item is null</li>
- * <li>ERROR_INVALID_ARGUMENT - if the item has been disposed</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see Tree#getTopItem()
- *
- * @since 2.1
- */
-public void setTopItem (TreeItem item) {
- checkWidget ();
- if (item == null) SWT.error (SWT.ERROR_NULL_ARGUMENT);
- if (item.isDisposed ()) SWT.error (SWT.ERROR_INVALID_ARGUMENT);
- OS.SendMessage (handle, OS.TVM_SELECTITEM, OS.TVGN_FIRSTVISIBLE, item.handle);
-}
-
-void showItem (int hItem) {
- /*
- * Bug in Windows. When TVM_ENSUREVISIBLE is used to ensure
- * that an item is visible and the client area of the tree is
- * smaller that the size of one item, TVM_ENSUREVISIBLE makes
- * the next item in the tree visible by making it the top item
- * instead of making the desired item visible. The fix is to
- * detect the case when the client area is too small and make
- * the desired visible item be the top item in the tree.
- */
- if (OS.SendMessage (handle, OS.TVM_GETVISIBLECOUNT, 0, 0) == 0) {
- OS.SendMessage (handle, OS.TVM_SELECTITEM, OS.TVGN_FIRSTVISIBLE, hItem);
- OS.SendMessage (handle, OS.WM_HSCROLL, OS.SB_TOP ,0);
- } else {
- boolean scroll = true;
- RECT itemRect = new RECT ();
- itemRect.left = hItem;
- if (OS.SendMessage (handle, OS.TVM_GETITEMRECT, 1, itemRect) != 0) {
- RECT rect = new RECT ();
- OS.GetClientRect (handle, rect);
- POINT pt = new POINT ();
- pt.x = itemRect.left;
- pt.y = itemRect.top;
- if (OS.PtInRect (rect, pt)) {
- pt.y = itemRect.bottom;
- if (OS.PtInRect (rect, pt)) scroll = false;
- }
- }
- if (scroll) OS.SendMessage (handle, OS.TVM_ENSUREVISIBLE, 0, hItem);
- }
-}
-
-/**
- * Shows the item. If the item is already showing in the receiver,
- * this method simply returns. Otherwise, the items are scrolled
- * and expanded until the item is visible.
- *
- * @param item the item to be shown
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the item is null</li>
- * <li>ERROR_INVALID_ARGUMENT - if the item has been disposed</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see Tree#showSelection()
- */
-public void showItem (TreeItem item) {
- checkWidget ();
- if (item == null) error (SWT.ERROR_NULL_ARGUMENT);
- if (item.isDisposed ()) error(SWT.ERROR_INVALID_ARGUMENT);
- showItem (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 SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if 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 = 0;
- if ((style & SWT.SINGLE) != 0) {
- hItem = OS.SendMessage (handle, OS.TVM_GETNEXTITEM, OS.TVGN_CARET, 0);
- if (hItem == 0) return;
- 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;
- } else {
- TVITEM tvItem = new TVITEM ();
- tvItem.mask = OS.TVIF_STATE;
- int oldProc = OS.GetWindowLong (handle, OS.GWL_WNDPROC);
- OS.SetWindowLong (handle, OS.GWL_WNDPROC, TreeProc);
- int index = 0;
- while (index <items.length) {
- TreeItem item = items [index];
- if (item != null) {
- tvItem.hItem = item.handle;
- OS.SendMessage (handle, OS.TVM_GETITEM, 0, tvItem);
- if ((tvItem.state & OS.TVIS_SELECTED) != 0) {
- hItem = tvItem.hItem;
- break;
- }
- }
- index++;
- }
- OS.SetWindowLong (handle, OS.GWL_WNDPROC, oldProc);
- }
- if (hItem != 0) showItem (hItem);
-}
-
-String toolTipText (NMTTDISPINFO hdr) {
- int hwndToolTip = OS.SendMessage (handle, OS.TVM_GETTOOLTIPS, 0, 0);
- if (hwndToolTip == hdr.hwndFrom && toolTipText != null) return "";
- return super.toolTipText (hdr);
-}
-
-int widgetStyle () {
- int bits = super.widgetStyle () | 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.
- */
-// if ((style & SWT.FULL_SELECTION) != 0) {
-// bits |= OS.TVS_FULLROWSELECT;
-// } else {
-// bits |= OS.TVS_HASLINES | OS.TVS_HASBUTTONS;
-// }
-// bits |= OS.TVS_NOTOOLTIPS;
- return bits;
-}
-
-TCHAR 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 ESC, CR or SPACE.
- * The fix is to avoid calling the tree window
- * proc in these cases.
- */
- switch (wParam) {
- case OS.VK_ESCAPE:
- case OS.VK_RETURN:
- case OS.VK_SPACE: return LRESULT.ZERO;
- }
- return result;
-}
-
-LRESULT WM_GETOBJECT (int wParam, int lParam) {
- /*
- * Ensure that there is an accessible object created for this
- * control because support for checked item accessibility is
- * temporarily implemented in the accessibility package.
- */
- if ((style & SWT.CHECK) != 0) {
- if (accessible == null) accessible = new_Accessible (this);
- }
- return super.WM_GETOBJECT (wParam, lParam);
-}
-
-LRESULT WM_KEYDOWN (int wParam, int lParam) {
- LRESULT result = super.WM_KEYDOWN (wParam, lParam);
- if (result != null) return result;
- switch (wParam) {
- case OS.VK_SPACE: {
- int hItem = OS.SendMessage (handle, OS.TVM_GETNEXTITEM, OS.TVGN_CARET, 0);
- if (hItem != 0) {
- hAnchor = hItem;
- OS.SendMessage (handle, OS.TVM_ENSUREVISIBLE, 0, hItem);
- TVITEM tvItem = new TVITEM ();
- tvItem.mask = OS.TVIF_STATE | OS.TVIF_PARAM;
- tvItem.hItem = hItem;
- if ((style & SWT.CHECK) != 0) {
- 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);
- }
- tvItem.stateMask = OS.TVIS_SELECTED;
- OS.SendMessage (handle, OS.TVM_GETITEM, 0, tvItem);
- if ((style & SWT.MULTI) != 0 && OS.GetKeyState (OS.VK_CONTROL) < 0) {
- if ((tvItem.state & OS.TVIS_SELECTED) != 0) {
- tvItem.state &= ~OS.TVIS_SELECTED;
- } else {
- tvItem.state |= OS.TVIS_SELECTED;
- }
- } else {
- tvItem.state |= OS.TVIS_SELECTED;
- }
- OS.SendMessage (handle, OS.TVM_SETITEM, 0, tvItem);
- Event event = new Event ();
- event.item = items [tvItem.lParam];
- postEvent (SWT.Selection, event);
- if ((style & SWT.CHECK) != 0) {
- event = new Event ();
- event.item = items [tvItem.lParam];
- event.detail = SWT.CHECK;
- postEvent (SWT.Selection, event);
- }
- return LRESULT.ZERO;
- }
- break;
- }
- case OS.VK_UP:
- case OS.VK_DOWN:
- case OS.VK_PRIOR:
- case OS.VK_NEXT:
- case OS.VK_HOME:
- case OS.VK_END: {
- if ((style & SWT.SINGLE) != 0) break;
- if (OS.GetKeyState (OS.VK_SHIFT) < 0) {
- int hItem = OS.SendMessage (handle, OS.TVM_GETNEXTITEM, OS.TVGN_CARET, 0);
- if (hItem != 0) {
- if (hAnchor == 0) hAnchor = hItem;
- ignoreSelect = ignoreDeselect = true;
- int code = callWindowProc (OS.WM_KEYDOWN, wParam, lParam);
- ignoreSelect = ignoreDeselect = false;
- int hNewItem = OS.SendMessage (handle, OS.TVM_GETNEXTITEM, OS.TVGN_CARET, 0);
- TVITEM tvItem = new TVITEM ();
- tvItem.mask = OS.TVIF_STATE;
- tvItem.stateMask = OS.TVIS_SELECTED;
- int hDeselectItem = hItem;
- RECT rect1 = new RECT ();
- rect1.left = hAnchor;
- OS.SendMessage (handle, OS.TVM_GETITEMRECT, 1, rect1);
- RECT rect2 = rect2 = new RECT ();
- rect2.left = hDeselectItem;
- OS.SendMessage (handle, OS.TVM_GETITEMRECT, 1, rect2);
- int flags = rect1.top < rect2.top ? OS.TVGN_PREVIOUSVISIBLE : OS.TVGN_NEXTVISIBLE;
- while (hDeselectItem != hAnchor) {
- tvItem.hItem = hDeselectItem;
- OS.SendMessage (handle, OS.TVM_SETITEM, 0, tvItem);
- hDeselectItem = OS.SendMessage (handle, OS.TVM_GETNEXTITEM, flags, hDeselectItem);
- }
- int hSelectItem = hAnchor;
- rect1.left = hNewItem;
- OS.SendMessage (handle, OS.TVM_GETITEMRECT, 1, rect1);
- rect2.left = hSelectItem;
- OS.SendMessage (handle, OS.TVM_GETITEMRECT, 1, rect2);
- tvItem.state = OS.TVIS_SELECTED;
- flags = rect1.top < rect2.top ? OS.TVGN_PREVIOUSVISIBLE : OS.TVGN_NEXTVISIBLE;
- while (hSelectItem != hNewItem) {
- tvItem.hItem = hSelectItem;
- OS.SendMessage (handle, OS.TVM_SETITEM, 0, tvItem);
- hSelectItem = OS.SendMessage (handle, OS.TVM_GETNEXTITEM, flags, hSelectItem);
- }
- tvItem.hItem = hNewItem;
- OS.SendMessage (handle, OS.TVM_SETITEM, 0, tvItem);
- tvItem.mask = OS.TVIF_PARAM;
- tvItem.hItem = hNewItem;
- OS.SendMessage (handle, OS.TVM_GETITEM, 0, tvItem);
- Event event = new Event ();
- event.item = items [tvItem.lParam];
- postEvent (SWT.Selection, event);
- return new LRESULT (code);
- }
- }
- if (OS.GetKeyState (OS.VK_CONTROL) < 0) {
- int hItem = OS.SendMessage (handle, OS.TVM_GETNEXTITEM, OS.TVGN_CARET, 0);
- if (hItem != 0) {
- TVITEM tvItem = new TVITEM ();
- tvItem.mask = OS.TVIF_STATE;
- tvItem.stateMask = OS.TVIS_SELECTED;
- tvItem.hItem = hItem;
- OS.SendMessage (handle, OS.TVM_GETITEM, 0, tvItem);
- boolean oldSelected = (tvItem.state & OS.TVIS_SELECTED) != 0;
- int hNewItem = 0;
- switch (wParam) {
- case OS.VK_UP:
- hNewItem = OS.SendMessage (handle, OS.TVM_GETNEXTITEM, OS.TVGN_PREVIOUSVISIBLE, hItem);
- break;
- case OS.VK_DOWN:
- hNewItem = OS.SendMessage (handle, OS.TVM_GETNEXTITEM, OS.TVGN_NEXTVISIBLE, hItem);
- break;
- case OS.VK_HOME:
- hNewItem = OS.SendMessage (handle, OS.TVM_GETNEXTITEM, OS.TVGN_ROOT, 0);
- break;
- case OS.VK_PRIOR:
- hNewItem = OS.SendMessage (handle, OS.TVM_GETNEXTITEM, OS.TVGN_FIRSTVISIBLE, 0);
- if (hNewItem == hItem) {
- OS.SendMessage (handle, OS.WM_VSCROLL, OS.SB_PAGEUP, 0);
- hNewItem = OS.SendMessage (handle, OS.TVM_GETNEXTITEM, OS.TVGN_FIRSTVISIBLE, 0);
- }
- break;
- case OS.VK_NEXT:
- RECT rect = new RECT (), clientRect = new RECT ();
- OS.GetClientRect (handle, clientRect);
- hNewItem = OS.SendMessage (handle, OS.TVM_GETNEXTITEM, OS.TVGN_FIRSTVISIBLE, 0);
- do {
- int hVisible = OS.SendMessage (handle, OS.TVM_GETNEXTITEM, OS.TVGN_NEXTVISIBLE, hNewItem);
- if (hVisible == 0) break;
- rect.left = hVisible;
- OS.SendMessage (handle, OS.TVM_GETITEMRECT, 1, rect);
- if (rect.bottom > clientRect.bottom) break;
- if ((hNewItem = hVisible) == hItem) {
- OS.SendMessage (handle, OS.WM_VSCROLL, OS.SB_PAGEDOWN, 0);
- }
- } while (hNewItem != 0);
- break;
- case OS.VK_END:
- hNewItem = OS.SendMessage (handle, OS.TVM_GETNEXTITEM, OS.TVGN_LASTVISIBLE, 0);
- break;
- }
- if (hNewItem != 0) {
- OS.SendMessage (handle, OS.TVM_ENSUREVISIBLE, 0, hNewItem);
- tvItem.hItem = hNewItem;
- OS.SendMessage (handle, OS.TVM_GETITEM, 0, tvItem);
- boolean newSelected = (tvItem.state & OS.TVIS_SELECTED) != 0;
- if (!newSelected && 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);
- }
- ignoreSelect = true;
- OS.SendMessage (handle, OS.TVM_SELECTITEM, OS.TVGN_CARET, hNewItem);
- ignoreSelect = false;
- if (oldSelected) {
- tvItem.state = OS.TVIS_SELECTED;
- tvItem.hItem = hItem;
- OS.SendMessage (handle, OS.TVM_SETITEM, 0, tvItem);
- }
- if (!newSelected) {
- tvItem.state = 0;
- tvItem.hItem = hNewItem;
- OS.SendMessage (handle, OS.TVM_SETITEM, 0, tvItem);
- }
- if (!newSelected && drawCount == 0) {
- RECT rect1 = new RECT (), rect2 = new RECT ();
- rect1.left = hItem; 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);
- if (OS.IsWinCE) {
- OS.InvalidateRect (handle, rect1, false);
- OS.InvalidateRect (handle, rect2, false);
- OS.UpdateWindow (handle);
- } else {
- int flags = OS.RDW_UPDATENOW | OS.RDW_INVALIDATE;
- OS.RedrawWindow (handle, rect1, 0, flags);
- OS.RedrawWindow (handle, rect2, 0, flags);
- }
- }
- return LRESULT.ZERO;
- }
- }
- }
- int code = callWindowProc (OS.WM_KEYDOWN, wParam, lParam);
- hAnchor = OS.SendMessage (handle, OS.TVM_GETNEXTITEM, OS.TVGN_CARET, 0);
- return new LRESULT (code);
- }
- }
- return result;
-}
-
-LRESULT WM_KILLFOCUS (int wParam, int lParam) {
- LRESULT result = super.WM_KILLFOCUS (wParam, lParam);
- 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. The first part of this work
- * around is to ensure that the user has selected
- * an item.
- */
- 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);
-
- /*
- * Feature in Windows. When the old and new focused item
- * are the same, Windows does not check to make sure that
- * the item is actually selected, not just focused. The
- * fix is to force the item to draw selected by setting
- * the state mask. This is only necessary when the tree
- * is single select.
- */
- if ((style & SWT.SINGLE) != 0) {
- if (hOldItem == hNewItem) {
- tvItem.mask = OS.TVIF_STATE;
- tvItem.state = OS.TVIS_SELECTED;
- tvItem.stateMask = OS.TVIS_SELECTED;
- tvItem.hItem = hNewItem;
- OS.SendMessage (handle, OS.TVM_SETITEM, 0, tvItem);
- }
- }
-
- /* 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);
- if (OS.IsWinCE) {
- OS.InvalidateRect (handle, rect1, false);
- OS.InvalidateRect (handle, rect2, false);
- OS.UpdateWindow (handle);
- } else {
- 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_PARAM;
- OS.SendMessage (handle, OS.TVM_GETITEM, 0, tvItem);
- Event event = new Event ();
- 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) {
- postEvent (SWT.DragDetect);
- } 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.mask = OS.TVIF_STATE;
- tvItem.stateMask = OS.TVIS_SELECTED;
- tvItem.hItem = lpht.hItem;
- OS.SendMessage (handle, OS.TVM_GETITEM, 0, tvItem);
- if ((tvItem.state & OS.TVIS_SELECTED) == 0) {
- ignoreSelect = true;
- OS.SendMessage (handle, OS.TVM_SELECTITEM, OS.TVGN_CARET, 0);
- ignoreSelect = false;
- 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 ((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 ((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_CUSTOMDRAW: {
- if (!customDraw) break;
- NMTVCUSTOMDRAW nmcd = new NMTVCUSTOMDRAW ();
- OS.MoveMemory (nmcd, lParam, NMTVCUSTOMDRAW.sizeof);
- switch (nmcd.dwDrawStage) {
- case OS.CDDS_PREPAINT: return new LRESULT (OS.CDRF_NOTIFYITEMDRAW);
- case OS.CDDS_ITEMPREPAINT:
- TreeItem item = items [nmcd.lItemlParam];
- /*
- * Feature on Windows. When a new tree item is inserted
- * using TVM_INSERTITEM and the tree is using custom draw,
- * a NM_CUSTOMDRAW is sent before TVM_INSERTITEM returns
- * and before the item is added to the items array. The
- * fix is to check for null.
- *
- * NOTE: This only happens on XP with the version 6.00 of
- * COMCTL32.DLL,
- */
- if (item == null) break;
- TVITEM tvItem = new TVITEM ();
- tvItem.mask = OS.TVIF_STATE;
- tvItem.hItem = item.handle;
- OS.SendMessage (handle, OS.TVM_GETITEM, 0, tvItem);
- if ((tvItem.state & OS.TVIS_SELECTED) != 0) break;
- int clrText = item.foreground, clrTextBk = item.background;
- if (clrText == -1 && clrTextBk == -1) break;
- nmcd.clrText = clrText == -1 ? getForegroundPixel () : clrText;
- nmcd.clrTextBk = clrTextBk == -1 ? getBackgroundPixel () : clrTextBk;
- OS.MoveMemory (lParam, nmcd, NMTVCUSTOMDRAW.sizeof);
- return new LRESULT (OS.CDRF_NEWFONT);
- }
- break;
- }
- 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_SELCHANGEDA:
- case OS.TVN_SELCHANGEDW:
- 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);
- hAnchor = tvItem.hItem;
- } 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.SendMessage (handle, OS.TVM_GETITEM, 0, tvItem);
- }
- }
- Event event = new Event ();
- if (tvItem != null) {
- event.item = items [tvItem.lParam];
- }
- 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_SELCHANGINGA:
- case OS.TVN_SELCHANGINGW:
- if (!ignoreSelect && !ignoreDeselect) {
- hAnchor = 0;
- if ((style & SWT.MULTI) != 0) deselectAll ();
- }
- break;
- case OS.TVN_ITEMEXPANDINGA:
- case OS.TVN_ITEMEXPANDINGW:
- 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_BEGINDRAGA:
- case OS.TVN_BEGINDRAGW:
- case OS.TVN_BEGINRDRAGA:
- case OS.TVN_BEGINRDRAGW:
- 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);
-}
-
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+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>
+ * The item children that may be added to instances of this class
+ * must be of type <code>TreeItem</code>.
+ * </p><p>
+ * Note that although this class is a subclass of <code>Composite</code>,
+ * it does not make sense to add <code>Control</code> children to it,
+ * or set a layout on it.
+ * </p><p>
+ * <dl>
+ * <dt><b>Styles:</b></dt>
+ * <dd>SINGLE, MULTI, CHECK</dd>
+ * <dt><b>Events:</b></dt>
+ * <dd>Selection, DefaultSelection, Collapse, Expand</dd>
+ * </dl>
+ * <p>
+ * Note: Only one of the styles SINGLE and MULTI may be specified.
+ * </p><p>
+ * IMPORTANT: This class is <em>not</em> intended to be subclassed.
+ * </p>
+ */
+public class Tree extends Composite {
+ int hAnchor;
+ TreeItem [] items;
+ ImageList imageList;
+ boolean dragStarted;
+ boolean ignoreSelect, ignoreExpand, ignoreDeselect;
+ boolean customDraw;
+ static final int TreeProc;
+ static final TCHAR TreeClass = new TCHAR (0, OS.WC_TREEVIEW, true);
+ static {
+ WNDCLASS lpWndClass = new WNDCLASS ();
+ OS.GetClassInfo (0, TreeClass, lpWndClass);
+ TreeProc = 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
+ * lists the style constants that are applicable to the class.
+ * Style bits are also inherited from superclasses.
+ * </p>
+ *
+ * @param parent a composite control which will be the parent of the new instance (cannot be null)
+ * @param style the style of control to construct
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
+ * <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
+ * </ul>
+ *
+ * @see SWT#SINGLE
+ * @see SWT#MULTI
+ * @see SWT#CHECK
+ * @see Widget#checkSubclass
+ * @see Widget#getStyle
+ */
+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.
+ * <p>
+ * When <code>widgetSelected</code> is called, the item field of the event object is valid.
+ * If the reciever has <code>SWT.CHECK</code> style set and the check selection changes,
+ * the event object detail field contains the value <code>SWT.CHECK</code>.
+ * <code>widgetDefaultSelected</code> is typically called when an item is double-clicked.
+ * The item field of the event object is valid for default selection, but the detail field is not used.
+ * </p>
+ *
+ * @param listener the listener which should be notified
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see SelectionListener
+ * @see #removeSelectionListener
+ * @see SelectionEvent
+ */
+public void addSelectionListener(SelectionListener listener) {
+ checkWidget ();
+ if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+ TypedListener typedListener = new TypedListener (listener);
+ addListener (SWT.Selection, typedListener);
+ addListener (SWT.DefaultSelection, typedListener);
+}
+
+/**
+ * Adds the listener to the collection of listeners who will
+ * be notified when an item in the receiver is expanded or collapsed
+ * by sending it one of the messages defined in the <code>TreeListener</code>
+ * interface.
+ *
+ * @param listener the listener which should be notified
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see TreeListener
+ * @see #removeTreeListener
+ */
+public void addTreeListener(TreeListener listener) {
+ checkWidget ();
+ if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+ TypedListener typedListener = new TypedListener (listener);
+ addListener (SWT.Expand, typedListener);
+ addListener (SWT.Collapse, typedListener);
+}
+
+int 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) {
+ item.foreground = item.background = -1;
+ 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 is 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);
+ }
+}
+
+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;
+ 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);
+ }
+ TVITEM tvItem = new TVITEM ();
+ tvItem.mask = OS.TVIF_HANDLE | OS.TVIF_PARAM;
+ releaseItems (item.getItems (), tvItem);
+ releaseItem (item, tvItem);
+ 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);
+ Display display = getDisplay ();
+ display.releaseImageList (imageList);
+ }
+ imageList = null;
+ customDraw = false;
+ items = new TreeItem [4];
+ }
+}
+
+int getBackgroundPixel () {
+ if (OS.IsWinCE) return OS.GetSysColor (OS.COLOR_WINDOW);
+ int pixel = OS.SendMessage (handle, OS.TVM_GETBKCOLOR, 0, 0);
+ if (pixel == -1) return OS.GetSysColor (OS.COLOR_WINDOW);
+ return pixel;
+}
+
+int getForegroundPixel () {
+ if (OS.IsWinCE) return OS.GetSysColor (OS.COLOR_WINDOWTEXT);
+ 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 point is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public TreeItem getItem (Point point) {
+ checkWidget ();
+ if (point == null) error (SWT.ERROR_NULL_ARGUMENT);
+ 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 affect 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 affect the receiver.
+ * </p>
+ * @return an array representing the selection
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public TreeItem [] getSelection () {
+ checkWidget ();
+ 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;
+ TreeItem [] guess = new TreeItem [8];
+ 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) {
+ if (count < guess.length) guess [count] = item;
+ count++;
+ }
+ }
+ }
+ OS.SetWindowLong (handle, OS.GWL_WNDPROC, oldProc);
+ if (count == 0) return new TreeItem [0];
+ if (count == guess.length) return guess;
+ TreeItem [] result = new TreeItem [count];
+ if (count < guess.length) {
+ System.arraycopy (guess, 0, result, 0, count);
+ return result;
+ }
+ OS.SetWindowLong (handle, OS.GWL_WNDPROC, TreeProc);
+ 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;
+}
+
+/**
+ * Returns the item which is currently at the top of the receiver.
+ * This item can change when items are expanded, collapsed, scrolled
+ * or new items are added or removed.
+ *
+ * @return the item at the top of the receiver
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @since 2.1
+ */
+public TreeItem getTopItem () {
+ checkWidget ();
+ int hItem = OS.SendMessage (handle, OS.TVM_GETNEXTITEM, OS.TVGN_FIRSTVISIBLE, 0);
+ if (hItem == 0) return null;
+ TVITEM tvItem = new TVITEM ();
+ tvItem.mask = OS.TVIF_PARAM;
+ tvItem.hItem = hItem;
+ if (OS.SendMessage (handle, OS.TVM_GETITEM, 0, tvItem) == 0) return null;
+ return items [tvItem.lParam];
+}
+
+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);
+ Rectangle bounds = image.getBounds ();
+ imageList = getDisplay ().getImageList (new Point (bounds.width, bounds.height));
+ int index = imageList.indexOf (image);
+ if (index == -1) index = imageList.add (image);
+ int hImageList = imageList.getHandle ();
+ OS.SendMessage (handle, OS.TVM_SETIMAGELIST, OS.TVSIL_NORMAL, hImageList);
+ return index;
+ }
+ int index = imageList.indexOf (image);
+ if (index != -1) return index;
+ return imageList.add (image);
+}
+
+boolean releaseItem (TreeItem item, TVITEM tvItem) {
+ int hItem = item.handle;
+ if (hItem == hAnchor) hAnchor = 0;
+ if (item.isDisposed ()) return false;
+ tvItem.hItem = hItem;
+ OS.SendMessage (handle, OS.TVM_GETITEM, 0, tvItem);
+ items [tvItem.lParam] = null;
+ return true;
+}
+
+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);
+ }
+ if (releaseItem (item, tvItem)) {
+ item.releaseResources ();
+ }
+ }
+}
+
+void releaseWidget () {
+ for (int i=0; i<items.length; i++) {
+ TreeItem item = items [i];
+ if (item != null && !item.isDisposed ()) {
+ item.releaseResources ();
+ }
+ }
+ /*
+ * Feature in Windows. For some reason, when
+ * TVM_GETIMAGELIST or TVM_SETIMAGELIST is sent,
+ * the tree issues NM_CUSTOMDRAW messages. This
+ * behavior is unwanted when the tree is being
+ * disposed. The fix is to ingore NM_CUSTOMDRAW
+ * messages by usnig the custom draw flag.
+ *
+ * NOTE: This only happens on Windows XP.
+ */
+ customDraw = false;
+ items = null;
+ if (imageList != null) {
+ OS.SendMessage (handle, OS.TVM_SETIMAGELIST, OS.TVSIL_NORMAL, 0);
+ Display display = getDisplay ();
+ display.releaseImageList (imageList);
+ } 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);
+ super.releaseWidget ();
+}
+
+
+/**
+ * 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;
+ if (drawCount == 0) {
+ OS.DefWindowProc (handle, OS.WM_SETREDRAW, 0, 0);
+ /*
+ * This code is intentionally commented.
+ */
+// OS.SendMessage (handle, OS.WM_SETREDRAW, 0, 0);
+ }
+ int result = OS.SendMessage (handle, OS.TVM_DELETEITEM, 0, OS.TVI_ROOT);
+ if (drawCount == 0) {
+ OS.DefWindowProc (handle, OS.WM_SETREDRAW, 1, 0);
+ /*
+ * This code is intentionally commented.
+ */
+// OS.SendMessage (handle, OS.WM_SETREDRAW, 1, 0);
+ OS.InvalidateRect (handle, null, true);
+ }
+ 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.releaseResources ();
+ }
+ }
+ if (imageList != null) {
+ OS.SendMessage (handle, OS.TVM_SETIMAGELIST, 0, 0);
+ Display display = getDisplay ();
+ display.releaseImageList (imageList);
+ }
+ imageList = null;
+ customDraw = false;
+ 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 IllegalArgumentException <ul>
+ * <li>ERROR_INVALID_ARGUMENT - if the item has been disposed</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setInsertMark (TreeItem item, boolean before) {
+ checkWidget ();
+ int hItem = 0;
+ if (item != null) {
+ if (item.isDisposed()) error(SWT.ERROR_INVALID_ARGUMENT);
+ 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;
+ }
+ }
+ 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 ((style & SWT.CHECK) != 0) setCheckboxImageList ();
+}
+
+void setBounds (int x, int y, int width, int height, int flags) {
+ /*
+ * Ensure that the selection is visible when the tree is resized
+ * from a zero size to a size that can show the selection.
+ */
+ boolean fixSelection = false;
+ if ((flags & OS.SWP_NOSIZE) == 0 && (width != 0 || height != 0)) {
+ if (OS.SendMessage (handle, OS.TVM_GETVISIBLECOUNT, 0, 0) == 0) {
+ fixSelection = true;
+ }
+ }
+ super.setBounds (x, y, width, height, flags);
+ if (fixSelection) {
+ int hItem = OS.SendMessage (handle, OS.TVM_GETNEXTITEM, OS.TVGN_CARET, 0);
+ if (hItem != 0) showItem (hItem);
+ }
+}
+
+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);
+}
+
+public void setRedraw (boolean redraw) {
+ checkWidget ();
+ /*
+ * Bug in Windows. For some reason, when WM_SETREDRAW
+ * is used to turn redraw on for a tree and the tree
+ * contains no items, the last item in the tree does
+ * not redraw properly. If the tree has only one item,
+ * that item is not drawn. If another window is dragged
+ * on top of the item, parts of the item are redrawn
+ * and erased at random. The fix is to ensure that this
+ * case doesn't happen by inserting and deleting an item
+ * when redraw is turned on and there are no items in
+ * the tree.
+ */
+ int hItem = 0;
+ if (redraw) {
+ int count = OS.SendMessage (handle, OS.TVM_GETCOUNT, 0, 0);
+ if (count == 0) {
+ TVINSERTSTRUCT tvInsert = new TVINSERTSTRUCT ();
+ tvInsert.hInsertAfter = OS.TVI_FIRST;
+ hItem = OS.SendMessage (handle, OS.TVM_INSERTITEM, 0, tvInsert);
+ }
+ }
+ super.setRedraw (redraw);
+ if (hItem != 0) {
+ OS.SendMessage (handle, OS.TVM_DELETEITEM, 0, hItem);
+ }
+}
+
+/**
+ * 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 array of items is null</li>
+ * <li>ERROR_INVALID_ARGUMENT - if one of the item has been disposed</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see Tree#deselectAll()
+ */
+public void setSelection (TreeItem [] items) {
+ checkWidget ();
+ if (items == null) error (SWT.ERROR_NULL_ARGUMENT);
+
+ /* Select/deselect the first item */
+ int hOldItem = OS.SendMessage (handle, OS.TVM_GETNEXTITEM, OS.TVGN_CARET, 0);
+ if (items.length == 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) {
+ if (item.isDisposed ()) error (SWT.ERROR_INVALID_ARGUMENT);
+ hAnchor = hNewItem = item.handle;
+ }
+ ignoreSelect = true;
+ OS.SendMessage (handle, OS.TVM_SELECTITEM, OS.TVGN_CARET, hNewItem);
+ ignoreSelect = false;
+ /*
+ * Feature in Windows. When the old and new focused item
+ * are the same, Windows does not check to make sure that
+ * the item is actually selected, not just focused. The
+ * fix is to force the item to draw selected by setting
+ * the state mask.
+ */
+ if (hOldItem == hNewItem) {
+ TVITEM tvItem = new TVITEM ();
+ tvItem.mask = OS.TVIF_STATE;
+ tvItem.state = OS.TVIS_SELECTED;
+ tvItem.stateMask = OS.TVIS_SELECTED;
+ tvItem.hItem = hNewItem;
+ OS.SendMessage (handle, OS.TVM_SETITEM, 0, tvItem);
+ }
+ showItem (hNewItem);
+ }
+ 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);
+}
+
+/**
+ * Sets the item which is currently at the top of the receiver.
+ * This item can change when items are expanded, collapsed, scrolled
+ * or new items are added or removed.
+ *
+ * @param item the item to be shown
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if the item is null</li>
+ * <li>ERROR_INVALID_ARGUMENT - if the item has been disposed</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see Tree#getTopItem()
+ *
+ * @since 2.1
+ */
+public void setTopItem (TreeItem item) {
+ checkWidget ();
+ if (item == null) SWT.error (SWT.ERROR_NULL_ARGUMENT);
+ if (item.isDisposed ()) SWT.error (SWT.ERROR_INVALID_ARGUMENT);
+ OS.SendMessage (handle, OS.TVM_SELECTITEM, OS.TVGN_FIRSTVISIBLE, item.handle);
+}
+
+void showItem (int hItem) {
+ /*
+ * Bug in Windows. When TVM_ENSUREVISIBLE is used to ensure
+ * that an item is visible and the client area of the tree is
+ * smaller that the size of one item, TVM_ENSUREVISIBLE makes
+ * the next item in the tree visible by making it the top item
+ * instead of making the desired item visible. The fix is to
+ * detect the case when the client area is too small and make
+ * the desired visible item be the top item in the tree.
+ */
+ if (OS.SendMessage (handle, OS.TVM_GETVISIBLECOUNT, 0, 0) == 0) {
+ OS.SendMessage (handle, OS.TVM_SELECTITEM, OS.TVGN_FIRSTVISIBLE, hItem);
+ OS.SendMessage (handle, OS.WM_HSCROLL, OS.SB_TOP ,0);
+ } else {
+ boolean scroll = true;
+ RECT itemRect = new RECT ();
+ itemRect.left = hItem;
+ if (OS.SendMessage (handle, OS.TVM_GETITEMRECT, 1, itemRect) != 0) {
+ RECT rect = new RECT ();
+ OS.GetClientRect (handle, rect);
+ POINT pt = new POINT ();
+ pt.x = itemRect.left;
+ pt.y = itemRect.top;
+ if (OS.PtInRect (rect, pt)) {
+ pt.y = itemRect.bottom;
+ if (OS.PtInRect (rect, pt)) scroll = false;
+ }
+ }
+ if (scroll) OS.SendMessage (handle, OS.TVM_ENSUREVISIBLE, 0, hItem);
+ }
+}
+
+/**
+ * Shows the item. If the item is already showing in the receiver,
+ * this method simply returns. Otherwise, the items are scrolled
+ * and expanded until the item is visible.
+ *
+ * @param item the item to be shown
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if the item is null</li>
+ * <li>ERROR_INVALID_ARGUMENT - if the item has been disposed</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see Tree#showSelection()
+ */
+public void showItem (TreeItem item) {
+ checkWidget ();
+ if (item == null) error (SWT.ERROR_NULL_ARGUMENT);
+ if (item.isDisposed ()) error(SWT.ERROR_INVALID_ARGUMENT);
+ showItem (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 SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if 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 = 0;
+ if ((style & SWT.SINGLE) != 0) {
+ hItem = OS.SendMessage (handle, OS.TVM_GETNEXTITEM, OS.TVGN_CARET, 0);
+ if (hItem == 0) return;
+ 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;
+ } else {
+ TVITEM tvItem = new TVITEM ();
+ tvItem.mask = OS.TVIF_STATE;
+ int oldProc = OS.GetWindowLong (handle, OS.GWL_WNDPROC);
+ OS.SetWindowLong (handle, OS.GWL_WNDPROC, TreeProc);
+ int index = 0;
+ while (index <items.length) {
+ TreeItem item = items [index];
+ if (item != null) {
+ tvItem.hItem = item.handle;
+ OS.SendMessage (handle, OS.TVM_GETITEM, 0, tvItem);
+ if ((tvItem.state & OS.TVIS_SELECTED) != 0) {
+ hItem = tvItem.hItem;
+ break;
+ }
+ }
+ index++;
+ }
+ OS.SetWindowLong (handle, OS.GWL_WNDPROC, oldProc);
+ }
+ if (hItem != 0) showItem (hItem);
+}
+
+String toolTipText (NMTTDISPINFO hdr) {
+ int hwndToolTip = OS.SendMessage (handle, OS.TVM_GETTOOLTIPS, 0, 0);
+ if (hwndToolTip == hdr.hwndFrom && toolTipText != null) return "";
+ return super.toolTipText (hdr);
+}
+
+int widgetStyle () {
+ int bits = super.widgetStyle () | 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.
+ */
+// if ((style & SWT.FULL_SELECTION) != 0) {
+// bits |= OS.TVS_FULLROWSELECT;
+// } else {
+// bits |= OS.TVS_HASLINES | OS.TVS_HASBUTTONS;
+// }
+// bits |= OS.TVS_NOTOOLTIPS;
+ return bits;
+}
+
+TCHAR 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 ESC, CR or SPACE.
+ * The fix is to avoid calling the tree window
+ * proc in these cases.
+ */
+ switch (wParam) {
+ case OS.VK_ESCAPE:
+ case OS.VK_RETURN:
+ case OS.VK_SPACE: return LRESULT.ZERO;
+ }
+ return result;
+}
+
+LRESULT WM_GETOBJECT (int wParam, int lParam) {
+ /*
+ * Ensure that there is an accessible object created for this
+ * control because support for checked item accessibility is
+ * temporarily implemented in the accessibility package.
+ */
+ if ((style & SWT.CHECK) != 0) {
+ if (accessible == null) accessible = new_Accessible (this);
+ }
+ return super.WM_GETOBJECT (wParam, lParam);
+}
+
+LRESULT WM_KEYDOWN (int wParam, int lParam) {
+ LRESULT result = super.WM_KEYDOWN (wParam, lParam);
+ if (result != null) return result;
+ switch (wParam) {
+ case OS.VK_SPACE: {
+ int hItem = OS.SendMessage (handle, OS.TVM_GETNEXTITEM, OS.TVGN_CARET, 0);
+ if (hItem != 0) {
+ hAnchor = hItem;
+ OS.SendMessage (handle, OS.TVM_ENSUREVISIBLE, 0, hItem);
+ TVITEM tvItem = new TVITEM ();
+ tvItem.mask = OS.TVIF_STATE | OS.TVIF_PARAM;
+ tvItem.hItem = hItem;
+ if ((style & SWT.CHECK) != 0) {
+ 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);
+ }
+ tvItem.stateMask = OS.TVIS_SELECTED;
+ OS.SendMessage (handle, OS.TVM_GETITEM, 0, tvItem);
+ if ((style & SWT.MULTI) != 0 && OS.GetKeyState (OS.VK_CONTROL) < 0) {
+ if ((tvItem.state & OS.TVIS_SELECTED) != 0) {
+ tvItem.state &= ~OS.TVIS_SELECTED;
+ } else {
+ tvItem.state |= OS.TVIS_SELECTED;
+ }
+ } else {
+ tvItem.state |= OS.TVIS_SELECTED;
+ }
+ OS.SendMessage (handle, OS.TVM_SETITEM, 0, tvItem);
+ Event event = new Event ();
+ event.item = items [tvItem.lParam];
+ postEvent (SWT.Selection, event);
+ if ((style & SWT.CHECK) != 0) {
+ event = new Event ();
+ event.item = items [tvItem.lParam];
+ event.detail = SWT.CHECK;
+ postEvent (SWT.Selection, event);
+ }
+ return LRESULT.ZERO;
+ }
+ break;
+ }
+ case OS.VK_UP:
+ case OS.VK_DOWN:
+ case OS.VK_PRIOR:
+ case OS.VK_NEXT:
+ case OS.VK_HOME:
+ case OS.VK_END: {
+ if ((style & SWT.SINGLE) != 0) break;
+ if (OS.GetKeyState (OS.VK_SHIFT) < 0) {
+ int hItem = OS.SendMessage (handle, OS.TVM_GETNEXTITEM, OS.TVGN_CARET, 0);
+ if (hItem != 0) {
+ if (hAnchor == 0) hAnchor = hItem;
+ ignoreSelect = ignoreDeselect = true;
+ int code = callWindowProc (OS.WM_KEYDOWN, wParam, lParam);
+ ignoreSelect = ignoreDeselect = false;
+ int hNewItem = OS.SendMessage (handle, OS.TVM_GETNEXTITEM, OS.TVGN_CARET, 0);
+ TVITEM tvItem = new TVITEM ();
+ tvItem.mask = OS.TVIF_STATE;
+ tvItem.stateMask = OS.TVIS_SELECTED;
+ int hDeselectItem = hItem;
+ RECT rect1 = new RECT ();
+ rect1.left = hAnchor;
+ OS.SendMessage (handle, OS.TVM_GETITEMRECT, 1, rect1);
+ RECT rect2 = rect2 = new RECT ();
+ rect2.left = hDeselectItem;
+ OS.SendMessage (handle, OS.TVM_GETITEMRECT, 1, rect2);
+ int flags = rect1.top < rect2.top ? OS.TVGN_PREVIOUSVISIBLE : OS.TVGN_NEXTVISIBLE;
+ while (hDeselectItem != hAnchor) {
+ tvItem.hItem = hDeselectItem;
+ OS.SendMessage (handle, OS.TVM_SETITEM, 0, tvItem);
+ hDeselectItem = OS.SendMessage (handle, OS.TVM_GETNEXTITEM, flags, hDeselectItem);
+ }
+ int hSelectItem = hAnchor;
+ rect1.left = hNewItem;
+ OS.SendMessage (handle, OS.TVM_GETITEMRECT, 1, rect1);
+ rect2.left = hSelectItem;
+ OS.SendMessage (handle, OS.TVM_GETITEMRECT, 1, rect2);
+ tvItem.state = OS.TVIS_SELECTED;
+ flags = rect1.top < rect2.top ? OS.TVGN_PREVIOUSVISIBLE : OS.TVGN_NEXTVISIBLE;
+ while (hSelectItem != hNewItem) {
+ tvItem.hItem = hSelectItem;
+ OS.SendMessage (handle, OS.TVM_SETITEM, 0, tvItem);
+ hSelectItem = OS.SendMessage (handle, OS.TVM_GETNEXTITEM, flags, hSelectItem);
+ }
+ tvItem.hItem = hNewItem;
+ OS.SendMessage (handle, OS.TVM_SETITEM, 0, tvItem);
+ tvItem.mask = OS.TVIF_PARAM;
+ tvItem.hItem = hNewItem;
+ OS.SendMessage (handle, OS.TVM_GETITEM, 0, tvItem);
+ Event event = new Event ();
+ event.item = items [tvItem.lParam];
+ postEvent (SWT.Selection, event);
+ return new LRESULT (code);
+ }
+ }
+ if (OS.GetKeyState (OS.VK_CONTROL) < 0) {
+ int hItem = OS.SendMessage (handle, OS.TVM_GETNEXTITEM, OS.TVGN_CARET, 0);
+ if (hItem != 0) {
+ TVITEM tvItem = new TVITEM ();
+ tvItem.mask = OS.TVIF_STATE;
+ tvItem.stateMask = OS.TVIS_SELECTED;
+ tvItem.hItem = hItem;
+ OS.SendMessage (handle, OS.TVM_GETITEM, 0, tvItem);
+ boolean oldSelected = (tvItem.state & OS.TVIS_SELECTED) != 0;
+ int hNewItem = 0;
+ switch (wParam) {
+ case OS.VK_UP:
+ hNewItem = OS.SendMessage (handle, OS.TVM_GETNEXTITEM, OS.TVGN_PREVIOUSVISIBLE, hItem);
+ break;
+ case OS.VK_DOWN:
+ hNewItem = OS.SendMessage (handle, OS.TVM_GETNEXTITEM, OS.TVGN_NEXTVISIBLE, hItem);
+ break;
+ case OS.VK_HOME:
+ hNewItem = OS.SendMessage (handle, OS.TVM_GETNEXTITEM, OS.TVGN_ROOT, 0);
+ break;
+ case OS.VK_PRIOR:
+ hNewItem = OS.SendMessage (handle, OS.TVM_GETNEXTITEM, OS.TVGN_FIRSTVISIBLE, 0);
+ if (hNewItem == hItem) {
+ OS.SendMessage (handle, OS.WM_VSCROLL, OS.SB_PAGEUP, 0);
+ hNewItem = OS.SendMessage (handle, OS.TVM_GETNEXTITEM, OS.TVGN_FIRSTVISIBLE, 0);
+ }
+ break;
+ case OS.VK_NEXT:
+ RECT rect = new RECT (), clientRect = new RECT ();
+ OS.GetClientRect (handle, clientRect);
+ hNewItem = OS.SendMessage (handle, OS.TVM_GETNEXTITEM, OS.TVGN_FIRSTVISIBLE, 0);
+ do {
+ int hVisible = OS.SendMessage (handle, OS.TVM_GETNEXTITEM, OS.TVGN_NEXTVISIBLE, hNewItem);
+ if (hVisible == 0) break;
+ rect.left = hVisible;
+ OS.SendMessage (handle, OS.TVM_GETITEMRECT, 1, rect);
+ if (rect.bottom > clientRect.bottom) break;
+ if ((hNewItem = hVisible) == hItem) {
+ OS.SendMessage (handle, OS.WM_VSCROLL, OS.SB_PAGEDOWN, 0);
+ }
+ } while (hNewItem != 0);
+ break;
+ case OS.VK_END:
+ hNewItem = OS.SendMessage (handle, OS.TVM_GETNEXTITEM, OS.TVGN_LASTVISIBLE, 0);
+ break;
+ }
+ if (hNewItem != 0) {
+ OS.SendMessage (handle, OS.TVM_ENSUREVISIBLE, 0, hNewItem);
+ tvItem.hItem = hNewItem;
+ OS.SendMessage (handle, OS.TVM_GETITEM, 0, tvItem);
+ boolean newSelected = (tvItem.state & OS.TVIS_SELECTED) != 0;
+ if (!newSelected && 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);
+ }
+ ignoreSelect = true;
+ OS.SendMessage (handle, OS.TVM_SELECTITEM, OS.TVGN_CARET, hNewItem);
+ ignoreSelect = false;
+ if (oldSelected) {
+ tvItem.state = OS.TVIS_SELECTED;
+ tvItem.hItem = hItem;
+ OS.SendMessage (handle, OS.TVM_SETITEM, 0, tvItem);
+ }
+ if (!newSelected) {
+ tvItem.state = 0;
+ tvItem.hItem = hNewItem;
+ OS.SendMessage (handle, OS.TVM_SETITEM, 0, tvItem);
+ }
+ if (!newSelected && drawCount == 0) {
+ RECT rect1 = new RECT (), rect2 = new RECT ();
+ rect1.left = hItem; 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);
+ if (OS.IsWinCE) {
+ OS.InvalidateRect (handle, rect1, false);
+ OS.InvalidateRect (handle, rect2, false);
+ OS.UpdateWindow (handle);
+ } else {
+ int flags = OS.RDW_UPDATENOW | OS.RDW_INVALIDATE;
+ OS.RedrawWindow (handle, rect1, 0, flags);
+ OS.RedrawWindow (handle, rect2, 0, flags);
+ }
+ }
+ return LRESULT.ZERO;
+ }
+ }
+ }
+ int code = callWindowProc (OS.WM_KEYDOWN, wParam, lParam);
+ hAnchor = OS.SendMessage (handle, OS.TVM_GETNEXTITEM, OS.TVGN_CARET, 0);
+ return new LRESULT (code);
+ }
+ }
+ return result;
+}
+
+LRESULT WM_KILLFOCUS (int wParam, int lParam) {
+ LRESULT result = super.WM_KILLFOCUS (wParam, lParam);
+ 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. The first part of this work
+ * around is to ensure that the user has selected
+ * an item.
+ */
+ 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);
+
+ /*
+ * Feature in Windows. When the old and new focused item
+ * are the same, Windows does not check to make sure that
+ * the item is actually selected, not just focused. The
+ * fix is to force the item to draw selected by setting
+ * the state mask. This is only necessary when the tree
+ * is single select.
+ */
+ if ((style & SWT.SINGLE) != 0) {
+ if (hOldItem == hNewItem) {
+ tvItem.mask = OS.TVIF_STATE;
+ tvItem.state = OS.TVIS_SELECTED;
+ tvItem.stateMask = OS.TVIS_SELECTED;
+ tvItem.hItem = hNewItem;
+ OS.SendMessage (handle, OS.TVM_SETITEM, 0, tvItem);
+ }
+ }
+
+ /* 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);
+ if (OS.IsWinCE) {
+ OS.InvalidateRect (handle, rect1, false);
+ OS.InvalidateRect (handle, rect2, false);
+ OS.UpdateWindow (handle);
+ } else {
+ 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_PARAM;
+ OS.SendMessage (handle, OS.TVM_GETITEM, 0, tvItem);
+ Event event = new Event ();
+ 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) {
+ postEvent (SWT.DragDetect);
+ } 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.mask = OS.TVIF_STATE;
+ tvItem.stateMask = OS.TVIS_SELECTED;
+ tvItem.hItem = lpht.hItem;
+ OS.SendMessage (handle, OS.TVM_GETITEM, 0, tvItem);
+ if ((tvItem.state & OS.TVIS_SELECTED) == 0) {
+ ignoreSelect = true;
+ OS.SendMessage (handle, OS.TVM_SELECTITEM, OS.TVGN_CARET, 0);
+ ignoreSelect = false;
+ 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 ((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 ((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_CUSTOMDRAW: {
+ if (!customDraw) break;
+ NMTVCUSTOMDRAW nmcd = new NMTVCUSTOMDRAW ();
+ OS.MoveMemory (nmcd, lParam, NMTVCUSTOMDRAW.sizeof);
+ switch (nmcd.dwDrawStage) {
+ case OS.CDDS_PREPAINT: return new LRESULT (OS.CDRF_NOTIFYITEMDRAW);
+ case OS.CDDS_ITEMPREPAINT:
+ TreeItem item = items [nmcd.lItemlParam];
+ /*
+ * Feature on Windows. When a new tree item is inserted
+ * using TVM_INSERTITEM and the tree is using custom draw,
+ * a NM_CUSTOMDRAW is sent before TVM_INSERTITEM returns
+ * and before the item is added to the items array. The
+ * fix is to check for null.
+ *
+ * NOTE: This only happens on XP with the version 6.00 of
+ * COMCTL32.DLL,
+ */
+ if (item == null) break;
+ TVITEM tvItem = new TVITEM ();
+ tvItem.mask = OS.TVIF_STATE;
+ tvItem.hItem = item.handle;
+ OS.SendMessage (handle, OS.TVM_GETITEM, 0, tvItem);
+ if ((tvItem.state & OS.TVIS_SELECTED) != 0) break;
+ int clrText = item.foreground, clrTextBk = item.background;
+ if (clrText == -1 && clrTextBk == -1) break;
+ nmcd.clrText = clrText == -1 ? getForegroundPixel () : clrText;
+ nmcd.clrTextBk = clrTextBk == -1 ? getBackgroundPixel () : clrTextBk;
+ OS.MoveMemory (lParam, nmcd, NMTVCUSTOMDRAW.sizeof);
+ return new LRESULT (OS.CDRF_NEWFONT);
+ }
+ break;
+ }
+ 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_SELCHANGEDA:
+ case OS.TVN_SELCHANGEDW:
+ 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);
+ hAnchor = tvItem.hItem;
+ } 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.SendMessage (handle, OS.TVM_GETITEM, 0, tvItem);
+ }
+ }
+ Event event = new Event ();
+ if (tvItem != null) {
+ event.item = items [tvItem.lParam];
+ }
+ 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_SELCHANGINGA:
+ case OS.TVN_SELCHANGINGW:
+ if (!ignoreSelect && !ignoreDeselect) {
+ hAnchor = 0;
+ if ((style & SWT.MULTI) != 0) deselectAll ();
+ }
+ break;
+ case OS.TVN_ITEMEXPANDINGA:
+ case OS.TVN_ITEMEXPANDINGW:
+ 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_BEGINDRAGA:
+ case OS.TVN_BEGINDRAGW:
+ case OS.TVN_BEGINRDRAGA:
+ case OS.TVN_BEGINRDRAGW:
+ 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);
+}
+
+}
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
index 2178d69ed8..cdcd8df0d0 100755
--- 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
@@ -1,684 +1,684 @@
-package org.eclipse.swt.widgets;
-
-/*
+package org.eclipse.swt.widgets;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-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 hierarchy of tree items in a tree widget.
- *
- * <dl>
- * <dt><b>Styles:</b></dt>
- * <dd>(none)</dd>
- * <dt><b>Events:</b></dt>
- * <dd>(none)</dd>
- * </dl>
- * <p>
- * IMPORTANT: This class is <em>not</em> intended to be subclassed.
- * </p>
- */
-
-public class TreeItem extends Item {
- /**
- * the handle to the OS resource
- * (Warning: This field is platform dependent)
- */
- public int handle;
-
- Tree parent;
- int background, foreground;
-
-/**
- * Constructs a new instance of this class given its parent
- * (which must be a <code>Tree</code> or a <code>TreeItem</code>)
- * and a style value describing its behavior and appearance.
- * The item is added to the end of the items maintained by its parent.
- * <p>
- * The style value is either one of the style constants defined in
- * class <code>SWT</code> which is applicable to instances of this
- * class, or must be built by <em>bitwise OR</em>'ing together
- * (that is, using the <code>int</code> "|" operator) two or more
- * of those <code>SWT</code> style constants. The class description
- * lists the style constants that are applicable to the class.
- * Style bits are also inherited from superclasses.
- * </p>
- *
- * @param parent a 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 TreeItem (Tree parent, int style) {
- super (parent, style);
- this.parent = parent;
- parent.createItem (this, 0, OS.TVI_LAST);
-}
-
-/**
- * Constructs a new instance of this class given its parent
- * (which must be a <code>Tree</code> or a <code>TreeItem</code>),
- * a style value describing its behavior and appearance, and the index
- * at which to place it in the items maintained by its parent.
- * <p>
- * The style value is either one of the style constants defined in
- * class <code>SWT</code> which is applicable to instances of this
- * class, or must be built by <em>bitwise OR</em>'ing together
- * (that is, using the <code>int</code> "|" operator) two or more
- * of those <code>SWT</code> style constants. The class description
- * lists the style constants that are applicable to the class.
- * Style bits are also inherited from superclasses.
- * </p>
- *
- * @param parent a 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 TreeItem (Tree parent, int style, int index) {
- super (parent, style);
- if (index < 0) error (SWT.ERROR_INVALID_RANGE);
- this.parent = parent;
- int hItem = OS.TVI_FIRST;
- if (index != 0) {
- int count = 1, hwnd = parent.handle;
- hItem = OS.SendMessage (hwnd, OS.TVM_GETNEXTITEM, OS.TVGN_ROOT, 0);
- while (hItem != 0 && count < index) {
- 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);
-}
-
-/**
- * Constructs a new instance of this class given its parent
- * (which must be a <code>Tree</code> or a <code>TreeItem</code>)
- * and a style value describing its behavior and appearance.
- * The item is added to the end of the items maintained by its parent.
- * <p>
- * The style value is either one of the style constants defined in
- * class <code>SWT</code> which is applicable to instances of this
- * class, or must be built by <em>bitwise OR</em>'ing together
- * (that is, using the <code>int</code> "|" operator) two or more
- * of those <code>SWT</code> style constants. The class description
- * lists the style constants that are applicable to the class.
- * Style bits are also inherited from superclasses.
- * </p>
- *
- * @param parentItem a 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 TreeItem (TreeItem parentItem, int style) {
- super (checkNull (parentItem).parent, style);
- parent = parentItem.parent;
- int hItem = parentItem.handle;
- parent.createItem (this, hItem, OS.TVI_LAST);
-}
-
-/**
- * Constructs a new instance of this class given its parent
- * (which must be a <code>Tree</code> or a <code>TreeItem</code>),
- * a style value describing its behavior and appearance, and the index
- * at which to place it in the items maintained by its parent.
- * <p>
- * The style value is either one of the style constants defined in
- * class <code>SWT</code> which is applicable to instances of this
- * class, or must be built by <em>bitwise OR</em>'ing together
- * (that is, using the <code>int</code> "|" operator) two or more
- * of those <code>SWT</code> style constants. The class description
- * lists the style constants that are applicable to the class.
- * Style bits are also inherited from superclasses.
- * </p>
- *
- * @param parentItem a 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 TreeItem (TreeItem parentItem, int style, int index) {
- super (checkNull (parentItem).parent, style);
- if (index < 0) error (SWT.ERROR_INVALID_RANGE);
- parent = parentItem.parent;
- int hItem = OS.TVI_FIRST;
- int hParent = parentItem.handle;
- if (index != 0) {
- int count = 1, hwnd = parent.handle;
- hItem = OS.SendMessage (hwnd, OS.TVM_GETNEXTITEM, OS.TVGN_CHILD, hParent);
- while (hItem != 0 && count < index) {
- 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);
-}
-
-/**
- * Returns the receiver's background color.
- *
- * @return the background color
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @since 2.0
- *
- */
-public Color getBackground () {
- checkWidget ();
- int pixel = (background == -1) ? parent.getBackgroundPixel() : background;
- return Color.win32_new (getDisplay (), pixel);
-}
-
-/**
- * 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;
- if (OS.SendMessage (hwnd, OS.TVM_GETITEMRECT, 1, rect) == 0) {
- return new Rectangle (0, 0, 0, 0);
- }
- 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 the foreground color that the receiver will use to draw.
- *
- * @return the receiver's foreground color
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @since 2.0
- *
- */
-public Color getForeground () {
- checkWidget ();
- int pixel = (foreground == -1) ? parent.getForegroundPixel() : foreground;
- return Color.win32_new (getDisplay (), pixel);
-}
-
-/**
- * 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 affect the receiver.
- * </p>
- *
- * @return the receiver's items
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public TreeItem [] getItems () {
- checkWidget ();
- 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 redraw () {
- if (parent.drawCount > 0) return;
- int hwnd = parent.handle;
- if (!OS.IsWindowVisible (hwnd)) return;
- RECT rect = new RECT ();
- rect.left = handle;
- if (OS.SendMessage (hwnd, OS.TVM_GETITEMRECT, 1, rect) != 0) {
- OS.InvalidateRect (hwnd, rect, true);
- }
-}
-
-void releaseChild () {
- super.releaseChild ();
- parent.destroyItem (this);
-}
-
-void releaseHandle () {
- super.releaseHandle ();
- handle = 0;
-}
-
-void releaseWidget () {
- super.releaseWidget ();
- parent = null;
-}
-
-/**
- * Sets the receiver's background color to the color specified
- * by the argument, or to the default system color for the item
- * if the argument is null.
- *
- * @param color the new color (or null)
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_INVALID_ARGUMENT - if the argument has been disposed</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @since 2.0
- *
- */
-public void setBackground (Color color) {
- checkWidget ();
- if (color != null && color.isDisposed ()) {
- SWT.error (SWT.ERROR_INVALID_ARGUMENT);
- }
- int pixel = -1;
- if (color != null) {
- parent.customDraw = true;
- pixel = color.handle;
- }
- background = pixel;
- redraw ();
-}
-
-/**
- * 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.hAnchor = hNewItem;
- }
- parent.sendEvent (SWT.Selection, event);
- }
-}
-
-/**
- * Sets the receiver's foreground color to the color specified
- * by the argument, or to the default system color for the item
- * if the argument is null.
- *
- * @param color the new color (or null)
- *
- * @since 2.0
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_INVALID_ARGUMENT - if the argument has been disposed</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @since 2.0
- *
- */
-public void setForeground (Color color) {
- checkWidget ();
- if (color != null && color.isDisposed ()) {
- SWT.error (SWT.ERROR_INVALID_ARGUMENT);
- }
- int pixel = -1;
- if (color != null) {
- parent.customDraw = true;
- pixel = color.handle;
- }
- foreground = pixel;
- redraw ();
-}
-
-/**
- * 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;
- 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 ();
- TCHAR buffer = new TCHAR (parent.getCodePage (), string, true);
- int byteCount = buffer.length () * TCHAR.sizeof;
- int pszText = OS.HeapAlloc (hHeap, OS.HEAP_ZERO_MEMORY, byteCount);
- OS.MoveMemory (pszText, buffer, byteCount);
- TVITEM tvItem = new TVITEM ();
- tvItem.mask = OS.TVIF_HANDLE | OS.TVIF_TEXT;
- tvItem.hItem = handle;
- tvItem.pszText = pszText;
- OS.SendMessage (hwnd, OS.TVM_SETITEM, 0, tvItem);
- OS.HeapFree (hHeap, 0, pszText);
-}
-
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+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 hierarchy of tree items in a tree widget.
+ *
+ * <dl>
+ * <dt><b>Styles:</b></dt>
+ * <dd>(none)</dd>
+ * <dt><b>Events:</b></dt>
+ * <dd>(none)</dd>
+ * </dl>
+ * <p>
+ * IMPORTANT: This class is <em>not</em> intended to be subclassed.
+ * </p>
+ */
+
+public class TreeItem extends Item {
+ /**
+ * the handle to the OS resource
+ * (Warning: This field is platform dependent)
+ */
+ public int handle;
+
+ Tree parent;
+ int background, foreground;
+
+/**
+ * Constructs a new instance of this class given its parent
+ * (which must be a <code>Tree</code> or a <code>TreeItem</code>)
+ * and a style value describing its behavior and appearance.
+ * The item is added to the end of the items maintained by its parent.
+ * <p>
+ * The style value is either one of the style constants defined in
+ * class <code>SWT</code> which is applicable to instances of this
+ * class, or must be built by <em>bitwise OR</em>'ing together
+ * (that is, using the <code>int</code> "|" operator) two or more
+ * of those <code>SWT</code> style constants. The class description
+ * lists the style constants that are applicable to the class.
+ * Style bits are also inherited from superclasses.
+ * </p>
+ *
+ * @param parent a 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 TreeItem (Tree parent, int style) {
+ super (parent, style);
+ this.parent = parent;
+ parent.createItem (this, 0, OS.TVI_LAST);
+}
+
+/**
+ * Constructs a new instance of this class given its parent
+ * (which must be a <code>Tree</code> or a <code>TreeItem</code>),
+ * a style value describing its behavior and appearance, and the index
+ * at which to place it in the items maintained by its parent.
+ * <p>
+ * The style value is either one of the style constants defined in
+ * class <code>SWT</code> which is applicable to instances of this
+ * class, or must be built by <em>bitwise OR</em>'ing together
+ * (that is, using the <code>int</code> "|" operator) two or more
+ * of those <code>SWT</code> style constants. The class description
+ * lists the style constants that are applicable to the class.
+ * Style bits are also inherited from superclasses.
+ * </p>
+ *
+ * @param parent a 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 TreeItem (Tree parent, int style, int index) {
+ super (parent, style);
+ if (index < 0) error (SWT.ERROR_INVALID_RANGE);
+ this.parent = parent;
+ int hItem = OS.TVI_FIRST;
+ if (index != 0) {
+ int count = 1, hwnd = parent.handle;
+ hItem = OS.SendMessage (hwnd, OS.TVM_GETNEXTITEM, OS.TVGN_ROOT, 0);
+ while (hItem != 0 && count < index) {
+ 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);
+}
+
+/**
+ * Constructs a new instance of this class given its parent
+ * (which must be a <code>Tree</code> or a <code>TreeItem</code>)
+ * and a style value describing its behavior and appearance.
+ * The item is added to the end of the items maintained by its parent.
+ * <p>
+ * The style value is either one of the style constants defined in
+ * class <code>SWT</code> which is applicable to instances of this
+ * class, or must be built by <em>bitwise OR</em>'ing together
+ * (that is, using the <code>int</code> "|" operator) two or more
+ * of those <code>SWT</code> style constants. The class description
+ * lists the style constants that are applicable to the class.
+ * Style bits are also inherited from superclasses.
+ * </p>
+ *
+ * @param parentItem a 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 TreeItem (TreeItem parentItem, int style) {
+ super (checkNull (parentItem).parent, style);
+ parent = parentItem.parent;
+ int hItem = parentItem.handle;
+ parent.createItem (this, hItem, OS.TVI_LAST);
+}
+
+/**
+ * Constructs a new instance of this class given its parent
+ * (which must be a <code>Tree</code> or a <code>TreeItem</code>),
+ * a style value describing its behavior and appearance, and the index
+ * at which to place it in the items maintained by its parent.
+ * <p>
+ * The style value is either one of the style constants defined in
+ * class <code>SWT</code> which is applicable to instances of this
+ * class, or must be built by <em>bitwise OR</em>'ing together
+ * (that is, using the <code>int</code> "|" operator) two or more
+ * of those <code>SWT</code> style constants. The class description
+ * lists the style constants that are applicable to the class.
+ * Style bits are also inherited from superclasses.
+ * </p>
+ *
+ * @param parentItem a 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 TreeItem (TreeItem parentItem, int style, int index) {
+ super (checkNull (parentItem).parent, style);
+ if (index < 0) error (SWT.ERROR_INVALID_RANGE);
+ parent = parentItem.parent;
+ int hItem = OS.TVI_FIRST;
+ int hParent = parentItem.handle;
+ if (index != 0) {
+ int count = 1, hwnd = parent.handle;
+ hItem = OS.SendMessage (hwnd, OS.TVM_GETNEXTITEM, OS.TVGN_CHILD, hParent);
+ while (hItem != 0 && count < index) {
+ 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);
+}
+
+/**
+ * Returns the receiver's background color.
+ *
+ * @return the background color
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @since 2.0
+ *
+ */
+public Color getBackground () {
+ checkWidget ();
+ int pixel = (background == -1) ? parent.getBackgroundPixel() : background;
+ return Color.win32_new (getDisplay (), pixel);
+}
+
+/**
+ * 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;
+ if (OS.SendMessage (hwnd, OS.TVM_GETITEMRECT, 1, rect) == 0) {
+ return new Rectangle (0, 0, 0, 0);
+ }
+ 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 the foreground color that the receiver will use to draw.
+ *
+ * @return the receiver's foreground color
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @since 2.0
+ *
+ */
+public Color getForeground () {
+ checkWidget ();
+ int pixel = (foreground == -1) ? parent.getForegroundPixel() : foreground;
+ return Color.win32_new (getDisplay (), pixel);
+}
+
+/**
+ * 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 affect the receiver.
+ * </p>
+ *
+ * @return the receiver's items
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public TreeItem [] getItems () {
+ checkWidget ();
+ 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 redraw () {
+ if (parent.drawCount > 0) return;
+ int hwnd = parent.handle;
+ if (!OS.IsWindowVisible (hwnd)) return;
+ RECT rect = new RECT ();
+ rect.left = handle;
+ if (OS.SendMessage (hwnd, OS.TVM_GETITEMRECT, 1, rect) != 0) {
+ OS.InvalidateRect (hwnd, rect, true);
+ }
+}
+
+void releaseChild () {
+ super.releaseChild ();
+ parent.destroyItem (this);
+}
+
+void releaseHandle () {
+ super.releaseHandle ();
+ handle = 0;
+}
+
+void releaseWidget () {
+ super.releaseWidget ();
+ parent = null;
+}
+
+/**
+ * Sets the receiver's background color to the color specified
+ * by the argument, or to the default system color for the item
+ * if the argument is null.
+ *
+ * @param color the new color (or null)
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_INVALID_ARGUMENT - if the argument has been disposed</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @since 2.0
+ *
+ */
+public void setBackground (Color color) {
+ checkWidget ();
+ if (color != null && color.isDisposed ()) {
+ SWT.error (SWT.ERROR_INVALID_ARGUMENT);
+ }
+ int pixel = -1;
+ if (color != null) {
+ parent.customDraw = true;
+ pixel = color.handle;
+ }
+ background = pixel;
+ redraw ();
+}
+
+/**
+ * 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.hAnchor = hNewItem;
+ }
+ parent.sendEvent (SWT.Selection, event);
+ }
+}
+
+/**
+ * Sets the receiver's foreground color to the color specified
+ * by the argument, or to the default system color for the item
+ * if the argument is null.
+ *
+ * @param color the new color (or null)
+ *
+ * @since 2.0
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_INVALID_ARGUMENT - if the argument has been disposed</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @since 2.0
+ *
+ */
+public void setForeground (Color color) {
+ checkWidget ();
+ if (color != null && color.isDisposed ()) {
+ SWT.error (SWT.ERROR_INVALID_ARGUMENT);
+ }
+ int pixel = -1;
+ if (color != null) {
+ parent.customDraw = true;
+ pixel = color.handle;
+ }
+ foreground = pixel;
+ redraw ();
+}
+
+/**
+ * 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;
+ 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 ();
+ TCHAR buffer = new TCHAR (parent.getCodePage (), string, true);
+ int byteCount = buffer.length () * TCHAR.sizeof;
+ int pszText = OS.HeapAlloc (hHeap, OS.HEAP_ZERO_MEMORY, byteCount);
+ OS.MoveMemory (pszText, buffer, byteCount);
+ TVITEM tvItem = new TVITEM ();
+ tvItem.mask = OS.TVIF_HANDLE | OS.TVIF_TEXT;
+ tvItem.hItem = handle;
+ tvItem.pszText = pszText;
+ 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
index d4cc41bae2..109a3b552c 100755
--- 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
@@ -1,1057 +1,1057 @@
-package org.eclipse.swt.widgets;
-
-/*
+package org.eclipse.swt.widgets;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-import org.eclipse.swt.internal.*;
-import org.eclipse.swt.internal.win32.*;
-import org.eclipse.swt.*;
-import org.eclipse.swt.events.*;
-
-/**
- * This class is the abstract superclass of all user interface objects.
- * Widgets are created, disposed and issue notification to listeners
- * when events occur which affect them.
- * <dl>
- * <dt><b>Styles:</b></dt>
- * <dd>(none)</dd>
- * <dt><b>Events:</b></dt>
- * <dd>Dispose</dd>
- * </dl>
- * <p>
- * IMPORTANT: This class is intended to be subclassed <em>only</em>
- * within the SWT implementation. However, it has not been marked
- * final to allow those outside of the SWT development team to implement
- * patched versions of the class in order to get around specific
- * limitations in advance of when those limitations can be addressed
- * by the team. Any class built using subclassing to access the internals
- * of this class will likely fail to compile or run between releases and
- * may be strongly platform specific. Subclassing should not be attempted
- * without an intimate and detailed understanding of the workings of the
- * hierarchy. No support is provided for user-written classes which are
- * implemented as subclasses of this class.
- * </p>
- *
- * @see #checkSubclass
- */
-
-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 GRAB = 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 = '&';
-
- /* COMCTL32.DLL flags */
- static final int MAJOR = 4, MINOR = 71;
- static final int COMCTL32_MAJOR, COMCTL32_MINOR;
- static {
-
- /* Get the COMCTL32.DLL version */
- DLLVERSIONINFO dvi = new DLLVERSIONINFO ();
- dvi.cbSize = DLLVERSIONINFO.sizeof;
- dvi.dwMajorVersion = 4;
- dvi.dwMinorVersion = 0;
- TCHAR lpLibFileName = new TCHAR (0, "comctl32.dll", true);
- int hModule = OS.LoadLibrary (lpLibFileName);
- if (hModule != 0) {
- String name = "DllGetVersion\0";
- byte [] lpProcName = new byte [name.length ()];
- for (int i=0; i<lpProcName.length; i++) {
- lpProcName [i] = (byte) name.charAt (i);
- }
- 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 (!OS.IsWinCE) {
- if ((COMCTL32_MAJOR << 16 | COMCTL32_MINOR) < (MAJOR << 16 | MINOR)) {
- System.out.println ("***WARNING: SWT requires comctl32.dll version " + MAJOR + "." + MINOR + " or greater");
- System.out.println ("***WARNING: Detected: " + COMCTL32_MAJOR + "." + COMCTL32_MINOR);
- }
- }
-
- /* 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
- * lists the style constants that are applicable to the class.
- * Style bits are also inherited from superclasses.
- * </p>
- *
- * @param parent a widget which will be the parent of the new instance (cannot be null)
- * @param style the style of widget to construct
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
- * <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
- * </ul>
- *
- * @see SWT
- * @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;
-}
-
-void checkOrientation (Widget parent) {
- style &= ~SWT.MIRRORED;
- if ((style & (SWT.LEFT_TO_RIGHT | SWT.RIGHT_TO_LEFT)) == 0) {
- if (parent != null) {
- if ((parent.style & SWT.LEFT_TO_RIGHT) != 0) style |= SWT.LEFT_TO_RIGHT;
- if ((parent.style & SWT.RIGHT_TO_LEFT) != 0) style |= SWT.RIGHT_TO_LEFT;
- }
- }
- style = checkBits (style, SWT.LEFT_TO_RIGHT, SWT.RIGHT_TO_LEFT, 0, 0, 0, 0);
-}
-
-/**
- * Throws an exception if the specified widget can not be
- * used as a parent for the receiver.
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
- * <li>ERROR_INVALID_ARGUMENT - if the parent is disposed</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
- * </ul>
- */
-void checkParent (Widget parent) {
- if (parent == null) error (SWT.ERROR_NULL_ARGUMENT);
- if (!parent.isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
- if (parent.isDisposed()) error (SWT.ERROR_INVALID_ARGUMENT);
-}
-
-/**
- * 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 (isDisposed ()) 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><p>
- * This method is called after <code>releaseWidget</code>.
- * </p>
- * @see #dispose
- * @see #releaseChild
- * @see #releaseWidget
- * @see #releaseHandle
- */
-void destroyWidget () {
- releaseHandle ();
-}
-
-/**
- * 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 (isDisposed ()) 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);
-}
-
-boolean filters (int eventType) {
- Display display = getDisplay ();
- return display.filters (eventType);
-}
-
-/**
- * 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.
- * </p>
- *
- * @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.
- * </p>
- *
- * @return <code>true</code> when the widget is disposed and <code>false</code> otherwise
- */
-public boolean isDisposed () {
- return (state & DISPOSED) != 0;
-}
-
-/**
- * Returns <code>true</code> if there are any listeners
- * for the specified event type associated with the receiver,
- * and <code>false</code> otherwise.
- *
- * @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 a single character, converted from the default
- * 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 (int ch) {
- return mbcsToWcs (ch, 0);
-}
-
-/*
- * Returns a single character, converted from the specified
- * 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
- * @param codePage the code page used to convert the character
- * @return the WCS character
- */
-char mbcsToWcs (int ch, int codePage) {
- if (OS.IsUnicode) return (char) ch;
- int key = ch & 0xFFFF;
- if (key <= 0x7F) return (char) 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 [] unicode = new char [1];
- int cp = codePage != 0 ? codePage : OS.CP_ACP;
- int count = OS.MultiByteToWideChar (cp, OS.MB_PRECOMPOSED, buffer, buffer.length, unicode, 1);
- if (count == 0) return 0;
- return unicode [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);
- sendEvent (eventType, event);
-}
-
-void postEvent (int eventType) {
- sendEvent (eventType, null, false);
-}
-
-void postEvent (int eventType, Event event) {
- sendEvent (eventType, event, false);
-}
-
-/*
- * 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 () {
- state |= DISPOSED;
-}
-
-void releaseResources () {
- releaseWidget ();
- 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);
- 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, SWTEventListener 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 #addDisposeListener
- */
-public void removeDisposeListener (DisposeListener listener) {
- checkWidget();
- if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
- if (eventTable == null) return;
- eventTable.unhook (SWT.Dispose, listener);
-}
-
-void sendEvent (Event event) {
- Display display = event.display;
- if (!display.filterEvent (event)) {
- if (eventTable != null) eventTable.sendEvent (event);
- }
-}
-
-void sendEvent (int eventType) {
- sendEvent (eventType, null, true);
-}
-
-void sendEvent (int eventType, Event event) {
- sendEvent (eventType, event, true);
-}
-
-void sendEvent (int eventType, Event event, boolean send) {
- Display display = getDisplay ();
- if (eventTable == null && !display.filters (eventType)) {
- return;
- }
- if (event == null) event = new Event ();
- event.type = eventType;
- event.display = display;
- event.widget = this;
- if (event.time == 0) {
- event.time = display.getLastEventTime ();
- }
- if (send) {
- sendEvent (event);
- } else {
- display.postEvent (event);
- }
-}
-
-/**
- * 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;
-}
-
-boolean setInputState (Event event, int type) {
- if (OS.GetKeyState (OS.VK_MENU) < 0) event.stateMask |= SWT.ALT;
- if (OS.GetKeyState (OS.VK_SHIFT) < 0) event.stateMask |= SWT.SHIFT;
- if (OS.GetKeyState (OS.VK_CONTROL) < 0) 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;
- switch (type) {
- case SWT.MouseDown:
- case SWT.MouseDoubleClick:
- if (event.button == 1) event.stateMask &= ~SWT.BUTTON1;
- if (event.button == 2) event.stateMask &= ~SWT.BUTTON2;
- if (event.button == 3) event.stateMask &= ~SWT.BUTTON3;
- break;
- case SWT.MouseUp:
- if (event.button == 1) event.stateMask |= SWT.BUTTON1;
- if (event.button == 2) event.stateMask |= SWT.BUTTON2;
- if (event.button == 3) event.stateMask |= SWT.BUTTON3;
- break;
- case SWT.KeyDown:
- case SWT.Traverse:
- 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;
- break;
- case 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;
- break;
- }
- return 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) {
- if (!display.lastNull) return false;
- }
- return setInputState (event, type);
-}
-
-/**
- * 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 specified
- * multi-byte character set used by the operating system
- * widgets.
- *
- * @param ch the WCS character
- * @param codePage the code page used to convert the character
- * @return the MBCS character
- */
-int wcsToMbcs (char ch, int codePage) {
- if (OS.IsUnicode) return ch;
- if (ch <= 0x7F) return ch;
- TCHAR buffer = new TCHAR (codePage, ch, false);
- return buffer.tcharAt (0);
-}
-
-/*
- * Returns a single character, converted from the wide
- * character set (WCS) used by Java to the default
- * multi-byte character set used by the operating system
- * widgets.
- *
- * @param ch the WCS character
- * @return the MBCS character
- */
-int wcsToMbcs (char ch) {
- return wcsToMbcs (ch, 0);
-}
-
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+import org.eclipse.swt.internal.*;
+import org.eclipse.swt.internal.win32.*;
+import org.eclipse.swt.*;
+import org.eclipse.swt.events.*;
+
+/**
+ * This class is the abstract superclass of all user interface objects.
+ * Widgets are created, disposed and issue notification to listeners
+ * when events occur which affect them.
+ * <dl>
+ * <dt><b>Styles:</b></dt>
+ * <dd>(none)</dd>
+ * <dt><b>Events:</b></dt>
+ * <dd>Dispose</dd>
+ * </dl>
+ * <p>
+ * IMPORTANT: This class is intended to be subclassed <em>only</em>
+ * within the SWT implementation. However, it has not been marked
+ * final to allow those outside of the SWT development team to implement
+ * patched versions of the class in order to get around specific
+ * limitations in advance of when those limitations can be addressed
+ * by the team. Any class built using subclassing to access the internals
+ * of this class will likely fail to compile or run between releases and
+ * may be strongly platform specific. Subclassing should not be attempted
+ * without an intimate and detailed understanding of the workings of the
+ * hierarchy. No support is provided for user-written classes which are
+ * implemented as subclasses of this class.
+ * </p>
+ *
+ * @see #checkSubclass
+ */
+
+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 GRAB = 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 = '&';
+
+ /* COMCTL32.DLL flags */
+ static final int MAJOR = 4, MINOR = 71;
+ static final int COMCTL32_MAJOR, COMCTL32_MINOR;
+ static {
+
+ /* Get the COMCTL32.DLL version */
+ DLLVERSIONINFO dvi = new DLLVERSIONINFO ();
+ dvi.cbSize = DLLVERSIONINFO.sizeof;
+ dvi.dwMajorVersion = 4;
+ dvi.dwMinorVersion = 0;
+ TCHAR lpLibFileName = new TCHAR (0, "comctl32.dll", true);
+ int hModule = OS.LoadLibrary (lpLibFileName);
+ if (hModule != 0) {
+ String name = "DllGetVersion\0";
+ byte [] lpProcName = new byte [name.length ()];
+ for (int i=0; i<lpProcName.length; i++) {
+ lpProcName [i] = (byte) name.charAt (i);
+ }
+ 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 (!OS.IsWinCE) {
+ if ((COMCTL32_MAJOR << 16 | COMCTL32_MINOR) < (MAJOR << 16 | MINOR)) {
+ System.out.println ("***WARNING: SWT requires comctl32.dll version " + MAJOR + "." + MINOR + " or greater");
+ System.out.println ("***WARNING: Detected: " + COMCTL32_MAJOR + "." + COMCTL32_MINOR);
+ }
+ }
+
+ /* 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
+ * lists the style constants that are applicable to the class.
+ * Style bits are also inherited from superclasses.
+ * </p>
+ *
+ * @param parent a widget which will be the parent of the new instance (cannot be null)
+ * @param style the style of widget to construct
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
+ * <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
+ * </ul>
+ *
+ * @see SWT
+ * @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;
+}
+
+void checkOrientation (Widget parent) {
+ style &= ~SWT.MIRRORED;
+ if ((style & (SWT.LEFT_TO_RIGHT | SWT.RIGHT_TO_LEFT)) == 0) {
+ if (parent != null) {
+ if ((parent.style & SWT.LEFT_TO_RIGHT) != 0) style |= SWT.LEFT_TO_RIGHT;
+ if ((parent.style & SWT.RIGHT_TO_LEFT) != 0) style |= SWT.RIGHT_TO_LEFT;
+ }
+ }
+ style = checkBits (style, SWT.LEFT_TO_RIGHT, SWT.RIGHT_TO_LEFT, 0, 0, 0, 0);
+}
+
+/**
+ * Throws an exception if the specified widget can not be
+ * used as a parent for the receiver.
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
+ * <li>ERROR_INVALID_ARGUMENT - if the parent is disposed</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
+ * </ul>
+ */
+void checkParent (Widget parent) {
+ if (parent == null) error (SWT.ERROR_NULL_ARGUMENT);
+ if (!parent.isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (parent.isDisposed()) error (SWT.ERROR_INVALID_ARGUMENT);
+}
+
+/**
+ * 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 (isDisposed ()) 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><p>
+ * This method is called after <code>releaseWidget</code>.
+ * </p>
+ * @see #dispose
+ * @see #releaseChild
+ * @see #releaseWidget
+ * @see #releaseHandle
+ */
+void destroyWidget () {
+ releaseHandle ();
+}
+
+/**
+ * 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 (isDisposed ()) 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);
+}
+
+boolean filters (int eventType) {
+ Display display = getDisplay ();
+ return display.filters (eventType);
+}
+
+/**
+ * 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.
+ * </p>
+ *
+ * @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.
+ * </p>
+ *
+ * @return <code>true</code> when the widget is disposed and <code>false</code> otherwise
+ */
+public boolean isDisposed () {
+ return (state & DISPOSED) != 0;
+}
+
+/**
+ * Returns <code>true</code> if there are any listeners
+ * for the specified event type associated with the receiver,
+ * and <code>false</code> otherwise.
+ *
+ * @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 a single character, converted from the default
+ * 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 (int ch) {
+ return mbcsToWcs (ch, 0);
+}
+
+/*
+ * Returns a single character, converted from the specified
+ * 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
+ * @param codePage the code page used to convert the character
+ * @return the WCS character
+ */
+char mbcsToWcs (int ch, int codePage) {
+ if (OS.IsUnicode) return (char) ch;
+ int key = ch & 0xFFFF;
+ if (key <= 0x7F) return (char) 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 [] unicode = new char [1];
+ int cp = codePage != 0 ? codePage : OS.CP_ACP;
+ int count = OS.MultiByteToWideChar (cp, OS.MB_PRECOMPOSED, buffer, buffer.length, unicode, 1);
+ if (count == 0) return 0;
+ return unicode [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);
+ sendEvent (eventType, event);
+}
+
+void postEvent (int eventType) {
+ sendEvent (eventType, null, false);
+}
+
+void postEvent (int eventType, Event event) {
+ sendEvent (eventType, event, false);
+}
+
+/*
+ * 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 () {
+ state |= DISPOSED;
+}
+
+void releaseResources () {
+ releaseWidget ();
+ 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);
+ 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, SWTEventListener 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 #addDisposeListener
+ */
+public void removeDisposeListener (DisposeListener listener) {
+ checkWidget();
+ if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+ if (eventTable == null) return;
+ eventTable.unhook (SWT.Dispose, listener);
+}
+
+void sendEvent (Event event) {
+ Display display = event.display;
+ if (!display.filterEvent (event)) {
+ if (eventTable != null) eventTable.sendEvent (event);
+ }
+}
+
+void sendEvent (int eventType) {
+ sendEvent (eventType, null, true);
+}
+
+void sendEvent (int eventType, Event event) {
+ sendEvent (eventType, event, true);
+}
+
+void sendEvent (int eventType, Event event, boolean send) {
+ Display display = getDisplay ();
+ if (eventTable == null && !display.filters (eventType)) {
+ return;
+ }
+ if (event == null) event = new Event ();
+ event.type = eventType;
+ event.display = display;
+ event.widget = this;
+ if (event.time == 0) {
+ event.time = display.getLastEventTime ();
+ }
+ if (send) {
+ sendEvent (event);
+ } else {
+ display.postEvent (event);
+ }
+}
+
+/**
+ * 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;
+}
+
+boolean setInputState (Event event, int type) {
+ if (OS.GetKeyState (OS.VK_MENU) < 0) event.stateMask |= SWT.ALT;
+ if (OS.GetKeyState (OS.VK_SHIFT) < 0) event.stateMask |= SWT.SHIFT;
+ if (OS.GetKeyState (OS.VK_CONTROL) < 0) 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;
+ switch (type) {
+ case SWT.MouseDown:
+ case SWT.MouseDoubleClick:
+ if (event.button == 1) event.stateMask &= ~SWT.BUTTON1;
+ if (event.button == 2) event.stateMask &= ~SWT.BUTTON2;
+ if (event.button == 3) event.stateMask &= ~SWT.BUTTON3;
+ break;
+ case SWT.MouseUp:
+ if (event.button == 1) event.stateMask |= SWT.BUTTON1;
+ if (event.button == 2) event.stateMask |= SWT.BUTTON2;
+ if (event.button == 3) event.stateMask |= SWT.BUTTON3;
+ break;
+ case SWT.KeyDown:
+ case SWT.Traverse:
+ 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;
+ break;
+ case 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;
+ break;
+ }
+ return 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) {
+ if (!display.lastNull) return false;
+ }
+ return setInputState (event, type);
+}
+
+/**
+ * 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 specified
+ * multi-byte character set used by the operating system
+ * widgets.
+ *
+ * @param ch the WCS character
+ * @param codePage the code page used to convert the character
+ * @return the MBCS character
+ */
+int wcsToMbcs (char ch, int codePage) {
+ if (OS.IsUnicode) return ch;
+ if (ch <= 0x7F) return ch;
+ TCHAR buffer = new TCHAR (codePage, ch, false);
+ return buffer.tcharAt (0);
+}
+
+/*
+ * Returns a single character, converted from the wide
+ * character set (WCS) used by Java to the default
+ * multi-byte character set used by the operating system
+ * widgets.
+ *
+ * @param ch the WCS character
+ * @return the MBCS character
+ */
+int wcsToMbcs (char ch) {
+ return wcsToMbcs (ch, 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
index 3e4590df35..5398addd49 100755
--- 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
@@ -1,115 +1,115 @@
-package org.eclipse.swt.widgets;
-
-/*
+package org.eclipse.swt.widgets;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-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;
-}
-
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+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/build.properties b/bundles/org.eclipse.swt/build.properties
index 869eca15b2..9c86577d76 100644
--- a/bundles/org.eclipse.swt/build.properties
+++ b/bundles/org.eclipse.swt/build.properties
@@ -1 +1 @@
-custom = true
+custom = true
diff --git a/bundles/org.eclipse.swt/build.xml b/bundles/org.eclipse.swt/build.xml
index 5d86aa9575..ac375ec7f9 100644
--- a/bundles/org.eclipse.swt/build.xml
+++ b/bundles/org.eclipse.swt/build.xml
@@ -1,38 +1,38 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<project name="org.eclipse.swt" default="build.update.jar" basedir=".">
-
- <target name="init">
- <property name="plugin" value="org.eclipse.swt"/>
- <property name="version.suffix" value="_2.1.0"/>
- <property name="full.name" value="${plugin}${version.suffix}"/>
- <property name="temp.folder" value="${basedir}/temp.folder"/>
- <property name="plugin.destination" value="${basedir}"/>
- <property name="build.result.folder" value="${basedir}"/>
- </target>
-
- <target name="build.update.jar" depends="init">
- <delete dir="${temp.folder}"/>
- <mkdir dir="${temp.folder}"/>
- <antcall target="gather.bin.parts">
- <param name="destination.temp.folder" value="${temp.folder}/"/>
- </antcall>
- <zip zipfile="${plugin.destination}/${full.name}.jar" basedir="${temp.folder}/${full.name}" filesonly="false"/>
- <delete dir="${temp.folder}"/>
- </target>
-
- <target name="gather.bin.parts" depends="init" if="destination.temp.folder">
- <mkdir dir="${destination.temp.folder}/${full.name}"/>
- <copy todir="${destination.temp.folder}/${full.name}">
- <fileset dir="${basedir}" includes="plugin.properties,plugin.xml,about.html" />
- </copy>
- </target>
-
- <target name="build.jars" />
- <target name="gather.sources" />
- <target name="build.sources" />
- <target name="gather.logs" />
-
- <target name="clean" depends="init">
- </target>
-
+<?xml version="1.0" encoding="UTF-8"?>
+<project name="org.eclipse.swt" default="build.update.jar" basedir=".">
+
+ <target name="init">
+ <property name="plugin" value="org.eclipse.swt"/>
+ <property name="version.suffix" value="_2.1.0"/>
+ <property name="full.name" value="${plugin}${version.suffix}"/>
+ <property name="temp.folder" value="${basedir}/temp.folder"/>
+ <property name="plugin.destination" value="${basedir}"/>
+ <property name="build.result.folder" value="${basedir}"/>
+ </target>
+
+ <target name="build.update.jar" depends="init">
+ <delete dir="${temp.folder}"/>
+ <mkdir dir="${temp.folder}"/>
+ <antcall target="gather.bin.parts">
+ <param name="destination.temp.folder" value="${temp.folder}/"/>
+ </antcall>
+ <zip zipfile="${plugin.destination}/${full.name}.jar" basedir="${temp.folder}/${full.name}" filesonly="false"/>
+ <delete dir="${temp.folder}"/>
+ </target>
+
+ <target name="gather.bin.parts" depends="init" if="destination.temp.folder">
+ <mkdir dir="${destination.temp.folder}/${full.name}"/>
+ <copy todir="${destination.temp.folder}/${full.name}">
+ <fileset dir="${basedir}" includes="plugin.properties,plugin.xml,about.html" />
+ </copy>
+ </target>
+
+ <target name="build.jars" />
+ <target name="gather.sources" />
+ <target name="build.sources" />
+ <target name="gather.logs" />
+
+ <target name="clean" depends="init">
+ </target>
+
</project> \ No newline at end of file
diff --git a/bundles/org.eclipse.swt/buildnotes_swt.html b/bundles/org.eclipse.swt/buildnotes_swt.html
index 1851a58b0d..8c67d823f7 100755
--- a/bundles/org.eclipse.swt/buildnotes_swt.html
+++ b/bundles/org.eclipse.swt/buildnotes_swt.html
@@ -1,2272 +1,2272 @@
-<!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.7 [en] (WinNT; I) [Netscape]">
- <meta name="Author" content="IBM">
- <title>Eclipse Platform Build Notes - SWT</title>
-</head>
-<body>
-
-<h1>
-Eclipse Platform Build Notes<br>
-SWT</h1>
-SWT Build 2.1 031 - Thursday February 27, 2003
-
-<h2>
-<a NAME="Problem reports fixed"></a>Problem reports fixed</h2>
-<blockquote>
-16808: Icon in Windows taskbar incorrect
-<br>24494: Incorrect i18n char encoding in text areas
-<br>26541: Exit the Workbench: crash after saving the workspace
-<br>28643: Setting label's background color has no effect
-<br>28845: Refresh tab layout incorrect for lower composite
-<br>29198: Difficult to change character case of cached input values
-<br>29837: [Contributions] Combo control does not show on GTK toolbar, works fine on Win and Motif
-<br>30377: No caret in Java Editor
-<br>30905: Add Menu.setRedraw(boolean) API
-<br>30924: StyledText - StyleRange hashCode throws NullPointerException
-<br>31039: Eclipse does not responde when dialog is opened.
-<br>31187: Selection by mouse drag is out of kilter
-<br>31382: New Folder and New File dialogs UI problem
-<br>31833: wrong background for separator label on MacOS X
-<br>31857: No icons in Labels
-<br>31866: Scrolling in Readme editor is delayed
-<br>31946: Moving CoolBarItems leaves temporary cheese
-<br>31950: StyledText - Shift+UP broken in StyledText control
-<br>31973: GB18030: After created a GB18030 named class, Eclipse for Motif crashed when exiting.
-<br>32360: Embedded display not waking on new Photon events (BBAWT)
-<br>33022: NPE in FontDialog
-<br>33030: Arguments tab 'shows through' Main tab on OS X
-<br>33063: [JUNIT] Caret.setFont
-<br>33119: nullpointer dispose table column
-</blockquote>
-
-<h1>
-Eclipse Platform Build Notes<br>
-SWT</h1>
-SWT Build 2.1 030 - Tuesday February 18, 2003
-
-<h2>
-<a NAME="Problem reports fixed"></a>Problem reports fixed</h2>
-<blockquote>
-17057: Outliner: focus causes select causes horizontal scroll
-<br>21469: Accessibility - Tabbing causes a button to become the default
-<br>22767: toolbar looks very ugly with Win XP's lnf (using manifest file)
-<br>23370: CLabel needs to allow transparent background for Mac OS X
-<br>28831: Displays ligature for fi & fl
-<br>29100: Mouse wheel scrolling not working in editors
-<br>29879: HANG - gtk_main_iteration - Eclipse Freezes moving between perspectives
-<br>30055: DBCS: font rendering quality issue on motif
-<br>30570: DBCS - GB18030: Input GB18030 characters as run arguments cause eclipse for motif crash
-<br>31568: TableLayoutComposite and Table.showItem don't mix
-<br>31686: Wrong margin correction in widgets.Text.computeSize(int, int, boolean)
-<br>31823: Clicking on partially obscured tab should scroll it into view
-<br>31855: [Editor Mgmt] Close buttons in editor get cut off
-<br>31880: Layout bug in commit menu
-</blockquote>
-
-<h1>
-Eclipse Platform Build Notes<br>
-SWT</h1>
-SWT Build 2.1 029 - Thursday February 13, 2003
-
-<h2>
-<a NAME="Problem reports fixed"></a>Problem reports fixed</h2>
-<blockquote>
-6230: ImageLoader: 32-bit colour depth unsupported
-<br>23472: Xlib: unexpected async reply (sequence 0x922d2)!
-<br>23842: "banded" default background look shows through where it shouldn't
-<br>25446: Tree Shift-Click not working when item collapse changes selection
-<br>26381: OpenType: Key Navigation
-<br>29456: GP - XmDSIGetChildPosition - Problem in Shutdown
-<br>29607: [Cell Editors] usability: ComboBoxCellEditor unusable on GTK
-<br>31009: ACC - I20030205 accelerators issues
-<br>31017: HANG - Hang on import external plugins
-<br>31267: Label and text box get the wrong order
-<br>31448: BIDI - Bidi enablement for StyledText - ArrayIndexOutOfBoundsException when highlighting a blank line
-<br>31513: CTabFolder's close box highlight gets clipped at bottom
-<br>31566: FontData "equals()" and "hashcode()" methods do not consider height of the the fontdata
-</blockquote>
-
-<h1>
-Eclipse Platform Build Notes<br>
-SWT</h1>
-SWT Build 2.1 028 - Thursday February 6, 2003
-
-<h2>
-<a NAME="Problem reports fixed"></a>Problem reports fixed</h2>
-<blockquote>
-23262: WebBrowser crashes when viewing Shockwave
-<br>25736: Memory leak while using OLE automation
-<br>29265: Control.setEnabled() not implemented properly on GTK
-<br>29593: Contextual menu too short near bottom of menu
-<br>29931: Mouse clicks are unreliable
-<br>30403: CTabItem close box shifts by 2 pixels when tab selected
-<br>30443: Menubar of SWT standalone applications is empty
-<br>30945: Change in mouse clicking behaviour makes FastViews unusable
-</blockquote>
-
-<h1>
-Eclipse Platform Build Notes<br>
-SWT</h1>
-SWT Build 2.1 027 - Wednesday February 5, 2003
-
-<h2>
-<a NAME="Problem reports fixed"></a>Problem reports fixed</h2>
-<blockquote>
-20755: TVT2: truncated text in dropdown for Dependencies tab in manifest editor
-<br>22759: Input method does not work on GTK/GTK2
-<br>27180: Unable to copy and paste in editing java file
-<br>27183: Mouse drag select produces crash
-<br>28419: Crash when closing shells
-<br>29777: DBCS: Can't drag a file into Run-time workbench
-<br>30212: Read only text widget : can't copy selection
-<br>30401: SWT standalone examples can't come to foreground
-<br>30452: Mouse gets warped to upper left corner of workbench window on actions
-<br>30500: "roaming" focus
-<br>30537: setSelection(allItems) not working on GTK
-</blockquote>
-
-<h1>
-Eclipse Platform Build Notes<br>
-SWT</h1>
-SWT Build 2.1 026 - Tuesday January 28, 2003
-
-<h2>
-<a NAME="Problem reports fixed"></a>Problem reports fixed</h2>
-<blockquote>
-14814: Button mnemonics are not shown properly on Windows XP
-<br>24333: DCR - Tree.getTopItem/setTopItem
-<br>24489: Tab cannot get focus when child-composite has scrollbar
-<br>24815: Cannot launch eclipse: javacore dump
-<br>29142: Hyperlinking from stackdump locks up Eclipse
-<br>29191: Tree - no gray check boxes on MAC (carbon2)
-<br>29426: DBCS:Copy/Paste DBCS failed between eclipse and gedit
-<br>29428: DBCS: Pasted string can't be shown correctly in Search dialog
-<br>29910: Checkbox not displayed until table scrolled
-<br>29966: No more handles on startup
-</blockquote>
-
-<h1>
-Eclipse Platform Build Notes<br>
-SWT</h1>
-SWT Build 2.1 025 - Tuesday January 21, 2003
-
-<h2>
-<a NAME="Problem reports fixed"></a>Problem reports fixed</h2>
-<blockquote>
-25030: (BBAWT) Image Analyzer fails to load a .png file
-<br>25359: RuntimeExceptions thrown from OleListener.handleEvent crash VM
-<br>27099: StyledText - Change CTRL key bindings to MOD1
-<br>27369: No more handles error
-<br>27822: Package Explorer allways centers opened file
-<br>28062: Text field in dialog doesn't get focus
-<br>28743: Trying to see test hiearchy freezes eclipse [JUnit]
-<br>28745: Esc does not cancel tracker
-<br>28967: [Editor Mgmt] no close button on last editor when editors drop-down is active
-<br>29427: DBCS: Can't input DBCS characters in Search dialog
-<br>29496: Cut & paste does not work in dialog text fields
-<br>29503: DBCS:Can't sort by clicking "Description" on "Task View"
-<br>29599: DBCS: upper bar character will be padded
-<br>29608: DBCS: Selected DBCS Classpath can't be shown
-<br>29611: DBCS:Can not input Hangul(Korea font)
-<br>29612: DBCS:Browse function of "Export" doesn't work
-<br>29614: DBCS: Unable to get "Import" contents location with "Browse" button
-<br>29664: SWT Styled Text Wrapping Doesn't Use Font Size Correctly
-<br>29685: DBCS: Candidate Selection Window will be disappeared at DBCS composition
-<br>29730: RowLayout.computeSize provides wrong parameter to layoutVertical
-</blockquote>
-
-<h1>
-Eclipse Platform Build Notes<br>
-SWT</h1>
-SWT Build 2.1 024 - Tuesday January 14, 2003
-
-<h2>
-<a NAME="Problem reports fixed"></a>Problem reports fixed</h2>
-<blockquote>
-21063: Can't drop views over some widgets
-<br>21561: Keyboard navigation in tree widgets on Linux
-<br>25619: OleControlSite event listener problem
-<br>25843: Info pops do not work for Red Hat 8.0.
-<br>27677: [Key Bindings] ctrl-f7 not working
-<br>28879: [Navigator] right-clicking a file doesn't allow me to open it
-<br>29208: Gtk directory dialog behaves like a file dialog
-<br>29252: Accelerators are not disabled when the toolbars and menus are on GTK
-<br>29302: Slider and Scrollbar handle many boundary cases wrong in set* methods
-<br>29334: Make javadoc available for download
-<br>29408: Invoking List.select(*) before open() does not select correct item
-</blockquote>
-
-<h1>
-Eclipse Platform Build Notes<br>
-SWT</h1>
-SWT Build 2.1 023 - Tuesday January 7, 2003
-
-<h2>
-<a NAME="Problem reports fixed"></a>Problem reports fixed</h2>
-<blockquote>
-24283: Default button in the dialog get the enter when typing in japanese
-<br>25486: Eclipse fails with 'no free callback slot'
-<br>26057: StyledText - cleanup passing around of fontdata
-<br>26079: Use PfLoadMetrics() to speed up text extenting
-<br>27869: StyledText overuse of Font.getFontData
-<br>28286: BBAWT: Incorrect palette/color returned on 32-bit true color display
-<br>28382: Extra separator line drawn in emulated CoolBar
-<br>28498: Help menu is confused
-<br>28607: Progress bar doesn't finish in PDE import wizard
-<br>28658: No context menu in perspective bar
-<br>28683: Ctrl-Click in TreeView loses selection
-<br>28701: Method "assert" declared in org.eclipse.swt.tests.junit.StyledTextContentSpec
-<br>28719: Scrolling in Welcome editor is not 'live'
-<br>28812: Mouse cursor changes to arrow after hovering a hyperlinked indentifier
-<br>28833: Eclipse no longer responds to 'Quit' AppleEvent
-<br>28835: Cursor doesn't change to arrow shape when over text scrollbars
-<br>28991: TabFolder.computeSize is grows each time is it called
-<br>29017: ScrolledComposite always makes it's content bigger on resize
-</blockquote>
-
-<h1>
-Eclipse Platform Build Notes<br>
-SWT</h1>
-SWT Build 2.1 022 - Tuesday December 17, 2002
-
-<h2>
-<a NAME="Problem reports fixed"></a>Problem reports fixed</h2>
-<blockquote>
-21409: IllegalArgumentException when editing Java source
-<br>21993: Can't change font sizes
-<br>22305: Launch configuration pane gets visually messed up and ref...
-<br>23830: Out-of-box experience with the Mac.
-<br>23843: Chevrons show up in default layout of Java perspective
-<br>23844: Label doesn't wrap text initiallly
-<br>23850: Missing scrollbar in List
-<br>24437: KeyListeners don't get called
-<br>26322: NPE in Font Dialog
-<br>26331: Wrapped Labels - second line cut off
-<br>26587: Navigate -> Go To Type goes to wrong shell on Mac
-<br>27997: Color dialog crashes Eclipse
-<br>28288: [Editor Mgmt] Editor pane out of sync with views and tabs
-<br>28361: ToolItem leaks Images (?)
-<br>28524: Inconsistent behaviour of tab in password fields
-</blockquote>
-
-<h1>
-Eclipse Platform Build Notes<br>
-SWT</h1>
-SWT Build 2.1 021 - Friday December 13, 2002
-
-<h2>
-<a NAME="Problem reports fixed"></a>Problem reports fixed</h2>
-<blockquote>
-27526: Color selection dialog takes a long time to display in 8-bit mode
-<br>27862: Tree.setSelection() takes > 1 second
-<br>28035: Different callback behavior on Windows and Mac with Combo widget
-</blockquote>
-
-<h1>
-Eclipse Platform Build Notes<br>
-SWT</h1>
-SWT Build 2.1 020 - Tuesday December 10, 2002
-
-<h2>
-<a NAME="Problem reports fixed"></a>Problem reports fixed</h2>
-<blockquote>
-24112: Keyboard shortcuts defined as Ctrl-Shift-x don't work
-<br>24436: Entering Asterisk crashes Eclipse
-<br>26506: Importing External Plug-ins is slow
-<br>27031: en_US.UTF-8 locale not supported on Motif
-<br>27410: [SWT Examples] Arrow buttons won't resize for 10x10,50x50,100x100
-<br>27422: [SWT Examples] Progress bar reverts to 'black' color after Selection slider repositioning
-<br>27501: Selection not correctly updated on right click on a tree
-<br>27524: [SWT Examples] Table item foreground color changes fail after first attempt
-<br>27644: Dismissing open type dialog with Escape crashes Eclipse
-<br>27704: Remove csh build dependency
-<br>27710: Entry point not found SetLayout in GDI32
-</blockquote>
-
-<h1>
-Eclipse Platform Build Notes<br>
-SWT</h1>
-SWT Build 2.1 019 - Tuesday December 3, 2002
-
-<h2>
-<a NAME="Problem reports fixed"></a>Problem reports fixed</h2>
-<blockquote>
-19080: Chaff in table tree of property sheet
-<br>20318: [StyledText] print selection prints whole page (at least in <=f2)
-<br>26563: Crash in Carbon native CopyMask
-<br>26731: Attempting to create a view plug-in project crashes
-<br>27181: Sleak - instrumentation not done on GTK and Motif
-<br>27305: EC: CLabel keeps background colour after gradient is used
-<br>27411: [SWT Examples] SWT.FLAT has no effect for buttons
-<br>27442: Mouse click outside horizontal scroll bar does nothing
-</blockquote>
-
-<h1>
-Eclipse Platform Build Notes<br>
-SWT</h1>
-SWT Build 2.1 018 - Tuesday November 26, 2002
-
-<h2>
-<a NAME="Problem reports fixed"></a>Problem reports fixed</h2>
-<blockquote>
-15031: Font parsing failed
-<br>17237: Progress monitor flickers
-<br>18172: Sig11 from GTK
-<br>19530: Saving locks resizing in second perspective
-<br>19735: No space between longest item in menu and accel keys
-<br>20953: StyledText - tilde problem with french keyboard (2000,NT,XP) on R2.0
-<br>21626: TableItem.getImageBounds fails on Motif (Emulated Widget)
-<br>24872: Splash screen does not show at startup
-<br>24969: JP GP: showing Java-Editor pref. page with editor open
-<br>25053: Cannot use the pull down menu in GTK
-<br>25335: Scrollbars too small on variable selection dialog
-<br>25653: DCR: StyledText do not activate the default button
-<br>26179: Can't select items in a checkbox tree without toggling checked state
-<br>26353: Infopop broken on solaris
-<br>26362: StyledText - investigate necessary state changes between handleTextChanging and handleTextChanged
-<br>26733: Eclipse crashes when GTK theme is changed
-<br>26804: Gtk Label widget has focus decoration drawn too big
-<br>26935: Exception in StyledText with WRAP flag.
-<br>26997: StyledTextRenderer: creates too many Strings
-<br>27016: Default "Open" action not working in Navigator tree view
-</blockquote>
-
-<h1>
-Eclipse Platform Build Notes<br>
-SWT</h1>
-SWT Build 2.1 017 - Tuesday November 19, 2002
-
-<h2>
-<a NAME="Problem reports fixed"></a>Problem reports fixed</h2>
-<blockquote>
-21251: Crash in org.eclipse.swt.internal.gtk.OS.pango_layout_set_font_description
-<br>24835: GTK: Multiple selection and right click in tree
-<br>25741: StyledText does not set the background and foreground color in the OS
-<br>25803: StyledText should use new Font API
-<br>26004: Removing a Text field leaves behind crud
-<br>26008: [StyledText] setTopPixel limits argument to logical line count
-<br>26121: Cannot launch eclipse #2: javacore dump
-<br>26151: SWT widget org.eclipse.swt.widgets.Sash is not properly constrained when in HORIZONTAL mode
-<br>26258: Accented characters bug in editors reinvented
-<br>26367: NPE when debugging as java application
-<br>26414: Accelerators don't work on aix
-<br>26419: StyledText - print pages causes walkback
-<br>26421: List hangs on GTK
-<br>26434: PrinterData startPage/endPage invalid when page >32767
-</blockquote>
-
-<h1>
-Eclipse Platform Build Notes<br>
-SWT</h1>
-SWT Build 2.1 016 - Tuesday November 12, 2002
-
-<h2>
-<a NAME="Problem reports fixed"></a>Problem reports fixed</h2>
-<blockquote>
-23935: Text widget with Tree parent does not lose focus
-<br>23997: Tracker moves mouse cursor
-<br>24493: Cant type braces in java editor with italian keyboard in 2.1m1
-<br>25732: MLEAK: Resize eclipse, usually 4K allocated
-<br>25775: Combo doesn't get restored after minimize/restore
-<br>25781: Some change broke compare with patch
-<br>25797: GTK: Selection Index not preserved after Combo item removal
-<br>25986: No source for SWT plugin imported as binary
-<br>25989: Radion buttons are not mutually exclusive in same composite
-</blockquote>
-
-<h1>
-Eclipse Platform Build Notes<br>
-SWT</h1>
-SWT Build 2.1 015 - Tuesday November 5, 2002
-
-<h2>
-<a NAME="Problem reports fixed"></a>Problem reports fixed</h2>
-<blockquote>
-4607: Missing API for Font(Display display, FontData fd[]) (1G93TPM)
-<br>14956: StyledText - printing should support pagination, headers, and footers
-<br>21695: Crash when starting eclipse on Solaris8 with java 1.4
-<br>22052: Launch configuration dialog loses workspace data dir
-<br>23049: Cannot write Swedish characters (������) in editor
-<br>24273: GP -Tree removeAll reboot windowsXp
-<br>24359: MenuItems with style SWT.RADIO should handle mutual exclusion on selection
-<br>24757: GTK: X pointer grab when resizing a table column
-<br>25212: GPF synchronizing files with new Tree implementation
-<br>25253: Preference dialog doesn't display last preference page
-<br>25399: Drag and drop crashes Eclipse
-<br>25545: StyledText - printing ignores end page
-</blockquote>
-
-<h1>
-Eclipse Platform Build Notes<br>
-SWT</h1>
-SWT Build 2.1 014 - Tuesday October 29, 2002
-
-<h2>
-<a NAME="Problem reports fixed"></a>Problem reports fixed</h2>
-<blockquote>
-10090: Cannot see Combo-box selection in DBCS locale
-<br>12078: SWT exception when running on debian woody on KDE using the motif build
-<br>14448: Setting the accelerator of a menu item gives highlight to tool bar entries
-<br>17361: Tree flickers on update
-<br>17428: Internal Error (SWT) opening a new perspective by double-clicking
-<br>20075: Infopop exhibits strange behaviour under Motif
-<br>21066: Switch editors/views/perspectives windows have scrollbars
-<br>21121: [External Tools] Configuration default selection could be better on GTK
-<br>21375: Reproducible JVM termination when using WebDAV.
-<br>21656: GTK: disposing all the columns in table.getColumns fails
-<br>22038: Wrong widget scrolls in Java Browsing perspective.
-<br>22120: Excessive redraw in debug view
-<br>22252: Project properties - java build path screen shows artifacts
-<br>22371: Invalid selection items in working set
-<br>22527: Working set dialog only selects projects
-<br>22743: Type dialog horizontal scroll too small to read contents
-<br>23657: Problems implementing MenuItem.setText (worked around for English)
-<br>23789: GTK tree display problem
-<br>23845: Spurious scrollbar drawn on other controls
-<br>24150: Shift-Tab does not shift left
-<br>24257: Native exception when trying to export preferences
-<br>24314: FileDialog doesn't allow to navigate into packages
-<br>24372: StyledText - StringIndexOutOfBoundsException in ControlExample
-<br>24426: StyledText - investigate replacing caretLine with simpler concept
-<br>24504: StyledText - showSelection when selection RtoL problem
-<br>24619: DCR - State mask not set in MouseTracker.mouseHover
-<br>25016: [Viewers] Double click not working when item already selected
-<br>25149: StyledText - WrappedContent API does not check line index range
-</blockquote>
-
-<h1>
-Eclipse Platform Build Notes<br>
-SWT</h1>
-SWT Build 2.1 013 - Tuesday October 22, 2002
-
-<h2>
-<a NAME="Problem reports fixed"></a>Problem reports fixed</h2>
-<blockquote>
-20377: StyledText - SWT.WRAP style and widthHint specification
-<br>22986: SWT Controls Combo box Colors selection tool does not change foreground color
-<br>24728: StyledText Enter/Ctrl-Enter VerifyEvent inconsistencies
-<br>24805: ComputeSize issue
-</blockquote>
-
-<h1>
-Eclipse Platform Build Notes<br>
-SWT</h1>
-SWT Build 2.1 012 - Tuesday October 15, 2002
-
-<h2>
-<a NAME="Problem reports fixed"></a>Problem reports fixed</h2>
-<blockquote>
-16657: [Open Modes] Search results doesn't respond to double click
-<br>17334: Icon missing in check box tree
-<br>17918: Tree widgets with multiple entries
-<br>18902: PgUp key causes items to be selected in tree widget under GTK
-<br>20258: [CVS] Esc key doesn't work on Commit Dialog
-<br>21367: Display problem in the properties view
-<br>21438: Java core dump in gtk_ctree_get_node_info
-<br>24560: Ctrl+shift doesn't traverse word
-<br>24676: StyledText - double click word select and caret placement
-<br>24677: 32 bit image fails with a certain mask
-<br>24702: WinCE: Image 32bits is incorrect
-</blockquote>
-
-<h1>
-Eclipse Platform Build Notes<br>
-SWT</h1>
-SWT Build 2.1 011 - Tuesday October 8, 2002
-
-<h2>
-<a NAME="Problem reports fixed"></a>Problem reports fixed</h2>
-<blockquote>
-4822: Group size doesn't seem to consider group name (1GJYIWB)
-<br>10019: Right clicking in a list box should select before popping up menu
-<br>17160: Task List: missing icon
-<br>18842: Cheese when scrolling after deleting row in table
-<br>19773: Coolbar icons in Windows XP with Luna theme are not vertically aligned
-<br>20094: Layout problems using StyledText with word wrap in a ScrolledComposite
-<br>23978: Horizontal scrollbars in tables and trees don't scroll page-wise
-<br>24225: DragSourceAdapter incorrect JavaDoc
-<br>24358: Incomplete JavaDoc on MenuItem.setText
-</blockquote>
-
-<h1>
-Eclipse Platform Build Notes<br>
-SWT</h1>
-SWT Build 2.1 010 - Tuesday October 1, 2002
-
-<h2>
-<a NAME="Problem reports fixed"></a>Problem reports fixed</h2>
-<blockquote>
-10459: I can't run eclipse
-<br>19148: Tooltip pops up underneath code completion alternatives in F2
-<br>20672: Shift+F10 has wrong keyCode
-<br>21287: Uncaught exception hanging Eclipse
-<br>22615: [Dialogs] Native ProgressBar look does not match look of AnimatedProgress
-<br>22645: StyledText - cheese when typing in SWT.SINGLE mode
-<br>23645: Disabled default button can still be reached pressing ENTER
-<br>23846: Initial font height of text field is wrong
-<br>23851: Initial text in Text control is scrolled out of visible area
-<br>23910: CTabFolder selected tab loses synch with its contents
-<br>23936: NPE in ControlExample
-<br>23947: Menu implementation prevents KeybindingMenu from working correctly
-<br>23975: No keyboard shortcuts displayed in menu items
-<br>23976: Function keys must be pressed twice
-<br>24000: No scrollwheel support for Mac OS X
-<br>24055: No more callback exception hang Eclipse
-<br>24088: File chooser for OSX returns wrong path
-<br>24106: Table Column Resizable Doesn't work if you click on Column itself
-<br>24137: Top item on popup is often invisible
-<br>24139: Copy causes exception
-<br>24141: Keyboard not functional in editors (mac os x)
-</blockquote>
-
-<h1>
-Eclipse Platform Build Notes<br>
-SWT</h1>
-SWT Build 2.1 009 - Tuesday September 24, 2002
-
-<h2>
-<a NAME="Problem reports fixed"></a>Problem reports fixed</h2>
-<blockquote>
-7435: ArrayIndexOutBoundsException occurs when using Solaris through remote terminal
-<br>15146: Printing support under Linux?
-<br>18483: IE6 causes conflict with SWT.APPLICATION_MODAL on Windows 98
-<br>20461: WinCE - Wait cursor does not show up
-<br>20958: Eclipse crashes when pasting PDF text into a Java file editor
-<br>21416: Gtk+ launcher
-<br>22121: Eclipse crashes when pasting URL in Java-code
-<br>23007: [Navigator] Import of workspace folder into parent
-<br>23744: Device.getFontList() uses wrong constant name
-<br>23745: Wrong flag used in Device.getFontList().
-<br>23748: Input group is hardcoded as 1 in PhWindowQueryVisible()
-<br>23753: Groups don't look like the platform
-<br>23754: Label.setFont() needs to check "text != null"
-<br>23766: Labels with image only have extra space on GTK
-<br>23795: ControlExample: Image Label leaves cheese when resized
-<br>23807: Display class needs to pick better default fonts.
-<br>23864: CoolBar - Plus 2, Minus 2 problem
-<br>23884: WinCE - OS.InitCommonControlsEx fails with flag DATETIMEPICK_CLASS
-<br>23898: Group.setBackground() don't work on Gtk
-<br>23899: CTRL + Mouseclick
-<br>23974: Use native ComboBox
-</blockquote>
-
-<h1>
-Eclipse Platform Build Notes<br>
-SWT</h1>
-SWT Build 2.1 008 - Tuesday September 17, 2002
-
-<h2>
-<a NAME="Problem reports fixed"></a>Problem reports fixed</h2>
-<blockquote>
-4637: TreeEditor example does not show how to use double click (1GCP6OH)
-<br>4656: Pop-up menu not showing for Composite (1GENYM0)
-<br>4710: Remaining Javadoc problems (1GF088W)
-<br>4730: Support for lesstif on Linux
-<br>4733: Issues with Win32 GDI setBkMode(), and similar things in Motif (1GFPGK3)
-<br>4796: DCR: keyboard support for move/resize (accessibility issue)
-<br>5900: CheckboxTableViewer does disable correctly
-<br>10532: DCR: Table.setSelection(int, int) -- order matters
-<br>12048: NPE exiting workspace
-<br>16700: Coolbar tab order is backwards
-<br>17494: Veronika needs to check her javadoc
-<br>19256: SIP event
-<br>19736: Tooltips for long entries in code assist pop behind code assist
-<br>21126: Print Dialog Is Not Modal, Resulting in Unpredictable Workbench Behavior
-<br>21620: FontData.setLocale() crashes workbench
-<br>22189: Win32 GDI Resource Leak in WrappedContent.java
-<br>22210: Photon:Removing item from Combo does not remove the text(BBAWT)
-<br>22364: Incorrect height of widget in TextViewer
-<br>22490: Background color of Graphical Editors is always black.
-<br>22534: No way to turn border off for linux text widget
-<br>22564: Cannot draw transparent PNG files properly
-<br>22577: List.setSelection(String[]) infinite loop
-<br>22839: When swt window in focus palettes of other windows hosed, and vise versa
-<br>22862: StyledText - Tab does not tab out of non-editable
-<br>22926: Clipboard copy/paste is cut/paste on Windows 98
-</blockquote>
-
-<h1>
-Eclipse Platform Build Notes<br>
-SWT</h1>
-SWT Build 2.1 007 - Tuesday September 10, 2002
-
-<h2>
-<a NAME="Problem reports fixed"></a>Problem reports fixed</h2>
-<blockquote>
-10050: StyledText - Change selection color when changing background color
-<br>14637: StyledText - copy-from text edit feature
-<br>16009: Eclipse's toolbar buttons' icon in black and upside down
-<br>17793: Motif FileDialog often does not use reasonable default directory
-<br>20179: Coolbar item clipped on bottom edge with SWT.BORDER style
-<br>21185: GTK: Label positioning incorrect when style bit used and bounds set(BBAWT)
-<br>22079: StyledText - BidiUtil.isBidiPlatform returns true when not running with bidi locale
-<br>22114: * key expands TableTree but does not send SWT.Expand event
-<br>22115: MessageDialog does not wrap message
-<br>22158: getItem() crashes eclipse called with index 0
-<br>22647: Variant class incorrectly marshals VT_BOOL values
-<br>22746: Text cut off in GTK in TitleAreDialog
-<br>22868: Eclipse hangs while creating a shell from ControlExample
-<br>22874: 2104: Converter contains references to Converter.class
-<br>22916: CCombo not dropping down list properly
-<br>22918: Table.getItem(Point) throws ArrayIndexOutOfBounds
-<br>22959: Dragging over multiple stacked trees uses invisible tree for drop target
-<br>22978: Motif FileDialog ignores SWT.MULTI bit
-<br>23003: Xcopyplane requires 11 args but HP-UX JRE can only handle 10
-<br>23028: EC: Tab un-indent does not work
-<br>23061: 'Back' key does not delete character on Smartphone 2002
-<br>23178: Eclipse Fails to Start First Time
-<br>23285: Linux Motif has become extremely slow
-</blockquote>
-
-<h1>
-Eclipse Platform Build Notes<br>
-SWT</h1>
-SWT Build 2.1 006 - Tuesday August 27, 2002
-
-<h2>
-<a NAME="Problem reports fixed"></a>Problem reports fixed</h2>
-<blockquote>
-5678: TVT: Unable to open Filter dialog on Win98 if another view is undocked (free floating)
-<br>12878: Combo setItems removes setText
-<br>13024: Two tooltips displayed on tree
-<br>14923: Show Text Hover toolbar item in wrong place
-<br>16333: Accessibility - tab key in dialog boxes
-<br>20321: Multiple opened ApplicationWindows with statuslines show incorrect display/event handling
-<br>22231: Pressing ENTER in a text field no longer performs OK in dialogs
-<br>22659: Function key events are often lost
-<br>22661: StyledText - Shift+Alt+<character> inserts character
-<br>22721: Cannot use keyboard to toggle checkboxes
-<br>22737: Mouse Capture on Motif causes Context Menu not to work
-<br>22825: Consecutive vertical cursor movement commands don't retain column offset
-</blockquote>
-
-<h1>
-Eclipse Platform Build Notes<br>
-SWT</h1>
-SWT Build 2.1 005 - Tuesday August 20, 2002
-
-<h2>
-<a NAME="Problem reports fixed"></a>Problem reports fixed</h2>
-<blockquote>
-4554: Combo selection scrolls for certain fonts (1G1AD9Y)
-<br>4577: Ctrl+Backspace & Ctrl+del have the same key code and key event (1G54RAJ)
-<br>4685: Variables View re-positions on each step (1GETE8F)
-<br>10091: MessageBox loses activation
-<br>10976: Workbench windows don't reopen correctly in Dual Monitor environments
-<br>14942: Unexpected KeyDown event after pressing non existing menu mnemonic
-<br>18705: Too much flashin in Control Example
-<br>21829: API needed to allow CCombo to display its list at the prefered width
-<br>22443: OLE - org.eclipse.swt.internal.ole.win32.CONTROLINFO has a useless field 'filler'
-<br>22457: Win32 org.eclipse.swt.widgets.Combo computeSize() is wrong
-<br>22507: Modal dialog does not prevent adjusting of table headers in parent.
-</blockquote>
-
-<h1>
-Eclipse Platform Build Notes<br>
-SWT</h1>
-SWT Build 2.1 004 - Tuesday August 13, 2002
-
-<h2>
-<a NAME="Problem reports fixed"></a>Problem reports fixed</h2>
-<blockquote>
-4737: Redraw problem in table (1GFW2PE)
-<br>9075: Tooltips only partially displayed in Hoverhelp.java example
-<br>15610: StyledText - Double-Click-Drag doesn't work, works on Text
-<br>16990: ToolBar does not send MouseHover events
-<br>20632: Polish national fonts
-<br>20792: sometimes resize callback is not sent to the shell when the shell is not visible
-<br>20815: Menus not displayed on SmartPhone 2002
-<br>21268: StyledText - Ctrl+Shift+J inserts line
-<br>21272: StyledText does not support setting selection with caret on the left
-<br>21921: Emulated Table setTopIndex fails and causes NPE when adding an item afterwards
-<br>21933: TableColumn does not listen to ControlEvents
-<br>22004: no keyboard shortcuts for switching between pages of MultiPageEditorPart
-<br>22188: StyledText - only first character of a line displayed
-<br>22204: Photon: Text.selectAll() does not select all the text(BBAWT)
-<br>22254: Command H is not mapped properly
-<br>22365: SWT_AWT does not compile under JDK 1.4
-</blockquote>
-
-<h1>
-Eclipse Platform Build Notes<br>
-SWT</h1>
-SWT Build 2.1 003 - Tuesday August 6, 2002
-
-<h2>
-<a NAME="Problem reports fixed"></a>Problem reports fixed</h2>
-<blockquote>
-4521: Display.syncExec or Display.asyncExec can block processing of native events (1G03DF0)
-<br>20144: Enter key not working in packages view
-<br>21179: Step filter in-place text editor invisible
-<br>21243: Scroll lock inserts a character during incremental search on GTK
-<br>21338: Accents and � don't work in editor using gtk
-<br>21472: keyPressed event ignored by org.eclipse.swt.widgets.Text for ENTER key
-<br>21696: StyledText - RTF transfer codepage encoding
-<br>21698: StyledText - RTF writer performance improvement
-<br>21834: Coolbar - deleting items corrupting layout
-<br>22004: No keyboard shortcuts for switching between pages of MultiPageEditorPart
-<br>22025: Motif: Unexplained termination running BBAWT JUnit tests
-<br>22036: MOTIF: Appearance issue with Combo
-<br>22060: StyledText - bidi - ArrayIndexOutOfBoundsException
-</blockquote>
-
-<h1>
-Eclipse Platform Build Notes<br>
-SWT</h1>
-SWT Build 2.1 002 - Tuesday July 30, 2002
-
-<h2>
-<a NAME="Problem reports fixed"></a>Problem reports fixed</h2>
-<blockquote>
-4578: Ctrl+J & Ctrl+Enter have the same key code (1G54RJJ)
-<br>4816: TabItem displays & (1GJL704)
-<br>6888: Combo sends ModifyEvent on setItems
-<br>9025: OLE, StyledText widget and WinCE
-<br>19632: Tracker should adjust cursor on mouse not down, not on MENU
-<br>19985: StyledText - Bulleting proofing RTF copy function
-<br>20691: StyledText - bidi - Win2K/XP support
-<br>20746: Inconsistent @param in Javadoc for TableItem.setGrayed(boolean)
-<br>21313: Combo.getItem wrong error thrown
-<br>21423: GTK: GPF in Shell.setVisible()
-<br>21500: GTK: SWT.Activate and SWT.Deactivate events not fired when Shell with NO_TRIM used as its style bit
-<br>21526: Shell.computeTrim does not include menu bar
-<br>21563: Mnemonics give focus to the label on GTK
-<br>21564: GTK: Text of Button(with style bit SWT.CHECK) does not show up correctly
-<br>21573: TableTreeItem should have get/setGrayed() methods like TableItem
-<br>21601: getLineCount() method for Text widget does not work on Motif
-<br>21623: List.setSelection (int start, int end) fails on Motif
-<br>21653: WinCE/SH4: Arrow keys don't generate key events
-<br>21702: Debug Display view error msg to console on GTK
-<br>21706: BidiUtil in win32 has Class.forName() usage
-<br>21805: event.character = 0 for all Ctrl-<alpha> on QNX 6.2
-<br>21937: COMObject leakage on OleControlSite
-<br>21958: ControlExample FileDialog does not filter correctly
-<br>21964: GTK: Adding an item to Combo changes the selection index
-<br>21967: GTK: Setting selection index to -1 for a Combo throws an exception
-<br>21969: List.getSelectionIndex bug
-<br>21976: GTK: Combo.getSelectionIndex() changes when an item is removed
-</blockquote>
-
-<h1>
-Eclipse Platform Build Notes<br>
-SWT</h1>
-SWT Build 2.1 001 - Tuesday July 23, 2002
-
-<h2>
-<a NAME="Problem reports fixed"></a>Problem reports fixed</h2>
-<blockquote>
-4428: Table - Grid lines not drawn correctly (1FE4K5U)
-<br>4451: Shell: setDefaultButton, default button cannot be reset to null (1FGLS6M)
-<br>4489: MouseUp fired for button 1 when button 1 is still pressed (1FODDP4)
-<br>4511: Pane title update flashes tool bar buttons (1FUUR7A)
-<br>4524: CTRL sequences not handled gracefully by TextEditor (1FVSBTS)
-<br>4544: CTRL combination not handled as accelerators when Caps are locked (1FZQDGR)
-<br>4590: VerifyEvent values ignored (1G7G5Y3)
-<br>4626: TableTree: Two selection events generated for each checkbox selection (1GBRSLM)
-<br>4642: DirectoryDialog does not support / on windows (1GD41DZ)
-<br>4648: MenuItem.setEnabled() always causes a redraw (1GDDCN2)
-<br>4786: FontDialog should give access to color setting (1GIEFBD)
-<br>4861: Key state for toolbar items (1GL54A0)
-<br>5935: StyledText - up/down arrow behavior wrt varying line lengths
-<br>6775: Radio button setSelection changes focus
-<br>9859: Combo widget doesn't fire keyPressed or keyReleased for Enter key
-<br>11868: StyledText: text selection with key 'arrow down' does not include last line
-<br>11994: StyledText - replace getXAtOffset(caretOffset) with caret.getLocation().x
-<br>12178: StyledText - move StyledTextRenderer#bidiTextWidth to DisplayRenderer
-<br>12181: StyledText - mixing text width/caret position is confusing
-<br>13944: DCR - Need cut/copy/paste routines on Combo
-<br>14672: Combo and Scale setBackground does not refresh
-<br>14799: Window manipulations block other threads from executing
-<br>15088: StyledText - getTopIndex semantics undefined when no line fully visible
-<br>15554: DCR - alignment in a text widget
-<br>15559: JAWS reads the parent window for dialog shells
-<br>15728: Packages view selection always one too high
-<br>16110: StyledText scroll not working with PageUp/Down keys.
-<br>16205: StyledText - Tab does not tab out of read-only
-<br>16402: Working set dialog: table columns have incorrect size
-<br>16777: Busy cursor lost over progress indicator edges
-<br>16986: JavaViewer example should remember path
-<br>17191: SWT Error in JUnit view
-<br>17252: Accelerator labels: Ctrl-Shift-A, Shift-Ctrl-A or Shift-Ctl-A?
-<br>17279: Extra CoolBar row created when switching perspectives.
-<br>17370: Combo box flashes to much when resizing dialog.
-<br>17993: Find/Replace shouldn't replace typed entry with value from history
-<br>18253: Coolbar - disposing items not honoring setRedraw = false
-<br>18308: Ctrl+SHIFT+@ does not call the listener.
-<br>18429: ScrolledComposite with LayoutManager is VERY slow in iPAQ
-<br>18570: Combo flashes by resizing
-<br>19380: Listboxes flash as preferences dialog is resized
-<br>19434: ToolItem does not need to check for TOGGLE
-<br>19568: {} on a german keyboard [swt-carbon]
-<br>19615: StyledText - example Text Editor bug in copy/paste
-<br>19630: Coolbar - odd dispose behavior
-<br>19815: JRE crashes using error log and progress bar.
-<br>19964: Coolbar - can "lose" items when platform widget wraps
-<br>20159: Right-clicking on coolbar grabber causes strange behavior
-<br>20183: Motif : Coolbar preferred size is too small width wise
-<br>20190: CoolBar problems on Windows XP with Manifest
-<br>20339: Hitting spacebar does not press currently focused button
-<br>20583: Segfault when control tries to dispose of itself under Motif
-<br>20683: [ExternalTools] F3 (and F2) crashes the JVM when trying to cancel an external tool on linux-gtk
-<br>20690: StyledText - bidi - should force font script when keyboard language changed
-<br>20705: Cursor Keys don't work in Dialogs
-<br>20722: GTK TableColumn#pack does not work if no header
-<br>20788: A composite is being mysteriously disposed for no reason
-<br>20846: WIN32: 'Combo.indexOf' always returns -1 for empty string
-<br>20893: Bad size for Text widget when flag READ_ONLY is set (Photon)
-<br>20904: SWT exception on LayoutExample (Photon)
-<br>20950: GTK: F1 help does not work for menu items.
-<br>20956: Emulated CoolItem do not respect SWT.DROP_DOWN flag
-<br>21030: StyledText - during cut if clipboard copy fails do not delete text
-<br>21096: Properties accelerator missing ENTER
-<br>21122: Emacs: Accelerators not shown in menus under GTK
-<br>21154: StyledText - BIDI - Bad effect of RLO unicode character
-<br>21192: UnsatisfiedLinkError thrown when pressing a hardware key
-<br>21215: [Help] F1 Help does not close menu on GTK
-<br>21223: StyledText - Cursor should stop blinking when moving
-<br>21268: StyledText - Ctrl+Shift+J inserts line
-<br>21368: GTK: GC.drawImage() fails when scaling an image
-<br>21371: SWTError while using Navigator->Goto->Resource
-<br>21378: GTK: Shell event's doit flag ignored when shellClosed() is called
-<br>21412: Paste with accelator key doesn't work
-<br>21413: CoolBar computeSize fails on XP
-<br>21415: Javadoc for CLabel.setBackground has typos
-<br>21440: Unable to display Today screen when SWT app running on WinCE
-<br>21449: GTK: Calling Text.setSelection() causes GPF
-<br>21456: GTK: Cannot type in Text widget contained in Shell which has style bit as NO_TRIM
-<br>21484: Shift-Tab does nothing on GTK
-<br>21523: StyledText - caret does not move when widget shell is not open
-<br>21524: StyledText - NPE when typing text and caret is null
-<br>21596: StyledText - initial bidi caret position wrong when widget empty
-<br>21598: StyledText - setFont enables caret when it was disabled
-</blockquote>
-
-<h1>
-Eclipse Platform Build Notes<br>
-SWT</h1>
-SWT Build 2.0 052 - Wednesday October 30, 2002 (2.0.2 stream)
-
-<h2>
-<a NAME="Problem reports fixed"></a>Problem reports fixed</h2>
-<blockquote>
-10459: I can't run eclipse
-<br>24693: org.eclipse.swt.graphics.GC.drawString() fails to draw euro
-<br>24869: GP - Eclipse crashed when entering invalid file name in FileDialog
-</blockquote>
-
-<h1>
-Eclipse Platform Build Notes<br>
-SWT</h1>
-SWT Build 2.0 050 - Wednesday October 16, 2002 (2.0.2 stream)
-
-<h2>
-<a NAME="Problem reports fixed"></a>Problem reports fixed</h2>
-<blockquote>
-24542: [DND] Crash when drag&drop on the Package Explorer
-</blockquote>
-
-<h1>
-Eclipse Platform Build Notes<br>
-SWT</h1>
-SWT Build 2.0 049d - Monday August 26, 2002 (2.0.1 stream)
-
-<h2>
-<a NAME="Problem reports fixed"></a>Problem reports fixed</h2>
-<blockquote>
-22729: Permissions.properties missing from the build script
-<br>22779: Eclipse linux-motif GPFs on exit on J9
-</blockquote>
-
-<h1>
-Eclipse Platform Build Notes<br>
-SWT</h1>
-SWT Build 2.0 049b - Wednesday August 21, 2002 (2.0.1 stream)
-
-<h2>
-<a NAME="Problem reports fixed"></a>Problem reports fixed</h2>
-<blockquote>
-22448: CoolBar - deleting first item in row does unnecessary collapse/expand of row
-<br>22561: Hover Help broken in 2.0.1 I20020815
-</blockquote>
-
-<h1>
-Eclipse Platform Build Notes<br>
-SWT</h1>
-SWT Build 2.0 049 - Wednesday August 14, 2002 (2.0.1 stream)
-
-<h2>
-<a NAME="Problem reports fixed"></a>Problem reports fixed</h2>
-<blockquote>
-22055: CoolBar - setWrapIndices causes rows to collapse/expand unnecessarily
-<br>22144: Coolbar - setSize not being honored after setWrapIndices API used
-<br>22320: Coolbar - delete item behavior problem
-</blockquote>
-
-<h1>
-Eclipse Platform Build Notes<br>
-SWT</h1>
-SWT Build 2.0 048 - Tuesday August 6, 2002 (2.0.1 stream)
-
-<h2>
-<a NAME="Problem reports fixed"></a>Problem reports fixed</h2>
-<blockquote>
-15559: JAWS reads the parent window for dialog shells
-<br>18253: Coolbar - disposing items not honoring setRedraw = false
-<br>19964: Coolbar - can "lose" items when platform widget wraps
-<br>21268: StyledText - Ctrl+Shift+J inserts line
-<br>21834: Coolbar - deleting items corrupting layout
-</blockquote>
-
-<h1>
-Eclipse Platform Build Notes<br>
-SWT</h1>
-SWT Build 2.0 047 - Monday June 17, 2002
-
-<h2>
-<a NAME="Problem reports fixed"></a>Problem reports fixed</h2>
-<blockquote>
-4772: Javadoc: Graphics constructors need to doc if device null (1GHSPUW)
-<br>14144: ScrollBars can't be made invisible on PocketPC
-<br>20265: F3. test C3. No new updates for Eclipse on HP.
-<br>20362: Coolbar cannot be traversed to
-</blockquote>
-
-<h1>
-Eclipse Platform Build Notes<br>
-SWT</h1>
-SWT Build 2.0 046 - Friday June 14, 2002
-
-<h2>
-<a NAME="Problem reports fixed"></a>Problem reports fixed</h2>
-<blockquote>
-16809: Clicking to close non-active editor doesn't have an affect
-<br>16939: DnD: Moving the mouse while dropping behaves strangely while dragging views
-<br>17190: No cell editor support
-<br>17563: Flat tool bar buttons
-<br>17621: Resource Patcher wizard - widgets not properly aligned
-<br>19089: No popup menu java editor ruler (Photon)
-<br>19243: Eclipse launchers have hardcoded j9 args
-<br>19244: Spacing between Table rows grows with number of rows
-<br>20006: X Pointer grab not released
-<br>20044: Unable to scroll license text using keyboard
-<br>20072: Workbench bounces when swtiching perspectives
-<br>20134: Eclipse CLOSES automatically, when i'm working in it
-<br>20184: Color javadoc could use reference to Device.getSystemColor()
-<br>20209: Hang due to OS locking
-<br>20354: GP when attempt to check out SWT from repository
-<br>20372: Tracker needs more javadoc
-</blockquote>
-
-<h1>
-Eclipse Platform Build Notes<br>
-SWT</h1>
-SWT Build 2.0 046 - Tuesday June 11, 2002
-
-<h2>
-<a NAME="Problem reports fixed"></a>Problem reports fixed</h2>
-<blockquote>
-16809: Clicking to close non-active editor doesn't have an affect
-<br>16939: DnD: Moving the mouse while dropping behaves strangely while dragging views
-<br>17190: No cell editor support
-<br>17563: Flat tool bar buttons
-<br>17621: Resource Patcher wizard - widgets not properly aligned
-<br>19089: No popup menu java editor ruler (Photon)
-<br>19243: Eclipse launchers have hardcoded j9 args
-<br>19244: Spacing between Table rows grows with number of rows
-<br>20006: X Pointer grab not released
-<br>20044: Unable to scroll license text using keyboard
-<br>20072: Workbench bounces when swtiching perspectives
-<br>20134: Eclipse CLOSES automatically, when i'm working in it
-<br>20184: Color javadoc could use reference to Device.getSystemColor()
-<br>20209: Hang due to OS locking
-<br>20354: GP when attempt to check out SWT from repository
-<br>20372: Tracker needs more javadoc
-</blockquote>
-
-<h1>
-Eclipse Platform Build Notes<br>
-SWT</h1>
-SWT Build 2.0 045 - Tuesday June 11, 2002
-
-<h2>
-<a NAME="Problem reports fixed"></a>Problem reports fixed</h2>
-<blockquote>
-15242: CoolBar - layout issues
-<br>18517: Coolbar - delete and row layout bug
-<br>19090: Combo doesn't size itself properly in GTK2
-<br>19670: Regression in OLE support
-<br>19671: Unable to expand/collapse trees in properties view
-<br>19720: Coolbar - getPreferredSize problem (was getClientArea problem)
-<br>19787: Hover help is not removed
-<br>19947: GTK2 sends key events with both keyCode and character equals to 0 for some keys
-</blockquote>
-
-<h1>
-Eclipse Platform Build Notes<br>
-SWT</h1>
-SWT Build 2.0 044 - Monday June 10, 2002
-
-<h2>
-<a NAME="Problem reports fixed"></a>Problem reports fixed</h2>
-<blockquote>
-4807: Text.setEchoChar spec should say 0 <= char < 128 (1GJ6CDM)
-<br>4837: Javadoc: Cursor constructor ERROR_NO_HANDLES is not spec'ed (1GKA7Q9)
-<br>5577: Text javadoc
-<br>7526: No spec for Display.update()
-<br>8513: JavaDoc for Menu.addMenuListener incorrect
-<br>12820: Finishing preview of the refactoring code crashes Eclipse
-<br>14463: GP opening two files at the same time
-<br>15460: CoolBar doc unclear/insufficient
-<br>15939: KeyEvent character is not consistent between Linux and Windows
-<br>16810: Mouse pointer not update
-<br>16837: Keys completely lost
-<br>16883: Variable sorting changes unexpectedly
-<br>16895: In-place text fields are unusable
-<br>17036: Disposing a CoolItem is triggering an activation callback.
-<br>17146: Editor Preference page buttom list clipped
-<br>17154: View part loses focus when opening context menu
-<br>17289: Combo doesn't take focus by clicking on it (Photon)
-<br>17290: Modify Method Parameters: wrong enablement of buttons
-<br>17507: AIX FileDialog is not responsive in stand-alone example
-<br>17613: Add from local history shows nothing in right and lower pane
-<br>17670: Cannot move through Plug-in Code Generation page list with arrow keys
-<br>17692: IAE when deleting line in Java Editor
-<br>17752: Cannot select a non-bold font
-<br>17788: Scale with preferred size is unusable (no range of motion)
-<br>17848: F1 build, JVM terminated Exit code 139
-<br>17936: Eclipse launcher must launch headless in headless environments
-<br>18439: Ctrl+F6 editor switching is unusable
-<br>18508: Javacoredump when opening vertical ruler context menu
-<br>18521: Coolbar layout and chevron bug
-<br>18543: An invisible character is added when the 'Windows' key is pressed
-<br>18625: Tabbing in Java editor takes cursor
-<br>18629: GTK: Unable to select dialog buttons with mouse
-<br>18645: Release SWT sources & javadoc in future builds
-<br>18733: ControlExample: List widget not being resized properly
-<br>18804: GPF setting image to menu item (Photon)
-<br>18838: Launch Configurations dialog creeps up
-<br>18841: Question: What does -DMBCS do?
-<br>18930: Wrong content displayed in tabs in the Launch Configuration Dialog
-<br>18934: Scrollbars should be disabled in ImageAnalyzer example
-<br>19057: Problem saving java file through popup menu
-<br>19116: Missing about.html in source directory for examples
-<br>19169: NPE on Emulated CoolItem constructor
-<br>19345: Task View: Not clearing priority icons
-<br>19394: False "unsaved changes" notification from launch configs
-<br>19503: Widget in outliner gets wrapped/cropped
-<br>19595: StyledText - redrawRange not clearing properly when clear flag set
-<br>19660: Preference page does not expand to fit all widgets
-<br>19769: Internet Explorer and Help, EXCEPTION_ACCESS_VIOLATION
-</blockquote>
-
-<h1>
-Eclipse Platform Build Notes<br>
-SWT</h1>
-SWT Build 2.0 043 - Friday May 31, 2002
-
-<h2>
-<a NAME="Problem reports fixed"></a>Problem reports fixed</h2>
-<blockquote>
-4692: Empty popup menu appears in Outline view (1GET1B1)
-<br>8821: Opening editors has become very slow
-<br>15565: Coolbar - minimumWidth not honored under certain conditions
-<br>16688: Selection background on emulated widgets is wrong
-<br>17150: Strange selection behaviour in Java Browsing Perspective
-<br>17156: Delete key not working in package view
-<br>17228: Weird Tree selection behaviour
-<br>17354: Double clicking expands and collapses item
-<br>17363: Test A4.4 cannot edit action set id in properties view
-<br>17680: Outline doesn't expand when adding new method
-<br>17825: ControlExample->Text beeps when I choose SWT.MULTI
-<br>17831: Coolbar - chevron not always displayed when it should be
-<br>18160: "Show in packages view" doesn't scroll to selection
-<br>18229: Walkback when closing ImageAnalyzer
-<br>18368: Get rid of all fragment.properties
-<br>18376: No execute permissions of libraries
-</blockquote>
-
-<h1>
-Eclipse Platform Build Notes<br>
-SWT</h1>
-SWT Build 2.0 042 - Thursday May 30, 2002
-
-<h2>
-<a NAME="Problem reports fixed"></a>Problem reports fixed</h2>
-<blockquote>
-4533: Cheese when resizing toolbar (1FWL943)
-<br>4841: SWT sample imageviewer nothing display at pixel data area (1GKEOUE)
-<br>6735: AWT/SWT - Swing / Swt integration : JComboBox doesn't show correctly
-<br>10972: Core dump drag and droppping from inline text
-<br>12498: Unable to add External Jar using the Java Project Wizard
-<br>16174: Wrong popup menu
-<br>16553: SWT_AWT.new_Panel does not work
-<br>16791: Can't select check boxes
-<br>17199: Table widget - only last column header is clickable
-<br>17375: Cheese on Java Scrapbook page ruler
-<br>17390: JUnit testcases result for Graphics (1 error, 2 failures)
-<br>17565: Add JRE validation not working
-<br>17568: Error doesn't disapear when switching to source folder layout
-<br>17574: Status line contributions appear twice
-<br>17637: Resize problem when diableing overview ruler in Editor
-<br>17662: Incorrect status display in new Feature Wizard
-<br>17917: Shift-Tab does not work
-<br>18223: Text widget with SWT.MULTI has strange behavior on GTK
-</blockquote>
-
-<h1>
-Eclipse Platform Build Notes<br>
-SWT</h1>
-SWT Build 2.0 041 - Tuesday May 28, 2002
-
-<h2>
-<a NAME="Problem reports fixed"></a>Problem reports fixed</h2>
-<blockquote>
-4398: Visual Coordination: Borders (1FSGONG)
-<br>4411: DCR - Support printing (1PQ8QCK)
-<br>4426: ScrollBar - Can't query size (1FDVP23)
-<br>4431: Folder tab does not get focus (1FIGI95)
-<br>4437: Tree Keyboard Support (1FOLZPT)
-<br>4452: MenuItem: setImage does not show image on menu (1FGNP8U)
-<br>4469: Inconsistencies between single line Text and RichText widgets (1FK1RRM)
-<br>4474: Not supportting Windows Accessibility Standard? (1FM0IFS)
-<br>4490: Fonts in examples appear too big (1FOMCWQ)
-<br>4496: DCR - Contour mouse middle button doesn't work (1FREAS4)
-<br>4503: FontDialog is missing fonts (1FSMRV0)
-<br>4526: Severe - Delete key is not redirected to editor (1FVXDST)
-<br>4529: Closing external MS Word makes in-place MS Word disappear (1FWG9AR)
-<br>4534: Flashing when computeSize called on Toolbar (1FWLD1E)
-<br>4545: No OS.GetKeyState function on motif (1FZQOZM)
-<br>4550: JUnit tests assumes boundary condition which is setting dependant (1G0LQKD)
-<br>4552: Adobe doesn't like ImageData... (1G0ZBE0)
-<br>4563: Need support for *.xpm and *.png image file formats (1G3HWSA)
-<br>4636: Tooltips not working on Linux (1GCN4FK)
-<br>4672: DCR - Include "begining / end " arrows to select files (1GEFYCG)
-<br>4679: Colour gradient of views is not gradual (16bit color depth) (1GELWSO)
-<br>4699: DCR - outstanding issue for customer- Changing cursor during drag operation (1GETC8U)
-<br>4703: WinME - Disabled icons in tabbed folder do not display properly. (1GEWXLI)
-<br>4706: StackOverflow resizing Workbench window (1GEWLSU)
-<br>4708: FATAL X error (1GF07HN)
-<br>4709: GP running ( Eclipse ^ 2 ) (1GEZ9UR)
-<br>4711: Navigator messed up when midi(w/DBCS) in it -Can't create view (1GEZNVC)
-<br>4728: Windows with tab pages should allow Ctrl-Tab switching (1GFIUG5)
-<br>4785: DCR - Custom notebook scrolling not optimal (1GI97VZ)
-<br>4839: TabFolder mnemonic problem (1GKAPKK)
-<br>4840: Hebrew: cannot paste from external file into java editor (1GKCWVX)
-<br>4851: Print ignores print to file option (1GKXC30)
-<br>4867: PgMemFlush() considered expensive (1GLEEJC)
-<br>5697: *Please* make SWT use GTK+ instead of Motif
-<br>8346: Workbench will not start
-<br>9217: Internal error at open the package view
-<br>9491: 1GRTRXQ: WSWB:Workbench 2.0 Problem- ArrayIndexOutOfBoundsException with MultiPageEditorPart
-<br>11204: Some ActiveX control can not accept key input.
-<br>11436: Request for public interface to call "UIDeactivate()" of IOleInPlaceObject
-<br>11498: StyledText does not always redraw when the line style changes
-<br>14846: Accessibility: getLocation does not position XP Magnifier
-<br>15218: Platform does not recognize the GUI - 20020502
-<br>15466: ImageData.blit throws ArrayIndexOutOfBounds Exception
-<br>15548: 'X' close box on tab hidden by arrows
-<br>15564: javaw.exe has generated errors and will be closed by windows
-<br>15653: Tab halts on CCombo objects
-<br>16094: Cheese on CTabFolder when resizing
-<br>16200: Tracker leaves cheese
-<br>16345: JVM termination when attepmting to run Update Manager
-<br>16458: Trying to free a GdkEvent: pointer=NULL
-<br>16549: Cannot navigate tabbed notebook with keyboard
-<br>16557: Tab does not move cursor between text fields
-<br>16565: Typed text is lost
-<br>16576: ACC: Checkboxes in lists are not real checkboxes
-<br>16828: CTabFolder flashing tooltip
-<br>16927: External programs support on Photon
-<br>16957: TreeItem.setForegroundColor() doesn't work
-<br>16967: Strange scroll behavior in package dialog
-<br>16995: HoverHelp example does not create ON_TOP Shell for tooltips
-<br>17022: SWT Layouts example - missing window title
-<br>17090: StyledText selects text when menu is showing
-<br>17183: Icon in wizard banner clipped
-<br>17208: Long operations are being modal.
-<br>17305: Search Dialog: Java Page clipped
-<br>17320: Search dialog freezes Eclipse
-<br>17368: 4 Toolbar icons pushed off the toolbar way to the right
-<br>17488: Image Support in SWT - FAQ (1G5Z1KS)
-<br>17497: FileDialog open() returns wrong result
-<br>17632: "Color Button" doesn't update
-<br>17802: Moving a sash requires an extra click to take effect
-<br>17811: Two menu bar items highlighted at the same time
-<br>17816: Menu appears then dissapprears with click after Alt.
-<br>17832: Vertical Scrollbar clipped
-<br>17834: JavaDoc API bad for Image
-<br>17835: Smalltalk code around :)
-<br>17928: NPE on addressbook example
-<br>17932: Emulated Coolbar do not resize when the last item on the row is removed
-<br>17933: Emulated Coolbar chevron too narrow on Photon
-<br>18005: BusyIndicator should check args
-</blockquote>
-
-<h1>
-Eclipse Platform Build Notes<br>
-SWT</h1>
-SWT Build 2.0 040 - Tuesday May 21, 2002
-
-<h2>
-<a NAME="Problem reports fixed"></a>Problem reports fixed</h2>
-<blockquote>
-3554: TP125: weird tab order in create project wizard (1G83VP8)
-<br>4424: Table draws a stray pixel in top left corner (1FS9QBQ)
-<br>4476: No syncExec runnables run during scrolling (1FMGG2X)
-<br>4528: Need FocusIn event for OleClientSite (1FW2S00)
-<br>4586: Use checkWidget() more often (1G80URQ)
-<br>4609: FillLayout should have FillLayout(type) constructor (1G9XBPI)
-<br>4694: Editor Name is missing from tab (1GET93J)
-<br>4726: CODE CHANGES AFTER THE FREEZE (1GF9YF0)
-<br>4788: Feature request: styled tree items (1GIGJK4)
-<br>4789: XP - Look and feel problems (1GIGGKM)
-<br>4831: DND not working properly (1GJYOZC)
-<br>4838: Can create FontData with null name string (1GKA93P)
-<br>4941: Focus callback during OleClientSite deactivate call
-<br>4942: Combo selection index should move when upper item removed (1GLGA41)
-<br>5910: Toolbar with all items disabled still shows up in tab order
-<br>5936: Composite.setTabList should accept null
-<br>6198: Focus lost in tab folder when switching pages
-<br>6406: J IME positioning incorrect
-<br>6514: Code assist behaves differently on Linux
-<br>6856: Default buttons different on Variable dialog
-<br>8162: Accessibility: focus goes missing in CVS location wizard
-<br>8791: Overaggressive focus grabbing
-<br>9141: WorkBench->Preference dialog's buttons font is too small.
-<br>9287: Combo.setText does not work
-<br>10491: Bold button will not bold text in SWT TextEditor Example
-<br>11074: EventTable.sendEvent should probably use try/finally
-<br>11349: Editor Tabs should fill to the right.
-<br>11369: Coolbar feature requests
-<br>11516: ViewForm should override computeTrim
-<br>11738: growing status bar
-<br>11847: OLE Editor prevents navigation without keys
-<br>12398: Accessibility problems
-<br>12641: Error in .classpath for Photon
-<br>12904: Accessible resizing of Views should move/change the Display's Cursor
-<br>12972: Noticed increased number of Eclipse crashes
-<br>13622: DCR - need ability to cancel window system shutdown
-<br>14449: [M5] error bringing up Code Formatter page
-<br>14546: TableColumn alignment problem with Motif
-<br>14656: Repaint of window does not wotk with IME up
-<br>14801: Mnemonic character doesn't work on TabFolder on QNX
-<br>15124: NPE: Label Decorations preference page
-<br>15134: Open Type dialog has wrong initial focus
-<br>15172: focus not on text field for OpenTypeDialog
-<br>15224: FileDialog does not return the file selected on PocketPC
-<br>15237: Coolbar - corrupts wrap layout when items deleted
-<br>15513: CCombo.setTooltipText() doesn't work
-<br>15516: GP - Eclipse crashed
-<br>15575: Tree with checkbox items are not accessible
-<br>15613: Copy/paste inserts NULL
-<br>15705: Editor with focus, tab text disappears sometimes
-<br>15872: Editor area frame should align with open editor's, excluding drop shadow
-<br>15989: Coolbar walkback when adding item
-<br>16069: Can't see source in imported binary SWT
-<br>16210: Core Dump Occurred while in Open Type dialog
-<br>16245: CTabFolder - tooltips and arrowing around
-<br>16281: Eclipse does not come up
-<br>16297: Wrong tab order in newer builds
-<br>16318: Can't activate views; losing events
-<br>16465: Stack Overflow when importing a project
-<br>16523: Unable to double-click
-<br>16525: Eclipse does not layout properly
-</blockquote>
-
-<h1>
-Eclipse Platform Build Notes<br>
-SWT</h1>
-SWT Build 2.0 039 - Tuesday May 14, 2002
-
-<h2>
-<a NAME="Problem reports fixed"></a>Problem reports fixed</h2>
-<blockquote>
-6103: Menu mnemonics don't work when toolbar has focus
-<br>8805: Context menus and finding references to methods
-<br>14823: Drag&Drop: need way to set the default behvaiour of a drop o
-<br>15055: Column Header Height in a Table or Table Tree SWT widget
-<br>15253: Linux GTK 2 library not found
-<br>15274: Can't add external jar in Linux-GTK version
-<br>15603: Preference page no longer resizes to fit contents
-<br>15634: Table not acting like list when last column deleted
-<br>15637: Cheese in Table when setting column image
-<br>15643: Cheese in Table when changing font
-<br>15705: Editor with focus, tab text disappears sometimes
-</blockquote>
-
-<h1>
-Eclipse Platform Build Notes<br>
-SWT</h1>
-SWT Build 2.0 038 - Tuesday May 7, 2002
-
-<h2>
-<a NAME="Problem reports fixed"></a>Problem reports fixed</h2>
-<blockquote>
-6391: Display.getActiveShell() can answer wrong value
-<br>7170: Tab space size problem
-<br>8542: Close perspective with mouse isn't possible
-<br>8591: Editor tabs should scroll automatically to fill available tab space
-<br>8648: StyledText - Caret can be hidden under scrollbar
-<br>10263: Editor keeps scrolling after mouse up
-<br>12226: Solaris - can't copy file into same directory
-<br>12360: TraverseEvent e.doit doesn't turn off on TabFolder
-<br>12952: Alt+{char} gets inserted as text
-<br>13614: JFace Tables have an extra column
-<br>13651: Printed output issues
-<br>13725: Revert is much slower than close and re-open in java editor.
-<br>14431: TableViewer inconsistent when clicking off of item list
-<br>14866: Shift-selection doesn't work immediately after restart
-<br>14880: Column resize problems/cheese
-<br>14902: Executable launcher does not restart
-<br>14935: EmulatedWidgetTests fail on Linux
-<br>14937: Launch from New Office Document hangs until Eclipse exits.
-<br>14964: StyledText - add new API for replacing style ranges
-<br>14981: Focus not set anymore
-<br>15057: getSystemColor(SWT.COLOR_WIDGET_FOREGROUND) always returns black
-<br>15115: removeColumn are broken in Emulated Table
-<br>15141: Tab is caught by read only text
-<br>15150: Progress bar behaves erraticaly
-<br>15208: StyledText - text change even mechanism poorly documented
-<br>15348: GPF in OS.MoveMemoryW
-</blockquote>
-
-<h1>
-Eclipse Platform Build Notes<br>
-SWT</h1>
-SWT Build 2.0 037 - Tuesday April 30, 2002
-
-<h2>
-<a NAME="LIBRARY LOCATION CHANGE"></a>LIBRARY LOCATION CHANGE</h2>
-
-As of this build, libraries are no longer in the org.eclipse.swt plugin.
-
-<p>Libraries can now be found in the associated windowing system fragment which to date are:
-<ul>
-<li>org.eclipse.swt.win32
-<li>org.eclipse.swt.motif
-<li>org.eclipse.swt.photon
-<li>org.eclipse.swt.gtk
-<li>org.eclipse.swt.gtk1x
-</ul>
-
-<h2>
-<a NAME="Problem reports fixed"></a>Problem reports fixed</h2>
-<blockquote>
-4641: Icon lookup fails for some windows icon paths (1GD2DEY)
-<br>4802: StyledText - Bidi Support Open Issues (1GIZ5G3)
-<br>4842: Can't launch external editors. (1GKEYOE)
-<br>6098: EXCEPTION_ACCESS_VIOLATION running Eclipse
-<br>6858: GP - Crash VM
-<br>8826: GPF - closing a Java editor
-<br>8837: Window position changed incorrectly in Shell.open()
-<br>9297: Eclipse crashed
-<br>11374: gp: Crash in swt-win32-2026.dll
-<br>11587: BIDI:Java editor and Text editor: User Interface issues.
-<br>12811: TableColumns don't pack properly
-<br>13200: gp - MoveMemory error on Windows XP
-<br>14049: gp - Crash in OS.MoveMemoryW
-<br>14220: gp - Crash closing editor
-<br>14245: gp - crash while debugging (NRCRASH)
-<br>14249: Exception while stepping
-<br>14280: Unsatisfied Link Errors running libswt-pi-gtk-2034.so on Linux/Gtk 2.0
-<br>14425: Font dialog exception
-<br>14528: Problem with Label.computeSize.
-<br>14538: StyledText - bidi - change backspace and delete behavior
-<br>14813: ClassCastException creating a new Run configuration
-<br>14872: ArrayIndexOutOfBoundsException in TableItem.insertColumn
-</blockquote>
-
-<h1>
-Eclipse Platform Build Notes<br>
-SWT</h1>
-SWT Build 2.0 036 - Tuesday April 23, 2002
-
-<h2>
-<a NAME="Problem reports fixed"></a>Problem reports fixed</h2>
-<blockquote>
-4834: DCR - mnemonics do not work on tabbed pages (1GK7O0N)
-<br>7189: Method highlight in border does not match the method
-<br>8253: Right clicking does not bring up context menu
-<br>8306: Inconsistencies in SWT example descriptions
-<br>8538: Mismatch between selected tab and displayed tab
-<br>8544: Some problems with the editor-pane (repaint, focus)
-<br>9360: Text entry in cvs comment dialog can't deal with quick typing
-<br>9794: Linux-GTK KeyEvents bad/different from the other platforms
-<br>12947: Color Preferences in Preferences->Java->Editor
-<br>13826: Performance issue in Table.RemoveAll()
-<br>13922: Eclipse crashes when running LayoutExample
-<br>13999: StyledText - appending single line data doesn't update properly
-<br>14047: StyledText - inefficient redraw during text change with word wrap
-</blockquote>
-
-<h1>
-Eclipse Platform Build Notes<br>
-SWT</h1>
-SWT Build 2.0 035 - Thursday April 18, 2002
-
-<h2>
-<a NAME="New APIs"></a>New APIs</h2>
-<ul>
-<li>Display.setCursorLocation</li>
-<li>GridLayout(int,boolean)</li>
-</ul>
-
-<h2>
-<a NAME="Problem reports fixed"></a>Problem reports fixed</h2>
-<blockquote>
-4602: GridLayout should have GridLayout(numColumns) constructor (1G9Z73D)
-<br>8549: org.eclipse.core.resources 4 Unhandled exception caught in event loop
-<br>9029: GC.setClipping(Rectangle) should handle null argument on GTK
-<br>10590: GTK Version / Tree View blanks...
-<br>10715: Code Assist dialog hide after press and release CTRL + SPACE
-<br>11182: Property Sheet does not allow editing when there is only one property
-<br>11515: computeTrim and getClientArea are inconsistent in CTabFolder
-<br>11713: Descriptions in preference pages aren't aligned
-<br>11715: Tab doesn't switch fields on gtk
-<br>11835: Strange behaviour of backspace in new Java Class dialog
-<br>11935: Can't Ctrl+Tab out of PDE Editor's dependencies page
-<br>12073: Moving shell above other shells does not work.
-<br>12882: DCR: Set Cursor location programmatically for accessibility
-<br>13194: Usability: editor tabs
-<br>13384: NPE on launching
-<br>13432: OleControlSIte doesn't propagate WM_SETFOCUS message to an ActiveX control
-<br>13639: Controls do not appear in tool items
-<br>13800: Can not get FocusEvent from Combo
-<br>13982: Eclipse won't start on GTK2
-</blockquote>
-
-<h1>
-Eclipse Platform Build Notes<br>
-SWT</h1>
-SWT Build 2.0 034 - Tuesday April 9, 2002
-
-<h2>
-<a NAME="Problem reports fixed"></a>Problem reports fixed</h2>
-<blockquote>
-6774: WinCE - items regarding Pocket PC (including 2002) integration
-<br>8806: Moving views is difficult
-<br>9245: ToolItems in a ToolBar not displaying images on WinCE
-<br>9616: Resize column leaves some cheese in the table
-<br>10603: Add Breakpoint keeps prompting me
-<br>10937: Converter problem on Solaris
-<br>11520: ShellAdapter.shellDeactivated() never called on Linux-Motif
-<br>11734: Focus not on "Finished" button
-<br>11940: Down arrow does not access drop-down portion of toolbar buttons
-<br>12241: Codeassist disappear after a few seconds
-<br>12573: Table sends selection event twice when in TabFolder
-<br>12787: Changing a menu item's text makes its icon disappear
-<br>12885: Label as a seperator doesn't resize properly
-<br>13006: Alt+1 with blank TabFolder results in NPE
-<br>13014: SetToolTipText called multiple times does not resize.
-<br>13049: CTabFolder focus traversing is busted
-</blockquote>
-
-<h1>
-Eclipse Platform Build Notes<br>
-SWT</h1>
-SWT Build 2.0 033 - Tuesday April 2, 2002
-
-<h2>
-<a NAME="Problem reports fixed"></a>Problem reports fixed</h2>
-<blockquote>
-12446: SWT Table Column Image Corruption
-<br>12447: Tree.getSelection() is slow for large trees
-</blockquote>
-
-<h1>
-Eclipse Platform Build Notes<br>
-SWT</h1>
-SWT Build 2.0 032 - Thursday March 28, 2002
-
-<h2>
-<a NAME="StyledText Bidi Printing"></a>StyledText Bidi Printing</h2>
-<blockquote>
-<p>Support has been added for printing the contents of a StyledText widget on
-bidirectional language Windows platforms.</p>
-<p> Note however that printing English or local language text does not work properly with some
-printer drivers when using a non-TrueType font. This has been noticed on Windows
-NT systems with the HP Laserjet 4 series printer driver. Please use a TrueType
-font if text is printed garbled .
-<br></p>
-</blockquote>
-
-<h2>
-<a NAME="Problem reports fixed"></a>Problem reports fixed</h2>
-<blockquote>
-4467: DCR - Tree missing keyboard support (1FJH5GY)
-<br>4525: Property viewer doesn't adapt to bg color changes (1FX8XL1)
-<br>10317: StyledText - bidi printing support
-<br>10483: SWT ControlExample DirectoryDialog does not choose directories
-<br>11081: Java Source Editing with Greek Locale no longer works
-<br>11549: Create project does not allow creation of folder in its project selection
-<br>12099: Accessibility : JAWS can not read TabItem's text
-<br>12231: DND : Drag and Drop busted (mouse capture not released)
-</blockquote>
-
-<h1>
-Eclipse Platform Build Notes<br>
-SWT</h1>
-SWT Build 2.0 031 - Monday March 18, 2002
-
-<h2>
-<a NAME="New APIs"></a>New APIs</h2>
-<ul>
-<li>ScrolledComposite.getOrigin</li>
-<li>ScrolledComposite.setOrigin</li>
-<li>Variant.getType</li>
-</ul>
-
-<h2>
-<a NAME="Problem reports fixed"></a>Problem reports fixed</h2>
-<blockquote>
-7500: Display.getBounds() calls from another thread give incorrect results
-<br>10273: NPEs caused by unitialized 'item' field in event
-<br>10481: View will not Size via Pull Down
-<br>10511: Add programmatic scrolling to ScrolledComposite
-<br>10942: Launcher should autodetect gtk only installation.
-<br>11051: Invalid token pasting in callback.c
-<br>11090: CLabel Javadoc says SmartLabel
-</blockquote>
-
-<h1>
-Eclipse Platform Build Notes<br>
-SWT</h1>
-SWT Build 2.0 030 - Tuesday March 12, 2002
-
-<h2>
-<a NAME="New APIs"></a>New APIs</h2>
-<ul>
-<li>OleControlSite.addEventListener(OleAutomation,int,OleListener)</li>
-<li>TableItem.getForeground()</li>
-<li>TableItem.getBackground()</li>
-<li>TableItem.setForeground(Color)</li>
-<li>TableItem.setBackground(Color)</li>
-<li>TreeItem.getForeground()</li>
-<li>TreeItem.getBackground()</li>
-<li>TreeItem.setForeground(Color)</li>
-<li>TreeItem.setBackground(Color)</li>
-<li>TableTreeItem.getForeground()</li>
-<li>TableTreeItem.getBackground()</li>
-<li>TableTreeItem.setForeground(Color)</li>
-<li>TableTreeItem.setBackground(Color)</li>
-</ul>
-
-<h2>
-<a NAME="Problem reports fixed"></a>Problem reports fixed</h2>
-<blockquote>
-8737: No Selection event when DND starts
-<br>9950: ColorDialog weird behavior
-<br>9959: Persistent Eclipse NPE on startup
-<br>9993: OleControlSite is not powerful enough
-<br>10420: Mouse and DND Event notification out of order
-<br>10480: Unable to open files with "System Editor"
-<br>10482: View will not Move via Pull Down
-</blockquote>
-
-<h1>
-Eclipse Platform Build Notes<br>
-SWT</h1>
-SWT Build 2.0 029 - Tuesday March 5, 2002
-
-<h2>
-<a NAME="New APIs"></a>New APIs</h2>
-
-<b>Note:</b> The new Accessibility API is experimental, and will likely change.
-<ul>
-<li>Control.getAccessible() added</li>
-<li>package <b>org.eclipse.swt.accessibility</b> added, containing the following classes:<ul>
-<li>Accessible</li>
-<li>ACC</li>
-<li>AccessibleListener</li>
-<li>AccessibleAdapter</li>
-<li>AccessibleEvent</li>
-<li>AccessibleControlListener</li>
-<li>AccessibleControlAdapter</li>
-<li>AccessibleControlEvent</li>
-</ul></li></ul>
-
-Here are two examples that use the accessibility API:<ul>
-<li>For a control with no child items:
-<code><pre>
- button.getAccessible().addAccessibleListener(new AccessibleAdapter() {
- public void getName(AccessibleEvent e) {
- e.result = "My Button Label";
- }
- });
-</pre></code></li>
-
-<li>For a control that has child items:
-<code><pre>
- list.getAccessible().addAccessibleListener(new AccessibleAdapter() {
- public void getName(AccessibleEvent e) {
- if (e.childID == ACC.CHILDID_SELF) {
- e.result = "My List Label";
- } else {
- e.result = "My List Item Label: " + list.getItem(e.childID);
- }
- }
- });
-</pre></code></li></ul>
-<b>Note:</b> The API involving the AccessibleControlXxx classes is more complex, and more likely to change.
-It is unlikely that application code will need to use it.
-It is primarily for the use of custom control implementors.
-
-<h2>
-<a NAME="Problem reports fixed"></a>Problem reports fixed</h2>
-<blockquote>
-4436: Grid Layout Problem (1FOLZZE)
-<br>4666: DCR - Need a way for child shells to disable ESC closing (1GE8RXW)
-<br>4790: XInitThreads causes japanese input method to hang (1GIRYR6)
-<br>4775: XInitThreads causes X printing to hang (1GITBQL)
-<br>4454: DCR: Tables need to support cell editing (1FGPLPP)
-<br>10002: Detection of CDE as active WM is platform-specific
-<br>10426: Esc traverse does not go up hierarchy
-</blockquote>
-
-<h1>
-Eclipse Platform Build Notes<br>
-SWT</h1>
-SWT Build 2.0 028 - Thursday February 28, 2002
-
-<h2>
-<a NAME="Problem reports fixed"></a>Problem reports fixed</h2>
-<blockquote>
-4688: J - Font Dialog does not select a font when selecting a font family (1GET5BW)
-<br>7139: FontDialog: Selected font not used
-<br>8865: Exception when creating a ToolItem with a null image in Linux
-<br>10250: Slider with VERTICAL orientation - down arrow increments
-</blockquote>
-
-<h1>
-Eclipse Platform Build Notes<br>
-SWT</h1>
-SWT Build 2.0 027 - Tuesday February 26, 2002
-
-<h2>
-<a NAME="Problem reports fixed"></a>Problem reports fixed</h2>
-<blockquote>
-6409: Node selection in package view
-<br>8389: MouseUp not reported correctly if DragDetect hooked
-<br>9364: Exception in StyledText
-<br>9773: Font and Color dialogs do not appear centred on parent
-<br>9950: ColorDialog weird behavior
-</blockquote>
-
-<h1>
-Eclipse Platform Build Notes<br>
-SWT</h1>
-SWT Build 2.0 026 - Tuesday February 12, 2002
-
-<h2>
-<a NAME="Problem reports fixed"></a>Problem reports fixed</h2>
-<blockquote>
-6679: Image.getImageData() not implemented
-<br>7962: SWT.getPlatform() javadoc incorrect for return description
-<br>8984: CTabFolder.MIN_TAB_WIDTH should not be static
-<br>9022: Linux: Tree Viewer does not get defualt Selection
-<br>9072: Table Tree does not pick up windows settings changes
-<br>9091: StyledText in SINGLE mode should look more like a Text widget
-<br>9172: SWT AddressBook Example calls undefined method
-<br>9432: The doc for Tracker widget should specify that rectangles are in screen coordinates
-</blockquote>
-
-<h1>
-Eclipse Platform Build Notes<br>
-SWT</h1>
-SWT Build 2.0 025 - Tuesday February 5, 2002
-
-<h2>
-<a NAME="Problem reports fixed"></a>Problem reports fixed</h2>
-<blockquote>
-2430: Sorting the Tasks List should display icon for sort key/order (1GF5TQO)
-<br>4485: DCR - Table column header decoration capability needed (1FOQQM8)
-<br>6035: Difference in tree "expanded state" between Windows and Motif
-<br>6983: Browse button in Import->Plugins not working.
-<br>7400: Single line text fields not firing "Key Pressed" events for the Enter, Up(arrow), and Down(arrow) keys
-<br>8173: Accessibility: keyboard-invoked popup menu not usable
-<br>8196: Accessibility: shift+F10 does not display view menu
-<br>8273: Horizontal scorllbar does not allow scrolling when required
-<br>8396: WINCE: Menu bar obscures control when control location is 0,0
-<br>8397: WINCE: Menu item colors don't match menu bar
-<br>8412: WINCE: Background color of buttons looks wrong
-<br>8640: GP: opening Synchronization perspective
-<br>8942: Wrong text indent in a table when use image
-</blockquote>
-
-<h1>
-Eclipse Platform Build Notes<br>
-SWT</h1>
-SWT Build 2.0 024 - Tuesday January 29, 2002
-
-<h2>
-<a NAME="Problem reports fixed"></a>Problem reports fixed</h2>
-<blockquote>
-4654: VAJ hangs when dragging from file manager to the desktop. (1GDQFZ6)
-<br>4720: Eclipse freezes during drag & drop operation (1GF7RRH)
-<br>4724: GP - Fatal app error - renaming resource on linux (1GF7TXO)
-<br>4736: Fix printing (1GFW2CW)
-<br>4817: Need JavaDoc comments for SWT Photon (1GJLEU0)
-<br>6835: Characters ��� and � doesn't work in Java editor on Swedish
-<br>8255: Closing paint viewer causes internal error
-<br>8410: Black color become transparent in ToolBar images
-<br>8503: StyledText - cheese if resize in word wrap tries to keep partial top line
-<br>8547: Intellimouse scrolling does not work in eclipse
-</blockquote>
-
-<h1>
-Eclipse Platform Build Notes<br>
-SWT</h1>
-SWT Build 2.0 023a - Thursday January 24, 2002 (Eclipse Milestone 2)
-
-<h2>
-<a NAME="Problem reports fixed"></a>Problem reports fixed</h2>
-<blockquote>
-4700: NumLock and CapsLock disable accelerators (1GETDT9)
-<br>6180: Wake mechanism broken on Motif
-<br>6873: Decorations.setImage() throws NPE on WINCE
-<br>7805: A new ImageData(from an InputStream) throwing NPE
-<br>8133: When toolbar has focus, can't use mnemonics for File menus
-<br>8213: exception: widget is disposed
-</blockquote>
-
-<h1>
-Eclipse Platform Build Notes<br>
-SWT</h1>
-SWT Build 2.0 023 - Tuesday January 22, 2002
-
-<h2>
-<a NAME="Problem reports fixed"></a>Problem reports fixed</h2>
-<blockquote>
-4610: StyledText - DCR - Word wrap (1GABS6C)
-<br>4644: Mouse click on a link displayed in embedded IE5 ActiveX is not reliable (1GD7TT2)
-<br>5660: SWT default font's need to honor accesability settings
-<br>6324: SWT.CLOSE implies rendering of Minimize and Maximize buttons
-<br>6997: StyledText - mark new API
-<br>7123: Shell shows the maximize button enabled when SWT.TITLE | SWT.BORDER | SWT.CLOSE style passed
-<br>7361: Add getOffsetAtLine API
-<br>7632: Tree widget doesn't select item with focus on right-click
-<br>7849: Labels on WINCE don't use background color of parent when color isn't set
-<br>7867: DCR: Delete checkSubclass method from Dialog
-<br>7959: Potential problems when running on big endian machines
-</blockquote>
-
-<h1>
-Eclipse Platform Build Notes<br>
-SWT</h1>
-SWT Build 2.0 022 - Tuesday January 15, 2002
-
-<h2>
-<a NAME="Problem reports fixed"></a>Problem reports fixed</h2>
-<blockquote>
-4663: Fail to tab the views. (1GGYV8T)
-<br>4718: Tool tip is openning when on dragging. (1GF5Z7Z)
-<br>5866: Can't multiselect in Tree using keyboard
-<br>6592: Box for checkbox table items is too large when using large fonts
-<br>6770: Only the left mouse button should select in a Table.
-<br>6852: StyledText - verify event character invalid value
-<br>6940: MenuShortcuts only respond to Ctrl-N
-<br>7190: Ctrl-S does not work
-<br>7458: WinCE - top level Shells created through Display.asyncexec can have incorrect Z-order
-<br>7459: Caret leaving garbage
-<br>7486: Cannot use keyboard Shift Select in a Tree
-<br>7559: ScrollBar thumb is reset when ScrollBar is hidden, then shown
-</blockquote>
-
-<h1>
-Eclipse Platform Build Notes<br>
-SWT</h1>
-SWT Build 2.0 021 - Tuesday January 8, 2002
-
-<h2>
-<a NAME="Problem reports fixed"></a>Problem reports fixed</h2>
-<blockquote>
-4443: Layout: Exceptions when horizontalSpan > remaining columns (1FFC6XZ)
-<br>4462: ScrollBar - vbar.setMaximum does not work after hbar is hidden (and vice versa) (1FIG5CG)
-<br>4722: First editor tab missing close button (1GF7QIQ)
-<br>4755: Rebuilding launcher from another directory (1GGNRG0)
-<br>6315: Some perspective save confirmation messages cut off
-<br>6352: Editor doesn't get activated when revealing first match
-<br>6908: Menu handle leak in org.eclipse.swt.widgets.Menu.destroyItem(MenuItem)
-<br>6945: Child shells not displaying on WinCE
-<br>6982: CheckedTables have no check boxes
-<br>7005: Missing methods in SWT/GTK implementation
-<br>7018: Tree does not honor SWT.CHECK style
-<br>7068: ScrollBar.setVisible(true) does not work after changing values
-<br>7150: StyledText - bidi - partial styling of ligatures bug
-<br>7191: Dialogs not big enough for content
-</blockquote>
-
-<h1>
-Eclipse Platform Build Notes<br>
-SWT</h1>
-SWT Build 2.0 020 - Tuesday December 18, 2001
-
-<h2>
-<a NAME="Problem reports fixed"></a>Problem reports fixed</h2>
-<blockquote>
-4715: First help click on a chapter is ignored (1GF5TV9)
-<br>4784: MIF Files sometime fail (1GI7H7V)
-<br>4797: Table does not use System fonts (1GIV4PZ)
-<br>6635: WinCE: decorations.setMenuBar can be set only once
-<br>6685: StyledText - on setFont caret not being positioned correctly
-<br>6773: StyledText.computeSize uses display width to calculate number of visible lines
-<br>6790: Touching code assist scrollbar dumps javacore
-<br>6863: Remaining issues in emulated CoolBar and CoolItem
-<br>6933: Switching to help perspective crashes the workbench
-<br>7014: Tree not accepting children
-</blockquote>
-
-<h1>
-Eclipse Platform Build Notes<br>
-SWT</h1>
-SWT Build 2.0 019 - Tuesday December 11, 2001
-
-<h2>
-<a NAME="Problem reports fixed"></a>Problem reports fixed</h2>
-<blockquote>
-4461: SWTException should overwrite printStackTrace(..) (1GLDW6P)
-<br>4493: Check multilingual support on Windows 2000 (1FQFCBQ)
-<br>4611: StyledText - StringIndexOutOfBounds exception inserting text in line break (1GEID8B)
-<br>4620: Workbench does not close ActiveX control's file handle (1GB76AZ)
-<br>4660: Moving
-<br>4719: Background colour of views/editors (1GF6C8Y)
-<br>4739: DCR: Provide auto-scrolling and expansion by default in the tree during DND (1GFW7NQ)
-<br>4767: Tab Folders can not be toggled using keys. (1GHFCZU)
-<br>4780: YAM: Cannot read some JPEG files (1GI6ZEN)
-<br>4783: Can't scroll to the top of the navigator (1GI7GTG)
-<br>5071: Shift-TAB doesn't generate proper event
-<br>5677: Hierarchy outline has empty space
-<br>5857: Image.getImageData needs to support 15 bit color depth
-<br>6472: Table widget has empty entries
-<br>6572: Default background color of Lists and Combos not consistent with Win2K
-<br>6651: Text.setSelection() doesn't actually display the selection visually for SWT.SINGLE
-<br>6654: Text.getSelection() not returning correct info on WINCE
-</blockquote>
-
-<h1>
-Eclipse Platform Build Notes<br>
-SWT</h1>
-SWT Build 2.0 018 - Tuesday December 4, 2001
-
-<h2>
-<a NAME="Problem reports fixed"></a>Problem reports fixed</h2>
-<blockquote>
-4419: Widgets - Missing features and API on MOTIF (1FBPKCT)
-<br>4494: ColorDialog doesn't open in VA/Java with JDK 1.2 (1FQGM6H)
-<br>4833: Remove focus button from Table (1GK7MK4)
-<br>4860: StyledText - StyledTextBidi, BidiUtil need doc (1GL32C8)
-<br>6204: KeyListener on table does not work.
-<br>6438: StyledText - bidi - isBidi test not working on XP
-</blockquote>
-
-<h1>
-Eclipse Platform Build Notes<br>
-SWT</h1>
-SWT Build 2.0 017 - Tuesday November 27, 2001
-
-<h2>
-<a NAME="Problem reports fixed"></a>Problem reports fixed</h2>
-<blockquote>
-4714: Label draws wrong background when image is set (1GF0IC6)
-<br>5503: Tabbing broken
-<br>5986: BidiUtil handling of WM_INPUTLANGCHANGE needs to be fixed
-<br>5992: Changing Java Editor font in Preference Page makes Eclipse hang or crash
-<br>6171: NullPointerException in ImageLoader save method with SWT.IMAGE_JPEG
-</blockquote>
-
-<h1>
-Eclipse Platform Build Notes<br>
-SWT</h1>
-SWT Build 2.0 015 - Tuesday November 20, 2001
-
-<h2>
-<a NAME="Problem reports fixed"></a>Problem reports fixed</h2>
-<blockquote>
-4791: StyledText does not switch colour (1GILHIW)
-<br>4956: StyledText - change StyledTextBidi.toString to conform with standard SWT format
-<br>5599: StyledText - redrawRange does not check range
-<br>5722: Selecting font crashes eclipse with a javacore
-<br>5815: StyledText - setFont refresh problem
-<br>5846: Combo.select does not ignore an out of range index
-<br>5990: Printing single page prints entire document
-</blockquote>
-
-<h1>
-Eclipse Platform Build Notes<br>
-SWT</h1>
-SWT Build 2.0 014 - Thursday November 15, 2001
-
-<h2>
-<a NAME="Problem reports fixed"></a>Problem reports fixed</h2>
-<blockquote>
-4542: Menu accelerators CTRL+ / and CTRL + SHIFT + / don't work (1FYAF8V)
-<br>4754: Arrow keys not accepted as keyboard accelerators (1GGM4U3)
-<br>5815: StyledText - setFont refresh problem
-</blockquote>
-
-<h1>
-Eclipse Platform Build Notes<br>
-SWT</h1>
-SWT Build 2.0 013 - Tuesday November 13, 2001
-
-<h2>
-<a NAME="Problem reports fixed"></a>Problem reports fixed</h2>
-<blockquote>
-4846: StyledText - bidi - partial styling of ligatures (1GL3AWT)
-<br>4859: StyledText - bidi - provide solution for bidi coloring hack (1GL2UNC)
-<br>5491: StyledText - getStyleRangeAtOffset allows offset == getCharCount
-<br>5497: StyledText - ExtendedModify event not sent on setText
-<br>5602: StyledText - page down causes IllegalArgumentException in invisible/small widget
-<br>5615: StyledText - window start does not always work
-<br>5622: StyledText - print causes NPE when invoked on empty widget
-<br>5626: StyledText - print does not check for null Printer argument
-<br>5633: StyledText - replaceTextRange and setText do not check for null argument
-<br>5664: StyledText - Single line should not accept tab
-<br>5673: StyledText - SINGLE line mode still allows some multi line cursor navigation
-<br>5722: Selecting font crashes eclipse with a javacore
-<br>5725: Please rename "Eclipse Launcher"
-<br>5802: EC: ControlExample does not run on Solaris
-</blockquote>
-
-<h1>
-Eclipse Platform Build Notes<br>
-SWT</h1>
-SWT Build 2.0 012 - Monday November 5, 2001
-
-<h2>
-<a NAME="Problem reports fixed"></a>Problem reports fixed</h2>
-<blockquote>
-5470: User is lost when trying to move views around
-<br>5484: Tab no longer traverses between widgets!!!
-</blockquote>
-
-<h1>
-Eclipse Platform Build Notes<br>
-SWT</h1>
-SWT Build 2.0 011 - Thursday November 1, 2001
-<h2>
-<a NAME="API Changes"></a>API Changes</h2>
-<code>FontData.setLocale(Locale)</code> has been changed to <code>FontData.setLocale(String)</code>.
-<ul>
-<li>
-J2SE code can simply create a <code>Locale</code> and invoke <code>toString()</code> to pass it onto the new <code>setLocale</code>.
-<li>
-CLDC code will have to form a string matching the format specified in the J2SE javadoc of <code>java.util.Locale.toString()</code>.
-</ul>
-Example:
-<blockquote><code><pre>
-Locale[] locales = {
- Locale.US, new Locale("iw", "IL"), new Locale("ar", "SA"), new Locale("ru", "RU"),
- Locale.GERMAN, new Locale("ja", "JP"),
- null,
-};
-// old code: fd.setLocale(locales[i]);
-String locale = (locales[i] != null ? locales[i].toString() : null);
-fd.setLocale(locale);
-</pre></code></blockquote></p>
-
-<h2>
-<a NAME="Problem reports fixed"></a>Problem reports fixed</h2>
-
-<blockquote>
-4664: StyledText does not compute correct text width (1GELJXD)
-<br>4832: German: Fonts cannot handle German characters (1GKMHHY)
-<br>4961: Preferences dialog disappears when you click on certain pages
-<br>5180: Open Motif for Linux shared libraries are duplicated in Eclipse
-<br>5304: StyledText - ArrayIndexOutOfBoundsException in StyledTextBidi.segmentedRangesFor
-</blockquote>
-
-
-<h1>
-Eclipse Platform Build Notes<br>
-SWT</h1>
-SWT Build 2.0 010 - Thursday October 25, 2001
-
-<h2>
-<a NAME="Behaviour change"></a>Behaviour change</h2>
-<p>
-1) The Drag Under effect of scrolling and expanding items as you drag over the <code>Tree</code> or <code>Table</code> has been added. To enable this drag under effect, in the <code>DragOver</code> event set the <code>event.feedback</code> to have a bitwise combination of <code>DND.FEEDBACK_SCROLL, DND.FEEDBACK_EXPAND</code> and (<code>DND.FEEDBACK_SELECT, DND.FEEDBACK_INSERT_BEFORE, DND.FEEDBACK_INSERT_AFTER</code>) - where the last three items are mutually exclusive.
-<blockquote><code><pre>
-target.addDropListener (new DropTargetAdapter() {
- public void dragOver(DropTargetEvent event){
- event.feedback = DND.FEEDBACK_SELECT | DND.FEEDBACK_EXPAND | DND.FEEDBACK_SCROLL;
- }
-}
-</pre></code></blockquote></p>
-<p>
-2) On some operating systems it is preferred to move files in a drag and drop operation rather than for the drop target to make a copy of the file and the drag source to delete the original file. The operation of moving the file is preformed by the drop target. For these cases, the new drop type <code>DND.DROP_TARGET_MOVE</code> has been added. The Eclipse <code>DropTarget</code> does not support this behaviour but the Eclipse <code>DragSource</code> can recognize this scenario. If another application has chosen to move the file rather than copy/delete, the <code>DragFinished</code> event on the <code>DragSource</code> will have an <code>event.detail</code> value of <code>DND.DROP_TARGET_MOVE</code>.
-<blockquote><code><pre>
-source.addDragListener (new DragSourceAdapter () {
- public void dragFinished(DragSourceEvent event) {
- if (event.detail == DND.DROP_TARGET_MOVE) {
- // clean up presentation but do not delete underlying file
- }
- }
-}
-</pre></code></blockquote></p>
-
-<h2>
-<a NAME="Problem reports fixed"></a>Problem reports fixed</h2>
-
-<blockquote>
-1767: Display ASCII for values greater than 127 fails (1GLE8I5)
-<br>4725: FontData spec should disallow null name (1GL34H3)
-<br>4844: Tab appears narrower than space (1GL2WTY)
-<br>4852: German: Cannot start Eclipse in Linux 7.2 (1GKYY99)
-<br>4865: TableTreeEditor.getItem returns an item after setting it to null (1GLE0IQ)
-<br>4932: StyledTextBidi has equals but no hashCode method
-<br>4957: StyledText - implement StyledTextBidi.isLigated
-<br>5132: StyledText - remove hardcoded margin
-<br>5178: Change BidiUtil calls to handle true Unicode/Windows CE changes
-</blockquote>
-
-<h1>
-Eclipse Platform Build Notes<br>
-SWT</h1>
-SWT Build 2.0 009 - Thursday October 18, 2001
-
-<h2>
-<a NAME="Problem reports fixed"></a>Problem reports fixed</h2>
-
-<blockquote>
-4444: EWT - incorrect selection feedback when the item's text is changed (1FFP3U2)
-<br>4446: DCR - GridBagLayout compatible LayoutManager (1FGCPO2)
-<br>4762: StyledText - default lineStyler remove line background color hack (1GHBMUV)
-<br>4819: StyledText - bidi - cursor navigation (1GJLKSN)
-<br>4820: StyledText with style SINGLE does not handle CR/LF well (1GJM2Z5)
-<br>4855: Severe: Check boxes are black (1GL0XSI)
-<br>4909: EC: Combo.setText doesn't work on Linux
-<br>4910: EC: Combo.select() fires a selected event on Linux only
-<br>5045: Control.moveAbove() throws NPE if argument is null
-</blockquote>
-
-
-<h1>
-Eclipse Platform Build Notes<br>
-SWT</h1>
-SWT Build 2.0 008 - Thursday October 11, 2001
-
-<h2>
-<a NAME="Problem reports fixed"></a>Problem reports fixed</h2>
-
-<blockquote>
-1GLDQYB: SWT:WIN - Text widget with DND enabled, MouseDown but no MouseUp
-<br>1GLADBK: SWT:ALL - StyledText - getOffsetAtLocation should throw exception
-<br>1GL4ZVE: SWT:ALL - StyledText - getOffsetAtLocation(getLocationAtOffset(N)) != N
-<br>1GKO6NY: SWT:ALL - Backspacing in StyledText does not fire selection changed
-<br>1GKB1OC: ITPJUI:ALL - Error in JavaDoc hover help
-<br>1GK9API: SWT:ALL - StyledText - bidi - numbers,mixed LtoR/RtoL text and caret positioning
-<br>1GJLQ16: SWT:ALL - StyledText - bidi - backspace and delete behavior
-<br>1GIK7D4: SWT:ALL - StyledText - Selection cleared when deletion disallowed by verify listeners
-<br>1GDOMBI: SWT:WINNT - StyledText - redrawRange() doesn't checkWidget
-<br>1GDKK3R: SWT:WINNT - StyledText - setCaretOffset and line delimiters bug
-<br>1FMRQOT: SWT:ALL - No null argument checks in Dialog constructors
-</blockquote>
-
-
-<h1>
-Eclipse Platform Build Notes<br>
-SWT</h1>
-SWT Build 2.0 007 - Thursday October 4, 2001
-
-<h2>
-<a NAME="Problem reports fixed"></a>Problem reports fixed</h2>
-
-<blockquote>
-1GKZH74: ITPJUI:WIN2000 - Disappearing Stop icon
-<br>1GKZ8CV: SWT:WINNT - setSelection triggers SelectionChanged event
-<br>1GKU4C5: SWT:ALL - StyledText - bidi - scrolling to show cursor should take cursor direction into account
-<br>1GKPYMK: SWT:WINNT - StyledText - bidi - caret moves when switching keyboard from Hebrew to Arabic
-<br>1GKOGQO: SWT:ALL - Javadoc: setSelection in Button and ToolItem
-<br>1GKM2O5: SWT:WINNT - StyledText - bidi - ArrayIndexOutOfBounds exception in StyledTextBidi.isRightToLeft
-<br>1GKM193: SWT:WINNT - StyledText - bidi autoscroll left does not always scroll all the way to the left
-<br>1GKKC0U: SWT:ALL - Tracker calls OS.DispatchMessage(msg) on windows but does not on Linux.
-<br>1GIVAXX: SWT:ALL - StyledText - Editors should support shift-backspace
-<br>1GELQ14: SWT:WINNT - StyledText - DefaultContent - handle weird line delimiter cases
-<br>1GE8LG0: SWT:Linux - Toolbar is not showing the separators.
-</blockquote>
-
-
-<h1>
-Eclipse Platform Build Notes<br>
-SWT</h1>
-SWT Build 2.0 006 - Thursday Sept 27, 2001
-
-<h2>
-<a NAME="Problem reports fixed"></a>Problem reports fixed</h2>
-
-<blockquote>
-1GHWA19: SWT:WINNT - Problem with callbacks from CCombo
-<br>1GHFDPV: SWT:WIN2000 - Setting selection in Table does not update focus item
-<br>1GF644V: ITPUI:Linux - Unzoom is changing the active editor.
-<br>1GKM3XS: SWT:WINNT - StyledText - bidi autoscroll left: selection reset on mouse move
-</blockquote>
-
-
-<h1>
-Eclipse Platform Build Notes<br>
-SWT</h1>
-SWT Build 2.0 005 - Friday Sept 21, 2001
-
-<h2>
-<a NAME="Problem reports fixed"></a>Problem reports fixed</h2>
-
-<blockquote>
-1GK09Z0: SWT:Linux - setEnabled(false) has no effect on aToolbar
-<br>1GJZZS6: SWT:Linux - File Dialog returns a directory
-<br>1GF7SMC: ITPUI:Linux - Wrong bg for close button on editor tab
-</blockquote>
-
-
-<h1>
-Eclipse Platform Build Notes<br>
-SWT</h1>
-SWT Build 2.0 004 - Thursday Sept 13, 2001
-
-<h2>
-<a NAME="API Behaviour change"></a>API Behaviour change</h2>
-The behaviour of dispose for GCs has been modified such that attempting to dispose of
-a GC on a control <em>after</em> the control has been disposed will generate an
-SWTException. This fixes an OS resource leak and potential GPF situation.
-
-<h2>
-<a NAME="Problem reports fixed"></a>Problem reports fixed</h2>
-
-<blockquote>
-1GJUAKL: SWT:Neutrino - Control.internal_new_GC() needs !isValidWidget() check
-<br>1GJN52N: SWT:Linux - Text prints system error message for horizontal scrollbar
-<br>1GJBOAV: SWT:ALL - ScrolledComposite bugs
-<br>1GIXELI: SWT:ALL - Need Caret to allow bitmaps so bidi caret can be created
-<br>1GI5O1T: SWT:WINNT - Composite.setFocus takes focus when it should not
-<br>1GHOND7: SWT:WIN2000 - Selection problem with single-selection trees
-<br>1GHG990: SWT:ALL - Probable bug in Slider page increment setting
-<br>1GENJ60: SWT:ALL - ScrolledComposite should include example in its class comment
-<br>1GEA7K7: ITPUI:Linux - Default button not working
-</blockquote>
-
-
-<h1>
-Eclipse Platform Build Notes<br>
-SWT</h1>
-SWT Build 2.0 003 - Friday Sept 07, 2001
-
-<h2>
-<a NAME="New APIs"></a>New APIs</h2>
-
-<blockquote>
-FontData.setLocale(java.util.Locale) added
-<br>Caret.getImage() added
-<br>Caret.setImage(Image) added
-<br>GC.fillGradientRectangle(int, int, int, int, boolean) added
-</blockquote>
-
-<h2>
-<a NAME="Problem reports fixed"></a>Problem reports fixed</h2>
-
-<blockquote>
-1GJM7KM: SWT:Linux - Table and Tree return a different size for every second call to computeSize
-<br>1GJLKHE: SWT:SPARC - GP on "Installed JREs" preference page
-<br>1GJLK63: SWT:ALL - StyledText - bidi - keyboard switching
-<br>1GJLE36: SWT:WINNT - Alpha data redrawing improperly after occlusion
-<br>1GJA2L7: SWT:WIN - Different behavior for GC.drawString() args on Win vs. Photon
-<br>1GIZ0P6: SWT:WINNT - GC.drawImage() problem with transparent pixels
-<br>1GIXELI: SWT:ALL - Need Caret to allow bitmaps so bidi caret can be created
-<br>1GI7FQF: SWT:ALL - Can't set focus to Tasks View by Keyboard
-<br>1GI7EBL: SWT:Linux - api typo: ToolItem>>getDisabledmage()
-<br>1GI3P86: SWT:ALL - Semantic differences between emulated Table and Tree codebase on Motif and Photon
-<br>1GI1WEA: SWT:Neutrino - Text selection code not working correctly
-<br>1GHWED2: SWT:WINNT - GC.stringExtent() not correct for Windows Arial font
-<br>1GHWB7G: SWT:Linux - Linux font dialog doesn't open with given values.
-<br>1GHVRFY: SWT:Neutrino - Text#ClearSelection changes the CaretPosition in a SINGLE-line widget
-<br>1GHVLV6: SWT:Neutrino - Text#SetTopIndex and getTopIndex inconsistent
-<br>1GHOJ6T: SWT:Neutrino - Text#setSelection inconsistent between SINGLE and MULTI
-<br>1GHBLRA: SWT:Neutrino - Display.getBounds() returns incorrect info
-<br>1GH48UQ: SWT:Neutrino - Enter key does not insert new line with Text.MULTI widget
-<br>1GGT0TM: SWT:Neutrino - GC#drawArc inconsistent between NT and NTO
-<br>1GG1DBT: SWT:SPARC - Solaris loses input characters
-<br>1GG07HW: SWT:Linux - Tree.getItem() modifies its argument on Motif
-<br>1GG0069: SWT:Linux - Weird layout issues seen in Control Example
-<br>1GFZZLK: SWT:Linux - ToolItems not disabled when containing ToolBar is disabled
-<br>1GFZU3X: SWT:ALL - ImageLoader.load(String) not closing file input stream
-<br>1GFZPDP: SWT:Linux - Combo box with SWT.SIMPLE style does not respect Disabled flag (visually)
-<br>1GFW85H: SWT:ALL - Printer.getPrinterData() has stale comment
-<br>1GFW6MQ: SWT:ALL - DCR: Program class needs .equals() and .hashCode()
-<br>1GFW4YN: SWT:ALL - Help KevinH add printing to Eclipse
-<br>1GFQKDT: SWT:ALL - Image.setBackground() / getBackground() asymmetry
-<br>1GFONVW: SWT:Linux - Empty Combo should not fire Selection event
-<br>1GFL0HP: SWT:Linux - Remaining items in SWT comments to fix
-<br>1GET90D: SWT:Linux - SWTExceptions bring down Eclipse
-<br>1GESQBK: ITPJUI:WINNT - How to get access to pop-up menus of the Java editor ?
-<br>1GELX4A: ITPUI:ALL - Hover help is not visible if pane is dragged out of workbench
-<br>1GEHWAF: ITPUI:WIN2000 - Can't enter text in a Swing TextField or TextArea
-<br>1GE5ECJ: ITPUI:WIN2000 - Hover help for title bar buttons appears behind detached view
-<br>1GDX7R8: ITPUI:ALL - SWT setText() does NOT have any way to avoid making mnemonics.
-<br>1GD5UHA: SWT:WIN2000 - Double-clicking on toolbar item gives double-click event on toolbar
-<br>1GBXIEO: SWT:ALL - DCR: Include cursor pos in Tracker move event
-<br>1G4IMQ3: SWT:WINNT - Table images incorrect after rapid removal and creation
-</blockquote>
-
-<h1>
-Eclipse Platform Build Notes<br>
-SWT</h1>
-SWT Build 2.0 002 - Wednesday July 18, 2001
-
-<h2>
-<a NAME="Problem reports fixed"></a>Problem reports fixed</h2>
-
-<blockquote>
-1GGZ13T: SWT:Neutrino - invalid mouse state occuring in Photon
-<br>1GGRCCS: SWT:Neutrino - Label does not wrap in SWT0125
-<br>1GGAON2: SWT:ALL - Scaling image with alphas does not work correctly
-<br>1GFZQVQ: SWT:Linux - Vertical ProgressBar grows incorrectly
-<br>1GFQA18: SWT:Linux - Cheese with GC drawRoundedRectangle() on Motif
-<br>1GFPK6G: SWT:Linux - Motif fillPolygon() specifies improper hint
-</blockquote>
-
-<h1>
-Eclipse Platform Build Notes<br>
-SWT</h1>
-SWT Build 2.0 001 - Thursday July 12, 2001
-
-<h2>
-<a NAME="Problem reports fixed"></a>Problem reports fixed</h2>
-
-<blockquote>
-1GGET76: SWT:Neutrino - Canvas does not respond to setFocus()
-<br>1GGAS5P: SWT:Neutrino - Photon on QNX 6.1.x needs SWT native changes
-<br>1GG96RO: SWT:Neutrino - drawOval and fillOval not compatible
-<br>1GG8ZLV: SWT:WINNT - drawOval behaves differently on Windows vs. other platforms
-<br>1GFKYD9: SWT:Linux - -HANG- (Xserver) When perfoming display.wake() in a DND dragStart()
-<br>1GFKK37: SWT:Linux - FileViewer examples issues
-<br>1GFBHX6: SWT:ALL - CTabItem tool tip flashing
-<br>1GF9ZMT: SWT:SPARC - 8-bit Icons are losing colors
-<br>1GF9ZJG: SWT:SPARC - Icons are being masked incorrectly on Solaris
-<br>1GF9YHD: ITPUI:WIN2000 - SWTException: help view
-<br>1GF9Y32: SWT:SPARC - 24-bit MSB Icons are wrong color (greenish)
-<br>1GF0D05: SWT:Linux - GPFs when running JUnit TestRunner in J9 AWT
-<br>1GEUZZC: SWT:ALL - "Name" of plugin inconsistant with other plugins
-<br>1GETDP5: ITPUI:Linux - NPE while closing editor on linux
-<br>1GDVRT5: SWT:Neutrino - Alpha channel memory leak
-<br>1GDRXZR: ITPJUI:Linux - SWT: Context-Menus issue under Linux
-<br>1GD0OSK: SWT:ALL - API - package javadoc for SWT packages missing
-<br>1GCHS75: SWT:WINNT - workbench exits during expand collapse
-<br>1GCFUS0: SWT:ALL - CTabFolder "floating" X sticks sometimes
-<br>1GAR95O: SWT:ALL - Remove Smalltalk comments from SWT code
-<br>1GAQRND: SWT:ALL - DOC: Write good Javadoc comments for all of SWT
-<br>1G97I28: SWT:Linux - Tool bar buttons do not always work
-<br>1G84AZB: ITPDUI:ALL - Rename truncates name
-<br>1G845EZ: SWT:WIN2000 - Spec for Layout.computeSize() is truncated
-<br>1G7YXLB: SWT:WIN - StyledText - NLS Support
-<br>1G7NSHR: SWT:ALL - Widget.addListener(int, Listener) vs. adding typed listeners
-<br>1G4XDJO: SWT:Linux - Tree needs to display an insert marker
-<br>1G0Y8NZ: SWT:ALL - Combo box doesn't send key and mouse events
-<br>1FXAVLF: SWT:WINNT - Disabled toolbar icons don't adapt to appearance changes
-<br>1FV1S18: SWT:ALL - Need more WM_* messages passed to ActiveX Control
-<br>1FTWX55: SWT:ALL - Inconsistant commenting of which SWT objects need to be disposed.
-</blockquote>
-<a href="hglegal.htm"><img SRC="ngibmcpy.gif" BORDER=0 height=12 width=195></a>
-</body>
-</html>
+<!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.7 [en] (WinNT; I) [Netscape]">
+ <meta name="Author" content="IBM">
+ <title>Eclipse Platform Build Notes - SWT</title>
+</head>
+<body>
+
+<h1>
+Eclipse Platform Build Notes<br>
+SWT</h1>
+SWT Build 2.1 031 - Thursday February 27, 2003
+
+<h2>
+<a NAME="Problem reports fixed"></a>Problem reports fixed</h2>
+<blockquote>
+16808: Icon in Windows taskbar incorrect
+<br>24494: Incorrect i18n char encoding in text areas
+<br>26541: Exit the Workbench: crash after saving the workspace
+<br>28643: Setting label's background color has no effect
+<br>28845: Refresh tab layout incorrect for lower composite
+<br>29198: Difficult to change character case of cached input values
+<br>29837: [Contributions] Combo control does not show on GTK toolbar, works fine on Win and Motif
+<br>30377: No caret in Java Editor
+<br>30905: Add Menu.setRedraw(boolean) API
+<br>30924: StyledText - StyleRange hashCode throws NullPointerException
+<br>31039: Eclipse does not responde when dialog is opened.
+<br>31187: Selection by mouse drag is out of kilter
+<br>31382: New Folder and New File dialogs UI problem
+<br>31833: wrong background for separator label on MacOS X
+<br>31857: No icons in Labels
+<br>31866: Scrolling in Readme editor is delayed
+<br>31946: Moving CoolBarItems leaves temporary cheese
+<br>31950: StyledText - Shift+UP broken in StyledText control
+<br>31973: GB18030: After created a GB18030 named class, Eclipse for Motif crashed when exiting.
+<br>32360: Embedded display not waking on new Photon events (BBAWT)
+<br>33022: NPE in FontDialog
+<br>33030: Arguments tab 'shows through' Main tab on OS X
+<br>33063: [JUNIT] Caret.setFont
+<br>33119: nullpointer dispose table column
+</blockquote>
+
+<h1>
+Eclipse Platform Build Notes<br>
+SWT</h1>
+SWT Build 2.1 030 - Tuesday February 18, 2003
+
+<h2>
+<a NAME="Problem reports fixed"></a>Problem reports fixed</h2>
+<blockquote>
+17057: Outliner: focus causes select causes horizontal scroll
+<br>21469: Accessibility - Tabbing causes a button to become the default
+<br>22767: toolbar looks very ugly with Win XP's lnf (using manifest file)
+<br>23370: CLabel needs to allow transparent background for Mac OS X
+<br>28831: Displays ligature for fi & fl
+<br>29100: Mouse wheel scrolling not working in editors
+<br>29879: HANG - gtk_main_iteration - Eclipse Freezes moving between perspectives
+<br>30055: DBCS: font rendering quality issue on motif
+<br>30570: DBCS - GB18030: Input GB18030 characters as run arguments cause eclipse for motif crash
+<br>31568: TableLayoutComposite and Table.showItem don't mix
+<br>31686: Wrong margin correction in widgets.Text.computeSize(int, int, boolean)
+<br>31823: Clicking on partially obscured tab should scroll it into view
+<br>31855: [Editor Mgmt] Close buttons in editor get cut off
+<br>31880: Layout bug in commit menu
+</blockquote>
+
+<h1>
+Eclipse Platform Build Notes<br>
+SWT</h1>
+SWT Build 2.1 029 - Thursday February 13, 2003
+
+<h2>
+<a NAME="Problem reports fixed"></a>Problem reports fixed</h2>
+<blockquote>
+6230: ImageLoader: 32-bit colour depth unsupported
+<br>23472: Xlib: unexpected async reply (sequence 0x922d2)!
+<br>23842: "banded" default background look shows through where it shouldn't
+<br>25446: Tree Shift-Click not working when item collapse changes selection
+<br>26381: OpenType: Key Navigation
+<br>29456: GP - XmDSIGetChildPosition - Problem in Shutdown
+<br>29607: [Cell Editors] usability: ComboBoxCellEditor unusable on GTK
+<br>31009: ACC - I20030205 accelerators issues
+<br>31017: HANG - Hang on import external plugins
+<br>31267: Label and text box get the wrong order
+<br>31448: BIDI - Bidi enablement for StyledText - ArrayIndexOutOfBoundsException when highlighting a blank line
+<br>31513: CTabFolder's close box highlight gets clipped at bottom
+<br>31566: FontData "equals()" and "hashcode()" methods do not consider height of the the fontdata
+</blockquote>
+
+<h1>
+Eclipse Platform Build Notes<br>
+SWT</h1>
+SWT Build 2.1 028 - Thursday February 6, 2003
+
+<h2>
+<a NAME="Problem reports fixed"></a>Problem reports fixed</h2>
+<blockquote>
+23262: WebBrowser crashes when viewing Shockwave
+<br>25736: Memory leak while using OLE automation
+<br>29265: Control.setEnabled() not implemented properly on GTK
+<br>29593: Contextual menu too short near bottom of menu
+<br>29931: Mouse clicks are unreliable
+<br>30403: CTabItem close box shifts by 2 pixels when tab selected
+<br>30443: Menubar of SWT standalone applications is empty
+<br>30945: Change in mouse clicking behaviour makes FastViews unusable
+</blockquote>
+
+<h1>
+Eclipse Platform Build Notes<br>
+SWT</h1>
+SWT Build 2.1 027 - Wednesday February 5, 2003
+
+<h2>
+<a NAME="Problem reports fixed"></a>Problem reports fixed</h2>
+<blockquote>
+20755: TVT2: truncated text in dropdown for Dependencies tab in manifest editor
+<br>22759: Input method does not work on GTK/GTK2
+<br>27180: Unable to copy and paste in editing java file
+<br>27183: Mouse drag select produces crash
+<br>28419: Crash when closing shells
+<br>29777: DBCS: Can't drag a file into Run-time workbench
+<br>30212: Read only text widget : can't copy selection
+<br>30401: SWT standalone examples can't come to foreground
+<br>30452: Mouse gets warped to upper left corner of workbench window on actions
+<br>30500: "roaming" focus
+<br>30537: setSelection(allItems) not working on GTK
+</blockquote>
+
+<h1>
+Eclipse Platform Build Notes<br>
+SWT</h1>
+SWT Build 2.1 026 - Tuesday January 28, 2003
+
+<h2>
+<a NAME="Problem reports fixed"></a>Problem reports fixed</h2>
+<blockquote>
+14814: Button mnemonics are not shown properly on Windows XP
+<br>24333: DCR - Tree.getTopItem/setTopItem
+<br>24489: Tab cannot get focus when child-composite has scrollbar
+<br>24815: Cannot launch eclipse: javacore dump
+<br>29142: Hyperlinking from stackdump locks up Eclipse
+<br>29191: Tree - no gray check boxes on MAC (carbon2)
+<br>29426: DBCS:Copy/Paste DBCS failed between eclipse and gedit
+<br>29428: DBCS: Pasted string can't be shown correctly in Search dialog
+<br>29910: Checkbox not displayed until table scrolled
+<br>29966: No more handles on startup
+</blockquote>
+
+<h1>
+Eclipse Platform Build Notes<br>
+SWT</h1>
+SWT Build 2.1 025 - Tuesday January 21, 2003
+
+<h2>
+<a NAME="Problem reports fixed"></a>Problem reports fixed</h2>
+<blockquote>
+25030: (BBAWT) Image Analyzer fails to load a .png file
+<br>25359: RuntimeExceptions thrown from OleListener.handleEvent crash VM
+<br>27099: StyledText - Change CTRL key bindings to MOD1
+<br>27369: No more handles error
+<br>27822: Package Explorer allways centers opened file
+<br>28062: Text field in dialog doesn't get focus
+<br>28743: Trying to see test hiearchy freezes eclipse [JUnit]
+<br>28745: Esc does not cancel tracker
+<br>28967: [Editor Mgmt] no close button on last editor when editors drop-down is active
+<br>29427: DBCS: Can't input DBCS characters in Search dialog
+<br>29496: Cut & paste does not work in dialog text fields
+<br>29503: DBCS:Can't sort by clicking "Description" on "Task View"
+<br>29599: DBCS: upper bar character will be padded
+<br>29608: DBCS: Selected DBCS Classpath can't be shown
+<br>29611: DBCS:Can not input Hangul(Korea font)
+<br>29612: DBCS:Browse function of "Export" doesn't work
+<br>29614: DBCS: Unable to get "Import" contents location with "Browse" button
+<br>29664: SWT Styled Text Wrapping Doesn't Use Font Size Correctly
+<br>29685: DBCS: Candidate Selection Window will be disappeared at DBCS composition
+<br>29730: RowLayout.computeSize provides wrong parameter to layoutVertical
+</blockquote>
+
+<h1>
+Eclipse Platform Build Notes<br>
+SWT</h1>
+SWT Build 2.1 024 - Tuesday January 14, 2003
+
+<h2>
+<a NAME="Problem reports fixed"></a>Problem reports fixed</h2>
+<blockquote>
+21063: Can't drop views over some widgets
+<br>21561: Keyboard navigation in tree widgets on Linux
+<br>25619: OleControlSite event listener problem
+<br>25843: Info pops do not work for Red Hat 8.0.
+<br>27677: [Key Bindings] ctrl-f7 not working
+<br>28879: [Navigator] right-clicking a file doesn't allow me to open it
+<br>29208: Gtk directory dialog behaves like a file dialog
+<br>29252: Accelerators are not disabled when the toolbars and menus are on GTK
+<br>29302: Slider and Scrollbar handle many boundary cases wrong in set* methods
+<br>29334: Make javadoc available for download
+<br>29408: Invoking List.select(*) before open() does not select correct item
+</blockquote>
+
+<h1>
+Eclipse Platform Build Notes<br>
+SWT</h1>
+SWT Build 2.1 023 - Tuesday January 7, 2003
+
+<h2>
+<a NAME="Problem reports fixed"></a>Problem reports fixed</h2>
+<blockquote>
+24283: Default button in the dialog get the enter when typing in japanese
+<br>25486: Eclipse fails with 'no free callback slot'
+<br>26057: StyledText - cleanup passing around of fontdata
+<br>26079: Use PfLoadMetrics() to speed up text extenting
+<br>27869: StyledText overuse of Font.getFontData
+<br>28286: BBAWT: Incorrect palette/color returned on 32-bit true color display
+<br>28382: Extra separator line drawn in emulated CoolBar
+<br>28498: Help menu is confused
+<br>28607: Progress bar doesn't finish in PDE import wizard
+<br>28658: No context menu in perspective bar
+<br>28683: Ctrl-Click in TreeView loses selection
+<br>28701: Method "assert" declared in org.eclipse.swt.tests.junit.StyledTextContentSpec
+<br>28719: Scrolling in Welcome editor is not 'live'
+<br>28812: Mouse cursor changes to arrow after hovering a hyperlinked indentifier
+<br>28833: Eclipse no longer responds to 'Quit' AppleEvent
+<br>28835: Cursor doesn't change to arrow shape when over text scrollbars
+<br>28991: TabFolder.computeSize is grows each time is it called
+<br>29017: ScrolledComposite always makes it's content bigger on resize
+</blockquote>
+
+<h1>
+Eclipse Platform Build Notes<br>
+SWT</h1>
+SWT Build 2.1 022 - Tuesday December 17, 2002
+
+<h2>
+<a NAME="Problem reports fixed"></a>Problem reports fixed</h2>
+<blockquote>
+21409: IllegalArgumentException when editing Java source
+<br>21993: Can't change font sizes
+<br>22305: Launch configuration pane gets visually messed up and ref...
+<br>23830: Out-of-box experience with the Mac.
+<br>23843: Chevrons show up in default layout of Java perspective
+<br>23844: Label doesn't wrap text initiallly
+<br>23850: Missing scrollbar in List
+<br>24437: KeyListeners don't get called
+<br>26322: NPE in Font Dialog
+<br>26331: Wrapped Labels - second line cut off
+<br>26587: Navigate -> Go To Type goes to wrong shell on Mac
+<br>27997: Color dialog crashes Eclipse
+<br>28288: [Editor Mgmt] Editor pane out of sync with views and tabs
+<br>28361: ToolItem leaks Images (?)
+<br>28524: Inconsistent behaviour of tab in password fields
+</blockquote>
+
+<h1>
+Eclipse Platform Build Notes<br>
+SWT</h1>
+SWT Build 2.1 021 - Friday December 13, 2002
+
+<h2>
+<a NAME="Problem reports fixed"></a>Problem reports fixed</h2>
+<blockquote>
+27526: Color selection dialog takes a long time to display in 8-bit mode
+<br>27862: Tree.setSelection() takes > 1 second
+<br>28035: Different callback behavior on Windows and Mac with Combo widget
+</blockquote>
+
+<h1>
+Eclipse Platform Build Notes<br>
+SWT</h1>
+SWT Build 2.1 020 - Tuesday December 10, 2002
+
+<h2>
+<a NAME="Problem reports fixed"></a>Problem reports fixed</h2>
+<blockquote>
+24112: Keyboard shortcuts defined as Ctrl-Shift-x don't work
+<br>24436: Entering Asterisk crashes Eclipse
+<br>26506: Importing External Plug-ins is slow
+<br>27031: en_US.UTF-8 locale not supported on Motif
+<br>27410: [SWT Examples] Arrow buttons won't resize for 10x10,50x50,100x100
+<br>27422: [SWT Examples] Progress bar reverts to 'black' color after Selection slider repositioning
+<br>27501: Selection not correctly updated on right click on a tree
+<br>27524: [SWT Examples] Table item foreground color changes fail after first attempt
+<br>27644: Dismissing open type dialog with Escape crashes Eclipse
+<br>27704: Remove csh build dependency
+<br>27710: Entry point not found SetLayout in GDI32
+</blockquote>
+
+<h1>
+Eclipse Platform Build Notes<br>
+SWT</h1>
+SWT Build 2.1 019 - Tuesday December 3, 2002
+
+<h2>
+<a NAME="Problem reports fixed"></a>Problem reports fixed</h2>
+<blockquote>
+19080: Chaff in table tree of property sheet
+<br>20318: [StyledText] print selection prints whole page (at least in <=f2)
+<br>26563: Crash in Carbon native CopyMask
+<br>26731: Attempting to create a view plug-in project crashes
+<br>27181: Sleak - instrumentation not done on GTK and Motif
+<br>27305: EC: CLabel keeps background colour after gradient is used
+<br>27411: [SWT Examples] SWT.FLAT has no effect for buttons
+<br>27442: Mouse click outside horizontal scroll bar does nothing
+</blockquote>
+
+<h1>
+Eclipse Platform Build Notes<br>
+SWT</h1>
+SWT Build 2.1 018 - Tuesday November 26, 2002
+
+<h2>
+<a NAME="Problem reports fixed"></a>Problem reports fixed</h2>
+<blockquote>
+15031: Font parsing failed
+<br>17237: Progress monitor flickers
+<br>18172: Sig11 from GTK
+<br>19530: Saving locks resizing in second perspective
+<br>19735: No space between longest item in menu and accel keys
+<br>20953: StyledText - tilde problem with french keyboard (2000,NT,XP) on R2.0
+<br>21626: TableItem.getImageBounds fails on Motif (Emulated Widget)
+<br>24872: Splash screen does not show at startup
+<br>24969: JP GP: showing Java-Editor pref. page with editor open
+<br>25053: Cannot use the pull down menu in GTK
+<br>25335: Scrollbars too small on variable selection dialog
+<br>25653: DCR: StyledText do not activate the default button
+<br>26179: Can't select items in a checkbox tree without toggling checked state
+<br>26353: Infopop broken on solaris
+<br>26362: StyledText - investigate necessary state changes between handleTextChanging and handleTextChanged
+<br>26733: Eclipse crashes when GTK theme is changed
+<br>26804: Gtk Label widget has focus decoration drawn too big
+<br>26935: Exception in StyledText with WRAP flag.
+<br>26997: StyledTextRenderer: creates too many Strings
+<br>27016: Default "Open" action not working in Navigator tree view
+</blockquote>
+
+<h1>
+Eclipse Platform Build Notes<br>
+SWT</h1>
+SWT Build 2.1 017 - Tuesday November 19, 2002
+
+<h2>
+<a NAME="Problem reports fixed"></a>Problem reports fixed</h2>
+<blockquote>
+21251: Crash in org.eclipse.swt.internal.gtk.OS.pango_layout_set_font_description
+<br>24835: GTK: Multiple selection and right click in tree
+<br>25741: StyledText does not set the background and foreground color in the OS
+<br>25803: StyledText should use new Font API
+<br>26004: Removing a Text field leaves behind crud
+<br>26008: [StyledText] setTopPixel limits argument to logical line count
+<br>26121: Cannot launch eclipse #2: javacore dump
+<br>26151: SWT widget org.eclipse.swt.widgets.Sash is not properly constrained when in HORIZONTAL mode
+<br>26258: Accented characters bug in editors reinvented
+<br>26367: NPE when debugging as java application
+<br>26414: Accelerators don't work on aix
+<br>26419: StyledText - print pages causes walkback
+<br>26421: List hangs on GTK
+<br>26434: PrinterData startPage/endPage invalid when page >32767
+</blockquote>
+
+<h1>
+Eclipse Platform Build Notes<br>
+SWT</h1>
+SWT Build 2.1 016 - Tuesday November 12, 2002
+
+<h2>
+<a NAME="Problem reports fixed"></a>Problem reports fixed</h2>
+<blockquote>
+23935: Text widget with Tree parent does not lose focus
+<br>23997: Tracker moves mouse cursor
+<br>24493: Cant type braces in java editor with italian keyboard in 2.1m1
+<br>25732: MLEAK: Resize eclipse, usually 4K allocated
+<br>25775: Combo doesn't get restored after minimize/restore
+<br>25781: Some change broke compare with patch
+<br>25797: GTK: Selection Index not preserved after Combo item removal
+<br>25986: No source for SWT plugin imported as binary
+<br>25989: Radion buttons are not mutually exclusive in same composite
+</blockquote>
+
+<h1>
+Eclipse Platform Build Notes<br>
+SWT</h1>
+SWT Build 2.1 015 - Tuesday November 5, 2002
+
+<h2>
+<a NAME="Problem reports fixed"></a>Problem reports fixed</h2>
+<blockquote>
+4607: Missing API for Font(Display display, FontData fd[]) (1G93TPM)
+<br>14956: StyledText - printing should support pagination, headers, and footers
+<br>21695: Crash when starting eclipse on Solaris8 with java 1.4
+<br>22052: Launch configuration dialog loses workspace data dir
+<br>23049: Cannot write Swedish characters (������) in editor
+<br>24273: GP -Tree removeAll reboot windowsXp
+<br>24359: MenuItems with style SWT.RADIO should handle mutual exclusion on selection
+<br>24757: GTK: X pointer grab when resizing a table column
+<br>25212: GPF synchronizing files with new Tree implementation
+<br>25253: Preference dialog doesn't display last preference page
+<br>25399: Drag and drop crashes Eclipse
+<br>25545: StyledText - printing ignores end page
+</blockquote>
+
+<h1>
+Eclipse Platform Build Notes<br>
+SWT</h1>
+SWT Build 2.1 014 - Tuesday October 29, 2002
+
+<h2>
+<a NAME="Problem reports fixed"></a>Problem reports fixed</h2>
+<blockquote>
+10090: Cannot see Combo-box selection in DBCS locale
+<br>12078: SWT exception when running on debian woody on KDE using the motif build
+<br>14448: Setting the accelerator of a menu item gives highlight to tool bar entries
+<br>17361: Tree flickers on update
+<br>17428: Internal Error (SWT) opening a new perspective by double-clicking
+<br>20075: Infopop exhibits strange behaviour under Motif
+<br>21066: Switch editors/views/perspectives windows have scrollbars
+<br>21121: [External Tools] Configuration default selection could be better on GTK
+<br>21375: Reproducible JVM termination when using WebDAV.
+<br>21656: GTK: disposing all the columns in table.getColumns fails
+<br>22038: Wrong widget scrolls in Java Browsing perspective.
+<br>22120: Excessive redraw in debug view
+<br>22252: Project properties - java build path screen shows artifacts
+<br>22371: Invalid selection items in working set
+<br>22527: Working set dialog only selects projects
+<br>22743: Type dialog horizontal scroll too small to read contents
+<br>23657: Problems implementing MenuItem.setText (worked around for English)
+<br>23789: GTK tree display problem
+<br>23845: Spurious scrollbar drawn on other controls
+<br>24150: Shift-Tab does not shift left
+<br>24257: Native exception when trying to export preferences
+<br>24314: FileDialog doesn't allow to navigate into packages
+<br>24372: StyledText - StringIndexOutOfBoundsException in ControlExample
+<br>24426: StyledText - investigate replacing caretLine with simpler concept
+<br>24504: StyledText - showSelection when selection RtoL problem
+<br>24619: DCR - State mask not set in MouseTracker.mouseHover
+<br>25016: [Viewers] Double click not working when item already selected
+<br>25149: StyledText - WrappedContent API does not check line index range
+</blockquote>
+
+<h1>
+Eclipse Platform Build Notes<br>
+SWT</h1>
+SWT Build 2.1 013 - Tuesday October 22, 2002
+
+<h2>
+<a NAME="Problem reports fixed"></a>Problem reports fixed</h2>
+<blockquote>
+20377: StyledText - SWT.WRAP style and widthHint specification
+<br>22986: SWT Controls Combo box Colors selection tool does not change foreground color
+<br>24728: StyledText Enter/Ctrl-Enter VerifyEvent inconsistencies
+<br>24805: ComputeSize issue
+</blockquote>
+
+<h1>
+Eclipse Platform Build Notes<br>
+SWT</h1>
+SWT Build 2.1 012 - Tuesday October 15, 2002
+
+<h2>
+<a NAME="Problem reports fixed"></a>Problem reports fixed</h2>
+<blockquote>
+16657: [Open Modes] Search results doesn't respond to double click
+<br>17334: Icon missing in check box tree
+<br>17918: Tree widgets with multiple entries
+<br>18902: PgUp key causes items to be selected in tree widget under GTK
+<br>20258: [CVS] Esc key doesn't work on Commit Dialog
+<br>21367: Display problem in the properties view
+<br>21438: Java core dump in gtk_ctree_get_node_info
+<br>24560: Ctrl+shift doesn't traverse word
+<br>24676: StyledText - double click word select and caret placement
+<br>24677: 32 bit image fails with a certain mask
+<br>24702: WinCE: Image 32bits is incorrect
+</blockquote>
+
+<h1>
+Eclipse Platform Build Notes<br>
+SWT</h1>
+SWT Build 2.1 011 - Tuesday October 8, 2002
+
+<h2>
+<a NAME="Problem reports fixed"></a>Problem reports fixed</h2>
+<blockquote>
+4822: Group size doesn't seem to consider group name (1GJYIWB)
+<br>10019: Right clicking in a list box should select before popping up menu
+<br>17160: Task List: missing icon
+<br>18842: Cheese when scrolling after deleting row in table
+<br>19773: Coolbar icons in Windows XP with Luna theme are not vertically aligned
+<br>20094: Layout problems using StyledText with word wrap in a ScrolledComposite
+<br>23978: Horizontal scrollbars in tables and trees don't scroll page-wise
+<br>24225: DragSourceAdapter incorrect JavaDoc
+<br>24358: Incomplete JavaDoc on MenuItem.setText
+</blockquote>
+
+<h1>
+Eclipse Platform Build Notes<br>
+SWT</h1>
+SWT Build 2.1 010 - Tuesday October 1, 2002
+
+<h2>
+<a NAME="Problem reports fixed"></a>Problem reports fixed</h2>
+<blockquote>
+10459: I can't run eclipse
+<br>19148: Tooltip pops up underneath code completion alternatives in F2
+<br>20672: Shift+F10 has wrong keyCode
+<br>21287: Uncaught exception hanging Eclipse
+<br>22615: [Dialogs] Native ProgressBar look does not match look of AnimatedProgress
+<br>22645: StyledText - cheese when typing in SWT.SINGLE mode
+<br>23645: Disabled default button can still be reached pressing ENTER
+<br>23846: Initial font height of text field is wrong
+<br>23851: Initial text in Text control is scrolled out of visible area
+<br>23910: CTabFolder selected tab loses synch with its contents
+<br>23936: NPE in ControlExample
+<br>23947: Menu implementation prevents KeybindingMenu from working correctly
+<br>23975: No keyboard shortcuts displayed in menu items
+<br>23976: Function keys must be pressed twice
+<br>24000: No scrollwheel support for Mac OS X
+<br>24055: No more callback exception hang Eclipse
+<br>24088: File chooser for OSX returns wrong path
+<br>24106: Table Column Resizable Doesn't work if you click on Column itself
+<br>24137: Top item on popup is often invisible
+<br>24139: Copy causes exception
+<br>24141: Keyboard not functional in editors (mac os x)
+</blockquote>
+
+<h1>
+Eclipse Platform Build Notes<br>
+SWT</h1>
+SWT Build 2.1 009 - Tuesday September 24, 2002
+
+<h2>
+<a NAME="Problem reports fixed"></a>Problem reports fixed</h2>
+<blockquote>
+7435: ArrayIndexOutBoundsException occurs when using Solaris through remote terminal
+<br>15146: Printing support under Linux?
+<br>18483: IE6 causes conflict with SWT.APPLICATION_MODAL on Windows 98
+<br>20461: WinCE - Wait cursor does not show up
+<br>20958: Eclipse crashes when pasting PDF text into a Java file editor
+<br>21416: Gtk+ launcher
+<br>22121: Eclipse crashes when pasting URL in Java-code
+<br>23007: [Navigator] Import of workspace folder into parent
+<br>23744: Device.getFontList() uses wrong constant name
+<br>23745: Wrong flag used in Device.getFontList().
+<br>23748: Input group is hardcoded as 1 in PhWindowQueryVisible()
+<br>23753: Groups don't look like the platform
+<br>23754: Label.setFont() needs to check "text != null"
+<br>23766: Labels with image only have extra space on GTK
+<br>23795: ControlExample: Image Label leaves cheese when resized
+<br>23807: Display class needs to pick better default fonts.
+<br>23864: CoolBar - Plus 2, Minus 2 problem
+<br>23884: WinCE - OS.InitCommonControlsEx fails with flag DATETIMEPICK_CLASS
+<br>23898: Group.setBackground() don't work on Gtk
+<br>23899: CTRL + Mouseclick
+<br>23974: Use native ComboBox
+</blockquote>
+
+<h1>
+Eclipse Platform Build Notes<br>
+SWT</h1>
+SWT Build 2.1 008 - Tuesday September 17, 2002
+
+<h2>
+<a NAME="Problem reports fixed"></a>Problem reports fixed</h2>
+<blockquote>
+4637: TreeEditor example does not show how to use double click (1GCP6OH)
+<br>4656: Pop-up menu not showing for Composite (1GENYM0)
+<br>4710: Remaining Javadoc problems (1GF088W)
+<br>4730: Support for lesstif on Linux
+<br>4733: Issues with Win32 GDI setBkMode(), and similar things in Motif (1GFPGK3)
+<br>4796: DCR: keyboard support for move/resize (accessibility issue)
+<br>5900: CheckboxTableViewer does disable correctly
+<br>10532: DCR: Table.setSelection(int, int) -- order matters
+<br>12048: NPE exiting workspace
+<br>16700: Coolbar tab order is backwards
+<br>17494: Veronika needs to check her javadoc
+<br>19256: SIP event
+<br>19736: Tooltips for long entries in code assist pop behind code assist
+<br>21126: Print Dialog Is Not Modal, Resulting in Unpredictable Workbench Behavior
+<br>21620: FontData.setLocale() crashes workbench
+<br>22189: Win32 GDI Resource Leak in WrappedContent.java
+<br>22210: Photon:Removing item from Combo does not remove the text(BBAWT)
+<br>22364: Incorrect height of widget in TextViewer
+<br>22490: Background color of Graphical Editors is always black.
+<br>22534: No way to turn border off for linux text widget
+<br>22564: Cannot draw transparent PNG files properly
+<br>22577: List.setSelection(String[]) infinite loop
+<br>22839: When swt window in focus palettes of other windows hosed, and vise versa
+<br>22862: StyledText - Tab does not tab out of non-editable
+<br>22926: Clipboard copy/paste is cut/paste on Windows 98
+</blockquote>
+
+<h1>
+Eclipse Platform Build Notes<br>
+SWT</h1>
+SWT Build 2.1 007 - Tuesday September 10, 2002
+
+<h2>
+<a NAME="Problem reports fixed"></a>Problem reports fixed</h2>
+<blockquote>
+10050: StyledText - Change selection color when changing background color
+<br>14637: StyledText - copy-from text edit feature
+<br>16009: Eclipse's toolbar buttons' icon in black and upside down
+<br>17793: Motif FileDialog often does not use reasonable default directory
+<br>20179: Coolbar item clipped on bottom edge with SWT.BORDER style
+<br>21185: GTK: Label positioning incorrect when style bit used and bounds set(BBAWT)
+<br>22079: StyledText - BidiUtil.isBidiPlatform returns true when not running with bidi locale
+<br>22114: * key expands TableTree but does not send SWT.Expand event
+<br>22115: MessageDialog does not wrap message
+<br>22158: getItem() crashes eclipse called with index 0
+<br>22647: Variant class incorrectly marshals VT_BOOL values
+<br>22746: Text cut off in GTK in TitleAreDialog
+<br>22868: Eclipse hangs while creating a shell from ControlExample
+<br>22874: 2104: Converter contains references to Converter.class
+<br>22916: CCombo not dropping down list properly
+<br>22918: Table.getItem(Point) throws ArrayIndexOutOfBounds
+<br>22959: Dragging over multiple stacked trees uses invisible tree for drop target
+<br>22978: Motif FileDialog ignores SWT.MULTI bit
+<br>23003: Xcopyplane requires 11 args but HP-UX JRE can only handle 10
+<br>23028: EC: Tab un-indent does not work
+<br>23061: 'Back' key does not delete character on Smartphone 2002
+<br>23178: Eclipse Fails to Start First Time
+<br>23285: Linux Motif has become extremely slow
+</blockquote>
+
+<h1>
+Eclipse Platform Build Notes<br>
+SWT</h1>
+SWT Build 2.1 006 - Tuesday August 27, 2002
+
+<h2>
+<a NAME="Problem reports fixed"></a>Problem reports fixed</h2>
+<blockquote>
+5678: TVT: Unable to open Filter dialog on Win98 if another view is undocked (free floating)
+<br>12878: Combo setItems removes setText
+<br>13024: Two tooltips displayed on tree
+<br>14923: Show Text Hover toolbar item in wrong place
+<br>16333: Accessibility - tab key in dialog boxes
+<br>20321: Multiple opened ApplicationWindows with statuslines show incorrect display/event handling
+<br>22231: Pressing ENTER in a text field no longer performs OK in dialogs
+<br>22659: Function key events are often lost
+<br>22661: StyledText - Shift+Alt+<character> inserts character
+<br>22721: Cannot use keyboard to toggle checkboxes
+<br>22737: Mouse Capture on Motif causes Context Menu not to work
+<br>22825: Consecutive vertical cursor movement commands don't retain column offset
+</blockquote>
+
+<h1>
+Eclipse Platform Build Notes<br>
+SWT</h1>
+SWT Build 2.1 005 - Tuesday August 20, 2002
+
+<h2>
+<a NAME="Problem reports fixed"></a>Problem reports fixed</h2>
+<blockquote>
+4554: Combo selection scrolls for certain fonts (1G1AD9Y)
+<br>4577: Ctrl+Backspace & Ctrl+del have the same key code and key event (1G54RAJ)
+<br>4685: Variables View re-positions on each step (1GETE8F)
+<br>10091: MessageBox loses activation
+<br>10976: Workbench windows don't reopen correctly in Dual Monitor environments
+<br>14942: Unexpected KeyDown event after pressing non existing menu mnemonic
+<br>18705: Too much flashin in Control Example
+<br>21829: API needed to allow CCombo to display its list at the prefered width
+<br>22443: OLE - org.eclipse.swt.internal.ole.win32.CONTROLINFO has a useless field 'filler'
+<br>22457: Win32 org.eclipse.swt.widgets.Combo computeSize() is wrong
+<br>22507: Modal dialog does not prevent adjusting of table headers in parent.
+</blockquote>
+
+<h1>
+Eclipse Platform Build Notes<br>
+SWT</h1>
+SWT Build 2.1 004 - Tuesday August 13, 2002
+
+<h2>
+<a NAME="Problem reports fixed"></a>Problem reports fixed</h2>
+<blockquote>
+4737: Redraw problem in table (1GFW2PE)
+<br>9075: Tooltips only partially displayed in Hoverhelp.java example
+<br>15610: StyledText - Double-Click-Drag doesn't work, works on Text
+<br>16990: ToolBar does not send MouseHover events
+<br>20632: Polish national fonts
+<br>20792: sometimes resize callback is not sent to the shell when the shell is not visible
+<br>20815: Menus not displayed on SmartPhone 2002
+<br>21268: StyledText - Ctrl+Shift+J inserts line
+<br>21272: StyledText does not support setting selection with caret on the left
+<br>21921: Emulated Table setTopIndex fails and causes NPE when adding an item afterwards
+<br>21933: TableColumn does not listen to ControlEvents
+<br>22004: no keyboard shortcuts for switching between pages of MultiPageEditorPart
+<br>22188: StyledText - only first character of a line displayed
+<br>22204: Photon: Text.selectAll() does not select all the text(BBAWT)
+<br>22254: Command H is not mapped properly
+<br>22365: SWT_AWT does not compile under JDK 1.4
+</blockquote>
+
+<h1>
+Eclipse Platform Build Notes<br>
+SWT</h1>
+SWT Build 2.1 003 - Tuesday August 6, 2002
+
+<h2>
+<a NAME="Problem reports fixed"></a>Problem reports fixed</h2>
+<blockquote>
+4521: Display.syncExec or Display.asyncExec can block processing of native events (1G03DF0)
+<br>20144: Enter key not working in packages view
+<br>21179: Step filter in-place text editor invisible
+<br>21243: Scroll lock inserts a character during incremental search on GTK
+<br>21338: Accents and � don't work in editor using gtk
+<br>21472: keyPressed event ignored by org.eclipse.swt.widgets.Text for ENTER key
+<br>21696: StyledText - RTF transfer codepage encoding
+<br>21698: StyledText - RTF writer performance improvement
+<br>21834: Coolbar - deleting items corrupting layout
+<br>22004: No keyboard shortcuts for switching between pages of MultiPageEditorPart
+<br>22025: Motif: Unexplained termination running BBAWT JUnit tests
+<br>22036: MOTIF: Appearance issue with Combo
+<br>22060: StyledText - bidi - ArrayIndexOutOfBoundsException
+</blockquote>
+
+<h1>
+Eclipse Platform Build Notes<br>
+SWT</h1>
+SWT Build 2.1 002 - Tuesday July 30, 2002
+
+<h2>
+<a NAME="Problem reports fixed"></a>Problem reports fixed</h2>
+<blockquote>
+4578: Ctrl+J & Ctrl+Enter have the same key code (1G54RJJ)
+<br>4816: TabItem displays & (1GJL704)
+<br>6888: Combo sends ModifyEvent on setItems
+<br>9025: OLE, StyledText widget and WinCE
+<br>19632: Tracker should adjust cursor on mouse not down, not on MENU
+<br>19985: StyledText - Bulleting proofing RTF copy function
+<br>20691: StyledText - bidi - Win2K/XP support
+<br>20746: Inconsistent @param in Javadoc for TableItem.setGrayed(boolean)
+<br>21313: Combo.getItem wrong error thrown
+<br>21423: GTK: GPF in Shell.setVisible()
+<br>21500: GTK: SWT.Activate and SWT.Deactivate events not fired when Shell with NO_TRIM used as its style bit
+<br>21526: Shell.computeTrim does not include menu bar
+<br>21563: Mnemonics give focus to the label on GTK
+<br>21564: GTK: Text of Button(with style bit SWT.CHECK) does not show up correctly
+<br>21573: TableTreeItem should have get/setGrayed() methods like TableItem
+<br>21601: getLineCount() method for Text widget does not work on Motif
+<br>21623: List.setSelection (int start, int end) fails on Motif
+<br>21653: WinCE/SH4: Arrow keys don't generate key events
+<br>21702: Debug Display view error msg to console on GTK
+<br>21706: BidiUtil in win32 has Class.forName() usage
+<br>21805: event.character = 0 for all Ctrl-<alpha> on QNX 6.2
+<br>21937: COMObject leakage on OleControlSite
+<br>21958: ControlExample FileDialog does not filter correctly
+<br>21964: GTK: Adding an item to Combo changes the selection index
+<br>21967: GTK: Setting selection index to -1 for a Combo throws an exception
+<br>21969: List.getSelectionIndex bug
+<br>21976: GTK: Combo.getSelectionIndex() changes when an item is removed
+</blockquote>
+
+<h1>
+Eclipse Platform Build Notes<br>
+SWT</h1>
+SWT Build 2.1 001 - Tuesday July 23, 2002
+
+<h2>
+<a NAME="Problem reports fixed"></a>Problem reports fixed</h2>
+<blockquote>
+4428: Table - Grid lines not drawn correctly (1FE4K5U)
+<br>4451: Shell: setDefaultButton, default button cannot be reset to null (1FGLS6M)
+<br>4489: MouseUp fired for button 1 when button 1 is still pressed (1FODDP4)
+<br>4511: Pane title update flashes tool bar buttons (1FUUR7A)
+<br>4524: CTRL sequences not handled gracefully by TextEditor (1FVSBTS)
+<br>4544: CTRL combination not handled as accelerators when Caps are locked (1FZQDGR)
+<br>4590: VerifyEvent values ignored (1G7G5Y3)
+<br>4626: TableTree: Two selection events generated for each checkbox selection (1GBRSLM)
+<br>4642: DirectoryDialog does not support / on windows (1GD41DZ)
+<br>4648: MenuItem.setEnabled() always causes a redraw (1GDDCN2)
+<br>4786: FontDialog should give access to color setting (1GIEFBD)
+<br>4861: Key state for toolbar items (1GL54A0)
+<br>5935: StyledText - up/down arrow behavior wrt varying line lengths
+<br>6775: Radio button setSelection changes focus
+<br>9859: Combo widget doesn't fire keyPressed or keyReleased for Enter key
+<br>11868: StyledText: text selection with key 'arrow down' does not include last line
+<br>11994: StyledText - replace getXAtOffset(caretOffset) with caret.getLocation().x
+<br>12178: StyledText - move StyledTextRenderer#bidiTextWidth to DisplayRenderer
+<br>12181: StyledText - mixing text width/caret position is confusing
+<br>13944: DCR - Need cut/copy/paste routines on Combo
+<br>14672: Combo and Scale setBackground does not refresh
+<br>14799: Window manipulations block other threads from executing
+<br>15088: StyledText - getTopIndex semantics undefined when no line fully visible
+<br>15554: DCR - alignment in a text widget
+<br>15559: JAWS reads the parent window for dialog shells
+<br>15728: Packages view selection always one too high
+<br>16110: StyledText scroll not working with PageUp/Down keys.
+<br>16205: StyledText - Tab does not tab out of read-only
+<br>16402: Working set dialog: table columns have incorrect size
+<br>16777: Busy cursor lost over progress indicator edges
+<br>16986: JavaViewer example should remember path
+<br>17191: SWT Error in JUnit view
+<br>17252: Accelerator labels: Ctrl-Shift-A, Shift-Ctrl-A or Shift-Ctl-A?
+<br>17279: Extra CoolBar row created when switching perspectives.
+<br>17370: Combo box flashes to much when resizing dialog.
+<br>17993: Find/Replace shouldn't replace typed entry with value from history
+<br>18253: Coolbar - disposing items not honoring setRedraw = false
+<br>18308: Ctrl+SHIFT+@ does not call the listener.
+<br>18429: ScrolledComposite with LayoutManager is VERY slow in iPAQ
+<br>18570: Combo flashes by resizing
+<br>19380: Listboxes flash as preferences dialog is resized
+<br>19434: ToolItem does not need to check for TOGGLE
+<br>19568: {} on a german keyboard [swt-carbon]
+<br>19615: StyledText - example Text Editor bug in copy/paste
+<br>19630: Coolbar - odd dispose behavior
+<br>19815: JRE crashes using error log and progress bar.
+<br>19964: Coolbar - can "lose" items when platform widget wraps
+<br>20159: Right-clicking on coolbar grabber causes strange behavior
+<br>20183: Motif : Coolbar preferred size is too small width wise
+<br>20190: CoolBar problems on Windows XP with Manifest
+<br>20339: Hitting spacebar does not press currently focused button
+<br>20583: Segfault when control tries to dispose of itself under Motif
+<br>20683: [ExternalTools] F3 (and F2) crashes the JVM when trying to cancel an external tool on linux-gtk
+<br>20690: StyledText - bidi - should force font script when keyboard language changed
+<br>20705: Cursor Keys don't work in Dialogs
+<br>20722: GTK TableColumn#pack does not work if no header
+<br>20788: A composite is being mysteriously disposed for no reason
+<br>20846: WIN32: 'Combo.indexOf' always returns -1 for empty string
+<br>20893: Bad size for Text widget when flag READ_ONLY is set (Photon)
+<br>20904: SWT exception on LayoutExample (Photon)
+<br>20950: GTK: F1 help does not work for menu items.
+<br>20956: Emulated CoolItem do not respect SWT.DROP_DOWN flag
+<br>21030: StyledText - during cut if clipboard copy fails do not delete text
+<br>21096: Properties accelerator missing ENTER
+<br>21122: Emacs: Accelerators not shown in menus under GTK
+<br>21154: StyledText - BIDI - Bad effect of RLO unicode character
+<br>21192: UnsatisfiedLinkError thrown when pressing a hardware key
+<br>21215: [Help] F1 Help does not close menu on GTK
+<br>21223: StyledText - Cursor should stop blinking when moving
+<br>21268: StyledText - Ctrl+Shift+J inserts line
+<br>21368: GTK: GC.drawImage() fails when scaling an image
+<br>21371: SWTError while using Navigator->Goto->Resource
+<br>21378: GTK: Shell event's doit flag ignored when shellClosed() is called
+<br>21412: Paste with accelator key doesn't work
+<br>21413: CoolBar computeSize fails on XP
+<br>21415: Javadoc for CLabel.setBackground has typos
+<br>21440: Unable to display Today screen when SWT app running on WinCE
+<br>21449: GTK: Calling Text.setSelection() causes GPF
+<br>21456: GTK: Cannot type in Text widget contained in Shell which has style bit as NO_TRIM
+<br>21484: Shift-Tab does nothing on GTK
+<br>21523: StyledText - caret does not move when widget shell is not open
+<br>21524: StyledText - NPE when typing text and caret is null
+<br>21596: StyledText - initial bidi caret position wrong when widget empty
+<br>21598: StyledText - setFont enables caret when it was disabled
+</blockquote>
+
+<h1>
+Eclipse Platform Build Notes<br>
+SWT</h1>
+SWT Build 2.0 052 - Wednesday October 30, 2002 (2.0.2 stream)
+
+<h2>
+<a NAME="Problem reports fixed"></a>Problem reports fixed</h2>
+<blockquote>
+10459: I can't run eclipse
+<br>24693: org.eclipse.swt.graphics.GC.drawString() fails to draw euro
+<br>24869: GP - Eclipse crashed when entering invalid file name in FileDialog
+</blockquote>
+
+<h1>
+Eclipse Platform Build Notes<br>
+SWT</h1>
+SWT Build 2.0 050 - Wednesday October 16, 2002 (2.0.2 stream)
+
+<h2>
+<a NAME="Problem reports fixed"></a>Problem reports fixed</h2>
+<blockquote>
+24542: [DND] Crash when drag&drop on the Package Explorer
+</blockquote>
+
+<h1>
+Eclipse Platform Build Notes<br>
+SWT</h1>
+SWT Build 2.0 049d - Monday August 26, 2002 (2.0.1 stream)
+
+<h2>
+<a NAME="Problem reports fixed"></a>Problem reports fixed</h2>
+<blockquote>
+22729: Permissions.properties missing from the build script
+<br>22779: Eclipse linux-motif GPFs on exit on J9
+</blockquote>
+
+<h1>
+Eclipse Platform Build Notes<br>
+SWT</h1>
+SWT Build 2.0 049b - Wednesday August 21, 2002 (2.0.1 stream)
+
+<h2>
+<a NAME="Problem reports fixed"></a>Problem reports fixed</h2>
+<blockquote>
+22448: CoolBar - deleting first item in row does unnecessary collapse/expand of row
+<br>22561: Hover Help broken in 2.0.1 I20020815
+</blockquote>
+
+<h1>
+Eclipse Platform Build Notes<br>
+SWT</h1>
+SWT Build 2.0 049 - Wednesday August 14, 2002 (2.0.1 stream)
+
+<h2>
+<a NAME="Problem reports fixed"></a>Problem reports fixed</h2>
+<blockquote>
+22055: CoolBar - setWrapIndices causes rows to collapse/expand unnecessarily
+<br>22144: Coolbar - setSize not being honored after setWrapIndices API used
+<br>22320: Coolbar - delete item behavior problem
+</blockquote>
+
+<h1>
+Eclipse Platform Build Notes<br>
+SWT</h1>
+SWT Build 2.0 048 - Tuesday August 6, 2002 (2.0.1 stream)
+
+<h2>
+<a NAME="Problem reports fixed"></a>Problem reports fixed</h2>
+<blockquote>
+15559: JAWS reads the parent window for dialog shells
+<br>18253: Coolbar - disposing items not honoring setRedraw = false
+<br>19964: Coolbar - can "lose" items when platform widget wraps
+<br>21268: StyledText - Ctrl+Shift+J inserts line
+<br>21834: Coolbar - deleting items corrupting layout
+</blockquote>
+
+<h1>
+Eclipse Platform Build Notes<br>
+SWT</h1>
+SWT Build 2.0 047 - Monday June 17, 2002
+
+<h2>
+<a NAME="Problem reports fixed"></a>Problem reports fixed</h2>
+<blockquote>
+4772: Javadoc: Graphics constructors need to doc if device null (1GHSPUW)
+<br>14144: ScrollBars can't be made invisible on PocketPC
+<br>20265: F3. test C3. No new updates for Eclipse on HP.
+<br>20362: Coolbar cannot be traversed to
+</blockquote>
+
+<h1>
+Eclipse Platform Build Notes<br>
+SWT</h1>
+SWT Build 2.0 046 - Friday June 14, 2002
+
+<h2>
+<a NAME="Problem reports fixed"></a>Problem reports fixed</h2>
+<blockquote>
+16809: Clicking to close non-active editor doesn't have an affect
+<br>16939: DnD: Moving the mouse while dropping behaves strangely while dragging views
+<br>17190: No cell editor support
+<br>17563: Flat tool bar buttons
+<br>17621: Resource Patcher wizard - widgets not properly aligned
+<br>19089: No popup menu java editor ruler (Photon)
+<br>19243: Eclipse launchers have hardcoded j9 args
+<br>19244: Spacing between Table rows grows with number of rows
+<br>20006: X Pointer grab not released
+<br>20044: Unable to scroll license text using keyboard
+<br>20072: Workbench bounces when swtiching perspectives
+<br>20134: Eclipse CLOSES automatically, when i'm working in it
+<br>20184: Color javadoc could use reference to Device.getSystemColor()
+<br>20209: Hang due to OS locking
+<br>20354: GP when attempt to check out SWT from repository
+<br>20372: Tracker needs more javadoc
+</blockquote>
+
+<h1>
+Eclipse Platform Build Notes<br>
+SWT</h1>
+SWT Build 2.0 046 - Tuesday June 11, 2002
+
+<h2>
+<a NAME="Problem reports fixed"></a>Problem reports fixed</h2>
+<blockquote>
+16809: Clicking to close non-active editor doesn't have an affect
+<br>16939: DnD: Moving the mouse while dropping behaves strangely while dragging views
+<br>17190: No cell editor support
+<br>17563: Flat tool bar buttons
+<br>17621: Resource Patcher wizard - widgets not properly aligned
+<br>19089: No popup menu java editor ruler (Photon)
+<br>19243: Eclipse launchers have hardcoded j9 args
+<br>19244: Spacing between Table rows grows with number of rows
+<br>20006: X Pointer grab not released
+<br>20044: Unable to scroll license text using keyboard
+<br>20072: Workbench bounces when swtiching perspectives
+<br>20134: Eclipse CLOSES automatically, when i'm working in it
+<br>20184: Color javadoc could use reference to Device.getSystemColor()
+<br>20209: Hang due to OS locking
+<br>20354: GP when attempt to check out SWT from repository
+<br>20372: Tracker needs more javadoc
+</blockquote>
+
+<h1>
+Eclipse Platform Build Notes<br>
+SWT</h1>
+SWT Build 2.0 045 - Tuesday June 11, 2002
+
+<h2>
+<a NAME="Problem reports fixed"></a>Problem reports fixed</h2>
+<blockquote>
+15242: CoolBar - layout issues
+<br>18517: Coolbar - delete and row layout bug
+<br>19090: Combo doesn't size itself properly in GTK2
+<br>19670: Regression in OLE support
+<br>19671: Unable to expand/collapse trees in properties view
+<br>19720: Coolbar - getPreferredSize problem (was getClientArea problem)
+<br>19787: Hover help is not removed
+<br>19947: GTK2 sends key events with both keyCode and character equals to 0 for some keys
+</blockquote>
+
+<h1>
+Eclipse Platform Build Notes<br>
+SWT</h1>
+SWT Build 2.0 044 - Monday June 10, 2002
+
+<h2>
+<a NAME="Problem reports fixed"></a>Problem reports fixed</h2>
+<blockquote>
+4807: Text.setEchoChar spec should say 0 <= char < 128 (1GJ6CDM)
+<br>4837: Javadoc: Cursor constructor ERROR_NO_HANDLES is not spec'ed (1GKA7Q9)
+<br>5577: Text javadoc
+<br>7526: No spec for Display.update()
+<br>8513: JavaDoc for Menu.addMenuListener incorrect
+<br>12820: Finishing preview of the refactoring code crashes Eclipse
+<br>14463: GP opening two files at the same time
+<br>15460: CoolBar doc unclear/insufficient
+<br>15939: KeyEvent character is not consistent between Linux and Windows
+<br>16810: Mouse pointer not update
+<br>16837: Keys completely lost
+<br>16883: Variable sorting changes unexpectedly
+<br>16895: In-place text fields are unusable
+<br>17036: Disposing a CoolItem is triggering an activation callback.
+<br>17146: Editor Preference page buttom list clipped
+<br>17154: View part loses focus when opening context menu
+<br>17289: Combo doesn't take focus by clicking on it (Photon)
+<br>17290: Modify Method Parameters: wrong enablement of buttons
+<br>17507: AIX FileDialog is not responsive in stand-alone example
+<br>17613: Add from local history shows nothing in right and lower pane
+<br>17670: Cannot move through Plug-in Code Generation page list with arrow keys
+<br>17692: IAE when deleting line in Java Editor
+<br>17752: Cannot select a non-bold font
+<br>17788: Scale with preferred size is unusable (no range of motion)
+<br>17848: F1 build, JVM terminated Exit code 139
+<br>17936: Eclipse launcher must launch headless in headless environments
+<br>18439: Ctrl+F6 editor switching is unusable
+<br>18508: Javacoredump when opening vertical ruler context menu
+<br>18521: Coolbar layout and chevron bug
+<br>18543: An invisible character is added when the 'Windows' key is pressed
+<br>18625: Tabbing in Java editor takes cursor
+<br>18629: GTK: Unable to select dialog buttons with mouse
+<br>18645: Release SWT sources & javadoc in future builds
+<br>18733: ControlExample: List widget not being resized properly
+<br>18804: GPF setting image to menu item (Photon)
+<br>18838: Launch Configurations dialog creeps up
+<br>18841: Question: What does -DMBCS do?
+<br>18930: Wrong content displayed in tabs in the Launch Configuration Dialog
+<br>18934: Scrollbars should be disabled in ImageAnalyzer example
+<br>19057: Problem saving java file through popup menu
+<br>19116: Missing about.html in source directory for examples
+<br>19169: NPE on Emulated CoolItem constructor
+<br>19345: Task View: Not clearing priority icons
+<br>19394: False "unsaved changes" notification from launch configs
+<br>19503: Widget in outliner gets wrapped/cropped
+<br>19595: StyledText - redrawRange not clearing properly when clear flag set
+<br>19660: Preference page does not expand to fit all widgets
+<br>19769: Internet Explorer and Help, EXCEPTION_ACCESS_VIOLATION
+</blockquote>
+
+<h1>
+Eclipse Platform Build Notes<br>
+SWT</h1>
+SWT Build 2.0 043 - Friday May 31, 2002
+
+<h2>
+<a NAME="Problem reports fixed"></a>Problem reports fixed</h2>
+<blockquote>
+4692: Empty popup menu appears in Outline view (1GET1B1)
+<br>8821: Opening editors has become very slow
+<br>15565: Coolbar - minimumWidth not honored under certain conditions
+<br>16688: Selection background on emulated widgets is wrong
+<br>17150: Strange selection behaviour in Java Browsing Perspective
+<br>17156: Delete key not working in package view
+<br>17228: Weird Tree selection behaviour
+<br>17354: Double clicking expands and collapses item
+<br>17363: Test A4.4 cannot edit action set id in properties view
+<br>17680: Outline doesn't expand when adding new method
+<br>17825: ControlExample->Text beeps when I choose SWT.MULTI
+<br>17831: Coolbar - chevron not always displayed when it should be
+<br>18160: "Show in packages view" doesn't scroll to selection
+<br>18229: Walkback when closing ImageAnalyzer
+<br>18368: Get rid of all fragment.properties
+<br>18376: No execute permissions of libraries
+</blockquote>
+
+<h1>
+Eclipse Platform Build Notes<br>
+SWT</h1>
+SWT Build 2.0 042 - Thursday May 30, 2002
+
+<h2>
+<a NAME="Problem reports fixed"></a>Problem reports fixed</h2>
+<blockquote>
+4533: Cheese when resizing toolbar (1FWL943)
+<br>4841: SWT sample imageviewer nothing display at pixel data area (1GKEOUE)
+<br>6735: AWT/SWT - Swing / Swt integration : JComboBox doesn't show correctly
+<br>10972: Core dump drag and droppping from inline text
+<br>12498: Unable to add External Jar using the Java Project Wizard
+<br>16174: Wrong popup menu
+<br>16553: SWT_AWT.new_Panel does not work
+<br>16791: Can't select check boxes
+<br>17199: Table widget - only last column header is clickable
+<br>17375: Cheese on Java Scrapbook page ruler
+<br>17390: JUnit testcases result for Graphics (1 error, 2 failures)
+<br>17565: Add JRE validation not working
+<br>17568: Error doesn't disapear when switching to source folder layout
+<br>17574: Status line contributions appear twice
+<br>17637: Resize problem when diableing overview ruler in Editor
+<br>17662: Incorrect status display in new Feature Wizard
+<br>17917: Shift-Tab does not work
+<br>18223: Text widget with SWT.MULTI has strange behavior on GTK
+</blockquote>
+
+<h1>
+Eclipse Platform Build Notes<br>
+SWT</h1>
+SWT Build 2.0 041 - Tuesday May 28, 2002
+
+<h2>
+<a NAME="Problem reports fixed"></a>Problem reports fixed</h2>
+<blockquote>
+4398: Visual Coordination: Borders (1FSGONG)
+<br>4411: DCR - Support printing (1PQ8QCK)
+<br>4426: ScrollBar - Can't query size (1FDVP23)
+<br>4431: Folder tab does not get focus (1FIGI95)
+<br>4437: Tree Keyboard Support (1FOLZPT)
+<br>4452: MenuItem: setImage does not show image on menu (1FGNP8U)
+<br>4469: Inconsistencies between single line Text and RichText widgets (1FK1RRM)
+<br>4474: Not supportting Windows Accessibility Standard? (1FM0IFS)
+<br>4490: Fonts in examples appear too big (1FOMCWQ)
+<br>4496: DCR - Contour mouse middle button doesn't work (1FREAS4)
+<br>4503: FontDialog is missing fonts (1FSMRV0)
+<br>4526: Severe - Delete key is not redirected to editor (1FVXDST)
+<br>4529: Closing external MS Word makes in-place MS Word disappear (1FWG9AR)
+<br>4534: Flashing when computeSize called on Toolbar (1FWLD1E)
+<br>4545: No OS.GetKeyState function on motif (1FZQOZM)
+<br>4550: JUnit tests assumes boundary condition which is setting dependant (1G0LQKD)
+<br>4552: Adobe doesn't like ImageData... (1G0ZBE0)
+<br>4563: Need support for *.xpm and *.png image file formats (1G3HWSA)
+<br>4636: Tooltips not working on Linux (1GCN4FK)
+<br>4672: DCR - Include "begining / end " arrows to select files (1GEFYCG)
+<br>4679: Colour gradient of views is not gradual (16bit color depth) (1GELWSO)
+<br>4699: DCR - outstanding issue for customer- Changing cursor during drag operation (1GETC8U)
+<br>4703: WinME - Disabled icons in tabbed folder do not display properly. (1GEWXLI)
+<br>4706: StackOverflow resizing Workbench window (1GEWLSU)
+<br>4708: FATAL X error (1GF07HN)
+<br>4709: GP running ( Eclipse ^ 2 ) (1GEZ9UR)
+<br>4711: Navigator messed up when midi(w/DBCS) in it -Can't create view (1GEZNVC)
+<br>4728: Windows with tab pages should allow Ctrl-Tab switching (1GFIUG5)
+<br>4785: DCR - Custom notebook scrolling not optimal (1GI97VZ)
+<br>4839: TabFolder mnemonic problem (1GKAPKK)
+<br>4840: Hebrew: cannot paste from external file into java editor (1GKCWVX)
+<br>4851: Print ignores print to file option (1GKXC30)
+<br>4867: PgMemFlush() considered expensive (1GLEEJC)
+<br>5697: *Please* make SWT use GTK+ instead of Motif
+<br>8346: Workbench will not start
+<br>9217: Internal error at open the package view
+<br>9491: 1GRTRXQ: WSWB:Workbench 2.0 Problem- ArrayIndexOutOfBoundsException with MultiPageEditorPart
+<br>11204: Some ActiveX control can not accept key input.
+<br>11436: Request for public interface to call "UIDeactivate()" of IOleInPlaceObject
+<br>11498: StyledText does not always redraw when the line style changes
+<br>14846: Accessibility: getLocation does not position XP Magnifier
+<br>15218: Platform does not recognize the GUI - 20020502
+<br>15466: ImageData.blit throws ArrayIndexOutOfBounds Exception
+<br>15548: 'X' close box on tab hidden by arrows
+<br>15564: javaw.exe has generated errors and will be closed by windows
+<br>15653: Tab halts on CCombo objects
+<br>16094: Cheese on CTabFolder when resizing
+<br>16200: Tracker leaves cheese
+<br>16345: JVM termination when attepmting to run Update Manager
+<br>16458: Trying to free a GdkEvent: pointer=NULL
+<br>16549: Cannot navigate tabbed notebook with keyboard
+<br>16557: Tab does not move cursor between text fields
+<br>16565: Typed text is lost
+<br>16576: ACC: Checkboxes in lists are not real checkboxes
+<br>16828: CTabFolder flashing tooltip
+<br>16927: External programs support on Photon
+<br>16957: TreeItem.setForegroundColor() doesn't work
+<br>16967: Strange scroll behavior in package dialog
+<br>16995: HoverHelp example does not create ON_TOP Shell for tooltips
+<br>17022: SWT Layouts example - missing window title
+<br>17090: StyledText selects text when menu is showing
+<br>17183: Icon in wizard banner clipped
+<br>17208: Long operations are being modal.
+<br>17305: Search Dialog: Java Page clipped
+<br>17320: Search dialog freezes Eclipse
+<br>17368: 4 Toolbar icons pushed off the toolbar way to the right
+<br>17488: Image Support in SWT - FAQ (1G5Z1KS)
+<br>17497: FileDialog open() returns wrong result
+<br>17632: "Color Button" doesn't update
+<br>17802: Moving a sash requires an extra click to take effect
+<br>17811: Two menu bar items highlighted at the same time
+<br>17816: Menu appears then dissapprears with click after Alt.
+<br>17832: Vertical Scrollbar clipped
+<br>17834: JavaDoc API bad for Image
+<br>17835: Smalltalk code around :)
+<br>17928: NPE on addressbook example
+<br>17932: Emulated Coolbar do not resize when the last item on the row is removed
+<br>17933: Emulated Coolbar chevron too narrow on Photon
+<br>18005: BusyIndicator should check args
+</blockquote>
+
+<h1>
+Eclipse Platform Build Notes<br>
+SWT</h1>
+SWT Build 2.0 040 - Tuesday May 21, 2002
+
+<h2>
+<a NAME="Problem reports fixed"></a>Problem reports fixed</h2>
+<blockquote>
+3554: TP125: weird tab order in create project wizard (1G83VP8)
+<br>4424: Table draws a stray pixel in top left corner (1FS9QBQ)
+<br>4476: No syncExec runnables run during scrolling (1FMGG2X)
+<br>4528: Need FocusIn event for OleClientSite (1FW2S00)
+<br>4586: Use checkWidget() more often (1G80URQ)
+<br>4609: FillLayout should have FillLayout(type) constructor (1G9XBPI)
+<br>4694: Editor Name is missing from tab (1GET93J)
+<br>4726: CODE CHANGES AFTER THE FREEZE (1GF9YF0)
+<br>4788: Feature request: styled tree items (1GIGJK4)
+<br>4789: XP - Look and feel problems (1GIGGKM)
+<br>4831: DND not working properly (1GJYOZC)
+<br>4838: Can create FontData with null name string (1GKA93P)
+<br>4941: Focus callback during OleClientSite deactivate call
+<br>4942: Combo selection index should move when upper item removed (1GLGA41)
+<br>5910: Toolbar with all items disabled still shows up in tab order
+<br>5936: Composite.setTabList should accept null
+<br>6198: Focus lost in tab folder when switching pages
+<br>6406: J IME positioning incorrect
+<br>6514: Code assist behaves differently on Linux
+<br>6856: Default buttons different on Variable dialog
+<br>8162: Accessibility: focus goes missing in CVS location wizard
+<br>8791: Overaggressive focus grabbing
+<br>9141: WorkBench->Preference dialog's buttons font is too small.
+<br>9287: Combo.setText does not work
+<br>10491: Bold button will not bold text in SWT TextEditor Example
+<br>11074: EventTable.sendEvent should probably use try/finally
+<br>11349: Editor Tabs should fill to the right.
+<br>11369: Coolbar feature requests
+<br>11516: ViewForm should override computeTrim
+<br>11738: growing status bar
+<br>11847: OLE Editor prevents navigation without keys
+<br>12398: Accessibility problems
+<br>12641: Error in .classpath for Photon
+<br>12904: Accessible resizing of Views should move/change the Display's Cursor
+<br>12972: Noticed increased number of Eclipse crashes
+<br>13622: DCR - need ability to cancel window system shutdown
+<br>14449: [M5] error bringing up Code Formatter page
+<br>14546: TableColumn alignment problem with Motif
+<br>14656: Repaint of window does not wotk with IME up
+<br>14801: Mnemonic character doesn't work on TabFolder on QNX
+<br>15124: NPE: Label Decorations preference page
+<br>15134: Open Type dialog has wrong initial focus
+<br>15172: focus not on text field for OpenTypeDialog
+<br>15224: FileDialog does not return the file selected on PocketPC
+<br>15237: Coolbar - corrupts wrap layout when items deleted
+<br>15513: CCombo.setTooltipText() doesn't work
+<br>15516: GP - Eclipse crashed
+<br>15575: Tree with checkbox items are not accessible
+<br>15613: Copy/paste inserts NULL
+<br>15705: Editor with focus, tab text disappears sometimes
+<br>15872: Editor area frame should align with open editor's, excluding drop shadow
+<br>15989: Coolbar walkback when adding item
+<br>16069: Can't see source in imported binary SWT
+<br>16210: Core Dump Occurred while in Open Type dialog
+<br>16245: CTabFolder - tooltips and arrowing around
+<br>16281: Eclipse does not come up
+<br>16297: Wrong tab order in newer builds
+<br>16318: Can't activate views; losing events
+<br>16465: Stack Overflow when importing a project
+<br>16523: Unable to double-click
+<br>16525: Eclipse does not layout properly
+</blockquote>
+
+<h1>
+Eclipse Platform Build Notes<br>
+SWT</h1>
+SWT Build 2.0 039 - Tuesday May 14, 2002
+
+<h2>
+<a NAME="Problem reports fixed"></a>Problem reports fixed</h2>
+<blockquote>
+6103: Menu mnemonics don't work when toolbar has focus
+<br>8805: Context menus and finding references to methods
+<br>14823: Drag&Drop: need way to set the default behvaiour of a drop o
+<br>15055: Column Header Height in a Table or Table Tree SWT widget
+<br>15253: Linux GTK 2 library not found
+<br>15274: Can't add external jar in Linux-GTK version
+<br>15603: Preference page no longer resizes to fit contents
+<br>15634: Table not acting like list when last column deleted
+<br>15637: Cheese in Table when setting column image
+<br>15643: Cheese in Table when changing font
+<br>15705: Editor with focus, tab text disappears sometimes
+</blockquote>
+
+<h1>
+Eclipse Platform Build Notes<br>
+SWT</h1>
+SWT Build 2.0 038 - Tuesday May 7, 2002
+
+<h2>
+<a NAME="Problem reports fixed"></a>Problem reports fixed</h2>
+<blockquote>
+6391: Display.getActiveShell() can answer wrong value
+<br>7170: Tab space size problem
+<br>8542: Close perspective with mouse isn't possible
+<br>8591: Editor tabs should scroll automatically to fill available tab space
+<br>8648: StyledText - Caret can be hidden under scrollbar
+<br>10263: Editor keeps scrolling after mouse up
+<br>12226: Solaris - can't copy file into same directory
+<br>12360: TraverseEvent e.doit doesn't turn off on TabFolder
+<br>12952: Alt+{char} gets inserted as text
+<br>13614: JFace Tables have an extra column
+<br>13651: Printed output issues
+<br>13725: Revert is much slower than close and re-open in java editor.
+<br>14431: TableViewer inconsistent when clicking off of item list
+<br>14866: Shift-selection doesn't work immediately after restart
+<br>14880: Column resize problems/cheese
+<br>14902: Executable launcher does not restart
+<br>14935: EmulatedWidgetTests fail on Linux
+<br>14937: Launch from New Office Document hangs until Eclipse exits.
+<br>14964: StyledText - add new API for replacing style ranges
+<br>14981: Focus not set anymore
+<br>15057: getSystemColor(SWT.COLOR_WIDGET_FOREGROUND) always returns black
+<br>15115: removeColumn are broken in Emulated Table
+<br>15141: Tab is caught by read only text
+<br>15150: Progress bar behaves erraticaly
+<br>15208: StyledText - text change even mechanism poorly documented
+<br>15348: GPF in OS.MoveMemoryW
+</blockquote>
+
+<h1>
+Eclipse Platform Build Notes<br>
+SWT</h1>
+SWT Build 2.0 037 - Tuesday April 30, 2002
+
+<h2>
+<a NAME="LIBRARY LOCATION CHANGE"></a>LIBRARY LOCATION CHANGE</h2>
+
+As of this build, libraries are no longer in the org.eclipse.swt plugin.
+
+<p>Libraries can now be found in the associated windowing system fragment which to date are:
+<ul>
+<li>org.eclipse.swt.win32
+<li>org.eclipse.swt.motif
+<li>org.eclipse.swt.photon
+<li>org.eclipse.swt.gtk
+<li>org.eclipse.swt.gtk1x
+</ul>
+
+<h2>
+<a NAME="Problem reports fixed"></a>Problem reports fixed</h2>
+<blockquote>
+4641: Icon lookup fails for some windows icon paths (1GD2DEY)
+<br>4802: StyledText - Bidi Support Open Issues (1GIZ5G3)
+<br>4842: Can't launch external editors. (1GKEYOE)
+<br>6098: EXCEPTION_ACCESS_VIOLATION running Eclipse
+<br>6858: GP - Crash VM
+<br>8826: GPF - closing a Java editor
+<br>8837: Window position changed incorrectly in Shell.open()
+<br>9297: Eclipse crashed
+<br>11374: gp: Crash in swt-win32-2026.dll
+<br>11587: BIDI:Java editor and Text editor: User Interface issues.
+<br>12811: TableColumns don't pack properly
+<br>13200: gp - MoveMemory error on Windows XP
+<br>14049: gp - Crash in OS.MoveMemoryW
+<br>14220: gp - Crash closing editor
+<br>14245: gp - crash while debugging (NRCRASH)
+<br>14249: Exception while stepping
+<br>14280: Unsatisfied Link Errors running libswt-pi-gtk-2034.so on Linux/Gtk 2.0
+<br>14425: Font dialog exception
+<br>14528: Problem with Label.computeSize.
+<br>14538: StyledText - bidi - change backspace and delete behavior
+<br>14813: ClassCastException creating a new Run configuration
+<br>14872: ArrayIndexOutOfBoundsException in TableItem.insertColumn
+</blockquote>
+
+<h1>
+Eclipse Platform Build Notes<br>
+SWT</h1>
+SWT Build 2.0 036 - Tuesday April 23, 2002
+
+<h2>
+<a NAME="Problem reports fixed"></a>Problem reports fixed</h2>
+<blockquote>
+4834: DCR - mnemonics do not work on tabbed pages (1GK7O0N)
+<br>7189: Method highlight in border does not match the method
+<br>8253: Right clicking does not bring up context menu
+<br>8306: Inconsistencies in SWT example descriptions
+<br>8538: Mismatch between selected tab and displayed tab
+<br>8544: Some problems with the editor-pane (repaint, focus)
+<br>9360: Text entry in cvs comment dialog can't deal with quick typing
+<br>9794: Linux-GTK KeyEvents bad/different from the other platforms
+<br>12947: Color Preferences in Preferences->Java->Editor
+<br>13826: Performance issue in Table.RemoveAll()
+<br>13922: Eclipse crashes when running LayoutExample
+<br>13999: StyledText - appending single line data doesn't update properly
+<br>14047: StyledText - inefficient redraw during text change with word wrap
+</blockquote>
+
+<h1>
+Eclipse Platform Build Notes<br>
+SWT</h1>
+SWT Build 2.0 035 - Thursday April 18, 2002
+
+<h2>
+<a NAME="New APIs"></a>New APIs</h2>
+<ul>
+<li>Display.setCursorLocation</li>
+<li>GridLayout(int,boolean)</li>
+</ul>
+
+<h2>
+<a NAME="Problem reports fixed"></a>Problem reports fixed</h2>
+<blockquote>
+4602: GridLayout should have GridLayout(numColumns) constructor (1G9Z73D)
+<br>8549: org.eclipse.core.resources 4 Unhandled exception caught in event loop
+<br>9029: GC.setClipping(Rectangle) should handle null argument on GTK
+<br>10590: GTK Version / Tree View blanks...
+<br>10715: Code Assist dialog hide after press and release CTRL + SPACE
+<br>11182: Property Sheet does not allow editing when there is only one property
+<br>11515: computeTrim and getClientArea are inconsistent in CTabFolder
+<br>11713: Descriptions in preference pages aren't aligned
+<br>11715: Tab doesn't switch fields on gtk
+<br>11835: Strange behaviour of backspace in new Java Class dialog
+<br>11935: Can't Ctrl+Tab out of PDE Editor's dependencies page
+<br>12073: Moving shell above other shells does not work.
+<br>12882: DCR: Set Cursor location programmatically for accessibility
+<br>13194: Usability: editor tabs
+<br>13384: NPE on launching
+<br>13432: OleControlSIte doesn't propagate WM_SETFOCUS message to an ActiveX control
+<br>13639: Controls do not appear in tool items
+<br>13800: Can not get FocusEvent from Combo
+<br>13982: Eclipse won't start on GTK2
+</blockquote>
+
+<h1>
+Eclipse Platform Build Notes<br>
+SWT</h1>
+SWT Build 2.0 034 - Tuesday April 9, 2002
+
+<h2>
+<a NAME="Problem reports fixed"></a>Problem reports fixed</h2>
+<blockquote>
+6774: WinCE - items regarding Pocket PC (including 2002) integration
+<br>8806: Moving views is difficult
+<br>9245: ToolItems in a ToolBar not displaying images on WinCE
+<br>9616: Resize column leaves some cheese in the table
+<br>10603: Add Breakpoint keeps prompting me
+<br>10937: Converter problem on Solaris
+<br>11520: ShellAdapter.shellDeactivated() never called on Linux-Motif
+<br>11734: Focus not on "Finished" button
+<br>11940: Down arrow does not access drop-down portion of toolbar buttons
+<br>12241: Codeassist disappear after a few seconds
+<br>12573: Table sends selection event twice when in TabFolder
+<br>12787: Changing a menu item's text makes its icon disappear
+<br>12885: Label as a seperator doesn't resize properly
+<br>13006: Alt+1 with blank TabFolder results in NPE
+<br>13014: SetToolTipText called multiple times does not resize.
+<br>13049: CTabFolder focus traversing is busted
+</blockquote>
+
+<h1>
+Eclipse Platform Build Notes<br>
+SWT</h1>
+SWT Build 2.0 033 - Tuesday April 2, 2002
+
+<h2>
+<a NAME="Problem reports fixed"></a>Problem reports fixed</h2>
+<blockquote>
+12446: SWT Table Column Image Corruption
+<br>12447: Tree.getSelection() is slow for large trees
+</blockquote>
+
+<h1>
+Eclipse Platform Build Notes<br>
+SWT</h1>
+SWT Build 2.0 032 - Thursday March 28, 2002
+
+<h2>
+<a NAME="StyledText Bidi Printing"></a>StyledText Bidi Printing</h2>
+<blockquote>
+<p>Support has been added for printing the contents of a StyledText widget on
+bidirectional language Windows platforms.</p>
+<p> Note however that printing English or local language text does not work properly with some
+printer drivers when using a non-TrueType font. This has been noticed on Windows
+NT systems with the HP Laserjet 4 series printer driver. Please use a TrueType
+font if text is printed garbled .
+<br></p>
+</blockquote>
+
+<h2>
+<a NAME="Problem reports fixed"></a>Problem reports fixed</h2>
+<blockquote>
+4467: DCR - Tree missing keyboard support (1FJH5GY)
+<br>4525: Property viewer doesn't adapt to bg color changes (1FX8XL1)
+<br>10317: StyledText - bidi printing support
+<br>10483: SWT ControlExample DirectoryDialog does not choose directories
+<br>11081: Java Source Editing with Greek Locale no longer works
+<br>11549: Create project does not allow creation of folder in its project selection
+<br>12099: Accessibility : JAWS can not read TabItem's text
+<br>12231: DND : Drag and Drop busted (mouse capture not released)
+</blockquote>
+
+<h1>
+Eclipse Platform Build Notes<br>
+SWT</h1>
+SWT Build 2.0 031 - Monday March 18, 2002
+
+<h2>
+<a NAME="New APIs"></a>New APIs</h2>
+<ul>
+<li>ScrolledComposite.getOrigin</li>
+<li>ScrolledComposite.setOrigin</li>
+<li>Variant.getType</li>
+</ul>
+
+<h2>
+<a NAME="Problem reports fixed"></a>Problem reports fixed</h2>
+<blockquote>
+7500: Display.getBounds() calls from another thread give incorrect results
+<br>10273: NPEs caused by unitialized 'item' field in event
+<br>10481: View will not Size via Pull Down
+<br>10511: Add programmatic scrolling to ScrolledComposite
+<br>10942: Launcher should autodetect gtk only installation.
+<br>11051: Invalid token pasting in callback.c
+<br>11090: CLabel Javadoc says SmartLabel
+</blockquote>
+
+<h1>
+Eclipse Platform Build Notes<br>
+SWT</h1>
+SWT Build 2.0 030 - Tuesday March 12, 2002
+
+<h2>
+<a NAME="New APIs"></a>New APIs</h2>
+<ul>
+<li>OleControlSite.addEventListener(OleAutomation,int,OleListener)</li>
+<li>TableItem.getForeground()</li>
+<li>TableItem.getBackground()</li>
+<li>TableItem.setForeground(Color)</li>
+<li>TableItem.setBackground(Color)</li>
+<li>TreeItem.getForeground()</li>
+<li>TreeItem.getBackground()</li>
+<li>TreeItem.setForeground(Color)</li>
+<li>TreeItem.setBackground(Color)</li>
+<li>TableTreeItem.getForeground()</li>
+<li>TableTreeItem.getBackground()</li>
+<li>TableTreeItem.setForeground(Color)</li>
+<li>TableTreeItem.setBackground(Color)</li>
+</ul>
+
+<h2>
+<a NAME="Problem reports fixed"></a>Problem reports fixed</h2>
+<blockquote>
+8737: No Selection event when DND starts
+<br>9950: ColorDialog weird behavior
+<br>9959: Persistent Eclipse NPE on startup
+<br>9993: OleControlSite is not powerful enough
+<br>10420: Mouse and DND Event notification out of order
+<br>10480: Unable to open files with "System Editor"
+<br>10482: View will not Move via Pull Down
+</blockquote>
+
+<h1>
+Eclipse Platform Build Notes<br>
+SWT</h1>
+SWT Build 2.0 029 - Tuesday March 5, 2002
+
+<h2>
+<a NAME="New APIs"></a>New APIs</h2>
+
+<b>Note:</b> The new Accessibility API is experimental, and will likely change.
+<ul>
+<li>Control.getAccessible() added</li>
+<li>package <b>org.eclipse.swt.accessibility</b> added, containing the following classes:<ul>
+<li>Accessible</li>
+<li>ACC</li>
+<li>AccessibleListener</li>
+<li>AccessibleAdapter</li>
+<li>AccessibleEvent</li>
+<li>AccessibleControlListener</li>
+<li>AccessibleControlAdapter</li>
+<li>AccessibleControlEvent</li>
+</ul></li></ul>
+
+Here are two examples that use the accessibility API:<ul>
+<li>For a control with no child items:
+<code><pre>
+ button.getAccessible().addAccessibleListener(new AccessibleAdapter() {
+ public void getName(AccessibleEvent e) {
+ e.result = "My Button Label";
+ }
+ });
+</pre></code></li>
+
+<li>For a control that has child items:
+<code><pre>
+ list.getAccessible().addAccessibleListener(new AccessibleAdapter() {
+ public void getName(AccessibleEvent e) {
+ if (e.childID == ACC.CHILDID_SELF) {
+ e.result = "My List Label";
+ } else {
+ e.result = "My List Item Label: " + list.getItem(e.childID);
+ }
+ }
+ });
+</pre></code></li></ul>
+<b>Note:</b> The API involving the AccessibleControlXxx classes is more complex, and more likely to change.
+It is unlikely that application code will need to use it.
+It is primarily for the use of custom control implementors.
+
+<h2>
+<a NAME="Problem reports fixed"></a>Problem reports fixed</h2>
+<blockquote>
+4436: Grid Layout Problem (1FOLZZE)
+<br>4666: DCR - Need a way for child shells to disable ESC closing (1GE8RXW)
+<br>4790: XInitThreads causes japanese input method to hang (1GIRYR6)
+<br>4775: XInitThreads causes X printing to hang (1GITBQL)
+<br>4454: DCR: Tables need to support cell editing (1FGPLPP)
+<br>10002: Detection of CDE as active WM is platform-specific
+<br>10426: Esc traverse does not go up hierarchy
+</blockquote>
+
+<h1>
+Eclipse Platform Build Notes<br>
+SWT</h1>
+SWT Build 2.0 028 - Thursday February 28, 2002
+
+<h2>
+<a NAME="Problem reports fixed"></a>Problem reports fixed</h2>
+<blockquote>
+4688: J - Font Dialog does not select a font when selecting a font family (1GET5BW)
+<br>7139: FontDialog: Selected font not used
+<br>8865: Exception when creating a ToolItem with a null image in Linux
+<br>10250: Slider with VERTICAL orientation - down arrow increments
+</blockquote>
+
+<h1>
+Eclipse Platform Build Notes<br>
+SWT</h1>
+SWT Build 2.0 027 - Tuesday February 26, 2002
+
+<h2>
+<a NAME="Problem reports fixed"></a>Problem reports fixed</h2>
+<blockquote>
+6409: Node selection in package view
+<br>8389: MouseUp not reported correctly if DragDetect hooked
+<br>9364: Exception in StyledText
+<br>9773: Font and Color dialogs do not appear centred on parent
+<br>9950: ColorDialog weird behavior
+</blockquote>
+
+<h1>
+Eclipse Platform Build Notes<br>
+SWT</h1>
+SWT Build 2.0 026 - Tuesday February 12, 2002
+
+<h2>
+<a NAME="Problem reports fixed"></a>Problem reports fixed</h2>
+<blockquote>
+6679: Image.getImageData() not implemented
+<br>7962: SWT.getPlatform() javadoc incorrect for return description
+<br>8984: CTabFolder.MIN_TAB_WIDTH should not be static
+<br>9022: Linux: Tree Viewer does not get defualt Selection
+<br>9072: Table Tree does not pick up windows settings changes
+<br>9091: StyledText in SINGLE mode should look more like a Text widget
+<br>9172: SWT AddressBook Example calls undefined method
+<br>9432: The doc for Tracker widget should specify that rectangles are in screen coordinates
+</blockquote>
+
+<h1>
+Eclipse Platform Build Notes<br>
+SWT</h1>
+SWT Build 2.0 025 - Tuesday February 5, 2002
+
+<h2>
+<a NAME="Problem reports fixed"></a>Problem reports fixed</h2>
+<blockquote>
+2430: Sorting the Tasks List should display icon for sort key/order (1GF5TQO)
+<br>4485: DCR - Table column header decoration capability needed (1FOQQM8)
+<br>6035: Difference in tree "expanded state" between Windows and Motif
+<br>6983: Browse button in Import->Plugins not working.
+<br>7400: Single line text fields not firing "Key Pressed" events for the Enter, Up(arrow), and Down(arrow) keys
+<br>8173: Accessibility: keyboard-invoked popup menu not usable
+<br>8196: Accessibility: shift+F10 does not display view menu
+<br>8273: Horizontal scorllbar does not allow scrolling when required
+<br>8396: WINCE: Menu bar obscures control when control location is 0,0
+<br>8397: WINCE: Menu item colors don't match menu bar
+<br>8412: WINCE: Background color of buttons looks wrong
+<br>8640: GP: opening Synchronization perspective
+<br>8942: Wrong text indent in a table when use image
+</blockquote>
+
+<h1>
+Eclipse Platform Build Notes<br>
+SWT</h1>
+SWT Build 2.0 024 - Tuesday January 29, 2002
+
+<h2>
+<a NAME="Problem reports fixed"></a>Problem reports fixed</h2>
+<blockquote>
+4654: VAJ hangs when dragging from file manager to the desktop. (1GDQFZ6)
+<br>4720: Eclipse freezes during drag & drop operation (1GF7RRH)
+<br>4724: GP - Fatal app error - renaming resource on linux (1GF7TXO)
+<br>4736: Fix printing (1GFW2CW)
+<br>4817: Need JavaDoc comments for SWT Photon (1GJLEU0)
+<br>6835: Characters ��� and � doesn't work in Java editor on Swedish
+<br>8255: Closing paint viewer causes internal error
+<br>8410: Black color become transparent in ToolBar images
+<br>8503: StyledText - cheese if resize in word wrap tries to keep partial top line
+<br>8547: Intellimouse scrolling does not work in eclipse
+</blockquote>
+
+<h1>
+Eclipse Platform Build Notes<br>
+SWT</h1>
+SWT Build 2.0 023a - Thursday January 24, 2002 (Eclipse Milestone 2)
+
+<h2>
+<a NAME="Problem reports fixed"></a>Problem reports fixed</h2>
+<blockquote>
+4700: NumLock and CapsLock disable accelerators (1GETDT9)
+<br>6180: Wake mechanism broken on Motif
+<br>6873: Decorations.setImage() throws NPE on WINCE
+<br>7805: A new ImageData(from an InputStream) throwing NPE
+<br>8133: When toolbar has focus, can't use mnemonics for File menus
+<br>8213: exception: widget is disposed
+</blockquote>
+
+<h1>
+Eclipse Platform Build Notes<br>
+SWT</h1>
+SWT Build 2.0 023 - Tuesday January 22, 2002
+
+<h2>
+<a NAME="Problem reports fixed"></a>Problem reports fixed</h2>
+<blockquote>
+4610: StyledText - DCR - Word wrap (1GABS6C)
+<br>4644: Mouse click on a link displayed in embedded IE5 ActiveX is not reliable (1GD7TT2)
+<br>5660: SWT default font's need to honor accesability settings
+<br>6324: SWT.CLOSE implies rendering of Minimize and Maximize buttons
+<br>6997: StyledText - mark new API
+<br>7123: Shell shows the maximize button enabled when SWT.TITLE | SWT.BORDER | SWT.CLOSE style passed
+<br>7361: Add getOffsetAtLine API
+<br>7632: Tree widget doesn't select item with focus on right-click
+<br>7849: Labels on WINCE don't use background color of parent when color isn't set
+<br>7867: DCR: Delete checkSubclass method from Dialog
+<br>7959: Potential problems when running on big endian machines
+</blockquote>
+
+<h1>
+Eclipse Platform Build Notes<br>
+SWT</h1>
+SWT Build 2.0 022 - Tuesday January 15, 2002
+
+<h2>
+<a NAME="Problem reports fixed"></a>Problem reports fixed</h2>
+<blockquote>
+4663: Fail to tab the views. (1GGYV8T)
+<br>4718: Tool tip is openning when on dragging. (1GF5Z7Z)
+<br>5866: Can't multiselect in Tree using keyboard
+<br>6592: Box for checkbox table items is too large when using large fonts
+<br>6770: Only the left mouse button should select in a Table.
+<br>6852: StyledText - verify event character invalid value
+<br>6940: MenuShortcuts only respond to Ctrl-N
+<br>7190: Ctrl-S does not work
+<br>7458: WinCE - top level Shells created through Display.asyncexec can have incorrect Z-order
+<br>7459: Caret leaving garbage
+<br>7486: Cannot use keyboard Shift Select in a Tree
+<br>7559: ScrollBar thumb is reset when ScrollBar is hidden, then shown
+</blockquote>
+
+<h1>
+Eclipse Platform Build Notes<br>
+SWT</h1>
+SWT Build 2.0 021 - Tuesday January 8, 2002
+
+<h2>
+<a NAME="Problem reports fixed"></a>Problem reports fixed</h2>
+<blockquote>
+4443: Layout: Exceptions when horizontalSpan > remaining columns (1FFC6XZ)
+<br>4462: ScrollBar - vbar.setMaximum does not work after hbar is hidden (and vice versa) (1FIG5CG)
+<br>4722: First editor tab missing close button (1GF7QIQ)
+<br>4755: Rebuilding launcher from another directory (1GGNRG0)
+<br>6315: Some perspective save confirmation messages cut off
+<br>6352: Editor doesn't get activated when revealing first match
+<br>6908: Menu handle leak in org.eclipse.swt.widgets.Menu.destroyItem(MenuItem)
+<br>6945: Child shells not displaying on WinCE
+<br>6982: CheckedTables have no check boxes
+<br>7005: Missing methods in SWT/GTK implementation
+<br>7018: Tree does not honor SWT.CHECK style
+<br>7068: ScrollBar.setVisible(true) does not work after changing values
+<br>7150: StyledText - bidi - partial styling of ligatures bug
+<br>7191: Dialogs not big enough for content
+</blockquote>
+
+<h1>
+Eclipse Platform Build Notes<br>
+SWT</h1>
+SWT Build 2.0 020 - Tuesday December 18, 2001
+
+<h2>
+<a NAME="Problem reports fixed"></a>Problem reports fixed</h2>
+<blockquote>
+4715: First help click on a chapter is ignored (1GF5TV9)
+<br>4784: MIF Files sometime fail (1GI7H7V)
+<br>4797: Table does not use System fonts (1GIV4PZ)
+<br>6635: WinCE: decorations.setMenuBar can be set only once
+<br>6685: StyledText - on setFont caret not being positioned correctly
+<br>6773: StyledText.computeSize uses display width to calculate number of visible lines
+<br>6790: Touching code assist scrollbar dumps javacore
+<br>6863: Remaining issues in emulated CoolBar and CoolItem
+<br>6933: Switching to help perspective crashes the workbench
+<br>7014: Tree not accepting children
+</blockquote>
+
+<h1>
+Eclipse Platform Build Notes<br>
+SWT</h1>
+SWT Build 2.0 019 - Tuesday December 11, 2001
+
+<h2>
+<a NAME="Problem reports fixed"></a>Problem reports fixed</h2>
+<blockquote>
+4461: SWTException should overwrite printStackTrace(..) (1GLDW6P)
+<br>4493: Check multilingual support on Windows 2000 (1FQFCBQ)
+<br>4611: StyledText - StringIndexOutOfBounds exception inserting text in line break (1GEID8B)
+<br>4620: Workbench does not close ActiveX control's file handle (1GB76AZ)
+<br>4660: Moving
+<br>4719: Background colour of views/editors (1GF6C8Y)
+<br>4739: DCR: Provide auto-scrolling and expansion by default in the tree during DND (1GFW7NQ)
+<br>4767: Tab Folders can not be toggled using keys. (1GHFCZU)
+<br>4780: YAM: Cannot read some JPEG files (1GI6ZEN)
+<br>4783: Can't scroll to the top of the navigator (1GI7GTG)
+<br>5071: Shift-TAB doesn't generate proper event
+<br>5677: Hierarchy outline has empty space
+<br>5857: Image.getImageData needs to support 15 bit color depth
+<br>6472: Table widget has empty entries
+<br>6572: Default background color of Lists and Combos not consistent with Win2K
+<br>6651: Text.setSelection() doesn't actually display the selection visually for SWT.SINGLE
+<br>6654: Text.getSelection() not returning correct info on WINCE
+</blockquote>
+
+<h1>
+Eclipse Platform Build Notes<br>
+SWT</h1>
+SWT Build 2.0 018 - Tuesday December 4, 2001
+
+<h2>
+<a NAME="Problem reports fixed"></a>Problem reports fixed</h2>
+<blockquote>
+4419: Widgets - Missing features and API on MOTIF (1FBPKCT)
+<br>4494: ColorDialog doesn't open in VA/Java with JDK 1.2 (1FQGM6H)
+<br>4833: Remove focus button from Table (1GK7MK4)
+<br>4860: StyledText - StyledTextBidi, BidiUtil need doc (1GL32C8)
+<br>6204: KeyListener on table does not work.
+<br>6438: StyledText - bidi - isBidi test not working on XP
+</blockquote>
+
+<h1>
+Eclipse Platform Build Notes<br>
+SWT</h1>
+SWT Build 2.0 017 - Tuesday November 27, 2001
+
+<h2>
+<a NAME="Problem reports fixed"></a>Problem reports fixed</h2>
+<blockquote>
+4714: Label draws wrong background when image is set (1GF0IC6)
+<br>5503: Tabbing broken
+<br>5986: BidiUtil handling of WM_INPUTLANGCHANGE needs to be fixed
+<br>5992: Changing Java Editor font in Preference Page makes Eclipse hang or crash
+<br>6171: NullPointerException in ImageLoader save method with SWT.IMAGE_JPEG
+</blockquote>
+
+<h1>
+Eclipse Platform Build Notes<br>
+SWT</h1>
+SWT Build 2.0 015 - Tuesday November 20, 2001
+
+<h2>
+<a NAME="Problem reports fixed"></a>Problem reports fixed</h2>
+<blockquote>
+4791: StyledText does not switch colour (1GILHIW)
+<br>4956: StyledText - change StyledTextBidi.toString to conform with standard SWT format
+<br>5599: StyledText - redrawRange does not check range
+<br>5722: Selecting font crashes eclipse with a javacore
+<br>5815: StyledText - setFont refresh problem
+<br>5846: Combo.select does not ignore an out of range index
+<br>5990: Printing single page prints entire document
+</blockquote>
+
+<h1>
+Eclipse Platform Build Notes<br>
+SWT</h1>
+SWT Build 2.0 014 - Thursday November 15, 2001
+
+<h2>
+<a NAME="Problem reports fixed"></a>Problem reports fixed</h2>
+<blockquote>
+4542: Menu accelerators CTRL+ / and CTRL + SHIFT + / don't work (1FYAF8V)
+<br>4754: Arrow keys not accepted as keyboard accelerators (1GGM4U3)
+<br>5815: StyledText - setFont refresh problem
+</blockquote>
+
+<h1>
+Eclipse Platform Build Notes<br>
+SWT</h1>
+SWT Build 2.0 013 - Tuesday November 13, 2001
+
+<h2>
+<a NAME="Problem reports fixed"></a>Problem reports fixed</h2>
+<blockquote>
+4846: StyledText - bidi - partial styling of ligatures (1GL3AWT)
+<br>4859: StyledText - bidi - provide solution for bidi coloring hack (1GL2UNC)
+<br>5491: StyledText - getStyleRangeAtOffset allows offset == getCharCount
+<br>5497: StyledText - ExtendedModify event not sent on setText
+<br>5602: StyledText - page down causes IllegalArgumentException in invisible/small widget
+<br>5615: StyledText - window start does not always work
+<br>5622: StyledText - print causes NPE when invoked on empty widget
+<br>5626: StyledText - print does not check for null Printer argument
+<br>5633: StyledText - replaceTextRange and setText do not check for null argument
+<br>5664: StyledText - Single line should not accept tab
+<br>5673: StyledText - SINGLE line mode still allows some multi line cursor navigation
+<br>5722: Selecting font crashes eclipse with a javacore
+<br>5725: Please rename "Eclipse Launcher"
+<br>5802: EC: ControlExample does not run on Solaris
+</blockquote>
+
+<h1>
+Eclipse Platform Build Notes<br>
+SWT</h1>
+SWT Build 2.0 012 - Monday November 5, 2001
+
+<h2>
+<a NAME="Problem reports fixed"></a>Problem reports fixed</h2>
+<blockquote>
+5470: User is lost when trying to move views around
+<br>5484: Tab no longer traverses between widgets!!!
+</blockquote>
+
+<h1>
+Eclipse Platform Build Notes<br>
+SWT</h1>
+SWT Build 2.0 011 - Thursday November 1, 2001
+<h2>
+<a NAME="API Changes"></a>API Changes</h2>
+<code>FontData.setLocale(Locale)</code> has been changed to <code>FontData.setLocale(String)</code>.
+<ul>
+<li>
+J2SE code can simply create a <code>Locale</code> and invoke <code>toString()</code> to pass it onto the new <code>setLocale</code>.
+<li>
+CLDC code will have to form a string matching the format specified in the J2SE javadoc of <code>java.util.Locale.toString()</code>.
+</ul>
+Example:
+<blockquote><code><pre>
+Locale[] locales = {
+ Locale.US, new Locale("iw", "IL"), new Locale("ar", "SA"), new Locale("ru", "RU"),
+ Locale.GERMAN, new Locale("ja", "JP"),
+ null,
+};
+// old code: fd.setLocale(locales[i]);
+String locale = (locales[i] != null ? locales[i].toString() : null);
+fd.setLocale(locale);
+</pre></code></blockquote></p>
+
+<h2>
+<a NAME="Problem reports fixed"></a>Problem reports fixed</h2>
+
+<blockquote>
+4664: StyledText does not compute correct text width (1GELJXD)
+<br>4832: German: Fonts cannot handle German characters (1GKMHHY)
+<br>4961: Preferences dialog disappears when you click on certain pages
+<br>5180: Open Motif for Linux shared libraries are duplicated in Eclipse
+<br>5304: StyledText - ArrayIndexOutOfBoundsException in StyledTextBidi.segmentedRangesFor
+</blockquote>
+
+
+<h1>
+Eclipse Platform Build Notes<br>
+SWT</h1>
+SWT Build 2.0 010 - Thursday October 25, 2001
+
+<h2>
+<a NAME="Behaviour change"></a>Behaviour change</h2>
+<p>
+1) The Drag Under effect of scrolling and expanding items as you drag over the <code>Tree</code> or <code>Table</code> has been added. To enable this drag under effect, in the <code>DragOver</code> event set the <code>event.feedback</code> to have a bitwise combination of <code>DND.FEEDBACK_SCROLL, DND.FEEDBACK_EXPAND</code> and (<code>DND.FEEDBACK_SELECT, DND.FEEDBACK_INSERT_BEFORE, DND.FEEDBACK_INSERT_AFTER</code>) - where the last three items are mutually exclusive.
+<blockquote><code><pre>
+target.addDropListener (new DropTargetAdapter() {
+ public void dragOver(DropTargetEvent event){
+ event.feedback = DND.FEEDBACK_SELECT | DND.FEEDBACK_EXPAND | DND.FEEDBACK_SCROLL;
+ }
+}
+</pre></code></blockquote></p>
+<p>
+2) On some operating systems it is preferred to move files in a drag and drop operation rather than for the drop target to make a copy of the file and the drag source to delete the original file. The operation of moving the file is preformed by the drop target. For these cases, the new drop type <code>DND.DROP_TARGET_MOVE</code> has been added. The Eclipse <code>DropTarget</code> does not support this behaviour but the Eclipse <code>DragSource</code> can recognize this scenario. If another application has chosen to move the file rather than copy/delete, the <code>DragFinished</code> event on the <code>DragSource</code> will have an <code>event.detail</code> value of <code>DND.DROP_TARGET_MOVE</code>.
+<blockquote><code><pre>
+source.addDragListener (new DragSourceAdapter () {
+ public void dragFinished(DragSourceEvent event) {
+ if (event.detail == DND.DROP_TARGET_MOVE) {
+ // clean up presentation but do not delete underlying file
+ }
+ }
+}
+</pre></code></blockquote></p>
+
+<h2>
+<a NAME="Problem reports fixed"></a>Problem reports fixed</h2>
+
+<blockquote>
+1767: Display ASCII for values greater than 127 fails (1GLE8I5)
+<br>4725: FontData spec should disallow null name (1GL34H3)
+<br>4844: Tab appears narrower than space (1GL2WTY)
+<br>4852: German: Cannot start Eclipse in Linux 7.2 (1GKYY99)
+<br>4865: TableTreeEditor.getItem returns an item after setting it to null (1GLE0IQ)
+<br>4932: StyledTextBidi has equals but no hashCode method
+<br>4957: StyledText - implement StyledTextBidi.isLigated
+<br>5132: StyledText - remove hardcoded margin
+<br>5178: Change BidiUtil calls to handle true Unicode/Windows CE changes
+</blockquote>
+
+<h1>
+Eclipse Platform Build Notes<br>
+SWT</h1>
+SWT Build 2.0 009 - Thursday October 18, 2001
+
+<h2>
+<a NAME="Problem reports fixed"></a>Problem reports fixed</h2>
+
+<blockquote>
+4444: EWT - incorrect selection feedback when the item's text is changed (1FFP3U2)
+<br>4446: DCR - GridBagLayout compatible LayoutManager (1FGCPO2)
+<br>4762: StyledText - default lineStyler remove line background color hack (1GHBMUV)
+<br>4819: StyledText - bidi - cursor navigation (1GJLKSN)
+<br>4820: StyledText with style SINGLE does not handle CR/LF well (1GJM2Z5)
+<br>4855: Severe: Check boxes are black (1GL0XSI)
+<br>4909: EC: Combo.setText doesn't work on Linux
+<br>4910: EC: Combo.select() fires a selected event on Linux only
+<br>5045: Control.moveAbove() throws NPE if argument is null
+</blockquote>
+
+
+<h1>
+Eclipse Platform Build Notes<br>
+SWT</h1>
+SWT Build 2.0 008 - Thursday October 11, 2001
+
+<h2>
+<a NAME="Problem reports fixed"></a>Problem reports fixed</h2>
+
+<blockquote>
+1GLDQYB: SWT:WIN - Text widget with DND enabled, MouseDown but no MouseUp
+<br>1GLADBK: SWT:ALL - StyledText - getOffsetAtLocation should throw exception
+<br>1GL4ZVE: SWT:ALL - StyledText - getOffsetAtLocation(getLocationAtOffset(N)) != N
+<br>1GKO6NY: SWT:ALL - Backspacing in StyledText does not fire selection changed
+<br>1GKB1OC: ITPJUI:ALL - Error in JavaDoc hover help
+<br>1GK9API: SWT:ALL - StyledText - bidi - numbers,mixed LtoR/RtoL text and caret positioning
+<br>1GJLQ16: SWT:ALL - StyledText - bidi - backspace and delete behavior
+<br>1GIK7D4: SWT:ALL - StyledText - Selection cleared when deletion disallowed by verify listeners
+<br>1GDOMBI: SWT:WINNT - StyledText - redrawRange() doesn't checkWidget
+<br>1GDKK3R: SWT:WINNT - StyledText - setCaretOffset and line delimiters bug
+<br>1FMRQOT: SWT:ALL - No null argument checks in Dialog constructors
+</blockquote>
+
+
+<h1>
+Eclipse Platform Build Notes<br>
+SWT</h1>
+SWT Build 2.0 007 - Thursday October 4, 2001
+
+<h2>
+<a NAME="Problem reports fixed"></a>Problem reports fixed</h2>
+
+<blockquote>
+1GKZH74: ITPJUI:WIN2000 - Disappearing Stop icon
+<br>1GKZ8CV: SWT:WINNT - setSelection triggers SelectionChanged event
+<br>1GKU4C5: SWT:ALL - StyledText - bidi - scrolling to show cursor should take cursor direction into account
+<br>1GKPYMK: SWT:WINNT - StyledText - bidi - caret moves when switching keyboard from Hebrew to Arabic
+<br>1GKOGQO: SWT:ALL - Javadoc: setSelection in Button and ToolItem
+<br>1GKM2O5: SWT:WINNT - StyledText - bidi - ArrayIndexOutOfBounds exception in StyledTextBidi.isRightToLeft
+<br>1GKM193: SWT:WINNT - StyledText - bidi autoscroll left does not always scroll all the way to the left
+<br>1GKKC0U: SWT:ALL - Tracker calls OS.DispatchMessage(msg) on windows but does not on Linux.
+<br>1GIVAXX: SWT:ALL - StyledText - Editors should support shift-backspace
+<br>1GELQ14: SWT:WINNT - StyledText - DefaultContent - handle weird line delimiter cases
+<br>1GE8LG0: SWT:Linux - Toolbar is not showing the separators.
+</blockquote>
+
+
+<h1>
+Eclipse Platform Build Notes<br>
+SWT</h1>
+SWT Build 2.0 006 - Thursday Sept 27, 2001
+
+<h2>
+<a NAME="Problem reports fixed"></a>Problem reports fixed</h2>
+
+<blockquote>
+1GHWA19: SWT:WINNT - Problem with callbacks from CCombo
+<br>1GHFDPV: SWT:WIN2000 - Setting selection in Table does not update focus item
+<br>1GF644V: ITPUI:Linux - Unzoom is changing the active editor.
+<br>1GKM3XS: SWT:WINNT - StyledText - bidi autoscroll left: selection reset on mouse move
+</blockquote>
+
+
+<h1>
+Eclipse Platform Build Notes<br>
+SWT</h1>
+SWT Build 2.0 005 - Friday Sept 21, 2001
+
+<h2>
+<a NAME="Problem reports fixed"></a>Problem reports fixed</h2>
+
+<blockquote>
+1GK09Z0: SWT:Linux - setEnabled(false) has no effect on aToolbar
+<br>1GJZZS6: SWT:Linux - File Dialog returns a directory
+<br>1GF7SMC: ITPUI:Linux - Wrong bg for close button on editor tab
+</blockquote>
+
+
+<h1>
+Eclipse Platform Build Notes<br>
+SWT</h1>
+SWT Build 2.0 004 - Thursday Sept 13, 2001
+
+<h2>
+<a NAME="API Behaviour change"></a>API Behaviour change</h2>
+The behaviour of dispose for GCs has been modified such that attempting to dispose of
+a GC on a control <em>after</em> the control has been disposed will generate an
+SWTException. This fixes an OS resource leak and potential GPF situation.
+
+<h2>
+<a NAME="Problem reports fixed"></a>Problem reports fixed</h2>
+
+<blockquote>
+1GJUAKL: SWT:Neutrino - Control.internal_new_GC() needs !isValidWidget() check
+<br>1GJN52N: SWT:Linux - Text prints system error message for horizontal scrollbar
+<br>1GJBOAV: SWT:ALL - ScrolledComposite bugs
+<br>1GIXELI: SWT:ALL - Need Caret to allow bitmaps so bidi caret can be created
+<br>1GI5O1T: SWT:WINNT - Composite.setFocus takes focus when it should not
+<br>1GHOND7: SWT:WIN2000 - Selection problem with single-selection trees
+<br>1GHG990: SWT:ALL - Probable bug in Slider page increment setting
+<br>1GENJ60: SWT:ALL - ScrolledComposite should include example in its class comment
+<br>1GEA7K7: ITPUI:Linux - Default button not working
+</blockquote>
+
+
+<h1>
+Eclipse Platform Build Notes<br>
+SWT</h1>
+SWT Build 2.0 003 - Friday Sept 07, 2001
+
+<h2>
+<a NAME="New APIs"></a>New APIs</h2>
+
+<blockquote>
+FontData.setLocale(java.util.Locale) added
+<br>Caret.getImage() added
+<br>Caret.setImage(Image) added
+<br>GC.fillGradientRectangle(int, int, int, int, boolean) added
+</blockquote>
+
+<h2>
+<a NAME="Problem reports fixed"></a>Problem reports fixed</h2>
+
+<blockquote>
+1GJM7KM: SWT:Linux - Table and Tree return a different size for every second call to computeSize
+<br>1GJLKHE: SWT:SPARC - GP on "Installed JREs" preference page
+<br>1GJLK63: SWT:ALL - StyledText - bidi - keyboard switching
+<br>1GJLE36: SWT:WINNT - Alpha data redrawing improperly after occlusion
+<br>1GJA2L7: SWT:WIN - Different behavior for GC.drawString() args on Win vs. Photon
+<br>1GIZ0P6: SWT:WINNT - GC.drawImage() problem with transparent pixels
+<br>1GIXELI: SWT:ALL - Need Caret to allow bitmaps so bidi caret can be created
+<br>1GI7FQF: SWT:ALL - Can't set focus to Tasks View by Keyboard
+<br>1GI7EBL: SWT:Linux - api typo: ToolItem>>getDisabledmage()
+<br>1GI3P86: SWT:ALL - Semantic differences between emulated Table and Tree codebase on Motif and Photon
+<br>1GI1WEA: SWT:Neutrino - Text selection code not working correctly
+<br>1GHWED2: SWT:WINNT - GC.stringExtent() not correct for Windows Arial font
+<br>1GHWB7G: SWT:Linux - Linux font dialog doesn't open with given values.
+<br>1GHVRFY: SWT:Neutrino - Text#ClearSelection changes the CaretPosition in a SINGLE-line widget
+<br>1GHVLV6: SWT:Neutrino - Text#SetTopIndex and getTopIndex inconsistent
+<br>1GHOJ6T: SWT:Neutrino - Text#setSelection inconsistent between SINGLE and MULTI
+<br>1GHBLRA: SWT:Neutrino - Display.getBounds() returns incorrect info
+<br>1GH48UQ: SWT:Neutrino - Enter key does not insert new line with Text.MULTI widget
+<br>1GGT0TM: SWT:Neutrino - GC#drawArc inconsistent between NT and NTO
+<br>1GG1DBT: SWT:SPARC - Solaris loses input characters
+<br>1GG07HW: SWT:Linux - Tree.getItem() modifies its argument on Motif
+<br>1GG0069: SWT:Linux - Weird layout issues seen in Control Example
+<br>1GFZZLK: SWT:Linux - ToolItems not disabled when containing ToolBar is disabled
+<br>1GFZU3X: SWT:ALL - ImageLoader.load(String) not closing file input stream
+<br>1GFZPDP: SWT:Linux - Combo box with SWT.SIMPLE style does not respect Disabled flag (visually)
+<br>1GFW85H: SWT:ALL - Printer.getPrinterData() has stale comment
+<br>1GFW6MQ: SWT:ALL - DCR: Program class needs .equals() and .hashCode()
+<br>1GFW4YN: SWT:ALL - Help KevinH add printing to Eclipse
+<br>1GFQKDT: SWT:ALL - Image.setBackground() / getBackground() asymmetry
+<br>1GFONVW: SWT:Linux - Empty Combo should not fire Selection event
+<br>1GFL0HP: SWT:Linux - Remaining items in SWT comments to fix
+<br>1GET90D: SWT:Linux - SWTExceptions bring down Eclipse
+<br>1GESQBK: ITPJUI:WINNT - How to get access to pop-up menus of the Java editor ?
+<br>1GELX4A: ITPUI:ALL - Hover help is not visible if pane is dragged out of workbench
+<br>1GEHWAF: ITPUI:WIN2000 - Can't enter text in a Swing TextField or TextArea
+<br>1GE5ECJ: ITPUI:WIN2000 - Hover help for title bar buttons appears behind detached view
+<br>1GDX7R8: ITPUI:ALL - SWT setText() does NOT have any way to avoid making mnemonics.
+<br>1GD5UHA: SWT:WIN2000 - Double-clicking on toolbar item gives double-click event on toolbar
+<br>1GBXIEO: SWT:ALL - DCR: Include cursor pos in Tracker move event
+<br>1G4IMQ3: SWT:WINNT - Table images incorrect after rapid removal and creation
+</blockquote>
+
+<h1>
+Eclipse Platform Build Notes<br>
+SWT</h1>
+SWT Build 2.0 002 - Wednesday July 18, 2001
+
+<h2>
+<a NAME="Problem reports fixed"></a>Problem reports fixed</h2>
+
+<blockquote>
+1GGZ13T: SWT:Neutrino - invalid mouse state occuring in Photon
+<br>1GGRCCS: SWT:Neutrino - Label does not wrap in SWT0125
+<br>1GGAON2: SWT:ALL - Scaling image with alphas does not work correctly
+<br>1GFZQVQ: SWT:Linux - Vertical ProgressBar grows incorrectly
+<br>1GFQA18: SWT:Linux - Cheese with GC drawRoundedRectangle() on Motif
+<br>1GFPK6G: SWT:Linux - Motif fillPolygon() specifies improper hint
+</blockquote>
+
+<h1>
+Eclipse Platform Build Notes<br>
+SWT</h1>
+SWT Build 2.0 001 - Thursday July 12, 2001
+
+<h2>
+<a NAME="Problem reports fixed"></a>Problem reports fixed</h2>
+
+<blockquote>
+1GGET76: SWT:Neutrino - Canvas does not respond to setFocus()
+<br>1GGAS5P: SWT:Neutrino - Photon on QNX 6.1.x needs SWT native changes
+<br>1GG96RO: SWT:Neutrino - drawOval and fillOval not compatible
+<br>1GG8ZLV: SWT:WINNT - drawOval behaves differently on Windows vs. other platforms
+<br>1GFKYD9: SWT:Linux - -HANG- (Xserver) When perfoming display.wake() in a DND dragStart()
+<br>1GFKK37: SWT:Linux - FileViewer examples issues
+<br>1GFBHX6: SWT:ALL - CTabItem tool tip flashing
+<br>1GF9ZMT: SWT:SPARC - 8-bit Icons are losing colors
+<br>1GF9ZJG: SWT:SPARC - Icons are being masked incorrectly on Solaris
+<br>1GF9YHD: ITPUI:WIN2000 - SWTException: help view
+<br>1GF9Y32: SWT:SPARC - 24-bit MSB Icons are wrong color (greenish)
+<br>1GF0D05: SWT:Linux - GPFs when running JUnit TestRunner in J9 AWT
+<br>1GEUZZC: SWT:ALL - "Name" of plugin inconsistant with other plugins
+<br>1GETDP5: ITPUI:Linux - NPE while closing editor on linux
+<br>1GDVRT5: SWT:Neutrino - Alpha channel memory leak
+<br>1GDRXZR: ITPJUI:Linux - SWT: Context-Menus issue under Linux
+<br>1GD0OSK: SWT:ALL - API - package javadoc for SWT packages missing
+<br>1GCHS75: SWT:WINNT - workbench exits during expand collapse
+<br>1GCFUS0: SWT:ALL - CTabFolder "floating" X sticks sometimes
+<br>1GAR95O: SWT:ALL - Remove Smalltalk comments from SWT code
+<br>1GAQRND: SWT:ALL - DOC: Write good Javadoc comments for all of SWT
+<br>1G97I28: SWT:Linux - Tool bar buttons do not always work
+<br>1G84AZB: ITPDUI:ALL - Rename truncates name
+<br>1G845EZ: SWT:WIN2000 - Spec for Layout.computeSize() is truncated
+<br>1G7YXLB: SWT:WIN - StyledText - NLS Support
+<br>1G7NSHR: SWT:ALL - Widget.addListener(int, Listener) vs. adding typed listeners
+<br>1G4XDJO: SWT:Linux - Tree needs to display an insert marker
+<br>1G0Y8NZ: SWT:ALL - Combo box doesn't send key and mouse events
+<br>1FXAVLF: SWT:WINNT - Disabled toolbar icons don't adapt to appearance changes
+<br>1FV1S18: SWT:ALL - Need more WM_* messages passed to ActiveX Control
+<br>1FTWX55: SWT:ALL - Inconsistant commenting of which SWT objects need to be disposed.
+</blockquote>
+<a href="hglegal.htm"><img SRC="ngibmcpy.gif" BORDER=0 height=12 width=195></a>
+</body>
+</html>
diff --git a/bundles/org.eclipse.swt/plugin.properties b/bundles/org.eclipse.swt/plugin.properties
index 1b9208a43e..bf0ac5c05b 100644
--- a/bundles/org.eclipse.swt/plugin.properties
+++ b/bundles/org.eclipse.swt/plugin.properties
@@ -1,2 +1,2 @@
-pluginName = Standard Widget Toolkit
+pluginName = Standard Widget Toolkit
providerName = Eclipse.org \ No newline at end of file
diff --git a/bundles/org.eclipse.swt/plugin.xml b/bundles/org.eclipse.swt/plugin.xml
index 7bd98bee0c..e6c840ca3c 100755
--- a/bundles/org.eclipse.swt/plugin.xml
+++ b/bundles/org.eclipse.swt/plugin.xml
@@ -1,16 +1,16 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!-- File written by PDE 1.0 -->
-<plugin
- id="org.eclipse.swt"
- name="%pluginName"
- version="2.1.0"
- provider-name="%providerName">
-
-<!-- Runtime -->
-<runtime>
- <library name="$ws$/swt.jar">
- <export name="*"/>
- <packages prefixes="org.eclipse.swt"/>
- </library>
-</runtime>
-</plugin>
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- File written by PDE 1.0 -->
+<plugin
+ id="org.eclipse.swt"
+ name="%pluginName"
+ version="2.1.0"
+ provider-name="%providerName">
+
+<!-- Runtime -->
+<runtime>
+ <library name="$ws$/swt.jar">
+ <export name="*"/>
+ <packages prefixes="org.eclipse.swt"/>
+ </library>
+</runtime>
+</plugin>
diff --git a/bundles/org.eclipse.swt/readme_swt.html b/bundles/org.eclipse.swt/readme_swt.html
index d02c3485ea..6228263cc3 100755
--- a/bundles/org.eclipse.swt/readme_swt.html
+++ b/bundles/org.eclipse.swt/readme_swt.html
@@ -1,116 +1,116 @@
-<!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.7 [en] (WinNT; I) [Netscape]">
- <title>Eclipse Project SDK R2.0 - SWT Release Notes</title>
-</head>
-<body>
-
-<table COLS=1 WIDTH="604" HEIGHT="45" >
-<tr>
-<td BACKGROUND="workbench.gif"><b>Eclipse Project SDK R2.0 - SWT Release
-Notes</b></td>
-</tr>
-</table>
-
-<h3>
-Notices</h3>
-(c) Copyright IBM Corp. 2000, 2002. All Rights Reserved.
-<h3>
-Table Of Contents</h3>
-&nbsp;1. Known Issues
-<h3>
-1 Known Issues</h3>
-<h4>
-1.1 Available Colors on 8-bit Linux</h4>
-
-Typically, in Gnome Linux installs running with 8 bitplain visuals (i.e. 256 color mode), before the
-Eclipse application is started, you already do not have any free colors. This may mean that Eclipse
-is unable to allocate the default widget background color causing it to display a white background.
-The functionality, however, is not affected.
-
-<h4>
-1.2 Printing Support</h4>
-
-The X printing extension implementation on Linux is currently disabled because
-it can take up to 7 seconds to determine that the X print server is not running.
-Until this is rectified, <code>Printer.getPrinterList()</code> will always return
-an empty array on the Linux platform.</dd>
-
-<h4>
-1.3 List and ComboBox on Windows NT</h4>
-
-On Windows NT only, you should avoid creating items in a List or ComboBox with strings longer than 1000 characters.
-Doing so may result in a General Protection Fault. This has been fixed in more recent versions of Windows.
-
-<h4>
-1.4 BiDi Support</h4>
-
-The StyledText widget now provides bidirectional language support for Hebrew and Arabic locales.
-Currently, this support is available only on win32, and has several known problems. It should be
-considered to be a preliminary implementation only.
-
-<h4>
-1.5 Cursor constructor arguments</h4>
-
-In the constructor Cursor(Device device, ImageData source, ImageData mask, int hotspotX, int hotspotY),
-when both a source and mask argument are specified (i.e. mask is not null), the meaning of the two arguments
-is reversed. That is, the "mask" argument should be the source image and the "source" argument should be
-the mask image. For a description of this issue see bugzilla report #4809.
-
-<h4>
-1.6 ToolBar on Windows</h4>
-
-On Windows, you must create all tool bars with the FLAT style bit set. If you do not do this,
-the "hot" (rollover) images of <em>all</em> toolbars may display incorrectly.
-This will be fixed in a future release.
-
-<h4>
-1.7 Non ASCII strings on Linux</h4>
-
-On Linux RedHat 6.2 only, you will not be able to display text that contains non
-ASCII characters. This limitation is not present on Linux RedHat 7.1 or higher.
-
-<h4>
-1.8 Using J9 VM on Photon and AIX</h4>
-
-On Photon and AIX, the SWT library will not be found when running with
-the J9 VM (version 1.5). This is a bug in the J9 classes library. You
-can workaround this problem by adding the SWT library directory to your
-load library path.
-
-<h4>
-1.9 Javadoc not consistent across platforms</h4>
-
-Because of a bug in the way we updated the javadoc in our source code,
-the javadoc for protected methods is not consistent across platforms.
-The javadoc for the Windows platform, which is used to generate the
-documentation that appears in the Platform Plug-in Developer guide,
-is the definitive source. This will be fixed in a future release.
-
-<h4>
-1.10 JAWS requires MSAA for List Views to read checkboxes in Tables</h4>
-
-In order for JAWS to detect the checkbox information in Tables,
-MSAA support for List Views must be activated as follows:
-
-<ol>
-<li>Open Eclipse and hit INSERT + F2.
-<li>In the "Run JAWS Manager" dialog select "Configuration Manager".
-<li>In the "Jaws Configuration Manager" that opens up, select "Set Options" and then select "Advanced Options".
-<li>Check "Rely on MSAA for List views".
-<li>Hit the OK button.
-<li>Choose File -> Save from the menu bar.
-</ol>
-
-<h4>
-1.11 Combo boxes with multi-line items on Linux/Motif</h4>
-
-The Linux implementation of Motif has a bug that causes program execution to terminate
-if the value of an editable Combo is set through Combo.setText(String) to a string
-that contains five or more newline characters.
-
-<p><a href="hglegal.htm"><img SRC="ngibmcpy.gif" BORDER=0 height=12 width=195></a>
-</body>
-</html>
+<!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.7 [en] (WinNT; I) [Netscape]">
+ <title>Eclipse Project SDK R2.0 - SWT Release Notes</title>
+</head>
+<body>
+
+<table COLS=1 WIDTH="604" HEIGHT="45" >
+<tr>
+<td BACKGROUND="workbench.gif"><b>Eclipse Project SDK R2.0 - SWT Release
+Notes</b></td>
+</tr>
+</table>
+
+<h3>
+Notices</h3>
+(c) Copyright IBM Corp. 2000, 2002. All Rights Reserved.
+<h3>
+Table Of Contents</h3>
+&nbsp;1. Known Issues
+<h3>
+1 Known Issues</h3>
+<h4>
+1.1 Available Colors on 8-bit Linux</h4>
+
+Typically, in Gnome Linux installs running with 8 bitplain visuals (i.e. 256 color mode), before the
+Eclipse application is started, you already do not have any free colors. This may mean that Eclipse
+is unable to allocate the default widget background color causing it to display a white background.
+The functionality, however, is not affected.
+
+<h4>
+1.2 Printing Support</h4>
+
+The X printing extension implementation on Linux is currently disabled because
+it can take up to 7 seconds to determine that the X print server is not running.
+Until this is rectified, <code>Printer.getPrinterList()</code> will always return
+an empty array on the Linux platform.</dd>
+
+<h4>
+1.3 List and ComboBox on Windows NT</h4>
+
+On Windows NT only, you should avoid creating items in a List or ComboBox with strings longer than 1000 characters.
+Doing so may result in a General Protection Fault. This has been fixed in more recent versions of Windows.
+
+<h4>
+1.4 BiDi Support</h4>
+
+The StyledText widget now provides bidirectional language support for Hebrew and Arabic locales.
+Currently, this support is available only on win32, and has several known problems. It should be
+considered to be a preliminary implementation only.
+
+<h4>
+1.5 Cursor constructor arguments</h4>
+
+In the constructor Cursor(Device device, ImageData source, ImageData mask, int hotspotX, int hotspotY),
+when both a source and mask argument are specified (i.e. mask is not null), the meaning of the two arguments
+is reversed. That is, the "mask" argument should be the source image and the "source" argument should be
+the mask image. For a description of this issue see bugzilla report #4809.
+
+<h4>
+1.6 ToolBar on Windows</h4>
+
+On Windows, you must create all tool bars with the FLAT style bit set. If you do not do this,
+the "hot" (rollover) images of <em>all</em> toolbars may display incorrectly.
+This will be fixed in a future release.
+
+<h4>
+1.7 Non ASCII strings on Linux</h4>
+
+On Linux RedHat 6.2 only, you will not be able to display text that contains non
+ASCII characters. This limitation is not present on Linux RedHat 7.1 or higher.
+
+<h4>
+1.8 Using J9 VM on Photon and AIX</h4>
+
+On Photon and AIX, the SWT library will not be found when running with
+the J9 VM (version 1.5). This is a bug in the J9 classes library. You
+can workaround this problem by adding the SWT library directory to your
+load library path.
+
+<h4>
+1.9 Javadoc not consistent across platforms</h4>
+
+Because of a bug in the way we updated the javadoc in our source code,
+the javadoc for protected methods is not consistent across platforms.
+The javadoc for the Windows platform, which is used to generate the
+documentation that appears in the Platform Plug-in Developer guide,
+is the definitive source. This will be fixed in a future release.
+
+<h4>
+1.10 JAWS requires MSAA for List Views to read checkboxes in Tables</h4>
+
+In order for JAWS to detect the checkbox information in Tables,
+MSAA support for List Views must be activated as follows:
+
+<ol>
+<li>Open Eclipse and hit INSERT + F2.
+<li>In the "Run JAWS Manager" dialog select "Configuration Manager".
+<li>In the "Jaws Configuration Manager" that opens up, select "Set Options" and then select "Advanced Options".
+<li>Check "Rely on MSAA for List views".
+<li>Hit the OK button.
+<li>Choose File -> Save from the menu bar.
+</ol>
+
+<h4>
+1.11 Combo boxes with multi-line items on Linux/Motif</h4>
+
+The Linux implementation of Motif has a bug that causes program execution to terminate
+if the value of an editable Combo is set through Combo.setText(String) to a string
+that contains five or more newline characters.
+
+<p><a href="hglegal.htm"><img SRC="ngibmcpy.gif" BORDER=0 height=12 width=195></a>
+</body>
+</html>

Back to the top